Merge remote-tracking branch 'arm64/for-next/fixes' into for-next/core
authorCatalin Marinas <catalin.marinas@arm.com>
Wed, 9 Dec 2020 18:04:55 +0000 (18:04 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 9 Dec 2020 18:04:55 +0000 (18:04 +0000)
* arm64/for-next/fixes: (26 commits)
  arm64: mte: fix prctl(PR_GET_TAGGED_ADDR_CTRL) if TCF0=NONE
  arm64: mte: Fix typo in macro definition
  arm64: entry: fix EL1 debug transitions
  arm64: entry: fix NMI {user, kernel}->kernel transitions
  arm64: entry: fix non-NMI kernel<->kernel transitions
  arm64: ptrace: prepare for EL1 irq/rcu tracking
  arm64: entry: fix non-NMI user<->kernel transitions
  arm64: entry: move el1 irq/nmi logic to C
  arm64: entry: prepare ret_to_user for function call
  arm64: entry: move enter_from_user_mode to entry-common.c
  arm64: entry: mark entry code as noinstr
  arm64: mark idle code as noinstr
  arm64: syscall: exit userspace before unmasking exceptions
  arm64: pgtable: Ensure dirty bit is preserved across pte_wrprotect()
  arm64: pgtable: Fix pte_accessible()
  ACPI/IORT: Fix doc warnings in iort.c
  arm64/fpsimd: add <asm/insn.h> to <asm/kprobes.h> to fix fpsimd build
  arm64: cpu_errata: Apply Erratum 845719 to KRYO2XX Silver
  arm64: proton-pack: Add KRYO2XX silver CPUs to spectre-v2 safe-list
  arm64: kpti: Add KRYO2XX gold/silver CPU cores to kpti safelist
  ...

# Conflicts:
# arch/arm64/include/asm/exception.h
# arch/arm64/kernel/sdei.c

1343 files changed:
CREDITS
Documentation/ABI/README
Documentation/ABI/obsolete/sysfs-class-dax
Documentation/ABI/obsolete/sysfs-driver-hid-roccat-pyra
Documentation/ABI/obsolete/sysfs-gpio
Documentation/ABI/removed/devfs
Documentation/ABI/removed/raw1394
Documentation/ABI/removed/sysfs-class-rfkill
Documentation/ABI/removed/video1394
Documentation/ABI/stable/firewire-cdev
Documentation/ABI/stable/sysfs-acpi-pmprofile
Documentation/ABI/stable/sysfs-bus-firewire
Documentation/ABI/stable/sysfs-bus-nvmem
Documentation/ABI/stable/sysfs-bus-usb
Documentation/ABI/stable/sysfs-bus-vmbus
Documentation/ABI/stable/sysfs-bus-w1
Documentation/ABI/stable/sysfs-class-backlight
Documentation/ABI/stable/sysfs-class-infiniband
Documentation/ABI/stable/sysfs-class-rfkill
Documentation/ABI/stable/sysfs-class-tpm
Documentation/ABI/stable/sysfs-devices
Documentation/ABI/stable/sysfs-driver-dma-ioatdma
Documentation/ABI/stable/sysfs-driver-firmware-zynqmp
Documentation/ABI/stable/sysfs-driver-ib_srp
Documentation/ABI/stable/sysfs-driver-speakup
Documentation/ABI/stable/sysfs-firmware-efi-vars
Documentation/ABI/stable/sysfs-firmware-opal-dump
Documentation/ABI/stable/sysfs-firmware-opal-elog
Documentation/ABI/stable/sysfs-hypervisor-xen
Documentation/ABI/stable/vdso
Documentation/ABI/testing/configfs-acpi
Documentation/ABI/testing/configfs-most
Documentation/ABI/testing/configfs-spear-pcie-gadget
Documentation/ABI/testing/configfs-usb-gadget
Documentation/ABI/testing/configfs-usb-gadget-ecm
Documentation/ABI/testing/configfs-usb-gadget-eem
Documentation/ABI/testing/configfs-usb-gadget-hid
Documentation/ABI/testing/configfs-usb-gadget-loopback
Documentation/ABI/testing/configfs-usb-gadget-mass-storage
Documentation/ABI/testing/configfs-usb-gadget-midi
Documentation/ABI/testing/configfs-usb-gadget-printer
Documentation/ABI/testing/configfs-usb-gadget-rndis
Documentation/ABI/testing/configfs-usb-gadget-sourcesink
Documentation/ABI/testing/configfs-usb-gadget-subset
Documentation/ABI/testing/configfs-usb-gadget-uac1
Documentation/ABI/testing/configfs-usb-gadget-uac2
Documentation/ABI/testing/configfs-usb-gadget-uvc
Documentation/ABI/testing/debugfs-cec-error-inj
Documentation/ABI/testing/debugfs-driver-habanalabs
Documentation/ABI/testing/debugfs-ec
Documentation/ABI/testing/debugfs-moxtet
Documentation/ABI/testing/debugfs-pfo-nx-crypto
Documentation/ABI/testing/debugfs-pktcdvd
Documentation/ABI/testing/debugfs-turris-mox-rwtm
Documentation/ABI/testing/debugfs-wilco-ec
Documentation/ABI/testing/dell-smbios-wmi
Documentation/ABI/testing/dev-kmsg
Documentation/ABI/testing/evm
Documentation/ABI/testing/gpio-cdev
Documentation/ABI/testing/ima_policy
Documentation/ABI/testing/procfs-diskstats
Documentation/ABI/testing/procfs-smaps_rollup
Documentation/ABI/testing/pstore
Documentation/ABI/testing/sysfs-block
Documentation/ABI/testing/sysfs-block-device
Documentation/ABI/testing/sysfs-block-rnbd
Documentation/ABI/testing/sysfs-bus-acpi
Documentation/ABI/testing/sysfs-bus-coresight-devices-cti
Documentation/ABI/testing/sysfs-bus-coresight-devices-etb10
Documentation/ABI/testing/sysfs-bus-coresight-devices-etm3x
Documentation/ABI/testing/sysfs-bus-coresight-devices-etm4x
Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
Documentation/ABI/testing/sysfs-bus-coresight-devices-tmc
Documentation/ABI/testing/sysfs-bus-css
Documentation/ABI/testing/sysfs-bus-dfl
Documentation/ABI/testing/sysfs-bus-event_source-devices-dfl_fme
Documentation/ABI/testing/sysfs-bus-event_source-devices-format
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_gpci
Documentation/ABI/testing/sysfs-bus-fcoe
Documentation/ABI/testing/sysfs-bus-fsl-mc
Documentation/ABI/testing/sysfs-bus-i2c-devices-fsa9480
Documentation/ABI/testing/sysfs-bus-i2c-devices-pca954x
Documentation/ABI/testing/sysfs-bus-i3c
Documentation/ABI/testing/sysfs-bus-iio
Documentation/ABI/testing/sysfs-bus-iio-adc-envelope-detector
Documentation/ABI/testing/sysfs-bus-iio-adc-hi8435
Documentation/ABI/testing/sysfs-bus-iio-adc-stm32
Documentation/ABI/testing/sysfs-bus-iio-cros-ec
Documentation/ABI/testing/sysfs-bus-iio-dfsdm-adc-stm32
Documentation/ABI/testing/sysfs-bus-iio-distance-srf08
Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523
Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4371
Documentation/ABI/testing/sysfs-bus-iio-health-afe440x
Documentation/ABI/testing/sysfs-bus-iio-light-isl29018
Documentation/ABI/testing/sysfs-bus-iio-lptimer-stm32
Documentation/ABI/testing/sysfs-bus-iio-magnetometer-hmc5843
Documentation/ABI/testing/sysfs-bus-iio-temperature-max31856
Documentation/ABI/testing/sysfs-bus-iio-timer-stm32
Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth
Documentation/ABI/testing/sysfs-bus-intel_th-devices-msc
Documentation/ABI/testing/sysfs-bus-most
Documentation/ABI/testing/sysfs-bus-moxtet-devices
Documentation/ABI/testing/sysfs-bus-nfit
Documentation/ABI/testing/sysfs-bus-nvdimm
Documentation/ABI/testing/sysfs-bus-papr-pmem
Documentation/ABI/testing/sysfs-bus-pci
Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats
Documentation/ABI/testing/sysfs-bus-pci-devices-catpt
Documentation/ABI/testing/sysfs-bus-pci-drivers-ehci_hcd
Documentation/ABI/testing/sysfs-bus-rapidio
Documentation/ABI/testing/sysfs-bus-rbd
Documentation/ABI/testing/sysfs-bus-siox
Documentation/ABI/testing/sysfs-bus-thunderbolt
Documentation/ABI/testing/sysfs-bus-usb
Documentation/ABI/testing/sysfs-bus-usb-devices-usbsevseg
Documentation/ABI/testing/sysfs-bus-vfio-mdev
Documentation/ABI/testing/sysfs-c2port
Documentation/ABI/testing/sysfs-class-backlight
Documentation/ABI/testing/sysfs-class-backlight-adp8860
Documentation/ABI/testing/sysfs-class-backlight-driver-adp8870
Documentation/ABI/testing/sysfs-class-backlight-driver-lm3533
Documentation/ABI/testing/sysfs-class-bdi
Documentation/ABI/testing/sysfs-class-chromeos
Documentation/ABI/testing/sysfs-class-cxl
Documentation/ABI/testing/sysfs-class-devfreq
Documentation/ABI/testing/sysfs-class-devlink
Documentation/ABI/testing/sysfs-class-extcon
Documentation/ABI/testing/sysfs-class-fpga-manager
Documentation/ABI/testing/sysfs-class-gnss
Documentation/ABI/testing/sysfs-class-led
Documentation/ABI/testing/sysfs-class-led-driver-el15203000
Documentation/ABI/testing/sysfs-class-led-driver-lm3533
Documentation/ABI/testing/sysfs-class-led-driver-sc27xx [deleted file]
Documentation/ABI/testing/sysfs-class-led-flash
Documentation/ABI/testing/sysfs-class-led-multicolor
Documentation/ABI/testing/sysfs-class-led-trigger-netdev
Documentation/ABI/testing/sysfs-class-led-trigger-pattern
Documentation/ABI/testing/sysfs-class-led-trigger-usbport
Documentation/ABI/testing/sysfs-class-leds-gt683r
Documentation/ABI/testing/sysfs-class-mic
Documentation/ABI/testing/sysfs-class-net
Documentation/ABI/testing/sysfs-class-net-cdc_ncm
Documentation/ABI/testing/sysfs-class-net-phydev
Documentation/ABI/testing/sysfs-class-ocxl
Documentation/ABI/testing/sysfs-class-pktcdvd
Documentation/ABI/testing/sysfs-class-power
Documentation/ABI/testing/sysfs-class-power-mp2629
Documentation/ABI/testing/sysfs-class-power-twl4030
Documentation/ABI/testing/sysfs-class-power-wilco
Documentation/ABI/testing/sysfs-class-rapidio
Documentation/ABI/testing/sysfs-class-rc
Documentation/ABI/testing/sysfs-class-regulator
Documentation/ABI/testing/sysfs-class-remoteproc
Documentation/ABI/testing/sysfs-class-rnbd-client
Documentation/ABI/testing/sysfs-class-rtc-rtc0-device-rtc_calibration
Documentation/ABI/testing/sysfs-class-rtrs-client
Documentation/ABI/testing/sysfs-class-scsi_host
Documentation/ABI/testing/sysfs-class-typec
Documentation/ABI/testing/sysfs-class-uwb_rc
Documentation/ABI/testing/sysfs-class-watchdog
Documentation/ABI/testing/sysfs-dev
Documentation/ABI/testing/sysfs-devices-mapping
Documentation/ABI/testing/sysfs-devices-memory
Documentation/ABI/testing/sysfs-devices-platform-ACPI-TAD
Documentation/ABI/testing/sysfs-devices-platform-_UDC_-gadget
Documentation/ABI/testing/sysfs-devices-platform-docg3
Documentation/ABI/testing/sysfs-devices-platform-ipmi
Documentation/ABI/testing/sysfs-devices-platform-sh_mobile_lcdc_fb
Documentation/ABI/testing/sysfs-devices-platform-stratix10-rsu
Documentation/ABI/testing/sysfs-devices-system-cpu
Documentation/ABI/testing/sysfs-devices-system-ibm-rtl
Documentation/ABI/testing/sysfs-driver-bd9571mwv-regulator
Documentation/ABI/testing/sysfs-driver-genwqe
Documentation/ABI/testing/sysfs-driver-hid-lenovo
Documentation/ABI/testing/sysfs-driver-hid-logitech-lg4ff
Documentation/ABI/testing/sysfs-driver-hid-ntrig
Documentation/ABI/testing/sysfs-driver-hid-roccat-kone
Documentation/ABI/testing/sysfs-driver-hid-wiimote
Documentation/ABI/testing/sysfs-driver-input-exc3000
Documentation/ABI/testing/sysfs-driver-jz4780-efuse
Documentation/ABI/testing/sysfs-driver-pciback
Documentation/ABI/testing/sysfs-driver-samsung-laptop
Documentation/ABI/testing/sysfs-driver-toshiba_acpi
Documentation/ABI/testing/sysfs-driver-toshiba_haps
Documentation/ABI/testing/sysfs-driver-ufs
Documentation/ABI/testing/sysfs-driver-w1_ds28e17
Documentation/ABI/testing/sysfs-driver-w1_therm
Documentation/ABI/testing/sysfs-driver-wacom
Documentation/ABI/testing/sysfs-firmware-acpi
Documentation/ABI/testing/sysfs-firmware-dmi-entries
Documentation/ABI/testing/sysfs-firmware-efi-esrt
Documentation/ABI/testing/sysfs-firmware-efi-runtime-map
Documentation/ABI/testing/sysfs-firmware-gsmi
Documentation/ABI/testing/sysfs-firmware-memmap
Documentation/ABI/testing/sysfs-firmware-qemu_fw_cfg
Documentation/ABI/testing/sysfs-firmware-sfi
Documentation/ABI/testing/sysfs-firmware-sgi_uv
Documentation/ABI/testing/sysfs-firmware-turris-mox-rwtm
Documentation/ABI/testing/sysfs-fs-ext4
Documentation/ABI/testing/sysfs-fs-f2fs
Documentation/ABI/testing/sysfs-hypervisor-xen
Documentation/ABI/testing/sysfs-kernel-boot_params
Documentation/ABI/testing/sysfs-kernel-mm-hugepages
Documentation/ABI/testing/sysfs-kernel-mm-ksm
Documentation/ABI/testing/sysfs-kernel-slab
Documentation/ABI/testing/sysfs-module
Documentation/ABI/testing/sysfs-platform-asus-laptop
Documentation/ABI/testing/sysfs-platform-asus-wmi
Documentation/ABI/testing/sysfs-platform-at91
Documentation/ABI/testing/sysfs-platform-dell-laptop
Documentation/ABI/testing/sysfs-platform-dell-smbios
Documentation/ABI/testing/sysfs-platform-dfl-fme
Documentation/ABI/testing/sysfs-platform-dptf
Documentation/ABI/testing/sysfs-platform-eeepc-laptop
Documentation/ABI/testing/sysfs-platform-i2c-demux-pinctrl
Documentation/ABI/testing/sysfs-platform-ideapad-laptop
Documentation/ABI/testing/sysfs-platform-intel-wmi-sbl-fw-update
Documentation/ABI/testing/sysfs-platform-intel-wmi-thunderbolt
Documentation/ABI/testing/sysfs-platform-kim
Documentation/ABI/testing/sysfs-platform-mellanox-bootctl
Documentation/ABI/testing/sysfs-platform-phy-rcar-gen3-usb2
Documentation/ABI/testing/sysfs-platform-renesas_usb3
Documentation/ABI/testing/sysfs-platform-sst-atom
Documentation/ABI/testing/sysfs-platform-usbip-vudc
Documentation/ABI/testing/sysfs-platform-wilco-ec
Documentation/ABI/testing/sysfs-power
Documentation/ABI/testing/sysfs-profiling
Documentation/ABI/testing/sysfs-ptp
Documentation/ABI/testing/sysfs-uevent
Documentation/ABI/testing/sysfs-wusb_cbaf
Documentation/ABI/testing/usb-charger-uevent
Documentation/ABI/testing/usb-uevent
Documentation/Kconfig
Documentation/Makefile
Documentation/admin-guide/LSM/SafeSetID.rst
Documentation/admin-guide/abi-obsolete.rst [new file with mode: 0644]
Documentation/admin-guide/abi-removed.rst [new file with mode: 0644]
Documentation/admin-guide/abi-stable.rst [new file with mode: 0644]
Documentation/admin-guide/abi-testing.rst [new file with mode: 0644]
Documentation/admin-guide/abi.rst [new file with mode: 0644]
Documentation/admin-guide/index.rst
Documentation/admin-guide/pm/cpuidle.rst
Documentation/admin-guide/sysctl/net.rst
Documentation/arm/sunxi.rst
Documentation/arm64/kasan-offsets.sh
Documentation/arm64/memory.rst
Documentation/arm64/tagged-pointers.rst
Documentation/conf.py
Documentation/dev-tools/kasan.rst
Documentation/dev-tools/kunit/start.rst
Documentation/dev-tools/kunit/usage.rst
Documentation/devicetree/bindings/arm/actions.yaml
Documentation/devicetree/bindings/arm/altera.yaml
Documentation/devicetree/bindings/arm/amazon,al.yaml
Documentation/devicetree/bindings/arm/amlogic.yaml
Documentation/devicetree/bindings/arm/arm,integrator.yaml
Documentation/devicetree/bindings/arm/arm,realview.yaml
Documentation/devicetree/bindings/arm/arm,versatile.yaml
Documentation/devicetree/bindings/arm/arm,vexpress-juno.yaml
Documentation/devicetree/bindings/arm/atmel-at91.yaml
Documentation/devicetree/bindings/arm/axxia.yaml
Documentation/devicetree/bindings/arm/bcm/bcm2835.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,bcm11351.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,bcm21664.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,bcm23550.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,bcm4708.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,cygnus.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,hr2.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,ns2.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,nsp.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,stingray.yaml
Documentation/devicetree/bindings/arm/bcm/brcm,vulcan-soc.yaml
Documentation/devicetree/bindings/arm/bitmain.yaml
Documentation/devicetree/bindings/arm/calxeda.yaml
Documentation/devicetree/bindings/arm/digicolor.yaml
Documentation/devicetree/bindings/arm/fsl.yaml
Documentation/devicetree/bindings/arm/hisilicon/hisilicon.yaml
Documentation/devicetree/bindings/arm/intel,keembay.yaml
Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml
Documentation/devicetree/bindings/arm/keystone/ti,k3-sci-common.yaml
Documentation/devicetree/bindings/arm/marvell/armada-7k-8k.yaml
Documentation/devicetree/bindings/arm/mediatek.yaml
Documentation/devicetree/bindings/arm/microchip,sparx5.yaml
Documentation/devicetree/bindings/arm/moxart.yaml
Documentation/devicetree/bindings/arm/mrvl/mrvl.yaml
Documentation/devicetree/bindings/arm/mstar/mstar.yaml
Documentation/devicetree/bindings/arm/nxp/lpc32xx.yaml
Documentation/devicetree/bindings/arm/qcom.yaml
Documentation/devicetree/bindings/arm/rda.yaml
Documentation/devicetree/bindings/arm/realtek.yaml
Documentation/devicetree/bindings/arm/renesas.yaml
Documentation/devicetree/bindings/arm/rockchip.yaml
Documentation/devicetree/bindings/arm/samsung/samsung-boards.yaml
Documentation/devicetree/bindings/arm/sirf.yaml
Documentation/devicetree/bindings/arm/socionext/milbeaut.yaml
Documentation/devicetree/bindings/arm/socionext/uniphier.yaml
Documentation/devicetree/bindings/arm/spear.yaml
Documentation/devicetree/bindings/arm/sprd/sprd.yaml
Documentation/devicetree/bindings/arm/sti.yaml
Documentation/devicetree/bindings/arm/stm32/stm32.yaml
Documentation/devicetree/bindings/arm/sunxi.yaml
Documentation/devicetree/bindings/arm/tegra.yaml
Documentation/devicetree/bindings/arm/ti/k3.yaml
Documentation/devicetree/bindings/arm/ti/nspire.yaml
Documentation/devicetree/bindings/arm/ti/ti,davinci.yaml
Documentation/devicetree/bindings/arm/toshiba.yaml
Documentation/devicetree/bindings/arm/ux500.yaml
Documentation/devicetree/bindings/arm/vt8500.yaml
Documentation/devicetree/bindings/arm/xilinx.yaml
Documentation/devicetree/bindings/arm/zte.yaml
Documentation/devicetree/bindings/clock/hi6220-clock.txt
Documentation/devicetree/bindings/display/bridge/toshiba,tc358775.yaml
Documentation/devicetree/bindings/display/panel/ilitek,ili9881c.yaml
Documentation/devicetree/bindings/display/panel/mantix,mlaf057we51-x.yaml
Documentation/devicetree/bindings/edac/amazon,al-mc-edac.yaml
Documentation/devicetree/bindings/eeprom/at25.yaml
Documentation/devicetree/bindings/gpio/kontron,sl28cpld-gpio.yaml
Documentation/devicetree/bindings/i2c/google,cros-ec-i2c-tunnel.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/i2c/i2c-cros-ec-tunnel.txt [deleted file]
Documentation/devicetree/bindings/i2c/ingenic,i2c.yaml
Documentation/devicetree/bindings/iio/adc/adi,ad7291.yaml
Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml
Documentation/devicetree/bindings/iio/adc/cosmic,10001-adc.yaml
Documentation/devicetree/bindings/iio/adc/holt,hi8435.yaml
Documentation/devicetree/bindings/iio/adc/lltc,ltc2497.yaml
Documentation/devicetree/bindings/iio/humidity/ti,hdc2010.yaml
Documentation/devicetree/bindings/input/cros-ec-keyb.txt [deleted file]
Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/interrupt-controller/ti,pruss-intc.yaml
Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml
Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml
Documentation/devicetree/bindings/leds/backlight/common.yaml
Documentation/devicetree/bindings/leds/common.yaml
Documentation/devicetree/bindings/leds/leds-class-multicolor.yaml
Documentation/devicetree/bindings/leds/leds-lp50xx.yaml
Documentation/devicetree/bindings/mailbox/mtk-gce.txt
Documentation/devicetree/bindings/mfd/ene-kb3930.yaml
Documentation/devicetree/bindings/mfd/google,cros-ec.yaml
Documentation/devicetree/bindings/mips/ingenic/devices.yaml
Documentation/devicetree/bindings/mips/loongson/devices.yaml
Documentation/devicetree/bindings/mmc/arasan,sdhci.yaml
Documentation/devicetree/bindings/mmc/microchip,dw-sparx5-sdhci.yaml
Documentation/devicetree/bindings/mmc/sdhci-am654.yaml
Documentation/devicetree/bindings/net/can/can-controller.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/net/can/fsl-flexcan.txt [deleted file]
Documentation/devicetree/bindings/net/intel,dwmac-plat.yaml
Documentation/devicetree/bindings/net/ti,dp83822.yaml
Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml
Documentation/devicetree/bindings/phy/socionext,uniphier-ahci-phy.yaml
Documentation/devicetree/bindings/phy/ti,omap-usb2.yaml
Documentation/devicetree/bindings/pinctrl/actions,s500-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/pinctrl-mt8192.yaml
Documentation/devicetree/bindings/pinctrl/qcom,msm8226-pinctrl.yaml
Documentation/devicetree/bindings/pinctrl/toshiba,visconti-pinctrl.yaml
Documentation/devicetree/bindings/power/reset/reboot-mode.yaml
Documentation/devicetree/bindings/power/supply/ingenic,battery.yaml
Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
Documentation/devicetree/bindings/regulator/mps,mp886x.yaml
Documentation/devicetree/bindings/regulator/pfuze100.yaml
Documentation/devicetree/bindings/riscv/sifive-l2-cache.yaml
Documentation/devicetree/bindings/riscv/sifive.yaml
Documentation/devicetree/bindings/rng/imx-rng.yaml
Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
Documentation/devicetree/bindings/sound/google,cros-ec-codec.yaml
Documentation/devicetree/bindings/sound/mchp,spdifrx.yaml
Documentation/devicetree/bindings/sound/mchp,spdiftx.yaml
Documentation/devicetree/bindings/sound/qcom,lpass-cpu.yaml
Documentation/devicetree/bindings/sound/realtek,rt1015p.yaml
Documentation/devicetree/bindings/sram/allwinner,sun4i-a10-system-control.yaml
Documentation/devicetree/bindings/timer/arm,sp804.yaml
Documentation/devicetree/bindings/usb/cdns,usb3.yaml
Documentation/devicetree/bindings/usb/ti,hd3ss3220.yaml
Documentation/devicetree/bindings/w1/fsl-imx-owire.yaml
Documentation/filesystems/api-summary.rst
Documentation/filesystems/debugfs.rst
Documentation/gpu/amdgpu.rst
Documentation/hwmon/adm1266.rst
Documentation/hwmon/index.rst
Documentation/hwmon/mp2975.rst
Documentation/leds/index.rst
Documentation/leds/leds-el15203000.rst [new file with mode: 0644]
Documentation/leds/leds-sc27xx.rst [new file with mode: 0644]
Documentation/locking/lockdep-design.rst
Documentation/misc-devices/index.rst
Documentation/misc-devices/mic/index.rst [deleted file]
Documentation/misc-devices/mic/mic_overview.rst [deleted file]
Documentation/misc-devices/mic/scif_overview.rst [deleted file]
Documentation/networking/devlink/ice.rst
Documentation/networking/j1939.rst
Documentation/networking/statistics.rst
Documentation/sphinx/automarkup.py
Documentation/sphinx/kernel_abi.py [new file with mode: 0644]
Documentation/sphinx/kernellog.py
Documentation/userspace-api/index.rst
Documentation/virt/kvm/cpuid.rst
MAINTAINERS
Makefile
arch/alpha/include/uapi/asm/signal.h
arch/arc/kernel/head.S
arch/arc/kernel/stacktrace.c
arch/arc/plat-hsdk/platform.c
arch/arm/boot/dts/mmp2-olpc-xo-1-75.dts
arch/arm/boot/dts/mmp3.dtsi
arch/arm/boot/dts/stm32mp157c-ed1.dts
arch/arm/boot/dts/stm32mp15xx-dkx.dtsi
arch/arm/boot/dts/sun4i-a10.dtsi
arch/arm/configs/imx_v4_v5_defconfig
arch/arm/configs/imx_v6_v7_defconfig
arch/arm/configs/multi_v5_defconfig
arch/arm/configs/multi_v7_defconfig
arch/arm/include/asm/signal.h
arch/arm/include/uapi/asm/signal.h
arch/arm/kernel/vmlinux.lds.S
arch/arm/mach-mvebu/coherency_ll.S
arch/arm/mm/init.c
arch/arm64/Kconfig
arch/arm64/Kconfig.platforms
arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
arch/arm64/boot/dts/amlogic/meson-axg.dtsi
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi
arch/arm64/boot/dts/amlogic/meson-g12b-odroid-n2-plus.dts
arch/arm64/boot/dts/amlogic/meson-gx.dtsi
arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7-emmc.dts
arch/arm64/boot/dts/marvell/armada-3720-espressobin-v7.dts
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dtsi
arch/arm64/configs/defconfig
arch/arm64/include/asm/alternative-macros.h [new file with mode: 0644]
arch/arm64/include/asm/alternative.h
arch/arm64/include/asm/asm-uaccess.h
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/exception.h
arch/arm64/include/asm/exec.h
arch/arm64/include/asm/futex.h
arch/arm64/include/asm/insn.h
arch/arm64/include/asm/kernel-pgtable.h
arch/arm64/include/asm/kprobes.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/include/asm/memory.h
arch/arm64/include/asm/mmu_context.h
arch/arm64/include/asm/pgtable-hwdef.h
arch/arm64/include/asm/pgtable.h
arch/arm64/include/asm/processor.h
arch/arm64/include/asm/ptrace.h
arch/arm64/include/asm/rwonce.h [new file with mode: 0644]
arch/arm64/include/asm/signal.h [new file with mode: 0644]
arch/arm64/include/asm/sysreg.h
arch/arm64/include/asm/system_misc.h
arch/arm64/include/asm/thread_info.h
arch/arm64/include/asm/topology.h
arch/arm64/include/asm/traps.h
arch/arm64/include/asm/uaccess.h
arch/arm64/include/asm/virt.h
arch/arm64/kernel/Makefile
arch/arm64/kernel/alternative.c
arch/arm64/kernel/armv8_deprecated.c
arch/arm64/kernel/asm-offsets.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/debug-monitors.c
arch/arm64/kernel/efi-header.S
arch/arm64/kernel/entry-common.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/head.S
arch/arm64/kernel/image-vars.h
arch/arm64/kernel/irq.c
arch/arm64/kernel/kaslr.c
arch/arm64/kernel/perf_event.c
arch/arm64/kernel/probes/kprobes.c
arch/arm64/kernel/process.c
arch/arm64/kernel/proton-pack.c
arch/arm64/kernel/ptrace.c
arch/arm64/kernel/scs.c [deleted file]
arch/arm64/kernel/sdei.c
arch/arm64/kernel/setup.c
arch/arm64/kernel/signal.c
arch/arm64/kernel/sleep.S
arch/arm64/kernel/smp.c
arch/arm64/kernel/suspend.c
arch/arm64/kernel/sys_compat.c
arch/arm64/kernel/syscall.c
arch/arm64/kernel/topology.c
arch/arm64/kernel/traps.c
arch/arm64/kernel/vdso/Makefile
arch/arm64/kernel/vdso32/Makefile
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/kvm/arm.c
arch/arm64/kvm/hyp/nvhe/host.S
arch/arm64/kvm/hyp/nvhe/hyp-init.S
arch/arm64/kvm/hyp/nvhe/tlb.c
arch/arm64/kvm/hyp/pgtable.c
arch/arm64/kvm/mmu.c
arch/arm64/kvm/sys_regs.c
arch/arm64/lib/clear_user.S
arch/arm64/lib/copy_from_user.S
arch/arm64/lib/copy_in_user.S
arch/arm64/lib/copy_to_user.S
arch/arm64/lib/mte.S
arch/arm64/lib/uaccess_flushcache.c
arch/arm64/mm/fault.c
arch/arm64/mm/init.c
arch/arm64/mm/mmu.c
arch/arm64/mm/proc.S
arch/h8300/include/uapi/asm/signal.h
arch/ia64/include/uapi/asm/signal.h
arch/m68k/include/uapi/asm/signal.h
arch/mips/include/uapi/asm/signal.h
arch/parisc/include/asm/signal.h
arch/parisc/include/uapi/asm/signal.h
arch/powerpc/include/asm/nohash/32/kup-8xx.h
arch/powerpc/include/asm/nohash/32/mmu-8xx.h
arch/powerpc/include/asm/nohash/32/pte-8xx.h
arch/powerpc/include/asm/topology.h
arch/powerpc/include/asm/uaccess.h
arch/powerpc/include/uapi/asm/signal.h
arch/powerpc/kernel/eeh_cache.c
arch/powerpc/kernel/head_40x.S
arch/powerpc/kernel/head_8xx.S
arch/powerpc/kernel/head_book3s_32.S
arch/powerpc/kernel/smp.c
arch/riscv/include/asm/uaccess.h
arch/riscv/kernel/ftrace.c
arch/riscv/kernel/head.S
arch/riscv/kernel/vdso/.gitignore
arch/riscv/kernel/vdso/Makefile
arch/riscv/kernel/vdso/so2s.sh [new file with mode: 0755]
arch/riscv/mm/fault.c
arch/riscv/mm/init.c
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
arch/s390/configs/zfcpdump_defconfig
arch/s390/include/asm/pgtable.h
arch/s390/include/asm/sections.h
arch/s390/include/asm/vdso/vdso.h [deleted file]
arch/s390/include/uapi/asm/signal.h
arch/s390/kernel/asm-offsets.c
arch/s390/kernel/smp.c
arch/s390/pci/pci_event.c
arch/sparc/include/uapi/asm/signal.h
arch/um/kernel/skas/clone.c
arch/x86/boot/compressed/ident_map_64.c
arch/x86/boot/compressed/mem_encrypt.S
arch/x86/boot/compressed/misc.h
arch/x86/crypto/poly1305_glue.c
arch/x86/entry/syscalls/syscall_64.tbl
arch/x86/hyperv/hv_apic.c
arch/x86/include/uapi/asm/kvm_para.h
arch/x86/include/uapi/asm/signal.h
arch/x86/kernel/alternative.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/kernel/cpu/bugs.c
arch/x86/kernel/head_64.S
arch/x86/kernel/kexec-bzimage64.c
arch/x86/kernel/sev-es-shared.c
arch/x86/kernel/sev-es.c
arch/x86/kernel/sev_verify_cbit.S [new file with mode: 0644]
arch/x86/kernel/signal_compat.c
arch/x86/kernel/traps.c
arch/x86/kernel/unwind_orc.c
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/spte.c
arch/x86/kvm/mmu/spte.h
arch/x86/kvm/vmx/evmcs.c
arch/x86/kvm/vmx/evmcs.h
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/lib/memcpy_64.S
arch/x86/lib/memmove_64.S
arch/x86/lib/memset_64.S
arch/x86/mm/mem_encrypt.c
arch/x86/um/stub_segv.c
arch/xtensa/include/uapi/asm/signal.h
arch/xtensa/mm/init.c
block/bio.c
block/blk-cgroup.c
block/blk-flush.c
drivers/acpi/arm64/iort.c
drivers/acpi/button.c
drivers/acpi/dock.c
drivers/acpi/nfit/core.c
drivers/ata/sata_nv.c
drivers/base/core.c
drivers/base/dd.c
drivers/base/power/runtime.c
drivers/block/nbd.c
drivers/block/null_blk.h
drivers/block/null_blk_zoned.c
drivers/block/xsysace.c
drivers/bluetooth/btintel.h
drivers/char/tpm/eventlog/efi.c
drivers/char/tpm/tpm_tis.c
drivers/cpufreq/Kconfig
drivers/cpufreq/cpufreq.c
drivers/cpufreq/e_powersaver.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/longhaul.c
drivers/cpufreq/speedstep-lib.c
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-prng.c
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-trng.c
drivers/dma/Kconfig
drivers/dma/Makefile
drivers/dma/mic_x100_dma.c [deleted file]
drivers/dma/mic_x100_dma.h [deleted file]
drivers/firmware/arm_scmi/base.c
drivers/firmware/arm_scmi/clock.c
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c
drivers/firmware/arm_scmi/notify.c
drivers/firmware/arm_scmi/perf.c
drivers/firmware/arm_scmi/reset.c
drivers/firmware/arm_scmi/sensors.c
drivers/firmware/arm_scmi/smc.c
drivers/firmware/arm_sdei.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
drivers/gpu/drm/amd/amdgpu/cik.c
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/psp_v12_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdkfd/kfd_crat.c
drivers/gpu/drm/amd/display/Kconfig
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
drivers/gpu/drm/amd/display/dc/gpio/dcn30/hw_factory_dcn30.c
drivers/gpu/drm/amd/display/dc/gpio/gpio_base.c
drivers/gpu/drm/amd/display/dc/os_types.h
drivers/gpu/drm/amd/display/include/dal_asic_id.h
drivers/gpu/drm/amd/include/amd_shared.h
drivers/gpu/drm/amd/pm/inc/hwmgr.h
drivers/gpu/drm/amd/pm/inc/smumgr.h
drivers/gpu/drm/amd/pm/powerplay/hwmgr/ci_baco.c
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c
drivers/gpu/drm/amd/pm/powerplay/smumgr/smumgr.c
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
drivers/gpu/drm/drm_dp_helper.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_gem.c
drivers/gpu/drm/drm_gem_shmem_helper.c
drivers/gpu/drm/drm_prime.c
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_psr.c
drivers/gpu/drm/i915/gem/i915_gem_domain.c
drivers/gpu/drm/i915/gt/intel_engine.h
drivers/gpu/drm/i915/gt/intel_lrc.c
drivers/gpu/drm/i915/gt/intel_timeline.c
drivers/gpu/drm/i915/gt/intel_timeline_types.h
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/scheduler.c
drivers/gpu/drm/i915/i915_pci.c
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/intel_memory_region.c
drivers/gpu/drm/i915/selftests/intel_memory_region.c
drivers/gpu/drm/i915/selftests/mock_region.c
drivers/gpu/drm/imx/dw_hdmi-imx.c
drivers/gpu/drm/imx/imx-drm-core.c
drivers/gpu/drm/imx/imx-ldb.c
drivers/gpu/drm/imx/imx-tve.c
drivers/gpu/drm/imx/parallel-display.c
drivers/gpu/drm/nouveau/dispnv50/core.h
drivers/gpu/drm/nouveau/dispnv50/core507d.c
drivers/gpu/drm/nouveau/dispnv50/core907d.c
drivers/gpu/drm/nouveau/dispnv50/core917d.c
drivers/gpu/drm/nouveau/include/nvhw/class/cl507d.h
drivers/gpu/drm/nouveau/include/nvhw/class/cl907d.h
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_dp.c
drivers/gpu/drm/nouveau/nouveau_gem.c
drivers/gpu/drm/nouveau/nouveau_svm.c
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
drivers/gpu/drm/panel/panel-mantix-mlaf057we51.c
drivers/gpu/drm/panfrost/panfrost_drv.c
drivers/gpu/drm/panfrost/panfrost_gem.c
drivers/gpu/drm/panfrost/panfrost_gem.h
drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c
drivers/gpu/drm/sun4i/sun4i_frontend.c
drivers/gpu/drm/sun4i/sun4i_frontend.h
drivers/gpu/drm/v3d/v3d_gem.c
drivers/gpu/drm/vc4/vc4_bo.c
drivers/gpu/drm/vc4/vc4_drv.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_gem.c
drivers/gpu/drm/vc4/vc4_hdmi.c
drivers/gpu/drm/vc4/vc4_hvs.c
drivers/gpu/drm/vc4/vc4_kms.c
drivers/gpu/drm/vc4/vc4_v3d.c
drivers/gpu/ipu-v3/ipu-common.c
drivers/hv/hv_balloon.c
drivers/hwtracing/coresight/coresight-core.c
drivers/hwtracing/coresight/coresight-cti-sysfs.c
drivers/hwtracing/coresight/coresight-etm-perf.c
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-designware-slave.c
drivers/i2c/busses/i2c-mlxbf.c
drivers/i2c/busses/i2c-mt65xx.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/idle/intel_idle.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/uverbs_std_types_device.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/qedr/qedr_iw_cm.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h
drivers/infiniband/sw/rdmavt/vt.c
drivers/infiniband/sw/rxe/rxe_av.c
drivers/infiniband/sw/rxe/rxe_net.c
drivers/infiniband/sw/rxe/rxe_verbs.c
drivers/infiniband/sw/siw/siw_main.c
drivers/infiniband/ulp/iser/iser_verbs.c
drivers/infiniband/ulp/rtrs/rtrs-clt.c
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/infiniband/ulp/srpt/ib_srpt.h
drivers/interconnect/core.c
drivers/interconnect/qcom/icc-rpmh.c
drivers/interconnect/qcom/sc7180.c
drivers/interconnect/qcom/sdm845.c
drivers/interconnect/qcom/sm8150.c
drivers/interconnect/qcom/sm8250.c
drivers/iommu/amd/amd_iommu_types.h
drivers/iommu/intel/iommu.c
drivers/iommu/intel/svm.c
drivers/iommu/iommu.c
drivers/irqchip/Kconfig
drivers/irqchip/irq-bcm2836.c
drivers/irqchip/irq-mst-intc.c
drivers/irqchip/irq-renesas-intc-irqpin.c
drivers/irqchip/irq-sifive-plic.c
drivers/irqchip/irq-stm32-exti.c
drivers/irqchip/irq-ti-sci-inta.c
drivers/message/fusion/mptscsih.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/mei/hw.h
drivers/misc/mic/Kconfig [deleted file]
drivers/misc/mic/Makefile [deleted file]
drivers/misc/mic/bus/Makefile [deleted file]
drivers/misc/mic/bus/cosm_bus.c [deleted file]
drivers/misc/mic/bus/cosm_bus.h [deleted file]
drivers/misc/mic/bus/mic_bus.c [deleted file]
drivers/misc/mic/bus/scif_bus.c [deleted file]
drivers/misc/mic/bus/scif_bus.h [deleted file]
drivers/misc/mic/bus/vop_bus.c [deleted file]
drivers/misc/mic/bus/vop_bus.h [deleted file]
drivers/misc/mic/card/Makefile [deleted file]
drivers/misc/mic/card/mic_debugfs.c [deleted file]
drivers/misc/mic/card/mic_device.c [deleted file]
drivers/misc/mic/card/mic_device.h [deleted file]
drivers/misc/mic/card/mic_x100.c [deleted file]
drivers/misc/mic/card/mic_x100.h [deleted file]
drivers/misc/mic/common/mic_dev.h [deleted file]
drivers/misc/mic/cosm/Makefile [deleted file]
drivers/misc/mic/cosm/cosm_debugfs.c [deleted file]
drivers/misc/mic/cosm/cosm_main.c [deleted file]
drivers/misc/mic/cosm/cosm_main.h [deleted file]
drivers/misc/mic/cosm/cosm_scif_server.c [deleted file]
drivers/misc/mic/cosm/cosm_sysfs.c [deleted file]
drivers/misc/mic/cosm_client/Makefile [deleted file]
drivers/misc/mic/cosm_client/cosm_scif_client.c [deleted file]
drivers/misc/mic/host/Makefile [deleted file]
drivers/misc/mic/host/mic_boot.c [deleted file]
drivers/misc/mic/host/mic_debugfs.c [deleted file]
drivers/misc/mic/host/mic_device.h [deleted file]
drivers/misc/mic/host/mic_intr.c [deleted file]
drivers/misc/mic/host/mic_intr.h [deleted file]
drivers/misc/mic/host/mic_main.c [deleted file]
drivers/misc/mic/host/mic_smpt.c [deleted file]
drivers/misc/mic/host/mic_smpt.h [deleted file]
drivers/misc/mic/host/mic_x100.c [deleted file]
drivers/misc/mic/host/mic_x100.h [deleted file]
drivers/misc/mic/scif/Makefile [deleted file]
drivers/misc/mic/scif/scif_api.c [deleted file]
drivers/misc/mic/scif/scif_debugfs.c [deleted file]
drivers/misc/mic/scif/scif_dma.c [deleted file]
drivers/misc/mic/scif/scif_epd.c [deleted file]
drivers/misc/mic/scif/scif_epd.h [deleted file]
drivers/misc/mic/scif/scif_fd.c [deleted file]
drivers/misc/mic/scif/scif_fence.c [deleted file]
drivers/misc/mic/scif/scif_main.c [deleted file]
drivers/misc/mic/scif/scif_main.h [deleted file]
drivers/misc/mic/scif/scif_map.h [deleted file]
drivers/misc/mic/scif/scif_mmap.c [deleted file]
drivers/misc/mic/scif/scif_nm.c [deleted file]
drivers/misc/mic/scif/scif_nodeqp.c [deleted file]
drivers/misc/mic/scif/scif_nodeqp.h [deleted file]
drivers/misc/mic/scif/scif_peer_bus.c [deleted file]
drivers/misc/mic/scif/scif_peer_bus.h [deleted file]
drivers/misc/mic/scif/scif_ports.c [deleted file]
drivers/misc/mic/scif/scif_rb.c [deleted file]
drivers/misc/mic/scif/scif_rb.h [deleted file]
drivers/misc/mic/scif/scif_rma.c [deleted file]
drivers/misc/mic/scif/scif_rma.h [deleted file]
drivers/misc/mic/scif/scif_rma_list.c [deleted file]
drivers/misc/mic/scif/scif_rma_list.h [deleted file]
drivers/misc/mic/vop/Makefile [deleted file]
drivers/misc/mic/vop/vop_debugfs.c [deleted file]
drivers/misc/mic/vop/vop_main.c [deleted file]
drivers/misc/mic/vop/vop_main.h [deleted file]
drivers/misc/mic/vop/vop_vringh.c [deleted file]
drivers/mmc/host/sdhci-esdhc.h
drivers/mmc/host/sdhci-of-esdhc.c
drivers/mmc/host/sdhci.c
drivers/mtd/nand/raw/fsl_ifc_nand.c
drivers/mtd/nand/raw/mxc_nand.c
drivers/mtd/nand/raw/stm32_fmc2_nand.c
drivers/mtd/spi-nor/core.c
drivers/net/can/dev.c
drivers/net/can/flexcan.c
drivers/net/can/peak_canfd/peak_canfd.c
drivers/net/can/rx-offload.c
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
drivers/net/can/spi/mcp251xfd/mcp251xfd-regmap.c
drivers/net/can/ti_hecc.c
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/peak_usb/pcan_usb_fd.c
drivers/net/can/xilinx_can.c
drivers/net/dsa/qca8k.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/cadence/macb_main.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_cm.c
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_hw.c
drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/enetc/enetc_qos.c
drivers/net/ethernet/freescale/fec.h
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/google/gve/gve_adminq.h
drivers/net/ethernet/google/gve/gve_main.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
drivers/net/ethernet/ibm/ibmveth.c
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c
drivers/net/ethernet/pensando/ionic/ionic_dev.c
drivers/net/ethernet/pensando/ionic/ionic_dev.h
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
drivers/net/ethernet/pensando/ionic/ionic_fw.c
drivers/net/ethernet/pensando/ionic/ionic_lif.c
drivers/net/ethernet/pensando/ionic/ionic_main.c
drivers/net/ethernet/pensando/ionic/ionic_stats.h
drivers/net/ethernet/pensando/ionic/ionic_txrx.c
drivers/net/ethernet/pensando/ionic/ionic_txrx.h
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/ti/cpsw_ethtool.c
drivers/net/ethernet/ti/cpsw_priv.c
drivers/net/gtp.c
drivers/net/ipa/gsi_trans.c
drivers/net/phy/sfp.c
drivers/net/usb/qmi_wwan.c
drivers/nvme/host/core.c
drivers/nvme/host/fc.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c
drivers/nvme/target/core.c
drivers/nvme/target/trace.h
drivers/of/address.c
drivers/of/device.c
drivers/of/of_reserved_mem.c
drivers/of/unittest.c
drivers/opp/core.c
drivers/opp/of.c
drivers/pci/controller/dwc/pcie-designware-host.c
drivers/pci/controller/pci-mvebu.c
drivers/pci/pci.c
drivers/perf/Kconfig
drivers/perf/Makefile
drivers/perf/arm_dmc620_pmu.c [new file with mode: 0644]
drivers/perf/arm_dsu_pmu.c
drivers/perf/arm_pmu.c
drivers/perf/arm_smmuv3_pmu.c
drivers/perf/fsl_imx8_ddr_perf.c
drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
drivers/perf/hisilicon/hisi_uncore_l3c_pmu.c
drivers/perf/hisilicon/hisi_uncore_pmu.c
drivers/perf/hisilicon/hisi_uncore_pmu.h
drivers/pnp/core.c
drivers/powercap/intel_rapl_common.c
drivers/regulator/core.c
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/pkey_api.c
drivers/s390/crypto/zcrypt_card.c
drivers/s390/crypto/zcrypt_queue.c
drivers/s390/net/ism_drv.c
drivers/scsi/device_handler/scsi_dh_alua.c
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hpsa.c
drivers/scsi/ibmvscsi/ibmvscsi.c
drivers/scsi/mpt3sas/mpt3sas_base.c
drivers/scsi/qla2xxx/qla_nvme.c
drivers/scsi/qla2xxx/qla_tmpl.c
drivers/scsi/scsi_scan.c
drivers/soc/ti/ti_sci_pm_domains.c
drivers/spi/spi-bcm2835.c
drivers/spi/spi-fsl-dspi.c
drivers/spi/spi-imx.c
drivers/staging/comedi/drivers/cb_pcidas.c
drivers/staging/fieldbus/anybuss/arcx-anybus.c
drivers/staging/octeon/ethernet-mdio.c
drivers/staging/octeon/ethernet-rx.c
drivers/staging/octeon/ethernet.c
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
drivers/staging/wfx/Documentation/devicetree/bindings/net/wireless/silabs,wfx.yaml
drivers/staging/wfx/bh.c
drivers/staging/wfx/data_tx.c
drivers/target/target_core_user.c
drivers/tee/tee_core.c
drivers/tty/serial/21285.c
drivers/tty/serial/8250/8250_mtk.c
drivers/tty/serial/Kconfig
drivers/tty/serial/fsl_lpuart.c
drivers/tty/serial/serial_txx9.c
drivers/tty/tty_io.c
drivers/tty/vt/keyboard.c
drivers/tty/vt/vt.c
drivers/tty/vt/vt_ioctl.c
drivers/usb/cdns3/ep0.c
drivers/usb/cdns3/gadget.c
drivers/usb/cdns3/gadget.h
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-acm.h
drivers/usb/core/driver.c
drivers/usb/core/generic.c
drivers/usb/core/quirks.c
drivers/usb/core/usb.h
drivers/usb/dwc2/platform.c
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h
drivers/usb/dwc3/dwc3-pci.c
drivers/usb/dwc3/ep0.c
drivers/usb/gadget/composite.c
drivers/usb/gadget/legacy/raw_gadget.c
drivers/usb/gadget/udc/fsl_udc_core.c
drivers/usb/gadget/udc/goku_udc.c
drivers/usb/host/ehci-tegra.c
drivers/usb/host/fsl-mph-dr-of.c
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/misc/apple-mfi-fastcharge.c
drivers/usb/mtu3/mtu3_gadget.c
drivers/usb/serial/cyberjack.c
drivers/usb/serial/option.c
drivers/usb/typec/mux.c
drivers/usb/typec/stusb160x.c
drivers/usb/typec/tcpm/tcpm.c
drivers/vdpa/mlx5/core/mr.c
drivers/vdpa/vdpa_sim/vdpa_sim.c
drivers/vfio/fsl-mc/vfio_fsl_mc.c
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c
drivers/vfio/pci/vfio_pci.c
drivers/vfio/pci/vfio_pci_rdwr.c
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/vdpa.c
drivers/video/fbdev/hyperv_fb.c
fs/afs/cell.c
fs/afs/dir.c
fs/afs/dir_edit.c
fs/afs/file.c
fs/afs/internal.h
fs/afs/write.c
fs/afs/xattr.c
fs/afs/yfsclient.c
fs/binfmt_elf.c
fs/btrfs/backref.c
fs/btrfs/block-group.c
fs/btrfs/ctree.h
fs/btrfs/dev-replace.c
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/extent-tree.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/qgroup.c
fs/btrfs/reada.c
fs/btrfs/tree-checker.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h
fs/cachefiles/rdwr.c
fs/ceph/caps.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h
fs/ceph/quota.c
fs/ceph/snap.c
fs/debugfs/file.c
fs/ext4/dir.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/fast_commit.c
fs/ext4/hash.c
fs/ext4/inode.c
fs/ext4/namei.c
fs/ext4/super.c
fs/ext4/sysfs.c
fs/gfs2/glock.c
fs/gfs2/glops.c
fs/gfs2/glops.h
fs/gfs2/inode.c
fs/gfs2/lops.c
fs/gfs2/lops.h
fs/gfs2/ops_fstype.c
fs/gfs2/recovery.c
fs/gfs2/rgrp.c
fs/gfs2/super.c
fs/hfs/btree.h
fs/hfsplus/hfsplus_fs.h
fs/io-wq.c
fs/io_uring.c
fs/iomap/buffered-io.c
fs/isofs/rock.h
fs/proc/base.c
fs/proc/cpuinfo.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/stat.c
fs/select.c
fs/seq_file.c
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_bmap.h
fs/xfs/scrub/inode.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_iops.c
fs/xfs/xfs_reflink.c
include/asm-generic/uaccess.h
include/asm-generic/vmlinux.lds.h
include/drm/drm_dp_helper.h
include/drm/drm_edid.h
include/drm/drm_print.h
include/kunit/test.h
include/linux/acpi_iort.h
include/linux/blk-mq.h
include/linux/can/skb.h
include/linux/cpufreq.h
include/linux/debugfs.h
include/linux/dma/ti-cppi5.h
include/linux/fs.h
include/linux/io_uring.h
include/linux/iomap.h
include/linux/jbd2.h
include/linux/jhash.h
include/linux/mailbox/zynqmp-ipi-message.h
include/linux/mic_bus.h [deleted file]
include/linux/mlx5/driver.h
include/linux/mlx5/mlx5_ifc.h
include/linux/mm.h
include/linux/mmzone.h
include/linux/netfilter/nfnetlink.h
include/linux/netfilter_ipv4.h
include/linux/netfilter_ipv6.h
include/linux/of.h
include/linux/pagemap.h
include/linux/perf/arm_pmu.h
include/linux/pgtable.h
include/linux/phy.h
include/linux/platform_data/cros_ec_commands.h
include/linux/platform_data/cros_ec_proto.h
include/linux/pm_runtime.h
include/linux/refcount.h
include/linux/scif.h [deleted file]
include/linux/scs.h
include/linux/seq_file.h
include/linux/signal.h
include/linux/signal_types.h
include/linux/time64.h
include/linux/usb/composite.h
include/linux/vdpa.h
include/net/cfg80211.h
include/net/mac80211.h
include/rdma/rdma_cm.h
include/sound/control.h
include/sound/core.h
include/sound/pcm.h
include/trace/events/afs.h
include/uapi/asm-generic/signal-defs.h
include/uapi/asm-generic/signal.h
include/uapi/linux/icmpv6.h
include/uapi/linux/mic_common.h [deleted file]
include/uapi/linux/mic_ioctl.h [deleted file]
include/uapi/linux/vhost.h
include/uapi/linux/vhost_types.h
include/uapi/sound/compress_offload.h
include/video/imx-ipu-v3.h
kernel/entry/common.c
kernel/events/core.c
kernel/fork.c
kernel/futex.c
kernel/hung_task.c
kernel/irq/Kconfig
kernel/kprobes.c
kernel/kthread.c
kernel/locking/lockdep.c
kernel/params.c
kernel/power/process.c
kernel/printk/printk_ringbuffer.c
kernel/rcu/tree.c
kernel/sched/cpufreq_schedutil.c
kernel/scs.c
kernel/signal.c
kernel/stop_machine.c
kernel/time/hrtimer.c
kernel/time/itimer.c
kernel/time/sched_clock.c
kernel/time/timer.c
kernel/trace/ring_buffer.c
kernel/trace/trace.c
kernel/trace/trace.h
kernel/trace/trace_events_synth.c
kernel/trace/trace_selftest.c
kernel/tracepoint.c
lib/Kconfig.debug
lib/crc32test.c
lib/fonts/font_10x18.c
lib/fonts/font_6x10.c
lib/fonts/font_6x11.c
lib/fonts/font_6x8.c
lib/fonts/font_7x14.c
lib/fonts/font_8x16.c
lib/fonts/font_8x8.c
lib/fonts/font_acorn_8x8.c
lib/fonts/font_mini_4x6.c
lib/fonts/font_pearl_8x8.c
lib/fonts/font_sun12x22.c
lib/fonts/font_sun8x16.c
lib/fonts/font_ter16x32.c
lib/scatterlist.c
lib/test_kasan.c
mm/hugetlb.c
mm/memcontrol.c
mm/mempolicy.c
mm/memremap.c
mm/process_vm_access.c
mm/truncate.c
net/atm/lec.c
net/bluetooth/msft.c
net/can/Kconfig
net/can/isotp.c
net/can/j1939/socket.c
net/can/proc.c
net/core/devlink.c
net/ipv4/ip_tunnel.c
net/ipv4/netfilter.c
net/ipv4/netfilter/iptable_mangle.c
net/ipv4/netfilter/nf_reject_ipv4.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/xfrm4_tunnel.c
net/ipv6/icmp.c
net/ipv6/ip6_tunnel.c
net/ipv6/netfilter.c
net/ipv6/netfilter/ip6table_mangle.c
net/ipv6/reassembly.c
net/ipv6/xfrm6_tunnel.c
net/mac80211/mlme.c
net/mac80211/sta_info.c
net/mac80211/sta_info.h
net/mac80211/tx.c
net/mptcp/protocol.c
net/mptcp/token.c
net/netfilter/ipset/ip_set_core.c
net/netfilter/ipvs/ip_vs_core.c
net/netfilter/nf_nat_proto.c
net/netfilter/nf_synproxy_core.c
net/netfilter/nf_tables_api.c
net/netfilter/nfnetlink.c
net/netfilter/nft_chain_route.c
net/netfilter/utils.c
net/openvswitch/datapath.c
net/openvswitch/flow_table.c
net/rds/ib_cm.c
net/sched/act_mpls.c
net/sched/cls_api.c
net/sched/sch_netem.c
net/sctp/sm_sideeffect.c
net/smc/af_smc.c
net/smc/smc_clc.h
net/smc/smc_core.c
net/tipc/msg.c
net/vmw_vsock/af_vsock.c
net/wireless/core.c
net/wireless/core.h
net/wireless/nl80211.c
net/wireless/reg.c
net/xfrm/xfrm_interface.c
net/xfrm/xfrm_state.c
samples/mic/mpssd/.gitignore [deleted file]
samples/mic/mpssd/Makefile [deleted file]
samples/mic/mpssd/micctrl [deleted file]
samples/mic/mpssd/mpss [deleted file]
samples/mic/mpssd/mpssd.c [deleted file]
samples/mic/mpssd/mpssd.h [deleted file]
samples/mic/mpssd/sysfs.c [deleted file]
scripts/get_abi.pl
scripts/kernel-doc
security/integrity/ima/ima.h
sound/core/control.c
sound/core/pcm_dmaengine.c
sound/core/pcm_lib.c
sound/core/pcm_native.c
sound/hda/ext/hdac_ext_controller.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_controller.h
sound/pci/hda/hda_intel.c
sound/pci/hda/patch_realtek.c
sound/soc/atmel/mchp-spdiftx.c
sound/soc/codecs/cs42l51.c
sound/soc/codecs/wcd9335.c
sound/soc/codecs/wcd934x.c
sound/soc/codecs/wsa881x.c
sound/soc/intel/Kconfig
sound/soc/intel/atom/Makefile
sound/soc/intel/atom/sst/Makefile
sound/soc/intel/boards/kbl_rt5663_max98927.c
sound/soc/intel/catpt/dsp.c
sound/soc/intel/catpt/pcm.c
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c
sound/soc/qcom/lpass-cpu.c
sound/soc/qcom/lpass-sc7180.c
sound/soc/qcom/sdm845.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/sof/loader.c
sound/usb/pcm.c
sound/usb/quirks.c
tools/arch/arm64/include/uapi/asm/kvm.h
tools/arch/s390/include/uapi/asm/sie.h
tools/arch/x86/include/asm/cpufeatures.h
tools/arch/x86/include/asm/disabled-features.h
tools/arch/x86/include/asm/msr-index.h
tools/arch/x86/include/asm/required-features.h
tools/arch/x86/include/uapi/asm/kvm.h
tools/arch/x86/include/uapi/asm/svm.h
tools/build/feature/test-all.c
tools/include/linux/compiler-gcc.h
tools/include/linux/compiler.h
tools/include/uapi/asm-generic/unistd.h
tools/include/uapi/drm/i915_drm.h
tools/include/uapi/linux/fscrypt.h
tools/include/uapi/linux/kvm.h
tools/include/uapi/linux/mman.h
tools/include/uapi/linux/mount.h
tools/include/uapi/linux/perf_event.h
tools/include/uapi/linux/prctl.h
tools/include/uapi/linux/vhost.h
tools/perf/Makefile.config
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
tools/perf/builtin-trace.c
tools/perf/pmu-events/arch/x86/cascadelakex/clx-metrics.json
tools/perf/pmu-events/arch/x86/skylakex/skx-metrics.json
tools/perf/tests/dwarf-unwind.c
tools/perf/ui/browsers/hists.c
tools/perf/util/build-id.c
tools/perf/util/hashmap.c
tools/perf/util/hashmap.h
tools/perf/util/machine.c
tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/util/session.c
tools/perf/util/symbol.c
tools/perf/util/symbol.h
tools/testing/kunit/kunit_parser.py
tools/testing/kunit/kunit_tool_test.py
tools/testing/kunit/test_data/test_config_printk_time.log
tools/testing/kunit/test_data/test_interrupted_tap_output.log
tools/testing/kunit/test_data/test_kernel_panic_interrupt.log
tools/testing/kunit/test_data/test_multiple_prefixes.log
tools/testing/kunit/test_data/test_pound_no_prefix.log
tools/testing/kunit/test_data/test_pound_sign.log
tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
tools/testing/selftests/core/close_range_test.c
tools/testing/selftests/filesystems/binderfs/binderfs_test.c
tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_kprobe.tc
tools/testing/selftests/ftrace/test.d/dynevent/clear_select_events.tc
tools/testing/selftests/ftrace/test.d/dynevent/generic_clear_event.tc
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
tools/testing/selftests/ftrace/test.d/functions
tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_comm.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_symbol.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_multiprobe.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
tools/testing/selftests/kselftest_harness.h
tools/testing/selftests/kvm/.gitignore
tools/testing/selftests/kvm/Makefile
tools/testing/selftests/kvm/include/x86_64/vmx.h
tools/testing/selftests/kvm/lib/kvm_util.c
tools/testing/selftests/kvm/lib/x86_64/vmx.c
tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c [new file with mode: 0644]
tools/testing/selftests/lib.mk
tools/testing/selftests/pidfd/config
tools/testing/selftests/pidfd/pidfd_getfd_test.c
tools/testing/selftests/pidfd/pidfd_open_test.c
tools/testing/selftests/pidfd/pidfd_poll_test.c
tools/testing/selftests/pidfd/pidfd_setns_test.c
tools/testing/selftests/pidfd/pidfd_test.c
tools/testing/selftests/proc/proc-loadavg-001.c
tools/testing/selftests/proc/proc-self-syscall.c
tools/testing/selftests/proc/proc-uptime-002.c
tools/testing/selftests/wireguard/netns.sh
tools/testing/selftests/wireguard/qemu/kernel.config

diff --git a/CREDITS b/CREDITS
index cb02b9923a5261769e0b8f1b92713575c480b3ac..8592e45e3932022b27eac6c09a79aeb85a967fc1 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -1910,6 +1910,15 @@ S: 660 Harvard Ave. #7
 S: Santa Clara, CA 95051
 S: USA
 
+N: Kukjin Kim
+E: kgene@kernel.org
+D: Samsung S3C, S5P and Exynos ARM architectures
+
+N: Sangbeom Kim
+E: sbkim73@samsung.com
+D: Samsung SoC Audio (ASoC) drivers
+D: Samsung PMIC (RTC, regulators, MFD) drivers
+
 N: Russell King
 E: rmk@arm.linux.org.uk
 D: Linux/arm integrator, maintainer & hacker
index 3121029dce210f1fbc9d06a711af40546d8788dd..8bac9cb09a6de7a50f596abab38318368e592128 100644 (file)
@@ -32,7 +32,7 @@ The different levels of stability are:
        layout of the files below for details on how to do this.)
 
   obsolete/
-       This directory documents interfaces that are still remaining in
+       This directory documents interfaces that are still remaining in
        the kernel, but are marked to be removed at some later point in
        time.  The description of the interface will document the reason
        why it is obsolete and when it can be expected to be removed.
@@ -58,6 +58,14 @@ Users:               All users of this interface who wish to be notified when
                be changed further.
 
 
+Note:
+   The fields should be use a simple notation, compatible with ReST markup.
+   Also, the file **should not** have a top-level index, like::
+
+       ===
+       foo
+       ===
+
 How things move between levels:
 
 Interfaces in stable may move to obsolete, as long as the proper
index 2cb9fc5e8bd1420e5c82a11109a1867d98a95ba1..0faf1354cd054fd39d69120e5b8eb5b89723af7b 100644 (file)
@@ -8,11 +8,11 @@ Description:  Device DAX is the device-centric analogue of Filesystem
                system.  Device DAX is strict, precise and predictable.
                Specifically this interface:
 
-               1/ Guarantees fault granularity with respect to a given
-               page size (pte, pmd, or pud) set at configuration time.
+               1. Guarantees fault granularity with respect to a given
+                  page size (pte, pmd, or pud) set at configuration time.
 
-               2/ Enforces deterministic behavior by being strict about
-               what fault scenarios are supported.
+               2. Enforces deterministic behavior by being strict about
+                  what fault scenarios are supported.
 
                The /sys/class/dax/ interface enumerates all the
                device-dax instances in the system. The ABI is
index 5d41ebadf15e9250adb9a6d5258e21281b23870d..66545c587a64a8335ffe2cf939943de0e47d6d43 100644 (file)
@@ -7,10 +7,13 @@ Description:  It is possible to switch the cpi setting of the mouse with the
                setting reported by the mouse. This number has to be further
                processed to receive the real dpi value:
 
+               ===== ====
                VALUE DPI
+               ===== ====
                1     400
                2     800
                4     1600
+               ===== ====
 
                This file is readonly.
                Has never been used. If bookkeeping is done, it's done in userland tools.
index e0d4e5e2dd90a4dafb082b23ddec928497794f97..b8b0fd341c17975f1226e7ec424d5d033132be34 100644 (file)
@@ -13,6 +13,8 @@ Description:
   GPIOs are identified as they are inside the kernel, using integers in
   the range 0..INT_MAX.  See Documentation/admin-guide/gpio for more information.
 
+  ::
+
     /sys/class/gpio
        /export ... asks the kernel to export a GPIO to userspace
        /unexport ... to return a GPIO to the kernel
index 0020c49933c45ab0b61cd7e57fa9b4baa672d3c0..24fb35adf27753ea087990f7a421f21188744cfb 100644 (file)
@@ -5,6 +5,7 @@ Description:
        devfs has been unmaintained for a number of years, has unfixable
        races, contains a naming policy within the kernel that is
        against the LSB, and can be replaced by using udev.
+
        The files fs/devfs/*, include/linux/devfs_fs*.h were removed,
        along with the assorted devfs function calls throughout the
        kernel tree.
index ec333e67632266a935daa6e2124744c09caa8d77..9ec7ec4939203e3ba9b9f9a532e5d4b879f2e6b9 100644 (file)
@@ -7,6 +7,7 @@ Description:
        to implement sensible device security policies, and its low level
        of abstraction that required userspace clients to duplicate much
        of the kernel's ieee1394 core functionality.
+
        Replaced by /dev/fw*, i.e. the <linux/firewire-cdev.h> ABI of
        firewire-core.
 
index 9c08c7f98ffb145b1b46fe506b036ae7467cc188..f25174eafd55aecfeb3c3e49e653a0392ed6954e 100644 (file)
@@ -10,4 +10,4 @@ Description:  This file was deprecated because there no longer was a way to
                claim just control over a single rfkill instance.
                This file was scheduled to be removed in 2012, and was removed
                in 2016.
-Values:        0: Kernel handles events
+Values:                0: Kernel handles events
index c39c25aee77b13e6d92e46686000ac2d8978da51..1905d35a66198724489837b440503a5824231f0b 100644 (file)
@@ -8,6 +8,7 @@ Description:
        performance issues in its first generation.  Any video1394 user had
        to use raw1394 + libraw1394 too because video1394 did not provide
        asynchronous I/O for device discovery and configuration.
+
        Replaced by /dev/fw*, i.e. the <linux/firewire-cdev.h> ABI of
        firewire-core.
 
index f72ed653878a619c62720b17c8428ba208842170..261f85b1315497999c17dfeb2ec720114d62c9e0 100644 (file)
@@ -14,13 +14,17 @@ Description:
                Each /dev/fw* is associated with one IEEE 1394 node, which can
                be remote or local nodes.  Operations on a /dev/fw* file have
                different scope:
+
                  - The 1394 node which is associated with the file:
+
                          - Asynchronous request transmission
                          - Get the Configuration ROM
                          - Query node ID
                          - Query maximum speed of the path between this node
                            and local node
+
                  - The 1394 bus (i.e. "card") to which the node is attached to:
+
                          - Isochronous stream transmission and reception
                          - Asynchronous stream transmission and reception
                          - Asynchronous broadcast request transmission
@@ -31,7 +35,9 @@ Description:
                            manager
                          - Query cycle time
                          - Bus reset initiation, bus reset event reception
+
                  - All 1394 buses:
+
                          - Allocation of IEEE 1212 address ranges on the local
                            link layers, reception of inbound requests to such
                            an address range, asynchronous response transmission
@@ -43,6 +49,7 @@ Description:
                userland implement different access permission models, some
                operations are restricted to /dev/fw* files that are associated
                with a local node:
+
                          - Addition of descriptors or directories to the local
                            nodes' Configuration ROM
                          - PHY packet transmission and reception
@@ -55,50 +62,50 @@ Description:
                The following file operations are supported:
 
                open(2)
-               Currently the only useful flags are O_RDWR.
+                   Currently the only useful flags are O_RDWR.
 
                ioctl(2)
-               Initiate various actions.  Some take immediate effect, others
-               are performed asynchronously while or after the ioctl returns.
-               See the inline documentation in <linux/firewire-cdev.h> for
-               descriptions of all ioctls.
+                   Initiate various actions.  Some take immediate effect, others
+                   are performed asynchronously while or after the ioctl returns.
+                   See the inline documentation in <linux/firewire-cdev.h> for
+                   descriptions of all ioctls.
 
                poll(2), select(2), epoll_wait(2) etc.
-               Watch for events to become available to be read.
+                   Watch for events to become available to be read.
 
                read(2)
-               Receive various events.  There are solicited events like
-               outbound asynchronous transaction completion or isochronous
-               buffer completion, and unsolicited events such as bus resets,
-               request reception, or PHY packet reception.  Always use a read
-               buffer which is large enough to receive the largest event that
-               could ever arrive.  See <linux/firewire-cdev.h> for descriptions
-               of all event types and for which ioctls affect reception of
-               events.
+                   Receive various events.  There are solicited events like
+                   outbound asynchronous transaction completion or isochronous
+                   buffer completion, and unsolicited events such as bus resets,
+                   request reception, or PHY packet reception.  Always use a read
+                   buffer which is large enough to receive the largest event that
+                   could ever arrive.  See <linux/firewire-cdev.h> for descriptions
+                   of all event types and for which ioctls affect reception of
+                   events.
 
                mmap(2)
-               Allocate a DMA buffer for isochronous reception or transmission
-               and map it into the process address space.  The arguments should
-               be used as follows:  addr = NULL, length = the desired buffer
-               size, i.e. number of packets times size of largest packet,
-               prot = at least PROT_READ for reception and at least PROT_WRITE
-               for transmission, flags = MAP_SHARED, fd = the handle to the
-               /dev/fw*, offset = 0.
+                   Allocate a DMA buffer for isochronous reception or transmission
+                   and map it into the process address space.  The arguments should
+                   be used as follows:  addr = NULL, length = the desired buffer
+                   size, i.e. number of packets times size of largest packet,
+                   prot = at least PROT_READ for reception and at least PROT_WRITE
+                   for transmission, flags = MAP_SHARED, fd = the handle to the
+                   /dev/fw*, offset = 0.
 
                Isochronous reception works in packet-per-buffer fashion except
                for multichannel reception which works in buffer-fill mode.
 
                munmap(2)
-               Unmap the isochronous I/O buffer from the process address space.
+                   Unmap the isochronous I/O buffer from the process address space.
 
                close(2)
-               Besides stopping and freeing I/O contexts that were associated
-               with the file descriptor, back out any changes to the local
-               nodes' Configuration ROM.  Deallocate isochronous channels and
-               bandwidth at the IRM that were marked for kernel-assisted
-               re- and deallocation.
-
-Users:         libraw1394
-               libdc1394
-               libhinawa
+                   Besides stopping and freeing I/O contexts that were associated
+                   with the file descriptor, back out any changes to the local
+                   nodes' Configuration ROM.  Deallocate isochronous channels and
+                   bandwidth at the IRM that were marked for kernel-assisted
+                   re- and deallocation.
+
+Users:         libraw1394;
+               libdc1394;
+               libhinawa;
                tools like linux-firewire-utils, fwhack, ...
index 964c7a8afb268ae004364b0d71117efa51261dc3..2d6314f0e4e47e0110fc20712bd9dd2757769d41 100644 (file)
@@ -1,22 +1,26 @@
-What:          /sys/firmware/acpi/pm_profile
+What:          /sys/firmware/acpi/pm_profile
 Date:          03-Nov-2011
 KernelVersion: v3.2
 Contact:       linux-acpi@vger.kernel.org
-Description:   The ACPI pm_profile sysfs interface exports the platform
+Description:   The ACPI pm_profile sysfs interface exports the platform
                power management (and performance) requirement expectations
                as provided by BIOS. The integer value is directly passed as
                retrieved from the FADT ACPI table.
-Values:         For possible values see ACPI specification:
+
+Values:                For possible values see ACPI specification:
                5.2.9 Fixed ACPI Description Table (FADT)
                Field: Preferred_PM_Profile
 
                Currently these values are defined by spec:
-               0 Unspecified
-               1 Desktop
-               2 Mobile
-               3 Workstation
-               4 Enterprise Server
-               5 SOHO Server
-               6 Appliance PC
-               7 Performance Server
+
+               == =================
+               0  Unspecified
+               1  Desktop
+               2  Mobile
+               3  Workstation
+               4  Enterprise Server
+               5  SOHO Server
+               6  Appliance PC
+               7  Performance Server
                >7 Reserved
+               == =================
index 41e5a0cd1e3ed334234c4f3e9e3db1e2fa021dfc..9ac9eddb82efa358e21cb6f4f5249547ff057a44 100644 (file)
@@ -47,6 +47,7 @@ Description:
                IEEE 1394 node device attribute.
                Read-only and immutable.
 Values:                1: The sysfs entry represents a local node (a controller card).
+
                0: The sysfs entry represents a remote node.
 
 
@@ -125,7 +126,9 @@ Description:
                Read-only attribute, immutable during the target's lifetime.
                Format, as exposed by firewire-sbp2 since 2.6.22, May 2007:
                Colon-separated hexadecimal string representations of
+
                        u64 EUI-64 : u24 directory_ID : u16 LUN
+
                without 0x prefixes, without whitespace.  The former sbp2 driver
                (removed in 2.6.37 after being superseded by firewire-sbp2) used
                a somewhat shorter format which was not as close to SAM.
index 9ffba8576f7b690e334517a8f8fd647f2441b670..c399323f37de370d561f65a6bebda93c14e5f0c4 100644 (file)
@@ -9,13 +9,14 @@ Description:
                Note: This file is only present if CONFIG_NVMEM_SYSFS
                is enabled
 
-               ex:
-               hexdump /sys/bus/nvmem/devices/qfprom0/nvmem
+               ex::
 
-               0000000 0000 0000 0000 0000 0000 0000 0000 0000
-               *
-               00000a0 db10 2240 0000 e000 0c00 0c00 0000 0c00
-               0000000 0000 0000 0000 0000 0000 0000 0000 0000
-               ...
-               *
-               0001000
+                 hexdump /sys/bus/nvmem/devices/qfprom0/nvmem
+
+                 0000000 0000 0000 0000 0000 0000 0000 0000 0000
+                 *
+                 00000a0 db10 2240 0000 e000 0c00 0c00 0000 0c00
+                 0000000 0000 0000 0000 0000 0000 0000 0000 0000
+                 ...
+                 *
+                 0001000
index b832eeff999914b0afa4e4a99d7379e4f852dea8..cad4bc23252066bdbaf89bcbeefd3285bd74858d 100644 (file)
@@ -50,8 +50,10 @@ Description:
 
                Tools can use this file and the connected_duration file to
                compute the percentage of time that a device has been active.
-               For example,
-               echo $((100 * `cat active_duration` / `cat connected_duration`))
+               For example::
+
+                 echo $((100 * `cat active_duration` / `cat connected_duration`))
+
                will give an integer percentage.  Note that this does not
                account for counter wrap.
 Users:
index 8e8d167eca3145c049e44a9d9b8b0bdbe17c6838..c27b7b89477ce7778e3b4af0bcc3a36637bfd489 100644 (file)
@@ -63,13 +63,6 @@ Contact:     Stephen Hemminger <sthemmin@microsoft.com>
 Description:   VCPU (sub)channel is affinitized to
 Users:         tools/hv/lsvmbus and other debugging tools
 
-What:          /sys/bus/vmbus/devices/<UUID>/channels/<N>/cpu
-Date:          September. 2017
-KernelVersion: 4.14
-Contact:       Stephen Hemminger <sthemmin@microsoft.com>
-Description:   VCPU (sub)channel is affinitized to
-Users:         tools/hv/lsvmbus and other debugging tools
-
 What:          /sys/bus/vmbus/devices/<UUID>/channels/<N>/in_mask
 Date:          September. 2017
 KernelVersion: 4.14
index 992dfb183ed0221edd6562544c78dfcd0a2d0d7f..5cd5e872bcaed22a8bca71a8499d792024f7938c 100644 (file)
@@ -6,6 +6,7 @@ Description:    Bus scanning interval, microseconds component.
                control systems are attached/generate presence for as short as
                100 ms - hence the tens-to-hundreds milliseconds scan intervals
                are required.
+
                see Documentation/w1/w1-generic.rst for detailed information.
 Users:         any user space application which wants to know bus scanning
                interval
index 70302f370e7ec1c1d46e4d278f41319e1ce536c1..023fb52645f8bdcd02c22c3faf0f803609a9a2dd 100644 (file)
@@ -4,6 +4,7 @@ KernelVersion:  2.6.12
 Contact:       Richard Purdie <rpurdie@rpsys.net>
 Description:
                Control BACKLIGHT power, values are FB_BLANK_* from fb.h
+
                 - FB_BLANK_UNBLANK (0)   : power on.
                 - FB_BLANK_POWERDOWN (4) : power off
 Users:         HAL
index 87b11f91b42568f5ac3c6153f10c4c020e4cca20..348c4ac803ade36060d45b2354416b61478f5b34 100644 (file)
@@ -8,12 +8,14 @@ Date:         Apr, 2005
 KernelVersion: v2.6.12
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ===========================================
                node_type:      (RO) Node type (CA, RNIC, usNIC, usNIC UDP,
                                switch or router)
 
                node_guid:      (RO) Node GUID
 
                sys_image_guid: (RO) System image GUID
+               =============== ===========================================
 
 
 What:          /sys/class/infiniband/<device>/node_desc
@@ -47,6 +49,7 @@ KernelVersion:        v2.6.12
 Contact:       linux-rdma@vger.kernel.org
 Description:
 
+               =============== ===============================================
                lid:            (RO) Port LID
 
                rate:           (RO) Port data rate (active width * active
@@ -66,8 +69,9 @@ Description:
 
                cap_mask:       (RO) Port capability mask. 2 bits here are
                                settable- IsCommunicationManagementSupported
-                               (set when CM module is loaded) and IsSM (set via
-                               open of issmN file).
+                               (set when CM module is loaded) and IsSM (set
+                               via open of issmN file).
+               =============== ===============================================
 
 
 What:          /sys/class/infiniband/<device>/ports/<port-num>/link_layer
@@ -103,8 +107,7 @@ Date:               Apr, 2005
 KernelVersion: v2.6.12
 Contact:       linux-rdma@vger.kernel.org
 Description:
-               Errors info:
-               -----------
+               **Errors info**:
 
                symbol_error: (RO) Total number of minor link errors detected on
                one or more physical lanes.
@@ -142,8 +145,7 @@ Description:
                intervention. It can also indicate hardware issues or extremely
                poor link signal integrity
 
-               Data info:
-               ---------
+               **Data info**:
 
                port_xmit_data: (RO) Total number of data octets, divided by 4
                (lanes), transmitted on all VLs. This is 64 bit counter
@@ -176,8 +178,7 @@ Description:
                transmitted on all VLs from the port. This may include multicast
                packets with errors.
 
-               Misc info:
-               ---------
+               **Misc info**:
 
                port_xmit_discards: (RO) Total number of outbound packets
                discarded by the port because the port is down or congested.
@@ -244,9 +245,11 @@ Description:
                two umad devices and two issm devices, while a switch will have
                one device of each type (for switch port 0).
 
+               ======= =====================================
                ibdev:  (RO) Show Infiniband (IB) device name
 
                port:   (RO) Display port number
+               ======= =====================================
 
 
 What:          /sys/class/infiniband_mad/abi_version
@@ -264,10 +267,12 @@ Date:             Sept, 2005
 KernelVersion: v2.6.14
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ===========================================
                ibdev:          (RO) Display Infiniband (IB) device name
 
                abi_version:    (RO) Show ABI version of IB device specific
                                interfaces.
+               =============== ===========================================
 
 
 What:          /sys/class/infiniband_verbs/abi_version
@@ -289,12 +294,14 @@ Date:             Apr, 2005
 KernelVersion: v2.6.12
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ================================================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Host Channel Adapter type: MT23108, MT25208
                                (MT23108 compat mode), MT25208 or MT25204
 
                board_id:       (RO) Manufacturing board ID
+               =============== ================================================
 
 
 sysfs interface for Mellanox ConnectX HCA IB driver (mlx4)
@@ -307,11 +314,13 @@ Date:             Sep, 2007
 KernelVersion: v2.6.24
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ===============================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Host channel adapter type
 
                board_id:       (RO) Manufacturing board ID
+               =============== ===============================
 
 
 What:          /sys/class/infiniband/mlx4_X/iov/ports/<port-num>/gids/<n>
@@ -337,6 +346,7 @@ Description:
                example, ports/1/pkeys/10 contains the value at index 10 in port
                1's P_Key table.
 
+               ======================= ==========================================
                gids/<n>:               (RO) The physical port gids n = 0..127
 
                admin_guids/<n>:        (RW) Allows examining or changing the
@@ -365,6 +375,7 @@ Description:
                                        guest, whenever it uses its pkey index
                                        1, will actually be using the real pkey
                                        index 10.
+               ======================= ==========================================
 
 
 What:          /sys/class/infiniband/mlx4_X/iov/<pci-slot-num>/ports/<m>/smi_enabled
@@ -376,12 +387,14 @@ Description:
                Enabling QP0 on VFs for selected VF/port. By default, no VFs are
                enabled for QP0 operation.
 
-               smi_enabled:    (RO) Indicates whether smi is currently enabled
-                               for the indicated VF/port
+               ================= ==== ===========================================
+               smi_enabled:      (RO) Indicates whether smi is currently enabled
+                                      for the indicated VF/port
 
-               enable_smi_admin:(RW) Used by the admin to request that smi
-                               capability be enabled or disabled for the
-                               indicated VF/port. 0 = disable, 1 = enable.
+               enable_smi_admin: (RW) Used by the admin to request that smi
+                                      capability be enabled or disabled for the
+                                      indicated VF/port. 0 = disable, 1 = enable.
+               ================= ==== ===========================================
 
                The requested enablement will occur at the next reset of the VF
                (e.g. driver restart on the VM which owns the VF).
@@ -398,6 +411,7 @@ KernelVersion:      v2.6.35
 Contact:       linux-rdma@vger.kernel.org
 Description:
 
+               =============== =============================================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Driver short name. Should normally match
@@ -406,6 +420,7 @@ Description:
 
                board_id:       (RO) Manufacturing board id. (Vendor + device
                                information)
+               =============== =============================================
 
 
 sysfs interface for Intel IB driver qib
@@ -426,6 +441,7 @@ Date:               May, 2010
 KernelVersion: v2.6.35
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ======================================================
                version:        (RO) Display version information of installed software
                                and drivers.
 
@@ -452,6 +468,7 @@ Description:
                chip_reset:     (WO) Reset the chip if possible by writing
                                "reset" to this file. Only allowed if no user
                                contexts are open that use chip resources.
+               =============== ======================================================
 
 
 What:          /sys/class/infiniband/qibX/ports/N/sl2vl/[0-15]
@@ -471,14 +488,16 @@ Contact:  linux-rdma@vger.kernel.org
 Description:
                Per-port congestion control. Both are binary attributes.
 
-               cc_table_bin:   (RO) Congestion control table size followed by
+               =============== ================================================
+               cc_table_bin    (RO) Congestion control table size followed by
                                table entries.
 
-               cc_settings_bin:(RO) Congestion settings: port control, control
+               cc_settings_bin (RO) Congestion settings: port control, control
                                map and an array of 16 entries for the
                                congestion entries - increase, timer, event log
                                trigger threshold and the minimum injection rate
                                delay.
+               =============== ================================================
 
 What:          /sys/class/infiniband/qibX/ports/N/linkstate/loopback
 What:          /sys/class/infiniband/qibX/ports/N/linkstate/led_override
@@ -491,6 +510,7 @@ Contact:    linux-rdma@vger.kernel.org
 Description:
                [to be documented]
 
+               =============== ===============================================
                loopback:       (WO)
                led_override:   (WO)
                hrtbt_enable:   (RW)
@@ -501,6 +521,7 @@ Description:
                                errors. Possible states are- "Initted",
                                "Present", "IB_link_up", "IB_configured" or
                                "Fatal_Hardware_Error".
+               =============== ===============================================
 
 What:          /sys/class/infiniband/qibX/ports/N/diag_counters/rc_resends
 What:          /sys/class/infiniband/qibX/ports/N/diag_counters/seq_naks
@@ -549,6 +570,7 @@ Contact:    Christian Benvenuti <benve@cisco.com>,
                linux-rdma@vger.kernel.org
 Description:
 
+               =============== ===============================================
                board_id:       (RO) Manufacturing board id
 
                config:         (RO) Report the configuration for this PF
@@ -561,6 +583,7 @@ Description:
 
                iface:          (RO) Shows which network interface this usNIC
                                entry is associated to (visible with ifconfig).
+               =============== ===============================================
 
 What:          /sys/class/infiniband/usnic_X/qpn/summary
 What:          /sys/class/infiniband/usnic_X/qpn/context
@@ -605,6 +628,7 @@ Date:               May, 2016
 KernelVersion: v4.6
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== =============================================
                hw_rev:         (RO) Hardware revision number
 
                board_id:       (RO) Manufacturing board id
@@ -623,6 +647,7 @@ Description:
                                available.
 
                tempsense:      (RO) Thermal sense information
+               =============== =============================================
 
 
 What:          /sys/class/infiniband/hfi1_X/ports/N/CCMgtA/cc_settings_bin
@@ -634,19 +659,21 @@ Contact:  linux-rdma@vger.kernel.org
 Description:
                Per-port congestion control.
 
-               cc_table_bin:   (RO) CCA tables used by PSM2 Congestion control
+               =============== ================================================
+               cc_table_bin    (RO) CCA tables used by PSM2 Congestion control
                                table size followed by table entries. Binary
                                attribute.
 
-               cc_settings_bin:(RO) Congestion settings: port control, control
+               cc_settings_bin (RO) Congestion settings: port control, control
                                map and an array of 16 entries for the
                                congestion entries - increase, timer, event log
                                trigger threshold and the minimum injection rate
                                delay. Binary attribute.
 
-               cc_prescan:     (RW) enable prescanning for faster BECN
+               cc_prescan      (RW) enable prescanning for faster BECN
                                response. Write "on" to enable and "off" to
                                disable.
+               =============== ================================================
 
 What:          /sys/class/infiniband/hfi1_X/ports/N/sc2vl/[0-31]
 What:          /sys/class/infiniband/hfi1_X/ports/N/sl2sc/[0-31]
@@ -655,11 +682,13 @@ Date:             May, 2016
 KernelVersion: v4.6
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ===================================================
                sc2vl/:         (RO) 32 files (0 - 31) used to translate sl->vl
 
                sl2sc/:         (RO) 32 files (0 - 31) used to translate sl->sc
 
                vl2mtu/:        (RO) 16 files (0 - 15) used to determine MTU for vl
+               =============== ===================================================
 
 
 What:          /sys/class/infiniband/hfi1_X/sdma_N/cpu_list
@@ -670,26 +699,28 @@ Contact:  linux-rdma@vger.kernel.org
 Description:
                sdma<N>/ contains one directory per sdma engine (0 - 15)
 
+               =============== ==============================================
                cpu_list:       (RW) List of cpus for user-process to sdma
                                engine assignment.
 
                vl:             (RO) Displays the virtual lane (vl) the sdma
                                engine maps to.
+               =============== ==============================================
 
                This interface gives the user control on the affinity settings
                for the device. As an example, to set an sdma engine irq
                affinity and thread affinity of a user processes to use the
                sdma engine, which is "near" in terms of NUMA configuration, or
-               physical cpu location, the user will do:
+               physical cpu location, the user will do::
 
-               echo "3" > /proc/irq/<N>/smp_affinity_list
-               echo "4-7" > /sys/devices/.../sdma3/cpu_list
-               cat /sys/devices/.../sdma3/vl
-               0
-               echo "8" > /proc/irq/<M>/smp_affinity_list
-               echo "9-12" > /sys/devices/.../sdma4/cpu_list
-               cat /sys/devices/.../sdma4/vl
-               1
+                 echo "3" > /proc/irq/<N>/smp_affinity_list
+                 echo "4-7" > /sys/devices/.../sdma3/cpu_list
+                 cat /sys/devices/.../sdma3/vl
+                 0
+                 echo "8" > /proc/irq/<M>/smp_affinity_list
+                 echo "9-12" > /sys/devices/.../sdma4/cpu_list
+                 cat /sys/devices/.../sdma4/vl
+                 1
 
                to make sure that when a process runs on cpus 4,5,6, or 7, and
                uses vl=0, then sdma engine 3 is selected by the driver, and
@@ -711,11 +742,13 @@ Date:             Jan, 2016
 KernelVersion: v4.10
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ==== ========================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Show HCA type (I40IW)
 
                board_id:       (RO) I40IW board ID
+               =============== ==== ========================
 
 
 sysfs interface for QLogic qedr NIC Driver
@@ -728,9 +761,11 @@ KernelVersion:     v4.10
 Contact:       linux-rdma@vger.kernel.org
 Description:
 
+               =============== ==== ========================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Display HCA type
+               =============== ==== ========================
 
 
 sysfs interface for VMware Paravirtual RDMA driver
@@ -744,11 +779,13 @@ KernelVersion:    v4.10
 Contact:       linux-rdma@vger.kernel.org
 Description:
 
+               =============== ==== =====================================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Host channel adapter type
 
                board_id:       (RO) Display PVRDMA manufacturing board ID
+               =============== ==== =====================================
 
 
 sysfs interface for Broadcom NetXtreme-E RoCE driver
@@ -760,6 +797,8 @@ Date:               Feb, 2017
 KernelVersion: v4.11
 Contact:       linux-rdma@vger.kernel.org
 Description:
+               =============== ==== =========================
                hw_rev:         (RO) Hardware revision number
 
                hca_type:       (RO) Host channel adapter type
+               =============== ==== =========================
index 5b154f9226430292a9e62d4199c59bcf542c49b3..037979f7dc4bed3bc1e06a61d6aff3cdfd1960b3 100644 (file)
@@ -2,7 +2,7 @@ rfkill - radio frequency (RF) connector kill switch support
 
 For details to this subsystem look at Documentation/driver-api/rfkill.rst.
 
-For the deprecated /sys/class/rfkill/*/claim knobs of this interface look in
+For the deprecated ``/sys/class/rfkill/*/claim`` knobs of this interface look in
 Documentation/ABI/removed/sysfs-class-rfkill.
 
 What:          /sys/class/rfkill
@@ -36,9 +36,10 @@ KernelVersion        v2.6.22
 Contact:       linux-wireless@vger.kernel.org
 Description:   Whether the soft blocked state is initialised from non-volatile
                storage at startup.
-Values:        A numeric value.
-               0: false
-               1: true
+Values:        A numeric value:
+
+               - 0: false
+               - 1: true
 
 
 What:          /sys/class/rfkill/rfkill[0-9]+/state
@@ -54,6 +55,7 @@ Description:  Current state of the transmitter.
                through this interface. There will likely be another attempt to
                remove it in the future.
 Values:        A numeric value.
+
                0: RFKILL_STATE_SOFT_BLOCKED
                        transmitter is turned off by software
                1: RFKILL_STATE_UNBLOCKED
@@ -69,6 +71,7 @@ KernelVersion v2.6.34
 Contact:       linux-wireless@vger.kernel.org
 Description:   Current hardblock state. This file is read only.
 Values:        A numeric value.
+
                0: inactive
                        The transmitter is (potentially) active.
                1: active
@@ -82,7 +85,9 @@ KernelVersion v2.6.34
 Contact:       linux-wireless@vger.kernel.org
 Description:   Current softblock state. This file is read and write.
 Values:        A numeric value.
+
                0: inactive
                        The transmitter is (potentially) active.
+
                1: active
                        The transmitter is turned off by software.
index 58e94e7d55be5f8ec949545c677b148f0ec46868..91ca63ec7581aa72be7d2bb2228d6ab18d92470f 100644 (file)
@@ -32,11 +32,11 @@ KernelVersion:      2.6.12
 Contact:       linux-integrity@vger.kernel.org
 Description:   The "caps" property contains TPM manufacturer and version info.
 
-               Example output:
+               Example output::
 
-               Manufacturer: 0x53544d20
-               TCG version: 1.2
-               Firmware version: 8.16
+                 Manufacturer: 0x53544d20
+                 TCG version: 1.2
+                 Firmware version: 8.16
 
                Manufacturer is a hex dump of the 4 byte manufacturer info
                space in a TPM. TCG version shows the TCG TPM spec level that
@@ -54,9 +54,9 @@ Description:  The "durations" property shows the 3 vendor-specific values
                any longer than necessary before starting to poll for a
                result.
 
-               Example output:
+               Example output::
 
-               3015000 4508000 180995000 [original]
+                 3015000 4508000 180995000 [original]
 
                Here the short, medium and long durations are displayed in
                usecs. "[original]" indicates that the values are displayed
@@ -92,14 +92,14 @@ Description:        The "pcrs" property will dump the current value of all Platform
                values may be constantly changing, the output is only valid
                for a snapshot in time.
 
-               Example output:
+               Example output::
 
-               PCR-00: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
-               PCR-01: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
-               PCR-02: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
-               PCR-03: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
-               PCR-04: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
-               ...
+                 PCR-00: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
+                 PCR-01: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
+                 PCR-02: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
+                 PCR-03: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
+                 PCR-04: 3A 3F 78 0F 11 A4 B4 99 69 FC AA 80 CD 6E 39 57 C3 3B 22 75
+                 ...
 
                The number of PCRs and hex bytes needed to represent a PCR
                value will vary depending on TPM chip version. For TPM 1.1 and
@@ -119,44 +119,44 @@ Description:      The "pubek" property will return the TPM's public endorsement
                ated at TPM manufacture time and exists for the life of the
                chip.
 
-               Example output:
-
-               Algorithm: 00 00 00 01
-               Encscheme: 00 03
-               Sigscheme: 00 01
-               Parameters: 00 00 08 00 00 00 00 02 00 00 00 00
-               Modulus length: 256
-               Modulus:
-               B4 76 41 82 C9 20 2C 10 18 40 BC 8B E5 44 4C 6C
-               3A B2 92 0C A4 9B 2A 83 EB 5C 12 85 04 48 A0 B6
-               1E E4 81 84 CE B2 F2 45 1C F0 85 99 61 02 4D EB
-               86 C4 F7 F3 29 60 52 93 6B B2 E5 AB 8B A9 09 E3
-               D7 0E 7D CA 41 BF 43 07 65 86 3C 8C 13 7A D0 8B
-               82 5E 96 0B F8 1F 5F 34 06 DA A2 52 C1 A9 D5 26
-               0F F4 04 4B D9 3F 2D F2 AC 2F 74 64 1F 8B CD 3E
-               1E 30 38 6C 70 63 69 AB E2 50 DF 49 05 2E E1 8D
-               6F 78 44 DA 57 43 69 EE 76 6C 38 8A E9 8E A3 F0
-               A7 1F 3C A8 D0 12 15 3E CA 0E BD FA 24 CD 33 C6
-               47 AE A4 18 83 8E 22 39 75 93 86 E6 FD 66 48 B6
-               10 AD 94 14 65 F9 6A 17 78 BD 16 53 84 30 BF 70
-               E0 DC 65 FD 3C C6 B0 1E BF B9 C1 B5 6C EF B1 3A
-               F8 28 05 83 62 26 11 DC B4 6B 5A 97 FF 32 26 B6
-               F7 02 71 CF 15 AE 16 DD D1 C1 8E A8 CF 9B 50 7B
-               C3 91 FF 44 1E CF 7C 39 FE 17 77 21 20 BD CE 9B
-
-               Possible values:
-
-               Algorithm:      TPM_ALG_RSA                     (1)
-               Encscheme:      TPM_ES_RSAESPKCSv15             (2)
+               Example output::
+
+                 Algorithm: 00 00 00 01
+                 Encscheme: 00 03
+                 Sigscheme: 00 01
+                 Parameters: 00 00 08 00 00 00 00 02 00 00 00 00
+                 Modulus length: 256
+                 Modulus:
+                 B4 76 41 82 C9 20 2C 10 18 40 BC 8B E5 44 4C 6C
+                 3A B2 92 0C A4 9B 2A 83 EB 5C 12 85 04 48 A0 B6
+                 1E E4 81 84 CE B2 F2 45 1C F0 85 99 61 02 4D EB
+                 86 C4 F7 F3 29 60 52 93 6B B2 E5 AB 8B A9 09 E3
+                 D7 0E 7D CA 41 BF 43 07 65 86 3C 8C 13 7A D0 8B
+                 82 5E 96 0B F8 1F 5F 34 06 DA A2 52 C1 A9 D5 26
+                 0F F4 04 4B D9 3F 2D F2 AC 2F 74 64 1F 8B CD 3E
+                 1E 30 38 6C 70 63 69 AB E2 50 DF 49 05 2E E1 8D
+                 6F 78 44 DA 57 43 69 EE 76 6C 38 8A E9 8E A3 F0
+                 A7 1F 3C A8 D0 12 15 3E CA 0E BD FA 24 CD 33 C6
+                 47 AE A4 18 83 8E 22 39 75 93 86 E6 FD 66 48 B6
+                 10 AD 94 14 65 F9 6A 17 78 BD 16 53 84 30 BF 70
+                 E0 DC 65 FD 3C C6 B0 1E BF B9 C1 B5 6C EF B1 3A
+                 F8 28 05 83 62 26 11 DC B4 6B 5A 97 FF 32 26 B6
+                 F7 02 71 CF 15 AE 16 DD D1 C1 8E A8 CF 9B 50 7B
+                 C3 91 FF 44 1E CF 7C 39 FE 17 77 21 20 BD CE 9B
+
+               Possible values::
+
+                 Algorithm:    TPM_ALG_RSA                     (1)
+                 Encscheme:    TPM_ES_RSAESPKCSv15             (2)
                                TPM_ES_RSAESOAEP_SHA1_MGF1      (3)
-               Sigscheme:      TPM_SS_NONE                     (1)
-               Parameters, a byte string of 3 u32 values:
+                 Sigscheme:    TPM_SS_NONE                     (1)
+                 Parameters, a byte string of 3 u32 values:
                        Key Length (bits):      00 00 08 00     (2048)
                        Num primes:             00 00 00 02     (2)
                        Exponent Size:          00 00 00 00     (0 means the
                                                                 default exp)
-               Modulus Length: 256 (bytes)
-               Modulus:        The 256 byte Endorsement Key modulus
+                 Modulus Length: 256 (bytes)
+                 Modulus:      The 256 byte Endorsement Key modulus
 
 What:          /sys/class/tpm/tpmX/device/temp_deactivated
 Date:          April 2006
@@ -176,9 +176,9 @@ Description:        The "timeouts" property shows the 4 vendor-specific values
                timeouts is defined by the TPM interface spec that the chip
                conforms to.
 
-               Example output:
+               Example output::
 
-               750000 750000 750000 750000 [original]
+                 750000 750000 750000 750000 [original]
 
                The four timeout values are shown in usecs, with a trailing
                "[original]" or "[adjusted]" depending on whether the values
@@ -191,6 +191,6 @@ Contact:    linux-integrity@vger.kernel.org
 Description:   The "tpm_version_major" property shows the TCG spec major version
                implemented by the TPM device.
 
-               Example output:
+               Example output::
 
-               2
+                 2
index 4404bd9b96c1972336b02707346f951fc3642a6b..42bf1eab5677ba462e05d3f68954dd013e2dfeb7 100644 (file)
@@ -1,5 +1,6 @@
-# Note: This documents additional properties of any device beyond what
-# is documented in Documentation/admin-guide/sysfs-rules.rst
+Note:
+  This documents additional properties of any device beyond what
+  is documented in Documentation/admin-guide/sysfs-rules.rst
 
 What:          /sys/devices/*/of_node
 Date:          February 2015
index 420c1d09e42f36fa9cbd24375cf985815450a575..3a4e2cd0ddcc0e203c44f7cd347e89931b821b95 100644 (file)
@@ -1,29 +1,29 @@
-What:           sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/cap
+What:           /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/cap
 Date:           December 3, 2009
 KernelVersion:  2.6.32
 Contact:        dmaengine@vger.kernel.org
 Description:   Capabilities the DMA supports.Currently there are DMA_PQ, DMA_PQ_VAL,
                DMA_XOR,DMA_XOR_VAL,DMA_INTERRUPT.
 
-What:           sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_active
+What:           /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_active
 Date:           December 3, 2009
 KernelVersion:  2.6.32
 Contact:        dmaengine@vger.kernel.org
 Description:   The number of descriptors active in the ring.
 
-What:           sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_size
+What:           /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/ring_size
 Date:           December 3, 2009
 KernelVersion:  2.6.32
 Contact:        dmaengine@vger.kernel.org
 Description:   Descriptor ring size, total number of descriptors available.
 
-What:           sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/version
+What:           /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/version
 Date:           December 3, 2009
 KernelVersion:  2.6.32
 Contact:        dmaengine@vger.kernel.org
 Description:   Version of ioatdma device.
 
-What:           sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/intr_coalesce
+What:           /sys/devices/pciXXXX:XX/0000:XX:XX.X/dma/dma<n>chan<n>/quickdata/intr_coalesce
 Date:           August 8, 2017
 KernelVersion:  4.14
 Contact:        dmaengine@vger.kernel.org
index 00fa04c76ff3f79ab7a416aa9468eae508a3948c..f5724bb5b4624bb0b7c65650049406f531964fa7 100644 (file)
@@ -12,13 +12,15 @@ Description:
                resets. Three registers are used by the FSBL and
                other Xilinx software products: GLOBAL_GEN_STORAGE{4:6}.
 
-               Usage:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
-               # echo <value> > /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
+               Usage::
+
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
+                   # echo <value> > /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
+
+               Example::
 
-               Example:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
-               # echo 0x1234ABCD > /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
+                   # echo 0x1234ABCD > /sys/devices/platform/firmware\:zynqmp-firmware/ggs0
 
 Users:         Xilinx
 
@@ -39,13 +41,15 @@ Description:
                software products: PERS_GLOB_GEN_STORAGE{4:7}.
                Register is reset only by a POR reset.
 
-               Usage:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
-               # echo <value> > /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
+               Usage::
+
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
+                   # echo <value> > /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
+
+               Example::
 
-               Example:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
-               # echo 0x1234ABCD > /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
+                   # echo 0x1234ABCD > /sys/devices/platform/firmware\:zynqmp-firmware/pggs0
 
 Users:         Xilinx
 
@@ -61,23 +65,28 @@ Description:
 
                Following are available shutdown scopes(subtypes):
 
-               subsystem:      Only the APU along with all of its peripherals
+               subsystem:
+                               Only the APU along with all of its peripherals
                                not used by other processing units will be
                                shut down. This may result in the FPD power
                                domain being shut down provided that no other
                                processing unit uses FPD peripherals or DRAM.
-               ps_only:        The complete PS will be shut down, including the
+               ps_only:
+                               The complete PS will be shut down, including the
                                RPU, PMU, etc.  Only the PL domain (FPGA)
                                remains untouched.
-               system:         The complete system/device is shut down.
+               system:
+                               The complete system/device is shut down.
 
-               Usage:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
-               # echo <scope> > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
+               Usage::
+
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
+                   # echo <scope> > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
+
+               Example::
 
-               Example:
-               # cat /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
-               # echo "subsystem" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
+                   # cat /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
+                   # echo "subsystem" > /sys/devices/platform/firmware\:zynqmp-firmware/shutdown_scope
 
 Users:         Xilinx
 
@@ -94,10 +103,13 @@ Description:
                system restart.
 
                Usage:
-               Set healthy bit
-               # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
 
-               Unset healthy bit
-               # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
+               Set healthy bit::
+
+                   # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
+
+               Unset healthy bit::
+
+                   # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/health_status
 
 Users:         Xilinx
index 84972a57caaeb9cfdab006648303fc4db5f56c7f..bada15a329f7ce7cda5e023f45f09e5d1d3ec056 100644 (file)
@@ -6,6 +6,7 @@ Description:    Interface for making ib_srp connect to a new target.
                One can request ib_srp to connect to a new target by writing
                a comma-separated list of login parameters to this sysfs
                attribute. The supported parameters are:
+
                * id_ext, a 16-digit hexadecimal number specifying the eight
                  byte identifier extension in the 16-byte SRP target port
                  identifier. The target port identifier is sent by ib_srp
index c6a32c434ce92a3e0e7daa16864ba931fc4631d2..792f58ba327d3bef5c34a4debf340c617a5e8fbb 100644 (file)
@@ -69,6 +69,7 @@ Description:  Controls if typing interrupts output from speakup. With
                speakup if for example
                the say screen command is used before the
                entire screen  is read.
+
                With no_interrupt set to one, if the say
                screen command is used, and one then types on the keyboard,
                speakup will continue to say the whole screen regardless until
@@ -215,8 +216,10 @@ Description:       This file contains names for key states.
                Again, these are part of the help system.  For instance, if you
                had pressed speakup + keypad 3, you would hear:
                "speakup keypad 3 is go to bottom edge."
+
                The speakup key is depressed, so the name of the key state is
                speakup.
+
                This part of the message comes from the states collection.
 
 What:          /sys/accessibility/speakup/i18n/characters
@@ -297,6 +300,7 @@ KernelVersion:      2.6
 Contact:       speakup@linux-speakup.org
 Description:   Controls if punctuation is spoken by speakup, or by the
                synthesizer.
+
                For example, speakup speaks ">" as "greater", while
                the espeak synthesizer used by the soft driver speaks "greater
                than". Zero lets speakup speak the punctuation. One lets the
index 5def20b9019e93299ed111d53c338e705b1e2639..46ccd233e3594e12234e0da9f985df232bef5664 100644 (file)
@@ -17,6 +17,7 @@ Description:
                directory has a name of the form "<key>-<vendor guid>"
                and contains the following files:
 
+               =============== ========================================
                attributes:     A read-only text file enumerating the
                                EFI variable flags.  Potential values
                                include:
@@ -59,12 +60,14 @@ Description:
 
                size:           As ASCII representation of the size of
                                the variable's value.
+               =============== ========================================
 
 
                In addition, two other magic binary files are provided
                in the top-level directory and are used for adding and
                removing variables:
 
+               =============== ========================================
                new_var:        Takes a "struct efi_variable" and
                                instructs the EFI firmware to create a
                                new variable.
@@ -73,3 +76,4 @@ Description:
                                instructs the EFI firmware to remove any
                                variable that has a matching vendor GUID
                                and variable key name.
+               =============== ========================================
index 32fe7f5c488069c64b8c37951b6dfcfa90f4eb57..1f74f45327ba2bbf12ec0df97ed5de9d33edc9f4 100644 (file)
@@ -7,6 +7,7 @@ Description:
 
                This is only for the powerpc/powernv platform.
 
+               =============== ===============================================
                initiate_dump:  When '1' is written to it,
                                we will initiate a dump.
                                Read this file for supported commands.
@@ -19,8 +20,11 @@ Description:
                                and ID of the dump, use the id and type files.
                                Do not rely on any particular size of dump
                                type or dump id.
+               =============== ===============================================
 
                Each dump has the following files:
+
+               =============== ===============================================
                id:             An ASCII representation of the dump ID
                                in hex (e.g. '0x01')
                type:           An ASCII representation of the type of
@@ -39,3 +43,4 @@ Description:
                                inaccessible.
                                Reading this file will get a list of
                                supported actions.
+               =============== ===============================================
index 2536434d49d06cff06b31331a2f12d7d475725c4..7c8a61a2d005596b3d5a526e1ade6bc30d1886d5 100644 (file)
@@ -38,6 +38,7 @@ Description:
                For each log entry (directory), there are the following
                files:
 
+               ==============  ================================================
                id:             An ASCII representation of the ID of the
                                error log, in hex - e.g. "0x01".
 
@@ -58,3 +59,4 @@ Description:
                                entry will be removed from sysfs.
                                Reading this file will list the supported
                                operations (currently just acknowledge).
+               ==============  ================================================
index 3cf5cdfcd9a8c20a169b71ae75f0fc17cbab1ffd..748593c64568ba4a62d7473addacd5687392a400 100644 (file)
@@ -33,6 +33,8 @@ Description:  If running under Xen:
                Space separated list of supported guest system types. Each type
                is in the format: <class>-<major>.<minor>-<arch>
                With:
+
+                       ======== ============================================
                        <class>: "xen" -- x86: paravirtualized, arm: standard
                                 "hvm" -- x86 only: fully virtualized
                        <major>: major guest interface version
@@ -43,6 +45,7 @@ Description:  If running under Xen:
                                 "x86_64": 64 bit x86 guest
                                 "armv7l": 32 bit arm guest
                                 "aarch64": 64 bit arm guest
+                       ======== ============================================
 
 What:          /sys/hypervisor/properties/changeset
 Date:          March 2009
index 55406ec8a35a34d9c0f67713344e769d5fc76021..951838d4278114bb24a44eb95a12628c9e463714 100644 (file)
@@ -1,3 +1,9 @@
+What:          vDSO
+Date:          July 2011
+KernelVersion: 3.0
+Contact:       Andy Lutomirski <luto@kernel.org>
+Description:
+
 On some architectures, when the kernel loads any userspace program it
 maps an ELF DSO into that program's address space.  This DSO is called
 the vDSO and it often contains useful and highly-optimized alternatives
@@ -23,6 +29,7 @@ Unless otherwise noted, the set of symbols with any given version and the
 ABI of those symbols is considered stable.  It may vary across architectures,
 though.
 
-(As of this writing, this ABI documentation as been confirmed for x86_64.
+Note:
+ As of this writing, this ABI documentation as been confirmed for x86_64.
  The maintainers of the other vDSO-using architectures should confirm
- that it is correct for their architecture.)
+ that it is correct for their architecture.
index 4ab4e99aa863e5054ff28abc5e5a75613d96f4de..c09b640c3cb14afb3a2e0374fffbd44da7b9e033 100644 (file)
@@ -14,7 +14,8 @@ Description:
                This group contains the configuration for user defined ACPI
                tables. The attributes of a user define table are:
 
-               aml             - a binary attribute that the user can use to
+               aml
+                             - a binary attribute that the user can use to
                                fill in the ACPI aml definitions. Once the aml
                                data is written to this file and the file is
                                closed the table will be loaded and ACPI devices
@@ -26,11 +27,26 @@ Description:
                The rest of the attributes are read-only and are valid only
                after the table has been loaded by filling the aml entry:
 
-               signature       - ASCII table signature
-               length          - length of table in bytes, including the header
-               revision        - ACPI Specification minor version number
-               oem_id          - ASCII OEM identification
-               oem_table_id    - ASCII OEM table identification
-               oem_revision    - OEM revision number
-               asl_compiler_id - ASCII ASL compiler vendor ID
-               asl_compiler_revision - ASL compiler version
+               signature
+                               - ASCII table signature
+
+               length
+                               - length of table in bytes, including the header
+
+               revision
+                               - ACPI Specification minor version number
+
+               oem_id
+                               - ASCII OEM identification
+
+               oem_table_id
+                               - ASCII OEM table identification
+
+               oem_revision
+                               - OEM revision number
+
+               asl_compiler_id
+                               - ASCII ASL compiler vendor ID
+
+               asl_compiler_revision
+                               - ASL compiler version
index ed67a4d9f6d63f8bc410c2560df45236bb2d7927..bc6b8bd18da49bf32ab23eb0b12e75e27d81790e 100644 (file)
@@ -15,22 +15,28 @@ KernelVersion:  5.2
 Description:
                The attributes:
 
-               buffer_size     configure the buffer size for this channel
+               buffer_size
+                               configure the buffer size for this channel
 
-               subbuffer_size  configure the sub-buffer size for this channel
+               subbuffer_size
+                               configure the sub-buffer size for this channel
                                (needed for synchronous and isochrnous data)
 
 
-               num_buffers     configure number of buffers used for this
+               num_buffers
+                               configure number of buffers used for this
                                channel
 
-               datatype        configure type of data that will travel over
+               datatype
+                               configure type of data that will travel over
                                this channel
 
-               direction       configure whether this link will be an input
+               direction
+                               configure whether this link will be an input
                                or output
 
-               dbr_size        configure DBR data buffer size (this is used
+               dbr_size
+                               configure DBR data buffer size (this is used
                                for MediaLB communication only)
 
                packets_per_xact
@@ -39,18 +45,23 @@ Description:
                                transmitted via USB (this is used for USB
                                communication only)
 
-               device          name of the device the link is to be attached to
+               device
+                               name of the device the link is to be attached to
 
-               channel         name of the channel the link is to be attached to
+               channel
+                               name of the channel the link is to be attached to
 
-               comp_params     pass parameters needed by some components
+               comp_params
+                               pass parameters needed by some components
 
-               create_link     write '1' to this attribute to trigger the
+               create_link
+                               write '1' to this attribute to trigger the
                                creation of the link. In case of speculative
                                configuration, the creation is post-poned until
                                a physical device is being attached to the bus.
 
-               destroy_link    write '1' to this attribute to destroy an
+               destroy_link
+                               write '1' to this attribute to destroy an
                                active link
 
 What:          /sys/kernel/config/most_video/<link>
@@ -59,22 +70,28 @@ KernelVersion:  5.2
 Description:
                The attributes:
 
-               buffer_size     configure the buffer size for this channel
+               buffer_size
+                               configure the buffer size for this channel
 
-               subbuffer_size  configure the sub-buffer size for this channel
+               subbuffer_size
+                               configure the sub-buffer size for this channel
                                (needed for synchronous and isochrnous data)
 
 
-               num_buffers     configure number of buffers used for this
+               num_buffers
+                               configure number of buffers used for this
                                channel
 
-               datatype        configure type of data that will travel over
+               datatype
+                               configure type of data that will travel over
                                this channel
 
-               direction       configure whether this link will be an input
+               direction
+                               configure whether this link will be an input
                                or output
 
-               dbr_size        configure DBR data buffer size (this is used
+               dbr_size
+                               configure DBR data buffer size (this is used
                                for MediaLB communication only)
 
                packets_per_xact
@@ -83,18 +100,23 @@ Description:
                                transmitted via USB (this is used for USB
                                communication only)
 
-               device          name of the device the link is to be attached to
+               device
+                               name of the device the link is to be attached to
 
-               channel         name of the channel the link is to be attached to
+               channel
+                               name of the channel the link is to be attached to
 
-               comp_params     pass parameters needed by some components
+               comp_params
+                               pass parameters needed by some components
 
-               create_link     write '1' to this attribute to trigger the
+               create_link
+                               write '1' to this attribute to trigger the
                                creation of the link. In case of speculative
                                configuration, the creation is post-poned until
                                a physical device is being attached to the bus.
 
-               destroy_link    write '1' to this attribute to destroy an
+               destroy_link
+                               write '1' to this attribute to destroy an
                                active link
 
 What:          /sys/kernel/config/most_net/<link>
@@ -103,22 +125,28 @@ KernelVersion:  5.2
 Description:
                The attributes:
 
-               buffer_size     configure the buffer size for this channel
+               buffer_size
+                               configure the buffer size for this channel
 
-               subbuffer_size  configure the sub-buffer size for this channel
+               subbuffer_size
+                               configure the sub-buffer size for this channel
                                (needed for synchronous and isochrnous data)
 
 
-               num_buffers     configure number of buffers used for this
+               num_buffers
+                               configure number of buffers used for this
                                channel
 
-               datatype        configure type of data that will travel over
+               datatype
+                               configure type of data that will travel over
                                this channel
 
-               direction       configure whether this link will be an input
+               direction
+                               configure whether this link will be an input
                                or output
 
-               dbr_size        configure DBR data buffer size (this is used
+               dbr_size
+                               configure DBR data buffer size (this is used
                                for MediaLB communication only)
 
                packets_per_xact
@@ -127,18 +155,23 @@ Description:
                                transmitted via USB (this is used for USB
                                communication only)
 
-               device          name of the device the link is to be attached to
+               device
+                               name of the device the link is to be attached to
 
-               channel         name of the channel the link is to be attached to
+               channel
+                               name of the channel the link is to be attached to
 
-               comp_params     pass parameters needed by some components
+               comp_params
+                               pass parameters needed by some components
 
-               create_link     write '1' to this attribute to trigger the
+               create_link
+                               write '1' to this attribute to trigger the
                                creation of the link. In case of speculative
                                configuration, the creation is post-poned until
                                a physical device is being attached to the bus.
 
-               destroy_link    write '1' to this attribute to destroy an
+               destroy_link
+                               write '1' to this attribute to destroy an
                                active link
 
 What:          /sys/kernel/config/most_sound/<card>
@@ -147,7 +180,8 @@ KernelVersion:  5.2
 Description:
                The attributes:
 
-               create_card     write '1' to this attribute to trigger the
+               create_card
+                               write '1' to this attribute to trigger the
                                 registration of the sound card with the ALSA
                                subsystem.
 
@@ -157,22 +191,28 @@ KernelVersion:  5.2
 Description:
                The attributes:
 
-               buffer_size     configure the buffer size for this channel
+               buffer_size
+                               configure the buffer size for this channel
 
-               subbuffer_size  configure the sub-buffer size for this channel
+               subbuffer_size
+                               configure the sub-buffer size for this channel
                                (needed for synchronous and isochrnous data)
 
 
-               num_buffers     configure number of buffers used for this
+               num_buffers
+                               configure number of buffers used for this
                                channel
 
-               datatype        configure type of data that will travel over
+               datatype
+                               configure type of data that will travel over
                                this channel
 
-               direction       configure whether this link will be an input
+               direction
+                               configure whether this link will be an input
                                or output
 
-               dbr_size        configure DBR data buffer size (this is used
+               dbr_size
+                               configure DBR data buffer size (this is used
                                for MediaLB communication only)
 
                packets_per_xact
@@ -181,16 +221,21 @@ Description:
                                transmitted via USB (this is used for USB
                                communication only)
 
-               device          name of the device the link is to be attached to
+               device
+                               name of the device the link is to be attached to
 
-               channel         name of the channel the link is to be attached to
+               channel
+                               name of the channel the link is to be attached to
 
-               comp_params     pass parameters needed by some components
+               comp_params
+                               pass parameters needed by some components
 
-               create_link     write '1' to this attribute to trigger the
+               create_link
+                               write '1' to this attribute to trigger the
                                creation of the link. In case of speculative
                                configuration, the creation is post-poned until
                                a physical device is being attached to the bus.
 
-               destroy_link    write '1' to this attribute to destroy an
+               destroy_link
+                               write '1' to this attribute to destroy an
                                active link
index 840c324ef34d3e67b1c2d39377e075c25be1af9f..cf877bd341df126a56ae57ad64371243760f4a4d 100644 (file)
@@ -10,22 +10,24 @@ Description:
        This interfaces can be used to show spear's PCIe device capability.
 
        Nodes are only visible when configfs is mounted. To mount configfs
-       in /config directory use:
-       # mount -t configfs none /config/
+       in /config directory use::
 
-       For nth PCIe Device Controller
-       /config/pcie-gadget.n/
-               link ... used to enable ltssm and read its status.
-               int_type ...used to configure and read type of supported
-                       interrupt
-               no_of_msi ... used to configure number of MSI vector needed and
+         # mount -t configfs none /config/
+
+       For nth PCIe Device Controller /config/pcie-gadget.n/:
+
+       =============== ======================================================
+       link            used to enable ltssm and read its status.
+       int_type        used to configure and read type of supported interrupt
+       no_of_msi       used to configure number of MSI vector needed and
                        to read no of MSI granted.
-               inta ... write 1 to assert INTA and 0 to de-assert.
-               send_msi ... write MSI vector to be sent.
-               vendor_id ... used to write and read vendor id (hex)
-               device_id ... used to write and read device id (hex)
-               bar0_size ... used to write and read bar0_size
-               bar0_address ... used to write and read bar0 mapped area in hex.
-               bar0_rw_offset ... used to write and read offset of bar0 where
-                       bar0_data will be written or read.
-               bar0_data ... used to write and read data at bar0_rw_offset.
+       inta            write 1 to assert INTA and 0 to de-assert.
+       send_msi        write MSI vector to be sent.
+       vendor_id       used to write and read vendor id (hex)
+       device_id       used to write and read device id (hex)
+       bar0_size       used to write and read bar0_size
+       bar0_address    used to write and read bar0 mapped area in hex.
+       bar0_rw_offset  used to write and read offset of bar0 where bar0_data
+                       will be written or read.
+       bar0_data       used to write and read data at bar0_rw_offset.
+       =============== ======================================================
index 4594cc2435e8cab6a8f3040343cf86d6ed2a232b..dc351e9af80ad0eb93da456c8e696dea08ccbe76 100644 (file)
@@ -12,22 +12,24 @@ Description:
 
                The attributes of a gadget:
 
-               UDC             - bind a gadget to UDC/unbind a gadget;
-                               write UDC's name found in /sys/class/udc/*
-                               to bind a gadget, empty string "" to unbind.
-
-               max_speed       - maximum speed the driver supports. Valid
-                               names are super-speed-plus, super-speed,
-                               high-speed, full-speed, and low-speed.
-
-               bDeviceClass    - USB device class code
-               bDeviceSubClass - USB device subclass code
-               bDeviceProtocol - USB device protocol code
-               bMaxPacketSize0 - maximum endpoint 0 packet size
-               bcdDevice       - bcd device release number
-               bcdUSB          - bcd USB specification version number
-               idProduct       - product ID
-               idVendor        - vendor ID
+               ================  ============================================
+               UDC               bind a gadget to UDC/unbind a gadget;
+                                 write UDC's name found in /sys/class/udc/*
+                                 to bind a gadget, empty string "" to unbind.
+
+               max_speed         maximum speed the driver supports. Valid
+                                 names are super-speed-plus, super-speed,
+                                 high-speed, full-speed, and low-speed.
+
+               bDeviceClass      USB device class code
+               bDeviceSubClass   USB device subclass code
+               bDeviceProtocol   USB device protocol code
+               bMaxPacketSize0   maximum endpoint 0 packet size
+               bcdDevice         bcd device release number
+               bcdUSB            bcd USB specification version number
+               idProduct         product ID
+               idVendor          vendor ID
+               ================  ============================================
 
 What:          /config/usb-gadget/gadget/configs
 Date:          Jun 2013
@@ -41,8 +43,10 @@ KernelVersion:       3.11
 Description:
                The attributes of a configuration:
 
-               bmAttributes    - configuration characteristics
-               MaxPower        - maximum power consumption from the bus
+               ================  ======================================
+               bmAttributes      configuration characteristics
+               MaxPower          maximum power consumption from the bus
+               ================  ======================================
 
 What:          /config/usb-gadget/gadget/configs/config/strings
 Date:          Jun 2013
@@ -57,7 +61,9 @@ KernelVersion:        3.11
 Description:
                The attributes:
 
-               configuration   - configuration description
+               ================  =========================
+               configuration     configuration description
+               ================  =========================
 
 
 What:          /config/usb-gadget/gadget/functions
@@ -76,8 +82,10 @@ Description:
 
                The attributes:
 
-               compatible_id           - 8-byte string for "Compatible ID"
-               sub_compatible_id       - 8-byte string for "Sub Compatible ID"
+               =================       =====================================
+               compatible_id           8-byte string for "Compatible ID"
+               sub_compatible_id       8-byte string for "Sub Compatible ID"
+               =================       =====================================
 
 What:          /config/usb-gadget/gadget/functions/<func>.<inst>/interface.<n>/<property>
 Date:          May 2014
@@ -89,16 +97,19 @@ Description:
 
                The attributes:
 
-               type            - value 1..7 for interpreting the data
-                               1: unicode string
-                               2: unicode string with environment variable
-                               3: binary
-                               4: little-endian 32-bit
-                               5: big-endian 32-bit
-                               6: unicode string with a symbolic link
-                               7: multiple unicode strings
-               data            - blob of data to be interpreted depending on
+               =====           ===============================================
+               type            value 1..7 for interpreting the data
+
+                               - 1: unicode string
+                               - 2: unicode string with environment variable
+                               - 3: binary
+                               - 4: little-endian 32-bit
+                               - 5: big-endian 32-bit
+                               - 6: unicode string with a symbolic link
+                               - 7: multiple unicode strings
+               data            blob of data to be interpreted depending on
                                type
+               =====           ===============================================
 
 What:          /config/usb-gadget/gadget/strings
 Date:          Jun 2013
@@ -113,9 +124,11 @@ KernelVersion:     3.11
 Description:
                The attributes:
 
-               serialnumber    - gadget's serial number (string)
-               product         - gadget's product description
-               manufacturer    - gadget's manufacturer description
+               ============    =================================
+               serialnumber    gadget's serial number (string)
+               product         gadget's product description
+               manufacturer    gadget's manufacturer description
+               ============    =================================
 
 What:          /config/usb-gadget/gadget/os_desc
 Date:          May 2014
@@ -123,8 +136,10 @@ KernelVersion:     3.16
 Description:
                This group contains "OS String" extension handling attributes.
 
-               use             - flag turning "OS Desctiptors" support on/off
-               b_vendor_code   - one-byte value used for custom per-device and
+               =============   ===============================================
+               use             flag turning "OS Desctiptors" support on/off
+               b_vendor_code   one-byte value used for custom per-device and
                                per-interface requests
-               qw_sign         an identifier to be reported as "OS String"
+               qw_sign         an identifier to be reported as "OS String"
                                proper
+               =============   ===============================================
index 0addf7704b4c0ee9639406abfd7f16184d7402fd..272bc1e4ce2e6257639bf1ddf42ae88917d3aa63 100644 (file)
@@ -4,13 +4,17 @@ KernelVersion:        3.11
 Description:
                The attributes:
 
-               ifname          - network device interface name associated with
+               ifname
+                             - network device interface name associated with
                                this function instance
-               qmult           - queue length multiplier for high and
+               qmult   
+                             - queue length multiplier for high and
                                super speed
-               host_addr       - MAC address of host's end of this
+               host_addr
+                             - MAC address of host's end of this
                                Ethernet over USB link
-               dev_addr        - MAC address of device's end of this
+               dev_addr
+                             - MAC address of device's end of this
                                Ethernet over USB link
 
 
index a4c57158fcdef28a8805157b24015eb4edb38568..178c3d5fb64780f64934f9cdff4bf56aa21ceb9a 100644 (file)
@@ -4,11 +4,13 @@ KernelVersion:        3.11
 Description:
                The attributes:
 
-               ifname          - network device interface name associated with
+               ==========      =============================================
+               ifname          network device interface name associated with
                                this function instance
-               qmult           queue length multiplier for high and
+               qmult           queue length multiplier for high and
                                super speed
-               host_addr       MAC address of host's end of this
+               host_addr       MAC address of host's end of this
                                Ethernet over USB link
-               dev_addr        MAC address of device's end of this
+               dev_addr        MAC address of device's end of this
                                Ethernet over USB link
+               ==========      =============================================
index f12e00e6baa34d275be7430c91410da22faca651..748705c4cb5887cb457b5783c8b26c4add996831 100644 (file)
@@ -4,8 +4,10 @@ KernelVersion: 3.19
 Description:
                The attributes:
 
-               protocol        - HID protocol to use
-               report_desc     - blob corresponding to HID report descriptors
+               =============   ============================================
+               protocol        HID protocol to use
+               report_desc     blob corresponding to HID report descriptors
                                except the data passed through /dev/hidg<N>
-               report_length   - HID report length
-               subclass        - HID device subclass to use
+               report_length   HID report length
+               subclass        HID device subclass to use
+               =============   ============================================
index 06beefbcf061a76f2dc1deb5696649eda35c1aaa..e6c6ba5ac7ff4e58ee1be2412dff937946a9b316 100644 (file)
@@ -4,5 +4,7 @@ KernelVersion:  3.13
 Description:
                The attributes:
 
-               qlen            - depth of loopback queue
-               buflen          - buffer length
+               =======         =======================
+               qlen            depth of loopback queue
+               buflen          buffer length
+               =======         =======================
index 9931fb0d63ba44ce155d3e859a5bac2df451298a..c86b63a7bb435be23ad5761d4ca8c6cf98b571ef 100644 (file)
@@ -4,12 +4,14 @@ KernelVersion:        3.13
 Description:
                The attributes:
 
-               stall           - Set to permit function to halt bulk endpoints.
+               ===========     ==============================================
+               stall           Set to permit function to halt bulk endpoints.
                                Disabled on some USB devices known not to work
                                correctly. You should set it to true.
-               num_buffers     Number of pipeline buffers. Valid numbers
+               num_buffers     Number of pipeline buffers. Valid numbers
                                are 2..4. Available only if
                                CONFIG_USB_GADGET_DEBUG_FILES is set.
+               ===========     ==============================================
 
 What:          /config/usb-gadget/gadget/functions/mass_storage.name/lun.name
 Date:          Oct 2013
@@ -17,15 +19,17 @@ KernelVersion:      3.13
 Description:
                The attributes:
 
-               file            - The path to the backing file for the LUN.
+               ===========     ==============================================
+               file            The path to the backing file for the LUN.
                                Required if LUN is not marked as removable.
-               ro              Flag specifying access to the LUN shall be
+               ro              Flag specifying access to the LUN shall be
                                read-only. This is implied if CD-ROM emulation
                                is enabled as well as when it was impossible
                                to open "filename" in R/W mode.
-               removable       Flag specifying that LUN shall be indicated as
+               removable       Flag specifying that LUN shall be indicated as
                                being removable.
-               cdrom           Flag specifying that LUN shall be reported as
+               cdrom           Flag specifying that LUN shall be reported as
                                being a CD-ROM.
-               nofua           Flag specifying that FUA flag
+               nofua           Flag specifying that FUA flag
                                in SCSI WRITE(10,12)
+               ===========     ==============================================
index 6b341df7249c8cb9b3b578ddda5cc08878dced6e..07389cddd51a3d833bab0370529504d9c57763ff 100644 (file)
@@ -4,9 +4,11 @@ KernelVersion: 3.19
 Description:
                The attributes:
 
-               index           - index value for the USB MIDI adapter
-               id              - ID string for the USB MIDI adapter
-               buflen          - MIDI buffer length
-               qlen            - USB read request queue length
-               in_ports        - number of MIDI input ports
-               out_ports       - number of MIDI output ports
+               ==========      ====================================
+               index           index value for the USB MIDI adapter
+               id              ID string for the USB MIDI adapter
+               buflen          MIDI buffer length
+               qlen            USB read request queue length
+               in_ports        number of MIDI input ports
+               out_ports       number of MIDI output ports
+               ==========      ====================================
index 6b0714e3c605f0d04676ee1a95ec084816f4436d..7aa731bac2da326ca4b0a9b58b799cb33b6caeac 100644 (file)
@@ -4,6 +4,8 @@ KernelVersion:  4.1
 Description:
                The attributes:
 
-               pnp_string      - Data to be passed to the host in pnp string
-               q_len           - Number of requests per endpoint
+               ==========      ===========================================
+               pnp_string      Data to be passed to the host in pnp string
+               q_len           Number of requests per endpoint
+               ==========      ===========================================
 
index 137399095d74b53540deed58ffc10b5329a97136..9416eda7fe9330efcd42e10fc473ea22b3d9b309 100644 (file)
@@ -4,14 +4,16 @@ KernelVersion:        3.11
 Description:
                The attributes:
 
-               ifname          - network device interface name associated with
+               =========       =============================================
+               ifname          network device interface name associated with
                                this function instance
-               qmult           queue length multiplier for high and
+               qmult           queue length multiplier for high and
                                super speed
-               host_addr       MAC address of host's end of this
+               host_addr       MAC address of host's end of this
                                Ethernet over USB link
-               dev_addr        MAC address of device's end of this
+               dev_addr        MAC address of device's end of this
                                Ethernet over USB link
-               class           - USB interface class, default is 02 (hex)
-               subclass        - USB interface subclass, default is 06 (hex)
-               protocol        - USB interface protocol, default is 00 (hex)
+               class           USB interface class, default is 02 (hex)
+               subclass        USB interface subclass, default is 06 (hex)
+               protocol        USB interface protocol, default is 00 (hex)
+               =========       =============================================
index f56335af2d88f7d8faf5ad0109e0da75aafe1e2b..1f3d31b607b7cec1f75bdcd74aa9c40b6e0a3edd 100644 (file)
@@ -4,11 +4,13 @@ KernelVersion:        3.13
 Description:
                The attributes:
 
-               pattern         - 0 (all zeros), 1 (mod63), 2 (none)
-               isoc_interval   - 1..16
-               isoc_maxpacket  - 0 - 1023 (fs), 0 - 1024 (hs/ss)
-               isoc_mult       - 0..2 (hs/ss only)
-               isoc_maxburst   - 0..15 (ss only)
-               buflen          - buffer length
-               bulk_qlen       - depth of queue for bulk
-               iso_qlen        - depth of queue for iso
+               ==============    ==================================
+               pattern           0 (all zeros), 1 (mod63), 2 (none)
+               isoc_interval     1..16
+               isoc_maxpacket    0 - 1023 (fs), 0 - 1024 (hs/ss)
+               isoc_mult         0..2 (hs/ss only)
+               isoc_maxburst     0..15 (ss only)
+               buflen            buffer length
+               bulk_qlen         depth of queue for bulk
+               iso_qlen          depth of queue for iso
+               ==============    ==================================
index 9373e2c51ea454e6de4031908ed5cdee4a04e9b6..0061b864351fa97f78f0b06311e699dd947af1ac 100644 (file)
@@ -4,11 +4,13 @@ KernelVersion:        3.11
 Description:
                The attributes:
 
-               ifname          - network device interface name associated with
+               ==========      =============================================
+               ifname          network device interface name associated with
                                this function instance
-               qmult           queue length multiplier for high and
+               qmult           queue length multiplier for high and
                                super speed
-               host_addr       MAC address of host's end of this
+               host_addr       MAC address of host's end of this
                                Ethernet over USB link
-               dev_addr        MAC address of device's end of this
+               dev_addr        MAC address of device's end of this
                                Ethernet over USB link
+               ==========      =============================================
index abfe447c848fc00ba527a9909110f98b42fbab9f..dc23fd776943b9721f175e715fc4a064caa12cfd 100644 (file)
@@ -4,11 +4,13 @@ KernelVersion:        4.14
 Description:
                The attributes:
 
-               c_chmask - capture channel mask
-               c_srate - capture sampling rate
-               c_ssize - capture sample size (bytes)
-               p_chmask - playback channel mask
-               p_srate - playback sampling rate
-               p_ssize - playback sample size (bytes)
-               req_number - the number of pre-allocated request
-                       for both capture and playback
+               ==========      ===================================
+               c_chmask        capture channel mask
+               c_srate         capture sampling rate
+               c_ssize         capture sample size (bytes)
+               p_chmask        playback channel mask
+               p_srate         playback sampling rate
+               p_ssize         playback sample size (bytes)
+               req_number      the number of pre-allocated request
+                               for both capture and playback
+               ==========      ===================================
index 2bfdd4efa9bd3683f80cc7c7f7fe49526cdfaa10..d4356c8b8cd6541516582de48c9d5479effa0b52 100644 (file)
@@ -4,9 +4,11 @@ KernelVersion: 3.18
 Description:
                The attributes:
 
-               c_chmask - capture channel mask
-               c_srate - capture sampling rate
-               c_ssize - capture sample size (bytes)
-               p_chmask - playback channel mask
-               p_srate - playback sampling rate
-               p_ssize - playback sample size (bytes)
+               =========  ============================
+               c_chmask   capture channel mask
+               c_srate    capture sampling rate
+               c_ssize    capture sample size (bytes)
+               p_chmask   playback channel mask
+               p_srate    playback sampling rate
+               p_ssize    playback sample size (bytes)
+               =========  ============================
index 809765bd95730649f89030c4441831559da8da51..ac5e11af79a81b0a8e8b57016103d4ea2090d579 100644 (file)
@@ -3,9 +3,11 @@ Date:          Dec 2014
 KernelVersion: 4.0
 Description:   UVC function directory
 
-               streaming_maxburst      - 0..15 (ss only)
-               streaming_maxpacket     - 1..1023 (fs), 1..3072 (hs/ss)
-               streaming_interval      - 1..16
+               ===================     =============================
+               streaming_maxburst      0..15 (ss only)
+               streaming_maxpacket     1..1023 (fs), 1..3072 (hs/ss)
+               streaming_interval      1..16
+               ===================     =============================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/control
 Date:          Dec 2014
@@ -13,8 +15,11 @@ KernelVersion:       4.0
 Description:   Control descriptors
 
                All attributes read only:
-               bInterfaceNumber        - USB interface number for this
-                                         streaming interface
+
+               ================        =============================
+               bInterfaceNumber        USB interface number for this
+                                       streaming interface
+               ================        =============================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/control/class
 Date:          Dec 2014
@@ -47,13 +52,16 @@ KernelVersion:      4.0
 Description:   Default output terminal descriptors
 
                All attributes read only:
-               iTerminal       - index of string descriptor
-               bSourceID       - id of the terminal to which this terminal
+
+               ==============  =============================================
+               iTerminal       index of string descriptor
+               bSourceID       id of the terminal to which this terminal
                                is connected
-               bAssocTerminal  id of the input terminal to which this output
+               bAssocTerminal  id of the input terminal to which this output
                                terminal is associated
-               wTerminalType   - terminal type
-               bTerminalID     - a non-zero id of this terminal
+               wTerminalType   terminal type
+               bTerminalID     a non-zero id of this terminal
+               ==============  =============================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/control/terminal/camera
 Date:          Dec 2014
@@ -66,16 +74,19 @@ KernelVersion:      4.0
 Description:   Default camera terminal descriptors
 
                All attributes read only:
-               bmControls              - bitmap specifying which controls are
-                                       supported for the video stream
-               wOcularFocalLength      - the value of Locular
-               wObjectiveFocalLengthMax- the value of Lmin
-               wObjectiveFocalLengthMin- the value of Lmax
-               iTerminal               - index of string descriptor
-               bAssocTerminal          - id of the output terminal to which
-                                       this terminal is connected
-               wTerminalType           - terminal type
-               bTerminalID             - a non-zero id of this terminal
+
+               ========================  ====================================
+               bmControls                bitmap specifying which controls are
+                                         supported for the video stream
+               wOcularFocalLength        the value of Locular
+               wObjectiveFocalLengthMax  the value of Lmin
+               wObjectiveFocalLengthMin  the value of Lmax
+               iTerminal                 index of string descriptor
+               bAssocTerminal            id of the output terminal to which
+                                         this terminal is connected
+               wTerminalType             terminal type
+               bTerminalID               a non-zero id of this terminal
+               ========================  ====================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/control/processing
 Date:          Dec 2014
@@ -88,13 +99,16 @@ KernelVersion:      4.0
 Description:   Default processing unit descriptors
 
                All attributes read only:
-               iProcessing     - index of string descriptor
-               bmControls      - bitmap specifying which controls are
+
+               =============== ========================================
+               iProcessing     index of string descriptor
+               bmControls      bitmap specifying which controls are
                                supported for the video stream
-               wMaxMultiplier  maximum digital magnification x100
-               bSourceID       id of the terminal to which this unit is
+               wMaxMultiplier  maximum digital magnification x100
+               bSourceID       id of the terminal to which this unit is
                                connected
-               bUnitID         - a non-zero id of this unit
+               bUnitID         a non-zero id of this unit
+               =============== ========================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/control/header
 Date:          Dec 2014
@@ -114,8 +128,11 @@ KernelVersion:     4.0
 Description:   Streaming descriptors
 
                All attributes read only:
-               bInterfaceNumber        - USB interface number for this
-                                         streaming interface
+
+               ================        =============================
+               bInterfaceNumber        USB interface number for this
+                                       streaming interface
+               ================        =============================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/class
 Date:          Dec 2014
@@ -148,13 +165,16 @@ KernelVersion:    4.0
 Description:   Default color matching descriptors
 
                All attributes read only:
-               bMatrixCoefficients     - matrix used to compute luma and
-                                       chroma values from the color primaries
-               bTransferCharacteristics- optoelectronic transfer
-                                       characteristic of the source picutre,
-                                       also called the gamma function
-               bColorPrimaries         - color primaries and the reference
-                                       white
+
+               ========================  ======================================
+               bMatrixCoefficients       matrix used to compute luma and
+                                         chroma values from the color primaries
+               bTransferCharacteristics  optoelectronic transfer
+                                         characteristic of the source picutre,
+                                         also called the gamma function
+               bColorPrimaries           color primaries and the reference
+                                         white
+               ========================  ======================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/mjpeg
 Date:          Dec 2014
@@ -168,47 +188,52 @@ Description:      Specific MJPEG format descriptors
 
                All attributes read only,
                except bmaControls and bDefaultFrameIndex:
-               bFormatIndex            - unique id for this format descriptor;
+
+               ===================     =====================================
+               bFormatIndex            unique id for this format descriptor;
                                        only defined after parent header is
                                        linked into the streaming class;
                                        read-only
-               bmaControls             this format's data for bmaControls in
+               bmaControls             this format's data for bmaControls in
                                        the streaming header
-               bmInterfaceFlags        specifies interlace information,
+               bmInterfaceFlags        specifies interlace information,
                                        read-only
-               bAspectRatioY           the X dimension of the picture aspect
+               bAspectRatioY           the X dimension of the picture aspect
                                        ratio, read-only
-               bAspectRatioX           the Y dimension of the picture aspect
+               bAspectRatioX           the Y dimension of the picture aspect
                                        ratio, read-only
-               bmFlags                 characteristics of this format,
+               bmFlags                 characteristics of this format,
                                        read-only
-               bDefaultFrameIndex      - optimum frame index for this stream
+               bDefaultFrameIndex      optimum frame index for this stream
+               ===================     =====================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/mjpeg/name/name
 Date:          Dec 2014
 KernelVersion: 4.0
 Description:   Specific MJPEG frame descriptors
 
-               bFrameIndex             - unique id for this framedescriptor;
-                                       only defined after parent format is
-                                       linked into the streaming header;
-                                       read-only
-               dwFrameInterval         - indicates how frame interval can be
-                                       programmed; a number of values
-                                       separated by newline can be specified
-               dwDefaultFrameInterval  - the frame interval the device would
-                                       like to use as default
-               dwMaxVideoFrameBufferSize- the maximum number of bytes the
-                                       compressor will produce for a video
-                                       frame or still image
-               dwMaxBitRate            - the maximum bit rate at the shortest
-                                       frame interval in bps
-               dwMinBitRate            - the minimum bit rate at the longest
-                                       frame interval in bps
-               wHeight                 - height of decoded bitmap frame in px
-               wWidth                  - width of decoded bitmam frame in px
-               bmCapabilities          - still image support, fixed frame-rate
-                                       support
+               =========================  =====================================
+               bFrameIndex                unique id for this framedescriptor;
+                                          only defined after parent format is
+                                          linked into the streaming header;
+                                          read-only
+               dwFrameInterval            indicates how frame interval can be
+                                          programmed; a number of values
+                                          separated by newline can be specified
+               dwDefaultFrameInterval     the frame interval the device would
+                                          like to use as default
+               dwMaxVideoFrameBufferSize  the maximum number of bytes the
+                                          compressor will produce for a video
+                                          frame or still image
+               dwMaxBitRate               the maximum bit rate at the shortest
+                                          frame interval in bps
+               dwMinBitRate               the minimum bit rate at the longest
+                                          frame interval in bps
+               wHeight                    height of decoded bitmap frame in px
+               wWidth                     width of decoded bitmam frame in px
+               bmCapabilities             still image support, fixed frame-rate
+                                          support
+               =========================  =====================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/uncompressed
 Date:          Dec 2014
@@ -220,50 +245,54 @@ Date:             Dec 2014
 KernelVersion: 4.0
 Description:   Specific uncompressed format descriptors
 
-               bFormatIndex            - unique id for this format descriptor;
+               ==================      =======================================
+               bFormatIndex            unique id for this format descriptor;
                                        only defined after parent header is
                                        linked into the streaming class;
                                        read-only
-               bmaControls             this format's data for bmaControls in
+               bmaControls             this format's data for bmaControls in
                                        the streaming header
-               bmInterfaceFlags        specifies interlace information,
+               bmInterfaceFlags        specifies interlace information,
                                        read-only
-               bAspectRatioY           the X dimension of the picture aspect
+               bAspectRatioY           the X dimension of the picture aspect
                                        ratio, read-only
-               bAspectRatioX           the Y dimension of the picture aspect
+               bAspectRatioX           the Y dimension of the picture aspect
                                        ratio, read-only
-               bDefaultFrameIndex      optimum frame index for this stream
-               bBitsPerPixel           number of bits per pixel used to
+               bDefaultFrameIndex      optimum frame index for this stream
+               bBitsPerPixel           number of bits per pixel used to
                                        specify color in the decoded video
                                        frame
-               guidFormat              globally unique id used to identify
+               guidFormat              globally unique id used to identify
                                        stream-encoding format
+               ==================      =======================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/uncompressed/name/name
 Date:          Dec 2014
 KernelVersion: 4.0
 Description:   Specific uncompressed frame descriptors
 
-               bFrameIndex             - unique id for this framedescriptor;
-                                       only defined after parent format is
-                                       linked into the streaming header;
-                                       read-only
-               dwFrameInterval         - indicates how frame interval can be
-                                       programmed; a number of values
-                                       separated by newline can be specified
-               dwDefaultFrameInterval  - the frame interval the device would
-                                       like to use as default
-               dwMaxVideoFrameBufferSize- the maximum number of bytes the
-                                       compressor will produce for a video
-                                       frame or still image
-               dwMaxBitRate            - the maximum bit rate at the shortest
-                                       frame interval in bps
-               dwMinBitRate            - the minimum bit rate at the longest
-                                       frame interval in bps
-               wHeight                 - height of decoded bitmap frame in px
-               wWidth                  - width of decoded bitmam frame in px
-               bmCapabilities          - still image support, fixed frame-rate
-                                       support
+               =========================  =====================================
+               bFrameIndex                unique id for this framedescriptor;
+                                          only defined after parent format is
+                                          linked into the streaming header;
+                                          read-only
+               dwFrameInterval            indicates how frame interval can be
+                                          programmed; a number of values
+                                          separated by newline can be specified
+               dwDefaultFrameInterval     the frame interval the device would
+                                          like to use as default
+               dwMaxVideoFrameBufferSize  the maximum number of bytes the
+                                          compressor will produce for a video
+                                          frame or still image
+               dwMaxBitRate               the maximum bit rate at the shortest
+                                          frame interval in bps
+               dwMinBitRate               the minimum bit rate at the longest
+                                          frame interval in bps
+               wHeight                    height of decoded bitmap frame in px
+               wWidth                     width of decoded bitmam frame in px
+               bmCapabilities             still image support, fixed frame-rate
+                                          support
+               =========================  =====================================
 
 What:          /config/usb-gadget/gadget/functions/uvc.name/streaming/header
 Date:          Dec 2014
@@ -276,17 +305,20 @@ KernelVersion:    4.0
 Description:   Specific streaming header descriptors
 
                All attributes read only:
-               bTriggerUsage           - how the host software will respond to
+
+               ====================    =====================================
+               bTriggerUsage           how the host software will respond to
                                        a hardware trigger interrupt event
-               bTriggerSupport         flag specifying if hardware
+               bTriggerSupport         flag specifying if hardware
                                        triggering is supported
-               bStillCaptureMethod     method of still image caputre
+               bStillCaptureMethod     method of still image caputre
                                        supported
-               bTerminalLink           id of the output terminal to which
+               bTerminalLink           id of the output terminal to which
                                        the video endpoint of this interface
                                        is connected
-               bmInfo                  capabilities of this video streaming
+               bmInfo                  capabilities of this video streaming
                                        interface
+               ====================    =====================================
 
 What:          /sys/class/udc/udc.name/device/gadget/video4linux/video.name/function_name
 Date:          May 2018
index 5afcd78fbdb7e324d8d12b82224622bc53921a9a..8debcb08a3b5179e065d3e0fbd4cadc836157042 100644 (file)
@@ -23,7 +23,7 @@ error injections without having to know the details of the driver-specific
 commands.
 
 Note that the output of 'error-inj' shall be valid as input to 'error-inj'.
-So this must work:
+So this must work::
 
        $ cat error-inj >einj.txt
        $ cat einj.txt >error-inj
index 2e9ae311e02d23c6dc52e58781f89ee96c3cfe09..c5d678d3914472514eca90fa67f894845a9d374e 100644 (file)
@@ -20,9 +20,13 @@ Description:    Allow the root user to disable/enable in runtime the clock
                 The user can supply a bitmask value, each bit represents
                 a different engine to disable/enable its clock gating feature.
                 The bitmask is composed of 20 bits:
-                0  -  7 : DMA channels
-                8  - 11 : MME engines
-                12 - 19 : TPC engines
+
+               =======   ============
+                0  -  7   DMA channels
+                8  - 11   MME engines
+                12 - 19   TPC engines
+               =======   ============
+
                 The bit's location of a specific engine can be determined
                 using (1 << GAUDI_ENGINE_ID_*). GAUDI_ENGINE_ID_* values
                 are defined in uapi habanalabs.h file in enum gaudi_engine_id
@@ -59,6 +63,7 @@ Description:    Allows the root user to read or write directly through the
                 the generic Linux user-space PCI mapping) because the DDR bar
                 is very small compared to the DDR memory and only the driver can
                 move the bar before and after the transaction.
+
                 If the IOMMU is disabled, it also allows the root user to read
                 or write from the host a device VA of a host mapped memory
 
@@ -73,6 +78,7 @@ Description:    Allows the root user to read or write 64 bit data directly
                 the generic Linux user-space PCI mapping) because the DDR bar
                 is very small compared to the DDR memory and only the driver can
                 move the bar before and after the transaction.
+
                 If the IOMMU is disabled, it also allows the root user to read
                 or write from the host a device VA of a host mapped memory
 
index 6546115a94dae8014be9c01322062731425568cf..ab6099daa8f5e65f3ab1bd76d2b12305cb4c930d 100644 (file)
@@ -6,7 +6,7 @@ Description:
 General information like which GPE is assigned to the EC and whether
 the global lock should get used.
 Knowing the EC GPE one can watch the amount of HW events related to
-the EC here (XY -> GPE number from /sys/kernel/debug/ec/*/gpe):
+the EC here (XY -> GPE number from `/sys/kernel/debug/ec/*/gpe`):
 /sys/firmware/acpi/interrupts/gpeXY
 
 The io file is binary and a userspace tool located here:
@@ -14,7 +14,8 @@ ftp://ftp.suse.com/pub/people/trenn/sources/ec/
 should get used to read out the 256 Embedded Controller registers
 or writing to them.
 
-CAUTION: Do not write to the Embedded Controller if you don't know
-what you are doing! Rebooting afterwards also is a good idea.
-This can influence the way your machine is cooled and fans may
-not get switched on again after you did a wrong write.
+CAUTION:
+  Do not write to the Embedded Controller if you don't know
+  what you are doing! Rebooting afterwards also is a good idea.
+  This can influence the way your machine is cooled and fans may
+  not get switched on again after you did a wrong write.
index 67b1717794d879022e36da5d0b6f69b5dec0fde9..6eee10c3d5a1ae6f5e30f114fea6200ba8d2e44f 100644 (file)
@@ -2,13 +2,19 @@ What:         /sys/kernel/debug/moxtet/input
 Date:          March 2019
 KernelVersion: 5.3
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Read input from the shift registers, in hexadecimal.
+Description:   (Read) Read input from the shift registers, in hexadecimal.
                Returns N+1 bytes, where N is the number of Moxtet connected
                modules. The first byte is from the CPU board itself.
-               Example: 101214
-                        10: CPU board with SD card
-                        12: 2 = PCIe module, 1 = IRQ not active
-                        14: 4 = Peridot module, 1 = IRQ not active
+
+               Example::
+
+                       101214
+
+               ==  =======================================
+               10  CPU board with SD card
+               12  2 = PCIe module, 1 = IRQ not active
+               14  4 = Peridot module, 1 = IRQ not active
+               ==  =======================================
 
 What:          /sys/kernel/debug/moxtet/output
 Date:          March 2019
@@ -17,7 +23,13 @@ Contact:     Marek Behún <marek.behun@nic.cz>
 Description:   (RW) Read last written value to the shift registers, in
                hexadecimal, or write values to the shift registers, also
                in hexadecimal.
-               Example: 0102
-                        01: 01 was last written, or is to be written, to the
-                            first module's shift register
-                        02: the same for second module
+
+               Example::
+
+                   0102
+
+               ==  ================================================
+               01  01 was last written, or is to be written, to the
+                   first module's shift register
+               02  the same for second module
+               ==  ================================================
index 685d5a448423f2d9a5f303786b4ce909d13107d4..f75a655c1531d85f89a297ed9fd49bb70caca58e 100644 (file)
@@ -4,42 +4,42 @@ KernelVersion:        3.4
 Contact:       Kent Yoder <key@linux.vnet.ibm.com>
 Description:
 
-  These debugfs interfaces are built by the nx-crypto driver, built in
+These debugfs interfaces are built by the nx-crypto driver, built in
 arch/powerpc/crypto/nx.
 
 Error Detection
 ===============
 
 errors:
-- A u32 providing a total count of errors since the driver was loaded. The
-only errors counted here are those returned from the hcall, H_COP_OP.
+  A u32 providing a total count of errors since the driver was loaded. The
+  only errors counted here are those returned from the hcall, H_COP_OP.
 
 last_error:
-- The most recent non-zero return code from the H_COP_OP hcall. -EBUSY is not
-recorded here (the hcall will retry until -EBUSY goes away).
+  The most recent non-zero return code from the H_COP_OP hcall. -EBUSY is not
+  recorded here (the hcall will retry until -EBUSY goes away).
 
 last_error_pid:
-- The process ID of the process who received the most recent error from the
-hcall.
+  The process ID of the process who received the most recent error from the
+  hcall.
 
 Device Use
 ==========
 
 aes_bytes:
-- The total number of bytes encrypted using AES in any of the driver's
-supported modes.
+  The total number of bytes encrypted using AES in any of the driver's
+  supported modes.
 
 aes_ops:
-- The total number of AES operations submitted to the hardware.
+  The total number of AES operations submitted to the hardware.
 
 sha256_bytes:
-- The total number of bytes hashed by the hardware using SHA-256.
+  The total number of bytes hashed by the hardware using SHA-256.
 
 sha256_ops:
-- The total number of SHA-256 operations submitted to the hardware.
+  The total number of SHA-256 operations submitted to the hardware.
 
 sha512_bytes:
-- The total number of bytes hashed by the hardware using SHA-512.
+  The total number of bytes hashed by the hardware using SHA-512.
 
 sha512_ops:
-- The total number of SHA-512 operations submitted to the hardware.
+  The total number of SHA-512 operations submitted to the hardware.
index cf11736acb76a9e9822b1fc52a11165476f1671e..f6f65a4faea06c0fc3286b4c4b54c927f0d0fa5c 100644 (file)
@@ -4,16 +4,15 @@ KernelVersion:  2.6.20
 Contact:        Thomas Maier <balagi@justmail.de>
 Description:
 
-debugfs interface
------------------
-
 The pktcdvd module (packet writing driver) creates
 these files in debugfs:
 
 /sys/kernel/debug/pktcdvd/pktcdvd[0-7]/
-    info            (0444) Lots of driver statistics and infos.
 
-Example:
--------
+    ====            ====== ====================================
+    info            0444   Lots of driver statistics and infos.
+    ====            ====== ====================================
+
+Example::
 
-cat /sys/kernel/debug/pktcdvd/pktcdvd0/info
+    cat /sys/kernel/debug/pktcdvd/pktcdvd0/info
index 2b3255ee68fd62a37eabb2d9c90637150db822f8..326df1b74707e1753a6d351b1dd1f783d4b32a43 100644 (file)
@@ -2,8 +2,13 @@ What:          /sys/kernel/debug/turris-mox-rwtm/do_sign
 Date:          Jun 2020
 KernelVersion: 5.8
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (W) Message to sign with the ECDSA private key stored in
-                   device's OTP. The message must be exactly 64 bytes (since
-                   this is intended for SHA-512 hashes).
-               (R) The resulting signature, 136 bytes. This contains the R and
-                   S values of the ECDSA signature, both in big-endian format.
+Description:
+
+               ======= ===========================================================
+               (Write) Message to sign with the ECDSA private key stored in
+                       device's OTP. The message must be exactly 64 bytes
+                       (since this is intended for SHA-512 hashes).
+               (Read)  The resulting signature, 136 bytes. This contains the
+                       R and S values of the ECDSA signature, both in
+                       big-endian format.
+               ======= ===========================================================
index 9d8d9d2def5b35dd367392210d0979190e5f86c8..682e3c09ef4d610e510d81f26a681b9a6b6f2ad6 100644 (file)
@@ -27,16 +27,17 @@ Description:
                for writing, two for the type and at least a single byte of
                data.
 
-               Example:
-               // Request EC info type 3 (EC firmware build date)
-               // Corresponds with sending type 0x00f0 with
-               // MBOX = [38, 00, 03, 00]
-               $ echo 00 f0 38 00 03 00 > /sys/kernel/debug/wilco_ec/raw
-               // View the result. The decoded ASCII result "12/21/18" is
-               // included after the raw hex.
-               // Corresponds with MBOX = [00, 00, 31, 32, 2f, 32, 31, 38, ...]
-               $ cat /sys/kernel/debug/wilco_ec/raw
-               00 00 31 32 2f 32 31 2f 31 38 00 38 00 01 00 2f 00  ..12/21/18.8...
+               Example::
+
+                   // Request EC info type 3 (EC firmware build date)
+                   // Corresponds with sending type 0x00f0 with
+                   // MBOX = [38, 00, 03, 00]
+                   $ echo 00 f0 38 00 03 00 > /sys/kernel/debug/wilco_ec/raw
+                   // View the result. The decoded ASCII result "12/21/18" is
+                   // included after the raw hex.
+                   // Corresponds with MBOX = [00, 00, 31, 32, 2f, 32, 31, 38, ...]
+                   $ cat /sys/kernel/debug/wilco_ec/raw
+                   00 00 31 32 2f 32 31 2f 31 38 00 38 00 01 00 2f 00  ..12/21/18.8...
 
                Note that the first 16 bytes of the received MBOX[] will be
                printed, even if some of the data is junk, and skipping bytes
index fc919ce16008d99c74761406a9351dc275ea0316..5f3a0dc670507163afb6ce65a49b199ce483dd3c 100644 (file)
@@ -10,29 +10,29 @@ Description:
                <uapi/linux/wmi.h>
 
                1) To perform an SMBIOS call from userspace, you'll need to
-               first determine the minimum size of the calling interface
-               buffer for your machine.
-               Platforms that contain larger buffers can return larger
-               objects from the system firmware.
-               Commonly this size is either 4k or 32k.
+                  first determine the minimum size of the calling interface
+                  buffer for your machine.
+                  Platforms that contain larger buffers can return larger
+                  objects from the system firmware.
+                  Commonly this size is either 4k or 32k.
 
-               To determine the size of the buffer read() a u64 dword from
-               the WMI character device /dev/wmi/dell-smbios.
+                  To determine the size of the buffer read() a u64 dword from
+                  the WMI character device /dev/wmi/dell-smbios.
 
                2) After you've determined the minimum size of the calling
-               interface buffer, you can allocate a structure that represents
-               the structure documented above.
+                  interface buffer, you can allocate a structure that represents
+                  the structure documented above.
 
                3) In the 'length' object store the size of the buffer you
-               determined above and allocated.
+                  determined above and allocated.
 
                4) In this buffer object, prepare as necessary for the SMBIOS
-               call you're interested in.  Typically SMBIOS buffers have
-               "class", "select", and "input" defined to values that coincide
-               with the data you are interested in.
-               Documenting class/select/input values is outside of the scope
-               of this documentation. Check with the libsmbios project for
-               further documentation on these values.
+                  call you're interested in.  Typically SMBIOS buffers have
+                  "class", "select", and "input" defined to values that coincide
+                  with the data you are interested in.
+                  Documenting class/select/input values is outside of the scope
+                  of this documentation. Check with the libsmbios project for
+                  further documentation on these values.
 
                6) Run the call by using ioctl() as described in the header.
 
index 3c0bb76e3417e7ce402378e849d4ee7858ae019c..a377b6c093c9425ba9359a1766d1c8b0a9886eaa 100644 (file)
@@ -6,6 +6,7 @@ Description:    The /dev/kmsg character device node provides userspace access
                to the kernel's printk buffer.
 
                Injecting messages:
+
                Every write() to the opened device node places a log entry in
                the kernel's printk buffer.
 
@@ -21,6 +22,7 @@ Description:  The /dev/kmsg character device node provides userspace access
                the messages can always be reliably determined.
 
                Accessing the buffer:
+
                Every read() from the opened device node receives one record
                of the kernel's printk buffer.
 
@@ -48,6 +50,7 @@ Description:  The /dev/kmsg character device node provides userspace access
                if needed, without limiting the interface to a single reader.
 
                The device supports seek with the following parameters:
+
                SEEK_SET, 0
                  seek to the first entry in the buffer
                SEEK_END, 0
@@ -87,18 +90,22 @@ Description:        The /dev/kmsg character device node provides userspace access
                readable context of the message, for reliable processing in
                userspace.
 
-               Example:
-               7,160,424069,-;pci_root PNP0A03:00: host bridge window [io  0x0000-0x0cf7] (ignored)
-                SUBSYSTEM=acpi
-                DEVICE=+acpi:PNP0A03:00
-               6,339,5140900,-;NET: Registered protocol family 10
-               30,340,5690716,-;udevd[80]: starting version 181
+               Example::
+
+                 7,160,424069,-;pci_root PNP0A03:00: host bridge window [io  0x0000-0x0cf7] (ignored)
+                  SUBSYSTEM=acpi
+                  DEVICE=+acpi:PNP0A03:00
+                 6,339,5140900,-;NET: Registered protocol family 10
+                 30,340,5690716,-;udevd[80]: starting version 181
 
                The DEVICE= key uniquely identifies devices the following way:
-                 b12:8        - block dev_t
-                 c127:3       - char dev_t
-                 n8           - netdev ifindex
-                 +sound:card0 - subsystem:devname
+
+                 ============  =================
+                 b12:8         block dev_t
+                 c127:3        char dev_t
+                 n8            netdev ifindex
+                 +sound:card0  subsystem:devname
+                 ============  =================
 
                The flags field carries '-' by default. A 'c' indicates a
                fragment of a line. Note, that these hints about continuation
index 201d10319fa18b588a42246814b13b67047a7dd3..3c477ba48a31233186fa4fe106f8846c3fd5c88b 100644 (file)
@@ -17,26 +17,33 @@ Description:
                echoing a value to <securityfs>/evm made up of the
                following bits:
 
+               ===       ==================================================
                Bit       Effect
+               ===       ==================================================
                0         Enable HMAC validation and creation
                1         Enable digital signature validation
                2         Permit modification of EVM-protected metadata at
                          runtime. Not supported if HMAC validation and
                          creation is enabled.
                31        Disable further runtime modification of EVM policy
+               ===       ==================================================
 
-               For example:
+               For example::
 
-               echo 1 ><securityfs>/evm
+                 echo 1 ><securityfs>/evm
 
                will enable HMAC validation and creation
 
-               echo 0x80000003 ><securityfs>/evm
+               ::
+
+                 echo 0x80000003 ><securityfs>/evm
 
                will enable HMAC and digital signature validation and
                HMAC creation and disable all further modification of policy.
 
-               echo 0x80000006 ><securityfs>/evm
+               ::
+
+                 echo 0x80000006 ><securityfs>/evm
 
                will enable digital signature validation, permit
                modification of EVM-protected metadata and
@@ -65,7 +72,7 @@ Description:
                Shows the set of extended attributes used to calculate or
                validate the EVM signature, and allows additional attributes
                to be added at runtime. Any signatures generated after
-               additional attributes are added (and on files posessing those
+               additional attributes are added (and on files possessing those
                additional attributes) will only be valid if the same
                additional attributes are configured on system boot. Writing
                a single period (.) will lock the xattr list from any further
index 7b265fbb47e37a3f5d63da74e783d9ba91351971..66bdcd188b6c98320ae56b1dcf73585eb891fe91 100644 (file)
@@ -12,15 +12,16 @@ Description:
                The following file operations are supported:
 
                open(2)
-               Currently the only useful flags are O_RDWR.
+                 Currently the only useful flags are O_RDWR.
 
                ioctl(2)
-               Initiate various actions.
-               See the inline documentation in [include/uapi]<linux/gpio.h>
-               for descriptions of all ioctls.
+                 Initiate various actions.
+
+                 See the inline documentation in [include/uapi]<linux/gpio.h>
+                 for descriptions of all ioctls.
 
                close(2)
-               Stops and free up the I/O contexts that was associated
-               with the file descriptor.
+                 Stops and free up the I/O contexts that was associated
+                 with the file descriptor.
 
 Users:         TBD
index cd572912c593898fe82a377be4aa3dda354eaea9..e35263f97fc1a7c89c5eccf8a879223d1c81e02a 100644 (file)
@@ -15,19 +15,22 @@ Description:
                IMA appraisal, if configured, uses these file measurements
                for local measurement appraisal.
 
-               rule format: action [condition ...]
+               ::
 
-               action: measure | dont_measure | appraise | dont_appraise |
-                       audit | hash | dont_hash
-               condition:= base | lsm  [option]
+                 rule format: action [condition ...]
+
+                 action: measure | dont_measure | appraise | dont_appraise |
+                         audit | hash | dont_hash
+                 condition:= base | lsm  [option]
                        base:   [[func=] [mask=] [fsmagic=] [fsuuid=] [uid=]
                                [euid=] [fowner=] [fsname=]]
                        lsm:    [[subj_user=] [subj_role=] [subj_type=]
                                 [obj_user=] [obj_role=] [obj_type=]]
                        option: [[appraise_type=]] [template=] [permit_directio]
                                [appraise_flag=] [keyrings=]
-               base:   func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK][MODULE_CHECK]
-                               [FIRMWARE_CHECK]
+                 base:
+                       func:= [BPRM_CHECK][MMAP_CHECK][CREDS_CHECK][FILE_CHECK]MODULE_CHECK]
+                               [FIRMWARE_CHECK]
                                [KEXEC_KERNEL_CHECK] [KEXEC_INITRAMFS_CHECK]
                                [KEXEC_CMDLINE] [KEY_CHECK]
                        mask:= [[^]MAY_READ] [[^]MAY_WRITE] [[^]MAY_APPEND]
@@ -37,8 +40,9 @@ Description:
                        uid:= decimal value
                        euid:= decimal value
                        fowner:= decimal value
-               lsm:    are LSM specific
-               option: appraise_type:= [imasig] [imasig|modsig]
+                 lsm:  are LSM specific
+                 option:
+                       appraise_type:= [imasig] [imasig|modsig]
                        appraise_flag:= [check_blacklist]
                        Currently, blacklist check is only for files signed with appended
                        signature.
@@ -49,7 +53,7 @@ Description:
                        (eg, ima-ng). Only valid when action is "measure".
                        pcr:= decimal value
 
-               default policy:
+                 default policy:
                        # PROC_SUPER_MAGIC
                        dont_measure fsmagic=0x9fa0
                        dont_appraise fsmagic=0x9fa0
@@ -97,7 +101,8 @@ Description:
 
                Examples of LSM specific definitions:
 
-               SELinux:
+               SELinux::
+
                        dont_measure obj_type=var_log_t
                        dont_appraise obj_type=var_log_t
                        dont_measure obj_type=auditd_log_t
@@ -105,10 +110,11 @@ Description:
                        measure subj_user=system_u func=FILE_CHECK mask=MAY_READ
                        measure subj_role=system_r func=FILE_CHECK mask=MAY_READ
 
-               Smack:
+               Smack::
+
                        measure subj_user=_ func=FILE_CHECK mask=MAY_READ
 
-               Example of measure rules using alternate PCRs:
+               Example of measure rules using alternate PCRs::
 
                        measure func=KEXEC_KERNEL_CHECK pcr=4
                        measure func=KEXEC_INITRAMFS_CHECK pcr=5
index 70dcaf2481f49c99e4e5b23eee5a0f7b671e8369..e58d641443d34a415b451701362b09aaa9f1ba24 100644 (file)
@@ -6,32 +6,38 @@ Description:
                of block devices. Each line contains the following 14
                fields:
 
-                1 - major number
-                2 - minor mumber
-                3 - device name
-                4 - reads completed successfully
-                5 - reads merged
-                6 - sectors read
-                7 - time spent reading (ms)
-                8 - writes completed
-                9 - writes merged
-               10 - sectors written
-               11 - time spent writing (ms)
-               12 - I/Os currently in progress
-               13 - time spent doing I/Os (ms)
-               14 - weighted time spent doing I/Os (ms)
+               ==  ===================================
+                1  major number
+                2  minor mumber
+                3  device name
+                4  reads completed successfully
+                5  reads merged
+                6  sectors read
+                7  time spent reading (ms)
+                8  writes completed
+                9  writes merged
+               10  sectors written
+               11  time spent writing (ms)
+               12  I/Os currently in progress
+               13  time spent doing I/Os (ms)
+               14  weighted time spent doing I/Os (ms)
+               ==  ===================================
 
                Kernel 4.18+ appends four more fields for discard
                tracking putting the total at 18:
 
-               15 - discards completed successfully
-               16 - discards merged
-               17 - sectors discarded
-               18 - time spent discarding
+               ==  ===================================
+               15  discards completed successfully
+               16  discards merged
+               17  sectors discarded
+               18  time spent discarding
+               ==  ===================================
 
                Kernel 5.5+ appends two more fields for flush requests:
 
-               19 - flush requests completed successfully
-               20 - time spent flushing
+               ==  =====================================
+               19  flush requests completed successfully
+               20  time spent flushing
+               ==  =====================================
 
                For more details refer to Documentation/admin-guide/iostats.rst
index 0469781933684cb8bb6e5809e2372a6af6c2e98f..a4e31c46519442dbb42206d363ccaf869babb289 100644 (file)
@@ -14,28 +14,28 @@ Description:
                For more details, see Documentation/filesystems/proc.rst
                and the procfs man page.
 
-               Typical output looks like this:
+               Typical output looks like this::
 
-               00100000-ff709000 ---p 00000000 00:00 0          [rollup]
-               Size:               1192 kB
-               KernelPageSize:        4 kB
-               MMUPageSize:           4 kB
-               Rss:                 884 kB
-               Pss:                 385 kB
-               Pss_Anon:            301 kB
-               Pss_File:             80 kB
-               Pss_Shmem:             4 kB
-               Shared_Clean:        696 kB
-               Shared_Dirty:          0 kB
-               Private_Clean:       120 kB
-               Private_Dirty:        68 kB
-               Referenced:          884 kB
-               Anonymous:            68 kB
-               LazyFree:              0 kB
-               AnonHugePages:         0 kB
-               ShmemPmdMapped:        0 kB
-               Shared_Hugetlb:        0 kB
-               Private_Hugetlb:       0 kB
-               Swap:                  0 kB
-               SwapPss:               0 kB
-               Locked:              385 kB
+                       00100000-ff709000 ---p 00000000 00:00 0          [rollup]
+                       Size:               1192 kB
+                       KernelPageSize:        4 kB
+                       MMUPageSize:           4 kB
+                       Rss:                 884 kB
+                       Pss:                 385 kB
+                       Pss_Anon:            301 kB
+                       Pss_File:             80 kB
+                       Pss_Shmem:             4 kB
+                       Shared_Clean:        696 kB
+                       Shared_Dirty:          0 kB
+                       Private_Clean:       120 kB
+                       Private_Dirty:        68 kB
+                       Referenced:          884 kB
+                       Anonymous:            68 kB
+                       LazyFree:              0 kB
+                       AnonHugePages:         0 kB
+                       ShmemPmdMapped:        0 kB
+                       Shared_Hugetlb:        0 kB
+                       Private_Hugetlb:       0 kB
+                       Swap:                  0 kB
+                       SwapPss:               0 kB
+                       Locked:              385 kB
index d45209abdb1bd979f63f0b0b3c888038fbba2779..5b02540781a236fcb299f9c02cef872419b403d9 100644 (file)
@@ -9,25 +9,25 @@ Description:  Generic interface to platform dependent persistent storage.
                provide a generic interface to show records captured in
                the dying moments.  In the case of a panic the last part
                of the console log is captured, but other interesting
-               data can also be saved.
+               data can also be saved::
 
-               # mount -t pstore -o kmsg_bytes=8000 - /sys/fs/pstore
+                   # mount -t pstore -o kmsg_bytes=8000 - /sys/fs/pstore
 
-               $ ls -l /sys/fs/pstore/
-               total 0
-               -r--r--r-- 1 root root 7896 Nov 30 15:38 dmesg-erst-1
+                   $ ls -l /sys/fs/pstore/
+                   total 0
+                   -r--r--r-- 1 root root 7896 Nov 30 15:38 dmesg-erst-1
 
                Different users of this interface will result in different
                filename prefixes.  Currently two are defined:
 
-               "dmesg" - saved console log
-               "mce"   - architecture dependent data from fatal h/w error
+               "dmesg" - saved console log
+               "mce"   - architecture dependent data from fatal h/w error
 
                Once the information in a file has been read, removing
                the file will signal to the underlying persistent storage
-               device that it can reclaim the space for later re-use.
+               device that it can reclaim the space for later re-use::
 
-               $ rm /sys/fs/pstore/dmesg-erst-1
+                   $ rm /sys/fs/pstore/dmesg-erst-1
 
                The expectation is that all files in /sys/fs/pstore/
                will be saved elsewhere and erased from persistent store
@@ -44,4 +44,3 @@ Description:  Generic interface to platform dependent persistent storage.
                backends are available, the preferred backend may be
                set by passing the pstore.backend= argument to the kernel at
                boot time.
-
index 2322eb748b38774b2936d5411cafa091fef644ab..e34cdeeeb9d420a673f5236ff59ec99242630a40 100644 (file)
@@ -4,23 +4,27 @@ Contact:      Jerome Marchand <jmarchan@redhat.com>
 Description:
                The /sys/block/<disk>/stat files displays the I/O
                statistics of disk <disk>. They contain 11 fields:
-                1 - reads completed successfully
-                2 - reads merged
-                3 - sectors read
-                4 - time spent reading (ms)
-                5 - writes completed
-                6 - writes merged
-                7 - sectors written
-                8 - time spent writing (ms)
-                9 - I/Os currently in progress
-               10 - time spent doing I/Os (ms)
-               11 - weighted time spent doing I/Os (ms)
-               12 - discards completed
-               13 - discards merged
-               14 - sectors discarded
-               15 - time spent discarding (ms)
-               16 - flush requests completed
-               17 - time spent flushing (ms)
+
+               ==  ==============================================
+                1  reads completed successfully
+                2  reads merged
+                3  sectors read
+                4  time spent reading (ms)
+                5  writes completed
+                6  writes merged
+                7  sectors written
+                8  time spent writing (ms)
+                9  I/Os currently in progress
+               10  time spent doing I/Os (ms)
+               11  weighted time spent doing I/Os (ms)
+               12  discards completed
+               13  discards merged
+               14  sectors discarded
+               15  time spent discarding (ms)
+               16  flush requests completed
+               17  time spent flushing (ms)
+               ==  ==============================================
+
                For more details refer Documentation/admin-guide/iostats.rst
 
 
index 17f2bc7dd261c45ecb43087bf35e46665c9592a1..aa0fb500e3c9510cdd7fb5e9ffe475468cc2d86d 100644 (file)
@@ -8,11 +8,13 @@ Description:
 
                It has the following valid values:
 
+               ==      ========================================================
                0       OFF - the LED is not activated on activity
                1       BLINK_ON - the LED blinks on every 10ms when activity is
                        detected.
                2       BLINK_OFF - the LED is on when idle, and blinks off
                        every 10ms when activity is detected.
+               ==      ========================================================
 
                Note that the user must turn sw_activity OFF it they wish to
                control the activity LED via the em_message file.
index 8f070b47f3612c896abbd9c6ec90cf4284972577..14a6fe9422b327593ac42700efaf5ab54b3603c4 100644 (file)
@@ -9,9 +9,9 @@ Description:    To unmap a volume, "normal" or "force" has to be written to:
                is using the device.  When "force" is used, the device is also unmapped
                when device is in use.  All I/Os that are in progress will fail.
 
-               Example:
+               Example::
 
-               # echo "normal" > /sys/block/rnbd0/rnbd/unmap_device
+                 # echo "normal" > /sys/block/rnbd0/rnbd/unmap_device
 
 What:          /sys/block/rnbd<N>/rnbd/state
 Date:          Feb 2020
index e7898cfe5fb12e8d5e4a6d52bd48dafa2c10bb22..58abacf59b2aba5ca5ba338cbfe6396312a3ff91 100644 (file)
@@ -5,6 +5,7 @@ Description:
                This attribute indicates the full path of ACPI namespace
                object associated with the device object.  For example,
                \_SB_.PCI0.
+
                This file is not present for device objects representing
                fixed ACPI hardware features (like power and sleep
                buttons).
@@ -67,14 +68,16 @@ Description:
                The return value is a decimal integer representing the device's
                status bitmap:
 
-               Bit [0] â€“  Set if the device is present.
-               Bit [1] â€“  Set if the device is enabled and decoding its
-                          resources.
-               Bit [2] â€“  Set if the device should be shown in the UI.
-               Bit [3] â€“  Set if the device is functioning properly (cleared if
-                          device failed its diagnostics).
-               Bit [4] â€“  Set if the battery is present.
-               Bits [31:5] â€“  Reserved (must be cleared)
+               ===========  ==================================================
+               Bit [0]      Set if the device is present.
+               Bit [1]      Set if the device is enabled and decoding its
+                            resources.
+               Bit [2]      Set if the device should be shown in the UI.
+               Bit [3]      Set if the device is functioning properly (cleared
+                            if device failed its diagnostics).
+               Bit [4]      Set if the battery is present.
+               Bits [31:5]  Reserved (must be cleared)
+               ===========  ==================================================
 
                If bit [0] is clear, then bit 1 must also be clear (a device
                that is not present cannot be enabled).
index 9d11502b43907c051183a76595cdac6f041b57a8..bf2869c413e72253ba25d5ab8b373b55a6c597b6 100644 (file)
@@ -8,50 +8,50 @@ What:         /sys/bus/coresight/devices/<cti-name>/powered
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Indicate if the CTI hardware is powered.
+Description:   (Read) Indicate if the CTI hardware is powered.
 
 What:          /sys/bus/coresight/devices/<cti-name>/ctmid
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Display the associated CTM ID
+Description:   (Read) Display the associated CTM ID
 
 What:          /sys/bus/coresight/devices/<cti-name>/nr_trigger_cons
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Number of devices connected to triggers on this CTI
+Description:   (Read) Number of devices connected to triggers on this CTI
 
 What:          /sys/bus/coresight/devices/<cti-name>/triggers<N>/name
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Name of connected device <N>
+Description:   (Read) Name of connected device <N>
 
 What:          /sys/bus/coresight/devices/<cti-name>/triggers<N>/in_signals
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Input trigger signals from connected device <N>
+Description:   (Read) Input trigger signals from connected device <N>
 
 What:          /sys/bus/coresight/devices/<cti-name>/triggers<N>/in_types
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Functional types for the input trigger signals
+Description:   (Read) Functional types for the input trigger signals
                from connected device <N>
 
 What:          /sys/bus/coresight/devices/<cti-name>/triggers<N>/out_signals
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Output trigger signals to connected device <N>
+Description:   (Read) Output trigger signals to connected device <N>
 
 What:          /sys/bus/coresight/devices/<cti-name>/triggers<N>/out_types
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Functional types for the output trigger signals
+Description:   (Read) Functional types for the output trigger signals
                to connected device <N>
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/inout_sel
@@ -88,7 +88,7 @@ What:         /sys/bus/coresight/devices/<cti-name>/regs/intack
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Write the INTACK register.
+Description:   (Write) Write the INTACK register.
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/appset
 Date:          March 2020
@@ -101,99 +101,99 @@ What:             /sys/bus/coresight/devices/<cti-name>/regs/appclear
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Write APPCLEAR register to deactivate channel.
+Description:   (Write) Write APPCLEAR register to deactivate channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/apppulse
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Write APPPULSE to pulse a channel active for one clock
+Description:   (Write) Write APPPULSE to pulse a channel active for one clock
                cycle.
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/chinstatus
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Read current status of channel inputs.
+Description:   (Read) Read current status of channel inputs.
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/choutstatus
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) read current status of channel outputs.
+Description:   (Read) read current status of channel outputs.
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/triginstatus
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) read current status of input trigger signals
+Description:   (Read) read current status of input trigger signals
 
 What:          /sys/bus/coresight/devices/<cti-name>/regs/trigoutstatus
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) read current status of output trigger signals.
+Description:   (Read) read current status of output trigger signals.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trigin_attach
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Attach a CTI input trigger to a CTM channel.
+Description:   (Write) Attach a CTI input trigger to a CTM channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trigin_detach
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Detach a CTI input trigger from a CTM channel.
+Description:   (Write) Detach a CTI input trigger from a CTM channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trigout_attach
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Attach a CTI output trigger to a CTM channel.
+Description:   (Write) Attach a CTI output trigger to a CTM channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trigout_detach
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Detach a CTI output trigger from a CTM channel.
+Description:   (Write) Detach a CTI output trigger from a CTM channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_gate_enable
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (RW) Enable CTIGATE for single channel (W) or list enabled
+Description:   (RW) Enable CTIGATE for single channel (Write) or list enabled
                channels through the gate (R).
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_gate_disable
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Disable CTIGATE for single channel.
+Description:   (Write) Disable CTIGATE for single channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_set
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Activate a single channel.
+Description:   (Write) Activate a single channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_clear
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Deactivate a single channel.
+Description:   (Write) Deactivate a single channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_pulse
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Pulse a single channel - activate for a single clock cycle.
+Description:   (Write) Pulse a single channel - activate for a single clock cycle.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trigout_filtered
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) List of output triggers filtered across all connections.
+Description:   (Read) List of output triggers filtered across all connections.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/trig_filter_enable
 Date:          March 2020
@@ -205,13 +205,13 @@ What:             /sys/bus/coresight/devices/<cti-name>/channels/chan_inuse
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) show channels with at least one attached trigger signal.
+Description:   (Read) show channels with at least one attached trigger signal.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_free
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) show channels with no attached trigger signals.
+Description:   (Read) show channels with no attached trigger signals.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_xtrigs_sel
 Date:          March 2020
@@ -224,18 +224,18 @@ What:             /sys/bus/coresight/devices/<cti-name>/channels/chan_xtrigs_in
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Read to see input triggers connected to selected view
+Description:   (Read) Read to see input triggers connected to selected view
                channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_xtrigs_out
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (R) Read to see output triggers connected to selected view
+Description:   (Read) Read to see output triggers connected to selected view
                channel.
 
 What:          /sys/bus/coresight/devices/<cti-name>/channels/chan_xtrigs_reset
 Date:          March 2020
 KernelVersion  5.7
 Contact:       Mike Leach or Mathieu Poirier
-Description:   (W) Clear all channel / trigger programming.
+Description:   (Write) Clear all channel / trigger programming.
index b5f526081711878eb46f0586415f043b929aaba0..9a383f6a74ebe10cd8991d8493ac931f510b0c07 100644 (file)
@@ -4,7 +4,10 @@ KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
 Description:   (RW) Add/remove a sink from a trace path.  There can be multiple
                source for a single sink.
-               ex: echo 1 > /sys/bus/coresight/devices/20010000.etb/enable_sink
+
+               ex::
+
+                 echo 1 > /sys/bus/coresight/devices/20010000.etb/enable_sink
 
 What:          /sys/bus/coresight/devices/<memory_map>.etb/trigger_cntr
 Date:          November 2014
@@ -20,21 +23,21 @@ What:               /sys/bus/coresight/devices/<memory_map>.etb/mgmt/rdp
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Defines the depth, in words, of the trace RAM in powers of
+Description:   (Read) Defines the depth, in words, of the trace RAM in powers of
                2.  The value is read directly from HW register RDP, 0x004.
 
 What:          /sys/bus/coresight/devices/<memory_map>.etb/mgmt/sts
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB status register.  The value
+Description:   (Read) Shows the value held by the ETB status register.  The value
                is read directly from HW register STS, 0x00C.
 
 What:          /sys/bus/coresight/devices/<memory_map>.etb/mgmt/rrp
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB RAM Read Pointer register
+Description:   (Read) Shows the value held by the ETB RAM Read Pointer register
                that is used to read entries from the Trace RAM over the APB
                interface.  The value is read directly from HW register RRP,
                0x014.
@@ -43,7 +46,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.etb/mgmt/rwp
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB RAM Write Pointer register
+Description:   (Read) Shows the value held by the ETB RAM Write Pointer register
                that is used to sets the write pointer to write entries from
                the CoreSight bus into the Trace RAM. The value is read directly
                from HW register RWP, 0x018.
@@ -52,21 +55,21 @@ What:               /sys/bus/coresight/devices/<memory_map>.etb/mgmt/trg
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Similar to "trigger_cntr" above except that this value is
+Description:   (Read) Similar to "trigger_cntr" above except that this value is
                read directly from HW register TRG, 0x01C.
 
 What:          /sys/bus/coresight/devices/<memory_map>.etb/mgmt/ctl
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB Control register. The value
+Description:   (Read) Shows the value held by the ETB Control register. The value
                is read directly from HW register CTL, 0x020.
 
 What:          /sys/bus/coresight/devices/<memory_map>.etb/mgmt/ffsr
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB Formatter and Flush Status
+Description:   (Read) Shows the value held by the ETB Formatter and Flush Status
                register.  The value is read directly from HW register FFSR,
                0x300.
 
@@ -74,6 +77,6 @@ What:         /sys/bus/coresight/devices/<memory_map>.etb/mgmt/ffcr
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the ETB Formatter and Flush Control
+Description:   (Read) Shows the value held by the ETB Formatter and Flush Control
                register.  The value is read directly from HW register FFCR,
                0x304.
index 924265a1295dc021f3a26969c9139a9b7e196ac5..651602a61eac82af31d878a9ba1670aa18bab798 100644 (file)
@@ -146,28 +146,28 @@ What:             /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/nr_addr_cmp
 Date:          November 2014
 KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Provides the number of address comparators pairs accessible
+Description:   (Read) Provides the number of address comparators pairs accessible
                on a trace unit, as specified by bit 3:0 of register ETMCCR.
 
 What:          /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/nr_cntr
 Date:          November 2014
 KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Provides the number of counters accessible on a trace unit,
+Description:   (Read) Provides the number of counters accessible on a trace unit,
                as specified by bit 15:13 of register ETMCCR.
 
 What:          /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/nr_ctxid_cmp
 Date:          November 2014
 KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Provides the number of context ID comparator available on a
+Description:   (Read) Provides the number of context ID comparator available on a
                trace unit, as specified by bit 25:24 of register ETMCCR.
 
 What:          /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/reset
 Date:          November 2014
 KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (W) Cancels all configuration on a trace unit and set it back
+Description:   (Write) Cancels all configuration on a trace unit and set it back
                to its boot configuration.
 
 What:          /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/seq_12_event
@@ -216,7 +216,7 @@ What:               /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/curr_seq_state
 Date:          November 2014
 KernelVersion: 3.19
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Holds the current state of the sequencer.
+Description:   (Read) Holds the current state of the sequencer.
 
 What:          /sys/bus/coresight/devices/<memory_map>.[etm|ptm]/sync_freq
 Date:          November 2014
index 614874e2cf53602acc8c5d5b62ac9ffae66d103d..881f0cd99ce4ed7c894ec4bc35c59bf8dc7f1ecc 100644 (file)
@@ -12,75 +12,75 @@ What:               /sys/bus/coresight/devices/etm<N>/cpu
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) The CPU this tracing entity is associated with.
+Description:   (Read) The CPU this tracing entity is associated with.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_pe_cmp
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of PE comparator inputs that are
+Description:   (Read) Indicates the number of PE comparator inputs that are
                available for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_addr_cmp
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of address comparator pairs that are
+Description:   (Read) Indicates the number of address comparator pairs that are
                available for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_cntr
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of counters that are available for
+Description:   (Read) Indicates the number of counters that are available for
                tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_ext_inp
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates how many external inputs are implemented.
+Description:   (Read) Indicates how many external inputs are implemented.
 
 What:          /sys/bus/coresight/devices/etm<N>/numcidc
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of Context ID comparators that are
+Description:   (Read) Indicates the number of Context ID comparators that are
                available for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/numvmidc
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of VMID comparators that are available
+Description:   (Read) Indicates the number of VMID comparators that are available
                for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/nrseqstate
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of sequencer states that are
+Description:   (Read) Indicates the number of sequencer states that are
                implemented.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_resource
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of resource selection pairs that are
+Description:   (Read) Indicates the number of resource selection pairs that are
                available for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/nr_ss_cmp
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the number of single-shot comparator controls that
+Description:   (Read) Indicates the number of single-shot comparator controls that
                are available for tracing.
 
 What:          /sys/bus/coresight/devices/etm<N>/reset
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (W) Cancels all configuration on a trace unit and set it back
+Description:   (Write) Cancels all configuration on a trace unit and set it back
                to its boot configuration.
 
 What:          /sys/bus/coresight/devices/etm<N>/mode
@@ -300,7 +300,7 @@ What:               /sys/bus/coresight/devices/etm<N>/addr_cmp_view
 Date:          December 2019
 KernelVersion: 5.5
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the current settings for the selected address
+Description:   (Read) Print the current settings for the selected address
                comparator.
 
 What:          /sys/bus/coresight/devices/etm<N>/sshot_idx
@@ -319,7 +319,7 @@ What:               /sys/bus/coresight/devices/etm<N>/sshot_status
 Date:          December 2019
 KernelVersion: 5.5
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the current value of the selected single shot
+Description:   (Read) Print the current value of the selected single shot
                status register.
 
 What:          /sys/bus/coresight/devices/etm<N>/sshot_pe_ctrl
@@ -333,111 +333,111 @@ What:           /sys/bus/coresight/devices/etm<N>/mgmt/trcoslsr
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the OS Lock Status Register (0x304).
+Description:   (Read) Print the content of the OS Lock Status Register (0x304).
                The value it taken directly  from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpdcr
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Power Down Control Register
+Description:   (Read) Print the content of the Power Down Control Register
                (0x310).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpdsr
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Power Down Status Register
+Description:   (Read) Print the content of the Power Down Status Register
                (0x314).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trclsr
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the SW Lock Status Register
+Description:   (Read) Print the content of the SW Lock Status Register
                (0xFB4).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcauthstatus
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Authentication Status Register
+Description:   (Read) Print the content of the Authentication Status Register
                (0xFB8).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcdevid
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Device ID Register
+Description:   (Read) Print the content of the Device ID Register
                (0xFC8).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcdevtype
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Device Type Register
+Description:   (Read) Print the content of the Device Type Register
                (0xFCC).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpidr0
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Peripheral ID0 Register
+Description:   (Read) Print the content of the Peripheral ID0 Register
                (0xFE0).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpidr1
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Peripheral ID1 Register
+Description:   (Read) Print the content of the Peripheral ID1 Register
                (0xFE4).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpidr2
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Peripheral ID2 Register
+Description:   (Read) Print the content of the Peripheral ID2 Register
                (0xFE8).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcpidr3
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the Peripheral ID3 Register
+Description:   (Read) Print the content of the Peripheral ID3 Register
                (0xFEC).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trcconfig
 Date:          February 2016
 KernelVersion: 4.07
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the trace configuration register
+Description:   (Read) Print the content of the trace configuration register
                (0x010) as currently set by SW.
 
 What:          /sys/bus/coresight/devices/etm<N>/mgmt/trctraceid
 Date:          February 2016
 KernelVersion: 4.07
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Print the content of the trace ID register (0x040).
+Description:   (Read) Print the content of the trace ID register (0x040).
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr0
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the tracing capabilities of the trace unit (0x1E0).
+Description:   (Read) Returns the tracing capabilities of the trace unit (0x1E0).
                The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr1
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the tracing capabilities of the trace unit (0x1E4).
+Description:   (Read) Returns the tracing capabilities of the trace unit (0x1E4).
                The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr2
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the maximum size of the data value, data address,
+Description:   (Read) Returns the maximum size of the data value, data address,
                VMID, context ID and instuction address in the trace unit
                (0x1E8).  The value is taken directly from the HW.
 
@@ -445,7 +445,7 @@ What:               /sys/bus/coresight/devices/etm<N>/trcidr/trcidr3
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the value associated with various resources
+Description:   (Read) Returns the value associated with various resources
                available to the trace unit.  See the Trace Macrocell
                architecture specification for more details (0x1E8).
                The value is taken directly from the HW.
@@ -454,42 +454,42 @@ What:             /sys/bus/coresight/devices/etm<N>/trcidr/trcidr4
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns how many resources the trace unit supports (0x1F0).
+Description:   (Read) Returns how many resources the trace unit supports (0x1F0).
                The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr5
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns how many resources the trace unit supports (0x1F4).
+Description:   (Read) Returns how many resources the trace unit supports (0x1F4).
                The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr8
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the maximum speculation depth of the instruction
+Description:   (Read) Returns the maximum speculation depth of the instruction
                trace stream. (0x180).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr9
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the number of P0 right-hand keys that the trace unit
+Description:   (Read) Returns the number of P0 right-hand keys that the trace unit
                can use (0x184).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr10
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the number of P1 right-hand keys that the trace unit
+Description:   (Read) Returns the number of P1 right-hand keys that the trace unit
                can use (0x188).  The value is taken directly from the HW.
 
 What:          /sys/bus/coresight/devices/etm<N>/trcidr/trcidr11
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the number of special P1 right-hand keys that the
+Description:   (Read) Returns the number of special P1 right-hand keys that the
                trace unit can use (0x18C).  The value is taken directly from
                the HW.
 
@@ -497,7 +497,7 @@ What:               /sys/bus/coresight/devices/etm<N>/trcidr/trcidr12
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the number of conditional P1 right-hand keys that
+Description:   (Read) Returns the number of conditional P1 right-hand keys that
                the trace unit can use (0x190).  The value is taken directly
                from the HW.
 
@@ -505,6 +505,6 @@ What:               /sys/bus/coresight/devices/etm<N>/trcidr/trcidr13
 Date:          April 2015
 KernelVersion: 4.01
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Returns the number of special conditional P1 right-hand keys
+Description:   (Read) Returns the number of special conditional P1 right-hand keys
                that the trace unit can use (0x194).  The value is taken
                directly from the HW.
index 1dffabe7f48d6500e0f66d2f18c42d388051f3bb..53e1f4815d64314e6d6181978fa2ecbd77f5b9db 100644 (file)
@@ -42,7 +42,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.stm/status
 Date:          April 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) List various control and status registers.  The specific
+Description:   (Read) List various control and status registers.  The specific
                layout and content is driver specific.
 
 What:          /sys/bus/coresight/devices/<memory_map>.stm/traceid
index ab49b9ac3bcb0515f85e6d4e0e660d76df5e3f8a..6aa527296c71080cbbf8ecf3ce53e375a2e70022 100644 (file)
@@ -11,21 +11,21 @@ What:           /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rsz
 Date:           March 2016
 KernelVersion:  4.7
 Contact:        Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:    (R) Defines the size, in 32-bit words, of the local RAM buffer.
+Description:    (Read) Defines the size, in 32-bit words, of the local RAM buffer.
                 The value is read directly from HW register RSZ, 0x004.
 
 What:           /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/sts
 Date:           March 2016
 KernelVersion:  4.7
 Contact:        Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC status register.  The value
+Description:   (Read) Shows the value held by the TMC status register.  The value
                 is read directly from HW register STS, 0x00C.
 
 What:          /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rrp
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC RAM Read Pointer register
+Description:   (Read) Shows the value held by the TMC RAM Read Pointer register
                that is used to read entries from the Trace RAM over the APB
                interface.  The value is read directly from HW register RRP,
                0x014.
@@ -34,7 +34,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/rwp
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC RAM Write Pointer register
+Description:   (Read) Shows the value held by the TMC RAM Write Pointer register
                that is used to sets the write pointer to write entries from
                the CoreSight bus into the Trace RAM. The value is read directly
                from HW register RWP, 0x018.
@@ -43,21 +43,21 @@ What:               /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/trg
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Similar to "trigger_cntr" above except that this value is
+Description:   (Read) Similar to "trigger_cntr" above except that this value is
                read directly from HW register TRG, 0x01C.
 
 What:          /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ctl
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC Control register. The value
+Description:   (Read) Shows the value held by the TMC Control register. The value
                is read directly from HW register CTL, 0x020.
 
 What:          /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ffsr
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC Formatter and Flush Status
+Description:   (Read) Shows the value held by the TMC Formatter and Flush Status
                register.  The value is read directly from HW register FFSR,
                0x300.
 
@@ -65,7 +65,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/ffcr
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC Formatter and Flush Control
+Description:   (Read) Shows the value held by the TMC Formatter and Flush Control
                register.  The value is read directly from HW register FFCR,
                0x304.
 
@@ -73,7 +73,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/mode
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Shows the value held by the TMC Mode register, which
+Description:   (Read) Shows the value held by the TMC Mode register, which
                indicate the mode the device has been configured to enact.  The
                The value is read directly from the MODE register, 0x028.
 
@@ -81,7 +81,7 @@ What:         /sys/bus/coresight/devices/<memory_map>.tmc/mgmt/devid
 Date:          March 2016
 KernelVersion: 4.7
 Contact:       Mathieu Poirier <mathieu.poirier@linaro.org>
-Description:   (R) Indicates the capabilities of the Coresight TMC.
+Description:   (Read) Indicates the capabilities of the Coresight TMC.
                The value is read directly from the DEVID register, 0xFC8,
 
 What:          /sys/bus/coresight/devices/<memory_map>.tmc/buffer_size
index 966f8504bd7b498274129525554b2b07195f9f25..12a733fe357fd43a8128d20cbbd6ae548e838832 100644 (file)
@@ -20,6 +20,7 @@ Contact:      Cornelia Huck <cornelia.huck@de.ibm.com>
 Description:   Contains the ids of the channel paths used by this
                subchannel, as reported by the channel subsystem
                during subchannel recognition.
+
                Note: This is an I/O-subchannel specific attribute.
 Users:         s390-tools, HAL
 
@@ -31,6 +32,7 @@ Description:  Contains the PIM/PAM/POM values, as reported by the
                channel subsystem when last queried by the common I/O
                layer (this implies that this attribute is not necessarily
                in sync with the values current in the channel subsystem).
+
                Note: This is an I/O-subchannel specific attribute.
 Users:         s390-tools, HAL
 
@@ -53,6 +55,7 @@ Description:  This file allows the driver for a device to be specified. When
                opt-out of driver binding using a driver_override name such as
                "none".  Only a single driver may be specified in the override,
                there is no support for parsing delimiters.
+
                Note that unlike the mechanism of the same name for pci, this
                file does not allow to override basic matching rules. I.e.,
                the driver must still match the subchannel type of the device.
index 23543be904f2a30ccc53c879348ed44d08f80b47..b0265ab17200987a7416d9d0865d6d53679c4b61 100644 (file)
@@ -4,6 +4,7 @@ KernelVersion:  5.10
 Contact:       Xu Yilun <yilun.xu@intel.com>
 Description:   Read-only. It returns type of DFL FIU of the device. Now DFL
                supports 2 FIU types, 0 for FME, 1 for PORT.
+
                Format: 0x%x
 
 What:          /sys/bus/dfl/devices/dfl_dev.X/feature_id
@@ -12,4 +13,5 @@ KernelVersion:        5.10
 Contact:       Xu Yilun <yilun.xu@intel.com>
 Description:   Read-only. It returns feature identifier local to its DFL FIU
                type.
+
                Format: 0x%x
index c9278a3b3df166f392a0336c81d452a050703bdb..63a32ddcb95e7f275c236f66f826a75823be78a2 100644 (file)
@@ -8,13 +8,13 @@ Description:  Read-only. Attribute group to describe the magic bits
 
                Each attribute under this group defines a bit range of the
                perf_event_attr.config. All supported attributes are listed
-               below.
+               below::
 
                    event  = "config:0-11"  - event ID
                    evtype = "config:12-15" - event type
                    portid = "config:16-23" - event source
 
-               For example,
+               For example::
 
                    fab_mmio_read = "event=0x06,evtype=0x02,portid=0xff"
 
@@ -40,11 +40,11 @@ Description:        Read-only. Attribute group to describe performance monitoring
 
                All supported performance monitoring events are listed below.
 
-               Basic events (evtype=0x00)
+               Basic events (evtype=0x00)::
 
                    clock = "event=0x00,evtype=0x00,portid=0xff"
 
-               Cache events (evtype=0x01)
+               Cache events (evtype=0x01)::
 
                    cache_read_hit      = "event=0x00,evtype=0x01,portid=0xff"
                    cache_read_miss     = "event=0x01,evtype=0x01,portid=0xff"
@@ -59,7 +59,7 @@ Description:  Read-only. Attribute group to describe performance monitoring
                    cache_rx_req_stall  = "event=0x09,evtype=0x01,portid=0xff"
                    cache_eviction      = "event=0x0a,evtype=0x01,portid=0xff"
 
-               Fabric events (evtype=0x02)
+               Fabric events (evtype=0x02)::
 
                    fab_pcie0_read       = "event=0x00,evtype=0x02,portid=0xff"
                    fab_pcie0_write      = "event=0x01,evtype=0x02,portid=0xff"
@@ -78,7 +78,7 @@ Description:  Read-only. Attribute group to describe performance monitoring
                    fab_port_mmio_read   = "event=0x06,evtype=0x02,portid=?"
                    fab_port_mmio_write  = "event=0x07,evtype=0x02,portid=?"
 
-               VTD events (evtype=0x03)
+               VTD events (evtype=0x03)::
 
                    vtd_port_read_transaction  = "event=0x00,evtype=0x03,portid=?"
                    vtd_port_write_transaction = "event=0x01,evtype=0x03,portid=?"
@@ -88,7 +88,7 @@ Description:  Read-only. Attribute group to describe performance monitoring
                    vtd_port_devtlb_2m_fill    = "event=0x05,evtype=0x03,portid=?"
                    vtd_port_devtlb_1g_fill    = "event=0x06,evtype=0x03,portid=?"
 
-               VTD SIP events (evtype=0x04)
+               VTD SIP events (evtype=0x04)::
 
                    vtd_sip_iotlb_4k_hit  = "event=0x00,evtype=0x04,portid=0xff"
                    vtd_sip_iotlb_2m_hit  = "event=0x01,evtype=0x04,portid=0xff"
index 5bb793ec926c1f6ed84acb7abc2a48e36a440c3b..df7ccc1b2fba6b59d77f72d931519cc71833ac87 100644 (file)
@@ -10,7 +10,8 @@ Description:
                name/value pairs.
 
                Userspace must be prepared for the possibility that attributes
-               define overlapping bit ranges. For example:
+               define overlapping bit ranges. For example::
+
                        attr1 = 'config:0-23'
                        attr2 = 'config:0-7'
                        attr3 = 'config:12-35'
index 2273627df1906379c608b8785f7550226a1cc4ab..de390a010af857354f22e527db0c03cac4c6976e 100644 (file)
@@ -7,7 +7,7 @@ Description:    Read-only. Attribute group to describe the magic bits
 
                 Each attribute under this group defines a bit range of the
                 perf_event_attr.config. All supported attributes are listed
-                below.
+                below::
 
                                chip = "config:16-31"
                                core  = "config:16-31"
@@ -16,9 +16,9 @@ Description:    Read-only. Attribute group to describe the magic bits
                                offset = "config:32-63"
                                vcpu = "config:16-31"
 
-               For example,
+                For example::
 
-               PM_PB_CYC =  "domain=1,offset=0x80,chip=?,lpar=0x0"
+                 PM_PB_CYC =  "domain=1,offset=0x80,chip=?,lpar=0x0"
 
                In this event, '?' after chip specifies that
                this value will be provided by user while running this event.
index 6a023b42486c610a3c4af8293b97c5a02ed5c063..12e2bf92783fbd08caaa5f60bc1c8474325a2d27 100644 (file)
@@ -7,7 +7,7 @@ Description:    Read-only. Attribute group to describe the magic bits
 
                 Each attribute under this group defines a bit range of the
                 perf_event_attr.config. All supported attributes are listed
-                below.
+                below::
 
                                counter_info_version  = "config:16-23"
                                length  = "config:24-31"
@@ -20,9 +20,9 @@ Description:    Read-only. Attribute group to describe the magic bits
                                secondary_index = "config:0-15"
                                starting_index = "config:32-63"
 
-               For example,
+                For example::
 
-               processor_core_utilization_instructions_completed = "request=0x94,
+                 processor_core_utilization_instructions_completed = "request=0x94,
                                        phys_processor_idx=?,counter_info_version=0x8,
                                        length=8,offset=0x18"
 
@@ -36,6 +36,7 @@ Description:
                '0' if the hypervisor is configured to forbid access to event
                counters being accumulated by other guests and to physical
                domain event counters.
+
                '1' if that access is allowed.
 
 What:          /sys/bus/event_source/devices/hv_gpci/interface/ga
index 657df13b100d241f5aca4942c0bada25d413bf15..8fe787cc4ab70a4c0fe05949f7db84f640dddfb5 100644 (file)
@@ -3,16 +3,19 @@ Date:         August 2012
 KernelVersion: TBD
 Contact:       Robert Love <robert.w.love@intel.com>, devel@open-fcoe.org
 Description:   The FCoE bus. Attributes in this directory are control interfaces.
+
 Attributes:
 
-       ctlr_create: 'FCoE Controller' instance creation interface. Writing an
+       ctlr_create:
+                    'FCoE Controller' instance creation interface. Writing an
                     <ifname> to this file will allocate and populate sysfs with a
                     fcoe_ctlr_device (ctlr_X). The user can then configure any
                     per-port settings and finally write to the fcoe_ctlr_device's
                     'start' attribute to begin the kernel's discovery and login
                     process.
 
-       ctlr_destroy: 'FCoE Controller' instance removal interface. Writing a
+       ctlr_destroy:
+                      'FCoE Controller' instance removal interface. Writing a
                       fcoe_ctlr_device's sysfs name to this file will log the
                       fcoe_ctlr_device out of the fabric or otherwise connected
                       FCoE devices. It will also free all kernel memory allocated
@@ -32,11 +35,13 @@ Description:        'FCoE Controller' instances on the fcoe bus.
 
 Attributes:
 
-       fcf_dev_loss_tmo: Device loss timeout period (see below). Changing
+       fcf_dev_loss_tmo:
+                         Device loss timeout period (see below). Changing
                          this value will change the dev_loss_tmo for all
                          FCFs discovered by this controller.
 
-       mode:             Display or change the FCoE Controller's mode. Possible
+       mode:
+                         Display or change the FCoE Controller's mode. Possible
                          modes are 'Fabric' and 'VN2VN'. If a FCoE Controller
                          is started in 'Fabric' mode then FIP FCF discovery is
                          initiated and ultimately a fabric login is attempted.
@@ -44,23 +49,30 @@ Attributes:
                          FIP VN2VN discovery and login is performed. A FCoE
                          Controller only supports one mode at a time.
 
-       enabled:          Whether an FCoE controller is enabled or disabled.
+       enabled:
+                         Whether an FCoE controller is enabled or disabled.
                          0 if disabled, 1 if enabled. Writing either 0 or 1
                          to this file will enable or disable the FCoE controller.
 
-       lesb/link_fail:   Link Error Status Block (LESB) link failure count.
+       lesb/link_fail:
+                         Link Error Status Block (LESB) link failure count.
 
-       lesb/vlink_fail:  Link Error Status Block (LESB) virtual link
+       lesb/vlink_fail:
+                         Link Error Status Block (LESB) virtual link
                          failure count.
 
-       lesb/miss_fka:    Link Error Status Block (LESB) missed FCoE
+       lesb/miss_fka:
+                         Link Error Status Block (LESB) missed FCoE
                          Initialization Protocol (FIP) Keep-Alives (FKA).
 
-       lesb/symb_err:    Link Error Status Block (LESB) symbolic error count.
+       lesb/symb_err:
+                         Link Error Status Block (LESB) symbolic error count.
 
-       lesb/err_block:   Link Error Status Block (LESB) block error count.
+       lesb/err_block:
+                         Link Error Status Block (LESB) block error count.
 
-       lesb/fcs_error:   Link Error Status Block (LESB) Fibre Channel
+       lesb/fcs_error:
+                         Link Error Status Block (LESB) Fibre Channel
                          Services error count.
 
 Notes: ctlr_X (global increment starting at 0)
@@ -75,31 +87,41 @@ Description:        'FCoE FCF' instances on the fcoe bus. A FCF is a Fibre Channel
                Fibre Channel frames into a FC fabric. It can also take
                outbound FC frames and pack them in Ethernet packets to
                be sent to their destination on the Ethernet segment.
+
 Attributes:
 
-       fabric_name: Identifies the fabric that the FCF services.
+       fabric_name:
+                    Identifies the fabric that the FCF services.
 
-       switch_name: Identifies the FCF.
+       switch_name:
+                    Identifies the FCF.
 
-       priority:    The switch's priority amongst other FCFs on the same
+       priority:
+                    The switch's priority amongst other FCFs on the same
                     fabric.
 
-       selected:    1 indicates that the switch has been selected for use;
+       selected:
+                    1 indicates that the switch has been selected for use;
                     0 indicates that the switch will not be used.
 
-       fc_map:      The Fibre Channel MAP
+       fc_map:
+                    The Fibre Channel MAP
 
-       vfid:        The Virtual Fabric ID
+       vfid:
+                    The Virtual Fabric ID
 
-       mac:         The FCF's MAC address
+       mac:
+                    The FCF's MAC address
 
-       fka_period:  The FIP Keep-Alive period
+       fka_period:
+                    The FIP Keep-Alive period
 
        fabric_state: The internal kernel state
-                     "Unknown" - Initialization value
-                     "Disconnected" - No link to the FCF/fabric
-                     "Connected" - Host is connected to the FCF
-                     "Deleted" - FCF is being removed from the system
+
+                     - "Unknown" - Initialization value
+                     - "Disconnected" - No link to the FCF/fabric
+                     - "Connected" - Host is connected to the FCF
+                     - "Deleted" - FCF is being removed from the system
 
        dev_loss_tmo: The device loss timeout period for this FCF.
 
index 80256b8b4f26119e0d97fa455e67d4e7e5f4fdeb..bf3c6af6ad89af7e6de86d57763ecc1b7e69179a 100644 (file)
@@ -6,8 +6,10 @@ Description:
                the driver to attempt to bind to the device found at
                this location. The format for the location is Object.Id
                and is the same as found in /sys/bus/fsl-mc/devices/.
-                For example:
-               # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/bind
+
+                For example::
+
+                 # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/bind
 
 What:          /sys/bus/fsl-mc/drivers/.../unbind
 Date:          December 2016
@@ -17,5 +19,7 @@ Description:
                driver to attempt to unbind from the device found at
                this location. The format for the location is Object.Id
                and is the same as found in /sys/bus/fsl-mc/devices/.
-                For example:
-               # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/unbind
+
+                For example::
+
+                 # echo dpni.2 > /sys/bus/fsl-mc/drivers/fsl_dpaa2_eth/unbind
index 9de269bb0ae53a6995ec3c364338bde2228c1ba3..42dfc9399d2dc8c33bb7e8639a65951eca1638e4 100644 (file)
@@ -3,19 +3,25 @@ Date:         February 2011
 Contact:       Minkyu Kang <mk7.kang@samsung.com>
 Description:
                show what device is attached
-               NONE - no device
-               USB - USB device is attached
-               UART - UART is attached
-               CHARGER - Charger is attaced
-               JIG - JIG is attached
+
+               =======  ======================
+               NONE     no device
+               USB      USB device is attached
+               UART     UART is attached
+               CHARGER  Charger is attaced
+               JIG      JIG is attached
+               =======  ======================
 
 What:          /sys/bus/i2c/devices/.../switch
 Date:          February 2011
 Contact:       Minkyu Kang <mk7.kang@samsung.com>
 Description:
                show or set the state of manual switch
-               VAUDIO - switch to VAUDIO path
-               UART - switch to UART path
-               AUDIO - switch to AUDIO path
-               DHOST - switch to DHOST path
-               AUTO - switch automatically by device
+
+               =======  ==============================
+               VAUDIO   switch to VAUDIO path
+               UART     switch to UART path
+               AUDIO    switch to AUDIO path
+               DHOST    switch to DHOST path
+               AUTO     switch automatically by device
+               =======  ==============================
index 0b0de8cd0d13784c3427eef231184d208c2f5f82..b6c69eb80ca44d7138322dcd901cdd78e4a3867e 100644 (file)
@@ -6,15 +6,18 @@ Description:
                Value that exists only for mux devices that can be
                written to control the behaviour of the multiplexer on
                idle. Possible values:
-               -2 - disconnect on idle, i.e. deselect the last used
-                    channel, which is useful when there is a device
-                    with an address that conflicts with another
-                    device on another mux on the same parent bus.
-               -1 - leave the mux as-is, which is the most optimal
-                    setting in terms of I2C operations and is the
-                    default mode.
-               0..<nchans> - set the mux to a predetermined channel,
-                    which is useful if there is one channel that is
-                    used almost always, and you want to reduce the
-                    latency for normal operations after rare
-                    transactions on other channels
+
+               ===========  ===============================================
+               -2           disconnect on idle, i.e. deselect the last used
+                            channel, which is useful when there is a device
+                            with an address that conflicts with another
+                            device on another mux on the same parent bus.
+               -1           leave the mux as-is, which is the most optimal
+                            setting in terms of I2C operations and is the
+                            default mode.
+               0..<nchans>  set the mux to a predetermined channel,
+                            which is useful if there is one channel that is
+                            used almost always, and you want to reduce the
+                            latency for normal operations after rare
+                            transactions on other channels
+               ===========  ===============================================
index 2f332ec36f82a11e205ca7fb58f2f6956aeba1fa..1f4a2662335bb1a68cd401c1a6b85056994eb94b 100644 (file)
@@ -84,6 +84,7 @@ Description:
                by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl".
                See the I3C specification for more details about these HDR
                modes.
+
                This entry describes the HDRCAP of the master controller
                driving the bus.
 
@@ -135,6 +136,7 @@ Description:
                Expose the HDR (High Data Rate) capabilities of a device.
                Returns a list of supported HDR mode, each element is separated
                by space. Modes can be "hdr-ddr", "hdr-tsp" and "hdr-tsl".
+
                See the I3C specification for more details about these HDR
                modes.
 
index a9d51810a3bad5e1005fd450d885d585ab96f83a..df42bed09f25d8d3db72b2745e193457d8959a98 100644 (file)
@@ -15,6 +15,7 @@ Description:
                based on hardware generated events (e.g. data ready) or
                provided by a separate driver for other hardware (e.g.
                periodic timer, GPIO or high resolution timer).
+
                Contains trigger type specific elements. These do not
                generalize well and hence are not documented in this file.
                X is the IIO index of the trigger.
@@ -65,6 +66,7 @@ Contact:      linux-iio@vger.kernel.org
 Description:
                When the internal sampling clock can only take a specific set of
                frequencies, we can specify the available values with:
+
                - a small discrete set of values like "0 2 4 6 8"
                - a range with minimum, step and maximum frequencies like
                  "[min step max]"
@@ -665,6 +667,7 @@ Description:
                <type>[Y][_name]_<raw|input>_thresh_falling_value may take
                different values, but the device can only enable both thresholds
                or neither.
+
                Note the driver will assume the last p events requested are
                to be enabled where p is how many it supports (which may vary
                depending on the exact set requested. So if you want to be
@@ -719,6 +722,7 @@ Description:
                <type>[Y][_name]_<raw|input>_roc_falling_value may take
                different values, but the device can only enable both rate of
                change thresholds or neither.
+
                Note the driver will assume the last p events requested are
                to be enabled where p is however many it supports (which may
                vary depending on the exact set requested. So if you want to be
@@ -774,9 +778,11 @@ Description:
                Specifies the value of threshold that the device is comparing
                against for the events enabled by
                <type>Y[_name]_thresh[_rising|falling]_en.
+
                If separate attributes exist for the two directions, but
                direction is not specified for this attribute, then a single
                threshold value applies to both directions.
+
                The raw or input element of the name indicates whether the
                value is in raw device units or in processed units (as _raw
                and _input do on sysfs direct channel read attributes).
@@ -859,6 +865,7 @@ Description:
                If separate attributes exist for the two directions, but
                direction is not specified for this attribute, then a single
                hysteresis value applies to both directions.
+
                For falling events the hysteresis is added to the _value attribute for
                this event to get the upper threshold for when the event goes back to
                normal, for rising events the hysteresis is subtracted from the _value
@@ -905,6 +912,7 @@ Description:
                Specifies the value of rate of change threshold that the
                device is comparing against for the events enabled by
                <type>[Y][_name]_roc[_rising|falling]_en.
+
                If separate attributes exist for the two directions,
                but direction is not specified for this attribute,
                then a single threshold value applies to both directions.
@@ -1304,6 +1312,7 @@ Description:
                Proximity measurement indicating that some
                object is near the sensor, usually by observing
                reflectivity of infrared or ultrasound emitted.
+
                Often these sensors are unit less and as such conversion
                to SI units is not possible. Higher proximity measurements
                indicate closer objects, and vice versa. Units after
@@ -1449,9 +1458,12 @@ Contact: linux-iio@vger.kernel.org
 Description:
                A single positive integer specifying the maximum number of scan
                elements to wait for.
+
                Poll will block until the watermark is reached.
+
                Blocking read will wait until the minimum between the requested
                read amount or the low water mark is available.
+
                Non-blocking read will retrieve the available samples from the
                buffer even if there are less samples then watermark level. This
                allows the application to block on poll with a timeout and read
@@ -1480,11 +1492,13 @@ Description:
                device settings allows it (e.g. if a trigger is set that samples
                data differently that the hardware fifo does then hardware fifo
                will not enabled).
+
                If the hardware fifo is enabled and the level of the hardware
                fifo reaches the hardware fifo watermark level the device will
                flush its hardware fifo to the device buffer. Doing a non
                blocking read on the device when no samples are present in the
                device buffer will also force a flush.
+
                When the hardware fifo is enabled there is no need to use a
                trigger to use buffer mode since the watermark settings
                guarantees that the hardware fifo is flushed to the device
@@ -1522,6 +1536,7 @@ Description:
                A single positive integer specifying the minimum watermark level
                for the hardware fifo of this device. If the device does not
                have a hardware fifo this entry is not present.
+
                If the user sets buffer/watermark to a value less than this one,
                then the hardware watermark will remain unset.
 
@@ -1532,6 +1547,7 @@ Description:
                A single positive integer specifying the maximum watermark level
                for the hardware fifo of this device. If the device does not
                have a hardware fifo this entry is not present.
+
                If the user sets buffer/watermark to a value greater than this
                one, then the hardware watermark will be capped at this value.
 
@@ -1543,6 +1559,7 @@ Description:
                levels for the hardware fifo. This entry is optional and if it
                is not present it means that all the values between
                hwfifo_watermark_min and hwfifo_watermark_max are supported.
+
                If the user sets buffer/watermark to a value greater than
                hwfifo_watermak_min but not equal to any of the values in this
                list, the driver will chose an appropriate value for the
@@ -1604,7 +1621,8 @@ KernelVersion:    4.1.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                '1' (enable) or '0' (disable) specifying the enable
-               of heater function. Same reading values apply
+               of heater function. Same reading values apply.
+
                This ABI is especially applicable for humidity sensors
                to heatup the device and get rid of any condensation
                in some humidity environment
@@ -1627,17 +1645,21 @@ Description:
                Mounting matrix for IIO sensors. This is a rotation matrix which
                informs userspace about sensor chip's placement relative to the
                main hardware it is mounted on.
+
                Main hardware placement is defined according to the local
                reference frame related to the physical quantity the sensor
                measures.
+
                Given that the rotation matrix is defined in a board specific
                way (platform data and / or device-tree), the main hardware
                reference frame definition is left to the implementor's choice
                (see below for a magnetometer example).
+
                Applications should apply this rotation matrix to samples so
                that when main hardware reference frame is aligned onto local
                reference frame, then sensor chip reference frame is also
                perfectly aligned with it.
+
                Matrix is a 3x3 unitary matrix and typically looks like
                [0, 1, 0; 1, 0, 0; 0, 0, -1]. Identity matrix
                [1, 0, 0; 0, 1, 0; 0, 0, 1] means sensor chip and main hardware
@@ -1646,8 +1668,10 @@ Description:
                For example, a mounting matrix for a magnetometer sensor informs
                userspace about sensor chip's ORIENTATION relative to the main
                hardware.
+
                More specifically, main hardware orientation is defined with
                respect to the LOCAL EARTH GEOMAGNETIC REFERENCE FRAME where :
+
                * Y is in the ground plane and positive towards magnetic North ;
                * X is in the ground plane, perpendicular to the North axis and
                  positive towards the East ;
@@ -1656,13 +1680,16 @@ Description:
                An implementor might consider that for a hand-held device, a
                'natural' orientation would be 'front facing camera at the top'.
                The main hardware reference frame could then be described as :
+
                * Y is in the plane of the screen and is positive towards the
                  top of the screen ;
                * X is in the plane of the screen, perpendicular to Y axis, and
                  positive towards the right hand side of the screen ;
                * Z is perpendicular to the screen plane and positive out of the
                  screen.
+
                Another example for a quadrotor UAV might be :
+
                * Y is in the plane of the propellers and positive towards the
                  front-view camera;
                * X is in the plane of the propellers, perpendicular to Y axis,
@@ -1704,6 +1731,7 @@ Description:
                This interface is deprecated; please use the Counter subsystem.
 
                A list of possible counting directions which are:
+
                - "up"  : counter device is increasing.
                - "down": counter device is decreasing.
 
index 2071f9bcfaa5c021fe5ef5e0fa0f9c0f6da41cab..1c2a07f7a75e17675df540c1e5b673e6182bc176 100644 (file)
@@ -5,7 +5,8 @@ Contact:        Peter Rosin <peda@axentia.se>
 Description:
                The DAC is used to find the peak level of an alternating
                voltage input signal by a binary search using the output
-               of a comparator wired to an interrupt pin. Like so:
+               of a comparator wired to an interrupt pin. Like so::
+
                                           _
                                          | \
                     input +------>-------|+ \
@@ -19,10 +20,12 @@ Description:
                            |    irq|------<-------'
                            |       |
                            '-------'
+
                The boolean invert attribute (0/1) should be set when the
                input signal is centered around the maximum value of the
                dac instead of zero. The envelope detector will search
                from below in this case and will also invert the result.
+
                The edge/level of the interrupt is also switched to its
                opposite value.
 
index f30b4c424fb60ada0e51a95d63e963dbbcd2c3d2..4b01150af397d97d5b8388312a17b88197958f98 100644 (file)
@@ -19,9 +19,11 @@ Description:
                is separately set for "GND-Open" and "Supply-Open" modes.
                Channels 0..31 have common low threshold values, but could have different
                sensing_modes.
+
                The low voltage threshold range is between 2..21V.
                Hysteresis between low and high thresholds can not be lower then 2 and
                can not be odd.
+
                If falling threshold results hysteresis to odd value then rising
                threshold is automatically subtracted by one.
 
@@ -34,10 +36,13 @@ Description:
                this value then the threshold rising event is pushed.
                Depending on in_voltageY_sensing_mode the high voltage threshold
                is separately set for "GND-Open" and "Supply-Open" modes.
+
                Channels 0..31 have common high threshold values, but could have different
                sensing_modes.
+
                The high voltage threshold range is between 3..22V.
                Hysteresis between low and high thresholds can not be lower then 2 and
                can not be odd.
+
                If rising threshold results hysteresis to odd value then falling
                threshold is automatically appended by one.
index efe4c85e3c8b59ecf481367b83cf0aad6076eb5c..1975c7a1af34670359413e531eff0c9c41152b50 100644 (file)
@@ -5,10 +5,13 @@ Description:
                The STM32 ADC can be configured to use external trigger sources
                (e.g. timers, pwm or exti gpio). Then, it can be tuned to start
                conversions on external trigger by either:
+
                - "rising-edge"
                - "falling-edge"
                - "both-edges".
+
                Reading returns current trigger polarity.
+
                Writing value before enabling conversions sets trigger polarity.
 
 What:          /sys/bus/iio/devices/triggerX/trigger_polarity_available
index 6158f831c761f7242b0c0afffcea21b1c570205e..adf24c40126f08163d3704e98ed49808414d3c25 100644 (file)
@@ -4,7 +4,7 @@ KernelVersion:  4.7
 Contact:       linux-iio@vger.kernel.org
 Description:
                Writing '1' will perform a FOC (Fast Online Calibration). The
-                corresponding calibration offsets can be read from *_calibbias
+                corresponding calibration offsets can be read from `*_calibbias`
                 entries.
 
 What:          /sys/bus/iio/devices/iio:deviceX/location
index 0e66ae9b0071e80b245796aa5b04bf2b461e39b6..91439d6d60b5c0ce0acd7924602f2a2af8b7b49a 100644 (file)
@@ -3,14 +3,20 @@ KernelVersion:        4.14
 Contact:       arnaud.pouliquen@st.com
 Description:
                For audio purpose only.
+
                Used by audio driver to set/get the spi input frequency.
+
                This is mandatory if DFSDM is slave on SPI bus, to
                provide information on the SPI clock frequency during runtime
                Notice that the SPI frequency should be a multiple of sample
                frequency to ensure the precision.
-               if DFSDM input is SPI master
+
+               if DFSDM input is SPI master:
+
                        Reading  SPI clkout frequency,
                        error on writing
+
                If DFSDM input is SPI Slave:
+
                        Reading returns value previously set.
                        Writing value before starting conversions.
index a133fd8d081ac23f74f881ef387f71c9de6fc585..40df5c9fef996efa5956222c23ca1cb3c0f53a11 100644 (file)
@@ -15,8 +15,11 @@ Description:
                first object echoed in meters. Default value is 6.020.
                This setting limits the time the driver is waiting for a
                echo.
+
                Showing the range of available values is represented as the
                minimum value, the step and the maximum value, all enclosed
                in square brackets.
-               Example:
-               [0.043 0.043 11.008]
+
+               Example::
+
+                       [0.043 0.043 11.008]
index a91aeabe7b244ff07a51bd1bd1ea935b6e7c7e4b..d065cda7dd961de9ecfd8d6fb302584fb4e421f9 100644 (file)
@@ -8,7 +8,9 @@ KernelVersion:  3.4.0
 Contact:       linux-iio@vger.kernel.org
 Description:
                Reading returns either '1' or '0'.
+
                '1' means that the clock in question is present.
+
                '0' means that the clock is missing.
 
 What:          /sys/bus/iio/devices/iio:deviceX/pllY_locked
index 302de64cb4246f21d42ffa93a5996d962ebfe7ce..544548ee794c9a39bdbac3bab5d5aa3b8accec34 100644 (file)
@@ -27,12 +27,12 @@ What:               /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_name
 KernelVersion:
 Contact:       linux-iio@vger.kernel.org
 Description:
-               Reading returns the datasheet name for channel Y:
+               Reading returns the datasheet name for channel Y::
 
-               out_altvoltage0_name: RF8x
-               out_altvoltage1_name: RFAUX8x
-               out_altvoltage2_name: RF16x
-               out_altvoltage3_name: RF32x
+                 out_altvoltage0_name: RF8x
+                 out_altvoltage1_name: RFAUX8x
+                 out_altvoltage2_name: RF16x
+                 out_altvoltage3_name: RF32x
 
 What:          /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_powerdown
 KernelVersion:
index 6adba9058b22b649d772381ae24634c1d8a0f940..66b621f10223f7443fe7cfae33434e33f8474073 100644 (file)
@@ -6,10 +6,14 @@ Description:
                Get measured values from the ADC for these stages. Y is the
                specific stage number corresponding to datasheet stage names
                as follows:
-               1 -> LED2
-               2 -> ALED2/LED3
-               3 -> LED1
-               4 -> ALED1/LED4
+
+               == ==========
+               1  LED2
+               2  ALED2/LED3
+               3  LED1
+               4  ALED1/LED4
+               == ==========
+
                Note that channels 5 and 6 represent LED2-ALED2 and LED1-ALED1
                respectively which simply helper channels containing the
                calculated difference in the value of stage 1 - 2 and 3 - 4.
index f0ce0a0476ea6f32153494a9e14d99868dd00756..220206a20d9865150eed9694ab659cde18c78b65 100644 (file)
@@ -15,5 +15,7 @@ Description:
                Scheme 0 has wider dynamic range, Scheme 1 proximity detection
                is less affected by the ambient IR noise variation.
 
-               0 Sensing IR from LED and ambient
-               1 Sensing IR from LED with ambient IR rejection
+               == =============================================
+               0  Sensing IR from LED and ambient
+               1  Sensing IR from LED with ambient IR rejection
+               == =============================================
index ad2cc63e4bf8252ace73583faa7c9fffbe6cede8..73498ff666bd74a92269bf5e1006d34571869233 100644 (file)
@@ -17,9 +17,11 @@ KernelVersion:       4.13
 Contact:       fabrice.gasnier@st.com
 Description:
                Configure the device counter quadrature modes:
+
                - non-quadrature:
                        Encoder IN1 input servers as the count input (up
                        direction).
+
                - quadrature:
                        Encoder IN1 and IN2 inputs are mixed to get direction
                        and count.
@@ -35,23 +37,26 @@ KernelVersion:      4.13
 Contact:       fabrice.gasnier@st.com
 Description:
                Configure the device encoder/counter active edge:
+
                - rising-edge
                - falling-edge
                - both-edges
 
                In non-quadrature mode, device counts up on active edge.
+
                In quadrature mode, encoder counting scenarios are as follows:
-               ----------------------------------------------------------------
+
+               +---------+----------+--------------------+--------------------+
                | Active  | Level on |      IN1 signal    |     IN2 signal     |
-               | edge    | opposite |------------------------------------------
+               | edge    | opposite +----------+---------+----------+---------+
                |         | signal   |  Rising  | Falling |  Rising  | Falling |
-               ----------------------------------------------------------------
-               | Rising  | High ->  |   Down   |    -    |    Up    |    -    |
-               | edge    | Low  ->  |    Up    |    -    |   Down   |    -    |
-               ----------------------------------------------------------------
-               | Falling | High ->  |    -     |    Up   |    -     |   Down  |
-               | edge    | Low  ->  |    -     |   Down  |    -     |    Up   |
-               ----------------------------------------------------------------
-               | Both    | High ->  |   Down   |    Up   |    Up    |   Down  |
-               | edges   | Low  ->  |    Up    |   Down  |   Down   |    Up   |
-               ----------------------------------------------------------------
+               +---------+----------+----------+---------+----------+---------+
+               | Rising  | High ->  |   Down   |    -    |   Up     |    -    |
+               | edge    | Low  ->  |   Up     |    -    |   Down   |    -    |
+               +---------+----------+----------+---------+----------+---------+
+               | Falling | High ->  |    -     |   Up    |    -     |   Down  |
+               | edge    | Low  ->  |    -     |   Down  |    -     |   Up    |
+               +---------+----------+----------+---------+----------+---------+
+               | Both    | High ->  |   Down   |   Up    |   Up     |   Down  |
+               | edges   | Low  ->  |   Up     |   Down  |   Down   |   Up    |
+               +---------+----------+----------+---------+----------+---------+
index 6275e9f56e6c3d668d8429df3986a2f3625696e7..13f099ef6a953ed4420617d040185dc95b59e869 100644 (file)
@@ -5,11 +5,16 @@ Contact:        linux-iio@vger.kernel.org
 Description:
                 Current configuration and available configurations
                for the bias current.
-               normal          - Normal measurement configurations (default)
-               positivebias    - Positive bias configuration
-               negativebias    - Negative bias configuration
-               disabled        - Only available on HMC5983. Disables magnetic
+
+               ============      ============================================
+               normal            Normal measurement configurations (default)
+               positivebias      Positive bias configuration
+               negativebias      Negative bias configuration
+               disabled          Only available on HMC5983. Disables magnetic
                                  sensor and enables temperature sensor.
-               Note: The effect of this configuration may vary
-               according to the device. For exact documentation
-               check the device's datasheet.
+               ============      ============================================
+
+               Note:
+                 The effect of this configuration may vary
+                 according to the device. For exact documentation
+                 check the device's datasheet.
index 3b3509a3ef2f78068ce349352ab6ab9601f5a565..e5ef6d8e5da11dca0f86b99fdd754fda711f7141 100644 (file)
@@ -5,9 +5,12 @@ Description:
                Open-circuit fault. The detection of open-circuit faults,
                such as those caused by broken thermocouple wires.
                Reading returns either '1' or '0'.
-               '1' = An open circuit such as broken thermocouple wires
-                     has been detected.
-               '0' = No open circuit or broken thermocouple wires are detected
+
+               ===  =======================================================
+               '1'  An open circuit such as broken thermocouple wires
+                    has been detected.
+               '0'  No open circuit or broken thermocouple wires are detected
+               ===  =======================================================
 
 What:          /sys/bus/iio/devices/iio:deviceX/fault_ovuv
 KernelVersion: 5.1
@@ -18,7 +21,11 @@ Description:
                cables by integrated MOSFETs at the T+ and T- inputs, and the
                BIAS output. These MOSFETs turn off when the input voltage is
                negative or greater than VDD.
+
                Reading returns either '1' or '0'.
-               '1' = The input voltage is negative or greater than VDD.
-               '0' = The input voltage is positive and less than VDD (normal
-               state).
+
+               ===  =======================================================
+               '1'  The input voltage is negative or greater than VDD.
+               '0'  The input voltage is positive and less than VDD (normal
+                    state).
+               ===  =======================================================
index b7259234ad70081172e26dd3b9ccc19ef62556d0..a10a4de3e5fea9a10dd308479576df686bc2941e 100644 (file)
@@ -3,67 +3,85 @@ KernelVersion:        4.11
 Contact:       benjamin.gaignard@st.com
 Description:
                Reading returns the list possible master modes which are:
-               - "reset"     : The UG bit from the TIMx_EGR register is
+
+
+               - "reset"
+                               The UG bit from the TIMx_EGR register is
                                used as trigger output (TRGO).
-               - "enable"    : The Counter Enable signal CNT_EN is used
+               - "enable"
+                               The Counter Enable signal CNT_EN is used
                                as trigger output.
-               - "update"    : The update event is selected as trigger output.
+               - "update"
+                               The update event is selected as trigger output.
                                For instance a master timer can then be used
                                as a prescaler for a slave timer.
-               - "compare_pulse" : The trigger output send a positive pulse
-                                   when the CC1IF flag is to be set.
-               - "OC1REF"    : OC1REF signal is used as trigger output.
-               - "OC2REF"    : OC2REF signal is used as trigger output.
-               - "OC3REF"    : OC3REF signal is used as trigger output.
-               - "OC4REF"    : OC4REF signal is used as trigger output.
+               - "compare_pulse"
+                               The trigger output send a positive pulse
+                               when the CC1IF flag is to be set.
+               - "OC1REF"
+                               OC1REF signal is used as trigger output.
+               - "OC2REF"
+                               OC2REF signal is used as trigger output.
+               - "OC3REF"
+                               OC3REF signal is used as trigger output.
+               - "OC4REF"
+                               OC4REF signal is used as trigger output.
+
                Additional modes (on TRGO2 only):
-               - "OC5REF"    : OC5REF signal is used as trigger output.
-               - "OC6REF"    : OC6REF signal is used as trigger output.
+
+               - "OC5REF"
+                               OC5REF signal is used as trigger output.
+               - "OC6REF"
+                               OC6REF signal is used as trigger output.
                - "compare_pulse_OC4REF":
-                 OC4REF rising or falling edges generate pulses.
+                               OC4REF rising or falling edges generate pulses.
                - "compare_pulse_OC6REF":
-                 OC6REF rising or falling edges generate pulses.
+                               OC6REF rising or falling edges generate pulses.
                - "compare_pulse_OC4REF_r_or_OC6REF_r":
-                 OC4REF or OC6REF rising edges generate pulses.
+                               OC4REF or OC6REF rising edges generate pulses.
                - "compare_pulse_OC4REF_r_or_OC6REF_f":
-                 OC4REF rising or OC6REF falling edges generate pulses.
+                               OC4REF rising or OC6REF falling edges generate
+                               pulses.
                - "compare_pulse_OC5REF_r_or_OC6REF_r":
-                 OC5REF or OC6REF rising edges generate pulses.
+                               OC5REF or OC6REF rising edges generate pulses.
                - "compare_pulse_OC5REF_r_or_OC6REF_f":
-                 OC5REF rising or OC6REF falling edges generate pulses.
-
-               +-----------+   +-------------+            +---------+
-               | Prescaler +-> | Counter     |        +-> | Master  | TRGO(2)
-               +-----------+   +--+--------+-+        |-> | Control +-->
-                                  |        |          ||  +---------+
-                               +--v--------+-+ OCxREF ||  +---------+
-                               | Chx compare +----------> | Output  | ChX
-                               +-----------+-+         |  | Control +-->
-                                     .     |           |  +---------+
-                                     .     |           |    .
-                               +-----------v-+ OC6REF  |    .
-                               | Ch6 compare +---------+>
-                               +-------------+
-
-               Example with: "compare_pulse_OC4REF_r_or_OC6REF_r":
-
-                               X
-                             X   X
-                           X .   . X
-                         X   .   .   X
-                       X     .   .     X
-               count X .     .   .     . X
-                       .     .   .     .
-                       .     .   .     .
-                       +---------------+
-               OC4REF  |     .   .     |
-                     +-+     .   .     +-+
-                       .     +---+     .
-               OC6REF  .     |   |     .
-                     +-------+   +-------+
-                       +-+   +-+
-               TRGO2   | |   | |
-                     +-+ +---+ +---------+
+                               OC5REF rising or OC6REF falling edges generate
+                               pulses.
+
+               ::
+
+                 +-----------+   +-------------+            +---------+
+                 | Prescaler +-> | Counter     |        +-> | Master  | TRGO(2)
+                 +-----------+   +--+--------+-+        |-> | Control +-->
+                                    |        |          ||  +---------+
+                                 +--v--------+-+ OCxREF ||  +---------+
+                                 | Chx compare +----------> | Output  | ChX
+                                 +-----------+-+         |  | Control +-->
+                                       .     |           |  +---------+
+                                       .     |           |    .
+                                 +-----------v-+ OC6REF  |    .
+                                 | Ch6 compare +---------+>
+                                 +-------------+
+
+               Example with: "compare_pulse_OC4REF_r_or_OC6REF_r"::
+
+                                 X
+                               X   X
+                             X .   . X
+                           X   .   .   X
+                         X     .   .     X
+                 count X .     .   .     . X
+                         .     .   .     .
+                         .     .   .     .
+                         +---------------+
+                 OC4REF  |     .   .     |
+                       +-+     .   .     +-+
+                         .     +---+     .
+                 OC6REF  .     |   |     .
+                       +-------+   +-------+
+                         +-+   +-+
+                 TRGO2   | |   | |
+                       +-+ +---+ +---------+
 
 What:          /sys/bus/iio/devices/triggerX/master_mode
 KernelVersion: 4.11
@@ -91,6 +109,30 @@ Description:
                When counting down the counter start from preset value
                and fire event when reach 0.
 
+What:          /sys/bus/iio/devices/iio:deviceX/in_count_quadrature_mode_available
+KernelVersion: 4.12
+Contact:       benjamin.gaignard@st.com
+Description:
+               Reading returns the list possible quadrature modes.
+
+What:          /sys/bus/iio/devices/iio:deviceX/in_count0_quadrature_mode
+KernelVersion: 4.12
+Contact:       benjamin.gaignard@st.com
+Description:
+               Configure the device counter quadrature modes:
+
+               channel_A:
+                       Encoder A input servers as the count input and B as
+                       the UP/DOWN direction control input.
+
+               channel_B:
+                       Encoder B input serves as the count input and A as
+                       the UP/DOWN direction control input.
+
+               quadrature:
+                       Encoder A and B inputs are mixed to get direction
+                       and count with a scale of 0.25.
+
 What:          /sys/bus/iio/devices/iio:deviceX/in_count_enable_mode_available
 KernelVersion: 4.12
 Contact:       benjamin.gaignard@st.com
@@ -104,6 +146,7 @@ Description:
                Configure the device counter enable modes, in all case
                counting direction is set by in_count0_count_direction
                attribute and the counter is clocked by the internal clock.
+
                always:
                        Counter is always ON.
 
index 22d0843849a85bd21dcea6045f293a67b7007df2..b7b2278fe0421c6ee5228cb334032e8e889f9e14 100644 (file)
@@ -10,10 +10,13 @@ Date:               June 2015
 KernelVersion: 4.3
 Contact:       Alexander Shishkin <alexander.shishkin@linux.intel.com>
 Description:   (RO) Output port type:
-                 0: not present,
-                 1: MSU (Memory Storage Unit)
-                 2: CTP (Common Trace Port)
-                 4: PTI (MIPI PTI).
+
+                ==  =========================
+                 0  not present,
+                 1  MSU (Memory Storage Unit)
+                 2  CTP (Common Trace Port)
+                 4  PTI (MIPI PTI).
+                ==  =========================
 
 What:          /sys/bus/intel_th/devices/<intel_th_id>-gth/outputs/[0-7]_drop
 Date:          June 2015
index 7fd2601c2831b3ad1392b4615681f123fbc70572..a74252e580a564b833bf4fa06c4c53dc71e61586 100644 (file)
@@ -9,11 +9,13 @@ Date:         June 2015
 KernelVersion: 4.3
 Contact:       Alexander Shishkin <alexander.shishkin@linux.intel.com>
 Description:   (RW) Configure MSC operating mode:
+
                  - "single", for contiguous buffer mode (high-order alloc);
                  - "multi", for multiblock mode;
                  - "ExI", for DCI handler mode;
                  - "debug", for debug mode;
                  - any of the currently loaded buffer sinks.
+
                If operating mode changes, existing buffer is deallocated,
                provided there are no active users and tracing is not enabled,
                otherwise the write will fail.
@@ -23,10 +25,12 @@ Date:               June 2015
 KernelVersion: 4.3
 Contact:       Alexander Shishkin <alexander.shishkin@linux.intel.com>
 Description:   (RW) Configure MSC buffer size for "single" or "multi" modes.
+
                In single mode, this is a single number of pages, has to be
                power of 2. In multiblock mode, this is a comma-separated list
                of numbers of pages for each window to be allocated. Number of
                windows is not limited.
+
                Writing to this file deallocates existing buffer (provided
                there are no active users and tracing is not enabled) and then
                allocates a new one.
index ec0a603d804ba0785a9725ca8d8c0feba4506115..38cc03e408e7be39c2f111390fb0c2f4f75be526 100644 (file)
@@ -235,7 +235,8 @@ KernelVersion:      4.15
 Contact:       Christian Gromm <christian.gromm@microchip.com>
 Description:
                This is to read back the configured direction of the channel.
-               The following strings will be accepted:
+               The following strings will be accepted::
+
                        'tx',
                        'rx'
 Users:
@@ -246,7 +247,8 @@ KernelVersion:      4.15
 Contact:       Christian Gromm <christian.gromm@microchip.com>
 Description:
                This is to read back the configured data type of the channel.
-               The following strings will be accepted:
+               The following strings will be accepted::
+
                        'control',
                        'async',
                        'sync',
index 355958527fa357b51576c574ca46a68b6d01f2df..4a6d61b44f3f4fb59323c21963691455f4dc8be3 100644 (file)
@@ -2,16 +2,16 @@ What:         /sys/bus/moxtet/devices/moxtet-<name>.<addr>/module_description
 Date:          March 2019
 KernelVersion: 5.3
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Moxtet module description. Format: string
+Description:   (Read) Moxtet module description. Format: string
 
 What:          /sys/bus/moxtet/devices/moxtet-<name>.<addr>/module_id
 Date:          March 2019
 KernelVersion: 5.3
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Moxtet module ID. Format: %x
+Description:   (Read) Moxtet module ID. Format: %x
 
 What:          /sys/bus/moxtet/devices/moxtet-<name>.<addr>/module_name
 Date:          March 2019
 KernelVersion: 5.3
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Moxtet module name. Format: string
+Description:   (Read) Moxtet module name. Format: string
index e4f76e7eab938cff005f78518b2326833bb9d6b7..63ef0b9ecce70be910ff1d3da30be7565d3642be 100644 (file)
@@ -1,4 +1,4 @@
-For all of the nmem device attributes under nfit/*, see the 'NVDIMM Firmware
+For all of the nmem device attributes under ``nfit/*``, see the 'NVDIMM Firmware
 Interface Table (NFIT)' section in the ACPI specification
 (http://www.uefi.org/specifications) for more details.
 
index d64380262be8cffa9bcbce619ae3818210ac8a72..bff84a16812a0c5e17c9f0f95eee1dac407084a1 100644 (file)
@@ -1,2 +1,8 @@
+What:          nvdimm
+Date:          July 2020
+KernelVersion: 5.8
+Contact:       Dan Williams <dan.j.williams@intel.com>
+Description:
+
 The libnvdimm sub-system implements a common sysfs interface for
 platform nvdimm resources. See Documentation/driver-api/nvdimm/.
index c1a67275c43f84623959575a6fddf8fd8e5c3c64..8316c33862a047b86fb508a75122bcae16ca9768 100644 (file)
@@ -11,19 +11,26 @@ Description:
                at 'Documentation/powerpc/papr_hcalls.rst' . Below are
                the flags reported in this sysfs file:
 
-               * "not_armed"   : Indicates that NVDIMM contents will not
+               * "not_armed"
+                                 Indicates that NVDIMM contents will not
                                  survive a power cycle.
-               * "flush_fail"  : Indicates that NVDIMM contents
+               * "flush_fail"
+                                 Indicates that NVDIMM contents
                                  couldn't be flushed during last
                                  shut-down event.
-               * "restore_fail": Indicates that NVDIMM contents
+               * "restore_fail"
+                                 Indicates that NVDIMM contents
                                  couldn't be restored during NVDIMM
                                  initialization.
-               * "encrypted"   : NVDIMM contents are encrypted.
-               * "smart_notify": There is health event for the NVDIMM.
-               * "scrubbed"    : Indicating that contents of the
+               * "encrypted"
+                                 NVDIMM contents are encrypted.
+               * "smart_notify"
+                                 There is health event for the NVDIMM.
+               * "scrubbed"
+                                 Indicating that contents of the
                                  NVDIMM have been scrubbed.
-               * "locked"      : Indicating that NVDIMM contents cant
+               * "locked"
+                                 Indicating that NVDIMM contents cant
                                  be modified until next power cycle.
 
 What:          /sys/bus/nd/devices/nmemX/papr/perf_stats
@@ -51,4 +58,4 @@ Description:
                * "MedWDur " : Media Write Duration
                * "CchRHCnt" : Cache Read Hit Count
                * "CchWHCnt" : Cache Write Hit Count
-               * "FastWCnt" : Fast Write Count
\ No newline at end of file
+               * "FastWCnt" : Fast Write Count
index 450296cc7948ecbaab3e70446bcba5b0d1e8807b..77ad9ec3c801966213147ee5c18273f48edda9b0 100644 (file)
@@ -7,8 +7,10 @@ Description:
                this location.  This is useful for overriding default
                bindings.  The format for the location is: DDDD:BB:DD.F.
                That is Domain:Bus:Device.Function and is the same as
-               found in /sys/bus/pci/devices/.  For example:
-               # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/bind
+               found in /sys/bus/pci/devices/.  For example::
+
+                 # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/bind
+
                (Note: kernels before 2.6.28 may require echo -n).
 
 What:          /sys/bus/pci/drivers/.../unbind
@@ -20,8 +22,10 @@ Description:
                this location.  This may be useful when overriding default
                bindings.  The format for the location is: DDDD:BB:DD.F.
                That is Domain:Bus:Device.Function and is the same as
-               found in /sys/bus/pci/devices/. For example:
-               # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/unbind
+               found in /sys/bus/pci/devices/. For example::
+
+                 # echo 0000:00:19.0 > /sys/bus/pci/drivers/foo/unbind
+
                (Note: kernels before 2.6.28 may require echo -n).
 
 What:          /sys/bus/pci/drivers/.../new_id
@@ -38,8 +42,9 @@ Description:
                Class, Class Mask, and Private Driver Data.  The Vendor ID
                and Device ID fields are required, the rest are optional.
                Upon successfully adding an ID, the driver will probe
-               for the device and attempt to bind to it.  For example:
-               # echo "8086 10f5" > /sys/bus/pci/drivers/foo/new_id
+               for the device and attempt to bind to it.  For example::
+
+                 # echo "8086 10f5" > /sys/bus/pci/drivers/foo/new_id
 
 What:          /sys/bus/pci/drivers/.../remove_id
 Date:          February 2009
@@ -54,8 +59,9 @@ Description:
                required, the rest are optional.  After successfully
                removing an ID, the driver will no longer support the
                device.  This is useful to ensure auto probing won't
-               match the driver to the device.  For example:
-               # echo "8086 10f5" > /sys/bus/pci/drivers/foo/remove_id
+               match the driver to the device.  For example::
+
+                 # echo "8086 10f5" > /sys/bus/pci/drivers/foo/remove_id
 
 What:          /sys/bus/pci/rescan
 Date:          January 2009
index 3c9a8c4a25eb89a87448f18fd7b550b4c5e74c55..860db53037a58fae2faa10fcfc8672c0ed20ace9 100644 (file)
@@ -1,6 +1,6 @@
-==========================
 PCIe Device AER statistics
-==========================
+--------------------------
+
 These attributes show up under all the devices that are AER capable. These
 statistical counters indicate the errors "as seen/reported by the device".
 Note that this may mean that if an endpoint is causing problems, the AER
@@ -17,19 +17,18 @@ Description:        List of correctable errors seen and reported by this
                PCI device using ERR_COR. Note that since multiple errors may
                be reported using a single ERR_COR message, thus
                TOTAL_ERR_COR at the end of the file may not match the actual
-               total of all the errors in the file. Sample output:
--------------------------------------------------------------------------
-localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_correctable
-Receiver Error 2
-Bad TLP 0
-Bad DLLP 0
-RELAY_NUM Rollover 0
-Replay Timer Timeout 0
-Advisory Non-Fatal 0
-Corrected Internal Error 0
-Header Log Overflow 0
-TOTAL_ERR_COR 2
--------------------------------------------------------------------------
+               total of all the errors in the file. Sample output::
+
+                   localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_correctable
+                   Receiver Error 2
+                   Bad TLP 0
+                   Bad DLLP 0
+                   RELAY_NUM Rollover 0
+                   Replay Timer Timeout 0
+                   Advisory Non-Fatal 0
+                   Corrected Internal Error 0
+                   Header Log Overflow 0
+                   TOTAL_ERR_COR 2
 
 What:          /sys/bus/pci/devices/<dev>/aer_dev_fatal
 Date:          July 2018
@@ -39,28 +38,27 @@ Description:        List of uncorrectable fatal errors seen and reported by this
                PCI device using ERR_FATAL. Note that since multiple errors may
                be reported using a single ERR_FATAL message, thus
                TOTAL_ERR_FATAL at the end of the file may not match the actual
-               total of all the errors in the file. Sample output:
--------------------------------------------------------------------------
-localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_fatal
-Undefined 0
-Data Link Protocol 0
-Surprise Down Error 0
-Poisoned TLP 0
-Flow Control Protocol 0
-Completion Timeout 0
-Completer Abort 0
-Unexpected Completion 0
-Receiver Overflow 0
-Malformed TLP 0
-ECRC 0
-Unsupported Request 0
-ACS Violation 0
-Uncorrectable Internal Error 0
-MC Blocked TLP 0
-AtomicOp Egress Blocked 0
-TLP Prefix Blocked Error 0
-TOTAL_ERR_FATAL 0
--------------------------------------------------------------------------
+               total of all the errors in the file. Sample output::
+
+                   localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_fatal
+                   Undefined 0
+                   Data Link Protocol 0
+                   Surprise Down Error 0
+                   Poisoned TLP 0
+                   Flow Control Protocol 0
+                   Completion Timeout 0
+                   Completer Abort 0
+                   Unexpected Completion 0
+                   Receiver Overflow 0
+                   Malformed TLP 0
+                   ECRC 0
+                   Unsupported Request 0
+                   ACS Violation 0
+                   Uncorrectable Internal Error 0
+                   MC Blocked TLP 0
+                   AtomicOp Egress Blocked 0
+                   TLP Prefix Blocked Error 0
+                   TOTAL_ERR_FATAL 0
 
 What:          /sys/bus/pci/devices/<dev>/aer_dev_nonfatal
 Date:          July 2018
@@ -70,32 +68,31 @@ Description:        List of uncorrectable nonfatal errors seen and reported by this
                PCI device using ERR_NONFATAL. Note that since multiple errors
                may be reported using a single ERR_FATAL message, thus
                TOTAL_ERR_NONFATAL at the end of the file may not match the
-               actual total of all the errors in the file. Sample output:
--------------------------------------------------------------------------
-localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_nonfatal
-Undefined 0
-Data Link Protocol 0
-Surprise Down Error 0
-Poisoned TLP 0
-Flow Control Protocol 0
-Completion Timeout 0
-Completer Abort 0
-Unexpected Completion 0
-Receiver Overflow 0
-Malformed TLP 0
-ECRC 0
-Unsupported Request 0
-ACS Violation 0
-Uncorrectable Internal Error 0
-MC Blocked TLP 0
-AtomicOp Egress Blocked 0
-TLP Prefix Blocked Error 0
-TOTAL_ERR_NONFATAL 0
--------------------------------------------------------------------------
+               actual total of all the errors in the file. Sample output::
+
+                   localhost /sys/devices/pci0000:00/0000:00:1c.0 # cat aer_dev_nonfatal
+                   Undefined 0
+                   Data Link Protocol 0
+                   Surprise Down Error 0
+                   Poisoned TLP 0
+                   Flow Control Protocol 0
+                   Completion Timeout 0
+                   Completer Abort 0
+                   Unexpected Completion 0
+                   Receiver Overflow 0
+                   Malformed TLP 0
+                   ECRC 0
+                   Unsupported Request 0
+                   ACS Violation 0
+                   Uncorrectable Internal Error 0
+                   MC Blocked TLP 0
+                   AtomicOp Egress Blocked 0
+                   TLP Prefix Blocked Error 0
+                   TOTAL_ERR_NONFATAL 0
 
-============================
 PCIe Rootport AER statistics
-============================
+----------------------------
+
 These attributes show up under only the rootports (or root complex event
 collectors) that are AER capable. These indicate the number of error messages as
 "reported to" the rootport. Please note that the rootports also transmit
index 8a200f4eefbd7557b4d8739e746e6ef8f3355c3e..f85db86d63e834b50a734dec6cbdd7dd0312c218 100644 (file)
@@ -4,6 +4,7 @@ Contact:        Cezary Rojewski <cezary.rojewski@intel.com>
 Description:
                Version of AudioDSP firmware ASoC catpt driver is
                communicating with.
+
                Format: %d.%d.%d.%d, type:major:minor:build.
 
 What:          /sys/devices/pci0000:00/<dev>/fw_info
index 60c60fa624b2a063ea762d47f28b87847d041550..c90d97a80855244e7231f2bd44c11c412aeb986d 100644 (file)
@@ -21,11 +21,11 @@ Description:
                number returns the port to normal operation.
 
                For example: To force the high-speed device attached to
-               port 4 on bus 2 to run at full speed:
+               port 4 on bus 2 to run at full speed::
 
                        echo 4 >/sys/bus/usb/devices/usb2/../companion
 
-               To return the port to high-speed operation:
+               To return the port to high-speed operation::
 
                        echo -4 >/sys/bus/usb/devices/usb2/../companion
 
index 13208b27dd87d5e70c2269ca9d9186de4a6bea74..634ea207a50a9d1b9e982ed69c24c8106719de72 100644 (file)
@@ -4,24 +4,27 @@ Description:
                an individual subdirectory with the following name format of
                device_name "nn:d:iiii", where:
 
-               nn   - two-digit hexadecimal ID of RapidIO network where the
+               ====   ========================================================
+               nn     two-digit hexadecimal ID of RapidIO network where the
                       device resides
-               d    - device type: 'e' - for endpoint or 's' - for switch
-               iiii - four-digit device destID for endpoints, or switchID for
+               d      device type: 'e' - for endpoint or 's' - for switch
+               iiii   four-digit device destID for endpoints, or switchID for
                       switches
+               ====   ========================================================
 
                For example, below is a list of device directories that
                represents a typical RapidIO network with one switch, one host,
                and two agent endpoints, as it is seen by the enumerating host
-               (with destID = 1):
+               (with destID = 1)::
 
-               /sys/bus/rapidio/devices/00:e:0000
-               /sys/bus/rapidio/devices/00:e:0002
-               /sys/bus/rapidio/devices/00:s:0001
+                 /sys/bus/rapidio/devices/00:e:0000
+                 /sys/bus/rapidio/devices/00:e:0002
+                 /sys/bus/rapidio/devices/00:s:0001
 
-               NOTE: An enumerating or discovering endpoint does not create a
-               sysfs entry for itself, this is why an endpoint with destID=1 is
-               not shown in the list.
+               NOTE:
+                 An enumerating or discovering endpoint does not create a
+                 sysfs entry for itself, this is why an endpoint with destID=1
+                 is not shown in the list.
 
 Attributes Common for All RapidIO Devices
 -----------------------------------------
index cc30bee8b5f4430be0e10322ee14cb7cc25f98a8..417a2fe21be1effd9bde442199a6b217c9011c52 100644 (file)
@@ -7,6 +7,8 @@ Description:
 
                Usage: <mon ip addr> <options> <pool name> <rbd image name> [<snap name>]
 
+               Example::
+
                 $ echo "192.168.0.1 name=admin rbd foo" > /sys/bus/rbd/add
 
                The snapshot name can be "-" or omitted to map the image
@@ -23,6 +25,8 @@ Description:
 
                Usage: <dev-id> [force]
 
+               Example::
+
                 $ echo 2 > /sys/bus/rbd/remove
 
                Optional "force" argument which when passed will wait for
@@ -80,26 +84,29 @@ Date:               Oct, 2010
 KernelVersion: v2.6.37
 Contact:       Sage Weil <sage@newdream.net>
 Description:
-               size:           (RO) The size (in bytes) of the mapped block
+
+               ==============  ================================================
+               size            (RO) The size (in bytes) of the mapped block
                                device.
 
-               major:          (RO) The block device major number.
+               major           (RO) The block device major number.
 
-               client_id:      (RO) The ceph unique client id that was assigned
+               client_id       (RO) The ceph unique client id that was assigned
                                for this specific session.
 
-               pool:           (RO) The name of the storage pool where this rbd
+               pool            (RO) The name of the storage pool where this rbd
                                image resides. An rbd image name is unique
                                within its pool.
 
-               name:           (RO) The name of the rbd image.
+               name            (RO) The name of the rbd image.
 
-               refresh:        (WO) Writing to this file will reread the image
+               refresh         (WO) Writing to this file will reread the image
                                header data and set all relevant data structures
                                accordingly.
 
-               current_snap:   (RO) The current snapshot for which the device
+               current_snap    (RO) The current snapshot for which the device
                                is mapped.
+               ==============  ================================================
 
 
 What:          /sys/bus/rbd/devices/<dev-id>/pool_id
@@ -117,11 +124,13 @@ Date:             Oct, 2012
 KernelVersion: v3.7
 Contact:       Sage Weil <sage@newdream.net>
 Description:
-               image_id:       (RO) The unique id for the rbd image. (For rbd
+               =========       ===============================================
+               image_id        (RO) The unique id for the rbd image. (For rbd
                                image format 1 this is empty.)
 
-               features:       (RO) A hexadecimal encoding of the feature bits
+               features        (RO) A hexadecimal encoding of the feature bits
                                for this image.
+               =========       ===============================================
 
 
 What:          /sys/bus/rbd/devices/<dev-id>/parent
@@ -149,14 +158,16 @@ Date:             Aug, 2016
 KernelVersion: v4.9
 Contact:       Sage Weil <sage@newdream.net>
 Description:
-               snap_id:        (RO) The current snapshot's id.
+               ============    ================================================
+               snap_id         (RO) The current snapshot's id.
 
-               config_info:    (RO) The string written into
+               config_info     (RO) The string written into
                                /sys/bus/rbd/add{,_single_major}.
 
-               cluster_fsid:   (RO) The ceph cluster UUID.
+               cluster_fsid    (RO) The ceph cluster UUID.
 
-               client_addr:    (RO) The ceph unique client
+               client_addr     (RO) The ceph unique client
                                entity_addr_t (address + nonce). The format is
                                <address>:<port>/<nonce>: '1.2.3.4:1234/5678' or
                                '[1:2:3:4:5:6:7:8]:1234/5678'.
+               ============    ================================================
index c2a403f20b90820e42c601412b56516d812689b5..50e80238f30dfe276f1cc6dc4e95d30ef7a3dc88 100644 (file)
@@ -8,6 +8,7 @@ Description:
                When the file contains a "1" the bus is operated and periodically
                does a push-pull cycle to write and read data from the
                connected devices.
+
                When writing a "0" or "1" the bus moves to the described state.
 
 What:          /sys/bus/siox/devices/siox-X/device_add
@@ -21,8 +22,10 @@ Description:
                to add a new device dynamically. <type> is the name that is used to match
                to a driver (similar to the platform bus). <inbytes> and <outbytes> define
                the length of the input and output shift register in bytes respectively.
+
                <statustype> defines the 4 bit device type that is check to identify connection
                problems.
+
                The new device is added to the end of the existing chain.
 
 What:          /sys/bus/siox/devices/siox-X/device_remove
index dd565c378b4032f18b1e528f6b3c0bdc6e5e0939..0b4ab9e4b8f475248ec67d1c9f23e7822331954f 100644 (file)
@@ -37,16 +37,18 @@ Contact:    thunderbolt-software@lists.01.org
 Description:   This attribute holds current Thunderbolt security level
                set by the system BIOS. Possible values are:
 
-               none: All devices are automatically authorized
-               user: Devices are only authorized based on writing
-                     appropriate value to the authorized attribute
-               secure: Require devices that support secure connect at
-                       minimum. User needs to authorize each device.
-               dponly: Automatically tunnel Display port (and USB). No
-                       PCIe tunnels are created.
-               usbonly: Automatically tunnel USB controller of the
+               =======  ==================================================
+               none     All devices are automatically authorized
+               user     Devices are only authorized based on writing
+                        appropriate value to the authorized attribute
+               secure   Require devices that support secure connect at
+                        minimum. User needs to authorize each device.
+               dponly   Automatically tunnel Display port (and USB). No
+                        PCIe tunnels are created.
+               usbonly  Automatically tunnel USB controller of the
                         connected Thunderbolt dock (and Display Port). All
                         PCIe links downstream of the dock are removed.
+               =======  ==================================================
 
 What: /sys/bus/thunderbolt/devices/.../authorized
 Date:          Sep 2017
@@ -61,17 +63,23 @@ Description:        This attribute is used to authorize Thunderbolt devices
                yet authorized.
 
                Possible values are supported:
-               1: The device will be authorized and connected
+
+               ==  ===========================================
+               1   The device will be authorized and connected
+               ==  ===========================================
 
                When key attribute contains 32 byte hex string the possible
                values are:
-               1: The 32 byte hex string is added to the device NVM and
-                  the device is authorized.
-               2: Send a challenge based on the 32 byte hex string. If the
-                  challenge response from device is valid, the device is
-                  authorized. In case of failure errno will be ENOKEY if
-                  the device did not contain a key at all, and
-                  EKEYREJECTED if the challenge response did not match.
+
+               ==  ========================================================
+               1   The 32 byte hex string is added to the device NVM and
+                   the device is authorized.
+               2   Send a challenge based on the 32 byte hex string. If the
+                   challenge response from device is valid, the device is
+                   authorized. In case of failure errno will be ENOKEY if
+                   the device did not contain a key at all, and
+                   EKEYREJECTED if the challenge response did not match.
+               ==  ========================================================
 
 What: /sys/bus/thunderbolt/devices/.../boot
 Date:          Jun 2018
@@ -185,10 +193,11 @@ Description:      When new NVM image is written to the non-active NVM
                verification fails an error code is returned instead.
 
                This file will accept writing values "1" or "2"
+
                - Writing "1" will flush the image to the storage
-               area and authenticate the image in one action.
+                 area and authenticate the image in one action.
                - Writing "2" will run some basic validation on the image
-               and flush it to the storage area.
+                 and flush it to the storage area.
 
                When read holds status of the last authentication
                operation if an error occurred during the process. This
@@ -205,9 +214,11 @@ Description:       This contains name of the property directory the XDomain
                question. Following directories are already reserved by
                the Apple XDomain specification:
 
-               network:  IP/ethernet over Thunderbolt
-               targetdm: Target disk mode protocol over Thunderbolt
-               extdisp:  External display mode protocol over Thunderbolt
+               ========  ===============================================
+               network   IP/ethernet over Thunderbolt
+               targetdm  Target disk mode protocol over Thunderbolt
+               extdisp   External display mode protocol over Thunderbolt
+               ========  ===============================================
 
 What:          /sys/bus/thunderbolt/devices/<xdomain>.<service>/modalias
 Date:          Jan 2018
@@ -285,7 +296,8 @@ Description:        For supported devices, automatically authenticate the new Thunderbo
                image when the device is disconnected from the host system.
 
                This file will accept writing values "1" or "2"
+
                - Writing "1" will flush the image to the storage
-               area and prepare the device for authentication on disconnect.
+                 area and prepare the device for authentication on disconnect.
                - Writing "2" will run some basic validation on the image
-               and flush it to the storage area.
+                 and flush it to the storage area.
index 614d216dff1d9f2066c7e834d4497a32bd73a99c..bf2c1968525f01187e55d9c6a1d3638a352b9ae4 100644 (file)
@@ -9,6 +9,7 @@ Description:
                by writing INTERFACE to /sys/bus/usb/drivers_probe
                This allows to avoid side-effects with drivers
                that need multiple interfaces.
+
                A deauthorized interface cannot be probed or claimed.
 
 What:          /sys/bus/usb/devices/usbX/interface_authorized_default
@@ -72,24 +73,27 @@ Description:
                table at compile time. The format for the device ID is:
                idVendor idProduct bInterfaceClass RefIdVendor RefIdProduct
                The vendor ID and device ID fields are required, the
-               rest is optional. The Ref* tuple can be used to tell the
+               rest is optional. The `Ref*` tuple can be used to tell the
                driver to use the same driver_data for the new device as
                it is used for the reference device.
                Upon successfully adding an ID, the driver will probe
-               for the device and attempt to bind to it.  For example:
-               # echo "8086 10f5" > /sys/bus/usb/drivers/foo/new_id
+               for the device and attempt to bind to it.  For example::
+
+                 # echo "8086 10f5" > /sys/bus/usb/drivers/foo/new_id
 
                Here add a new device (0458:7045) using driver_data from
-               an already supported device (0458:704c):
-               # echo "0458 7045 0 0458 704c" > /sys/bus/usb/drivers/foo/new_id
+               an already supported device (0458:704c)::
+
+                 # echo "0458 7045 0 0458 704c" > /sys/bus/usb/drivers/foo/new_id
 
                Reading from this file will list all dynamically added
                device IDs in the same format, with one entry per
-               line. For example:
-               # cat /sys/bus/usb/drivers/foo/new_id
-               8086 10f5
-               dead beef 06
-               f00d cafe
+               line. For example::
+
+                 # cat /sys/bus/usb/drivers/foo/new_id
+                 8086 10f5
+                 dead beef 06
+                 f00d cafe
 
                The list will be truncated at PAGE_SIZE bytes due to
                sysfs restrictions.
@@ -209,9 +213,11 @@ Description:
                advance, and behaves well according to the specification.
                This attribute is a bit-field that controls the behavior of
                a specific port:
+
                 - Bit 0 of this field selects the "old" enumeration scheme,
                   as it is considerably faster (it only causes one USB reset
                   instead of 2).
+
                   The old enumeration scheme can also be selected globally
                   using /sys/module/usbcore/parameters/old_scheme_first, but
                   it is often not desirable as the new scheme was introduced to
@@ -233,10 +239,10 @@ Description:
                poll() for monitoring changes to this value in user space.
 
                Any time this value changes the corresponding hub device will send a
-               udev event with the following attributes:
+               udev event with the following attributes::
 
-               OVER_CURRENT_PORT=/sys/bus/usb/devices/.../(hub interface)/portX
-               OVER_CURRENT_COUNT=[current value of this sysfs attribute]
+                 OVER_CURRENT_PORT=/sys/bus/usb/devices/.../(hub interface)/portX
+                 OVER_CURRENT_COUNT=[current value of this sysfs attribute]
 
 What:          /sys/bus/usb/devices/.../(hub interface)/portX/usb3_lpm_permit
 Date:          November 2015
index 9ade80f81f96c4abaacd17723146bbe362e41ea6..2f86e4223bfc8d25cc9552fe3865e3ccc964803b 100644 (file)
@@ -12,8 +12,11 @@ KernelVersion:       2.6.26
 Contact:       Harrison Metzger <harrisonmetz@gmail.com>
 Description:   Controls the devices display mode.
                For a 6 character display the values are
+
                        MSB 0x06; LSB 0x3F, and
+
                for an 8 character display the values are
+
                        MSB 0x08; LSB 0xFF.
 
 What:          /sys/bus/usb/.../textmode
@@ -37,7 +40,7 @@ KernelVersion:        2.6.26
 Contact:       Harrison Metzger <harrisonmetz@gmail.com>
 Description:   Controls the decimal places on the device.
                To set the nth decimal place, give this field
-               the value of 10 ** n. Assume this field has
+               the value of ``10 ** n``. Assume this field has
                the value k and has 1 or more decimal places set,
                to set the mth place (where m is not already set),
-               change this fields value to k + 10 ** m.
+               change this fields value to ``k + 10 ** m``.
index 452dbe39270ecab61f6ca9b1aa30f628519f761e..59fc804265dba5eba09e0d36c7dcfdf4cab6718d 100644 (file)
@@ -28,8 +28,9 @@ Description:
                Writing UUID to this file will create mediated device of
                type <type-id> for parent device <device>. This is a
                write-only file.
-               For example:
-               # echo "83b8f4f2-509f-382f-3c1e-e6bfe0fa1001" > \
+               For example::
+
+                 # echo "83b8f4f2-509f-382f-3c1e-e6bfe0fa1001" >       \
                       /sys/devices/foo/mdev_supported_types/foo-1/create
 
 What:           /sys/.../mdev_supported_types/<type-id>/devices/
@@ -107,5 +108,6 @@ Description:
                Writing '1' to this file destroys the mediated device. The
                vendor driver can fail the remove() callback if that device
                is active and the vendor driver doesn't support hot unplug.
-               Example:
-               # echo 1 > /sys/bus/mdev/devices/<UUID>/remove
+               Example::
+
+                 # echo 1 > /sys/bus/mdev/devices/<UUID>/remove
index 716cffc457e94c80099459b0b1e6c1b30719c710..f7b8cf6e43989b9a4d4fc0b96d7cebe00a76c115 100644 (file)
@@ -66,13 +66,6 @@ Description:
                the "erase" command on the on-board flash of the connected
                micro.
 
-What:          /sys/class/c2port/c2portX/flash_erase
-Date:          October 2008
-Contact:       Rodolfo Giometti <giometti@linux.it>
-Description:
-               The /sys/class/c2port/c2portX/flash_erase file show the
-               on-board flash size of the connected micro.
-
 What:          /sys/class/c2port/c2portX/reset
 Date:          October 2008
 Contact:       Rodolfo Giometti <giometti@linux.it>
index 3ab175a3f5cb34ee4b25b9adfa2430ff93baba30..1fc86401bf95938ce71d8e7ac4df47c8b399c059 100644 (file)
@@ -24,3 +24,63 @@ Description:
                non-linear
                  The brightness changes non-linearly with each step. Brightness
                  controls should use a linear mapping for a linear perception.
+
+What:          /sys/class/backlight/<backlight>/ambient_light_level
+Date:          Apr, 2010
+KernelVersion: v2.6.35
+Contact:       Michael Hennerich <michael.hennerich@analog.com>
+Description:
+               (RO) Get conversion value of the light sensor.
+
+               The value is automatically updated every 80 ms when the
+               light sensor is enabled.
+
+               The value range is device-driver specific:
+
+               For ADP8870:
+
+                 It returns integer between 0 (dark) and 8000 (max ambient
+                 brightness).
+
+               For ADP8860:
+
+                 It returns a 13-bits integer.
+
+What:          /sys/class/backlight/<backlight>/ambient_light_zone
+Date:          Apr, 2010
+KernelVersion: v2.6.35
+Contact:       Michael Hennerich <michael.hennerich@analog.com>,
+               device-drivers-devel@blackfin.uclinux.org
+
+Description:
+               (RW) Read or write the specific brightness level at which the
+               backlight operates.
+
+               The value meaning is device-driver specific:
+
+               For ADP8860:
+
+                 ==    ==========================
+                  0    Off: Backlight set to 0 mA
+                  1    Level 1: daylight
+                  2    Level 2: bright
+                  3    Level 3: dark
+                 ==    ==========================
+
+               For ADP8870:
+
+                 ==    ==========================
+                  0    Off: Backlight set to 0 mA
+                  1    Level 1: daylight
+                  2    Level 2: bright
+                  3    Level 3: office
+                  4    Level 4: indoor
+                  5    Level 5: dark
+                 ==    ==========================
+
+               Writing 0 returns to normal/automatic ambient light level
+               operation.
+
+               It can be enabled by writing the value stored in
+               /sys/class/backlight/<backlight>/max_brightness to
+               /sys/class/backlight/<backlight>/brightness.
index 54d61c788b1b56292da338ec0f2033fbabb92ab2..6610ac73f9ba06b5084db00020e87d2694345d42 100644 (file)
@@ -6,25 +6,8 @@ adp8860, adp8861 and adp8863 devices: daylight (level 1), office (level 2) and
 dark (level 3). By default the brightness operates at the daylight brightness
 level.
 
-What:          /sys/class/backlight/<backlight>/ambient_light_level
-Date:          Apr, 2010
-KernelVersion: v2.6.35
-Contact:       Michael Hennerich <michael.hennerich@analog.com>
-Description:
-               (RO) 13-bit conversion value for the first light sensor—high
-               byte (Bit 12 to Bit 8). The value is updated every 80 ms (when
-               the light sensor is enabled).
-
-
-What:          /sys/class/backlight/<backlight>/ambient_light_zone
-Date:          Apr, 2010
-KernelVersion: v2.6.35
-Contact:       Michael Hennerich <michael.hennerich@analog.com>
-Description:
-               (RW) Read or write the specific level at which the backlight
-               operates. Value "0" enables automatic ambient light sensing, and
-               values "1", "2" or "3" set the control to daylight, office or
-               dark respectively.
+See also /sys/class/backlight/<backlight>/ambient_light_level and
+/sys/class/backlight/<backlight>/ambient_light_zone.
 
 
 What:          /sys/class/backlight/<backlight>/l1_daylight_max
index 33e648808117770949f81bd72e4b7fe1479705d4..b08ca912cad40c19693f98ace7cdfbe35cb3412e 100644 (file)
@@ -1,3 +1,6 @@
+See also /sys/class/backlight/<backlight>/ambient_light_level and
+/sys/class/backlight/<backlight>/ambient_light_zone.
+
 What:          /sys/class/backlight/<backlight>/<ambient light zone>_max
 What:          /sys/class/backlight/<backlight>/l1_daylight_max
 What:          /sys/class/backlight/<backlight>/l2_bright_max
@@ -27,30 +30,3 @@ Description:
                set to 0. Full off when the backlight is disabled.
                This file will also show the dim brightness level stored for
                this <ambient light zone>.
-
-What:          /sys/class/backlight/<backlight>/ambient_light_level
-Date:          May 2011
-KernelVersion: 3.0
-Contact:       device-drivers-devel@blackfin.uclinux.org
-Description:
-               Get conversion value of the light sensor.
-               This value is updated every 80 ms (when the light sensor
-               is enabled). Returns integer between 0 (dark) and
-               8000 (max ambient brightness)
-
-What:          /sys/class/backlight/<backlight>/ambient_light_zone
-Date:          May 2011
-KernelVersion: 3.0
-Contact:       device-drivers-devel@blackfin.uclinux.org
-Description:
-               Get/Set current ambient light zone. Reading returns
-               integer between 1..5 (1 = daylight, 2 = bright, ..., 5 = dark).
-               Writing a value between 1..5 forces the backlight controller
-               to enter the corresponding ambient light zone.
-               Writing 0 returns to normal/automatic ambient light level
-               operation. The ambient light sensing feature on these devices
-               is an extension to the API documented in
-               Documentation/ABI/stable/sysfs-class-backlight.
-               It can be enabled by writing the value stored in
-               /sys/class/backlight/<backlight>/max_brightness to
-               /sys/class/backlight/<backlight>/brightness.
index c0e0a9ae7b3d9bfb4a344d00490759d2475e013d..8251e78abc493e3ddb7e965e7920fe6baa2c4d01 100644 (file)
@@ -6,8 +6,10 @@ Description:
                Get the ALS output channel used as input in
                ALS-current-control mode (0, 1), where:
 
-               0 - out_current0 (backlight 0)
-               1 - out_current1 (backlight 1)
+               ==  ==========================
+               0   out_current0 (backlight 0)
+               1   out_current1 (backlight 1)
+               ==  ==========================
 
 What:          /sys/class/backlight/<backlight>/als_en
 Date:          May 2012
@@ -30,8 +32,10 @@ Contact:     Johan Hovold <jhovold@gmail.com>
 Description:
                Set the brightness-mapping mode (0, 1), where:
 
-               0 - exponential mode
-               1 - linear mode
+               ==  ================
+               0   exponential mode
+               1   linear mode
+               ==  ================
 
 What:          /sys/class/backlight/<backlight>/pwm
 Date:          April 2012
@@ -40,9 +44,11 @@ Contact:     Johan Hovold <jhovold@gmail.com>
 Description:
                Set the PWM-input control mask (5 bits), where:
 
-               bit 5 - PWM-input enabled in Zone 4
-               bit 4 - PWM-input enabled in Zone 3
-               bit 3 - PWM-input enabled in Zone 2
-               bit 2 - PWM-input enabled in Zone 1
-               bit 1 - PWM-input enabled in Zone 0
-               bit 0 - PWM-input enabled
+               =====   ===========================
+               bit 5   PWM-input enabled in Zone 4
+               bit 4   PWM-input enabled in Zone 3
+               bit 3   PWM-input enabled in Zone 2
+               bit 2   PWM-input enabled in Zone 1
+               bit 1   PWM-input enabled in Zone 0
+               bit 0   PWM-input enabled
+               =====   ===========================
index d773d5697cf588349b74fd7d19e63983472b1632..5402bd74ba43b4303f95d026bcde1df86bbd737a 100644 (file)
@@ -24,7 +24,6 @@ default
        filesystems which do not provide their own BDI.
 
 Files under /sys/class/bdi/<bdi>/
----------------------------------
 
 read_ahead_kb (read-write)
 
index 5819699d66ec08b081cc2c1202ac2fcf14755ece..74ece942722e71ec139f544f0701725f1125c68b 100644 (file)
@@ -17,13 +17,14 @@ Date:               August 2015
 KernelVersion: 4.2
 Description:
                Tell the EC to reboot in various ways. Options are:
-               "cancel": Cancel a pending reboot.
-               "ro": Jump to RO without rebooting.
-               "rw": Jump to RW without rebooting.
-               "cold": Cold reboot.
-               "disable-jump": Disable jump until next reboot.
-               "hibernate": Hibernate the EC.
-               "at-shutdown": Reboot after an AP shutdown.
+
+               - "cancel": Cancel a pending reboot.
+               - "ro": Jump to RO without rebooting.
+               - "rw": Jump to RW without rebooting.
+               - "cold": Cold reboot.
+               - "disable-jump": Disable jump until next reboot.
+               - "hibernate": Hibernate the EC.
+               - "at-shutdown": Reboot after an AP shutdown.
 
 What:          /sys/class/chromeos/<ec-device-name>/version
 Date:          August 2015
index 7970e3713e705ce91c3f0dbceb51efc6c876d2a6..818f55970efbd1418ea68b3a93b729818a2ede67 100644 (file)
@@ -72,11 +72,16 @@ Description:    read/write
                 when performing the START_WORK ioctl. Only applicable when
                 running under hashed page table mmu.
                 Possible values:
-                        none: No prefaulting (default)
-                        work_element_descriptor: Treat the work element
-                                 descriptor as an effective address and
-                                 prefault what it points to.
-                        all: all segments process calling START_WORK maps.
+
+                =======================  ======================================
+               none                     No prefaulting (default)
+               work_element_descriptor  Treat the work element
+                                        descriptor as an effective address and
+                                        prefault what it points to.
+                all                     all segments process calling
+                                        START_WORK maps.
+                =======================  ======================================
+
 Users:         https://github.com/ibm-capi/libcxl
 
 What:           /sys/class/cxl/<afu>/reset
@@ -212,6 +217,7 @@ Description:    read/write
                 card.  A power cycle is required to load the image.
                 "none" could be useful for debugging because the trace arrays
                 are preserved.
+
                 "user" and "factory" means PERST will cause either the user or
                 user or factory image to be loaded.
                 Default is to reload on PERST whichever image the card has
@@ -235,8 +241,11 @@ Contact:   linuxppc-dev@lists.ozlabs.org
 Description:   read/write
                Trust that when an image is reloaded via PERST, it will not
                have changed.
-               0 = don't trust, the image may be different (default)
-               1 = trust that the image will not change.
+
+               ==  =================================================
+               0   don't trust, the image may be different (default)
+               1   trust that the image will not change.
+               ==  =================================================
 Users:         https://github.com/ibm-capi/libcxl
 
 What:           /sys/class/cxl/<card>/psl_timebase_synced
index deefffb3bbe45dba1c855e3525c739363afed0f6..b8ebff4b1c4ca23f35f61ec37e78bb2e377611df 100644 (file)
@@ -62,7 +62,8 @@ Description:
                driver should provide the list of available frequencies
                with its profile. If need to reset the statistics of devfreq
                behavior on a specific device, enter 0(zero) to 'trans_stat'
-               as following:
+               as following::
+
                        echo 0 > /sys/class/devfreq/.../trans_stat
 
 What:          /sys/class/devfreq/.../userspace/set_freq
@@ -117,6 +118,7 @@ Description:
                This work timer is used by devfreq workqueue in order to
                monitor the device status such as utilization. The user
                can change the work timer on runtime according to their demand
-               as following:
+               as following::
+
                        echo deferrable > /sys/class/devfreq/.../timer
                        echo delayed > /sys/class/devfreq/.../timer
index 64791b65c9a384279aab2d6f7206ef7c721a85af..b662f747c83ebd99eac633e92a034ca407ed5354 100644 (file)
@@ -18,9 +18,9 @@ Description:
 
                This will be one of the following strings:
 
-               'consumer unbind'
-               'supplier unbind'
-               'never'
+               'consumer unbind'
+               'supplier unbind'
+               'never'
 
                'consumer unbind' means the device link will be removed when
                the consumer's driver is unbound from the consumer device.
@@ -49,8 +49,10 @@ Description:
 
                This will be one of the following strings:
 
-               '0' - Does not affect runtime power management
-               '1' - Affects runtime power management
+               ===   ========================================
+               '0'   Does not affect runtime power management
+               '1'   Affects runtime power management
+               ===   ========================================
 
 What:          /sys/class/devlink/.../status
 Date:          May 2020
@@ -68,13 +70,13 @@ Description:
 
                This will be one of the following strings:
 
-               'not tracked'
-               'dormant'
-               'available'
-               'consumer probing'
-               'active'
-               'supplier unbinding'
-               'unknown'
+               'not tracked'
+               'dormant'
+               'available'
+               'consumer probing'
+               'active'
+               'supplier unbinding'
+               'unknown'
 
                'not tracked' means this device link does not track the status
                and has no impact on the binding, unbinding and syncing the
@@ -114,8 +116,10 @@ Description:
 
                This will be one of the following strings:
 
+               ===  ================================
                '0'
-               '1' - Affects runtime power management
+               '1'  Affects runtime power management
+               ===  ================================
 
                '0' means the device link can affect other device behaviors
                like binding/unbinding, suspend/resume, runtime power
index 57a726232912e46ae61adfc545ace17d25023558..fde0fecd5de95bbfc151c19a8c0df09e0f966264 100644 (file)
@@ -39,19 +39,22 @@ Description:
                callback.
 
                If the default callback for showing function is used, the
-               format is like this:
-               # cat state
-               USB_OTG=1
-               HDMI=0
-               TA=1
-               EAR_JACK=0
-               #
+               format is like this::
+
+                   # cat state
+                   USB_OTG=1
+                   HDMI=0
+                   TA=1
+                   EAR_JACK=0
+                   #
+
                In this example, the extcon device has USB_OTG and TA
                cables attached and HDMI and EAR_JACK cables detached.
 
                In order to update the state of an extcon device, enter a hex
-               state number starting with 0x:
-               # echo 0xHEX > state
+               state number starting with 0x::
+
+                   # echo 0xHEX > state
 
                This updates the whole state of the extcon device.
                Inputs of all the methods are required to meet the
@@ -84,12 +87,13 @@ Contact:    MyungJoo Ham <myungjoo.ham@samsung.com>
 Description:
                Shows the relations of mutually exclusiveness. For example,
                if the mutually_exclusive array of extcon device is
-               {0x3, 0x5, 0xC, 0x0}, then the output is:
-               # ls mutually_exclusive/
-               0x3
-               0x5
-               0xc
-               #
+               {0x3, 0x5, 0xC, 0x0}, then the output is::
+
+                   # ls mutually_exclusive/
+                   0x3
+                   0x5
+                   0xc
+                   #
 
                Note that mutually_exclusive is a sub-directory of the extcon
                device and the file names under the mutually_exclusive
index 5284fa33d4c55fa449c9fa5deca2053c09bc307e..d78689c357a518c4e2ee16182f744fb9d02495f4 100644 (file)
@@ -28,8 +28,7 @@ Description:  Read fpga manager state as a string.
                * firmware request      = firmware class request in progress
                * firmware request error = firmware request failed
                * write init            = preparing FPGA for programming
-               * write init error      = Error while preparing FPGA for
-                                         programming
+               * write init error      = Error while preparing FPGA for programming
                * write                 = FPGA ready to receive image data
                * write error           = Error while programming
                * write complete        = Doing post programming steps
@@ -47,7 +46,7 @@ Description:  Read fpga manager status as a string.
                programming errors to userspace. This is a list of strings for
                the supported status.
 
-               * reconfig operation error      - invalid operations detected by
+               * reconfig operation error      - invalid operations detected by
                                                  reconfiguration hardware.
                                                  e.g. start reconfiguration
                                                  with errors not cleared
index 2467b6900eae5124662afe397fef320bb9d74e4b..c8553d972eddfde93341b04d161528d13b543afc 100644 (file)
@@ -6,9 +6,11 @@ Description:
                The GNSS receiver type. The currently identified types reflect
                the protocol(s) supported by the receiver:
 
+                       ======          ===========
                        "NMEA"          NMEA 0183
                        "SiRF"          SiRF Binary
                        "UBX"           UBX
+                       ======          ===========
 
                Note that also non-"NMEA" type receivers typically support a
                subset of NMEA 0183 with vendor extensions (e.g. to allow
index 5f67f7ab277bc51af0bdb8ccb94ae03f6936ad6c..2e24ac3bd7efa4e64d8dc084462cc0ef92dc9202 100644 (file)
@@ -3,9 +3,26 @@ Date:          March 2006
 KernelVersion: 2.6.17
 Contact:       Richard Purdie <rpurdie@rpsys.net>
 Description:
-               Set the brightness of the LED. Most LEDs don't
-               have hardware brightness support, so will just be turned on for
-               non-zero brightness settings. The value is between 0 and
+               Set the brightness of the LED.
+
+               Most LEDs don't have hardware brightness support, so will
+               just be turned on for non-zero brightness settings.
+
+               .. Note::
+
+                 For multicolor LEDs, writing to this file will update all
+                 LEDs within the group to a calculated percentage of what
+                 each color LED intensity is set to.
+
+                 The percentage is calculated for each grouped LED via
+                 the equation below::
+
+                   led_brightness = brightness * multi_intensity/max_brightness
+
+                 For additional details please refer to
+                 Documentation/leds/leds-class-multicolor.rst.
+
+               The value is between 0 and
                /sys/class/leds/<led>/max_brightness.
 
                Writing 0 to this file clears active trigger.
@@ -13,6 +30,8 @@ Description:
                Writing non-zero to this file while trigger is active changes the
                top brightness trigger is going to use.
 
+
+
 What:          /sys/class/leds/<led>/max_brightness
 Date:          March 2006
 KernelVersion: 2.6.17
@@ -47,10 +66,11 @@ Contact:    Richard Purdie <rpurdie@rpsys.net>
 Description:
                Set the trigger for this LED. A trigger is a kernel based source
                of LED events.
+
                You can change triggers in a similar manner to the way an IO
                scheduler is chosen. Trigger specific parameters can appear in
                /sys/class/leds/<led> once a given trigger is selected. For
-               their documentation see sysfs-class-led-trigger-*.
+               their documentation see `sysfs-class-led-trigger-*`.
 
 What:          /sys/class/leds/<led>/inverted
 Date:          January 2011
index f520ece9b64c555a3757771e3ad2deda0aabb04f..04f3ffdc593615340a9bed0a4d78584bbb9d6abf 100644 (file)
@@ -1,133 +1,3 @@
-What:          /sys/class/leds/<led>/hw_pattern
-Date:          September 2019
-KernelVersion: 5.5
-Description:
-               Specify a hardware pattern for the EL15203000 LED.
-               The LEDs board supports only predefined patterns by firmware
-               for specific LEDs.
-
-               Breathing mode for Screen frame light tube:
-               "0 4000 1 4000"
-
-                   ^
-                   |
-               Max-|     ---
-                   |    /   \
-                   |   /     \
-                   |  /       \     /
-                   | /         \   /
-               Min-|-           ---
-                   |
-                   0------4------8--> time (sec)
-
-               Cascade mode for Pipe LED:
-               "1 800 2 800 4 800 8 800 16 800"
-
-                     ^
-                     |
-               0 On -|----+                   +----+                   +---
-                     |    |                   |    |                   |
-                 Off-|    +-------------------+    +-------------------+
-                     |
-               1 On -|    +----+                   +----+
-                     |    |    |                   |    |
-                 Off |----+    +-------------------+    +------------------
-                     |
-               2 On -|         +----+                   +----+
-                     |         |    |                   |    |
-                 Off-|---------+    +-------------------+    +-------------
-                     |
-               3 On -|              +----+                   +----+
-                     |              |    |                   |    |
-                 Off-|--------------+    +-------------------+    +--------
-                     |
-               4 On -|                   +----+                   +----+
-                     |                   |    |                   |    |
-                 Off-|-------------------+    +-------------------+    +---
-                     |
-                     0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
-
-               Inverted cascade mode for Pipe LED:
-               "30 800 29 800 27 800 23 800 15 800"
-
-                     ^
-                     |
-               0 On -|    +-------------------+    +-------------------+
-                     |    |                   |    |                   |
-                 Off-|----+                   +----+                   +---
-                     |
-               1 On -|----+    +-------------------+    +------------------
-                     |    |    |                   |    |
-                 Off |    +----+                   +----+
-                     |
-               2 On -|---------+    +-------------------+    +-------------
-                     |         |    |                   |    |
-                 Off-|         +----+                   +----+
-                     |
-               3 On -|--------------+    +-------------------+    +--------
-                     |              |    |                   |    |
-                 Off-|              +----+                   +----+
-                     |
-               4 On -|-------------------+    +-------------------+    +---
-                     |                   |    |                   |    |
-                 Off-|                   +----+                   +----+
-                     |
-                     0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
-
-               Bounce mode for Pipe LED:
-               "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
-
-                     ^
-                     |
-               0 On -|----+                                       +--------
-                     |    |                                       |
-                 Off-|    +---------------------------------------+
-                     |
-               1 On -|    +----+                             +----+
-                     |    |    |                             |    |
-                 Off |----+    +-----------------------------+    +--------
-                     |
-               2 On -|         +----+                   +----+
-                     |         |    |                   |    |
-                 Off-|---------+    +-------------------+    +-------------
-                     |
-               3 On -|              +----+         +----+
-                     |              |    |         |    |
-                 Off-|--------------+    +---------+    +------------------
-                     |
-               4 On -|                   +---------+
-                     |                   |         |
-                 Off-|-------------------+         +-----------------------
-                     |
-                     0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
-
-               Inverted bounce mode for Pipe LED:
-               "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
-
-                     ^
-                     |
-               0 On -|    +---------------------------------------+
-                     |    |                                       |
-                 Off-|----+                                       +--------
-                     |
-               1 On -|----+    +-----------------------------+    +--------
-                     |    |    |                             |    |
-                 Off |    +----+                             +----+
-                     |
-               2 On -|---------+    +-------------------+    +-------------
-                     |         |    |                   |    |
-                 Off-|         +----+                   +----+
-                     |
-               3 On -|--------------+    +---------+    +------------------
-                     |              |    |         |    |
-                 Off-|              +----+         +----+
-                     |
-               4 On -|-------------------+         +-----------------------
-                     |                   |         |
-                 Off-|                   +---------+
-                     |
-                     0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
-
 What:          /sys/class/leds/<led>/repeat
 Date:          September 2019
 KernelVersion: 5.5
index e4c89b261546c367463561adf0017ca7ea18a565..e38a835d0a85e89a9db507fceccf26bc3ef5953b 100644 (file)
@@ -6,8 +6,10 @@ Description:
                Set the ALS output channel to use as input in
                ALS-current-control mode (1, 2), where:
 
-               1 - out_current1
-               2 - out_current2
+               ==  ============
+               1   out_current1
+               2   out_current2
+               ==  ============
 
 What:          /sys/class/leds/<led>/als_en
 Date:          May 2012
@@ -24,14 +26,16 @@ Contact:    Johan Hovold <jhovold@gmail.com>
 Description:
                Set the pattern generator fall and rise times (0..7), where:
 
-               0 - 2048 us
-               1 - 262 ms
-               2 - 524 ms
-               3 - 1.049 s
-               4 - 2.097 s
-               5 - 4.194 s
-               6 - 8.389 s
-               7 - 16.78 s
+               ==  =======
+               0   2048 us
+               1   262 ms
+               2   524 ms
+               3   1.049 s
+               4   2.097 s
+               5   4.194 s
+               6   8.389 s
+               7   16.78 s
+               ==  =======
 
 What:          /sys/class/leds/<led>/id
 Date:          April 2012
@@ -47,8 +51,10 @@ Contact:     Johan Hovold <jhovold@gmail.com>
 Description:
                Set the brightness-mapping mode (0, 1), where:
 
-               0 - exponential mode
-               1 - linear mode
+               ==  ================
+               0   exponential mode
+               1   linear mode
+               ==  ================
 
 What:          /sys/class/leds/<led>/pwm
 Date:          April 2012
@@ -57,9 +63,11 @@ Contact:     Johan Hovold <jhovold@gmail.com>
 Description:
                Set the PWM-input control mask (5 bits), where:
 
-               bit 5 - PWM-input enabled in Zone 4
-               bit 4 - PWM-input enabled in Zone 3
-               bit 3 - PWM-input enabled in Zone 2
-               bit 2 - PWM-input enabled in Zone 1
-               bit 1 - PWM-input enabled in Zone 0
-               bit 0 - PWM-input enabled
+               =====  ===========================
+               bit 5  PWM-input enabled in Zone 4
+               bit 4  PWM-input enabled in Zone 3
+               bit 3  PWM-input enabled in Zone 2
+               bit 2  PWM-input enabled in Zone 1
+               bit 1  PWM-input enabled in Zone 0
+               bit 0  PWM-input enabled
+               =====  ===========================
diff --git a/Documentation/ABI/testing/sysfs-class-led-driver-sc27xx b/Documentation/ABI/testing/sysfs-class-led-driver-sc27xx
deleted file mode 100644 (file)
index 45b1e60..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-What:          /sys/class/leds/<led>/hw_pattern
-Date:          September 2018
-KernelVersion: 4.20
-Description:
-               Specify a hardware pattern for the SC27XX LED. For the SC27XX
-               LED controller, it only supports 4 stages to make a single
-               hardware pattern, which is used to configure the rise time,
-               high time, fall time and low time for the breathing mode.
-
-               For the breathing mode, the SC27XX LED only expects one brightness
-               for the high stage. To be compatible with the hardware pattern
-               format, we should set brightness as 0 for rise stage, fall
-               stage and low stage.
-
-               Min stage duration: 125 ms
-               Max stage duration: 31875 ms
-
-               Since the stage duration step is 125 ms, the duration should be
-               a multiplier of 125, like 125ms, 250ms, 375ms, 500ms ... 31875ms.
-
-               Thus the format of the hardware pattern values should be:
-               "0 rise_duration brightness high_duration 0 fall_duration 0 low_duration".
index 220a0270b47b4981936e1832f83aa11dfd8c9558..11e5677c3672954ad45b189301bf081ff49fa411 100644 (file)
@@ -55,26 +55,35 @@ Description:        read only
                Flash faults are re-read after strobing the flash. Possible
                flash faults:
 
-               * led-over-voltage - flash controller voltage to the flash LED
+               * led-over-voltage
+                       flash controller voltage to the flash LED
                        has exceeded the limit specific to the flash controller
-               * flash-timeout-exceeded - the flash strobe was still on when
+               * flash-timeout-exceeded
+                       the flash strobe was still on when
                        the timeout set by the user has expired; not all flash
                        controllers may set this in all such conditions
-               * controller-over-temperature - the flash controller has
+               * controller-over-temperature
+                       the flash controller has
                        overheated
-               * controller-short-circuit - the short circuit protection
+               * controller-short-circuit
+                       the short circuit protection
                        of the flash controller has been triggered
-               * led-power-supply-over-current - current in the LED power
+               * led-power-supply-over-current
+                       current in the LED power
                        supply has exceeded the limit specific to the flash
                        controller
-               * indicator-led-fault - the flash controller has detected
+               * indicator-led-fault
+                       the flash controller has detected
                        a short or open circuit condition on the indicator LED
-               * led-under-voltage - flash controller voltage to the flash
+               * led-under-voltage
+                       flash controller voltage to the flash
                        LED has been below the minimum limit specific to
                        the flash
-               * controller-under-voltage - the input voltage of the flash
+               * controller-under-voltage
+                       the input voltage of the flash
                        controller is below the limit under which strobing the
                        flash at full current will not be possible;
                        the condition persists until this flag is no longer set
-               * led-over-temperature - the temperature of the LED has exceeded
+               * led-over-temperature
+                       the temperature of the LED has exceeded
                        its allowed upper limit
index eeeddcbdbbe3373a26328c6407550e6964fa9d22..16fc827b10cb60773feb18720b79a8eb6cb224d0 100644 (file)
@@ -1,20 +1,3 @@
-What:          /sys/class/leds/<led>/brightness
-Date:          March 2020
-KernelVersion: 5.9
-Contact:       Dan Murphy <dmurphy@ti.com>
-Description:   read/write
-               Writing to this file will update all LEDs within the group to a
-               calculated percentage of what each color LED intensity is set
-               to. The percentage is calculated for each grouped LED via the
-               equation below:
-
-               led_brightness = brightness * multi_intensity/max_brightness
-
-               For additional details please refer to
-               Documentation/leds/leds-class-multicolor.rst.
-
-               The value of the LED is from 0 to
-               /sys/class/leds/<led>/max_brightness.
 
 What:          /sys/class/leds/<led>/multi_index
 Date:          March 2020
@@ -25,6 +8,9 @@ Description:   read
                as an array of strings as they are indexed in the
                multi_intensity file.
 
+               For additional details please refer to
+               Documentation/leds/leds-class-multicolor.rst.
+
 What:          /sys/class/leds/<led>/multi_intensity
 Date:          March 2020
 KernelVersion: 5.9
@@ -33,3 +19,6 @@ Description:  read/write
                This file contains array of integers. Order of components is
                described by the multi_index array. The maximum intensity should
                not exceed /sys/class/leds/<led>/max_brightness.
+
+               For additional details please refer to
+               Documentation/leds/leds-class-multicolor.rst.
index 451af6d6768c5c8aa87bb49a72602da1d2554cd9..646540950e381ad021eaec6745035896ccd6e7b3 100644 (file)
@@ -19,18 +19,23 @@ KernelVersion:      4.16
 Contact:       linux-leds@vger.kernel.org
 Description:
                Signal the link state of the named network device.
+
                If set to 0 (default), the LED's normal state is off.
+
                If set to 1, the LED's normal state reflects the link state
                of the named network device.
                Setting this value also immediately changes the LED state.
 
+
 What:          /sys/class/leds/<led>/tx
 Date:          Dec 2017
 KernelVersion: 4.16
 Contact:       linux-leds@vger.kernel.org
 Description:
                Signal transmission of data on the named network device.
+
                If set to 0 (default), the LED will not blink on transmission.
+
                If set to 1, the LED will blink for the milliseconds specified
                in interval to signal transmission.
 
@@ -40,6 +45,8 @@ KernelVersion:        4.16
 Contact:       linux-leds@vger.kernel.org
 Description:
                Signal reception of data on the named network device.
+
                If set to 0 (default), the LED will not blink on reception.
+
                If set to 1, the LED will blink for the milliseconds specified
                in interval to signal reception.
index bd92ef9d6faa8d4a65a7c143267c12eceb58256d..d91a07767adf067f5ab6ce3fd04b2bf097a08b09 100644 (file)
@@ -23,8 +23,8 @@ Description:
 
                Since different LED hardware can have different semantics of
                hardware patterns, each driver is expected to provide its own
-               description for the hardware patterns in their ABI documentation
-               file.
+               description for the hardware patterns in their documentation
+               file at Documentation/leds/.
 
 What:          /sys/class/leds/<led>/repeat
 Date:          September 2018
index f440e690daef65dc21c48c253a6b428fb435103b..eb81152b8348c31b02491cb87c434909c339c5cf 100644 (file)
@@ -8,5 +8,6 @@ Description:
                selected for the USB port trigger. Selecting ports makes trigger
                observing them for any connected devices and lighting on LED if
                there are any.
+
                Echoing "1" value selects USB port. Echoing "0" unselects it.
                Current state can be also read.
index 6adab27f646e668eeb46d92ee5fe6ed560ad15c2..b57ffb26e722a3dd9048fedf98ad703b294211fb 100644 (file)
@@ -7,9 +7,11 @@ Description:
                of one LED will update the mode of its two sibling devices as
                well. Possible values are:
 
-               0 - normal
-               1 - audio
-               2 - breathing
+               ==  =========
+               0   normal
+               1   audio
+               2   breathing
+               ==  =========
 
                Normal: LEDs are fully on when enabled
                Audio:  LEDs brightness depends on sound level
index 6ef68260317975d0daf1b62c2070430fef1ba91d..bd0e780c37601d56554591acf58477cc55ba49be 100644 (file)
@@ -41,24 +41,33 @@ Description:
                When read, this entry provides the current state of an Intel
                MIC device in the context of the card OS. Possible values that
                will be read are:
-               "ready" - The MIC device is ready to boot the card OS. On
-               reading this entry after an OSPM resume, a "boot" has to be
-               written to this entry if the card was previously shutdown
-               during OSPM suspend.
-               "booting" - The MIC device has initiated booting a card OS.
-               "online" - The MIC device has completed boot and is online
-               "shutting_down" - The card OS is shutting down.
-               "resetting" - A reset has been initiated for the MIC device
-               "reset_failed" - The MIC device has failed to reset.
+
+
+               ===============  ===============================================
+               "ready"          The MIC device is ready to boot the card OS.
+                                On reading this entry after an OSPM resume,
+                                a "boot" has to be written to this entry if
+                                the card was previously shutdown during OSPM
+                                suspend.
+               "booting"        The MIC device has initiated booting a card OS.
+               "online"         The MIC device has completed boot and is online
+               "shutting_down"  The card OS is shutting down.
+               "resetting"      A reset has been initiated for the MIC device
+               "reset_failed"   The MIC device has failed to reset.
+               ===============  ===============================================
 
                When written, this sysfs entry triggers different state change
                operations depending upon the current state of the card OS.
                Acceptable values are:
-               "boot" - Boot the card OS image specified by the combination
-                        of firmware, ramdisk, cmdline and bootmode
-                       sysfs entries.
-               "reset" - Initiates device reset.
-               "shutdown" - Initiates card OS shutdown.
+
+
+               ==========  ===================================================
+               "boot"      Boot the card OS image specified by the combination
+                           of firmware, ramdisk, cmdline and bootmode
+                           sysfs entries.
+               "reset"     Initiates device reset.
+               "shutdown"  Initiates card OS shutdown.
+               ==========  ===================================================
 
 What:          /sys/class/mic/mic(x)/shutdown_status
 Date:          October 2013
@@ -69,12 +78,15 @@ Description:
                OS can shutdown because of various reasons. When read, this
                entry provides the status on why the card OS was shutdown.
                Possible values are:
-               "nop" -  shutdown status is not applicable, when the card OS is
-                       "online"
-               "crashed" - Shutdown because of a HW or SW crash.
-               "halted" - Shutdown because of a halt command.
-               "poweroff" - Shutdown because of a poweroff command.
-               "restart" - Shutdown because of a restart command.
+
+               ==========  ===================================================
+               "nop"       shutdown status is not applicable, when the card OS
+                           is "online"
+               "crashed"   Shutdown because of a HW or SW crash.
+               "halted"    Shutdown because of a halt command.
+               "poweroff"  Shutdown because of a poweroff command.
+               "restart"   Shutdown because of a restart command.
+               ==========  ===================================================
 
 What:          /sys/class/mic/mic(x)/cmdline
 Date:          October 2013
index 3b404577f380267f2fc30ffb3de88f67555b8c54..1f2002df5ba2378390a7c88573051fc2e1f511fb 100644 (file)
@@ -4,10 +4,13 @@ KernelVersion:        3.17
 Contact:       netdev@vger.kernel.org
 Description:
                Indicates the name assignment type. Possible values are:
-               1: enumerated by the kernel, possibly in an unpredictable way
-               2: predictably named by the kernel
-               3: named by userspace
-               4: renamed
+
+               == ==========================================================
+               1  enumerated by the kernel, possibly in an unpredictable way
+               2  predictably named by the kernel
+               3  named by userspace
+               4  renamed
+               == ==========================================================
 
 What:          /sys/class/net/<iface>/addr_assign_type
 Date:          July 2010
@@ -15,10 +18,13 @@ KernelVersion:      3.2
 Contact:       netdev@vger.kernel.org
 Description:
                Indicates the address assignment type. Possible values are:
-               0: permanent address
-               1: randomly generated
-               2: stolen from another device
-               3: set using dev_set_mac_address
+
+               == =============================
+               0  permanent address
+               1  randomly generated
+               2  stolen from another device
+               3  set using dev_set_mac_address
+               == =============================
 
 What:          /sys/class/net/<iface>/addr_len
 Date:          April 2005
@@ -51,9 +57,12 @@ Description:
                Default value 0 does not forward any link local frames.
 
                Restricted bits:
-               0: 01-80-C2-00-00-00 Bridge Group Address used for STP
-               1: 01-80-C2-00-00-01 (MAC Control) 802.3 used for MAC PAUSE
-               2: 01-80-C2-00-00-02 (Link Aggregation) 802.3ad
+
+               == ========================================================
+               0  01-80-C2-00-00-00 Bridge Group Address used for STP
+               1  01-80-C2-00-00-01 (MAC Control) 802.3 used for MAC PAUSE
+               2  01-80-C2-00-00-02 (Link Aggregation) 802.3ad
+               == ========================================================
 
                Any values not setting these bits can be used. Take special
                care when forwarding control frames e.g. 802.1X-PAE or LLDP.
@@ -74,8 +83,11 @@ Contact:     netdev@vger.kernel.org
 Description:
                Indicates the current physical link state of the interface.
                Posssible values are:
-               0: physical link is down
-               1: physical link is up
+
+               == =====================
+               0  physical link is down
+               1  physical link is up
+               == =====================
 
                Note: some special devices, e.g: bonding and team drivers will
                allow this attribute to be written to force a link state for
@@ -131,21 +143,27 @@ Contact:  netdev@vger.kernel.org
 Description:
                Indicates whether the interface is under test. Possible
                values are:
-               0: interface is not being tested
-               1: interface is being tested
+
+               == =============================
+               0  interface is not being tested
+               1  interface is being tested
+               == =============================
 
                When an interface is under test, it cannot be expected
                to pass packets as normal.
 
-What:          /sys/clas/net/<iface>/duplex
+What:          /sys/class/net/<iface>/duplex
 Date:          October 2009
 KernelVersion: 2.6.33
 Contact:       netdev@vger.kernel.org
 Description:
                Indicates the interface latest or current duplex value. Possible
                values are:
-               half: half duplex
-               full: full duplex
+
+               ====  ===========
+               half  half duplex
+               full  full duplex
+               ====  ===========
 
                Note: This attribute is only valid for interfaces that implement
                the ethtool get_link_ksettings method (mostly Ethernet).
@@ -196,8 +214,11 @@ Description:
                Indicates the interface link mode, as a decimal number. This
                attribute should be used in conjunction with 'dormant' attribute
                to determine the interface usability. Possible values:
-               0: default link mode
-               1: dormant link mode
+
+               ==  =================
+               0   default link mode
+               1   dormant link mode
+               ==  =================
 
 What:          /sys/class/net/<iface>/mtu
 Date:          April 2005
@@ -226,7 +247,9 @@ KernelVersion:      2.6.17
 Contact:       netdev@vger.kernel.org
 Description:
                Indicates the interface RFC2863 operational state as a string.
+
                Possible values are:
+
                "unknown", "notpresent", "down", "lowerlayerdown", "testing",
                "dormant", "up".
 
index f7be0e88b139d0483bca5624aa0cffb9243309b0..06416d0e163d8ec4e13c7d7df566ff468fe4a701 100644 (file)
@@ -91,9 +91,9 @@ Date:         May 2014
 KernelVersion: 3.16
 Contact:       Bjørn Mork <bjorn@mork.no>
 Description:
-               Bit 0: 16-bit NTB supported (set to 1)
-               Bit 1: 32-bit NTB supported
-               Bits 2 â€“ 15: reserved (reset to zero; must be ignored by host)
+               Bit 0: 16-bit NTB supported (set to 1)
+               Bit 1: 32-bit NTB supported
+               Bits 2 â€“ 15: reserved (reset to zero; must be ignored by host)
 
 What:          /sys/class/net/<iface>/cdc_ncm/dwNtbInMaxSize
 Date:          May 2014
index 206cbf538b59c12ceb6df481358334a1bb2af272..40ced0ea431663fee1d71801ad87fb9939610940 100644 (file)
@@ -35,7 +35,9 @@ Description:
                Ethernet driver during bus enumeration, encoded in string.
                This interface mode is used to configure the Ethernet MAC with the
                appropriate mode for its data lines to the PHY hardware.
+
                Possible values are:
+
                <empty> (not available), mii, gmii, sgmii, tbi, rev-mii,
                rmii, rgmii, rgmii-id, rgmii-rxid, rgmii-txid, rtbi, smii
                xgmii, moca, qsgmii, trgmii, 1000base-x, 2500base-x, rxaui,
index ae1276efa45a2562866893abb49739d5997de474..847a7edc3113dd8d97d82bcc7e92ae0b1d32a488 100644 (file)
@@ -11,8 +11,11 @@ Contact:     linuxppc-dev@lists.ozlabs.org
 Description:   read only
                Number of contexts for the AFU, in the format <n>/<max>
                where:
-                       n:      number of currently active contexts, for debug
-                       max:    maximum number of contexts supported by the AFU
+
+                       ====    ===============================================
+                       n       number of currently active contexts, for debug
+                       max     maximum number of contexts supported by the AFU
+                       ====    ===============================================
 
 What:          /sys/class/ocxl/<afu name>/pp_mmio_size
 Date:          January 2018
@@ -40,7 +43,9 @@ Contact:      linuxppc-dev@lists.ozlabs.org
 Description:   read/write
                Control whether the FPGA is reloaded on a link reset. Enabled
                through a vendor-specific logic block on the FPGA.
-                       0       Do not reload FPGA image from flash
-                       1       Reload FPGA image from flash
-                       unavailable
-                               The device does not support this capability
+
+                       ===========  ===========================================
+                       0            Do not reload FPGA image from flash
+                       1            Reload FPGA image from flash
+                       unavailable  The device does not support this capability
+                       ===========  ===========================================
index dde4f26d0780e75e7c7397f0bfb8a4aa3cdbc2f6..ba1ce626591d9c4e666fea449075c44a3f447b17 100644 (file)
@@ -11,15 +11,17 @@ KernelVersion:      2.6.20
 Contact:       Thomas Maier <balagi@justmail.de>
 Description:
 
-               add:            (WO) Write a block device id (major:minor) to
+               ==========      ==============================================
+               add             (WO) Write a block device id (major:minor) to
                                create a new pktcdvd device and map it to the
                                block device.
 
-               remove:         (WO) Write the pktcdvd device id (major:minor)
+               remove          (WO) Write the pktcdvd device id (major:minor)
                                to remove the pktcdvd device.
 
-               device_map:     (RO) Shows the device mapping in format:
+               device_map      (RO) Shows the device mapping in format:
                                pktcdvd[0-7] <pktdevid> <blkdevid>
+               ==========      ==============================================
 
 
 What:          /sys/class/pktcdvd/pktcdvd[0-7]/dev
@@ -65,29 +67,31 @@ Date:               Oct. 2006
 KernelVersion: 2.6.20
 Contact:       Thomas Maier <balagi@justmail.de>
 Description:
-               size:           (RO) Contains the size of the bio write queue.
+               ==============  ================================================
+               size            (RO) Contains the size of the bio write queue.
 
-               congestion_off: (RW) If bio write queue size is below this mark,
+               congestion_off  (RW) If bio write queue size is below this mark,
                                accept new bio requests from the block layer.
 
-               congestion_on:  (RW) If bio write queue size is higher as this
+               congestion_on   (RW) If bio write queue size is higher as this
                                mark, do no longer accept bio write requests
                                from the block layer and wait till the pktcdvd
                                device has processed enough bio's so that bio
                                write queue size is below congestion off mark.
                                A value of <= 0 disables congestion control.
+               ==============  ================================================
 
 
 Example:
 --------
-To use the pktcdvd sysfs interface directly, you can do:
-
-# create a new pktcdvd device mapped to /dev/hdc
-echo "22:0" >/sys/class/pktcdvd/add
-cat /sys/class/pktcdvd/device_map
-# assuming device pktcdvd0 was created, look at stat's
-cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written
-# print the device id of the mapped block device
-fgrep pktcdvd0 /sys/class/pktcdvd/device_map
-# remove device, using pktcdvd0 device id   253:0
-echo "253:0" >/sys/class/pktcdvd/remove
+To use the pktcdvd sysfs interface directly, you can do::
+
+    # create a new pktcdvd device mapped to /dev/hdc
+    echo "22:0" >/sys/class/pktcdvd/add
+    cat /sys/class/pktcdvd/device_map
+    # assuming device pktcdvd0 was created, look at stat's
+    cat /sys/class/pktcdvd/pktcdvd0/stat/kb_written
+    # print the device id of the mapped block device
+    fgrep pktcdvd0 /sys/class/pktcdvd/device_map
+    # remove device, using pktcdvd0 device id   253:0
+    echo "253:0" >/sys/class/pktcdvd/remove
index dbccb2fcd7ce7c65e0416a9307a09e7ba0f2ca91..ca830c6cd8094b047522d6d672be73a7193c2826 100644 (file)
@@ -1,4 +1,4 @@
-===== General Properties =====
+**General Properties**
 
 What:          /sys/class/power_supply/<supply_name>/manufacturer
 Date:          May 2007
@@ -36,14 +36,238 @@ Description:
                Access: Read
                Valid values: "Battery", "UPS", "Mains", "USB", "Wireless"
 
-===== Battery Properties =====
+**Battery and USB properties**
+
+What:          /sys/class/power_supply/<supply_name>/current_avg
+Date:          May 2007
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports an average IBAT current reading for the battery, over
+                 a fixed period. Normally devices will provide a fixed interval
+                 in which they average readings to smooth out the reported
+                 value.
+
+               USB:
+
+                 Reports an average IBUS current reading over a fixed period.
+                 Normally devices will provide a fixed interval in which they
+                 average readings to smooth out the reported value.
+
+               Access: Read
+
+               Valid values: Represented in microamps. Negative values are
+               used for discharging batteries, positive values for charging
+               batteries and for USB IBUS current.
+
+What:          /sys/class/power_supply/<supply_name>/current_max
+Date:          October 2010
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the maximum IBAT current allowed into the battery.
+
+               USB:
+
+                 Reports the maximum IBUS current the supply can support.
+
+               Access: Read
+               Valid values: Represented in microamps
+
+What:          /sys/class/power_supply/<supply_name>/current_now
+Date:          May 2007
+Contact:       linux-pm@vger.kernel.org
+Description:
+
+               Battery:
+
+                 Reports an instant, single IBAT current reading for the
+                 battery. This value is not averaged/smoothed.
+
+                 Access: Read
+
+               USB:
+
+                 Reports the IBUS current supplied now. This value is generally
+                 read-only reporting, unless the 'online' state of the supply
+                 is set to be programmable, in which case this value can be set
+                 within the reported min/max range.
+
+                 Access: Read, Write
+
+               Valid values: Represented in microamps. Negative values are
+               used for discharging batteries, positive values for charging
+               batteries and for USB IBUS current.
+
+What:          /sys/class/power_supply/<supply_name>/temp
+Date:          May 2007
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the current TBAT battery temperature reading.
+
+               USB:
+
+                 Reports the current supply temperature reading. This would
+                 normally be the internal temperature of the device itself
+                 (e.g TJUNC temperature of an IC)
+
+               Access: Read
+
+               Valid values: Represented in 1/10 Degrees Celsius
+
+What:          /sys/class/power_supply/<supply_name>/temp_alert_max
+Date:          July 2012
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Maximum TBAT temperature trip-wire value where the supply will
+                 notify user-space of the event.
+
+               USB:
+
+                 Maximum supply temperature trip-wire value where the supply
+                 will notify user-space of the event.
+
+               This is normally used for the charging scenario where
+               user-space needs to know if the temperature has crossed an
+               upper threshold so it can take appropriate action (e.g. warning
+               user that the temperature is critically high, and charging has
+               stopped).
+
+               Access: Read
+
+               Valid values: Represented in 1/10 Degrees Celsius
+
+What:          /sys/class/power_supply/<supply_name>/temp_alert_min
+Date:          July 2012
+Contact:       linux-pm@vger.kernel.org
+Description:
+
+               Battery:
+
+                 Minimum TBAT temperature trip-wire value where the supply will
+                 notify user-space of the event.
+
+               USB:
+
+                 Minimum supply temperature trip-wire value where the supply
+                 will notify user-space of the event.
+
+               This is normally used for the charging scenario where user-space
+               needs to know if the temperature has crossed a lower threshold
+               so it can take appropriate action (e.g. warning user that
+               temperature level is high, and charging current has been
+               reduced accordingly to remedy the situation).
+
+               Access: Read
+
+               Valid values: Represented in 1/10 Degrees Celsius
+
+What:          /sys/class/power_supply/<supply_name>/temp_max
+Date:          July 2014
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the maximum allowed TBAT battery temperature for
+                 charging.
+
+               USB:
+
+                 Reports the maximum allowed supply temperature for operation.
+
+               Access: Read
+
+               Valid values: Represented in 1/10 Degrees Celsius
+
+What:          /sys/class/power_supply/<supply_name>/temp_min
+Date:          July 2014
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the minimum allowed TBAT battery temperature for
+                 charging.
+
+               USB:
+
+                 Reports the minimum allowed supply temperature for operation.
+
+               Access: Read
+
+               Valid values: Represented in 1/10 Degrees Celsius
+
+What:          /sys/class/power_supply/<supply_name>/voltage_max,
+Date:          January 2008
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the maximum safe VBAT voltage permitted for the
+                 battery, during charging.
+
+               USB:
+
+                 Reports the maximum VBUS voltage the supply can support.
+
+               Access: Read
+
+               Valid values: Represented in microvolts
+
+What:          /sys/class/power_supply/<supply_name>/voltage_min,
+Date:          January 2008
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports the minimum safe VBAT voltage permitted for the
+                 battery, during discharging.
+
+               USB:
+
+                 Reports the minimum VBUS voltage the supply can support.
+
+               Access: Read
+
+               Valid values: Represented in microvolts
+
+What:          /sys/class/power_supply/<supply_name>/voltage_now,
+Date:          May 2007
+Contact:       linux-pm@vger.kernel.org
+Description:
+               Battery:
+
+                 Reports an instant, single VBAT voltage reading for the
+                 battery. This value is not averaged/smoothed.
+
+                 Access: Read
+
+               USB:
+
+                 Reports the VBUS voltage supplied now. This value is generally
+                 read-only reporting, unless the 'online' state of the supply
+                 is set to be programmable, in which case this value can be set
+                 within the reported min/max range.
+
+                 Access: Read, Write
+
+               Valid values: Represented in microvolts
+
+**Battery Properties**
 
 What:          /sys/class/power_supply/<supply_name>/capacity
 Date:          May 2007
 Contact:       linux-pm@vger.kernel.org
 Description:
                Fine grain representation of battery capacity.
+
                Access: Read
+
                Valid values: 0 - 100 (percent)
 
 What:          /sys/class/power_supply/<supply_name>/capacity_alert_max
@@ -58,6 +282,7 @@ Description:
                low).
 
                Access: Read, Write
+
                Valid values: 0 - 100 (percent)
 
 What:          /sys/class/power_supply/<supply_name>/capacity_alert_min
@@ -72,6 +297,7 @@ Description:
                critically low).
 
                Access: Read, Write
+
                Valid values: 0 - 100 (percent)
 
 What:          /sys/class/power_supply/<supply_name>/capacity_error_margin
@@ -87,6 +313,7 @@ Description:
                completely useless.
 
                Access: Read
+
                Valid values: 0 - 100 (percent)
 
 What:          /sys/class/power_supply/<supply_name>/capacity_level
@@ -96,40 +323,10 @@ Description:
                Coarse representation of battery capacity.
 
                Access: Read
-               Valid values: "Unknown", "Critical", "Low", "Normal", "High",
-                             "Full"
-
-What:          /sys/class/power_supply/<supply_name>/current_avg
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports an average IBAT current reading for the battery, over a
-               fixed period. Normally devices will provide a fixed interval in
-               which they average readings to smooth out the reported value.
-
-               Access: Read
-               Valid values: Represented in microamps. Negative values are used
-               for discharging batteries, positive values for charging batteries.
 
-What:          /sys/class/power_supply/<supply_name>/current_max
-Date:          October 2010
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum IBAT current allowed into the battery.
-
-               Access: Read
-               Valid values: Represented in microamps
-
-What:          /sys/class/power_supply/<supply_name>/current_now
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports an instant, single IBAT current reading for the battery.
-               This value is not averaged/smoothed.
-
-               Access: Read
-               Valid values: Represented in microamps. Negative values are used
-               for discharging batteries, positive values for charging batteries.
+               Valid values:
+                             "Unknown", "Critical", "Low", "Normal", "High",
+                             "Full"
 
 What:          /sys/class/power_supply/<supply_name>/charge_control_limit
 Date:          Oct 2012
@@ -139,6 +336,7 @@ Description:
                throttling for thermal cooling or improving battery health.
 
                Access: Read, Write
+
                Valid values: Represented in microamps
 
 What:          /sys/class/power_supply/<supply_name>/charge_control_limit_max
@@ -148,6 +346,7 @@ Description:
                Maximum legal value for the charge_control_limit property.
 
                Access: Read
+
                Valid values: Represented in microamps
 
 What:          /sys/class/power_supply/<supply_name>/charge_control_start_threshold
@@ -168,6 +367,7 @@ Description:
                stop.
 
                Access: Read, Write
+
                Valid values: 0 - 100 (percent)
 
 What:          /sys/class/power_supply/<supply_name>/charge_type
@@ -183,7 +383,9 @@ Description:
                different algorithm.
 
                Access: Read, Write
-               Valid values: "Unknown", "N/A", "Trickle", "Fast", "Standard",
+
+               Valid values:
+                             "Unknown", "N/A", "Trickle", "Fast", "Standard",
                              "Adaptive", "Custom"
 
 What:          /sys/class/power_supply/<supply_name>/charge_term_current
@@ -194,6 +396,7 @@ Description:
                when the battery is considered full and charging should end.
 
                Access: Read
+
                Valid values: Represented in microamps
 
 What:          /sys/class/power_supply/<supply_name>/health
@@ -204,7 +407,9 @@ Description:
                functionality.
 
                Access: Read
-               Valid values: "Unknown", "Good", "Overheat", "Dead",
+
+               Valid values:
+                             "Unknown", "Good", "Overheat", "Dead",
                              "Over voltage", "Unspecified failure", "Cold",
                              "Watchdog timer expire", "Safety timer expire",
                              "Over current", "Calibration required", "Warm",
@@ -218,6 +423,7 @@ Description:
                for a battery charge cycle.
 
                Access: Read
+
                Valid values: Represented in microamps
 
 What:          /sys/class/power_supply/<supply_name>/present
@@ -227,9 +433,13 @@ Description:
                Reports whether a battery is present or not in the system.
 
                Access: Read
+
                Valid values:
+
+                       == =======
                        0: Absent
                        1: Present
+                       == =======
 
 What:          /sys/class/power_supply/<supply_name>/status
 Date:          May 2007
@@ -240,7 +450,9 @@ Description:
                used to enable/disable charging to the battery.
 
                Access: Read, Write
-               Valid values: "Unknown", "Charging", "Discharging",
+
+               Valid values:
+                             "Unknown", "Charging", "Discharging",
                              "Not charging", "Full"
 
 What:          /sys/class/power_supply/<supply_name>/technology
@@ -250,66 +462,11 @@ Description:
                Describes the battery technology supported by the supply.
 
                Access: Read
-               Valid values: "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe",
-                             "NiCd", "LiMn"
-
-What:          /sys/class/power_supply/<supply_name>/temp
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the current TBAT battery temperature reading.
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_alert_max
-Date:          July 2012
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Maximum TBAT temperature trip-wire value where the supply will
-               notify user-space of the event. This is normally used for the
-               battery charging scenario where user-space needs to know the
-               battery temperature has crossed an upper threshold so it can
-               take appropriate action (e.g. warning user that battery level is
-               critically high, and charging has stopped).
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_alert_min
-Date:          July 2012
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Minimum TBAT temperature trip-wire value where the supply will
-               notify user-space of the event. This is normally used for the
-               battery charging scenario where user-space needs to know the
-               battery temperature has crossed a lower threshold so it can take
-               appropriate action (e.g. warning user that battery level is
-               high, and charging current has been reduced accordingly to
-               remedy the situation).
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_max
-Date:          July 2014
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum allowed TBAT battery temperature for
-               charging.
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
 
-What:          /sys/class/power_supply/<supply_name>/temp_min
-Date:          July 2014
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the minimum allowed TBAT battery temperature for
-               charging.
+               Valid values:
+                             "Unknown", "NiMH", "Li-ion", "Li-poly", "LiFe",
+                             "NiCd", "LiMn"
 
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
 
 What:          /sys/class/power_supply/<supply_name>/voltage_avg,
 Date:          May 2007
@@ -320,72 +477,10 @@ Description:
                which they average readings to smooth out the reported value.
 
                Access: Read
-               Valid values: Represented in microvolts
-
-What:          /sys/class/power_supply/<supply_name>/voltage_max,
-Date:          January 2008
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum safe VBAT voltage permitted for the battery,
-               during charging.
-
-               Access: Read
-               Valid values: Represented in microvolts
-
-What:          /sys/class/power_supply/<supply_name>/voltage_min,
-Date:          January 2008
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the minimum safe VBAT voltage permitted for the battery,
-               during discharging.
 
-               Access: Read
                Valid values: Represented in microvolts
 
-What:          /sys/class/power_supply/<supply_name>/voltage_now,
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports an instant, single VBAT voltage reading for the battery.
-               This value is not averaged/smoothed.
-
-               Access: Read
-               Valid values: Represented in microvolts
-
-===== USB Properties =====
-
-What:          /sys/class/power_supply/<supply_name>/current_avg
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports an average IBUS current reading over a fixed period.
-               Normally devices will provide a fixed interval in which they
-               average readings to smooth out the reported value.
-
-               Access: Read
-               Valid values: Represented in microamps
-
-
-What:          /sys/class/power_supply/<supply_name>/current_max
-Date:          October 2010
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum IBUS current the supply can support.
-
-               Access: Read
-               Valid values: Represented in microamps
-
-What:          /sys/class/power_supply/<supply_name>/current_now
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the IBUS current supplied now. This value is generally
-               read-only reporting, unless the 'online' state of the supply
-               is set to be programmable, in which case this value can be set
-               within the reported min/max range.
-
-               Access: Read, Write
-               Valid values: Represented in microamps
+**USB Properties**
 
 What:          /sys/class/power_supply/<supply_name>/input_current_limit
 Date:          July 2014
@@ -399,6 +494,7 @@ Description:
                solved using power limit use input_current_limit.
 
                Access: Read, Write
+
                Valid values: Represented in microamps
 
 What:          /sys/class/power_supply/<supply_name>/input_voltage_limit
@@ -416,6 +512,7 @@ Description:
                solved using power limit use input_voltage_limit.
 
                Access: Read, Write
+
                Valid values: Represented in microvolts
 
 What:          /sys/class/power_supply/<supply_name>/input_power_limit
@@ -429,6 +526,7 @@ Description:
                limit only for problems that can be solved using power limit.
 
                Access: Read, Write
+
                Valid values: Represented in microwatts
 
 What:          /sys/class/power_supply/<supply_name>/online,
@@ -441,69 +539,14 @@ Description:
                USB supply so voltage and current can be controlled).
 
                Access: Read, Write
+
                Valid values:
+
+                       == ==================================================
                        0: Offline
                        1: Online Fixed - Fixed Voltage Supply
                        2: Online Programmable - Programmable Voltage Supply
-
-What:          /sys/class/power_supply/<supply_name>/temp
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the current supply temperature reading. This would
-               normally be the internal temperature of the device itself (e.g
-               TJUNC temperature of an IC)
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_alert_max
-Date:          July 2012
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Maximum supply temperature trip-wire value where the supply will
-               notify user-space of the event. This is normally used for the
-               charging scenario where user-space needs to know the supply
-               temperature has crossed an upper threshold so it can take
-               appropriate action (e.g. warning user that the supply
-               temperature is critically high, and charging has stopped to
-               remedy the situation).
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_alert_min
-Date:          July 2012
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Minimum supply temperature trip-wire value where the supply will
-               notify user-space of the event. This is normally used for the
-               charging scenario where user-space needs to know the supply
-               temperature has crossed a lower threshold so it can take
-               appropriate action (e.g. warning user that the supply
-               temperature is high, and charging current has been reduced
-               accordingly to remedy the situation).
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_max
-Date:          July 2014
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum allowed supply temperature for operation.
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
-
-What:          /sys/class/power_supply/<supply_name>/temp_min
-Date:          July 2014
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the mainimum allowed supply temperature for operation.
-
-               Access: Read
-               Valid values: Represented in 1/10 Degrees Celsius
+                       == ==================================================
 
 What:          /sys/class/power_supply/<supply_name>/usb_type
 Date:          March 2018
@@ -514,40 +557,12 @@ Description:
                is attached.
 
                Access: Read-Only
-               Valid values: "Unknown", "SDP", "DCP", "CDP", "ACA", "C", "PD",
-                             "PD_DRP", "PD_PPS", "BrickID"
-
-What:          /sys/class/power_supply/<supply_name>/voltage_max
-Date:          January 2008
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the maximum VBUS voltage the supply can support.
-
-               Access: Read
-               Valid values: Represented in microvolts
-
-What:          /sys/class/power_supply/<supply_name>/voltage_min
-Date:          January 2008
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the minimum VBUS voltage the supply can support.
 
-               Access: Read
-               Valid values: Represented in microvolts
-
-What:          /sys/class/power_supply/<supply_name>/voltage_now
-Date:          May 2007
-Contact:       linux-pm@vger.kernel.org
-Description:
-               Reports the VBUS voltage supplied now. This value is generally
-               read-only reporting, unless the 'online' state of the supply
-               is set to be programmable, in which case this value can be set
-               within the reported min/max range.
-
-               Access: Read, Write
-               Valid values: Represented in microvolts
+               Valid values:
+                             "Unknown", "SDP", "DCP", "CDP", "ACA", "C", "PD",
+                             "PD_DRP", "PD_PPS", "BrickID"
 
-===== Device Specific Properties =====
+**Device Specific Properties**
 
 What:          /sys/class/power/ds2760-battery.*/charge_now
 Date:          May 2010
@@ -581,6 +596,7 @@ Description:
                will drop to 0 A) and will trigger interrupt.
 
                Valid values:
+
                - 5, 6 or 7 (hours),
                - 0: disabled.
 
@@ -595,6 +611,7 @@ Description:
                will drop to 0 A) and will trigger interrupt.
 
                Valid values:
+
                - 4 - 16 (hours), step by 2 (rounded down)
                - 0: disabled.
 
@@ -609,6 +626,7 @@ Description:
                interrupt and start top-off charging mode.
 
                Valid values:
+
                - 100000 - 200000 (microamps), step by 25000 (rounded down)
                - 200000 - 350000 (microamps), step by 50000 (rounded down)
                - 0: disabled.
@@ -624,6 +642,7 @@ Description:
                will drop to 0 A) and will trigger interrupt.
 
                Valid values:
+
                - 0 - 70 (minutes), step by 10 (rounded down)
 
 What:          /sys/class/power_supply/bq24257-charger/ovp_voltage
@@ -637,6 +656,7 @@ Description:
                device datasheet for details.
 
                Valid values:
+
                - 6000000, 6500000, 7000000, 8000000, 9000000, 9500000, 10000000,
                  10500000 (all uV)
 
@@ -652,6 +672,7 @@ Description:
                lower than the set value. See device datasheet for details.
 
                Valid values:
+
                - 4200000, 4280000, 4360000, 4440000, 4520000, 4600000, 4680000,
                  4760000 (all uV)
 
@@ -666,6 +687,7 @@ Description:
                the charger operates normally. See device datasheet for details.
 
                Valid values:
+
                - 1: enabled
                - 0: disabled
 
@@ -681,6 +703,7 @@ Description:
                from the system. See device datasheet for details.
 
                Valid values:
+
                - 1: enabled
                - 0: disabled
 
@@ -692,6 +715,7 @@ Description:
                manufactured.
 
                Access: Read
+
                Valid values: Reported as integer
 
 What:          /sys/class/power_supply/<supply_name>/manufacture_month
@@ -701,6 +725,7 @@ Description:
                Reports the month when the device has been manufactured.
 
                Access: Read
+
                Valid values: 1-12
 
 What:          /sys/class/power_supply/<supply_name>/manufacture_day
index 327a07e22805ba6888fa4d24655325d6a5051cad..914d67caac0d79e3fd9e6f4ea192d1f55dacf53a 100644 (file)
@@ -5,4 +5,5 @@ Description:
                Represents a battery impedance compensation to accelerate charging.
 
                 Access: Read, Write
+
                 Valid values: Represented in milli-ohms. Valid range is [0, 140].
index b4fd32d210c55261dfba8af264e8755314876037..b52f7023f8ba0123334e14c3f920c64d3304e786 100644 (file)
@@ -4,18 +4,20 @@ Description:
        Writing to this can disable charging.
 
        Possible values are:
-               "auto" - draw power as appropriate for detected
-                        power source and battery status.
-               "off"  - do not draw any power.
-               "continuous"
-                      - activate mode described as "linear" in
-                        TWL data sheets.  This uses whatever
-                        current is available and doesn't switch off
-                        when voltage drops.
 
-                        This is useful for unstable power sources
-                        such as bicycle dynamo, but care should
-                        be taken that battery is not over-charged.
+               =============   ===========================================
+               "auto"          draw power as appropriate for detected
+                               power source and battery status.
+               "off"           do not draw any power.
+               "continuous"    activate mode described as "linear" in
+                               TWL data sheets.  This uses whatever
+                               current is available and doesn't switch off
+                               when voltage drops.
+
+                               This is useful for unstable power sources
+                               such as bicycle dynamo, but care should
+                               be taken that battery is not over-charged.
+               =============   ===========================================
 
 What: /sys/class/power_supply/twl4030_ac/mode
 Description:
@@ -23,6 +25,9 @@ Description:
        Writing to this can disable charging.
 
        Possible values are:
-               "auto" - draw power as appropriate for detected
-                        power source and battery status.
-               "off"  - do not draw any power.
+
+               ======  ===========================================
+               "auto"  draw power as appropriate for detected
+                       power source and battery status.
+               "off"   do not draw any power.
+               ======  ===========================================
index 84fde1d0ada065e1fd972acaea4eef4d8c4b7b73..82af180fcaab991056bf3f3218ee03ab4bb840c7 100644 (file)
@@ -4,17 +4,23 @@ KernelVersion:        5.2
 Description:
                What charging algorithm to use:
 
-               Standard: Fully charges battery at a standard rate.
-               Adaptive: Battery settings adaptively optimized based on
+               Standard:
+                       Fully charges battery at a standard rate.
+               Adaptive:
+                       Battery settings adaptively optimized based on
                        typical battery usage pattern.
-               Fast: Battery charges over a shorter period.
-               Trickle: Extends battery lifespan, intended for users who
+               Fast:
+                       Battery charges over a shorter period.
+               Trickle:
+                       Extends battery lifespan, intended for users who
                        primarily use their Chromebook while connected to AC.
-               Custom: A low and high threshold percentage is specified.
+               Custom:
+                       A low and high threshold percentage is specified.
                        Charging begins when level drops below
                        charge_control_start_threshold, and ceases when
                        level is above charge_control_end_threshold.
-               Long Life: Customized charge rate for last longer battery life.
+               Long Life:
+                       Customized charge rate for last longer battery life.
                        On Wilco device this mode is pre-configured in the factory
                        through EC's private PID. Swiching to a different mode will
                        be denied by Wilco EC when Long Life mode is enabled.
index 8716beeb16c16cbb401a68999de909e32a5efc01..19aefb21b639dd1cd607008ee61b59c7d174692a 100644 (file)
@@ -6,6 +6,7 @@ Description:
                The /sys/class/rapidio_port subdirectory contains individual
                subdirectories named as "rapidioN" where N = mport ID registered
                with RapidIO subsystem.
+
                NOTE: An mport ID is not a RapidIO destination ID assigned to a
                given local mport device.
 
@@ -16,7 +17,9 @@ Contact:      Matt Porter <mporter@kernel.crashing.org>,
                Alexandre Bounine <alexandre.bounine@idt.com>
 Description:
                (RO) reports RapidIO common transport system size:
+
                0 = small (8-bit destination ID, max. 256 devices),
+
                1 = large (16-bit destination ID, max. 65536 devices).
 
 What:          /sys/class/rapidio_port/rapidioN/port_destid
@@ -25,31 +28,32 @@ KernelVersion:      v3.15
 Contact:       Matt Porter <mporter@kernel.crashing.org>,
                Alexandre Bounine <alexandre.bounine@idt.com>
 Description:
-               (RO) reports RapidIO destination ID assigned to the given
-               RapidIO mport device. If value 0xFFFFFFFF is returned this means
-               that no valid destination ID have been assigned to the mport
-               (yet). Normally, before enumeration/discovery have been executed
-               only fabric enumerating mports have a valid destination ID
-               assigned to them using "hdid=..." rapidio module parameter.
+
+(RO) reports RapidIO destination ID assigned to the given
+RapidIO mport device. If value 0xFFFFFFFF is returned this means
+that no valid destination ID have been assigned to the mport
+(yet). Normally, before enumeration/discovery have been executed
+only fabric enumerating mports have a valid destination ID
+assigned to them using "hdid=..." rapidio module parameter.
 
 After enumeration or discovery was performed for a given mport device,
 the corresponding subdirectory will also contain subdirectories for each
 child RapidIO device connected to the mport.
 
 The example below shows mport device subdirectory with several child RapidIO
-devices attached to it.
-
-[rio@rapidio ~]$ ls /sys/class/rapidio_port/rapidio0/ -l
-total 0
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0001
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0004
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0007
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0002
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0003
-drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0005
-lrwxrwxrwx 1 root root    0 Feb 11 15:11 device -> ../../../0000:01:00.0
--r--r--r-- 1 root root 4096 Feb 11 15:11 port_destid
-drwxr-xr-x 2 root root    0 Feb 11 15:11 power
-lrwxrwxrwx 1 root root    0 Feb 11 15:04 subsystem -> ../../../../../../class/rapidio_port
--r--r--r-- 1 root root 4096 Feb 11 15:11 sys_size
--rw-r--r-- 1 root root 4096 Feb 11 15:04 uevent
+devices attached to it::
+
+    [rio@rapidio ~]$ ls /sys/class/rapidio_port/rapidio0/ -l
+    total 0
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0001
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0004
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:e:0007
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0002
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0003
+    drwxr-xr-x 3 root root    0 Feb 11 15:10 00:s:0005
+    lrwxrwxrwx 1 root root    0 Feb 11 15:11 device -> ../../../0000:01:00.0
+    -r--r--r-- 1 root root 4096 Feb 11 15:11 port_destid
+    drwxr-xr-x 2 root root    0 Feb 11 15:11 power
+    lrwxrwxrwx 1 root root    0 Feb 11 15:04 subsystem -> ../../../../../../class/rapidio_port
+    -r--r--r-- 1 root root 4096 Feb 11 15:11 sys_size
+    -rw-r--r-- 1 root root 4096 Feb 11 15:04 uevent
index 6c0d6c8cb91105779324b78efe4d3c12bb191316..9c8ff79108583f90ebedf3d493fd22b8807142e9 100644 (file)
@@ -21,15 +21,22 @@ KernelVersion:      2.6.36
 Contact:       Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
 Description:
                Reading this file returns a list of available protocols,
-               something like:
+               something like::
+
                    "rc5 [rc6] nec jvc [sony]"
+
                Enabled protocols are shown in [] brackets.
+
                Writing "+proto" will add a protocol to the list of enabled
                protocols.
+
                Writing "-proto" will remove a protocol from the list of enabled
                protocols.
+
                Writing "proto" will enable only "proto".
+
                Writing "none" will disable all protocols.
+
                Write fails with EINVAL if an invalid protocol combination or
                unknown protocol name is used.
 
@@ -39,11 +46,13 @@ KernelVersion:      3.15
 Contact:       Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
 Description:
                Sets the scancode filter expected value.
+
                Use in combination with /sys/class/rc/rcN/filter_mask to set the
                expected value of the bits set in the filter mask.
                If the hardware supports it then scancodes which do not match
                the filter will be ignored. Otherwise the write will fail with
                an error.
+
                This value may be reset to 0 if the current protocol is altered.
 
 What:          /sys/class/rc/rcN/filter_mask
@@ -56,9 +65,11 @@ Description:
                of the scancode which should be compared against the expected
                value. A value of 0 disables the filter to allow all valid
                scancodes to be processed.
+
                If the hardware supports it then scancodes which do not match
                the filter will be ignored. Otherwise the write will fail with
                an error.
+
                This value may be reset to 0 if the current protocol is altered.
 
 What:          /sys/class/rc/rcN/wakeup_protocols
@@ -67,15 +78,22 @@ KernelVersion:      4.11
 Contact:       Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
 Description:
                Reading this file returns a list of available protocols to use
-               for the wakeup filter, something like:
+               for the wakeup filter, something like::
+
                    "rc-5 nec nec-x rc-6-0 rc-6-6a-24 [rc-6-6a-32] rc-6-mce"
+
                Note that protocol variants are listed, so "nec", "sony",
                "rc-5", "rc-6" have their different bit length encodings
                listed if available.
+
                The enabled wakeup protocol is shown in [] brackets.
+
                Only one protocol can be selected at a time.
+
                Writing "proto" will use "proto" for wakeup events.
+
                Writing "none" will disable wakeup.
+
                Write fails with EINVAL if an invalid protocol combination or
                unknown protocol name is used, or if wakeup is not supported by
                the hardware.
@@ -86,13 +104,17 @@ KernelVersion:     3.15
 Contact:       Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
 Description:
                Sets the scancode wakeup filter expected value.
+
                Use in combination with /sys/class/rc/rcN/wakeup_filter_mask to
                set the expected value of the bits set in the wakeup filter mask
                to trigger a system wake event.
+
                If the hardware supports it and wakeup_filter_mask is not 0 then
                scancodes which match the filter will wake the system from e.g.
                suspend to RAM or power off.
+
                Otherwise the write will fail with an error.
+
                This value may be reset to 0 if the wakeup protocol is altered.
 
 What:          /sys/class/rc/rcN/wakeup_filter_mask
@@ -101,11 +123,15 @@ KernelVersion:    3.15
 Contact:       Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
 Description:
                Sets the scancode wakeup filter mask of bits to compare.
+
                Use in combination with /sys/class/rc/rcN/wakeup_filter to set
                the bits of the scancode which should be compared against the
                expected value to trigger a system wake event.
+
                If the hardware supports it and wakeup_filter_mask is not 0 then
                scancodes which match the filter will wake the system from e.g.
                suspend to RAM or power off.
+
                Otherwise the write will fail with an error.
+
                This value may be reset to 0 if the wakeup protocol is altered.
index bc578bc606284bf248fe87169e8cda0dbdfa4f3a..8516f08806dd992b04841d48d4ec55410d9189fb 100644 (file)
@@ -35,13 +35,13 @@ Description:
 
                This will be one of the following strings:
 
-                       off
-                       on
-                       error
-                       fast
-                       normal
-                       idle
-                       standby
+                       off
+                       on
+                       error
+                       fast
+                       normal
+                       idle
+                       standby
 
                "off" means the regulator is not supplying power to the
                system.
@@ -74,9 +74,9 @@ Description:
 
                This will be one of the following strings:
 
-               'voltage'
-               'current'
-               'unknown'
+               'voltage'
+               'current'
+               'unknown'
 
                'voltage' means the regulator output voltage can be controlled
                by software.
@@ -129,11 +129,11 @@ Description:
 
                The opmode value can be one of the following strings:
 
-               'fast'
-               'normal'
-               'idle'
-               'standby'
-               'unknown'
+               'fast'
+               'normal'
+               'idle'
+               'standby'
+               'unknown'
 
                The modes are described in include/linux/regulator/consumer.h
 
@@ -360,9 +360,9 @@ Description:
 
                This will be one of the following strings:
 
-               'enabled'
-               'disabled'
-               'unknown'
+               'enabled'
+               'disabled'
+               'unknown'
 
                'enabled' means the regulator is in bypass mode.
 
index 066b9b6f4924d76b8b116684dd8def5f030d7beb..0c9ee55098b8200138fcc57bed8d29391c1be63b 100644 (file)
@@ -16,11 +16,11 @@ Description:        Remote processor state
 
                Reports the state of the remote processor, which will be one of:
 
-               "offline"
-               "suspended"
-               "running"
-               "crashed"
-               "invalid"
+               "offline"
+               "suspended"
+               "running"
+               "crashed"
+               "invalid"
 
                "offline" means the remote processor is powered off.
 
@@ -38,8 +38,8 @@ Description:  Remote processor state
                Writing this file controls the state of the remote processor.
                The following states can be written:
 
-               "start"
-               "stop"
+               "start"
+               "stop"
 
                Writing "start" will attempt to start the processor running the
                firmware indicated by, or written to,
index c084f203b41ed7903ad29ac7046052a76a2da052..00c0286733d48c2cf845cb169697e8e7994d6bd2 100644 (file)
@@ -5,62 +5,70 @@ Contact:      Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud
 Description:   Provide information about RNBD-client.
                All sysfs files that are not read-only provide the usage information on read:
 
-               Example:
-               # cat /sys/class/rnbd-client/ctl/map_device
+               Example::
 
-               > Usage: echo "sessname=<name of the rtrs session> path=<[srcaddr,]dstaddr>
-               > [path=<[srcaddr,]dstaddr>] device_path=<full path on remote side>
-               > [access_mode=<ro|rw|migration>] > map_device
-               >
-               > addr ::= [ ip:<ipv4> | ip:<ipv6> | gid:<gid> ]
+                   # cat /sys/class/rnbd-client/ctl/map_device
+
+                   > Usage: echo "sessname=<name of the rtrs session> path=<[srcaddr,]dstaddr>
+                   > [path=<[srcaddr,]dstaddr>] device_path=<full path on remote side>
+                   > [access_mode=<ro|rw|migration>] > map_device
+                   >
+                   > addr ::= [ ip:<ipv4> | ip:<ipv6> | gid:<gid> ]
 
 What:          /sys/class/rnbd-client/ctl/map_device
 Date:          Feb 2020
 KernelVersion: 5.7
 Contact:       Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
-Description:   Expected format is the following:
+Description:   Expected format is the following::
 
-               sessname=<name of the rtrs session>
-               path=<[srcaddr,]dstaddr> [path=<[srcaddr,]dstaddr> ...]
-               device_path=<full path on remote side>
-               [access_mode=<ro|rw|migration>]
+                   sessname=<name of the rtrs session>
+                   path=<[srcaddr,]dstaddr> [path=<[srcaddr,]dstaddr> ...]
+                   device_path=<full path on remote side>
+                   [access_mode=<ro|rw|migration>]
 
                Where:
 
-               sessname: accepts a string not bigger than 256 chars, which identifies
-               a given session on the client and on the server.
-               I.e. "clt_hostname-srv_hostname" could be a natural choice.
+               sessname:
+                   accepts a string not bigger than 256 chars, which identifies
+                   a given session on the client and on the server.
+                   I.e. "clt_hostname-srv_hostname" could be a natural choice.
+
+               path:
+                   describes a connection between the client and the server by
+                   specifying destination and, when required, the source address.
+                   The addresses are to be provided in the following format::
 
-               path:     describes a connection between the client and the server by
-               specifying destination and, when required, the source address.
-               The addresses are to be provided in the following format:
+                       ip:<IPv6>
+                       ip:<IPv4>
+                       gid:<GID>
 
-               ip:<IPv6>
-               ip:<IPv4>
-               gid:<GID>
+               for example::
 
-               for example:
+                   path=ip:10.0.0.66
 
-               path=ip:10.0.0.66
                The single addr is treated as the destination.
                The connection will be established to this server from any client IP address.
 
-               path=ip:10.0.0.66,ip:10.0.1.66
+               ::
+
+                   path=ip:10.0.0.66,ip:10.0.1.66
+
                First addr is the source address and the second is the destination.
 
                If multiple "path=" options are specified multiple connection
                will be established and data will be sent according to
                the selected multipath policy (see RTRS mp_policy sysfs entry description).
 
-               device_path: Path to the block device on the server side. Path is specified
-               relative to the directory on server side configured in the
-               'dev_search_path' module parameter of the rnbd_server.
-               The rnbd_server prepends the <device_path> received from client
-               with <dev_search_path> and tries to open the
-               <dev_search_path>/<device_path> block device.  On success,
-               a /dev/rnbd<N> device file, a /sys/block/rnbd_client/rnbd<N>/
-               directory and an entry in /sys/class/rnbd-client/ctl/devices
-               will be created.
+               device_path:
+                   Path to the block device on the server side. Path is specified
+                   relative to the directory on server side configured in the
+                   'dev_search_path' module parameter of the rnbd_server.
+                   The rnbd_server prepends the <device_path> received from client
+                   with <dev_search_path> and tries to open the
+                   <dev_search_path>/<device_path> block device.  On success,
+                   a /dev/rnbd<N> device file, a /sys/block/rnbd_client/rnbd<N>/
+                   directory and an entry in /sys/class/rnbd-client/ctl/devices
+                   will be created.
 
                If 'dev_search_path' contains '%SESSNAME%', then each session can
                have different devices namespace, e.g. server was configured with
@@ -68,11 +76,12 @@ Description:        Expected format is the following:
                client has this string "sessname=blya device_path=sda", then server
                will try to open: /run/rnbd-devs/blya/sda.
 
-               access_mode: the access_mode parameter specifies if the device is to be
-               mapped as "ro" read-only or "rw" read-write. The server allows
-               a device to be exported in rw mode only once. The "migration"
-               access mode has to be specified if a second mapping in read-write
-               mode is desired.
+               access_mode:
+                   the access_mode parameter specifies if the device is to be
+                   mapped as "ro" read-only or "rw" read-write. The server allows
+                   a device to be exported in rw mode only once. The "migration"
+                   access mode has to be specified if a second mapping in read-write
+                   mode is desired.
 
                By default "rw" is used.
 
@@ -91,7 +100,7 @@ Description: Expected format is the following:
                is the same as the device name.  By extracting the last part of the
                path the path to the device /dev/<dev-name> can be build.
 
-               o /dev/block/$(cat /sys/class/rnbd-client/ctl/devices/<device_id>/dev)
+               * /dev/block/$(cat /sys/class/rnbd-client/ctl/devices/<device_id>/dev)
 
                How to find the <device_id> of the device is described on the next
                section.
@@ -106,6 +115,6 @@ Description:        For each device mapped on the client a new symbolic link is created
                The <device_id> of each device is created as follows:
 
                - If the 'device_path' provided during mapping contains slashes ("/"),
-               they are replaced by exclamation mark ("!") and used as as the
-               <device_id>. Otherwise, the <device_id> will be the same as the
-               "device_path" provided.
+                 they are replaced by exclamation mark ("!") and used as as the
+                 <device_id>. Otherwise, the <device_id> will be the same as the
+                 "device_path" provided.
index ec950c93e5c6998daf2ee497732f732a2182ec25..ee8ed6494a014b2237389018f86a737866011965 100644 (file)
@@ -7,6 +7,7 @@ Description:    Attribute for calibrating ST-Ericsson AB8500 Real Time Clock
                 calibrate the AB8500.s 32KHz Real Time Clock.
                 Every 60 seconds the AB8500 will correct the RTC's value
                 by adding to it the value of this attribute.
+
                 The range of the attribute is -127 to +127 in units of
                 30.5 micro-seconds (half-parts-per-million of the 32KHz clock)
 Users:          The /vendor/st-ericsson/base_utilities/core/rtc_calibration
index e7e718db8941f25c18cb7a34d23ea7a75c3ca01e..0f7165aab25126de4fd4839943418cdae96b0d95 100644 (file)
@@ -10,10 +10,10 @@ Date:               Feb 2020
 KernelVersion: 5.7
 Contact:       Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
 Description:   RW, adds a new path (connection) to an existing session. Expected format is the
-               following:
+               following::
 
-               <[source addr,]destination addr>
-               *addr ::= [ ip:<ipv4|ipv6> | gid:<gid> ]
+                   <[source addr,]destination addr>
+                   *addr ::= [ ip:<ipv4|ipv6> | gid:<gid> ]
 
 What:          /sys/class/rtrs-client/<session-name>/max_reconnect_attempts
 Date:          Feb 2020
@@ -29,10 +29,10 @@ Contact:    Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud
 Description:   Multipath policy specifies which path should be selected on each IO:
 
                round-robin (0):
-               select path in per CPU round-robin manner.
+                   select path in per CPU round-robin manner.
 
                min-inflight (1):
-               select path with minimum inflights.
+                   select path with minimum inflights.
 
 What:          /sys/class/rtrs-client/<session-name>/paths/
 Date:          Feb 2020
@@ -109,8 +109,11 @@ Description:       RTRS expects that each HCA IRQ is pinned to a separate CPU. If it's
                not the case, the processing of an I/O response could be processed on a
                different CPU than where it was originally submitted.  This file shows
                how many interrupts where generated on a non expected CPU.
-               "from:" is the CPU on which the IRQ was expected, but not generated.
-               "to:" is the CPU on which the IRQ was generated, but not expected.
+
+               "from:"
+                   is the CPU on which the IRQ was expected, but not generated.
+               "to:"
+                   is the CPU on which the IRQ was generated, but not expected.
 
 What:          /sys/class/rtrs-client/<session-name>/paths/<src@dst>/stats/reconnects
 Date:          Feb 2020
@@ -125,7 +128,7 @@ Date:               Feb 2020
 KernelVersion: 5.7
 Contact:       Jack Wang <jinpu.wang@cloud.ionos.com> Danil Kipnis <danil.kipnis@cloud.ionos.com>
 Description:   Contains statistics regarding rdma operations and inflight operations.
-               The output consists of 6 values:
+               The output consists of 6 values::
 
-               <read-count> <read-total-size> <write-count> <write-total-size> \
-               <inflights> <failovered>
+                   <read-count> <read-total-size> <write-count> \
+                   <write-total-size> <inflights> <failovered>
index bafc59fd7b69ec355d6631681e3471195b0ae5ca..7c98d8f43c4562904d153e5b63e607ea31f52a8a 100644 (file)
@@ -56,8 +56,9 @@ Description:
                management) on top, which makes it match the Windows IRST (Intel
                Rapid Storage Technology) driver settings. This setting is also
                close to min_power, except that:
+
                a) It does not use host-initiated slumber mode, but it does
-               allow device-initiated slumber
+                  allow device-initiated slumber
                b) It does not enable low power device sleep mode (DevSlp).
 
 What:          /sys/class/scsi_host/hostX/em_message
@@ -70,8 +71,8 @@ Description:
                protocol, writes and reads correspond to the LED message format
                as defined in the AHCI spec.
 
-               The user must turn sw_activity (under /sys/block/*/device/) OFF
-               it they wish to control the activity LED via the em_message
+               The user must turn sw_activity (under `/sys/block/*/device/`)
+               OFF it they wish to control the activity LED via the em_message
                file.
 
                em_message_type: (RO) Displays the current enclosure management
index b834671522d6f98c76a66981c2e9ef36693ad82b..b7794e02ad205626582a693b3ebd7800e402eb8c 100644 (file)
@@ -40,10 +40,13 @@ Description:
                attribute will not return until the operation has finished.
 
                Valid values:
-               - source (The port will behave as source only DFP port)
-               - sink (The port will behave as sink only UFP port)
-               - dual (The port will behave as dual-role-data and
+
+               ======  ==============================================
+               source  (The port will behave as source only DFP port)
+               sink    (The port will behave as sink only UFP port)
+               dual    (The port will behave as dual-role-data and
                        dual-role-power port)
+               ======  ==============================================
 
 What:          /sys/class/typec/<port>/vconn_source
 Date:          April 2017
@@ -59,6 +62,7 @@ Description:
                generates uevent KOBJ_CHANGE.
 
                Valid values:
+
                - "no" when the port is not the VCONN Source
                - "yes" when the port is the VCONN Source
 
@@ -72,6 +76,7 @@ Description:
                power operation mode should show "usb_power_delivery".
 
                Valid values:
+
                - default
                - 1.5A
                - 3.0A
@@ -191,6 +196,7 @@ Date:               April 2017
 Contact:       Heikki Krogerus <heikki.krogerus@linux.intel.com>
 Description:
                Shows type of the plug on the cable:
+
                - type-a - Standard A
                - type-b - Standard B
                - type-c
index a0578751c1e38c475c18dfd183b66e2c7844e0ad..6c5dcad21e198ceca1471c350b3f5074d4302ad8 100644 (file)
@@ -66,11 +66,14 @@ Description:
                 <channel> <type> [<bpst offset>]
 
                 to start (or stop) scanning on a channel.  <type> is one of:
-                    0 - scan
-                    1 - scan outside BP
-                    2 - scan while inactive
-                    3 - scanning disabled
-                    4 - scan (with start time of <bpst offset>)
+
+                  ==   =======================================
+                    0   scan
+                    1   scan outside BP
+                    2   scan while inactive
+                    3   scanning disabled
+                    4   scan (with start time of <bpst offset>)
+                  ==   =======================================
 
 What:           /sys/class/uwb_rc/uwbN/mac_address
 Date:           July 2008
index 9860a8b2ba7504422d8e2e3e5b0e5a402026d742..585caecda3a5fc3a533360eea7ac95589b9c2545 100644 (file)
@@ -91,10 +91,13 @@ Description:
                h/w strapping (for WDT2 only).
 
                At alternate flash the 'access_cs0' sysfs node provides:
-                       ast2400: a way to get access to the primary SPI flash
+
+                       ast2400:
+                               a way to get access to the primary SPI flash
                                chip at CS0 after booting from the alternate
                                chip at CS1.
-                       ast2500: a way to restore the normal address mapping
+                       ast2500:
+                               a way to restore the normal address mapping
                                from (CS0->CS1, CS1->CS0) to (CS0->CS0,
                                CS1->CS1).
 
index a9f2b8b0530fb193be12ccfb7d0a529bf0ba435d..d1739063e762914c6012eb122809a7eac30ef266 100644 (file)
@@ -9,9 +9,10 @@ Description:   The /sys/dev tree provides a method to look up the sysfs
                the form "<major>:<minor>".  These links point to the
                corresponding sysfs path for the given device.
 
-               Example:
-               $ readlink /sys/dev/block/8:32
-               ../../block/sdc
+               Example::
+
+                 $ readlink /sys/dev/block/8:32
+                 ../../block/sdc
 
                Entries in /sys/dev/char and /sys/dev/block will be
                dynamically created and destroyed as devices enter and
index 490ccfd67f125a005cc411bda7496018938691e3..8d202bac9394ad06c2e7792081b562d8deb52287 100644 (file)
@@ -8,26 +8,27 @@ Description:
                 block.
                 For example, on 4-die Xeon platform with up to 6 IIO stacks per
                 die and, therefore, 6 IIO PMON blocks per die, the mapping of
-                IIO PMON block 0 exposes as the following:
+                IIO PMON block 0 exposes as the following::
 
-                $ ls /sys/devices/uncore_iio_0/die*
-                -r--r--r-- /sys/devices/uncore_iio_0/die0
-                -r--r--r-- /sys/devices/uncore_iio_0/die1
-                -r--r--r-- /sys/devices/uncore_iio_0/die2
-                -r--r--r-- /sys/devices/uncore_iio_0/die3
+                   $ ls /sys/devices/uncore_iio_0/die*
+                   -r--r--r-- /sys/devices/uncore_iio_0/die0
+                   -r--r--r-- /sys/devices/uncore_iio_0/die1
+                   -r--r--r-- /sys/devices/uncore_iio_0/die2
+                   -r--r--r-- /sys/devices/uncore_iio_0/die3
 
-                $ tail /sys/devices/uncore_iio_0/die*
-                ==> /sys/devices/uncore_iio_0/die0 <==
-                0000:00
-                ==> /sys/devices/uncore_iio_0/die1 <==
-                0000:40
-                ==> /sys/devices/uncore_iio_0/die2 <==
-                0000:80
-                ==> /sys/devices/uncore_iio_0/die3 <==
-                0000:c0
+                   $ tail /sys/devices/uncore_iio_0/die*
+                   ==> /sys/devices/uncore_iio_0/die0 <==
+                   0000:00
+                   ==> /sys/devices/uncore_iio_0/die1 <==
+                   0000:40
+                   ==> /sys/devices/uncore_iio_0/die2 <==
+                   0000:80
+                   ==> /sys/devices/uncore_iio_0/die3 <==
+                   0000:c0
 
-                Which means:
-                IIO PMU 0 on die 0 belongs to PCI RP on bus 0x00, domain 0x0000
-                IIO PMU 0 on die 1 belongs to PCI RP on bus 0x40, domain 0x0000
-                IIO PMU 0 on die 2 belongs to PCI RP on bus 0x80, domain 0x0000
-                IIO PMU 0 on die 3 belongs to PCI RP on bus 0xc0, domain 0x0000
+                Which means::
+
+                   IIO PMU 0 on die 0 belongs to PCI RP on bus 0x00, domain 0x0000
+                   IIO PMU 0 on die 1 belongs to PCI RP on bus 0x40, domain 0x0000
+                   IIO PMU 0 on die 2 belongs to PCI RP on bus 0x80, domain 0x0000
+                   IIO PMU 0 on die 3 belongs to PCI RP on bus 0xc0, domain 0x0000
index deef3b5723cf2685925a791e20bc97027142b5df..2da2b1fba2c1cd108c5ec514a5b524675d5b5f64 100644 (file)
@@ -47,16 +47,19 @@ Description:
                online/offline state of the memory section.  When written,
                root can toggle the the online/offline state of a removable
                memory section (see removable file description above)
-               using the following commands.
-               # echo online > /sys/devices/system/memory/memoryX/state
-               # echo offline > /sys/devices/system/memory/memoryX/state
+               using the following commands::
+
+                 # echo online > /sys/devices/system/memory/memoryX/state
+                 # echo offline > /sys/devices/system/memory/memoryX/state
 
                For example, if /sys/devices/system/memory/memory22/removable
                contains a value of 1 and
                /sys/devices/system/memory/memory22/state contains the
                string "online" the following command can be executed by
-               by root to offline that section.
-               # echo offline > /sys/devices/system/memory/memory22/state
+               by root to offline that section::
+
+                 # echo offline > /sys/devices/system/memory/memory22/state
+
 Users:         hotplug memory remove tools
                http://www.ibm.com/developerworks/wikis/display/LinuxP/powerpc-utils
 
@@ -78,6 +81,7 @@ Description:
 
                For example, the following symbolic link is created for
                memory section 9 on node0:
+
                /sys/devices/system/memory/memory9/node0 -> ../../node/node0
 
 
@@ -90,4 +94,5 @@ Description:
                points to the corresponding /sys/devices/system/memory/memoryY
                memory section directory.  For example, the following symbolic
                link is created for memory section 9 on node0.
+
                /sys/devices/system/node/node0/memory9 -> ../../memory/memory9
index 7e43cdce9a5272ba85ef1d59f69c76be3d38a414..f7b360a61b2181ea2cf0f501699a68a8c5edd4dc 100644 (file)
@@ -7,6 +7,7 @@ Description:
                (RO) Hexadecimal bitmask of the TAD attributes are reported by
                the platform firmware (see ACPI 6.2, section 9.18.2):
 
+               ======= ======================================================
                BIT(0): AC wakeup implemented if set
                BIT(1): DC wakeup implemented if set
                BIT(2): Get/set real time features implemented if set
@@ -16,6 +17,7 @@ Description:
                BIT(6): The AC timer wakes up from S5 if set
                BIT(7): The DC timer wakes up from S4 if set
                BIT(8): The DC timer wakes up from S5 if set
+               ======= ======================================================
 
                The other bits are reserved.
 
@@ -62,9 +64,11 @@ Description:
                timer status with the following meaning of bits (see ACPI 6.2,
                Section 9.18.5):
 
+               ======= ======================================================
                Bit(0): The timer has expired if set.
                Bit(1): The timer has woken up the system from a sleep state
                        (S3 or S4/S5 if supported) if set.
+               ======= ======================================================
 
                The other bits are reserved.
 
index d548eaac230a43f51eb4b613b7db114f7ce70b19..40f29a01fd143071b2426af9801c2acd1d566fd1 100644 (file)
@@ -3,8 +3,9 @@ Date:           April 2010
 Contact:       Fabien Chouteau <fabien.chouteau@barco.com>
 Description:
                Show the suspend state of an USB composite gadget.
-               1 -> suspended
-               0 -> resumed
+
+               - 1 -> suspended
+               - 0 -> resumed
 
                (_UDC_ is the name of the USB Device Controller driver)
 
@@ -17,5 +18,6 @@ Description:
                Storage mode.
 
                Possible values are:
-                       1 -> ignore the FUA flag
-                       0 -> obey the FUA flag
+
+                       - 1 -> ignore the FUA flag
+                       - 0 -> obey the FUA flag
index 8aa36716882f87179aa8d025b2f1696d6aa1ac3b..378c42694bfb6b4d57c9d9f23dc3179c2a20cf3a 100644 (file)
@@ -9,8 +9,10 @@ Description:
                The protection has information embedded whether it blocks reads,
                writes or both.
                The result is:
-               0 -> the DPS is not keylocked
-               1 -> the DPS is keylocked
+
+               - 0 -> the DPS is not keylocked
+               - 1 -> the DPS is keylocked
+
 Users:         None identified so far.
 
 What:          /sys/devices/platform/docg3/f[0-3]_dps[01]_protection_key
@@ -27,8 +29,12 @@ Description:
                Entering the correct value toggle the lock, and can be observed
                through f[0-3]_dps[01]_is_keylocked.
                Possible values are:
+
                        - 8 bytes
+
                Typical values are:
+
                        - "00000000"
                        - "12345678"
+
 Users:         None identified so far.
index afb5db856e1cad3927c5b14f93c54c205008a79f..07df0ddc0b696ecebbd2436824f10facb448bbdb 100644 (file)
@@ -123,38 +123,40 @@ KernelVersion:    v4.15
 Contact:       openipmi-developer@lists.sourceforge.net
 Description:
 
-               idles:                  (RO) Number of times the interface was
+               ======================  ========================================
+               idles                   (RO) Number of times the interface was
                                        idle while being polled.
 
-               watchdog_pretimeouts:   (RO) Number of watchdog pretimeouts.
+               watchdog_pretimeouts    (RO) Number of watchdog pretimeouts.
 
-               complete_transactions:  (RO) Number of completed messages.
+               complete_transactions   (RO) Number of completed messages.
 
-               events:                 (RO) Number of IPMI events received from
+               events                  (RO) Number of IPMI events received from
                                        the hardware.
 
-               interrupts:             (RO) Number of interrupts the driver
+               interrupts              (RO) Number of interrupts the driver
                                        handled.
 
-               hosed_count:            (RO) Number of times the hardware didn't
+               hosed_count             (RO) Number of times the hardware didn't
                                        follow the state machine.
 
-               long_timeouts:          (RO) Number of times the driver
+               long_timeouts           (RO) Number of times the driver
                                        requested a timer while nothing was in
                                        progress.
 
-               flag_fetches:           (RO) Number of times the driver
+               flag_fetches            (RO) Number of times the driver
                                        requested flags from the hardware.
 
-               attentions:             (RO) Number of time the driver got an
+               attentions              (RO) Number of time the driver got an
                                        ATTN from the hardware.
 
-               incoming_messages:      (RO) Number of asynchronous messages
+               incoming_messages       (RO) Number of asynchronous messages
                                        received.
 
-               short_timeouts:         (RO) Number of times the driver
+               short_timeouts          (RO) Number of times the driver
                                        requested a timer while an operation was
                                        in progress.
+               ======================  ========================================
 
 
 What:          /sys/devices/platform/ipmi_si.*/interrupts_enabled
@@ -201,38 +203,40 @@ Date:             Sep, 2017
 KernelVersion: v4.15
 Contact:       openipmi-developer@lists.sourceforge.net
 Description:
-               hosed:                  (RO) Number of times the hardware didn't
+               ======================  ========================================
+               hosed                   (RO) Number of times the hardware didn't
                                        follow the state machine.
 
-               alerts:                 (RO) Number of alerts received.
+               alerts                  (RO) Number of alerts received.
 
-               sent_messages:          (RO) Number of total messages sent.
+               sent_messages           (RO) Number of total messages sent.
 
-               sent_message_parts:     (RO) Number of message parts sent.
+               sent_message_parts      (RO) Number of message parts sent.
                                        Messages may be broken into parts if
                                        they are long.
 
-               received_messages:      (RO) Number of message responses
+               received_messages       (RO) Number of message responses
                                        received.
 
-               received_message_parts: (RO) Number of message fragments
+               received_message_parts  (RO) Number of message fragments
                                        received.
 
-               events:                 (RO) Number of received events.
+               events                  (RO) Number of received events.
 
-               watchdog_pretimeouts:   (RO) Number of watchdog pretimeouts.
+               watchdog_pretimeouts    (RO) Number of watchdog pretimeouts.
 
-               flag_fetches:           (RO) Number of times a flag fetch was
+               flag_fetches            (RO) Number of times a flag fetch was
                                        requested.
 
-               send_retries:           (RO) Number of time a message was
+               send_retries            (RO) Number of time a message was
                                        retried.
 
-               receive_retries:        (RO) Number of times the receive of a
+               receive_retries         (RO) Number of times the receive of a
                                        message was retried.
 
-               send_errors:            (RO) Number of times the send of a
+               send_errors             (RO) Number of times the send of a
                                        message failed.
 
-               receive_errors:         (RO) Number of errors in receiving
+               receive_errors          (RO) Number of errors in receiving
                                        messages.
+               ======================  ========================================
index 2107082426daf2f5076d7bb851a6dcca189484d9..e45ac2e865d5e44bc2d157f0a36563741fa3db1b 100644 (file)
@@ -17,10 +17,10 @@ Description:
                to overlay planes.
 
                Selects the composition mode for the overlay. Possible values
-               are
+               are:
 
-               0 - Alpha Blending
-               1 - ROP3
+               0 - Alpha Blending
+               1 - ROP3
 
 What:          /sys/devices/platform/sh_mobile_lcdc_fb.[0-3]/graphics/fb[0-9]/ovl_position
 Date:          May 2012
@@ -30,7 +30,7 @@ Description:
                to overlay planes.
 
                Stores the x,y overlay position on the display in pixels. The
-               position format is `[0-9]+,[0-9]+'.
+               position format is `[0-9]+,[0-9]+`.
 
 What:          /sys/devices/platform/sh_mobile_lcdc_fb.[0-3]/graphics/fb[0-9]/ovl_rop3
 Date:          May 2012
index a8daceb4a95655b605c37904578b5abcfdcbbfb3..ee253b033280e9abe74c50a0e70e619c31fdf97a 100644 (file)
@@ -102,6 +102,8 @@ Description:
                b[15:0]
                        inform firmware the current software execution
                        stage.
+
+                       ==      ===========================================
                        0       the first stage bootloader didn't run or
                                didn't reach the point of launching second
                                stage bootloader.
@@ -111,21 +113,29 @@ Description:
                        2       both first and second stage bootloader ran
                                and the operating system launch was
                                attempted.
+                       ==      ===========================================
 
                b[16]
+                       ==      ===========================================
                        1       firmware to reset current image retry
                                counter.
                        0       no action.
+                       ==      ===========================================
 
                b[17]
+                       ==      ===========================================
                        1       firmware to clear RSU log
                        0       no action.
+                       ==      ===========================================
 
                b[18]
                        this is negative logic
+
+                       ==      ===========================================
                        1       no action
                        0       firmware record the notify code defined
                                in b[15:0].
+                       ==      ===========================================
 
 What:          /sys/devices/platform/stratix10-rsu.0/dcmf0
 Date:          June 2020
index b555df825447a42d053d583bd11d92719e998cb4..1a04ca8162ad882483e402256059446fea8d6943 100644 (file)
@@ -151,23 +151,28 @@ Description:
                The processor idle states which are available for use have the
                following attributes:
 
-               name: (RO) Name of the idle state (string).
+               ======== ==== =================================================
+               name:    (RO) Name of the idle state (string).
 
                latency: (RO) The latency to exit out of this idle state (in
-               microseconds).
+                             microseconds).
 
-               power: (RO) The power consumed while in this idle state (in
-               milliwatts).
+               power:   (RO) The power consumed while in this idle state (in
+                             milliwatts).
 
-               time: (RO) The total time spent in this idle state (in microseconds).
+               time:    (RO) The total time spent in this idle state
+                             (in microseconds).
 
-               usage: (RO) Number of times this state was entered (a count).
+               usage:   (RO) Number of times this state was entered (a count).
 
-               above: (RO) Number of times this state was entered, but the
-                      observed CPU idle duration was too short for it (a count).
+               above:   (RO) Number of times this state was entered, but the
+                             observed CPU idle duration was too short for it
+                             (a count).
 
-               below: (RO) Number of times this state was entered, but the
-                      observed CPU idle duration was too long for it (a count).
+               below:   (RO) Number of times this state was entered, but the
+                             observed CPU idle duration was too long for it
+                             (a count).
+               ======== ==== =================================================
 
 What:          /sys/devices/system/cpu/cpuX/cpuidle/stateN/desc
 Date:          February 2008
@@ -290,6 +295,7 @@ Description:        Processor frequency boosting control
                This switch controls the boost setting for the whole system.
                Boosting allows the CPU and the firmware to run at a frequency
                beyound it's nominal limit.
+
                More details can be found in
                Documentation/admin-guide/pm/cpufreq.rst
 
@@ -337,43 +343,57 @@ Contact:  Sudeep Holla <sudeep.holla@arm.com>
 Description:   Parameters for the CPU cache attributes
 
                allocation_policy:
-                       - WriteAllocate: allocate a memory location to a cache line
-                                        on a cache miss because of a write
-                       - ReadAllocate: allocate a memory location to a cache line
+                       - WriteAllocate:
+                                       allocate a memory location to a cache line
+                                       on a cache miss because of a write
+                       - ReadAllocate:
+                                       allocate a memory location to a cache line
                                        on a cache miss because of a read
-                       - ReadWriteAllocate: both writeallocate and readallocate
+                       - ReadWriteAllocate:
+                                       both writeallocate and readallocate
 
-               attributes: LEGACY used only on IA64 and is same as write_policy
+               attributes:
+                           LEGACY used only on IA64 and is same as write_policy
 
-               coherency_line_size: the minimum amount of data in bytes that gets
+               coherency_line_size:
+                                    the minimum amount of data in bytes that gets
                                     transferred from memory to cache
 
-               level: the cache hierarchy in the multi-level cache configuration
+               level:
+                       the cache hierarchy in the multi-level cache configuration
 
-               number_of_sets: total number of sets in the cache, a set is a
+               number_of_sets:
+                               total number of sets in the cache, a set is a
                                collection of cache lines with the same cache index
 
-               physical_line_partition: number of physical cache line per cache tag
+               physical_line_partition:
+                               number of physical cache line per cache tag
 
-               shared_cpu_list: the list of logical cpus sharing the cache
+               shared_cpu_list:
+                               the list of logical cpus sharing the cache
 
-               shared_cpu_map: logical cpu mask containing the list of cpus sharing
+               shared_cpu_map:
+                               logical cpu mask containing the list of cpus sharing
                                the cache
 
-               size: the total cache size in kB
+               size:
+                       the total cache size in kB
 
                type:
                        - Instruction: cache that only holds instructions
                        - Data: cache that only caches data
                        - Unified: cache that holds both data and instructions
 
-               ways_of_associativity: degree of freedom in placing a particular block
-                                       of memory in the cache
+               ways_of_associativity:
+                       degree of freedom in placing a particular block
+                       of memory in the cache
 
                write_policy:
-                       - WriteThrough: data is written to both the cache line
+                       - WriteThrough:
+                                       data is written to both the cache line
                                        and to the block in the lower-level memory
-                       - WriteBack: data is written only to the cache line and
+                       - WriteBack:
+                                    data is written only to the cache line and
                                     the modified cache line is written to main
                                     memory only when it is replaced
 
@@ -414,30 +434,30 @@ Description:      POWERNV CPUFreq driver's frequency throttle stats directory and
                throttle attributes exported in the 'throttle_stats' directory:
 
                - turbo_stat : This file gives the total number of times the max
-               frequency is throttled to lower frequency in turbo (at and above
-               nominal frequency) range of frequencies.
+                 frequency is throttled to lower frequency in turbo (at and above
+                 nominal frequency) range of frequencies.
 
                - sub_turbo_stat : This file gives the total number of times the
-               max frequency is throttled to lower frequency in sub-turbo(below
-               nominal frequency) range of frequencies.
+                 max frequency is throttled to lower frequency in sub-turbo(below
+                 nominal frequency) range of frequencies.
 
                - unthrottle : This file gives the total number of times the max
-               frequency is unthrottled after being throttled.
+                 frequency is unthrottled after being throttled.
 
                - powercap : This file gives the total number of times the max
-               frequency is throttled due to 'Power Capping'.
+                 frequency is throttled due to 'Power Capping'.
 
                - overtemp : This file gives the total number of times the max
-               frequency is throttled due to 'CPU Over Temperature'.
+                 frequency is throttled due to 'CPU Over Temperature'.
 
                - supply_fault : This file gives the total number of times the
-               max frequency is throttled due to 'Power Supply Failure'.
+                 max frequency is throttled due to 'Power Supply Failure'.
 
                - overcurrent : This file gives the total number of times the
-               max frequency is throttled due to 'Overcurrent'.
+                 max frequency is throttled due to 'Overcurrent'.
 
                - occ_reset : This file gives the total number of times the max
-               frequency is throttled due to 'OCC Reset'.
+                 frequency is throttled due to 'OCC Reset'.
 
                The sysfs attributes representing different throttle reasons like
                powercap, overtemp, supply_fault, overcurrent and occ_reset map to
@@ -469,8 +489,9 @@ What:               /sys/devices/system/cpu/cpuX/regs/
 Date:          June 2016
 Contact:       Linux ARM Kernel Mailing list <linux-arm-kernel@lists.infradead.org>
 Description:   AArch64 CPU registers
+
                'identification' directory exposes the CPU ID registers for
-                identifying model and revision of the CPU.
+               identifying model and revision of the CPU.
 
 What:          /sys/devices/system/cpu/cpu#/cpu_capacity
 Date:          December 2016
@@ -497,9 +518,11 @@ Description:       Information about CPU vulnerabilities
                vulnerabilities. The output of those files reflects the
                state of the CPUs in the system. Possible output values:
 
+               ================  ==============================================
                "Not affected"    CPU is not affected by the vulnerability
                "Vulnerable"      CPU is affected and no mitigation in effect
                "Mitigation: $M"  CPU is affected and mitigation $M is in effect
+               ================  ==============================================
 
                See also: Documentation/admin-guide/hw-vuln/index.rst
 
@@ -515,12 +538,14 @@ Description:      Control Symetric Multi Threading (SMT)
                control: Read/write interface to control SMT. Possible
                         values:
 
+                        ================ =========================================
                         "on"             SMT is enabled
                         "off"            SMT is disabled
                         "forceoff"       SMT is force disabled. Cannot be changed.
                         "notsupported"   SMT is not supported by the CPU
                         "notimplemented" SMT runtime toggling is not
                                          implemented for the architecture
+                        ================ =========================================
 
                         If control status is "forceoff" or "notsupported" writes
                         are rejected.
@@ -576,7 +601,7 @@ Description:        Secure Virtual Machine
                Facility in POWER9 and newer processors. i.e., it is a Secure
                Virtual Machine.
 
-What:          /sys/devices/system/cpu/cpuX/purr
+What:          /sys/devices/system/cpu/cpuX/purr
 Date:          Apr 2005
 Contact:       Linux for PowerPC mailing list <linuxppc-dev@ozlabs.org>
 Description:   PURR ticks for this CPU since the system boot.
index 470def06ab0a42e40f860d1fe54f8e0d489ec4c3..1a8ee26e92ae61b4c7bb51824e56b43f3ddd2d13 100644 (file)
@@ -5,8 +5,10 @@ Contact:        Vernon Mauery <vernux@us.ibm.com>
 Description:    The state file allows a means by which to change in and
                 out of Premium Real-Time Mode (PRTM), as well as the
                 ability to query the current state.
-                    0 => PRTM off
-                    1 => PRTM enabled
+
+                    - 0 => PRTM off
+                    - 1 => PRTM enabled
+
 Users:          The ibm-prtm userspace daemon uses this interface.
 
 
index 4d63a7904b94a9938fe4e41916de6c1ea6c31be0..42214b4ff14a1372dcbf9822c8c192725366ed56 100644 (file)
@@ -6,11 +6,13 @@ Description:  Read/write the current state of DDR Backup Mode, which controls
                if DDR power rails will be kept powered during system suspend.
                ("on"/"1" = enabled, "off"/"0" = disabled).
                Two types of power switches (or control signals) can be used:
+
                  A. With a momentary power switch (or pulse signal), DDR
                     Backup Mode is enabled by default when available, as the
                     PMIC will be configured only during system suspend.
                  B. With a toggle power switch (or level signal), the
                     following steps must be followed exactly:
+
                       1. Configure PMIC for backup mode, to change the role of
                          the accessory power switch from a power switch to a
                          wake-up switch,
@@ -20,8 +22,10 @@ Description: Read/write the current state of DDR Backup Mode, which controls
                       3. Suspend system,
                       4. Switch accessory power switch on, to resume the
                          system.
+
                     DDR Backup Mode must be explicitly enabled by the user,
                     to invoke step 1.
+
                See also Documentation/devicetree/bindings/mfd/bd9571mwv.txt.
 Users:         User space applications for embedded boards equipped with a
                BD9571MWV PMIC.
index 64ac6d567c4b95eefdb7432a7dab65b3ad7d030d..69d855dc4c47c9e15e1fac119bf40c1c2b91cf86 100644 (file)
@@ -29,8 +29,12 @@ What:           /sys/class/genwqe/genwqe<n>_card/reload_bitstream
 Date:           May 2014
 Contact:        klebers@linux.vnet.ibm.com
 Description:    Interface to trigger a PCIe card reset to reload the bitstream.
+
+               ::
+
                   sudo sh -c 'echo 1 > \
                     /sys/class/genwqe/genwqe0_card/reload_bitstream'
+
                 If successfully, the card will come back with the bitstream set
                 on 'next_bitstream'.
 
@@ -64,8 +68,11 @@ Description:    Base clock frequency of the card.
 What:           /sys/class/genwqe/genwqe<n>_card/device/sriov_numvfs
 Date:           Oct 2013
 Contact:        haver@linux.vnet.ibm.com
-Description:    Enable VFs (1..15):
+Description:    Enable VFs (1..15)::
+
                   sudo sh -c 'echo 15 > \
                     /sys/bus/pci/devices/0000\:1b\:00.0/sriov_numvfs'
-                Disable VFs:
+
+                Disable VFs::
+
                   Write a 0 into the same sysfs entry.
index 53a0725962e1ac53036b78d0f9da6f852092c447..aee85ca1f6be658e8aad45eb867e5c261e6b4510 100644 (file)
@@ -3,14 +3,18 @@ Date:         July 2011
 Contact:       linux-input@vger.kernel.org
 Description:   This controls if mouse clicks should be generated if the trackpoint is quickly pressed. How fast this press has to be
                is being controlled by press_speed.
+
                Values are 0 or 1.
+
                Applies to Thinkpad USB Keyboard with TrackPoint.
 
 What:          /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/dragging
 Date:          July 2011
 Contact:       linux-input@vger.kernel.org
 Description:   If this setting is enabled, it is possible to do dragging by pressing the trackpoint. This requires press_to_select to be enabled.
+
                Values are 0 or 1.
+
                Applies to Thinkpad USB Keyboard with TrackPoint.
 
 What:          /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/release_to_select
@@ -25,7 +29,9 @@ Date:         July 2011
 Contact:       linux-input@vger.kernel.org
 Description:   This setting controls if the mouse click events generated by pressing the trackpoint (if press_to_select is enabled) generate
                a left or right mouse button click.
+
                Values are 0 or 1.
+
                Applies to Thinkpad USB Keyboard with TrackPoint.
 
 What:          /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/sensitivity
@@ -39,12 +45,16 @@ What:               /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-
 Date:          July 2011
 Contact:       linux-input@vger.kernel.org
 Description:   This setting controls how fast the trackpoint needs to be pressed to generate a mouse click if press_to_select is enabled.
+
                Values are decimal integers from 1 (slowest) to 255 (fastest).
+
                Applies to Thinkpad USB Keyboard with TrackPoint.
 
 What:          /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/fn_lock
 Date:          July 2014
 Contact:       linux-input@vger.kernel.org
 Description:   This setting controls whether Fn Lock is enabled on the keyboard (i.e. if F1 is Mute or F1)
+
                Values are 0 or 1
+
                Applies to ThinkPad Compact (USB|Bluetooth) Keyboard with TrackPoint.
index 305dffd229a83cab521758cde40d61b055b9d6c6..de07be314efc7f598912961a873fc041d537446e 100644 (file)
@@ -12,7 +12,9 @@ KernelVersion:        4.1
 Contact:       Michal Malý <madcatxster@devoid-pointer.net>
 Description:   Displays a set of alternate modes supported by a wheel. Each
                mode is listed as follows:
+
                  Tag: Mode Name
+
                Currently active mode is marked with an asterisk. List also
                contains an abstract item "native" which always denotes the
                native mode of the wheel. Echoing the mode tag switches the
@@ -24,24 +26,30 @@ Description:        Displays a set of alternate modes supported by a wheel. Each
                This entry is not created for devices that have only one mode.
 
                Currently supported mode switches:
-               Driving Force Pro:
+
+               Driving Force Pro::
+
                  DF-EX --> DFP
 
-               G25:
+               G25::
+
                  DF-EX --> DFP --> G25
 
-               G27:
+               G27::
+
                  DF-EX <*> DFP <-> G25 <-> G27
                  DF-EX <*--------> G25 <-> G27
                  DF-EX <*----------------> G27
 
-               G29:
+               G29::
+
                  DF-EX <*> DFP <-> G25 <-> G27 <-> G29
                  DF-EX <*--------> G25 <-> G27 <-> G29
                  DF-EX <*----------------> G27 <-> G29
                  DF-EX <*------------------------> G29
 
-               DFGT:
+               DFGT::
+
                  DF-EX <*> DFP <-> DFGT
                  DF-EX <*--------> DFGT
 
index e574a5625efe035267d65ff4e9e34611d933e28d..0e323a5cec6c07d2a9b133ed39803bc5c6879386 100644 (file)
@@ -29,12 +29,13 @@ Contact:    linux-input@vger.kernel.org
 Description:
                Threholds to override activation slack.
 
-               activation_width:       (RW) Width threshold to immediately
+               =================       =====================================
+               activation_width        (RW) Width threshold to immediately
                                        start processing touch events.
 
-               activation_height:      (RW) Height threshold to immediately
+               activation_height       (RW) Height threshold to immediately
                                        start processing touch events.
-
+               =================       =====================================
 
 What:          /sys/bus/hid/drivers/ntrig/<dev>/min_width
 What:          /sys/bus/hid/drivers/ntrig/<dev>/min_height
@@ -44,11 +45,13 @@ Contact:    linux-input@vger.kernel.org
 Description:
                Minimum size contact accepted.
 
-               min_width:      (RW) Minimum touch contact width to decide
+               ==========      ===========================================
+               min_width       (RW) Minimum touch contact width to decide
                                activation and activity.
 
-               min_height:     (RW) Minimum touch contact height to decide
+               min_height      (RW) Minimum touch contact height to decide
                                activation and activity.
+               ==========      ===========================================
 
 
 What:          /sys/bus/hid/drivers/ntrig/<dev>/sensor_physical_width
index 8f7982c70d72cc797a18c15720056bb96f573ebc..11cd9bf0ad185e9e91c17806fdda893695424a3d 100644 (file)
@@ -3,17 +3,21 @@ Date:         March 2010
 Contact:       Stefan Achatz <erazor_de@users.sourceforge.net>
 Description:   It is possible to switch the dpi setting of the mouse with the
                press of a button.
+
                When read, this file returns the raw number of the actual dpi
                setting reported by the mouse. This number has to be further
                processed to receive the real dpi value:
 
+               ===== =====
                VALUE DPI
+               ===== =====
                1     800
                2     1200
                3     1600
                4     2000
                5     2400
                6     3200
+               ===== =====
 
                This file is readonly.
 Users:         http://roccat.sourceforge.net
@@ -22,6 +26,7 @@ What:         /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-
 Date:          March 2010
 Contact:       Stefan Achatz <erazor_de@users.sourceforge.net>
 Description:   When read, this file returns the number of the actual profile.
+
                This file is readonly.
 Users:         http://roccat.sourceforge.net
 
@@ -33,6 +38,7 @@ Description:  When read, this file returns the raw integer version number of the
                further usage in other programs. To receive the real version
                number the decimal point has to be shifted 2 positions to the
                left. E.g. a returned value of 138 means 1.38
+
                This file is readonly.
 Users:         http://roccat.sourceforge.net
 
@@ -43,10 +49,13 @@ Description:        The mouse can store 5 profiles which can be switched by the
                 press of a button. A profile holds information like button
                 mappings, sensitivity, the colors of the 5 leds and light
                 effects.
+
                 When read, these files return the respective profile. The
                 returned data is 975 bytes in size.
+
                When written, this file lets one write the respective profile
                data back to the mouse. The data has to be 975 bytes long.
+
                The mouse will reject invalid data, whereas the profile number
                stored in the profile doesn't need to fit the number of the
                store.
@@ -58,6 +67,7 @@ Contact:      Stefan Achatz <erazor_de@users.sourceforge.net>
 Description:   When read, this file returns the settings stored in the mouse.
                The size of the data is 36 bytes and holds information like the
                startup_profile, tcu state and calibration_data.
+
                When written, this file lets write settings back to the mouse.
                The data has to be 36 bytes long. The mouse will reject invalid
                data.
@@ -67,8 +77,10 @@ What:                /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-
 Date:          March 2010
 Contact:       Stefan Achatz <erazor_de@users.sourceforge.net>
 Description:   The integer value of this attribute ranges from 1 to 5.
+
                 When read, this attribute returns the number of the profile
                 that's active when the mouse is powered on.
+
                When written, this file sets the number of the startup profile
                and the mouse activates this profile immediately.
 Users:         http://roccat.sourceforge.net
@@ -80,9 +92,12 @@ Description: The mouse has a "Tracking Control Unit" which lets the user
                calibrate the laser power to fit the mousepad surface.
                When read, this file returns the current state of the TCU,
                where 0 means off and 1 means on.
+
                Writing 0 in this file will switch the TCU off.
+
                Writing 1 in this file will start the calibration which takes
                around 6 seconds to complete and activates the TCU.
+
 Users:         http://roccat.sourceforge.net
 
 What:          /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/weight
@@ -93,14 +108,18 @@ Description:       The mouse can be equipped with one of four supplied weights
                and its value can be read out. When read, this file returns the
                raw value returned by the mouse which eases further processing
                in other software.
+
                The values map to the weights as follows:
 
+               ===== ======
                VALUE WEIGHT
+               ===== ======
                0     none
                1     5g
                2     10g
                3     15g
                4     20g
+               ===== ======
 
                This file is readonly.
 Users:         http://roccat.sourceforge.net
index 39dfa5cb1cc56c41af0ca297de0d3c003655ce2d..3bf43d9dcdfe5b1799fc0e8209fad067e6b6686f 100644 (file)
@@ -20,6 +20,7 @@ Description:  This file contains the currently connected and initialized
                the official Nintendo Nunchuck extension and classic is the
                Nintendo Classic Controller extension. The motionp extension can
                be combined with the other two.
+
                Starting with kernel-version 3.11 Motion Plus hotplugging is
                supported and if detected, it's no longer reported as static
                extension. You will get uevent notifications for the motion-plus
@@ -39,9 +40,13 @@ Description: While a device is initialized by the wiimote driver, we perform
                Other strings for each device-type are available and may be
                added if new device-specific detections are added.
                Currently supported are:
-                       gen10: First Wii Remote generation
-                       gen20: Second Wii Remote Plus generation (builtin MP)
+
+                       ============= =======================================
+                       gen10:        First Wii Remote generation
+                       gen20:        Second Wii Remote Plus generation
+                                     (builtin MP)
                        balanceboard: Wii Balance Board
+                       ============= =======================================
 
 What:          /sys/bus/hid/drivers/wiimote/<dev>/bboard_calib
 Date:          May 2013
@@ -54,6 +59,7 @@ Description:  This attribute is only provided if the device was detected as a
                First, 0kg values for all 4 sensors are written, followed by the
                17kg values for all 4 sensors and last the 34kg values for all 4
                sensors.
+
                Calibration data is already applied by the kernel to all input
                values but may be used by user-space to perform other
                transformations.
@@ -68,9 +74,11 @@ Description: This attribute is only provided if the device was detected as a
                is prefixed with a +/-. Each value is a signed 16bit number.
                Data is encoded as decimal numbers and specifies the offsets of
                the analog sticks of the pro-controller.
+
                Calibration data is already applied by the kernel to all input
                values but may be used by user-space to perform other
                transformations.
+
                Calibration data is detected by the kernel during device setup.
                You can write "scan\n" into this file to re-trigger calibration.
                You can also write data directly in the form "x1:y1 x2:y2" to
index 3d316d54f81c22a83a289a82c11c91cf48e5cb49..cd7c578aef2c98dde62fe8d07038c22666766f4e 100644 (file)
@@ -4,6 +4,7 @@ Contact:        linux-input@vger.kernel.org
 Description:    Reports the firmware version provided by the touchscreen, for example "00_T6" on a EXC80H60
 
                Access: Read
+
                Valid values: Represented as string
 
 What:          /sys/bus/i2c/devices/xxx/model
@@ -12,4 +13,5 @@ Contact:      linux-input@vger.kernel.org
 Description:    Reports the model identification provided by the touchscreen, for example "Orion_1320" on a EXC80H60
 
                Access: Read
+
                Valid values: Represented as string
index bb6f5d6ceea0cd370340b3d5b44132f21639316d..4cf595d681e655b399ef67e50f9482e6fdc0e364 100644 (file)
@@ -4,7 +4,9 @@ Contact:        PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
 Description:   read-only access to the efuse on the Ingenic JZ4780 SoC
                The SoC has a one time programmable 8K efuse that is
                split into segments. The driver supports read only.
-               The segments are
+               The segments are:
+
+               ===== ======== =================
                0x000   64 bit Random Number
                0x008  128 bit Ingenic Chip ID
                0x018  128 bit Customer ID
@@ -12,5 +14,7 @@ Description:  read-only access to the efuse on the Ingenic JZ4780 SoC
                0x1E0    8 bit Protect Segment
                0x1E1 2296 bit HDMI Key
                0x300 2048 bit Security boot key
+               ===== ======== =================
+
 Users:         any user space application which wants to read the Chip
                and Customer ID
index 73308c2b81b043d54654e04d10ae8d273a7a731a..49f5fd0c8bbd32c43b75a5170a06ae39fceef0af 100644 (file)
@@ -7,8 +7,10 @@ Description:
                 the format of DDDD:BB:DD.F-REG:SIZE:MASK will allow the guest
                 to write and read from the PCI device. That is Domain:Bus:
                 Device.Function-Register:Size:Mask (Domain is optional).
-                For example:
-                #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
+                For example::
+
+                  #echo 00:19.0-E0:2:FF > /sys/bus/pci/drivers/pciback/quirks
+
                 will allow the guest to read and write to the configuration
                 register 0x0E.
 
index 34d3a3359cf4587fb182eaf146d6b1648d6a7188..28c9c040de5d15956b35771550caec97bf1c033b 100644 (file)
@@ -9,10 +9,12 @@ Description:  Some Samsung laptops have different "performance levels"
                their fans quiet at all costs.  Reading from this file
                will show the current performance level.  Writing to the
                file can change this value.
+
                        Valid options:
-                               "silent"
-                               "normal"
-                               "overclock"
+                               - "silent"
+                               - "normal"
+                               - "overclock"
+
                Note that not all laptops support all of these options.
                Specifically, not all support the "overclock" option,
                and it's still unknown if this value even changes
@@ -25,8 +27,9 @@ Contact:      Corentin Chary <corentin.chary@gmail.com>
 Description:   Max battery charge level can be modified, battery cycle
                life can be extended by reducing the max battery charge
                level.
-               0 means normal battery mode (100% charge)
-               1 means battery life extender mode (80% charge)
+
+               - 0 means normal battery mode (100% charge)
+               - 1 means battery life extender mode (80% charge)
 
 What:          /sys/devices/platform/samsung/usb_charge
 Date:          December 1, 2011
index f34221b52b14b796377893207692c48ddaabf7fb..e5a438d84e1fbfc3f4b8402786af6eac73b50311 100644 (file)
@@ -4,10 +4,12 @@ KernelVersion:        3.15
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the keyboard backlight operation mode, valid
                values are:
+
                        * 0x1  -> FN-Z
                        * 0x2  -> AUTO (also called TIMER)
                        * 0x8  -> ON
                        * 0x10 -> OFF
+
                Note that from kernel 3.16 onwards this file accepts all listed
                parameters, kernel 3.15 only accepts the first two (FN-Z and
                AUTO).
@@ -41,8 +43,10 @@ KernelVersion:       3.15
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This files controls the status of the touchpad and pointing
                stick (if available), valid values are:
+
                        * 0 -> OFF
                        * 1 -> ON
+
 Users:         KToshiba
 
 What:          /sys/devices/LNXSYSTM:00/LNXSYBUS:00/TOS{1900,620{0,7,8}}:00/available_kbd_modes
@@ -51,10 +55,12 @@ KernelVersion:      3.16
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file shows the supported keyboard backlight modes
                the system supports, which can be:
+
                        * 0x1  -> FN-Z
                        * 0x2  -> AUTO (also called TIMER)
                        * 0x8  -> ON
                        * 0x10 -> OFF
+
                Note that not all keyboard types support the listed modes.
                See the entry named "available_kbd_modes"
 Users:         KToshiba
@@ -65,6 +71,7 @@ KernelVersion:        3.16
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file shows the current keyboard backlight type,
                which can be:
+
                        * 1 -> Type 1, supporting modes FN-Z and AUTO
                        * 2 -> Type 2, supporting modes TIMER, ON and OFF
 Users:         KToshiba
@@ -75,10 +82,12 @@ KernelVersion:      4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the USB Sleep & Charge charging mode, which
                can be:
+
                        * 0 -> Disabled         (0x00)
                        * 1 -> Alternate        (0x09)
                        * 2 -> Auto             (0x21)
                        * 3 -> Typical          (0x11)
+
                Note that from kernel 4.1 onwards this file accepts all listed
                values, kernel 4.0 only supports the first three.
                Note that this feature only works when connected to power, if
@@ -93,8 +102,10 @@ Contact:    Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the USB Sleep Functions under battery, and
                set the level at which point they will be disabled, accepted
                values can be:
+
                        * 0     -> Disabled
                        * 1-100 -> Battery level to disable sleep functions
+
                Currently it prints two values, the first one indicates if the
                feature is enabled or disabled, while the second one shows the
                current battery level set.
@@ -107,8 +118,10 @@ Date:              January 23, 2015
 KernelVersion: 4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the USB Rapid Charge state, which can be:
+
                        * 0 -> Disabled
                        * 1 -> Enabled
+
                Note that toggling this value requires a reboot for changes to
                take effect.
 Users:         KToshiba
@@ -118,8 +131,10 @@ Date:              January 23, 2015
 KernelVersion: 4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the Sleep & Music state, which values can be:
+
                        * 0 -> Disabled
                        * 1 -> Enabled
+
                Note that this feature only works when connected to power, if
                you want to use it under battery, see the entry named
                "sleep_functions_on_battery"
@@ -138,6 +153,7 @@ KernelVersion:      4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the state of the internal fan, valid
                values are:
+
                        * 0 -> OFF
                        * 1 -> ON
 
@@ -147,8 +163,10 @@ KernelVersion:     4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the Special Functions (hotkeys) operation
                mode, valid values are:
+
                        * 0 -> Normal Operation
                        * 1 -> Special Functions
+
                In the "Normal Operation" mode, the F{1-12} keys are as usual
                and the hotkeys are accessed via FN-F{1-12}.
                In the "Special Functions" mode, the F{1-12} keys trigger the
@@ -163,8 +181,10 @@ KernelVersion:     4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls whether the laptop should turn ON whenever
                the LID is opened, valid values are:
+
                        * 0 -> Disabled
                        * 1 -> Enabled
+
                Note that toggling this value requires a reboot for changes to
                take effect.
 Users:         KToshiba
@@ -174,8 +194,10 @@ Date:              February 12, 2015
 KernelVersion: 4.0
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the USB 3 functionality, valid values are:
+
                        * 0 -> Disabled (Acts as a regular USB 2)
                        * 1 -> Enabled (Full USB 3 functionality)
+
                Note that toggling this value requires a reboot for changes to
                take effect.
 Users:         KToshiba
@@ -188,10 +210,14 @@ Description:      This file controls the Cooling Method feature.
                Reading this file prints two values, the first is the actual cooling method
                and the second is the maximum cooling method supported.
                When the maximum cooling method is ONE, valid values are:
+
                        * 0 -> Maximum Performance
                        * 1 -> Battery Optimized
+
                When the maximum cooling method is TWO, valid values are:
+
                        * 0 -> Maximum Performance
                        * 1 -> Performance
                        * 2 -> Battery Optimized
+
 Users:         KToshiba
index a662370b4dbfa76c0c589601fe4c32d8e42e0ff1..c938690ce10d7bcaf4c413b623f4b9ab6479e176 100644 (file)
@@ -4,10 +4,12 @@ KernelVersion:        3.17
 Contact:       Azael Avalos <coproscefalo@gmail.com>
 Description:   This file controls the built-in accelerometer protection level,
                valid values are:
+
                        * 0 -> Disabled
                        * 1 -> Low
                        * 2 -> Medium
                        * 3 -> High
+
                The default potection value is set to 2 (Medium).
 Users:         KToshiba
 
index d1a352194d2eaf65d2d8ca435885bbded5424e6a..adc0d0e916078001cd573c896cda7402e7b5e10b 100644 (file)
@@ -18,6 +18,7 @@ Contact:      Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the device type. This is one of the UFS
                device descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_class
@@ -26,6 +27,7 @@ Contact:      Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the device class. This is one of the UFS
                device descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_sub_class
@@ -34,6 +36,7 @@ Contact:      Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the UFS storage subclass. This is one of
                the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/protocol
@@ -43,6 +46,7 @@ Description:  This file shows the protocol supported by an UFS device.
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/number_of_luns
@@ -51,6 +55,7 @@ Contact:      Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows number of logical units. This is one of
                the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/number_of_wluns
@@ -60,6 +65,7 @@ Description:  This file shows number of well known logical units.
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/boot_enable
@@ -69,6 +75,7 @@ Description:  This file shows value that indicates whether the device is
                enabled for boot. This is one of the UFS device descriptor
                parameters. The full information about the descriptor could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/descriptor_access_enable
@@ -79,6 +86,7 @@ Description:  This file shows value that indicates whether the device
                of the boot sequence. This is one of the UFS device descriptor
                parameters. The full information about the descriptor could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/initial_power_mode
@@ -88,6 +96,7 @@ Description:  This file shows value that defines the power mode after
                device initialization or hardware reset. This is one of
                the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/high_priority_lun
@@ -96,6 +105,7 @@ Contact:     Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the high priority lun. This is one of
                the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/secure_removal_type
@@ -104,6 +114,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the secure removal type. This is one of
                the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/support_security_lun
@@ -113,6 +124,7 @@ Description:        This file shows whether the security lun is supported.
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/bkops_termination_latency
@@ -122,6 +134,7 @@ Description:        This file shows the background operations termination
                latency. This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/initial_active_icc_level
@@ -130,6 +143,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the initial active ICC level. This is one
                of the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/specification_version
@@ -138,6 +152,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the specification version. This is one
                of the UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/manufacturing_date
@@ -147,6 +162,7 @@ Description:        This file shows the manufacturing date in BCD format.
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/manufacturer_id
@@ -155,6 +171,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the manufacturee ID. This is one of the
                UFS device descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/rtt_capability
@@ -164,6 +181,7 @@ Description:        This file shows the maximum number of outstanding RTTs
                supported by the device. This is one of the UFS device
                descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/rtc_update
@@ -173,6 +191,7 @@ Description:        This file shows the frequency and method of the realtime
                clock update. This is one of the UFS device descriptor
                parameters. The full information about the descriptor
                could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/ufs_features
@@ -182,6 +201,7 @@ Description:        This file shows which features are supported by the device.
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be
                found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/ffu_timeout
@@ -190,6 +210,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the FFU timeout. This is one of the
                UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/queue_depth
@@ -198,6 +219,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the device queue depth. This is one of the
                UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/device_version
@@ -206,6 +228,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the device version. This is one of the
                UFS device descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/number_of_secure_wpa
@@ -215,6 +238,7 @@ Description:        This file shows number of secure write protect areas
                supported by the device. This is one of the UFS device
                descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/psa_max_data_size
@@ -225,6 +249,7 @@ Description:        This file shows the maximum amount of data that may be
                This is one of the UFS device descriptor parameters.
                The full information about the descriptor could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/psa_state_timeout
@@ -234,6 +259,7 @@ Description:        This file shows the command maximum timeout for a change
                in PSA state. This is one of the UFS device descriptor
                parameters. The full information about the descriptor could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -244,6 +270,7 @@ Description:        This file shows the MIPI UniPro version number in BCD format.
                This is one of the UFS interconnect descriptor parameters.
                The full information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/interconnect_descriptor/mphy_version
@@ -253,6 +280,7 @@ Description:        This file shows the MIPI M-PHY version number in BCD format.
                This is one of the UFS interconnect descriptor parameters.
                The full information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -264,6 +292,7 @@ Description:        This file shows the total memory quantity available to
                of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_number_of_luns
@@ -273,6 +302,7 @@ Description:        This file shows the maximum number of logical units
                supported by the UFS device. This is one of the UFS
                geometry descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/segment_size
@@ -281,6 +311,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the segment size. This is one of the UFS
                geometry descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/allocation_unit_size
@@ -289,6 +320,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the allocation unit size. This is one of
                the UFS geometry descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/min_addressable_block_size
@@ -298,6 +330,7 @@ Description:        This file shows the minimum addressable block size. This
                is one of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at UFS
                specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/optimal_read_block_size
@@ -307,6 +340,7 @@ Description:        This file shows the optimal read block size. This is one
                of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at UFS
                specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/optimal_write_block_size
@@ -316,6 +350,7 @@ Description:        This file shows the optimal write block size. This is one
                of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at UFS
                specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_in_buffer_size
@@ -325,6 +360,7 @@ Description:        This file shows the maximum data-in buffer size. This
                is one of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at UFS
                specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_out_buffer_size
@@ -334,6 +370,7 @@ Description:        This file shows the maximum data-out buffer size. This
                is one of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at UFS
                specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/rpmb_rw_size
@@ -343,6 +380,7 @@ Description:        This file shows the maximum number of RPMB frames allowed
                in Security Protocol In/Out. This is one of the UFS geometry
                descriptor parameters. The full information about the
                descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/dyn_capacity_resource_policy
@@ -352,6 +390,7 @@ Description:        This file shows the dynamic capacity resource policy. This
                is one of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/data_ordering
@@ -361,6 +400,7 @@ Description:        This file shows support for out-of-order data transfer.
                This is one of the UFS geometry descriptor parameters.
                The full information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/max_number_of_contexts
@@ -370,6 +410,7 @@ Description:        This file shows maximum available number of contexts which
                are supported by the device. This is one of the UFS geometry
                descriptor parameters. The full information about the
                descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/sys_data_tag_unit_size
@@ -378,6 +419,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows system data tag unit size. This is one of
                the UFS geometry descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/sys_data_tag_resource_size
@@ -388,6 +430,7 @@ Description:        This file shows maximum storage area size allocated by
                This is one of the UFS geometry descriptor parameters.
                The full information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/secure_removal_types
@@ -397,6 +440,7 @@ Description:        This file shows supported secure removal types. This is
                one of the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/memory_types
@@ -406,6 +450,7 @@ Description:        This file shows supported memory types. This is one of
                the UFS geometry descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/*_memory_max_alloc_units
@@ -416,6 +461,7 @@ Description:        This file shows the maximum number of allocation units for
                enhanced type 1-4). This is one of the UFS geometry
                descriptor parameters. The full information about the
                descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/*_memory_capacity_adjustment_factor
@@ -426,6 +472,7 @@ Description:        This file shows the memory capacity adjustment factor for
                enhanced type 1-4). This is one of the UFS geometry
                descriptor parameters. The full information about the
                descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -436,6 +483,7 @@ Description:        This file shows preend of life information. This is one
                of the UFS health descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/health_descriptor/life_time_estimation_a
@@ -445,6 +493,7 @@ Description:        This file shows indication of the device life time
                (method a). This is one of the UFS health descriptor
                parameters. The full information about the descriptor
                could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/health_descriptor/life_time_estimation_b
@@ -454,6 +503,7 @@ Description:        This file shows indication of the device life time
                (method b). This is one of the UFS health descriptor
                parameters. The full information about the descriptor
                could be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -464,6 +514,7 @@ Description:        This file shows maximum VCC, VCCQ and VCCQ2 value for
                active ICC levels from 0 to 15. This is one of the UFS
                power descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -473,6 +524,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file contains a device manufactureer name string.
                The full information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/string_descriptors/product_name
@@ -480,6 +532,7 @@ Date:               February 2018
 Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file contains a product name string. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/string_descriptors/oem_id
@@ -487,6 +540,7 @@ Date:               February 2018
 Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file contains a OEM ID string. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/string_descriptors/serial_number
@@ -495,6 +549,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file contains a device serial number string. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/string_descriptors/product_revision
@@ -503,6 +558,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file contains a product revision string. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -512,6 +568,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows boot LUN information. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/lun_write_protect
@@ -520,6 +577,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows LUN write protection status. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/lun_queue_depth
@@ -528,6 +586,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows LUN queue depth. This is one of the UFS
                unit descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/psa_sensitive
@@ -536,6 +595,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows PSA sensitivity. This is one of the UFS
                unit descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/lun_memory_type
@@ -544,6 +604,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows LUN memory type. This is one of the UFS
                unit descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/data_reliability
@@ -553,6 +614,7 @@ Description:        This file defines the device behavior when a power failure
                occurs during a write operation. This is one of the UFS
                unit descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/logical_block_size
@@ -562,6 +624,7 @@ Description:        This file shows the size of addressable logical blocks
                (calculated as an exponent with base 2). This is one of
                the UFS unit descriptor parameters. The full information about
                the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/logical_block_count
@@ -571,6 +634,7 @@ Description:        This file shows total number of addressable logical blocks.
                This is one of the UFS unit descriptor parameters. The full
                information about the descriptor could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/erase_block_size
@@ -579,6 +643,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the erase block size. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/provisioning_type
@@ -587,6 +652,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the thin provisioning type. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/physical_memory_resourse_count
@@ -595,6 +661,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the total physical memory resources. This is
                one of the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/context_capabilities
@@ -603,6 +670,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the context capabilities. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/large_unit_granularity
@@ -611,6 +679,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the granularity of the LUN. This is one of
                the UFS unit descriptor parameters. The full information
                about the descriptor could be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -619,6 +688,7 @@ Date:               February 2018
 Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the device init status. The full information
                about the flag could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/permanent_wpe
@@ -627,6 +697,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether permanent write protection is enabled.
                The full information about the flag could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/power_on_wpe
@@ -636,6 +707,7 @@ Description:        This file shows whether write protection is enabled on all
                logical units configured as power on write protected. The
                full information about the flag could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/bkops_enable
@@ -644,6 +716,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether the device background operations are
                enabled. The full information about the flag could be
                found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/life_span_mode_enable
@@ -652,6 +725,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether the device life span mode is enabled.
                The full information about the flag could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/phy_resource_removal
@@ -660,6 +734,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether physical resource removal is enable.
                The full information about the flag could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/busy_rtc
@@ -668,6 +743,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether the device is executing internal
                operation related to real time clock. The full information
                about the flag could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/disable_fw_update
@@ -676,6 +752,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows whether the device FW update is permanently
                disabled. The full information about the flag could be found
                at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -685,6 +762,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the boot lun enabled UFS device attribute.
                The full information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/current_power_mode
@@ -693,6 +771,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the current power mode UFS device attribute.
                The full information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/active_icc_level
@@ -701,6 +780,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the active icc level UFS device attribute.
                The full information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/ooo_data_enabled
@@ -709,6 +789,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the out of order data transfer enabled UFS
                device attribute. The full information about the attribute
                could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/bkops_status
@@ -717,6 +798,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the background operations status UFS device
                attribute. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/purge_status
@@ -725,6 +807,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the purge operation status UFS device
                attribute. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/max_data_in_size
@@ -733,6 +816,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the maximum data size in a DATA IN
                UPIU. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/max_data_out_size
@@ -741,6 +825,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file shows the maximum number of bytes that can be
                requested with a READY TO TRANSFER UPIU. The full information
                about the attribute could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/reference_clock_frequency
@@ -749,6 +834,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the reference clock frequency UFS device
                attribute. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/configuration_descriptor_lock
@@ -765,6 +851,7 @@ Description:        This file provides the maximum current number of
                outstanding RTTs in device that is allowed. The full
                information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/exception_event_control
@@ -773,6 +860,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the exception event control UFS device
                attribute. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/exception_event_status
@@ -781,6 +869,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the exception event status UFS device
                attribute. The full information about the attribute could
                be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/ffu_status
@@ -789,6 +878,7 @@ Contact:    Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file provides the ffu status UFS device attribute.
                The full information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/psa_state
@@ -796,6 +886,7 @@ Date:               February 2018
 Contact:       Stanislav Nijnikov <stanislav.nijnikov@wdc.com>
 Description:   This file show the PSA feature status. The full information
                about the attribute could be found at UFS specifications 2.1.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/psa_data_size
@@ -805,6 +896,7 @@ Description:        This file shows the amount of data that the host plans to
                load to all logical units in pre-soldering state.
                The full information about the attribute could be found at
                UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -815,6 +907,7 @@ Description:        This file shows the The amount of physical memory needed
                to be removed from the physical memory resources pool of
                the particular logical unit. The full information about
                the attribute could be found at UFS specifications 2.1.
+
                The file is read only.
 
 
@@ -824,24 +917,28 @@ Contact:  Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry could be used to set or show the UFS device
                runtime power management level. The current driver
                implementation supports 6 levels with next target states:
-               0 - an UFS device will stay active, an UIC link will
-               stay active
-               1 - an UFS device will stay active, an UIC link will
-               hibernate
-               2 - an UFS device will moved to sleep, an UIC link will
-               stay active
-               3 - an UFS device will moved to sleep, an UIC link will
-               hibernate
-               4 - an UFS device will be powered off, an UIC link will
-               hibernate
-               5 - an UFS device will be powered off, an UIC link will
-               be powered off
+
+               ==  ====================================================
+               0   an UFS device will stay active, an UIC link will
+                   stay active
+               1   an UFS device will stay active, an UIC link will
+                   hibernate
+               2   an UFS device will moved to sleep, an UIC link will
+                   stay active
+               3   an UFS device will moved to sleep, an UIC link will
+                   hibernate
+               4   an UFS device will be powered off, an UIC link will
+                   hibernate
+               5   an UFS device will be powered off, an UIC link will
+                   be powered off
+               ==  ====================================================
 
 What:          /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state
 Date:          February 2018
 Contact:       Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry shows the target power mode of an UFS device
                for the chosen runtime power management level.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/rpm_target_link_state
@@ -849,6 +946,7 @@ Date:               February 2018
 Contact:       Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry shows the target state of an UFS UIC link
                for the chosen runtime power management level.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/spm_lvl
@@ -857,24 +955,28 @@ Contact:  Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry could be used to set or show the UFS device
                system power management level. The current driver
                implementation supports 6 levels with next target states:
-               0 - an UFS device will stay active, an UIC link will
-               stay active
-               1 - an UFS device will stay active, an UIC link will
-               hibernate
-               2 - an UFS device will moved to sleep, an UIC link will
-               stay active
-               3 - an UFS device will moved to sleep, an UIC link will
-               hibernate
-               4 - an UFS device will be powered off, an UIC link will
-               hibernate
-               5 - an UFS device will be powered off, an UIC link will
-               be powered off
+
+               ==  ====================================================
+               0   an UFS device will stay active, an UIC link will
+                   stay active
+               1   an UFS device will stay active, an UIC link will
+                   hibernate
+               2   an UFS device will moved to sleep, an UIC link will
+                   stay active
+               3   an UFS device will moved to sleep, an UIC link will
+                   hibernate
+               4   an UFS device will be powered off, an UIC link will
+                   hibernate
+               5   an UFS device will be powered off, an UIC link will
+                   be powered off
+               ==  ====================================================
 
 What:          /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state
 Date:          February 2018
 Contact:       Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry shows the target power mode of an UFS device
                for the chosen system power management level.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/spm_target_link_state
@@ -882,18 +984,21 @@ Date:             February 2018
 Contact:       Subhash Jadavani <subhashj@codeaurora.org>
 Description:   This entry shows the target state of an UFS UIC link
                for the chosen system power management level.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_presv_us_en
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows if preserve user-space was configured
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_shared_alloc_units
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the shared allocated units of WB buffer
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_type
@@ -901,6 +1006,7 @@ Date:              June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the configured WB type.
                0x1 for shared buffer mode. 0x0 for dedicated buffer mode.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_buff_cap_adj
@@ -910,6 +1016,7 @@ Description:       This entry shows the total user-space decrease in shared
                buffer mode.
                The value of this parameter is 3 for TLC NAND when SLC mode
                is used as WriteBooster Buffer. 2 for MLC NAND.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_max_alloc_units
@@ -917,6 +1024,7 @@ Date:              June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the Maximum total WriteBooster Buffer size
                which is supported by the entire device.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_max_wb_luns
@@ -924,6 +1032,7 @@ Date:              June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the maximum number of luns that can support
                WriteBooster.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_sup_red_type
@@ -937,46 +1046,59 @@ Description:     The supportability of user space reduction mode
                preserve user space type.
                02h: Device can be configured in either user space
                reduction type or preserve user space type.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_sup_wb_type
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   The supportability of WriteBooster Buffer type.
-               00h: LU based WriteBooster Buffer configuration
-               01h: Single shared WriteBooster Buffer
-               configuration
-               02h: Supporting both LU based WriteBooster
-               Buffer and Single shared WriteBooster Buffer
-               configuration
+
+               ===  ==========================================================
+               00h  LU based WriteBooster Buffer configuration
+               01h  Single shared WriteBooster Buffer configuration
+               02h  Supporting both LU based WriteBooster.
+                    Buffer and Single shared WriteBooster Buffer configuration
+               ===  ==========================================================
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/wb_enable
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the status of WriteBooster.
-               0: WriteBooster is not enabled.
-               1: WriteBooster is enabled
+
+               == ============================
+               0  WriteBooster is not enabled.
+               1  WriteBooster is enabled
+               == ============================
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/wb_flush_en
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows if flush is enabled.
-               0: Flush operation is not performed.
-               1: Flush operation is performed.
+
+               == =================================
+               0  Flush operation is not performed.
+               1  Flush operation is performed.
+               == =================================
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/flags/wb_flush_during_h8
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   Flush WriteBooster Buffer during hibernate state.
-               0: Device is not allowed to flush the
-               WriteBooster Buffer during link hibernate
-               state.
-               1: Device is allowed to flush the
-               WriteBooster Buffer during link hibernate
-               state
+
+               == =================================================
+               0  Device is not allowed to flush the
+                  WriteBooster Buffer during link hibernate state.
+               1  Device is allowed to flush the
+                  WriteBooster Buffer during link hibernate state.
+               == =================================================
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/wb_avail_buf
@@ -984,23 +1106,30 @@ Date:            June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the amount of unused WriteBooster buffer
                available.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/wb_cur_buf
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the amount of unused current buffer.
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/wb_flush_status
 Date:          June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the flush operation status.
-               00h: idle
-               01h: Flush operation in progress
-               02h: Flush operation stopped prematurely.
-               03h: Flush operation completed successfully
-               04h: Flush operation general failure
+
+
+               ===  ======================================
+               00h  idle
+               01h  Flush operation in progress
+               02h  Flush operation stopped prematurely.
+               03h  Flush operation completed successfully
+               04h  Flush operation general failure
+               ===  ======================================
+
                The file is read only.
 
 What:          /sys/bus/platform/drivers/ufshcd/*/attributes/wb_life_time_est
@@ -1008,9 +1137,13 @@ Date:            June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows an indication of the WriteBooster Buffer
                lifetime based on the amount of performed program/erase cycles
-               01h: 0% - 10% WriteBooster Buffer life time used
+
+               ===  =============================================
+               01h  0% - 10% WriteBooster Buffer life time used
                ...
-               0Ah: 90% - 100% WriteBooster Buffer life time used
+               0Ah  90% - 100% WriteBooster Buffer life time used
+               ===  =============================================
+
                The file is read only.
 
 What:          /sys/class/scsi_device/*/device/unit_descriptor/wb_buf_alloc_units
@@ -1018,4 +1151,5 @@ Date:             June 2020
 Contact:       Asutosh Das <asutoshd@codeaurora.org>
 Description:   This entry shows the configured size of WriteBooster buffer.
                0400h corresponds to 4GB.
+
                The file is read only.
index d301e7017afe164cf9140252f0168ee23007d197..e92aba4eb594e92f25c4482a360c82df9e4191be 100644 (file)
@@ -5,7 +5,9 @@ Contact:        Jan Kandziora <jjj@gmx.de>
 Description:   When written, this file sets the I2C speed on the connected
                DS28E17 chip. When read, it reads the current setting from
                the DS28E17 chip.
+
                Valid values: 100, 400, 900 [kBaud].
+
                Default 100, can be set by w1_ds28e17.speed= module parameter.
 Users:         w1_ds28e17 driver
 
@@ -17,5 +19,6 @@ Description:  When written, this file sets the multiplier used to calculate
                the busy timeout for I2C operations on the connected DS28E17
                chip. When read, returns the current setting.
                Valid values: 1 to 9.
+
                Default 1, can be set by w1_ds28e17.stretch= module parameter.
 Users:         w1_ds28e17 driver
index 8873bbb075cb9fdb343f1a0b23aeb499cf3efd78..6a37dc33ffdb567af4224e6ef2e9453383ca44d3 100644 (file)
@@ -22,8 +22,10 @@ Description:
                device data to its embedded EEPROM, either restore data
                embedded in device EEPROM. Be aware that devices support
                limited EEPROM writing cycles (typical 50k)
+
                        * 'save': save device RAM to EEPROM
                        * 'restore': restore EEPROM data in device RAM
+
 Users:         any user space application which wants to communicate with
                w1_term device
 
@@ -33,9 +35,11 @@ Date:                May 2020
 Contact:       Akira Shimahara <akira215corp@gmail.com>
 Description:
                (RO) return the power status by asking the device
+
                        * '0': device parasite powered
                        * '1': device externally powered
                        * '-xx': xx is kernel error when reading power status
+
 Users:         any user space application which wants to communicate with
                w1_term device
 
@@ -49,10 +53,12 @@ Description:
                will be changed only in device RAM, so it will be cleared when
                power is lost. Trigger a 'save' to EEPROM command to keep
                values after power-on. Read or write are :
+
                        * '9..14': device resolution in bit
-                       or resolution to set in bit
+                         or resolution to set in bit
                        * '-xx': xx is kernel error when reading the resolution
                        * Anything else: do nothing
+
                Some DS18B20 clones are fixed in 12-bit resolution, so the
                actual resolution is read back from the chip and verified. Error
                is reported if the results differ.
@@ -65,16 +71,18 @@ Date:               May 2020
 Contact:       Akira Shimahara <akira215corp@gmail.com>
 Description:
                (RO) return the temperature in 1/1000 degC.
+
                        * If a bulk read has been triggered, it will directly
-                       return the temperature computed when the bulk read
-                       occurred, if available. If not yet available, nothing
-                       is returned (a debug kernel message is sent), you
-                       should retry later on.
+                         return the temperature computed when the bulk read
+                         occurred, if available. If not yet available, nothing
+                         is returned (a debug kernel message is sent), you
+                         should retry later on.
                        * If no bulk read has been triggered, it will trigger
-                       a conversion and send the result. Note that the
-                       conversion duration depend on the resolution (if
-                       device support this feature). It takes 94ms in 9bits
-                       resolution, 750ms for 12bits.
+                         a conversion and send the result. Note that the
+                         conversion duration depend on the resolution (if
+                         device support this feature). It takes 94ms in 9bits
+                         resolution, 750ms for 12bits.
+
 Users:         any user space application which wants to communicate with
                w1_term device
 
@@ -86,12 +94,14 @@ Description:
                (RW) return the temperature in 1/1000 degC.
                *read*: return 2 lines with the hexa output data sent on the
                bus, return the CRC check and temperature in 1/1000 degC
-               *write* :
+               *write*:
+
                        * '0' : save the 2 or 3 bytes to the device EEPROM
-                       (i.e. TH, TL and config register)
+                         (i.e. TH, TL and config register)
                        * '9..14' : set the device resolution in RAM
-                       (if supported)
+                         (if supported)
                        * Anything else: do nothing
+
                refer to Documentation/w1/slaves/w1_therm.rst for detailed
                information.
 Users:         any user space application which wants to communicate with
@@ -103,14 +113,21 @@ Date:             May 2020
 Contact:       Akira Shimahara <akira215corp@gmail.com>
 Description:
                (RW) trigger a bulk read conversion. read the status
+
                *read*:
-                       * '-1': conversion in progress on at least 1 sensor
-                       * '1' : conversion complete but at least one sensor
+                       * '-1':
+                               conversion in progress on at least 1 sensor
+                       * '1' :
+                               conversion complete but at least one sensor
                                value has not been read yet
-                       * '0' : no bulk operation. Reading temperature will
+                       * '0' :
+                               no bulk operation. Reading temperature will
                                trigger a conversion on each device
-               *write*: 'trigger': trigger a bulk read on all supporting
+
+               *write*:
+                       'trigger': trigger a bulk read on all supporting
                        devices on the bus
+
                Note that if a bulk read is sent but one sensor is not read
                immediately, the next access to temperature on this device
                will return the temperature measured at the time of issue
@@ -128,14 +145,19 @@ Description:
                reset to default (datasheet) conversion time for a new
                resolution.
 
-               *read*: Actual conversion time in milliseconds. *write*:
-                       '0': Set the default conversion time from the datasheet.
-                       '1': Measure and set the conversion time. Make a single
+               *read*:
+                       Actual conversion time in milliseconds.
+
+               *write*:
+                       * '0':
+                            Set the default conversion time from the datasheet.
+                       * '1':
+                            Measure and set the conversion time. Make a single
                             temperature conversion, measure an actual value.
                             Increase it by 20% for temperature range. A new
                             conversion time can be obtained by reading this
                             same attribute.
-                       other positive value:
+                       other positive value:
                             Set the conversion time in milliseconds.
 
 Users:         An application using the w1_term device
@@ -148,16 +170,21 @@ Description:
                (RW) Control optional driver settings.
                Bit masks to read/write (bitwise OR):
 
-                1: Enable check for conversion success. If byte 6 of
+               == ============================================================
+                 1 Enable check for conversion success. If byte 6 of
                    scratchpad memory is 0xC after conversion, and
                    temperature reads 85.00 (powerup value) or 127.94
                    (insufficient power) - return a conversion error.
 
-                2: Enable poll for conversion completion. Generate read cycles
+                2  Enable poll for conversion completion. Generate read cycles
                    after the conversion start and wait for 1's. In parasite
                    power mode this feature is not available.
+               == ============================================================
+
+               *read*:
+                   Currently selected features.
 
-               *read*:  Currently selected features.
-               *write*: Select features.
+               *write*:
+                   Select features.
 
 Users:         An application using the w1_term device
index afc48fc163b5903bdf6d41018b8dfb961a4a1b85..16acaa5712ec9d231151f4723acdcd51baaca128 100644 (file)
@@ -79,7 +79,9 @@ Description:
                When the Wacom Intuos 4 is connected over Bluetooth, the
                image has to contain 256 bytes (64x32 px 1 bit colour).
                The format is also scrambled, like in the USB mode, and it can
-               be summarized by converting 76543210 into GECA6420.
+               be summarized by converting::
+
+                                           76543210 into GECA6420.
                                            HGFEDCBA      HFDB7531
 
 What:          /sys/bus/hid/devices/<bus>:<vid>:<pid>.<n>/wacom_remote/unpair_remote
index 613f42a9d5cdcd7b6a9f754b59387065daa1576f..b16d30a71709f771136c58cb0ad939e3cece1a8d 100644 (file)
@@ -12,11 +12,14 @@ Description:
                image: The image bitmap. Currently a 32-bit BMP.
                status: 1 if the image is valid, 0 if firmware invalidated it.
                type: 0 indicates image is in BMP format.
+
+               ======== ===================================================
                version: The version of the BGRT. Currently 1.
                xoffset: The number of pixels between the left of the screen
                         and the left edge of the image.
                yoffset: The number of pixels between the top of the screen
                         and the top edge of the image.
+               ======== ===================================================
 
 What:          /sys/firmware/acpi/hotplug/
 Date:          February 2013
@@ -33,12 +36,14 @@ Description:
                The following setting is available to user space for each
                hotplug profile:
 
+               ======== =======================================================
                enabled: If set, the ACPI core will handle notifications of
-                       hotplug events associated with the given class of
-                       devices and will allow those devices to be ejected with
-                       the help of the _EJ0 control method.  Unsetting it
-                       effectively disables hotplug for the correspoinding
-                       class of devices.
+                        hotplug events associated with the given class of
+                        devices and will allow those devices to be ejected with
+                        the help of the _EJ0 control method.  Unsetting it
+                        effectively disables hotplug for the correspoinding
+                        class of devices.
+               ======== =======================================================
 
                The value of the above attribute is an integer number: 1 (set)
                or 0 (unset).  Attempts to write any other values to it will
@@ -71,86 +76,90 @@ Description:
                To figure out where all the SCI's are coming from,
                /sys/firmware/acpi/interrupts contains a file listing
                every possible source, and the count of how many
-               times it has triggered.
-
-               $ cd /sys/firmware/acpi/interrupts
-               $ grep . *
-               error:       0
-               ff_gbl_lock:       0   enable
-               ff_pmtimer:       0  invalid
-               ff_pwr_btn:       0   enable
-               ff_rt_clk:       2  disable
-               ff_slp_btn:       0  invalid
-               gpe00:       0  invalid
-               gpe01:       0   enable
-               gpe02:     108   enable
-               gpe03:       0  invalid
-               gpe04:       0  invalid
-               gpe05:       0  invalid
-               gpe06:       0   enable
-               gpe07:       0   enable
-               gpe08:       0  invalid
-               gpe09:       0  invalid
-               gpe0A:       0  invalid
-               gpe0B:       0  invalid
-               gpe0C:       0  invalid
-               gpe0D:       0  invalid
-               gpe0E:       0  invalid
-               gpe0F:       0  invalid
-               gpe10:       0  invalid
-               gpe11:       0  invalid
-               gpe12:       0  invalid
-               gpe13:       0  invalid
-               gpe14:       0  invalid
-               gpe15:       0  invalid
-               gpe16:       0  invalid
-               gpe17:    1084   enable
-               gpe18:       0   enable
-               gpe19:       0  invalid
-               gpe1A:       0  invalid
-               gpe1B:       0  invalid
-               gpe1C:       0  invalid
-               gpe1D:       0  invalid
-               gpe1E:       0  invalid
-               gpe1F:       0  invalid
-               gpe_all:    1192
-               sci:    1194
-               sci_not:     0  
-
-               sci - The number of times the ACPI SCI
-               has been called and claimed an interrupt.
-
-               sci_not - The number of times the ACPI SCI
-               has been called and NOT claimed an interrupt.
-
-               gpe_all - count of SCI caused by GPEs.
-
-               gpeXX - count for individual GPE source
-
-               ff_gbl_lock - Global Lock
-
-               ff_pmtimer - PM Timer
-
-               ff_pwr_btn - Power Button
-
-               ff_rt_clk - Real Time Clock
-
-               ff_slp_btn - Sleep Button
-
-               error - an interrupt that can't be accounted for above.
-
-               invalid: it's either a GPE or a Fixed Event that
-                       doesn't have an event handler.
-
-               disable: the GPE/Fixed Event is valid but disabled.
-
-               enable: the GPE/Fixed Event is valid and enabled.
-
-               Root has permission to clear any of these counters.  Eg.
-               # echo 0 > gpe11
-
-               All counters can be cleared by clearing the total "sci":
-               # echo 0 > sci
+               times it has triggered::
+
+                 $ cd /sys/firmware/acpi/interrupts
+                 $ grep . *
+                 error:             0
+                 ff_gbl_lock:       0   enable
+                 ff_pmtimer:        0  invalid
+                 ff_pwr_btn:        0   enable
+                 ff_rt_clk:         2  disable
+                 ff_slp_btn:        0  invalid
+                 gpe00:             0  invalid
+                 gpe01:             0   enable
+                 gpe02:           108   enable
+                 gpe03:             0  invalid
+                 gpe04:             0  invalid
+                 gpe05:             0  invalid
+                 gpe06:             0   enable
+                 gpe07:             0   enable
+                 gpe08:             0  invalid
+                 gpe09:             0  invalid
+                 gpe0A:             0  invalid
+                 gpe0B:             0  invalid
+                 gpe0C:             0  invalid
+                 gpe0D:             0  invalid
+                 gpe0E:             0  invalid
+                 gpe0F:             0  invalid
+                 gpe10:             0  invalid
+                 gpe11:             0  invalid
+                 gpe12:             0  invalid
+                 gpe13:             0  invalid
+                 gpe14:             0  invalid
+                 gpe15:             0  invalid
+                 gpe16:             0  invalid
+                 gpe17:          1084   enable
+                 gpe18:             0   enable
+                 gpe19:             0  invalid
+                 gpe1A:             0  invalid
+                 gpe1B:             0  invalid
+                 gpe1C:             0  invalid
+                 gpe1D:             0  invalid
+                 gpe1E:             0  invalid
+                 gpe1F:             0  invalid
+                 gpe_all:        1192
+                 sci:            1194
+                 sci_not:           0
+
+               ===========  ==================================================
+               sci          The number of times the ACPI SCI
+                            has been called and claimed an interrupt.
+
+               sci_not      The number of times the ACPI SCI
+                            has been called and NOT claimed an interrupt.
+
+               gpe_all      count of SCI caused by GPEs.
+
+               gpeXX        count for individual GPE source
+
+               ff_gbl_lock  Global Lock
+
+               ff_pmtimer   PM Timer
+
+               ff_pwr_btn   Power Button
+
+               ff_rt_clk    Real Time Clock
+
+               ff_slp_btn   Sleep Button
+
+               error        an interrupt that can't be accounted for above.
+
+               invalid      it's either a GPE or a Fixed Event that
+                            doesn't have an event handler.
+
+               disable      the GPE/Fixed Event is valid but disabled.
+
+               enable       the GPE/Fixed Event is valid and enabled.
+               ===========  ==================================================
+
+               Root has permission to clear any of these counters.  Eg.::
+
+                 # echo 0 > gpe11
+
+               All counters can be cleared by clearing the total "sci"::
+
+                 # echo 0 > sci
 
                None of these counters has an effect on the function
                of the system, they are simply statistics.
@@ -165,32 +174,34 @@ Description:
 
                Let's take power button fixed event for example, please kill acpid
                and other user space applications so that the machine won't shutdown
-               when pressing the power button.
-               # cat ff_pwr_btn
-               0       enabled
-               # press the power button for 3 times;
-               # cat ff_pwr_btn
-               3       enabled
-               # echo disable > ff_pwr_btn
-               # cat ff_pwr_btn
-               3       disabled
-               # press the power button for 3 times;
-               # cat ff_pwr_btn
-               3       disabled
-               # echo enable > ff_pwr_btn
-               # cat ff_pwr_btn
-               4       enabled
-               /*
-                * this is because the status bit is set even if the enable bit is cleared,
-                * and it triggers an ACPI fixed event when the enable bit is set again
-                */
-               # press the power button for 3 times;
-               # cat ff_pwr_btn
-               7       enabled
-               # echo disable > ff_pwr_btn
-               # press the power button for 3 times;
-               # echo clear > ff_pwr_btn       /* clear the status bit */
-               # echo disable > ff_pwr_btn
-               # cat ff_pwr_btn
-               7       enabled
+               when pressing the power button::
+
+                 # cat ff_pwr_btn
+                 0     enabled
+                 # press the power button for 3 times;
+                 # cat ff_pwr_btn
+                 3     enabled
+                 # echo disable > ff_pwr_btn
+                 # cat ff_pwr_btn
+                 3     disabled
+                 # press the power button for 3 times;
+                 # cat ff_pwr_btn
+                 3     disabled
+                 # echo enable > ff_pwr_btn
+                 # cat ff_pwr_btn
+                 4     enabled
+                 /*
+                  * this is because the status bit is set even if the enable
+                  * bit is cleared, and it triggers an ACPI fixed event when
+                  * the enable bit is set again
+                  */
+                 # press the power button for 3 times;
+                 # cat ff_pwr_btn
+                 7     enabled
+                 # echo disable > ff_pwr_btn
+                 # press the power button for 3 times;
+                 # echo clear > ff_pwr_btn     /* clear the status bit */
+                 # echo disable > ff_pwr_btn
+                 # cat ff_pwr_btn
+                 7     enabled
 
index 210ad44b95a557bd16b924940f283101a906d1d9..fe0289c877684958b23e31bc32cbff428a31524b 100644 (file)
@@ -33,7 +33,7 @@ Description:
                doesn't matter), they will be represented in sysfs as
                entries "T-0" through "T-(N-1)":
 
-               Example entry directories:
+               Example entry directories::
 
                        /sys/firmware/dmi/entries/17-0
                        /sys/firmware/dmi/entries/17-1
@@ -50,61 +50,65 @@ Description:
                Each DMI entry in sysfs has the common header values
                exported as attributes:
 
-               handle  : The 16bit 'handle' that is assigned to this
+               ========  =================================================
+               handle    The 16bit 'handle' that is assigned to this
                          entry by the firmware.  This handle may be
                          referred to by other entries.
-               length  : The length of the entry, as presented in the
+               length    The length of the entry, as presented in the
                          entry itself.  Note that this is _not the
                          total count of bytes associated with the
-                         entry_.  This value represents the length of
+                         entry.  This value represents the length of
                          the "formatted" portion of the entry.  This
                          "formatted" region is sometimes followed by
                          the "unformatted" region composed of nul
                          terminated strings, with termination signalled
                          by a two nul characters in series.
-               raw     : The raw bytes of the entry. This includes the
+               raw       The raw bytes of the entry. This includes the
                          "formatted" portion of the entry, the
                          "unformatted" strings portion of the entry,
                          and the two terminating nul characters.
-               type    : The type of the entry.  This value is the same
+               type      The type of the entry.  This value is the same
                          as found in the directory name.  It indicates
                          how the rest of the entry should be interpreted.
-               instance: The instance ordinal of the entry for the
+               instance  The instance ordinal of the entry for the
                          given type.  This value is the same as found
                          in the parent directory name.
-               position: The ordinal position (zero-based) of the entry
+               position  The ordinal position (zero-based) of the entry
                          within the entirety of the DMI entry table.
+               ========  =================================================
 
-               === Entry Specialization ===
+               **Entry Specialization**
 
                Some entry types may have other information available in
                sysfs.  Not all types are specialized.
 
-               --- Type 15 - System Event Log ---
+               **Type 15 - System Event Log**
 
                This entry allows the firmware to export a log of
                events the system has taken.  This information is
                typically backed by nvram, but the implementation
                details are abstracted by this table.  This entry's data
-               is exported in the directory:
+               is exported in the directory::
 
-               /sys/firmware/dmi/entries/15-0/system_event_log
+                 /sys/firmware/dmi/entries/15-0/system_event_log
 
                and has the following attributes (documented in the
                SMBIOS / DMI specification under "System Event Log (Type 15)":
 
-               area_length
-               header_start_offset
-               data_start_offset
-               access_method
-               status
-               change_token
-               access_method_address
-               header_format
-               per_log_type_descriptor_length
-               type_descriptors_supported_count
+               area_length
+               header_start_offset
+               data_start_offset
+               access_method
+               status
+               change_token
+               access_method_address
+               header_format
+               per_log_type_descriptor_length
+               type_descriptors_supported_count
 
                As well, the kernel exports the binary attribute:
 
-               raw_event_log   : The raw binary bits of the event log
+               =============     ====================================
+               raw_event_log     The raw binary bits of the event log
                                  as described by the DMI entry.
+               =============     ====================================
index 6e431d1a4e7976343adb8946d2982e40c7120080..31b57676d4ad5420ef61b62ce5a2bc1775258d30 100644 (file)
@@ -35,10 +35,13 @@ What:               /sys/firmware/efi/esrt/entries/entry$N/fw_type
 Date:          February 2015
 Contact:       Peter Jones <pjones@redhat.com>
 Description:   What kind of firmware entry this is:
-               0 - Unknown
-               1 - System Firmware
-               2 - Device Firmware
-               3 - UEFI Driver
+
+               ==  ===============
+               0   Unknown
+               1   System Firmware
+               2   Device Firmware
+               3   UEFI Driver
+               ==  ===============
 
 What:          /sys/firmware/efi/esrt/entries/entry$N/fw_class
 Date:          February 2015
@@ -71,11 +74,14 @@ Date:               February 2015
 Contact:       Peter Jones <pjones@redhat.com>
 Description:   The result of the last firmware update attempt for the
                firmware resource entry.
-               0 - Success
-               1 - Insufficient resources
-               2 - Incorrect version
-               3 - Invalid format
-               4 - Authentication error
-               5 - AC power event
-               6 - Battery power event
+
+               ==  ======================
+               0   Success
+               1   Insufficient resources
+               2   Incorrect version
+               3   Invalid format
+               4   Authentication error
+               5   AC power event
+               6   Battery power event
+               ==  ======================
 
index c61b9b348e9996da13767058d843974052680a83..9c4d581be396c4ac000236933c75aef7de3aed75 100644 (file)
@@ -14,7 +14,7 @@ Description:  Switching efi runtime services to virtual mode requires
                /sys/firmware/efi/runtime-map/ is the directory the kernel
                exports that information in.
 
-               subdirectories are named with the number of the memory range:
+               subdirectories are named with the number of the memory range::
 
                        /sys/firmware/efi/runtime-map/0
                        /sys/firmware/efi/runtime-map/1
@@ -24,11 +24,13 @@ Description:        Switching efi runtime services to virtual mode requires
 
                Each subdirectory contains five files:
 
-               attribute : The attributes of the memory range.
-               num_pages : The size of the memory range in pages.
-               phys_addr : The physical address of the memory range.
-               type      : The type of the memory range.
-               virt_addr : The virtual address of the memory range.
+               =========   =========================================
+               attribute   The attributes of the memory range.
+               num_pages   The size of the memory range in pages.
+               phys_addr   The physical address of the memory range.
+               type        The type of the memory range.
+               virt_addr   The virtual address of the memory range.
+               =========   =========================================
 
                Above values are all hexadecimal numbers with the '0x' prefix.
 Users:         Kexec
index 0faa0aaf4b6af88e1f4668aca0e147e26d9a438b..7a558354c1ee0182d354fe3c490d0c571abf96cb 100644 (file)
@@ -20,7 +20,7 @@ Description:
 
                        This directory has the same layout (and
                        underlying implementation as /sys/firmware/efi/vars.
-                       See Documentation/ABI/*/sysfs-firmware-efi-vars
+                       See `Documentation/ABI/*/sysfs-firmware-efi-vars`
                        for more information on how to interact with
                        this structure.
 
index eca0d65087dc4239352add5f2167a85ae7a179e8..1f6f4d3a32c06f8f61775a73ec6b08dec8c458a2 100644 (file)
@@ -20,7 +20,7 @@ Description:
                the raw memory map to userspace.
 
                The structure is as follows: Under /sys/firmware/memmap there
-               are subdirectories with the number of the entry as their name:
+               are subdirectories with the number of the entry as their name::
 
                        /sys/firmware/memmap/0
                        /sys/firmware/memmap/1
@@ -34,14 +34,16 @@ Description:
 
                Each directory contains three files:
 
-               start   : The start address (as hexadecimal number with the
+               ========  =====================================================
+               start     The start address (as hexadecimal number with the
                          '0x' prefix).
-               end     : The end address, inclusive (regardless whether the
+               end       The end address, inclusive (regardless whether the
                          firmware provides inclusive or exclusive ranges).
-               type    : Type of the entry as string. See below for a list of
+               type      Type of the entry as string. See below for a list of
                          valid types.
+               ========  =====================================================
 
-               So, for example:
+               So, for example::
 
                        /sys/firmware/memmap/0/start
                        /sys/firmware/memmap/0/end
@@ -57,9 +59,8 @@ Description:
                  - reserved
 
                Following shell snippet can be used to display that memory
-               map in a human-readable format:
+               map in a human-readable format::
 
-               -------------------- 8< ----------------------------------------
                  #!/bin/bash
                  cd /sys/firmware/memmap
                  for dir in * ; do
@@ -68,4 +69,3 @@ Description:
                      type=$(cat $dir/type)
                      printf "%016x-%016x (%s)\n" $start $[ $end +1] "$type"
                  done
-               -------------------- >8 ----------------------------------------
index 011dda4f8e8a062d257c024db3ed0b948a46a768..ee0d6dbc810e5fc5604bd87e235ef74a3c3afce7 100644 (file)
@@ -15,7 +15,7 @@ Description:
                to the fw_cfg device can be found in "docs/specs/fw_cfg.txt"
                in the QEMU source tree.
 
-               === SysFS fw_cfg Interface ===
+               **SysFS fw_cfg Interface**
 
                The fw_cfg sysfs interface described in this document is only
                intended to display discoverable blobs (i.e., those registered
@@ -31,7 +31,7 @@ Description:
 
                        /sys/firmware/qemu_fw_cfg/rev
 
-               --- Discoverable fw_cfg blobs by selector key ---
+               **Discoverable fw_cfg blobs by selector key**
 
                All discoverable blobs listed in the fw_cfg file directory are
                displayed as entries named after their unique selector key
@@ -45,24 +45,26 @@ Description:
                Each such fw_cfg sysfs entry has the following values exported
                as attributes:
 
-               name    : The 56-byte nul-terminated ASCII string used as the
+               ====      ====================================================
+               name      The 56-byte nul-terminated ASCII string used as the
                          blob's 'file name' in the fw_cfg directory.
-               size    : The length of the blob, as given in the fw_cfg
+               size      The length of the blob, as given in the fw_cfg
                          directory.
-               key     : The value of the blob's selector key as given in the
+               key       The value of the blob's selector key as given in the
                          fw_cfg directory. This value is the same as used in
                          the parent directory name.
-               raw     : The raw bytes of the blob, obtained by selecting the
+               raw       The raw bytes of the blob, obtained by selecting the
                          entry via the control register, and reading a number
                          of bytes equal to the blob size from the data
                          register.
+               ====      ====================================================
 
-               --- Listing fw_cfg blobs by file name ---
+               **Listing fw_cfg blobs by file name**
 
                While the fw_cfg device does not impose any specific naming
                convention on the blobs registered in the file directory,
                QEMU developers have traditionally used path name semantics
-               to give each blob a descriptive name. For example:
+               to give each blob a descriptive name. For example::
 
                        "bootorder"
                        "genroms/kvmvapic.bin"
@@ -81,7 +83,7 @@ Description:
                of directories matching the path name components of fw_cfg
                blob names, ending in symlinks to the by_key entry for each
                "basename", as illustrated below (assume current directory is
-               /sys/firmware):
+               /sys/firmware)::
 
                    qemu_fw_cfg/by_name/bootorder -> ../by_key/38
                    qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35
index 4be7d44aeacf88fc7ad77f707684ae5aee5dc161..5210e0f06ddbe9982420cdf0da7eb57907630184 100644 (file)
@@ -9,7 +9,7 @@ Description:
                http://simplefirmware.org/documentation
 
                While the tables are used by the kernel, user-space
-               can observe them this way:
+               can observe them this way::
 
-               # cd /sys/firmware/sfi/tables
-               # cat $TABLENAME > $TABLENAME.bin
+                 # cd /sys/firmware/sfi/tables
+                 # cat $TABLENAME > $TABLENAME.bin
index 4573fd4b7876cfd1c3d80281f8b4101df35ba1f4..66800baab0965e8438d37a5bd0375b2d45d0c20c 100644 (file)
@@ -5,7 +5,7 @@ Description:
                The /sys/firmware/sgi_uv directory contains information
                about the SGI UV platform.
 
-               Under that directory are a number of files:
+               Under that directory are a number of files::
 
                        partition_id
                        coherence_id
@@ -14,7 +14,7 @@ Description:
                SGI UV systems can be partitioned into multiple physical
                machines, which each partition running a unique copy
                of the operating system.  Each partition will have a unique
-               partition id.  To display the partition id, use the command:
+               partition id.  To display the partition id, use the command::
 
                        cat /sys/firmware/sgi_uv/partition_id
 
@@ -22,6 +22,6 @@ Description:
                A partitioned SGI UV system can have one or more coherence
                domain.  The coherence id indicates which coherence domain
                this partition is in.  To display the coherence id, use the
-               command:
+               command::
 
                        cat /sys/firmware/sgi_uv/coherence_id
index 15595fab88d18469030d5f7f2d500cca44afdbf1..b8631f5a29c4c5779347333098ac14252293dbe3 100644 (file)
@@ -2,21 +2,21 @@ What:         /sys/firmware/turris-mox-rwtm/board_version
 Date:          August 2019
 KernelVersion: 5.4
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Board version burned into eFuses of this Turris Mox board.
+Description:   (Read) Board version burned into eFuses of this Turris Mox board.
                Format: %i
 
 What:          /sys/firmware/turris-mox-rwtm/mac_address*
 Date:          August 2019
 KernelVersion: 5.4
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) MAC addresses burned into eFuses of this Turris Mox board.
+Description:   (Read) MAC addresses burned into eFuses of this Turris Mox board.
                Format: %pM
 
 What:          /sys/firmware/turris-mox-rwtm/pubkey
 Date:          August 2019
 KernelVersion: 5.4
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) ECDSA public key (in pubkey hex compressed form) computed
+Description:   (Read) ECDSA public key (in pubkey hex compressed form) computed
                as pair to the ECDSA private key burned into eFuses of this
                Turris Mox Board.
                Format: string
@@ -25,7 +25,7 @@ What:         /sys/firmware/turris-mox-rwtm/ram_size
 Date:          August 2019
 KernelVersion: 5.4
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) RAM size in MiB of this Turris Mox board as was detected
+Description:   (Read) RAM size in MiB of this Turris Mox board as was detected
                during manufacturing and burned into eFuses. Can be 512 or 1024.
                Format: %i
 
@@ -33,5 +33,5 @@ What:         /sys/firmware/turris-mox-rwtm/serial_number
 Date:          August 2019
 KernelVersion: 5.4
 Contact:       Marek Behún <marek.behun@nic.cz>
-Description:   (R) Serial number burned into eFuses of this Turris Mox device.
+Description:   (Read) Serial number burned into eFuses of this Turris Mox device.
                Format: %016X
index 78604db56279966246980c2070657bf32667a0cf..99e3d92f8299c9a2ff390da172655f38e9bfc5e3 100644 (file)
@@ -45,8 +45,8 @@ Description:
                parameter will have their blocks allocated out of a
                block group specific preallocation pool, so that small
                files are packed closely together.  Each large file
-                will have its blocks allocated out of its own unique
-                preallocation pool.
+               will have its blocks allocated out of its own unique
+               preallocation pool.
 
 What:          /sys/fs/ext4/<disk>/inode_readahead_blks
 Date:          March 2008
index 834d0becae6ddf9a74438b6318764f82789815eb..67b3ed8e8c2f7305592b09ccb347694e81a9d9f4 100644 (file)
@@ -20,10 +20,13 @@ What:               /sys/fs/f2fs/<disk>/gc_idle
 Date:          July 2013
 Contact:       "Namjae Jeon" <namjae.jeon@samsung.com>
 Description:   Controls the victim selection policy for garbage collection.
-               Setting gc_idle = 0(default) will disable this option. Setting
-               gc_idle = 1 will select the Cost Benefit approach & setting
-               gc_idle = 2 will select the greedy approach & setting
-               gc_idle = 3 will select the age-threshold based approach.
+               Setting gc_idle = 0(default) will disable this option. Setting:
+
+               ===========  ===============================================
+               gc_idle = 1  will select the Cost Benefit approach & setting
+               gc_idle = 2  will select the greedy approach & setting
+               gc_idle = 3  will select the age-threshold based approach.
+               ===========  ===============================================
 
 What:          /sys/fs/f2fs/<disk>/reclaim_segments
 Date:          October 2013
@@ -46,10 +49,17 @@ Date:               November 2013
 Contact:       "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
 Description:   Controls the in-place-update policy.
                updates in f2fs. User can set:
-               0x01: F2FS_IPU_FORCE, 0x02: F2FS_IPU_SSR,
-               0x04: F2FS_IPU_UTIL,  0x08: F2FS_IPU_SSR_UTIL,
-               0x10: F2FS_IPU_FSYNC, 0x20: F2FS_IPU_ASYNC,
-               0x40: F2FS_IPU_NOCACHE.
+
+               ====  =================
+               0x01  F2FS_IPU_FORCE
+               0x02  F2FS_IPU_SSR
+               0x04  F2FS_IPU_UTIL
+               0x08  F2FS_IPU_SSR_UTIL
+               0x10  F2FS_IPU_FSYNC
+               0x20  F2FS_IPU_ASYNC,
+               0x40  F2FS_IPU_NOCACHE
+               ====  =================
+
                Refer segment.h for details.
 
 What:          /sys/fs/f2fs/<disk>/min_ipu_util
@@ -332,18 +342,28 @@ Date:             April 2020
 Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:   Give a way to attach REQ_META|FUA to data writes
                given temperature-based bits. Now the bits indicate:
-               *      REQ_META     |      REQ_FUA      |
-               *    5 |    4 |   3 |    2 |    1 |   0 |
-               * Cold | Warm | Hot | Cold | Warm | Hot |
+
+               +-------------------+-------------------+
+               |      REQ_META     |      REQ_FUA      |
+               +------+------+-----+------+------+-----+
+               |    5 |    4 |   3 |    2 |    1 |   0 |
+               +------+------+-----+------+------+-----+
+               | Cold | Warm | Hot | Cold | Warm | Hot |
+               +------+------+-----+------+------+-----+
 
 What:          /sys/fs/f2fs/<disk>/node_io_flag
 Date:          June 2020
 Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:   Give a way to attach REQ_META|FUA to node writes
                given temperature-based bits. Now the bits indicate:
-               *      REQ_META     |      REQ_FUA      |
-               *    5 |    4 |   3 |    2 |    1 |   0 |
-               * Cold | Warm | Hot | Cold | Warm | Hot |
+
+               +-------------------+-------------------+
+               |      REQ_META     |      REQ_FUA      |
+               +------+------+-----+------+------+-----+
+               |    5 |    4 |   3 |    2 |    1 |   0 |
+               +------+------+-----+------+------+-----+
+               | Cold | Warm | Hot | Cold | Warm | Hot |
+               +------+------+-----+------+------+-----+
 
 What:          /sys/fs/f2fs/<disk>/iostat_period_ms
 Date:          April 2020
index 53b7b2ea75154b86e80fbfcf086eca307a32cee9..4dbe0c49b393e5e476c8046d987d56b0a8324de1 100644 (file)
@@ -15,14 +15,17 @@ KernelVersion:      4.3
 Contact:       Boris Ostrovsky <boris.ostrovsky@oracle.com>
 Description:   If running under Xen:
                Describes mode that Xen's performance-monitoring unit (PMU)
-               uses. Accepted values are
-                       "off"  -- PMU is disabled
-                       "self" -- The guest can profile itself
-                       "hv"   -- The guest can profile itself and, if it is
+               uses. Accepted values are:
+
+                       ======    ============================================
+                       "off"     PMU is disabled
+                       "self"    The guest can profile itself
+                       "hv"      The guest can profile itself and, if it is
                                  privileged (e.g. dom0), the hypervisor
-                       "all" --  The guest can profile itself, the hypervisor
+                       "all"     The guest can profile itself, the hypervisor
                                  and all other guests. Only available to
                                  privileged guests.
+                       ======    ============================================
 
 What:           /sys/hypervisor/pmu/pmu_features
 Date:           August 2015
index eca38ce2852d3ab27cba5559aa6db655ba0301bf..7f9bda453c4d1a4bfdcf57031127fa38be610799 100644 (file)
@@ -23,16 +23,17 @@ Description:        The /sys/kernel/boot_params directory contains two
                representation of setup_data type. "data" file is the binary
                representation of setup_data payload.
 
-               The whole boot_params directory structure is like below:
-               /sys/kernel/boot_params
-               |__ data
-               |__ setup_data
-               |   |__ 0
-               |   |   |__ data
-               |   |   |__ type
-               |   |__ 1
-               |       |__ data
-               |       |__ type
-               |__ version
+               The whole boot_params directory structure is like below::
+
+                 /sys/kernel/boot_params
+                 |__ data
+                 |__ setup_data
+                 |   |__ 0
+                 |   |   |__ data
+                 |   |   |__ type
+                 |   |__ 1
+                 |       |__ data
+                 |       |__ type
+                 |__ version
 
 Users:         Kexec
index fdaa2162fae1528529b7045c6e9184ae9620bc01..294387e2c7fb58901cdb0bac3e4ddc75298d7d28 100644 (file)
@@ -7,9 +7,11 @@ Description:
                of the hugepages supported by the kernel/CPU combination.
 
                Under these directories are a number of files:
-                       nr_hugepages
-                       nr_overcommit_hugepages
-                       free_hugepages
-                       surplus_hugepages
-                       resv_hugepages
+
+                       - nr_hugepages
+                       - nr_overcommit_hugepages
+                       - free_hugepages
+                       - surplus_hugepages
+                       - resv_hugepages
+
                See Documentation/admin-guide/mm/hugetlbpage.rst for details.
index dfc13244cda3bb567591fbd6cbcfaee6905731c6..1c9bed5595f5d2b5273fc399b00439d828c4d06b 100644 (file)
@@ -34,8 +34,9 @@ Description:  Kernel Samepage Merging daemon sysfs interface
                in a tree.
 
                run: write 0 to disable ksm, read 0 while ksm is disabled.
-                       write 1 to run ksm, read 1 while ksm is running.
-                       write 2 to disable ksm and unmerge all its pages.
+
+                       - write 1 to run ksm, read 1 while ksm is running.
+                       - write 2 to disable ksm and unmerge all its pages.
 
                sleep_millisecs: how many milliseconds ksm should sleep between
                scans.
index ed35833ad7f05592c53fa615bcf72126de404821..c9f12baf8baac812456058549536f2b717627dd7 100644 (file)
@@ -346,6 +346,7 @@ Description:
                number of objects per slab.  If a slab cannot be allocated
                because of fragmentation, SLUB will retry with the minimum order
                possible depending on its characteristics.
+
                When debug_guardpage_minorder=N (N > 0) parameter is specified
                (see Documentation/admin-guide/kernel-parameters.rst), the minimum possible
                order is used and this sysfs entry can not be used to change
@@ -361,6 +362,7 @@ Description:
                new slab has not been possible at the cache's order and instead
                fallen back to its minimum possible order.  It can be written to
                clear the current count.
+
                Available when CONFIG_SLUB_STATS is enabled.
 
 What:          /sys/kernel/slab/cache/partial
@@ -410,6 +412,7 @@ Description:
                slab from a remote node as opposed to allocating a new slab on
                the local node.  This reduces the amount of wasted memory over
                the entire system but can be expensive.
+
                Available when CONFIG_NUMA is enabled.
 
 What:          /sys/kernel/slab/cache/sanity_checks
index 0aac02e7fb0e22e532dca3aca30c6fe7472bef95..353c0db5bc1f584a09176772d91daf61639084d7 100644 (file)
@@ -17,14 +17,15 @@ KernelVersion:      3.1
 Contact:       Kirill Smelkov <kirr@mns.spb.ru>
 Description:   Maximum time allowed for periodic transfers per microframe (μs)
 
-               [ USB 2.0 sets maximum allowed time for periodic transfers per
+               Note:
+                 USB 2.0 sets maximum allowed time for periodic transfers per
                  microframe to be 80%, that is 100 microseconds out of 125
                  microseconds (full microframe).
 
                  However there are cases, when 80% max isochronous bandwidth is
                  too limiting. For example two video streams could require 110
                  microseconds of isochronous bandwidth per microframe to work
-                 together. ]
+                 together. 
 
                Through this setting it is possible to raise the limit so that
                the host controller would allow allocating more than 100
@@ -45,8 +46,10 @@ Date:                Jan 2012
 KernelVersion:»·3.3
 Contact:       Kay Sievers <kay.sievers@vrfy.org>
 Description:   Module taint flags:
-                       P - proprietary module
-                       O - out-of-tree module
-                       F - force-loaded module
-                       C - staging driver module
-                       E - unsigned module
+                       ==  =====================
+                       P   proprietary module
+                       O   out-of-tree module
+                       F   force-loaded module
+                       C   staging driver module
+                       E   unsigned module
+                       ==  =====================
index 8b0e8205a6a2451331b4c38d4b532742ee2b83ac..c78d358dbdbede7a7088e526f0abf3b77ae0f872 100644 (file)
@@ -4,13 +4,16 @@ KernelVersion:        2.6.20
 Contact:       "Corentin Chary" <corentincj@iksaif.net>
 Description:
                This file allows display switching. The value
-               is composed by 4 bits and defined as follow:
-               4321
-               |||`- LCD
-               ||`-- CRT
-               |`--- TV
-               `---- DVI
-               Ex: - 0 (0000b) means no display
+               is composed by 4 bits and defined as follow::
+
+                 4321
+                 |||`- LCD
+                 ||`-- CRT
+                 |`--- TV
+                 `---- DVI
+
+               Ex:
+                   - 0 (0000b) means no display
                    - 3 (0011b) CRT+LCD.
 
 What:          /sys/devices/platform/asus_laptop/gps
@@ -28,8 +31,10 @@ Contact:     "Corentin Chary" <corentincj@iksaif.net>
 Description:
                Some models like the W1N have a LED display that can be
                used to display several items of information.
-               To control the LED display, use the following :
+               To control the LED display, use the following::
+
                    echo 0x0T000DDD > /sys/devices/platform/asus_laptop/
+
                where T control the 3 letters display, and DDD the 3 digits display.
                The DDD table can be found in Documentation/admin-guide/laptops/asus-laptop.rst
 
index 1efac0ddb417e0b04ffeeb11573eca9488147f06..04885738cf156987afd64c12b035d1b7736cf772 100644 (file)
@@ -5,6 +5,7 @@ Contact:        "Corentin Chary" <corentincj@iksaif.net>
 Description:
                Change CPU clock configuration (write-only).
                There are three available clock configuration:
+
                    * 0 -> Super Performance Mode
                    * 1 -> High Performance Mode
                    * 2 -> Power Saving Mode
index 4cc6a865ae662f6252057aff396d42d837a566b6..b146be74b8e0d225a8c031b8cc67a73c8524e116 100644 (file)
@@ -18,8 +18,10 @@ Description:
                In order to use an extended can_id add the
                CAN_EFF_FLAG (0x80000000U) to the can_id. Example:
 
-               - standard id 0x7ff:
-               echo 0x7ff      > /sys/class/net/can0/mb0_id
+               - standard id 0x7ff::
 
-               - extended id 0x1fffffff:
-               echo 0x9fffffff > /sys/class/net/can0/mb0_id
+                   echo 0x7ff      > /sys/class/net/can0/mb0_id
+
+               - extended id 0x1fffffff::
+
+                   echo 0x9fffffff > /sys/class/net/can0/mb0_id
index 9b917c7453dee769d17f90c593861255c2ef6daf..82bcfe9df66eefc41334dbd73f6294e059eeae2e 100644 (file)
@@ -34,9 +34,12 @@ Description:
                this file. To disable a trigger, write its name preceded
                by '-' instead.
 
-               For example, to enable the keyboard as trigger run:
+               For example, to enable the keyboard as trigger run::
+
                    echo +keyboard > /sys/class/leds/dell::kbd_backlight/start_triggers
-               To disable it:
+
+               To disable it::
+
                    echo -keyboard > /sys/class/leds/dell::kbd_backlight/start_triggers
 
                Note that not all the available triggers can be configured.
@@ -57,7 +60,8 @@ Description:
                with any the above units. If no unit is specified, the value
                is assumed to be expressed in seconds.
 
-               For example, to set the timeout to 10 minutes run:
+               For example, to set the timeout to 10 minutes run::
+
                    echo 10m > /sys/class/leds/dell::kbd_backlight/stop_timeout
 
                Note that when this file is read, the returned value might be
index 205d3b6361e0db9c3c653f56928c6d8609ee000d..e6e0f7f834a7434aa3844c03e65ffbdbd06efb16 100644 (file)
@@ -13,8 +13,8 @@ Description:
                For example the token ID "5" would be available
                as the following attributes:
 
-               0005_location
-               0005_value
+               0005_location
+               0005_value
 
                Tokens will vary from machine to machine, and
                only tokens available on that machine will be
index 3683cb1cdc3de80141134b1563415e590bfce646..d6ab34e81b9b3b6146f7144222571ad176450f95 100644 (file)
@@ -113,8 +113,11 @@ KernelVersion:     5.5
 Contact:       Wu Hao <hao.wu@intel.com>
 Description:   Read-Only. Read this file to get the name of hwmon device, it
                supports values:
-                   'dfl_fme_thermal' - thermal hwmon device name
-                   'dfl_fme_power'   - power hwmon device name
+
+               =================  =========================
+               'dfl_fme_thermal'  thermal hwmon device name
+               'dfl_fme_power'    power hwmon device name
+               =================  =========================
 
 What:          /sys/bus/platform/devices/dfl-fme.0/hwmon/hwmonX/temp1_input
 Date:          October 2019
@@ -169,8 +172,11 @@ KernelVersion:     5.5
 Contact:       Wu Hao <hao.wu@intel.com>
 Description:   Read-Only. Read this file to get the policy of hardware threshold1
                (see 'temp1_max'). It only supports two values (policies):
-                   0 - AP2 state (90% throttling)
-                   1 - AP1 state (50% throttling)
+
+               ==  ==========================
+                0  AP2 state (90% throttling)
+                1  AP1 state (50% throttling)
+               ==  ==========================
 
 What:          /sys/bus/platform/devices/dfl-fme.0/hwmon/hwmonX/power1_input
 Date:          October 2019
index 2cbc660d163b25e3e944b768b63604567984ad78..141834342a4dd01c0f559c2d071e8f59cbdbe132 100644 (file)
@@ -27,12 +27,15 @@ KernelVersion:      v4.10
 Contact:       linux-acpi@vger.kernel.org
 Description:
                (RO) Display the platform power source
+
+               ========= ============================
                bits[3:0] Current power source
-                       0x00 = DC
-                       0x01 = AC
-                       0x02 = USB
-                       0x03 = Wireless Charger
+                         - 0x00 = DC
+                         - 0x01 = AC
+                         - 0x02 = USB
+                         - 0x03 = Wireless Charger
                bits[7:4] Power source sequence number
+               ========= ============================
 
 What:          /sys/bus/platform/devices/INT3407:00/dptf_power/battery_steady_power
 Date:          Jul, 2016
index 5b026c69587ac881efbcdf3fff697722f9df2301..70dbe0733cf622e7c36086329802e488e2b128bc 100644 (file)
@@ -4,9 +4,11 @@ KernelVersion: 2.6.26
 Contact:       "Corentin Chary" <corentincj@iksaif.net>
 Description:
                This file allows display switching.
+
                - 1 = LCD
                - 2 = CRT
                - 3 = LCD+CRT
+
                If you run X11, you should use xrandr instead.
 
 What:          /sys/devices/platform/eeepc/camera
@@ -30,16 +32,20 @@ Contact:    "Corentin Chary" <corentincj@iksaif.net>
 Description:
                Change CPU clock configuration.
                On the Eee PC 1000H there are three available clock configuration:
+
                    * 0 -> Super Performance Mode
                    * 1 -> High Performance Mode
                    * 2 -> Power Saving Mode
+
                On Eee PC 701 there is only 2 available clock configurations.
                Available configuration are listed in available_cpufv file.
                Reading this file will show the raw hexadecimal value which
-               is defined as follow:
-               | 8 bit | 8 bit |
-                   |       `---- Current mode
-                   `------------ Availables modes
+               is defined as follow::
+
+                 | 8 bit | 8 bit |
+                     |       `---- Current mode
+                     `------------ Availables modes
+
                For example, 0x301 means: mode 1 selected, 3 available modes.
 
 What:          /sys/devices/platform/eeepc/available_cpufv
index c394b808be197221e9e7958a0e17c00a5b006efc..b6a138b50d994a326e6055bd5f70c8cb207cf6df 100644 (file)
@@ -5,9 +5,9 @@ Contact:        Wolfram Sang <wsa+renesas@sang-engineering.com>
 Description:
                Reading the file will give you a list of masters which can be
                selected for a demultiplexed bus. The format is
-               "<index>:<name>". Example from a Renesas Lager board:
+               "<index>:<name>". Example from a Renesas Lager board::
 
-               0:/i2c@e6500000 1:/i2c@e6508000
+                 0:/i2c@e6500000 1:/i2c@e6508000
 
 What:          /sys/devices/platform/<i2c-demux-name>/current_master
 Date:          January 2016
index 1b31be3f996a40df66299e4715ee4eb984ec12e1..fd2ac02bc5bd8b6fae8314a4598304f3a8fe7bd5 100644 (file)
@@ -12,6 +12,7 @@ Contact:      "Maxim Mikityanskiy <maxtram95@gmail.com>"
 Description:
                Change fan mode
                There are four available modes:
+
                        * 0 -> Super Silent Mode
                        * 1 -> Standard Mode
                        * 2 -> Dust Cleaning
@@ -32,9 +33,11 @@ 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
+               For example::
+
+                 # echo "0" >  \
+                 /sys/bus/pci/devices/0000:00:1f.0/PNP0C09:00/VPC2004:00/fn_lock
index 5aa618987cad6dafb7fdabfd5699124862115aa5..02ae1e9bbfc8d0edeb3c16efd445d69df9f6f2cb 100644 (file)
@@ -8,5 +8,6 @@ Description:
                of 0 and userspace can signal SBL to update firmware,
                on next reboot, by writing a value of 1.
                There are two available states:
+
                    * 0 -> Skip firmware update while rebooting
                    * 1 -> Attempt firmware update on next reboot
index 8af65059d51907de713066d243e73848346bf0e0..e19144fd5d8694db7823d3e2952026199ed9381d 100644 (file)
@@ -7,5 +7,6 @@ Description:
                Thunderbolt controllers to turn on or off when no
                devices are connected (write-only)
                There are two available states:
+
                    * 0 -> Force power disabled
                    * 1 -> Force power enabled
index c1653271872a9ff7d38306558c0f9c2e78fb6abf..a7f81de68046167220459f4e0eef4a53defec572 100644 (file)
@@ -5,6 +5,7 @@ Contact:        "Pavan Savoy" <pavan_savoy@ti.com>
 Description:
                Name of the UART device at which the WL128x chip
                is connected. example: "/dev/ttyS0".
+
                The device name flows down to architecture specific board
                initialization file from the SFI/ATAGS bootloader
                firmware. The name exposed is read from the user-space
index 401d202f478b230014ce7a6ee247cbea76dc45da..e79ca22e2f459b4af1ac7d9e8ff52641c56cfca0 100644 (file)
@@ -5,10 +5,13 @@ Contact:      "Liming Sun <lsun@mellanox.com>"
 Description:
                The Life-cycle state of the SoC, which could be one of the
                following values.
-                 Production - Production state and can be updated to secure
-                 GA Secured - Secure chip and not able to change state
-                 GA Non-Secured - Non-Secure chip and not able to change state
-                 RMA - Return Merchandise Authorization
+
+               ==============  =============================================
+               Production      Production state and can be updated to secure
+               GA Secured      Secure chip and not able to change state
+               GA Non-Secured  Non-Secure chip and not able to change state
+               RMA             Return Merchandise Authorization
+               ==============  =============================================
 
 What:          /sys/bus/platform/devices/MLNXBF04:00/post_reset_wdog
 Date:          Oct 2019
@@ -25,10 +28,13 @@ KernelVersion:      5.5
 Contact:       "Liming Sun <lsun@mellanox.com>"
 Description:
                The source of the boot stream for the next reset. It could be
-               one of the following values.
-                 external - boot from external source (USB or PCIe)
-                 emmc - boot from the onchip eMMC
-                 emmc_legacy - boot from the onchip eMMC in legacy (slow) mode
+               one of the following values:
+
+               ===========  ===============================================
+               external     boot from external source (USB or PCIe)
+               emmc         boot from the onchip eMMC
+               emmc_legacy  boot from the onchip eMMC in legacy (slow) mode
+               ===========  ===============================================
 
 What:          /sys/bus/platform/devices/MLNXBF04:00/second_reset_action
 Date:          Oct 2019
@@ -38,11 +44,14 @@ Description:
                Update the source of the boot stream after next reset. It could
                be one of the following values and will be applied after next
                reset.
-                 external - boot from external source (USB or PCIe)
-                 emmc - boot from the onchip eMMC
-                 emmc_legacy - boot from the onchip eMMC in legacy (slow) mode
-                 swap_emmc - swap the primary / secondary boot partition
-                 none - cancel the action
+
+               ===========  ===============================================
+               external     boot from external source (USB or PCIe)
+               emmc         boot from the onchip eMMC
+               emmc_legacy  boot from the onchip eMMC in legacy (slow) mode
+               swap_emmc    swap the primary / secondary boot partition
+               none         cancel the action
+               ===========  ===============================================
 
 What:          /sys/bus/platform/devices/MLNXBF04:00/secure_boot_fuse_state
 Date:          Oct 2019
@@ -50,9 +59,12 @@ KernelVersion:       5.5
 Contact:       "Liming Sun <lsun@mellanox.com>"
 Description:
                The state of eFuse versions with the following values.
-                 InUse - burnt, valid and currently in use
-                 Used - burnt and valid
-                 Free - not burnt and free to use
-                 Skipped - not burnt but not free (skipped)
-                 Wasted - burnt and invalid
-                 Invalid - not burnt but marked as valid (error state).
+
+               =======  ===============================================
+               InUse    burnt, valid and currently in use
+               Used     burnt and valid
+               Free     not burnt and free to use
+               Skipped  not burnt but not free (skipped)
+               Wasted   burnt and invalid
+               Invalid  not burnt but marked as valid (error state).
+               =======  ===============================================
index 6212697bbf6f5775c3d2614b1817b2cb138a0d48..bc510ccc37a7bf0d446d027b926cd077db8ab850 100644 (file)
@@ -7,9 +7,11 @@ Description:
                The file can show/change the phy mode for role swap of usb.
 
                Write the following strings to change the mode:
-                "host" - switching mode from peripheral to host.
-                "peripheral" - switching mode from host to peripheral.
+
+                - "host" - switching mode from peripheral to host.
+                - "peripheral" - switching mode from host to peripheral.
 
                Read the file, then it shows the following strings:
-                "host" - The mode is host now.
-                "peripheral" - The mode is peripheral now.
+
+                - "host" - The mode is host now.
+                - "peripheral" - The mode is peripheral now.
index 5621c15d5dc0c30756f77971e44919211834a458..8af5b9c3fabbf07bb87cd5e44607cb0680c60f28 100644 (file)
@@ -7,9 +7,11 @@ Description:
                The file can show/change the drd mode of usb.
 
                Write the following string to change the mode:
-                "host" - switching mode from peripheral to host.
-                "peripheral" - switching mode from host to peripheral.
+
+               - "host" - switching mode from peripheral to host.
+               - "peripheral" - switching mode from host to peripheral.
 
                Read the file, then it shows the following strings:
-                "host" - The mode is host now.
-                "peripheral" - The mode is peripheral now.
+               
+               - "host" - The mode is host now.
+               - "peripheral" - The mode is peripheral now.
index 0d07c0395660e68b0754923456550d31e8dbabdb..d5f6e21f0e4280fbaaeffeb4d5e8aa667894674d 100644 (file)
@@ -5,13 +5,22 @@ Contact:      "Sebastien Guiriec" <sebastien.guiriec@intel.com>
 Description:
                LPE Firmware version for SST driver on all atom
                plaforms (BYT/CHT/Merrifield/BSW).
-               If the FW has never been loaded it will display:
+               If the FW has never been loaded it will display::
+
                        "FW not yet loaded"
-               If FW has been loaded it will display:
+
+               If FW has been loaded it will display::
+
                        "v01.aa.bb.cc"
+
                aa: Major version is reflecting SoC version:
+
+                       === =============
                        0d: BYT FW
                        0b: BSW FW
                        07: Merrifield FW
+                       === =============
+
                bb: Minor version
+
                cc: Build version
index 81fcfb45491382ea315484bc8feffbcf5f9b7138..53622d3ba27c64a3e3a0526f46684436a963eb3a 100644 (file)
@@ -16,10 +16,13 @@ Contact:    Krzysztof Opasiak <k.opasiak@samsung.com>
 Description:
                Current status of the device.
                Allowed values:
-               1 - Device is available and can be exported
-               2 - Device is currently exported
-               3 - Fatal error occurred during communication
-                 with peer
+
+               ==  ==========================================
+               1   Device is available and can be exported
+               2   Device is currently exported
+               3   Fatal error occurred during communication
+                   with peer
+               ==  ==========================================
 
 What:          /sys/devices/platform/usbip-vudc.%d/usbip_sockfd
 Date:          April 2016
index 5f60b184a5a5e1fb5314bad202eb218dc5dbaab3..4439d064409173fc1b91e7590fcd378e60f58cdc 100644 (file)
@@ -39,6 +39,7 @@ Description:
                which affects charging via the special USB PowerShare port
                (marked with a small lightning bolt or battery icon) when in
                low power states:
+
                - In S0, the port will always provide power.
                - In S0ix, if usb_charge is enabled, then power will be
                  supplied to the port when on AC or if battery is > 50%.
index 5e6ead29124ccefb781645ba1b00af77f242367e..51c0f578bfce53ffa844d2cee44125eb6e84a353 100644 (file)
@@ -47,14 +47,18 @@ Description:
                suspend-to-disk mechanism.  Reading from this file returns
                the name of the method by which the system will be put to
                sleep on the next suspend.  There are four methods supported:
+
                'firmware' - means that the memory image will be saved to disk
                by some firmware, in which case we also assume that the
                firmware will handle the system suspend.
+
                'platform' - the memory image will be saved by the kernel and
                the system will be put to sleep by the platform driver (e.g.
                ACPI or other PM registers).
+
                'shutdown' - the memory image will be saved by the kernel and
                the system will be powered off.
+
                'reboot' - the memory image will be saved by the kernel and
                the system will be rebooted.
 
@@ -74,12 +78,12 @@ Description:
                The suspend-to-disk method may be chosen by writing to this
                file one of the accepted strings:
 
-               'firmware'
-               'platform'
-               'shutdown'
-               'reboot'
-               'testproc'
-               'test'
+               'firmware'
+               'platform'
+               'shutdown'
+               'reboot'
+               'testproc'
+               'test'
 
                It will only change to 'firmware' or 'platform' if the system
                supports that.
@@ -114,9 +118,9 @@ Description:
                string representing a nonzero integer into it.
 
                To use this debugging feature you should attempt to suspend
-               the machine, then reboot it and run
+               the machine, then reboot it and run::
 
-               dmesg -s 1000000 | grep 'hash matches'
+                 dmesg -s 1000000 | grep 'hash matches'
 
                If you do not get any matches (or they appear to be false
                positives), it is possible that the last PM event point
@@ -244,6 +248,7 @@ Description:
                wakeup sources created with the help of /sys/power/wake_lock.
                When a string is written to /sys/power/wake_unlock, it will be
                assumed to represent the name of a wakeup source to deactivate.
+
                If a wakeup source object of that name exists and is active at
                the moment, it will be deactivated.
 
index 8a8e466eb2c01d39ec2afb7cac46cc183dde94aa..e39dd3a0ceef3e36a27cc03e4510950388b2b093 100644 (file)
@@ -5,7 +5,7 @@ Description:
                /sys/kernel/profiling is the runtime equivalent
                of the boot-time profile= option.
 
-               You can get the same effect running:
+               You can get the same effect running::
 
                        echo 2 > /sys/kernel/profiling
 
index a17f817a93095b22f12b9aff657c0dd50c845fc7..2363ad810ddbee070a87002c28e00e84a2faad7b 100644 (file)
@@ -69,7 +69,7 @@ Description:
                pin offered by the PTP hardware clock. The file name
                is the hardware dependent pin name. Reading from this
                file produces two numbers, the assigned function (see
-               the PTP_PF_ enumeration values in linux/ptp_clock.h)
+               the `PTP_PF_` enumeration values in linux/ptp_clock.h)
                and the channel number. The function and channel
                assignment may be changed by two writing numbers into
                the file.
index aa39f8d7bcdff3c7b789e69752ec65a30bff7cc9..0b6227706b35ed1b18acb086c41b05b83f4480d9 100644 (file)
@@ -6,42 +6,46 @@ Description:
                 Enable passing additional variables for synthetic uevents that
                 are generated by writing /sys/.../uevent file.
 
-                Recognized extended format is ACTION [UUID [KEY=VALUE ...].
+                Recognized extended format is::
 
-                The ACTION is compulsory - it is the name of the uevent action
-                ("add", "change", "remove"). There is no change compared to
-                previous functionality here. The rest of the extended format
-                is optional.
+                       ACTION [UUID [KEY=VALUE ...]
+
+                The ACTION is compulsory - it is the name of the uevent
+                action (``add``, ``change``, ``remove``). There is no change
+                compared to previous functionality here. The rest of the
+                extended format is optional.
 
                 You need to pass UUID first before any KEY=VALUE pairs.
-                The UUID must be in "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
+                The UUID must be in ``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx``
                 format where 'x' is a hex digit. The UUID is considered to be
                 a transaction identifier so it's possible to use the same UUID
                 value for one or more synthetic uevents in which case we
                 logically group these uevents together for any userspace
                 listeners. The UUID value appears in uevent as
-                "SYNTH_UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" environment
+                ``SYNTH_UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`` environment
                 variable.
 
                 If UUID is not passed in, the generated synthetic uevent gains
-                "SYNTH_UUID=0" environment variable automatically.
+                ``SYNTH_UUID=0`` environment variable automatically.
 
                 The KEY=VALUE pairs can contain alphanumeric characters only.
+
                 It's possible to define zero or more pairs - each pair is then
                 delimited by a space character ' '. Each pair appears in
-                synthetic uevent as "SYNTH_ARG_KEY=VALUE". That means the KEY
-                name gains "SYNTH_ARG_" prefix to avoid possible collisions
+                synthetic uevent as ``SYNTH_ARG_KEY=VALUE``. That means the KEY
+                name gains ``SYNTH_ARG_`` prefix to avoid possible collisions
                 with existing variables.
 
-                Example of valid sequence written to the uevent file:
+                Example of valid sequence written to the uevent file::
 
                     add fe4d7c9d-b8c6-4a70-9ef1-3d8a58d18eed A=1 B=abc
 
-                This generates synthetic uevent including these variables:
+                This generates synthetic uevent including these variables::
 
                     ACTION=add
                     SYNTH_ARG_A=1
                     SYNTH_ARG_B=abc
                     SYNTH_UUID=fe4d7c9d-b8c6-4a70-9ef1-3d8a58d18eed
+
 Users:
                 udev, userspace tools generating synthetic uevents
index a99c5f86a37a7fdf7b165cc8b9c62a708ce018cc..2969d3694ec0da19013a643f62854b5aee8ba549 100644 (file)
@@ -45,7 +45,8 @@ Description:
                 7. Device is unplugged.
 
                 References:
-                  [WUSB-AM] Association Models Supplement to the
+                  [WUSB-AM]
+                           Association Models Supplement to the
                             Certified Wireless Universal Serial Bus
                             Specification, version 1.0.
 
index 419a92dd0d86a9a8ef1a521aef8b50284ad373ff..1db89b0cf80fe2c9e9f2caf97fdf75c0f44e6e72 100644 (file)
@@ -3,44 +3,52 @@ Date:         2020-01-14
 KernelVersion: 5.6
 Contact:       linux-usb@vger.kernel.org
 Description:   There are two USB charger states:
-               USB_CHARGER_ABSENT
-               USB_CHARGER_PRESENT
+
+               - USB_CHARGER_ABSENT
+               - USB_CHARGER_PRESENT
+
                There are five USB charger types:
-               USB_CHARGER_UNKNOWN_TYPE: Charger type is unknown
-               USB_CHARGER_SDP_TYPE: Standard Downstream Port
-               USB_CHARGER_CDP_TYPE: Charging Downstream Port
-               USB_CHARGER_DCP_TYPE: Dedicated Charging Port
-               USB_CHARGER_ACA_TYPE: Accessory Charging Adapter
+
+               ========================  ==========================
+               USB_CHARGER_UNKNOWN_TYPE  Charger type is unknown
+               USB_CHARGER_SDP_TYPE      Standard Downstream Port
+               USB_CHARGER_CDP_TYPE      Charging Downstream Port
+               USB_CHARGER_DCP_TYPE      Dedicated Charging Port
+               USB_CHARGER_ACA_TYPE      Accessory Charging Adapter
+               ========================  ==========================
+
                https://www.usb.org/document-library/battery-charging-v12-spec-and-adopters-agreement
 
-               Here are two examples taken using udevadm monitor -p when
-               USB charger is online:
-               UDEV  change   /devices/soc0/usbphynop1 (platform)
-               ACTION=change
-               DEVPATH=/devices/soc0/usbphynop1
-               DRIVER=usb_phy_generic
-               MODALIAS=of:Nusbphynop1T(null)Cusb-nop-xceiv
-               OF_COMPATIBLE_0=usb-nop-xceiv
-               OF_COMPATIBLE_N=1
-               OF_FULLNAME=/usbphynop1
-               OF_NAME=usbphynop1
-               SEQNUM=2493
-               SUBSYSTEM=platform
-               USB_CHARGER_STATE=USB_CHARGER_PRESENT
-               USB_CHARGER_TYPE=USB_CHARGER_SDP_TYPE
-               USEC_INITIALIZED=227422826
-
-               USB charger is offline:
-               KERNEL change   /devices/soc0/usbphynop1 (platform)
-               ACTION=change
-               DEVPATH=/devices/soc0/usbphynop1
-               DRIVER=usb_phy_generic
-               MODALIAS=of:Nusbphynop1T(null)Cusb-nop-xceiv
-               OF_COMPATIBLE_0=usb-nop-xceiv
-               OF_COMPATIBLE_N=1
-               OF_FULLNAME=/usbphynop1
-               OF_NAME=usbphynop1
-               SEQNUM=2494
-               SUBSYSTEM=platform
-               USB_CHARGER_STATE=USB_CHARGER_ABSENT
-               USB_CHARGER_TYPE=USB_CHARGER_UNKNOWN_TYPE
+               Here are two examples taken using ``udevadm monitor -p`` when
+               USB charger is online::
+
+                   UDEV  change   /devices/soc0/usbphynop1 (platform)
+                   ACTION=change
+                   DEVPATH=/devices/soc0/usbphynop1
+                   DRIVER=usb_phy_generic
+                   MODALIAS=of:Nusbphynop1T(null)Cusb-nop-xceiv
+                   OF_COMPATIBLE_0=usb-nop-xceiv
+                   OF_COMPATIBLE_N=1
+                   OF_FULLNAME=/usbphynop1
+                   OF_NAME=usbphynop1
+                   SEQNUM=2493
+                   SUBSYSTEM=platform
+                   USB_CHARGER_STATE=USB_CHARGER_PRESENT
+                   USB_CHARGER_TYPE=USB_CHARGER_SDP_TYPE
+                   USEC_INITIALIZED=227422826
+
+               USB charger is offline::
+
+                   KERNEL change   /devices/soc0/usbphynop1 (platform)
+                   ACTION=change
+                   DEVPATH=/devices/soc0/usbphynop1
+                   DRIVER=usb_phy_generic
+                   MODALIAS=of:Nusbphynop1T(null)Cusb-nop-xceiv
+                   OF_COMPATIBLE_0=usb-nop-xceiv
+                   OF_COMPATIBLE_N=1
+                   OF_FULLNAME=/usbphynop1
+                   OF_NAME=usbphynop1
+                   SEQNUM=2494
+                   SUBSYSTEM=platform
+                   USB_CHARGER_STATE=USB_CHARGER_ABSENT
+                   USB_CHARGER_TYPE=USB_CHARGER_UNKNOWN_TYPE
index d35c3cad892c0627e2672c7002693b146c572d8b..2b8eca4bf2b1fde69a612311af44602630ee129a 100644 (file)
@@ -6,22 +6,22 @@ Description:  When the USB Host Controller has entered a state where it is no
                longer functional a uevent will be raised. The uevent will
                contain ACTION=offline and ERROR=DEAD.
 
-               Here is an example taken using udevadm monitor -p:
+               Here is an example taken using udevadm monitor -p::
 
-               KERNEL[130.428945] offline  /devices/pci0000:00/0000:00:10.0/usb2 (usb)
-               ACTION=offline
-               BUSNUM=002
-               DEVNAME=/dev/bus/usb/002/001
-               DEVNUM=001
-               DEVPATH=/devices/pci0000:00/0000:00:10.0/usb2
-               DEVTYPE=usb_device
-               DRIVER=usb
-               ERROR=DEAD
-               MAJOR=189
-               MINOR=128
-               PRODUCT=1d6b/2/414
-               SEQNUM=2168
-               SUBSYSTEM=usb
-               TYPE=9/0/1
+                   KERNEL[130.428945] offline  /devices/pci0000:00/0000:00:10.0/usb2 (usb)
+                   ACTION=offline
+                   BUSNUM=002
+                   DEVNAME=/dev/bus/usb/002/001
+                   DEVNUM=001
+                   DEVPATH=/devices/pci0000:00/0000:00:10.0/usb2
+                   DEVTYPE=usb_device
+                   DRIVER=usb
+                   ERROR=DEAD
+                   MAJOR=189
+                   MINOR=128
+                   PRODUCT=1d6b/2/414
+                   SEQNUM=2168
+                   SUBSYSTEM=usb
+                   TYPE=9/0/1
 
 Users:         chromium-os-dev@chromium.org
index 66046fa1c341eb551567723d26da937a444f9695..e549a61f4d9660fc3560dcbfba2c89aca24a4bb2 100644 (file)
@@ -10,4 +10,14 @@ config WARN_MISSING_DOCUMENTS
 
           If unsure, select 'N'.
 
+config WARN_ABI_ERRORS
+       bool "Warn if there are errors at ABI files"
+       depends on COMPILE_TEST
+       help
+          The files under Documentation/ABI should follow what's
+          described at Documentation/ABI/README. Yet, as they're manually
+          written, it would be possible that some of those files would
+          have errors that would break them for being parsed by
+          scripts/get_abi.pl. Add a check to verify them.
 
+          If unsure, select 'N'.
index 6b12dd82f71249318637aa8b2de73139d95de4b7..61a7310b49e0ce355e8f73e4afa33d6026545387 100644 (file)
@@ -10,6 +10,11 @@ ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
 $(shell $(srctree)/scripts/documentation-file-ref-check --warn)
 endif
 
+# Check for broken ABI files
+ifeq ($(CONFIG_WARN_ABI_ERRORS),y)
+$(shell $(srctree)/scripts/get_abi.pl validate --dir $(srctree)/Documentation/ABI)
+endif
+
 # You can set these variables from the command line.
 SPHINXBUILD   = sphinx-build
 SPHINXOPTS    =
@@ -21,6 +26,10 @@ BUILDDIR      = $(obj)/output
 PDFLATEX      = xelatex
 LATEXOPTS     = -interaction=batchmode
 
+ifeq ($(KBUILD_VERBOSE),0)
+SPHINXOPTS    += "-q"
+endif
+
 # User-friendly check for sphinx-build
 HAVE_SPHINX := $(shell if which $(SPHINXBUILD) >/dev/null 2>&1; then echo 1; else echo 0; fi)
 
index 17996c9070e23a8bbb0621c14ded21f729248100..0ec34863c6742b6b0a0a553ada9bf8269ff66000 100644 (file)
@@ -107,7 +107,7 @@ for a UID/GID will prevent that UID/GID from obtaining auxiliary setid
 privileges, such as allowing a user to set up user namespace UID/GID mappings.
 
 Note on GID policies and setgroups()
-==================
+====================================
 In v5.9 we are adding support for limiting CAP_SETGID privileges as was done
 previously for CAP_SETUID. However, for compatibility with common sandboxing
 related code conventions in userspace, we currently allow arbitrary
diff --git a/Documentation/admin-guide/abi-obsolete.rst b/Documentation/admin-guide/abi-obsolete.rst
new file mode 100644 (file)
index 0000000..d095867
--- /dev/null
@@ -0,0 +1,11 @@
+ABI obsolete symbols
+====================
+
+Documents interfaces that are still remaining in the kernel, but are
+marked to be removed at some later point in time.
+
+The description of the interface will document the reason why it is
+obsolete and when it can be expected to be removed.
+
+.. kernel-abi:: $srctree/Documentation/ABI/obsolete
+   :rst:
diff --git a/Documentation/admin-guide/abi-removed.rst b/Documentation/admin-guide/abi-removed.rst
new file mode 100644 (file)
index 0000000..f7e9e43
--- /dev/null
@@ -0,0 +1,5 @@
+ABI removed symbols
+===================
+
+.. kernel-abi:: $srctree/Documentation/ABI/removed
+   :rst:
diff --git a/Documentation/admin-guide/abi-stable.rst b/Documentation/admin-guide/abi-stable.rst
new file mode 100644 (file)
index 0000000..7049073
--- /dev/null
@@ -0,0 +1,14 @@
+ABI stable symbols
+==================
+
+Documents the interfaces that the developer has defined to be stable.
+
+Userspace programs are free to use these interfaces with no
+restrictions, and backward compatibility for them will be guaranteed
+for at least 2 years.
+
+Most interfaces (like syscalls) are expected to never change and always
+be available.
+
+.. kernel-abi:: $srctree/Documentation/ABI/stable
+   :rst:
diff --git a/Documentation/admin-guide/abi-testing.rst b/Documentation/admin-guide/abi-testing.rst
new file mode 100644 (file)
index 0000000..b205b16
--- /dev/null
@@ -0,0 +1,20 @@
+ABI testing symbols
+===================
+
+Documents interfaces that are felt to be stable,
+as the main development of this interface has been completed.
+
+The interface can be changed to add new features, but the
+current interface will not break by doing this, unless grave
+errors or security problems are found in them.
+
+Userspace programs can start to rely on these interfaces, but they must
+be aware of changes that can occur before these interfaces move to
+be marked stable.
+
+Programs that use these interfaces are strongly encouraged to add their
+name to the description of these interfaces, so that the kernel
+developers can easily notify them if any changes occur.
+
+.. kernel-abi:: $srctree/Documentation/ABI/testing
+   :rst:
diff --git a/Documentation/admin-guide/abi.rst b/Documentation/admin-guide/abi.rst
new file mode 100644 (file)
index 0000000..bcab3ef
--- /dev/null
@@ -0,0 +1,11 @@
+=====================
+Linux ABI description
+=====================
+
+.. toctree::
+   :maxdepth: 2
+
+   abi-stable
+   abi-testing
+   abi-obsolete
+   abi-removed
index ed1cf94ea50c2773b1e0c21250c06ac8d2336fcd..4e0c4ae44acda53b01ef194ad4ffb6bd84ec6e39 100644 (file)
@@ -18,6 +18,8 @@ etc.
    devices
    sysctl/index
 
+   abi
+
 This section describes CPU vulnerabilities and their mitigations.
 
 .. toctree::
index 37940a0584ec188a686dbef917a9652f81f12af3..10fde58d086972701f732ec0d85fb5540c25a35b 100644 (file)
@@ -478,7 +478,7 @@ order to ask the hardware to enter that state.  Also, for each
 statistics of the given idle state.  That information is exposed by the kernel
 via ``sysfs``.
 
-For each CPU in the system, there is a :file:`/sys/devices/system/cpu<N>/cpuidle/`
+For each CPU in the system, there is a :file:`/sys/devices/system/cpu/cpu<N>/cpuidle/`
 directory in ``sysfs``, where the number ``<N>`` is assigned to the given
 CPU at the initialization time.  That directory contains a set of subdirectories
 called :file:`state0`, :file:`state1` and so on, up to the number of idle state
@@ -494,7 +494,7 @@ object corresponding to it, as follows:
        residency.
 
 ``below``
-       Total number of times this idle state had been asked for, but cerainly
+       Total number of times this idle state had been asked for, but certainly
        a deeper idle state would have been a better match for the observed idle
        duration.
 
index 57fd6ce68fe05d3b1df5cf705c81da98d50144e3..f2ab8a5b6a4b867e760026920929f68a19850194 100644 (file)
@@ -300,6 +300,7 @@ Note:
       0:    0     1     2     3     4     5     6     7
   RSS hash key:
   84:50:f4:00:a8:15:d1:a7:e9:7f:1d:60:35:c7:47:25:42:97:74:ca:56:bb:b6:a1:d8:43:e3:c9:0c:fd:17:55:c2:3a:4d:69:ed:f1:42:89
+
 netdev_tstamp_prequeue
 ----------------------
 
index 62b533d0ba9443ff3e8818947a1e846ebd044528..0c536ae1d7c2b20301fdfac04d237232e28d9f9c 100644 (file)
@@ -148,3 +148,13 @@ SunXi family
         * User Manual
 
           http://dl.linux-sunxi.org/A64/Allwinner%20A64%20User%20Manual%20v1.0.pdf
+
+      - Allwinner H6
+
+       * Datasheet
+
+         https://linux-sunxi.org/images/5/5c/Allwinner_H6_V200_Datasheet_V1.1.pdf
+
+       * User Manual
+
+         https://linux-sunxi.org/images/4/46/Allwinner_H6_V200_User_Manual_V1.1.pdf
index 2b7a021db363abcff632eeeaf4d2527b9911d0d5..2dc5f9e18039b3a01e08857455cc2c59e79d6af6 100644 (file)
@@ -1,12 +1,11 @@
 #!/bin/sh
 
 # Print out the KASAN_SHADOW_OFFSETS required to place the KASAN SHADOW
-# start address at the mid-point of the kernel VA space
+# start address at the top of the linear region
 
 print_kasan_offset () {
        printf "%02d\t" $1
        printf "0x%08x00000000\n" $(( (0xffffffff & (-1 << ($1 - 1 - 32))) \
-                       + (1 << ($1 - 32 - $2)) \
                        - (1 << (64 - 32 - $2)) ))
 }
 
index cf03b3290800c25ea7c5d8cba093b0189e3d727a..e7522e5c8322b3a3f0df9654c34618f5de4d1229 100644 (file)
@@ -32,17 +32,16 @@ AArch64 Linux memory layout with 4KB pages + 4 levels (48-bit)::
   -----------------------------------------------------------------------
   0000000000000000     0000ffffffffffff         256TB          user
   ffff000000000000     ffff7fffffffffff         128TB          kernel logical memory map
-  ffff800000000000     ffff9fffffffffff          32TB          kasan shadow region
-  ffffa00000000000     ffffa00007ffffff         128MB          bpf jit region
-  ffffa00008000000     ffffa0000fffffff         128MB          modules
-  ffffa00010000000     fffffdffbffeffff         ~93TB          vmalloc
-  fffffdffbfff0000     fffffdfffe5f8fff        ~998MB          [guard region]
-  fffffdfffe5f9000     fffffdfffe9fffff        4124KB          fixed mappings
-  fffffdfffea00000     fffffdfffebfffff           2MB          [guard region]
-  fffffdfffec00000     fffffdffffbfffff          16MB          PCI I/O space
-  fffffdffffc00000     fffffdffffdfffff           2MB          [guard region]
-  fffffdffffe00000     ffffffffffdfffff           2TB          vmemmap
-  ffffffffffe00000     ffffffffffffffff           2MB          [guard region]
+ [ffff600000000000     ffff7fffffffffff]         32TB          [kasan shadow region]
+  ffff800000000000     ffff800007ffffff         128MB          bpf jit region
+  ffff800008000000     ffff80000fffffff         128MB          modules
+  ffff800010000000     fffffbffefffffff         124TB          vmalloc
+  fffffbfff0000000     fffffbfffdffffff         224MB          fixed mappings (top down)
+  fffffbfffe000000     fffffbfffe7fffff           8MB          [guard region]
+  fffffbfffe800000     fffffbffff7fffff          16MB          PCI I/O space
+  fffffbffff800000     fffffbffffffffff           8MB          [guard region]
+  fffffc0000000000     fffffdffffffffff           2TB          vmemmap
+  fffffe0000000000     ffffffffffffffff           2TB          [guard region]
 
 
 AArch64 Linux memory layout with 64KB pages + 3 levels (52-bit with HW support)::
@@ -50,19 +49,17 @@ AArch64 Linux memory layout with 64KB pages + 3 levels (52-bit with HW support):
   Start                        End                     Size            Use
   -----------------------------------------------------------------------
   0000000000000000     000fffffffffffff           4PB          user
-  fff0000000000000     fff7ffffffffffff           2PB          kernel logical memory map
-  fff8000000000000     fffd9fffffffffff        1440TB          [gap]
-  fffda00000000000     ffff9fffffffffff         512TB          kasan shadow region
-  ffffa00000000000     ffffa00007ffffff         128MB          bpf jit region
-  ffffa00008000000     ffffa0000fffffff         128MB          modules
-  ffffa00010000000     fffff81ffffeffff         ~88TB          vmalloc
-  fffff81fffff0000     fffffc1ffe58ffff          ~3TB          [guard region]
-  fffffc1ffe590000     fffffc1ffe9fffff        4544KB          fixed mappings
-  fffffc1ffea00000     fffffc1ffebfffff           2MB          [guard region]
-  fffffc1ffec00000     fffffc1fffbfffff          16MB          PCI I/O space
-  fffffc1fffc00000     fffffc1fffdfffff           2MB          [guard region]
-  fffffc1fffe00000     ffffffffffdfffff        3968GB          vmemmap
-  ffffffffffe00000     ffffffffffffffff           2MB          [guard region]
+  fff0000000000000     ffff7fffffffffff          ~4PB          kernel logical memory map
+ [fffd800000000000     ffff7fffffffffff]        512TB          [kasan shadow region]
+  ffff800000000000     ffff800007ffffff         128MB          bpf jit region
+  ffff800008000000     ffff80000fffffff         128MB          modules
+  ffff800010000000     fffffbffefffffff         124TB          vmalloc
+  fffffbfff0000000     fffffbfffdffffff         224MB          fixed mappings (top down)
+  fffffbfffe000000     fffffbfffe7fffff           8MB          [guard region]
+  fffffbfffe800000     fffffbffff7fffff          16MB          PCI I/O space
+  fffffbffff800000     fffffbffffffffff           8MB          [guard region]
+  fffffc0000000000     ffffffdfffffffff          ~4TB          vmemmap
+  ffffffe000000000     ffffffffffffffff         128GB          [guard region]
 
 
 Translation table lookup with 4KB pages::
index eab4323609b97fd8dafa962404713aab8c8c04e9..19d284b7038487a5af95807362c4c3799781c58f 100644 (file)
@@ -53,12 +53,25 @@ visibility.
 Preserving tags
 ---------------
 
-Non-zero tags are not preserved when delivering signals. This means that
-signal handlers in applications making use of tags cannot rely on the
-tag information for user virtual addresses being maintained for fields
-inside siginfo_t. One exception to this rule is for signals raised in
-response to watchpoint debug exceptions, where the tag information will
-be preserved.
+When delivering signals, non-zero tags are not preserved in
+siginfo.si_addr unless the flag SA_EXPOSE_TAGBITS was set in
+sigaction.sa_flags when the signal handler was installed. This means
+that signal handlers in applications making use of tags cannot rely
+on the tag information for user virtual addresses being maintained
+in these fields unless the flag was set.
+
+Due to architecture limitations, bits 63:60 of the fault address
+are not preserved in response to synchronous tag check faults
+(SEGV_MTESERR) even if SA_EXPOSE_TAGBITS was set. Applications should
+treat the values of these bits as undefined in order to accommodate
+future architecture revisions which may preserve the bits.
+
+For signals raised in response to watchpoint debug exceptions, the
+tag information will be preserved regardless of the SA_EXPOSE_TAGBITS
+flag setting.
+
+Non-zero tags are never preserved in sigcontext.fault_address
+regardless of the SA_EXPOSE_TAGBITS flag setting.
 
 The architecture prevents the use of a tagged PC, so the upper byte will
 be set to a sign-extension of bit 55 on exception return.
index 376dd0ddf39cdcc89d1ea37d49b299f1ed154c7a..ed2b43ec7754e5b886c6edbda64332179ed5ea56 100644 (file)
@@ -38,7 +38,8 @@ needs_sphinx = '1.3'
 # ones.
 extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
               'kfigure', 'sphinx.ext.ifconfig', 'automarkup',
-              'maintainers_include', 'sphinx.ext.autosectionlabel' ]
+              'maintainers_include', 'sphinx.ext.autosectionlabel',
+              'kernel_abi']
 
 #
 # cdomain is badly broken in Sphinx 3+.  Leaving it out generates *most*
@@ -50,7 +51,7 @@ if major >= 3:
         support for Sphinx v3.0 and above is brand new. Be prepared for
         possible issues in the generated output.
         ''')
-    if minor > 0 or patch >= 2:
+    if (major > 3) or (minor > 0 or patch >= 2):
         # Sphinx c function parser is more pedantic with regards to type
         # checking. Due to that, having macros at c:function cause problems.
         # Those needed to be scaped by using c_id_attributes[] array
index c09c9ca2ff1cbae16417bf92e05a6193e53641d4..2b68addaadcd756f4cb08eda4133fcae5710e5f0 100644 (file)
@@ -295,11 +295,13 @@ print the number of the test and the status of the test:
 pass::
 
         ok 28 - kmalloc_double_kzfree
+
 or, if kmalloc failed::
 
         # kmalloc_large_oob_right: ASSERTION FAILED at lib/test_kasan.c:163
         Expected ptr is not null, but is
         not ok 4 - kmalloc_large_oob_right
+
 or, if a KASAN report was expected, but not found::
 
         # kmalloc_double_kzfree: EXPECTATION FAILED at lib/test_kasan.c:629
index d23385e3e1592bea6240287f0422bb94da629022..454f307813ea6689d5ee80954e5d32792a0c8627 100644 (file)
@@ -197,7 +197,7 @@ Now add the following to ``drivers/misc/Kconfig``:
 
        config MISC_EXAMPLE_TEST
                bool "Test for my example"
-               depends on MISC_EXAMPLE && KUNIT
+               depends on MISC_EXAMPLE && KUNIT=y
 
 and the following to ``drivers/misc/Makefile``:
 
index 961d3ea3ca19ad2211252395a04f9519ede0161a..62142a47488cf21eb227a65bcdc1f948ccf8f01e 100644 (file)
@@ -561,6 +561,11 @@ Once the kernel is built and installed, a simple
 
 ...will run the tests.
 
+.. note::
+   Note that you should make sure your test depends on ``KUNIT=y`` in Kconfig
+   if the test does not support module build.  Otherwise, it will trigger
+   compile errors if ``CONFIG_KUNIT`` is ``m``.
+
 Writing new tests for other architectures
 -----------------------------------------
 
index fe22c66e9c15a3c71220db32dc2b17c5401316de..02dc72c976456bb790d5267ec469d1cf49a82967 100644 (file)
@@ -49,3 +49,5 @@ properties:
           - enum:
               - ucrobotics,bubblegum-96 # uCRobotics Bubblegum-96
           - const: actions,s900
+
+additionalProperties: true
index 0bc5020b7539540844b6f0536053156424833861..c15c92fdf2ed80c1e1b04b5cb631ae71b17eb924 100644 (file)
@@ -19,4 +19,7 @@ properties:
           - altr,socfpga-arria5
           - altr,socfpga-arria10
       - const: altr,socfpga
+
+additionalProperties: true
+
 ...
index a3a4d710bd02a00b1ff94f0fdc2b60aa595dd53a..0f03135d91b6165888a5a94f78fec6b5be57f919 100644 (file)
@@ -30,4 +30,6 @@ properties:
               - amazon,al-alpine-v3-evp
           - const: amazon,al-alpine-v3
 
+additionalProperties: true
+
 ...
index 0ee7c5b7b3f66b8fbe50a04c791b986daa8c8778..3341788d10965618e73117c574d2e7e22a55013c 100644 (file)
@@ -173,4 +173,7 @@ properties:
           - enum:
               - amlogic,ad401
           - const: amlogic,a1
+
+additionalProperties: true
+
 ...
index f0daf990e0778456c1887f9cd6f0270fee295ba5..528eee64290ab514fe5baa356ef1af86c8cd012b 100644 (file)
@@ -83,4 +83,6 @@ required:
   - compatible
   - core-module@10000000
 
+additionalProperties: true
+
 ...
index 1d0b4e2bc7d2bf11ba4a7ff719411cc18eac2b75..4f9b21f49e84619b59fd8c4e8ebd8d4a11eca6d4 100644 (file)
@@ -120,4 +120,6 @@ required:
   - compatible
   - soc
 
+additionalProperties: true
+
 ...
index 06efd2a075c9dfb78305f494b2173d2e5b8ce60c..34b437c727517ec14bf357177b79112327439fdb 100644 (file)
@@ -68,4 +68,6 @@ required:
   - compatible
   - core-module@10000000
 
+additionalProperties: true
+
 ...
index 26829a803fda8dddc63d736466480a8bf7e27365..55ef656d1192e24b3b8d1f5278b9f39888e4b60c 100644 (file)
@@ -216,4 +216,6 @@ allOf:
       required:
         - arm,hbi
 
+additionalProperties: true
+
 ...
index 614c91956798a248405d7476cd6beb97e93abc36..6fc5a22ad962f86e18ba10817b480fb6b2ad8a69 100644 (file)
@@ -184,4 +184,6 @@ properties:
           - const: atmel,samv71
           - const: atmel,samv7
 
+additionalProperties: true
+
 ...
index 3ea5f2fdcd96c1874fa675f80f26125bf7e01c4c..e0d2bb71cf502b1e1697a0b9db6a95660df79b44 100644 (file)
@@ -18,4 +18,6 @@ properties:
       - const: lsi,axm5516-amarillo
       - const: lsi,axm5516
 
+additionalProperties: true
+
 ...
index dd52e29b0642db7c4bdcc60115c365ca65ef62f2..812ae8cc595981c353a3fa055e0c3de29dc9093b 100644 (file)
@@ -51,4 +51,6 @@ properties:
               - raspberrypi,3-compute-module-lite
           - const: brcm,bcm2837
 
+additionalProperties: true
+
 ...
index 497600a2ffb9c42e1b6dcfb9538dbf9da6e63554..c6032435743574d9341778c87d348a3a3a2d0a00 100644 (file)
@@ -18,4 +18,6 @@ properties:
           - brcm,bcm28155-ap
       - const: brcm,bcm11351
 
+additionalProperties: true
+
 ...
index e0ee931723dc431d2495229260e151a341171cd0..b3020757380f610f70169b86d41f34cbe8785397 100644 (file)
@@ -18,4 +18,6 @@ properties:
           - brcm,bcm21664-garnet
       - const: brcm,bcm21664
 
+additionalProperties: true
+
 ...
index 40d12ea56e547e11a8980b05fe36bda11f1fa4e4..37f3a6fcde760a67857bc61e6321b0a4b01b9208 100644 (file)
@@ -18,4 +18,6 @@ properties:
           - brcm,bcm23550-sparrow
       - const: brcm,bcm23550
 
+additionalProperties: true
+
 ...
index 988e0bbb2a62877cb3e823856f129ecb0543cd15..434d3c6db61eef2d0f7186d3eb49c5b69f8d243f 100644 (file)
@@ -87,4 +87,7 @@ properties:
           - const: brcm,brcm53012
           - const: brcm,brcm53016
           - const: brcm,bcm4708
+
+additionalProperties: true
+
 ...
index 9ba7b16e1fc4dd3dadca0202fdb8274141894a84..432ccf990f9e8e75c5528a7e444dc36b8e02050c 100644 (file)
@@ -26,4 +26,6 @@ properties:
           - brcm,bcm58305
       - const: brcm,cygnus
 
+additionalProperties: true
+
 ...
index ae614b6722c2b5a313724b39eb38671c618ef81c..294948399f82545fa84c817271ee665f763ebc0f 100644 (file)
@@ -25,4 +25,6 @@ properties:
       - const: brcm,bcm53342
       - const: brcm,hr2
 
+additionalProperties: true
+
 ...
index 0749adf94c28929c64d5cc9ed079d05acd476d9d..c4847abbecd8e792b216e45f08e6893fa250867d 100644 (file)
@@ -20,4 +20,6 @@ properties:
           - brcm,ns2-xmc
       - const: brcm,ns2
 
+additionalProperties: true
+
 ...
index 8c2cacb2bb4f12b02f348704c0a3492939eb29e9..476bc23a7f75c098af05e74b0c27f906612c9804 100644 (file)
@@ -33,4 +33,6 @@ properties:
           - brcm,bcm88312
       - const: brcm,nsp
 
+additionalProperties: true
+
 ...
index c13cb96545a2836008229791e5260610892fbe02..c638e04ebae0fd1e4bf0243c56a08e11577a4de0 100644 (file)
@@ -21,4 +21,6 @@ properties:
           - brcm,bcm958802a802x
       - const: brcm,stingray
 
+additionalProperties: true
+
 ...
index ccdf9f99cb2b01a9eb862c1674924f1207e60111..4eba182abd5358921123606703ab1ae445448cae 100644 (file)
@@ -19,4 +19,6 @@ properties:
           - cavium,thunderx2-cn9900
       - const: brcm,vulcan-soc
 
+additionalProperties: true
+
 ...
index 5880083ab8d01af78b86172405bd0d4dd62d1385..90ba02be48ce5b9ce13a2ae5dc681ab79660b0f2 100644 (file)
@@ -17,4 +17,7 @@ properties:
       - enum:
           - bitmain,sophon-edge
       - const: bitmain,bm1880
+
+additionalProperties: true
+
 ...
index aa5571d23c39b2230218f5f40c4b83f2220d0590..46f78addebb0f35445df83c6c3b37dc726b1a0d0 100644 (file)
@@ -20,3 +20,5 @@ properties:
       - enum:
           - calxeda,highbank
           - calxeda,ecx-2000
+
+additionalProperties: true
index 849e205183392b480db0fa8d5671f1b298f9cc6c..a35de3c9e28474113f3f4f7addf466c6babc27d5 100644 (file)
@@ -15,4 +15,6 @@ properties:
   compatible:
     const: cnxt,cx92755
 
+additionalProperties: true
+
 ...
index 1ca9dfa8ce9ac07a5dc8ce3290d1a9e07a93f9b8..934289446abb652c4848ee2751fc5473d1df5b96 100644 (file)
@@ -621,4 +621,6 @@ properties:
               - fsl,s32v234-evb           # S32V234-EVB2 Customer Evaluation Board
           - const: fsl,s32v234
 
+additionalProperties: true
+
 ...
index 43b8ce2227aaae903c7557e56415aaefbe7ab735..b38458022946f0d3610efcd83d55821e46623f27 100644 (file)
@@ -64,4 +64,7 @@ properties:
         items:
           - const: H836ASDJ
           - const: hisilicon,sd5203
+
+additionalProperties: true
+
 ...
index 06a7b05f435f3d7ef629e0afa17d37b41f38a20c..69cd3087292833c9182774c4e21384757c00a815 100644 (file)
@@ -16,4 +16,7 @@ properties:
       - enum:
           - intel,keembay-evm
       - const: intel,keembay
+
+additionalProperties: true
+
 ...
index f18302efb90eaca2c930816412746d59c9f21dba..d72e92bdf7c14e99eec675ca905a1513d92b2bd3 100644 (file)
@@ -22,3 +22,5 @@ properties:
           - enum:
               - gateworks,gw2358
           - const: intel,ixp43x
+
+additionalProperties: true
index 7597bc93a55fa037889da75e9a4dcea168bd5ec8..5cbcacaeb441e20a831a9c79b59af60055849271 100644 (file)
@@ -42,3 +42,5 @@ properties:
       - description: TI-SCI processor id for the remote processor device
       - description: TI-SCI host id to which processor control ownership
                      should be transferred to
+
+additionalProperties: true
index a9828c50c0fba31ef30a9c2dd5bdc94383685b11..e9bf3054529f1297d383e4b5cd801c9cecb284df 100644 (file)
@@ -59,3 +59,5 @@ properties:
           - const: marvell,cn9130
           - const: marvell,armada-ap807-quad
           - const: marvell,armada-ap807
+
+additionalProperties: true
index 30908963ae26159d96c62f56654df892c4c7576e..f736e8c859fa1dbc7569f6bd72faea3a0372bcf5 100644 (file)
@@ -119,4 +119,7 @@ properties:
           - const: google,krane-sku176
           - const: google,krane
           - const: mediatek,mt8183
+
+additionalProperties: true
+
 ...
index ecf6fa12e6ad26c63ea20e98666caa1112877e89..6193388c63182a7069b45cb21ff84640c85448d2 100644 (file)
@@ -62,4 +62,6 @@ required:
   - compatible
   - axi@600000000
 
+additionalProperties: true
+
 ...
index c068df59fad2b80f6181dbd5aebd2959ba06f9dd..670d24ce8ec5e57d8f075dd70d90f461226ced73 100644 (file)
@@ -16,4 +16,5 @@ properties:
       - const: moxa,moxart-uc-7112-lx
       - const: moxa,moxart
 
+additionalProperties: true
 ...
index 3235ec9e9bad182e8409b5ba4133f5c7bcb2ed70..d581161361547d12c0cfc02f5d50b1fd3ff369d7 100644 (file)
@@ -35,4 +35,7 @@ properties:
           - enum:
               - dell,wyse-ariel
           - const: marvell,mmp3
+
+additionalProperties: true
+
 ...
index c2f980b00b0670cdeb9fad851b5abfd53d3fdd3a..7c787405bb2f40a56fc71b089c02d05b622aaf09 100644 (file)
@@ -31,3 +31,5 @@ properties:
           - enum:
               - 70mai,midrived08 # 70mai midrive d08
           - const: mstar,mercury5
+
+additionalProperties: true
index f7f024910e716d4d7c055f67fe455bb0306e6804..214c97bc30634d21c3769991afe635df4fe4be58 100644 (file)
@@ -21,4 +21,6 @@ properties:
               - ea,ea3250
               - phytec,phy3250
           - const: nxp,lpc3250
+
+additionalProperties: true
 ...
index ad25deba4d8634e4a62c82c28d958b9f2c4ef463..c97d4a580f47b0b1674b9f43b62e3d780f21a8cf 100644 (file)
@@ -178,4 +178,6 @@ properties:
               - qcom,sm8250-mtp
           - const: qcom,sm8250
 
+additionalProperties: true
+
 ...
index 9672aa0c760d101be6b43bdceacc624b4af95911..a5c0444aa2b47b7281f7ff095ce7f6944195372e 100644 (file)
@@ -19,4 +19,6 @@ properties:
           - xunlong,orangepi-i96        # Orange Pi i96
       - const: rda,8810pl
 
+additionalProperties: true
+
 ...
index 845f9c76d6f708ae293e707d5e86a9763bb2b078..9fb0297fe1ced79c9b342f953fa8972a58c95007 100644 (file)
@@ -54,4 +54,7 @@ properties:
           - enum:
               - realtek,mjolnir # Realtek Mjolnir EVB
           - const: realtek,rtd1619
+
+additionalProperties: true
+
 ...
index 01a6d0c571ad541477c94a84df4ee0d6ba6954b0..ff94c45eefb014565740fa0ee1be81882851dc2c 100644 (file)
@@ -299,4 +299,6 @@ properties:
               - renesas,rzn1d400-db # RZN1D-DB (RZ/N1D Demo Board for the RZ/N1D 400 pins package)
           - const: renesas,r9a06g032
 
+additionalProperties: true
+
 ...
index 65b4cc2c63f7c1e5fbf20ce34b20f9dc15f264e2..b621752aaa652b9b5185ddd1c7f37d7d1754a1af 100644 (file)
@@ -569,4 +569,7 @@ properties:
         items:
           - const: zkmagic,a95x-z2
           - const: rockchip,rk3318
+
+additionalProperties: true
+
 ...
index eb92f9eefaba6be07c5d010008b04d0fb65b9853..272508010b02ebb6d648584a60ff974888d59a86 100644 (file)
@@ -180,3 +180,5 @@ properties:
 
 required:
   - compatible
+
+additionalProperties: true
index 0b597032c9239740164eb1cba8811091eb9d0eaf..b25eb35d1b66354b7c0a1673177db80705c43f6c 100644 (file)
@@ -24,4 +24,7 @@ properties:
       - items:
           - const: sirf,prima2-cb
           - const: sirf,prima2
+
+additionalProperties: true
+
 ...
index 2bd519d2e8557fae8f648ab32fe416bb6e39fc71..aa1d4afbc5105fb6b4b5dad4ed1fb2a4b0c64ccf 100644 (file)
@@ -19,4 +19,7 @@ properties:
           - enum:
               - socionext,milbeaut-m10v-evb
           - const: socionext,sc2000a
+
+additionalProperties: true
+
 ...
index 6caf1f9be390f281762243ef57bbabf710d6d480..8c0e91658474f8effdf1518e33c0c3895ba0d1f4 100644 (file)
@@ -60,3 +60,5 @@ properties:
           - enum:
               - socionext,uniphier-pxs3-ref
           - const: socionext,uniphier-pxs3
+
+additionalProperties: true
index f6ec731c9531306a1ee80b4b0f8d0b066704c7a0..605ad3f882efcfe8de256b5dad429eefb0afb056 100644 (file)
@@ -22,4 +22,7 @@ properties:
           - st,spear320
           - st,spear1310
           - st,spear1340
+
+additionalProperties: true
+
 ...
index 0258a96bfbdefb95f40797366232f9a4cb2f9f60..7b6ae3070396547392660abdb1a5e44a25889e5f 100644 (file)
@@ -30,4 +30,6 @@ properties:
               - sprd,sp9863a-1h10
           - const: sprd,sc9863a
 
+additionalProperties: true
+
 ...
index 47f9b8eebaa010561d1d58ca7908f4733dfad497..b1f28d16d3fbccdadb42d357b17175697284d90e 100644 (file)
@@ -20,4 +20,7 @@ properties:
           - st,stih407
           - st,stih410
           - st,stih418
+
+additionalProperties: true
+
 ...
index deacb4e686e83968686d2f038aa10436a5286d4d..009b424e456e9e3366a952f200b2ea6db7e01e82 100644 (file)
@@ -54,8 +54,11 @@ properties:
           - const: st,stm32mp157
       - description: Odyssey STM32MP1 SoM based Boards
         items:
-              - enum:
-                  - seeed,stm32mp157c-odyssey
-              - const: seeed,stm32mp157c-odyssey-som
-              - const: st,stm32mp157
+          - enum:
+              - seeed,stm32mp157c-odyssey
+          - const: seeed,stm32mp157c-odyssey-som
+          - const: st,stm32mp157
+
+additionalProperties: true
+
 ...
index afa00268c7db731ee27d43de83af1d5d6b35484c..cab8e1b6417bff989cc8cb53945b54de4b71ddcb 100644 (file)
@@ -893,3 +893,5 @@ properties:
         items:
           - const: xunlong,orangepi-zero-plus2-h3
           - const: allwinner,sun8i-h3
+
+additionalProperties: true
index 8ae44948e8733619f54368d4dc322ba092bdfc98..767e86354c8e9597c5868aecd0a90c911456e521 100644 (file)
@@ -125,3 +125,5 @@ properties:
           - enum:
               - nvidia,tegra234-vdk
           - const: nvidia,tegra234
+
+additionalProperties: true
index 8297512095435884f7e74329da9f8f5338239265..c6e1c1e63e432365ec7e043c37a568a416169aa3 100644 (file)
@@ -32,4 +32,7 @@ properties:
       - description: K3 J7200 SoC
         items:
           - const: ti,j7200
+
+additionalProperties: true
+
 ...
index e372b43da62fb3a0b039da2970f7391b02358e4b..cc2023bb7fa608405eced3f6e4d74f0798afa66e 100644 (file)
@@ -21,4 +21,7 @@ properties:
           - ti,nspire-tp
           # Clickpad models
           - ti,nspire-clp
+
+additionalProperties: true
+
 ...
index a8765ba29476cac331edd641cab3f6de2dab9092..c022d325fc08b3db313cd020dccc95f631e9dc5e 100644 (file)
@@ -23,4 +23,7 @@ properties:
           - enbw,cmc        # EnBW AM1808 based CMC board
           - lego,ev3        # LEGO MINDSTORMS EV3 (AM1808 based)
       - const: ti,da850
+
+additionalProperties: true
+
 ...
index 0e066290238eef3a3b6cb9db0127fd73ccb0dddb..001bbbcd143283ede9e5f439fc038b4c5faf792f 100644 (file)
@@ -19,4 +19,7 @@ properties:
           - enum:
               - toshiba,tmpv7708-rm-mbrc  # TMPV7708 RM main board
           - const: toshiba,tmpv7708
+
+additionalProperties: true
+
 ...
index accaee9060506321fc7c40f6c3aef0dd820cd577..5db7cfba81a477d17fe56d760f7c34df9f83f80d 100644 (file)
@@ -34,3 +34,5 @@ properties:
         items:
           - const: samsung,golden
           - const: st-ericsson,u8500
+
+additionalProperties: true
index 7b25b6fa34e918148c469caad0d0a504c49fd8c5..29ff399551ca799f93da90604e793d5a0c540a9f 100644 (file)
@@ -21,3 +21,6 @@ properties:
           - wm,wm8650
           - wm,wm8750
           - wm,wm8850
+          
+additionalProperties: true
+
index c73b1f5c7f49f9000d5c317ed9bdaa927eed51db..e0c6787f6e9494785faacbd338209d6c2482bd8b 100644 (file)
@@ -111,4 +111,6 @@ properties:
           - const: xlnx,zynqmp-zcu111
           - const: xlnx,zynqmp
 
+additionalProperties: true
+
 ...
index 2d3fefdccdff437ad2986d2e83d6495d5c954c06..672f8129cd3199a970c58ee69650cd8c1886dfe5 100644 (file)
@@ -23,4 +23,6 @@ properties:
               - zte,zx296718-evb
           - const: zte,zx296718
 
+additionalProperties: true
+
 ...
index ef3deb7b86eaf18468a2b779c9b7786c92d158d0..17ac4a3dd26aa841f53a60ce48806e8203499da8 100644 (file)
@@ -4,7 +4,7 @@ Clock control registers reside in different Hi6220 system controllers,
 please refer the following document to know more about the binding rules
 for these system controllers:
 
-Documentation/devicetree/bindings/arm/hisilicon/hisilicon.txt
+Documentation/devicetree/bindings/arm/hisilicon/hisilicon.yaml
 
 Required Properties:
 
index 31f085d8ab13e7c136ee35c265504e2eaf019f77..fd3113aa9ccdc2dd831e3b1006b1f68bdaf79150 100644 (file)
@@ -7,17 +7,17 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Toshiba TC358775 DSI to LVDS bridge bindings
 
 maintainers:
- - Vinay Simha BN <simhavcs@gmail.com>
 - Vinay Simha BN <simhavcs@gmail.com>
 
 description: |
- This binding supports DSI to LVDS bridge TC358775
 This binding supports DSI to LVDS bridge TC358775
 
- MIPI DSI-RX Data 4-lane, CLK 1-lane with data rates up to 800 Mbps/lane.
- Video frame size:
- Up to 1600x1200 24-bit/pixel resolution for single-link LVDS display panel
- limited by 135 MHz LVDS speed
- Up to WUXGA (1920x1200 24-bit pixels) resolution for dual-link LVDS display
- panel, limited by 270 MHz LVDS speed.
 MIPI DSI-RX Data 4-lane, CLK 1-lane with data rates up to 800 Mbps/lane.
 Video frame size:
 Up to 1600x1200 24-bit/pixel resolution for single-link LVDS display panel
 limited by 135 MHz LVDS speed
 Up to WUXGA (1920x1200 24-bit pixels) resolution for dual-link LVDS display
 panel, limited by 270 MHz LVDS speed.
 
 properties:
   compatible:
@@ -29,7 +29,7 @@ properties:
 
   vdd-supply:
     maxItems: 1
-    description:  1.2V LVDS Power Supply
+    description: 1.2V LVDS Power Supply
 
   vddio-supply:
     maxItems: 1
@@ -77,16 +77,18 @@ properties:
       - port@1
 
 required:
- - compatible
- - reg
- - vdd-supply
- - vddio-supply
- - stby-gpios
- - reset-gpios
- - ports
+  - compatible
+  - reg
+  - vdd-supply
+  - vddio-supply
+  - stby-gpios
+  - reset-gpios
+  - ports
+
+additionalProperties: false
 
 examples:
- - |
 - |
     #include <dt-bindings/gpio/gpio.h>
 
     /* For single-link LVDS display panel */
@@ -147,7 +149,7 @@ examples:
          };
      };
 
- - |
 - |
     /* For dual-link LVDS display panel */
 
     i2c@78b8000 {
index c60b3bd74337eb85995b815254fe47ea2a43c877..b2fcec4f22fd1087630ffe0a172b3fed3a4b796b 100644 (file)
@@ -13,9 +13,8 @@ properties:
   compatible:
     items:
       - enum:
-        - bananapi,lhr050h41
-        - feixin,k101-im2byl02
-
+          - bananapi,lhr050h41
+          - feixin,k101-im2byl02
       - const: ilitek,ili9881c
 
   backlight: true
index 937323cc9aaac12f3abae9f9941d0ea86c558932..51f423297ec8447b46575016d8b428644ba4822d 100644 (file)
@@ -37,6 +37,9 @@ properties:
 
   reset-gpios: true
 
+  'mantix,tp-rstn-gpios':
+    description: second reset line that triggers DSI config load
+
   backlight: true
 
 required:
@@ -63,6 +66,7 @@ examples:
             avee-supply = <&reg_avee>;
             vddi-supply = <&reg_1v8_p>;
             reset-gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
+            mantix,tp-rstn-gpios = <&gpio1 24 GPIO_ACTIVE_LOW>;
             backlight = <&backlight>;
         };
     };
index a25387df0865aa94158976c9d26cf1adf580b964..57e5270a0741c0d93d83ccd3ff88f1c16e70d483 100644 (file)
@@ -48,6 +48,7 @@ required:
   - "#address-cells"
   - "#size-cells"
 
+additionalProperties: false
 
 examples:
   - |
index 9810619a2b5c899aa5d0da640d755aec2a6fb477..7449736376788ba39515fce6b674324b5859ec5c 100644 (file)
@@ -81,14 +81,14 @@ properties:
   at25,byte-len:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
-       Total eeprom size in bytes. Deprecated, use "size" property instead.
+      Total eeprom size in bytes. Deprecated, use "size" property instead.
     deprecated: true
 
   at25,addr-mode:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
-       Addr-mode flags, as defined in include/linux/spi/eeprom.h.
-       Deprecated, use "address-width" property instead.
+      Addr-mode flags, as defined in include/linux/spi/eeprom.h.
+      Deprecated, use "address-width" property instead.
     deprecated: true
 
   at25,page-size:
index e2d2c10e536a640a135bf2d7d6d0282c9dc6410a..b032471831e7c711892787b6d279a7dfa46da974 100644 (file)
@@ -43,8 +43,8 @@ properties:
   gpio-controller: true
 
   gpio-line-names:
-      minItems: 1
-      maxItems: 8
+    minItems: 1
+    maxItems: 8
 
 required:
   - compatible
diff --git a/Documentation/devicetree/bindings/i2c/google,cros-ec-i2c-tunnel.yaml b/Documentation/devicetree/bindings/i2c/google,cros-ec-i2c-tunnel.yaml
new file mode 100644 (file)
index 0000000..b386e41
--- /dev/null
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/i2c/google,cros-ec-i2c-tunnel.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: I2C bus that tunnels through the ChromeOS EC (cros-ec)
+
+maintainers:
+  - Doug Anderson <dianders@chromium.org>
+  - Benson Leung <bleung@chromium.org>
+  - Enric Balletbo i Serra <enric.balletbo@collabora.com>
+
+description: |
+  On some ChromeOS board designs we've got a connection to the EC
+  (embedded controller) but no direct connection to some devices on the
+  other side of the EC (like a battery and PMIC).  To get access to
+  those devices we need to tunnel our i2c commands through the EC.
+
+  The node for this device should be under a cros-ec node like
+  google,cros-ec-spi or google,cros-ec-i2c.
+
+allOf:
+  - $ref: i2c-controller.yaml#
+
+properties:
+  compatible:
+    const: google,cros-ec-i2c-tunnel
+
+  google,remote-bus:
+    description: The EC bus we'd like to talk to.
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - google,remote-bus
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        cros-ec@0 {
+            compatible = "google,cros-ec-spi";
+            reg = <0>;
+            spi-max-frequency = <5000000>;
+
+            i2c-tunnel {
+                compatible = "google,cros-ec-i2c-tunnel";
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                google,remote-bus = <0>;
+
+                battery: sbs-battery@b {
+                    compatible = "sbs,sbs-battery";
+                    reg = <0xb>;
+                    sbs,poll-retry-count = <1>;
+                };
+            };
+        };
+    };
diff --git a/Documentation/devicetree/bindings/i2c/i2c-cros-ec-tunnel.txt b/Documentation/devicetree/bindings/i2c/i2c-cros-ec-tunnel.txt
deleted file mode 100644 (file)
index 898f030..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-I2C bus that tunnels through the ChromeOS EC (cros-ec)
-======================================================
-On some ChromeOS board designs we've got a connection to the EC (embedded
-controller) but no direct connection to some devices on the other side of
-the EC (like a battery and PMIC).  To get access to those devices we need
-to tunnel our i2c commands through the EC.
-
-The node for this device should be under a cros-ec node like google,cros-ec-spi
-or google,cros-ec-i2c.
-
-
-Required properties:
-- compatible: google,cros-ec-i2c-tunnel
-- google,remote-bus: The EC bus we'd like to talk to.
-
-Optional child nodes:
-- One node per I2C device connected to the tunnelled I2C bus.
-
-
-Example:
-       cros-ec@0 {
-               compatible = "google,cros-ec-spi";
-
-               ...
-
-               i2c-tunnel {
-                       compatible = "google,cros-ec-i2c-tunnel";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
-                       google,remote-bus = <0>;
-
-                       battery: sbs-battery@b {
-                               compatible = "sbs,sbs-battery";
-                               reg = <0xb>;
-                               sbs,poll-retry-count = <1>;
-                       };
-               };
-       }
index 0e7b4b8a7e48deee37153292cb3314f32c62c958..e1e65eb4f795975e3e4357eb8b76509d26c8bb4f 100644 (file)
@@ -19,11 +19,11 @@ properties:
   compatible:
     oneOf:
       - enum:
-        - ingenic,jz4770-i2c
-        - ingenic,x1000-i2c
+          - ingenic,jz4770-i2c
+          - ingenic,x1000-i2c
       - items:
-        - const: ingenic,jz4780-i2c
-        - const: ingenic,jz4770-i2c
+          - const: ingenic,jz4780-i2c
+          - const: ingenic,jz4770-i2c
 
   reg:
     maxItems: 1
index 6feafb7e531e303e70a3d9a45db2fcf2d7b9ca26..930f9e3904d7d9647879059be84c11a270e0be38 100644 (file)
@@ -43,4 +43,5 @@ examples:
         vref-supply = <&adc_vref>;
       };
     };
-...
\ No newline at end of file
+...
+
index d3733ad8785ae489e305b6c8a16f3430833d5801..8f32800fe5b73c24aab14f7b01f39f6733a1218e 100644 (file)
@@ -46,7 +46,8 @@ properties:
   spi-max-frequency: true
 
   spi-cpol: true
-  spi-cpha : true
+
+  spi-cpha: true
 
   "#io-channel-cells":
     const: 1
index 5d92b477e23f91e1065170e505bd871ce4293b15..4e695b97d0156ba916dac2913a191cb300bdb2a5 100644 (file)
@@ -22,8 +22,8 @@ properties:
   adc-reserved-channels:
     $ref: /schemas/types.yaml#/definitions/uint32
     description:
-       Bitmask of reserved channels, i.e. channels that cannot be
-       used by the OS.
+      Bitmask of reserved channels, i.e. channels that cannot be
+      used by the OS.
 
   clocks:
     maxItems: 1
index 9514c3381c422c7c79968852ea5becc4afd70da4..52490cbb0af08755427adc08403bd986eaafe133 100644 (file)
@@ -21,7 +21,7 @@ properties:
 
   gpios:
     description:
-       GPIO used for controlling the reset pin
+      GPIO used for controlling the reset pin
     maxItems: 1
 
   spi-max-frequency: true
index 6a176f551d755f55c4ec6f3a8d9bceb7e3450030..c1772b568cd1b10f7af038babb98f65094a72a43 100644 (file)
@@ -28,6 +28,8 @@ required:
   - reg
   - vref-supply
 
+additionalProperties: false
+
 examples:
   - |
     i2c {
index dc870eb2875f8563b7f62d9d664056fe90945381..7037f82ec7530f99b111e94416d621dd8d7710e2 100644 (file)
@@ -32,6 +32,8 @@ required:
   - compatible
   - reg
 
+additionalProperties: false
+
 examples:
   - |
     i2c0 {
diff --git a/Documentation/devicetree/bindings/input/cros-ec-keyb.txt b/Documentation/devicetree/bindings/input/cros-ec-keyb.txt
deleted file mode 100644 (file)
index 0f6355c..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-ChromeOS EC Keyboard
-
-Google's ChromeOS EC Keyboard is a simple matrix keyboard implemented on
-a separate EC (Embedded Controller) device. It provides a message for reading
-key scans from the EC. These are then converted into keycodes for processing
-by the kernel.
-
-This binding is based on matrix-keymap.txt and extends/modifies it as follows:
-
-Required properties:
-- compatible: "google,cros-ec-keyb"
-
-Optional properties:
-- google,needs-ghost-filter: True to enable a ghost filter for the matrix
-keyboard. This is recommended if the EC does not have its own logic or
-hardware for this.
-
-
-Example:
-
-cros-ec-keyb {
-       compatible = "google,cros-ec-keyb";
-       keypad,num-rows = <8>;
-       keypad,num-columns = <13>;
-       google,needs-ghost-filter;
-       /*
-        * Keymap entries take the form of 0xRRCCKKKK where
-        * RR=Row CC=Column KKKK=Key Code
-        * The values below are for a US keyboard layout and
-        * are taken from the Linux driver. Note that the
-        * 102ND key is not used for US keyboards.
-        */
-       linux,keymap = <
-               /* CAPSLCK F1         B          F10     */
-               0x0001003a 0x0002003b 0x00030030 0x00040044
-               /* N       =          R_ALT      ESC     */
-               0x00060031 0x0008000d 0x000a0064 0x01010001
-               /* F4      G          F7         H       */
-               0x0102003e 0x01030022 0x01040041 0x01060023
-               /* '       F9         BKSPACE    L_CTRL  */
-               0x01080028 0x01090043 0x010b000e 0x0200001d
-               /* TAB     F3         T          F6      */
-               0x0201000f 0x0202003d 0x02030014 0x02040040
-               /* ]       Y          102ND      [       */
-               0x0205001b 0x02060015 0x02070056 0x0208001a
-               /* F8      GRAVE      F2         5       */
-               0x02090042 0x03010029 0x0302003c 0x03030006
-               /* F5      6          -          \       */
-               0x0304003f 0x03060007 0x0308000c 0x030b002b
-               /* R_CTRL  A          D          F       */
-               0x04000061 0x0401001e 0x04020020 0x04030021
-               /* S       K          J          ;       */
-               0x0404001f 0x04050025 0x04060024 0x04080027
-               /* L       ENTER      Z          C       */
-               0x04090026 0x040b001c 0x0501002c 0x0502002e
-               /* V       X          ,          M       */
-               0x0503002f 0x0504002d 0x05050033 0x05060032
-               /* L_SHIFT /          .          SPACE   */
-               0x0507002a 0x05080035 0x05090034 0x050B0039
-               /* 1       3          4          2       */
-               0x06010002 0x06020004 0x06030005 0x06040003
-               /* 8       7          0          9       */
-               0x06050009 0x06060008 0x0608000b 0x0609000a
-               /* L_ALT   DOWN       RIGHT      Q       */
-               0x060a0038 0x060b006c 0x060c006a 0x07010010
-               /* E       R          W          I       */
-               0x07020012 0x07030013 0x07040011 0x07050017
-               /* U       R_SHIFT    P          O       */
-               0x07060016 0x07070036 0x07080019 0x07090018
-               /* UP      LEFT    */
-               0x070b0067 0x070c0069>;
-};
diff --git a/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml b/Documentation/devicetree/bindings/input/google,cros-ec-keyb.yaml
new file mode 100644 (file)
index 0000000..8e50c14
--- /dev/null
@@ -0,0 +1,92 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+
+$id: http://devicetree.org/schemas/input/google,cros-ec-keyb.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ChromeOS EC Keyboard
+
+maintainers:
+  - Simon Glass <sjg@chromium.org>
+  - Benson Leung <bleung@chromium.org>
+  - Enric Balletbo i Serra <enric.balletbo@collabora.com>
+
+description: |
+  Google's ChromeOS EC Keyboard is a simple matrix keyboard
+  implemented on a separate EC (Embedded Controller) device. It provides
+  a message for reading key scans from the EC. These are then converted
+  into keycodes for processing by the kernel.
+
+allOf:
+  - $ref: "/schemas/input/matrix-keymap.yaml#"
+
+properties:
+  compatible:
+    const: google,cros-ec-keyb
+
+  google,needs-ghost-filter:
+    description:
+      Enable a ghost filter for the matrix keyboard. This is recommended
+      if the EC does not have its own logic or hardware for this.
+    type: boolean
+
+required:
+  - compatible
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    cros-ec-keyb {
+        compatible = "google,cros-ec-keyb";
+        keypad,num-rows = <8>;
+        keypad,num-columns = <13>;
+        google,needs-ghost-filter;
+        /*
+         * Keymap entries take the form of 0xRRCCKKKK where
+         * RR=Row CC=Column KKKK=Key Code
+         * The values below are for a US keyboard layout and
+         * are taken from the Linux driver. Note that the
+         * 102ND key is not used for US keyboards.
+         */
+        linux,keymap = <
+            /* CAPSLCK F1         B          F10     */
+            0x0001003a 0x0002003b 0x00030030 0x00040044
+            /* N       =          R_ALT      ESC     */
+            0x00060031 0x0008000d 0x000a0064 0x01010001
+            /* F4      G          F7         H       */
+            0x0102003e 0x01030022 0x01040041 0x01060023
+            /* '       F9         BKSPACE    L_CTRL  */
+            0x01080028 0x01090043 0x010b000e 0x0200001d
+            /* TAB     F3         T          F6      */
+            0x0201000f 0x0202003d 0x02030014 0x02040040
+            /* ]       Y          102ND      [       */
+            0x0205001b 0x02060015 0x02070056 0x0208001a
+            /* F8      GRAVE      F2         5       */
+            0x02090042 0x03010029 0x0302003c 0x03030006
+            /* F5      6          -          \       */
+            0x0304003f 0x03060007 0x0308000c 0x030b002b
+            /* R_CTRL  A          D          F       */
+            0x04000061 0x0401001e 0x04020020 0x04030021
+            /* S       K          J          ;       */
+            0x0404001f 0x04050025 0x04060024 0x04080027
+            /* L       ENTER      Z          C       */
+            0x04090026 0x040b001c 0x0501002c 0x0502002e
+            /* V       X          ,          M       */
+            0x0503002f 0x0504002d 0x05050033 0x05060032
+            /* L_SHIFT /          .          SPACE   */
+            0x0507002a 0x05080035 0x05090034 0x050B0039
+            /* 1       3          4          2       */
+            0x06010002 0x06020004 0x06030005 0x06040003
+            /* 8       7          0          9       */
+            0x06050009 0x06060008 0x0608000b 0x0609000a
+            /* L_ALT   DOWN       RIGHT      Q       */
+            0x060a0038 0x060b006c 0x060c006a 0x07010010
+            /* E       R          W          I       */
+            0x07020012 0x07030013 0x07040011 0x07050017
+            /* U       R_SHIFT    P          O       */
+            0x07060016 0x07070036 0x07080019 0x07090018
+            /* UP      LEFT    */
+            0x070b0067 0x070c0069>;
+    };
index bbf79d125675dfef4cd07b95ab528f797563d013..1c4c009dedd041c17ebd30aeeeb5ff357b275491 100644 (file)
@@ -94,12 +94,12 @@ properties:
               instances.
 
 required:
- - compatible
- - reg
- - interrupts
- - interrupt-names
- - interrupt-controller
- - "#interrupt-cells"
 - compatible
 - reg
 - interrupts
 - interrupt-names
 - interrupt-controller
 - "#interrupt-cells"
 
 additionalProperties: false
 
index c7cd05656a3e9cf38ac5b66f833ce42d74561502..b5af120114990a7e42acb32824efc91a7232c507 100644 (file)
@@ -32,6 +32,11 @@ description: |
                        | | vint  | bit  |  | 0 |.....|63| vintx  |
                        | +--------------+  +------------+        |
                        |                                         |
+                       |      Unmap                              |
+                       | +--------------+                        |
+  Unmapped events ---->| |   umapidx    |-------------------------> Globalevents
+                       | +--------------+                        |
+                       |                                         |
                        +-----------------------------------------+
 
   Configuration of these Intmap registers that maps global events to vint is
@@ -70,6 +75,11 @@ properties:
         - description: |
             "limit" specifies the limit for translation
 
+  ti,unmapped-event-sources:
+    $ref: /schemas/types.yaml#definitions/phandle-array
+    description:
+      Array of phandles to DMA controllers where the unmapped events originate.
+
 required:
   - compatible
   - reg
@@ -79,6 +89,8 @@ required:
   - ti,sci-dev-id
   - ti,interrupt-ranges
 
+unevaluatedProperties: false
+
 examples:
   - |
     bus {
index cff6a956afb44e287e9be0d9b15b693e4c6fdaa2..e12aee42b12685fe6a26233bc79a73a8d30e6137 100644 (file)
@@ -88,6 +88,8 @@ required:
   - ti,sci-dev-id
   - ti,interrupt-ranges
 
+unevaluatedProperties: false
+
 examples:
   - |
     main_gpio_intr: interrupt-controller0 {
index 4e7e95e331a57dc26dd598c87eb8a8477b2fe062..bc817f77d2b109f20de0e296625e0d861abbfd83 100644 (file)
@@ -32,3 +32,5 @@ properties:
       that a LED can be made so bright that it gets damaged or causes damage
       due to restrictions in a specific system, such as mounting conditions.
     $ref: /schemas/types.yaml#definitions/uint32
+
+additionalProperties: true
index 08b6700ca61edecfe898f987d7d63716f993356a..f1211e7045f12f3696c029e9af8b4c455fce8064 100644 (file)
@@ -43,7 +43,7 @@ properties:
       LED_COLOR_ID available, add a new one.
     $ref: /schemas/types.yaml#definitions/uint32
     minimum: 0
-    maximum: 8
+    maximum: 9
 
   function-enumerator:
     description:
index b1a53f054b895e4c88b195d5cf8f4f817596e57d..37445c68cdef9aac2bab2ef46323c3bf2cdc516b 100644 (file)
@@ -16,7 +16,7 @@ description: |
   modules. This is achieved by adding multi-led nodes layer to the
   monochrome LED bindings.
   The nodes and properties defined in this document are unique to the multicolor
-  LED class.  Common LED nodes and properties are inherited from the common.txt
+  LED class.  Common LED nodes and properties are inherited from the common.yaml
   within this documentation directory.
 
 patternProperties:
@@ -25,10 +25,11 @@ patternProperties:
     description: Represents the LEDs that are to be grouped.
     properties:
       color:
-        const: 8  # LED_COLOR_ID_MULTI
         description: |
-          For multicolor LED support this property should be defined as
-          LED_COLOR_ID_MULTI which can be found in include/linux/leds/common.h.
+          For multicolor LED support this property should be defined as either
+          LED_COLOR_ID_RGB or LED_COLOR_ID_MULTI which can be found in
+          include/linux/leds/common.h.
+        enum: [ 8, 9 ]
 
     $ref: "common.yaml#"
 
index 947542a253ec6bae8ad79292231ef87be69860c1..c192b5feadc76c80147ac2c99c1f34563d2256bd 100644 (file)
@@ -46,6 +46,12 @@ properties:
   vled-supply:
     description: LED supply.
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
 patternProperties:
   '^multi-led@[0-9a-f]$':
     type: object
@@ -69,6 +75,8 @@ required:
   - compatible
   - reg
 
+additionalProperties: false
+
 examples:
   - |
    #include <dt-bindings/gpio/gpio.h>
index cf48cd806e0022a793663cd8d13fde504168ea02..7771ecaac58683a68bd2a6bb03deb1b6b4b486e4 100644 (file)
@@ -47,7 +47,7 @@ Example:
                interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_LOW>;
                clocks = <&infracfg CLK_INFRA_GCE>;
                clock-names = "gce";
-               #mbox-cells = <3>;
+               #mbox-cells = <2>;
        };
 
 Example for a client device:
index 074243c40891088b5938f0f025a7732aff1eca6d..08af356f5d275d590a57f232e88f075c8f93554c 100644 (file)
@@ -17,7 +17,7 @@ properties:
   compatible:
     items:
       - enum:
-        - dell,wyse-ariel-ec  # Dell Wyse Ariel board (3020)
+          - dell,wyse-ariel-ec  # Dell Wyse Ariel board (3020)
       - const: ene,kb3930
   reg:
     maxItems: 1
index f49c0d5d31ad20ed82ae5658a0f0f3f0c8fd043b..76bf16ee27ec746fdb2b49f4b73efeb3a3301008 100644 (file)
@@ -59,6 +59,14 @@ properties:
       whether this nvram is present or not.
     type: boolean
 
+  mtk,rpmsg-name:
+    description:
+      Must be defined if the cros-ec is a rpmsg device for a Mediatek
+      ARM Cortex M4 Co-processor. Contains the name pf the rpmsg
+      device. Used to match the subnode to the rpmsg device announced by
+      the SCP.
+    $ref: "/schemas/types.yaml#/definitions/string"
+
   spi-max-frequency:
     description: Maximum SPI frequency of the device in Hz.
 
@@ -71,6 +79,54 @@ properties:
   wakeup-source:
     description: Button can wake-up the system.
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  typec:
+    $ref: "/schemas/chrome/google,cros-ec-typec.yaml#"
+
+  ec-pwm:
+    $ref: "/schemas/pwm/google,cros-ec-pwm.yaml#"
+
+  keyboard-controller:
+    $ref: "/schemas/input/google,cros-ec-keyb.yaml#"
+
+  codecs:
+    type: object
+    additionalProperties: false
+
+    properties:
+      '#address-cells':
+        const: 2
+
+      '#size-cells':
+        const: 1
+
+    patternProperties:
+      "^ec-codec@[a-f0-9]+$":
+        type: object
+        $ref: "/schemas/sound/google,cros-ec-codec.yaml#"
+
+    required:
+      - "#address-cells"
+      - "#size-cells"
+
+patternProperties:
+  "^i2c-tunnel[0-9]*$":
+    type: object
+    $ref: "/schemas/i2c/google,cros-ec-i2c-tunnel.yaml#"
+
+  "^regulator@[0-9]+$":
+    type: object
+    $ref: "/schemas/regulator/google,cros-ec-regulator.yaml#"
+
+  "^extcon[0-9]*$":
+    type: object
+    $ref: "/schemas/extcon/extcon-usbc-cros-ec.yaml#"
+
 required:
   - compatible
 
index dc21b4630c25cdaa407c8c271346139cc93a1a01..ee00d414df100142d52d5a826917f35f80c79203 100644 (file)
@@ -52,4 +52,7 @@ properties:
         items:
           - const: yna,cu2000-neo
           - const: ingenic,x2000e
+
+additionalProperties: true
+
 ...
index d25e80aa8b2aec73eeb22858c265516e01ab8b22..9fee6708e6f5937698dfa8f06ade8b7d863ca0fd 100644 (file)
@@ -36,4 +36,7 @@ properties:
       - description: Virtual Loongson64 Quad Core + VirtIO
         items:
           - const: loongson,loongson64v-4core-virtio
+
+additionalProperties: true
+
 ...
index 58fe9d02a781a035c1b35a0a234a98f8652293bf..0753289fba844cc517d31a55d12d4af7f8ec1f1a 100644 (file)
@@ -32,11 +32,11 @@ allOf:
         clock-output-names:
           oneOf:
             - items:
-              - const: clk_out_sd0
-              - const: clk_in_sd0
+                - const: clk_out_sd0
+                - const: clk_in_sd0
             - items:
-              - const: clk_out_sd1
-              - const: clk_in_sd1
+                - const: clk_out_sd1
+                - const: clk_in_sd1
 
 properties:
   compatible:
index 55883290543b93f520227e41c9d2831d51abe67b..69ff065c9a39ad68f5409210cc49b925cbb02935 100644 (file)
@@ -46,6 +46,8 @@ required:
   - clocks
   - clock-names
 
+unevaluatedProperties: false
+
 examples:
   - |
     #include <dt-bindings/interrupt-controller/arm-gic.h>
index ac79f3adf20b0d2103cad46e7cb8f66efc780af7..1ae945434c53c8ed38b0e094c84043202dbf3c5a 100644 (file)
@@ -3,7 +3,7 @@
 %YAML 1.2
 ---
 $id: "http://devicetree.org/schemas/mmc/sdhci-am654.yaml#"
-$schema : "http://devicetree.org/meta-schemas/core.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
 
 title: TI AM654 MMC Controller
 
@@ -163,13 +163,12 @@ properties:
   ti,driver-strength-ohm:
     description: DLL drive strength in ohms
     $ref: "/schemas/types.yaml#/definitions/uint32"
-    oneOf:
-      - enum:
-        - 33
-        - 40
-        - 50
-        - 66
-        - 100
+    enum:
+      - 33
+      - 40
+      - 50
+      - 66
+      - 100
 
   ti,strobe-sel:
     description: strobe select delay for HS400 speed mode.
@@ -187,6 +186,8 @@ required:
   - clock-names
   - ti,otap-del-sel-legacy
 
+unevaluatedProperties: false
+
 examples:
   - |
     #include <dt-bindings/interrupt-controller/irq.h>
diff --git a/Documentation/devicetree/bindings/net/can/can-controller.yaml b/Documentation/devicetree/bindings/net/can/can-controller.yaml
new file mode 100644 (file)
index 0000000..9cf2ae0
--- /dev/null
@@ -0,0 +1,18 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/can/can-controller.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: CAN Controller Generic Binding
+
+maintainers:
+  - Marc Kleine-Budde <mkl@pengutronix.de>
+
+properties:
+  $nodename:
+    pattern: "^can(@.*)?$"
+
+additionalProperties: true
+
+...
diff --git a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
new file mode 100644 (file)
index 0000000..43df15b
--- /dev/null
@@ -0,0 +1,135 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/can/fsl,flexcan.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title:
+  Flexcan CAN controller on Freescale's ARM and PowerPC system-on-a-chip (SOC).
+
+maintainers:
+  - Marc Kleine-Budde <mkl@pengutronix.de>
+
+allOf:
+  - $ref: can-controller.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - enum:
+          - fsl,imx8qm-flexcan
+          - fsl,imx8mp-flexcan
+          - fsl,imx6q-flexcan
+          - fsl,imx53-flexcan
+          - fsl,imx35-flexcan
+          - fsl,imx28-flexcan
+          - fsl,imx25-flexcan
+          - fsl,p1010-flexcan
+          - fsl,vf610-flexcan
+          - fsl,ls1021ar2-flexcan
+          - fsl,lx2160ar1-flexcan
+      - items:
+          - enum:
+              - fsl,imx7d-flexcan
+              - fsl,imx6ul-flexcan
+              - fsl,imx6sx-flexcan
+          - const: fsl,imx6q-flexcan
+      - items:
+          - enum:
+              - fsl,ls1028ar1-flexcan
+          - const: fsl,lx2160ar1-flexcan
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: ipg
+      - const: per
+
+  clock-frequency:
+    description: |
+      The oscillator frequency driving the flexcan device, filled in by the
+      boot loader. This property should only be used the used operating system
+      doesn't support the clocks and clock-names property.
+
+  xceiver-supply:
+    description: Regulator that powers the CAN transceiver.
+
+  big-endian:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: |
+      This means the registers of FlexCAN controller are big endian. This is
+      optional property.i.e. if this property is not present in device tree
+      node then controller is assumed to be little endian. If this property is
+      present then controller is assumed to be big endian.
+
+  fsl,stop-mode:
+    description: |
+      Register bits of stop mode control.
+
+      The format should be as follows:
+      <gpr req_gpr req_bit>
+      gpr is the phandle to general purpose register node.
+      req_gpr is the gpr register offset of CAN stop request.
+      req_bit is the bit offset of CAN stop request.
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - description: The 'gpr' is the phandle to general purpose register node.
+      - description: The 'req_gpr' is the gpr register offset of CAN stop request.
+        maximum: 0xff
+      - description: The 'req_bit' is the bit offset of CAN stop request.
+        maximum: 0x1f
+
+  fsl,clk-source:
+    description: |
+      Select the clock source to the CAN Protocol Engine (PE). It's SoC
+      implementation dependent. Refer to RM for detailed definition. If this
+      property is not set in device tree node then driver selects clock source 1
+      by default.
+      0: clock source 0 (oscillator clock)
+      1: clock source 1 (peripheral clock)
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 1
+    minimum: 0
+    maximum: 1
+
+  wakeup-source:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Enable CAN remote wakeup.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    can@1c000 {
+        compatible = "fsl,p1010-flexcan";
+        reg = <0x1c000 0x1000>;
+        interrupts = <48 0x2>;
+        interrupt-parent = <&mpic>;
+        clock-frequency = <200000000>;
+        fsl,clk-source = <0>;
+    };
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    can@2090000 {
+        compatible = "fsl,imx6q-flexcan";
+        reg = <0x02090000 0x4000>;
+        interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&clks 1>, <&clks 2>;
+        clock-names = "ipg", "per";
+        fsl,stop-mode = <&gpr 0x34 28>;
+    };
diff --git a/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt b/Documentation/devicetree/bindings/net/can/fsl-flexcan.txt
deleted file mode 100644 (file)
index e10b6eb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-Flexcan CAN controller on Freescale's ARM and PowerPC system-on-a-chip (SOC).
-
-Required properties:
-
-- compatible : Should be "fsl,<processor>-flexcan"
-
-  where <processor> is imx8qm, imx6q, imx28, imx53, imx35, imx25, p1010,
-  vf610, ls1021ar2, lx2160ar1, ls1028ar1.
-
-  The ls1028ar1 must be followed by lx2160ar1, e.g.
-   - "fsl,ls1028ar1-flexcan", "fsl,lx2160ar1-flexcan"
-
-  An implementation should also claim any of the following compatibles
-  that it is fully backwards compatible with:
-
-  - fsl,p1010-flexcan
-
-- reg : Offset and length of the register set for this device
-- interrupts : Interrupt tuple for this device
-
-Optional properties:
-
-- clock-frequency : The oscillator frequency driving the flexcan device
-
-- xceiver-supply: Regulator that powers the CAN transceiver
-
-- big-endian: This means the registers of FlexCAN controller are big endian.
-              This is optional property.i.e. if this property is not present in
-              device tree node then controller is assumed to be little endian.
-              if this property is present then controller is assumed to be big
-              endian.
-
-- fsl,stop-mode: register bits of stop mode control, the format is
-                <&gpr req_gpr req_bit>.
-                gpr is the phandle to general purpose register node.
-                req_gpr is the gpr register offset of CAN stop request.
-                req_bit is the bit offset of CAN stop request.
-
-- fsl,clk-source: Select the clock source to the CAN Protocol Engine (PE).
-                 It's SoC Implementation dependent. Refer to RM for detailed
-                 definition. If this property is not set in device tree node
-                 then driver selects clock source 1 by default.
-                 0: clock source 0 (oscillator clock)
-                 1: clock source 1 (peripheral clock)
-
-- wakeup-source: enable CAN remote wakeup
-
-Example:
-
-       can@1c000 {
-               compatible = "fsl,p1010-flexcan";
-               reg = <0x1c000 0x1000>;
-               interrupts = <48 0x2>;
-               interrupt-parent = <&mpic>;
-               clock-frequency = <200000000>; // filled in by bootloader
-               fsl,clk-source = <0>; // select clock source 0 for PE
-       };
index fa3ebba4e63584b34ece8b8c3d44c26a72709af1..c1948ce00081b66e18d65769a6700b48455f4ebc 100644 (file)
@@ -46,6 +46,8 @@ required:
   - clocks
   - clock-names
 
+unevaluatedProperties: false
+
 examples:
 # FIXME: Remove defines and include the correct header file
 # once it is available in mainline.
index 55913534cbc2b843d91d5d81c390d6a3c16a8998..75e8712e903a6ce9381e4cc0576bbcde32fb08e9 100644 (file)
@@ -65,6 +65,8 @@ properties:
 required:
   - reg
 
+unevaluatedProperties: false
+
 examples:
   - |
     mdio0 {
index f4292d2c54e3c4201561e2828a6b285926e0e4ec..d6cf8a560ef00c42d9f03424061eba51550eb852 100644 (file)
@@ -29,16 +29,16 @@ properties:
   reg-names:
     oneOf:
       - items:
-        - const: dbi
-        - const: dbi2
-        - const: link
-        - const: addr_space
+          - const: dbi
+          - const: dbi2
+          - const: link
+          - const: addr_space
       - items:
-        - const: dbi
-        - const: dbi2
-        - const: link
-        - const: addr_space
-        - const: atu
+          - const: dbi
+          - const: dbi2
+          - const: link
+          - const: addr_space
+          - const: atu
 
   clocks:
     maxItems: 2
index 5aad9f4e0b2a6c47ac8caceec7ee0594622bfe8f..80a92385367ee82f3adc6a0cb942edda4f1f2c2d 100644 (file)
@@ -15,6 +15,9 @@ properties:
       - enum:
           - fsl,imx8-ddr-pmu
           - fsl,imx8m-ddr-pmu
+          - fsl,imx8mq-ddr-pmu
+          - fsl,imx8mm-ddr-pmu
+          - fsl,imx8mn-ddr-pmu
           - fsl,imx8mp-ddr-pmu
       - items:
           - enum:
index bab2ff4d9dc98bb53be0d00068919681df1cde7d..34756347a14ef59e5242f022a41e35fde3f77097 100644 (file)
@@ -31,10 +31,10 @@ properties:
   clock-names:
     oneOf:
       - items:          # for PXs2
-        - const: link
+          - const: link
       - items:          # for others
-        - const: link
-        - const: phy
+          - const: link
+          - const: phy
 
   resets:
     maxItems: 2
index 15207ca9548f2f0144ba914ba1a24af5a9a6bdeb..83d5d0aceb04ef19adec4ade54560414f4027206 100644 (file)
@@ -7,23 +7,23 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: OMAP USB2 PHY
 
 maintainers:
- - Kishon Vijay Abraham I <kishon@ti.com>
- - Roger Quadros <rogerq@ti.com>
 - Kishon Vijay Abraham I <kishon@ti.com>
 - Roger Quadros <rogerq@ti.com>
 
 properties:
   compatible:
     oneOf:
       - items:
-        - enum:
-          - ti,dra7x-usb2
-          - ti,dra7x-usb2-phy2
-          - ti,am654-usb2
-        - enum:
-          - ti,omap-usb2
+          - enum:
+              - ti,dra7x-usb2
+              - ti,dra7x-usb2-phy2
+              - ti,am654-usb2
+          - enum:
+              - ti,omap-usb2
       - items:
-        - const: ti,am437x-usb2
+          - const: ti,am437x-usb2
       - items:
-        - const: ti,omap-usb2
+          - const: ti,omap-usb2
 
   reg:
     maxItems: 1
@@ -62,6 +62,8 @@ required:
   - clocks
   - clock-names
 
+additionalProperties: false
+
 examples:
   - |
     usb0_phy: phy@4100000 {
index 33391d30c00c5008cc7a2b37e82fd50a7c54dd06..ccdd9e3820d737016724135bb527b03a49130ad5 100644 (file)
@@ -76,22 +76,22 @@ patternProperties:
             items:
               oneOf:
                 - enum: [lcd0_d18_mfp, rmii_crs_dv_mfp, rmii_txd0_mfp,
-                    rmii_txd1_mfp, rmii_txen_mfp, rmii_rxen_mfp, rmii_rxd1_mfp,
-                    rmii_rxd0_mfp, rmii_ref_clk_mfp, i2s_d0_mfp, i2s_pcm1_mfp,
-                    i2s0_pcm0_mfp, i2s1_pcm0_mfp, i2s_d1_mfp, ks_in2_mfp,
-                    ks_in1_mfp, ks_in0_mfp, ks_in3_mfp, ks_out0_mfp,
-                    ks_out1_mfp, ks_out2_mfp, lvds_o_pn_mfp, dsi_dn0_mfp,
-                    dsi_dp2_mfp, lcd0_d17_mfp, dsi_dp3_mfp, dsi_dn3_mfp,
-                    dsi_dp0_mfp, lvds_ee_pn_mfp, spi0_i2c_pcm_mfp,
-                    spi0_i2s_pcm_mfp, dsi_dnp1_cp_mfp, lvds_e_pn_mfp,
-                    dsi_dn2_mfp, uart2_rtsb_mfp, uart2_ctsb_mfp, uart3_rtsb_mfp,
-                    uart3_ctsb_mfp, sd0_d0_mfp, sd0_d1_mfp, sd0_d2_d3_mfp,
-                    sd1_d0_d3_mfp, sd0_cmd_mfp, sd0_clk_mfp, sd1_cmd_mfp,
-                    uart0_rx_mfp, clko_25m_mfp, csi_cn_cp_mfp, sens0_ckout_mfp,
-                    uart0_tx_mfp, i2c0_mfp, csi_dn_dp_mfp, sen0_pclk_mfp,
-                    pcm1_in_mfp, pcm1_clk_mfp, pcm1_sync_mfp, pcm1_out_mfp,
-                    dnand_data_wr_mfp, dnand_acle_ce0_mfp, nand_ceb2_mfp,
-                    nand_ceb3_mfp]
+                         rmii_txd1_mfp, rmii_txen_mfp, rmii_rxen_mfp, rmii_rxd1_mfp,
+                         rmii_rxd0_mfp, rmii_ref_clk_mfp, i2s_d0_mfp, i2s_pcm1_mfp,
+                         i2s0_pcm0_mfp, i2s1_pcm0_mfp, i2s_d1_mfp, ks_in2_mfp,
+                         ks_in1_mfp, ks_in0_mfp, ks_in3_mfp, ks_out0_mfp,
+                         ks_out1_mfp, ks_out2_mfp, lvds_o_pn_mfp, dsi_dn0_mfp,
+                         dsi_dp2_mfp, lcd0_d17_mfp, dsi_dp3_mfp, dsi_dn3_mfp,
+                         dsi_dp0_mfp, lvds_ee_pn_mfp, spi0_i2c_pcm_mfp,
+                         spi0_i2s_pcm_mfp, dsi_dnp1_cp_mfp, lvds_e_pn_mfp,
+                         dsi_dn2_mfp, uart2_rtsb_mfp, uart2_ctsb_mfp, uart3_rtsb_mfp,
+                         uart3_ctsb_mfp, sd0_d0_mfp, sd0_d1_mfp, sd0_d2_d3_mfp,
+                         sd1_d0_d3_mfp, sd0_cmd_mfp, sd0_clk_mfp, sd1_cmd_mfp,
+                         uart0_rx_mfp, clko_25m_mfp, csi_cn_cp_mfp, sens0_ckout_mfp,
+                         uart0_tx_mfp, i2c0_mfp, csi_dn_dp_mfp, sen0_pclk_mfp,
+                         pcm1_in_mfp, pcm1_clk_mfp, pcm1_sync_mfp, pcm1_out_mfp,
+                         dnand_data_wr_mfp, dnand_acle_ce0_mfp, nand_ceb2_mfp,
+                         nand_ceb3_mfp]
             minItems: 1
             maxItems: 32
 
@@ -100,10 +100,10 @@ patternProperties:
               Specify the alternative function to be configured for the
               given gpio pin groups.
             enum: [nor, eth_rmii, eth_smii, spi0, spi1, spi2, spi3, sens0,
-              sens1, uart0, uart1, uart2, uart3, uart4, uart5, uart6, i2s0,
-              i2s1, pcm1, pcm0, ks, jtag, pwm0, pwm1, pwm2, pwm3, pwm4, pwm5,
-              p0, sd0, sd1, sd2, i2c0, i2c1, i2c3, dsi, lvds, usb30, clko_25m,
-              mipi_csi, nand, spdif, ts, lcd0]
+                   sens1, uart0, uart1, uart2, uart3, uart4, uart5, uart6, i2s0,
+                   i2s1, pcm1, pcm0, ks, jtag, pwm0, pwm1, pwm2, pwm3, pwm4, pwm5,
+                   p0, sd0, sd1, sd2, i2c0, i2c1, i2c3, dsi, lvds, usb30, clko_25m,
+                   mipi_csi, nand, spdif, ts, lcd0]
 
         required:
           - groups
@@ -126,14 +126,14 @@ patternProperties:
             items:
               oneOf:
                 - enum: [sirq_drv, rmii_txd01_txen_drv, rmii_rxer_drv,
-                    rmii_crs_drv, rmii_rxd10_drv, rmii_ref_clk_drv,
-                    smi_mdc_mdio_drv, i2s_d0_drv, i2s_bclk0_drv, i2s3_drv,
-                    i2s13_drv, pcm1_drv, ks_in_drv, ks_out_drv, lvds_all_drv,
-                    lcd_dsi_drv, dsi_drv, sd0_d0_d3_drv, sd1_d0_d3_drv,
-                    sd0_cmd_drv, sd0_clk_drv, sd1_cmd_drv, sd1_clk_drv,
-                    spi0_all_drv, uart0_rx_drv, uart0_tx_drv, uart2_all_drv,
-                    i2c0_all_drv, i2c12_all_drv, sens0_pclk_drv,
-                    sens0_ckout_drv, uart3_all_drv]
+                         rmii_crs_drv, rmii_rxd10_drv, rmii_ref_clk_drv,
+                         smi_mdc_mdio_drv, i2s_d0_drv, i2s_bclk0_drv, i2s3_drv,
+                         i2s13_drv, pcm1_drv, ks_in_drv, ks_out_drv, lvds_all_drv,
+                         lcd_dsi_drv, dsi_drv, sd0_d0_d3_drv, sd1_d0_d3_drv,
+                         sd0_cmd_drv, sd0_clk_drv, sd1_cmd_drv, sd1_clk_drv,
+                         spi0_all_drv, uart0_rx_drv, uart0_tx_drv, uart2_all_drv,
+                         i2c0_all_drv, i2c12_all_drv, sens0_pclk_drv,
+                         sens0_ckout_drv, uart3_all_drv]
             minItems: 1
             maxItems: 32
 
@@ -144,29 +144,29 @@ patternProperties:
             items:
               oneOf:
                 - enum: [dnand_dqs, dnand_dqsn, eth_txd0, eth_txd1, eth_txen,
-                    eth_rxer, eth_crs_dv, eth_rxd1, eth_rxd0, eth_ref_clk,
-                    eth_mdc, eth_mdio, sirq0, sirq1, sirq2, i2s_d0, i2s_bclk0,
-                    i2s_lrclk0, i2s_mclk0, i2s_d1, i2s_bclk1, i2s_lrclk1,
-                    i2s_mclk1, ks_in0, ks_in1, ks_in2, ks_in3, ks_out0, ks_out1,
-                    ks_out2, lvds_oep, lvds_oen, lvds_odp, lvds_odn, lvds_ocp,
-                    lvds_ocn, lvds_obp, lvds_obn, lvds_oap, lvds_oan, lvds_eep,
-                    lvds_een, lvds_edp, lvds_edn, lvds_ecp, lvds_ecn, lvds_ebp,
-                    lvds_ebn, lvds_eap, lvds_ean, lcd0_d18, lcd0_d17, dsi_dp3,
-                    dsi_dn3, dsi_dp1, dsi_dn1, dsi_cp, dsi_cn, dsi_dp0, dsi_dn0,
-                    dsi_dp2, dsi_dn2, sd0_d0, sd0_d1, sd0_d2, sd0_d3, sd1_d0,
-                    sd1_d1, sd1_d2, sd1_d3, sd0_cmd, sd0_clk, sd1_cmd, sd1_clk,
-                    spi0_sclk, spi0_ss, spi0_miso, spi0_mosi, uart0_rx,
-                    uart0_tx, i2c0_sclk, i2c0_sdata, sensor0_pclk,
-                    sensor0_ckout, dnand_ale, dnand_cle, dnand_ceb0, dnand_ceb1,
-                    dnand_ceb2, dnand_ceb3, uart2_rx, uart2_tx, uart2_rtsb,
-                    uart2_ctsb, uart3_rx, uart3_tx, uart3_rtsb, uart3_ctsb,
-                    pcm1_in, pcm1_clk, pcm1_sync, pcm1_out, i2c1_sclk,
-                    i2c1_sdata, i2c2_sclk, i2c2_sdata, csi_dn0, csi_dp0,
-                    csi_dn1, csi_dp1, csi_dn2, csi_dp2, csi_dn3, csi_dp3,
-                    csi_cn, csi_cp, dnand_d0, dnand_d1, dnand_d2, dnand_d3,
-                    dnand_d4, dnand_d5, dnand_d6, dnand_d7, dnand_rb, dnand_rdb,
-                    dnand_rdbn, dnand_wrb, porb, clko_25m, bsel, pkg0, pkg1,
-                    pkg2, pkg3]
+                         eth_rxer, eth_crs_dv, eth_rxd1, eth_rxd0, eth_ref_clk,
+                         eth_mdc, eth_mdio, sirq0, sirq1, sirq2, i2s_d0, i2s_bclk0,
+                         i2s_lrclk0, i2s_mclk0, i2s_d1, i2s_bclk1, i2s_lrclk1,
+                         i2s_mclk1, ks_in0, ks_in1, ks_in2, ks_in3, ks_out0, ks_out1,
+                         ks_out2, lvds_oep, lvds_oen, lvds_odp, lvds_odn, lvds_ocp,
+                         lvds_ocn, lvds_obp, lvds_obn, lvds_oap, lvds_oan, lvds_eep,
+                         lvds_een, lvds_edp, lvds_edn, lvds_ecp, lvds_ecn, lvds_ebp,
+                         lvds_ebn, lvds_eap, lvds_ean, lcd0_d18, lcd0_d17, dsi_dp3,
+                         dsi_dn3, dsi_dp1, dsi_dn1, dsi_cp, dsi_cn, dsi_dp0, dsi_dn0,
+                         dsi_dp2, dsi_dn2, sd0_d0, sd0_d1, sd0_d2, sd0_d3, sd1_d0,
+                         sd1_d1, sd1_d2, sd1_d3, sd0_cmd, sd0_clk, sd1_cmd, sd1_clk,
+                         spi0_sclk, spi0_ss, spi0_miso, spi0_mosi, uart0_rx,
+                         uart0_tx, i2c0_sclk, i2c0_sdata, sensor0_pclk,
+                         sensor0_ckout, dnand_ale, dnand_cle, dnand_ceb0, dnand_ceb1,
+                         dnand_ceb2, dnand_ceb3, uart2_rx, uart2_tx, uart2_rtsb,
+                         uart2_ctsb, uart3_rx, uart3_tx, uart3_rtsb, uart3_ctsb,
+                         pcm1_in, pcm1_clk, pcm1_sync, pcm1_out, i2c1_sclk,
+                         i2c1_sdata, i2c2_sclk, i2c2_sdata, csi_dn0, csi_dp0,
+                         csi_dn1, csi_dp1, csi_dn2, csi_dp2, csi_dn3, csi_dp3,
+                         csi_cn, csi_cp, dnand_d0, dnand_d1, dnand_d2, dnand_d3,
+                         dnand_d4, dnand_d5, dnand_d6, dnand_d7, dnand_rb, dnand_rdb,
+                         dnand_rdbn, dnand_wrb, porb, clko_25m, bsel, pkg0, pkg1,
+                         pkg2, pkg3]
             minItems: 1
             maxItems: 64
 
index 5556def6b99bc4b4625717ea82cb753107945012..c4c07121161163478cd18224975263ef37f4f2d0 100644 (file)
@@ -106,7 +106,7 @@ patternProperties:
     required:
       - pinmux
 
-    additionalProperties:  false
+    additionalProperties: false
 
 required:
   - compatible
index 1f0f5757f9e170fa6654e8e6d8687d5b05784c6a..040d2ada36690ac369f27049f04ae988f56426b8 100644 (file)
@@ -71,9 +71,9 @@ patternProperties:
           Specify the alternative function to be configured for the specified
           pins. Functions are only valid for gpio pins.
         enum: [ gpio, cci_i2c0, blsp_uim1, blsp_uim2, blsp_uim3, blsp_uim5,
-          blsp_i2c1, blsp_i2c2, blsp_i2c3, blsp_i2c5, blsp_spi1,
-          blsp_spi2, blsp_spi3, blsp_spi5, blsp_uart1, blsp_uart2,
-          blsp_uart3, blsp_uart5, cam_mclk0, cam_mclk1, wlan ]
+                blsp_i2c1, blsp_i2c2, blsp_i2c3, blsp_i2c5, blsp_spi1,
+                blsp_spi2, blsp_spi3, blsp_spi5, blsp_uart1, blsp_uart2,
+                blsp_uart3, blsp_uart5, cam_mclk0, cam_mclk1, wlan ]
 
       drive-strength:
         enum: [2, 4, 6, 8, 10, 12, 14, 16]
index d0d1a01140ea79684466b0f83c716514624dc753..9f1dab0c2430b476efef9f929482f1db829babce 100644 (file)
@@ -40,24 +40,24 @@ patternProperties:
           Function to mux.
         $ref: "/schemas/types.yaml#/definitions/string"
         enum: [i2c0, i2c1, i2c2, i2c3, i2c4, i2c5, i2c6, i2c7, i2c8,
-          spi0, spi1, spi2, spi3, spi4, spi5, spi6,
-          uart0, uart1, uart2, uart3, pwm, pcmif_out, pcmif_in]
+               spi0, spi1, spi2, spi3, spi4, spi5, spi6,
+               uart0, uart1, uart2, uart3, pwm, pcmif_out, pcmif_in]
 
       groups:
         description:
           Name of the pin group to use for the functions.
         $ref: "/schemas/types.yaml#/definitions/string"
         enum: [i2c0_grp, i2c1_grp, i2c2_grp, i2c3_grp, i2c4_grp,
-          i2c5_grp, i2c6_grp, i2c7_grp, i2c8_grp,
-          spi0_grp, spi0_cs0_grp, spi0_cs1_grp, spi0_cs2_grp,
-          spi1_grp, spi2_grp, spi3_grp, spi4_grp, spi5_grp, spi6_grp,
-          uart0_grp, uart1_grp, uart2_grp, uart3_grp,
-          pwm0_gpio4_grp, pwm0_gpio8_grp, pwm0_gpio12_grp,
-          pwm0_gpio16_grp, pwm1_gpio5_grp, pwm1_gpio9_grp,
-          pwm1_gpio13_grp, pwm1_gpio17_grp, pwm2_gpio6_grp,
-          pwm2_gpio10_grp, pwm2_gpio14_grp, pwm2_gpio18_grp,
-          pwm3_gpio7_grp, pwm3_gpio11_grp, pwm3_gpio15_grp,
-          pwm3_gpio19_grp, pcmif_out_grp, pcmif_in_grp]
+               i2c5_grp, i2c6_grp, i2c7_grp, i2c8_grp,
+               spi0_grp, spi0_cs0_grp, spi0_cs1_grp, spi0_cs2_grp,
+               spi1_grp, spi2_grp, spi3_grp, spi4_grp, spi5_grp, spi6_grp,
+               uart0_grp, uart1_grp, uart2_grp, uart3_grp,
+               pwm0_gpio4_grp, pwm0_gpio8_grp, pwm0_gpio12_grp,
+               pwm0_gpio16_grp, pwm1_gpio5_grp, pwm1_gpio9_grp,
+               pwm1_gpio13_grp, pwm1_gpio17_grp, pwm2_gpio6_grp,
+               pwm2_gpio10_grp, pwm2_gpio14_grp, pwm2_gpio18_grp,
+               pwm3_gpio7_grp, pwm3_gpio11_grp, pwm3_gpio15_grp,
+               pwm3_gpio19_grp, pcmif_out_grp, pcmif_in_grp]
 
       drive-strength:
         enum: [2, 4, 6, 8, 16, 24, 32]
index a6c91026d4ccd60727bad77636e34eb4715cf72d..9c6fda6b1dd9ac089be820c9608d288de2fad84b 100644 (file)
@@ -28,14 +28,16 @@ description: |
 
 properties:
   mode-normal:
-      $ref: /schemas/types.yaml#/definitions/uint32
-      description: |
-        Default value to set on a reboot if no command was provided.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description:
+      Default value to set on a reboot if no command was provided.
 
 patternProperties:
   "^mode-.*$":
     $ref: /schemas/types.yaml#/definitions/uint32
 
+additionalProperties: false
+
 examples:
   - |
     reboot-mode {
index 867e3e6b7e80f734656fbb91fe316356c53efd10..76c227a7cd5cd833e2ed26560625287cbdffa5ac 100644 (file)
@@ -15,10 +15,10 @@ properties:
     oneOf:
       - const: ingenic,jz4740-battery
       - items:
-        - enum:
-          - ingenic,jz4725b-battery
-          - ingenic,jz4770-battery
-        - const: ingenic,jz4740-battery
+          - enum:
+              - ingenic,jz4725b-battery
+              - ingenic,jz4770-battery
+          - const: ingenic,jz4740-battery
 
   io-channels:
     maxItems: 1
index 193a23af2007bc2eb58177eb006e6b8b64737a3e..983fc215c1e51ecfd778b21051eff3dd618d50c8 100644 (file)
@@ -84,12 +84,12 @@ allOf:
     then:
       properties:
         summit,mains-current-limit-microamp:
-          enum: [ 300000,  500000,  700000, 1000000,
-                 1500000, 1800000, 2000000]
+          enum: [ 300000, 500000, 700000, 1000000,
+                  1500000, 1800000, 2000000]
 
         summit,usb-current-limit-microamp:
-          enum: [ 300000,  500000,  700000, 1000000,
-                 1500000, 1800000, 2000000]
+          enum: [ 300000, 500000, 700000, 1000000,
+                  1500000, 1800000, 2000000]
 
         summit,charge-current-compensation-microamp:
           enum: [200000, 450000, 600000, 900000]
@@ -97,12 +97,12 @@ allOf:
     else:
       properties:
         summit,mains-current-limit-microamp:
-          enum: [ 300000,  500000,  700000,  900000, 1200000,
-                 1500000, 1800000, 2000000, 2200000, 2500000]
+          enum: [ 300000, 500000, 700000, 900000, 1200000,
+                  1500000, 1800000, 2000000, 2200000, 2500000]
 
         summit,usb-current-limit-microamp:
-          enum: [ 300000,  500000,  700000,  900000, 1200000,
-                 1500000, 1800000, 2000000, 2200000, 2500000]
+          enum: [ 300000, 500000, 700000, 900000, 1200000,
+                  1500000, 1800000, 2000000, 2200000, 2500000]
 
         summit,charge-current-compensation-microamp:
           enum: [250000, 700000, 900000, 1200000]
index ba175b30f468623f0949b8bd926fc29797c1de56..9245b7199439f0b582180bd7a2f8020c7c877750 100644 (file)
@@ -41,6 +41,8 @@ required:
   - enable-gpios
   - mps,fb-voltage-divider
 
+unevaluatedProperties: false
+
 examples:
   - |
     #include <dt-bindings/gpio/gpio.h>
index c6de49685db7f02f00fe3c17a6fde503b7f99e51..f578e72778a7c0fb1522b769b03adf7e3fa4a52a 100644 (file)
@@ -80,6 +80,8 @@ required:
   - compatible
   - reg
 
+additionalProperties: false
+
 examples:
   - |
     i2c {
index 3f4a1939554d50803ec89d8529953f4fc0c7c228..efc0198eeb74d8fdcdedd73ff511557bb4d1932b 100644 (file)
@@ -25,8 +25,8 @@ select:
   properties:
     compatible:
       items:
-       - enum:
-          - sifive,fu540-c000-ccache
+        - enum:
+            - sifive,fu540-c000-ccache
 
   required:
     - compatible
index 3ab532713dc12dfe0273f320b0ff9700e764890f..3a8647d1da4c75890f5bda47ff201a407aac0782 100644 (file)
@@ -22,4 +22,7 @@ properties:
           - sifive,hifive-unleashed-a00
       - const: sifive,fu540-c000
       - const: sifive,fu540
+
+additionalProperties: true
+
 ...
index 4ad1e456a8012e636ee07957a1ac73951f4846b4..07f6ff89bcc15eff5b6c2ef904f5207a0bacc4f7 100644 (file)
@@ -19,9 +19,9 @@ properties:
           - const: fsl,imx21-rnga
       - items:
           - enum:
-            - fsl,imx6sl-rngb
-            - fsl,imx6sll-rngb
-            - fsl,imx6ull-rngb
+              - fsl,imx6sl-rngb
+              - fsl,imx6sll-rngb
+              - fsl,imx6ull-rngb
           - const: fsl,imx25-rngb
       - const: fsl,imx35-rngc
 
index 9ff85bc6859c47ce4896cbf66ac43a1b74b6b4ba..9702c07a6b6c77e564db9849d3911e6e553e9ad6 100644 (file)
@@ -20,30 +20,30 @@ properties:
       - const: fsl,imx21-uart
       - items:
           - enum:
-            - fsl,imx25-uart
-            - fsl,imx27-uart
-            - fsl,imx31-uart
-            - fsl,imx35-uart
-            - fsl,imx50-uart
-            - fsl,imx51-uart
-            - fsl,imx53-uart
-            - fsl,imx6q-uart
+              - fsl,imx25-uart
+              - fsl,imx27-uart
+              - fsl,imx31-uart
+              - fsl,imx35-uart
+              - fsl,imx50-uart
+              - fsl,imx51-uart
+              - fsl,imx53-uart
+              - fsl,imx6q-uart
           - const: fsl,imx21-uart
       - items:
           - enum:
-            - fsl,imx6sl-uart
-            - fsl,imx6sll-uart
-            - fsl,imx6sx-uart
+              - fsl,imx6sl-uart
+              - fsl,imx6sll-uart
+              - fsl,imx6sx-uart
           - const: fsl,imx6q-uart
           - const: fsl,imx21-uart
       - items:
           - enum:
-            - fsl,imx6ul-uart
-            - fsl,imx7d-uart
-            - fsl,imx8mm-uart
-            - fsl,imx8mn-uart
-            - fsl,imx8mp-uart
-            - fsl,imx8mq-uart
+              - fsl,imx6ul-uart
+              - fsl,imx7d-uart
+              - fsl,imx8mm-uart
+              - fsl,imx8mn-uart
+              - fsl,imx8mp-uart
+              - fsl,imx8mq-uart
           - const: fsl,imx6q-uart
 
   reg:
index 3b9143af2c7cb2e42ce21437425b1ce4afc38c6a..acfb9db021dcd9b553f3b6715fa164b34ab5c03d 100644 (file)
@@ -11,9 +11,10 @@ maintainers:
 
 description: |
   Google's ChromeOS EC codec is a digital mic codec provided by the
-  Embedded Controller (EC) and is controlled via a host-command interface.
-  An EC codec node should only be found as a sub-node of the EC node (see
-  Documentation/devicetree/bindings/mfd/google,cros-ec.yaml).
+  Embedded Controller (EC) and is controlled via a host-command
+  interface.  An EC codec node should only be found inside the "codecs"
+  subnode of a cros-ec node.
+  (see Documentation/devicetree/bindings/mfd/google,cros-ec.yaml).
 
 properties:
   compatible:
@@ -54,14 +55,19 @@ examples:
         #size-cells = <0>;
         cros-ec@0 {
             compatible = "google,cros-ec-spi";
-            #address-cells = <2>;
-            #size-cells = <1>;
             reg = <0>;
-            cros_ec_codec: ec-codec@10500000 {
-                compatible = "google,cros-ec-codec";
-                #sound-dai-cells = <1>;
-                reg = <0x0 0x10500000 0x80000>;
-                memory-region = <&reserved_mem>;
+
+            codecs {
+                #address-cells = <2>;
+                #size-cells = <1>;
+
+                cros_ec_codec: ec-codec@10500000 {
+                    compatible = "google,cros-ec-codec";
+                    #sound-dai-cells = <1>;
+                    reg = <0x0 0x10500000 0x80000>;
+                    memory-region = <&reserved_mem>;
+                };
+
             };
         };
     };
index 7d8bd4e144345452a417539c598a5f4de7fa9be4..4a2129005c0f80aa2ef1cd27f2974925f8224faf 100644 (file)
@@ -10,8 +10,8 @@ maintainers:
   - Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
 
 description:
-        The Microchip Sony/Philips Digital Interface Receiver is a
-        serial port compliant with the IEC-60958 standard.
+  The Microchip Sony/Philips Digital Interface Receiver is a serial port 
+  compliant with the IEC-60958 standard.
 
 properties:
   "#sound-dai-cells":
index a03b0b871fc98605b1824ee1a25b2b36c5e066aa..bdfb63387c536bb4a129ec45edb30e9baaf14197 100644 (file)
@@ -10,8 +10,8 @@ maintainers:
   - Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
 
 description:
-        The Microchip Sony/Philips Digital Interface Transmitter is a
-        serial port compliant with the IEC-60958 standard.
+  The Microchip Sony/Philips Digital Interface Transmitter is a serial port 
+  compliant with the IEC-60958 standard.
 
 properties:
   "#sound-dai-cells":
index f6f9fb49f385606bf84ddf51cd9958258a8074c2..1e23c0e20bc17bfa168ffef5461bedcb64610852 100644 (file)
@@ -26,8 +26,10 @@ properties:
   reg:
     maxItems: 2
     description: LPAIF core registers
+
   reg-names:
-     maxItems: 2
+    maxItems: 2
+
   clocks:
     minItems: 3
     maxItems: 6
@@ -39,8 +41,10 @@ properties:
   interrupts:
     maxItems: 2
     description: LPAIF DMA buffer interrupt
+
   interrupt-names:
     maxItems: 2
+
   qcom,adsp:
     $ref: /schemas/types.yaml#/definitions/phandle
     description: Phandle for the audio DSP node
@@ -141,31 +145,31 @@ allOf:
       properties:
         clock-names:
           oneOf:
-           - items:   #for I2S
-              - const: pcnoc-sway-clk
-              - const: audio-core
-              - const: mclk0
-              - const: pcnoc-mport-clk
-              - const: mi2s-bit-clk0
-              - const: mi2s-bit-clk1
-           - items:   #for HDMI
-              - const: pcnoc-sway-clk
-              - const: audio-core
-              - const: pcnoc-mport-clk
+            - items:   #for I2S
+                - const: pcnoc-sway-clk
+                - const: audio-core
+                - const: mclk0
+                - const: pcnoc-mport-clk
+                - const: mi2s-bit-clk0
+                - const: mi2s-bit-clk1
+            - items:   #for HDMI
+                - const: pcnoc-sway-clk
+                - const: audio-core
+                - const: pcnoc-mport-clk
         reg-names:
           anyOf:
             - items:   #for I2S
-              - const: lpass-lpaif
+                - const: lpass-lpaif
             - items:   #for I2S and HDMI
-              - const: lpass-hdmiif
-              - const: lpass-lpaif
+                - const: lpass-hdmiif
+                - const: lpass-lpaif
         interrupt-names:
           anyOf:
             - items:   #for I2S
-              - const: lpass-irq-lpaif
+                - const: lpass-irq-lpaif
             - items:   #for I2S and HDMI
-              - const: lpass-irq-lpaif
-              - const: lpass-irq-hdmi
+                - const: lpass-irq-lpaif
+                - const: lpass-irq-hdmi
       required:
         - iommus
         - power-domains
index def1db298eacb46b01989124779aeba6c9d6cdd8..644b68edf3e1dae8843aa56ffa43b357c27a0e1c 100644 (file)
@@ -26,6 +26,8 @@ properties:
 required:
   - compatible
 
+additionalProperties: false
+
 examples:
   - |
     #include <dt-bindings/gpio/gpio.h>
index 6ebcbc15369181988c02e4bee352b43d3162863b..b66a07e21d1e5de756438bc5f690459aa00a00c1 100644 (file)
@@ -33,6 +33,9 @@ properties:
           - const: allwinner,sun4i-a10-system-control
       - const: allwinner,sun8i-a23-system-control
       - const: allwinner,sun8i-h3-system-control
+      - items:
+          - const: allwinner,sun8i-v3s-system-control
+          - const: allwinner,sun8i-h3-system-control
       - items:
           - const: allwinner,sun8i-r40-system-control
           - const: allwinner,sun4i-a10-system-control
index e35d3053250a557253c887efb47fdd4584f1f717..960e2bd66a97031bf040c2b154f731a62b89e325 100644 (file)
@@ -33,8 +33,8 @@ properties:
   compatible:
     items:
       - enum:
-        - arm,sp804
-        - hisilicon,sp804
+          - arm,sp804
+          - hisilicon,sp804
       - const: arm,primecell
 
   interrupts:
@@ -58,11 +58,11 @@ properties:
       clock is used for all clock inputs.
     oneOf:
       - items:
-        - description: clock for timer 1
-        - description: clock for timer 2
-        - description: bus clock
+          - description: clock for timer 1
+          - description: clock for timer 2
+          - description: bus clock
       - items:
-        - description: unified clock for both timers and the bus
+          - description: unified clock for both timers and the bus
 
   clock-names: true
     # The original binding did not specify any clock names, and there is no
index ac20b98e99101c8afaccb877f68053544a112f49..d6af2794d44481ce70e626c9b2d89d795810ec23 100644 (file)
@@ -44,8 +44,8 @@ properties:
     enum: [super-speed, high-speed, full-speed]
 
   phys:
-   minItems: 1
-   maxItems: 2
+    minItems: 1
+    maxItems: 2
 
   phy-names:
     minItems: 1
index 5fe9e6211ba2b9c65b9c764e081666530cb715cc..52ceb07294a35877e916499b39c8b125fa3d8992 100644 (file)
@@ -17,7 +17,7 @@ description: |-
 
 properties:
   compatible:
-   const: ti,hd3ss3220
+    const: ti,hd3ss3220
 
   reg:
     maxItems: 1
index 1aaf3e768c8113f6ecbfc84b8b5cdb1320e409a9..55adea827c3499ac6872c3e73feda2c3b83af5f5 100644 (file)
@@ -15,10 +15,10 @@ properties:
       - const: fsl,imx21-owire
       - items:
           - enum:
-            - fsl,imx27-owire
-            - fsl,imx50-owire
-            - fsl,imx51-owire
-            - fsl,imx53-owire
+              - fsl,imx27-owire
+              - fsl,imx50-owire
+              - fsl,imx51-owire
+              - fsl,imx53-owire
           - const: fsl,imx21-owire
 
   reg:
index bbb0c1c0e5cf980ac059728a4d8b07771289e733..a94f17d9b8365fddc44eb32df1fc50507e908577 100644 (file)
@@ -86,9 +86,6 @@ Other Functions
 .. kernel-doc:: fs/dax.c
    :export:
 
-.. kernel-doc:: fs/direct-io.c
-   :export:
-
 .. kernel-doc:: fs/libfs.c
    :export:
 
index 728ab57a611a468db44f95a1af01d45629ac944d..0f2292e367e62bdf638b9c812b7df38ce1bbb7ff 100644 (file)
@@ -199,7 +199,7 @@ of its elements. Note: Once array is created its size can not be changed.
 
 There is a helper function to create device related seq_file::
 
-   struct dentry *debugfs_create_devm_seqfile(struct device *dev,
+   void debugfs_create_devm_seqfile(struct device *dev,
                                const char *name,
                                struct dentry *parent,
                                int (*read_fn)(struct seq_file *s,
index 1f9ea8221f80c5307d6dfc7cb88cc0b6d30494b0..2062a6023678d04b86abb096ebb7c9bfd9b418ad 100644 (file)
@@ -83,10 +83,6 @@ AMDGPU XGMI Support
 ===================
 
 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
-   :doc: AMDGPU XGMI Support
-
-.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
-   :internal:
 
 AMDGPU RAS Support
 ==================
@@ -124,9 +120,6 @@ RAS VRAM Bad Pages sysfs Interface
 .. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
    :doc: AMDGPU RAS sysfs gpu_vram_bad_pages Interface
 
-.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
-   :internal:
-
 Sample Code
 -----------
 Sample code for testing error injection can be found here:
index 9257f8a48650d99caaef9b8ca4e8fcf185a1ad5d..2b877011cfdf0b511805bd8a4fe09c7b056cd15c 100644 (file)
@@ -20,7 +20,7 @@ ADM1266 is a sequencer that features voltage readback from 17 channels via an
 integrated 12 bit SAR ADC, accessed using a PMBus interface.
 
 The driver is a client driver to the core PMBus driver. Please see
-Documentation/hwmon/pmbus for details on PMBus client drivers.
+Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
 
 
 Sysfs entries
index e6b91ab1297850c86d5905ef77d6219c7de49d16..b797db73822524867b9cd2d55e3a8d1303cb33f1 100644 (file)
@@ -132,6 +132,7 @@ Hardware Monitoring Kernel Drivers
    mcp3021
    menf21bmc
    mlxreg-fan
+   mp2975
    nct6683
    nct6775
    nct7802
index 5b0609c62f4843e005b82ac5a75a6e41ab81957b..81d816b71490d7cb9608450553166985a22a5411 100644 (file)
@@ -20,6 +20,7 @@ This driver implements support for Monolithic Power Systems, Inc. (MPS)
 vendor dual-loop, digital, multi-phase controller MP2975.
 
 This device:
+
 - Supports up to two power rail.
 - Provides 8 pulse-width modulations (PWMs), and can be configured up
   to 8-phase operation for rail 1 and up to 4-phase operation for rail
@@ -32,10 +33,12 @@ This device:
   10-mV DAC, IMVP9 mode with 5-mV DAC.
 
 Device supports:
+
 - SVID interface.
 - AVSBus interface.
 
 Device complaint with:
+
 - PMBus rev 1.3 interface.
 
 Device supports direct format for reading output current, output voltage,
@@ -45,11 +48,14 @@ Device supports VID and direct formats for reading output voltage.
 The below VID modes are supported: VR12, VR13, IMVP9.
 
 The driver provides the next attributes for the current:
+
 - for current in: input, maximum alarm;
 - for current out input, maximum alarm and highest values;
 - for phase current: input and label.
-attributes.
+  attributes.
+
 The driver exports the following attributes via the 'sysfs' files, where
+
 - 'n' is number of telemetry pages (from 1 to 2);
 - 'k' is number of configured phases (from 1 to 8);
 - indexes 1, 1*n for "iin";
@@ -65,11 +71,14 @@ The driver exports the following attributes via the 'sysfs' files, where
 **curr[1-{2n+k}]_label**
 
 The driver provides the next attributes for the voltage:
+
 - for voltage in: input, high critical threshold, high critical alarm, all only
   from page 0;
 - for voltage out: input, low and high critical thresholds, low and high
   critical alarms, from pages 0 and 1;
+
 The driver exports the following attributes via the 'sysfs' files, where
+
 - 'n' is number of telemetry pages (from 1 to 2);
 - indexes 1 for "iin";
 - indexes n+1, n+2 for "vout";
@@ -87,9 +96,12 @@ The driver exports the following attributes via the 'sysfs' files, where
 **in[2-{n+1}1_lcrit_alarm**
 
 The driver provides the next attributes for the power:
+
 - for power in alarm and input.
 - for power out: highest and input.
+
 The driver exports the following attributes via the 'sysfs' files, where
+
 - 'n' is number of telemetry pages (from 1 to 2);
 - indexes 1 for "pin";
 - indexes n+1, n+2 for "pout";
index bc70c6aa713844766a878f62abf1052cb0ac8096..e5d63b9400459c2aa401028acab6b880d9a7a7c6 100644 (file)
@@ -17,6 +17,7 @@ LEDs
    uleds
 
    leds-blinkm
+   leds-el15203000
    leds-lm3556
    leds-lp3944
    leds-lp5521
@@ -24,3 +25,4 @@ LEDs
    leds-lp5562
    leds-lp55xx
    leds-mlxcpld
+   leds-sc27xx
diff --git a/Documentation/leds/leds-el15203000.rst b/Documentation/leds/leds-el15203000.rst
new file mode 100644 (file)
index 0000000..12c23d7
--- /dev/null
@@ -0,0 +1,140 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==================================
+Kernel driver for Crane EL15203000
+==================================
+
+/sys/class/leds/<led>/hw_pattern
+--------------------------------
+
+Specify a hardware pattern for the EL15203000 LED.
+
+The LEDs board supports only predefined patterns by firmware
+for specific LEDs.
+
+Breathing mode for Screen frame light tube::
+
+    "0 4000 1 4000"
+
+       ^
+       |
+    Max-|     ---
+       |    /   \
+       |   /     \
+       |  /       \     /
+       | /         \   /
+    Min-|-           ---
+       |
+       0------4------8--> time (sec)
+
+Cascade mode for Pipe LED::
+
+    "1 800 2 800 4 800 8 800 16 800"
+
+       ^
+       |
+  0 On -|----+                   +----+                   +---
+       |    |                   |    |                   |
+    Off-|    +-------------------+    +-------------------+
+       |
+  1 On -|    +----+                   +----+
+       |    |    |                   |    |
+    Off |----+    +-------------------+    +------------------
+       |
+  2 On -|         +----+                   +----+
+       |         |    |                   |    |
+    Off-|---------+    +-------------------+    +-------------
+       |
+  3 On -|              +----+                   +----+
+       |              |    |                   |    |
+    Off-|--------------+    +-------------------+    +--------
+       |
+  4 On -|                   +----+                   +----+
+       |                   |    |                   |    |
+    Off-|-------------------+    +-------------------+    +---
+       |
+       0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
+
+Inverted cascade mode for Pipe LED::
+
+    "30 800 29 800 27 800 23 800 15 800"
+
+       ^
+       |
+  0 On -|    +-------------------+    +-------------------+
+       |    |                   |    |                   |
+    Off-|----+                   +----+                   +---
+       |
+  1 On -|----+    +-------------------+    +------------------
+       |    |    |                   |    |
+    Off |    +----+                   +----+
+       |
+  2 On -|---------+    +-------------------+    +-------------
+       |         |    |                   |    |
+    Off-|         +----+                   +----+
+       |
+  3 On -|--------------+    +-------------------+    +--------
+       |              |    |                   |    |
+    Off-|              +----+                   +----+
+       |
+  4 On -|-------------------+    +-------------------+    +---
+       |                   |    |                   |    |
+    Off-|                   +----+                   +----+
+       |
+       0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
+
+Bounce mode for Pipe LED::
+
+    "1 800 2 800 4 800 8 800 16 800 16 800 8 800 4 800 2 800 1 800"
+
+       ^
+       |
+  0 On -|----+                                       +--------
+       |    |                                       |
+    Off-|    +---------------------------------------+
+       |
+  1 On -|    +----+                             +----+
+       |    |    |                             |    |
+    Off |----+    +-----------------------------+    +--------
+       |
+  2 On -|         +----+                   +----+
+       |         |    |                   |    |
+    Off-|---------+    +-------------------+    +-------------
+       |
+  3 On -|              +----+         +----+
+       |              |    |         |    |
+    Off-|--------------+    +---------+    +------------------
+       |
+  4 On -|                   +---------+
+       |                   |         |
+    Off-|-------------------+         +-----------------------
+       |
+       0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
+
+Inverted bounce mode for Pipe LED::
+
+    "30 800 29 800 27 800 23 800 15 800 15 800 23 800 27 800 29 800 30 800"
+
+       ^
+       |
+  0 On -|    +---------------------------------------+
+       |    |                                       |
+    Off-|----+                                       +--------
+       |
+  1 On -|----+    +-----------------------------+    +--------
+       |    |    |                             |    |
+    Off |    +----+                             +----+
+       |
+  2 On -|---------+    +-------------------+    +-------------
+       |         |    |                   |    |
+    Off-|         +----+                   +----+
+       |
+  3 On -|--------------+    +---------+    +------------------
+       |              |    |         |    |
+    Off-|              +----+         +----+
+       |
+  4 On -|-------------------+         +-----------------------
+       |                   |         |
+    Off-|                   +---------+
+       |
+       0---0.8--1.6--2.4--3.2---4---4.8--5.6--6.4--7.2---8--> time (sec)
diff --git a/Documentation/leds/leds-sc27xx.rst b/Documentation/leds/leds-sc27xx.rst
new file mode 100644 (file)
index 0000000..6bdf6ba
--- /dev/null
@@ -0,0 +1,27 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===================================
+Kernel driver for Spreadtrum SC27XX
+===================================
+
+/sys/class/leds/<led>/hw_pattern
+--------------------------------
+
+Specify a hardware pattern for the SC27XX LED. For the SC27XX
+LED controller, it only supports 4 stages to make a single
+hardware pattern, which is used to configure the rise time,
+high time, fall time and low time for the breathing mode.
+
+For the breathing mode, the SC27XX LED only expects one brightness
+for the high stage. To be compatible with the hardware pattern
+format, we should set brightness as 0 for rise stage, fall
+stage and low stage.
+
+- Min stage duration: 125 ms
+- Max stage duration: 31875 ms
+
+Since the stage duration step is 125 ms, the duration should be
+a multiplier of 125, like 125ms, 250ms, 375ms, 500ms ... 31875ms.
+
+Thus the format of the hardware pattern values should be:
+"0 rise_duration brightness high_duration 0 fall_duration 0 low_duration".
index cec03bd1294aabf6d07cd7e8fcc0d919d0847ece..9f3cfca9f8a4547349205d7d53859fdb4e314d77 100644 (file)
@@ -42,6 +42,7 @@ The validator tracks lock-class usage history and divides the usage into
 (4 usages * n STATEs + 1) categories:
 
 where the 4 usages can be:
+
 - 'ever held in STATE context'
 - 'ever held as readlock in STATE context'
 - 'ever held with STATE enabled'
@@ -49,10 +50,12 @@ where the 4 usages can be:
 
 where the n STATEs are coded in kernel/locking/lockdep_states.h and as of
 now they include:
+
 - hardirq
 - softirq
 
 where the last 1 category is:
+
 - 'ever used'                                       [ == !unused        ]
 
 When locking rules are violated, these usage bits are presented in the
@@ -96,9 +99,9 @@ exact case is for the lock as of the reporting time.
   +--------------+-------------+--------------+
   |              | irq enabled | irq disabled |
   +--------------+-------------+--------------+
-  | ever in irq  |      ?      |       -      |
+  | ever in irq  |     '?'     |      '-'     |
   +--------------+-------------+--------------+
-  | never in irq |      +      |       .      |
+  | never in irq |     '+'     |      '.'     |
   +--------------+-------------+--------------+
 
 The character '-' suggests irq is disabled because if otherwise the
@@ -216,7 +219,7 @@ looks like this::
        BD_MUTEX_PARTITION
   };
 
-mutex_lock_nested(&bdev->bd_contains->bd_mutex, BD_MUTEX_PARTITION);
+  mutex_lock_nested(&bdev->bd_contains->bd_mutex, BD_MUTEX_PARTITION);
 
 In this case the locking is done on a bdev object that is known to be a
 partition.
@@ -334,7 +337,7 @@ Troubleshooting:
 ----------------
 
 The validator tracks a maximum of MAX_LOCKDEP_KEYS number of lock classes.
-Exceeding this number will trigger the following lockdep warning:
+Exceeding this number will trigger the following lockdep warning::
 
        (DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS))
 
@@ -420,7 +423,8 @@ the critical section of another reader of the same lock instance.
 
 The difference between recursive readers and non-recursive readers is because:
 recursive readers get blocked only by a write lock *holder*, while non-recursive
-readers could get blocked by a write lock *waiter*. Considering the follow example:
+readers could get blocked by a write lock *waiter*. Considering the follow
+example::
 
        TASK A:                 TASK B:
 
@@ -448,20 +452,22 @@ There are simply four block conditions:
 
 Block condition matrix, Y means the row blocks the column, and N means otherwise.
 
-           | E | r | R |
        +---+---+---+---+
-         E | Y | Y | Y |
+       |   | E | r | R |
+       +---+---+---+---+
+       | E | Y | Y | Y |
+       +---+---+---+---+
+       | r | Y | Y | N |
        +---+---+---+---+
-         r | Y | Y | N |
+       | R | Y | Y | N |
        +---+---+---+---+
-         R | Y | Y | N |
 
        (W: writers, r: non-recursive readers, R: recursive readers)
 
 
 acquired recursively. Unlike non-recursive read locks, recursive read locks
 only get blocked by current write lock *holders* other than write lock
-*waiters*, for example:
+*waiters*, for example::
 
        TASK A:                 TASK B:
 
@@ -491,7 +497,7 @@ Recursive locks don't block each other, while non-recursive locks do (this is
 even true for two non-recursive read locks). A non-recursive lock can block the
 corresponding recursive lock, and vice versa.
 
-A deadlock case with recursive locks involved is as follow:
+A deadlock case with recursive locks involved is as follow::
 
        TASK A:                 TASK B:
 
@@ -510,7 +516,7 @@ because there are 3 types for lockers, there are, in theory, 9 types of lock
 dependencies, but we can show that 4 types of lock dependencies are enough for
 deadlock detection.
 
-For each lock dependency:
+For each lock dependency::
 
        L1 -> L2
 
@@ -525,20 +531,25 @@ same types).
 With the above combination for simplification, there are 4 types of dependency edges
 in the lockdep graph:
 
-1) -(ER)->: exclusive writer to recursive reader dependency, "X -(ER)-> Y" means
+1) -(ER)->:
+           exclusive writer to recursive reader dependency, "X -(ER)-> Y" means
            X -> Y and X is a writer and Y is a recursive reader.
 
-2) -(EN)->: exclusive writer to non-recursive locker dependency, "X -(EN)-> Y" means
+2) -(EN)->:
+           exclusive writer to non-recursive locker dependency, "X -(EN)-> Y" means
            X -> Y and X is a writer and Y is either a writer or non-recursive reader.
 
-3) -(SR)->: shared reader to recursive reader dependency, "X -(SR)-> Y" means
+3) -(SR)->:
+           shared reader to recursive reader dependency, "X -(SR)-> Y" means
            X -> Y and X is a reader (recursive or not) and Y is a recursive reader.
 
-4) -(SN)->: shared reader to non-recursive locker dependency, "X -(SN)-> Y" means
+4) -(SN)->:
+           shared reader to non-recursive locker dependency, "X -(SN)-> Y" means
            X -> Y and X is a reader (recursive or not) and Y is either a writer or
            non-recursive reader.
 
-Note that given two locks, they may have multiple dependencies between them, for example:
+Note that given two locks, they may have multiple dependencies between them,
+for example::
 
        TASK A:
 
@@ -592,11 +603,11 @@ circles that won't cause deadlocks.
 
 Proof for sufficiency (Lemma 1):
 
-Let's say we have a strong circle:
+Let's say we have a strong circle::
 
        L1 -> L2 ... -> Ln -> L1
 
-, which means we have dependencies:
+, which means we have dependencies::
 
        L1 -> L2
        L2 -> L3
@@ -633,7 +644,7 @@ a lock held by P2, and P2 is waiting for a lock held by P3, ... and Pn is waitin
 for a lock held by P1. Let's name the lock Px is waiting as Lx, so since P1 is waiting
 for L1 and holding Ln, so we will have Ln -> L1 in the dependency graph. Similarly,
 we have L1 -> L2, L2 -> L3, ..., Ln-1 -> Ln in the dependency graph, which means we
-have a circle:
+have a circle::
 
        Ln -> L1 -> L2 -> ... -> Ln
 
index 46072ce3d7efb97ca58df861c7527e5789c9eb3a..64420b3314feb4bb1399edbbeb541f0a09030b0e 100644 (file)
@@ -24,7 +24,6 @@ fit into other categories.
    isl29003
    lis3lv02d
    max6875
-   mic/index
    pci-endpoint-test
    spear-pcie-gadget
    uacce
diff --git a/Documentation/misc-devices/mic/index.rst b/Documentation/misc-devices/mic/index.rst
deleted file mode 100644 (file)
index 3a8d063..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-=============================================
-Intel Many Integrated Core (MIC) architecture
-=============================================
-
-.. toctree::
-    :maxdepth: 1
-
-    mic_overview
-    scif_overview
-
-.. only::  subproject and html
-
-   Indices
-   =======
-
-   * :ref:`genindex`
diff --git a/Documentation/misc-devices/mic/mic_overview.rst b/Documentation/misc-devices/mic/mic_overview.rst
deleted file mode 100644 (file)
index 17d956b..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-======================================================
-Intel Many Integrated Core (MIC) architecture overview
-======================================================
-
-An Intel MIC X100 device is a PCIe form factor add-in coprocessor
-card based on the Intel Many Integrated Core (MIC) architecture
-that runs a Linux OS. It is a PCIe endpoint in a platform and therefore
-implements the three required standard address spaces i.e. configuration,
-memory and I/O. The host OS loads a device driver as is typical for
-PCIe devices. The card itself runs a bootstrap after reset that
-transfers control to the card OS downloaded from the host driver. The
-host driver supports OSPM suspend and resume operations. It shuts down
-the card during suspend and reboots the card OS during resume.
-The card OS as shipped by Intel is a Linux kernel with modifications
-for the X100 devices.
-
-Since it is a PCIe card, it does not have the ability to host hardware
-devices for networking, storage and console. We provide these devices
-on X100 coprocessors thus enabling a self-bootable equivalent
-environment for applications. A key benefit of our solution is that it
-leverages the standard virtio framework for network, disk and console
-devices, though in our case the virtio framework is used across a PCIe
-bus. A Virtio Over PCIe (VOP) driver allows creating user space
-backends or devices on the host which are used to probe virtio drivers
-for these devices on the MIC card. The existing VRINGH infrastructure
-in the kernel is used to access virtio rings from the host. The card
-VOP driver allows card virtio drivers to communicate with their user
-space backends on the host via a device page. Ring 3 apps on the host
-can add, remove and configure virtio devices. A thin MIC specific
-virtio_config_ops is implemented which is borrowed heavily from
-previous similar implementations in lguest and s390.
-
-MIC PCIe card has a dma controller with 8 channels. These channels are
-shared between the host s/w and the card s/w. 0 to 3 are used by host
-and 4 to 7 by card. As the dma device doesn't show up as PCIe device,
-a virtual bus called mic bus is created and virtual dma devices are
-created on it by the host/card drivers. On host the channels are private
-and used only by the host driver to transfer data for the virtio devices.
-
-The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a
-low level communications API across PCIe currently implemented for MIC.
-More details are available at scif_overview.txt.
-
-The Coprocessor State Management (COSM) driver on the host allows for
-boot, shutdown and reset of Intel MIC devices. It communicates with a COSM
-"client" driver on the MIC cards over SCIF to perform these functions.
-
-Here is a block diagram of the various components described above. The
-virtio backends are situated on the host rather than the card given better
-single threaded performance for the host compared to MIC, the ability of
-the host to initiate DMA's to/from the card using the MIC DMA engine and
-the fact that the virtio block storage backend can only be on the host::
-
-               +----------+           |             +----------+
-               | Card OS  |           |             | Host OS  |
-               +----------+           |             +----------+
-                                      |
-        +-------+ +--------+ +------+ | +---------+  +--------+ +--------+
-        | Virtio| |Virtio  | |Virtio| | |Virtio   |  |Virtio  | |Virtio  |
-        | Net   | |Console | |Block | | |Net      |  |Console | |Block   |
-        | Driver| |Driver  | |Driver| | |backend  |  |backend | |backend |
-        +---+---+ +---+----+ +--+---+ | +---------+  +----+---+ +--------+
-            |         |         |     |      |            |         |
-            |         |         |     |User  |            |         |
-            |         |         |     |------|------------|--+------|-------
-            +---------+---------+     |Kernel                |
-                      |               |                      |
-  +---------+     +---+----+ +------+ | +------+ +------+ +--+---+  +-------+
-  |MIC DMA  |     |  VOP   | | SCIF | | | SCIF | | COSM | | VOP  |  |MIC DMA|
-  +---+-----+     +---+----+ +--+---+ | +--+---+ +--+---+ +------+  +----+--+
-      |               |         |     |    |        |                    |
-  +---+-----+     +---+----+ +--+---+ | +--+---+ +--+---+ +------+  +----+--+
-  |MIC      |     |  VOP   | |SCIF  | | |SCIF  | | COSM | | VOP  |  | MIC   |
-  |HW Bus   |     |  HW Bus| |HW Bus| | |HW Bus| | Bus  | |HW Bus|  |HW Bus |
-  +---------+     +--------+ +--+---+ | +--+---+ +------+ +------+  +-------+
-      |               |         |     |       |     |                    |
-      |   +-----------+--+      |     |       |    +---------------+     |
-      |   |Intel MIC     |      |     |       |    |Intel MIC      |     |
-      |   |Card Driver   |      |     |       |    |Host Driver    |     |
-      +---+--------------+------+     |       +----+---------------+-----+
-                 |                    |                   |
-             +-------------------------------------------------------------+
-             |                                                             |
-             |                    PCIe Bus                                 |
-             +-------------------------------------------------------------+
diff --git a/Documentation/misc-devices/mic/scif_overview.rst b/Documentation/misc-devices/mic/scif_overview.rst
deleted file mode 100644 (file)
index 4c8ad9e..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-========================================
-Symmetric Communication Interface (SCIF)
-========================================
-
-The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a low
-level communications API across PCIe currently implemented for MIC. Currently
-SCIF provides inter-node communication within a single host platform, where a
-node is a MIC Coprocessor or Xeon based host. SCIF abstracts the details of
-communicating over the PCIe bus while providing an API that is symmetric
-across all the nodes in the PCIe network. An important design objective for SCIF
-is to deliver the maximum possible performance given the communication
-abilities of the hardware. SCIF has been used to implement an offload compiler
-runtime and OFED support for MPI implementations for MIC coprocessors.
-
-SCIF API Components
-===================
-
-The SCIF API has the following parts:
-
-1. Connection establishment using a client server model
-2. Byte stream messaging intended for short messages
-3. Node enumeration to determine online nodes
-4. Poll semantics for detection of incoming connections and messages
-5. Memory registration to pin down pages
-6. Remote memory mapping for low latency CPU accesses via mmap
-7. Remote DMA (RDMA) for high bandwidth DMA transfers
-8. Fence APIs for RDMA synchronization
-
-SCIF exposes the notion of a connection which can be used by peer processes on
-nodes in a SCIF PCIe "network" to share memory "windows" and to communicate. A
-process in a SCIF node initiates a SCIF connection to a peer process on a
-different node via a SCIF "endpoint". SCIF endpoints support messaging APIs
-which are similar to connection oriented socket APIs. Connected SCIF endpoints
-can also register local memory which is followed by data transfer using either
-DMA, CPU copies or remote memory mapping via mmap. SCIF supports both user and
-kernel mode clients which are functionally equivalent.
-
-SCIF Performance for MIC
-========================
-
-DMA bandwidth comparison between the TCP (over ethernet over PCIe) stack versus
-SCIF shows the performance advantages of SCIF for HPC applications and
-runtimes::
-
-             Comparison of TCP and SCIF based BW
-
-  Throughput (GB/sec)
-    8 +                                             PCIe Bandwidth ******
-      +                                                        TCP ######
-    7 +    **************************************             SCIF %%%%%%
-      |                       %%%%%%%%%%%%%%%%%%%
-    6 +                   %%%%
-      |                 %%
-      |               %%%
-    5 +              %%
-      |            %%
-    4 +           %%
-      |          %%
-    3 +         %%
-      |        %
-    2 +      %%
-      |     %%
-      |    %
-    1 +
-      +    ######################################
-    0 +++---+++--+--+-+--+--+-++-+--+-++-+--+-++-+-
-      1       10     100      1000   10000   100000
-                   Transfer Size (KBytes)
-
-SCIF allows memory sharing via mmap(..) between processes on different PCIe
-nodes and thus provides bare-metal PCIe latency. The round trip SCIF mmap
-latency from the host to an x100 MIC for an 8 byte message is 0.44 usecs.
-
-SCIF has a user space library which is a thin IOCTL wrapper providing a user
-space API similar to the kernel API in scif.h. The SCIF user space library
-is distributed @ https://software.intel.com/en-us/mic-developer
-
-Here is some pseudo code for an example of how two applications on two PCIe
-nodes would typically use the SCIF API::
-
-  Process A (on node A)                        Process B (on node B)
-
-  /* get online node information */
-  scif_get_node_ids(..)                        scif_get_node_ids(..)
-  scif_open(..)                                scif_open(..)
-  scif_bind(..)                                scif_bind(..)
-  scif_listen(..)
-  scif_accept(..)                              scif_connect(..)
-  /* SCIF connection established */
-
-  /* Send and receive short messages */
-  scif_send(..)/scif_recv(..)          scif_send(..)/scif_recv(..)
-
-  /* Register memory */
-  scif_register(..)                    scif_register(..)
-
-  /* RDMA */
-  scif_readfrom(..)/scif_writeto(..)   scif_readfrom(..)/scif_writeto(..)
-
-  /* Fence DMAs */
-  scif_fence_signal(..)                        scif_fence_signal(..)
-
-  mmap(..)                             mmap(..)
-
-  /* Access remote registered memory */
-
-  /* Close the endpoints */
-  scif_close(..)                               scif_close(..)
index b165181d5d4daa68cb7cfc3dcecf75d4511c1653..a432dc419fa4031d2b7c82961d6708dd552f688c 100644 (file)
@@ -70,6 +70,7 @@ The ``ice`` driver reports the following versions
         that both the name (as reported by ``fw.app.name``) and version are
         required to uniquely identify the package.
     * - ``fw.app.bundle_id``
+      - running
       - 0xc0000001
       - Unique identifier for the DDP package loaded in the device. Also
         referred to as the DDP Track ID. Can be used to uniquely identify
index f5be243d250a40e75d8bdef11b2489b56d7af691..0a4b73b03b997105bec7f1fa0bb1857c165a928d 100644 (file)
@@ -10,9 +10,9 @@ Overview / What Is J1939
 SAE J1939 defines a higher layer protocol on CAN. It implements a more
 sophisticated addressing scheme and extends the maximum packet size above 8
 bytes. Several derived specifications exist, which differ from the original
-J1939 on the application level, like MilCAN A, NMEA2000 and especially
+J1939 on the application level, like MilCAN A, NMEA2000, and especially
 ISO-11783 (ISOBUS). This last one specifies the so-called ETP (Extended
-Transport Protocol) which is has been included in this implementation. This
+Transport Protocol), which has been included in this implementation. This
 results in a maximum packet size of ((2 ^ 24) - 1) * 7 bytes == 111 MiB.
 
 Specifications used
@@ -32,15 +32,15 @@ sockets, we found some reasons to justify a kernel implementation for the
 addressing and transport methods used by J1939.
 
 * **Addressing:** when a process on an ECU communicates via J1939, it should
-  not necessarily know its source address. Although at least one process per
+  not necessarily know its source address. Although, at least one process per
   ECU should know the source address. Other processes should be able to reuse
   that address. This way, address parameters for different processes
   cooperating for the same ECU, are not duplicated. This way of working is
-  closely related to the UNIX concept where programs do just one thing, and do
+  closely related to the UNIX concept, where programs do just one thing and do
   it well.
 
 * **Dynamic addressing:** Address Claiming in J1939 is time critical.
-  Furthermore data transport should be handled properly during the address
+  Furthermore, data transport should be handled properly during the address
   negotiation. Putting this functionality in the kernel eliminates it as a
   requirement for _every_ user space process that communicates via J1939. This
   results in a consistent J1939 bus with proper addressing.
@@ -58,7 +58,7 @@ Therefore, these parts are left to user space.
 
 The J1939 sockets operate on CAN network devices (see SocketCAN). Any J1939
 user space library operating on CAN raw sockets will still operate properly.
-Since such library does not communicate with the in-kernel implementation, care
+Since such library does not communicate with the in-kernel implementation, care
 must be taken that these two do not interfere. In practice, this means they
 cannot share ECU addresses. A single ECU (or virtual ECU) address is used by
 the library exclusively, or by the in-kernel system exclusively.
@@ -77,13 +77,13 @@ is composed as follows:
 8 bits : PS (PDU Specific)
 
 In J1939-21 distinction is made between PDU1 format (where PF < 240) and PDU2
-format (where PF >= 240). Furthermore, when using PDU2 format, the PS-field
+format (where PF >= 240). Furthermore, when using the PDU2 format, the PS-field
 contains a so-called Group Extension, which is part of the PGN. When using PDU2
 format, the Group Extension is set in the PS-field.
 
 On the other hand, when using PDU1 format, the PS-field contains a so-called
 Destination Address, which is _not_ part of the PGN. When communicating a PGN
-from user space to kernel (or visa versa) and PDU2 format is used, the PS-field
+from user space to kernel (or vice versa) and PDU2 format is used, the PS-field
 of the PGN shall be set to zero. The Destination Address shall be set
 elsewhere.
 
@@ -96,15 +96,15 @@ Addressing
 
 Both static and dynamic addressing methods can be used.
 
-For static addresses, no extra checks are made by the kernel, and provided
+For static addresses, no extra checks are made by the kernel and provided
 addresses are considered right. This responsibility is for the OEM or system
 integrator.
 
 For dynamic addressing, so-called Address Claiming, extra support is foreseen
-in the kernel. In J1939 any ECU is known by it's 64-bit NAME. At the moment of
+in the kernel. In J1939 any ECU is known by its 64-bit NAME. At the moment of
 a successful address claim, the kernel keeps track of both NAME and source
 address being claimed. This serves as a base for filter schemes. By default,
-packets with a destination that is not locally, will be rejected.
+packets with a destination that is not locally will be rejected.
 
 Mixed mode packets (from a static to a dynamic address or vice versa) are
 allowed. The BSD sockets define separate API calls for getting/setting the
@@ -131,31 +131,31 @@ API Calls
 ---------
 
 On CAN, you first need to open a socket for communicating over a CAN network.
-To use J1939, #include <linux/can/j1939.h>. From there, <linux/can.h> will be
+To use J1939, ``#include <linux/can/j1939.h>``. From there, ``<linux/can.h>`` will be
 included too. To open a socket, use:
 
 .. code-block:: C
 
     s = socket(PF_CAN, SOCK_DGRAM, CAN_J1939);
 
-J1939 does use SOCK_DGRAM sockets. In the J1939 specification, connections are
+J1939 does use ``SOCK_DGRAM`` sockets. In the J1939 specification, connections are
 mentioned in the context of transport protocol sessions. These still deliver
-packets to the other end (using several CAN packets). SOCK_STREAM is not
+packets to the other end (using several CAN packets). ``SOCK_STREAM`` is not
 supported.
 
-After the successful creation of the socket, you would normally use the bind(2)
-and/or connect(2) system call to bind the socket to a CAN interface.  After
-binding and/or connecting the socket, you can read(2) and write(2) from/to the
-socket or use send(2), sendto(2), sendmsg(2) and the recv*() counterpart
+After the successful creation of the socket, you would normally use the ``bind(2)``
+and/or ``connect(2)`` system call to bind the socket to a CAN interface. After
+binding and/or connecting the socket, you can ``read(2)`` and ``write(2)`` from/to the
+socket or use ``send(2)``, ``sendto(2)``, ``sendmsg(2)`` and the ``recv*()`` counterpart
 operations on the socket as usual. There are also J1939 specific socket options
 described below.
 
-In order to send data, a bind(2) must have been successful. bind(2) assigns a
+In order to send data, a ``bind(2)`` must have been successful. ``bind(2)`` assigns a
 local address to a socket.
 
-Different from CAN is that the payload data is just the data that get send,
-without it's header info. The header info is derived from the sockaddr supplied
-to bind(2), connect(2), sendto(2) and recvfrom(2). A write(2) with size 4 will
+Different from CAN is that the payload data is just the data that get sends,
+without its header info. The header info is derived from the sockaddr supplied
+to ``bind(2)``, ``connect(2)``, ``sendto(2)`` and ``recvfrom(2)``. A ``write(2)`` with size 4 will
 result in a packet with 4 bytes.
 
 The sockaddr structure has extensions for use with J1939 as specified below:
@@ -180,47 +180,47 @@ The sockaddr structure has extensions for use with J1939 as specified below:
          } can_addr;
       }
 
-can_family & can_ifindex serve the same purpose as for other SocketCAN sockets.
+``can_family`` & ``can_ifindex`` serve the same purpose as for other SocketCAN sockets.
 
-can_addr.j1939.pgn specifies the PGN (max 0x3ffff). Individual bits are
+``can_addr.j1939.pgn`` specifies the PGN (max 0x3ffff). Individual bits are
 specified above.
 
-can_addr.j1939.name contains the 64-bit J1939 NAME.
+``can_addr.j1939.name`` contains the 64-bit J1939 NAME.
 
-can_addr.j1939.addr contains the address.
+``can_addr.j1939.addr`` contains the address.
 
-The bind(2) system call assigns the local address, i.e. the source address when
-sending packages. If a PGN during bind(2) is set, it's used as a RX filter.
-I.e.  only packets with a matching PGN are received. If an ADDR or NAME is set
+The ``bind(2)`` system call assigns the local address, i.e. the source address when
+sending packages. If a PGN during ``bind(2)`` is set, it's used as a RX filter.
+I.e. only packets with a matching PGN are received. If an ADDR or NAME is set
 it is used as a receive filter, too. It will match the destination NAME or ADDR
 of the incoming packet. The NAME filter will work only if appropriate Address
 Claiming for this name was done on the CAN bus and registered/cached by the
 kernel.
 
-On the other hand connect(2) assigns the remote address, i.e. the destination
-address. The PGN from connect(2) is used as the default PGN when sending
+On the other hand ``connect(2)`` assigns the remote address, i.e. the destination
+address. The PGN from ``connect(2)`` is used as the default PGN when sending
 packets. If ADDR or NAME is set it will be used as the default destination ADDR
-or NAME. Further a set ADDR or NAME during connect(2) is used as a receive
+or NAME. Further a set ADDR or NAME during ``connect(2)`` is used as a receive
 filter. It will match the source NAME or ADDR of the incoming packet.
 
-Both write(2) and send(2) will send a packet with local address from bind(2) and
-the remote address from connect(2). Use sendto(2) to overwrite the destination
+Both ``write(2)`` and ``send(2)`` will send a packet with local address from ``bind(2)`` and the
+remote address from ``connect(2)``. Use ``sendto(2)`` to overwrite the destination
 address.
 
-If can_addr.j1939.name is set (!= 0) the NAME is looked up by the kernel and
-the corresponding ADDR is used. If can_addr.j1939.name is not set (== 0),
-can_addr.j1939.addr is used.
+If ``can_addr.j1939.name`` is set (!= 0) the NAME is looked up by the kernel and
+the corresponding ADDR is used. If ``can_addr.j1939.name`` is not set (== 0),
+``can_addr.j1939.addr`` is used.
 
 When creating a socket, reasonable defaults are set. Some options can be
-modified with setsockopt(2) & getsockopt(2).
+modified with ``setsockopt(2)`` & ``getsockopt(2)``.
 
 RX path related options:
 
-- SO_J1939_FILTER - configure array of filters
-- SO_J1939_PROMISC - disable filters set by bind(2) and connect(2)
+- ``SO_J1939_FILTER`` - configure array of filters
+- ``SO_J1939_PROMISC`` - disable filters set by ``bind(2)`` and ``connect(2)``
 
 By default no broadcast packets can be send or received. To enable sending or
-receiving broadcast packets use the socket option SO_BROADCAST:
+receiving broadcast packets use the socket option ``SO_BROADCAST``:
 
 .. code-block:: C
 
@@ -261,26 +261,26 @@ The following diagram illustrates the RX path:
      +---------------------------+
 
 TX path related options:
-SO_J1939_SEND_PRIO - change default send priority for the socket
+``SO_J1939_SEND_PRIO`` - change default send priority for the socket
 
 Message Flags during send() and Related System Calls
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-send(2), sendto(2) and sendmsg(2) take a 'flags' argument. Currently
+``send(2)``, ``sendto(2)`` and ``sendmsg(2)`` take a 'flags' argument. Currently
 supported flags are:
 
-* MSG_DONTWAIT, i.e. non-blocking operation.
+* ``MSG_DONTWAIT``, i.e. non-blocking operation.
 
 recvmsg(2)
 ^^^^^^^^^^
 
-In most cases recvmsg(2) is needed if you want to extract more information than
-recvfrom(2) can provide. For example package priority and timestamp. The
+In most cases ``recvmsg(2)`` is needed if you want to extract more information than
+``recvfrom(2)`` can provide. For example package priority and timestamp. The
 Destination Address, name and packet priority (if applicable) are attached to
-the msghdr in the recvmsg(2) call. They can be extracted using cmsg(3) macros,
-with cmsg_level == SOL_J1939 && cmsg_type == SCM_J1939_DEST_ADDR,
-SCM_J1939_DEST_NAME or SCM_J1939_PRIO. The returned data is a uint8_t for
-priority and dst_addr, and uint64_t for dst_name.
+the msghdr in the ``recvmsg(2)`` call. They can be extracted using ``cmsg(3)`` macros,
+with ``cmsg_level == SOL_J1939 && cmsg_type == SCM_J1939_DEST_ADDR``,
+``SCM_J1939_DEST_NAME`` or ``SCM_J1939_PRIO``. The returned data is a ``uint8_t`` for
+``priority`` and ``dst_addr``, and ``uint64_t`` for ``dst_name``.
 
 .. code-block:: C
 
@@ -305,12 +305,12 @@ Dynamic Addressing
 
 Distinction has to be made between using the claimed address and doing an
 address claim. To use an already claimed address, one has to fill in the
-j1939.name member and provide it to bind(2). If the name had claimed an address
+``j1939.name`` member and provide it to ``bind(2)``. If the name had claimed an address
 earlier, all further messages being sent will use that address. And the
-j1939.addr member will be ignored.
+``j1939.addr`` member will be ignored.
 
 An exception on this is PGN 0x0ee00. This is the "Address Claim/Cannot Claim
-Address" message and the kernel will use the j1939.addr member for that PGN if
+Address" message and the kernel will use the ``j1939.addr`` member for that PGN if
 necessary.
 
 To claim an address following code example can be used:
@@ -371,12 +371,12 @@ NAME can send packets.
 
 If another ECU claims the address, the kernel will mark the NAME-SA expired.
 No socket bound to the NAME can send packets (other than address claims). To
-claim another address, some socket bound to NAME, must bind(2) again, but with
-only j1939.addr changed to the new SA, and must then send a valid address claim
+claim another address, some socket bound to NAME, must ``bind(2)`` again, but with
+only ``j1939.addr`` changed to the new SA, and must then send a valid address claim
 packet. This restarts the state machine in the kernel (and any other
 participant on the bus) for this NAME.
 
-can-utils also include the jacd tool, so it can be used as code example or as
+``can-utils`` also include the ``j1939acd`` tool, so it can be used as code example or as
 default Address Claiming daemon.
 
 Send Examples
@@ -403,8 +403,8 @@ Bind:
 
        bind(sock, (struct sockaddr *)&baddr, sizeof(baddr));
 
-Now, the socket 'sock' is bound to the SA 0x20. Since no connect(2) was called,
-at this point we can use only sendto(2) or sendmsg(2).
+Now, the socket 'sock' is bound to the SA 0x20. Since no ``connect(2)`` was called,
+at this point we can use only ``sendto(2)`` or ``sendmsg(2)``.
 
 Send:
 
@@ -414,8 +414,8 @@ Send:
                .can_family = AF_CAN,
                .can_addr.j1939 = {
                        .name = J1939_NO_NAME;
-                       .pgn = 0x30,
-                       .addr = 0x12300,
+                       .addr = 0x30,
+                       .pgn = 0x12300,
                },
        };
 
index 8e15bc98830b70bd5e51fd73e1f145c8e6dc9c36..234abedc29b2b525855c0db8f87d83268813ff9d 100644 (file)
@@ -175,5 +175,4 @@ The following structures are internal to the kernel, their members are
 translated to netlink attributes when dumped. Drivers must not overwrite
 the statistics they don't report with 0.
 
-.. kernel-doc:: include/linux/ethtool.h
-    :identifiers: ethtool_pause_stats
+- ethtool_pause_stats()
index 409dbc4100def91ee496d32f3a66efef1fe8993d..3e81ebab26ed3c4b18dbaae4e13481f724780268 100644 (file)
@@ -15,6 +15,14 @@ else:
 import re
 from itertools import chain
 
+#
+# Python 2 lacks re.ASCII...
+#
+try:
+    ascii_p3 = re.ASCII
+except AttributeError:
+    ascii_p3 = 0
+
 #
 # Regex nastiness.  Of course.
 # Try to identify "function()" that's not already marked up some
@@ -22,22 +30,22 @@ from itertools import chain
 # :c:func: block (i.e. ":c:func:`mmap()`s" flakes out), so the last
 # bit tries to restrict matches to things that won't create trouble.
 #
-RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=re.ASCII)
+RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=ascii_p3)
 
 #
 # Sphinx 2 uses the same :c:type role for struct, union, enum and typedef
 #
 RE_generic_type = re.compile(r'\b(struct|union|enum|typedef)\s+([a-zA-Z_]\w+)',
-                             flags=re.ASCII)
+                             flags=ascii_p3)
 
 #
 # Sphinx 3 uses a different C role for each one of struct, union, enum and
 # typedef
 #
-RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
-RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
-RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
-RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
+RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
+RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
+RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
 
 #
 # Detects a reference to a documentation page of the form Documentation/... with
diff --git a/Documentation/sphinx/kernel_abi.py b/Documentation/sphinx/kernel_abi.py
new file mode 100644 (file)
index 0000000..f3da859
--- /dev/null
@@ -0,0 +1,194 @@
+# -*- coding: utf-8; mode: python -*-
+# coding=utf-8
+# SPDX-License-Identifier: GPL-2.0
+#
+u"""
+    kernel-abi
+    ~~~~~~~~~~
+
+    Implementation of the ``kernel-abi`` reST-directive.
+
+    :copyright:  Copyright (C) 2016  Markus Heiser
+    :copyright:  Copyright (C) 2016-2020  Mauro Carvalho Chehab
+    :maintained-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+    :license:    GPL Version 2, June 1991 see Linux/COPYING for details.
+
+    The ``kernel-abi`` (:py:class:`KernelCmd`) directive calls the
+    scripts/get_abi.pl script to parse the Kernel ABI files.
+
+    Overview of directive's argument and options.
+
+    .. code-block:: rst
+
+        .. kernel-abi:: <ABI directory location>
+            :debug:
+
+    The argument ``<ABI directory location>`` is required. It contains the
+    location of the ABI files to be parsed.
+
+    ``debug``
+      Inserts a code-block with the *raw* reST. Sometimes it is helpful to see
+      what reST is generated.
+
+"""
+
+import codecs
+import os
+import subprocess
+import sys
+import re
+import kernellog
+
+from os import path
+
+from docutils import nodes, statemachine
+from docutils.statemachine import ViewList
+from docutils.parsers.rst import directives, Directive
+from docutils.utils.error_reporting import ErrorString
+
+#
+# AutodocReporter is only good up to Sphinx 1.7
+#
+import sphinx
+
+Use_SSI = sphinx.__version__[:3] >= '1.7'
+if Use_SSI:
+    from sphinx.util.docutils import switch_source_input
+else:
+    from sphinx.ext.autodoc import AutodocReporter
+
+__version__  = '1.0'
+
+def setup(app):
+
+    app.add_directive("kernel-abi", KernelCmd)
+    return dict(
+        version = __version__
+        , parallel_read_safe = True
+        , parallel_write_safe = True
+    )
+
+class KernelCmd(Directive):
+
+    u"""KernelABI (``kernel-abi``) directive"""
+
+    required_arguments = 1
+    optional_arguments = 2
+    has_content = False
+    final_argument_whitespace = True
+
+    option_spec = {
+        "debug"     : directives.flag,
+        "rst"       : directives.unchanged
+    }
+
+    def run(self):
+
+        doc = self.state.document
+        if not doc.settings.file_insertion_enabled:
+            raise self.warning("docutils: file insertion disabled")
+
+        env = doc.settings.env
+        cwd = path.dirname(doc.current_source)
+        cmd = "get_abi.pl rest --enable-lineno --dir "
+        cmd += self.arguments[0]
+
+        if 'rst' in self.options:
+            cmd += " --rst-source"
+
+        srctree = path.abspath(os.environ["srctree"])
+
+        fname = cmd
+
+        # extend PATH with $(srctree)/scripts
+        path_env = os.pathsep.join([
+            srctree + os.sep + "scripts",
+            os.environ["PATH"]
+        ])
+        shell_env = os.environ.copy()
+        shell_env["PATH"]    = path_env
+        shell_env["srctree"] = srctree
+
+        lines = self.runCmd(cmd, shell=True, cwd=cwd, env=shell_env)
+        nodeList = self.nestedParse(lines, self.arguments[0])
+        return nodeList
+
+    def runCmd(self, cmd, **kwargs):
+        u"""Run command ``cmd`` and return it's stdout as unicode."""
+
+        try:
+            proc = subprocess.Popen(
+                cmd
+                , stdout = subprocess.PIPE
+                , stderr = subprocess.PIPE
+                , **kwargs
+            )
+            out, err = proc.communicate()
+
+            out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8')
+
+            if proc.returncode != 0:
+                raise self.severe(
+                    u"command '%s' failed with return code %d"
+                    % (cmd, proc.returncode)
+                )
+        except OSError as exc:
+            raise self.severe(u"problems with '%s' directive: %s."
+                              % (self.name, ErrorString(exc)))
+        return out
+
+    def nestedParse(self, lines, fname):
+        content = ViewList()
+        node = nodes.section()
+
+        if "debug" in self.options:
+            code_block = "\n\n.. code-block:: rst\n    :linenos:\n"
+            for l in lines.split("\n"):
+                code_block += "\n    " + l
+            lines = code_block + "\n\n"
+
+        line_regex = re.compile("^#define LINENO (\S+)\#([0-9]+)$")
+        ln = 0
+        n = 0
+        f = fname
+
+        for line in lines.split("\n"):
+            n = n + 1
+            match = line_regex.search(line)
+            if match:
+                new_f = match.group(1)
+
+                # Sphinx parser is lazy: it stops parsing contents in the
+                # middle, if it is too big. So, handle it per input file
+                if new_f != f and content:
+                    self.do_parse(content, node)
+                    content = ViewList()
+
+                f = new_f
+
+                # sphinx counts lines from 0
+                ln = int(match.group(2)) - 1
+            else:
+                content.append(line, f, ln)
+
+        kernellog.info(self.state.document.settings.env.app, "%s: parsed %i lines" % (fname, n))
+
+        if content:
+            self.do_parse(content, node)
+
+        return node.children
+
+    def do_parse(self, content, node):
+        if Use_SSI:
+            with switch_source_input(self.state, content):
+                self.state.nested_parse(content, 0, node, match_titles=1)
+        else:
+            buf  = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
+
+            self.state.memo.title_styles  = []
+            self.state.memo.section_level = 0
+            self.state.memo.reporter      = AutodocReporter(content, self.state.memo.reporter)
+            try:
+                self.state.nested_parse(content, 0, node, match_titles=1)
+            finally:
+                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
index af924f51a7dcc5838c80a11c3ff4447e500936e2..8ac7d274f542b78d9e6061b4f6900e309d817613 100644 (file)
@@ -25,4 +25,8 @@ def verbose(app, message):
     else:
         app.verbose(message)
 
-
+def info(app, message):
+    if UseLogging:
+        logger.info(message)
+    else:
+        app.info(message)
index 69fc5167e6486b6c6378b80a08df7ce1651fb051..acd2cc2a538df5f9a4bb8343c423fa1ef4b7e6d4 100644 (file)
@@ -22,6 +22,7 @@ place where this information is gathered.
    spec_ctrl
    accelerators/ocxl
    ioctl/index
+   iommu
    media/index
 
 .. only::  subproject and html
index 7d81c0aa4a59c1303224ab8f534825d02143d159..cf62162d4be207e5e9f8beaecf2f044cb7352d8a 100644 (file)
@@ -92,6 +92,10 @@ KVM_FEATURE_ASYNC_PF_INT           14          guest checks this feature bit
                                                async pf acknowledgment msr
                                                0x4b564d07.
 
+KVM_FEATURE_MSI_EXT_DEST_ID        15          guest checks this feature bit
+                                               before using extended destination
+                                               ID bits in MSI address bits 11-5.
+
 KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 24          host will warn if no guest-side
                                                per-cpu warps are expected in
                                                kvmclock
index e73636b75f29de8644c5c260b60f029e36df635a..3da6d8c154e486f4b9eb43b574b580ac43ecf1ea 100644 (file)
@@ -934,7 +934,7 @@ M:  Evan Quan <evan.quan@amd.com>
 L:     amd-gfx@lists.freedesktop.org
 S:     Supported
 T:     git git://people.freedesktop.org/~agd5f/linux
-F:     drivers/gpu/drm/amd/powerplay/
+F:     drivers/gpu/drm/amd/pm/powerplay/
 
 AMD SEATTLE DEVICE TREE SUPPORT
 M:     Brijesh Singh <brijeshkumar.singh@amd.com>
@@ -978,7 +978,7 @@ M:  Michael Hennerich <Michael.Hennerich@analog.com>
 L:     linux-iio@vger.kernel.org
 S:     Supported
 W:     http://ez.analog.com/community/linux-device-drivers
-F:     Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt
+F:     Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml
 F:     drivers/iio/adc/ad7768-1.c
 
 ANALOG DEVICES INC AD7780 DRIVER
@@ -2375,7 +2375,6 @@ F:        sound/soc/rockchip/
 N:     rockchip
 
 ARM/SAMSUNG EXYNOS ARM ARCHITECTURES
-M:     Kukjin Kim <kgene@kernel.org>
 M:     Krzysztof Kozlowski <krzk@kernel.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 L:     linux-samsung-soc@vger.kernel.org
@@ -2642,10 +2641,8 @@ F:       drivers/pinctrl/visconti/
 N:     visconti
 
 ARM/UNIPHIER ARCHITECTURE
-M:     Masahiro Yamada <yamada.masahiro@socionext.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/masahiroy/linux-uniphier.git
+S:     Orphan
 F:     Documentation/devicetree/bindings/arm/socionext/uniphier.yaml
 F:     Documentation/devicetree/bindings/gpio/socionext,uniphier-gpio.yaml
 F:     Documentation/devicetree/bindings/pinctrl/socionext,uniphier-pinctrl.yaml
@@ -3860,7 +3857,7 @@ M:        Roger Quadros <rogerq@ti.com>
 L:     linux-usb@vger.kernel.org
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git
-F:     Documentation/devicetree/bindings/usb/cdns-usb3.txt
+F:     Documentation/devicetree/bindings/usb/cdns,usb3.yaml
 F:     drivers/usb/cdns3/
 
 CADET FM/AM RADIO RECEIVER DRIVER
@@ -5006,9 +5003,8 @@ T:        git git://linuxtv.org/media_tree.git
 F:     drivers/media/platform/sti/delta
 
 DENALI NAND DRIVER
-M:     Masahiro Yamada <yamada.masahiro@socionext.com>
 L:     linux-mtd@lists.infradead.org
-S:     Supported
+S:     Orphan
 F:     drivers/mtd/nand/raw/denali*
 
 DESIGNWARE EDMA CORE IP DRIVER
@@ -7920,7 +7916,7 @@ HISILICON LPC BUS DRIVER
 M:     john.garry@huawei.com
 S:     Maintained
 W:     http://www.hisilicon.com
-F:     Documentation/devicetree/bindings/arm/hisilicon/hisilicon-low-pin-count.txt
+F:     Documentation/devicetree/bindings/arm/hisilicon/low-pin-count.yaml
 F:     drivers/bus/hisi_lpc.c
 
 HISILICON NETWORK SUBSYSTEM 3 DRIVER (HNS3)
@@ -8976,22 +8972,6 @@ S:       Supported
 W:     https://01.org/linux-acpi
 F:     drivers/platform/x86/intel_menlow.c
 
-INTEL MIC DRIVERS (mic)
-M:     Sudeep Dutt <sudeep.dutt@intel.com>
-M:     Ashutosh Dixit <ashutosh.dixit@intel.com>
-S:     Supported
-W:     https://github.com/sudeepdutt/mic
-W:     http://software.intel.com/en-us/mic-developer
-F:     Documentation/misc-devices/mic/
-F:     drivers/dma/mic_x100_dma.c
-F:     drivers/dma/mic_x100_dma.h
-F:     drivers/misc/mic/
-F:     include/linux/mic_bus.h
-F:     include/linux/scif.h
-F:     include/uapi/linux/mic_common.h
-F:     include/uapi/linux/mic_ioctl.h
-F:     include/uapi/linux/scif_ioctl.h
-
 INTEL P-Unit IPC DRIVER
 M:     Zha Qipeng <qipeng.zha@intel.com>
 L:     platform-driver-x86@vger.kernel.org
@@ -11183,7 +11163,7 @@ F:      Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt
 F:     drivers/input/touchscreen/melfas_mip4.c
 
 MELLANOX BLUEFIELD I2C DRIVER
-M:     Khalil Blaiech <kblaiech@mellanox.com>
+M:     Khalil Blaiech <kblaiech@nvidia.com>
 L:     linux-i2c@vger.kernel.org
 S:     Supported
 F:     drivers/i2c/busses/i2c-mlxbf.c
@@ -14547,6 +14527,14 @@ F:     Documentation/devicetree/bindings/mailbox/qcom-ipcc.yaml
 F:     drivers/mailbox/qcom-ipcc.c
 F:     include/dt-bindings/mailbox/qcom-ipcc.h
 
+QUALCOMM IPQ4019 VQMMC REGULATOR DRIVER
+M:     Robert Marko <robert.marko@sartura.hr>
+M:     Luka Perkov <luka.perkov@sartura.hr>
+L:     linux-arm-msm@vger.kernel.org
+S:     Maintained
+F:     Documentation/devicetree/bindings/regulator/vqmmc-ipq4019-regulator.yaml
+F:     drivers/regulator/vqmmc-ipq4019-regulator.c
+
 QUALCOMM RMNET DRIVER
 M:     Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
 M:     Sean Tranchetti <stranche@codeaurora.org>
@@ -14902,7 +14890,6 @@ RENESAS ETHERNET DRIVERS
 R:     Sergei Shtylyov <sergei.shtylyov@gmail.com>
 L:     netdev@vger.kernel.org
 L:     linux-renesas-soc@vger.kernel.org
-F:     Documentation/devicetree/bindings/net/renesas,*.txt
 F:     Documentation/devicetree/bindings/net/renesas,*.yaml
 F:     drivers/net/ethernet/renesas/
 F:     include/linux/sh_eth.h
@@ -15372,7 +15359,6 @@ F:      security/safesetid/
 
 SAMSUNG AUDIO (ASoC) DRIVERS
 M:     Krzysztof Kozlowski <krzk@kernel.org>
-M:     Sangbeom Kim <sbkim73@samsung.com>
 M:     Sylwester Nawrocki <s.nawrocki@samsung.com>
 L:     alsa-devel@alsa-project.org (moderated for non-subscribers)
 S:     Supported
@@ -15407,7 +15393,6 @@ S:      Maintained
 F:     drivers/platform/x86/samsung-laptop.c
 
 SAMSUNG MULTIFUNCTION PMIC DEVICE DRIVERS
-M:     Sangbeom Kim <sbkim73@samsung.com>
 M:     Krzysztof Kozlowski <krzk@kernel.org>
 M:     Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
 L:     linux-kernel@vger.kernel.org
@@ -15489,7 +15474,6 @@ F:      include/linux/clk/samsung.h
 F:     include/linux/platform_data/clk-s3c2410.h
 
 SAMSUNG SPI DRIVERS
-M:     Kukjin Kim <kgene@kernel.org>
 M:     Krzysztof Kozlowski <krzk@kernel.org>
 M:     Andi Shyti <andi@etezian.org>
 L:     linux-spi@vger.kernel.org
@@ -18106,7 +18090,7 @@ M:      Yu Chen <chenyu56@huawei.com>
 M:     Binghui Wang <wangbinghui@hisilicon.com>
 L:     linux-usb@vger.kernel.org
 S:     Maintained
-F:     Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
+F:     Documentation/devicetree/bindings/phy/hisilicon,hi3660-usb3.yaml
 F:     drivers/phy/hisilicon/phy-hi3660-usb3.c
 
 USB ISP116X DRIVER
index ee2284a5cad2e6bd6a8c7d6a9f88ecfb8f714c3c..008aba5f1a20fcc90908cfd6bb9cdf55e73ae6d0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 5
 PATCHLEVEL = 10
 SUBLEVEL = 0
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc3
 NAME = Kleptomaniac Octopus
 
 # *DOCUMENTATION*
index 74c750bf1c1a26298fc2179b44ae784b577b7e75..a69dd8d080a881a69dcb6d0a757c95ca80e45ee6 100644 (file)
@@ -60,20 +60,6 @@ typedef unsigned long sigset_t;
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-
 #define SA_ONSTACK     0x00000001
 #define SA_RESTART     0x00000002
 #define SA_NOCLDSTOP   0x00000004
index 17fd1ed700ccab4285973c15fa83b143ad695cea..9152782444b55737ad04a227598fc4a17f69d7a8 100644 (file)
        sr      r5, [ARC_REG_LPB_CTRL]
 1:
 #endif /* CONFIG_ARC_LPB_DISABLE */
-#endif
+
+       /* On HSDK, CCMs need to remapped super early */
+#ifdef CONFIG_ARC_SOC_HSDK
+       mov     r6, 0x60000000
+       lr      r5, [ARC_REG_ICCM_BUILD]
+       breq    r5, 0, 1f
+       sr      r6, [ARC_REG_AUX_ICCM]
+1:
+       lr      r5, [ARC_REG_DCCM_BUILD]
+       breq    r5, 0, 2f
+       sr      r6, [ARC_REG_AUX_DCCM]
+2:
+#endif /* CONFIG_ARC_SOC_HSDK */
+
+#endif /* CONFIG_ISA_ARCV2 */
+
        ; Config DSP_CTRL properly, so kernel may use integer multiply,
        ; multiply-accumulate, and divide operations
        DSP_EARLY_INIT
index feba91c9d969cae7a86afb4daba599c26a098290..b23986f984509587c714ce006622ba9023a84ef9 100644 (file)
@@ -112,7 +112,7 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
                int (*consumer_fn) (unsigned int, void *), void *arg)
 {
 #ifdef CONFIG_ARC_DW2_UNWIND
-       int ret = 0;
+       int ret = 0, cnt = 0;
        unsigned int address;
        struct unwind_frame_info frame_info;
 
@@ -132,6 +132,11 @@ arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs,
                        break;
 
                frame_info.regs.r63 = frame_info.regs.r31;
+
+               if (cnt++ > 128) {
+                       printk("unwinder looping too long, aborting !\n");
+                       return 0;
+               }
        }
 
        return address;         /* return the last address it saw */
index 0b63fc095b998a2137281eccf37fd8e83512ff78..b3ea1fa11f870efc264a2a33966bbcd2a191efad 100644 (file)
@@ -17,22 +17,6 @@ int arc_hsdk_axi_dmac_coherent __section(".data") = 0;
 
 #define ARC_CCM_UNUSED_ADDR    0x60000000
 
-static void __init hsdk_init_per_cpu(unsigned int cpu)
-{
-       /*
-        * By default ICCM is mapped to 0x7z while this area is used for
-        * kernel virtual mappings, so move it to currently unused area.
-        */
-       if (cpuinfo_arc700[cpu].iccm.sz)
-               write_aux_reg(ARC_REG_AUX_ICCM, ARC_CCM_UNUSED_ADDR);
-
-       /*
-        * By default DCCM is mapped to 0x8z while this area is used by kernel,
-        * so move it to currently unused area.
-        */
-       if (cpuinfo_arc700[cpu].dccm.sz)
-               write_aux_reg(ARC_REG_AUX_DCCM, ARC_CCM_UNUSED_ADDR);
-}
 
 #define ARC_PERIPHERAL_BASE    0xf0000000
 #define CREG_BASE              (ARC_PERIPHERAL_BASE + 0x1000)
@@ -339,5 +323,4 @@ static const char *hsdk_compat[] __initconst = {
 MACHINE_START(SIMULATION, "hsdk")
        .dt_compat      = hsdk_compat,
        .init_early     = hsdk_init_early,
-       .init_per_cpu   = hsdk_init_per_cpu,
 MACHINE_END
index f1a41152e9dd70d57beaa6eed9608433cf64b25e..adde62d6fce73b99e9f088fd61916a5e4833f910 100644 (file)
        /delete-property/ #size-cells;
        spi-slave;
        status = "okay";
-       ready-gpio = <&gpio 125 GPIO_ACTIVE_HIGH>;
+       ready-gpios = <&gpio 125 GPIO_ACTIVE_HIGH>;
 
        slave {
                compatible = "olpc,xo1.75-ec";
                spi-cpha;
-               cmd-gpio = <&gpio 155 GPIO_ACTIVE_HIGH>;
+               cmd-gpios = <&gpio 155 GPIO_ACTIVE_HIGH>;
        };
 };
 
index cc4efd0efabd2664cd0fb7afc6232a981dff5f0f..4ae630d37d094fd47505c1f26a142a70bbba28ca 100644 (file)
                                interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&soc_clocks MMP2_CLK_CCIC0>;
                                clock-names = "axi";
+                               power-domains = <&soc_clocks MMP3_POWER_DOMAIN_CAMERA>;
                                #clock-cells = <0>;
                                clock-output-names = "mclk";
                                status = "disabled";
                                interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&soc_clocks MMP2_CLK_CCIC1>;
                                clock-names = "axi";
+                               power-domains = <&soc_clocks MMP3_POWER_DOMAIN_CAMERA>;
                                #clock-cells = <0>;
                                clock-output-names = "mclk";
                                status = "disabled";
index ca109dc182388dfd193d9505d556ce77c5aec940..2e77ccec3fc16553d813b0d925841a98945cc82a 100644 (file)
                states = <1800000 0x1>,
                         <2900000 0x0>;
        };
+
+       vin: vin {
+               compatible = "regulator-fixed";
+               regulator-name = "vin";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-always-on;
+       };
 };
 
 &adc {
 
                regulators {
                        compatible = "st,stpmic1-regulators";
+                       buck1-supply = <&vin>;
+                       buck2-supply = <&vin>;
+                       buck3-supply = <&vin>;
+                       buck4-supply = <&vin>;
                        ldo1-supply = <&v3v3>;
                        ldo2-supply = <&v3v3>;
                        ldo3-supply = <&vdd_ddr>;
+                       ldo4-supply = <&vin>;
                        ldo5-supply = <&v3v3>;
                        ldo6-supply = <&v3v3>;
+                       vref_ddr-supply = <&vin>;
+                       boost-supply = <&vin>;
                        pwr_sw1-supply = <&bst_out>;
                        pwr_sw2-supply = <&bst_out>;
 
index a5307745719a02fc2b78bc7302fe57dfe930d23c..93398cfae97ee41d10bddf0d4dc7cc7d3ea05ca2 100644 (file)
                dais = <&sai2a_port &sai2b_port &i2s2_port>;
                status = "okay";
        };
+
+       vin: vin {
+               compatible = "regulator-fixed";
+               regulator-name = "vin";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-always-on;
+       };
 };
 
 &adc {
 
                regulators {
                        compatible = "st,stpmic1-regulators";
+                       buck1-supply = <&vin>;
+                       buck2-supply = <&vin>;
+                       buck3-supply = <&vin>;
+                       buck4-supply = <&vin>;
                        ldo1-supply = <&v3v3>;
+                       ldo2-supply = <&vin>;
                        ldo3-supply = <&vdd_ddr>;
+                       ldo4-supply = <&vin>;
+                       ldo5-supply = <&vin>;
                        ldo6-supply = <&v3v3>;
+                       vref_ddr-supply = <&vin>;
+                       boost-supply = <&vin>;
                        pwr_sw1-supply = <&bst_out>;
                        pwr_sw2-supply = <&bst_out>;
 
index 0f95a6ef8543a77513cabf78c131d8afa3589565..1c5a666c54b533245f03844a2ca3cd03d8cd055f 100644 (file)
                        trips {
                                cpu_alert0: cpu-alert0 {
                                        /* milliCelsius */
-                                       temperature = <850000>;
+                                       temperature = <85000>;
                                        hysteresis = <2000>;
                                        type = "passive";
                                };
index aeb1209e080463f2f2c69e5c8669d814cd6cf10f..bb70acc6b52648a61d0459786eb940c41b6ec469 100644 (file)
@@ -93,6 +93,7 @@ CONFIG_SPI=y
 CONFIG_SPI_IMX=y
 CONFIG_SPI_SPIDEV=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MXC=y
 CONFIG_W1=y
 CONFIG_W1_MASTER_MXC=y
 CONFIG_W1_SLAVE_THERM=y
index 0fa79bd00219140264aea6668157076cfafd3747..221f5c340c8653e40a6be937080669236554180d 100644 (file)
@@ -217,6 +217,7 @@ CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_PCF857X=y
 CONFIG_GPIO_STMPE=y
 CONFIG_GPIO_74X164=y
+CONFIG_GPIO_MXC=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_POWER_RESET_SYSCON_POWEROFF=y
index 70b709a669d2b681ab29b2ffc875834cd62f7d10..e00be9faa23bfa7e1a28a8b8f8d0bd8ba0c60a2b 100644 (file)
@@ -166,6 +166,7 @@ CONFIG_SPI_IMX=y
 CONFIG_SPI_ORION=y
 CONFIG_GPIO_ASPEED=m
 CONFIG_GPIO_ASPEED_SGPIO=y
+CONFIG_GPIO_MXC=y
 CONFIG_POWER_RESET=y
 CONFIG_POWER_RESET_GPIO=y
 CONFIG_POWER_RESET_QNAP=y
index e731cdf7c88c4ad177513a4be7ff9290007369c1..a611b0c1e540fcada57f3a20dfdcf90e3fad7e36 100644 (file)
@@ -465,6 +465,7 @@ CONFIG_GPIO_PALMAS=y
 CONFIG_GPIO_TPS6586X=y
 CONFIG_GPIO_TPS65910=y
 CONFIG_GPIO_TWL4030=y
+CONFIG_GPIO_MXC=y
 CONFIG_POWER_AVS=y
 CONFIG_ROCKCHIP_IODOMAIN=y
 CONFIG_POWER_RESET_AS3722=y
index 65530a042009b90dde5d667756ab05f1b2083cd5..430be7774402ef10b0b34c7f8a28c13bcfddc85c 100644 (file)
@@ -17,6 +17,8 @@ typedef struct {
        unsigned long sig[_NSIG_WORDS];
 } sigset_t;
 
+#define __ARCH_UAPI_SA_FLAGS   (SA_THIRTYTWO | SA_RESTORER)
+
 #define __ARCH_HAS_SA_RESTORER
 
 #include <asm/sigcontext.h>
index 9b4185ba4f8a5baea01d7ce93d740780e05524bc..c9a3ea1d8d4166349dfee7c20a27444efa37dcac 100644 (file)
@@ -60,33 +60,12 @@ typedef unsigned long sigset_t;
 #define SIGSWI         32
 
 /*
- * SA_FLAGS values:
- *
- * SA_NOCLDSTOP                flag to turn off SIGCHLD when children stop.
- * SA_NOCLDWAIT                flag on SIGCHLD to inhibit zombies.
- * SA_SIGINFO          deliver the signal with SIGINFO structs
- * SA_THIRTYTWO                delivers the signal in 32-bit mode, even if the task 
- *                     is running in 26-bit.
- * SA_ONSTACK          allows alternate signal stacks (see sigaltstack(2)).
- * SA_RESTART          flag to get restarting signals (which were the default long ago)
- * SA_NODEFER          prevents the current signal from being masked in the handler.
- * SA_RESETHAND                clears the handler when the signal is delivered.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
+ * SA_THIRTYTWO historically meant deliver the signal in 32-bit mode, even if
+ * the task is running in 26-bit. But since the kernel no longer supports
+ * 26-bit mode, the flag has no effect.
  */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002
-#define SA_SIGINFO     0x00000004
 #define SA_THIRTYTWO   0x02000000
 #define SA_RESTORER    0x04000000
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
 
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
index 5f4922e858d033604900106c7fa249ef5ed19b5a..f7f4620d59c3aff852f73ecbc22c78d69f0e87de 100644 (file)
@@ -40,6 +40,10 @@ SECTIONS
                ARM_DISCARD
 #ifndef CONFIG_SMP_ON_UP
                *(.alt.smp.init)
+#endif
+#ifndef CONFIG_ARM_UNWIND
+               *(.ARM.exidx) *(.ARM.exidx.*)
+               *(.ARM.extab) *(.ARM.extab.*)
 #endif
        }
 
index 2d962fe488210d309f050e7387bc7f1812210d3f..a3a64bf972507b3c311844fce4838aaed4446168 100644 (file)
@@ -35,13 +35,8 @@ ENTRY(ll_get_coherency_base)
 
        /*
         * MMU is disabled, use the physical address of the coherency
-        * base address. However, if the coherency fabric isn't mapped
-        * (i.e its virtual address is zero), it means coherency is
-        * not enabled, so we return 0.
+        * base address, (or 0x0 if the coherency fabric is not mapped)
         */
-       ldr     r1, =coherency_base
-       cmp     r1, #0
-       beq     2f
        adr     r1, 3f
        ldr     r3, [r1]
        ldr     r1, [r1, r3]
index d57112a276f5ac79da2100970e8ca8c6a78af54a..c23dbf8bebeeb7f4387b90e7827c6a570d940566 100644 (file)
@@ -354,8 +354,8 @@ static void __init free_highpages(void)
        /* set highmem page free */
        for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
                                &range_start, &range_end, NULL) {
-               unsigned long start = PHYS_PFN(range_start);
-               unsigned long end = PHYS_PFN(range_end);
+               unsigned long start = PFN_UP(range_start);
+               unsigned long end = PFN_DOWN(range_end);
 
                /* Ignore complete lowmem entries */
                if (end <= max_low)
index 1515f6f153a0dc9a3ebc4220442686138a9f7859..984ca3a6d2a0a212a042b9271d6df008962e3afc 100644 (file)
@@ -170,6 +170,8 @@ config ARM64
        select HAVE_NMI
        select HAVE_PATA_PLATFORM
        select HAVE_PERF_EVENTS
+       select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI && HW_PERF_EVENTS
+       select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_REGS_AND_STACK_ACCESS_API
@@ -195,7 +197,6 @@ config ARM64
        select PCI_SYSCALL if PCI
        select POWER_RESET
        select POWER_SUPPLY
-       select SET_FS
        select SPARSE_IRQ
        select SWIOTLB
        select SYSCTL_EXCEPTION_TRACE
@@ -331,16 +332,16 @@ config BROKEN_GAS_INST
 config KASAN_SHADOW_OFFSET
        hex
        depends on KASAN
-       default 0xdfffa00000000000 if (ARM64_VA_BITS_48 || ARM64_VA_BITS_52) && !KASAN_SW_TAGS
-       default 0xdfffd00000000000 if ARM64_VA_BITS_47 && !KASAN_SW_TAGS
-       default 0xdffffe8000000000 if ARM64_VA_BITS_42 && !KASAN_SW_TAGS
-       default 0xdfffffd000000000 if ARM64_VA_BITS_39 && !KASAN_SW_TAGS
-       default 0xdffffffa00000000 if ARM64_VA_BITS_36 && !KASAN_SW_TAGS
-       default 0xefff900000000000 if (ARM64_VA_BITS_48 || ARM64_VA_BITS_52) && KASAN_SW_TAGS
-       default 0xefffc80000000000 if ARM64_VA_BITS_47 && KASAN_SW_TAGS
-       default 0xeffffe4000000000 if ARM64_VA_BITS_42 && KASAN_SW_TAGS
-       default 0xefffffc800000000 if ARM64_VA_BITS_39 && KASAN_SW_TAGS
-       default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
+       default 0xdfff800000000000 if (ARM64_VA_BITS_48 || ARM64_VA_BITS_52) && !KASAN_SW_TAGS
+       default 0xdfffc00000000000 if ARM64_VA_BITS_47 && !KASAN_SW_TAGS
+       default 0xdffffe0000000000 if ARM64_VA_BITS_42 && !KASAN_SW_TAGS
+       default 0xdfffffc000000000 if ARM64_VA_BITS_39 && !KASAN_SW_TAGS
+       default 0xdffffff800000000 if ARM64_VA_BITS_36 && !KASAN_SW_TAGS
+       default 0xefff800000000000 if (ARM64_VA_BITS_48 || ARM64_VA_BITS_52) && KASAN_SW_TAGS
+       default 0xefffc00000000000 if ARM64_VA_BITS_47 && KASAN_SW_TAGS
+       default 0xeffffe0000000000 if ARM64_VA_BITS_42 && KASAN_SW_TAGS
+       default 0xefffffc000000000 if ARM64_VA_BITS_39 && KASAN_SW_TAGS
+       default 0xeffffff800000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
        default 0xffffffffffffffff
 
 source "arch/arm64/Kconfig.platforms"
@@ -1388,6 +1389,9 @@ config ARM64_PAN
         The feature is detected at runtime, and will remain as a 'nop'
         instruction if the cpu does not implement the feature.
 
+config AS_HAS_LDAPR
+       def_bool $(as-instr,.arch_extension rcpc)
+
 config ARM64_LSE_ATOMICS
        bool
        default ARM64_USE_LSE_ATOMICS
@@ -1425,27 +1429,6 @@ endmenu
 
 menu "ARMv8.2 architectural features"
 
-config ARM64_UAO
-       bool "Enable support for User Access Override (UAO)"
-       default y
-       help
-         User Access Override (UAO; part of the ARMv8.2 Extensions)
-         causes the 'unprivileged' variant of the load/store instructions to
-         be overridden to be privileged.
-
-         This option changes get_user() and friends to use the 'unprivileged'
-         variant of the load/store instructions. This ensures that user-space
-         really did have access to the supplied memory. When addr_limit is
-         set to kernel memory the UAO bit will be set, allowing privileged
-         access to kernel memory.
-
-         Choosing this option will cause copy_to_user() et al to use user-space
-         memory permissions.
-
-         The feature is detected at runtime, the kernel will use the
-         regular load/store instructions if the cpu does not implement the
-         feature.
-
 config ARM64_PMEM
        bool "Enable support for persistent memory"
        select ARCH_HAS_PMEM_API
@@ -1846,15 +1829,36 @@ config CMDLINE
          entering them here. As a minimum, you should specify the the
          root device (e.g. root=/dev/nfs).
 
+choice
+       prompt "Kernel command line type" if CMDLINE != ""
+       default CMDLINE_FROM_BOOTLOADER
+       help
+         Choose how the kernel will handle the provided default kernel
+         command line string.
+
+config CMDLINE_FROM_BOOTLOADER
+       bool "Use bootloader kernel arguments if available"
+       help
+         Uses the command-line options passed by the boot loader. If
+         the boot loader doesn't provide any, the default kernel command
+         string provided in CMDLINE will be used.
+
+config CMDLINE_EXTEND
+       bool "Extend bootloader kernel arguments"
+       help
+         The command-line arguments provided by the boot loader will be
+         appended to the default kernel command string.
+
 config CMDLINE_FORCE
        bool "Always use the default kernel command string"
-       depends on CMDLINE != ""
        help
          Always use the default kernel command string, even if the boot
          loader passes other arguments to the kernel.
          This is useful if you cannot or don't want to change the
          command-line options your boot loader passes to the kernel.
 
+endchoice
+
 config EFI_STUB
        bool
 
index 6f2494dd6d60b60b5967ddc121d886d4ff00b253..5c4ac1c9f4e0295183c26a97bb8be42861766a67 100644 (file)
@@ -54,6 +54,7 @@ config ARCH_BCM_IPROC
 config ARCH_BERLIN
        bool "Marvell Berlin SoC Family"
        select DW_APB_ICTL
+       select DW_APB_TIMER_OF
        select GPIOLIB
        select PINCTRL
        help
index cb1360ae1211e27b7783eac19ad00244f121e12f..7740f97c240f050455eeb25702a9d0a22c6ff483 100644 (file)
        pinctrl-0 = <&uart_ao_a_pins>;
        pinctrl-names = "default";
 };
+
+&usb {
+       status = "okay";
+       dr_mode = "otg";
+       vbus-supply = <&usb_pwr>;
+};
index b9efc8469265d871d244c2cb2a89be88152d0bf2..724ee179b316e23d9540736a8eac7adabc4c807f 100644 (file)
                #size-cells = <2>;
                ranges;
 
+               usb: usb@ffe09080 {
+                       compatible = "amlogic,meson-axg-usb-ctrl";
+                       reg = <0x0 0xffe09080 0x0 0x20>;
+                       interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+                       #address-cells = <2>;
+                       #size-cells = <2>;
+                       ranges;
+
+                       clocks = <&clkc CLKID_USB>, <&clkc CLKID_USB1_DDR_BRIDGE>;
+                       clock-names = "usb_ctrl", "ddr";
+                       resets = <&reset RESET_USB_OTG>;
+
+                       dr_mode = "otg";
+
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb2-phy1";
+
+                       dwc2: usb@ff400000 {
+                               compatible = "amlogic,meson-g12a-usb", "snps,dwc2";
+                               reg = <0x0 0xff400000 0x0 0x40000>;
+                               interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
+                               clocks = <&clkc CLKID_USB1>;
+                               clock-names = "otg";
+                               phys = <&usb2_phy1>;
+                               dr_mode = "peripheral";
+                               g-rx-fifo-size = <192>;
+                               g-np-tx-fifo-size = <128>;
+                               g-tx-fifo-size = <128 128 16 16 16>;
+                       };
+
+                       dwc3: usb@ff500000 {
+                               compatible = "snps,dwc3";
+                               reg = <0x0 0xff500000 0x0 0x100000>;
+                               interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+                               dr_mode = "host";
+                               maximum-speed = "high-speed";
+                               snps,dis_u2_susphy_quirk;
+                       };
+               };
+
                ethmac: ethernet@ff3f0000 {
                        compatible = "amlogic,meson-axg-dwmac",
                                     "snps,dwmac-3.70a",
                                      "timing-adjustment";
                        rx-fifo-depth = <4096>;
                        tx-fifo-depth = <2048>;
+                       resets = <&reset RESET_ETHERNET>;
+                       reset-names = "stmmaceth";
                        status = "disabled";
                };
 
                                clock-names = "core", "clkin0", "clkin1";
                                resets = <&reset RESET_SD_EMMC_C>;
                        };
+
+                       usb2_phy1: phy@9020 {
+                               compatible = "amlogic,meson-gxl-usb2-phy";
+                               #phy-cells = <0>;
+                               reg = <0x0 0x9020 0x0 0x20>;
+                               clocks = <&clkc CLKID_USB>;
+                               clock-names = "phy";
+                               resets = <&reset RESET_USB_OTG>;
+                               reset-names = "phy";
+                       };
                };
 
                sram: sram@fffc0000 {
index 1e83ec5b8c91a13018b3fc7a1651eca7f75290f7..8514fe6a275a320d6b58bcc578ad56dd129690e6 100644 (file)
                };
 
                ethmac: ethernet@ff3f0000 {
-                       compatible = "amlogic,meson-axg-dwmac",
+                       compatible = "amlogic,meson-g12a-dwmac",
                                     "snps,dwmac-3.70a",
                                     "snps,dwmac";
                        reg = <0x0 0xff3f0000 0x0 0x10000>,
                                      "timing-adjustment";
                        rx-fifo-depth = <4096>;
                        tx-fifo-depth = <2048>;
+                       resets = <&reset RESET_ETHERNET>;
+                       reset-names = "stmmaceth";
                        status = "disabled";
 
                        mdio0: mdio {
                                hwrng: rng@218 {
                                        compatible = "amlogic,meson-rng";
                                        reg = <0x0 0x218 0x0 0x4>;
+                                       clocks = <&clkc CLKID_RNG0>;
+                                       clock-names = "core";
                                };
                        };
 
index 5de2815ba99de9627aa7c7954df376c1c74fd9d3..ce1198ad34e425ea9077dea51a263dfd9238b63f 100644 (file)
@@ -19,7 +19,7 @@
        regulator-min-microvolt = <680000>;
        regulator-max-microvolt = <1040000>;
 
-       pwms = <&pwm_AO_cd 1 1500 0>;
+       pwms = <&pwm_ab 0 1500 0>;
 };
 
 &vddcpu_b {
index 0edd137151f89eb6ba63695d28abdfaf18cf6434..726b91d3a905a5cfd9a9322654570a2074ff58d0 100644 (file)
@@ -13,6 +13,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/power/meson-gxbb-power.h>
+#include <dt-bindings/reset/amlogic,meson-gxbb-reset.h>
 #include <dt-bindings/thermal/thermal.h>
 
 / {
                        interrupt-names = "macirq";
                        rx-fifo-depth = <4096>;
                        tx-fifo-depth = <2048>;
+                       resets = <&reset RESET_ETHERNET>;
+                       reset-names = "stmmaceth";
                        power-domains = <&pwrc PWRC_GXBB_ETHERNET_MEM_ID>;
                        status = "disabled";
                };
index 03733fd92732d4eeb48bd53facedef2bb012a4e9..215d2f70262332ff95a24ce91b78e030a23a7c73 100644 (file)
        compatible = "globalscale,espressobin-v7-emmc", "globalscale,espressobin-v7",
                     "globalscale,espressobin", "marvell,armada3720",
                     "marvell,armada3710";
+
+       aliases {
+               /* ethernet1 is wan port */
+               ethernet1 = &switch0port3;
+               ethernet3 = &switch0port1;
+       };
 };
 
 &switch0 {
        ports {
-               port@1 {
+               switch0port1: port@1 {
                        reg = <1>;
                        label = "lan1";
                        phy-handle = <&switch0phy0>;
                };
 
-               port@3 {
+               switch0port3: port@3 {
                        reg = <3>;
                        label = "wan";
                        phy-handle = <&switch0phy2>;
index 8570c5f47d7d89d0c39e3162cf23034061d1927e..b6f4af8ebafbb9739edcf69dc021c18be3973320 100644 (file)
        model = "Globalscale Marvell ESPRESSOBin Board V7";
        compatible = "globalscale,espressobin-v7", "globalscale,espressobin",
                     "marvell,armada3720", "marvell,armada3710";
+
+       aliases {
+               /* ethernet1 is wan port */
+               ethernet1 = &switch0port3;
+               ethernet3 = &switch0port1;
+       };
 };
 
 &switch0 {
        ports {
-               port@1 {
+               switch0port1: port@1 {
                        reg = <1>;
                        label = "lan1";
                        phy-handle = <&switch0phy0>;
                };
 
-               port@3 {
+               switch0port3: port@3 {
                        reg = <3>;
                        label = "wan";
                        phy-handle = <&switch0phy2>;
index b97218c727277ac1976c6cf2c8c4eeb8375febd6..0775c16e0ec8062cbf77cc3b4bfc4d7540005592 100644 (file)
 / {
        aliases {
                ethernet0 = &eth0;
+               /* for dsa slave device */
+               ethernet1 = &switch0port1;
+               ethernet2 = &switch0port2;
+               ethernet3 = &switch0port3;
                serial0 = &uart0;
                serial1 = &uart1;
        };
                        #address-cells = <1>;
                        #size-cells = <0>;
 
-                       port@0 {
+                       switch0port0: port@0 {
                                reg = <0>;
                                label = "cpu";
                                ethernet = <&eth0>;
                                };
                        };
 
-                       port@1 {
+                       switch0port1: port@1 {
                                reg = <1>;
                                label = "wan";
                                phy-handle = <&switch0phy0>;
                        };
 
-                       port@2 {
+                       switch0port2: port@2 {
                                reg = <2>;
                                label = "lan0";
                                phy-handle = <&switch0phy1>;
                        };
 
-                       port@3 {
+                       switch0port3: port@3 {
                                reg = <3>;
                                label = "lan1";
                                phy-handle = <&switch0phy2>;
index 17a2df6a263e8fc96ce9a959b7e08aa1ba50b8cb..5cfe3cf6f2acb2db8020bbf8821aba0a9c787538 100644 (file)
@@ -500,6 +500,7 @@ CONFIG_GPIO_ALTERA=m
 CONFIG_GPIO_DWAPB=y
 CONFIG_GPIO_MB86S7X=y
 CONFIG_GPIO_MPC8XXX=y
+CONFIG_GPIO_MXC=y
 CONFIG_GPIO_PL061=y
 CONFIG_GPIO_RCAR=y
 CONFIG_GPIO_UNIPHIER=y
diff --git a/arch/arm64/include/asm/alternative-macros.h b/arch/arm64/include/asm/alternative-macros.h
new file mode 100644 (file)
index 0000000..5df500d
--- /dev/null
@@ -0,0 +1,217 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_ALTERNATIVE_MACROS_H
+#define __ASM_ALTERNATIVE_MACROS_H
+
+#include <asm/cpucaps.h>
+
+#define ARM64_CB_PATCH ARM64_NCAPS
+
+/* A64 instructions are always 32 bits. */
+#define        AARCH64_INSN_SIZE               4
+
+#ifndef __ASSEMBLY__
+
+#include <linux/stringify.h>
+
+#define ALTINSTR_ENTRY(feature)                                                      \
+       " .word 661b - .\n"                             /* label           */ \
+       " .word 663f - .\n"                             /* new instruction */ \
+       " .hword " __stringify(feature) "\n"            /* feature bit     */ \
+       " .byte 662b-661b\n"                            /* source len      */ \
+       " .byte 664f-663f\n"                            /* replacement len */
+
+#define ALTINSTR_ENTRY_CB(feature, cb)                                       \
+       " .word 661b - .\n"                             /* label           */ \
+       " .word " __stringify(cb) "- .\n"               /* callback */        \
+       " .hword " __stringify(feature) "\n"            /* feature bit     */ \
+       " .byte 662b-661b\n"                            /* source len      */ \
+       " .byte 664f-663f\n"                            /* replacement len */
+
+/*
+ * alternative assembly primitive:
+ *
+ * If any of these .org directive fail, it means that insn1 and insn2
+ * don't have the same length. This used to be written as
+ *
+ * .if ((664b-663b) != (662b-661b))
+ *     .error "Alternatives instruction length mismatch"
+ * .endif
+ *
+ * but most assemblers die if insn1 or insn2 have a .inst. This should
+ * be fixed in a binutils release posterior to 2.25.51.0.2 (anything
+ * containing commit 4e4d08cf7399b606 or c1baaddf8861).
+ *
+ * Alternatives with callbacks do not generate replacement instructions.
+ */
+#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled)    \
+       ".if "__stringify(cfg_enabled)" == 1\n"                         \
+       "661:\n\t"                                                      \
+       oldinstr "\n"                                                   \
+       "662:\n"                                                        \
+       ".pushsection .altinstructions,\"a\"\n"                         \
+       ALTINSTR_ENTRY(feature)                                         \
+       ".popsection\n"                                                 \
+       ".subsection 1\n"                                               \
+       "663:\n\t"                                                      \
+       newinstr "\n"                                                   \
+       "664:\n\t"                                                      \
+       ".org   . - (664b-663b) + (662b-661b)\n\t"                      \
+       ".org   . - (662b-661b) + (664b-663b)\n\t"                      \
+       ".previous\n"                                                   \
+       ".endif\n"
+
+#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb)       \
+       ".if "__stringify(cfg_enabled)" == 1\n"                         \
+       "661:\n\t"                                                      \
+       oldinstr "\n"                                                   \
+       "662:\n"                                                        \
+       ".pushsection .altinstructions,\"a\"\n"                         \
+       ALTINSTR_ENTRY_CB(feature, cb)                                  \
+       ".popsection\n"                                                 \
+       "663:\n\t"                                                      \
+       "664:\n\t"                                                      \
+       ".endif\n"
+
+#define _ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg, ...)        \
+       __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg))
+
+#define ALTERNATIVE_CB(oldinstr, cb) \
+       __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_PATCH, 1, cb)
+#else
+
+#include <asm/assembler.h>
+
+.macro altinstruction_entry orig_offset alt_offset feature orig_len alt_len
+       .word \orig_offset - .
+       .word \alt_offset - .
+       .hword \feature
+       .byte \orig_len
+       .byte \alt_len
+.endm
+
+.macro alternative_insn insn1, insn2, cap, enable = 1
+       .if \enable
+661:   \insn1
+662:   .pushsection .altinstructions, "a"
+       altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f
+       .popsection
+       .subsection 1
+663:   \insn2
+664:   .previous
+       .org    . - (664b-663b) + (662b-661b)
+       .org    . - (662b-661b) + (664b-663b)
+       .endif
+.endm
+
+/*
+ * Alternative sequences
+ *
+ * The code for the case where the capability is not present will be
+ * assembled and linked as normal. There are no restrictions on this
+ * code.
+ *
+ * The code for the case where the capability is present will be
+ * assembled into a special section to be used for dynamic patching.
+ * Code for that case must:
+ *
+ * 1. Be exactly the same length (in bytes) as the default code
+ *    sequence.
+ *
+ * 2. Not contain a branch target that is used outside of the
+ *    alternative sequence it is defined in (branches into an
+ *    alternative sequence are not fixed up).
+ */
+
+/*
+ * Begin an alternative code sequence.
+ */
+.macro alternative_if_not cap
+       .set .Lasm_alt_mode, 0
+       .pushsection .altinstructions, "a"
+       altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f
+       .popsection
+661:
+.endm
+
+.macro alternative_if cap
+       .set .Lasm_alt_mode, 1
+       .pushsection .altinstructions, "a"
+       altinstruction_entry 663f, 661f, \cap, 664f-663f, 662f-661f
+       .popsection
+       .subsection 1
+       .align 2        /* So GAS knows label 661 is suitably aligned */
+661:
+.endm
+
+.macro alternative_cb cb
+       .set .Lasm_alt_mode, 0
+       .pushsection .altinstructions, "a"
+       altinstruction_entry 661f, \cb, ARM64_CB_PATCH, 662f-661f, 0
+       .popsection
+661:
+.endm
+
+/*
+ * Provide the other half of the alternative code sequence.
+ */
+.macro alternative_else
+662:
+       .if .Lasm_alt_mode==0
+       .subsection 1
+       .else
+       .previous
+       .endif
+663:
+.endm
+
+/*
+ * Complete an alternative code sequence.
+ */
+.macro alternative_endif
+664:
+       .if .Lasm_alt_mode==0
+       .previous
+       .endif
+       .org    . - (664b-663b) + (662b-661b)
+       .org    . - (662b-661b) + (664b-663b)
+.endm
+
+/*
+ * Callback-based alternative epilogue
+ */
+.macro alternative_cb_end
+662:
+.endm
+
+/*
+ * Provides a trivial alternative or default sequence consisting solely
+ * of NOPs. The number of NOPs is chosen automatically to match the
+ * previous case.
+ */
+.macro alternative_else_nop_endif
+alternative_else
+       nops    (662b-661b) / AARCH64_INSN_SIZE
+alternative_endif
+.endm
+
+#define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)  \
+       alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
+
+.macro user_alt, label, oldinstr, newinstr, cond
+9999:  alternative_insn "\oldinstr", "\newinstr", \cond
+       _asm_extable 9999b, \label
+.endm
+
+#endif  /*  __ASSEMBLY__  */
+
+/*
+ * Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature));
+ *
+ * Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature, CONFIG_FOO));
+ * N.B. If CONFIG_FOO is specified, but not selected, the whole block
+ *      will be omitted, including oldinstr.
+ */
+#define ALTERNATIVE(oldinstr, newinstr, ...)   \
+       _ALTERNATIVE_CFG(oldinstr, newinstr, __VA_ARGS__, 1)
+
+#endif /* __ASM_ALTERNATIVE_MACROS_H */
index 619db9b4c9d5c0434e321736c7a5fec9dc6a9b1c..a38b92e11811e8b1ce379df536e11545bff4f1cc 100644 (file)
@@ -2,17 +2,13 @@
 #ifndef __ASM_ALTERNATIVE_H
 #define __ASM_ALTERNATIVE_H
 
-#include <asm/cpucaps.h>
-#include <asm/insn.h>
-
-#define ARM64_CB_PATCH ARM64_NCAPS
+#include <asm/alternative-macros.h>
 
 #ifndef __ASSEMBLY__
 
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/stddef.h>
-#include <linux/stringify.h>
 
 struct alt_instr {
        s32 orig_offset;        /* offset to original instruction */
@@ -35,264 +31,5 @@ void apply_alternatives_module(void *start, size_t length);
 static inline void apply_alternatives_module(void *start, size_t length) { }
 #endif
 
-#define ALTINSTR_ENTRY(feature)                                                      \
-       " .word 661b - .\n"                             /* label           */ \
-       " .word 663f - .\n"                             /* new instruction */ \
-       " .hword " __stringify(feature) "\n"            /* feature bit     */ \
-       " .byte 662b-661b\n"                            /* source len      */ \
-       " .byte 664f-663f\n"                            /* replacement len */
-
-#define ALTINSTR_ENTRY_CB(feature, cb)                                       \
-       " .word 661b - .\n"                             /* label           */ \
-       " .word " __stringify(cb) "- .\n"               /* callback */        \
-       " .hword " __stringify(feature) "\n"            /* feature bit     */ \
-       " .byte 662b-661b\n"                            /* source len      */ \
-       " .byte 664f-663f\n"                            /* replacement len */
-
-/*
- * alternative assembly primitive:
- *
- * If any of these .org directive fail, it means that insn1 and insn2
- * don't have the same length. This used to be written as
- *
- * .if ((664b-663b) != (662b-661b))
- *     .error "Alternatives instruction length mismatch"
- * .endif
- *
- * but most assemblers die if insn1 or insn2 have a .inst. This should
- * be fixed in a binutils release posterior to 2.25.51.0.2 (anything
- * containing commit 4e4d08cf7399b606 or c1baaddf8861).
- *
- * Alternatives with callbacks do not generate replacement instructions.
- */
-#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled)    \
-       ".if "__stringify(cfg_enabled)" == 1\n"                         \
-       "661:\n\t"                                                      \
-       oldinstr "\n"                                                   \
-       "662:\n"                                                        \
-       ".pushsection .altinstructions,\"a\"\n"                         \
-       ALTINSTR_ENTRY(feature)                                         \
-       ".popsection\n"                                                 \
-       ".subsection 1\n"                                               \
-       "663:\n\t"                                                      \
-       newinstr "\n"                                                   \
-       "664:\n\t"                                                      \
-       ".org   . - (664b-663b) + (662b-661b)\n\t"                      \
-       ".org   . - (662b-661b) + (664b-663b)\n\t"                      \
-       ".previous\n"                                                   \
-       ".endif\n"
-
-#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb)       \
-       ".if "__stringify(cfg_enabled)" == 1\n"                         \
-       "661:\n\t"                                                      \
-       oldinstr "\n"                                                   \
-       "662:\n"                                                        \
-       ".pushsection .altinstructions,\"a\"\n"                         \
-       ALTINSTR_ENTRY_CB(feature, cb)                                  \
-       ".popsection\n"                                                 \
-       "663:\n\t"                                                      \
-       "664:\n\t"                                                      \
-       ".endif\n"
-
-#define _ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg, ...)        \
-       __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg))
-
-#define ALTERNATIVE_CB(oldinstr, cb) \
-       __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_PATCH, 1, cb)
-#else
-
-#include <asm/assembler.h>
-
-.macro altinstruction_entry orig_offset alt_offset feature orig_len alt_len
-       .word \orig_offset - .
-       .word \alt_offset - .
-       .hword \feature
-       .byte \orig_len
-       .byte \alt_len
-.endm
-
-.macro alternative_insn insn1, insn2, cap, enable = 1
-       .if \enable
-661:   \insn1
-662:   .pushsection .altinstructions, "a"
-       altinstruction_entry 661b, 663f, \cap, 662b-661b, 664f-663f
-       .popsection
-       .subsection 1
-663:   \insn2
-664:   .previous
-       .org    . - (664b-663b) + (662b-661b)
-       .org    . - (662b-661b) + (664b-663b)
-       .endif
-.endm
-
-/*
- * Alternative sequences
- *
- * The code for the case where the capability is not present will be
- * assembled and linked as normal. There are no restrictions on this
- * code.
- *
- * The code for the case where the capability is present will be
- * assembled into a special section to be used for dynamic patching.
- * Code for that case must:
- *
- * 1. Be exactly the same length (in bytes) as the default code
- *    sequence.
- *
- * 2. Not contain a branch target that is used outside of the
- *    alternative sequence it is defined in (branches into an
- *    alternative sequence are not fixed up).
- */
-
-/*
- * Begin an alternative code sequence.
- */
-.macro alternative_if_not cap
-       .set .Lasm_alt_mode, 0
-       .pushsection .altinstructions, "a"
-       altinstruction_entry 661f, 663f, \cap, 662f-661f, 664f-663f
-       .popsection
-661:
-.endm
-
-.macro alternative_if cap
-       .set .Lasm_alt_mode, 1
-       .pushsection .altinstructions, "a"
-       altinstruction_entry 663f, 661f, \cap, 664f-663f, 662f-661f
-       .popsection
-       .subsection 1
-       .align 2        /* So GAS knows label 661 is suitably aligned */
-661:
-.endm
-
-.macro alternative_cb cb
-       .set .Lasm_alt_mode, 0
-       .pushsection .altinstructions, "a"
-       altinstruction_entry 661f, \cb, ARM64_CB_PATCH, 662f-661f, 0
-       .popsection
-661:
-.endm
-
-/*
- * Provide the other half of the alternative code sequence.
- */
-.macro alternative_else
-662:
-       .if .Lasm_alt_mode==0
-       .subsection 1
-       .else
-       .previous
-       .endif
-663:
-.endm
-
-/*
- * Complete an alternative code sequence.
- */
-.macro alternative_endif
-664:
-       .if .Lasm_alt_mode==0
-       .previous
-       .endif
-       .org    . - (664b-663b) + (662b-661b)
-       .org    . - (662b-661b) + (664b-663b)
-.endm
-
-/*
- * Callback-based alternative epilogue
- */
-.macro alternative_cb_end
-662:
-.endm
-
-/*
- * Provides a trivial alternative or default sequence consisting solely
- * of NOPs. The number of NOPs is chosen automatically to match the
- * previous case.
- */
-.macro alternative_else_nop_endif
-alternative_else
-       nops    (662b-661b) / AARCH64_INSN_SIZE
-alternative_endif
-.endm
-
-#define _ALTERNATIVE_CFG(insn1, insn2, cap, cfg, ...)  \
-       alternative_insn insn1, insn2, cap, IS_ENABLED(cfg)
-
-.macro user_alt, label, oldinstr, newinstr, cond
-9999:  alternative_insn "\oldinstr", "\newinstr", \cond
-       _asm_extable 9999b, \label
-.endm
-
-/*
- * Generate the assembly for UAO alternatives with exception table entries.
- * This is complicated as there is no post-increment or pair versions of the
- * unprivileged instructions, and USER() only works for single instructions.
- */
-#ifdef CONFIG_ARM64_UAO
-       .macro uao_ldp l, reg1, reg2, addr, post_inc
-               alternative_if_not ARM64_HAS_UAO
-8888:                  ldp     \reg1, \reg2, [\addr], \post_inc;
-8889:                  nop;
-                       nop;
-               alternative_else
-                       ldtr    \reg1, [\addr];
-                       ldtr    \reg2, [\addr, #8];
-                       add     \addr, \addr, \post_inc;
-               alternative_endif
-
-               _asm_extable    8888b,\l;
-               _asm_extable    8889b,\l;
-       .endm
-
-       .macro uao_stp l, reg1, reg2, addr, post_inc
-               alternative_if_not ARM64_HAS_UAO
-8888:                  stp     \reg1, \reg2, [\addr], \post_inc;
-8889:                  nop;
-                       nop;
-               alternative_else
-                       sttr    \reg1, [\addr];
-                       sttr    \reg2, [\addr, #8];
-                       add     \addr, \addr, \post_inc;
-               alternative_endif
-
-               _asm_extable    8888b,\l;
-               _asm_extable    8889b,\l;
-       .endm
-
-       .macro uao_user_alternative l, inst, alt_inst, reg, addr, post_inc
-               alternative_if_not ARM64_HAS_UAO
-8888:                  \inst   \reg, [\addr], \post_inc;
-                       nop;
-               alternative_else
-                       \alt_inst       \reg, [\addr];
-                       add             \addr, \addr, \post_inc;
-               alternative_endif
-
-               _asm_extable    8888b,\l;
-       .endm
-#else
-       .macro uao_ldp l, reg1, reg2, addr, post_inc
-               USER(\l, ldp \reg1, \reg2, [\addr], \post_inc)
-       .endm
-       .macro uao_stp l, reg1, reg2, addr, post_inc
-               USER(\l, stp \reg1, \reg2, [\addr], \post_inc)
-       .endm
-       .macro uao_user_alternative l, inst, alt_inst, reg, addr, post_inc
-               USER(\l, \inst \reg, [\addr], \post_inc)
-       .endm
-#endif
-
-#endif  /*  __ASSEMBLY__  */
-
-/*
- * Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature));
- *
- * Usage: asm(ALTERNATIVE(oldinstr, newinstr, feature, CONFIG_FOO));
- * N.B. If CONFIG_FOO is specified, but not selected, the whole block
- *      will be omitted, including oldinstr.
- */
-#define ALTERNATIVE(oldinstr, newinstr, ...)   \
-       _ALTERNATIVE_CFG(oldinstr, newinstr, __VA_ARGS__, 1)
-
+#endif /* __ASSEMBLY__ */
 #endif /* __ASM_ALTERNATIVE_H */
index f68a0e64482a1eb2acceb89a000b517175aba6d4..9990059be1060f9bcad459dcafdcc19444801514 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef __ASM_ASM_UACCESS_H
 #define __ASM_ASM_UACCESS_H
 
-#include <asm/alternative.h>
+#include <asm/alternative-macros.h>
 #include <asm/kernel-pgtable.h>
 #include <asm/mmu.h>
 #include <asm/sysreg.h>
        .macro  __uaccess_ttbr0_disable, tmp1
        mrs     \tmp1, ttbr1_el1                        // swapper_pg_dir
        bic     \tmp1, \tmp1, #TTBR_ASID_MASK
-       sub     \tmp1, \tmp1, #RESERVED_TTBR0_SIZE      // reserved_ttbr0 just before swapper_pg_dir
+       sub     \tmp1, \tmp1, #PAGE_SIZE                // reserved_pg_dir just before swapper_pg_dir
        msr     ttbr0_el1, \tmp1                        // set reserved TTBR0_EL1
        isb
-       add     \tmp1, \tmp1, #RESERVED_TTBR0_SIZE
+       add     \tmp1, \tmp1, #PAGE_SIZE
        msr     ttbr1_el1, \tmp1                // set reserved ASID
        isb
        .endm
@@ -58,4 +58,33 @@ alternative_else_nop_endif
        .endm
 #endif
 
+/*
+ * Generate the assembly for LDTR/STTR with exception table entries.
+ * This is complicated as there is no post-increment or pair versions of the
+ * unprivileged instructions, and USER() only works for single instructions.
+ */
+       .macro user_ldp l, reg1, reg2, addr, post_inc
+8888:          ldtr    \reg1, [\addr];
+8889:          ldtr    \reg2, [\addr, #8];
+               add     \addr, \addr, \post_inc;
+
+               _asm_extable    8888b,\l;
+               _asm_extable    8889b,\l;
+       .endm
+
+       .macro user_stp l, reg1, reg2, addr, post_inc
+8888:          sttr    \reg1, [\addr];
+8889:          sttr    \reg2, [\addr, #8];
+               add     \addr, \addr, \post_inc;
+
+               _asm_extable    8888b,\l;
+               _asm_extable    8889b,\l;
+       .endm
+
+       .macro user_ldst l, inst, reg, addr, post_inc
+8888:          \inst           \reg, [\addr];
+               add             \addr, \addr, \post_inc;
+
+               _asm_extable    8888b,\l;
+       .endm
 #endif
index e7d98997c09c3058dd0656af26528ebd220cd2bc..a7242ef2a2cd6581e72eac43fef38ba3e44a3848 100644 (file)
@@ -16,8 +16,6 @@
 #define ARM64_WORKAROUND_CAVIUM_23154          6
 #define ARM64_WORKAROUND_834220                        7
 #define ARM64_HAS_NO_HW_PREFETCH               8
-#define ARM64_HAS_UAO                          9
-#define ARM64_ALT_PAN_NOT_UAO                  10
 #define ARM64_HAS_VIRT_HOST_EXTN               11
 #define ARM64_WORKAROUND_CAVIUM_27456          12
 #define ARM64_HAS_32BIT_EL0                    13
@@ -66,7 +64,8 @@
 #define ARM64_HAS_TLB_RANGE                    56
 #define ARM64_MTE                              57
 #define ARM64_WORKAROUND_1508412               58
+#define ARM64_HAS_LDAPR                                59
 
-#define ARM64_NCAPS                            59
+#define ARM64_NCAPS                            60
 
 #endif /* __ASM_CPUCAPS_H */
index c59c16a6ea8b69c29f03e04e8be9e650050ee6fa..1c406e8ae27eb62b4b9b0b46f9313bfef76a857c 100644 (file)
@@ -377,6 +377,23 @@ cpucap_multi_entry_cap_matches(const struct arm64_cpu_capabilities *entry,
        return false;
 }
 
+static __always_inline bool is_vhe_hyp_code(void)
+{
+       /* Only defined for code run in VHE hyp context */
+       return __is_defined(__KVM_VHE_HYPERVISOR__);
+}
+
+static __always_inline bool is_nvhe_hyp_code(void)
+{
+       /* Only defined for code run in NVHE hyp context */
+       return __is_defined(__KVM_NVHE_HYPERVISOR__);
+}
+
+static __always_inline bool is_hyp_code(void)
+{
+       return is_vhe_hyp_code() || is_nvhe_hyp_code();
+}
+
 extern DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
 extern struct static_key_false cpu_hwcap_keys[ARM64_NCAPS];
 extern struct static_key_false arm64_const_caps_ready;
@@ -430,35 +447,40 @@ static __always_inline bool __cpus_have_const_cap(int num)
 }
 
 /*
- * Test for a capability, possibly with a runtime check.
+ * Test for a capability without a runtime check.
  *
- * Before capabilities are finalized, this behaves as cpus_have_cap().
+ * Before capabilities are finalized, this will BUG().
  * After capabilities are finalized, this is patched to avoid a runtime check.
  *
  * @num must be a compile-time constant.
  */
-static __always_inline bool cpus_have_const_cap(int num)
+static __always_inline bool cpus_have_final_cap(int num)
 {
        if (system_capabilities_finalized())
                return __cpus_have_const_cap(num);
        else
-               return cpus_have_cap(num);
+               BUG();
 }
 
 /*
- * Test for a capability without a runtime check.
+ * Test for a capability, possibly with a runtime check for non-hyp code.
  *
- * Before capabilities are finalized, this will BUG().
+ * For hyp code, this behaves the same as cpus_have_final_cap().
+ *
+ * For non-hyp code:
+ * Before capabilities are finalized, this behaves as cpus_have_cap().
  * After capabilities are finalized, this is patched to avoid a runtime check.
  *
  * @num must be a compile-time constant.
  */
-static __always_inline bool cpus_have_final_cap(int num)
+static __always_inline bool cpus_have_const_cap(int num)
 {
-       if (system_capabilities_finalized())
+       if (is_hyp_code())
+               return cpus_have_final_cap(num);
+       else if (system_capabilities_finalized())
                return __cpus_have_const_cap(num);
        else
-               BUG();
+               return cpus_have_cap(num);
 }
 
 static inline void cpus_set_cap(unsigned int num)
@@ -647,10 +669,16 @@ static __always_inline bool system_supports_fpsimd(void)
        return !cpus_have_const_cap(ARM64_HAS_NO_FPSIMD);
 }
 
+static inline bool system_uses_hw_pan(void)
+{
+       return IS_ENABLED(CONFIG_ARM64_PAN) &&
+               cpus_have_const_cap(ARM64_HAS_PAN);
+}
+
 static inline bool system_uses_ttbr0_pan(void)
 {
        return IS_ENABLED(CONFIG_ARM64_SW_TTBR0_PAN) &&
-               !cpus_have_const_cap(ARM64_HAS_PAN);
+               !system_uses_hw_pan();
 }
 
 static __always_inline bool system_supports_sve(void)
@@ -742,11 +770,26 @@ static inline bool cpu_has_hw_af(void)
                                                ID_AA64MMFR1_HADBS_SHIFT);
 }
 
+static inline bool cpu_has_pan(void)
+{
+       u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1);
+       return cpuid_feature_extract_unsigned_field(mmfr1,
+                                                   ID_AA64MMFR1_PAN_SHIFT);
+}
+
 #ifdef CONFIG_ARM64_AMU_EXTN
 /* Check whether the cpu supports the Activity Monitors Unit (AMU) */
 extern bool cpu_has_amu_feat(int cpu);
+#else
+static inline bool cpu_has_amu_feat(int cpu)
+{
+       return false;
+}
 #endif
 
+/* Get a cpu that supports the Activity Monitors Unit (AMU) */
+extern int get_cpu_with_amu_feat(void);
+
 static inline unsigned int get_vmid_bits(u64 mmfr1)
 {
        int vmid_bits;
index 0756191f44f644b9a3153dd584cda74ecc75dd4e..78537393b6506be7ff4d6fdc112843a6aa9b1733 100644 (file)
@@ -37,7 +37,7 @@ asmlinkage void enter_from_user_mode(void);
 asmlinkage void exit_to_user_mode(void);
 void arm64_enter_nmi(struct pt_regs *regs);
 void arm64_exit_nmi(struct pt_regs *regs);
-void do_mem_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs);
+void do_mem_abort(unsigned long far, unsigned int esr, struct pt_regs *regs);
 void do_undefinstr(struct pt_regs *regs);
 void do_bti(struct pt_regs *regs);
 asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr);
index 1aae6f9962fc1604e0f11ce8797eb7abc2e1bcfb..9a1c22ce664b518ad5c6dbb32e59291b4836e540 100644 (file)
@@ -10,6 +10,5 @@
 #include <linux/sched.h>
 
 extern unsigned long arch_align_stack(unsigned long sp);
-void uao_thread_switch(struct task_struct *next);
 
 #endif /* __ASM_EXEC_H */
index 97f6a63810ecbf7a8d803b6eaaba3b4884a2bd3f..8e41faa37c691cdcc35eb658ca4f4005d6c74698 100644 (file)
@@ -16,7 +16,7 @@
 do {                                                                   \
        unsigned int loops = FUTEX_MAX_LOOPS;                           \
                                                                        \
-       uaccess_enable();                                               \
+       uaccess_enable_privileged();                                    \
        asm volatile(                                                   \
 "      prfm    pstl1strm, %2\n"                                        \
 "1:    ldxr    %w1, %2\n"                                              \
@@ -39,7 +39,7 @@ do {                                                                  \
          "+r" (loops)                                                  \
        : "r" (oparg), "Ir" (-EFAULT), "Ir" (-EAGAIN)                   \
        : "memory");                                                    \
-       uaccess_disable();                                              \
+       uaccess_disable_privileged();                                   \
 } while (0)
 
 static inline int
@@ -95,7 +95,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
                return -EFAULT;
 
        uaddr = __uaccess_mask_ptr(_uaddr);
-       uaccess_enable();
+       uaccess_enable_privileged();
        asm volatile("// futex_atomic_cmpxchg_inatomic\n"
 "      prfm    pstl1strm, %2\n"
 "1:    ldxr    %w1, %2\n"
@@ -118,7 +118,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr,
        : "+r" (ret), "=&r" (val), "+Q" (*uaddr), "=&r" (tmp), "+r" (loops)
        : "r" (oldval), "r" (newval), "Ir" (-EFAULT), "Ir" (-EAGAIN)
        : "memory");
-       uaccess_disable();
+       uaccess_disable_privileged();
 
        if (!ret)
                *uval = val;
index 4b39293d0f72dddb809c734aace5df8f80fdc669..4ebb9c054cccd7fa9c70a47d3065dad6de0842ca 100644 (file)
@@ -10,8 +10,7 @@
 #include <linux/build_bug.h>
 #include <linux/types.h>
 
-/* A64 instructions are always 32 bits. */
-#define        AARCH64_INSN_SIZE               4
+#include <asm/alternative.h>
 
 #ifndef __ASSEMBLY__
 /*
index 19ca76ea60d98ae6338b677988dc4ccc5cda6b15..587c504a4c8b2d5162a23c566283e6b019d60dff 100644 (file)
 #define INIT_DIR_SIZE (PAGE_SIZE * EARLY_PAGES(KIMAGE_VADDR, _end))
 #define IDMAP_DIR_SIZE         (IDMAP_PGTABLE_LEVELS * PAGE_SIZE)
 
-#ifdef CONFIG_ARM64_SW_TTBR0_PAN
-#define RESERVED_TTBR0_SIZE    (PAGE_SIZE)
-#else
-#define RESERVED_TTBR0_SIZE    (0)
-#endif
-
 /* Initial memory map size */
 #if ARM64_SWAPPER_USES_SECTION_MAPS
 #define SWAPPER_BLOCK_SHIFT    SECTION_SHIFT
index 8699ce30f587ec39ea7cda4cd6a3630f947de1ca..5d38ff4a48062ad5963c0236201d044d2c8c0482 100644 (file)
@@ -28,18 +28,11 @@ struct prev_kprobe {
        unsigned int status;
 };
 
-/* Single step context for kprobe */
-struct kprobe_step_ctx {
-       unsigned long ss_pending;
-       unsigned long match_addr;
-};
-
 /* per-cpu kprobe control block */
 struct kprobe_ctlblk {
        unsigned int kprobe_status;
        unsigned long saved_irqflag;
        struct prev_kprobe prev_kprobe;
-       struct kprobe_step_ctx ss_ctx;
 };
 
 void arch_remove_kprobe(struct kprobe *);
index 0aecbab6a7fb3bfc941f0776d5b31e32ca913195..781d029b8aa857174604cb9d66e00afca6bc0963 100644 (file)
@@ -239,6 +239,7 @@ enum vcpu_sysreg {
 #define cp14_DBGWCR0   (DBGWCR0_EL1 * 2)
 #define cp14_DBGWVR0   (DBGWVR0_EL1 * 2)
 #define cp14_DBGDCCINT (MDCCINT_EL1 * 2)
+#define cp14_DBGVCR    (DBGVCR32_EL2 * 2)
 
 #define NR_COPRO_REGS  (NR_SYS_REGS * 2)
 
index cd61239bae8c25d4a59f7121ba1c34201eb4f79d..556cb2d62b5bb907d66d10dc27d3446268dd7946 100644 (file)
@@ -30,8 +30,8 @@
  * keep a constant PAGE_OFFSET and "fallback" to using the higher end
  * of the VMEMMAP where 52-bit support is not available in hardware.
  */
-#define VMEMMAP_SIZE ((_PAGE_END(VA_BITS_MIN) - PAGE_OFFSET) \
-                       >> (PAGE_SHIFT - STRUCT_PAGE_MAX_SHIFT))
+#define VMEMMAP_SHIFT  (PAGE_SHIFT - STRUCT_PAGE_MAX_SHIFT)
+#define VMEMMAP_SIZE   ((_PAGE_END(VA_BITS_MIN) - PAGE_OFFSET) >> VMEMMAP_SHIFT)
 
 /*
  * PAGE_OFFSET - the virtual address of the start of the linear map, at the
 #define _PAGE_OFFSET(va)       (-(UL(1) << (va)))
 #define PAGE_OFFSET            (_PAGE_OFFSET(VA_BITS))
 #define KIMAGE_VADDR           (MODULES_END)
-#define BPF_JIT_REGION_START   (KASAN_SHADOW_END)
+#define BPF_JIT_REGION_START   (_PAGE_END(VA_BITS_MIN))
 #define BPF_JIT_REGION_SIZE    (SZ_128M)
 #define BPF_JIT_REGION_END     (BPF_JIT_REGION_START + BPF_JIT_REGION_SIZE)
 #define MODULES_END            (MODULES_VADDR + MODULES_VSIZE)
 #define MODULES_VADDR          (BPF_JIT_REGION_END)
 #define MODULES_VSIZE          (SZ_128M)
-#define VMEMMAP_START          (-VMEMMAP_SIZE - SZ_2M)
+#define VMEMMAP_START          (-(UL(1) << (VA_BITS - VMEMMAP_SHIFT)))
 #define VMEMMAP_END            (VMEMMAP_START + VMEMMAP_SIZE)
-#define PCI_IO_END             (VMEMMAP_START - SZ_2M)
+#define PCI_IO_END             (VMEMMAP_START - SZ_8M)
 #define PCI_IO_START           (PCI_IO_END - PCI_IO_SIZE)
-#define FIXADDR_TOP            (PCI_IO_START - SZ_2M)
+#define FIXADDR_TOP            (VMEMMAP_START - SZ_32M)
 
 #if VA_BITS > 48
 #define VA_BITS_MIN            (48)
 #define KASAN_SHADOW_OFFSET    _AC(CONFIG_KASAN_SHADOW_OFFSET, UL)
 #define KASAN_SHADOW_END       ((UL(1) << (64 - KASAN_SHADOW_SCALE_SHIFT)) \
                                        + KASAN_SHADOW_OFFSET)
+#define PAGE_END               (KASAN_SHADOW_END - (1UL << (vabits_actual - KASAN_SHADOW_SCALE_SHIFT)))
 #define KASAN_THREAD_SHIFT     1
 #else
 #define KASAN_THREAD_SHIFT     0
-#define KASAN_SHADOW_END       (_PAGE_END(VA_BITS_MIN))
+#define PAGE_END               (_PAGE_END(VA_BITS_MIN))
 #endif /* CONFIG_KASAN */
 
 #define MIN_THREAD_SHIFT       (14 + KASAN_THREAD_SHIFT)
 #include <asm/bug.h>
 
 extern u64                     vabits_actual;
-#define PAGE_END               (_PAGE_END(vabits_actual))
 
 extern s64                     memstart_addr;
 /* PHYS_OFFSET - the physical address of the start of memory. */
@@ -238,11 +238,9 @@ static inline const void *__tag_set(const void *addr, u8 tag)
 
 
 /*
- * The linear kernel range starts at the bottom of the virtual address
- * space. Testing the top bit for the start of the region is a
- * sufficient check and avoids having to worry about the tag.
+ * The linear kernel range starts at the bottom of the virtual address space.
  */
-#define __is_lm_address(addr)  (!(((u64)addr) & BIT(vabits_actual - 1)))
+#define __is_lm_address(addr)  (((u64)(addr) & ~PAGE_OFFSET) < (PAGE_END - PAGE_OFFSET))
 
 #define __lm_to_phys(addr)     (((addr) & ~PAGE_OFFSET) + PHYS_OFFSET)
 #define __kimg_to_phys(addr)   ((addr) - kimage_voffset)
index 0672236e1aeab1e1cc2ebce29672fb471bba842a..5c72c20bd300e1cc964f16a2e124a7f1e9b60d05 100644 (file)
@@ -36,11 +36,11 @@ static inline void contextidr_thread_switch(struct task_struct *next)
 }
 
 /*
- * Set TTBR0 to empty_zero_page. No translations will be possible via TTBR0.
+ * Set TTBR0 to reserved_pg_dir. No translations will be possible via TTBR0.
  */
 static inline void cpu_set_reserved_ttbr0(void)
 {
-       unsigned long ttbr = phys_to_ttbr(__pa_symbol(empty_zero_page));
+       unsigned long ttbr = phys_to_ttbr(__pa_symbol(reserved_pg_dir));
 
        write_sysreg(ttbr, ttbr0_el1);
        isb();
@@ -195,7 +195,7 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
                return;
 
        if (mm == &init_mm)
-               ttbr = __pa_symbol(empty_zero_page);
+               ttbr = __pa_symbol(reserved_pg_dir);
        else
                ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
 
index 01a96d07ae741c58f90b3fc21f04776a449b058d..42442a0ae2ab9b3d37afd3f2cc3ae920c37f76db 100644 (file)
 #define TCR_TBI1               (UL(1) << 38)
 #define TCR_HA                 (UL(1) << 39)
 #define TCR_HD                 (UL(1) << 40)
+#define TCR_TBID1              (UL(1) << 52)
 #define TCR_NFD0               (UL(1) << 53)
 #define TCR_NFD1               (UL(1) << 54)
 #define TCR_E0PD0              (UL(1) << 55)
index 5628289b9d5e60c1c7ebdd490e13711c7ca5f01b..005eb035fbfa7230ba4001211ba45bb19cf9c1e2 100644 (file)
@@ -22,7 +22,7 @@
  *     and fixed mappings
  */
 #define VMALLOC_START          (MODULES_END)
-#define VMALLOC_END            (- PUD_SIZE - VMEMMAP_SIZE - SZ_64K)
+#define VMALLOC_END            (VMEMMAP_START - SZ_256M)
 
 #define vmemmap                        ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
 
@@ -527,6 +527,7 @@ extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
 extern pgd_t idmap_pg_dir[PTRS_PER_PGD];
 extern pgd_t idmap_pg_end[];
 extern pgd_t tramp_pg_dir[PTRS_PER_PGD];
+extern pgd_t reserved_pg_dir[PTRS_PER_PGD];
 
 extern void set_swapper_pgd(pgd_t *pgdp, pgd_t pgd);
 
index fce8cbecd6bc721e2b11aa2666bb947ef8e76fd9..724249f37af5d1ca18c53a124d89a3584d8c7590 100644 (file)
@@ -8,9 +8,6 @@
 #ifndef __ASM_PROCESSOR_H
 #define __ASM_PROCESSOR_H
 
-#define KERNEL_DS              UL(-1)
-#define USER_DS                        ((UL(1) << VA_BITS) - 1)
-
 /*
  * On arm64 systems, unaligned accesses by the CPU are cheap, and so there is
  * no point in shifting all network buffers by 2 bytes just to make some IP
@@ -48,6 +45,7 @@
 
 #define DEFAULT_MAP_WINDOW_64  (UL(1) << VA_BITS_MIN)
 #define TASK_SIZE_64           (UL(1) << vabits_actual)
+#define TASK_SIZE_MAX          (UL(1) << VA_BITS)
 
 #ifdef CONFIG_COMPAT
 #if defined(CONFIG_ARM64_64K_PAGES) && defined(CONFIG_KUSER_HELPERS)
index 28c85b87b8cd471da2b0c3c601578683c033b9eb..e58bca832dfff2e89536e8daceeb23cae73d2160 100644 (file)
 #define CurrentEL_EL1          (1 << 2)
 #define CurrentEL_EL2          (2 << 2)
 
+#define INIT_PSTATE_EL1 \
+       (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | PSR_MODE_EL1h)
+#define INIT_PSTATE_EL2 \
+       (PSR_D_BIT | PSR_A_BIT | PSR_I_BIT | PSR_F_BIT | PSR_MODE_EL2h)
+
 /*
  * PMR values used to mask/unmask interrupts.
  *
@@ -188,8 +193,7 @@ struct pt_regs {
        s32 syscallno;
        u32 unused2;
 #endif
-
-       u64 orig_addr_limit;
+       u64 sdei_ttbr1;
        /* Only valid when ARM64_HAS_IRQ_PRIO_MASKING is enabled. */
        u64 pmr_save;
        u64 stackframe[2];
diff --git a/arch/arm64/include/asm/rwonce.h b/arch/arm64/include/asm/rwonce.h
new file mode 100644 (file)
index 0000000..1bce62f
--- /dev/null
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Google LLC.
+ */
+#ifndef __ASM_RWONCE_H
+#define __ASM_RWONCE_H
+
+#ifdef CONFIG_LTO
+
+#include <linux/compiler_types.h>
+#include <asm/alternative-macros.h>
+
+#ifndef BUILD_VDSO
+
+#ifdef CONFIG_AS_HAS_LDAPR
+#define __LOAD_RCPC(sfx, regs...)                                      \
+       ALTERNATIVE(                                                    \
+               "ldar"  #sfx "\t" #regs,                                \
+               ".arch_extension rcpc\n"                                \
+               "ldapr" #sfx "\t" #regs,                                \
+       ARM64_HAS_LDAPR)
+#else
+#define __LOAD_RCPC(sfx, regs...)      "ldar" #sfx "\t" #regs
+#endif /* CONFIG_AS_HAS_LDAPR */
+
+/*
+ * When building with LTO, there is an increased risk of the compiler
+ * converting an address dependency headed by a READ_ONCE() invocation
+ * into a control dependency and consequently allowing for harmful
+ * reordering by the CPU.
+ *
+ * Ensure that such transformations are harmless by overriding the generic
+ * READ_ONCE() definition with one that provides RCpc acquire semantics
+ * when building with LTO.
+ */
+#define __READ_ONCE(x)                                                 \
+({                                                                     \
+       typeof(&(x)) __x = &(x);                                        \
+       int atomic = 1;                                                 \
+       union { __unqual_scalar_typeof(*__x) __val; char __c[1]; } __u; \
+       switch (sizeof(x)) {                                            \
+       case 1:                                                         \
+               asm volatile(__LOAD_RCPC(b, %w0, %1)                    \
+                       : "=r" (*(__u8 *)__u.__c)                       \
+                       : "Q" (*__x) : "memory");                       \
+               break;                                                  \
+       case 2:                                                         \
+               asm volatile(__LOAD_RCPC(h, %w0, %1)                    \
+                       : "=r" (*(__u16 *)__u.__c)                      \
+                       : "Q" (*__x) : "memory");                       \
+               break;                                                  \
+       case 4:                                                         \
+               asm volatile(__LOAD_RCPC(, %w0, %1)                     \
+                       : "=r" (*(__u32 *)__u.__c)                      \
+                       : "Q" (*__x) : "memory");                       \
+               break;                                                  \
+       case 8:                                                         \
+               asm volatile(__LOAD_RCPC(, %0, %1)                      \
+                       : "=r" (*(__u64 *)__u.__c)                      \
+                       : "Q" (*__x) : "memory");                       \
+               break;                                                  \
+       default:                                                        \
+               atomic = 0;                                             \
+       }                                                               \
+       atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\
+})
+
+#endif /* !BUILD_VDSO */
+#endif /* CONFIG_LTO */
+
+#include <asm-generic/rwonce.h>
+
+#endif /* __ASM_RWONCE_H */
diff --git a/arch/arm64/include/asm/signal.h b/arch/arm64/include/asm/signal.h
new file mode 100644 (file)
index 0000000..ef449f5
--- /dev/null
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ARM64_ASM_SIGNAL_H
+#define __ARM64_ASM_SIGNAL_H
+
+#include <asm/memory.h>
+#include <uapi/asm/signal.h>
+#include <uapi/asm/siginfo.h>
+
+static inline void __user *arch_untagged_si_addr(void __user *addr,
+                                                unsigned long sig,
+                                                unsigned long si_code)
+{
+       /*
+        * For historical reasons, all bits of the fault address are exposed as
+        * address bits for watchpoint exceptions. New architectures should
+        * handle the tag bits consistently.
+        */
+       if (sig == SIGTRAP && si_code == TRAP_BRKPT)
+               return addr;
+
+       return untagged_addr(addr);
+}
+#define arch_untagged_si_addr arch_untagged_si_addr
+
+#endif
index c8ab9900293ff6e498df972af685003820dd537f..9e53ca349d2f79366b1ce1902e5bd0bb5392bb66 100644 (file)
 #define SET_PSTATE_SSBS(x)             __emit_inst(0xd500401f | PSTATE_SSBS | ((!!x) << PSTATE_Imm_shift))
 #define SET_PSTATE_TCO(x)              __emit_inst(0xd500401f | PSTATE_TCO | ((!!x) << PSTATE_Imm_shift))
 
+#define set_pstate_pan(x)              asm volatile(SET_PSTATE_PAN(x))
+#define set_pstate_uao(x)              asm volatile(SET_PSTATE_UAO(x))
+#define set_pstate_ssbs(x)             asm volatile(SET_PSTATE_SSBS(x))
+
 #define __SYS_BARRIER_INSN(CRm, op2, Rt) \
        __emit_inst(0xd5000000 | sys_insn(0, 3, 3, (CRm), (op2)) | ((Rt) & 0x1f))
 
 #define ENDIAN_SET_EL2         0
 #endif
 
+#define INIT_SCTLR_EL2_MMU_OFF \
+       (SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
+
 /* SCTLR_EL1 specific flags. */
 #define SCTLR_EL1_ATA0         (BIT(42))
 
 #define ENDIAN_SET_EL1         0
 #endif
 
-#define SCTLR_EL1_SET  (SCTLR_ELx_M    | SCTLR_ELx_C    | SCTLR_ELx_SA   |\
-                        SCTLR_EL1_SA0  | SCTLR_EL1_SED  | SCTLR_ELx_I    |\
-                        SCTLR_EL1_DZE  | SCTLR_EL1_UCT                   |\
-                        SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN |\
-                        SCTLR_ELx_ITFSB| SCTLR_ELx_ATA  | SCTLR_EL1_ATA0 |\
-                        ENDIAN_SET_EL1 | SCTLR_EL1_UCI  | SCTLR_EL1_RES1)
+#define INIT_SCTLR_EL1_MMU_OFF \
+       (ENDIAN_SET_EL1 | SCTLR_EL1_RES1)
+
+#define INIT_SCTLR_EL1_MMU_ON \
+       (SCTLR_ELx_M    | SCTLR_ELx_C    | SCTLR_ELx_SA   | SCTLR_EL1_SA0   | \
+        SCTLR_EL1_SED  | SCTLR_ELx_I    | SCTLR_EL1_DZE  | SCTLR_EL1_UCT   | \
+        SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN | SCTLR_ELx_ITFSB | \
+        SCTLR_ELx_ATA  | SCTLR_EL1_ATA0 | ENDIAN_SET_EL1 | SCTLR_EL1_UCI   | \
+        SCTLR_EL1_RES1)
 
 /* MAIR_ELx memory attributes (used by Linux) */
 #define MAIR_ATTR_DEVICE_nGnRnE                UL(0x00)
index 1ab63cfbbaf178df5b1e73dd832f81661d883f27..673be2d1263c4915d56fe9f2e9af61646f1a5f1d 100644 (file)
@@ -22,7 +22,7 @@ void die(const char *msg, struct pt_regs *regs, int err);
 
 struct siginfo;
 void arm64_notify_die(const char *str, struct pt_regs *regs,
-                     int signo, int sicode, void __user *addr,
+                     int signo, int sicode, unsigned long far,
                      int err);
 
 void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned int,
index 1fbab854a51b0ee5872b9f23991c3f0ae72fb9b3..015beafe58f539849554651e013a93e89b25d152 100644 (file)
@@ -18,14 +18,11 @@ struct task_struct;
 #include <asm/stack_pointer.h>
 #include <asm/types.h>
 
-typedef unsigned long mm_segment_t;
-
 /*
  * low level task data that entry.S needs immediate access to.
  */
 struct thread_info {
        unsigned long           flags;          /* low level flags */
-       mm_segment_t            addr_limit;     /* address limit */
 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
        u64                     ttbr0;          /* saved TTBR0_EL1 */
 #endif
@@ -66,8 +63,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define TIF_NOTIFY_RESUME      2       /* callback before returning to user */
 #define TIF_FOREIGN_FPSTATE    3       /* CPU's FP state is not current's */
 #define TIF_UPROBE             4       /* uprobe breakpoint or singlestep */
-#define TIF_FSCHECK            5       /* Check FS is USER_DS on return */
-#define TIF_MTE_ASYNC_FAULT    6       /* MTE Asynchronous Tag Check Fault */
+#define TIF_MTE_ASYNC_FAULT    5       /* MTE Asynchronous Tag Check Fault */
 #define TIF_SYSCALL_TRACE      8       /* syscall trace active */
 #define TIF_SYSCALL_AUDIT      9       /* syscall auditing */
 #define TIF_SYSCALL_TRACEPOINT 10      /* syscall tracepoint for ftrace */
@@ -93,7 +89,6 @@ void arch_release_task_struct(struct task_struct *tsk);
 #define _TIF_SECCOMP           (1 << TIF_SECCOMP)
 #define _TIF_SYSCALL_EMU       (1 << TIF_SYSCALL_EMU)
 #define _TIF_UPROBE            (1 << TIF_UPROBE)
-#define _TIF_FSCHECK           (1 << TIF_FSCHECK)
 #define _TIF_SINGLESTEP                (1 << TIF_SINGLESTEP)
 #define _TIF_32BIT             (1 << TIF_32BIT)
 #define _TIF_SVE               (1 << TIF_SVE)
@@ -101,7 +96,7 @@ void arch_release_task_struct(struct task_struct *tsk);
 
 #define _TIF_WORK_MASK         (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
                                 _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
-                                _TIF_UPROBE | _TIF_FSCHECK | _TIF_MTE_ASYNC_FAULT)
+                                _TIF_UPROBE | _TIF_MTE_ASYNC_FAULT)
 
 #define _TIF_SYSCALL_WORK      (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
                                 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
@@ -119,7 +114,6 @@ void arch_release_task_struct(struct task_struct *tsk);
 {                                                                      \
        .flags          = _TIF_FOREIGN_FPSTATE,                         \
        .preempt_count  = INIT_PREEMPT_COUNT,                           \
-       .addr_limit     = KERNEL_DS,                                    \
        INIT_SCS                                                        \
 }
 
index 11a465243f660a1413026901ea02d00375f3b536..3b8dca4eb08d4138d5301d352178be877511bc29 100644 (file)
@@ -16,12 +16,14 @@ int pcibus_to_node(struct pci_bus *bus);
 
 #include <linux/arch_topology.h>
 
+void update_freq_counters_refs(void);
+void topology_scale_freq_tick(void);
+
 #ifdef CONFIG_ARM64_AMU_EXTN
 /*
  * Replace task scheduler's default counter-based
  * frequency-invariance scale factor setting.
  */
-void topology_scale_freq_tick(void);
 #define arch_scale_freq_tick topology_scale_freq_tick
 #endif /* CONFIG_ARM64_AMU_EXTN */
 
index d96dc2c7c09dab0320b12c0624f68fcd72dd4b8b..54f32a0675dffd81981c066a813d092415be81f7 100644 (file)
@@ -26,9 +26,9 @@ void register_undef_hook(struct undef_hook *hook);
 void unregister_undef_hook(struct undef_hook *hook);
 void force_signal_inject(int signal, int code, unsigned long address, unsigned int err);
 void arm64_notify_segfault(unsigned long addr);
-void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str);
-void arm64_force_sig_mceerr(int code, void __user *addr, short lsb, const char *str);
-void arm64_force_sig_ptrace_errno_trap(int errno, void __user *addr, const char *str);
+void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str);
+void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str);
+void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str);
 
 /*
  * Move regs->pc to next instruction and do necessary setup before it
index 991dd5f031e4613cdfceab311d37aec32ee4d60a..abb31aa1f8cad25a972dd06f30b295773243a15a 100644 (file)
 #include <asm/memory.h>
 #include <asm/extable.h>
 
-#define get_fs()       (current_thread_info()->addr_limit)
-
-static inline void set_fs(mm_segment_t fs)
-{
-       current_thread_info()->addr_limit = fs;
-
-       /*
-        * Prevent a mispredicted conditional call to set_fs from forwarding
-        * the wrong address limit to access_ok under speculation.
-        */
-       spec_bar();
-
-       /* On user-mode return, check fs is correct */
-       set_thread_flag(TIF_FSCHECK);
-
-       /*
-        * Enable/disable UAO so that copy_to_user() etc can access
-        * kernel memory with the unprivileged instructions.
-        */
-       if (IS_ENABLED(CONFIG_ARM64_UAO) && fs == KERNEL_DS)
-               asm(ALTERNATIVE("nop", SET_PSTATE_UAO(1), ARM64_HAS_UAO));
-       else
-               asm(ALTERNATIVE("nop", SET_PSTATE_UAO(0), ARM64_HAS_UAO,
-                               CONFIG_ARM64_UAO));
-}
-
-#define uaccess_kernel()       (get_fs() == KERNEL_DS)
+#define HAVE_GET_KERNEL_NOFAULT
 
 /*
  * Test whether a block of memory is a valid user space address.
  * Returns 1 if the range is valid, 0 otherwise.
  *
  * This is equivalent to the following test:
- * (u65)addr + (u65)size <= (u65)current->addr_limit + 1
+ * (u65)addr + (u65)size <= (u65)TASK_SIZE_MAX
  */
 static inline unsigned long __range_ok(const void __user *addr, unsigned long size)
 {
-       unsigned long ret, limit = current_thread_info()->addr_limit;
+       unsigned long ret, limit = TASK_SIZE_MAX - 1;
 
        /*
         * Asynchronous I/O running in a kernel thread does not have the
@@ -94,7 +68,6 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si
 }
 
 #define access_ok(addr, size)  __range_ok(addr, size)
-#define user_addr_max                  get_fs
 
 #define _ASM_EXTABLE(from, to)                                         \
        "       .pushsection    __ex_table, \"a\"\n"                    \
@@ -113,8 +86,8 @@ static inline void __uaccess_ttbr0_disable(void)
        local_irq_save(flags);
        ttbr = read_sysreg(ttbr1_el1);
        ttbr &= ~TTBR_ASID_MASK;
-       /* reserved_ttbr0 placed before swapper_pg_dir */
-       write_sysreg(ttbr - RESERVED_TTBR0_SIZE, ttbr0_el1);
+       /* reserved_pg_dir placed before swapper_pg_dir */
+       write_sysreg(ttbr - PAGE_SIZE, ttbr0_el1);
        isb();
        /* Set reserved ASID */
        write_sysreg(ttbr, ttbr1_el1);
@@ -186,47 +159,26 @@ static inline void __uaccess_enable_hw_pan(void)
                        CONFIG_ARM64_PAN));
 }
 
-#define __uaccess_disable(alt)                                         \
-do {                                                                   \
-       if (!uaccess_ttbr0_disable())                                   \
-               asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), alt,          \
-                               CONFIG_ARM64_PAN));                     \
-} while (0)
-
-#define __uaccess_enable(alt)                                          \
-do {                                                                   \
-       if (!uaccess_ttbr0_enable())                                    \
-               asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), alt,          \
-                               CONFIG_ARM64_PAN));                     \
-} while (0)
-
-static inline void uaccess_disable(void)
+static inline void uaccess_disable_privileged(void)
 {
-       __uaccess_disable(ARM64_HAS_PAN);
-}
+       if (uaccess_ttbr0_disable())
+               return;
 
-static inline void uaccess_enable(void)
-{
-       __uaccess_enable(ARM64_HAS_PAN);
+       __uaccess_enable_hw_pan();
 }
 
-/*
- * These functions are no-ops when UAO is present.
- */
-static inline void uaccess_disable_not_uao(void)
+static inline void uaccess_enable_privileged(void)
 {
-       __uaccess_disable(ARM64_ALT_PAN_NOT_UAO);
-}
+       if (uaccess_ttbr0_enable())
+               return;
 
-static inline void uaccess_enable_not_uao(void)
-{
-       __uaccess_enable(ARM64_ALT_PAN_NOT_UAO);
+       __uaccess_disable_hw_pan();
 }
 
 /*
- * Sanitise a uaccess pointer such that it becomes NULL if above the
- * current addr_limit. In case the pointer is tagged (has the top byte set),
- * untag the pointer before checking.
+ * Sanitise a uaccess pointer such that it becomes NULL if above the maximum
+ * user address. In case the pointer is tagged (has the top byte set), untag
+ * the pointer before checking.
  */
 #define uaccess_mask_ptr(ptr) (__typeof__(ptr))__uaccess_mask_ptr(ptr)
 static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
@@ -237,7 +189,7 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
        "       bics    xzr, %3, %2\n"
        "       csel    %0, %1, xzr, eq\n"
        : "=&r" (safe_ptr)
-       : "r" (ptr), "r" (current_thread_info()->addr_limit),
+       : "r" (ptr), "r" (TASK_SIZE_MAX - 1),
          "r" (untagged_addr(ptr))
        : "cc");
 
@@ -253,10 +205,9 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
  * The "__xxx_error" versions set the third argument to -EFAULT if an error
  * occurs, and leave it unchanged on success.
  */
-#define __get_user_asm(instr, alt_instr, reg, x, addr, err, feature)   \
+#define __get_mem_asm(load, reg, x, addr, err)                         \
        asm volatile(                                                   \
-       "1:"ALTERNATIVE(instr "     " reg "1, [%2]\n",                  \
-                       alt_instr " " reg "1, [%2]\n", feature)         \
+       "1:     " load "        " reg "1, [%2]\n"                       \
        "2:\n"                                                          \
        "       .section .fixup, \"ax\"\n"                              \
        "       .align  2\n"                                            \
@@ -268,35 +219,36 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr)
        : "+r" (err), "=&r" (x)                                         \
        : "r" (addr), "i" (-EFAULT))
 
-#define __raw_get_user(x, ptr, err)                                    \
+#define __raw_get_mem(ldr, x, ptr, err)                                        \
 do {                                                                   \
        unsigned long __gu_val;                                         \
-       __chk_user_ptr(ptr);                                            \
-       uaccess_enable_not_uao();                                       \
        switch (sizeof(*(ptr))) {                                       \
        case 1:                                                         \
-               __get_user_asm("ldrb", "ldtrb", "%w", __gu_val, (ptr),  \
-                              (err), ARM64_HAS_UAO);                   \
+               __get_mem_asm(ldr "b", "%w", __gu_val, (ptr), (err));   \
                break;                                                  \
        case 2:                                                         \
-               __get_user_asm("ldrh", "ldtrh", "%w", __gu_val, (ptr),  \
-                              (err), ARM64_HAS_UAO);                   \
+               __get_mem_asm(ldr "h", "%w", __gu_val, (ptr), (err));   \
                break;                                                  \
        case 4:                                                         \
-               __get_user_asm("ldr", "ldtr", "%w", __gu_val, (ptr),    \
-                              (err), ARM64_HAS_UAO);                   \
+               __get_mem_asm(ldr, "%w", __gu_val, (ptr), (err));       \
                break;                                                  \
        case 8:                                                         \
-               __get_user_asm("ldr", "ldtr", "%x",  __gu_val, (ptr),   \
-                              (err), ARM64_HAS_UAO);                   \
+               __get_mem_asm(ldr, "%x",  __gu_val, (ptr), (err));      \
                break;                                                  \
        default:                                                        \
                BUILD_BUG();                                            \
        }                                                               \
-       uaccess_disable_not_uao();                                      \
        (x) = (__force __typeof__(*(ptr)))__gu_val;                     \
 } while (0)
 
+#define __raw_get_user(x, ptr, err)                                    \
+do {                                                                   \
+       __chk_user_ptr(ptr);                                            \
+       uaccess_ttbr0_enable();                                         \
+       __raw_get_mem("ldtr", x, ptr, err);                             \
+       uaccess_ttbr0_disable();                                        \
+} while (0)
+
 #define __get_user_error(x, ptr, err)                                  \
 do {                                                                   \
        __typeof__(*(ptr)) __user *__p = (ptr);                         \
@@ -318,10 +270,19 @@ do {                                                                      \
 
 #define get_user       __get_user
 
-#define __put_user_asm(instr, alt_instr, reg, x, addr, err, feature)   \
+#define __get_kernel_nofault(dst, src, type, err_label)                        \
+do {                                                                   \
+       int __gkn_err = 0;                                              \
+                                                                       \
+       __raw_get_mem("ldr", *((type *)(dst)),                          \
+                     (__force type *)(src), __gkn_err);                \
+       if (unlikely(__gkn_err))                                        \
+               goto err_label;                                         \
+} while (0)
+
+#define __put_mem_asm(store, reg, x, addr, err)                                \
        asm volatile(                                                   \
-       "1:"ALTERNATIVE(instr "     " reg "1, [%2]\n",                  \
-                       alt_instr " " reg "1, [%2]\n", feature)         \
+       "1:     " store "       " reg "1, [%2]\n"                       \
        "2:\n"                                                          \
        "       .section .fixup,\"ax\"\n"                               \
        "       .align  2\n"                                            \
@@ -332,32 +293,33 @@ do {                                                                      \
        : "+r" (err)                                                    \
        : "r" (x), "r" (addr), "i" (-EFAULT))
 
-#define __raw_put_user(x, ptr, err)                                    \
+#define __raw_put_mem(str, x, ptr, err)                                        \
 do {                                                                   \
        __typeof__(*(ptr)) __pu_val = (x);                              \
-       __chk_user_ptr(ptr);                                            \
-       uaccess_enable_not_uao();                                       \
        switch (sizeof(*(ptr))) {                                       \
        case 1:                                                         \
-               __put_user_asm("strb", "sttrb", "%w", __pu_val, (ptr),  \
-                              (err), ARM64_HAS_UAO);                   \
+               __put_mem_asm(str "b", "%w", __pu_val, (ptr), (err));   \
                break;                                                  \
        case 2:                                                         \
-               __put_user_asm("strh", "sttrh", "%w", __pu_val, (ptr),  \
-                              (err), ARM64_HAS_UAO);                   \
+               __put_mem_asm(str "h", "%w", __pu_val, (ptr), (err));   \
                break;                                                  \
        case 4:                                                         \
-               __put_user_asm("str", "sttr", "%w", __pu_val, (ptr),    \
-                              (err), ARM64_HAS_UAO);                   \
+               __put_mem_asm(str, "%w", __pu_val, (ptr), (err));       \
                break;                                                  \
        case 8:                                                         \
-               __put_user_asm("str", "sttr", "%x", __pu_val, (ptr),    \
-                              (err), ARM64_HAS_UAO);                   \
+               __put_mem_asm(str, "%x", __pu_val, (ptr), (err));       \
                break;                                                  \
        default:                                                        \
                BUILD_BUG();                                            \
        }                                                               \
-       uaccess_disable_not_uao();                                      \
+} while (0)
+
+#define __raw_put_user(x, ptr, err)                                    \
+do {                                                                   \
+       __chk_user_ptr(ptr);                                            \
+       uaccess_ttbr0_enable();                                         \
+       __raw_put_mem("sttr", x, ptr, err);                             \
+       uaccess_ttbr0_disable();                                        \
 } while (0)
 
 #define __put_user_error(x, ptr, err)                                  \
@@ -381,14 +343,24 @@ do {                                                                      \
 
 #define put_user       __put_user
 
+#define __put_kernel_nofault(dst, src, type, err_label)                        \
+do {                                                                   \
+       int __pkn_err = 0;                                              \
+                                                                       \
+       __raw_put_mem("str", *((type *)(src)),                          \
+                     (__force type *)(dst), __pkn_err);                \
+       if (unlikely(__pkn_err))                                        \
+               goto err_label;                                         \
+} while(0)
+
 extern unsigned long __must_check __arch_copy_from_user(void *to, const void __user *from, unsigned long n);
 #define raw_copy_from_user(to, from, n)                                        \
 ({                                                                     \
        unsigned long __acfu_ret;                                       \
-       uaccess_enable_not_uao();                                       \
+       uaccess_ttbr0_enable();                                         \
        __acfu_ret = __arch_copy_from_user((to),                        \
                                      __uaccess_mask_ptr(from), (n));   \
-       uaccess_disable_not_uao();                                      \
+       uaccess_ttbr0_disable();                                        \
        __acfu_ret;                                                     \
 })
 
@@ -396,10 +368,10 @@ extern unsigned long __must_check __arch_copy_to_user(void __user *to, const voi
 #define raw_copy_to_user(to, from, n)                                  \
 ({                                                                     \
        unsigned long __actu_ret;                                       \
-       uaccess_enable_not_uao();                                       \
+       uaccess_ttbr0_enable();                                         \
        __actu_ret = __arch_copy_to_user(__uaccess_mask_ptr(to),        \
                                    (from), (n));                       \
-       uaccess_disable_not_uao();                                      \
+       uaccess_ttbr0_disable();                                        \
        __actu_ret;                                                     \
 })
 
@@ -407,10 +379,10 @@ extern unsigned long __must_check __arch_copy_in_user(void __user *to, const voi
 #define raw_copy_in_user(to, from, n)                                  \
 ({                                                                     \
        unsigned long __aciu_ret;                                       \
-       uaccess_enable_not_uao();                                       \
+       uaccess_ttbr0_enable();                                         \
        __aciu_ret = __arch_copy_in_user(__uaccess_mask_ptr(to),        \
                                    __uaccess_mask_ptr(from), (n));     \
-       uaccess_disable_not_uao();                                      \
+       uaccess_ttbr0_disable();                                        \
        __aciu_ret;                                                     \
 })
 
@@ -421,9 +393,9 @@ extern unsigned long __must_check __arch_clear_user(void __user *to, unsigned lo
 static inline unsigned long __must_check __clear_user(void __user *to, unsigned long n)
 {
        if (access_ok(to, n)) {
-               uaccess_enable_not_uao();
+               uaccess_ttbr0_enable();
                n = __arch_clear_user(__uaccess_mask_ptr(to), n);
-               uaccess_disable_not_uao();
+               uaccess_ttbr0_disable();
        }
        return n;
 }
index 09977acc007d1562c53ad74c6d0da3d32558a1cd..6069be50baf9fba2d5a05c5e0893b08b2b6a03f8 100644 (file)
@@ -86,13 +86,12 @@ static inline bool is_kernel_in_hyp_mode(void)
 static __always_inline bool has_vhe(void)
 {
        /*
-        * The following macros are defined for code specic to VHE/nVHE.
-        * If has_vhe() is inlined into those compilation units, it can
-        * be determined statically. Otherwise fall back to caps.
+        * Code only run in VHE/NVHE hyp context can assume VHE is present or
+        * absent. Otherwise fall back to caps.
         */
-       if (__is_defined(__KVM_VHE_HYPERVISOR__))
+       if (is_vhe_hyp_code())
                return true;
-       else if (__is_defined(__KVM_NVHE_HYPERVISOR__))
+       else if (is_nvhe_hyp_code())
                return false;
        else
                return cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN);
index bbaf0bc4ad60966ea35a730aa5a746355fdcf424..86364ab6f13fdfdce67beb1ba26798faee36f94e 100644 (file)
@@ -58,7 +58,6 @@ obj-$(CONFIG_CRASH_DUMP)              += crash_dump.o
 obj-$(CONFIG_CRASH_CORE)               += crash_core.o
 obj-$(CONFIG_ARM_SDE_INTERFACE)                += sdei.o
 obj-$(CONFIG_ARM64_PTR_AUTH)           += pointer_auth.o
-obj-$(CONFIG_SHADOW_CALL_STACK)                += scs.o
 obj-$(CONFIG_ARM64_MTE)                        += mte.o
 
 obj-y                                  += vdso/ probes/
index 73039949b5ce2f6227f11d0d1591967c38bda8f6..a57cffb752e8955b8b9b9dbc144f632dead81402 100644 (file)
@@ -21,7 +21,8 @@
 #define ALT_ORIG_PTR(a)                __ALT_PTR(a, orig_offset)
 #define ALT_REPL_PTR(a)                __ALT_PTR(a, alt_offset)
 
-static int all_alternatives_applied;
+/* Volatile, as we may be patching the guts of READ_ONCE() */
+static volatile int all_alternatives_applied;
 
 static DECLARE_BITMAP(applied_alternatives, ARM64_NCAPS);
 
@@ -205,7 +206,7 @@ static int __apply_alternatives_multi_stop(void *unused)
 
        /* We always have a CPU 0 at this point (__init) */
        if (smp_processor_id()) {
-               while (!READ_ONCE(all_alternatives_applied))
+               while (!all_alternatives_applied)
                        cpu_relax();
                isb();
        } else {
@@ -217,7 +218,7 @@ static int __apply_alternatives_multi_stop(void *unused)
                BUG_ON(all_alternatives_applied);
                __apply_alternatives(&region, false, remaining_capabilities);
                /* Barriers provided by the cache flushing */
-               WRITE_ONCE(all_alternatives_applied, 1);
+               all_alternatives_applied = 1;
        }
 
        return 0;
index 7364de008bab395762358fdfddf5aa8d8e2c13c5..0e86e8b9ceddf246a459d48cacbc0ac421faa4a8 100644 (file)
@@ -277,7 +277,7 @@ static void __init register_insn_emulation_sysctl(void)
 
 #define __user_swpX_asm(data, addr, res, temp, temp2, B)       \
 do {                                                           \
-       uaccess_enable();                                       \
+       uaccess_enable_privileged();                            \
        __asm__ __volatile__(                                   \
        "       mov             %w3, %w7\n"                     \
        "0:     ldxr"B"         %w2, [%4]\n"                    \
@@ -302,7 +302,7 @@ do {                                                                \
          "i" (-EFAULT),                                        \
          "i" (__SWP_LL_SC_LOOPS)                               \
        : "memory");                                            \
-       uaccess_disable();                                      \
+       uaccess_disable_privileged();                           \
 } while (0)
 
 #define __user_swp_asm(data, addr, res, temp, temp2) \
index 7d32fc959b1a071a0eefb2efe666b2dd1dbbe057..679b19b8a7ff23a98b35b200ba24590aaf3fc2da 100644 (file)
@@ -30,7 +30,6 @@ int main(void)
   BLANK();
   DEFINE(TSK_TI_FLAGS,         offsetof(struct task_struct, thread_info.flags));
   DEFINE(TSK_TI_PREEMPT,       offsetof(struct task_struct, thread_info.preempt_count));
-  DEFINE(TSK_TI_ADDR_LIMIT,    offsetof(struct task_struct, thread_info.addr_limit));
 #ifdef CONFIG_ARM64_SW_TTBR0_PAN
   DEFINE(TSK_TI_TTBR0,         offsetof(struct task_struct, thread_info.ttbr0));
 #endif
@@ -70,7 +69,7 @@ int main(void)
   DEFINE(S_PSTATE,             offsetof(struct pt_regs, pstate));
   DEFINE(S_PC,                 offsetof(struct pt_regs, pc));
   DEFINE(S_SYSCALLNO,          offsetof(struct pt_regs, syscallno));
-  DEFINE(S_ORIG_ADDR_LIMIT,    offsetof(struct pt_regs, orig_addr_limit));
+  DEFINE(S_SDEI_TTBR1,         offsetof(struct pt_regs, sdei_ttbr1));
   DEFINE(S_PMR_SAVE,           offsetof(struct pt_regs, pmr_save));
   DEFINE(S_STACKFRAME,         offsetof(struct pt_regs, stackframe));
   DEFINE(S_FRAME_SIZE,         sizeof(struct pt_regs));
index 6f36c4f62f6945f1e74323b4987f4e2684445dcd..39138f6d3ba2b290c37735b06e51fd2cf7be66f5 100644 (file)
@@ -153,10 +153,6 @@ EXPORT_SYMBOL(cpu_hwcap_keys);
                .width = 0,                             \
        }
 
-/* meta feature for alternatives */
-static bool __maybe_unused
-cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused);
-
 static void cpu_enable_cnp(struct arm64_cpu_capabilities const *cap);
 
 static bool __system_matches_cap(unsigned int n);
@@ -1528,8 +1524,10 @@ bool cpu_has_amu_feat(int cpu)
        return cpumask_test_cpu(cpu, &amu_cpus);
 }
 
-/* Initialize the use of AMU counters for frequency invariance */
-extern void init_cpu_freq_invariance_counters(void);
+int get_cpu_with_amu_feat(void)
+{
+       return cpumask_any(&amu_cpus);
+}
 
 static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
 {
@@ -1537,7 +1535,7 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap)
                pr_info("detected CPU%d: Activity Monitors Unit (AMU)\n",
                        smp_processor_id());
                cpumask_set_cpu(smp_processor_id(), &amu_cpus);
-               init_cpu_freq_invariance_counters();
+               update_freq_counters_refs();
        }
 }
 
@@ -1559,6 +1557,11 @@ static bool has_amu(const struct arm64_cpu_capabilities *cap,
 
        return true;
 }
+#else
+int get_cpu_with_amu_feat(void)
+{
+       return nr_cpu_ids;
+}
 #endif
 
 #ifdef CONFIG_ARM64_VHE
@@ -1600,7 +1603,7 @@ static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
        WARN_ON_ONCE(in_interrupt());
 
        sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0);
-       asm(SET_PSTATE_PAN(1));
+       set_pstate_pan(1);
 }
 #endif /* CONFIG_ARM64_PAN */
 
@@ -1770,28 +1773,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
                .matches = has_no_hw_prefetch,
        },
-#ifdef CONFIG_ARM64_UAO
-       {
-               .desc = "User Access Override",
-               .capability = ARM64_HAS_UAO,
-               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
-               .matches = has_cpuid_feature,
-               .sys_reg = SYS_ID_AA64MMFR2_EL1,
-               .field_pos = ID_AA64MMFR2_UAO_SHIFT,
-               .min_field_value = 1,
-               /*
-                * We rely on stop_machine() calling uao_thread_switch() to set
-                * UAO immediately after patching.
-                */
-       },
-#endif /* CONFIG_ARM64_UAO */
-#ifdef CONFIG_ARM64_PAN
-       {
-               .capability = ARM64_ALT_PAN_NOT_UAO,
-               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
-               .matches = cpufeature_pan_not_uao,
-       },
-#endif /* CONFIG_ARM64_PAN */
 #ifdef CONFIG_ARM64_VHE
        {
                .desc = "Virtualization Host Extensions",
@@ -2138,6 +2119,16 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .cpu_enable = cpu_enable_mte,
        },
 #endif /* CONFIG_ARM64_MTE */
+       {
+               .desc = "RCpc load-acquire (LDAPR)",
+               .capability = ARM64_HAS_LDAPR,
+               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
+               .sys_reg = SYS_ID_AA64ISAR1_EL1,
+               .sign = FTR_UNSIGNED,
+               .field_pos = ID_AA64ISAR1_LRCPC_SHIFT,
+               .matches = has_cpuid_feature,
+               .min_field_value = 1,
+       },
        {},
 };
 
@@ -2652,7 +2643,7 @@ bool this_cpu_has_cap(unsigned int n)
  * - The SYSTEM_FEATURE cpu_hwcaps may not have been set.
  * In all other cases cpus_have_{const_}cap() should be used.
  */
-static bool __system_matches_cap(unsigned int n)
+static bool __maybe_unused __system_matches_cap(unsigned int n)
 {
        if (n < ARM64_NCAPS) {
                const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n];
@@ -2732,12 +2723,6 @@ void __init setup_cpu_features(void)
                        ARCH_DMA_MINALIGN);
 }
 
-static bool __maybe_unused
-cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused)
-{
-       return (__system_matches_cap(ARM64_HAS_PAN) && !__system_matches_cap(ARM64_HAS_UAO));
-}
-
 static void __maybe_unused cpu_enable_cnp(struct arm64_cpu_capabilities const *cap)
 {
        cpu_replace_ttbr1(lm_alias(swapper_pg_dir));
index fa76151de6ff148372963f91521af354931fc115..4f3661eeb7ec6f28873cccf4411ec649c2475815 100644 (file)
@@ -234,9 +234,8 @@ static void send_user_sigtrap(int si_code)
        if (interrupts_enabled(regs))
                local_irq_enable();
 
-       arm64_force_sig_fault(SIGTRAP, si_code,
-                            (void __user *)instruction_pointer(regs),
-                            "User debug trap");
+       arm64_force_sig_fault(SIGTRAP, si_code, instruction_pointer(regs),
+                             "User debug trap");
 }
 
 static int single_step_handler(unsigned long unused, unsigned int esr,
index a71844fb923eef9669bd23b087b752c214b8a763..28d8a5dca5f129784b158589a3c4c1d231ffd6e9 100644 (file)
@@ -7,30 +7,48 @@
 #include <linux/pe.h>
 #include <linux/sizes.h>
 
+       .macro  efi_signature_nop
+#ifdef CONFIG_EFI
+.L_head:
+       /*
+        * This ccmp instruction has no meaningful effect except that
+        * its opcode forms the magic "MZ" signature required by UEFI.
+        */
+       ccmp    x18, #0, #0xd, pl
+#else
+       /*
+        * Bootloaders may inspect the opcode at the start of the kernel
+        * image to decide if the kernel is capable of booting via UEFI.
+        * So put an ordinary NOP here, not the "MZ.." pseudo-nop above.
+        */
+       nop
+#endif
+       .endm
+
        .macro  __EFI_PE_HEADER
+#ifdef CONFIG_EFI
+       .set    .Lpe_header_offset, . - .L_head
        .long   PE_MAGIC
-coff_header:
        .short  IMAGE_FILE_MACHINE_ARM64                // Machine
-       .short  section_count                           // NumberOfSections
+       .short  .Lsection_count                         // NumberOfSections
        .long   0                                       // TimeDateStamp
        .long   0                                       // PointerToSymbolTable
        .long   0                                       // NumberOfSymbols
-       .short  section_table - optional_header         // SizeOfOptionalHeader
+       .short  .Lsection_table - .Loptional_header     // SizeOfOptionalHeader
        .short  IMAGE_FILE_DEBUG_STRIPPED | \
                IMAGE_FILE_EXECUTABLE_IMAGE | \
                IMAGE_FILE_LINE_NUMS_STRIPPED           // Characteristics
 
-optional_header:
+.Loptional_header:
        .short  PE_OPT_MAGIC_PE32PLUS                   // PE32+ format
        .byte   0x02                                    // MajorLinkerVersion
        .byte   0x14                                    // MinorLinkerVersion
-       .long   __initdata_begin - efi_header_end       // SizeOfCode
+       .long   __initdata_begin - .Lefi_header_end     // SizeOfCode
        .long   __pecoff_data_size                      // SizeOfInitializedData
        .long   0                                       // SizeOfUninitializedData
-       .long   __efistub_efi_pe_entry - _head          // AddressOfEntryPoint
-       .long   efi_header_end - _head                  // BaseOfCode
+       .long   __efistub_efi_pe_entry - .L_head        // AddressOfEntryPoint
+       .long   .Lefi_header_end - .L_head              // BaseOfCode
 
-extra_header_fields:
        .quad   0                                       // ImageBase
        .long   SEGMENT_ALIGN                           // SectionAlignment
        .long   PECOFF_FILE_ALIGNMENT                   // FileAlignment
@@ -42,10 +60,10 @@ extra_header_fields:
        .short  0                                       // MinorSubsystemVersion
        .long   0                                       // Win32VersionValue
 
-       .long   _end - _head                            // SizeOfImage
+       .long   _end - .L_head                          // SizeOfImage
 
        // Everything before the kernel image is considered part of the header
-       .long   efi_header_end - _head                  // SizeOfHeaders
+       .long   .Lefi_header_end - .L_head              // SizeOfHeaders
        .long   0                                       // CheckSum
        .short  IMAGE_SUBSYSTEM_EFI_APPLICATION         // Subsystem
        .short  0                                       // DllCharacteristics
@@ -54,7 +72,7 @@ extra_header_fields:
        .quad   0                                       // SizeOfHeapReserve
        .quad   0                                       // SizeOfHeapCommit
        .long   0                                       // LoaderFlags
-       .long   (section_table - .) / 8                 // NumberOfRvaAndSizes
+       .long   (.Lsection_table - .) / 8               // NumberOfRvaAndSizes
 
        .quad   0                                       // ExportTable
        .quad   0                                       // ImportTable
@@ -64,17 +82,17 @@ extra_header_fields:
        .quad   0                                       // BaseRelocationTable
 
 #ifdef CONFIG_DEBUG_EFI
-       .long   efi_debug_table - _head                 // DebugTable
-       .long   efi_debug_table_size
+       .long   .Lefi_debug_table - .L_head             // DebugTable
+       .long   .Lefi_debug_table_size
 #endif
 
        // Section table
-section_table:
+.Lsection_table:
        .ascii  ".text\0\0\0"
-       .long   __initdata_begin - efi_header_end       // VirtualSize
-       .long   efi_header_end - _head                  // VirtualAddress
-       .long   __initdata_begin - efi_header_end       // SizeOfRawData
-       .long   efi_header_end - _head                  // PointerToRawData
+       .long   __initdata_begin - .Lefi_header_end     // VirtualSize
+       .long   .Lefi_header_end - .L_head              // VirtualAddress
+       .long   __initdata_begin - .Lefi_header_end     // SizeOfRawData
+       .long   .Lefi_header_end - .L_head              // PointerToRawData
 
        .long   0                                       // PointerToRelocations
        .long   0                                       // PointerToLineNumbers
@@ -86,9 +104,9 @@ section_table:
 
        .ascii  ".data\0\0\0"
        .long   __pecoff_data_size                      // VirtualSize
-       .long   __initdata_begin - _head                // VirtualAddress
+       .long   __initdata_begin - .L_head              // VirtualAddress
        .long   __pecoff_data_rawsize                   // SizeOfRawData
-       .long   __initdata_begin - _head                // PointerToRawData
+       .long   __initdata_begin - .L_head              // PointerToRawData
 
        .long   0                                       // PointerToRelocations
        .long   0                                       // PointerToLineNumbers
@@ -98,7 +116,7 @@ section_table:
                IMAGE_SCN_MEM_READ | \
                IMAGE_SCN_MEM_WRITE                     // Characteristics
 
-       .set    section_count, (. - section_table) / 40
+       .set    .Lsection_count, (. - .Lsection_table) / 40
 
 #ifdef CONFIG_DEBUG_EFI
        /*
@@ -114,21 +132,21 @@ section_table:
        __INITRODATA
 
        .align  2
-efi_debug_table:
+.Lefi_debug_table:
        // EFI_IMAGE_DEBUG_DIRECTORY_ENTRY
        .long   0                                       // Characteristics
        .long   0                                       // TimeDateStamp
        .short  0                                       // MajorVersion
        .short  0                                       // MinorVersion
        .long   IMAGE_DEBUG_TYPE_CODEVIEW               // Type
-       .long   efi_debug_entry_size                    // SizeOfData
+       .long   .Lefi_debug_entry_size                  // SizeOfData
        .long   0                                       // RVA
-       .long   efi_debug_entry - _head                 // FileOffset
+       .long   .Lefi_debug_entry - .L_head             // FileOffset
 
-       .set    efi_debug_table_size, . - efi_debug_table
+       .set    .Lefi_debug_table_size, . - .Lefi_debug_table
        .previous
 
-efi_debug_entry:
+.Lefi_debug_entry:
        // EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY
        .ascii  "NB10"                                  // Signature
        .long   0                                       // Unknown
@@ -137,16 +155,12 @@ efi_debug_entry:
 
        .asciz  VMLINUX_PATH
 
-       .set    efi_debug_entry_size, . - efi_debug_entry
+       .set    .Lefi_debug_entry_size, . - .Lefi_debug_entry
 #endif
 
-       /*
-        * EFI will load .text onwards at the 4k section alignment
-        * described in the PE/COFF header. To ensure that instruction
-        * sequences using an adrp and a :lo12: immediate will function
-        * correctly at this alignment, we must ensure that .text is
-        * placed at a 4k boundary in the Image to begin with.
-        */
        .balign SEGMENT_ALIGN
-efi_header_end:
+.Lefi_header_end:
+#else
+       .set    .Lpe_header_offset, 0x0
+#endif
        .endm
index 70e0a7591245d6a1cc1ec07c3e13a3d8e10f95e7..5346953e4382e9424079ad52cffe69f4e83bc6bc 100644 (file)
@@ -115,7 +115,6 @@ static void noinstr el1_abort(struct pt_regs *regs, unsigned long esr)
 
        enter_from_kernel_mode(regs);
        local_daif_inherit(regs);
-       far = untagged_addr(far);
        do_mem_abort(far, esr, regs);
        local_daif_mask();
        exit_to_kernel_mode(regs);
@@ -256,7 +255,6 @@ static void noinstr el0_da(struct pt_regs *regs, unsigned long esr)
 
        enter_from_user_mode();
        local_daif_restore(DAIF_PROCCTX);
-       far = untagged_addr(far);
        do_mem_abort(far, esr, regs);
 }
 
index d72c818b019ca7530569fd810f356ad426f0cdf1..51c76215609966753008b7464e801d29244a6c00 100644 (file)
@@ -216,12 +216,6 @@ alternative_else_nop_endif
        .else
        add     x21, sp, #S_FRAME_SIZE
        get_current_task tsk
-       /* Save the task's original addr_limit and set USER_DS */
-       ldr     x20, [tsk, #TSK_TI_ADDR_LIMIT]
-       str     x20, [sp, #S_ORIG_ADDR_LIMIT]
-       mov     x20, #USER_DS
-       str     x20, [tsk, #TSK_TI_ADDR_LIMIT]
-       /* No need to reset PSTATE.UAO, hardware's already set it to 0 for us */
        .endif /* \el == 0 */
        mrs     x22, elr_el1
        mrs     x23, spsr_el1
@@ -279,12 +273,6 @@ alternative_else_nop_endif
        .macro  kernel_exit, el
        .if     \el != 0
        disable_daif
-
-       /* Restore the task's original addr_limit. */
-       ldr     x20, [sp, #S_ORIG_ADDR_LIMIT]
-       str     x20, [tsk, #TSK_TI_ADDR_LIMIT]
-
-       /* No need to restore UAO, it will be restored from SPSR_EL1 */
        .endif
 
        /* Restore pmr */
@@ -438,7 +426,7 @@ SYM_CODE_END(__swpan_exit_el0)
 
 #ifdef CONFIG_SHADOW_CALL_STACK
        /* also switch to the irq shadow stack */
-       adr_this_cpu scs_sp, irq_shadow_call_stack, x26
+       ldr_this_cpu scs_sp, irq_shadow_call_stack_ptr, x26
 #endif
 
 9998:
@@ -773,9 +761,10 @@ SYM_CODE_END(ret_to_user)
  */
        .pushsection ".entry.tramp.text", "ax"
 
+       // Move from tramp_pg_dir to swapper_pg_dir
        .macro tramp_map_kernel, tmp
        mrs     \tmp, ttbr1_el1
-       add     \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE)
+       add     \tmp, \tmp, #(2 * PAGE_SIZE)
        bic     \tmp, \tmp, #USER_ASID_FLAG
        msr     ttbr1_el1, \tmp
 #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003
@@ -792,9 +781,10 @@ alternative_else_nop_endif
 #endif /* CONFIG_QCOM_FALKOR_ERRATUM_1003 */
        .endm
 
+       // Move from swapper_pg_dir to tramp_pg_dir
        .macro tramp_unmap_kernel, tmp
        mrs     \tmp, ttbr1_el1
-       sub     \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE)
+       sub     \tmp, \tmp, #(2 * PAGE_SIZE)
        orr     \tmp, \tmp, #USER_ASID_FLAG
        msr     ttbr1_el1, \tmp
        /*
@@ -965,10 +955,9 @@ SYM_CODE_START(__sdei_asm_entry_trampoline)
        mov     x4, xzr
 
        /*
-        * Use reg->interrupted_regs.addr_limit to remember whether to unmap
-        * the kernel on exit.
+        * Remember whether to unmap the kernel on exit.
         */
-1:     str     x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)]
+1:     str     x4, [x1, #(SDEI_EVENT_INTREGS + S_SDEI_TTBR1)]
 
 #ifdef CONFIG_RANDOMIZE_BASE
        adr     x4, tramp_vectors + PAGE_SIZE
@@ -989,7 +978,7 @@ NOKPROBE(__sdei_asm_entry_trampoline)
  * x4: struct sdei_registered_event argument from registration time.
  */
 SYM_CODE_START(__sdei_asm_exit_trampoline)
-       ldr     x4, [x4, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)]
+       ldr     x4, [x4, #(SDEI_EVENT_INTREGS + S_SDEI_TTBR1)]
        cbnz    x4, 1f
 
        tramp_unmap_kernel      tmp=x4
@@ -1063,9 +1052,9 @@ SYM_CODE_START(__sdei_asm_handler)
 #ifdef CONFIG_SHADOW_CALL_STACK
        /* Use a separate shadow call stack for normal and critical events */
        cbnz    w4, 3f
-       adr_this_cpu dst=scs_sp, sym=sdei_shadow_call_stack_normal, tmp=x6
+       ldr_this_cpu dst=scs_sp, sym=sdei_shadow_call_stack_normal_ptr, tmp=x6
        b       4f
-3:     adr_this_cpu dst=scs_sp, sym=sdei_shadow_call_stack_critical, tmp=x6
+3:     ldr_this_cpu dst=scs_sp, sym=sdei_shadow_call_stack_critical_ptr, tmp=x6
 4:
 #endif
 
index d8d9caf02834e03f3b1da6201cc57b2dbf59eabe..f2eb206920a2ecf7b3fdbebf30c5096b398bbc64 100644 (file)
  * in the entry routines.
  */
        __HEAD
-_head:
        /*
         * DO NOT MODIFY. Image header expected by Linux boot-loaders.
         */
-#ifdef CONFIG_EFI
-       /*
-        * This add instruction has no meaningful effect except that
-        * its opcode forms the magic "MZ" signature required by UEFI.
-        */
-       add     x13, x18, #0x16
-       b       primary_entry
-#else
+       efi_signature_nop                       // special NOP to identity as PE/COFF executable
        b       primary_entry                   // branch to kernel start, magic
-       .long   0                               // reserved
-#endif
        .quad   0                               // Image load offset from start of RAM, little-endian
        le64sym _kernel_size_le                 // Effective size of kernel image, little-endian
        le64sym _kernel_flags_le                // Informative flags, little-endian
@@ -80,14 +70,9 @@ _head:
        .quad   0                               // reserved
        .quad   0                               // reserved
        .ascii  ARM64_IMAGE_MAGIC               // Magic number
-#ifdef CONFIG_EFI
-       .long   pe_header - _head               // Offset to the PE header.
+       .long   .Lpe_header_offset              // Offset to the PE header.
 
-pe_header:
        __EFI_PE_HEADER
-#else
-       .long   0                               // reserved
-#endif
 
        __INIT
 
@@ -104,7 +89,7 @@ pe_header:
         */
 SYM_CODE_START(primary_entry)
        bl      preserve_boot_args
-       bl      el2_setup                       // Drop to EL1, w0=cpu_boot_mode
+       bl      init_kernel_el                  // w0=cpu_boot_mode
        adrp    x23, __PHYS_OFFSET
        and     x23, x23, MIN_KIMG_ALIGN - 1    // KASLR offset, defaults to 0
        bl      set_cpu_boot_mode_flag
@@ -482,24 +467,33 @@ EXPORT_SYMBOL(kimage_vaddr)
        .section ".idmap.text","awx"
 
 /*
- * If we're fortunate enough to boot at EL2, ensure that the world is
- * sane before dropping to EL1.
+ * Starting from EL2 or EL1, configure the CPU to execute at the highest
+ * reachable EL supported by the kernel in a chosen default state. If dropping
+ * from EL2 to EL1, configure EL2 before configuring EL1.
+ *
+ * Since we cannot always rely on ERET synchronizing writes to sysregs (e.g. if
+ * SCTLR_ELx.EOS is clear), we place an ISB prior to ERET.
  *
  * Returns either BOOT_CPU_MODE_EL1 or BOOT_CPU_MODE_EL2 in w0 if
  * booted in EL1 or EL2 respectively.
  */
-SYM_FUNC_START(el2_setup)
-       msr     SPsel, #1                       // We want to use SP_EL{1,2}
+SYM_FUNC_START(init_kernel_el)
        mrs     x0, CurrentEL
        cmp     x0, #CurrentEL_EL2
-       b.eq    1f
-       mov_q   x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1)
+       b.eq    init_el2
+
+SYM_INNER_LABEL(init_el1, SYM_L_LOCAL)
+       mov_q   x0, INIT_SCTLR_EL1_MMU_OFF
        msr     sctlr_el1, x0
-       mov     w0, #BOOT_CPU_MODE_EL1          // This cpu booted in EL1
        isb
-       ret
+       mov_q   x0, INIT_PSTATE_EL1
+       msr     spsr_el1, x0
+       msr     elr_el1, lr
+       mov     w0, #BOOT_CPU_MODE_EL1
+       eret
 
-1:     mov_q   x0, (SCTLR_EL2_RES1 | ENDIAN_SET_EL2)
+SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
+       mov_q   x0, INIT_SCTLR_EL2_MMU_OFF
        msr     sctlr_el2, x0
 
 #ifdef CONFIG_ARM64_VHE
@@ -608,9 +602,12 @@ set_hcr:
 
        cbz     x2, install_el2_stub
 
-       mov     w0, #BOOT_CPU_MODE_EL2          // This CPU booted in EL2
        isb
-       ret
+       mov_q   x0, INIT_PSTATE_EL2
+       msr     spsr_el2, x0
+       msr     elr_el2, lr
+       mov     w0, #BOOT_CPU_MODE_EL2
+       eret
 
 SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL)
        /*
@@ -620,7 +617,7 @@ SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL)
         * requires no configuration, and all non-hyp-specific EL2 setup
         * will be done via the _EL1 system register aliases in __cpu_setup.
         */
-       mov_q   x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1)
+       mov_q   x0, INIT_SCTLR_EL1_MMU_OFF
        msr     sctlr_el1, x0
 
        /* Coprocessor traps. */
@@ -642,14 +639,13 @@ SYM_INNER_LABEL(install_el2_stub, SYM_L_LOCAL)
 7:     adr_l   x0, __hyp_stub_vectors
        msr     vbar_el2, x0
 
-       /* spsr */
-       mov     x0, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\
-                     PSR_MODE_EL1h)
+       isb
+       mov     x0, #INIT_PSTATE_EL1
        msr     spsr_el2, x0
        msr     elr_el2, lr
-       mov     w0, #BOOT_CPU_MODE_EL2          // This CPU booted in EL2
+       mov     w0, #BOOT_CPU_MODE_EL2
        eret
-SYM_FUNC_END(el2_setup)
+SYM_FUNC_END(init_kernel_el)
 
 /*
  * Sets the __boot_cpu_mode flag depending on the CPU boot mode passed
@@ -699,7 +695,7 @@ SYM_DATA_END(__early_cpu_boot_status)
         * cores are held until we're ready for them to initialise.
         */
 SYM_FUNC_START(secondary_holding_pen)
-       bl      el2_setup                       // Drop to EL1, w0=cpu_boot_mode
+       bl      init_kernel_el                  // w0=cpu_boot_mode
        bl      set_cpu_boot_mode_flag
        mrs     x0, mpidr_el1
        mov_q   x1, MPIDR_HWID_BITMASK
@@ -717,7 +713,7 @@ SYM_FUNC_END(secondary_holding_pen)
         * be used where CPUs are brought online dynamically by the kernel.
         */
 SYM_FUNC_START(secondary_entry)
-       bl      el2_setup                       // Drop to EL1
+       bl      init_kernel_el                  // w0=cpu_boot_mode
        bl      set_cpu_boot_mode_flag
        b       secondary_startup
 SYM_FUNC_END(secondary_entry)
index 61684a5009148d245d1b8b4e9526f20cad9963b4..c615b285ff5b332bf25eea2dff882100c0066dd0 100644 (file)
@@ -87,7 +87,6 @@ KVM_NVHE_ALIAS(__icache_flags);
 /* Kernel symbols needed for cpus_have_final/const_caps checks. */
 KVM_NVHE_ALIAS(arm64_const_caps_ready);
 KVM_NVHE_ALIAS(cpu_hwcap_keys);
-KVM_NVHE_ALIAS(cpu_hwcaps);
 
 /* Static keys which are set if a vGIC trap should be handled in hyp. */
 KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
index 60456a62da11660f3e4316e097501eddadcd7542..dfb1feab867d43b7fd5ea029b3f69d9bbf873907 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/irqchip.h>
 #include <linux/kprobes.h>
+#include <linux/scs.h>
 #include <linux/seq_file.h>
 #include <linux/vmalloc.h>
 #include <asm/daifflags.h>
@@ -27,6 +28,25 @@ DEFINE_PER_CPU(struct nmi_ctx, nmi_contexts);
 
 DEFINE_PER_CPU(unsigned long *, irq_stack_ptr);
 
+
+DECLARE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr);
+
+#ifdef CONFIG_SHADOW_CALL_STACK
+DEFINE_PER_CPU(unsigned long *, irq_shadow_call_stack_ptr);
+#endif
+
+static void init_irq_scs(void)
+{
+       int cpu;
+
+       if (!IS_ENABLED(CONFIG_SHADOW_CALL_STACK))
+               return;
+
+       for_each_possible_cpu(cpu)
+               per_cpu(irq_shadow_call_stack_ptr, cpu) =
+                       scs_alloc(cpu_to_node(cpu));
+}
+
 #ifdef CONFIG_VMAP_STACK
 static void init_irq_stacks(void)
 {
@@ -54,6 +74,7 @@ static void init_irq_stacks(void)
 void __init init_IRQ(void)
 {
        init_irq_stacks();
+       init_irq_scs();
        irqchip_init();
        if (!handle_arch_irq)
                panic("No interrupt controller found.");
index b181e0544b79909b8d514e69514c57af8a8cb258..0921aa1520b07f73c9baeded902e135cf0adb6ed 100644 (file)
@@ -50,10 +50,16 @@ static __init u64 get_kaslr_seed(void *fdt)
        return ret;
 }
 
-static __init const u8 *kaslr_get_cmdline(void *fdt)
+static __init bool cmdline_contains_nokaslr(const u8 *cmdline)
 {
-       static __initconst const u8 default_cmdline[] = CONFIG_CMDLINE;
+       const u8 *str;
 
+       str = strstr(cmdline, "nokaslr");
+       return str == cmdline || (str > cmdline && *(str - 1) == ' ');
+}
+
+static __init bool is_kaslr_disabled_cmdline(void *fdt)
+{
        if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
                int node;
                const u8 *prop;
@@ -65,10 +71,17 @@ static __init const u8 *kaslr_get_cmdline(void *fdt)
                prop = fdt_getprop(fdt, node, "bootargs", NULL);
                if (!prop)
                        goto out;
-               return prop;
+
+               if (cmdline_contains_nokaslr(prop))
+                       return true;
+
+               if (IS_ENABLED(CONFIG_CMDLINE_EXTEND))
+                       goto out;
+
+               return false;
        }
 out:
-       return default_cmdline;
+       return cmdline_contains_nokaslr(CONFIG_CMDLINE);
 }
 
 /*
@@ -83,7 +96,6 @@ u64 __init kaslr_early_init(u64 dt_phys)
 {
        void *fdt;
        u64 seed, offset, mask, module_range;
-       const u8 *cmdline, *str;
        unsigned long raw;
        int size;
 
@@ -115,9 +127,7 @@ u64 __init kaslr_early_init(u64 dt_phys)
         * Check if 'nokaslr' appears on the command line, and
         * return 0 if that is the case.
         */
-       cmdline = kaslr_get_cmdline(fdt);
-       str = strstr(cmdline, "nokaslr");
-       if (str == cmdline || (str > cmdline && *(str - 1) == ' ')) {
+       if (is_kaslr_disabled_cmdline(fdt)) {
                kaslr_status = KASLR_DISABLED_CMDLINE;
                return 0;
        }
index 3605f77ad4df1796c52b01a2bb959569d5ea1a83..38bb07eff8720d238e1d03759f59fb76e8f5ee05 100644 (file)
@@ -23,6 +23,8 @@
 #include <linux/platform_device.h>
 #include <linux/sched_clock.h>
 #include <linux/smp.h>
+#include <linux/nmi.h>
+#include <linux/cpufreq.h>
 
 /* ARMv8 Cortex-A53 specific event types. */
 #define ARMV8_A53_PERFCTR_PREF_LINEFILL                                0xC2
@@ -1248,10 +1250,21 @@ static struct platform_driver armv8_pmu_driver = {
 
 static int __init armv8_pmu_driver_init(void)
 {
+       int ret;
+
        if (acpi_disabled)
-               return platform_driver_register(&armv8_pmu_driver);
+               ret = platform_driver_register(&armv8_pmu_driver);
        else
-               return arm_pmu_acpi_probe(armv8_pmuv3_init);
+               ret = arm_pmu_acpi_probe(armv8_pmuv3_init);
+
+       /*
+        * Try to re-initialize lockup detector after PMU init in
+        * case PMU events are triggered via NMIs.
+        */
+       if (ret == 0 && arm_pmu_irq_is_nmi())
+               lockup_detector_init();
+
+       return ret;
 }
 device_initcall(armv8_pmu_driver_init)
 
@@ -1309,3 +1322,27 @@ void arch_perf_update_userpage(struct perf_event *event,
        userpg->cap_user_time_zero = 1;
        userpg->cap_user_time_short = 1;
 }
+
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
+/*
+ * Safe maximum CPU frequency in case a particular platform doesn't implement
+ * cpufreq driver. Although, architecture doesn't put any restrictions on
+ * maximum frequency but 5 GHz seems to be safe maximum given the available
+ * Arm CPUs in the market which are clocked much less than 5 GHz. On the other
+ * hand, we can't make it much higher as it would lead to a large hard-lockup
+ * detection timeout on parts which are running slower (eg. 1GHz on
+ * Developerbox) and doesn't possess a cpufreq driver.
+ */
+#define SAFE_MAX_CPU_FREQ      5000000000UL // 5 GHz
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+       unsigned int cpu = smp_processor_id();
+       unsigned long max_cpu_freq;
+
+       max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL;
+       if (!max_cpu_freq)
+               max_cpu_freq = SAFE_MAX_CPU_FREQ;
+
+       return (u64)max_cpu_freq * watchdog_thresh;
+}
+#endif
index f11a1a1f702614b1ae54438fe51b8adae4bd69ee..89c64ada8732413bc28ae5669651b0adf5efe702 100644 (file)
@@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
 
 static void __kprobes
-post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *);
+post_kprobe_handler(struct kprobe *, struct kprobe_ctlblk *, struct pt_regs *);
 
 static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
 {
@@ -68,7 +68,7 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
                p->ainsn.api.handler((u32)p->opcode, (long)p->addr, regs);
 
        /* single step simulated, now go for post processing */
-       post_kprobe_handler(kcb, regs);
+       post_kprobe_handler(p, kcb, regs);
 }
 
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
@@ -177,19 +177,6 @@ static void __kprobes kprobes_restore_local_irqflag(struct kprobe_ctlblk *kcb,
        regs->pstate |= kcb->saved_irqflag;
 }
 
-static void __kprobes
-set_ss_context(struct kprobe_ctlblk *kcb, unsigned long addr)
-{
-       kcb->ss_ctx.ss_pending = true;
-       kcb->ss_ctx.match_addr = addr + sizeof(kprobe_opcode_t);
-}
-
-static void __kprobes clear_ss_context(struct kprobe_ctlblk *kcb)
-{
-       kcb->ss_ctx.ss_pending = false;
-       kcb->ss_ctx.match_addr = 0;
-}
-
 static void __kprobes setup_singlestep(struct kprobe *p,
                                       struct pt_regs *regs,
                                       struct kprobe_ctlblk *kcb, int reenter)
@@ -209,7 +196,6 @@ static void __kprobes setup_singlestep(struct kprobe *p,
                /* prepare for single stepping */
                slot = (unsigned long)p->ainsn.api.insn;
 
-               set_ss_context(kcb, slot);      /* mark pending ss */
                kprobes_save_local_irqflag(kcb, regs);
                instruction_pointer_set(regs, slot);
        } else {
@@ -243,13 +229,8 @@ static int __kprobes reenter_kprobe(struct kprobe *p,
 }
 
 static void __kprobes
-post_kprobe_handler(struct kprobe_ctlblk *kcb, struct pt_regs *regs)
+post_kprobe_handler(struct kprobe *cur, struct kprobe_ctlblk *kcb, struct pt_regs *regs)
 {
-       struct kprobe *cur = kprobe_running();
-
-       if (!cur)
-               return;
-
        /* return addr restore if non-branching insn */
        if (cur->ainsn.api.restore != 0)
                instruction_pointer_set(regs, cur->ainsn.api.restore);
@@ -364,33 +345,23 @@ static void __kprobes kprobe_handler(struct pt_regs *regs)
         */
 }
 
-static int __kprobes
-kprobe_ss_hit(struct kprobe_ctlblk *kcb, unsigned long addr)
-{
-       if ((kcb->ss_ctx.ss_pending)
-           && (kcb->ss_ctx.match_addr == addr)) {
-               clear_ss_context(kcb);  /* clear pending ss */
-               return DBG_HOOK_HANDLED;
-       }
-       /* not ours, kprobes should ignore it */
-       return DBG_HOOK_ERROR;
-}
-
 static int __kprobes
 kprobe_breakpoint_ss_handler(struct pt_regs *regs, unsigned int esr)
 {
        struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
-       int retval;
-
-       /* return error if this is not our step */
-       retval = kprobe_ss_hit(kcb, instruction_pointer(regs));
+       unsigned long addr = instruction_pointer(regs);
+       struct kprobe *cur = kprobe_running();
 
-       if (retval == DBG_HOOK_HANDLED) {
+       if (cur && (kcb->kprobe_status == KPROBE_HIT_SS)
+           && ((unsigned long)&cur->ainsn.api.insn[1] == addr)) {
                kprobes_restore_local_irqflag(kcb, regs);
-               post_kprobe_handler(kcb, regs);
+               post_kprobe_handler(cur, kcb, regs);
+
+               return DBG_HOOK_HANDLED;
        }
 
-       return retval;
+       /* not ours, kprobes should ignore it */
+       return DBG_HOOK_ERROR;
 }
 
 static struct break_hook kprobes_break_ss_hook = {
index 0c65a91f8f53f47020f41c78bc48112fa5b18be2..3834cfafbbc273ac235fec8ea15fd51f2409f7f4 100644 (file)
@@ -422,16 +422,15 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
                if (clone_flags & CLONE_SETTLS)
                        p->thread.uw.tp_value = tls;
        } else {
+               /*
+                * A kthread has no context to ERET to, so ensure any buggy
+                * ERET is treated as an illegal exception return.
+                *
+                * When a user task is created from a kthread, childregs will
+                * be initialized by start_thread() or start_compat_thread().
+                */
                memset(childregs, 0, sizeof(struct pt_regs));
-               childregs->pstate = PSR_MODE_EL1h;
-               if (IS_ENABLED(CONFIG_ARM64_UAO) &&
-                   cpus_have_const_cap(ARM64_HAS_UAO))
-                       childregs->pstate |= PSR_UAO_BIT;
-
-               spectre_v4_enable_task_mitigation(p);
-
-               if (system_uses_irq_prio_masking())
-                       childregs->pmr_save = GIC_PRIO_IRQON;
+               childregs->pstate = PSR_MODE_EL1h | PSR_IL_BIT;
 
                p->thread.cpu_context.x19 = stack_start;
                p->thread.cpu_context.x20 = stk_sz;
@@ -461,17 +460,6 @@ static void tls_thread_switch(struct task_struct *next)
        write_sysreg(*task_user_tls(next), tpidr_el0);
 }
 
-/* Restore the UAO state depending on next's addr_limit */
-void uao_thread_switch(struct task_struct *next)
-{
-       if (IS_ENABLED(CONFIG_ARM64_UAO)) {
-               if (task_thread_info(next)->addr_limit == KERNEL_DS)
-                       asm(ALTERNATIVE("nop", SET_PSTATE_UAO(1), ARM64_HAS_UAO));
-               else
-                       asm(ALTERNATIVE("nop", SET_PSTATE_UAO(0), ARM64_HAS_UAO));
-       }
-}
-
 /*
  * Force SSBS state on context-switch, since it may be lost after migrating
  * from a CPU which treats the bit as RES0 in a heterogeneous system.
@@ -554,7 +542,6 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
        hw_breakpoint_thread_switch(next);
        contextidr_thread_switch(next);
        entry_task_switch(next);
-       uao_thread_switch(next);
        ssbs_thread_switch(next);
        erratum_1418040_thread_switch(prev, next);
 
index f6e4e3737405dea81ba0f21faa90050b1750e71a..4c25c008504f23b41b0d7912ce097cabc19f74c9 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/prctl.h>
 #include <linux/sched/task_stack.h>
 
+#include <asm/insn.h>
 #include <asm/spectre.h>
 #include <asm/traps.h>
 
@@ -538,12 +539,12 @@ static enum mitigation_state spectre_v4_enable_hw_mitigation(void)
 
        if (spectre_v4_mitigations_off()) {
                sysreg_clear_set(sctlr_el1, 0, SCTLR_ELx_DSSBS);
-               asm volatile(SET_PSTATE_SSBS(1));
+               set_pstate_ssbs(1);
                return SPECTRE_VULNERABLE;
        }
 
        /* SCTLR_EL1.DSSBS was initialised to 0 during boot */
-       asm volatile(SET_PSTATE_SSBS(0));
+       set_pstate_ssbs(0);
        return SPECTRE_MITIGATED;
 }
 
index f49b349e16a3452cb67138d4a82c57f5ed3e88a5..8ac487c84e3793ea539c857db114ba37f02d794f 100644 (file)
@@ -192,14 +192,11 @@ static void ptrace_hbptriggered(struct perf_event *bp,
                                break;
                        }
                }
-               arm64_force_sig_ptrace_errno_trap(si_errno,
-                                                 (void __user *)bkpt->trigger,
+               arm64_force_sig_ptrace_errno_trap(si_errno, bkpt->trigger,
                                                  desc);
        }
 #endif
-       arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT,
-                             (void __user *)(bkpt->trigger),
-                             desc);
+       arm64_force_sig_fault(SIGTRAP, TRAP_HWBKPT, bkpt->trigger, desc);
 }
 
 /*
diff --git a/arch/arm64/kernel/scs.c b/arch/arm64/kernel/scs.c
deleted file mode 100644 (file)
index e8f7ff4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Shadow Call Stack support.
- *
- * Copyright (C) 2019 Google LLC
- */
-
-#include <linux/percpu.h>
-#include <linux/scs.h>
-
-DEFINE_SCS(irq_shadow_call_stack);
-
-#ifdef CONFIG_ARM_SDE_INTERFACE
-DEFINE_SCS(sdei_shadow_call_stack_normal);
-DEFINE_SCS(sdei_shadow_call_stack_critical);
-#endif
index 793c46d6a44791c11eee1600956ec3f35c54050f..2c7ca449dd5111206fa8559065fd95ce2858dcf9 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/hardirq.h>
 #include <linux/irqflags.h>
 #include <linux/sched/task_stack.h>
+#include <linux/scs.h>
 #include <linux/uaccess.h>
 
 #include <asm/alternative.h>
@@ -38,6 +39,14 @@ DEFINE_PER_CPU(unsigned long *, sdei_stack_normal_ptr);
 DEFINE_PER_CPU(unsigned long *, sdei_stack_critical_ptr);
 #endif
 
+DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr);
+DECLARE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr);
+
+#ifdef CONFIG_SHADOW_CALL_STACK
+DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_normal_ptr);
+DEFINE_PER_CPU(unsigned long *, sdei_shadow_call_stack_critical_ptr);
+#endif
+
 static void _free_sdei_stack(unsigned long * __percpu *ptr, int cpu)
 {
        unsigned long *p;
@@ -53,6 +62,9 @@ static void free_sdei_stacks(void)
 {
        int cpu;
 
+       if (!IS_ENABLED(CONFIG_VMAP_STACK))
+               return;
+
        for_each_possible_cpu(cpu) {
                _free_sdei_stack(&sdei_stack_normal_ptr, cpu);
                _free_sdei_stack(&sdei_stack_critical_ptr, cpu);
@@ -76,6 +88,9 @@ static int init_sdei_stacks(void)
        int cpu;
        int err = 0;
 
+       if (!IS_ENABLED(CONFIG_VMAP_STACK))
+               return 0;
+
        for_each_possible_cpu(cpu) {
                err = _init_sdei_stack(&sdei_stack_normal_ptr, cpu);
                if (err)
@@ -91,6 +106,62 @@ static int init_sdei_stacks(void)
        return err;
 }
 
+static void _free_sdei_scs(unsigned long * __percpu *ptr, int cpu)
+{
+       void *s;
+
+       s = per_cpu(*ptr, cpu);
+       if (s) {
+               per_cpu(*ptr, cpu) = NULL;
+               scs_free(s);
+       }
+}
+
+static void free_sdei_scs(void)
+{
+       int cpu;
+
+       for_each_possible_cpu(cpu) {
+               _free_sdei_scs(&sdei_shadow_call_stack_normal_ptr, cpu);
+               _free_sdei_scs(&sdei_shadow_call_stack_critical_ptr, cpu);
+       }
+}
+
+static int _init_sdei_scs(unsigned long * __percpu *ptr, int cpu)
+{
+       void *s;
+
+       s = scs_alloc(cpu_to_node(cpu));
+       if (!s)
+               return -ENOMEM;
+       per_cpu(*ptr, cpu) = s;
+
+       return 0;
+}
+
+static int init_sdei_scs(void)
+{
+       int cpu;
+       int err = 0;
+
+       if (!IS_ENABLED(CONFIG_SHADOW_CALL_STACK))
+               return 0;
+
+       for_each_possible_cpu(cpu) {
+               err = _init_sdei_scs(&sdei_shadow_call_stack_normal_ptr, cpu);
+               if (err)
+                       break;
+               err = _init_sdei_scs(&sdei_shadow_call_stack_critical_ptr, cpu);
+               if (err)
+                       break;
+       }
+
+       if (err)
+               free_sdei_scs();
+
+       return err;
+}
+
 static bool on_sdei_normal_stack(unsigned long sp, struct stack_info *info)
 {
        unsigned long low = (unsigned long)raw_cpu_read(sdei_stack_normal_ptr);
@@ -131,13 +202,14 @@ unsigned long sdei_arch_get_entry_point(int conduit)
         */
        if (is_hyp_mode_available() && !is_kernel_in_hyp_mode()) {
                pr_err("Not supported on this hardware/boot configuration\n");
-               return 0;
+               goto out_err;
        }
 
-       if (IS_ENABLED(CONFIG_VMAP_STACK)) {
-               if (init_sdei_stacks())
-                       return 0;
-       }
+       if (init_sdei_stacks())
+               goto out_err;
+
+       if (init_sdei_scs())
+               goto out_err_free_stacks;
 
        sdei_exit_mode = (conduit == SMCCC_CONDUIT_HVC) ? SDEI_EXIT_HVC : SDEI_EXIT_SMC;
 
@@ -152,6 +224,10 @@ unsigned long sdei_arch_get_entry_point(int conduit)
 #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
                return (unsigned long)__sdei_asm_handler;
 
+out_err_free_stacks:
+       free_sdei_stacks();
+out_err:
+       return 0;
 }
 
 /*
@@ -179,12 +255,6 @@ static __kprobes unsigned long _sdei_handler(struct pt_regs *regs,
                sdei_api_event_context(i, &regs->regs[i]);
        }
 
-       /*
-        * We didn't take an exception to get here, set PAN. UAO will be cleared
-        * by sdei_event_handler()s force_uaccess_begin() call.
-        */
-       __uaccess_enable_hw_pan();
-
        err = sdei_event_handler(regs, arg);
        if (err)
                return SDEI_EV_FAILED;
@@ -223,12 +293,39 @@ static __kprobes unsigned long _sdei_handler(struct pt_regs *regs,
        return vbar + 0x480;
 }
 
+static void __kprobes notrace __sdei_pstate_entry(void)
+{
+       /*
+        * The original SDEI spec (ARM DEN 0054A) can be read ambiguously as to
+        * whether PSTATE bits are inherited unchanged or generated from
+        * scratch, and the TF-A implementation always clears PAN and always
+        * clears UAO. There are no other known implementations.
+        *
+        * Subsequent revisions (ARM DEN 0054B) follow the usual rules for how
+        * PSTATE is modified upon architectural exceptions, and so PAN is
+        * either inherited or set per SCTLR_ELx.SPAN, and UAO is always
+        * cleared.
+        *
+        * We must explicitly reset PAN to the expected state, including
+        * clearing it when the host isn't using it, in case a VM had it set.
+        */
+       if (system_uses_hw_pan())
+               set_pstate_pan(1);
+       else if (cpu_has_pan())
+               set_pstate_pan(0);
+}
 
 asmlinkage noinstr unsigned long
 __sdei_handler(struct pt_regs *regs, struct sdei_registered_event *arg)
 {
        unsigned long ret;
 
+       /*
+        * We didn't take an exception to get here, so the HW hasn't
+        * set/cleared bits in PSTATE that we may rely on. Initialize PAN.
+        */
+       __sdei_pstate_entry();
+
        arm64_enter_nmi(regs);
 
        ret = _sdei_handler(regs, arg);
index 133257ffd8591d692f5f64abf8f41fb2d0e0910c..1a57a76e1cc207b30417dedd3d0f77aa5c77328e 100644 (file)
@@ -206,7 +206,7 @@ static void __init request_standard_resources(void)
        unsigned long i = 0;
        size_t res_size;
 
-       kernel_code.start   = __pa_symbol(_text);
+       kernel_code.start   = __pa_symbol(_stext);
        kernel_code.end     = __pa_symbol(__init_begin - 1);
        kernel_data.start   = __pa_symbol(_sdata);
        kernel_data.end     = __pa_symbol(_end - 1);
@@ -283,7 +283,7 @@ u64 cpu_logical_map(int cpu)
 
 void __init __no_sanitize_address setup_arch(char **cmdline_p)
 {
-       init_mm.start_code = (unsigned long) _text;
+       init_mm.start_code = (unsigned long) _stext;
        init_mm.end_code   = (unsigned long) _etext;
        init_mm.end_data   = (unsigned long) _edata;
        init_mm.brk        = (unsigned long) _end;
@@ -366,7 +366,7 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)
         * faults in case uaccess_enable() is inadvertently called by the init
         * thread.
         */
-       init_task.thread_info.ttbr0 = __pa_symbol(empty_zero_page);
+       init_task.thread_info.ttbr0 = __pa_symbol(reserved_pg_dir);
 #endif
 
        if (boot_args[1] || boot_args[2] || boot_args[3]) {
index a8184cad889075ebc665bd30e018a77a6ec5986e..af5c6c6638f7bb5cddd59faeacc0a1be367f4fa8 100644 (file)
@@ -922,9 +922,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
        trace_hardirqs_off();
 
        do {
-               /* Check valid user FS if needed */
-               addr_limit_user_check();
-
                if (thread_flags & _TIF_NEED_RESCHED) {
                        /* Unmask Debug and SError for the next task */
                        local_daif_restore(DAIF_PROCCTX_NOIRQ);
index ba40d57757d63c10f671ba8f7e674d1e2430e161..4be7f7eed87502570c5efb54299fafca19e4be86 100644 (file)
@@ -99,7 +99,7 @@ SYM_FUNC_END(__cpu_suspend_enter)
 
        .pushsection ".idmap.text", "awx"
 SYM_CODE_START(cpu_resume)
-       bl      el2_setup               // if in EL2 drop to EL1 cleanly
+       bl      init_kernel_el
        bl      __cpu_setup
        /* enable the MMU early - so we can access sleep_save_stash by va */
        adrp    x1, swapper_pg_dir
index 18e9727d3f64502a4ec763495b850c9ebd105f0a..2499b895efea45c41a704f34b4ccdec4328cbcba 100644 (file)
@@ -787,14 +787,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 }
 
 static const char *ipi_types[NR_IPI] __tracepoint_string = {
-#define S(x,s) [x] = s
-       S(IPI_RESCHEDULE, "Rescheduling interrupts"),
-       S(IPI_CALL_FUNC, "Function call interrupts"),
-       S(IPI_CPU_STOP, "CPU stop interrupts"),
-       S(IPI_CPU_CRASH_STOP, "CPU stop (for crash dump) interrupts"),
-       S(IPI_TIMER, "Timer broadcast interrupts"),
-       S(IPI_IRQ_WORK, "IRQ work interrupts"),
-       S(IPI_WAKEUP, "CPU wake-up interrupts"),
+       [IPI_RESCHEDULE]        = "Rescheduling interrupts",
+       [IPI_CALL_FUNC]         = "Function call interrupts",
+       [IPI_CPU_STOP]          = "CPU stop interrupts",
+       [IPI_CPU_CRASH_STOP]    = "CPU stop (for crash dump) interrupts",
+       [IPI_TIMER]             = "Timer broadcast interrupts",
+       [IPI_IRQ_WORK]          = "IRQ work interrupts",
+       [IPI_WAKEUP]            = "CPU wake-up interrupts",
 };
 
 static void smp_cross_call(const struct cpumask *target, unsigned int ipinr);
index 96cd347c7a4651597fa2459d4256188134792c1c..a67b37a7a47e1fc7e38ccb88acd236a797837ca8 100644 (file)
@@ -58,7 +58,6 @@ void notrace __cpu_suspend_exit(void)
         * features that might not have been set correctly.
         */
        __uaccess_enable_hw_pan();
-       uao_thread_switch(current);
 
        /*
         * Restore HW breakpoint registers to sane values
index 3c18c2454089b477b3cc012585d731d58a883daf..265fe3eb10699b71033d350b004b0549af6dfd58 100644 (file)
@@ -68,7 +68,7 @@ do_compat_cache_op(unsigned long start, unsigned long end, int flags)
  */
 long compat_arm_syscall(struct pt_regs *regs, int scno)
 {
-       void __user *addr;
+       unsigned long addr;
 
        switch (scno) {
        /*
@@ -111,8 +111,7 @@ long compat_arm_syscall(struct pt_regs *regs, int scno)
                break;
        }
 
-       addr  = (void __user *)instruction_pointer(regs) -
-               (compat_thumb_mode(regs) ? 2 : 4);
+       addr = instruction_pointer(regs) - (compat_thumb_mode(regs) ? 2 : 4);
 
        arm64_notify_die("Oops - bad compat syscall(2)", regs,
                         SIGILL, ILL_ILLTRP, addr, scno);
index f8f758e4a3064e961a8b3d74cb6535574ecaa561..f61e9d8cc55a1efe2cda0bb94f67177bb79acef6 100644 (file)
@@ -122,7 +122,7 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr,
        cortex_a76_erratum_1463225_svc_handler();
        local_daif_restore(DAIF_PROCCTX);
 
-       if (system_supports_mte() && (flags & _TIF_MTE_ASYNC_FAULT)) {
+       if (flags & _TIF_MTE_ASYNC_FAULT) {
                /*
                 * Process the asynchronous tag check fault before the actual
                 * syscall. do_notify_resume() will send a signal to userspace
index 543c67cae02ff7d4c96dc027e85ec3d2b075ecc9..b8026ec684ba1c3d4d79c6112d14b1fffe16bc3f 100644 (file)
@@ -124,6 +124,12 @@ int __init parse_acpi_topology(void)
 #endif
 
 #ifdef CONFIG_ARM64_AMU_EXTN
+#define read_corecnt() read_sysreg_s(SYS_AMEVCNTR0_CORE_EL0)
+#define read_constcnt()        read_sysreg_s(SYS_AMEVCNTR0_CONST_EL0)
+#else
+#define read_corecnt() (0UL)
+#define read_constcnt()        (0UL)
+#endif
 
 #undef pr_fmt
 #define pr_fmt(fmt) "AMU: " fmt
@@ -133,54 +139,58 @@ static DEFINE_PER_CPU(u64, arch_const_cycles_prev);
 static DEFINE_PER_CPU(u64, arch_core_cycles_prev);
 static cpumask_var_t amu_fie_cpus;
 
-/* Initialize counter reference per-cpu variables for the current CPU */
-void init_cpu_freq_invariance_counters(void)
+void update_freq_counters_refs(void)
 {
-       this_cpu_write(arch_core_cycles_prev,
-                      read_sysreg_s(SYS_AMEVCNTR0_CORE_EL0));
-       this_cpu_write(arch_const_cycles_prev,
-                      read_sysreg_s(SYS_AMEVCNTR0_CONST_EL0));
+       this_cpu_write(arch_core_cycles_prev, read_corecnt());
+       this_cpu_write(arch_const_cycles_prev, read_constcnt());
 }
 
-static int validate_cpu_freq_invariance_counters(int cpu)
+static inline bool freq_counters_valid(int cpu)
 {
-       u64 max_freq_hz, ratio;
+       if ((cpu >= nr_cpu_ids) || !cpumask_test_cpu(cpu, cpu_present_mask))
+               return false;
 
        if (!cpu_has_amu_feat(cpu)) {
                pr_debug("CPU%d: counters are not supported.\n", cpu);
-               return -EINVAL;
+               return false;
        }
 
        if (unlikely(!per_cpu(arch_const_cycles_prev, cpu) ||
                     !per_cpu(arch_core_cycles_prev, cpu))) {
                pr_debug("CPU%d: cycle counters are not enabled.\n", cpu);
-               return -EINVAL;
+               return false;
        }
 
-       /* Convert maximum frequency from KHz to Hz and validate */
-       max_freq_hz = cpufreq_get_hw_max_freq(cpu) * 1000;
-       if (unlikely(!max_freq_hz)) {
-               pr_debug("CPU%d: invalid maximum frequency.\n", cpu);
+       return true;
+}
+
+static int freq_inv_set_max_ratio(int cpu, u64 max_rate, u64 ref_rate)
+{
+       u64 ratio;
+
+       if (unlikely(!max_rate || !ref_rate)) {
+               pr_debug("CPU%d: invalid maximum or reference frequency.\n",
+                        cpu);
                return -EINVAL;
        }
 
        /*
         * Pre-compute the fixed ratio between the frequency of the constant
-        * counter and the maximum frequency of the CPU.
+        * reference counter and the maximum frequency of the CPU.
         *
-        *                            const_freq
-        * arch_max_freq_scale =   ---------------- * SCHED_CAPACITY_SCALE²
-        *                         cpuinfo_max_freq
+        *                          ref_rate
+        * arch_max_freq_scale =   ---------- * SCHED_CAPACITY_SCALE²
+        *                          max_rate
         *
         * We use a factor of 2 * SCHED_CAPACITY_SHIFT -> SCHED_CAPACITY_SCALE²
         * in order to ensure a good resolution for arch_max_freq_scale for
-        * very low arch timer frequencies (down to the KHz range which should
+        * very low reference frequencies (down to the KHz range which should
         * be unlikely).
         */
-       ratio = (u64)arch_timer_get_rate() << (2 * SCHED_CAPACITY_SHIFT);
-       ratio = div64_u64(ratio, max_freq_hz);
+       ratio = ref_rate << (2 * SCHED_CAPACITY_SHIFT);
+       ratio = div64_u64(ratio, max_rate);
        if (!ratio) {
-               WARN_ONCE(1, "System timer frequency too low.\n");
+               WARN_ONCE(1, "Reference frequency too low.\n");
                return -EINVAL;
        }
 
@@ -227,8 +237,12 @@ static int __init init_amu_fie(void)
        }
 
        for_each_present_cpu(cpu) {
-               if (validate_cpu_freq_invariance_counters(cpu))
+               if (!freq_counters_valid(cpu) ||
+                   freq_inv_set_max_ratio(cpu,
+                                          cpufreq_get_hw_max_freq(cpu) * 1000,
+                                          arch_timer_get_rate()))
                        continue;
+
                cpumask_set_cpu(cpu, valid_cpus);
                have_policy |= enable_policy_freq_counters(cpu, valid_cpus);
        }
@@ -280,11 +294,14 @@ void topology_scale_freq_tick(void)
        if (!cpumask_test_cpu(cpu, amu_fie_cpus))
                return;
 
-       const_cnt = read_sysreg_s(SYS_AMEVCNTR0_CONST_EL0);
-       core_cnt = read_sysreg_s(SYS_AMEVCNTR0_CORE_EL0);
        prev_const_cnt = this_cpu_read(arch_const_cycles_prev);
        prev_core_cnt = this_cpu_read(arch_core_cycles_prev);
 
+       update_freq_counters_refs();
+
+       const_cnt = this_cpu_read(arch_const_cycles_prev);
+       core_cnt = this_cpu_read(arch_core_cycles_prev);
+
        if (unlikely(core_cnt <= prev_core_cnt ||
                     const_cnt <= prev_const_cnt))
                goto store_and_exit;
@@ -309,4 +326,71 @@ store_and_exit:
        this_cpu_write(arch_core_cycles_prev, core_cnt);
        this_cpu_write(arch_const_cycles_prev, const_cnt);
 }
-#endif /* CONFIG_ARM64_AMU_EXTN */
+
+#ifdef CONFIG_ACPI_CPPC_LIB
+#include <acpi/cppc_acpi.h>
+
+static void cpu_read_corecnt(void *val)
+{
+       *(u64 *)val = read_corecnt();
+}
+
+static void cpu_read_constcnt(void *val)
+{
+       *(u64 *)val = read_constcnt();
+}
+
+static inline
+int counters_read_on_cpu(int cpu, smp_call_func_t func, u64 *val)
+{
+       /*
+        * Abort call on counterless CPU or when interrupts are
+        * disabled - can lead to deadlock in smp sync call.
+        */
+       if (!cpu_has_amu_feat(cpu))
+               return -EOPNOTSUPP;
+
+       if (WARN_ON_ONCE(irqs_disabled()))
+               return -EPERM;
+
+       smp_call_function_single(cpu, func, val, 1);
+
+       return 0;
+}
+
+/*
+ * Refer to drivers/acpi/cppc_acpi.c for the description of the functions
+ * below.
+ */
+bool cpc_ffh_supported(void)
+{
+       return freq_counters_valid(get_cpu_with_amu_feat());
+}
+
+int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
+{
+       int ret = -EOPNOTSUPP;
+
+       switch ((u64)reg->address) {
+       case 0x0:
+               ret = counters_read_on_cpu(cpu, cpu_read_corecnt, val);
+               break;
+       case 0x1:
+               ret = counters_read_on_cpu(cpu, cpu_read_constcnt, val);
+               break;
+       }
+
+       if (!ret) {
+               *val &= GENMASK_ULL(reg->bit_offset + reg->bit_width - 1,
+                                   reg->bit_offset);
+               *val >>= reg->bit_offset;
+       }
+
+       return ret;
+}
+
+int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
+{
+       return -EOPNOTSUPP;
+}
+#endif /* CONFIG_ACPI_CPPC_LIB */
index 2059d8f43f55f05d9bd93ca3515043f4ae0dcf44..08156be755691d6cb7dd239119326ef4a3904b87 100644 (file)
@@ -171,32 +171,32 @@ static void arm64_show_signal(int signo, const char *str)
        __show_regs(regs);
 }
 
-void arm64_force_sig_fault(int signo, int code, void __user *addr,
+void arm64_force_sig_fault(int signo, int code, unsigned long far,
                           const char *str)
 {
        arm64_show_signal(signo, str);
        if (signo == SIGKILL)
                force_sig(SIGKILL);
        else
-               force_sig_fault(signo, code, addr);
+               force_sig_fault(signo, code, (void __user *)far);
 }
 
-void arm64_force_sig_mceerr(int code, void __user *addr, short lsb,
+void arm64_force_sig_mceerr(int code, unsigned long far, short lsb,
                            const char *str)
 {
        arm64_show_signal(SIGBUS, str);
-       force_sig_mceerr(code, addr, lsb);
+       force_sig_mceerr(code, (void __user *)far, lsb);
 }
 
-void arm64_force_sig_ptrace_errno_trap(int errno, void __user *addr,
+void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far,
                                       const char *str)
 {
        arm64_show_signal(SIGTRAP, str);
-       force_sig_ptrace_errno_trap(errno, addr);
+       force_sig_ptrace_errno_trap(errno, (void __user *)far);
 }
 
 void arm64_notify_die(const char *str, struct pt_regs *regs,
-                     int signo, int sicode, void __user *addr,
+                     int signo, int sicode, unsigned long far,
                      int err)
 {
        if (user_mode(regs)) {
@@ -204,7 +204,7 @@ void arm64_notify_die(const char *str, struct pt_regs *regs,
                current->thread.fault_address = 0;
                current->thread.fault_code = err;
 
-               arm64_force_sig_fault(signo, sicode, addr, str);
+               arm64_force_sig_fault(signo, sicode, far, str);
        } else {
                die(str, regs, err);
        }
@@ -375,7 +375,7 @@ void force_signal_inject(int signal, int code, unsigned long address, unsigned i
                signal = SIGKILL;
        }
 
-       arm64_notify_die(desc, regs, signal, code, (void __user *)address, err);
+       arm64_notify_die(desc, regs, signal, code, address, err);
 }
 
 /*
@@ -386,7 +386,7 @@ void arm64_notify_segfault(unsigned long addr)
        int code;
 
        mmap_read_lock(current->mm);
-       if (find_vma(current->mm, addr) == NULL)
+       if (find_vma(current->mm, untagged_addr(addr)) == NULL)
                code = SEGV_MAPERR;
        else
                code = SEGV_ACCERR;
@@ -449,12 +449,13 @@ NOKPROBE_SYMBOL(do_ptrauth_fault);
 
 static void user_cache_maint_handler(unsigned int esr, struct pt_regs *regs)
 {
-       unsigned long address;
+       unsigned long tagged_address, address;
        int rt = ESR_ELx_SYS64_ISS_RT(esr);
        int crm = (esr & ESR_ELx_SYS64_ISS_CRM_MASK) >> ESR_ELx_SYS64_ISS_CRM_SHIFT;
        int ret = 0;
 
-       address = untagged_addr(pt_regs_read_reg(regs, rt));
+       tagged_address = pt_regs_read_reg(regs, rt);
+       address = untagged_addr(tagged_address);
 
        switch (crm) {
        case ESR_ELx_SYS64_ISS_CRM_DC_CVAU:     /* DC CVAU, gets promoted */
@@ -481,7 +482,7 @@ static void user_cache_maint_handler(unsigned int esr, struct pt_regs *regs)
        }
 
        if (ret)
-               arm64_notify_segfault(address);
+               arm64_notify_segfault(tagged_address);
        else
                arm64_skip_faulting_instruction(regs, AARCH64_INSN_SIZE);
 }
@@ -775,7 +776,7 @@ asmlinkage void notrace bad_mode(struct pt_regs *regs, int reason, unsigned int
  */
 void bad_el0_sync(struct pt_regs *regs, int reason, unsigned int esr)
 {
-       void __user *pc = (void __user *)instruction_pointer(regs);
+       unsigned long pc = instruction_pointer(regs);
 
        current->thread.fault_address = 0;
        current->thread.fault_code = esr;
index d65f52264abaeb9edb0566037665a0e970f49ade..a8f8e409e2bfbcdd2a9c0318eb41465570a83882 100644 (file)
@@ -28,7 +28,7 @@ ldflags-y := -shared -nostdlib -soname=linux-vdso.so.1 --hash-style=sysv      \
             $(btildflags-y) -T
 
 ccflags-y := -fno-common -fno-builtin -fno-stack-protector -ffixed-x18
-ccflags-y += -DDISABLE_BRANCH_PROFILING
+ccflags-y += -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
 
 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) $(GCC_PLUGINS_CFLAGS)
 KASAN_SANITIZE                 := n
index 79280c53b9a616953eead419df59948c5f7e13a5..a1e0f91e6cea649a6527b367b16618c356905918 100644 (file)
@@ -48,7 +48,7 @@ cc32-as-instr = $(call try-run,\
 # As a result we set our own flags here.
 
 # KBUILD_CPPFLAGS and NOSTDINC_FLAGS from top-level Makefile
-VDSO_CPPFLAGS := -D__KERNEL__ -nostdinc -isystem $(shell $(CC_COMPAT) -print-file-name=include)
+VDSO_CPPFLAGS := -DBUILD_VDSO -D__KERNEL__ -nostdinc -isystem $(shell $(CC_COMPAT) -print-file-name=include)
 VDSO_CPPFLAGS += $(LINUXINCLUDE)
 
 # Common C and assembly flags
index 1bda604f4c704bd22f810c02fcacd60d720c43e4..5d5857c5b025e3c1943dfa21afd8c057d95800dd 100644 (file)
@@ -121,7 +121,7 @@ SECTIONS
                _text = .;
                HEAD_TEXT
        }
-       .text : {                       /* Real text segment            */
+       .text : ALIGN(SEGMENT_ALIGN) {  /* Real text segment            */
                _stext = .;             /* Text and read-only data      */
                        IRQENTRY_TEXT
                        SOFTIRQENTRY_TEXT
@@ -164,13 +164,11 @@ SECTIONS
        . += PAGE_SIZE;
 #endif
 
-#ifdef CONFIG_ARM64_SW_TTBR0_PAN
-       reserved_ttbr0 = .;
-       . += RESERVED_TTBR0_SIZE;
-#endif
+       reserved_pg_dir = .;
+       . += PAGE_SIZE;
+
        swapper_pg_dir = .;
        . += PAGE_SIZE;
-       swapper_pg_end = .;
 
        . = ALIGN(SEGMENT_ALIGN);
        __init_begin = .;
@@ -201,7 +199,7 @@ SECTIONS
                INIT_CALLS
                CON_INITCALL
                INIT_RAM_FS
-               *(.init.rodata.* .init.bss)     /* from the EFI stub */
+               *(.init.altinstructions .init.bss)      /* from the EFI stub */
        }
        .exit.data : {
                EXIT_DATA
index 8f8fca47abfc0ebdfc0b4b4635bc1d2dc5d0f28f..5750ec34960e9426ae03a66e9c0af94c5738c070 100644 (file)
@@ -808,6 +808,25 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
 
                preempt_enable();
 
+               /*
+                * The ARMv8 architecture doesn't give the hypervisor
+                * a mechanism to prevent a guest from dropping to AArch32 EL0
+                * if implemented by the CPU. If we spot the guest in such
+                * state and that we decided it wasn't supposed to do so (like
+                * with the asymmetric AArch32 case), return to userspace with
+                * a fatal error.
+                */
+               if (!system_supports_32bit_el0() && vcpu_mode_is_32bit(vcpu)) {
+                       /*
+                        * As we have caught the guest red-handed, decide that
+                        * it isn't fit for purpose anymore by making the vcpu
+                        * invalid. The VMM can try and fix it by issuing  a
+                        * KVM_ARM_VCPU_INIT if it really wants to.
+                        */
+                       vcpu->arch.target = -1;
+                       ret = ARM_EXCEPTION_IL;
+               }
+
                ret = handle_exit(vcpu, ret);
        }
 
index ff9a0f547b9f0ea78ccd87ff289772b3fdb4db0d..ed27f06a31ba2bbb46db322525cc3bdb55e3f916 100644 (file)
@@ -17,8 +17,6 @@ SYM_FUNC_START(__host_exit)
 
        get_host_ctxt   x0, x1
 
-       ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN)
-
        /* Store the host regs x2 and x3 */
        stp     x2, x3,   [x0, #CPU_XREG_OFFSET(2)]
 
index 47224dc62c51f5c9df1061ecf49665ea6cbc6e72..b11a9d7db677db887f306d4f801a2bdb37cdcb1d 100644 (file)
@@ -57,16 +57,25 @@ __do_hyp_init:
        cmp     x0, #HVC_STUB_HCALL_NR
        b.lo    __kvm_handle_stub_hvc
 
-       /* Set tpidr_el2 for use by HYP to free a register */
-       msr     tpidr_el2, x2
-
-       mov     x2, #KVM_HOST_SMCCC_FUNC(__kvm_hyp_init)
-       cmp     x0, x2
-       b.eq    1f
+       // We only actively check bits [24:31], and everything
+       // else has to be zero, which we check at build time.
+#if (KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) & 0xFFFFFFFF00FFFFFF)
+#error Unexpected __KVM_HOST_SMCCC_FUNC___kvm_hyp_init value
+#endif
+
+       ror     x0, x0, #24
+       eor     x0, x0, #((KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) >> 24) & 0xF)
+       ror     x0, x0, #4
+       eor     x0, x0, #((KVM_HOST_SMCCC_FUNC(__kvm_hyp_init) >> 28) & 0xF)
+       cbz     x0, 1f
        mov     x0, #SMCCC_RET_NOT_SUPPORTED
        eret
 
-1:     phys_to_ttbr x0, x1
+1:
+       /* Set tpidr_el2 for use by HYP to free a register */
+       msr     tpidr_el2, x2
+
+       phys_to_ttbr x0, x1
 alternative_if ARM64_HAS_CNP
        orr     x0, x0, #TTBR_CNP_BIT
 alternative_else_nop_endif
index 39ca71ab88664755d4a0ef8774ec19971035cea7..fbde89a2c6e838d0ad9cbcb9029130b789bf2360 100644 (file)
@@ -128,7 +128,6 @@ void __kvm_tlb_flush_local_vmid(struct kvm_s2_mmu *mmu)
        struct tlb_inv_context cxt;
 
        /* Switch to requested VMID */
-       mmu = kern_hyp_va(mmu);
        __tlb_switch_to_guest(mmu, &cxt);
 
        __tlbi(vmalle1);
index 0cdf6e461cbd257df4932a40ad23da04385fb47c..0271b4a3b9fe183aba1d075f7fda832b52723ff3 100644 (file)
@@ -635,7 +635,7 @@ static void stage2_flush_dcache(void *addr, u64 size)
 
 static bool stage2_pte_cacheable(kvm_pte_t pte)
 {
-       u64 memattr = FIELD_GET(KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR, pte);
+       u64 memattr = pte & KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR;
        return memattr == PAGE_S2_MEMATTR(NORMAL);
 }
 
@@ -846,7 +846,7 @@ int kvm_pgtable_stage2_init(struct kvm_pgtable *pgt, struct kvm *kvm)
        u32 start_level = VTCR_EL2_TGRAN_SL0_BASE - sl0;
 
        pgd_sz = kvm_pgd_pages(ia_bits, start_level) * PAGE_SIZE;
-       pgt->pgd = alloc_pages_exact(pgd_sz, GFP_KERNEL | __GFP_ZERO);
+       pgt->pgd = alloc_pages_exact(pgd_sz, GFP_KERNEL_ACCOUNT | __GFP_ZERO);
        if (!pgt->pgd)
                return -ENOMEM;
 
index 19aacc7d64deaf42f3c9bf774c5c920af8f0566c..1a01da9fdc99cd11a9912c31e4893d94cf070cb4 100644 (file)
@@ -787,14 +787,28 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                vma_shift = PAGE_SHIFT;
        }
 
-       if (vma_shift == PUD_SHIFT &&
-           !fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
-              vma_shift = PMD_SHIFT;
-
-       if (vma_shift == PMD_SHIFT &&
-           !fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) {
-               force_pte = true;
+       switch (vma_shift) {
+#ifndef __PAGETABLE_PMD_FOLDED
+       case PUD_SHIFT:
+               if (fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
+                       break;
+               fallthrough;
+#endif
+       case CONT_PMD_SHIFT:
+               vma_shift = PMD_SHIFT;
+               fallthrough;
+       case PMD_SHIFT:
+               if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE))
+                       break;
+               fallthrough;
+       case CONT_PTE_SHIFT:
                vma_shift = PAGE_SHIFT;
+               force_pte = true;
+               fallthrough;
+       case PAGE_SHIFT:
+               break;
+       default:
+               WARN_ONCE(1, "Unknown vma_shift %d", vma_shift);
        }
 
        vma_pagesize = 1UL << vma_shift;
@@ -839,6 +853,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 
        if (kvm_is_device_pfn(pfn)) {
                device = true;
+               force_pte = true;
        } else if (logging_active && !write_fault) {
                /*
                 * Only actually map the page as writable if this was a write
index 41348a7781d94c23d80b678e4a25a00233563ca5..fb12d3ef423ad04cfc7c5b734c52e8382780811d 100644 (file)
@@ -1897,9 +1897,9 @@ static const struct sys_reg_desc cp14_regs[] = {
        { Op1( 0), CRn( 0), CRm( 1), Op2( 0), trap_raz_wi },
        DBG_BCR_BVR_WCR_WVR(1),
        /* DBGDCCINT */
-       { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32 },
+       { Op1( 0), CRn( 0), CRm( 2), Op2( 0), trap_debug32, NULL, cp14_DBGDCCINT },
        /* DBGDSCRext */
-       { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32 },
+       { Op1( 0), CRn( 0), CRm( 2), Op2( 2), trap_debug32, NULL, cp14_DBGDSCRext },
        DBG_BCR_BVR_WCR_WVR(2),
        /* DBGDTR[RT]Xint */
        { Op1( 0), CRn( 0), CRm( 3), Op2( 0), trap_raz_wi },
@@ -1914,7 +1914,7 @@ static const struct sys_reg_desc cp14_regs[] = {
        { Op1( 0), CRn( 0), CRm( 6), Op2( 2), trap_raz_wi },
        DBG_BCR_BVR_WCR_WVR(6),
        /* DBGVCR */
-       { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32 },
+       { Op1( 0), CRn( 0), CRm( 7), Op2( 0), trap_debug32, NULL, cp14_DBGVCR },
        DBG_BCR_BVR_WCR_WVR(7),
        DBG_BCR_BVR_WCR_WVR(8),
        DBG_BCR_BVR_WCR_WVR(9),
index 48a3a26eff663589a18c3944eff17d1240f66822..af9afcbec92cd8080734c9f50288ab0ca32549f5 100644 (file)
@@ -24,20 +24,20 @@ SYM_FUNC_START(__arch_clear_user)
        subs    x1, x1, #8
        b.mi    2f
 1:
-uao_user_alternative 9f, str, sttr, xzr, x0, 8
+user_ldst 9f, sttr, xzr, x0, 8
        subs    x1, x1, #8
        b.pl    1b
 2:     adds    x1, x1, #4
        b.mi    3f
-uao_user_alternative 9f, str, sttr, wzr, x0, 4
+user_ldst 9f, sttr, wzr, x0, 4
        sub     x1, x1, #4
 3:     adds    x1, x1, #2
        b.mi    4f
-uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
+user_ldst 9f, sttrh, wzr, x0, 2
        sub     x1, x1, #2
 4:     adds    x1, x1, #1
        b.mi    5f
-uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
+user_ldst 9f, sttrb, wzr, x0, 0
 5:     mov     x0, #0
        ret
 SYM_FUNC_END(__arch_clear_user)
index 0f8a3a9e3795b64b6cb0e53c0953e3b1833884e4..95cd62d6737113aaaf18454b4c1ff677966c48e3 100644 (file)
@@ -21,7 +21,7 @@
  */
 
        .macro ldrb1 reg, ptr, val
-       uao_user_alternative 9998f, ldrb, ldtrb, \reg, \ptr, \val
+       user_ldst 9998f, ldtrb, \reg, \ptr, \val
        .endm
 
        .macro strb1 reg, ptr, val
@@ -29,7 +29,7 @@
        .endm
 
        .macro ldrh1 reg, ptr, val
-       uao_user_alternative 9998f, ldrh, ldtrh, \reg, \ptr, \val
+       user_ldst 9998f, ldtrh, \reg, \ptr, \val
        .endm
 
        .macro strh1 reg, ptr, val
@@ -37,7 +37,7 @@
        .endm
 
        .macro ldr1 reg, ptr, val
-       uao_user_alternative 9998f, ldr, ldtr, \reg, \ptr, \val
+       user_ldst 9998f, ldtr, \reg, \ptr, \val
        .endm
 
        .macro str1 reg, ptr, val
@@ -45,7 +45,7 @@
        .endm
 
        .macro ldp1 reg1, reg2, ptr, val
-       uao_ldp 9998f, \reg1, \reg2, \ptr, \val
+       user_ldp 9998f, \reg1, \reg2, \ptr, \val
        .endm
 
        .macro stp1 reg1, reg2, ptr, val
index 80e37ada0ee1a501d5d4fb9fe87db9fc5853af2b..1f61cd0df0627bf8d6c9f9746e140eca8ae8f624 100644 (file)
  *     x0 - bytes not copied
  */
        .macro ldrb1 reg, ptr, val
-       uao_user_alternative 9998f, ldrb, ldtrb, \reg, \ptr, \val
+       user_ldst 9998f, ldtrb, \reg, \ptr, \val
        .endm
 
        .macro strb1 reg, ptr, val
-       uao_user_alternative 9998f, strb, sttrb, \reg, \ptr, \val
+       user_ldst 9998f, sttrb, \reg, \ptr, \val
        .endm
 
        .macro ldrh1 reg, ptr, val
-       uao_user_alternative 9998f, ldrh, ldtrh, \reg, \ptr, \val
+       user_ldst 9998f, ldtrh, \reg, \ptr, \val
        .endm
 
        .macro strh1 reg, ptr, val
-       uao_user_alternative 9998f, strh, sttrh, \reg, \ptr, \val
+       user_ldst 9998f, sttrh, \reg, \ptr, \val
        .endm
 
        .macro ldr1 reg, ptr, val
-       uao_user_alternative 9998f, ldr, ldtr, \reg, \ptr, \val
+       user_ldst 9998f, ldtr, \reg, \ptr, \val
        .endm
 
        .macro str1 reg, ptr, val
-       uao_user_alternative 9998f, str, sttr, \reg, \ptr, \val
+       user_ldst 9998f, sttr, \reg, \ptr, \val
        .endm
 
        .macro ldp1 reg1, reg2, ptr, val
-       uao_ldp 9998f, \reg1, \reg2, \ptr, \val
+       user_ldp 9998f, \reg1, \reg2, \ptr, \val
        .endm
 
        .macro stp1 reg1, reg2, ptr, val
-       uao_stp 9998f, \reg1, \reg2, \ptr, \val
+       user_stp 9998f, \reg1, \reg2, \ptr, \val
        .endm
 
 end    .req    x5
index 4ec59704b8f2d19933ec1f39ca48e76315309609..043da90f5dd7dffef07ca1914e60ecd7bbb8bcd4 100644 (file)
@@ -24,7 +24,7 @@
        .endm
 
        .macro strb1 reg, ptr, val
-       uao_user_alternative 9998f, strb, sttrb, \reg, \ptr, \val
+       user_ldst 9998f, sttrb, \reg, \ptr, \val
        .endm
 
        .macro ldrh1 reg, ptr, val
@@ -32,7 +32,7 @@
        .endm
 
        .macro strh1 reg, ptr, val
-       uao_user_alternative 9998f, strh, sttrh, \reg, \ptr, \val
+       user_ldst 9998f, sttrh, \reg, \ptr, \val
        .endm
 
        .macro ldr1 reg, ptr, val
@@ -40,7 +40,7 @@
        .endm
 
        .macro str1 reg, ptr, val
-       uao_user_alternative 9998f, str, sttr, \reg, \ptr, \val
+       user_ldst 9998f, sttr, \reg, \ptr, \val
        .endm
 
        .macro ldp1 reg1, reg2, ptr, val
@@ -48,7 +48,7 @@
        .endm
 
        .macro stp1 reg1, reg2, ptr, val
-       uao_stp 9998f, \reg1, \reg2, \ptr, \val
+       user_stp 9998f, \reg1, \reg2, \ptr, \val
        .endm
 
 end    .req    x5
index 03ca6d8b8670692dc18994fe348ab4ed0d2100fb..351537c12f36eac5826adce7d74ac24942e03d36 100644 (file)
@@ -4,7 +4,7 @@
  */
 #include <linux/linkage.h>
 
-#include <asm/alternative.h>
+#include <asm/asm-uaccess.h>
 #include <asm/assembler.h>
 #include <asm/mte.h>
 #include <asm/page.h>
@@ -67,7 +67,7 @@ SYM_FUNC_START(mte_copy_tags_from_user)
        mov     x3, x1
        cbz     x2, 2f
 1:
-       uao_user_alternative 2f, ldrb, ldtrb, w4, x1, 0
+       user_ldst 2f, ldtrb, w4, x1, 0
        lsl     x4, x4, #MTE_TAG_SHIFT
        stg     x4, [x0], #MTE_GRANULE_SIZE
        add     x1, x1, #1
@@ -94,7 +94,7 @@ SYM_FUNC_START(mte_copy_tags_to_user)
 1:
        ldg     x4, [x1]
        ubfx    x4, x4, #MTE_TAG_SHIFT, #MTE_TAG_SIZE
-       uao_user_alternative 2f, strb, sttrb, w4, x0, 0
+       user_ldst 2f, sttrb, w4, x0, 0
        add     x0, x0, #1
        add     x1, x1, #MTE_GRANULE_SIZE
        subs    x2, x2, #1
index bfa30b75b2b8e628f00502e911409b3116a7930e..c83bb5a4aad2c53ed2cc32029f34d50fdd97e1ed 100644 (file)
@@ -30,9 +30,7 @@ unsigned long __copy_user_flushcache(void *to, const void __user *from,
 {
        unsigned long rc;
 
-       uaccess_enable_not_uao();
-       rc = __arch_copy_from_user(to, from, n);
-       uaccess_disable_not_uao();
+       rc = raw_copy_from_user(to, from, n);
 
        /* See above */
        __clean_dcache_area_pop(to, n - rc);
index 795d224f184ff2ce63d8427f5e70d4a9a89fd4ef..2848952b178d618c81d49a9575a132548912f94d 100644 (file)
@@ -40,7 +40,7 @@
 #include <asm/traps.h>
 
 struct fault_info {
-       int     (*fn)(unsigned long addr, unsigned int esr,
+       int     (*fn)(unsigned long far, unsigned int esr,
                      struct pt_regs *regs);
        int     sig;
        int     code;
@@ -385,8 +385,11 @@ static void set_thread_esr(unsigned long address, unsigned int esr)
        current->thread.fault_code = esr;
 }
 
-static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+static void do_bad_area(unsigned long far, unsigned int esr,
+                       struct pt_regs *regs)
 {
+       unsigned long addr = untagged_addr(far);
+
        /*
         * If we are in kernel mode at this point, we have no context to
         * handle this fault with.
@@ -395,8 +398,7 @@ static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *re
                const struct fault_info *inf = esr_to_fault_info(esr);
 
                set_thread_esr(addr, esr);
-               arm64_force_sig_fault(inf->sig, inf->code, (void __user *)addr,
-                                     inf->name);
+               arm64_force_sig_fault(inf->sig, inf->code, far, inf->name);
        } else {
                __do_kernel_fault(addr, esr, regs);
        }
@@ -448,7 +450,7 @@ static bool is_write_abort(unsigned int esr)
        return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM);
 }
 
-static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
+static int __kprobes do_page_fault(unsigned long far, unsigned int esr,
                                   struct pt_regs *regs)
 {
        const struct fault_info *inf;
@@ -456,6 +458,7 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
        vm_fault_t fault;
        unsigned long vm_flags = VM_ACCESS_FLAGS;
        unsigned int mm_flags = FAULT_FLAG_DEFAULT;
+       unsigned long addr = untagged_addr(far);
 
        if (kprobe_page_fault(regs, esr))
                return 0;
@@ -479,11 +482,6 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
        }
 
        if (is_ttbr0_addr(addr) && is_el1_permission_fault(addr, esr, regs)) {
-               /* regs->orig_addr_limit may be 0 if we entered from EL0 */
-               if (regs->orig_addr_limit == KERNEL_DS)
-                       die_kernel_fault("access to user memory with fs=KERNEL_DS",
-                                        addr, esr, regs);
-
                if (is_el1_instruction_abort(esr))
                        die_kernel_fault("execution of user memory",
                                         addr, esr, regs);
@@ -567,8 +565,7 @@ retry:
                 * We had some memory, but were unable to successfully fix up
                 * this page fault.
                 */
-               arm64_force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)addr,
-                                     inf->name);
+               arm64_force_sig_fault(SIGBUS, BUS_ADRERR, far, inf->name);
        } else if (fault & (VM_FAULT_HWPOISON_LARGE | VM_FAULT_HWPOISON)) {
                unsigned int lsb;
 
@@ -576,8 +573,7 @@ retry:
                if (fault & VM_FAULT_HWPOISON_LARGE)
                        lsb = hstate_index_to_shift(VM_FAULT_GET_HINDEX(fault));
 
-               arm64_force_sig_mceerr(BUS_MCEERR_AR, (void __user *)addr, lsb,
-                                      inf->name);
+               arm64_force_sig_mceerr(BUS_MCEERR_AR, far, lsb, inf->name);
        } else {
                /*
                 * Something tried to access memory that isn't in our memory
@@ -585,8 +581,7 @@ retry:
                 */
                arm64_force_sig_fault(SIGSEGV,
                                      fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR,
-                                     (void __user *)addr,
-                                     inf->name);
+                                     far, inf->name);
        }
 
        return 0;
@@ -596,33 +591,35 @@ no_context:
        return 0;
 }
 
-static int __kprobes do_translation_fault(unsigned long addr,
+static int __kprobes do_translation_fault(unsigned long far,
                                          unsigned int esr,
                                          struct pt_regs *regs)
 {
+       unsigned long addr = untagged_addr(far);
+
        if (is_ttbr0_addr(addr))
-               return do_page_fault(addr, esr, regs);
+               return do_page_fault(far, esr, regs);
 
-       do_bad_area(addr, esr, regs);
+       do_bad_area(far, esr, regs);
        return 0;
 }
 
-static int do_alignment_fault(unsigned long addr, unsigned int esr,
+static int do_alignment_fault(unsigned long far, unsigned int esr,
                              struct pt_regs *regs)
 {
-       do_bad_area(addr, esr, regs);
+       do_bad_area(far, esr, regs);
        return 0;
 }
 
-static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+static int do_bad(unsigned long far, unsigned int esr, struct pt_regs *regs)
 {
        return 1; /* "fault" */
 }
 
-static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+static int do_sea(unsigned long far, unsigned int esr, struct pt_regs *regs)
 {
        const struct fault_info *inf;
-       void __user *siaddr;
+       unsigned long siaddr;
 
        inf = esr_to_fault_info(esr);
 
@@ -634,19 +631,30 @@ static int do_sea(unsigned long addr, unsigned int esr, struct pt_regs *regs)
                return 0;
        }
 
-       if (esr & ESR_ELx_FnV)
-               siaddr = NULL;
-       else
-               siaddr  = (void __user *)addr;
+       if (esr & ESR_ELx_FnV) {
+               siaddr = 0;
+       } else {
+               /*
+                * The architecture specifies that the tag bits of FAR_EL1 are
+                * UNKNOWN for synchronous external aborts. Mask them out now
+                * so that userspace doesn't see them.
+                */
+               siaddr  = untagged_addr(far);
+       }
        arm64_notify_die(inf->name, regs, inf->sig, inf->code, siaddr, esr);
 
        return 0;
 }
 
-static int do_tag_check_fault(unsigned long addr, unsigned int esr,
+static int do_tag_check_fault(unsigned long far, unsigned int esr,
                              struct pt_regs *regs)
 {
-       do_bad_area(addr, esr, regs);
+       /*
+        * The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN for tag
+        * check faults. Mask them out now so that userspace doesn't see them.
+        */
+       far &= (1UL << 60) - 1;
+       do_bad_area(far, esr, regs);
        return 0;
 }
 
@@ -717,11 +725,12 @@ static const struct fault_info fault_info[] = {
        { do_bad,               SIGKILL, SI_KERNEL,     "unknown 63"                    },
 };
 
-void do_mem_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs)
+void do_mem_abort(unsigned long far, unsigned int esr, struct pt_regs *regs)
 {
        const struct fault_info *inf = esr_to_fault_info(esr);
+       unsigned long addr = untagged_addr(far);
 
-       if (!inf->fn(addr, esr, regs))
+       if (!inf->fn(far, esr, regs))
                return;
 
        if (!user_mode(regs)) {
@@ -730,8 +739,12 @@ void do_mem_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs)
                show_pte(addr);
        }
 
-       arm64_notify_die(inf->name, regs,
-                        inf->sig, inf->code, (void __user *)addr, esr);
+       /*
+        * At this point we have an unrecognized fault type whose tag bits may
+        * have been defined as UNKNOWN. Therefore we only expose the untagged
+        * address to the signal handler.
+        */
+       arm64_notify_die(inf->name, regs, inf->sig, inf->code, addr, esr);
 }
 NOKPROBE_SYMBOL(do_mem_abort);
 
@@ -744,8 +757,8 @@ NOKPROBE_SYMBOL(do_el0_irq_bp_hardening);
 
 void do_sp_pc_abort(unsigned long addr, unsigned int esr, struct pt_regs *regs)
 {
-       arm64_notify_die("SP/PC alignment exception", regs,
-                        SIGBUS, BUS_ADRALN, (void __user *)addr, esr);
+       arm64_notify_die("SP/PC alignment exception", regs, SIGBUS, BUS_ADRALN,
+                        addr, esr);
 }
 NOKPROBE_SYMBOL(do_sp_pc_abort);
 
@@ -846,8 +859,7 @@ void do_debug_exception(unsigned long addr_if_watchpoint, unsigned int esr,
                arm64_apply_bp_hardening();
 
        if (inf->fn(addr_if_watchpoint, esr, regs)) {
-               arm64_notify_die(inf->name, regs,
-                                inf->sig, inf->code, (void __user *)pc, esr);
+               arm64_notify_die(inf->name, regs, inf->sig, inf->code, pc, esr);
        }
 
        debug_exception_exit(regs);
index 095540667f0fdd7ed408202264ffd57d5c22d0da..fbd452e12397b6d8198ca0b3b6bd9385917ee328 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
 #include <linux/hugetlb.h>
+#include <linux/acpi_iort.h>
 
 #include <asm/boot.h>
 #include <asm/fixmap.h>
@@ -42,8 +43,6 @@
 #include <asm/tlb.h>
 #include <asm/alternative.h>
 
-#define ARM64_ZONE_DMA_BITS    30
-
 /*
  * We need to be able to catch inadvertent references to memstart_addr
  * that occur (potentially in generic code) before arm64_memblock_init()
@@ -175,21 +174,34 @@ static void __init reserve_elfcorehdr(void)
 #endif /* CONFIG_CRASH_DUMP */
 
 /*
- * Return the maximum physical address for a zone with a given address size
- * limit. It currently assumes that for memory starting above 4G, 32-bit
- * devices will use a DMA offset.
+ * Return the maximum physical address for a zone accessible by the given bits
+ * limit. If DRAM starts above 32-bit, expand the zone to the maximum
+ * available memory, otherwise cap it at 32-bit.
  */
 static phys_addr_t __init max_zone_phys(unsigned int zone_bits)
 {
-       phys_addr_t offset = memblock_start_of_DRAM() & GENMASK_ULL(63, zone_bits);
-       return min(offset + (1ULL << zone_bits), memblock_end_of_DRAM());
+       phys_addr_t zone_mask = DMA_BIT_MASK(zone_bits);
+       phys_addr_t phys_start = memblock_start_of_DRAM();
+
+       if (phys_start > U32_MAX)
+               zone_mask = PHYS_ADDR_MAX;
+       else if (phys_start > zone_mask)
+               zone_mask = U32_MAX;
+
+       return min(zone_mask, memblock_end_of_DRAM() - 1) + 1;
 }
 
 static void __init zone_sizes_init(unsigned long min, unsigned long max)
 {
        unsigned long max_zone_pfns[MAX_NR_ZONES]  = {0};
+       unsigned int __maybe_unused acpi_zone_dma_bits;
+       unsigned int __maybe_unused dt_zone_dma_bits;
 
 #ifdef CONFIG_ZONE_DMA
+       acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address());
+       dt_zone_dma_bits = fls64(of_dma_get_max_cpu_address(NULL));
+       zone_dma_bits = min3(32U, dt_zone_dma_bits, acpi_zone_dma_bits);
+       arm64_dma_phys_limit = max_zone_phys(zone_dma_bits);
        max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit);
 #endif
 #ifdef CONFIG_ZONE_DMA32
@@ -269,7 +281,7 @@ static void __init fdt_enforce_memory_region(void)
 
 void __init arm64_memblock_init(void)
 {
-       const s64 linear_region_size = BIT(vabits_actual - 1);
+       const s64 linear_region_size = PAGE_END - _PAGE_OFFSET(vabits_actual);
 
        /* Handle linux,usable-memory-range property */
        fdt_enforce_memory_region();
@@ -348,15 +360,18 @@ void __init arm64_memblock_init(void)
 
        if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
                extern u16 memstart_offset_seed;
-               u64 range = linear_region_size -
-                           (memblock_end_of_DRAM() - memblock_start_of_DRAM());
+               u64 mmfr0 = read_cpuid(ID_AA64MMFR0_EL1);
+               int parange = cpuid_feature_extract_unsigned_field(
+                                       mmfr0, ID_AA64MMFR0_PARANGE_SHIFT);
+               s64 range = linear_region_size -
+                           BIT(id_aa64mmfr0_parange_to_phys_shift(parange));
 
                /*
                 * If the size of the linear region exceeds, by a sufficient
-                * margin, the size of the region that the available physical
-                * memory spans, randomize the linear region as well.
+                * margin, the size of the region that the physical memory can
+                * span, randomize the linear region as well.
                 */
-               if (memstart_offset_seed > 0 && range >= ARM64_MEMSTART_ALIGN) {
+               if (memstart_offset_seed > 0 && range >= (s64)ARM64_MEMSTART_ALIGN) {
                        range /= ARM64_MEMSTART_ALIGN;
                        memstart_addr -= ARM64_MEMSTART_ALIGN *
                                         ((range * memstart_offset_seed) >> 16);
@@ -367,7 +382,7 @@ void __init arm64_memblock_init(void)
         * Register the kernel text, kernel data, initrd, and initial
         * pagetables with memblock.
         */
-       memblock_reserve(__pa_symbol(_text), _end - _text);
+       memblock_reserve(__pa_symbol(_stext), _end - _stext);
        if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && phys_initrd_size) {
                /* the generic initrd code expects virtual addresses */
                initrd_start = __phys_to_virt(phys_initrd_start);
@@ -376,18 +391,11 @@ void __init arm64_memblock_init(void)
 
        early_init_fdt_scan_reserved_mem();
 
-       if (IS_ENABLED(CONFIG_ZONE_DMA)) {
-               zone_dma_bits = ARM64_ZONE_DMA_BITS;
-               arm64_dma_phys_limit = max_zone_phys(ARM64_ZONE_DMA_BITS);
-       }
-
        if (IS_ENABLED(CONFIG_ZONE_DMA32))
                arm64_dma32_phys_limit = max_zone_phys(32);
        else
                arm64_dma32_phys_limit = PHYS_MASK + 1;
 
-       reserve_crashkernel();
-
        reserve_elfcorehdr();
 
        high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
@@ -427,6 +435,12 @@ void __init bootmem_init(void)
        sparse_init();
        zone_sizes_init(min, max);
 
+       /*
+        * request_standard_resources() depends on crashkernel's memory being
+        * reserved, so do it here.
+        */
+       reserve_crashkernel();
+
        memblock_dump_all();
 }
 
index ca692a8157315dda46557a3962cc3df6d121f439..ae0c3d023824e070fbd4d29d73e2dc2def64a785 100644 (file)
@@ -464,20 +464,35 @@ void __init mark_linear_text_alias_ro(void)
        /*
         * Remove the write permissions from the linear alias of .text/.rodata
         */
-       update_mapping_prot(__pa_symbol(_text), (unsigned long)lm_alias(_text),
-                           (unsigned long)__init_begin - (unsigned long)_text,
+       update_mapping_prot(__pa_symbol(_stext), (unsigned long)lm_alias(_stext),
+                           (unsigned long)__init_begin - (unsigned long)_stext,
                            PAGE_KERNEL_RO);
 }
 
+static bool crash_mem_map __initdata;
+
+static int __init enable_crash_mem_map(char *arg)
+{
+       /*
+        * Proper parameter parsing is done by reserve_crashkernel(). We only
+        * need to know if the linear map has to avoid block mappings so that
+        * the crashkernel reservations can be unmapped later.
+        */
+       crash_mem_map = true;
+
+       return 0;
+}
+early_param("crashkernel", enable_crash_mem_map);
+
 static void __init map_mem(pgd_t *pgdp)
 {
-       phys_addr_t kernel_start = __pa_symbol(_text);
+       phys_addr_t kernel_start = __pa_symbol(_stext);
        phys_addr_t kernel_end = __pa_symbol(__init_begin);
        phys_addr_t start, end;
        int flags = 0;
        u64 i;
 
-       if (rodata_full || debug_pagealloc_enabled())
+       if (rodata_full || crash_mem_map || debug_pagealloc_enabled())
                flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
 
        /*
@@ -487,11 +502,6 @@ static void __init map_mem(pgd_t *pgdp)
         * the following for-loop
         */
        memblock_mark_nomap(kernel_start, kernel_end - kernel_start);
-#ifdef CONFIG_KEXEC_CORE
-       if (crashk_res.end)
-               memblock_mark_nomap(crashk_res.start,
-                                   resource_size(&crashk_res));
-#endif
 
        /* map all the memory banks */
        for_each_mem_range(i, &start, &end) {
@@ -506,7 +516,7 @@ static void __init map_mem(pgd_t *pgdp)
        }
 
        /*
-        * Map the linear alias of the [_text, __init_begin) interval
+        * Map the linear alias of the [_stext, __init_begin) interval
         * as non-executable now, and remove the write permission in
         * mark_linear_text_alias_ro() below (which will be called after
         * alternative patching has completed). This makes the contents
@@ -518,21 +528,6 @@ static void __init map_mem(pgd_t *pgdp)
        __map_memblock(pgdp, kernel_start, kernel_end,
                       PAGE_KERNEL, NO_CONT_MAPPINGS);
        memblock_clear_nomap(kernel_start, kernel_end - kernel_start);
-
-#ifdef CONFIG_KEXEC_CORE
-       /*
-        * Use page-level mappings here so that we can shrink the region
-        * in page granularity and put back unused memory to buddy system
-        * through /sys/kernel/kexec_crash_size interface.
-        */
-       if (crashk_res.end) {
-               __map_memblock(pgdp, crashk_res.start, crashk_res.end + 1,
-                              PAGE_KERNEL,
-                              NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS);
-               memblock_clear_nomap(crashk_res.start,
-                                    resource_size(&crashk_res));
-       }
-#endif
 }
 
 void mark_rodata_ro(void)
@@ -665,7 +660,7 @@ static void __init map_kernel(pgd_t *pgdp)
         * Only rodata will be remapped with different permissions later on,
         * all other segments are allowed to use contiguous mappings.
         */
-       map_kernel_segment(pgdp, _text, _etext, text_prot, &vmlinux_text, 0,
+       map_kernel_segment(pgdp, _stext, _etext, text_prot, &vmlinux_text, 0,
                           VM_NO_GUARD);
        map_kernel_segment(pgdp, __start_rodata, __inittext_begin, PAGE_KERNEL,
                           &vmlinux_rodata, NO_CONT_MAPPINGS, VM_NO_GUARD);
@@ -1132,8 +1127,11 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
                        void *p = NULL;
 
                        p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap);
-                       if (!p)
-                               return -ENOMEM;
+                       if (!p) {
+                               if (vmemmap_populate_basepages(addr, next, node, altmap))
+                                       return -ENOMEM;
+                               continue;
+                       }
 
                        pmd_set_huge(pmdp, __pa(p), __pgprot(PROT_SECT_NORMAL));
                } else
@@ -1510,13 +1508,43 @@ static int prevent_bootmem_remove_notifier(struct notifier_block *nb,
        unsigned long end_pfn = arg->start_pfn + arg->nr_pages;
        unsigned long pfn = arg->start_pfn;
 
-       if (action != MEM_GOING_OFFLINE)
+       if ((action != MEM_GOING_OFFLINE) && (action != MEM_OFFLINE))
                return NOTIFY_OK;
 
        for (; pfn < end_pfn; pfn += PAGES_PER_SECTION) {
+               unsigned long start = PFN_PHYS(pfn);
+               unsigned long end = start + (1UL << PA_SECTION_SHIFT);
+
                ms = __pfn_to_section(pfn);
-               if (early_section(ms))
+               if (!early_section(ms))
+                       continue;
+
+               if (action == MEM_GOING_OFFLINE) {
+                       /*
+                        * Boot memory removal is not supported. Prevent
+                        * it via blocking any attempted offline request
+                        * for the boot memory and just report it.
+                        */
+                       pr_warn("Boot memory [%lx %lx] offlining attempted\n", start, end);
                        return NOTIFY_BAD;
+               } else if (action == MEM_OFFLINE) {
+                       /*
+                        * This should have never happened. Boot memory
+                        * offlining should have been prevented by this
+                        * very notifier. Probably some memory removal
+                        * procedure might have changed which would then
+                        * require further debug.
+                        */
+                       pr_err("Boot memory [%lx %lx] offlined\n", start, end);
+
+                       /*
+                        * Core memory hotplug does not process a return
+                        * code from the notifier for MEM_OFFLINE events.
+                        * The error condition has been reported. Return
+                        * from here as if ignored.
+                        */
+                       return NOTIFY_DONE;
+               }
        }
        return NOTIFY_OK;
 }
@@ -1525,9 +1553,66 @@ static struct notifier_block prevent_bootmem_remove_nb = {
        .notifier_call = prevent_bootmem_remove_notifier,
 };
 
+/*
+ * This ensures that boot memory sections on the platform are online
+ * from early boot. Memory sections could not be prevented from being
+ * offlined, unless for some reason they are not online to begin with.
+ * This helps validate the basic assumption on which the above memory
+ * event notifier works to prevent boot memory section offlining and
+ * its possible removal.
+ */
+static void validate_bootmem_online(void)
+{
+       phys_addr_t start, end, addr;
+       struct mem_section *ms;
+       u64 i;
+
+       /*
+        * Scanning across all memblock might be expensive
+        * on some big memory systems. Hence enable this
+        * validation only with DEBUG_VM.
+        */
+       if (!IS_ENABLED(CONFIG_DEBUG_VM))
+               return;
+
+       for_each_mem_range(i, &start, &end) {
+               for (addr = start; addr < end; addr += (1UL << PA_SECTION_SHIFT)) {
+                       ms = __pfn_to_section(PHYS_PFN(addr));
+
+                       /*
+                        * All memory ranges in the system at this point
+                        * should have been marked as early sections.
+                        */
+                       WARN_ON(!early_section(ms));
+
+                       /*
+                        * Memory notifier mechanism here to prevent boot
+                        * memory offlining depends on the fact that each
+                        * early section memory on the system is initially
+                        * online. Otherwise a given memory section which
+                        * is already offline will be overlooked and can
+                        * be removed completely. Call out such sections.
+                        */
+                       if (!online_section(ms))
+                               pr_err("Boot memory [%llx %llx] is offline, can be removed\n",
+                                       addr, addr + (1UL << PA_SECTION_SHIFT));
+               }
+       }
+}
+
 static int __init prevent_bootmem_remove_init(void)
 {
-       return register_memory_notifier(&prevent_bootmem_remove_nb);
+       int ret = 0;
+
+       if (!IS_ENABLED(CONFIG_MEMORY_HOTREMOVE))
+               return ret;
+
+       validate_bootmem_online();
+       ret = register_memory_notifier(&prevent_bootmem_remove_nb);
+       if (ret)
+               pr_err("%s: Notifier registration failed %d\n", __func__, ret);
+
+       return ret;
 }
-device_initcall(prevent_bootmem_remove_init);
+early_initcall(prevent_bootmem_remove_init);
 #endif
index 23c326a06b2d40cde5dbdc1cf491a1441766a82e..a0831bf8a018205e0d5191795a22c5f0af87866a 100644 (file)
@@ -40,7 +40,7 @@
 #define TCR_CACHE_FLAGS        TCR_IRGN_WBWA | TCR_ORGN_WBWA
 
 #ifdef CONFIG_KASAN_SW_TAGS
-#define TCR_KASAN_FLAGS TCR_TBI1
+#define TCR_KASAN_FLAGS TCR_TBI1 | TCR_TBID1
 #else
 #define TCR_KASAN_FLAGS 0
 #endif
@@ -168,7 +168,7 @@ SYM_FUNC_END(cpu_do_resume)
        .pushsection ".idmap.text", "awx"
 
 .macro __idmap_cpu_set_reserved_ttbr1, tmp1, tmp2
-       adrp    \tmp1, empty_zero_page
+       adrp    \tmp1, reserved_pg_dir
        phys_to_ttbr \tmp2, \tmp1
        offset_ttbr1 \tmp2, \tmp1
        msr     ttbr1_el1, \tmp2
@@ -489,6 +489,6 @@ SYM_FUNC_START(__cpu_setup)
        /*
         * Prepare SCTLR
         */
-       mov_q   x0, SCTLR_EL1_SET
+       mov_q   x0, INIT_SCTLR_EL1_MMU_ON
        ret                                     // return to head.S
 SYM_FUNC_END(__cpu_setup)
index e155210373487eab9c1c655de2d1559dae28d5c7..2cd0dce2b6a67d4f21623223e6643858b2946164 100644 (file)
@@ -57,30 +57,6 @@ typedef unsigned long sigset_t;
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002 /* not supported yet */
-#define SA_SIGINFO     0x00000004
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define SA_RESTORER    0x04000000
 
 #define MINSIGSTKSZ    2048
index aa98ff1b9e228baef39845a8195cab1e119cdef5..38166a88e4c96cdc8047a00d93d8343ab37722f6 100644 (file)
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002
-#define SA_SIGINFO     0x00000004
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define SA_RESTORER    0x04000000
 
 /*
index 915cc755a1841c5172ea103191af77149788a18a..4619291df601ff946bde7ff1b164ea10867c178f 100644 (file)
@@ -57,30 +57,6 @@ typedef unsigned long sigset_t;
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002
-#define SA_SIGINFO     0x00000004
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
index 53104b10aae2e8fe753f4bcbfcdd72fa1f7ae435..e6c78a15cb2f115efe9322342b22283b6914bd8b 100644 (file)
@@ -62,18 +62,6 @@ typedef unsigned long old_sigset_t;          /* at least 32 bits */
 #define SIGRTMAX       _NSIG
 
 /*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- *
  * SA_RESTORER used to be defined as 0x04000000 but only the O32 ABI ever
  * supported its use and no libc was using it, so the entire sa-restorer
  * functionality was removed with lmo commit 39bffc12c3580ab for 2.5.48
index 715c96ba2ec81c2907ead07ffd21fbf79a0fb0cb..30dd1e43ef8845d5f25571c279cba51b6cd3ab19 100644 (file)
@@ -21,6 +21,8 @@ typedef struct {
        unsigned long sig[_NSIG_WORDS];
 } sigset_t;
 
+#define __ARCH_UAPI_SA_FLAGS   _SA_SIGGFAULT
+
 #include <asm/sigcontext.h>
 
 #endif /* !__ASSEMBLY */
index e605197b462cf1b982dd1f2759e908a0ec667048..e5a2657477ac9fecf91e0608c0a9cbccbd0ca44a 100644 (file)
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
 #define SA_ONSTACK     0x00000001
 #define SA_RESETHAND   0x00000004
 #define SA_NOCLDSTOP   0x00000008
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
 
-
-#define SIG_BLOCK          0   /* for blocking signals */
-#define SIG_UNBLOCK        1   /* for unblocking signals */
-#define SIG_SETMASK        2   /* for setting the signal mask */
-
-#define SIG_DFL        ((__sighandler_t)0)     /* default signal handling */
-#define SIG_IGN        ((__sighandler_t)1)     /* ignore signal */
-#define SIG_ERR        ((__sighandler_t)-1)    /* error return from signal */
+#include <asm-generic/signal-defs.h>
 
 # ifndef __ASSEMBLY__
 
 /* Avoid too many header ordering problems.  */
 struct siginfo;
 
-/* Type of a signal handler.  */
-#if defined(__LP64__)
-/* function pointers on 64-bit parisc are pointers to little structs and the
- * compiler doesn't support code which changes or tests the address of
- * the function in the little struct.  This is really ugly -PB
- */
-typedef char __user *__sighandler_t;
-#else
-typedef void __signalfn_t(int);
-typedef __signalfn_t __user *__sighandler_t;
-#endif
-
 typedef struct sigaltstack {
        void __user *ss_sp;
        int ss_flags;
index 85ed2390fb99587e5f2fbcabb8954ab4e1b4dd1f..567cdc55740241c653c56f3e5f37b4fc2a178098 100644 (file)
@@ -63,7 +63,7 @@ static inline void restore_user_access(unsigned long flags)
 static inline bool
 bad_kuap_fault(struct pt_regs *regs, unsigned long address, bool is_write)
 {
-       return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xf0000000),
+       return WARN(!((regs->kuap ^ MD_APG_KUAP) & 0xff000000),
                    "Bug: fault blocked by AP register !");
 }
 
index 1d9ac0f9c794416dade15930995cb4f645fcc375..0bd1b144eb76851de95267b8737f14b6ff7359a0 100644 (file)
  * respectively NA for All or X for Supervisor and no access for User.
  * Then we use the APG to say whether accesses are according to Page rules or
  * "all Supervisor" rules (Access to all)
- * Therefore, we define 2 APG groups. lsb is _PMD_USER
- * 0 => Kernel => 01 (all accesses performed according to page definition)
- * 1 => User => 00 (all accesses performed as supervisor iaw page definition)
- * 2-15 => Not Used
- */
-#define MI_APG_INIT    0x40000000
-
-/*
- * 0 => Kernel => 01 (all accesses performed according to page definition)
- * 1 => User => 10 (all accesses performed according to swaped page definition)
- * 2-15 => Not Used
- */
-#define MI_APG_KUEP    0x60000000
+ * _PAGE_ACCESSED is also managed via APG. When _PAGE_ACCESSED is not set, say
+ * "all User" rules, that will lead to NA for all.
+ * Therefore, we define 4 APG groups. lsb is _PAGE_ACCESSED
+ * 0 => Kernel => 11 (all accesses performed according as user iaw page definition)
+ * 1 => Kernel+Accessed => 01 (all accesses performed according to page definition)
+ * 2 => User => 11 (all accesses performed according as user iaw page definition)
+ * 3 => User+Accessed => 00 (all accesses performed as supervisor iaw page definition) for INIT
+ *                    => 10 (all accesses performed according to swaped page definition) for KUEP
+ * 4-15 => Not Used
+ */
+#define MI_APG_INIT    0xdc000000
+#define MI_APG_KUEP    0xde000000
 
 /* The effective page number register.  When read, contains the information
  * about the last instruction TLB miss.  When MI_RPN is written, bits in
 #define MD_Ks          0x80000000      /* Should not be set */
 #define MD_Kp          0x40000000      /* Should always be set */
 
-/*
- * All pages' PP data bits are set to either 000 or 011 or 001, which means
- * respectively RW for Supervisor and no access for User, or RO for
- * Supervisor and no access for user and NA for ALL.
- * Then we use the APG to say whether accesses are according to Page rules or
- * "all Supervisor" rules (Access to all)
- * Therefore, we define 2 APG groups. lsb is _PMD_USER
- * 0 => Kernel => 01 (all accesses performed according to page definition)
- * 1 => User => 00 (all accesses performed as supervisor iaw page definition)
- * 2-15 => Not Used
- */
-#define MD_APG_INIT    0x40000000
-
-/*
- * 0 => No user => 01 (all accesses performed according to page definition)
- * 1 => User => 10 (all accesses performed according to swaped page definition)
- * 2-15 => Not Used
- */
-#define MD_APG_KUAP    0x60000000
+/* See explanation above at the definition of MI_APG_INIT */
+#define MD_APG_INIT    0xdc000000
+#define MD_APG_KUAP    0xde000000
 
 /* The effective page number register.  When read, contains the information
  * about the last instruction TLB miss.  When MD_RPN is written, bits in
index 66f403a7da44c4e1021e8fd7281ac056edeb146d..1581204467e1de1a685fd00b5a2ed9432383bd68 100644 (file)
@@ -39,9 +39,9 @@
  * into the TLB.
  */
 #define _PAGE_GUARDED  0x0010  /* Copied to L1 G entry in DTLB */
-#define _PAGE_SPECIAL  0x0020  /* SW entry */
+#define _PAGE_ACCESSED 0x0020  /* Copied to L1 APG 1 entry in I/DTLB */
 #define _PAGE_EXEC     0x0040  /* Copied to PP (bit 21) in ITLB */
-#define _PAGE_ACCESSED 0x0080  /* software: page referenced */
+#define _PAGE_SPECIAL  0x0080  /* SW entry */
 
 #define _PAGE_NA       0x0200  /* Supervisor NA, User no access */
 #define _PAGE_RO       0x0600  /* Supervisor RO, User no access */
 
 #define _PMD_PRESENT   0x0001
 #define _PMD_PRESENT_MASK      _PMD_PRESENT
-#define _PMD_BAD       0x0fd0
+#define _PMD_BAD       0x0f90
 #define _PMD_PAGE_MASK 0x000c
 #define _PMD_PAGE_8M   0x000c
 #define _PMD_PAGE_512K 0x0004
-#define _PMD_USER      0x0020  /* APG 1 */
+#define _PMD_ACCESSED  0x0020  /* APG 1 */
+#define _PMD_USER      0x0040  /* APG 2 */
 
 #define _PTE_NONE_MASK 0
 
index 8728590f514a8ccf3421ec75266d7657e64cb759..3beeb030cd78e9bbcababbf4de178c588fbe0eee 100644 (file)
@@ -6,6 +6,7 @@
 
 struct device;
 struct device_node;
+struct drmem_lmb;
 
 #ifdef CONFIG_NUMA
 
@@ -61,6 +62,9 @@ static inline int early_cpu_to_node(int cpu)
         */
        return (nid < 0) ? 0 : nid;
 }
+
+int of_drconf_to_nid_single(struct drmem_lmb *lmb);
+
 #else
 
 static inline int early_cpu_to_node(int cpu) { return 0; }
@@ -84,10 +88,12 @@ static inline int cpu_distance(__be32 *cpu1_assoc, __be32 *cpu2_assoc)
        return 0;
 }
 
-#endif /* CONFIG_NUMA */
+static inline int of_drconf_to_nid_single(struct drmem_lmb *lmb)
+{
+       return first_online_node;
+}
 
-struct drmem_lmb;
-int of_drconf_to_nid_single(struct drmem_lmb *lmb);
+#endif /* CONFIG_NUMA */
 
 #if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
 extern int find_and_online_cpu_nid(int cpu);
index ef5bbb705c08b7b12a7c11451305f2a64d8b5266..501c9a79038c081fbecfbd9fa1f13ada323f8f79 100644 (file)
@@ -178,7 +178,7 @@ do {                                                                \
  * are no aliasing issues.
  */
 #define __put_user_asm_goto(x, addr, label, op)                        \
-       asm volatile goto(                                      \
+       asm_volatile_goto(                                      \
                "1:     " op "%U1%X1 %0,%1      # put_user\n"   \
                EX_TABLE(1b, %l2)                               \
                :                                               \
@@ -191,7 +191,7 @@ do {                                                                \
        __put_user_asm_goto(x, ptr, label, "std")
 #else /* __powerpc64__ */
 #define __put_user_asm2_goto(x, addr, label)                   \
-       asm volatile goto(                                      \
+       asm_volatile_goto(                                      \
                "1:     stw%X1 %0, %1\n"                        \
                "2:     stw%X1 %L0, %L1\n"                      \
                EX_TABLE(1b, %l2)                               \
index 85b0a7aa43e7ef02067644c260ae2c3075547847..04873dd311c2af91963d9bd796e850ee296b78c6 100644 (file)
@@ -60,30 +60,6 @@ typedef struct {
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK is not currently supported, but will allow sigaltstack(2).
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001U
-#define SA_NOCLDWAIT   0x00000002U
-#define SA_SIGINFO     0x00000004U
-#define SA_ONSTACK     0x08000000U
-#define SA_RESTART     0x10000000U
-#define SA_NODEFER     0x40000000U
-#define SA_RESETHAND   0x80000000U
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define SA_RESTORER    0x04000000U
 
 #define MINSIGSTKSZ    2048
index 6b50bf15d8c19123181d1298cd35c3d3d3ff1e09..bf3270426d82d6569d48fedb0fefbbf7d1061b06 100644 (file)
@@ -264,8 +264,9 @@ static int eeh_addr_cache_show(struct seq_file *s, void *v)
 {
        struct pci_io_addr_range *piar;
        struct rb_node *n;
+       unsigned long flags;
 
-       spin_lock(&pci_io_addr_cache_root.piar_lock);
+       spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
        for (n = rb_first(&pci_io_addr_cache_root.rb_root); n; n = rb_next(n)) {
                piar = rb_entry(n, struct pci_io_addr_range, rb_node);
 
@@ -273,7 +274,7 @@ static int eeh_addr_cache_show(struct seq_file *s, void *v)
                       (piar->flags & IORESOURCE_IO) ? "i/o" : "mem",
                       &piar->addr_lo, &piar->addr_hi, pci_name(piar->pcidev));
        }
-       spin_unlock(&pci_io_addr_cache_root.piar_lock);
+       spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
 
        return 0;
 }
index 44c9018aed1b08bb380a0f980c1c5f3675c420f3..a1ae00689e0f4898d17a6782a9e82afc7756edd7 100644 (file)
@@ -284,11 +284,7 @@ _ENTRY(saved_ksp_limit)
 
        rlwimi  r11, r10, 22, 20, 29    /* Compute PTE address */
        lwz     r11, 0(r11)             /* Get Linux PTE */
-#ifdef CONFIG_SWAP
        li      r9, _PAGE_PRESENT | _PAGE_ACCESSED
-#else
-       li      r9, _PAGE_PRESENT
-#endif
        andc.   r9, r9, r11             /* Check permission */
        bne     5f
 
@@ -369,11 +365,7 @@ _ENTRY(saved_ksp_limit)
 
        rlwimi  r11, r10, 22, 20, 29    /* Compute PTE address */
        lwz     r11, 0(r11)             /* Get Linux PTE */
-#ifdef CONFIG_SWAP
        li      r9, _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
-#else
-       li      r9, _PAGE_PRESENT | _PAGE_EXEC
-#endif
        andc.   r9, r9, r11             /* Check permission */
        bne     5f
 
index 9f359d3fba749230d03ac883083f69ff30f09b70..ee0bfebc375f26237919173698761c593e939347 100644 (file)
@@ -202,9 +202,7 @@ SystemCall:
 
 InstructionTLBMiss:
        mtspr   SPRN_SPRG_SCRATCH0, r10
-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)
        mtspr   SPRN_SPRG_SCRATCH1, r11
-#endif
 
        /* If we are faulting a kernel address, we have to use the
         * kernel page tables.
@@ -224,25 +222,13 @@ InstructionTLBMiss:
 3:
        mtcr    r11
 #endif
-#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)
        lwz     r11, (swapper_pg_dir-PAGE_OFFSET)@l(r10)        /* Get level 1 entry */
        mtspr   SPRN_MD_TWC, r11
-#else
-       lwz     r10, (swapper_pg_dir-PAGE_OFFSET)@l(r10)        /* Get level 1 entry */
-       mtspr   SPRN_MI_TWC, r10        /* Set segment attributes */
-       mtspr   SPRN_MD_TWC, r10
-#endif
        mfspr   r10, SPRN_MD_TWC
        lwz     r10, 0(r10)     /* Get the pte */
-#if defined(CONFIG_HUGETLBFS) || !defined(CONFIG_PIN_TLB_TEXT)
+       rlwimi  r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
        rlwimi  r11, r10, 32 - 9, _PMD_PAGE_512K
        mtspr   SPRN_MI_TWC, r11
-#endif
-#ifdef CONFIG_SWAP
-       rlwinm  r11, r10, 32-5, _PAGE_PRESENT
-       and     r11, r11, r10
-       rlwimi  r10, r11, 0, _PAGE_PRESENT
-#endif
        /* The Linux PTE won't go exactly into the MMU TLB.
         * Software indicator bits 20 and 23 must be clear.
         * Software indicator bits 22, 24, 25, 26, and 27 must be
@@ -256,9 +242,7 @@ InstructionTLBMiss:
 
        /* Restore registers */
 0:     mfspr   r10, SPRN_SPRG_SCRATCH0
-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS)
        mfspr   r11, SPRN_SPRG_SCRATCH1
-#endif
        rfi
        patch_site      0b, patch__itlbmiss_exit_1
 
@@ -268,9 +252,7 @@ InstructionTLBMiss:
        addi    r10, r10, 1
        stw     r10, (itlb_miss_counter - PAGE_OFFSET)@l(0)
        mfspr   r10, SPRN_SPRG_SCRATCH0
-#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP)
        mfspr   r11, SPRN_SPRG_SCRATCH1
-#endif
        rfi
 #endif
 
@@ -297,30 +279,16 @@ DataStoreTLBMiss:
        mfspr   r10, SPRN_MD_TWC
        lwz     r10, 0(r10)     /* Get the pte */
 
-       /* Insert the Guarded flag into the TWC from the Linux PTE.
+       /* Insert Guarded and Accessed flags into the TWC from the Linux PTE.
         * It is bit 27 of both the Linux PTE and the TWC (at least
         * I got that right :-).  It will be better when we can put
         * this into the Linux pgd/pmd and load it in the operation
         * above.
         */
-       rlwimi  r11, r10, 0, _PAGE_GUARDED
+       rlwimi  r11, r10, 0, _PAGE_GUARDED | _PAGE_ACCESSED
        rlwimi  r11, r10, 32 - 9, _PMD_PAGE_512K
        mtspr   SPRN_MD_TWC, r11
 
-       /* Both _PAGE_ACCESSED and _PAGE_PRESENT has to be set.
-        * We also need to know if the insn is a load/store, so:
-        * Clear _PAGE_PRESENT and load that which will
-        * trap into DTLB Error with store bit set accordinly.
-        */
-       /* PRESENT=0x1, ACCESSED=0x20
-        * r11 = ((r10 & PRESENT) & ((r10 & ACCESSED) >> 5));
-        * r10 = (r10 & ~PRESENT) | r11;
-        */
-#ifdef CONFIG_SWAP
-       rlwinm  r11, r10, 32-5, _PAGE_PRESENT
-       and     r11, r11, r10
-       rlwimi  r10, r11, 0, _PAGE_PRESENT
-#endif
        /* The Linux PTE won't go exactly into the MMU TLB.
         * Software indicator bits 24, 25, 26, and 27 must be
         * set.  All other Linux PTE bits control the behavior
@@ -711,7 +679,7 @@ initial_mmu:
        li      r9, 4                           /* up to 4 pages of 8M */
        mtctr   r9
        lis     r9, KERNELBASE@h                /* Create vaddr for TLB */
-       li      r10, MI_PS8MEG | MI_SVALID      /* Set 8M byte page */
+       li      r10, MI_PS8MEG | _PMD_ACCESSED | MI_SVALID
        li      r11, MI_BOOTINIT                /* Create RPN for address 0 */
 1:
        mtspr   SPRN_MI_CTR, r8 /* Set instruction MMU control */
@@ -775,7 +743,7 @@ _GLOBAL(mmu_pin_tlb)
 #ifdef CONFIG_PIN_TLB_TEXT
        LOAD_REG_IMMEDIATE(r5, 28 << 8)
        LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
-       LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)
+       LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
        LOAD_REG_IMMEDIATE(r8, 0xf0 | _PAGE_RO | _PAGE_SPS | _PAGE_SH | _PAGE_PRESENT)
        LOAD_REG_ADDR(r9, _sinittext)
        li      r0, 4
@@ -797,7 +765,7 @@ _GLOBAL(mmu_pin_tlb)
        LOAD_REG_IMMEDIATE(r5, 28 << 8 | MD_TWAM)
 #ifdef CONFIG_PIN_TLB_DATA
        LOAD_REG_IMMEDIATE(r6, PAGE_OFFSET)
-       LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG)
+       LOAD_REG_IMMEDIATE(r7, MI_SVALID | MI_PS8MEG | _PMD_ACCESSED)
 #ifdef CONFIG_PIN_TLB_IMMR
        li      r0, 3
 #else
@@ -834,7 +802,7 @@ _GLOBAL(mmu_pin_tlb)
 #endif
 #ifdef CONFIG_PIN_TLB_IMMR
        LOAD_REG_IMMEDIATE(r0, VIRT_IMMR_BASE | MD_EVALID)
-       LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED)
+       LOAD_REG_IMMEDIATE(r7, MD_SVALID | MD_PS512K | MD_GUARDED | _PMD_ACCESSED)
        mfspr   r8, SPRN_IMMR
        rlwinm  r8, r8, 0, 0xfff80000
        ori     r8, r8, 0xf0 | _PAGE_DIRTY | _PAGE_SPS | _PAGE_SH | \
index 5eb9eedac920034e43de70e6e2a1b998f8209983..2aa16d5368e1f1b643b2160f0b4b40df6409b554 100644 (file)
@@ -457,11 +457,7 @@ InstructionTLBMiss:
        cmplw   0,r1,r3
 #endif
        mfspr   r2, SPRN_SPRG_PGDIR
-#ifdef CONFIG_SWAP
        li      r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
-#else
-       li      r1,_PAGE_PRESENT | _PAGE_EXEC
-#endif
 #if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC)
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
@@ -523,11 +519,7 @@ DataLoadTLBMiss:
        lis     r1, TASK_SIZE@h         /* check if kernel address */
        cmplw   0,r1,r3
        mfspr   r2, SPRN_SPRG_PGDIR
-#ifdef CONFIG_SWAP
        li      r1, _PAGE_PRESENT | _PAGE_ACCESSED
-#else
-       li      r1, _PAGE_PRESENT
-#endif
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
        addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
@@ -603,11 +595,7 @@ DataStoreTLBMiss:
        lis     r1, TASK_SIZE@h         /* check if kernel address */
        cmplw   0,r1,r3
        mfspr   r2, SPRN_SPRG_PGDIR
-#ifdef CONFIG_SWAP
        li      r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED
-#else
-       li      r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT
-#endif
        bgt-    112f
        lis     r2, (swapper_pg_dir - PAGE_OFFSET)@ha   /* if kernel address, use */
        addi    r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l        /* kernel page table */
index 3c6b9822f9789b7524fe1cb29c17350986b851ae..8c2857cbd96097b25a3105ad533df080b50f534a 100644 (file)
@@ -1393,13 +1393,14 @@ static void add_cpu_to_masks(int cpu)
 /* Activate a secondary processor. */
 void start_secondary(void *unused)
 {
-       unsigned int cpu = smp_processor_id();
+       unsigned int cpu = raw_smp_processor_id();
 
        mmgrab(&init_mm);
        current->active_mm = &init_mm;
 
        smp_store_cpu_info(cpu);
        set_dec(tb_ticks_per_jiffy);
+       rcu_cpu_starting(cpu);
        preempt_disable();
        cpu_callin_map[cpu] = 1;
 
index c47e6b35c551f4a8500d3bd3200528b46ce3a034..824b2c9da75bd2095274c2ef73933944cc900845 100644 (file)
@@ -476,7 +476,7 @@ do {                                                                        \
 do {                                                                   \
        long __kr_err;                                                  \
                                                                        \
-       __put_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err);  \
+       __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err);  \
        if (unlikely(__kr_err))                                         \
                goto err_label;                                         \
 } while (0)
index 99e12faa54986a3c32e26b6dc34ee4cf8f45b22c..765b62434f303d2c99f63b82be3799725b82e5dc 100644 (file)
@@ -1,4 +1,4 @@
-/* SPDX-License-Identifier: GPL-2.0 */
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2013 Linaro Limited
  * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
index 11e2a4fe66e0af9bb0650cf2156432f9c965fad6..7e849797c9c38ddc81311787dcf5188ba9de7a02 100644 (file)
@@ -35,12 +35,17 @@ ENTRY(_start)
        .word 0
 #endif
        .balign 8
+#ifdef CONFIG_RISCV_M_MODE
+       /* Image load offset (0MB) from start of RAM for M-mode */
+       .dword 0
+#else
 #if __riscv_xlen == 64
        /* Image load offset(2MB) from start of RAM */
        .dword 0x200000
 #else
        /* Image load offset(4MB) from start of RAM */
        .dword 0x400000
+#endif
 #endif
        /* Effective size of kernel image */
        .dword _end - _start
index 11ebee9e4c1d6fdbe684acc3283ff6eade12335e..3a19def868eccd8c5544a6629592be0932204646 100644 (file)
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 vdso.lds
 *.tmp
+vdso-syms.S
index 7d6a94d45ec94190234f74994fffbf3491741732..cb8f9e4cfcbf802baa15a2465d44c860c786cd84 100644 (file)
@@ -43,19 +43,14 @@ $(obj)/vdso.o: $(obj)/vdso.so
 SYSCFLAGS_vdso.so.dbg = $(c_flags)
 $(obj)/vdso.so.dbg: $(src)/vdso.lds $(obj-vdso) FORCE
        $(call if_changed,vdsold)
+SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
+       -Wl,--build-id -Wl,--hash-style=both
 
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO. With ld --just-symbols we can then
 # refer to these symbols in the kernel code rather than hand-coded addresses.
-
-SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
-       -Wl,--build-id=sha1 -Wl,--hash-style=both
-$(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
-       $(call if_changed,vdsold)
-
-LDFLAGS_vdso-syms.o := -r --just-symbols
-$(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
-       $(call if_changed,ld)
+$(obj)/vdso-syms.S: $(obj)/vdso.so FORCE
+       $(call if_changed,so2s)
 
 # strip rule for the .so file
 $(obj)/%.so: OBJCOPYFLAGS := -S
@@ -73,6 +68,11 @@ quiet_cmd_vdsold = VDSOLD  $@
                            $(patsubst %, -G __vdso_%, $(vdso-syms)) $@.tmp $@ && \
                    rm $@.tmp
 
+# Extracts symbol offsets from the VDSO, converting them into an assembly file
+# that contains the same symbols at the same offsets.
+quiet_cmd_so2s = SO2S    $@
+      cmd_so2s = $(NM) -D $< | $(srctree)/$(src)/so2s.sh > $@
+
 # install commands for the unstripped file
 quiet_cmd_vdso_install = INSTALL $@
       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/$@
diff --git a/arch/riscv/kernel/vdso/so2s.sh b/arch/riscv/kernel/vdso/so2s.sh
new file mode 100755 (executable)
index 0000000..e64cb6d
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright 2020 Palmer Dabbelt <palmerdabbelt@google.com>
+
+sed 's!\([0-9a-f]*\) T \([a-z0-9_]*\)\(@@LINUX_4.15\)*!.global \2\n.set \2,0x\1!' \
+| grep '^\.'
index 1359e21c0c62a8d7f4e90e174ee8948e9072aedd..3c8b9e433c673754e29444ffe2e75883c8ce0e99 100644 (file)
@@ -86,6 +86,7 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
        pmd_t *pmd, *pmd_k;
        pte_t *pte_k;
        int index;
+       unsigned long pfn;
 
        /* User mode accesses just cause a SIGSEGV */
        if (user_mode(regs))
@@ -100,7 +101,8 @@ static inline void vmalloc_fault(struct pt_regs *regs, int code, unsigned long a
         * of a task switch.
         */
        index = pgd_index(addr);
-       pgd = (pgd_t *)pfn_to_virt(csr_read(CSR_SATP)) + index;
+       pfn = csr_read(CSR_SATP) & SATP_PPN;
+       pgd = (pgd_t *)pfn_to_virt(pfn) + index;
        pgd_k = init_mm.pgd + index;
 
        if (!pgd_present(*pgd_k)) {
index ea933b789a882f29bec8b1f81892747764b7de3e..8e577f14f1205d67eaf3ec44b0df941a598da0a6 100644 (file)
@@ -154,9 +154,8 @@ disable:
 
 void __init setup_bootmem(void)
 {
-       phys_addr_t mem_size = 0;
-       phys_addr_t total_mem = 0;
-       phys_addr_t mem_start, start, end = 0;
+       phys_addr_t mem_start = 0;
+       phys_addr_t start, end = 0;
        phys_addr_t vmlinux_end = __pa_symbol(&_end);
        phys_addr_t vmlinux_start = __pa_symbol(&_start);
        u64 i;
@@ -164,21 +163,18 @@ void __init setup_bootmem(void)
        /* Find the memory region containing the kernel */
        for_each_mem_range(i, &start, &end) {
                phys_addr_t size = end - start;
-               if (!total_mem)
+               if (!mem_start)
                        mem_start = start;
                if (start <= vmlinux_start && vmlinux_end <= end)
                        BUG_ON(size == 0);
-               total_mem = total_mem + size;
        }
 
        /*
-        * Remove memblock from the end of usable area to the
-        * end of region
+        * The maximal physical memory size is -PAGE_OFFSET.
+        * Make sure that any memory beyond mem_start + (-PAGE_OFFSET) is removed
+        * as it is unusable by kernel.
         */
-       mem_size = min(total_mem, (phys_addr_t)-PAGE_OFFSET);
-       if (mem_start + mem_size < end)
-               memblock_remove(mem_start + mem_size,
-                               end - mem_start - mem_size);
+       memblock_enforce_memory_limit(mem_start - PAGE_OFFSET);
 
        /* Reserve from the start of the kernel to the end of the kernel */
        memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
@@ -297,6 +293,7 @@ pmd_t fixmap_pmd[PTRS_PER_PMD] __page_aligned_bss;
 #define NUM_EARLY_PMDS         (1UL + MAX_EARLY_MAPPING_SIZE / PGDIR_SIZE)
 #endif
 pmd_t early_pmd[PTRS_PER_PMD * NUM_EARLY_PMDS] __initdata __aligned(PAGE_SIZE);
+pmd_t early_dtb_pmd[PTRS_PER_PMD] __initdata __aligned(PAGE_SIZE);
 
 static pmd_t *__init get_pmd_virt_early(phys_addr_t pa)
 {
@@ -494,6 +491,18 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
                                   load_pa + (va - PAGE_OFFSET),
                                   map_size, PAGE_KERNEL_EXEC);
 
+#ifndef __PAGETABLE_PMD_FOLDED
+       /* Setup early PMD for DTB */
+       create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,
+                          (uintptr_t)early_dtb_pmd, PGDIR_SIZE, PAGE_TABLE);
+       /* Create two consecutive PMD mappings for FDT early scan */
+       pa = dtb_pa & ~(PMD_SIZE - 1);
+       create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,
+                          pa, PMD_SIZE, PAGE_KERNEL);
+       create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA + PMD_SIZE,
+                          pa + PMD_SIZE, PMD_SIZE, PAGE_KERNEL);
+       dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PMD_SIZE - 1));
+#else
        /* Create two consecutive PGD mappings for FDT early scan */
        pa = dtb_pa & ~(PGDIR_SIZE - 1);
        create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,
@@ -501,6 +510,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
        create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA + PGDIR_SIZE,
                           pa + PGDIR_SIZE, PGDIR_SIZE, PAGE_KERNEL);
        dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PGDIR_SIZE - 1));
+#endif
        dtb_early_pa = dtb_pa;
 
        /*
index 0784bf3caf43d95a732a0b0b96d418c8b8c15de8..a4d3c578fbd8a3633f65bd7bccfd20b890e71ab5 100644 (file)
@@ -93,9 +93,10 @@ CONFIG_CLEANCACHE=y
 CONFIG_FRONTSWAP=y
 CONFIG_CMA_DEBUG=y
 CONFIG_CMA_DEBUGFS=y
+CONFIG_CMA_AREAS=7
 CONFIG_MEM_SOFT_DIRTY=y
 CONFIG_ZSWAP=y
-CONFIG_ZSMALLOC=m
+CONFIG_ZSMALLOC=y
 CONFIG_ZSMALLOC_STAT=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
 CONFIG_IDLE_PAGE_TRACKING=y
@@ -378,7 +379,6 @@ CONFIG_NETLINK_DIAG=m
 CONFIG_CGROUP_NET_PRIO=y
 CONFIG_BPF_JIT=y
 CONFIG_NET_PKTGEN=m
-# CONFIG_NET_DROP_MONITOR is not set
 CONFIG_PCI=y
 # CONFIG_PCIEASPM is not set
 CONFIG_PCI_DEBUG=y
@@ -386,7 +386,7 @@ CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_S390=y
 CONFIG_DEVTMPFS=y
 CONFIG_CONNECTOR=y
-CONFIG_ZRAM=m
+CONFIG_ZRAM=y
 CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_CRYPTOLOOP=m
 CONFIG_BLK_DEV_DRBD=m
@@ -689,6 +689,7 @@ CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_DH=m
 CONFIG_CRYPTO_ECDH=m
 CONFIG_CRYPTO_ECRDSA=m
+CONFIG_CRYPTO_SM2=m
 CONFIG_CRYPTO_CURVE25519=m
 CONFIG_CRYPTO_GCM=y
 CONFIG_CRYPTO_CHACHA20POLY1305=m
@@ -709,7 +710,6 @@ CONFIG_CRYPTO_RMD160=m
 CONFIG_CRYPTO_RMD256=m
 CONFIG_CRYPTO_RMD320=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_SM3=m
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_AES_TI=m
@@ -753,6 +753,7 @@ CONFIG_CRYPTO_DES_S390=m
 CONFIG_CRYPTO_AES_S390=m
 CONFIG_CRYPTO_GHASH_S390=m
 CONFIG_CRYPTO_CRC32_S390=y
+CONFIG_CRYPTO_DEV_VIRTIO=m
 CONFIG_CORDIC=m
 CONFIG_CRC32_SELFTEST=y
 CONFIG_CRC4=m
@@ -829,6 +830,7 @@ CONFIG_NETDEV_NOTIFIER_ERROR_INJECT=m
 CONFIG_FAULT_INJECTION=y
 CONFIG_FAILSLAB=y
 CONFIG_FAIL_PAGE_ALLOC=y
+CONFIG_FAULT_INJECTION_USERCOPY=y
 CONFIG_FAIL_MAKE_REQUEST=y
 CONFIG_FAIL_IO_TIMEOUT=y
 CONFIG_FAIL_FUTEX=y
index 905bc8c4cfaf5ee63dae4c5646b0ad5ecefa70a3..17d5df2c1eff34833f81fd8d6ad29c39a9aa0ec4 100644 (file)
@@ -87,9 +87,10 @@ CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_CLEANCACHE=y
 CONFIG_FRONTSWAP=y
+CONFIG_CMA_AREAS=7
 CONFIG_MEM_SOFT_DIRTY=y
 CONFIG_ZSWAP=y
-CONFIG_ZSMALLOC=m
+CONFIG_ZSMALLOC=y
 CONFIG_ZSMALLOC_STAT=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
 CONFIG_IDLE_PAGE_TRACKING=y
@@ -371,7 +372,6 @@ CONFIG_NETLINK_DIAG=m
 CONFIG_CGROUP_NET_PRIO=y
 CONFIG_BPF_JIT=y
 CONFIG_NET_PKTGEN=m
-# CONFIG_NET_DROP_MONITOR is not set
 CONFIG_PCI=y
 # CONFIG_PCIEASPM is not set
 CONFIG_HOTPLUG_PCI=y
@@ -379,7 +379,7 @@ CONFIG_HOTPLUG_PCI_S390=y
 CONFIG_UEVENT_HELPER=y
 CONFIG_DEVTMPFS=y
 CONFIG_CONNECTOR=y
-CONFIG_ZRAM=m
+CONFIG_ZRAM=y
 CONFIG_BLK_DEV_LOOP=m
 CONFIG_BLK_DEV_CRYPTOLOOP=m
 CONFIG_BLK_DEV_DRBD=m
@@ -680,6 +680,7 @@ CONFIG_CRYPTO_TEST=m
 CONFIG_CRYPTO_DH=m
 CONFIG_CRYPTO_ECDH=m
 CONFIG_CRYPTO_ECRDSA=m
+CONFIG_CRYPTO_SM2=m
 CONFIG_CRYPTO_CURVE25519=m
 CONFIG_CRYPTO_GCM=y
 CONFIG_CRYPTO_CHACHA20POLY1305=m
@@ -701,7 +702,6 @@ CONFIG_CRYPTO_RMD160=m
 CONFIG_CRYPTO_RMD256=m
 CONFIG_CRYPTO_RMD320=m
 CONFIG_CRYPTO_SHA3=m
-CONFIG_CRYPTO_SM3=m
 CONFIG_CRYPTO_TGR192=m
 CONFIG_CRYPTO_WP512=m
 CONFIG_CRYPTO_AES_TI=m
@@ -745,6 +745,7 @@ CONFIG_CRYPTO_DES_S390=m
 CONFIG_CRYPTO_AES_S390=m
 CONFIG_CRYPTO_GHASH_S390=m
 CONFIG_CRYPTO_CRC32_S390=y
+CONFIG_CRYPTO_DEV_VIRTIO=m
 CONFIG_CORDIC=m
 CONFIG_PRIME_NUMBERS=m
 CONFIG_CRC4=m
index 8f67c55625f9eb0f744ebc529361f6a97d80a4dd..a302630341effc410cbc1587663639f94b75920d 100644 (file)
@@ -17,11 +17,11 @@ CONFIG_HZ_100=y
 # CONFIG_CHSC_SCH is not set
 # CONFIG_SCM_BUS is not set
 CONFIG_CRASH_DUMP=y
-# CONFIG_SECCOMP is not set
 # CONFIG_PFAULT is not set
 # CONFIG_S390_HYPFS_FS is not set
 # CONFIG_VIRTUALIZATION is not set
 # CONFIG_S390_GUEST is not set
+# CONFIG_SECCOMP is not set
 CONFIG_PARTITION_ADVANCED=y
 CONFIG_IBM_PARTITION=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
index 6b8d8c69b1a116a4fb1d8c42f877544697c31713..b5dbae78969b9876dc24c29c22e9a69298b5478b 100644 (file)
@@ -692,16 +692,6 @@ static inline int pud_large(pud_t pud)
        return !!(pud_val(pud) & _REGION3_ENTRY_LARGE);
 }
 
-static inline unsigned long pud_pfn(pud_t pud)
-{
-       unsigned long origin_mask;
-
-       origin_mask = _REGION_ENTRY_ORIGIN;
-       if (pud_large(pud))
-               origin_mask = _REGION3_ENTRY_ORIGIN_LARGE;
-       return (pud_val(pud) & origin_mask) >> PAGE_SHIFT;
-}
-
 #define pmd_leaf       pmd_large
 static inline int pmd_large(pmd_t pmd)
 {
@@ -747,16 +737,6 @@ static inline int pmd_none(pmd_t pmd)
        return pmd_val(pmd) == _SEGMENT_ENTRY_EMPTY;
 }
 
-static inline unsigned long pmd_pfn(pmd_t pmd)
-{
-       unsigned long origin_mask;
-
-       origin_mask = _SEGMENT_ENTRY_ORIGIN;
-       if (pmd_large(pmd))
-               origin_mask = _SEGMENT_ENTRY_ORIGIN_LARGE;
-       return (pmd_val(pmd) & origin_mask) >> PAGE_SHIFT;
-}
-
 #define pmd_write pmd_write
 static inline int pmd_write(pmd_t pmd)
 {
@@ -1238,11 +1218,39 @@ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot)
 #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1))
 #define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
 
-#define pmd_deref(pmd) (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN)
-#define pud_deref(pud) (pud_val(pud) & _REGION_ENTRY_ORIGIN)
 #define p4d_deref(pud) (p4d_val(pud) & _REGION_ENTRY_ORIGIN)
 #define pgd_deref(pgd) (pgd_val(pgd) & _REGION_ENTRY_ORIGIN)
 
+static inline unsigned long pmd_deref(pmd_t pmd)
+{
+       unsigned long origin_mask;
+
+       origin_mask = _SEGMENT_ENTRY_ORIGIN;
+       if (pmd_large(pmd))
+               origin_mask = _SEGMENT_ENTRY_ORIGIN_LARGE;
+       return pmd_val(pmd) & origin_mask;
+}
+
+static inline unsigned long pmd_pfn(pmd_t pmd)
+{
+       return pmd_deref(pmd) >> PAGE_SHIFT;
+}
+
+static inline unsigned long pud_deref(pud_t pud)
+{
+       unsigned long origin_mask;
+
+       origin_mask = _REGION_ENTRY_ORIGIN;
+       if (pud_large(pud))
+               origin_mask = _REGION3_ENTRY_ORIGIN_LARGE;
+       return pud_val(pud) & origin_mask;
+}
+
+static inline unsigned long pud_pfn(pud_t pud)
+{
+       return pud_deref(pud) >> PAGE_SHIFT;
+}
+
 /*
  * The pgd_offset function *always* adds the index for the top-level
  * region/segment table. This is done to get a sequence like the
index a996d3990a02b211ddf6d0c5bb6cab7a9ad798be..0c2151451ba593be330d1252f8609d9c53cb762b 100644 (file)
@@ -26,14 +26,14 @@ static inline int arch_is_kernel_initmem_freed(unsigned long addr)
  * final .boot.data section, which should be identical in the decompressor and
  * the decompressed kernel (that is checked during the build).
  */
-#define __bootdata(var) __section(".boot.data.var") var
+#define __bootdata(var) __section(".boot.data." #var) var
 
 /*
  * .boot.preserved.data is similar to .boot.data, but it is not part of the
  * .init section and thus will be preserved for later use in the decompressed
  * kernel.
  */
-#define __bootdata_preserved(var) __section(".boot.preserved.data.var") var
+#define __bootdata_preserved(var) __section(".boot.preserved.data." #var) var
 
 extern unsigned long __sdma, __edma;
 extern unsigned long __stext_dma, __etext_dma;
diff --git a/arch/s390/include/asm/vdso/vdso.h b/arch/s390/include/asm/vdso/vdso.h
deleted file mode 100644 (file)
index e69de29..0000000
index 9a14a611ed822e70cde1ef86d14bbd979a16eb39..0189f326aac5910cad8556de4df4eaebc3a3d400 100644 (file)
@@ -65,30 +65,6 @@ typedef unsigned long sigset_t;
 #define SIGRTMIN        32
 #define SIGRTMAX        _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP    0x00000001
-#define SA_NOCLDWAIT    0x00000002
-#define SA_SIGINFO      0x00000004
-#define SA_ONSTACK      0x08000000
-#define SA_RESTART      0x10000000
-#define SA_NODEFER      0x40000000
-#define SA_RESETHAND    0x80000000
-
-#define SA_NOMASK       SA_NODEFER
-#define SA_ONESHOT      SA_RESETHAND
-
 #define SA_RESTORER     0x04000000
 
 #define MINSIGSTKSZ     2048
index ece58f2217cbe20d3a10974a607a08b7e8fbdcee..2012c1cf0853aff23a7778afb0fbbb5315883efb 100644 (file)
@@ -61,14 +61,6 @@ int main(void)
        BLANK();
        OFFSET(__VDSO_GETCPU_VAL, vdso_per_cpu_data, getcpu_val);
        BLANK();
-       /* constants used by the vdso */
-       DEFINE(__CLOCK_REALTIME, CLOCK_REALTIME);
-       DEFINE(__CLOCK_MONOTONIC, CLOCK_MONOTONIC);
-       DEFINE(__CLOCK_REALTIME_COARSE, CLOCK_REALTIME_COARSE);
-       DEFINE(__CLOCK_MONOTONIC_COARSE, CLOCK_MONOTONIC_COARSE);
-       DEFINE(__CLOCK_THREAD_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID);
-       DEFINE(__CLOCK_COARSE_RES, LOW_RES_NSEC);
-       BLANK();
        /* idle data offsets */
        OFFSET(__CLOCK_IDLE_ENTER, s390_idle_data, clock_idle_enter);
        OFFSET(__CLOCK_IDLE_EXIT, s390_idle_data, clock_idle_exit);
index ebfe86d097f0afa6c83f8582e1909eeccda6d620..390d97daa2b3ff245f6c216712468072dae6f326 100644 (file)
@@ -855,13 +855,14 @@ void __init smp_detect_cpus(void)
 
 static void smp_init_secondary(void)
 {
-       int cpu = smp_processor_id();
+       int cpu = raw_smp_processor_id();
 
        S390_lowcore.last_update_clock = get_tod_clock();
        restore_access_regs(S390_lowcore.access_regs_save_area);
        set_cpu_flag(CIF_ASCE_PRIMARY);
        set_cpu_flag(CIF_ASCE_SECONDARY);
        cpu_init();
+       rcu_cpu_starting(cpu);
        preempt_disable();
        init_cpu_timer();
        vtime_init();
index d33f21545dfdb82bff668c8092a2a8e58ec069fc..9a6bae503fe61c0b54866bdf1c3d6f5459c44194 100644 (file)
@@ -101,6 +101,10 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
                if (ret)
                        break;
 
+               /* the PCI function will be scanned once function 0 appears */
+               if (!zdev->zbus->bus)
+                       break;
+
                pdev = pci_scan_single_device(zdev->zbus->bus, zdev->devfn);
                if (!pdev)
                        break;
index ff9505923b9abd6ca3c54b5ca0d127e9a8cf1369..53758d53ac0ecc2d2acd1863fd05c506cc0d767c 100644 (file)
@@ -137,13 +137,11 @@ struct sigstack {
 #define SA_STACK       _SV_SSTACK
 #define SA_ONSTACK     _SV_SSTACK
 #define SA_RESTART     _SV_INTR
-#define SA_ONESHOT     _SV_RESET
+#define SA_RESETHAND   _SV_RESET
 #define SA_NODEFER     0x20u
 #define SA_NOCLDWAIT    0x100u
 #define SA_SIGINFO      0x200u
 
-#define SA_NOMASK      SA_NODEFER
-
 #define SIG_BLOCK          0x01        /* for blocking signals */
 #define SIG_UNBLOCK        0x02        /* for unblocking signals */
 #define SIG_SETMASK        0x04        /* for setting the signal mask */
index 95c355181dcdd2e3967b810e9b7299398676d222..bfb70c456b302ad8a19cde1869768e8c208573bf 100644 (file)
@@ -21,7 +21,7 @@
  * on some systems.
  */
 
-void __section(".__syscall_stub")
+void __attribute__ ((__section__ (".__syscall_stub")))
 stub_clone_handler(void)
 {
        struct stub_data *data = (struct stub_data *) STUB_DATA;
index a5e5db6ada3c76c8132be74e420d77771c488e64..39b2eded7bc2b633c8fafa2bce50ed788b054a83 100644 (file)
@@ -164,6 +164,7 @@ void initialize_identity_maps(void *rmode)
        add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE);
 
        /* Load the new page-table. */
+       sev_verify_cbit(top_level_pgt);
        write_cr3(top_level_pgt);
 }
 
index dd07e7b41b115e65e9c762024bd77ae61de35b8f..aa561795efd16182fa185964045ec40571d0b71b 100644 (file)
@@ -68,6 +68,9 @@ SYM_FUNC_START(get_sev_encryption_bit)
 SYM_FUNC_END(get_sev_encryption_bit)
 
        .code64
+
+#include "../../kernel/sev_verify_cbit.S"
+
 SYM_FUNC_START(set_sev_encryption_mask)
 #ifdef CONFIG_AMD_MEM_ENCRYPT
        push    %rbp
@@ -81,6 +84,19 @@ SYM_FUNC_START(set_sev_encryption_mask)
 
        bts     %rax, sme_me_mask(%rip) /* Create the encryption mask */
 
+       /*
+        * Read MSR_AMD64_SEV again and store it to sev_status. Can't do this in
+        * get_sev_encryption_bit() because this function is 32-bit code and
+        * shared between 64-bit and 32-bit boot path.
+        */
+       movl    $MSR_AMD64_SEV, %ecx    /* Read the SEV MSR */
+       rdmsr
+
+       /* Store MSR value in sev_status */
+       shlq    $32, %rdx
+       orq     %rdx, %rax
+       movq    %rax, sev_status(%rip)
+
 .Lno_sev_mask:
        movq    %rbp, %rsp              /* Restore original stack pointer */
 
@@ -96,5 +112,7 @@ SYM_FUNC_END(set_sev_encryption_mask)
 
 #ifdef CONFIG_AMD_MEM_ENCRYPT
        .balign 8
-SYM_DATA(sme_me_mask, .quad 0)
+SYM_DATA(sme_me_mask,          .quad 0)
+SYM_DATA(sev_status,           .quad 0)
+SYM_DATA(sev_check_data,       .quad 0)
 #endif
index 6d31f1b4c4d1085f3bee1d7fc495d29b3409bce0..d9a631c5973c7f6423299baae66167579a8bdcff 100644 (file)
@@ -159,4 +159,6 @@ void boot_page_fault(void);
 void boot_stage1_vc(void);
 void boot_stage2_vc(void);
 
+unsigned long sev_verify_cbit(unsigned long cr3);
+
 #endif /* BOOT_COMPRESSED_MISC_H */
index e508dbd918139781de284623106b3c2ce9e50421..c44aba290fbb861e7ae34592911fe34fe0794fa1 100644 (file)
@@ -158,6 +158,7 @@ static unsigned int crypto_poly1305_setdctxkey(struct poly1305_desc_ctx *dctx,
                        dctx->s[1] = get_unaligned_le32(&inp[4]);
                        dctx->s[2] = get_unaligned_le32(&inp[8]);
                        dctx->s[3] = get_unaligned_le32(&inp[12]);
+                       acc += POLY1305_BLOCK_SIZE;
                        dctx->sset = true;
                }
        }
index 1f47e24fb65cf8a7525be8a53934eb4fa63da7d1..379819244b91d275b2c98f7ff38a59049c24b42a 100644 (file)
 440    common  process_madvise         sys_process_madvise
 
 #
-# x32-specific system call numbers start at 512 to avoid cache impact
-# for native 64-bit operation. The __x32_compat_sys stubs are created
-# on-the-fly for compat_sys_*() compatibility system calls if X86_X32
-# is defined.
+# Due to a historical design error, certain syscalls are numbered differently
+# in x32 as compared to native x86_64.  These syscalls have numbers 512-547.
+# Do not add new syscalls to this range.  Numbers 548 and above are available
+# for non-x32 use.
 #
 512    x32     rt_sigaction            compat_sys_rt_sigaction
 513    x32     rt_sigreturn            compat_sys_x32_rt_sigreturn
 545    x32     execveat                compat_sys_execveat
 546    x32     preadv2                 compat_sys_preadv64v2
 547    x32     pwritev2                compat_sys_pwritev64v2
+# This is the end of the legacy x32 range.  Numbers 548 and above are
+# not special and are not to be used for x32-specific syscalls.
index 40e0e322161d7bbc4b88e854c4a4e6f503e627f9..284e73661a18bde5d17ba6b03efd78d9be1cd309 100644 (file)
@@ -273,11 +273,15 @@ void __init hv_apic_init(void)
                pr_info("Hyper-V: Using enlightened APIC (%s mode)",
                        x2apic_enabled() ? "x2apic" : "xapic");
                /*
-                * With x2apic, architectural x2apic MSRs are equivalent to the
-                * respective synthetic MSRs, so there's no need to override
-                * the apic accessors.  The only exception is
-                * hv_apic_eoi_write, because it benefits from lazy EOI when
-                * available, but it works for both xapic and x2apic modes.
+                * When in x2apic mode, don't use the Hyper-V specific APIC
+                * accessors since the field layout in the ICR register is
+                * different in x2apic mode. Furthermore, the architectural
+                * x2apic MSRs function just as well as the Hyper-V
+                * synthetic APIC MSRs, so there's no benefit in having
+                * separate Hyper-V accessors for x2apic mode. The only
+                * exception is hv_apic_eoi_write, because it benefits from
+                * lazy EOI when available, but the same accessor works for
+                * both xapic and x2apic because the field layout is the same.
                 */
                apic_set_eoi_write(hv_apic_eoi_write);
                if (!x2apic_enabled()) {
index 812e9b4c111412db345b82854799351571a72a0a..950afebfba888573a6bf50226a0b70a589f05947 100644 (file)
@@ -32,6 +32,7 @@
 #define KVM_FEATURE_POLL_CONTROL       12
 #define KVM_FEATURE_PV_SCHED_YIELD     13
 #define KVM_FEATURE_ASYNC_PF_INT       14
+#define KVM_FEATURE_MSI_EXT_DEST_ID    15
 
 #define KVM_HINTS_REALTIME      0
 
index e5745d593dc727103b567d126ad9d431440cce7d..164a22a7298413c17fba58d1302ccbda06847e1d 100644 (file)
@@ -62,30 +62,6 @@ typedef unsigned long sigset_t;
 #define SIGRTMIN       32
 #define SIGRTMAX       _NSIG
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001u
-#define SA_NOCLDWAIT   0x00000002u
-#define SA_SIGINFO     0x00000004u
-#define SA_ONSTACK     0x08000000u
-#define SA_RESTART     0x10000000u
-#define SA_NODEFER     0x40000000u
-#define SA_RESETHAND   0x80000000u
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define SA_RESTORER    0x04000000
 
 #define MINSIGSTKSZ    2048
index 4adbe65afe235f9a71f290e874486d4a1dbfa3cf..2400ad62f330b9f518b3bcfa3462f5fd2e659e78 100644 (file)
@@ -807,6 +807,15 @@ static inline temp_mm_state_t use_temporary_mm(struct mm_struct *mm)
        temp_mm_state_t temp_state;
 
        lockdep_assert_irqs_disabled();
+
+       /*
+        * Make sure not to be in TLB lazy mode, as otherwise we'll end up
+        * with a stale address space WITHOUT being in lazy mode after
+        * restoring the previous mm.
+        */
+       if (this_cpu_read(cpu_tlbstate.is_lazy))
+               leave_mm(smp_processor_id());
+
        temp_state.mm = this_cpu_read(cpu_tlbstate.loaded_mm);
        switch_mm_irqs_off(NULL, mm, current);
 
index 714233cee0b5760db7615c0d76d6d89aaa4ef74d..3115caa7d7d0e8e85fd300fa897bbbb5f4e67a86 100644 (file)
@@ -290,6 +290,9 @@ static void __init uv_stringify(int len, char *to, char *from)
 {
        /* Relies on 'to' being NULL chars so result will be NULL terminated */
        strncpy(to, from, len-1);
+
+       /* Trim trailing spaces */
+       (void)strim(to);
 }
 
 /* Find UV arch type entry in UVsystab */
@@ -366,7 +369,7 @@ static int __init early_get_arch_type(void)
        return ret;
 }
 
-static int __init uv_set_system_type(char *_oem_id)
+static int __init uv_set_system_type(char *_oem_id, char *_oem_table_id)
 {
        /* Save OEM_ID passed from ACPI MADT */
        uv_stringify(sizeof(oem_id), oem_id, _oem_id);
@@ -386,13 +389,23 @@ static int __init uv_set_system_type(char *_oem_id)
                        /* (Not hubless), not a UV */
                        return 0;
 
+               /* Is UV hubless system */
+               uv_hubless_system = 0x01;
+
+               /* UV5 Hubless */
+               if (strncmp(uv_archtype, "NSGI5", 5) == 0)
+                       uv_hubless_system |= 0x20;
+
                /* UV4 Hubless: CH */
-               if (strncmp(uv_archtype, "NSGI4", 5) == 0)
-                       uv_hubless_system = 0x11;
+               else if (strncmp(uv_archtype, "NSGI4", 5) == 0)
+                       uv_hubless_system |= 0x10;
 
                /* UV3 Hubless: UV300/MC990X w/o hub */
                else
-                       uv_hubless_system = 0x9;
+                       uv_hubless_system |= 0x8;
+
+               /* Copy APIC type */
+               uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id);
 
                pr_info("UV: OEM IDs %s/%s, SystemType %d, HUBLESS ID %x\n",
                        oem_id, oem_table_id, uv_system_type, uv_hubless_system);
@@ -456,7 +469,7 @@ static int __init uv_acpi_madt_oem_check(char *_oem_id, char *_oem_table_id)
        uv_cpu_info->p_uv_hub_info = &uv_hub_info_node0;
 
        /* If not UV, return. */
-       if (likely(uv_set_system_type(_oem_id) == 0))
+       if (uv_set_system_type(_oem_id, _oem_table_id) == 0)
                return 0;
 
        /* Save and Decode OEM Table ID */
index d3f0db463f96ab57021e42958b057194fad1ad93..581fb7223ad0e6c19dc237effd9a6b32ec515ffd 100644 (file)
@@ -1254,6 +1254,14 @@ static int ssb_prctl_set(struct task_struct *task, unsigned long ctrl)
        return 0;
 }
 
+static bool is_spec_ib_user_controlled(void)
+{
+       return spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL ||
+               spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||
+               spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL ||
+               spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP;
+}
+
 static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
 {
        switch (ctrl) {
@@ -1261,16 +1269,26 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
                if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
                    spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
                        return 0;
+
                /*
-                * Indirect branch speculation is always disabled in strict
-                * mode. It can neither be enabled if it was force-disabled
-                * by a  previous prctl call.
+                * With strict mode for both IBPB and STIBP, the instruction
+                * code paths avoid checking this task flag and instead,
+                * unconditionally run the instruction. However, STIBP and IBPB
+                * are independent and either can be set to conditionally
+                * enabled regardless of the mode of the other.
+                *
+                * If either is set to conditional, allow the task flag to be
+                * updated, unless it was force-disabled by a previous prctl
+                * call. Currently, this is possible on an AMD CPU which has the
+                * feature X86_FEATURE_AMD_STIBP_ALWAYS_ON. In this case, if the
+                * kernel is booted with 'spectre_v2_user=seccomp', then
+                * spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP and
+                * spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED.
                 */
-               if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
-                   spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
-                   spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED ||
+               if (!is_spec_ib_user_controlled() ||
                    task_spec_ib_force_disable(task))
                        return -EPERM;
+
                task_clear_spec_ib_disable(task);
                task_update_spec_tif(task);
                break;
@@ -1283,10 +1301,10 @@ static int ib_prctl_set(struct task_struct *task, unsigned long ctrl)
                if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
                    spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
                        return -EPERM;
-               if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
-                   spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
-                   spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
+
+               if (!is_spec_ib_user_controlled())
                        return 0;
+
                task_set_spec_ib_disable(task);
                if (ctrl == PR_SPEC_FORCE_DISABLE)
                        task_set_spec_ib_force_disable(task);
@@ -1351,20 +1369,17 @@ static int ib_prctl_get(struct task_struct *task)
        if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
            spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
                return PR_SPEC_ENABLE;
-       else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
-           spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
-           spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
-               return PR_SPEC_DISABLE;
-       else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL ||
-           spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||
-           spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL ||
-           spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP) {
+       else if (is_spec_ib_user_controlled()) {
                if (task_spec_ib_force_disable(task))
                        return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE;
                if (task_spec_ib_disable(task))
                        return PR_SPEC_PRCTL | PR_SPEC_DISABLE;
                return PR_SPEC_PRCTL | PR_SPEC_ENABLE;
-       } else
+       } else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
+           spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
+           spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
+               return PR_SPEC_DISABLE;
+       else
                return PR_SPEC_NOT_AFFECTED;
 }
 
index 7eb2a1c879695dcf1712964eb546e77b26d5513a..3c417734790f0390089beaa9da01e612c750c54a 100644 (file)
@@ -161,6 +161,21 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
 
        /* Setup early boot stage 4-/5-level pagetables. */
        addq    phys_base(%rip), %rax
+
+       /*
+        * For SEV guests: Verify that the C-bit is correct. A malicious
+        * hypervisor could lie about the C-bit position to perform a ROP
+        * attack on the guest by writing to the unencrypted stack and wait for
+        * the next RET instruction.
+        * %rsi carries pointer to realmode data and is callee-clobbered. Save
+        * and restore it.
+        */
+       pushq   %rsi
+       movq    %rax, %rdi
+       call    sev_verify_cbit
+       popq    %rsi
+
+       /* Switch to new page-table */
        movq    %rax, %cr3
 
        /* Ensure I am executing from virtual addresses */
@@ -279,6 +294,7 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
 SYM_CODE_END(secondary_startup_64)
 
 #include "verify_cpu.S"
+#include "sev_verify_cbit.S"
 
 #ifdef CONFIG_HOTPLUG_CPU
 /*
index 57c2ecf43134380ca2bb36c51cc66b1a3b074454..ce831f9448e71e107f07479bca4e497038bae3c8 100644 (file)
@@ -200,8 +200,7 @@ setup_boot_parameters(struct kimage *image, struct boot_params *params,
        params->hdr.hardware_subarch = boot_params.hdr.hardware_subarch;
 
        /* Copying screen_info will do? */
-       memcpy(&params->screen_info, &boot_params.screen_info,
-                               sizeof(struct screen_info));
+       memcpy(&params->screen_info, &screen_info, sizeof(struct screen_info));
 
        /* Fill in memsize later */
        params->screen_info.ext_mem_k = 0;
index 5f83ccaab877b57c88412c38d7fa8b3532249cfa..7d04b356d44d3362b9d59c561f4c680514a56a2b 100644 (file)
@@ -178,6 +178,32 @@ void __init do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code)
                goto fail;
        regs->dx = val >> 32;
 
+       /*
+        * This is a VC handler and the #VC is only raised when SEV-ES is
+        * active, which means SEV must be active too. Do sanity checks on the
+        * CPUID results to make sure the hypervisor does not trick the kernel
+        * into the no-sev path. This could map sensitive data unencrypted and
+        * make it accessible to the hypervisor.
+        *
+        * In particular, check for:
+        *      - Hypervisor CPUID bit
+        *      - Availability of CPUID leaf 0x8000001f
+        *      - SEV CPUID bit.
+        *
+        * The hypervisor might still report the wrong C-bit position, but this
+        * can't be checked here.
+        */
+
+       if ((fn == 1 && !(regs->cx & BIT(31))))
+               /* Hypervisor bit */
+               goto fail;
+       else if (fn == 0x80000000 && (regs->ax < 0x8000001f))
+               /* SEV leaf check */
+               goto fail;
+       else if ((fn == 0x8000001f && !(regs->ax & BIT(1))))
+               /* SEV bit */
+               goto fail;
+
        /* Skip over the CPUID two-byte opcode */
        regs->ip += 2;
 
index 4a96726fbaf88b4d079a7d1e3ca6857d51fc27ff..0bd1a0fc587e0f830e25e5b4199972ad1471ff96 100644 (file)
@@ -374,8 +374,8 @@ fault:
        return ES_EXCEPTION;
 }
 
-static bool vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
-                                unsigned long vaddr, phys_addr_t *paddr)
+static enum es_result vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
+                                          unsigned long vaddr, phys_addr_t *paddr)
 {
        unsigned long va = (unsigned long)vaddr;
        unsigned int level;
@@ -394,15 +394,19 @@ static bool vc_slow_virt_to_phys(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
                if (user_mode(ctxt->regs))
                        ctxt->fi.error_code |= X86_PF_USER;
 
-               return false;
+               return ES_EXCEPTION;
        }
 
+       if (WARN_ON_ONCE(pte_val(*pte) & _PAGE_ENC))
+               /* Emulated MMIO to/from encrypted memory not supported */
+               return ES_UNSUPPORTED;
+
        pa = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT;
        pa |= va & ~page_level_mask(level);
 
        *paddr = pa;
 
-       return true;
+       return ES_OK;
 }
 
 /* Include code shared with pre-decompression boot stage */
@@ -731,6 +735,7 @@ static enum es_result vc_do_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
 {
        u64 exit_code, exit_info_1, exit_info_2;
        unsigned long ghcb_pa = __pa(ghcb);
+       enum es_result res;
        phys_addr_t paddr;
        void __user *ref;
 
@@ -740,11 +745,12 @@ static enum es_result vc_do_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt,
 
        exit_code = read ? SVM_VMGEXIT_MMIO_READ : SVM_VMGEXIT_MMIO_WRITE;
 
-       if (!vc_slow_virt_to_phys(ghcb, ctxt, (unsigned long)ref, &paddr)) {
-               if (!read)
+       res = vc_slow_virt_to_phys(ghcb, ctxt, (unsigned long)ref, &paddr);
+       if (res != ES_OK) {
+               if (res == ES_EXCEPTION && !read)
                        ctxt->fi.error_code |= X86_PF_WRITE;
 
-               return ES_EXCEPTION;
+               return res;
        }
 
        exit_info_1 = paddr;
diff --git a/arch/x86/kernel/sev_verify_cbit.S b/arch/x86/kernel/sev_verify_cbit.S
new file mode 100644 (file)
index 0000000..ee04941
--- /dev/null
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *     sev_verify_cbit.S - Code for verification of the C-bit position reported
+ *                         by the Hypervisor when running with SEV enabled.
+ *
+ *     Copyright (c) 2020  Joerg Roedel (jroedel@suse.de)
+ *
+ * sev_verify_cbit() is called before switching to a new long-mode page-table
+ * at boot.
+ *
+ * Verify that the C-bit position is correct by writing a random value to
+ * an encrypted memory location while on the current page-table. Then it
+ * switches to the new page-table to verify the memory content is still the
+ * same. After that it switches back to the current page-table and when the
+ * check succeeded it returns. If the check failed the code invalidates the
+ * stack pointer and goes into a hlt loop. The stack-pointer is invalidated to
+ * make sure no interrupt or exception can get the CPU out of the hlt loop.
+ *
+ * New page-table pointer is expected in %rdi (first parameter)
+ *
+ */
+SYM_FUNC_START(sev_verify_cbit)
+#ifdef CONFIG_AMD_MEM_ENCRYPT
+       /* First check if a C-bit was detected */
+       movq    sme_me_mask(%rip), %rsi
+       testq   %rsi, %rsi
+       jz      3f
+
+       /* sme_me_mask != 0 could mean SME or SEV - Check also for SEV */
+       movq    sev_status(%rip), %rsi
+       testq   %rsi, %rsi
+       jz      3f
+
+       /* Save CR4 in %rsi */
+       movq    %cr4, %rsi
+
+       /* Disable Global Pages */
+       movq    %rsi, %rdx
+       andq    $(~X86_CR4_PGE), %rdx
+       movq    %rdx, %cr4
+
+       /*
+        * Verified that running under SEV - now get a random value using
+        * RDRAND. This instruction is mandatory when running as an SEV guest.
+        *
+        * Don't bail out of the loop if RDRAND returns errors. It is better to
+        * prevent forward progress than to work with a non-random value here.
+        */
+1:     rdrand  %rdx
+       jnc     1b
+
+       /* Store value to memory and keep it in %rdx */
+       movq    %rdx, sev_check_data(%rip)
+
+       /* Backup current %cr3 value to restore it later */
+       movq    %cr3, %rcx
+
+       /* Switch to new %cr3 - This might unmap the stack */
+       movq    %rdi, %cr3
+
+       /*
+        * Compare value in %rdx with memory location. If C-bit is incorrect
+        * this would read the encrypted data and make the check fail.
+        */
+       cmpq    %rdx, sev_check_data(%rip)
+
+       /* Restore old %cr3 */
+       movq    %rcx, %cr3
+
+       /* Restore previous CR4 */
+       movq    %rsi, %cr4
+
+       /* Check CMPQ result */
+       je      3f
+
+       /*
+        * The check failed, prevent any forward progress to prevent ROP
+        * attacks, invalidate the stack and go into a hlt loop.
+        */
+       xorq    %rsp, %rsp
+       subq    $0x1000, %rsp
+2:     hlt
+       jmp 2b
+3:
+#endif
+       /* Return page-table pointer */
+       movq    %rdi, %rax
+       ret
+SYM_FUNC_END(sev_verify_cbit)
index a7f3e12cfbdb8b9001b06a1968c2753eb38e593a..ddfd919be46c6f31f7d40d1f7ce7f13bd95a8685 100644 (file)
@@ -165,16 +165,9 @@ void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact)
 {
        signal_compat_build_tests();
 
-       /* Don't leak in-kernel non-uapi flags to user-space */
-       if (oact)
-               oact->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
-
        if (!act)
                return;
 
-       /* Don't let flags to be set from userspace */
-       act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI);
-
        if (in_ia32_syscall())
                act->sa.sa_flags |= SA_IA32_ABI;
        if (in_x32_syscall())
index 3c70fb34028b1d74bd38d00f98c8cfa6836d21af..e19df6cde35d1d5d7c6a1ffb09e2d26cc39d1b95 100644 (file)
@@ -793,19 +793,6 @@ static __always_inline unsigned long debug_read_clear_dr6(void)
        set_debugreg(DR6_RESERVED, 6);
        dr6 ^= DR6_RESERVED; /* Flip to positive polarity */
 
-       /*
-        * Clear the virtual DR6 value, ptrace routines will set bits here for
-        * things we want signals for.
-        */
-       current->thread.virtual_dr6 = 0;
-
-       /*
-        * The SDM says "The processor clears the BTF flag when it
-        * generates a debug exception."  Clear TIF_BLOCKSTEP to keep
-        * TIF_BLOCKSTEP in sync with the hardware BTF flag.
-        */
-       clear_thread_flag(TIF_BLOCKSTEP);
-
        return dr6;
 }
 
@@ -873,6 +860,20 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
         */
        WARN_ON_ONCE(user_mode(regs));
 
+       if (test_thread_flag(TIF_BLOCKSTEP)) {
+               /*
+                * The SDM says "The processor clears the BTF flag when it
+                * generates a debug exception." but PTRACE_BLOCKSTEP requested
+                * it for userspace, but we just took a kernel #DB, so re-set
+                * BTF.
+                */
+               unsigned long debugctl;
+
+               rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+               debugctl |= DEBUGCTLMSR_BTF;
+               wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl);
+       }
+
        /*
         * Catch SYSENTER with TF set and clear DR_STEP. If this hit a
         * watchpoint at the same time then that will still be handled.
@@ -935,6 +936,22 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
        irqentry_enter_from_user_mode(regs);
        instrumentation_begin();
 
+       /*
+        * Start the virtual/ptrace DR6 value with just the DR_STEP mask
+        * of the real DR6. ptrace_triggered() will set the DR_TRAPn bits.
+        *
+        * Userspace expects DR_STEP to be visible in ptrace_get_debugreg(6)
+        * even if it is not the result of PTRACE_SINGLESTEP.
+        */
+       current->thread.virtual_dr6 = (dr6 & DR_STEP);
+
+       /*
+        * The SDM says "The processor clears the BTF flag when it
+        * generates a debug exception."  Clear TIF_BLOCKSTEP to keep
+        * TIF_BLOCKSTEP in sync with the hardware BTF flag.
+        */
+       clear_thread_flag(TIF_BLOCKSTEP);
+
        /*
         * If dr6 has no reason to give us about the origin of this trap,
         * then it's very likely the result of an icebp/int01 trap.
index 6a339ce328e0a7eb2546ae1f5f8517b293100226..73f8001000669e2595fe8a4a9eeb7bf9108e9c62 100644 (file)
@@ -321,19 +321,12 @@ EXPORT_SYMBOL_GPL(unwind_get_return_address);
 
 unsigned long *unwind_get_return_address_ptr(struct unwind_state *state)
 {
-       struct task_struct *task = state->task;
-
        if (unwind_done(state))
                return NULL;
 
        if (state->regs)
                return &state->regs->ip;
 
-       if (task != current && state->sp == task->thread.sp) {
-               struct inactive_task_frame *frame = (void *)task->thread.sp;
-               return &frame->ret_addr;
-       }
-
        if (state->sp)
                return (unsigned long *)state->sp - 1;
 
@@ -663,7 +656,7 @@ void __unwind_start(struct unwind_state *state, struct task_struct *task,
        } else {
                struct inactive_task_frame *frame = (void *)task->thread.sp;
 
-               state->sp = task->thread.sp;
+               state->sp = task->thread.sp + sizeof(*frame);
                state->bp = READ_ONCE_NOCHECK(frame->bp);
                state->ip = READ_ONCE_NOCHECK(frame->ret_addr);
                state->signal = (void *)state->ip == ret_from_fork;
index 17587f496ec74aa260674361fb05712142c2df24..1f96adff8dc4fa92548032e04efb9483c3f1cf2f 100644 (file)
@@ -225,7 +225,7 @@ static gfn_t get_mmio_spte_gfn(u64 spte)
 {
        u64 gpa = spte & shadow_nonpresent_or_rsvd_lower_gfn_mask;
 
-       gpa |= (spte >> shadow_nonpresent_or_rsvd_mask_len)
+       gpa |= (spte >> SHADOW_NONPRESENT_OR_RSVD_MASK_LEN)
               & shadow_nonpresent_or_rsvd_mask;
 
        return gpa >> PAGE_SHIFT;
@@ -591,15 +591,15 @@ static u64 mmu_spte_get_lockless(u64 *sptep)
 static u64 restore_acc_track_spte(u64 spte)
 {
        u64 new_spte = spte;
-       u64 saved_bits = (spte >> shadow_acc_track_saved_bits_shift)
-                        & shadow_acc_track_saved_bits_mask;
+       u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT)
+                        & SHADOW_ACC_TRACK_SAVED_BITS_MASK;
 
        WARN_ON_ONCE(spte_ad_enabled(spte));
        WARN_ON_ONCE(!is_access_track_spte(spte));
 
        new_spte &= ~shadow_acc_track_mask;
-       new_spte &= ~(shadow_acc_track_saved_bits_mask <<
-                     shadow_acc_track_saved_bits_shift);
+       new_spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK <<
+                     SHADOW_ACC_TRACK_SAVED_BITS_SHIFT);
        new_spte |= saved_bits;
 
        return new_spte;
index d9c5665a55e97d5e1426be6140fa69c559f9496a..fcac2cac78fe0781838c3d49ae5860a19e2d1e12 100644 (file)
@@ -55,7 +55,7 @@ u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access)
        mask |= shadow_mmio_value | access;
        mask |= gpa | shadow_nonpresent_or_rsvd_mask;
        mask |= (gpa & shadow_nonpresent_or_rsvd_mask)
-               << shadow_nonpresent_or_rsvd_mask_len;
+               << SHADOW_NONPRESENT_OR_RSVD_MASK_LEN;
 
        return mask;
 }
@@ -231,12 +231,12 @@ u64 mark_spte_for_access_track(u64 spte)
                  !spte_can_locklessly_be_made_writable(spte),
                  "kvm: Writable SPTE is not locklessly dirty-trackable\n");
 
-       WARN_ONCE(spte & (shadow_acc_track_saved_bits_mask <<
-                         shadow_acc_track_saved_bits_shift),
+       WARN_ONCE(spte & (SHADOW_ACC_TRACK_SAVED_BITS_MASK <<
+                         SHADOW_ACC_TRACK_SAVED_BITS_SHIFT),
                  "kvm: Access Tracking saved bit locations are not zero\n");
 
-       spte |= (spte & shadow_acc_track_saved_bits_mask) <<
-               shadow_acc_track_saved_bits_shift;
+       spte |= (spte & SHADOW_ACC_TRACK_SAVED_BITS_MASK) <<
+               SHADOW_ACC_TRACK_SAVED_BITS_SHIFT;
        spte &= ~shadow_acc_track_mask;
 
        return spte;
@@ -245,7 +245,7 @@ u64 mark_spte_for_access_track(u64 spte)
 void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 access_mask)
 {
        BUG_ON((u64)(unsigned)access_mask != access_mask);
-       WARN_ON(mmio_value & (shadow_nonpresent_or_rsvd_mask << shadow_nonpresent_or_rsvd_mask_len));
+       WARN_ON(mmio_value & (shadow_nonpresent_or_rsvd_mask << SHADOW_NONPRESENT_OR_RSVD_MASK_LEN));
        WARN_ON(mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask);
        shadow_mmio_value = mmio_value | SPTE_MMIO_MASK;
        shadow_mmio_access_mask = access_mask;
@@ -306,9 +306,9 @@ void kvm_mmu_reset_all_pte_masks(void)
        low_phys_bits = boot_cpu_data.x86_phys_bits;
        if (boot_cpu_has_bug(X86_BUG_L1TF) &&
            !WARN_ON_ONCE(boot_cpu_data.x86_cache_bits >=
-                         52 - shadow_nonpresent_or_rsvd_mask_len)) {
+                         52 - SHADOW_NONPRESENT_OR_RSVD_MASK_LEN)) {
                low_phys_bits = boot_cpu_data.x86_cache_bits
-                       - shadow_nonpresent_or_rsvd_mask_len;
+                       - SHADOW_NONPRESENT_OR_RSVD_MASK_LEN;
                shadow_nonpresent_or_rsvd_mask =
                        rsvd_bits(low_phys_bits, boot_cpu_data.x86_cache_bits - 1);
        }
index 4ecf40e0b8fe647fa76a84c1799f1f7ee54e8350..5c75a451c00036f0d06246ff90ff62479c5e7318 100644 (file)
@@ -104,20 +104,20 @@ extern u64 __read_mostly shadow_acc_track_mask;
  */
 extern u64 __read_mostly shadow_nonpresent_or_rsvd_mask;
 
+/*
+ * The number of high-order 1 bits to use in the mask above.
+ */
+#define SHADOW_NONPRESENT_OR_RSVD_MASK_LEN 5
+
 /*
  * The mask/shift to use for saving the original R/X bits when marking the PTE
  * as not-present for access tracking purposes. We do not save the W bit as the
  * PTEs being access tracked also need to be dirty tracked, so the W bit will be
  * restored only when a write is attempted to the page.
  */
-static const u64 shadow_acc_track_saved_bits_mask = PT64_EPT_READABLE_MASK |
-                                                   PT64_EPT_EXECUTABLE_MASK;
-static const u64 shadow_acc_track_saved_bits_shift = PT64_SECOND_AVAIL_BITS_SHIFT;
-
-/*
- * The number of high-order 1 bits to use in the mask above.
- */
-static const u64 shadow_nonpresent_or_rsvd_mask_len = 5;
+#define SHADOW_ACC_TRACK_SAVED_BITS_MASK (PT64_EPT_READABLE_MASK | \
+                                         PT64_EPT_EXECUTABLE_MASK)
+#define SHADOW_ACC_TRACK_SAVED_BITS_SHIFT PT64_SECOND_AVAIL_BITS_SHIFT
 
 /*
  * In some cases, we need to preserve the GFN of a non-present or reserved
index e5325bd0f3047231d2d597a2f8255585605da648..f3199bb02f22dfd9b8338d7d3465842fb3f7718e 100644 (file)
@@ -297,14 +297,13 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = {
 };
 const unsigned int nr_evmcs_1_fields = ARRAY_SIZE(vmcs_field_to_evmcs_1);
 
-void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
+__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf)
 {
        vmcs_conf->pin_based_exec_ctrl &= ~EVMCS1_UNSUPPORTED_PINCTRL;
        vmcs_conf->cpu_based_2nd_exec_ctrl &= ~EVMCS1_UNSUPPORTED_2NDEXEC;
 
        vmcs_conf->vmexit_ctrl &= ~EVMCS1_UNSUPPORTED_VMEXIT_CTRL;
        vmcs_conf->vmentry_ctrl &= ~EVMCS1_UNSUPPORTED_VMENTRY_CTRL;
-
 }
 #endif
 
index e5f7a7ebf27d6047ebdd2b7f824aab201f1a1b5c..bd41d9462355fd65909554b41b3ce49654ef3e4d 100644 (file)
@@ -185,7 +185,7 @@ static inline void evmcs_load(u64 phys_addr)
        vp_ap->enlighten_vmentry = 1;
 }
 
-void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf);
+__init void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf);
 #else /* !IS_ENABLED(CONFIG_HYPERV) */
 static inline void evmcs_write64(unsigned long field, u64 value) {}
 static inline void evmcs_write32(unsigned long field, u32 value) {}
@@ -194,7 +194,6 @@ static inline u64 evmcs_read64(unsigned long field) { return 0; }
 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) */
 
index d14c94d0aff17924f964f1a47446ff8069cde01c..47b8357b97517ecda8a3c52d99dfe10cbf0e91c0 100644 (file)
@@ -2560,8 +2560,10 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
        vmcs_conf->vmexit_ctrl         = _vmexit_control;
        vmcs_conf->vmentry_ctrl        = _vmentry_control;
 
-       if (static_branch_unlikely(&enable_evmcs))
+#if IS_ENABLED(CONFIG_HYPERV)
+       if (enlightened_vmcs)
                evmcs_sanitize_exec_ctrls(vmcs_conf);
+#endif
 
        return 0;
 }
@@ -6834,7 +6836,6 @@ static void vmx_free_vcpu(struct kvm_vcpu *vcpu)
 static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
 {
        struct vcpu_vmx *vmx;
-       unsigned long *msr_bitmap;
        int i, cpu, err;
 
        BUILD_BUG_ON(offsetof(struct vcpu_vmx, vcpu) != 0);
@@ -6894,7 +6895,6 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
        bitmap_fill(vmx->shadow_msr_intercept.read, MAX_POSSIBLE_PASSTHROUGH_MSRS);
        bitmap_fill(vmx->shadow_msr_intercept.write, MAX_POSSIBLE_PASSTHROUGH_MSRS);
 
-       msr_bitmap = vmx->vmcs01.msr_bitmap;
        vmx_disable_intercept_for_msr(vcpu, MSR_IA32_TSC, MSR_TYPE_R);
        vmx_disable_intercept_for_msr(vcpu, MSR_FS_BASE, MSR_TYPE_RW);
        vmx_disable_intercept_for_msr(vcpu, MSR_GS_BASE, MSR_TYPE_RW);
index 397f599b20e5a8aeb4ff1423a346d1c4d2c1e2c4..f5ede41bf9e62aa7ced58aae884267344b3d72ae 100644 (file)
@@ -265,13 +265,13 @@ static int kvm_msr_ignored_check(struct kvm_vcpu *vcpu, u32 msr,
 
        if (ignore_msrs) {
                if (report_ignored_msrs)
-                       vcpu_unimpl(vcpu, "ignored %s: 0x%x data 0x%llx\n",
-                                   op, msr, data);
+                       kvm_pr_unimpl("ignored %s: 0x%x data 0x%llx\n",
+                                     op, msr, data);
                /* Mask the error */
                return 0;
        } else {
-               vcpu_debug_ratelimited(vcpu, "unhandled %s: 0x%x data 0x%llx\n",
-                                      op, msr, data);
+               kvm_debug_ratelimited("unhandled %s: 0x%x data 0x%llx\n",
+                                     op, msr, data);
                return -ENOENT;
        }
 }
index 037faac46b0cc92f2a31297910ea63b35d10d83b..1e299ac73c8698622c7e631a4571b5b88e8b32f7 100644 (file)
@@ -16,8 +16,6 @@
  * to a jmp to memcpy_erms which does the REP; MOVSB mem copy.
  */
 
-.weak memcpy
-
 /*
  * memcpy - Copy a memory block.
  *
@@ -30,7 +28,7 @@
  * rax original destination
  */
 SYM_FUNC_START_ALIAS(__memcpy)
-SYM_FUNC_START_LOCAL(memcpy)
+SYM_FUNC_START_WEAK(memcpy)
        ALTERNATIVE_2 "jmp memcpy_orig", "", X86_FEATURE_REP_GOOD, \
                      "jmp memcpy_erms", X86_FEATURE_ERMS
 
index 7ff00ea64e4fe558f11a8f4c8961551edf35d84b..41902fe8b85982e10409c1a68e86cf01ee1519fd 100644 (file)
@@ -24,9 +24,7 @@
  * Output:
  * rax: dest
  */
-.weak memmove
-
-SYM_FUNC_START_ALIAS(memmove)
+SYM_FUNC_START_WEAK(memmove)
 SYM_FUNC_START(__memmove)
 
        mov %rdi, %rax
index 9ff15ee404a48b4de82c8a1314075bd6bba8a0d2..0bfd26e4ca9e938af774c5b1e4fea753d47d156c 100644 (file)
@@ -6,8 +6,6 @@
 #include <asm/alternative-asm.h>
 #include <asm/export.h>
 
-.weak memset
-
 /*
  * ISO C memset - set a memory block to a byte value. This function uses fast
  * string to get better performance than the original function. The code is
@@ -19,7 +17,7 @@
  *
  * rax   original destination
  */
-SYM_FUNC_START_ALIAS(memset)
+SYM_FUNC_START_WEAK(memset)
 SYM_FUNC_START(__memset)
        /*
         * Some CPUs support enhanced REP MOVSB/STOSB feature. It is recommended
index efbb3de472df4613a32308b000cf9ee1300bd154..bc0833713be955444359d83ad013125f295f1dfd 100644 (file)
@@ -39,6 +39,7 @@
  */
 u64 sme_me_mask __section(".data") = 0;
 u64 sev_status __section(".data") = 0;
+u64 sev_check_data __section(".data") = 0;
 EXPORT_SYMBOL(sme_me_mask);
 DEFINE_STATIC_KEY_FALSE(sev_enable_key);
 EXPORT_SYMBOL_GPL(sev_enable_key);
index fdcd58af707aebefb183380b1ecd2517dbb8b260..27361cbb7ca9bed47194fe4127e231a8d3c39c0d 100644 (file)
@@ -8,7 +8,7 @@
 #include <sysdep/mcontext.h>
 #include <sys/ucontext.h>
 
-void __section(".__syscall_stub")
+void __attribute__ ((__section__ (".__syscall_stub")))
 stub_segv_handler(int sig, siginfo_t *info, void *p)
 {
        ucontext_t *uc = p;
index 005dec5bfde4d33a9870e2e9fb26ba3ec59ca403..79ddabaa4e5da33dab6eb5c739a3c7a0ee95db5a 100644 (file)
@@ -72,30 +72,6 @@ typedef struct {
 #define SIGRTMIN       32
 #define SIGRTMAX       (_NSIG-1)
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002 /* not supported yet */
-#define SA_SIGINFO     0x00000004
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
 #define SA_RESTORER    0x04000000
 
 #define MINSIGSTKSZ    2048
index c6fc83efee0c94148a0da0608fec7d6e02ee140d..8731b7ad930884e26778e7c24751b0c1ce74877c 100644 (file)
@@ -89,8 +89,8 @@ static void __init free_highpages(void)
        /* set highmem page free */
        for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE,
                                &range_start, &range_end, NULL) {
-               unsigned long start = PHYS_PFN(range_start);
-               unsigned long end = PHYS_PFN(range_end);
+               unsigned long start = PFN_UP(range_start);
+               unsigned long end = PFN_DOWN(range_end);
 
                /* Ignore complete lowmem entries */
                if (end <= max_low)
index e6e26d7a1ffbba5079318041d7b793c9ed656724..fa01bef35bb1fe77b26d797cfdb76e7e04082ac3 100644 (file)
@@ -1044,6 +1044,7 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter)
        ssize_t size, left;
        unsigned len, i;
        size_t offset;
+       int ret = 0;
 
        if (WARN_ON_ONCE(!max_append_sectors))
                return 0;
@@ -1066,15 +1067,17 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter)
 
                len = min_t(size_t, PAGE_SIZE - offset, left);
                if (bio_add_hw_page(q, bio, page, len, offset,
-                               max_append_sectors, &same_page) != len)
-                       return -EINVAL;
+                               max_append_sectors, &same_page) != len) {
+                       ret = -EINVAL;
+                       break;
+               }
                if (same_page)
                        put_page(page);
                offset = 0;
        }
 
-       iov_iter_advance(iter, size);
-       return 0;
+       iov_iter_advance(iter, size - left);
+       return ret;
 }
 
 /**
index f9b55614d67d45db0ef1527c3467b61343fcac59..c68bdf58c9a6e1c0c2f28246f7d69b903cc698ac 100644 (file)
@@ -657,13 +657,20 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
                        goto fail;
                }
 
+               if (radix_tree_preload(GFP_KERNEL)) {
+                       blkg_free(new_blkg);
+                       ret = -ENOMEM;
+                       goto fail;
+               }
+
                rcu_read_lock();
                spin_lock_irq(&q->queue_lock);
 
                blkg = blkg_lookup_check(pos, pol, q);
                if (IS_ERR(blkg)) {
                        ret = PTR_ERR(blkg);
-                       goto fail_unlock;
+                       blkg_free(new_blkg);
+                       goto fail_preloaded;
                }
 
                if (blkg) {
@@ -672,10 +679,12 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
                        blkg = blkg_create(pos, q, new_blkg);
                        if (IS_ERR(blkg)) {
                                ret = PTR_ERR(blkg);
-                               goto fail_unlock;
+                               goto fail_preloaded;
                        }
                }
 
+               radix_tree_preload_end();
+
                if (pos == blkcg)
                        goto success;
        }
@@ -685,6 +694,8 @@ success:
        ctx->body = input;
        return 0;
 
+fail_preloaded:
+       radix_tree_preload_end();
 fail_unlock:
        spin_unlock_irq(&q->queue_lock);
        rcu_read_unlock();
index 53abb5c73d99f90a90033855b60f2d27e3546104..e32958f0b687506c3815c1105ffa3acf62b7df6b 100644 (file)
@@ -225,6 +225,7 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)
        /* release the tag's ownership to the req cloned from */
        spin_lock_irqsave(&fq->mq_flush_lock, flags);
 
+       WRITE_ONCE(flush_rq->state, MQ_RQ_IDLE);
        if (!refcount_dec_and_test(&flush_rq->ref)) {
                fq->rq_status = error;
                spin_unlock_irqrestore(&fq->mq_flush_lock, flags);
index 770d84071a3286f8a0e61aa244ff6a4bd8e2d0e6..d4eac6d7e9fbc5659bc494402212d0d9eedca66e 100644 (file)
@@ -1720,3 +1720,58 @@ void __init acpi_iort_init(void)
 
        iort_init_platform_devices();
 }
+
+#ifdef CONFIG_ZONE_DMA
+/*
+ * Extract the highest CPU physical address accessible to all DMA masters in
+ * the system. PHYS_ADDR_MAX is returned when no constrained device is found.
+ */
+phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
+{
+       phys_addr_t limit = PHYS_ADDR_MAX;
+       struct acpi_iort_node *node, *end;
+       struct acpi_table_iort *iort;
+       acpi_status status;
+       int i;
+
+       if (acpi_disabled)
+               return limit;
+
+       status = acpi_get_table(ACPI_SIG_IORT, 0,
+                               (struct acpi_table_header **)&iort);
+       if (ACPI_FAILURE(status))
+               return limit;
+
+       node = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->node_offset);
+       end = ACPI_ADD_PTR(struct acpi_iort_node, iort, iort->header.length);
+
+       for (i = 0; i < iort->node_count; i++) {
+               if (node >= end)
+                       break;
+
+               switch (node->type) {
+                       struct acpi_iort_named_component *ncomp;
+                       struct acpi_iort_root_complex *rc;
+                       phys_addr_t local_limit;
+
+               case ACPI_IORT_NODE_NAMED_COMPONENT:
+                       ncomp = (struct acpi_iort_named_component *)node->node_data;
+                       local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
+                       limit = min_not_zero(limit, local_limit);
+                       break;
+
+               case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+                       if (node->revision < 1)
+                               break;
+
+                       rc = (struct acpi_iort_root_complex *)node->node_data;
+                       local_limit = DMA_BIT_MASK(rc->memory_address_limit);
+                       limit = min_not_zero(limit, local_limit);
+                       break;
+               }
+               node = ACPI_ADD_PTR(struct acpi_iort_node, node, node->length);
+       }
+       acpi_put_table(&iort->header);
+       return limit;
+}
+#endif
index da4b125ab4c3ea2bd606060e8c8d2968c0e8d403..0761529cac05eecc801e3968d07498c8352ec1e8 100644 (file)
@@ -73,19 +73,6 @@ MODULE_DEVICE_TABLE(acpi, button_device_ids);
 
 /* Please keep this list sorted alphabetically by vendor and model */
 static const struct dmi_system_id dmi_lid_quirks[] = {
-       {
-               /*
-                * Acer Switch 10 SW5-012. _LID method messes with home and
-                * power button GPIO IRQ settings causing an interrupt storm on
-                * both GPIOs. This is unfixable without a DSDT override, so we
-                * have to disable the lid-switch functionality altogether :|
-                */
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
-               },
-               .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_DISABLED,
-       },
        {
                /* GP-electronic T701, _LID method points to a floating GPIO */
                .matches = {
index 45d4b7b69de879cfd4e492899912abcefcdde636..24e076f44d23827874c4d476ba8323d55dfa993c 100644 (file)
@@ -231,7 +231,8 @@ static void hot_remove_dock_devices(struct dock_station *ds)
         * between them).
         */
        list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
-               dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST, false);
+               dock_hotplug_event(dd, ACPI_NOTIFY_EJECT_REQUEST,
+                                  DOCK_CALL_HANDLER);
 
        list_for_each_entry_reverse(dd, &ds->dependent_devices, list)
                acpi_bus_trim(dd->adev);
index 756227837b3b4876d14c447ca7fdb9194a6193b2..3a3c209ed3d36a6111be6bf5804bb6a4fe3024d1 100644 (file)
@@ -1564,7 +1564,7 @@ static ssize_t format1_show(struct device *dev,
                                        le16_to_cpu(nfit_dcr->dcr->code));
                        break;
                }
-               if (rc != ENXIO)
+               if (rc != -ENXIO)
                        break;
        }
        mutex_unlock(&acpi_desc->init_mutex);
index eb9dc14e5147aaebbc210c1481ce146a6d9c57a4..20190f66ced987c10badfad6012bdfdbe678345b 100644 (file)
@@ -2100,7 +2100,7 @@ static int nv_swncq_sdbfis(struct ata_port *ap)
        pp->dhfis_bits &= ~done_mask;
        pp->dmafis_bits &= ~done_mask;
        pp->sdbfis_bits |= done_mask;
-       ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
+       ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask);
 
        if (!ap->qc_active) {
                DPRINTK("over\n");
index c852f16c111b248046bc1e73e0246eb49e1ae332..d661ada1518fb49ceab77789043946abfa32d3d8 100644 (file)
@@ -773,8 +773,7 @@ static void __device_link_del(struct kref *kref)
        dev_dbg(link->consumer, "Dropping the link to %s\n",
                dev_name(link->supplier));
 
-       if (link->flags & DL_FLAG_PM_RUNTIME)
-               pm_runtime_drop_link(link->consumer);
+       pm_runtime_drop_link(link);
 
        list_del_rcu(&link->s_node);
        list_del_rcu(&link->c_node);
@@ -788,8 +787,7 @@ static void __device_link_del(struct kref *kref)
        dev_info(link->consumer, "Dropping the link to %s\n",
                 dev_name(link->supplier));
 
-       if (link->flags & DL_FLAG_PM_RUNTIME)
-               pm_runtime_drop_link(link->consumer);
+       pm_runtime_drop_link(link);
 
        list_del(&link->s_node);
        list_del(&link->c_node);
@@ -4264,6 +4262,7 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
  */
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 {
+       struct device *parent = dev->parent;
        struct fwnode_handle *fn = dev->fwnode;
 
        if (fwnode) {
@@ -4278,7 +4277,8 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
        } else {
                if (fwnode_is_primary(fn)) {
                        dev->fwnode = fn->secondary;
-                       fn->secondary = NULL;
+                       if (!(parent && fn == parent->fwnode))
+                               fn->secondary = ERR_PTR(-ENODEV);
                } else {
                        dev->fwnode = NULL;
                }
index b42229b74fd69688b1af2ea0de19008c8e169ba2..148e81969e04625ce1645c4c1857facb3360d1bd 100644 (file)
@@ -1117,6 +1117,8 @@ static void __device_release_driver(struct device *dev, struct device *parent)
 
        drv = dev->driver;
        if (drv) {
+               pm_runtime_get_sync(dev);
+
                while (device_links_busy(dev)) {
                        __device_driver_unlock(dev, parent);
 
@@ -1128,13 +1130,12 @@ static void __device_release_driver(struct device *dev, struct device *parent)
                         * have released the driver successfully while this one
                         * was waiting, so check for that.
                         */
-                       if (dev->driver != drv)
+                       if (dev->driver != drv) {
+                               pm_runtime_put(dev);
                                return;
+                       }
                }
 
-               pm_runtime_get_sync(dev);
-               pm_runtime_clean_up_links(dev);
-
                driver_sysfs_remove(dev);
 
                if (dev->bus)
index 6f605f7820bb5fe55707645b7dea56eb70d21b5c..bfda153b1a41deed5a36ae53912fc7b0a4346980 100644 (file)
@@ -1642,42 +1642,6 @@ void pm_runtime_remove(struct device *dev)
        pm_runtime_reinit(dev);
 }
 
-/**
- * pm_runtime_clean_up_links - Prepare links to consumers for driver removal.
- * @dev: Device whose driver is going to be removed.
- *
- * Check links from this device to any consumers and if any of them have active
- * runtime PM references to the device, drop the usage counter of the device
- * (as many times as needed).
- *
- * Links with the DL_FLAG_MANAGED flag unset are ignored.
- *
- * Since the device is guaranteed to be runtime-active at the point this is
- * called, nothing else needs to be done here.
- *
- * Moreover, this is called after device_links_busy() has returned 'false', so
- * the status of each link is guaranteed to be DL_STATE_SUPPLIER_UNBIND and
- * therefore rpm_active can't be manipulated concurrently.
- */
-void pm_runtime_clean_up_links(struct device *dev)
-{
-       struct device_link *link;
-       int idx;
-
-       idx = device_links_read_lock();
-
-       list_for_each_entry_rcu(link, &dev->links.consumers, s_node,
-                               device_links_read_lock_held()) {
-               if (!(link->flags & DL_FLAG_MANAGED))
-                       continue;
-
-               while (refcount_dec_not_one(&link->rpm_active))
-                       pm_runtime_put_noidle(dev);
-       }
-
-       device_links_read_unlock(idx);
-}
-
 /**
  * pm_runtime_get_suppliers - Resume and reference-count supplier devices.
  * @dev: Consumer device.
@@ -1729,7 +1693,7 @@ void pm_runtime_new_link(struct device *dev)
        spin_unlock_irq(&dev->power.lock);
 }
 
-void pm_runtime_drop_link(struct device *dev)
+static void pm_runtime_drop_link_count(struct device *dev)
 {
        spin_lock_irq(&dev->power.lock);
        WARN_ON(dev->power.links_count == 0);
@@ -1737,6 +1701,25 @@ void pm_runtime_drop_link(struct device *dev)
        spin_unlock_irq(&dev->power.lock);
 }
 
+/**
+ * pm_runtime_drop_link - Prepare for device link removal.
+ * @link: Device link going away.
+ *
+ * Drop the link count of the consumer end of @link and decrement the supplier
+ * device's runtime PM usage counter as many times as needed to drop all of the
+ * PM runtime reference to it from the consumer.
+ */
+void pm_runtime_drop_link(struct device_link *link)
+{
+       if (!(link->flags & DL_FLAG_PM_RUNTIME))
+               return;
+
+       pm_runtime_drop_link_count(link->consumer);
+
+       while (refcount_dec_not_one(&link->rpm_active))
+               pm_runtime_put(link->supplier);
+}
+
 static bool pm_runtime_need_not_resume(struct device *dev)
 {
        return atomic_read(&dev->power.usage_count) <= 1 &&
index 0bed21c0c81b29b7dd45ff451db8042f11b05d2f..c4f9ccf5cc2ac56ac7df9a335d43e2a7e03c28d9 100644 (file)
@@ -296,7 +296,7 @@ static void nbd_size_clear(struct nbd_device *nbd)
        }
 }
 
-static void nbd_size_update(struct nbd_device *nbd)
+static void nbd_size_update(struct nbd_device *nbd, bool start)
 {
        struct nbd_config *config = nbd->config;
        struct block_device *bdev = bdget_disk(nbd->disk, 0);
@@ -313,7 +313,8 @@ static void nbd_size_update(struct nbd_device *nbd)
        if (bdev) {
                if (bdev->bd_disk) {
                        bd_set_nr_sectors(bdev, nr_sectors);
-                       set_blocksize(bdev, config->blksize);
+                       if (start)
+                               set_blocksize(bdev, config->blksize);
                } else
                        set_bit(GD_NEED_PART_SCAN, &nbd->disk->state);
                bdput(bdev);
@@ -328,7 +329,7 @@ static void nbd_size_set(struct nbd_device *nbd, loff_t blocksize,
        config->blksize = blocksize;
        config->bytesize = blocksize * nr_blocks;
        if (nbd->task_recv != NULL)
-               nbd_size_update(nbd);
+               nbd_size_update(nbd, false);
 }
 
 static void nbd_complete_rq(struct request *req)
@@ -1308,7 +1309,7 @@ static int nbd_start_device(struct nbd_device *nbd)
                args->index = i;
                queue_work(nbd->recv_workq, &args->work);
        }
-       nbd_size_update(nbd);
+       nbd_size_update(nbd, true);
        return error;
 }
 
index d2e7db43a52a7c22363f5a38c4911179f18496c3..c24d9b5ad81af26c2761daf8a29948a44e8ff607 100644 (file)
@@ -47,6 +47,8 @@ struct nullb_device {
        unsigned int nr_zones_closed;
        struct blk_zone *zones;
        sector_t zone_size_sects;
+       spinlock_t zone_lock;
+       unsigned long *zone_locks;
 
        unsigned long size; /* device size in MB */
        unsigned long completion_nsec; /* time in ns to complete a request */
index 7d94f2d47a6af6326051d90a7543ba410bbb9877..beb34b4f76b0e6c7f2fe91167fea922c786e5f3a 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/vmalloc.h>
+#include <linux/bitmap.h>
 #include "null_blk.h"
 
 #define CREATE_TRACE_POINTS
@@ -45,6 +46,22 @@ int null_init_zoned_dev(struct nullb_device *dev, struct request_queue *q)
        if (!dev->zones)
                return -ENOMEM;
 
+       /*
+        * With memory backing, the zone_lock spinlock needs to be temporarily
+        * released to avoid scheduling in atomic context. To guarantee zone
+        * information protection, use a bitmap to lock zones with
+        * wait_on_bit_lock_io(). Sleeping on the lock is OK as memory backing
+        * implies that the queue is marked with BLK_MQ_F_BLOCKING.
+        */
+       spin_lock_init(&dev->zone_lock);
+       if (dev->memory_backed) {
+               dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL);
+               if (!dev->zone_locks) {
+                       kvfree(dev->zones);
+                       return -ENOMEM;
+               }
+       }
+
        if (dev->zone_nr_conv >= dev->nr_zones) {
                dev->zone_nr_conv = dev->nr_zones - 1;
                pr_info("changed the number of conventional zones to %u",
@@ -123,15 +140,31 @@ int null_register_zoned_dev(struct nullb *nullb)
 
 void null_free_zoned_dev(struct nullb_device *dev)
 {
+       bitmap_free(dev->zone_locks);
        kvfree(dev->zones);
 }
 
+static inline void null_lock_zone(struct nullb_device *dev, unsigned int zno)
+{
+       if (dev->memory_backed)
+               wait_on_bit_lock_io(dev->zone_locks, zno, TASK_UNINTERRUPTIBLE);
+       spin_lock_irq(&dev->zone_lock);
+}
+
+static inline void null_unlock_zone(struct nullb_device *dev, unsigned int zno)
+{
+       spin_unlock_irq(&dev->zone_lock);
+
+       if (dev->memory_backed)
+               clear_and_wake_up_bit(zno, dev->zone_locks);
+}
+
 int null_report_zones(struct gendisk *disk, sector_t sector,
                unsigned int nr_zones, report_zones_cb cb, void *data)
 {
        struct nullb *nullb = disk->private_data;
        struct nullb_device *dev = nullb->dev;
-       unsigned int first_zone, i;
+       unsigned int first_zone, i, zno;
        struct blk_zone zone;
        int error;
 
@@ -142,15 +175,18 @@ int null_report_zones(struct gendisk *disk, sector_t sector,
        nr_zones = min(nr_zones, dev->nr_zones - first_zone);
        trace_nullb_report_zones(nullb, nr_zones);
 
-       for (i = 0; i < nr_zones; i++) {
+       zno = first_zone;
+       for (i = 0; i < nr_zones; i++, zno++) {
                /*
                 * Stacked DM target drivers will remap the zone information by
                 * modifying the zone information passed to the report callback.
                 * So use a local copy to avoid corruption of the device zone
                 * array.
                 */
-               memcpy(&zone, &dev->zones[first_zone + i],
-                      sizeof(struct blk_zone));
+               null_lock_zone(dev, zno);
+               memcpy(&zone, &dev->zones[zno], sizeof(struct blk_zone));
+               null_unlock_zone(dev, zno);
+
                error = cb(&zone, i, data);
                if (error)
                        return error;
@@ -159,6 +195,10 @@ int null_report_zones(struct gendisk *disk, sector_t sector,
        return nr_zones;
 }
 
+/*
+ * This is called in the case of memory backing from null_process_cmd()
+ * with the target zone already locked.
+ */
 size_t null_zone_valid_read_len(struct nullb *nullb,
                                sector_t sector, unsigned int len)
 {
@@ -295,22 +335,26 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
        if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
                return null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors);
 
+       null_lock_zone(dev, zno);
+
        switch (zone->cond) {
        case BLK_ZONE_COND_FULL:
                /* Cannot write to a full zone */
-               return BLK_STS_IOERR;
+               ret = BLK_STS_IOERR;
+               goto unlock;
        case BLK_ZONE_COND_EMPTY:
        case BLK_ZONE_COND_CLOSED:
                ret = null_check_zone_resources(dev, zone);
                if (ret != BLK_STS_OK)
-                       return ret;
+                       goto unlock;
                break;
        case BLK_ZONE_COND_IMP_OPEN:
        case BLK_ZONE_COND_EXP_OPEN:
                break;
        default:
                /* Invalid zone condition */
-               return BLK_STS_IOERR;
+               ret = BLK_STS_IOERR;
+               goto unlock;
        }
 
        /*
@@ -326,11 +370,14 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
                else
                        cmd->rq->__sector = sector;
        } else if (sector != zone->wp) {
-               return BLK_STS_IOERR;
+               ret = BLK_STS_IOERR;
+               goto unlock;
        }
 
-       if (zone->wp + nr_sectors > zone->start + zone->capacity)
-               return BLK_STS_IOERR;
+       if (zone->wp + nr_sectors > zone->start + zone->capacity) {
+               ret = BLK_STS_IOERR;
+               goto unlock;
+       }
 
        if (zone->cond == BLK_ZONE_COND_CLOSED) {
                dev->nr_zones_closed--;
@@ -341,9 +388,19 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
        if (zone->cond != BLK_ZONE_COND_EXP_OPEN)
                zone->cond = BLK_ZONE_COND_IMP_OPEN;
 
+       /*
+        * Memory backing allocation may sleep: release the zone_lock spinlock
+        * to avoid scheduling in atomic context. Zone operation atomicity is
+        * still guaranteed through the zone_locks bitmap.
+        */
+       if (dev->memory_backed)
+               spin_unlock_irq(&dev->zone_lock);
        ret = null_process_cmd(cmd, REQ_OP_WRITE, sector, nr_sectors);
+       if (dev->memory_backed)
+               spin_lock_irq(&dev->zone_lock);
+
        if (ret != BLK_STS_OK)
-               return ret;
+               goto unlock;
 
        zone->wp += nr_sectors;
        if (zone->wp == zone->start + zone->capacity) {
@@ -353,7 +410,12 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
                        dev->nr_zones_imp_open--;
                zone->cond = BLK_ZONE_COND_FULL;
        }
-       return BLK_STS_OK;
+       ret = BLK_STS_OK;
+
+unlock:
+       null_unlock_zone(dev, zno);
+
+       return ret;
 }
 
 static blk_status_t null_open_zone(struct nullb_device *dev, struct blk_zone *zone)
@@ -464,16 +526,30 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
                                   sector_t sector)
 {
        struct nullb_device *dev = cmd->nq->dev;
-       unsigned int zone_no = null_zone_no(dev, sector);
-       struct blk_zone *zone = &dev->zones[zone_no];
-       blk_status_t ret = BLK_STS_OK;
+       unsigned int zone_no;
+       struct blk_zone *zone;
+       blk_status_t ret;
        size_t i;
 
+       if (op == REQ_OP_ZONE_RESET_ALL) {
+               for (i = dev->zone_nr_conv; i < dev->nr_zones; i++) {
+                       null_lock_zone(dev, i);
+                       zone = &dev->zones[i];
+                       if (zone->cond != BLK_ZONE_COND_EMPTY) {
+                               null_reset_zone(dev, zone);
+                               trace_nullb_zone_op(cmd, i, zone->cond);
+                       }
+                       null_unlock_zone(dev, i);
+               }
+               return BLK_STS_OK;
+       }
+
+       zone_no = null_zone_no(dev, sector);
+       zone = &dev->zones[zone_no];
+
+       null_lock_zone(dev, zone_no);
+
        switch (op) {
-       case REQ_OP_ZONE_RESET_ALL:
-               for (i = dev->zone_nr_conv; i < dev->nr_zones; i++)
-                       null_reset_zone(dev, &dev->zones[i]);
-               break;
        case REQ_OP_ZONE_RESET:
                ret = null_reset_zone(dev, zone);
                break;
@@ -487,30 +563,44 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
                ret = null_finish_zone(dev, zone);
                break;
        default:
-               return BLK_STS_NOTSUPP;
+               ret = BLK_STS_NOTSUPP;
+               break;
        }
 
        if (ret == BLK_STS_OK)
                trace_nullb_zone_op(cmd, zone_no, zone->cond);
 
+       null_unlock_zone(dev, zone_no);
+
        return ret;
 }
 
 blk_status_t null_process_zoned_cmd(struct nullb_cmd *cmd, enum req_opf op,
                                    sector_t sector, sector_t nr_sectors)
 {
+       struct nullb_device *dev = cmd->nq->dev;
+       unsigned int zno = null_zone_no(dev, sector);
+       blk_status_t sts;
+
        switch (op) {
        case REQ_OP_WRITE:
-               return null_zone_write(cmd, sector, nr_sectors, false);
+               sts = null_zone_write(cmd, sector, nr_sectors, false);
+               break;
        case REQ_OP_ZONE_APPEND:
-               return null_zone_write(cmd, sector, nr_sectors, true);
+               sts = null_zone_write(cmd, sector, nr_sectors, true);
+               break;
        case REQ_OP_ZONE_RESET:
        case REQ_OP_ZONE_RESET_ALL:
        case REQ_OP_ZONE_OPEN:
        case REQ_OP_ZONE_CLOSE:
        case REQ_OP_ZONE_FINISH:
-               return null_zone_mgmt(cmd, op, sector);
+               sts = null_zone_mgmt(cmd, op, sector);
+               break;
        default:
-               return null_process_cmd(cmd, op, sector, nr_sectors);
+               null_lock_zone(dev, zno);
+               sts = null_process_cmd(cmd, op, sector, nr_sectors);
+               null_unlock_zone(dev, zno);
        }
+
+       return sts;
 }
index 8d581c7536fb510f08aebd3abdf3425b4a7ff7bd..eb8ef65778c35eab417668f89165520db47b3cf2 100644 (file)
@@ -443,22 +443,27 @@ static void ace_fix_driveid(u16 *id)
 #define ACE_FSM_NUM_STATES              11
 
 /* Set flag to exit FSM loop and reschedule tasklet */
-static inline void ace_fsm_yield(struct ace_device *ace)
+static inline void ace_fsm_yieldpoll(struct ace_device *ace)
 {
-       dev_dbg(ace->dev, "ace_fsm_yield()\n");
        tasklet_schedule(&ace->fsm_tasklet);
        ace->fsm_continue_flag = 0;
 }
 
+static inline void ace_fsm_yield(struct ace_device *ace)
+{
+       dev_dbg(ace->dev, "%s()\n", __func__);
+       ace_fsm_yieldpoll(ace);
+}
+
 /* Set flag to exit FSM loop and wait for IRQ to reschedule tasklet */
 static inline void ace_fsm_yieldirq(struct ace_device *ace)
 {
        dev_dbg(ace->dev, "ace_fsm_yieldirq()\n");
 
-       if (!ace->irq)
-               /* No IRQ assigned, so need to poll */
-               tasklet_schedule(&ace->fsm_tasklet);
-       ace->fsm_continue_flag = 0;
+       if (ace->irq > 0)
+               ace->fsm_continue_flag = 0;
+       else
+               ace_fsm_yieldpoll(ace);
 }
 
 static bool ace_has_next_request(struct request_queue *q)
@@ -1053,12 +1058,12 @@ static int ace_setup(struct ace_device *ace)
                ACE_CTRL_DATABUFRDYIRQ | ACE_CTRL_ERRORIRQ);
 
        /* Now we can hook up the irq handler */
-       if (ace->irq) {
+       if (ace->irq > 0) {
                rc = request_irq(ace->irq, ace_interrupt, 0, "systemace", ace);
                if (rc) {
                        /* Failure - fall back to polled mode */
                        dev_err(ace->dev, "request_irq failed\n");
-                       ace->irq = 0;
+                       ace->irq = rc;
                }
        }
 
@@ -1110,7 +1115,7 @@ static void ace_teardown(struct ace_device *ace)
 
        tasklet_kill(&ace->fsm_tasklet);
 
-       if (ace->irq)
+       if (ace->irq > 0)
                free_irq(ace->irq, ace);
 
        iounmap(ace->baseaddr);
@@ -1123,11 +1128,6 @@ static int ace_alloc(struct device *dev, int id, resource_size_t physaddr,
        int rc;
        dev_dbg(dev, "ace_alloc(%p)\n", dev);
 
-       if (!physaddr) {
-               rc = -ENODEV;
-               goto err_noreg;
-       }
-
        /* Allocate and initialize the ace device structure */
        ace = kzalloc(sizeof(struct ace_device), GFP_KERNEL);
        if (!ace) {
@@ -1153,7 +1153,6 @@ err_setup:
        dev_set_drvdata(dev, NULL);
        kfree(ace);
 err_alloc:
-err_noreg:
        dev_err(dev, "could not initialize device, err=%i\n", rc);
        return rc;
 }
@@ -1176,10 +1175,11 @@ static void ace_free(struct device *dev)
 
 static int ace_probe(struct platform_device *dev)
 {
-       resource_size_t physaddr = 0;
        int bus_width = ACE_BUS_WIDTH_16; /* FIXME: should not be hard coded */
+       resource_size_t physaddr;
+       struct resource *res;
        u32 id = dev->id;
-       int irq = 0;
+       int irq;
        int i;
 
        dev_dbg(&dev->dev, "ace_probe(%p)\n", dev);
@@ -1190,12 +1190,15 @@ static int ace_probe(struct platform_device *dev)
        if (of_find_property(dev->dev.of_node, "8-bit", NULL))
                bus_width = ACE_BUS_WIDTH_8;
 
-       for (i = 0; i < dev->num_resources; i++) {
-               if (dev->resource[i].flags & IORESOURCE_MEM)
-                       physaddr = dev->resource[i].start;
-               if (dev->resource[i].flags & IORESOURCE_IRQ)
-                       irq = dev->resource[i].start;
-       }
+       res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -EINVAL;
+
+       physaddr = res->start;
+       if (!physaddr)
+               return -ENODEV;
+
+       irq = platform_get_irq_optional(dev, 0);
 
        /* Call the bus-independent setup code */
        return ace_alloc(&dev->dev, id, physaddr, irq, bus_width);
index 09346ae308eb22f94f7d0dc8cd060b12625c53dd..78cc64b42b30a619fddca092e73c8d8944850db4 100644 (file)
@@ -47,7 +47,7 @@ enum {
 struct intel_tlv {
        u8 type;
        u8 len;
-       u8 val[0];
+       u8 val[];
 } __packed;
 
 struct intel_version_tlv {
index 6bb023de17f1fb086daa1ba5ff122a7e8e5c7d13..35229e5143cacde3771a460f2e1c820579eca025 100644 (file)
@@ -41,6 +41,11 @@ int tpm_read_log_efi(struct tpm_chip *chip)
        log_size = log_tbl->size;
        memunmap(log_tbl);
 
+       if (!log_size) {
+               pr_warn("UEFI TPM log area empty\n");
+               return -EIO;
+       }
+
        log_tbl = memremap(efi.tpm_log, sizeof(*log_tbl) + log_size,
                           MEMREMAP_WB);
        if (!log_tbl) {
index 0b214963539de2ee6977f85344f9b12d3c5dae57..4ed6e660273a4142d015991fde826de1e7598537 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/kernel.h>
+#include <linux/dmi.h>
 #include "tpm.h"
 #include "tpm_tis_core.h"
 
@@ -49,8 +50,8 @@ static inline struct tpm_tis_tcg_phy *to_tpm_tis_tcg_phy(struct tpm_tis_data *da
        return container_of(data, struct tpm_tis_tcg_phy, priv);
 }
 
-static bool interrupts = true;
-module_param(interrupts, bool, 0444);
+static int interrupts = -1;
+module_param(interrupts, int, 0444);
 MODULE_PARM_DESC(interrupts, "Enable interrupts");
 
 static bool itpm;
@@ -63,6 +64,28 @@ module_param(force, bool, 0444);
 MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
 #endif
 
+static int tpm_tis_disable_irq(const struct dmi_system_id *d)
+{
+       if (interrupts == -1) {
+               pr_notice("tpm_tis: %s detected: disabling interrupts.\n", d->ident);
+               interrupts = 0;
+       }
+
+       return 0;
+}
+
+static const struct dmi_system_id tpm_tis_dmi_table[] = {
+       {
+               .callback = tpm_tis_disable_irq,
+               .ident = "ThinkPad T490s",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
+               },
+       },
+       {}
+};
+
 #if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
 static int has_hid(struct acpi_device *dev, const char *hid)
 {
@@ -192,6 +215,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info)
        int irq = -1;
        int rc;
 
+       dmi_check_system(tpm_tis_dmi_table);
+
        rc = check_acpi_tpm2(dev);
        if (rc)
                return rc;
index 2c7171e0b001027a7364bd9b84af9444186710f8..85de313ddec29cdc33824ec98964abe2bae8c962 100644 (file)
@@ -71,6 +71,7 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE
 
 config CPU_FREQ_DEFAULT_GOV_ONDEMAND
        bool "ondemand"
+       depends on !(X86_INTEL_PSTATE && SMP)
        select CPU_FREQ_GOV_ONDEMAND
        select CPU_FREQ_GOV_PERFORMANCE
        help
@@ -83,6 +84,7 @@ config CPU_FREQ_DEFAULT_GOV_ONDEMAND
 
 config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
        bool "conservative"
+       depends on !(X86_INTEL_PSTATE && SMP)
        select CPU_FREQ_GOV_CONSERVATIVE
        select CPU_FREQ_GOV_PERFORMANCE
        help
index f4b60663efe65335b0501db403a6315a43227566..336b5e94cbc83cf55a021fce886c5f1f678b9944 100644 (file)
@@ -1907,6 +1907,18 @@ void cpufreq_resume(void)
        }
 }
 
+/**
+ * cpufreq_driver_test_flags - Test cpufreq driver's flags against given ones.
+ * @flags: Flags to test against the current cpufreq driver's flags.
+ *
+ * Assumes that the driver is there, so callers must ensure that this is the
+ * case.
+ */
+bool cpufreq_driver_test_flags(u16 flags)
+{
+       return !!(cpufreq_driver->flags & flags);
+}
+
 /**
  *     cpufreq_get_current_driver - return current driver's name
  *
@@ -2187,7 +2199,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
         * exactly same freq is called again and so we can save on few function
         * calls.
         */
-       if (target_freq == policy->cur)
+       if (target_freq == policy->cur &&
+           !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
                return 0;
 
        /* Save last value to restore later on errors */
index 776a58bab0ffd5f67266fe8ef703b6a867d0ef57..ab93bce8ae77d9573319f793961d4cb8b6fced8d 100644 (file)
@@ -223,7 +223,6 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
        case EPS_BRAND_C3:
                pr_cont("C3\n");
                return -ENODEV;
-               break;
        }
        /* Enable Enhanced PowerSaver */
        rdmsrl(MSR_IA32_MISC_ENABLE, val);
index 3c1455518738f80d5f1e28e06ebc07273e656a50..b7a9779250aaa5f5e4160effe0bd7a33caba6569 100644 (file)
@@ -2568,14 +2568,12 @@ static int intel_cpufreq_update_pstate(struct cpudata *cpu, int target_pstate,
        int old_pstate = cpu->pstate.current_pstate;
 
        target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
-       if (target_pstate != old_pstate) {
+       if (hwp_active) {
+               intel_cpufreq_adjust_hwp(cpu, target_pstate, fast_switch);
+               cpu->pstate.current_pstate = target_pstate;
+       } else if (target_pstate != old_pstate) {
+               intel_cpufreq_adjust_perf_ctl(cpu, target_pstate, fast_switch);
                cpu->pstate.current_pstate = target_pstate;
-               if (hwp_active)
-                       intel_cpufreq_adjust_hwp(cpu, target_pstate,
-                                                fast_switch);
-               else
-                       intel_cpufreq_adjust_perf_ctl(cpu, target_pstate,
-                                                     fast_switch);
        }
 
        intel_cpufreq_trace(cpu, fast_switch ? INTEL_PSTATE_TRACE_FAST_SWITCH :
@@ -3032,6 +3030,7 @@ static int __init intel_pstate_init(void)
                        hwp_mode_bdw = id->driver_data;
                        intel_pstate.attr = hwp_cpufreq_attrs;
                        intel_cpufreq.attr = hwp_cpufreq_attrs;
+                       intel_cpufreq.flags |= CPUFREQ_NEED_UPDATE_LIMITS;
                        if (!default_driver)
                                default_driver = &intel_pstate;
 
index 123fb006810d5da028c926b3a68da2b324095500..182a4dbca0952c7cc6a7db2e1d5940555000c926 100644 (file)
@@ -593,7 +593,6 @@ static void longhaul_setup_voltagescaling(void)
                break;
        default:
                return;
-               break;
        }
        if (min_vid_speed >= highest_speed)
                return;
index a13a2d1e444ed6e62ff357927f1912b6d0408131..0b66df4ed513408f1b28e2ca5a5094c41a885717 100644 (file)
@@ -240,7 +240,7 @@ unsigned int speedstep_get_frequency(enum speedstep_processor processor)
                return pentium3_get_frequency(processor);
        default:
                return 0;
-       };
+       }
        return 0;
 }
 EXPORT_SYMBOL_GPL(speedstep_get_frequency);
index fa2f1b4fad7b4236214ed8c429fdb4dd8a461ea9..a94bf28f858a7f0fb513534c7190d1274d232348 100644 (file)
@@ -7,7 +7,7 @@
  *
  * This file add support for MD5 and SHA1/SHA224/SHA256/SHA384/SHA512.
  *
- * You could find the datasheet in Documentation/arm/sunxi/README
+ * You could find the datasheet in Documentation/arm/sunxi.rst
  */
 #include <linux/dma-mapping.h>
 #include <linux/pm_runtime.h>
index 78503006949c8fb8647ea1c3035dd1f95d52e416..cfde9ee4356b138260ae51f110a991febb3d4b30 100644 (file)
@@ -7,7 +7,7 @@
  *
  * This file handle the PRNG
  *
- * You could find a link for the datasheet in Documentation/arm/sunxi/README
+ * You could find a link for the datasheet in Documentation/arm/sunxi.rst
  */
 #include "sun8i-ce.h"
 #include <linux/dma-mapping.h>
index 654328160d19b2bef593803f945a82fa7928b8fb..5b7af4498bd5a6f937a5ae15caced491237f8c8e 100644 (file)
@@ -7,7 +7,7 @@
  *
  * This file handle the TRNG
  *
- * You could find a link for the datasheet in Documentation/arm/sunxi/README
+ * You could find a link for the datasheet in Documentation/arm/sunxi.rst
  */
 #include "sun8i-ce.h"
 #include <linux/dma-mapping.h>
index 518a1437862ac2212f2dbe7795add9740b6e377a..90284ffda58a7b43e45d4617ab8cdde1a1411a80 100644 (file)
@@ -318,24 +318,6 @@ config INTEL_IOP_ADMA
        help
          Enable support for the Intel(R) IOP Series RAID engines.
 
-config INTEL_MIC_X100_DMA
-       tristate "Intel MIC X100 DMA Driver"
-       depends on 64BIT && X86 && INTEL_MIC_BUS
-       select DMA_ENGINE
-       help
-         This enables DMA support for the Intel Many Integrated Core
-         (MIC) family of PCIe form factor coprocessor X100 devices that
-         run a 64 bit Linux OS. This driver will be used by both MIC
-         host and card drivers.
-
-         If you are building host kernel with a MIC device or a card
-         kernel for a MIC device, then say M (recommended) or Y, else
-         say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
 config K3_DMA
        tristate "Hisilicon K3 DMA support"
        depends on ARCH_HI3xxx || ARCH_HISI || COMPILE_TEST
index e60f81331d4c74c16292d03297778dd8a0ff28a9..948a8da05f8b6829c498d9961b9c3e8dfc665586 100644 (file)
@@ -44,7 +44,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioat/
 obj-$(CONFIG_INTEL_IDXD) += idxd/
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
-obj-$(CONFIG_INTEL_MIC_X100_DMA) += mic_x100_dma.o
 obj-$(CONFIG_K3_DMA) += k3dma.o
 obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
 obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c
deleted file mode 100644 (file)
index fea8608..0000000
+++ /dev/null
@@ -1,770 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel MIC X100 DMA Driver.
- *
- * Adapted from IOAT dma driver.
- */
-#include <linux/module.h>
-#include <linux/io.h>
-#include <linux/seq_file.h>
-#include <linux/vmalloc.h>
-
-#include "mic_x100_dma.h"
-
-#define MIC_DMA_MAX_XFER_SIZE_CARD  (1 * 1024 * 1024 -\
-                                      MIC_DMA_ALIGN_BYTES)
-#define MIC_DMA_MAX_XFER_SIZE_HOST  (1 * 1024 * 1024 >> 1)
-#define MIC_DMA_DESC_TYPE_SHIFT        60
-#define MIC_DMA_MEMCPY_LEN_SHIFT 46
-#define MIC_DMA_STAT_INTR_SHIFT 59
-
-/* high-water mark for pushing dma descriptors */
-static int mic_dma_pending_level = 4;
-
-/* Status descriptor is used to write a 64 bit value to a memory location */
-enum mic_dma_desc_format_type {
-       MIC_DMA_MEMCPY = 1,
-       MIC_DMA_STATUS,
-};
-
-static inline u32 mic_dma_hw_ring_inc(u32 val)
-{
-       return (val + 1) % MIC_DMA_DESC_RX_SIZE;
-}
-
-static inline u32 mic_dma_hw_ring_dec(u32 val)
-{
-       return val ? val - 1 : MIC_DMA_DESC_RX_SIZE - 1;
-}
-
-static inline void mic_dma_hw_ring_inc_head(struct mic_dma_chan *ch)
-{
-       ch->head = mic_dma_hw_ring_inc(ch->head);
-}
-
-/* Prepare a memcpy desc */
-static inline void mic_dma_memcpy_desc(struct mic_dma_desc *desc,
-       dma_addr_t src_phys, dma_addr_t dst_phys, u64 size)
-{
-       u64 qw0, qw1;
-
-       qw0 = src_phys;
-       qw0 |= (size >> MIC_DMA_ALIGN_SHIFT) << MIC_DMA_MEMCPY_LEN_SHIFT;
-       qw1 = MIC_DMA_MEMCPY;
-       qw1 <<= MIC_DMA_DESC_TYPE_SHIFT;
-       qw1 |= dst_phys;
-       desc->qw0 = qw0;
-       desc->qw1 = qw1;
-}
-
-/* Prepare a status desc. with @data to be written at @dst_phys */
-static inline void mic_dma_prep_status_desc(struct mic_dma_desc *desc, u64 data,
-       dma_addr_t dst_phys, bool generate_intr)
-{
-       u64 qw0, qw1;
-
-       qw0 = data;
-       qw1 = (u64) MIC_DMA_STATUS << MIC_DMA_DESC_TYPE_SHIFT | dst_phys;
-       if (generate_intr)
-               qw1 |= (1ULL << MIC_DMA_STAT_INTR_SHIFT);
-       desc->qw0 = qw0;
-       desc->qw1 = qw1;
-}
-
-static void mic_dma_cleanup(struct mic_dma_chan *ch)
-{
-       struct dma_async_tx_descriptor *tx;
-       u32 tail;
-       u32 last_tail;
-
-       spin_lock(&ch->cleanup_lock);
-       tail = mic_dma_read_cmp_cnt(ch);
-       /*
-        * This is the barrier pair for smp_wmb() in fn.
-        * mic_dma_tx_submit_unlock. It's required so that we read the
-        * updated cookie value from tx->cookie.
-        */
-       smp_rmb();
-       for (last_tail = ch->last_tail; tail != last_tail;) {
-               tx = &ch->tx_array[last_tail];
-               if (tx->cookie) {
-                       dma_cookie_complete(tx);
-                       dmaengine_desc_get_callback_invoke(tx, NULL);
-                       tx->callback = NULL;
-               }
-               last_tail = mic_dma_hw_ring_inc(last_tail);
-       }
-       /* finish all completion callbacks before incrementing tail */
-       smp_mb();
-       ch->last_tail = last_tail;
-       spin_unlock(&ch->cleanup_lock);
-}
-
-static u32 mic_dma_ring_count(u32 head, u32 tail)
-{
-       u32 count;
-
-       if (head >= tail)
-               count = (tail - 0) + (MIC_DMA_DESC_RX_SIZE - head);
-       else
-               count = tail - head;
-       return count - 1;
-}
-
-/* Returns the num. of free descriptors on success, -ENOMEM on failure */
-static int mic_dma_avail_desc_ring_space(struct mic_dma_chan *ch, int required)
-{
-       struct device *dev = mic_dma_ch_to_device(ch);
-       u32 count;
-
-       count = mic_dma_ring_count(ch->head, ch->last_tail);
-       if (count < required) {
-               mic_dma_cleanup(ch);
-               count = mic_dma_ring_count(ch->head, ch->last_tail);
-       }
-
-       if (count < required) {
-               dev_dbg(dev, "Not enough desc space");
-               dev_dbg(dev, "%s %d required=%u, avail=%u\n",
-                       __func__, __LINE__, required, count);
-               return -ENOMEM;
-       } else {
-               return count;
-       }
-}
-
-/* Program memcpy descriptors into the descriptor ring and update s/w head ptr*/
-static int mic_dma_prog_memcpy_desc(struct mic_dma_chan *ch, dma_addr_t src,
-                                   dma_addr_t dst, size_t len)
-{
-       size_t current_transfer_len;
-       size_t max_xfer_size = to_mic_dma_dev(ch)->max_xfer_size;
-       /* 3 is added to make sure we have enough space for status desc */
-       int num_desc = len / max_xfer_size + 3;
-       int ret;
-
-       if (len % max_xfer_size)
-               num_desc++;
-
-       ret = mic_dma_avail_desc_ring_space(ch, num_desc);
-       if (ret < 0)
-               return ret;
-       do {
-               current_transfer_len = min(len, max_xfer_size);
-               mic_dma_memcpy_desc(&ch->desc_ring[ch->head],
-                                   src, dst, current_transfer_len);
-               mic_dma_hw_ring_inc_head(ch);
-               len -= current_transfer_len;
-               dst = dst + current_transfer_len;
-               src = src + current_transfer_len;
-       } while (len > 0);
-       return 0;
-}
-
-/* It's a h/w quirk and h/w needs 2 status descriptors for every status desc */
-static void mic_dma_prog_intr(struct mic_dma_chan *ch)
-{
-       mic_dma_prep_status_desc(&ch->desc_ring[ch->head], 0,
-                                ch->status_dest_micpa, false);
-       mic_dma_hw_ring_inc_head(ch);
-       mic_dma_prep_status_desc(&ch->desc_ring[ch->head], 0,
-                                ch->status_dest_micpa, true);
-       mic_dma_hw_ring_inc_head(ch);
-}
-
-/* Wrapper function to program memcpy descriptors/status descriptors */
-static int mic_dma_do_dma(struct mic_dma_chan *ch, int flags, dma_addr_t src,
-                         dma_addr_t dst, size_t len)
-{
-       if (len && -ENOMEM == mic_dma_prog_memcpy_desc(ch, src, dst, len)) {
-               return -ENOMEM;
-       } else {
-               /* 3 is the maximum number of status descriptors */
-               int ret = mic_dma_avail_desc_ring_space(ch, 3);
-
-               if (ret < 0)
-                       return ret;
-       }
-
-       /* Above mic_dma_prog_memcpy_desc() makes sure we have enough space */
-       if (flags & DMA_PREP_FENCE) {
-               mic_dma_prep_status_desc(&ch->desc_ring[ch->head], 0,
-                                        ch->status_dest_micpa, false);
-               mic_dma_hw_ring_inc_head(ch);
-       }
-
-       if (flags & DMA_PREP_INTERRUPT)
-               mic_dma_prog_intr(ch);
-
-       return 0;
-}
-
-static inline void mic_dma_issue_pending(struct dma_chan *ch)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-
-       spin_lock(&mic_ch->issue_lock);
-       /*
-        * Write to head triggers h/w to act on the descriptors.
-        * On MIC, writing the same head value twice causes
-        * a h/w error. On second write, h/w assumes we filled
-        * the entire ring & overwrote some of the descriptors.
-        */
-       if (mic_ch->issued == mic_ch->submitted)
-               goto out;
-       mic_ch->issued = mic_ch->submitted;
-       /*
-        * make descriptor updates visible before advancing head,
-        * this is purposefully not smp_wmb() since we are also
-        * publishing the descriptor updates to a dma device
-        */
-       wmb();
-       mic_dma_write_reg(mic_ch, MIC_DMA_REG_DHPR, mic_ch->issued);
-out:
-       spin_unlock(&mic_ch->issue_lock);
-}
-
-static inline void mic_dma_update_pending(struct mic_dma_chan *ch)
-{
-       if (mic_dma_ring_count(ch->issued, ch->submitted)
-                       > mic_dma_pending_level)
-               mic_dma_issue_pending(&ch->api_ch);
-}
-
-static dma_cookie_t mic_dma_tx_submit_unlock(struct dma_async_tx_descriptor *tx)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(tx->chan);
-       dma_cookie_t cookie;
-
-       dma_cookie_assign(tx);
-       cookie = tx->cookie;
-       /*
-        * We need an smp write barrier here because another CPU might see
-        * an update to submitted and update h/w head even before we
-        * assigned a cookie to this tx.
-        */
-       smp_wmb();
-       mic_ch->submitted = mic_ch->head;
-       spin_unlock(&mic_ch->prep_lock);
-       mic_dma_update_pending(mic_ch);
-       return cookie;
-}
-
-static inline struct dma_async_tx_descriptor *
-allocate_tx(struct mic_dma_chan *ch)
-{
-       u32 idx = mic_dma_hw_ring_dec(ch->head);
-       struct dma_async_tx_descriptor *tx = &ch->tx_array[idx];
-
-       dma_async_tx_descriptor_init(tx, &ch->api_ch);
-       tx->tx_submit = mic_dma_tx_submit_unlock;
-       return tx;
-}
-
-/* Program a status descriptor with dst as address and value to be written */
-static struct dma_async_tx_descriptor *
-mic_dma_prep_status_lock(struct dma_chan *ch, dma_addr_t dst, u64 src_val,
-                        unsigned long flags)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-       int result;
-
-       spin_lock(&mic_ch->prep_lock);
-       result = mic_dma_avail_desc_ring_space(mic_ch, 4);
-       if (result < 0)
-               goto error;
-       mic_dma_prep_status_desc(&mic_ch->desc_ring[mic_ch->head], src_val, dst,
-                                false);
-       mic_dma_hw_ring_inc_head(mic_ch);
-       result = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
-       if (result < 0)
-               goto error;
-
-       return allocate_tx(mic_ch);
-error:
-       dev_err(mic_dma_ch_to_device(mic_ch),
-               "Error enqueueing dma status descriptor, error=%d\n", result);
-       spin_unlock(&mic_ch->prep_lock);
-       return NULL;
-}
-
-/*
- * Prepare a memcpy descriptor to be added to the ring.
- * Note that the temporary descriptor adds an extra overhead of copying the
- * descriptor to ring. So, we copy directly to the descriptor ring
- */
-static struct dma_async_tx_descriptor *
-mic_dma_prep_memcpy_lock(struct dma_chan *ch, dma_addr_t dma_dest,
-                        dma_addr_t dma_src, size_t len, unsigned long flags)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-       struct device *dev = mic_dma_ch_to_device(mic_ch);
-       int result;
-
-       if (!len && !flags)
-               return NULL;
-
-       spin_lock(&mic_ch->prep_lock);
-       result = mic_dma_do_dma(mic_ch, flags, dma_src, dma_dest, len);
-       if (result >= 0)
-               return allocate_tx(mic_ch);
-       dev_err(dev, "Error enqueueing dma, error=%d\n", result);
-       spin_unlock(&mic_ch->prep_lock);
-       return NULL;
-}
-
-static struct dma_async_tx_descriptor *
-mic_dma_prep_interrupt_lock(struct dma_chan *ch, unsigned long flags)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-       int ret;
-
-       spin_lock(&mic_ch->prep_lock);
-       ret = mic_dma_do_dma(mic_ch, flags, 0, 0, 0);
-       if (!ret)
-               return allocate_tx(mic_ch);
-       spin_unlock(&mic_ch->prep_lock);
-       return NULL;
-}
-
-/* Return the status of the transaction */
-static enum dma_status
-mic_dma_tx_status(struct dma_chan *ch, dma_cookie_t cookie,
-                 struct dma_tx_state *txstate)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-
-       if (DMA_COMPLETE != dma_cookie_status(ch, cookie, txstate))
-               mic_dma_cleanup(mic_ch);
-
-       return dma_cookie_status(ch, cookie, txstate);
-}
-
-static irqreturn_t mic_dma_thread_fn(int irq, void *data)
-{
-       mic_dma_cleanup((struct mic_dma_chan *)data);
-       return IRQ_HANDLED;
-}
-
-static irqreturn_t mic_dma_intr_handler(int irq, void *data)
-{
-       struct mic_dma_chan *ch = ((struct mic_dma_chan *)data);
-
-       mic_dma_ack_interrupt(ch);
-       return IRQ_WAKE_THREAD;
-}
-
-static int mic_dma_alloc_desc_ring(struct mic_dma_chan *ch)
-{
-       u64 desc_ring_size = MIC_DMA_DESC_RX_SIZE * sizeof(*ch->desc_ring);
-       struct device *dev = &to_mbus_device(ch)->dev;
-
-       desc_ring_size = ALIGN(desc_ring_size, MIC_DMA_ALIGN_BYTES);
-       ch->desc_ring = kzalloc(desc_ring_size, GFP_KERNEL);
-
-       if (!ch->desc_ring)
-               return -ENOMEM;
-
-       ch->desc_ring_micpa = dma_map_single(dev, ch->desc_ring,
-                                            desc_ring_size, DMA_BIDIRECTIONAL);
-       if (dma_mapping_error(dev, ch->desc_ring_micpa))
-               goto map_error;
-
-       ch->tx_array = vzalloc(array_size(MIC_DMA_DESC_RX_SIZE,
-                                         sizeof(*ch->tx_array)));
-       if (!ch->tx_array)
-               goto tx_error;
-       return 0;
-tx_error:
-       dma_unmap_single(dev, ch->desc_ring_micpa, desc_ring_size,
-                        DMA_BIDIRECTIONAL);
-map_error:
-       kfree(ch->desc_ring);
-       return -ENOMEM;
-}
-
-static void mic_dma_free_desc_ring(struct mic_dma_chan *ch)
-{
-       u64 desc_ring_size = MIC_DMA_DESC_RX_SIZE * sizeof(*ch->desc_ring);
-
-       vfree(ch->tx_array);
-       desc_ring_size = ALIGN(desc_ring_size, MIC_DMA_ALIGN_BYTES);
-       dma_unmap_single(&to_mbus_device(ch)->dev, ch->desc_ring_micpa,
-                        desc_ring_size, DMA_BIDIRECTIONAL);
-       kfree(ch->desc_ring);
-       ch->desc_ring = NULL;
-}
-
-static void mic_dma_free_status_dest(struct mic_dma_chan *ch)
-{
-       dma_unmap_single(&to_mbus_device(ch)->dev, ch->status_dest_micpa,
-                        L1_CACHE_BYTES, DMA_BIDIRECTIONAL);
-       kfree(ch->status_dest);
-}
-
-static int mic_dma_alloc_status_dest(struct mic_dma_chan *ch)
-{
-       struct device *dev = &to_mbus_device(ch)->dev;
-
-       ch->status_dest = kzalloc(L1_CACHE_BYTES, GFP_KERNEL);
-       if (!ch->status_dest)
-               return -ENOMEM;
-       ch->status_dest_micpa = dma_map_single(dev, ch->status_dest,
-                                       L1_CACHE_BYTES, DMA_BIDIRECTIONAL);
-       if (dma_mapping_error(dev, ch->status_dest_micpa)) {
-               kfree(ch->status_dest);
-               ch->status_dest = NULL;
-               return -ENOMEM;
-       }
-       return 0;
-}
-
-static int mic_dma_check_chan(struct mic_dma_chan *ch)
-{
-       if (mic_dma_read_reg(ch, MIC_DMA_REG_DCHERR) ||
-           mic_dma_read_reg(ch, MIC_DMA_REG_DSTAT) & MIC_DMA_CHAN_QUIESCE) {
-               mic_dma_disable_chan(ch);
-               mic_dma_chan_mask_intr(ch);
-               dev_err(mic_dma_ch_to_device(ch),
-                       "%s %d error setting up mic dma chan %d\n",
-                       __func__, __LINE__, ch->ch_num);
-               return -EBUSY;
-       }
-       return 0;
-}
-
-static int mic_dma_chan_setup(struct mic_dma_chan *ch)
-{
-       if (MIC_DMA_CHAN_MIC == ch->owner)
-               mic_dma_chan_set_owner(ch);
-       mic_dma_disable_chan(ch);
-       mic_dma_chan_mask_intr(ch);
-       mic_dma_write_reg(ch, MIC_DMA_REG_DCHERRMSK, 0);
-       mic_dma_chan_set_desc_ring(ch);
-       ch->last_tail = mic_dma_read_reg(ch, MIC_DMA_REG_DTPR);
-       ch->head = ch->last_tail;
-       ch->issued = 0;
-       mic_dma_chan_unmask_intr(ch);
-       mic_dma_enable_chan(ch);
-       return mic_dma_check_chan(ch);
-}
-
-static void mic_dma_chan_destroy(struct mic_dma_chan *ch)
-{
-       mic_dma_disable_chan(ch);
-       mic_dma_chan_mask_intr(ch);
-}
-
-static int mic_dma_setup_irq(struct mic_dma_chan *ch)
-{
-       ch->cookie =
-               to_mbus_hw_ops(ch)->request_threaded_irq(to_mbus_device(ch),
-                       mic_dma_intr_handler, mic_dma_thread_fn,
-                       "mic dma_channel", ch, ch->ch_num);
-       return PTR_ERR_OR_ZERO(ch->cookie);
-}
-
-static inline void mic_dma_free_irq(struct mic_dma_chan *ch)
-{
-       to_mbus_hw_ops(ch)->free_irq(to_mbus_device(ch), ch->cookie, ch);
-}
-
-static int mic_dma_chan_init(struct mic_dma_chan *ch)
-{
-       int ret = mic_dma_alloc_desc_ring(ch);
-
-       if (ret)
-               goto ring_error;
-       ret = mic_dma_alloc_status_dest(ch);
-       if (ret)
-               goto status_error;
-       ret = mic_dma_chan_setup(ch);
-       if (ret)
-               goto chan_error;
-       return ret;
-chan_error:
-       mic_dma_free_status_dest(ch);
-status_error:
-       mic_dma_free_desc_ring(ch);
-ring_error:
-       return ret;
-}
-
-static int mic_dma_drain_chan(struct mic_dma_chan *ch)
-{
-       struct dma_async_tx_descriptor *tx;
-       int err = 0;
-       dma_cookie_t cookie;
-
-       tx = mic_dma_prep_memcpy_lock(&ch->api_ch, 0, 0, 0, DMA_PREP_FENCE);
-       if (!tx) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       cookie = tx->tx_submit(tx);
-       if (dma_submit_error(cookie))
-               err = -ENOMEM;
-       else
-               err = dma_sync_wait(&ch->api_ch, cookie);
-       if (err) {
-               dev_err(mic_dma_ch_to_device(ch), "%s %d TO chan 0x%x\n",
-                       __func__, __LINE__, ch->ch_num);
-               err = -EIO;
-       }
-error:
-       mic_dma_cleanup(ch);
-       return err;
-}
-
-static inline void mic_dma_chan_uninit(struct mic_dma_chan *ch)
-{
-       mic_dma_chan_destroy(ch);
-       mic_dma_cleanup(ch);
-       mic_dma_free_status_dest(ch);
-       mic_dma_free_desc_ring(ch);
-}
-
-static int mic_dma_init(struct mic_dma_device *mic_dma_dev,
-                       enum mic_dma_chan_owner owner)
-{
-       int i, first_chan = mic_dma_dev->start_ch;
-       struct mic_dma_chan *ch;
-       int ret;
-
-       for (i = first_chan; i < first_chan + MIC_DMA_NUM_CHAN; i++) {
-               ch = &mic_dma_dev->mic_ch[i];
-               ch->ch_num = i;
-               ch->owner = owner;
-               spin_lock_init(&ch->cleanup_lock);
-               spin_lock_init(&ch->prep_lock);
-               spin_lock_init(&ch->issue_lock);
-               ret = mic_dma_setup_irq(ch);
-               if (ret)
-                       goto error;
-       }
-       return 0;
-error:
-       for (i = i - 1; i >= first_chan; i--)
-               mic_dma_free_irq(ch);
-       return ret;
-}
-
-static void mic_dma_uninit(struct mic_dma_device *mic_dma_dev)
-{
-       int i, first_chan = mic_dma_dev->start_ch;
-       struct mic_dma_chan *ch;
-
-       for (i = first_chan; i < first_chan + MIC_DMA_NUM_CHAN; i++) {
-               ch = &mic_dma_dev->mic_ch[i];
-               mic_dma_free_irq(ch);
-       }
-}
-
-static int mic_dma_alloc_chan_resources(struct dma_chan *ch)
-{
-       int ret = mic_dma_chan_init(to_mic_dma_chan(ch));
-       if (ret)
-               return ret;
-       return MIC_DMA_DESC_RX_SIZE;
-}
-
-static void mic_dma_free_chan_resources(struct dma_chan *ch)
-{
-       struct mic_dma_chan *mic_ch = to_mic_dma_chan(ch);
-       mic_dma_drain_chan(mic_ch);
-       mic_dma_chan_uninit(mic_ch);
-}
-
-/* Set the fn. handlers and register the dma device with dma api */
-static int mic_dma_register_dma_device(struct mic_dma_device *mic_dma_dev,
-                                      enum mic_dma_chan_owner owner)
-{
-       int i, first_chan = mic_dma_dev->start_ch;
-
-       dma_cap_zero(mic_dma_dev->dma_dev.cap_mask);
-       /*
-        * This dma engine is not capable of host memory to host memory
-        * transfers
-        */
-       dma_cap_set(DMA_MEMCPY, mic_dma_dev->dma_dev.cap_mask);
-
-       if (MIC_DMA_CHAN_HOST == owner)
-               dma_cap_set(DMA_PRIVATE, mic_dma_dev->dma_dev.cap_mask);
-       mic_dma_dev->dma_dev.device_alloc_chan_resources =
-               mic_dma_alloc_chan_resources;
-       mic_dma_dev->dma_dev.device_free_chan_resources =
-               mic_dma_free_chan_resources;
-       mic_dma_dev->dma_dev.device_tx_status = mic_dma_tx_status;
-       mic_dma_dev->dma_dev.device_prep_dma_memcpy = mic_dma_prep_memcpy_lock;
-       mic_dma_dev->dma_dev.device_prep_dma_imm_data =
-               mic_dma_prep_status_lock;
-       mic_dma_dev->dma_dev.device_prep_dma_interrupt =
-               mic_dma_prep_interrupt_lock;
-       mic_dma_dev->dma_dev.device_issue_pending = mic_dma_issue_pending;
-       mic_dma_dev->dma_dev.copy_align = MIC_DMA_ALIGN_SHIFT;
-       INIT_LIST_HEAD(&mic_dma_dev->dma_dev.channels);
-       for (i = first_chan; i < first_chan + MIC_DMA_NUM_CHAN; i++) {
-               mic_dma_dev->mic_ch[i].api_ch.device = &mic_dma_dev->dma_dev;
-               dma_cookie_init(&mic_dma_dev->mic_ch[i].api_ch);
-               list_add_tail(&mic_dma_dev->mic_ch[i].api_ch.device_node,
-                             &mic_dma_dev->dma_dev.channels);
-       }
-       return dmaenginem_async_device_register(&mic_dma_dev->dma_dev);
-}
-
-/*
- * Initializes dma channels and registers the dma device with the
- * dma engine api.
- */
-static struct mic_dma_device *mic_dma_dev_reg(struct mbus_device *mbdev,
-                                             enum mic_dma_chan_owner owner)
-{
-       struct mic_dma_device *mic_dma_dev;
-       int ret;
-       struct device *dev = &mbdev->dev;
-
-       mic_dma_dev = devm_kzalloc(dev, sizeof(*mic_dma_dev), GFP_KERNEL);
-       if (!mic_dma_dev) {
-               ret = -ENOMEM;
-               goto alloc_error;
-       }
-       mic_dma_dev->mbdev = mbdev;
-       mic_dma_dev->dma_dev.dev = dev;
-       mic_dma_dev->mmio = mbdev->mmio_va;
-       if (MIC_DMA_CHAN_HOST == owner) {
-               mic_dma_dev->start_ch = 0;
-               mic_dma_dev->max_xfer_size = MIC_DMA_MAX_XFER_SIZE_HOST;
-       } else {
-               mic_dma_dev->start_ch = 4;
-               mic_dma_dev->max_xfer_size = MIC_DMA_MAX_XFER_SIZE_CARD;
-       }
-       ret = mic_dma_init(mic_dma_dev, owner);
-       if (ret)
-               goto init_error;
-       ret = mic_dma_register_dma_device(mic_dma_dev, owner);
-       if (ret)
-               goto reg_error;
-       return mic_dma_dev;
-reg_error:
-       mic_dma_uninit(mic_dma_dev);
-init_error:
-       mic_dma_dev = NULL;
-alloc_error:
-       dev_err(dev, "Error at %s %d ret=%d\n", __func__, __LINE__, ret);
-       return mic_dma_dev;
-}
-
-static void mic_dma_dev_unreg(struct mic_dma_device *mic_dma_dev)
-{
-       mic_dma_uninit(mic_dma_dev);
-}
-
-/* DEBUGFS CODE */
-static int mic_dma_reg_show(struct seq_file *s, void *pos)
-{
-       struct mic_dma_device *mic_dma_dev = s->private;
-       int i, chan_num, first_chan = mic_dma_dev->start_ch;
-       struct mic_dma_chan *ch;
-
-       seq_printf(s, "SBOX_DCR: %#x\n",
-                  mic_dma_mmio_read(&mic_dma_dev->mic_ch[first_chan],
-                                    MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR));
-       seq_puts(s, "DMA Channel Registers\n");
-       seq_printf(s, "%-10s| %-10s %-10s %-10s %-10s %-10s",
-                  "Channel", "DCAR", "DTPR", "DHPR", "DRAR_HI", "DRAR_LO");
-       seq_printf(s, " %-11s %-14s %-10s\n", "DCHERR", "DCHERRMSK", "DSTAT");
-       for (i = first_chan; i < first_chan + MIC_DMA_NUM_CHAN; i++) {
-               ch = &mic_dma_dev->mic_ch[i];
-               chan_num = ch->ch_num;
-               seq_printf(s, "%-10i| %-#10x %-#10x %-#10x %-#10x",
-                          chan_num,
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DCAR),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DTPR),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DHPR),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DRAR_HI));
-               seq_printf(s, " %-#10x %-#10x %-#14x %-#10x\n",
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DRAR_LO),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DCHERR),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DCHERRMSK),
-                          mic_dma_read_reg(ch, MIC_DMA_REG_DSTAT));
-       }
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mic_dma_reg);
-
-/* Debugfs parent dir */
-static struct dentry *mic_dma_dbg;
-
-static int mic_dma_driver_probe(struct mbus_device *mbdev)
-{
-       struct mic_dma_device *mic_dma_dev;
-       enum mic_dma_chan_owner owner;
-
-       if (MBUS_DEV_DMA_MIC == mbdev->id.device)
-               owner = MIC_DMA_CHAN_MIC;
-       else
-               owner = MIC_DMA_CHAN_HOST;
-
-       mic_dma_dev = mic_dma_dev_reg(mbdev, owner);
-       dev_set_drvdata(&mbdev->dev, mic_dma_dev);
-
-       if (mic_dma_dbg) {
-               mic_dma_dev->dbg_dir = debugfs_create_dir(dev_name(&mbdev->dev),
-                                                         mic_dma_dbg);
-               debugfs_create_file("mic_dma_reg", 0444, mic_dma_dev->dbg_dir,
-                                   mic_dma_dev, &mic_dma_reg_fops);
-       }
-       return 0;
-}
-
-static void mic_dma_driver_remove(struct mbus_device *mbdev)
-{
-       struct mic_dma_device *mic_dma_dev;
-
-       mic_dma_dev = dev_get_drvdata(&mbdev->dev);
-       debugfs_remove_recursive(mic_dma_dev->dbg_dir);
-       mic_dma_dev_unreg(mic_dma_dev);
-}
-
-static struct mbus_device_id id_table[] = {
-       {MBUS_DEV_DMA_MIC, MBUS_DEV_ANY_ID},
-       {MBUS_DEV_DMA_HOST, MBUS_DEV_ANY_ID},
-       {0},
-};
-
-static struct mbus_driver mic_dma_driver = {
-       .driver.name =  KBUILD_MODNAME,
-       .driver.owner = THIS_MODULE,
-       .id_table = id_table,
-       .probe = mic_dma_driver_probe,
-       .remove = mic_dma_driver_remove,
-};
-
-static int __init mic_x100_dma_init(void)
-{
-       int rc = mbus_register_driver(&mic_dma_driver);
-       if (rc)
-               return rc;
-       mic_dma_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-       return 0;
-}
-
-static void __exit mic_x100_dma_exit(void)
-{
-       debugfs_remove_recursive(mic_dma_dbg);
-       mbus_unregister_driver(&mic_dma_driver);
-}
-
-module_init(mic_x100_dma_init);
-module_exit(mic_x100_dma_exit);
-
-MODULE_DEVICE_TABLE(mbus, id_table);
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC X100 DMA Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/dma/mic_x100_dma.h b/drivers/dma/mic_x100_dma.h
deleted file mode 100644 (file)
index 68ef43a..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel MIC X100 DMA Driver.
- *
- * Adapted from IOAT dma driver.
- */
-#ifndef _MIC_X100_DMA_H_
-#define _MIC_X100_DMA_H_
-
-#include <linux/kernel.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/debugfs.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/mic_bus.h>
-
-#include "dmaengine.h"
-
-/*
- * MIC has a total of 8 dma channels.
- * Four channels are assigned for host SW use & the remaining for MIC SW.
- * MIC DMA transfer size & addresses need to be 64 byte aligned.
- */
-#define MIC_DMA_MAX_NUM_CHAN   8
-#define MIC_DMA_NUM_CHAN       4
-#define MIC_DMA_ALIGN_SHIFT    DMAENGINE_ALIGN_64_BYTES
-#define MIC_DMA_ALIGN_BYTES    (1 << MIC_DMA_ALIGN_SHIFT)
-#define MIC_DMA_DESC_RX_SIZE   (128 * 1024 - 4)
-
-/*
- * Register descriptions
- * All the registers are 32 bit registers.
- * DCR is a global register and all others are per-channel.
- * DCR - bits 0, 2, 4, 6, 8, 10, 12, 14 - enable bits for channels 0 to 7
- *      bits 1, 3, 5, 7, 9, 11, 13, 15 - owner bits for channels 0 to 7
- * DCAR - bit 24 & 25 interrupt masks for mic owned & host owned channels
- * DHPR - head of the descriptor ring updated by s/w
- * DTPR - tail of the descriptor ring updated by h/w
- * DRAR_LO - lower 32 bits of descriptor ring's mic address
- * DRAR_HI - 3:0 - remaining 4 bits of descriptor ring's mic address
- *          20:4 descriptor ring size
- *          25:21 mic smpt entry number
- * DSTAT - 16:0 h/w completion count; 31:28 dma engine status
- * DCHERR - this register is non-zero on error
- * DCHERRMSK - interrupt mask register
- */
-#define MIC_DMA_HW_CMP_CNT_MASK                0x1ffff
-#define MIC_DMA_CHAN_QUIESCE           0x20000000
-#define MIC_DMA_SBOX_BASE              0x00010000
-#define MIC_DMA_SBOX_DCR               0x0000A280
-#define MIC_DMA_SBOX_CH_BASE           0x0001A000
-#define MIC_DMA_SBOX_CHAN_OFF          0x40
-#define MIC_DMA_SBOX_DCAR_IM0          (0x1 << 24)
-#define MIC_DMA_SBOX_DCAR_IM1          (0x1 << 25)
-#define MIC_DMA_SBOX_DRARHI_SYS_MASK   (0x1 << 26)
-#define MIC_DMA_REG_DCAR               0
-#define MIC_DMA_REG_DHPR               4
-#define MIC_DMA_REG_DTPR               8
-#define MIC_DMA_REG_DRAR_LO            20
-#define MIC_DMA_REG_DRAR_HI            24
-#define MIC_DMA_REG_DSTAT              32
-#define MIC_DMA_REG_DCHERR             44
-#define MIC_DMA_REG_DCHERRMSK          48
-
-/* HW dma desc */
-struct mic_dma_desc {
-       u64 qw0;
-       u64 qw1;
-};
-
-enum mic_dma_chan_owner {
-       MIC_DMA_CHAN_MIC = 0,
-       MIC_DMA_CHAN_HOST
-};
-
-/*
- * mic_dma_chan - channel specific information
- * @ch_num: channel number
- * @owner: owner of this channel
- * @last_tail: cached value of descriptor ring tail
- * @head: index of next descriptor in desc_ring
- * @issued: hardware notification point
- * @submitted: index that will be used to submit descriptors to h/w
- * @api_ch: dma engine api channel
- * @desc_ring: dma descriptor ring
- * @desc_ring_micpa: mic physical address of desc_ring
- * @status_dest: destination for status (fence) descriptor
- * @status_dest_micpa: mic address for status_dest,
- *                    DMA controller uses this address
- * @tx_array: array of async_tx
- * @cleanup_lock: lock held when processing completed tx
- * @prep_lock: lock held in prep_memcpy & released in tx_submit
- * @issue_lock: lock used to synchronize writes to head
- * @cookie: mic_irq cookie used with mic irq request
- */
-struct mic_dma_chan {
-       int ch_num;
-       enum mic_dma_chan_owner owner;
-       u32 last_tail;
-       u32 head;
-       u32 issued;
-       u32 submitted;
-       struct dma_chan api_ch;
-       struct mic_dma_desc *desc_ring;
-       dma_addr_t desc_ring_micpa;
-       u64 *status_dest;
-       dma_addr_t status_dest_micpa;
-       struct dma_async_tx_descriptor *tx_array;
-       spinlock_t cleanup_lock;
-       spinlock_t prep_lock;
-       spinlock_t issue_lock;
-       struct mic_irq *cookie;
-};
-
-/*
- * struct mic_dma_device - per mic device
- * @mic_ch: dma channels
- * @dma_dev: underlying dma device
- * @mbdev: mic bus dma device
- * @mmio: virtual address of the mmio space
- * @dbg_dir: debugfs directory
- * @start_ch: first channel number that can be used
- * @max_xfer_size: maximum transfer size per dma descriptor
- */
-struct mic_dma_device {
-       struct mic_dma_chan mic_ch[MIC_DMA_MAX_NUM_CHAN];
-       struct dma_device dma_dev;
-       struct mbus_device *mbdev;
-       void __iomem *mmio;
-       struct dentry *dbg_dir;
-       int start_ch;
-       size_t max_xfer_size;
-};
-
-static inline struct mic_dma_chan *to_mic_dma_chan(struct dma_chan *ch)
-{
-       return container_of(ch, struct mic_dma_chan, api_ch);
-}
-
-static inline struct mic_dma_device *to_mic_dma_dev(struct mic_dma_chan *ch)
-{
-       return
-       container_of((const typeof(((struct mic_dma_device *)0)->mic_ch)*)
-                    (ch - ch->ch_num), struct mic_dma_device, mic_ch);
-}
-
-static inline struct mbus_device *to_mbus_device(struct mic_dma_chan *ch)
-{
-       return to_mic_dma_dev(ch)->mbdev;
-}
-
-static inline struct mbus_hw_ops *to_mbus_hw_ops(struct mic_dma_chan *ch)
-{
-       return to_mbus_device(ch)->hw_ops;
-}
-
-static inline struct device *mic_dma_ch_to_device(struct mic_dma_chan *ch)
-{
-       return to_mic_dma_dev(ch)->dma_dev.dev;
-}
-
-static inline void __iomem *mic_dma_chan_to_mmio(struct mic_dma_chan *ch)
-{
-       return to_mic_dma_dev(ch)->mmio;
-}
-
-static inline u32 mic_dma_read_reg(struct mic_dma_chan *ch, u32 reg)
-{
-       return ioread32(mic_dma_chan_to_mmio(ch) + MIC_DMA_SBOX_CH_BASE +
-                       ch->ch_num * MIC_DMA_SBOX_CHAN_OFF + reg);
-}
-
-static inline void mic_dma_write_reg(struct mic_dma_chan *ch, u32 reg, u32 val)
-{
-       iowrite32(val, mic_dma_chan_to_mmio(ch) + MIC_DMA_SBOX_CH_BASE +
-                 ch->ch_num * MIC_DMA_SBOX_CHAN_OFF + reg);
-}
-
-static inline u32 mic_dma_mmio_read(struct mic_dma_chan *ch, u32 offset)
-{
-       return ioread32(mic_dma_chan_to_mmio(ch) + offset);
-}
-
-static inline void mic_dma_mmio_write(struct mic_dma_chan *ch, u32 val,
-                                     u32 offset)
-{
-       iowrite32(val, mic_dma_chan_to_mmio(ch) + offset);
-}
-
-static inline u32 mic_dma_read_cmp_cnt(struct mic_dma_chan *ch)
-{
-       return mic_dma_read_reg(ch, MIC_DMA_REG_DSTAT) &
-              MIC_DMA_HW_CMP_CNT_MASK;
-}
-
-static inline void mic_dma_chan_set_owner(struct mic_dma_chan *ch)
-{
-       u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-       u32 chan_num = ch->ch_num;
-
-       dcr = (dcr & ~(0x1 << (chan_num * 2))) | (ch->owner << (chan_num * 2));
-       mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-}
-
-static inline void mic_dma_enable_chan(struct mic_dma_chan *ch)
-{
-       u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-
-       dcr |= 2 << (ch->ch_num << 1);
-       mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-}
-
-static inline void mic_dma_disable_chan(struct mic_dma_chan *ch)
-{
-       u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-
-       dcr &= ~(2 << (ch->ch_num << 1));
-       mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
-}
-
-static void mic_dma_chan_set_desc_ring(struct mic_dma_chan *ch)
-{
-       u32 drar_hi;
-       dma_addr_t desc_ring_micpa = ch->desc_ring_micpa;
-
-       drar_hi = (MIC_DMA_DESC_RX_SIZE & 0x1ffff) << 4;
-       if (MIC_DMA_CHAN_MIC == ch->owner) {
-               drar_hi |= (desc_ring_micpa >> 32) & 0xf;
-       } else {
-               drar_hi |= MIC_DMA_SBOX_DRARHI_SYS_MASK;
-               drar_hi |= ((desc_ring_micpa >> 34)
-                           & 0x1f) << 21;
-               drar_hi |= (desc_ring_micpa >> 32) & 0x3;
-       }
-       mic_dma_write_reg(ch, MIC_DMA_REG_DRAR_LO, (u32) desc_ring_micpa);
-       mic_dma_write_reg(ch, MIC_DMA_REG_DRAR_HI, drar_hi);
-}
-
-static inline void mic_dma_chan_mask_intr(struct mic_dma_chan *ch)
-{
-       u32 dcar = mic_dma_read_reg(ch, MIC_DMA_REG_DCAR);
-
-       if (MIC_DMA_CHAN_MIC == ch->owner)
-               dcar |= MIC_DMA_SBOX_DCAR_IM0;
-       else
-               dcar |= MIC_DMA_SBOX_DCAR_IM1;
-       mic_dma_write_reg(ch, MIC_DMA_REG_DCAR, dcar);
-}
-
-static inline void mic_dma_chan_unmask_intr(struct mic_dma_chan *ch)
-{
-       u32 dcar = mic_dma_read_reg(ch, MIC_DMA_REG_DCAR);
-
-       if (MIC_DMA_CHAN_MIC == ch->owner)
-               dcar &= ~MIC_DMA_SBOX_DCAR_IM0;
-       else
-               dcar &= ~MIC_DMA_SBOX_DCAR_IM1;
-       mic_dma_write_reg(ch, MIC_DMA_REG_DCAR, dcar);
-}
-
-static void mic_dma_ack_interrupt(struct mic_dma_chan *ch)
-{
-       if (MIC_DMA_CHAN_MIC == ch->owner) {
-               /* HW errata */
-               mic_dma_chan_mask_intr(ch);
-               mic_dma_chan_unmask_intr(ch);
-       }
-       to_mbus_hw_ops(ch)->ack_interrupt(to_mbus_device(ch), ch->ch_num);
-}
-#endif
index 9853bd3c4d456b490855a36425935b29378427c6..017e5d8bd869a752d14bd7cdf58032e9d8a96787 100644 (file)
@@ -197,6 +197,8 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
                        protocols_imp[tot_num_ret + loop] = *(list + loop);
 
                tot_num_ret += loop_num_ret;
+
+               scmi_reset_rx_to_maxsz(handle, t);
        } while (loop_num_ret);
 
        scmi_xfer_put(handle, t);
index c1cfe3ee3d55a826ff1f97ca8156873a61c212ca..4645677d86f1b1648bccfb99c9f88a2393a98dff 100644 (file)
@@ -192,6 +192,8 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
                }
 
                tot_rate_cnt += num_returned;
+
+               scmi_reset_rx_to_maxsz(handle, t);
                /*
                 * check for both returned and remaining to avoid infinite
                 * loop due to buggy firmware
index 37fb583f1bf5f9e1362b121ca6eb9796345009fc..65063fa948d412e41b81aff9489bcfd0802fd8e2 100644 (file)
@@ -147,6 +147,8 @@ int scmi_do_xfer_with_response(const struct scmi_handle *h,
                               struct scmi_xfer *xfer);
 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);
+void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle,
+                           struct scmi_xfer *xfer);
 int scmi_handle_put(const struct scmi_handle *handle);
 struct scmi_handle *scmi_handle_get(struct device *dev);
 void scmi_set_handle(struct scmi_device *scmi_dev);
index c5dea87edf8f2c61b6be519232434be9a91e6f50..3dfd8b6a0ebf789089c17d87a3348619fbccfc27 100644 (file)
@@ -402,6 +402,14 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
        return ret;
 }
 
+void scmi_reset_rx_to_maxsz(const struct scmi_handle *handle,
+                           struct scmi_xfer *xfer)
+{
+       struct scmi_info *info = handle_to_scmi_info(handle);
+
+       xfer->rx.len = info->desc->max_msg_size;
+}
+
 #define SCMI_MAX_RESPONSE_TIMEOUT      (2 * MSEC_PER_SEC)
 
 /**
index 2754f9d01636ae711eb31d8ca3f6f83c5bac02d6..ce336899d6366172487dab71e9c9ca77778f3848 100644 (file)
@@ -1403,15 +1403,21 @@ static void scmi_protocols_late_init(struct work_struct *work)
                                "finalized PENDING handler - key:%X\n",
                                hndl->key);
                        ret = scmi_event_handler_enable_events(hndl);
+                       if (ret) {
+                               dev_dbg(ni->handle->dev,
+                                       "purging INVALID handler - key:%X\n",
+                                       hndl->key);
+                               scmi_put_active_handler(ni, hndl);
+                       }
                } else {
                        ret = scmi_valid_pending_handler(ni, hndl);
-               }
-               if (ret) {
-                       dev_dbg(ni->handle->dev,
-                               "purging PENDING handler - key:%X\n",
-                               hndl->key);
-                       /* this hndl can be only a pending one */
-                       scmi_put_handler_unlocked(ni, hndl);
+                       if (ret) {
+                               dev_dbg(ni->handle->dev,
+                                       "purging PENDING handler - key:%X\n",
+                                       hndl->key);
+                               /* this hndl can be only a pending one */
+                               scmi_put_handler_unlocked(ni, hndl);
+                       }
                }
        }
        mutex_unlock(&ni->pending_mtx);
@@ -1468,7 +1474,7 @@ int scmi_notification_init(struct scmi_handle *handle)
        ni->gid = gid;
        ni->handle = handle;
 
-       ni->notify_wq = alloc_workqueue("scmi_notify",
+       ni->notify_wq = alloc_workqueue(dev_name(handle->dev),
                                        WQ_UNBOUND | WQ_FREEZABLE | WQ_SYSFS,
                                        0);
        if (!ni->notify_wq)
index ed475b40bd083a0d20424977cfa223633e1199f0..82fb3babff72133f67997491b30beb8a575d87c2 100644 (file)
@@ -304,6 +304,8 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
                }
 
                tot_opp_cnt += num_returned;
+
+               scmi_reset_rx_to_maxsz(handle, t);
                /*
                 * check for both returned and remaining to avoid infinite
                 * loop due to buggy firmware
index f063cfe17e0299b04185b47a070c18a779227a4b..a981a22cfe8912b4ae68bbadc18f275ada8c514f 100644 (file)
@@ -36,9 +36,7 @@ struct scmi_msg_reset_domain_reset {
 #define EXPLICIT_RESET_ASSERT  BIT(1)
 #define ASYNCHRONOUS_RESET     BIT(2)
        __le32 reset_state;
-#define ARCH_RESET_TYPE                BIT(31)
-#define COLD_RESET_STATE       BIT(0)
-#define ARCH_COLD_RESET                (ARCH_RESET_TYPE | COLD_RESET_STATE)
+#define ARCH_COLD_RESET                0
 };
 
 struct scmi_msg_reset_notify {
index 9703cf6356a0452c3af99d608c6ba52febd6c901..b4232d611033e5ff83168bf6a20772bbe6801c88 100644 (file)
@@ -166,6 +166,8 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
                }
 
                desc_index += num_returned;
+
+               scmi_reset_rx_to_maxsz(handle, t);
                /*
                 * check for both returned and remaining to avoid infinite
                 * loop due to buggy firmware
index 1a03c3ec02300226384d32ad2d1219e9dade9edf..82a82a5dc86ae0e7554256a33d1e9d1e10909901 100644 (file)
@@ -149,6 +149,6 @@ static const struct scmi_transport_ops scmi_smc_ops = {
 const struct scmi_desc scmi_smc_desc = {
        .ops = &scmi_smc_ops,
        .max_rx_timeout_ms = 30,
-       .max_msg = 1,
+       .max_msg = 20,
        .max_msg_size = 128,
 };
index 840754dcc6ca4429ac17b7e398cc5a8ca70fd6e4..a7e762c352f950d68289e4048eaae657bc031d38 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/slab.h>
 #include <linux/smp.h>
 #include <linux/spinlock.h>
-#include <linux/uaccess.h>
 
 /*
  * The call to use to reach the firmware.
@@ -1092,26 +1091,13 @@ int sdei_event_handler(struct pt_regs *regs,
                       struct sdei_registered_event *arg)
 {
        int err;
-       mm_segment_t orig_addr_limit;
        u32 event_num = arg->event_num;
 
-       /*
-        * Save restore 'fs'.
-        * The architecture's entry code save/restores 'fs' when taking an
-        * exception from the kernel. This ensures addr_limit isn't inherited
-        * if you interrupted something that allowed the uaccess routines to
-        * access kernel memory.
-        * Do the same here because this doesn't come via the same entry code.
-       */
-       orig_addr_limit = force_uaccess_begin();
-
        err = arg->callback(event_num, regs, arg->callback_arg);
        if (err)
                pr_err_ratelimited("event %u on CPU %u failed with error: %d\n",
                                   event_num, smp_processor_id(), err);
 
-       force_uaccess_end(orig_addr_limit);
-
        return err;
 }
 NOKPROBE_SYMBOL(sdei_event_handler);
index 37da3537ba2e723247b274eee8699ff9f5e62e04..e3783f5a459d555050a0ec5b41a3ecc3b2d75186 100644 (file)
@@ -80,6 +80,7 @@ MODULE_FIRMWARE("amdgpu/renoir_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/navi10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/navi14_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/navi12_gpu_info.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_gpu_info.bin");
 
 #define AMDGPU_RESUME_MS               2000
 
@@ -239,9 +240,11 @@ bool amdgpu_device_supports_baco(struct drm_device *dev)
        return amdgpu_asic_supports_baco(adev);
 }
 
+/*
+ * VRAM access helper functions
+ */
+
 /**
- * VRAM access helper functions.
- *
  * amdgpu_device_vram_access - read/write a buffer in vram
  *
  * @adev: amdgpu_device pointer
@@ -705,7 +708,7 @@ void amdgpu_device_indirect_wreg64(struct amdgpu_device *adev,
 /**
  * amdgpu_invalid_rreg - dummy reg read function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @reg: offset of register
  *
  * Dummy register read function.  Used for register blocks
@@ -722,7 +725,7 @@ static uint32_t amdgpu_invalid_rreg(struct amdgpu_device *adev, uint32_t reg)
 /**
  * amdgpu_invalid_wreg - dummy reg write function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @reg: offset of register
  * @v: value to write to the register
  *
@@ -739,7 +742,7 @@ static void amdgpu_invalid_wreg(struct amdgpu_device *adev, uint32_t reg, uint32
 /**
  * amdgpu_invalid_rreg64 - dummy 64 bit reg read function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @reg: offset of register
  *
  * Dummy register read function.  Used for register blocks
@@ -756,7 +759,7 @@ static uint64_t amdgpu_invalid_rreg64(struct amdgpu_device *adev, uint32_t reg)
 /**
  * amdgpu_invalid_wreg64 - dummy reg write function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @reg: offset of register
  * @v: value to write to the register
  *
@@ -773,7 +776,7 @@ static void amdgpu_invalid_wreg64(struct amdgpu_device *adev, uint32_t reg, uint
 /**
  * amdgpu_block_invalid_rreg - dummy reg read function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @block: offset of instance
  * @reg: offset of register
  *
@@ -793,7 +796,7 @@ static uint32_t amdgpu_block_invalid_rreg(struct amdgpu_device *adev,
 /**
  * amdgpu_block_invalid_wreg - dummy reg write function
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @block: offset of instance
  * @reg: offset of register
  * @v: value to write to the register
@@ -813,7 +816,7 @@ static void amdgpu_block_invalid_wreg(struct amdgpu_device *adev,
 /**
  * amdgpu_device_asic_init - Wrapper for atom asic_init
  *
- * @dev: drm_device pointer
+ * @adev: amdgpu_device pointer
  *
  * Does any asic specific work and then calls atom asic init.
  */
@@ -827,7 +830,7 @@ static int amdgpu_device_asic_init(struct amdgpu_device *adev)
 /**
  * amdgpu_device_vram_scratch_init - allocate the VRAM scratch page
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  *
  * Allocates a scratch page of VRAM for use by various things in the
  * driver.
@@ -844,7 +847,7 @@ static int amdgpu_device_vram_scratch_init(struct amdgpu_device *adev)
 /**
  * amdgpu_device_vram_scratch_fini - Free the VRAM scratch page
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  *
  * Frees the VRAM scratch page.
  */
@@ -1803,7 +1806,10 @@ static int amdgpu_device_parse_gpu_info_fw(struct amdgpu_device *adev)
                chip_name = "arcturus";
                break;
        case CHIP_RENOIR:
-               chip_name = "renoir";
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       chip_name = "renoir";
+               else
+                       chip_name = "green_sardine";
                break;
        case CHIP_NAVI10:
                chip_name = "navi10";
@@ -3011,7 +3017,7 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)
 /**
  * amdgpu_device_has_dc_support - check if dc is supported
  *
- * @adev: amdgpu_device_pointer
+ * @adev: amdgpu_device pointer
  *
  * Returns true for supported, false for not supported
  */
@@ -4045,7 +4051,7 @@ static int amdgpu_device_recover_vram(struct amdgpu_device *adev)
 /**
  * amdgpu_device_reset_sriov - reset ASIC for SR-IOV vf
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @from_hypervisor: request from hypervisor
  *
  * do VF FLR and reinitialize Asic
@@ -4100,7 +4106,7 @@ error:
 /**
  * amdgpu_device_has_job_running - check if there is any job in mirror list
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  *
  * check if there is any job in mirror list
  */
@@ -4128,7 +4134,7 @@ bool amdgpu_device_has_job_running(struct amdgpu_device *adev)
 /**
  * amdgpu_device_should_recover_gpu - check if we should try GPU recovery
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  *
  * Check amdgpu_gpu_recovery and SRIOV status to see if we should try to recover
  * a hung GPU.
@@ -4477,7 +4483,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
 /**
  * amdgpu_device_gpu_recover - reset the asic and recover scheduler
  *
- * @adev: amdgpu device pointer
+ * @adev: amdgpu_device pointer
  * @job: which job trigger hang
  *
  * Attempt to reset the GPU if it has hung (all asics).
@@ -4497,7 +4503,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
        bool need_emergency_restart = false;
        bool audio_suspended = false;
 
-       /**
+       /*
         * Special case: RAS triggered and full reset isn't supported
         */
        need_emergency_restart = amdgpu_ras_need_emergency_restart(adev);
index c241317edee7813a8530336d43f319582b766ebe..42d9748921f5e3b5732d0915b3e9bcd54c6c3a34 100644 (file)
@@ -1066,6 +1066,7 @@ static const struct pci_device_id pciidlist[] = {
        {0x1002, 0x7319, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
        {0x1002, 0x731A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
        {0x1002, 0x731B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
+       {0x1002, 0x731E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
        {0x1002, 0x731F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI10},
        /* Navi14 */
        {0x1002, 0x7340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI14},
index aa7f230c71bf5aa48328accb28fa2d417282183e..7e8265da9f2508e1eb9e584e9848462a45cd63fc 100644 (file)
@@ -596,6 +596,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
        struct ww_acquire_ctx ticket;
        struct list_head list, duplicates;
        uint64_t va_flags;
+       uint64_t vm_size;
        int r = 0;
 
        if (args->va_address < AMDGPU_VA_RESERVED_SIZE) {
@@ -616,6 +617,15 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
 
        args->va_address &= AMDGPU_GMC_HOLE_MASK;
 
+       vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
+       vm_size -= AMDGPU_VA_RESERVED_SIZE;
+       if (args->va_address + args->map_size > vm_size) {
+               dev_dbg(&dev->pdev->dev,
+                       "va_address 0x%llx is in top reserved area 0x%llx\n",
+                       args->va_address + args->map_size, vm_size);
+               return -EINVAL;
+       }
+
        if ((args->flags & ~valid_flags) && (args->flags & ~prt_flags)) {
                dev_dbg(&dev->pdev->dev, "invalid flags combination 0x%08X\n",
                        args->flags);
index f203e4a6a3f2b062dce032044229d109e817def3..731f3aa2e6ba64b6a5dcbd5a0af758b468f49a0a 100644 (file)
@@ -81,8 +81,8 @@ static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
 /**
  * amdgpu_gtt_mgr_init - init GTT manager and DRM MM
  *
- * @man: TTM memory type manager
- * @p_size: maximum size of GTT
+ * @adev: amdgpu_device pointer
+ * @gtt_size: maximum size of GTT
  *
  * Allocate and initialize the GTT manager.
  */
@@ -123,7 +123,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
 /**
  * amdgpu_gtt_mgr_fini - free and destroy GTT manager
  *
- * @man: TTM memory type manager
+ * @adev: amdgpu_device pointer
  *
  * Destroy and free the GTT manager, returns -EBUSY if ranges are still
  * allocated inside it.
index 96a9699f87ba840256bf69b924aa76db9e19763c..a6dbe4b83533f7888a2e60bf36350d5951247062 100644 (file)
@@ -2524,6 +2524,7 @@ int parse_ta_bin_descriptor(struct psp_context *psp,
                psp->asd_feature_version   = le32_to_cpu(desc->fw_version);
                psp->asd_ucode_size        = le32_to_cpu(desc->size_bytes);
                psp->asd_start_addr        = ucode_start_addr;
+               psp->asd_fw                = psp->ta_fw;
                break;
        case TA_FW_TYPE_PSP_XGMI:
                psp->ta_xgmi_ucode_version = le32_to_cpu(desc->fw_version);
index f3b7287e84c43ea433a8bbcc9a959842059517dd..a563328e3daea297e3eb836940ddf3caad5d07a7 100644 (file)
@@ -39,6 +39,7 @@
 #define FIRMWARE_RAVEN2                "amdgpu/raven2_vcn.bin"
 #define FIRMWARE_ARCTURUS      "amdgpu/arcturus_vcn.bin"
 #define FIRMWARE_RENOIR        "amdgpu/renoir_vcn.bin"
+#define FIRMWARE_GREEN_SARDINE         "amdgpu/green_sardine_vcn.bin"
 #define FIRMWARE_NAVI10        "amdgpu/navi10_vcn.bin"
 #define FIRMWARE_NAVI14        "amdgpu/navi14_vcn.bin"
 #define FIRMWARE_NAVI12        "amdgpu/navi12_vcn.bin"
@@ -50,6 +51,7 @@ MODULE_FIRMWARE(FIRMWARE_PICASSO);
 MODULE_FIRMWARE(FIRMWARE_RAVEN2);
 MODULE_FIRMWARE(FIRMWARE_ARCTURUS);
 MODULE_FIRMWARE(FIRMWARE_RENOIR);
+MODULE_FIRMWARE(FIRMWARE_GREEN_SARDINE);
 MODULE_FIRMWARE(FIRMWARE_NAVI10);
 MODULE_FIRMWARE(FIRMWARE_NAVI14);
 MODULE_FIRMWARE(FIRMWARE_NAVI12);
@@ -89,7 +91,11 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
                        adev->vcn.indirect_sram = true;
                break;
        case CHIP_RENOIR:
-               fw_name = FIRMWARE_RENOIR;
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       fw_name = FIRMWARE_RENOIR;
+               else
+                       fw_name = FIRMWARE_GREEN_SARDINE;
+
                if ((adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) &&
                    (adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG))
                        adev->vcn.indirect_sram = true;
index c6abb16e80182705921b0a02a232da9de0e1bda6..58c83a7ad0fd9d224b7339cbcd5c1d949769b977 100644 (file)
@@ -112,8 +112,8 @@ struct amdgpu_bo_list_entry;
 #define AMDGPU_MMHUB_0                         1
 #define AMDGPU_MMHUB_1                         2
 
-/* hardcode that limit for now */
-#define AMDGPU_VA_RESERVED_SIZE                        (1ULL << 20)
+/* Reserve 2MB at top/bottom of address space for kernel use */
+#define AMDGPU_VA_RESERVED_SIZE                        (2ULL << 20)
 
 /* max vmids dedicated for process */
 #define AMDGPU_VM_MAX_RESERVED_VMID    1
index 01c1171afbe02f18208128f37b4e001cfffafc48..0c6b7c5ecfec897a4868475e3823b3f5f57a8522 100644 (file)
@@ -168,8 +168,7 @@ static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
 /**
  * amdgpu_vram_mgr_init - init VRAM manager and DRM MM
  *
- * @man: TTM memory type manager
- * @p_size: maximum size of VRAM
+ * @adev: amdgpu_device pointer
  *
  * Allocate and initialize the VRAM manager.
  */
@@ -199,7 +198,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
 /**
  * amdgpu_vram_mgr_fini - free and destroy VRAM manager
  *
- * @man: TTM memory type manager
+ * @adev: amdgpu_device pointer
  *
  * Destroy and free the VRAM manager, returns -EBUSY if ranges are still
  * allocated inside it.
@@ -229,7 +228,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
 /**
  * amdgpu_vram_mgr_vis_size - Calculate visible node size
  *
- * @adev: amdgpu device structure
+ * @adev: amdgpu_device pointer
  * @node: MM node structure
  *
  * Calculate how many bytes of the MM node are inside visible VRAM
index 03ff8bd1fee84df67998a4be24adc8e3ed26c526..5442df0941024c83324de7a5685d7f66498c21ca 100644 (file)
@@ -1336,11 +1336,13 @@ cik_asic_reset_method(struct amdgpu_device *adev)
 
        switch (adev->asic_type) {
        case CHIP_BONAIRE:
-       case CHIP_HAWAII:
                /* disable baco reset until it works */
                /* smu7_asic_get_baco_capability(adev, &baco_reset); */
                baco_reset = false;
                break;
+       case CHIP_HAWAII:
+               baco_reset = cik_asic_supports_baco(adev);
+               break;
        default:
                baco_reset = false;
                break;
index 20f108818b2b966f5893f05e7b72e233d0b3054a..a3c3fe96515f2133cbe79382f822951deaea9fc9 100644 (file)
@@ -1071,22 +1071,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
        u32 srbm_soft_reset = 0;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-       u32 tmp = RREG32(mmSRBM_STATUS2);
+       u32 tmp;
 
-       if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-               /* sdma0 */
-               tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-               tmp |= SDMA0_F32_CNTL__HALT_MASK;
-               WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-               srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-       }
-       if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-               /* sdma1 */
-               tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-               tmp |= SDMA0_F32_CNTL__HALT_MASK;
-               WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-               srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-       }
+       /* sdma0 */
+       tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+       tmp |= SDMA0_F32_CNTL__HALT_MASK;
+       WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+       srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+       /* sdma1 */
+       tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+       tmp |= SDMA0_F32_CNTL__HALT_MASK;
+       WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+       srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
        if (srbm_soft_reset) {
                tmp = RREG32(mmSRBM_SOFT_RESET);
index 56fdbe626d3031f58e4adc5a9f92f451dc84b425..3579565e0eabc2819d6d01ce869b4f8c499c84b9 100644 (file)
 #define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO__SHIFT 0x3
 #define PA_SC_ENHANCE_3__FORCE_PBB_WORKLOAD_MODE_TO_ZERO_MASK   0x00000008L
 
+#define mmCGTT_SPI_CS_CLK_CTRL                 0x507c
+#define mmCGTT_SPI_CS_CLK_CTRL_BASE_IDX         1
+
 MODULE_FIRMWARE("amdgpu/navi10_ce.bin");
 MODULE_FIRMWARE("amdgpu/navi10_pfp.bin");
 MODULE_FIRMWARE("amdgpu/navi10_me.bin");
@@ -3094,6 +3097,7 @@ static const struct soc15_reg_golden golden_settings_gc_rlc_spm_10_1_2_nv12[] =
 
 static const struct soc15_reg_golden golden_settings_gc_10_3[] =
 {
+       SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_CS_CLK_CTRL, 0x78000000, 0x78000100),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_PS_CLK_CTRL, 0xff7f0fff, 0x78000100),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_RA0_CLK_CTRL, 0xff7f0fff, 0x30000100),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmCGTT_SPI_RA1_CLK_CTRL, 0xff7f0fff, 0x7e000100),
index 6959aebae6d41833ec664f7b924216238e4f56c4..0d8e203b10efb2a645d67e8cc51384f811bd698b 100644 (file)
@@ -117,6 +117,13 @@ MODULE_FIRMWARE("amdgpu/renoir_mec.bin");
 MODULE_FIRMWARE("amdgpu/renoir_mec2.bin");
 MODULE_FIRMWARE("amdgpu/renoir_rlc.bin");
 
+MODULE_FIRMWARE("amdgpu/green_sardine_ce.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_pfp.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_me.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_mec.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_mec2.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_rlc.bin");
+
 #define mmTCP_CHAN_STEER_0_ARCT                                                                0x0b03
 #define mmTCP_CHAN_STEER_0_ARCT_BASE_IDX                                                       0
 #define mmTCP_CHAN_STEER_1_ARCT                                                                0x0b04
@@ -1630,7 +1637,10 @@ static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
                chip_name = "arcturus";
                break;
        case CHIP_RENOIR:
-               chip_name = "renoir";
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       chip_name = "renoir";
+               else
+                       chip_name = "green_sardine";
                break;
        default:
                BUG();
index 1ce741a0c6a74ce0fe183dfc635e50e9cb0039e9..d5715c1d177bad7c2a6a0dbe2ceffc5665bbc31a 100644 (file)
@@ -455,6 +455,15 @@ void nv_set_virt_ops(struct amdgpu_device *adev)
        adev->virt.ops = &xgpu_nv_virt_ops;
 }
 
+static bool nv_is_headless_sku(struct pci_dev *pdev)
+{
+       if ((pdev->device == 0x731E &&
+           (pdev->revision == 0xC6 || pdev->revision == 0xC7)) ||
+           (pdev->device == 0x7340 && pdev->revision == 0xC9))
+               return true;
+       return false;
+}
+
 int nv_set_ip_blocks(struct amdgpu_device *adev)
 {
        int r;
@@ -483,7 +492,8 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
                if (adev->enable_virtual_display || amdgpu_sriov_vf(adev))
                        amdgpu_device_ip_block_add(adev, &dce_virtual_ip_block);
 #if defined(CONFIG_DRM_AMD_DC)
-               else if (amdgpu_device_has_dc_support(adev))
+               else if (amdgpu_device_has_dc_support(adev) &&
+                        !nv_is_headless_sku(adev->pdev))
                        amdgpu_device_ip_block_add(adev, &dm_ip_block);
 #endif
                amdgpu_device_ip_block_add(adev, &gfx_v10_0_ip_block);
@@ -491,7 +501,8 @@ int nv_set_ip_blocks(struct amdgpu_device *adev)
                if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT &&
                    !amdgpu_sriov_vf(adev))
                        amdgpu_device_ip_block_add(adev, &smu_v11_0_ip_block);
-               amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
+               if (!nv_is_headless_sku(adev->pdev))
+                       amdgpu_device_ip_block_add(adev, &vcn_v2_0_ip_block);
                amdgpu_device_ip_block_add(adev, &jpeg_v2_0_ip_block);
                if (adev->enable_mes)
                        amdgpu_device_ip_block_add(adev, &mes_v10_1_ip_block);
index 75489313dbadf77ad7c48616a40526180a43cf0a..dff5c15b4858e2ef8057da6cb5465dda344b8d34 100644 (file)
@@ -39,6 +39,7 @@
 
 MODULE_FIRMWARE("amdgpu/renoir_asd.bin");
 MODULE_FIRMWARE("amdgpu/renoir_ta.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_asd.bin");
 
 /* address block */
 #define smnMP1_FIRMWARE_FLAGS          0x3010024
@@ -54,7 +55,10 @@ static int psp_v12_0_init_microcode(struct psp_context *psp)
 
        switch (adev->asic_type) {
        case CHIP_RENOIR:
-               chip_name = "renoir";
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       chip_name = "renoir";
+               else
+                       chip_name = "green_sardine";
                break;
        default:
                BUG();
index 86fb1eddf5a6f0ece961190362341e9d0a4edbba..e82f49f62f6e6d81525197cb817323c0d960cd03 100644 (file)
@@ -69,6 +69,7 @@ MODULE_FIRMWARE("amdgpu/picasso_sdma.bin");
 MODULE_FIRMWARE("amdgpu/raven2_sdma.bin");
 MODULE_FIRMWARE("amdgpu/arcturus_sdma.bin");
 MODULE_FIRMWARE("amdgpu/renoir_sdma.bin");
+MODULE_FIRMWARE("amdgpu/green_sardine_sdma.bin");
 
 #define SDMA0_POWER_CNTL__ON_OFF_CONDITION_HOLD_TIME_MASK  0x000000F8L
 #define SDMA0_POWER_CNTL__ON_OFF_STATUS_DURATION_TIME_MASK 0xFC000000L
@@ -619,7 +620,10 @@ static int sdma_v4_0_init_microcode(struct amdgpu_device *adev)
                chip_name = "arcturus";
                break;
        case CHIP_RENOIR:
-               chip_name = "renoir";
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       chip_name = "renoir";
+               else
+                       chip_name = "green_sardine";
                break;
        default:
                BUG();
index afcccc6c0fc619380d625fa415e1b6be8bbea2f8..f57c5f57efa8a9e90d64765fdfef080954038a76 100644 (file)
@@ -1195,8 +1195,7 @@ static int soc15_common_early_init(void *handle)
 
                        adev->pg_flags = AMD_PG_SUPPORT_SDMA |
                                AMD_PG_SUPPORT_MMHUB |
-                               AMD_PG_SUPPORT_VCN |
-                               AMD_PG_SUPPORT_VCN_DPG;
+                               AMD_PG_SUPPORT_VCN;
                } else {
                        adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
                                AMD_CG_SUPPORT_GFX_MGLS |
@@ -1243,7 +1242,15 @@ static int soc15_common_early_init(void *handle)
                break;
        case CHIP_RENOIR:
                adev->asic_funcs = &soc15_asic_funcs;
-               adev->apu_flags |= AMD_APU_IS_RENOIR;
+               if (adev->pdev->device == 0x1636)
+                       adev->apu_flags |= AMD_APU_IS_RENOIR;
+               else
+                       adev->apu_flags |= AMD_APU_IS_GREEN_SARDINE;
+
+               if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                       adev->external_rev_id = adev->rev_id + 0x91;
+               else
+                       adev->external_rev_id = adev->rev_id + 0xa1;
                adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
                                 AMD_CG_SUPPORT_GFX_MGLS |
                                 AMD_CG_SUPPORT_GFX_3D_CGCG |
@@ -1268,7 +1275,6 @@ static int soc15_common_early_init(void *handle)
                                 AMD_PG_SUPPORT_VCN |
                                 AMD_PG_SUPPORT_JPEG |
                                 AMD_PG_SUPPORT_VCN_DPG;
-               adev->external_rev_id = adev->rev_id + 0x91;
                break;
        default:
                /* FIXME: not supported yet */
index 5e2254b9e93165bb03af515256ebf1e3a67aead6..3de5e14c5ae316f559518e13bbf73ef2922da386 100644 (file)
@@ -798,10 +798,10 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)
        }
 
        pcrat_image = kvmalloc(crat_table->length, GFP_KERNEL);
-       memcpy(pcrat_image, crat_table, crat_table->length);
        if (!pcrat_image)
                return -ENOMEM;
 
+       memcpy(pcrat_image, crat_table, crat_table->length);
        *crat_image = pcrat_image;
        *size = crat_table->length;
 
index f24abf428534e4f8bde0d760fa5a1e8cabfa18e0..60dfdd432aba0ed47e723d259e6313a5dad4557a 100644 (file)
@@ -42,6 +42,7 @@ config DRM_AMD_DC_SI
 config DEBUG_KERNEL_DC
        bool "Enable kgdb break in DC"
        depends on DRM_AMD_DC
+       depends on KGDB
        help
          Choose this option if you want to hit kdgb_break in assert.
 
index e2b23486ba4c9dac4f8f30570c07bc5e12327249..e93e18c06c0e9482be6d77b6d5d32eda0a6cc19f 100644 (file)
@@ -100,6 +100,8 @@ MODULE_FIRMWARE(FIRMWARE_SIENNA_CICHLID_DMUB);
 #define FIRMWARE_NAVY_FLOUNDER_DMUB "amdgpu/navy_flounder_dmcub.bin"
 MODULE_FIRMWARE(FIRMWARE_NAVY_FLOUNDER_DMUB);
 #endif
+#define FIRMWARE_GREEN_SARDINE_DMUB "amdgpu/green_sardine_dmcub.bin"
+MODULE_FIRMWARE(FIRMWARE_GREEN_SARDINE_DMUB);
 
 #define FIRMWARE_RAVEN_DMCU            "amdgpu/raven_dmcu.bin"
 MODULE_FIRMWARE(FIRMWARE_RAVEN_DMCU);
@@ -583,7 +585,7 @@ static void amdgpu_dm_fbc_init(struct drm_connector *connector)
 {
        struct drm_device *dev = connector->dev;
        struct amdgpu_device *adev = drm_to_adev(dev);
-       struct dm_comressor_info *compressor = &adev->dm.compressor;
+       struct dm_compressor_info *compressor = &adev->dm.compressor;
        struct amdgpu_dm_connector *aconn = to_amdgpu_dm_connector(connector);
        struct drm_display_mode *mode;
        unsigned long max_size = 0;
@@ -973,6 +975,8 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
        case CHIP_RAVEN:
        case CHIP_RENOIR:
                init_data.flags.gpu_vm_support = true;
+               if (ASICREV_IS_GREEN_SARDINE(adev->external_rev_id))
+                       init_data.flags.disable_dmcu = true;
                break;
        default:
                break;
@@ -1267,6 +1271,8 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
        case CHIP_RENOIR:
                dmub_asic = DMUB_ASIC_DCN21;
                fw_name_dmub = FIRMWARE_RENOIR_DMUB;
+               if (ASICREV_IS_GREEN_SARDINE(adev->external_rev_id))
+                       fw_name_dmub = FIRMWARE_GREEN_SARDINE_DMUB;
                break;
 #if defined(CONFIG_DRM_AMD_DC_DCN3_0)
        case CHIP_SIENNA_CICHLID:
index 34f6369bf51fb34d8fb27860928887a86568b21e..a8a0e8cb1a118f8da0bb0eec81ceb7aa730c3a77 100644 (file)
@@ -86,7 +86,7 @@ struct irq_list_head {
  * @bo_ptr: Pointer to the buffer object
  * @gpu_addr: MMIO gpu addr
  */
-struct dm_comressor_info {
+struct dm_compressor_info {
        void *cpu_addr;
        struct amdgpu_bo *bo_ptr;
        uint64_t gpu_addr;
@@ -148,7 +148,7 @@ struct amdgpu_dm_backlight_caps {
  * @soc_bounding_box: SOC bounding box values provided by gpu_info FW
  * @cached_state: Caches device atomic state for suspend/resume
  * @cached_dc_state: Cached state of content streams
- * @compressor: Frame buffer compression buffer. See &struct dm_comressor_info
+ * @compressor: Frame buffer compression buffer. See &struct dm_compressor_info
  * @force_timing_sync: set via debugfs. When set, indicates that all connected
  *                    displays will be forced to synchronize.
  */
@@ -324,7 +324,7 @@ struct amdgpu_display_manager {
        struct drm_atomic_state *cached_state;
        struct dc_state *cached_dc_state;
 
-       struct dm_comressor_info compressor;
+       struct dm_compressor_info compressor;
 
        const struct firmware *fw_dmcu;
        uint32_t dmcu_fw_version;
index efb909ef7a0f732ca6e905cc5efc3575c150562f..857f156e4985b4ed91ab304900b01eeaac8234ba 100644 (file)
@@ -166,6 +166,11 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p
                        rn_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
                        break;
                }
+
+               if (ASICREV_IS_GREEN_SARDINE(asic_id.hw_internal_rev)) {
+                       rn_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
+                       break;
+               }
                if (ASICREV_IS_RAVEN2(asic_id.hw_internal_rev)) {
                        rv2_clk_mgr_construct(ctx, clk_mgr, pp_smu);
                        break;
index 1eb29c3621224a3d4bfa1fa5a9e3dc0f13bba74b..45ad05f6e03b9d965e7ea4af841a5f10bfd443d6 100644 (file)
@@ -1571,8 +1571,8 @@ static void init_state(struct dc *dc, struct dc_state *context)
 
 struct dc_state *dc_create_state(struct dc *dc)
 {
-       struct dc_state *context = kzalloc(sizeof(struct dc_state),
-                                          GFP_KERNEL);
+       struct dc_state *context = kvzalloc(sizeof(struct dc_state),
+                                           GFP_KERNEL);
 
        if (!context)
                return NULL;
index e430148e47cf4f25ea109011ab31127a1d6e2dbc..59d48cf819ea8e1a51ac024b979996566cd3c2c3 100644 (file)
@@ -120,6 +120,8 @@ enum dce_version resource_parse_asic_id(struct hw_asic_id asic_id)
                        dc_version = DCN_VERSION_1_01;
                if (ASICREV_IS_RENOIR(asic_id.hw_internal_rev))
                        dc_version = DCN_VERSION_2_1;
+               if (ASICREV_IS_GREEN_SARDINE(asic_id.hw_internal_rev))
+                       dc_version = DCN_VERSION_2_1;
                break;
 #endif
 
index 9cc65dc1970f88adac661ceb0a4ada134f0f520e..49ae5ff12da633db5227b344e3f4a77187bddc57 100644 (file)
@@ -1149,7 +1149,8 @@ static uint32_t dcn3_get_pix_clk_dividers(
 static const struct clock_source_funcs dcn3_clk_src_funcs = {
        .cs_power_down = dce110_clock_source_power_down,
        .program_pix_clk = dcn3_program_pix_clk,
-       .get_pix_clk_dividers = dcn3_get_pix_clk_dividers
+       .get_pix_clk_dividers = dcn3_get_pix_clk_dividers,
+       .get_pixel_clk_frequency_100hz = get_pixel_clk_frequency_100hz
 };
 #endif
 /*****************************************/
index 24fb39a11e5d5c261a7b4e5dc8daf991fd399191..2455d210ccf68579e196c4a9fac764af116cfe7b 100644 (file)
@@ -2105,12 +2105,12 @@ static bool dcn30_internal_validate_bw(
 
                if (split[i]) {
                        if (odm) {
-                               if (split[i] == 4 && old_pipe->next_odm_pipe->next_odm_pipe)
+                               if (split[i] == 4 && old_pipe->next_odm_pipe && old_pipe->next_odm_pipe->next_odm_pipe)
                                        old_index = old_pipe->next_odm_pipe->next_odm_pipe->pipe_idx;
                                else if (old_pipe->next_odm_pipe)
                                        old_index = old_pipe->next_odm_pipe->pipe_idx;
                        } else {
-                               if (split[i] == 4 && old_pipe->bottom_pipe->bottom_pipe &&
+                               if (split[i] == 4 && old_pipe->bottom_pipe && old_pipe->bottom_pipe->bottom_pipe &&
                                                old_pipe->bottom_pipe->bottom_pipe->plane_state == old_pipe->plane_state)
                                        old_index = old_pipe->bottom_pipe->bottom_pipe->pipe_idx;
                                else if (old_pipe->bottom_pipe &&
@@ -2150,10 +2150,12 @@ static bool dcn30_internal_validate_bw(
                                goto validate_fail;
                        newly_split[pipe_4to1->pipe_idx] = true;
 
-                       if (odm && old_pipe->next_odm_pipe->next_odm_pipe->next_odm_pipe)
+                       if (odm && old_pipe->next_odm_pipe && old_pipe->next_odm_pipe->next_odm_pipe
+                                       && old_pipe->next_odm_pipe->next_odm_pipe->next_odm_pipe)
                                old_index = old_pipe->next_odm_pipe->next_odm_pipe->next_odm_pipe->pipe_idx;
-                       else if (!odm && old_pipe->bottom_pipe->bottom_pipe->bottom_pipe &&
-                                               old_pipe->bottom_pipe->bottom_pipe->bottom_pipe->plane_state == old_pipe->plane_state)
+                       else if (!odm && old_pipe->bottom_pipe && old_pipe->bottom_pipe->bottom_pipe &&
+                                       old_pipe->bottom_pipe->bottom_pipe->bottom_pipe &&
+                                       old_pipe->bottom_pipe->bottom_pipe->bottom_pipe->plane_state == old_pipe->plane_state)
                                old_index = old_pipe->bottom_pipe->bottom_pipe->bottom_pipe->pipe_idx;
                        else
                                old_index = -1;
index 3be2c90b0c618e601b484b5b8267481b733a2ffd..21583699f9926c478f3be2dcb130cc0520cfcfaa 100644 (file)
@@ -117,6 +117,12 @@ static const struct ddc_registers ddc_data_regs_dcn[] = {
        ddc_data_regs_dcn2(4),
        ddc_data_regs_dcn2(5),
        ddc_data_regs_dcn2(6),
+       {
+                       DDC_GPIO_VGA_REG_LIST(DATA),
+                       .ddc_setup = 0,
+                       .phy_aux_cntl = 0,
+                       .dc_gpio_aux_ctrl_5 = 0
+       }
 };
 
 static const struct ddc_registers ddc_clk_regs_dcn[] = {
@@ -126,6 +132,12 @@ static const struct ddc_registers ddc_clk_regs_dcn[] = {
        ddc_clk_regs_dcn2(4),
        ddc_clk_regs_dcn2(5),
        ddc_clk_regs_dcn2(6),
+       {
+                       DDC_GPIO_VGA_REG_LIST(CLK),
+                       .ddc_setup = 0,
+                       .phy_aux_cntl = 0,
+                       .dc_gpio_aux_ctrl_5 = 0
+       }
 };
 
 static const struct ddc_sh_mask ddc_shift[] = {
index f67c18375bfdb7ae63adce970a42cfebf969a19a..dac427b68fd7b5c97a1e0715ac27759d497aa747 100644 (file)
@@ -63,13 +63,13 @@ enum gpio_result dal_gpio_open_ex(
        enum gpio_mode mode)
 {
        if (gpio->pin) {
-               ASSERT_CRITICAL(false);
+               BREAK_TO_DEBUGGER();
                return GPIO_RESULT_ALREADY_OPENED;
        }
 
        // No action if allocation failed during gpio construct
        if (!gpio->hw_container.ddc) {
-               ASSERT_CRITICAL(false);
+               BREAK_TO_DEBUGGER();
                return GPIO_RESULT_NON_SPECIFIC_ERROR;
        }
        gpio->mode = mode;
index 330acaaed79aef8a9264bf6a87742fff8fe41faa..95cb56929e79e76fc2a6320a8f5b0477d27e8fa1 100644 (file)
  * general debug capabilities
  *
  */
-#if defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB)
-#define ASSERT_CRITICAL(expr) do {     \
-       if (WARN_ON(!(expr))) { \
-               kgdb_breakpoint(); \
-       } \
-} while (0)
+#ifdef CONFIG_DEBUG_KERNEL_DC
+#define dc_breakpoint()                kgdb_breakpoint()
 #else
-#define ASSERT_CRITICAL(expr) do {     \
-       if (WARN_ON(!(expr))) { \
-               ; \
-       } \
-} while (0)
+#define dc_breakpoint()                do {} while (0)
 #endif
 
-#if defined(CONFIG_DEBUG_KERNEL_DC)
-#define ASSERT(expr) ASSERT_CRITICAL(expr)
+#define ASSERT_CRITICAL(expr) do {             \
+               if (WARN_ON(!(expr)))           \
+                       dc_breakpoint();        \
+       } while (0)
 
-#else
-#define ASSERT(expr) WARN_ON_ONCE(!(expr))
-#endif
+#define ASSERT(expr) do {                      \
+               if (WARN_ON_ONCE(!(expr)))      \
+                       dc_breakpoint();        \
+       } while (0)
 
-#if defined(CONFIG_DEBUG_KERNEL_DC) && (defined(CONFIG_HAVE_KGDB) || defined(CONFIG_KGDB))
 #define BREAK_TO_DEBUGGER() \
        do { \
                DRM_DEBUG_DRIVER("%s():%d\n", __func__, __LINE__); \
-               kgdb_breakpoint(); \
+               dc_breakpoint(); \
        } while (0)
-#else
-#define BREAK_TO_DEBUGGER() DRM_DEBUG_DRIVER("%s():%d\n", __func__, __LINE__)
-#endif
 
 #define DC_ERR(...)  do { \
        dm_error(__VA_ARGS__); \
index b267987aed068e69f03634f90da72d4c28e39e66..ffcb059297d30faebc60d1ffde8c9d4f3d9a814e 100644 (file)
@@ -205,6 +205,10 @@ enum {
 #if defined(CONFIG_DRM_AMD_DC_DCN3_0)
 #define ASICREV_IS_SIENNA_CICHLID_P(eChipRev)        ((eChipRev >= NV_SIENNA_CICHLID_P_A0))
 #endif
+#define GREEN_SARDINE_A0 0xA1
+#ifndef ASICREV_IS_GREEN_SARDINE
+#define ASICREV_IS_GREEN_SARDINE(eChipRev) ((eChipRev >= GREEN_SARDINE_A0) && (eChipRev < 0xFF))
+#endif
 
 /*
  * ASIC chip ID
index 10dc481ecbc4be28e0b2919f4b4aa042c35c345e..06c1aabf10cef840355453f08467cd220e7de8fc 100644 (file)
@@ -45,6 +45,7 @@ enum amd_apu_flags {
        AMD_APU_IS_RAVEN2 = 0x00000002UL,
        AMD_APU_IS_PICASSO = 0x00000004UL,
        AMD_APU_IS_RENOIR = 0x00000008UL,
+       AMD_APU_IS_GREEN_SARDINE = 0x00000010UL,
 };
 
 /**
index 3898a95ec28b18cdb92874fb705e771420baf3d2..518796a26eda9cffd7a5e94aaed38e180a2e8768 100644 (file)
@@ -229,6 +229,7 @@ struct pp_smumgr_func {
        bool (*is_hw_avfs_present)(struct pp_hwmgr  *hwmgr);
        int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting);
        int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw); /*rw: true for read, false for write */
+       int (*stop_smc)(struct pp_hwmgr *hwmgr);
 };
 
 struct pp_hwmgr_func {
index ad100b533d0496c8f4f4c5be28c3ced01692208b..5f46f1a4f38efa357e9afd450642dbc47c583e96 100644 (file)
@@ -113,4 +113,6 @@ extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, void *profile_settin
 
 extern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw);
 
+extern int smum_stop_smc(struct pp_hwmgr *hwmgr);
+
 #endif
index 3be40114e63d2e274ac17006961570becaa1cd78..45f608838f6ebf0e457e65fd8191846b9e03ea39 100644 (file)
@@ -142,12 +142,12 @@ static const struct baco_cmd_entry exit_baco_tbl[] =
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_BCLK_OFF_MASK,           BACO_CNTL__BACO_BCLK_OFF__SHIFT, 0, 0x00 },
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_POWER_OFF_MASK,          BACO_CNTL__BACO_POWER_OFF__SHIFT, 0, 0x00 },
        { CMD_DELAY_MS, 0, 0, 0, 20, 0 },
-       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_BF_MASK, 0, 0xffffffff, 0x20 },
+       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_BF_MASK, 0, 0xffffffff, 0x200 },
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_ISO_DIS_MASK, BACO_CNTL__BACO_ISO_DIS__SHIFT, 0, 0x01 },
-       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_MASK, 0, 5, 0x1c },
+       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_MASK, 0, 5, 0x1c00 },
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_ANA_ISO_DIS_MASK, BACO_CNTL__BACO_ANA_ISO_DIS__SHIFT, 0, 0x01 },
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_RESET_EN_MASK, BACO_CNTL__BACO_RESET_EN__SHIFT, 0, 0x00 },
-       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__RCU_BIF_CONFIG_DONE_MASK, 0, 5, 0x10 },
+       { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__RCU_BIF_CONFIG_DONE_MASK, 0, 5, 0x100 },
        { CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_EN_MASK, BACO_CNTL__BACO_EN__SHIFT, 0, 0x00 },
        { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__BACO_MODE_MASK, 0, 0xffffffff, 0x00 }
 };
@@ -155,6 +155,7 @@ static const struct baco_cmd_entry exit_baco_tbl[] =
 static const struct baco_cmd_entry clean_baco_tbl[] =
 {
        { CMD_WRITE, mmBIOS_SCRATCH_6, 0, 0, 0, 0 },
+       { CMD_WRITE, mmBIOS_SCRATCH_7, 0, 0, 0, 0 },
        { CMD_WRITE, mmCP_PFP_UCODE_ADDR, 0, 0, 0, 0 }
 };
 
index 1e8919b0acdb262c714f4229be9855c64bbf436c..35629140fc7aa0e65ac99c7eba9a7aceff7b3a03 100644 (file)
@@ -1541,6 +1541,10 @@ static int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
        PP_ASSERT_WITH_CODE((tmp_result == 0),
                        "Failed to reset to default!", result = tmp_result);
 
+       tmp_result = smum_stop_smc(hwmgr);
+       PP_ASSERT_WITH_CODE((tmp_result == 0),
+                       "Failed to stop smc!", result = tmp_result);
+
        tmp_result = smu7_force_switch_to_arbf0(hwmgr);
        PP_ASSERT_WITH_CODE((tmp_result == 0),
                        "Failed to force to switch arbf0!", result = tmp_result);
@@ -1585,18 +1589,24 @@ static void smu7_init_dpm_defaults(struct pp_hwmgr *hwmgr)
        data->current_profile_setting.sclk_down_hyst = 100;
        data->current_profile_setting.sclk_activity = SMU7_SCLK_TARGETACTIVITY_DFLT;
        data->current_profile_setting.bupdate_mclk = 1;
-       if (adev->gmc.vram_width == 256) {
-               data->current_profile_setting.mclk_up_hyst = 10;
-               data->current_profile_setting.mclk_down_hyst = 60;
-               data->current_profile_setting.mclk_activity = 25;
-       } else if (adev->gmc.vram_width == 128) {
-               data->current_profile_setting.mclk_up_hyst = 5;
-               data->current_profile_setting.mclk_down_hyst = 16;
-               data->current_profile_setting.mclk_activity = 20;
-       } else if (adev->gmc.vram_width == 64) {
-               data->current_profile_setting.mclk_up_hyst = 3;
-               data->current_profile_setting.mclk_down_hyst = 16;
-               data->current_profile_setting.mclk_activity = 20;
+       if (hwmgr->chip_id >= CHIP_POLARIS10) {
+               if (adev->gmc.vram_width == 256) {
+                       data->current_profile_setting.mclk_up_hyst = 10;
+                       data->current_profile_setting.mclk_down_hyst = 60;
+                       data->current_profile_setting.mclk_activity = 25;
+               } else if (adev->gmc.vram_width == 128) {
+                       data->current_profile_setting.mclk_up_hyst = 5;
+                       data->current_profile_setting.mclk_down_hyst = 16;
+                       data->current_profile_setting.mclk_activity = 20;
+               } else if (adev->gmc.vram_width == 64) {
+                       data->current_profile_setting.mclk_up_hyst = 3;
+                       data->current_profile_setting.mclk_down_hyst = 16;
+                       data->current_profile_setting.mclk_activity = 20;
+               }
+       } else {
+               data->current_profile_setting.mclk_up_hyst = 0;
+               data->current_profile_setting.mclk_down_hyst = 100;
+               data->current_profile_setting.mclk_activity = SMU7_MCLK_TARGETACTIVITY_DFLT;
        }
        hwmgr->workload_mask = 1 << hwmgr->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D];
        hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_FULLSCREEN3D;
index e4d1f3d66ef4888fe4a9d2add1fe240db14731d0..329bf4d44bbceb0f1e0afe052f5b9c8abf0c2117 100644 (file)
@@ -2726,10 +2726,7 @@ static int ci_initialize_mc_reg_table(struct pp_hwmgr *hwmgr)
 
 static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
-       return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-                                            CGS_IND_REG__SMC, FEATURE_STATUS,
-                                            VOLTAGE_CONTROLLER_ON))
-               ? true : false;
+       return ci_is_smc_ram_running(hwmgr);
 }
 
 static int ci_smu_init(struct pp_hwmgr *hwmgr)
@@ -2939,6 +2936,29 @@ static int ci_update_smc_table(struct pp_hwmgr *hwmgr, uint32_t type)
        return 0;
 }
 
+static void ci_reset_smc(struct pp_hwmgr *hwmgr)
+{
+       PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+                                 SMC_SYSCON_RESET_CNTL,
+                                 rst_reg, 1);
+}
+
+
+static void ci_stop_smc_clock(struct pp_hwmgr *hwmgr)
+{
+       PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+                                 SMC_SYSCON_CLOCK_CNTL_0,
+                                 ck_disable, 1);
+}
+
+static int ci_stop_smc(struct pp_hwmgr *hwmgr)
+{
+       ci_reset_smc(hwmgr);
+       ci_stop_smc_clock(hwmgr);
+
+       return 0;
+}
+
 const struct pp_smumgr_func ci_smu_funcs = {
        .name = "ci_smu",
        .smu_init = ci_smu_init,
@@ -2964,4 +2984,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
        .is_dpm_running = ci_is_dpm_running,
        .update_dpm_settings = ci_update_dpm_settings,
        .update_smc_table = ci_update_smc_table,
+       .stop_smc = ci_stop_smc,
 };
index b6fb480668416a92892f5e6d85122d0a5ac2eb8b..b6921db3c1305988ff974e34352e4d49264f8193 100644 (file)
@@ -245,3 +245,11 @@ int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t tabl
 
        return -EINVAL;
 }
+
+int smum_stop_smc(struct pp_hwmgr *hwmgr)
+{
+       if (hwmgr->smumgr_funcs->stop_smc)
+               return hwmgr->smumgr_funcs->stop_smc(hwmgr);
+
+       return 0;
+}
index fc4f95fa87cf62b381da5449320bacb7cb9ce2f7..b1e5ec01527b82d7035ba705fe5b1ad4de4188c0 100644 (file)
@@ -1029,17 +1029,6 @@ static int smu_smc_hw_setup(struct smu_context *smu)
                return ret;
        }
 
-       /*
-        * Set initialized values (get from vbios) to dpm tables context such as
-        * gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each
-        * type of clks.
-        */
-       ret = smu_set_default_dpm_table(smu);
-       if (ret) {
-               dev_err(adev->dev, "Failed to setup default dpm clock tables!\n");
-               return ret;
-       }
-
        ret = smu_notify_display_change(smu);
        if (ret)
                return ret;
index 8d8081c6bd3850f62a18d2b9879341ea3ce6c89f..ef1a62e86a0ee2d11f86f27aa713790bb19fc8ed 100644 (file)
@@ -1361,14 +1361,9 @@ static int navi10_get_fan_speed_rpm(struct smu_context *smu,
        if (!speed)
                return -EINVAL;
 
-       switch (smu_v11_0_get_fan_control_mode(smu)) {
-       case AMD_FAN_CTRL_AUTO:
-               return navi10_get_smu_metrics_data(smu,
-                                                  METRICS_CURR_FANSPEED,
-                                                  speed);
-       default:
-               return smu_v11_0_get_fan_speed_rpm(smu, speed);
-       }
+       return navi10_get_smu_metrics_data(smu,
+                                          METRICS_CURR_FANSPEED,
+                                          speed);
 }
 
 static int navi10_get_fan_parameters(struct smu_context *smu)
@@ -2534,29 +2529,6 @@ static const struct i2c_algorithm navi10_i2c_algo = {
        .functionality = navi10_i2c_func,
 };
 
-static int navi10_i2c_control_init(struct smu_context *smu, struct i2c_adapter *control)
-{
-       struct amdgpu_device *adev = to_amdgpu_device(control);
-       int res;
-
-       control->owner = THIS_MODULE;
-       control->class = I2C_CLASS_SPD;
-       control->dev.parent = &adev->pdev->dev;
-       control->algo = &navi10_i2c_algo;
-       snprintf(control->name, sizeof(control->name), "AMDGPU SMU");
-
-       res = i2c_add_adapter(control);
-       if (res)
-               DRM_ERROR("Failed to register hw i2c, err: %d\n", res);
-
-       return res;
-}
-
-static void navi10_i2c_control_fini(struct smu_context *smu, struct i2c_adapter *control)
-{
-       i2c_del_adapter(control);
-}
-
 static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
                                      void **table)
 {
@@ -2687,8 +2659,6 @@ static const struct pptable_funcs navi10_ppt_funcs = {
        .set_default_dpm_table = navi10_set_default_dpm_table,
        .dpm_set_vcn_enable = navi10_dpm_set_vcn_enable,
        .dpm_set_jpeg_enable = navi10_dpm_set_jpeg_enable,
-       .i2c_init = navi10_i2c_control_init,
-       .i2c_fini = navi10_i2c_control_fini,
        .print_clk_levels = navi10_print_clk_levels,
        .force_clk_levels = navi10_force_clk_levels,
        .populate_umd_state_clk = navi10_populate_umd_state_clk,
index 685a8a3b25d4d75466aeeb839bb1edfd3a15ac4f..895d89bea7faa68f6d9d11f24c8068fcb1b64b1a 100644 (file)
@@ -1177,14 +1177,9 @@ static int sienna_cichlid_get_fan_speed_rpm(struct smu_context *smu,
        if (!speed)
                return -EINVAL;
 
-       switch (smu_v11_0_get_fan_control_mode(smu)) {
-       case AMD_FAN_CTRL_AUTO:
-               return sienna_cichlid_get_smu_metrics_data(smu,
-                                                          METRICS_CURR_FANSPEED,
-                                                          speed);
-       default:
-               return smu_v11_0_get_fan_speed_rpm(smu, speed);
-       }
+       return sienna_cichlid_get_smu_metrics_data(smu,
+                                               METRICS_CURR_FANSPEED,
+                                               speed);
 }
 
 static int sienna_cichlid_get_fan_parameters(struct smu_context *smu)
index 90807a6b415ca8598e83f72dd0a589c0d3cbc0b6..deeed73f4ed6924d92a9f66668a1249a6f144f4d 100644 (file)
@@ -374,6 +374,10 @@ static bool is_edid_digital_input_dp(const struct edid *edid)
  * drm_dp_downstream_is_type() - is the downstream facing port of certain type?
  * @dpcd: DisplayPort configuration data
  * @port_cap: port capabilities
+ * @type: port type to be checked. Can be:
+ *       %DP_DS_PORT_TYPE_DP, %DP_DS_PORT_TYPE_VGA, %DP_DS_PORT_TYPE_DVI,
+ *       %DP_DS_PORT_TYPE_HDMI, %DP_DS_PORT_TYPE_NON_EDID,
+ *       %DP_DS_PORT_TYPE_DP_DUALMODE or %DP_DS_PORT_TYPE_WIRELESS.
  *
  * Caveat: Only works with DPCD 1.1+ port caps.
  *
@@ -870,6 +874,7 @@ EXPORT_SYMBOL(drm_dp_downstream_444_to_420_conversion);
 
 /**
  * drm_dp_downstream_mode() - return a mode for downstream facing port
+ * @dev: DRM device
  * @dpcd: DisplayPort configuration data
  * @port_cap: port capabilities
  *
@@ -1028,7 +1033,8 @@ EXPORT_SYMBOL(drm_dp_downstream_debug);
 
 /**
  * drm_dp_subconnector_type() - get DP branch device type
- *
+ * @dpcd: DisplayPort configuration data
+ * @port_cap: port capabilities
  */
 enum drm_mode_subconnector
 drm_dp_subconnector_type(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
@@ -1079,6 +1085,10 @@ EXPORT_SYMBOL(drm_dp_subconnector_type);
 
 /**
  * drm_mode_set_dp_subconnector_property - set subconnector for DP connector
+ * @connector: connector to set property on
+ * @status: connector status
+ * @dpcd: DisplayPort configuration data
+ * @port_cap: port capabilities
  *
  * Called by a driver on every detect event.
  */
index a82f37d4425826b72f9bb036fad293c51408574f..631125b46e04c6df67a5a14a13cc4b98b6061137 100644 (file)
@@ -3741,7 +3741,7 @@ drm_add_cmdb_modes(struct drm_connector *connector, u8 svd)
 /**
  * drm_display_mode_from_cea_vic() - return a mode for CEA VIC
  * @dev: DRM device
- * @vic: CEA VIC of the mode
+ * @video_code: CEA VIC of the mode
  *
  * Creates a new mode matching the specified CEA VIC.
  *
index 19d73868490e65d3b35040a47065378186101674..69c2c079d8036bcde1d17b717c50ea5168cea2a1 100644 (file)
@@ -1085,6 +1085,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
         */
        drm_gem_object_get(obj);
 
+       vma->vm_private_data = obj;
+
        if (obj->funcs && obj->funcs->mmap) {
                ret = obj->funcs->mmap(obj, vma);
                if (ret) {
@@ -1107,8 +1109,6 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
                vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
        }
 
-       vma->vm_private_data = obj;
-
        return 0;
 }
 EXPORT_SYMBOL(drm_gem_mmap_obj);
index d77c9f8ff26ced1e994792f36e4cc49321bb31f3..e00616d94f26ef9b21584fd2a0f8311b5a714d32 100644 (file)
@@ -593,8 +593,13 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
        /* Remove the fake offset */
        vma->vm_pgoff -= drm_vma_node_start(&obj->vma_node);
 
-       if (obj->import_attach)
+       if (obj->import_attach) {
+               /* Drop the reference drm_gem_mmap_obj() acquired.*/
+               drm_gem_object_put(obj);
+               vma->vm_private_data = NULL;
+
                return dma_buf_mmap(obj->dma_buf, vma, 0);
+       }
 
        shmem = to_drm_gem_shmem_obj(obj);
 
index d6808f678db541388e1e808085d4ec022e6acd43..9f955f2010c25770f53110a2ff92ba98d0caadf4 100644 (file)
@@ -794,6 +794,7 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops =  {
 
 /**
  * drm_prime_pages_to_sg - converts a page array into an sg list
+ * @dev: DRM device
  * @pages: pointer to the array of page pointers to convert
  * @nr_pages: length of the page vector
  *
index 829b2a40a48219810c162c0d8c312dceec470b40..31337d2a2cdea11c94241a4bd7387931af3bdffd 100644 (file)
@@ -10636,6 +10636,10 @@ skl_get_initial_plane_config(struct intel_crtc *crtc,
            val & PLANE_CTL_FLIP_HORIZONTAL)
                plane_config->rotation |= DRM_MODE_REFLECT_X;
 
+       /* 90/270 degree rotation would require extra work */
+       if (drm_rotation_90_or_270(plane_config->rotation))
+               goto error;
+
        base = intel_de_read(dev_priv, PLANE_SURF(pipe, plane_id)) & 0xfffff000;
        plane_config->base = base;
 
index 8a9d0bdde1bfb229a725e94b4a4c3c659fc9ed52..40e9cb29233d4d49c730b037e9c4ac0431e8dc23 100644 (file)
@@ -1754,7 +1754,7 @@ void intel_psr_atomic_check(struct drm_connector *connector,
                return;
 
        intel_connector = to_intel_connector(connector);
-       dig_port = enc_to_dig_port(intel_attached_encoder(intel_connector));
+       dig_port = enc_to_dig_port(to_intel_encoder(new_state->best_encoder));
        if (dev_priv->psr.dp != &dig_port->dp)
                return;
 
index 7c90a63c273d8d52e2148f45bee13e94d4e27e6e..fcce6909f201769876dea539f22681ff37d80ec6 100644 (file)
@@ -508,21 +508,6 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
        if (!obj)
                return -ENOENT;
 
-       /*
-        * Already in the desired write domain? Nothing for us to do!
-        *
-        * We apply a little bit of cunning here to catch a broader set of
-        * no-ops. If obj->write_domain is set, we must be in the same
-        * obj->read_domains, and only that domain. Therefore, if that
-        * obj->write_domain matches the request read_domains, we are
-        * already in the same read/write domain and can skip the operation,
-        * without having to further check the requested write_domain.
-        */
-       if (READ_ONCE(obj->write_domain) == read_domains) {
-               err = 0;
-               goto out;
-       }
-
        /*
         * Try to flush the object off the GPU without holding the lock.
         * We will repeat the flush holding the lock in the normal manner
@@ -560,6 +545,19 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
        if (err)
                goto out;
 
+       /*
+        * Already in the desired write domain? Nothing for us to do!
+        *
+        * We apply a little bit of cunning here to catch a broader set of
+        * no-ops. If obj->write_domain is set, we must be in the same
+        * obj->read_domains, and only that domain. Therefore, if that
+        * obj->write_domain matches the request read_domains, we are
+        * already in the same read/write domain and can skip the operation,
+        * without having to further check the requested write_domain.
+        */
+       if (READ_ONCE(obj->write_domain) == read_domains)
+               goto out_unpin;
+
        err = i915_gem_object_lock_interruptible(obj, NULL);
        if (err)
                goto out_unpin;
index 7c3a1012e702046de696e82191ab1bef23bb9009..760fefdfe39216361b74dd1a8faf330b0e045641 100644 (file)
@@ -245,22 +245,14 @@ static inline u32 *gen12_emit_pipe_control(u32 *batch, u32 flags0, u32 flags1, u
 }
 
 static inline u32 *
-__gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 flags1)
+__gen8_emit_write_rcs(u32 *cs, u32 value, u32 offset, u32 flags0, u32 flags1)
 {
-       /* We're using qword write, offset should be aligned to 8 bytes. */
-       GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
-
-       /* w/a for post sync ops following a GPGPU operation we
-        * need a prior CS_STALL, which is emitted by the flush
-        * following the batch.
-        */
        *cs++ = GFX_OP_PIPE_CONTROL(6) | flags0;
-       *cs++ = flags1 | PIPE_CONTROL_QW_WRITE | PIPE_CONTROL_GLOBAL_GTT_IVB;
-       *cs++ = gtt_offset;
+       *cs++ = flags1 | PIPE_CONTROL_QW_WRITE;
+       *cs++ = offset;
        *cs++ = 0;
        *cs++ = value;
-       /* We're thrashing one dword of HWS. */
-       *cs++ = 0;
+       *cs++ = 0; /* We're thrashing one extra dword. */
 
        return cs;
 }
@@ -268,13 +260,38 @@ __gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 f
 static inline u32*
 gen8_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
 {
-       return __gen8_emit_ggtt_write_rcs(cs, value, gtt_offset, 0, flags);
+       /* We're using qword write, offset should be aligned to 8 bytes. */
+       GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
+
+       return __gen8_emit_write_rcs(cs,
+                                    value,
+                                    gtt_offset,
+                                    0,
+                                    flags | PIPE_CONTROL_GLOBAL_GTT_IVB);
 }
 
 static inline u32*
 gen12_emit_ggtt_write_rcs(u32 *cs, u32 value, u32 gtt_offset, u32 flags0, u32 flags1)
 {
-       return __gen8_emit_ggtt_write_rcs(cs, value, gtt_offset, flags0, flags1);
+       /* We're using qword write, offset should be aligned to 8 bytes. */
+       GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
+
+       return __gen8_emit_write_rcs(cs,
+                                    value,
+                                    gtt_offset,
+                                    flags0,
+                                    flags1 | PIPE_CONTROL_GLOBAL_GTT_IVB);
+}
+
+static inline u32 *
+__gen8_emit_flush_dw(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
+{
+       *cs++ = (MI_FLUSH_DW + 1) | flags;
+       *cs++ = gtt_offset;
+       *cs++ = 0;
+       *cs++ = value;
+
+       return cs;
 }
 
 static inline u32 *
@@ -285,12 +302,10 @@ gen8_emit_ggtt_write(u32 *cs, u32 value, u32 gtt_offset, u32 flags)
        /* Offset should be aligned to 8 bytes for both (QW/DW) write types */
        GEM_BUG_ON(!IS_ALIGNED(gtt_offset, 8));
 
-       *cs++ = (MI_FLUSH_DW + 1) | MI_FLUSH_DW_OP_STOREDW | flags;
-       *cs++ = gtt_offset | MI_FLUSH_DW_USE_GTT;
-       *cs++ = 0;
-       *cs++ = value;
-
-       return cs;
+       return __gen8_emit_flush_dw(cs,
+                                   value,
+                                   gtt_offset | MI_FLUSH_DW_USE_GTT,
+                                   flags | MI_FLUSH_DW_OP_STOREDW);
 }
 
 static inline void __intel_engine_reset(struct intel_engine_cs *engine,
index a32aabce7901dc7ef113ec09814832ba8b466161..f82c6dd1de1831faf067dce7e815325b25ff175c 100644 (file)
@@ -3547,6 +3547,19 @@ static const struct intel_context_ops execlists_context_ops = {
        .destroy = execlists_context_destroy,
 };
 
+static u32 hwsp_offset(const struct i915_request *rq)
+{
+       const struct intel_timeline_cacheline *cl;
+
+       /* Before the request is executed, the timeline/cachline is fixed */
+
+       cl = rcu_dereference_protected(rq->hwsp_cacheline, 1);
+       if (cl)
+               return cl->ggtt_offset;
+
+       return rcu_dereference_protected(rq->timeline, 1)->hwsp_offset;
+}
+
 static int gen8_emit_init_breadcrumb(struct i915_request *rq)
 {
        u32 *cs;
@@ -3569,7 +3582,7 @@ static int gen8_emit_init_breadcrumb(struct i915_request *rq)
        *cs++ = MI_NOOP;
 
        *cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
-       *cs++ = i915_request_timeline(rq)->hwsp_offset;
+       *cs++ = hwsp_offset(rq);
        *cs++ = 0;
        *cs++ = rq->fence.seqno - 1;
 
@@ -4886,11 +4899,9 @@ gen8_emit_fini_breadcrumb_tail(struct i915_request *request, u32 *cs)
        return gen8_emit_wa_tail(request, cs);
 }
 
-static u32 *emit_xcs_breadcrumb(struct i915_request *request, u32 *cs)
+static u32 *emit_xcs_breadcrumb(struct i915_request *rq, u32 *cs)
 {
-       u32 addr = i915_request_active_timeline(request)->hwsp_offset;
-
-       return gen8_emit_ggtt_write(cs, request->fence.seqno, addr, 0);
+       return gen8_emit_ggtt_write(cs, rq->fence.seqno, hwsp_offset(rq), 0);
 }
 
 static u32 *gen8_emit_fini_breadcrumb(struct i915_request *rq, u32 *cs)
@@ -4909,7 +4920,7 @@ static u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
        /* XXX flush+write+CS_STALL all in one upsets gem_concurrent_blt:kbl */
        cs = gen8_emit_ggtt_write_rcs(cs,
                                      request->fence.seqno,
-                                     i915_request_active_timeline(request)->hwsp_offset,
+                                     hwsp_offset(request),
                                      PIPE_CONTROL_FLUSH_ENABLE |
                                      PIPE_CONTROL_CS_STALL);
 
@@ -4921,7 +4932,7 @@ gen11_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
 {
        cs = gen8_emit_ggtt_write_rcs(cs,
                                      request->fence.seqno,
-                                     i915_request_active_timeline(request)->hwsp_offset,
+                                     hwsp_offset(request),
                                      PIPE_CONTROL_CS_STALL |
                                      PIPE_CONTROL_TILE_CACHE_FLUSH |
                                      PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH |
@@ -4983,7 +4994,9 @@ gen12_emit_fini_breadcrumb_tail(struct i915_request *request, u32 *cs)
 
 static u32 *gen12_emit_fini_breadcrumb(struct i915_request *rq, u32 *cs)
 {
-       return gen12_emit_fini_breadcrumb_tail(rq, emit_xcs_breadcrumb(rq, cs));
+       /* XXX Stalling flush before seqno write; post-sync not */
+       cs = emit_xcs_breadcrumb(rq, __gen8_emit_flush_dw(cs, 0, 0, 0));
+       return gen12_emit_fini_breadcrumb_tail(rq, cs);
 }
 
 static u32 *
@@ -4991,7 +5004,7 @@ gen12_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
 {
        cs = gen12_emit_ggtt_write_rcs(cs,
                                       request->fence.seqno,
-                                      i915_request_active_timeline(request)->hwsp_offset,
+                                      hwsp_offset(request),
                                       PIPE_CONTROL0_HDC_PIPELINE_FLUSH,
                                       PIPE_CONTROL_CS_STALL |
                                       PIPE_CONTROL_TILE_CACHE_FLUSH |
index a2f74cefe4c3fa59ed74ddb1bf284aabe0b7fedf..7ea94d201fe6fbd9c5e8d1e160621bfd2ceaf273 100644 (file)
@@ -188,10 +188,14 @@ cacheline_alloc(struct intel_timeline_hwsp *hwsp, unsigned int cacheline)
        return cl;
 }
 
-static void cacheline_acquire(struct intel_timeline_cacheline *cl)
+static void cacheline_acquire(struct intel_timeline_cacheline *cl,
+                             u32 ggtt_offset)
 {
-       if (cl)
-               i915_active_acquire(&cl->active);
+       if (!cl)
+               return;
+
+       cl->ggtt_offset = ggtt_offset;
+       i915_active_acquire(&cl->active);
 }
 
 static void cacheline_release(struct intel_timeline_cacheline *cl)
@@ -340,7 +344,7 @@ int intel_timeline_pin(struct intel_timeline *tl, struct i915_gem_ww_ctx *ww)
        GT_TRACE(tl->gt, "timeline:%llx using HWSP offset:%x\n",
                 tl->fence_context, tl->hwsp_offset);
 
-       cacheline_acquire(tl->hwsp_cacheline);
+       cacheline_acquire(tl->hwsp_cacheline, tl->hwsp_offset);
        if (atomic_fetch_inc(&tl->pin_count)) {
                cacheline_release(tl->hwsp_cacheline);
                __i915_vma_unpin(tl->hwsp_ggtt);
@@ -515,7 +519,7 @@ __intel_timeline_get_seqno(struct intel_timeline *tl,
        GT_TRACE(tl->gt, "timeline:%llx using HWSP offset:%x\n",
                 tl->fence_context, tl->hwsp_offset);
 
-       cacheline_acquire(cl);
+       cacheline_acquire(cl, tl->hwsp_offset);
        tl->hwsp_cacheline = cl;
 
        *seqno = timeline_advance(tl);
@@ -573,9 +577,7 @@ int intel_timeline_read_hwsp(struct i915_request *from,
        if (err)
                goto out;
 
-       *hwsp = i915_ggtt_offset(cl->hwsp->vma) +
-               ptr_unmask_bits(cl->vaddr, CACHELINE_BITS) * CACHELINE_BYTES;
-
+       *hwsp = cl->ggtt_offset;
 out:
        i915_active_release(&cl->active);
        return err;
index 02181c5020db0739f4ce11d854be126a655c3efc..4474f487f58991ad0bf133a7ee6e8bf54bb8ea79 100644 (file)
@@ -94,6 +94,8 @@ struct intel_timeline_cacheline {
        struct intel_timeline_hwsp *hwsp;
        void *vaddr;
 
+       u32 ggtt_offset;
+
        struct rcu_head rcu;
 };
 
index 3be37e6fe33da016b66123b6077996621899e262..eb342a7599438c641168768ac6c20a92d7d449ee 100644 (file)
@@ -1489,7 +1489,8 @@ static int hws_pga_write(struct intel_vgpu *vgpu, unsigned int offset,
        const struct intel_engine_cs *engine =
                intel_gvt_render_mmio_to_engine(vgpu->gvt, offset);
 
-       if (!intel_gvt_ggtt_validate_range(vgpu, value, I915_GTT_PAGE_SIZE)) {
+       if (value != 0 &&
+           !intel_gvt_ggtt_validate_range(vgpu, value, I915_GTT_PAGE_SIZE)) {
                gvt_vgpu_err("write invalid HWSP address, reg:0x%x, value:0x%x\n",
                              offset, value);
                return -EINVAL;
@@ -1650,6 +1651,34 @@ static int edp_psr_imr_iir_write(struct intel_vgpu *vgpu,
        return 0;
 }
 
+/**
+ * FixMe:
+ * If guest fills non-priv batch buffer on ApolloLake/Broxton as Mesa i965 did:
+ * 717e7539124d (i965: Use a WC map and memcpy for the batch instead of pwrite.)
+ * Due to the missing flush of bb filled by VM vCPU, host GPU hangs on executing
+ * these MI_BATCH_BUFFER.
+ * Temporarily workaround this by setting SNOOP bit for PAT3 used by PPGTT
+ * PML4 PTE: PAT(0) PCD(1) PWT(1).
+ * The performance is still expected to be low, will need further improvement.
+ */
+static int bxt_ppat_low_write(struct intel_vgpu *vgpu, unsigned int offset,
+                             void *p_data, unsigned int bytes)
+{
+       u64 pat =
+               GEN8_PPAT(0, CHV_PPAT_SNOOP) |
+               GEN8_PPAT(1, 0) |
+               GEN8_PPAT(2, 0) |
+               GEN8_PPAT(3, CHV_PPAT_SNOOP) |
+               GEN8_PPAT(4, CHV_PPAT_SNOOP) |
+               GEN8_PPAT(5, CHV_PPAT_SNOOP) |
+               GEN8_PPAT(6, CHV_PPAT_SNOOP) |
+               GEN8_PPAT(7, CHV_PPAT_SNOOP);
+
+       vgpu_vreg(vgpu, offset) = lower_32_bits(pat);
+
+       return 0;
+}
+
 static int guc_status_read(struct intel_vgpu *vgpu,
                           unsigned int offset, void *p_data,
                           unsigned int bytes)
@@ -2812,7 +2841,7 @@ static int init_bdw_mmio_info(struct intel_gvt *gvt)
 
        MMIO_DH(GEN6_PCODE_MAILBOX, D_BDW_PLUS, NULL, mailbox_write);
 
-       MMIO_D(GEN8_PRIVATE_PAT_LO, D_BDW_PLUS);
+       MMIO_D(GEN8_PRIVATE_PAT_LO, D_BDW_PLUS & ~D_BXT);
        MMIO_D(GEN8_PRIVATE_PAT_HI, D_BDW_PLUS);
 
        MMIO_D(GAMTARBMODE, D_BDW_PLUS);
@@ -3139,7 +3168,7 @@ static int init_skl_mmio_info(struct intel_gvt *gvt)
                 NULL, NULL);
 
        MMIO_DFH(GAMT_CHKN_BIT_REG, D_KBL | D_CFL, F_CMD_ACCESS, NULL, NULL);
-       MMIO_D(GEN9_CTX_PREEMPT_REG, D_SKL_PLUS);
+       MMIO_D(GEN9_CTX_PREEMPT_REG, D_SKL_PLUS & ~D_BXT);
 
        return 0;
 }
@@ -3313,9 +3342,21 @@ static int init_bxt_mmio_info(struct intel_gvt *gvt)
        MMIO_D(GEN8_PUSHBUS_SHIFT, D_BXT);
        MMIO_D(GEN6_GFXPAUSE, D_BXT);
        MMIO_DFH(GEN8_L3SQCREG1, D_BXT, F_CMD_ACCESS, NULL, NULL);
+       MMIO_DFH(GEN8_L3CNTLREG, D_BXT, F_CMD_ACCESS, NULL, NULL);
+       MMIO_DFH(_MMIO(0x20D8), D_BXT, F_CMD_ACCESS, NULL, NULL);
+       MMIO_F(GEN8_RING_CS_GPR(RENDER_RING_BASE, 0), 0x40, F_CMD_ACCESS,
+              0, 0, D_BXT, NULL, NULL);
+       MMIO_F(GEN8_RING_CS_GPR(GEN6_BSD_RING_BASE, 0), 0x40, F_CMD_ACCESS,
+              0, 0, D_BXT, NULL, NULL);
+       MMIO_F(GEN8_RING_CS_GPR(BLT_RING_BASE, 0), 0x40, F_CMD_ACCESS,
+              0, 0, D_BXT, NULL, NULL);
+       MMIO_F(GEN8_RING_CS_GPR(VEBOX_RING_BASE, 0), 0x40, F_CMD_ACCESS,
+              0, 0, D_BXT, NULL, NULL);
 
        MMIO_DFH(GEN9_CTX_PREEMPT_REG, D_BXT, F_CMD_ACCESS, NULL, NULL);
 
+       MMIO_DH(GEN8_PRIVATE_PAT_LO, D_BXT, NULL, bxt_ppat_low_write);
+
        return 0;
 }
 
index 1570eb8aa97836130e8f3ca703947359991a9c3e..aed2ef6466a2db765db71bfa52696d698aa134ee 100644 (file)
@@ -1277,7 +1277,7 @@ void intel_vgpu_clean_submission(struct intel_vgpu *vgpu)
 
        i915_context_ppgtt_root_restore(s, i915_vm_to_ppgtt(s->shadow[0]->vm));
        for_each_engine(engine, vgpu->gvt->gt, id)
-               intel_context_unpin(s->shadow[id]);
+               intel_context_put(s->shadow[id]);
 
        kmem_cache_destroy(s->workloads);
 }
@@ -1369,11 +1369,6 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu)
                        ce->ring = __intel_context_ring_size(ring_size);
                }
 
-               ret = intel_context_pin(ce);
-               intel_context_put(ce);
-               if (ret)
-                       goto out_shadow_ctx;
-
                s->shadow[i] = ce;
        }
 
@@ -1405,7 +1400,6 @@ out_shadow_ctx:
                if (IS_ERR(s->shadow[i]))
                        break;
 
-               intel_context_unpin(s->shadow[i]);
                intel_context_put(s->shadow[i]);
        }
        i915_vm_put(&ppgtt->vm);
@@ -1479,6 +1473,7 @@ void intel_vgpu_destroy_workload(struct intel_vgpu_workload *workload)
 {
        struct intel_vgpu_submission *s = &workload->vgpu->submission;
 
+       intel_context_unpin(s->shadow[workload->engine->id]);
        release_shadow_batch_buffer(workload);
        release_shadow_wa_ctx(&workload->wa_ctx);
 
@@ -1724,6 +1719,12 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu,
                return ERR_PTR(ret);
        }
 
+       ret = intel_context_pin(s->shadow[engine->id]);
+       if (ret) {
+               intel_vgpu_destroy_workload(workload);
+               return ERR_PTR(ret);
+       }
+
        return workload;
 }
 
index 366ddfc8df6b65982a69445f83943506e5a86724..fb5e30de78c2a022a0ca817e46910e3491f8111a 100644 (file)
@@ -389,6 +389,7 @@ static const struct intel_device_info ilk_m_info = {
        GEN5_FEATURES,
        PLATFORM(INTEL_IRONLAKE),
        .is_mobile = 1,
+       .has_rps = true,
        .display.has_fbc = 1,
 };
 
index ffb5287e055a93fcfc54ecec8aa63401e12969b7..caa9b041616b0d0903788589ad4a7ae7965339c6 100644 (file)
@@ -314,8 +314,10 @@ static void __vma_release(struct dma_fence_work *work)
 {
        struct i915_vma_work *vw = container_of(work, typeof(*vw), base);
 
-       if (vw->pinned)
+       if (vw->pinned) {
                __i915_gem_object_unpin_pages(vw->pinned);
+               i915_gem_object_put(vw->pinned);
+       }
 
        i915_vm_free_pt_stash(vw->vm, &vw->stash);
        i915_vm_put(vw->vm);
@@ -431,7 +433,7 @@ int i915_vma_bind(struct i915_vma *vma,
 
                if (vma->obj) {
                        __i915_gem_object_pin_pages(vma->obj);
-                       work->pinned = vma->obj;
+                       work->pinned = i915_gem_object_get(vma->obj);
                }
        } else {
                vma->ops->bind_vma(vma->vm, NULL, vma, cache_level, bind_flags);
index 6b5e9d88646de4aa683b8a004517b93954420362..180e1078ef7c1a16421fd118c5e3a54e7e0282eb 100644 (file)
@@ -87,7 +87,7 @@ __intel_memory_region_get_pages_buddy(struct intel_memory_region *mem,
                min_order = ilog2(size) - ilog2(mem->mm.chunk_size);
        }
 
-       if (size > BIT(mem->mm.max_order) * mem->mm.chunk_size)
+       if (size > mem->mm.size)
                return -E2BIG;
 
        n_pages = size >> ilog2(mem->mm.chunk_size);
index 334b0648e253e96039c2b2941466a7d63d0fde84..0aeba8e3af28daecde5424c9458683f8faf5d4db 100644 (file)
@@ -261,6 +261,82 @@ err_close_objects:
        return err;
 }
 
+static int igt_mock_splintered_region(void *arg)
+{
+       struct intel_memory_region *mem = arg;
+       struct drm_i915_private *i915 = mem->i915;
+       struct drm_i915_gem_object *obj;
+       unsigned int expected_order;
+       LIST_HEAD(objects);
+       u64 size;
+       int err = 0;
+
+       /*
+        * Sanity check we can still allocate everything even if the
+        * mm.max_order != mm.size. i.e our starting address space size is not a
+        * power-of-two.
+        */
+
+       size = (SZ_4G - 1) & PAGE_MASK;
+       mem = mock_region_create(i915, 0, size, PAGE_SIZE, 0);
+       if (IS_ERR(mem))
+               return PTR_ERR(mem);
+
+       if (mem->mm.size != size) {
+               pr_err("%s size mismatch(%llu != %llu)\n",
+                      __func__, mem->mm.size, size);
+               err = -EINVAL;
+               goto out_put;
+       }
+
+       expected_order = get_order(rounddown_pow_of_two(size));
+       if (mem->mm.max_order != expected_order) {
+               pr_err("%s order mismatch(%u != %u)\n",
+                      __func__, mem->mm.max_order, expected_order);
+               err = -EINVAL;
+               goto out_put;
+       }
+
+       obj = igt_object_create(mem, &objects, size, 0);
+       if (IS_ERR(obj)) {
+               err = PTR_ERR(obj);
+               goto out_close;
+       }
+
+       close_objects(mem, &objects);
+
+       /*
+        * While we should be able allocate everything without any flag
+        * restrictions, if we consider I915_BO_ALLOC_CONTIGUOUS then we are
+        * actually limited to the largest power-of-two for the region size i.e
+        * max_order, due to the inner workings of the buddy allocator. So make
+        * sure that does indeed hold true.
+        */
+
+       obj = igt_object_create(mem, &objects, size, I915_BO_ALLOC_CONTIGUOUS);
+       if (!IS_ERR(obj)) {
+               pr_err("%s too large contiguous allocation was not rejected\n",
+                      __func__);
+               err = -EINVAL;
+               goto out_close;
+       }
+
+       obj = igt_object_create(mem, &objects, rounddown_pow_of_two(size),
+                               I915_BO_ALLOC_CONTIGUOUS);
+       if (IS_ERR(obj)) {
+               pr_err("%s largest possible contiguous allocation failed\n",
+                      __func__);
+               err = PTR_ERR(obj);
+               goto out_close;
+       }
+
+out_close:
+       close_objects(mem, &objects);
+out_put:
+       intel_memory_region_put(mem);
+       return err;
+}
+
 static int igt_gpu_write_dw(struct intel_context *ce,
                            struct i915_vma *vma,
                            u32 dword,
@@ -771,6 +847,7 @@ int intel_memory_region_mock_selftests(void)
        static const struct i915_subtest tests[] = {
                SUBTEST(igt_mock_fill),
                SUBTEST(igt_mock_contiguous),
+               SUBTEST(igt_mock_splintered_region),
        };
        struct intel_memory_region *mem;
        struct drm_i915_private *i915;
index 09660f5a0a4c9f6f4c0172662a209137ee473c03..979d96f27c43a7c81f965b1f505caad062c44c50 100644 (file)
@@ -24,7 +24,7 @@ mock_object_create(struct intel_memory_region *mem,
        struct drm_i915_private *i915 = mem->i915;
        struct drm_i915_gem_object *obj;
 
-       if (size > BIT(mem->mm.max_order) * mem->mm.chunk_size)
+       if (size > mem->mm.size)
                return ERR_PTR(-E2BIG);
 
        obj = i915_gem_object_alloc();
index 71d84c7a5378a4bfaeb77598910749f8756d37a4..d07b39b8afd21a0a7c43b45760d750bd1e4ae997 100644 (file)
@@ -111,10 +111,6 @@ static int dw_hdmi_imx_parse_dt(struct imx_hdmi *hdmi)
        return 0;
 }
 
-static void dw_hdmi_imx_encoder_disable(struct drm_encoder *encoder)
-{
-}
-
 static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder)
 {
        struct imx_hdmi *hdmi = enc_to_imx_hdmi(encoder);
@@ -140,7 +136,6 @@ static int dw_hdmi_imx_atomic_check(struct drm_encoder *encoder,
 
 static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = {
        .enable     = dw_hdmi_imx_encoder_enable,
-       .disable    = dw_hdmi_imx_encoder_disable,
        .atomic_check = dw_hdmi_imx_atomic_check,
 };
 
@@ -219,15 +214,9 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master,
        hdmi->dev = &pdev->dev;
        encoder = &hdmi->encoder;
 
-       encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
-       /*
-        * If we failed to find the CRTC(s) which this encoder is
-        * supposed to be connected to, it's because the CRTC has
-        * not been registered yet.  Defer probing, and hope that
-        * the required CRTC is added later.
-        */
-       if (encoder->possible_crtcs == 0)
-               return -EPROBE_DEFER;
+       ret = imx_drm_encoder_parse_of(drm, encoder, dev->of_node);
+       if (ret)
+               return ret;
 
        ret = dw_hdmi_imx_parse_dt(hdmi);
        if (ret < 0)
index 7d00c49fd5a5409f1ca70c7c34fef0ed46a1be45..9bf5ad6d18a22822d2f2fe2dcdba41a836f3e72f 100644 (file)
@@ -20,6 +20,7 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_of.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_probe_helper.h>
@@ -212,7 +213,9 @@ static int imx_drm_bind(struct device *dev)
        drm->mode_config.allow_fb_modifiers = true;
        drm->mode_config.normalize_zpos = true;
 
-       drm_mode_config_init(drm);
+       ret = drmm_mode_config_init(drm);
+       if (ret)
+               return ret;
 
        ret = drm_vblank_init(drm, MAX_CRTC);
        if (ret)
@@ -251,7 +254,6 @@ err_poll_fini:
        drm_kms_helper_poll_fini(drm);
        component_unbind_all(drm->dev, drm);
 err_kms:
-       drm_mode_config_cleanup(drm);
        drm_dev_put(drm);
 
        return ret;
@@ -267,11 +269,9 @@ static void imx_drm_unbind(struct device *dev)
 
        component_unbind_all(drm->dev, drm);
 
-       drm_mode_config_cleanup(drm);
+       drm_dev_put(drm);
 
        dev_set_drvdata(dev, NULL);
-
-       drm_dev_put(drm);
 }
 
 static const struct component_master_ops imx_drm_ops = {
index af757d1e21fedfc3e7d0e0a95a9560ce768d6266..41e2978cb1ebf278fa93ac803d6ea74d06ad5ecd 100644 (file)
@@ -62,7 +62,6 @@ struct imx_ldb_channel {
        struct i2c_adapter *ddc;
        int chno;
        void *edid;
-       int edid_len;
        struct drm_display_mode mode;
        int mode_valid;
        u32 bus_format;
@@ -536,15 +535,14 @@ static int imx_ldb_panel_ddc(struct device *dev,
        }
 
        if (!channel->ddc) {
+               int edid_len;
+
                /* if no DDC available, fallback to hardcoded EDID */
                dev_dbg(dev, "no ddc available\n");
 
-               edidp = of_get_property(child, "edid",
-                                       &channel->edid_len);
+               edidp = of_get_property(child, "edid", &edid_len);
                if (edidp) {
-                       channel->edid = kmemdup(edidp,
-                                               channel->edid_len,
-                                               GFP_KERNEL);
+                       channel->edid = kmemdup(edidp, edid_len, GFP_KERNEL);
                } else if (!channel->panel) {
                        /* fallback to display-timings node */
                        ret = of_get_drm_display_mode(child,
index 813bb6156a680e5384ccd3cb8398b92a072d0595..2a8d2e32e7b42678850cf9758019653cc4957882 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
-#include <linux/spinlock.h>
 #include <linux/videodev2.h>
 
 #include <video/imx-ipu-v3.h>
@@ -104,8 +103,6 @@ struct imx_tve {
        struct drm_connector connector;
        struct drm_encoder encoder;
        struct device *dev;
-       spinlock_t lock;        /* register lock */
-       bool enabled;
        int mode;
        int di_hsync_pin;
        int di_vsync_pin;
@@ -129,30 +126,10 @@ static inline struct imx_tve *enc_to_tve(struct drm_encoder *e)
        return container_of(e, struct imx_tve, encoder);
 }
 
-static void tve_lock(void *__tve)
-__acquires(&tve->lock)
-{
-       struct imx_tve *tve = __tve;
-
-       spin_lock(&tve->lock);
-}
-
-static void tve_unlock(void *__tve)
-__releases(&tve->lock)
-{
-       struct imx_tve *tve = __tve;
-
-       spin_unlock(&tve->lock);
-}
-
 static void tve_enable(struct imx_tve *tve)
 {
-       if (!tve->enabled) {
-               tve->enabled = true;
-               clk_prepare_enable(tve->clk);
-               regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
-                                  TVE_EN, TVE_EN);
-       }
+       clk_prepare_enable(tve->clk);
+       regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, TVE_EN);
 
        /* clear interrupt status register */
        regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff);
@@ -169,11 +146,8 @@ static void tve_enable(struct imx_tve *tve)
 
 static void tve_disable(struct imx_tve *tve)
 {
-       if (tve->enabled) {
-               tve->enabled = false;
-               regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
-               clk_disable_unprepare(tve->clk);
-       }
+       regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
+       clk_disable_unprepare(tve->clk);
 }
 
 static int tve_setup_tvout(struct imx_tve *tve)
@@ -500,8 +474,7 @@ static struct regmap_config tve_regmap_config = {
 
        .readable_reg = imx_tve_readable_reg,
 
-       .lock = tve_lock,
-       .unlock = tve_unlock,
+       .fast_io = true,
 
        .max_register = 0xdc,
 };
@@ -511,7 +484,7 @@ static const char * const imx_tve_modes[] = {
        [TVE_MODE_VGA] = "vga",
 };
 
-static const int of_get_tve_mode(struct device_node *np)
+static int of_get_tve_mode(struct device_node *np)
 {
        const char *bm;
        int ret, i;
@@ -544,7 +517,6 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
        memset(tve, 0, sizeof(*tve));
 
        tve->dev = dev;
-       spin_lock_init(&tve->lock);
 
        ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
        if (ddc_node) {
index 8232f512b9ed8ec84af4760817a1d4d399b0922c..2eb8df4697dfac6c0bd1e6a2098a62a296e0498c 100644 (file)
@@ -28,7 +28,6 @@ struct imx_parallel_display {
        struct drm_bridge bridge;
        struct device *dev;
        void *edid;
-       int edid_len;
        u32 bus_format;
        u32 bus_flags;
        struct drm_display_mode mode;
@@ -41,11 +40,6 @@ static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
        return container_of(c, struct imx_parallel_display, connector);
 }
 
-static inline struct imx_parallel_display *enc_to_imxpd(struct drm_encoder *e)
-{
-       return container_of(e, struct imx_parallel_display, encoder);
-}
-
 static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b)
 {
        return container_of(b, struct imx_parallel_display, bridge);
@@ -310,6 +304,7 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
        struct device_node *np = dev->of_node;
        const u8 *edidp;
        struct imx_parallel_display *imxpd;
+       int edid_len;
        int ret;
        u32 bus_format = 0;
        const char *fmt;
@@ -323,9 +318,9 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
        if (ret && ret != -ENODEV)
                return ret;
 
-       edidp = of_get_property(np, "edid", &imxpd->edid_len);
+       edidp = of_get_property(np, "edid", &edid_len);
        if (edidp)
-               imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL);
+               imxpd->edid = devm_kmemdup(dev, edidp, edid_len, GFP_KERNEL);
 
        ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
        if (!ret) {
@@ -349,17 +344,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
        return 0;
 }
 
-static void imx_pd_unbind(struct device *dev, struct device *master,
-       void *data)
-{
-       struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
-
-       kfree(imxpd->edid);
-}
-
 static const struct component_ops imx_pd_ops = {
        .bind   = imx_pd_bind,
-       .unbind = imx_pd_unbind,
 };
 
 static int imx_pd_probe(struct platform_device *pdev)
index 498622c0c670dcdf041b69790e1d47babe7bb4a7..f75088186fba3f4802f8486c9cc61e59e82b56bc 100644 (file)
@@ -44,6 +44,7 @@ int core507d_new_(const struct nv50_core_func *, struct nouveau_drm *, s32,
                  struct nv50_core **);
 int core507d_init(struct nv50_core *);
 void core507d_ntfy_init(struct nouveau_bo *, u32);
+int core507d_read_caps(struct nv50_disp *disp);
 int core507d_caps_init(struct nouveau_drm *, struct nv50_disp *);
 int core507d_ntfy_wait_done(struct nouveau_bo *, u32, struct nvif_device *);
 int core507d_update(struct nv50_core *, u32 *, bool);
@@ -55,6 +56,7 @@ extern const struct nv50_outp_func pior507d;
 int core827d_new(struct nouveau_drm *, s32, struct nv50_core **);
 
 int core907d_new(struct nouveau_drm *, s32, struct nv50_core **);
+int core907d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp);
 extern const struct nv50_outp_func dac907d;
 extern const struct nv50_outp_func sor907d;
 
index 248edf69e1683170f2bab46941e4b539d79fa6a4..e6f16a7750f07c2090c9acb2259b02701b020619 100644 (file)
@@ -78,18 +78,55 @@ core507d_ntfy_init(struct nouveau_bo *bo, u32 offset)
 }
 
 int
-core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
+core507d_read_caps(struct nv50_disp *disp)
 {
        struct nvif_push *push = disp->core->chan.push;
        int ret;
 
-       if ((ret = PUSH_WAIT(push, 2)))
+       ret = PUSH_WAIT(push, 6);
+       if (ret)
                return ret;
 
+       PUSH_MTHD(push, NV507D, SET_NOTIFIER_CONTROL,
+                 NVDEF(NV507D, SET_NOTIFIER_CONTROL, MODE, WRITE) |
+                 NVVAL(NV507D, SET_NOTIFIER_CONTROL, OFFSET, NV50_DISP_CORE_NTFY >> 2) |
+                 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, ENABLE));
+
        PUSH_MTHD(push, NV507D, GET_CAPABILITIES, 0x00000000);
+
+       PUSH_MTHD(push, NV507D, SET_NOTIFIER_CONTROL,
+                 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
+
        return PUSH_KICK(push);
 }
 
+int
+core507d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
+{
+       struct nv50_core *core = disp->core;
+       struct nouveau_bo *bo = disp->sync;
+       s64 time;
+       int ret;
+
+       NVBO_WR32(bo, NV50_DISP_CORE_NTFY, NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1,
+                                    NVDEF(NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, FALSE));
+
+       ret = core507d_read_caps(disp);
+       if (ret < 0)
+               return ret;
+
+       time = nvif_msec(core->chan.base.device, 2000ULL,
+                        if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
+                                      NV_DISP_CORE_NOTIFIER_1, CAPABILITIES_1, DONE, ==, TRUE))
+                                break;
+                        usleep_range(1, 2);
+                        );
+       if (time < 0)
+               NV_ERROR(drm, "core caps notifier timeout\n");
+
+       return 0;
+}
+
 int
 core507d_init(struct nv50_core *core)
 {
index b17c03529c784e81408ee5739877cad07a2f95b8..8564d4dffaff0aa0e6b64bff1c091180b6a19787 100644 (file)
 #include "core.h"
 #include "head.h"
 
+#include <nvif/push507c.h>
+#include <nvif/timer.h>
+
+#include <nvhw/class/cl907d.h>
+
+#include "nouveau_bo.h"
+
+int
+core907d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
+{
+       struct nv50_core *core = disp->core;
+       struct nouveau_bo *bo = disp->sync;
+       s64 time;
+       int ret;
+
+       NVBO_WR32(bo, NV50_DISP_CORE_NTFY, NV907D_CORE_NOTIFIER_3, CAPABILITIES_4,
+                                    NVDEF(NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, FALSE));
+
+       ret = core507d_read_caps(disp);
+       if (ret < 0)
+               return ret;
+
+       time = nvif_msec(core->chan.base.device, 2000ULL,
+                        if (NVBO_TD32(bo, NV50_DISP_CORE_NTFY,
+                                      NV907D_CORE_NOTIFIER_3, CAPABILITIES_4, DONE, ==, TRUE))
+                                break;
+                        usleep_range(1, 2);
+                        );
+       if (time < 0)
+               NV_ERROR(drm, "core caps notifier timeout\n");
+
+       return 0;
+}
+
 static const struct nv50_core_func
 core907d = {
        .init = core507d_init,
        .ntfy_init = core507d_ntfy_init,
-       .caps_init = core507d_caps_init,
+       .caps_init = core907d_caps_init,
        .ntfy_wait_done = core507d_ntfy_wait_done,
        .update = core507d_update,
        .head = &head907d,
index 66846f37208051989e991c0f24b1b9f6d1a6969f..1cd3a2a35dfb7faad430424e861fe3d681edbcec 100644 (file)
@@ -26,7 +26,7 @@ static const struct nv50_core_func
 core917d = {
        .init = core507d_init,
        .ntfy_init = core507d_ntfy_init,
-       .caps_init = core507d_caps_init,
+       .caps_init = core907d_caps_init,
        .ntfy_wait_done = core507d_ntfy_wait_done,
        .update = core507d_update,
        .head = &head917d,
index 2e444bac701dd1aca08d6cfc37b02d0ff795f524..6a463f308b64fffed630459777c2e50b3982762c 100644 (file)
 #define NV_DISP_CORE_NOTIFIER_1_COMPLETION_0_DONE_TRUE                               0x00000001
 #define NV_DISP_CORE_NOTIFIER_1_COMPLETION_0_R0                                      15:1
 #define NV_DISP_CORE_NOTIFIER_1_COMPLETION_0_TIMESTAMP                               29:16
-
+#define NV_DISP_CORE_NOTIFIER_1_CAPABILITIES_1                                       0x00000001
+#define NV_DISP_CORE_NOTIFIER_1_CAPABILITIES_1_DONE                                  0:0
+#define NV_DISP_CORE_NOTIFIER_1_CAPABILITIES_1_DONE_FALSE                            0x00000000
+#define NV_DISP_CORE_NOTIFIER_1_CAPABILITIES_1_DONE_TRUE                             0x00000001
 
 // class methods
 #define NV507D_UPDATE                                                           (0x00000080)
index 34bc3eafac7d18660bcfca05eae502a06150d7ad..79aff6ff31385c45fcf223fe0efc4fc4c01b752b 100644 (file)
 #ifndef _cl907d_h_
 #define _cl907d_h_
 
+#define NV907D_CORE_NOTIFIER_3_CAPABILITIES_4                                       0x00000004
+#define NV907D_CORE_NOTIFIER_3_CAPABILITIES_4_DONE                                  0:0
+#define NV907D_CORE_NOTIFIER_3_CAPABILITIES_4_DONE_FALSE                            0x00000000
+#define NV907D_CORE_NOTIFIER_3_CAPABILITIES_4_DONE_TRUE                             0x00000001
 #define NV907D_CORE_NOTIFIER_3_CAPABILITIES_CAP_SOR0_20                             0x00000014
 #define NV907D_CORE_NOTIFIER_3_CAPABILITIES_CAP_SOR0_20_SINGLE_LVDS18               0:0
 #define NV907D_CORE_NOTIFIER_3_CAPABILITIES_CAP_SOR0_20_SINGLE_LVDS18_FALSE         0x00000000
index 49dd0cbc332ffa0107d9ba9e45867b33dc69ed41..6f21f36719fc1281b2ecd99f6b0665cac4bd1f61 100644 (file)
@@ -1023,29 +1023,6 @@ get_tmds_link_bandwidth(struct drm_connector *connector)
                return 112000 * duallink_scale;
 }
 
-enum drm_mode_status
-nouveau_conn_mode_clock_valid(const struct drm_display_mode *mode,
-                             const unsigned min_clock,
-                             const unsigned max_clock,
-                             unsigned int *clock_out)
-{
-       unsigned int clock = mode->clock;
-
-       if ((mode->flags & DRM_MODE_FLAG_3D_MASK) ==
-           DRM_MODE_FLAG_3D_FRAME_PACKING)
-               clock *= 2;
-
-       if (clock < min_clock)
-               return MODE_CLOCK_LOW;
-       if (clock > max_clock)
-               return MODE_CLOCK_HIGH;
-
-       if (clock_out)
-               *clock_out = clock;
-
-       return MODE_OK;
-}
-
 static enum drm_mode_status
 nouveau_connector_mode_valid(struct drm_connector *connector,
                             struct drm_display_mode *mode)
@@ -1053,7 +1030,7 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
        struct nouveau_connector *nv_connector = nouveau_connector(connector);
        struct nouveau_encoder *nv_encoder = nv_connector->detected_encoder;
        struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
-       unsigned min_clock = 25000, max_clock = min_clock;
+       unsigned int min_clock = 25000, max_clock = min_clock, clock = mode->clock;
 
        switch (nv_encoder->dcb->type) {
        case DCB_OUTPUT_LVDS:
@@ -1082,8 +1059,15 @@ nouveau_connector_mode_valid(struct drm_connector *connector,
                return MODE_BAD;
        }
 
-       return nouveau_conn_mode_clock_valid(mode, min_clock, max_clock,
-                                            NULL);
+       if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
+               clock *= 2;
+
+       if (clock < min_clock)
+               return MODE_CLOCK_LOW;
+       if (clock > max_clock)
+               return MODE_CLOCK_HIGH;
+
+       return MODE_OK;
 }
 
 static struct drm_encoder *
index 7b640e05bd4cdc76a69dde97122ed1f1eccd6fa5..040ed88d362d795591aaad854e9dd70de94fd47f 100644 (file)
@@ -231,23 +231,30 @@ nv50_dp_mode_valid(struct drm_connector *connector,
                   const struct drm_display_mode *mode,
                   unsigned *out_clock)
 {
-       const unsigned min_clock = 25000;
-       unsigned max_clock, ds_clock, clock;
-       enum drm_mode_status ret;
+       const unsigned int min_clock = 25000;
+       unsigned int max_rate, mode_rate, ds_max_dotclock, clock = mode->clock;
+       const u8 bpp = connector->display_info.bpc * 3;
 
        if (mode->flags & DRM_MODE_FLAG_INTERLACE && !outp->caps.dp_interlace)
                return MODE_NO_INTERLACE;
 
-       max_clock = outp->dp.link_nr * outp->dp.link_bw;
-       ds_clock = drm_dp_downstream_max_dotclock(outp->dp.dpcd,
-                                                 outp->dp.downstream_ports);
-       if (ds_clock)
-               max_clock = min(max_clock, ds_clock);
+       if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
+               clock *= 2;
+
+       max_rate = outp->dp.link_nr * outp->dp.link_bw;
+       mode_rate = DIV_ROUND_UP(clock * bpp, 8);
+       if (mode_rate > max_rate)
+               return MODE_CLOCK_HIGH;
+
+       ds_max_dotclock = drm_dp_downstream_max_dotclock(outp->dp.dpcd, outp->dp.downstream_ports);
+       if (ds_max_dotclock && clock > ds_max_dotclock)
+               return MODE_CLOCK_HIGH;
+
+       if (clock < min_clock)
+               return MODE_CLOCK_LOW;
 
-       clock = mode->clock * (connector->display_info.bpc * 3) / 10;
-       ret = nouveau_conn_mode_clock_valid(mode, min_clock, max_clock,
-                                           &clock);
        if (out_clock)
                *out_clock = clock;
-       return ret;
+
+       return MODE_OK;
 }
index 89adadf4706b456b5f1a0d8a85ae91273dc7e842..549bc67feabb4b645b6b1a9b2eecf46c2b435014 100644 (file)
@@ -190,7 +190,8 @@ nouveau_gem_new(struct nouveau_cli *cli, u64 size, int align, uint32_t domain,
         * to the caller, instead of a normal nouveau_bo ttm reference. */
        ret = drm_gem_object_init(drm->dev, &nvbo->bo.base, size);
        if (ret) {
-               nouveau_bo_ref(NULL, &nvbo);
+               drm_gem_object_release(&nvbo->bo.base);
+               kfree(nvbo);
                return ret;
        }
 
index 2df1c04605594f5733efb6dc0cd8e7ddb075873c..4f69e4c3dafde298f6f7707b719a074a5dca5076 100644 (file)
@@ -105,11 +105,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
        struct nouveau_cli *cli = nouveau_cli(file_priv);
        struct drm_nouveau_svm_bind *args = data;
        unsigned target, cmd, priority;
-       unsigned long addr, end, size;
+       unsigned long addr, end;
        struct mm_struct *mm;
 
        args->va_start &= PAGE_MASK;
-       args->va_end &= PAGE_MASK;
+       args->va_end = ALIGN(args->va_end, PAGE_SIZE);
 
        /* Sanity check arguments */
        if (args->reserved0 || args->reserved1)
@@ -118,8 +118,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
                return -EINVAL;
        if (args->va_start >= args->va_end)
                return -EINVAL;
-       if (!args->npages)
-               return -EINVAL;
 
        cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT;
        cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK;
@@ -151,12 +149,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
        if (args->stride)
                return -EINVAL;
 
-       size = ((unsigned long)args->npages) << PAGE_SHIFT;
-       if ((args->va_start + size) <= args->va_start)
-               return -EINVAL;
-       if ((args->va_start + size) > args->va_end)
-               return -EINVAL;
-
        /*
         * Ok we are ask to do something sane, for now we only support migrate
         * commands but we will add things like memory policy (what to do on
@@ -171,7 +163,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
                return -EINVAL;
        }
 
-       for (addr = args->va_start, end = args->va_start + size; addr < end;) {
+       for (addr = args->va_start, end = args->va_end; addr < end;) {
                struct vm_area_struct *vma;
                unsigned long next;
 
index dcb70677d0accac488ac98712e56903ad025c571..7851bec5f0e5feccd8b2be5f1fbcb2b6180a21bf 100644 (file)
@@ -2924,17 +2924,34 @@ nvkm_device_del(struct nvkm_device **pdevice)
        }
 }
 
+/* returns true if the GPU is in the CPU native byte order */
 static inline bool
 nvkm_device_endianness(struct nvkm_device *device)
 {
-       u32 boot1 = nvkm_rd32(device, 0x000004) & 0x01000001;
 #ifdef __BIG_ENDIAN
-       if (!boot1)
-               return false;
+       const bool big_endian = true;
 #else
-       if (boot1)
-               return false;
+       const bool big_endian = false;
 #endif
+
+       /* Read NV_PMC_BOOT_1, and assume non-functional endian switch if it
+        * doesn't contain the expected values.
+        */
+       u32 pmc_boot_1 = nvkm_rd32(device, 0x000004);
+       if (pmc_boot_1 && pmc_boot_1 != 0x01000001)
+               return !big_endian; /* Assume GPU is LE in this case. */
+
+       /* 0 means LE and 0x01000001 means BE GPU. Condition is true when
+        * GPU/CPU endianness don't match.
+        */
+       if (big_endian == !pmc_boot_1) {
+               nvkm_wr32(device, 0x000004, 0x01000001);
+               nvkm_rd32(device, 0x000000);
+               if (nvkm_rd32(device, 0x000004) != (big_endian ? 0x01000001 : 0x00000000))
+                       return !big_endian; /* Assume GPU is LE on any unexpected read-back. */
+       }
+
+       /* CPU/GPU endianness should (hopefully) match. */
        return true;
 }
 
@@ -2987,14 +3004,10 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
        if (detect) {
                /* switch mmio to cpu's native endianness */
                if (!nvkm_device_endianness(device)) {
-                       nvkm_wr32(device, 0x000004, 0x01000001);
-                       nvkm_rd32(device, 0x000000);
-                       if (!nvkm_device_endianness(device)) {
-                               nvdev_error(device,
-                                           "GPU not supported on big-endian\n");
-                               ret = -ENOSYS;
-                               goto done;
-                       }
+                       nvdev_error(device,
+                                   "Couldn't switch GPU to CPUs endianess\n");
+                       ret = -ENOSYS;
+                       goto done;
                }
 
                boot0 = nvkm_rd32(device, 0x000000);
index 3482e28e30fc9ed3c68698891e6ffcf0929e9598..0c5f22e95c2dbbafb9850faf2aeb4771788d09ad 100644 (file)
@@ -26,7 +26,9 @@
 struct mantix {
        struct device *dev;
        struct drm_panel panel;
+
        struct gpio_desc *reset_gpio;
+       struct gpio_desc *tp_rstn_gpio;
 
        struct regulator *avdd;
        struct regulator *avee;
@@ -124,6 +126,10 @@ static int mantix_unprepare(struct drm_panel *panel)
 {
        struct mantix *ctx = panel_to_mantix(panel);
 
+       gpiod_set_value_cansleep(ctx->tp_rstn_gpio, 1);
+       usleep_range(5000, 6000);
+       gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
        regulator_disable(ctx->avee);
        regulator_disable(ctx->avdd);
        /* T11 */
@@ -165,13 +171,10 @@ static int mantix_prepare(struct drm_panel *panel)
                return ret;
        }
 
-       /* T3+T5 */
-       usleep_range(10000, 12000);
-
-       gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-       usleep_range(5150, 7000);
-
+       /* T3 + T4 + time for voltage to become stable: */
+       usleep_range(6000, 7000);
        gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+       gpiod_set_value_cansleep(ctx->tp_rstn_gpio, 0);
 
        /* T6 */
        msleep(50);
@@ -204,7 +207,7 @@ static int mantix_get_modes(struct drm_panel *panel,
        if (!mode) {
                dev_err(ctx->dev, "Failed to add mode %ux%u@%u\n",
                        default_mode.hdisplay, default_mode.vdisplay,
-                       drm_mode_vrefresh(mode));
+                       drm_mode_vrefresh(&default_mode));
                return -ENOMEM;
        }
 
@@ -236,12 +239,18 @@ static int mantix_probe(struct mipi_dsi_device *dsi)
        if (!ctx)
                return -ENOMEM;
 
-       ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+       ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
        if (IS_ERR(ctx->reset_gpio)) {
                dev_err(dev, "cannot get reset gpio\n");
                return PTR_ERR(ctx->reset_gpio);
        }
 
+       ctx->tp_rstn_gpio = devm_gpiod_get(dev, "mantix,tp-rstn", GPIOD_OUT_HIGH);
+       if (IS_ERR(ctx->tp_rstn_gpio)) {
+               dev_err(dev, "cannot get tp-rstn gpio\n");
+               return PTR_ERR(ctx->tp_rstn_gpio);
+       }
+
        mipi_dsi_set_drvdata(dsi, ctx);
        ctx->dev = dev;
 
index 37d4cb7a5491c4a58ea1a3102ac3f05032e4a9fc..0fc084110e5ba0c7761a05118a5a6bba57923bd9 100644 (file)
@@ -626,6 +626,7 @@ static int panfrost_probe(struct platform_device *pdev)
 err_out1:
        pm_runtime_disable(pfdev->dev);
        panfrost_device_fini(pfdev);
+       pm_runtime_set_suspended(pfdev->dev);
 err_out0:
        drm_dev_put(ddev);
        return err;
@@ -640,9 +641,9 @@ static int panfrost_remove(struct platform_device *pdev)
        panfrost_gem_shrinker_cleanup(ddev);
 
        pm_runtime_get_sync(pfdev->dev);
-       panfrost_device_fini(pfdev);
-       pm_runtime_put_sync_suspend(pfdev->dev);
        pm_runtime_disable(pfdev->dev);
+       panfrost_device_fini(pfdev);
+       pm_runtime_set_suspended(pfdev->dev);
 
        drm_dev_put(ddev);
        return 0;
index 1a6cea0e0bd743baf77dfc82571f86134ea743ef..62d4d710a57118dcc02481a6cdb8ac4a7cdc8c86 100644 (file)
@@ -105,14 +105,12 @@ void panfrost_gem_mapping_put(struct panfrost_gem_mapping *mapping)
        kref_put(&mapping->refcount, panfrost_gem_mapping_release);
 }
 
-void panfrost_gem_teardown_mappings(struct panfrost_gem_object *bo)
+void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo)
 {
        struct panfrost_gem_mapping *mapping;
 
-       mutex_lock(&bo->mappings.lock);
        list_for_each_entry(mapping, &bo->mappings.list, node)
                panfrost_gem_teardown_mapping(mapping);
-       mutex_unlock(&bo->mappings.lock);
 }
 
 int panfrost_gem_open(struct drm_gem_object *obj, struct drm_file *file_priv)
index b3517ff9630cb23a8753d066303fb5880adcf984..8088d5fd8480e809f0a50f61ef3b09c4f45388e4 100644 (file)
@@ -82,7 +82,7 @@ struct panfrost_gem_mapping *
 panfrost_gem_mapping_get(struct panfrost_gem_object *bo,
                         struct panfrost_file_priv *priv);
 void panfrost_gem_mapping_put(struct panfrost_gem_mapping *mapping);
-void panfrost_gem_teardown_mappings(struct panfrost_gem_object *bo);
+void panfrost_gem_teardown_mappings_locked(struct panfrost_gem_object *bo);
 
 void panfrost_gem_shrinker_init(struct drm_device *dev);
 void panfrost_gem_shrinker_cleanup(struct drm_device *dev);
index 288e46c40673a9d102580030b8a107c2d2af3572..1b9f68d8e9aa69ab3c5bea17bb5d541b19ebe72c 100644 (file)
@@ -40,18 +40,26 @@ static bool panfrost_gem_purge(struct drm_gem_object *obj)
 {
        struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
        struct panfrost_gem_object *bo = to_panfrost_bo(obj);
+       bool ret = false;
 
        if (atomic_read(&bo->gpu_usecount))
                return false;
 
-       if (!mutex_trylock(&shmem->pages_lock))
+       if (!mutex_trylock(&bo->mappings.lock))
                return false;
 
-       panfrost_gem_teardown_mappings(bo);
+       if (!mutex_trylock(&shmem->pages_lock))
+               goto unlock_mappings;
+
+       panfrost_gem_teardown_mappings_locked(bo);
        drm_gem_shmem_purge_locked(obj);
+       ret = true;
 
        mutex_unlock(&shmem->pages_lock);
-       return true;
+
+unlock_mappings:
+       mutex_unlock(&bo->mappings.lock);
+       return ret;
 }
 
 static unsigned long
index b51cc685c13adbff30cc21fd36bb08d639950029..edb60ae0a9b75f667b67f65d7380c1208b8f977e 100644 (file)
@@ -407,6 +407,7 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
        struct drm_framebuffer *fb = state->fb;
        const struct drm_format_info *format = fb->format;
        uint64_t modifier = fb->modifier;
+       unsigned int ch1_phase_idx;
        u32 out_fmt_val;
        u32 in_fmt_val, in_mod_val, in_ps_val;
        unsigned int i;
@@ -442,18 +443,19 @@ int sun4i_frontend_update_formats(struct sun4i_frontend *frontend,
         * I have no idea what this does exactly, but it seems to be
         * related to the scaler FIR filter phase parameters.
         */
+       ch1_phase_idx = (format->num_planes > 1) ? 1 : 0;
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_HORZPHASE_REG,
-                    frontend->data->ch_phase[0].horzphase);
+                    frontend->data->ch_phase[0]);
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_HORZPHASE_REG,
-                    frontend->data->ch_phase[1].horzphase);
+                    frontend->data->ch_phase[ch1_phase_idx]);
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE0_REG,
-                    frontend->data->ch_phase[0].vertphase[0]);
+                    frontend->data->ch_phase[0]);
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE0_REG,
-                    frontend->data->ch_phase[1].vertphase[0]);
+                    frontend->data->ch_phase[ch1_phase_idx]);
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH0_VERTPHASE1_REG,
-                    frontend->data->ch_phase[0].vertphase[1]);
+                    frontend->data->ch_phase[0]);
        regmap_write(frontend->regs, SUN4I_FRONTEND_CH1_VERTPHASE1_REG,
-                    frontend->data->ch_phase[1].vertphase[1]);
+                    frontend->data->ch_phase[ch1_phase_idx]);
 
        /*
         * Checking the input format is sufficient since we currently only
@@ -687,30 +689,12 @@ static const struct dev_pm_ops sun4i_frontend_pm_ops = {
 };
 
 static const struct sun4i_frontend_data sun4i_a10_frontend = {
-       .ch_phase               = {
-               {
-                       .horzphase = 0,
-                       .vertphase = { 0, 0 },
-               },
-               {
-                       .horzphase = 0xfc000,
-                       .vertphase = { 0xfc000, 0xfc000 },
-               },
-       },
+       .ch_phase               = { 0x000, 0xfc000 },
        .has_coef_rdy           = true,
 };
 
 static const struct sun4i_frontend_data sun8i_a33_frontend = {
-       .ch_phase               = {
-               {
-                       .horzphase = 0x400,
-                       .vertphase = { 0x400, 0x400 },
-               },
-               {
-                       .horzphase = 0x400,
-                       .vertphase = { 0x400, 0x400 },
-               },
-       },
+       .ch_phase               = { 0x400, 0xfc400 },
        .has_coef_access_ctrl   = true,
 };
 
index 0c382c1ddb0fe81b0eb8f63999d0f6e2856d650c..2e7b76e50c2ba21942fa16b4c5d42f33c6f15326 100644 (file)
@@ -115,11 +115,7 @@ struct reset_control;
 struct sun4i_frontend_data {
        bool    has_coef_access_ctrl;
        bool    has_coef_rdy;
-
-       struct {
-               u32     horzphase;
-               u32     vertphase[2];
-       } ch_phase[2];
+       u32     ch_phase[2];
 };
 
 struct sun4i_frontend {
index 915f8bfdb58cad0f355b4e5c94fbf37df651309a..182c586525eb844807588c2e62064e779f887d9f 100644 (file)
@@ -568,7 +568,6 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
                ret = v3d_job_init(v3d, file_priv, &bin->base,
                                   v3d_job_free, args->in_sync_bcl);
                if (ret) {
-                       kfree(bin);
                        v3d_job_put(&render->base);
                        kfree(bin);
                        return ret;
index 74ceebd62fbce4aa131ff6444bfc912c630ec7c9..cc74a3f3a07af960564935aeca7614343c1d9b7e 100644 (file)
@@ -449,7 +449,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
        }
 
        if (IS_ERR(cma_obj)) {
-               struct drm_printer p = drm_info_printer(vc4->dev->dev);
+               struct drm_printer p = drm_info_printer(vc4->base.dev);
                DRM_ERROR("Failed to allocate from CMA:\n");
                vc4_bo_stats_print(&p, vc4);
                return ERR_PTR(-ENOMEM);
@@ -590,7 +590,7 @@ static void vc4_bo_cache_time_work(struct work_struct *work)
 {
        struct vc4_dev *vc4 =
                container_of(work, struct vc4_dev, bo_cache.time_work);
-       struct drm_device *dev = vc4->dev;
+       struct drm_device *dev = &vc4->base;
 
        mutex_lock(&vc4->bo_lock);
        vc4_bo_cache_free_old(dev);
@@ -1005,6 +1005,7 @@ int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused);
 int vc4_bo_cache_init(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -1033,10 +1034,10 @@ int vc4_bo_cache_init(struct drm_device *dev)
        INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
        timer_setup(&vc4->bo_cache.time_timer, vc4_bo_cache_time_timer, 0);
 
-       return 0;
+       return drmm_add_action_or_reset(dev, vc4_bo_cache_destroy, NULL);
 }
 
-void vc4_bo_cache_destroy(struct drm_device *dev)
+static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        int i;
index f1a5fd5dab6f5caf103a98764449fa79bfaf374f..839610f8092af6842c08e65d4128cd937c24ede1 100644 (file)
@@ -257,37 +257,37 @@ static int vc4_drm_bind(struct device *dev)
 
        dev->coherent_dma_mask = DMA_BIT_MASK(32);
 
-       vc4 = devm_kzalloc(dev, sizeof(*vc4), GFP_KERNEL);
-       if (!vc4)
-               return -ENOMEM;
-
        /* If VC4 V3D is missing, don't advertise render nodes. */
        node = of_find_matching_node_and_match(NULL, vc4_v3d_dt_match, NULL);
        if (!node || !of_device_is_available(node))
                vc4_drm_driver.driver_features &= ~DRIVER_RENDER;
        of_node_put(node);
 
-       drm = drm_dev_alloc(&vc4_drm_driver, dev);
-       if (IS_ERR(drm))
-               return PTR_ERR(drm);
+       vc4 = devm_drm_dev_alloc(dev, &vc4_drm_driver, struct vc4_dev, base);
+       if (IS_ERR(vc4))
+               return PTR_ERR(vc4);
+
+       drm = &vc4->base;
        platform_set_drvdata(pdev, drm);
-       vc4->dev = drm;
-       drm->dev_private = vc4;
        INIT_LIST_HEAD(&vc4->debugfs_list);
 
        mutex_init(&vc4->bin_bo_lock);
 
        ret = vc4_bo_cache_init(drm);
        if (ret)
-               goto dev_put;
+               return ret;
 
-       drm_mode_config_init(drm);
+       ret = drmm_mode_config_init(drm);
+       if (ret)
+               return ret;
 
-       vc4_gem_init(drm);
+       ret = vc4_gem_init(drm);
+       if (ret)
+               return ret;
 
        ret = component_bind_all(dev, drm);
        if (ret)
-               goto gem_destroy;
+               return ret;
 
        ret = vc4_plane_create_additional_planes(drm);
        if (ret)
@@ -312,29 +312,17 @@ static int vc4_drm_bind(struct device *dev)
 
 unbind_all:
        component_unbind_all(dev, drm);
-gem_destroy:
-       vc4_gem_destroy(drm);
-       vc4_bo_cache_destroy(drm);
-dev_put:
-       drm_dev_put(drm);
+
        return ret;
 }
 
 static void vc4_drm_unbind(struct device *dev)
 {
        struct drm_device *drm = dev_get_drvdata(dev);
-       struct vc4_dev *vc4 = to_vc4_dev(drm);
 
        drm_dev_unregister(drm);
 
        drm_atomic_helper_shutdown(drm);
-
-       drm_mode_config_cleanup(drm);
-
-       drm_atomic_private_obj_fini(&vc4->load_tracker);
-       drm_atomic_private_obj_fini(&vc4->ctm_manager);
-
-       drm_dev_put(drm);
 }
 
 static const struct component_master_ops vc4_drm_ops = {
index 90b911fd2a7f3b43191fdba401ea03ecc19809c1..19b75bebd35f9d37fbed246a4cadcab93889467a 100644 (file)
@@ -14,6 +14,7 @@
 #include <drm/drm_device.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_mm.h>
 #include <drm/drm_modeset_lock.h>
 
@@ -71,7 +72,7 @@ struct vc4_perfmon {
 };
 
 struct vc4_dev {
-       struct drm_device *dev;
+       struct drm_device base;
 
        struct vc4_hvs *hvs;
        struct vc4_v3d *v3d;
@@ -234,7 +235,7 @@ struct vc4_dev {
 static inline struct vc4_dev *
 to_vc4_dev(struct drm_device *dev)
 {
-       return (struct vc4_dev *)dev->dev_private;
+       return container_of(dev, struct vc4_dev, base);
 }
 
 struct vc4_bo {
@@ -287,7 +288,7 @@ struct vc4_bo {
 static inline struct vc4_bo *
 to_vc4_bo(struct drm_gem_object *bo)
 {
-       return (struct vc4_bo *)bo;
+       return container_of(to_drm_gem_cma_obj(bo), struct vc4_bo, base);
 }
 
 struct vc4_fence {
@@ -300,7 +301,7 @@ struct vc4_fence {
 static inline struct vc4_fence *
 to_vc4_fence(struct dma_fence *fence)
 {
-       return (struct vc4_fence *)fence;
+       return container_of(fence, struct vc4_fence, base);
 }
 
 struct vc4_seqno_cb {
@@ -347,7 +348,7 @@ struct vc4_plane {
 static inline struct vc4_plane *
 to_vc4_plane(struct drm_plane *plane)
 {
-       return (struct vc4_plane *)plane;
+       return container_of(plane, struct vc4_plane, base);
 }
 
 enum vc4_scaling_mode {
@@ -423,7 +424,7 @@ struct vc4_plane_state {
 static inline struct vc4_plane_state *
 to_vc4_plane_state(struct drm_plane_state *state)
 {
-       return (struct vc4_plane_state *)state;
+       return container_of(state, struct vc4_plane_state, base);
 }
 
 enum vc4_encoder_type {
@@ -499,7 +500,7 @@ struct vc4_crtc {
 static inline struct vc4_crtc *
 to_vc4_crtc(struct drm_crtc *crtc)
 {
-       return (struct vc4_crtc *)crtc;
+       return container_of(crtc, struct vc4_crtc, base);
 }
 
 static inline const struct vc4_crtc_data *
@@ -537,7 +538,7 @@ struct vc4_crtc_state {
 static inline struct vc4_crtc_state *
 to_vc4_crtc_state(struct drm_crtc_state *crtc_state)
 {
-       return (struct vc4_crtc_state *)crtc_state;
+       return container_of(crtc_state, struct vc4_crtc_state, base);
 }
 
 #define V3D_READ(offset) readl(vc4->v3d->regs + offset)
@@ -809,7 +810,6 @@ struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
                                                 struct sg_table *sgt);
 void *vc4_prime_vmap(struct drm_gem_object *obj);
 int vc4_bo_cache_init(struct drm_device *dev);
-void vc4_bo_cache_destroy(struct drm_device *dev);
 int vc4_bo_inc_usecnt(struct vc4_bo *bo);
 void vc4_bo_dec_usecnt(struct vc4_bo *bo);
 void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);
@@ -874,8 +874,7 @@ extern struct platform_driver vc4_dsi_driver;
 extern const struct dma_fence_ops vc4_fence_ops;
 
 /* vc4_gem.c */
-void vc4_gem_init(struct drm_device *dev);
-void vc4_gem_destroy(struct drm_device *dev);
+int vc4_gem_init(struct drm_device *dev);
 int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
                        struct drm_file *file_priv);
 int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
index 9f01ddd5b932655eadf3849f3262dc2b28277477..b641252939d878ee83527d9774fd91b426ababce 100644 (file)
@@ -314,16 +314,16 @@ vc4_reset_work(struct work_struct *work)
        struct vc4_dev *vc4 =
                container_of(work, struct vc4_dev, hangcheck.reset_work);
 
-       vc4_save_hang_state(vc4->dev);
+       vc4_save_hang_state(&vc4->base);
 
-       vc4_reset(vc4->dev);
+       vc4_reset(&vc4->base);
 }
 
 static void
 vc4_hangcheck_elapsed(struct timer_list *t)
 {
        struct vc4_dev *vc4 = from_timer(vc4, t, hangcheck.timer);
-       struct drm_device *dev = vc4->dev;
+       struct drm_device *dev = &vc4->base;
        uint32_t ct0ca, ct1ca;
        unsigned long irqflags;
        struct vc4_exec_info *bin_exec, *render_exec;
@@ -1000,7 +1000,7 @@ vc4_job_handle_completed(struct vc4_dev *vc4)
                list_del(&exec->head);
 
                spin_unlock_irqrestore(&vc4->job_lock, irqflags);
-               vc4_complete_exec(vc4->dev, exec);
+               vc4_complete_exec(&vc4->base, exec);
                spin_lock_irqsave(&vc4->job_lock, irqflags);
        }
 
@@ -1258,13 +1258,13 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
        return 0;
 
 fail:
-       vc4_complete_exec(vc4->dev, exec);
+       vc4_complete_exec(&vc4->base, exec);
 
        return ret;
 }
 
-void
-vc4_gem_init(struct drm_device *dev)
+static void vc4_gem_destroy(struct drm_device *dev, void *unused);
+int vc4_gem_init(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
@@ -1285,10 +1285,11 @@ vc4_gem_init(struct drm_device *dev)
 
        INIT_LIST_HEAD(&vc4->purgeable.list);
        mutex_init(&vc4->purgeable.lock);
+
+       return drmm_add_action_or_reset(dev, vc4_gem_destroy, NULL);
 }
 
-void
-vc4_gem_destroy(struct drm_device *dev)
+static void vc4_gem_destroy(struct drm_device *dev, void *unused)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
index e8f99e29065559a58bfc7be61e48d3239445304f..95779d50cca0b45cf38bdbeb413c4a47a450f33d 100644 (file)
@@ -922,6 +922,7 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,
                                    struct snd_soc_dai *dai)
 {
        struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
+       struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
        struct device *dev = &vc4_hdmi->pdev->dev;
        u32 audio_packet_config, channel_mask;
        u32 channel_map;
@@ -981,6 +982,8 @@ static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream,
        HDMI_WRITE(HDMI_AUDIO_PACKET_CONFIG, audio_packet_config);
        vc4_hdmi_set_n_cts(vc4_hdmi);
 
+       vc4_hdmi_set_audio_infoframe(encoder);
+
        return 0;
 }
 
@@ -988,11 +991,9 @@ static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,
                                  struct snd_soc_dai *dai)
 {
        struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
-       struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
-               vc4_hdmi_set_audio_infoframe(encoder);
                vc4_hdmi->audio.streaming = true;
 
                if (vc4_hdmi->variant->phy_rng_enable)
@@ -1076,6 +1077,7 @@ static const struct snd_soc_dapm_route vc4_hdmi_audio_routes[] = {
 };
 
 static const struct snd_soc_component_driver vc4_hdmi_audio_component_drv = {
+       .name                   = "vc4-hdmi-codec-dai-component",
        .controls               = vc4_hdmi_audio_controls,
        .num_controls           = ARRAY_SIZE(vc4_hdmi_audio_controls),
        .dapm_widgets           = vc4_hdmi_audio_widgets,
index 4d0a833366cee10eb6fca2644433738b78985eeb..b72b2bd05a815c7b31064ac8ea807760c9e5a350 100644 (file)
@@ -560,7 +560,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct drm_device *drm = dev_get_drvdata(master);
-       struct vc4_dev *vc4 = drm->dev_private;
+       struct vc4_dev *vc4 = to_vc4_dev(drm);
        struct vc4_hvs *hvs = NULL;
        int ret;
        u32 dispctrl;
@@ -679,7 +679,7 @@ static void vc4_hvs_unbind(struct device *dev, struct device *master,
                           void *data)
 {
        struct drm_device *drm = dev_get_drvdata(master);
-       struct vc4_dev *vc4 = drm->dev_private;
+       struct vc4_dev *vc4 = to_vc4_dev(drm);
        struct vc4_hvs *hvs = vc4->hvs;
 
        if (drm_mm_node_allocated(&vc4->hvs->mitchell_netravali_filter))
index 149825ff5df8d41f2a815c735cb087b41aea536f..2b951cae04ad49aad49cbb218baee30512c7809c 100644 (file)
@@ -51,7 +51,7 @@ static struct vc4_ctm_state *vc4_get_ctm_state(struct drm_atomic_state *state,
                                               struct drm_private_obj *manager)
 {
        struct drm_device *dev = state->dev;
-       struct vc4_dev *vc4 = dev->dev_private;
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
        struct drm_private_state *priv_state;
        int ret;
 
@@ -93,6 +93,29 @@ static const struct drm_private_state_funcs vc4_ctm_state_funcs = {
        .atomic_destroy_state = vc4_ctm_destroy_state,
 };
 
+static void vc4_ctm_obj_fini(struct drm_device *dev, void *unused)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+
+       drm_atomic_private_obj_fini(&vc4->ctm_manager);
+}
+
+static int vc4_ctm_obj_init(struct vc4_dev *vc4)
+{
+       struct vc4_ctm_state *ctm_state;
+
+       drm_modeset_lock_init(&vc4->ctm_state_lock);
+
+       ctm_state = kzalloc(sizeof(*ctm_state), GFP_KERNEL);
+       if (!ctm_state)
+               return -ENOMEM;
+
+       drm_atomic_private_obj_init(&vc4->base, &vc4->ctm_manager, &ctm_state->base,
+                                   &vc4_ctm_state_funcs);
+
+       return drmm_add_action(&vc4->base, vc4_ctm_obj_fini, NULL);
+}
+
 /* Converts a DRM S31.32 value to the HW S0.9 format. */
 static u16 vc4_ctm_s31_32_to_s0_9(u64 in)
 {
@@ -609,6 +632,34 @@ static const struct drm_private_state_funcs vc4_load_tracker_state_funcs = {
        .atomic_destroy_state = vc4_load_tracker_destroy_state,
 };
 
+static void vc4_load_tracker_obj_fini(struct drm_device *dev, void *unused)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+
+       if (!vc4->load_tracker_available)
+               return;
+
+       drm_atomic_private_obj_fini(&vc4->load_tracker);
+}
+
+static int vc4_load_tracker_obj_init(struct vc4_dev *vc4)
+{
+       struct vc4_load_tracker_state *load_state;
+
+       if (!vc4->load_tracker_available)
+               return 0;
+
+       load_state = kzalloc(sizeof(*load_state), GFP_KERNEL);
+       if (!load_state)
+               return -ENOMEM;
+
+       drm_atomic_private_obj_init(&vc4->base, &vc4->load_tracker,
+                                   &load_state->base,
+                                   &vc4_load_tracker_state_funcs);
+
+       return drmm_add_action(&vc4->base, vc4_load_tracker_obj_fini, NULL);
+}
+
 #define NUM_OUTPUTS  6
 #define NUM_CHANNELS 3
 
@@ -711,8 +762,6 @@ static const struct drm_mode_config_funcs vc4_mode_funcs = {
 int vc4_kms_load(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
-       struct vc4_ctm_state *ctm_state;
-       struct vc4_load_tracker_state *load_state;
        bool is_vc5 = of_device_is_compatible(dev->dev->of_node,
                                              "brcm,bcm2711-vc5");
        int ret;
@@ -751,26 +800,13 @@ int vc4_kms_load(struct drm_device *dev)
        dev->mode_config.async_page_flip = true;
        dev->mode_config.allow_fb_modifiers = true;
 
-       drm_modeset_lock_init(&vc4->ctm_state_lock);
-
-       ctm_state = kzalloc(sizeof(*ctm_state), GFP_KERNEL);
-       if (!ctm_state)
-               return -ENOMEM;
-
-       drm_atomic_private_obj_init(dev, &vc4->ctm_manager, &ctm_state->base,
-                                   &vc4_ctm_state_funcs);
-
-       if (vc4->load_tracker_available) {
-               load_state = kzalloc(sizeof(*load_state), GFP_KERNEL);
-               if (!load_state) {
-                       drm_atomic_private_obj_fini(&vc4->ctm_manager);
-                       return -ENOMEM;
-               }
+       ret = vc4_ctm_obj_init(vc4);
+       if (ret)
+               return ret;
 
-               drm_atomic_private_obj_init(dev, &vc4->load_tracker,
-                                           &load_state->base,
-                                           &vc4_load_tracker_state_funcs);
-       }
+       ret = vc4_load_tracker_obj_init(vc4);
+       if (ret)
+               return ret;
 
        drm_mode_config_reset(dev);
 
index f7ab979721b32bc3ad7cacbd9648da079676b606..65d0dac69b0bc3cd2bb50c4e321b137aa3190dd1 100644 (file)
@@ -168,7 +168,7 @@ static void vc4_v3d_init_hw(struct drm_device *dev)
 
 int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
 {
-       struct drm_device *dev = vc4->dev;
+       struct drm_device *dev = &vc4->base;
        unsigned long irqflags;
        int slot;
        uint64_t seqno = 0;
@@ -246,7 +246,7 @@ static int bin_bo_alloc(struct vc4_dev *vc4)
        INIT_LIST_HEAD(&list);
 
        while (true) {
-               struct vc4_bo *bo = vc4_bo_create(vc4->dev, size, true,
+               struct vc4_bo *bo = vc4_bo_create(&vc4->base, size, true,
                                                  VC4_BO_TYPE_BIN);
 
                if (IS_ERR(bo)) {
@@ -361,7 +361,7 @@ static int vc4_v3d_runtime_suspend(struct device *dev)
        struct vc4_v3d *v3d = dev_get_drvdata(dev);
        struct vc4_dev *vc4 = v3d->vc4;
 
-       vc4_irq_uninstall(vc4->dev);
+       vc4_irq_uninstall(&vc4->base);
 
        clk_disable_unprepare(v3d->clk);
 
@@ -378,11 +378,11 @@ static int vc4_v3d_runtime_resume(struct device *dev)
        if (ret != 0)
                return ret;
 
-       vc4_v3d_init_hw(vc4->dev);
+       vc4_v3d_init_hw(&vc4->base);
 
        /* We disabled the IRQ as part of vc4_irq_uninstall in suspend. */
-       enable_irq(vc4->dev->irq);
-       vc4_irq_postinstall(vc4->dev);
+       enable_irq(vc4->base.irq);
+       vc4_irq_postinstall(&vc4->base);
 
        return 0;
 }
index b3dae9ec1a38bf18c16a480ee5ded8cb16d0dfa1..d166ee262ce4390f0987d07e589aebe59f25bd5e 100644 (file)
@@ -133,73 +133,6 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
 }
 EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
 
-bool ipu_pixelformat_is_planar(u32 pixelformat)
-{
-       switch (pixelformat) {
-       case V4L2_PIX_FMT_YUV420:
-       case V4L2_PIX_FMT_YVU420:
-       case V4L2_PIX_FMT_YUV422P:
-       case V4L2_PIX_FMT_NV12:
-       case V4L2_PIX_FMT_NV21:
-       case V4L2_PIX_FMT_NV16:
-       case V4L2_PIX_FMT_NV61:
-               return true;
-       }
-
-       return false;
-}
-EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar);
-
-enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
-{
-       switch (mbus_code & 0xf000) {
-       case 0x1000:
-               return IPUV3_COLORSPACE_RGB;
-       case 0x2000:
-               return IPUV3_COLORSPACE_YUV;
-       default:
-               return IPUV3_COLORSPACE_UNKNOWN;
-       }
-}
-EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
-
-int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
-{
-       switch (pixelformat) {
-       case V4L2_PIX_FMT_YUV420:
-       case V4L2_PIX_FMT_YVU420:
-       case V4L2_PIX_FMT_YUV422P:
-       case V4L2_PIX_FMT_NV12:
-       case V4L2_PIX_FMT_NV21:
-       case V4L2_PIX_FMT_NV16:
-       case V4L2_PIX_FMT_NV61:
-               /*
-                * for the planar YUV formats, the stride passed to
-                * cpmem must be the stride in bytes of the Y plane.
-                * And all the planar YUV formats have an 8-bit
-                * Y component.
-                */
-               return (8 * pixel_stride) >> 3;
-       case V4L2_PIX_FMT_RGB565:
-       case V4L2_PIX_FMT_YUYV:
-       case V4L2_PIX_FMT_UYVY:
-               return (16 * pixel_stride) >> 3;
-       case V4L2_PIX_FMT_BGR24:
-       case V4L2_PIX_FMT_RGB24:
-               return (24 * pixel_stride) >> 3;
-       case V4L2_PIX_FMT_BGR32:
-       case V4L2_PIX_FMT_RGB32:
-       case V4L2_PIX_FMT_XBGR32:
-       case V4L2_PIX_FMT_XRGB32:
-               return (32 * pixel_stride) >> 3;
-       default:
-               break;
-       }
-
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
-
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
                            bool hflip, bool vflip)
 {
index b64d2efbefe71a5df31d1bd3c934faf19ecb515d..eb56e09ae15f3999478b0e75f601836c92ad175a 100644 (file)
@@ -1275,7 +1275,7 @@ static void balloon_up(struct work_struct *dummy)
 
        /* Refuse to balloon below the floor. */
        if (avail_pages < num_pages || avail_pages - num_pages < floor) {
-               pr_warn("Balloon request will be partially fulfilled. %s\n",
+               pr_info("Balloon request will be partially fulfilled. %s\n",
                        avail_pages < num_pages ? "Not enough memory." :
                        "Balloon floor reached.");
 
index 6994c1309b2b6c66abb8dc6eb52e2d4396daa77c..cc9e8025c533c018942d5fb5e9b751fb8873a228 100644 (file)
@@ -1689,6 +1689,7 @@ static void __exit coresight_exit(void)
 module_init(coresight_init);
 module_exit(coresight_exit);
 
+MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
 MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
 MODULE_DESCRIPTION("Arm CoreSight tracer driver");
index 392757f3a019e8f753b383896be5f89e83ed061c..7ff7e7780bbfbcde5b74f7a2f118b0a3914d1267 100644 (file)
@@ -1065,6 +1065,13 @@ static int cti_create_con_sysfs_attr(struct device *dev,
        }
        eattr->var = con;
        con->con_attrs[attr_idx] = &eattr->attr.attr;
+       /*
+        * Initialize the dynamically allocated attribute
+        * to avoid LOCKDEP splat. See include/linux/sysfs.h
+        * for more details.
+        */
+       sysfs_attr_init(con->con_attrs[attr_idx]);
+
        return 0;
 }
 
index c2c9b127d0748045155bcec51b8d191a8daec760..bdc34ca449f7145ba06755738e4e97029310564f 100644 (file)
@@ -210,7 +210,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
        u32 id;
        int cpu = event->cpu;
        cpumask_t *mask;
-       struct coresight_device *sink;
+       struct coresight_device *sink = NULL;
        struct etm_event_data *event_data = NULL;
 
        event_data = alloc_event_data(cpu);
index a4f473ef4e5c04c87abdb5d0343115a2f098dfc4..a97a9d05819852570320315950bca0bb08ed942b 100644 (file)
@@ -733,7 +733,7 @@ config I2C_LPC2K
 
 config I2C_MLXBF
         tristate "Mellanox BlueField I2C controller"
-        depends on ARM64
+        depends on MELLANOX_PLATFORM && ARM64
         help
           Enabling this option will add I2C SMBus support for Mellanox BlueField
           system.
index 44974b53a6268149007cff3c5c394ba3c6b56b63..0d15f4c1e9f7e3ae17a03f7b39465b47f8cf5abe 100644 (file)
@@ -159,7 +159,6 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
        u32 raw_stat, stat, enabled, tmp;
        u8 val = 0, slave_activity;
 
-       regmap_read(dev->map, DW_IC_INTR_STAT, &stat);
        regmap_read(dev->map, DW_IC_ENABLE, &enabled);
        regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_stat);
        regmap_read(dev->map, DW_IC_STATUS, &tmp);
@@ -168,32 +167,30 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
        if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave)
                return 0;
 
+       stat = i2c_dw_read_clear_intrbits_slave(dev);
        dev_dbg(dev->dev,
                "%#x STATUS SLAVE_ACTIVITY=%#x : RAW_INTR_STAT=%#x : INTR_STAT=%#x\n",
                enabled, slave_activity, raw_stat, stat);
 
-       if ((stat & DW_IC_INTR_RX_FULL) && (stat & DW_IC_INTR_STOP_DET))
-               i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED, &val);
+       if (stat & DW_IC_INTR_RX_FULL) {
+               if (dev->status != STATUS_WRITE_IN_PROGRESS) {
+                       dev->status = STATUS_WRITE_IN_PROGRESS;
+                       i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED,
+                                       &val);
+               }
+
+               regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
+               val = tmp;
+               if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,
+                                    &val))
+                       dev_vdbg(dev->dev, "Byte %X acked!", val);
+       }
 
        if (stat & DW_IC_INTR_RD_REQ) {
                if (slave_activity) {
-                       if (stat & DW_IC_INTR_RX_FULL) {
-                               regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
-                               val = tmp;
-
-                               if (!i2c_slave_event(dev->slave,
-                                                    I2C_SLAVE_WRITE_RECEIVED,
-                                                    &val)) {
-                                       dev_vdbg(dev->dev, "Byte %X acked!",
-                                                val);
-                               }
-                               regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
-                               stat = i2c_dw_read_clear_intrbits_slave(dev);
-                       } else {
-                               regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
-                               regmap_read(dev->map, DW_IC_CLR_RX_UNDER, &tmp);
-                               stat = i2c_dw_read_clear_intrbits_slave(dev);
-                       }
+                       regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp);
+
+                       dev->status = STATUS_READ_IN_PROGRESS;
                        if (!i2c_slave_event(dev->slave,
                                             I2C_SLAVE_READ_REQUESTED,
                                             &val))
@@ -205,21 +202,11 @@ static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev)
                if (!i2c_slave_event(dev->slave, I2C_SLAVE_READ_PROCESSED,
                                     &val))
                        regmap_read(dev->map, DW_IC_CLR_RX_DONE, &tmp);
-
-               i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
-               stat = i2c_dw_read_clear_intrbits_slave(dev);
-               return 1;
        }
 
-       if (stat & DW_IC_INTR_RX_FULL) {
-               regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
-               val = tmp;
-               if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED,
-                                    &val))
-                       dev_vdbg(dev->dev, "Byte %X acked!", val);
-       } else {
+       if (stat & DW_IC_INTR_STOP_DET) {
+               dev->status = STATUS_IDLE;
                i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val);
-               stat = i2c_dw_read_clear_intrbits_slave(dev);
        }
 
        return 1;
@@ -230,7 +217,6 @@ static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id)
        struct dw_i2c_dev *dev = dev_id;
        int ret;
 
-       i2c_dw_read_clear_intrbits_slave(dev);
        ret = i2c_dw_irq_handler_slave(dev);
        if (ret > 0)
                complete(&dev->cmd_complete);
index ee59e0da082dfbe3b55acadb37010c6b344f9321..33574d40ea9ca8671655159bc645747404e71856 100644 (file)
  * Master. Default value is set to 400MHz.
  */
 #define MLXBF_I2C_TYU_PLL_OUT_FREQ  (400 * 1000 * 1000)
-/* Reference clock for Bluefield 1 - 156 MHz. */
-#define MLXBF_I2C_TYU_PLL_IN_FREQ   (156 * 1000 * 1000)
-/* Reference clock for BlueField 2 - 200 MHz. */
-#define MLXBF_I2C_YU_PLL_IN_FREQ    (200 * 1000 * 1000)
+/* Reference clock for Bluefield - 156 MHz. */
+#define MLXBF_I2C_PLL_IN_FREQ       (156 * 1000 * 1000)
 
 /* Constant used to determine the PLL frequency. */
 #define MLNXBF_I2C_COREPLL_CONST    16384
@@ -489,44 +487,6 @@ static struct mutex mlxbf_i2c_bus_lock;
 
 #define MLXBF_I2C_FREQUENCY_1GHZ  1000000000
 
-static void mlxbf_i2c_write(void __iomem *io, int reg, u32 val)
-{
-       writel(val, io + reg);
-}
-
-static u32 mlxbf_i2c_read(void __iomem *io, int reg)
-{
-       return readl(io + reg);
-}
-
-/*
- * This function is used to read data from Master GW Data Descriptor.
- * Data bytes in the Master GW Data Descriptor are shifted left so the
- * data starts at the MSB of the descriptor registers as set by the
- * underlying hardware. TYU_READ_DATA enables byte swapping while
- * reading data bytes, and MUST be called by the SMBus read routines
- * to copy data from the 32 * 32-bit HW Data registers a.k.a Master GW
- * Data Descriptor.
- */
-static u32 mlxbf_i2c_read_data(void __iomem *io, int reg)
-{
-       return (u32)be32_to_cpu(mlxbf_i2c_read(io, reg));
-}
-
-/*
- * This function is used to write data to the Master GW Data Descriptor.
- * Data copied to the Master GW Data Descriptor MUST be shifted left so
- * the data starts at the MSB of the descriptor registers as required by
- * the underlying hardware. TYU_WRITE_DATA enables byte swapping when
- * writing data bytes, and MUST be called by the SMBus write routines to
- * copy data to the 32 * 32-bit HW Data registers a.k.a Master GW Data
- * Descriptor.
- */
-static void mlxbf_i2c_write_data(void __iomem *io, int reg, u32 val)
-{
-       mlxbf_i2c_write(io, reg, (u32)cpu_to_be32(val));
-}
-
 /*
  * Function to poll a set of bits at a specific address; it checks whether
  * the bits are equal to zero when eq_zero is set to 'true', and not equal
@@ -541,7 +501,7 @@ static u32 mlxbf_smbus_poll(void __iomem *io, u32 addr, u32 mask,
        timeout = (timeout / MLXBF_I2C_POLL_FREQ_IN_USEC) + 1;
 
        do {
-               bits = mlxbf_i2c_read(io, addr) & mask;
+               bits = readl(io + addr) & mask;
                if (eq_zero ? bits == 0 : bits != 0)
                        return eq_zero ? 1 : bits;
                udelay(MLXBF_I2C_POLL_FREQ_IN_USEC);
@@ -609,16 +569,16 @@ static int mlxbf_i2c_smbus_check_status(struct mlxbf_i2c_priv *priv)
                         MLXBF_I2C_SMBUS_TIMEOUT);
 
        /* Read cause status bits. */
-       cause_status_bits = mlxbf_i2c_read(priv->mst_cause->io,
-                                          MLXBF_I2C_CAUSE_ARBITER);
+       cause_status_bits = readl(priv->mst_cause->io +
+                                       MLXBF_I2C_CAUSE_ARBITER);
        cause_status_bits &= MLXBF_I2C_CAUSE_MASTER_ARBITER_BITS_MASK;
 
        /*
         * Parse both Cause and Master GW bits, then return transaction status.
         */
 
-       master_status_bits = mlxbf_i2c_read(priv->smbus->io,
-                                           MLXBF_I2C_SMBUS_MASTER_STATUS);
+       master_status_bits = readl(priv->smbus->io +
+                                       MLXBF_I2C_SMBUS_MASTER_STATUS);
        master_status_bits &= MLXBF_I2C_SMBUS_MASTER_STATUS_MASK;
 
        if (mlxbf_i2c_smbus_transaction_success(master_status_bits,
@@ -649,10 +609,17 @@ static void mlxbf_i2c_smbus_write_data(struct mlxbf_i2c_priv *priv,
 
        aligned_length = round_up(length, 4);
 
-       /* Copy data bytes from 4-byte aligned source buffer. */
+       /*
+        * Copy data bytes from 4-byte aligned source buffer.
+        * Data copied to the Master GW Data Descriptor MUST be shifted
+        * left so the data starts at the MSB of the descriptor registers
+        * as required by the underlying hardware. Enable byte swapping
+        * when writing data bytes to the 32 * 32-bit HW Data registers
+        * a.k.a Master GW Data Descriptor.
+        */
        for (offset = 0; offset < aligned_length; offset += sizeof(u32)) {
                data32 = *((u32 *)(data + offset));
-               mlxbf_i2c_write_data(priv->smbus->io, addr + offset, data32);
+               iowrite32be(data32, priv->smbus->io + addr + offset);
        }
 }
 
@@ -664,15 +631,23 @@ static void mlxbf_i2c_smbus_read_data(struct mlxbf_i2c_priv *priv,
 
        mask = sizeof(u32) - 1;
 
+       /*
+        * Data bytes in the Master GW Data Descriptor are shifted left
+        * so the data starts at the MSB of the descriptor registers as
+        * set by the underlying hardware. Enable byte swapping while
+        * reading data bytes from the 32 * 32-bit HW Data registers
+        * a.k.a Master GW Data Descriptor.
+        */
+
        for (offset = 0; offset < (length & ~mask); offset += sizeof(u32)) {
-               data32 = mlxbf_i2c_read_data(priv->smbus->io, addr + offset);
+               data32 = ioread32be(priv->smbus->io + addr + offset);
                *((u32 *)(data + offset)) = data32;
        }
 
        if (!(length & mask))
                return;
 
-       data32 = mlxbf_i2c_read_data(priv->smbus->io, addr + offset);
+       data32 = ioread32be(priv->smbus->io + addr + offset);
 
        for (byte = 0; byte < (length & mask); byte++) {
                data[offset + byte] = data32 & GENMASK(7, 0);
@@ -698,16 +673,16 @@ static int mlxbf_i2c_smbus_enable(struct mlxbf_i2c_priv *priv, u8 slave,
        command |= rol32(pec_en, MLXBF_I2C_MASTER_SEND_PEC_SHIFT);
 
        /* Clear status bits. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_STATUS, 0x0);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_STATUS);
        /* Set the cause data. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_CAUSE_OR_CLEAR, ~0x0);
+       writel(~0x0, priv->smbus->io + MLXBF_I2C_CAUSE_OR_CLEAR);
        /* Zero PEC byte. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_PEC, 0x0);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_PEC);
        /* Zero byte count. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_RS_BYTES, 0x0);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_RS_BYTES);
 
        /* GW activation. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_GW, command);
+       writel(command, priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_GW);
 
        /*
         * Poll master status and check status bits. An ACK is sent when
@@ -823,8 +798,8 @@ mlxbf_i2c_smbus_start_transaction(struct mlxbf_i2c_priv *priv,
                 * needs to be 'manually' reset. This should be removed in
                 * next tag integration.
                 */
-               mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_MASTER_FSM,
-                               MLXBF_I2C_SMBUS_MASTER_FSM_PS_STATE_MASK);
+               writel(MLXBF_I2C_SMBUS_MASTER_FSM_PS_STATE_MASK,
+                       priv->smbus->io + MLXBF_I2C_SMBUS_MASTER_FSM);
        }
 
        return ret;
@@ -1113,8 +1088,8 @@ static void mlxbf_i2c_set_timings(struct mlxbf_i2c_priv *priv,
        timer |= mlxbf_i2c_set_timer(priv, timings->scl_low,
                                     false, MLXBF_I2C_MASK_16,
                                     MLXBF_I2C_SHIFT_16);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_SCL_LOW_SCL_HIGH,
-                         timer);
+       writel(timer, priv->smbus->io +
+               MLXBF_I2C_SMBUS_TIMER_SCL_LOW_SCL_HIGH);
 
        timer = mlxbf_i2c_set_timer(priv, timings->sda_rise, false,
                                    MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_0);
@@ -1124,37 +1099,34 @@ static void mlxbf_i2c_set_timings(struct mlxbf_i2c_priv *priv,
                                     MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_16);
        timer |= mlxbf_i2c_set_timer(priv, timings->scl_fall, false,
                                     MLXBF_I2C_MASK_8, MLXBF_I2C_SHIFT_24);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_FALL_RISE_SPIKE,
-                         timer);
+       writel(timer, priv->smbus->io +
+               MLXBF_I2C_SMBUS_TIMER_FALL_RISE_SPIKE);
 
        timer = mlxbf_i2c_set_timer(priv, timings->hold_start, true,
                                    MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);
        timer |= mlxbf_i2c_set_timer(priv, timings->hold_data, true,
                                     MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_THOLD, timer);
+       writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_TIMER_THOLD);
 
        timer = mlxbf_i2c_set_timer(priv, timings->setup_start, true,
                                    MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);
        timer |= mlxbf_i2c_set_timer(priv, timings->setup_stop, true,
                                     MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);
-       mlxbf_i2c_write(priv->smbus->io,
-                       MLXBF_I2C_SMBUS_TIMER_TSETUP_START_STOP, timer);
+       writel(timer, priv->smbus->io +
+               MLXBF_I2C_SMBUS_TIMER_TSETUP_START_STOP);
 
        timer = mlxbf_i2c_set_timer(priv, timings->setup_data, true,
                                    MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_TIMER_TSETUP_DATA,
-                         timer);
+       writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_TIMER_TSETUP_DATA);
 
        timer = mlxbf_i2c_set_timer(priv, timings->buf, false,
                                    MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_0);
        timer |= mlxbf_i2c_set_timer(priv, timings->thigh_max, false,
                                     MLXBF_I2C_MASK_16, MLXBF_I2C_SHIFT_16);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_THIGH_MAX_TBUF,
-                       timer);
+       writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_THIGH_MAX_TBUF);
 
        timer = timings->timeout;
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT,
-                       timer);
+       writel(timer, priv->smbus->io + MLXBF_I2C_SMBUS_SCL_LOW_TIMEOUT);
 }
 
 enum mlxbf_i2c_timings_config {
@@ -1426,19 +1398,15 @@ static int mlxbf_i2c_init_master(struct platform_device *pdev,
         * platform firmware; disabling the bus might compromise the system
         * functionality.
         */
-       config_reg = mlxbf_i2c_read(gpio_res->io,
-                                   MLXBF_I2C_GPIO_0_FUNC_EN_0);
+       config_reg = readl(gpio_res->io + MLXBF_I2C_GPIO_0_FUNC_EN_0);
        config_reg = MLXBF_I2C_GPIO_SMBUS_GW_ASSERT_PINS(priv->bus,
                                                         config_reg);
-       mlxbf_i2c_write(gpio_res->io, MLXBF_I2C_GPIO_0_FUNC_EN_0,
-                       config_reg);
+       writel(config_reg, gpio_res->io + MLXBF_I2C_GPIO_0_FUNC_EN_0);
 
-       config_reg = mlxbf_i2c_read(gpio_res->io,
-                                   MLXBF_I2C_GPIO_0_FORCE_OE_EN);
+       config_reg = readl(gpio_res->io + MLXBF_I2C_GPIO_0_FORCE_OE_EN);
        config_reg = MLXBF_I2C_GPIO_SMBUS_GW_RESET_PINS(priv->bus,
                                                        config_reg);
-       mlxbf_i2c_write(gpio_res->io, MLXBF_I2C_GPIO_0_FORCE_OE_EN,
-                       config_reg);
+       writel(config_reg, gpio_res->io + MLXBF_I2C_GPIO_0_FORCE_OE_EN);
 
        mutex_unlock(gpio_res->lock);
 
@@ -1452,10 +1420,9 @@ static u64 mlxbf_calculate_freq_from_tyu(struct mlxbf_i2c_resource *corepll_res)
        u32 corepll_val;
        u16 core_f;
 
-       pad_frequency = MLXBF_I2C_TYU_PLL_IN_FREQ;
+       pad_frequency = MLXBF_I2C_PLL_IN_FREQ;
 
-       corepll_val = mlxbf_i2c_read(corepll_res->io,
-                                    MLXBF_I2C_CORE_PLL_REG1);
+       corepll_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG1);
 
        /* Get Core PLL configuration bits. */
        core_f = rol32(corepll_val, MLXBF_I2C_COREPLL_CORE_F_TYU_SHIFT) &
@@ -1488,12 +1455,10 @@ static u64 mlxbf_calculate_freq_from_yu(struct mlxbf_i2c_resource *corepll_res)
        u8 core_od, core_r;
        u32 core_f;
 
-       pad_frequency = MLXBF_I2C_YU_PLL_IN_FREQ;
+       pad_frequency = MLXBF_I2C_PLL_IN_FREQ;
 
-       corepll_reg1_val = mlxbf_i2c_read(corepll_res->io,
-                                         MLXBF_I2C_CORE_PLL_REG1);
-       corepll_reg2_val = mlxbf_i2c_read(corepll_res->io,
-                                         MLXBF_I2C_CORE_PLL_REG2);
+       corepll_reg1_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG1);
+       corepll_reg2_val = readl(corepll_res->io + MLXBF_I2C_CORE_PLL_REG2);
 
        /* Get Core PLL configuration bits */
        core_f = rol32(corepll_reg1_val, MLXBF_I2C_COREPLL_CORE_F_YU_SHIFT) &
@@ -1585,7 +1550,7 @@ static int mlxbf_slave_enable(struct mlxbf_i2c_priv *priv, u8 addr)
         * (7-bit address, 1 status bit (1 if enabled, 0 if not)).
         */
        for (reg = 0; reg < reg_cnt; reg++) {
-               slave_reg = mlxbf_i2c_read(priv->smbus->io,
+               slave_reg = readl(priv->smbus->io +
                                MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4);
                /*
                 * Each register holds 4 slave addresses. So, we have to keep
@@ -1643,8 +1608,8 @@ static int mlxbf_slave_enable(struct mlxbf_i2c_priv *priv, u8 addr)
 
        /* Enable the slave address and update the register. */
        slave_reg |= (1 << MLXBF_I2C_SMBUS_SLAVE_ADDR_EN_BIT) << (byte * 8);
-       mlxbf_i2c_write(priv->smbus->io,
-                       MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4, slave_reg);
+       writel(slave_reg, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG +
+               reg * 0x4);
 
        return 0;
 }
@@ -1668,7 +1633,7 @@ static int mlxbf_slave_disable(struct mlxbf_i2c_priv *priv)
         * (7-bit address, 1 status bit (1 if enabled, 0 if not)).
         */
        for (reg = 0; reg < reg_cnt; reg++) {
-               slave_reg = mlxbf_i2c_read(priv->smbus->io,
+               slave_reg = readl(priv->smbus->io +
                                MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4);
 
                /* Check whether the address slots are empty. */
@@ -1708,8 +1673,8 @@ static int mlxbf_slave_disable(struct mlxbf_i2c_priv *priv)
 
        /* Cleanup the slave address slot. */
        slave_reg &= ~(GENMASK(7, 0) << (slave_byte * 8));
-       mlxbf_i2c_write(priv->smbus->io,
-                       MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG + reg * 0x4, slave_reg);
+       writel(slave_reg, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_ADDR_CFG +
+               reg * 0x4);
 
        return 0;
 }
@@ -1801,7 +1766,7 @@ static int mlxbf_i2c_init_slave(struct platform_device *pdev,
        int ret;
 
        /* Reset FSM. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_FSM, 0);
+       writel(0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_FSM);
 
        /*
         * Enable slave cause interrupt bits. Drive
@@ -1810,15 +1775,13 @@ static int mlxbf_i2c_init_slave(struct platform_device *pdev,
         * masters issue a Read and Write, respectively. But, clear all
         * interrupts first.
         */
-       mlxbf_i2c_write(priv->slv_cause->io,
-                         MLXBF_I2C_CAUSE_OR_CLEAR, ~0);
+       writel(~0, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_CLEAR);
        int_reg = MLXBF_I2C_CAUSE_READ_WAIT_FW_RESPONSE;
        int_reg |= MLXBF_I2C_CAUSE_WRITE_SUCCESS;
-       mlxbf_i2c_write(priv->slv_cause->io,
-                         MLXBF_I2C_CAUSE_OR_EVTEN0, int_reg);
+       writel(int_reg, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_EVTEN0);
 
        /* Finally, set the 'ready' bit to start handling transactions. */
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);
+       writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);
 
        /* Initialize the cause coalesce resource. */
        ret = mlxbf_i2c_init_coalesce(pdev, priv);
@@ -1844,23 +1807,21 @@ static bool mlxbf_i2c_has_coalesce(struct mlxbf_i2c_priv *priv, bool *read,
                                MLXBF_I2C_CAUSE_YU_SLAVE_BIT :
                                priv->bus + MLXBF_I2C_CAUSE_TYU_SLAVE_BIT;
 
-       coalesce0_reg = mlxbf_i2c_read(priv->coalesce->io,
-                                      MLXBF_I2C_CAUSE_COALESCE_0);
+       coalesce0_reg = readl(priv->coalesce->io + MLXBF_I2C_CAUSE_COALESCE_0);
        is_set = coalesce0_reg & (1 << slave_shift);
 
        if (!is_set)
                return false;
 
        /* Check the source of the interrupt, i.e. whether a Read or Write. */
-       cause_reg = mlxbf_i2c_read(priv->slv_cause->io,
-                                    MLXBF_I2C_CAUSE_ARBITER);
+       cause_reg = readl(priv->slv_cause->io + MLXBF_I2C_CAUSE_ARBITER);
        if (cause_reg & MLXBF_I2C_CAUSE_READ_WAIT_FW_RESPONSE)
                *read = true;
        else if (cause_reg & MLXBF_I2C_CAUSE_WRITE_SUCCESS)
                *write = true;
 
        /* Clear cause bits. */
-       mlxbf_i2c_write(priv->slv_cause->io, MLXBF_I2C_CAUSE_OR_CLEAR, ~0x0);
+       writel(~0x0, priv->slv_cause->io + MLXBF_I2C_CAUSE_OR_CLEAR);
 
        return true;
 }
@@ -1900,8 +1861,8 @@ static int mlxbf_smbus_irq_send(struct mlxbf_i2c_priv *priv, u8 recv_bytes)
         * address, if supplied.
         */
        if (recv_bytes > 0) {
-               data32 = mlxbf_i2c_read_data(priv->smbus->io,
-                                            MLXBF_I2C_SLAVE_DATA_DESC_ADDR);
+               data32 = ioread32be(priv->smbus->io +
+                                       MLXBF_I2C_SLAVE_DATA_DESC_ADDR);
 
                /* Parse the received bytes. */
                switch (recv_bytes) {
@@ -1966,7 +1927,7 @@ static int mlxbf_smbus_irq_send(struct mlxbf_i2c_priv *priv, u8 recv_bytes)
        control32 |= rol32(write_size, MLXBF_I2C_SLAVE_WRITE_BYTES_SHIFT);
        control32 |= rol32(pec_en, MLXBF_I2C_SLAVE_SEND_PEC_SHIFT);
 
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_GW, control32);
+       writel(control32, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_GW);
 
        /*
         * Wait until the transfer is completed; the driver will wait
@@ -1975,10 +1936,9 @@ static int mlxbf_smbus_irq_send(struct mlxbf_i2c_priv *priv, u8 recv_bytes)
        mlxbf_smbus_slave_wait_for_idle(priv, MLXBF_I2C_SMBUS_TIMEOUT);
 
        /* Release the Slave GW. */
-       mlxbf_i2c_write(priv->smbus->io,
-                       MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES, 0x0);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_PEC, 0x0);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_PEC);
+       writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);
 
        return 0;
 }
@@ -2023,10 +1983,9 @@ static int mlxbf_smbus_irq_recv(struct mlxbf_i2c_priv *priv, u8 recv_bytes)
        i2c_slave_event(slave, I2C_SLAVE_STOP, &value);
 
        /* Release the Slave GW. */
-       mlxbf_i2c_write(priv->smbus->io,
-                       MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES, 0x0);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_PEC, 0x0);
-       mlxbf_i2c_write(priv->smbus->io, MLXBF_I2C_SMBUS_SLAVE_READY, 0x1);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);
+       writel(0x0, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_PEC);
+       writel(0x1, priv->smbus->io + MLXBF_I2C_SMBUS_SLAVE_READY);
 
        return ret;
 }
@@ -2061,8 +2020,8 @@ static irqreturn_t mlxbf_smbus_irq(int irq, void *ptr)
         * slave, if the higher 8 bits are sent then the slave expect N bytes
         * from the master.
         */
-       rw_bytes_reg = mlxbf_i2c_read(priv->smbus->io,
-                                     MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);
+       rw_bytes_reg = readl(priv->smbus->io +
+                               MLXBF_I2C_SMBUS_SLAVE_RS_MASTER_BYTES);
        recv_bytes = (rw_bytes_reg >> 8) & GENMASK(7, 0);
 
        /*
@@ -2264,6 +2223,7 @@ static const struct of_device_id mlxbf_i2c_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, mlxbf_i2c_dt_ids);
 
+#ifdef CONFIG_ACPI
 static const struct acpi_device_id mlxbf_i2c_acpi_ids[] = {
        { "MLNXBF03", (kernel_ulong_t)&mlxbf_i2c_chip[MLXBF_I2C_CHIP_TYPE_1] },
        { "MLNXBF23", (kernel_ulong_t)&mlxbf_i2c_chip[MLXBF_I2C_CHIP_TYPE_2] },
@@ -2305,6 +2265,12 @@ static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
 
        return ret;
 }
+#else
+static int mlxbf_i2c_acpi_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
+{
+       return -ENOENT;
+}
+#endif /* CONFIG_ACPI */
 
 static int mlxbf_i2c_of_probe(struct device *dev, struct mlxbf_i2c_priv *priv)
 {
@@ -2473,7 +2439,9 @@ static struct platform_driver mlxbf_i2c_driver = {
        .driver = {
                .name = "i2c-mlxbf",
                .of_match_table = mlxbf_i2c_dt_ids,
+#ifdef CONFIG_ACPI
                .acpi_match_table = ACPI_PTR(mlxbf_i2c_acpi_ids),
+#endif /* CONFIG_ACPI  */
        },
 };
 
@@ -2502,5 +2470,5 @@ static void __exit mlxbf_i2c_exit(void)
 module_exit(mlxbf_i2c_exit);
 
 MODULE_DESCRIPTION("Mellanox BlueField I2C bus driver");
-MODULE_AUTHOR("Khalil Blaiech <kblaiech@mellanox.com>");
+MODULE_AUTHOR("Khalil Blaiech <kblaiech@nvidia.com>");
 MODULE_LICENSE("GPL v2");
index 0cbdfbe605b55ebdcb3cb25e1ccac224ad9fabe2..33de99b7bc20c0ea215991c43efa1f89529e474e 100644 (file)
@@ -475,6 +475,10 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c)
 {
        u16 control_reg;
 
+       writel(I2C_DMA_HARD_RST, i2c->pdmabase + OFFSET_RST);
+       udelay(50);
+       writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST);
+
        mtk_i2c_writew(i2c, I2C_SOFT_RST, OFFSET_SOFTRESET);
 
        /* Set ioconfig */
@@ -529,10 +533,6 @@ static void mtk_i2c_init_hw(struct mtk_i2c *i2c)
 
        mtk_i2c_writew(i2c, control_reg, OFFSET_CONTROL);
        mtk_i2c_writew(i2c, I2C_DELAY_LEN, OFFSET_DELAY_LEN);
-
-       writel(I2C_DMA_HARD_RST, i2c->pdmabase + OFFSET_RST);
-       udelay(50);
-       writel(I2C_DMA_CLR_FLAG, i2c->pdmabase + OFFSET_RST);
 }
 
 static const struct i2c_spec_values *mtk_i2c_get_spec(unsigned int speed)
index cab7255599991962c67c629ba148f8e22278efc7..bdd60770779ad5231699da43e553d6552c392541 100644 (file)
@@ -129,6 +129,7 @@ struct sh_mobile_i2c_data {
        int sr;
        bool send_stop;
        bool stop_after_dma;
+       bool atomic_xfer;
 
        struct resource *res;
        struct dma_chan *dma_tx;
@@ -330,13 +331,15 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, enum sh_mobile_i2c_op
                ret = iic_rd(pd, ICDR);
                break;
        case OP_RX_STOP: /* enable DTE interrupt, issue stop */
-               iic_wr(pd, ICIC,
-                      ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+               if (!pd->atomic_xfer)
+                       iic_wr(pd, ICIC,
+                              ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
                iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
                break;
        case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */
-               iic_wr(pd, ICIC,
-                      ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+               if (!pd->atomic_xfer)
+                       iic_wr(pd, ICIC,
+                              ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
                ret = iic_rd(pd, ICDR);
                iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
                break;
@@ -429,7 +432,8 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
 
        if (wakeup) {
                pd->sr |= SW_DONE;
-               wake_up(&pd->wait);
+               if (!pd->atomic_xfer)
+                       wake_up(&pd->wait);
        }
 
        /* defeat write posting to avoid spurious WAIT interrupts */
@@ -581,6 +585,9 @@ static void start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
        pd->pos = -1;
        pd->sr = 0;
 
+       if (pd->atomic_xfer)
+               return;
+
        pd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8);
        if (pd->dma_buf)
                sh_mobile_i2c_xfer_dma(pd);
@@ -637,15 +644,13 @@ static int poll_busy(struct sh_mobile_i2c_data *pd)
        return i ? 0 : -ETIMEDOUT;
 }
 
-static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
-                             struct i2c_msg *msgs,
-                             int num)
+static int sh_mobile_xfer(struct sh_mobile_i2c_data *pd,
+                        struct i2c_msg *msgs, int num)
 {
-       struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter);
        struct i2c_msg  *msg;
        int err = 0;
        int i;
-       long timeout;
+       long time_left;
 
        /* Wake up device and enable clock */
        pm_runtime_get_sync(pd->dev);
@@ -662,15 +667,35 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
                if (do_start)
                        i2c_op(pd, OP_START);
 
-               /* The interrupt handler takes care of the rest... */
-               timeout = wait_event_timeout(pd->wait,
-                                      pd->sr & (ICSR_TACK | SW_DONE),
-                                      adapter->timeout);
-
-               /* 'stop_after_dma' tells if DMA transfer was complete */
-               i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, pd->stop_after_dma);
+               if (pd->atomic_xfer) {
+                       unsigned long j = jiffies + pd->adap.timeout;
+
+                       time_left = time_before_eq(jiffies, j);
+                       while (time_left &&
+                              !(pd->sr & (ICSR_TACK | SW_DONE))) {
+                               unsigned char sr = iic_rd(pd, ICSR);
+
+                               if (sr & (ICSR_AL   | ICSR_TACK |
+                                         ICSR_WAIT | ICSR_DTE)) {
+                                       sh_mobile_i2c_isr(0, pd);
+                                       udelay(150);
+                               } else {
+                                       cpu_relax();
+                               }
+                               time_left = time_before_eq(jiffies, j);
+                       }
+               } else {
+                       /* The interrupt handler takes care of the rest... */
+                       time_left = wait_event_timeout(pd->wait,
+                                       pd->sr & (ICSR_TACK | SW_DONE),
+                                       pd->adap.timeout);
+
+                       /* 'stop_after_dma' tells if DMA xfer was complete */
+                       i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg,
+                                                pd->stop_after_dma);
+               }
 
-               if (!timeout) {
+               if (!time_left) {
                        dev_err(pd->dev, "Transfer request timed out\n");
                        if (pd->dma_direction != DMA_NONE)
                                sh_mobile_i2c_cleanup_dma(pd);
@@ -696,14 +721,35 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
        return err ?: num;
 }
 
+static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
+                             struct i2c_msg *msgs,
+                             int num)
+{
+       struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter);
+
+       pd->atomic_xfer = false;
+       return sh_mobile_xfer(pd, msgs, num);
+}
+
+static int sh_mobile_i2c_xfer_atomic(struct i2c_adapter *adapter,
+                                    struct i2c_msg *msgs,
+                                    int num)
+{
+       struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter);
+
+       pd->atomic_xfer = true;
+       return sh_mobile_xfer(pd, msgs, num);
+}
+
 static u32 sh_mobile_i2c_func(struct i2c_adapter *adapter)
 {
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING;
 }
 
 static const struct i2c_algorithm sh_mobile_i2c_algorithm = {
-       .functionality  = sh_mobile_i2c_func,
-       .master_xfer    = sh_mobile_i2c_xfer,
+       .functionality = sh_mobile_i2c_func,
+       .master_xfer = sh_mobile_i2c_xfer,
+       .master_xfer_atomic = sh_mobile_i2c_xfer_atomic,
 };
 
 static const struct i2c_adapter_quirks sh_mobile_i2c_quirks = {
index 56f5b8077cbad7b1f096c3ee596374d2dffefc1c..01bace49a9626cf79fe2d0d3fd758fe455a6e745 100644 (file)
@@ -1239,7 +1239,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
                struct acpi_processor_cx *cx;
                struct cpuidle_state *state;
 
-               if (intel_idle_max_cstate_reached(cstate))
+               if (intel_idle_max_cstate_reached(cstate - 1))
                        break;
 
                cx = &acpi_state_table.states[cstate];
index 7c2ab1f2fbea3785d445f06a2d463330de59a231..a77750b8954db039ebeb2f040e7a028fb011da16 100644 (file)
@@ -405,10 +405,10 @@ static int cma_comp_exch(struct rdma_id_private *id_priv,
        /*
         * The FSM uses a funny double locking where state is protected by both
         * the handler_mutex and the spinlock. State is not allowed to change
-        * away from a handler_mutex protected value without also holding
+        * to/from a handler_mutex protected value without also holding
         * handler_mutex.
         */
-       if (comp == RDMA_CM_CONNECT)
+       if (comp == RDMA_CM_CONNECT || exch == RDMA_CM_CONNECT)
                lockdep_assert_held(&id_priv->handler_mutex);
 
        spin_lock_irqsave(&id_priv->lock, flags);
@@ -4038,17 +4038,23 @@ out:
        return ret;
 }
 
-int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+/**
+ * rdma_connect_locked - Initiate an active connection request.
+ * @id: Connection identifier to connect.
+ * @conn_param: Connection information used for connected QPs.
+ *
+ * Same as rdma_connect() but can only be called from the
+ * RDMA_CM_EVENT_ROUTE_RESOLVED handler callback.
+ */
+int rdma_connect_locked(struct rdma_cm_id *id,
+                       struct rdma_conn_param *conn_param)
 {
        struct rdma_id_private *id_priv =
                container_of(id, struct rdma_id_private, id);
        int ret;
 
-       mutex_lock(&id_priv->handler_mutex);
-       if (!cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_CONNECT)) {
-               ret = -EINVAL;
-               goto err_unlock;
-       }
+       if (!cma_comp_exch(id_priv, RDMA_CM_ROUTE_RESOLVED, RDMA_CM_CONNECT))
+               return -EINVAL;
 
        if (!id->qp) {
                id_priv->qp_num = conn_param->qp_num;
@@ -4066,11 +4072,33 @@ int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
                ret = -ENOSYS;
        if (ret)
                goto err_state;
-       mutex_unlock(&id_priv->handler_mutex);
        return 0;
 err_state:
        cma_comp_exch(id_priv, RDMA_CM_CONNECT, RDMA_CM_ROUTE_RESOLVED);
-err_unlock:
+       return ret;
+}
+EXPORT_SYMBOL(rdma_connect_locked);
+
+/**
+ * rdma_connect - Initiate an active connection request.
+ * @id: Connection identifier to connect.
+ * @conn_param: Connection information used for connected QPs.
+ *
+ * Users must have resolved a route for the rdma_cm_id to connect with by having
+ * called rdma_resolve_route before calling this routine.
+ *
+ * This call will either connect to a remote QP or obtain remote QP information
+ * for unconnected rdma_cm_id's.  The actual operation is based on the
+ * rdma_cm_id's port space.
+ */
+int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param)
+{
+       struct rdma_id_private *id_priv =
+               container_of(id, struct rdma_id_private, id);
+       int ret;
+
+       mutex_lock(&id_priv->handler_mutex);
+       ret = rdma_connect_locked(id, conn_param);
        mutex_unlock(&id_priv->handler_mutex);
        return ret;
 }
index f367d523a46b81d0ff94cb7444d66e5d04dc6439..302f898c5833fce490c052fb5eb2450a703848fe 100644 (file)
@@ -401,9 +401,6 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_GID_ENTRY)(
        if (!rdma_is_port_valid(ib_dev, port_num))
                return -EINVAL;
 
-       if (!rdma_ib_or_roce(ib_dev, port_num))
-               return -EOPNOTSUPP;
-
        gid_attr = rdma_get_gid_attr(ib_dev, port_num, gid_index);
        if (IS_ERR(gid_attr))
                return PTR_ERR(gid_attr);
index 89e04ca62ae0fa4965cdaba51dd7fb68a76a3012..246e3cbe0b2c7c84ef7fe83b52c256bd5a1e714f 100644 (file)
@@ -3305,7 +3305,8 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
        int err;
 
        dev->port[port_num].roce.nb.notifier_call = mlx5_netdev_event;
-       err = register_netdevice_notifier(&dev->port[port_num].roce.nb);
+       err = register_netdevice_notifier_net(mlx5_core_net(dev->mdev),
+                                             &dev->port[port_num].roce.nb);
        if (err) {
                dev->port[port_num].roce.nb.notifier_call = NULL;
                return err;
@@ -3317,7 +3318,8 @@ static int mlx5_add_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
 static void mlx5_remove_netdev_notifier(struct mlx5_ib_dev *dev, u8 port_num)
 {
        if (dev->port[port_num].roce.nb.notifier_call) {
-               unregister_netdevice_notifier(&dev->port[port_num].roce.nb);
+               unregister_netdevice_notifier_net(mlx5_core_net(dev->mdev),
+                                                 &dev->port[port_num].roce.nb);
                dev->port[port_num].roce.nb.notifier_call = NULL;
        }
 }
index c7169d2c69e5b0438816a491458be80a7593f5d8..c4bc58736e489ecfdf58cf629830c795cca441d2 100644 (file)
@@ -727,6 +727,7 @@ int qedr_iw_destroy_listen(struct iw_cm_id *cm_id)
                                                    listener->qed_handle);
 
        cm_id->rem_ref(cm_id);
+       kfree(listener);
        return rc;
 }
 
index f0e5ffba2d51d1544cf928011f2e64497c69657a..97ed8f952f6e94c750083333f4f17dfc03e764a0 100644 (file)
@@ -176,7 +176,7 @@ struct pvrdma_port_attr {
        u8                      subnet_timeout;
        u8                      init_type_reply;
        u8                      active_width;
-       u16                     active_speed;
+       u                     active_speed;
        u8                      phys_state;
        u8                      reserved[2];
 };
index 52218684ad4ab0f77ceb0d1bc4a0c2e81a550c8b..670a9623b46e1169fc978d74ea47236389474a56 100644 (file)
@@ -524,6 +524,7 @@ static noinline int check_support(struct rvt_dev_info *rdi, int verb)
 int rvt_register_device(struct rvt_dev_info *rdi)
 {
        int ret = 0, i;
+       u64 dma_mask;
 
        if (!rdi)
                return -EINVAL;
@@ -580,8 +581,10 @@ int rvt_register_device(struct rvt_dev_info *rdi)
 
        /* DMA Operations */
        rdi->ibdev.dev.dma_parms = rdi->ibdev.dev.parent->dma_parms;
-       dma_set_coherent_mask(&rdi->ibdev.dev,
-                             rdi->ibdev.dev.parent->coherent_dma_mask);
+       dma_mask = IS_ENABLED(CONFIG_64BIT) ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
+       ret = dma_coerce_mask_and_coherent(&rdi->ibdev.dev, dma_mask);
+       if (ret)
+               goto bail_wss;
 
        /* Protection Domain */
        spin_lock_init(&rdi->n_pds_lock);
index 38021e2c868811dcd8cef2c8b2223f061beefc62..df0d173d6acba6c8c8d461f4cb1d6b54918c15f0 100644 (file)
@@ -16,15 +16,24 @@ void rxe_init_av(struct rdma_ah_attr *attr, struct rxe_av *av)
 
 int rxe_av_chk_attr(struct rxe_dev *rxe, struct rdma_ah_attr *attr)
 {
+       const struct ib_global_route *grh = rdma_ah_read_grh(attr);
        struct rxe_port *port;
+       int type;
 
        port = &rxe->port;
 
        if (rdma_ah_get_ah_flags(attr) & IB_AH_GRH) {
-               u8 sgid_index = rdma_ah_read_grh(attr)->sgid_index;
+               if (grh->sgid_index > port->attr.gid_tbl_len) {
+                       pr_warn("invalid sgid index = %d\n",
+                                       grh->sgid_index);
+                       return -EINVAL;
+               }
 
-               if (sgid_index > port->attr.gid_tbl_len) {
-                       pr_warn("invalid sgid index = %d\n", sgid_index);
+               type = rdma_gid_attr_network_type(grh->sgid_attr);
+               if (type < RDMA_NETWORK_IPV4 ||
+                   type > RDMA_NETWORK_IPV6) {
+                       pr_warn("invalid network type for rdma_rxe = %d\n",
+                                       type);
                        return -EINVAL;
                }
        }
@@ -65,11 +74,29 @@ void rxe_av_to_attr(struct rxe_av *av, struct rdma_ah_attr *attr)
 void rxe_av_fill_ip_info(struct rxe_av *av, struct rdma_ah_attr *attr)
 {
        const struct ib_gid_attr *sgid_attr = attr->grh.sgid_attr;
+       int ibtype;
+       int type;
 
        rdma_gid2ip((struct sockaddr *)&av->sgid_addr, &sgid_attr->gid);
        rdma_gid2ip((struct sockaddr *)&av->dgid_addr,
                    &rdma_ah_read_grh(attr)->dgid);
-       av->network_type = rdma_gid_attr_network_type(sgid_attr);
+
+       ibtype = rdma_gid_attr_network_type(sgid_attr);
+
+       switch (ibtype) {
+       case RDMA_NETWORK_IPV4:
+               type = RXE_NETWORK_TYPE_IPV4;
+               break;
+       case RDMA_NETWORK_IPV6:
+               type = RXE_NETWORK_TYPE_IPV4;
+               break;
+       default:
+               /* not reached - checked in rxe_av_chk_attr */
+               type = 0;
+               break;
+       }
+
+       av->network_type = type;
 }
 
 struct rxe_av *rxe_get_av(struct rxe_pkt_info *pkt)
index 575e1a4ec82121272c7821932f220d744ddf0b91..34bef7d8e6b41b4845a3de5b165726b7dc150779 100644 (file)
@@ -442,7 +442,7 @@ struct sk_buff *rxe_init_packet(struct rxe_dev *rxe, struct rxe_av *av,
        if (IS_ERR(attr))
                return NULL;
 
-       if (av->network_type == RXE_NETWORK_TYPE_IPV6)
+       if (av->network_type == RXE_NETWORK_TYPE_IPV4)
                hdr_len = ETH_HLEN + sizeof(struct udphdr) +
                        sizeof(struct iphdr);
        else
index 1fc022362fbe4973298623e164a4394f03a93378..f9c832e82552f9259d4926d02225458222e0f4cb 100644 (file)
@@ -1118,6 +1118,7 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
        int err;
        struct ib_device *dev = &rxe->ib_dev;
        struct crypto_shash *tfm;
+       u64 dma_mask;
 
        strlcpy(dev->node_desc, "rxe", sizeof(dev->node_desc));
 
@@ -1130,7 +1131,10 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)
                            rxe->ndev->dev_addr);
        dev->dev.dma_parms = &rxe->dma_parms;
        dma_set_max_seg_size(&dev->dev, UINT_MAX);
-       dma_set_coherent_mask(&dev->dev, dma_get_required_mask(&dev->dev));
+       dma_mask = IS_ENABLED(CONFIG_64BIT) ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
+       err = dma_coerce_mask_and_coherent(&dev->dev, dma_mask);
+       if (err)
+               return err;
 
        dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT)
            | BIT_ULL(IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL)
index ca8bc72968672f7cbcc3563db5db47fcaf3dc28f..181e06c1c43d7eb080c06246215bb32186575895 100644 (file)
@@ -306,6 +306,7 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
        struct siw_device *sdev = NULL;
        struct ib_device *base_dev;
        struct device *parent = netdev->dev.parent;
+       u64 dma_mask;
        int rv;
 
        if (!parent) {
@@ -384,8 +385,10 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
        base_dev->dev.parent = parent;
        base_dev->dev.dma_parms = &sdev->dma_parms;
        dma_set_max_seg_size(&base_dev->dev, UINT_MAX);
-       dma_set_coherent_mask(&base_dev->dev,
-                             dma_get_required_mask(&base_dev->dev));
+       dma_mask = IS_ENABLED(CONFIG_64BIT) ? DMA_BIT_MASK(64) : DMA_BIT_MASK(32);
+       if (dma_coerce_mask_and_coherent(&base_dev->dev, dma_mask))
+               goto error;
+
        base_dev->num_comp_vectors = num_possible_cpus();
 
        xa_init_flags(&sdev->qp_xa, XA_FLAGS_ALLOC1);
index 2f3ebc0a75d92466456ab8948b50e723ab45f870..2bd18b0068934145de9440665eb80a438dc11a5a 100644 (file)
@@ -620,7 +620,7 @@ static void iser_route_handler(struct rdma_cm_id *cma_id)
        conn_param.private_data = (void *)&req_hdr;
        conn_param.private_data_len = sizeof(struct iser_cm_hdr);
 
-       ret = rdma_connect(cma_id, &conn_param);
+       ret = rdma_connect_locked(cma_id, &conn_param);
        if (ret) {
                iser_err("failure connecting: %d\n", ret);
                goto failure;
index 776e89231c52f77a5096d46b2286c0f2377e2458..f298adc02acba2e7fbe24bf1da40d47b0edc7453 100644 (file)
@@ -1674,9 +1674,9 @@ static int rtrs_rdma_route_resolved(struct rtrs_clt_con *con)
        uuid_copy(&msg.sess_uuid, &sess->s.uuid);
        uuid_copy(&msg.paths_uuid, &clt->paths_uuid);
 
-       err = rdma_connect(con->c.cm_id, &param);
+       err = rdma_connect_locked(con->c.cm_id, &param);
        if (err)
-               rtrs_err(clt, "rdma_connect(): %d\n", err);
+               rtrs_err(clt, "rdma_connect_locked(): %d\n", err);
 
        return err;
 }
index 0065eb17ae36b49ebb9097cee09ff7688f3fbf8c..53a8becac82761f80860fdb9eb4b057cccaa2767 100644 (file)
@@ -622,10 +622,11 @@ static int srpt_refresh_port(struct srpt_port *sport)
 /**
  * srpt_unregister_mad_agent - unregister MAD callback functions
  * @sdev: SRPT HCA pointer.
+ * @port_cnt: number of ports with registered MAD
  *
  * Note: It is safe to call this function more than once for the same device.
  */
-static void srpt_unregister_mad_agent(struct srpt_device *sdev)
+static void srpt_unregister_mad_agent(struct srpt_device *sdev, int port_cnt)
 {
        struct ib_port_modify port_modify = {
                .clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP,
@@ -633,7 +634,7 @@ static void srpt_unregister_mad_agent(struct srpt_device *sdev)
        struct srpt_port *sport;
        int i;
 
-       for (i = 1; i <= sdev->device->phys_port_cnt; i++) {
+       for (i = 1; i <= port_cnt; i++) {
                sport = &sdev->port[i - 1];
                WARN_ON(sport->port != i);
                if (sport->mad_agent) {
@@ -3185,7 +3186,8 @@ static int srpt_add_one(struct ib_device *device)
                if (ret) {
                        pr_err("MAD registration failed for %s-%d.\n",
                               dev_name(&sdev->device->dev), i);
-                       goto err_event;
+                       i--;
+                       goto err_port;
                }
        }
 
@@ -3197,7 +3199,8 @@ static int srpt_add_one(struct ib_device *device)
        pr_debug("added %s.\n", dev_name(&device->dev));
        return 0;
 
-err_event:
+err_port:
+       srpt_unregister_mad_agent(sdev, i);
        ib_unregister_event_handler(&sdev->event_handler);
 err_cm:
        if (sdev->cm_id)
@@ -3221,7 +3224,7 @@ static void srpt_remove_one(struct ib_device *device, void *client_data)
        struct srpt_device *sdev = client_data;
        int i;
 
-       srpt_unregister_mad_agent(sdev);
+       srpt_unregister_mad_agent(sdev, sdev->device->phys_port_cnt);
 
        ib_unregister_event_handler(&sdev->event_handler);
 
index 41435a699b53e81b5bb7daa860b8c6f62c4c0316..bdeb010efee680a3e160f862344a3e1e81c59801 100644 (file)
@@ -256,6 +256,7 @@ enum rdma_ch_state {
  * @rdma_cm:      See below.
  * @rdma_cm.cm_id: RDMA CM ID associated with the channel.
  * @cq:            IB completion queue for this channel.
+ * @cq_size:      Number of CQEs in @cq.
  * @zw_cqe:       Zero-length write CQE.
  * @rcu:           RCU head.
  * @kref:         kref for this channel.
index eea47b4c84aa779e23a663eb1e6c7ec0f3a8246f..974a66725d094f4700f1e362d2afb50c941ae666 100644 (file)
@@ -971,6 +971,9 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider)
        }
        node->avg_bw = node->init_avg;
        node->peak_bw = node->init_peak;
+       if (provider->aggregate)
+               provider->aggregate(node, 0, node->init_avg, node->init_peak,
+                                   &node->avg_bw, &node->peak_bw);
        provider->set(node, node);
        node->avg_bw = 0;
        node->peak_bw = 0;
index cf10a4b9611bc31bf592f0e0c3aba4dcfbeabe30..bf01d09dba6c43c563c6c2360c8a177a07513ab8 100644 (file)
@@ -79,6 +79,7 @@ EXPORT_SYMBOL_GPL(qcom_icc_aggregate);
 int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
 {
        struct qcom_icc_provider *qp;
+       struct qcom_icc_node *qn;
        struct icc_node *node;
 
        if (!src)
@@ -87,6 +88,12 @@ int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
                node = src;
 
        qp = to_qcom_provider(node->provider);
+       qn = node->data;
+
+       qn->sum_avg[QCOM_ICC_BUCKET_AMC] = max_t(u64, qn->sum_avg[QCOM_ICC_BUCKET_AMC],
+                                                node->avg_bw);
+       qn->max_peak[QCOM_ICC_BUCKET_AMC] = max_t(u64, qn->max_peak[QCOM_ICC_BUCKET_AMC],
+                                                 node->peak_bw);
 
        qcom_icc_bcm_voter_commit(qp->voter);
 
index bf11b82ed55cf8a521b384c57f0318c8f219bf76..8d9044ed18ab9efbd25f4a49922abdd587e41879 100644 (file)
@@ -553,6 +553,9 @@ static int qnoc_probe(struct platform_device *pdev)
                return ret;
        }
 
+       for (i = 0; i < qp->num_bcms; i++)
+               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
+
        for (i = 0; i < num_nodes; i++) {
                size_t j;
 
@@ -576,9 +579,6 @@ static int qnoc_probe(struct platform_device *pdev)
        }
        data->num_nodes = num_nodes;
 
-       for (i = 0; i < qp->num_bcms; i++)
-               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
-
        platform_set_drvdata(pdev, qp);
 
        return 0;
index d79e3163e2c38b5ade1949066861e3a05fef2ab8..5304aea3b05850cdb986174fe85d9abb9fc2444f 100644 (file)
@@ -151,7 +151,7 @@ DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi);
 DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc);
 DEFINE_QBCM(bcm_mm0, "MM0", false, &qns_mem_noc_hf);
 DEFINE_QBCM(bcm_sh1, "SH1", false, &qns_apps_io);
-DEFINE_QBCM(bcm_mm1, "MM1", false, &qxm_camnoc_hf0_uncomp, &qxm_camnoc_hf1_uncomp, &qxm_camnoc_sf_uncomp, &qxm_camnoc_hf0, &qxm_camnoc_hf1, &qxm_mdp0, &qxm_mdp1);
+DEFINE_QBCM(bcm_mm1, "MM1", true, &qxm_camnoc_hf0_uncomp, &qxm_camnoc_hf1_uncomp, &qxm_camnoc_sf_uncomp, &qxm_camnoc_hf0, &qxm_camnoc_hf1, &qxm_mdp0, &qxm_mdp1);
 DEFINE_QBCM(bcm_sh2, "SH2", false, &qns_memnoc_snoc);
 DEFINE_QBCM(bcm_mm2, "MM2", false, &qns2_mem_noc);
 DEFINE_QBCM(bcm_sh3, "SH3", false, &acm_tcu);
@@ -489,6 +489,9 @@ static int qnoc_probe(struct platform_device *pdev)
                return ret;
        }
 
+       for (i = 0; i < qp->num_bcms; i++)
+               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
+
        for (i = 0; i < num_nodes; i++) {
                size_t j;
 
@@ -512,9 +515,6 @@ static int qnoc_probe(struct platform_device *pdev)
        }
        data->num_nodes = num_nodes;
 
-       for (i = 0; i < qp->num_bcms; i++)
-               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
-
        platform_set_drvdata(pdev, qp);
 
        return 0;
index 9218efed04a072235e992ec572e2f884980d6bce..c76b2c7f9b106dad1a2807bacbbbf939531de873 100644 (file)
@@ -551,6 +551,9 @@ static int qnoc_probe(struct platform_device *pdev)
                return ret;
        }
 
+       for (i = 0; i < qp->num_bcms; i++)
+               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
+
        for (i = 0; i < num_nodes; i++) {
                size_t j;
 
@@ -574,9 +577,6 @@ static int qnoc_probe(struct platform_device *pdev)
        }
        data->num_nodes = num_nodes;
 
-       for (i = 0; i < qp->num_bcms; i++)
-               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
-
        platform_set_drvdata(pdev, qp);
 
        return 0;
@@ -627,6 +627,7 @@ static struct platform_driver qnoc_driver = {
        .driver = {
                .name = "qnoc-sm8150",
                .of_match_table = qnoc_of_match,
+               .sync_state = icc_sync_state,
        },
 };
 module_platform_driver(qnoc_driver);
index 9b58946f789837b654f7cad7ad747afc7493d3b6..cc558fec74e38780de5d42b75ca412cee7a9bb7b 100644 (file)
@@ -567,6 +567,9 @@ static int qnoc_probe(struct platform_device *pdev)
                return ret;
        }
 
+       for (i = 0; i < qp->num_bcms; i++)
+               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
+
        for (i = 0; i < num_nodes; i++) {
                size_t j;
 
@@ -590,9 +593,6 @@ static int qnoc_probe(struct platform_device *pdev)
        }
        data->num_nodes = num_nodes;
 
-       for (i = 0; i < qp->num_bcms; i++)
-               qcom_icc_bcm_init(qp->bcms[i], &pdev->dev);
-
        platform_set_drvdata(pdev, qp);
 
        return 0;
@@ -643,6 +643,7 @@ static struct platform_driver qnoc_driver = {
        .driver = {
                .name = "qnoc-sm8250",
                .of_match_table = qnoc_of_match,
+               .sync_state = icc_sync_state,
        },
 };
 module_platform_driver(qnoc_driver);
index f696ac7c5f8931251dd0c052ddff26278d250c7e..89647700bab2dc4e20c85017e82d2ebd4f5dc208 100644 (file)
@@ -409,7 +409,11 @@ extern bool amd_iommu_np_cache;
 /* Only true if all IOMMUs support device IOTLBs */
 extern bool amd_iommu_iotlb_sup;
 
-#define MAX_IRQS_PER_TABLE     256
+/*
+ * AMD IOMMU hardware only support 512 IRTEs despite
+ * the architectural limitation of 2048 entries.
+ */
+#define MAX_IRQS_PER_TABLE     512
 #define IRQ_TABLE_ALIGNMENT    128
 
 struct irq_remap_table {
index 8651f6d4dfa032c00f9c2149ae643a3614960fb7..1b1ca63e6bbee759f91914ad4c59c80127b19331 100644 (file)
@@ -2525,6 +2525,9 @@ struct dmar_domain *find_domain(struct device *dev)
 {
        struct device_domain_info *info;
 
+       if (unlikely(!dev || !dev->iommu))
+               return NULL;
+
        if (unlikely(attach_deferred(dev)))
                return NULL;
 
index f1861fa3d0e4a4091454938ba788bd33c12cc285..3242ebd0bca36a766f5bd92b02dc46f89efe7093 100644 (file)
@@ -279,6 +279,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
        struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL);
        struct intel_svm_dev *sdev = NULL;
        struct dmar_domain *dmar_domain;
+       struct device_domain_info *info;
        struct intel_svm *svm = NULL;
        int ret = 0;
 
@@ -310,6 +311,10 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
        if (data->hpasid <= 0 || data->hpasid >= PASID_MAX)
                return -EINVAL;
 
+       info = get_domain_info(dev);
+       if (!info)
+               return -EINVAL;
+
        dmar_domain = to_dmar_domain(domain);
 
        mutex_lock(&pasid_mutex);
@@ -357,6 +362,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,
                goto out;
        }
        sdev->dev = dev;
+       sdev->sid = PCI_DEVID(info->bus, info->devfn);
 
        /* Only count users if device has aux domains */
        if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))
@@ -1029,7 +1035,7 @@ no_pasid:
                        resp.qw0 = QI_PGRP_PASID(req->pasid) |
                                QI_PGRP_DID(req->rid) |
                                QI_PGRP_PASID_P(req->pasid_present) |
-                               QI_PGRP_PDP(req->pasid_present) |
+                               QI_PGRP_PDP(req->priv_data_present) |
                                QI_PGRP_RESP_CODE(result) |
                                QI_PGRP_RESP_TYPE;
                        resp.qw1 = QI_PGRP_IDX(req->prg_index) |
index 8c470f451a323e590293309c0331af3db10bebaf..b53446bb8c6b4e7970f494fe4dc52d76bb1e07cc 100644 (file)
@@ -2071,7 +2071,7 @@ EXPORT_SYMBOL_GPL(iommu_uapi_cache_invalidate);
 
 static int iommu_check_bind_data(struct iommu_gpasid_bind_data *data)
 {
-       u32 mask;
+       u64 mask;
        int i;
 
        if (data->version != IOMMU_GPASID_BIND_VERSION_1)
index c6098eee0c7cf217f83153ad406e63bd35426b27..2aa79c32ee228d530945b68b49f8f23372eb7043 100644 (file)
@@ -180,7 +180,6 @@ config IRQ_MIPS_CPU
        select GENERIC_IRQ_CHIP
        select GENERIC_IRQ_IPI if SYS_SUPPORTS_MULTITHREADING
        select IRQ_DOMAIN
-       select IRQ_DOMAIN_HIERARCHY if GENERIC_IRQ_IPI
        select GENERIC_IRQ_EFFECTIVE_AFF_MASK
 
 config CLPS711X_IRQCHIP
@@ -315,7 +314,6 @@ config KEYSTONE_IRQ
 config MIPS_GIC
        bool
        select GENERIC_IRQ_IPI
-       select IRQ_DOMAIN_HIERARCHY
        select MIPS_CM
 
 config INGENIC_IRQ
@@ -591,6 +589,7 @@ config LOONGSON_PCH_MSI
 
 config MST_IRQ
        bool "MStar Interrupt Controller"
+       depends on ARCH_MEDIATEK || ARCH_MSTARV7 || COMPILE_TEST
        default ARCH_MEDIATEK
        select IRQ_DOMAIN
        select IRQ_DOMAIN_HIERARCHY
index 97838eb705f9339aa3790bb46e44d2a4f682f2bf..cbc7c740e4dc39f1740df68f6b0e031d512e8d2b 100644 (file)
@@ -244,7 +244,7 @@ static int bcm2836_cpu_dying(unsigned int cpu)
 
 #define BITS_PER_MBOX  32
 
-static void bcm2836_arm_irqchip_smp_init(void)
+static void __init bcm2836_arm_irqchip_smp_init(void)
 {
        struct irq_fwspec ipi_fwspec = {
                .fwnode         = intc.domain->fwnode,
index 4be0775918981a3cb4c249c3601f5ac69ee617fa..143657b0cf281aa57b0876d1c167a536ff419d7e 100644 (file)
@@ -154,8 +154,8 @@ static const struct irq_domain_ops mst_intc_domain_ops = {
        .free           = irq_domain_free_irqs_common,
 };
 
-int __init
-mst_intc_of_init(struct device_node *dn, struct device_node *parent)
+static int __init mst_intc_of_init(struct device_node *dn,
+                                  struct device_node *parent)
 {
        struct irq_domain *domain, *domain_parent;
        struct mst_intc_chip_data *cd;
index 3819185bfd02c63f6f0a2abbd7bb8ee60b5f291a..cb7f60b3b4a920c2aef276d3eff817bc52d22ba3 100644 (file)
@@ -71,8 +71,7 @@ struct intc_irqpin_priv {
 };
 
 struct intc_irqpin_config {
-       unsigned int irlm_bit;
-       unsigned needs_irlm:1;
+       int irlm_bit;           /* -1 if non-existent */
 };
 
 static unsigned long intc_irqpin_read32(void __iomem *iomem)
@@ -349,11 +348,10 @@ static const struct irq_domain_ops intc_irqpin_irq_domain_ops = {
 
 static const struct intc_irqpin_config intc_irqpin_irlm_r8a777x = {
        .irlm_bit = 23, /* ICR0.IRLM0 */
-       .needs_irlm = 1,
 };
 
 static const struct intc_irqpin_config intc_irqpin_rmobile = {
-       .needs_irlm = 0,
+       .irlm_bit = -1,
 };
 
 static const struct of_device_id intc_irqpin_dt_ids[] = {
@@ -470,7 +468,7 @@ static int intc_irqpin_probe(struct platform_device *pdev)
        }
 
        /* configure "individual IRQ mode" where needed */
-       if (config && config->needs_irlm) {
+       if (config && config->irlm_bit >= 0) {
                if (io[INTC_IRQPIN_REG_IRLM])
                        intc_irqpin_read_modify_write(p, INTC_IRQPIN_REG_IRLM,
                                                      config->irlm_bit, 1, 1);
index eaa3e9fe54e918d85429696a9a2a30bc8249e4e0..6f432d2a5cebdc388f5c7d88e1c807f4d83fc28f 100644 (file)
@@ -99,7 +99,7 @@ static inline void plic_irq_toggle(const struct cpumask *mask,
                                   struct irq_data *d, int enable)
 {
        int cpu;
-       struct plic_priv *priv = irq_get_chip_data(d->irq);
+       struct plic_priv *priv = irq_data_get_irq_chip_data(d);
 
        writel(enable, priv->regs + PRIORITY_BASE + d->hwirq * PRIORITY_PER_ID);
        for_each_cpu(cpu, mask) {
@@ -115,7 +115,7 @@ static void plic_irq_unmask(struct irq_data *d)
 {
        struct cpumask amask;
        unsigned int cpu;
-       struct plic_priv *priv = irq_get_chip_data(d->irq);
+       struct plic_priv *priv = irq_data_get_irq_chip_data(d);
 
        cpumask_and(&amask, &priv->lmask, cpu_online_mask);
        cpu = cpumask_any_and(irq_data_get_affinity_mask(d),
@@ -127,7 +127,7 @@ static void plic_irq_unmask(struct irq_data *d)
 
 static void plic_irq_mask(struct irq_data *d)
 {
-       struct plic_priv *priv = irq_get_chip_data(d->irq);
+       struct plic_priv *priv = irq_data_get_irq_chip_data(d);
 
        plic_irq_toggle(&priv->lmask, d, 0);
 }
@@ -138,7 +138,7 @@ static int plic_set_affinity(struct irq_data *d,
 {
        unsigned int cpu;
        struct cpumask amask;
-       struct plic_priv *priv = irq_get_chip_data(d->irq);
+       struct plic_priv *priv = irq_data_get_irq_chip_data(d);
 
        cpumask_and(&amask, &priv->lmask, mask_val);
 
@@ -151,7 +151,7 @@ static int plic_set_affinity(struct irq_data *d,
                return -EINVAL;
 
        plic_irq_toggle(&priv->lmask, d, 0);
-       plic_irq_toggle(cpumask_of(cpu), d, 1);
+       plic_irq_toggle(cpumask_of(cpu), d, !irqd_irq_masked(d));
 
        irq_data_update_effective_affinity(d, cpumask_of(cpu));
 
index 0c2c61db26b45dfaf1bb995c89e9cdcdeb276431..8662d7b7b2625af83c70235569e8f5da6e603d5e 100644 (file)
@@ -195,6 +195,10 @@ static const struct stm32_desc_irq stm32mp1_desc_irq[] = {
        { .exti = 25, .irq_parent = 107, .chip = &stm32_exti_h_chip_direct },
        { .exti = 30, .irq_parent = 52, .chip = &stm32_exti_h_chip_direct },
        { .exti = 47, .irq_parent = 93, .chip = &stm32_exti_h_chip_direct },
+       { .exti = 48, .irq_parent = 138, .chip = &stm32_exti_h_chip_direct },
+       { .exti = 50, .irq_parent = 139, .chip = &stm32_exti_h_chip_direct },
+       { .exti = 52, .irq_parent = 140, .chip = &stm32_exti_h_chip_direct },
+       { .exti = 53, .irq_parent = 141, .chip = &stm32_exti_h_chip_direct },
        { .exti = 54, .irq_parent = 135, .chip = &stm32_exti_h_chip_direct },
        { .exti = 61, .irq_parent = 100, .chip = &stm32_exti_h_chip_direct },
        { .exti = 65, .irq_parent = 144, .chip = &stm32_exti_h_chip },
index e0cceb81c6486bbf0cc2225fde3147bd05fb7be2..b2ab8db439d928b1ff73e40d7c782a9d357fc8f7 100644 (file)
@@ -85,6 +85,17 @@ struct ti_sci_inta_vint_desc {
  * @base:              Base address of the memory mapped IO registers
  * @pdev:              Pointer to platform device.
  * @ti_sci_id:         TI-SCI device identifier
+ * @unmapped_cnt:      Number of @unmapped_dev_ids entries
+ * @unmapped_dev_ids:  Pointer to an array of TI-SCI device identifiers of
+ *                     unmapped event sources.
+ *                     Unmapped Events are not part of the Global Event Map and
+ *                     they are converted to Global event within INTA to be
+ *                     received by the same INTA to generate an interrupt.
+ *                     In case an interrupt request comes for a device which is
+ *                     generating Unmapped Event, we must use the INTA's TI-SCI
+ *                     device identifier in place of the source device
+ *                     identifier to let sysfw know where it has to program the
+ *                     Global Event number.
  */
 struct ti_sci_inta_irq_domain {
        const struct ti_sci_handle *sci;
@@ -96,11 +107,37 @@ struct ti_sci_inta_irq_domain {
        void __iomem *base;
        struct platform_device *pdev;
        u32 ti_sci_id;
+
+       int unmapped_cnt;
+       u16 *unmapped_dev_ids;
 };
 
 #define to_vint_desc(e, i) container_of(e, struct ti_sci_inta_vint_desc, \
                                        events[i])
 
+static u16 ti_sci_inta_get_dev_id(struct ti_sci_inta_irq_domain *inta, u32 hwirq)
+{
+       u16 dev_id = HWIRQ_TO_DEVID(hwirq);
+       int i;
+
+       if (inta->unmapped_cnt == 0)
+               return dev_id;
+
+       /*
+        * For devices sending Unmapped Events we must use the INTA's TI-SCI
+        * device identifier number to be able to convert it to a Global Event
+        * and map it to an interrupt.
+        */
+       for (i = 0; i < inta->unmapped_cnt; i++) {
+               if (dev_id == inta->unmapped_dev_ids[i]) {
+                       dev_id = inta->ti_sci_id;
+                       break;
+               }
+       }
+
+       return dev_id;
+}
+
 /**
  * ti_sci_inta_irq_handler() - Chained IRQ handler for the vint irqs
  * @desc:      Pointer to irq_desc corresponding to the irq
@@ -251,7 +288,7 @@ static struct ti_sci_inta_event_desc *ti_sci_inta_alloc_event(struct ti_sci_inta
        u16 dev_id, dev_index;
        int err;
 
-       dev_id = HWIRQ_TO_DEVID(hwirq);
+       dev_id = ti_sci_inta_get_dev_id(inta, hwirq);
        dev_index = HWIRQ_TO_IRQID(hwirq);
 
        event_desc = &vint_desc->events[free_bit];
@@ -352,14 +389,15 @@ static void ti_sci_inta_free_irq(struct ti_sci_inta_event_desc *event_desc,
 {
        struct ti_sci_inta_vint_desc *vint_desc;
        struct ti_sci_inta_irq_domain *inta;
+       u16 dev_id;
 
        vint_desc = to_vint_desc(event_desc, event_desc->vint_bit);
        inta = vint_desc->domain->host_data;
+       dev_id = ti_sci_inta_get_dev_id(inta, hwirq);
        /* free event irq */
        mutex_lock(&inta->vint_mutex);
        inta->sci->ops.rm_irq_ops.free_event_map(inta->sci,
-                                                HWIRQ_TO_DEVID(hwirq),
-                                                HWIRQ_TO_IRQID(hwirq),
+                                                dev_id, HWIRQ_TO_IRQID(hwirq),
                                                 inta->ti_sci_id,
                                                 vint_desc->vint_id,
                                                 event_desc->global_event,
@@ -574,6 +612,41 @@ static struct msi_domain_info ti_sci_inta_msi_domain_info = {
        .chip   = &ti_sci_inta_msi_irq_chip,
 };
 
+static int ti_sci_inta_get_unmapped_sources(struct ti_sci_inta_irq_domain *inta)
+{
+       struct device *dev = &inta->pdev->dev;
+       struct device_node *node = dev_of_node(dev);
+       struct of_phandle_iterator it;
+       int count, err, ret, i;
+
+       count = of_count_phandle_with_args(node, "ti,unmapped-event-sources", NULL);
+       if (count <= 0)
+               return 0;
+
+       inta->unmapped_dev_ids = devm_kcalloc(dev, count,
+                                             sizeof(*inta->unmapped_dev_ids),
+                                             GFP_KERNEL);
+       if (!inta->unmapped_dev_ids)
+               return -ENOMEM;
+
+       i = 0;
+       of_for_each_phandle(&it, err, node, "ti,unmapped-event-sources", NULL, 0) {
+               u32 dev_id;
+
+               ret = of_property_read_u32(it.node, "ti,sci-dev-id", &dev_id);
+               if (ret) {
+                       dev_err(dev, "ti,sci-dev-id read failure for %pOFf\n", it.node);
+                       of_node_put(it.node);
+                       return ret;
+               }
+               inta->unmapped_dev_ids[i++] = dev_id;
+       }
+
+       inta->unmapped_cnt = count;
+
+       return 0;
+}
+
 static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
 {
        struct irq_domain *parent_domain, *domain, *msi_domain;
@@ -629,6 +702,10 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
        if (IS_ERR(inta->base))
                return PTR_ERR(inta->base);
 
+       ret = ti_sci_inta_get_unmapped_sources(inta);
+       if (ret)
+               return ret;
+
        domain = irq_domain_add_linear(dev_of_node(dev),
                                       ti_sci_get_num_resources(inta->vint),
                                       &ti_sci_inta_irq_domain_ops, inta);
index a5ef9faf71c7d4f5a03ba7487ceb6c2d27198517..e7f0d4ae0f9601cbddc68d5667572b6ef4ca769b 100644 (file)
@@ -1176,8 +1176,10 @@ mptscsih_remove(struct pci_dev *pdev)
        MPT_SCSI_HOST           *hd;
        int sz1;
 
-       if((hd = shost_priv(host)) == NULL)
-               return;
+       if (host == NULL)
+               hd = NULL;
+       else
+               hd = shost_priv(host);
 
        mptscsih_shutdown(pdev);
 
@@ -1193,14 +1195,15 @@ mptscsih_remove(struct pci_dev *pdev)
            "Free'd ScsiLookup (%d) memory\n",
            ioc->name, sz1));
 
-       kfree(hd->info_kbuf);
+       if (hd)
+               kfree(hd->info_kbuf);
 
        /* NULL the Scsi_Host pointer
         */
        ioc->sh = NULL;
 
-       scsi_host_put(host);
-
+       if (host)
+               scsi_host_put(host);
        mpt_detach(pdev);
 
 }
index d5ce8082b0a0ac28a35310fb1a2705d586428d99..fafa8b0d809960e7867d6e60201f33d0a86a65d3 100644 (file)
@@ -474,7 +474,6 @@ source "drivers/misc/lis3lv02d/Kconfig"
 source "drivers/misc/altera-stapl/Kconfig"
 source "drivers/misc/mei/Kconfig"
 source "drivers/misc/vmw_vmci/Kconfig"
-source "drivers/misc/mic/Kconfig"
 source "drivers/misc/genwqe/Kconfig"
 source "drivers/misc/echo/Kconfig"
 source "drivers/misc/cxl/Kconfig"
index 2521359e8ef7b5f82498dba5c4329495b12ca98c..d23231e73330373cf13f81eff6ff4e5ce7ef4769 100644 (file)
@@ -46,7 +46,6 @@ obj-$(CONFIG_VMWARE_VMCI)     += vmw_vmci/
 obj-$(CONFIG_LATTICE_ECP3_CONFIG)      += lattice-ecp3-config.o
 obj-$(CONFIG_SRAM)             += sram.o
 obj-$(CONFIG_SRAM_EXEC)                += sram-exec.o
-obj-y                          += mic/
 obj-$(CONFIG_GENWQE)           += genwqe/
 obj-$(CONFIG_ECHO)             += echo/
 obj-$(CONFIG_CXL_BASE)         += cxl/
index 8bac86c4d86b778a4554f5a6c3ecc34a7fe5f587..df2fb9520dd8d03cdbc422243f37f5f737e4ba0a 100644 (file)
@@ -224,7 +224,7 @@ struct mei_ext_hdr {
        u8 type;
        u8 length;
        u8 ext_payload[2];
-       u8 hdr[0];
+       u8 hdr[];
 };
 
 /**
@@ -238,7 +238,7 @@ struct mei_ext_meta_hdr {
        u8 count;
        u8 size;
        u8 reserved[2];
-       struct mei_ext_hdr hdrs[0];
+       struct mei_ext_hdr hdrs[];
 };
 
 /*
@@ -308,7 +308,7 @@ struct mei_msg_hdr {
        u32 dma_ring:1;
        u32 internal:1;
        u32 msg_complete:1;
-       u32 extension[0];
+       u32 extension[];
 } __packed;
 
 /* The length is up to 9 bits */
diff --git a/drivers/misc/mic/Kconfig b/drivers/misc/mic/Kconfig
deleted file mode 100644 (file)
index 8a7c2c5..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-menu "Intel MIC & related support"
-
-config INTEL_MIC_BUS
-       tristate "Intel MIC Bus Driver"
-       depends on 64BIT && PCI && X86
-       select DMA_OPS
-       help
-         This option is selected by any driver which registers a
-         device or driver on the MIC Bus, such as CONFIG_INTEL_MIC_HOST,
-         CONFIG_INTEL_MIC_CARD, CONFIG_INTEL_MIC_X100_DMA etc.
-
-         If you are building a host/card kernel with an Intel MIC device
-         then say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config SCIF_BUS
-       tristate "SCIF Bus Driver"
-       depends on 64BIT && PCI && X86
-       select DMA_OPS
-       help
-         This option is selected by any driver which registers a
-         device or driver on the SCIF Bus, such as CONFIG_INTEL_MIC_HOST
-         and CONFIG_INTEL_MIC_CARD.
-
-         If you are building a host/card kernel with an Intel MIC device
-         then say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config VOP_BUS
-       tristate "VOP Bus Driver"
-       depends on HAS_DMA
-       select DMA_OPS
-       help
-         This option is selected by any driver which registers a
-         device or driver on the VOP Bus, such as CONFIG_INTEL_MIC_HOST
-         and CONFIG_INTEL_MIC_CARD.
-
-         If you are building a host/card kernel with an Intel MIC device
-         then say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config INTEL_MIC_HOST
-       tristate "Intel MIC Host Driver"
-       depends on 64BIT && PCI && X86
-       depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
-       select DMA_OPS
-       help
-         This enables Host Driver support for the Intel Many Integrated
-         Core (MIC) family of PCIe form factor coprocessor devices that
-         run a 64 bit Linux OS. The driver manages card OS state and
-         enables communication between host and card. Intel MIC X100
-         devices are currently supported.
-
-         If you are building a host kernel with an Intel MIC device then
-         say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config INTEL_MIC_CARD
-       tristate "Intel MIC Card Driver"
-       depends on 64BIT && X86
-       depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
-       select VIRTIO
-       help
-         This enables card driver support for the Intel Many Integrated
-         Core (MIC) device family. The card driver communicates shutdown/
-         crash events to the host and allows registration/configuration of
-         virtio devices. Intel MIC X100 devices are currently supported.
-
-         If you are building a card kernel for an Intel MIC device then
-         say M (recommended) or Y, else say N. If unsure say N.
-
-         For more information see
-         <http://software.intel.com/en-us/mic-developer>.
-
-config SCIF
-       tristate "SCIF Driver"
-       depends on 64BIT && PCI && X86 && SCIF_BUS && IOMMU_SUPPORT
-       select IOMMU_IOVA
-       help
-         This enables SCIF Driver support for the Intel Many Integrated
-         Core (MIC) family of PCIe form factor coprocessor devices that
-         run a 64 bit Linux OS. The Symmetric Communication Interface
-         (SCIF (pronounced as skiff)) is a low level communications API
-         across PCIe currently implemented for MIC.
-
-         If you are building a host kernel with an Intel MIC device then
-         say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config MIC_COSM
-       tristate "Intel MIC Coprocessor State Management (COSM) Drivers"
-       depends on 64BIT && PCI && X86 && SCIF
-       help
-         This enables COSM driver support for the Intel Many
-         Integrated Core (MIC) family of PCIe form factor coprocessor
-         devices. COSM drivers implement functions such as boot,
-         shutdown, reset and reboot of MIC devices.
-
-         If you are building a host kernel with an Intel MIC device then
-         say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-config VOP
-       tristate "VOP Driver"
-       depends on VOP_BUS
-       select VHOST_RING
-       select VIRTIO
-       help
-         This enables VOP (Virtio over PCIe) Driver support for the Intel
-         Many Integrated Core (MIC) family of PCIe form factor coprocessor
-         devices. The VOP driver allows virtio drivers, e.g. net, console
-         and block drivers, on the card connect to user space virtio
-         devices on the host.
-
-         If you are building a host kernel with an Intel MIC device then
-         say M (recommended) or Y, else say N. If unsure say N.
-
-         More information about the Intel MIC family as well as the Linux
-         OS and tools for MIC to use with this driver are available from
-         <http://software.intel.com/en-us/mic-developer>.
-
-endmenu
diff --git a/drivers/misc/mic/Makefile b/drivers/misc/mic/Makefile
deleted file mode 100644 (file)
index 1a43622..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile - Intel MIC Linux driver.
-# Copyright(c) 2013, Intel Corporation.
-#
-obj-$(CONFIG_INTEL_MIC_HOST) += host/
-obj-$(CONFIG_INTEL_MIC_CARD) += card/
-obj-y += bus/
-obj-$(CONFIG_SCIF) += scif/
-obj-$(CONFIG_MIC_COSM) += cosm/
-obj-$(CONFIG_MIC_COSM) += cosm_client/
-obj-$(CONFIG_VOP) += vop/
diff --git a/drivers/misc/mic/bus/Makefile b/drivers/misc/mic/bus/Makefile
deleted file mode 100644 (file)
index 0a6aa21..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Makefile - Intel MIC Linux driver.
-# Copyright(c) 2014, Intel Corporation.
-#
-obj-$(CONFIG_INTEL_MIC_BUS) += mic_bus.o
-obj-$(CONFIG_SCIF_BUS) += scif_bus.o
-obj-$(CONFIG_MIC_COSM) += cosm_bus.o
-obj-$(CONFIG_VOP_BUS) += vop_bus.o
diff --git a/drivers/misc/mic/bus/cosm_bus.c b/drivers/misc/mic/bus/cosm_bus.c
deleted file mode 100644 (file)
index 5f2141c..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC COSM Bus Driver
- */
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/idr.h>
-#include "cosm_bus.h"
-
-/* Unique numbering for cosm devices. */
-static DEFINE_IDA(cosm_index_ida);
-
-static int cosm_dev_probe(struct device *d)
-{
-       struct cosm_device *dev = dev_to_cosm(d);
-       struct cosm_driver *drv = drv_to_cosm(dev->dev.driver);
-
-       return drv->probe(dev);
-}
-
-static int cosm_dev_remove(struct device *d)
-{
-       struct cosm_device *dev = dev_to_cosm(d);
-       struct cosm_driver *drv = drv_to_cosm(dev->dev.driver);
-
-       drv->remove(dev);
-       return 0;
-}
-
-static struct bus_type cosm_bus = {
-       .name  = "cosm_bus",
-       .probe = cosm_dev_probe,
-       .remove = cosm_dev_remove,
-};
-
-int cosm_register_driver(struct cosm_driver *driver)
-{
-       driver->driver.bus = &cosm_bus;
-       return driver_register(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(cosm_register_driver);
-
-void cosm_unregister_driver(struct cosm_driver *driver)
-{
-       driver_unregister(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(cosm_unregister_driver);
-
-static inline void cosm_release_dev(struct device *d)
-{
-       struct cosm_device *cdev = dev_to_cosm(d);
-
-       kfree(cdev);
-}
-
-struct cosm_device *
-cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops)
-{
-       struct cosm_device *cdev;
-       int ret;
-
-       cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
-       if (!cdev)
-               return ERR_PTR(-ENOMEM);
-
-       cdev->dev.parent = pdev;
-       cdev->dev.release = cosm_release_dev;
-       cdev->hw_ops = hw_ops;
-       dev_set_drvdata(&cdev->dev, cdev);
-       cdev->dev.bus = &cosm_bus;
-
-       /* Assign a unique device index and hence name */
-       ret = ida_simple_get(&cosm_index_ida, 0, 0, GFP_KERNEL);
-       if (ret < 0)
-               goto free_cdev;
-
-       cdev->index = ret;
-       cdev->dev.id = ret;
-       dev_set_name(&cdev->dev, "cosm-dev%u", cdev->index);
-
-       ret = device_register(&cdev->dev);
-       if (ret)
-               goto ida_remove;
-       return cdev;
-ida_remove:
-       ida_simple_remove(&cosm_index_ida, cdev->index);
-free_cdev:
-       put_device(&cdev->dev);
-       return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(cosm_register_device);
-
-void cosm_unregister_device(struct cosm_device *dev)
-{
-       int index = dev->index; /* save for after device release */
-
-       device_unregister(&dev->dev);
-       ida_simple_remove(&cosm_index_ida, index);
-}
-EXPORT_SYMBOL_GPL(cosm_unregister_device);
-
-struct cosm_device *cosm_find_cdev_by_id(int id)
-{
-       struct device *dev = subsys_find_device_by_id(&cosm_bus, id, NULL);
-
-       return dev ? container_of(dev, struct cosm_device, dev) : NULL;
-}
-EXPORT_SYMBOL_GPL(cosm_find_cdev_by_id);
-
-static int __init cosm_init(void)
-{
-       return bus_register(&cosm_bus);
-}
-
-static void __exit cosm_exit(void)
-{
-       bus_unregister(&cosm_bus);
-       ida_destroy(&cosm_index_ida);
-}
-
-core_initcall(cosm_init);
-module_exit(cosm_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC card OS state management bus driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/bus/cosm_bus.h b/drivers/misc/mic/bus/cosm_bus.h
deleted file mode 100644 (file)
index d50d7ae..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC COSM Bus Driver
- */
-#ifndef _COSM_BUS_H_
-#define _COSM_BUS_H_
-
-#include <linux/scif.h>
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-
-/**
- * cosm_device - representation of a cosm device
- *
- * @attr_group: Pointer to list of sysfs attribute groups.
- * @sdev: Device for sysfs entries.
- * @state: MIC state.
- * @prev_state: MIC state previous to MIC_RESETTING
- * @shutdown_status: MIC status reported by card for shutdown/crashes.
- * @shutdown_status_int: Internal shutdown status maintained by the driver
- * @cosm_mutex: Mutex for synchronizing access to data structures.
- * @reset_trigger_work: Work for triggering reset requests.
- * @scif_work: Work for handling per device SCIF connections
- * @cmdline: Kernel command line.
- * @firmware: Firmware file name.
- * @ramdisk: Ramdisk file name.
- * @bootmode: Boot mode i.e. "linux" or "elf" for flash updates.
- * @log_buf_addr: Log buffer address for MIC.
- * @log_buf_len: Log buffer length address for MIC.
- * @state_sysfs: Sysfs dirent for notifying ring 3 about MIC state changes.
- * @hw_ops: the hardware bus ops for this device.
- * @dev: underlying device.
- * @index: unique position on the cosm bus
- * @dbg_dir: debug fs directory
- * @newepd: new endpoint from scif accept to be assigned to this cdev
- * @epd: SCIF endpoint for this cdev
- * @heartbeat_watchdog_enable: if heartbeat watchdog is enabled for this cdev
- * @sysfs_heartbeat_enable: sysfs setting for disabling heartbeat notification
- */
-struct cosm_device {
-       const struct attribute_group **attr_group;
-       struct device *sdev;
-       u8 state;
-       u8 prev_state;
-       u8 shutdown_status;
-       u8 shutdown_status_int;
-       struct mutex cosm_mutex;
-       struct work_struct reset_trigger_work;
-       struct work_struct scif_work;
-       char *cmdline;
-       char *firmware;
-       char *ramdisk;
-       char *bootmode;
-       void *log_buf_addr;
-       int *log_buf_len;
-       struct kernfs_node *state_sysfs;
-       struct cosm_hw_ops *hw_ops;
-       struct device dev;
-       int index;
-       struct dentry *dbg_dir;
-       scif_epd_t newepd;
-       scif_epd_t epd;
-       bool heartbeat_watchdog_enable;
-       bool sysfs_heartbeat_enable;
-};
-
-/**
- * cosm_driver - operations for a cosm driver
- *
- * @driver: underlying device driver (populate name and owner).
- * @probe: the function to call when a device is found.  Returns 0 or -errno.
- * @remove: the function to call when a device is removed.
- */
-struct cosm_driver {
-       struct device_driver driver;
-       int (*probe)(struct cosm_device *dev);
-       void (*remove)(struct cosm_device *dev);
-};
-
-/**
- * cosm_hw_ops - cosm bus ops
- *
- * @reset: trigger MIC reset
- * @force_reset: force MIC reset
- * @post_reset: inform MIC reset is complete
- * @ready: is MIC ready for OS download
- * @start: boot MIC
- * @stop: prepare MIC for reset
- * @family: return MIC HW family string
- * @stepping: return MIC HW stepping string
- * @aper: return MIC PCIe aperture
- */
-struct cosm_hw_ops {
-       void (*reset)(struct cosm_device *cdev);
-       void (*force_reset)(struct cosm_device *cdev);
-       void (*post_reset)(struct cosm_device *cdev, enum mic_states state);
-       bool (*ready)(struct cosm_device *cdev);
-       int (*start)(struct cosm_device *cdev, int id);
-       void (*stop)(struct cosm_device *cdev, bool force);
-       ssize_t (*family)(struct cosm_device *cdev, char *buf);
-       ssize_t (*stepping)(struct cosm_device *cdev, char *buf);
-       struct mic_mw *(*aper)(struct cosm_device *cdev);
-};
-
-struct cosm_device *
-cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops);
-void cosm_unregister_device(struct cosm_device *dev);
-int cosm_register_driver(struct cosm_driver *drv);
-void cosm_unregister_driver(struct cosm_driver *drv);
-struct cosm_device *cosm_find_cdev_by_id(int id);
-
-static inline struct cosm_device *dev_to_cosm(struct device *dev)
-{
-       return container_of(dev, struct cosm_device, dev);
-}
-
-static inline struct cosm_driver *drv_to_cosm(struct device_driver *drv)
-{
-       return container_of(drv, struct cosm_driver, driver);
-}
-#endif /* _COSM_BUS_H */
diff --git a/drivers/misc/mic/bus/mic_bus.c b/drivers/misc/mic/bus/mic_bus.c
deleted file mode 100644 (file)
index a08cb29..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel MIC Bus driver.
- *
- * This implementation is very similar to the the virtio bus driver
- * implementation @ drivers/virtio/virtio.c
- */
-#include <linux/dma-map-ops.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/idr.h>
-#include <linux/mic_bus.h>
-
-static ssize_t device_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct mbus_device *dev = dev_to_mbus(d);
-       return sprintf(buf, "0x%04x\n", dev->id.device);
-}
-static DEVICE_ATTR_RO(device);
-
-static ssize_t vendor_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct mbus_device *dev = dev_to_mbus(d);
-       return sprintf(buf, "0x%04x\n", dev->id.vendor);
-}
-static DEVICE_ATTR_RO(vendor);
-
-static ssize_t modalias_show(struct device *d,
-                            struct device_attribute *attr, char *buf)
-{
-       struct mbus_device *dev = dev_to_mbus(d);
-       return sprintf(buf, "mbus:d%08Xv%08X\n",
-                      dev->id.device, dev->id.vendor);
-}
-static DEVICE_ATTR_RO(modalias);
-
-static struct attribute *mbus_dev_attrs[] = {
-       &dev_attr_device.attr,
-       &dev_attr_vendor.attr,
-       &dev_attr_modalias.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(mbus_dev);
-
-static inline int mbus_id_match(const struct mbus_device *dev,
-                               const struct mbus_device_id *id)
-{
-       if (id->device != dev->id.device && id->device != MBUS_DEV_ANY_ID)
-               return 0;
-
-       return id->vendor == MBUS_DEV_ANY_ID || id->vendor == dev->id.vendor;
-}
-
-/*
- * This looks through all the IDs a driver claims to support.  If any of them
- * match, we return 1 and the kernel will call mbus_dev_probe().
- */
-static int mbus_dev_match(struct device *dv, struct device_driver *dr)
-{
-       unsigned int i;
-       struct mbus_device *dev = dev_to_mbus(dv);
-       const struct mbus_device_id *ids;
-
-       ids = drv_to_mbus(dr)->id_table;
-       for (i = 0; ids[i].device; i++)
-               if (mbus_id_match(dev, &ids[i]))
-                       return 1;
-       return 0;
-}
-
-static int mbus_uevent(struct device *dv, struct kobj_uevent_env *env)
-{
-       struct mbus_device *dev = dev_to_mbus(dv);
-
-       return add_uevent_var(env, "MODALIAS=mbus:d%08Xv%08X",
-                             dev->id.device, dev->id.vendor);
-}
-
-static int mbus_dev_probe(struct device *d)
-{
-       int err;
-       struct mbus_device *dev = dev_to_mbus(d);
-       struct mbus_driver *drv = drv_to_mbus(dev->dev.driver);
-
-       err = drv->probe(dev);
-       if (!err)
-               if (drv->scan)
-                       drv->scan(dev);
-       return err;
-}
-
-static int mbus_dev_remove(struct device *d)
-{
-       struct mbus_device *dev = dev_to_mbus(d);
-       struct mbus_driver *drv = drv_to_mbus(dev->dev.driver);
-
-       drv->remove(dev);
-       return 0;
-}
-
-static struct bus_type mic_bus = {
-       .name  = "mic_bus",
-       .match = mbus_dev_match,
-       .dev_groups = mbus_dev_groups,
-       .uevent = mbus_uevent,
-       .probe = mbus_dev_probe,
-       .remove = mbus_dev_remove,
-};
-
-int mbus_register_driver(struct mbus_driver *driver)
-{
-       driver->driver.bus = &mic_bus;
-       return driver_register(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(mbus_register_driver);
-
-void mbus_unregister_driver(struct mbus_driver *driver)
-{
-       driver_unregister(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(mbus_unregister_driver);
-
-static void mbus_release_dev(struct device *d)
-{
-       struct mbus_device *mbdev = dev_to_mbus(d);
-       kfree(mbdev);
-}
-
-struct mbus_device *
-mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
-                    struct mbus_hw_ops *hw_ops, int index,
-                    void __iomem *mmio_va)
-{
-       int ret;
-       struct mbus_device *mbdev;
-
-       mbdev = kzalloc(sizeof(*mbdev), GFP_KERNEL);
-       if (!mbdev)
-               return ERR_PTR(-ENOMEM);
-
-       mbdev->mmio_va = mmio_va;
-       mbdev->dev.parent = pdev;
-       mbdev->id.device = id;
-       mbdev->id.vendor = MBUS_DEV_ANY_ID;
-       mbdev->dev.dma_ops = dma_ops;
-       mbdev->dev.dma_mask = &mbdev->dev.coherent_dma_mask;
-       dma_set_mask(&mbdev->dev, DMA_BIT_MASK(64));
-       mbdev->dev.release = mbus_release_dev;
-       mbdev->hw_ops = hw_ops;
-       mbdev->dev.bus = &mic_bus;
-       mbdev->index = index;
-       dev_set_name(&mbdev->dev, "mbus-dev%u", mbdev->index);
-       /*
-        * device_register() causes the bus infrastructure to look for a
-        * matching driver.
-        */
-       ret = device_register(&mbdev->dev);
-       if (ret)
-               goto free_mbdev;
-       return mbdev;
-free_mbdev:
-       put_device(&mbdev->dev);
-       return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(mbus_register_device);
-
-void mbus_unregister_device(struct mbus_device *mbdev)
-{
-       device_unregister(&mbdev->dev);
-}
-EXPORT_SYMBOL_GPL(mbus_unregister_device);
-
-static int __init mbus_init(void)
-{
-       return bus_register(&mic_bus);
-}
-
-static void __exit mbus_exit(void)
-{
-       bus_unregister(&mic_bus);
-}
-
-core_initcall(mbus_init);
-module_exit(mbus_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC Bus driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/bus/scif_bus.c b/drivers/misc/mic/bus/scif_bus.c
deleted file mode 100644 (file)
index ad7c360..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel Symmetric Communications Interface Bus driver.
- */
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/idr.h>
-#include <linux/dma-map-ops.h>
-
-#include "scif_bus.h"
-
-static ssize_t device_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct scif_hw_dev *dev = dev_to_scif(d);
-
-       return sprintf(buf, "0x%04x\n", dev->id.device);
-}
-static DEVICE_ATTR_RO(device);
-
-static ssize_t vendor_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct scif_hw_dev *dev = dev_to_scif(d);
-
-       return sprintf(buf, "0x%04x\n", dev->id.vendor);
-}
-static DEVICE_ATTR_RO(vendor);
-
-static ssize_t modalias_show(struct device *d,
-                            struct device_attribute *attr, char *buf)
-{
-       struct scif_hw_dev *dev = dev_to_scif(d);
-
-       return sprintf(buf, "scif:d%08Xv%08X\n",
-                      dev->id.device, dev->id.vendor);
-}
-static DEVICE_ATTR_RO(modalias);
-
-static struct attribute *scif_dev_attrs[] = {
-       &dev_attr_device.attr,
-       &dev_attr_vendor.attr,
-       &dev_attr_modalias.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(scif_dev);
-
-static inline int scif_id_match(const struct scif_hw_dev *dev,
-                               const struct scif_hw_dev_id *id)
-{
-       if (id->device != dev->id.device && id->device != SCIF_DEV_ANY_ID)
-               return 0;
-
-       return id->vendor == SCIF_DEV_ANY_ID || id->vendor == dev->id.vendor;
-}
-
-/*
- * This looks through all the IDs a driver claims to support.  If any of them
- * match, we return 1 and the kernel will call scif_dev_probe().
- */
-static int scif_dev_match(struct device *dv, struct device_driver *dr)
-{
-       unsigned int i;
-       struct scif_hw_dev *dev = dev_to_scif(dv);
-       const struct scif_hw_dev_id *ids;
-
-       ids = drv_to_scif(dr)->id_table;
-       for (i = 0; ids[i].device; i++)
-               if (scif_id_match(dev, &ids[i]))
-                       return 1;
-       return 0;
-}
-
-static int scif_uevent(struct device *dv, struct kobj_uevent_env *env)
-{
-       struct scif_hw_dev *dev = dev_to_scif(dv);
-
-       return add_uevent_var(env, "MODALIAS=scif:d%08Xv%08X",
-                             dev->id.device, dev->id.vendor);
-}
-
-static int scif_dev_probe(struct device *d)
-{
-       struct scif_hw_dev *dev = dev_to_scif(d);
-       struct scif_driver *drv = drv_to_scif(dev->dev.driver);
-
-       return drv->probe(dev);
-}
-
-static int scif_dev_remove(struct device *d)
-{
-       struct scif_hw_dev *dev = dev_to_scif(d);
-       struct scif_driver *drv = drv_to_scif(dev->dev.driver);
-
-       drv->remove(dev);
-       return 0;
-}
-
-static struct bus_type scif_bus = {
-       .name  = "scif_bus",
-       .match = scif_dev_match,
-       .dev_groups = scif_dev_groups,
-       .uevent = scif_uevent,
-       .probe = scif_dev_probe,
-       .remove = scif_dev_remove,
-};
-
-int scif_register_driver(struct scif_driver *driver)
-{
-       driver->driver.bus = &scif_bus;
-       return driver_register(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(scif_register_driver);
-
-void scif_unregister_driver(struct scif_driver *driver)
-{
-       driver_unregister(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(scif_unregister_driver);
-
-static void scif_release_dev(struct device *d)
-{
-       struct scif_hw_dev *sdev = dev_to_scif(d);
-
-       kfree(sdev);
-}
-
-struct scif_hw_dev *
-scif_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
-                    struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
-                    struct mic_mw *mmio, struct mic_mw *aper, void *dp,
-                    void __iomem *rdp, struct dma_chan **chan, int num_chan,
-                    bool card_rel_da)
-{
-       int ret;
-       struct scif_hw_dev *sdev;
-
-       sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
-       if (!sdev)
-               return ERR_PTR(-ENOMEM);
-
-       sdev->dev.parent = pdev;
-       sdev->id.device = id;
-       sdev->id.vendor = SCIF_DEV_ANY_ID;
-       sdev->dev.dma_ops = dma_ops;
-       sdev->dev.release = scif_release_dev;
-       sdev->hw_ops = hw_ops;
-       sdev->dnode = dnode;
-       sdev->snode = snode;
-       dev_set_drvdata(&sdev->dev, sdev);
-       sdev->dev.bus = &scif_bus;
-       sdev->mmio = mmio;
-       sdev->aper = aper;
-       sdev->dp = dp;
-       sdev->rdp = rdp;
-       sdev->dev.dma_mask = &sdev->dev.coherent_dma_mask;
-       dma_set_mask(&sdev->dev, DMA_BIT_MASK(64));
-       sdev->dma_ch = chan;
-       sdev->num_dma_ch = num_chan;
-       sdev->card_rel_da = card_rel_da;
-       dev_set_name(&sdev->dev, "scif-dev%u", sdev->dnode);
-       /*
-        * device_register() causes the bus infrastructure to look for a
-        * matching driver.
-        */
-       ret = device_register(&sdev->dev);
-       if (ret)
-               goto free_sdev;
-       return sdev;
-free_sdev:
-       put_device(&sdev->dev);
-       return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(scif_register_device);
-
-void scif_unregister_device(struct scif_hw_dev *sdev)
-{
-       device_unregister(&sdev->dev);
-}
-EXPORT_SYMBOL_GPL(scif_unregister_device);
-
-static int __init scif_init(void)
-{
-       return bus_register(&scif_bus);
-}
-
-static void __exit scif_exit(void)
-{
-       bus_unregister(&scif_bus);
-}
-
-core_initcall(scif_init);
-module_exit(scif_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) SCIF Bus driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/bus/scif_bus.h b/drivers/misc/mic/bus/scif_bus.h
deleted file mode 100644 (file)
index 4981eb5..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel Symmetric Communications Interface Bus driver.
- */
-#ifndef _SCIF_BUS_H_
-#define _SCIF_BUS_H_
-/*
- * Everything a scif driver needs to work with any particular scif
- * hardware abstraction layer.
- */
-#include <linux/dma-map-ops.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-
-struct scif_hw_dev_id {
-       u32 device;
-       u32 vendor;
-};
-
-#define MIC_SCIF_DEV 1
-#define SCIF_DEV_ANY_ID 0xffffffff
-
-/**
- * scif_hw_dev - representation of a hardware device abstracted for scif
- * @hw_ops: the hardware ops supported by this device
- * @id: the device type identification (used to match it with a driver)
- * @mmio: MMIO memory window
- * @aper: Aperture memory window
- * @dev: underlying device
- * @dnode - The destination node which this device will communicate with.
- * @snode - The source node for this device.
- * @dp - Self device page
- * @rdp - Remote device page
- * @dma_ch - Array of DMA channels
- * @num_dma_ch - Number of DMA channels available
- * @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
- *             are relative to the card point of view
- */
-struct scif_hw_dev {
-       struct scif_hw_ops *hw_ops;
-       struct scif_hw_dev_id id;
-       struct mic_mw *mmio;
-       struct mic_mw *aper;
-       struct device dev;
-       u8 dnode;
-       u8 snode;
-       void *dp;
-       void __iomem *rdp;
-       struct dma_chan **dma_ch;
-       int num_dma_ch;
-       bool card_rel_da;
-};
-
-/**
- * scif_driver - operations for a scif I/O driver
- * @driver: underlying device driver (populate name and owner).
- * @id_table: the ids serviced by this driver.
- * @probe: the function to call when a device is found.  Returns 0 or -errno.
- * @remove: the function to call when a device is removed.
- */
-struct scif_driver {
-       struct device_driver driver;
-       const struct scif_hw_dev_id *id_table;
-       int (*probe)(struct scif_hw_dev *dev);
-       void (*remove)(struct scif_hw_dev *dev);
-};
-
-/**
- * scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
- *
- * @next_db: Obtain the next available doorbell.
- * @request_irq: Request an interrupt on a particular doorbell.
- * @free_irq: Free an interrupt requested previously.
- * @ack_interrupt: acknowledge an interrupt in the ISR.
- * @send_intr: Send an interrupt to the remote node on a specified doorbell.
- * @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
- * which is specifically targeted for a peer to peer node.
- * @remap: Map a buffer with the specified physical address and length.
- * @unmap: Unmap a buffer previously mapped.
- */
-struct scif_hw_ops {
-       int (*next_db)(struct scif_hw_dev *sdev);
-       struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
-                                       irqreturn_t (*func)(int irq,
-                                                           void *data),
-                                       const char *name, void *data,
-                                       int db);
-       void (*free_irq)(struct scif_hw_dev *sdev,
-                        struct mic_irq *cookie, void *data);
-       void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
-       void (*send_intr)(struct scif_hw_dev *sdev, int db);
-       void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
-                             struct mic_mw *mw);
-       void __iomem * (*remap)(struct scif_hw_dev *sdev,
-                                 phys_addr_t pa, size_t len);
-       void (*unmap)(struct scif_hw_dev *sdev, void __iomem *va);
-};
-
-int scif_register_driver(struct scif_driver *driver);
-void scif_unregister_driver(struct scif_driver *driver);
-struct scif_hw_dev *
-scif_register_device(struct device *pdev, int id,
-                    const struct dma_map_ops *dma_ops,
-                    struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
-                    struct mic_mw *mmio, struct mic_mw *aper,
-                    void *dp, void __iomem *rdp,
-                    struct dma_chan **chan, int num_chan,
-                    bool card_rel_da);
-void scif_unregister_device(struct scif_hw_dev *sdev);
-
-static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
-{
-       return container_of(dev, struct scif_hw_dev, dev);
-}
-
-static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
-{
-       return container_of(drv, struct scif_driver, driver);
-}
-#endif /* _SCIF_BUS_H */
diff --git a/drivers/misc/mic/bus/vop_bus.c b/drivers/misc/mic/bus/vop_bus.c
deleted file mode 100644 (file)
index 6935ddc..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Intel Virtio Over PCIe (VOP) Bus driver.
- */
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/idr.h>
-#include <linux/dma-map-ops.h>
-
-#include "vop_bus.h"
-
-static ssize_t device_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct vop_device *dev = dev_to_vop(d);
-
-       return sprintf(buf, "0x%04x\n", dev->id.device);
-}
-static DEVICE_ATTR_RO(device);
-
-static ssize_t vendor_show(struct device *d,
-                          struct device_attribute *attr, char *buf)
-{
-       struct vop_device *dev = dev_to_vop(d);
-
-       return sprintf(buf, "0x%04x\n", dev->id.vendor);
-}
-static DEVICE_ATTR_RO(vendor);
-
-static ssize_t modalias_show(struct device *d,
-                            struct device_attribute *attr, char *buf)
-{
-       struct vop_device *dev = dev_to_vop(d);
-
-       return sprintf(buf, "vop:d%08Xv%08X\n",
-                      dev->id.device, dev->id.vendor);
-}
-static DEVICE_ATTR_RO(modalias);
-
-static struct attribute *vop_dev_attrs[] = {
-       &dev_attr_device.attr,
-       &dev_attr_vendor.attr,
-       &dev_attr_modalias.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(vop_dev);
-
-static inline int vop_id_match(const struct vop_device *dev,
-                              const struct vop_device_id *id)
-{
-       if (id->device != dev->id.device && id->device != VOP_DEV_ANY_ID)
-               return 0;
-
-       return id->vendor == VOP_DEV_ANY_ID || id->vendor == dev->id.vendor;
-}
-
-/*
- * This looks through all the IDs a driver claims to support.  If any of them
- * match, we return 1 and the kernel will call vop_dev_probe().
- */
-static int vop_dev_match(struct device *dv, struct device_driver *dr)
-{
-       unsigned int i;
-       struct vop_device *dev = dev_to_vop(dv);
-       const struct vop_device_id *ids;
-
-       ids = drv_to_vop(dr)->id_table;
-       for (i = 0; ids[i].device; i++)
-               if (vop_id_match(dev, &ids[i]))
-                       return 1;
-       return 0;
-}
-
-static int vop_uevent(struct device *dv, struct kobj_uevent_env *env)
-{
-       struct vop_device *dev = dev_to_vop(dv);
-
-       return add_uevent_var(env, "MODALIAS=vop:d%08Xv%08X",
-                             dev->id.device, dev->id.vendor);
-}
-
-static int vop_dev_probe(struct device *d)
-{
-       struct vop_device *dev = dev_to_vop(d);
-       struct vop_driver *drv = drv_to_vop(dev->dev.driver);
-
-       return drv->probe(dev);
-}
-
-static int vop_dev_remove(struct device *d)
-{
-       struct vop_device *dev = dev_to_vop(d);
-       struct vop_driver *drv = drv_to_vop(dev->dev.driver);
-
-       drv->remove(dev);
-       return 0;
-}
-
-static struct bus_type vop_bus = {
-       .name  = "vop_bus",
-       .match = vop_dev_match,
-       .dev_groups = vop_dev_groups,
-       .uevent = vop_uevent,
-       .probe = vop_dev_probe,
-       .remove = vop_dev_remove,
-};
-
-int vop_register_driver(struct vop_driver *driver)
-{
-       driver->driver.bus = &vop_bus;
-       return driver_register(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(vop_register_driver);
-
-void vop_unregister_driver(struct vop_driver *driver)
-{
-       driver_unregister(&driver->driver);
-}
-EXPORT_SYMBOL_GPL(vop_unregister_driver);
-
-static void vop_release_dev(struct device *d)
-{
-       struct vop_device *dev = dev_to_vop(d);
-
-       kfree(dev);
-}
-
-struct vop_device *
-vop_register_device(struct device *pdev, int id,
-                   const struct dma_map_ops *dma_ops,
-                   struct vop_hw_ops *hw_ops, u8 dnode, struct mic_mw *aper,
-                   struct dma_chan *chan)
-{
-       int ret;
-       struct vop_device *vdev;
-
-       vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
-       if (!vdev)
-               return ERR_PTR(-ENOMEM);
-
-       vdev->dev.parent = pdev;
-       vdev->id.device = id;
-       vdev->id.vendor = VOP_DEV_ANY_ID;
-       vdev->dev.dma_ops = dma_ops;
-       vdev->dev.dma_mask = &vdev->dev.coherent_dma_mask;
-       dma_set_mask(&vdev->dev, DMA_BIT_MASK(64));
-       vdev->dev.release = vop_release_dev;
-       vdev->hw_ops = hw_ops;
-       vdev->dev.bus = &vop_bus;
-       vdev->dnode = dnode;
-       vdev->aper = aper;
-       vdev->dma_ch = chan;
-       vdev->index = dnode - 1;
-       dev_set_name(&vdev->dev, "vop-dev%u", vdev->index);
-       /*
-        * device_register() causes the bus infrastructure to look for a
-        * matching driver.
-        */
-       ret = device_register(&vdev->dev);
-       if (ret)
-               goto free_vdev;
-       return vdev;
-free_vdev:
-       put_device(&vdev->dev);
-       return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(vop_register_device);
-
-void vop_unregister_device(struct vop_device *dev)
-{
-       device_unregister(&dev->dev);
-}
-EXPORT_SYMBOL_GPL(vop_unregister_device);
-
-static int __init vop_init(void)
-{
-       return bus_register(&vop_bus);
-}
-
-static void __exit vop_exit(void)
-{
-       bus_unregister(&vop_bus);
-}
-
-core_initcall(vop_init);
-module_exit(vop_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) VOP Bus driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/bus/vop_bus.h b/drivers/misc/mic/bus/vop_bus.h
deleted file mode 100644 (file)
index 4fa0280..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Intel Virtio over PCIe Bus driver.
- */
-#ifndef _VOP_BUS_H_
-#define _VOP_BUS_H_
-/*
- * Everything a vop driver needs to work with any particular vop
- * implementation.
- */
-#include <linux/dmaengine.h>
-#include <linux/interrupt.h>
-
-#include "../common/mic_dev.h"
-
-struct vop_device_id {
-       u32 device;
-       u32 vendor;
-};
-
-#define VOP_DEV_TRNSP 1
-#define VOP_DEV_ANY_ID 0xffffffff
-/*
- * Size of the internal buffer used during DMA's as an intermediate buffer
- * for copy to/from user. Must be an integral number of pages.
- */
-#define VOP_INT_DMA_BUF_SIZE PAGE_ALIGN(64 * 1024ULL)
-
-/**
- * vop_device - representation of a device using vop
- * @hw_ops: the hardware ops supported by this device.
- * @id: the device type identification (used to match it with a driver).
- * @dev: underlying device.
- * @dnode - The destination node which this device will communicate with.
- * @aper: Aperture memory window
- * @dma_ch - DMA channel
- * @index: unique position on the vop bus
- */
-struct vop_device {
-       struct vop_hw_ops *hw_ops;
-       struct vop_device_id id;
-       struct device dev;
-       u8 dnode;
-       struct mic_mw *aper;
-       struct dma_chan *dma_ch;
-       int index;
-};
-
-/**
- * vop_driver - operations for a vop I/O driver
- * @driver: underlying device driver (populate name and owner).
- * @id_table: the ids serviced by this driver.
- * @probe: the function to call when a device is found.  Returns 0 or -errno.
- * @remove: the function to call when a device is removed.
- */
-struct vop_driver {
-       struct device_driver driver;
-       const struct vop_device_id *id_table;
-       int (*probe)(struct vop_device *dev);
-       void (*remove)(struct vop_device *dev);
-};
-
-/**
- * vop_hw_ops - Hardware operations for accessing a VOP device on the VOP bus.
- *
- * @next_db: Obtain the next available doorbell.
- * @request_irq: Request an interrupt on a particular doorbell.
- * @free_irq: Free an interrupt requested previously.
- * @ack_interrupt: acknowledge an interrupt in the ISR.
- * @get_remote_dp: Get access to the virtio device page used by the remote
- *                 node to add/remove/configure virtio devices.
- * @get_dp: Get access to the virtio device page used by the self
- *          node to add/remove/configure virtio devices.
- * @send_intr: Send an interrupt to the peer node on a specified doorbell.
- * @remap: Map a buffer with the specified DMA address and length.
- * @unmap: Unmap a buffer previously mapped.
- * @dma_filter: The DMA filter function to use for obtaining access to
- *             a DMA channel on the peer node.
- */
-struct vop_hw_ops {
-       int (*next_db)(struct vop_device *vpdev);
-       struct mic_irq *(*request_irq)(struct vop_device *vpdev,
-                                      irqreturn_t (*func)(int irq, void *data),
-                                      const char *name, void *data,
-                                      int intr_src);
-       void (*free_irq)(struct vop_device *vpdev,
-                        struct mic_irq *cookie, void *data);
-       void (*ack_interrupt)(struct vop_device *vpdev, int num);
-       void __iomem * (*get_remote_dp)(struct vop_device *vpdev);
-       void * (*get_dp)(struct vop_device *vpdev);
-       void (*send_intr)(struct vop_device *vpdev, int db);
-       void __iomem * (*remap)(struct vop_device *vpdev,
-                                 dma_addr_t pa, size_t len);
-       void (*unmap)(struct vop_device *vpdev, void __iomem *va);
-};
-
-struct vop_device *
-vop_register_device(struct device *pdev, int id,
-                   const struct dma_map_ops *dma_ops,
-                   struct vop_hw_ops *hw_ops, u8 dnode, struct mic_mw *aper,
-                   struct dma_chan *chan);
-void vop_unregister_device(struct vop_device *dev);
-int vop_register_driver(struct vop_driver *drv);
-void vop_unregister_driver(struct vop_driver *drv);
-
-/*
- * module_vop_driver() - Helper macro for drivers that don't do
- * anything special in module init/exit.  This eliminates a lot of
- * boilerplate.  Each module may only use this macro once, and
- * calling it replaces module_init() and module_exit()
- */
-#define module_vop_driver(__vop_driver) \
-       module_driver(__vop_driver, vop_register_driver, \
-                       vop_unregister_driver)
-
-static inline struct vop_device *dev_to_vop(struct device *dev)
-{
-       return container_of(dev, struct vop_device, dev);
-}
-
-static inline struct vop_driver *drv_to_vop(struct device_driver *drv)
-{
-       return container_of(drv, struct vop_driver, driver);
-}
-#endif /* _VOP_BUS_H */
diff --git a/drivers/misc/mic/card/Makefile b/drivers/misc/mic/card/Makefile
deleted file mode 100644 (file)
index 921a7e7..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile - Intel MIC Linux driver.
-# Copyright(c) 2013, Intel Corporation.
-#
-ccflags-y += -DINTEL_MIC_CARD
-
-obj-$(CONFIG_INTEL_MIC_CARD) += mic_card.o
-mic_card-y += mic_x100.o
-mic_card-y += mic_device.o
-mic_card-y += mic_debugfs.o
diff --git a/drivers/misc/mic/card/mic_debugfs.c b/drivers/misc/mic/card/mic_debugfs.c
deleted file mode 100644 (file)
index 4c326e8..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Disclaimer: The codes contained in these modules may be specific to
- * the Intel Software Development Platform codenamed: Knights Ferry, and
- * the Intel product codenamed: Knights Corner, and are not backward
- * compatible with other Intel products. Additionally, Intel will NOT
- * support the codes or instruction set in future products.
- *
- * Intel MIC Card driver.
- */
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/seq_file.h>
-#include <linux/interrupt.h>
-#include <linux/device.h>
-
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-
-/* Debugfs parent dir */
-static struct dentry *mic_dbg;
-
-/*
- * mic_intr_show - Send interrupts to host.
- */
-static int mic_intr_show(struct seq_file *s, void *unused)
-{
-       struct mic_driver *mdrv = s->private;
-       struct mic_device *mdev = &mdrv->mdev;
-
-       mic_send_intr(mdev, 0);
-       msleep(1000);
-       mic_send_intr(mdev, 1);
-       msleep(1000);
-       mic_send_intr(mdev, 2);
-       msleep(1000);
-       mic_send_intr(mdev, 3);
-       msleep(1000);
-
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mic_intr);
-
-/*
- * mic_create_card_debug_dir - Initialize MIC debugfs entries.
- */
-void __init mic_create_card_debug_dir(struct mic_driver *mdrv)
-{
-       if (!mic_dbg)
-               return;
-
-       mdrv->dbg_dir = debugfs_create_dir(mdrv->name, mic_dbg);
-
-       debugfs_create_file("intr_test", 0444, mdrv->dbg_dir, mdrv,
-                           &mic_intr_fops);
-}
-
-/*
- * mic_delete_card_debug_dir - Uninitialize MIC debugfs entries.
- */
-void mic_delete_card_debug_dir(struct mic_driver *mdrv)
-{
-       debugfs_remove_recursive(mdrv->dbg_dir);
-}
-
-/*
- * mic_init_card_debugfs - Initialize global debugfs entry.
- */
-void __init mic_init_card_debugfs(void)
-{
-       mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-}
-
-/*
- * mic_exit_card_debugfs - Uninitialize global debugfs entry
- */
-void mic_exit_card_debugfs(void)
-{
-       debugfs_remove(mic_dbg);
-}
diff --git a/drivers/misc/mic/card/mic_device.c b/drivers/misc/mic/card/mic_device.c
deleted file mode 100644 (file)
index a156062..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Disclaimer: The codes contained in these modules may be specific to
- * the Intel Software Development Platform codenamed: Knights Ferry, and
- * the Intel product codenamed: Knights Corner, and are not backward
- * compatible with other Intel products. Additionally, Intel will NOT
- * support the codes or instruction set in future products.
- *
- * Intel MIC Card driver.
- */
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/reboot.h>
-#include <linux/dmaengine.h>
-#include <linux/kmod.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-
-static struct mic_driver *g_drv;
-
-static int __init mic_dp_init(void)
-{
-       struct mic_driver *mdrv = g_drv;
-       struct mic_device *mdev = &mdrv->mdev;
-       struct mic_bootparam __iomem *bootparam;
-       u64 lo, hi, dp_dma_addr;
-       u32 magic;
-
-       lo = mic_read_spad(&mdrv->mdev, MIC_DPLO_SPAD);
-       hi = mic_read_spad(&mdrv->mdev, MIC_DPHI_SPAD);
-
-       dp_dma_addr = lo | (hi << 32);
-       mdrv->dp = mic_card_map(mdev, dp_dma_addr, MIC_DP_SIZE);
-       if (!mdrv->dp) {
-               dev_err(mdrv->dev, "Cannot remap Aperture BAR\n");
-               return -ENOMEM;
-       }
-       bootparam = mdrv->dp;
-       magic = ioread32(&bootparam->magic);
-       if (MIC_MAGIC != magic) {
-               dev_err(mdrv->dev, "bootparam magic mismatch 0x%x\n", magic);
-               return -EIO;
-       }
-       return 0;
-}
-
-/* Uninitialize the device page */
-static void mic_dp_uninit(void)
-{
-       mic_card_unmap(&g_drv->mdev, g_drv->dp);
-}
-
-/**
- * mic_request_card_irq - request an irq.
- *
- * @handler: interrupt handler passed to request_threaded_irq.
- * @thread_fn: thread fn. passed to request_threaded_irq.
- * @name: The ASCII name of the callee requesting the irq.
- * @data: private data that is returned back when calling the
- * function handler.
- * @index: The doorbell index of the requester.
- *
- * returns: The cookie that is transparent to the caller. Passed
- * back when calling mic_free_irq. An appropriate error code
- * is returned on failure. Caller needs to use IS_ERR(return_val)
- * to check for failure and PTR_ERR(return_val) to obtained the
- * error code.
- *
- */
-struct mic_irq *
-mic_request_card_irq(irq_handler_t handler,
-                    irq_handler_t thread_fn, const char *name,
-                    void *data, int index)
-{
-       int rc = 0;
-       unsigned long cookie;
-       struct mic_driver *mdrv = g_drv;
-
-       rc  = request_threaded_irq(mic_db_to_irq(mdrv, index), handler,
-                                  thread_fn, 0, name, data);
-       if (rc) {
-               dev_err(mdrv->dev, "request_threaded_irq failed rc = %d\n", rc);
-               goto err;
-       }
-       mdrv->irq_info.irq_usage_count[index]++;
-       cookie = index;
-       return (struct mic_irq *)cookie;
-err:
-       return ERR_PTR(rc);
-}
-
-/**
- * mic_free_card_irq - free irq.
- *
- * @cookie: cookie obtained during a successful call to mic_request_threaded_irq
- * @data: private data specified by the calling function during the
- * mic_request_threaded_irq
- *
- * returns: none.
- */
-void mic_free_card_irq(struct mic_irq *cookie, void *data)
-{
-       int index;
-       struct mic_driver *mdrv = g_drv;
-
-       index = (unsigned long)cookie & 0xFFFFU;
-       free_irq(mic_db_to_irq(mdrv, index), data);
-       mdrv->irq_info.irq_usage_count[index]--;
-}
-
-/**
- * mic_next_card_db - Get the doorbell with minimum usage count.
- *
- * Returns the irq index.
- */
-int mic_next_card_db(void)
-{
-       int i;
-       int index = 0;
-       struct mic_driver *mdrv = g_drv;
-
-       for (i = 0; i < mdrv->intr_info.num_intr; i++) {
-               if (mdrv->irq_info.irq_usage_count[i] <
-                       mdrv->irq_info.irq_usage_count[index])
-                       index = i;
-       }
-
-       return index;
-}
-
-/**
- * mic_init_irq - Initialize irq information.
- *
- * Returns 0 in success. Appropriate error code on failure.
- */
-static int mic_init_irq(void)
-{
-       struct mic_driver *mdrv = g_drv;
-
-       mdrv->irq_info.irq_usage_count = kzalloc((sizeof(u32) *
-                       mdrv->intr_info.num_intr),
-                       GFP_KERNEL);
-       if (!mdrv->irq_info.irq_usage_count)
-               return -ENOMEM;
-       return 0;
-}
-
-/**
- * mic_uninit_irq - Uninitialize irq information.
- *
- * None.
- */
-static void mic_uninit_irq(void)
-{
-       struct mic_driver *mdrv = g_drv;
-
-       kfree(mdrv->irq_info.irq_usage_count);
-}
-
-static inline struct mic_driver *scdev_to_mdrv(struct scif_hw_dev *scdev)
-{
-       return dev_get_drvdata(scdev->dev.parent);
-}
-
-static struct mic_irq *
-___mic_request_irq(struct scif_hw_dev *scdev,
-                  irqreturn_t (*func)(int irq, void *data),
-                                      const char *name, void *data,
-                                      int db)
-{
-       return mic_request_card_irq(func, NULL, name, data, db);
-}
-
-static void
-___mic_free_irq(struct scif_hw_dev *scdev,
-               struct mic_irq *cookie, void *data)
-{
-       return mic_free_card_irq(cookie, data);
-}
-
-static void ___mic_ack_interrupt(struct scif_hw_dev *scdev, int num)
-{
-       struct mic_driver *mdrv = scdev_to_mdrv(scdev);
-
-       mic_ack_interrupt(&mdrv->mdev);
-}
-
-static int ___mic_next_db(struct scif_hw_dev *scdev)
-{
-       return mic_next_card_db();
-}
-
-static void ___mic_send_intr(struct scif_hw_dev *scdev, int db)
-{
-       struct mic_driver *mdrv = scdev_to_mdrv(scdev);
-
-       mic_send_intr(&mdrv->mdev, db);
-}
-
-static void ___mic_send_p2p_intr(struct scif_hw_dev *scdev, int db,
-                                struct mic_mw *mw)
-{
-       mic_send_p2p_intr(db, mw);
-}
-
-static void __iomem *
-___mic_ioremap(struct scif_hw_dev *scdev,
-              phys_addr_t pa, size_t len)
-{
-       struct mic_driver *mdrv = scdev_to_mdrv(scdev);
-
-       return mic_card_map(&mdrv->mdev, pa, len);
-}
-
-static void ___mic_iounmap(struct scif_hw_dev *scdev, void __iomem *va)
-{
-       struct mic_driver *mdrv = scdev_to_mdrv(scdev);
-
-       mic_card_unmap(&mdrv->mdev, va);
-}
-
-static struct scif_hw_ops scif_hw_ops = {
-       .request_irq = ___mic_request_irq,
-       .free_irq = ___mic_free_irq,
-       .ack_interrupt = ___mic_ack_interrupt,
-       .next_db = ___mic_next_db,
-       .send_intr = ___mic_send_intr,
-       .send_p2p_intr = ___mic_send_p2p_intr,
-       .remap = ___mic_ioremap,
-       .unmap = ___mic_iounmap,
-};
-
-static inline struct mic_driver *vpdev_to_mdrv(struct vop_device *vpdev)
-{
-       return dev_get_drvdata(vpdev->dev.parent);
-}
-
-static struct mic_irq *
-__mic_request_irq(struct vop_device *vpdev,
-                 irqreturn_t (*func)(int irq, void *data),
-                  const char *name, void *data, int intr_src)
-{
-       return mic_request_card_irq(func, NULL, name, data, intr_src);
-}
-
-static void __mic_free_irq(struct vop_device *vpdev,
-                          struct mic_irq *cookie, void *data)
-{
-       return mic_free_card_irq(cookie, data);
-}
-
-static void __mic_ack_interrupt(struct vop_device *vpdev, int num)
-{
-       struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);
-
-       mic_ack_interrupt(&mdrv->mdev);
-}
-
-static int __mic_next_db(struct vop_device *vpdev)
-{
-       return mic_next_card_db();
-}
-
-static void __iomem *__mic_get_remote_dp(struct vop_device *vpdev)
-{
-       struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);
-
-       return mdrv->dp;
-}
-
-static void __mic_send_intr(struct vop_device *vpdev, int db)
-{
-       struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);
-
-       mic_send_intr(&mdrv->mdev, db);
-}
-
-static void __iomem *__mic_ioremap(struct vop_device *vpdev,
-                                  dma_addr_t pa, size_t len)
-{
-       struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);
-
-       return mic_card_map(&mdrv->mdev, pa, len);
-}
-
-static void __mic_iounmap(struct vop_device *vpdev, void __iomem *va)
-{
-       struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);
-
-       mic_card_unmap(&mdrv->mdev, va);
-}
-
-static struct vop_hw_ops vop_hw_ops = {
-       .request_irq = __mic_request_irq,
-       .free_irq = __mic_free_irq,
-       .ack_interrupt = __mic_ack_interrupt,
-       .next_db = __mic_next_db,
-       .get_remote_dp = __mic_get_remote_dp,
-       .send_intr = __mic_send_intr,
-       .remap = __mic_ioremap,
-       .unmap = __mic_iounmap,
-};
-
-static int mic_request_dma_chans(struct mic_driver *mdrv)
-{
-       dma_cap_mask_t mask;
-       struct dma_chan *chan;
-
-       dma_cap_zero(mask);
-       dma_cap_set(DMA_MEMCPY, mask);
-
-       do {
-               chan = dma_request_channel(mask, NULL, NULL);
-               if (chan) {
-                       mdrv->dma_ch[mdrv->num_dma_ch++] = chan;
-                       if (mdrv->num_dma_ch >= MIC_MAX_DMA_CHAN)
-                               break;
-               }
-       } while (chan);
-       dev_info(mdrv->dev, "DMA channels # %d\n", mdrv->num_dma_ch);
-       return mdrv->num_dma_ch;
-}
-
-static void mic_free_dma_chans(struct mic_driver *mdrv)
-{
-       int i = 0;
-
-       for (i = 0; i < mdrv->num_dma_ch; i++) {
-               dma_release_channel(mdrv->dma_ch[i]);
-               mdrv->dma_ch[i] = NULL;
-       }
-       mdrv->num_dma_ch = 0;
-}
-
-/*
- * mic_driver_init - MIC driver initialization tasks.
- *
- * Returns 0 in success. Appropriate error code on failure.
- */
-int __init mic_driver_init(struct mic_driver *mdrv)
-{
-       int rc;
-       struct mic_bootparam __iomem *bootparam;
-       u8 node_id;
-
-       g_drv = mdrv;
-       /* Unloading the card module is not supported. */
-       if (!try_module_get(mdrv->dev->driver->owner)) {
-               rc = -ENODEV;
-               goto done;
-       }
-       rc = mic_dp_init();
-       if (rc)
-               goto put;
-       rc = mic_init_irq();
-       if (rc)
-               goto dp_uninit;
-       if (!mic_request_dma_chans(mdrv)) {
-               rc = -ENODEV;
-               goto irq_uninit;
-       }
-       mdrv->vpdev = vop_register_device(mdrv->dev, VOP_DEV_TRNSP,
-                                         NULL, &vop_hw_ops, 0,
-                                         NULL, mdrv->dma_ch[0]);
-       if (IS_ERR(mdrv->vpdev)) {
-               rc = PTR_ERR(mdrv->vpdev);
-               goto dma_free;
-       }
-       bootparam = mdrv->dp;
-       node_id = ioread8(&bootparam->node_id);
-       mdrv->scdev = scif_register_device(mdrv->dev, MIC_SCIF_DEV,
-                                          NULL, &scif_hw_ops,
-                                          0, node_id, &mdrv->mdev.mmio, NULL,
-                                          NULL, mdrv->dp, mdrv->dma_ch,
-                                          mdrv->num_dma_ch, true);
-       if (IS_ERR(mdrv->scdev)) {
-               rc = PTR_ERR(mdrv->scdev);
-               goto vop_remove;
-       }
-       mic_create_card_debug_dir(mdrv);
-done:
-       return rc;
-vop_remove:
-       vop_unregister_device(mdrv->vpdev);
-dma_free:
-       mic_free_dma_chans(mdrv);
-irq_uninit:
-       mic_uninit_irq();
-dp_uninit:
-       mic_dp_uninit();
-put:
-       module_put(mdrv->dev->driver->owner);
-       return rc;
-}
-
-/*
- * mic_driver_uninit - MIC driver uninitialization tasks.
- *
- * Returns None
- */
-void mic_driver_uninit(struct mic_driver *mdrv)
-{
-       mic_delete_card_debug_dir(mdrv);
-       scif_unregister_device(mdrv->scdev);
-       vop_unregister_device(mdrv->vpdev);
-       mic_free_dma_chans(mdrv);
-       mic_uninit_irq();
-       mic_dp_uninit();
-       module_put(mdrv->dev->driver->owner);
-}
diff --git a/drivers/misc/mic/card/mic_device.h b/drivers/misc/mic/card/mic_device.h
deleted file mode 100644 (file)
index d6cc69a..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Disclaimer: The codes contained in these modules may be specific to
- * the Intel Software Development Platform codenamed: Knights Ferry, and
- * the Intel product codenamed: Knights Corner, and are not backward
- * compatible with other Intel products. Additionally, Intel will NOT
- * support the codes or instruction set in future products.
- *
- * Intel MIC Card driver.
- */
-#ifndef _MIC_CARD_DEVICE_H_
-#define _MIC_CARD_DEVICE_H_
-
-#include <linux/workqueue.h>
-#include <linux/io.h>
-#include <linux/interrupt.h>
-#include <linux/mic_bus.h>
-#include "../bus/scif_bus.h"
-#include "../bus/vop_bus.h"
-
-/**
- * struct mic_intr_info - Contains h/w specific interrupt sources info
- *
- * @num_intr: The number of irqs available
- */
-struct mic_intr_info {
-       u32 num_intr;
-};
-
-/**
- * struct mic_irq_info - OS specific irq information
- *
- * @irq_usage_count: usage count array tracking the number of sources
- * assigned for each irq.
- */
-struct mic_irq_info {
-       int *irq_usage_count;
-};
-
-/**
- * struct mic_device -  MIC device information.
- *
- * @mmio: MMIO bar information.
- */
-struct mic_device {
-       struct mic_mw mmio;
-};
-
-/**
- * struct mic_driver - MIC card driver information.
- *
- * @name: Name for MIC driver.
- * @dbg_dir: debugfs directory of this MIC device.
- * @dev: The device backing this MIC.
- * @dp: The pointer to the virtio device page.
- * @mdev: MIC device information for the host.
- * @hotplug_work: Hot plug work for adding/removing virtio devices.
- * @irq_info: The OS specific irq information
- * @intr_info: H/W specific interrupt information.
- * @dma_mbdev: dma device on the MIC virtual bus.
- * @dma_ch - Array of DMA channels
- * @num_dma_ch - Number of DMA channels available
- * @scdev: SCIF device on the SCIF virtual bus.
- * @vpdev: Virtio over PCIe device on the VOP virtual bus.
- */
-struct mic_driver {
-       char name[20];
-       struct dentry *dbg_dir;
-       struct device *dev;
-       void __iomem *dp;
-       struct mic_device mdev;
-       struct work_struct hotplug_work;
-       struct mic_irq_info irq_info;
-       struct mic_intr_info intr_info;
-       struct mbus_device *dma_mbdev;
-       struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN];
-       int num_dma_ch;
-       struct scif_hw_dev *scdev;
-       struct vop_device *vpdev;
-};
-
-/**
- * struct mic_irq - opaque pointer used as cookie
- */
-struct mic_irq;
-
-/**
- * mic_mmio_read - read from an MMIO register.
- * @mw: MMIO register base virtual address.
- * @offset: register offset.
- *
- * RETURNS: register value.
- */
-static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
-{
-       return ioread32(mw->va + offset);
-}
-
-/**
- * mic_mmio_write - write to an MMIO register.
- * @mw: MMIO register base virtual address.
- * @val: the data value to put into the register
- * @offset: register offset.
- *
- * RETURNS: none.
- */
-static inline void
-mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
-{
-       iowrite32(val, mw->va + offset);
-}
-
-int mic_driver_init(struct mic_driver *mdrv);
-void mic_driver_uninit(struct mic_driver *mdrv);
-int mic_next_card_db(void);
-struct mic_irq *
-mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn,
-                    const char *name, void *data, int db);
-void mic_free_card_irq(struct mic_irq *cookie, void *data);
-u32 mic_read_spad(struct mic_device *mdev, unsigned int idx);
-void mic_send_intr(struct mic_device *mdev, int doorbell);
-void mic_send_p2p_intr(int doorbell, struct mic_mw *mw);
-int mic_db_to_irq(struct mic_driver *mdrv, int db);
-u32 mic_ack_interrupt(struct mic_device *mdev);
-void mic_hw_intr_init(struct mic_driver *mdrv);
-void __iomem *
-mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size);
-void mic_card_unmap(struct mic_device *mdev, void __iomem *addr);
-void __init mic_create_card_debug_dir(struct mic_driver *mdrv);
-void mic_delete_card_debug_dir(struct mic_driver *mdrv);
-void __init mic_init_card_debugfs(void);
-void mic_exit_card_debugfs(void);
-#endif
diff --git a/drivers/misc/mic/card/mic_x100.c b/drivers/misc/mic/card/mic_x100.c
deleted file mode 100644 (file)
index c8bff29..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Disclaimer: The codes contained in these modules may be specific to
- * the Intel Software Development Platform codenamed: Knights Ferry, and
- * the Intel product codenamed: Knights Corner, and are not backward
- * compatible with other Intel products. Additionally, Intel will NOT
- * support the codes or instruction set in future products.
- *
- * Intel MIC Card driver.
- */
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/platform_device.h>
-
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_x100.h"
-
-static const char mic_driver_name[] = "mic";
-
-static struct mic_driver g_drv;
-
-/**
- * mic_read_spad - read from the scratchpad register
- * @mdev: pointer to mic_device instance
- * @idx: index to scratchpad register, 0 based
- *
- * This function allows reading of the 32bit scratchpad register.
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-u32 mic_read_spad(struct mic_device *mdev, unsigned int idx)
-{
-       return mic_mmio_read(&mdev->mmio,
-               MIC_X100_SBOX_BASE_ADDRESS +
-               MIC_X100_SBOX_SPAD0 + idx * 4);
-}
-
-/**
- * __mic_send_intr - Send interrupt to Host.
- * @mdev: pointer to mic_device instance
- * @doorbell: Doorbell number.
- */
-void mic_send_intr(struct mic_device *mdev, int doorbell)
-{
-       struct mic_mw *mw = &mdev->mmio;
-
-       if (doorbell > MIC_X100_MAX_DOORBELL_IDX)
-               return;
-       /* Ensure that the interrupt is ordered w.r.t previous stores. */
-       wmb();
-       mic_mmio_write(mw, MIC_X100_SBOX_SDBIC0_DBREQ_BIT,
-                      MIC_X100_SBOX_BASE_ADDRESS +
-                      (MIC_X100_SBOX_SDBIC0 + (4 * doorbell)));
-}
-
-/*
- * mic_x100_send_sbox_intr - Send an MIC_X100_SBOX interrupt to MIC.
- */
-static void mic_x100_send_sbox_intr(struct mic_mw *mw, int doorbell)
-{
-       u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8;
-       u32 apicicr_low = mic_mmio_read(mw, MIC_X100_SBOX_BASE_ADDRESS +
-                                       apic_icr_offset);
-
-       /* for MIC we need to make sure we "hit" the send_icr bit (13) */
-       apicicr_low = (apicicr_low | (1 << 13));
-       /*
-        * Ensure that the interrupt is ordered w.r.t. previous stores
-        * to main memory. Fence instructions are not implemented in X100
-        * since execution is in order but a compiler barrier is still
-        * required.
-        */
-       wmb();
-       mic_mmio_write(mw, apicicr_low,
-                      MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
-}
-
-static void mic_x100_send_rdmasr_intr(struct mic_mw *mw, int doorbell)
-{
-       int rdmasr_offset = MIC_X100_SBOX_RDMASR0 + (doorbell << 2);
-       /*
-        * Ensure that the interrupt is ordered w.r.t. previous stores
-        * to main memory. Fence instructions are not implemented in X100
-        * since execution is in order but a compiler barrier is still
-        * required.
-        */
-       wmb();
-       mic_mmio_write(mw, 0, MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset);
-}
-
-/**
- * mic_ack_interrupt - Device specific interrupt handling.
- * @mdev: pointer to mic_device instance
- *
- * Returns: bitmask of doorbell events triggered.
- */
-u32 mic_ack_interrupt(struct mic_device *mdev)
-{
-       return 0;
-}
-
-static inline int mic_get_sbox_irq(int db)
-{
-       return MIC_X100_IRQ_BASE + db;
-}
-
-static inline int mic_get_rdmasr_irq(int index)
-{
-       return  MIC_X100_RDMASR_IRQ_BASE + index;
-}
-
-void mic_send_p2p_intr(int db, struct mic_mw *mw)
-{
-       int rdmasr_index;
-
-       if (db < MIC_X100_NUM_SBOX_IRQ) {
-               mic_x100_send_sbox_intr(mw, db);
-       } else {
-               rdmasr_index = db - MIC_X100_NUM_SBOX_IRQ;
-               mic_x100_send_rdmasr_intr(mw, rdmasr_index);
-       }
-}
-
-/**
- * mic_hw_intr_init - Initialize h/w specific interrupt
- * information.
- * @mdrv: pointer to mic_driver
- */
-void mic_hw_intr_init(struct mic_driver *mdrv)
-{
-       mdrv->intr_info.num_intr = MIC_X100_NUM_SBOX_IRQ +
-                               MIC_X100_NUM_RDMASR_IRQ;
-}
-
-/**
- * mic_db_to_irq - Retrieve irq number corresponding to a doorbell.
- * @mdrv: pointer to mic_driver
- * @db: The doorbell obtained for which the irq is needed. Doorbell
- * may correspond to an sbox doorbell or an rdmasr index.
- *
- * Returns the irq corresponding to the doorbell.
- */
-int mic_db_to_irq(struct mic_driver *mdrv, int db)
-{
-       int rdmasr_index;
-
-       /*
-        * The total number of doorbell interrupts on the card are 16. Indices
-        * 0-8 falls in the SBOX category and 8-15 fall in the RDMASR category.
-        */
-       if (db < MIC_X100_NUM_SBOX_IRQ) {
-               return mic_get_sbox_irq(db);
-       } else {
-               rdmasr_index = db - MIC_X100_NUM_SBOX_IRQ;
-               return mic_get_rdmasr_irq(rdmasr_index);
-       }
-}
-
-/*
- * mic_card_map - Allocate virtual address for a remote memory region.
- * @mdev: pointer to mic_device instance.
- * @addr: Remote DMA address.
- * @size: Size of the region.
- *
- * Returns: Virtual address backing the remote memory region.
- */
-void __iomem *
-mic_card_map(struct mic_device *mdev, dma_addr_t addr, size_t size)
-{
-       return ioremap(addr, size);
-}
-
-/*
- * mic_card_unmap - Unmap the virtual address for a remote memory region.
- * @mdev: pointer to mic_device instance.
- * @addr: Virtual address for remote memory region.
- *
- * Returns: None.
- */
-void mic_card_unmap(struct mic_device *mdev, void __iomem *addr)
-{
-       iounmap(addr);
-}
-
-static inline struct mic_driver *mbdev_to_mdrv(struct mbus_device *mbdev)
-{
-       return dev_get_drvdata(mbdev->dev.parent);
-}
-
-static struct mic_irq *
-_mic_request_threaded_irq(struct mbus_device *mbdev,
-                         irq_handler_t handler, irq_handler_t thread_fn,
-                         const char *name, void *data, int intr_src)
-{
-       int rc = 0;
-       unsigned int irq = intr_src;
-       unsigned long cookie = irq;
-
-       rc  = request_threaded_irq(irq, handler, thread_fn, 0, name, data);
-       if (rc) {
-               dev_err(mbdev_to_mdrv(mbdev)->dev,
-                       "request_threaded_irq failed rc = %d\n", rc);
-               return ERR_PTR(rc);
-       }
-       return (struct mic_irq *)cookie;
-}
-
-static void _mic_free_irq(struct mbus_device *mbdev,
-                         struct mic_irq *cookie, void *data)
-{
-       unsigned long irq = (unsigned long)cookie;
-       free_irq(irq, data);
-}
-
-static void _mic_ack_interrupt(struct mbus_device *mbdev, int num)
-{
-       mic_ack_interrupt(&mbdev_to_mdrv(mbdev)->mdev);
-}
-
-static struct mbus_hw_ops mbus_hw_ops = {
-       .request_threaded_irq = _mic_request_threaded_irq,
-       .free_irq = _mic_free_irq,
-       .ack_interrupt = _mic_ack_interrupt,
-};
-
-static int __init mic_probe(struct platform_device *pdev)
-{
-       struct mic_driver *mdrv = &g_drv;
-       struct mic_device *mdev = &mdrv->mdev;
-       int rc = 0;
-
-       mdrv->dev = &pdev->dev;
-       snprintf(mdrv->name, sizeof(mic_driver_name), mic_driver_name);
-
-       /* FIXME: use dma_set_mask_and_coherent() and check result */
-       dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
-
-       mdev->mmio.pa = MIC_X100_MMIO_BASE;
-       mdev->mmio.len = MIC_X100_MMIO_LEN;
-       mdev->mmio.va = devm_ioremap(&pdev->dev, MIC_X100_MMIO_BASE,
-                                    MIC_X100_MMIO_LEN);
-       if (!mdev->mmio.va) {
-               dev_err(&pdev->dev, "Cannot remap MMIO BAR\n");
-               rc = -EIO;
-               goto done;
-       }
-       mic_hw_intr_init(mdrv);
-       platform_set_drvdata(pdev, mdrv);
-       mdrv->dma_mbdev = mbus_register_device(mdrv->dev, MBUS_DEV_DMA_MIC,
-                                              NULL, &mbus_hw_ops, 0,
-                                              mdrv->mdev.mmio.va);
-       if (IS_ERR(mdrv->dma_mbdev)) {
-               rc = PTR_ERR(mdrv->dma_mbdev);
-               dev_err(&pdev->dev, "mbus_add_device failed rc %d\n", rc);
-               goto done;
-       }
-       rc = mic_driver_init(mdrv);
-       if (rc) {
-               dev_err(&pdev->dev, "mic_driver_init failed rc %d\n", rc);
-               goto remove_dma;
-       }
-done:
-       return rc;
-remove_dma:
-       mbus_unregister_device(mdrv->dma_mbdev);
-       return rc;
-}
-
-static int mic_remove(struct platform_device *pdev)
-{
-       struct mic_driver *mdrv = &g_drv;
-
-       mic_driver_uninit(mdrv);
-       mbus_unregister_device(mdrv->dma_mbdev);
-       return 0;
-}
-
-static void mic_platform_shutdown(struct platform_device *pdev)
-{
-       mic_remove(pdev);
-}
-
-static struct platform_driver __refdata mic_platform_driver = {
-       .probe = mic_probe,
-       .remove = mic_remove,
-       .shutdown = mic_platform_shutdown,
-       .driver         = {
-               .name   = mic_driver_name,
-       },
-};
-
-static struct platform_device *mic_platform_dev;
-
-static int __init mic_init(void)
-{
-       int ret;
-       struct cpuinfo_x86 *c = &cpu_data(0);
-
-       if (!(c->x86 == 11 && c->x86_model == 1)) {
-               ret = -ENODEV;
-               pr_err("%s not running on X100 ret %d\n", __func__, ret);
-               goto done;
-       }
-
-       request_module("mic_x100_dma");
-       mic_init_card_debugfs();
-
-       mic_platform_dev = platform_device_register_simple(mic_driver_name,
-                                                          0, NULL, 0);
-       ret = PTR_ERR_OR_ZERO(mic_platform_dev);
-       if (ret) {
-               pr_err("platform_device_register_full ret %d\n", ret);
-               goto cleanup_debugfs;
-       }
-       ret = platform_driver_register(&mic_platform_driver);
-       if (ret) {
-               pr_err("platform_driver_register ret %d\n", ret);
-               goto device_unregister;
-       }
-       return ret;
-
-device_unregister:
-       platform_device_unregister(mic_platform_dev);
-cleanup_debugfs:
-       mic_exit_card_debugfs();
-done:
-       return ret;
-}
-
-static void __exit mic_exit(void)
-{
-       platform_driver_unregister(&mic_platform_driver);
-       platform_device_unregister(mic_platform_dev);
-       mic_exit_card_debugfs();
-}
-
-module_init(mic_init);
-module_exit(mic_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC X100 Card driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/card/mic_x100.h b/drivers/misc/mic/card/mic_x100.h
deleted file mode 100644 (file)
index 46644dd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Disclaimer: The codes contained in these modules may be specific to
- * the Intel Software Development Platform codenamed: Knights Ferry, and
- * the Intel product codenamed: Knights Corner, and are not backward
- * compatible with other Intel products. Additionally, Intel will NOT
- * support the codes or instruction set in future products.
- *
- * Intel MIC Card driver.
- */
-#ifndef _MIC_X100_CARD_H_
-#define _MIC_X100_CARD_H_
-
-#define MIC_X100_MMIO_BASE 0x08007C0000ULL
-#define MIC_X100_MMIO_LEN 0x00020000ULL
-#define MIC_X100_SBOX_BASE_ADDRESS 0x00010000ULL
-
-#define MIC_X100_SBOX_SPAD0 0x0000AB20
-#define MIC_X100_SBOX_SDBIC0 0x0000CC90
-#define MIC_X100_SBOX_SDBIC0_DBREQ_BIT 0x80000000
-#define MIC_X100_SBOX_RDMASR0  0x0000B180
-#define MIC_X100_SBOX_APICICR0 0x0000A9D0
-
-#define MIC_X100_MAX_DOORBELL_IDX 8
-
-#define MIC_X100_NUM_SBOX_IRQ 8
-#define MIC_X100_NUM_RDMASR_IRQ 8
-#define MIC_X100_SBOX_IRQ_BASE 0
-#define MIC_X100_RDMASR_IRQ_BASE 17
-
-#define MIC_X100_IRQ_BASE 26
-
-#endif
diff --git a/drivers/misc/mic/common/mic_dev.h b/drivers/misc/mic/common/mic_dev.h
deleted file mode 100644 (file)
index f94f08d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC driver.
- */
-#ifndef __MIC_DEV_H__
-#define __MIC_DEV_H__
-
-/* The maximum number of MIC devices supported in a single host system. */
-#define MIC_MAX_NUM_DEVS 128
-
-/**
- * enum mic_hw_family - The hardware family to which a device belongs.
- */
-enum mic_hw_family {
-       MIC_FAMILY_X100 = 0,
-       MIC_FAMILY_X200,
-       MIC_FAMILY_UNKNOWN,
-       MIC_FAMILY_LAST
-};
-
-/**
- * struct mic_mw - MIC memory window
- *
- * @pa: Base physical address.
- * @va: Base ioremap'd virtual address.
- * @len: Size of the memory window.
- */
-struct mic_mw {
-       phys_addr_t pa;
-       void __iomem *va;
-       resource_size_t len;
-};
-
-/*
- * Scratch pad register offsets used by the host to communicate
- * device page DMA address to the card.
- */
-#define MIC_DPLO_SPAD 14
-#define MIC_DPHI_SPAD 15
-
-/*
- * These values are supposed to be in the config_change field of the
- * device page when the host sends a config change interrupt to the card.
- */
-#define MIC_VIRTIO_PARAM_DEV_REMOVE 0x1
-#define MIC_VIRTIO_PARAM_CONFIG_CHANGED 0x2
-
-/* Maximum number of DMA channels */
-#define MIC_MAX_DMA_CHAN 4
-
-#endif
diff --git a/drivers/misc/mic/cosm/Makefile b/drivers/misc/mic/cosm/Makefile
deleted file mode 100644 (file)
index 97d74cb..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile - Intel MIC Coprocessor State Management (COSM) Driver
-# Copyright(c) 2015, Intel Corporation.
-#
-obj-$(CONFIG_MIC_COSM) += mic_cosm.o
-
-mic_cosm-objs := cosm_main.o
-mic_cosm-objs += cosm_debugfs.o
-mic_cosm-objs += cosm_sysfs.o
-mic_cosm-objs += cosm_scif_server.o
diff --git a/drivers/misc/mic/cosm/cosm_debugfs.c b/drivers/misc/mic/cosm/cosm_debugfs.c
deleted file mode 100644 (file)
index cb55653..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC Coprocessor State Management (COSM) Driver
- */
-
-#include <linux/debugfs.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include "cosm_main.h"
-
-/* Debugfs parent dir */
-static struct dentry *cosm_dbg;
-
-/*
- * log_buf_show - Display MIC kernel log buffer
- *
- * log_buf addr/len is read from System.map by user space
- * and populated in sysfs entries.
- */
-static int log_buf_show(struct seq_file *s, void *unused)
-{
-       void __iomem *log_buf_va;
-       int __iomem *log_buf_len_va;
-       struct cosm_device *cdev = s->private;
-       void *kva;
-       int size;
-       u64 aper_offset;
-
-       if (!cdev || !cdev->log_buf_addr || !cdev->log_buf_len)
-               goto done;
-
-       mutex_lock(&cdev->cosm_mutex);
-       switch (cdev->state) {
-       case MIC_BOOTING:
-       case MIC_ONLINE:
-       case MIC_SHUTTING_DOWN:
-               break;
-       default:
-               goto unlock;
-       }
-
-       /*
-        * Card kernel will never be relocated and any kernel text/data mapping
-        * can be translated to phys address by subtracting __START_KERNEL_map.
-        */
-       aper_offset = (u64)cdev->log_buf_len - __START_KERNEL_map;
-       log_buf_len_va = cdev->hw_ops->aper(cdev)->va + aper_offset;
-       aper_offset = (u64)cdev->log_buf_addr - __START_KERNEL_map;
-       log_buf_va = cdev->hw_ops->aper(cdev)->va + aper_offset;
-
-       size = ioread32(log_buf_len_va);
-       kva = kmalloc(size, GFP_KERNEL);
-       if (!kva)
-               goto unlock;
-
-       memcpy_fromio(kva, log_buf_va, size);
-       seq_write(s, kva, size);
-       kfree(kva);
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-done:
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(log_buf);
-
-/*
- * force_reset_show - Force MIC reset
- *
- * Invokes the force_reset COSM bus op instead of the standard reset
- * op in case a force reset of the MIC device is required
- */
-static int force_reset_show(struct seq_file *s, void *pos)
-{
-       struct cosm_device *cdev = s->private;
-
-       cosm_stop(cdev, true);
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(force_reset);
-
-void cosm_create_debug_dir(struct cosm_device *cdev)
-{
-       char name[16];
-
-       if (!cosm_dbg)
-               return;
-
-       scnprintf(name, sizeof(name), "mic%d", cdev->index);
-       cdev->dbg_dir = debugfs_create_dir(name, cosm_dbg);
-
-       debugfs_create_file("log_buf", 0444, cdev->dbg_dir, cdev,
-                           &log_buf_fops);
-       debugfs_create_file("force_reset", 0444, cdev->dbg_dir, cdev,
-                           &force_reset_fops);
-}
-
-void cosm_delete_debug_dir(struct cosm_device *cdev)
-{
-       debugfs_remove_recursive(cdev->dbg_dir);
-}
-
-void cosm_init_debugfs(void)
-{
-       cosm_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-}
-
-void cosm_exit_debugfs(void)
-{
-       debugfs_remove(cosm_dbg);
-}
diff --git a/drivers/misc/mic/cosm/cosm_main.c b/drivers/misc/mic/cosm/cosm_main.c
deleted file mode 100644 (file)
index ebb0eac..0000000
+++ /dev/null
@@ -1,382 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC Coprocessor State Management (COSM) Driver
- */
-
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/idr.h>
-#include <linux/slab.h>
-#include <linux/cred.h>
-#include "cosm_main.h"
-
-static const char cosm_driver_name[] = "mic";
-
-/* COSM ID allocator */
-static struct ida g_cosm_ida;
-/* Class of MIC devices for sysfs accessibility. */
-static struct class *g_cosm_class;
-/* Number of MIC devices */
-static atomic_t g_num_dev;
-
-/**
- * cosm_hw_reset - Issue a HW reset for the MIC device
- * @cdev: pointer to cosm_device instance
- * @force: force a MIC to reset even if it is already reset and ready
- */
-static void cosm_hw_reset(struct cosm_device *cdev, bool force)
-{
-       int i;
-
-#define MIC_RESET_TO (45)
-       if (force && cdev->hw_ops->force_reset)
-               cdev->hw_ops->force_reset(cdev);
-       else
-               cdev->hw_ops->reset(cdev);
-
-       for (i = 0; i < MIC_RESET_TO; i++) {
-               if (cdev->hw_ops->ready(cdev)) {
-                       cosm_set_state(cdev, MIC_READY);
-                       return;
-               }
-               /*
-                * Resets typically take 10s of seconds to complete.
-                * Since an MMIO read is required to check if the
-                * firmware is ready or not, a 1 second delay works nicely.
-                */
-               msleep(1000);
-       }
-       cosm_set_state(cdev, MIC_RESET_FAILED);
-}
-
-/**
- * cosm_start - Start the MIC
- * @cdev: pointer to cosm_device instance
- *
- * This function prepares an MIC for boot and initiates boot.
- * RETURNS: An appropriate -ERRNO error value on error, or 0 for success.
- */
-int cosm_start(struct cosm_device *cdev)
-{
-       const struct cred *orig_cred;
-       struct cred *override_cred;
-       int rc;
-
-       mutex_lock(&cdev->cosm_mutex);
-       if (!cdev->bootmode) {
-               dev_err(&cdev->dev, "%s %d bootmode not set\n",
-                       __func__, __LINE__);
-               rc = -EINVAL;
-               goto unlock_ret;
-       }
-retry:
-       if (cdev->state != MIC_READY) {
-               dev_err(&cdev->dev, "%s %d MIC state not READY\n",
-                       __func__, __LINE__);
-               rc = -EINVAL;
-               goto unlock_ret;
-       }
-       if (!cdev->hw_ops->ready(cdev)) {
-               cosm_hw_reset(cdev, false);
-               /*
-                * The state will either be MIC_READY if the reset succeeded
-                * or MIC_RESET_FAILED if the firmware reset failed.
-                */
-               goto retry;
-       }
-
-       /*
-        * Set credentials to root to allow non-root user to download initramsfs
-        * with 600 permissions
-        */
-       override_cred = prepare_creds();
-       if (!override_cred) {
-               dev_err(&cdev->dev, "%s %d prepare_creds failed\n",
-                       __func__, __LINE__);
-               rc = -ENOMEM;
-               goto unlock_ret;
-       }
-       override_cred->fsuid = GLOBAL_ROOT_UID;
-       orig_cred = override_creds(override_cred);
-
-       rc = cdev->hw_ops->start(cdev, cdev->index);
-
-       revert_creds(orig_cred);
-       put_cred(override_cred);
-       if (rc)
-               goto unlock_ret;
-
-       /*
-        * If linux is being booted, card is treated 'online' only
-        * when the scif interface in the card is up. If anything else
-        * is booted, we set card to 'online' immediately.
-        */
-       if (!strcmp(cdev->bootmode, "linux"))
-               cosm_set_state(cdev, MIC_BOOTING);
-       else
-               cosm_set_state(cdev, MIC_ONLINE);
-unlock_ret:
-       mutex_unlock(&cdev->cosm_mutex);
-       if (rc)
-               dev_err(&cdev->dev, "cosm_start failed rc %d\n", rc);
-       return rc;
-}
-
-/**
- * cosm_stop - Prepare the MIC for reset and trigger reset
- * @cdev: pointer to cosm_device instance
- * @force: force a MIC to reset even if it is already reset and ready.
- *
- * RETURNS: None
- */
-void cosm_stop(struct cosm_device *cdev, bool force)
-{
-       mutex_lock(&cdev->cosm_mutex);
-       if (cdev->state != MIC_READY || force) {
-               /*
-                * Don't call hw_ops if they have been called previously.
-                * stop(..) calls device_unregister and will crash the system if
-                * called multiple times.
-                */
-               u8 state = cdev->state == MIC_RESETTING ?
-                                       cdev->prev_state : cdev->state;
-               bool call_hw_ops = state != MIC_RESET_FAILED &&
-                                       state != MIC_READY;
-
-               if (cdev->state != MIC_RESETTING)
-                       cosm_set_state(cdev, MIC_RESETTING);
-               cdev->heartbeat_watchdog_enable = false;
-               if (call_hw_ops)
-                       cdev->hw_ops->stop(cdev, force);
-               cosm_hw_reset(cdev, force);
-               cosm_set_shutdown_status(cdev, MIC_NOP);
-               if (call_hw_ops && cdev->hw_ops->post_reset)
-                       cdev->hw_ops->post_reset(cdev, cdev->state);
-       }
-       mutex_unlock(&cdev->cosm_mutex);
-       flush_work(&cdev->scif_work);
-}
-
-/**
- * cosm_reset_trigger_work - Trigger MIC reset
- * @work: The work structure
- *
- * This work is scheduled whenever the host wants to reset the MIC.
- */
-static void cosm_reset_trigger_work(struct work_struct *work)
-{
-       struct cosm_device *cdev = container_of(work, struct cosm_device,
-                                               reset_trigger_work);
-       cosm_stop(cdev, false);
-}
-
-/**
- * cosm_reset - Schedule MIC reset
- * @cdev: pointer to cosm_device instance
- *
- * RETURNS: An -EINVAL if the card is already READY or 0 for success.
- */
-int cosm_reset(struct cosm_device *cdev)
-{
-       int rc = 0;
-
-       mutex_lock(&cdev->cosm_mutex);
-       if (cdev->state != MIC_READY) {
-               if (cdev->state != MIC_RESETTING) {
-                       cdev->prev_state = cdev->state;
-                       cosm_set_state(cdev, MIC_RESETTING);
-                       schedule_work(&cdev->reset_trigger_work);
-               }
-       } else {
-               dev_err(&cdev->dev, "%s %d MIC is READY\n", __func__, __LINE__);
-               rc = -EINVAL;
-       }
-       mutex_unlock(&cdev->cosm_mutex);
-       return rc;
-}
-
-/**
- * cosm_shutdown - Initiate MIC shutdown.
- * @cdev: pointer to cosm_device instance
- *
- * RETURNS: None
- */
-int cosm_shutdown(struct cosm_device *cdev)
-{
-       struct cosm_msg msg = { .id = COSM_MSG_SHUTDOWN };
-       int rc = 0;
-
-       mutex_lock(&cdev->cosm_mutex);
-       if (cdev->state != MIC_ONLINE) {
-               rc = -EINVAL;
-               dev_err(&cdev->dev, "%s %d skipping shutdown in state: %s\n",
-                       __func__, __LINE__, cosm_state_string[cdev->state]);
-               goto err;
-       }
-
-       if (!cdev->epd) {
-               rc = -ENOTCONN;
-               dev_err(&cdev->dev, "%s %d scif endpoint not connected rc %d\n",
-                       __func__, __LINE__, rc);
-               goto err;
-       }
-
-       rc = scif_send(cdev->epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
-       if (rc < 0) {
-               dev_err(&cdev->dev, "%s %d scif_send failed rc %d\n",
-                       __func__, __LINE__, rc);
-               goto err;
-       }
-       cdev->heartbeat_watchdog_enable = false;
-       cosm_set_state(cdev, MIC_SHUTTING_DOWN);
-       rc = 0;
-err:
-       mutex_unlock(&cdev->cosm_mutex);
-       return rc;
-}
-
-static int cosm_driver_probe(struct cosm_device *cdev)
-{
-       int rc;
-
-       /* Initialize SCIF server at first probe */
-       if (atomic_add_return(1, &g_num_dev) == 1) {
-               rc = cosm_scif_init();
-               if (rc)
-                       goto scif_exit;
-       }
-       mutex_init(&cdev->cosm_mutex);
-       INIT_WORK(&cdev->reset_trigger_work, cosm_reset_trigger_work);
-       INIT_WORK(&cdev->scif_work, cosm_scif_work);
-       cdev->sysfs_heartbeat_enable = true;
-       cosm_sysfs_init(cdev);
-       cdev->sdev = device_create_with_groups(g_cosm_class, cdev->dev.parent,
-                              MKDEV(0, cdev->index), cdev, cdev->attr_group,
-                              "mic%d", cdev->index);
-       if (IS_ERR(cdev->sdev)) {
-               rc = PTR_ERR(cdev->sdev);
-               dev_err(&cdev->dev, "device_create_with_groups failed rc %d\n",
-                       rc);
-               goto scif_exit;
-       }
-
-       cdev->state_sysfs = sysfs_get_dirent(cdev->sdev->kobj.sd,
-               "state");
-       if (!cdev->state_sysfs) {
-               rc = -ENODEV;
-               dev_err(&cdev->dev, "sysfs_get_dirent failed rc %d\n", rc);
-               goto destroy_device;
-       }
-       cosm_create_debug_dir(cdev);
-       return 0;
-destroy_device:
-       device_destroy(g_cosm_class, MKDEV(0, cdev->index));
-scif_exit:
-       if (atomic_dec_and_test(&g_num_dev))
-               cosm_scif_exit();
-       return rc;
-}
-
-static void cosm_driver_remove(struct cosm_device *cdev)
-{
-       cosm_delete_debug_dir(cdev);
-       sysfs_put(cdev->state_sysfs);
-       device_destroy(g_cosm_class, MKDEV(0, cdev->index));
-       flush_work(&cdev->reset_trigger_work);
-       cosm_stop(cdev, false);
-       if (atomic_dec_and_test(&g_num_dev))
-               cosm_scif_exit();
-
-       /* These sysfs entries might have allocated */
-       kfree(cdev->cmdline);
-       kfree(cdev->firmware);
-       kfree(cdev->ramdisk);
-       kfree(cdev->bootmode);
-}
-
-static int cosm_suspend(struct device *dev)
-{
-       struct cosm_device *cdev = dev_to_cosm(dev);
-
-       mutex_lock(&cdev->cosm_mutex);
-       switch (cdev->state) {
-       /**
-        * Suspend/freeze hooks in userspace have already shutdown the card.
-        * Card should be 'ready' in most cases. It is however possible that
-        * some userspace application initiated a boot. In those cases, we
-        * simply reset the card.
-        */
-       case MIC_ONLINE:
-       case MIC_BOOTING:
-       case MIC_SHUTTING_DOWN:
-               mutex_unlock(&cdev->cosm_mutex);
-               cosm_stop(cdev, false);
-               break;
-       default:
-               mutex_unlock(&cdev->cosm_mutex);
-               break;
-       }
-       return 0;
-}
-
-static const struct dev_pm_ops cosm_pm_ops = {
-       .suspend = cosm_suspend,
-       .freeze = cosm_suspend
-};
-
-static struct cosm_driver cosm_driver = {
-       .driver = {
-               .name =  KBUILD_MODNAME,
-               .owner = THIS_MODULE,
-               .pm = &cosm_pm_ops,
-       },
-       .probe = cosm_driver_probe,
-       .remove = cosm_driver_remove
-};
-
-static int __init cosm_init(void)
-{
-       int ret;
-
-       cosm_init_debugfs();
-
-       g_cosm_class = class_create(THIS_MODULE, cosm_driver_name);
-       if (IS_ERR(g_cosm_class)) {
-               ret = PTR_ERR(g_cosm_class);
-               pr_err("class_create failed ret %d\n", ret);
-               goto cleanup_debugfs;
-       }
-
-       ida_init(&g_cosm_ida);
-       ret = cosm_register_driver(&cosm_driver);
-       if (ret) {
-               pr_err("cosm_register_driver failed ret %d\n", ret);
-               goto ida_destroy;
-       }
-       return 0;
-ida_destroy:
-       ida_destroy(&g_cosm_ida);
-       class_destroy(g_cosm_class);
-cleanup_debugfs:
-       cosm_exit_debugfs();
-       return ret;
-}
-
-static void __exit cosm_exit(void)
-{
-       cosm_unregister_driver(&cosm_driver);
-       ida_destroy(&g_cosm_ida);
-       class_destroy(g_cosm_class);
-       cosm_exit_debugfs();
-}
-
-module_init(cosm_init);
-module_exit(cosm_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC Coprocessor State Management (COSM) Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/cosm/cosm_main.h b/drivers/misc/mic/cosm/cosm_main.h
deleted file mode 100644 (file)
index 5188ad2..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC Coprocessor State Management (COSM) Driver
- */
-#ifndef _COSM_COSM_H_
-#define _COSM_COSM_H_
-
-#include <linux/scif.h>
-#include "../bus/cosm_bus.h"
-
-#define COSM_HEARTBEAT_SEND_SEC 30
-#define SCIF_COSM_LISTEN_PORT  201
-
-/**
- * enum COSM msg id's
- * @COSM_MSG_SHUTDOWN: host->card trigger shutdown
- * @COSM_MSG_SYNC_TIME: host->card send host time to card to sync time
- * @COSM_MSG_HEARTBEAT: card->host heartbeat
- * @COSM_MSG_SHUTDOWN_STATUS: card->host with shutdown status as payload
- */
-enum cosm_msg_id {
-       COSM_MSG_SHUTDOWN,
-       COSM_MSG_SYNC_TIME,
-       COSM_MSG_HEARTBEAT,
-       COSM_MSG_SHUTDOWN_STATUS,
-};
-
-struct cosm_msg {
-       u64 id;
-       union {
-               u64 shutdown_status;
-               struct {
-                       u64 tv_sec;
-                       u64 tv_nsec;
-               } timespec;
-       };
-};
-
-extern const char * const cosm_state_string[];
-extern const char * const cosm_shutdown_status_string[];
-
-void cosm_sysfs_init(struct cosm_device *cdev);
-int cosm_start(struct cosm_device *cdev);
-void cosm_stop(struct cosm_device *cdev, bool force);
-int cosm_reset(struct cosm_device *cdev);
-int cosm_shutdown(struct cosm_device *cdev);
-void cosm_set_state(struct cosm_device *cdev, u8 state);
-void cosm_set_shutdown_status(struct cosm_device *cdev, u8 status);
-void cosm_init_debugfs(void);
-void cosm_exit_debugfs(void);
-void cosm_create_debug_dir(struct cosm_device *cdev);
-void cosm_delete_debug_dir(struct cosm_device *cdev);
-int cosm_scif_init(void);
-void cosm_scif_exit(void);
-void cosm_scif_work(struct work_struct *work);
-
-#endif
diff --git a/drivers/misc/mic/cosm/cosm_scif_server.c b/drivers/misc/mic/cosm/cosm_scif_server.c
deleted file mode 100644 (file)
index 7baec9f..0000000
+++ /dev/null
@@ -1,399 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC Coprocessor State Management (COSM) Driver
- */
-#include <linux/kthread.h>
-#include <linux/sched/signal.h>
-
-#include "cosm_main.h"
-
-/*
- * The COSM driver uses SCIF to communicate between the management node and the
- * MIC cards. SCIF is used to (a) Send a shutdown command to the card (b)
- * receive a shutdown status back from the card upon completion of shutdown and
- * (c) receive periodic heartbeat messages from the card used to deduce if the
- * card has crashed.
- *
- * A COSM server consisting of a SCIF listening endpoint waits for incoming
- * connections from the card. Upon acceptance of the connection, a separate
- * work-item is scheduled to handle SCIF message processing for that card. The
- * life-time of this work-item is therefore the time from which the connection
- * from a card is accepted to the time at which the connection is closed. A new
- * work-item starts each time the card boots and is alive till the card (a)
- * shuts down (b) is reset (c) crashes (d) cosm_client driver on the card is
- * unloaded.
- *
- * From the point of view of COSM interactions with SCIF during card
- * shutdown, reset and crash are as follows:
- *
- * Card shutdown
- * -------------
- * 1. COSM client on the card invokes orderly_poweroff() in response to SHUTDOWN
- *    message from the host.
- * 2. Card driver shutdown callback invokes scif_unregister_device(..) resulting
- *    in scif_remove(..) getting called on the card
- * 3. scif_remove -> scif_stop -> scif_handle_remove_node ->
- *    scif_peer_unregister_device -> device_unregister for the host peer device
- * 4. During device_unregister remove(..) method of cosm_client is invoked which
- *    closes the COSM SCIF endpoint on the card. This results in a SCIF_DISCNCT
- *    message being sent to host SCIF. SCIF_DISCNCT message processing on the
- *    host SCIF sets the host COSM SCIF endpoint state to DISCONNECTED and wakes
- *    up the host COSM thread blocked in scif_poll(..) resulting in
- *    scif_poll(..)  returning EPOLLHUP.
- * 5. On the card, scif_peer_release_dev is next called which results in an
- *    SCIF_EXIT message being sent to the host and after receiving the
- *    SCIF_EXIT_ACK from the host the peer device teardown on the card is
- *    complete.
- * 6. As part of the SCIF_EXIT message processing on the host, host sends a
- *    SCIF_REMOVE_NODE to itself corresponding to the card being removed. This
- *    starts a similar SCIF peer device teardown sequence on the host
- *    corresponding to the card being shut down.
- *
- * Card reset
- * ----------
- * The case of interest here is when the card has not been previously shut down
- * since most of the steps below are skipped in that case:
-
- * 1. cosm_stop(..) invokes hw_ops->stop(..) method of the base PCIe driver
- *    which unregisters the SCIF HW device resulting in scif_remove(..) being
- *    called on the host.
- * 2. scif_remove(..) calls scif_disconnect_node(..) which results in a
- *    SCIF_EXIT message being sent to the card.
- * 3. The card executes scif_stop() as part of SCIF_EXIT message
- *    processing. This results in the COSM endpoint on the card being closed and
- *    the SCIF host peer device on the card getting unregistered similar to
- *    steps 3, 4 and 5 for the card shutdown case above. scif_poll(..) on the
- *    host returns EPOLLHUP as a result.
- * 4. On the host, card peer device unregister and SCIF HW remove(..) also
- *    subsequently complete.
- *
- * Card crash
- * ----------
- * If a reset is issued after the card has crashed, there is no SCIF_DISCNT
- * message from the card which would result in scif_poll(..) returning
- * EPOLLHUP. In this case when the host SCIF driver sends a SCIF_REMOVE_NODE
- * message to itself resulting in the card SCIF peer device being unregistered,
- * this results in a scif_peer_release_dev -> scif_cleanup_scifdev->
- * scif_invalidate_ep call sequence which sets the endpoint state to
- * DISCONNECTED and results in scif_poll(..) returning EPOLLHUP.
- */
-
-#define COSM_SCIF_BACKLOG 16
-#define COSM_HEARTBEAT_CHECK_DELTA_SEC 10
-#define COSM_HEARTBEAT_TIMEOUT_SEC \
-               (COSM_HEARTBEAT_SEND_SEC + COSM_HEARTBEAT_CHECK_DELTA_SEC)
-#define COSM_HEARTBEAT_TIMEOUT_MSEC (COSM_HEARTBEAT_TIMEOUT_SEC * MSEC_PER_SEC)
-
-static struct task_struct *server_thread;
-static scif_epd_t listen_epd;
-
-/* Publish MIC card's shutdown status to user space MIC daemon */
-static void cosm_update_mic_status(struct cosm_device *cdev)
-{
-       if (cdev->shutdown_status_int != MIC_NOP) {
-               cosm_set_shutdown_status(cdev, cdev->shutdown_status_int);
-               cdev->shutdown_status_int = MIC_NOP;
-       }
-}
-
-/* Store MIC card's shutdown status internally when it is received */
-static void cosm_shutdown_status_int(struct cosm_device *cdev,
-                                    enum mic_status shutdown_status)
-{
-       switch (shutdown_status) {
-       case MIC_HALTED:
-       case MIC_POWER_OFF:
-       case MIC_RESTART:
-       case MIC_CRASHED:
-               break;
-       default:
-               dev_err(&cdev->dev, "%s %d Unexpected shutdown_status %d\n",
-                       __func__, __LINE__, shutdown_status);
-               return;
-       };
-       cdev->shutdown_status_int = shutdown_status;
-       cdev->heartbeat_watchdog_enable = false;
-
-       if (cdev->state != MIC_SHUTTING_DOWN)
-               cosm_set_state(cdev, MIC_SHUTTING_DOWN);
-}
-
-/* Non-blocking recv. Read and process all available messages */
-static void cosm_scif_recv(struct cosm_device *cdev)
-{
-       struct cosm_msg msg;
-       int rc;
-
-       while (1) {
-               rc = scif_recv(cdev->epd, &msg, sizeof(msg), 0);
-               if (!rc) {
-                       break;
-               } else if (rc < 0) {
-                       dev_dbg(&cdev->dev, "%s: %d rc %d\n",
-                               __func__, __LINE__, rc);
-                       break;
-               }
-               dev_dbg(&cdev->dev, "%s: %d rc %d id 0x%llx\n",
-                       __func__, __LINE__, rc, msg.id);
-
-               switch (msg.id) {
-               case COSM_MSG_SHUTDOWN_STATUS:
-                       cosm_shutdown_status_int(cdev, msg.shutdown_status);
-                       break;
-               case COSM_MSG_HEARTBEAT:
-                       /* Nothing to do, heartbeat only unblocks scif_poll */
-                       break;
-               default:
-                       dev_err(&cdev->dev, "%s: %d unknown msg.id %lld\n",
-                               __func__, __LINE__, msg.id);
-                       break;
-               }
-       }
-}
-
-/* Publish crashed status for this MIC card */
-static void cosm_set_crashed(struct cosm_device *cdev)
-{
-       dev_err(&cdev->dev, "node alive timeout\n");
-       cosm_shutdown_status_int(cdev, MIC_CRASHED);
-       cosm_update_mic_status(cdev);
-}
-
-/* Send host time to the MIC card to sync system time between host and MIC */
-static void cosm_send_time(struct cosm_device *cdev)
-{
-       struct cosm_msg msg = { .id = COSM_MSG_SYNC_TIME };
-       struct timespec64 ts;
-       int rc;
-
-       ktime_get_real_ts64(&ts);
-       msg.timespec.tv_sec = ts.tv_sec;
-       msg.timespec.tv_nsec = ts.tv_nsec;
-
-       rc = scif_send(cdev->epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
-       if (rc < 0)
-               dev_err(&cdev->dev, "%s %d scif_send failed rc %d\n",
-                       __func__, __LINE__, rc);
-}
-
-/*
- * Close this cosm_device's endpoint after its peer endpoint on the card has
- * been closed. In all cases except MIC card crash EPOLLHUP on the host is
- * triggered by the client's endpoint being closed.
- */
-static void cosm_scif_close(struct cosm_device *cdev)
-{
-       /*
-        * Because SHUTDOWN_STATUS message is sent by the MIC cards in the
-        * reboot notifier when shutdown is still not complete, we notify mpssd
-        * to reset the card when SCIF endpoint is closed.
-        */
-       cosm_update_mic_status(cdev);
-       scif_close(cdev->epd);
-       cdev->epd = NULL;
-       dev_dbg(&cdev->dev, "%s %d\n", __func__, __LINE__);
-}
-
-/*
- * Set card state to ONLINE when a new SCIF connection from a MIC card is
- * received. Normally the state is BOOTING when the connection comes in, but can
- * be ONLINE if cosm_client driver on the card was unloaded and then reloaded.
- */
-static int cosm_set_online(struct cosm_device *cdev)
-{
-       int rc = 0;
-
-       if (MIC_BOOTING == cdev->state || MIC_ONLINE == cdev->state) {
-               cdev->heartbeat_watchdog_enable = cdev->sysfs_heartbeat_enable;
-               cdev->epd = cdev->newepd;
-               if (cdev->state == MIC_BOOTING)
-                       cosm_set_state(cdev, MIC_ONLINE);
-               cosm_send_time(cdev);
-               dev_dbg(&cdev->dev, "%s %d\n", __func__, __LINE__);
-       } else {
-               dev_warn(&cdev->dev, "%s %d not going online in state: %s\n",
-                        __func__, __LINE__, cosm_state_string[cdev->state]);
-               rc = -EINVAL;
-       }
-       /* Drop reference acquired by bus_find_device in the server thread */
-       put_device(&cdev->dev);
-       return rc;
-}
-
-/*
- * Work function for handling work for a SCIF connection from a particular MIC
- * card. It first sets the card state to ONLINE and then calls scif_poll to
- * block on activity such as incoming messages on the SCIF endpoint. When the
- * endpoint is closed, the work function exits, completing its life cycle, from
- * MIC card boot to card shutdown/reset/crash.
- */
-void cosm_scif_work(struct work_struct *work)
-{
-       struct cosm_device *cdev = container_of(work, struct cosm_device,
-                                               scif_work);
-       struct scif_pollepd pollepd;
-       int rc;
-
-       mutex_lock(&cdev->cosm_mutex);
-       if (cosm_set_online(cdev))
-               goto exit;
-
-       while (1) {
-               pollepd.epd = cdev->epd;
-               pollepd.events = EPOLLIN;
-
-               /* Drop the mutex before blocking in scif_poll(..) */
-               mutex_unlock(&cdev->cosm_mutex);
-               /* poll(..) with timeout on our endpoint */
-               rc = scif_poll(&pollepd, 1, COSM_HEARTBEAT_TIMEOUT_MSEC);
-               mutex_lock(&cdev->cosm_mutex);
-               if (rc < 0) {
-                       dev_err(&cdev->dev, "%s %d scif_poll rc %d\n",
-                               __func__, __LINE__, rc);
-                       continue;
-               }
-
-               /* There is a message from the card */
-               if (pollepd.revents & EPOLLIN)
-                       cosm_scif_recv(cdev);
-
-               /* The peer endpoint is closed or this endpoint disconnected */
-               if (pollepd.revents & EPOLLHUP) {
-                       cosm_scif_close(cdev);
-                       break;
-               }
-
-               /* Did we timeout from poll? */
-               if (!rc && cdev->heartbeat_watchdog_enable)
-                       cosm_set_crashed(cdev);
-       }
-exit:
-       dev_dbg(&cdev->dev, "%s %d exiting\n", __func__, __LINE__);
-       mutex_unlock(&cdev->cosm_mutex);
-}
-
-/*
- * COSM SCIF server thread function. Accepts incoming SCIF connections from MIC
- * cards, finds the correct cosm_device to associate that connection with and
- * schedules individual work items for each MIC card.
- */
-static int cosm_scif_server(void *unused)
-{
-       struct cosm_device *cdev;
-       scif_epd_t newepd;
-       struct scif_port_id port_id;
-       int rc;
-
-       allow_signal(SIGKILL);
-
-       while (!kthread_should_stop()) {
-               rc = scif_accept(listen_epd, &port_id, &newepd,
-                                SCIF_ACCEPT_SYNC);
-               if (rc < 0) {
-                       if (-ERESTARTSYS != rc)
-                               pr_err("%s %d rc %d\n", __func__, __LINE__, rc);
-                       continue;
-               }
-
-               /*
-                * Associate the incoming connection with a particular
-                * cosm_device, COSM device ID == SCIF node ID - 1
-                */
-               cdev = cosm_find_cdev_by_id(port_id.node - 1);
-               if (!cdev)
-                       continue;
-               cdev->newepd = newepd;
-               schedule_work(&cdev->scif_work);
-       }
-
-       pr_debug("%s %d Server thread stopped\n", __func__, __LINE__);
-       return 0;
-}
-
-static int cosm_scif_listen(void)
-{
-       int rc;
-
-       listen_epd = scif_open();
-       if (!listen_epd) {
-               pr_err("%s %d scif_open failed\n", __func__, __LINE__);
-               return -ENOMEM;
-       }
-
-       rc = scif_bind(listen_epd, SCIF_COSM_LISTEN_PORT);
-       if (rc < 0) {
-               pr_err("%s %d scif_bind failed rc %d\n",
-                      __func__, __LINE__, rc);
-               goto err;
-       }
-
-       rc = scif_listen(listen_epd, COSM_SCIF_BACKLOG);
-       if (rc < 0) {
-               pr_err("%s %d scif_listen rc %d\n", __func__, __LINE__, rc);
-               goto err;
-       }
-       pr_debug("%s %d listen_epd set up\n", __func__, __LINE__);
-       return 0;
-err:
-       scif_close(listen_epd);
-       listen_epd = NULL;
-       return rc;
-}
-
-static void cosm_scif_listen_exit(void)
-{
-       pr_debug("%s %d closing listen_epd\n", __func__, __LINE__);
-       if (listen_epd) {
-               scif_close(listen_epd);
-               listen_epd = NULL;
-       }
-}
-
-/*
- * Create a listening SCIF endpoint and a server kthread which accepts incoming
- * SCIF connections from MIC cards
- */
-int cosm_scif_init(void)
-{
-       int rc = cosm_scif_listen();
-
-       if (rc) {
-               pr_err("%s %d cosm_scif_listen rc %d\n",
-                      __func__, __LINE__, rc);
-               goto err;
-       }
-
-       server_thread = kthread_run(cosm_scif_server, NULL, "cosm_server");
-       if (IS_ERR(server_thread)) {
-               rc = PTR_ERR(server_thread);
-               pr_err("%s %d kthread_run rc %d\n", __func__, __LINE__, rc);
-               goto listen_exit;
-       }
-       return 0;
-listen_exit:
-       cosm_scif_listen_exit();
-err:
-       return rc;
-}
-
-/* Stop the running server thread and close the listening SCIF endpoint */
-void cosm_scif_exit(void)
-{
-       int rc;
-
-       if (!IS_ERR_OR_NULL(server_thread)) {
-               rc = send_sig(SIGKILL, server_thread, 0);
-               if (rc) {
-                       pr_err("%s %d send_sig rc %d\n",
-                              __func__, __LINE__, rc);
-                       return;
-               }
-               kthread_stop(server_thread);
-       }
-
-       cosm_scif_listen_exit();
-}
diff --git a/drivers/misc/mic/cosm/cosm_sysfs.c b/drivers/misc/mic/cosm/cosm_sysfs.c
deleted file mode 100644 (file)
index e6dac96..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC Coprocessor State Management (COSM) Driver
- */
-#include <linux/slab.h>
-#include "cosm_main.h"
-
-/*
- * A state-to-string lookup table, for exposing a human readable state
- * via sysfs. Always keep in sync with enum cosm_states
- */
-const char * const cosm_state_string[] = {
-       [MIC_READY] = "ready",
-       [MIC_BOOTING] = "booting",
-       [MIC_ONLINE] = "online",
-       [MIC_SHUTTING_DOWN] = "shutting_down",
-       [MIC_RESETTING] = "resetting",
-       [MIC_RESET_FAILED] = "reset_failed",
-};
-
-/*
- * A shutdown-status-to-string lookup table, for exposing a human
- * readable state via sysfs. Always keep in sync with enum cosm_shutdown_status
- */
-const char * const cosm_shutdown_status_string[] = {
-       [MIC_NOP] = "nop",
-       [MIC_CRASHED] = "crashed",
-       [MIC_HALTED] = "halted",
-       [MIC_POWER_OFF] = "poweroff",
-       [MIC_RESTART] = "restart",
-};
-
-void cosm_set_shutdown_status(struct cosm_device *cdev, u8 shutdown_status)
-{
-       dev_dbg(&cdev->dev, "Shutdown Status %s -> %s\n",
-               cosm_shutdown_status_string[cdev->shutdown_status],
-               cosm_shutdown_status_string[shutdown_status]);
-       cdev->shutdown_status = shutdown_status;
-}
-
-void cosm_set_state(struct cosm_device *cdev, u8 state)
-{
-       dev_dbg(&cdev->dev, "State %s -> %s\n",
-               cosm_state_string[cdev->state],
-               cosm_state_string[state]);
-       cdev->state = state;
-       sysfs_notify_dirent(cdev->state_sysfs);
-}
-
-static ssize_t
-family_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       return cdev->hw_ops->family(cdev, buf);
-}
-static DEVICE_ATTR_RO(family);
-
-static ssize_t
-stepping_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       return cdev->hw_ops->stepping(cdev, buf);
-}
-static DEVICE_ATTR_RO(stepping);
-
-static ssize_t
-state_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev || cdev->state >= MIC_LAST)
-               return -EINVAL;
-
-       return scnprintf(buf, PAGE_SIZE, "%s\n",
-               cosm_state_string[cdev->state]);
-}
-
-static ssize_t
-state_store(struct device *dev, struct device_attribute *attr,
-           const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       int rc;
-
-       if (!cdev)
-               return -EINVAL;
-
-       if (sysfs_streq(buf, "boot")) {
-               rc = cosm_start(cdev);
-               goto done;
-       }
-       if (sysfs_streq(buf, "reset")) {
-               rc = cosm_reset(cdev);
-               goto done;
-       }
-
-       if (sysfs_streq(buf, "shutdown")) {
-               rc = cosm_shutdown(cdev);
-               goto done;
-       }
-       rc = -EINVAL;
-done:
-       if (rc)
-               count = rc;
-       return count;
-}
-static DEVICE_ATTR_RW(state);
-
-static ssize_t shutdown_status_show(struct device *dev,
-                                   struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev || cdev->shutdown_status >= MIC_STATUS_LAST)
-               return -EINVAL;
-
-       return scnprintf(buf, PAGE_SIZE, "%s\n",
-               cosm_shutdown_status_string[cdev->shutdown_status]);
-}
-static DEVICE_ATTR_RO(shutdown_status);
-
-static ssize_t
-heartbeat_enable_show(struct device *dev,
-                     struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       return scnprintf(buf, PAGE_SIZE, "%d\n", cdev->sysfs_heartbeat_enable);
-}
-
-static ssize_t
-heartbeat_enable_store(struct device *dev,
-                      struct device_attribute *attr,
-                      const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       int enable;
-       int ret;
-
-       if (!cdev)
-               return -EINVAL;
-
-       mutex_lock(&cdev->cosm_mutex);
-       ret = kstrtoint(buf, 10, &enable);
-       if (ret)
-               goto unlock;
-
-       cdev->sysfs_heartbeat_enable = enable;
-       /* if state is not online, cdev->heartbeat_watchdog_enable is 0 */
-       if (cdev->state == MIC_ONLINE)
-               cdev->heartbeat_watchdog_enable = enable;
-       ret = count;
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-       return ret;
-}
-static DEVICE_ATTR_RW(heartbeat_enable);
-
-static ssize_t
-cmdline_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       char *cmdline;
-
-       if (!cdev)
-               return -EINVAL;
-
-       cmdline = cdev->cmdline;
-
-       if (cmdline)
-               return scnprintf(buf, PAGE_SIZE, "%s\n", cmdline);
-       return 0;
-}
-
-static ssize_t
-cmdline_store(struct device *dev, struct device_attribute *attr,
-             const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       mutex_lock(&cdev->cosm_mutex);
-       kfree(cdev->cmdline);
-
-       cdev->cmdline = kmalloc(count + 1, GFP_KERNEL);
-       if (!cdev->cmdline) {
-               count = -ENOMEM;
-               goto unlock;
-       }
-
-       strncpy(cdev->cmdline, buf, count);
-
-       if (cdev->cmdline[count - 1] == '\n')
-               cdev->cmdline[count - 1] = '\0';
-       else
-               cdev->cmdline[count] = '\0';
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-       return count;
-}
-static DEVICE_ATTR_RW(cmdline);
-
-static ssize_t
-firmware_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       char *firmware;
-
-       if (!cdev)
-               return -EINVAL;
-
-       firmware = cdev->firmware;
-
-       if (firmware)
-               return scnprintf(buf, PAGE_SIZE, "%s\n", firmware);
-       return 0;
-}
-
-static ssize_t
-firmware_store(struct device *dev, struct device_attribute *attr,
-              const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       mutex_lock(&cdev->cosm_mutex);
-       kfree(cdev->firmware);
-
-       cdev->firmware = kmalloc(count + 1, GFP_KERNEL);
-       if (!cdev->firmware) {
-               count = -ENOMEM;
-               goto unlock;
-       }
-       strncpy(cdev->firmware, buf, count);
-
-       if (cdev->firmware[count - 1] == '\n')
-               cdev->firmware[count - 1] = '\0';
-       else
-               cdev->firmware[count] = '\0';
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-       return count;
-}
-static DEVICE_ATTR_RW(firmware);
-
-static ssize_t
-ramdisk_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       char *ramdisk;
-
-       if (!cdev)
-               return -EINVAL;
-
-       ramdisk = cdev->ramdisk;
-
-       if (ramdisk)
-               return scnprintf(buf, PAGE_SIZE, "%s\n", ramdisk);
-       return 0;
-}
-
-static ssize_t
-ramdisk_store(struct device *dev, struct device_attribute *attr,
-             const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       mutex_lock(&cdev->cosm_mutex);
-       kfree(cdev->ramdisk);
-
-       cdev->ramdisk = kmalloc(count + 1, GFP_KERNEL);
-       if (!cdev->ramdisk) {
-               count = -ENOMEM;
-               goto unlock;
-       }
-
-       strncpy(cdev->ramdisk, buf, count);
-
-       if (cdev->ramdisk[count - 1] == '\n')
-               cdev->ramdisk[count - 1] = '\0';
-       else
-               cdev->ramdisk[count] = '\0';
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-       return count;
-}
-static DEVICE_ATTR_RW(ramdisk);
-
-static ssize_t
-bootmode_show(struct device *dev, struct device_attribute *attr, char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       char *bootmode;
-
-       if (!cdev)
-               return -EINVAL;
-
-       bootmode = cdev->bootmode;
-
-       if (bootmode)
-               return scnprintf(buf, PAGE_SIZE, "%s\n", bootmode);
-       return 0;
-}
-
-static ssize_t
-bootmode_store(struct device *dev, struct device_attribute *attr,
-              const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       if (!sysfs_streq(buf, "linux") && !sysfs_streq(buf, "flash"))
-               return -EINVAL;
-
-       mutex_lock(&cdev->cosm_mutex);
-       kfree(cdev->bootmode);
-
-       cdev->bootmode = kmalloc(count + 1, GFP_KERNEL);
-       if (!cdev->bootmode) {
-               count = -ENOMEM;
-               goto unlock;
-       }
-
-       strncpy(cdev->bootmode, buf, count);
-
-       if (cdev->bootmode[count - 1] == '\n')
-               cdev->bootmode[count - 1] = '\0';
-       else
-               cdev->bootmode[count] = '\0';
-unlock:
-       mutex_unlock(&cdev->cosm_mutex);
-       return count;
-}
-static DEVICE_ATTR_RW(bootmode);
-
-static ssize_t
-log_buf_addr_show(struct device *dev, struct device_attribute *attr,
-                 char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       return scnprintf(buf, PAGE_SIZE, "%p\n", cdev->log_buf_addr);
-}
-
-static ssize_t
-log_buf_addr_store(struct device *dev, struct device_attribute *attr,
-                  const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       int ret;
-       unsigned long addr;
-
-       if (!cdev)
-               return -EINVAL;
-
-       ret = kstrtoul(buf, 16, &addr);
-       if (ret)
-               goto exit;
-
-       cdev->log_buf_addr = (void *)addr;
-       ret = count;
-exit:
-       return ret;
-}
-static DEVICE_ATTR_RW(log_buf_addr);
-
-static ssize_t
-log_buf_len_show(struct device *dev, struct device_attribute *attr,
-                char *buf)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-
-       if (!cdev)
-               return -EINVAL;
-
-       return scnprintf(buf, PAGE_SIZE, "%p\n", cdev->log_buf_len);
-}
-
-static ssize_t
-log_buf_len_store(struct device *dev, struct device_attribute *attr,
-                 const char *buf, size_t count)
-{
-       struct cosm_device *cdev = dev_get_drvdata(dev);
-       int ret;
-       unsigned long addr;
-
-       if (!cdev)
-               return -EINVAL;
-
-       ret = kstrtoul(buf, 16, &addr);
-       if (ret)
-               goto exit;
-
-       cdev->log_buf_len = (int *)addr;
-       ret = count;
-exit:
-       return ret;
-}
-static DEVICE_ATTR_RW(log_buf_len);
-
-static struct attribute *cosm_default_attrs[] = {
-       &dev_attr_family.attr,
-       &dev_attr_stepping.attr,
-       &dev_attr_state.attr,
-       &dev_attr_shutdown_status.attr,
-       &dev_attr_heartbeat_enable.attr,
-       &dev_attr_cmdline.attr,
-       &dev_attr_firmware.attr,
-       &dev_attr_ramdisk.attr,
-       &dev_attr_bootmode.attr,
-       &dev_attr_log_buf_addr.attr,
-       &dev_attr_log_buf_len.attr,
-
-       NULL
-};
-
-ATTRIBUTE_GROUPS(cosm_default);
-
-void cosm_sysfs_init(struct cosm_device *cdev)
-{
-       cdev->attr_group = cosm_default_groups;
-}
diff --git a/drivers/misc/mic/cosm_client/Makefile b/drivers/misc/mic/cosm_client/Makefile
deleted file mode 100644 (file)
index 5b62270..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Makefile - Intel MIC COSM Client Driver
-# Copyright(c) 2015, Intel Corporation.
-#
-obj-$(CONFIG_MIC_COSM) += cosm_client.o
-
-cosm_client-objs += cosm_scif_client.o
diff --git a/drivers/misc/mic/cosm_client/cosm_scif_client.c b/drivers/misc/mic/cosm_client/cosm_scif_client.c
deleted file mode 100644 (file)
index a03213d..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel MIC COSM Client Driver
- */
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/reboot.h>
-#include <linux/kthread.h>
-#include <linux/sched/signal.h>
-
-#include "../cosm/cosm_main.h"
-
-#define COSM_SCIF_MAX_RETRIES 10
-#define COSM_HEARTBEAT_SEND_MSEC (COSM_HEARTBEAT_SEND_SEC * MSEC_PER_SEC)
-
-static struct task_struct *client_thread;
-static scif_epd_t client_epd;
-static struct scif_peer_dev *client_spdev;
-
-/*
- * Reboot notifier: receives shutdown status from the OS and communicates it
- * back to the COSM process on the host
- */
-static int cosm_reboot_event(struct notifier_block *this, unsigned long event,
-                            void *ptr)
-{
-       struct cosm_msg msg = { .id = COSM_MSG_SHUTDOWN_STATUS };
-       int rc;
-
-       event = (event == SYS_RESTART) ? SYSTEM_RESTART : event;
-       dev_info(&client_spdev->dev, "%s %d received event %ld\n",
-                __func__, __LINE__, event);
-
-       msg.shutdown_status = event;
-       rc = scif_send(client_epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
-       if (rc < 0)
-               dev_err(&client_spdev->dev, "%s %d scif_send rc %d\n",
-                       __func__, __LINE__, rc);
-
-       return NOTIFY_DONE;
-}
-
-static struct notifier_block cosm_reboot = {
-       .notifier_call  = cosm_reboot_event,
-};
-
-/* Set system time from timespec value received from the host */
-static void cosm_set_time(struct cosm_msg *msg)
-{
-       struct timespec64 ts = {
-               .tv_sec = msg->timespec.tv_sec,
-               .tv_nsec = msg->timespec.tv_nsec,
-       };
-       int rc = do_settimeofday64(&ts);
-
-       if (rc)
-               dev_err(&client_spdev->dev, "%s: %d settimeofday rc %d\n",
-                       __func__, __LINE__, rc);
-}
-
-/* COSM client receive message processing */
-static void cosm_client_recv(void)
-{
-       struct cosm_msg msg;
-       int rc;
-
-       while (1) {
-               rc = scif_recv(client_epd, &msg, sizeof(msg), 0);
-               if (!rc) {
-                       return;
-               } else if (rc < 0) {
-                       dev_err(&client_spdev->dev, "%s: %d rc %d\n",
-                               __func__, __LINE__, rc);
-                       return;
-               }
-
-               dev_dbg(&client_spdev->dev, "%s: %d rc %d id 0x%llx\n",
-                       __func__, __LINE__, rc, msg.id);
-
-               switch (msg.id) {
-               case COSM_MSG_SYNC_TIME:
-                       cosm_set_time(&msg);
-                       break;
-               case COSM_MSG_SHUTDOWN:
-                       orderly_poweroff(true);
-                       break;
-               default:
-                       dev_err(&client_spdev->dev, "%s: %d unknown id %lld\n",
-                               __func__, __LINE__, msg.id);
-                       break;
-               }
-       }
-}
-
-/* Initiate connection to the COSM server on the host */
-static int cosm_scif_connect(void)
-{
-       struct scif_port_id port_id;
-       int i, rc;
-
-       client_epd = scif_open();
-       if (!client_epd) {
-               dev_err(&client_spdev->dev, "%s %d scif_open failed\n",
-                       __func__, __LINE__);
-               return -ENOMEM;
-       }
-
-       port_id.node = 0;
-       port_id.port = SCIF_COSM_LISTEN_PORT;
-
-       for (i = 0; i < COSM_SCIF_MAX_RETRIES; i++) {
-               rc = scif_connect(client_epd, &port_id);
-               if (rc < 0)
-                       msleep(1000);
-               else
-                       break;
-       }
-
-       if (rc < 0) {
-               dev_err(&client_spdev->dev, "%s %d scif_connect rc %d\n",
-                       __func__, __LINE__, rc);
-               scif_close(client_epd);
-               client_epd = NULL;
-       }
-       return rc < 0 ? rc : 0;
-}
-
-/* Close host SCIF connection */
-static void cosm_scif_connect_exit(void)
-{
-       if (client_epd) {
-               scif_close(client_epd);
-               client_epd = NULL;
-       }
-}
-
-/*
- * COSM SCIF client thread function: waits for messages from the host and sends
- * a heartbeat to the host
- */
-static int cosm_scif_client(void *unused)
-{
-       struct cosm_msg msg = { .id = COSM_MSG_HEARTBEAT };
-       struct scif_pollepd pollepd;
-       int rc;
-
-       allow_signal(SIGKILL);
-
-       while (!kthread_should_stop()) {
-               pollepd.epd = client_epd;
-               pollepd.events = EPOLLIN;
-
-               rc = scif_poll(&pollepd, 1, COSM_HEARTBEAT_SEND_MSEC);
-               if (rc < 0) {
-                       if (-EINTR != rc)
-                               dev_err(&client_spdev->dev,
-                                       "%s %d scif_poll rc %d\n",
-                                       __func__, __LINE__, rc);
-                       continue;
-               }
-
-               if (pollepd.revents & EPOLLIN)
-                       cosm_client_recv();
-
-               msg.id = COSM_MSG_HEARTBEAT;
-               rc = scif_send(client_epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
-               if (rc < 0)
-                       dev_err(&client_spdev->dev, "%s %d scif_send rc %d\n",
-                               __func__, __LINE__, rc);
-       }
-
-       dev_dbg(&client_spdev->dev, "%s %d Client thread stopped\n",
-               __func__, __LINE__);
-       return 0;
-}
-
-static void cosm_scif_probe(struct scif_peer_dev *spdev)
-{
-       int rc;
-
-       dev_dbg(&spdev->dev, "%s %d: dnode %d\n",
-               __func__, __LINE__, spdev->dnode);
-
-       /* We are only interested in the host with spdev->dnode == 0 */
-       if (spdev->dnode)
-               return;
-
-       client_spdev = spdev;
-       rc = cosm_scif_connect();
-       if (rc)
-               goto exit;
-
-       rc = register_reboot_notifier(&cosm_reboot);
-       if (rc) {
-               dev_err(&spdev->dev,
-                       "reboot notifier registration failed rc %d\n", rc);
-               goto connect_exit;
-       }
-
-       client_thread = kthread_run(cosm_scif_client, NULL, "cosm_client");
-       if (IS_ERR(client_thread)) {
-               rc = PTR_ERR(client_thread);
-               dev_err(&spdev->dev, "%s %d kthread_run rc %d\n",
-                       __func__, __LINE__, rc);
-               goto unreg_reboot;
-       }
-       return;
-unreg_reboot:
-       unregister_reboot_notifier(&cosm_reboot);
-connect_exit:
-       cosm_scif_connect_exit();
-exit:
-       client_spdev = NULL;
-}
-
-static void cosm_scif_remove(struct scif_peer_dev *spdev)
-{
-       int rc;
-
-       dev_dbg(&spdev->dev, "%s %d: dnode %d\n",
-               __func__, __LINE__, spdev->dnode);
-
-       if (spdev->dnode)
-               return;
-
-       if (!IS_ERR_OR_NULL(client_thread)) {
-               rc = send_sig(SIGKILL, client_thread, 0);
-               if (rc) {
-                       pr_err("%s %d send_sig rc %d\n",
-                              __func__, __LINE__, rc);
-                       return;
-               }
-               kthread_stop(client_thread);
-       }
-       unregister_reboot_notifier(&cosm_reboot);
-       cosm_scif_connect_exit();
-       client_spdev = NULL;
-}
-
-static struct scif_client scif_client_cosm = {
-       .name = KBUILD_MODNAME,
-       .probe = cosm_scif_probe,
-       .remove = cosm_scif_remove,
-};
-
-static int __init cosm_client_init(void)
-{
-       int rc = scif_client_register(&scif_client_cosm);
-
-       if (rc)
-               pr_err("scif_client_register failed rc %d\n", rc);
-       return rc;
-}
-
-static void __exit cosm_client_exit(void)
-{
-       scif_client_unregister(&scif_client_cosm);
-}
-
-module_init(cosm_client_init);
-module_exit(cosm_client_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC card OS state management client driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/host/Makefile b/drivers/misc/mic/host/Makefile
deleted file mode 100644 (file)
index 25f1533..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile - Intel MIC Linux driver.
-# Copyright(c) 2013, Intel Corporation.
-#
-obj-$(CONFIG_INTEL_MIC_HOST) += mic_host.o
-mic_host-objs := mic_main.o
-mic_host-objs += mic_x100.o
-mic_host-objs += mic_smpt.o
-mic_host-objs += mic_intr.o
-mic_host-objs += mic_boot.o
-mic_host-objs += mic_debugfs.o
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c
deleted file mode 100644 (file)
index 8cb85b8..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/delay.h>
-#include <linux/firmware.h>
-#include <linux/pci.h>
-#include <linux/kmod.h>
-#include <linux/dma-map-ops.h>
-#include <linux/mic_common.h>
-#include <linux/mic_bus.h>
-#include "../bus/scif_bus.h"
-#include "../bus/vop_bus.h"
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_smpt.h"
-
-static inline struct mic_device *vpdev_to_mdev(struct device *dev)
-{
-       return dev_get_drvdata(dev->parent);
-}
-
-static dma_addr_t
-_mic_dma_map_page(struct device *dev, struct page *page,
-                 unsigned long offset, size_t size,
-                 enum dma_data_direction dir, unsigned long attrs)
-{
-       void *va = phys_to_virt(page_to_phys(page)) + offset;
-       struct mic_device *mdev = vpdev_to_mdev(dev);
-
-       return mic_map_single(mdev, va, size);
-}
-
-static void _mic_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
-                               size_t size, enum dma_data_direction dir,
-                               unsigned long attrs)
-{
-       struct mic_device *mdev = vpdev_to_mdev(dev);
-
-       mic_unmap_single(mdev, dma_addr, size);
-}
-
-static const struct dma_map_ops _mic_dma_ops = {
-       .map_page = _mic_dma_map_page,
-       .unmap_page = _mic_dma_unmap_page,
-};
-
-static struct mic_irq *
-__mic_request_irq(struct vop_device *vpdev,
-                 irqreturn_t (*func)(int irq, void *data),
-                 const char *name, void *data, int intr_src)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       return mic_request_threaded_irq(mdev, func, NULL, name, data,
-                                       intr_src, MIC_INTR_DB);
-}
-
-static void __mic_free_irq(struct vop_device *vpdev,
-                          struct mic_irq *cookie, void *data)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       mic_free_irq(mdev, cookie, data);
-}
-
-static void __mic_ack_interrupt(struct vop_device *vpdev, int num)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       mdev->ops->intr_workarounds(mdev);
-}
-
-static int __mic_next_db(struct vop_device *vpdev)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       return mic_next_db(mdev);
-}
-
-static void *__mic_get_dp(struct vop_device *vpdev)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       return mdev->dp;
-}
-
-static void __iomem *__mic_get_remote_dp(struct vop_device *vpdev)
-{
-       return NULL;
-}
-
-static void __mic_send_intr(struct vop_device *vpdev, int db)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       mdev->ops->send_intr(mdev, db);
-}
-
-static void __iomem *__mic_ioremap(struct vop_device *vpdev,
-                                  dma_addr_t pa, size_t len)
-{
-       struct mic_device *mdev = vpdev_to_mdev(&vpdev->dev);
-
-       return mdev->aper.va + pa;
-}
-
-static void __mic_iounmap(struct vop_device *vpdev, void __iomem *va)
-{
-       /* nothing to do */
-}
-
-static struct vop_hw_ops vop_hw_ops = {
-       .request_irq = __mic_request_irq,
-       .free_irq = __mic_free_irq,
-       .ack_interrupt = __mic_ack_interrupt,
-       .next_db = __mic_next_db,
-       .get_dp = __mic_get_dp,
-       .get_remote_dp = __mic_get_remote_dp,
-       .send_intr = __mic_send_intr,
-       .remap = __mic_ioremap,
-       .unmap = __mic_iounmap,
-};
-
-static inline struct mic_device *scdev_to_mdev(struct scif_hw_dev *scdev)
-{
-       return dev_get_drvdata(scdev->dev.parent);
-}
-
-static void *__mic_dma_alloc(struct device *dev, size_t size,
-                            dma_addr_t *dma_handle, gfp_t gfp,
-                            unsigned long attrs)
-{
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-       dma_addr_t tmp;
-       void *va = kzalloc(size, gfp);
-
-       if (va) {
-               tmp = mic_map_single(mdev, va, size);
-               if (dma_mapping_error(dev, tmp)) {
-                       kfree(va);
-                       va = NULL;
-               } else {
-                       *dma_handle = tmp;
-               }
-       }
-       return va;
-}
-
-static void __mic_dma_free(struct device *dev, size_t size, void *vaddr,
-                          dma_addr_t dma_handle, unsigned long attrs)
-{
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       mic_unmap_single(mdev, dma_handle, size);
-       kfree(vaddr);
-}
-
-static dma_addr_t
-__mic_dma_map_page(struct device *dev, struct page *page, unsigned long offset,
-                  size_t size, enum dma_data_direction dir,
-                  unsigned long attrs)
-{
-       void *va = phys_to_virt(page_to_phys(page)) + offset;
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       return mic_map_single(mdev, va, size);
-}
-
-static void
-__mic_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
-                    size_t size, enum dma_data_direction dir,
-                    unsigned long attrs)
-{
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       mic_unmap_single(mdev, dma_addr, size);
-}
-
-static int __mic_dma_map_sg(struct device *dev, struct scatterlist *sg,
-                           int nents, enum dma_data_direction dir,
-                           unsigned long attrs)
-{
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-       struct scatterlist *s;
-       int i, j, ret;
-       dma_addr_t da;
-
-       ret = dma_map_sg(&mdev->pdev->dev, sg, nents, dir);
-       if (ret <= 0)
-               return 0;
-
-       for_each_sg(sg, s, nents, i) {
-               da = mic_map(mdev, sg_dma_address(s) + s->offset, s->length);
-               if (!da)
-                       goto err;
-               sg_dma_address(s) = da;
-       }
-       return nents;
-err:
-       for_each_sg(sg, s, i, j) {
-               mic_unmap(mdev, sg_dma_address(s), s->length);
-               sg_dma_address(s) = mic_to_dma_addr(mdev, sg_dma_address(s));
-       }
-       dma_unmap_sg(&mdev->pdev->dev, sg, nents, dir);
-       return 0;
-}
-
-static void __mic_dma_unmap_sg(struct device *dev,
-                              struct scatterlist *sg, int nents,
-                              enum dma_data_direction dir,
-                              unsigned long attrs)
-{
-       struct scif_hw_dev *scdev = dev_get_drvdata(dev);
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-       struct scatterlist *s;
-       dma_addr_t da;
-       int i;
-
-       for_each_sg(sg, s, nents, i) {
-               da = mic_to_dma_addr(mdev, sg_dma_address(s));
-               mic_unmap(mdev, sg_dma_address(s), s->length);
-               sg_dma_address(s) = da;
-       }
-       dma_unmap_sg(&mdev->pdev->dev, sg, nents, dir);
-}
-
-static const struct dma_map_ops __mic_dma_ops = {
-       .alloc = __mic_dma_alloc,
-       .free = __mic_dma_free,
-       .map_page = __mic_dma_map_page,
-       .unmap_page = __mic_dma_unmap_page,
-       .map_sg = __mic_dma_map_sg,
-       .unmap_sg = __mic_dma_unmap_sg,
-};
-
-static struct mic_irq *
-___mic_request_irq(struct scif_hw_dev *scdev,
-                  irqreturn_t (*func)(int irq, void *data),
-                                      const char *name,
-                                      void *data, int db)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       return mic_request_threaded_irq(mdev, func, NULL, name, data,
-                                       db, MIC_INTR_DB);
-}
-
-static void
-___mic_free_irq(struct scif_hw_dev *scdev,
-               struct mic_irq *cookie, void *data)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       mic_free_irq(mdev, cookie, data);
-}
-
-static void ___mic_ack_interrupt(struct scif_hw_dev *scdev, int num)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       mdev->ops->intr_workarounds(mdev);
-}
-
-static int ___mic_next_db(struct scif_hw_dev *scdev)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       return mic_next_db(mdev);
-}
-
-static void ___mic_send_intr(struct scif_hw_dev *scdev, int db)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       mdev->ops->send_intr(mdev, db);
-}
-
-static void __iomem *___mic_ioremap(struct scif_hw_dev *scdev,
-                                   phys_addr_t pa, size_t len)
-{
-       struct mic_device *mdev = scdev_to_mdev(scdev);
-
-       return mdev->aper.va + pa;
-}
-
-static void ___mic_iounmap(struct scif_hw_dev *scdev, void __iomem *va)
-{
-       /* nothing to do */
-}
-
-static struct scif_hw_ops scif_hw_ops = {
-       .request_irq = ___mic_request_irq,
-       .free_irq = ___mic_free_irq,
-       .ack_interrupt = ___mic_ack_interrupt,
-       .next_db = ___mic_next_db,
-       .send_intr = ___mic_send_intr,
-       .remap = ___mic_ioremap,
-       .unmap = ___mic_iounmap,
-};
-
-static inline struct mic_device *mbdev_to_mdev(struct mbus_device *mbdev)
-{
-       return dev_get_drvdata(mbdev->dev.parent);
-}
-
-static dma_addr_t
-mic_dma_map_page(struct device *dev, struct page *page,
-                unsigned long offset, size_t size, enum dma_data_direction dir,
-                unsigned long attrs)
-{
-       void *va = phys_to_virt(page_to_phys(page)) + offset;
-       struct mic_device *mdev = dev_get_drvdata(dev->parent);
-
-       return mic_map_single(mdev, va, size);
-}
-
-static void
-mic_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
-                  size_t size, enum dma_data_direction dir,
-                  unsigned long attrs)
-{
-       struct mic_device *mdev = dev_get_drvdata(dev->parent);
-       mic_unmap_single(mdev, dma_addr, size);
-}
-
-static const struct dma_map_ops mic_dma_ops = {
-       .map_page = mic_dma_map_page,
-       .unmap_page = mic_dma_unmap_page,
-};
-
-static struct mic_irq *
-_mic_request_threaded_irq(struct mbus_device *mbdev,
-                         irq_handler_t handler, irq_handler_t thread_fn,
-                         const char *name, void *data, int intr_src)
-{
-       return mic_request_threaded_irq(mbdev_to_mdev(mbdev), handler,
-                                       thread_fn, name, data,
-                                       intr_src, MIC_INTR_DMA);
-}
-
-static void _mic_free_irq(struct mbus_device *mbdev,
-                         struct mic_irq *cookie, void *data)
-{
-       mic_free_irq(mbdev_to_mdev(mbdev), cookie, data);
-}
-
-static void _mic_ack_interrupt(struct mbus_device *mbdev, int num)
-{
-       struct mic_device *mdev = mbdev_to_mdev(mbdev);
-       mdev->ops->intr_workarounds(mdev);
-}
-
-static struct mbus_hw_ops mbus_hw_ops = {
-       .request_threaded_irq = _mic_request_threaded_irq,
-       .free_irq = _mic_free_irq,
-       .ack_interrupt = _mic_ack_interrupt,
-};
-
-/* Initialize the MIC bootparams */
-void mic_bootparam_init(struct mic_device *mdev)
-{
-       struct mic_bootparam *bootparam = mdev->dp;
-
-       bootparam->magic = cpu_to_le32(MIC_MAGIC);
-       bootparam->h2c_config_db = -1;
-       bootparam->node_id = mdev->id + 1;
-       bootparam->scif_host_dma_addr = 0x0;
-       bootparam->scif_card_dma_addr = 0x0;
-       bootparam->c2h_scif_db = -1;
-       bootparam->h2c_scif_db = -1;
-}
-
-static inline struct mic_device *cosmdev_to_mdev(struct cosm_device *cdev)
-{
-       return dev_get_drvdata(cdev->dev.parent);
-}
-
-static void _mic_reset(struct cosm_device *cdev)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-
-       mdev->ops->reset_fw_ready(mdev);
-       mdev->ops->reset(mdev);
-}
-
-static bool _mic_ready(struct cosm_device *cdev)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-
-       return mdev->ops->is_fw_ready(mdev);
-}
-
-/**
- * mic_request_dma_chans - Request DMA channels
- * @mdev: pointer to mic_device instance
- *
- * returns number of DMA channels acquired
- */
-static int mic_request_dma_chans(struct mic_device *mdev)
-{
-       dma_cap_mask_t mask;
-       struct dma_chan *chan;
-
-       dma_cap_zero(mask);
-       dma_cap_set(DMA_MEMCPY, mask);
-
-       do {
-               chan = dma_request_channel(mask, mdev->ops->dma_filter,
-                                          &mdev->pdev->dev);
-               if (chan) {
-                       mdev->dma_ch[mdev->num_dma_ch++] = chan;
-                       if (mdev->num_dma_ch >= MIC_MAX_DMA_CHAN)
-                               break;
-               }
-       } while (chan);
-       dev_info(&mdev->pdev->dev, "DMA channels # %d\n", mdev->num_dma_ch);
-       return mdev->num_dma_ch;
-}
-
-/**
- * mic_free_dma_chans - release DMA channels
- * @mdev: pointer to mic_device instance
- *
- * returns none
- */
-static void mic_free_dma_chans(struct mic_device *mdev)
-{
-       int i = 0;
-
-       for (i = 0; i < mdev->num_dma_ch; i++) {
-               dma_release_channel(mdev->dma_ch[i]);
-               mdev->dma_ch[i] = NULL;
-       }
-       mdev->num_dma_ch = 0;
-}
-
-/**
- * _mic_start - Start the MIC.
- * @cdev: pointer to cosm_device instance
- * @id: MIC device id/index provided by COSM used in other drivers like SCIF
- *
- * This function prepares an MIC for boot and initiates boot.
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- *
- * For all cosm_hw_ops the caller holds a mutex to ensure serialization.
- */
-static int _mic_start(struct cosm_device *cdev, int id)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-       int rc;
-
-       mic_bootparam_init(mdev);
-       mdev->dma_mbdev = mbus_register_device(&mdev->pdev->dev,
-                                              MBUS_DEV_DMA_HOST, &mic_dma_ops,
-                                              &mbus_hw_ops, id, mdev->mmio.va);
-       if (IS_ERR(mdev->dma_mbdev)) {
-               rc = PTR_ERR(mdev->dma_mbdev);
-               goto unlock_ret;
-       }
-       if (!mic_request_dma_chans(mdev)) {
-               rc = -ENODEV;
-               goto dma_remove;
-       }
-       mdev->scdev = scif_register_device(&mdev->pdev->dev, MIC_SCIF_DEV,
-                                          &__mic_dma_ops, &scif_hw_ops,
-                                          id + 1, 0, &mdev->mmio,
-                                          &mdev->aper, mdev->dp, NULL,
-                                          mdev->dma_ch, mdev->num_dma_ch,
-                                          true);
-       if (IS_ERR(mdev->scdev)) {
-               rc = PTR_ERR(mdev->scdev);
-               goto dma_free;
-       }
-
-       mdev->vpdev = vop_register_device(&mdev->pdev->dev,
-                                         VOP_DEV_TRNSP, &_mic_dma_ops,
-                                         &vop_hw_ops, id + 1, &mdev->aper,
-                                         mdev->dma_ch[0]);
-       if (IS_ERR(mdev->vpdev)) {
-               rc = PTR_ERR(mdev->vpdev);
-               goto scif_remove;
-       }
-
-       rc = mdev->ops->load_mic_fw(mdev, NULL);
-       if (rc)
-               goto vop_remove;
-       mic_smpt_restore(mdev);
-       mic_intr_restore(mdev);
-       mdev->intr_ops->enable_interrupts(mdev);
-       mdev->ops->write_spad(mdev, MIC_DPLO_SPAD, mdev->dp_dma_addr);
-       mdev->ops->write_spad(mdev, MIC_DPHI_SPAD, mdev->dp_dma_addr >> 32);
-       mdev->ops->send_firmware_intr(mdev);
-       goto unlock_ret;
-vop_remove:
-       vop_unregister_device(mdev->vpdev);
-scif_remove:
-       scif_unregister_device(mdev->scdev);
-dma_free:
-       mic_free_dma_chans(mdev);
-dma_remove:
-       mbus_unregister_device(mdev->dma_mbdev);
-unlock_ret:
-       return rc;
-}
-
-/**
- * _mic_stop - Prepare the MIC for reset and trigger reset.
- * @cdev: pointer to cosm_device instance
- * @force: force a MIC to reset even if it is already offline.
- *
- * RETURNS: None.
- */
-static void _mic_stop(struct cosm_device *cdev, bool force)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-
-       /*
-        * Since SCIF handles card shutdown and reset (using COSM), it will
-        * will be the first to be registered and the last to be
-        * unregistered.
-        */
-       vop_unregister_device(mdev->vpdev);
-       scif_unregister_device(mdev->scdev);
-       mic_free_dma_chans(mdev);
-       mbus_unregister_device(mdev->dma_mbdev);
-       mic_bootparam_init(mdev);
-}
-
-static ssize_t _mic_family(struct cosm_device *cdev, char *buf)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-       static const char *family[MIC_FAMILY_LAST] = { "x100", "Unknown" };
-
-       return scnprintf(buf, PAGE_SIZE, "%s\n", family[mdev->family]);
-}
-
-static ssize_t _mic_stepping(struct cosm_device *cdev, char *buf)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-       const char *string = "??";
-
-       switch (mdev->stepping) {
-       case MIC_A0_STEP:
-               string = "A0";
-               break;
-       case MIC_B0_STEP:
-               string = "B0";
-               break;
-       case MIC_B1_STEP:
-               string = "B1";
-               break;
-       case MIC_C0_STEP:
-               string = "C0";
-               break;
-       default:
-               break;
-       }
-       return scnprintf(buf, PAGE_SIZE, "%s\n", string);
-}
-
-static struct mic_mw *_mic_aper(struct cosm_device *cdev)
-{
-       struct mic_device *mdev = cosmdev_to_mdev(cdev);
-
-       return &mdev->aper;
-}
-
-struct cosm_hw_ops cosm_hw_ops = {
-       .reset = _mic_reset,
-       .force_reset = _mic_reset,
-       .post_reset = NULL,
-       .ready = _mic_ready,
-       .start = _mic_start,
-       .stop = _mic_stop,
-       .family = _mic_family,
-       .stepping = _mic_stepping,
-       .aper = _mic_aper,
-};
diff --git a/drivers/misc/mic/host/mic_debugfs.c b/drivers/misc/mic/host/mic_debugfs.c
deleted file mode 100644 (file)
index ffda740..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/debugfs.h>
-#include <linux/pci.h>
-#include <linux/seq_file.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_smpt.h"
-
-/* Debugfs parent dir */
-static struct dentry *mic_dbg;
-
-static int mic_smpt_show(struct seq_file *s, void *pos)
-{
-       int i;
-       struct mic_device *mdev = s->private;
-       unsigned long flags;
-
-       seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
-                  mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
-       seq_puts(s, "====================================================\n");
-
-       if (mdev->smpt) {
-               struct mic_smpt_info *smpt_info = mdev->smpt;
-               spin_lock_irqsave(&smpt_info->smpt_lock, flags);
-               for (i = 0; i < smpt_info->info.num_reg; i++) {
-                       seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
-                                  " ",  i, smpt_info->entry[i].dma_addr,
-                                  smpt_info->entry[i].ref_count);
-               }
-               spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
-       }
-       seq_puts(s, "====================================================\n");
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mic_smpt);
-
-static int mic_post_code_show(struct seq_file *s, void *pos)
-{
-       struct mic_device *mdev = s->private;
-       u32 reg = mdev->ops->get_postcode(mdev);
-
-       seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff);
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mic_post_code);
-
-static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
-{
-       struct mic_device *mdev  = s->private;
-       int reg;
-       int i, j;
-       u16 entry;
-       u16 vector;
-       struct pci_dev *pdev = mdev->pdev;
-
-       if (pci_dev_msi_enabled(pdev)) {
-               for (i = 0; i < mdev->irq_info.num_vectors; i++) {
-                       if (pdev->msix_enabled) {
-                               entry = mdev->irq_info.msix_entries[i].entry;
-                               vector = mdev->irq_info.msix_entries[i].vector;
-                       } else {
-                               entry = 0;
-                               vector = pdev->irq;
-                       }
-
-                       reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
-
-                       seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
-                                  "IRQ:", vector, "Entry:", entry, i, reg);
-
-                       seq_printf(s, "%-10s", "offset:");
-                       for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
-                               seq_printf(s, "%4d ", j);
-                       seq_puts(s, "\n");
-
-
-                       seq_printf(s, "%-10s", "count:");
-                       for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
-                               seq_printf(s, "%4d ",
-                                          (mdev->irq_info.mic_msi_map[i] &
-                                          BIT(j)) ? 1 : 0);
-                       seq_puts(s, "\n\n");
-               }
-       } else {
-               seq_puts(s, "MSI/MSIx interrupts not enabled\n");
-       }
-
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(mic_msi_irq_info);
-
-/*
- * mic_create_debug_dir - Initialize MIC debugfs entries.
- */
-void mic_create_debug_dir(struct mic_device *mdev)
-{
-       char name[16];
-
-       if (!mic_dbg)
-               return;
-
-       scnprintf(name, sizeof(name), "mic%d", mdev->id);
-       mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
-
-       debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
-                           &mic_smpt_fops);
-
-       debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
-                           &mic_post_code_fops);
-
-       debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
-                           &mic_msi_irq_info_fops);
-}
-
-/*
- * mic_delete_debug_dir - Uninitialize MIC debugfs entries.
- */
-void mic_delete_debug_dir(struct mic_device *mdev)
-{
-       debugfs_remove_recursive(mdev->dbg_dir);
-}
-
-/*
- * mic_init_debugfs - Initialize global debugfs entry.
- */
-void __init mic_init_debugfs(void)
-{
-       mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-}
-
-/*
- * mic_exit_debugfs - Uninitialize global debugfs entry
- */
-void mic_exit_debugfs(void)
-{
-       debugfs_remove(mic_dbg);
-}
diff --git a/drivers/misc/mic/host/mic_device.h b/drivers/misc/mic/host/mic_device.h
deleted file mode 100644 (file)
index 41bcd30..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#ifndef _MIC_DEVICE_H_
-#define _MIC_DEVICE_H_
-
-#include <linux/cdev.h>
-#include <linux/idr.h>
-#include <linux/notifier.h>
-#include <linux/irqreturn.h>
-#include <linux/dmaengine.h>
-#include <linux/miscdevice.h>
-#include <linux/mic_bus.h>
-#include "../bus/scif_bus.h"
-#include "../bus/vop_bus.h"
-#include "../bus/cosm_bus.h"
-#include "mic_intr.h"
-
-/**
- * enum mic_stepping - MIC stepping ids.
- */
-enum mic_stepping {
-       MIC_A0_STEP = 0x0,
-       MIC_B0_STEP = 0x10,
-       MIC_B1_STEP = 0x11,
-       MIC_C0_STEP = 0x20,
-};
-
-extern struct cosm_hw_ops cosm_hw_ops;
-
-/**
- * struct mic_device -  MIC device information for each card.
- *
- * @mmio: MMIO bar information.
- * @aper: Aperture bar information.
- * @family: The MIC family to which this device belongs.
- * @ops: MIC HW specific operations.
- * @id: The unique device id for this MIC device.
- * @stepping: Stepping ID.
- * @pdev: Underlying PCI device.
- * @mic_mutex: Mutex for synchronizing access to mic_device.
- * @intr_ops: HW specific interrupt operations.
- * @smpt_ops: Hardware specific SMPT operations.
- * @smpt: MIC SMPT information.
- * @intr_info: H/W specific interrupt information.
- * @irq_info: The OS specific irq information
- * @dbg_dir: debugfs directory of this MIC device.
- * @bootaddr: MIC boot address.
- * @dp: virtio device page
- * @dp_dma_addr: virtio device page DMA address.
- * @dma_mbdev: MIC BUS DMA device.
- * @dma_ch - Array of DMA channels
- * @num_dma_ch - Number of DMA channels available
- * @scdev: SCIF device on the SCIF virtual bus.
- * @vpdev: Virtio over PCIe device on the VOP virtual bus.
- * @cosm_dev: COSM device
- */
-struct mic_device {
-       struct mic_mw mmio;
-       struct mic_mw aper;
-       enum mic_hw_family family;
-       struct mic_hw_ops *ops;
-       int id;
-       enum mic_stepping stepping;
-       struct pci_dev *pdev;
-       struct mutex mic_mutex;
-       struct mic_hw_intr_ops *intr_ops;
-       struct mic_smpt_ops *smpt_ops;
-       struct mic_smpt_info *smpt;
-       struct mic_intr_info *intr_info;
-       struct mic_irq_info irq_info;
-       struct dentry *dbg_dir;
-       u32 bootaddr;
-       void *dp;
-       dma_addr_t dp_dma_addr;
-       struct mbus_device *dma_mbdev;
-       struct dma_chan *dma_ch[MIC_MAX_DMA_CHAN];
-       int num_dma_ch;
-       struct scif_hw_dev *scdev;
-       struct vop_device *vpdev;
-       struct cosm_device *cosm_dev;
-};
-
-/**
- * struct mic_hw_ops - MIC HW specific operations.
- * @aper_bar: Aperture bar resource number.
- * @mmio_bar: MMIO bar resource number.
- * @read_spad: Read from scratch pad register.
- * @write_spad: Write to scratch pad register.
- * @send_intr: Send an interrupt for a particular doorbell on the card.
- * @ack_interrupt: Hardware specific operations to ack the h/w on
- * receipt of an interrupt.
- * @intr_workarounds: Hardware specific workarounds needed after
- * handling an interrupt.
- * @reset: Reset the remote processor.
- * @reset_fw_ready: Reset firmware ready field.
- * @is_fw_ready: Check if firmware is ready for OS download.
- * @send_firmware_intr: Send an interrupt to the card firmware.
- * @load_mic_fw: Load firmware segments required to boot the card
- * into card memory. This includes the kernel, command line, ramdisk etc.
- * @get_postcode: Get post code status from firmware.
- * @dma_filter: DMA filter function to be used.
- */
-struct mic_hw_ops {
-       u8 aper_bar;
-       u8 mmio_bar;
-       u32 (*read_spad)(struct mic_device *mdev, unsigned int idx);
-       void (*write_spad)(struct mic_device *mdev, unsigned int idx, u32 val);
-       void (*send_intr)(struct mic_device *mdev, int doorbell);
-       u32 (*ack_interrupt)(struct mic_device *mdev);
-       void (*intr_workarounds)(struct mic_device *mdev);
-       void (*reset)(struct mic_device *mdev);
-       void (*reset_fw_ready)(struct mic_device *mdev);
-       bool (*is_fw_ready)(struct mic_device *mdev);
-       void (*send_firmware_intr)(struct mic_device *mdev);
-       int (*load_mic_fw)(struct mic_device *mdev, const char *buf);
-       u32 (*get_postcode)(struct mic_device *mdev);
-       bool (*dma_filter)(struct dma_chan *chan, void *param);
-};
-
-/**
- * mic_mmio_read - read from an MMIO register.
- * @mw: MMIO register base virtual address.
- * @offset: register offset.
- *
- * RETURNS: register value.
- */
-static inline u32 mic_mmio_read(struct mic_mw *mw, u32 offset)
-{
-       return ioread32(mw->va + offset);
-}
-
-/**
- * mic_mmio_write - write to an MMIO register.
- * @mw: MMIO register base virtual address.
- * @val: the data value to put into the register
- * @offset: register offset.
- *
- * RETURNS: none.
- */
-static inline void
-mic_mmio_write(struct mic_mw *mw, u32 val, u32 offset)
-{
-       iowrite32(val, mw->va + offset);
-}
-
-void mic_bootparam_init(struct mic_device *mdev);
-void mic_create_debug_dir(struct mic_device *dev);
-void mic_delete_debug_dir(struct mic_device *dev);
-void __init mic_init_debugfs(void);
-void mic_exit_debugfs(void);
-#endif
diff --git a/drivers/misc/mic/host/mic_intr.c b/drivers/misc/mic/host/mic_intr.c
deleted file mode 100644 (file)
index 85b3221..0000000
+++ /dev/null
@@ -1,635 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-
-static irqreturn_t mic_thread_fn(int irq, void *dev)
-{
-       struct mic_device *mdev = dev;
-       struct mic_intr_info *intr_info = mdev->intr_info;
-       struct mic_irq_info *irq_info = &mdev->irq_info;
-       struct mic_intr_cb *intr_cb;
-       struct pci_dev *pdev = mdev->pdev;
-       int i;
-
-       spin_lock(&irq_info->mic_thread_lock);
-       for (i = intr_info->intr_start_idx[MIC_INTR_DB];
-                       i < intr_info->intr_len[MIC_INTR_DB]; i++)
-               if (test_and_clear_bit(i, &irq_info->mask)) {
-                       list_for_each_entry(intr_cb, &irq_info->cb_list[i],
-                                           list)
-                               if (intr_cb->thread_fn)
-                                       intr_cb->thread_fn(pdev->irq,
-                                                        intr_cb->data);
-               }
-       spin_unlock(&irq_info->mic_thread_lock);
-       return IRQ_HANDLED;
-}
-/**
- * mic_interrupt - Generic interrupt handler for
- * MSI and INTx based interrupts.
- * @irq:  interrupt to handle (unused)
- * @dev: pointer to the mic_device instance
- */
-static irqreturn_t mic_interrupt(int irq, void *dev)
-{
-       struct mic_device *mdev = dev;
-       struct mic_intr_info *intr_info = mdev->intr_info;
-       struct mic_irq_info *irq_info = &mdev->irq_info;
-       struct mic_intr_cb *intr_cb;
-       struct pci_dev *pdev = mdev->pdev;
-       u32 mask;
-       int i;
-
-       mask = mdev->ops->ack_interrupt(mdev);
-       if (!mask)
-               return IRQ_NONE;
-
-       spin_lock(&irq_info->mic_intr_lock);
-       for (i = intr_info->intr_start_idx[MIC_INTR_DB];
-                       i < intr_info->intr_len[MIC_INTR_DB]; i++)
-               if (mask & BIT(i)) {
-                       list_for_each_entry(intr_cb, &irq_info->cb_list[i],
-                                           list)
-                               if (intr_cb->handler)
-                                       intr_cb->handler(pdev->irq,
-                                                        intr_cb->data);
-                       set_bit(i, &irq_info->mask);
-               }
-       spin_unlock(&irq_info->mic_intr_lock);
-       return IRQ_WAKE_THREAD;
-}
-
-/* Return the interrupt offset from the index. Index is 0 based. */
-static u16 mic_map_src_to_offset(struct mic_device *mdev,
-                                int intr_src, enum mic_intr_type type)
-{
-       if (type >= MIC_NUM_INTR_TYPES)
-               return MIC_NUM_OFFSETS;
-       if (intr_src >= mdev->intr_info->intr_len[type])
-               return MIC_NUM_OFFSETS;
-
-       return mdev->intr_info->intr_start_idx[type] + intr_src;
-}
-
-/* Return next available msix_entry. */
-static struct msix_entry *mic_get_available_vector(struct mic_device *mdev)
-{
-       int i;
-       struct mic_irq_info *info = &mdev->irq_info;
-
-       for (i = 0; i < info->num_vectors; i++)
-               if (!info->mic_msi_map[i])
-                       return &info->msix_entries[i];
-       return NULL;
-}
-
-/**
- * mic_register_intr_callback - Register a callback handler for the
- * given source id.
- *
- * @mdev: pointer to the mic_device instance
- * @idx: The source id to be registered.
- * @handler: The function to be called when the source id receives
- * the interrupt.
- * @thread_fn: thread fn. corresponding to the handler
- * @data: Private data of the requester.
- * Return the callback structure that was registered or an
- * appropriate error on failure.
- */
-static struct mic_intr_cb *mic_register_intr_callback(struct mic_device *mdev,
-                       u8 idx, irq_handler_t handler, irq_handler_t thread_fn,
-                       void *data)
-{
-       struct mic_intr_cb *intr_cb;
-       unsigned long flags;
-       int rc;
-       intr_cb = kmalloc(sizeof(*intr_cb), GFP_KERNEL);
-
-       if (!intr_cb)
-               return ERR_PTR(-ENOMEM);
-
-       intr_cb->handler = handler;
-       intr_cb->thread_fn = thread_fn;
-       intr_cb->data = data;
-       intr_cb->cb_id = ida_simple_get(&mdev->irq_info.cb_ida,
-               0, 0, GFP_KERNEL);
-       if (intr_cb->cb_id < 0) {
-               rc = intr_cb->cb_id;
-               goto ida_fail;
-       }
-
-       spin_lock(&mdev->irq_info.mic_thread_lock);
-       spin_lock_irqsave(&mdev->irq_info.mic_intr_lock, flags);
-       list_add_tail(&intr_cb->list, &mdev->irq_info.cb_list[idx]);
-       spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
-       spin_unlock(&mdev->irq_info.mic_thread_lock);
-
-       return intr_cb;
-ida_fail:
-       kfree(intr_cb);
-       return ERR_PTR(rc);
-}
-
-/**
- * mic_unregister_intr_callback - Unregister the callback handler
- * identified by its callback id.
- *
- * @mdev: pointer to the mic_device instance
- * @idx: The callback structure id to be unregistered.
- * Return the source id that was unregistered or MIC_NUM_OFFSETS if no
- * such callback handler was found.
- */
-static u8 mic_unregister_intr_callback(struct mic_device *mdev, u32 idx)
-{
-       struct list_head *pos, *tmp;
-       struct mic_intr_cb *intr_cb;
-       unsigned long flags;
-       int i;
-
-       spin_lock(&mdev->irq_info.mic_thread_lock);
-       spin_lock_irqsave(&mdev->irq_info.mic_intr_lock, flags);
-       for (i = 0;  i < MIC_NUM_OFFSETS; i++) {
-               list_for_each_safe(pos, tmp, &mdev->irq_info.cb_list[i]) {
-                       intr_cb = list_entry(pos, struct mic_intr_cb, list);
-                       if (intr_cb->cb_id == idx) {
-                               list_del(pos);
-                               ida_simple_remove(&mdev->irq_info.cb_ida,
-                                                 intr_cb->cb_id);
-                               kfree(intr_cb);
-                               spin_unlock_irqrestore(
-                                       &mdev->irq_info.mic_intr_lock, flags);
-                               spin_unlock(&mdev->irq_info.mic_thread_lock);
-                               return i;
-                       }
-               }
-       }
-       spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
-       spin_unlock(&mdev->irq_info.mic_thread_lock);
-       return MIC_NUM_OFFSETS;
-}
-
-/**
- * mic_setup_msix - Initializes MSIx interrupts.
- *
- * @mdev: pointer to mic_device instance
- * @pdev: PCI device structure
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int mic_setup_msix(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       int rc, i;
-       int entry_size = sizeof(*mdev->irq_info.msix_entries);
-
-       mdev->irq_info.msix_entries = kmalloc_array(MIC_MIN_MSIX,
-                                                   entry_size, GFP_KERNEL);
-       if (!mdev->irq_info.msix_entries) {
-               rc = -ENOMEM;
-               goto err_nomem1;
-       }
-
-       for (i = 0; i < MIC_MIN_MSIX; i++)
-               mdev->irq_info.msix_entries[i].entry = i;
-
-       rc = pci_enable_msix_exact(pdev, mdev->irq_info.msix_entries,
-                                  MIC_MIN_MSIX);
-       if (rc) {
-               dev_dbg(&pdev->dev, "Error enabling MSIx. rc = %d\n", rc);
-               goto err_enable_msix;
-       }
-
-       mdev->irq_info.num_vectors = MIC_MIN_MSIX;
-       mdev->irq_info.mic_msi_map = kzalloc((sizeof(u32) *
-               mdev->irq_info.num_vectors), GFP_KERNEL);
-
-       if (!mdev->irq_info.mic_msi_map) {
-               rc = -ENOMEM;
-               goto err_nomem2;
-       }
-
-       dev_dbg(&mdev->pdev->dev,
-               "%d MSIx irqs setup\n", mdev->irq_info.num_vectors);
-       return 0;
-err_nomem2:
-       pci_disable_msix(pdev);
-err_enable_msix:
-       kfree(mdev->irq_info.msix_entries);
-err_nomem1:
-       mdev->irq_info.num_vectors = 0;
-       return rc;
-}
-
-/**
- * mic_setup_callbacks - Initialize data structures needed
- * to handle callbacks.
- *
- * @mdev: pointer to mic_device instance
- */
-static int mic_setup_callbacks(struct mic_device *mdev)
-{
-       int i;
-
-       mdev->irq_info.cb_list = kmalloc_array(MIC_NUM_OFFSETS,
-                                              sizeof(*mdev->irq_info.cb_list),
-                                              GFP_KERNEL);
-       if (!mdev->irq_info.cb_list)
-               return -ENOMEM;
-
-       for (i = 0; i < MIC_NUM_OFFSETS; i++)
-               INIT_LIST_HEAD(&mdev->irq_info.cb_list[i]);
-       ida_init(&mdev->irq_info.cb_ida);
-       spin_lock_init(&mdev->irq_info.mic_intr_lock);
-       spin_lock_init(&mdev->irq_info.mic_thread_lock);
-       return 0;
-}
-
-/**
- * mic_release_callbacks - Uninitialize data structures needed
- * to handle callbacks.
- *
- * @mdev: pointer to mic_device instance
- */
-static void mic_release_callbacks(struct mic_device *mdev)
-{
-       unsigned long flags;
-       struct list_head *pos, *tmp;
-       struct mic_intr_cb *intr_cb;
-       int i;
-
-       spin_lock(&mdev->irq_info.mic_thread_lock);
-       spin_lock_irqsave(&mdev->irq_info.mic_intr_lock, flags);
-       for (i = 0; i < MIC_NUM_OFFSETS; i++) {
-               if (list_empty(&mdev->irq_info.cb_list[i]))
-                       break;
-
-               list_for_each_safe(pos, tmp, &mdev->irq_info.cb_list[i]) {
-                       intr_cb = list_entry(pos, struct mic_intr_cb, list);
-                       list_del(pos);
-                       ida_simple_remove(&mdev->irq_info.cb_ida,
-                                         intr_cb->cb_id);
-                       kfree(intr_cb);
-               }
-       }
-       spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
-       spin_unlock(&mdev->irq_info.mic_thread_lock);
-       ida_destroy(&mdev->irq_info.cb_ida);
-       kfree(mdev->irq_info.cb_list);
-}
-
-/**
- * mic_setup_msi - Initializes MSI interrupts.
- *
- * @mdev: pointer to mic_device instance
- * @pdev: PCI device structure
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int mic_setup_msi(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       int rc;
-
-       rc = pci_enable_msi(pdev);
-       if (rc) {
-               dev_dbg(&pdev->dev, "Error enabling MSI. rc = %d\n", rc);
-               return rc;
-       }
-
-       mdev->irq_info.num_vectors = 1;
-       mdev->irq_info.mic_msi_map = kzalloc((sizeof(u32) *
-               mdev->irq_info.num_vectors), GFP_KERNEL);
-
-       if (!mdev->irq_info.mic_msi_map) {
-               rc = -ENOMEM;
-               goto err_nomem1;
-       }
-
-       rc = mic_setup_callbacks(mdev);
-       if (rc) {
-               dev_err(&pdev->dev, "Error setting up callbacks\n");
-               goto err_nomem2;
-       }
-
-       rc = request_threaded_irq(pdev->irq, mic_interrupt, mic_thread_fn,
-                                 0, "mic-msi", mdev);
-       if (rc) {
-               dev_err(&pdev->dev, "Error allocating MSI interrupt\n");
-               goto err_irq_req_fail;
-       }
-
-       dev_dbg(&pdev->dev, "%d MSI irqs setup\n", mdev->irq_info.num_vectors);
-       return 0;
-err_irq_req_fail:
-       mic_release_callbacks(mdev);
-err_nomem2:
-       kfree(mdev->irq_info.mic_msi_map);
-err_nomem1:
-       pci_disable_msi(pdev);
-       mdev->irq_info.num_vectors = 0;
-       return rc;
-}
-
-/**
- * mic_setup_intx - Initializes legacy interrupts.
- *
- * @mdev: pointer to mic_device instance
- * @pdev: PCI device structure
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int mic_setup_intx(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       int rc;
-
-       /* Enable intx */
-       pci_intx(pdev, 1);
-       rc = mic_setup_callbacks(mdev);
-       if (rc) {
-               dev_err(&pdev->dev, "Error setting up callbacks\n");
-               goto err_nomem;
-       }
-
-       rc = request_threaded_irq(pdev->irq, mic_interrupt, mic_thread_fn,
-                                 IRQF_SHARED, "mic-intx", mdev);
-       if (rc)
-               goto err;
-
-       dev_dbg(&pdev->dev, "intx irq setup\n");
-       return 0;
-err:
-       mic_release_callbacks(mdev);
-err_nomem:
-       return rc;
-}
-
-/**
- * mic_next_db - Retrieve the next doorbell interrupt source id.
- * The id is picked sequentially from the available pool of
- * doorlbell ids.
- *
- * @mdev: pointer to the mic_device instance.
- *
- * Returns the next doorbell interrupt source.
- */
-int mic_next_db(struct mic_device *mdev)
-{
-       int next_db;
-
-       next_db = mdev->irq_info.next_avail_src %
-               mdev->intr_info->intr_len[MIC_INTR_DB];
-       mdev->irq_info.next_avail_src++;
-       return next_db;
-}
-
-#define COOKIE_ID_SHIFT 16
-#define GET_ENTRY(cookie) ((cookie) & 0xFFFF)
-#define GET_OFFSET(cookie) ((cookie) >> COOKIE_ID_SHIFT)
-#define MK_COOKIE(x, y) ((x) | (y) << COOKIE_ID_SHIFT)
-
-/**
- * mic_request_threaded_irq - request an irq. mic_mutex needs
- * to be held before calling this function.
- *
- * @mdev: pointer to mic_device instance
- * @handler: The callback function that handles the interrupt.
- * The function needs to call ack_interrupts
- * (mdev->ops->ack_interrupt(mdev)) when handling the interrupts.
- * @thread_fn: thread fn required by request_threaded_irq.
- * @name: The ASCII name of the callee requesting the irq.
- * @data: private data that is returned back when calling the
- * function handler.
- * @intr_src: The source id of the requester. Its the doorbell id
- * for Doorbell interrupts and DMA channel id for DMA interrupts.
- * @type: The type of interrupt. Values defined in mic_intr_type
- *
- * returns: The cookie that is transparent to the caller. Passed
- * back when calling mic_free_irq. An appropriate error code
- * is returned on failure. Caller needs to use IS_ERR(return_val)
- * to check for failure and PTR_ERR(return_val) to obtained the
- * error code.
- *
- */
-struct mic_irq *
-mic_request_threaded_irq(struct mic_device *mdev,
-                        irq_handler_t handler, irq_handler_t thread_fn,
-                        const char *name, void *data, int intr_src,
-                        enum mic_intr_type type)
-{
-       u16 offset;
-       int rc = 0;
-       struct msix_entry *msix = NULL;
-       unsigned long cookie = 0;
-       u16 entry;
-       struct mic_intr_cb *intr_cb;
-       struct pci_dev *pdev = mdev->pdev;
-
-       offset = mic_map_src_to_offset(mdev, intr_src, type);
-       if (offset >= MIC_NUM_OFFSETS) {
-               dev_err(&mdev->pdev->dev,
-                       "Error mapping index %d to a valid source id.\n",
-                       intr_src);
-               rc = -EINVAL;
-               goto err;
-       }
-
-       if (mdev->irq_info.num_vectors > 1) {
-               msix = mic_get_available_vector(mdev);
-               if (!msix) {
-                       dev_err(&mdev->pdev->dev,
-                               "No MSIx vectors available for use.\n");
-                       rc = -ENOSPC;
-                       goto err;
-               }
-
-               rc = request_threaded_irq(msix->vector, handler, thread_fn,
-                                         0, name, data);
-               if (rc) {
-                       dev_dbg(&mdev->pdev->dev,
-                               "request irq failed rc = %d\n", rc);
-                       goto err;
-               }
-               entry = msix->entry;
-               mdev->irq_info.mic_msi_map[entry] |= BIT(offset);
-               mdev->intr_ops->program_msi_to_src_map(mdev,
-                               entry, offset, true);
-               cookie = MK_COOKIE(entry, offset);
-               dev_dbg(&mdev->pdev->dev, "irq: %d assigned for src: %d\n",
-                       msix->vector, intr_src);
-       } else {
-               intr_cb = mic_register_intr_callback(mdev, offset, handler,
-                                                    thread_fn, data);
-               if (IS_ERR(intr_cb)) {
-                       dev_err(&mdev->pdev->dev,
-                               "No available callback entries for use\n");
-                       rc = PTR_ERR(intr_cb);
-                       goto err;
-               }
-
-               entry = 0;
-               if (pci_dev_msi_enabled(pdev)) {
-                       mdev->irq_info.mic_msi_map[entry] |= (1 << offset);
-                       mdev->intr_ops->program_msi_to_src_map(mdev,
-                               entry, offset, true);
-               }
-               cookie = MK_COOKIE(entry, intr_cb->cb_id);
-               dev_dbg(&mdev->pdev->dev, "callback %d registered for src: %d\n",
-                       intr_cb->cb_id, intr_src);
-       }
-       return (struct mic_irq *)cookie;
-err:
-       return ERR_PTR(rc);
-}
-
-/**
- * mic_free_irq - free irq. mic_mutex
- *  needs to be held before calling this function.
- *
- * @mdev: pointer to mic_device instance
- * @cookie: cookie obtained during a successful call to mic_request_threaded_irq
- * @data: private data specified by the calling function during the
- * mic_request_threaded_irq
- *
- * returns: none.
- */
-void mic_free_irq(struct mic_device *mdev,
-                 struct mic_irq *cookie, void *data)
-{
-       u32 offset;
-       u32 entry;
-       u8 src_id;
-       unsigned int irq;
-       struct pci_dev *pdev = mdev->pdev;
-
-       entry = GET_ENTRY((unsigned long)cookie);
-       offset = GET_OFFSET((unsigned long)cookie);
-       if (mdev->irq_info.num_vectors > 1) {
-               if (entry >= mdev->irq_info.num_vectors) {
-                       dev_warn(&mdev->pdev->dev,
-                                "entry %d should be < num_irq %d\n",
-                               entry, mdev->irq_info.num_vectors);
-                       return;
-               }
-               irq = mdev->irq_info.msix_entries[entry].vector;
-               free_irq(irq, data);
-               mdev->irq_info.mic_msi_map[entry] &= ~(BIT(offset));
-               mdev->intr_ops->program_msi_to_src_map(mdev,
-                       entry, offset, false);
-
-               dev_dbg(&mdev->pdev->dev, "irq: %d freed\n", irq);
-       } else {
-               irq = pdev->irq;
-               src_id = mic_unregister_intr_callback(mdev, offset);
-               if (src_id >= MIC_NUM_OFFSETS) {
-                       dev_warn(&mdev->pdev->dev, "Error unregistering callback\n");
-                       return;
-               }
-               if (pci_dev_msi_enabled(pdev)) {
-                       mdev->irq_info.mic_msi_map[entry] &= ~(BIT(src_id));
-                       mdev->intr_ops->program_msi_to_src_map(mdev,
-                               entry, src_id, false);
-               }
-               dev_dbg(&mdev->pdev->dev, "callback %d unregistered for src: %d\n",
-                       offset, src_id);
-       }
-}
-
-/**
- * mic_setup_interrupts - Initializes interrupts.
- *
- * @mdev: pointer to mic_device instance
- * @pdev: PCI device structure
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-int mic_setup_interrupts(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       int rc;
-
-       rc = mic_setup_msix(mdev, pdev);
-       if (!rc)
-               goto done;
-
-       rc = mic_setup_msi(mdev, pdev);
-       if (!rc)
-               goto done;
-
-       rc = mic_setup_intx(mdev, pdev);
-       if (rc) {
-               dev_err(&mdev->pdev->dev, "no usable interrupts\n");
-               return rc;
-       }
-done:
-       mdev->intr_ops->enable_interrupts(mdev);
-       return 0;
-}
-
-/**
- * mic_free_interrupts - Frees interrupts setup by mic_setup_interrupts
- *
- * @mdev: pointer to mic_device instance
- * @pdev: PCI device structure
- *
- * returns none.
- */
-void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       int i;
-
-       mdev->intr_ops->disable_interrupts(mdev);
-       if (mdev->irq_info.num_vectors > 1) {
-               for (i = 0; i < mdev->irq_info.num_vectors; i++) {
-                       if (mdev->irq_info.mic_msi_map[i])
-                               dev_warn(&pdev->dev, "irq %d may still be in use.\n",
-                                        mdev->irq_info.msix_entries[i].vector);
-               }
-               kfree(mdev->irq_info.mic_msi_map);
-               kfree(mdev->irq_info.msix_entries);
-               pci_disable_msix(pdev);
-       } else {
-               if (pci_dev_msi_enabled(pdev)) {
-                       free_irq(pdev->irq, mdev);
-                       kfree(mdev->irq_info.mic_msi_map);
-                       pci_disable_msi(pdev);
-               } else {
-                       free_irq(pdev->irq, mdev);
-               }
-               mic_release_callbacks(mdev);
-       }
-}
-
-/**
- * mic_intr_restore - Restore MIC interrupt registers.
- *
- * @mdev: pointer to mic_device instance.
- *
- * Restore the interrupt registers to values previously
- * stored in the SW data structures. mic_mutex needs to
- * be held before calling this function.
- *
- * returns None.
- */
-void mic_intr_restore(struct mic_device *mdev)
-{
-       int entry, offset;
-       struct pci_dev *pdev = mdev->pdev;
-
-       if (!pci_dev_msi_enabled(pdev))
-               return;
-
-       for (entry = 0; entry < mdev->irq_info.num_vectors; entry++) {
-               for (offset = 0; offset < MIC_NUM_OFFSETS; offset++) {
-                       if (mdev->irq_info.mic_msi_map[entry] & BIT(offset))
-                               mdev->intr_ops->program_msi_to_src_map(mdev,
-                                       entry, offset, true);
-               }
-       }
-}
diff --git a/drivers/misc/mic/host/mic_intr.h b/drivers/misc/mic/host/mic_intr.h
deleted file mode 100644 (file)
index b14ba81..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#ifndef _MIC_INTR_H_
-#define _MIC_INTR_H_
-
-#include <linux/bitops.h>
-#include <linux/interrupt.h>
-/*
- * The minimum number of msix vectors required for normal operation.
- * 3 for virtio network, console and block devices.
- * 1 for card shutdown notifications.
- * 4 for host owned DMA channels.
- * 1 for SCIF
- */
-#define MIC_MIN_MSIX 9
-#define MIC_NUM_OFFSETS 32
-
-/**
- * mic_intr_source - The type of source that will generate
- * the interrupt.The number of types needs to be in sync with
- * MIC_NUM_INTR_TYPES
- *
- * MIC_INTR_DB: The source is a doorbell
- * MIC_INTR_DMA: The source is a DMA channel
- * MIC_INTR_ERR: The source is an error interrupt e.g. SBOX ERR
- * MIC_NUM_INTR_TYPES: Total number of interrupt sources.
- */
-enum mic_intr_type {
-       MIC_INTR_DB = 0,
-       MIC_INTR_DMA,
-       MIC_INTR_ERR,
-       MIC_NUM_INTR_TYPES
-};
-
-/**
- * struct mic_intr_info - Contains h/w specific interrupt sources
- * information.
- *
- * @intr_start_idx: Contains the starting indexes of the
- * interrupt types.
- * @intr_len: Contains the length of the interrupt types.
- */
-struct mic_intr_info {
-       u16 intr_start_idx[MIC_NUM_INTR_TYPES];
-       u16 intr_len[MIC_NUM_INTR_TYPES];
-};
-
-/**
- * struct mic_irq_info - OS specific irq information
- *
- * @next_avail_src: next available doorbell that can be assigned.
- * @msix_entries: msix entries allocated while setting up MSI-x
- * @mic_msi_map: The MSI/MSI-x mapping information.
- * @num_vectors: The number of MSI/MSI-x vectors that have been allocated.
- * @cb_ida: callback ID allocator to track the callbacks registered.
- * @mic_intr_lock: spinlock to protect the interrupt callback list.
- * @mic_thread_lock: spinlock to protect the thread callback list.
- *                This lock is used to protect against thread_fn while
- *                mic_intr_lock is used to protect against interrupt handler.
- * @cb_list: Array of callback lists one for each source.
- * @mask: Mask used by the main thread fn to call the underlying thread fns.
- */
-struct mic_irq_info {
-       int next_avail_src;
-       struct msix_entry *msix_entries;
-       u32 *mic_msi_map;
-       u16 num_vectors;
-       struct ida cb_ida;
-       spinlock_t mic_intr_lock;
-       spinlock_t mic_thread_lock;
-       struct list_head *cb_list;
-       unsigned long mask;
-};
-
-/**
- * struct mic_intr_cb - Interrupt callback structure.
- *
- * @handler: The callback function
- * @thread_fn: The thread_fn.
- * @data: Private data of the requester.
- * @cb_id: The callback id. Identifies this callback.
- * @list: list head pointing to the next callback structure.
- */
-struct mic_intr_cb {
-       irq_handler_t handler;
-       irq_handler_t thread_fn;
-       void *data;
-       int cb_id;
-       struct list_head list;
-};
-
-/**
- * struct mic_irq - opaque pointer used as cookie
- */
-struct mic_irq;
-
-/* Forward declaration */
-struct mic_device;
-
-/**
- * struct mic_hw_intr_ops: MIC HW specific interrupt operations
- * @intr_init: Initialize H/W specific interrupt information.
- * @enable_interrupts: Enable interrupts from the hardware.
- * @disable_interrupts: Disable interrupts from the hardware.
- * @program_msi_to_src_map: Update MSI mapping registers with
- * irq information.
- * @read_msi_to_src_map: Read MSI mapping registers containing
- * irq information.
- */
-struct mic_hw_intr_ops {
-       void (*intr_init)(struct mic_device *mdev);
-       void (*enable_interrupts)(struct mic_device *mdev);
-       void (*disable_interrupts)(struct mic_device *mdev);
-       void (*program_msi_to_src_map) (struct mic_device *mdev,
-                       int idx, int intr_src, bool set);
-       u32 (*read_msi_to_src_map) (struct mic_device *mdev,
-                       int idx);
-};
-
-int mic_next_db(struct mic_device *mdev);
-struct mic_irq *
-mic_request_threaded_irq(struct mic_device *mdev,
-                        irq_handler_t handler, irq_handler_t thread_fn,
-                        const char *name, void *data, int intr_src,
-                        enum mic_intr_type type);
-void mic_free_irq(struct mic_device *mdev,
-               struct mic_irq *cookie, void *data);
-int mic_setup_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
-void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
-void mic_intr_restore(struct mic_device *mdev);
-#endif
diff --git a/drivers/misc/mic/host/mic_main.c b/drivers/misc/mic/host/mic_main.c
deleted file mode 100644 (file)
index ea46085..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/poll.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_x100.h"
-#include "mic_smpt.h"
-
-static const char mic_driver_name[] = "mic";
-
-static const struct pci_device_id mic_pci_tbl[] = {
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2250)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2251)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2252)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2253)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2254)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2255)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2256)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2257)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2258)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_2259)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_225a)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_225b)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_225c)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_225d)},
-       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MIC_X100_PCI_DEVICE_225e)},
-
-       /* required last entry */
-       { 0, }
-};
-
-MODULE_DEVICE_TABLE(pci, mic_pci_tbl);
-
-/* ID allocator for MIC devices */
-static struct ida g_mic_ida;
-
-/* Initialize the device page */
-static int mic_dp_init(struct mic_device *mdev)
-{
-       mdev->dp = kzalloc(MIC_DP_SIZE, GFP_KERNEL);
-       if (!mdev->dp)
-               return -ENOMEM;
-
-       mdev->dp_dma_addr = mic_map_single(mdev,
-               mdev->dp, MIC_DP_SIZE);
-       if (mic_map_error(mdev->dp_dma_addr)) {
-               kfree(mdev->dp);
-               dev_err(&mdev->pdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, -ENOMEM);
-               return -ENOMEM;
-       }
-       mdev->ops->write_spad(mdev, MIC_DPLO_SPAD, mdev->dp_dma_addr);
-       mdev->ops->write_spad(mdev, MIC_DPHI_SPAD, mdev->dp_dma_addr >> 32);
-       return 0;
-}
-
-/* Uninitialize the device page */
-static void mic_dp_uninit(struct mic_device *mdev)
-{
-       mic_unmap_single(mdev, mdev->dp_dma_addr, MIC_DP_SIZE);
-       kfree(mdev->dp);
-}
-
-/**
- * mic_ops_init: Initialize HW specific operation tables.
- *
- * @mdev: pointer to mic_device instance
- *
- * returns none.
- */
-static void mic_ops_init(struct mic_device *mdev)
-{
-       switch (mdev->family) {
-       case MIC_FAMILY_X100:
-               mdev->ops = &mic_x100_ops;
-               mdev->intr_ops = &mic_x100_intr_ops;
-               mdev->smpt_ops = &mic_x100_smpt_ops;
-               break;
-       default:
-               break;
-       }
-}
-
-/**
- * mic_get_family - Determine hardware family to which this MIC belongs.
- *
- * @pdev: The pci device structure
- *
- * returns family.
- */
-static enum mic_hw_family mic_get_family(struct pci_dev *pdev)
-{
-       enum mic_hw_family family;
-
-       switch (pdev->device) {
-       case MIC_X100_PCI_DEVICE_2250:
-       case MIC_X100_PCI_DEVICE_2251:
-       case MIC_X100_PCI_DEVICE_2252:
-       case MIC_X100_PCI_DEVICE_2253:
-       case MIC_X100_PCI_DEVICE_2254:
-       case MIC_X100_PCI_DEVICE_2255:
-       case MIC_X100_PCI_DEVICE_2256:
-       case MIC_X100_PCI_DEVICE_2257:
-       case MIC_X100_PCI_DEVICE_2258:
-       case MIC_X100_PCI_DEVICE_2259:
-       case MIC_X100_PCI_DEVICE_225a:
-       case MIC_X100_PCI_DEVICE_225b:
-       case MIC_X100_PCI_DEVICE_225c:
-       case MIC_X100_PCI_DEVICE_225d:
-       case MIC_X100_PCI_DEVICE_225e:
-               family = MIC_FAMILY_X100;
-               break;
-       default:
-               family = MIC_FAMILY_UNKNOWN;
-               break;
-       }
-       return family;
-}
-
-/**
- * mic_device_init - Allocates and initializes the MIC device structure
- *
- * @mdev: pointer to mic_device instance
- * @pdev: The pci device structure
- *
- * returns none.
- */
-static void
-mic_device_init(struct mic_device *mdev, struct pci_dev *pdev)
-{
-       mdev->pdev = pdev;
-       mdev->family = mic_get_family(pdev);
-       mdev->stepping = pdev->revision;
-       mic_ops_init(mdev);
-       mutex_init(&mdev->mic_mutex);
-       mdev->irq_info.next_avail_src = 0;
-}
-
-/**
- * mic_probe - Device Initialization Routine
- *
- * @pdev: PCI device structure
- * @ent: entry in mic_pci_tbl
- *
- * returns 0 on success, < 0 on failure.
- */
-static int mic_probe(struct pci_dev *pdev,
-                    const struct pci_device_id *ent)
-{
-       int rc;
-       struct mic_device *mdev;
-
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
-       if (!mdev) {
-               rc = -ENOMEM;
-               goto mdev_alloc_fail;
-       }
-       mdev->id = ida_simple_get(&g_mic_ida, 0, MIC_MAX_NUM_DEVS, GFP_KERNEL);
-       if (mdev->id < 0) {
-               rc = mdev->id;
-               dev_err(&pdev->dev, "ida_simple_get failed rc %d\n", rc);
-               goto ida_fail;
-       }
-
-       mic_device_init(mdev, pdev);
-
-       rc = pci_enable_device(pdev);
-       if (rc) {
-               dev_err(&pdev->dev, "failed to enable pci device.\n");
-               goto ida_remove;
-       }
-
-       pci_set_master(pdev);
-
-       rc = pci_request_regions(pdev, mic_driver_name);
-       if (rc) {
-               dev_err(&pdev->dev, "failed to get pci regions.\n");
-               goto disable_device;
-       }
-
-       rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(64));
-       if (rc) {
-               dev_err(&pdev->dev, "Cannot set DMA mask\n");
-               goto release_regions;
-       }
-
-       mdev->mmio.pa = pci_resource_start(pdev, mdev->ops->mmio_bar);
-       mdev->mmio.len = pci_resource_len(pdev, mdev->ops->mmio_bar);
-       mdev->mmio.va = pci_ioremap_bar(pdev, mdev->ops->mmio_bar);
-       if (!mdev->mmio.va) {
-               dev_err(&pdev->dev, "Cannot remap MMIO BAR\n");
-               rc = -EIO;
-               goto release_regions;
-       }
-
-       mdev->aper.pa = pci_resource_start(pdev, mdev->ops->aper_bar);
-       mdev->aper.len = pci_resource_len(pdev, mdev->ops->aper_bar);
-       mdev->aper.va = ioremap_wc(mdev->aper.pa, mdev->aper.len);
-       if (!mdev->aper.va) {
-               dev_err(&pdev->dev, "Cannot remap Aperture BAR\n");
-               rc = -EIO;
-               goto unmap_mmio;
-       }
-
-       mdev->intr_ops->intr_init(mdev);
-       rc = mic_setup_interrupts(mdev, pdev);
-       if (rc) {
-               dev_err(&pdev->dev, "mic_setup_interrupts failed %d\n", rc);
-               goto unmap_aper;
-       }
-       rc = mic_smpt_init(mdev);
-       if (rc) {
-               dev_err(&pdev->dev, "smpt_init failed %d\n", rc);
-               goto free_interrupts;
-       }
-
-       pci_set_drvdata(pdev, mdev);
-
-       rc = mic_dp_init(mdev);
-       if (rc) {
-               dev_err(&pdev->dev, "mic_dp_init failed rc %d\n", rc);
-               goto smpt_uninit;
-       }
-       mic_bootparam_init(mdev);
-       mic_create_debug_dir(mdev);
-
-       mdev->cosm_dev = cosm_register_device(&mdev->pdev->dev, &cosm_hw_ops);
-       if (IS_ERR(mdev->cosm_dev)) {
-               rc = PTR_ERR(mdev->cosm_dev);
-               dev_err(&pdev->dev, "cosm_add_device failed rc %d\n", rc);
-               goto cleanup_debug_dir;
-       }
-       return 0;
-cleanup_debug_dir:
-       mic_delete_debug_dir(mdev);
-       mic_dp_uninit(mdev);
-smpt_uninit:
-       mic_smpt_uninit(mdev);
-free_interrupts:
-       mic_free_interrupts(mdev, pdev);
-unmap_aper:
-       iounmap(mdev->aper.va);
-unmap_mmio:
-       iounmap(mdev->mmio.va);
-release_regions:
-       pci_release_regions(pdev);
-disable_device:
-       pci_disable_device(pdev);
-ida_remove:
-       ida_simple_remove(&g_mic_ida, mdev->id);
-ida_fail:
-       kfree(mdev);
-mdev_alloc_fail:
-       dev_err(&pdev->dev, "Probe failed rc %d\n", rc);
-       return rc;
-}
-
-/**
- * mic_remove - Device Removal Routine
- * mic_remove is called by the PCI subsystem to alert the driver
- * that it should release a PCI device.
- *
- * @pdev: PCI device structure
- */
-static void mic_remove(struct pci_dev *pdev)
-{
-       struct mic_device *mdev;
-
-       mdev = pci_get_drvdata(pdev);
-       if (!mdev)
-               return;
-
-       cosm_unregister_device(mdev->cosm_dev);
-       mic_delete_debug_dir(mdev);
-       mic_dp_uninit(mdev);
-       mic_smpt_uninit(mdev);
-       mic_free_interrupts(mdev, pdev);
-       iounmap(mdev->aper.va);
-       iounmap(mdev->mmio.va);
-       pci_release_regions(pdev);
-       pci_disable_device(pdev);
-       ida_simple_remove(&g_mic_ida, mdev->id);
-       kfree(mdev);
-}
-
-static struct pci_driver mic_driver = {
-       .name = mic_driver_name,
-       .id_table = mic_pci_tbl,
-       .probe = mic_probe,
-       .remove = mic_remove
-};
-
-static int __init mic_init(void)
-{
-       int ret;
-
-       request_module("mic_x100_dma");
-       mic_init_debugfs();
-       ida_init(&g_mic_ida);
-       ret = pci_register_driver(&mic_driver);
-       if (ret) {
-               pr_err("pci_register_driver failed ret %d\n", ret);
-               goto cleanup_debugfs;
-       }
-       return 0;
-cleanup_debugfs:
-       ida_destroy(&g_mic_ida);
-       mic_exit_debugfs();
-       return ret;
-}
-
-static void __exit mic_exit(void)
-{
-       pci_unregister_driver(&mic_driver);
-       ida_destroy(&g_mic_ida);
-       mic_exit_debugfs();
-}
-
-module_init(mic_init);
-module_exit(mic_exit);
-
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) MIC X100 Host driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/host/mic_smpt.c b/drivers/misc/mic/host/mic_smpt.c
deleted file mode 100644 (file)
index 50d1beb..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/pci.h>
-
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_smpt.h"
-
-static inline u64 mic_system_page_mask(struct mic_device *mdev)
-{
-       return (1ULL << mdev->smpt->info.page_shift) - 1ULL;
-}
-
-static inline u8 mic_sys_addr_to_smpt(struct mic_device *mdev, dma_addr_t pa)
-{
-       return (pa - mdev->smpt->info.base) >> mdev->smpt->info.page_shift;
-}
-
-static inline u64 mic_smpt_to_pa(struct mic_device *mdev, u8 index)
-{
-       return mdev->smpt->info.base + (index * mdev->smpt->info.page_size);
-}
-
-static inline u64 mic_smpt_offset(struct mic_device *mdev, dma_addr_t pa)
-{
-       return pa & mic_system_page_mask(mdev);
-}
-
-static inline u64 mic_smpt_align_low(struct mic_device *mdev, dma_addr_t pa)
-{
-       return ALIGN(pa - mic_system_page_mask(mdev),
-               mdev->smpt->info.page_size);
-}
-
-static inline u64 mic_smpt_align_high(struct mic_device *mdev, dma_addr_t pa)
-{
-       return ALIGN(pa, mdev->smpt->info.page_size);
-}
-
-/* Total Cumulative system memory accessible by MIC across all SMPT entries */
-static inline u64 mic_max_system_memory(struct mic_device *mdev)
-{
-       return mdev->smpt->info.num_reg * mdev->smpt->info.page_size;
-}
-
-/* Maximum system memory address accessible by MIC */
-static inline u64 mic_max_system_addr(struct mic_device *mdev)
-{
-       return mdev->smpt->info.base + mic_max_system_memory(mdev) - 1ULL;
-}
-
-/* Check if the DMA address is a MIC system memory address */
-static inline bool
-mic_is_system_addr(struct mic_device *mdev, dma_addr_t pa)
-{
-       return pa >= mdev->smpt->info.base && pa <= mic_max_system_addr(mdev);
-}
-
-/* Populate an SMPT entry and update the reference counts. */
-static void mic_add_smpt_entry(int spt, s64 *ref, u64 addr,
-                              int entries, struct mic_device *mdev)
-{
-       struct mic_smpt_info *smpt_info = mdev->smpt;
-       int i;
-
-       for (i = spt; i < spt + entries; i++,
-               addr += smpt_info->info.page_size) {
-               if (!smpt_info->entry[i].ref_count &&
-                   (smpt_info->entry[i].dma_addr != addr)) {
-                       mdev->smpt_ops->set(mdev, addr, i);
-                       smpt_info->entry[i].dma_addr = addr;
-               }
-               smpt_info->entry[i].ref_count += ref[i - spt];
-       }
-}
-
-/*
- * Find an available MIC address in MIC SMPT address space
- * for a given DMA address and size.
- */
-static dma_addr_t mic_smpt_op(struct mic_device *mdev, u64 dma_addr,
-                             int entries, s64 *ref, size_t size)
-{
-       int spt;
-       int ae = 0;
-       int i;
-       unsigned long flags;
-       dma_addr_t mic_addr = 0;
-       dma_addr_t addr = dma_addr;
-       struct mic_smpt_info *smpt_info = mdev->smpt;
-
-       spin_lock_irqsave(&smpt_info->smpt_lock, flags);
-
-       /* find existing entries */
-       for (i = 0; i < smpt_info->info.num_reg; i++) {
-               if (smpt_info->entry[i].dma_addr == addr) {
-                       ae++;
-                       addr += smpt_info->info.page_size;
-               } else if (ae) /* cannot find contiguous entries */
-                       goto not_found;
-
-               if (ae == entries)
-                       goto found;
-       }
-
-       /* find free entry */
-       for (ae = 0, i = 0; i < smpt_info->info.num_reg; i++) {
-               ae = (smpt_info->entry[i].ref_count == 0) ? ae + 1 : 0;
-               if (ae == entries)
-                       goto found;
-       }
-
-not_found:
-       spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
-       return mic_addr;
-
-found:
-       spt = i - entries + 1;
-       mic_addr = mic_smpt_to_pa(mdev, spt);
-       mic_add_smpt_entry(spt, ref, dma_addr, entries, mdev);
-       smpt_info->map_count++;
-       smpt_info->ref_count += (s64)size;
-       spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
-       return mic_addr;
-}
-
-/*
- * Returns number of smpt entries needed for dma_addr to dma_addr + size
- * also returns the reference count array for each of those entries
- * and the starting smpt address
- */
-static int mic_get_smpt_ref_count(struct mic_device *mdev, dma_addr_t dma_addr,
-                                 size_t size, s64 *ref,  u64 *smpt_start)
-{
-       u64 start =  dma_addr;
-       u64 end = dma_addr + size;
-       int i = 0;
-
-       while (start < end) {
-               ref[i++] = min(mic_smpt_align_high(mdev, start + 1),
-                       end) - start;
-               start = mic_smpt_align_high(mdev, start + 1);
-       }
-
-       if (smpt_start)
-               *smpt_start = mic_smpt_align_low(mdev, dma_addr);
-
-       return i;
-}
-
-/*
- * mic_to_dma_addr - Converts a MIC address to a DMA address.
- *
- * @mdev: pointer to mic_device instance.
- * @mic_addr: MIC address.
- *
- * returns a DMA address.
- */
-dma_addr_t mic_to_dma_addr(struct mic_device *mdev, dma_addr_t mic_addr)
-{
-       struct mic_smpt_info *smpt_info = mdev->smpt;
-       int spt;
-       dma_addr_t dma_addr;
-
-       if (!mic_is_system_addr(mdev, mic_addr)) {
-               dev_err(&mdev->pdev->dev,
-                       "mic_addr is invalid. mic_addr = 0x%llx\n", mic_addr);
-               return -EINVAL;
-       }
-       spt = mic_sys_addr_to_smpt(mdev, mic_addr);
-       dma_addr = smpt_info->entry[spt].dma_addr +
-               mic_smpt_offset(mdev, mic_addr);
-       return dma_addr;
-}
-
-/**
- * mic_map - Maps a DMA address to a MIC physical address.
- *
- * @mdev: pointer to mic_device instance.
- * @dma_addr: DMA address.
- * @size: Size of the region to be mapped.
- *
- * This API converts the DMA address provided to a DMA address understood
- * by MIC. Caller should check for errors by calling mic_map_error(..).
- *
- * returns DMA address as required by MIC.
- */
-dma_addr_t mic_map(struct mic_device *mdev, dma_addr_t dma_addr, size_t size)
-{
-       dma_addr_t mic_addr = 0;
-       int num_entries;
-       s64 *ref;
-       u64 smpt_start;
-
-       if (!size || size > mic_max_system_memory(mdev))
-               return mic_addr;
-
-       ref = kmalloc_array(mdev->smpt->info.num_reg, sizeof(s64), GFP_ATOMIC);
-       if (!ref)
-               return mic_addr;
-
-       num_entries = mic_get_smpt_ref_count(mdev, dma_addr, size,
-                                            ref, &smpt_start);
-
-       /* Set the smpt table appropriately and get 16G aligned mic address */
-       mic_addr = mic_smpt_op(mdev, smpt_start, num_entries, ref, size);
-
-       kfree(ref);
-
-       /*
-        * If mic_addr is zero then its an error case
-        * since mic_addr can never be zero.
-        * else generate mic_addr by adding the 16G offset in dma_addr
-        */
-       if (!mic_addr && MIC_FAMILY_X100 == mdev->family) {
-               dev_err(&mdev->pdev->dev,
-                       "mic_map failed dma_addr 0x%llx size 0x%lx\n",
-                       dma_addr, size);
-               return mic_addr;
-       } else {
-               return mic_addr + mic_smpt_offset(mdev, dma_addr);
-       }
-}
-
-/**
- * mic_unmap - Unmaps a MIC physical address.
- *
- * @mdev: pointer to mic_device instance.
- * @mic_addr: MIC physical address.
- * @size: Size of the region to be unmapped.
- *
- * This API unmaps the mappings created by mic_map(..).
- *
- * returns None.
- */
-void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size)
-{
-       struct mic_smpt_info *smpt_info = mdev->smpt;
-       s64 *ref;
-       int num_smpt;
-       int spt;
-       int i;
-       unsigned long flags;
-
-       if (!size)
-               return;
-
-       if (!mic_is_system_addr(mdev, mic_addr)) {
-               dev_err(&mdev->pdev->dev,
-                       "invalid address: 0x%llx\n", mic_addr);
-               return;
-       }
-
-       spt = mic_sys_addr_to_smpt(mdev, mic_addr);
-       ref = kmalloc_array(mdev->smpt->info.num_reg, sizeof(s64), GFP_ATOMIC);
-       if (!ref)
-               return;
-
-       /* Get number of smpt entries to be mapped, ref count array */
-       num_smpt = mic_get_smpt_ref_count(mdev, mic_addr, size, ref, NULL);
-
-       spin_lock_irqsave(&smpt_info->smpt_lock, flags);
-       smpt_info->unmap_count++;
-       smpt_info->ref_count -= (s64)size;
-
-       for (i = spt; i < spt + num_smpt; i++) {
-               smpt_info->entry[i].ref_count -= ref[i - spt];
-               if (smpt_info->entry[i].ref_count < 0)
-                       dev_warn(&mdev->pdev->dev,
-                                "ref count for entry %d is negative\n", i);
-       }
-       spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
-       kfree(ref);
-}
-
-/**
- * mic_map_single - Maps a virtual address to a MIC physical address.
- *
- * @mdev: pointer to mic_device instance.
- * @va: Kernel direct mapped virtual address.
- * @size: Size of the region to be mapped.
- *
- * This API calls pci_map_single(..) for the direct mapped virtual address
- * and then converts the DMA address provided to a DMA address understood
- * by MIC. Caller should check for errors by calling mic_map_error(..).
- *
- * returns DMA address as required by MIC.
- */
-dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size)
-{
-       dma_addr_t mic_addr = 0;
-       struct pci_dev *pdev = mdev->pdev;
-       dma_addr_t dma_addr =
-               pci_map_single(pdev, va, size, PCI_DMA_BIDIRECTIONAL);
-
-       if (!pci_dma_mapping_error(pdev, dma_addr)) {
-               mic_addr = mic_map(mdev, dma_addr, size);
-               if (!mic_addr) {
-                       dev_err(&mdev->pdev->dev,
-                               "mic_map failed dma_addr 0x%llx size 0x%lx\n",
-                               dma_addr, size);
-                       pci_unmap_single(pdev, dma_addr,
-                                        size, PCI_DMA_BIDIRECTIONAL);
-               }
-       }
-       return mic_addr;
-}
-
-/**
- * mic_unmap_single - Unmaps a MIC physical address.
- *
- * @mdev: pointer to mic_device instance.
- * @mic_addr: MIC physical address.
- * @size: Size of the region to be unmapped.
- *
- * This API unmaps the mappings created by mic_map_single(..).
- *
- * returns None.
- */
-void
-mic_unmap_single(struct mic_device *mdev, dma_addr_t mic_addr, size_t size)
-{
-       struct pci_dev *pdev = mdev->pdev;
-       dma_addr_t dma_addr = mic_to_dma_addr(mdev, mic_addr);
-       mic_unmap(mdev, mic_addr, size);
-       pci_unmap_single(pdev, dma_addr, size, PCI_DMA_BIDIRECTIONAL);
-}
-
-/**
- * mic_smpt_init - Initialize MIC System Memory Page Tables.
- *
- * @mdev: pointer to mic_device instance.
- *
- * returns 0 for success and -errno for error.
- */
-int mic_smpt_init(struct mic_device *mdev)
-{
-       int i, err = 0;
-       dma_addr_t dma_addr;
-       struct mic_smpt_info *smpt_info;
-
-       mdev->smpt = kmalloc(sizeof(*mdev->smpt), GFP_KERNEL);
-       if (!mdev->smpt)
-               return -ENOMEM;
-
-       smpt_info = mdev->smpt;
-       mdev->smpt_ops->init(mdev);
-       smpt_info->entry = kmalloc_array(smpt_info->info.num_reg,
-                                        sizeof(*smpt_info->entry), GFP_KERNEL);
-       if (!smpt_info->entry) {
-               err = -ENOMEM;
-               goto free_smpt;
-       }
-       spin_lock_init(&smpt_info->smpt_lock);
-       for (i = 0; i < smpt_info->info.num_reg; i++) {
-               dma_addr = i * smpt_info->info.page_size;
-               smpt_info->entry[i].dma_addr = dma_addr;
-               smpt_info->entry[i].ref_count = 0;
-               mdev->smpt_ops->set(mdev, dma_addr, i);
-       }
-       smpt_info->ref_count = 0;
-       smpt_info->map_count = 0;
-       smpt_info->unmap_count = 0;
-       return 0;
-free_smpt:
-       kfree(smpt_info);
-       return err;
-}
-
-/**
- * mic_smpt_uninit - UnInitialize MIC System Memory Page Tables.
- *
- * @mdev: pointer to mic_device instance.
- *
- * returns None.
- */
-void mic_smpt_uninit(struct mic_device *mdev)
-{
-       struct mic_smpt_info *smpt_info = mdev->smpt;
-       int i;
-
-       dev_dbg(&mdev->pdev->dev,
-               "nodeid %d SMPT ref count %lld map %lld unmap %lld\n",
-               mdev->id, smpt_info->ref_count,
-               smpt_info->map_count, smpt_info->unmap_count);
-
-       for (i = 0; i < smpt_info->info.num_reg; i++) {
-               dev_dbg(&mdev->pdev->dev,
-                       "SMPT entry[%d] dma_addr = 0x%llx ref_count = %lld\n",
-                       i, smpt_info->entry[i].dma_addr,
-                       smpt_info->entry[i].ref_count);
-               if (smpt_info->entry[i].ref_count)
-                       dev_warn(&mdev->pdev->dev,
-                                "ref count for entry %d is not zero\n", i);
-       }
-       kfree(smpt_info->entry);
-       kfree(smpt_info);
-}
-
-/**
- * mic_smpt_restore - Restore MIC System Memory Page Tables.
- *
- * @mdev: pointer to mic_device instance.
- *
- * Restore the SMPT registers to values previously stored in the
- * SW data structures. Some MIC steppings lose register state
- * across resets and this API should be called for performing
- * a restore operation if required.
- *
- * returns None.
- */
-void mic_smpt_restore(struct mic_device *mdev)
-{
-       int i;
-       dma_addr_t dma_addr;
-
-       for (i = 0; i < mdev->smpt->info.num_reg; i++) {
-               dma_addr = mdev->smpt->entry[i].dma_addr;
-               mdev->smpt_ops->set(mdev, dma_addr, i);
-       }
-}
diff --git a/drivers/misc/mic/host/mic_smpt.h b/drivers/misc/mic/host/mic_smpt.h
deleted file mode 100644 (file)
index 3b1ec14..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#ifndef MIC_SMPT_H
-#define MIC_SMPT_H
-/**
- * struct mic_smpt_ops - MIC HW specific SMPT operations.
- * @init: Initialize hardware specific SMPT information in mic_smpt_hw_info.
- * @set: Set the value for a particular SMPT entry.
- */
-struct mic_smpt_ops {
-       void (*init)(struct mic_device *mdev);
-       void (*set)(struct mic_device *mdev, dma_addr_t dma_addr, u8 index);
-};
-
-/**
- * struct mic_smpt - MIC SMPT entry information.
- * @dma_addr: Base DMA address for this SMPT entry.
- * @ref_count: Number of active mappings for this SMPT entry in bytes.
- */
-struct mic_smpt {
-       dma_addr_t dma_addr;
-       s64 ref_count;
-};
-
-/**
- * struct mic_smpt_hw_info - MIC SMPT hardware specific information.
- * @num_reg: Number of SMPT registers.
- * @page_shift: System memory page shift.
- * @page_size: System memory page size.
- * @base: System address base.
- */
-struct mic_smpt_hw_info {
-       u8 num_reg;
-       u8 page_shift;
-       u64 page_size;
-       u64 base;
-};
-
-/**
- * struct mic_smpt_info - MIC SMPT information.
- * @entry: Array of SMPT entries.
- * @smpt_lock: Spin lock protecting access to SMPT data structures.
- * @info: Hardware specific SMPT information.
- * @ref_count: Number of active SMPT mappings (for debug).
- * @map_count: Number of SMPT mappings created (for debug).
- * @unmap_count: Number of SMPT mappings destroyed (for debug).
- */
-struct mic_smpt_info {
-       struct mic_smpt *entry;
-       spinlock_t smpt_lock;
-       struct mic_smpt_hw_info info;
-       s64 ref_count;
-       s64 map_count;
-       s64 unmap_count;
-};
-
-dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size);
-void mic_unmap_single(struct mic_device *mdev,
-       dma_addr_t mic_addr, size_t size);
-dma_addr_t mic_map(struct mic_device *mdev,
-       dma_addr_t dma_addr, size_t size);
-void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size);
-dma_addr_t mic_to_dma_addr(struct mic_device *mdev, dma_addr_t mic_addr);
-
-/**
- * mic_map_error - Check a MIC address for errors.
- *
- * @mdev: pointer to mic_device instance.
- *
- * returns Whether there was an error during mic_map..(..) APIs.
- */
-static inline bool mic_map_error(dma_addr_t mic_addr)
-{
-       return !mic_addr;
-}
-
-int mic_smpt_init(struct mic_device *mdev);
-void mic_smpt_uninit(struct mic_device *mdev);
-void mic_smpt_restore(struct mic_device *mdev);
-
-#endif
diff --git a/drivers/misc/mic/host/mic_x100.c b/drivers/misc/mic/host/mic_x100.c
deleted file mode 100644 (file)
index f5536c1..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#include <linux/fs.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/firmware.h>
-#include <linux/delay.h>
-
-#include "../common/mic_dev.h"
-#include "mic_device.h"
-#include "mic_x100.h"
-#include "mic_smpt.h"
-
-static const u16 mic_x100_intr_init[] = {
-               MIC_X100_DOORBELL_IDX_START,
-               MIC_X100_DMA_IDX_START,
-               MIC_X100_ERR_IDX_START,
-               MIC_X100_NUM_DOORBELL,
-               MIC_X100_NUM_DMA,
-               MIC_X100_NUM_ERR,
-};
-
-/**
- * mic_x100_write_spad - write to the scratchpad register
- * @mdev: pointer to mic_device instance
- * @idx: index to the scratchpad register, 0 based
- * @val: the data value to put into the register
- *
- * This function allows writing of a 32bit value to the indexed scratchpad
- * register.
- *
- * RETURNS: none.
- */
-static void
-mic_x100_write_spad(struct mic_device *mdev, unsigned int idx, u32 val)
-{
-       dev_dbg(&mdev->pdev->dev, "Writing 0x%x to scratch pad index %d\n",
-               val, idx);
-       mic_mmio_write(&mdev->mmio, val,
-                      MIC_X100_SBOX_BASE_ADDRESS +
-                      MIC_X100_SBOX_SPAD0 + idx * 4);
-}
-
-/**
- * mic_x100_read_spad - read from the scratchpad register
- * @mdev: pointer to mic_device instance
- * @idx: index to scratchpad register, 0 based
- *
- * This function allows reading of the 32bit scratchpad register.
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static u32
-mic_x100_read_spad(struct mic_device *mdev, unsigned int idx)
-{
-       u32 val = mic_mmio_read(&mdev->mmio,
-               MIC_X100_SBOX_BASE_ADDRESS +
-               MIC_X100_SBOX_SPAD0 + idx * 4);
-
-       dev_dbg(&mdev->pdev->dev,
-               "Reading 0x%x from scratch pad index %d\n", val, idx);
-       return val;
-}
-
-/**
- * mic_x100_enable_interrupts - Enable interrupts.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_enable_interrupts(struct mic_device *mdev)
-{
-       u32 reg;
-       struct mic_mw *mw = &mdev->mmio;
-       u32 sice0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SICE0;
-       u32 siac0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SIAC0;
-
-       reg = mic_mmio_read(mw, sice0);
-       reg |= MIC_X100_SBOX_DBR_BITS(0xf) | MIC_X100_SBOX_DMA_BITS(0xff);
-       mic_mmio_write(mw, reg, sice0);
-
-       /*
-        * Enable auto-clear when enabling interrupts. Applicable only for
-        * MSI-x. Legacy and MSI mode cannot have auto-clear enabled.
-        */
-       if (mdev->irq_info.num_vectors > 1) {
-               reg = mic_mmio_read(mw, siac0);
-               reg |= MIC_X100_SBOX_DBR_BITS(0xf) |
-                       MIC_X100_SBOX_DMA_BITS(0xff);
-               mic_mmio_write(mw, reg, siac0);
-       }
-}
-
-/**
- * mic_x100_disable_interrupts - Disable interrupts.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_disable_interrupts(struct mic_device *mdev)
-{
-       u32 reg;
-       struct mic_mw *mw = &mdev->mmio;
-       u32 sice0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SICE0;
-       u32 siac0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SIAC0;
-       u32 sicc0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SICC0;
-
-       reg = mic_mmio_read(mw, sice0);
-       mic_mmio_write(mw, reg, sicc0);
-
-       if (mdev->irq_info.num_vectors > 1) {
-               reg = mic_mmio_read(mw, siac0);
-               reg &= ~(MIC_X100_SBOX_DBR_BITS(0xf) |
-                       MIC_X100_SBOX_DMA_BITS(0xff));
-               mic_mmio_write(mw, reg, siac0);
-       }
-}
-
-/**
- * mic_x100_send_sbox_intr - Send an MIC_X100_SBOX interrupt to MIC.
- * @mdev: pointer to mic_device instance
- * @doorbell: doorbell number
- */
-static void mic_x100_send_sbox_intr(struct mic_device *mdev,
-                                   int doorbell)
-{
-       struct mic_mw *mw = &mdev->mmio;
-       u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8;
-       u32 apicicr_low = mic_mmio_read(mw, MIC_X100_SBOX_BASE_ADDRESS +
-                                       apic_icr_offset);
-
-       /* for MIC we need to make sure we "hit" the send_icr bit (13) */
-       apicicr_low = (apicicr_low | (1 << 13));
-
-       /* Ensure that the interrupt is ordered w.r.t. previous stores. */
-       wmb();
-       mic_mmio_write(mw, apicicr_low,
-                      MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
-}
-
-/**
- * mic_x100_send_rdmasr_intr - Send an RDMASR interrupt to MIC.
- * @mdev: pointer to mic_device instance
- * @doorbell: doorbell number
- */
-static void mic_x100_send_rdmasr_intr(struct mic_device *mdev,
-                                     int doorbell)
-{
-       int rdmasr_offset = MIC_X100_SBOX_RDMASR0 + (doorbell << 2);
-       /* Ensure that the interrupt is ordered w.r.t. previous stores. */
-       wmb();
-       mic_mmio_write(&mdev->mmio, 0,
-                      MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset);
-}
-
-/**
- * __mic_x100_send_intr - Send interrupt to MIC.
- * @mdev: pointer to mic_device instance
- * @doorbell: doorbell number.
- */
-static void mic_x100_send_intr(struct mic_device *mdev, int doorbell)
-{
-       int rdmasr_db;
-       if (doorbell < MIC_X100_NUM_SBOX_IRQ) {
-               mic_x100_send_sbox_intr(mdev, doorbell);
-       } else {
-               rdmasr_db = doorbell - MIC_X100_NUM_SBOX_IRQ;
-               mic_x100_send_rdmasr_intr(mdev, rdmasr_db);
-       }
-}
-
-/**
- * mic_x100_ack_interrupt - Read the interrupt sources register and
- * clear it. This function will be called in the MSI/INTx case.
- * @mdev: Pointer to mic_device instance.
- *
- * Returns: bitmask of interrupt sources triggered.
- */
-static u32 mic_x100_ack_interrupt(struct mic_device *mdev)
-{
-       u32 sicr0 = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_SICR0;
-       u32 reg = mic_mmio_read(&mdev->mmio, sicr0);
-       mic_mmio_write(&mdev->mmio, reg, sicr0);
-       return reg;
-}
-
-/**
- * mic_x100_intr_workarounds - These hardware specific workarounds are
- * to be invoked everytime an interrupt is handled.
- * @mdev: Pointer to mic_device instance.
- *
- * Returns: none
- */
-static void mic_x100_intr_workarounds(struct mic_device *mdev)
-{
-       struct mic_mw *mw = &mdev->mmio;
-
-       /* Clear pending bit array. */
-       if (MIC_A0_STEP == mdev->stepping)
-               mic_mmio_write(mw, 1, MIC_X100_SBOX_BASE_ADDRESS +
-                       MIC_X100_SBOX_MSIXPBACR);
-
-       if (mdev->stepping >= MIC_B0_STEP)
-               mdev->intr_ops->enable_interrupts(mdev);
-}
-
-/**
- * mic_x100_hw_intr_init - Initialize h/w specific interrupt
- * information.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_hw_intr_init(struct mic_device *mdev)
-{
-       mdev->intr_info = (struct mic_intr_info *)mic_x100_intr_init;
-}
-
-/**
- * mic_x100_read_msi_to_src_map - read from the MSI mapping registers
- * @mdev: pointer to mic_device instance
- * @idx: index to the mapping register, 0 based
- *
- * This function allows reading of the 32bit MSI mapping register.
- *
- * RETURNS: The value in the register.
- */
-static u32
-mic_x100_read_msi_to_src_map(struct mic_device *mdev, int idx)
-{
-       return mic_mmio_read(&mdev->mmio,
-               MIC_X100_SBOX_BASE_ADDRESS +
-               MIC_X100_SBOX_MXAR0 + idx * 4);
-}
-
-/**
- * mic_x100_program_msi_to_src_map - program the MSI mapping registers
- * @mdev: pointer to mic_device instance
- * @idx: index to the mapping register, 0 based
- * @offset: The bit offset in the register that needs to be updated.
- * @set: boolean specifying if the bit in the specified offset needs
- * to be set or cleared.
- *
- * RETURNS: None.
- */
-static void
-mic_x100_program_msi_to_src_map(struct mic_device *mdev,
-                               int idx, int offset, bool set)
-{
-       unsigned long reg;
-       struct mic_mw *mw = &mdev->mmio;
-       u32 mxar = MIC_X100_SBOX_BASE_ADDRESS +
-               MIC_X100_SBOX_MXAR0 + idx * 4;
-
-       reg = mic_mmio_read(mw, mxar);
-       if (set)
-               __set_bit(offset, &reg);
-       else
-               __clear_bit(offset, &reg);
-       mic_mmio_write(mw, reg, mxar);
-}
-
-/*
- * mic_x100_reset_fw_ready - Reset Firmware ready status field.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_reset_fw_ready(struct mic_device *mdev)
-{
-       mdev->ops->write_spad(mdev, MIC_X100_DOWNLOAD_INFO, 0);
-}
-
-/*
- * mic_x100_is_fw_ready - Check if firmware is ready.
- * @mdev: pointer to mic_device instance
- */
-static bool mic_x100_is_fw_ready(struct mic_device *mdev)
-{
-       u32 scratch2 = mdev->ops->read_spad(mdev, MIC_X100_DOWNLOAD_INFO);
-       return MIC_X100_SPAD2_DOWNLOAD_STATUS(scratch2) ? true : false;
-}
-
-/**
- * mic_x100_get_apic_id - Get bootstrap APIC ID.
- * @mdev: pointer to mic_device instance
- */
-static u32 mic_x100_get_apic_id(struct mic_device *mdev)
-{
-       u32 scratch2 = 0;
-
-       scratch2 = mdev->ops->read_spad(mdev, MIC_X100_DOWNLOAD_INFO);
-       return MIC_X100_SPAD2_APIC_ID(scratch2);
-}
-
-/**
- * mic_x100_send_firmware_intr - Send an interrupt to the firmware on MIC.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_send_firmware_intr(struct mic_device *mdev)
-{
-       u32 apicicr_low;
-       u64 apic_icr_offset = MIC_X100_SBOX_APICICR7;
-       int vector = MIC_X100_BSP_INTERRUPT_VECTOR;
-       struct mic_mw *mw = &mdev->mmio;
-
-       /*
-        * For MIC we need to make sure we "hit"
-        * the send_icr bit (13).
-        */
-       apicicr_low = (vector | (1 << 13));
-
-       mic_mmio_write(mw, mic_x100_get_apic_id(mdev),
-                      MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset + 4);
-
-       /* Ensure that the interrupt is ordered w.r.t. previous stores. */
-       wmb();
-       mic_mmio_write(mw, apicicr_low,
-                      MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
-}
-
-/**
- * mic_x100_hw_reset - Reset the MIC device.
- * @mdev: pointer to mic_device instance
- */
-static void mic_x100_hw_reset(struct mic_device *mdev)
-{
-       u32 reset_reg;
-       u32 rgcr = MIC_X100_SBOX_BASE_ADDRESS + MIC_X100_SBOX_RGCR;
-       struct mic_mw *mw = &mdev->mmio;
-
-       /* Ensure that the reset is ordered w.r.t. previous loads and stores */
-       mb();
-       /* Trigger reset */
-       reset_reg = mic_mmio_read(mw, rgcr);
-       reset_reg |= 0x1;
-       mic_mmio_write(mw, reset_reg, rgcr);
-       /*
-        * It seems we really want to delay at least 1 second
-        * after touching reset to prevent a lot of problems.
-        */
-       msleep(1000);
-}
-
-/**
- * mic_x100_load_command_line - Load command line to MIC.
- * @mdev: pointer to mic_device instance
- * @fw: the firmware image
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int
-mic_x100_load_command_line(struct mic_device *mdev, const struct firmware *fw)
-{
-       u32 len = 0;
-       u32 boot_mem;
-       char *buf;
-       void __iomem *cmd_line_va = mdev->aper.va + mdev->bootaddr + fw->size;
-#define CMDLINE_SIZE 2048
-
-       boot_mem = mdev->aper.len >> 20;
-       buf = kzalloc(CMDLINE_SIZE, GFP_KERNEL);
-       if (!buf)
-               return -ENOMEM;
-
-       len += scnprintf(buf, CMDLINE_SIZE - len,
-               " mem=%dM", boot_mem);
-       if (mdev->cosm_dev->cmdline)
-               scnprintf(buf + len, CMDLINE_SIZE - len, " %s",
-                        mdev->cosm_dev->cmdline);
-       memcpy_toio(cmd_line_va, buf, strlen(buf) + 1);
-       kfree(buf);
-       return 0;
-}
-
-/**
- * mic_x100_load_ramdisk - Load ramdisk to MIC.
- * @mdev: pointer to mic_device instance
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int
-mic_x100_load_ramdisk(struct mic_device *mdev)
-{
-       const struct firmware *fw;
-       int rc;
-       struct boot_params __iomem *bp = mdev->aper.va + mdev->bootaddr;
-
-       rc = request_firmware(&fw, mdev->cosm_dev->ramdisk, &mdev->pdev->dev);
-       if (rc < 0) {
-               dev_err(&mdev->pdev->dev,
-                       "ramdisk request_firmware failed: %d %s\n",
-                       rc, mdev->cosm_dev->ramdisk);
-               goto error;
-       }
-       /*
-        * Typically the bootaddr for card OS is 64M
-        * so copy over the ramdisk @ 128M.
-        */
-       memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size);
-       iowrite32(mdev->bootaddr << 1, &bp->hdr.ramdisk_image);
-       iowrite32(fw->size, &bp->hdr.ramdisk_size);
-       release_firmware(fw);
-error:
-       return rc;
-}
-
-/**
- * mic_x100_get_boot_addr - Get MIC boot address.
- * @mdev: pointer to mic_device instance
- *
- * This function is called during firmware load to determine
- * the address at which the OS should be downloaded in card
- * memory i.e. GDDR.
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int
-mic_x100_get_boot_addr(struct mic_device *mdev)
-{
-       u32 scratch2, boot_addr;
-       int rc = 0;
-
-       scratch2 = mdev->ops->read_spad(mdev, MIC_X100_DOWNLOAD_INFO);
-       boot_addr = MIC_X100_SPAD2_DOWNLOAD_ADDR(scratch2);
-       dev_dbg(&mdev->pdev->dev, "%s %d boot_addr 0x%x\n",
-               __func__, __LINE__, boot_addr);
-       if (boot_addr > (1 << 31)) {
-               dev_err(&mdev->pdev->dev,
-                       "incorrect bootaddr 0x%x\n",
-                       boot_addr);
-               rc = -EINVAL;
-               goto error;
-       }
-       mdev->bootaddr = boot_addr;
-error:
-       return rc;
-}
-
-/**
- * mic_x100_load_firmware - Load firmware to MIC.
- * @mdev: pointer to mic_device instance
- * @buf: buffer containing boot string including firmware/ramdisk path.
- *
- * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
- */
-static int
-mic_x100_load_firmware(struct mic_device *mdev, const char *buf)
-{
-       int rc;
-       const struct firmware *fw;
-
-       rc = mic_x100_get_boot_addr(mdev);
-       if (rc)
-               return rc;
-       /* load OS */
-       rc = request_firmware(&fw, mdev->cosm_dev->firmware, &mdev->pdev->dev);
-       if (rc < 0) {
-               dev_err(&mdev->pdev->dev,
-                       "ramdisk request_firmware failed: %d %s\n",
-                       rc, mdev->cosm_dev->firmware);
-               return rc;
-       }
-       if (mdev->bootaddr > mdev->aper.len - fw->size) {
-               rc = -EINVAL;
-               dev_err(&mdev->pdev->dev, "%s %d rc %d bootaddr 0x%x\n",
-                       __func__, __LINE__, rc, mdev->bootaddr);
-               goto error;
-       }
-       memcpy_toio(mdev->aper.va + mdev->bootaddr, fw->data, fw->size);
-       mdev->ops->write_spad(mdev, MIC_X100_FW_SIZE, fw->size);
-       if (!strcmp(mdev->cosm_dev->bootmode, "flash")) {
-               rc = -EINVAL;
-               dev_err(&mdev->pdev->dev, "%s %d rc %d\n",
-                       __func__, __LINE__, rc);
-               goto error;
-       }
-       /* load command line */
-       rc = mic_x100_load_command_line(mdev, fw);
-       if (rc) {
-               dev_err(&mdev->pdev->dev, "%s %d rc %d\n",
-                       __func__, __LINE__, rc);
-               goto error;
-       }
-       release_firmware(fw);
-       /* load ramdisk */
-       if (mdev->cosm_dev->ramdisk)
-               rc = mic_x100_load_ramdisk(mdev);
-
-       return rc;
-
-error:
-       release_firmware(fw);
-       return rc;
-}
-
-/**
- * mic_x100_get_postcode - Get postcode status from firmware.
- * @mdev: pointer to mic_device instance
- *
- * RETURNS: postcode.
- */
-static u32 mic_x100_get_postcode(struct mic_device *mdev)
-{
-       return mic_mmio_read(&mdev->mmio, MIC_X100_POSTCODE);
-}
-
-/**
- * mic_x100_smpt_set - Update an SMPT entry with a DMA address.
- * @mdev: pointer to mic_device instance
- * @dma_addr: DMA address to use
- * @index: entry to write to
- *
- * RETURNS: none.
- */
-static void
-mic_x100_smpt_set(struct mic_device *mdev, dma_addr_t dma_addr, u8 index)
-{
-#define SNOOP_ON       (0 << 0)
-#define SNOOP_OFF      (1 << 0)
-/*
- * Sbox Smpt Reg Bits:
- * Bits        31:2    Host address
- * Bits        1       RSVD
- * Bits        0       No snoop
- */
-#define BUILD_SMPT(NO_SNOOP, HOST_ADDR)  \
-       (u32)(((HOST_ADDR) << 2) | ((NO_SNOOP) & 0x01))
-
-       uint32_t smpt_reg_val = BUILD_SMPT(SNOOP_ON,
-                       dma_addr >> mdev->smpt->info.page_shift);
-       mic_mmio_write(&mdev->mmio, smpt_reg_val,
-                      MIC_X100_SBOX_BASE_ADDRESS +
-                      MIC_X100_SBOX_SMPT00 + (4 * index));
-}
-
-/**
- * mic_x100_smpt_hw_init - Initialize SMPT X100 specific fields.
- * @mdev: pointer to mic_device instance
- *
- * RETURNS: none.
- */
-static void mic_x100_smpt_hw_init(struct mic_device *mdev)
-{
-       struct mic_smpt_hw_info *info = &mdev->smpt->info;
-
-       info->num_reg = 32;
-       info->page_shift = 34;
-       info->page_size = (1ULL << info->page_shift);
-       info->base = 0x8000000000ULL;
-}
-
-struct mic_smpt_ops mic_x100_smpt_ops = {
-       .init = mic_x100_smpt_hw_init,
-       .set = mic_x100_smpt_set,
-};
-
-static bool mic_x100_dma_filter(struct dma_chan *chan, void *param)
-{
-       if (chan->device->dev->parent == (struct device *)param)
-               return true;
-       return false;
-}
-
-struct mic_hw_ops mic_x100_ops = {
-       .aper_bar = MIC_X100_APER_BAR,
-       .mmio_bar = MIC_X100_MMIO_BAR,
-       .read_spad = mic_x100_read_spad,
-       .write_spad = mic_x100_write_spad,
-       .send_intr = mic_x100_send_intr,
-       .ack_interrupt = mic_x100_ack_interrupt,
-       .intr_workarounds = mic_x100_intr_workarounds,
-       .reset = mic_x100_hw_reset,
-       .reset_fw_ready = mic_x100_reset_fw_ready,
-       .is_fw_ready = mic_x100_is_fw_ready,
-       .send_firmware_intr = mic_x100_send_firmware_intr,
-       .load_mic_fw = mic_x100_load_firmware,
-       .get_postcode = mic_x100_get_postcode,
-       .dma_filter = mic_x100_dma_filter,
-};
-
-struct mic_hw_intr_ops mic_x100_intr_ops = {
-       .intr_init = mic_x100_hw_intr_init,
-       .enable_interrupts = mic_x100_enable_interrupts,
-       .disable_interrupts = mic_x100_disable_interrupts,
-       .program_msi_to_src_map = mic_x100_program_msi_to_src_map,
-       .read_msi_to_src_map = mic_x100_read_msi_to_src_map,
-};
diff --git a/drivers/misc/mic/host/mic_x100.h b/drivers/misc/mic/host/mic_x100.h
deleted file mode 100644 (file)
index aebcaed..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC Host driver.
- */
-#ifndef _MIC_X100_HW_H_
-#define _MIC_X100_HW_H_
-
-#define MIC_X100_PCI_DEVICE_2250 0x2250
-#define MIC_X100_PCI_DEVICE_2251 0x2251
-#define MIC_X100_PCI_DEVICE_2252 0x2252
-#define MIC_X100_PCI_DEVICE_2253 0x2253
-#define MIC_X100_PCI_DEVICE_2254 0x2254
-#define MIC_X100_PCI_DEVICE_2255 0x2255
-#define MIC_X100_PCI_DEVICE_2256 0x2256
-#define MIC_X100_PCI_DEVICE_2257 0x2257
-#define MIC_X100_PCI_DEVICE_2258 0x2258
-#define MIC_X100_PCI_DEVICE_2259 0x2259
-#define MIC_X100_PCI_DEVICE_225a 0x225a
-#define MIC_X100_PCI_DEVICE_225b 0x225b
-#define MIC_X100_PCI_DEVICE_225c 0x225c
-#define MIC_X100_PCI_DEVICE_225d 0x225d
-#define MIC_X100_PCI_DEVICE_225e 0x225e
-
-#define MIC_X100_APER_BAR 0
-#define MIC_X100_MMIO_BAR 4
-
-#define MIC_X100_SBOX_BASE_ADDRESS 0x00010000
-#define MIC_X100_SBOX_SPAD0 0x0000AB20
-#define MIC_X100_SBOX_SICR0_DBR(x) ((x) & 0xf)
-#define MIC_X100_SBOX_SICR0_DMA(x) (((x) >> 8) & 0xff)
-#define MIC_X100_SBOX_SICE0_DBR(x) ((x) & 0xf)
-#define MIC_X100_SBOX_DBR_BITS(x) ((x) & 0xf)
-#define MIC_X100_SBOX_SICE0_DMA(x) (((x) >> 8) & 0xff)
-#define MIC_X100_SBOX_DMA_BITS(x) (((x) & 0xff) << 8)
-
-#define MIC_X100_SBOX_APICICR0 0x0000A9D0
-#define MIC_X100_SBOX_SICR0 0x00009004
-#define MIC_X100_SBOX_SICE0 0x0000900C
-#define MIC_X100_SBOX_SICC0 0x00009010
-#define MIC_X100_SBOX_SIAC0 0x00009014
-#define MIC_X100_SBOX_MSIXPBACR 0x00009084
-#define MIC_X100_SBOX_MXAR0 0x00009044
-#define MIC_X100_SBOX_SMPT00 0x00003100
-#define MIC_X100_SBOX_RDMASR0 0x0000B180
-
-#define MIC_X100_DOORBELL_IDX_START 0
-#define MIC_X100_NUM_DOORBELL 4
-#define MIC_X100_DMA_IDX_START 8
-#define MIC_X100_NUM_DMA 8
-#define MIC_X100_ERR_IDX_START 30
-#define MIC_X100_NUM_ERR 1
-
-#define MIC_X100_NUM_SBOX_IRQ 8
-#define MIC_X100_NUM_RDMASR_IRQ 8
-#define MIC_X100_RDMASR_IRQ_BASE 17
-#define MIC_X100_SPAD2_DOWNLOAD_STATUS(x) ((x) & 0x1)
-#define MIC_X100_SPAD2_APIC_ID(x)      (((x) >> 1) & 0x1ff)
-#define MIC_X100_SPAD2_DOWNLOAD_ADDR(x) ((x) & 0xfffff000)
-#define MIC_X100_SBOX_APICICR7 0x0000AA08
-#define MIC_X100_SBOX_RGCR 0x00004010
-#define MIC_X100_SBOX_SDBIC0 0x0000CC90
-#define MIC_X100_DOWNLOAD_INFO 2
-#define MIC_X100_FW_SIZE 5
-#define MIC_X100_POSTCODE 0x242c
-
-/* Host->Card(bootstrap) Interrupt Vector */
-#define MIC_X100_BSP_INTERRUPT_VECTOR 229
-
-extern struct mic_hw_ops mic_x100_ops;
-extern struct mic_smpt_ops mic_x100_smpt_ops;
-extern struct mic_hw_intr_ops mic_x100_intr_ops;
-
-#endif
diff --git a/drivers/misc/mic/scif/Makefile b/drivers/misc/mic/scif/Makefile
deleted file mode 100644 (file)
index ff37255..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile - SCIF driver.
-# Copyright(c) 2014, Intel Corporation.
-#
-obj-$(CONFIG_SCIF) += scif.o
-scif-objs := scif_main.o
-scif-objs += scif_peer_bus.o
-scif-objs += scif_ports.o
-scif-objs += scif_debugfs.o
-scif-objs += scif_fd.o
-scif-objs += scif_api.o
-scif-objs += scif_epd.o
-scif-objs += scif_rb.o
-scif-objs += scif_nodeqp.o
-scif-objs += scif_nm.o
-scif-objs += scif_dma.o
-scif-objs += scif_fence.o
-scif-objs += scif_mmap.o
-scif-objs += scif_rma.o
-scif-objs += scif_rma_list.o
diff --git a/drivers/misc/mic/scif/scif_api.c b/drivers/misc/mic/scif/scif_api.c
deleted file mode 100644 (file)
index 304d6c8..0000000
+++ /dev/null
@@ -1,1485 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/scif.h>
-#include "scif_main.h"
-#include "scif_map.h"
-
-static const char * const scif_ep_states[] = {
-       "Unbound",
-       "Bound",
-       "Listening",
-       "Connected",
-       "Connecting",
-       "Mapping",
-       "Closing",
-       "Close Listening",
-       "Disconnected",
-       "Zombie"};
-
-enum conn_async_state {
-       ASYNC_CONN_IDLE = 1,    /* ep setup for async connect */
-       ASYNC_CONN_INPROGRESS,  /* async connect in progress */
-       ASYNC_CONN_FLUSH_WORK   /* async work flush in progress  */
-};
-
-/*
- * File operations for anonymous inode file associated with a SCIF endpoint,
- * used in kernel mode SCIF poll. Kernel mode SCIF poll calls portions of the
- * poll API in the kernel and these take in a struct file *. Since a struct
- * file is not available to kernel mode SCIF, it uses an anonymous file for
- * this purpose.
- */
-const struct file_operations scif_anon_fops = {
-       .owner = THIS_MODULE,
-};
-
-scif_epd_t scif_open(void)
-{
-       struct scif_endpt *ep;
-       int err;
-
-       might_sleep();
-       ep = kzalloc(sizeof(*ep), GFP_KERNEL);
-       if (!ep)
-               goto err_ep_alloc;
-
-       ep->qp_info.qp = kzalloc(sizeof(*ep->qp_info.qp), GFP_KERNEL);
-       if (!ep->qp_info.qp)
-               goto err_qp_alloc;
-
-       err = scif_anon_inode_getfile(ep);
-       if (err)
-               goto err_anon_inode;
-
-       spin_lock_init(&ep->lock);
-       mutex_init(&ep->sendlock);
-       mutex_init(&ep->recvlock);
-
-       scif_rma_ep_init(ep);
-       ep->state = SCIFEP_UNBOUND;
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI open: ep %p success\n", ep);
-       return ep;
-
-err_anon_inode:
-       kfree(ep->qp_info.qp);
-err_qp_alloc:
-       kfree(ep);
-err_ep_alloc:
-       return NULL;
-}
-EXPORT_SYMBOL_GPL(scif_open);
-
-/*
- * scif_disconnect_ep - Disconnects the endpoint if found
- * @epd: The end point returned from scif_open()
- */
-static struct scif_endpt *scif_disconnect_ep(struct scif_endpt *ep)
-{
-       struct scifmsg msg;
-       struct scif_endpt *fep = NULL;
-       struct scif_endpt *tmpep;
-       struct list_head *pos, *tmpq;
-       int err;
-
-       /*
-        * Wake up any threads blocked in send()/recv() before closing
-        * out the connection. Grabbing and releasing the send/recv lock
-        * will ensure that any blocked senders/receivers have exited for
-        * Ring 0 endpoints. It is a Ring 0 bug to call send/recv after
-        * close. Ring 3 endpoints are not affected since close will not
-        * be called while there are IOCTLs executing.
-        */
-       wake_up_interruptible(&ep->sendwq);
-       wake_up_interruptible(&ep->recvwq);
-       mutex_lock(&ep->sendlock);
-       mutex_unlock(&ep->sendlock);
-       mutex_lock(&ep->recvlock);
-       mutex_unlock(&ep->recvlock);
-
-       /* Remove from the connected list */
-       mutex_lock(&scif_info.connlock);
-       list_for_each_safe(pos, tmpq, &scif_info.connected) {
-               tmpep = list_entry(pos, struct scif_endpt, list);
-               if (tmpep == ep) {
-                       list_del(pos);
-                       fep = tmpep;
-                       spin_lock(&ep->lock);
-                       break;
-               }
-       }
-
-       if (!fep) {
-               /*
-                * The other side has completed the disconnect before
-                * the end point can be removed from the list. Therefore
-                * the ep lock is not locked, traverse the disconnected
-                * list to find the endpoint and release the conn lock.
-                */
-               list_for_each_safe(pos, tmpq, &scif_info.disconnected) {
-                       tmpep = list_entry(pos, struct scif_endpt, list);
-                       if (tmpep == ep) {
-                               list_del(pos);
-                               break;
-                       }
-               }
-               mutex_unlock(&scif_info.connlock);
-               return NULL;
-       }
-
-       init_completion(&ep->discon);
-       msg.uop = SCIF_DISCNCT;
-       msg.src = ep->port;
-       msg.dst = ep->peer;
-       msg.payload[0] = (u64)ep;
-       msg.payload[1] = ep->remote_ep;
-
-       err = scif_nodeqp_send(ep->remote_dev, &msg);
-       spin_unlock(&ep->lock);
-       mutex_unlock(&scif_info.connlock);
-
-       if (!err)
-               /* Wait for the remote node to respond with SCIF_DISCNT_ACK */
-               wait_for_completion_timeout(&ep->discon,
-                                           SCIF_NODE_ALIVE_TIMEOUT);
-       return ep;
-}
-
-int scif_close(scif_epd_t epd)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scif_endpt *tmpep;
-       struct list_head *pos, *tmpq;
-       enum scif_epd_state oldstate;
-       bool flush_conn;
-
-       dev_dbg(scif_info.mdev.this_device, "SCIFAPI close: ep %p %s\n",
-               ep, scif_ep_states[ep->state]);
-       might_sleep();
-       spin_lock(&ep->lock);
-       flush_conn = (ep->conn_async_state == ASYNC_CONN_INPROGRESS);
-       spin_unlock(&ep->lock);
-
-       if (flush_conn)
-               flush_work(&scif_info.conn_work);
-
-       spin_lock(&ep->lock);
-       oldstate = ep->state;
-
-       ep->state = SCIFEP_CLOSING;
-
-       switch (oldstate) {
-       case SCIFEP_ZOMBIE:
-               dev_err(scif_info.mdev.this_device,
-                       "SCIFAPI close: zombie state unexpected\n");
-               fallthrough;
-       case SCIFEP_DISCONNECTED:
-               spin_unlock(&ep->lock);
-               scif_unregister_all_windows(epd);
-               /* Remove from the disconnected list */
-               mutex_lock(&scif_info.connlock);
-               list_for_each_safe(pos, tmpq, &scif_info.disconnected) {
-                       tmpep = list_entry(pos, struct scif_endpt, list);
-                       if (tmpep == ep) {
-                               list_del(pos);
-                               break;
-                       }
-               }
-               mutex_unlock(&scif_info.connlock);
-               break;
-       case SCIFEP_UNBOUND:
-       case SCIFEP_BOUND:
-       case SCIFEP_CONNECTING:
-               spin_unlock(&ep->lock);
-               break;
-       case SCIFEP_MAPPING:
-       case SCIFEP_CONNECTED:
-       case SCIFEP_CLOSING:
-       {
-               spin_unlock(&ep->lock);
-               scif_unregister_all_windows(epd);
-               scif_disconnect_ep(ep);
-               break;
-       }
-       case SCIFEP_LISTENING:
-       case SCIFEP_CLLISTEN:
-       {
-               struct scif_conreq *conreq;
-               struct scifmsg msg;
-               struct scif_endpt *aep;
-
-               spin_unlock(&ep->lock);
-               mutex_lock(&scif_info.eplock);
-
-               /* remove from listen list */
-               list_for_each_safe(pos, tmpq, &scif_info.listen) {
-                       tmpep = list_entry(pos, struct scif_endpt, list);
-                       if (tmpep == ep)
-                               list_del(pos);
-               }
-               /* Remove any dangling accepts */
-               while (ep->acceptcnt) {
-                       aep = list_first_entry(&ep->li_accept,
-                                              struct scif_endpt, liacceptlist);
-                       list_del(&aep->liacceptlist);
-                       scif_put_port(aep->port.port);
-                       list_for_each_safe(pos, tmpq, &scif_info.uaccept) {
-                               tmpep = list_entry(pos, struct scif_endpt,
-                                                  miacceptlist);
-                               if (tmpep == aep) {
-                                       list_del(pos);
-                                       break;
-                               }
-                       }
-                       mutex_unlock(&scif_info.eplock);
-                       mutex_lock(&scif_info.connlock);
-                       list_for_each_safe(pos, tmpq, &scif_info.connected) {
-                               tmpep = list_entry(pos,
-                                                  struct scif_endpt, list);
-                               if (tmpep == aep) {
-                                       list_del(pos);
-                                       break;
-                               }
-                       }
-                       list_for_each_safe(pos, tmpq, &scif_info.disconnected) {
-                               tmpep = list_entry(pos,
-                                                  struct scif_endpt, list);
-                               if (tmpep == aep) {
-                                       list_del(pos);
-                                       break;
-                               }
-                       }
-                       mutex_unlock(&scif_info.connlock);
-                       scif_teardown_ep(aep);
-                       mutex_lock(&scif_info.eplock);
-                       scif_add_epd_to_zombie_list(aep, SCIF_EPLOCK_HELD);
-                       ep->acceptcnt--;
-               }
-
-               spin_lock(&ep->lock);
-               mutex_unlock(&scif_info.eplock);
-
-               /* Remove and reject any pending connection requests. */
-               while (ep->conreqcnt) {
-                       conreq = list_first_entry(&ep->conlist,
-                                                 struct scif_conreq, list);
-                       list_del(&conreq->list);
-
-                       msg.uop = SCIF_CNCT_REJ;
-                       msg.dst.node = conreq->msg.src.node;
-                       msg.dst.port = conreq->msg.src.port;
-                       msg.payload[0] = conreq->msg.payload[0];
-                       msg.payload[1] = conreq->msg.payload[1];
-                       /*
-                        * No Error Handling on purpose for scif_nodeqp_send().
-                        * If the remote node is lost we still want free the
-                        * connection requests on the self node.
-                        */
-                       scif_nodeqp_send(&scif_dev[conreq->msg.src.node],
-                                        &msg);
-                       ep->conreqcnt--;
-                       kfree(conreq);
-               }
-
-               spin_unlock(&ep->lock);
-               /* If a kSCIF accept is waiting wake it up */
-               wake_up_interruptible(&ep->conwq);
-               break;
-       }
-       }
-       scif_put_port(ep->port.port);
-       scif_anon_inode_fput(ep);
-       scif_teardown_ep(ep);
-       scif_add_epd_to_zombie_list(ep, !SCIF_EPLOCK_HELD);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(scif_close);
-
-/**
- * scif_flush() - Wakes up any blocking accepts. The endpoint will no longer
- *                     accept new connections.
- * @epd: The end point returned from scif_open()
- */
-int __scif_flush(scif_epd_t epd)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-
-       switch (ep->state) {
-       case SCIFEP_LISTENING:
-       {
-               ep->state = SCIFEP_CLLISTEN;
-
-               /* If an accept is waiting wake it up */
-               wake_up_interruptible(&ep->conwq);
-               break;
-       }
-       default:
-               break;
-       }
-       return 0;
-}
-
-int scif_bind(scif_epd_t epd, u16 pn)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int ret = 0;
-       int tmp;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI bind: ep %p %s requested port number %d\n",
-               ep, scif_ep_states[ep->state], pn);
-       if (pn) {
-               /*
-                * Similar to IETF RFC 1700, SCIF ports below
-                * SCIF_ADMIN_PORT_END can only be bound by system (or root)
-                * processes or by processes executed by privileged users.
-                */
-               if (pn < SCIF_ADMIN_PORT_END && !capable(CAP_SYS_ADMIN)) {
-                       ret = -EACCES;
-                       goto scif_bind_admin_exit;
-               }
-       }
-
-       spin_lock(&ep->lock);
-       if (ep->state == SCIFEP_BOUND) {
-               ret = -EINVAL;
-               goto scif_bind_exit;
-       } else if (ep->state != SCIFEP_UNBOUND) {
-               ret = -EISCONN;
-               goto scif_bind_exit;
-       }
-
-       if (pn) {
-               tmp = scif_rsrv_port(pn);
-               if (tmp != pn) {
-                       ret = -EINVAL;
-                       goto scif_bind_exit;
-               }
-       } else {
-               ret = scif_get_new_port();
-               if (ret < 0)
-                       goto scif_bind_exit;
-               pn = ret;
-       }
-
-       ep->state = SCIFEP_BOUND;
-       ep->port.node = scif_info.nodeid;
-       ep->port.port = pn;
-       ep->conn_async_state = ASYNC_CONN_IDLE;
-       ret = pn;
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI bind: bound to port number %d\n", pn);
-scif_bind_exit:
-       spin_unlock(&ep->lock);
-scif_bind_admin_exit:
-       return ret;
-}
-EXPORT_SYMBOL_GPL(scif_bind);
-
-int scif_listen(scif_epd_t epd, int backlog)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI listen: ep %p %s\n", ep, scif_ep_states[ep->state]);
-       spin_lock(&ep->lock);
-       switch (ep->state) {
-       case SCIFEP_ZOMBIE:
-       case SCIFEP_CLOSING:
-       case SCIFEP_CLLISTEN:
-       case SCIFEP_UNBOUND:
-       case SCIFEP_DISCONNECTED:
-               spin_unlock(&ep->lock);
-               return -EINVAL;
-       case SCIFEP_LISTENING:
-       case SCIFEP_CONNECTED:
-       case SCIFEP_CONNECTING:
-       case SCIFEP_MAPPING:
-               spin_unlock(&ep->lock);
-               return -EISCONN;
-       case SCIFEP_BOUND:
-               break;
-       }
-
-       ep->state = SCIFEP_LISTENING;
-       ep->backlog = backlog;
-
-       ep->conreqcnt = 0;
-       ep->acceptcnt = 0;
-       INIT_LIST_HEAD(&ep->conlist);
-       init_waitqueue_head(&ep->conwq);
-       INIT_LIST_HEAD(&ep->li_accept);
-       spin_unlock(&ep->lock);
-
-       /*
-        * Listen status is complete so delete the qp information not needed
-        * on a listen before placing on the list of listening ep's
-        */
-       scif_teardown_ep(ep);
-       ep->qp_info.qp = NULL;
-
-       mutex_lock(&scif_info.eplock);
-       list_add_tail(&ep->list, &scif_info.listen);
-       mutex_unlock(&scif_info.eplock);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(scif_listen);
-
-/*
- ************************************************************************
- * SCIF connection flow:
- *
- * 1) A SCIF listening endpoint can call scif_accept(..) to wait for SCIF
- *     connections via a SCIF_CNCT_REQ message
- * 2) A SCIF endpoint can initiate a SCIF connection by calling
- *     scif_connect(..) which calls scif_setup_qp_connect(..) which
- *     allocates the local qp for the endpoint ring buffer and then sends
- *     a SCIF_CNCT_REQ to the remote node and waits for a SCIF_CNCT_GNT or
- *     a SCIF_CNCT_REJ message
- * 3) The peer node handles a SCIF_CNCT_REQ via scif_cnctreq_resp(..) which
- *     wakes up any threads blocked in step 1 or sends a SCIF_CNCT_REJ
- *     message otherwise
- * 4) A thread blocked waiting for incoming connections allocates its local
- *     endpoint QP and ring buffer following which it sends a SCIF_CNCT_GNT
- *     and waits for a SCIF_CNCT_GNT(N)ACK. If the allocation fails then
- *     the node sends a SCIF_CNCT_REJ message
- * 5) Upon receipt of a SCIF_CNCT_GNT or a SCIF_CNCT_REJ message the
- *     connecting endpoint is woken up as part of handling
- *     scif_cnctgnt_resp(..) following which it maps the remote endpoints'
- *     QP, updates its outbound QP and sends a SCIF_CNCT_GNTACK message on
- *     success or a SCIF_CNCT_GNTNACK message on failure and completes
- *     the scif_connect(..) API
- * 6) Upon receipt of a SCIF_CNCT_GNT(N)ACK the accepting endpoint blocked
- *     in step 4 is woken up and completes the scif_accept(..) API
- * 7) The SCIF connection is now established between the two SCIF endpoints.
- */
-static int scif_conn_func(struct scif_endpt *ep)
-{
-       int err = 0;
-       struct scifmsg msg;
-       struct device *spdev;
-
-       err = scif_reserve_dma_chan(ep);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               ep->state = SCIFEP_BOUND;
-               goto connect_error_simple;
-       }
-       /* Initiate the first part of the endpoint QP setup */
-       err = scif_setup_qp_connect(ep->qp_info.qp, &ep->qp_info.qp_offset,
-                                   SCIF_ENDPT_QP_SIZE, ep->remote_dev);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s err %d qp_offset 0x%llx\n",
-                       __func__, err, ep->qp_info.qp_offset);
-               ep->state = SCIFEP_BOUND;
-               goto connect_error_simple;
-       }
-
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               goto cleanup_qp;
-       }
-       /* Format connect message and send it */
-       msg.src = ep->port;
-       msg.dst = ep->conn_port;
-       msg.uop = SCIF_CNCT_REQ;
-       msg.payload[0] = (u64)ep;
-       msg.payload[1] = ep->qp_info.qp_offset;
-       err = _scif_nodeqp_send(ep->remote_dev, &msg);
-       if (err)
-               goto connect_error_dec;
-       scif_put_peer_dev(spdev);
-       /*
-        * Wait for the remote node to respond with SCIF_CNCT_GNT or
-        * SCIF_CNCT_REJ message.
-        */
-       err = wait_event_timeout(ep->conwq, ep->state != SCIFEP_CONNECTING,
-                                SCIF_NODE_ALIVE_TIMEOUT);
-       if (!err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d timeout\n", __func__, __LINE__);
-               ep->state = SCIFEP_BOUND;
-       }
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               goto cleanup_qp;
-       }
-       if (ep->state == SCIFEP_MAPPING) {
-               err = scif_setup_qp_connect_response(ep->remote_dev,
-                                                    ep->qp_info.qp,
-                                                    ep->qp_info.gnt_pld);
-               /*
-                * If the resource to map the queue are not available then
-                * we need to tell the other side to terminate the accept
-                */
-               if (err) {
-                       dev_err(&ep->remote_dev->sdev->dev,
-                               "%s %d err %d\n", __func__, __LINE__, err);
-                       msg.uop = SCIF_CNCT_GNTNACK;
-                       msg.payload[0] = ep->remote_ep;
-                       _scif_nodeqp_send(ep->remote_dev, &msg);
-                       ep->state = SCIFEP_BOUND;
-                       goto connect_error_dec;
-               }
-
-               msg.uop = SCIF_CNCT_GNTACK;
-               msg.payload[0] = ep->remote_ep;
-               err = _scif_nodeqp_send(ep->remote_dev, &msg);
-               if (err) {
-                       ep->state = SCIFEP_BOUND;
-                       goto connect_error_dec;
-               }
-               ep->state = SCIFEP_CONNECTED;
-               mutex_lock(&scif_info.connlock);
-               list_add_tail(&ep->list, &scif_info.connected);
-               mutex_unlock(&scif_info.connlock);
-               dev_dbg(&ep->remote_dev->sdev->dev,
-                       "SCIFAPI connect: ep %p connected\n", ep);
-       } else if (ep->state == SCIFEP_BOUND) {
-               dev_dbg(&ep->remote_dev->sdev->dev,
-                       "SCIFAPI connect: ep %p connection refused\n", ep);
-               err = -ECONNREFUSED;
-               goto connect_error_dec;
-       }
-       scif_put_peer_dev(spdev);
-       return err;
-connect_error_dec:
-       scif_put_peer_dev(spdev);
-cleanup_qp:
-       scif_cleanup_ep_qp(ep);
-connect_error_simple:
-       return err;
-}
-
-/*
- * scif_conn_handler:
- *
- * Workqueue handler for servicing non-blocking SCIF connect
- *
- */
-void scif_conn_handler(struct work_struct *work)
-{
-       struct scif_endpt *ep;
-
-       do {
-               ep = NULL;
-               spin_lock(&scif_info.nb_connect_lock);
-               if (!list_empty(&scif_info.nb_connect_list)) {
-                       ep = list_first_entry(&scif_info.nb_connect_list,
-                                             struct scif_endpt, conn_list);
-                       list_del(&ep->conn_list);
-               }
-               spin_unlock(&scif_info.nb_connect_lock);
-               if (ep) {
-                       ep->conn_err = scif_conn_func(ep);
-                       wake_up_interruptible(&ep->conn_pend_wq);
-               }
-       } while (ep);
-}
-
-int __scif_connect(scif_epd_t epd, struct scif_port_id *dst, bool non_block)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-       struct scif_dev *remote_dev;
-       struct device *spdev;
-
-       dev_dbg(scif_info.mdev.this_device, "SCIFAPI connect: ep %p %s\n", ep,
-               scif_ep_states[ep->state]);
-
-       if (!scif_dev || dst->node > scif_info.maxid)
-               return -ENODEV;
-
-       might_sleep();
-
-       remote_dev = &scif_dev[dst->node];
-       spdev = scif_get_peer_dev(remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               return err;
-       }
-
-       spin_lock(&ep->lock);
-       switch (ep->state) {
-       case SCIFEP_ZOMBIE:
-       case SCIFEP_CLOSING:
-               err = -EINVAL;
-               break;
-       case SCIFEP_DISCONNECTED:
-               if (ep->conn_async_state == ASYNC_CONN_INPROGRESS)
-                       ep->conn_async_state = ASYNC_CONN_FLUSH_WORK;
-               else
-                       err = -EINVAL;
-               break;
-       case SCIFEP_LISTENING:
-       case SCIFEP_CLLISTEN:
-               err = -EOPNOTSUPP;
-               break;
-       case SCIFEP_CONNECTING:
-       case SCIFEP_MAPPING:
-               if (ep->conn_async_state == ASYNC_CONN_INPROGRESS)
-                       err = -EINPROGRESS;
-               else
-                       err = -EISCONN;
-               break;
-       case SCIFEP_CONNECTED:
-               if (ep->conn_async_state == ASYNC_CONN_INPROGRESS)
-                       ep->conn_async_state = ASYNC_CONN_FLUSH_WORK;
-               else
-                       err = -EISCONN;
-               break;
-       case SCIFEP_UNBOUND:
-               err = scif_get_new_port();
-               if (err < 0)
-                       break;
-               ep->port.port = err;
-               ep->port.node = scif_info.nodeid;
-               ep->conn_async_state = ASYNC_CONN_IDLE;
-               fallthrough;
-       case SCIFEP_BOUND:
-               /*
-                * If a non-blocking connect has been already initiated
-                * (conn_async_state is either ASYNC_CONN_INPROGRESS or
-                * ASYNC_CONN_FLUSH_WORK), the end point could end up in
-                * SCIF_BOUND due an error in the connection process
-                * (e.g., connection refused) If conn_async_state is
-                * ASYNC_CONN_INPROGRESS - transition to ASYNC_CONN_FLUSH_WORK
-                * so that the error status can be collected. If the state is
-                * already ASYNC_CONN_FLUSH_WORK - then set the error to
-                * EINPROGRESS since some other thread is waiting to collect
-                * error status.
-                */
-               if (ep->conn_async_state == ASYNC_CONN_INPROGRESS) {
-                       ep->conn_async_state = ASYNC_CONN_FLUSH_WORK;
-               } else if (ep->conn_async_state == ASYNC_CONN_FLUSH_WORK) {
-                       err = -EINPROGRESS;
-               } else {
-                       ep->conn_port = *dst;
-                       init_waitqueue_head(&ep->sendwq);
-                       init_waitqueue_head(&ep->recvwq);
-                       init_waitqueue_head(&ep->conwq);
-                       ep->conn_async_state = 0;
-
-                       if (unlikely(non_block))
-                               ep->conn_async_state = ASYNC_CONN_INPROGRESS;
-               }
-               break;
-       }
-
-       if (err || ep->conn_async_state == ASYNC_CONN_FLUSH_WORK)
-                       goto connect_simple_unlock1;
-
-       ep->state = SCIFEP_CONNECTING;
-       ep->remote_dev = &scif_dev[dst->node];
-       ep->qp_info.qp->magic = SCIFEP_MAGIC;
-       if (ep->conn_async_state == ASYNC_CONN_INPROGRESS) {
-               init_waitqueue_head(&ep->conn_pend_wq);
-               spin_lock(&scif_info.nb_connect_lock);
-               list_add_tail(&ep->conn_list, &scif_info.nb_connect_list);
-               spin_unlock(&scif_info.nb_connect_lock);
-               err = -EINPROGRESS;
-               schedule_work(&scif_info.conn_work);
-       }
-connect_simple_unlock1:
-       spin_unlock(&ep->lock);
-       scif_put_peer_dev(spdev);
-       if (err) {
-               return err;
-       } else if (ep->conn_async_state == ASYNC_CONN_FLUSH_WORK) {
-               flush_work(&scif_info.conn_work);
-               err = ep->conn_err;
-               spin_lock(&ep->lock);
-               ep->conn_async_state = ASYNC_CONN_IDLE;
-               spin_unlock(&ep->lock);
-       } else {
-               err = scif_conn_func(ep);
-       }
-       return err;
-}
-
-int scif_connect(scif_epd_t epd, struct scif_port_id *dst)
-{
-       return __scif_connect(epd, dst, false);
-}
-EXPORT_SYMBOL_GPL(scif_connect);
-
-/*
- * scif_accept() - Accept a connection request from the remote node
- *
- * The function accepts a connection request from the remote node.  Successful
- * complete is indicate by a new end point being created and passed back
- * to the caller for future reference.
- *
- * Upon successful complete a zero will be returned and the peer information
- * will be filled in.
- *
- * If the end point is not in the listening state -EINVAL will be returned.
- *
- * If during the connection sequence resource allocation fails the -ENOMEM
- * will be returned.
- *
- * If the function is called with the ASYNC flag set and no connection requests
- * are pending it will return -EAGAIN.
- *
- * If the remote side is not sending any connection requests the caller may
- * terminate this function with a signal.  If so a -EINTR will be returned.
- */
-int scif_accept(scif_epd_t epd, struct scif_port_id *peer,
-               scif_epd_t *newepd, int flags)
-{
-       struct scif_endpt *lep = (struct scif_endpt *)epd;
-       struct scif_endpt *cep;
-       struct scif_conreq *conreq;
-       struct scifmsg msg;
-       int err;
-       struct device *spdev;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI accept: ep %p %s\n", lep, scif_ep_states[lep->state]);
-
-       if (flags & ~SCIF_ACCEPT_SYNC)
-               return -EINVAL;
-
-       if (!peer || !newepd)
-               return -EINVAL;
-
-       might_sleep();
-       spin_lock(&lep->lock);
-       if (lep->state != SCIFEP_LISTENING) {
-               spin_unlock(&lep->lock);
-               return -EINVAL;
-       }
-
-       if (!lep->conreqcnt && !(flags & SCIF_ACCEPT_SYNC)) {
-               /* No connection request present and we do not want to wait */
-               spin_unlock(&lep->lock);
-               return -EAGAIN;
-       }
-
-       lep->files = current->files;
-retry_connection:
-       spin_unlock(&lep->lock);
-       /* Wait for the remote node to send us a SCIF_CNCT_REQ */
-       err = wait_event_interruptible(lep->conwq,
-                                      (lep->conreqcnt ||
-                                      (lep->state != SCIFEP_LISTENING)));
-       if (err)
-               return err;
-
-       if (lep->state != SCIFEP_LISTENING)
-               return -EINTR;
-
-       spin_lock(&lep->lock);
-
-       if (!lep->conreqcnt)
-               goto retry_connection;
-
-       /* Get the first connect request off the list */
-       conreq = list_first_entry(&lep->conlist, struct scif_conreq, list);
-       list_del(&conreq->list);
-       lep->conreqcnt--;
-       spin_unlock(&lep->lock);
-
-       /* Fill in the peer information */
-       peer->node = conreq->msg.src.node;
-       peer->port = conreq->msg.src.port;
-
-       cep = kzalloc(sizeof(*cep), GFP_KERNEL);
-       if (!cep) {
-               err = -ENOMEM;
-               goto scif_accept_error_epalloc;
-       }
-       spin_lock_init(&cep->lock);
-       mutex_init(&cep->sendlock);
-       mutex_init(&cep->recvlock);
-       cep->state = SCIFEP_CONNECTING;
-       cep->remote_dev = &scif_dev[peer->node];
-       cep->remote_ep = conreq->msg.payload[0];
-
-       scif_rma_ep_init(cep);
-
-       err = scif_reserve_dma_chan(cep);
-       if (err) {
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto scif_accept_error_qpalloc;
-       }
-
-       cep->qp_info.qp = kzalloc(sizeof(*cep->qp_info.qp), GFP_KERNEL);
-       if (!cep->qp_info.qp) {
-               err = -ENOMEM;
-               goto scif_accept_error_qpalloc;
-       }
-
-       err = scif_anon_inode_getfile(cep);
-       if (err)
-               goto scif_accept_error_anon_inode;
-
-       cep->qp_info.qp->magic = SCIFEP_MAGIC;
-       spdev = scif_get_peer_dev(cep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               goto scif_accept_error_map;
-       }
-       err = scif_setup_qp_accept(cep->qp_info.qp, &cep->qp_info.qp_offset,
-                                  conreq->msg.payload[1], SCIF_ENDPT_QP_SIZE,
-                                  cep->remote_dev);
-       if (err) {
-               dev_dbg(&cep->remote_dev->sdev->dev,
-                       "SCIFAPI accept: ep %p new %p scif_setup_qp_accept %d qp_offset 0x%llx\n",
-                       lep, cep, err, cep->qp_info.qp_offset);
-               scif_put_peer_dev(spdev);
-               goto scif_accept_error_map;
-       }
-
-       cep->port.node = lep->port.node;
-       cep->port.port = lep->port.port;
-       cep->peer.node = peer->node;
-       cep->peer.port = peer->port;
-       init_waitqueue_head(&cep->sendwq);
-       init_waitqueue_head(&cep->recvwq);
-       init_waitqueue_head(&cep->conwq);
-
-       msg.uop = SCIF_CNCT_GNT;
-       msg.src = cep->port;
-       msg.payload[0] = cep->remote_ep;
-       msg.payload[1] = cep->qp_info.qp_offset;
-       msg.payload[2] = (u64)cep;
-
-       err = _scif_nodeqp_send(cep->remote_dev, &msg);
-       scif_put_peer_dev(spdev);
-       if (err)
-               goto scif_accept_error_map;
-retry:
-       /* Wait for the remote node to respond with SCIF_CNCT_GNT(N)ACK */
-       err = wait_event_timeout(cep->conwq, cep->state != SCIFEP_CONNECTING,
-                                SCIF_NODE_ACCEPT_TIMEOUT);
-       if (!err && scifdev_alive(cep))
-               goto retry;
-       err = !err ? -ENODEV : 0;
-       if (err)
-               goto scif_accept_error_map;
-       kfree(conreq);
-
-       spin_lock(&cep->lock);
-
-       if (cep->state == SCIFEP_CLOSING) {
-               /*
-                * Remote failed to allocate resources and NAKed the grant.
-                * There is at this point nothing referencing the new end point.
-                */
-               spin_unlock(&cep->lock);
-               scif_teardown_ep(cep);
-               kfree(cep);
-
-               /* If call with sync flag then go back and wait. */
-               if (flags & SCIF_ACCEPT_SYNC) {
-                       spin_lock(&lep->lock);
-                       goto retry_connection;
-               }
-               return -EAGAIN;
-       }
-
-       scif_get_port(cep->port.port);
-       *newepd = (scif_epd_t)cep;
-       spin_unlock(&cep->lock);
-       return 0;
-scif_accept_error_map:
-       scif_anon_inode_fput(cep);
-scif_accept_error_anon_inode:
-       scif_teardown_ep(cep);
-scif_accept_error_qpalloc:
-       kfree(cep);
-scif_accept_error_epalloc:
-       msg.uop = SCIF_CNCT_REJ;
-       msg.dst.node = conreq->msg.src.node;
-       msg.dst.port = conreq->msg.src.port;
-       msg.payload[0] = conreq->msg.payload[0];
-       msg.payload[1] = conreq->msg.payload[1];
-       scif_nodeqp_send(&scif_dev[conreq->msg.src.node], &msg);
-       kfree(conreq);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_accept);
-
-/*
- * scif_msg_param_check:
- * @epd: The end point returned from scif_open()
- * @len: Length to receive
- * @flags: blocking or non blocking
- *
- * Validate parameters for messaging APIs scif_send(..)/scif_recv(..).
- */
-static inline int scif_msg_param_check(scif_epd_t epd, int len, int flags)
-{
-       int ret = -EINVAL;
-
-       if (len < 0)
-               goto err_ret;
-       if (flags && (!(flags & SCIF_RECV_BLOCK)))
-               goto err_ret;
-       ret = 0;
-err_ret:
-       return ret;
-}
-
-static int _scif_send(scif_epd_t epd, void *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scifmsg notif_msg;
-       int curr_xfer_len = 0, sent_len = 0, write_count;
-       int ret = 0;
-       struct scif_qp *qp = ep->qp_info.qp;
-
-       if (flags & SCIF_SEND_BLOCK)
-               might_sleep();
-
-       spin_lock(&ep->lock);
-       while (sent_len != len && SCIFEP_CONNECTED == ep->state) {
-               write_count = scif_rb_space(&qp->outbound_q);
-               if (write_count) {
-                       /* Best effort to send as much data as possible */
-                       curr_xfer_len = min(len - sent_len, write_count);
-                       ret = scif_rb_write(&qp->outbound_q, msg,
-                                           curr_xfer_len);
-                       if (ret < 0)
-                               break;
-                       /* Success. Update write pointer */
-                       scif_rb_commit(&qp->outbound_q);
-                       /*
-                        * Send a notification to the peer about the
-                        * produced data message.
-                        */
-                       notif_msg.src = ep->port;
-                       notif_msg.uop = SCIF_CLIENT_SENT;
-                       notif_msg.payload[0] = ep->remote_ep;
-                       ret = _scif_nodeqp_send(ep->remote_dev, &notif_msg);
-                       if (ret)
-                               break;
-                       sent_len += curr_xfer_len;
-                       msg = msg + curr_xfer_len;
-                       continue;
-               }
-               curr_xfer_len = min(len - sent_len, SCIF_ENDPT_QP_SIZE - 1);
-               /* Not enough RB space. return for the Non Blocking case */
-               if (!(flags & SCIF_SEND_BLOCK))
-                       break;
-
-               spin_unlock(&ep->lock);
-               /* Wait for a SCIF_CLIENT_RCVD message in the Blocking case */
-               ret =
-               wait_event_interruptible(ep->sendwq,
-                                        (SCIFEP_CONNECTED != ep->state) ||
-                                        (scif_rb_space(&qp->outbound_q) >=
-                                        curr_xfer_len));
-               spin_lock(&ep->lock);
-               if (ret)
-                       break;
-       }
-       if (sent_len)
-               ret = sent_len;
-       else if (!ret && SCIFEP_CONNECTED != ep->state)
-               ret = SCIFEP_DISCONNECTED == ep->state ?
-                       -ECONNRESET : -ENOTCONN;
-       spin_unlock(&ep->lock);
-       return ret;
-}
-
-static int _scif_recv(scif_epd_t epd, void *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scifmsg notif_msg;
-       int curr_recv_len = 0, remaining_len = len, read_count;
-       int ret = 0;
-       struct scif_qp *qp = ep->qp_info.qp;
-
-       if (flags & SCIF_RECV_BLOCK)
-               might_sleep();
-       spin_lock(&ep->lock);
-       while (remaining_len && (SCIFEP_CONNECTED == ep->state ||
-                                SCIFEP_DISCONNECTED == ep->state)) {
-               read_count = scif_rb_count(&qp->inbound_q, remaining_len);
-               if (read_count) {
-                       /*
-                        * Best effort to recv as much data as there
-                        * are bytes to read in the RB particularly
-                        * important for the Non Blocking case.
-                        */
-                       curr_recv_len = min(remaining_len, read_count);
-                       scif_rb_get_next(&qp->inbound_q, msg, curr_recv_len);
-                       if (ep->state == SCIFEP_CONNECTED) {
-                               /*
-                                * Update the read pointer only if the endpoint
-                                * is still connected else the read pointer
-                                * might no longer exist since the peer has
-                                * freed resources!
-                                */
-                               scif_rb_update_read_ptr(&qp->inbound_q);
-                               /*
-                                * Send a notification to the peer about the
-                                * consumed data message only if the EP is in
-                                * SCIFEP_CONNECTED state.
-                                */
-                               notif_msg.src = ep->port;
-                               notif_msg.uop = SCIF_CLIENT_RCVD;
-                               notif_msg.payload[0] = ep->remote_ep;
-                               ret = _scif_nodeqp_send(ep->remote_dev,
-                                                       &notif_msg);
-                               if (ret)
-                                       break;
-                       }
-                       remaining_len -= curr_recv_len;
-                       msg = msg + curr_recv_len;
-                       continue;
-               }
-               /*
-                * Bail out now if the EP is in SCIFEP_DISCONNECTED state else
-                * we will keep looping forever.
-                */
-               if (ep->state == SCIFEP_DISCONNECTED)
-                       break;
-               /*
-                * Return in the Non Blocking case if there is no data
-                * to read in this iteration.
-                */
-               if (!(flags & SCIF_RECV_BLOCK))
-                       break;
-               curr_recv_len = min(remaining_len, SCIF_ENDPT_QP_SIZE - 1);
-               spin_unlock(&ep->lock);
-               /*
-                * Wait for a SCIF_CLIENT_SEND message in the blocking case
-                * or until other side disconnects.
-                */
-               ret =
-               wait_event_interruptible(ep->recvwq,
-                                        SCIFEP_CONNECTED != ep->state ||
-                                        scif_rb_count(&qp->inbound_q,
-                                                      curr_recv_len)
-                                        >= curr_recv_len);
-               spin_lock(&ep->lock);
-               if (ret)
-                       break;
-       }
-       if (len - remaining_len)
-               ret = len - remaining_len;
-       else if (!ret && ep->state != SCIFEP_CONNECTED)
-               ret = ep->state == SCIFEP_DISCONNECTED ?
-                       -ECONNRESET : -ENOTCONN;
-       spin_unlock(&ep->lock);
-       return ret;
-}
-
-/**
- * scif_user_send() - Send data to connection queue
- * @epd: The end point returned from scif_open()
- * @msg: Address to place data
- * @len: Length to receive
- * @flags: blocking or non blocking
- *
- * This function is called from the driver IOCTL entry point
- * only and is a wrapper for _scif_send().
- */
-int scif_user_send(scif_epd_t epd, void __user *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-       int sent_len = 0;
-       char *tmp;
-       int loop_len;
-       int chunk_len = min(len, (1 << (MAX_ORDER + PAGE_SHIFT - 1)));
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI send (U): ep %p %s\n", ep, scif_ep_states[ep->state]);
-       if (!len)
-               return 0;
-
-       err = scif_msg_param_check(epd, len, flags);
-       if (err)
-               goto send_err;
-
-       tmp = kmalloc(chunk_len, GFP_KERNEL);
-       if (!tmp) {
-               err = -ENOMEM;
-               goto send_err;
-       }
-       /*
-        * Grabbing the lock before breaking up the transfer in
-        * multiple chunks is required to ensure that messages do
-        * not get fragmented and reordered.
-        */
-       mutex_lock(&ep->sendlock);
-       while (sent_len != len) {
-               loop_len = len - sent_len;
-               loop_len = min(chunk_len, loop_len);
-               if (copy_from_user(tmp, msg, loop_len)) {
-                       err = -EFAULT;
-                       goto send_free_err;
-               }
-               err = _scif_send(epd, tmp, loop_len, flags);
-               if (err < 0)
-                       goto send_free_err;
-               sent_len += err;
-               msg += err;
-               if (err != loop_len)
-                       goto send_free_err;
-       }
-send_free_err:
-       mutex_unlock(&ep->sendlock);
-       kfree(tmp);
-send_err:
-       return err < 0 ? err : sent_len;
-}
-
-/**
- * scif_user_recv() - Receive data from connection queue
- * @epd: The end point returned from scif_open()
- * @msg: Address to place data
- * @len: Length to receive
- * @flags: blocking or non blocking
- *
- * This function is called from the driver IOCTL entry point
- * only and is a wrapper for _scif_recv().
- */
-int scif_user_recv(scif_epd_t epd, void __user *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-       int recv_len = 0;
-       char *tmp;
-       int loop_len;
-       int chunk_len = min(len, (1 << (MAX_ORDER + PAGE_SHIFT - 1)));
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI recv (U): ep %p %s\n", ep, scif_ep_states[ep->state]);
-       if (!len)
-               return 0;
-
-       err = scif_msg_param_check(epd, len, flags);
-       if (err)
-               goto recv_err;
-
-       tmp = kmalloc(chunk_len, GFP_KERNEL);
-       if (!tmp) {
-               err = -ENOMEM;
-               goto recv_err;
-       }
-       /*
-        * Grabbing the lock before breaking up the transfer in
-        * multiple chunks is required to ensure that messages do
-        * not get fragmented and reordered.
-        */
-       mutex_lock(&ep->recvlock);
-       while (recv_len != len) {
-               loop_len = len - recv_len;
-               loop_len = min(chunk_len, loop_len);
-               err = _scif_recv(epd, tmp, loop_len, flags);
-               if (err < 0)
-                       goto recv_free_err;
-               if (copy_to_user(msg, tmp, err)) {
-                       err = -EFAULT;
-                       goto recv_free_err;
-               }
-               recv_len += err;
-               msg += err;
-               if (err != loop_len)
-                       goto recv_free_err;
-       }
-recv_free_err:
-       mutex_unlock(&ep->recvlock);
-       kfree(tmp);
-recv_err:
-       return err < 0 ? err : recv_len;
-}
-
-/**
- * scif_send() - Send data to connection queue
- * @epd: The end point returned from scif_open()
- * @msg: Address to place data
- * @len: Length to receive
- * @flags: blocking or non blocking
- *
- * This function is called from the kernel mode only and is
- * a wrapper for _scif_send().
- */
-int scif_send(scif_epd_t epd, void *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int ret;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI send (K): ep %p %s\n", ep, scif_ep_states[ep->state]);
-       if (!len)
-               return 0;
-
-       ret = scif_msg_param_check(epd, len, flags);
-       if (ret)
-               return ret;
-       if (!ep->remote_dev)
-               return -ENOTCONN;
-       /*
-        * Grab the mutex lock in the blocking case only
-        * to ensure messages do not get fragmented/reordered.
-        * The non blocking mode is protected using spin locks
-        * in _scif_send().
-        */
-       if (flags & SCIF_SEND_BLOCK)
-               mutex_lock(&ep->sendlock);
-
-       ret = _scif_send(epd, msg, len, flags);
-
-       if (flags & SCIF_SEND_BLOCK)
-               mutex_unlock(&ep->sendlock);
-       return ret;
-}
-EXPORT_SYMBOL_GPL(scif_send);
-
-/**
- * scif_recv() - Receive data from connection queue
- * @epd: The end point returned from scif_open()
- * @msg: Address to place data
- * @len: Length to receive
- * @flags: blocking or non blocking
- *
- * This function is called from the kernel mode only and is
- * a wrapper for _scif_recv().
- */
-int scif_recv(scif_epd_t epd, void *msg, int len, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int ret;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI recv (K): ep %p %s\n", ep, scif_ep_states[ep->state]);
-       if (!len)
-               return 0;
-
-       ret = scif_msg_param_check(epd, len, flags);
-       if (ret)
-               return ret;
-       /*
-        * Grab the mutex lock in the blocking case only
-        * to ensure messages do not get fragmented/reordered.
-        * The non blocking mode is protected using spin locks
-        * in _scif_send().
-        */
-       if (flags & SCIF_RECV_BLOCK)
-               mutex_lock(&ep->recvlock);
-
-       ret = _scif_recv(epd, msg, len, flags);
-
-       if (flags & SCIF_RECV_BLOCK)
-               mutex_unlock(&ep->recvlock);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(scif_recv);
-
-static inline void _scif_poll_wait(struct file *f, wait_queue_head_t *wq,
-                                  poll_table *p, struct scif_endpt *ep)
-{
-       /*
-        * Because poll_wait makes a GFP_KERNEL allocation, give up the lock
-        * and regrab it afterwards. Because the endpoint state might have
-        * changed while the lock was given up, the state must be checked
-        * again after re-acquiring the lock. The code in __scif_pollfd(..)
-        * does this.
-        */
-       spin_unlock(&ep->lock);
-       poll_wait(f, wq, p);
-       spin_lock(&ep->lock);
-}
-
-__poll_t
-__scif_pollfd(struct file *f, poll_table *wait, struct scif_endpt *ep)
-{
-       __poll_t mask = 0;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI pollfd: ep %p %s\n", ep, scif_ep_states[ep->state]);
-
-       spin_lock(&ep->lock);
-
-       /* Endpoint is waiting for a non-blocking connect to complete */
-       if (ep->conn_async_state == ASYNC_CONN_INPROGRESS) {
-               _scif_poll_wait(f, &ep->conn_pend_wq, wait, ep);
-               if (ep->conn_async_state == ASYNC_CONN_INPROGRESS) {
-                       if (ep->state == SCIFEP_CONNECTED ||
-                           ep->state == SCIFEP_DISCONNECTED ||
-                           ep->conn_err)
-                               mask |= EPOLLOUT;
-                       goto exit;
-               }
-       }
-
-       /* Endpoint is listening for incoming connection requests */
-       if (ep->state == SCIFEP_LISTENING) {
-               _scif_poll_wait(f, &ep->conwq, wait, ep);
-               if (ep->state == SCIFEP_LISTENING) {
-                       if (ep->conreqcnt)
-                               mask |= EPOLLIN;
-                       goto exit;
-               }
-       }
-
-       /* Endpoint is connected or disconnected */
-       if (ep->state == SCIFEP_CONNECTED || ep->state == SCIFEP_DISCONNECTED) {
-               if (poll_requested_events(wait) & EPOLLIN)
-                       _scif_poll_wait(f, &ep->recvwq, wait, ep);
-               if (poll_requested_events(wait) & EPOLLOUT)
-                       _scif_poll_wait(f, &ep->sendwq, wait, ep);
-               if (ep->state == SCIFEP_CONNECTED ||
-                   ep->state == SCIFEP_DISCONNECTED) {
-                       /* Data can be read without blocking */
-                       if (scif_rb_count(&ep->qp_info.qp->inbound_q, 1))
-                               mask |= EPOLLIN;
-                       /* Data can be written without blocking */
-                       if (scif_rb_space(&ep->qp_info.qp->outbound_q))
-                               mask |= EPOLLOUT;
-                       /* Return EPOLLHUP if endpoint is disconnected */
-                       if (ep->state == SCIFEP_DISCONNECTED)
-                               mask |= EPOLLHUP;
-                       goto exit;
-               }
-       }
-
-       /* Return EPOLLERR if the endpoint is in none of the above states */
-       mask |= EPOLLERR;
-exit:
-       spin_unlock(&ep->lock);
-       return mask;
-}
-
-/**
- * scif_poll() - Kernel mode SCIF poll
- * @ufds: Array of scif_pollepd structures containing the end points
- *       and events to poll on
- * @nfds: Size of the ufds array
- * @timeout_msecs: Timeout in msecs, -ve implies infinite timeout
- *
- * The code flow in this function is based on do_poll(..) in select.c
- *
- * Returns the number of endpoints which have pending events or 0 in
- * the event of a timeout. If a signal is used for wake up, -EINTR is
- * returned.
- */
-int
-scif_poll(struct scif_pollepd *ufds, unsigned int nfds, long timeout_msecs)
-{
-       struct poll_wqueues table;
-       poll_table *pt;
-       int i, count = 0, timed_out = timeout_msecs == 0;
-       __poll_t mask;
-       u64 timeout = timeout_msecs < 0 ? MAX_SCHEDULE_TIMEOUT
-               : msecs_to_jiffies(timeout_msecs);
-
-       poll_initwait(&table);
-       pt = &table.pt;
-       while (1) {
-               for (i = 0; i < nfds; i++) {
-                       pt->_key = ufds[i].events | EPOLLERR | EPOLLHUP;
-                       mask = __scif_pollfd(ufds[i].epd->anon,
-                                            pt, ufds[i].epd);
-                       mask &= ufds[i].events | EPOLLERR | EPOLLHUP;
-                       if (mask) {
-                               count++;
-                               pt->_qproc = NULL;
-                       }
-                       ufds[i].revents = mask;
-               }
-               pt->_qproc = NULL;
-               if (!count) {
-                       count = table.error;
-                       if (signal_pending(current))
-                               count = -EINTR;
-               }
-               if (count || timed_out)
-                       break;
-
-               if (!schedule_timeout_interruptible(timeout))
-                       timed_out = 1;
-       }
-       poll_freewait(&table);
-       return count;
-}
-EXPORT_SYMBOL_GPL(scif_poll);
-
-int scif_get_node_ids(u16 *nodes, int len, u16 *self)
-{
-       int online = 0;
-       int offset = 0;
-       int node;
-
-       if (!scif_is_mgmt_node())
-               scif_get_node_info();
-
-       *self = scif_info.nodeid;
-       mutex_lock(&scif_info.conflock);
-       len = min_t(int, len, scif_info.total);
-       for (node = 0; node <= scif_info.maxid; node++) {
-               if (_scifdev_alive(&scif_dev[node])) {
-                       online++;
-                       if (offset < len)
-                               nodes[offset++] = node;
-               }
-       }
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI get_node_ids total %d online %d filled in %d nodes\n",
-               scif_info.total, online, offset);
-       mutex_unlock(&scif_info.conflock);
-
-       return online;
-}
-EXPORT_SYMBOL_GPL(scif_get_node_ids);
-
-static int scif_add_client_dev(struct device *dev, struct subsys_interface *si)
-{
-       struct scif_client *client =
-               container_of(si, struct scif_client, si);
-       struct scif_peer_dev *spdev =
-               container_of(dev, struct scif_peer_dev, dev);
-
-       if (client->probe)
-               client->probe(spdev);
-       return 0;
-}
-
-static void scif_remove_client_dev(struct device *dev,
-                                  struct subsys_interface *si)
-{
-       struct scif_client *client =
-               container_of(si, struct scif_client, si);
-       struct scif_peer_dev *spdev =
-               container_of(dev, struct scif_peer_dev, dev);
-
-       if (client->remove)
-               client->remove(spdev);
-}
-
-void scif_client_unregister(struct scif_client *client)
-{
-       subsys_interface_unregister(&client->si);
-}
-EXPORT_SYMBOL_GPL(scif_client_unregister);
-
-int scif_client_register(struct scif_client *client)
-{
-       struct subsys_interface *si = &client->si;
-
-       si->name = client->name;
-       si->subsys = &scif_peer_bus;
-       si->add_dev = scif_add_client_dev;
-       si->remove_dev = scif_remove_client_dev;
-
-       return subsys_interface_register(&client->si);
-}
-EXPORT_SYMBOL_GPL(scif_client_register);
diff --git a/drivers/misc/mic/scif/scif_debugfs.c b/drivers/misc/mic/scif/scif_debugfs.c
deleted file mode 100644 (file)
index 8fe38e7..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
-
-#include "../common/mic_dev.h"
-#include "scif_main.h"
-
-/* Debugfs parent dir */
-static struct dentry *scif_dbg;
-
-static int scif_dev_show(struct seq_file *s, void *unused)
-{
-       int node;
-
-       seq_printf(s, "Total Nodes %d Self Node Id %d Maxid %d\n",
-                  scif_info.total, scif_info.nodeid,
-                  scif_info.maxid);
-
-       if (!scif_dev)
-               return 0;
-
-       seq_printf(s, "%-16s\t%-16s\n", "node_id", "state");
-
-       for (node = 0; node <= scif_info.maxid; node++)
-               seq_printf(s, "%-16d\t%-16s\n", scif_dev[node].node,
-                          _scifdev_alive(&scif_dev[node]) ?
-                          "Running" : "Offline");
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(scif_dev);
-
-static void scif_display_window(struct scif_window *window, struct seq_file *s)
-{
-       int j;
-       struct scatterlist *sg;
-       scif_pinned_pages_t pin = window->pinned_pages;
-
-       seq_printf(s, "window %p type %d temp %d offset 0x%llx ",
-                  window, window->type, window->temp, window->offset);
-       seq_printf(s, "nr_pages 0x%llx nr_contig_chunks 0x%x prot %d ",
-                  window->nr_pages, window->nr_contig_chunks, window->prot);
-       seq_printf(s, "ref_count %d magic 0x%llx peer_window 0x%llx ",
-                  window->ref_count, window->magic, window->peer_window);
-       seq_printf(s, "unreg_state 0x%x va_for_temp 0x%lx\n",
-                  window->unreg_state, window->va_for_temp);
-
-       for (j = 0; j < window->nr_contig_chunks; j++)
-               seq_printf(s, "page[%d] dma_addr 0x%llx num_pages 0x%llx\n", j,
-                          window->dma_addr[j], window->num_pages[j]);
-
-       if (window->type == SCIF_WINDOW_SELF && pin)
-               for (j = 0; j < window->nr_pages; j++)
-                       seq_printf(s, "page[%d] = pinned_pages %p address %p\n",
-                                  j, pin->pages[j],
-                                  page_address(pin->pages[j]));
-
-       if (window->st)
-               for_each_sg(window->st->sgl, sg, window->st->nents, j)
-                       seq_printf(s, "sg[%d] dma addr 0x%llx length 0x%x\n",
-                                  j, sg_dma_address(sg), sg_dma_len(sg));
-}
-
-static void scif_display_all_windows(struct list_head *head, struct seq_file *s)
-{
-       struct list_head *item;
-       struct scif_window *window;
-
-       list_for_each(item, head) {
-               window = list_entry(item, struct scif_window, list);
-               scif_display_window(window, s);
-       }
-}
-
-static int scif_rma_show(struct seq_file *s, void *unused)
-{
-       struct scif_endpt *ep;
-       struct list_head *pos;
-
-       mutex_lock(&scif_info.connlock);
-       list_for_each(pos, &scif_info.connected) {
-               ep = list_entry(pos, struct scif_endpt, list);
-               seq_printf(s, "ep %p self windows\n", ep);
-               mutex_lock(&ep->rma_info.rma_lock);
-               scif_display_all_windows(&ep->rma_info.reg_list, s);
-               seq_printf(s, "ep %p remote windows\n", ep);
-               scif_display_all_windows(&ep->rma_info.remote_reg_list, s);
-               mutex_unlock(&ep->rma_info.rma_lock);
-       }
-       mutex_unlock(&scif_info.connlock);
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(scif_rma);
-
-void __init scif_init_debugfs(void)
-{
-       scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
-
-       debugfs_create_file("scif_dev", 0444, scif_dbg, NULL, &scif_dev_fops);
-       debugfs_create_file("scif_rma", 0444, scif_dbg, NULL, &scif_rma_fops);
-       debugfs_create_u8("en_msg_log", 0666, scif_dbg, &scif_info.en_msg_log);
-       debugfs_create_u8("p2p_enable", 0666, scif_dbg, &scif_info.p2p_enable);
-}
-
-void scif_exit_debugfs(void)
-{
-       debugfs_remove_recursive(scif_dbg);
-}
diff --git a/drivers/misc/mic/scif/scif_dma.c b/drivers/misc/mic/scif/scif_dma.c
deleted file mode 100644 (file)
index 401b98e..0000000
+++ /dev/null
@@ -1,1940 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-#include "scif_map.h"
-
-/*
- * struct scif_dma_comp_cb - SCIF DMA completion callback
- *
- * @dma_completion_func: DMA completion callback
- * @cb_cookie: DMA completion callback cookie
- * @temp_buf: Temporary buffer
- * @temp_buf_to_free: Temporary buffer to be freed
- * @is_cache: Is a kmem_cache allocated buffer
- * @dst_offset: Destination registration offset
- * @dst_window: Destination registration window
- * @len: Length of the temp buffer
- * @temp_phys: DMA address of the temp buffer
- * @sdev: The SCIF device
- * @header_padding: padding for cache line alignment
- */
-struct scif_dma_comp_cb {
-       void (*dma_completion_func)(void *cookie);
-       void *cb_cookie;
-       u8 *temp_buf;
-       u8 *temp_buf_to_free;
-       bool is_cache;
-       s64 dst_offset;
-       struct scif_window *dst_window;
-       size_t len;
-       dma_addr_t temp_phys;
-       struct scif_dev *sdev;
-       int header_padding;
-};
-
-/**
- * struct scif_copy_work - Work for DMA copy
- *
- * @src_offset: Starting source offset
- * @dst_offset: Starting destination offset
- * @src_window: Starting src registered window
- * @dst_window: Starting dst registered window
- * @loopback: true if this is a loopback DMA transfer
- * @len: Length of the transfer
- * @comp_cb: DMA copy completion callback
- * @remote_dev: The remote SCIF peer device
- * @fence_type: polling or interrupt based
- * @ordered: is this a tail byte ordered DMA transfer
- */
-struct scif_copy_work {
-       s64 src_offset;
-       s64 dst_offset;
-       struct scif_window *src_window;
-       struct scif_window *dst_window;
-       int loopback;
-       size_t len;
-       struct scif_dma_comp_cb   *comp_cb;
-       struct scif_dev *remote_dev;
-       int fence_type;
-       bool ordered;
-};
-
-/**
- * scif_reserve_dma_chan:
- * @ep: Endpoint Descriptor.
- *
- * This routine reserves a DMA channel for a particular
- * endpoint. All DMA transfers for an endpoint are always
- * programmed on the same DMA channel.
- */
-int scif_reserve_dma_chan(struct scif_endpt *ep)
-{
-       int err = 0;
-       struct scif_dev *scifdev;
-       struct scif_hw_dev *sdev;
-       struct dma_chan *chan;
-
-       /* Loopback DMAs are not supported on the management node */
-       if (!scif_info.nodeid && scifdev_self(ep->remote_dev))
-               return 0;
-       if (scif_info.nodeid)
-               scifdev = &scif_dev[0];
-       else
-               scifdev = ep->remote_dev;
-       sdev = scifdev->sdev;
-       if (!sdev->num_dma_ch)
-               return -ENODEV;
-       chan = sdev->dma_ch[scifdev->dma_ch_idx];
-       scifdev->dma_ch_idx = (scifdev->dma_ch_idx + 1) % sdev->num_dma_ch;
-       mutex_lock(&ep->rma_info.rma_lock);
-       ep->rma_info.dma_chan = chan;
-       mutex_unlock(&ep->rma_info.rma_lock);
-       return err;
-}
-
-#ifdef CONFIG_MMU_NOTIFIER
-/*
- * scif_rma_destroy_tcw:
- *
- * This routine destroys temporary cached windows
- */
-static
-void __scif_rma_destroy_tcw(struct scif_mmu_notif *mmn,
-                           u64 start, u64 len)
-{
-       struct list_head *item, *tmp;
-       struct scif_window *window;
-       u64 start_va, end_va;
-       u64 end = start + len;
-
-       if (end <= start)
-               return;
-
-       list_for_each_safe(item, tmp, &mmn->tc_reg_list) {
-               window = list_entry(item, struct scif_window, list);
-               if (!len)
-                       break;
-               start_va = window->va_for_temp;
-               end_va = start_va + (window->nr_pages << PAGE_SHIFT);
-               if (start < start_va && end <= start_va)
-                       break;
-               if (start >= end_va)
-                       continue;
-               __scif_rma_destroy_tcw_helper(window);
-       }
-}
-
-static void scif_rma_destroy_tcw(struct scif_mmu_notif *mmn, u64 start, u64 len)
-{
-       struct scif_endpt *ep = mmn->ep;
-
-       spin_lock(&ep->rma_info.tc_lock);
-       __scif_rma_destroy_tcw(mmn, start, len);
-       spin_unlock(&ep->rma_info.tc_lock);
-}
-
-static void scif_rma_destroy_tcw_ep(struct scif_endpt *ep)
-{
-       struct list_head *item, *tmp;
-       struct scif_mmu_notif *mmn;
-
-       list_for_each_safe(item, tmp, &ep->rma_info.mmn_list) {
-               mmn = list_entry(item, struct scif_mmu_notif, list);
-               scif_rma_destroy_tcw(mmn, 0, ULONG_MAX);
-       }
-}
-
-static void __scif_rma_destroy_tcw_ep(struct scif_endpt *ep)
-{
-       struct list_head *item, *tmp;
-       struct scif_mmu_notif *mmn;
-
-       spin_lock(&ep->rma_info.tc_lock);
-       list_for_each_safe(item, tmp, &ep->rma_info.mmn_list) {
-               mmn = list_entry(item, struct scif_mmu_notif, list);
-               __scif_rma_destroy_tcw(mmn, 0, ULONG_MAX);
-       }
-       spin_unlock(&ep->rma_info.tc_lock);
-}
-
-static bool scif_rma_tc_can_cache(struct scif_endpt *ep, size_t cur_bytes)
-{
-       if ((cur_bytes >> PAGE_SHIFT) > scif_info.rma_tc_limit)
-               return false;
-       if ((atomic_read(&ep->rma_info.tcw_total_pages)
-                       + (cur_bytes >> PAGE_SHIFT)) >
-                       scif_info.rma_tc_limit) {
-               dev_info(scif_info.mdev.this_device,
-                        "%s %d total=%d, current=%zu reached max\n",
-                        __func__, __LINE__,
-                        atomic_read(&ep->rma_info.tcw_total_pages),
-                        (1 + (cur_bytes >> PAGE_SHIFT)));
-               scif_rma_destroy_tcw_invalid();
-               __scif_rma_destroy_tcw_ep(ep);
-       }
-       return true;
-}
-
-static void scif_mmu_notifier_release(struct mmu_notifier *mn,
-                                     struct mm_struct *mm)
-{
-       struct scif_mmu_notif   *mmn;
-
-       mmn = container_of(mn, struct scif_mmu_notif, ep_mmu_notifier);
-       scif_rma_destroy_tcw(mmn, 0, ULONG_MAX);
-       schedule_work(&scif_info.misc_work);
-}
-
-static int scif_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
-                                       const struct mmu_notifier_range *range)
-{
-       struct scif_mmu_notif   *mmn;
-
-       mmn = container_of(mn, struct scif_mmu_notif, ep_mmu_notifier);
-       scif_rma_destroy_tcw(mmn, range->start, range->end - range->start);
-
-       return 0;
-}
-
-static void scif_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,
-                       const struct mmu_notifier_range *range)
-{
-       /*
-        * Nothing to do here, everything needed was done in
-        * invalidate_range_start.
-        */
-}
-
-static const struct mmu_notifier_ops scif_mmu_notifier_ops = {
-       .release = scif_mmu_notifier_release,
-       .clear_flush_young = NULL,
-       .invalidate_range_start = scif_mmu_notifier_invalidate_range_start,
-       .invalidate_range_end = scif_mmu_notifier_invalidate_range_end};
-
-static void scif_ep_unregister_mmu_notifier(struct scif_endpt *ep)
-{
-       struct scif_endpt_rma_info *rma = &ep->rma_info;
-       struct scif_mmu_notif *mmn = NULL;
-       struct list_head *item, *tmp;
-
-       mutex_lock(&ep->rma_info.mmn_lock);
-       list_for_each_safe(item, tmp, &rma->mmn_list) {
-               mmn = list_entry(item, struct scif_mmu_notif, list);
-               mmu_notifier_unregister(&mmn->ep_mmu_notifier, mmn->mm);
-               list_del(item);
-               kfree(mmn);
-       }
-       mutex_unlock(&ep->rma_info.mmn_lock);
-}
-
-static void scif_init_mmu_notifier(struct scif_mmu_notif *mmn,
-                                  struct mm_struct *mm, struct scif_endpt *ep)
-{
-       mmn->ep = ep;
-       mmn->mm = mm;
-       mmn->ep_mmu_notifier.ops = &scif_mmu_notifier_ops;
-       INIT_LIST_HEAD(&mmn->list);
-       INIT_LIST_HEAD(&mmn->tc_reg_list);
-}
-
-static struct scif_mmu_notif *
-scif_find_mmu_notifier(struct mm_struct *mm, struct scif_endpt_rma_info *rma)
-{
-       struct scif_mmu_notif *mmn;
-
-       list_for_each_entry(mmn, &rma->mmn_list, list)
-               if (mmn->mm == mm)
-                       return mmn;
-       return NULL;
-}
-
-static struct scif_mmu_notif *
-scif_add_mmu_notifier(struct mm_struct *mm, struct scif_endpt *ep)
-{
-       struct scif_mmu_notif *mmn
-                = kzalloc(sizeof(*mmn), GFP_KERNEL);
-
-       if (!mmn)
-               return ERR_PTR(-ENOMEM);
-
-       scif_init_mmu_notifier(mmn, current->mm, ep);
-       if (mmu_notifier_register(&mmn->ep_mmu_notifier, current->mm)) {
-               kfree(mmn);
-               return ERR_PTR(-EBUSY);
-       }
-       list_add(&mmn->list, &ep->rma_info.mmn_list);
-       return mmn;
-}
-
-/*
- * Called from the misc thread to destroy temporary cached windows and
- * unregister the MMU notifier for the SCIF endpoint.
- */
-void scif_mmu_notif_handler(struct work_struct *work)
-{
-       struct list_head *pos, *tmpq;
-       struct scif_endpt *ep;
-restart:
-       scif_rma_destroy_tcw_invalid();
-       spin_lock(&scif_info.rmalock);
-       list_for_each_safe(pos, tmpq, &scif_info.mmu_notif_cleanup) {
-               ep = list_entry(pos, struct scif_endpt, mmu_list);
-               list_del(&ep->mmu_list);
-               spin_unlock(&scif_info.rmalock);
-               scif_rma_destroy_tcw_ep(ep);
-               scif_ep_unregister_mmu_notifier(ep);
-               goto restart;
-       }
-       spin_unlock(&scif_info.rmalock);
-}
-
-static bool scif_is_set_reg_cache(int flags)
-{
-       return !!(flags & SCIF_RMA_USECACHE);
-}
-#else
-static struct scif_mmu_notif *
-scif_find_mmu_notifier(struct mm_struct *mm,
-                      struct scif_endpt_rma_info *rma)
-{
-       return NULL;
-}
-
-static struct scif_mmu_notif *
-scif_add_mmu_notifier(struct mm_struct *mm, struct scif_endpt *ep)
-{
-       return NULL;
-}
-
-void scif_mmu_notif_handler(struct work_struct *work)
-{
-}
-
-static bool scif_is_set_reg_cache(int flags)
-{
-       return false;
-}
-
-static bool scif_rma_tc_can_cache(struct scif_endpt *ep, size_t cur_bytes)
-{
-       return false;
-}
-#endif
-
-/**
- * scif_register_temp:
- * @epd: End Point Descriptor.
- * @addr: virtual address to/from which to copy
- * @len: length of range to copy
- * @prot: read/write protection
- * @out_offset: computed offset returned by reference.
- * @out_window: allocated registered window returned by reference.
- *
- * Create a temporary registered window. The peer will not know about this
- * window. This API is used for scif_vreadfrom()/scif_vwriteto() API's.
- */
-static int
-scif_register_temp(scif_epd_t epd, unsigned long addr, size_t len, int prot,
-                  off_t *out_offset, struct scif_window **out_window)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err;
-       scif_pinned_pages_t pinned_pages;
-       size_t aligned_len;
-
-       aligned_len = ALIGN(len, PAGE_SIZE);
-
-       err = __scif_pin_pages((void *)(addr & PAGE_MASK),
-                              aligned_len, &prot, 0, &pinned_pages);
-       if (err)
-               return err;
-
-       pinned_pages->prot = prot;
-
-       /* Compute the offset for this registration */
-       err = scif_get_window_offset(ep, 0, 0,
-                                    aligned_len >> PAGE_SHIFT,
-                                    (s64 *)out_offset);
-       if (err)
-               goto error_unpin;
-
-       /* Allocate and prepare self registration window */
-       *out_window = scif_create_window(ep, aligned_len >> PAGE_SHIFT,
-                                       *out_offset, true);
-       if (!*out_window) {
-               scif_free_window_offset(ep, NULL, *out_offset);
-               err = -ENOMEM;
-               goto error_unpin;
-       }
-
-       (*out_window)->pinned_pages = pinned_pages;
-       (*out_window)->nr_pages = pinned_pages->nr_pages;
-       (*out_window)->prot = pinned_pages->prot;
-
-       (*out_window)->va_for_temp = addr & PAGE_MASK;
-       err = scif_map_window(ep->remote_dev, *out_window);
-       if (err) {
-               /* Something went wrong! Rollback */
-               scif_destroy_window(ep, *out_window);
-               *out_window = NULL;
-       } else {
-               *out_offset |= (addr - (*out_window)->va_for_temp);
-       }
-       return err;
-error_unpin:
-       if (err)
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       scif_unpin_pages(pinned_pages);
-       return err;
-}
-
-#define SCIF_DMA_TO (3 * HZ)
-
-/*
- * scif_sync_dma - Program a DMA without an interrupt descriptor
- *
- * @dev - The address of the pointer to the device instance used
- * for DMA registration.
- * @chan - DMA channel to be used.
- * @sync_wait: Wait for DMA to complete?
- *
- * Return 0 on success and -errno on error.
- */
-static int scif_sync_dma(struct scif_hw_dev *sdev, struct dma_chan *chan,
-                        bool sync_wait)
-{
-       int err = 0;
-       struct dma_async_tx_descriptor *tx = NULL;
-       enum dma_ctrl_flags flags = DMA_PREP_FENCE;
-       dma_cookie_t cookie;
-       struct dma_device *ddev;
-
-       if (!chan) {
-               err = -EIO;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       ddev = chan->device;
-
-       tx = ddev->device_prep_dma_memcpy(chan, 0, 0, 0, flags);
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-       cookie = tx->tx_submit(tx);
-
-       if (dma_submit_error(cookie)) {
-               err = -ENOMEM;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-       if (!sync_wait) {
-               dma_async_issue_pending(chan);
-       } else {
-               if (dma_sync_wait(chan, cookie) == DMA_COMPLETE) {
-                       err = 0;
-               } else {
-                       err = -EIO;
-                       dev_err(&sdev->dev, "%s %d err %d\n",
-                               __func__, __LINE__, err);
-               }
-       }
-release:
-       return err;
-}
-
-static void scif_dma_callback(void *arg)
-{
-       struct completion *done = (struct completion *)arg;
-
-       complete(done);
-}
-
-#define SCIF_DMA_SYNC_WAIT true
-#define SCIF_DMA_POLL BIT(0)
-#define SCIF_DMA_INTR BIT(1)
-
-/*
- * scif_async_dma - Program a DMA with an interrupt descriptor
- *
- * @dev - The address of the pointer to the device instance used
- * for DMA registration.
- * @chan - DMA channel to be used.
- * Return 0 on success and -errno on error.
- */
-static int scif_async_dma(struct scif_hw_dev *sdev, struct dma_chan *chan)
-{
-       int err = 0;
-       struct dma_device *ddev;
-       struct dma_async_tx_descriptor *tx = NULL;
-       enum dma_ctrl_flags flags = DMA_PREP_INTERRUPT | DMA_PREP_FENCE;
-       DECLARE_COMPLETION_ONSTACK(done_wait);
-       dma_cookie_t cookie;
-       enum dma_status status;
-
-       if (!chan) {
-               err = -EIO;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       ddev = chan->device;
-
-       tx = ddev->device_prep_dma_memcpy(chan, 0, 0, 0, flags);
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-       reinit_completion(&done_wait);
-       tx->callback = scif_dma_callback;
-       tx->callback_param = &done_wait;
-       cookie = tx->tx_submit(tx);
-
-       if (dma_submit_error(cookie)) {
-               err = -ENOMEM;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-       dma_async_issue_pending(chan);
-
-       err = wait_for_completion_timeout(&done_wait, SCIF_DMA_TO);
-       if (!err) {
-               err = -EIO;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-       err = 0;
-       status = dma_async_is_tx_complete(chan, cookie, NULL, NULL);
-       if (status != DMA_COMPLETE) {
-               err = -EIO;
-               dev_err(&sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto release;
-       }
-release:
-       return err;
-}
-
-/*
- * scif_drain_dma_poll - Drain all outstanding DMA operations for a particular
- * DMA channel via polling.
- *
- * @sdev - The SCIF device
- * @chan - DMA channel
- * Return 0 on success and -errno on error.
- */
-static int scif_drain_dma_poll(struct scif_hw_dev *sdev, struct dma_chan *chan)
-{
-       if (!chan)
-               return -EINVAL;
-       return scif_sync_dma(sdev, chan, SCIF_DMA_SYNC_WAIT);
-}
-
-/*
- * scif_drain_dma_intr - Drain all outstanding DMA operations for a particular
- * DMA channel via interrupt based blocking wait.
- *
- * @sdev - The SCIF device
- * @chan - DMA channel
- * Return 0 on success and -errno on error.
- */
-int scif_drain_dma_intr(struct scif_hw_dev *sdev, struct dma_chan *chan)
-{
-       if (!chan)
-               return -EINVAL;
-       return scif_async_dma(sdev, chan);
-}
-
-/**
- * scif_rma_destroy_windows:
- *
- * This routine destroys all windows queued for cleanup
- */
-void scif_rma_destroy_windows(void)
-{
-       struct list_head *item, *tmp;
-       struct scif_window *window;
-       struct scif_endpt *ep;
-       struct dma_chan *chan;
-
-       might_sleep();
-restart:
-       spin_lock(&scif_info.rmalock);
-       list_for_each_safe(item, tmp, &scif_info.rma) {
-               window = list_entry(item, struct scif_window,
-                                   list);
-               ep = (struct scif_endpt *)window->ep;
-               chan = ep->rma_info.dma_chan;
-
-               list_del_init(&window->list);
-               spin_unlock(&scif_info.rmalock);
-               if (!chan || !scifdev_alive(ep) ||
-                   !scif_drain_dma_intr(ep->remote_dev->sdev,
-                                        ep->rma_info.dma_chan))
-                       /* Remove window from global list */
-                       window->unreg_state = OP_COMPLETED;
-               else
-                       dev_warn(&ep->remote_dev->sdev->dev,
-                                "DMA engine hung?\n");
-               if (window->unreg_state == OP_COMPLETED) {
-                       if (window->type == SCIF_WINDOW_SELF)
-                               scif_destroy_window(ep, window);
-                       else
-                               scif_destroy_remote_window(window);
-                       atomic_dec(&ep->rma_info.tw_refcount);
-               }
-               goto restart;
-       }
-       spin_unlock(&scif_info.rmalock);
-}
-
-/**
- * scif_rma_destroy_tcw:
- *
- * This routine destroys temporary cached registered windows
- * which have been queued for cleanup.
- */
-void scif_rma_destroy_tcw_invalid(void)
-{
-       struct list_head *item, *tmp;
-       struct scif_window *window;
-       struct scif_endpt *ep;
-       struct dma_chan *chan;
-
-       might_sleep();
-restart:
-       spin_lock(&scif_info.rmalock);
-       list_for_each_safe(item, tmp, &scif_info.rma_tc) {
-               window = list_entry(item, struct scif_window, list);
-               ep = (struct scif_endpt *)window->ep;
-               chan = ep->rma_info.dma_chan;
-               list_del_init(&window->list);
-               spin_unlock(&scif_info.rmalock);
-               mutex_lock(&ep->rma_info.rma_lock);
-               if (!chan || !scifdev_alive(ep) ||
-                   !scif_drain_dma_intr(ep->remote_dev->sdev,
-                                        ep->rma_info.dma_chan)) {
-                       atomic_sub(window->nr_pages,
-                                  &ep->rma_info.tcw_total_pages);
-                       scif_destroy_window(ep, window);
-                       atomic_dec(&ep->rma_info.tcw_refcount);
-               } else {
-                       dev_warn(&ep->remote_dev->sdev->dev,
-                                "DMA engine hung?\n");
-               }
-               mutex_unlock(&ep->rma_info.rma_lock);
-               goto restart;
-       }
-       spin_unlock(&scif_info.rmalock);
-}
-
-static inline
-void *_get_local_va(off_t off, struct scif_window *window, size_t len)
-{
-       int page_nr = (off - window->offset) >> PAGE_SHIFT;
-       off_t page_off = off & ~PAGE_MASK;
-       void *va = NULL;
-
-       if (window->type == SCIF_WINDOW_SELF) {
-               struct page **pages = window->pinned_pages->pages;
-
-               va = page_address(pages[page_nr]) + page_off;
-       }
-       return va;
-}
-
-static inline
-void *ioremap_remote(off_t off, struct scif_window *window,
-                    size_t len, struct scif_dev *dev,
-                    struct scif_window_iter *iter)
-{
-       dma_addr_t phys = scif_off_to_dma_addr(window, off, NULL, iter);
-
-       /*
-        * If the DMA address is not card relative then we need the DMA
-        * addresses to be an offset into the bar. The aperture base was already
-        * added so subtract it here since scif_ioremap is going to add it again
-        */
-       if (!scifdev_self(dev) && window->type == SCIF_WINDOW_PEER &&
-           dev->sdev->aper && !dev->sdev->card_rel_da)
-               phys = phys - dev->sdev->aper->pa;
-       return scif_ioremap(phys, len, dev);
-}
-
-static inline void
-iounmap_remote(void *virt, size_t size, struct scif_copy_work *work)
-{
-       scif_iounmap(virt, size, work->remote_dev);
-}
-
-/*
- * Takes care of ordering issue caused by
- * 1. Hardware:  Only in the case of cpu copy from mgmt node to card
- * because of WC memory.
- * 2. Software: If memcpy reorders copy instructions for optimization.
- * This could happen at both mgmt node and card.
- */
-static inline void
-scif_ordered_memcpy_toio(char *dst, const char *src, size_t count)
-{
-       if (!count)
-               return;
-
-       memcpy_toio((void __iomem __force *)dst, src, --count);
-       /* Order the last byte with the previous stores */
-       wmb();
-       *(dst + count) = *(src + count);
-}
-
-static inline void scif_unaligned_cpy_toio(char *dst, const char *src,
-                                          size_t count, bool ordered)
-{
-       if (ordered)
-               scif_ordered_memcpy_toio(dst, src, count);
-       else
-               memcpy_toio((void __iomem __force *)dst, src, count);
-}
-
-static inline
-void scif_ordered_memcpy_fromio(char *dst, const char *src, size_t count)
-{
-       if (!count)
-               return;
-
-       memcpy_fromio(dst, (void __iomem __force *)src, --count);
-       /* Order the last byte with the previous loads */
-       rmb();
-       *(dst + count) = *(src + count);
-}
-
-static inline void scif_unaligned_cpy_fromio(char *dst, const char *src,
-                                            size_t count, bool ordered)
-{
-       if (ordered)
-               scif_ordered_memcpy_fromio(dst, src, count);
-       else
-               memcpy_fromio(dst, (void __iomem __force *)src, count);
-}
-
-#define SCIF_RMA_ERROR_CODE (~(dma_addr_t)0x0)
-
-/*
- * scif_off_to_dma_addr:
- * Obtain the dma_addr given the window and the offset.
- * @window: Registered window.
- * @off: Window offset.
- * @nr_bytes: Return the number of contiguous bytes till next DMA addr index.
- * @index: Return the index of the dma_addr array found.
- * @start_off: start offset of index of the dma addr array found.
- * The nr_bytes provides the callee an estimate of the maximum possible
- * DMA xfer possible while the index/start_off provide faster lookups
- * for the next iteration.
- */
-dma_addr_t scif_off_to_dma_addr(struct scif_window *window, s64 off,
-                               size_t *nr_bytes, struct scif_window_iter *iter)
-{
-       int i, page_nr;
-       s64 start, end;
-       off_t page_off;
-
-       if (window->nr_pages == window->nr_contig_chunks) {
-               page_nr = (off - window->offset) >> PAGE_SHIFT;
-               page_off = off & ~PAGE_MASK;
-
-               if (nr_bytes)
-                       *nr_bytes = PAGE_SIZE - page_off;
-               return window->dma_addr[page_nr] | page_off;
-       }
-       if (iter) {
-               i = iter->index;
-               start = iter->offset;
-       } else {
-               i =  0;
-               start =  window->offset;
-       }
-       for (; i < window->nr_contig_chunks; i++) {
-               end = start + (window->num_pages[i] << PAGE_SHIFT);
-               if (off >= start && off < end) {
-                       if (iter) {
-                               iter->index = i;
-                               iter->offset = start;
-                       }
-                       if (nr_bytes)
-                               *nr_bytes = end - off;
-                       return (window->dma_addr[i] + (off - start));
-               }
-               start += (window->num_pages[i] << PAGE_SHIFT);
-       }
-       dev_err(scif_info.mdev.this_device,
-               "%s %d BUG. Addr not found? window %p off 0x%llx\n",
-               __func__, __LINE__, window, off);
-       return SCIF_RMA_ERROR_CODE;
-}
-
-/*
- * Copy between rma window and temporary buffer
- */
-static void scif_rma_local_cpu_copy(s64 offset, struct scif_window *window,
-                                   u8 *temp, size_t rem_len, bool to_temp)
-{
-       void *window_virt;
-       size_t loop_len;
-       int offset_in_page;
-       s64 end_offset;
-
-       offset_in_page = offset & ~PAGE_MASK;
-       loop_len = PAGE_SIZE - offset_in_page;
-
-       if (rem_len < loop_len)
-               loop_len = rem_len;
-
-       window_virt = _get_local_va(offset, window, loop_len);
-       if (!window_virt)
-               return;
-       if (to_temp)
-               memcpy(temp, window_virt, loop_len);
-       else
-               memcpy(window_virt, temp, loop_len);
-
-       offset += loop_len;
-       temp += loop_len;
-       rem_len -= loop_len;
-
-       end_offset = window->offset +
-               (window->nr_pages << PAGE_SHIFT);
-       while (rem_len) {
-               if (offset == end_offset) {
-                       window = list_next_entry(window, list);
-                       end_offset = window->offset +
-                               (window->nr_pages << PAGE_SHIFT);
-               }
-               loop_len = min(PAGE_SIZE, rem_len);
-               window_virt = _get_local_va(offset, window, loop_len);
-               if (!window_virt)
-                       return;
-               if (to_temp)
-                       memcpy(temp, window_virt, loop_len);
-               else
-                       memcpy(window_virt, temp, loop_len);
-               offset  += loop_len;
-               temp    += loop_len;
-               rem_len -= loop_len;
-       }
-}
-
-/**
- * scif_rma_completion_cb:
- * @data: RMA cookie
- *
- * RMA interrupt completion callback.
- */
-static void scif_rma_completion_cb(void *data)
-{
-       struct scif_dma_comp_cb *comp_cb = data;
-
-       /* Free DMA Completion CB. */
-       if (comp_cb->dst_window)
-               scif_rma_local_cpu_copy(comp_cb->dst_offset,
-                                       comp_cb->dst_window,
-                                       comp_cb->temp_buf +
-                                       comp_cb->header_padding,
-                                       comp_cb->len, false);
-       scif_unmap_single(comp_cb->temp_phys, comp_cb->sdev,
-                         SCIF_KMEM_UNALIGNED_BUF_SIZE);
-       if (comp_cb->is_cache)
-               kmem_cache_free(unaligned_cache,
-                               comp_cb->temp_buf_to_free);
-       else
-               kfree(comp_cb->temp_buf_to_free);
-}
-
-/* Copies between temporary buffer and offsets provided in work */
-static int
-scif_rma_list_dma_copy_unaligned(struct scif_copy_work *work,
-                                u8 *temp, struct dma_chan *chan,
-                                bool src_local)
-{
-       struct scif_dma_comp_cb *comp_cb = work->comp_cb;
-       dma_addr_t window_dma_addr, temp_dma_addr;
-       dma_addr_t temp_phys = comp_cb->temp_phys;
-       size_t loop_len, nr_contig_bytes = 0, remaining_len = work->len;
-       int offset_in_ca, ret = 0;
-       s64 end_offset, offset;
-       struct scif_window *window;
-       void *window_virt_addr;
-       size_t tail_len;
-       struct dma_async_tx_descriptor *tx;
-       struct dma_device *dev = chan->device;
-       dma_cookie_t cookie;
-
-       if (src_local) {
-               offset = work->dst_offset;
-               window = work->dst_window;
-       } else {
-               offset = work->src_offset;
-               window = work->src_window;
-       }
-
-       offset_in_ca = offset & (L1_CACHE_BYTES - 1);
-       if (offset_in_ca) {
-               loop_len = L1_CACHE_BYTES - offset_in_ca;
-               loop_len = min(loop_len, remaining_len);
-               window_virt_addr = ioremap_remote(offset, window,
-                                                 loop_len,
-                                                 work->remote_dev,
-                                                 NULL);
-               if (!window_virt_addr)
-                       return -ENOMEM;
-               if (src_local)
-                       scif_unaligned_cpy_toio(window_virt_addr, temp,
-                                               loop_len,
-                                               work->ordered &&
-                                               !(remaining_len - loop_len));
-               else
-                       scif_unaligned_cpy_fromio(temp, window_virt_addr,
-                                                 loop_len, work->ordered &&
-                                                 !(remaining_len - loop_len));
-               iounmap_remote(window_virt_addr, loop_len, work);
-
-               offset += loop_len;
-               temp += loop_len;
-               temp_phys += loop_len;
-               remaining_len -= loop_len;
-       }
-
-       offset_in_ca = offset & ~PAGE_MASK;
-       end_offset = window->offset +
-               (window->nr_pages << PAGE_SHIFT);
-
-       tail_len = remaining_len & (L1_CACHE_BYTES - 1);
-       remaining_len -= tail_len;
-       while (remaining_len) {
-               if (offset == end_offset) {
-                       window = list_next_entry(window, list);
-                       end_offset = window->offset +
-                               (window->nr_pages << PAGE_SHIFT);
-               }
-               if (scif_is_mgmt_node())
-                       temp_dma_addr = temp_phys;
-               else
-                       /* Fix if we ever enable IOMMU on the card */
-                       temp_dma_addr = (dma_addr_t)virt_to_phys(temp);
-               window_dma_addr = scif_off_to_dma_addr(window, offset,
-                                                      &nr_contig_bytes,
-                                                      NULL);
-               loop_len = min(nr_contig_bytes, remaining_len);
-               if (src_local) {
-                       if (work->ordered && !tail_len &&
-                           !(remaining_len - loop_len) &&
-                           loop_len != L1_CACHE_BYTES) {
-                               /*
-                                * Break up the last chunk of the transfer into
-                                * two steps. if there is no tail to guarantee
-                                * DMA ordering. SCIF_DMA_POLLING inserts
-                                * a status update descriptor in step 1 which
-                                * acts as a double sided synchronization fence
-                                * for the DMA engine to ensure that the last
-                                * cache line in step 2 is updated last.
-                                */
-                               /* Step 1) DMA: Body Length - L1_CACHE_BYTES. */
-                               tx =
-                               dev->device_prep_dma_memcpy(chan,
-                                                           window_dma_addr,
-                                                           temp_dma_addr,
-                                                           loop_len -
-                                                           L1_CACHE_BYTES,
-                                                           DMA_PREP_FENCE);
-                               if (!tx) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               cookie = tx->tx_submit(tx);
-                               if (dma_submit_error(cookie)) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               dma_async_issue_pending(chan);
-                               offset += (loop_len - L1_CACHE_BYTES);
-                               temp_dma_addr += (loop_len - L1_CACHE_BYTES);
-                               window_dma_addr += (loop_len - L1_CACHE_BYTES);
-                               remaining_len -= (loop_len - L1_CACHE_BYTES);
-                               loop_len = remaining_len;
-
-                               /* Step 2) DMA: L1_CACHE_BYTES */
-                               tx =
-                               dev->device_prep_dma_memcpy(chan,
-                                                           window_dma_addr,
-                                                           temp_dma_addr,
-                                                           loop_len, 0);
-                               if (!tx) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               cookie = tx->tx_submit(tx);
-                               if (dma_submit_error(cookie)) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               dma_async_issue_pending(chan);
-                       } else {
-                               tx =
-                               dev->device_prep_dma_memcpy(chan,
-                                                           window_dma_addr,
-                                                           temp_dma_addr,
-                                                           loop_len, 0);
-                               if (!tx) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               cookie = tx->tx_submit(tx);
-                               if (dma_submit_error(cookie)) {
-                                       ret = -ENOMEM;
-                                       goto err;
-                               }
-                               dma_async_issue_pending(chan);
-                       }
-               } else {
-                       tx = dev->device_prep_dma_memcpy(chan, temp_dma_addr,
-                                       window_dma_addr, loop_len, 0);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       dma_async_issue_pending(chan);
-               }
-               offset += loop_len;
-               temp += loop_len;
-               temp_phys += loop_len;
-               remaining_len -= loop_len;
-               offset_in_ca = 0;
-       }
-       if (tail_len) {
-               if (offset == end_offset) {
-                       window = list_next_entry(window, list);
-                       end_offset = window->offset +
-                               (window->nr_pages << PAGE_SHIFT);
-               }
-               window_virt_addr = ioremap_remote(offset, window, tail_len,
-                                                 work->remote_dev,
-                                                 NULL);
-               if (!window_virt_addr)
-                       return -ENOMEM;
-               /*
-                * The CPU copy for the tail bytes must be initiated only once
-                * previous DMA transfers for this endpoint have completed
-                * to guarantee ordering.
-                */
-               if (work->ordered) {
-                       struct scif_dev *rdev = work->remote_dev;
-
-                       ret = scif_drain_dma_intr(rdev->sdev, chan);
-                       if (ret)
-                               return ret;
-               }
-               if (src_local)
-                       scif_unaligned_cpy_toio(window_virt_addr, temp,
-                                               tail_len, work->ordered);
-               else
-                       scif_unaligned_cpy_fromio(temp, window_virt_addr,
-                                                 tail_len, work->ordered);
-               iounmap_remote(window_virt_addr, tail_len, work);
-       }
-       tx = dev->device_prep_dma_memcpy(chan, 0, 0, 0, DMA_PREP_INTERRUPT);
-       if (!tx) {
-               ret = -ENOMEM;
-               return ret;
-       }
-       tx->callback = &scif_rma_completion_cb;
-       tx->callback_param = comp_cb;
-       cookie = tx->tx_submit(tx);
-
-       if (dma_submit_error(cookie)) {
-               ret = -ENOMEM;
-               return ret;
-       }
-       dma_async_issue_pending(chan);
-       return 0;
-err:
-       dev_err(scif_info.mdev.this_device,
-               "%s %d Desc Prog Failed ret %d\n",
-               __func__, __LINE__, ret);
-       return ret;
-}
-
-/*
- * _scif_rma_list_dma_copy_aligned:
- *
- * Traverse all the windows and perform DMA copy.
- */
-static int _scif_rma_list_dma_copy_aligned(struct scif_copy_work *work,
-                                          struct dma_chan *chan)
-{
-       dma_addr_t src_dma_addr, dst_dma_addr;
-       size_t loop_len, remaining_len, src_contig_bytes = 0;
-       size_t dst_contig_bytes = 0;
-       struct scif_window_iter src_win_iter;
-       struct scif_window_iter dst_win_iter;
-       s64 end_src_offset, end_dst_offset;
-       struct scif_window *src_window = work->src_window;
-       struct scif_window *dst_window = work->dst_window;
-       s64 src_offset = work->src_offset, dst_offset = work->dst_offset;
-       int ret = 0;
-       struct dma_async_tx_descriptor *tx;
-       struct dma_device *dev = chan->device;
-       dma_cookie_t cookie;
-
-       remaining_len = work->len;
-
-       scif_init_window_iter(src_window, &src_win_iter);
-       scif_init_window_iter(dst_window, &dst_win_iter);
-       end_src_offset = src_window->offset +
-               (src_window->nr_pages << PAGE_SHIFT);
-       end_dst_offset = dst_window->offset +
-               (dst_window->nr_pages << PAGE_SHIFT);
-       while (remaining_len) {
-               if (src_offset == end_src_offset) {
-                       src_window = list_next_entry(src_window, list);
-                       end_src_offset = src_window->offset +
-                               (src_window->nr_pages << PAGE_SHIFT);
-                       scif_init_window_iter(src_window, &src_win_iter);
-               }
-               if (dst_offset == end_dst_offset) {
-                       dst_window = list_next_entry(dst_window, list);
-                       end_dst_offset = dst_window->offset +
-                               (dst_window->nr_pages << PAGE_SHIFT);
-                       scif_init_window_iter(dst_window, &dst_win_iter);
-               }
-
-               /* compute dma addresses for transfer */
-               src_dma_addr = scif_off_to_dma_addr(src_window, src_offset,
-                                                   &src_contig_bytes,
-                                                   &src_win_iter);
-               dst_dma_addr = scif_off_to_dma_addr(dst_window, dst_offset,
-                                                   &dst_contig_bytes,
-                                                   &dst_win_iter);
-               loop_len = min(src_contig_bytes, dst_contig_bytes);
-               loop_len = min(loop_len, remaining_len);
-               if (work->ordered && !(remaining_len - loop_len)) {
-                       /*
-                        * Break up the last chunk of the transfer into two
-                        * steps to ensure that the last byte in step 2 is
-                        * updated last.
-                        */
-                       /* Step 1) DMA: Body Length - 1 */
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                                        src_dma_addr,
-                                                        loop_len - 1,
-                                                        DMA_PREP_FENCE);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       src_offset += (loop_len - 1);
-                       dst_offset += (loop_len - 1);
-                       src_dma_addr += (loop_len - 1);
-                       dst_dma_addr += (loop_len - 1);
-                       remaining_len -= (loop_len - 1);
-                       loop_len = remaining_len;
-
-                       /* Step 2) DMA: 1 BYTES */
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                       src_dma_addr, loop_len, 0);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       dma_async_issue_pending(chan);
-               } else {
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                       src_dma_addr, loop_len, 0);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-               }
-               src_offset += loop_len;
-               dst_offset += loop_len;
-               remaining_len -= loop_len;
-       }
-       return ret;
-err:
-       dev_err(scif_info.mdev.this_device,
-               "%s %d Desc Prog Failed ret %d\n",
-               __func__, __LINE__, ret);
-       return ret;
-}
-
-/*
- * scif_rma_list_dma_copy_aligned:
- *
- * Traverse all the windows and perform DMA copy.
- */
-static int scif_rma_list_dma_copy_aligned(struct scif_copy_work *work,
-                                         struct dma_chan *chan)
-{
-       dma_addr_t src_dma_addr, dst_dma_addr;
-       size_t loop_len, remaining_len, tail_len, src_contig_bytes = 0;
-       size_t dst_contig_bytes = 0;
-       int src_cache_off;
-       s64 end_src_offset, end_dst_offset;
-       struct scif_window_iter src_win_iter;
-       struct scif_window_iter dst_win_iter;
-       void *src_virt, *dst_virt;
-       struct scif_window *src_window = work->src_window;
-       struct scif_window *dst_window = work->dst_window;
-       s64 src_offset = work->src_offset, dst_offset = work->dst_offset;
-       int ret = 0;
-       struct dma_async_tx_descriptor *tx;
-       struct dma_device *dev = chan->device;
-       dma_cookie_t cookie;
-
-       remaining_len = work->len;
-       scif_init_window_iter(src_window, &src_win_iter);
-       scif_init_window_iter(dst_window, &dst_win_iter);
-
-       src_cache_off = src_offset & (L1_CACHE_BYTES - 1);
-       if (src_cache_off != 0) {
-               /* Head */
-               loop_len = L1_CACHE_BYTES - src_cache_off;
-               loop_len = min(loop_len, remaining_len);
-               src_dma_addr = __scif_off_to_dma_addr(src_window, src_offset);
-               dst_dma_addr = __scif_off_to_dma_addr(dst_window, dst_offset);
-               if (src_window->type == SCIF_WINDOW_SELF)
-                       src_virt = _get_local_va(src_offset, src_window,
-                                                loop_len);
-               else
-                       src_virt = ioremap_remote(src_offset, src_window,
-                                                 loop_len,
-                                                 work->remote_dev, NULL);
-               if (!src_virt)
-                       return -ENOMEM;
-               if (dst_window->type == SCIF_WINDOW_SELF)
-                       dst_virt = _get_local_va(dst_offset, dst_window,
-                                                loop_len);
-               else
-                       dst_virt = ioremap_remote(dst_offset, dst_window,
-                                                 loop_len,
-                                                 work->remote_dev, NULL);
-               if (!dst_virt) {
-                       if (src_window->type != SCIF_WINDOW_SELF)
-                               iounmap_remote(src_virt, loop_len, work);
-                       return -ENOMEM;
-               }
-               if (src_window->type == SCIF_WINDOW_SELF)
-                       scif_unaligned_cpy_toio(dst_virt, src_virt, loop_len,
-                                               remaining_len == loop_len ?
-                                               work->ordered : false);
-               else
-                       scif_unaligned_cpy_fromio(dst_virt, src_virt, loop_len,
-                                                 remaining_len == loop_len ?
-                                                 work->ordered : false);
-               if (src_window->type != SCIF_WINDOW_SELF)
-                       iounmap_remote(src_virt, loop_len, work);
-               if (dst_window->type != SCIF_WINDOW_SELF)
-                       iounmap_remote(dst_virt, loop_len, work);
-               src_offset += loop_len;
-               dst_offset += loop_len;
-               remaining_len -= loop_len;
-       }
-
-       end_src_offset = src_window->offset +
-               (src_window->nr_pages << PAGE_SHIFT);
-       end_dst_offset = dst_window->offset +
-               (dst_window->nr_pages << PAGE_SHIFT);
-       tail_len = remaining_len & (L1_CACHE_BYTES - 1);
-       remaining_len -= tail_len;
-       while (remaining_len) {
-               if (src_offset == end_src_offset) {
-                       src_window = list_next_entry(src_window, list);
-                       end_src_offset = src_window->offset +
-                               (src_window->nr_pages << PAGE_SHIFT);
-                       scif_init_window_iter(src_window, &src_win_iter);
-               }
-               if (dst_offset == end_dst_offset) {
-                       dst_window = list_next_entry(dst_window, list);
-                       end_dst_offset = dst_window->offset +
-                               (dst_window->nr_pages << PAGE_SHIFT);
-                       scif_init_window_iter(dst_window, &dst_win_iter);
-               }
-
-               /* compute dma addresses for transfer */
-               src_dma_addr = scif_off_to_dma_addr(src_window, src_offset,
-                                                   &src_contig_bytes,
-                                                   &src_win_iter);
-               dst_dma_addr = scif_off_to_dma_addr(dst_window, dst_offset,
-                                                   &dst_contig_bytes,
-                                                   &dst_win_iter);
-               loop_len = min(src_contig_bytes, dst_contig_bytes);
-               loop_len = min(loop_len, remaining_len);
-               if (work->ordered && !tail_len &&
-                   !(remaining_len - loop_len)) {
-                       /*
-                        * Break up the last chunk of the transfer into two
-                        * steps. if there is no tail to gurantee DMA ordering.
-                        * Passing SCIF_DMA_POLLING inserts a status update
-                        * descriptor in step 1 which acts as a double sided
-                        * synchronization fence for the DMA engine to ensure
-                        * that the last cache line in step 2 is updated last.
-                        */
-                       /* Step 1) DMA: Body Length - L1_CACHE_BYTES. */
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                                        src_dma_addr,
-                                                        loop_len -
-                                                        L1_CACHE_BYTES,
-                                                        DMA_PREP_FENCE);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       dma_async_issue_pending(chan);
-                       src_offset += (loop_len - L1_CACHE_BYTES);
-                       dst_offset += (loop_len - L1_CACHE_BYTES);
-                       src_dma_addr += (loop_len - L1_CACHE_BYTES);
-                       dst_dma_addr += (loop_len - L1_CACHE_BYTES);
-                       remaining_len -= (loop_len - L1_CACHE_BYTES);
-                       loop_len = remaining_len;
-
-                       /* Step 2) DMA: L1_CACHE_BYTES */
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                                        src_dma_addr,
-                                                        loop_len, 0);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       dma_async_issue_pending(chan);
-               } else {
-                       tx = dev->device_prep_dma_memcpy(chan, dst_dma_addr,
-                                                        src_dma_addr,
-                                                        loop_len, 0);
-                       if (!tx) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       cookie = tx->tx_submit(tx);
-                       if (dma_submit_error(cookie)) {
-                               ret = -ENOMEM;
-                               goto err;
-                       }
-                       dma_async_issue_pending(chan);
-               }
-               src_offset += loop_len;
-               dst_offset += loop_len;
-               remaining_len -= loop_len;
-       }
-       remaining_len = tail_len;
-       if (remaining_len) {
-               loop_len = remaining_len;
-               if (src_offset == end_src_offset)
-                       src_window = list_next_entry(src_window, list);
-               if (dst_offset == end_dst_offset)
-                       dst_window = list_next_entry(dst_window, list);
-
-               src_dma_addr = __scif_off_to_dma_addr(src_window, src_offset);
-               dst_dma_addr = __scif_off_to_dma_addr(dst_window, dst_offset);
-               /*
-                * The CPU copy for the tail bytes must be initiated only once
-                * previous DMA transfers for this endpoint have completed to
-                * guarantee ordering.
-                */
-               if (work->ordered) {
-                       struct scif_dev *rdev = work->remote_dev;
-
-                       ret = scif_drain_dma_poll(rdev->sdev, chan);
-                       if (ret)
-                               return ret;
-               }
-               if (src_window->type == SCIF_WINDOW_SELF)
-                       src_virt = _get_local_va(src_offset, src_window,
-                                                loop_len);
-               else
-                       src_virt = ioremap_remote(src_offset, src_window,
-                                                 loop_len,
-                                                 work->remote_dev, NULL);
-               if (!src_virt)
-                       return -ENOMEM;
-
-               if (dst_window->type == SCIF_WINDOW_SELF)
-                       dst_virt = _get_local_va(dst_offset, dst_window,
-                                                loop_len);
-               else
-                       dst_virt = ioremap_remote(dst_offset, dst_window,
-                                                 loop_len,
-                                                 work->remote_dev, NULL);
-               if (!dst_virt) {
-                       if (src_window->type != SCIF_WINDOW_SELF)
-                               iounmap_remote(src_virt, loop_len, work);
-                       return -ENOMEM;
-               }
-
-               if (src_window->type == SCIF_WINDOW_SELF)
-                       scif_unaligned_cpy_toio(dst_virt, src_virt, loop_len,
-                                               work->ordered);
-               else
-                       scif_unaligned_cpy_fromio(dst_virt, src_virt,
-                                                 loop_len, work->ordered);
-               if (src_window->type != SCIF_WINDOW_SELF)
-                       iounmap_remote(src_virt, loop_len, work);
-
-               if (dst_window->type != SCIF_WINDOW_SELF)
-                       iounmap_remote(dst_virt, loop_len, work);
-               remaining_len -= loop_len;
-       }
-       return ret;
-err:
-       dev_err(scif_info.mdev.this_device,
-               "%s %d Desc Prog Failed ret %d\n",
-               __func__, __LINE__, ret);
-       return ret;
-}
-
-/*
- * scif_rma_list_cpu_copy:
- *
- * Traverse all the windows and perform CPU copy.
- */
-static int scif_rma_list_cpu_copy(struct scif_copy_work *work)
-{
-       void *src_virt, *dst_virt;
-       size_t loop_len, remaining_len;
-       int src_page_off, dst_page_off;
-       s64 src_offset = work->src_offset, dst_offset = work->dst_offset;
-       struct scif_window *src_window = work->src_window;
-       struct scif_window *dst_window = work->dst_window;
-       s64 end_src_offset, end_dst_offset;
-       int ret = 0;
-       struct scif_window_iter src_win_iter;
-       struct scif_window_iter dst_win_iter;
-
-       remaining_len = work->len;
-
-       scif_init_window_iter(src_window, &src_win_iter);
-       scif_init_window_iter(dst_window, &dst_win_iter);
-       while (remaining_len) {
-               src_page_off = src_offset & ~PAGE_MASK;
-               dst_page_off = dst_offset & ~PAGE_MASK;
-               loop_len = min(PAGE_SIZE -
-                              max(src_page_off, dst_page_off),
-                              remaining_len);
-
-               if (src_window->type == SCIF_WINDOW_SELF)
-                       src_virt = _get_local_va(src_offset, src_window,
-                                                loop_len);
-               else
-                       src_virt = ioremap_remote(src_offset, src_window,
-                                                 loop_len,
-                                                 work->remote_dev,
-                                                 &src_win_iter);
-               if (!src_virt) {
-                       ret = -ENOMEM;
-                       goto error;
-               }
-
-               if (dst_window->type == SCIF_WINDOW_SELF)
-                       dst_virt = _get_local_va(dst_offset, dst_window,
-                                                loop_len);
-               else
-                       dst_virt = ioremap_remote(dst_offset, dst_window,
-                                                 loop_len,
-                                                 work->remote_dev,
-                                                 &dst_win_iter);
-               if (!dst_virt) {
-                       if (src_window->type == SCIF_WINDOW_PEER)
-                               iounmap_remote(src_virt, loop_len, work);
-                       ret = -ENOMEM;
-                       goto error;
-               }
-
-               if (work->loopback) {
-                       memcpy(dst_virt, src_virt, loop_len);
-               } else {
-                       if (src_window->type == SCIF_WINDOW_SELF)
-                               memcpy_toio((void __iomem __force *)dst_virt,
-                                           src_virt, loop_len);
-                       else
-                               memcpy_fromio(dst_virt,
-                                             (void __iomem __force *)src_virt,
-                                             loop_len);
-               }
-               if (src_window->type == SCIF_WINDOW_PEER)
-                       iounmap_remote(src_virt, loop_len, work);
-
-               if (dst_window->type == SCIF_WINDOW_PEER)
-                       iounmap_remote(dst_virt, loop_len, work);
-
-               src_offset += loop_len;
-               dst_offset += loop_len;
-               remaining_len -= loop_len;
-               if (remaining_len) {
-                       end_src_offset = src_window->offset +
-                               (src_window->nr_pages << PAGE_SHIFT);
-                       end_dst_offset = dst_window->offset +
-                               (dst_window->nr_pages << PAGE_SHIFT);
-                       if (src_offset == end_src_offset) {
-                               src_window = list_next_entry(src_window, list);
-                               scif_init_window_iter(src_window,
-                                                     &src_win_iter);
-                       }
-                       if (dst_offset == end_dst_offset) {
-                               dst_window = list_next_entry(dst_window, list);
-                               scif_init_window_iter(dst_window,
-                                                     &dst_win_iter);
-                       }
-               }
-       }
-error:
-       return ret;
-}
-
-static int scif_rma_list_dma_copy_wrapper(struct scif_endpt *epd,
-                                         struct scif_copy_work *work,
-                                         struct dma_chan *chan, off_t loffset)
-{
-       int src_cache_off, dst_cache_off;
-       s64 src_offset = work->src_offset, dst_offset = work->dst_offset;
-       u8 *temp = NULL;
-       bool src_local = true;
-       struct scif_dma_comp_cb *comp_cb;
-       int err;
-
-       if (is_dma_copy_aligned(chan->device, 1, 1, 1))
-               return _scif_rma_list_dma_copy_aligned(work, chan);
-
-       src_cache_off = src_offset & (L1_CACHE_BYTES - 1);
-       dst_cache_off = dst_offset & (L1_CACHE_BYTES - 1);
-
-       if (dst_cache_off == src_cache_off)
-               return scif_rma_list_dma_copy_aligned(work, chan);
-
-       if (work->loopback)
-               return scif_rma_list_cpu_copy(work);
-       src_local = work->src_window->type == SCIF_WINDOW_SELF;
-
-       /* Allocate dma_completion cb */
-       comp_cb = kzalloc(sizeof(*comp_cb), GFP_KERNEL);
-       if (!comp_cb)
-               goto error;
-
-       work->comp_cb = comp_cb;
-       comp_cb->cb_cookie = comp_cb;
-       comp_cb->dma_completion_func = &scif_rma_completion_cb;
-
-       if (work->len + (L1_CACHE_BYTES << 1) < SCIF_KMEM_UNALIGNED_BUF_SIZE) {
-               comp_cb->is_cache = false;
-               /* Allocate padding bytes to align to a cache line */
-               temp = kmalloc(work->len + (L1_CACHE_BYTES << 1),
-                              GFP_KERNEL);
-               if (!temp)
-                       goto free_comp_cb;
-               comp_cb->temp_buf_to_free = temp;
-               /* kmalloc(..) does not guarantee cache line alignment */
-               if (!IS_ALIGNED((u64)temp, L1_CACHE_BYTES))
-                       temp = PTR_ALIGN(temp, L1_CACHE_BYTES);
-       } else {
-               comp_cb->is_cache = true;
-               temp = kmem_cache_alloc(unaligned_cache, GFP_KERNEL);
-               if (!temp)
-                       goto free_comp_cb;
-               comp_cb->temp_buf_to_free = temp;
-       }
-
-       if (src_local) {
-               temp += dst_cache_off;
-               scif_rma_local_cpu_copy(work->src_offset, work->src_window,
-                                       temp, work->len, true);
-       } else {
-               comp_cb->dst_window = work->dst_window;
-               comp_cb->dst_offset = work->dst_offset;
-               work->src_offset = work->src_offset - src_cache_off;
-               comp_cb->len = work->len;
-               work->len = ALIGN(work->len + src_cache_off, L1_CACHE_BYTES);
-               comp_cb->header_padding = src_cache_off;
-       }
-       comp_cb->temp_buf = temp;
-
-       err = scif_map_single(&comp_cb->temp_phys, temp,
-                             work->remote_dev, SCIF_KMEM_UNALIGNED_BUF_SIZE);
-       if (err)
-               goto free_temp_buf;
-       comp_cb->sdev = work->remote_dev;
-       if (scif_rma_list_dma_copy_unaligned(work, temp, chan, src_local) < 0)
-               goto free_temp_buf;
-       if (!src_local)
-               work->fence_type = SCIF_DMA_INTR;
-       return 0;
-free_temp_buf:
-       if (comp_cb->is_cache)
-               kmem_cache_free(unaligned_cache, comp_cb->temp_buf_to_free);
-       else
-               kfree(comp_cb->temp_buf_to_free);
-free_comp_cb:
-       kfree(comp_cb);
-error:
-       return -ENOMEM;
-}
-
-/**
- * scif_rma_copy:
- * @epd: end point descriptor.
- * @loffset: offset in local registered address space to/from which to copy
- * @addr: user virtual address to/from which to copy
- * @len: length of range to copy
- * @roffset: offset in remote registered address space to/from which to copy
- * @flags: flags
- * @dir: LOCAL->REMOTE or vice versa.
- * @last_chunk: true if this is the last chunk of a larger transfer
- *
- * Validate parameters, check if src/dst registered ranges requested for copy
- * are valid and initiate either CPU or DMA copy.
- */
-static int scif_rma_copy(scif_epd_t epd, off_t loffset, unsigned long addr,
-                        size_t len, off_t roffset, int flags,
-                        enum scif_rma_dir dir, bool last_chunk)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scif_rma_req remote_req;
-       struct scif_rma_req req;
-       struct scif_window *local_window = NULL;
-       struct scif_window *remote_window = NULL;
-       struct scif_copy_work copy_work;
-       bool loopback;
-       int err = 0;
-       struct dma_chan *chan;
-       struct scif_mmu_notif *mmn = NULL;
-       bool cache = false;
-       struct device *spdev;
-
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       if (flags && !(flags & (SCIF_RMA_USECPU | SCIF_RMA_USECACHE |
-                               SCIF_RMA_SYNC | SCIF_RMA_ORDERED)))
-               return -EINVAL;
-
-       loopback = scifdev_self(ep->remote_dev) ? true : false;
-       copy_work.fence_type = ((flags & SCIF_RMA_SYNC) && last_chunk) ?
-                               SCIF_DMA_POLL : 0;
-       copy_work.ordered = !!((flags & SCIF_RMA_ORDERED) && last_chunk);
-
-       /* Use CPU for Mgmt node <-> Mgmt node copies */
-       if (loopback && scif_is_mgmt_node()) {
-               flags |= SCIF_RMA_USECPU;
-               copy_work.fence_type = 0x0;
-       }
-
-       cache = scif_is_set_reg_cache(flags);
-
-       remote_req.out_window = &remote_window;
-       remote_req.offset = roffset;
-       remote_req.nr_bytes = len;
-       /*
-        * If transfer is from local to remote then the remote window
-        * must be writeable and vice versa.
-        */
-       remote_req.prot = dir == SCIF_LOCAL_TO_REMOTE ? VM_WRITE : VM_READ;
-       remote_req.type = SCIF_WINDOW_PARTIAL;
-       remote_req.head = &ep->rma_info.remote_reg_list;
-
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               return err;
-       }
-
-       if (addr && cache) {
-               mutex_lock(&ep->rma_info.mmn_lock);
-               mmn = scif_find_mmu_notifier(current->mm, &ep->rma_info);
-               if (!mmn)
-                       mmn = scif_add_mmu_notifier(current->mm, ep);
-               mutex_unlock(&ep->rma_info.mmn_lock);
-               if (IS_ERR(mmn)) {
-                       scif_put_peer_dev(spdev);
-                       return PTR_ERR(mmn);
-               }
-               cache = cache && !scif_rma_tc_can_cache(ep, len);
-       }
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (addr) {
-               req.out_window = &local_window;
-               req.nr_bytes = ALIGN(len + (addr & ~PAGE_MASK),
-                                    PAGE_SIZE);
-               req.va_for_temp = addr & PAGE_MASK;
-               req.prot = (dir == SCIF_LOCAL_TO_REMOTE ?
-                           VM_READ : VM_WRITE | VM_READ);
-               /* Does a valid local window exist? */
-               if (mmn) {
-                       spin_lock(&ep->rma_info.tc_lock);
-                       req.head = &mmn->tc_reg_list;
-                       err = scif_query_tcw(ep, &req);
-                       spin_unlock(&ep->rma_info.tc_lock);
-               }
-               if (!mmn || err) {
-                       err = scif_register_temp(epd, req.va_for_temp,
-                                                req.nr_bytes, req.prot,
-                                                &loffset, &local_window);
-                       if (err) {
-                               mutex_unlock(&ep->rma_info.rma_lock);
-                               goto error;
-                       }
-                       if (!cache)
-                               goto skip_cache;
-                       atomic_inc(&ep->rma_info.tcw_refcount);
-                       atomic_add_return(local_window->nr_pages,
-                                         &ep->rma_info.tcw_total_pages);
-                       if (mmn) {
-                               spin_lock(&ep->rma_info.tc_lock);
-                               scif_insert_tcw(local_window,
-                                               &mmn->tc_reg_list);
-                               spin_unlock(&ep->rma_info.tc_lock);
-                       }
-               }
-skip_cache:
-               loffset = local_window->offset +
-                               (addr - local_window->va_for_temp);
-       } else {
-               req.out_window = &local_window;
-               req.offset = loffset;
-               /*
-                * If transfer is from local to remote then the self window
-                * must be readable and vice versa.
-                */
-               req.prot = dir == SCIF_LOCAL_TO_REMOTE ? VM_READ : VM_WRITE;
-               req.nr_bytes = len;
-               req.type = SCIF_WINDOW_PARTIAL;
-               req.head = &ep->rma_info.reg_list;
-               /* Does a valid local window exist? */
-               err = scif_query_window(&req);
-               if (err) {
-                       mutex_unlock(&ep->rma_info.rma_lock);
-                       goto error;
-               }
-       }
-
-       /* Does a valid remote window exist? */
-       err = scif_query_window(&remote_req);
-       if (err) {
-               mutex_unlock(&ep->rma_info.rma_lock);
-               goto error;
-       }
-
-       /*
-        * Prepare copy_work for submitting work to the DMA kernel thread
-        * or CPU copy routine.
-        */
-       copy_work.len = len;
-       copy_work.loopback = loopback;
-       copy_work.remote_dev = ep->remote_dev;
-       if (dir == SCIF_LOCAL_TO_REMOTE) {
-               copy_work.src_offset = loffset;
-               copy_work.src_window = local_window;
-               copy_work.dst_offset = roffset;
-               copy_work.dst_window = remote_window;
-       } else {
-               copy_work.src_offset = roffset;
-               copy_work.src_window = remote_window;
-               copy_work.dst_offset = loffset;
-               copy_work.dst_window = local_window;
-       }
-
-       if (flags & SCIF_RMA_USECPU) {
-               scif_rma_list_cpu_copy(&copy_work);
-       } else {
-               chan = ep->rma_info.dma_chan;
-               err = scif_rma_list_dma_copy_wrapper(epd, &copy_work,
-                                                    chan, loffset);
-       }
-       if (addr && !cache)
-               atomic_inc(&ep->rma_info.tw_refcount);
-
-       mutex_unlock(&ep->rma_info.rma_lock);
-
-       if (last_chunk) {
-               struct scif_dev *rdev = ep->remote_dev;
-
-               if (copy_work.fence_type == SCIF_DMA_POLL)
-                       err = scif_drain_dma_poll(rdev->sdev,
-                                                 ep->rma_info.dma_chan);
-               else if (copy_work.fence_type == SCIF_DMA_INTR)
-                       err = scif_drain_dma_intr(rdev->sdev,
-                                                 ep->rma_info.dma_chan);
-       }
-
-       if (addr && !cache)
-               scif_queue_for_cleanup(local_window, &scif_info.rma);
-       scif_put_peer_dev(spdev);
-       return err;
-error:
-       if (err) {
-               if (addr && local_window && !cache)
-                       scif_destroy_window(ep, local_window);
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d len 0x%lx\n",
-                       __func__, __LINE__, err, len);
-       }
-       scif_put_peer_dev(spdev);
-       return err;
-}
-
-int scif_readfrom(scif_epd_t epd, off_t loffset, size_t len,
-                 off_t roffset, int flags)
-{
-       int err;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI readfrom: ep %p loffset 0x%lx len 0x%lx offset 0x%lx flags 0x%x\n",
-               epd, loffset, len, roffset, flags);
-       if (scif_unaligned(loffset, roffset)) {
-               while (len > SCIF_MAX_UNALIGNED_BUF_SIZE) {
-                       err = scif_rma_copy(epd, loffset, 0x0,
-                                           SCIF_MAX_UNALIGNED_BUF_SIZE,
-                                           roffset, flags,
-                                           SCIF_REMOTE_TO_LOCAL, false);
-                       if (err)
-                               goto readfrom_err;
-                       loffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       roffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       len -= SCIF_MAX_UNALIGNED_BUF_SIZE;
-               }
-       }
-       err = scif_rma_copy(epd, loffset, 0x0, len,
-                           roffset, flags, SCIF_REMOTE_TO_LOCAL, true);
-readfrom_err:
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_readfrom);
-
-int scif_writeto(scif_epd_t epd, off_t loffset, size_t len,
-                off_t roffset, int flags)
-{
-       int err;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI writeto: ep %p loffset 0x%lx len 0x%lx roffset 0x%lx flags 0x%x\n",
-               epd, loffset, len, roffset, flags);
-       if (scif_unaligned(loffset, roffset)) {
-               while (len > SCIF_MAX_UNALIGNED_BUF_SIZE) {
-                       err = scif_rma_copy(epd, loffset, 0x0,
-                                           SCIF_MAX_UNALIGNED_BUF_SIZE,
-                                           roffset, flags,
-                                           SCIF_LOCAL_TO_REMOTE, false);
-                       if (err)
-                               goto writeto_err;
-                       loffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       roffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       len -= SCIF_MAX_UNALIGNED_BUF_SIZE;
-               }
-       }
-       err = scif_rma_copy(epd, loffset, 0x0, len,
-                           roffset, flags, SCIF_LOCAL_TO_REMOTE, true);
-writeto_err:
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_writeto);
-
-int scif_vreadfrom(scif_epd_t epd, void *addr, size_t len,
-                  off_t roffset, int flags)
-{
-       int err;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI vreadfrom: ep %p addr %p len 0x%lx roffset 0x%lx flags 0x%x\n",
-               epd, addr, len, roffset, flags);
-       if (scif_unaligned((off_t __force)addr, roffset)) {
-               if (len > SCIF_MAX_UNALIGNED_BUF_SIZE)
-                       flags &= ~SCIF_RMA_USECACHE;
-
-               while (len > SCIF_MAX_UNALIGNED_BUF_SIZE) {
-                       err = scif_rma_copy(epd, 0, (u64)addr,
-                                           SCIF_MAX_UNALIGNED_BUF_SIZE,
-                                           roffset, flags,
-                                           SCIF_REMOTE_TO_LOCAL, false);
-                       if (err)
-                               goto vreadfrom_err;
-                       addr += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       roffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       len -= SCIF_MAX_UNALIGNED_BUF_SIZE;
-               }
-       }
-       err = scif_rma_copy(epd, 0, (u64)addr, len,
-                           roffset, flags, SCIF_REMOTE_TO_LOCAL, true);
-vreadfrom_err:
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_vreadfrom);
-
-int scif_vwriteto(scif_epd_t epd, void *addr, size_t len,
-                 off_t roffset, int flags)
-{
-       int err;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI vwriteto: ep %p addr %p len 0x%lx roffset 0x%lx flags 0x%x\n",
-               epd, addr, len, roffset, flags);
-       if (scif_unaligned((off_t __force)addr, roffset)) {
-               if (len > SCIF_MAX_UNALIGNED_BUF_SIZE)
-                       flags &= ~SCIF_RMA_USECACHE;
-
-               while (len > SCIF_MAX_UNALIGNED_BUF_SIZE) {
-                       err = scif_rma_copy(epd, 0, (u64)addr,
-                                           SCIF_MAX_UNALIGNED_BUF_SIZE,
-                                           roffset, flags,
-                                           SCIF_LOCAL_TO_REMOTE, false);
-                       if (err)
-                               goto vwriteto_err;
-                       addr += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       roffset += SCIF_MAX_UNALIGNED_BUF_SIZE;
-                       len -= SCIF_MAX_UNALIGNED_BUF_SIZE;
-               }
-       }
-       err = scif_rma_copy(epd, 0, (u64)addr, len,
-                           roffset, flags, SCIF_LOCAL_TO_REMOTE, true);
-vwriteto_err:
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_vwriteto);
diff --git a/drivers/misc/mic/scif/scif_epd.c b/drivers/misc/mic/scif/scif_epd.c
deleted file mode 100644 (file)
index 426687f..0000000
+++ /dev/null
@@ -1,357 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-#include "scif_map.h"
-
-void scif_cleanup_ep_qp(struct scif_endpt *ep)
-{
-       struct scif_qp *qp = ep->qp_info.qp;
-
-       if (qp->outbound_q.rb_base) {
-               scif_iounmap((void *)qp->outbound_q.rb_base,
-                            qp->outbound_q.size, ep->remote_dev);
-               qp->outbound_q.rb_base = NULL;
-       }
-       if (qp->remote_qp) {
-               scif_iounmap((void *)qp->remote_qp,
-                            sizeof(struct scif_qp), ep->remote_dev);
-               qp->remote_qp = NULL;
-       }
-       if (qp->local_qp) {
-               scif_unmap_single(qp->local_qp, ep->remote_dev,
-                                 sizeof(struct scif_qp));
-               qp->local_qp = 0x0;
-       }
-       if (qp->local_buf) {
-               scif_unmap_single(qp->local_buf, ep->remote_dev,
-                                 SCIF_ENDPT_QP_SIZE);
-               qp->local_buf = 0;
-       }
-}
-
-void scif_teardown_ep(void *endpt)
-{
-       struct scif_endpt *ep = endpt;
-       struct scif_qp *qp = ep->qp_info.qp;
-
-       if (qp) {
-               spin_lock(&ep->lock);
-               scif_cleanup_ep_qp(ep);
-               spin_unlock(&ep->lock);
-               kfree(qp->inbound_q.rb_base);
-               kfree(qp);
-       }
-}
-
-/*
- * Enqueue the endpoint to the zombie list for cleanup.
- * The endpoint should not be accessed once this API returns.
- */
-void scif_add_epd_to_zombie_list(struct scif_endpt *ep, bool eplock_held)
-{
-       if (!eplock_held)
-               mutex_lock(&scif_info.eplock);
-       spin_lock(&ep->lock);
-       ep->state = SCIFEP_ZOMBIE;
-       spin_unlock(&ep->lock);
-       list_add_tail(&ep->list, &scif_info.zombie);
-       scif_info.nr_zombies++;
-       if (!eplock_held)
-               mutex_unlock(&scif_info.eplock);
-       schedule_work(&scif_info.misc_work);
-}
-
-static struct scif_endpt *scif_find_listen_ep(u16 port)
-{
-       struct scif_endpt *ep = NULL;
-       struct list_head *pos, *tmpq;
-
-       mutex_lock(&scif_info.eplock);
-       list_for_each_safe(pos, tmpq, &scif_info.listen) {
-               ep = list_entry(pos, struct scif_endpt, list);
-               if (ep->port.port == port) {
-                       mutex_unlock(&scif_info.eplock);
-                       return ep;
-               }
-       }
-       mutex_unlock(&scif_info.eplock);
-       return NULL;
-}
-
-void scif_cleanup_zombie_epd(void)
-{
-       struct list_head *pos, *tmpq;
-       struct scif_endpt *ep;
-
-       mutex_lock(&scif_info.eplock);
-       list_for_each_safe(pos, tmpq, &scif_info.zombie) {
-               ep = list_entry(pos, struct scif_endpt, list);
-               if (scif_rma_ep_can_uninit(ep)) {
-                       list_del(pos);
-                       scif_info.nr_zombies--;
-                       put_iova_domain(&ep->rma_info.iovad);
-                       kfree(ep);
-               }
-       }
-       mutex_unlock(&scif_info.eplock);
-}
-
-/**
- * scif_cnctreq() - Respond to SCIF_CNCT_REQ interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * This message is initiated by the remote node to request a connection
- * to the local node.  This function looks for an end point in the
- * listen state on the requested port id.
- *
- * If it finds a listening port it places the connect request on the
- * listening end points queue and wakes up any pending accept calls.
- *
- * If it does not find a listening end point it sends a connection
- * reject message to the remote node.
- */
-void scif_cnctreq(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = NULL;
-       struct scif_conreq *conreq;
-
-       conreq = kmalloc(sizeof(*conreq), GFP_KERNEL);
-       if (!conreq)
-               /* Lack of resources so reject the request. */
-               goto conreq_sendrej;
-
-       ep = scif_find_listen_ep(msg->dst.port);
-       if (!ep)
-               /*  Send reject due to no listening ports */
-               goto conreq_sendrej_free;
-       else
-               spin_lock(&ep->lock);
-
-       if (ep->backlog <= ep->conreqcnt) {
-               /*  Send reject due to too many pending requests */
-               spin_unlock(&ep->lock);
-               goto conreq_sendrej_free;
-       }
-
-       conreq->msg = *msg;
-       list_add_tail(&conreq->list, &ep->conlist);
-       ep->conreqcnt++;
-       wake_up_interruptible(&ep->conwq);
-       spin_unlock(&ep->lock);
-       return;
-
-conreq_sendrej_free:
-       kfree(conreq);
-conreq_sendrej:
-       msg->uop = SCIF_CNCT_REJ;
-       scif_nodeqp_send(&scif_dev[msg->src.node], msg);
-}
-
-/**
- * scif_cnctgnt() - Respond to SCIF_CNCT_GNT interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * An accept() on the remote node has occurred and sent this message
- * to indicate success.  Place the end point in the MAPPING state and
- * save the remote nodes memory information.  Then wake up the connect
- * request so it can finish.
- */
-void scif_cnctgnt(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       if (SCIFEP_CONNECTING == ep->state) {
-               ep->peer.node = msg->src.node;
-               ep->peer.port = msg->src.port;
-               ep->qp_info.gnt_pld = msg->payload[1];
-               ep->remote_ep = msg->payload[2];
-               ep->state = SCIFEP_MAPPING;
-
-               wake_up(&ep->conwq);
-       }
-       spin_unlock(&ep->lock);
-}
-
-/**
- * scif_cnctgnt_ack() - Respond to SCIF_CNCT_GNTACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * The remote connection request has finished mapping the local memory.
- * Place the connection in the connected state and wake up the pending
- * accept() call.
- */
-void scif_cnctgnt_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       mutex_lock(&scif_info.connlock);
-       spin_lock(&ep->lock);
-       /* New ep is now connected with all resources set. */
-       ep->state = SCIFEP_CONNECTED;
-       list_add_tail(&ep->list, &scif_info.connected);
-       wake_up(&ep->conwq);
-       spin_unlock(&ep->lock);
-       mutex_unlock(&scif_info.connlock);
-}
-
-/**
- * scif_cnctgnt_nack() - Respond to SCIF_CNCT_GNTNACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * The remote connection request failed to map the local memory it was sent.
- * Place the end point in the CLOSING state to indicate it and wake up
- * the pending accept();
- */
-void scif_cnctgnt_nack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       ep->state = SCIFEP_CLOSING;
-       wake_up(&ep->conwq);
-       spin_unlock(&ep->lock);
-}
-
-/**
- * scif_cnctrej() - Respond to SCIF_CNCT_REJ interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * The remote end has rejected the connection request.  Set the end
- * point back to the bound state and wake up the pending connect().
- */
-void scif_cnctrej(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       if (SCIFEP_CONNECTING == ep->state) {
-               ep->state = SCIFEP_BOUND;
-               wake_up(&ep->conwq);
-       }
-       spin_unlock(&ep->lock);
-}
-
-/**
- * scif_discnct() - Respond to SCIF_DISCNCT interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * The remote node has indicated close() has been called on its end
- * point.  Remove the local end point from the connected list, set its
- * state to disconnected and ensure accesses to the remote node are
- * shutdown.
- *
- * When all accesses to the remote end have completed then send a
- * DISCNT_ACK to indicate it can remove its resources and complete
- * the close routine.
- */
-void scif_discnct(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = NULL;
-       struct scif_endpt *tmpep;
-       struct list_head *pos, *tmpq;
-
-       mutex_lock(&scif_info.connlock);
-       list_for_each_safe(pos, tmpq, &scif_info.connected) {
-               tmpep = list_entry(pos, struct scif_endpt, list);
-               /*
-                * The local ep may have sent a disconnect and and been closed
-                * due to a message response time out. It may have been
-                * allocated again and formed a new connection so we want to
-                * check if the remote ep matches
-                */
-               if (((u64)tmpep == msg->payload[1]) &&
-                   ((u64)tmpep->remote_ep == msg->payload[0])) {
-                       list_del(pos);
-                       ep = tmpep;
-                       spin_lock(&ep->lock);
-                       break;
-               }
-       }
-
-       /*
-        * If the terminated end is not found then this side started closing
-        * before the other side sent the disconnect.  If so the ep will no
-        * longer be on the connected list.  Regardless the other side
-        * needs to be acked to let it know close is complete.
-        */
-       if (!ep) {
-               mutex_unlock(&scif_info.connlock);
-               goto discnct_ack;
-       }
-
-       ep->state = SCIFEP_DISCONNECTED;
-       list_add_tail(&ep->list, &scif_info.disconnected);
-
-       wake_up_interruptible(&ep->sendwq);
-       wake_up_interruptible(&ep->recvwq);
-       spin_unlock(&ep->lock);
-       mutex_unlock(&scif_info.connlock);
-
-discnct_ack:
-       msg->uop = SCIF_DISCNT_ACK;
-       scif_nodeqp_send(&scif_dev[msg->src.node], msg);
-}
-
-/**
- * scif_discnct_ack() - Respond to SCIF_DISCNT_ACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remote side has indicated it has not more references to local resources
- */
-void scif_discnt_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       ep->state = SCIFEP_DISCONNECTED;
-       spin_unlock(&ep->lock);
-       complete(&ep->discon);
-}
-
-/**
- * scif_clientsend() - Respond to SCIF_CLIENT_SEND interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remote side is confirming send or receive interrupt handling is complete.
- */
-void scif_clientsend(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       if (SCIFEP_CONNECTED == ep->state)
-               wake_up_interruptible(&ep->recvwq);
-       spin_unlock(&ep->lock);
-}
-
-/**
- * scif_clientrcvd() - Respond to SCIF_CLIENT_RCVD interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remote side is confirming send or receive interrupt handling is complete.
- */
-void scif_clientrcvd(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-
-       spin_lock(&ep->lock);
-       if (SCIFEP_CONNECTED == ep->state)
-               wake_up_interruptible(&ep->sendwq);
-       spin_unlock(&ep->lock);
-}
diff --git a/drivers/misc/mic/scif/scif_epd.h b/drivers/misc/mic/scif/scif_epd.h
deleted file mode 100644 (file)
index 0b9dfe1..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#ifndef SCIF_EPD_H
-#define SCIF_EPD_H
-
-#include <linux/delay.h>
-#include <linux/scif.h>
-#include <linux/scif_ioctl.h>
-
-#define SCIF_EPLOCK_HELD true
-
-enum scif_epd_state {
-       SCIFEP_UNBOUND,
-       SCIFEP_BOUND,
-       SCIFEP_LISTENING,
-       SCIFEP_CONNECTED,
-       SCIFEP_CONNECTING,
-       SCIFEP_MAPPING,
-       SCIFEP_CLOSING,
-       SCIFEP_CLLISTEN,
-       SCIFEP_DISCONNECTED,
-       SCIFEP_ZOMBIE
-};
-
-/*
- * struct scif_conreq - Data structure added to the connection list.
- *
- * @msg: connection request message received
- * @list: link to list of connection requests
- */
-struct scif_conreq {
-       struct scifmsg msg;
-       struct list_head list;
-};
-
-/* Size of the RB for the Endpoint QP */
-#define SCIF_ENDPT_QP_SIZE 0x1000
-
-/*
- * scif_endpt_qp_info - SCIF endpoint queue pair
- *
- * @qp - Qpair for this endpoint
- * @qp_offset - DMA address of the QP
- * @gnt_pld - Payload in a SCIF_CNCT_GNT message containing the
- * physical address of the remote_qp.
- */
-struct scif_endpt_qp_info {
-       struct scif_qp *qp;
-       dma_addr_t qp_offset;
-       dma_addr_t gnt_pld;
-};
-
-/*
- * struct scif_endpt - The SCIF endpoint data structure
- *
- * @state: end point state
- * @lock: lock synchronizing access to endpoint fields like state etc
- * @port: self port information
- * @peer: peer port information
- * @backlog: maximum pending connection requests
- * @qp_info: Endpoint QP information for SCIF messaging
- * @remote_dev: scifdev used by this endpt to communicate with remote node.
- * @remote_ep: remote endpoint
- * @conreqcnt: Keep track of number of connection requests.
- * @files: Open file information used to match the id passed in with
- *         the flush routine.
- * @conlist: list of connection requests
- * @conwq: waitqueue for connection processing
- * @discon: completion used during disconnection
- * @sendwq: waitqueue used during sending messages
- * @recvwq: waitqueue used during message receipt
- * @sendlock: Synchronize ordering of messages sent
- * @recvlock: Synchronize ordering of messages received
- * @list: link to list of various endpoints like connected, listening etc
- * @li_accept: pending ACCEPTREG
- * @acceptcnt: pending ACCEPTREG cnt
- * @liacceptlist: link to listen accept
- * @miacceptlist: link to uaccept
- * @listenep: associated listen ep
- * @conn_work: Non blocking connect work
- * @conn_port: Connection port
- * @conn_err: Errors during connection
- * @conn_async_state: Async connection
- * @conn_pend_wq: Used by poll while waiting for incoming connections
- * @conn_list: List of async connection requests
- * @rma_info: Information for triggering SCIF RMA and DMA operations
- * @mmu_list: link to list of MMU notifier cleanup work
- * @anon: anonymous file for use in kernel mode scif poll
- */
-struct scif_endpt {
-       enum scif_epd_state state;
-       spinlock_t lock;
-       struct scif_port_id port;
-       struct scif_port_id peer;
-       int backlog;
-       struct scif_endpt_qp_info qp_info;
-       struct scif_dev *remote_dev;
-       u64 remote_ep;
-       int conreqcnt;
-       struct files_struct *files;
-       struct list_head conlist;
-       wait_queue_head_t conwq;
-       struct completion discon;
-       wait_queue_head_t sendwq;
-       wait_queue_head_t recvwq;
-       struct mutex sendlock;
-       struct mutex recvlock;
-       struct list_head list;
-       struct list_head li_accept;
-       int acceptcnt;
-       struct list_head liacceptlist;
-       struct list_head miacceptlist;
-       struct scif_endpt *listenep;
-       struct scif_port_id conn_port;
-       int conn_err;
-       int conn_async_state;
-       wait_queue_head_t conn_pend_wq;
-       struct list_head conn_list;
-       struct scif_endpt_rma_info rma_info;
-       struct list_head mmu_list;
-       struct file *anon;
-};
-
-static inline int scifdev_alive(struct scif_endpt *ep)
-{
-       return _scifdev_alive(ep->remote_dev);
-}
-
-/*
- * scif_verify_epd:
- * ep: SCIF endpoint
- *
- * Checks several generic error conditions and returns the
- * appropriate error.
- */
-static inline int scif_verify_epd(struct scif_endpt *ep)
-{
-       if (ep->state == SCIFEP_DISCONNECTED)
-               return -ECONNRESET;
-
-       if (ep->state != SCIFEP_CONNECTED)
-               return -ENOTCONN;
-
-       if (!scifdev_alive(ep))
-               return -ENODEV;
-
-       return 0;
-}
-
-static inline int scif_anon_inode_getfile(scif_epd_t epd)
-{
-       epd->anon = anon_inode_getfile("scif", &scif_anon_fops, NULL, 0);
-
-       return PTR_ERR_OR_ZERO(epd->anon);
-}
-
-static inline void scif_anon_inode_fput(scif_epd_t epd)
-{
-       if (epd->anon) {
-               fput(epd->anon);
-               epd->anon = NULL;
-       }
-}
-
-void scif_cleanup_zombie_epd(void);
-void scif_teardown_ep(void *endpt);
-void scif_cleanup_ep_qp(struct scif_endpt *ep);
-void scif_add_epd_to_zombie_list(struct scif_endpt *ep, bool eplock_held);
-void scif_get_node_info(void);
-void scif_send_acks(struct scif_dev *dev);
-void scif_conn_handler(struct work_struct *work);
-int scif_rsrv_port(u16 port);
-void scif_get_port(u16 port);
-int scif_get_new_port(void);
-void scif_put_port(u16 port);
-int scif_user_send(scif_epd_t epd, void __user *msg, int len, int flags);
-int scif_user_recv(scif_epd_t epd, void __user *msg, int len, int flags);
-void scif_cnctreq(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_cnctgnt(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_cnctgnt_ack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_cnctgnt_nack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_cnctrej(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_discnct(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_discnt_ack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_clientsend(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_clientrcvd(struct scif_dev *scifdev, struct scifmsg *msg);
-int __scif_connect(scif_epd_t epd, struct scif_port_id *dst, bool non_block);
-int __scif_flush(scif_epd_t epd);
-int scif_mmap(struct vm_area_struct *vma, scif_epd_t epd);
-__poll_t __scif_pollfd(struct file *f, poll_table *wait,
-                          struct scif_endpt *ep);
-int __scif_pin_pages(void *addr, size_t len, int *out_prot,
-                    int map_flags, scif_pinned_pages_t *pages);
-#endif /* SCIF_EPD_H */
diff --git a/drivers/misc/mic/scif/scif_fd.c b/drivers/misc/mic/scif/scif_fd.c
deleted file mode 100644 (file)
index 3f08646..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-
-static int scif_fdopen(struct inode *inode, struct file *f)
-{
-       struct scif_endpt *priv = scif_open();
-
-       if (!priv)
-               return -ENOMEM;
-       f->private_data = priv;
-       return 0;
-}
-
-static int scif_fdclose(struct inode *inode, struct file *f)
-{
-       struct scif_endpt *priv = f->private_data;
-
-       return scif_close(priv);
-}
-
-static int scif_fdmmap(struct file *f, struct vm_area_struct *vma)
-{
-       struct scif_endpt *priv = f->private_data;
-
-       return scif_mmap(vma, priv);
-}
-
-static __poll_t scif_fdpoll(struct file *f, poll_table *wait)
-{
-       struct scif_endpt *priv = f->private_data;
-
-       return __scif_pollfd(f, wait, priv);
-}
-
-static int scif_fdflush(struct file *f, fl_owner_t id)
-{
-       struct scif_endpt *ep = f->private_data;
-
-       spin_lock(&ep->lock);
-       /*
-        * The listening endpoint stashes the open file information before
-        * waiting for incoming connections. The release callback would never be
-        * called if the application closed the endpoint, while waiting for
-        * incoming connections from a separate thread since the file descriptor
-        * reference count is bumped up in the accept IOCTL. Call the flush
-        * routine if the id matches the endpoint open file information so that
-        * the listening endpoint can be woken up and the fd released.
-        */
-       if (ep->files == id)
-               __scif_flush(ep);
-       spin_unlock(&ep->lock);
-       return 0;
-}
-
-static __always_inline void scif_err_debug(int err, const char *str)
-{
-       /*
-        * ENOTCONN is a common uninteresting error which is
-        * flooding debug messages to the console unnecessarily.
-        */
-       if (err < 0 && err != -ENOTCONN)
-               dev_dbg(scif_info.mdev.this_device, "%s err %d\n", str, err);
-}
-
-static long scif_fdioctl(struct file *f, unsigned int cmd, unsigned long arg)
-{
-       struct scif_endpt *priv = f->private_data;
-       void __user *argp = (void __user *)arg;
-       int err = 0;
-       struct scifioctl_msg request;
-       bool non_block = false;
-
-       non_block = !!(f->f_flags & O_NONBLOCK);
-
-       switch (cmd) {
-       case SCIF_BIND:
-       {
-               int pn;
-
-               if (copy_from_user(&pn, argp, sizeof(pn)))
-                       return -EFAULT;
-
-               pn = scif_bind(priv, pn);
-               if (pn < 0)
-                       return pn;
-
-               if (copy_to_user(argp, &pn, sizeof(pn)))
-                       return -EFAULT;
-
-               return 0;
-       }
-       case SCIF_LISTEN:
-               return scif_listen(priv, arg);
-       case SCIF_CONNECT:
-       {
-               struct scifioctl_connect req;
-               struct scif_endpt *ep = (struct scif_endpt *)priv;
-
-               if (copy_from_user(&req, argp, sizeof(req)))
-                       return -EFAULT;
-
-               err = __scif_connect(priv, &req.peer, non_block);
-               if (err < 0)
-                       return err;
-
-               req.self.node = ep->port.node;
-               req.self.port = ep->port.port;
-
-               if (copy_to_user(argp, &req, sizeof(req)))
-                       return -EFAULT;
-
-               return 0;
-       }
-       /*
-        * Accept is done in two halves.  The request ioctl does the basic
-        * functionality of accepting the request and returning the information
-        * about it including the internal ID of the end point.  The register
-        * is done with the internal ID on a new file descriptor opened by the
-        * requesting process.
-        */
-       case SCIF_ACCEPTREQ:
-       {
-               struct scifioctl_accept request;
-               scif_epd_t *ep = (scif_epd_t *)&request.endpt;
-
-               if (copy_from_user(&request, argp, sizeof(request)))
-                       return -EFAULT;
-
-               err = scif_accept(priv, &request.peer, ep, request.flags);
-               if (err < 0)
-                       return err;
-
-               if (copy_to_user(argp, &request, sizeof(request))) {
-                       scif_close(*ep);
-                       return -EFAULT;
-               }
-               /*
-                * Add to the list of user mode eps where the second half
-                * of the accept is not yet completed.
-                */
-               mutex_lock(&scif_info.eplock);
-               list_add_tail(&((*ep)->miacceptlist), &scif_info.uaccept);
-               list_add_tail(&((*ep)->liacceptlist), &priv->li_accept);
-               (*ep)->listenep = priv;
-               priv->acceptcnt++;
-               mutex_unlock(&scif_info.eplock);
-
-               return 0;
-       }
-       case SCIF_ACCEPTREG:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scif_endpt *newep;
-               struct scif_endpt *lisep;
-               struct scif_endpt *fep = NULL;
-               struct scif_endpt *tmpep;
-               struct list_head *pos, *tmpq;
-
-               /* Finally replace the pointer to the accepted endpoint */
-               if (copy_from_user(&newep, argp, sizeof(void *)))
-                       return -EFAULT;
-
-               /* Remove form the user accept queue */
-               mutex_lock(&scif_info.eplock);
-               list_for_each_safe(pos, tmpq, &scif_info.uaccept) {
-                       tmpep = list_entry(pos,
-                                          struct scif_endpt, miacceptlist);
-                       if (tmpep == newep) {
-                               list_del(pos);
-                               fep = tmpep;
-                               break;
-                       }
-               }
-
-               if (!fep) {
-                       mutex_unlock(&scif_info.eplock);
-                       return -ENOENT;
-               }
-
-               lisep = newep->listenep;
-               list_for_each_safe(pos, tmpq, &lisep->li_accept) {
-                       tmpep = list_entry(pos,
-                                          struct scif_endpt, liacceptlist);
-                       if (tmpep == newep) {
-                               list_del(pos);
-                               lisep->acceptcnt--;
-                               break;
-                       }
-               }
-
-               mutex_unlock(&scif_info.eplock);
-
-               /* Free the resources automatically created from the open. */
-               scif_anon_inode_fput(priv);
-               scif_teardown_ep(priv);
-               scif_add_epd_to_zombie_list(priv, !SCIF_EPLOCK_HELD);
-               f->private_data = newep;
-               return 0;
-       }
-       case SCIF_SEND:
-       {
-               struct scif_endpt *priv = f->private_data;
-
-               if (copy_from_user(&request, argp,
-                                  sizeof(struct scifioctl_msg))) {
-                       err = -EFAULT;
-                       goto send_err;
-               }
-               err = scif_user_send(priv, (void __user *)request.msg,
-                                    request.len, request.flags);
-               if (err < 0)
-                       goto send_err;
-               if (copy_to_user(&
-                                ((struct scifioctl_msg __user *)argp)->out_len,
-                                &err, sizeof(err))) {
-                       err = -EFAULT;
-                       goto send_err;
-               }
-               err = 0;
-send_err:
-               scif_err_debug(err, "scif_send");
-               return err;
-       }
-       case SCIF_RECV:
-       {
-               struct scif_endpt *priv = f->private_data;
-
-               if (copy_from_user(&request, argp,
-                                  sizeof(struct scifioctl_msg))) {
-                       err = -EFAULT;
-                       goto recv_err;
-               }
-
-               err = scif_user_recv(priv, (void __user *)request.msg,
-                                    request.len, request.flags);
-               if (err < 0)
-                       goto recv_err;
-
-               if (copy_to_user(&
-                                ((struct scifioctl_msg __user *)argp)->out_len,
-                       &err, sizeof(err))) {
-                       err = -EFAULT;
-                       goto recv_err;
-               }
-               err = 0;
-recv_err:
-               scif_err_debug(err, "scif_recv");
-               return err;
-       }
-       case SCIF_GET_NODEIDS:
-       {
-               struct scifioctl_node_ids node_ids;
-               int entries;
-               u16 *nodes;
-               void __user *unodes, *uself;
-               u16 self;
-
-               if (copy_from_user(&node_ids, argp, sizeof(node_ids))) {
-                       err = -EFAULT;
-                       goto getnodes_err2;
-               }
-
-               entries = min_t(int, scif_info.maxid, node_ids.len);
-               nodes = kmalloc_array(entries, sizeof(u16), GFP_KERNEL);
-               if (entries && !nodes) {
-                       err = -ENOMEM;
-                       goto getnodes_err2;
-               }
-               node_ids.len = scif_get_node_ids(nodes, entries, &self);
-
-               unodes = (void __user *)node_ids.nodes;
-               if (copy_to_user(unodes, nodes, sizeof(u16) * entries)) {
-                       err = -EFAULT;
-                       goto getnodes_err1;
-               }
-
-               uself = (void __user *)node_ids.self;
-               if (copy_to_user(uself, &self, sizeof(u16))) {
-                       err = -EFAULT;
-                       goto getnodes_err1;
-               }
-
-               if (copy_to_user(argp, &node_ids, sizeof(node_ids))) {
-                       err = -EFAULT;
-                       goto getnodes_err1;
-               }
-getnodes_err1:
-               kfree(nodes);
-getnodes_err2:
-               return err;
-       }
-       case SCIF_REG:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_reg reg;
-               off_t ret;
-
-               if (copy_from_user(&reg, argp, sizeof(reg))) {
-                       err = -EFAULT;
-                       goto reg_err;
-               }
-               if (reg.flags & SCIF_MAP_KERNEL) {
-                       err = -EINVAL;
-                       goto reg_err;
-               }
-               ret = scif_register(priv, (void *)reg.addr, reg.len,
-                                   reg.offset, reg.prot, reg.flags);
-               if (ret < 0) {
-                       err = (int)ret;
-                       goto reg_err;
-               }
-
-               if (copy_to_user(&((struct scifioctl_reg __user *)argp)
-                                ->out_offset, &ret, sizeof(reg.out_offset))) {
-                       err = -EFAULT;
-                       goto reg_err;
-               }
-               err = 0;
-reg_err:
-               scif_err_debug(err, "scif_register");
-               return err;
-       }
-       case SCIF_UNREG:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_unreg unreg;
-
-               if (copy_from_user(&unreg, argp, sizeof(unreg))) {
-                       err = -EFAULT;
-                       goto unreg_err;
-               }
-               err = scif_unregister(priv, unreg.offset, unreg.len);
-unreg_err:
-               scif_err_debug(err, "scif_unregister");
-               return err;
-       }
-       case SCIF_READFROM:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_copy copy;
-
-               if (copy_from_user(&copy, argp, sizeof(copy))) {
-                       err = -EFAULT;
-                       goto readfrom_err;
-               }
-               err = scif_readfrom(priv, copy.loffset, copy.len, copy.roffset,
-                                   copy.flags);
-readfrom_err:
-               scif_err_debug(err, "scif_readfrom");
-               return err;
-       }
-       case SCIF_WRITETO:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_copy copy;
-
-               if (copy_from_user(&copy, argp, sizeof(copy))) {
-                       err = -EFAULT;
-                       goto writeto_err;
-               }
-               err = scif_writeto(priv, copy.loffset, copy.len, copy.roffset,
-                                  copy.flags);
-writeto_err:
-               scif_err_debug(err, "scif_writeto");
-               return err;
-       }
-       case SCIF_VREADFROM:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_copy copy;
-
-               if (copy_from_user(&copy, argp, sizeof(copy))) {
-                       err = -EFAULT;
-                       goto vreadfrom_err;
-               }
-               err = scif_vreadfrom(priv, (void __force *)copy.addr, copy.len,
-                                    copy.roffset, copy.flags);
-vreadfrom_err:
-               scif_err_debug(err, "scif_vreadfrom");
-               return err;
-       }
-       case SCIF_VWRITETO:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_copy copy;
-
-               if (copy_from_user(&copy, argp, sizeof(copy))) {
-                       err = -EFAULT;
-                       goto vwriteto_err;
-               }
-               err = scif_vwriteto(priv, (void __force *)copy.addr, copy.len,
-                                   copy.roffset, copy.flags);
-vwriteto_err:
-               scif_err_debug(err, "scif_vwriteto");
-               return err;
-       }
-       case SCIF_FENCE_MARK:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_fence_mark mark;
-               int tmp_mark = 0;
-
-               if (copy_from_user(&mark, argp, sizeof(mark))) {
-                       err = -EFAULT;
-                       goto fence_mark_err;
-               }
-               err = scif_fence_mark(priv, mark.flags, &tmp_mark);
-               if (err)
-                       goto fence_mark_err;
-               if (copy_to_user((void __user *)mark.mark, &tmp_mark,
-                                sizeof(tmp_mark))) {
-                       err = -EFAULT;
-                       goto fence_mark_err;
-               }
-fence_mark_err:
-               scif_err_debug(err, "scif_fence_mark");
-               return err;
-       }
-       case SCIF_FENCE_WAIT:
-       {
-               struct scif_endpt *priv = f->private_data;
-
-               err = scif_fence_wait(priv, arg);
-               scif_err_debug(err, "scif_fence_wait");
-               return err;
-       }
-       case SCIF_FENCE_SIGNAL:
-       {
-               struct scif_endpt *priv = f->private_data;
-               struct scifioctl_fence_signal signal;
-
-               if (copy_from_user(&signal, argp, sizeof(signal))) {
-                       err = -EFAULT;
-                       goto fence_signal_err;
-               }
-
-               err = scif_fence_signal(priv, signal.loff, signal.lval,
-                                       signal.roff, signal.rval, signal.flags);
-fence_signal_err:
-               scif_err_debug(err, "scif_fence_signal");
-               return err;
-       }
-       }
-       return -EINVAL;
-}
-
-const struct file_operations scif_fops = {
-       .open = scif_fdopen,
-       .release = scif_fdclose,
-       .unlocked_ioctl = scif_fdioctl,
-       .mmap = scif_fdmmap,
-       .poll = scif_fdpoll,
-       .flush = scif_fdflush,
-       .owner = THIS_MODULE,
-};
diff --git a/drivers/misc/mic/scif/scif_fence.c b/drivers/misc/mic/scif/scif_fence.c
deleted file mode 100644 (file)
index 4fedf61..0000000
+++ /dev/null
@@ -1,783 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-
-#include "scif_main.h"
-
-/**
- * scif_recv_mark: Handle SCIF_MARK request
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has requested a mark.
- */
-void scif_recv_mark(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       int mark = 0;
-       int err;
-
-       err = _scif_fence_mark(ep, &mark);
-       if (err)
-               msg->uop = SCIF_MARK_NACK;
-       else
-               msg->uop = SCIF_MARK_ACK;
-       msg->payload[0] = ep->remote_ep;
-       msg->payload[2] = mark;
-       scif_nodeqp_send(ep->remote_dev, msg);
-}
-
-/**
- * scif_recv_mark_resp: Handle SCIF_MARK_(N)ACK messages.
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has responded to a SCIF_MARK message.
- */
-void scif_recv_mark_resp(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       struct scif_fence_info *fence_req =
-               (struct scif_fence_info *)msg->payload[1];
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (msg->uop == SCIF_MARK_ACK) {
-               fence_req->state = OP_COMPLETED;
-               fence_req->dma_mark = (int)msg->payload[2];
-       } else {
-               fence_req->state = OP_FAILED;
-       }
-       mutex_unlock(&ep->rma_info.rma_lock);
-       complete(&fence_req->comp);
-}
-
-/**
- * scif_recv_wait: Handle SCIF_WAIT request
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has requested waiting on a fence.
- */
-void scif_recv_wait(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       struct scif_remote_fence_info *fence;
-
-       /*
-        * Allocate structure for remote fence information and
-        * send a NACK if the allocation failed. The peer will
-        * return ENOMEM upon receiving a NACK.
-        */
-       fence = kmalloc(sizeof(*fence), GFP_KERNEL);
-       if (!fence) {
-               msg->payload[0] = ep->remote_ep;
-               msg->uop = SCIF_WAIT_NACK;
-               scif_nodeqp_send(ep->remote_dev, msg);
-               return;
-       }
-
-       /* Prepare the fence request */
-       memcpy(&fence->msg, msg, sizeof(struct scifmsg));
-       INIT_LIST_HEAD(&fence->list);
-
-       /* Insert to the global remote fence request list */
-       mutex_lock(&scif_info.fencelock);
-       atomic_inc(&ep->rma_info.fence_refcount);
-       list_add_tail(&fence->list, &scif_info.fence);
-       mutex_unlock(&scif_info.fencelock);
-
-       schedule_work(&scif_info.misc_work);
-}
-
-/**
- * scif_recv_wait_resp: Handle SCIF_WAIT_(N)ACK messages.
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has responded to a SCIF_WAIT message.
- */
-void scif_recv_wait_resp(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       struct scif_fence_info *fence_req =
-               (struct scif_fence_info *)msg->payload[1];
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (msg->uop == SCIF_WAIT_ACK)
-               fence_req->state = OP_COMPLETED;
-       else
-               fence_req->state = OP_FAILED;
-       mutex_unlock(&ep->rma_info.rma_lock);
-       complete(&fence_req->comp);
-}
-
-/**
- * scif_recv_sig_local: Handle SCIF_SIG_LOCAL request
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has requested a signal on a local offset.
- */
-void scif_recv_sig_local(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       int err;
-
-       err = scif_prog_signal(ep, msg->payload[1], msg->payload[2],
-                              SCIF_WINDOW_SELF);
-       if (err)
-               msg->uop = SCIF_SIG_NACK;
-       else
-               msg->uop = SCIF_SIG_ACK;
-       msg->payload[0] = ep->remote_ep;
-       scif_nodeqp_send(ep->remote_dev, msg);
-}
-
-/**
- * scif_recv_sig_remote: Handle SCIF_SIGNAL_REMOTE request
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has requested a signal on a remote offset.
- */
-void scif_recv_sig_remote(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       int err;
-
-       err = scif_prog_signal(ep, msg->payload[1], msg->payload[2],
-                              SCIF_WINDOW_PEER);
-       if (err)
-               msg->uop = SCIF_SIG_NACK;
-       else
-               msg->uop = SCIF_SIG_ACK;
-       msg->payload[0] = ep->remote_ep;
-       scif_nodeqp_send(ep->remote_dev, msg);
-}
-
-/**
- * scif_recv_sig_resp: Handle SCIF_SIG_(N)ACK messages.
- * @scifdev:   SCIF device
- * @msg:       Interrupt message
- *
- * The peer has responded to a signal request.
- */
-void scif_recv_sig_resp(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       struct scif_fence_info *fence_req =
-               (struct scif_fence_info *)msg->payload[3];
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (msg->uop == SCIF_SIG_ACK)
-               fence_req->state = OP_COMPLETED;
-       else
-               fence_req->state = OP_FAILED;
-       mutex_unlock(&ep->rma_info.rma_lock);
-       complete(&fence_req->comp);
-}
-
-static inline void *scif_get_local_va(off_t off, struct scif_window *window)
-{
-       struct page **pages = window->pinned_pages->pages;
-       int page_nr = (off - window->offset) >> PAGE_SHIFT;
-       off_t page_off = off & ~PAGE_MASK;
-
-       return page_address(pages[page_nr]) + page_off;
-}
-
-static void scif_prog_signal_cb(void *arg)
-{
-       struct scif_cb_arg *cb_arg = arg;
-
-       dma_pool_free(cb_arg->ep->remote_dev->signal_pool, cb_arg->status,
-                     cb_arg->src_dma_addr);
-       kfree(cb_arg);
-}
-
-static int _scif_prog_signal(scif_epd_t epd, dma_addr_t dst, u64 val)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct dma_chan *chan = ep->rma_info.dma_chan;
-       struct dma_device *ddev = chan->device;
-       bool x100 = !is_dma_copy_aligned(chan->device, 1, 1, 1);
-       struct dma_async_tx_descriptor *tx;
-       struct scif_status *status = NULL;
-       struct scif_cb_arg *cb_arg = NULL;
-       dma_addr_t src;
-       dma_cookie_t cookie;
-       int err;
-
-       tx = ddev->device_prep_dma_memcpy(chan, 0, 0, 0, DMA_PREP_FENCE);
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto alloc_fail;
-       }
-       cookie = tx->tx_submit(tx);
-       if (dma_submit_error(cookie)) {
-               err = (int)cookie;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto alloc_fail;
-       }
-       dma_async_issue_pending(chan);
-       if (x100) {
-               /*
-                * For X100 use the status descriptor to write the value to
-                * the destination.
-                */
-               tx = ddev->device_prep_dma_imm_data(chan, dst, val, 0);
-       } else {
-               status = dma_pool_alloc(ep->remote_dev->signal_pool, GFP_KERNEL,
-                                       &src);
-               if (!status) {
-                       err = -ENOMEM;
-                       dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto alloc_fail;
-               }
-               status->val = val;
-               status->src_dma_addr = src;
-               status->ep = ep;
-               src += offsetof(struct scif_status, val);
-               tx = ddev->device_prep_dma_memcpy(chan, dst, src, sizeof(val),
-                                                 DMA_PREP_INTERRUPT);
-       }
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto dma_fail;
-       }
-       if (!x100) {
-               cb_arg = kmalloc(sizeof(*cb_arg), GFP_KERNEL);
-               if (!cb_arg) {
-                       err = -ENOMEM;
-                       goto dma_fail;
-               }
-               cb_arg->src_dma_addr = src;
-               cb_arg->status = status;
-               cb_arg->ep = ep;
-               tx->callback = scif_prog_signal_cb;
-               tx->callback_param = cb_arg;
-       }
-       cookie = tx->tx_submit(tx);
-       if (dma_submit_error(cookie)) {
-               err = -EIO;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto dma_fail;
-       }
-       dma_async_issue_pending(chan);
-       return 0;
-dma_fail:
-       if (!x100) {
-               dma_pool_free(ep->remote_dev->signal_pool, status,
-                             src - offsetof(struct scif_status, val));
-               kfree(cb_arg);
-       }
-alloc_fail:
-       return err;
-}
-
-/**
- * scif_prog_signal:
- * @epd: Endpoint Descriptor
- * @offset: registered address to write @val to
- * @val: Value to be written at @offset
- * @type: Type of the window.
- *
- * Arrange to write a value to the registered offset after ensuring that the
- * offset provided is indeed valid.
- */
-int scif_prog_signal(scif_epd_t epd, off_t offset, u64 val,
-                    enum scif_window_type type)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scif_window *window = NULL;
-       struct scif_rma_req req;
-       dma_addr_t dst_dma_addr;
-       int err;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       req.out_window = &window;
-       req.offset = offset;
-       req.nr_bytes = sizeof(u64);
-       req.prot = SCIF_PROT_WRITE;
-       req.type = SCIF_WINDOW_SINGLE;
-       if (type == SCIF_WINDOW_SELF)
-               req.head = &ep->rma_info.reg_list;
-       else
-               req.head = &ep->rma_info.remote_reg_list;
-       /* Does a valid window exist? */
-       err = scif_query_window(&req);
-       if (err) {
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto unlock_ret;
-       }
-
-       if (scif_is_mgmt_node() && scifdev_self(ep->remote_dev)) {
-               u64 *dst_virt;
-
-               if (type == SCIF_WINDOW_SELF)
-                       dst_virt = scif_get_local_va(offset, window);
-               else
-                       dst_virt =
-                       scif_get_local_va(offset, (struct scif_window *)
-                                         window->peer_window);
-               *dst_virt = val;
-       } else {
-               dst_dma_addr = __scif_off_to_dma_addr(window, offset);
-               err = _scif_prog_signal(epd, dst_dma_addr, val);
-       }
-unlock_ret:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       return err;
-}
-
-static int _scif_fence_wait(scif_epd_t epd, int mark)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       dma_cookie_t cookie = mark & ~SCIF_REMOTE_FENCE;
-       int err;
-
-       /* Wait for DMA callback in scif_fence_mark_cb(..) */
-       err = wait_event_interruptible_timeout(ep->rma_info.markwq,
-                                              dma_async_is_tx_complete(
-                                              ep->rma_info.dma_chan,
-                                              cookie, NULL, NULL) ==
-                                              DMA_COMPLETE,
-                                              SCIF_NODE_ALIVE_TIMEOUT);
-       if (!err)
-               err = -ETIMEDOUT;
-       else if (err > 0)
-               err = 0;
-       return err;
-}
-
-/**
- * scif_rma_handle_remote_fences:
- *
- * This routine services remote fence requests.
- */
-void scif_rma_handle_remote_fences(void)
-{
-       struct list_head *item, *tmp;
-       struct scif_remote_fence_info *fence;
-       struct scif_endpt *ep;
-       int mark, err;
-
-       might_sleep();
-       mutex_lock(&scif_info.fencelock);
-       list_for_each_safe(item, tmp, &scif_info.fence) {
-               fence = list_entry(item, struct scif_remote_fence_info,
-                                  list);
-               /* Remove fence from global list */
-               list_del(&fence->list);
-
-               /* Initiate the fence operation */
-               ep = (struct scif_endpt *)fence->msg.payload[0];
-               mark = fence->msg.payload[2];
-               err = _scif_fence_wait(ep, mark);
-               if (err)
-                       fence->msg.uop = SCIF_WAIT_NACK;
-               else
-                       fence->msg.uop = SCIF_WAIT_ACK;
-               fence->msg.payload[0] = ep->remote_ep;
-               scif_nodeqp_send(ep->remote_dev, &fence->msg);
-               kfree(fence);
-               if (!atomic_sub_return(1, &ep->rma_info.fence_refcount))
-                       schedule_work(&scif_info.misc_work);
-       }
-       mutex_unlock(&scif_info.fencelock);
-}
-
-static int _scif_send_fence(scif_epd_t epd, int uop, int mark, int *out_mark)
-{
-       int err;
-       struct scifmsg msg;
-       struct scif_fence_info *fence_req;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-
-       fence_req = kmalloc(sizeof(*fence_req), GFP_KERNEL);
-       if (!fence_req) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       fence_req->state = OP_IN_PROGRESS;
-       init_completion(&fence_req->comp);
-
-       msg.src = ep->port;
-       msg.uop = uop;
-       msg.payload[0] = ep->remote_ep;
-       msg.payload[1] = (u64)fence_req;
-       if (uop == SCIF_WAIT)
-               msg.payload[2] = mark;
-       spin_lock(&ep->lock);
-       if (ep->state == SCIFEP_CONNECTED)
-               err = scif_nodeqp_send(ep->remote_dev, &msg);
-       else
-               err = -ENOTCONN;
-       spin_unlock(&ep->lock);
-       if (err)
-               goto error_free;
-retry:
-       /* Wait for a SCIF_WAIT_(N)ACK message */
-       err = wait_for_completion_timeout(&fence_req->comp,
-                                         SCIF_NODE_ALIVE_TIMEOUT);
-       if (!err && scifdev_alive(ep))
-               goto retry;
-       if (!err)
-               err = -ENODEV;
-       if (err > 0)
-               err = 0;
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (err < 0) {
-               if (fence_req->state == OP_IN_PROGRESS)
-                       fence_req->state = OP_FAILED;
-       }
-       if (fence_req->state == OP_FAILED && !err)
-               err = -ENOMEM;
-       if (uop == SCIF_MARK && fence_req->state == OP_COMPLETED)
-               *out_mark = SCIF_REMOTE_FENCE | fence_req->dma_mark;
-       mutex_unlock(&ep->rma_info.rma_lock);
-error_free:
-       kfree(fence_req);
-error:
-       return err;
-}
-
-/**
- * scif_send_fence_mark:
- * @epd: end point descriptor.
- * @out_mark: Output DMA mark reported by peer.
- *
- * Send a remote fence mark request.
- */
-static int scif_send_fence_mark(scif_epd_t epd, int *out_mark)
-{
-       return _scif_send_fence(epd, SCIF_MARK, 0, out_mark);
-}
-
-/**
- * scif_send_fence_wait:
- * @epd: end point descriptor.
- * @mark: DMA mark to wait for.
- *
- * Send a remote fence wait request.
- */
-static int scif_send_fence_wait(scif_epd_t epd, int mark)
-{
-       return _scif_send_fence(epd, SCIF_WAIT, mark, NULL);
-}
-
-static int _scif_send_fence_signal_wait(struct scif_endpt *ep,
-                                       struct scif_fence_info *fence_req)
-{
-       int err;
-
-retry:
-       /* Wait for a SCIF_SIG_(N)ACK message */
-       err = wait_for_completion_timeout(&fence_req->comp,
-                                         SCIF_NODE_ALIVE_TIMEOUT);
-       if (!err && scifdev_alive(ep))
-               goto retry;
-       if (!err)
-               err = -ENODEV;
-       if (err > 0)
-               err = 0;
-       if (err < 0) {
-               mutex_lock(&ep->rma_info.rma_lock);
-               if (fence_req->state == OP_IN_PROGRESS)
-                       fence_req->state = OP_FAILED;
-               mutex_unlock(&ep->rma_info.rma_lock);
-       }
-       if (fence_req->state == OP_FAILED && !err)
-               err = -ENXIO;
-       return err;
-}
-
-/**
- * scif_send_fence_signal:
- * @epd: endpoint descriptor
- * @loff: local offset
- * @lval: local value to write to loffset
- * @roff: remote offset
- * @rval: remote value to write to roffset
- * @flags: flags
- *
- * Sends a remote fence signal request
- */
-static int scif_send_fence_signal(scif_epd_t epd, off_t roff, u64 rval,
-                                 off_t loff, u64 lval, int flags)
-{
-       int err = 0;
-       struct scifmsg msg;
-       struct scif_fence_info *fence_req;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-
-       fence_req = kmalloc(sizeof(*fence_req), GFP_KERNEL);
-       if (!fence_req) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       fence_req->state = OP_IN_PROGRESS;
-       init_completion(&fence_req->comp);
-       msg.src = ep->port;
-       if (flags & SCIF_SIGNAL_LOCAL) {
-               msg.uop = SCIF_SIG_LOCAL;
-               msg.payload[0] = ep->remote_ep;
-               msg.payload[1] = roff;
-               msg.payload[2] = rval;
-               msg.payload[3] = (u64)fence_req;
-               spin_lock(&ep->lock);
-               if (ep->state == SCIFEP_CONNECTED)
-                       err = scif_nodeqp_send(ep->remote_dev, &msg);
-               else
-                       err = -ENOTCONN;
-               spin_unlock(&ep->lock);
-               if (err)
-                       goto error_free;
-               err = _scif_send_fence_signal_wait(ep, fence_req);
-               if (err)
-                       goto error_free;
-       }
-       fence_req->state = OP_IN_PROGRESS;
-
-       if (flags & SCIF_SIGNAL_REMOTE) {
-               msg.uop = SCIF_SIG_REMOTE;
-               msg.payload[0] = ep->remote_ep;
-               msg.payload[1] = loff;
-               msg.payload[2] = lval;
-               msg.payload[3] = (u64)fence_req;
-               spin_lock(&ep->lock);
-               if (ep->state == SCIFEP_CONNECTED)
-                       err = scif_nodeqp_send(ep->remote_dev, &msg);
-               else
-                       err = -ENOTCONN;
-               spin_unlock(&ep->lock);
-               if (err)
-                       goto error_free;
-               err = _scif_send_fence_signal_wait(ep, fence_req);
-       }
-error_free:
-       kfree(fence_req);
-error:
-       return err;
-}
-
-static void scif_fence_mark_cb(void *arg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)arg;
-
-       wake_up_interruptible(&ep->rma_info.markwq);
-       atomic_dec(&ep->rma_info.fence_refcount);
-}
-
-/**
- * _scif_fence_mark:
- * @epd: endpoint descriptor
- * @mark: DMA mark to set-up
- *
- * Set up a mark for this endpoint and return the value of the mark.
- */
-int _scif_fence_mark(scif_epd_t epd, int *mark)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct dma_chan *chan = ep->rma_info.dma_chan;
-       struct dma_device *ddev = chan->device;
-       struct dma_async_tx_descriptor *tx;
-       dma_cookie_t cookie;
-       int err;
-
-       tx = ddev->device_prep_dma_memcpy(chan, 0, 0, 0, DMA_PREP_FENCE);
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       cookie = tx->tx_submit(tx);
-       if (dma_submit_error(cookie)) {
-               err = (int)cookie;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       dma_async_issue_pending(chan);
-       tx = ddev->device_prep_dma_interrupt(chan, DMA_PREP_INTERRUPT);
-       if (!tx) {
-               err = -ENOMEM;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       tx->callback = scif_fence_mark_cb;
-       tx->callback_param = ep;
-       *mark = cookie = tx->tx_submit(tx);
-       if (dma_submit_error(cookie)) {
-               err = (int)cookie;
-               dev_err(&ep->remote_dev->sdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               return err;
-       }
-       atomic_inc(&ep->rma_info.fence_refcount);
-       dma_async_issue_pending(chan);
-       return 0;
-}
-
-#define SCIF_LOOPB_MAGIC_MARK 0xdead
-
-int scif_fence_mark(scif_epd_t epd, int flags, int *mark)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI fence_mark: ep %p flags 0x%x mark 0x%x\n",
-               ep, flags, *mark);
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       /* Invalid flags? */
-       if (flags & ~(SCIF_FENCE_INIT_SELF | SCIF_FENCE_INIT_PEER))
-               return -EINVAL;
-
-       /* At least one of init self or peer RMA should be set */
-       if (!(flags & (SCIF_FENCE_INIT_SELF | SCIF_FENCE_INIT_PEER)))
-               return -EINVAL;
-
-       /* Exactly one of init self or peer RMA should be set but not both */
-       if ((flags & SCIF_FENCE_INIT_SELF) && (flags & SCIF_FENCE_INIT_PEER))
-               return -EINVAL;
-
-       /*
-        * Management node loopback does not need to use DMA.
-        * Return a valid mark to be symmetric.
-        */
-       if (scifdev_self(ep->remote_dev) && scif_is_mgmt_node()) {
-               *mark = SCIF_LOOPB_MAGIC_MARK;
-               return 0;
-       }
-
-       if (flags & SCIF_FENCE_INIT_SELF)
-               err = _scif_fence_mark(epd, mark);
-       else
-               err = scif_send_fence_mark(ep, mark);
-
-       if (err)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI fence_mark: ep %p flags 0x%x mark 0x%x err %d\n",
-               ep, flags, *mark, err);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_fence_mark);
-
-int scif_fence_wait(scif_epd_t epd, int mark)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI fence_wait: ep %p mark 0x%x\n",
-               ep, mark);
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-       /*
-        * Management node loopback does not need to use DMA.
-        * The only valid mark provided is 0 so simply
-        * return success if the mark is valid.
-        */
-       if (scifdev_self(ep->remote_dev) && scif_is_mgmt_node()) {
-               if (mark == SCIF_LOOPB_MAGIC_MARK)
-                       return 0;
-               else
-                       return -EINVAL;
-       }
-       if (mark & SCIF_REMOTE_FENCE)
-               err = scif_send_fence_wait(epd, mark);
-       else
-               err = _scif_fence_wait(epd, mark);
-       if (err < 0)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_fence_wait);
-
-int scif_fence_signal(scif_epd_t epd, off_t loff, u64 lval,
-                     off_t roff, u64 rval, int flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       int err = 0;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI fence_signal: ep %p loff 0x%lx lval 0x%llx roff 0x%lx rval 0x%llx flags 0x%x\n",
-               ep, loff, lval, roff, rval, flags);
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       /* Invalid flags? */
-       if (flags & ~(SCIF_FENCE_INIT_SELF | SCIF_FENCE_INIT_PEER |
-                       SCIF_SIGNAL_LOCAL | SCIF_SIGNAL_REMOTE))
-               return -EINVAL;
-
-       /* At least one of init self or peer RMA should be set */
-       if (!(flags & (SCIF_FENCE_INIT_SELF | SCIF_FENCE_INIT_PEER)))
-               return -EINVAL;
-
-       /* Exactly one of init self or peer RMA should be set but not both */
-       if ((flags & SCIF_FENCE_INIT_SELF) && (flags & SCIF_FENCE_INIT_PEER))
-               return -EINVAL;
-
-       /* At least one of SCIF_SIGNAL_LOCAL or SCIF_SIGNAL_REMOTE required */
-       if (!(flags & (SCIF_SIGNAL_LOCAL | SCIF_SIGNAL_REMOTE)))
-               return -EINVAL;
-
-       /* Only Dword offsets allowed */
-       if ((flags & SCIF_SIGNAL_LOCAL) && (loff & (sizeof(u32) - 1)))
-               return -EINVAL;
-
-       /* Only Dword aligned offsets allowed */
-       if ((flags & SCIF_SIGNAL_REMOTE) && (roff & (sizeof(u32) - 1)))
-               return -EINVAL;
-
-       if (flags & SCIF_FENCE_INIT_PEER) {
-               err = scif_send_fence_signal(epd, roff, rval, loff,
-                                            lval, flags);
-       } else {
-               /* Local Signal in Local RAS */
-               if (flags & SCIF_SIGNAL_LOCAL) {
-                       err = scif_prog_signal(epd, loff, lval,
-                                              SCIF_WINDOW_SELF);
-                       if (err)
-                               goto error_ret;
-               }
-
-               /* Signal in Remote RAS */
-               if (flags & SCIF_SIGNAL_REMOTE)
-                       err = scif_prog_signal(epd, roff,
-                                              rval, SCIF_WINDOW_PEER);
-       }
-error_ret:
-       if (err)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_fence_signal);
diff --git a/drivers/misc/mic/scif/scif_main.c b/drivers/misc/mic/scif/scif_main.c
deleted file mode 100644 (file)
index e2278bf..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/module.h>
-#include <linux/idr.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-#include "../bus/scif_bus.h"
-#include "scif_peer_bus.h"
-#include "scif_main.h"
-#include "scif_map.h"
-
-struct scif_info scif_info = {
-       .mdev = {
-               .minor = MISC_DYNAMIC_MINOR,
-               .name = "scif",
-               .fops = &scif_fops,
-       }
-};
-
-struct scif_dev *scif_dev;
-struct kmem_cache *unaligned_cache;
-static atomic_t g_loopb_cnt;
-
-/* Runs in the context of intr_wq */
-static void scif_intr_bh_handler(struct work_struct *work)
-{
-       struct scif_dev *scifdev =
-                       container_of(work, struct scif_dev, intr_bh);
-
-       if (scifdev_self(scifdev))
-               scif_loopb_msg_handler(scifdev, scifdev->qpairs);
-       else
-               scif_nodeqp_intrhandler(scifdev, scifdev->qpairs);
-}
-
-int scif_setup_intr_wq(struct scif_dev *scifdev)
-{
-       if (!scifdev->intr_wq) {
-               snprintf(scifdev->intr_wqname, sizeof(scifdev->intr_wqname),
-                        "SCIF INTR %d", scifdev->node);
-               scifdev->intr_wq =
-                       alloc_ordered_workqueue(scifdev->intr_wqname, 0);
-               if (!scifdev->intr_wq)
-                       return -ENOMEM;
-               INIT_WORK(&scifdev->intr_bh, scif_intr_bh_handler);
-       }
-       return 0;
-}
-
-void scif_destroy_intr_wq(struct scif_dev *scifdev)
-{
-       if (scifdev->intr_wq) {
-               destroy_workqueue(scifdev->intr_wq);
-               scifdev->intr_wq = NULL;
-       }
-}
-
-irqreturn_t scif_intr_handler(int irq, void *data)
-{
-       struct scif_dev *scifdev = data;
-       struct scif_hw_dev *sdev = scifdev->sdev;
-
-       sdev->hw_ops->ack_interrupt(sdev, scifdev->db);
-       queue_work(scifdev->intr_wq, &scifdev->intr_bh);
-       return IRQ_HANDLED;
-}
-
-static void scif_qp_setup_handler(struct work_struct *work)
-{
-       struct scif_dev *scifdev = container_of(work, struct scif_dev,
-                                               qp_dwork.work);
-       struct scif_hw_dev *sdev = scifdev->sdev;
-       dma_addr_t da = 0;
-       int err;
-
-       if (scif_is_mgmt_node()) {
-               struct mic_bootparam *bp = sdev->dp;
-
-               da = bp->scif_card_dma_addr;
-               scifdev->rdb = bp->h2c_scif_db;
-       } else {
-               struct mic_bootparam __iomem *bp = sdev->rdp;
-
-               da = readq(&bp->scif_host_dma_addr);
-               scifdev->rdb = ioread8(&bp->c2h_scif_db);
-       }
-       if (da) {
-               err = scif_qp_response(da, scifdev);
-               if (err)
-                       dev_err(&scifdev->sdev->dev,
-                               "scif_qp_response err %d\n", err);
-       } else {
-               schedule_delayed_work(&scifdev->qp_dwork,
-                                     msecs_to_jiffies(1000));
-       }
-}
-
-static int scif_setup_scifdev(void)
-{
-       /* We support a maximum of 129 SCIF nodes including the mgmt node */
-#define MAX_SCIF_NODES 129
-       int i;
-       u8 num_nodes = MAX_SCIF_NODES;
-
-       scif_dev = kcalloc(num_nodes, sizeof(*scif_dev), GFP_KERNEL);
-       if (!scif_dev)
-               return -ENOMEM;
-       for (i = 0; i < num_nodes; i++) {
-               struct scif_dev *scifdev = &scif_dev[i];
-
-               scifdev->node = i;
-               scifdev->exit = OP_IDLE;
-               init_waitqueue_head(&scifdev->disconn_wq);
-               mutex_init(&scifdev->lock);
-               INIT_WORK(&scifdev->peer_add_work, scif_add_peer_device);
-               INIT_DELAYED_WORK(&scifdev->p2p_dwork,
-                                 scif_poll_qp_state);
-               INIT_DELAYED_WORK(&scifdev->qp_dwork,
-                                 scif_qp_setup_handler);
-               INIT_LIST_HEAD(&scifdev->p2p);
-               RCU_INIT_POINTER(scifdev->spdev, NULL);
-       }
-       return 0;
-}
-
-static void scif_destroy_scifdev(void)
-{
-       kfree(scif_dev);
-       scif_dev = NULL;
-}
-
-static int scif_probe(struct scif_hw_dev *sdev)
-{
-       struct scif_dev *scifdev = &scif_dev[sdev->dnode];
-       int rc;
-
-       dev_set_drvdata(&sdev->dev, sdev);
-       scifdev->sdev = sdev;
-
-       if (1 == atomic_add_return(1, &g_loopb_cnt)) {
-               struct scif_dev *loopb_dev = &scif_dev[sdev->snode];
-
-               loopb_dev->sdev = sdev;
-               rc = scif_setup_loopback_qp(loopb_dev);
-               if (rc)
-                       goto exit;
-       }
-
-       rc = scif_setup_intr_wq(scifdev);
-       if (rc)
-               goto destroy_loopb;
-       rc = scif_setup_qp(scifdev);
-       if (rc)
-               goto destroy_intr;
-       scifdev->db = sdev->hw_ops->next_db(sdev);
-       scifdev->cookie = sdev->hw_ops->request_irq(sdev, scif_intr_handler,
-                                                   "SCIF_INTR", scifdev,
-                                                   scifdev->db);
-       if (IS_ERR(scifdev->cookie)) {
-               rc = PTR_ERR(scifdev->cookie);
-               goto free_qp;
-       }
-       if (scif_is_mgmt_node()) {
-               struct mic_bootparam *bp = sdev->dp;
-
-               bp->c2h_scif_db = scifdev->db;
-               bp->scif_host_dma_addr = scifdev->qp_dma_addr;
-       } else {
-               struct mic_bootparam __iomem *bp = sdev->rdp;
-
-               iowrite8(scifdev->db, &bp->h2c_scif_db);
-               writeq(scifdev->qp_dma_addr, &bp->scif_card_dma_addr);
-       }
-       schedule_delayed_work(&scifdev->qp_dwork,
-                             msecs_to_jiffies(1000));
-       return rc;
-free_qp:
-       scif_free_qp(scifdev);
-destroy_intr:
-       scif_destroy_intr_wq(scifdev);
-destroy_loopb:
-       if (atomic_dec_and_test(&g_loopb_cnt))
-               scif_destroy_loopback_qp(&scif_dev[sdev->snode]);
-exit:
-       return rc;
-}
-
-void scif_stop(struct scif_dev *scifdev)
-{
-       struct scif_dev *dev;
-       int i;
-
-       for (i = scif_info.maxid; i >= 0; i--) {
-               dev = &scif_dev[i];
-               if (scifdev_self(dev))
-                       continue;
-               scif_handle_remove_node(i);
-       }
-}
-
-static void scif_remove(struct scif_hw_dev *sdev)
-{
-       struct scif_dev *scifdev = &scif_dev[sdev->dnode];
-
-       if (scif_is_mgmt_node()) {
-               struct mic_bootparam *bp = sdev->dp;
-
-               bp->c2h_scif_db = -1;
-               bp->scif_host_dma_addr = 0x0;
-       } else {
-               struct mic_bootparam __iomem *bp = sdev->rdp;
-
-               iowrite8(-1, &bp->h2c_scif_db);
-               writeq(0x0, &bp->scif_card_dma_addr);
-       }
-       if (scif_is_mgmt_node()) {
-               scif_disconnect_node(scifdev->node, true);
-       } else {
-               scif_info.card_initiated_exit = true;
-               scif_stop(scifdev);
-       }
-       if (atomic_dec_and_test(&g_loopb_cnt))
-               scif_destroy_loopback_qp(&scif_dev[sdev->snode]);
-       if (scifdev->cookie) {
-               sdev->hw_ops->free_irq(sdev, scifdev->cookie, scifdev);
-               scifdev->cookie = NULL;
-       }
-       scif_destroy_intr_wq(scifdev);
-       cancel_delayed_work(&scifdev->qp_dwork);
-       scif_free_qp(scifdev);
-       scifdev->rdb = -1;
-       scifdev->sdev = NULL;
-}
-
-static struct scif_hw_dev_id id_table[] = {
-       { MIC_SCIF_DEV, SCIF_DEV_ANY_ID },
-       { 0 },
-};
-
-static struct scif_driver scif_driver = {
-       .driver.name =  KBUILD_MODNAME,
-       .driver.owner = THIS_MODULE,
-       .id_table = id_table,
-       .probe = scif_probe,
-       .remove = scif_remove,
-};
-
-static int _scif_init(void)
-{
-       int rc;
-
-       mutex_init(&scif_info.eplock);
-       spin_lock_init(&scif_info.rmalock);
-       spin_lock_init(&scif_info.nb_connect_lock);
-       spin_lock_init(&scif_info.port_lock);
-       mutex_init(&scif_info.conflock);
-       mutex_init(&scif_info.connlock);
-       mutex_init(&scif_info.fencelock);
-       INIT_LIST_HEAD(&scif_info.uaccept);
-       INIT_LIST_HEAD(&scif_info.listen);
-       INIT_LIST_HEAD(&scif_info.zombie);
-       INIT_LIST_HEAD(&scif_info.connected);
-       INIT_LIST_HEAD(&scif_info.disconnected);
-       INIT_LIST_HEAD(&scif_info.rma);
-       INIT_LIST_HEAD(&scif_info.rma_tc);
-       INIT_LIST_HEAD(&scif_info.mmu_notif_cleanup);
-       INIT_LIST_HEAD(&scif_info.fence);
-       INIT_LIST_HEAD(&scif_info.nb_connect_list);
-       init_waitqueue_head(&scif_info.exitwq);
-       scif_info.rma_tc_limit = SCIF_RMA_TEMP_CACHE_LIMIT;
-       scif_info.en_msg_log = 0;
-       scif_info.p2p_enable = 1;
-       rc = scif_setup_scifdev();
-       if (rc)
-               goto error;
-       unaligned_cache = kmem_cache_create("Unaligned_DMA",
-                                           SCIF_KMEM_UNALIGNED_BUF_SIZE,
-                                           0, SLAB_HWCACHE_ALIGN, NULL);
-       if (!unaligned_cache) {
-               rc = -ENOMEM;
-               goto free_sdev;
-       }
-       INIT_WORK(&scif_info.misc_work, scif_misc_handler);
-       INIT_WORK(&scif_info.mmu_notif_work, scif_mmu_notif_handler);
-       INIT_WORK(&scif_info.conn_work, scif_conn_handler);
-       idr_init(&scif_ports);
-       return 0;
-free_sdev:
-       scif_destroy_scifdev();
-error:
-       return rc;
-}
-
-static void _scif_exit(void)
-{
-       idr_destroy(&scif_ports);
-       kmem_cache_destroy(unaligned_cache);
-       scif_destroy_scifdev();
-}
-
-static int __init scif_init(void)
-{
-       struct miscdevice *mdev = &scif_info.mdev;
-       int rc;
-
-       _scif_init();
-       iova_cache_get();
-       rc = scif_peer_bus_init();
-       if (rc)
-               goto exit;
-       rc = scif_register_driver(&scif_driver);
-       if (rc)
-               goto peer_bus_exit;
-       rc = misc_register(mdev);
-       if (rc)
-               goto unreg_scif;
-       scif_init_debugfs();
-       return 0;
-unreg_scif:
-       scif_unregister_driver(&scif_driver);
-peer_bus_exit:
-       scif_peer_bus_exit();
-exit:
-       _scif_exit();
-       return rc;
-}
-
-static void __exit scif_exit(void)
-{
-       scif_exit_debugfs();
-       misc_deregister(&scif_info.mdev);
-       scif_unregister_driver(&scif_driver);
-       scif_peer_bus_exit();
-       iova_cache_put();
-       _scif_exit();
-}
-
-module_init(scif_init);
-module_exit(scif_exit);
-
-MODULE_DEVICE_TABLE(scif, id_table);
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) SCIF driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/scif/scif_main.h b/drivers/misc/mic/scif/scif_main.h
deleted file mode 100644 (file)
index bb3ab97..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#ifndef SCIF_MAIN_H
-#define SCIF_MAIN_H
-
-#include <linux/sched/signal.h>
-#include <linux/pci.h>
-#include <linux/miscdevice.h>
-#include <linux/dmaengine.h>
-#include <linux/iova.h>
-#include <linux/anon_inodes.h>
-#include <linux/file.h>
-#include <linux/vmalloc.h>
-#include <linux/scif.h>
-#include "../common/mic_dev.h"
-
-#define SCIF_MGMT_NODE 0
-#define SCIF_DEFAULT_WATCHDOG_TO 30
-#define SCIF_NODE_ACCEPT_TIMEOUT (3 * HZ)
-#define SCIF_NODE_ALIVE_TIMEOUT (SCIF_DEFAULT_WATCHDOG_TO * HZ)
-#define SCIF_RMA_TEMP_CACHE_LIMIT 0x20000
-
-/*
- * Generic state used for certain node QP message exchanges
- * like Unregister, Alloc etc.
- */
-enum scif_msg_state {
-       OP_IDLE = 1,
-       OP_IN_PROGRESS,
-       OP_COMPLETED,
-       OP_FAILED
-};
-
-/*
- * struct scif_info - Global SCIF information
- *
- * @nodeid: Node ID this node is to others
- * @maxid: Max known node ID
- * @total: Total number of SCIF nodes
- * @nr_zombies: number of zombie endpoints
- * @eplock: Lock to synchronize listening, zombie endpoint lists
- * @connlock: Lock to synchronize connected and disconnected lists
- * @nb_connect_lock: Synchronize non blocking connect operations
- * @port_lock: Synchronize access to SCIF ports
- * @uaccept: List of user acceptreq waiting for acceptreg
- * @listen: List of listening end points
- * @zombie: List of zombie end points with pending RMA's
- * @connected: List of end points in connected state
- * @disconnected: List of end points in disconnected state
- * @nb_connect_list: List for non blocking connections
- * @misc_work: miscellaneous SCIF tasks
- * @conflock: Lock to synchronize SCIF node configuration changes
- * @en_msg_log: Enable debug message logging
- * @p2p_enable: Enable P2P SCIF network
- * @mdev: The MISC device
- * @conn_work: Work for workqueue handling all connections
- * @exitwq: Wait queue for waiting for an EXIT node QP message response
- * @loopb_dev: Dummy SCIF device used for loopback
- * @loopb_wq: Workqueue used for handling loopback messages
- * @loopb_wqname[16]: Name of loopback workqueue
- * @loopb_work: Used for submitting work to loopb_wq
- * @loopb_recv_q: List of messages received on the loopb_wq
- * @card_initiated_exit: set when the card has initiated the exit
- * @rmalock: Synchronize access to RMA operations
- * @fencelock: Synchronize access to list of remote fences requested.
- * @rma: List of temporary registered windows to be destroyed.
- * @rma_tc: List of temporary registered & cached Windows to be destroyed
- * @fence: List of remote fence requests
- * @mmu_notif_work: Work for registration caching MMU notifier workqueue
- * @mmu_notif_cleanup: List of temporary cached windows for reg cache
- * @rma_tc_limit: RMA temporary cache limit
- */
-struct scif_info {
-       u8 nodeid;
-       u8 maxid;
-       u8 total;
-       u32 nr_zombies;
-       struct mutex eplock;
-       struct mutex connlock;
-       spinlock_t nb_connect_lock;
-       spinlock_t port_lock;
-       struct list_head uaccept;
-       struct list_head listen;
-       struct list_head zombie;
-       struct list_head connected;
-       struct list_head disconnected;
-       struct list_head nb_connect_list;
-       struct work_struct misc_work;
-       struct mutex conflock;
-       u8 en_msg_log;
-       u8 p2p_enable;
-       struct miscdevice mdev;
-       struct work_struct conn_work;
-       wait_queue_head_t exitwq;
-       struct scif_dev *loopb_dev;
-       struct workqueue_struct *loopb_wq;
-       char loopb_wqname[16];
-       struct work_struct loopb_work;
-       struct list_head loopb_recv_q;
-       bool card_initiated_exit;
-       spinlock_t rmalock;
-       struct mutex fencelock;
-       struct list_head rma;
-       struct list_head rma_tc;
-       struct list_head fence;
-       struct work_struct mmu_notif_work;
-       struct list_head mmu_notif_cleanup;
-       unsigned long rma_tc_limit;
-};
-
-/*
- * struct scif_p2p_info - SCIF mapping information used for P2P
- *
- * @ppi_peer_id - SCIF peer node id
- * @ppi_sg - Scatter list for bar information (One for mmio and one for aper)
- * @sg_nentries - Number of entries in the scatterlist
- * @ppi_da: DMA address for MMIO and APER bars
- * @ppi_len: Length of MMIO and APER bars
- * @ppi_list: Link in list of mapping information
- */
-struct scif_p2p_info {
-       u8 ppi_peer_id;
-       struct scatterlist *ppi_sg[2];
-       u64 sg_nentries[2];
-       dma_addr_t ppi_da[2];
-       u64 ppi_len[2];
-#define SCIF_PPI_MMIO 0
-#define SCIF_PPI_APER 1
-       struct list_head ppi_list;
-};
-
-/*
- * struct scif_dev - SCIF remote device specific fields
- *
- * @node: Node id
- * @p2p: List of P2P mapping information
- * @qpairs: The node queue pair for exchanging control messages
- * @intr_wq: Workqueue for handling Node QP messages
- * @intr_wqname: Name of node QP workqueue for handling interrupts
- * @intr_bh: Used for submitting work to intr_wq
- * @lock: Lock used for synchronizing access to the scif device
- * @sdev: SCIF hardware device on the SCIF hardware bus
- * @db: doorbell the peer will trigger to generate an interrupt on self
- * @rdb: Doorbell to trigger on the peer to generate an interrupt on the peer
- * @cookie: Cookie received while registering the interrupt handler
- * @peer_add_work: Work for handling device_add for peer devices
- * @p2p_dwork: Delayed work to enable polling for P2P state
- * @qp_dwork: Delayed work for enabling polling for remote QP information
- * @p2p_retry: Number of times to retry polling of P2P state
- * @base_addr: P2P aperture bar base address
- * @mic_mw mmio: The peer MMIO information used for P2P
- * @spdev: SCIF peer device on the SCIF peer bus
- * @node_remove_ack_pending: True if a node_remove_ack is pending
- * @exit_ack_pending: true if an exit_ack is pending
- * @disconn_wq: Used while waiting for a node remove response
- * @disconn_rescnt: Keeps track of number of node remove requests sent
- * @exit: Status of exit message
- * @qp_dma_addr: Queue pair DMA address passed to the peer
- * @dma_ch_idx: Round robin index for DMA channels
- * @signal_pool: DMA pool used for scheduling scif_fence_signal DMA's
-*/
-struct scif_dev {
-       u8 node;
-       struct list_head p2p;
-       struct scif_qp *qpairs;
-       struct workqueue_struct *intr_wq;
-       char intr_wqname[16];
-       struct work_struct intr_bh;
-       struct mutex lock;
-       struct scif_hw_dev *sdev;
-       int db;
-       int rdb;
-       struct mic_irq *cookie;
-       struct work_struct peer_add_work;
-       struct delayed_work p2p_dwork;
-       struct delayed_work qp_dwork;
-       int p2p_retry;
-       dma_addr_t base_addr;
-       struct mic_mw mmio;
-       struct scif_peer_dev __rcu *spdev;
-       bool node_remove_ack_pending;
-       bool exit_ack_pending;
-       wait_queue_head_t disconn_wq;
-       atomic_t disconn_rescnt;
-       enum scif_msg_state exit;
-       dma_addr_t qp_dma_addr;
-       int dma_ch_idx;
-       struct dma_pool *signal_pool;
-};
-
-extern bool scif_reg_cache_enable;
-extern bool scif_ulimit_check;
-extern struct scif_info scif_info;
-extern struct idr scif_ports;
-extern struct bus_type scif_peer_bus;
-extern struct scif_dev *scif_dev;
-extern const struct file_operations scif_fops;
-extern const struct file_operations scif_anon_fops;
-
-/* Size of the RB for the Node QP */
-#define SCIF_NODE_QP_SIZE 0x10000
-
-#include "scif_nodeqp.h"
-#include "scif_rma.h"
-#include "scif_rma_list.h"
-
-/*
- * scifdev_self:
- * @dev: The remote SCIF Device
- *
- * Returns true if the SCIF Device passed is the self aka Loopback SCIF device.
- */
-static inline int scifdev_self(struct scif_dev *dev)
-{
-       return dev->node == scif_info.nodeid;
-}
-
-static inline bool scif_is_mgmt_node(void)
-{
-       return !scif_info.nodeid;
-}
-
-/*
- * scifdev_is_p2p:
- * @dev: The remote SCIF Device
- *
- * Returns true if the SCIF Device is a MIC Peer to Peer SCIF device.
- */
-static inline bool scifdev_is_p2p(struct scif_dev *dev)
-{
-       if (scif_is_mgmt_node())
-               return false;
-       else
-               return dev != &scif_dev[SCIF_MGMT_NODE] &&
-                       !scifdev_self(dev);
-}
-
-/*
- * scifdev_alive:
- * @scifdev: The remote SCIF Device
- *
- * Returns true if the remote SCIF Device is running or sleeping for
- * this endpoint.
- */
-static inline int _scifdev_alive(struct scif_dev *scifdev)
-{
-       struct scif_peer_dev *spdev;
-
-       rcu_read_lock();
-       spdev = rcu_dereference(scifdev->spdev);
-       rcu_read_unlock();
-       return !!spdev;
-}
-
-#include "scif_epd.h"
-
-void __init scif_init_debugfs(void);
-void scif_exit_debugfs(void);
-int scif_setup_intr_wq(struct scif_dev *scifdev);
-void scif_destroy_intr_wq(struct scif_dev *scifdev);
-void scif_cleanup_scifdev(struct scif_dev *dev);
-void scif_handle_remove_node(int node);
-void scif_disconnect_node(u32 node_id, bool mgmt_initiated);
-void scif_free_qp(struct scif_dev *dev);
-void scif_misc_handler(struct work_struct *work);
-void scif_stop(struct scif_dev *scifdev);
-irqreturn_t scif_intr_handler(int irq, void *data);
-#endif /* SCIF_MAIN_H */
diff --git a/drivers/misc/mic/scif/scif_map.h b/drivers/misc/mic/scif/scif_map.h
deleted file mode 100644 (file)
index 96b7608..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#ifndef SCIF_MAP_H
-#define SCIF_MAP_H
-
-#include "../bus/scif_bus.h"
-
-static __always_inline void *
-scif_alloc_coherent(dma_addr_t *dma_handle,
-                   struct scif_dev *scifdev, size_t size,
-                   gfp_t gfp)
-{
-       void *va;
-
-       if (scifdev_self(scifdev)) {
-               va = kmalloc(size, gfp);
-               if (va)
-                       *dma_handle = virt_to_phys(va);
-       } else {
-               va = dma_alloc_coherent(&scifdev->sdev->dev,
-                                       size, dma_handle, gfp);
-               if (va && scifdev_is_p2p(scifdev))
-                       *dma_handle = *dma_handle + scifdev->base_addr;
-       }
-       return va;
-}
-
-static __always_inline void
-scif_free_coherent(void *va, dma_addr_t local,
-                  struct scif_dev *scifdev, size_t size)
-{
-       if (scifdev_self(scifdev)) {
-               kfree(va);
-       } else {
-               if (scifdev_is_p2p(scifdev) && local > scifdev->base_addr)
-                       local = local - scifdev->base_addr;
-               dma_free_coherent(&scifdev->sdev->dev,
-                                 size, va, local);
-       }
-}
-
-static __always_inline int
-scif_map_single(dma_addr_t *dma_handle,
-               void *local, struct scif_dev *scifdev, size_t size)
-{
-       int err = 0;
-
-       if (scifdev_self(scifdev)) {
-               *dma_handle = virt_to_phys((local));
-       } else {
-               *dma_handle = dma_map_single(&scifdev->sdev->dev,
-                                            local, size, DMA_BIDIRECTIONAL);
-               if (dma_mapping_error(&scifdev->sdev->dev, *dma_handle))
-                       err = -ENOMEM;
-               else if (scifdev_is_p2p(scifdev))
-                       *dma_handle = *dma_handle + scifdev->base_addr;
-       }
-       if (err)
-               *dma_handle = 0;
-       return err;
-}
-
-static __always_inline void
-scif_unmap_single(dma_addr_t local, struct scif_dev *scifdev,
-                 size_t size)
-{
-       if (!scifdev_self(scifdev)) {
-               if (scifdev_is_p2p(scifdev))
-                       local = local - scifdev->base_addr;
-               dma_unmap_single(&scifdev->sdev->dev, local,
-                                size, DMA_BIDIRECTIONAL);
-       }
-}
-
-static __always_inline void *
-scif_ioremap(dma_addr_t phys, size_t size, struct scif_dev *scifdev)
-{
-       void *out_virt;
-       struct scif_hw_dev *sdev = scifdev->sdev;
-
-       if (scifdev_self(scifdev))
-               out_virt = phys_to_virt(phys);
-       else
-               out_virt = (void __force *)
-                          sdev->hw_ops->remap(sdev, phys, size);
-       return out_virt;
-}
-
-static __always_inline void
-scif_iounmap(void *virt, size_t len, struct scif_dev *scifdev)
-{
-       if (!scifdev_self(scifdev)) {
-               struct scif_hw_dev *sdev = scifdev->sdev;
-
-               sdev->hw_ops->unmap(sdev, (void __force __iomem *)virt);
-       }
-}
-
-static __always_inline int
-scif_map_page(dma_addr_t *dma_handle, struct page *page,
-             struct scif_dev *scifdev)
-{
-       int err = 0;
-
-       if (scifdev_self(scifdev)) {
-               *dma_handle = page_to_phys(page);
-       } else {
-               struct scif_hw_dev *sdev = scifdev->sdev;
-               *dma_handle = dma_map_page(&sdev->dev,
-                                          page, 0x0, PAGE_SIZE,
-                                          DMA_BIDIRECTIONAL);
-               if (dma_mapping_error(&sdev->dev, *dma_handle))
-                       err = -ENOMEM;
-               else if (scifdev_is_p2p(scifdev))
-                       *dma_handle = *dma_handle + scifdev->base_addr;
-       }
-       if (err)
-               *dma_handle = 0;
-       return err;
-}
-#endif  /* SCIF_MAP_H */
diff --git a/drivers/misc/mic/scif/scif_mmap.c b/drivers/misc/mic/scif/scif_mmap.c
deleted file mode 100644 (file)
index a151d41..0000000
+++ /dev/null
@@ -1,690 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-
-/*
- * struct scif_vma_info - Information about a remote memory mapping
- *                       created via scif_mmap(..)
- * @vma: VM area struct
- * @list: link to list of active vmas
- */
-struct scif_vma_info {
-       struct vm_area_struct *vma;
-       struct list_head list;
-};
-
-void scif_recv_munmap(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_rma_req req;
-       struct scif_window *window = NULL;
-       struct scif_window *recv_window =
-               (struct scif_window *)msg->payload[0];
-       struct scif_endpt *ep;
-
-       ep = (struct scif_endpt *)recv_window->ep;
-       req.out_window = &window;
-       req.offset = recv_window->offset;
-       req.prot = recv_window->prot;
-       req.nr_bytes = recv_window->nr_pages << PAGE_SHIFT;
-       req.type = SCIF_WINDOW_FULL;
-       req.head = &ep->rma_info.reg_list;
-       msg->payload[0] = ep->remote_ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Does a valid window exist? */
-       if (scif_query_window(&req)) {
-               dev_err(&scifdev->sdev->dev,
-                       "%s %d -ENXIO\n", __func__, __LINE__);
-               msg->uop = SCIF_UNREGISTER_ACK;
-               goto error;
-       }
-
-       scif_put_window(window, window->nr_pages);
-
-       if (!window->ref_count) {
-               atomic_inc(&ep->rma_info.tw_refcount);
-               ep->rma_info.async_list_del = 1;
-               list_del_init(&window->list);
-               scif_free_window_offset(ep, window, window->offset);
-       }
-error:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (window && !window->ref_count)
-               scif_queue_for_cleanup(window, &scif_info.rma);
-}
-
-/*
- * Remove valid remote memory mappings created via scif_mmap(..) from the
- * process address space since the remote node is lost
- */
-static void __scif_zap_mmaps(struct scif_endpt *ep)
-{
-       struct list_head *item;
-       struct scif_vma_info *info;
-       struct vm_area_struct *vma;
-       unsigned long size;
-
-       spin_lock(&ep->lock);
-       list_for_each(item, &ep->rma_info.vma_list) {
-               info = list_entry(item, struct scif_vma_info, list);
-               vma = info->vma;
-               size = vma->vm_end - vma->vm_start;
-               zap_vma_ptes(vma, vma->vm_start, size);
-               dev_dbg(scif_info.mdev.this_device,
-                       "%s ep %p zap vma %p size 0x%lx\n",
-                       __func__, ep, info->vma, size);
-       }
-       spin_unlock(&ep->lock);
-}
-
-/*
- * Traverse the list of endpoints for a particular remote node and
- * zap valid remote memory mappings since the remote node is lost
- */
-static void _scif_zap_mmaps(int node, struct list_head *head)
-{
-       struct scif_endpt *ep;
-       struct list_head *item;
-
-       mutex_lock(&scif_info.connlock);
-       list_for_each(item, head) {
-               ep = list_entry(item, struct scif_endpt, list);
-               if (ep->remote_dev->node == node)
-                       __scif_zap_mmaps(ep);
-       }
-       mutex_unlock(&scif_info.connlock);
-}
-
-/*
- * Wrapper for removing remote memory mappings for a particular node. This API
- * is called by peer nodes as part of handling a lost node.
- */
-void scif_zap_mmaps(int node)
-{
-       _scif_zap_mmaps(node, &scif_info.connected);
-       _scif_zap_mmaps(node, &scif_info.disconnected);
-}
-
-/*
- * This API is only called while handling a lost node:
- * a) Remote node is dead.
- * b) Remote memory mappings have been zapped
- * So we can traverse the remote_reg_list without any locks. Since
- * the window has not yet been unregistered we can drop the ref count
- * and queue it to the cleanup thread.
- */
-static void __scif_cleanup_rma_for_zombies(struct scif_endpt *ep)
-{
-       struct list_head *pos, *tmp;
-       struct scif_window *window;
-
-       list_for_each_safe(pos, tmp, &ep->rma_info.remote_reg_list) {
-               window = list_entry(pos, struct scif_window, list);
-               if (window->ref_count)
-                       scif_put_window(window, window->nr_pages);
-               else
-                       dev_err(scif_info.mdev.this_device,
-                               "%s %d unexpected\n",
-                               __func__, __LINE__);
-               if (!window->ref_count) {
-                       atomic_inc(&ep->rma_info.tw_refcount);
-                       list_del_init(&window->list);
-                       scif_queue_for_cleanup(window, &scif_info.rma);
-               }
-       }
-}
-
-/* Cleanup remote registration lists for zombie endpoints */
-void scif_cleanup_rma_for_zombies(int node)
-{
-       struct scif_endpt *ep;
-       struct list_head *item;
-
-       mutex_lock(&scif_info.eplock);
-       list_for_each(item, &scif_info.zombie) {
-               ep = list_entry(item, struct scif_endpt, list);
-               if (ep->remote_dev && ep->remote_dev->node == node)
-                       __scif_cleanup_rma_for_zombies(ep);
-       }
-       mutex_unlock(&scif_info.eplock);
-       flush_work(&scif_info.misc_work);
-}
-
-/* Insert the VMA into the per endpoint VMA list */
-static int scif_insert_vma(struct scif_endpt *ep, struct vm_area_struct *vma)
-{
-       struct scif_vma_info *info;
-       int err = 0;
-
-       info = kzalloc(sizeof(*info), GFP_KERNEL);
-       if (!info) {
-               err = -ENOMEM;
-               goto done;
-       }
-       info->vma = vma;
-       spin_lock(&ep->lock);
-       list_add_tail(&info->list, &ep->rma_info.vma_list);
-       spin_unlock(&ep->lock);
-done:
-       return err;
-}
-
-/* Delete the VMA from the per endpoint VMA list */
-static void scif_delete_vma(struct scif_endpt *ep, struct vm_area_struct *vma)
-{
-       struct list_head *item;
-       struct scif_vma_info *info;
-
-       spin_lock(&ep->lock);
-       list_for_each(item, &ep->rma_info.vma_list) {
-               info = list_entry(item, struct scif_vma_info, list);
-               if (info->vma == vma) {
-                       list_del(&info->list);
-                       kfree(info);
-                       break;
-               }
-       }
-       spin_unlock(&ep->lock);
-}
-
-static phys_addr_t scif_get_phys(phys_addr_t phys, struct scif_endpt *ep)
-{
-       struct scif_dev *scifdev = (struct scif_dev *)ep->remote_dev;
-       struct scif_hw_dev *sdev = scifdev->sdev;
-       phys_addr_t out_phys, apt_base = 0;
-
-       /*
-        * If the DMA address is card relative then we need to add the
-        * aperture base for mmap to work correctly
-        */
-       if (!scifdev_self(scifdev) && sdev->aper && sdev->card_rel_da)
-               apt_base = sdev->aper->pa;
-       out_phys = apt_base + phys;
-       return out_phys;
-}
-
-int scif_get_pages(scif_epd_t epd, off_t offset, size_t len,
-                  struct scif_range **pages)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scif_rma_req req;
-       struct scif_window *window = NULL;
-       int nr_pages, err, i;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI get_pinned_pages: ep %p offset 0x%lx len 0x%lx\n",
-               ep, offset, len);
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       if (!len || (offset < 0) ||
-           (offset + len < offset) ||
-           (ALIGN(offset, PAGE_SIZE) != offset) ||
-           (ALIGN(len, PAGE_SIZE) != len))
-               return -EINVAL;
-
-       nr_pages = len >> PAGE_SHIFT;
-
-       req.out_window = &window;
-       req.offset = offset;
-       req.prot = 0;
-       req.nr_bytes = len;
-       req.type = SCIF_WINDOW_SINGLE;
-       req.head = &ep->rma_info.remote_reg_list;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Does a valid window exist? */
-       err = scif_query_window(&req);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error;
-       }
-
-       /* Allocate scif_range */
-       *pages = kzalloc(sizeof(**pages), GFP_KERNEL);
-       if (!*pages) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       /* Allocate phys addr array */
-       (*pages)->phys_addr = scif_zalloc(nr_pages * sizeof(dma_addr_t));
-       if (!((*pages)->phys_addr)) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       if (scif_is_mgmt_node() && !scifdev_self(ep->remote_dev)) {
-               /* Allocate virtual address array */
-               ((*pages)->va = scif_zalloc(nr_pages * sizeof(void *)));
-               if (!(*pages)->va) {
-                       err = -ENOMEM;
-                       goto error;
-               }
-       }
-       /* Populate the values */
-       (*pages)->cookie = window;
-       (*pages)->nr_pages = nr_pages;
-       (*pages)->prot_flags = window->prot;
-
-       for (i = 0; i < nr_pages; i++) {
-               (*pages)->phys_addr[i] =
-                       __scif_off_to_dma_addr(window, offset +
-                                              (i * PAGE_SIZE));
-               (*pages)->phys_addr[i] = scif_get_phys((*pages)->phys_addr[i],
-                                                       ep);
-               if (scif_is_mgmt_node() && !scifdev_self(ep->remote_dev))
-                       (*pages)->va[i] =
-                               ep->remote_dev->sdev->aper->va +
-                               (*pages)->phys_addr[i] -
-                               ep->remote_dev->sdev->aper->pa;
-       }
-
-       scif_get_window(window, nr_pages);
-error:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (err) {
-               if (*pages) {
-                       scif_free((*pages)->phys_addr,
-                                 nr_pages * sizeof(dma_addr_t));
-                       scif_free((*pages)->va,
-                                 nr_pages * sizeof(void *));
-                       kfree(*pages);
-                       *pages = NULL;
-               }
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       }
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_get_pages);
-
-int scif_put_pages(struct scif_range *pages)
-{
-       struct scif_endpt *ep;
-       struct scif_window *window;
-       struct scifmsg msg;
-
-       if (!pages || !pages->cookie)
-               return -EINVAL;
-
-       window = pages->cookie;
-
-       if (!window || window->magic != SCIFEP_MAGIC)
-               return -EINVAL;
-
-       ep = (struct scif_endpt *)window->ep;
-       /*
-        * If the state is SCIFEP_CONNECTED or SCIFEP_DISCONNECTED then the
-        * callee should be allowed to release references to the pages,
-        * else the endpoint was not connected in the first place,
-        * hence the ENOTCONN.
-        */
-       if (ep->state != SCIFEP_CONNECTED && ep->state != SCIFEP_DISCONNECTED)
-               return -ENOTCONN;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-
-       scif_put_window(window, pages->nr_pages);
-
-       /* Initiate window destruction if ref count is zero */
-       if (!window->ref_count) {
-               list_del(&window->list);
-               mutex_unlock(&ep->rma_info.rma_lock);
-               scif_drain_dma_intr(ep->remote_dev->sdev,
-                                   ep->rma_info.dma_chan);
-               /* Inform the peer about this window being destroyed. */
-               msg.uop = SCIF_MUNMAP;
-               msg.src = ep->port;
-               msg.payload[0] = window->peer_window;
-               /* No error handling for notification messages */
-               scif_nodeqp_send(ep->remote_dev, &msg);
-               /* Destroy this window from the peer's registered AS */
-               scif_destroy_remote_window(window);
-       } else {
-               mutex_unlock(&ep->rma_info.rma_lock);
-       }
-
-       scif_free(pages->phys_addr, pages->nr_pages * sizeof(dma_addr_t));
-       scif_free(pages->va, pages->nr_pages * sizeof(void *));
-       kfree(pages);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(scif_put_pages);
-
-/*
- * scif_rma_list_mmap:
- *
- * Traverse the remote registration list starting from start_window:
- * 1) Create VtoP mappings via remap_pfn_range(..)
- * 2) Once step 1) and 2) complete successfully then traverse the range of
- *    windows again and bump the reference count.
- * RMA lock must be held.
- */
-static int scif_rma_list_mmap(struct scif_window *start_window, s64 offset,
-                             int nr_pages, struct vm_area_struct *vma)
-{
-       s64 end_offset, loop_offset = offset;
-       struct scif_window *window = start_window;
-       int loop_nr_pages, nr_pages_left = nr_pages;
-       struct scif_endpt *ep = (struct scif_endpt *)start_window->ep;
-       struct list_head *head = &ep->rma_info.remote_reg_list;
-       int i, err = 0;
-       dma_addr_t phys_addr;
-       struct scif_window_iter src_win_iter;
-       size_t contig_bytes = 0;
-
-       might_sleep();
-       list_for_each_entry_from(window, head, list) {
-               end_offset = window->offset +
-                       (window->nr_pages << PAGE_SHIFT);
-               loop_nr_pages = min_t(int,
-                                     (end_offset - loop_offset) >> PAGE_SHIFT,
-                                     nr_pages_left);
-               scif_init_window_iter(window, &src_win_iter);
-               for (i = 0; i < loop_nr_pages; i++) {
-                       phys_addr = scif_off_to_dma_addr(window, loop_offset,
-                                                        &contig_bytes,
-                                                        &src_win_iter);
-                       phys_addr = scif_get_phys(phys_addr, ep);
-                       err = remap_pfn_range(vma,
-                                             vma->vm_start +
-                                             loop_offset - offset,
-                                             phys_addr >> PAGE_SHIFT,
-                                             PAGE_SIZE,
-                                             vma->vm_page_prot);
-                       if (err)
-                               goto error;
-                       loop_offset += PAGE_SIZE;
-               }
-               nr_pages_left -= loop_nr_pages;
-               if (!nr_pages_left)
-                       break;
-       }
-       /*
-        * No more failures expected. Bump up the ref count for all
-        * the windows. Another traversal from start_window required
-        * for handling errors encountered across windows during
-        * remap_pfn_range(..).
-        */
-       loop_offset = offset;
-       nr_pages_left = nr_pages;
-       window = start_window;
-       head = &ep->rma_info.remote_reg_list;
-       list_for_each_entry_from(window, head, list) {
-               end_offset = window->offset +
-                       (window->nr_pages << PAGE_SHIFT);
-               loop_nr_pages = min_t(int,
-                                     (end_offset - loop_offset) >> PAGE_SHIFT,
-                                     nr_pages_left);
-               scif_get_window(window, loop_nr_pages);
-               nr_pages_left -= loop_nr_pages;
-               loop_offset += (loop_nr_pages << PAGE_SHIFT);
-               if (!nr_pages_left)
-                       break;
-       }
-error:
-       if (err)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       return err;
-}
-
-/*
- * scif_rma_list_munmap:
- *
- * Traverse the remote registration list starting from window:
- * 1) Decrement ref count.
- * 2) If the ref count drops to zero then send a SCIF_MUNMAP message to peer.
- * RMA lock must be held.
- */
-static void scif_rma_list_munmap(struct scif_window *start_window,
-                                s64 offset, int nr_pages)
-{
-       struct scifmsg msg;
-       s64 loop_offset = offset, end_offset;
-       int loop_nr_pages, nr_pages_left = nr_pages;
-       struct scif_endpt *ep = (struct scif_endpt *)start_window->ep;
-       struct list_head *head = &ep->rma_info.remote_reg_list;
-       struct scif_window *window = start_window, *_window;
-
-       msg.uop = SCIF_MUNMAP;
-       msg.src = ep->port;
-       loop_offset = offset;
-       nr_pages_left = nr_pages;
-       list_for_each_entry_safe_from(window, _window, head, list) {
-               end_offset = window->offset +
-                       (window->nr_pages << PAGE_SHIFT);
-               loop_nr_pages = min_t(int,
-                                     (end_offset - loop_offset) >> PAGE_SHIFT,
-                                     nr_pages_left);
-               scif_put_window(window, loop_nr_pages);
-               if (!window->ref_count) {
-                       struct scif_dev *rdev = ep->remote_dev;
-
-                       scif_drain_dma_intr(rdev->sdev,
-                                           ep->rma_info.dma_chan);
-                       /* Inform the peer about this munmap */
-                       msg.payload[0] = window->peer_window;
-                       /* No error handling for Notification messages. */
-                       scif_nodeqp_send(ep->remote_dev, &msg);
-                       list_del(&window->list);
-                       /* Destroy this window from the peer's registered AS */
-                       scif_destroy_remote_window(window);
-               }
-               nr_pages_left -= loop_nr_pages;
-               loop_offset += (loop_nr_pages << PAGE_SHIFT);
-               if (!nr_pages_left)
-                       break;
-       }
-}
-
-/*
- * The private data field of each VMA used to mmap a remote window
- * points to an instance of struct vma_pvt
- */
-struct vma_pvt {
-       struct scif_endpt *ep;  /* End point for remote window */
-       s64 offset;             /* offset within remote window */
-       bool valid_offset;      /* offset is valid only if the original
-                                * mmap request was for a single page
-                                * else the offset within the vma is
-                                * the correct offset
-                                */
-       struct kref ref;
-};
-
-static void vma_pvt_release(struct kref *ref)
-{
-       struct vma_pvt *vmapvt = container_of(ref, struct vma_pvt, ref);
-
-       kfree(vmapvt);
-}
-
-/**
- * scif_vma_open - VMA open driver callback
- * @vma: VMM memory area.
- * The open method is called by the kernel to allow the subsystem implementing
- * the VMA to initialize the area. This method is invoked any time a new
- * reference to the VMA is made (when a process forks, for example).
- * The one exception happens when the VMA is first created by mmap;
- * in this case, the driver's mmap method is called instead.
- * This function is also invoked when an existing VMA is split by the kernel
- * due to a call to munmap on a subset of the VMA resulting in two VMAs.
- * The kernel invokes this function only on one of the two VMAs.
- */
-static void scif_vma_open(struct vm_area_struct *vma)
-{
-       struct vma_pvt *vmapvt = vma->vm_private_data;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI vma open: vma_start 0x%lx vma_end 0x%lx\n",
-               vma->vm_start, vma->vm_end);
-       scif_insert_vma(vmapvt->ep, vma);
-       kref_get(&vmapvt->ref);
-}
-
-/**
- * scif_munmap - VMA close driver callback.
- * @vma: VMM memory area.
- * When an area is destroyed, the kernel calls its close operation.
- * Note that there's no usage count associated with VMA's; the area
- * is opened and closed exactly once by each process that uses it.
- */
-static void scif_munmap(struct vm_area_struct *vma)
-{
-       struct scif_endpt *ep;
-       struct vma_pvt *vmapvt = vma->vm_private_data;
-       int nr_pages = vma_pages(vma);
-       s64 offset;
-       struct scif_rma_req req;
-       struct scif_window *window = NULL;
-       int err;
-
-       might_sleep();
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI munmap: vma_start 0x%lx vma_end 0x%lx\n",
-               vma->vm_start, vma->vm_end);
-       ep = vmapvt->ep;
-       offset = vmapvt->valid_offset ? vmapvt->offset :
-               (vma->vm_pgoff) << PAGE_SHIFT;
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI munmap: ep %p nr_pages 0x%x offset 0x%llx\n",
-               ep, nr_pages, offset);
-       req.out_window = &window;
-       req.offset = offset;
-       req.nr_bytes = vma->vm_end - vma->vm_start;
-       req.prot = vma->vm_flags & (VM_READ | VM_WRITE);
-       req.type = SCIF_WINDOW_PARTIAL;
-       req.head = &ep->rma_info.remote_reg_list;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-
-       err = scif_query_window(&req);
-       if (err)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-       else
-               scif_rma_list_munmap(window, offset, nr_pages);
-
-       mutex_unlock(&ep->rma_info.rma_lock);
-       /*
-        * The kernel probably zeroes these out but we still want
-        * to clean up our own mess just in case.
-        */
-       vma->vm_ops = NULL;
-       vma->vm_private_data = NULL;
-       kref_put(&vmapvt->ref, vma_pvt_release);
-       scif_delete_vma(ep, vma);
-}
-
-static const struct vm_operations_struct scif_vm_ops = {
-       .open = scif_vma_open,
-       .close = scif_munmap,
-};
-
-/**
- * scif_mmap - Map pages in virtual address space to a remote window.
- * @vma: VMM memory area.
- * @epd: endpoint descriptor
- *
- * Return: Upon successful completion, scif_mmap() returns zero
- * else an apt error is returned as documented in scif.h
- */
-int scif_mmap(struct vm_area_struct *vma, scif_epd_t epd)
-{
-       struct scif_rma_req req;
-       struct scif_window *window = NULL;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       s64 start_offset = vma->vm_pgoff << PAGE_SHIFT;
-       int nr_pages = vma_pages(vma);
-       int err;
-       struct vma_pvt *vmapvt;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI mmap: ep %p start_offset 0x%llx nr_pages 0x%x\n",
-               ep, start_offset, nr_pages);
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       might_sleep();
-
-       err = scif_insert_vma(ep, vma);
-       if (err)
-               return err;
-
-       vmapvt = kzalloc(sizeof(*vmapvt), GFP_KERNEL);
-       if (!vmapvt) {
-               scif_delete_vma(ep, vma);
-               return -ENOMEM;
-       }
-
-       vmapvt->ep = ep;
-       kref_init(&vmapvt->ref);
-
-       req.out_window = &window;
-       req.offset = start_offset;
-       req.nr_bytes = vma->vm_end - vma->vm_start;
-       req.prot = vma->vm_flags & (VM_READ | VM_WRITE);
-       req.type = SCIF_WINDOW_PARTIAL;
-       req.head = &ep->rma_info.remote_reg_list;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Does a valid window exist? */
-       err = scif_query_window(&req);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error_unlock;
-       }
-
-       /* Default prot for loopback */
-       if (!scifdev_self(ep->remote_dev))
-               vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-
-       /*
-        * VM_DONTCOPY - Do not copy this vma on fork
-        * VM_DONTEXPAND - Cannot expand with mremap()
-        * VM_RESERVED - Count as reserved_vm like IO
-        * VM_PFNMAP - Page-ranges managed without "struct page"
-        * VM_IO - Memory mapped I/O or similar
-        *
-        * We do not want to copy this VMA automatically on a fork(),
-        * expand this VMA due to mremap() or swap out these pages since
-        * the VMA is actually backed by physical pages in the remote
-        * node's physical memory and not via a struct page.
-        */
-       vma->vm_flags |= VM_DONTCOPY | VM_DONTEXPAND | VM_DONTDUMP;
-
-       if (!scifdev_self(ep->remote_dev))
-               vma->vm_flags |= VM_IO | VM_PFNMAP;
-
-       /* Map this range of windows */
-       err = scif_rma_list_mmap(window, start_offset, nr_pages, vma);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error_unlock;
-       }
-       /* Set up the driver call back */
-       vma->vm_ops = &scif_vm_ops;
-       vma->vm_private_data = vmapvt;
-error_unlock:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (err) {
-               kfree(vmapvt);
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               scif_delete_vma(ep, vma);
-       }
-       return err;
-}
diff --git a/drivers/misc/mic/scif/scif_nm.c b/drivers/misc/mic/scif/scif_nm.c
deleted file mode 100644 (file)
index c4d9422..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_peer_bus.h"
-
-#include "scif_main.h"
-#include "scif_map.h"
-
-/**
- * scif_invalidate_ep() - Set state for all connected endpoints
- * to disconnected and wake up all send/recv waitqueues
- *
- * @node: Node to invalidate
- */
-static void scif_invalidate_ep(int node)
-{
-       struct scif_endpt *ep;
-       struct list_head *pos, *tmpq;
-
-       flush_work(&scif_info.conn_work);
-       mutex_lock(&scif_info.connlock);
-       list_for_each_safe(pos, tmpq, &scif_info.disconnected) {
-               ep = list_entry(pos, struct scif_endpt, list);
-               if (ep->remote_dev->node == node) {
-                       scif_unmap_all_windows(ep);
-                       spin_lock(&ep->lock);
-                       scif_cleanup_ep_qp(ep);
-                       spin_unlock(&ep->lock);
-               }
-       }
-       list_for_each_safe(pos, tmpq, &scif_info.connected) {
-               ep = list_entry(pos, struct scif_endpt, list);
-               if (ep->remote_dev->node == node) {
-                       list_del(pos);
-                       spin_lock(&ep->lock);
-                       ep->state = SCIFEP_DISCONNECTED;
-                       list_add_tail(&ep->list, &scif_info.disconnected);
-                       scif_cleanup_ep_qp(ep);
-                       wake_up_interruptible(&ep->sendwq);
-                       wake_up_interruptible(&ep->recvwq);
-                       spin_unlock(&ep->lock);
-                       scif_unmap_all_windows(ep);
-               }
-       }
-       mutex_unlock(&scif_info.connlock);
-}
-
-void scif_free_qp(struct scif_dev *scifdev)
-{
-       struct scif_qp *qp = scifdev->qpairs;
-
-       if (!qp)
-               return;
-       scif_unmap_single(qp->local_buf, scifdev, qp->inbound_q.size);
-       kfree(qp->inbound_q.rb_base);
-       scif_unmap_single(qp->local_qp, scifdev, sizeof(struct scif_qp));
-       kfree(scifdev->qpairs);
-       scifdev->qpairs = NULL;
-}
-
-static void scif_cleanup_qp(struct scif_dev *dev)
-{
-       struct scif_qp *qp = &dev->qpairs[0];
-
-       if (!qp)
-               return;
-       scif_iounmap((void *)qp->remote_qp, sizeof(struct scif_qp), dev);
-       scif_iounmap((void *)qp->outbound_q.rb_base,
-                    sizeof(struct scif_qp), dev);
-       qp->remote_qp = NULL;
-       qp->local_write = 0;
-       qp->inbound_q.current_write_offset = 0;
-       qp->inbound_q.current_read_offset = 0;
-       if (scifdev_is_p2p(dev))
-               scif_free_qp(dev);
-}
-
-void scif_send_acks(struct scif_dev *dev)
-{
-       struct scifmsg msg;
-
-       if (dev->node_remove_ack_pending) {
-               msg.uop = SCIF_NODE_REMOVE_ACK;
-               msg.src.node = scif_info.nodeid;
-               msg.dst.node = SCIF_MGMT_NODE;
-               msg.payload[0] = dev->node;
-               scif_nodeqp_send(&scif_dev[SCIF_MGMT_NODE], &msg);
-               dev->node_remove_ack_pending = false;
-       }
-       if (dev->exit_ack_pending) {
-               msg.uop = SCIF_EXIT_ACK;
-               msg.src.node = scif_info.nodeid;
-               msg.dst.node = dev->node;
-               scif_nodeqp_send(dev, &msg);
-               dev->exit_ack_pending = false;
-       }
-}
-
-/**
- * scif_cleanup_scifdev - Uninitialize SCIF data structures for remote
- *                        SCIF device.
- * @dev: Remote SCIF device.
- */
-void scif_cleanup_scifdev(struct scif_dev *dev)
-{
-       struct scif_hw_dev *sdev = dev->sdev;
-
-       if (!dev->sdev)
-               return;
-       if (scifdev_is_p2p(dev)) {
-               if (dev->cookie) {
-                       sdev->hw_ops->free_irq(sdev, dev->cookie, dev);
-                       dev->cookie = NULL;
-               }
-               scif_destroy_intr_wq(dev);
-       }
-       flush_work(&scif_info.misc_work);
-       scif_destroy_p2p(dev);
-       scif_invalidate_ep(dev->node);
-       scif_zap_mmaps(dev->node);
-       scif_cleanup_rma_for_zombies(dev->node);
-       flush_work(&scif_info.misc_work);
-       scif_send_acks(dev);
-       if (!dev->node && scif_info.card_initiated_exit) {
-               /*
-                * Send an SCIF_EXIT message which is the last message from MIC
-                * to the Host and wait for a SCIF_EXIT_ACK
-                */
-               scif_send_exit(dev);
-               scif_info.card_initiated_exit = false;
-       }
-       scif_cleanup_qp(dev);
-}
-
-/**
- * scif_remove_node
- *
- * @node: Node to remove
- */
-void scif_handle_remove_node(int node)
-{
-       struct scif_dev *scifdev = &scif_dev[node];
-
-       if (scif_peer_unregister_device(scifdev))
-               scif_send_acks(scifdev);
-}
-
-static int scif_send_rmnode_msg(int node, int remove_node)
-{
-       struct scifmsg notif_msg;
-       struct scif_dev *dev = &scif_dev[node];
-
-       notif_msg.uop = SCIF_NODE_REMOVE;
-       notif_msg.src.node = scif_info.nodeid;
-       notif_msg.dst.node = node;
-       notif_msg.payload[0] = remove_node;
-       return scif_nodeqp_send(dev, &notif_msg);
-}
-
-/**
- * scif_node_disconnect
- *
- * @node_id: source node id [in]
- * @mgmt_initiated: Disconnection initiated from the mgmt node
- *
- * Disconnect a node from the scif network.
- */
-void scif_disconnect_node(u32 node_id, bool mgmt_initiated)
-{
-       int ret;
-       int msg_cnt = 0;
-       u32 i = 0;
-       struct scif_dev *scifdev = &scif_dev[node_id];
-
-       if (!node_id)
-               return;
-
-       atomic_set(&scifdev->disconn_rescnt, 0);
-
-       /* Destroy p2p network */
-       for (i = 1; i <= scif_info.maxid; i++) {
-               if (i == node_id)
-                       continue;
-               ret = scif_send_rmnode_msg(i, node_id);
-               if (!ret)
-                       msg_cnt++;
-       }
-       /* Wait for the remote nodes to respond with SCIF_NODE_REMOVE_ACK */
-       ret = wait_event_timeout(scifdev->disconn_wq,
-                                (atomic_read(&scifdev->disconn_rescnt)
-                                == msg_cnt), SCIF_NODE_ALIVE_TIMEOUT);
-       /* Tell the card to clean up */
-       if (mgmt_initiated && _scifdev_alive(scifdev))
-               /*
-                * Send an SCIF_EXIT message which is the last message from Host
-                * to the MIC and wait for a SCIF_EXIT_ACK
-                */
-               scif_send_exit(scifdev);
-       atomic_set(&scifdev->disconn_rescnt, 0);
-       /* Tell the mgmt node to clean up */
-       ret = scif_send_rmnode_msg(SCIF_MGMT_NODE, node_id);
-       if (!ret)
-               /* Wait for mgmt node to respond with SCIF_NODE_REMOVE_ACK */
-               wait_event_timeout(scifdev->disconn_wq,
-                                  (atomic_read(&scifdev->disconn_rescnt) == 1),
-                                  SCIF_NODE_ALIVE_TIMEOUT);
-}
-
-void scif_get_node_info(void)
-{
-       struct scifmsg msg;
-       DECLARE_COMPLETION_ONSTACK(node_info);
-
-       msg.uop = SCIF_GET_NODE_INFO;
-       msg.src.node = scif_info.nodeid;
-       msg.dst.node = SCIF_MGMT_NODE;
-       msg.payload[3] = (u64)&node_info;
-
-       if ((scif_nodeqp_send(&scif_dev[SCIF_MGMT_NODE], &msg)))
-               return;
-
-       /* Wait for a response with SCIF_GET_NODE_INFO */
-       wait_for_completion(&node_info);
-}
diff --git a/drivers/misc/mic/scif/scif_nodeqp.c b/drivers/misc/mic/scif/scif_nodeqp.c
deleted file mode 100644 (file)
index 384ce08..0000000
+++ /dev/null
@@ -1,1349 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "../bus/scif_bus.h"
-#include "scif_peer_bus.h"
-#include "scif_main.h"
-#include "scif_nodeqp.h"
-#include "scif_map.h"
-
-/*
- ************************************************************************
- * SCIF node Queue Pair (QP) setup flow:
- *
- * 1) SCIF driver gets probed with a scif_hw_dev via the scif_hw_bus
- * 2) scif_setup_qp(..) allocates the local qp and calls
- *     scif_setup_qp_connect(..) which allocates and maps the local
- *     buffer for the inbound QP
- * 3) The local node updates the device page with the DMA address of the QP
- * 4) A delayed work is scheduled (qp_dwork) which periodically reads if
- *     the peer node has updated its QP DMA address
- * 5) Once a valid non zero address is found in the QP DMA address field
- *     in the device page, the local node maps the remote node's QP,
- *     updates its outbound QP and sends a SCIF_INIT message to the peer
- * 6) The SCIF_INIT message is received by the peer node QP interrupt bottom
- *     half handler by calling scif_init(..)
- * 7) scif_init(..) registers a new SCIF peer node by calling
- *     scif_peer_register_device(..) which signifies the addition of a new
- *     SCIF node
- * 8) On the mgmt node, P2P network setup/teardown is initiated if all the
- *     remote nodes are online via scif_p2p_setup(..)
- * 9) For P2P setup, the host maps the remote nodes' aperture and memory
- *     bars and sends a SCIF_NODE_ADD message to both nodes
- * 10) As part of scif_nodeadd, both nodes set up their local inbound
- *     QPs and send a SCIF_NODE_ADD_ACK to the mgmt node
- * 11) As part of scif_node_add_ack(..) the mgmt node forwards the
- *     SCIF_NODE_ADD_ACK to the remote nodes
- * 12) As part of scif_node_add_ack(..) the remote nodes update their
- *     outbound QPs, make sure they can access memory on the remote node
- *     and then add a new SCIF peer node by calling
- *     scif_peer_register_device(..) which signifies the addition of a new
- *     SCIF node.
- * 13) The SCIF network is now established across all nodes.
- *
- ************************************************************************
- * SCIF node QP teardown flow (initiated by non mgmt node):
- *
- * 1) SCIF driver gets a remove callback with a scif_hw_dev via the scif_hw_bus
- * 2) The device page QP DMA address field is updated with 0x0
- * 3) A non mgmt node now cleans up all local data structures and sends a
- *     SCIF_EXIT message to the peer and waits for a SCIF_EXIT_ACK
- * 4) As part of scif_exit(..) handling scif_disconnect_node(..) is called
- * 5) scif_disconnect_node(..) sends a SCIF_NODE_REMOVE message to all the
- *     peers and waits for a SCIF_NODE_REMOVE_ACK
- * 6) As part of scif_node_remove(..) a remote node unregisters the peer
- *     node from the SCIF network and sends a SCIF_NODE_REMOVE_ACK
- * 7) When the mgmt node has received all the SCIF_NODE_REMOVE_ACKs
- *     it sends itself a node remove message whose handling cleans up local
- *     data structures and unregisters the peer node from the SCIF network
- * 8) The mgmt node sends a SCIF_EXIT_ACK
- * 9) Upon receipt of the SCIF_EXIT_ACK the node initiating the teardown
- *     completes the SCIF remove routine
- * 10) The SCIF network is now torn down for the node initiating the
- *     teardown sequence
- *
- ************************************************************************
- * SCIF node QP teardown flow (initiated by mgmt node):
- *
- * 1) SCIF driver gets a remove callback with a scif_hw_dev via the scif_hw_bus
- * 2) The device page QP DMA address field is updated with 0x0
- * 3) The mgmt node calls scif_disconnect_node(..)
- * 4) scif_disconnect_node(..) sends a SCIF_NODE_REMOVE message to all the peers
- *     and waits for a SCIF_NODE_REMOVE_ACK
- * 5) As part of scif_node_remove(..) a remote node unregisters the peer
- *     node from the SCIF network and sends a SCIF_NODE_REMOVE_ACK
- * 6) When the mgmt node has received all the SCIF_NODE_REMOVE_ACKs
- *     it unregisters the peer node from the SCIF network
- * 7) The mgmt node sends a SCIF_EXIT message and waits for a SCIF_EXIT_ACK.
- * 8) A non mgmt node upon receipt of a SCIF_EXIT message calls scif_stop(..)
- *     which would clean up local data structures for all SCIF nodes and
- *     then send a SCIF_EXIT_ACK back to the mgmt node
- * 9) Upon receipt of the SCIF_EXIT_ACK the the mgmt node sends itself a node
- *     remove message whose handling cleans up local data structures and
- *     destroys any P2P mappings.
- * 10) The SCIF hardware device for which a remove callback was received is now
- *     disconnected from the SCIF network.
- */
-/*
- * Initializes "local" data structures for the QP. Allocates the QP
- * ring buffer (rb) and initializes the "in bound" queue.
- */
-int scif_setup_qp_connect(struct scif_qp *qp, dma_addr_t *qp_offset,
-                         int local_size, struct scif_dev *scifdev)
-{
-       void *local_q = qp->inbound_q.rb_base;
-       int err = 0;
-       u32 tmp_rd = 0;
-
-       spin_lock_init(&qp->send_lock);
-       spin_lock_init(&qp->recv_lock);
-
-       /* Allocate rb only if not already allocated */
-       if (!local_q) {
-               local_q = kzalloc(local_size, GFP_KERNEL);
-               if (!local_q) {
-                       err = -ENOMEM;
-                       return err;
-               }
-       }
-
-       err = scif_map_single(&qp->local_buf, local_q, scifdev, local_size);
-       if (err)
-               goto kfree;
-       /*
-        * To setup the inbound_q, the buffer lives locally, the read pointer
-        * is remote and the write pointer is local.
-        */
-       scif_rb_init(&qp->inbound_q,
-                    &tmp_rd,
-                    &qp->local_write,
-                    local_q, get_count_order(local_size));
-       /*
-        * The read pointer is NULL initially and it is unsafe to use the ring
-        * buffer til this changes!
-        */
-       qp->inbound_q.read_ptr = NULL;
-       err = scif_map_single(qp_offset, qp,
-                             scifdev, sizeof(struct scif_qp));
-       if (err)
-               goto unmap;
-       qp->local_qp = *qp_offset;
-       return err;
-unmap:
-       scif_unmap_single(qp->local_buf, scifdev, local_size);
-       qp->local_buf = 0;
-kfree:
-       kfree(local_q);
-       return err;
-}
-
-/* When the other side has already done it's allocation, this is called */
-int scif_setup_qp_accept(struct scif_qp *qp, dma_addr_t *qp_offset,
-                        dma_addr_t phys, int local_size,
-                        struct scif_dev *scifdev)
-{
-       void *local_q;
-       void *remote_q;
-       struct scif_qp *remote_qp;
-       int remote_size;
-       int err = 0;
-
-       spin_lock_init(&qp->send_lock);
-       spin_lock_init(&qp->recv_lock);
-       /* Start by figuring out where we need to point */
-       remote_qp = scif_ioremap(phys, sizeof(struct scif_qp), scifdev);
-       if (!remote_qp)
-               return -EIO;
-       qp->remote_qp = remote_qp;
-       if (qp->remote_qp->magic != SCIFEP_MAGIC) {
-               err = -EIO;
-               goto iounmap;
-       }
-       qp->remote_buf = remote_qp->local_buf;
-       remote_size = qp->remote_qp->inbound_q.size;
-       remote_q = scif_ioremap(qp->remote_buf, remote_size, scifdev);
-       if (!remote_q) {
-               err = -EIO;
-               goto iounmap;
-       }
-       qp->remote_qp->local_write = 0;
-       /*
-        * To setup the outbound_q, the buffer lives in remote memory,
-        * the read pointer is local, the write pointer is remote
-        */
-       scif_rb_init(&qp->outbound_q,
-                    &qp->local_read,
-                    &qp->remote_qp->local_write,
-                    remote_q,
-                    get_count_order(remote_size));
-       local_q = kzalloc(local_size, GFP_KERNEL);
-       if (!local_q) {
-               err = -ENOMEM;
-               goto iounmap_1;
-       }
-       err = scif_map_single(&qp->local_buf, local_q, scifdev, local_size);
-       if (err)
-               goto kfree;
-       qp->remote_qp->local_read = 0;
-       /*
-        * To setup the inbound_q, the buffer lives locally, the read pointer
-        * is remote and the write pointer is local
-        */
-       scif_rb_init(&qp->inbound_q,
-                    &qp->remote_qp->local_read,
-                    &qp->local_write,
-                    local_q, get_count_order(local_size));
-       err = scif_map_single(qp_offset, qp, scifdev,
-                             sizeof(struct scif_qp));
-       if (err)
-               goto unmap;
-       qp->local_qp = *qp_offset;
-       return err;
-unmap:
-       scif_unmap_single(qp->local_buf, scifdev, local_size);
-       qp->local_buf = 0;
-kfree:
-       kfree(local_q);
-iounmap_1:
-       scif_iounmap(remote_q, remote_size, scifdev);
-       qp->outbound_q.rb_base = NULL;
-iounmap:
-       scif_iounmap(qp->remote_qp, sizeof(struct scif_qp), scifdev);
-       qp->remote_qp = NULL;
-       return err;
-}
-
-int scif_setup_qp_connect_response(struct scif_dev *scifdev,
-                                  struct scif_qp *qp, u64 payload)
-{
-       int err = 0;
-       void *r_buf;
-       int remote_size;
-       phys_addr_t tmp_phys;
-
-       qp->remote_qp = scif_ioremap(payload, sizeof(struct scif_qp), scifdev);
-
-       if (!qp->remote_qp) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       if (qp->remote_qp->magic != SCIFEP_MAGIC) {
-               dev_err(&scifdev->sdev->dev,
-                       "SCIFEP_MAGIC mismatch between self %d remote %d\n",
-                       scif_dev[scif_info.nodeid].node, scifdev->node);
-               err = -ENODEV;
-               goto error;
-       }
-
-       tmp_phys = qp->remote_qp->local_buf;
-       remote_size = qp->remote_qp->inbound_q.size;
-       r_buf = scif_ioremap(tmp_phys, remote_size, scifdev);
-
-       if (!r_buf)
-               return -EIO;
-
-       qp->local_read = 0;
-       scif_rb_init(&qp->outbound_q,
-                    &qp->local_read,
-                    &qp->remote_qp->local_write,
-                    r_buf,
-                    get_count_order(remote_size));
-       /*
-        * Because the node QP may already be processing an INIT message, set
-        * the read pointer so the cached read offset isn't lost
-        */
-       qp->remote_qp->local_read = qp->inbound_q.current_read_offset;
-       /*
-        * resetup the inbound_q now that we know where the
-        * inbound_read really is.
-        */
-       scif_rb_init(&qp->inbound_q,
-                    &qp->remote_qp->local_read,
-                    &qp->local_write,
-                    qp->inbound_q.rb_base,
-                    get_count_order(qp->inbound_q.size));
-error:
-       return err;
-}
-
-static __always_inline void
-scif_send_msg_intr(struct scif_dev *scifdev)
-{
-       struct scif_hw_dev *sdev = scifdev->sdev;
-
-       if (scifdev_is_p2p(scifdev))
-               sdev->hw_ops->send_p2p_intr(sdev, scifdev->rdb, &scifdev->mmio);
-       else
-               sdev->hw_ops->send_intr(sdev, scifdev->rdb);
-}
-
-int scif_qp_response(phys_addr_t phys, struct scif_dev *scifdev)
-{
-       int err = 0;
-       struct scifmsg msg;
-
-       err = scif_setup_qp_connect_response(scifdev, scifdev->qpairs, phys);
-       if (!err) {
-               /*
-                * Now that everything is setup and mapped, we're ready
-                * to tell the peer about our queue's location
-                */
-               msg.uop = SCIF_INIT;
-               msg.dst.node = scifdev->node;
-               err = scif_nodeqp_send(scifdev, &msg);
-       }
-       return err;
-}
-
-void scif_send_exit(struct scif_dev *scifdev)
-{
-       struct scifmsg msg;
-       int ret;
-
-       scifdev->exit = OP_IN_PROGRESS;
-       msg.uop = SCIF_EXIT;
-       msg.src.node = scif_info.nodeid;
-       msg.dst.node = scifdev->node;
-       ret = scif_nodeqp_send(scifdev, &msg);
-       if (ret)
-               goto done;
-       /* Wait for a SCIF_EXIT_ACK message */
-       wait_event_timeout(scif_info.exitwq, scifdev->exit == OP_COMPLETED,
-                          SCIF_NODE_ALIVE_TIMEOUT);
-done:
-       scifdev->exit = OP_IDLE;
-}
-
-int scif_setup_qp(struct scif_dev *scifdev)
-{
-       int err = 0;
-       int local_size;
-       struct scif_qp *qp;
-
-       local_size = SCIF_NODE_QP_SIZE;
-
-       qp = kzalloc(sizeof(*qp), GFP_KERNEL);
-       if (!qp) {
-               err = -ENOMEM;
-               return err;
-       }
-       qp->magic = SCIFEP_MAGIC;
-       scifdev->qpairs = qp;
-       err = scif_setup_qp_connect(qp, &scifdev->qp_dma_addr,
-                                   local_size, scifdev);
-       if (err)
-               goto free_qp;
-       /*
-        * We're as setup as we can be. The inbound_q is setup, w/o a usable
-        * outbound q.  When we get a message, the read_ptr will be updated,
-        * and we will pull the message.
-        */
-       return err;
-free_qp:
-       kfree(scifdev->qpairs);
-       scifdev->qpairs = NULL;
-       return err;
-}
-
-static void scif_p2p_freesg(struct scatterlist *sg)
-{
-       kfree(sg);
-}
-
-static struct scatterlist *
-scif_p2p_setsg(phys_addr_t pa, int page_size, int page_cnt)
-{
-       struct scatterlist *sg;
-       struct page *page;
-       int i;
-
-       sg = kmalloc_array(page_cnt, sizeof(struct scatterlist), GFP_KERNEL);
-       if (!sg)
-               return NULL;
-       sg_init_table(sg, page_cnt);
-       for (i = 0; i < page_cnt; i++) {
-               page = pfn_to_page(pa >> PAGE_SHIFT);
-               sg_set_page(&sg[i], page, page_size, 0);
-               pa += page_size;
-       }
-       return sg;
-}
-
-/* Init p2p mappings required to access peerdev from scifdev */
-static struct scif_p2p_info *
-scif_init_p2p_info(struct scif_dev *scifdev, struct scif_dev *peerdev)
-{
-       struct scif_p2p_info *p2p;
-       int num_mmio_pages, num_aper_pages, sg_page_shift, err, num_aper_chunks;
-       struct scif_hw_dev *psdev = peerdev->sdev;
-       struct scif_hw_dev *sdev = scifdev->sdev;
-
-       num_mmio_pages = psdev->mmio->len >> PAGE_SHIFT;
-       num_aper_pages = psdev->aper->len >> PAGE_SHIFT;
-
-       p2p = kzalloc(sizeof(*p2p), GFP_KERNEL);
-       if (!p2p)
-               return NULL;
-       p2p->ppi_sg[SCIF_PPI_MMIO] = scif_p2p_setsg(psdev->mmio->pa,
-                                                   PAGE_SIZE, num_mmio_pages);
-       if (!p2p->ppi_sg[SCIF_PPI_MMIO])
-               goto free_p2p;
-       p2p->sg_nentries[SCIF_PPI_MMIO] = num_mmio_pages;
-       sg_page_shift = get_order(min(psdev->aper->len, (u64)(1 << 30)));
-       num_aper_chunks = num_aper_pages >> (sg_page_shift - PAGE_SHIFT);
-       p2p->ppi_sg[SCIF_PPI_APER] = scif_p2p_setsg(psdev->aper->pa,
-                                                   1 << sg_page_shift,
-                                                   num_aper_chunks);
-       p2p->sg_nentries[SCIF_PPI_APER] = num_aper_chunks;
-       err = dma_map_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_MMIO],
-                        num_mmio_pages, PCI_DMA_BIDIRECTIONAL);
-       if (err != num_mmio_pages)
-               goto scif_p2p_free;
-       err = dma_map_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_APER],
-                        num_aper_chunks, PCI_DMA_BIDIRECTIONAL);
-       if (err != num_aper_chunks)
-               goto dma_unmap;
-       p2p->ppi_da[SCIF_PPI_MMIO] = sg_dma_address(p2p->ppi_sg[SCIF_PPI_MMIO]);
-       p2p->ppi_da[SCIF_PPI_APER] = sg_dma_address(p2p->ppi_sg[SCIF_PPI_APER]);
-       p2p->ppi_len[SCIF_PPI_MMIO] = num_mmio_pages;
-       p2p->ppi_len[SCIF_PPI_APER] = num_aper_pages;
-       p2p->ppi_peer_id = peerdev->node;
-       return p2p;
-dma_unmap:
-       dma_unmap_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_MMIO],
-                    p2p->sg_nentries[SCIF_PPI_MMIO], DMA_BIDIRECTIONAL);
-scif_p2p_free:
-       scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_MMIO]);
-       scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_APER]);
-free_p2p:
-       kfree(p2p);
-       return NULL;
-}
-
-/* Uninitialize and release resources from a p2p mapping */
-static void scif_deinit_p2p_info(struct scif_dev *scifdev,
-                                struct scif_p2p_info *p2p)
-{
-       struct scif_hw_dev *sdev = scifdev->sdev;
-
-       dma_unmap_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_MMIO],
-                    p2p->sg_nentries[SCIF_PPI_MMIO], DMA_BIDIRECTIONAL);
-       dma_unmap_sg(&sdev->dev, p2p->ppi_sg[SCIF_PPI_APER],
-                    p2p->sg_nentries[SCIF_PPI_APER], DMA_BIDIRECTIONAL);
-       scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_MMIO]);
-       scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_APER]);
-       kfree(p2p);
-}
-
-/**
- * scif_node_connect: Respond to SCIF_NODE_CONNECT interrupt message
- * @scifdev: SCIF device
- * @dst: Destination node
- *
- * Connect the src and dst node by setting up the p2p connection
- * between them. Management node here acts like a proxy.
- */
-static void scif_node_connect(struct scif_dev *scifdev, int dst)
-{
-       struct scif_dev *dev_j = scifdev;
-       struct scif_dev *dev_i = NULL;
-       struct scif_p2p_info *p2p_ij = NULL;    /* bus addr for j from i */
-       struct scif_p2p_info *p2p_ji = NULL;    /* bus addr for i from j */
-       struct scif_p2p_info *p2p;
-       struct list_head *pos, *tmp;
-       struct scifmsg msg;
-       int err;
-       u64 tmppayload;
-
-       if (dst < 1 || dst > scif_info.maxid)
-               return;
-
-       dev_i = &scif_dev[dst];
-
-       if (!_scifdev_alive(dev_i))
-               return;
-       /*
-        * If the p2p connection is already setup or in the process of setting
-        * up then just ignore this request. The requested node will get
-        * informed by SCIF_NODE_ADD_ACK or SCIF_NODE_ADD_NACK
-        */
-       if (!list_empty(&dev_i->p2p)) {
-               list_for_each_safe(pos, tmp, &dev_i->p2p) {
-                       p2p = list_entry(pos, struct scif_p2p_info, ppi_list);
-                       if (p2p->ppi_peer_id == dev_j->node)
-                               return;
-               }
-       }
-       p2p_ij = scif_init_p2p_info(dev_i, dev_j);
-       if (!p2p_ij)
-               return;
-       p2p_ji = scif_init_p2p_info(dev_j, dev_i);
-       if (!p2p_ji) {
-               scif_deinit_p2p_info(dev_i, p2p_ij);
-               return;
-       }
-       list_add_tail(&p2p_ij->ppi_list, &dev_i->p2p);
-       list_add_tail(&p2p_ji->ppi_list, &dev_j->p2p);
-
-       /*
-        * Send a SCIF_NODE_ADD to dev_i, pass it its bus address
-        * as seen from dev_j
-        */
-       msg.uop = SCIF_NODE_ADD;
-       msg.src.node = dev_j->node;
-       msg.dst.node = dev_i->node;
-
-       msg.payload[0] = p2p_ji->ppi_da[SCIF_PPI_APER];
-       msg.payload[1] = p2p_ij->ppi_da[SCIF_PPI_MMIO];
-       msg.payload[2] = p2p_ij->ppi_da[SCIF_PPI_APER];
-       msg.payload[3] = p2p_ij->ppi_len[SCIF_PPI_APER] << PAGE_SHIFT;
-
-       err = scif_nodeqp_send(dev_i,  &msg);
-       if (err) {
-               dev_err(&scifdev->sdev->dev,
-                       "%s %d error %d\n", __func__, __LINE__, err);
-               return;
-       }
-
-       /* Same as above but to dev_j */
-       msg.uop = SCIF_NODE_ADD;
-       msg.src.node = dev_i->node;
-       msg.dst.node = dev_j->node;
-
-       tmppayload = msg.payload[0];
-       msg.payload[0] = msg.payload[2];
-       msg.payload[2] = tmppayload;
-       msg.payload[1] = p2p_ji->ppi_da[SCIF_PPI_MMIO];
-       msg.payload[3] = p2p_ji->ppi_len[SCIF_PPI_APER] << PAGE_SHIFT;
-
-       scif_nodeqp_send(dev_j, &msg);
-}
-
-static void scif_p2p_setup(void)
-{
-       int i, j;
-
-       if (!scif_info.p2p_enable)
-               return;
-
-       for (i = 1; i <= scif_info.maxid; i++)
-               if (!_scifdev_alive(&scif_dev[i]))
-                       return;
-
-       for (i = 1; i <= scif_info.maxid; i++) {
-               for (j = 1; j <= scif_info.maxid; j++) {
-                       struct scif_dev *scifdev = &scif_dev[i];
-
-                       if (i == j)
-                               continue;
-                       scif_node_connect(scifdev, j);
-               }
-       }
-}
-
-static char *message_types[] = {"BAD",
-                               "INIT",
-                               "EXIT",
-                               "SCIF_EXIT_ACK",
-                               "SCIF_NODE_ADD",
-                               "SCIF_NODE_ADD_ACK",
-                               "SCIF_NODE_ADD_NACK",
-                               "REMOVE_NODE",
-                               "REMOVE_NODE_ACK",
-                               "CNCT_REQ",
-                               "CNCT_GNT",
-                               "CNCT_GNTACK",
-                               "CNCT_GNTNACK",
-                               "CNCT_REJ",
-                               "DISCNCT",
-                               "DISCNT_ACK",
-                               "CLIENT_SENT",
-                               "CLIENT_RCVD",
-                               "SCIF_GET_NODE_INFO",
-                               "REGISTER",
-                               "REGISTER_ACK",
-                               "REGISTER_NACK",
-                               "UNREGISTER",
-                               "UNREGISTER_ACK",
-                               "UNREGISTER_NACK",
-                               "ALLOC_REQ",
-                               "ALLOC_GNT",
-                               "ALLOC_REJ",
-                               "FREE_PHYS",
-                               "FREE_VIRT",
-                               "MUNMAP",
-                               "MARK",
-                               "MARK_ACK",
-                               "MARK_NACK",
-                               "WAIT",
-                               "WAIT_ACK",
-                               "WAIT_NACK",
-                               "SIGNAL_LOCAL",
-                               "SIGNAL_REMOTE",
-                               "SIG_ACK",
-                               "SIG_NACK"};
-
-static void
-scif_display_message(struct scif_dev *scifdev, struct scifmsg *msg,
-                    const char *label)
-{
-       if (!scif_info.en_msg_log)
-               return;
-       if (msg->uop > SCIF_MAX_MSG) {
-               dev_err(&scifdev->sdev->dev,
-                       "%s: unknown msg type %d\n", label, msg->uop);
-               return;
-       }
-       dev_info(&scifdev->sdev->dev,
-                "%s: msg type %s, src %d:%d, dest %d:%d payload 0x%llx:0x%llx:0x%llx:0x%llx\n",
-                label, message_types[msg->uop], msg->src.node, msg->src.port,
-                msg->dst.node, msg->dst.port, msg->payload[0], msg->payload[1],
-                msg->payload[2], msg->payload[3]);
-}
-
-int _scif_nodeqp_send(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_qp *qp = scifdev->qpairs;
-       int err = -ENOMEM, loop_cnt = 0;
-
-       scif_display_message(scifdev, msg, "Sent");
-       if (!qp) {
-               err = -EINVAL;
-               goto error;
-       }
-       spin_lock(&qp->send_lock);
-
-       while ((err = scif_rb_write(&qp->outbound_q,
-                                   msg, sizeof(struct scifmsg)))) {
-               mdelay(1);
-#define SCIF_NODEQP_SEND_TO_MSEC (3 * 1000)
-               if (loop_cnt++ > (SCIF_NODEQP_SEND_TO_MSEC)) {
-                       err = -ENODEV;
-                       break;
-               }
-       }
-       if (!err)
-               scif_rb_commit(&qp->outbound_q);
-       spin_unlock(&qp->send_lock);
-       if (!err) {
-               if (scifdev_self(scifdev))
-                       /*
-                        * For loopback we need to emulate an interrupt by
-                        * queuing work for the queue handling real node
-                        * Qp interrupts.
-                        */
-                       queue_work(scifdev->intr_wq, &scifdev->intr_bh);
-               else
-                       scif_send_msg_intr(scifdev);
-       }
-error:
-       if (err)
-               dev_dbg(&scifdev->sdev->dev,
-                       "%s %d error %d uop %d\n",
-                        __func__, __LINE__, err, msg->uop);
-       return err;
-}
-
-/**
- * scif_nodeqp_send - Send a message on the node queue pair
- * @scifdev: Scif Device.
- * @msg: The message to be sent.
- */
-int scif_nodeqp_send(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       int err;
-       struct device *spdev = NULL;
-
-       if (msg->uop > SCIF_EXIT_ACK) {
-               /* Don't send messages once the exit flow has begun */
-               if (OP_IDLE != scifdev->exit)
-                       return -ENODEV;
-               spdev = scif_get_peer_dev(scifdev);
-               if (IS_ERR(spdev)) {
-                       err = PTR_ERR(spdev);
-                       return err;
-               }
-       }
-       err = _scif_nodeqp_send(scifdev, msg);
-       if (msg->uop > SCIF_EXIT_ACK)
-               scif_put_peer_dev(spdev);
-       return err;
-}
-
-/*
- * scif_misc_handler:
- *
- * Work queue handler for servicing miscellaneous SCIF tasks.
- * Examples include:
- * 1) Remote fence requests.
- * 2) Destruction of temporary registered windows
- *    created during scif_vreadfrom()/scif_vwriteto().
- * 3) Cleanup of zombie endpoints.
- */
-void scif_misc_handler(struct work_struct *work)
-{
-       scif_rma_handle_remote_fences();
-       scif_rma_destroy_windows();
-       scif_rma_destroy_tcw_invalid();
-       scif_cleanup_zombie_epd();
-}
-
-/**
- * scif_init() - Respond to SCIF_INIT interrupt message
- * @scifdev:    Remote SCIF device node
- * @msg:        Interrupt message
- */
-static __always_inline void
-scif_init(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       /*
-        * Allow the thread waiting for device page updates for the peer QP DMA
-        * address to complete initializing the inbound_q.
-        */
-       flush_delayed_work(&scifdev->qp_dwork);
-
-       scif_peer_register_device(scifdev);
-
-       if (scif_is_mgmt_node()) {
-               mutex_lock(&scif_info.conflock);
-               scif_p2p_setup();
-               mutex_unlock(&scif_info.conflock);
-       }
-}
-
-/**
- * scif_exit() - Respond to SCIF_EXIT interrupt message
- * @scifdev:    Remote SCIF device node
- * @unused:     Interrupt message (unused)
- *
- * This function stops the SCIF interface for the node which sent
- * the SCIF_EXIT message and starts waiting for that node to
- * resetup the queue pair again.
- */
-static __always_inline void
-scif_exit(struct scif_dev *scifdev, struct scifmsg *unused)
-{
-       scifdev->exit_ack_pending = true;
-       if (scif_is_mgmt_node())
-               scif_disconnect_node(scifdev->node, false);
-       else
-               scif_stop(scifdev);
-       schedule_delayed_work(&scifdev->qp_dwork,
-                             msecs_to_jiffies(1000));
-}
-
-/**
- * scif_exitack() - Respond to SCIF_EXIT_ACK interrupt message
- * @scifdev:    Remote SCIF device node
- * @unused:     Interrupt message (unused)
- *
- */
-static __always_inline void
-scif_exit_ack(struct scif_dev *scifdev, struct scifmsg *unused)
-{
-       scifdev->exit = OP_COMPLETED;
-       wake_up(&scif_info.exitwq);
-}
-
-/**
- * scif_node_add() - Respond to SCIF_NODE_ADD interrupt message
- * @scifdev:    Remote SCIF device node
- * @msg:        Interrupt message
- *
- * When the mgmt node driver has finished initializing a MIC node queue pair it
- * marks the node as online. It then looks for all currently online MIC cards
- * and send a SCIF_NODE_ADD message to identify the ID of the new card for
- * peer to peer initialization
- *
- * The local node allocates its incoming queue and sends its address in the
- * SCIF_NODE_ADD_ACK message back to the mgmt node, the mgmt node "reflects"
- * this message to the new node
- */
-static __always_inline void
-scif_node_add(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_dev *newdev;
-       dma_addr_t qp_offset;
-       int qp_connect;
-       struct scif_hw_dev *sdev;
-
-       dev_dbg(&scifdev->sdev->dev,
-               "Scifdev %d:%d received NODE_ADD msg for node %d\n",
-               scifdev->node, msg->dst.node, msg->src.node);
-       dev_dbg(&scifdev->sdev->dev,
-               "Remote address for this node's aperture %llx\n",
-               msg->payload[0]);
-       newdev = &scif_dev[msg->src.node];
-       newdev->node = msg->src.node;
-       newdev->sdev = scif_dev[SCIF_MGMT_NODE].sdev;
-       sdev = newdev->sdev;
-
-       if (scif_setup_intr_wq(newdev)) {
-               dev_err(&scifdev->sdev->dev,
-                       "failed to setup interrupts for %d\n", msg->src.node);
-               goto interrupt_setup_error;
-       }
-       newdev->mmio.va = ioremap(msg->payload[1], sdev->mmio->len);
-       if (!newdev->mmio.va) {
-               dev_err(&scifdev->sdev->dev,
-                       "failed to map mmio for %d\n", msg->src.node);
-               goto mmio_map_error;
-       }
-       newdev->qpairs = kzalloc(sizeof(*newdev->qpairs), GFP_KERNEL);
-       if (!newdev->qpairs)
-               goto qp_alloc_error;
-       /*
-        * Set the base address of the remote node's memory since it gets
-        * added to qp_offset
-        */
-       newdev->base_addr = msg->payload[0];
-
-       qp_connect = scif_setup_qp_connect(newdev->qpairs, &qp_offset,
-                                          SCIF_NODE_QP_SIZE, newdev);
-       if (qp_connect) {
-               dev_err(&scifdev->sdev->dev,
-                       "failed to setup qp_connect %d\n", qp_connect);
-               goto qp_connect_error;
-       }
-
-       newdev->db = sdev->hw_ops->next_db(sdev);
-       newdev->cookie = sdev->hw_ops->request_irq(sdev, scif_intr_handler,
-                                                  "SCIF_INTR", newdev,
-                                                  newdev->db);
-       if (IS_ERR(newdev->cookie))
-               goto qp_connect_error;
-       newdev->qpairs->magic = SCIFEP_MAGIC;
-       newdev->qpairs->qp_state = SCIF_QP_OFFLINE;
-
-       msg->uop = SCIF_NODE_ADD_ACK;
-       msg->dst.node = msg->src.node;
-       msg->src.node = scif_info.nodeid;
-       msg->payload[0] = qp_offset;
-       msg->payload[2] = newdev->db;
-       scif_nodeqp_send(&scif_dev[SCIF_MGMT_NODE], msg);
-       return;
-qp_connect_error:
-       kfree(newdev->qpairs);
-       newdev->qpairs = NULL;
-qp_alloc_error:
-       iounmap(newdev->mmio.va);
-       newdev->mmio.va = NULL;
-mmio_map_error:
-interrupt_setup_error:
-       dev_err(&scifdev->sdev->dev,
-               "node add failed for node %d\n", msg->src.node);
-       msg->uop = SCIF_NODE_ADD_NACK;
-       msg->dst.node = msg->src.node;
-       msg->src.node = scif_info.nodeid;
-       scif_nodeqp_send(&scif_dev[SCIF_MGMT_NODE], msg);
-}
-
-void scif_poll_qp_state(struct work_struct *work)
-{
-#define SCIF_NODE_QP_RETRY 100
-#define SCIF_NODE_QP_TIMEOUT 100
-       struct scif_dev *peerdev = container_of(work, struct scif_dev,
-                                                       p2p_dwork.work);
-       struct scif_qp *qp = &peerdev->qpairs[0];
-
-       if (qp->qp_state != SCIF_QP_ONLINE ||
-           qp->remote_qp->qp_state != SCIF_QP_ONLINE) {
-               if (peerdev->p2p_retry++ == SCIF_NODE_QP_RETRY) {
-                       dev_err(&peerdev->sdev->dev,
-                               "Warning: QP check timeout with state %d\n",
-                               qp->qp_state);
-                       goto timeout;
-               }
-               schedule_delayed_work(&peerdev->p2p_dwork,
-                                     msecs_to_jiffies(SCIF_NODE_QP_TIMEOUT));
-               return;
-       }
-       return;
-timeout:
-       dev_err(&peerdev->sdev->dev,
-               "%s %d remote node %d offline,  state = 0x%x\n",
-               __func__, __LINE__, peerdev->node, qp->qp_state);
-       qp->remote_qp->qp_state = SCIF_QP_OFFLINE;
-       scif_peer_unregister_device(peerdev);
-       scif_cleanup_scifdev(peerdev);
-}
-
-/**
- * scif_node_add_ack() - Respond to SCIF_NODE_ADD_ACK interrupt message
- * @scifdev:    Remote SCIF device node
- * @msg:        Interrupt message
- *
- * After a MIC node receives the SCIF_NODE_ADD_ACK message it send this
- * message to the mgmt node to confirm the sequence is finished.
- *
- */
-static __always_inline void
-scif_node_add_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_dev *peerdev;
-       struct scif_qp *qp;
-       struct scif_dev *dst_dev = &scif_dev[msg->dst.node];
-
-       dev_dbg(&scifdev->sdev->dev,
-               "Scifdev %d received SCIF_NODE_ADD_ACK msg src %d dst %d\n",
-               scifdev->node, msg->src.node, msg->dst.node);
-       dev_dbg(&scifdev->sdev->dev,
-               "payload %llx %llx %llx %llx\n", msg->payload[0],
-               msg->payload[1], msg->payload[2], msg->payload[3]);
-       if (scif_is_mgmt_node()) {
-               /*
-                * the lock serializes with scif_qp_response_ack. The mgmt node
-                * is forwarding the NODE_ADD_ACK message from src to dst we
-                * need to make sure that the dst has already received a
-                * NODE_ADD for src and setup its end of the qp to dst
-                */
-               mutex_lock(&scif_info.conflock);
-               msg->payload[1] = scif_info.maxid;
-               scif_nodeqp_send(dst_dev, msg);
-               mutex_unlock(&scif_info.conflock);
-               return;
-       }
-       peerdev = &scif_dev[msg->src.node];
-       peerdev->sdev = scif_dev[SCIF_MGMT_NODE].sdev;
-       peerdev->node = msg->src.node;
-
-       qp = &peerdev->qpairs[0];
-
-       if ((scif_setup_qp_connect_response(peerdev, &peerdev->qpairs[0],
-                                           msg->payload[0])))
-               goto local_error;
-       peerdev->rdb = msg->payload[2];
-       qp->remote_qp->qp_state = SCIF_QP_ONLINE;
-
-       scif_peer_register_device(peerdev);
-
-       schedule_delayed_work(&peerdev->p2p_dwork, 0);
-       return;
-local_error:
-       scif_cleanup_scifdev(peerdev);
-}
-
-/**
- * scif_node_add_nack: Respond to SCIF_NODE_ADD_NACK interrupt message
- * @scifdev:    Remote SCIF device node
- * @msg:        Interrupt message
- *
- * SCIF_NODE_ADD failed, so inform the waiting wq.
- */
-static __always_inline void
-scif_node_add_nack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       if (scif_is_mgmt_node()) {
-               struct scif_dev *dst_dev = &scif_dev[msg->dst.node];
-
-               dev_dbg(&scifdev->sdev->dev,
-                       "SCIF_NODE_ADD_NACK received from %d\n", scifdev->node);
-               scif_nodeqp_send(dst_dev, msg);
-       }
-}
-
-/**
- * scif_node_remove: Handle SCIF_NODE_REMOVE message
- * @scifdev:    Remote SCIF device node
- * @msg: Interrupt message
- *
- * Handle node removal.
- */
-static __always_inline void
-scif_node_remove(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       int node = msg->payload[0];
-       struct scif_dev *scdev = &scif_dev[node];
-
-       scdev->node_remove_ack_pending = true;
-       scif_handle_remove_node(node);
-}
-
-/**
- * scif_node_remove_ack: Handle SCIF_NODE_REMOVE_ACK message
- * @scifdev:    Remote SCIF device node
- * @msg: Interrupt message
- *
- * The peer has acked a SCIF_NODE_REMOVE message.
- */
-static __always_inline void
-scif_node_remove_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_dev *sdev = &scif_dev[msg->payload[0]];
-
-       atomic_inc(&sdev->disconn_rescnt);
-       wake_up(&sdev->disconn_wq);
-}
-
-/**
- * scif_get_node_info: Respond to SCIF_GET_NODE_INFO interrupt message
- * @scifdev:    Remote SCIF device node
- * @msg:        Interrupt message
- *
- * Retrieve node info i.e maxid and total from the mgmt node.
- */
-static __always_inline void
-scif_get_node_info_resp(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       if (scif_is_mgmt_node()) {
-               swap(msg->dst.node, msg->src.node);
-               mutex_lock(&scif_info.conflock);
-               msg->payload[1] = scif_info.maxid;
-               msg->payload[2] = scif_info.total;
-               mutex_unlock(&scif_info.conflock);
-               scif_nodeqp_send(scifdev, msg);
-       } else {
-               struct completion *node_info =
-                       (struct completion *)msg->payload[3];
-
-               mutex_lock(&scif_info.conflock);
-               scif_info.maxid = msg->payload[1];
-               scif_info.total = msg->payload[2];
-               complete_all(node_info);
-               mutex_unlock(&scif_info.conflock);
-       }
-}
-
-static void
-scif_msg_unknown(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       /* Bogus Node Qp Message? */
-       dev_err(&scifdev->sdev->dev,
-               "Unknown message 0x%xn scifdev->node 0x%x\n",
-               msg->uop, scifdev->node);
-}
-
-static void (*scif_intr_func[SCIF_MAX_MSG + 1])
-           (struct scif_dev *, struct scifmsg *msg) = {
-       scif_msg_unknown,       /* Error */
-       scif_init,              /* SCIF_INIT */
-       scif_exit,              /* SCIF_EXIT */
-       scif_exit_ack,          /* SCIF_EXIT_ACK */
-       scif_node_add,          /* SCIF_NODE_ADD */
-       scif_node_add_ack,      /* SCIF_NODE_ADD_ACK */
-       scif_node_add_nack,     /* SCIF_NODE_ADD_NACK */
-       scif_node_remove,       /* SCIF_NODE_REMOVE */
-       scif_node_remove_ack,   /* SCIF_NODE_REMOVE_ACK */
-       scif_cnctreq,           /* SCIF_CNCT_REQ */
-       scif_cnctgnt,           /* SCIF_CNCT_GNT */
-       scif_cnctgnt_ack,       /* SCIF_CNCT_GNTACK */
-       scif_cnctgnt_nack,      /* SCIF_CNCT_GNTNACK */
-       scif_cnctrej,           /* SCIF_CNCT_REJ */
-       scif_discnct,           /* SCIF_DISCNCT */
-       scif_discnt_ack,        /* SCIF_DISCNT_ACK */
-       scif_clientsend,        /* SCIF_CLIENT_SENT */
-       scif_clientrcvd,        /* SCIF_CLIENT_RCVD */
-       scif_get_node_info_resp,/* SCIF_GET_NODE_INFO */
-       scif_recv_reg,          /* SCIF_REGISTER */
-       scif_recv_reg_ack,      /* SCIF_REGISTER_ACK */
-       scif_recv_reg_nack,     /* SCIF_REGISTER_NACK */
-       scif_recv_unreg,        /* SCIF_UNREGISTER */
-       scif_recv_unreg_ack,    /* SCIF_UNREGISTER_ACK */
-       scif_recv_unreg_nack,   /* SCIF_UNREGISTER_NACK */
-       scif_alloc_req,         /* SCIF_ALLOC_REQ */
-       scif_alloc_gnt_rej,     /* SCIF_ALLOC_GNT */
-       scif_alloc_gnt_rej,     /* SCIF_ALLOC_REJ */
-       scif_free_virt,         /* SCIF_FREE_VIRT */
-       scif_recv_munmap,       /* SCIF_MUNMAP */
-       scif_recv_mark,         /* SCIF_MARK */
-       scif_recv_mark_resp,    /* SCIF_MARK_ACK */
-       scif_recv_mark_resp,    /* SCIF_MARK_NACK */
-       scif_recv_wait,         /* SCIF_WAIT */
-       scif_recv_wait_resp,    /* SCIF_WAIT_ACK */
-       scif_recv_wait_resp,    /* SCIF_WAIT_NACK */
-       scif_recv_sig_local,    /* SCIF_SIG_LOCAL */
-       scif_recv_sig_remote,   /* SCIF_SIG_REMOTE */
-       scif_recv_sig_resp,     /* SCIF_SIG_ACK */
-       scif_recv_sig_resp,     /* SCIF_SIG_NACK */
-};
-
-static int scif_max_msg_id = SCIF_MAX_MSG;
-/**
- * scif_nodeqp_msg_handler() - Common handler for node messages
- * @scifdev: Remote device to respond to
- * @qp: Remote memory pointer
- * @msg: The message to be handled.
- *
- * This routine calls the appropriate routine to handle a Node Qp
- * message receipt
- */
-static void
-scif_nodeqp_msg_handler(struct scif_dev *scifdev,
-                       struct scif_qp *qp, struct scifmsg *msg)
-{
-       scif_display_message(scifdev, msg, "Rcvd");
-
-       if (msg->uop > (u32)scif_max_msg_id) {
-               /* Bogus Node Qp Message? */
-               dev_err(&scifdev->sdev->dev,
-                       "Unknown message 0x%xn scifdev->node 0x%x\n",
-                       msg->uop, scifdev->node);
-               return;
-       }
-
-       scif_intr_func[msg->uop](scifdev, msg);
-}
-
-/**
- * scif_nodeqp_intrhandler() - Interrupt handler for node messages
- * @scifdev:    Remote device to respond to
- * @qp:         Remote memory pointer
- *
- * This routine is triggered by the interrupt mechanism.  It reads
- * messages from the node queue RB and calls the Node QP Message handling
- * routine.
- */
-void scif_nodeqp_intrhandler(struct scif_dev *scifdev, struct scif_qp *qp)
-{
-       struct scifmsg msg;
-       int read_size;
-
-       do {
-               read_size = scif_rb_get_next(&qp->inbound_q, &msg, sizeof(msg));
-               if (!read_size)
-                       break;
-               scif_nodeqp_msg_handler(scifdev, qp, &msg);
-               /*
-                * The node queue pair is unmapped so skip the read pointer
-                * update after receipt of a SCIF_EXIT_ACK
-                */
-               if (SCIF_EXIT_ACK == msg.uop)
-                       break;
-               scif_rb_update_read_ptr(&qp->inbound_q);
-       } while (1);
-}
-
-/**
- * scif_loopb_wq_handler - Loopback Workqueue Handler.
- * @unused: loop back work (unused)
- *
- * This work queue routine is invoked by the loopback work queue handler.
- * It grabs the recv lock, dequeues any available messages from the head
- * of the loopback message list, calls the node QP message handler,
- * waits for it to return, then frees up this message and dequeues more
- * elements of the list if available.
- */
-static void scif_loopb_wq_handler(struct work_struct *unused)
-{
-       struct scif_dev *scifdev = scif_info.loopb_dev;
-       struct scif_qp *qp = scifdev->qpairs;
-       struct scif_loopb_msg *msg;
-
-       do {
-               msg = NULL;
-               spin_lock(&qp->recv_lock);
-               if (!list_empty(&scif_info.loopb_recv_q)) {
-                       msg = list_first_entry(&scif_info.loopb_recv_q,
-                                              struct scif_loopb_msg,
-                                              list);
-                       list_del(&msg->list);
-               }
-               spin_unlock(&qp->recv_lock);
-
-               if (msg) {
-                       scif_nodeqp_msg_handler(scifdev, qp, &msg->msg);
-                       kfree(msg);
-               }
-       } while (msg);
-}
-
-/**
- * scif_loopb_msg_handler() - Workqueue handler for loopback messages.
- * @scifdev: SCIF device
- * @qp: Queue pair.
- *
- * This work queue routine is triggered when a loopback message is received.
- *
- * We need special handling for receiving Node Qp messages on a loopback SCIF
- * device via two workqueues for receiving messages.
- *
- * The reason we need the extra workqueue which is not required with *normal*
- * non-loopback SCIF devices is the potential classic deadlock described below:
- *
- * Thread A tries to send a message on a loopback SCIF device and blocks since
- * there is no space in the RB while it has the send_lock held or another
- * lock called lock X for example.
- *
- * Thread B: The Loopback Node QP message receive workqueue receives the message
- * and tries to send a message (eg an ACK) to the loopback SCIF device. It tries
- * to grab the send lock again or lock X and deadlocks with Thread A. The RB
- * cannot be drained any further due to this classic deadlock.
- *
- * In order to avoid deadlocks as mentioned above we have an extra level of
- * indirection achieved by having two workqueues.
- * 1) The first workqueue whose handler is scif_loopb_msg_handler reads
- * messages from the Node QP RB, adds them to a list and queues work for the
- * second workqueue.
- *
- * 2) The second workqueue whose handler is scif_loopb_wq_handler dequeues
- * messages from the list, handles them, frees up the memory and dequeues
- * more elements from the list if possible.
- */
-int
-scif_loopb_msg_handler(struct scif_dev *scifdev, struct scif_qp *qp)
-{
-       int read_size;
-       struct scif_loopb_msg *msg;
-
-       do {
-               msg = kmalloc(sizeof(*msg), GFP_KERNEL);
-               if (!msg)
-                       return -ENOMEM;
-               read_size = scif_rb_get_next(&qp->inbound_q, &msg->msg,
-                                            sizeof(struct scifmsg));
-               if (read_size != sizeof(struct scifmsg)) {
-                       kfree(msg);
-                       scif_rb_update_read_ptr(&qp->inbound_q);
-                       break;
-               }
-               spin_lock(&qp->recv_lock);
-               list_add_tail(&msg->list, &scif_info.loopb_recv_q);
-               spin_unlock(&qp->recv_lock);
-               queue_work(scif_info.loopb_wq, &scif_info.loopb_work);
-               scif_rb_update_read_ptr(&qp->inbound_q);
-       } while (read_size == sizeof(struct scifmsg));
-       return read_size;
-}
-
-/**
- * scif_setup_loopback_qp - One time setup work for Loopback Node Qp.
- * @scifdev: SCIF device
- *
- * Sets up the required loopback workqueues, queue pairs and ring buffers
- */
-int scif_setup_loopback_qp(struct scif_dev *scifdev)
-{
-       int err = 0;
-       void *local_q;
-       struct scif_qp *qp;
-
-       err = scif_setup_intr_wq(scifdev);
-       if (err)
-               goto exit;
-       INIT_LIST_HEAD(&scif_info.loopb_recv_q);
-       snprintf(scif_info.loopb_wqname, sizeof(scif_info.loopb_wqname),
-                "SCIF LOOPB %d", scifdev->node);
-       scif_info.loopb_wq =
-               alloc_ordered_workqueue(scif_info.loopb_wqname, 0);
-       if (!scif_info.loopb_wq) {
-               err = -ENOMEM;
-               goto destroy_intr;
-       }
-       INIT_WORK(&scif_info.loopb_work, scif_loopb_wq_handler);
-       /* Allocate Self Qpair */
-       scifdev->qpairs = kzalloc(sizeof(*scifdev->qpairs), GFP_KERNEL);
-       if (!scifdev->qpairs) {
-               err = -ENOMEM;
-               goto destroy_loopb_wq;
-       }
-
-       qp = scifdev->qpairs;
-       qp->magic = SCIFEP_MAGIC;
-       spin_lock_init(&qp->send_lock);
-       spin_lock_init(&qp->recv_lock);
-
-       local_q = kzalloc(SCIF_NODE_QP_SIZE, GFP_KERNEL);
-       if (!local_q) {
-               err = -ENOMEM;
-               goto free_qpairs;
-       }
-       /*
-        * For loopback the inbound_q and outbound_q are essentially the same
-        * since the Node sends a message on the loopback interface to the
-        * outbound_q which is then received on the inbound_q.
-        */
-       scif_rb_init(&qp->outbound_q,
-                    &qp->local_read,
-                    &qp->local_write,
-                    local_q, get_count_order(SCIF_NODE_QP_SIZE));
-
-       scif_rb_init(&qp->inbound_q,
-                    &qp->local_read,
-                    &qp->local_write,
-                    local_q, get_count_order(SCIF_NODE_QP_SIZE));
-       scif_info.nodeid = scifdev->node;
-
-       scif_peer_register_device(scifdev);
-
-       scif_info.loopb_dev = scifdev;
-       return err;
-free_qpairs:
-       kfree(scifdev->qpairs);
-destroy_loopb_wq:
-       destroy_workqueue(scif_info.loopb_wq);
-destroy_intr:
-       scif_destroy_intr_wq(scifdev);
-exit:
-       return err;
-}
-
-/**
- * scif_destroy_loopback_qp - One time uninit work for Loopback Node Qp
- * @scifdev: SCIF device
- *
- * Destroys the workqueues and frees up the Ring Buffer and Queue Pair memory.
- */
-int scif_destroy_loopback_qp(struct scif_dev *scifdev)
-{
-       scif_peer_unregister_device(scifdev);
-       destroy_workqueue(scif_info.loopb_wq);
-       scif_destroy_intr_wq(scifdev);
-       kfree(scifdev->qpairs->outbound_q.rb_base);
-       kfree(scifdev->qpairs);
-       scifdev->sdev = NULL;
-       scif_info.loopb_dev = NULL;
-       return 0;
-}
-
-void scif_destroy_p2p(struct scif_dev *scifdev)
-{
-       struct scif_dev *peer_dev;
-       struct scif_p2p_info *p2p;
-       struct list_head *pos, *tmp;
-       int bd;
-
-       mutex_lock(&scif_info.conflock);
-       /* Free P2P mappings in the given node for all its peer nodes */
-       list_for_each_safe(pos, tmp, &scifdev->p2p) {
-               p2p = list_entry(pos, struct scif_p2p_info, ppi_list);
-               dma_unmap_sg(&scifdev->sdev->dev, p2p->ppi_sg[SCIF_PPI_MMIO],
-                            p2p->sg_nentries[SCIF_PPI_MMIO],
-                            DMA_BIDIRECTIONAL);
-               dma_unmap_sg(&scifdev->sdev->dev, p2p->ppi_sg[SCIF_PPI_APER],
-                            p2p->sg_nentries[SCIF_PPI_APER],
-                            DMA_BIDIRECTIONAL);
-               scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_MMIO]);
-               scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_APER]);
-               list_del(pos);
-               kfree(p2p);
-       }
-
-       /* Free P2P mapping created in the peer nodes for the given node */
-       for (bd = SCIF_MGMT_NODE + 1; bd <= scif_info.maxid; bd++) {
-               peer_dev = &scif_dev[bd];
-               list_for_each_safe(pos, tmp, &peer_dev->p2p) {
-                       p2p = list_entry(pos, struct scif_p2p_info, ppi_list);
-                       if (p2p->ppi_peer_id == scifdev->node) {
-                               dma_unmap_sg(&peer_dev->sdev->dev,
-                                            p2p->ppi_sg[SCIF_PPI_MMIO],
-                                            p2p->sg_nentries[SCIF_PPI_MMIO],
-                                            DMA_BIDIRECTIONAL);
-                               dma_unmap_sg(&peer_dev->sdev->dev,
-                                            p2p->ppi_sg[SCIF_PPI_APER],
-                                            p2p->sg_nentries[SCIF_PPI_APER],
-                                            DMA_BIDIRECTIONAL);
-                               scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_MMIO]);
-                               scif_p2p_freesg(p2p->ppi_sg[SCIF_PPI_APER]);
-                               list_del(pos);
-                               kfree(p2p);
-                       }
-               }
-       }
-       mutex_unlock(&scif_info.conflock);
-}
diff --git a/drivers/misc/mic/scif/scif_nodeqp.h b/drivers/misc/mic/scif/scif_nodeqp.h
deleted file mode 100644 (file)
index 9589627..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * 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) 2014 Intel Corporation.
- *
- * 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.
- *
- * 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.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * 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 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 SCIF driver.
- *
- */
-#ifndef SCIF_NODEQP
-#define SCIF_NODEQP
-
-#include "scif_rb.h"
-#include "scif_peer_bus.h"
-
-#define SCIF_INIT 1  /* First message sent to the peer node for discovery */
-#define SCIF_EXIT 2  /* Last message from the peer informing intent to exit */
-#define SCIF_EXIT_ACK 3 /* Response to SCIF_EXIT message */
-#define SCIF_NODE_ADD 4  /* Tell Online nodes a new node exits */
-#define SCIF_NODE_ADD_ACK 5  /* Confirm to mgmt node sequence is finished */
-#define SCIF_NODE_ADD_NACK 6 /* SCIF_NODE_ADD failed */
-#define SCIF_NODE_REMOVE 7 /* Request to deactivate a SCIF node */
-#define SCIF_NODE_REMOVE_ACK 8 /* Response to a SCIF_NODE_REMOVE message */
-#define SCIF_CNCT_REQ 9  /* Phys addr of Request connection to a port */
-#define SCIF_CNCT_GNT 10  /* Phys addr of new Grant connection request */
-#define SCIF_CNCT_GNTACK 11  /* Error type Reject a connection request */
-#define SCIF_CNCT_GNTNACK 12  /* Error type Reject a connection request */
-#define SCIF_CNCT_REJ 13  /* Error type Reject a connection request */
-#define SCIF_DISCNCT 14 /* Notify peer that connection is being terminated */
-#define SCIF_DISCNT_ACK 15 /* Notify peer that connection is being terminated */
-#define SCIF_CLIENT_SENT 16 /* Notify the peer that data has been written */
-#define SCIF_CLIENT_RCVD 17 /* Notify the peer that data has been read */
-#define SCIF_GET_NODE_INFO 18 /* Get current node mask from the mgmt node*/
-#define SCIF_REGISTER 19 /* Tell peer about a new registered window */
-#define SCIF_REGISTER_ACK 20 /* Notify peer about unregistration success */
-#define SCIF_REGISTER_NACK 21 /* Notify peer about registration success */
-#define SCIF_UNREGISTER 22 /* Tell peer about unregistering a window */
-#define SCIF_UNREGISTER_ACK 23 /* Notify peer about registration failure */
-#define SCIF_UNREGISTER_NACK 24 /* Notify peer about unregistration failure */
-#define SCIF_ALLOC_REQ 25 /* Request a mapped buffer */
-#define SCIF_ALLOC_GNT 26 /* Notify peer about allocation success */
-#define SCIF_ALLOC_REJ 27 /* Notify peer about allocation failure */
-#define SCIF_FREE_VIRT 28 /* Free previously allocated virtual memory */
-#define SCIF_MUNMAP 29 /* Acknowledgment for a SCIF_MMAP request */
-#define SCIF_MARK 30 /* SCIF Remote Fence Mark Request */
-#define SCIF_MARK_ACK 31 /* SCIF Remote Fence Mark Success */
-#define SCIF_MARK_NACK 32 /* SCIF Remote Fence Mark Failure */
-#define SCIF_WAIT 33 /* SCIF Remote Fence Wait Request */
-#define SCIF_WAIT_ACK 34 /* SCIF Remote Fence Wait Success */
-#define SCIF_WAIT_NACK 35 /* SCIF Remote Fence Wait Failure */
-#define SCIF_SIG_LOCAL 36 /* SCIF Remote Fence Local Signal Request */
-#define SCIF_SIG_REMOTE 37 /* SCIF Remote Fence Remote Signal Request */
-#define SCIF_SIG_ACK 38 /* SCIF Remote Fence Remote Signal Success */
-#define SCIF_SIG_NACK 39 /* SCIF Remote Fence Remote Signal Failure */
-#define SCIF_MAX_MSG SCIF_SIG_NACK
-
-/*
- * struct scifmsg - Node QP message format
- *
- * @src: Source information
- * @dst: Destination information
- * @uop: The message opcode
- * @payload: Unique payload format for each message
- */
-struct scifmsg {
-       struct scif_port_id src;
-       struct scif_port_id dst;
-       u32 uop;
-       u64 payload[4];
-} __packed;
-
-/*
- * struct scif_allocmsg - Used with SCIF_ALLOC_REQ to request
- * the remote note to allocate memory
- *
- * phys_addr: Physical address of the buffer
- * vaddr: Virtual address of the buffer
- * size: Size of the buffer
- * state: Current state
- * allocwq: wait queue for status
- */
-struct scif_allocmsg {
-       dma_addr_t phys_addr;
-       unsigned long vaddr;
-       size_t size;
-       enum scif_msg_state state;
-       wait_queue_head_t allocwq;
-};
-
-/*
- * struct scif_qp - Node Queue Pair
- *
- * Interesting structure -- a little difficult because we can only
- * write across the PCIe, so any r/w pointer we need to read is
- * local. We only need to read the read pointer on the inbound_q
- * and read the write pointer in the outbound_q
- *
- * @magic: Magic value to ensure the peer sees the QP correctly
- * @outbound_q: The outbound ring buffer for sending messages
- * @inbound_q: The inbound ring buffer for receiving messages
- * @local_write: Local write index
- * @local_read: Local read index
- * @remote_qp: The remote queue pair
- * @local_buf: DMA address of local ring buffer
- * @local_qp: DMA address of the local queue pair data structure
- * @remote_buf: DMA address of remote ring buffer
- * @qp_state: QP state i.e. online or offline used for P2P
- * @send_lock: synchronize access to outbound queue
- * @recv_lock: Synchronize access to inbound queue
- */
-struct scif_qp {
-       u64 magic;
-#define SCIFEP_MAGIC 0x5c1f000000005c1fULL
-       struct scif_rb outbound_q;
-       struct scif_rb inbound_q;
-
-       u32 local_write __aligned(64);
-       u32 local_read __aligned(64);
-       struct scif_qp *remote_qp;
-       dma_addr_t local_buf;
-       dma_addr_t local_qp;
-       dma_addr_t remote_buf;
-       u32 qp_state;
-#define SCIF_QP_OFFLINE 0xdead
-#define SCIF_QP_ONLINE 0xc0de
-       spinlock_t send_lock;
-       spinlock_t recv_lock;
-};
-
-/*
- * struct scif_loopb_msg - An element in the loopback Node QP message list.
- *
- * @msg - The SCIF node QP message
- * @list - link in the list of messages
- */
-struct scif_loopb_msg {
-       struct scifmsg msg;
-       struct list_head list;
-};
-
-int scif_nodeqp_send(struct scif_dev *scifdev, struct scifmsg *msg);
-int _scif_nodeqp_send(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_nodeqp_intrhandler(struct scif_dev *scifdev, struct scif_qp *qp);
-int scif_loopb_msg_handler(struct scif_dev *scifdev, struct scif_qp *qp);
-int scif_setup_qp(struct scif_dev *scifdev);
-int scif_qp_response(phys_addr_t phys, struct scif_dev *dev);
-int scif_setup_qp_connect(struct scif_qp *qp, dma_addr_t *qp_offset,
-                         int local_size, struct scif_dev *scifdev);
-int scif_setup_qp_accept(struct scif_qp *qp, dma_addr_t *qp_offset,
-                        dma_addr_t phys, int local_size,
-                        struct scif_dev *scifdev);
-int scif_setup_qp_connect_response(struct scif_dev *scifdev,
-                                  struct scif_qp *qp, u64 payload);
-int scif_setup_loopback_qp(struct scif_dev *scifdev);
-int scif_destroy_loopback_qp(struct scif_dev *scifdev);
-void scif_poll_qp_state(struct work_struct *work);
-void scif_destroy_p2p(struct scif_dev *scifdev);
-void scif_send_exit(struct scif_dev *scifdev);
-static inline struct device *scif_get_peer_dev(struct scif_dev *scifdev)
-{
-       struct scif_peer_dev *spdev;
-       struct device *spdev_ret;
-
-       rcu_read_lock();
-       spdev = rcu_dereference(scifdev->spdev);
-       if (spdev)
-               spdev_ret = get_device(&spdev->dev);
-       else
-               spdev_ret = ERR_PTR(-ENODEV);
-       rcu_read_unlock();
-       return spdev_ret;
-}
-
-static inline void scif_put_peer_dev(struct device *dev)
-{
-       put_device(dev);
-}
-#endif  /* SCIF_NODEQP */
diff --git a/drivers/misc/mic/scif/scif_peer_bus.c b/drivers/misc/mic/scif/scif_peer_bus.c
deleted file mode 100644 (file)
index 6d60830..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-#include "../bus/scif_bus.h"
-#include "scif_peer_bus.h"
-
-static inline struct scif_peer_dev *
-dev_to_scif_peer(struct device *dev)
-{
-       return container_of(dev, struct scif_peer_dev, dev);
-}
-
-struct bus_type scif_peer_bus = {
-       .name  = "scif_peer_bus",
-};
-
-static void scif_peer_release_dev(struct device *d)
-{
-       struct scif_peer_dev *sdev = dev_to_scif_peer(d);
-       struct scif_dev *scifdev = &scif_dev[sdev->dnode];
-
-       scif_cleanup_scifdev(scifdev);
-       kfree(sdev);
-}
-
-static int scif_peer_initialize_device(struct scif_dev *scifdev)
-{
-       struct scif_peer_dev *spdev;
-       int ret;
-
-       spdev = kzalloc(sizeof(*spdev), GFP_KERNEL);
-       if (!spdev) {
-               ret = -ENOMEM;
-               goto err;
-       }
-
-       spdev->dev.parent = scifdev->sdev->dev.parent;
-       spdev->dev.release = scif_peer_release_dev;
-       spdev->dnode = scifdev->node;
-       spdev->dev.bus = &scif_peer_bus;
-       dev_set_name(&spdev->dev, "scif_peer-dev%u", spdev->dnode);
-
-       device_initialize(&spdev->dev);
-       get_device(&spdev->dev);
-       rcu_assign_pointer(scifdev->spdev, spdev);
-
-       mutex_lock(&scif_info.conflock);
-       scif_info.total++;
-       scif_info.maxid = max_t(u32, spdev->dnode, scif_info.maxid);
-       mutex_unlock(&scif_info.conflock);
-       return 0;
-err:
-       dev_err(&scifdev->sdev->dev,
-               "dnode %d: initialize_device rc %d\n", scifdev->node, ret);
-       return ret;
-}
-
-static int scif_peer_add_device(struct scif_dev *scifdev)
-{
-       struct scif_peer_dev *spdev = rcu_dereference(scifdev->spdev);
-       char pool_name[16];
-       int ret;
-
-       ret = device_add(&spdev->dev);
-       put_device(&spdev->dev);
-       if (ret) {
-               dev_err(&scifdev->sdev->dev,
-                       "dnode %d: peer device_add failed\n", scifdev->node);
-               goto put_spdev;
-       }
-
-       scnprintf(pool_name, sizeof(pool_name), "scif-%d", spdev->dnode);
-       scifdev->signal_pool = dmam_pool_create(pool_name, &scifdev->sdev->dev,
-                                               sizeof(struct scif_status), 1,
-                                               0);
-       if (!scifdev->signal_pool) {
-               dev_err(&scifdev->sdev->dev,
-                       "dnode %d: dmam_pool_create failed\n", scifdev->node);
-               ret = -ENOMEM;
-               goto del_spdev;
-       }
-       dev_dbg(&spdev->dev, "Added peer dnode %d\n", spdev->dnode);
-       return 0;
-del_spdev:
-       device_del(&spdev->dev);
-put_spdev:
-       RCU_INIT_POINTER(scifdev->spdev, NULL);
-       synchronize_rcu();
-       put_device(&spdev->dev);
-
-       mutex_lock(&scif_info.conflock);
-       scif_info.total--;
-       mutex_unlock(&scif_info.conflock);
-       return ret;
-}
-
-void scif_add_peer_device(struct work_struct *work)
-{
-       struct scif_dev *scifdev = container_of(work, struct scif_dev,
-                                               peer_add_work);
-
-       scif_peer_add_device(scifdev);
-}
-
-/*
- * Peer device registration is split into a device_initialize and a device_add.
- * The reason for doing this is as follows: First, peer device registration
- * itself cannot be done in the message processing thread and must be delegated
- * to another workqueue, otherwise if SCIF client probe, called during peer
- * device registration, calls scif_connect(..), it will block the message
- * processing thread causing a deadlock. Next, device_initialize is done in the
- * "top-half" message processing thread and device_add in the "bottom-half"
- * workqueue. If this is not done, SCIF_CNCT_REQ message processing executing
- * concurrently with SCIF_INIT message processing is unable to get a reference
- * on the peer device, thereby failing the connect request.
- */
-void scif_peer_register_device(struct scif_dev *scifdev)
-{
-       int ret;
-
-       mutex_lock(&scifdev->lock);
-       ret = scif_peer_initialize_device(scifdev);
-       if (ret)
-               goto exit;
-       schedule_work(&scifdev->peer_add_work);
-exit:
-       mutex_unlock(&scifdev->lock);
-}
-
-int scif_peer_unregister_device(struct scif_dev *scifdev)
-{
-       struct scif_peer_dev *spdev;
-
-       mutex_lock(&scifdev->lock);
-       /* Flush work to ensure device register is complete */
-       flush_work(&scifdev->peer_add_work);
-
-       /*
-        * Continue holding scifdev->lock since theoretically unregister_device
-        * can be called simultaneously from multiple threads
-        */
-       spdev = rcu_dereference(scifdev->spdev);
-       if (!spdev) {
-               mutex_unlock(&scifdev->lock);
-               return -ENODEV;
-       }
-
-       RCU_INIT_POINTER(scifdev->spdev, NULL);
-       synchronize_rcu();
-       mutex_unlock(&scifdev->lock);
-
-       dev_dbg(&spdev->dev, "Removing peer dnode %d\n", spdev->dnode);
-       device_unregister(&spdev->dev);
-
-       mutex_lock(&scif_info.conflock);
-       scif_info.total--;
-       mutex_unlock(&scif_info.conflock);
-       return 0;
-}
-
-int scif_peer_bus_init(void)
-{
-       return bus_register(&scif_peer_bus);
-}
-
-void scif_peer_bus_exit(void)
-{
-       bus_unregister(&scif_peer_bus);
-}
diff --git a/drivers/misc/mic/scif/scif_peer_bus.h b/drivers/misc/mic/scif/scif_peer_bus.h
deleted file mode 100644 (file)
index 2ea4c51..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#ifndef _SCIF_PEER_BUS_H_
-#define _SCIF_PEER_BUS_H_
-
-#include <linux/device.h>
-#include <linux/mic_common.h>
-#include <linux/scif.h>
-
-struct scif_dev;
-
-void scif_add_peer_device(struct work_struct *work);
-void scif_peer_register_device(struct scif_dev *sdev);
-int scif_peer_unregister_device(struct scif_dev *scifdev);
-int scif_peer_bus_init(void);
-void scif_peer_bus_exit(void);
-#endif /* _SCIF_PEER_BUS_H */
diff --git a/drivers/misc/mic/scif/scif_ports.c b/drivers/misc/mic/scif/scif_ports.c
deleted file mode 100644 (file)
index 4bdb5ef..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/idr.h>
-
-#include "scif_main.h"
-
-#define SCIF_PORT_COUNT        0x10000 /* Ports available */
-
-struct idr scif_ports;
-
-/**
- * struct scif_port - SCIF port information
- *
- * @ref_cnt:  Reference count since there can be multiple endpoints
- *           created via scif_accept(..) simultaneously using a port.
- */
-struct scif_port {
-       int ref_cnt;
-};
-
-/**
- * __scif_get_port - Reserve a specified port # for SCIF and add it
- * to the global list.
- * @start: lowest port # to be reserved (inclusive).
- * @end:   highest port # to be reserved (exclusive).
- *
- * @return : Allocated SCIF port #, or -ENOSPC if port unavailable.
- *             On memory allocation failure, returns -ENOMEM.
- */
-static int __scif_get_port(int start, int end)
-{
-       int id;
-       struct scif_port *port = kzalloc(sizeof(*port), GFP_ATOMIC);
-
-       if (!port)
-               return -ENOMEM;
-       spin_lock(&scif_info.port_lock);
-       id = idr_alloc(&scif_ports, port, start, end, GFP_ATOMIC);
-       if (id >= 0)
-               port->ref_cnt++;
-       spin_unlock(&scif_info.port_lock);
-       return id;
-}
-
-/**
- * scif_rsrv_port - Reserve a specified port # for SCIF.
- * @port : port # to be reserved.
- *
- * @return : Allocated SCIF port #, or -ENOSPC if port unavailable.
- *             On memory allocation failure, returns -ENOMEM.
- */
-int scif_rsrv_port(u16 port)
-{
-       return __scif_get_port(port, port + 1);
-}
-
-/**
- * scif_get_new_port - Get and reserve any port # for SCIF in the range
- *                     SCIF_PORT_RSVD + 1 to SCIF_PORT_COUNT - 1.
- *
- * @return : Allocated SCIF port #, or -ENOSPC if no ports available.
- *             On memory allocation failure, returns -ENOMEM.
- */
-int scif_get_new_port(void)
-{
-       return __scif_get_port(SCIF_PORT_RSVD + 1, SCIF_PORT_COUNT);
-}
-
-/**
- * scif_get_port - Increment the reference count for a SCIF port
- * @id : SCIF port
- *
- * @return : None
- */
-void scif_get_port(u16 id)
-{
-       struct scif_port *port;
-
-       if (!id)
-               return;
-       spin_lock(&scif_info.port_lock);
-       port = idr_find(&scif_ports, id);
-       if (port)
-               port->ref_cnt++;
-       spin_unlock(&scif_info.port_lock);
-}
-
-/**
- * scif_put_port - Release a reserved SCIF port
- * @id : SCIF port to be released.
- *
- * @return : None
- */
-void scif_put_port(u16 id)
-{
-       struct scif_port *port;
-
-       if (!id)
-               return;
-       spin_lock(&scif_info.port_lock);
-       port = idr_find(&scif_ports, id);
-       if (port) {
-               port->ref_cnt--;
-               if (!port->ref_cnt) {
-                       idr_remove(&scif_ports, id);
-                       kfree(port);
-               }
-       }
-       spin_unlock(&scif_info.port_lock);
-}
diff --git a/drivers/misc/mic/scif/scif_rb.c b/drivers/misc/mic/scif/scif_rb.c
deleted file mode 100644 (file)
index e425882..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/circ_buf.h>
-#include <linux/types.h>
-#include <linux/io.h>
-#include <linux/errno.h>
-
-#include "scif_rb.h"
-
-#define scif_rb_ring_cnt(head, tail, size) CIRC_CNT(head, tail, size)
-#define scif_rb_ring_space(head, tail, size) CIRC_SPACE(head, tail, size)
-
-/**
- * scif_rb_init - Initializes the ring buffer
- * @rb: ring buffer
- * @read_ptr: A pointer to the read offset
- * @write_ptr: A pointer to the write offset
- * @rb_base: A pointer to the base of the ring buffer
- * @size: The size of the ring buffer in powers of two
- */
-void scif_rb_init(struct scif_rb *rb, u32 *read_ptr, u32 *write_ptr,
-                 void *rb_base, u8 size)
-{
-       rb->rb_base = rb_base;
-       rb->size = (1 << size);
-       rb->read_ptr = read_ptr;
-       rb->write_ptr = write_ptr;
-       rb->current_read_offset = *read_ptr;
-       rb->current_write_offset = *write_ptr;
-}
-
-/* Copies a message to the ring buffer -- handles the wrap around case */
-static void memcpy_torb(struct scif_rb *rb, void *header,
-                       void *msg, u32 size)
-{
-       u32 size1, size2;
-
-       if (header + size >= rb->rb_base + rb->size) {
-               /* Need to call two copies if it wraps around */
-               size1 = (u32)(rb->rb_base + rb->size - header);
-               size2 = size - size1;
-               memcpy_toio((void __iomem __force *)header, msg, size1);
-               memcpy_toio((void __iomem __force *)rb->rb_base,
-                           msg + size1, size2);
-       } else {
-               memcpy_toio((void __iomem __force *)header, msg, size);
-       }
-}
-
-/* Copies a message from the ring buffer -- handles the wrap around case */
-static void memcpy_fromrb(struct scif_rb *rb, void *header,
-                         void *msg, u32 size)
-{
-       u32 size1, size2;
-
-       if (header + size >= rb->rb_base + rb->size) {
-               /* Need to call two copies if it wraps around */
-               size1 = (u32)(rb->rb_base + rb->size - header);
-               size2 = size - size1;
-               memcpy_fromio(msg, (void __iomem __force *)header, size1);
-               memcpy_fromio(msg + size1,
-                             (void __iomem __force *)rb->rb_base, size2);
-       } else {
-               memcpy_fromio(msg, (void __iomem __force *)header, size);
-       }
-}
-
-/**
- * scif_rb_space - Query space available for writing to the RB
- * @rb: ring buffer
- *
- * Return: size available for writing to RB in bytes.
- */
-u32 scif_rb_space(struct scif_rb *rb)
-{
-       rb->current_read_offset = *rb->read_ptr;
-       /*
-        * Update from the HW read pointer only once the peer has exposed the
-        * new empty slot. This barrier is paired with the memory barrier
-        * scif_rb_update_read_ptr()
-        */
-       mb();
-       return scif_rb_ring_space(rb->current_write_offset,
-                                 rb->current_read_offset, rb->size);
-}
-
-/**
- * scif_rb_write - Write a message to the RB
- * @rb: ring buffer
- * @msg: buffer to send the message.  Must be at least size bytes long
- * @size: the size (in bytes) to be copied to the RB
- *
- * This API does not block if there isn't enough space in the RB.
- * Returns: 0 on success or -ENOMEM on failure
- */
-int scif_rb_write(struct scif_rb *rb, void *msg, u32 size)
-{
-       void *header;
-
-       if (scif_rb_space(rb) < size)
-               return -ENOMEM;
-       header = rb->rb_base + rb->current_write_offset;
-       memcpy_torb(rb, header, msg, size);
-       /*
-        * Wait until scif_rb_commit(). Update the local ring
-        * buffer data, not the shared data until commit.
-        */
-       rb->current_write_offset =
-               (rb->current_write_offset + size) & (rb->size - 1);
-       return 0;
-}
-
-/**
- * scif_rb_commit - To submit the message to let the peer fetch it
- * @rb: ring buffer
- */
-void scif_rb_commit(struct scif_rb *rb)
-{
-       /*
-        * We must ensure ordering between the all the data committed
-        * previously before we expose the new message to the peer by
-        * updating the write_ptr. This write barrier is paired with
-        * the read barrier in scif_rb_count(..)
-        */
-       wmb();
-       WRITE_ONCE(*rb->write_ptr, rb->current_write_offset);
-#ifdef CONFIG_INTEL_MIC_CARD
-       /*
-        * X100 Si bug: For the case where a Core is performing an EXT_WR
-        * followed by a Doorbell Write, the Core must perform two EXT_WR to the
-        * same address with the same data before it does the Doorbell Write.
-        * This way, if ordering is violated for the Interrupt Message, it will
-        * fall just behind the first Posted associated with the first EXT_WR.
-        */
-       WRITE_ONCE(*rb->write_ptr, rb->current_write_offset);
-#endif
-}
-
-/**
- * scif_rb_get - To get next message from the ring buffer
- * @rb: ring buffer
- * @size: Number of bytes to be read
- *
- * Return: NULL if no bytes to be read from the ring buffer, otherwise the
- *     pointer to the next byte
- */
-static void *scif_rb_get(struct scif_rb *rb, u32 size)
-{
-       void *header = NULL;
-
-       if (scif_rb_count(rb, size) >= size)
-               header = rb->rb_base + rb->current_read_offset;
-       return header;
-}
-
-/*
- * scif_rb_get_next - Read from ring buffer.
- * @rb: ring buffer
- * @msg: buffer to hold the message.  Must be at least size bytes long
- * @size: Number of bytes to be read
- *
- * Return: number of bytes read if available bytes are >= size, otherwise
- * returns zero.
- */
-u32 scif_rb_get_next(struct scif_rb *rb, void *msg, u32 size)
-{
-       void *header = NULL;
-       int read_size = 0;
-
-       header = scif_rb_get(rb, size);
-       if (header) {
-               u32 next_cmd_offset =
-                       (rb->current_read_offset + size) & (rb->size - 1);
-
-               read_size = size;
-               rb->current_read_offset = next_cmd_offset;
-               memcpy_fromrb(rb, header, msg, size);
-       }
-       return read_size;
-}
-
-/**
- * scif_rb_update_read_ptr
- * @rb: ring buffer
- */
-void scif_rb_update_read_ptr(struct scif_rb *rb)
-{
-       u32 new_offset;
-
-       new_offset = rb->current_read_offset;
-       /*
-        * We must ensure ordering between the all the data committed or read
-        * previously before we expose the empty slot to the peer by updating
-        * the read_ptr. This barrier is paired with the memory barrier in
-        * scif_rb_space(..)
-        */
-       mb();
-       WRITE_ONCE(*rb->read_ptr, new_offset);
-#ifdef CONFIG_INTEL_MIC_CARD
-       /*
-        * X100 Si Bug: For the case where a Core is performing an EXT_WR
-        * followed by a Doorbell Write, the Core must perform two EXT_WR to the
-        * same address with the same data before it does the Doorbell Write.
-        * This way, if ordering is violated for the Interrupt Message, it will
-        * fall just behind the first Posted associated with the first EXT_WR.
-        */
-       WRITE_ONCE(*rb->read_ptr, new_offset);
-#endif
-}
-
-/**
- * scif_rb_count
- * @rb: ring buffer
- * @size: Number of bytes expected to be read
- *
- * Return: number of bytes that can be read from the RB
- */
-u32 scif_rb_count(struct scif_rb *rb, u32 size)
-{
-       if (scif_rb_ring_cnt(rb->current_write_offset,
-                            rb->current_read_offset,
-                            rb->size) < size) {
-               rb->current_write_offset = *rb->write_ptr;
-               /*
-                * Update from the HW write pointer if empty only once the peer
-                * has exposed the new message. This read barrier is paired
-                * with the write barrier in scif_rb_commit(..)
-                */
-               smp_rmb();
-       }
-       return scif_rb_ring_cnt(rb->current_write_offset,
-                               rb->current_read_offset,
-                               rb->size);
-}
diff --git a/drivers/misc/mic/scif/scif_rb.h b/drivers/misc/mic/scif/scif_rb.h
deleted file mode 100644 (file)
index 166dffe..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * 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) 2014 Intel Corporation.
- *
- * 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.
- *
- * 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.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * 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 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 SCIF driver.
- */
-#ifndef SCIF_RB_H
-#define SCIF_RB_H
-/*
- * This file describes a general purpose, byte based ring buffer. Writers to the
- * ring buffer need to synchronize using a lock. The same is true for readers,
- * although in practice, the ring buffer has a single reader. It is lockless
- * between producer and consumer so it can handle being used across the PCIe
- * bus. The ring buffer ensures that there are no reads across the PCIe bus for
- * performance reasons. Two of these are used to form a single bidirectional
- * queue-pair across PCIe.
- */
-/*
- * struct scif_rb - SCIF Ring Buffer
- *
- * @rb_base: The base of the memory used for storing RB messages
- * @read_ptr: Pointer to the read offset
- * @write_ptr: Pointer to the write offset
- * @size: Size of the memory in rb_base
- * @current_read_offset: Cached read offset for performance
- * @current_write_offset: Cached write offset for performance
- */
-struct scif_rb {
-       void *rb_base;
-       u32 *read_ptr;
-       u32 *write_ptr;
-       u32 size;
-       u32 current_read_offset;
-       u32 current_write_offset;
-};
-
-/* methods used by both */
-void scif_rb_init(struct scif_rb *rb, u32 *read_ptr, u32 *write_ptr,
-                 void *rb_base, u8 size);
-/* writer only methods */
-/* write a new command, then scif_rb_commit() */
-int scif_rb_write(struct scif_rb *rb, void *msg, u32 size);
-/* after write(), then scif_rb_commit() */
-void scif_rb_commit(struct scif_rb *rb);
-/* query space available for writing to a RB. */
-u32 scif_rb_space(struct scif_rb *rb);
-
-/* reader only methods */
-/* read a new message from the ring buffer of size bytes */
-u32 scif_rb_get_next(struct scif_rb *rb, void *msg, u32 size);
-/* update the read pointer so that the space can be reused */
-void scif_rb_update_read_ptr(struct scif_rb *rb);
-/* count the number of bytes that can be read */
-u32 scif_rb_count(struct scif_rb *rb, u32 size);
-#endif
diff --git a/drivers/misc/mic/scif/scif_rma.c b/drivers/misc/mic/scif/scif_rma.c
deleted file mode 100644 (file)
index 18fb9d8..0000000
+++ /dev/null
@@ -1,1760 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include <linux/intel-iommu.h>
-#include <linux/pagemap.h>
-#include <linux/sched/mm.h>
-#include <linux/sched/signal.h>
-
-#include "scif_main.h"
-#include "scif_map.h"
-
-/* Used to skip ulimit checks for registrations with SCIF_MAP_KERNEL flag */
-#define SCIF_MAP_ULIMIT 0x40
-
-bool scif_ulimit_check = 1;
-
-/**
- * scif_rma_ep_init:
- * @ep: end point
- *
- * Initialize RMA per EP data structures.
- */
-void scif_rma_ep_init(struct scif_endpt *ep)
-{
-       struct scif_endpt_rma_info *rma = &ep->rma_info;
-
-       mutex_init(&rma->rma_lock);
-       init_iova_domain(&rma->iovad, PAGE_SIZE, SCIF_IOVA_START_PFN);
-       spin_lock_init(&rma->tc_lock);
-       mutex_init(&rma->mmn_lock);
-       INIT_LIST_HEAD(&rma->reg_list);
-       INIT_LIST_HEAD(&rma->remote_reg_list);
-       atomic_set(&rma->tw_refcount, 0);
-       atomic_set(&rma->tcw_refcount, 0);
-       atomic_set(&rma->tcw_total_pages, 0);
-       atomic_set(&rma->fence_refcount, 0);
-
-       rma->async_list_del = 0;
-       rma->dma_chan = NULL;
-       INIT_LIST_HEAD(&rma->mmn_list);
-       INIT_LIST_HEAD(&rma->vma_list);
-       init_waitqueue_head(&rma->markwq);
-}
-
-/**
- * scif_rma_ep_can_uninit:
- * @ep: end point
- *
- * Returns 1 if an endpoint can be uninitialized and 0 otherwise.
- */
-int scif_rma_ep_can_uninit(struct scif_endpt *ep)
-{
-       int ret = 0;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Destroy RMA Info only if both lists are empty */
-       if (list_empty(&ep->rma_info.reg_list) &&
-           list_empty(&ep->rma_info.remote_reg_list) &&
-           list_empty(&ep->rma_info.mmn_list) &&
-           !atomic_read(&ep->rma_info.tw_refcount) &&
-           !atomic_read(&ep->rma_info.tcw_refcount) &&
-           !atomic_read(&ep->rma_info.fence_refcount))
-               ret = 1;
-       mutex_unlock(&ep->rma_info.rma_lock);
-       return ret;
-}
-
-/**
- * scif_create_pinned_pages:
- * @nr_pages: number of pages in window
- * @prot: read/write protection
- *
- * Allocate and prepare a set of pinned pages.
- */
-static struct scif_pinned_pages *
-scif_create_pinned_pages(int nr_pages, int prot)
-{
-       struct scif_pinned_pages *pin;
-
-       might_sleep();
-       pin = scif_zalloc(sizeof(*pin));
-       if (!pin)
-               goto error;
-
-       pin->pages = scif_zalloc(nr_pages * sizeof(*pin->pages));
-       if (!pin->pages)
-               goto error_free_pinned_pages;
-
-       pin->prot = prot;
-       pin->magic = SCIFEP_MAGIC;
-       return pin;
-
-error_free_pinned_pages:
-       scif_free(pin, sizeof(*pin));
-error:
-       return NULL;
-}
-
-/**
- * scif_destroy_pinned_pages:
- * @pin: A set of pinned pages.
- *
- * Deallocate resources for pinned pages.
- */
-static int scif_destroy_pinned_pages(struct scif_pinned_pages *pin)
-{
-       int j;
-       int writeable = pin->prot & SCIF_PROT_WRITE;
-       int kernel = SCIF_MAP_KERNEL & pin->map_flags;
-
-       if (kernel) {
-               for (j = 0; j < pin->nr_pages; j++) {
-                       if (pin->pages[j] && !kernel) {
-                               if (writeable)
-                                       set_page_dirty_lock(pin->pages[j]);
-                               put_page(pin->pages[j]);
-                       }
-               }
-       } else
-               unpin_user_pages_dirty_lock(pin->pages, pin->nr_pages,
-                                           writeable);
-       scif_free(pin->pages,
-                 pin->nr_pages * sizeof(*pin->pages));
-       scif_free(pin, sizeof(*pin));
-       return 0;
-}
-
-/*
- * scif_create_window:
- * @ep: end point
- * @nr_pages: number of pages
- * @offset: registration offset
- * @temp: true if a temporary window is being created
- *
- * Allocate and prepare a self registration window.
- */
-struct scif_window *scif_create_window(struct scif_endpt *ep, int nr_pages,
-                                      s64 offset, bool temp)
-{
-       struct scif_window *window;
-
-       might_sleep();
-       window = scif_zalloc(sizeof(*window));
-       if (!window)
-               goto error;
-
-       window->dma_addr = scif_zalloc(nr_pages * sizeof(*window->dma_addr));
-       if (!window->dma_addr)
-               goto error_free_window;
-
-       window->num_pages = scif_zalloc(nr_pages * sizeof(*window->num_pages));
-       if (!window->num_pages)
-               goto error_free_window;
-
-       window->offset = offset;
-       window->ep = (u64)ep;
-       window->magic = SCIFEP_MAGIC;
-       window->reg_state = OP_IDLE;
-       init_waitqueue_head(&window->regwq);
-       window->unreg_state = OP_IDLE;
-       init_waitqueue_head(&window->unregwq);
-       INIT_LIST_HEAD(&window->list);
-       window->type = SCIF_WINDOW_SELF;
-       window->temp = temp;
-       return window;
-
-error_free_window:
-       scif_free(window->dma_addr,
-                 nr_pages * sizeof(*window->dma_addr));
-       scif_free(window, sizeof(*window));
-error:
-       return NULL;
-}
-
-/**
- * scif_destroy_incomplete_window:
- * @ep: end point
- * @window: registration window
- *
- * Deallocate resources for self window.
- */
-static void scif_destroy_incomplete_window(struct scif_endpt *ep,
-                                          struct scif_window *window)
-{
-       int err;
-       int nr_pages = window->nr_pages;
-       struct scif_allocmsg *alloc = &window->alloc_handle;
-       struct scifmsg msg;
-
-retry:
-       /* Wait for a SCIF_ALLOC_GNT/REJ message */
-       err = wait_event_timeout(alloc->allocwq,
-                                alloc->state != OP_IN_PROGRESS,
-                                SCIF_NODE_ALIVE_TIMEOUT);
-       if (!err && scifdev_alive(ep))
-               goto retry;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       if (alloc->state == OP_COMPLETED) {
-               msg.uop = SCIF_FREE_VIRT;
-               msg.src = ep->port;
-               msg.payload[0] = ep->remote_ep;
-               msg.payload[1] = window->alloc_handle.vaddr;
-               msg.payload[2] = (u64)window;
-               msg.payload[3] = SCIF_REGISTER;
-               _scif_nodeqp_send(ep->remote_dev, &msg);
-       }
-       mutex_unlock(&ep->rma_info.rma_lock);
-
-       scif_free_window_offset(ep, window, window->offset);
-       scif_free(window->dma_addr, nr_pages * sizeof(*window->dma_addr));
-       scif_free(window->num_pages, nr_pages * sizeof(*window->num_pages));
-       scif_free(window, sizeof(*window));
-}
-
-/**
- * scif_unmap_window:
- * @remote_dev: SCIF remote device
- * @window: registration window
- *
- * Delete any DMA mappings created for a registered self window
- */
-void scif_unmap_window(struct scif_dev *remote_dev, struct scif_window *window)
-{
-       int j;
-
-       if (scif_is_iommu_enabled() && !scifdev_self(remote_dev)) {
-               if (window->st) {
-                       dma_unmap_sg(&remote_dev->sdev->dev,
-                                    window->st->sgl, window->st->nents,
-                                    DMA_BIDIRECTIONAL);
-                       sg_free_table(window->st);
-                       kfree(window->st);
-                       window->st = NULL;
-               }
-       } else {
-               for (j = 0; j < window->nr_contig_chunks; j++) {
-                       if (window->dma_addr[j]) {
-                               scif_unmap_single(window->dma_addr[j],
-                                                 remote_dev,
-                                                 window->num_pages[j] <<
-                                                 PAGE_SHIFT);
-                               window->dma_addr[j] = 0x0;
-                       }
-               }
-       }
-}
-
-static inline struct mm_struct *__scif_acquire_mm(void)
-{
-       if (scif_ulimit_check)
-               return get_task_mm(current);
-       return NULL;
-}
-
-static inline void __scif_release_mm(struct mm_struct *mm)
-{
-       if (mm)
-               mmput(mm);
-}
-
-static inline int
-__scif_dec_pinned_vm_lock(struct mm_struct *mm,
-                         int nr_pages)
-{
-       if (!mm || !nr_pages || !scif_ulimit_check)
-               return 0;
-
-       atomic64_sub(nr_pages, &mm->pinned_vm);
-       return 0;
-}
-
-static inline int __scif_check_inc_pinned_vm(struct mm_struct *mm,
-                                            int nr_pages)
-{
-       unsigned long locked, lock_limit;
-
-       if (!mm || !nr_pages || !scif_ulimit_check)
-               return 0;
-
-       lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-       locked = atomic64_add_return(nr_pages, &mm->pinned_vm);
-
-       if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
-               atomic64_sub(nr_pages, &mm->pinned_vm);
-               dev_err(scif_info.mdev.this_device,
-                       "locked(%lu) > lock_limit(%lu)\n",
-                       locked, lock_limit);
-               return -ENOMEM;
-       }
-       return 0;
-}
-
-/**
- * scif_destroy_window:
- * @ep: end point
- * @window: registration window
- *
- * Deallocate resources for self window.
- */
-int scif_destroy_window(struct scif_endpt *ep, struct scif_window *window)
-{
-       int j;
-       struct scif_pinned_pages *pinned_pages = window->pinned_pages;
-       int nr_pages = window->nr_pages;
-
-       might_sleep();
-       if (!window->temp && window->mm) {
-               __scif_dec_pinned_vm_lock(window->mm, window->nr_pages);
-               __scif_release_mm(window->mm);
-               window->mm = NULL;
-       }
-
-       scif_free_window_offset(ep, window, window->offset);
-       scif_unmap_window(ep->remote_dev, window);
-       /*
-        * Decrement references for this set of pinned pages from
-        * this window.
-        */
-       j = atomic_sub_return(1, &pinned_pages->ref_count);
-       if (j < 0)
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d incorrect ref count %d\n",
-                       __func__, __LINE__, j);
-       /*
-        * If the ref count for pinned_pages is zero then someone
-        * has already called scif_unpin_pages() for it and we should
-        * destroy the page cache.
-        */
-       if (!j)
-               scif_destroy_pinned_pages(window->pinned_pages);
-       scif_free(window->dma_addr, nr_pages * sizeof(*window->dma_addr));
-       scif_free(window->num_pages, nr_pages * sizeof(*window->num_pages));
-       window->magic = 0;
-       scif_free(window, sizeof(*window));
-       return 0;
-}
-
-/**
- * scif_create_remote_lookup:
- * @remote_dev: SCIF remote device
- * @window: remote window
- *
- * Allocate and prepare lookup entries for the remote
- * end to copy over the physical addresses.
- * Returns 0 on success and appropriate errno on failure.
- */
-static int scif_create_remote_lookup(struct scif_dev *remote_dev,
-                                    struct scif_window *window)
-{
-       int i, j, err = 0;
-       int nr_pages = window->nr_pages;
-       bool vmalloc_dma_phys, vmalloc_num_pages;
-
-       might_sleep();
-       /* Map window */
-       err = scif_map_single(&window->mapped_offset,
-                             window, remote_dev, sizeof(*window));
-       if (err)
-               goto error_window;
-
-       /* Compute the number of lookup entries. 21 == 2MB Shift */
-       window->nr_lookup = ALIGN(nr_pages * PAGE_SIZE,
-                                       ((2) * 1024 * 1024)) >> 21;
-
-       window->dma_addr_lookup.lookup =
-               scif_alloc_coherent(&window->dma_addr_lookup.offset,
-                                   remote_dev, window->nr_lookup *
-                                   sizeof(*window->dma_addr_lookup.lookup),
-                                   GFP_KERNEL | __GFP_ZERO);
-       if (!window->dma_addr_lookup.lookup) {
-               err = -ENOMEM;
-               goto error_window;
-       }
-
-       window->num_pages_lookup.lookup =
-               scif_alloc_coherent(&window->num_pages_lookup.offset,
-                                   remote_dev, window->nr_lookup *
-                                   sizeof(*window->num_pages_lookup.lookup),
-                                   GFP_KERNEL | __GFP_ZERO);
-       if (!window->num_pages_lookup.lookup) {
-               err = -ENOMEM;
-               goto error_window;
-       }
-
-       vmalloc_dma_phys = is_vmalloc_addr(&window->dma_addr[0]);
-       vmalloc_num_pages = is_vmalloc_addr(&window->num_pages[0]);
-
-       /* Now map each of the pages containing physical addresses */
-       for (i = 0, j = 0; i < nr_pages; i += SCIF_NR_ADDR_IN_PAGE, j++) {
-               err = scif_map_page(&window->dma_addr_lookup.lookup[j],
-                                   vmalloc_dma_phys ?
-                                   vmalloc_to_page(&window->dma_addr[i]) :
-                                   virt_to_page(&window->dma_addr[i]),
-                                   remote_dev);
-               if (err)
-                       goto error_window;
-               err = scif_map_page(&window->num_pages_lookup.lookup[j],
-                                   vmalloc_num_pages ?
-                                   vmalloc_to_page(&window->num_pages[i]) :
-                                   virt_to_page(&window->num_pages[i]),
-                                   remote_dev);
-               if (err)
-                       goto error_window;
-       }
-       return 0;
-error_window:
-       return err;
-}
-
-/**
- * scif_destroy_remote_lookup:
- * @remote_dev: SCIF remote device
- * @window: remote window
- *
- * Destroy lookup entries used for the remote
- * end to copy over the physical addresses.
- */
-static void scif_destroy_remote_lookup(struct scif_dev *remote_dev,
-                                      struct scif_window *window)
-{
-       int i, j;
-
-       if (window->nr_lookup) {
-               struct scif_rma_lookup *lup = &window->dma_addr_lookup;
-               struct scif_rma_lookup *npup = &window->num_pages_lookup;
-
-               for (i = 0, j = 0; i < window->nr_pages;
-                       i += SCIF_NR_ADDR_IN_PAGE, j++) {
-                       if (lup->lookup && lup->lookup[j])
-                               scif_unmap_single(lup->lookup[j],
-                                                 remote_dev,
-                                                 PAGE_SIZE);
-                       if (npup->lookup && npup->lookup[j])
-                               scif_unmap_single(npup->lookup[j],
-                                                 remote_dev,
-                                                 PAGE_SIZE);
-               }
-               if (lup->lookup)
-                       scif_free_coherent(lup->lookup, lup->offset,
-                                          remote_dev, window->nr_lookup *
-                                          sizeof(*lup->lookup));
-               if (npup->lookup)
-                       scif_free_coherent(npup->lookup, npup->offset,
-                                          remote_dev, window->nr_lookup *
-                                          sizeof(*npup->lookup));
-               if (window->mapped_offset)
-                       scif_unmap_single(window->mapped_offset,
-                                         remote_dev, sizeof(*window));
-               window->nr_lookup = 0;
-       }
-}
-
-/**
- * scif_create_remote_window:
- * @scifdev:  SCIF device
- * @nr_pages: number of pages in window
- *
- * Allocate and prepare a remote registration window.
- */
-static struct scif_window *
-scif_create_remote_window(struct scif_dev *scifdev, int nr_pages)
-{
-       struct scif_window *window;
-
-       might_sleep();
-       window = scif_zalloc(sizeof(*window));
-       if (!window)
-               goto error_ret;
-
-       window->magic = SCIFEP_MAGIC;
-       window->nr_pages = nr_pages;
-
-       window->dma_addr = scif_zalloc(nr_pages * sizeof(*window->dma_addr));
-       if (!window->dma_addr)
-               goto error_window;
-
-       window->num_pages = scif_zalloc(nr_pages *
-                                       sizeof(*window->num_pages));
-       if (!window->num_pages)
-               goto error_window;
-
-       if (scif_create_remote_lookup(scifdev, window))
-               goto error_window;
-
-       window->type = SCIF_WINDOW_PEER;
-       window->unreg_state = OP_IDLE;
-       INIT_LIST_HEAD(&window->list);
-       return window;
-error_window:
-       scif_destroy_remote_window(window);
-error_ret:
-       return NULL;
-}
-
-/**
- * scif_destroy_remote_window:
- * @window: remote registration window
- *
- * Deallocate resources for remote window.
- */
-void
-scif_destroy_remote_window(struct scif_window *window)
-{
-       scif_free(window->dma_addr, window->nr_pages *
-                 sizeof(*window->dma_addr));
-       scif_free(window->num_pages, window->nr_pages *
-                 sizeof(*window->num_pages));
-       window->magic = 0;
-       scif_free(window, sizeof(*window));
-}
-
-/**
- * scif_iommu_map: create DMA mappings if the IOMMU is enabled
- * @remote_dev: SCIF remote device
- * @window: remote registration window
- *
- * Map the physical pages using dma_map_sg(..) and then detect the number
- * of contiguous DMA mappings allocated
- */
-static int scif_iommu_map(struct scif_dev *remote_dev,
-                         struct scif_window *window)
-{
-       struct scatterlist *sg;
-       int i, err;
-       scif_pinned_pages_t pin = window->pinned_pages;
-
-       window->st = kzalloc(sizeof(*window->st), GFP_KERNEL);
-       if (!window->st)
-               return -ENOMEM;
-
-       err = sg_alloc_table(window->st, window->nr_pages, GFP_KERNEL);
-       if (err)
-               return err;
-
-       for_each_sg(window->st->sgl, sg, window->st->nents, i)
-               sg_set_page(sg, pin->pages[i], PAGE_SIZE, 0x0);
-
-       err = dma_map_sg(&remote_dev->sdev->dev, window->st->sgl,
-                        window->st->nents, DMA_BIDIRECTIONAL);
-       if (!err)
-               return -ENOMEM;
-       /* Detect contiguous ranges of DMA mappings */
-       sg = window->st->sgl;
-       for (i = 0; sg; i++) {
-               dma_addr_t last_da;
-
-               window->dma_addr[i] = sg_dma_address(sg);
-               window->num_pages[i] = sg_dma_len(sg) >> PAGE_SHIFT;
-               last_da = sg_dma_address(sg) + sg_dma_len(sg);
-               while ((sg = sg_next(sg)) && sg_dma_address(sg) == last_da) {
-                       window->num_pages[i] +=
-                               (sg_dma_len(sg) >> PAGE_SHIFT);
-                       last_da = window->dma_addr[i] +
-                               sg_dma_len(sg);
-               }
-               window->nr_contig_chunks++;
-       }
-       return 0;
-}
-
-/**
- * scif_map_window:
- * @remote_dev: SCIF remote device
- * @window: self registration window
- *
- * Map pages of a window into the aperture/PCI.
- * Also determine addresses required for DMA.
- */
-int
-scif_map_window(struct scif_dev *remote_dev, struct scif_window *window)
-{
-       int i, j, k, err = 0, nr_contig_pages;
-       scif_pinned_pages_t pin;
-       phys_addr_t phys_prev, phys_curr;
-
-       might_sleep();
-
-       pin = window->pinned_pages;
-
-       if (intel_iommu_enabled && !scifdev_self(remote_dev))
-               return scif_iommu_map(remote_dev, window);
-
-       for (i = 0, j = 0; i < window->nr_pages; i += nr_contig_pages, j++) {
-               phys_prev = page_to_phys(pin->pages[i]);
-               nr_contig_pages = 1;
-
-               /* Detect physically contiguous chunks */
-               for (k = i + 1; k < window->nr_pages; k++) {
-                       phys_curr = page_to_phys(pin->pages[k]);
-                       if (phys_curr != (phys_prev + PAGE_SIZE))
-                               break;
-                       phys_prev = phys_curr;
-                       nr_contig_pages++;
-               }
-               window->num_pages[j] = nr_contig_pages;
-               window->nr_contig_chunks++;
-               if (scif_is_mgmt_node()) {
-                       /*
-                        * Management node has to deal with SMPT on X100 and
-                        * hence the DMA mapping is required
-                        */
-                       err = scif_map_single(&window->dma_addr[j],
-                                             phys_to_virt(page_to_phys(
-                                                          pin->pages[i])),
-                                             remote_dev,
-                                             nr_contig_pages << PAGE_SHIFT);
-                       if (err)
-                               return err;
-               } else {
-                       window->dma_addr[j] = page_to_phys(pin->pages[i]);
-               }
-       }
-       return err;
-}
-
-/**
- * scif_send_scif_unregister:
- * @ep: end point
- * @window: self registration window
- *
- * Send a SCIF_UNREGISTER message.
- */
-static int scif_send_scif_unregister(struct scif_endpt *ep,
-                                    struct scif_window *window)
-{
-       struct scifmsg msg;
-
-       msg.uop = SCIF_UNREGISTER;
-       msg.src = ep->port;
-       msg.payload[0] = window->alloc_handle.vaddr;
-       msg.payload[1] = (u64)window;
-       return scif_nodeqp_send(ep->remote_dev, &msg);
-}
-
-/**
- * scif_unregister_window:
- * @window: self registration window
- *
- * Send an unregistration request and wait for a response.
- */
-int scif_unregister_window(struct scif_window *window)
-{
-       int err = 0;
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-       bool send_msg = false;
-
-       might_sleep();
-       switch (window->unreg_state) {
-       case OP_IDLE:
-       {
-               window->unreg_state = OP_IN_PROGRESS;
-               send_msg = true;
-       }
-               fallthrough;
-       case OP_IN_PROGRESS:
-       {
-               scif_get_window(window, 1);
-               mutex_unlock(&ep->rma_info.rma_lock);
-               if (send_msg) {
-                       err = scif_send_scif_unregister(ep, window);
-                       if (err) {
-                               window->unreg_state = OP_COMPLETED;
-                               goto done;
-                       }
-               } else {
-                       /* Return ENXIO since unregistration is in progress */
-                       mutex_lock(&ep->rma_info.rma_lock);
-                       return -ENXIO;
-               }
-retry:
-               /* Wait for a SCIF_UNREGISTER_(N)ACK message */
-               err = wait_event_timeout(window->unregwq,
-                                        window->unreg_state != OP_IN_PROGRESS,
-                                        SCIF_NODE_ALIVE_TIMEOUT);
-               if (!err && scifdev_alive(ep))
-                       goto retry;
-               if (!err) {
-                       err = -ENODEV;
-                       window->unreg_state = OP_COMPLETED;
-                       dev_err(scif_info.mdev.this_device,
-                               "%s %d err %d\n", __func__, __LINE__, err);
-               }
-               if (err > 0)
-                       err = 0;
-done:
-               mutex_lock(&ep->rma_info.rma_lock);
-               scif_put_window(window, 1);
-               break;
-       }
-       case OP_FAILED:
-       {
-               if (!scifdev_alive(ep)) {
-                       err = -ENODEV;
-                       window->unreg_state = OP_COMPLETED;
-               }
-               break;
-       }
-       case OP_COMPLETED:
-               break;
-       default:
-               err = -ENODEV;
-       }
-
-       if (window->unreg_state == OP_COMPLETED && window->ref_count)
-               scif_put_window(window, window->nr_pages);
-
-       if (!window->ref_count) {
-               atomic_inc(&ep->rma_info.tw_refcount);
-               list_del_init(&window->list);
-               scif_free_window_offset(ep, window, window->offset);
-               mutex_unlock(&ep->rma_info.rma_lock);
-               if ((!!(window->pinned_pages->map_flags & SCIF_MAP_KERNEL)) &&
-                   scifdev_alive(ep)) {
-                       scif_drain_dma_intr(ep->remote_dev->sdev,
-                                           ep->rma_info.dma_chan);
-               } else {
-                       if (!__scif_dec_pinned_vm_lock(window->mm,
-                                                      window->nr_pages)) {
-                               __scif_release_mm(window->mm);
-                               window->mm = NULL;
-                       }
-               }
-               scif_queue_for_cleanup(window, &scif_info.rma);
-               mutex_lock(&ep->rma_info.rma_lock);
-       }
-       return err;
-}
-
-/**
- * scif_send_alloc_request:
- * @ep: end point
- * @window: self registration window
- *
- * Send a remote window allocation request
- */
-static int scif_send_alloc_request(struct scif_endpt *ep,
-                                  struct scif_window *window)
-{
-       struct scifmsg msg;
-       struct scif_allocmsg *alloc = &window->alloc_handle;
-
-       /* Set up the Alloc Handle */
-       alloc->state = OP_IN_PROGRESS;
-       init_waitqueue_head(&alloc->allocwq);
-
-       /* Send out an allocation request */
-       msg.uop = SCIF_ALLOC_REQ;
-       msg.payload[1] = window->nr_pages;
-       msg.payload[2] = (u64)&window->alloc_handle;
-       return _scif_nodeqp_send(ep->remote_dev, &msg);
-}
-
-/**
- * scif_prep_remote_window:
- * @ep: end point
- * @window: self registration window
- *
- * Send a remote window allocation request, wait for an allocation response,
- * and prepares the remote window by copying over the page lists
- */
-static int scif_prep_remote_window(struct scif_endpt *ep,
-                                  struct scif_window *window)
-{
-       struct scifmsg msg;
-       struct scif_window *remote_window;
-       struct scif_allocmsg *alloc = &window->alloc_handle;
-       dma_addr_t *dma_phys_lookup, *tmp, *num_pages_lookup, *tmp1;
-       int i = 0, j = 0;
-       int nr_contig_chunks, loop_nr_contig_chunks;
-       int remaining_nr_contig_chunks, nr_lookup;
-       int err, map_err;
-
-       map_err = scif_map_window(ep->remote_dev, window);
-       if (map_err)
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d map_err %d\n", __func__, __LINE__, map_err);
-       remaining_nr_contig_chunks = window->nr_contig_chunks;
-       nr_contig_chunks = window->nr_contig_chunks;
-retry:
-       /* Wait for a SCIF_ALLOC_GNT/REJ message */
-       err = wait_event_timeout(alloc->allocwq,
-                                alloc->state != OP_IN_PROGRESS,
-                                SCIF_NODE_ALIVE_TIMEOUT);
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Synchronize with the thread waking up allocwq */
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (!err && scifdev_alive(ep))
-               goto retry;
-
-       if (!err)
-               err = -ENODEV;
-
-       if (err > 0)
-               err = 0;
-       else
-               return err;
-
-       /* Bail out. The remote end rejected this request */
-       if (alloc->state == OP_FAILED)
-               return -ENOMEM;
-
-       if (map_err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, map_err);
-               msg.uop = SCIF_FREE_VIRT;
-               msg.src = ep->port;
-               msg.payload[0] = ep->remote_ep;
-               msg.payload[1] = window->alloc_handle.vaddr;
-               msg.payload[2] = (u64)window;
-               msg.payload[3] = SCIF_REGISTER;
-               spin_lock(&ep->lock);
-               if (ep->state == SCIFEP_CONNECTED)
-                       err = _scif_nodeqp_send(ep->remote_dev, &msg);
-               else
-                       err = -ENOTCONN;
-               spin_unlock(&ep->lock);
-               return err;
-       }
-
-       remote_window = scif_ioremap(alloc->phys_addr, sizeof(*window),
-                                    ep->remote_dev);
-
-       /* Compute the number of lookup entries. 21 == 2MB Shift */
-       nr_lookup = ALIGN(nr_contig_chunks, SCIF_NR_ADDR_IN_PAGE)
-                         >> ilog2(SCIF_NR_ADDR_IN_PAGE);
-
-       dma_phys_lookup =
-               scif_ioremap(remote_window->dma_addr_lookup.offset,
-                            nr_lookup *
-                            sizeof(*remote_window->dma_addr_lookup.lookup),
-                            ep->remote_dev);
-       num_pages_lookup =
-               scif_ioremap(remote_window->num_pages_lookup.offset,
-                            nr_lookup *
-                            sizeof(*remote_window->num_pages_lookup.lookup),
-                            ep->remote_dev);
-
-       while (remaining_nr_contig_chunks) {
-               loop_nr_contig_chunks = min_t(int, remaining_nr_contig_chunks,
-                                             (int)SCIF_NR_ADDR_IN_PAGE);
-               /* #1/2 - Copy  physical addresses over to the remote side */
-
-               /* #2/2 - Copy DMA addresses (addresses that are fed into the
-                * DMA engine) We transfer bus addresses which are then
-                * converted into a MIC physical address on the remote
-                * side if it is a MIC, if the remote node is a mgmt node we
-                * transfer the MIC physical address
-                */
-               tmp = scif_ioremap(dma_phys_lookup[j],
-                                  loop_nr_contig_chunks *
-                                  sizeof(*window->dma_addr),
-                                  ep->remote_dev);
-               tmp1 = scif_ioremap(num_pages_lookup[j],
-                                   loop_nr_contig_chunks *
-                                   sizeof(*window->num_pages),
-                                   ep->remote_dev);
-               if (scif_is_mgmt_node()) {
-                       memcpy_toio((void __force __iomem *)tmp,
-                                   &window->dma_addr[i], loop_nr_contig_chunks
-                                   * sizeof(*window->dma_addr));
-                       memcpy_toio((void __force __iomem *)tmp1,
-                                   &window->num_pages[i], loop_nr_contig_chunks
-                                   * sizeof(*window->num_pages));
-               } else {
-                       if (scifdev_is_p2p(ep->remote_dev)) {
-                               /*
-                                * add remote node's base address for this node
-                                * to convert it into a MIC address
-                                */
-                               int m;
-                               dma_addr_t dma_addr;
-
-                               for (m = 0; m < loop_nr_contig_chunks; m++) {
-                                       dma_addr = window->dma_addr[i + m] +
-                                               ep->remote_dev->base_addr;
-                                       writeq(dma_addr,
-                                              (void __force __iomem *)&tmp[m]);
-                               }
-                               memcpy_toio((void __force __iomem *)tmp1,
-                                           &window->num_pages[i],
-                                           loop_nr_contig_chunks
-                                           * sizeof(*window->num_pages));
-                       } else {
-                               /* Mgmt node or loopback - transfer DMA
-                                * addresses as is, this is the same as a
-                                * MIC physical address (we use the dma_addr
-                                * and not the phys_addr array since the
-                                * phys_addr is only setup if there is a mmap()
-                                * request from the mgmt node)
-                                */
-                               memcpy_toio((void __force __iomem *)tmp,
-                                           &window->dma_addr[i],
-                                           loop_nr_contig_chunks *
-                                           sizeof(*window->dma_addr));
-                               memcpy_toio((void __force __iomem *)tmp1,
-                                           &window->num_pages[i],
-                                           loop_nr_contig_chunks *
-                                           sizeof(*window->num_pages));
-                       }
-               }
-               remaining_nr_contig_chunks -= loop_nr_contig_chunks;
-               i += loop_nr_contig_chunks;
-               j++;
-               scif_iounmap(tmp, loop_nr_contig_chunks *
-                            sizeof(*window->dma_addr), ep->remote_dev);
-               scif_iounmap(tmp1, loop_nr_contig_chunks *
-                            sizeof(*window->num_pages), ep->remote_dev);
-       }
-
-       /* Prepare the remote window for the peer */
-       remote_window->peer_window = (u64)window;
-       remote_window->offset = window->offset;
-       remote_window->prot = window->prot;
-       remote_window->nr_contig_chunks = nr_contig_chunks;
-       remote_window->ep = ep->remote_ep;
-       scif_iounmap(num_pages_lookup,
-                    nr_lookup *
-                    sizeof(*remote_window->num_pages_lookup.lookup),
-                    ep->remote_dev);
-       scif_iounmap(dma_phys_lookup,
-                    nr_lookup *
-                    sizeof(*remote_window->dma_addr_lookup.lookup),
-                    ep->remote_dev);
-       scif_iounmap(remote_window, sizeof(*remote_window), ep->remote_dev);
-       window->peer_window = alloc->vaddr;
-       return err;
-}
-
-/**
- * scif_send_scif_register:
- * @ep: end point
- * @window: self registration window
- *
- * Send a SCIF_REGISTER message if EP is connected and wait for a
- * SCIF_REGISTER_(N)ACK message else send a SCIF_FREE_VIRT
- * message so that the peer can free its remote window allocated earlier.
- */
-static int scif_send_scif_register(struct scif_endpt *ep,
-                                  struct scif_window *window)
-{
-       int err = 0;
-       struct scifmsg msg;
-
-       msg.src = ep->port;
-       msg.payload[0] = ep->remote_ep;
-       msg.payload[1] = window->alloc_handle.vaddr;
-       msg.payload[2] = (u64)window;
-       spin_lock(&ep->lock);
-       if (ep->state == SCIFEP_CONNECTED) {
-               msg.uop = SCIF_REGISTER;
-               window->reg_state = OP_IN_PROGRESS;
-               err = _scif_nodeqp_send(ep->remote_dev, &msg);
-               spin_unlock(&ep->lock);
-               if (!err) {
-retry:
-                       /* Wait for a SCIF_REGISTER_(N)ACK message */
-                       err = wait_event_timeout(window->regwq,
-                                                window->reg_state !=
-                                                OP_IN_PROGRESS,
-                                                SCIF_NODE_ALIVE_TIMEOUT);
-                       if (!err && scifdev_alive(ep))
-                               goto retry;
-                       err = !err ? -ENODEV : 0;
-                       if (window->reg_state == OP_FAILED)
-                               err = -ENOTCONN;
-               }
-       } else {
-               msg.uop = SCIF_FREE_VIRT;
-               msg.payload[3] = SCIF_REGISTER;
-               err = _scif_nodeqp_send(ep->remote_dev, &msg);
-               spin_unlock(&ep->lock);
-               if (!err)
-                       err = -ENOTCONN;
-       }
-       return err;
-}
-
-/**
- * scif_get_window_offset:
- * @ep: end point descriptor
- * @flags: flags
- * @offset: offset hint
- * @num_pages: number of pages
- * @out_offset: computed offset returned by reference.
- *
- * Compute/Claim a new offset for this EP.
- */
-int scif_get_window_offset(struct scif_endpt *ep, int flags, s64 offset,
-                          int num_pages, s64 *out_offset)
-{
-       s64 page_index;
-       struct iova *iova_ptr;
-       int err = 0;
-
-       if (flags & SCIF_MAP_FIXED) {
-               page_index = SCIF_IOVA_PFN(offset);
-               iova_ptr = reserve_iova(&ep->rma_info.iovad, page_index,
-                                       page_index + num_pages - 1);
-               if (!iova_ptr)
-                       err = -EADDRINUSE;
-       } else {
-               iova_ptr = alloc_iova(&ep->rma_info.iovad, num_pages,
-                                     SCIF_DMA_63BIT_PFN - 1, 0);
-               if (!iova_ptr)
-                       err = -ENOMEM;
-       }
-       if (!err)
-               *out_offset = (iova_ptr->pfn_lo) << PAGE_SHIFT;
-       return err;
-}
-
-/**
- * scif_free_window_offset:
- * @ep: end point descriptor
- * @window: registration window
- * @offset: Offset to be freed
- *
- * Free offset for this EP. The callee is supposed to grab
- * the RMA mutex before calling this API.
- */
-void scif_free_window_offset(struct scif_endpt *ep,
-                            struct scif_window *window, s64 offset)
-{
-       if ((window && !window->offset_freed) || !window) {
-               free_iova(&ep->rma_info.iovad, offset >> PAGE_SHIFT);
-               if (window)
-                       window->offset_freed = true;
-       }
-}
-
-/**
- * scif_alloc_req: Respond to SCIF_ALLOC_REQ interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remote side is requesting a memory allocation.
- */
-void scif_alloc_req(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       int err;
-       struct scif_window *window = NULL;
-       int nr_pages = msg->payload[1];
-
-       window = scif_create_remote_window(scifdev, nr_pages);
-       if (!window) {
-               err = -ENOMEM;
-               goto error;
-       }
-
-       /* The peer's allocation request is granted */
-       msg->uop = SCIF_ALLOC_GNT;
-       msg->payload[0] = (u64)window;
-       msg->payload[1] = window->mapped_offset;
-       err = scif_nodeqp_send(scifdev, msg);
-       if (err)
-               scif_destroy_remote_window(window);
-       return;
-error:
-       /* The peer's allocation request is rejected */
-       dev_err(&scifdev->sdev->dev,
-               "%s %d error %d alloc_ptr %p nr_pages 0x%x\n",
-               __func__, __LINE__, err, window, nr_pages);
-       msg->uop = SCIF_ALLOC_REJ;
-       scif_nodeqp_send(scifdev, msg);
-}
-
-/**
- * scif_alloc_gnt_rej: Respond to SCIF_ALLOC_GNT/REJ interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remote side responded to a memory allocation.
- */
-void scif_alloc_gnt_rej(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_allocmsg *handle = (struct scif_allocmsg *)msg->payload[2];
-       struct scif_window *window = container_of(handle, struct scif_window,
-                                                 alloc_handle);
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       handle->vaddr = msg->payload[0];
-       handle->phys_addr = msg->payload[1];
-       if (msg->uop == SCIF_ALLOC_GNT)
-               handle->state = OP_COMPLETED;
-       else
-               handle->state = OP_FAILED;
-       wake_up(&handle->allocwq);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-/**
- * scif_free_virt: Respond to SCIF_FREE_VIRT interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Free up memory kmalloc'd earlier.
- */
-void scif_free_virt(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_window *window = (struct scif_window *)msg->payload[1];
-
-       scif_destroy_remote_window(window);
-}
-
-static void
-scif_fixup_aper_base(struct scif_dev *dev, struct scif_window *window)
-{
-       int j;
-       struct scif_hw_dev *sdev = dev->sdev;
-       phys_addr_t apt_base = 0;
-
-       /*
-        * Add the aperture base if the DMA address is not card relative
-        * since the DMA addresses need to be an offset into the bar
-        */
-       if (!scifdev_self(dev) && window->type == SCIF_WINDOW_PEER &&
-           sdev->aper && !sdev->card_rel_da)
-               apt_base = sdev->aper->pa;
-       else
-               return;
-
-       for (j = 0; j < window->nr_contig_chunks; j++) {
-               if (window->num_pages[j])
-                       window->dma_addr[j] += apt_base;
-               else
-                       break;
-       }
-}
-
-/**
- * scif_recv_reg: Respond to SCIF_REGISTER interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Update remote window list with a new registered window.
- */
-void scif_recv_reg(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)msg->payload[0];
-       struct scif_window *window =
-               (struct scif_window *)msg->payload[1];
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       spin_lock(&ep->lock);
-       if (ep->state == SCIFEP_CONNECTED) {
-               msg->uop = SCIF_REGISTER_ACK;
-               scif_nodeqp_send(ep->remote_dev, msg);
-               scif_fixup_aper_base(ep->remote_dev, window);
-               /* No further failures expected. Insert new window */
-               scif_insert_window(window, &ep->rma_info.remote_reg_list);
-       } else {
-               msg->uop = SCIF_REGISTER_NACK;
-               scif_nodeqp_send(ep->remote_dev, msg);
-       }
-       spin_unlock(&ep->lock);
-       mutex_unlock(&ep->rma_info.rma_lock);
-       /* free up any lookup resources now that page lists are transferred */
-       scif_destroy_remote_lookup(ep->remote_dev, window);
-       /*
-        * We could not insert the window but we need to
-        * destroy the window.
-        */
-       if (msg->uop == SCIF_REGISTER_NACK)
-               scif_destroy_remote_window(window);
-}
-
-/**
- * scif_recv_unreg: Respond to SCIF_UNREGISTER interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Remove window from remote registration list;
- */
-void scif_recv_unreg(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_rma_req req;
-       struct scif_window *window = NULL;
-       struct scif_window *recv_window =
-               (struct scif_window *)msg->payload[0];
-       struct scif_endpt *ep;
-       int del_window = 0;
-
-       ep = (struct scif_endpt *)recv_window->ep;
-       req.out_window = &window;
-       req.offset = recv_window->offset;
-       req.prot = 0;
-       req.nr_bytes = recv_window->nr_pages << PAGE_SHIFT;
-       req.type = SCIF_WINDOW_FULL;
-       req.head = &ep->rma_info.remote_reg_list;
-       msg->payload[0] = ep->remote_ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Does a valid window exist? */
-       if (scif_query_window(&req)) {
-               dev_err(&scifdev->sdev->dev,
-                       "%s %d -ENXIO\n", __func__, __LINE__);
-               msg->uop = SCIF_UNREGISTER_ACK;
-               goto error;
-       }
-       if (window) {
-               if (window->ref_count)
-                       scif_put_window(window, window->nr_pages);
-               else
-                       dev_err(&scifdev->sdev->dev,
-                               "%s %d ref count should be +ve\n",
-                               __func__, __LINE__);
-               window->unreg_state = OP_COMPLETED;
-               if (!window->ref_count) {
-                       msg->uop = SCIF_UNREGISTER_ACK;
-                       atomic_inc(&ep->rma_info.tw_refcount);
-                       ep->rma_info.async_list_del = 1;
-                       list_del_init(&window->list);
-                       del_window = 1;
-               } else {
-                       /* NACK! There are valid references to this window */
-                       msg->uop = SCIF_UNREGISTER_NACK;
-               }
-       } else {
-               /* The window did not make its way to the list at all. ACK */
-               msg->uop = SCIF_UNREGISTER_ACK;
-               scif_destroy_remote_window(recv_window);
-       }
-error:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (del_window)
-               scif_drain_dma_intr(ep->remote_dev->sdev,
-                                   ep->rma_info.dma_chan);
-       scif_nodeqp_send(ep->remote_dev, msg);
-       if (del_window)
-               scif_queue_for_cleanup(window, &scif_info.rma);
-}
-
-/**
- * scif_recv_reg_ack: Respond to SCIF_REGISTER_ACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Wake up the window waiting to complete registration.
- */
-void scif_recv_reg_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_window *window =
-               (struct scif_window *)msg->payload[2];
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       window->reg_state = OP_COMPLETED;
-       wake_up(&window->regwq);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-/**
- * scif_recv_reg_nack: Respond to SCIF_REGISTER_NACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Wake up the window waiting to inform it that registration
- * cannot be completed.
- */
-void scif_recv_reg_nack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_window *window =
-               (struct scif_window *)msg->payload[2];
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       window->reg_state = OP_FAILED;
-       wake_up(&window->regwq);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-/**
- * scif_recv_unreg_ack: Respond to SCIF_UNREGISTER_ACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Wake up the window waiting to complete unregistration.
- */
-void scif_recv_unreg_ack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_window *window =
-               (struct scif_window *)msg->payload[1];
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       window->unreg_state = OP_COMPLETED;
-       wake_up(&window->unregwq);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-/**
- * scif_recv_unreg_nack: Respond to SCIF_UNREGISTER_NACK interrupt message
- * @scifdev:    SCIF device
- * @msg:        Interrupt message
- *
- * Wake up the window waiting to inform it that unregistration
- * cannot be completed immediately.
- */
-void scif_recv_unreg_nack(struct scif_dev *scifdev, struct scifmsg *msg)
-{
-       struct scif_window *window =
-               (struct scif_window *)msg->payload[1];
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       window->unreg_state = OP_FAILED;
-       wake_up(&window->unregwq);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-int __scif_pin_pages(void *addr, size_t len, int *out_prot,
-                    int map_flags, scif_pinned_pages_t *pages)
-{
-       struct scif_pinned_pages *pinned_pages;
-       int nr_pages, err = 0, i;
-       bool vmalloc_addr = false;
-       bool try_upgrade = false;
-       int prot = *out_prot;
-       int ulimit = 0;
-       struct mm_struct *mm = NULL;
-
-       /* Unsupported flags */
-       if (map_flags & ~(SCIF_MAP_KERNEL | SCIF_MAP_ULIMIT))
-               return -EINVAL;
-       ulimit = !!(map_flags & SCIF_MAP_ULIMIT);
-
-       /* Unsupported protection requested */
-       if (prot & ~(SCIF_PROT_READ | SCIF_PROT_WRITE))
-               return -EINVAL;
-
-       /* addr/len must be page aligned. len should be non zero */
-       if (!len ||
-           (ALIGN((u64)addr, PAGE_SIZE) != (u64)addr) ||
-           (ALIGN((u64)len, PAGE_SIZE) != (u64)len))
-               return -EINVAL;
-
-       might_sleep();
-
-       nr_pages = len >> PAGE_SHIFT;
-
-       /* Allocate a set of pinned pages */
-       pinned_pages = scif_create_pinned_pages(nr_pages, prot);
-       if (!pinned_pages)
-               return -ENOMEM;
-
-       if (map_flags & SCIF_MAP_KERNEL) {
-               if (is_vmalloc_addr(addr))
-                       vmalloc_addr = true;
-
-               for (i = 0; i < nr_pages; i++) {
-                       if (vmalloc_addr)
-                               pinned_pages->pages[i] =
-                                       vmalloc_to_page(addr + (i * PAGE_SIZE));
-                       else
-                               pinned_pages->pages[i] =
-                                       virt_to_page(addr + (i * PAGE_SIZE));
-               }
-               pinned_pages->nr_pages = nr_pages;
-               pinned_pages->map_flags = SCIF_MAP_KERNEL;
-       } else {
-               /*
-                * SCIF supports registration caching. If a registration has
-                * been requested with read only permissions, then we try
-                * to pin the pages with RW permissions so that a subsequent
-                * transfer with RW permission can hit the cache instead of
-                * invalidating it. If the upgrade fails with RW then we
-                * revert back to R permission and retry
-                */
-               if (prot == SCIF_PROT_READ)
-                       try_upgrade = true;
-               prot |= SCIF_PROT_WRITE;
-retry:
-               mm = current->mm;
-               if (ulimit) {
-                       err = __scif_check_inc_pinned_vm(mm, nr_pages);
-                       if (err) {
-                               pinned_pages->nr_pages = 0;
-                               goto error_unmap;
-                       }
-               }
-
-               pinned_pages->nr_pages = pin_user_pages_fast(
-                               (u64)addr,
-                               nr_pages,
-                               (prot & SCIF_PROT_WRITE) ? FOLL_WRITE : 0,
-                               pinned_pages->pages);
-               if (nr_pages != pinned_pages->nr_pages) {
-                       if (pinned_pages->nr_pages < 0)
-                               pinned_pages->nr_pages = 0;
-                       if (try_upgrade) {
-                               if (ulimit)
-                                       __scif_dec_pinned_vm_lock(mm, nr_pages);
-                               /* Roll back any pinned pages */
-                               unpin_user_pages(pinned_pages->pages,
-                                                pinned_pages->nr_pages);
-                               prot &= ~SCIF_PROT_WRITE;
-                               try_upgrade = false;
-                               goto retry;
-                       }
-               }
-               pinned_pages->map_flags = 0;
-       }
-
-       if (pinned_pages->nr_pages < nr_pages) {
-               err = -EFAULT;
-               goto dec_pinned;
-       }
-
-       *out_prot = prot;
-       atomic_set(&pinned_pages->ref_count, 1);
-       *pages = pinned_pages;
-       return err;
-dec_pinned:
-       if (ulimit)
-               __scif_dec_pinned_vm_lock(mm, nr_pages);
-       /* Something went wrong! Rollback */
-error_unmap:
-       scif_destroy_pinned_pages(pinned_pages);
-       *pages = NULL;
-       dev_dbg(scif_info.mdev.this_device,
-               "%s %d err %d len 0x%lx\n", __func__, __LINE__, err, len);
-       return err;
-}
-
-int scif_pin_pages(void *addr, size_t len, int prot,
-                  int map_flags, scif_pinned_pages_t *pages)
-{
-       return __scif_pin_pages(addr, len, &prot, map_flags, pages);
-}
-EXPORT_SYMBOL_GPL(scif_pin_pages);
-
-int scif_unpin_pages(scif_pinned_pages_t pinned_pages)
-{
-       int err = 0, ret;
-
-       if (!pinned_pages || SCIFEP_MAGIC != pinned_pages->magic)
-               return -EINVAL;
-
-       ret = atomic_sub_return(1, &pinned_pages->ref_count);
-       if (ret < 0) {
-               dev_err(scif_info.mdev.this_device,
-                       "%s %d scif_unpin_pages called without pinning? rc %d\n",
-                       __func__, __LINE__, ret);
-               return -EINVAL;
-       }
-       /*
-        * Destroy the window if the ref count for this set of pinned
-        * pages has dropped to zero. If it is positive then there is
-        * a valid registered window which is backed by these pages and
-        * it will be destroyed once all such windows are unregistered.
-        */
-       if (!ret)
-               err = scif_destroy_pinned_pages(pinned_pages);
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_unpin_pages);
-
-static inline void
-scif_insert_local_window(struct scif_window *window, struct scif_endpt *ep)
-{
-       mutex_lock(&ep->rma_info.rma_lock);
-       scif_insert_window(window, &ep->rma_info.reg_list);
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-off_t scif_register_pinned_pages(scif_epd_t epd,
-                                scif_pinned_pages_t pinned_pages,
-                                off_t offset, int map_flags)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       s64 computed_offset;
-       struct scif_window *window;
-       int err;
-       size_t len;
-       struct device *spdev;
-
-       /* Unsupported flags */
-       if (map_flags & ~SCIF_MAP_FIXED)
-               return -EINVAL;
-
-       len = pinned_pages->nr_pages << PAGE_SHIFT;
-
-       /*
-        * Offset is not page aligned/negative or offset+len
-        * wraps around with SCIF_MAP_FIXED.
-        */
-       if ((map_flags & SCIF_MAP_FIXED) &&
-           ((ALIGN(offset, PAGE_SIZE) != offset) ||
-           (offset < 0) ||
-           (len > LONG_MAX - offset)))
-               return -EINVAL;
-
-       might_sleep();
-
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-       /*
-        * It is an error to pass pinned_pages to scif_register_pinned_pages()
-        * after calling scif_unpin_pages().
-        */
-       if (!atomic_add_unless(&pinned_pages->ref_count, 1, 0))
-               return -EINVAL;
-
-       /* Compute the offset for this registration */
-       err = scif_get_window_offset(ep, map_flags, offset,
-                                    len, &computed_offset);
-       if (err) {
-               atomic_sub(1, &pinned_pages->ref_count);
-               return err;
-       }
-
-       /* Allocate and prepare self registration window */
-       window = scif_create_window(ep, pinned_pages->nr_pages,
-                                   computed_offset, false);
-       if (!window) {
-               atomic_sub(1, &pinned_pages->ref_count);
-               scif_free_window_offset(ep, NULL, computed_offset);
-               return -ENOMEM;
-       }
-
-       window->pinned_pages = pinned_pages;
-       window->nr_pages = pinned_pages->nr_pages;
-       window->prot = pinned_pages->prot;
-
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               scif_destroy_window(ep, window);
-               return err;
-       }
-       err = scif_send_alloc_request(ep, window);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error_unmap;
-       }
-
-       /* Prepare the remote registration window */
-       err = scif_prep_remote_window(ep, window);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error_unmap;
-       }
-
-       /* Tell the peer about the new window */
-       err = scif_send_scif_register(ep, window);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error_unmap;
-       }
-
-       scif_put_peer_dev(spdev);
-       /* No further failures expected. Insert new window */
-       scif_insert_local_window(window, ep);
-       return computed_offset;
-error_unmap:
-       scif_destroy_window(ep, window);
-       scif_put_peer_dev(spdev);
-       dev_err(&ep->remote_dev->sdev->dev,
-               "%s %d err %d\n", __func__, __LINE__, err);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_register_pinned_pages);
-
-off_t scif_register(scif_epd_t epd, void *addr, size_t len, off_t offset,
-                   int prot, int map_flags)
-{
-       scif_pinned_pages_t pinned_pages;
-       off_t err;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       s64 computed_offset;
-       struct scif_window *window;
-       struct mm_struct *mm = NULL;
-       struct device *spdev;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI register: ep %p addr %p len 0x%lx offset 0x%lx prot 0x%x map_flags 0x%x\n",
-               epd, addr, len, offset, prot, map_flags);
-       /* Unsupported flags */
-       if (map_flags & ~(SCIF_MAP_FIXED | SCIF_MAP_KERNEL))
-               return -EINVAL;
-
-       /*
-        * Offset is not page aligned/negative or offset+len
-        * wraps around with SCIF_MAP_FIXED.
-        */
-       if ((map_flags & SCIF_MAP_FIXED) &&
-           ((ALIGN(offset, PAGE_SIZE) != offset) ||
-           (offset < 0) ||
-           (len > LONG_MAX - offset)))
-               return -EINVAL;
-
-       /* Unsupported protection requested */
-       if (prot & ~(SCIF_PROT_READ | SCIF_PROT_WRITE))
-               return -EINVAL;
-
-       /* addr/len must be page aligned. len should be non zero */
-       if (!len || (ALIGN((u64)addr, PAGE_SIZE) != (u64)addr) ||
-           (ALIGN(len, PAGE_SIZE) != len))
-               return -EINVAL;
-
-       might_sleep();
-
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       /* Compute the offset for this registration */
-       err = scif_get_window_offset(ep, map_flags, offset,
-                                    len >> PAGE_SHIFT, &computed_offset);
-       if (err)
-               return err;
-
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               scif_free_window_offset(ep, NULL, computed_offset);
-               return err;
-       }
-       /* Allocate and prepare self registration window */
-       window = scif_create_window(ep, len >> PAGE_SHIFT,
-                                   computed_offset, false);
-       if (!window) {
-               scif_free_window_offset(ep, NULL, computed_offset);
-               scif_put_peer_dev(spdev);
-               return -ENOMEM;
-       }
-
-       window->nr_pages = len >> PAGE_SHIFT;
-
-       err = scif_send_alloc_request(ep, window);
-       if (err) {
-               scif_destroy_incomplete_window(ep, window);
-               scif_put_peer_dev(spdev);
-               return err;
-       }
-
-       if (!(map_flags & SCIF_MAP_KERNEL)) {
-               mm = __scif_acquire_mm();
-               map_flags |= SCIF_MAP_ULIMIT;
-       }
-       /* Pin down the pages */
-       err = __scif_pin_pages(addr, len, &prot,
-                              map_flags & (SCIF_MAP_KERNEL | SCIF_MAP_ULIMIT),
-                              &pinned_pages);
-       if (err) {
-               scif_destroy_incomplete_window(ep, window);
-               __scif_release_mm(mm);
-               goto error;
-       }
-
-       window->pinned_pages = pinned_pages;
-       window->prot = pinned_pages->prot;
-       window->mm = mm;
-
-       /* Prepare the remote registration window */
-       err = scif_prep_remote_window(ep, window);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %ld\n", __func__, __LINE__, err);
-               goto error_unmap;
-       }
-
-       /* Tell the peer about the new window */
-       err = scif_send_scif_register(ep, window);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %ld\n", __func__, __LINE__, err);
-               goto error_unmap;
-       }
-
-       scif_put_peer_dev(spdev);
-       /* No further failures expected. Insert new window */
-       scif_insert_local_window(window, ep);
-       dev_dbg(&ep->remote_dev->sdev->dev,
-               "SCIFAPI register: ep %p addr %p len 0x%lx computed_offset 0x%llx\n",
-               epd, addr, len, computed_offset);
-       return computed_offset;
-error_unmap:
-       scif_destroy_window(ep, window);
-error:
-       scif_put_peer_dev(spdev);
-       dev_err(&ep->remote_dev->sdev->dev,
-               "%s %d err %ld\n", __func__, __LINE__, err);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_register);
-
-int
-scif_unregister(scif_epd_t epd, off_t offset, size_t len)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct scif_window *window = NULL;
-       struct scif_rma_req req;
-       int nr_pages, err;
-       struct device *spdev;
-
-       dev_dbg(scif_info.mdev.this_device,
-               "SCIFAPI unregister: ep %p offset 0x%lx len 0x%lx\n",
-               ep, offset, len);
-       /* len must be page aligned. len should be non zero */
-       if (!len ||
-           (ALIGN((u64)len, PAGE_SIZE) != (u64)len))
-               return -EINVAL;
-
-       /* Offset is not page aligned or offset+len wraps around */
-       if ((ALIGN(offset, PAGE_SIZE) != offset) ||
-           (offset < 0) ||
-           (len > LONG_MAX - offset))
-               return -EINVAL;
-
-       err = scif_verify_epd(ep);
-       if (err)
-               return err;
-
-       might_sleep();
-       nr_pages = len >> PAGE_SHIFT;
-
-       req.out_window = &window;
-       req.offset = offset;
-       req.prot = 0;
-       req.nr_bytes = len;
-       req.type = SCIF_WINDOW_FULL;
-       req.head = &ep->rma_info.reg_list;
-
-       spdev = scif_get_peer_dev(ep->remote_dev);
-       if (IS_ERR(spdev)) {
-               err = PTR_ERR(spdev);
-               return err;
-       }
-       mutex_lock(&ep->rma_info.rma_lock);
-       /* Does a valid window exist? */
-       err = scif_query_window(&req);
-       if (err) {
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-               goto error;
-       }
-       /* Unregister all the windows in this range */
-       err = scif_rma_list_unregister(window, offset, nr_pages);
-       if (err)
-               dev_err(&ep->remote_dev->sdev->dev,
-                       "%s %d err %d\n", __func__, __LINE__, err);
-error:
-       mutex_unlock(&ep->rma_info.rma_lock);
-       scif_put_peer_dev(spdev);
-       return err;
-}
-EXPORT_SYMBOL_GPL(scif_unregister);
diff --git a/drivers/misc/mic/scif/scif_rma.h b/drivers/misc/mic/scif/scif_rma.h
deleted file mode 100644 (file)
index 964dd0f..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * 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) 2015 Intel Corporation.
- *
- * 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.
- *
- * 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.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * 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 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 SCIF driver.
- *
- */
-#ifndef SCIF_RMA_H
-#define SCIF_RMA_H
-
-#include <linux/intel-iommu.h>
-#include <linux/mmu_notifier.h>
-
-#include "../bus/scif_bus.h"
-
-/* If this bit is set then the mark is a remote fence mark */
-#define SCIF_REMOTE_FENCE_BIT          31
-/* Magic value used to indicate a remote fence request */
-#define SCIF_REMOTE_FENCE BIT_ULL(SCIF_REMOTE_FENCE_BIT)
-
-#define SCIF_MAX_UNALIGNED_BUF_SIZE (1024 * 1024ULL)
-#define SCIF_KMEM_UNALIGNED_BUF_SIZE (SCIF_MAX_UNALIGNED_BUF_SIZE + \
-                                     (L1_CACHE_BYTES << 1))
-
-#define SCIF_IOVA_START_PFN            (1)
-#define SCIF_IOVA_PFN(addr) ((addr) >> PAGE_SHIFT)
-#define SCIF_DMA_64BIT_PFN SCIF_IOVA_PFN(DMA_BIT_MASK(64))
-#define SCIF_DMA_63BIT_PFN SCIF_IOVA_PFN(DMA_BIT_MASK(63))
-
-/*
- * struct scif_endpt_rma_info - Per Endpoint Remote Memory Access Information
- *
- * @reg_list: List of registration windows for self
- * @remote_reg_list: List of registration windows for peer
- * @iovad: Offset generator
- * @rma_lock: Synchronizes access to self/remote list and also protects the
- *           window from being destroyed while RMAs are in progress.
- * @tc_lock: Synchronizes access to temporary cached windows list
- *          for SCIF Registration Caching.
- * @mmn_lock: Synchronizes access to the list of MMU notifiers registered
- * @tw_refcount: Keeps track of number of outstanding temporary registered
- *              windows created by scif_vreadfrom/scif_vwriteto which have
- *              not been destroyed.
- * @tcw_refcount: Same as tw_refcount but for temporary cached windows
- * @tcw_total_pages: Same as tcw_refcount but in terms of pages pinned
- * @mmn_list: MMU notifier so that we can destroy the windows when required
- * @fence_refcount: Keeps track of number of outstanding remote fence
- *                 requests which have been received by the peer.
- * @dma_chan: DMA channel used for all DMA transfers for this endpoint.
- * @async_list_del: Detect asynchronous list entry deletion
- * @vma_list: List of vmas with remote memory mappings
- * @markwq: Wait queue used for scif_fence_mark/scif_fence_wait
-*/
-struct scif_endpt_rma_info {
-       struct list_head reg_list;
-       struct list_head remote_reg_list;
-       struct iova_domain iovad;
-       struct mutex rma_lock;
-       spinlock_t tc_lock;
-       struct mutex mmn_lock;
-       atomic_t tw_refcount;
-       atomic_t tcw_refcount;
-       atomic_t tcw_total_pages;
-       struct list_head mmn_list;
-       atomic_t fence_refcount;
-       struct dma_chan *dma_chan;
-       int async_list_del;
-       struct list_head vma_list;
-       wait_queue_head_t markwq;
-};
-
-/*
- * struct scif_fence_info - used for tracking fence requests
- *
- * @state: State of this transfer
- * @wq: Fences wait on this queue
- * @dma_mark: Used for storing the DMA mark
- */
-struct scif_fence_info {
-       enum scif_msg_state state;
-       struct completion comp;
-       int dma_mark;
-};
-
-/*
- * struct scif_remote_fence_info - used for tracking remote fence requests
- *
- * @msg: List of SCIF node QP fence messages
- * @list: Link to list of remote fence requests
- */
-struct scif_remote_fence_info {
-       struct scifmsg msg;
-       struct list_head list;
-};
-
-/*
- * Specifies whether an RMA operation can span across partial windows, a single
- * window or multiple contiguous windows. Mmaps can span across partial windows.
- * Unregistration can span across complete windows. scif_get_pages() can span a
- * single window. A window can also be of type self or peer.
- */
-enum scif_window_type {
-       SCIF_WINDOW_PARTIAL,
-       SCIF_WINDOW_SINGLE,
-       SCIF_WINDOW_FULL,
-       SCIF_WINDOW_SELF,
-       SCIF_WINDOW_PEER
-};
-
-/* The number of physical addresses that can be stored in a PAGE. */
-#define SCIF_NR_ADDR_IN_PAGE   (0x1000 >> 3)
-
-/*
- * struct scif_rma_lookup - RMA lookup data structure for page list transfers
- *
- * Store an array of lookup offsets. Each offset in this array maps
- * one 4K page containing 512 physical addresses i.e. 2MB. 512 such
- * offsets in a 4K page will correspond to 1GB of registered address space.
-
- * @lookup: Array of offsets
- * @offset: DMA offset of lookup array
- */
-struct scif_rma_lookup {
-       dma_addr_t *lookup;
-       dma_addr_t offset;
-};
-
-/*
- * struct scif_pinned_pages - A set of pinned pages obtained with
- * scif_pin_pages() which could be part of multiple registered
- * windows across different end points.
- *
- * @nr_pages: Number of pages which is defined as a s64 instead of an int
- * to avoid sign extension with buffers >= 2GB
- * @prot: read/write protections
- * @map_flags: Flags specified during the pin operation
- * @ref_count: Reference count bumped in terms of number of pages
- * @magic: A magic value
- * @pages: Array of pointers to struct pages populated with get_user_pages(..)
- */
-struct scif_pinned_pages {
-       s64 nr_pages;
-       int prot;
-       int map_flags;
-       atomic_t ref_count;
-       u64 magic;
-       struct page **pages;
-};
-
-/*
- * struct scif_status - Stores DMA status update information
- *
- * @src_dma_addr: Source buffer DMA address
- * @val: src location for value to be written to the destination
- * @ep: SCIF endpoint
- */
-struct scif_status {
-       dma_addr_t src_dma_addr;
-       u64 val;
-       struct scif_endpt *ep;
-};
-
-/*
- * struct scif_cb_arg - Stores the argument of the callback func
- *
- * @src_dma_addr: Source buffer DMA address
- * @status: DMA status
- * @ep: SCIF endpoint
- */
-struct scif_cb_arg {
-       dma_addr_t src_dma_addr;
-       struct scif_status *status;
-       struct scif_endpt *ep;
-};
-
-/*
- * struct scif_window - Registration Window for Self and Remote
- *
- * @nr_pages: Number of pages which is defined as a s64 instead of an int
- * to avoid sign extension with buffers >= 2GB
- * @nr_contig_chunks: Number of contiguous physical chunks
- * @prot: read/write protections
- * @ref_count: reference count in terms of number of pages
- * @magic: Cookie to detect corruption
- * @offset: registered offset
- * @va_for_temp: va address that this window represents
- * @dma_mark: Used to determine if all DMAs against the window are done
- * @ep: Pointer to EP. Useful for passing EP around with messages to
-       avoid expensive list traversals.
- * @list: link to list of windows for the endpoint
- * @type: self or peer window
- * @peer_window: Pointer to peer window. Useful for sending messages to peer
- *              without requiring an extra list traversal
- * @unreg_state: unregistration state
- * @offset_freed: True if the offset has been freed
- * @temp: True for temporary windows created via scif_vreadfrom/scif_vwriteto
- * @mm: memory descriptor for the task_struct which initiated the RMA
- * @st: scatter gather table for DMA mappings with IOMMU enabled
- * @pinned_pages: The set of pinned_pages backing this window
- * @alloc_handle: Handle for sending ALLOC_REQ
- * @regwq: Wait Queue for an registration (N)ACK
- * @reg_state: Registration state
- * @unregwq: Wait Queue for an unregistration (N)ACK
- * @dma_addr_lookup: Lookup for physical addresses used for DMA
- * @nr_lookup: Number of entries in lookup
- * @mapped_offset: Offset used to map the window by the peer
- * @dma_addr: Array of physical addresses used for Mgmt node & MIC initiated DMA
- * @num_pages: Array specifying number of pages for each physical address
- */
-struct scif_window {
-       s64 nr_pages;
-       int nr_contig_chunks;
-       int prot;
-       int ref_count;
-       u64 magic;
-       s64 offset;
-       unsigned long va_for_temp;
-       int dma_mark;
-       u64 ep;
-       struct list_head list;
-       enum scif_window_type type;
-       u64 peer_window;
-       enum scif_msg_state unreg_state;
-       bool offset_freed;
-       bool temp;
-       struct mm_struct *mm;
-       struct sg_table *st;
-       union {
-               struct {
-                       struct scif_pinned_pages *pinned_pages;
-                       struct scif_allocmsg alloc_handle;
-                       wait_queue_head_t regwq;
-                       enum scif_msg_state reg_state;
-                       wait_queue_head_t unregwq;
-               };
-               struct {
-                       struct scif_rma_lookup dma_addr_lookup;
-                       struct scif_rma_lookup num_pages_lookup;
-                       int nr_lookup;
-                       dma_addr_t mapped_offset;
-               };
-       };
-       dma_addr_t *dma_addr;
-       u64 *num_pages;
-} __packed;
-
-/*
- * scif_mmu_notif - SCIF mmu notifier information
- *
- * @mmu_notifier ep_mmu_notifier: MMU notifier operations
- * @tc_reg_list: List of temp registration windows for self
- * @mm: memory descriptor for the task_struct which initiated the RMA
- * @ep: SCIF endpoint
- * @list: link to list of MMU notifier information
- */
-struct scif_mmu_notif {
-#ifdef CONFIG_MMU_NOTIFIER
-       struct mmu_notifier ep_mmu_notifier;
-#endif
-       struct list_head tc_reg_list;
-       struct mm_struct *mm;
-       struct scif_endpt *ep;
-       struct list_head list;
-};
-
-enum scif_rma_dir {
-       SCIF_LOCAL_TO_REMOTE,
-       SCIF_REMOTE_TO_LOCAL
-};
-
-extern struct kmem_cache *unaligned_cache;
-/* Initialize RMA for this EP */
-void scif_rma_ep_init(struct scif_endpt *ep);
-/* Check if epd can be uninitialized */
-int scif_rma_ep_can_uninit(struct scif_endpt *ep);
-/* Obtain a new offset. Callee must grab RMA lock */
-int scif_get_window_offset(struct scif_endpt *ep, int flags,
-                          s64 offset, int nr_pages, s64 *out_offset);
-/* Free offset. Callee must grab RMA lock */
-void scif_free_window_offset(struct scif_endpt *ep,
-                            struct scif_window *window, s64 offset);
-/* Create self registration window */
-struct scif_window *scif_create_window(struct scif_endpt *ep, int nr_pages,
-                                      s64 offset, bool temp);
-/* Destroy self registration window.*/
-int scif_destroy_window(struct scif_endpt *ep, struct scif_window *window);
-void scif_unmap_window(struct scif_dev *remote_dev, struct scif_window *window);
-/* Map pages of self window to Aperture/PCI */
-int scif_map_window(struct scif_dev *remote_dev,
-                   struct scif_window *window);
-/* Unregister a self window */
-int scif_unregister_window(struct scif_window *window);
-/* Destroy remote registration window */
-void
-scif_destroy_remote_window(struct scif_window *window);
-/* remove valid remote memory mappings from process address space */
-void scif_zap_mmaps(int node);
-/* Query if any applications have remote memory mappings */
-bool scif_rma_do_apps_have_mmaps(int node);
-/* Cleanup remote registration lists for zombie endpoints */
-void scif_cleanup_rma_for_zombies(int node);
-/* Reserve a DMA channel for a particular endpoint */
-int scif_reserve_dma_chan(struct scif_endpt *ep);
-/* Setup a DMA mark for an endpoint */
-int _scif_fence_mark(scif_epd_t epd, int *mark);
-int scif_prog_signal(scif_epd_t epd, off_t offset, u64 val,
-                    enum scif_window_type type);
-void scif_alloc_req(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_alloc_gnt_rej(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_free_virt(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_reg(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_unreg(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_reg_ack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_reg_nack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_unreg_ack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_unreg_nack(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_munmap(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_mark(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_mark_resp(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_wait(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_wait_resp(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_sig_local(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_sig_remote(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_recv_sig_resp(struct scif_dev *scifdev, struct scifmsg *msg);
-void scif_mmu_notif_handler(struct work_struct *work);
-void scif_rma_handle_remote_fences(void);
-void scif_rma_destroy_windows(void);
-void scif_rma_destroy_tcw_invalid(void);
-int scif_drain_dma_intr(struct scif_hw_dev *sdev, struct dma_chan *chan);
-
-struct scif_window_iter {
-       s64 offset;
-       int index;
-};
-
-static inline void
-scif_init_window_iter(struct scif_window *window, struct scif_window_iter *iter)
-{
-       iter->offset = window->offset;
-       iter->index = 0;
-}
-
-dma_addr_t scif_off_to_dma_addr(struct scif_window *window, s64 off,
-                               size_t *nr_bytes,
-                               struct scif_window_iter *iter);
-static inline
-dma_addr_t __scif_off_to_dma_addr(struct scif_window *window, s64 off)
-{
-       return scif_off_to_dma_addr(window, off, NULL, NULL);
-}
-
-static inline bool scif_unaligned(off_t src_offset, off_t dst_offset)
-{
-       src_offset = src_offset & (L1_CACHE_BYTES - 1);
-       dst_offset = dst_offset & (L1_CACHE_BYTES - 1);
-       return !(src_offset == dst_offset);
-}
-
-/*
- * scif_zalloc:
- * @size: Size of the allocation request.
- *
- * Helper API which attempts to allocate zeroed pages via
- * __get_free_pages(..) first and then falls back on
- * vzalloc(..) if that fails.
- */
-static inline void *scif_zalloc(size_t size)
-{
-       void *ret = NULL;
-       size_t align = ALIGN(size, PAGE_SIZE);
-
-       if (align && get_order(align) < MAX_ORDER)
-               ret = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
-                                              get_order(align));
-       return ret ? ret : vzalloc(align);
-}
-
-/*
- * scif_free:
- * @addr: Address to be freed.
- * @size: Size of the allocation.
- * Helper API which frees memory allocated via scif_zalloc().
- */
-static inline void scif_free(void *addr, size_t size)
-{
-       size_t align = ALIGN(size, PAGE_SIZE);
-
-       if (is_vmalloc_addr(addr))
-               vfree(addr);
-       else
-               free_pages((unsigned long)addr, get_order(align));
-}
-
-static inline void scif_get_window(struct scif_window *window, int nr_pages)
-{
-       window->ref_count += nr_pages;
-}
-
-static inline void scif_put_window(struct scif_window *window, int nr_pages)
-{
-       window->ref_count -= nr_pages;
-}
-
-static inline void scif_set_window_ref(struct scif_window *window, int nr_pages)
-{
-       window->ref_count = nr_pages;
-}
-
-static inline void
-scif_queue_for_cleanup(struct scif_window *window, struct list_head *list)
-{
-       spin_lock(&scif_info.rmalock);
-       list_add_tail(&window->list, list);
-       spin_unlock(&scif_info.rmalock);
-       schedule_work(&scif_info.misc_work);
-}
-
-static inline void __scif_rma_destroy_tcw_helper(struct scif_window *window)
-{
-       list_del_init(&window->list);
-       scif_queue_for_cleanup(window, &scif_info.rma_tc);
-}
-
-static inline bool scif_is_iommu_enabled(void)
-{
-#ifdef CONFIG_INTEL_IOMMU
-       return intel_iommu_enabled;
-#else
-       return false;
-#endif
-}
-#endif /* SCIF_RMA_H */
diff --git a/drivers/misc/mic/scif/scif_rma_list.c b/drivers/misc/mic/scif/scif_rma_list.c
deleted file mode 100644 (file)
index ef923ba..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#include "scif_main.h"
-#include <linux/mmu_notifier.h>
-#include <linux/highmem.h>
-
-/*
- * scif_insert_tcw:
- *
- * Insert a temp window to the temp registration list sorted by va_for_temp.
- * RMA lock must be held.
- */
-void scif_insert_tcw(struct scif_window *window, struct list_head *head)
-{
-       struct scif_window *curr = NULL;
-       struct scif_window *prev = list_entry(head, struct scif_window, list);
-       struct list_head *item;
-
-       INIT_LIST_HEAD(&window->list);
-       /* Compare with tail and if the entry is new tail add it to the end */
-       if (!list_empty(head)) {
-               curr = list_entry(head->prev, struct scif_window, list);
-               if (curr->va_for_temp < window->va_for_temp) {
-                       list_add_tail(&window->list, head);
-                       return;
-               }
-       }
-       list_for_each(item, head) {
-               curr = list_entry(item, struct scif_window, list);
-               if (curr->va_for_temp > window->va_for_temp)
-                       break;
-               prev = curr;
-       }
-       list_add(&window->list, &prev->list);
-}
-
-/*
- * scif_insert_window:
- *
- * Insert a window to the self registration list sorted by offset.
- * RMA lock must be held.
- */
-void scif_insert_window(struct scif_window *window, struct list_head *head)
-{
-       struct scif_window *curr = NULL, *prev = NULL;
-       struct list_head *item;
-
-       INIT_LIST_HEAD(&window->list);
-       list_for_each(item, head) {
-               curr = list_entry(item, struct scif_window, list);
-               if (curr->offset > window->offset)
-                       break;
-               prev = curr;
-       }
-       if (!prev)
-               list_add(&window->list, head);
-       else
-               list_add(&window->list, &prev->list);
-       scif_set_window_ref(window, window->nr_pages);
-}
-
-/*
- * scif_query_tcw:
- *
- * Query the temp cached registration list of ep for an overlapping window
- * in case of permission mismatch, destroy the previous window. if permissions
- * match and overlap is partial, destroy the window but return the new range
- * RMA lock must be held.
- */
-int scif_query_tcw(struct scif_endpt *ep, struct scif_rma_req *req)
-{
-       struct list_head *item, *temp, *head = req->head;
-       struct scif_window *window;
-       u64 start_va_window, start_va_req = req->va_for_temp;
-       u64 end_va_window, end_va_req = start_va_req + req->nr_bytes;
-
-       if (!req->nr_bytes)
-               return -EINVAL;
-       /*
-        * Avoid traversing the entire list to find out that there
-        * is no entry that matches
-        */
-       if (!list_empty(head)) {
-               window = list_last_entry(head, struct scif_window, list);
-               end_va_window = window->va_for_temp +
-                       (window->nr_pages << PAGE_SHIFT);
-               if (start_va_req > end_va_window)
-                       return -ENXIO;
-       }
-       list_for_each_safe(item, temp, head) {
-               window = list_entry(item, struct scif_window, list);
-               start_va_window = window->va_for_temp;
-               end_va_window = window->va_for_temp +
-                       (window->nr_pages << PAGE_SHIFT);
-               if (start_va_req < start_va_window &&
-                   end_va_req < start_va_window)
-                       break;
-               if (start_va_req >= end_va_window)
-                       continue;
-               if ((window->prot & req->prot) == req->prot) {
-                       if (start_va_req >= start_va_window &&
-                           end_va_req <= end_va_window) {
-                               *req->out_window = window;
-                               return 0;
-                       }
-                       /* expand window */
-                       if (start_va_req < start_va_window) {
-                               req->nr_bytes +=
-                                       start_va_window - start_va_req;
-                               req->va_for_temp = start_va_window;
-                       }
-                       if (end_va_req >= end_va_window)
-                               req->nr_bytes += end_va_window - end_va_req;
-               }
-               /* Destroy the old window to create a new one */
-               __scif_rma_destroy_tcw_helper(window);
-               break;
-       }
-       return -ENXIO;
-}
-
-/*
- * scif_query_window:
- *
- * Query the registration list and check if a valid contiguous
- * range of windows exist.
- * RMA lock must be held.
- */
-int scif_query_window(struct scif_rma_req *req)
-{
-       struct list_head *item;
-       struct scif_window *window;
-       s64 end_offset, offset = req->offset;
-       u64 tmp_min, nr_bytes_left = req->nr_bytes;
-
-       if (!req->nr_bytes)
-               return -EINVAL;
-
-       list_for_each(item, req->head) {
-               window = list_entry(item, struct scif_window, list);
-               end_offset = window->offset +
-                       (window->nr_pages << PAGE_SHIFT);
-               if (offset < window->offset)
-                       /* Offset not found! */
-                       return -ENXIO;
-               if (offset >= end_offset)
-                       continue;
-               /* Check read/write protections. */
-               if ((window->prot & req->prot) != req->prot)
-                       return -EPERM;
-               if (nr_bytes_left == req->nr_bytes)
-                       /* Store the first window */
-                       *req->out_window = window;
-               tmp_min = min((u64)end_offset - offset, nr_bytes_left);
-               nr_bytes_left -= tmp_min;
-               offset += tmp_min;
-               /*
-                * Range requested encompasses
-                * multiple windows contiguously.
-                */
-               if (!nr_bytes_left) {
-                       /* Done for partial window */
-                       if (req->type == SCIF_WINDOW_PARTIAL ||
-                           req->type == SCIF_WINDOW_SINGLE)
-                               return 0;
-                       /* Extra logic for full windows */
-                       if (offset == end_offset)
-                               /* Spanning multiple whole windows */
-                               return 0;
-                               /* Not spanning multiple whole windows */
-                       return -ENXIO;
-               }
-               if (req->type == SCIF_WINDOW_SINGLE)
-                       break;
-       }
-       dev_err(scif_info.mdev.this_device,
-               "%s %d ENXIO\n", __func__, __LINE__);
-       return -ENXIO;
-}
-
-/*
- * scif_rma_list_unregister:
- *
- * Traverse the self registration list starting from window:
- * 1) Call scif_unregister_window(..)
- * RMA lock must be held.
- */
-int scif_rma_list_unregister(struct scif_window *window,
-                            s64 offset, int nr_pages)
-{
-       struct scif_endpt *ep = (struct scif_endpt *)window->ep;
-       struct list_head *head = &ep->rma_info.reg_list;
-       s64 end_offset;
-       int err = 0;
-       int loop_nr_pages;
-       struct scif_window *_window;
-
-       list_for_each_entry_safe_from(window, _window, head, list) {
-               end_offset = window->offset + (window->nr_pages << PAGE_SHIFT);
-               loop_nr_pages = min((int)((end_offset - offset) >> PAGE_SHIFT),
-                                   nr_pages);
-               err = scif_unregister_window(window);
-               if (err)
-                       return err;
-               nr_pages -= loop_nr_pages;
-               offset += (loop_nr_pages << PAGE_SHIFT);
-               if (!nr_pages)
-                       break;
-       }
-       return 0;
-}
-
-/*
- * scif_unmap_all_window:
- *
- * Traverse all the windows in the self registration list and:
- * 1) Delete any DMA mappings created
- */
-void scif_unmap_all_windows(scif_epd_t epd)
-{
-       struct list_head *item, *tmp;
-       struct scif_window *window;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct list_head *head = &ep->rma_info.reg_list;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-       list_for_each_safe(item, tmp, head) {
-               window = list_entry(item, struct scif_window, list);
-               scif_unmap_window(ep->remote_dev, window);
-       }
-       mutex_unlock(&ep->rma_info.rma_lock);
-}
-
-/*
- * scif_unregister_all_window:
- *
- * Traverse all the windows in the self registration list and:
- * 1) Call scif_unregister_window(..)
- * RMA lock must be held.
- */
-int scif_unregister_all_windows(scif_epd_t epd)
-{
-       struct list_head *item, *tmp;
-       struct scif_window *window;
-       struct scif_endpt *ep = (struct scif_endpt *)epd;
-       struct list_head *head = &ep->rma_info.reg_list;
-       int err = 0;
-
-       mutex_lock(&ep->rma_info.rma_lock);
-retry:
-       item = NULL;
-       tmp = NULL;
-       list_for_each_safe(item, tmp, head) {
-               window = list_entry(item, struct scif_window, list);
-               ep->rma_info.async_list_del = 0;
-               err = scif_unregister_window(window);
-               if (err)
-                       dev_err(scif_info.mdev.this_device,
-                               "%s %d err %d\n",
-                               __func__, __LINE__, err);
-               /*
-                * Need to restart list traversal if there has been
-                * an asynchronous list entry deletion.
-                */
-               if (READ_ONCE(ep->rma_info.async_list_del))
-                       goto retry;
-       }
-       mutex_unlock(&ep->rma_info.rma_lock);
-       if (!list_empty(&ep->rma_info.mmn_list)) {
-               spin_lock(&scif_info.rmalock);
-               list_add_tail(&ep->mmu_list, &scif_info.mmu_notif_cleanup);
-               spin_unlock(&scif_info.rmalock);
-               schedule_work(&scif_info.mmu_notif_work);
-       }
-       return err;
-}
diff --git a/drivers/misc/mic/scif/scif_rma_list.h b/drivers/misc/mic/scif/scif_rma_list.h
deleted file mode 100644 (file)
index 0f8e0ed..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2015 Intel Corporation.
- *
- * Intel SCIF driver.
- */
-#ifndef SCIF_RMA_LIST_H
-#define SCIF_RMA_LIST_H
-
-/*
- * struct scif_rma_req - Self Registration list RMA Request query
- *
- * @out_window - Returns the window if found
- * @offset: Starting offset
- * @nr_bytes: number of bytes
- * @prot: protection requested i.e. read or write or both
- * @type: Specify single, partial or multiple windows
- * @head: Head of list on which to search
- * @va_for_temp: VA for searching temporary cached windows
- */
-struct scif_rma_req {
-       struct scif_window **out_window;
-       union {
-               s64 offset;
-               unsigned long va_for_temp;
-       };
-       size_t nr_bytes;
-       int prot;
-       enum scif_window_type type;
-       struct list_head *head;
-};
-
-/* Insert */
-void scif_insert_window(struct scif_window *window, struct list_head *head);
-void scif_insert_tcw(struct scif_window *window,
-                    struct list_head *head);
-/* Query */
-int scif_query_window(struct scif_rma_req *request);
-int scif_query_tcw(struct scif_endpt *ep, struct scif_rma_req *request);
-/* Called from close to unregister all self windows */
-int scif_unregister_all_windows(scif_epd_t epd);
-void scif_unmap_all_windows(scif_epd_t epd);
-/* Traverse list and unregister */
-int scif_rma_list_unregister(struct scif_window *window, s64 offset,
-                            int nr_pages);
-#endif /* SCIF_RMA_LIST_H */
diff --git a/drivers/misc/mic/vop/Makefile b/drivers/misc/mic/vop/Makefile
deleted file mode 100644 (file)
index 51b9b00..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-#
-# Makefile - Intel MIC Linux driver.
-# Copyright(c) 2016, Intel Corporation.
-#
-obj-$(CONFIG_VOP) := vop.o
-
-vop-objs += vop_main.o
-vop-objs += vop_debugfs.o
-vop-objs += vop_vringh.o
diff --git a/drivers/misc/mic/vop/vop_debugfs.c b/drivers/misc/mic/vop/vop_debugfs.c
deleted file mode 100644 (file)
index 9d4f175..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Intel Virtio Over PCIe (VOP) driver.
- */
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
-
-#include "vop_main.h"
-
-static int vop_dp_show(struct seq_file *s, void *pos)
-{
-       struct mic_device_desc *d;
-       struct mic_device_ctrl *dc;
-       struct mic_vqconfig *vqconfig;
-       __u32 *features;
-       __u8 *config;
-       struct vop_info *vi = s->private;
-       struct vop_device *vpdev = vi->vpdev;
-       struct mic_bootparam *bootparam = vpdev->hw_ops->get_dp(vpdev);
-       int j, k;
-
-       seq_printf(s, "Bootparam: magic 0x%x\n",
-                  bootparam->magic);
-       seq_printf(s, "Bootparam: h2c_config_db %d\n",
-                  bootparam->h2c_config_db);
-       seq_printf(s, "Bootparam: node_id %d\n",
-                  bootparam->node_id);
-       seq_printf(s, "Bootparam: c2h_scif_db %d\n",
-                  bootparam->c2h_scif_db);
-       seq_printf(s, "Bootparam: h2c_scif_db %d\n",
-                  bootparam->h2c_scif_db);
-       seq_printf(s, "Bootparam: scif_host_dma_addr 0x%llx\n",
-                  bootparam->scif_host_dma_addr);
-       seq_printf(s, "Bootparam: scif_card_dma_addr 0x%llx\n",
-                  bootparam->scif_card_dma_addr);
-
-       for (j = sizeof(*bootparam);
-               j < MIC_DP_SIZE; j += mic_total_desc_size(d)) {
-               d = (void *)bootparam + j;
-               dc = (void *)d + mic_aligned_desc_size(d);
-
-               /* end of list */
-               if (d->type == 0)
-                       break;
-
-               if (d->type == -1)
-                       continue;
-
-               seq_printf(s, "Type %d ", d->type);
-               seq_printf(s, "Num VQ %d ", d->num_vq);
-               seq_printf(s, "Feature Len %d\n", d->feature_len);
-               seq_printf(s, "Config Len %d ", d->config_len);
-               seq_printf(s, "Shutdown Status %d\n", d->status);
-
-               for (k = 0; k < d->num_vq; k++) {
-                       vqconfig = mic_vq_config(d) + k;
-                       seq_printf(s, "vqconfig[%d]: ", k);
-                       seq_printf(s, "address 0x%llx ",
-                                  vqconfig->address);
-                       seq_printf(s, "num %d ", vqconfig->num);
-                       seq_printf(s, "used address 0x%llx\n",
-                                  vqconfig->used_address);
-               }
-
-               features = (__u32 *)mic_vq_features(d);
-               seq_printf(s, "Features: Host 0x%x ", features[0]);
-               seq_printf(s, "Guest 0x%x\n", features[1]);
-
-               config = mic_vq_configspace(d);
-               for (k = 0; k < d->config_len; k++)
-                       seq_printf(s, "config[%d]=%d\n", k, config[k]);
-
-               seq_puts(s, "Device control:\n");
-               seq_printf(s, "Config Change %d ", dc->config_change);
-               seq_printf(s, "Vdev reset %d\n", dc->vdev_reset);
-               seq_printf(s, "Guest Ack %d ", dc->guest_ack);
-               seq_printf(s, "Host ack %d\n", dc->host_ack);
-               seq_printf(s, "Used address updated %d ",
-                          dc->used_address_updated);
-               seq_printf(s, "Vdev 0x%llx\n", dc->vdev);
-               seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db);
-               seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db);
-       }
-       schedule_work(&vi->hotplug_work);
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(vop_dp);
-
-static int vop_vdev_info_show(struct seq_file *s, void *unused)
-{
-       struct vop_info *vi = s->private;
-       struct list_head *pos, *tmp;
-       struct vop_vdev *vdev;
-       int i, j;
-
-       mutex_lock(&vi->vop_mutex);
-       list_for_each_safe(pos, tmp, &vi->vdev_list) {
-               vdev = list_entry(pos, struct vop_vdev, list);
-               seq_printf(s, "VDEV type %d state %s in %ld out %ld in_dma %ld out_dma %ld\n",
-                          vdev->virtio_id,
-                          vop_vdevup(vdev) ? "UP" : "DOWN",
-                          vdev->in_bytes,
-                          vdev->out_bytes,
-                          vdev->in_bytes_dma,
-                          vdev->out_bytes_dma);
-               for (i = 0; i < MIC_MAX_VRINGS; i++) {
-                       struct vring_desc *desc;
-                       struct vring_avail *avail;
-                       struct vring_used *used;
-                       struct vop_vringh *vvr = &vdev->vvr[i];
-                       struct vringh *vrh = &vvr->vrh;
-                       int num = vrh->vring.num;
-
-                       if (!num)
-                               continue;
-                       desc = vrh->vring.desc;
-                       seq_printf(s, "vring i %d avail_idx %d",
-                                  i, vvr->vring.info->avail_idx & (num - 1));
-                       seq_printf(s, " vring i %d avail_idx %d\n",
-                                  i, vvr->vring.info->avail_idx);
-                       seq_printf(s, "vrh i %d weak_barriers %d",
-                                  i, vrh->weak_barriers);
-                       seq_printf(s, " last_avail_idx %d last_used_idx %d",
-                                  vrh->last_avail_idx, vrh->last_used_idx);
-                       seq_printf(s, " completed %d\n", vrh->completed);
-                       for (j = 0; j < num; j++) {
-                               seq_printf(s, "desc[%d] addr 0x%llx len %d",
-                                          j, desc->addr, desc->len);
-                               seq_printf(s, " flags 0x%x next %d\n",
-                                          desc->flags, desc->next);
-                               desc++;
-                       }
-                       avail = vrh->vring.avail;
-                       seq_printf(s, "avail flags 0x%x idx %d\n",
-                                  vringh16_to_cpu(vrh, avail->flags),
-                                  vringh16_to_cpu(vrh,
-                                                  avail->idx) & (num - 1));
-                       seq_printf(s, "avail flags 0x%x idx %d\n",
-                                  vringh16_to_cpu(vrh, avail->flags),
-                                  vringh16_to_cpu(vrh, avail->idx));
-                       for (j = 0; j < num; j++)
-                               seq_printf(s, "avail ring[%d] %d\n",
-                                          j, avail->ring[j]);
-                       used = vrh->vring.used;
-                       seq_printf(s, "used flags 0x%x idx %d\n",
-                                  vringh16_to_cpu(vrh, used->flags),
-                                  vringh16_to_cpu(vrh, used->idx) & (num - 1));
-                       seq_printf(s, "used flags 0x%x idx %d\n",
-                                  vringh16_to_cpu(vrh, used->flags),
-                                  vringh16_to_cpu(vrh, used->idx));
-                       for (j = 0; j < num; j++)
-                               seq_printf(s, "used ring[%d] id %d len %d\n",
-                                          j, vringh32_to_cpu(vrh,
-                                                             used->ring[j].id),
-                                          vringh32_to_cpu(vrh,
-                                                          used->ring[j].len));
-               }
-       }
-       mutex_unlock(&vi->vop_mutex);
-
-       return 0;
-}
-
-DEFINE_SHOW_ATTRIBUTE(vop_vdev_info);
-
-void vop_init_debugfs(struct vop_info *vi)
-{
-       char name[16];
-
-       snprintf(name, sizeof(name), "%s%d", KBUILD_MODNAME, vi->vpdev->dnode);
-       vi->dbg = debugfs_create_dir(name, NULL);
-       debugfs_create_file("dp", 0444, vi->dbg, vi, &vop_dp_fops);
-       debugfs_create_file("vdev_info", 0444, vi->dbg, vi, &vop_vdev_info_fops);
-}
-
-void vop_exit_debugfs(struct vop_info *vi)
-{
-       debugfs_remove_recursive(vi->dbg);
-}
diff --git a/drivers/misc/mic/vop/vop_main.c b/drivers/misc/mic/vop/vop_main.c
deleted file mode 100644 (file)
index 714b94f..0000000
+++ /dev/null
@@ -1,784 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Adapted from:
- *
- * virtio for kvm on s390
- *
- * Copyright IBM Corp. 2008
- *
- *    Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
- *
- * Intel Virtio Over PCIe (VOP) driver.
- */
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/dma-mapping.h>
-#include <linux/io-64-nonatomic-lo-hi.h>
-
-#include "vop_main.h"
-
-#define VOP_MAX_VRINGS 4
-
-/*
- * _vop_vdev - Allocated per virtio device instance injected by the peer.
- *
- * @vdev: Virtio device
- * @desc: Virtio device page descriptor
- * @dc: Virtio device control
- * @vpdev: VOP device which is the parent for this virtio device
- * @vr: Buffer for accessing the VRING
- * @used_virt: Virtual address of used ring
- * @used: DMA address of used ring
- * @used_size: Size of the used buffer
- * @reset_done: Track whether VOP reset is complete
- * @virtio_cookie: Cookie returned upon requesting a interrupt
- * @c2h_vdev_db: The doorbell used by the guest to interrupt the host
- * @h2c_vdev_db: The doorbell used by the host to interrupt the guest
- * @dnode: The destination node
- */
-struct _vop_vdev {
-       struct virtio_device vdev;
-       struct mic_device_desc __iomem *desc;
-       struct mic_device_ctrl __iomem *dc;
-       struct vop_device *vpdev;
-       void __iomem *vr[VOP_MAX_VRINGS];
-       void *used_virt[VOP_MAX_VRINGS];
-       dma_addr_t used[VOP_MAX_VRINGS];
-       int used_size[VOP_MAX_VRINGS];
-       struct completion reset_done;
-       struct mic_irq *virtio_cookie;
-       int c2h_vdev_db;
-       int h2c_vdev_db;
-       int dnode;
-};
-
-#define to_vopvdev(vd) container_of(vd, struct _vop_vdev, vdev)
-
-#define _vop_aligned_desc_size(d) __mic_align(_vop_desc_size(d), 8)
-
-/* Helper API to obtain the parent of the virtio device */
-static inline struct device *_vop_dev(struct _vop_vdev *vdev)
-{
-       return vdev->vdev.dev.parent;
-}
-
-static inline unsigned _vop_desc_size(struct mic_device_desc __iomem *desc)
-{
-       return sizeof(*desc)
-               + ioread8(&desc->num_vq) * sizeof(struct mic_vqconfig)
-               + ioread8(&desc->feature_len) * 2
-               + ioread8(&desc->config_len);
-}
-
-static inline struct mic_vqconfig __iomem *
-_vop_vq_config(struct mic_device_desc __iomem *desc)
-{
-       return (struct mic_vqconfig __iomem *)(desc + 1);
-}
-
-static inline u8 __iomem *
-_vop_vq_features(struct mic_device_desc __iomem *desc)
-{
-       return (u8 __iomem *)(_vop_vq_config(desc) + ioread8(&desc->num_vq));
-}
-
-static inline u8 __iomem *
-_vop_vq_configspace(struct mic_device_desc __iomem *desc)
-{
-       return _vop_vq_features(desc) + ioread8(&desc->feature_len) * 2;
-}
-
-static inline unsigned
-_vop_total_desc_size(struct mic_device_desc __iomem *desc)
-{
-       return _vop_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl);
-}
-
-/* This gets the device's feature bits. */
-static u64 vop_get_features(struct virtio_device *vdev)
-{
-       unsigned int i, bits;
-       u64 features = 0;
-       struct mic_device_desc __iomem *desc = to_vopvdev(vdev)->desc;
-       u8 __iomem *in_features = _vop_vq_features(desc);
-       int feature_len = ioread8(&desc->feature_len);
-
-       bits = min_t(unsigned, feature_len, sizeof(vdev->features)) * 8;
-       for (i = 0; i < bits; i++)
-               if (ioread8(&in_features[i / 8]) & (BIT(i % 8)))
-                       features |= BIT_ULL(i);
-
-       return features;
-}
-
-static void vop_transport_features(struct virtio_device *vdev)
-{
-       /*
-        * Packed ring isn't enabled on virtio_vop for now,
-        * because virtio_vop uses vring_new_virtqueue() which
-        * creates virtio rings on preallocated memory.
-        */
-       __virtio_clear_bit(vdev, VIRTIO_F_RING_PACKED);
-       __virtio_set_bit(vdev, VIRTIO_F_ACCESS_PLATFORM);
-}
-
-static int vop_finalize_features(struct virtio_device *vdev)
-{
-       unsigned int i, bits;
-       struct mic_device_desc __iomem *desc = to_vopvdev(vdev)->desc;
-       u8 feature_len = ioread8(&desc->feature_len);
-       /* Second half of bitmap is features we accept. */
-       u8 __iomem *out_features =
-               _vop_vq_features(desc) + feature_len;
-
-       /* Give virtio_ring a chance to accept features. */
-       vring_transport_features(vdev);
-
-       /* Give virtio_vop a chance to accept features. */
-       vop_transport_features(vdev);
-
-       memset_io(out_features, 0, feature_len);
-       bits = min_t(unsigned, feature_len,
-                    sizeof(vdev->features)) * 8;
-       for (i = 0; i < bits; i++) {
-               if (__virtio_test_bit(vdev, i))
-                       iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
-                                &out_features[i / 8]);
-       }
-       return 0;
-}
-
-/*
- * Reading and writing elements in config space
- */
-static void vop_get(struct virtio_device *vdev, unsigned int offset,
-                   void *buf, unsigned len)
-{
-       struct mic_device_desc __iomem *desc = to_vopvdev(vdev)->desc;
-
-       if (offset + len > ioread8(&desc->config_len))
-               return;
-       memcpy_fromio(buf, _vop_vq_configspace(desc) + offset, len);
-}
-
-static void vop_set(struct virtio_device *vdev, unsigned int offset,
-                   const void *buf, unsigned len)
-{
-       struct mic_device_desc __iomem *desc = to_vopvdev(vdev)->desc;
-
-       if (offset + len > ioread8(&desc->config_len))
-               return;
-       memcpy_toio(_vop_vq_configspace(desc) + offset, buf, len);
-}
-
-/*
- * The operations to get and set the status word just access the status
- * field of the device descriptor. set_status also interrupts the host
- * to tell about status changes.
- */
-static u8 vop_get_status(struct virtio_device *vdev)
-{
-       return ioread8(&to_vopvdev(vdev)->desc->status);
-}
-
-static void vop_set_status(struct virtio_device *dev, u8 status)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-       struct vop_device *vpdev = vdev->vpdev;
-
-       if (!status)
-               return;
-       iowrite8(status, &vdev->desc->status);
-       vpdev->hw_ops->send_intr(vpdev, vdev->c2h_vdev_db);
-}
-
-/* Inform host on a virtio device reset and wait for ack from host */
-static void vop_reset_inform_host(struct virtio_device *dev)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-       struct mic_device_ctrl __iomem *dc = vdev->dc;
-       struct vop_device *vpdev = vdev->vpdev;
-       int retry;
-
-       iowrite8(0, &dc->host_ack);
-       iowrite8(1, &dc->vdev_reset);
-       vpdev->hw_ops->send_intr(vpdev, vdev->c2h_vdev_db);
-
-       /* Wait till host completes all card accesses and acks the reset */
-       for (retry = 100; retry--;) {
-               if (ioread8(&dc->host_ack))
-                       break;
-               msleep(100);
-       }
-
-       dev_dbg(_vop_dev(vdev), "%s: retry: %d\n", __func__, retry);
-
-       /* Reset status to 0 in case we timed out */
-       iowrite8(0, &vdev->desc->status);
-}
-
-static void vop_reset(struct virtio_device *dev)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-
-       dev_dbg(_vop_dev(vdev), "%s: virtio id %d\n",
-               __func__, dev->id.device);
-
-       vop_reset_inform_host(dev);
-       complete_all(&vdev->reset_done);
-}
-
-/*
- * The virtio_ring code calls this API when it wants to notify the Host.
- */
-static bool vop_notify(struct virtqueue *vq)
-{
-       struct _vop_vdev *vdev = vq->priv;
-       struct vop_device *vpdev = vdev->vpdev;
-
-       vpdev->hw_ops->send_intr(vpdev, vdev->c2h_vdev_db);
-       return true;
-}
-
-static void vop_del_vq(struct virtqueue *vq, int n)
-{
-       struct _vop_vdev *vdev = to_vopvdev(vq->vdev);
-       struct vop_device *vpdev = vdev->vpdev;
-
-       dma_unmap_single(&vpdev->dev, vdev->used[n],
-                        vdev->used_size[n], DMA_BIDIRECTIONAL);
-       free_pages((unsigned long)vdev->used_virt[n],
-                  get_order(vdev->used_size[n]));
-       vring_del_virtqueue(vq);
-       vpdev->hw_ops->unmap(vpdev, vdev->vr[n]);
-       vdev->vr[n] = NULL;
-}
-
-static void vop_del_vqs(struct virtio_device *dev)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-       struct virtqueue *vq, *n;
-       int idx = 0;
-
-       dev_dbg(_vop_dev(vdev), "%s\n", __func__);
-
-       list_for_each_entry_safe(vq, n, &dev->vqs, list)
-               vop_del_vq(vq, idx++);
-}
-
-static struct virtqueue *vop_new_virtqueue(unsigned int index,
-                                     unsigned int num,
-                                     struct virtio_device *vdev,
-                                     bool context,
-                                     void *pages,
-                                     bool (*notify)(struct virtqueue *vq),
-                                     void (*callback)(struct virtqueue *vq),
-                                     const char *name,
-                                     void *used)
-{
-       bool weak_barriers = false;
-       struct vring vring;
-
-       vring_init(&vring, num, pages, MIC_VIRTIO_RING_ALIGN);
-       vring.used = used;
-
-       return __vring_new_virtqueue(index, vring, vdev, weak_barriers, context,
-                                    notify, callback, name);
-}
-
-/*
- * This routine will assign vring's allocated in host/io memory. Code in
- * virtio_ring.c however continues to access this io memory as if it were local
- * memory without io accessors.
- */
-static struct virtqueue *vop_find_vq(struct virtio_device *dev,
-                                    unsigned index,
-                                    void (*callback)(struct virtqueue *vq),
-                                    const char *name, bool ctx)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-       struct vop_device *vpdev = vdev->vpdev;
-       struct mic_vqconfig __iomem *vqconfig;
-       struct mic_vqconfig config;
-       struct virtqueue *vq;
-       void __iomem *va;
-       struct _mic_vring_info __iomem *info;
-       void *used;
-       int vr_size, _vr_size, err, magic;
-       u8 type = ioread8(&vdev->desc->type);
-
-       if (index >= ioread8(&vdev->desc->num_vq))
-               return ERR_PTR(-ENOENT);
-
-       if (!name)
-               return ERR_PTR(-ENOENT);
-
-       /* First assign the vring's allocated in host memory */
-       vqconfig = _vop_vq_config(vdev->desc) + index;
-       memcpy_fromio(&config, vqconfig, sizeof(config));
-       _vr_size = round_up(vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN), 4);
-       vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info));
-       va = vpdev->hw_ops->remap(vpdev, le64_to_cpu(config.address), vr_size);
-       if (!va)
-               return ERR_PTR(-ENOMEM);
-       vdev->vr[index] = va;
-       memset_io(va, 0x0, _vr_size);
-
-       info = va + _vr_size;
-       magic = ioread32(&info->magic);
-
-       if (WARN(magic != MIC_MAGIC + type + index, "magic mismatch")) {
-               err = -EIO;
-               goto unmap;
-       }
-
-       vdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
-                                            sizeof(struct vring_used_elem) *
-                                            le16_to_cpu(config.num));
-       used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
-                                       get_order(vdev->used_size[index]));
-       vdev->used_virt[index] = used;
-       if (!used) {
-               err = -ENOMEM;
-               dev_err(_vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto unmap;
-       }
-
-       vq = vop_new_virtqueue(index, le16_to_cpu(config.num), dev, ctx,
-                              (void __force *)va, vop_notify, callback,
-                              name, used);
-       if (!vq) {
-               err = -ENOMEM;
-               goto free_used;
-       }
-
-       vdev->used[index] = dma_map_single(&vpdev->dev, used,
-                                           vdev->used_size[index],
-                                           DMA_BIDIRECTIONAL);
-       if (dma_mapping_error(&vpdev->dev, vdev->used[index])) {
-               err = -ENOMEM;
-               dev_err(_vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto del_vq;
-       }
-       writeq(vdev->used[index], &vqconfig->used_address);
-
-       vq->priv = vdev;
-       return vq;
-del_vq:
-       vring_del_virtqueue(vq);
-free_used:
-       free_pages((unsigned long)used,
-                  get_order(vdev->used_size[index]));
-unmap:
-       vpdev->hw_ops->unmap(vpdev, vdev->vr[index]);
-       return ERR_PTR(err);
-}
-
-static int vop_find_vqs(struct virtio_device *dev, unsigned nvqs,
-                       struct virtqueue *vqs[],
-                       vq_callback_t *callbacks[],
-                       const char * const names[], const bool *ctx,
-                       struct irq_affinity *desc)
-{
-       struct _vop_vdev *vdev = to_vopvdev(dev);
-       struct vop_device *vpdev = vdev->vpdev;
-       struct mic_device_ctrl __iomem *dc = vdev->dc;
-       int i, err, retry, queue_idx = 0;
-
-       /* We must have this many virtqueues. */
-       if (nvqs > ioread8(&vdev->desc->num_vq))
-               return -ENOENT;
-
-       for (i = 0; i < nvqs; ++i) {
-               if (!names[i]) {
-                       vqs[i] = NULL;
-                       continue;
-               }
-
-               dev_dbg(_vop_dev(vdev), "%s: %d: %s\n",
-                       __func__, i, names[i]);
-               vqs[i] = vop_find_vq(dev, queue_idx++, callbacks[i], names[i],
-                                    ctx ? ctx[i] : false);
-               if (IS_ERR(vqs[i])) {
-                       err = PTR_ERR(vqs[i]);
-                       goto error;
-               }
-       }
-
-       iowrite8(1, &dc->used_address_updated);
-       /*
-        * Send an interrupt to the host to inform it that used
-        * rings have been re-assigned.
-        */
-       vpdev->hw_ops->send_intr(vpdev, vdev->c2h_vdev_db);
-       for (retry = 100; --retry;) {
-               if (!ioread8(&dc->used_address_updated))
-                       break;
-               msleep(100);
-       }
-
-       dev_dbg(_vop_dev(vdev), "%s: retry: %d\n", __func__, retry);
-       if (!retry) {
-               err = -ENODEV;
-               goto error;
-       }
-
-       return 0;
-error:
-       vop_del_vqs(dev);
-       return err;
-}
-
-/*
- * The config ops structure as defined by virtio config
- */
-static const struct virtio_config_ops vop_vq_config_ops = {
-       .get_features = vop_get_features,
-       .finalize_features = vop_finalize_features,
-       .get = vop_get,
-       .set = vop_set,
-       .get_status = vop_get_status,
-       .set_status = vop_set_status,
-       .reset = vop_reset,
-       .find_vqs = vop_find_vqs,
-       .del_vqs = vop_del_vqs,
-};
-
-static irqreturn_t vop_virtio_intr_handler(int irq, void *data)
-{
-       struct _vop_vdev *vdev = data;
-       struct vop_device *vpdev = vdev->vpdev;
-       struct virtqueue *vq;
-
-       vpdev->hw_ops->ack_interrupt(vpdev, vdev->h2c_vdev_db);
-       list_for_each_entry(vq, &vdev->vdev.vqs, list)
-               vring_interrupt(0, vq);
-
-       return IRQ_HANDLED;
-}
-
-static void vop_virtio_release_dev(struct device *_d)
-{
-       struct virtio_device *vdev =
-                       container_of(_d, struct virtio_device, dev);
-       struct _vop_vdev *vop_vdev =
-                       container_of(vdev, struct _vop_vdev, vdev);
-
-       kfree(vop_vdev);
-}
-
-/*
- * adds a new device and register it with virtio
- * appropriate drivers are loaded by the device model
- */
-static int _vop_add_device(struct mic_device_desc __iomem *d,
-                          unsigned int offset, struct vop_device *vpdev,
-                          int dnode)
-{
-       struct _vop_vdev *vdev, *reg_dev = NULL;
-       int ret;
-       u8 type = ioread8(&d->type);
-
-       vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
-       if (!vdev)
-               return -ENOMEM;
-
-       vdev->vpdev = vpdev;
-       vdev->vdev.dev.parent = &vpdev->dev;
-       vdev->vdev.dev.release = vop_virtio_release_dev;
-       vdev->vdev.id.device = type;
-       vdev->vdev.config = &vop_vq_config_ops;
-       vdev->desc = d;
-       vdev->dc = (void __iomem *)d + _vop_aligned_desc_size(d);
-       vdev->dnode = dnode;
-       vdev->vdev.priv = (void *)(unsigned long)dnode;
-       init_completion(&vdev->reset_done);
-
-       vdev->h2c_vdev_db = vpdev->hw_ops->next_db(vpdev);
-       vdev->virtio_cookie = vpdev->hw_ops->request_irq(vpdev,
-                       vop_virtio_intr_handler, "virtio intr",
-                       vdev, vdev->h2c_vdev_db);
-       if (IS_ERR(vdev->virtio_cookie)) {
-               ret = PTR_ERR(vdev->virtio_cookie);
-               goto kfree;
-       }
-       iowrite8((u8)vdev->h2c_vdev_db, &vdev->dc->h2c_vdev_db);
-       vdev->c2h_vdev_db = ioread8(&vdev->dc->c2h_vdev_db);
-
-       ret = register_virtio_device(&vdev->vdev);
-       reg_dev = vdev;
-       if (ret) {
-               dev_err(_vop_dev(vdev),
-                       "Failed to register vop device %u type %u\n",
-                       offset, type);
-               goto free_irq;
-       }
-       writeq((unsigned long)vdev, &vdev->dc->vdev);
-       dev_dbg(_vop_dev(vdev), "%s: registered vop device %u type %u vdev %p\n",
-               __func__, offset, type, vdev);
-
-       return 0;
-
-free_irq:
-       vpdev->hw_ops->free_irq(vpdev, vdev->virtio_cookie, vdev);
-kfree:
-       if (reg_dev)
-               put_device(&vdev->vdev.dev);
-       else
-               kfree(vdev);
-       return ret;
-}
-
-/*
- * match for a vop device with a specific desc pointer
- */
-static int vop_match_desc(struct device *dev, void *data)
-{
-       struct virtio_device *_dev = dev_to_virtio(dev);
-       struct _vop_vdev *vdev = to_vopvdev(_dev);
-
-       return vdev->desc == (void __iomem *)data;
-}
-
-static struct _vop_vdev *vop_dc_to_vdev(struct mic_device_ctrl __iomem *dc)
-{
-       return (struct _vop_vdev *)(unsigned long)readq(&dc->vdev);
-}
-
-static void _vop_handle_config_change(struct mic_device_desc __iomem *d,
-                                     unsigned int offset,
-                                     struct vop_device *vpdev)
-{
-       struct mic_device_ctrl __iomem *dc
-               = (void __iomem *)d + _vop_aligned_desc_size(d);
-       struct _vop_vdev *vdev = vop_dc_to_vdev(dc);
-
-       if (ioread8(&dc->config_change) != MIC_VIRTIO_PARAM_CONFIG_CHANGED)
-               return;
-
-       dev_dbg(&vpdev->dev, "%s %d\n", __func__, __LINE__);
-       virtio_config_changed(&vdev->vdev);
-       iowrite8(1, &dc->guest_ack);
-}
-
-/*
- * removes a virtio device if a hot remove event has been
- * requested by the host.
- */
-static int _vop_remove_device(struct mic_device_desc __iomem *d,
-                             unsigned int offset, struct vop_device *vpdev)
-{
-       struct mic_device_ctrl __iomem *dc
-               = (void __iomem *)d + _vop_aligned_desc_size(d);
-       struct _vop_vdev *vdev = vop_dc_to_vdev(dc);
-       u8 status;
-       int ret = -1;
-
-       if (ioread8(&dc->config_change) == MIC_VIRTIO_PARAM_DEV_REMOVE) {
-               struct device *dev = get_device(&vdev->vdev.dev);
-
-               dev_dbg(&vpdev->dev,
-                       "%s %d config_change %d type %d vdev %p\n",
-                       __func__, __LINE__,
-                       ioread8(&dc->config_change), ioread8(&d->type), vdev);
-               status = ioread8(&d->status);
-               reinit_completion(&vdev->reset_done);
-               unregister_virtio_device(&vdev->vdev);
-               vpdev->hw_ops->free_irq(vpdev, vdev->virtio_cookie, vdev);
-               iowrite8(-1, &dc->h2c_vdev_db);
-               if (status & VIRTIO_CONFIG_S_DRIVER_OK)
-                       wait_for_completion(&vdev->reset_done);
-               put_device(dev);
-               iowrite8(1, &dc->guest_ack);
-               dev_dbg(&vpdev->dev, "%s %d guest_ack %d\n",
-                       __func__, __LINE__, ioread8(&dc->guest_ack));
-               iowrite8(-1, &d->type);
-               ret = 0;
-       }
-       return ret;
-}
-
-#define REMOVE_DEVICES true
-
-static void _vop_scan_devices(void __iomem *dp, struct vop_device *vpdev,
-                             bool remove, int dnode)
-{
-       s8 type;
-       unsigned int i;
-       struct mic_device_desc __iomem *d;
-       struct mic_device_ctrl __iomem *dc;
-       struct device *dev;
-
-       for (i = sizeof(struct mic_bootparam);
-                       i < MIC_DP_SIZE; i += _vop_total_desc_size(d)) {
-               d = dp + i;
-               dc = (void __iomem *)d + _vop_aligned_desc_size(d);
-               /*
-                * This read barrier is paired with the corresponding write
-                * barrier on the host which is inserted before adding or
-                * removing a virtio device descriptor, by updating the type.
-                */
-               rmb();
-               type = ioread8(&d->type);
-
-               /* end of list */
-               if (type == 0)
-                       break;
-
-               if (type == -1)
-                       continue;
-
-               /* device already exists */
-               dev = device_find_child(&vpdev->dev, (void __force *)d,
-                                       vop_match_desc);
-               if (dev) {
-                       if (remove)
-                               iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
-                                        &dc->config_change);
-                       put_device(dev);
-                       _vop_handle_config_change(d, i, vpdev);
-                       _vop_remove_device(d, i, vpdev);
-                       if (remove) {
-                               iowrite8(0, &dc->config_change);
-                               iowrite8(0, &dc->guest_ack);
-                       }
-                       continue;
-               }
-
-               /* new device */
-               dev_dbg(&vpdev->dev, "%s %d Adding new virtio device %p\n",
-                       __func__, __LINE__, d);
-               if (!remove)
-                       _vop_add_device(d, i, vpdev, dnode);
-       }
-}
-
-static void vop_scan_devices(struct vop_info *vi,
-                            struct vop_device *vpdev, bool remove)
-{
-       void __iomem *dp = vpdev->hw_ops->get_remote_dp(vpdev);
-
-       if (!dp)
-               return;
-       mutex_lock(&vi->vop_mutex);
-       _vop_scan_devices(dp, vpdev, remove, vpdev->dnode);
-       mutex_unlock(&vi->vop_mutex);
-}
-
-/*
- * vop_hotplug_device tries to find changes in the device page.
- */
-static void vop_hotplug_devices(struct work_struct *work)
-{
-       struct vop_info *vi = container_of(work, struct vop_info,
-                                            hotplug_work);
-
-       vop_scan_devices(vi, vi->vpdev, !REMOVE_DEVICES);
-}
-
-/*
- * Interrupt handler for hot plug/config changes etc.
- */
-static irqreturn_t vop_extint_handler(int irq, void *data)
-{
-       struct vop_info *vi = data;
-       struct mic_bootparam __iomem *bp;
-       struct vop_device *vpdev = vi->vpdev;
-
-       bp = vpdev->hw_ops->get_remote_dp(vpdev);
-       dev_dbg(&vpdev->dev, "%s %d hotplug work\n",
-               __func__, __LINE__);
-       vpdev->hw_ops->ack_interrupt(vpdev, ioread8(&bp->h2c_config_db));
-       schedule_work(&vi->hotplug_work);
-       return IRQ_HANDLED;
-}
-
-static int vop_driver_probe(struct vop_device *vpdev)
-{
-       struct vop_info *vi;
-       int rc;
-
-       vi = kzalloc(sizeof(*vi), GFP_KERNEL);
-       if (!vi) {
-               rc = -ENOMEM;
-               goto exit;
-       }
-       dev_set_drvdata(&vpdev->dev, vi);
-       vi->vpdev = vpdev;
-
-       mutex_init(&vi->vop_mutex);
-       INIT_WORK(&vi->hotplug_work, vop_hotplug_devices);
-       if (vpdev->dnode) {
-               rc = vop_host_init(vi);
-               if (rc < 0)
-                       goto free;
-       } else {
-               struct mic_bootparam __iomem *bootparam;
-
-               vop_scan_devices(vi, vpdev, !REMOVE_DEVICES);
-
-               vi->h2c_config_db = vpdev->hw_ops->next_db(vpdev);
-               vi->cookie = vpdev->hw_ops->request_irq(vpdev,
-                                                       vop_extint_handler,
-                                                       "virtio_config_intr",
-                                                       vi, vi->h2c_config_db);
-               if (IS_ERR(vi->cookie)) {
-                       rc = PTR_ERR(vi->cookie);
-                       goto free;
-               }
-               bootparam = vpdev->hw_ops->get_remote_dp(vpdev);
-               iowrite8(vi->h2c_config_db, &bootparam->h2c_config_db);
-       }
-       vop_init_debugfs(vi);
-       return 0;
-free:
-       kfree(vi);
-exit:
-       return rc;
-}
-
-static void vop_driver_remove(struct vop_device *vpdev)
-{
-       struct vop_info *vi = dev_get_drvdata(&vpdev->dev);
-
-       if (vpdev->dnode) {
-               vop_host_uninit(vi);
-       } else {
-               struct mic_bootparam __iomem *bootparam =
-                       vpdev->hw_ops->get_remote_dp(vpdev);
-               if (bootparam)
-                       iowrite8(-1, &bootparam->h2c_config_db);
-               vpdev->hw_ops->free_irq(vpdev, vi->cookie, vi);
-               flush_work(&vi->hotplug_work);
-               vop_scan_devices(vi, vpdev, REMOVE_DEVICES);
-       }
-       vop_exit_debugfs(vi);
-       kfree(vi);
-}
-
-static const struct vop_device_id id_table[] = {
-       { VOP_DEV_TRNSP, VOP_DEV_ANY_ID },
-       { 0 },
-};
-
-static struct vop_driver vop_driver = {
-       .driver.name =  KBUILD_MODNAME,
-       .driver.owner = THIS_MODULE,
-       .id_table = id_table,
-       .probe = vop_driver_probe,
-       .remove = vop_driver_remove,
-};
-
-module_vop_driver(vop_driver);
-
-MODULE_DEVICE_TABLE(mbus, id_table);
-MODULE_AUTHOR("Intel Corporation");
-MODULE_DESCRIPTION("Intel(R) Virtio Over PCIe (VOP) driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/mic/vop/vop_main.h b/drivers/misc/mic/vop/vop_main.h
deleted file mode 100644 (file)
index 2451d92..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Intel Virtio Over PCIe (VOP) driver.
- */
-#ifndef _VOP_MAIN_H_
-#define _VOP_MAIN_H_
-
-#include <linux/vringh.h>
-#include <linux/virtio_config.h>
-#include <linux/virtio.h>
-#include <linux/miscdevice.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-
-#include "../bus/vop_bus.h"
-
-/*
- * Note on endianness.
- * 1. Host can be both BE or LE
- * 2. Guest/card is LE. Host uses le_to_cpu to access desc/avail
- *    rings and ioreadXX/iowriteXX to access used ring.
- * 3. Device page exposed by host to guest contains LE values. Guest
- *    accesses these using ioreadXX/iowriteXX etc. This way in general we
- *    obey the virtio spec according to which guest works with native
- *    endianness and host is aware of guest endianness and does all
- *    required endianness conversion.
- * 4. Data provided from user space to guest (in ADD_DEVICE and
- *    CONFIG_CHANGE ioctl's) is not interpreted by the driver and should be
- *    in guest endianness.
- */
-
-/*
- * vop_info - Allocated per invocation of VOP probe
- *
- * @vpdev: VOP device
- * @hotplug_work: Handle virtio device creation, deletion and configuration
- * @cookie: Cookie received upon requesting a virtio configuration interrupt
- * @h2c_config_db: The doorbell used by the peer to indicate a config change
- * @vdev_list: List of "active" virtio devices injected in the peer node
- * @vop_mutex: Synchronize access to the device page as well as serialize
- *             creation/deletion of virtio devices on the peer node
- * @dp: Peer device page information
- * @dbg: Debugfs entry
- * @dma_ch: The DMA channel used by this transport for data transfers.
- * @name: Name for this transport used in misc device creation.
- * @miscdev: The misc device registered.
- */
-struct vop_info {
-       struct vop_device *vpdev;
-       struct work_struct hotplug_work;
-       struct mic_irq *cookie;
-       int h2c_config_db;
-       struct list_head vdev_list;
-       struct mutex vop_mutex;
-       void __iomem *dp;
-       struct dentry *dbg;
-       struct dma_chan *dma_ch;
-       char name[16];
-       struct miscdevice miscdev;
-};
-
-/**
- * struct vop_vringh - Virtio ring host information.
- *
- * @vring: The VOP vring used for setting up user space mappings.
- * @vrh: The host VRINGH used for accessing the card vrings.
- * @riov: The VRINGH read kernel IOV.
- * @wiov: The VRINGH write kernel IOV.
- * @head: The VRINGH head index address passed to vringh_getdesc_kern(..).
- * @vr_mutex: Mutex for synchronizing access to the VRING.
- * @buf: Temporary kernel buffer used to copy in/out data
- * from/to the card via DMA.
- * @buf_da: dma address of buf.
- * @vdev: Back pointer to VOP virtio device for vringh_notify(..).
- */
-struct vop_vringh {
-       struct mic_vring vring;
-       struct vringh vrh;
-       struct vringh_kiov riov;
-       struct vringh_kiov wiov;
-       u16 head;
-       struct mutex vr_mutex;
-       void *buf;
-       dma_addr_t buf_da;
-       struct vop_vdev *vdev;
-};
-
-/**
- * struct vop_vdev - Host information for a card Virtio device.
- *
- * @virtio_id - Virtio device id.
- * @waitq - Waitqueue to allow ring3 apps to poll.
- * @vpdev - pointer to VOP bus device.
- * @poll_wake - Used for waking up threads blocked in poll.
- * @out_bytes - Debug stats for number of bytes copied from host to card.
- * @in_bytes - Debug stats for number of bytes copied from card to host.
- * @out_bytes_dma - Debug stats for number of bytes copied from host to card
- * using DMA.
- * @in_bytes_dma - Debug stats for number of bytes copied from card to host
- * using DMA.
- * @tx_len_unaligned - Debug stats for number of bytes copied to the card where
- * the transfer length did not have the required DMA alignment.
- * @tx_dst_unaligned - Debug stats for number of bytes copied where the
- * destination address on the card did not have the required DMA alignment.
- * @vvr - Store per VRING data structures.
- * @virtio_bh_work - Work struct used to schedule virtio bottom half handling.
- * @dd - Virtio device descriptor.
- * @dc - Virtio device control fields.
- * @list - List of Virtio devices.
- * @virtio_db - The doorbell used by the card to interrupt the host.
- * @virtio_cookie - The cookie returned while requesting interrupts.
- * @vi: Transport information.
- * @vdev_mutex: Mutex synchronizing virtio device injection,
- *              removal and data transfers.
- * @destroy: Track if a virtio device is being destroyed.
- * @deleted: The virtio device has been deleted.
- */
-struct vop_vdev {
-       int virtio_id;
-       wait_queue_head_t waitq;
-       struct vop_device *vpdev;
-       int poll_wake;
-       unsigned long out_bytes;
-       unsigned long in_bytes;
-       unsigned long out_bytes_dma;
-       unsigned long in_bytes_dma;
-       unsigned long tx_len_unaligned;
-       unsigned long tx_dst_unaligned;
-       unsigned long rx_dst_unaligned;
-       struct vop_vringh vvr[MIC_MAX_VRINGS];
-       struct work_struct virtio_bh_work;
-       struct mic_device_desc *dd;
-       struct mic_device_ctrl *dc;
-       struct list_head list;
-       int virtio_db;
-       struct mic_irq *virtio_cookie;
-       struct vop_info *vi;
-       struct mutex vdev_mutex;
-       struct completion destroy;
-       bool deleted;
-};
-
-/* Helper API to check if a virtio device is running */
-static inline bool vop_vdevup(struct vop_vdev *vdev)
-{
-       return !!vdev->dd->status;
-}
-
-void vop_init_debugfs(struct vop_info *vi);
-void vop_exit_debugfs(struct vop_info *vi);
-int vop_host_init(struct vop_info *vi);
-void vop_host_uninit(struct vop_info *vi);
-#endif
diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
deleted file mode 100644 (file)
index 7014ffe..0000000
+++ /dev/null
@@ -1,1166 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2016 Intel Corporation.
- *
- * Intel Virtio Over PCIe (VOP) driver.
- */
-#include <linux/sched.h>
-#include <linux/poll.h>
-#include <linux/dma-mapping.h>
-
-#include <linux/mic_common.h>
-#include "../common/mic_dev.h"
-
-#include <linux/mic_ioctl.h>
-#include "vop_main.h"
-
-/* Helper API to obtain the VOP PCIe device */
-static inline struct device *vop_dev(struct vop_vdev *vdev)
-{
-       return vdev->vpdev->dev.parent;
-}
-
-/* Helper API to check if a virtio device is initialized */
-static inline int vop_vdev_inited(struct vop_vdev *vdev)
-{
-       if (!vdev)
-               return -EINVAL;
-       /* Device has not been created yet */
-       if (!vdev->dd || !vdev->dd->type) {
-               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, -EINVAL);
-               return -EINVAL;
-       }
-       /* Device has been removed/deleted */
-       if (vdev->dd->type == -1) {
-               dev_dbg(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, -ENODEV);
-               return -ENODEV;
-       }
-       return 0;
-}
-
-static void _vop_notify(struct vringh *vrh)
-{
-       struct vop_vringh *vvrh = container_of(vrh, struct vop_vringh, vrh);
-       struct vop_vdev *vdev = vvrh->vdev;
-       struct vop_device *vpdev = vdev->vpdev;
-       s8 db = vdev->dc->h2c_vdev_db;
-
-       if (db != -1)
-               vpdev->hw_ops->send_intr(vpdev, db);
-}
-
-static void vop_virtio_init_post(struct vop_vdev *vdev)
-{
-       struct mic_vqconfig *vqconfig = mic_vq_config(vdev->dd);
-       struct vop_device *vpdev = vdev->vpdev;
-       int i, used_size;
-
-       for (i = 0; i < vdev->dd->num_vq; i++) {
-               used_size = PAGE_ALIGN(sizeof(u16) * 3 +
-                               sizeof(struct vring_used_elem) *
-                               le16_to_cpu(vqconfig->num));
-               if (!le64_to_cpu(vqconfig[i].used_address)) {
-                       dev_warn(vop_dev(vdev), "used_address zero??\n");
-                       continue;
-               }
-               vdev->vvr[i].vrh.vring.used =
-                       (void __force *)vpdev->hw_ops->remap(
-                       vpdev,
-                       le64_to_cpu(vqconfig[i].used_address),
-                       used_size);
-       }
-
-       vdev->dc->used_address_updated = 0;
-
-       dev_info(vop_dev(vdev), "%s: device type %d LINKUP\n",
-                __func__, vdev->virtio_id);
-}
-
-static inline void vop_virtio_device_reset(struct vop_vdev *vdev)
-{
-       int i;
-
-       dev_dbg(vop_dev(vdev), "%s: status %d device type %d RESET\n",
-               __func__, vdev->dd->status, vdev->virtio_id);
-
-       for (i = 0; i < vdev->dd->num_vq; i++)
-               /*
-                * Avoid lockdep false positive. The + 1 is for the vop
-                * mutex which is held in the reset devices code path.
-                */
-               mutex_lock_nested(&vdev->vvr[i].vr_mutex, i + 1);
-
-       /* 0 status means "reset" */
-       vdev->dd->status = 0;
-       vdev->dc->vdev_reset = 0;
-       vdev->dc->host_ack = 1;
-
-       for (i = 0; i < vdev->dd->num_vq; i++) {
-               struct vringh *vrh = &vdev->vvr[i].vrh;
-
-               vdev->vvr[i].vring.info->avail_idx = 0;
-               vrh->completed = 0;
-               vrh->last_avail_idx = 0;
-               vrh->last_used_idx = 0;
-       }
-
-       for (i = 0; i < vdev->dd->num_vq; i++)
-               mutex_unlock(&vdev->vvr[i].vr_mutex);
-}
-
-static void vop_virtio_reset_devices(struct vop_info *vi)
-{
-       struct list_head *pos, *tmp;
-       struct vop_vdev *vdev;
-
-       list_for_each_safe(pos, tmp, &vi->vdev_list) {
-               vdev = list_entry(pos, struct vop_vdev, list);
-               vop_virtio_device_reset(vdev);
-               vdev->poll_wake = 1;
-               wake_up(&vdev->waitq);
-       }
-}
-
-static void vop_bh_handler(struct work_struct *work)
-{
-       struct vop_vdev *vdev = container_of(work, struct vop_vdev,
-                       virtio_bh_work);
-
-       if (vdev->dc->used_address_updated)
-               vop_virtio_init_post(vdev);
-
-       if (vdev->dc->vdev_reset)
-               vop_virtio_device_reset(vdev);
-
-       vdev->poll_wake = 1;
-       wake_up(&vdev->waitq);
-}
-
-static irqreturn_t _vop_virtio_intr_handler(int irq, void *data)
-{
-       struct vop_vdev *vdev = data;
-       struct vop_device *vpdev = vdev->vpdev;
-
-       vpdev->hw_ops->ack_interrupt(vpdev, vdev->virtio_db);
-       schedule_work(&vdev->virtio_bh_work);
-       return IRQ_HANDLED;
-}
-
-static int vop_virtio_config_change(struct vop_vdev *vdev, void *argp)
-{
-       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
-       int ret = 0, retry, i;
-       struct vop_device *vpdev = vdev->vpdev;
-       struct vop_info *vi = dev_get_drvdata(&vpdev->dev);
-       struct mic_bootparam *bootparam = vpdev->hw_ops->get_dp(vpdev);
-       s8 db = bootparam->h2c_config_db;
-
-       mutex_lock(&vi->vop_mutex);
-       for (i = 0; i < vdev->dd->num_vq; i++)
-               mutex_lock_nested(&vdev->vvr[i].vr_mutex, i + 1);
-
-       if (db == -1 || vdev->dd->type == -1) {
-               ret = -EIO;
-               goto exit;
-       }
-
-       memcpy(mic_vq_configspace(vdev->dd), argp, vdev->dd->config_len);
-       vdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED;
-       vpdev->hw_ops->send_intr(vpdev, db);
-
-       for (retry = 100; retry--;) {
-               ret = wait_event_timeout(wake, vdev->dc->guest_ack,
-                                        msecs_to_jiffies(100));
-               if (ret)
-                       break;
-       }
-
-       dev_dbg(vop_dev(vdev),
-               "%s %d retry: %d\n", __func__, __LINE__, retry);
-       vdev->dc->config_change = 0;
-       vdev->dc->guest_ack = 0;
-exit:
-       for (i = 0; i < vdev->dd->num_vq; i++)
-               mutex_unlock(&vdev->vvr[i].vr_mutex);
-       mutex_unlock(&vi->vop_mutex);
-       return ret;
-}
-
-static int vop_copy_dp_entry(struct vop_vdev *vdev,
-                            struct mic_device_desc *argp, __u8 *type,
-                            struct mic_device_desc **devpage)
-{
-       struct vop_device *vpdev = vdev->vpdev;
-       struct mic_device_desc *devp;
-       struct mic_vqconfig *vqconfig;
-       int ret = 0, i;
-       bool slot_found = false;
-
-       vqconfig = mic_vq_config(argp);
-       for (i = 0; i < argp->num_vq; i++) {
-               if (le16_to_cpu(vqconfig[i].num) > MIC_MAX_VRING_ENTRIES) {
-                       ret =  -EINVAL;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       goto exit;
-               }
-       }
-
-       /* Find the first free device page entry */
-       for (i = sizeof(struct mic_bootparam);
-               i < MIC_DP_SIZE - mic_total_desc_size(argp);
-               i += mic_total_desc_size(devp)) {
-               devp = vpdev->hw_ops->get_dp(vpdev) + i;
-               if (devp->type == 0 || devp->type == -1) {
-                       slot_found = true;
-                       break;
-               }
-       }
-       if (!slot_found) {
-               ret =  -EINVAL;
-               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, ret);
-               goto exit;
-       }
-       /*
-        * Save off the type before doing the memcpy. Type will be set in the
-        * end after completing all initialization for the new device.
-        */
-       *type = argp->type;
-       argp->type = 0;
-       memcpy(devp, argp, mic_desc_size(argp));
-
-       *devpage = devp;
-exit:
-       return ret;
-}
-
-static void vop_init_device_ctrl(struct vop_vdev *vdev,
-                                struct mic_device_desc *devpage)
-{
-       struct mic_device_ctrl *dc;
-
-       dc = (void *)devpage + mic_aligned_desc_size(devpage);
-
-       dc->config_change = 0;
-       dc->guest_ack = 0;
-       dc->vdev_reset = 0;
-       dc->host_ack = 0;
-       dc->used_address_updated = 0;
-       dc->c2h_vdev_db = -1;
-       dc->h2c_vdev_db = -1;
-       vdev->dc = dc;
-}
-
-static int vop_virtio_add_device(struct vop_vdev *vdev,
-                                struct mic_device_desc *argp)
-{
-       struct vop_info *vi = vdev->vi;
-       struct vop_device *vpdev = vi->vpdev;
-       struct mic_device_desc *dd = NULL;
-       struct mic_vqconfig *vqconfig;
-       int vr_size, i, j, ret;
-       u8 type = 0;
-       s8 db = -1;
-       char irqname[16];
-       struct mic_bootparam *bootparam;
-       u16 num;
-       dma_addr_t vr_addr;
-
-       bootparam = vpdev->hw_ops->get_dp(vpdev);
-       init_waitqueue_head(&vdev->waitq);
-       INIT_LIST_HEAD(&vdev->list);
-       vdev->vpdev = vpdev;
-
-       ret = vop_copy_dp_entry(vdev, argp, &type, &dd);
-       if (ret) {
-               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, ret);
-               return ret;
-       }
-
-       vop_init_device_ctrl(vdev, dd);
-
-       vdev->dd = dd;
-       vdev->virtio_id = type;
-       vqconfig = mic_vq_config(dd);
-       INIT_WORK(&vdev->virtio_bh_work, vop_bh_handler);
-
-       for (i = 0; i < dd->num_vq; i++) {
-               struct vop_vringh *vvr = &vdev->vvr[i];
-               struct mic_vring *vr = &vdev->vvr[i].vring;
-
-               num = le16_to_cpu(vqconfig[i].num);
-               mutex_init(&vvr->vr_mutex);
-               vr_size = PAGE_ALIGN(round_up(vring_size(num, MIC_VIRTIO_RING_ALIGN), 4) +
-                       sizeof(struct _mic_vring_info));
-               vr->va = (void *)
-                       __get_free_pages(GFP_KERNEL | __GFP_ZERO,
-                                        get_order(vr_size));
-               if (!vr->va) {
-                       ret = -ENOMEM;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       goto err;
-               }
-               vr->len = vr_size;
-               vr->info = vr->va + round_up(vring_size(num, MIC_VIRTIO_RING_ALIGN), 4);
-               vr->info->magic = cpu_to_le32(MIC_MAGIC + vdev->virtio_id + i);
-               vr_addr = dma_map_single(&vpdev->dev, vr->va, vr_size,
-                                        DMA_BIDIRECTIONAL);
-               if (dma_mapping_error(&vpdev->dev, vr_addr)) {
-                       free_pages((unsigned long)vr->va, get_order(vr_size));
-                       ret = -ENOMEM;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       goto err;
-               }
-               vqconfig[i].address = cpu_to_le64(vr_addr);
-
-               vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN);
-               ret = vringh_init_kern(&vvr->vrh,
-                                      *(u32 *)mic_vq_features(vdev->dd),
-                                      num, false, vr->vr.desc, vr->vr.avail,
-                                      vr->vr.used);
-               if (ret) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       goto err;
-               }
-               vringh_kiov_init(&vvr->riov, NULL, 0);
-               vringh_kiov_init(&vvr->wiov, NULL, 0);
-               vvr->head = USHRT_MAX;
-               vvr->vdev = vdev;
-               vvr->vrh.notify = _vop_notify;
-               dev_dbg(&vpdev->dev,
-                       "%s %d index %d va %p info %p vr_size 0x%x\n",
-                       __func__, __LINE__, i, vr->va, vr->info, vr_size);
-               vvr->buf = (void *)__get_free_pages(GFP_KERNEL,
-                                       get_order(VOP_INT_DMA_BUF_SIZE));
-               vvr->buf_da = dma_map_single(&vpdev->dev,
-                                         vvr->buf, VOP_INT_DMA_BUF_SIZE,
-                                         DMA_BIDIRECTIONAL);
-       }
-
-       snprintf(irqname, sizeof(irqname), "vop%dvirtio%d", vpdev->index,
-                vdev->virtio_id);
-       vdev->virtio_db = vpdev->hw_ops->next_db(vpdev);
-       vdev->virtio_cookie = vpdev->hw_ops->request_irq(vpdev,
-                       _vop_virtio_intr_handler, irqname, vdev,
-                       vdev->virtio_db);
-       if (IS_ERR(vdev->virtio_cookie)) {
-               ret = PTR_ERR(vdev->virtio_cookie);
-               dev_dbg(&vpdev->dev, "request irq failed\n");
-               goto err;
-       }
-
-       vdev->dc->c2h_vdev_db = vdev->virtio_db;
-
-       /*
-        * Order the type update with previous stores. This write barrier
-        * is paired with the corresponding read barrier before the uncached
-        * system memory read of the type, on the card while scanning the
-        * device page.
-        */
-       smp_wmb();
-       dd->type = type;
-       argp->type = type;
-
-       if (bootparam) {
-               db = bootparam->h2c_config_db;
-               if (db != -1)
-                       vpdev->hw_ops->send_intr(vpdev, db);
-       }
-       dev_dbg(&vpdev->dev, "Added virtio id %d db %d\n", dd->type, db);
-       return 0;
-err:
-       vqconfig = mic_vq_config(dd);
-       for (j = 0; j < i; j++) {
-               struct vop_vringh *vvr = &vdev->vvr[j];
-
-               dma_unmap_single(&vpdev->dev, le64_to_cpu(vqconfig[j].address),
-                                vvr->vring.len, DMA_BIDIRECTIONAL);
-               free_pages((unsigned long)vvr->vring.va,
-                          get_order(vvr->vring.len));
-       }
-       return ret;
-}
-
-static void vop_dev_remove(struct vop_info *pvi, struct mic_device_ctrl *devp,
-                          struct vop_device *vpdev)
-{
-       struct mic_bootparam *bootparam = vpdev->hw_ops->get_dp(vpdev);
-       s8 db;
-       int ret, retry;
-       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
-
-       devp->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE;
-       db = bootparam->h2c_config_db;
-       if (db != -1)
-               vpdev->hw_ops->send_intr(vpdev, db);
-       else
-               goto done;
-       for (retry = 15; retry--;) {
-               ret = wait_event_timeout(wake, devp->guest_ack,
-                                        msecs_to_jiffies(1000));
-               if (ret)
-                       break;
-       }
-done:
-       devp->config_change = 0;
-       devp->guest_ack = 0;
-}
-
-static void vop_virtio_del_device(struct vop_vdev *vdev)
-{
-       struct vop_info *vi = vdev->vi;
-       struct vop_device *vpdev = vdev->vpdev;
-       int i;
-       struct mic_vqconfig *vqconfig;
-       struct mic_bootparam *bootparam = vpdev->hw_ops->get_dp(vpdev);
-
-       if (!bootparam)
-               goto skip_hot_remove;
-       vop_dev_remove(vi, vdev->dc, vpdev);
-skip_hot_remove:
-       vpdev->hw_ops->free_irq(vpdev, vdev->virtio_cookie, vdev);
-       flush_work(&vdev->virtio_bh_work);
-       vqconfig = mic_vq_config(vdev->dd);
-       for (i = 0; i < vdev->dd->num_vq; i++) {
-               struct vop_vringh *vvr = &vdev->vvr[i];
-
-               dma_unmap_single(&vpdev->dev,
-                                vvr->buf_da, VOP_INT_DMA_BUF_SIZE,
-                                DMA_BIDIRECTIONAL);
-               free_pages((unsigned long)vvr->buf,
-                          get_order(VOP_INT_DMA_BUF_SIZE));
-               vringh_kiov_cleanup(&vvr->riov);
-               vringh_kiov_cleanup(&vvr->wiov);
-               dma_unmap_single(&vpdev->dev, le64_to_cpu(vqconfig[i].address),
-                                vvr->vring.len, DMA_BIDIRECTIONAL);
-               free_pages((unsigned long)vvr->vring.va,
-                          get_order(vvr->vring.len));
-       }
-       /*
-        * Order the type update with previous stores. This write barrier
-        * is paired with the corresponding read barrier before the uncached
-        * system memory read of the type, on the card while scanning the
-        * device page.
-        */
-       smp_wmb();
-       vdev->dd->type = -1;
-}
-
-/*
- * vop_sync_dma - Wrapper for synchronous DMAs.
- *
- * @dev - The address of the pointer to the device instance used
- * for DMA registration.
- * @dst - destination DMA address.
- * @src - source DMA address.
- * @len - size of the transfer.
- *
- * Return DMA_SUCCESS on success
- */
-static int vop_sync_dma(struct vop_vdev *vdev, dma_addr_t dst, dma_addr_t src,
-                       size_t len)
-{
-       int err = 0;
-       struct dma_device *ddev;
-       struct dma_async_tx_descriptor *tx;
-       struct vop_info *vi = dev_get_drvdata(&vdev->vpdev->dev);
-       struct dma_chan *vop_ch = vi->dma_ch;
-
-       if (!vop_ch) {
-               err = -EBUSY;
-               goto error;
-       }
-       ddev = vop_ch->device;
-       tx = ddev->device_prep_dma_memcpy(vop_ch, dst, src, len,
-               DMA_PREP_FENCE);
-       if (!tx) {
-               err = -ENOMEM;
-               goto error;
-       } else {
-               dma_cookie_t cookie;
-
-               cookie = tx->tx_submit(tx);
-               if (dma_submit_error(cookie)) {
-                       err = -ENOMEM;
-                       goto error;
-               }
-               dma_async_issue_pending(vop_ch);
-               err = dma_sync_wait(vop_ch, cookie);
-       }
-error:
-       if (err)
-               dev_err(&vi->vpdev->dev, "%s %d err %d\n",
-                       __func__, __LINE__, err);
-       return err;
-}
-
-#define VOP_USE_DMA true
-
-/*
- * Initiates the copies across the PCIe bus from card memory to a user
- * space buffer. When transfers are done using DMA, source/destination
- * addresses and transfer length must follow the alignment requirements of
- * the MIC DMA engine.
- */
-static int vop_virtio_copy_to_user(struct vop_vdev *vdev, void __user *ubuf,
-                                  size_t len, u64 daddr, size_t dlen,
-                                  int vr_idx)
-{
-       struct vop_device *vpdev = vdev->vpdev;
-       void __iomem *dbuf = vpdev->hw_ops->remap(vpdev, daddr, len);
-       struct vop_vringh *vvr = &vdev->vvr[vr_idx];
-       struct vop_info *vi = dev_get_drvdata(&vpdev->dev);
-       size_t dma_alignment;
-       bool x200;
-       size_t dma_offset, partlen;
-       int err;
-
-       if (!VOP_USE_DMA || !vi->dma_ch) {
-               if (copy_to_user(ubuf, (void __force *)dbuf, len)) {
-                       err = -EFAULT;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               vdev->in_bytes += len;
-               err = 0;
-               goto err;
-       }
-
-       dma_alignment = 1 << vi->dma_ch->device->copy_align;
-       x200 = is_dma_copy_aligned(vi->dma_ch->device, 1, 1, 1);
-
-       dma_offset = daddr - round_down(daddr, dma_alignment);
-       daddr -= dma_offset;
-       len += dma_offset;
-       /*
-        * X100 uses DMA addresses as seen by the card so adding
-        * the aperture base is not required for DMA. However x200
-        * requires DMA addresses to be an offset into the bar so
-        * add the aperture base for x200.
-        */
-       if (x200)
-               daddr += vpdev->aper->pa;
-       while (len) {
-               partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE);
-               err = vop_sync_dma(vdev, vvr->buf_da, daddr,
-                                  ALIGN(partlen, dma_alignment));
-               if (err) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               if (copy_to_user(ubuf, vvr->buf + dma_offset,
-                                partlen - dma_offset)) {
-                       err = -EFAULT;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               daddr += partlen;
-               ubuf += partlen;
-               dbuf += partlen;
-               vdev->in_bytes_dma += partlen;
-               vdev->in_bytes += partlen;
-               len -= partlen;
-               dma_offset = 0;
-       }
-       err = 0;
-err:
-       vpdev->hw_ops->unmap(vpdev, dbuf);
-       dev_dbg(vop_dev(vdev),
-               "%s: ubuf %p dbuf %p len 0x%zx vr_idx 0x%x\n",
-               __func__, ubuf, dbuf, len, vr_idx);
-       return err;
-}
-
-/*
- * Initiates copies across the PCIe bus from a user space buffer to card
- * memory. When transfers are done using DMA, source/destination addresses
- * and transfer length must follow the alignment requirements of the MIC
- * DMA engine.
- */
-static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
-                                    size_t len, u64 daddr, size_t dlen,
-                                    int vr_idx)
-{
-       struct vop_device *vpdev = vdev->vpdev;
-       void __iomem *dbuf = vpdev->hw_ops->remap(vpdev, daddr, len);
-       struct vop_vringh *vvr = &vdev->vvr[vr_idx];
-       struct vop_info *vi = dev_get_drvdata(&vdev->vpdev->dev);
-       size_t dma_alignment;
-       bool x200;
-       size_t partlen;
-       bool dma = VOP_USE_DMA && vi->dma_ch;
-       int err = 0;
-       size_t offset = 0;
-
-       if (dma) {
-               dma_alignment = 1 << vi->dma_ch->device->copy_align;
-               x200 = is_dma_copy_aligned(vi->dma_ch->device, 1, 1, 1);
-
-               if (daddr & (dma_alignment - 1)) {
-                       vdev->tx_dst_unaligned += len;
-                       dma = false;
-               } else if (ALIGN(len, dma_alignment) > dlen) {
-                       vdev->tx_len_unaligned += len;
-                       dma = false;
-               }
-       }
-
-       if (!dma)
-               goto memcpy;
-
-       /*
-        * X100 uses DMA addresses as seen by the card so adding
-        * the aperture base is not required for DMA. However x200
-        * requires DMA addresses to be an offset into the bar so
-        * add the aperture base for x200.
-        */
-       if (x200)
-               daddr += vpdev->aper->pa;
-       while (len) {
-               partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE);
-
-               if (copy_from_user(vvr->buf, ubuf, partlen)) {
-                       err = -EFAULT;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               err = vop_sync_dma(vdev, daddr, vvr->buf_da,
-                                  ALIGN(partlen, dma_alignment));
-               if (err) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               daddr += partlen;
-               ubuf += partlen;
-               dbuf += partlen;
-               vdev->out_bytes_dma += partlen;
-               vdev->out_bytes += partlen;
-               len -= partlen;
-       }
-memcpy:
-       /*
-        * We are copying to IO below and should ideally use something
-        * like copy_from_user_toio(..) if it existed.
-        */
-       while (len) {
-               partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE);
-
-               if (copy_from_user(vvr->buf, ubuf + offset, partlen)) {
-                       err = -EFAULT;
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, err);
-                       goto err;
-               }
-               memcpy_toio(dbuf + offset, vvr->buf, partlen);
-               offset += partlen;
-               vdev->out_bytes += partlen;
-               len -= partlen;
-       }
-       err = 0;
-err:
-       vpdev->hw_ops->unmap(vpdev, dbuf);
-       dev_dbg(vop_dev(vdev),
-               "%s: ubuf %p dbuf %p len 0x%zx vr_idx 0x%x\n",
-               __func__, ubuf, dbuf, len, vr_idx);
-       return err;
-}
-
-#define MIC_VRINGH_READ true
-
-/* Determine the total number of bytes consumed in a VRINGH KIOV */
-static inline u32 vop_vringh_iov_consumed(struct vringh_kiov *iov)
-{
-       int i;
-       u32 total = iov->consumed;
-
-       for (i = 0; i < iov->i; i++)
-               total += iov->iov[i].iov_len;
-       return total;
-}
-
-/*
- * Traverse the VRINGH KIOV and issue the APIs to trigger the copies.
- * This API is heavily based on the vringh_iov_xfer(..) implementation
- * in vringh.c. The reason we cannot reuse vringh_iov_pull_kern(..)
- * and vringh_iov_push_kern(..) directly is because there is no
- * way to override the VRINGH xfer(..) routines as of v3.10.
- */
-static int vop_vringh_copy(struct vop_vdev *vdev, struct vringh_kiov *iov,
-                          void __user *ubuf, size_t len, bool read, int vr_idx,
-                          size_t *out_len)
-{
-       int ret = 0;
-       size_t partlen, tot_len = 0;
-
-       while (len && iov->i < iov->used) {
-               struct kvec *kiov = &iov->iov[iov->i];
-               unsigned long daddr = (unsigned long)kiov->iov_base;
-
-               partlen = min(kiov->iov_len, len);
-               if (read)
-                       ret = vop_virtio_copy_to_user(vdev, ubuf, partlen,
-                                                     daddr,
-                                                     kiov->iov_len,
-                                                     vr_idx);
-               else
-                       ret = vop_virtio_copy_from_user(vdev, ubuf, partlen,
-                                                       daddr,
-                                                       kiov->iov_len,
-                                                       vr_idx);
-               if (ret) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       break;
-               }
-               len -= partlen;
-               ubuf += partlen;
-               tot_len += partlen;
-               iov->consumed += partlen;
-               kiov->iov_len -= partlen;
-               kiov->iov_base += partlen;
-               if (!kiov->iov_len) {
-                       /* Fix up old iov element then increment. */
-                       kiov->iov_len = iov->consumed;
-                       kiov->iov_base -= iov->consumed;
-
-                       iov->consumed = 0;
-                       iov->i++;
-               }
-       }
-       *out_len = tot_len;
-       return ret;
-}
-
-/*
- * Use the standard VRINGH infrastructure in the kernel to fetch new
- * descriptors, initiate the copies and update the used ring.
- */
-static int _vop_virtio_copy(struct vop_vdev *vdev, struct mic_copy_desc *copy)
-{
-       int ret = 0;
-       u32 iovcnt = copy->iovcnt;
-       struct iovec iov;
-       struct iovec __user *u_iov = copy->iov;
-       void __user *ubuf = NULL;
-       struct vop_vringh *vvr = &vdev->vvr[copy->vr_idx];
-       struct vringh_kiov *riov = &vvr->riov;
-       struct vringh_kiov *wiov = &vvr->wiov;
-       struct vringh *vrh = &vvr->vrh;
-       u16 *head = &vvr->head;
-       struct mic_vring *vr = &vvr->vring;
-       size_t len = 0, out_len;
-
-       copy->out_len = 0;
-       /* Fetch a new IOVEC if all previous elements have been processed */
-       if (riov->i == riov->used && wiov->i == wiov->used) {
-               ret = vringh_getdesc_kern(vrh, riov, wiov,
-                                         head, GFP_KERNEL);
-               /* Check if there are available descriptors */
-               if (ret <= 0)
-                       return ret;
-       }
-       while (iovcnt) {
-               if (!len) {
-                       /* Copy over a new iovec from user space. */
-                       ret = copy_from_user(&iov, u_iov, sizeof(*u_iov));
-                       if (ret) {
-                               ret = -EINVAL;
-                               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                                       __func__, __LINE__, ret);
-                               break;
-                       }
-                       len = iov.iov_len;
-                       ubuf = iov.iov_base;
-               }
-               /* Issue all the read descriptors first */
-               ret = vop_vringh_copy(vdev, riov, ubuf, len,
-                                     MIC_VRINGH_READ, copy->vr_idx, &out_len);
-               if (ret) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       break;
-               }
-               len -= out_len;
-               ubuf += out_len;
-               copy->out_len += out_len;
-               /* Issue the write descriptors next */
-               ret = vop_vringh_copy(vdev, wiov, ubuf, len,
-                                     !MIC_VRINGH_READ, copy->vr_idx, &out_len);
-               if (ret) {
-                       dev_err(vop_dev(vdev), "%s %d err %d\n",
-                               __func__, __LINE__, ret);
-                       break;
-               }
-               len -= out_len;
-               ubuf += out_len;
-               copy->out_len += out_len;
-               if (!len) {
-                       /* One user space iovec is now completed */
-                       iovcnt--;
-                       u_iov++;
-               }
-               /* Exit loop if all elements in KIOVs have been processed. */
-               if (riov->i == riov->used && wiov->i == wiov->used)
-                       break;
-       }
-       /*
-        * Update the used ring if a descriptor was available and some data was
-        * copied in/out and the user asked for a used ring update.
-        */
-       if (*head != USHRT_MAX && copy->out_len && copy->update_used) {
-               u32 total = 0;
-
-               /* Determine the total data consumed */
-               total += vop_vringh_iov_consumed(riov);
-               total += vop_vringh_iov_consumed(wiov);
-               vringh_complete_kern(vrh, *head, total);
-               *head = USHRT_MAX;
-               if (vringh_need_notify_kern(vrh) > 0)
-                       vringh_notify(vrh);
-               vringh_kiov_cleanup(riov);
-               vringh_kiov_cleanup(wiov);
-               /* Update avail idx for user space */
-               vr->info->avail_idx = vrh->last_avail_idx;
-       }
-       return ret;
-}
-
-static inline int vop_verify_copy_args(struct vop_vdev *vdev,
-                                      struct mic_copy_desc *copy)
-{
-       if (!vdev || copy->vr_idx >= vdev->dd->num_vq)
-               return -EINVAL;
-       return 0;
-}
-
-/* Copy a specified number of virtio descriptors in a chain */
-static int vop_virtio_copy_desc(struct vop_vdev *vdev,
-                               struct mic_copy_desc *copy)
-{
-       int err;
-       struct vop_vringh *vvr;
-
-       err = vop_verify_copy_args(vdev, copy);
-       if (err)
-               return err;
-
-       vvr = &vdev->vvr[copy->vr_idx];
-       mutex_lock(&vvr->vr_mutex);
-       if (!vop_vdevup(vdev)) {
-               err = -ENODEV;
-               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, err);
-               goto err;
-       }
-       err = _vop_virtio_copy(vdev, copy);
-       if (err) {
-               dev_err(vop_dev(vdev), "%s %d err %d\n",
-                       __func__, __LINE__, err);
-       }
-err:
-       mutex_unlock(&vvr->vr_mutex);
-       return err;
-}
-
-static int vop_open(struct inode *inode, struct file *f)
-{
-       struct vop_vdev *vdev;
-       struct vop_info *vi = container_of(f->private_data,
-               struct vop_info, miscdev);
-
-       vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
-       if (!vdev)
-               return -ENOMEM;
-       vdev->vi = vi;
-       mutex_init(&vdev->vdev_mutex);
-       f->private_data = vdev;
-       init_completion(&vdev->destroy);
-       complete(&vdev->destroy);
-       return 0;
-}
-
-static int vop_release(struct inode *inode, struct file *f)
-{
-       struct vop_vdev *vdev = f->private_data, *vdev_tmp;
-       struct vop_info *vi = vdev->vi;
-       struct list_head *pos, *tmp;
-       bool found = false;
-
-       mutex_lock(&vdev->vdev_mutex);
-       if (vdev->deleted)
-               goto unlock;
-       mutex_lock(&vi->vop_mutex);
-       list_for_each_safe(pos, tmp, &vi->vdev_list) {
-               vdev_tmp = list_entry(pos, struct vop_vdev, list);
-               if (vdev == vdev_tmp) {
-                       vop_virtio_del_device(vdev);
-                       list_del(pos);
-                       found = true;
-                       break;
-               }
-       }
-       mutex_unlock(&vi->vop_mutex);
-unlock:
-       mutex_unlock(&vdev->vdev_mutex);
-       if (!found)
-               wait_for_completion(&vdev->destroy);
-       f->private_data = NULL;
-       kfree(vdev);
-       return 0;
-}
-
-static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
-{
-       struct vop_vdev *vdev = f->private_data;
-       struct vop_info *vi = vdev->vi;
-       void __user *argp = (void __user *)arg;
-       int ret;
-
-       switch (cmd) {
-       case MIC_VIRTIO_ADD_DEVICE:
-       {
-               struct mic_device_desc dd, *dd_config;
-
-               if (copy_from_user(&dd, argp, sizeof(dd)))
-                       return -EFAULT;
-
-               if (mic_aligned_desc_size(&dd) > MIC_MAX_DESC_BLK_SIZE ||
-                   dd.num_vq > MIC_MAX_VRINGS)
-                       return -EINVAL;
-
-               dd_config = memdup_user(argp, mic_desc_size(&dd));
-               if (IS_ERR(dd_config))
-                       return PTR_ERR(dd_config);
-
-               /* Ensure desc has not changed between the two reads */
-               if (memcmp(&dd, dd_config, sizeof(dd))) {
-                       ret = -EINVAL;
-                       goto free_ret;
-               }
-               mutex_lock(&vdev->vdev_mutex);
-               mutex_lock(&vi->vop_mutex);
-               ret = vop_virtio_add_device(vdev, dd_config);
-               if (ret)
-                       goto unlock_ret;
-               list_add_tail(&vdev->list, &vi->vdev_list);
-unlock_ret:
-               mutex_unlock(&vi->vop_mutex);
-               mutex_unlock(&vdev->vdev_mutex);
-free_ret:
-               kfree(dd_config);
-               return ret;
-       }
-       case MIC_VIRTIO_COPY_DESC:
-       {
-               struct mic_copy_desc copy;
-
-               mutex_lock(&vdev->vdev_mutex);
-               ret = vop_vdev_inited(vdev);
-               if (ret)
-                       goto _unlock_ret;
-
-               if (copy_from_user(&copy, argp, sizeof(copy))) {
-                       ret = -EFAULT;
-                       goto _unlock_ret;
-               }
-
-               ret = vop_virtio_copy_desc(vdev, &copy);
-               if (ret < 0)
-                       goto _unlock_ret;
-               if (copy_to_user(
-                       &((struct mic_copy_desc __user *)argp)->out_len,
-                       &copy.out_len, sizeof(copy.out_len)))
-                       ret = -EFAULT;
-_unlock_ret:
-               mutex_unlock(&vdev->vdev_mutex);
-               return ret;
-       }
-       case MIC_VIRTIO_CONFIG_CHANGE:
-       {
-               void *buf;
-
-               mutex_lock(&vdev->vdev_mutex);
-               ret = vop_vdev_inited(vdev);
-               if (ret)
-                       goto __unlock_ret;
-               buf = memdup_user(argp, vdev->dd->config_len);
-               if (IS_ERR(buf)) {
-                       ret = PTR_ERR(buf);
-                       goto __unlock_ret;
-               }
-               ret = vop_virtio_config_change(vdev, buf);
-               kfree(buf);
-__unlock_ret:
-               mutex_unlock(&vdev->vdev_mutex);
-               return ret;
-       }
-       default:
-               return -ENOIOCTLCMD;
-       };
-       return 0;
-}
-
-/*
- * We return EPOLLIN | EPOLLOUT from poll when new buffers are enqueued, and
- * not when previously enqueued buffers may be available. This means that
- * in the card->host (TX) path, when userspace is unblocked by poll it
- * must drain all available descriptors or it can stall.
- */
-static __poll_t vop_poll(struct file *f, poll_table *wait)
-{
-       struct vop_vdev *vdev = f->private_data;
-       __poll_t mask = 0;
-
-       mutex_lock(&vdev->vdev_mutex);
-       if (vop_vdev_inited(vdev)) {
-               mask = EPOLLERR;
-               goto done;
-       }
-       poll_wait(f, &vdev->waitq, wait);
-       if (vop_vdev_inited(vdev)) {
-               mask = EPOLLERR;
-       } else if (vdev->poll_wake) {
-               vdev->poll_wake = 0;
-               mask = EPOLLIN | EPOLLOUT;
-       }
-done:
-       mutex_unlock(&vdev->vdev_mutex);
-       return mask;
-}
-
-static inline int
-vop_query_offset(struct vop_vdev *vdev, unsigned long offset,
-                unsigned long *size, unsigned long *pa)
-{
-       struct vop_device *vpdev = vdev->vpdev;
-       unsigned long start = MIC_DP_SIZE;
-       int i;
-
-       /*
-        * MMAP interface is as follows:
-        * offset                               region
-        * 0x0                                  virtio device_page
-        * 0x1000                               first vring
-        * 0x1000 + size of 1st vring           second vring
-        * ....
-        */
-       if (!offset) {
-               *pa = virt_to_phys(vpdev->hw_ops->get_dp(vpdev));
-               *size = MIC_DP_SIZE;
-               return 0;
-       }
-
-       for (i = 0; i < vdev->dd->num_vq; i++) {
-               struct vop_vringh *vvr = &vdev->vvr[i];
-
-               if (offset == start) {
-                       *pa = virt_to_phys(vvr->vring.va);
-                       *size = vvr->vring.len;
-                       return 0;
-               }
-               start += vvr->vring.len;
-       }
-       return -1;
-}
-
-/*
- * Maps the device page and virtio rings to user space for readonly access.
- */
-static int vop_mmap(struct file *f, struct vm_area_struct *vma)
-{
-       struct vop_vdev *vdev = f->private_data;
-       unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
-       unsigned long pa, size = vma->vm_end - vma->vm_start, size_rem = size;
-       int i, err;
-
-       err = vop_vdev_inited(vdev);
-       if (err)
-               goto ret;
-       if (vma->vm_flags & VM_WRITE) {
-               err = -EACCES;
-               goto ret;
-       }
-       while (size_rem) {
-               i = vop_query_offset(vdev, offset, &size, &pa);
-               if (i < 0) {
-                       err = -EINVAL;
-                       goto ret;
-               }
-               err = remap_pfn_range(vma, vma->vm_start + offset,
-                                     pa >> PAGE_SHIFT, size,
-                                     vma->vm_page_prot);
-               if (err)
-                       goto ret;
-               size_rem -= size;
-               offset += size;
-       }
-ret:
-       return err;
-}
-
-static const struct file_operations vop_fops = {
-       .open = vop_open,
-       .release = vop_release,
-       .unlocked_ioctl = vop_ioctl,
-       .poll = vop_poll,
-       .mmap = vop_mmap,
-       .owner = THIS_MODULE,
-};
-
-int vop_host_init(struct vop_info *vi)
-{
-       int rc;
-       struct miscdevice *mdev;
-       struct vop_device *vpdev = vi->vpdev;
-
-       INIT_LIST_HEAD(&vi->vdev_list);
-       vi->dma_ch = vpdev->dma_ch;
-       mdev = &vi->miscdev;
-       mdev->minor = MISC_DYNAMIC_MINOR;
-       snprintf(vi->name, sizeof(vi->name), "vop_virtio%d", vpdev->index);
-       mdev->name = vi->name;
-       mdev->fops = &vop_fops;
-       mdev->parent = &vpdev->dev;
-
-       rc = misc_register(mdev);
-       if (rc)
-               dev_err(&vpdev->dev, "%s failed rc %d\n", __func__, rc);
-       return rc;
-}
-
-void vop_host_uninit(struct vop_info *vi)
-{
-       struct list_head *pos, *tmp;
-       struct vop_vdev *vdev;
-
-       mutex_lock(&vi->vop_mutex);
-       vop_virtio_reset_devices(vi);
-       list_for_each_safe(pos, tmp, &vi->vdev_list) {
-               vdev = list_entry(pos, struct vop_vdev, list);
-               list_del(pos);
-               reinit_completion(&vdev->destroy);
-               mutex_unlock(&vi->vop_mutex);
-               mutex_lock(&vdev->vdev_mutex);
-               vop_virtio_del_device(vdev);
-               vdev->deleted = true;
-               mutex_unlock(&vdev->vdev_mutex);
-               complete(&vdev->destroy);
-               mutex_lock(&vi->vop_mutex);
-       }
-       mutex_unlock(&vi->vop_mutex);
-       misc_deregister(&vi->miscdev);
-}
index a30796e79b1cbf6d5b13512e24229e6a0af10bcf..6de02f09c3222408a457b871c225b26071cd980d 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
+ * Copyright 2020 NXP
  *   Author: Wolfram Sang <kernel@pengutronix.de>
  */
 
@@ -88,6 +89,7 @@
 /* DLL Config 0 Register */
 #define ESDHC_DLLCFG0                  0x160
 #define ESDHC_DLL_ENABLE               0x80000000
+#define ESDHC_DLL_RESET                        0x40000000
 #define ESDHC_DLL_FREQ_SEL             0x08000000
 
 /* DLL Config 1 Register */
index 0b45eff6fed497a22cf89f665806f8a73bf8d3f4..bb094459196a3a1fd2e30e82f70b117409f09150 100644 (file)
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2020 NXP
  *
  * Authors: Xiaobo Xie <X.Xie@freescale.com>
  *         Anton Vorontsov <avorontsov@ru.mvista.com>
@@ -19,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/ktime.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
                if (host->mmc->actual_clock == MMC_HS200_MAX_DTR)
                        temp |= ESDHC_DLL_FREQ_SEL;
                sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               temp |= ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+               udelay(1);
+               temp &= ~ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               /* Wait max 20 ms */
+               if (read_poll_timeout(sdhci_readl, temp,
+                                     temp & ESDHC_DLL_STS_SLV_LOCK,
+                                     10, 20000, false,
+                                     host, ESDHC_DLLSTAT0))
+                       pr_err("%s: timeout for delay chain lock.\n",
+                              mmc_hostname(host->mmc));
+
                temp = sdhci_readl(host, ESDHC_TBCTL);
                sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL);
 
@@ -1052,6 +1069,17 @@ static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode)
 
        esdhc_tuning_block_enable(host, true);
 
+       /*
+        * The eSDHC controller takes the data timeout value into account
+        * during tuning. If the SD card is too slow sending the response, the
+        * timer will expire and a "Buffer Read Ready" interrupt without data
+        * is triggered. This leads to tuning errors.
+        *
+        * Just set the timeout to the maximum value because the core will
+        * already take care of it in sdhci_send_tuning().
+        */
+       sdhci_writeb(host, 0xe, SDHCI_TIMEOUT_CONTROL);
+
        hs400_tuning = host->flags & SDHCI_HS400_TUNING;
 
        do {
index 592a55a34b58eba8163d5277faecc880460f76f7..3561ae8a481a040194e106872ed21518cbb6f173 100644 (file)
@@ -1384,9 +1384,11 @@ static inline void sdhci_auto_cmd_select(struct sdhci_host *host,
        /*
         * In case of Version 4.10 or later, use of 'Auto CMD Auto
         * Select' is recommended rather than use of 'Auto CMD12
-        * Enable' or 'Auto CMD23 Enable'.
+        * Enable' or 'Auto CMD23 Enable'. We require Version 4 Mode
+        * here because some controllers (e.g sdhci-of-dwmshc) expect it.
         */
-       if (host->version >= SDHCI_SPEC_410 && (use_cmd12 || use_cmd23)) {
+       if (host->version >= SDHCI_SPEC_410 && host->v4_mode &&
+           (use_cmd12 || use_cmd23)) {
                *mode |= SDHCI_TRNS_AUTO_SEL;
 
                ctrl2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
index 0e7a9b64301e1198f0eeca2ee5a837ea86b6c092..e345f9d9f8e8dc2c2038fcbef3171a579575f67a 100644 (file)
@@ -707,6 +707,30 @@ static int fsl_ifc_attach_chip(struct nand_chip *chip)
 {
        struct mtd_info *mtd = nand_to_mtd(chip);
        struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);
+       struct fsl_ifc_ctrl *ctrl = priv->ctrl;
+       struct fsl_ifc_global __iomem *ifc_global = ctrl->gregs;
+       u32 csor;
+
+       csor = ifc_in32(&ifc_global->csor_cs[priv->bank].csor);
+
+       /* Must also set CSOR_NAND_ECC_ENC_EN if DEC_EN set */
+       if (csor & CSOR_NAND_ECC_DEC_EN) {
+               chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
+               mtd_set_ooblayout(mtd, &fsl_ifc_ooblayout_ops);
+
+               /* Hardware generates ECC per 512 Bytes */
+               chip->ecc.size = 512;
+               if ((csor & CSOR_NAND_ECC_MODE_MASK) == CSOR_NAND_ECC_MODE_4) {
+                       chip->ecc.bytes = 8;
+                       chip->ecc.strength = 4;
+               } else {
+                       chip->ecc.bytes = 16;
+                       chip->ecc.strength = 8;
+               }
+       } else {
+               chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
+               chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
+       }
 
        dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__,
                nanddev_ntargets(&chip->base));
@@ -910,25 +934,6 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
                return -ENODEV;
        }
 
-       /* Must also set CSOR_NAND_ECC_ENC_EN if DEC_EN set */
-       if (csor & CSOR_NAND_ECC_DEC_EN) {
-               chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
-               mtd_set_ooblayout(mtd, &fsl_ifc_ooblayout_ops);
-
-               /* Hardware generates ECC per 512 Bytes */
-               chip->ecc.size = 512;
-               if ((csor & CSOR_NAND_ECC_MODE_MASK) == CSOR_NAND_ECC_MODE_4) {
-                       chip->ecc.bytes = 8;
-                       chip->ecc.strength = 4;
-               } else {
-                       chip->ecc.bytes = 16;
-                       chip->ecc.strength = 8;
-               }
-       } else {
-               chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-               chip->ecc.algo = NAND_ECC_ALGO_HAMMING;
-       }
-
        ret = fsl_ifc_sram_init(priv);
        if (ret)
                return ret;
index d4200eb2ad3284984dec89758f0d798a0c333762..684c51e5e60dd07ce9963213fa3e7733f4419baf 100644 (file)
@@ -1681,6 +1681,11 @@ static int mxcnd_attach_chip(struct nand_chip *chip)
        struct mxc_nand_host *host = nand_get_controller_data(chip);
        struct device *dev = mtd->dev.parent;
 
+       chip->ecc.bytes = host->devtype_data->eccbytes;
+       host->eccsize = host->devtype_data->eccsize;
+       chip->ecc.size = 512;
+       mtd_set_ooblayout(mtd, host->devtype_data->ooblayout);
+
        switch (chip->ecc.engine_type) {
        case NAND_ECC_ENGINE_TYPE_ON_HOST:
                chip->ecc.read_page = mxc_nand_read_page;
@@ -1836,19 +1841,7 @@ static int mxcnd_probe(struct platform_device *pdev)
        if (host->devtype_data->axi_offset)
                host->regs_axi = host->base + host->devtype_data->axi_offset;
 
-       this->ecc.bytes = host->devtype_data->eccbytes;
-       host->eccsize = host->devtype_data->eccsize;
-
        this->legacy.select_chip = host->devtype_data->select_chip;
-       this->ecc.size = 512;
-       mtd_set_ooblayout(mtd, host->devtype_data->ooblayout);
-
-       if (host->pdata.hw_ecc) {
-               this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
-       } else {
-               this->ecc.engine_type = NAND_ECC_ENGINE_TYPE_SOFT;
-               this->ecc.algo = NAND_ECC_ALGO_HAMMING;
-       }
 
        /* NAND bus width determines access functions used by upper layer */
        if (host->pdata.width == 2)
index b31a5818234d3430c96da4fc51b924e590d6d3aa..550bda4d1415a34745bde133bf32203d3cf604e9 100644 (file)
@@ -1708,6 +1708,13 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
                return -EINVAL;
        }
 
+       /* Default ECC settings in case they are not set in the device tree */
+       if (!chip->ecc.size)
+               chip->ecc.size = FMC2_ECC_STEP_SIZE;
+
+       if (!chip->ecc.strength)
+               chip->ecc.strength = FMC2_ECC_BCH8;
+
        ret = nand_ecc_choose_conf(chip, &stm32_fmc2_nfc_ecc_caps,
                                   mtd->oobsize - FMC2_BBM_LEN);
        if (ret) {
@@ -1727,8 +1734,7 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
 
        mtd_set_ooblayout(mtd, &stm32_fmc2_nfc_ooblayout_ops);
 
-       if (chip->options & NAND_BUSWIDTH_16)
-               stm32_fmc2_nfc_set_buswidth_16(nfc, true);
+       stm32_fmc2_nfc_setup(chip);
 
        return 0;
 }
@@ -1952,11 +1958,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
        chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
                         NAND_USES_DMA;
 
-       /* Default ECC settings */
-       chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
-       chip->ecc.size = FMC2_ECC_STEP_SIZE;
-       chip->ecc.strength = FMC2_ECC_BCH8;
-
        /* Scan to find existence of the device */
        ret = nand_scan(chip, nand->ncs);
        if (ret)
index 0369d98b2d12efe0757196ee651a6e107f1cbeba..f0ae7a01703a1d7ac6d3ee699320360253b20577 100644 (file)
@@ -2701,11 +2701,10 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor)
 
        memcpy(&sfdp_params, nor->params, sizeof(sfdp_params));
 
-       if (spi_nor_parse_sfdp(nor, &sfdp_params)) {
+       if (spi_nor_parse_sfdp(nor, nor->params)) {
+               memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
                nor->addr_width = 0;
                nor->flags &= ~SNOR_F_4B_OPCODES;
-       } else {
-               memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
        }
 }
 
@@ -3009,13 +3008,15 @@ static int spi_nor_set_addr_width(struct spi_nor *nor)
                /* already configured from SFDP */
        } else if (nor->info->addr_width) {
                nor->addr_width = nor->info->addr_width;
-       } else if (nor->mtd.size > 0x1000000) {
-               /* enable 4-byte addressing if the device exceeds 16MiB */
-               nor->addr_width = 4;
        } else {
                nor->addr_width = 3;
        }
 
+       if (nor->addr_width == 3 && nor->mtd.size > 0x1000000) {
+               /* enable 4-byte addressing if the device exceeds 16MiB */
+               nor->addr_width = 4;
+       }
+
        if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) {
                dev_dbg(nor->dev, "address width is too large: %u\n",
                        nor->addr_width);
index b70ded3760f28cdb65d9372b4b0cf26f3afdc567..6dee4f8f2024744bfa241eab9a31ca92deb72456 100644 (file)
@@ -512,9 +512,13 @@ __can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
                 */
                struct sk_buff *skb = priv->echo_skb[idx];
                struct canfd_frame *cf = (struct canfd_frame *)skb->data;
-               u8 len = cf->len;
 
-               *len_ptr = len;
+               /* get the real payload length for netdev statistics */
+               if (cf->can_id & CAN_RTR_FLAG)
+                       *len_ptr = 0;
+               else
+                       *len_ptr = cf->len;
+
                priv->echo_skb[idx] = NULL;
 
                return skb;
@@ -538,7 +542,11 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
        if (!skb)
                return 0;
 
-       netif_rx(skb);
+       skb_get(skb);
+       if (netif_rx(skb) == NET_RX_SUCCESS)
+               dev_consume_skb_any(skb);
+       else
+               dev_kfree_skb_any(skb);
 
        return len;
 }
index 4d594e9774972b07fc414961494f67c491472a14..881799bd9c5ea0dfff2e468f2fe67c227f4bb070 100644 (file)
  *   MX8MP FlexCAN3  03.00.17.01    yes       yes        no      yes       yes          yes
  *   VF610 FlexCAN3  ?               no       yes        no      yes       yes?          no
  * LS1021A FlexCAN2  03.00.04.00     no       yes        no       no       yes           no
- * LX2160A FlexCAN3  03.00.23.00     no       yes        no       no       yes          yes
+ * LX2160A FlexCAN3  03.00.23.00     no       yes        no      yes       yes          yes
  *
  * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
  */
@@ -400,19 +400,19 @@ static struct flexcan_devtype_data fsl_imx8mp_devtype_data = {
 static const struct flexcan_devtype_data fsl_vf610_devtype_data = {
        .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
                FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP |
-               FLEXCAN_QUIRK_BROKEN_PERR_STATE,
+               FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_SUPPORT_ECC,
 };
 
 static const struct flexcan_devtype_data fsl_ls1021a_r2_devtype_data = {
        .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
-               FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-               FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
+               FLEXCAN_QUIRK_BROKEN_PERR_STATE | FLEXCAN_QUIRK_USE_OFF_TIMESTAMP,
 };
 
 static const struct flexcan_devtype_data fsl_lx2160a_r1_devtype_data = {
        .quirks = FLEXCAN_QUIRK_DISABLE_RXFG | FLEXCAN_QUIRK_ENABLE_EACEN_RRS |
                FLEXCAN_QUIRK_DISABLE_MECR | FLEXCAN_QUIRK_BROKEN_PERR_STATE |
-               FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_SUPPORT_FD,
+               FLEXCAN_QUIRK_USE_OFF_TIMESTAMP | FLEXCAN_QUIRK_SUPPORT_FD |
+               FLEXCAN_QUIRK_SUPPORT_ECC,
 };
 
 static const struct can_bittiming_const flexcan_bittiming_const = {
@@ -2062,6 +2062,8 @@ static int flexcan_remove(struct platform_device *pdev)
 {
        struct net_device *dev = platform_get_drvdata(pdev);
 
+       device_set_wakeup_enable(&pdev->dev, false);
+       device_set_wakeup_capable(&pdev->dev, false);
        unregister_flexcandev(dev);
        pm_runtime_disable(&pdev->dev);
        free_candev(dev);
index 10aa3e457c33d48fe2055a422c6399b56798b9e3..40c33b8a5fda3af93013c0e524f66d1ba6288907 100644 (file)
@@ -262,8 +262,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
                cf_len = get_can_dlc(pucan_msg_get_dlc(msg));
 
        /* if this frame is an echo, */
-       if ((rx_msg_flags & PUCAN_MSG_LOOPED_BACK) &&
-           !(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE)) {
+       if (rx_msg_flags & PUCAN_MSG_LOOPED_BACK) {
                unsigned long flags;
 
                spin_lock_irqsave(&priv->echo_lock, flags);
@@ -277,7 +276,13 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv,
                netif_wake_queue(priv->ndev);
 
                spin_unlock_irqrestore(&priv->echo_lock, flags);
-               return 0;
+
+               /* if this frame is only an echo, stop here. Otherwise,
+                * continue to push this application self-received frame into
+                * its own rx queue.
+                */
+               if (!(rx_msg_flags & PUCAN_MSG_SELF_RECEIVE))
+                       return 0;
        }
 
        /* otherwise, it should be pushed into rx fifo */
index 3b180269a92d944db7e37017e846d16cef0cf2e4..6e95193b215ba4725ced3724ac006cb2acb1986b 100644 (file)
@@ -245,7 +245,7 @@ int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
 
        if (skb_queue_len(&offload->skb_queue) >
            offload->skb_queue_len_max) {
-               kfree_skb(skb);
+               dev_kfree_skb_any(skb);
                return -ENOBUFS;
        }
 
@@ -290,7 +290,7 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 {
        if (skb_queue_len(&offload->skb_queue) >
            offload->skb_queue_len_max) {
-               kfree_skb(skb);
+               dev_kfree_skb_any(skb);
                return -ENOBUFS;
        }
 
index c3f49543ff269546ec9343323fce3cb2b9b44269..9c215f7c5f81b84652505fb982ab176972875ed9 100644 (file)
@@ -75,11 +75,11 @@ static const char *__mcp251xfd_get_model_str(enum mcp251xfd_model model)
 {
        switch (model) {
        case MCP251XFD_MODEL_MCP2517FD:
-               return "MCP2517FD"; break;
+               return "MCP2517FD";
        case MCP251XFD_MODEL_MCP2518FD:
-               return "MCP2518FD"; break;
+               return "MCP2518FD";
        case MCP251XFD_MODEL_MCP251XFD:
-               return "MCP251xFD"; break;
+               return "MCP251xFD";
        }
 
        return "<unknown>";
@@ -95,21 +95,21 @@ static const char *mcp251xfd_get_mode_str(const u8 mode)
 {
        switch (mode) {
        case MCP251XFD_REG_CON_MODE_MIXED:
-               return "Mixed (CAN FD/CAN 2.0)"; break;
+               return "Mixed (CAN FD/CAN 2.0)";
        case MCP251XFD_REG_CON_MODE_SLEEP:
-               return "Sleep"; break;
+               return "Sleep";
        case MCP251XFD_REG_CON_MODE_INT_LOOPBACK:
-               return "Internal Loopback"; break;
+               return "Internal Loopback";
        case MCP251XFD_REG_CON_MODE_LISTENONLY:
-               return "Listen Only"; break;
+               return "Listen Only";
        case MCP251XFD_REG_CON_MODE_CONFIG:
-               return "Configuration"; break;
+               return "Configuration";
        case MCP251XFD_REG_CON_MODE_EXT_LOOPBACK:
-               return "External Loopback"; break;
+               return "External Loopback";
        case MCP251XFD_REG_CON_MODE_CAN2_0:
-               return "CAN 2.0"; break;
+               return "CAN 2.0";
        case MCP251XFD_REG_CON_MODE_RESTRICTED:
-               return "Restricted Operation"; break;
+               return "Restricted Operation";
        }
 
        return "<unknown>";
index ba25902dd78c7584e6ab93ee4ae59fbc35a71d26..314f868b34658a40e7906a247cf5029084e2c19f 100644 (file)
@@ -173,7 +173,7 @@ mcp251xfd_regmap_nocrc_read(void *context,
                memcpy(&buf_tx->cmd, reg, sizeof(buf_tx->cmd));
                if (MCP251XFD_SANITIZE_SPI)
                        memset(buf_tx->data, 0x0, val_len);
-       };
+       }
 
        err = spi_sync(spi, &msg);
        if (err)
@@ -330,17 +330,17 @@ mcp251xfd_regmap_crc_read(void *context,
                        goto out;
                }
 
-               netdev_dbg(priv->ndev,
-                          "CRC read error at address 0x%04x (length=%zd, data=%*ph, CRC=0x%04x) retrying.\n",
-                          reg, val_len, (int)val_len, buf_rx->data,
-                          get_unaligned_be16(buf_rx->data + val_len));
-       }
-
-       if (err) {
                netdev_info(priv->ndev,
-                           "CRC read error at address 0x%04x (length=%zd, data=%*ph, CRC=0x%04x).\n",
+                           "CRC read error at address 0x%04x (length=%zd, data=%*ph, CRC=0x%04x) retrying.\n",
                            reg, val_len, (int)val_len, buf_rx->data,
                            get_unaligned_be16(buf_rx->data + val_len));
+       }
+
+       if (err) {
+               netdev_err(priv->ndev,
+                          "CRC read error at address 0x%04x (length=%zd, data=%*ph, CRC=0x%04x).\n",
+                          reg, val_len, (int)val_len, buf_rx->data,
+                          get_unaligned_be16(buf_rx->data + val_len));
 
                return err;
        }
index 1d63006c97bcd84a6f4cb0ca77a22d34b2cedb8e..9913f5458279b66a4d02774838e23c0d2657e3fd 100644 (file)
@@ -933,7 +933,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
        err = clk_prepare_enable(priv->clk);
        if (err) {
                dev_err(&pdev->dev, "clk_prepare_enable() failed\n");
-               goto probe_exit_clk;
+               goto probe_exit_release_clk;
        }
 
        priv->offload.mailbox_read = ti_hecc_mailbox_read;
@@ -942,7 +942,7 @@ static int ti_hecc_probe(struct platform_device *pdev)
        err = can_rx_offload_add_timestamp(ndev, &priv->offload);
        if (err) {
                dev_err(&pdev->dev, "can_rx_offload_add_timestamp() failed\n");
-               goto probe_exit_clk;
+               goto probe_exit_disable_clk;
        }
 
        err = register_candev(ndev);
@@ -960,7 +960,9 @@ static int ti_hecc_probe(struct platform_device *pdev)
 
 probe_exit_offload:
        can_rx_offload_del(&priv->offload);
-probe_exit_clk:
+probe_exit_disable_clk:
+       clk_disable_unprepare(priv->clk);
+probe_exit_release_clk:
        clk_put(priv->clk);
 probe_exit_candev:
        free_candev(ndev);
index d91df34e7fa8800f6931e7d4dade99c05a62dea4..c2764799f9efbcd4d57adee2271378e6179ccc78 100644 (file)
@@ -130,14 +130,55 @@ void peak_usb_get_ts_time(struct peak_time_ref *time_ref, u32 ts, ktime_t *time)
        /* protect from getting time before setting now */
        if (ktime_to_ns(time_ref->tv_host)) {
                u64 delta_us;
+               s64 delta_ts = 0;
+
+               /* General case: dev_ts_1 < dev_ts_2 < ts, with:
+                *
+                * - dev_ts_1 = previous sync timestamp
+                * - dev_ts_2 = last sync timestamp
+                * - ts = event timestamp
+                * - ts_period = known sync period (theoretical)
+                *             ~ dev_ts2 - dev_ts1
+                * *but*:
+                *
+                * - time counters wrap (see adapter->ts_used_bits)
+                * - sometimes, dev_ts_1 < ts < dev_ts2
+                *
+                * "normal" case (sync time counters increase):
+                * must take into account case when ts wraps (tsw)
+                *
+                *      < ts_period > <          >
+                *     |             |            |
+                *  ---+--------+----+-------0-+--+-->
+                *     ts_dev_1 |    ts_dev_2  |
+                *              ts             tsw
+                */
+               if (time_ref->ts_dev_1 < time_ref->ts_dev_2) {
+                       /* case when event time (tsw) wraps */
+                       if (ts < time_ref->ts_dev_1)
+                               delta_ts = 1 << time_ref->adapter->ts_used_bits;
+
+               /* Otherwise, sync time counter (ts_dev_2) has wrapped:
+                * handle case when event time (tsn) hasn't.
+                *
+                *      < ts_period > <          >
+                *     |             |            |
+                *  ---+--------+--0-+---------+--+-->
+                *     ts_dev_1 |    ts_dev_2  |
+                *              tsn            ts
+                */
+               } else if (time_ref->ts_dev_1 < ts) {
+                       delta_ts = -(1 << time_ref->adapter->ts_used_bits);
+               }
 
-               delta_us = ts - time_ref->ts_dev_2;
-               if (ts < time_ref->ts_dev_2)
-                       delta_us &= (1 << time_ref->adapter->ts_used_bits) - 1;
+               /* add delay between last sync and event timestamps */
+               delta_ts += (signed int)(ts - time_ref->ts_dev_2);
 
-               delta_us += time_ref->ts_total;
+               /* add time from beginning to last sync */
+               delta_ts += time_ref->ts_total;
 
-               delta_us *= time_ref->adapter->us_per_ts_scale;
+               /* convert ticks number into microseconds */
+               delta_us = delta_ts * time_ref->adapter->us_per_ts_scale;
                delta_us >>= time_ref->adapter->us_per_ts_shift;
 
                *time = ktime_add_us(time_ref->tv_host_0, delta_us);
index ab63fd9eb982df5c30e7fd12a04de59a52379a04..d29d20525588c621a80c2afbc56d8c0be48a4faa 100644 (file)
@@ -468,12 +468,18 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if,
                                     struct pucan_msg *rx_msg)
 {
        struct pucan_rx_msg *rm = (struct pucan_rx_msg *)rx_msg;
-       struct peak_usb_device *dev = usb_if->dev[pucan_msg_get_channel(rm)];
-       struct net_device *netdev = dev->netdev;
+       struct peak_usb_device *dev;
+       struct net_device *netdev;
        struct canfd_frame *cfd;
        struct sk_buff *skb;
        const u16 rx_msg_flags = le16_to_cpu(rm->flags);
 
+       if (pucan_msg_get_channel(rm) >= ARRAY_SIZE(usb_if->dev))
+               return -ENOMEM;
+
+       dev = usb_if->dev[pucan_msg_get_channel(rm)];
+       netdev = dev->netdev;
+
        if (rx_msg_flags & PUCAN_MSG_EXT_DATA_LEN) {
                /* CANFD frame case */
                skb = alloc_canfd_skb(netdev, &cfd);
@@ -519,15 +525,21 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if,
                                     struct pucan_msg *rx_msg)
 {
        struct pucan_status_msg *sm = (struct pucan_status_msg *)rx_msg;
-       struct peak_usb_device *dev = usb_if->dev[pucan_stmsg_get_channel(sm)];
-       struct pcan_usb_fd_device *pdev =
-                       container_of(dev, struct pcan_usb_fd_device, dev);
+       struct pcan_usb_fd_device *pdev;
        enum can_state new_state = CAN_STATE_ERROR_ACTIVE;
        enum can_state rx_state, tx_state;
-       struct net_device *netdev = dev->netdev;
+       struct peak_usb_device *dev;
+       struct net_device *netdev;
        struct can_frame *cf;
        struct sk_buff *skb;
 
+       if (pucan_stmsg_get_channel(sm) >= ARRAY_SIZE(usb_if->dev))
+               return -ENOMEM;
+
+       dev = usb_if->dev[pucan_stmsg_get_channel(sm)];
+       pdev = container_of(dev, struct pcan_usb_fd_device, dev);
+       netdev = dev->netdev;
+
        /* nothing should be sent while in BUS_OFF state */
        if (dev->can.state == CAN_STATE_BUS_OFF)
                return 0;
@@ -579,9 +591,14 @@ static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if,
                                    struct pucan_msg *rx_msg)
 {
        struct pucan_error_msg *er = (struct pucan_error_msg *)rx_msg;
-       struct peak_usb_device *dev = usb_if->dev[pucan_ermsg_get_channel(er)];
-       struct pcan_usb_fd_device *pdev =
-                       container_of(dev, struct pcan_usb_fd_device, dev);
+       struct pcan_usb_fd_device *pdev;
+       struct peak_usb_device *dev;
+
+       if (pucan_ermsg_get_channel(er) >= ARRAY_SIZE(usb_if->dev))
+               return -EINVAL;
+
+       dev = usb_if->dev[pucan_ermsg_get_channel(er)];
+       pdev = container_of(dev, struct pcan_usb_fd_device, dev);
 
        /* keep a trace of tx and rx error counters for later use */
        pdev->bec.txerr = er->tx_err_cnt;
@@ -595,11 +612,17 @@ static int pcan_usb_fd_decode_overrun(struct pcan_usb_fd_if *usb_if,
                                      struct pucan_msg *rx_msg)
 {
        struct pcan_ufd_ovr_msg *ov = (struct pcan_ufd_ovr_msg *)rx_msg;
-       struct peak_usb_device *dev = usb_if->dev[pufd_omsg_get_channel(ov)];
-       struct net_device *netdev = dev->netdev;
+       struct peak_usb_device *dev;
+       struct net_device *netdev;
        struct can_frame *cf;
        struct sk_buff *skb;
 
+       if (pufd_omsg_get_channel(ov) >= ARRAY_SIZE(usb_if->dev))
+               return -EINVAL;
+
+       dev = usb_if->dev[pufd_omsg_get_channel(ov)];
+       netdev = dev->netdev;
+
        /* allocate an skb to store the error frame */
        skb = alloc_can_err_skb(netdev, &cf);
        if (!skb)
@@ -716,6 +739,9 @@ static int pcan_usb_fd_encode_msg(struct peak_usb_device *dev,
        u16 tx_msg_size, tx_msg_flags;
        u8 can_dlc;
 
+       if (cfd->len > CANFD_MAX_DLEN)
+               return -EINVAL;
+
        tx_msg_size = ALIGN(sizeof(struct pucan_tx_msg) + cfd->len, 4);
        tx_msg->size = cpu_to_le16(tx_msg_size);
        tx_msg->type = cpu_to_le16(PUCAN_MSG_CAN_TX);
index 6c4d00d2dbdcc3c2ec5a36defdcb7b883dd93abb..48d746e18f30219e49ed04c24165a789d0bc71fc 100644 (file)
@@ -1395,7 +1395,7 @@ static int xcan_open(struct net_device *ndev)
        if (ret < 0) {
                netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
                           __func__, ret);
-               return ret;
+               goto err;
        }
 
        ret = request_irq(ndev->irq, xcan_interrupt, priv->irq_flags,
@@ -1479,6 +1479,7 @@ static int xcan_get_berr_counter(const struct net_device *ndev,
        if (ret < 0) {
                netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
                           __func__, ret);
+               pm_runtime_put(priv->dev);
                return ret;
        }
 
@@ -1793,7 +1794,7 @@ static int xcan_probe(struct platform_device *pdev)
        if (ret < 0) {
                netdev_err(ndev, "%s: pm_runtime_get failed(%d)\n",
                           __func__, ret);
-               goto err_pmdisable;
+               goto err_disableclks;
        }
 
        if (priv->read_reg(priv, XCAN_SR_OFFSET) != XCAN_SR_CONFIG_MASK) {
@@ -1828,7 +1829,6 @@ static int xcan_probe(struct platform_device *pdev)
 
 err_disableclks:
        pm_runtime_put(priv->dev);
-err_pmdisable:
        pm_runtime_disable(&pdev->dev);
 err_free:
        free_candev(ndev);
index 53064e0e161873eb4bf1b82b9c4acb37daceeba5..5bdac669a3392e69e340744c4fe5dd4bcdb6aacb 100644 (file)
@@ -1219,8 +1219,8 @@ qca8k_port_change_mtu(struct dsa_switch *ds, int port, int new_mtu)
        priv->port_mtu[port] = new_mtu;
 
        for (i = 0; i < QCA8K_NUM_PORTS; i++)
-               if (priv->port_mtu[port] > mtu)
-                       mtu = priv->port_mtu[port];
+               if (priv->port_mtu[i] > mtu)
+                       mtu = priv->port_mtu[i];
 
        /* Include L2 header / FCS length */
        qca8k_write(priv, QCA8K_MAX_FRAME_SIZE, mtu + ETH_HLEN + ETH_FCS_LEN);
index fa147865e33f4a1927c0dd439d0ab4b9bd6f150d..7975f59735d61f3da9bb018e6635a4a7a241d7a1 100644 (file)
@@ -1160,16 +1160,6 @@ static void bnxt_queue_sp_work(struct bnxt *bp)
                schedule_work(&bp->sp_task);
 }
 
-static void bnxt_cancel_sp_work(struct bnxt *bp)
-{
-       if (BNXT_PF(bp)) {
-               flush_workqueue(bnxt_pf_wq);
-       } else {
-               cancel_work_sync(&bp->sp_task);
-               cancel_delayed_work_sync(&bp->fw_reset_task);
-       }
-}
-
 static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
 {
        if (!rxr->bnapi->in_reset) {
@@ -4362,7 +4352,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
        u32 bar_offset = BNXT_GRCPF_REG_CHIMP_COMM;
        u16 dst = BNXT_HWRM_CHNL_CHIMP;
 
-       if (BNXT_NO_FW_ACCESS(bp))
+       if (BNXT_NO_FW_ACCESS(bp) &&
+           le16_to_cpu(req->req_type) != HWRM_FUNC_RESET)
                return -EBUSY;
 
        if (msg_len > BNXT_HWRM_MAX_REQ_LEN) {
@@ -9789,7 +9780,10 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
 {
        int rc = 0;
 
-       rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
+       if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
+               rc = -EIO;
+       if (!rc)
+               rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
        if (rc) {
                netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc);
                dev_close(bp->dev);
@@ -12108,15 +12102,17 @@ static void bnxt_remove_one(struct pci_dev *pdev)
        if (BNXT_PF(bp))
                bnxt_sriov_disable(bp);
 
-       clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
-       bnxt_cancel_sp_work(bp);
-       bp->sp_event = 0;
-
-       bnxt_dl_fw_reporters_destroy(bp, true);
        if (BNXT_PF(bp))
                devlink_port_type_clear(&bp->dl_port);
        pci_disable_pcie_error_reporting(pdev);
        unregister_netdev(dev);
+       clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
+       /* Flush any pending tasks */
+       cancel_work_sync(&bp->sp_task);
+       cancel_delayed_work_sync(&bp->fw_reset_task);
+       bp->sp_event = 0;
+
+       bnxt_dl_fw_reporters_destroy(bp, true);
        bnxt_dl_unregister(bp);
        bnxt_shutdown_tc(bp);
 
@@ -12860,6 +12856,9 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
                return PCI_ERS_RESULT_DISCONNECT;
        }
 
+       if (state == pci_channel_io_frozen)
+               set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state);
+
        if (netif_running(netdev))
                bnxt_close(netdev);
 
@@ -12886,7 +12885,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
        struct bnxt *bp = netdev_priv(netdev);
-       int err = 0;
+       int err = 0, off;
        pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT;
 
        netdev_info(bp->dev, "PCI Slot Reset\n");
@@ -12898,6 +12897,20 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
                        "Cannot re-enable PCI device after reset.\n");
        } else {
                pci_set_master(pdev);
+               /* Upon fatal error, our device internal logic that latches to
+                * BAR value is getting reset and will restore only upon
+                * rewritting the BARs.
+                *
+                * As pci_restore_state() does not re-write the BARs if the
+                * value is same as saved value earlier, driver needs to
+                * write the BARs to 0 to force restore, in case of fatal error.
+                */
+               if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN,
+                                      &bp->state)) {
+                       for (off = PCI_BASE_ADDRESS_0;
+                            off <= PCI_BASE_ADDRESS_5; off += 4)
+                               pci_write_config_dword(bp->pdev, off, 0);
+               }
                pci_restore_state(pdev);
                pci_save_state(pdev);
 
index 21ef1c21f602acdd444437a33b91bcf0be5ff14d..47b3c31278798b1b076f15fdd45d1e9d5a05311a 100644 (file)
@@ -1781,6 +1781,7 @@ struct bnxt {
 #define BNXT_STATE_ABORT_ERR   5
 #define BNXT_STATE_FW_FATAL_COND       6
 #define BNXT_STATE_DRV_REGISTERED      7
+#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN       8
 
 #define BNXT_NO_FW_ACCESS(bp)                                  \
        (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) ||    \
index 883e47c5b1a7852062ab196ebc3fb80743f128d1..286f0341bdf83a32781730151b27a4a9e831cafb 100644 (file)
@@ -1929,7 +1929,8 @@ static inline int macb_clear_csum(struct sk_buff *skb)
 
 static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *ndev)
 {
-       bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb);
+       bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) ||
+                     skb_is_nonlinear(*skb);
        int padlen = ETH_ZLEN - (*skb)->len;
        int headroom = skb_headroom(*skb);
        int tailroom = skb_tailroom(*skb);
index 6ec5f2f26f05526fbaf726e786e4154cac790012..4e55f7081644362871d1730492458c8c1fc8acbc 100644 (file)
@@ -145,13 +145,13 @@ static int configure_filter_smac(struct adapter *adap, struct filter_entry *f)
        int err;
 
        /* do a set-tcb for smac-sel and CWR bit.. */
-       err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
-       if (err)
-               goto smac_err;
-
        err = set_tcb_field(adap, f, f->tid, TCB_SMAC_SEL_W,
                            TCB_SMAC_SEL_V(TCB_SMAC_SEL_M),
                            TCB_SMAC_SEL_V(f->smt->idx), 1);
+       if (err)
+               goto smac_err;
+
+       err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
        if (!err)
                return 0;
 
@@ -862,6 +862,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
                      FW_FILTER_WR_DIRSTEERHASH_V(f->fs.dirsteerhash) |
                      FW_FILTER_WR_LPBK_V(f->fs.action == FILTER_SWITCH) |
                      FW_FILTER_WR_DMAC_V(f->fs.newdmac) |
+                     FW_FILTER_WR_SMAC_V(f->fs.newsmac) |
                      FW_FILTER_WR_INSVLAN_V(f->fs.newvlan == VLAN_INSERT ||
                                             f->fs.newvlan == VLAN_REWRITE) |
                      FW_FILTER_WR_RMVLAN_V(f->fs.newvlan == VLAN_REMOVE ||
@@ -879,7 +880,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
                 FW_FILTER_WR_OVLAN_VLD_V(f->fs.val.ovlan_vld) |
                 FW_FILTER_WR_IVLAN_VLDM_V(f->fs.mask.ivlan_vld) |
                 FW_FILTER_WR_OVLAN_VLDM_V(f->fs.mask.ovlan_vld));
-       fwr->smac_sel = 0;
+       fwr->smac_sel = f->smt->idx;
        fwr->rx_chan_rx_rpl_iq =
                htons(FW_FILTER_WR_RX_CHAN_V(0) |
                      FW_FILTER_WR_RX_RPL_IQ_V(adapter->sge.fw_evtq.abs_id));
@@ -1323,11 +1324,8 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
                            TX_QUEUE_V(f->fs.nat_mode) |
                            T5_OPT_2_VALID_F |
                            RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
-                           CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
-                                        (f->fs.dirsteer << 1)) |
                            PACE_V((f->fs.maskhash) |
-                                  ((f->fs.dirsteerhash) << 1)) |
-                           CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
+                                  ((f->fs.dirsteerhash) << 1)));
 }
 
 static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
@@ -1363,11 +1361,8 @@ static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
                            TX_QUEUE_V(f->fs.nat_mode) |
                            T5_OPT_2_VALID_F |
                            RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
-                           CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
-                                        (f->fs.dirsteer << 1)) |
                            PACE_V((f->fs.maskhash) |
-                                  ((f->fs.dirsteerhash) << 1)) |
-                           CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
+                                  ((f->fs.dirsteerhash) << 1)));
 }
 
 static int cxgb4_set_hash_filter(struct net_device *dev,
@@ -2039,6 +2034,20 @@ void hash_filter_rpl(struct adapter *adap, const struct cpl_act_open_rpl *rpl)
                        }
                        return;
                }
+               switch (f->fs.action) {
+               case FILTER_PASS:
+                       if (f->fs.dirsteer)
+                               set_tcb_tflag(adap, f, tid,
+                                             TF_DIRECT_STEER_S, 1, 1);
+                       break;
+               case FILTER_DROP:
+                       set_tcb_tflag(adap, f, tid, TF_DROP_S, 1, 1);
+                       break;
+               case FILTER_SWITCH:
+                       set_tcb_tflag(adap, f, tid, TF_LPBK_S, 1, 1);
+                       break;
+               }
+
                break;
 
        default:
@@ -2106,22 +2115,11 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
                        if (ctx)
                                ctx->result = 0;
                } else if (ret == FW_FILTER_WR_FLT_ADDED) {
-                       int err = 0;
-
-                       if (f->fs.newsmac)
-                               err = configure_filter_smac(adap, f);
-
-                       if (!err) {
-                               f->pending = 0;  /* async setup completed */
-                               f->valid = 1;
-                               if (ctx) {
-                                       ctx->result = 0;
-                                       ctx->tid = idx;
-                               }
-                       } else {
-                               clear_filter(adap, f);
-                               if (ctx)
-                                       ctx->result = err;
+                       f->pending = 0;  /* async setup completed */
+                       f->valid = 1;
+                       if (ctx) {
+                               ctx->result = 0;
+                               ctx->tid = idx;
                        }
                } else {
                        /* Something went wrong.  Issue a warning about the
index 50232e063f49e598d9df7b02b5f1fa794fd3ab5c..92473dda55d9f8238f6c5c3a6ebf168349b3f8b0 100644 (file)
 #define TCB_T_FLAGS_M          0xffffffffffffffffULL
 #define TCB_T_FLAGS_V(x)       ((__u64)(x) << TCB_T_FLAGS_S)
 
+#define TF_DROP_S              22
+#define TF_DIRECT_STEER_S      23
+#define TF_LPBK_S              59
+
 #define TF_CCTRL_ECE_S         60
 #define TF_CCTRL_CWR_S         61
 #define TF_CCTRL_RFR_S         62
index ec4f79049a061bda7109b686d1525ea238d52f9d..96d5616534963e298660f39782febd9744340c93 100644 (file)
@@ -212,7 +212,7 @@ static struct sk_buff *alloc_ctrl_skb(struct sk_buff *skb, int len)
 {
        if (likely(skb && !skb_shared(skb) && !skb_cloned(skb))) {
                __skb_trim(skb, 0);
-               refcount_add(2, &skb->users);
+               refcount_inc(&skb->users);
        } else {
                skb = alloc_skb(len, GFP_KERNEL | __GFP_NOFAIL);
        }
@@ -772,14 +772,13 @@ static int chtls_pass_open_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
        if (rpl->status != CPL_ERR_NONE) {
                pr_info("Unexpected PASS_OPEN_RPL status %u for STID %u\n",
                        rpl->status, stid);
-               return CPL_RET_BUF_DONE;
+       } else {
+               cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
+               sock_put(listen_ctx->lsk);
+               kfree(listen_ctx);
+               module_put(THIS_MODULE);
        }
-       cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
-       sock_put(listen_ctx->lsk);
-       kfree(listen_ctx);
-       module_put(THIS_MODULE);
-
-       return 0;
+       return CPL_RET_BUF_DONE;
 }
 
 static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
@@ -796,15 +795,13 @@ static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
        if (rpl->status != CPL_ERR_NONE) {
                pr_info("Unexpected CLOSE_LISTSRV_RPL status %u for STID %u\n",
                        rpl->status, stid);
-               return CPL_RET_BUF_DONE;
+       } else {
+               cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
+               sock_put(listen_ctx->lsk);
+               kfree(listen_ctx);
+               module_put(THIS_MODULE);
        }
-
-       cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
-       sock_put(listen_ctx->lsk);
-       kfree(listen_ctx);
-       module_put(THIS_MODULE);
-
-       return 0;
+       return CPL_RET_BUF_DONE;
 }
 
 static void chtls_purge_wr_queue(struct sock *sk)
@@ -1514,7 +1511,6 @@ static void add_to_reap_list(struct sock *sk)
        struct chtls_sock *csk = sk->sk_user_data;
 
        local_bh_disable();
-       bh_lock_sock(sk);
        release_tcp_port(sk); /* release the port immediately */
 
        spin_lock(&reap_list_lock);
@@ -1523,7 +1519,6 @@ static void add_to_reap_list(struct sock *sk)
        if (!csk->passive_reap_next)
                schedule_work(&reap_task);
        spin_unlock(&reap_list_lock);
-       bh_unlock_sock(sk);
        local_bh_enable();
 }
 
index f1820aca0d336902a1228db69e4f5c40b2e056f9..62c829023da564f46be598d7bc6fec13aebe3896 100644 (file)
@@ -383,6 +383,9 @@ int chtls_setkey(struct chtls_sock *csk, u32 keylen,
        if (ret)
                goto out_notcb;
 
+       if (unlikely(csk_flag(sk, CSK_ABORT_SHUTDOWN)))
+               goto out_notcb;
+
        set_wr_txq(skb, CPL_PRIORITY_DATA, csk->tlshws.txqid);
        csk->wr_credits -= DIV_ROUND_UP(len, 16);
        csk->wr_unacked += DIV_ROUND_UP(len, 16);
index 9fb5ca6682ea23fe2b2e4d488b8d6ede74f81bbe..188d871f6b8cdbf613a50edd09b48aa1fde39b88 100644 (file)
@@ -1585,6 +1585,7 @@ skip_copy:
                        tp->urg_data = 0;
 
                if ((avail + offset) >= skb->len) {
+                       struct sk_buff *next_skb;
                        if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) {
                                tp->copied_seq += skb->len;
                                hws->rcvpld = skb->hdr_len;
@@ -1595,8 +1596,10 @@ skip_copy:
                        chtls_free_skb(sk, skb);
                        buffers_freed++;
                        hws->copied_seq = 0;
-                       if (copied >= target &&
-                           !skb_peek(&sk->sk_receive_queue))
+                       next_skb = skb_peek(&sk->sk_receive_queue);
+                       if (copied >= target && !next_skb)
+                               break;
+                       if (ULP_SKB_CB(next_skb)->flags & ULPCB_FLAG_TLS_HDR)
                                break;
                }
        } while (len > 0);
index 06cc863f4dd63258556f18af04bf8898b3a76ff5..d9c285948fc21d0f4269c65d26234b685c6d3641 100644 (file)
@@ -174,12 +174,17 @@ MODULE_PARM_DESC(tx_timeout, "The Tx timeout in ms");
 #define DPAA_PARSE_RESULTS_SIZE sizeof(struct fman_prs_result)
 #define DPAA_TIME_STAMP_SIZE 8
 #define DPAA_HASH_RESULTS_SIZE 8
+#define DPAA_HWA_SIZE (DPAA_PARSE_RESULTS_SIZE + DPAA_TIME_STAMP_SIZE \
+                      + DPAA_HASH_RESULTS_SIZE)
+#define DPAA_RX_PRIV_DATA_DEFAULT_SIZE (DPAA_TX_PRIV_DATA_SIZE + \
+                                       dpaa_rx_extra_headroom)
 #ifdef CONFIG_DPAA_ERRATUM_A050385
-#define DPAA_RX_PRIV_DATA_SIZE (DPAA_A050385_ALIGN - (DPAA_PARSE_RESULTS_SIZE\
-        + DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE))
+#define DPAA_RX_PRIV_DATA_A050385_SIZE (DPAA_A050385_ALIGN - DPAA_HWA_SIZE)
+#define DPAA_RX_PRIV_DATA_SIZE (fman_has_errata_a050385() ? \
+                               DPAA_RX_PRIV_DATA_A050385_SIZE : \
+                               DPAA_RX_PRIV_DATA_DEFAULT_SIZE)
 #else
-#define DPAA_RX_PRIV_DATA_SIZE (u16)(DPAA_TX_PRIV_DATA_SIZE + \
-                                       dpaa_rx_extra_headroom)
+#define DPAA_RX_PRIV_DATA_SIZE DPAA_RX_PRIV_DATA_DEFAULT_SIZE
 #endif
 
 #define DPAA_ETH_PCD_RXQ_NUM   128
@@ -2840,7 +2845,8 @@ out_error:
        return err;
 }
 
-static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
+static u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl,
+                            enum port_type port)
 {
        u16 headroom;
 
@@ -2854,10 +2860,12 @@ static inline u16 dpaa_get_headroom(struct dpaa_buffer_layout *bl)
         *
         * Also make sure the headroom is a multiple of data_align bytes
         */
-       headroom = (u16)(bl->priv_data_size + DPAA_PARSE_RESULTS_SIZE +
-               DPAA_TIME_STAMP_SIZE + DPAA_HASH_RESULTS_SIZE);
+       headroom = (u16)(bl[port].priv_data_size + DPAA_HWA_SIZE);
 
-       return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
+       if (port == RX)
+               return ALIGN(headroom, DPAA_FD_RX_DATA_ALIGNMENT);
+       else
+               return ALIGN(headroom, DPAA_FD_DATA_ALIGNMENT);
 }
 
 static int dpaa_eth_probe(struct platform_device *pdev)
@@ -3025,8 +3033,8 @@ static int dpaa_eth_probe(struct platform_device *pdev)
                        goto free_dpaa_fqs;
        }
 
-       priv->tx_headroom = dpaa_get_headroom(&priv->buf_layout[TX]);
-       priv->rx_headroom = dpaa_get_headroom(&priv->buf_layout[RX]);
+       priv->tx_headroom = dpaa_get_headroom(priv->buf_layout, TX);
+       priv->rx_headroom = dpaa_get_headroom(priv->buf_layout, RX);
 
        /* All real interfaces need their ports initialized */
        err = dpaa_eth_init_ports(mac_dev, dpaa_bp, &port_fqs,
index c81be32bcedf61fce4f80aad5317117a5f313a0c..827f74e86d34a5c2e558df27d7b3974faee667de 100644 (file)
@@ -402,7 +402,7 @@ struct enetc_psfp_gate {
        u32 num_entries;
        refcount_t refcount;
        struct hlist_node node;
-       struct action_gate_entry entries[0];
+       struct action_gate_entry entries[];
 };
 
 /* Only enable the green color frame now
index 832a2175636d69b7a29ecd560b8b8804fa4c759f..c527f4ee1d3aed313124d2befbb6a536801e5594 100644 (file)
@@ -456,6 +456,12 @@ struct bufdesc_ex {
  */
 #define FEC_QUIRK_HAS_FRREG            (1 << 16)
 
+/* Some FEC hardware blocks need the MMFR cleared at setup time to avoid
+ * the generation of an MII event. This must be avoided in the older
+ * FEC blocks where it will stop MII events being generated.
+ */
+#define FEC_QUIRK_CLEAR_SETUP_MII      (1 << 17)
+
 struct bufdesc_prop {
        int qid;
        /* Address of Rx and Tx buffers */
index 8f7eca1e7716c9bbaddb28f9b541a339ef326a8c..d7919555250dd34fcf372c85dd1c03aa13d76d03 100644 (file)
@@ -100,14 +100,14 @@ static const struct fec_devinfo fec_imx27_info = {
 static const struct fec_devinfo fec_imx28_info = {
        .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_SWAP_FRAME |
                  FEC_QUIRK_SINGLE_MDIO | FEC_QUIRK_HAS_RACC |
-                 FEC_QUIRK_HAS_FRREG,
+                 FEC_QUIRK_HAS_FRREG | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_imx6q_info = {
        .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT |
                  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
                  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR006358 |
-                 FEC_QUIRK_HAS_RACC,
+                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_mvf600_info = {
@@ -119,7 +119,8 @@ static const struct fec_devinfo fec_imx6x_info = {
                  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
                  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB |
                  FEC_QUIRK_ERR007885 | FEC_QUIRK_BUG_CAPTURE |
-                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE,
+                 FEC_QUIRK_HAS_RACC | FEC_QUIRK_HAS_COALESCE |
+                 FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static const struct fec_devinfo fec_imx6ul_info = {
@@ -127,7 +128,7 @@ static const struct fec_devinfo fec_imx6ul_info = {
                  FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM |
                  FEC_QUIRK_HAS_VLAN | FEC_QUIRK_ERR007885 |
                  FEC_QUIRK_BUG_CAPTURE | FEC_QUIRK_HAS_RACC |
-                 FEC_QUIRK_HAS_COALESCE,
+                 FEC_QUIRK_HAS_COALESCE | FEC_QUIRK_CLEAR_SETUP_MII,
 };
 
 static struct platform_device_id fec_devtype[] = {
@@ -2134,15 +2135,17 @@ static int fec_enet_mii_init(struct platform_device *pdev)
        if (suppress_preamble)
                fep->phy_speed |= BIT(7);
 
-       /* Clear MMFR to avoid to generate MII event by writing MSCR.
-        * MII event generation condition:
-        * - writing MSCR:
-        *      - mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
-        *        mscr_reg_data_in[7:0] != 0
-        * - writing MMFR:
-        *      - mscr[7:0]_not_zero
-        */
-       writel(0, fep->hwp + FEC_MII_DATA);
+       if (fep->quirks & FEC_QUIRK_CLEAR_SETUP_MII) {
+               /* Clear MMFR to avoid to generate MII event by writing MSCR.
+                * MII event generation condition:
+                * - writing MSCR:
+                *      - mmfr[31:0]_not_zero & mscr[7:0]_is_zero &
+                *        mscr_reg_data_in[7:0] != 0
+                * - writing MMFR:
+                *      - mscr[7:0]_not_zero
+                */
+               writel(0, fep->hwp + FEC_MII_DATA);
+       }
 
        writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 
index 41dd3d0f3452442d60383e15b84cdac050673d6d..d391a45cebb661c7b94084648433c77c27484a99 100644 (file)
@@ -1829,20 +1829,12 @@ static netdev_tx_t gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
                fcb_len = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
        /* make space for additional header when fcb is needed */
-       if (fcb_len && unlikely(skb_headroom(skb) < fcb_len)) {
-               struct sk_buff *skb_new;
-
-               skb_new = skb_realloc_headroom(skb, fcb_len);
-               if (!skb_new) {
+       if (fcb_len) {
+               if (unlikely(skb_cow_head(skb, fcb_len))) {
                        dev->stats.tx_errors++;
                        dev_kfree_skb_any(skb);
                        return NETDEV_TX_OK;
                }
-
-               if (skb->sk)
-                       skb_set_owner_w(skb_new, skb->sk);
-               dev_consume_skb_any(skb);
-               skb = skb_new;
        }
 
        /* total number of fragments in the SKB */
@@ -3380,7 +3372,7 @@ static int gfar_probe(struct platform_device *ofdev)
 
        if (dev->features & NETIF_F_IP_CSUM ||
            priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
-               dev->needed_headroom = GMAC_FCB_LEN;
+               dev->needed_headroom = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
        /* Initializing some of the rx/tx queue level parameters */
        for (i = 0; i < priv->num_tx_queues; i++) {
index 714b501be7d09f805057f21222d8086900c53dc9..ba8869c3d891c0e05e29cd4fb1bcb5b17ce775ba 100644 (file)
@@ -1358,7 +1358,7 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
            (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
                upsmr |= UCC_GETH_UPSMR_TBIM;
        }
-       if ((ugeth->phy_interface == PHY_INTERFACE_MODE_SGMII))
+       if (ugeth->phy_interface == PHY_INTERFACE_MODE_SGMII)
                upsmr |= UCC_GETH_UPSMR_SGMM;
 
        out_be32(&uf_regs->upsmr, upsmr);
index 281de8326bc510ce7c536c63a77c1bb25c562145..015796a20118bcdf2c1b095d5f95c59d2300233e 100644 (file)
@@ -198,7 +198,7 @@ static_assert(sizeof(struct stats) == 16);
 
 struct gve_stats_report {
        __be64 written_count;
-       struct stats stats[0];
+       struct stats stats[];
 };
 
 static_assert(sizeof(struct gve_stats_report) == 8);
index 48a433154ce079c8c45cd8aae53eed7e0d3e5e04..02e7d74779f46adb76deb1ae935a7ce32442695a 100644 (file)
@@ -116,9 +116,8 @@ static int gve_alloc_stats_report(struct gve_priv *priv)
                       priv->tx_cfg.num_queues;
        rx_stats_num = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) *
                       priv->rx_cfg.num_queues;
-       priv->stats_report_len = sizeof(struct gve_stats_report) +
-                                (tx_stats_num + rx_stats_num) *
-                                sizeof(struct stats);
+       priv->stats_report_len = struct_size(priv->stats_report, stats,
+                                            tx_stats_num + rx_stats_num);
        priv->stats_report =
                dma_alloc_coherent(&priv->pdev->dev, priv->stats_report_len,
                                   &priv->stats_report_bus, GFP_KERNEL);
index 15f69fa863236cb838397dc7d3d2d107f8b890c2..e8495f58a1a8e81fa4dbdc86b998984fea437434 100644 (file)
@@ -1373,7 +1373,7 @@ static int hclge_tm_bp_setup(struct hclge_dev *hdev)
                        return ret;
        }
 
-       return ret;
+       return 0;
 }
 
 int hclge_pause_setup_hw(struct hclge_dev *hdev, bool init)
index 50c84c5e65d29566712772b5fc51b4bf1ab43cfa..c8e3fdd5999c4f676f65d1793357b6b47f6eaf87 100644 (file)
@@ -3262,8 +3262,8 @@ static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev)
                hclgevf_uninit_msi(hdev);
        }
 
-       hclgevf_pci_uninit(hdev);
        hclgevf_cmd_uninit(hdev);
+       hclgevf_pci_uninit(hdev);
        hclgevf_uninit_mac_list(hdev);
 }
 
index 7ef3369953b6a540fa15c7ad9cb192d50f570a3e..c3ec9ceed833ed4e6d128c86bbf09aa476de91b5 100644 (file)
@@ -1031,12 +1031,6 @@ static int ibmveth_is_packet_unsupported(struct sk_buff *skb,
                ret = -EOPNOTSUPP;
        }
 
-       if (!ether_addr_equal(ether_header->h_source, netdev->dev_addr)) {
-               netdev_dbg(netdev, "source packet MAC address does not match veth device's, dropping packet.\n");
-               netdev->stats.tx_dropped++;
-               ret = -EOPNOTSUPP;
-       }
-
        return ret;
 }
 
index 8148f796a8070b2aeb7c44ebfed4ca914c7dcf00..da15913879f8e7d8c89f22823b70cb27342f479e 100644 (file)
@@ -1185,18 +1185,27 @@ static int ibmvnic_open(struct net_device *netdev)
        if (adapter->state != VNIC_CLOSED) {
                rc = ibmvnic_login(netdev);
                if (rc)
-                       return rc;
+                       goto out;
 
                rc = init_resources(adapter);
                if (rc) {
                        netdev_err(netdev, "failed to initialize resources\n");
                        release_resources(adapter);
-                       return rc;
+                       goto out;
                }
        }
 
        rc = __ibmvnic_open(netdev);
 
+out:
+       /*
+        * If open fails due to a pending failover, set device state and
+        * return. Device operation will be handled by reset routine.
+        */
+       if (rc && adapter->failover_pending) {
+               adapter->state = VNIC_OPEN;
+               rc = 0;
+       }
        return rc;
 }
 
@@ -1815,9 +1824,13 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
        int rc;
 
        rc = 0;
-       ether_addr_copy(adapter->mac_addr, addr->sa_data);
-       if (adapter->state != VNIC_PROBED)
+       if (!is_valid_ether_addr(addr->sa_data))
+               return -EADDRNOTAVAIL;
+
+       if (adapter->state != VNIC_PROBED) {
+               ether_addr_copy(adapter->mac_addr, addr->sa_data);
                rc = __ibmvnic_set_mac(netdev, addr->sa_data);
+       }
 
        return rc;
 }
@@ -1918,6 +1931,13 @@ static int do_reset(struct ibmvnic_adapter *adapter,
                   rwi->reset_reason);
 
        rtnl_lock();
+       /*
+        * Now that we have the rtnl lock, clear any pending failover.
+        * This will ensure ibmvnic_open() has either completed or will
+        * block until failover is complete.
+        */
+       if (rwi->reset_reason == VNIC_RESET_FAILOVER)
+               adapter->failover_pending = false;
 
        netif_carrier_off(netdev);
        adapter->reset_reason = rwi->reset_reason;
@@ -2198,6 +2218,13 @@ static void __ibmvnic_reset(struct work_struct *work)
                        /* CHANGE_PARAM requestor holds rtnl_lock */
                        rc = do_change_param_reset(adapter, rwi, reset_state);
                } else if (adapter->force_reset_recovery) {
+                       /*
+                        * Since we are doing a hard reset now, clear the
+                        * failover_pending flag so we don't ignore any
+                        * future MOBILITY or other resets.
+                        */
+                       adapter->failover_pending = false;
+
                        /* Transport event occurred during previous reset */
                        if (adapter->wait_for_reset) {
                                /* Previous was CHANGE_PARAM; caller locked */
@@ -2262,9 +2289,15 @@ static int ibmvnic_reset(struct ibmvnic_adapter *adapter,
        unsigned long flags;
        int ret;
 
+       /*
+        * If failover is pending don't schedule any other reset.
+        * Instead let the failover complete. If there is already a
+        * a failover reset scheduled, we will detect and drop the
+        * duplicate reset when walking the ->rwi_list below.
+        */
        if (adapter->state == VNIC_REMOVING ||
            adapter->state == VNIC_REMOVED ||
-           adapter->failover_pending) {
+           (adapter->failover_pending && reason != VNIC_RESET_FAILOVER)) {
                ret = EBUSY;
                netdev_dbg(netdev, "Adapter removing or pending failover, skipping reset\n");
                goto err;
@@ -4709,7 +4742,6 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
                case IBMVNIC_CRQ_INIT:
                        dev_info(dev, "Partner initialized\n");
                        adapter->from_passive_init = true;
-                       adapter->failover_pending = false;
                        if (!completion_done(&adapter->init_done)) {
                                complete(&adapter->init_done);
                                adapter->init_done_rc = -EIO;
index d046db7bb047d5f9fc9dc59b415bef0a53efb356..3a9fa629503f0e0eb889ae0e4b79dc05eafee79e 100644 (file)
@@ -90,9 +90,4 @@ int mlx5_create_encryption_key(struct mlx5_core_dev *mdev,
                               u32 key_type, u32 *p_key_id);
 void mlx5_destroy_encryption_key(struct mlx5_core_dev *mdev, u32 key_id);
 
-static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
-{
-       return devlink_net(priv_to_devlink(dev));
-}
-
 #endif
index 7f77c2a71d1c63682a119ed64a197ae34446e951..937b8e46f8c770a7630e37165f80628f99cf40f9 100644 (file)
@@ -620,6 +620,9 @@ static void mlxsw_emad_transmit_retry(struct mlxsw_core *mlxsw_core,
                err = mlxsw_emad_transmit(trans->core, trans);
                if (err == 0)
                        return;
+
+               if (!atomic_dec_and_test(&trans->active))
+                       return;
        } else {
                err = -EIO;
        }
@@ -2064,6 +2067,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
        if (!reload)
                devlink_resources_unregister(devlink, NULL);
        mlxsw_core->bus->fini(mlxsw_core->bus_priv);
+       if (!reload)
+               devlink_free(devlink);
 
        return;
 
index 16b47fce540bb1b3ac77cd5d2524ccf36a9052bc..b08853f71b2beae79e1458e2fc2cb77eb6d4dec5 100644 (file)
@@ -1174,11 +1174,14 @@ mlxsw_sp_port_speed_by_width_set(struct mlxsw_sp_port *mlxsw_sp_port)
        u32 eth_proto_cap, eth_proto_admin, eth_proto_oper;
        const struct mlxsw_sp_port_type_speed_ops *ops;
        char ptys_pl[MLXSW_REG_PTYS_LEN];
+       u32 eth_proto_cap_masked;
        int err;
 
        ops = mlxsw_sp->port_type_speed_ops;
 
-       /* Set advertised speeds to supported speeds. */
+       /* Set advertised speeds to speeds supported by both the driver
+        * and the device.
+        */
        ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port,
                               0, false);
        err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
@@ -1187,8 +1190,10 @@ mlxsw_sp_port_speed_by_width_set(struct mlxsw_sp_port *mlxsw_sp_port)
 
        ops->reg_ptys_eth_unpack(mlxsw_sp, ptys_pl, &eth_proto_cap,
                                 &eth_proto_admin, &eth_proto_oper);
+       eth_proto_cap_masked = ops->ptys_proto_cap_masked_get(eth_proto_cap);
        ops->reg_ptys_eth_pack(mlxsw_sp, ptys_pl, mlxsw_sp_port->local_port,
-                              eth_proto_cap, mlxsw_sp_port->link.autoneg);
+                              eth_proto_cap_masked,
+                              mlxsw_sp_port->link.autoneg);
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ptys), ptys_pl);
 }
 
index 3e26eb6cb1404a0feb4decab8a8b1e09916c6b55..74b3959b36d4db43e23c7d4c20c690ac899a1e48 100644 (file)
@@ -342,6 +342,7 @@ struct mlxsw_sp_port_type_speed_ops {
                                    u32 *p_eth_proto_cap,
                                    u32 *p_eth_proto_admin,
                                    u32 *p_eth_proto_oper);
+       u32 (*ptys_proto_cap_masked_get)(u32 eth_proto_cap);
 };
 
 static inline struct net_device *
index 2096b6478958234c7e39c20be87a7b2be7c40cdb..540616469e2849abd00b9a7f742a06e6753ef7d7 100644 (file)
@@ -1303,6 +1303,20 @@ mlxsw_sp1_reg_ptys_eth_unpack(struct mlxsw_sp *mlxsw_sp, char *payload,
                                  p_eth_proto_oper);
 }
 
+static u32 mlxsw_sp1_ptys_proto_cap_masked_get(u32 eth_proto_cap)
+{
+       u32 ptys_proto_cap_masked = 0;
+       int i;
+
+       for (i = 0; i < MLXSW_SP1_PORT_LINK_MODE_LEN; i++) {
+               if (mlxsw_sp1_port_link_mode[i].mask & eth_proto_cap)
+                       ptys_proto_cap_masked |=
+                               mlxsw_sp1_port_link_mode[i].mask;
+       }
+
+       return ptys_proto_cap_masked;
+}
+
 const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops = {
        .from_ptys_supported_port       = mlxsw_sp1_from_ptys_supported_port,
        .from_ptys_link                 = mlxsw_sp1_from_ptys_link,
@@ -1313,6 +1327,7 @@ const struct mlxsw_sp_port_type_speed_ops mlxsw_sp1_port_type_speed_ops = {
        .to_ptys_speed                  = mlxsw_sp1_to_ptys_speed,
        .reg_ptys_eth_pack              = mlxsw_sp1_reg_ptys_eth_pack,
        .reg_ptys_eth_unpack            = mlxsw_sp1_reg_ptys_eth_unpack,
+       .ptys_proto_cap_masked_get      = mlxsw_sp1_ptys_proto_cap_masked_get,
 };
 
 static const enum ethtool_link_mode_bit_indices
@@ -1731,6 +1746,20 @@ mlxsw_sp2_reg_ptys_eth_unpack(struct mlxsw_sp *mlxsw_sp, char *payload,
                                      p_eth_proto_admin, p_eth_proto_oper);
 }
 
+static u32 mlxsw_sp2_ptys_proto_cap_masked_get(u32 eth_proto_cap)
+{
+       u32 ptys_proto_cap_masked = 0;
+       int i;
+
+       for (i = 0; i < MLXSW_SP2_PORT_LINK_MODE_LEN; i++) {
+               if (mlxsw_sp2_port_link_mode[i].mask & eth_proto_cap)
+                       ptys_proto_cap_masked |=
+                               mlxsw_sp2_port_link_mode[i].mask;
+       }
+
+       return ptys_proto_cap_masked;
+}
+
 const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops = {
        .from_ptys_supported_port       = mlxsw_sp2_from_ptys_supported_port,
        .from_ptys_link                 = mlxsw_sp2_from_ptys_link,
@@ -1741,4 +1770,5 @@ const struct mlxsw_sp_port_type_speed_ops mlxsw_sp2_port_type_speed_ops = {
        .to_ptys_speed                  = mlxsw_sp2_to_ptys_speed,
        .reg_ptys_eth_pack              = mlxsw_sp2_reg_ptys_eth_pack,
        .reg_ptys_eth_unpack            = mlxsw_sp2_reg_ptys_eth_unpack,
+       .ptys_proto_cap_masked_get      = mlxsw_sp2_ptys_proto_cap_masked_get,
 };
index 545c99b15df8e02fca4b5b4c7f87ee60990f2907..dc5fbc2704f3a3b4f3c37fddcb686a4ea7d804d9 100644 (file)
@@ -333,7 +333,7 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data)
        union ionic_dev_cmd cmd = {
                .vf_setattr.opcode = IONIC_CMD_VF_SETATTR,
                .vf_setattr.attr = attr,
-               .vf_setattr.vf_index = vf,
+               .vf_setattr.vf_index = cpu_to_le16(vf),
        };
        int err;
 
@@ -391,7 +391,7 @@ void ionic_dev_cmd_queue_identify(struct ionic_dev *idev,
 {
        union ionic_dev_cmd cmd = {
                .q_identify.opcode = IONIC_CMD_Q_IDENTIFY,
-               .q_identify.lif_type = lif_type,
+               .q_identify.lif_type = cpu_to_le16(lif_type),
                .q_identify.type = qtype,
                .q_identify.ver = qver,
        };
index c109cd5a04713e28328ed233ff5a9e15092e36fa..6c243b17312c729ea5fe0050e37bd21f5734abd0 100644 (file)
@@ -29,6 +29,7 @@ struct ionic_dev_bar {
        int res_index;
 };
 
+#ifndef __CHECKER__
 /* Registers */
 static_assert(sizeof(struct ionic_intr) == 32);
 
@@ -119,6 +120,7 @@ static_assert(sizeof(struct ionic_vf_setattr_cmd) == 64);
 static_assert(sizeof(struct ionic_vf_setattr_comp) == 16);
 static_assert(sizeof(struct ionic_vf_getattr_cmd) == 64);
 static_assert(sizeof(struct ionic_vf_getattr_comp) == 16);
+#endif /* __CHECKER__ */
 
 struct ionic_devinfo {
        u8 asic_type;
index ed9808fc743b218fa280d28d3ffb72d1c7c0ddd3..35c72d4a78b3f9ed37c4ae173346848790362484 100644 (file)
@@ -126,6 +126,11 @@ static int ionic_get_link_ksettings(struct net_device *netdev,
 
        ethtool_link_ksettings_zero_link_mode(ks, supported);
 
+       if (!idev->port_info) {
+               netdev_err(netdev, "port_info not initialized\n");
+               return -EOPNOTSUPP;
+       }
+
        /* The port_info data is found in a DMA space that the NIC keeps
         * up-to-date, so there's no need to request the data from the
         * NIC, we already have it in our memory space.
index f492ae406a605bb39933859f419a1f065a32621e..d7bbf336c6f65c505e176e13646f035e0fef15cd 100644 (file)
@@ -27,9 +27,9 @@ static void ionic_dev_cmd_firmware_download(struct ionic_dev *idev, u64 addr,
 {
        union ionic_dev_cmd cmd = {
                .fw_download.opcode = IONIC_CMD_FW_DOWNLOAD,
-               .fw_download.offset = offset,
-               .fw_download.addr = addr,
-               .fw_download.length = length
+               .fw_download.offset = cpu_to_le32(offset),
+               .fw_download.addr = cpu_to_le64(addr),
+               .fw_download.length = cpu_to_le32(length),
        };
 
        ionic_dev_cmd_go(idev, &cmd);
index d655a7ae3058cf401204be51ce4160581ac31981..a12df3946a07cdcb89474d1687755bb2a3019401 100644 (file)
@@ -1656,7 +1656,6 @@ static void ionic_txrx_deinit(struct ionic_lif *lif)
        if (lif->rxqcqs) {
                for (i = 0; i < lif->nxqs && lif->rxqcqs[i]; i++) {
                        ionic_lif_qcq_deinit(lif, lif->rxqcqs[i]);
-                       ionic_rx_flush(&lif->rxqcqs[i]->cq);
                        ionic_rx_empty(&lif->rxqcqs[i]->q);
                }
        }
@@ -1915,11 +1914,11 @@ static int ionic_get_vf_config(struct net_device *netdev,
                ret = -EINVAL;
        } else {
                ivf->vf           = vf;
-               ivf->vlan         = ionic->vfs[vf].vlanid;
+               ivf->vlan         = le16_to_cpu(ionic->vfs[vf].vlanid);
                ivf->qos          = 0;
                ivf->spoofchk     = ionic->vfs[vf].spoofchk;
                ivf->linkstate    = ionic->vfs[vf].linkstate;
-               ivf->max_tx_rate  = ionic->vfs[vf].maxrate;
+               ivf->max_tx_rate  = le32_to_cpu(ionic->vfs[vf].maxrate);
                ivf->trusted      = ionic->vfs[vf].trusted;
                ether_addr_copy(ivf->mac, ionic->vfs[vf].macaddr);
        }
@@ -2019,7 +2018,7 @@ static int ionic_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan,
                ret = ionic_set_vf_config(ionic, vf,
                                          IONIC_VF_ATTR_VLAN, (u8 *)&vlan);
                if (!ret)
-                       ionic->vfs[vf].vlanid = vlan;
+                       ionic->vfs[vf].vlanid = cpu_to_le16(vlan);
        }
 
        up_write(&ionic->vf_op_lock);
@@ -2048,7 +2047,7 @@ static int ionic_set_vf_rate(struct net_device *netdev, int vf,
                ret = ionic_set_vf_config(ionic, vf,
                                          IONIC_VF_ATTR_RATE, (u8 *)&tx_max);
                if (!ret)
-                       lif->ionic->vfs[vf].maxrate = tx_max;
+                       lif->ionic->vfs[vf].maxrate = cpu_to_le32(tx_max);
        }
 
        up_write(&ionic->vf_op_lock);
@@ -2981,14 +2980,14 @@ void ionic_lif_unregister(struct ionic_lif *lif)
 
 static void ionic_lif_queue_identify(struct ionic_lif *lif)
 {
+       union ionic_q_identity __iomem *q_ident;
        struct ionic *ionic = lif->ionic;
-       union ionic_q_identity *q_ident;
        struct ionic_dev *idev;
        int qtype;
        int err;
 
        idev = &lif->ionic->idev;
-       q_ident = (union ionic_q_identity *)&idev->dev_cmd_regs->data;
+       q_ident = (union ionic_q_identity __iomem *)&idev->dev_cmd_regs->data;
 
        for (qtype = 0; qtype < ARRAY_SIZE(ionic_qtype_versions); qtype++) {
                struct ionic_qtype_info *qti = &lif->qtype_info[qtype];
@@ -3011,14 +3010,14 @@ static void ionic_lif_queue_identify(struct ionic_lif *lif)
                                             ionic_qtype_versions[qtype]);
                err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
                if (!err) {
-                       qti->version   = q_ident->version;
-                       qti->supported = q_ident->supported;
-                       qti->features  = le64_to_cpu(q_ident->features);
-                       qti->desc_sz   = le16_to_cpu(q_ident->desc_sz);
-                       qti->comp_sz   = le16_to_cpu(q_ident->comp_sz);
-                       qti->sg_desc_sz   = le16_to_cpu(q_ident->sg_desc_sz);
-                       qti->max_sg_elems = le16_to_cpu(q_ident->max_sg_elems);
-                       qti->sg_desc_stride = le16_to_cpu(q_ident->sg_desc_stride);
+                       qti->version   = readb(&q_ident->version);
+                       qti->supported = readb(&q_ident->supported);
+                       qti->features  = readq(&q_ident->features);
+                       qti->desc_sz   = readw(&q_ident->desc_sz);
+                       qti->comp_sz   = readw(&q_ident->comp_sz);
+                       qti->sg_desc_sz   = readw(&q_ident->sg_desc_sz);
+                       qti->max_sg_elems = readw(&q_ident->max_sg_elems);
+                       qti->sg_desc_stride = readw(&q_ident->sg_desc_stride);
                }
                mutex_unlock(&ionic->dev_cmd_lock);
 
index ee0740881af31cd5512839a1a96cf420715d396f..d355676f6c160d685239d52565cf96075297eae2 100644 (file)
@@ -311,7 +311,7 @@ int ionic_adminq_post_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
 
 static void ionic_dev_cmd_clean(struct ionic *ionic)
 {
-       union ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs;
+       union __iomem ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs;
 
        iowrite32(0, &regs->doorbell);
        memset_io(&regs->cmd, 0, sizeof(regs->cmd));
@@ -333,7 +333,7 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds)
         */
        max_wait = jiffies + (max_seconds * HZ);
 try_again:
-       opcode = idev->dev_cmd_regs->cmd.cmd.opcode;
+       opcode = readb(&idev->dev_cmd_regs->cmd.cmd.opcode);
        start_time = jiffies;
        do {
                done = ionic_dev_cmd_done(idev);
index 3f543512616ee5eca55bafc36956a952bf12eef3..2a725834f792251d83b7ebb91208584cb84cc6b6 100644 (file)
@@ -49,7 +49,7 @@ extern const int ionic_num_stats_grps;
        (*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset)))
 
 #define IONIC_READ_STAT_LE64(base_ptr, desc_ptr) \
-       __le64_to_cpu(*((u64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset)))
+       __le64_to_cpu(*((__le64 *)(((u8 *)(base_ptr)) + (desc_ptr)->offset)))
 
 struct ionic_stat_desc {
        char name[ETH_GSTRING_LEN];
index 169ac4f54640dfd4c60e5c72c1ef017a74a80a9e..b3d2250c77d0492fc1ca67ba92c08b67b88e9a4a 100644 (file)
@@ -200,7 +200,7 @@ static void ionic_rx_clean(struct ionic_queue *q,
        if (likely(netdev->features & NETIF_F_RXCSUM)) {
                if (comp->csum_flags & IONIC_RXQ_COMP_CSUM_F_CALC) {
                        skb->ip_summed = CHECKSUM_COMPLETE;
-                       skb->csum = (__wsum)le16_to_cpu(comp->csum);
+                       skb->csum = (__force __wsum)le16_to_cpu(comp->csum);
                        stats->csum_complete++;
                }
        } else {
@@ -253,19 +253,6 @@ static bool ionic_rx_service(struct ionic_cq *cq, struct ionic_cq_info *cq_info)
        return true;
 }
 
-void ionic_rx_flush(struct ionic_cq *cq)
-{
-       struct ionic_dev *idev = &cq->lif->ionic->idev;
-       u32 work_done;
-
-       work_done = ionic_cq_service(cq, cq->num_descs,
-                                    ionic_rx_service, NULL, NULL);
-
-       if (work_done)
-               ionic_intr_credits(idev->intr_ctrl, cq->bound_intr->index,
-                                  work_done, IONIC_INTR_CRED_RESET_COALESCE);
-}
-
 static int ionic_rx_page_alloc(struct ionic_queue *q,
                               struct ionic_page_info *page_info)
 {
@@ -413,22 +400,20 @@ static void ionic_rx_fill_cb(void *arg)
 void ionic_rx_empty(struct ionic_queue *q)
 {
        struct ionic_desc_info *desc_info;
-       struct ionic_rxq_desc *desc;
-       unsigned int i;
-       u16 idx;
-
-       idx = q->tail_idx;
-       while (idx != q->head_idx) {
-               desc_info = &q->info[idx];
-               desc = desc_info->desc;
-               desc->addr = 0;
-               desc->len = 0;
+       struct ionic_page_info *page_info;
+       unsigned int i, j;
 
-               for (i = 0; i < desc_info->npages; i++)
-                       ionic_rx_page_free(q, &desc_info->pages[i]);
+       for (i = 0; i < q->num_descs; i++) {
+               desc_info = &q->info[i];
+               for (j = 0; j < IONIC_RX_MAX_SG_ELEMS + 1; j++) {
+                       page_info = &desc_info->pages[j];
+                       if (page_info->page)
+                               ionic_rx_page_free(q, page_info);
+               }
 
+               desc_info->npages = 0;
+               desc_info->cb = NULL;
                desc_info->cb_arg = NULL;
-               idx = (idx + 1) & (q->num_descs - 1);
        }
 }
 
@@ -812,6 +797,7 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
        skb_frag_t *frag;
        bool start, done;
        bool outer_csum;
+       dma_addr_t addr;
        bool has_vlan;
        u16 desc_len;
        u8 desc_nsge;
@@ -893,11 +879,10 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)
                        if (frag_left > 0) {
                                len = min(frag_left, left);
                                frag_left -= len;
-                               elem->addr =
-                                   cpu_to_le64(ionic_tx_map_frag(q, frag,
-                                                                 offset, len));
-                               if (dma_mapping_error(dev, elem->addr))
+                               addr = ionic_tx_map_frag(q, frag, offset, len);
+                               if (dma_mapping_error(dev, addr))
                                        goto err_out_abort;
+                               elem->addr = cpu_to_le64(addr);
                                elem->len = cpu_to_le16(len);
                                elem++;
                                desc_nsge++;
index a5883be0413f6da4e6bbef642f049521182e382c..7667b72232b8a32da7a33eb8e58383707544f61b 100644 (file)
@@ -4,7 +4,6 @@
 #ifndef _IONIC_TXRX_H_
 #define _IONIC_TXRX_H_
 
-void ionic_rx_flush(struct ionic_cq *cq);
 void ionic_tx_flush(struct ionic_cq *cq);
 
 void ionic_rx_fill(struct ionic_queue *q);
index 3b6ddc706e92eae265b15a45672367891b8edff9..7766d73823eb6ac814adde3db25e74c8d49b5d32 100644 (file)
@@ -4080,9 +4080,17 @@ err_out:
        return -EIO;
 }
 
-static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp, struct sk_buff *skb)
+static bool rtl_test_hw_pad_bug(struct rtl8169_private *tp)
 {
-       return skb->len < ETH_ZLEN && tp->mac_version == RTL_GIGA_MAC_VER_34;
+       switch (tp->mac_version) {
+       case RTL_GIGA_MAC_VER_34:
+       case RTL_GIGA_MAC_VER_60:
+       case RTL_GIGA_MAC_VER_61:
+       case RTL_GIGA_MAC_VER_63:
+               return true;
+       default:
+               return false;
+       }
 }
 
 static void rtl8169_tso_csum_v1(struct sk_buff *skb, u32 *opts)
@@ -4154,7 +4162,7 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
 
                opts[1] |= transport_offset << TCPHO_SHIFT;
        } else {
-               if (unlikely(rtl_test_hw_pad_bug(tp, skb)))
+               if (unlikely(skb->len < ETH_ZLEN && rtl_test_hw_pad_bug(tp)))
                        return !eth_skb_pad(skb);
        }
 
@@ -4573,7 +4581,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
        }
 
        rtl_irq_disable(tp);
-       napi_schedule_irqoff(&tp->napi);
+       napi_schedule(&tp->napi);
 out:
        rtl_ack_events(tp, status);
 
@@ -4746,7 +4754,7 @@ static int rtl_open(struct net_device *dev)
        rtl_request_firmware(tp);
 
        retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
-                            IRQF_NO_THREAD | IRQF_SHARED, dev->name, tp);
+                            IRQF_SHARED, dev->name, tp);
        if (retval < 0)
                goto err_release_fw_2;
 
index 9c4df4ede0111eae7e6b46518686c786097ce7b2..bd30505fbc57a6e31ddb431694cda784246acf9e 100644 (file)
@@ -1744,12 +1744,16 @@ static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req)
        config.flags = 0;
        config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON :
                                                HWTSTAMP_TX_OFF;
-       if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT)
+       switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) {
+       case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT:
                config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
-       else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL)
+               break;
+       case RAVB_RXTSTAMP_TYPE_ALL:
                config.rx_filter = HWTSTAMP_FILTER_ALL;
-       else
+               break;
+       default:
                config.rx_filter = HWTSTAMP_FILTER_NONE;
+       }
 
        return copy_to_user(req->ifr_data, &config, sizeof(config)) ?
                -EFAULT : 0;
index b6e5e3e36b63a182701189a6120923f28f39aad6..81ee0a071b4e96156c93b516c354d26a540e2cf6 100644 (file)
@@ -625,13 +625,6 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,
        if (ret)
                return ret;
 
-       if (plat->eee_usecs_rate > 0) {
-               u32 tx_lpi_usec;
-
-               tx_lpi_usec = (plat->eee_usecs_rate / 1000000) - 1;
-               writel(tx_lpi_usec, res.addr + GMAC_1US_TIC_COUNTER);
-       }
-
        ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
        if (ret < 0)
                return ret;
@@ -641,6 +634,13 @@ static int intel_eth_pci_probe(struct pci_dev *pdev,
        res.wol_irq = pci_irq_vector(pdev, 0);
        res.irq = pci_irq_vector(pdev, 0);
 
+       if (plat->eee_usecs_rate > 0) {
+               u32 tx_lpi_usec;
+
+               tx_lpi_usec = (plat->eee_usecs_rate / 1000000) - 1;
+               writel(tx_lpi_usec, res.addr + GMAC_1US_TIC_COUNTER);
+       }
+
        ret = stmmac_dvr_probe(&pdev->dev, plat, &res);
        if (ret) {
                pci_free_irq_vectors(pdev);
index 220626a8d499eb22376051d82fd752e02987c480..d833908b660a489d4b5e102f8e0db38a4ab4f61f 100644 (file)
@@ -4757,6 +4757,7 @@ static void stmmac_napi_add(struct net_device *dev)
 
                ch->priv_data = priv;
                ch->index = queue;
+               spin_lock_init(&ch->lock);
 
                if (queue < priv->plat->rx_queues_to_use) {
                        netif_napi_add(dev, &ch->rx_napi, stmmac_napi_poll_rx,
index 4d02c51356112f291ba22953b370b297960db08c..4619c3a950b01ef19f24e9283e80f5dc3d72b2d4 100644 (file)
@@ -728,7 +728,6 @@ int cpsw_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info)
                (1 << HWTSTAMP_TX_ON);
        info->rx_filters =
                (1 << HWTSTAMP_FILTER_NONE) |
-               (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
                (1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
        return 0;
 }
index 51cc29f39038b30321e24103d20e0628beb18c35..31c5e36ff7069f545f0ce9a4e05a72a3db64e428 100644 (file)
@@ -639,13 +639,10 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
                break;
        case HWTSTAMP_FILTER_ALL:
        case HWTSTAMP_FILTER_NTP_ALL:
-               return -ERANGE;
        case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
        case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
        case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
-               priv->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-               cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-               break;
+               return -ERANGE;
        case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
        case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
        case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
index 030a1a5afe05ad5b69abf31a15202df38506e72f..dc668ed280b9f46619e3b0abe282146dde599b65 100644 (file)
@@ -657,10 +657,6 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
 
        gtp = netdev_priv(dev);
 
-       err = gtp_encap_enable(gtp, data);
-       if (err < 0)
-               return err;
-
        if (!data[IFLA_GTP_PDP_HASHSIZE]) {
                hashsize = 1024;
        } else {
@@ -671,12 +667,16 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
 
        err = gtp_hashtable_new(gtp, hashsize);
        if (err < 0)
-               goto out_encap;
+               return err;
+
+       err = gtp_encap_enable(gtp, data);
+       if (err < 0)
+               goto out_hashtable;
 
        err = register_netdevice(dev);
        if (err < 0) {
                netdev_dbg(dev, "failed to register new netdev %d\n", err);
-               goto out_hashtable;
+               goto out_encap;
        }
 
        gn = net_generic(dev_net(dev), gtp_net_id);
@@ -687,11 +687,11 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
 
        return 0;
 
+out_encap:
+       gtp_encap_disable(gtp);
 out_hashtable:
        kfree(gtp->addr_hash);
        kfree(gtp->tid_hash);
-out_encap:
-       gtp_encap_disable(gtp);
        return err;
 }
 
index 43f5f5d93cb06220645435a553687567c980ff11..92642030e7356921e81b0ce133d0123aa9c15dcc 100644 (file)
@@ -397,15 +397,24 @@ void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
 
        /* assert(which < trans->tre_count); */
 
-       /* Set the page information for the buffer.  We also need to fill in
-        * the DMA address and length for the buffer (something dma_map_sg()
-        * normally does).
+       /* Commands are quite different from data transfer requests.
+        * Their payloads come from a pool whose memory is allocated
+        * using dma_alloc_coherent().  We therefore do *not* map them
+        * for DMA (unlike what we do for pages and skbs).
+        *
+        * When a transaction completes, the SGL is normally unmapped.
+        * A command transaction has direction DMA_NONE, which tells
+        * gsi_trans_complete() to skip the unmapping step.
+        *
+        * The only things we use directly in a command scatter/gather
+        * entry are the DMA address and length.  We still need the SG
+        * table flags to be maintained though, so assign a NULL page
+        * pointer for that purpose.
         */
        sg = &trans->sgl[which];
-
-       sg_set_buf(sg, buf, size);
+       sg_assign_page(sg, NULL);
        sg_dma_address(sg) = addr;
-       sg_dma_len(sg) = sg->length;
+       sg_dma_len(sg) = size;
 
        info = &trans->info[which];
        info->opcode = opcode;
index 1d18c10e8f82fcc0867d8114173f77e26a48f50c..34aa196b7465c6460d6268b6bce3864f4d45fee4 100644 (file)
@@ -2389,7 +2389,8 @@ static int sfp_probe(struct platform_device *pdev)
                        continue;
 
                sfp->gpio_irq[i] = gpiod_to_irq(sfp->gpio[i]);
-               if (!sfp->gpio_irq[i]) {
+               if (sfp->gpio_irq[i] < 0) {
+                       sfp->gpio_irq[i] = 0;
                        sfp->need_poll = true;
                        continue;
                }
index a322f51873d011dfd0272fcdc6e2253b38bf6c66..581ed51abb53293a49edac567d6e25a67e4fbaae 100644 (file)
@@ -1309,6 +1309,7 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x1bc7, 0x1101, 3)},    /* Telit ME910 dual modem */
        {QMI_FIXED_INTF(0x1bc7, 0x1200, 5)},    /* Telit LE920 */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1201, 2)}, /* Telit LE920, LE920A4 */
+       {QMI_QUIRK_SET_DTR(0x1bc7, 0x1230, 2)}, /* Telit LE910Cx */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1260, 2)}, /* Telit LE910Cx */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1261, 2)}, /* Telit LE910Cx */
        {QMI_QUIRK_SET_DTR(0x1bc7, 0x1900, 1)}, /* Telit LN940 series */
index 95ef4943d8bd4c2b464909effab150479aa54685..40ca71b29bb91a94ff5f7807454270eaf8e03c54 100644 (file)
@@ -2125,7 +2125,7 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 
        if (blk_queue_is_zoned(ns->queue)) {
                ret = nvme_revalidate_zones(ns);
-               if (ret)
+               if (ret && !nvme_first_scan(ns->disk))
                        return ret;
        }
 
@@ -4582,8 +4582,7 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 }
 EXPORT_SYMBOL_GPL(nvme_start_queues);
 
-
-void nvme_sync_queues(struct nvme_ctrl *ctrl)
+void nvme_sync_io_queues(struct nvme_ctrl *ctrl)
 {
        struct nvme_ns *ns;
 
@@ -4591,7 +4590,12 @@ void nvme_sync_queues(struct nvme_ctrl *ctrl)
        list_for_each_entry(ns, &ctrl->namespaces, list)
                blk_sync_queue(ns->queue);
        up_read(&ctrl->namespaces_rwsem);
+}
+EXPORT_SYMBOL_GPL(nvme_sync_io_queues);
 
+void nvme_sync_queues(struct nvme_ctrl *ctrl)
+{
+       nvme_sync_io_queues(ctrl);
        if (ctrl->admin_q)
                blk_sync_queue(ctrl->admin_q);
 }
index 3c002bdcace39ac4551eecc219d6edeaae4437fd..f4c246462658fa50ac08387257c93b63ef7a122f 100644 (file)
@@ -146,7 +146,8 @@ struct nvme_fc_rport {
 
 /* fc_ctrl flags values - specified as bit positions */
 #define ASSOC_ACTIVE           0
-#define FCCTRL_TERMIO          1
+#define ASSOC_FAILED           1
+#define FCCTRL_TERMIO          2
 
 struct nvme_fc_ctrl {
        spinlock_t              lock;
@@ -157,7 +158,6 @@ struct nvme_fc_ctrl {
        u32                     cnum;
 
        bool                    ioq_live;
-       atomic_t                err_work_active;
        u64                     association_id;
        struct nvmefc_ls_rcv_op *rcv_disconn;
 
@@ -167,7 +167,6 @@ struct nvme_fc_ctrl {
        struct blk_mq_tag_set   tag_set;
 
        struct delayed_work     connect_work;
-       struct work_struct      err_work;
 
        struct kref             ref;
        unsigned long           flags;
@@ -2414,24 +2413,97 @@ nvme_fc_nvme_ctrl_freed(struct nvme_ctrl *nctrl)
        nvme_fc_ctrl_put(ctrl);
 }
 
+/*
+ * This routine is used by the transport when it needs to find active
+ * io on a queue that is to be terminated. The transport uses
+ * blk_mq_tagset_busy_itr() to find the busy requests, which then invoke
+ * this routine to kill them on a 1 by 1 basis.
+ *
+ * As FC allocates FC exchange for each io, the transport must contact
+ * the LLDD to terminate the exchange, thus releasing the FC exchange.
+ * After terminating the exchange the LLDD will call the transport's
+ * normal io done path for the request, but it will have an aborted
+ * status. The done path will return the io request back to the block
+ * layer with an error status.
+ */
+static bool
+nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
+{
+       struct nvme_ctrl *nctrl = data;
+       struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
+       struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req);
+
+       __nvme_fc_abort_op(ctrl, op);
+       return true;
+}
+
+/*
+ * This routine runs through all outstanding commands on the association
+ * and aborts them.  This routine is typically be called by the
+ * delete_association routine. It is also called due to an error during
+ * reconnect. In that scenario, it is most likely a command that initializes
+ * the controller, including fabric Connect commands on io queues, that
+ * may have timed out or failed thus the io must be killed for the connect
+ * thread to see the error.
+ */
 static void
-nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
+__nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
 {
-       int active;
+       /*
+        * If io queues are present, stop them and terminate all outstanding
+        * ios on them. As FC allocates FC exchange for each io, the
+        * transport must contact the LLDD to terminate the exchange,
+        * thus releasing the FC exchange. We use blk_mq_tagset_busy_itr()
+        * to tell us what io's are busy and invoke a transport routine
+        * to kill them with the LLDD.  After terminating the exchange
+        * the LLDD will call the transport's normal io done path, but it
+        * will have an aborted status. The done path will return the
+        * io requests back to the block layer as part of normal completions
+        * (but with error status).
+        */
+       if (ctrl->ctrl.queue_count > 1) {
+               nvme_stop_queues(&ctrl->ctrl);
+               blk_mq_tagset_busy_iter(&ctrl->tag_set,
+                               nvme_fc_terminate_exchange, &ctrl->ctrl);
+               blk_mq_tagset_wait_completed_request(&ctrl->tag_set);
+               if (start_queues)
+                       nvme_start_queues(&ctrl->ctrl);
+       }
+
+       /*
+        * Other transports, which don't have link-level contexts bound
+        * to sqe's, would try to gracefully shutdown the controller by
+        * writing the registers for shutdown and polling (call
+        * nvme_shutdown_ctrl()). Given a bunch of i/o was potentially
+        * just aborted and we will wait on those contexts, and given
+        * there was no indication of how live the controlelr is on the
+        * link, don't send more io to create more contexts for the
+        * shutdown. Let the controller fail via keepalive failure if
+        * its still present.
+        */
 
        /*
-        * if an error (io timeout, etc) while (re)connecting,
-        * it's an error on creating the new association.
-        * Start the error recovery thread if it hasn't already
-        * been started. It is expected there could be multiple
-        * ios hitting this path before things are cleaned up.
+        * clean up the admin queue. Same thing as above.
+        */
+       blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
+       blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
+                               nvme_fc_terminate_exchange, &ctrl->ctrl);
+       blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set);
+}
+
+static void
+nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg)
+{
+       /*
+        * if an error (io timeout, etc) while (re)connecting, the remote
+        * port requested terminating of the association (disconnect_ls)
+        * or an error (timeout or abort) occurred on an io while creating
+        * the controller.  Abort any ios on the association and let the
+        * create_association error path resolve things.
         */
        if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) {
-               active = atomic_xchg(&ctrl->err_work_active, 1);
-               if (!active && !queue_work(nvme_fc_wq, &ctrl->err_work)) {
-                       atomic_set(&ctrl->err_work_active, 0);
-                       WARN_ON(1);
-               }
+               __nvme_fc_abort_outstanding_ios(ctrl, true);
+               set_bit(ASSOC_FAILED, &ctrl->flags);
                return;
        }
 
@@ -2745,30 +2817,6 @@ nvme_fc_complete_rq(struct request *rq)
        nvme_fc_ctrl_put(ctrl);
 }
 
-/*
- * This routine is used by the transport when it needs to find active
- * io on a queue that is to be terminated. The transport uses
- * blk_mq_tagset_busy_itr() to find the busy requests, which then invoke
- * this routine to kill them on a 1 by 1 basis.
- *
- * As FC allocates FC exchange for each io, the transport must contact
- * the LLDD to terminate the exchange, thus releasing the FC exchange.
- * After terminating the exchange the LLDD will call the transport's
- * normal io done path for the request, but it will have an aborted
- * status. The done path will return the io request back to the block
- * layer with an error status.
- */
-static bool
-nvme_fc_terminate_exchange(struct request *req, void *data, bool reserved)
-{
-       struct nvme_ctrl *nctrl = data;
-       struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
-       struct nvme_fc_fcp_op *op = blk_mq_rq_to_pdu(req);
-
-       __nvme_fc_abort_op(ctrl, op);
-       return true;
-}
-
 
 static const struct blk_mq_ops nvme_fc_mq_ops = {
        .queue_rq       = nvme_fc_queue_rq,
@@ -2988,6 +3036,8 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
                ctrl->cnum, ctrl->lport->localport.port_name,
                ctrl->rport->remoteport.port_name, ctrl->ctrl.opts->subsysnqn);
 
+       clear_bit(ASSOC_FAILED, &ctrl->flags);
+
        /*
         * Create the admin queue
         */
@@ -3016,7 +3066,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
         */
 
        ret = nvme_enable_ctrl(&ctrl->ctrl);
-       if (ret)
+       if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
                goto out_disconnect_admin_queue;
 
        ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments;
@@ -3026,7 +3076,7 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
        blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
 
        ret = nvme_init_identify(&ctrl->ctrl);
-       if (ret)
+       if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
                goto out_disconnect_admin_queue;
 
        /* sanity checks */
@@ -3071,9 +3121,9 @@ nvme_fc_create_association(struct nvme_fc_ctrl *ctrl)
                        ret = nvme_fc_create_io_queues(ctrl);
                else
                        ret = nvme_fc_recreate_io_queues(ctrl);
-               if (ret)
-                       goto out_term_aen_ops;
        }
+       if (ret || test_bit(ASSOC_FAILED, &ctrl->flags))
+               goto out_term_aen_ops;
 
        changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE);
 
@@ -3107,60 +3157,6 @@ out_free_queue:
 }
 
 
-/*
- * This routine runs through all outstanding commands on the association
- * and aborts them.  This routine is typically be called by the
- * delete_association routine. It is also called due to an error during
- * reconnect. In that scenario, it is most likely a command that initializes
- * the controller, including fabric Connect commands on io queues, that
- * may have timed out or failed thus the io must be killed for the connect
- * thread to see the error.
- */
-static void
-__nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl *ctrl, bool start_queues)
-{
-       /*
-        * If io queues are present, stop them and terminate all outstanding
-        * ios on them. As FC allocates FC exchange for each io, the
-        * transport must contact the LLDD to terminate the exchange,
-        * thus releasing the FC exchange. We use blk_mq_tagset_busy_itr()
-        * to tell us what io's are busy and invoke a transport routine
-        * to kill them with the LLDD.  After terminating the exchange
-        * the LLDD will call the transport's normal io done path, but it
-        * will have an aborted status. The done path will return the
-        * io requests back to the block layer as part of normal completions
-        * (but with error status).
-        */
-       if (ctrl->ctrl.queue_count > 1) {
-               nvme_stop_queues(&ctrl->ctrl);
-               blk_mq_tagset_busy_iter(&ctrl->tag_set,
-                               nvme_fc_terminate_exchange, &ctrl->ctrl);
-               blk_mq_tagset_wait_completed_request(&ctrl->tag_set);
-               if (start_queues)
-                       nvme_start_queues(&ctrl->ctrl);
-       }
-
-       /*
-        * Other transports, which don't have link-level contexts bound
-        * to sqe's, would try to gracefully shutdown the controller by
-        * writing the registers for shutdown and polling (call
-        * nvme_shutdown_ctrl()). Given a bunch of i/o was potentially
-        * just aborted and we will wait on those contexts, and given
-        * there was no indication of how live the controlelr is on the
-        * link, don't send more io to create more contexts for the
-        * shutdown. Let the controller fail via keepalive failure if
-        * its still present.
-        */
-
-       /*
-        * clean up the admin queue. Same thing as above.
-        */
-       blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
-       blk_mq_tagset_busy_iter(&ctrl->admin_tag_set,
-                               nvme_fc_terminate_exchange, &ctrl->ctrl);
-       blk_mq_tagset_wait_completed_request(&ctrl->admin_tag_set);
-}
-
 /*
  * This routine stops operation of the controller on the host side.
  * On the host os stack side: Admin and IO queues are stopped,
@@ -3237,7 +3233,6 @@ nvme_fc_delete_ctrl(struct nvme_ctrl *nctrl)
 {
        struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl);
 
-       cancel_work_sync(&ctrl->err_work);
        cancel_delayed_work_sync(&ctrl->connect_work);
        /*
         * kill the association on the link side.  this will block
@@ -3292,78 +3287,34 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
 }
 
 static void
-__nvme_fc_terminate_io(struct nvme_fc_ctrl *ctrl)
+nvme_fc_reset_ctrl_work(struct work_struct *work)
 {
-       /*
-        * if state is CONNECTING - the error occurred as part of a
-        * reconnect attempt. Abort any ios on the association and
-        * let the create_association error paths resolve things.
-        */
-       if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) {
-               __nvme_fc_abort_outstanding_ios(ctrl, true);
-               return;
-       }
-
-       /*
-        * For any other state, kill the association. As this routine
-        * is a common io abort routine for resetting and such, after
-        * the association is terminated, ensure that the state is set
-        * to CONNECTING.
-        */
+       struct nvme_fc_ctrl *ctrl =
+               container_of(work, struct nvme_fc_ctrl, ctrl.reset_work);
 
-       nvme_stop_keep_alive(&ctrl->ctrl);
+       nvme_stop_ctrl(&ctrl->ctrl);
 
        /* will block will waiting for io to terminate */
        nvme_fc_delete_association(ctrl);
 
-       if (ctrl->ctrl.state != NVME_CTRL_CONNECTING &&
-           !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
+       if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
                dev_err(ctrl->ctrl.device,
                        "NVME-FC{%d}: error_recovery: Couldn't change state "
                        "to CONNECTING\n", ctrl->cnum);
-}
-
-static void
-nvme_fc_reset_ctrl_work(struct work_struct *work)
-{
-       struct nvme_fc_ctrl *ctrl =
-               container_of(work, struct nvme_fc_ctrl, ctrl.reset_work);
-       int ret;
 
-       __nvme_fc_terminate_io(ctrl);
-
-       nvme_stop_ctrl(&ctrl->ctrl);
-
-       if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE)
-               ret = nvme_fc_create_association(ctrl);
-       else
-               ret = -ENOTCONN;
-
-       if (ret)
-               nvme_fc_reconnect_or_delete(ctrl, ret);
-       else
-               dev_info(ctrl->ctrl.device,
-                       "NVME-FC{%d}: controller reset complete\n",
-                       ctrl->cnum);
+       if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE) {
+               if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) {
+                       dev_err(ctrl->ctrl.device,
+                               "NVME-FC{%d}: failed to schedule connect "
+                               "after reset\n", ctrl->cnum);
+               } else {
+                       flush_delayed_work(&ctrl->connect_work);
+               }
+       } else {
+               nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN);
+       }
 }
 
-static void
-nvme_fc_connect_err_work(struct work_struct *work)
-{
-       struct nvme_fc_ctrl *ctrl =
-                       container_of(work, struct nvme_fc_ctrl, err_work);
-
-       __nvme_fc_terminate_io(ctrl);
-
-       atomic_set(&ctrl->err_work_active, 0);
-
-       /*
-        * Rescheduling the connection after recovering
-        * from the io error is left to the reconnect work
-        * item, which is what should have stalled waiting on
-        * the io that had the error that scheduled this work.
-        */
-}
 
 static const struct nvme_ctrl_ops nvme_fc_ctrl_ops = {
        .name                   = "fc",
@@ -3491,7 +3442,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
        ctrl->dev = lport->dev;
        ctrl->cnum = idx;
        ctrl->ioq_live = false;
-       atomic_set(&ctrl->err_work_active, 0);
        init_waitqueue_head(&ctrl->ioabort_wait);
 
        get_device(ctrl->dev);
@@ -3499,7 +3449,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 
        INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work);
        INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work);
-       INIT_WORK(&ctrl->err_work, nvme_fc_connect_err_work);
        spin_lock_init(&ctrl->lock);
 
        /* io queue count */
@@ -3592,7 +3541,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
 fail_ctrl:
        nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING);
        cancel_work_sync(&ctrl->ctrl.reset_work);
-       cancel_work_sync(&ctrl->err_work);
        cancel_delayed_work_sync(&ctrl->connect_work);
 
        ctrl->ctrl.opts = NULL;
index cc111136a9818813ba22d7bce5c1d75b6055851a..bc330bf0d3bdeabad32a94abee523abfdd0480cf 100644 (file)
@@ -602,6 +602,7 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl);
 void nvme_start_queues(struct nvme_ctrl *ctrl);
 void nvme_kill_queues(struct nvme_ctrl *ctrl);
 void nvme_sync_queues(struct nvme_ctrl *ctrl);
+void nvme_sync_io_queues(struct nvme_ctrl *ctrl);
 void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
 int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
index df8f3612107f1d0ffbe6671f971af3d615fa6bdc..0578ff253c4775a54c02297b7c99f0c588c7cd6c 100644 (file)
@@ -198,6 +198,7 @@ struct nvme_queue {
        u32 q_depth;
        u16 cq_vector;
        u16 sq_tail;
+       u16 last_sq_tail;
        u16 cq_head;
        u16 qid;
        u8 cq_phase;
@@ -455,11 +456,24 @@ static int nvme_pci_map_queues(struct blk_mq_tag_set *set)
        return 0;
 }
 
-static inline void nvme_write_sq_db(struct nvme_queue *nvmeq)
+/*
+ * Write sq tail if we are asked to, or if the next command would wrap.
+ */
+static inline void nvme_write_sq_db(struct nvme_queue *nvmeq, bool write_sq)
 {
+       if (!write_sq) {
+               u16 next_tail = nvmeq->sq_tail + 1;
+
+               if (next_tail == nvmeq->q_depth)
+                       next_tail = 0;
+               if (next_tail != nvmeq->last_sq_tail)
+                       return;
+       }
+
        if (nvme_dbbuf_update_and_check_event(nvmeq->sq_tail,
                        nvmeq->dbbuf_sq_db, nvmeq->dbbuf_sq_ei))
                writel(nvmeq->sq_tail, nvmeq->q_db);
+       nvmeq->last_sq_tail = nvmeq->sq_tail;
 }
 
 /**
@@ -476,8 +490,7 @@ static void nvme_submit_cmd(struct nvme_queue *nvmeq, struct nvme_command *cmd,
               cmd, sizeof(*cmd));
        if (++nvmeq->sq_tail == nvmeq->q_depth)
                nvmeq->sq_tail = 0;
-       if (write_sq)
-               nvme_write_sq_db(nvmeq);
+       nvme_write_sq_db(nvmeq, write_sq);
        spin_unlock(&nvmeq->sq_lock);
 }
 
@@ -486,7 +499,8 @@ static void nvme_commit_rqs(struct blk_mq_hw_ctx *hctx)
        struct nvme_queue *nvmeq = hctx->driver_data;
 
        spin_lock(&nvmeq->sq_lock);
-       nvme_write_sq_db(nvmeq);
+       if (nvmeq->sq_tail != nvmeq->last_sq_tail)
+               nvme_write_sq_db(nvmeq, true);
        spin_unlock(&nvmeq->sq_lock);
 }
 
@@ -1496,6 +1510,7 @@ static void nvme_init_queue(struct nvme_queue *nvmeq, u16 qid)
        struct nvme_dev *dev = nvmeq->dev;
 
        nvmeq->sq_tail = 0;
+       nvmeq->last_sq_tail = 0;
        nvmeq->cq_head = 0;
        nvmeq->cq_phase = 1;
        nvmeq->q_db = &dev->dbs[qid * 2 * dev->db_stride];
index aad829a2b50d0f9348bd819f75dd35bc53bc1a51..65e3d0ef36e1a33dffad84405aaa07d819385380 100644 (file)
@@ -122,7 +122,6 @@ struct nvme_rdma_ctrl {
        struct sockaddr_storage src_addr;
 
        struct nvme_ctrl        ctrl;
-       struct mutex            teardown_lock;
        bool                    use_inline_data;
        u32                     io_queues[HCTX_MAX_TYPES];
 };
@@ -1010,8 +1009,8 @@ out_free_io_queues:
 static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl,
                bool remove)
 {
-       mutex_lock(&ctrl->teardown_lock);
        blk_mq_quiesce_queue(ctrl->ctrl.admin_q);
+       blk_sync_queue(ctrl->ctrl.admin_q);
        nvme_rdma_stop_queue(&ctrl->queues[0]);
        if (ctrl->ctrl.admin_tagset) {
                blk_mq_tagset_busy_iter(ctrl->ctrl.admin_tagset,
@@ -1021,16 +1020,15 @@ static void nvme_rdma_teardown_admin_queue(struct nvme_rdma_ctrl *ctrl,
        if (remove)
                blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
        nvme_rdma_destroy_admin_queue(ctrl, remove);
-       mutex_unlock(&ctrl->teardown_lock);
 }
 
 static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
                bool remove)
 {
-       mutex_lock(&ctrl->teardown_lock);
        if (ctrl->ctrl.queue_count > 1) {
                nvme_start_freeze(&ctrl->ctrl);
                nvme_stop_queues(&ctrl->ctrl);
+               nvme_sync_io_queues(&ctrl->ctrl);
                nvme_rdma_stop_io_queues(ctrl);
                if (ctrl->ctrl.tagset) {
                        blk_mq_tagset_busy_iter(ctrl->ctrl.tagset,
@@ -1041,7 +1039,6 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
                        nvme_start_queues(&ctrl->ctrl);
                nvme_rdma_destroy_io_queues(ctrl, remove);
        }
-       mutex_unlock(&ctrl->teardown_lock);
 }
 
 static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl)
@@ -1768,6 +1765,14 @@ static void nvme_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc)
                return;
        }
 
+       /* sanity checking for received data length */
+       if (unlikely(wc->byte_len < len)) {
+               dev_err(queue->ctrl->ctrl.device,
+                       "Unexpected nvme completion length(%d)\n", wc->byte_len);
+               nvme_rdma_error_recovery(queue->ctrl);
+               return;
+       }
+
        ib_dma_sync_single_for_cpu(ibdev, qe->dma, len, DMA_FROM_DEVICE);
        /*
         * AEN requests are special as they don't time out and can
@@ -1890,10 +1895,10 @@ static int nvme_rdma_route_resolved(struct nvme_rdma_queue *queue)
                priv.hsqsize = cpu_to_le16(queue->ctrl->ctrl.sqsize);
        }
 
-       ret = rdma_connect(queue->cm_id, &param);
+       ret = rdma_connect_locked(queue->cm_id, &param);
        if (ret) {
                dev_err(ctrl->ctrl.device,
-                       "rdma_connect failed (%d).\n", ret);
+                       "rdma_connect_locked failed (%d).\n", ret);
                goto out_destroy_queue_ib;
        }
 
@@ -1968,16 +1973,12 @@ static void nvme_rdma_complete_timed_out(struct request *rq)
 {
        struct nvme_rdma_request *req = blk_mq_rq_to_pdu(rq);
        struct nvme_rdma_queue *queue = req->queue;
-       struct nvme_rdma_ctrl *ctrl = queue->ctrl;
 
-       /* fence other contexts that may complete the command */
-       mutex_lock(&ctrl->teardown_lock);
        nvme_rdma_stop_queue(queue);
-       if (!blk_mq_request_completed(rq)) {
+       if (blk_mq_request_started(rq) && !blk_mq_request_completed(rq)) {
                nvme_req(rq)->status = NVME_SC_HOST_ABORTED_CMD;
                blk_mq_complete_request(rq);
        }
-       mutex_unlock(&ctrl->teardown_lock);
 }
 
 static enum blk_eh_timer_return
@@ -2312,7 +2313,6 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev,
                return ERR_PTR(-ENOMEM);
        ctrl->ctrl.opts = opts;
        INIT_LIST_HEAD(&ctrl->list);
-       mutex_init(&ctrl->teardown_lock);
 
        if (!(opts->mask & NVMF_OPT_TRSVCID)) {
                opts->trsvcid =
index d6a3e148735428cac13e39e0ea7366ed38df84cf..c0c33320fe659ffad05362a3fd146ff539fa58ea 100644 (file)
@@ -124,7 +124,6 @@ struct nvme_tcp_ctrl {
        struct sockaddr_storage src_addr;
        struct nvme_ctrl        ctrl;
 
-       struct mutex            teardown_lock;
        struct work_struct      err_work;
        struct delayed_work     connect_work;
        struct nvme_tcp_request async_req;
@@ -1886,8 +1885,8 @@ out_free_queue:
 static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl,
                bool remove)
 {
-       mutex_lock(&to_tcp_ctrl(ctrl)->teardown_lock);
        blk_mq_quiesce_queue(ctrl->admin_q);
+       blk_sync_queue(ctrl->admin_q);
        nvme_tcp_stop_queue(ctrl, 0);
        if (ctrl->admin_tagset) {
                blk_mq_tagset_busy_iter(ctrl->admin_tagset,
@@ -1897,18 +1896,17 @@ static void nvme_tcp_teardown_admin_queue(struct nvme_ctrl *ctrl,
        if (remove)
                blk_mq_unquiesce_queue(ctrl->admin_q);
        nvme_tcp_destroy_admin_queue(ctrl, remove);
-       mutex_unlock(&to_tcp_ctrl(ctrl)->teardown_lock);
 }
 
 static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
                bool remove)
 {
-       mutex_lock(&to_tcp_ctrl(ctrl)->teardown_lock);
        if (ctrl->queue_count <= 1)
-               goto out;
+               return;
        blk_mq_quiesce_queue(ctrl->admin_q);
        nvme_start_freeze(ctrl);
        nvme_stop_queues(ctrl);
+       nvme_sync_io_queues(ctrl);
        nvme_tcp_stop_io_queues(ctrl);
        if (ctrl->tagset) {
                blk_mq_tagset_busy_iter(ctrl->tagset,
@@ -1918,8 +1916,6 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
        if (remove)
                nvme_start_queues(ctrl);
        nvme_tcp_destroy_io_queues(ctrl, remove);
-out:
-       mutex_unlock(&to_tcp_ctrl(ctrl)->teardown_lock);
 }
 
 static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl)
@@ -2171,14 +2167,11 @@ static void nvme_tcp_complete_timed_out(struct request *rq)
        struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
        struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl;
 
-       /* fence other contexts that may complete the command */
-       mutex_lock(&to_tcp_ctrl(ctrl)->teardown_lock);
        nvme_tcp_stop_queue(ctrl, nvme_tcp_queue_id(req->queue));
-       if (!blk_mq_request_completed(rq)) {
+       if (blk_mq_request_started(rq) && !blk_mq_request_completed(rq)) {
                nvme_req(rq)->status = NVME_SC_HOST_ABORTED_CMD;
                blk_mq_complete_request(rq);
        }
-       mutex_unlock(&to_tcp_ctrl(ctrl)->teardown_lock);
 }
 
 static enum blk_eh_timer_return
@@ -2455,7 +2448,6 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,
                        nvme_tcp_reconnect_ctrl_work);
        INIT_WORK(&ctrl->err_work, nvme_tcp_error_recovery_work);
        INIT_WORK(&ctrl->ctrl.reset_work, nvme_reset_ctrl_work);
-       mutex_init(&ctrl->teardown_lock);
 
        if (!(opts->mask & NVMF_OPT_TRSVCID)) {
                opts->trsvcid =
index aafcbc424b7a94e839a5c1f6d308e64686919637..957b39a82431b718f60875709c37827777dcf7d6 100644 (file)
@@ -907,8 +907,6 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
        req->error_loc = NVMET_NO_ERROR_LOC;
        req->error_slba = 0;
 
-       trace_nvmet_req_init(req, req->cmd);
-
        /* no support for fused commands yet */
        if (unlikely(flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND))) {
                req->error_loc = offsetof(struct nvme_common_command, flags);
@@ -938,6 +936,8 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq,
        if (status)
                goto fail;
 
+       trace_nvmet_req_init(req, req->cmd);
+
        if (unlikely(!percpu_ref_tryget_live(&sq->ref))) {
                status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
                goto fail;
index 0458046d650178b7a620a20b678ceeb1ba2a0292..c14e3249a14dc884c7ed4e571f7f4c1ab6199b36 100644 (file)
@@ -46,19 +46,12 @@ static inline struct nvmet_ctrl *nvmet_req_to_ctrl(struct nvmet_req *req)
        return req->sq->ctrl;
 }
 
-static inline void __assign_disk_name(char *name, struct nvmet_req *req,
-               bool init)
+static inline void __assign_req_name(char *name, struct nvmet_req *req)
 {
-       struct nvmet_ctrl *ctrl = nvmet_req_to_ctrl(req);
-       struct nvmet_ns *ns;
-
-       if ((init && req->sq->qid) || (!init && req->cq->qid)) {
-               ns = nvmet_find_namespace(ctrl, req->cmd->rw.nsid);
-               strncpy(name, ns->device_path, DISK_NAME_LEN);
-               return;
-       }
-
-       memset(name, 0, DISK_NAME_LEN);
+       if (req->ns)
+               strncpy(name, req->ns->device_path, DISK_NAME_LEN);
+       else
+               memset(name, 0, DISK_NAME_LEN);
 }
 #endif
 
@@ -81,7 +74,7 @@ TRACE_EVENT(nvmet_req_init,
        TP_fast_assign(
                __entry->cmd = cmd;
                __entry->ctrl = nvmet_req_to_ctrl(req);
-               __assign_disk_name(__entry->disk, req, true);
+               __assign_req_name(__entry->disk, req);
                __entry->qid = req->sq->qid;
                __entry->cid = cmd->common.command_id;
                __entry->opcode = cmd->common.opcode;
@@ -121,7 +114,7 @@ TRACE_EVENT(nvmet_req_complete,
                __entry->cid = req->cqe->command_id;
                __entry->result = le64_to_cpu(req->cqe->result.u64);
                __entry->status = le16_to_cpu(req->cqe->status) >> 1;
-               __assign_disk_name(__entry->disk, req, false);
+               __assign_req_name(__entry->disk, req);
        ),
        TP_printk("nvmet%s: %sqid=%d, cmdid=%u, res=%#llx, status=%#x",
                __print_ctrl_name(__entry->ctrl),
index eb9ab4f1e80b00c124e916ded75dfa597897ce75..09c0af7fd1c4480d6bd9f17bb4051bd49b514d0e 100644 (file)
@@ -1024,6 +1024,48 @@ out:
 }
 #endif /* CONFIG_HAS_DMA */
 
+/**
+ * of_dma_get_max_cpu_address - Gets highest CPU address suitable for DMA
+ * @np: The node to start searching from or NULL to start from the root
+ *
+ * Gets the highest CPU physical address that is addressable by all DMA masters
+ * in the sub-tree pointed by np, or the whole tree if NULL is passed. If no
+ * DMA constrained device is found, it returns PHYS_ADDR_MAX.
+ */
+phys_addr_t __init of_dma_get_max_cpu_address(struct device_node *np)
+{
+       phys_addr_t max_cpu_addr = PHYS_ADDR_MAX;
+       struct of_range_parser parser;
+       phys_addr_t subtree_max_addr;
+       struct device_node *child;
+       struct of_range range;
+       const __be32 *ranges;
+       u64 cpu_end = 0;
+       int len;
+
+       if (!np)
+               np = of_root;
+
+       ranges = of_get_property(np, "dma-ranges", &len);
+       if (ranges && len) {
+               of_dma_range_parser_init(&parser, np);
+               for_each_of_range(&parser, &range)
+                       if (range.cpu_addr + range.size > cpu_end)
+                               cpu_end = range.cpu_addr + range.size - 1;
+
+               if (max_cpu_addr > cpu_end)
+                       max_cpu_addr = cpu_end;
+       }
+
+       for_each_available_child_of_node(np, child) {
+               subtree_max_addr = of_dma_get_max_cpu_address(child);
+               if (max_cpu_addr > subtree_max_addr)
+                       max_cpu_addr = subtree_max_addr;
+       }
+
+       return max_cpu_addr;
+}
+
 /**
  * of_dma_is_coherent - Check if device is coherent
  * @np:        device node
index 655dee422563f05f14b946c32c3935d2e835e9e7..aedfaaafd3e7edb73a4468cba26cf2c177ea1164 100644 (file)
@@ -93,7 +93,7 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
 {
        const struct iommu_ops *iommu;
        const struct bus_dma_region *map = NULL;
-       dma_addr_t dma_start = 0;
+       u64 dma_start = 0;
        u64 mask, end, size = 0;
        bool coherent;
        int ret;
@@ -109,10 +109,10 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
                        return ret == -ENODEV ? 0 : ret;
        } else {
                const struct bus_dma_region *r = map;
-               dma_addr_t dma_end = 0;
+               u64 dma_end = 0;
 
                /* Determine the overall bounds of all DMA regions */
-               for (dma_start = ~(dma_addr_t)0; r->size; r++) {
+               for (dma_start = ~0; r->size; r++) {
                        /* Take lower and upper limits */
                        if (r->dma_start < dma_start)
                                dma_start = r->dma_start;
index bcd15448597244a4d44db9b413608f8a3b98da8a..a7fbc5e37e19ef67457425fc9381862aa66895c5 100644 (file)
@@ -200,6 +200,16 @@ static int __init __rmem_cmp(const void *a, const void *b)
        if (ra->base > rb->base)
                return 1;
 
+       /*
+        * Put the dynamic allocations (address == 0, size == 0) before static
+        * allocations at address 0x0 so that overlap detection works
+        * correctly.
+        */
+       if (ra->size < rb->size)
+               return -1;
+       if (ra->size > rb->size)
+               return 1;
+
        return 0;
 }
 
@@ -217,8 +227,7 @@ static void __init __rmem_check_for_overlap(void)
 
                this = &reserved_mem[i];
                next = &reserved_mem[i + 1];
-               if (!(this->base && next->base))
-                       continue;
+
                if (this->base + this->size > next->base) {
                        phys_addr_t this_end, next_end;
 
index 06cc988faf78b34dddf596faa3bbe5dac9622af2..eb51bc147440172ceb00ba4239e72f0c1bc358a8 100644 (file)
@@ -869,6 +869,26 @@ static void __init of_unittest_changeset(void)
 #endif
 }
 
+static void __init of_unittest_dma_get_max_cpu_address(void)
+{
+       struct device_node *np;
+       phys_addr_t cpu_addr;
+
+       if (!IS_ENABLED(CONFIG_OF_ADDRESS))
+               return;
+
+       np = of_find_node_by_path("/testcase-data/address-tests");
+       if (!np) {
+               pr_err("missing testcase data\n");
+               return;
+       }
+
+       cpu_addr = of_dma_get_max_cpu_address(np);
+       unittest(cpu_addr == 0x4fffffff,
+                "of_dma_get_max_cpu_address: wrong CPU addr %pad (expecting %x)\n",
+                &cpu_addr, 0x4fffffff);
+}
+
 static void __init of_unittest_dma_ranges_one(const char *path,
                u64 expect_dma_addr, u64 expect_paddr)
 {
@@ -3266,6 +3286,7 @@ static int __init of_unittest(void)
        of_unittest_changeset();
        of_unittest_parse_interrupts();
        of_unittest_parse_interrupts_extended();
+       of_unittest_dma_get_max_cpu_address();
        of_unittest_parse_dma_ranges();
        of_unittest_pci_dma_ranges();
        of_unittest_match_node();
index 2483e765318a3c01c3d4466a45322698f6f293d0..0e0a5269dc82f8314e936bcc71d457e51d24fb48 100644 (file)
@@ -1181,6 +1181,10 @@ static void _opp_table_kref_release(struct kref *kref)
        struct opp_device *opp_dev, *temp;
        int i;
 
+       /* Drop the lock as soon as we can */
+       list_del(&opp_table->node);
+       mutex_unlock(&opp_table_lock);
+
        _of_clear_opp_table(opp_table);
 
        /* Release clk */
@@ -1208,10 +1212,7 @@ static void _opp_table_kref_release(struct kref *kref)
 
        mutex_destroy(&opp_table->genpd_virt_dev_lock);
        mutex_destroy(&opp_table->lock);
-       list_del(&opp_table->node);
        kfree(opp_table);
-
-       mutex_unlock(&opp_table_lock);
 }
 
 void dev_pm_opp_put_opp_table(struct opp_table *opp_table)
@@ -1930,7 +1931,7 @@ struct opp_table *dev_pm_opp_register_set_opp_helper(struct device *dev,
                return ERR_PTR(-EINVAL);
 
        opp_table = dev_pm_opp_get_opp_table(dev);
-       if (!IS_ERR(opp_table))
+       if (IS_ERR(opp_table))
                return opp_table;
 
        /* This should be called before OPPs are initialized */
index 874b587562202219babd72ce0e7c9236a7c9ee75..9faeb83e4b326217e538d570f29e7e333d5888d5 100644 (file)
@@ -944,6 +944,8 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
                nr -= 2;
        }
 
+       return 0;
+
 remove_static_opp:
        _opp_remove_all_static(opp_table);
 
index 674f32db85ca4ccf5935eb4b3ba59ecdbd7401a7..44c2a6572199c341d9108e2b9243035215722ae7 100644 (file)
@@ -586,8 +586,12 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
         * ATU, so we should not program the ATU here.
         */
        if (pp->bridge->child_ops == &dw_child_pcie_ops) {
-               struct resource_entry *entry =
-                       resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
+               struct resource_entry *tmp, *entry = NULL;
+
+               /* Get last memory resource entry */
+               resource_list_for_each_entry(tmp, &pp->bridge->windows)
+                       if (resource_type(tmp->res) == IORESOURCE_MEM)
+                               entry = tmp;
 
                dw_pcie_prog_outbound_atu(pci, PCIE_ATU_REGION_INDEX0,
                                          PCIE_ATU_TYPE_MEM, entry->res->start,
index eee82838f4bace3309541ae14d1b516b9000bf70..ed13e81cd691d461708f2d7b798037fee15f8449 100644 (file)
@@ -958,25 +958,16 @@ static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
 }
 
 /*
- * We can't use devm_of_pci_get_host_bridge_resources() because we
- * need to parse our special DT properties encoding the MEM and IO
- * apertures.
+ * devm_of_pci_get_host_bridge_resources() only sets up translateable resources,
+ * so we need extra resource setup parsing our special DT properties encoding
+ * the MEM and IO apertures.
  */
 static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
 {
        struct device *dev = &pcie->pdev->dev;
-       struct device_node *np = dev->of_node;
        struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
        int ret;
 
-       /* Get the bus range */
-       ret = of_pci_parse_bus_range(np, &pcie->busn);
-       if (ret) {
-               dev_err(dev, "failed to parse bus-range property: %d\n", ret);
-               return ret;
-       }
-       pci_add_resource(&bridge->windows, &pcie->busn);
-
        /* Get the PCIe memory aperture */
        mvebu_mbus_get_pcie_mem_aperture(&pcie->mem);
        if (resource_size(&pcie->mem) == 0) {
@@ -986,6 +977,9 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
 
        pcie->mem.name = "PCI MEM";
        pci_add_resource(&bridge->windows, &pcie->mem);
+       ret = devm_request_resource(dev, &iomem_resource, &pcie->mem);
+       if (ret)
+               return ret;
 
        /* Get the PCIe IO aperture */
        mvebu_mbus_get_pcie_io_aperture(&pcie->io);
@@ -999,9 +993,12 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
                pcie->realio.name = "PCI I/O";
 
                pci_add_resource(&bridge->windows, &pcie->realio);
+               ret = devm_request_resource(dev, &ioport_resource, &pcie->realio);
+               if (ret)
+                       return ret;
        }
 
-       return devm_request_pci_bus_resources(dev, &bridge->windows);
+       return 0;
 }
 
 /*
index 6d4d5a2f923d9ef291eb7f09d5af3b452fe487df..e578d34095e91a1dea6731314d364bf981e1c697 100644 (file)
@@ -3516,8 +3516,13 @@ void pci_acs_init(struct pci_dev *dev)
 {
        dev->acs_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS);
 
-       if (dev->acs_cap)
-               pci_enable_acs(dev);
+       /*
+        * Attempt to enable ACS regardless of capability because some Root
+        * Ports (e.g. those quirked with *_intel_pch_acs_*) do not have
+        * the standard ACS capability but still support ACS via those
+        * quirks.
+        */
+       pci_enable_acs(dev);
 }
 
 /**
index 130327ff0b0ec8e6f4cc3a478d3b0ddfd6ee7c1c..3075cf171f7850a5a29f1cd9fa27bb62b2f47689 100644 (file)
@@ -130,6 +130,13 @@ config ARM_SPE_PMU
          Extension, which provides periodic sampling of operations in
          the CPU pipeline and reports this via the perf AUX interface.
 
+config ARM_DMC620_PMU
+       tristate "Enable PMU support for the ARM DMC-620 memory controller"
+       depends on (ARM64 && ACPI) || COMPILE_TEST
+       help
+         Support for PMU events monitoring on the ARM DMC-620 memory
+         controller.
+
 source "drivers/perf/hisilicon/Kconfig"
 
 endmenu
index 5365fd56f88f35096a60deade85b7cbe4e0292ad..5260b116c7dad05fbd2954df80e587522e8dd63f 100644 (file)
@@ -13,3 +13,4 @@ obj-$(CONFIG_QCOM_L3_PMU) += qcom_l3_pmu.o
 obj-$(CONFIG_THUNDERX2_PMU) += thunderx2_pmu.o
 obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o
 obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o
+obj-$(CONFIG_ARM_DMC620_PMU) += arm_dmc620_pmu.o
diff --git a/drivers/perf/arm_dmc620_pmu.c b/drivers/perf/arm_dmc620_pmu.c
new file mode 100644 (file)
index 0000000..004930e
--- /dev/null
@@ -0,0 +1,748 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * ARM DMC-620 memory controller PMU driver
+ *
+ * Copyright (C) 2020 Ampere Computing LLC.
+ */
+
+#define DMC620_PMUNAME         "arm_dmc620"
+#define DMC620_DRVNAME         DMC620_PMUNAME "_pmu"
+#define pr_fmt(fmt)            DMC620_DRVNAME ": " fmt
+
+#include <linux/acpi.h>
+#include <linux/bitfield.h>
+#include <linux/bitops.h>
+#include <linux/cpuhotplug.h>
+#include <linux/cpumask.h>
+#include <linux/device.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/perf_event.h>
+#include <linux/platform_device.h>
+#include <linux/printk.h>
+#include <linux/rculist.h>
+#include <linux/refcount.h>
+
+#define DMC620_PA_SHIFT                                        12
+#define DMC620_CNT_INIT                                        0x80000000
+#define DMC620_CNT_MAX_PERIOD                          0xffffffff
+#define DMC620_PMU_CLKDIV2_MAX_COUNTERS                        8
+#define DMC620_PMU_CLK_MAX_COUNTERS                    2
+#define DMC620_PMU_MAX_COUNTERS                                \
+       (DMC620_PMU_CLKDIV2_MAX_COUNTERS + DMC620_PMU_CLK_MAX_COUNTERS)
+
+/*
+ * The PMU registers start at 0xA00 in the DMC-620 memory map, and these
+ * offsets are relative to that base.
+ *
+ * Each counter has a group of control/value registers, and the
+ * DMC620_PMU_COUNTERn offsets are within a counter group.
+ *
+ * The counter registers groups start at 0xA10.
+ */
+#define DMC620_PMU_OVERFLOW_STATUS_CLKDIV2             0x8
+#define  DMC620_PMU_OVERFLOW_STATUS_CLKDIV2_MASK       \
+               (DMC620_PMU_CLKDIV2_MAX_COUNTERS - 1)
+#define DMC620_PMU_OVERFLOW_STATUS_CLK                 0xC
+#define  DMC620_PMU_OVERFLOW_STATUS_CLK_MASK           \
+               (DMC620_PMU_CLK_MAX_COUNTERS - 1)
+#define DMC620_PMU_COUNTERS_BASE                       0x10
+#define DMC620_PMU_COUNTERn_MASK_31_00                 0x0
+#define DMC620_PMU_COUNTERn_MASK_63_32                 0x4
+#define DMC620_PMU_COUNTERn_MATCH_31_00                        0x8
+#define DMC620_PMU_COUNTERn_MATCH_63_32                        0xC
+#define DMC620_PMU_COUNTERn_CONTROL                    0x10
+#define  DMC620_PMU_COUNTERn_CONTROL_ENABLE            BIT(0)
+#define  DMC620_PMU_COUNTERn_CONTROL_INVERT            BIT(1)
+#define  DMC620_PMU_COUNTERn_CONTROL_EVENT_MUX         GENMASK(6, 2)
+#define  DMC620_PMU_COUNTERn_CONTROL_INCR_MUX          GENMASK(8, 7)
+#define DMC620_PMU_COUNTERn_VALUE                      0x20
+/* Offset of the registers for a given counter, relative to 0xA00 */
+#define DMC620_PMU_COUNTERn_OFFSET(n) \
+       (DMC620_PMU_COUNTERS_BASE + 0x28 * (n))
+
+static LIST_HEAD(dmc620_pmu_irqs);
+static DEFINE_MUTEX(dmc620_pmu_irqs_lock);
+
+struct dmc620_pmu_irq {
+       struct hlist_node node;
+       struct list_head pmus_node;
+       struct list_head irqs_node;
+       refcount_t refcount;
+       unsigned int irq_num;
+       unsigned int cpu;
+};
+
+struct dmc620_pmu {
+       struct pmu pmu;
+
+       void __iomem *base;
+       struct dmc620_pmu_irq *irq;
+       struct list_head pmus_node;
+
+       /*
+        * We put all clkdiv2 and clk counters to a same array.
+        * The first DMC620_PMU_CLKDIV2_MAX_COUNTERS bits belong to
+        * clkdiv2 counters, the last DMC620_PMU_CLK_MAX_COUNTERS
+        * belong to clk counters.
+        */
+       DECLARE_BITMAP(used_mask, DMC620_PMU_MAX_COUNTERS);
+       struct perf_event *events[DMC620_PMU_MAX_COUNTERS];
+};
+
+#define to_dmc620_pmu(p) (container_of(p, struct dmc620_pmu, pmu))
+
+static int cpuhp_state_num;
+
+struct dmc620_pmu_event_attr {
+       struct device_attribute attr;
+       u8 clkdiv2;
+       u8 eventid;
+};
+
+static ssize_t
+dmc620_pmu_event_show(struct device *dev,
+                          struct device_attribute *attr, char *page)
+{
+       struct dmc620_pmu_event_attr *eattr;
+
+       eattr = container_of(attr, typeof(*eattr), attr);
+
+       return sprintf(page, "event=0x%x,clkdiv2=0x%x\n", eattr->eventid, eattr->clkdiv2);
+}
+
+#define DMC620_PMU_EVENT_ATTR(_name, _eventid, _clkdiv2)               \
+       (&((struct dmc620_pmu_event_attr[]) {{                          \
+               .attr = __ATTR(_name, 0444, dmc620_pmu_event_show, NULL),       \
+               .clkdiv2 = _clkdiv2,                                            \
+               .eventid = _eventid,                                    \
+       }})[0].attr.attr)
+
+static struct attribute *dmc620_pmu_events_attrs[] = {
+       /* clkdiv2 events list */
+       DMC620_PMU_EVENT_ATTR(clkdiv2_cycle_count, 0x0, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_allocate, 0x1, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_queue_depth, 0x2, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_waiting_for_wr_data, 0x3, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_read_backlog, 0x4, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_waiting_for_mi, 0x5, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_hazard_resolution, 0x6, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_enqueue, 0x7, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_arbitrate, 0x8, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_lrank_turnaround_activate, 0x9, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_prank_turnaround_activate, 0xa, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_read_depth, 0xb, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_write_depth, 0xc, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_highigh_qos_depth, 0xd, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_high_qos_depth, 0xe, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_medium_qos_depth, 0xf, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_low_qos_depth, 0x10, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_activate, 0x11, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_rdwr, 0x12, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_refresh, 0x13, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_training_request, 0x14, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_t_mac_tracker, 0x15, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_bk_fsm_tracker, 0x16, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_bk_open_tracker, 0x17, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_ranks_in_pwr_down, 0x18, 1),
+       DMC620_PMU_EVENT_ATTR(clkdiv2_ranks_in_sref, 0x19, 1),
+
+       /* clk events list */
+       DMC620_PMU_EVENT_ATTR(clk_cycle_count, 0x0, 0),
+       DMC620_PMU_EVENT_ATTR(clk_request, 0x1, 0),
+       DMC620_PMU_EVENT_ATTR(clk_upload_stall, 0x2, 0),
+       NULL,
+};
+
+static struct attribute_group dmc620_pmu_events_attr_group = {
+       .name = "events",
+       .attrs = dmc620_pmu_events_attrs,
+};
+
+/* User ABI */
+#define ATTR_CFG_FLD_mask_CFG          config
+#define ATTR_CFG_FLD_mask_LO           0
+#define ATTR_CFG_FLD_mask_HI           44
+#define ATTR_CFG_FLD_match_CFG         config1
+#define ATTR_CFG_FLD_match_LO          0
+#define ATTR_CFG_FLD_match_HI          44
+#define ATTR_CFG_FLD_invert_CFG                config2
+#define ATTR_CFG_FLD_invert_LO         0
+#define ATTR_CFG_FLD_invert_HI         0
+#define ATTR_CFG_FLD_incr_CFG          config2
+#define ATTR_CFG_FLD_incr_LO           1
+#define ATTR_CFG_FLD_incr_HI           2
+#define ATTR_CFG_FLD_event_CFG         config2
+#define ATTR_CFG_FLD_event_LO          3
+#define ATTR_CFG_FLD_event_HI          8
+#define ATTR_CFG_FLD_clkdiv2_CFG       config2
+#define ATTR_CFG_FLD_clkdiv2_LO                9
+#define ATTR_CFG_FLD_clkdiv2_HI                9
+
+#define __GEN_PMU_FORMAT_ATTR(cfg, lo, hi)                     \
+       (lo) == (hi) ? #cfg ":" #lo "\n" : #cfg ":" #lo "-" #hi
+
+#define _GEN_PMU_FORMAT_ATTR(cfg, lo, hi)                      \
+       __GEN_PMU_FORMAT_ATTR(cfg, lo, hi)
+
+#define GEN_PMU_FORMAT_ATTR(name)                              \
+       PMU_FORMAT_ATTR(name,                                   \
+       _GEN_PMU_FORMAT_ATTR(ATTR_CFG_FLD_##name##_CFG,         \
+                            ATTR_CFG_FLD_##name##_LO,          \
+                            ATTR_CFG_FLD_##name##_HI))
+
+#define _ATTR_CFG_GET_FLD(attr, cfg, lo, hi)                   \
+       ((((attr)->cfg) >> lo) & GENMASK_ULL(hi - lo, 0))
+
+#define ATTR_CFG_GET_FLD(attr, name)                           \
+       _ATTR_CFG_GET_FLD(attr,                                 \
+                         ATTR_CFG_FLD_##name##_CFG,            \
+                         ATTR_CFG_FLD_##name##_LO,             \
+                         ATTR_CFG_FLD_##name##_HI)
+
+GEN_PMU_FORMAT_ATTR(mask);
+GEN_PMU_FORMAT_ATTR(match);
+GEN_PMU_FORMAT_ATTR(invert);
+GEN_PMU_FORMAT_ATTR(incr);
+GEN_PMU_FORMAT_ATTR(event);
+GEN_PMU_FORMAT_ATTR(clkdiv2);
+
+static struct attribute *dmc620_pmu_formats_attrs[] = {
+       &format_attr_mask.attr,
+       &format_attr_match.attr,
+       &format_attr_invert.attr,
+       &format_attr_incr.attr,
+       &format_attr_event.attr,
+       &format_attr_clkdiv2.attr,
+       NULL,
+};
+
+static struct attribute_group dmc620_pmu_format_attr_group = {
+       .name   = "format",
+       .attrs  = dmc620_pmu_formats_attrs,
+};
+
+static const struct attribute_group *dmc620_pmu_attr_groups[] = {
+       &dmc620_pmu_events_attr_group,
+       &dmc620_pmu_format_attr_group,
+       NULL,
+};
+
+static inline
+u32 dmc620_pmu_creg_read(struct dmc620_pmu *dmc620_pmu,
+                       unsigned int idx, unsigned int reg)
+{
+       return readl(dmc620_pmu->base + DMC620_PMU_COUNTERn_OFFSET(idx) + reg);
+}
+
+static inline
+void dmc620_pmu_creg_write(struct dmc620_pmu *dmc620_pmu,
+                       unsigned int idx, unsigned int reg, u32 val)
+{
+       writel(val, dmc620_pmu->base + DMC620_PMU_COUNTERn_OFFSET(idx) + reg);
+}
+
+static
+unsigned int dmc620_event_to_counter_control(struct perf_event *event)
+{
+       struct perf_event_attr *attr = &event->attr;
+       unsigned int reg = 0;
+
+       reg |= FIELD_PREP(DMC620_PMU_COUNTERn_CONTROL_INVERT,
+                       ATTR_CFG_GET_FLD(attr, invert));
+       reg |= FIELD_PREP(DMC620_PMU_COUNTERn_CONTROL_EVENT_MUX,
+                       ATTR_CFG_GET_FLD(attr, event));
+       reg |= FIELD_PREP(DMC620_PMU_COUNTERn_CONTROL_INCR_MUX,
+                       ATTR_CFG_GET_FLD(attr, incr));
+
+       return reg;
+}
+
+static int dmc620_get_event_idx(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+       int idx, start_idx, end_idx;
+
+       if (ATTR_CFG_GET_FLD(&event->attr, clkdiv2)) {
+               start_idx = 0;
+               end_idx = DMC620_PMU_CLKDIV2_MAX_COUNTERS;
+       } else {
+               start_idx = DMC620_PMU_CLKDIV2_MAX_COUNTERS;
+               end_idx = DMC620_PMU_MAX_COUNTERS;
+       }
+
+       for (idx = start_idx; idx < end_idx; ++idx) {
+               if (!test_and_set_bit(idx, dmc620_pmu->used_mask))
+                       return idx;
+       }
+
+       /* The counters are all in use. */
+       return -EAGAIN;
+}
+
+static inline
+u64 dmc620_pmu_read_counter(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+
+       return dmc620_pmu_creg_read(dmc620_pmu,
+                                   event->hw.idx, DMC620_PMU_COUNTERn_VALUE);
+}
+
+static void dmc620_pmu_event_update(struct perf_event *event)
+{
+       struct hw_perf_event *hwc = &event->hw;
+       u64 delta, prev_count, new_count;
+
+       do {
+               /* We may also be called from the irq handler */
+               prev_count = local64_read(&hwc->prev_count);
+               new_count = dmc620_pmu_read_counter(event);
+       } while (local64_cmpxchg(&hwc->prev_count,
+                       prev_count, new_count) != prev_count);
+       delta = (new_count - prev_count) & DMC620_CNT_MAX_PERIOD;
+       local64_add(delta, &event->count);
+}
+
+static void dmc620_pmu_event_set_period(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+
+       local64_set(&event->hw.prev_count, DMC620_CNT_INIT);
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             event->hw.idx, DMC620_PMU_COUNTERn_VALUE, DMC620_CNT_INIT);
+}
+
+static void dmc620_pmu_enable_counter(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+       u32 reg;
+
+       reg = dmc620_event_to_counter_control(event) | DMC620_PMU_COUNTERn_CONTROL_ENABLE;
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             event->hw.idx, DMC620_PMU_COUNTERn_CONTROL, reg);
+}
+
+static void dmc620_pmu_disable_counter(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             event->hw.idx, DMC620_PMU_COUNTERn_CONTROL, 0);
+}
+
+static irqreturn_t dmc620_pmu_handle_irq(int irq_num, void *data)
+{
+       struct dmc620_pmu_irq *irq = data;
+       struct dmc620_pmu *dmc620_pmu;
+       irqreturn_t ret = IRQ_NONE;
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(dmc620_pmu, &irq->pmus_node, pmus_node) {
+               unsigned long status;
+               struct perf_event *event;
+               unsigned int idx;
+
+               /*
+                * HW doesn't provide a control to atomically disable all counters.
+                * To prevent race condition (overflow happens while clearing status register),
+                * disable all events before continuing
+                */
+               for (idx = 0; idx < DMC620_PMU_MAX_COUNTERS; idx++) {
+                       event = dmc620_pmu->events[idx];
+                       if (!event)
+                               continue;
+                       dmc620_pmu_disable_counter(event);
+               }
+
+               status = readl(dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLKDIV2);
+               status |= (readl(dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLK) <<
+                               DMC620_PMU_CLKDIV2_MAX_COUNTERS);
+               if (status) {
+                       for_each_set_bit(idx, &status,
+                                       DMC620_PMU_MAX_COUNTERS) {
+                               event = dmc620_pmu->events[idx];
+                               if (WARN_ON_ONCE(!event))
+                                       continue;
+                               dmc620_pmu_event_update(event);
+                               dmc620_pmu_event_set_period(event);
+                       }
+
+                       if (status & DMC620_PMU_OVERFLOW_STATUS_CLKDIV2_MASK)
+                               writel(0, dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLKDIV2);
+
+                       if ((status >> DMC620_PMU_CLKDIV2_MAX_COUNTERS) &
+                               DMC620_PMU_OVERFLOW_STATUS_CLK_MASK)
+                               writel(0, dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLK);
+               }
+
+               for (idx = 0; idx < DMC620_PMU_MAX_COUNTERS; idx++) {
+                       event = dmc620_pmu->events[idx];
+                       if (!event)
+                               continue;
+                       if (!(event->hw.state & PERF_HES_STOPPED))
+                               dmc620_pmu_enable_counter(event);
+               }
+
+               ret = IRQ_HANDLED;
+       }
+       rcu_read_unlock();
+
+       return ret;
+}
+
+static struct dmc620_pmu_irq *__dmc620_pmu_get_irq(int irq_num)
+{
+       struct dmc620_pmu_irq *irq;
+       int ret;
+
+       list_for_each_entry(irq, &dmc620_pmu_irqs, irqs_node)
+               if (irq->irq_num == irq_num && refcount_inc_not_zero(&irq->refcount))
+                       return irq;
+
+       irq = kzalloc(sizeof(*irq), GFP_KERNEL);
+       if (!irq)
+               return ERR_PTR(-ENOMEM);
+
+       INIT_LIST_HEAD(&irq->pmus_node);
+
+       /* Pick one CPU to be the preferred one to use */
+       irq->cpu = raw_smp_processor_id();
+       refcount_set(&irq->refcount, 1);
+
+       ret = request_irq(irq_num, dmc620_pmu_handle_irq,
+                         IRQF_NOBALANCING | IRQF_NO_THREAD,
+                         "dmc620-pmu", irq);
+       if (ret)
+               goto out_free_aff;
+
+       ret = irq_set_affinity_hint(irq_num, cpumask_of(irq->cpu));
+       if (ret)
+               goto out_free_irq;
+
+       ret = cpuhp_state_add_instance_nocalls(cpuhp_state_num, &irq->node);
+       if (ret)
+               goto out_free_irq;
+
+       irq->irq_num = irq_num;
+       list_add(&irq->irqs_node, &dmc620_pmu_irqs);
+
+       return irq;
+
+out_free_irq:
+       free_irq(irq_num, irq);
+out_free_aff:
+       kfree(irq);
+       return ERR_PTR(ret);
+}
+
+static int dmc620_pmu_get_irq(struct dmc620_pmu *dmc620_pmu, int irq_num)
+{
+       struct dmc620_pmu_irq *irq;
+
+       mutex_lock(&dmc620_pmu_irqs_lock);
+       irq = __dmc620_pmu_get_irq(irq_num);
+       mutex_unlock(&dmc620_pmu_irqs_lock);
+
+       if (IS_ERR(irq))
+               return PTR_ERR(irq);
+
+       dmc620_pmu->irq = irq;
+       mutex_lock(&dmc620_pmu_irqs_lock);
+       list_add_rcu(&dmc620_pmu->pmus_node, &irq->pmus_node);
+       mutex_unlock(&dmc620_pmu_irqs_lock);
+
+       return 0;
+}
+
+static void dmc620_pmu_put_irq(struct dmc620_pmu *dmc620_pmu)
+{
+       struct dmc620_pmu_irq *irq = dmc620_pmu->irq;
+
+       mutex_lock(&dmc620_pmu_irqs_lock);
+       list_del_rcu(&dmc620_pmu->pmus_node);
+
+       if (!refcount_dec_and_test(&irq->refcount)) {
+               mutex_unlock(&dmc620_pmu_irqs_lock);
+               return;
+       }
+
+       list_del(&irq->irqs_node);
+       mutex_unlock(&dmc620_pmu_irqs_lock);
+
+       WARN_ON(irq_set_affinity_hint(irq->irq_num, NULL));
+       free_irq(irq->irq_num, irq);
+       cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &irq->node);
+       kfree(irq);
+}
+
+static int dmc620_pmu_event_init(struct perf_event *event)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+       struct hw_perf_event *hwc = &event->hw;
+       struct perf_event *sibling;
+
+       if (event->attr.type != event->pmu->type)
+               return -ENOENT;
+
+       /*
+        * DMC 620 PMUs are shared across all cpus and cannot
+        * support task bound and sampling events.
+        */
+       if (is_sampling_event(event) ||
+               event->attach_state & PERF_ATTACH_TASK) {
+               dev_dbg(dmc620_pmu->pmu.dev,
+                       "Can't support per-task counters\n");
+               return -EOPNOTSUPP;
+       }
+
+       /*
+        * Many perf core operations (eg. events rotation) operate on a
+        * single CPU context. This is obvious for CPU PMUs, where one
+        * expects the same sets of events being observed on all CPUs,
+        * but can lead to issues for off-core PMUs, where each
+        * event could be theoretically assigned to a different CPU. To
+        * mitigate this, we enforce CPU assignment to one, selected
+        * processor.
+        */
+       event->cpu = dmc620_pmu->irq->cpu;
+       if (event->cpu < 0)
+               return -EINVAL;
+
+       /*
+        * We can't atomically disable all HW counters so only one event allowed,
+        * although software events are acceptable.
+        */
+       if (event->group_leader != event &&
+                       !is_software_event(event->group_leader))
+               return -EINVAL;
+
+       for_each_sibling_event(sibling, event->group_leader) {
+               if (sibling != event &&
+                               !is_software_event(sibling))
+                       return -EINVAL;
+       }
+
+       hwc->idx = -1;
+       return 0;
+}
+
+static void dmc620_pmu_read(struct perf_event *event)
+{
+       dmc620_pmu_event_update(event);
+}
+
+static void dmc620_pmu_start(struct perf_event *event, int flags)
+{
+       event->hw.state = 0;
+       dmc620_pmu_event_set_period(event);
+       dmc620_pmu_enable_counter(event);
+}
+
+static void dmc620_pmu_stop(struct perf_event *event, int flags)
+{
+       if (event->hw.state & PERF_HES_STOPPED)
+               return;
+
+       dmc620_pmu_disable_counter(event);
+       dmc620_pmu_event_update(event);
+       event->hw.state |= PERF_HES_STOPPED | PERF_HES_UPTODATE;
+}
+
+static int dmc620_pmu_add(struct perf_event *event, int flags)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+       struct perf_event_attr *attr = &event->attr;
+       struct hw_perf_event *hwc = &event->hw;
+       int idx;
+       u64 reg;
+
+       idx = dmc620_get_event_idx(event);
+       if (idx < 0)
+               return idx;
+
+       hwc->idx = idx;
+       dmc620_pmu->events[idx] = event;
+       hwc->state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
+
+       reg = ATTR_CFG_GET_FLD(attr, mask);
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             idx, DMC620_PMU_COUNTERn_MASK_31_00, lower_32_bits(reg));
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             idx, DMC620_PMU_COUNTERn_MASK_63_32, upper_32_bits(reg));
+
+       reg = ATTR_CFG_GET_FLD(attr, match);
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             idx, DMC620_PMU_COUNTERn_MATCH_31_00, lower_32_bits(reg));
+       dmc620_pmu_creg_write(dmc620_pmu,
+                             idx, DMC620_PMU_COUNTERn_MATCH_63_32, upper_32_bits(reg));
+
+       if (flags & PERF_EF_START)
+               dmc620_pmu_start(event, PERF_EF_RELOAD);
+
+       perf_event_update_userpage(event);
+       return 0;
+}
+
+static void dmc620_pmu_del(struct perf_event *event, int flags)
+{
+       struct dmc620_pmu *dmc620_pmu = to_dmc620_pmu(event->pmu);
+       struct hw_perf_event *hwc = &event->hw;
+       int idx = hwc->idx;
+
+       dmc620_pmu_stop(event, PERF_EF_UPDATE);
+       dmc620_pmu->events[idx] = NULL;
+       clear_bit(idx, dmc620_pmu->used_mask);
+       perf_event_update_userpage(event);
+}
+
+static int dmc620_pmu_cpu_teardown(unsigned int cpu,
+                                  struct hlist_node *node)
+{
+       struct dmc620_pmu_irq *irq;
+       struct dmc620_pmu *dmc620_pmu;
+       unsigned int target;
+
+       irq = hlist_entry_safe(node, struct dmc620_pmu_irq, node);
+       if (cpu != irq->cpu)
+               return 0;
+
+       target = cpumask_any_but(cpu_online_mask, cpu);
+       if (target >= nr_cpu_ids)
+               return 0;
+
+       /* We're only reading, but this isn't the place to be involving RCU */
+       mutex_lock(&dmc620_pmu_irqs_lock);
+       list_for_each_entry(dmc620_pmu, &irq->pmus_node, pmus_node)
+               perf_pmu_migrate_context(&dmc620_pmu->pmu, irq->cpu, target);
+       mutex_unlock(&dmc620_pmu_irqs_lock);
+
+       WARN_ON(irq_set_affinity_hint(irq->irq_num, cpumask_of(target)));
+       irq->cpu = target;
+
+       return 0;
+}
+
+static int dmc620_pmu_device_probe(struct platform_device *pdev)
+{
+       struct dmc620_pmu *dmc620_pmu;
+       struct resource *res;
+       char *name;
+       int irq_num;
+       int i, ret;
+
+       dmc620_pmu = devm_kzalloc(&pdev->dev,
+                       sizeof(struct dmc620_pmu), GFP_KERNEL);
+       if (!dmc620_pmu)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, dmc620_pmu);
+
+       dmc620_pmu->pmu = (struct pmu) {
+               .module = THIS_MODULE,
+               .capabilities   = PERF_PMU_CAP_NO_EXCLUDE,
+               .task_ctx_nr    = perf_invalid_context,
+               .event_init     = dmc620_pmu_event_init,
+               .add            = dmc620_pmu_add,
+               .del            = dmc620_pmu_del,
+               .start          = dmc620_pmu_start,
+               .stop           = dmc620_pmu_stop,
+               .read           = dmc620_pmu_read,
+               .attr_groups    = dmc620_pmu_attr_groups,
+       };
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       dmc620_pmu->base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(dmc620_pmu->base))
+               return PTR_ERR(dmc620_pmu->base);
+
+       /* Make sure device is reset before enabling interrupt */
+       for (i = 0; i < DMC620_PMU_MAX_COUNTERS; i++)
+               dmc620_pmu_creg_write(dmc620_pmu, i, DMC620_PMU_COUNTERn_CONTROL, 0);
+       writel(0, dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLKDIV2);
+       writel(0, dmc620_pmu->base + DMC620_PMU_OVERFLOW_STATUS_CLK);
+
+       irq_num = platform_get_irq(pdev, 0);
+       if (irq_num < 0)
+               return irq_num;
+
+       ret = dmc620_pmu_get_irq(dmc620_pmu, irq_num);
+       if (ret)
+               return ret;
+
+       name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
+                                 "%s_%llx", DMC620_PMUNAME,
+                                 (u64)(res->start >> DMC620_PA_SHIFT));
+       if (!name) {
+               dev_err(&pdev->dev,
+                         "Create name failed, PMU @%pa\n", &res->start);
+               goto out_teardown_dev;
+       }
+
+       ret = perf_pmu_register(&dmc620_pmu->pmu, name, -1);
+       if (ret)
+               goto out_teardown_dev;
+
+       return 0;
+
+out_teardown_dev:
+       dmc620_pmu_put_irq(dmc620_pmu);
+       synchronize_rcu();
+       return ret;
+}
+
+static int dmc620_pmu_device_remove(struct platform_device *pdev)
+{
+       struct dmc620_pmu *dmc620_pmu = platform_get_drvdata(pdev);
+
+       dmc620_pmu_put_irq(dmc620_pmu);
+
+       /* perf will synchronise RCU before devres can free dmc620_pmu */
+       perf_pmu_unregister(&dmc620_pmu->pmu);
+
+       return 0;
+}
+
+static const struct acpi_device_id dmc620_acpi_match[] = {
+       { "ARMHD620", 0},
+       {},
+};
+MODULE_DEVICE_TABLE(acpi, dmc620_acpi_match);
+static struct platform_driver dmc620_pmu_driver = {
+       .driver = {
+               .name           = DMC620_DRVNAME,
+               .acpi_match_table = dmc620_acpi_match,
+       },
+       .probe  = dmc620_pmu_device_probe,
+       .remove = dmc620_pmu_device_remove,
+};
+
+static int __init dmc620_pmu_init(void)
+{
+       cpuhp_state_num = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
+                                     DMC620_DRVNAME,
+                                     NULL,
+                                     dmc620_pmu_cpu_teardown);
+       if (cpuhp_state_num < 0)
+               return cpuhp_state_num;
+
+       return platform_driver_register(&dmc620_pmu_driver);
+}
+
+static void __exit dmc620_pmu_exit(void)
+{
+       platform_driver_unregister(&dmc620_pmu_driver);
+       cpuhp_remove_multi_state(cpuhp_state_num);
+}
+
+module_init(dmc620_pmu_init);
+module_exit(dmc620_pmu_exit);
+
+MODULE_DESCRIPTION("Perf driver for the ARM DMC-620 memory controller");
+MODULE_AUTHOR("Tuan Phan <tuanphan@os.amperecomputing.com");
+MODULE_LICENSE("GPL v2");
index 98e68ed7db85f854974a42fe7536d4e396fd5c23..0459a340346942f96b41e9afc573d16b4930f74f 100644 (file)
@@ -716,9 +716,6 @@ static int dsu_pmu_device_probe(struct platform_device *pdev)
        if (IS_ERR(dsu_pmu))
                return PTR_ERR(dsu_pmu);
 
-       if (IS_ERR_OR_NULL(fwnode))
-               return -ENOENT;
-
        if (is_of_node(fwnode))
                rc = dsu_pmu_dt_get_cpus(&pdev->dev, &dsu_pmu->associated_cpus);
        else if (is_acpi_device_node(fwnode))
index cb2f55f450e4adf05a7b3d81e8b9a01230665584..794a37d5085376c54b571274f360f9c427d5c5d9 100644 (file)
@@ -726,6 +726,11 @@ static int armpmu_get_cpu_irq(struct arm_pmu *pmu, int cpu)
        return per_cpu(hw_events->irq, cpu);
 }
 
+bool arm_pmu_irq_is_nmi(void)
+{
+       return has_nmi;
+}
+
 /*
  * PMU hardware loses all context when a CPU goes offline.
  * When a CPU is hotplugged back in, since some hardware registers are
index 5274f7fe359ebb678f09bd2916f11d935419d6db..74474bb322c3f2618940a15557b14651b848e41c 100644 (file)
@@ -74,6 +74,7 @@
 #define SMMU_PMCG_CFGR_NCTR             GENMASK(5, 0)
 #define SMMU_PMCG_CR                    0xE04
 #define SMMU_PMCG_CR_ENABLE             BIT(0)
+#define SMMU_PMCG_IIDR                  0xE08
 #define SMMU_PMCG_CEID0                 0xE20
 #define SMMU_PMCG_CEID1                 0xE28
 #define SMMU_PMCG_IRQ_CTRL              0xE50
@@ -112,6 +113,7 @@ struct smmu_pmu {
        void __iomem *reloc_base;
        u64 counter_mask;
        u32 options;
+       u32 iidr;
        bool global_filter;
 };
 
@@ -552,6 +554,40 @@ static struct attribute_group smmu_pmu_events_group = {
        .is_visible = smmu_pmu_event_is_visible,
 };
 
+static ssize_t smmu_pmu_identifier_attr_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *page)
+{
+       struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev));
+
+       return snprintf(page, PAGE_SIZE, "0x%08x\n", smmu_pmu->iidr);
+}
+
+static umode_t smmu_pmu_identifier_attr_visible(struct kobject *kobj,
+                                               struct attribute *attr,
+                                               int n)
+{
+       struct device *dev = kobj_to_dev(kobj);
+       struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev));
+
+       if (!smmu_pmu->iidr)
+               return 0;
+       return attr->mode;
+}
+
+static struct device_attribute smmu_pmu_identifier_attr =
+       __ATTR(identifier, 0444, smmu_pmu_identifier_attr_show, NULL);
+
+static struct attribute *smmu_pmu_identifier_attrs[] = {
+       &smmu_pmu_identifier_attr.attr,
+       NULL
+};
+
+static struct attribute_group smmu_pmu_identifier_group = {
+       .attrs = smmu_pmu_identifier_attrs,
+       .is_visible = smmu_pmu_identifier_attr_visible,
+};
+
 /* Formats */
 PMU_FORMAT_ATTR(event,            "config:0-15");
 PMU_FORMAT_ATTR(filter_stream_id,  "config1:0-31");
@@ -575,6 +611,7 @@ static const struct attribute_group *smmu_pmu_attr_grps[] = {
        &smmu_pmu_cpumask_group,
        &smmu_pmu_events_group,
        &smmu_pmu_format_group,
+       &smmu_pmu_identifier_group,
        NULL
 };
 
@@ -795,6 +832,8 @@ static int smmu_pmu_probe(struct platform_device *pdev)
                return err;
        }
 
+       smmu_pmu->iidr = readl_relaxed(smmu_pmu->reg_base + SMMU_PMCG_IIDR);
+
        name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "smmuv3_pmcg_%llx",
                              (res_0->start) >> SMMU_PMCG_PA_SHIFT);
        if (!name) {
index 397540a4b799c83d0030a35be2c93c6d77953a3f..a11bfd8a08230c2760b2969ab74f25a20f7fff96 100644 (file)
@@ -50,6 +50,7 @@ static DEFINE_IDA(ddr_ida);
 
 struct fsl_ddr_devtype_data {
        unsigned int quirks;    /* quirks needed for different DDR Perf core */
+       const char *identifier; /* system PMU identifier for userspace */
 };
 
 static const struct fsl_ddr_devtype_data imx8_devtype_data;
@@ -58,13 +59,32 @@ static const struct fsl_ddr_devtype_data imx8m_devtype_data = {
        .quirks = DDR_CAP_AXI_ID_FILTER,
 };
 
+static const struct fsl_ddr_devtype_data imx8mq_devtype_data = {
+       .quirks = DDR_CAP_AXI_ID_FILTER,
+       .identifier = "i.MX8MQ",
+};
+
+static const struct fsl_ddr_devtype_data imx8mm_devtype_data = {
+       .quirks = DDR_CAP_AXI_ID_FILTER,
+       .identifier = "i.MX8MM",
+};
+
+static const struct fsl_ddr_devtype_data imx8mn_devtype_data = {
+       .quirks = DDR_CAP_AXI_ID_FILTER,
+       .identifier = "i.MX8MN",
+};
+
 static const struct fsl_ddr_devtype_data imx8mp_devtype_data = {
        .quirks = DDR_CAP_AXI_ID_FILTER_ENHANCED,
+       .identifier = "i.MX8MP",
 };
 
 static const struct of_device_id imx_ddr_pmu_dt_ids[] = {
        { .compatible = "fsl,imx8-ddr-pmu", .data = &imx8_devtype_data},
        { .compatible = "fsl,imx8m-ddr-pmu", .data = &imx8m_devtype_data},
+       { .compatible = "fsl,imx8mq-ddr-pmu", .data = &imx8mq_devtype_data},
+       { .compatible = "fsl,imx8mm-ddr-pmu", .data = &imx8mm_devtype_data},
+       { .compatible = "fsl,imx8mn-ddr-pmu", .data = &imx8mn_devtype_data},
        { .compatible = "fsl,imx8mp-ddr-pmu", .data = &imx8mp_devtype_data},
        { /* sentinel */ }
 };
@@ -84,6 +104,40 @@ struct ddr_pmu {
        int id;
 };
 
+static ssize_t ddr_perf_identifier_show(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *page)
+{
+       struct ddr_pmu *pmu = dev_get_drvdata(dev);
+
+       return sprintf(page, "%s\n", pmu->devtype_data->identifier);
+}
+
+static umode_t ddr_perf_identifier_attr_visible(struct kobject *kobj,
+                                               struct attribute *attr,
+                                               int n)
+{
+       struct device *dev = kobj_to_dev(kobj);
+       struct ddr_pmu *pmu = dev_get_drvdata(dev);
+
+       if (!pmu->devtype_data->identifier)
+               return 0;
+       return attr->mode;
+};
+
+static struct device_attribute ddr_perf_identifier_attr =
+       __ATTR(identifier, 0444, ddr_perf_identifier_show, NULL);
+
+static struct attribute *ddr_perf_identifier_attrs[] = {
+       &ddr_perf_identifier_attr.attr,
+       NULL,
+};
+
+static struct attribute_group ddr_perf_identifier_attr_group = {
+       .attrs = ddr_perf_identifier_attrs,
+       .is_visible = ddr_perf_identifier_attr_visible,
+};
+
 enum ddr_perf_filter_capabilities {
        PERF_CAP_AXI_ID_FILTER = 0,
        PERF_CAP_AXI_ID_FILTER_ENHANCED,
@@ -237,6 +291,7 @@ static const struct attribute_group *attr_groups[] = {
        &ddr_perf_format_attr_group,
        &ddr_perf_cpumask_attr_group,
        &ddr_perf_filter_cap_attr_group,
+       &ddr_perf_identifier_attr_group,
        NULL,
 };
 
@@ -361,25 +416,6 @@ static int ddr_perf_event_init(struct perf_event *event)
        return 0;
 }
 
-
-static void ddr_perf_event_update(struct perf_event *event)
-{
-       struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
-       struct hw_perf_event *hwc = &event->hw;
-       u64 delta, prev_raw_count, new_raw_count;
-       int counter = hwc->idx;
-
-       do {
-               prev_raw_count = local64_read(&hwc->prev_count);
-               new_raw_count = ddr_perf_read_counter(pmu, counter);
-       } while (local64_cmpxchg(&hwc->prev_count, prev_raw_count,
-                       new_raw_count) != prev_raw_count);
-
-       delta = (new_raw_count - prev_raw_count) & 0xFFFFFFFF;
-
-       local64_add(delta, &event->count);
-}
-
 static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
                                  int counter, bool enable)
 {
@@ -404,6 +440,56 @@ static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
        }
 }
 
+static bool ddr_perf_counter_overflow(struct ddr_pmu *pmu, int counter)
+{
+       int val;
+
+       val = readl_relaxed(pmu->base + counter * 4 + COUNTER_CNTL);
+
+       return val & CNTL_OVER;
+}
+
+static void ddr_perf_counter_clear(struct ddr_pmu *pmu, int counter)
+{
+       u8 reg = counter * 4 + COUNTER_CNTL;
+       int val;
+
+       val = readl_relaxed(pmu->base + reg);
+       val &= ~CNTL_CLEAR;
+       writel(val, pmu->base + reg);
+
+       val |= CNTL_CLEAR;
+       writel(val, pmu->base + reg);
+}
+
+static void ddr_perf_event_update(struct perf_event *event)
+{
+       struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
+       struct hw_perf_event *hwc = &event->hw;
+       u64 new_raw_count;
+       int counter = hwc->idx;
+       int ret;
+
+       new_raw_count = ddr_perf_read_counter(pmu, counter);
+       local64_add(new_raw_count, &event->count);
+
+       /*
+        * For legacy SoCs: event counter continue counting when overflow,
+        *                  no need to clear the counter.
+        * For new SoCs: event counter stop counting when overflow, need
+        *               clear counter to let it count again.
+        */
+       if (counter != EVENT_CYCLES_COUNTER) {
+               ret = ddr_perf_counter_overflow(pmu, counter);
+               if (ret)
+                       dev_warn_ratelimited(pmu->dev,  "events lost due to counter overflow (config 0x%llx)\n",
+                                            event->attr.config);
+       }
+
+       /* clear counter every time for both cycle counter and event counter */
+       ddr_perf_counter_clear(pmu, counter);
+}
+
 static void ddr_perf_event_start(struct perf_event *event, int flags)
 {
        struct ddr_pmu *pmu = to_ddr_pmu(event->pmu);
@@ -537,7 +623,7 @@ static irqreturn_t ddr_perf_irq_handler(int irq, void *p)
 {
        int i;
        struct ddr_pmu *pmu = (struct ddr_pmu *) p;
-       struct perf_event *event, *cycle_event = NULL;
+       struct perf_event *event;
 
        /* all counter will stop if cycle counter disabled */
        ddr_perf_counter_enable(pmu,
@@ -547,7 +633,9 @@ static irqreturn_t ddr_perf_irq_handler(int irq, void *p)
        /*
         * When the cycle counter overflows, all counters are stopped,
         * and an IRQ is raised. If any other counter overflows, it
-        * continues counting, and no IRQ is raised.
+        * continues counting, and no IRQ is raised. But for new SoCs,
+        * such as i.MX8MP, event counter would stop when overflow, so
+        * we need use cycle counter to stop overflow of event counter.
         *
         * Cycles occur at least 4 times as often as other events, so we
         * can update all events on a cycle counter overflow and not
@@ -562,17 +650,12 @@ static irqreturn_t ddr_perf_irq_handler(int irq, void *p)
                event = pmu->events[i];
 
                ddr_perf_event_update(event);
-
-               if (event->hw.idx == EVENT_CYCLES_COUNTER)
-                       cycle_event = event;
        }
 
        ddr_perf_counter_enable(pmu,
                              EVENT_CYCLES_ID,
                              EVENT_CYCLES_COUNTER,
                              true);
-       if (cycle_event)
-               ddr_perf_event_update(cycle_event);
 
        return IRQ_HANDLED;
 }
index 5e3645c96443f6a864bfae50139dd6208a04c851..5ac6c9113767eae6a4c64bb66035ecc06439caa0 100644 (file)
@@ -33,6 +33,7 @@
 #define DDRC_INT_MASK          0x6c8
 #define DDRC_INT_STATUS                0x6cc
 #define DDRC_INT_CLEAR         0x6d0
+#define DDRC_VERSION           0x710
 
 /* DDRC has 8-counters */
 #define DDRC_NR_COUNTERS       0x8
@@ -267,6 +268,8 @@ static int hisi_ddrc_pmu_init_data(struct platform_device *pdev,
                return PTR_ERR(ddrc_pmu->base);
        }
 
+       ddrc_pmu->identifier = readl(ddrc_pmu->base + DDRC_VERSION);
+
        return 0;
 }
 
@@ -308,10 +311,23 @@ static const struct attribute_group hisi_ddrc_pmu_cpumask_attr_group = {
        .attrs = hisi_ddrc_pmu_cpumask_attrs,
 };
 
+static struct device_attribute hisi_ddrc_pmu_identifier_attr =
+       __ATTR(identifier, 0444, hisi_uncore_pmu_identifier_attr_show, NULL);
+
+static struct attribute *hisi_ddrc_pmu_identifier_attrs[] = {
+       &hisi_ddrc_pmu_identifier_attr.attr,
+       NULL
+};
+
+static struct attribute_group hisi_ddrc_pmu_identifier_group = {
+       .attrs = hisi_ddrc_pmu_identifier_attrs,
+};
+
 static const struct attribute_group *hisi_ddrc_pmu_attr_groups[] = {
        &hisi_ddrc_pmu_format_group,
        &hisi_ddrc_pmu_events_group,
        &hisi_ddrc_pmu_cpumask_attr_group,
+       &hisi_ddrc_pmu_identifier_group,
        NULL,
 };
 
index 5eb8168029c037fdc37bd4f5e1a38e6a1396ccac..41b2dceb5f26de856d022f770782afd56d040a2f 100644 (file)
@@ -23,6 +23,7 @@
 #define HHA_INT_MASK           0x0804
 #define HHA_INT_STATUS         0x0808
 #define HHA_INT_CLEAR          0x080C
+#define HHA_VERSION            0x1cf0
 #define HHA_PERF_CTRL          0x1E00
 #define HHA_EVENT_CTRL         0x1E04
 #define HHA_EVENT_TYPE0                0x1E80
@@ -261,6 +262,8 @@ static int hisi_hha_pmu_init_data(struct platform_device *pdev,
                return PTR_ERR(hha_pmu->base);
        }
 
+       hha_pmu->identifier = readl(hha_pmu->base + HHA_VERSION);
+
        return 0;
 }
 
@@ -320,10 +323,23 @@ static const struct attribute_group hisi_hha_pmu_cpumask_attr_group = {
        .attrs = hisi_hha_pmu_cpumask_attrs,
 };
 
+static struct device_attribute hisi_hha_pmu_identifier_attr =
+       __ATTR(identifier, 0444, hisi_uncore_pmu_identifier_attr_show, NULL);
+
+static struct attribute *hisi_hha_pmu_identifier_attrs[] = {
+       &hisi_hha_pmu_identifier_attr.attr,
+       NULL
+};
+
+static struct attribute_group hisi_hha_pmu_identifier_group = {
+       .attrs = hisi_hha_pmu_identifier_attrs,
+};
+
 static const struct attribute_group *hisi_hha_pmu_attr_groups[] = {
        &hisi_hha_pmu_format_group,
        &hisi_hha_pmu_events_group,
        &hisi_hha_pmu_cpumask_attr_group,
+       &hisi_hha_pmu_identifier_group,
        NULL,
 };
 
index 3e8b5eab55149a63794a5b09eafc6b8a7e40527c..705501d18d0313a15186aaaf1c500f0d16b51535 100644 (file)
@@ -25,6 +25,7 @@
 #define L3C_INT_STATUS         0x0808
 #define L3C_INT_CLEAR          0x080c
 #define L3C_EVENT_CTRL         0x1c00
+#define L3C_VERSION            0x1cf0
 #define L3C_EVENT_TYPE0                0x1d00
 /*
  * Each counter is 48-bits and [48:63] are reserved
@@ -264,6 +265,8 @@ static int hisi_l3c_pmu_init_data(struct platform_device *pdev,
                return PTR_ERR(l3c_pmu->base);
        }
 
+       l3c_pmu->identifier = readl(l3c_pmu->base + L3C_VERSION);
+
        return 0;
 }
 
@@ -310,10 +313,23 @@ static const struct attribute_group hisi_l3c_pmu_cpumask_attr_group = {
        .attrs = hisi_l3c_pmu_cpumask_attrs,
 };
 
+static struct device_attribute hisi_l3c_pmu_identifier_attr =
+       __ATTR(identifier, 0444, hisi_uncore_pmu_identifier_attr_show, NULL);
+
+static struct attribute *hisi_l3c_pmu_identifier_attrs[] = {
+       &hisi_l3c_pmu_identifier_attr.attr,
+       NULL
+};
+
+static struct attribute_group hisi_l3c_pmu_identifier_group = {
+       .attrs = hisi_l3c_pmu_identifier_attrs,
+};
+
 static const struct attribute_group *hisi_l3c_pmu_attr_groups[] = {
        &hisi_l3c_pmu_format_group,
        &hisi_l3c_pmu_events_group,
        &hisi_l3c_pmu_cpumask_attr_group,
+       &hisi_l3c_pmu_identifier_group,
        NULL,
 };
 
index 97aff877a4e7bfc0489432620be2f504f23480b3..9dbdc3fc3bb4baccf0d91cd86a4bbe4d0a6259ac 100644 (file)
@@ -119,6 +119,16 @@ int hisi_uncore_pmu_get_event_idx(struct perf_event *event)
 }
 EXPORT_SYMBOL_GPL(hisi_uncore_pmu_get_event_idx);
 
+ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
+                                            struct device_attribute *attr,
+                                            char *page)
+{
+       struct hisi_pmu *hisi_pmu = to_hisi_pmu(dev_get_drvdata(dev));
+
+       return snprintf(page, PAGE_SIZE, "0x%08x\n", hisi_pmu->identifier);
+}
+EXPORT_SYMBOL_GPL(hisi_uncore_pmu_identifier_attr_show);
+
 static void hisi_uncore_pmu_clear_event_idx(struct hisi_pmu *hisi_pmu, int idx)
 {
        if (!hisi_uncore_pmu_counter_valid(hisi_pmu, idx)) {
index b59ec22169ab6cbc85dc6e30a5ed866d369b1440..25b7cbe1f8185e20250749a96182c23daf63af56 100644 (file)
@@ -75,6 +75,7 @@ struct hisi_pmu {
        int counter_bits;
        /* check event code range */
        int check_event;
+       u32 identifier;
 };
 
 int hisi_uncore_pmu_counter_valid(struct hisi_pmu *hisi_pmu, int idx);
@@ -97,4 +98,10 @@ ssize_t hisi_cpumask_sysfs_show(struct device *dev,
                                struct device_attribute *attr, char *buf);
 int hisi_uncore_pmu_online_cpu(unsigned int cpu, struct hlist_node *node);
 int hisi_uncore_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node);
+
+ssize_t hisi_uncore_pmu_identifier_attr_show(struct device *dev,
+                                            struct device_attribute *attr,
+                                            char *page);
+
+
 #endif /* __HISI_UNCORE_PMU_H__ */
index 3bf18d7189750f2970753aded98930b03f068621..a50ab002e9e41c7f3b2fcc5026777a24c9fdec21 100644 (file)
@@ -51,7 +51,7 @@ static void pnp_remove_protocol(struct pnp_protocol *protocol)
 }
 
 /**
- * pnp_protocol_register - adds a pnp protocol to the pnp layer
+ * pnp_register_protocol - adds a pnp protocol to the pnp layer
  * @protocol: pointer to the corresponding pnp_protocol structure
  *
  *  Ex protocols: ISAPNP, PNPBIOS, etc
@@ -91,7 +91,7 @@ int pnp_register_protocol(struct pnp_protocol *protocol)
 }
 
 /**
- * pnp_protocol_unregister - removes a pnp protocol from the pnp layer
+ * pnp_unregister_protocol - removes a pnp protocol from the pnp layer
  * @protocol: pointer to the corresponding pnp_protocol structure
  */
 void pnp_unregister_protocol(struct pnp_protocol *protocol)
index 0b2830efc574993ea22dd3959b6196710f009295..70d6d52bc1e2175b38397f79ee3c58a552ab1b97 100644 (file)
@@ -620,7 +620,7 @@ static u64 rapl_unit_xlate(struct rapl_domain *rd, enum unit_type type,
        case ARBITRARY_UNIT:
        default:
                return value;
-       };
+       }
 
        if (to_raw)
                return div64_u64(value, units) * scale;
index a4ffd71696da67782f11b3fce1648f60c2cfa8fb..a5ad553da8cd4972f963a46deab46401e3d5f2cf 100644 (file)
@@ -4165,6 +4165,8 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev)
                ret = rdev->desc->fixed_uV;
        } else if (rdev->supply) {
                ret = regulator_get_voltage_rdev(rdev->supply->rdev);
+       } else if (rdev->supply_name) {
+               return -EPROBE_DEFER;
        } else {
                return -EINVAL;
        }
index 485cbfcbf06ed866dad7e0b158280d703f28e61c..ef738b42a0926d40aed3720ff6ea7521dd3092e6 100644 (file)
@@ -680,7 +680,10 @@ static int ap_device_probe(struct device *dev)
 {
        struct ap_device *ap_dev = to_ap_dev(dev);
        struct ap_driver *ap_drv = to_ap_drv(dev->driver);
-       int card, queue, devres, drvres, rc;
+       int card, queue, devres, drvres, rc = -ENODEV;
+
+       if (!get_device(dev))
+               return rc;
 
        if (is_queue_dev(dev)) {
                /*
@@ -697,7 +700,7 @@ static int ap_device_probe(struct device *dev)
                mutex_unlock(&ap_perms_mutex);
                drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT;
                if (!!devres != !!drvres)
-                       return -ENODEV;
+                       goto out;
        }
 
        /* Add queue/card to list of active queues/cards */
@@ -718,6 +721,9 @@ static int ap_device_probe(struct device *dev)
                ap_dev->drv = NULL;
        }
 
+out:
+       if (rc)
+               put_device(dev);
        return rc;
 }
 
@@ -744,6 +750,8 @@ static int ap_device_remove(struct device *dev)
                hash_del(&to_ap_queue(dev)->hnode);
        spin_unlock_bh(&ap_queues_lock);
 
+       put_device(dev);
+
        return 0;
 }
 
@@ -1371,6 +1379,8 @@ static inline void ap_scan_domains(struct ap_card *ac)
                                            __func__, ac->id, dom);
                                goto put_dev_and_continue;
                        }
+                       /* get it and thus adjust reference counter */
+                       get_device(dev);
                        if (decfg)
                                AP_DBF_INFO("%s(%d,%d) new (decfg) queue device created\n",
                                            __func__, ac->id, dom);
index 99cb60ea663d95ee3eeef7550db014cac238362d..dd84995049b9173e4db609462345ecbf3824ee8b 100644 (file)
@@ -35,9 +35,6 @@ MODULE_DESCRIPTION("s390 protected key interface");
 #define PROTKEYBLOBBUFSIZE 256 /* protected key buffer size used internal */
 #define MAXAPQNSINLIST 64      /* max 64 apqns within a apqn list */
 
-/* mask of available pckmo subfunctions, fetched once at module init */
-static cpacf_mask_t pckmo_functions;
-
 /*
  * debug feature data and functions
  */
@@ -91,6 +88,9 @@ static int pkey_clr2protkey(u32 keytype,
                            const struct pkey_clrkey *clrkey,
                            struct pkey_protkey *protkey)
 {
+       /* mask of available pckmo subfunctions */
+       static cpacf_mask_t pckmo_functions;
+
        long fc;
        int keysize;
        u8 paramblock[64];
@@ -114,11 +114,13 @@ static int pkey_clr2protkey(u32 keytype,
                return -EINVAL;
        }
 
-       /*
-        * Check if the needed pckmo subfunction is available.
-        * These subfunctions can be enabled/disabled by customers
-        * in the LPAR profile or may even change on the fly.
-        */
+       /* Did we already check for PCKMO ? */
+       if (!pckmo_functions.bytes[0]) {
+               /* no, so check now */
+               if (!cpacf_query(CPACF_PCKMO, &pckmo_functions))
+                       return -ENODEV;
+       }
+       /* check for the pckmo subfunction we need now */
        if (!cpacf_test_func(&pckmo_functions, fc)) {
                DEBUG_ERR("%s pckmo functions not available\n", __func__);
                return -ENODEV;
@@ -2058,7 +2060,7 @@ static struct miscdevice pkey_dev = {
  */
 static int __init pkey_init(void)
 {
-       cpacf_mask_t kmc_functions;
+       cpacf_mask_t func_mask;
 
        /*
         * The pckmo instruction should be available - even if we don't
@@ -2066,15 +2068,15 @@ static int __init pkey_init(void)
         * is also the minimum level for the kmc instructions which
         * are able to work with protected keys.
         */
-       if (!cpacf_query(CPACF_PCKMO, &pckmo_functions))
+       if (!cpacf_query(CPACF_PCKMO, &func_mask))
                return -ENODEV;
 
        /* check for kmc instructions available */
-       if (!cpacf_query(CPACF_KMC, &kmc_functions))
+       if (!cpacf_query(CPACF_KMC, &func_mask))
                return -ENODEV;
-       if (!cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_128) ||
-           !cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_192) ||
-           !cpacf_test_func(&kmc_functions, CPACF_KMC_PAES_256))
+       if (!cpacf_test_func(&func_mask, CPACF_KMC_PAES_128) ||
+           !cpacf_test_func(&func_mask, CPACF_KMC_PAES_192) ||
+           !cpacf_test_func(&func_mask, CPACF_KMC_PAES_256))
                return -ENODEV;
 
        pkey_debug_init();
index e342eb86acd1d0f77422e291d2d80426959338ee..33b23884b133fc1d12ebc7f46b33f3bb01277f47 100644 (file)
@@ -157,11 +157,6 @@ int zcrypt_card_register(struct zcrypt_card *zc)
 {
        int rc;
 
-       rc = sysfs_create_group(&zc->card->ap_dev.device.kobj,
-                               &zcrypt_card_attr_group);
-       if (rc)
-               return rc;
-
        spin_lock(&zcrypt_list_lock);
        list_add_tail(&zc->list, &zcrypt_card_list);
        spin_unlock(&zcrypt_list_lock);
@@ -170,6 +165,14 @@ int zcrypt_card_register(struct zcrypt_card *zc)
 
        ZCRYPT_DBF(DBF_INFO, "card=%02x register online=1\n", zc->card->id);
 
+       rc = sysfs_create_group(&zc->card->ap_dev.device.kobj,
+                               &zcrypt_card_attr_group);
+       if (rc) {
+               spin_lock(&zcrypt_list_lock);
+               list_del_init(&zc->list);
+               spin_unlock(&zcrypt_list_lock);
+       }
+
        return rc;
 }
 EXPORT_SYMBOL(zcrypt_card_register);
index 3c207066313cf0f36ab8771c48002e131a924adb..5062eae73d4aa6747451dd9b6a6ea6c24b8b166f 100644 (file)
@@ -180,7 +180,6 @@ int zcrypt_queue_register(struct zcrypt_queue *zq)
                                &zcrypt_queue_attr_group);
        if (rc)
                goto out;
-       get_device(&zq->queue->ap_dev.device);
 
        if (zq->ops->rng) {
                rc = zcrypt_rng_device_add();
@@ -192,7 +191,6 @@ int zcrypt_queue_register(struct zcrypt_queue *zq)
 out_unregister:
        sysfs_remove_group(&zq->queue->ap_dev.device.kobj,
                           &zcrypt_queue_attr_group);
-       put_device(&zq->queue->ap_dev.device);
 out:
        spin_lock(&zcrypt_list_lock);
        list_del_init(&zq->list);
@@ -220,12 +218,10 @@ void zcrypt_queue_unregister(struct zcrypt_queue *zq)
        list_del_init(&zq->list);
        zcrypt_device_count--;
        spin_unlock(&zcrypt_list_lock);
-       zcrypt_card_put(zc);
        if (zq->ops->rng)
                zcrypt_rng_device_remove();
        sysfs_remove_group(&zq->queue->ap_dev.device.kobj,
                           &zcrypt_queue_attr_group);
-       put_device(&zq->queue->ap_dev.device);
-       zcrypt_queue_put(zq);
+       zcrypt_card_put(zc);
 }
 EXPORT_SYMBOL(zcrypt_queue_unregister);
index fe96ca3c88a5a7a8bc38740c1ff9a4403b4c956f..26cc943d2034046e2ef8e956a53dbe46c0228b8d 100644 (file)
@@ -390,7 +390,7 @@ static int ism_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
 }
 
 static struct ism_systemeid SYSTEM_EID = {
-       .seid_string = "IBM-SYSZ-IBMSEID00000000",
+       .seid_string = "IBM-SYSZ-ISMSEID00000000",
        .serial_number = "0000",
        .type = "0000",
 };
index f32da0ca529e004f448c6f9803b9c57b145a6609..308bda2e9c0007a585f7b93613c59cfc00473aa7 100644 (file)
@@ -658,8 +658,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
                                        rcu_read_lock();
                                        list_for_each_entry_rcu(h,
                                                &tmp_pg->dh_list, node) {
-                                               /* h->sdev should always be valid */
-                                               BUG_ON(!h->sdev);
+                                               if (!h->sdev)
+                                                       continue;
                                                h->sdev->access_state = desc[0];
                                        }
                                        rcu_read_unlock();
@@ -705,7 +705,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
                        pg->expiry = 0;
                        rcu_read_lock();
                        list_for_each_entry_rcu(h, &pg->dh_list, node) {
-                               BUG_ON(!h->sdev);
+                               if (!h->sdev)
+                                       continue;
                                h->sdev->access_state =
                                        (pg->state & SCSI_ACCESS_STATE_MASK);
                                if (pg->pref)
@@ -1147,7 +1148,6 @@ static void alua_bus_detach(struct scsi_device *sdev)
        spin_lock(&h->pg_lock);
        pg = rcu_dereference_protected(h->pg, lockdep_is_held(&h->pg_lock));
        rcu_assign_pointer(h->pg, NULL);
-       h->sdev = NULL;
        spin_unlock(&h->pg_lock);
        if (pg) {
                spin_lock_irq(&pg->lock);
@@ -1156,6 +1156,7 @@ static void alua_bus_detach(struct scsi_device *sdev)
                kref_put(&pg->kref, release_port_group);
        }
        sdev->handler_data = NULL;
+       synchronize_rcu();
        kfree(h);
 }
 
index 128583dfccf2079d33cf99d71a4713d5225193b1..c8dd8588f800e08c852030b7580ea9e4ab3a2287 100644 (file)
@@ -445,7 +445,7 @@ static int hisi_sas_task_prep(struct sas_task *task,
                }
        }
 
-       if (scmd) {
+       if (scmd && hisi_hba->shost->nr_hw_queues) {
                unsigned int dq_index;
                u32 blk_tag;
 
index 83ce4f11a58941bd3df70ba946bc9e5ee3a01dd5..8df70c92911dd99d525c9b64f6f79def6d7dfeac 100644 (file)
@@ -8855,7 +8855,7 @@ reinit_after_soft_reset:
        /* hook into SCSI subsystem */
        rc = hpsa_scsi_add_host(h);
        if (rc)
-               goto clean7; /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
+               goto clean8; /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
 
        /* Monitor the controller for firmware lockups */
        h->heartbeat_sample_interval = HEARTBEAT_SAMPLE_INTERVAL;
@@ -8870,6 +8870,8 @@ reinit_after_soft_reset:
                                HPSA_EVENT_MONITOR_INTERVAL);
        return 0;
 
+clean8: /* lastlogicals, perf, sg, cmd, irq, shost, pci, lu, aer/h */
+       kfree(h->lastlogicals);
 clean7: /* perf, sg, cmd, irq, shost, pci, lu, aer/h */
        hpsa_free_performant_mode(h);
        h->access.set_intr_mask(h, HPSA_INTR_OFF);
index b1f3017b6547a47dee952c333db1bf18404b62ce..29fcc44be2d57f800363a8f8a5cfe98585c89a20 100644 (file)
@@ -806,6 +806,22 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
        spin_unlock_irqrestore(hostdata->host->host_lock, flags);
 }
 
+/**
+ * ibmvscsi_set_request_limit - Set the adapter request_limit in response to
+ * an adapter failure, reset, or SRP Login. Done under host lock to prevent
+ * race with SCSI command submission.
+ * @hostdata:  adapter to adjust
+ * @limit:     new request limit
+ */
+static void ibmvscsi_set_request_limit(struct ibmvscsi_host_data *hostdata, int limit)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(hostdata->host->host_lock, flags);
+       atomic_set(&hostdata->request_limit, limit);
+       spin_unlock_irqrestore(hostdata->host->host_lock, flags);
+}
+
 /**
  * ibmvscsi_reset_host - Reset the connection to the server
  * @hostdata:  struct ibmvscsi_host_data to reset
@@ -813,7 +829,7 @@ static void purge_requests(struct ibmvscsi_host_data *hostdata, int error_code)
 static void ibmvscsi_reset_host(struct ibmvscsi_host_data *hostdata)
 {
        scsi_block_requests(hostdata->host);
-       atomic_set(&hostdata->request_limit, 0);
+       ibmvscsi_set_request_limit(hostdata, 0);
 
        purge_requests(hostdata, DID_ERROR);
        hostdata->action = IBMVSCSI_HOST_ACTION_RESET;
@@ -1146,13 +1162,13 @@ static void login_rsp(struct srp_event_struct *evt_struct)
                dev_info(hostdata->dev, "SRP_LOGIN_REJ reason %u\n",
                         evt_struct->xfer_iu->srp.login_rej.reason);
                /* Login failed.  */
-               atomic_set(&hostdata->request_limit, -1);
+               ibmvscsi_set_request_limit(hostdata, -1);
                return;
        default:
                dev_err(hostdata->dev, "Invalid login response typecode 0x%02x!\n",
                        evt_struct->xfer_iu->srp.login_rsp.opcode);
                /* Login failed.  */
-               atomic_set(&hostdata->request_limit, -1);
+               ibmvscsi_set_request_limit(hostdata, -1);
                return;
        }
 
@@ -1163,7 +1179,7 @@ static void login_rsp(struct srp_event_struct *evt_struct)
         * This value is set rather than added to request_limit because
         * request_limit could have been set to -1 by this client.
         */
-       atomic_set(&hostdata->request_limit,
+       ibmvscsi_set_request_limit(hostdata,
                   be32_to_cpu(evt_struct->xfer_iu->srp.login_rsp.req_lim_delta));
 
        /* If we had any pending I/Os, kick them */
@@ -1195,13 +1211,13 @@ static int send_srp_login(struct ibmvscsi_host_data *hostdata)
        login->req_buf_fmt = cpu_to_be16(SRP_BUF_FORMAT_DIRECT |
                                         SRP_BUF_FORMAT_INDIRECT);
 
-       spin_lock_irqsave(hostdata->host->host_lock, flags);
        /* Start out with a request limit of 0, since this is negotiated in
         * the login request we are just sending and login requests always
         * get sent by the driver regardless of request_limit.
         */
-       atomic_set(&hostdata->request_limit, 0);
+       ibmvscsi_set_request_limit(hostdata, 0);
 
+       spin_lock_irqsave(hostdata->host->host_lock, flags);
        rc = ibmvscsi_send_srp_event(evt_struct, hostdata, login_timeout * 2);
        spin_unlock_irqrestore(hostdata->host->host_lock, flags);
        dev_info(hostdata->dev, "sent SRP login\n");
@@ -1781,7 +1797,7 @@ static void ibmvscsi_handle_crq(struct viosrp_crq *crq,
                return;
        case VIOSRP_CRQ_XPORT_EVENT:    /* Hypervisor telling us the connection is closed */
                scsi_block_requests(hostdata->host);
-               atomic_set(&hostdata->request_limit, 0);
+               ibmvscsi_set_request_limit(hostdata, 0);
                if (crq->format == 0x06) {
                        /* We need to re-setup the interpartition connection */
                        dev_info(hostdata->dev, "Re-enabling adapter!\n");
@@ -2137,12 +2153,12 @@ static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata)
        }
 
        hostdata->action = IBMVSCSI_HOST_ACTION_NONE;
+       spin_unlock_irqrestore(hostdata->host->host_lock, flags);
 
        if (rc) {
-               atomic_set(&hostdata->request_limit, -1);
+               ibmvscsi_set_request_limit(hostdata, -1);
                dev_err(hostdata->dev, "error after %s\n", action);
        }
-       spin_unlock_irqrestore(hostdata->host->host_lock, flags);
 
        scsi_unblock_requests(hostdata->host);
 }
@@ -2226,7 +2242,7 @@ static int ibmvscsi_probe(struct vio_dev *vdev, const struct vio_device_id *id)
        init_waitqueue_head(&hostdata->work_wait_q);
        hostdata->host = host;
        hostdata->dev = dev;
-       atomic_set(&hostdata->request_limit, -1);
+       ibmvscsi_set_request_limit(hostdata, -1);
        hostdata->host->max_sectors = IBMVSCSI_MAX_SECTORS_DEFAULT;
 
        if (map_persist_bufs(hostdata)) {
index 93230cd1982f478780290237939b5acac2d9b690..e4cc92bc4d94f6e5cc488057d51c0128f7138819 100644 (file)
@@ -1740,6 +1740,13 @@ _base_irqpoll(struct irq_poll *irqpoll, int budget)
                reply_q->irq_poll_scheduled = false;
                reply_q->irq_line_enable = true;
                enable_irq(reply_q->os_irq);
+               /*
+                * Go for one more round of processing the
+                * reply descriptor post queue incase if HBA
+                * Firmware has posted some reply descriptors
+                * while reenabling the IRQ.
+                */
+               _base_process_reply_queue(reply_q);
        }
 
        return num_entries;
index 1f90051253136bab14683b0e823800ffdaeca449..b7a1dc24db3806fb5c51e38f5fd17b9e0fdff926 100644 (file)
@@ -554,10 +554,12 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
 
        fcport = qla_rport->fcport;
 
-       if (!qpair || !fcport || (qpair && !qpair->fw_started) ||
-           (fcport && fcport->deleted))
+       if (!qpair || !fcport)
                return -ENODEV;
 
+       if (!qpair->fw_started || fcport->deleted)
+               return -EBUSY;
+
        vha = fcport->vha;
 
        if (!(fcport->nvme_flag & NVME_FLAG_REGISTERED))
index 84f4416d366fbf25baee1af1f56f4e55d2dc2040..bd8623ee156a6c1962ac2dec41c0696101f0dd6c 100644 (file)
@@ -1001,10 +1001,8 @@ qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked)
 {
        ulong flags = 0;
 
-#ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&vha->hw->hardware_lock, flags);
-#endif
        if (!vha->hw->mpi_fw_dump) {
                ql_log(ql_log_warn, vha, 0x02f3, "-> mpi_fwdump no buffer\n");
        } else {
@@ -1050,10 +1048,8 @@ qla27xx_mpi_fwdump(scsi_qla_host_t *vha, int hardware_locked)
        }
 
 bailout:
-#ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
-#endif
 }
 
 void
index f2437a7570ce8b05ea01590dcd5927cf07c92751..9af50e6f94c4c483ea26fc560bc758885b2397ed 100644 (file)
@@ -1714,15 +1714,16 @@ static void scsi_sysfs_add_devices(struct Scsi_Host *shost)
  */
 static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
 {
-       struct async_scan_data *data;
+       struct async_scan_data *data = NULL;
        unsigned long flags;
 
        if (strncmp(scsi_scan_type, "sync", 4) == 0)
                return NULL;
 
+       mutex_lock(&shost->scan_mutex);
        if (shost->async_scan) {
                shost_printk(KERN_DEBUG, shost, "%s called twice\n", __func__);
-               return NULL;
+               goto err;
        }
 
        data = kmalloc(sizeof(*data), GFP_KERNEL);
@@ -1733,7 +1734,6 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
                goto err;
        init_completion(&data->prev_finished);
 
-       mutex_lock(&shost->scan_mutex);
        spin_lock_irqsave(shost->host_lock, flags);
        shost->async_scan = 1;
        spin_unlock_irqrestore(shost->host_lock, flags);
@@ -1748,6 +1748,7 @@ static struct async_scan_data *scsi_prep_async_scan(struct Scsi_Host *shost)
        return data;
 
  err:
+       mutex_unlock(&shost->scan_mutex);
        kfree(data);
        return NULL;
 }
index af2126d2b2ff9fbf797b59c14602da94e4a8cc8e..8afb3f45d2637b6749b0f121931ab77a614ffd9d 100644 (file)
@@ -91,7 +91,7 @@ static struct generic_pm_domain *ti_sci_pd_xlate(
        struct genpd_onecell_data *genpd_data = data;
        unsigned int idx = genpdspec->args[0];
 
-       if (genpdspec->args_count < 2)
+       if (genpdspec->args_count != 1 && genpdspec->args_count != 2)
                return ERR_PTR(-EINVAL);
 
        if (idx >= genpd_data->num_domains) {
index b87116e9b41368d5bf29c6708b28a8426cec2054..7104cf17b8484edee5b689836e8a465ddd4bc764 100644 (file)
@@ -1193,7 +1193,6 @@ static int bcm2835_spi_setup(struct spi_device *spi)
        struct spi_controller *ctlr = spi->controller;
        struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
        struct gpio_chip *chip;
-       enum gpio_lookup_flags lflags;
        u32 cs;
 
        /*
@@ -1259,21 +1258,9 @@ static int bcm2835_spi_setup(struct spi_device *spi)
        if (!chip)
                return 0;
 
-       /*
-        * Retrieve the corresponding GPIO line used for CS.
-        * The inversion semantics will be handled by the GPIO core
-        * code, so we pass GPIOD_OUT_LOW for "unasserted" and
-        * the correct flag for inversion semantics. The SPI_CS_HIGH
-        * on spi->mode cannot be checked for polarity in this case
-        * as the flag use_gpio_descriptors enforces SPI_CS_HIGH.
-        */
-       if (of_property_read_bool(spi->dev.of_node, "spi-cs-high"))
-               lflags = GPIO_ACTIVE_HIGH;
-       else
-               lflags = GPIO_ACTIVE_LOW;
        spi->cs_gpiod = gpiochip_request_own_desc(chip, 8 - spi->chip_select,
                                                  DRV_NAME,
-                                                 lflags,
+                                                 GPIO_LOOKUP_FLAGS_DEFAULT,
                                                  GPIOD_OUT_LOW);
        if (IS_ERR(spi->cs_gpiod))
                return PTR_ERR(spi->cs_gpiod);
index 3967afa465f0ec29e29f361216f87640ab474ec7..1a08c1d584abe08b9b068d0217fe765371ece2cf 100644 (file)
@@ -1080,12 +1080,11 @@ MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids);
 #ifdef CONFIG_PM_SLEEP
 static int dspi_suspend(struct device *dev)
 {
-       struct spi_controller *ctlr = dev_get_drvdata(dev);
-       struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
+       struct fsl_dspi *dspi = dev_get_drvdata(dev);
 
        if (dspi->irq)
                disable_irq(dspi->irq);
-       spi_controller_suspend(ctlr);
+       spi_controller_suspend(dspi->ctlr);
        clk_disable_unprepare(dspi->clk);
 
        pinctrl_pm_select_sleep_state(dev);
@@ -1095,8 +1094,7 @@ static int dspi_suspend(struct device *dev)
 
 static int dspi_resume(struct device *dev)
 {
-       struct spi_controller *ctlr = dev_get_drvdata(dev);
-       struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
+       struct fsl_dspi *dspi = dev_get_drvdata(dev);
        int ret;
 
        pinctrl_pm_select_default_state(dev);
@@ -1104,7 +1102,7 @@ static int dspi_resume(struct device *dev)
        ret = clk_prepare_enable(dspi->clk);
        if (ret)
                return ret;
-       spi_controller_resume(ctlr);
+       spi_controller_resume(dspi->ctlr);
        if (dspi->irq)
                enable_irq(dspi->irq);
 
index 060b1f5c9b048bbc85139d64b88586dd2bd88bec..4b80e27ecdbf9aed3cf4bdecab7e7c0e7f74974e 100644 (file)
@@ -1676,15 +1676,18 @@ static int spi_imx_probe(struct platform_device *pdev)
                goto out_master_put;
        }
 
-       pm_runtime_enable(spi_imx->dev);
+       ret = clk_prepare_enable(spi_imx->clk_per);
+       if (ret)
+               goto out_master_put;
+
+       ret = clk_prepare_enable(spi_imx->clk_ipg);
+       if (ret)
+               goto out_put_per;
+
        pm_runtime_set_autosuspend_delay(spi_imx->dev, MXC_RPM_TIMEOUT);
        pm_runtime_use_autosuspend(spi_imx->dev);
-
-       ret = pm_runtime_get_sync(spi_imx->dev);
-       if (ret < 0) {
-               dev_err(spi_imx->dev, "failed to enable clock\n");
-               goto out_runtime_pm_put;
-       }
+       pm_runtime_set_active(spi_imx->dev);
+       pm_runtime_enable(spi_imx->dev);
 
        spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per);
        /*
@@ -1722,8 +1725,12 @@ out_bitbang_start:
                spi_imx_sdma_exit(spi_imx);
 out_runtime_pm_put:
        pm_runtime_dont_use_autosuspend(spi_imx->dev);
-       pm_runtime_put_sync(spi_imx->dev);
+       pm_runtime_set_suspended(&pdev->dev);
        pm_runtime_disable(spi_imx->dev);
+
+       clk_disable_unprepare(spi_imx->clk_ipg);
+out_put_per:
+       clk_disable_unprepare(spi_imx->clk_per);
 out_master_put:
        spi_master_put(master);
 
index 48ec2ee953dc5dd91b94e0202ce128157126ff15..d740c478277513c73233afce007e239a624d2edc 100644 (file)
@@ -1342,6 +1342,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
                if (dev->irq && board->has_ao_fifo) {
                        dev->write_subdev = s;
                        s->subdev_flags |= SDF_CMD_WRITE;
+                       s->len_chanlist = s->n_chan;
                        s->do_cmdtest   = cb_pcidas_ao_cmdtest;
                        s->do_cmd       = cb_pcidas_ao_cmd;
                        s->cancel       = cb_pcidas_ao_cancel;
index 5b8d0bae9ff3df03cd2c9b86569da79d21811d18..b5fded15e8a69b91039e2f3c934f1e613a8ff561 100644 (file)
@@ -293,7 +293,7 @@ static int controller_probe(struct platform_device *pdev)
        regulator = devm_regulator_register(dev, &can_power_desc, &config);
        if (IS_ERR(regulator)) {
                err = PTR_ERR(regulator);
-               goto out_reset;
+               goto out_ida;
        }
        /* make controller info visible to userspace */
        cd->class_dev = kzalloc(sizeof(*cd->class_dev), GFP_KERNEL);
index cfb673a52b257e68af4512fe0afd756fc5da50f5..0bf545849b119d1a410b385313661e2743cf0db2 100644 (file)
@@ -147,12 +147,6 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
 
        phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
        if (!phy_node && of_phy_is_fixed_link(priv->of_node)) {
-               int rc;
-
-               rc = of_phy_register_fixed_link(priv->of_node);
-               if (rc)
-                       return rc;
-
                phy_node = of_node_get(priv->of_node);
        }
        if (!phy_node)
index 2c16230f993cb01545088025ab74e4d93a44771b..9ebd665e5d4275a46143fdd814e905c30fd595dc 100644 (file)
@@ -69,15 +69,17 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work)
        else
                port = work->word1.cn38xx.ipprt;
 
-       if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64)) {
+       if ((work->word2.snoip.err_code == 10) && (work->word1.len <= 64))
                /*
                 * Ignore length errors on min size packets. Some
                 * equipment incorrectly pads packets to 64+4FCS
                 * instead of 60+4FCS.  Note these packets still get
                 * counted as frame errors.
                 */
-       } else if (work->word2.snoip.err_code == 5 ||
-                  work->word2.snoip.err_code == 7) {
+               return 0;
+
+       if (work->word2.snoip.err_code == 5 ||
+           work->word2.snoip.err_code == 7) {
                /*
                 * We received a packet with either an alignment error
                 * or a FCS error. This may be signalling that we are
@@ -108,7 +110,10 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work)
                                /* Port received 0xd5 preamble */
                                work->packet_ptr.s.addr += i + 1;
                                work->word1.len -= i + 5;
-                       } else if ((*ptr & 0xf) == 0xd) {
+                               return 0;
+                       }
+
+                       if ((*ptr & 0xf) == 0xd) {
                                /* Port received 0xd preamble */
                                work->packet_ptr.s.addr += i;
                                work->word1.len -= i + 4;
@@ -118,21 +123,20 @@ static inline int cvm_oct_check_rcv_error(struct cvmx_wqe *work)
                                            ((*(ptr + 1) & 0xf) << 4);
                                        ptr++;
                                }
-                       } else {
-                               printk_ratelimited("Port %d unknown preamble, packet dropped\n",
-                                                  port);
-                               cvm_oct_free_work(work);
-                               return 1;
+                               return 0;
                        }
+
+                       printk_ratelimited("Port %d unknown preamble, packet dropped\n",
+                                          port);
+                       cvm_oct_free_work(work);
+                       return 1;
                }
-       } else {
-               printk_ratelimited("Port %d receive error code %d, packet dropped\n",
-                                  port, work->word2.snoip.err_code);
-               cvm_oct_free_work(work);
-               return 1;
        }
 
-       return 0;
+       printk_ratelimited("Port %d receive error code %d, packet dropped\n",
+                          port, work->word2.snoip.err_code);
+       cvm_oct_free_work(work);
+       return 1;
 }
 
 static void copy_segments_to_skb(struct cvmx_wqe *work, struct sk_buff *skb)
index 204f0b1e27397e692974491a1b7b166a4bba9153..5dea6e96ec901806beecb1df1931f669e642b247 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/phy.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/of_mdio.h>
 #include <linux/of_net.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
@@ -892,6 +893,14 @@ static int cvm_oct_probe(struct platform_device *pdev)
                                break;
                        }
 
+                       if (priv->of_node && of_phy_is_fixed_link(priv->of_node)) {
+                               if (of_phy_register_fixed_link(priv->of_node)) {
+                                       netdev_err(dev, "Failed to register fixed link for interface %d, port %d\n",
+                                                  interface, priv->port);
+                                       dev->netdev_ops = NULL;
+                               }
+                       }
+
                        if (!dev->netdev_ops) {
                                free_netdev(dev);
                        } else if (register_netdev(dev) < 0) {
index 3a4202551cfca6605a7a3d06a7b3be0f7a2aa1f7..9097bcbd67d8226bc68315235af1de25e09cf5e4 100644 (file)
@@ -179,6 +179,9 @@ struct vchiq_mmal_instance {
 
        /* ordered workqueue to process all bulk operations */
        struct workqueue_struct *bulk_wq;
+
+       /* handle for a vchiq instance */
+       struct vchiq_instance *vchiq_instance;
 };
 
 static struct mmal_msg_context *
@@ -1840,6 +1843,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
 
        mutex_unlock(&instance->vchiq_mutex);
 
+       vchiq_shutdown(instance->vchiq_instance);
        flush_workqueue(instance->bulk_wq);
        destroy_workqueue(instance->bulk_wq);
 
@@ -1856,6 +1860,7 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_finalise);
 int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
 {
        int status;
+       int err = -ENODEV;
        struct vchiq_mmal_instance *instance;
        static struct vchiq_instance *vchiq_instance;
        struct vchiq_service_params_kernel params = {
@@ -1890,17 +1895,21 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
        status = vchiq_connect(vchiq_instance);
        if (status) {
                pr_err("Failed to connect VCHI instance (status=%d)\n", status);
-               return -EIO;
+               err = -EIO;
+               goto err_shutdown_vchiq;
        }
 
        instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 
-       if (!instance)
-               return -ENOMEM;
+       if (!instance) {
+               err = -ENOMEM;
+               goto err_shutdown_vchiq;
+       }
 
        mutex_init(&instance->vchiq_mutex);
 
        instance->bulk_scratch = vmalloc(PAGE_SIZE);
+       instance->vchiq_instance = vchiq_instance;
 
        mutex_init(&instance->context_map_lock);
        idr_init_base(&instance->context_map, 1);
@@ -1932,7 +1941,9 @@ err_close_services:
 err_free:
        vfree(instance->bulk_scratch);
        kfree(instance);
-       return -ENODEV;
+err_shutdown_vchiq:
+       vchiq_shutdown(vchiq_instance);
+       return err;
 }
 EXPORT_SYMBOL_GPL(vchiq_mmal_init);
 
index 43b5630c0407a29daa9688fe016cd482829a1b2d..510edd12ed19249559ae1b6e8ed11a0810053ad5 100644 (file)
@@ -24,7 +24,7 @@ description:
     In addition, it is recommended to declare a mmc-pwrseq on SDIO host above
     WFx. Without it, you may encounter issues with warm boot. The mmc-pwrseq
     should be compatible with mmc-pwrseq-simple. Please consult
-    Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.txt for more
+    Documentation/devicetree/bindings/mmc/mmc-pwrseq-simple.yaml for more
     information.
 
   For SPI':'
index 2ffa587aefaa7710f25a67953b6b74d690825b87..ed53d0b455927d7387add3f913c16a4761b48924 100644 (file)
@@ -21,7 +21,7 @@ static void device_wakeup(struct wfx_dev *wdev)
 
        if (!wdev->pdata.gpio_wakeup)
                return;
-       if (gpiod_get_value_cansleep(wdev->pdata.gpio_wakeup) >= 0)
+       if (gpiod_get_value_cansleep(wdev->pdata.gpio_wakeup) > 0)
                return;
 
        if (wfx_api_older_than(wdev, 1, 4)) {
index 41f6a604a697a3966a9558886548400f157f4bd3..36b36ef39d053ce88b60d5a729380224556f3273 100644 (file)
@@ -31,13 +31,13 @@ static int wfx_get_hw_rate(struct wfx_dev *wdev,
                }
                return rate->idx + 14;
        }
+       // WFx only support 2GHz, else band information should be retrieved
+       // from ieee80211_tx_info
+       band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
        if (rate->idx >= band->n_bitrates) {
                WARN(1, "wrong rate->idx value: %d", rate->idx);
                return -1;
        }
-       // WFx only support 2GHz, else band information should be retrieved
-       // from ieee80211_tx_info
-       band = wdev->hw->wiphy->bands[NL80211_BAND_2GHZ];
        return band->bitrates[rate->idx].hw_value;
 }
 
index ea84d08747df3749f878867228b5559c7c164674..590e6d072228109fbec0c37ea73662de7b5aa9a3 100644 (file)
@@ -194,7 +194,7 @@ struct tcmu_tmr {
 
        uint8_t tmr_type;
        uint32_t tmr_cmd_cnt;
-       int16_t tmr_cmd_ids[0];
+       int16_t tmr_cmd_ids[];
 };
 
 /*
index f53bf336c0a2025cf49c2ab017b7dfb1c4fce7dc..6ade4a5c4840789829fbd28b7825aad3742d9dc5 100644 (file)
@@ -200,7 +200,8 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
        int name_len;
        int rc;
 
-       if (connection_method == TEE_IOCTL_LOGIN_PUBLIC) {
+       if (connection_method == TEE_IOCTL_LOGIN_PUBLIC ||
+           connection_method == TEE_IOCTL_LOGIN_REE_KERNEL) {
                /* Nil UUID to be passed to TEE environment */
                uuid_copy(uuid, &uuid_null);
                return 0;
index 718e010fcb04855ef8eed6c3ce2193ecbcf62072..09baef4ccc39ae7fb4fcfd894b5b3dc838e05b2a 100644 (file)
@@ -50,25 +50,25 @@ static const char serial21285_name[] = "Footbridge UART";
 
 static bool is_enabled(struct uart_port *port, int bit)
 {
-       unsigned long private_data = (unsigned long)port->private_data;
+       unsigned long *private_data = (unsigned long *)&port->private_data;
 
-       if (test_bit(bit, &private_data))
+       if (test_bit(bit, private_data))
                return true;
        return false;
 }
 
 static void enable(struct uart_port *port, int bit)
 {
-       unsigned long private_data = (unsigned long)port->private_data;
+       unsigned long *private_data = (unsigned long *)&port->private_data;
 
-       set_bit(bit, &private_data);
+       set_bit(bit, private_data);
 }
 
 static void disable(struct uart_port *port, int bit)
 {
-       unsigned long private_data = (unsigned long)port->private_data;
+       unsigned long *private_data = (unsigned long *)&port->private_data;
 
-       clear_bit(bit, &private_data);
+       clear_bit(bit, private_data);
 }
 
 #define is_tx_enabled(port)    is_enabled(port, tx_enabled_bit)
index 41f4120abdf291b43f4a056d09c869c9e518c1f7..fa876e2c13e5dcc2d028eda6fdeae4b125852701 100644 (file)
@@ -317,7 +317,7 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
         */
        baud = tty_termios_baud_rate(termios);
 
-       serial8250_do_set_termios(port, termios, old);
+       serial8250_do_set_termios(port, termios, NULL);
 
        tty_termios_encode_baud_rate(termios, baud, baud);
 
index 1044fc3876914a0d50847bae629a5a0c3de8bc04..28f22e58639c6c18c17c1a0f9af03da40b600b41 100644 (file)
@@ -522,6 +522,7 @@ config SERIAL_IMX_EARLYCON
        depends on OF
        select SERIAL_EARLYCON
        select SERIAL_CORE_CONSOLE
+       default y if SERIAL_IMX_CONSOLE
        help
          If you have enabled the earlycon on the Freescale IMX
          CPU you can make it the earlycon by answering Y to this option.
index ff4b88c637d0e3021077add0632b34f8029efce8..bd047e1f9bea71f982b4d743b3dc1cc7c60887f4 100644 (file)
@@ -314,9 +314,10 @@ MODULE_DEVICE_TABLE(of, lpuart_dt_ids);
 /* Forward declare this for the dma callbacks*/
 static void lpuart_dma_tx_complete(void *arg);
 
-static inline bool is_ls1028a_lpuart(struct lpuart_port *sport)
+static inline bool is_layerscape_lpuart(struct lpuart_port *sport)
 {
-       return sport->devtype == LS1028A_LPUART;
+       return (sport->devtype == LS1021A_LPUART ||
+               sport->devtype == LS1028A_LPUART);
 }
 
 static inline bool is_imx8qxp_lpuart(struct lpuart_port *sport)
@@ -1701,11 +1702,11 @@ static int lpuart32_startup(struct uart_port *port)
                                            UARTFIFO_FIFOSIZE_MASK);
 
        /*
-        * The LS1028A has a fixed length of 16 words. Although it supports the
-        * RX/TXSIZE fields their encoding is different. Eg the reference manual
-        * states 0b101 is 16 words.
+        * The LS1021A and LS1028A have a fixed FIFO depth of 16 words.
+        * Although they support the RX/TXSIZE fields, their encoding is
+        * different. Eg the reference manual states 0b101 is 16 words.
         */
-       if (is_ls1028a_lpuart(sport)) {
+       if (is_layerscape_lpuart(sport)) {
                sport->rxfifo_size = 16;
                sport->txfifo_size = 16;
                sport->port.fifosize = sport->txfifo_size;
index b4d89e31730e3ab548303ef164f21ebbc30481b0..7a07e7272de1258d2bf48066ccd7d0e467a3244e 100644 (file)
@@ -1280,6 +1280,9 @@ static int __init serial_txx9_init(void)
 
 #ifdef ENABLE_SERIAL_TXX9_PCI
        ret = pci_register_driver(&serial_txx9_pci_driver);
+       if (ret) {
+               platform_driver_unregister(&serial_txx9_plat_driver);
+       }
 #endif
        if (ret == 0)
                goto out;
index 7a4c02548fb3fba74ae1542ce8e72ded414e618d..9f8b9a567b35991665ad299e5296c2fefe5f6dbf 100644 (file)
@@ -1515,10 +1515,12 @@ static void release_tty(struct tty_struct *tty, int idx)
                tty->ops->shutdown(tty);
        tty_save_termios(tty);
        tty_driver_remove_tty(tty->driver, tty);
-       tty->port->itty = NULL;
+       if (tty->port)
+               tty->port->itty = NULL;
        if (tty->link)
                tty->link->port->itty = NULL;
-       tty_buffer_cancel_work(tty->port);
+       if (tty->port)
+               tty_buffer_cancel_work(tty->port);
        if (tty->link)
                tty_buffer_cancel_work(tty->link->port);
 
index 0db53b5b3acf6b7d33338b659c81b586e841804f..78acc270e39ac6ab269eb993a76cd3ce8eb104ec 100644 (file)
@@ -743,8 +743,13 @@ static void k_fn(struct vc_data *vc, unsigned char value, char up_flag)
                return;
 
        if ((unsigned)value < ARRAY_SIZE(func_table)) {
+               unsigned long flags;
+
+               spin_lock_irqsave(&func_buf_lock, flags);
                if (func_table[value])
                        puts_queue(vc, func_table[value]);
+               spin_unlock_irqrestore(&func_buf_lock, flags);
+
        } else
                pr_err("k_fn called with value=%d\n", value);
 }
@@ -1991,13 +1996,11 @@ out:
 #undef s
 #undef v
 
-/* FIXME: This one needs untangling and locking */
+/* FIXME: This one needs untangling */
 int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
 {
        struct kbsentry *kbs;
-       char *p;
        u_char *q;
-       u_char __user *up;
        int sz, fnw_sz;
        int delta;
        char *first_free, *fj, *fnw;
@@ -2023,23 +2026,19 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
        i = array_index_nospec(kbs->kb_func, MAX_NR_FUNC);
 
        switch (cmd) {
-       case KDGKBSENT:
-               sz = sizeof(kbs->kb_string) - 1; /* sz should have been
-                                                 a struct member */
-               up = user_kdgkb->kb_string;
-               p = func_table[i];
-               if(p)
-                       for ( ; *p && sz; p++, sz--)
-                               if (put_user(*p, up++)) {
-                                       ret = -EFAULT;
-                                       goto reterr;
-                               }
-               if (put_user('\0', up)) {
-                       ret = -EFAULT;
-                       goto reterr;
-               }
-               kfree(kbs);
-               return ((p && *p) ? -EOVERFLOW : 0);
+       case KDGKBSENT: {
+               /* size should have been a struct member */
+               ssize_t len = sizeof(user_kdgkb->kb_string);
+
+               spin_lock_irqsave(&func_buf_lock, flags);
+               len = strlcpy(kbs->kb_string, func_table[i] ? : "", len);
+               spin_unlock_irqrestore(&func_buf_lock, flags);
+
+               ret = copy_to_user(user_kdgkb->kb_string, kbs->kb_string,
+                               len + 1) ? -EFAULT : 0;
+
+               goto reterr;
+       }
        case KDSKBSENT:
                if (!perm) {
                        ret = -EPERM;
index 9506a76f3ab67fc7333be5834fea5408ddf72f7a..d04a162939a4d527306bf7b1312306f1900184ef 100644 (file)
@@ -4704,27 +4704,6 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
        return rc;
 }
 
-static int con_font_copy(struct vc_data *vc, struct console_font_op *op)
-{
-       int con = op->height;
-       int rc;
-
-
-       console_lock();
-       if (vc->vc_mode != KD_TEXT)
-               rc = -EINVAL;
-       else if (!vc->vc_sw->con_font_copy)
-               rc = -ENOSYS;
-       else if (con < 0 || !vc_cons_allocated(con))
-               rc = -ENOTTY;
-       else if (con == vc->vc_num)     /* nothing to do */
-               rc = 0;
-       else
-               rc = vc->vc_sw->con_font_copy(vc, con);
-       console_unlock();
-       return rc;
-}
-
 int con_font_op(struct vc_data *vc, struct console_font_op *op)
 {
        switch (op->op) {
@@ -4735,7 +4714,8 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op)
        case KD_FONT_OP_SET_DEFAULT:
                return con_font_default(vc, op);
        case KD_FONT_OP_COPY:
-               return con_font_copy(vc, op);
+               /* was buggy and never really used */
+               return -EINVAL;
        }
        return -ENOSYS;
 }
index 0a33b8ababe38fbb2c8e7b16fda2e5789a0f249a..5f61b25a9aaa89208bd565e51c44ff2fde530620 100644 (file)
@@ -484,7 +484,7 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd,
        return 0;
 }
 
-static inline int do_fontx_ioctl(int cmd,
+static inline int do_fontx_ioctl(struct vc_data *vc, int cmd,
                struct consolefontdesc __user *user_cfd,
                struct console_font_op *op)
 {
@@ -502,15 +502,16 @@ static inline int do_fontx_ioctl(int cmd,
                op->height = cfdarg.charheight;
                op->charcount = cfdarg.charcount;
                op->data = cfdarg.chardata;
-               return con_font_op(vc_cons[fg_console].d, op);
-       case GIO_FONTX: {
+               return con_font_op(vc, op);
+
+       case GIO_FONTX:
                op->op = KD_FONT_OP_GET;
                op->flags = KD_FONT_FLAG_OLD;
                op->width = 8;
                op->height = cfdarg.charheight;
                op->charcount = cfdarg.charcount;
                op->data = cfdarg.chardata;
-               i = con_font_op(vc_cons[fg_console].d, op);
+               i = con_font_op(vc, op);
                if (i)
                        return i;
                cfdarg.charheight = op->height;
@@ -518,12 +519,11 @@ static inline int do_fontx_ioctl(int cmd,
                if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc)))
                        return -EFAULT;
                return 0;
-               }
        }
        return -EINVAL;
 }
 
-static int vt_io_fontreset(struct console_font_op *op)
+static int vt_io_fontreset(struct vc_data *vc, struct console_font_op *op)
 {
        int ret;
 
@@ -537,19 +537,19 @@ static int vt_io_fontreset(struct console_font_op *op)
 
        op->op = KD_FONT_OP_SET_DEFAULT;
        op->data = NULL;
-       ret = con_font_op(vc_cons[fg_console].d, op);
+       ret = con_font_op(vc, op);
        if (ret)
                return ret;
 
        console_lock();
-       con_set_default_unimap(vc_cons[fg_console].d);
+       con_set_default_unimap(vc);
        console_unlock();
 
        return 0;
 }
 
 static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud,
-               struct vc_data *vc)
+               bool perm, struct vc_data *vc)
 {
        struct unimapdesc tmp;
 
@@ -557,9 +557,11 @@ static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud,
                return -EFAULT;
        switch (cmd) {
        case PIO_UNIMAP:
+               if (!perm)
+                       return -EPERM;
                return con_set_unimap(vc, tmp.entry_ct, tmp.entries);
        case GIO_UNIMAP:
-               if (fg_console != vc->vc_num)
+               if (!perm && fg_console != vc->vc_num)
                        return -EPERM;
                return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
                                tmp.entries);
@@ -582,7 +584,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
                op.height = 0;
                op.charcount = 256;
                op.data = up;
-               return con_font_op(vc_cons[fg_console].d, &op);
+               return con_font_op(vc, &op);
 
        case GIO_FONT:
                op.op = KD_FONT_OP_GET;
@@ -591,7 +593,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
                op.height = 32;
                op.charcount = 256;
                op.data = up;
-               return con_font_op(vc_cons[fg_console].d, &op);
+               return con_font_op(vc, &op);
 
        case PIO_CMAP:
                 if (!perm)
@@ -607,13 +609,13 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
 
                fallthrough;
        case GIO_FONTX:
-               return do_fontx_ioctl(cmd, up, &op);
+               return do_fontx_ioctl(vc, cmd, up, &op);
 
        case PIO_FONTRESET:
                if (!perm)
                        return -EPERM;
 
-               return vt_io_fontreset(&op);
+               return vt_io_fontreset(vc, &op);
 
        case PIO_SCRNMAP:
                if (!perm)
@@ -639,10 +641,7 @@ static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
 
        case PIO_UNIMAP:
        case GIO_UNIMAP:
-               if (!perm)
-                       return -EPERM;
-
-               return do_unimap_ioctl(cmd, up, vc);
+               return do_unimap_ioctl(cmd, up, perm, vc);
 
        default:
                return -ENOIOCTLCMD;
@@ -1067,8 +1066,9 @@ struct compat_consolefontdesc {
 };
 
 static inline int
-compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
-                        int perm, struct console_font_op *op)
+compat_fontx_ioctl(struct vc_data *vc, int cmd,
+                  struct compat_consolefontdesc __user *user_cfd,
+                  int perm, struct console_font_op *op)
 {
        struct compat_consolefontdesc cfdarg;
        int i;
@@ -1086,7 +1086,8 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
                op->height = cfdarg.charheight;
                op->charcount = cfdarg.charcount;
                op->data = compat_ptr(cfdarg.chardata);
-               return con_font_op(vc_cons[fg_console].d, op);
+               return con_font_op(vc, op);
+
        case GIO_FONTX:
                op->op = KD_FONT_OP_GET;
                op->flags = KD_FONT_FLAG_OLD;
@@ -1094,7 +1095,7 @@ compat_fontx_ioctl(int cmd, struct compat_consolefontdesc __user *user_cfd,
                op->height = cfdarg.charheight;
                op->charcount = cfdarg.charcount;
                op->data = compat_ptr(cfdarg.chardata);
-               i = con_font_op(vc_cons[fg_console].d, op);
+               i = con_font_op(vc, op);
                if (i)
                        return i;
                cfdarg.charheight = op->height;
@@ -1184,7 +1185,7 @@ long vt_compat_ioctl(struct tty_struct *tty,
         */
        case PIO_FONTX:
        case GIO_FONTX:
-               return compat_fontx_ioctl(cmd, up, perm, &op);
+               return compat_fontx_ioctl(vc, cmd, up, perm, &op);
 
        case KDFONTOP:
                return compat_kdfontop_ioctl(up, perm, &op, vc);
index 4761c852d9c4b8bc686206669f3a72cefd229185..d3121a32cc68cfc25bec49668285ef03d3458b7d 100644 (file)
@@ -137,48 +137,36 @@ static int cdns3_req_ep0_set_configuration(struct cdns3_device *priv_dev,
                                           struct usb_ctrlrequest *ctrl_req)
 {
        enum usb_device_state device_state = priv_dev->gadget.state;
-       struct cdns3_endpoint *priv_ep;
        u32 config = le16_to_cpu(ctrl_req->wValue);
        int result = 0;
-       int i;
 
        switch (device_state) {
        case USB_STATE_ADDRESS:
-               /* Configure non-control EPs */
-               for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) {
-                       priv_ep = priv_dev->eps[i];
-                       if (!priv_ep)
-                               continue;
-
-                       if (priv_ep->flags & EP_CLAIMED)
-                               cdns3_ep_config(priv_ep);
-               }
-
                result = cdns3_ep0_delegate_req(priv_dev, ctrl_req);
 
-               if (result)
-                       return result;
-
-               if (!config) {
-                       cdns3_hw_reset_eps_config(priv_dev);
-                       usb_gadget_set_state(&priv_dev->gadget,
-                                            USB_STATE_ADDRESS);
-               }
+               if (result || !config)
+                       goto reset_config;
 
                break;
        case USB_STATE_CONFIGURED:
                result = cdns3_ep0_delegate_req(priv_dev, ctrl_req);
+               if (!config && !result)
+                       goto reset_config;
 
-               if (!config && !result) {
-                       cdns3_hw_reset_eps_config(priv_dev);
-                       usb_gadget_set_state(&priv_dev->gadget,
-                                            USB_STATE_ADDRESS);
-               }
                break;
        default:
-               result = -EINVAL;
+               return -EINVAL;
        }
 
+       return 0;
+
+reset_config:
+       if (result != USB_GADGET_DELAYED_STATUS)
+               cdns3_hw_reset_eps_config(priv_dev);
+
+       usb_gadget_set_state(&priv_dev->gadget,
+                            USB_STATE_ADDRESS);
+
        return result;
 }
 
@@ -705,6 +693,7 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
        unsigned long flags;
        int ret = 0;
        u8 zlp = 0;
+       int i;
 
        spin_lock_irqsave(&priv_dev->lock, flags);
        trace_cdns3_ep0_queue(priv_dev, request);
@@ -720,6 +709,17 @@ static int cdns3_gadget_ep0_queue(struct usb_ep *ep,
                u32 val;
 
                cdns3_select_ep(priv_dev, 0x00);
+
+               /*
+                * Configure all non-control EPs which are not enabled by class driver
+                */
+               for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++) {
+                       priv_ep = priv_dev->eps[i];
+                       if (priv_ep && priv_ep->flags & EP_CLAIMED &&
+                           !(priv_ep->flags & EP_ENABLED))
+                               cdns3_ep_config(priv_ep, 0);
+               }
+
                cdns3_set_hw_configuration(priv_dev);
                cdns3_ep0_complete_setup(priv_dev, 0, 1);
                /* wait until configuration set */
@@ -811,6 +811,7 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev)
        struct cdns3_usb_regs __iomem *regs;
        struct cdns3_endpoint *priv_ep;
        u32 max_packet_size = 64;
+       u32 ep_cfg;
 
        regs = priv_dev->regs;
 
@@ -842,8 +843,10 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev)
                                       BIT(0) | BIT(16));
        }
 
-       writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size),
-              &regs->ep_cfg);
+       ep_cfg = EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size);
+
+       if (!(priv_ep->flags & EP_CONFIGURED))
+               writel(ep_cfg, &regs->ep_cfg);
 
        writel(EP_STS_EN_SETUPEN | EP_STS_EN_DESCMISEN | EP_STS_EN_TRBERREN,
               &regs->ep_sts_en);
@@ -851,8 +854,10 @@ void cdns3_ep0_config(struct cdns3_device *priv_dev)
        /* init ep in */
        cdns3_select_ep(priv_dev, USB_DIR_IN);
 
-       writel(EP_CFG_ENABLE | EP_CFG_MAXPKTSIZE(max_packet_size),
-              &regs->ep_cfg);
+       if (!(priv_ep->flags & EP_CONFIGURED))
+               writel(ep_cfg, &regs->ep_cfg);
+
+       priv_ep->flags |= EP_CONFIGURED;
 
        writel(EP_STS_EN_SETUPEN | EP_STS_EN_TRBERREN, &regs->ep_sts_en);
 
index 6e7b70a2e352b9d5ed2dd58d1f23438c787ef853..66c1e6723eb1876871f85c0d36f4c15dc83eb90e 100644 (file)
@@ -296,6 +296,8 @@ static void cdns3_ep_stall_flush(struct cdns3_endpoint *priv_ep)
  */
 void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev)
 {
+       int i;
+
        writel(USB_CONF_CFGRST, &priv_dev->regs->usb_conf);
 
        cdns3_allow_enable_l1(priv_dev, 0);
@@ -304,6 +306,10 @@ void cdns3_hw_reset_eps_config(struct cdns3_device *priv_dev)
        priv_dev->out_mem_is_allocated = 0;
        priv_dev->wait_for_setup = 0;
        priv_dev->using_streams = 0;
+
+       for (i = 0; i < CDNS3_ENDPOINTS_MAX_COUNT; i++)
+               if (priv_dev->eps[i])
+                       priv_dev->eps[i]->flags &= ~EP_CONFIGURED;
 }
 
 /**
@@ -506,7 +512,6 @@ static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep,
 
        while (!list_empty(&priv_ep->wa2_descmiss_req_list)) {
                int chunk_end;
-               int length;
 
                descmiss_priv_req =
                        cdns3_next_priv_request(&priv_ep->wa2_descmiss_req_list);
@@ -517,7 +522,6 @@ static void cdns3_wa2_descmiss_copy_data(struct cdns3_endpoint *priv_ep,
                        break;
 
                chunk_end = descmiss_priv_req->flags & REQUEST_INTERNAL_CH;
-               length = request->actual + descmiss_req->actual;
                request->status = descmiss_req->status;
                __cdns3_descmiss_copy_data(request, descmiss_req);
                list_del_init(&descmiss_priv_req->list);
@@ -1746,11 +1750,8 @@ static int cdns3_check_ep_interrupt_proceed(struct cdns3_endpoint *priv_ep)
 
 static void cdns3_disconnect_gadget(struct cdns3_device *priv_dev)
 {
-       if (priv_dev->gadget_driver && priv_dev->gadget_driver->disconnect) {
-               spin_unlock(&priv_dev->lock);
+       if (priv_dev->gadget_driver && priv_dev->gadget_driver->disconnect)
                priv_dev->gadget_driver->disconnect(&priv_dev->gadget);
-               spin_lock(&priv_dev->lock);
-       }
 }
 
 /**
@@ -1761,6 +1762,7 @@ static void cdns3_disconnect_gadget(struct cdns3_device *priv_dev)
  */
 static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev,
                                              u32 usb_ists)
+__must_hold(&priv_dev->lock)
 {
        int speed = 0;
 
@@ -1785,7 +1787,9 @@ static void cdns3_check_usb_interrupt_proceed(struct cdns3_device *priv_dev,
 
        /* Disconnection detected */
        if (usb_ists & (USB_ISTS_DIS2I | USB_ISTS_DISI)) {
+               spin_unlock(&priv_dev->lock);
                cdns3_disconnect_gadget(priv_dev);
+               spin_lock(&priv_dev->lock);
                priv_dev->gadget.speed = USB_SPEED_UNKNOWN;
                usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED);
                cdns3_hw_reset_eps_config(priv_dev);
@@ -1979,27 +1983,6 @@ static int cdns3_ep_onchip_buffer_reserve(struct cdns3_device *priv_dev,
        return 0;
 }
 
-static void cdns3_stream_ep_reconfig(struct cdns3_device *priv_dev,
-                                    struct cdns3_endpoint *priv_ep)
-{
-       if (!priv_ep->use_streams || priv_dev->gadget.speed < USB_SPEED_SUPER)
-               return;
-
-       if (priv_dev->dev_ver >= DEV_VER_V3) {
-               u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0));
-
-               /*
-                * Stream capable endpoints are handled by using ep_tdl
-                * register. Other endpoints use TDL from TRB feature.
-                */
-               cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb, mask);
-       }
-
-       /*  Enable Stream Bit TDL chk and SID chk */
-       cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_STREAM_EN |
-                              EP_CFG_TDL_CHK | EP_CFG_SID_CHK);
-}
-
 static void cdns3_configure_dmult(struct cdns3_device *priv_dev,
                                  struct cdns3_endpoint *priv_ep)
 {
@@ -2037,8 +2020,9 @@ static void cdns3_configure_dmult(struct cdns3_device *priv_dev,
 /**
  * cdns3_ep_config Configure hardware endpoint
  * @priv_ep: extended endpoint object
+ * @enable: set EP_CFG_ENABLE bit in ep_cfg register.
  */
-void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
+int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable)
 {
        bool is_iso_ep = (priv_ep->type == USB_ENDPOINT_XFER_ISOC);
        struct cdns3_device *priv_dev = priv_ep->cdns3_dev;
@@ -2099,7 +2083,7 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
                break;
        default:
                /* all other speed are not supported */
-               return;
+               return -EINVAL;
        }
 
        if (max_packet_size == 1024)
@@ -2109,11 +2093,33 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
        else
                priv_ep->trb_burst_size = 16;
 
-       ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1,
-                                            !!priv_ep->dir);
-       if (ret) {
-               dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n");
-               return;
+       /* onchip buffer is only allocated before configuration */
+       if (!priv_dev->hw_configured_flag) {
+               ret = cdns3_ep_onchip_buffer_reserve(priv_dev, buffering + 1,
+                                                    !!priv_ep->dir);
+               if (ret) {
+                       dev_err(priv_dev->dev, "onchip mem is full, ep is invalid\n");
+                       return ret;
+               }
+       }
+
+       if (enable)
+               ep_cfg |= EP_CFG_ENABLE;
+
+       if (priv_ep->use_streams && priv_dev->gadget.speed >= USB_SPEED_SUPER) {
+               if (priv_dev->dev_ver >= DEV_VER_V3) {
+                       u32 mask = BIT(priv_ep->num + (priv_ep->dir ? 16 : 0));
+
+                       /*
+                        * Stream capable endpoints are handled by using ep_tdl
+                        * register. Other endpoints use TDL from TRB feature.
+                        */
+                       cdns3_clear_register_bit(&priv_dev->regs->tdl_from_trb,
+                                                mask);
+               }
+
+               /*  Enable Stream Bit TDL chk and SID chk */
+               ep_cfg |=  EP_CFG_STREAM_EN | EP_CFG_TDL_CHK | EP_CFG_SID_CHK;
        }
 
        ep_cfg |= EP_CFG_MAXPKTSIZE(max_packet_size) |
@@ -2123,9 +2129,12 @@ void cdns3_ep_config(struct cdns3_endpoint *priv_ep)
 
        cdns3_select_ep(priv_dev, bEndpointAddress);
        writel(ep_cfg, &priv_dev->regs->ep_cfg);
+       priv_ep->flags |= EP_CONFIGURED;
 
        dev_dbg(priv_dev->dev, "Configure %s: with val %08x\n",
                priv_ep->name, ep_cfg);
+
+       return 0;
 }
 
 /* Find correct direction for HW endpoint according to description */
@@ -2266,7 +2275,7 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
        u32 bEndpointAddress;
        unsigned long flags;
        int enable = 1;
-       int ret;
+       int ret = 0;
        int val;
 
        priv_ep = ep_to_cdns3_ep(ep);
@@ -2305,6 +2314,17 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
        bEndpointAddress = priv_ep->num | priv_ep->dir;
        cdns3_select_ep(priv_dev, bEndpointAddress);
 
+       /*
+        * For some versions of controller at some point during ISO OUT traffic
+        * DMA reads Transfer Ring for the EP which has never got doorbell.
+        * This issue was detected only on simulation, but to avoid this issue
+        * driver add protection against it. To fix it driver enable ISO OUT
+        * endpoint before setting DRBL. This special treatment of ISO OUT
+        * endpoints are recommended by controller specification.
+        */
+       if (priv_ep->type == USB_ENDPOINT_XFER_ISOC  && !priv_ep->dir)
+               enable = 0;
+
        if (usb_ss_max_streams(comp_desc) && usb_endpoint_xfer_bulk(desc)) {
                /*
                 * Enable stream support (SS mode) related interrupts
@@ -2315,13 +2335,17 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
                                EP_STS_EN_SIDERREN | EP_STS_EN_MD_EXITEN |
                                EP_STS_EN_STREAMREN;
                        priv_ep->use_streams = true;
-                       cdns3_stream_ep_reconfig(priv_dev, priv_ep);
+                       ret = cdns3_ep_config(priv_ep, enable);
                        priv_dev->using_streams |= true;
                }
+       } else {
+               ret = cdns3_ep_config(priv_ep, enable);
        }
 
-       ret = cdns3_allocate_trb_pool(priv_ep);
+       if (ret)
+               goto exit;
 
+       ret = cdns3_allocate_trb_pool(priv_ep);
        if (ret)
                goto exit;
 
@@ -2351,20 +2375,6 @@ static int cdns3_gadget_ep_enable(struct usb_ep *ep,
 
        writel(reg, &priv_dev->regs->ep_sts_en);
 
-       /*
-        * For some versions of controller at some point during ISO OUT traffic
-        * DMA reads Transfer Ring for the EP which has never got doorbell.
-        * This issue was detected only on simulation, but to avoid this issue
-        * driver add protection against it. To fix it driver enable ISO OUT
-        * endpoint before setting DRBL. This special treatment of ISO OUT
-        * endpoints are recommended by controller specification.
-        */
-       if (priv_ep->type == USB_ENDPOINT_XFER_ISOC  && !priv_ep->dir)
-               enable = 0;
-
-       if (enable)
-               cdns3_set_register_bit(&priv_dev->regs->ep_cfg, EP_CFG_ENABLE);
-
        ep->desc = desc;
        priv_ep->flags &= ~(EP_PENDING_REQUEST | EP_STALLED | EP_STALL_PENDING |
                            EP_QUIRK_ISO_OUT_EN | EP_QUIRK_EXTRA_BUF_EN);
@@ -3265,10 +3275,13 @@ err0:
 }
 
 static int cdns3_gadget_suspend(struct cdns3 *cdns, bool do_wakeup)
+__must_hold(&cdns->lock)
 {
        struct cdns3_device *priv_dev = cdns->gadget_dev;
 
+       spin_unlock(&cdns->lock);
        cdns3_disconnect_gadget(priv_dev);
+       spin_lock(&cdns->lock);
 
        priv_dev->gadget.speed = USB_SPEED_UNKNOWN;
        usb_gadget_set_state(&priv_dev->gadget, USB_STATE_NOTATTACHED);
index 1ccecd23753034edda19df66ab31910c4e14f752..21fa461c518ec269258012ff5ba6e35e79a18906 100644 (file)
@@ -1072,7 +1072,7 @@ struct cdns3_trb {
 #define TRB_TDL_SS_SIZE_GET(p) (((p) & GENMASK(23, 17)) >> 17)
 
 /* transfer_len bitmasks - bits 31:24 */
-#define TRB_BURST_LEN(p)       (((p) << 24) & GENMASK(31, 24))
+#define TRB_BURST_LEN(p)       ((unsigned int)((p) << 24) & GENMASK(31, 24))
 #define TRB_BURST_LEN_GET(p)   (((p) & GENMASK(31, 24)) >> 24)
 
 /* Data buffer pointer bitmasks*/
@@ -1159,6 +1159,7 @@ struct cdns3_endpoint {
 #define EP_QUIRK_EXTRA_BUF_DET BIT(12)
 #define EP_QUIRK_EXTRA_BUF_EN  BIT(13)
 #define EP_TDLCHK_EN           BIT(15)
+#define EP_CONFIGURED          BIT(16)
        u32                     flags;
 
        struct cdns3_request    *descmis_req;
@@ -1360,7 +1361,7 @@ void cdns3_gadget_giveback(struct cdns3_endpoint *priv_ep,
 int cdns3_init_ep0(struct cdns3_device *priv_dev,
                   struct cdns3_endpoint *priv_ep);
 void cdns3_ep0_config(struct cdns3_device *priv_dev);
-void cdns3_ep_config(struct cdns3_endpoint *priv_ep);
+int cdns3_ep_config(struct cdns3_endpoint *priv_ep, bool enable);
 void cdns3_check_ep0_interrupt_proceed(struct cdns3_device *priv_dev, int dir);
 int __cdns3_gadget_wakeup(struct cdns3_device *priv_dev);
 
index 30ef946a8e1a58964c28174ce0c34a0f9454ecaa..1e756886791021328bc4be45906acfa35b38fc8e 100644 (file)
@@ -508,6 +508,7 @@ static void acm_read_bulk_callback(struct urb *urb)
                        "%s - cooling babbling device\n", __func__);
                usb_mark_last_busy(acm->dev);
                set_bit(rb->index, &acm->urbs_in_error_delay);
+               set_bit(ACM_ERROR_DELAY, &acm->flags);
                cooldown = true;
                break;
        default:
@@ -533,7 +534,7 @@ static void acm_read_bulk_callback(struct urb *urb)
 
        if (stopped || stalled || cooldown) {
                if (stalled)
-                       schedule_work(&acm->work);
+                       schedule_delayed_work(&acm->dwork, 0);
                else if (cooldown)
                        schedule_delayed_work(&acm->dwork, HZ / 2);
                return;
@@ -563,13 +564,13 @@ static void acm_write_bulk(struct urb *urb)
        acm_write_done(acm, wb);
        spin_unlock_irqrestore(&acm->write_lock, flags);
        set_bit(EVENT_TTY_WAKEUP, &acm->flags);
-       schedule_work(&acm->work);
+       schedule_delayed_work(&acm->dwork, 0);
 }
 
 static void acm_softint(struct work_struct *work)
 {
        int i;
-       struct acm *acm = container_of(work, struct acm, work);
+       struct acm *acm = container_of(work, struct acm, dwork.work);
 
        if (test_bit(EVENT_RX_STALL, &acm->flags)) {
                smp_mb(); /* against acm_suspend() */
@@ -585,7 +586,7 @@ static void acm_softint(struct work_struct *work)
        if (test_and_clear_bit(ACM_ERROR_DELAY, &acm->flags)) {
                for (i = 0; i < acm->rx_buflimit; i++)
                        if (test_and_clear_bit(i, &acm->urbs_in_error_delay))
-                                       acm_submit_read_urb(acm, i, GFP_NOIO);
+                               acm_submit_read_urb(acm, i, GFP_KERNEL);
        }
 
        if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))
@@ -1351,7 +1352,6 @@ made_compressed_probe:
        acm->ctrlsize = ctrlsize;
        acm->readsize = readsize;
        acm->rx_buflimit = num_rx_buf;
-       INIT_WORK(&acm->work, acm_softint);
        INIT_DELAYED_WORK(&acm->dwork, acm_softint);
        init_waitqueue_head(&acm->wioctl);
        spin_lock_init(&acm->write_lock);
@@ -1561,7 +1561,6 @@ static void acm_disconnect(struct usb_interface *intf)
        }
 
        acm_kill_urbs(acm);
-       cancel_work_sync(&acm->work);
        cancel_delayed_work_sync(&acm->dwork);
 
        tty_unregister_device(acm_tty_driver, acm->minor);
@@ -1604,7 +1603,6 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
                return 0;
 
        acm_kill_urbs(acm);
-       cancel_work_sync(&acm->work);
        cancel_delayed_work_sync(&acm->dwork);
        acm->urbs_in_error_delay = 0;
 
index 9dce179d031bb0d7e455c44aea13dedab112d8d3..8aef5eb769a0de0e5a7bd1e853ea867fcdfffd42 100644 (file)
@@ -112,8 +112,7 @@ struct acm {
 #              define ACM_ERROR_DELAY  3
        unsigned long urbs_in_error_delay;              /* these need to be restarted after a delay */
        struct usb_cdc_line_coding line;                /* bits, stop, parity */
-       struct work_struct work;                        /* work queue entry for various purposes*/
-       struct delayed_work dwork;                      /* for cool downs needed in error recovery */
+       struct delayed_work dwork;                      /* work queue entry for various purposes */
        unsigned int ctrlin;                            /* input control lines (DCD, DSR, RI, break, overruns) */
        unsigned int ctrlout;                           /* output control lines (DTR, RTS) */
        struct async_icount iocount;                    /* counters for control line changes */
index 98b7449c11f3d04c92566fb2512cacdf08e6a90f..4dfa44d6cc3cf0666329b5c2b2a88680eee0503f 100644 (file)
@@ -839,6 +839,22 @@ const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
        return NULL;
 }
 
+bool usb_driver_applicable(struct usb_device *udev,
+                          struct usb_device_driver *udrv)
+{
+       if (udrv->id_table && udrv->match)
+               return usb_device_match_id(udev, udrv->id_table) != NULL &&
+                      udrv->match(udev);
+
+       if (udrv->id_table)
+               return usb_device_match_id(udev, udrv->id_table) != NULL;
+
+       if (udrv->match)
+               return udrv->match(udev);
+
+       return false;
+}
+
 static int usb_device_match(struct device *dev, struct device_driver *drv)
 {
        /* devices and interfaces are handled separately */
@@ -853,17 +869,14 @@ static int usb_device_match(struct device *dev, struct device_driver *drv)
                udev = to_usb_device(dev);
                udrv = to_usb_device_driver(drv);
 
-               if (udrv->id_table)
-                       return usb_device_match_id(udev, udrv->id_table) != NULL;
-
-               if (udrv->match)
-                       return udrv->match(udev);
-
                /* If the device driver under consideration does not have a
                 * id_table or a match function, then let the driver's probe
                 * function decide.
                 */
-               return 1;
+               if (!udrv->id_table && !udrv->match)
+                       return 1;
+
+               return usb_driver_applicable(udev, udrv);
 
        } else if (is_usb_interface(dev)) {
                struct usb_interface *intf;
@@ -941,8 +954,7 @@ static int __usb_bus_reprobe_drivers(struct device *dev, void *data)
                return 0;
 
        udev = to_usb_device(dev);
-       if (usb_device_match_id(udev, new_udriver->id_table) == NULL &&
-           (!new_udriver->match || new_udriver->match(udev) == 0))
+       if (!usb_driver_applicable(udev, new_udriver))
                return 0;
 
        ret = device_reprobe(dev);
index 22c887f5c49751e026c72ce19e2a35abb9100240..26f9fb9f67ca22537fe8bda301345bd5f0390de3 100644 (file)
@@ -205,9 +205,7 @@ static int __check_for_non_generic_match(struct device_driver *drv, void *data)
        udrv = to_usb_device_driver(drv);
        if (udrv == &usb_generic_driver)
                return 0;
-       if (usb_device_match_id(udev, udrv->id_table) != NULL)
-               return 1;
-       return (udrv->match && udrv->match(udev));
+       return usb_driver_applicable(udev, udrv);
 }
 
 static bool usb_generic_driver_match(struct usb_device *udev)
index 10574fa3f927742c0b46299c1f1cf5752754e2d8..a1e3a037a289272869bebcd706c4dab5df84a0a8 100644 (file)
@@ -378,6 +378,9 @@ static const struct usb_device_id usb_quirk_list[] = {
        { USB_DEVICE(0x0926, 0x3333), .driver_info =
                        USB_QUIRK_CONFIG_INTF_STRINGS },
 
+       /* Kingston DataTraveler 3.0 */
+       { USB_DEVICE(0x0951, 0x1666), .driver_info = USB_QUIRK_NO_LPM },
+
        /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */
        { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF },
 
index c893f54a3420a5c053c94f8983d5904c2438e944..82538daac8b8962b975dead6752706f44046b82a 100644 (file)
@@ -74,6 +74,8 @@ extern int usb_match_device(struct usb_device *dev,
                            const struct usb_device_id *id);
 extern const struct usb_device_id *usb_device_match_id(struct usb_device *udev,
                                const struct usb_device_id *id);
+extern bool usb_driver_applicable(struct usb_device *udev,
+                                 struct usb_device_driver *udrv);
 extern void usb_forced_unbind_intf(struct usb_interface *intf);
 extern void usb_unbind_and_rebind_marked_interfaces(struct usb_device *udev);
 
index e2820676beb11f4984134ecd17c8cd937cbaee18..5f18acac7406885927b4d473045aaae94d474470 100644 (file)
@@ -608,10 +608,13 @@ static int dwc2_driver_probe(struct platform_device *dev)
 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
        return 0;
 
+#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \
+       IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
 error_debugfs:
        dwc2_debugfs_exit(hsotg);
        if (hsotg->hcd_enabled)
                dwc2_hcd_remove(hsotg);
+#endif
 error_drd:
        dwc2_drd_exit(hsotg);
 
index bdf0925da6b642b54052d288f22daf42948369d6..841daec70b6efd808b1407da9a4ba561eb98c660 100644 (file)
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-/**
+/*
  * core.c - DesignWare USB3 DRD Controller Core file
  *
  * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com
index 74323b10a64ac5af7f215fde1a7d752e0d291170..2f95f08ca51190e89c14719ca880e726bef7c12b 100644 (file)
@@ -1277,7 +1277,7 @@ struct dwc3_event_type {
 #define DWC3_DEPEVT_EPCMDCMPLT         0x07
 
 /**
- * struct dwc3_event_depvt - Device Endpoint Events
+ * struct dwc3_event_depevt - Device Endpoint Events
  * @one_bit: indicates this is an endpoint event (not used)
  * @endpoint_number: number of the endpoint
  * @endpoint_event: The event we have:
index 242b6210380a4f383b9b24bc5511450e71178bc8..bae6a70664c80b48debc2a1569203c4c57008ea0 100644 (file)
@@ -40,6 +40,7 @@
 #define PCI_DEVICE_ID_INTEL_TGPLP              0xa0ee
 #define PCI_DEVICE_ID_INTEL_TGPH               0x43ee
 #define PCI_DEVICE_ID_INTEL_JSP                        0x4dee
+#define PCI_DEVICE_ID_INTEL_ADLS               0x7ae1
 
 #define PCI_INTEL_BXT_DSM_GUID         "732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511"
 #define PCI_INTEL_BXT_FUNC_PMU_PWR     4
@@ -367,6 +368,9 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_JSP),
          (kernel_ulong_t) &dwc3_pci_intel_properties, },
 
+       { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLS),
+         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB),
          (kernel_ulong_t) &dwc3_pci_amd_properties, },
        {  }    /* Terminating Entry */
index 7be3903cb8427cd183b765a3e369f276429411f8..8b668ef46f7f1fbead3f3ef091229669e9006026 100644 (file)
@@ -1058,10 +1058,11 @@ void dwc3_ep0_send_delayed_status(struct dwc3 *dwc)
 {
        unsigned int direction = !dwc->ep0_expect_in;
 
+       dwc->delayed_status = false;
+
        if (dwc->ep0state != EP0_STATUS_PHASE)
                return;
 
-       dwc->delayed_status = false;
        __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]);
 }
 
index 05b176c82cc522b7416b0379915af615b3eac4ec..c6d455f2bb928b22cbedc5f0901221fdca997429 100644 (file)
@@ -1245,7 +1245,7 @@ int usb_string_id(struct usb_composite_dev *cdev)
 EXPORT_SYMBOL_GPL(usb_string_id);
 
 /**
- * usb_string_ids() - allocate unused string IDs in batch
+ * usb_string_ids_tab() - allocate unused string IDs in batch
  * @cdev: the device whose string descriptor IDs are being allocated
  * @str: an array of usb_string objects to assign numbers to
  * Context: single threaded during gadget setup
index e01e366d89cd585cff3252c88e87cbe5691149d7..062dfac3039968d3f09868141aed177f91d8e5d4 100644 (file)
@@ -564,9 +564,12 @@ static int raw_ioctl_event_fetch(struct raw_dev *dev, unsigned long value)
                return -ENODEV;
        }
        length = min(arg.length, event->length);
-       if (copy_to_user((void __user *)value, event, sizeof(*event) + length))
+       if (copy_to_user((void __user *)value, event, sizeof(*event) + length)) {
+               kfree(event);
                return -EFAULT;
+       }
 
+       kfree(event);
        return 0;
 }
 
index de528e3b0662e7d536c46bb92b5e5776574ac4dd..ad6ff9c4188efb208635526583f4b63cb037a78b 100644 (file)
@@ -1051,7 +1051,7 @@ static int fsl_ep_fifo_status(struct usb_ep *_ep)
        u32 bitmask;
        struct ep_queue_head *qh;
 
-       if (!_ep || _ep->desc || !(_ep->desc->bEndpointAddress&0xF))
+       if (!_ep || !_ep->desc || !(_ep->desc->bEndpointAddress&0xF))
                return -ENODEV;
 
        ep = container_of(_ep, struct fsl_ep, ep);
index 25c1d6ab5adb457d4af5904dca7e3ff6b299a28b..3e1267d38774fa031000e5737161cc251b557de7 100644 (file)
@@ -1760,6 +1760,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                goto err;
        }
 
+       pci_set_drvdata(pdev, dev);
        spin_lock_init(&dev->lock);
        dev->pdev = pdev;
        dev->gadget.ops = &goku_ops;
@@ -1793,7 +1794,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        }
        dev->regs = (struct goku_udc_regs __iomem *) base;
 
-       pci_set_drvdata(pdev, dev);
        INFO(dev, "%s\n", driver_desc);
        INFO(dev, "version: " DRIVER_VERSION " %s\n", dmastr());
        INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base);
index e077b2ca53c517032d0a9816a56632a36aa7cd20..869d9c4de5fcd3dbfdf5723b63b188d59a50417d 100644 (file)
@@ -479,8 +479,8 @@ static int tegra_ehci_probe(struct platform_device *pdev)
        u_phy->otg->host = hcd_to_bus(hcd);
 
        irq = platform_get_irq(pdev, 0);
-       if (!irq) {
-               err = -ENODEV;
+       if (irq < 0) {
+               err = irq;
                goto cleanup_phy;
        }
 
index ae8f60f6e6a5e092bfd314e143fdf6816079e912..44a7e58a26e3ddc0edbf1a345254c1c4472a2dd5 100644 (file)
@@ -94,10 +94,13 @@ static struct platform_device *fsl_usb2_device_register(
 
        pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
 
-       if (!pdev->dev.dma_mask)
+       if (!pdev->dev.dma_mask) {
                pdev->dev.dma_mask = &ofdev->dev.coherent_dma_mask;
-       else
-               dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+       } else {
+               retval = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
+               if (retval)
+                       goto error;
+       }
 
        retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
        if (retval)
index fe405cd38dbc11790b5fd91e41d78f8136c306e9..138ba4528dd3a8dba3452b2f49ffe570460a365e 100644 (file)
@@ -2252,8 +2252,8 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci,
 
        if (!rhub->num_ports)
                return;
-       rhub->ports = kcalloc_node(rhub->num_ports, sizeof(rhub->ports), flags,
-                       dev_to_node(dev));
+       rhub->ports = kcalloc_node(rhub->num_ports, sizeof(*rhub->ports),
+                       flags, dev_to_node(dev));
        for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
                if (xhci->hw_ports[i].rhub != rhub ||
                    xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY)
index c26c06e5c88cde4430100b42adc6a2d414efcf50..bf89172c43cace41449d5099653fb135c533c0e8 100644 (file)
@@ -23,6 +23,8 @@
 #define SSIC_PORT_CFG2_OFFSET  0x30
 #define PROG_DONE              (1 << 30)
 #define SSIC_PORT_UNUSED       (1 << 31)
+#define SPARSE_DISABLE_BIT     17
+#define SPARSE_CNTL_ENABLE     0xC12C
 
 /* Device for a quirk */
 #define PCI_VENDOR_ID_FRESCO_LOGIC     0x1b73
@@ -161,6 +163,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
            (pdev->device == 0x15e0 || pdev->device == 0x15e1))
                xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
 
+       if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x15e5)
+               xhci->quirks |= XHCI_DISABLE_SPARSE;
+
        if (pdev->vendor == PCI_VENDOR_ID_AMD)
                xhci->quirks |= XHCI_TRUST_TX_LENGTH;
 
@@ -498,6 +503,15 @@ static void xhci_pme_quirk(struct usb_hcd *hcd)
        readl(reg);
 }
 
+static void xhci_sparse_control_quirk(struct usb_hcd *hcd)
+{
+       u32 reg;
+
+       reg = readl(hcd->regs + SPARSE_CNTL_ENABLE);
+       reg &= ~BIT(SPARSE_DISABLE_BIT);
+       writel(reg, hcd->regs + SPARSE_CNTL_ENABLE);
+}
+
 static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
@@ -517,6 +531,9 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
        if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
                xhci_ssic_port_unused_quirk(hcd, true);
 
+       if (xhci->quirks & XHCI_DISABLE_SPARSE)
+               xhci_sparse_control_quirk(hcd);
+
        ret = xhci_suspend(xhci, do_wakeup);
        if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
                xhci_ssic_port_unused_quirk(hcd, false);
index 482fe8c5e3b4778e1514d36e9fe22385e756fd75..d4a8d0efbbc4d6f06bcb3b807dce9f85837fb19b 100644 (file)
@@ -3533,11 +3533,14 @@ static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
                xhci_dbg(xhci, "Slot %u ep ctx %u now has streams.\n",
                         udev->slot_id, ep_index);
                vdev->eps[ep_index].ep_state |= EP_HAS_STREAMS;
-               xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
        }
        xhci_free_command(xhci, config_cmd);
        spin_unlock_irqrestore(&xhci->lock, flags);
 
+       for (i = 0; i < num_eps; i++) {
+               ep_index = xhci_get_endpoint_index(&eps[i]->desc);
+               xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
+       }
        /* Subtract 1 for stream 0, which drivers can't use */
        return num_streams - 1;
 
index 8be88379c0fb232bc306bd8ebcde7e23fae1fd16..ebb359ebb261c180e17cb1ee2c44ba6ee350999c 100644 (file)
@@ -1877,6 +1877,7 @@ struct xhci_hcd {
 #define XHCI_SNPS_BROKEN_SUSPEND    BIT_ULL(35)
 #define XHCI_RENESAS_FW_QUIRK  BIT_ULL(36)
 #define XHCI_SKIP_PHY_INIT     BIT_ULL(37)
+#define XHCI_DISABLE_SPARSE    BIT_ULL(38)
 
        unsigned int            num_active_eps;
        unsigned int            limit_active_eps;
index b403094a6b3a5058840074cff6d76a268e2ad6e9..9de0171b517763951b733774ca675aef94a29a7e 100644 (file)
@@ -120,8 +120,10 @@ static int apple_mfi_fc_set_property(struct power_supply *psy,
        dev_dbg(&mfi->udev->dev, "prop: %d\n", psp);
 
        ret = pm_runtime_get_sync(&mfi->udev->dev);
-       if (ret < 0)
+       if (ret < 0) {
+               pm_runtime_put_noidle(&mfi->udev->dev);
                return ret;
+       }
 
        switch (psp) {
        case POWER_SUPPLY_PROP_CHARGE_TYPE:
@@ -163,17 +165,23 @@ static const struct power_supply_desc apple_mfi_fc_desc = {
        .property_is_writeable  = apple_mfi_fc_property_is_writeable
 };
 
+static bool mfi_fc_match(struct usb_device *udev)
+{
+       int idProduct;
+
+       idProduct = le16_to_cpu(udev->descriptor.idProduct);
+       /* See comment above mfi_fc_id_table[] */
+       return (idProduct >= 0x1200 && idProduct <= 0x12ff);
+}
+
 static int mfi_fc_probe(struct usb_device *udev)
 {
        struct power_supply_config battery_cfg = {};
        struct mfi_device *mfi = NULL;
-       int err, idProduct;
+       int err;
 
-       idProduct = le16_to_cpu(udev->descriptor.idProduct);
-       /* See comment above mfi_fc_id_table[] */
-       if (idProduct < 0x1200 || idProduct > 0x12ff) {
+       if (!mfi_fc_match(udev))
                return -ENODEV;
-       }
 
        mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL);
        if (!mfi) {
@@ -220,6 +228,7 @@ static struct usb_device_driver mfi_fc_driver = {
        .probe =        mfi_fc_probe,
        .disconnect =   mfi_fc_disconnect,
        .id_table =     mfi_fc_id_table,
+       .match =        mfi_fc_match,
        .generic_subclass = 1,
 };
 
index 1de5c9a1d20a1b885601523d8c019f8de497b2fa..38f17d66d5bc16a3b4bf06b9c543d342ad39a0af 100644 (file)
@@ -564,6 +564,7 @@ static int mtu3_gadget_stop(struct usb_gadget *g)
 
        spin_unlock_irqrestore(&mtu->lock, flags);
 
+       synchronize_irq(mtu->irq);
        return 0;
 }
 
index 821970609695befc0a0f4a04a8b758baba3b988c..2e40908963dafc2c299cd770f3116dfbbfcacc93 100644 (file)
@@ -357,11 +357,12 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
        struct device *dev = &port->dev;
        int status = urb->status;
        unsigned long flags;
+       bool resubmitted = false;
 
-       set_bit(0, &port->write_urbs_free);
        if (status) {
                dev_dbg(dev, "%s - nonzero write bulk status received: %d\n",
                        __func__, status);
+               set_bit(0, &port->write_urbs_free);
                return;
        }
 
@@ -394,6 +395,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
                        goto exit;
                }
 
+               resubmitted = true;
+
                dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent);
                dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled);
 
@@ -410,6 +413,8 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
 
 exit:
        spin_unlock_irqrestore(&priv->lock, flags);
+       if (!resubmitted)
+               set_bit(0, &port->write_urbs_free);
        usb_serial_port_softint(port);
 }
 
index 2a3bfd6f867ed5acbf97aeed1da5e75d3b3d4738..54ca85cc920dcb62cad00c32e544e39e39684ece 100644 (file)
@@ -250,6 +250,7 @@ static void option_instat_callback(struct urb *urb);
 #define QUECTEL_PRODUCT_EP06                   0x0306
 #define QUECTEL_PRODUCT_EM12                   0x0512
 #define QUECTEL_PRODUCT_RM500Q                 0x0800
+#define QUECTEL_PRODUCT_EC200T                 0x6026
 
 #define CMOTECH_VENDOR_ID                      0x16d8
 #define CMOTECH_PRODUCT_6001                   0x6001
@@ -1117,6 +1118,7 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_RM500Q, 0xff, 0xff, 0x10),
          .driver_info = ZLP },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC200T, 0xff, 0, 0) },
 
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
@@ -1189,6 +1191,8 @@ static const struct usb_device_id option_ids[] = {
          .driver_info = NCTRL(0) | RSVD(1) },
        { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1054, 0xff),    /* Telit FT980-KS */
          .driver_info = NCTRL(2) | RSVD(3) },
+       { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1055, 0xff),    /* Telit FN980 (PCIe) */
+         .driver_info = NCTRL(0) | RSVD(1) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
          .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
@@ -1201,6 +1205,8 @@ static const struct usb_device_id option_ids[] = {
          .driver_info = NCTRL(0) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
          .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
+       { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1203, 0xff),    /* Telit LE910Cx (RNDIS) */
+         .driver_info = NCTRL(2) | RSVD(3) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
          .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
@@ -1215,6 +1221,10 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1213, 0xff) },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920A4_1214),
          .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) | RSVD(3) },
+       { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1230, 0xff),    /* Telit LE910Cx (rmnet) */
+         .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
+       { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1231, 0xff),    /* Telit LE910Cx (RNDIS) */
+         .driver_info = NCTRL(2) | RSVD(3) },
        { USB_DEVICE(TELIT_VENDOR_ID, 0x1260),
          .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
        { USB_DEVICE(TELIT_VENDOR_ID, 0x1261),
index b069a5122aaa9b162a475eb410cc3ef1cc1b261c..cf720e944aaaa44eba12eb87d06d2e96c4ab9afa 100644 (file)
@@ -71,7 +71,7 @@ struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode)
 EXPORT_SYMBOL_GPL(fwnode_typec_switch_get);
 
 /**
- * typec_put_switch - Release USB Type-C orientation switch
+ * typec_switch_put - Release USB Type-C orientation switch
  * @sw: USB Type-C orientation switch
  *
  * Decrement reference count for @sw.
index ce0bd7b3ad88e4293b53e86bb839a113c3f41492..2a618f02f4f101d5efa0e741256f14ca5193961f 100644 (file)
@@ -544,11 +544,10 @@ static int stusb160x_get_fw_caps(struct stusb160x *chip,
         */
        ret = fwnode_property_read_string(fwnode, "power-role", &cap_str);
        if (!ret) {
-               chip->port_type = typec_find_port_power_role(cap_str);
-               if (chip->port_type < 0) {
-                       ret = chip->port_type;
+               ret = typec_find_port_power_role(cap_str);
+               if (ret < 0)
                        return ret;
-               }
+               chip->port_type = ret;
        }
        chip->capability.type = chip->port_type;
 
@@ -565,15 +564,13 @@ static int stusb160x_get_fw_caps(struct stusb160x *chip,
         */
        ret = fwnode_property_read_string(fwnode, "power-opmode", &cap_str);
        if (!ret) {
-               chip->pwr_opmode = typec_find_pwr_opmode(cap_str);
+               ret = typec_find_pwr_opmode(cap_str);
                /* Power delivery not yet supported */
-               if (chip->pwr_opmode < 0 ||
-                   chip->pwr_opmode == TYPEC_PWR_MODE_PD) {
-                       ret = chip->pwr_opmode < 0 ? chip->pwr_opmode : -EINVAL;
-                       dev_err(chip->dev, "bad power operation mode: %d\n",
-                               chip->pwr_opmode);
-                       return ret;
+               if (ret < 0 || ret == TYPEC_PWR_MODE_PD) {
+                       dev_err(chip->dev, "bad power operation mode: %d\n", ret);
+                       return -EINVAL;
                }
+               chip->pwr_opmode = ret;
        }
 
        return 0;
@@ -632,6 +629,7 @@ static const struct of_device_id stusb160x_of_match[] = {
        { .compatible = "st,stusb1600", .data = &stusb1600_regmap_config},
        {},
 };
+MODULE_DEVICE_TABLE(of, stusb160x_of_match);
 
 static int stusb160x_probe(struct i2c_client *client)
 {
@@ -729,8 +727,8 @@ static int stusb160x_probe(struct i2c_client *client)
        }
 
        chip->port = typec_register_port(chip->dev, &chip->capability);
-       if (!chip->port) {
-               ret = -ENODEV;
+       if (IS_ERR(chip->port)) {
+               ret = PTR_ERR(chip->port);
                goto all_reg_disable;
        }
 
index 55535c4f66bfab241aa433480bd56bee9c3b4555..a6fae1f865051bcb28c96a74bd12ab04b37775b8 100644 (file)
@@ -2890,6 +2890,9 @@ static void tcpm_reset_port(struct tcpm_port *port)
 
 static void tcpm_detach(struct tcpm_port *port)
 {
+       if (tcpm_port_is_disconnected(port))
+               port->hard_reset_count = 0;
+
        if (!port->attached)
                return;
 
@@ -2898,9 +2901,6 @@ static void tcpm_detach(struct tcpm_port *port)
                port->tcpc->set_bist_data(port->tcpc, false);
        }
 
-       if (tcpm_port_is_disconnected(port))
-               port->hard_reset_count = 0;
-
        tcpm_reset_port(port);
 }
 
index ef1c550f8266255464ad816e99274a70026647b8..4b6195666c589512329f4a5886cf2ba9c7486bf2 100644 (file)
@@ -239,7 +239,6 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
        u64 paend;
        struct scatterlist *sg;
        struct device *dma = mvdev->mdev->device;
-       int ret;
 
        for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1);
             map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) {
@@ -277,8 +276,8 @@ static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr
 done:
        mr->log_size = log_entity_size;
        mr->nsg = nsg;
-       ret = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
-       if (!ret)
+       err = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
+       if (!err)
                goto err_map;
 
        err = create_direct_mr(mvdev, mr);
index 2629911c29bbf4e341982434682a8e5975d8c4d0..6a90fdb9cbfc6f8070a43692b858f9349d577f0e 100644 (file)
@@ -38,6 +38,10 @@ static int batch_mapping = 1;
 module_param(batch_mapping, int, 0444);
 MODULE_PARM_DESC(batch_mapping, "Batched mapping 1 -Enable; 0 - Disable");
 
+static char *macaddr;
+module_param(macaddr, charp, 0);
+MODULE_PARM_DESC(macaddr, "Ethernet MAC address");
+
 struct vdpasim_virtqueue {
        struct vringh vring;
        struct vringh_kiov iov;
@@ -60,7 +64,8 @@ struct vdpasim_virtqueue {
 
 static u64 vdpasim_features = (1ULL << VIRTIO_F_ANY_LAYOUT) |
                              (1ULL << VIRTIO_F_VERSION_1)  |
-                             (1ULL << VIRTIO_F_ACCESS_PLATFORM);
+                             (1ULL << VIRTIO_F_ACCESS_PLATFORM) |
+                             (1ULL << VIRTIO_NET_F_MAC);
 
 /* State of each vdpasim device */
 struct vdpasim {
@@ -361,7 +366,9 @@ static struct vdpasim *vdpasim_create(void)
        spin_lock_init(&vdpasim->iommu_lock);
 
        dev = &vdpasim->vdpa.dev;
-       dev->coherent_dma_mask = DMA_BIT_MASK(64);
+       dev->dma_mask = &dev->coherent_dma_mask;
+       if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)))
+               goto err_iommu;
        set_dma_ops(dev, &vdpasim_dma_ops);
 
        vdpasim->iommu = vhost_iotlb_alloc(2048, 0);
@@ -372,7 +379,15 @@ static struct vdpasim *vdpasim_create(void)
        if (!vdpasim->buffer)
                goto err_iommu;
 
-       eth_random_addr(vdpasim->config.mac);
+       if (macaddr) {
+               mac_pton(macaddr, vdpasim->config.mac);
+               if (!is_valid_ether_addr(vdpasim->config.mac)) {
+                       ret = -EADDRNOTAVAIL;
+                       goto err_iommu;
+               }
+       } else {
+               eth_random_addr(vdpasim->config.mac);
+       }
 
        vringh_set_iotlb(&vdpasim->vqs[0].vring, vdpasim->iommu);
        vringh_set_iotlb(&vdpasim->vqs[1].vring, vdpasim->iommu);
@@ -574,6 +589,16 @@ static u32 vdpasim_get_generation(struct vdpa_device *vdpa)
        return vdpasim->generation;
 }
 
+static struct vdpa_iova_range vdpasim_get_iova_range(struct vdpa_device *vdpa)
+{
+       struct vdpa_iova_range range = {
+               .first = 0ULL,
+               .last = ULLONG_MAX,
+       };
+
+       return range;
+}
+
 static int vdpasim_set_map(struct vdpa_device *vdpa,
                           struct vhost_iotlb *iotlb)
 {
@@ -657,6 +682,7 @@ static const struct vdpa_config_ops vdpasim_net_config_ops = {
        .get_config             = vdpasim_get_config,
        .set_config             = vdpasim_set_config,
        .get_generation         = vdpasim_get_generation,
+       .get_iova_range         = vdpasim_get_iova_range,
        .dma_map                = vdpasim_dma_map,
        .dma_unmap              = vdpasim_dma_unmap,
        .free                   = vdpasim_free,
@@ -683,6 +709,7 @@ static const struct vdpa_config_ops vdpasim_net_batch_config_ops = {
        .get_config             = vdpasim_get_config,
        .set_config             = vdpasim_set_config,
        .get_generation         = vdpasim_get_generation,
+       .get_iova_range         = vdpasim_get_iova_range,
        .set_map                = vdpasim_set_map,
        .free                   = vdpasim_free,
 };
index 0113a980f974955a42812ba8e8ef54038617ffd1..f27e25112c4037dc7e3d9926f970fca358dcc648 100644 (file)
@@ -248,7 +248,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd,
                info.size = vdev->regions[info.index].size;
                info.flags = vdev->regions[info.index].flags;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+               return 0;
        }
        case VFIO_DEVICE_GET_IRQ_INFO:
        {
@@ -267,7 +269,9 @@ static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd,
                info.flags = VFIO_IRQ_INFO_EVENTFD;
                info.count = 1;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+               return 0;
        }
        case VFIO_DEVICE_SET_IRQS:
        {
@@ -468,7 +472,7 @@ static int vfio_fsl_mc_mmap(void *device_data, struct vm_area_struct *vma)
 {
        struct vfio_fsl_mc_device *vdev = device_data;
        struct fsl_mc_device *mc_dev = vdev->mc_dev;
-       int index;
+       unsigned int index;
 
        index = vma->vm_pgoff >> (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT);
 
index c80dceb46f793893c8157fb2a4bfcacaebb3b90e..0d9f3002df7f51dc9bfebd6cba2f6c411ea34be2 100644 (file)
@@ -13,7 +13,7 @@
 #include "linux/fsl/mc.h"
 #include "vfio_fsl_mc_private.h"
 
-int vfio_fsl_mc_irqs_allocate(struct vfio_fsl_mc_device *vdev)
+static int vfio_fsl_mc_irqs_allocate(struct vfio_fsl_mc_device *vdev)
 {
        struct fsl_mc_device *mc_dev = vdev->mc_dev;
        struct vfio_fsl_mc_irq *mc_irq;
index fbd2b3404184ba31e6f72d3fb83920016ef68c58..e6190173482c7e9a2094cdad0888fece695368f9 100644 (file)
@@ -385,7 +385,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
            pdev->vendor == PCI_VENDOR_ID_INTEL &&
            IS_ENABLED(CONFIG_VFIO_PCI_IGD)) {
                ret = vfio_pci_igd_init(vdev);
-               if (ret) {
+               if (ret && ret != -ENODEV) {
                        pci_warn(pdev, "Failed to setup Intel IGD regions\n");
                        goto disable_exit;
                }
index 9e353c484ace2676b5fa51f0c07f0b50208cd04e..a0b5fc8e46f4dc05e8d46c0f04ecc9c54cb26363 100644 (file)
@@ -356,34 +356,60 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
        return done;
 }
 
-static int vfio_pci_ioeventfd_handler(void *opaque, void *unused)
+static void vfio_pci_ioeventfd_do_write(struct vfio_pci_ioeventfd *ioeventfd,
+                                       bool test_mem)
 {
-       struct vfio_pci_ioeventfd *ioeventfd = opaque;
-
        switch (ioeventfd->count) {
        case 1:
-               vfio_pci_iowrite8(ioeventfd->vdev, ioeventfd->test_mem,
+               vfio_pci_iowrite8(ioeventfd->vdev, test_mem,
                                  ioeventfd->data, ioeventfd->addr);
                break;
        case 2:
-               vfio_pci_iowrite16(ioeventfd->vdev, ioeventfd->test_mem,
+               vfio_pci_iowrite16(ioeventfd->vdev, test_mem,
                                   ioeventfd->data, ioeventfd->addr);
                break;
        case 4:
-               vfio_pci_iowrite32(ioeventfd->vdev, ioeventfd->test_mem,
+               vfio_pci_iowrite32(ioeventfd->vdev, test_mem,
                                   ioeventfd->data, ioeventfd->addr);
                break;
 #ifdef iowrite64
        case 8:
-               vfio_pci_iowrite64(ioeventfd->vdev, ioeventfd->test_mem,
+               vfio_pci_iowrite64(ioeventfd->vdev, test_mem,
                                   ioeventfd->data, ioeventfd->addr);
                break;
 #endif
        }
+}
+
+static int vfio_pci_ioeventfd_handler(void *opaque, void *unused)
+{
+       struct vfio_pci_ioeventfd *ioeventfd = opaque;
+       struct vfio_pci_device *vdev = ioeventfd->vdev;
+
+       if (ioeventfd->test_mem) {
+               if (!down_read_trylock(&vdev->memory_lock))
+                       return 1; /* Lock contended, use thread */
+               if (!__vfio_pci_memory_enabled(vdev)) {
+                       up_read(&vdev->memory_lock);
+                       return 0;
+               }
+       }
+
+       vfio_pci_ioeventfd_do_write(ioeventfd, false);
+
+       if (ioeventfd->test_mem)
+               up_read(&vdev->memory_lock);
 
        return 0;
 }
 
+static void vfio_pci_ioeventfd_thread(void *opaque, void *unused)
+{
+       struct vfio_pci_ioeventfd *ioeventfd = opaque;
+
+       vfio_pci_ioeventfd_do_write(ioeventfd, ioeventfd->test_mem);
+}
+
 long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset,
                        uint64_t data, int count, int fd)
 {
@@ -457,7 +483,8 @@ long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset,
        ioeventfd->test_mem = vdev->pdev->resource[bar].flags & IORESOURCE_MEM;
 
        ret = vfio_virqfd_enable(ioeventfd, vfio_pci_ioeventfd_handler,
-                                NULL, NULL, &ioeventfd->virqfd, fd);
+                                vfio_pci_ioeventfd_thread, NULL,
+                                &ioeventfd->virqfd, fd);
        if (ret) {
                kfree(ioeventfd);
                goto out_unlock;
index c0771a9567fb5dd7d4af1ec1b92b665c38cfa728..fb4b385191f288dfee2b35442b68538236deb257 100644 (file)
@@ -267,7 +267,7 @@ static int vfio_platform_open(void *device_data)
 
                ret = pm_runtime_get_sync(vdev->device);
                if (ret < 0)
-                       goto err_pm;
+                       goto err_rst;
 
                ret = vfio_platform_call_reset(vdev, &extra_dbg);
                if (ret && vdev->reset_required) {
@@ -284,7 +284,6 @@ static int vfio_platform_open(void *device_data)
 
 err_rst:
        pm_runtime_put(vdev->device);
-err_pm:
        vfio_platform_irq_cleanup(vdev);
 err_irq:
        vfio_platform_regions_cleanup(vdev);
index bb2684cc245ef522e5723ecf2a8c584c4a08a1bb..67e827638995157968e19f0864f107757c4e73f8 100644 (file)
@@ -1993,6 +1993,7 @@ static void vfio_iommu_iova_insert_copy(struct vfio_iommu *iommu,
 
        list_splice_tail(iova_copy, iova);
 }
+
 static int vfio_iommu_type1_attach_group(void *iommu_data,
                                         struct iommu_group *iommu_group)
 {
@@ -2009,18 +2010,10 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
 
        mutex_lock(&iommu->lock);
 
-       list_for_each_entry(d, &iommu->domain_list, next) {
-               if (find_iommu_group(d, iommu_group)) {
-                       mutex_unlock(&iommu->lock);
-                       return -EINVAL;
-               }
-       }
-
-       if (iommu->external_domain) {
-               if (find_iommu_group(iommu->external_domain, iommu_group)) {
-                       mutex_unlock(&iommu->lock);
-                       return -EINVAL;
-               }
+       /* Check for duplicates */
+       if (vfio_iommu_find_iommu_group(iommu, iommu_group)) {
+               mutex_unlock(&iommu->lock);
+               return -EINVAL;
        }
 
        group = kzalloc(sizeof(*group), GFP_KERNEL);
index a2dbc85e0b0d67b49ccc1f236f7f38c48035cd31..2754f3069738027965adcf1716009007d77f8abf 100644 (file)
@@ -47,6 +47,7 @@ struct vhost_vdpa {
        int minor;
        struct eventfd_ctx *config_ctx;
        int in_batch;
+       struct vdpa_iova_range range;
 };
 
 static DEFINE_IDA(vhost_vdpa_ida);
@@ -103,6 +104,9 @@ static void vhost_vdpa_setup_vq_irq(struct vhost_vdpa *v, u16 qid)
        vq->call_ctx.producer.token = vq->call_ctx.ctx;
        vq->call_ctx.producer.irq = irq;
        ret = irq_bypass_register_producer(&vq->call_ctx.producer);
+       if (unlikely(ret))
+               dev_info(&v->dev, "vq %u, irq bypass producer (token %p) registration fails, ret =  %d\n",
+                        qid, vq->call_ctx.producer.token, ret);
 }
 
 static void vhost_vdpa_unsetup_vq_irq(struct vhost_vdpa *v, u16 qid)
@@ -337,6 +341,16 @@ static long vhost_vdpa_set_config_call(struct vhost_vdpa *v, u32 __user *argp)
        return 0;
 }
 
+static long vhost_vdpa_get_iova_range(struct vhost_vdpa *v, u32 __user *argp)
+{
+       struct vhost_vdpa_iova_range range = {
+               .first = v->range.first,
+               .last = v->range.last,
+       };
+
+       return copy_to_user(argp, &range, sizeof(range));
+}
+
 static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
                                   void __user *argp)
 {
@@ -421,12 +435,11 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
        void __user *argp = (void __user *)arg;
        u64 __user *featurep = argp;
        u64 features;
-       long r;
+       long r = 0;
 
        if (cmd == VHOST_SET_BACKEND_FEATURES) {
-               r = copy_from_user(&features, featurep, sizeof(features));
-               if (r)
-                       return r;
+               if (copy_from_user(&features, featurep, sizeof(features)))
+                       return -EFAULT;
                if (features & ~VHOST_VDPA_BACKEND_FEATURES)
                        return -EOPNOTSUPP;
                vhost_set_backend_features(&v->vdev, features);
@@ -469,7 +482,11 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep,
                break;
        case VHOST_GET_BACKEND_FEATURES:
                features = VHOST_VDPA_BACKEND_FEATURES;
-               r = copy_to_user(featurep, &features, sizeof(features));
+               if (copy_to_user(featurep, &features, sizeof(features)))
+                       r = -EFAULT;
+               break;
+       case VHOST_VDPA_GET_IOVA_RANGE:
+               r = vhost_vdpa_get_iova_range(v, argp);
                break;
        default:
                r = vhost_dev_ioctl(&v->vdev, cmd, argp);
@@ -588,19 +605,25 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
        struct vhost_dev *dev = &v->vdev;
        struct vhost_iotlb *iotlb = dev->iotlb;
        struct page **page_list;
-       struct vm_area_struct **vmas;
+       unsigned long list_size = PAGE_SIZE / sizeof(struct page *);
        unsigned int gup_flags = FOLL_LONGTERM;
-       unsigned long map_pfn, last_pfn = 0;
-       unsigned long npages, lock_limit;
-       unsigned long i, nmap = 0;
+       unsigned long npages, cur_base, map_pfn, last_pfn = 0;
+       unsigned long locked, lock_limit, pinned, i;
        u64 iova = msg->iova;
-       long pinned;
        int ret = 0;
 
+       if (msg->iova < v->range.first ||
+           msg->iova + msg->size - 1 > v->range.last)
+               return -EINVAL;
+
        if (vhost_iotlb_itree_first(iotlb, msg->iova,
                                    msg->iova + msg->size - 1))
                return -EEXIST;
 
+       page_list = (struct page **) __get_free_page(GFP_KERNEL);
+       if (!page_list)
+               return -ENOMEM;
+
        if (msg->perm & VHOST_ACCESS_WO)
                gup_flags |= FOLL_WRITE;
 
@@ -608,86 +631,61 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v,
        if (!npages)
                return -EINVAL;
 
-       page_list = kvmalloc_array(npages, sizeof(struct page *), GFP_KERNEL);
-       vmas = kvmalloc_array(npages, sizeof(struct vm_area_struct *),
-                             GFP_KERNEL);
-       if (!page_list || !vmas) {
-               ret = -ENOMEM;
-               goto free;
-       }
-
        mmap_read_lock(dev->mm);
 
+       locked = atomic64_add_return(npages, &dev->mm->pinned_vm);
        lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-       if (npages + atomic64_read(&dev->mm->pinned_vm) > lock_limit) {
-               ret = -ENOMEM;
-               goto unlock;
-       }
 
-       pinned = pin_user_pages(msg->uaddr & PAGE_MASK, npages, gup_flags,
-                               page_list, vmas);
-       if (npages != pinned) {
-               if (pinned < 0) {
-                       ret = pinned;
-               } else {
-                       unpin_user_pages(page_list, pinned);
-                       ret = -ENOMEM;
-               }
-               goto unlock;
+       if (locked > lock_limit) {
+               ret = -ENOMEM;
+               goto out;
        }
 
+       cur_base = msg->uaddr & PAGE_MASK;
        iova &= PAGE_MASK;
-       map_pfn = page_to_pfn(page_list[0]);
-
-       /* One more iteration to avoid extra vdpa_map() call out of loop. */
-       for (i = 0; i <= npages; i++) {
-               unsigned long this_pfn;
-               u64 csize;
-
-               /* The last chunk may have no valid PFN next to it */
-               this_pfn = i < npages ? page_to_pfn(page_list[i]) : -1UL;
-
-               if (last_pfn && (this_pfn == -1UL ||
-                                this_pfn != last_pfn + 1)) {
-                       /* Pin a contiguous chunk of memory */
-                       csize = last_pfn - map_pfn + 1;
-                       ret = vhost_vdpa_map(v, iova, csize << PAGE_SHIFT,
-                                            map_pfn << PAGE_SHIFT,
-                                            msg->perm);
-                       if (ret) {
-                               /*
-                                * Unpin the rest chunks of memory on the
-                                * flight with no corresponding vdpa_map()
-                                * calls having been made yet. On the other
-                                * hand, vdpa_unmap() in the failure path
-                                * is in charge of accounting the number of
-                                * pinned pages for its own.
-                                * This asymmetrical pattern of accounting
-                                * is for efficiency to pin all pages at
-                                * once, while there is no other callsite
-                                * of vdpa_map() than here above.
-                                */
-                               unpin_user_pages(&page_list[nmap],
-                                                npages - nmap);
-                               goto out;
+
+       while (npages) {
+               pinned = min_t(unsigned long, npages, list_size);
+               ret = pin_user_pages(cur_base, pinned,
+                                    gup_flags, page_list, NULL);
+               if (ret != pinned)
+                       goto out;
+
+               if (!last_pfn)
+                       map_pfn = page_to_pfn(page_list[0]);
+
+               for (i = 0; i < ret; i++) {
+                       unsigned long this_pfn = page_to_pfn(page_list[i]);
+                       u64 csize;
+
+                       if (last_pfn && (this_pfn != last_pfn + 1)) {
+                               /* Pin a contiguous chunk of memory */
+                               csize = (last_pfn - map_pfn + 1) << PAGE_SHIFT;
+                               if (vhost_vdpa_map(v, iova, csize,
+                                                  map_pfn << PAGE_SHIFT,
+                                                  msg->perm))
+                                       goto out;
+                               map_pfn = this_pfn;
+                               iova += csize;
                        }
-                       atomic64_add(csize, &dev->mm->pinned_vm);
-                       nmap += csize;
-                       iova += csize << PAGE_SHIFT;
-                       map_pfn = this_pfn;
+
+                       last_pfn = this_pfn;
                }
-               last_pfn = this_pfn;
+
+               cur_base += ret << PAGE_SHIFT;
+               npages -= ret;
        }
 
-       WARN_ON(nmap != npages);
+       /* Pin the rest chunk */
+       ret = vhost_vdpa_map(v, iova, (last_pfn - map_pfn + 1) << PAGE_SHIFT,
+                            map_pfn << PAGE_SHIFT, msg->perm);
 out:
-       if (ret)
+       if (ret) {
                vhost_vdpa_unmap(v, msg->iova, msg->size);
-unlock:
+               atomic64_sub(npages, &dev->mm->pinned_vm);
+       }
        mmap_read_unlock(dev->mm);
-free:
-       kvfree(vmas);
-       kvfree(page_list);
+       free_page((unsigned long)page_list);
        return ret;
 }
 
@@ -783,6 +781,27 @@ static void vhost_vdpa_free_domain(struct vhost_vdpa *v)
        v->domain = NULL;
 }
 
+static void vhost_vdpa_set_iova_range(struct vhost_vdpa *v)
+{
+       struct vdpa_iova_range *range = &v->range;
+       struct iommu_domain_geometry geo;
+       struct vdpa_device *vdpa = v->vdpa;
+       const struct vdpa_config_ops *ops = vdpa->config;
+
+       if (ops->get_iova_range) {
+               *range = ops->get_iova_range(vdpa);
+       } else if (v->domain &&
+                  !iommu_domain_get_attr(v->domain,
+                  DOMAIN_ATTR_GEOMETRY, &geo) &&
+                  geo.force_aperture) {
+               range->first = geo.aperture_start;
+               range->last = geo.aperture_end;
+       } else {
+               range->first = 0;
+               range->last = ULLONG_MAX;
+       }
+}
+
 static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 {
        struct vhost_vdpa *v;
@@ -823,6 +842,8 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
        if (r)
                goto err_init_iotlb;
 
+       vhost_vdpa_set_iova_range(v);
+
        filep->private_data = v;
 
        return 0;
index 02411d89cb462e2f98b0960f480f3fafb7abae91..e36fb1a0ecdbdb40dae4c3339a9c0bcaf2e65ada 100644 (file)
@@ -1114,8 +1114,15 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
 getmem_done:
        remove_conflicting_framebuffers(info->apertures,
                                        KBUILD_MODNAME, false);
-       if (!gen2vm)
+
+       if (gen2vm) {
+               /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */
+               screen_info.lfb_size = 0;
+               screen_info.lfb_base = 0;
+               screen_info.orig_video_isVGA = 0;
+       } else {
                pci_dev_put(pdev);
+       }
        kfree(info->apertures);
 
        return 0;
index 52233fa6195faf68b80b71a8b9133e3e7d56d7d0..887b673f6223022f2b9699503ef80796736f52be 100644 (file)
@@ -589,7 +589,7 @@ struct afs_cell *afs_use_cell(struct afs_cell *cell, enum afs_cell_trace reason)
  */
 void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_trace reason)
 {
-       unsigned int debug_id = cell->debug_id;
+       unsigned int debug_id;
        time64_t now, expire_delay;
        int u, a;
 
@@ -604,6 +604,7 @@ void afs_unuse_cell(struct afs_net *net, struct afs_cell *cell, enum afs_cell_tr
        if (cell->vl_servers->nr_servers)
                expire_delay = afs_cell_gc_delay;
 
+       debug_id = cell->debug_id;
        u = atomic_read(&cell->ref);
        a = atomic_dec_return(&cell->active);
        trace_afs_cell(debug_id, u, a, reason);
index 1d2e61e0ab047c733e132c8ee4a7f98c13af7941..1bb5b9d7f0a2c4067b4404047106106b674d366e 100644 (file)
@@ -281,8 +281,7 @@ retry:
                        if (ret < 0)
                                goto error;
 
-                       set_page_private(req->pages[i], 1);
-                       SetPagePrivate(req->pages[i]);
+                       attach_page_private(req->pages[i], (void *)1);
                        unlock_page(req->pages[i]);
                        i++;
                } else {
@@ -1975,8 +1974,7 @@ static int afs_dir_releasepage(struct page *page, gfp_t gfp_flags)
 
        _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, page->index);
 
-       set_page_private(page, 0);
-       ClearPagePrivate(page);
+       detach_page_private(page);
 
        /* The directory will need reloading. */
        if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &dvnode->flags))
@@ -2003,8 +2001,6 @@ static void afs_dir_invalidatepage(struct page *page, unsigned int offset,
                afs_stat_v(dvnode, n_inval);
 
        /* we clean up only if the entire page is being invalidated */
-       if (offset == 0 && length == PAGE_SIZE) {
-               set_page_private(page, 0);
-               ClearPagePrivate(page);
-       }
+       if (offset == 0 && length == PAGE_SIZE)
+               detach_page_private(page);
 }
index b108528bf010dc56a0bde88d7451408822f64777..2ffe09abae7fcca86bf66471eb80a91e580bcb2e 100644 (file)
@@ -243,10 +243,8 @@ void afs_edit_dir_add(struct afs_vnode *vnode,
                                                   index, gfp);
                        if (!page)
                                goto error;
-                       if (!PagePrivate(page)) {
-                               set_page_private(page, 1);
-                               SetPagePrivate(page);
-                       }
+                       if (!PagePrivate(page))
+                               attach_page_private(page, (void *)1);
                        dir_page = kmap(page);
                }
 
index 371d1488cc549db412a75045b7bfaf5b4d37204e..85f5adf21aa08a50f372a9db3b5215d3822c3940 100644 (file)
@@ -33,6 +33,7 @@ const struct file_operations afs_file_operations = {
        .write_iter     = afs_file_write,
        .mmap           = afs_file_mmap,
        .splice_read    = generic_file_splice_read,
+       .splice_write   = iter_file_splice_write,
        .fsync          = afs_fsync,
        .lock           = afs_lock,
        .flock          = afs_flock,
@@ -600,6 +601,63 @@ static int afs_readpages(struct file *file, struct address_space *mapping,
        return ret;
 }
 
+/*
+ * Adjust the dirty region of the page on truncation or full invalidation,
+ * getting rid of the markers altogether if the region is entirely invalidated.
+ */
+static void afs_invalidate_dirty(struct page *page, unsigned int offset,
+                                unsigned int length)
+{
+       struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
+       unsigned long priv;
+       unsigned int f, t, end = offset + length;
+
+       priv = page_private(page);
+
+       /* we clean up only if the entire page is being invalidated */
+       if (offset == 0 && length == thp_size(page))
+               goto full_invalidate;
+
+        /* If the page was dirtied by page_mkwrite(), the PTE stays writable
+         * and we don't get another notification to tell us to expand it
+         * again.
+         */
+       if (afs_is_page_dirty_mmapped(priv))
+               return;
+
+       /* We may need to shorten the dirty region */
+       f = afs_page_dirty_from(priv);
+       t = afs_page_dirty_to(priv);
+
+       if (t <= offset || f >= end)
+               return; /* Doesn't overlap */
+
+       if (f < offset && t > end)
+               return; /* Splits the dirty region - just absorb it */
+
+       if (f >= offset && t <= end)
+               goto undirty;
+
+       if (f < offset)
+               t = offset;
+       else
+               f = end;
+       if (f == t)
+               goto undirty;
+
+       priv = afs_page_dirty(f, t);
+       set_page_private(page, priv);
+       trace_afs_page_dirty(vnode, tracepoint_string("trunc"), page->index, priv);
+       return;
+
+undirty:
+       trace_afs_page_dirty(vnode, tracepoint_string("undirty"), page->index, priv);
+       clear_page_dirty_for_io(page);
+full_invalidate:
+       priv = (unsigned long)detach_page_private(page);
+       trace_afs_page_dirty(vnode, tracepoint_string("inval"), page->index, priv);
+}
+
 /*
  * invalidate part or all of a page
  * - release a page and clean up its private data if offset is 0 (indicating
@@ -608,31 +666,23 @@ static int afs_readpages(struct file *file, struct address_space *mapping,
 static void afs_invalidatepage(struct page *page, unsigned int offset,
                               unsigned int length)
 {
-       struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
-       unsigned long priv;
-
        _enter("{%lu},%u,%u", page->index, offset, length);
 
        BUG_ON(!PageLocked(page));
 
+#ifdef CONFIG_AFS_FSCACHE
        /* we clean up only if the entire page is being invalidated */
        if (offset == 0 && length == PAGE_SIZE) {
-#ifdef CONFIG_AFS_FSCACHE
                if (PageFsCache(page)) {
                        struct afs_vnode *vnode = AFS_FS_I(page->mapping->host);
                        fscache_wait_on_page_write(vnode->cache, page);
                        fscache_uncache_page(vnode->cache, page);
                }
+       }
 #endif
 
-               if (PagePrivate(page)) {
-                       priv = page_private(page);
-                       trace_afs_page_dirty(vnode, tracepoint_string("inval"),
-                                            page->index, priv);
-                       set_page_private(page, 0);
-                       ClearPagePrivate(page);
-               }
-       }
+       if (PagePrivate(page))
+               afs_invalidate_dirty(page, offset, length);
 
        _leave("");
 }
@@ -660,11 +710,9 @@ static int afs_releasepage(struct page *page, gfp_t gfp_flags)
 #endif
 
        if (PagePrivate(page)) {
-               priv = page_private(page);
+               priv = (unsigned long)detach_page_private(page);
                trace_afs_page_dirty(vnode, tracepoint_string("rel"),
                                     page->index, priv);
-               set_page_private(page, 0);
-               ClearPagePrivate(page);
        }
 
        /* indicate that the page can be released */
index 81b0485fd22ad59ce6b216bb13abf31d1730a92d..14d5d75f4b6ed84156665986e69833123575f96e 100644 (file)
@@ -812,6 +812,7 @@ struct afs_operation {
                        pgoff_t         last;           /* last page in mapping to deal with */
                        unsigned        first_offset;   /* offset into mapping[first] */
                        unsigned        last_to;        /* amount of mapping[last] */
+                       bool            laundering;     /* Laundering page, PG_writeback not set */
                } store;
                struct {
                        struct iattr    *attr;
@@ -857,6 +858,62 @@ struct afs_vnode_cache_aux {
        u64                     data_version;
 } __packed;
 
+/*
+ * We use page->private to hold the amount of the page that we've written to,
+ * splitting the field into two parts.  However, we need to represent a range
+ * 0...PAGE_SIZE, so we reduce the resolution if the size of the page
+ * exceeds what we can encode.
+ */
+#ifdef CONFIG_64BIT
+#define __AFS_PAGE_PRIV_MASK   0x7fffffffUL
+#define __AFS_PAGE_PRIV_SHIFT  32
+#define __AFS_PAGE_PRIV_MMAPPED        0x80000000UL
+#else
+#define __AFS_PAGE_PRIV_MASK   0x7fffUL
+#define __AFS_PAGE_PRIV_SHIFT  16
+#define __AFS_PAGE_PRIV_MMAPPED        0x8000UL
+#endif
+
+static inline unsigned int afs_page_dirty_resolution(void)
+{
+       int shift = PAGE_SHIFT - (__AFS_PAGE_PRIV_SHIFT - 1);
+       return (shift > 0) ? shift : 0;
+}
+
+static inline size_t afs_page_dirty_from(unsigned long priv)
+{
+       unsigned long x = priv & __AFS_PAGE_PRIV_MASK;
+
+       /* The lower bound is inclusive */
+       return x << afs_page_dirty_resolution();
+}
+
+static inline size_t afs_page_dirty_to(unsigned long priv)
+{
+       unsigned long x = (priv >> __AFS_PAGE_PRIV_SHIFT) & __AFS_PAGE_PRIV_MASK;
+
+       /* The upper bound is immediately beyond the region */
+       return (x + 1) << afs_page_dirty_resolution();
+}
+
+static inline unsigned long afs_page_dirty(size_t from, size_t to)
+{
+       unsigned int res = afs_page_dirty_resolution();
+       from >>= res;
+       to = (to - 1) >> res;
+       return (to << __AFS_PAGE_PRIV_SHIFT) | from;
+}
+
+static inline unsigned long afs_page_dirty_mmapped(unsigned long priv)
+{
+       return priv | __AFS_PAGE_PRIV_MMAPPED;
+}
+
+static inline bool afs_is_page_dirty_mmapped(unsigned long priv)
+{
+       return priv & __AFS_PAGE_PRIV_MMAPPED;
+}
+
 #include <trace/events/afs.h>
 
 /*****************************************************************************/
index da12abd6db213b20c2b8ffda1f4bd25ee00bf450..50371207f3273e9c6c1862b3792aad001aa4c2f5 100644 (file)
@@ -76,7 +76,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
  */
 int afs_write_begin(struct file *file, struct address_space *mapping,
                    loff_t pos, unsigned len, unsigned flags,
-                   struct page **pagep, void **fsdata)
+                   struct page **_page, void **fsdata)
 {
        struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
        struct page *page;
@@ -90,11 +90,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
        _enter("{%llx:%llu},{%lx},%u,%u",
               vnode->fid.vid, vnode->fid.vnode, index, from, to);
 
-       /* We want to store information about how much of a page is altered in
-        * page->private.
-        */
-       BUILD_BUG_ON(PAGE_SIZE > 32768 && sizeof(page->private) < 8);
-
        page = grab_cache_page_write_begin(mapping, index, flags);
        if (!page)
                return -ENOMEM;
@@ -110,9 +105,6 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
                SetPageUptodate(page);
        }
 
-       /* page won't leak in error case: it eventually gets cleaned off LRU */
-       *pagep = page;
-
 try_again:
        /* See if this page is already partially written in a way that we can
         * merge the new write with.
@@ -120,8 +112,8 @@ try_again:
        t = f = 0;
        if (PagePrivate(page)) {
                priv = page_private(page);
-               f = priv & AFS_PRIV_MAX;
-               t = priv >> AFS_PRIV_SHIFT;
+               f = afs_page_dirty_from(priv);
+               t = afs_page_dirty_to(priv);
                ASSERTCMP(f, <=, t);
        }
 
@@ -138,21 +130,9 @@ try_again:
                if (!test_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags) &&
                    (to < f || from > t))
                        goto flush_conflicting_write;
-               if (from < f)
-                       f = from;
-               if (to > t)
-                       t = to;
-       } else {
-               f = from;
-               t = to;
        }
 
-       priv = (unsigned long)t << AFS_PRIV_SHIFT;
-       priv |= f;
-       trace_afs_page_dirty(vnode, tracepoint_string("begin"),
-                            page->index, priv);
-       SetPagePrivate(page);
-       set_page_private(page, priv);
+       *_page = page;
        _leave(" = 0");
        return 0;
 
@@ -162,17 +142,18 @@ try_again:
 flush_conflicting_write:
        _debug("flush conflict");
        ret = write_one_page(page);
-       if (ret < 0) {
-               _leave(" = %d", ret);
-               return ret;
-       }
+       if (ret < 0)
+               goto error;
 
        ret = lock_page_killable(page);
-       if (ret < 0) {
-               _leave(" = %d", ret);
-               return ret;
-       }
+       if (ret < 0)
+               goto error;
        goto try_again;
+
+error:
+       put_page(page);
+       _leave(" = %d", ret);
+       return ret;
 }
 
 /*
@@ -184,6 +165,9 @@ int afs_write_end(struct file *file, struct address_space *mapping,
 {
        struct afs_vnode *vnode = AFS_FS_I(file_inode(file));
        struct key *key = afs_file_key(file);
+       unsigned long priv;
+       unsigned int f, from = pos & (PAGE_SIZE - 1);
+       unsigned int t, to = from + copied;
        loff_t i_size, maybe_i_size;
        int ret;
 
@@ -215,6 +199,25 @@ int afs_write_end(struct file *file, struct address_space *mapping,
                SetPageUptodate(page);
        }
 
+       if (PagePrivate(page)) {
+               priv = page_private(page);
+               f = afs_page_dirty_from(priv);
+               t = afs_page_dirty_to(priv);
+               if (from < f)
+                       f = from;
+               if (to > t)
+                       t = to;
+               priv = afs_page_dirty(f, t);
+               set_page_private(page, priv);
+               trace_afs_page_dirty(vnode, tracepoint_string("dirty+"),
+                                    page->index, priv);
+       } else {
+               priv = afs_page_dirty(from, to);
+               attach_page_private(page, (void *)priv);
+               trace_afs_page_dirty(vnode, tracepoint_string("dirty"),
+                                    page->index, priv);
+       }
+
        set_page_dirty(page);
        if (PageDirty(page))
                _debug("dirtied");
@@ -334,10 +337,9 @@ static void afs_pages_written_back(struct afs_vnode *vnode,
                ASSERTCMP(pv.nr, ==, count);
 
                for (loop = 0; loop < count; loop++) {
-                       priv = page_private(pv.pages[loop]);
+                       priv = (unsigned long)detach_page_private(pv.pages[loop]);
                        trace_afs_page_dirty(vnode, tracepoint_string("clear"),
                                             pv.pages[loop]->index, priv);
-                       set_page_private(pv.pages[loop], 0);
                        end_page_writeback(pv.pages[loop]);
                }
                first += count;
@@ -396,7 +398,8 @@ static void afs_store_data_success(struct afs_operation *op)
        op->ctime = op->file[0].scb.status.mtime_client;
        afs_vnode_commit_status(op, &op->file[0]);
        if (op->error == 0) {
-               afs_pages_written_back(vnode, op->store.first, op->store.last);
+               if (!op->store.laundering)
+                       afs_pages_written_back(vnode, op->store.first, op->store.last);
                afs_stat_v(vnode, n_stores);
                atomic_long_add((op->store.last * PAGE_SIZE + op->store.last_to) -
                                (op->store.first * PAGE_SIZE + op->store.first_offset),
@@ -415,7 +418,7 @@ static const struct afs_operation_ops afs_store_data_operation = {
  */
 static int afs_store_data(struct address_space *mapping,
                          pgoff_t first, pgoff_t last,
-                         unsigned offset, unsigned to)
+                         unsigned offset, unsigned to, bool laundering)
 {
        struct afs_vnode *vnode = AFS_FS_I(mapping->host);
        struct afs_operation *op;
@@ -448,6 +451,7 @@ static int afs_store_data(struct address_space *mapping,
        op->store.last = last;
        op->store.first_offset = offset;
        op->store.last_to = to;
+       op->store.laundering = laundering;
        op->mtime = vnode->vfs_inode.i_mtime;
        op->flags |= AFS_OPERATION_UNINTR;
        op->ops = &afs_store_data_operation;
@@ -509,8 +513,8 @@ static int afs_write_back_from_locked_page(struct address_space *mapping,
         */
        start = primary_page->index;
        priv = page_private(primary_page);
-       offset = priv & AFS_PRIV_MAX;
-       to = priv >> AFS_PRIV_SHIFT;
+       offset = afs_page_dirty_from(priv);
+       to = afs_page_dirty_to(priv);
        trace_afs_page_dirty(vnode, tracepoint_string("store"),
                             primary_page->index, priv);
 
@@ -555,8 +559,8 @@ static int afs_write_back_from_locked_page(struct address_space *mapping,
                        }
 
                        priv = page_private(page);
-                       f = priv & AFS_PRIV_MAX;
-                       t = priv >> AFS_PRIV_SHIFT;
+                       f = afs_page_dirty_from(priv);
+                       t = afs_page_dirty_to(priv);
                        if (f != 0 &&
                            !test_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags)) {
                                unlock_page(page);
@@ -601,7 +605,7 @@ no_more:
        if (end > i_size)
                to = i_size & ~PAGE_MASK;
 
-       ret = afs_store_data(mapping, first, last, offset, to);
+       ret = afs_store_data(mapping, first, last, offset, to, false);
        switch (ret) {
        case 0:
                ret = count;
@@ -857,12 +861,14 @@ vm_fault_t afs_page_mkwrite(struct vm_fault *vmf)
         */
        wait_on_page_writeback(vmf->page);
 
-       priv = (unsigned long)PAGE_SIZE << AFS_PRIV_SHIFT; /* To */
-       priv |= 0; /* From */
+       priv = afs_page_dirty(0, PAGE_SIZE);
+       priv = afs_page_dirty_mmapped(priv);
        trace_afs_page_dirty(vnode, tracepoint_string("mkwrite"),
                             vmf->page->index, priv);
-       SetPagePrivate(vmf->page);
-       set_page_private(vmf->page, priv);
+       if (PagePrivate(vmf->page))
+               set_page_private(vmf->page, priv);
+       else
+               attach_page_private(vmf->page, (void *)priv);
        file_update_time(file);
 
        sb_end_pagefault(inode->i_sb);
@@ -915,19 +921,18 @@ int afs_launder_page(struct page *page)
                f = 0;
                t = PAGE_SIZE;
                if (PagePrivate(page)) {
-                       f = priv & AFS_PRIV_MAX;
-                       t = priv >> AFS_PRIV_SHIFT;
+                       f = afs_page_dirty_from(priv);
+                       t = afs_page_dirty_to(priv);
                }
 
                trace_afs_page_dirty(vnode, tracepoint_string("launder"),
                                     page->index, priv);
-               ret = afs_store_data(mapping, page->index, page->index, t, f);
+               ret = afs_store_data(mapping, page->index, page->index, t, f, true);
        }
 
+       priv = (unsigned long)detach_page_private(page);
        trace_afs_page_dirty(vnode, tracepoint_string("laundered"),
                             page->index, priv);
-       set_page_private(page, 0);
-       ClearPagePrivate(page);
 
 #ifdef CONFIG_AFS_FSCACHE
        if (PageFsCache(page)) {
index 84f3c4f575318d1691068eed06827f573f4be83b..95c573dcda1169d24438775fb143a94dbd1706a2 100644 (file)
@@ -85,7 +85,7 @@ static int afs_xattr_get_acl(const struct xattr_handler *handler,
                        if (acl->size <= size)
                                memcpy(buffer, acl->data, acl->size);
                        else
-                               op->error = -ERANGE;
+                               ret = -ERANGE;
                }
        }
 
@@ -148,11 +148,6 @@ static const struct xattr_handler afs_xattr_afs_acl_handler = {
        .set    = afs_xattr_set_acl,
 };
 
-static void yfs_acl_put(struct afs_operation *op)
-{
-       yfs_free_opaque_acl(op->yacl);
-}
-
 static const struct afs_operation_ops yfs_fetch_opaque_acl_operation = {
        .issue_yfs_rpc  = yfs_fs_fetch_opaque_acl,
        .success        = afs_acl_success,
@@ -246,7 +241,7 @@ error:
 static const struct afs_operation_ops yfs_store_opaque_acl2_operation = {
        .issue_yfs_rpc  = yfs_fs_store_opaque_acl2,
        .success        = afs_acl_success,
-       .put            = yfs_acl_put,
+       .put            = afs_acl_put,
 };
 
 /*
index 3b1239b7e90d8cffaa957e30a507dad2b8174afd..bd787e71a657f9b683922eeb7cd2ac5b655eb620 100644 (file)
@@ -1990,6 +1990,7 @@ void yfs_fs_store_opaque_acl2(struct afs_operation *op)
        memcpy(bp, acl->data, acl->size);
        if (acl->size != size)
                memset((void *)bp + acl->size, 0, size - acl->size);
+       bp += size / sizeof(__be32);
        yfs_check_req(call, bp);
 
        trace_afs_make_fs_call(call, &vp->fid);
index b6b3d052ca86dee2084da5d806d7848e80cac1c1..fa50e8936f5fc30205bfb845afd70e1f3e7f366a 100644 (file)
@@ -1690,7 +1690,7 @@ struct elf_thread_core_info {
        struct elf_thread_core_info *next;
        struct task_struct *task;
        struct elf_prstatus prstatus;
-       struct memelfnote notes[0];
+       struct memelfnote notes[];
 };
 
 struct elf_note_info {
index b3268f4ea5f34c187108a628890231d3eec43396..771a036867dc05e5dbba4dd9f06d6536c9279c0c 100644 (file)
@@ -544,7 +544,18 @@ static int resolve_indirect_ref(struct btrfs_fs_info *fs_info,
        int level = ref->level;
        struct btrfs_key search_key = ref->key_for_search;
 
-       root = btrfs_get_fs_root(fs_info, ref->root_id, false);
+       /*
+        * If we're search_commit_root we could possibly be holding locks on
+        * other tree nodes.  This happens when qgroups does backref walks when
+        * adding new delayed refs.  To deal with this we need to look in cache
+        * for the root, and if we don't find it then we need to search the
+        * tree_root's commit root, thus the btrfs_get_fs_root_commit_root usage
+        * here.
+        */
+       if (path->search_commit_root)
+               root = btrfs_get_fs_root_commit_root(fs_info, path, ref->root_id);
+       else
+               root = btrfs_get_fs_root(fs_info, ref->root_id, false);
        if (IS_ERR(root)) {
                ret = PTR_ERR(root);
                goto out_free;
index c0f1d6818df769604a3d4652d6bd684f49195d0f..3ba6f3839d3929e5ab6d7d60ce76ccd8b44a5387 100644 (file)
@@ -2024,6 +2024,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                key.offset = 0;
                btrfs_release_path(path);
        }
+       btrfs_release_path(path);
 
        list_for_each_entry(space_info, &info->space_info, list) {
                int i;
index aac3d6f4e35b170933d43a5befa0be88f89a2966..0378933d163c6d27dca020d960dc0a782fd25fba 100644 (file)
@@ -3564,6 +3564,8 @@ struct reada_control *btrfs_reada_add(struct btrfs_root *root,
 int btrfs_reada_wait(void *handle);
 void btrfs_reada_detach(void *handle);
 int btree_readahead_hook(struct extent_buffer *eb, int err);
+void btrfs_reada_remove_dev(struct btrfs_device *dev);
+void btrfs_reada_undo_remove_dev(struct btrfs_device *dev);
 
 static inline int is_fstree(u64 rootid)
 {
index 4a0243cb9d9730401f967c46ede2ec3a62a58556..5b9e3f3ace22cf7ef89cf532dfd9f00c1ea9a81d 100644 (file)
@@ -688,6 +688,9 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
        }
        btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);
 
+       if (!scrub_ret)
+               btrfs_reada_remove_dev(src_device);
+
        /*
         * We have to use this loop approach because at this point src_device
         * has to be available for transaction commit to complete, yet new
@@ -696,6 +699,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
        while (1) {
                trans = btrfs_start_transaction(root, 0);
                if (IS_ERR(trans)) {
+                       btrfs_reada_undo_remove_dev(src_device);
                        mutex_unlock(&dev_replace->lock_finishing_cancel_unmount);
                        return PTR_ERR(trans);
                }
@@ -746,6 +750,7 @@ error:
                up_write(&dev_replace->rwsem);
                mutex_unlock(&fs_info->chunk_mutex);
                mutex_unlock(&fs_info->fs_devices->device_list_mutex);
+               btrfs_reada_undo_remove_dev(src_device);
                btrfs_rm_dev_replace_blocked(fs_info);
                if (tgt_device)
                        btrfs_destroy_dev_replace_tgtdev(tgt_device);
index 8e3438672a82d2f53c78922fa43572e1fc130eb8..af97ddcc6b3e8710cf9a55a4064192b3b1027b81 100644 (file)
@@ -1281,32 +1281,26 @@ int btrfs_add_log_tree(struct btrfs_trans_handle *trans,
        return 0;
 }
 
-struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
-                                       struct btrfs_key *key)
+static struct btrfs_root *read_tree_root_path(struct btrfs_root *tree_root,
+                                             struct btrfs_path *path,
+                                             struct btrfs_key *key)
 {
        struct btrfs_root *root;
        struct btrfs_fs_info *fs_info = tree_root->fs_info;
-       struct btrfs_path *path;
        u64 generation;
        int ret;
        int level;
 
-       path = btrfs_alloc_path();
-       if (!path)
-               return ERR_PTR(-ENOMEM);
-
        root = btrfs_alloc_root(fs_info, key->objectid, GFP_NOFS);
-       if (!root) {
-               ret = -ENOMEM;
-               goto alloc_fail;
-       }
+       if (!root)
+               return ERR_PTR(-ENOMEM);
 
        ret = btrfs_find_root(tree_root, key, path,
                              &root->root_item, &root->root_key);
        if (ret) {
                if (ret > 0)
                        ret = -ENOENT;
-               goto find_fail;
+               goto fail;
        }
 
        generation = btrfs_root_generation(&root->root_item);
@@ -1317,21 +1311,31 @@ struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
        if (IS_ERR(root->node)) {
                ret = PTR_ERR(root->node);
                root->node = NULL;
-               goto find_fail;
+               goto fail;
        } else if (!btrfs_buffer_uptodate(root->node, generation, 0)) {
                ret = -EIO;
-               goto find_fail;
+               goto fail;
        }
        root->commit_root = btrfs_root_node(root);
-out:
-       btrfs_free_path(path);
        return root;
-
-find_fail:
+fail:
        btrfs_put_root(root);
-alloc_fail:
-       root = ERR_PTR(ret);
-       goto out;
+       return ERR_PTR(ret);
+}
+
+struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
+                                       struct btrfs_key *key)
+{
+       struct btrfs_root *root;
+       struct btrfs_path *path;
+
+       path = btrfs_alloc_path();
+       if (!path)
+               return ERR_PTR(-ENOMEM);
+       root = read_tree_root_path(tree_root, path, key);
+       btrfs_free_path(path);
+
+       return root;
 }
 
 /*
@@ -1419,6 +1423,31 @@ static struct btrfs_root *btrfs_lookup_fs_root(struct btrfs_fs_info *fs_info,
        return root;
 }
 
+static struct btrfs_root *btrfs_get_global_root(struct btrfs_fs_info *fs_info,
+                                               u64 objectid)
+{
+       if (objectid == BTRFS_ROOT_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->tree_root);
+       if (objectid == BTRFS_EXTENT_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->extent_root);
+       if (objectid == BTRFS_CHUNK_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->chunk_root);
+       if (objectid == BTRFS_DEV_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->dev_root);
+       if (objectid == BTRFS_CSUM_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->csum_root);
+       if (objectid == BTRFS_QUOTA_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->quota_root) ?
+                       fs_info->quota_root : ERR_PTR(-ENOENT);
+       if (objectid == BTRFS_UUID_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->uuid_root) ?
+                       fs_info->uuid_root : ERR_PTR(-ENOENT);
+       if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
+               return btrfs_grab_root(fs_info->free_space_root) ?
+                       fs_info->free_space_root : ERR_PTR(-ENOENT);
+       return NULL;
+}
+
 int btrfs_insert_fs_root(struct btrfs_fs_info *fs_info,
                         struct btrfs_root *root)
 {
@@ -1518,25 +1547,9 @@ static struct btrfs_root *btrfs_get_root_ref(struct btrfs_fs_info *fs_info,
        struct btrfs_key key;
        int ret;
 
-       if (objectid == BTRFS_ROOT_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->tree_root);
-       if (objectid == BTRFS_EXTENT_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->extent_root);
-       if (objectid == BTRFS_CHUNK_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->chunk_root);
-       if (objectid == BTRFS_DEV_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->dev_root);
-       if (objectid == BTRFS_CSUM_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->csum_root);
-       if (objectid == BTRFS_QUOTA_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->quota_root) ?
-                       fs_info->quota_root : ERR_PTR(-ENOENT);
-       if (objectid == BTRFS_UUID_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->uuid_root) ?
-                       fs_info->uuid_root : ERR_PTR(-ENOENT);
-       if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
-               return btrfs_grab_root(fs_info->free_space_root) ?
-                       fs_info->free_space_root : ERR_PTR(-ENOENT);
+       root = btrfs_get_global_root(fs_info, objectid);
+       if (root)
+               return root;
 again:
        root = btrfs_lookup_fs_root(fs_info, objectid);
        if (root) {
@@ -1621,6 +1634,52 @@ struct btrfs_root *btrfs_get_new_fs_root(struct btrfs_fs_info *fs_info,
        return btrfs_get_root_ref(fs_info, objectid, anon_dev, true);
 }
 
+/*
+ * btrfs_get_fs_root_commit_root - return a root for the given objectid
+ * @fs_info:   the fs_info
+ * @objectid:  the objectid we need to lookup
+ *
+ * This is exclusively used for backref walking, and exists specifically because
+ * of how qgroups does lookups.  Qgroups will do a backref lookup at delayed ref
+ * creation time, which means we may have to read the tree_root in order to look
+ * up a fs root that is not in memory.  If the root is not in memory we will
+ * read the tree root commit root and look up the fs root from there.  This is a
+ * temporary root, it will not be inserted into the radix tree as it doesn't
+ * have the most uptodate information, it'll simply be discarded once the
+ * backref code is finished using the root.
+ */
+struct btrfs_root *btrfs_get_fs_root_commit_root(struct btrfs_fs_info *fs_info,
+                                                struct btrfs_path *path,
+                                                u64 objectid)
+{
+       struct btrfs_root *root;
+       struct btrfs_key key;
+
+       ASSERT(path->search_commit_root && path->skip_locking);
+
+       /*
+        * This can return -ENOENT if we ask for a root that doesn't exist, but
+        * since this is called via the backref walking code we won't be looking
+        * up a root that doesn't exist, unless there's corruption.  So if root
+        * != NULL just return it.
+        */
+       root = btrfs_get_global_root(fs_info, objectid);
+       if (root)
+               return root;
+
+       root = btrfs_lookup_fs_root(fs_info, objectid);
+       if (root)
+               return root;
+
+       key.objectid = objectid;
+       key.type = BTRFS_ROOT_ITEM_KEY;
+       key.offset = (u64)-1;
+       root = read_tree_root_path(fs_info->tree_root, path, &key);
+       btrfs_release_path(path);
+
+       return root;
+}
+
 /*
  * called by the kthread helper functions to finally call the bio end_io
  * functions.  This is where read checksum verification actually happens
index fee69ced58b4b921df680dd9b39c87bdceb9df57..182540bdcea0fd3002435b034d6bd84c839949bb 100644 (file)
@@ -69,6 +69,9 @@ struct btrfs_root *btrfs_get_fs_root(struct btrfs_fs_info *fs_info,
                                     u64 objectid, bool check_ref);
 struct btrfs_root *btrfs_get_new_fs_root(struct btrfs_fs_info *fs_info,
                                         u64 objectid, dev_t anon_dev);
+struct btrfs_root *btrfs_get_fs_root_commit_root(struct btrfs_fs_info *fs_info,
+                                                struct btrfs_path *path,
+                                                u64 objectid);
 
 void btrfs_free_fs_info(struct btrfs_fs_info *fs_info);
 int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info);
index 3b21fee13e77811e1d6cba72478ef8f805ef28a8..5fd60b13f4f83287df44432acfb305228c674495 100644 (file)
@@ -3185,7 +3185,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
                struct btrfs_tree_block_info *bi;
                if (item_size < sizeof(*ei) + sizeof(*bi)) {
                        btrfs_crit(info,
-"invalid extent item size for key (%llu, %u, %llu) owner %llu, has %u expect >= %lu",
+"invalid extent item size for key (%llu, %u, %llu) owner %llu, has %u expect >= %zu",
                                   key.objectid, key.type, key.offset,
                                   owner_objectid, item_size,
                                   sizeof(*ei) + sizeof(*bi));
index 0ff659455b1ebc8588ef781cab448294579b14ba..87355a38a654702e154e3c9490d0c3da590743d6 100644 (file)
@@ -3628,7 +3628,8 @@ static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
                inode_lock_shared(inode);
                ret = btrfs_direct_IO(iocb, to);
                inode_unlock_shared(inode);
-               if (ret < 0)
+               if (ret < 0 || !iov_iter_count(to) ||
+                   iocb->ki_pos >= i_size_read(file_inode(iocb->ki_filp)))
                        return ret;
        }
 
index 936c3137c6467d30e8bca4fdb6398e51b11c52ae..da58c58ef9aa1cbb598306ca81af3583979b5f1b 100644 (file)
@@ -9672,10 +9672,16 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
                 * clear_offset by our extent size.
                 */
                clear_offset += ins.offset;
-               btrfs_dec_block_group_reservations(fs_info, ins.objectid);
 
                last_alloc = ins.offset;
                trans = insert_prealloc_file_extent(trans, inode, &ins, cur_offset);
+               /*
+                * Now that we inserted the prealloc extent we can finally
+                * decrement the number of reservations in the block group.
+                * If we did it before, we could race with relocation and have
+                * relocation miss the reserved extent, making it fail later.
+                */
+               btrfs_dec_block_group_reservations(fs_info, ins.objectid);
                if (IS_ERR(trans)) {
                        ret = PTR_ERR(trans);
                        btrfs_free_reserved_extent(fs_info, ins.objectid,
index 580899bdb9915bad902322d530808532f7e8a975..c54ea658663279aba968fa8a9365efcbe3b94ee1 100644 (file)
@@ -1026,6 +1026,10 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
                btrfs_item_key_to_cpu(leaf, &found_key, slot);
 
                if (found_key.type == BTRFS_ROOT_REF_KEY) {
+
+                       /* Release locks on tree_root before we access quota_root */
+                       btrfs_release_path(path);
+
                        ret = add_qgroup_item(trans, quota_root,
                                              found_key.offset);
                        if (ret) {
@@ -1044,6 +1048,20 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
                                btrfs_abort_transaction(trans, ret);
                                goto out_free_path;
                        }
+                       ret = btrfs_search_slot_for_read(tree_root, &found_key,
+                                                        path, 1, 0);
+                       if (ret < 0) {
+                               btrfs_abort_transaction(trans, ret);
+                               goto out_free_path;
+                       }
+                       if (ret > 0) {
+                               /*
+                                * Shouldn't happen, but in case it does we
+                                * don't need to do the btrfs_next_item, just
+                                * continue.
+                                */
+                               continue;
+                       }
                }
                ret = btrfs_next_item(tree_root, path);
                if (ret < 0) {
index 9d4f5316a7e8be1464d9349b6ef9a9fb20fccfcc..d9a166eb344e6484a6e86b11a4c5e7ca09dc35fa 100644 (file)
@@ -421,6 +421,9 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
                if (!dev->bdev)
                        continue;
 
+               if (test_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state))
+                       continue;
+
                if (dev_replace_is_ongoing &&
                    dev == fs_info->dev_replace.tgtdev) {
                        /*
@@ -445,6 +448,8 @@ static struct reada_extent *reada_find_extent(struct btrfs_fs_info *fs_info,
                }
                have_zone = 1;
        }
+       if (!have_zone)
+               radix_tree_delete(&fs_info->reada_tree, index);
        spin_unlock(&fs_info->reada_lock);
        up_read(&fs_info->dev_replace.rwsem);
 
@@ -1020,3 +1025,45 @@ void btrfs_reada_detach(void *handle)
 
        kref_put(&rc->refcnt, reada_control_release);
 }
+
+/*
+ * Before removing a device (device replace or device remove ioctls), call this
+ * function to wait for all existing readahead requests on the device and to
+ * make sure no one queues more readahead requests for the device.
+ *
+ * Must be called without holding neither the device list mutex nor the device
+ * replace semaphore, otherwise it will deadlock.
+ */
+void btrfs_reada_remove_dev(struct btrfs_device *dev)
+{
+       struct btrfs_fs_info *fs_info = dev->fs_info;
+
+       /* Serialize with readahead extent creation at reada_find_extent(). */
+       spin_lock(&fs_info->reada_lock);
+       set_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state);
+       spin_unlock(&fs_info->reada_lock);
+
+       /*
+        * There might be readahead requests added to the radix trees which
+        * were not yet added to the readahead work queue. We need to start
+        * them and wait for their completion, otherwise we can end up with
+        * use-after-free problems when dropping the last reference on the
+        * readahead extents and their zones, as they need to access the
+        * device structure.
+        */
+       reada_start_machine(fs_info);
+       btrfs_flush_workqueue(fs_info->readahead_workers);
+}
+
+/*
+ * If when removing a device (device replace or device remove ioctls) an error
+ * happens after calling btrfs_reada_remove_dev(), call this to undo what that
+ * function did. This is safe to call even if btrfs_reada_remove_dev() was not
+ * called before.
+ */
+void btrfs_reada_undo_remove_dev(struct btrfs_device *dev)
+{
+       spin_lock(&dev->fs_info->reada_lock);
+       clear_bit(BTRFS_DEV_STATE_NO_READA, &dev->dev_state);
+       spin_unlock(&dev->fs_info->reada_lock);
+}
index f0ffd5ee77bd5700847bb580417a3f3242f88630..8784b74f5232e797ceacede9c31bf19e64c9247d 100644 (file)
@@ -760,18 +760,36 @@ int btrfs_check_chunk_valid(struct extent_buffer *leaf,
        u64 type;
        u64 features;
        bool mixed = false;
+       int raid_index;
+       int nparity;
+       int ncopies;
 
        length = btrfs_chunk_length(leaf, chunk);
        stripe_len = btrfs_chunk_stripe_len(leaf, chunk);
        num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
        sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk);
        type = btrfs_chunk_type(leaf, chunk);
+       raid_index = btrfs_bg_flags_to_raid_index(type);
+       ncopies = btrfs_raid_array[raid_index].ncopies;
+       nparity = btrfs_raid_array[raid_index].nparity;
 
        if (!num_stripes) {
                chunk_err(leaf, chunk, logical,
                          "invalid chunk num_stripes, have %u", num_stripes);
                return -EUCLEAN;
        }
+       if (num_stripes < ncopies) {
+               chunk_err(leaf, chunk, logical,
+                         "invalid chunk num_stripes < ncopies, have %u < %d",
+                         num_stripes, ncopies);
+               return -EUCLEAN;
+       }
+       if (nparity && num_stripes == nparity) {
+               chunk_err(leaf, chunk, logical,
+                         "invalid chunk num_stripes == nparity, have %u == %d",
+                         num_stripes, nparity);
+               return -EUCLEAN;
+       }
        if (!IS_ALIGNED(logical, fs_info->sectorsize)) {
                chunk_err(leaf, chunk, logical,
                "invalid chunk logical, have %llu should aligned to %u",
index 58b9c419a2b6b257b61f43a21dd289560878a55e..b1e48078c3189c9527218ee18872415f6e7b1e33 100644 (file)
@@ -431,7 +431,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info)
 
        atomic_set(&dev->reada_in_flight, 0);
        atomic_set(&dev->dev_stats_ccnt, 0);
-       btrfs_device_data_ordered_init(dev);
+       btrfs_device_data_ordered_init(dev, fs_info);
        INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
        INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
        extent_io_tree_init(fs_info, &dev->alloc_state,
@@ -2099,6 +2099,8 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
 
        mutex_unlock(&uuid_mutex);
        ret = btrfs_shrink_device(device, 0);
+       if (!ret)
+               btrfs_reada_remove_dev(device);
        mutex_lock(&uuid_mutex);
        if (ret)
                goto error_undo;
@@ -2179,6 +2181,7 @@ out:
        return ret;
 
 error_undo:
+       btrfs_reada_undo_remove_dev(device);
        if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) {
                mutex_lock(&fs_info->chunk_mutex);
                list_add(&device->dev_alloc_list,
index bf27ac07d3153912c4683c2c7534970639854e78..232f02bd214fc44e013574357c1e3cd926c6e77f 100644 (file)
@@ -39,10 +39,10 @@ struct btrfs_io_geometry {
 #if BITS_PER_LONG==32 && defined(CONFIG_SMP)
 #include <linux/seqlock.h>
 #define __BTRFS_NEED_DEVICE_DATA_ORDERED
-#define btrfs_device_data_ordered_init(device) \
-       seqcount_init(&device->data_seqcount)
+#define btrfs_device_data_ordered_init(device, info)                           \
+       seqcount_mutex_init(&device->data_seqcount, &info->chunk_mutex)
 #else
-#define btrfs_device_data_ordered_init(device) do { } while (0)
+#define btrfs_device_data_ordered_init(device, info) do { } while (0)
 #endif
 
 #define BTRFS_DEV_STATE_WRITEABLE      (0)
@@ -50,6 +50,7 @@ struct btrfs_io_geometry {
 #define BTRFS_DEV_STATE_MISSING                (2)
 #define BTRFS_DEV_STATE_REPLACE_TGT    (3)
 #define BTRFS_DEV_STATE_FLUSH_SENT     (4)
+#define BTRFS_DEV_STATE_NO_READA       (5)
 
 struct btrfs_device {
        struct list_head dev_list; /* device_list_mutex */
@@ -71,7 +72,8 @@ struct btrfs_device {
        blk_status_t last_flush_error;
 
 #ifdef __BTRFS_NEED_DEVICE_DATA_ORDERED
-       seqcount_t data_seqcount;
+       /* A seqcount_t with associated chunk_mutex (for lockdep) */
+       seqcount_mutex_t data_seqcount;
 #endif
 
        /* the internal btrfs device id */
@@ -162,11 +164,9 @@ btrfs_device_get_##name(const struct btrfs_device *dev)                    \
 static inline void                                                     \
 btrfs_device_set_##name(struct btrfs_device *dev, u64 size)            \
 {                                                                      \
-       preempt_disable();                                              \
        write_seqcount_begin(&dev->data_seqcount);                      \
        dev->name = size;                                               \
        write_seqcount_end(&dev->data_seqcount);                        \
-       preempt_enable();                                               \
 }
 #elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
 #define BTRFS_DEVICE_GETSET_FUNCS(name)                                        \
index 3080cda9e82457c40d50c0fe3afc1c9aac8fa2e4..8bda092e60c5a00118ec8d5159f8a30bdcd38a04 100644 (file)
@@ -121,7 +121,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
                _debug("reissue read");
                ret = bmapping->a_ops->readpage(NULL, backpage);
                if (ret < 0)
-                       goto unlock_discard;
+                       goto discard;
        }
 
        /* but the page may have been read before the monitor was installed, so
@@ -138,6 +138,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
 
 unlock_discard:
        unlock_page(backpage);
+discard:
        spin_lock_irq(&object->work_lock);
        list_del(&monitor->op_link);
        spin_unlock_irq(&object->work_lock);
index 5027bbdca4199454c4a91b6999d28adbb6202198..ded4229c314a0270ae60a288e67879944bad6acd 100644 (file)
@@ -4074,7 +4074,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
             vino.snap, inode);
 
        mutex_lock(&session->s_mutex);
-       session->s_seq++;
+       inc_session_sequence(session);
        dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq,
             (unsigned)seq);
 
index 08f1c0c31dc2dac37d1b833b43fa31c779ce7bc5..8f1d7500a7ecb236d3610474dbf0b8d74981b0d5 100644 (file)
@@ -4231,7 +4231,7 @@ static void handle_lease(struct ceph_mds_client *mdsc,
             dname.len, dname.name);
 
        mutex_lock(&session->s_mutex);
-       session->s_seq++;
+       inc_session_sequence(session);
 
        if (!inode) {
                dout("handle_lease no inode %llx\n", vino.ino);
@@ -4385,28 +4385,48 @@ static void maybe_recover_session(struct ceph_mds_client *mdsc)
 
 bool check_session_state(struct ceph_mds_session *s)
 {
-       if (s->s_state == CEPH_MDS_SESSION_CLOSING) {
-               dout("resending session close request for mds%d\n",
-                               s->s_mds);
-               request_close_session(s);
-               return false;
-       }
-       if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
-               if (s->s_state == CEPH_MDS_SESSION_OPEN) {
+       switch (s->s_state) {
+       case CEPH_MDS_SESSION_OPEN:
+               if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
                        s->s_state = CEPH_MDS_SESSION_HUNG;
                        pr_info("mds%d hung\n", s->s_mds);
                }
-       }
-       if (s->s_state == CEPH_MDS_SESSION_NEW ||
-           s->s_state == CEPH_MDS_SESSION_RESTARTING ||
-           s->s_state == CEPH_MDS_SESSION_CLOSED ||
-           s->s_state == CEPH_MDS_SESSION_REJECTED)
-               /* this mds is failed or recovering, just wait */
+               break;
+       case CEPH_MDS_SESSION_CLOSING:
+               /* Should never reach this when we're unmounting */
+               WARN_ON_ONCE(true);
+               fallthrough;
+       case CEPH_MDS_SESSION_NEW:
+       case CEPH_MDS_SESSION_RESTARTING:
+       case CEPH_MDS_SESSION_CLOSED:
+       case CEPH_MDS_SESSION_REJECTED:
                return false;
+       }
 
        return true;
 }
 
+/*
+ * If the sequence is incremented while we're waiting on a REQUEST_CLOSE reply,
+ * then we need to retransmit that request.
+ */
+void inc_session_sequence(struct ceph_mds_session *s)
+{
+       lockdep_assert_held(&s->s_mutex);
+
+       s->s_seq++;
+
+       if (s->s_state == CEPH_MDS_SESSION_CLOSING) {
+               int ret;
+
+               dout("resending session close request for mds%d\n", s->s_mds);
+               ret = request_close_session(s);
+               if (ret < 0)
+                       pr_err("unable to close session to mds%d: %d\n",
+                              s->s_mds, ret);
+       }
+}
+
 /*
  * delayed work -- periodically trim expired leases, renew caps with mds
  */
index cbf8af437140584c4ede3b756f99410c09837e33..f5adbebcb38e5ca53508afd03f4622fb838ae55c 100644 (file)
@@ -480,6 +480,7 @@ struct ceph_mds_client {
 extern const char *ceph_mds_op_name(int op);
 
 extern bool check_session_state(struct ceph_mds_session *s);
+void inc_session_sequence(struct ceph_mds_session *s);
 
 extern struct ceph_mds_session *
 __ceph_lookup_mds_session(struct ceph_mds_client *, int mds);
index 83cb4f26b689b3bddc3f2959495aa5aff13067e8..9b785f11e95ac75f24b206100f32ecef741b4988 100644 (file)
@@ -53,7 +53,7 @@ void ceph_handle_quota(struct ceph_mds_client *mdsc,
 
        /* increment msg sequence number */
        mutex_lock(&session->s_mutex);
-       session->s_seq++;
+       inc_session_sequence(session);
        mutex_unlock(&session->s_mutex);
 
        /* lookup inode */
index 0da39c16dab49312f45a6c0f69cc8211fb43cc45..b611f829cb611590f2baaf36ec799a2fabb0ad66 100644 (file)
@@ -873,7 +873,7 @@ void ceph_handle_snap(struct ceph_mds_client *mdsc,
             ceph_snap_op_name(op), split, trace_len);
 
        mutex_lock(&session->s_mutex);
-       session->s_seq++;
+       inc_session_sequence(session);
        mutex_unlock(&session->s_mutex);
 
        down_write(&mdsc->snap_rwsem);
index a768a09430c3a9c0cad71e2f47a8544acafdf9c0..686e0ad287880c15406a479a3acc209a8fa1396f 100644 (file)
@@ -1127,24 +1127,23 @@ static const struct file_operations debugfs_devm_entry_ops = {
  *     file will be created in the root of the debugfs filesystem.
  * @read_fn: function pointer called to print the seq_file content.
  */
-struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
-                                          struct dentry *parent,
-                                          int (*read_fn)(struct seq_file *s,
-                                                         void *data))
+void debugfs_create_devm_seqfile(struct device *dev, const char *name,
+                                struct dentry *parent,
+                                int (*read_fn)(struct seq_file *s, void *data))
 {
        struct debugfs_devm_entry *entry;
 
        if (IS_ERR(parent))
-               return ERR_PTR(-ENOENT);
+               return;
 
        entry = devm_kzalloc(dev, sizeof(*entry), GFP_KERNEL);
        if (!entry)
-               return ERR_PTR(-ENOMEM);
+               return;
 
        entry->read = read_fn;
        entry->dev = dev;
 
-       return debugfs_create_file(name, S_IRUGO, parent, entry,
-                                  &debugfs_devm_entry_ops);
+       debugfs_create_file(name, S_IRUGO, parent, entry,
+                           &debugfs_devm_entry_ops);
 }
 EXPORT_SYMBOL_GPL(debugfs_create_devm_seqfile);
index 5b81f3b080ee605317c465332f343b35e27c5ce7..ca50c90adc4c48796de1d766c686345bf9ece94a 100644 (file)
@@ -669,68 +669,8 @@ const struct file_operations ext4_dir_operations = {
 };
 
 #ifdef CONFIG_UNICODE
-static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
-                         const char *str, const struct qstr *name)
-{
-       struct qstr qstr = {.name = str, .len = len };
-       const struct dentry *parent = READ_ONCE(dentry->d_parent);
-       const struct inode *inode = d_inode_rcu(parent);
-       char strbuf[DNAME_INLINE_LEN];
-
-       if (!inode || !IS_CASEFOLDED(inode) ||
-           !EXT4_SB(inode->i_sb)->s_encoding) {
-               if (len != name->len)
-                       return -1;
-               return memcmp(str, name->name, len);
-       }
-
-       /*
-        * If the dentry name is stored in-line, then it may be concurrently
-        * modified by a rename.  If this happens, the VFS will eventually retry
-        * the lookup, so it doesn't matter what ->d_compare() returns.
-        * However, it's unsafe to call utf8_strncasecmp() with an unstable
-        * string.  Therefore, we have to copy the name into a temporary buffer.
-        */
-       if (len <= DNAME_INLINE_LEN - 1) {
-               memcpy(strbuf, str, len);
-               strbuf[len] = 0;
-               qstr.name = strbuf;
-               /* prevent compiler from optimizing out the temporary buffer */
-               barrier();
-       }
-
-       return ext4_ci_compare(inode, name, &qstr, false);
-}
-
-static int ext4_d_hash(const struct dentry *dentry, struct qstr *str)
-{
-       const struct ext4_sb_info *sbi = EXT4_SB(dentry->d_sb);
-       const struct unicode_map *um = sbi->s_encoding;
-       const struct inode *inode = d_inode_rcu(dentry);
-       unsigned char *norm;
-       int len, ret = 0;
-
-       if (!inode || !IS_CASEFOLDED(inode) || !um)
-               return 0;
-
-       norm = kmalloc(PATH_MAX, GFP_ATOMIC);
-       if (!norm)
-               return -ENOMEM;
-
-       len = utf8_casefold(um, str, norm, PATH_MAX);
-       if (len < 0) {
-               if (ext4_has_strict_mode(sbi))
-                       ret = -EINVAL;
-               goto out;
-       }
-       str->hash = full_name_hash(dentry, norm, len);
-out:
-       kfree(norm);
-       return ret;
-}
-
 const struct dentry_operations ext4_dentry_ops = {
-       .d_hash = ext4_d_hash,
-       .d_compare = ext4_d_compare,
+       .d_hash = generic_ci_d_hash,
+       .d_compare = generic_ci_d_compare,
 };
 #endif
index 254d1c26bea8a80228ace0c1dbe330b535cfe845..45fcdbf538d1198257f75af5a090eb6920df9c15 100644 (file)
@@ -1166,10 +1166,6 @@ struct ext4_inode_info {
 #define        EXT4_VALID_FS                   0x0001  /* Unmounted cleanly */
 #define        EXT4_ERROR_FS                   0x0002  /* Errors detected */
 #define        EXT4_ORPHAN_FS                  0x0004  /* Orphans being recovered */
-#define EXT4_FC_INELIGIBLE             0x0008  /* Fast commit ineligible */
-#define EXT4_FC_COMMITTING             0x0010  /* File system underoing a fast
-                                                * commit.
-                                                */
 #define EXT4_FC_REPLAY                 0x0020  /* Fast commit replay ongoing */
 
 /*
@@ -1431,6 +1427,10 @@ struct ext4_super_block {
  */
 #define EXT4_MF_MNTDIR_SAMPLED         0x0001
 #define EXT4_MF_FS_ABORTED             0x0002  /* Fatal error detected */
+#define EXT4_MF_FC_INELIGIBLE          0x0004  /* Fast commit ineligible */
+#define EXT4_MF_FC_COMMITTING          0x0008  /* File system underoing a fast
+                                                * commit.
+                                                */
 
 #ifdef CONFIG_FS_ENCRYPTION
 #define DUMMY_ENCRYPTION_ENABLED(sbi) ((sbi)->s_dummy_enc_policy.policy != NULL)
@@ -1443,14 +1443,6 @@ struct ext4_super_block {
 
 #define EXT4_ENC_UTF8_12_1     1
 
-/*
- * Flags for ext4_sb_info.s_encoding_flags.
- */
-#define EXT4_ENC_STRICT_MODE_FL        (1 << 0)
-
-#define ext4_has_strict_mode(sbi) \
-       (sbi->s_encoding_flags & EXT4_ENC_STRICT_MODE_FL)
-
 /*
  * fourth extended-fs super-block data in memory
  */
@@ -1500,10 +1492,6 @@ struct ext4_sb_info {
        struct kobject s_kobj;
        struct completion s_kobj_unregister;
        struct super_block *s_sb;
-#ifdef CONFIG_UNICODE
-       struct unicode_map *s_encoding;
-       __u16 s_encoding_flags;
-#endif
 
        /* Journaling */
        struct journal_s *s_journal;
index 559100f3e23cd2d78d7d1fb11eb8283b726df4ec..57cfa28919a99a356610e4ec2c61637d2f882214 100644 (file)
@@ -1471,16 +1471,16 @@ static int ext4_ext_search_left(struct inode *inode,
 }
 
 /*
- * search the closest allocated block to the right for *logical
- * and returns it at @logical + it's physical address at @phys
- * if *logical is the largest allocated block, the function
- * returns 0 at @phys
- * return value contains 0 (success) or error code
+ * Search the closest allocated block to the right for *logical
+ * and returns it at @logical + it's physical address at @phys.
+ * If not exists, return 0 and @phys is set to 0. We will return
+ * 1 which means we found an allocated block and ret_ex is valid.
+ * Or return a (< 0) error code.
  */
 static int ext4_ext_search_right(struct inode *inode,
                                 struct ext4_ext_path *path,
                                 ext4_lblk_t *logical, ext4_fsblk_t *phys,
-                                struct ext4_extent **ret_ex)
+                                struct ext4_extent *ret_ex)
 {
        struct buffer_head *bh = NULL;
        struct ext4_extent_header *eh;
@@ -1574,10 +1574,11 @@ got_index:
 found_extent:
        *logical = le32_to_cpu(ex->ee_block);
        *phys = ext4_ext_pblock(ex);
-       *ret_ex = ex;
+       if (ret_ex)
+               *ret_ex = *ex;
        if (bh)
                put_bh(bh);
-       return 0;
+       return 1;
 }
 
 /*
@@ -2868,8 +2869,8 @@ again:
                         */
                        lblk = ex_end + 1;
                        err = ext4_ext_search_right(inode, path, &lblk, &pblk,
-                                                   &ex);
-                       if (err)
+                                                   NULL);
+                       if (err < 0)
                                goto out;
                        if (pblk) {
                                partial.pclu = EXT4_B2C(sbi, pblk);
@@ -4039,7 +4040,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
                        struct ext4_map_blocks *map, int flags)
 {
        struct ext4_ext_path *path = NULL;
-       struct ext4_extent newex, *ex, *ex2;
+       struct ext4_extent newex, *ex, ex2;
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
        ext4_fsblk_t newblock = 0, pblk;
        int err = 0, depth, ret;
@@ -4175,15 +4176,14 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
        if (err)
                goto out;
        ar.lright = map->m_lblk;
-       ex2 = NULL;
        err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2);
-       if (err)
+       if (err < 0)
                goto out;
 
        /* Check if the extent after searching to the right implies a
         * cluster we can use. */
-       if ((sbi->s_cluster_ratio > 1) && ex2 &&
-           get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {
+       if ((sbi->s_cluster_ratio > 1) && err &&
+           get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) {
                ar.len = allocated = map->m_len;
                newblock = map->m_pblk;
                goto got_allocated_blocks;
index 447c8d93f48081c11ed85e6076df2617af4f20c0..8d43058386c3037f0525b85bda4c5d14d775c6b1 100644 (file)
@@ -269,7 +269,7 @@ void ext4_fc_mark_ineligible(struct super_block *sb, int reason)
            (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
                return;
 
-       sbi->s_mount_state |= EXT4_FC_INELIGIBLE;
+       sbi->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;
        WARN_ON(reason >= EXT4_FC_REASON_MAX);
        sbi->s_fc_stats.fc_ineligible_reason_count[reason]++;
 }
@@ -292,7 +292,7 @@ void ext4_fc_start_ineligible(struct super_block *sb, int reason)
 }
 
 /*
- * Stop a fast commit ineligible update. We set EXT4_FC_INELIGIBLE flag here
+ * Stop a fast commit ineligible update. We set EXT4_MF_FC_INELIGIBLE flag here
  * to ensure that after stopping the ineligible update, at least one full
  * commit takes place.
  */
@@ -302,13 +302,13 @@ void ext4_fc_stop_ineligible(struct super_block *sb)
            (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY))
                return;
 
-       EXT4_SB(sb)->s_mount_state |= EXT4_FC_INELIGIBLE;
+       EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FC_INELIGIBLE;
        atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates);
 }
 
 static inline int ext4_fc_is_ineligible(struct super_block *sb)
 {
-       return (EXT4_SB(sb)->s_mount_state & EXT4_FC_INELIGIBLE) ||
+       return (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FC_INELIGIBLE) ||
                atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates);
 }
 
@@ -358,7 +358,7 @@ static int ext4_fc_track_template(
        spin_lock(&sbi->s_fc_lock);
        if (list_empty(&EXT4_I(inode)->i_fc_list))
                list_add_tail(&EXT4_I(inode)->i_fc_list,
-                               (sbi->s_mount_state & EXT4_FC_COMMITTING) ?
+                               (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING) ?
                                &sbi->s_fc_q[FC_Q_STAGING] :
                                &sbi->s_fc_q[FC_Q_MAIN]);
        spin_unlock(&sbi->s_fc_lock);
@@ -411,7 +411,7 @@ static int __track_dentry_update(struct inode *inode, void *arg, bool update)
        node->fcd_name.len = dentry->d_name.len;
 
        spin_lock(&sbi->s_fc_lock);
-       if (sbi->s_mount_state & EXT4_FC_COMMITTING)
+       if (sbi->s_mount_flags & EXT4_MF_FC_COMMITTING)
                list_add_tail(&node->fcd_list,
                                &sbi->s_fc_dentry_q[FC_Q_STAGING]);
        else
@@ -846,7 +846,7 @@ static int ext4_fc_submit_inode_data_all(journal_t *journal)
        int ret = 0;
 
        spin_lock(&sbi->s_fc_lock);
-       sbi->s_mount_state |= EXT4_FC_COMMITTING;
+       sbi->s_mount_flags |= EXT4_MF_FC_COMMITTING;
        list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) {
                ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
                ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING);
@@ -964,7 +964,6 @@ static int ext4_fc_commit_dentry_updates(journal_t *journal, u32 *crc)
                        fc_dentry->fcd_parent, fc_dentry->fcd_ino,
                        fc_dentry->fcd_name.len,
                        fc_dentry->fcd_name.name, crc)) {
-                       spin_lock(&sbi->s_fc_lock);
                        ret = -ENOSPC;
                        goto lock_and_exit;
                }
@@ -1191,8 +1190,8 @@ static void ext4_fc_cleanup(journal_t *journal, int full)
        list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],
                                &sbi->s_fc_q[FC_Q_STAGING]);
 
-       sbi->s_mount_state &= ~EXT4_FC_COMMITTING;
-       sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
 
        if (full)
                sbi->s_fc_bytes = 0;
@@ -1617,8 +1616,10 @@ static int ext4_fc_replay_add_range(struct super_block *sb,
                if (ret == 0) {
                        /* Range is not mapped */
                        path = ext4_find_extent(inode, cur, NULL, 0);
-                       if (!path)
-                               continue;
+                       if (IS_ERR(path)) {
+                               iput(inode);
+                               return 0;
+                       }
                        memset(&newex, 0, sizeof(newex));
                        newex.ee_block = cpu_to_le32(cur);
                        ext4_ext_store_pblock(
@@ -2078,6 +2079,8 @@ static int ext4_fc_replay(journal_t *journal, struct buffer_head *bh,
 
 void ext4_fc_init(struct super_block *sb, journal_t *journal)
 {
+       int num_fc_blocks;
+
        /*
         * We set replay callback even if fast commit disabled because we may
         * could still have fast commit blocks that need to be replayed even if
@@ -2087,7 +2090,15 @@ void ext4_fc_init(struct super_block *sb, journal_t *journal)
        if (!test_opt2(sb, JOURNAL_FAST_COMMIT))
                return;
        journal->j_fc_cleanup_callback = ext4_fc_cleanup;
-       if (jbd2_fc_init(journal, EXT4_NUM_FC_BLKS)) {
+       if (!buffer_uptodate(journal->j_sb_buffer)
+               && ext4_read_bh_lock(journal->j_sb_buffer, REQ_META | REQ_PRIO,
+                                       true)) {
+               ext4_msg(sb, KERN_ERR, "I/O error on journal");
+               return;
+       }
+       num_fc_blocks = be32_to_cpu(journal->j_superblock->s_num_fc_blks);
+       if (jbd2_fc_init(journal, num_fc_blocks ? num_fc_blocks :
+                                       EXT4_NUM_FC_BLKS)) {
                pr_warn("Error while enabling fast commits, turning off.");
                ext4_clear_feature_fast_commit(sb);
        }
index 2924261226e0fa6dcc83f849125e0a879b0f869f..a92eb79de0cc7fedd2f53cc369348846396e24f3 100644 (file)
@@ -275,7 +275,7 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
                   struct dx_hash_info *hinfo)
 {
 #ifdef CONFIG_UNICODE
-       const struct unicode_map *um = EXT4_SB(dir->i_sb)->s_encoding;
+       const struct unicode_map *um = dir->i_sb->s_encoding;
        int r, dlen;
        unsigned char *buff;
        struct qstr qstr = {.name = name, .len = len };
index 03c2253005f000722151a33c7324e8a83678b36b..b96a18679a27343e92669a3775525eb9b2a1b2f1 100644 (file)
@@ -1918,7 +1918,7 @@ static int __ext4_journalled_writepage(struct page *page,
        }
        if (ret == 0)
                ret = err;
-       err = ext4_jbd2_inode_add_write(handle, inode, 0, len);
+       err = ext4_jbd2_inode_add_write(handle, inode, page_offset(page), len);
        if (ret == 0)
                ret = err;
        EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
@@ -3307,10 +3307,12 @@ static bool ext4_inode_datasync_dirty(struct inode *inode)
 
        if (journal) {
                if (jbd2_transaction_committed(journal,
-                                       EXT4_I(inode)->i_datasync_tid))
-                       return true;
-               return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) >=
-                       EXT4_I(inode)->i_fc_committed_subtid;
+                       EXT4_I(inode)->i_datasync_tid))
+                       return false;
+               if (test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT))
+                       return atomic_read(&EXT4_SB(inode->i_sb)->s_fc_subtid) <
+                               EXT4_I(inode)->i_fc_committed_subtid;
+               return true;
        }
 
        /* Any metadata buffers to write? */
@@ -6157,7 +6159,8 @@ retry_alloc:
                        if (ext4_walk_page_buffers(handle, page_buffers(page),
                                        0, len, NULL, write_end_fn))
                                goto out_error;
-                       if (ext4_jbd2_inode_add_write(handle, inode, 0, len))
+                       if (ext4_jbd2_inode_add_write(handle, inode,
+                                                     page_offset(page), len))
                                goto out_error;
                        ext4_set_inode_state(inode, EXT4_STATE_JDATA);
                } else {
index 5159830dacb8aa61656b34784cd704fb82f811b5..f458d1d81d96b4858a2cc477f2a907e0fa755c0d 100644 (file)
@@ -1285,8 +1285,8 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block)
 int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
                    const struct qstr *entry, bool quick)
 {
-       const struct ext4_sb_info *sbi = EXT4_SB(parent->i_sb);
-       const struct unicode_map *um = sbi->s_encoding;
+       const struct super_block *sb = parent->i_sb;
+       const struct unicode_map *um = sb->s_encoding;
        int ret;
 
        if (quick)
@@ -1298,7 +1298,7 @@ int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
                /* Handle invalid character sequence as either an error
                 * or as an opaque byte sequence.
                 */
-               if (ext4_has_strict_mode(sbi))
+               if (sb_has_strict_encoding(sb))
                        return -EINVAL;
 
                if (name->len != entry->len)
@@ -1315,7 +1315,7 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
 {
        int len;
 
-       if (!IS_CASEFOLDED(dir) || !EXT4_SB(dir->i_sb)->s_encoding) {
+       if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding) {
                cf_name->name = NULL;
                return;
        }
@@ -1324,7 +1324,7 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
        if (!cf_name->name)
                return;
 
-       len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding,
+       len = utf8_casefold(dir->i_sb->s_encoding,
                            iname, cf_name->name,
                            EXT4_NAME_LEN);
        if (len <= 0) {
@@ -1361,7 +1361,7 @@ static inline bool ext4_match(const struct inode *parent,
 #endif
 
 #ifdef CONFIG_UNICODE
-       if (EXT4_SB(parent->i_sb)->s_encoding && IS_CASEFOLDED(parent)) {
+       if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent)) {
                if (fname->cf_name.name) {
                        struct qstr cf = {.name = fname->cf_name.name,
                                          .len = fname->cf_name.len};
@@ -2180,9 +2180,6 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
        struct buffer_head *bh = NULL;
        struct ext4_dir_entry_2 *de;
        struct super_block *sb;
-#ifdef CONFIG_UNICODE
-       struct ext4_sb_info *sbi;
-#endif
        struct ext4_filename fname;
        int     retval;
        int     dx_fallback=0;
@@ -2199,9 +2196,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
                return -EINVAL;
 
 #ifdef CONFIG_UNICODE
-       sbi = EXT4_SB(sb);
-       if (ext4_has_strict_mode(sbi) && IS_CASEFOLDED(dir) &&
-           sbi->s_encoding && utf8_validate(sbi->s_encoding, &dentry->d_name))
+       if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
+           sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
                return -EINVAL;
 #endif
 
index 2fe141ff3c7e602162a9da361fd8f7b825564179..ef4734b40e2a2808e637ba7f6f738fce4904ce2b 100644 (file)
@@ -1288,7 +1288,7 @@ static void ext4_put_super(struct super_block *sb)
        fs_put_dax(sbi->s_daxdev);
        fscrypt_free_dummy_policy(&sbi->s_dummy_enc_policy);
 #ifdef CONFIG_UNICODE
-       utf8_unload(sbi->s_encoding);
+       utf8_unload(sb->s_encoding);
 #endif
        kfree(sbi);
 }
@@ -4303,7 +4303,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                goto failed_mount;
 
 #ifdef CONFIG_UNICODE
-       if (ext4_has_feature_casefold(sb) && !sbi->s_encoding) {
+       if (ext4_has_feature_casefold(sb) && !sb->s_encoding) {
                const struct ext4_sb_encodings *encoding_info;
                struct unicode_map *encoding;
                __u16 encoding_flags;
@@ -4334,8 +4334,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                         "%s-%s with flags 0x%hx", encoding_info->name,
                         encoding_info->version?:"\b", encoding_flags);
 
-               sbi->s_encoding = encoding;
-               sbi->s_encoding_flags = encoding_flags;
+               sb->s_encoding = encoding;
+               sb->s_encoding_flags = encoding_flags;
        }
 #endif
 
@@ -4777,8 +4777,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
        INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_MAIN]);
        INIT_LIST_HEAD(&sbi->s_fc_dentry_q[FC_Q_STAGING]);
        sbi->s_fc_bytes = 0;
-       sbi->s_mount_state &= ~EXT4_FC_INELIGIBLE;
-       sbi->s_mount_state &= ~EXT4_FC_COMMITTING;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_INELIGIBLE;
+       sbi->s_mount_flags &= ~EXT4_MF_FC_COMMITTING;
        spin_lock_init(&sbi->s_fc_lock);
        memset(&sbi->s_fc_stats, 0, sizeof(sbi->s_fc_stats));
        sbi->s_fc_replay_state.fc_regions = NULL;
@@ -4975,7 +4975,7 @@ no_journal:
        }
 
 #ifdef CONFIG_UNICODE
-       if (sbi->s_encoding)
+       if (sb->s_encoding)
                sb->s_d_op = &ext4_dentry_ops;
 #endif
 
@@ -5184,7 +5184,7 @@ failed_mount:
                crypto_free_shash(sbi->s_chksum_driver);
 
 #ifdef CONFIG_UNICODE
-       utf8_unload(sbi->s_encoding);
+       utf8_unload(sb->s_encoding);
 #endif
 
 #ifdef CONFIG_QUOTA
index 5ff33d18996a859451c1eab552672892b32f0a2f..4e27fe6ed3ae6a97816f3b6c2915c3f58be88656 100644 (file)
@@ -315,6 +315,7 @@ EXT4_ATTR_FEATURE(casefold);
 EXT4_ATTR_FEATURE(verity);
 #endif
 EXT4_ATTR_FEATURE(metadata_csum_seed);
+EXT4_ATTR_FEATURE(fast_commit);
 
 static struct attribute *ext4_feat_attrs[] = {
        ATTR_LIST(lazy_itable_init),
@@ -331,6 +332,7 @@ static struct attribute *ext4_feat_attrs[] = {
        ATTR_LIST(verity),
 #endif
        ATTR_LIST(metadata_csum_seed),
+       ATTR_LIST(fast_commit),
        NULL,
 };
 ATTRIBUTE_GROUPS(ext4_feat);
index 5441c17562c569e40a981e66e27554fa6a7c10cb..d98a2e5dab9fded142bd81bdea45ed5eeb2e4792 100644 (file)
@@ -1078,7 +1078,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
 out_free:
        kfree(gl->gl_lksb.sb_lvbptr);
        kmem_cache_free(cachep, gl);
-       atomic_dec(&sdp->sd_glock_disposal);
+       if (atomic_dec_and_test(&sdp->sd_glock_disposal))
+               wake_up(&sdp->sd_glock_wait);
 
 out:
        return ret;
index aa3f5236befb4d5b23a59c8f4384812118756cbb..6c1432d78dce656fc1eec8b49bece5fd452a47c9 100644 (file)
@@ -164,6 +164,31 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
                       GFS2_LFC_AIL_FLUSH);
 }
 
+/**
+ * gfs2_rgrp_metasync - sync out the metadata of a resource group
+ * @gl: the glock protecting the resource group
+ *
+ */
+
+static int gfs2_rgrp_metasync(struct gfs2_glock *gl)
+{
+       struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
+       struct address_space *metamapping = &sdp->sd_aspace;
+       struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl);
+       const unsigned bsize = sdp->sd_sb.sb_bsize;
+       loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK;
+       loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1;
+       int error;
+
+       filemap_fdatawrite_range(metamapping, start, end);
+       error = filemap_fdatawait_range(metamapping, start, end);
+       WARN_ON_ONCE(error && !gfs2_withdrawn(sdp));
+       mapping_set_error(metamapping, error);
+       if (error)
+               gfs2_io_error(sdp);
+       return error;
+}
+
 /**
  * rgrp_go_sync - sync out the metadata for this glock
  * @gl: the glock
@@ -176,11 +201,7 @@ void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
 static int rgrp_go_sync(struct gfs2_glock *gl)
 {
        struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-       struct address_space *mapping = &sdp->sd_aspace;
        struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl);
-       const unsigned bsize = sdp->sd_sb.sb_bsize;
-       loff_t start = (rgd->rd_addr * bsize) & PAGE_MASK;
-       loff_t end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1;
        int error;
 
        if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
@@ -189,10 +210,7 @@ static int rgrp_go_sync(struct gfs2_glock *gl)
 
        gfs2_log_flush(sdp, gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
                       GFS2_LFC_RGRP_GO_SYNC);
-       filemap_fdatawrite_range(mapping, start, end);
-       error = filemap_fdatawait_range(mapping, start, end);
-       WARN_ON_ONCE(error && !gfs2_withdrawn(sdp));
-       mapping_set_error(mapping, error);
+       error = gfs2_rgrp_metasync(gl);
        if (!error)
                error = gfs2_ail_empty_gl(gl);
        gfs2_free_clones(rgd);
@@ -266,7 +284,24 @@ static void gfs2_clear_glop_pending(struct gfs2_inode *ip)
 }
 
 /**
- * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
+ * gfs2_inode_metasync - sync out the metadata of an inode
+ * @gl: the glock protecting the inode
+ *
+ */
+int gfs2_inode_metasync(struct gfs2_glock *gl)
+{
+       struct address_space *metamapping = gfs2_glock2aspace(gl);
+       int error;
+
+       filemap_fdatawrite(metamapping);
+       error = filemap_fdatawait(metamapping);
+       if (error)
+               gfs2_io_error(gl->gl_name.ln_sbd);
+       return error;
+}
+
+/**
+ * inode_go_sync - Sync the dirty metadata of an inode
  * @gl: the glock protecting the inode
  *
  */
@@ -297,8 +332,7 @@ static int inode_go_sync(struct gfs2_glock *gl)
                error = filemap_fdatawait(mapping);
                mapping_set_error(mapping, error);
        }
-       ret = filemap_fdatawait(metamapping);
-       mapping_set_error(metamapping, ret);
+       ret = gfs2_inode_metasync(gl);
        if (!error)
                error = ret;
        gfs2_ail_empty_gl(gl);
index 2dd192e8561825920ac24d9b4931e9f3fcc71104..695898afcaf1fbf6c9d3be048a1cfa90ce11e225 100644 (file)
@@ -22,6 +22,7 @@ extern const struct gfs2_glock_operations gfs2_quota_glops;
 extern const struct gfs2_glock_operations gfs2_journal_glops;
 extern const struct gfs2_glock_operations *gfs2_glops_list[];
 
+extern int gfs2_inode_metasync(struct gfs2_glock *gl);
 extern void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync);
 
 #endif /* __GLOPS_DOT_H__ */
index 6774865f5b5b5c5f8b468d85abc9cd4cb912afa4..077ccb1b3ccc6ea59c4a4963c96e39af6a4cc07a 100644 (file)
@@ -180,7 +180,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
                error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
                if (unlikely(error))
                        goto fail;
-               gfs2_cancel_delete_work(ip->i_iopen_gh.gh_gl);
+               if (blktype != GFS2_BLKST_UNLINKED)
+                       gfs2_cancel_delete_work(ip->i_iopen_gh.gh_gl);
                glock_set_object(ip->i_iopen_gh.gh_gl, ip);
                gfs2_glock_put(io_gl);
                io_gl = NULL;
index ed69298dd824a23c53cf6a83e7dad64c011ecf3c..3922b26264f5a87cec611ab2e6b01cf4827cde44 100644 (file)
@@ -22,6 +22,7 @@
 #include "incore.h"
 #include "inode.h"
 #include "glock.h"
+#include "glops.h"
 #include "log.h"
 #include "lops.h"
 #include "meta_io.h"
@@ -817,41 +818,19 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, u32 start,
        return error;
 }
 
-/**
- * gfs2_meta_sync - Sync all buffers associated with a glock
- * @gl: The glock
- *
- */
-
-void gfs2_meta_sync(struct gfs2_glock *gl)
-{
-       struct address_space *mapping = gfs2_glock2aspace(gl);
-       struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
-       int error;
-
-       if (mapping == NULL)
-               mapping = &sdp->sd_aspace;
-
-       filemap_fdatawrite(mapping);
-       error = filemap_fdatawait(mapping);
-
-       if (error)
-               gfs2_io_error(gl->gl_name.ln_sbd);
-}
-
 static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
 {
        struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
        if (error) {
-               gfs2_meta_sync(ip->i_gl);
+               gfs2_inode_metasync(ip->i_gl);
                return;
        }
        if (pass != 1)
                return;
 
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
                jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
@@ -1060,14 +1039,14 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
        struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 
        if (error) {
-               gfs2_meta_sync(ip->i_gl);
+               gfs2_inode_metasync(ip->i_gl);
                return;
        }
        if (pass != 1)
                return;
 
        /* data sync? */
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
        fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
                jd->jd_jid, jd->jd_replayed_blocks, jd->jd_found_blocks);
index 4a3d8aecdf82765a22dd655c7e8913ff8a3a289d..fbdbb08dcec6af19057a4f4181e10f2441295c11 100644 (file)
@@ -27,8 +27,6 @@ extern void gfs2_log_submit_bio(struct bio **biop, int opf);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
 extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
                           struct gfs2_log_header_host *head, bool keep_cache);
-extern void gfs2_meta_sync(struct gfs2_glock *gl);
-
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
 {
        unsigned int limit;
index 7a7e3c10a9a92947d7ef86b4dbcd3fa1f63d06ed..61fce59cb4d3839512974bc679bd1db4e7ecec87 100644 (file)
@@ -633,8 +633,10 @@ static int init_statfs(struct gfs2_sbd *sdp)
        if (IS_ERR(sdp->sd_statfs_inode)) {
                error = PTR_ERR(sdp->sd_statfs_inode);
                fs_err(sdp, "can't read in statfs inode: %d\n", error);
-               goto fail;
+               goto out;
        }
+       if (sdp->sd_args.ar_spectator)
+               goto out;
 
        pn = gfs2_lookup_simple(master, "per_node");
        if (IS_ERR(pn)) {
@@ -682,15 +684,17 @@ free_local:
        iput(pn);
 put_statfs:
        iput(sdp->sd_statfs_inode);
-fail:
+out:
        return error;
 }
 
 /* Uninitialize and free up memory used by the list of statfs inodes */
 static void uninit_statfs(struct gfs2_sbd *sdp)
 {
-       gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
-       free_local_statfs_inodes(sdp);
+       if (!sdp->sd_args.ar_spectator) {
+               gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
+               free_local_statfs_inodes(sdp);
+       }
        iput(sdp->sd_statfs_inode);
 }
 
@@ -704,7 +708,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
 
        if (undo) {
                jindex = 0;
-               goto fail_jinode_gh;
+               goto fail_statfs;
        }
 
        sdp->sd_jindex = gfs2_lookup_simple(master, "jindex");
index b5cbe21efdfb3b5608b1fb35dd8fc5329604c051..c26c68ebd29d4be67b3015838fca25068e6c0641 100644 (file)
@@ -349,7 +349,7 @@ static int update_statfs_inode(struct gfs2_jdesc *jd,
 
        mark_buffer_dirty(bh);
        brelse(bh);
-       gfs2_meta_sync(ip->i_gl);
+       gfs2_inode_metasync(ip->i_gl);
 
 out:
        return error;
index ee491bb9c1ccdcdef39bf233830cd82519f87963..92d799a193b816bbb975dbd4bdc8383e66d17632 100644 (file)
@@ -719,9 +719,9 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp)
                }
 
                gfs2_free_clones(rgd);
+               return_all_reservations(rgd);
                kfree(rgd->rd_bits);
                rgd->rd_bits = NULL;
-               return_all_reservations(rgd);
                kmem_cache_free(gfs2_rgrpd_cachep, rgd);
        }
 }
@@ -1370,6 +1370,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
+       if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags))
+               return -EROFS;
+
        if (!blk_queue_discard(q))
                return -EOPNOTSUPP;
 
index b285192bd6b3136e3ab40096e05ef59b16bdfb96..b3d951ab806806574bb2407c8bba1e11c05fe66a 100644 (file)
@@ -738,6 +738,7 @@ restart:
        gfs2_jindex_free(sdp);
        /*  Take apart glock structures and buffer lists  */
        gfs2_gl_hash_clear(sdp);
+       truncate_inode_pages_final(&sdp->sd_aspace);
        gfs2_delete_debugfs_file(sdp);
        /*  Unmount the locking protocol  */
        gfs2_lm_unmount(sdp);
index dcc2aab1b2c43fefc751c1c0b74fcfddac61257a..4ba45caf593929d00b8d665687715521ce737eb1 100644 (file)
@@ -60,7 +60,7 @@ struct hfs_bnode {
        wait_queue_head_t lock_wq;
        atomic_t refcnt;
        unsigned int page_offset;
-       struct page *page[0];
+       struct page *page[];
 };
 
 #define HFS_BNODE_ERROR                0
index 3b03fff68543c55eea2d3e39181d4453affccafe..a92de5199ec33ded8210b133b6b45185d8649e8c 100644 (file)
@@ -117,7 +117,7 @@ struct hfs_bnode {
        wait_queue_head_t lock_wq;
        atomic_t refcnt;
        unsigned int page_offset;
-       struct page *page[0];
+       struct page *page[];
 };
 
 #define HFS_BNODE_LOCK         0
index 02894df7656dd1df1b4a13141c3089bf4ce03518..b53c055bea6a36dba4d3d0d7d957798d5aceec29 100644 (file)
@@ -482,6 +482,10 @@ static void io_impersonate_work(struct io_worker *worker,
                current->files = work->identity->files;
                current->nsproxy = work->identity->nsproxy;
                task_unlock(current);
+               if (!work->identity->files) {
+                       /* failed grabbing files, ensure work gets cancelled */
+                       work->flags |= IO_WQ_WORK_CANCEL;
+               }
        }
        if ((work->flags & IO_WQ_WORK_FS) && current->fs != work->identity->fs)
                current->fs = work->identity->fs;
index b42dfa0243bfd5ecf83caf903044a724a3919e76..8018c7076b25ce66a8215500ffa3531d43f4204b 100644 (file)
@@ -995,20 +995,33 @@ static void io_sq_thread_drop_mm(void)
        if (mm) {
                kthread_unuse_mm(mm);
                mmput(mm);
+               current->mm = NULL;
        }
 }
 
 static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx)
 {
-       if (!current->mm) {
-               if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||
-                            !ctx->sqo_task->mm ||
-                            !mmget_not_zero(ctx->sqo_task->mm)))
-                       return -EFAULT;
-               kthread_use_mm(ctx->sqo_task->mm);
+       struct mm_struct *mm;
+
+       if (current->mm)
+               return 0;
+
+       /* Should never happen */
+       if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL)))
+               return -EFAULT;
+
+       task_lock(ctx->sqo_task);
+       mm = ctx->sqo_task->mm;
+       if (unlikely(!mm || !mmget_not_zero(mm)))
+               mm = NULL;
+       task_unlock(ctx->sqo_task);
+
+       if (mm) {
+               kthread_use_mm(mm);
+               return 0;
        }
 
-       return 0;
+       return -EFAULT;
 }
 
 static int io_sq_thread_acquire_mm(struct io_ring_ctx *ctx,
@@ -1274,9 +1287,12 @@ static bool io_identity_cow(struct io_kiocb *req)
        /* add one for this request */
        refcount_inc(&id->count);
 
-       /* drop old identity, assign new one. one ref for req, one for tctx */
-       if (req->work.identity != tctx->identity &&
-           refcount_sub_and_test(2, &req->work.identity->count))
+       /* drop tctx and req identity references, if needed */
+       if (tctx->identity != &tctx->__identity &&
+           refcount_dec_and_test(&tctx->identity->count))
+               kfree(tctx->identity);
+       if (req->work.identity != &tctx->__identity &&
+           refcount_dec_and_test(&req->work.identity->count))
                kfree(req->work.identity);
 
        req->work.identity = id;
@@ -1365,6 +1381,9 @@ static void io_prep_async_work(struct io_kiocb *req)
        io_req_init_async(req);
        id = req->work.identity;
 
+       if (req->flags & REQ_F_FORCE_ASYNC)
+               req->work.flags |= IO_WQ_WORK_CONCURRENT;
+
        if (req->flags & REQ_F_ISREG) {
                if (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL))
                        io_wq_hash_work(&req->work, file_inode(req->file));
@@ -1574,14 +1593,29 @@ static void io_cqring_mark_overflow(struct io_ring_ctx *ctx)
        }
 }
 
-static inline bool io_match_files(struct io_kiocb *req,
-                                      struct files_struct *files)
+static inline bool __io_match_files(struct io_kiocb *req,
+                                   struct files_struct *files)
 {
+       return ((req->flags & REQ_F_WORK_INITIALIZED) &&
+               (req->work.flags & IO_WQ_WORK_FILES)) &&
+               req->work.identity->files == files;
+}
+
+static bool io_match_files(struct io_kiocb *req,
+                          struct files_struct *files)
+{
+       struct io_kiocb *link;
+
        if (!files)
                return true;
-       if ((req->flags & REQ_F_WORK_INITIALIZED) &&
-           (req->work.flags & IO_WQ_WORK_FILES))
-               return req->work.identity->files == files;
+       if (__io_match_files(req, files))
+               return true;
+       if (req->flags & REQ_F_LINK_HEAD) {
+               list_for_each_entry(link, &req->link_list, link_list) {
+                       if (__io_match_files(link, files))
+                               return true;
+               }
+       }
        return false;
 }
 
@@ -1665,7 +1699,8 @@ static void __io_cqring_fill_event(struct io_kiocb *req, long res, long cflags)
                WRITE_ONCE(cqe->user_data, req->user_data);
                WRITE_ONCE(cqe->res, res);
                WRITE_ONCE(cqe->flags, cflags);
-       } else if (ctx->cq_overflow_flushed || req->task->io_uring->in_idle) {
+       } else if (ctx->cq_overflow_flushed ||
+                  atomic_read(&req->task->io_uring->in_idle)) {
                /*
                 * If we're in ring overflow flush mode, or in task cancel mode,
                 * then we cannot store the request for later flushing, we need
@@ -1835,7 +1870,7 @@ static void __io_free_req(struct io_kiocb *req)
        io_dismantle_req(req);
 
        percpu_counter_dec(&tctx->inflight);
-       if (tctx->in_idle)
+       if (atomic_read(&tctx->in_idle))
                wake_up(&tctx->wait);
        put_task_struct(req->task);
 
@@ -1846,59 +1881,39 @@ static void __io_free_req(struct io_kiocb *req)
        percpu_ref_put(&ctx->refs);
 }
 
-static bool io_link_cancel_timeout(struct io_kiocb *req)
+static void io_kill_linked_timeout(struct io_kiocb *req)
 {
-       struct io_timeout_data *io = req->async_data;
        struct io_ring_ctx *ctx = req->ctx;
-       int ret;
-
-       ret = hrtimer_try_to_cancel(&io->timer);
-       if (ret != -1) {
-               io_cqring_fill_event(req, -ECANCELED);
-               io_commit_cqring(ctx);
-               req->flags &= ~REQ_F_LINK_HEAD;
-               io_put_req_deferred(req, 1);
-               return true;
-       }
-
-       return false;
-}
-
-static bool __io_kill_linked_timeout(struct io_kiocb *req)
-{
        struct io_kiocb *link;
-       bool wake_ev;
+       bool cancelled = false;
+       unsigned long flags;
 
-       if (list_empty(&req->link_list))
-               return false;
-       link = list_first_entry(&req->link_list, struct io_kiocb, link_list);
-       if (link->opcode != IORING_OP_LINK_TIMEOUT)
-               return false;
+       spin_lock_irqsave(&ctx->completion_lock, flags);
+       link = list_first_entry_or_null(&req->link_list, struct io_kiocb,
+                                       link_list);
        /*
         * Can happen if a linked timeout fired and link had been like
         * req -> link t-out -> link t-out [-> ...]
         */
-       if (!(link->flags & REQ_F_LTIMEOUT_ACTIVE))
-               return false;
+       if (link && (link->flags & REQ_F_LTIMEOUT_ACTIVE)) {
+               struct io_timeout_data *io = link->async_data;
+               int ret;
 
-       list_del_init(&link->link_list);
-       wake_ev = io_link_cancel_timeout(link);
+               list_del_init(&link->link_list);
+               ret = hrtimer_try_to_cancel(&io->timer);
+               if (ret != -1) {
+                       io_cqring_fill_event(link, -ECANCELED);
+                       io_commit_cqring(ctx);
+                       cancelled = true;
+               }
+       }
        req->flags &= ~REQ_F_LINK_TIMEOUT;
-       return wake_ev;
-}
-
-static void io_kill_linked_timeout(struct io_kiocb *req)
-{
-       struct io_ring_ctx *ctx = req->ctx;
-       unsigned long flags;
-       bool wake_ev;
-
-       spin_lock_irqsave(&ctx->completion_lock, flags);
-       wake_ev = __io_kill_linked_timeout(req);
        spin_unlock_irqrestore(&ctx->completion_lock, flags);
 
-       if (wake_ev)
+       if (cancelled) {
                io_cqring_ev_posted(ctx);
+               io_put_req(link);
+       }
 }
 
 static struct io_kiocb *io_req_link_next(struct io_kiocb *req)
@@ -4977,8 +4992,10 @@ static int io_poll_double_wake(struct wait_queue_entry *wait, unsigned mode,
                /* make sure double remove sees this as being gone */
                wait->private = NULL;
                spin_unlock(&poll->head->lock);
-               if (!done)
-                       __io_async_wake(req, poll, mask, io_poll_task_func);
+               if (!done) {
+                       /* use wait func handler, so it matches the rq type */
+                       poll->wait.func(&poll->wait, mode, sync, key);
+               }
        }
        refcount_dec(&req->refs);
        return 1;
@@ -6180,7 +6197,6 @@ static struct io_kiocb *io_prep_linked_timeout(struct io_kiocb *req)
 static void __io_queue_sqe(struct io_kiocb *req, struct io_comp_state *cs)
 {
        struct io_kiocb *linked_timeout;
-       struct io_kiocb *nxt;
        const struct cred *old_creds = NULL;
        int ret;
 
@@ -6206,7 +6222,6 @@ again:
         */
        if (ret == -EAGAIN && !(req->flags & REQ_F_NOWAIT)) {
                if (!io_arm_poll_handler(req)) {
-punt:
                        /*
                         * Queued up for async execution, worker will release
                         * submit reference when the iocb is actually submitted.
@@ -6216,33 +6231,25 @@ punt:
 
                if (linked_timeout)
                        io_queue_linked_timeout(linked_timeout);
-               goto exit;
-       }
+       } else if (likely(!ret)) {
+               /* drop submission reference */
+               req = io_put_req_find_next(req);
+               if (linked_timeout)
+                       io_queue_linked_timeout(linked_timeout);
 
-       if (unlikely(ret)) {
+               if (req) {
+                       if (!(req->flags & REQ_F_FORCE_ASYNC))
+                               goto again;
+                       io_queue_async_work(req);
+               }
+       } else {
                /* un-prep timeout, so it'll be killed as any other linked */
                req->flags &= ~REQ_F_LINK_TIMEOUT;
                req_set_fail_links(req);
                io_put_req(req);
                io_req_complete(req, ret);
-               goto exit;
        }
 
-       /* drop submission reference */
-       nxt = io_put_req_find_next(req);
-       if (linked_timeout)
-               io_queue_linked_timeout(linked_timeout);
-
-       if (nxt) {
-               req = nxt;
-
-               if (req->flags & REQ_F_FORCE_ASYNC) {
-                       linked_timeout = NULL;
-                       goto punt;
-               }
-               goto again;
-       }
-exit:
        if (old_creds)
                revert_creds(old_creds);
 }
@@ -6266,13 +6273,6 @@ fail_req:
                        if (unlikely(ret))
                                goto fail_req;
                }
-
-               /*
-                * Never try inline submit of IOSQE_ASYNC is set, go straight
-                * to async execution.
-                */
-               io_req_init_async(req);
-               req->work.flags |= IO_WQ_WORK_CONCURRENT;
                io_queue_async_work(req);
        } else {
                if (sqe) {
@@ -7727,7 +7727,8 @@ static int io_uring_alloc_task_context(struct task_struct *task)
        xa_init(&tctx->xa);
        init_waitqueue_head(&tctx->wait);
        tctx->last = NULL;
-       tctx->in_idle = 0;
+       atomic_set(&tctx->in_idle, 0);
+       tctx->sqpoll = false;
        io_init_identity(&tctx->__identity);
        tctx->identity = &tctx->__identity;
        task->io_uring = tctx;
@@ -8420,22 +8421,6 @@ static bool io_match_link(struct io_kiocb *preq, struct io_kiocb *req)
        return false;
 }
 
-static bool io_match_link_files(struct io_kiocb *req,
-                               struct files_struct *files)
-{
-       struct io_kiocb *link;
-
-       if (io_match_files(req, files))
-               return true;
-       if (req->flags & REQ_F_LINK_HEAD) {
-               list_for_each_entry(link, &req->link_list, link_list) {
-                       if (io_match_files(link, files))
-                               return true;
-               }
-       }
-       return false;
-}
-
 /*
  * We're looking to cancel 'req' because it's holding on to our files, but
  * 'req' could be a link to another request. See if it is, and cancel that
@@ -8485,7 +8470,21 @@ static bool io_timeout_remove_link(struct io_ring_ctx *ctx,
 
 static bool io_cancel_link_cb(struct io_wq_work *work, void *data)
 {
-       return io_match_link(container_of(work, struct io_kiocb, work), data);
+       struct io_kiocb *req = container_of(work, struct io_kiocb, work);
+       bool ret;
+
+       if (req->flags & REQ_F_LINK_TIMEOUT) {
+               unsigned long flags;
+               struct io_ring_ctx *ctx = req->ctx;
+
+               /* protect against races with linked timeouts */
+               spin_lock_irqsave(&ctx->completion_lock, flags);
+               ret = io_match_link(req, data);
+               spin_unlock_irqrestore(&ctx->completion_lock, flags);
+       } else {
+               ret = io_match_link(req, data);
+       }
+       return ret;
 }
 
 static void io_attempt_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req)
@@ -8511,6 +8510,7 @@ static void io_attempt_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req)
 }
 
 static void io_cancel_defer_files(struct io_ring_ctx *ctx,
+                                 struct task_struct *task,
                                  struct files_struct *files)
 {
        struct io_defer_entry *de = NULL;
@@ -8518,7 +8518,8 @@ static void io_cancel_defer_files(struct io_ring_ctx *ctx,
 
        spin_lock_irq(&ctx->completion_lock);
        list_for_each_entry_reverse(de, &ctx->defer_list, list) {
-               if (io_match_link_files(de->req, files)) {
+               if (io_task_match(de->req, task) &&
+                   io_match_files(de->req, files)) {
                        list_cut_position(&list, &ctx->defer_list, &de->list);
                        break;
                }
@@ -8544,7 +8545,6 @@ static bool io_uring_cancel_files(struct io_ring_ctx *ctx,
        if (list_empty_careful(&ctx->inflight_list))
                return false;
 
-       io_cancel_defer_files(ctx, files);
        /* cancel all at once, should be faster than doing it one by one*/
        io_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true);
 
@@ -8630,8 +8630,16 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
 {
        struct task_struct *task = current;
 
-       if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data)
+       if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
                task = ctx->sq_data->thread;
+               atomic_inc(&task->io_uring->in_idle);
+               io_sq_thread_park(ctx->sq_data);
+       }
+
+       if (files)
+               io_cancel_defer_files(ctx, NULL, files);
+       else
+               io_cancel_defer_files(ctx, task, NULL);
 
        io_cqring_overflow_flush(ctx, true, task, files);
 
@@ -8639,12 +8647,23 @@ static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx,
                io_run_task_work();
                cond_resched();
        }
+
+       if ((ctx->flags & IORING_SETUP_SQPOLL) && ctx->sq_data) {
+               atomic_dec(&task->io_uring->in_idle);
+               /*
+                * If the files that are going away are the ones in the thread
+                * identity, clear them out.
+                */
+               if (task->io_uring->identity->files == files)
+                       task->io_uring->identity->files = NULL;
+               io_sq_thread_unpark(ctx->sq_data);
+       }
 }
 
 /*
  * Note that this task has used io_uring. We use it for cancelation purposes.
  */
-static int io_uring_add_task_file(struct file *file)
+static int io_uring_add_task_file(struct io_ring_ctx *ctx, struct file *file)
 {
        struct io_uring_task *tctx = current->io_uring;
 
@@ -8666,6 +8685,14 @@ static int io_uring_add_task_file(struct file *file)
                tctx->last = file;
        }
 
+       /*
+        * This is race safe in that the task itself is doing this, hence it
+        * cannot be going through the exit/cancel paths at the same time.
+        * This cannot be modified while exit/cancel is running.
+        */
+       if (!tctx->sqpoll && (ctx->flags & IORING_SETUP_SQPOLL))
+               tctx->sqpoll = true;
+
        return 0;
 }
 
@@ -8707,7 +8734,7 @@ void __io_uring_files_cancel(struct files_struct *files)
        unsigned long index;
 
        /* make sure overflow events are dropped */
-       tctx->in_idle = true;
+       atomic_inc(&tctx->in_idle);
 
        xa_for_each(&tctx->xa, index, file) {
                struct io_ring_ctx *ctx = file->private_data;
@@ -8716,6 +8743,35 @@ void __io_uring_files_cancel(struct files_struct *files)
                if (files)
                        io_uring_del_task_file(file);
        }
+
+       atomic_dec(&tctx->in_idle);
+}
+
+static s64 tctx_inflight(struct io_uring_task *tctx)
+{
+       unsigned long index;
+       struct file *file;
+       s64 inflight;
+
+       inflight = percpu_counter_sum(&tctx->inflight);
+       if (!tctx->sqpoll)
+               return inflight;
+
+       /*
+        * If we have SQPOLL rings, then we need to iterate and find them, and
+        * add the pending count for those.
+        */
+       xa_for_each(&tctx->xa, index, file) {
+               struct io_ring_ctx *ctx = file->private_data;
+
+               if (ctx->flags & IORING_SETUP_SQPOLL) {
+                       struct io_uring_task *__tctx = ctx->sqo_task->io_uring;
+
+                       inflight += percpu_counter_sum(&__tctx->inflight);
+               }
+       }
+
+       return inflight;
 }
 
 /*
@@ -8729,11 +8785,11 @@ void __io_uring_task_cancel(void)
        s64 inflight;
 
        /* make sure overflow events are dropped */
-       tctx->in_idle = true;
+       atomic_inc(&tctx->in_idle);
 
        do {
                /* read completions before cancelations */
-               inflight = percpu_counter_sum(&tctx->inflight);
+               inflight = tctx_inflight(tctx);
                if (!inflight)
                        break;
                __io_uring_files_cancel(NULL);
@@ -8744,13 +8800,13 @@ void __io_uring_task_cancel(void)
                 * If we've seen completions, retry. This avoids a race where
                 * a completion comes in before we did prepare_to_wait().
                 */
-               if (inflight != percpu_counter_sum(&tctx->inflight))
+               if (inflight != tctx_inflight(tctx))
                        continue;
                schedule();
        } while (1);
 
        finish_wait(&tctx->wait, &wait);
-       tctx->in_idle = false;
+       atomic_dec(&tctx->in_idle);
 }
 
 static int io_uring_flush(struct file *file, void *data)
@@ -8895,7 +8951,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
                        io_sqpoll_wait_sq(ctx);
                submitted = to_submit;
        } else if (to_submit) {
-               ret = io_uring_add_task_file(f.file);
+               ret = io_uring_add_task_file(ctx, f.file);
                if (unlikely(ret))
                        goto out;
                mutex_lock(&ctx->uring_lock);
@@ -8932,7 +8988,8 @@ out_fput:
 #ifdef CONFIG_PROC_FS
 static int io_uring_show_cred(int id, void *p, void *data)
 {
-       const struct cred *cred = p;
+       struct io_identity *iod = p;
+       const struct cred *cred = iod->creds;
        struct seq_file *m = data;
        struct user_namespace *uns = seq_user_ns(m);
        struct group_info *gi;
@@ -9124,7 +9181,7 @@ err_fd:
 #if defined(CONFIG_UNIX)
        ctx->ring_sock->file = file;
 #endif
-       if (unlikely(io_uring_add_task_file(file))) {
+       if (unlikely(io_uring_add_task_file(ctx, file))) {
                file = ERR_PTR(-ENOMEM);
                goto err_fd;
        }
index 8180061b9e16488a4535ccb93b0d0db54d1dafd6..10cc7979ce38070a7d6b16f3eca9d52804626e97 100644 (file)
@@ -1374,6 +1374,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
        WARN_ON_ONCE(!wpc->ioend && !list_empty(&submit_list));
        WARN_ON_ONCE(!PageLocked(page));
        WARN_ON_ONCE(PageWriteback(page));
+       WARN_ON_ONCE(PageDirty(page));
 
        /*
         * We cannot cancel the ioend directly here on error.  We may have
@@ -1382,33 +1383,22 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
         * appropriately.
         */
        if (unlikely(error)) {
+               /*
+                * Let the filesystem know what portion of the current page
+                * failed to map. If the page wasn't been added to ioend, it
+                * won't be affected by I/O completion and we must unlock it
+                * now.
+                */
+               if (wpc->ops->discard_page)
+                       wpc->ops->discard_page(page, file_offset);
                if (!count) {
-                       /*
-                        * If the current page hasn't been added to ioend, it
-                        * won't be affected by I/O completions and we must
-                        * discard and unlock it right here.
-                        */
-                       if (wpc->ops->discard_page)
-                               wpc->ops->discard_page(page);
                        ClearPageUptodate(page);
                        unlock_page(page);
                        goto done;
                }
-
-               /*
-                * If the page was not fully cleaned, we need to ensure that the
-                * higher layers come back to it correctly.  That means we need
-                * to keep the page dirty, and for WB_SYNC_ALL writeback we need
-                * to ensure the PAGECACHE_TAG_TOWRITE index mark is not removed
-                * so another attempt to write this page in this writeback sweep
-                * will be made.
-                */
-               set_page_writeback_keepwrite(page);
-       } else {
-               clear_page_dirty_for_io(page);
-               set_page_writeback(page);
        }
 
+       set_page_writeback(page);
        unlock_page(page);
 
        /*
index 1558cf22ef8a8ba7197a0df2f557b3cb0d088576..ee9660e9671cbc403a5f1e25439b298a10d1915b 100644 (file)
@@ -22,7 +22,7 @@ struct SU_ER_s {
        __u8 len_des;
        __u8 len_src;
        __u8 ext_ver;
-       __u8 data[0];
+       __u8 data[];
 } __attribute__ ((packed));
 
 struct RR_RR_s {
@@ -44,7 +44,7 @@ struct RR_PN_s {
 struct SL_component {
        __u8 flags;
        __u8 len;
-       __u8 text[0];
+       __u8 text[];
 } __attribute__ ((packed));
 
 struct RR_SL_s {
@@ -54,7 +54,7 @@ struct RR_SL_s {
 
 struct RR_NM_s {
        __u8 flags;
-       char name[0];
+       char name[];
 } __attribute__ ((packed));
 
 struct RR_CL_s {
@@ -71,7 +71,7 @@ struct stamp {
 
 struct RR_TF_s {
        __u8 flags;
-       struct stamp times[0];  /* Variable number of these beasts */
+       struct stamp times[];   /* Variable number of these beasts */
 } __attribute__ ((packed));
 
 /* Linux-specific extension for transparent decompression */
index 0f707003dda53fb722f6566b2d3a9eb69c386d9a..b362523a9829ace0f2df2a93a2bd2e8e47a7bdd5 100644 (file)
@@ -1049,6 +1049,8 @@ static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
                oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
                          OOM_SCORE_ADJ_MAX;
        put_task_struct(task);
+       if (oom_adj > OOM_ADJUST_MAX)
+               oom_adj = OOM_ADJUST_MAX;
        len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
        return simple_read_from_buffer(buf, count, ppos, buffer, len);
 }
index d0989a443c77dfe2b99207697a391bef17032c92..419760fd77bdd82b1fa1d1565bbcc8d13ae25967 100644 (file)
@@ -19,7 +19,7 @@ static int cpuinfo_open(struct inode *inode, struct file *file)
 static const struct proc_ops cpuinfo_proc_ops = {
        .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_open      = cpuinfo_open,
-       .proc_read      = seq_read,
+       .proc_read_iter = seq_read_iter,
        .proc_lseek     = seq_lseek,
        .proc_release   = seq_release,
 };
index 2f9fa179194d72739f9f76c9270068bbe89308a0..b84663252adda0abadc9656bb56e441f4f65d570 100644 (file)
@@ -590,7 +590,7 @@ static int proc_seq_release(struct inode *inode, struct file *file)
 static const struct proc_ops proc_seq_ops = {
        /* not permanent -- can call into arbitrary seq_operations */
        .proc_open      = proc_seq_open,
-       .proc_read      = seq_read,
+       .proc_read_iter = seq_read_iter,
        .proc_lseek     = seq_lseek,
        .proc_release   = proc_seq_release,
 };
@@ -621,7 +621,7 @@ static int proc_single_open(struct inode *inode, struct file *file)
 static const struct proc_ops proc_single_ops = {
        /* not permanent -- can call into arbitrary ->single_show */
        .proc_open      = proc_single_open,
-       .proc_read      = seq_read,
+       .proc_read_iter = seq_read_iter,
        .proc_lseek     = seq_lseek,
        .proc_release   = single_release,
 };
index 58c075e2a452d63cdc230d9aeb134a2426550ef4..bde6b6f69852d2206dbd6703b8f033ff9c6591b2 100644 (file)
@@ -597,6 +597,7 @@ static const struct file_operations proc_iter_file_ops = {
        .llseek         = proc_reg_llseek,
        .read_iter      = proc_reg_read_iter,
        .write          = proc_reg_write,
+       .splice_read    = generic_file_splice_read,
        .poll           = proc_reg_poll,
        .unlocked_ioctl = proc_reg_unlocked_ioctl,
        .mmap           = proc_reg_mmap,
@@ -622,6 +623,7 @@ static const struct file_operations proc_reg_file_ops_compat = {
 static const struct file_operations proc_iter_file_ops_compat = {
        .llseek         = proc_reg_llseek,
        .read_iter      = proc_reg_read_iter,
+       .splice_read    = generic_file_splice_read,
        .write          = proc_reg_write,
        .poll           = proc_reg_poll,
        .unlocked_ioctl = proc_reg_unlocked_ioctl,
index 46b3293015fe61f78dd14781aaabc4b9491da1a2..4695b6de315129aa62daba5131b82a3346bfd25a 100644 (file)
@@ -226,7 +226,7 @@ static int stat_open(struct inode *inode, struct file *file)
 static const struct proc_ops stat_proc_ops = {
        .proc_flags     = PROC_ENTRY_PERMANENT,
        .proc_open      = stat_open,
-       .proc_read      = seq_read,
+       .proc_read_iter = seq_read_iter,
        .proc_lseek     = seq_lseek,
        .proc_release   = single_release,
 };
index 7aef49552d4c2d3a8c3789d51daae89b4d00f68e..ebfebdfe5c69a168840aad4bc5e8ccdd4d7e6dbe 100644 (file)
@@ -97,7 +97,7 @@ u64 select_estimate_accuracy(struct timespec64 *tv)
 struct poll_table_page {
        struct poll_table_page * next;
        struct poll_table_entry * entry;
-       struct poll_table_entry entries[0];
+       struct poll_table_entry entries[];
 };
 
 #define POLL_TABLE_FULL(table) \
@@ -836,7 +836,7 @@ SYSCALL_DEFINE1(old_select, struct sel_arg_struct __user *, arg)
 struct poll_list {
        struct poll_list *next;
        int len;
-       struct pollfd entries[0];
+       struct pollfd entries[];
 };
 
 #define POLLFD_PER_PAGE  ((PAGE_SIZE-sizeof(struct poll_list)) / sizeof(struct pollfd))
index 31219c1db17de3589770a683cfedd8ffd0c5095e..3b20e21604e74aaa65defc63b82f7fdbdb193953 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/mm.h>
 #include <linux/printk.h>
 #include <linux/string_helpers.h>
+#include <linux/uio.h>
 
 #include <linux/uaccess.h>
 #include <asm/page.h>
@@ -146,7 +147,28 @@ Eoverflow:
  */
 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
 {
-       struct seq_file *m = file->private_data;
+       struct iovec iov = { .iov_base = buf, .iov_len = size};
+       struct kiocb kiocb;
+       struct iov_iter iter;
+       ssize_t ret;
+
+       init_sync_kiocb(&kiocb, file);
+       iov_iter_init(&iter, READ, &iov, 1, size);
+
+       kiocb.ki_pos = *ppos;
+       ret = seq_read_iter(&kiocb, &iter);
+       *ppos = kiocb.ki_pos;
+       return ret;
+}
+EXPORT_SYMBOL(seq_read);
+
+/*
+ * Ready-made ->f_op->read_iter()
+ */
+ssize_t seq_read_iter(struct kiocb *iocb, struct iov_iter *iter)
+{
+       struct seq_file *m = iocb->ki_filp->private_data;
+       size_t size = iov_iter_count(iter);
        size_t copied = 0;
        size_t n;
        void *p;
@@ -158,14 +180,14 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
         * if request is to read from zero offset, reset iterator to first
         * record as it might have been already advanced by previous requests
         */
-       if (*ppos == 0) {
+       if (iocb->ki_pos == 0) {
                m->index = 0;
                m->count = 0;
        }
 
-       /* Don't assume *ppos is where we left it */
-       if (unlikely(*ppos != m->read_pos)) {
-               while ((err = traverse(m, *ppos)) == -EAGAIN)
+       /* Don't assume ki_pos is where we left it */
+       if (unlikely(iocb->ki_pos != m->read_pos)) {
+               while ((err = traverse(m, iocb->ki_pos)) == -EAGAIN)
                        ;
                if (err) {
                        /* With prejudice... */
@@ -174,7 +196,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
                        m->count = 0;
                        goto Done;
                } else {
-                       m->read_pos = *ppos;
+                       m->read_pos = iocb->ki_pos;
                }
        }
 
@@ -187,13 +209,11 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
        /* if not empty - flush it first */
        if (m->count) {
                n = min(m->count, size);
-               err = copy_to_user(buf, m->buf + m->from, n);
-               if (err)
+               if (copy_to_iter(m->buf + m->from, n, iter) != n)
                        goto Efault;
                m->count -= n;
                m->from += n;
                size -= n;
-               buf += n;
                copied += n;
                if (!size)
                        goto Done;
@@ -254,8 +274,7 @@ Fill:
        }
        m->op->stop(m, p);
        n = min(m->count, size);
-       err = copy_to_user(buf, m->buf, n);
-       if (err)
+       if (copy_to_iter(m->buf, n, iter) != n)
                goto Efault;
        copied += n;
        m->count -= n;
@@ -264,7 +283,7 @@ Done:
        if (!copied)
                copied = err;
        else {
-               *ppos += copied;
+               iocb->ki_pos += copied;
                m->read_pos += copied;
        }
        mutex_unlock(&m->lock);
@@ -276,7 +295,7 @@ Efault:
        err = -EFAULT;
        goto Done;
 }
-EXPORT_SYMBOL(seq_read);
+EXPORT_SYMBOL(seq_read_iter);
 
 /**
  *     seq_lseek -     ->llseek() method for sequential files.
index 852b536551b53ef6948eee4308045b420390ff36..15640015be9d243320d5a383c48f08426eb7656f 100644 (file)
@@ -2467,6 +2467,7 @@ xfs_defer_agfl_block(
        new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
        new->xefi_blockcount = 1;
        new->xefi_oinfo = *oinfo;
+       new->xefi_skip_discard = false;
 
        trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
 
index e1bd484e55485411830ec5927f241c509b8ec0ab..6747e97a7949014b789981b5ef4a93648183c50c 100644 (file)
@@ -52,9 +52,9 @@ struct xfs_extent_free_item
 {
        xfs_fsblock_t           xefi_startblock;/* starting fs block number */
        xfs_extlen_t            xefi_blockcount;/* number of blocks in extent */
+       bool                    xefi_skip_discard;
        struct list_head        xefi_list;
        struct xfs_owner_info   xefi_oinfo;     /* extent owner */
-       bool                    xefi_skip_discard;
 };
 
 #define        XFS_BMAP_MAX_NMAP       4
index 3aa85b64de3624be7d80e0d0518b9cbe20fac178..bb25ff1b770d12519a4419d907d1a63750787e0e 100644 (file)
@@ -121,8 +121,7 @@ xchk_inode_flags(
                goto bad;
 
        /* rt flags require rt device */
-       if ((flags & (XFS_DIFLAG_REALTIME | XFS_DIFLAG_RTINHERIT)) &&
-           !mp->m_rtdev_targp)
+       if ((flags & XFS_DIFLAG_REALTIME) && !mp->m_rtdev_targp)
                goto bad;
 
        /* new rt bitmap flag only valid for rbmino */
index 55d126d4e096e2e32a1dade11e271deb21078f11..4304c6416fbbc1e30b77d655bd3678c2815c5df9 100644 (file)
@@ -346,8 +346,8 @@ xfs_map_blocks(
        ssize_t                 count = i_blocksize(inode);
        xfs_fileoff_t           offset_fsb = XFS_B_TO_FSBT(mp, offset);
        xfs_fileoff_t           end_fsb = XFS_B_TO_FSB(mp, offset + count);
-       xfs_fileoff_t           cow_fsb = NULLFILEOFF;
-       int                     whichfork = XFS_DATA_FORK;
+       xfs_fileoff_t           cow_fsb;
+       int                     whichfork;
        struct xfs_bmbt_irec    imap;
        struct xfs_iext_cursor  icur;
        int                     retries = 0;
@@ -381,6 +381,8 @@ xfs_map_blocks(
         * landed in a hole and we skip the block.
         */
 retry:
+       cow_fsb = NULLFILEOFF;
+       whichfork = XFS_DATA_FORK;
        xfs_ilock(ip, XFS_ILOCK_SHARED);
        ASSERT(ip->i_df.if_format != XFS_DINODE_FMT_BTREE ||
               (ip->i_df.if_flags & XFS_IFEXTENTS));
@@ -527,13 +529,15 @@ xfs_prepare_ioend(
  */
 static void
 xfs_discard_page(
-       struct page             *page)
+       struct page             *page,
+       loff_t                  fileoff)
 {
        struct inode            *inode = page->mapping->host;
        struct xfs_inode        *ip = XFS_I(inode);
        struct xfs_mount        *mp = ip->i_mount;
-       loff_t                  offset = page_offset(page);
-       xfs_fileoff_t           start_fsb = XFS_B_TO_FSBT(mp, offset);
+       unsigned int            pageoff = offset_in_page(fileoff);
+       xfs_fileoff_t           start_fsb = XFS_B_TO_FSBT(mp, fileoff);
+       xfs_fileoff_t           pageoff_fsb = XFS_B_TO_FSBT(mp, pageoff);
        int                     error;
 
        if (XFS_FORCED_SHUTDOWN(mp))
@@ -541,14 +545,14 @@ xfs_discard_page(
 
        xfs_alert_ratelimited(mp,
                "page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
-                       page, ip->i_ino, offset);
+                       page, ip->i_ino, fileoff);
 
        error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
-                       i_blocks_per_page(inode, page));
+                       i_blocks_per_page(inode, page) - pageoff_fsb);
        if (error && !XFS_FORCED_SHUTDOWN(mp))
                xfs_alert(mp, "page discard unable to remove delalloc mapping.");
 out_invalidate:
-       iomap_invalidatepage(page, 0, PAGE_SIZE);
+       iomap_invalidatepage(page, pageoff, PAGE_SIZE - pageoff);
 }
 
 static const struct iomap_writeback_ops xfs_writeback_ops = {
index 5e165456da68f42b7f23a126ee702d4f43cb1824..1414ab79eacfc27c4f8056a906133f4730153ea0 100644 (file)
@@ -911,6 +911,16 @@ xfs_setattr_size(
                error = iomap_zero_range(inode, oldsize, newsize - oldsize,
                                &did_zeroing, &xfs_buffered_write_iomap_ops);
        } else {
+               /*
+                * iomap won't detect a dirty page over an unwritten block (or a
+                * cow block over a hole) and subsequently skips zeroing the
+                * newly post-EOF portion of the page. Flush the new EOF to
+                * convert the block before the pagecache truncate.
+                */
+               error = filemap_write_and_wait_range(inode->i_mapping, newsize,
+                                                    newsize);
+               if (error)
+                       return error;
                error = iomap_truncate_page(inode, newsize, &did_zeroing,
                                &xfs_buffered_write_iomap_ops);
        }
index 16098dc42addb81cd3f862113d719edf8a3e73b3..6fa05fb78189bb1b2479d5071f690ed00e22f8d2 100644 (file)
@@ -1502,7 +1502,8 @@ xfs_reflink_unshare(
                        &xfs_buffered_write_iomap_ops);
        if (error)
                goto out;
-       error = filemap_write_and_wait(inode->i_mapping);
+
+       error = filemap_write_and_wait_range(inode->i_mapping, offset, len);
        if (error)
                goto out;
 
index 45f9872fd74759d7daf0a643d960378602c5e182..4973328f3c6e75ae04b010d10f7210d8c5279b1d 100644 (file)
@@ -12,7 +12,8 @@
 #ifdef CONFIG_UACCESS_MEMCPY
 #include <asm/unaligned.h>
 
-static inline int __get_user_fn(size_t size, const void __user *from, void *to)
+static __always_inline int
+__get_user_fn(size_t size, const void __user *from, void *to)
 {
        BUILD_BUG_ON(!__builtin_constant_p(size));
 
@@ -37,7 +38,8 @@ static inline int __get_user_fn(size_t size, const void __user *from, void *to)
 }
 #define __get_user_fn(sz, u, k)        __get_user_fn(sz, u, k)
 
-static inline int __put_user_fn(size_t size, void __user *to, void *from)
+static __always_inline int
+__put_user_fn(size_t size, void __user *to, void *from)
 {
        BUILD_BUG_ON(!__builtin_constant_p(size));
 
index cd14444bf600516a24894669b4f4473fd4021dd0..b2b3d81b1535a5abbf6803f3dfbb29058a979bc4 100644 (file)
 #ifdef CONFIG_CONSTRUCTORS
 #define KERNEL_CTORS() . = ALIGN(8);                      \
                        __ctors_start = .;                 \
+                       KEEP(*(SORT(.ctors.*)))            \
                        KEEP(*(.ctors))                    \
                        KEEP(*(SORT(.init_array.*)))       \
                        KEEP(*(.init_array))               \
index da53aebb7230b980ba23e9c87d361d9b6d6906df..a53243abd9450508bb302d59122607dede8eb049 100644 (file)
@@ -1836,7 +1836,7 @@ static inline void drm_dp_cec_unset_edid(struct drm_dp_aux *aux)
  * @link_rate: Requested Link rate from DPCD 0x219
  * @num_lanes: Number of lanes requested by sing through DPCD 0x220
  * @phy_pattern: DP Phy test pattern from DPCD 0x248
- * @hb2_reset: DP HBR2_COMPLIANCE_SCRAMBLER_RESET from DCPD 0x24A and 0x24B
+ * @hbr2_reset: DP HBR2_COMPLIANCE_SCRAMBLER_RESET from DCPD 0x24A and 0x24B
  * @custom80: DP Test_80BIT_CUSTOM_PATTERN from DPCDs 0x250 through 0x259
  * @enhanced_frame_cap: flag for enhanced frame capability.
  */
index b27a0e2169c8f56bdcd882ea18f5cd200248a327..e97daf6ffbb193a74505026492b9f29825ee365d 100644 (file)
@@ -359,13 +359,6 @@ drm_load_edid_firmware(struct drm_connector *connector)
 }
 #endif
 
-/**
- * drm_edid_are_equal - compare two edid blobs.
- * @edid1: pointer to first blob
- * @edid2: pointer to second blob
- * This helper can be used during probing to determine if
- * edid had changed.
- */
 bool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2);
 
 int
index 1c9417430d08520f8c5c9a593ee874f7d5aebdfc..f32d179e139d9cdd45621436fe866d5332bd510d 100644 (file)
@@ -338,7 +338,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
                 const char *format, ...);
 
 /**
- * Error output.
+ * DRM_DEV_ERROR() - Error output.
  *
  * @dev: device pointer
  * @fmt: printf() like format string.
@@ -347,10 +347,12 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
        drm_dev_printk(dev, KERN_ERR, "*ERROR* " fmt, ##__VA_ARGS__)
 
 /**
- * Rate limited error output.  Like DRM_ERROR() but won't flood the log.
+ * DRM_DEV_ERROR_RATELIMITED() - Rate limited error output.
  *
  * @dev: device pointer
  * @fmt: printf() like format string.
+ *
+ * Like DRM_ERROR() but won't flood the log.
  */
 #define DRM_DEV_ERROR_RATELIMITED(dev, fmt, ...)                       \
 ({                                                                     \
@@ -375,15 +377,27 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category,
 })
 
 /**
- * Debug output.
+ * DRM_DEV_DEBUG() - Debug output for generic drm code
  *
  * @dev: device pointer
  * @fmt: printf() like format string.
  */
 #define DRM_DEV_DEBUG(dev, fmt, ...)                                   \
        drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##__VA_ARGS__)
+/**
+ * DRM_DEV_DEBUG_DRIVER() - Debug output for vendor specific part of the driver
+ *
+ * @dev: device pointer
+ * @fmt: printf() like format string.
+ */
 #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...)                            \
        drm_dev_dbg(dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__)
+/**
+ * DRM_DEV_DEBUG_KMS() - Debug output for modesetting code
+ *
+ * @dev: device pointer
+ * @fmt: printf() like format string.
+ */
 #define DRM_DEV_DEBUG_KMS(dev, fmt, ...)                               \
        drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__VA_ARGS__)
 
index 9197da7923361a8a4e20674e547f7f8a036b56b4..db1b0ae666c4618a4396bcb80f68d314fb22362f 100644 (file)
@@ -252,13 +252,14 @@ static inline int kunit_run_all_tests(void)
 }
 #endif /* IS_BUILTIN(CONFIG_KUNIT) */
 
+#ifdef MODULE
 /**
- * kunit_test_suites() - used to register one or more &struct kunit_suite
- *                      with KUnit.
+ * kunit_test_suites_for_module() - used to register one or more
+ *                      &struct kunit_suite with KUnit.
  *
- * @suites_list...: a statically allocated list of &struct kunit_suite.
+ * @__suites: a statically allocated list of &struct kunit_suite.
  *
- * Registers @suites_list with the test framework. See &struct kunit_suite for
+ * Registers @__suites with the test framework. See &struct kunit_suite for
  * more information.
  *
  * If a test suite is built-in, module_init() gets translated into
@@ -267,7 +268,6 @@ static inline int kunit_run_all_tests(void)
  * module_{init|exit} functions for the builtin case when registering
  * suites via kunit_test_suites() below.
  */
-#ifdef MODULE
 #define kunit_test_suites_for_module(__suites)                         \
        static int __init kunit_test_suites_init(void)                  \
        {                                                               \
@@ -294,7 +294,7 @@ static inline int kunit_run_all_tests(void)
  * kunit_test_suites() - used to register one or more &struct kunit_suite
  *                      with KUnit.
  *
- * @suites: a statically allocated list of &struct kunit_suite.
+ * @__suites: a statically allocated list of &struct kunit_suite.
  *
  * Registers @suites with the test framework. See &struct kunit_suite for
  * more information.
@@ -308,10 +308,10 @@ static inline int kunit_run_all_tests(void)
  * module.
  *
  */
-#define kunit_test_suites(...)                                         \
+#define kunit_test_suites(__suites...)                                         \
        __kunit_test_suites(__UNIQUE_ID(array),                         \
                            __UNIQUE_ID(suites),                        \
-                           __VA_ARGS__)
+                           ##__suites)
 
 #define kunit_test_suite(suite)        kunit_test_suites(&suite)
 
index 20a32120bb880962ea7caa303c937991248b71cc..1a12baa58e409b05ea715704cb8e27ff6b95c195 100644 (file)
@@ -38,6 +38,7 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *size);
 const struct iommu_ops *iort_iommu_configure_id(struct device *dev,
                                                const u32 *id_in);
 int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head);
+phys_addr_t acpi_iort_dma_get_max_cpu_address(void);
 #else
 static inline void acpi_iort_init(void) { }
 static inline u32 iort_msi_map_id(struct device *dev, u32 id)
@@ -55,6 +56,9 @@ static inline const struct iommu_ops *iort_iommu_configure_id(
 static inline
 int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
 { return 0; }
+
+static inline phys_addr_t acpi_iort_dma_get_max_cpu_address(void)
+{ return PHYS_ADDR_MAX; }
 #endif
 
 #endif /* __ACPI_IORT_H__ */
index b23eeca4d67729c14e95a1a2ce082922939ebfcd..794b2a33a2c36c8f4c335a9868fbccdb11d2e99a 100644 (file)
@@ -235,6 +235,8 @@ enum hctx_type {
  * @flags:        Zero or more BLK_MQ_F_* flags.
  * @driver_data:   Pointer to data owned by the block driver that created this
  *                tag set.
+ * @active_queues_shared_sbitmap:
+ *                number of active request queues per tag set.
  * @__bitmap_tags: A shared tags sbitmap, used over all hctx's
  * @__breserved_tags:
  *                A shared reserved tags sbitmap, used over all hctx's
index 900b9f4e060540ce09d5cf6cd5081fee9af733e0..fc61cf4eff1c9af159ab25a37a8041de156034ef 100644 (file)
@@ -61,21 +61,17 @@ static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk)
  */
 static inline struct sk_buff *can_create_echo_skb(struct sk_buff *skb)
 {
-       if (skb_shared(skb)) {
-               struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
+       struct sk_buff *nskb;
 
-               if (likely(nskb)) {
-                       can_skb_set_owner(nskb, skb->sk);
-                       consume_skb(skb);
-                       return nskb;
-               } else {
-                       kfree_skb(skb);
-                       return NULL;
-               }
+       nskb = skb_clone(skb, GFP_ATOMIC);
+       if (unlikely(!nskb)) {
+               kfree_skb(skb);
+               return NULL;
        }
 
-       /* we can assume to have an unshared skb with proper owner */
-       return skb;
+       can_skb_set_owner(nskb, skb->sk);
+       consume_skb(skb);
+       return nskb;
 }
 
 #endif /* !_CAN_SKB_H */
index fa37b1c6644326467426335e27702c02cbbfe802..1eaa04f1bae634fe92485117aa4e596c011437c7 100644 (file)
@@ -298,7 +298,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
 
 struct cpufreq_driver {
        char            name[CPUFREQ_NAME_LEN];
-       u             flags;
+       u16             flags;
        void            *driver_data;
 
        /* needed by all drivers */
@@ -422,9 +422,18 @@ struct cpufreq_driver {
  */
 #define CPUFREQ_IS_COOLING_DEV                 BIT(7)
 
+/*
+ * Set by drivers that need to update internale upper and lower boundaries along
+ * with the target frequency and so the core and governors should also invoke
+ * the diver if the target frequency does not change, but the policy min or max
+ * may have changed.
+ */
+#define CPUFREQ_NEED_UPDATE_LIMITS             BIT(8)
+
 int cpufreq_register_driver(struct cpufreq_driver *driver_data);
 int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
 
+bool cpufreq_driver_test_flags(u16 flags);
 const char *cpufreq_get_current_driver(void);
 void *cpufreq_get_driver_data(void);
 
index 851dd1f9a8a5f5466933e23709c50d7c39e13d5b..d6c4cc9ecc77cca2f6d6e5b719ba4eb576dd2fd1 100644 (file)
@@ -144,10 +144,9 @@ void debugfs_create_u32_array(const char *name, umode_t mode,
                              struct dentry *parent,
                              struct debugfs_u32_array *array);
 
-struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name,
-                                          struct dentry *parent,
-                                          int (*read_fn)(struct seq_file *s,
-                                                         void *data));
+void debugfs_create_devm_seqfile(struct device *dev, const char *name,
+                                struct dentry *parent,
+                                int (*read_fn)(struct seq_file *s, void *data));
 
 bool debugfs_initialized(void);
 
@@ -327,13 +326,12 @@ static inline void debugfs_create_u32_array(const char *name, umode_t mode,
 {
 }
 
-static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev,
-                                                        const char *name,
-                                                        struct dentry *parent,
-                                          int (*read_fn)(struct seq_file *s,
-                                                         void *data))
+static inline void debugfs_create_devm_seqfile(struct device *dev,
+                                              const char *name,
+                                              struct dentry *parent,
+                                              int (*read_fn)(struct seq_file *s,
+                                                             void *data))
 {
-       return ERR_PTR(-ENODEV);
 }
 
 static inline ssize_t debugfs_read_file_bool(struct file *file,
index 5896441ee604c7c424a5655cb9cbe8dcae4f226e..efa2f0309f0049894ae5614c29d2f427bde44f57 100644 (file)
@@ -47,7 +47,7 @@ struct cppi5_host_desc_t {
        u32 buf_info1;
        u32 org_buf_len;
        u64 org_buf_ptr;
-       u32 epib[0];
+       u32 epib[];
 } __packed;
 
 #define CPPI5_DESC_MIN_ALIGN                   (16U)
@@ -139,7 +139,7 @@ struct cppi5_desc_epib_t {
  */
 struct cppi5_monolithic_desc_t {
        struct cppi5_desc_hdr_t hdr;
-       u32 epib[0];
+       u32 epib[];
 };
 
 #define CPPI5_INFO2_MDESC_DATA_OFFSET_SHIFT    (18U)
index 0bd126418bb6ad43bdf9302c50525dd3fe3baec4..21cc971fd96094731ee733b806ac2c6fbd744b15 100644 (file)
@@ -3285,7 +3285,7 @@ static inline ino_t parent_ino(struct dentry *dentry)
  */
 struct simple_transaction_argresp {
        ssize_t size;
-       char data[0];
+       char data[];
 };
 
 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))
index 868364cea3b740429a7ca4e84337b7ad79846956..35b2d845704d9175466d979138d413d85423664b 100644 (file)
@@ -30,7 +30,8 @@ struct io_uring_task {
        struct percpu_counter   inflight;
        struct io_identity      __identity;
        struct io_identity      *identity;
-       bool                    in_idle;
+       atomic_t                in_idle;
+       bool                    sqpoll;
 };
 
 #if defined(CONFIG_IO_URING)
index 172b3397a1a371bc7038f201bed644c92341700f..5bd3cac4df9cb4569689a1312dd8f8b8e7455b96 100644 (file)
@@ -221,7 +221,7 @@ struct iomap_writeback_ops {
         * Optional, allows the file system to discard state on a page where
         * we failed to submit any I/O.
         */
-       void (*discard_page)(struct page *page);
+       void (*discard_page)(struct page *page, loff_t fileoff);
 };
 
 struct iomap_writepage_ctx {
index fb3d71ad6eeafbef597200be28d867f664321848..1d5566af48ac45fcae6fb6ecda113f4ac5f67636 100644 (file)
@@ -263,7 +263,10 @@ typedef struct journal_superblock_s
 /* 0x0050 */
        __u8    s_checksum_type;        /* checksum type */
        __u8    s_padding2[3];
-       __u32   s_padding[42];
+/* 0x0054 */
+       __be32  s_num_fc_blks;          /* Number of fast commit blocks */
+/* 0x0058 */
+       __u32   s_padding[41];
        __be32  s_checksum;             /* crc32c(superblock) */
 
 /* 0x0100 */
@@ -1253,7 +1256,7 @@ struct journal_s
         */
        void (*j_fc_cleanup_callback)(struct journal_s *journal, int);
 
-       /*
+       /**
         * @j_fc_replay_callback:
         *
         * File-system specific function that performs replay of a fast
index cfb62e9f37be090da5a20e4b99c5d3bc31fe7f7e..ab7f8c152b89b4e791085900f78181b3b3444ee3 100644 (file)
@@ -99,6 +99,7 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
        case 2:  a += (u32)k[1]<<8;     fallthrough;
        case 1:  a += k[0];
                 __jhash_final(a, b, c);
+                break;
        case 0: /* Nothing left to add */
                break;
        }
@@ -136,6 +137,7 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
        case 2: b += k[1];      fallthrough;
        case 1: a += k[0];
                __jhash_final(a, b, c);
+               break;
        case 0: /* Nothing left to add */
                break;
        }
index 9542b41eacfdc5d3fa2ba7c0a0d5916ac18940af..35ce84c8ca02cefe55cdaebc16a75f11ec120409 100644 (file)
@@ -14,7 +14,7 @@
  */
 struct zynqmp_ipi_message {
        size_t len;
-       u8 data[0];
+       u8 data[];
 };
 
 #endif /* _LINUX_ZYNQMP_IPI_MESSAGE_H_ */
diff --git a/include/linux/mic_bus.h b/include/linux/mic_bus.h
deleted file mode 100644 (file)
index e99c789..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * Intel MIC Bus driver.
- *
- * This implementation is very similar to the virtio bus driver
- * implementation @ include/linux/virtio.h.
- */
-#ifndef _MIC_BUS_H_
-#define _MIC_BUS_H_
-/*
- * Everything a mbus driver needs to work with any particular mbus
- * implementation.
- */
-#include <linux/interrupt.h>
-#include <linux/dma-mapping.h>
-
-struct mbus_device_id {
-       __u32 device;
-       __u32 vendor;
-};
-
-#define MBUS_DEV_DMA_HOST 2
-#define MBUS_DEV_DMA_MIC 3
-#define MBUS_DEV_ANY_ID 0xffffffff
-
-/**
- * mbus_device - representation of a device using mbus
- * @mmio_va: virtual address of mmio space
- * @hw_ops: the hardware ops supported by this device.
- * @id: the device type identification (used to match it with a driver).
- * @dev: underlying device.
- * be used to communicate with.
- * @index: unique position on the mbus bus
- */
-struct mbus_device {
-       void __iomem *mmio_va;
-       struct mbus_hw_ops *hw_ops;
-       struct mbus_device_id id;
-       struct device dev;
-       int index;
-};
-
-/**
- * mbus_driver - operations for a mbus I/O driver
- * @driver: underlying device driver (populate name and owner).
- * @id_table: the ids serviced by this driver.
- * @probe: the function to call when a device is found.  Returns 0 or -errno.
- * @remove: the function to call when a device is removed.
- */
-struct mbus_driver {
-       struct device_driver driver;
-       const struct mbus_device_id *id_table;
-       int (*probe)(struct mbus_device *dev);
-       void (*scan)(struct mbus_device *dev);
-       void (*remove)(struct mbus_device *dev);
-};
-
-/**
- * struct mic_irq - opaque pointer used as cookie
- */
-struct mic_irq;
-
-/**
- * mbus_hw_ops - Hardware operations for accessing a MIC device on the MIC bus.
- */
-struct mbus_hw_ops {
-       struct mic_irq* (*request_threaded_irq)(struct mbus_device *mbdev,
-                                               irq_handler_t handler,
-                                               irq_handler_t thread_fn,
-                                               const char *name, void *data,
-                                               int intr_src);
-       void (*free_irq)(struct mbus_device *mbdev,
-                        struct mic_irq *cookie, void *data);
-       void (*ack_interrupt)(struct mbus_device *mbdev, int num);
-};
-
-struct mbus_device *
-mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
-                    struct mbus_hw_ops *hw_ops, int index,
-                    void __iomem *mmio_va);
-void mbus_unregister_device(struct mbus_device *mbdev);
-
-int mbus_register_driver(struct mbus_driver *drv);
-void mbus_unregister_driver(struct mbus_driver *drv);
-
-static inline struct mbus_device *dev_to_mbus(struct device *_dev)
-{
-       return container_of(_dev, struct mbus_device, dev);
-}
-
-static inline struct mbus_driver *drv_to_mbus(struct device_driver *drv)
-{
-       return container_of(drv, struct mbus_driver, driver);
-}
-
-#endif /* _MIC_BUS_H */
index add85094f9a58c14579fc624fd379be15c32e59e..0f23e1ed5e71095a38df7dc153b01b15e55a8472 100644 (file)
@@ -1213,4 +1213,22 @@ static inline bool mlx5_is_roce_enabled(struct mlx5_core_dev *dev)
        return val.vbool;
 }
 
+/**
+ * mlx5_core_net - Provide net namespace of the mlx5_core_dev
+ * @dev: mlx5 core device
+ *
+ * mlx5_core_net() returns the net namespace of mlx5 core device.
+ * This can be called only in below described limited context.
+ * (a) When a devlink instance for mlx5_core is registered and
+ *     when devlink reload operation is disabled.
+ *     or
+ * (b) during devlink reload reload_down() and reload_up callbacks
+ *     where it is ensured that devlink instance's net namespace is
+ *     stable.
+ */
+static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
+{
+       return devlink_net(priv_to_devlink(dev));
+}
+
 #endif /* MLX5_DRIVER_H */
index 651591a2965d218b71a82f3daa975a2956d9b3d0..a092346c7b2db0e38e4d069b2988ce45f07bef09 100644 (file)
@@ -5823,7 +5823,7 @@ struct mlx5_ifc_alloc_modify_header_context_in_bits {
        u8         reserved_at_68[0x10];
        u8         num_of_actions[0x8];
 
-       union mlx5_ifc_set_add_copy_action_in_auto_bits actions[0];
+       union mlx5_ifc_set_add_copy_action_in_auto_bits actions[];
 };
 
 struct mlx5_ifc_dealloc_modify_header_context_out_bits {
@@ -9761,7 +9761,7 @@ struct mlx5_ifc_mcda_reg_bits {
 
        u8         reserved_at_60[0x20];
 
-       u8         data[0][0x20];
+       u8         data[][0x20];
 };
 
 enum {
index ef360fe70aafcf6d2e40bc5b89a4cd0fc82a1bc9..db6ae4d3fb4edc82ad0c7ccf80eac47726862b20 100644 (file)
@@ -2759,6 +2759,15 @@ static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma,
        return VM_FAULT_NOPAGE;
 }
 
+#ifndef io_remap_pfn_range
+static inline int io_remap_pfn_range(struct vm_area_struct *vma,
+                                    unsigned long addr, unsigned long pfn,
+                                    unsigned long size, pgprot_t prot)
+{
+       return remap_pfn_range(vma, addr, pfn, size, pgprot_decrypted(prot));
+}
+#endif
+
 static inline vm_fault_t vmf_error(int err)
 {
        if (err == -ENOMEM)
index fb3bf696c05e86e81e6ff2c3ceca50e299625faf..9d0c454d23cd626107aecfd184f1e446f4d763b1 100644 (file)
@@ -354,26 +354,6 @@ enum zone_type {
         * DMA mask is assumed when ZONE_DMA32 is defined. Some 64-bit
         * platforms may need both zones as they support peripherals with
         * different DMA addressing limitations.
-        *
-        * Some examples:
-        *
-        *  - i386 and x86_64 have a fixed 16M ZONE_DMA and ZONE_DMA32 for the
-        *    rest of the lower 4G.
-        *
-        *  - arm only uses ZONE_DMA, the size, up to 4G, may vary depending on
-        *    the specific device.
-        *
-        *  - arm64 has a fixed 1G ZONE_DMA and ZONE_DMA32 for the rest of the
-        *    lower 4G.
-        *
-        *  - powerpc only uses ZONE_DMA, the size, up to 2G, may vary
-        *    depending on the specific device.
-        *
-        *  - s390 uses ZONE_DMA fixed to the lower 2G.
-        *
-        *  - ia64 and riscv only use ZONE_DMA32.
-        *
-        *  - parisc uses neither.
         */
 #ifdef CONFIG_ZONE_DMA
        ZONE_DMA,
index 89016d08f6a278d9a7703cc4256c277f05fa7173..f6267e2883f261e0bd533a349759fad1b7e8d656 100644 (file)
@@ -24,6 +24,12 @@ struct nfnl_callback {
        const u_int16_t attr_count;             /* number of nlattr's */
 };
 
+enum nfnl_abort_action {
+       NFNL_ABORT_NONE         = 0,
+       NFNL_ABORT_AUTOLOAD,
+       NFNL_ABORT_VALIDATE,
+};
+
 struct nfnetlink_subsystem {
        const char *name;
        __u8 subsys_id;                 /* nfnetlink subsystem ID */
@@ -31,7 +37,8 @@ struct nfnetlink_subsystem {
        const struct nfnl_callback *cb; /* callback for individual types */
        struct module *owner;
        int (*commit)(struct net *net, struct sk_buff *skb);
-       int (*abort)(struct net *net, struct sk_buff *skb, bool autoload);
+       int (*abort)(struct net *net, struct sk_buff *skb,
+                    enum nfnl_abort_action action);
        void (*cleanup)(struct net *net);
        bool (*valid_genid)(struct net *net, u32 genid);
 };
index 082e2c41b7ff90a8e03c55f2f78c4d1129345760..5b70ca868bb1907165cc68b364534849a3a37f0c 100644 (file)
@@ -16,7 +16,7 @@ struct ip_rt_info {
        u_int32_t mark;
 };
 
-int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned addr_type);
+int ip_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb, unsigned addr_type);
 
 struct nf_queue_entry;
 
index 9b67394471e1c63462327d5cefdd7ab2701e0acf..48314ade1506f2108e32a56a9bab93599ba67152 100644 (file)
@@ -42,7 +42,7 @@ struct nf_ipv6_ops {
 #if IS_MODULE(CONFIG_IPV6)
        int (*chk_addr)(struct net *net, const struct in6_addr *addr,
                        const struct net_device *dev, int strict);
-       int (*route_me_harder)(struct net *net, struct sk_buff *skb);
+       int (*route_me_harder)(struct net *net, struct sock *sk, struct sk_buff *skb);
        int (*dev_get_saddr)(struct net *net, const struct net_device *dev,
                       const struct in6_addr *daddr, unsigned int srcprefs,
                       struct in6_addr *saddr);
@@ -143,9 +143,9 @@ static inline int nf_br_ip6_fragment(struct net *net, struct sock *sk,
 #endif
 }
 
-int ip6_route_me_harder(struct net *net, struct sk_buff *skb);
+int ip6_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb);
 
-static inline int nf_ip6_route_me_harder(struct net *net, struct sk_buff *skb)
+static inline int nf_ip6_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
 #if IS_MODULE(CONFIG_IPV6)
        const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
@@ -153,9 +153,9 @@ static inline int nf_ip6_route_me_harder(struct net *net, struct sk_buff *skb)
        if (!v6_ops)
                return -EHOSTUNREACH;
 
-       return v6_ops->route_me_harder(net, skb);
+       return v6_ops->route_me_harder(net, sk, skb);
 #elif IS_BUILTIN(CONFIG_IPV6)
-       return ip6_route_me_harder(net, skb);
+       return ip6_route_me_harder(net, sk, skb);
 #else
        return -EHOSTUNREACH;
 #endif
index 5d51891cbf1a68b38dbe65745555759b7dd653e0..9ed5b8532c30318786831c0fb1183f86d40e4073 100644 (file)
@@ -558,6 +558,8 @@ int of_map_id(struct device_node *np, u32 id,
               const char *map_name, const char *map_mask_name,
               struct device_node **target, u32 *id_out);
 
+phys_addr_t of_dma_get_max_cpu_address(struct device_node *np);
+
 #else /* CONFIG_OF */
 
 static inline void of_core_init(void)
@@ -995,6 +997,11 @@ static inline int of_map_id(struct device_node *np, u32 id,
        return -EINVAL;
 }
 
+static inline phys_addr_t of_dma_get_max_cpu_address(struct device_node *np)
+{
+       return PHYS_ADDR_MAX;
+}
+
 #define of_match_ptr(_ptr)     NULL
 #define of_match_node(_matches, _node) NULL
 #endif /* CONFIG_OF */
index c77b7c31b2e49563a5c5d853bbd9c55cc725a29b..e1e19c1f9ec9a34f449028b43f0008f9507c4b60 100644 (file)
@@ -344,9 +344,9 @@ static inline struct page *find_get_page_flags(struct address_space *mapping,
 /**
  * find_lock_page - locate, pin and lock a pagecache page
  * @mapping: the address_space to search
- * @offset: the page index
+ * @index: the page index
  *
- * Looks up the page cache entry at @mapping & @offset.  If there is a
+ * Looks up the page cache entry at @mapping & @index.  If there is a
  * page cache page, it is returned locked and with an increased
  * refcount.
  *
@@ -363,9 +363,9 @@ static inline struct page *find_lock_page(struct address_space *mapping,
 /**
  * find_lock_head - Locate, pin and lock a pagecache page.
  * @mapping: The address_space to search.
- * @offset: The page index.
+ * @index: The page index.
  *
- * Looks up the page cache entry at @mapping & @offset.  If there is a
+ * Looks up the page cache entry at @mapping & @index.  If there is a
  * page cache page, its head page is returned locked and with an increased
  * refcount.
  *
index 505480217cf1a9b4f779b454d42bc78c464e189b..bf7966776c5577fd4a92a8c0837943b4f0aa5c54 100644 (file)
@@ -163,6 +163,8 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn);
 static inline int arm_pmu_acpi_probe(armpmu_init_fn init_fn) { return 0; }
 #endif
 
+bool arm_pmu_irq_is_nmi(void);
+
 /* Internal functions only for core arm_pmu code */
 struct arm_pmu *armpmu_alloc(void);
 struct arm_pmu *armpmu_alloc_atomic(void);
index 38c33eabea8942bb09e09d4976f0203d61f70246..71125a4676c4a65cc6d9a67f31c0e3a1e11c0438 100644 (file)
@@ -1427,10 +1427,6 @@ typedef unsigned int pgtbl_mod_mask;
 
 #endif /* !__ASSEMBLY__ */
 
-#ifndef io_remap_pfn_range
-#define io_remap_pfn_range remap_pfn_range
-#endif
-
 #ifndef has_transparent_hugepage
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 #define has_transparent_hugepage() 1
index eb3cb1a98b450267b248d51d90de46b8883aca10..56563e5e0dc7513706bb6a856cf671d1f099c044 100644 (file)
@@ -147,16 +147,8 @@ typedef enum {
        PHY_INTERFACE_MODE_MAX,
 } phy_interface_t;
 
-/**
+/*
  * phy_supported_speeds - return all speeds currently supported by a PHY device
- * @phy: The PHY device to return supported speeds of.
- * @speeds: buffer to store supported speeds in.
- * @size: size of speeds buffer.
- *
- * Description: Returns the number of supported speeds, and fills
- * the speeds buffer with the supported speeds. If speeds buffer is
- * too small to contain all currently supported speeds, will return as
- * many speeds as can fit.
  */
 unsigned int phy_supported_speeds(struct phy_device *phy,
                                      unsigned int *speeds,
@@ -1022,14 +1014,9 @@ static inline int __phy_modify_changed(struct phy_device *phydev, u32 regnum,
                                        regnum, mask, set);
 }
 
-/**
+/*
  * phy_read_mmd - Convenience function for reading a register
  * from an MMD on a given PHY.
- * @phydev: The phy_device struct
- * @devad: The MMD to read from
- * @regnum: The register on the MMD to read
- *
- * Same rules as for phy_read();
  */
 int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
 
@@ -1064,38 +1051,21 @@ int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
        __ret; \
 })
 
-/**
+/*
  * __phy_read_mmd - Convenience function for reading a register
  * from an MMD on a given PHY.
- * @phydev: The phy_device struct
- * @devad: The MMD to read from
- * @regnum: The register on the MMD to read
- *
- * Same rules as for __phy_read();
  */
 int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
 
-/**
+/*
  * phy_write_mmd - Convenience function for writing a register
  * on an MMD on a given PHY.
- * @phydev: The phy_device struct
- * @devad: The MMD to write to
- * @regnum: The register on the MMD to read
- * @val: value to write to @regnum
- *
- * Same rules as for phy_write();
  */
 int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val);
 
-/**
+/*
  * __phy_write_mmd - Convenience function for writing a register
  * on an MMD on a given PHY.
- * @phydev: The phy_device struct
- * @devad: The MMD to write to
- * @regnum: The register on the MMD to read
- * @val: value to write to @regnum
- *
- * Same rules as for __phy_write();
  */
 int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val);
 
index 1fcfe9e63cb9b7d9a44180ac40e374572db4630e..a3a9a878415f10b44b78dfda15878b39a5c3a843 100644 (file)
@@ -1419,7 +1419,7 @@ struct ec_response_flash_info_2 {
        uint16_t num_banks_total;
        /* Number of banks described in banks array. */
        uint16_t num_banks_desc;
-       struct ec_flash_bank banks[0];
+       struct ec_flash_bank banks[];
 } __ec_align4;
 
 /*
@@ -2420,12 +2420,12 @@ struct ec_response_motion_sense_fifo_info {
        /* Total amount of vector lost */
        uint16_t total_lost;
        /* Lost events since the last fifo_info, per sensors */
-       uint16_t lost[0];
+       uint16_t lost[];
 } __ec_todo_packed;
 
 struct ec_response_motion_sense_fifo_data {
        uint32_t number_data;
-       struct ec_response_motion_sensor_data data[0];
+       struct ec_response_motion_sensor_data data[];
 } __ec_todo_packed;
 
 /* List supported activity recognition */
@@ -3093,7 +3093,7 @@ struct ec_response_tmp006_get_calibration_v1 {
        uint8_t algorithm;
        uint8_t num_params;
        uint8_t reserved[2];
-       float val[0];
+       float val[];
 } __ec_align4;
 
 struct ec_params_tmp006_set_calibration_v1 {
@@ -3101,7 +3101,7 @@ struct ec_params_tmp006_set_calibration_v1 {
        uint8_t algorithm;
        uint8_t num_params;
        uint8_t reserved;
-       float val[0];
+       float val[];
 } __ec_align4;
 
 
@@ -5076,7 +5076,7 @@ struct ec_response_pd_log {
        uint8_t type;       /* event type : see PD_EVENT_xx below */
        uint8_t size_port;  /* [7:5] port number [4:0] payload size in bytes */
        uint16_t data;      /* type-defined data payload */
-       uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */
+       uint8_t payload[];  /* optional additional data payload: 0..16 bytes */
 } __ec_align4;
 
 /* The timestamp is the microsecond counter shifted to get about a ms. */
@@ -5789,7 +5789,7 @@ struct ec_response_fp_encryption_status {
 
 struct ec_response_tp_frame_info {
        uint32_t n_frames;
-       uint32_t frame_sizes[0];
+       uint32_t frame_sizes[];
 } __ec_align4;
 
 /* Create a snapshot of current frame readings */
index 4a415ae851ef0891538e0ab3a3f93d08e818d3ac..02599687770c548ee4e8650c156fe65c5f8776d8 100644 (file)
@@ -69,7 +69,7 @@ struct cros_ec_command {
        uint32_t outsize;
        uint32_t insize;
        uint32_t result;
-       uint8_t data[0];
+       uint8_t data[];
 };
 
 /**
index 18b02dcc168e54fb1036877d55f2c1e6a42fae0d..4b708f4e8eed9df4d7f98ddcc8482f97dba63d2f 100644 (file)
@@ -54,11 +54,10 @@ extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
 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_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);
+extern void pm_runtime_drop_link(struct device_link *link);
 
 /**
  * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter.
@@ -276,11 +275,10 @@ static inline u64 pm_runtime_autosuspend_expiration(
                                struct device *dev) { return 0; }
 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_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) {}
+static inline void pm_runtime_drop_link(struct device_link *link) {}
 
 #endif /* !CONFIG_PM */
 
index 7fabb1af18e042e2aa126f132eed2d5a4d994e43..497990c69b0bf1352d47ecf7a79e30ff5cc71090 100644 (file)
@@ -147,24 +147,6 @@ static inline unsigned int refcount_read(const refcount_t *r)
        return atomic_read(&r->refs);
 }
 
-/**
- * refcount_add_not_zero - add a value to a refcount unless it is 0
- * @i: the value to add to the refcount
- * @r: the refcount
- *
- * Will saturate at REFCOUNT_SATURATED and WARN.
- *
- * Provides no memory ordering, it is assumed the caller has guaranteed the
- * object memory to be stable (RCU, etc.). It does provide a control dependency
- * and thereby orders future stores. See the comment on top.
- *
- * Use of this function is not recommended for the normal reference counting
- * use case in which references are taken and released one at a time.  In these
- * cases, refcount_inc(), or one of its variants, should instead be used to
- * increment a reference count.
- *
- * Return: false if the passed refcount is 0, true otherwise
- */
 static inline __must_check bool __refcount_add_not_zero(int i, refcount_t *r, int *oldp)
 {
        int old = refcount_read(r);
@@ -183,17 +165,12 @@ static inline __must_check bool __refcount_add_not_zero(int i, refcount_t *r, in
        return old;
 }
 
-static inline __must_check bool refcount_add_not_zero(int i, refcount_t *r)
-{
-       return __refcount_add_not_zero(i, r, NULL);
-}
-
 /**
- * refcount_add - add a value to a refcount
+ * refcount_add_not_zero - add a value to a refcount unless it is 0
  * @i: the value to add to the refcount
  * @r: the refcount
  *
- * Similar to atomic_add(), but will saturate at REFCOUNT_SATURATED and WARN.
+ * Will saturate at REFCOUNT_SATURATED and WARN.
  *
  * Provides no memory ordering, it is assumed the caller has guaranteed the
  * object memory to be stable (RCU, etc.). It does provide a control dependency
@@ -203,7 +180,14 @@ static inline __must_check bool refcount_add_not_zero(int i, refcount_t *r)
  * use case in which references are taken and released one at a time.  In these
  * cases, refcount_inc(), or one of its variants, should instead be used to
  * increment a reference count.
+ *
+ * Return: false if the passed refcount is 0, true otherwise
  */
+static inline __must_check bool refcount_add_not_zero(int i, refcount_t *r)
+{
+       return __refcount_add_not_zero(i, r, NULL);
+}
+
 static inline void __refcount_add(int i, refcount_t *r, int *oldp)
 {
        int old = atomic_fetch_add_relaxed(i, &r->refs);
@@ -217,11 +201,32 @@ static inline void __refcount_add(int i, refcount_t *r, int *oldp)
                refcount_warn_saturate(r, REFCOUNT_ADD_OVF);
 }
 
+/**
+ * refcount_add - add a value to a refcount
+ * @i: the value to add to the refcount
+ * @r: the refcount
+ *
+ * Similar to atomic_add(), but will saturate at REFCOUNT_SATURATED and WARN.
+ *
+ * Provides no memory ordering, it is assumed the caller has guaranteed the
+ * object memory to be stable (RCU, etc.). It does provide a control dependency
+ * and thereby orders future stores. See the comment on top.
+ *
+ * Use of this function is not recommended for the normal reference counting
+ * use case in which references are taken and released one at a time.  In these
+ * cases, refcount_inc(), or one of its variants, should instead be used to
+ * increment a reference count.
+ */
 static inline void refcount_add(int i, refcount_t *r)
 {
        __refcount_add(i, r, NULL);
 }
 
+static inline __must_check bool __refcount_inc_not_zero(refcount_t *r, int *oldp)
+{
+       return __refcount_add_not_zero(1, r, oldp);
+}
+
 /**
  * refcount_inc_not_zero - increment a refcount unless it is 0
  * @r: the refcount to increment
@@ -235,14 +240,14 @@ static inline void refcount_add(int i, refcount_t *r)
  *
  * Return: true if the increment was successful, false otherwise
  */
-static inline __must_check bool __refcount_inc_not_zero(refcount_t *r, int *oldp)
+static inline __must_check bool refcount_inc_not_zero(refcount_t *r)
 {
-       return __refcount_add_not_zero(1, r, oldp);
+       return __refcount_inc_not_zero(r, NULL);
 }
 
-static inline __must_check bool refcount_inc_not_zero(refcount_t *r)
+static inline void __refcount_inc(refcount_t *r, int *oldp)
 {
-       return __refcount_inc_not_zero(r, NULL);
+       __refcount_add(1, r, oldp);
 }
 
 /**
@@ -257,14 +262,27 @@ static inline __must_check bool refcount_inc_not_zero(refcount_t *r)
  * Will WARN if the refcount is 0, as this represents a possible use-after-free
  * condition.
  */
-static inline void __refcount_inc(refcount_t *r, int *oldp)
+static inline void refcount_inc(refcount_t *r)
 {
-       __refcount_add(1, r, oldp);
+       __refcount_inc(r, NULL);
 }
 
-static inline void refcount_inc(refcount_t *r)
+static inline __must_check bool __refcount_sub_and_test(int i, refcount_t *r, int *oldp)
 {
-       __refcount_inc(r, NULL);
+       int old = atomic_fetch_sub_release(i, &r->refs);
+
+       if (oldp)
+               *oldp = old;
+
+       if (old == i) {
+               smp_acquire__after_ctrl_dep();
+               return true;
+       }
+
+       if (unlikely(old < 0 || old - i < 0))
+               refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
+
+       return false;
 }
 
 /**
@@ -287,27 +305,14 @@ static inline void refcount_inc(refcount_t *r)
  *
  * Return: true if the resulting refcount is 0, false otherwise
  */
-static inline __must_check bool __refcount_sub_and_test(int i, refcount_t *r, int *oldp)
+static inline __must_check bool refcount_sub_and_test(int i, refcount_t *r)
 {
-       int old = atomic_fetch_sub_release(i, &r->refs);
-
-       if (oldp)
-               *oldp = old;
-
-       if (old == i) {
-               smp_acquire__after_ctrl_dep();
-               return true;
-       }
-
-       if (unlikely(old < 0 || old - i < 0))
-               refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
-
-       return false;
+       return __refcount_sub_and_test(i, r, NULL);
 }
 
-static inline __must_check bool refcount_sub_and_test(int i, refcount_t *r)
+static inline __must_check bool __refcount_dec_and_test(refcount_t *r, int *oldp)
 {
-       return __refcount_sub_and_test(i, r, NULL);
+       return __refcount_sub_and_test(1, r, oldp);
 }
 
 /**
@@ -323,26 +328,11 @@ static inline __must_check bool refcount_sub_and_test(int i, refcount_t *r)
  *
  * Return: true if the resulting refcount is 0, false otherwise
  */
-static inline __must_check bool __refcount_dec_and_test(refcount_t *r, int *oldp)
-{
-       return __refcount_sub_and_test(1, r, oldp);
-}
-
 static inline __must_check bool refcount_dec_and_test(refcount_t *r)
 {
        return __refcount_dec_and_test(r, NULL);
 }
 
-/**
- * refcount_dec - decrement a refcount
- * @r: the refcount
- *
- * Similar to atomic_dec(), it will WARN on underflow and fail to decrement
- * when saturated at REFCOUNT_SATURATED.
- *
- * Provides release memory ordering, such that prior loads and stores are done
- * before.
- */
 static inline void __refcount_dec(refcount_t *r, int *oldp)
 {
        int old = atomic_fetch_sub_release(1, &r->refs);
@@ -354,6 +344,16 @@ static inline void __refcount_dec(refcount_t *r, int *oldp)
                refcount_warn_saturate(r, REFCOUNT_DEC_LEAK);
 }
 
+/**
+ * refcount_dec - decrement a refcount
+ * @r: the refcount
+ *
+ * Similar to atomic_dec(), it will WARN on underflow and fail to decrement
+ * when saturated at REFCOUNT_SATURATED.
+ *
+ * Provides release memory ordering, such that prior loads and stores are done
+ * before.
+ */
 static inline void refcount_dec(refcount_t *r)
 {
        __refcount_dec(r, NULL);
diff --git a/include/linux/scif.h b/include/linux/scif.h
deleted file mode 100644 (file)
index 329e695..0000000
+++ /dev/null
@@ -1,1339 +0,0 @@
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * 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) 2014 Intel Corporation.
- *
- * 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.
- *
- * 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.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2014 Intel Corporation.
- *
- * 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 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 SCIF driver.
- *
- */
-#ifndef __SCIF_H__
-#define __SCIF_H__
-
-#include <linux/types.h>
-#include <linux/poll.h>
-#include <linux/device.h>
-#include <linux/scif_ioctl.h>
-
-#define SCIF_ACCEPT_SYNC       1
-#define SCIF_SEND_BLOCK                1
-#define SCIF_RECV_BLOCK                1
-
-enum {
-       SCIF_PROT_READ = (1 << 0),
-       SCIF_PROT_WRITE = (1 << 1)
-};
-
-enum {
-       SCIF_MAP_FIXED = 0x10,
-       SCIF_MAP_KERNEL = 0x20,
-};
-
-enum {
-       SCIF_FENCE_INIT_SELF = (1 << 0),
-       SCIF_FENCE_INIT_PEER = (1 << 1),
-       SCIF_SIGNAL_LOCAL = (1 << 4),
-       SCIF_SIGNAL_REMOTE = (1 << 5)
-};
-
-enum {
-       SCIF_RMA_USECPU = (1 << 0),
-       SCIF_RMA_USECACHE = (1 << 1),
-       SCIF_RMA_SYNC = (1 << 2),
-       SCIF_RMA_ORDERED = (1 << 3)
-};
-
-/* End of SCIF Admin Reserved Ports */
-#define SCIF_ADMIN_PORT_END    1024
-
-/* End of SCIF Reserved Ports */
-#define SCIF_PORT_RSVD         1088
-
-typedef struct scif_endpt *scif_epd_t;
-typedef struct scif_pinned_pages *scif_pinned_pages_t;
-
-/**
- * struct scif_range - SCIF registered range used in kernel mode
- * @cookie: cookie used internally by SCIF
- * @nr_pages: number of pages of PAGE_SIZE
- * @prot_flags: R/W protection
- * @phys_addr: Array of bus addresses
- * @va: Array of kernel virtual addresses backed by the pages in the phys_addr
- *     array. The va is populated only when called on the host for a remote
- *     SCIF connection on MIC. This is required to support the use case of DMA
- *     between MIC and another device which is not a SCIF node e.g., an IB or
- *     ethernet NIC.
- */
-struct scif_range {
-       void *cookie;
-       int nr_pages;
-       int prot_flags;
-       dma_addr_t *phys_addr;
-       void __iomem **va;
-};
-
-/**
- * struct scif_pollepd - SCIF endpoint to be monitored via scif_poll
- * @epd: SCIF endpoint
- * @events: requested events
- * @revents: returned events
- */
-struct scif_pollepd {
-       scif_epd_t epd;
-       __poll_t events;
-       __poll_t revents;
-};
-
-/**
- * scif_peer_dev - representation of a peer SCIF device
- *
- * Peer devices show up as PCIe devices for the mgmt node but not the cards.
- * The mgmt node discovers all the cards on the PCIe bus and informs the other
- * cards about their peers. Upon notification of a peer a node adds a peer
- * device to the peer bus to maintain symmetry in the way devices are
- * discovered across all nodes in the SCIF network.
- *
- * @dev: underlying device
- * @dnode - The destination node which this device will communicate with.
- */
-struct scif_peer_dev {
-       struct device dev;
-       u8 dnode;
-};
-
-/**
- * scif_client - representation of a SCIF client
- * @name: client name
- * @probe - client method called when a peer device is registered
- * @remove - client method called when a peer device is unregistered
- * @si - subsys_interface used internally for implementing SCIF clients
- */
-struct scif_client {
-       const char *name;
-       void (*probe)(struct scif_peer_dev *spdev);
-       void (*remove)(struct scif_peer_dev *spdev);
-       struct subsys_interface si;
-};
-
-#define SCIF_OPEN_FAILED ((scif_epd_t)-1)
-#define SCIF_REGISTER_FAILED ((off_t)-1)
-#define SCIF_MMAP_FAILED ((void *)-1)
-
-/**
- * scif_open() - Create an endpoint
- *
- * Return:
- * Upon successful completion, scif_open() returns an endpoint descriptor to
- * be used in subsequent SCIF functions calls to refer to that endpoint;
- * otherwise in user mode SCIF_OPEN_FAILED (that is ((scif_epd_t)-1)) is
- * returned and errno is set to indicate the error; in kernel mode a NULL
- * scif_epd_t is returned.
- *
- * Errors:
- * ENOMEM - Insufficient kernel memory was available
- */
-scif_epd_t scif_open(void);
-
-/**
- * scif_bind() - Bind an endpoint to a port
- * @epd:       endpoint descriptor
- * @pn:                port number
- *
- * scif_bind() binds endpoint epd to port pn, where pn is a port number on the
- * local node. If pn is zero, a port number greater than or equal to
- * SCIF_PORT_RSVD is assigned and returned. Each endpoint may be bound to
- * exactly one local port. Ports less than 1024 when requested can only be bound
- * by system (or root) processes or by processes executed by privileged users.
- *
- * Return:
- * Upon successful completion, scif_bind() returns the port number to which epd
- * is bound; otherwise in user mode -1 is returned and errno is set to
- * indicate the error; in kernel mode the negative of one of the following
- * errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * EINVAL - the endpoint or the port is already bound
- * EISCONN - The endpoint is already connected
- * ENOSPC - No port number available for assignment
- * EACCES - The port requested is protected and the user is not the superuser
- */
-int scif_bind(scif_epd_t epd, u16 pn);
-
-/**
- * scif_listen() - Listen for connections on an endpoint
- * @epd:       endpoint descriptor
- * @backlog:   maximum pending connection requests
- *
- * scif_listen() marks the endpoint epd as a listening endpoint - that is, as
- * an endpoint that will be used to accept incoming connection requests. Once
- * so marked, the endpoint is said to be in the listening state and may not be
- * used as the endpoint of a connection.
- *
- * The endpoint, epd, must have been bound to a port.
- *
- * The backlog argument defines the maximum length to which the queue of
- * pending connections for epd may grow. If a connection request arrives when
- * the queue is full, the client may receive an error with an indication that
- * the connection was refused.
- *
- * Return:
- * Upon successful completion, scif_listen() returns 0; otherwise in user mode
- * -1 is returned and errno is set to indicate the error; in kernel mode the
- * negative of one of the following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * EINVAL - the endpoint is not bound to a port
- * EISCONN - The endpoint is already connected or listening
- */
-int scif_listen(scif_epd_t epd, int backlog);
-
-/**
- * scif_connect() - Initiate a connection on a port
- * @epd:       endpoint descriptor
- * @dst:       global id of port to which to connect
- *
- * The scif_connect() function requests the connection of endpoint epd to remote
- * port dst. If the connection is successful, a peer endpoint, bound to dst, is
- * created on node dst.node. On successful return, the connection is complete.
- *
- * If the endpoint epd has not already been bound to a port, scif_connect()
- * will bind it to an unused local port.
- *
- * A connection is terminated when an endpoint of the connection is closed,
- * either explicitly by scif_close(), or when a process that owns one of the
- * endpoints of the connection is terminated.
- *
- * In user space, scif_connect() supports an asynchronous connection mode
- * if the application has set the O_NONBLOCK flag on the endpoint via the
- * fcntl() system call. Setting this flag will result in the calling process
- * not to wait during scif_connect().
- *
- * Return:
- * Upon successful completion, scif_connect() returns the port ID to which the
- * endpoint, epd, is bound; otherwise in user mode -1 is returned and errno is
- * set to indicate the error; in kernel mode the negative of one of the
- * following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNREFUSED - The destination was not listening for connections or refused
- * the connection request
- * EINVAL - dst.port is not a valid port ID
- * EISCONN - The endpoint is already connected
- * ENOMEM - No buffer space is available
- * ENODEV - The destination node does not exist, or the node is lost or existed,
- * but is not currently in the network since it may have crashed
- * ENOSPC - No port number available for assignment
- * EOPNOTSUPP - The endpoint is listening and cannot be connected
- */
-int scif_connect(scif_epd_t epd, struct scif_port_id *dst);
-
-/**
- * scif_accept() - Accept a connection on an endpoint
- * @epd:       endpoint descriptor
- * @peer:      global id of port to which connected
- * @newepd:    new connected endpoint descriptor
- * @flags:     flags
- *
- * The scif_accept() call extracts the first connection request from the queue
- * of pending connections for the port on which epd is listening. scif_accept()
- * creates a new endpoint, bound to the same port as epd, and allocates a new
- * SCIF endpoint descriptor, returned in newepd, for the endpoint. The new
- * endpoint is connected to the endpoint through which the connection was
- * requested. epd is unaffected by this call, and remains in the listening
- * state.
- *
- * On successful return, peer holds the global port identifier (node id and
- * local port number) of the port which requested the connection.
- *
- * A connection is terminated when an endpoint of the connection is closed,
- * either explicitly by scif_close(), or when a process that owns one of the
- * endpoints of the connection is terminated.
- *
- * The number of connections that can (subsequently) be accepted on epd is only
- * limited by system resources (memory).
- *
- * The flags argument is formed by OR'ing together zero or more of the
- * following values.
- * SCIF_ACCEPT_SYNC - block until a connection request is presented. If
- *                     SCIF_ACCEPT_SYNC is not in flags, and no pending
- *                     connections are present on the queue, scif_accept()
- *                     fails with an EAGAIN error
- *
- * In user mode, the select() and poll() functions can be used to determine
- * when there is a connection request. In kernel mode, the scif_poll()
- * function may be used for this purpose. A readable event will be delivered
- * when a connection is requested.
- *
- * Return:
- * Upon successful completion, scif_accept() returns 0; otherwise in user mode
- * -1 is returned and errno is set to indicate the error; in kernel mode the
- *     negative of one of the following errors is returned.
- *
- * Errors:
- * EAGAIN - SCIF_ACCEPT_SYNC is not set and no connections are present to be
- * accepted or SCIF_ACCEPT_SYNC is not set and remote node failed to complete
- * its connection request
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * EINTR - Interrupted function
- * EINVAL - epd is not a listening endpoint, or flags is invalid, or peer is
- * NULL, or newepd is NULL
- * ENODEV - The requesting node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOMEM - Not enough space
- * ENOENT - Secondary part of epd registration failed
- */
-int scif_accept(scif_epd_t epd, struct scif_port_id *peer, scif_epd_t
-               *newepd, int flags);
-
-/**
- * scif_close() - Close an endpoint
- * @epd:       endpoint descriptor
- *
- * scif_close() closes an endpoint and performs necessary teardown of
- * facilities associated with that endpoint.
- *
- * If epd is a listening endpoint then it will no longer accept connection
- * requests on the port to which it is bound. Any pending connection requests
- * are rejected.
- *
- * If epd is a connected endpoint, then its peer endpoint is also closed. RMAs
- * which are in-process through epd or its peer endpoint will complete before
- * scif_close() returns. Registered windows of the local and peer endpoints are
- * released as if scif_unregister() was called against each window.
- *
- * Closing a SCIF endpoint does not affect local registered memory mapped by
- * a SCIF endpoint on a remote node. The local memory remains mapped by the peer
- * SCIF endpoint explicitly removed by calling munmap(..) by the peer.
- *
- * If the peer endpoint's receive queue is not empty at the time that epd is
- * closed, then the peer endpoint can be passed as the endpoint parameter to
- * scif_recv() until the receive queue is empty.
- *
- * epd is freed and may no longer be accessed.
- *
- * Return:
- * Upon successful completion, scif_close() returns 0; otherwise in user mode
- * -1 is returned and errno is set to indicate the error; in kernel mode the
- * negative of one of the following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- */
-int scif_close(scif_epd_t epd);
-
-/**
- * scif_send() - Send a message
- * @epd:       endpoint descriptor
- * @msg:       message buffer address
- * @len:       message length
- * @flags:     blocking mode flags
- *
- * scif_send() sends data to the peer of endpoint epd. Up to len bytes of data
- * are copied from memory starting at address msg. On successful execution the
- * return value of scif_send() is the number of bytes that were sent, and is
- * zero if no bytes were sent because len was zero. scif_send() may be called
- * only when the endpoint is in a connected state.
- *
- * If a scif_send() call is non-blocking, then it sends only those bytes which
- * can be sent without waiting, up to a maximum of len bytes.
- *
- * If a scif_send() call is blocking, then it normally returns after sending
- * all len bytes. If a blocking call is interrupted or the connection is
- * reset, the call is considered successful if some bytes were sent or len is
- * zero, otherwise the call is considered unsuccessful.
- *
- * In user mode, the select() and poll() functions can be used to determine
- * when the send queue is not full. In kernel mode, the scif_poll() function
- * may be used for this purpose.
- *
- * It is recommended that scif_send()/scif_recv() only be used for short
- * control-type message communication between SCIF endpoints. The SCIF RMA
- * APIs are expected to provide better performance for transfer sizes of
- * 1024 bytes or longer for the current MIC hardware and software
- * implementation.
- *
- * scif_send() will block until the entire message is sent if SCIF_SEND_BLOCK
- * is passed as the flags argument.
- *
- * Return:
- * Upon successful completion, scif_send() returns the number of bytes sent;
- * otherwise in user mode -1 is returned and errno is set to indicate the
- * error; in kernel mode the negative of one of the following errors is
- * returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - flags is invalid, or len is negative
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOMEM - Not enough space
- * ENOTCONN - The endpoint is not connected
- */
-int scif_send(scif_epd_t epd, void *msg, int len, int flags);
-
-/**
- * scif_recv() - Receive a message
- * @epd:       endpoint descriptor
- * @msg:       message buffer address
- * @len:       message buffer length
- * @flags:     blocking mode flags
- *
- * scif_recv() receives data from the peer of endpoint epd. Up to len bytes of
- * data are copied to memory starting at address msg. On successful execution
- * the return value of scif_recv() is the number of bytes that were received,
- * and is zero if no bytes were received because len was zero. scif_recv() may
- * be called only when the endpoint is in a connected state.
- *
- * If a scif_recv() call is non-blocking, then it receives only those bytes
- * which can be received without waiting, up to a maximum of len bytes.
- *
- * If a scif_recv() call is blocking, then it normally returns after receiving
- * all len bytes. If the blocking call was interrupted due to a disconnection,
- * subsequent calls to scif_recv() will copy all bytes received upto the point
- * of disconnection.
- *
- * In user mode, the select() and poll() functions can be used to determine
- * when data is available to be received. In kernel mode, the scif_poll()
- * function may be used for this purpose.
- *
- * It is recommended that scif_send()/scif_recv() only be used for short
- * control-type message communication between SCIF endpoints. The SCIF RMA
- * APIs are expected to provide better performance for transfer sizes of
- * 1024 bytes or longer for the current MIC hardware and software
- * implementation.
- *
- * scif_recv() will block until the entire message is received if
- * SCIF_RECV_BLOCK is passed as the flags argument.
- *
- * Return:
- * Upon successful completion, scif_recv() returns the number of bytes
- * received; otherwise in user mode -1 is returned and errno is set to
- * indicate the error; in kernel mode the negative of one of the following
- * errors is returned.
- *
- * Errors:
- * EAGAIN - The destination node is returning from a low power state
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - flags is invalid, or len is negative
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOMEM - Not enough space
- * ENOTCONN - The endpoint is not connected
- */
-int scif_recv(scif_epd_t epd, void *msg, int len, int flags);
-
-/**
- * scif_register() - Mark a memory region for remote access.
- * @epd:               endpoint descriptor
- * @addr:              starting virtual address
- * @len:               length of range
- * @offset:            offset of window
- * @prot_flags:                read/write protection flags
- * @map_flags:         mapping flags
- *
- * The scif_register() function opens a window, a range of whole pages of the
- * registered address space of the endpoint epd, starting at offset po and
- * continuing for len bytes. The value of po, further described below, is a
- * function of the parameters offset and len, and the value of map_flags. Each
- * page of the window represents the physical memory page which backs the
- * corresponding page of the range of virtual address pages starting at addr
- * and continuing for len bytes. addr and len are constrained to be multiples
- * of the page size. A successful scif_register() call returns po.
- *
- * When SCIF_MAP_FIXED is set in the map_flags argument, po will be offset
- * exactly, and offset is constrained to be a multiple of the page size. The
- * mapping established by scif_register() will not replace any existing
- * registration; an error is returned if any page within the range [offset,
- * offset + len - 1] intersects an existing window.
- *
- * When SCIF_MAP_FIXED is not set, the implementation uses offset in an
- * implementation-defined manner to arrive at po. The po value so chosen will
- * be an area of the registered address space that the implementation deems
- * suitable for a mapping of len bytes. An offset value of 0 is interpreted as
- * granting the implementation complete freedom in selecting po, subject to
- * constraints described below. A non-zero value of offset is taken to be a
- * suggestion of an offset near which the mapping should be placed. When the
- * implementation selects a value for po, it does not replace any extant
- * window. In all cases, po will be a multiple of the page size.
- *
- * The physical pages which are so represented by a window are available for
- * access in calls to mmap(), scif_readfrom(), scif_writeto(),
- * scif_vreadfrom(), and scif_vwriteto(). While a window is registered, the
- * physical pages represented by the window will not be reused by the memory
- * subsystem for any other purpose. Note that the same physical page may be
- * represented by multiple windows.
- *
- * Subsequent operations which change the memory pages to which virtual
- * addresses are mapped (such as mmap(), munmap()) have no effect on
- * existing window.
- *
- * If the process will fork(), it is recommended that the registered
- * virtual address range be marked with MADV_DONTFORK. Doing so will prevent
- * problems due to copy-on-write semantics.
- *
- * The prot_flags argument is formed by OR'ing together one or more of the
- * following values.
- * SCIF_PROT_READ - allow read operations from the window
- * SCIF_PROT_WRITE - allow write operations to the window
- *
- * Return:
- * Upon successful completion, scif_register() returns the offset at which the
- * mapping was placed (po); otherwise in user mode SCIF_REGISTER_FAILED (that
- * is (off_t *)-1) is returned and errno is set to indicate the error; in
- * kernel mode the negative of one of the following errors is returned.
- *
- * Errors:
- * EADDRINUSE - SCIF_MAP_FIXED is set in map_flags, and pages in the range
- * [offset, offset + len -1] are already registered
- * EAGAIN - The mapping could not be performed due to lack of resources
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - map_flags is invalid, or prot_flags is invalid, or SCIF_MAP_FIXED is
- * set in flags, and offset is not a multiple of the page size, or addr is not a
- * multiple of the page size, or len is not a multiple of the page size, or is
- * 0, or offset is negative
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOMEM - Not enough space
- * ENOTCONN -The endpoint is not connected
- */
-off_t scif_register(scif_epd_t epd, void *addr, size_t len, off_t offset,
-                   int prot_flags, int map_flags);
-
-/**
- * scif_unregister() - Mark a memory region for remote access.
- * @epd:       endpoint descriptor
- * @offset:    start of range to unregister
- * @len:       length of range to unregister
- *
- * The scif_unregister() function closes those previously registered windows
- * which are entirely within the range [offset, offset + len - 1]. It is an
- * error to specify a range which intersects only a subrange of a window.
- *
- * On a successful return, pages within the window may no longer be specified
- * in calls to mmap(), scif_readfrom(), scif_writeto(), scif_vreadfrom(),
- * scif_vwriteto(), scif_get_pages, and scif_fence_signal(). The window,
- * however, continues to exist until all previous references against it are
- * removed. A window is referenced if there is a mapping to it created by
- * mmap(), or if scif_get_pages() was called against the window
- * (and the pages have not been returned via scif_put_pages()). A window is
- * also referenced while an RMA, in which some range of the window is a source
- * or destination, is in progress. Finally a window is referenced while some
- * offset in that window was specified to scif_fence_signal(), and the RMAs
- * marked by that call to scif_fence_signal() have not completed. While a
- * window is in this state, its registered address space pages are not
- * available for use in a new registered window.
- *
- * When all such references to the window have been removed, its references to
- * all the physical pages which it represents are removed. Similarly, the
- * registered address space pages of the window become available for
- * registration in a new window.
- *
- * Return:
- * Upon successful completion, scif_unregister() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned. In the event of an
- * error, no windows are unregistered.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - the range [offset, offset + len - 1] intersects a subrange of a
- * window, or offset is negative
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - Offsets in the range [offset, offset + len - 1] are invalid for the
- * registered address space of epd
- */
-int scif_unregister(scif_epd_t epd, off_t offset, size_t len);
-
-/**
- * scif_readfrom() - Copy from a remote address space
- * @epd:       endpoint descriptor
- * @loffset:   offset in local registered address space to
- *             which to copy
- * @len:       length of range to copy
- * @roffset:   offset in remote registered address space
- *             from which to copy
- * @rma_flags: transfer mode flags
- *
- * scif_readfrom() copies len bytes from the remote registered address space of
- * the peer of endpoint epd, starting at the offset roffset to the local
- * registered address space of epd, starting at the offset loffset.
- *
- * Each of the specified ranges [loffset, loffset + len - 1] and [roffset,
- * roffset + len - 1] must be within some registered window or windows of the
- * local and remote nodes. A range may intersect multiple registered windows,
- * but only if those windows are contiguous in the registered address space.
- *
- * If rma_flags includes SCIF_RMA_USECPU, then the data is copied using
- * programmed read/writes. Otherwise the data is copied using DMA. If rma_-
- * flags includes SCIF_RMA_SYNC, then scif_readfrom() will return after the
- * transfer is complete. Otherwise, the transfer may be performed asynchron-
- * ously. The order in which any two asynchronous RMA operations complete
- * is non-deterministic. The synchronization functions, scif_fence_mark()/
- * scif_fence_wait() and scif_fence_signal(), can be used to synchronize to
- * the completion of asynchronous RMA operations on the same endpoint.
- *
- * The DMA transfer of individual bytes is not guaranteed to complete in
- * address order. If rma_flags includes SCIF_RMA_ORDERED, then the last
- * cacheline or partial cacheline of the source range will become visible on
- * the destination node after all other transferred data in the source
- * range has become visible on the destination node.
- *
- * The optimal DMA performance will likely be realized if both
- * loffset and roffset are cacheline aligned (are a multiple of 64). Lower
- * performance will likely be realized if loffset and roffset are not
- * cacheline aligned but are separated by some multiple of 64. The lowest level
- * of performance is likely if loffset and roffset are not separated by a
- * multiple of 64.
- *
- * The rma_flags argument is formed by ORing together zero or more of the
- * following values.
- * SCIF_RMA_USECPU - perform the transfer using the CPU, otherwise use the DMA
- *     engine.
- * SCIF_RMA_SYNC - perform the transfer synchronously, returning after the
- *             transfer has completed. Passing this flag results in the
- *             current implementation busy waiting and consuming CPU cycles
- *             while the DMA transfer is in progress for best performance by
- *             avoiding the interrupt latency.
- * SCIF_RMA_ORDERED - ensure that the last cacheline or partial cacheline of
- *             the source range becomes visible on the destination node
- *             after all other transferred data in the source range has
- *             become visible on the destination
- *
- * Return:
- * Upon successful completion, scif_readfrom() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EACCES - Attempt to write to a read-only range
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - rma_flags is invalid
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - The range [loffset, loffset + len - 1] is invalid for the registered
- * address space of epd, or, The range [roffset, roffset + len - 1] is invalid
- * for the registered address space of the peer of epd, or loffset or roffset
- * is negative
- */
-int scif_readfrom(scif_epd_t epd, off_t loffset, size_t len, off_t
-                 roffset, int rma_flags);
-
-/**
- * scif_writeto() - Copy to a remote address space
- * @epd:       endpoint descriptor
- * @loffset:   offset in local registered address space
- *             from which to copy
- * @len:       length of range to copy
- * @roffset:   offset in remote registered address space to
- *             which to copy
- * @rma_flags: transfer mode flags
- *
- * scif_writeto() copies len bytes from the local registered address space of
- * epd, starting at the offset loffset to the remote registered address space
- * of the peer of endpoint epd, starting at the offset roffset.
- *
- * Each of the specified ranges [loffset, loffset + len - 1] and [roffset,
- * roffset + len - 1] must be within some registered window or windows of the
- * local and remote nodes. A range may intersect multiple registered windows,
- * but only if those windows are contiguous in the registered address space.
- *
- * If rma_flags includes SCIF_RMA_USECPU, then the data is copied using
- * programmed read/writes. Otherwise the data is copied using DMA. If rma_-
- * flags includes SCIF_RMA_SYNC, then scif_writeto() will return after the
- * transfer is complete. Otherwise, the transfer may be performed asynchron-
- * ously. The order in which any two asynchronous RMA operations complete
- * is non-deterministic. The synchronization functions, scif_fence_mark()/
- * scif_fence_wait() and scif_fence_signal(), can be used to synchronize to
- * the completion of asynchronous RMA operations on the same endpoint.
- *
- * The DMA transfer of individual bytes is not guaranteed to complete in
- * address order. If rma_flags includes SCIF_RMA_ORDERED, then the last
- * cacheline or partial cacheline of the source range will become visible on
- * the destination node after all other transferred data in the source
- * range has become visible on the destination node.
- *
- * The optimal DMA performance will likely be realized if both
- * loffset and roffset are cacheline aligned (are a multiple of 64). Lower
- * performance will likely be realized if loffset and roffset are not cacheline
- * aligned but are separated by some multiple of 64. The lowest level of
- * performance is likely if loffset and roffset are not separated by a multiple
- * of 64.
- *
- * The rma_flags argument is formed by ORing together zero or more of the
- * following values.
- * SCIF_RMA_USECPU - perform the transfer using the CPU, otherwise use the DMA
- *                     engine.
- * SCIF_RMA_SYNC - perform the transfer synchronously, returning after the
- *             transfer has completed. Passing this flag results in the
- *             current implementation busy waiting and consuming CPU cycles
- *             while the DMA transfer is in progress for best performance by
- *             avoiding the interrupt latency.
- * SCIF_RMA_ORDERED - ensure that the last cacheline or partial cacheline of
- *             the source range becomes visible on the destination node
- *             after all other transferred data in the source range has
- *             become visible on the destination
- *
- * Return:
- * Upon successful completion, scif_readfrom() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EACCES - Attempt to write to a read-only range
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - rma_flags is invalid
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - The range [loffset, loffset + len - 1] is invalid for the registered
- * address space of epd, or, The range [roffset , roffset + len -1] is invalid
- * for the registered address space of the peer of epd, or loffset or roffset
- * is negative
- */
-int scif_writeto(scif_epd_t epd, off_t loffset, size_t len, off_t
-                roffset, int rma_flags);
-
-/**
- * scif_vreadfrom() - Copy from a remote address space
- * @epd:       endpoint descriptor
- * @addr:      address to which to copy
- * @len:       length of range to copy
- * @roffset:   offset in remote registered address space
- *             from which to copy
- * @rma_flags: transfer mode flags
- *
- * scif_vreadfrom() copies len bytes from the remote registered address
- * space of the peer of endpoint epd, starting at the offset roffset, to local
- * memory, starting at addr.
- *
- * The specified range [roffset, roffset + len - 1] must be within some
- * registered window or windows of the remote nodes. The range may
- * intersect multiple registered windows, but only if those windows are
- * contiguous in the registered address space.
- *
- * If rma_flags includes SCIF_RMA_USECPU, then the data is copied using
- * programmed read/writes. Otherwise the data is copied using DMA. If rma_-
- * flags includes SCIF_RMA_SYNC, then scif_vreadfrom() will return after the
- * transfer is complete. Otherwise, the transfer may be performed asynchron-
- * ously. The order in which any two asynchronous RMA operations complete
- * is non-deterministic. The synchronization functions, scif_fence_mark()/
- * scif_fence_wait() and scif_fence_signal(), can be used to synchronize to
- * the completion of asynchronous RMA operations on the same endpoint.
- *
- * The DMA transfer of individual bytes is not guaranteed to complete in
- * address order. If rma_flags includes SCIF_RMA_ORDERED, then the last
- * cacheline or partial cacheline of the source range will become visible on
- * the destination node after all other transferred data in the source
- * range has become visible on the destination node.
- *
- * If rma_flags includes SCIF_RMA_USECACHE, then the physical pages which back
- * the specified local memory range may be remain in a pinned state even after
- * the specified transfer completes. This may reduce overhead if some or all of
- * the same virtual address range is referenced in a subsequent call of
- * scif_vreadfrom() or scif_vwriteto().
- *
- * The optimal DMA performance will likely be realized if both
- * addr and roffset are cacheline aligned (are a multiple of 64). Lower
- * performance will likely be realized if addr and roffset are not
- * cacheline aligned but are separated by some multiple of 64. The lowest level
- * of performance is likely if addr and roffset are not separated by a
- * multiple of 64.
- *
- * The rma_flags argument is formed by ORing together zero or more of the
- * following values.
- * SCIF_RMA_USECPU - perform the transfer using the CPU, otherwise use the DMA
- *     engine.
- * SCIF_RMA_USECACHE - enable registration caching
- * SCIF_RMA_SYNC - perform the transfer synchronously, returning after the
- *             transfer has completed. Passing this flag results in the
- *             current implementation busy waiting and consuming CPU cycles
- *             while the DMA transfer is in progress for best performance by
- *             avoiding the interrupt latency.
- * SCIF_RMA_ORDERED - ensure that the last cacheline or partial cacheline of
- *     the source range becomes visible on the destination node
- *     after all other transferred data in the source range has
- *     become visible on the destination
- *
- * Return:
- * Upon successful completion, scif_vreadfrom() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EACCES - Attempt to write to a read-only range
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - rma_flags is invalid
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - Offsets in the range [roffset, roffset + len - 1] are invalid for the
- * registered address space of epd
- */
-int scif_vreadfrom(scif_epd_t epd, void *addr, size_t len, off_t roffset,
-                  int rma_flags);
-
-/**
- * scif_vwriteto() - Copy to a remote address space
- * @epd:       endpoint descriptor
- * @addr:      address from which to copy
- * @len:       length of range to copy
- * @roffset:   offset in remote registered address space to
- *             which to copy
- * @rma_flags: transfer mode flags
- *
- * scif_vwriteto() copies len bytes from the local memory, starting at addr, to
- * the remote registered address space of the peer of endpoint epd, starting at
- * the offset roffset.
- *
- * The specified range [roffset, roffset + len - 1] must be within some
- * registered window or windows of the remote nodes. The range may intersect
- * multiple registered windows, but only if those windows are contiguous in the
- * registered address space.
- *
- * If rma_flags includes SCIF_RMA_USECPU, then the data is copied using
- * programmed read/writes. Otherwise the data is copied using DMA. If rma_-
- * flags includes SCIF_RMA_SYNC, then scif_vwriteto() will return after the
- * transfer is complete. Otherwise, the transfer may be performed asynchron-
- * ously. The order in which any two asynchronous RMA operations complete
- * is non-deterministic. The synchronization functions, scif_fence_mark()/
- * scif_fence_wait() and scif_fence_signal(), can be used to synchronize to
- * the completion of asynchronous RMA operations on the same endpoint.
- *
- * The DMA transfer of individual bytes is not guaranteed to complete in
- * address order. If rma_flags includes SCIF_RMA_ORDERED, then the last
- * cacheline or partial cacheline of the source range will become visible on
- * the destination node after all other transferred data in the source
- * range has become visible on the destination node.
- *
- * If rma_flags includes SCIF_RMA_USECACHE, then the physical pages which back
- * the specified local memory range may be remain in a pinned state even after
- * the specified transfer completes. This may reduce overhead if some or all of
- * the same virtual address range is referenced in a subsequent call of
- * scif_vreadfrom() or scif_vwriteto().
- *
- * The optimal DMA performance will likely be realized if both
- * addr and offset are cacheline aligned (are a multiple of 64). Lower
- * performance will likely be realized if addr and offset are not cacheline
- * aligned but are separated by some multiple of 64. The lowest level of
- * performance is likely if addr and offset are not separated by a multiple of
- * 64.
- *
- * The rma_flags argument is formed by ORing together zero or more of the
- * following values.
- * SCIF_RMA_USECPU - perform the transfer using the CPU, otherwise use the DMA
- *     engine.
- * SCIF_RMA_USECACHE - allow registration caching
- * SCIF_RMA_SYNC - perform the transfer synchronously, returning after the
- *             transfer has completed. Passing this flag results in the
- *             current implementation busy waiting and consuming CPU cycles
- *             while the DMA transfer is in progress for best performance by
- *             avoiding the interrupt latency.
- * SCIF_RMA_ORDERED - ensure that the last cacheline or partial cacheline of
- *             the source range becomes visible on the destination node
- *             after all other transferred data in the source range has
- *             become visible on the destination
- *
- * Return:
- * Upon successful completion, scif_vwriteto() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EACCES - Attempt to write to a read-only range
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - rma_flags is invalid
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - Offsets in the range [roffset, roffset + len - 1] are invalid for the
- * registered address space of epd
- */
-int scif_vwriteto(scif_epd_t epd, void *addr, size_t len, off_t roffset,
-                 int rma_flags);
-
-/**
- * scif_fence_mark() - Mark previously issued RMAs
- * @epd:       endpoint descriptor
- * @flags:     control flags
- * @mark:      marked value returned as output.
- *
- * scif_fence_mark() returns after marking the current set of all uncompleted
- * RMAs initiated through the endpoint epd or the current set of all
- * uncompleted RMAs initiated through the peer of endpoint epd. The RMAs are
- * marked with a value returned at mark. The application may subsequently call
- * scif_fence_wait(), passing the value returned at mark, to await completion
- * of all RMAs so marked.
- *
- * The flags argument has exactly one of the following values.
- * SCIF_FENCE_INIT_SELF - RMA operations initiated through endpoint
- *     epd are marked
- * SCIF_FENCE_INIT_PEER - RMA operations initiated through the peer
- *     of endpoint epd are marked
- *
- * Return:
- * Upon successful completion, scif_fence_mark() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - flags is invalid
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENOMEM - Insufficient kernel memory was available
- */
-int scif_fence_mark(scif_epd_t epd, int flags, int *mark);
-
-/**
- * scif_fence_wait() - Wait for completion of marked RMAs
- * @epd:       endpoint descriptor
- * @mark:      mark request
- *
- * scif_fence_wait() returns after all RMAs marked with mark have completed.
- * The value passed in mark must have been obtained in a previous call to
- * scif_fence_mark().
- *
- * Return:
- * Upon successful completion, scif_fence_wait() returns 0; otherwise in user
- * mode -1 is returned and errno is set to indicate the error; in kernel mode
- * the negative of one of the following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENOMEM - Insufficient kernel memory was available
- */
-int scif_fence_wait(scif_epd_t epd, int mark);
-
-/**
- * scif_fence_signal() - Request a memory update on completion of RMAs
- * @epd:       endpoint descriptor
- * @loff:      local offset
- * @lval:      local value to write to loffset
- * @roff:      remote offset
- * @rval:      remote value to write to roffset
- * @flags:     flags
- *
- * scif_fence_signal() returns after marking the current set of all uncompleted
- * RMAs initiated through the endpoint epd or marking the current set of all
- * uncompleted RMAs initiated through the peer of endpoint epd.
- *
- * If flags includes SCIF_SIGNAL_LOCAL, then on completion of the RMAs in the
- * marked set, lval is written to memory at the address corresponding to offset
- * loff in the local registered address space of epd. loff must be within a
- * registered window. If flags includes SCIF_SIGNAL_REMOTE, then on completion
- * of the RMAs in the marked set, rval is written to memory at the address
- * corresponding to offset roff in the remote registered address space of epd.
- * roff must be within a remote registered window of the peer of epd. Note
- * that any specified offset must be DWORD (4 byte / 32 bit) aligned.
- *
- * The flags argument is formed by OR'ing together the following.
- * Exactly one of the following values.
- * SCIF_FENCE_INIT_SELF - RMA operations initiated through endpoint
- *     epd are marked
- * SCIF_FENCE_INIT_PEER - RMA operations initiated through the peer
- *     of endpoint epd are marked
- * One or more of the following values.
- * SCIF_SIGNAL_LOCAL - On completion of the marked set of RMAs, write lval to
- *     memory at the address corresponding to offset loff in the local
- *     registered address space of epd.
- * SCIF_SIGNAL_REMOTE - On completion of the marked set of RMAs, write rval to
- *     memory at the address corresponding to offset roff in the remote
- *     registered address space of epd.
- *
- * Return:
- * Upon successful completion, scif_fence_signal() returns 0; otherwise in
- * user mode -1 is returned and errno is set to indicate the error; in kernel
- * mode the negative of one of the following errors is returned.
- *
- * Errors:
- * EBADF, ENOTTY - epd is not a valid endpoint descriptor
- * ECONNRESET - Connection reset by peer
- * EINVAL - flags is invalid, or loff or roff are not DWORD aligned
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - loff is invalid for the registered address of epd, or roff is invalid
- * for the registered address space, of the peer of epd
- */
-int scif_fence_signal(scif_epd_t epd, off_t loff, u64 lval, off_t roff,
-                     u64 rval, int flags);
-
-/**
- * scif_get_node_ids() - Return information about online nodes
- * @nodes:     array in which to return online node IDs
- * @len:       number of entries in the nodes array
- * @self:      address to place the node ID of the local node
- *
- * scif_get_node_ids() fills in the nodes array with up to len node IDs of the
- * nodes in the SCIF network. If there is not enough space in nodes, as
- * indicated by the len parameter, only len node IDs are returned in nodes. The
- * return value of scif_get_node_ids() is the total number of nodes currently in
- * the SCIF network. By checking the return value against the len parameter,
- * the user may determine if enough space for nodes was allocated.
- *
- * The node ID of the local node is returned at self.
- *
- * Return:
- * Upon successful completion, scif_get_node_ids() returns the actual number of
- * online nodes in the SCIF network including 'self'; otherwise in user mode
- * -1 is returned and errno is set to indicate the error; in kernel mode no
- * errors are returned.
- */
-int scif_get_node_ids(u16 *nodes, int len, u16 *self);
-
-/**
- * scif_pin_pages() - Pin a set of pages
- * @addr:              Virtual address of range to pin
- * @len:               Length of range to pin
- * @prot_flags:                Page protection flags
- * @map_flags:         Page classification flags
- * @pinned_pages:      Handle to pinned pages
- *
- * scif_pin_pages() pins (locks in physical memory) the physical pages which
- * back the range of virtual address pages starting at addr and continuing for
- * len bytes. addr and len are constrained to be multiples of the page size. A
- * successful scif_pin_pages() call returns a handle to pinned_pages which may
- * be used in subsequent calls to scif_register_pinned_pages().
- *
- * The pages will remain pinned as long as there is a reference against the
- * scif_pinned_pages_t value returned by scif_pin_pages() and until
- * scif_unpin_pages() is called, passing the scif_pinned_pages_t value. A
- * reference is added to a scif_pinned_pages_t value each time a window is
- * created by calling scif_register_pinned_pages() and passing the
- * scif_pinned_pages_t value. A reference is removed from a
- * scif_pinned_pages_t value each time such a window is deleted.
- *
- * Subsequent operations which change the memory pages to which virtual
- * addresses are mapped (such as mmap(), munmap()) have no effect on the
- * scif_pinned_pages_t value or windows created against it.
- *
- * If the process will fork(), it is recommended that the registered
- * virtual address range be marked with MADV_DONTFORK. Doing so will prevent
- * problems due to copy-on-write semantics.
- *
- * The prot_flags argument is formed by OR'ing together one or more of the
- * following values.
- * SCIF_PROT_READ - allow read operations against the pages
- * SCIF_PROT_WRITE - allow write operations against the pages
- * The map_flags argument can be set as SCIF_MAP_KERNEL to interpret addr as a
- * kernel space address. By default, addr is interpreted as a user space
- * address.
- *
- * Return:
- * Upon successful completion, scif_pin_pages() returns 0; otherwise the
- * negative of one of the following errors is returned.
- *
- * Errors:
- * EINVAL - prot_flags is invalid, map_flags is invalid, or offset is negative
- * ENOMEM - Not enough space
- */
-int scif_pin_pages(void *addr, size_t len, int prot_flags, int map_flags,
-                  scif_pinned_pages_t *pinned_pages);
-
-/**
- * scif_unpin_pages() - Unpin a set of pages
- * @pinned_pages:      Handle to pinned pages to be unpinned
- *
- * scif_unpin_pages() prevents scif_register_pinned_pages() from registering new
- * windows against pinned_pages. The physical pages represented by pinned_pages
- * will remain pinned until all windows previously registered against
- * pinned_pages are deleted (the window is scif_unregister()'d and all
- * references to the window are removed (see scif_unregister()).
- *
- * pinned_pages must have been obtain from a previous call to scif_pin_pages().
- * After calling scif_unpin_pages(), it is an error to pass pinned_pages to
- * scif_register_pinned_pages().
- *
- * Return:
- * Upon successful completion, scif_unpin_pages() returns 0; otherwise the
- * negative of one of the following errors is returned.
- *
- * Errors:
- * EINVAL - pinned_pages is not valid
- */
-int scif_unpin_pages(scif_pinned_pages_t pinned_pages);
-
-/**
- * scif_register_pinned_pages() - Mark a memory region for remote access.
- * @epd:               endpoint descriptor
- * @pinned_pages:      Handle to pinned pages
- * @offset:            Registered address space offset
- * @map_flags:         Flags which control where pages are mapped
- *
- * The scif_register_pinned_pages() function opens a window, a range of whole
- * pages of the registered address space of the endpoint epd, starting at
- * offset po. The value of po, further described below, is a function of the
- * parameters offset and pinned_pages, and the value of map_flags. Each page of
- * the window represents a corresponding physical memory page of the range
- * represented by pinned_pages; the length of the window is the same as the
- * length of range represented by pinned_pages. A successful
- * scif_register_pinned_pages() call returns po as the return value.
- *
- * When SCIF_MAP_FIXED is set in the map_flags argument, po will be offset
- * exactly, and offset is constrained to be a multiple of the page size. The
- * mapping established by scif_register_pinned_pages() will not replace any
- * existing registration; an error is returned if any page of the new window
- * would intersect an existing window.
- *
- * When SCIF_MAP_FIXED is not set, the implementation uses offset in an
- * implementation-defined manner to arrive at po. The po so chosen will be an
- * area of the registered address space that the implementation deems suitable
- * for a mapping of the required size. An offset value of 0 is interpreted as
- * granting the implementation complete freedom in selecting po, subject to
- * constraints described below. A non-zero value of offset is taken to be a
- * suggestion of an offset near which the mapping should be placed. When the
- * implementation selects a value for po, it does not replace any extant
- * window. In all cases, po will be a multiple of the page size.
- *
- * The physical pages which are so represented by a window are available for
- * access in calls to scif_get_pages(), scif_readfrom(), scif_writeto(),
- * scif_vreadfrom(), and scif_vwriteto(). While a window is registered, the
- * physical pages represented by the window will not be reused by the memory
- * subsystem for any other purpose. Note that the same physical page may be
- * represented by multiple windows.
- *
- * Windows created by scif_register_pinned_pages() are unregistered by
- * scif_unregister().
- *
- * The map_flags argument can be set to SCIF_MAP_FIXED which interprets a
- * fixed offset.
- *
- * Return:
- * Upon successful completion, scif_register_pinned_pages() returns the offset
- * at which the mapping was placed (po); otherwise the negative of one of the
- * following errors is returned.
- *
- * Errors:
- * EADDRINUSE - SCIF_MAP_FIXED is set in map_flags and pages in the new window
- * would intersect an existing window
- * EAGAIN - The mapping could not be performed due to lack of resources
- * ECONNRESET - Connection reset by peer
- * EINVAL - map_flags is invalid, or SCIF_MAP_FIXED is set in map_flags, and
- * offset is not a multiple of the page size, or offset is negative
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOMEM - Not enough space
- * ENOTCONN - The endpoint is not connected
- */
-off_t scif_register_pinned_pages(scif_epd_t epd,
-                                scif_pinned_pages_t pinned_pages,
-                                off_t offset, int map_flags);
-
-/**
- * scif_get_pages() - Add references to remote registered pages
- * @epd:       endpoint descriptor
- * @offset:    remote registered offset
- * @len:       length of range of pages
- * @pages:     returned scif_range structure
- *
- * scif_get_pages() returns the addresses of the physical pages represented by
- * those pages of the registered address space of the peer of epd, starting at
- * offset and continuing for len bytes. offset and len are constrained to be
- * multiples of the page size.
- *
- * All of the pages in the specified range [offset, offset + len - 1] must be
- * within a single window of the registered address space of the peer of epd.
- *
- * The addresses are returned as a virtually contiguous array pointed to by the
- * phys_addr component of the scif_range structure whose address is returned in
- * pages. The nr_pages component of scif_range is the length of the array. The
- * prot_flags component of scif_range holds the protection flag value passed
- * when the pages were registered.
- *
- * Each physical page whose address is returned by scif_get_pages() remains
- * available and will not be released for reuse until the scif_range structure
- * is returned in a call to scif_put_pages(). The scif_range structure returned
- * by scif_get_pages() must be unmodified.
- *
- * It is an error to call scif_close() on an endpoint on which a scif_range
- * structure of that endpoint has not been returned to scif_put_pages().
- *
- * Return:
- * Upon successful completion, scif_get_pages() returns 0; otherwise the
- * negative of one of the following errors is returned.
- * Errors:
- * ECONNRESET - Connection reset by peer.
- * EINVAL - offset is not a multiple of the page size, or offset is negative, or
- * len is not a multiple of the page size
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- * ENXIO - Offsets in the range [offset, offset + len - 1] are invalid
- * for the registered address space of the peer epd
- */
-int scif_get_pages(scif_epd_t epd, off_t offset, size_t len,
-                  struct scif_range **pages);
-
-/**
- * scif_put_pages() - Remove references from remote registered pages
- * @pages:     pages to be returned
- *
- * scif_put_pages() releases a scif_range structure previously obtained by
- * calling scif_get_pages(). The physical pages represented by pages may
- * be reused when the window which represented those pages is unregistered.
- * Therefore, those pages must not be accessed after calling scif_put_pages().
- *
- * Return:
- * Upon successful completion, scif_put_pages() returns 0; otherwise the
- * negative of one of the following errors is returned.
- * Errors:
- * EINVAL - pages does not point to a valid scif_range structure, or
- * the scif_range structure pointed to by pages was already returned
- * ENODEV - The remote node is lost or existed, but is not currently in the
- * network since it may have crashed
- * ENOTCONN - The endpoint is not connected
- */
-int scif_put_pages(struct scif_range *pages);
-
-/**
- * scif_poll() - Wait for some event on an endpoint
- * @epds:      Array of endpoint descriptors
- * @nepds:     Length of epds
- * @timeout:   Upper limit on time for which scif_poll() will block
- *
- * scif_poll() waits for one of a set of endpoints to become ready to perform
- * an I/O operation.
- *
- * The epds argument specifies the endpoint descriptors to be examined and the
- * events of interest for each endpoint descriptor. epds is a pointer to an
- * array with one member for each open endpoint descriptor of interest.
- *
- * The number of items in the epds array is specified in nepds. The epd field
- * of scif_pollepd is an endpoint descriptor of an open endpoint. The field
- * events is a bitmask specifying the events which the application is
- * interested in. The field revents is an output parameter, filled by the
- * kernel with the events that actually occurred. The bits returned in revents
- * can include any of those specified in events, or one of the values EPOLLERR,
- * EPOLLHUP, or EPOLLNVAL. (These three bits are meaningless in the events
- * field, and will be set in the revents field whenever the corresponding
- * condition is true.)
- *
- * If none of the events requested (and no error) has occurred for any of the
- * endpoint descriptors, then scif_poll() blocks until one of the events occurs.
- *
- * The timeout argument specifies an upper limit on the time for which
- * scif_poll() will block, in milliseconds. Specifying a negative value in
- * timeout means an infinite timeout.
- *
- * The following bits may be set in events and returned in revents.
- * EPOLLIN - Data may be received without blocking. For a connected
- * endpoint, this means that scif_recv() may be called without blocking. For a
- * listening endpoint, this means that scif_accept() may be called without
- * blocking.
- * EPOLLOUT - Data may be sent without blocking. For a connected endpoint, this
- * means that scif_send() may be called without blocking. EPOLLOUT may also be
- * used to block waiting for a non-blocking connect to complete. This bit value
- * has no meaning for a listening endpoint and is ignored if specified.
- *
- * The following bits are only returned in revents, and are ignored if set in
- * events.
- * EPOLLERR - An error occurred on the endpoint
- * EPOLLHUP - The connection to the peer endpoint was disconnected
- * EPOLLNVAL - The specified endpoint descriptor is invalid.
- *
- * Return:
- * Upon successful completion, scif_poll() returns a non-negative value. A
- * positive value indicates the total number of endpoint descriptors that have
- * been selected (that is, endpoint descriptors for which the revents member is
- * non-zero). A value of 0 indicates that the call timed out and no endpoint
- * descriptors have been selected. Otherwise in user mode -1 is returned and
- * errno is set to indicate the error; in kernel mode the negative of one of
- * the following errors is returned.
- *
- * Errors:
- * EINTR - A signal occurred before any requested event
- * EINVAL - The nepds argument is greater than {OPEN_MAX}
- * ENOMEM - There was no space to allocate file descriptor tables
- */
-int scif_poll(struct scif_pollepd *epds, unsigned int nepds, long timeout);
-
-/**
- * scif_client_register() - Register a SCIF client
- * @client:    client to be registered
- *
- * scif_client_register() registers a SCIF client. The probe() method
- * of the client is called when SCIF peer devices come online and the
- * remove() method is called when the peer devices disappear.
- *
- * Return:
- * Upon successful completion, scif_client_register() returns a non-negative
- * value. Otherwise the return value is the same as subsys_interface_register()
- * in the kernel.
- */
-int scif_client_register(struct scif_client *client);
-
-/**
- * scif_client_unregister() - Unregister a SCIF client
- * @client:    client to be unregistered
- *
- * scif_client_unregister() unregisters a SCIF client.
- *
- * Return:
- * None
- */
-void scif_client_unregister(struct scif_client *client);
-
-#endif /* __SCIF_H__ */
index 6dec390cf154b7b30f9799a3d1f620e18927eb94..18122d9e17ff5c35f22d97fc4c093942837c5632 100644 (file)
 
 #ifdef CONFIG_SHADOW_CALL_STACK
 
-/*
- * In testing, 1 KiB shadow stack size (i.e. 128 stack frames on a 64-bit
- * architecture) provided ~40% safety margin on stack usage while keeping
- * memory allocation overhead reasonable.
- */
-#define SCS_SIZE               SZ_1K
+#define SCS_ORDER              0
+#define SCS_SIZE               (PAGE_SIZE << SCS_ORDER)
 #define GFP_SCS                        (GFP_KERNEL | __GFP_ZERO)
 
 /* An illegal pointer value to mark the end of the shadow stack. */
 #define SCS_END_MAGIC          (0x5f6UL + POISON_POINTER_DELTA)
 
-/* Allocate a static per-CPU shadow stack */
-#define DEFINE_SCS(name)                                               \
-       DEFINE_PER_CPU(unsigned long [SCS_SIZE/sizeof(long)], name)     \
-
 #define task_scs(tsk)          (task_thread_info(tsk)->scs_base)
 #define task_scs_sp(tsk)       (task_thread_info(tsk)->scs_sp)
 
+void *scs_alloc(int node);
+void scs_free(void *s);
 void scs_init(void);
 int scs_prepare(struct task_struct *tsk, int node);
 void scs_release(struct task_struct *tsk);
@@ -61,6 +55,8 @@ static inline bool task_scs_end_corrupted(struct task_struct *tsk)
 
 #else /* CONFIG_SHADOW_CALL_STACK */
 
+static inline void *scs_alloc(int node) { return NULL; }
+static inline void scs_free(void *s) {}
 static inline void scs_init(void) {}
 static inline void scs_task_reset(struct task_struct *tsk) {}
 static inline int scs_prepare(struct task_struct *tsk, int node) { return 0; }
index 813614d4b71fbcfdcf84ac21b8709949d51e5a3e..b83b3ae3c877f3b4d6e7989681db89ab645e586c 100644 (file)
@@ -107,6 +107,7 @@ void seq_pad(struct seq_file *m, char c);
 char *mangle_path(char *s, const char *p, const char *esc);
 int seq_open(struct file *, const struct seq_operations *);
 ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
+ssize_t seq_read_iter(struct kiocb *iocb, struct iov_iter *iter);
 loff_t seq_lseek(struct file *, loff_t, int);
 int seq_release(struct inode *, struct file *);
 int seq_write(struct seq_file *seq, const void *data, size_t len);
index 7bbc0e9cf084728ba6b28fbfb3ed736ee4a6e576..205526c4003aa10dba00560af3820b748928afe2 100644 (file)
@@ -238,6 +238,7 @@ static inline void siginitset(sigset_t *set, unsigned long mask)
                memset(&set->sig[1], 0, sizeof(long)*(_NSIG_WORDS-1));
                break;
        case 2: set->sig[1] = 0;
+               break;
        case 1: ;
        }
 }
@@ -250,6 +251,7 @@ static inline void siginitsetinv(sigset_t *set, unsigned long mask)
                memset(&set->sig[1], -1, sizeof(long)*(_NSIG_WORDS-1));
                break;
        case 2: set->sig[1] = -1;
+               break;
        case 1: ;
        }
 }
@@ -467,4 +469,18 @@ struct seq_file;
 extern void render_sigset_t(struct seq_file *, const char *, sigset_t *);
 #endif
 
+#ifndef arch_untagged_si_addr
+/*
+ * Given a fault address and a signal and si_code which correspond to the
+ * _sigfault union member, returns the address that must appear in si_addr if
+ * the signal handler does not have SA_EXPOSE_TAGBITS enabled in sa_flags.
+ */
+static inline void __user *arch_untagged_si_addr(void __user *addr,
+                                                unsigned long sig,
+                                                unsigned long si_code)
+{
+       return addr;
+}
+#endif
+
 #endif /* _LINUX_SIGNAL_H */
index f8a90ae9c6ec45ea65166bfb56fa2e96c20d9bef..68e06c75c5b22ac9d8d5e5c5c45792b60f5d4958 100644 (file)
@@ -68,4 +68,16 @@ struct ksignal {
        int sig;
 };
 
+#ifndef __ARCH_UAPI_SA_FLAGS
+#ifdef SA_RESTORER
+#define __ARCH_UAPI_SA_FLAGS   SA_RESTORER
+#else
+#define __ARCH_UAPI_SA_FLAGS   0
+#endif
+#endif
+
+#define UAPI_SA_FLAGS                                                          \
+       (SA_NOCLDSTOP | SA_NOCLDWAIT | SA_SIGINFO | SA_ONSTACK | SA_RESTART |  \
+        SA_NODEFER | SA_RESETHAND | SA_EXPOSE_TAGBITS | __ARCH_UAPI_SA_FLAGS)
+
 #endif /* _LINUX_SIGNAL_TYPES_H */
index c9dcb3e5781f8bac8169c783c3f42ab0e6d418fe..5117cb5b56561878d10126cd2fbef4b65b46574b 100644 (file)
@@ -124,6 +124,10 @@ static inline bool timespec64_valid_settod(const struct timespec64 *ts)
  */
 static inline s64 timespec64_to_ns(const struct timespec64 *ts)
 {
+       /* Prevent multiplication overflow */
+       if ((unsigned long long)ts->tv_sec >= KTIME_SEC_MAX)
+               return KTIME_MAX;
+
        return ((s64) ts->tv_sec * NSEC_PER_SEC) + ts->tv_nsec;
 }
 
index 2040696d75b6e03b6bf7802149068093dc51afe8..a2d229ab63ba58d548c822b6e3956a023e54320b 100644 (file)
@@ -437,7 +437,7 @@ static inline struct usb_composite_driver *to_cdriver(
 #define OS_STRING_IDX                  0xEE
 
 /**
- * struct usb_composite_device - represents one composite usb gadget
+ * struct usb_composite_dev - represents one composite usb gadget
  * @gadget: read-only, abstracts the gadget's usb peripheral controller
  * @req: used for control responses; buffer is pre-allocated
  * @os_desc_req: used for OS descriptors responses; buffer is pre-allocated
index eae0bfd87d911cb956b935b5e65253f5c41a99c3..30bc7a7223bb7476b75f67e8ba07e5d80df2dec1 100644 (file)
@@ -52,6 +52,16 @@ struct vdpa_device {
        int nvqs;
 };
 
+/**
+ * vDPA IOVA range - the IOVA range support by the device
+ * @first: start of the IOVA range
+ * @last: end of the IOVA range
+ */
+struct vdpa_iova_range {
+       u64 first;
+       u64 last;
+};
+
 /**
  * vDPA_config_ops - operations for configuring a vDPA device.
  * Note: vDPA device drivers are required to implement all of the
@@ -151,6 +161,10 @@ struct vdpa_device {
  * @get_generation:            Get device config generation (optional)
  *                             @vdev: vdpa device
  *                             Returns u32: device generation
+ * @get_iova_range:            Get supported iova range (optional)
+ *                             @vdev: vdpa device
+ *                             Returns the iova range supported by
+ *                             the device.
  * @set_map:                   Set device memory mapping (optional)
  *                             Needed for device that using device
  *                             specific DMA translation (on-chip IOMMU)
@@ -216,6 +230,7 @@ struct vdpa_config_ops {
        void (*set_config)(struct vdpa_device *vdev, unsigned int offset,
                           const void *buf, unsigned int len);
        u32 (*get_generation)(struct vdpa_device *vdev);
+       struct vdpa_iova_range (*get_iova_range)(struct vdpa_device *vdev);
 
        /* DMA ops */
        int (*set_map)(struct vdpa_device *vdev, struct vhost_iotlb *iotlb);
index 661edfc8722e1cf205cceb836a851de40210e1a8..d5ab8d99739f1e3c2acf90f86fd6966d2df4c96d 100644 (file)
@@ -1444,7 +1444,7 @@ int cfg80211_check_station_change(struct wiphy *wiphy,
                                  enum cfg80211_station_type statype);
 
 /**
- * enum station_info_rate_flags - bitrate info flags
+ * enum rate_info_flags - bitrate info flags
  *
  * Used by the driver to indicate the specific rate transmission
  * type for 802.11n transmissions.
@@ -1517,7 +1517,7 @@ struct rate_info {
 };
 
 /**
- * enum station_info_rate_flags - bitrate info flags
+ * enum bss_param_flags - bitrate info flags
  *
  * Used by the driver to indicate the specific rate transmission
  * type for 802.11n transmissions.
@@ -6467,7 +6467,8 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
                          struct ieee80211_channel *channel, gfp_t gfp);
 
 /**
- * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
+ * cfg80211_notify_new_peer_candidate - notify cfg80211 of a new mesh peer
+ *                                     candidate
  *
  * @dev: network device
  * @macaddr: the MAC address of the new candidate
@@ -7606,7 +7607,7 @@ u32 cfg80211_calculate_bitrate(struct rate_info *rate);
 void cfg80211_unregister_wdev(struct wireless_dev *wdev);
 
 /**
- * struct cfg80211_ft_event - FT Information Elements
+ * struct cfg80211_ft_event_params - FT Information Elements
  * @ies: FT IEs
  * @ies_len: length of the FT IE in bytes
  * @target_ap: target AP's MAC address
index e8e295dae744e4dc8d86182d193e0e387206a6e9..dcdba96814a2bf59dab074668ad632c6bc814566 100644 (file)
@@ -3311,7 +3311,7 @@ enum ieee80211_roc_type {
 };
 
 /**
- * enum ieee80211_reconfig_complete_type - reconfig type
+ * enum ieee80211_reconfig_type - reconfig type
  *
  * This enum is used by the reconfig_complete() callback to indicate what
  * reconfiguration type was completed.
@@ -6334,7 +6334,8 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw,
                              int band, struct ieee80211_sta **sta);
 
 /**
- * Sanity-check and parse the radiotap header of injected frames
+ * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header
+ *                              of injected frames
  * @skb: packet injected by userspace
  * @dev: the &struct device of this 802.11 device
  */
@@ -6389,7 +6390,7 @@ int ieee80211_parse_p2p_noa(const struct ieee80211_p2p_noa_attr *attr,
 void ieee80211_update_p2p_noa(struct ieee80211_noa_data *data, u32 tsf);
 
 /**
- * ieee80211_tdls_oper - request userspace to perform a TDLS operation
+ * ieee80211_tdls_oper_request - request userspace to perform a TDLS operation
  * @vif: virtual interface
  * @peer: the peer's destination address
  * @oper: the requested TDLS operation
index c672ae1da26bb5f022da290af726f1cb7f62460f..32a67af18415d6f5bad03fb25b04a48e0c340b79 100644 (file)
@@ -227,19 +227,9 @@ void rdma_destroy_qp(struct rdma_cm_id *id);
 int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
                       int *qp_attr_mask);
 
-/**
- * rdma_connect - Initiate an active connection request.
- * @id: Connection identifier to connect.
- * @conn_param: Connection information used for connected QPs.
- *
- * Users must have resolved a route for the rdma_cm_id to connect with
- * by having called rdma_resolve_route before calling this routine.
- *
- * This call will either connect to a remote QP or obtain remote QP
- * information for unconnected rdma_cm_id's.  The actual operation is
- * based on the rdma_cm_id's port space.
- */
 int rdma_connect(struct rdma_cm_id *id, struct rdma_conn_param *conn_param);
+int rdma_connect_locked(struct rdma_cm_id *id,
+                       struct rdma_conn_param *conn_param);
 
 int rdma_connect_ece(struct rdma_cm_id *id, struct rdma_conn_param *conn_param,
                     struct rdma_ucm_ece *ece);
index e128cff10dfaf3f60c48a5f9fe48441b9ca37c2d..77d9fa10812d01dcc35f0b24b6fc5a66cbe9bb94 100644 (file)
@@ -42,7 +42,7 @@ struct snd_kcontrol_new {
        snd_ctl_elem_iface_t iface;     /* interface identifier */
        unsigned int device;            /* device/client number */
        unsigned int subdevice;         /* subdevice (substream) number */
-       const unsigned char *name;      /* ASCII name of item */
+       const char *name;               /* ASCII name of item */
        unsigned int index;             /* index of item */
        unsigned int access;            /* access rights */
        unsigned int count;             /* count of same elements */
index 381a010a1bd4d2f38d953340f3f42f9e66306848..0462c577d7a3f832d38442c637cd16ab1488866e 100644 (file)
@@ -332,7 +332,8 @@ void __snd_printk(unsigned int level, const char *file, int line,
 #define snd_BUG()              WARN(1, "BUG?\n")
 
 /**
- * Suppress high rates of output when CONFIG_SND_DEBUG is enabled.
+ * snd_printd_ratelimit - Suppress high rates of output when
+ *                       CONFIG_SND_DEBUG is enabled.
  */
 #define snd_printd_ratelimit() printk_ratelimit()
 
index 2ba5df2c9e235737726cc14f13d9bffa2c3e6555..2336bf9243e185cd0e8b84b4afe3add26faf59b6 100644 (file)
@@ -1284,8 +1284,8 @@ snd_pcm_sgbuf_get_ptr(struct snd_pcm_substream *substream, unsigned int ofs)
 }
 
 /**
- * snd_pcm_sgbuf_chunk_size - Compute the max size that fits within the contig.
- * page from the given size
+ * snd_pcm_sgbuf_get_chunk_size - Compute the max size that fits within the
+ * contig. page from the given size
  * @substream: PCM substream
  * @ofs: byte offset
  * @size: byte size to examine
index 8eb49231c6bb7bc75d2f63127abe86d9e1656ce7..4eef374d4413e2ce79254846fafda749be3a05ce 100644 (file)
@@ -966,19 +966,6 @@ TRACE_EVENT(afs_dir_check_failed,
                      __entry->vnode, __entry->off, __entry->i_size)
            );
 
-/*
- * We use page->private to hold the amount of the page that we've written to,
- * splitting the field into two parts.  However, we need to represent a range
- * 0...PAGE_SIZE inclusive, so we can't support 64K pages on a 32-bit system.
- */
-#if PAGE_SIZE > 32768
-#define AFS_PRIV_MAX   0xffffffff
-#define AFS_PRIV_SHIFT 32
-#else
-#define AFS_PRIV_MAX   0xffff
-#define AFS_PRIV_SHIFT 16
-#endif
-
 TRACE_EVENT(afs_page_dirty,
            TP_PROTO(struct afs_vnode *vnode, const char *where,
                     pgoff_t page, unsigned long priv),
@@ -999,10 +986,11 @@ TRACE_EVENT(afs_page_dirty,
                    __entry->priv = priv;
                           ),
 
-           TP_printk("vn=%p %lx %s %lu-%lu",
+           TP_printk("vn=%p %lx %s %zx-%zx%s",
                      __entry->vnode, __entry->page, __entry->where,
-                     __entry->priv & AFS_PRIV_MAX,
-                     __entry->priv >> AFS_PRIV_SHIFT)
+                     afs_page_dirty_from(__entry->priv),
+                     afs_page_dirty_to(__entry->priv),
+                     afs_is_page_dirty_mmapped(__entry->priv) ? " M" : "")
            );
 
 TRACE_EVENT(afs_call_state,
index e9304c95ceea2a0898d797a2e522219d2e0ef3dc..fe929e7b77ca12fc19b84716331293109278d348 100644 (file)
@@ -4,6 +4,69 @@
 
 #include <linux/compiler.h>
 
+/*
+ * SA_FLAGS values:
+ *
+ * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
+ * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
+ * SA_SIGINFO delivers the signal with SIGINFO structs.
+ * SA_ONSTACK indicates that a registered stack_t will be used.
+ * SA_RESTART flag to get restarting signals (which were the default long ago)
+ * SA_NODEFER prevents the current signal from being masked in the handler.
+ * SA_RESETHAND clears the handler when the signal is delivered.
+ * SA_UNSUPPORTED is a flag bit that will never be supported. Kernels from
+ * before the introduction of SA_UNSUPPORTED did not clear unknown bits from
+ * sa_flags when read using the oldact argument to sigaction and rt_sigaction,
+ * so this bit allows flag bit support to be detected from userspace while
+ * allowing an old kernel to be distinguished from a kernel that supports every
+ * flag bit.
+ * SA_EXPOSE_TAGBITS exposes an architecture-defined set of tag bits in
+ * siginfo.si_addr.
+ *
+ * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
+ * Unix names RESETHAND and NODEFER respectively.
+ */
+#ifndef SA_NOCLDSTOP
+#define SA_NOCLDSTOP   0x00000001
+#endif
+#ifndef SA_NOCLDWAIT
+#define SA_NOCLDWAIT   0x00000002
+#endif
+#ifndef SA_SIGINFO
+#define SA_SIGINFO     0x00000004
+#endif
+/* 0x00000008 used on alpha, mips, parisc */
+/* 0x00000010 used on alpha, parisc */
+/* 0x00000020 used on alpha, parisc, sparc */
+/* 0x00000040 used on alpha, parisc */
+/* 0x00000080 used on parisc */
+/* 0x00000100 used on sparc */
+/* 0x00000200 used on sparc */
+#define SA_UNSUPPORTED 0x00000400
+#define SA_EXPOSE_TAGBITS      0x00000800
+/* 0x00010000 used on mips */
+/* 0x01000000 used on x86 */
+/* 0x02000000 used on x86 */
+/*
+ * New architectures should not define the obsolete
+ *     SA_RESTORER     0x04000000
+ */
+#ifndef SA_ONSTACK
+#define SA_ONSTACK     0x08000000
+#endif
+#ifndef SA_RESTART
+#define SA_RESTART     0x10000000
+#endif
+#ifndef SA_NODEFER
+#define SA_NODEFER     0x40000000
+#endif
+#ifndef SA_RESETHAND
+#define SA_RESETHAND   0x80000000
+#endif
+
+#define SA_NOMASK      SA_NODEFER
+#define SA_ONESHOT     SA_RESETHAND
+
 #ifndef SIG_BLOCK
 #define SIG_BLOCK          0   /* for blocking signals */
 #endif
index 5c716a952cbe34639334ff1745de70bd6a68d54b..f634822906e4ac292297043980649840ee814473 100644 (file)
 #define SIGRTMAX       _NSIG
 #endif
 
-/*
- * SA_FLAGS values:
- *
- * SA_ONSTACK indicates that a registered stack_t will be used.
- * SA_RESTART flag to get restarting signals (which were the default long ago)
- * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
- * SA_RESETHAND clears the handler when the signal is delivered.
- * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
- * SA_NODEFER prevents the current signal from being masked in the handler.
- *
- * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
- * Unix names RESETHAND and NODEFER respectively.
- */
-#define SA_NOCLDSTOP   0x00000001
-#define SA_NOCLDWAIT   0x00000002
-#define SA_SIGINFO     0x00000004
-#define SA_ONSTACK     0x08000000
-#define SA_RESTART     0x10000000
-#define SA_NODEFER     0x40000000
-#define SA_RESETHAND   0x80000000
-
-#define SA_NOMASK      SA_NODEFER
-#define SA_ONESHOT     SA_RESETHAND
-
-/*
- * New architectures should not define the obsolete
- *     SA_RESTORER     0x04000000
- */
-
 #if !defined MINSIGSTKSZ || !defined SIGSTKSZ
 #define MINSIGSTKSZ    2048
 #define SIGSTKSZ       8192
index c1661febc2dc4841304bb678e235475b79fa8ec1..0564fd7ccde4180da7911f473bf2e26f04c2051e 100644 (file)
@@ -138,6 +138,7 @@ struct icmp6hdr {
 #define ICMPV6_HDR_FIELD               0
 #define ICMPV6_UNK_NEXTHDR             1
 #define ICMPV6_UNK_OPTION              2
+#define ICMPV6_HDR_INCOMP              3
 
 /*
  *     constants for (set|get)sockopt
diff --git a/include/uapi/linux/mic_common.h b/include/uapi/linux/mic_common.h
deleted file mode 100644 (file)
index 504e523..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * The full GNU General Public License is included in this distribution in
- * the file called "COPYING".
- *
- * Intel MIC driver.
- *
- */
-#ifndef __MIC_COMMON_H_
-#define __MIC_COMMON_H_
-
-#include <linux/virtio_ring.h>
-
-#define __mic_align(a, x) (((a) + (x) - 1) & ~((x) - 1))
-
-/**
- * struct mic_device_desc: Virtio device information shared between the
- * virtio driver and userspace backend
- *
- * @type: Device type: console/network/disk etc.  Type 0/-1 terminates.
- * @num_vq: Number of virtqueues.
- * @feature_len: Number of bytes of feature bits.  Multiply by 2: one for
-   host features and one for guest acknowledgements.
- * @config_len: Number of bytes of the config array after virtqueues.
- * @status: A status byte, written by the Guest.
- * @config: Start of the following variable length config.
- */
-struct mic_device_desc {
-       __s8 type;
-       __u8 num_vq;
-       __u8 feature_len;
-       __u8 config_len;
-       __u8 status;
-       __le64 config[0];
-} __attribute__ ((aligned(8)));
-
-/**
- * struct mic_device_ctrl: Per virtio device information in the device page
- * used internally by the host and card side drivers.
- *
- * @vdev: Used for storing MIC vdev information by the guest.
- * @config_change: Set to 1 by host when a config change is requested.
- * @vdev_reset: Set to 1 by guest to indicate virtio device has been reset.
- * @guest_ack: Set to 1 by guest to ack a command.
- * @host_ack: Set to 1 by host to ack a command.
- * @used_address_updated: Set to 1 by guest when the used address should be
- * updated.
- * @c2h_vdev_db: The doorbell number to be used by guest. Set by host.
- * @h2c_vdev_db: The doorbell number to be used by host. Set by guest.
- */
-struct mic_device_ctrl {
-       __le64 vdev;
-       __u8 config_change;
-       __u8 vdev_reset;
-       __u8 guest_ack;
-       __u8 host_ack;
-       __u8 used_address_updated;
-       __s8 c2h_vdev_db;
-       __s8 h2c_vdev_db;
-} __attribute__ ((aligned(8)));
-
-/**
- * struct mic_bootparam: Virtio device independent information in device page
- *
- * @magic: A magic value used by the card to ensure it can see the host
- * @h2c_config_db: Host to Card Virtio config doorbell set by card
- * @node_id: Unique id of the node
- * @h2c_scif_db - Host to card SCIF doorbell set by card
- * @c2h_scif_db - Card to host SCIF doorbell set by host
- * @scif_host_dma_addr - SCIF host queue pair DMA address
- * @scif_card_dma_addr - SCIF card queue pair DMA address
- */
-struct mic_bootparam {
-       __le32 magic;
-       __s8 h2c_config_db;
-       __u8 node_id;
-       __u8 h2c_scif_db;
-       __u8 c2h_scif_db;
-       __u64 scif_host_dma_addr;
-       __u64 scif_card_dma_addr;
-} __attribute__ ((aligned(8)));
-
-/**
- * struct mic_device_page: High level representation of the device page
- *
- * @bootparam: The bootparam structure is used for sharing information and
- * status updates between MIC host and card drivers.
- * @desc: Array of MIC virtio device descriptors.
- */
-struct mic_device_page {
-       struct mic_bootparam bootparam;
-       struct mic_device_desc desc[0];
-};
-/**
- * struct mic_vqconfig: This is how we expect the device configuration field
- * for a virtqueue to be laid out in config space.
- *
- * @address: Guest/MIC physical address of the virtio ring
- * (avail and desc rings)
- * @used_address: Guest/MIC physical address of the used ring
- * @num: The number of entries in the virtio_ring
- */
-struct mic_vqconfig {
-       __le64 address;
-       __le64 used_address;
-       __le16 num;
-} __attribute__ ((aligned(8)));
-
-/*
- * The alignment to use between consumer and producer parts of vring.
- * This is pagesize for historical reasons.
- */
-#define MIC_VIRTIO_RING_ALIGN          4096
-
-#define MIC_MAX_VRINGS                 4
-#define MIC_VRING_ENTRIES              128
-
-/*
- * Max vring entries (power of 2) to ensure desc and avail rings
- * fit in a single page
- */
-#define MIC_MAX_VRING_ENTRIES          128
-
-/**
- * Max size of the desc block in bytes: includes:
- *     - struct mic_device_desc
- *     - struct mic_vqconfig (num_vq of these)
- *     - host and guest features
- *     - virtio device config space
- */
-#define MIC_MAX_DESC_BLK_SIZE          256
-
-/**
- * struct _mic_vring_info - Host vring info exposed to userspace backend
- * for the avail index and magic for the card.
- *
- * @avail_idx: host avail idx
- * @magic: A magic debug cookie.
- */
-struct _mic_vring_info {
-       __u16 avail_idx;
-       __le32 magic;
-};
-
-/**
- * struct mic_vring - Vring information.
- *
- * @vr: The virtio ring.
- * @info: Host vring information exposed to the userspace backend for the
- * avail index and magic for the card.
- * @va: The va for the buffer allocated for vr and info.
- * @len: The length of the buffer required for allocating vr and info.
- */
-struct mic_vring {
-       struct vring vr;
-       struct _mic_vring_info *info;
-       void *va;
-       int len;
-};
-
-#define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8)
-
-#ifndef INTEL_MIC_CARD
-static inline unsigned mic_desc_size(const struct mic_device_desc *desc)
-{
-       return sizeof(*desc) + desc->num_vq * sizeof(struct mic_vqconfig)
-               + desc->feature_len * 2 + desc->config_len;
-}
-
-static inline struct mic_vqconfig *
-mic_vq_config(const struct mic_device_desc *desc)
-{
-       return (struct mic_vqconfig *)(desc + 1);
-}
-
-static inline __u8 *mic_vq_features(const struct mic_device_desc *desc)
-{
-       return (__u8 *)(mic_vq_config(desc) + desc->num_vq);
-}
-
-static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc)
-{
-       return mic_vq_features(desc) + desc->feature_len * 2;
-}
-static inline unsigned mic_total_desc_size(struct mic_device_desc *desc)
-{
-       return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl);
-}
-#endif
-
-/* Device page size */
-#define MIC_DP_SIZE 4096
-
-#define MIC_MAGIC 0xc0ffee00
-
-/**
- * enum mic_states - MIC states.
- */
-enum mic_states {
-       MIC_READY = 0,
-       MIC_BOOTING,
-       MIC_ONLINE,
-       MIC_SHUTTING_DOWN,
-       MIC_RESETTING,
-       MIC_RESET_FAILED,
-       MIC_LAST
-};
-
-/**
- * enum mic_status - MIC status reported by card after
- * a host or card initiated shutdown or a card crash.
- */
-enum mic_status {
-       MIC_NOP = 0,
-       MIC_CRASHED,
-       MIC_HALTED,
-       MIC_POWER_OFF,
-       MIC_RESTART,
-       MIC_STATUS_LAST
-};
-
-#endif
diff --git a/include/uapi/linux/mic_ioctl.h b/include/uapi/linux/mic_ioctl.h
deleted file mode 100644 (file)
index 687b9cd..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * The full GNU General Public License is included in this distribution in
- * the file called "COPYING".
- *
- * Intel MIC Host driver.
- *
- */
-#ifndef _MIC_IOCTL_H_
-#define _MIC_IOCTL_H_
-
-#include <linux/types.h>
-
-/*
- * mic_copy - MIC virtio descriptor copy.
- *
- * @iov: An array of IOVEC structures containing user space buffers.
- * @iovcnt: Number of IOVEC structures in iov.
- * @vr_idx: The vring index.
- * @update_used: A non zero value results in used index being updated.
- * @out_len: The aggregate of the total length written to or read from
- *     the virtio device.
- */
-struct mic_copy_desc {
-#ifdef __KERNEL__
-       struct iovec __user *iov;
-#else
-       struct iovec *iov;
-#endif
-       __u32 iovcnt;
-       __u8 vr_idx;
-       __u8 update_used;
-       __u32 out_len;
-};
-
-/*
- * Add a new virtio device
- * The (struct mic_device_desc *) pointer points to a device page entry
- *     for the virtio device consisting of:
- *     - struct mic_device_desc
- *     - struct mic_vqconfig (num_vq of these)
- *     - host and guest features
- *     - virtio device config space
- * The total size referenced by the pointer should equal the size returned
- * by desc_size() in mic_common.h
- */
-#define MIC_VIRTIO_ADD_DEVICE _IOWR('s', 1, struct mic_device_desc *)
-
-/*
- * Copy the number of entries in the iovec and update the used index
- * if requested by the user.
- */
-#define MIC_VIRTIO_COPY_DESC   _IOWR('s', 2, struct mic_copy_desc *)
-
-/*
- * Notify virtio device of a config change
- * The (__u8 *) pointer points to config space values for the device
- * as they should be written into the device page. The total size
- * referenced by the pointer should equal the config_len field of struct
- * mic_device_desc.
- */
-#define MIC_VIRTIO_CONFIG_CHANGE _IOWR('s', 5, __u8 *)
-
-#endif
index 75232185324abb8bf16521b525ed007306ab582f..c998860d7bbc4351c37c702ea69ea88a814b19cf 100644 (file)
 
 /* Set event fd for config interrupt*/
 #define VHOST_VDPA_SET_CONFIG_CALL     _IOW(VHOST_VIRTIO, 0x77, int)
+
+/* Get the valid iova range */
+#define VHOST_VDPA_GET_IOVA_RANGE      _IOR(VHOST_VIRTIO, 0x78, \
+                                            struct vhost_vdpa_iova_range)
 #endif
index 9a269a88a6ffd1d6c9aff58ba854a6c7705df389..f7f6a3a28977ae15f7391e270fa327cc60e4f101 100644 (file)
@@ -138,6 +138,15 @@ struct vhost_vdpa_config {
        __u8 buf[0];
 };
 
+/* vhost vdpa IOVA range
+ * @first: First address that can be mapped by vhost-vDPA
+ * @last: Last address that can be mapped by vhost-vDPA
+ */
+struct vhost_vdpa_iova_range {
+       __u64 first;
+       __u64 last;
+};
+
 /* Feature bits */
 /* Log all write descriptors. Can be changed while device is active. */
 #define VHOST_F_LOG_ALL 26
index 7184265c0b0d4e01471e7f47e7d8ccd6e3b68509..9555f31c8425c79ac87cb239c446509e73f39369 100644 (file)
@@ -144,7 +144,7 @@ struct snd_compr_metadata {
         __u32 value[8];
 } __attribute__((packed, aligned(4)));
 
-/**
+/*
  * compress path ioctl definitions
  * SNDRV_COMPRESS_GET_CAPS: Query capability of DSP
  * SNDRV_COMPRESS_GET_CODEC_CAPS: Query capability of a codec
index 06b0b57e996cb5efad84cf74dc391766fedaf986..d1b3889f74d8fa24094a0642ced54eba0313bb9c 100644 (file)
@@ -484,9 +484,6 @@ int ipu_smfc_set_watermark(struct ipu_smfc *smfc, u32 set_level, u32 clr_level);
 
 enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
 enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
-enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
-int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
-bool ipu_pixelformat_is_planar(u32 pixelformat);
 int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
                            bool hflip, bool vflip);
 int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
index 2b8366693d5c119aa9f74e2a82cd1a1894a0c52f..e9e2df3f3f9eed2df7530d435f1569ed282fb178 100644 (file)
@@ -337,10 +337,10 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
         * already contains a warning when RCU is not watching, so no point
         * in having another one here.
         */
+       lockdep_hardirqs_off(CALLER_ADDR0);
        instrumentation_begin();
        rcu_irq_enter_check_tick();
-       /* Use the combo lockdep/tracing function */
-       trace_hardirqs_off();
+       trace_hardirqs_off_finish();
        instrumentation_end();
 
        return ret;
index da467e1dd49a2dd3b571245b5c8eeb5adbe73ac6..5a29ab09e72d6ac15776ff714d2afb114e118222 100644 (file)
@@ -10085,6 +10085,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
                        if (token == IF_SRC_FILE || token == IF_SRC_FILEADDR) {
                                int fpos = token == IF_SRC_FILE ? 2 : 1;
 
+                               kfree(filename);
                                filename = match_strdup(&args[fpos]);
                                if (!filename) {
                                        ret = -ENOMEM;
@@ -10131,16 +10132,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
                                 */
                                ret = -EOPNOTSUPP;
                                if (!event->ctx->task)
-                                       goto fail_free_name;
+                                       goto fail;
 
                                /* look up the path and grab its inode */
                                ret = kern_path(filename, LOOKUP_FOLLOW,
                                                &filter->path);
                                if (ret)
-                                       goto fail_free_name;
-
-                               kfree(filename);
-                               filename = NULL;
+                                       goto fail;
 
                                ret = -EINVAL;
                                if (!filter->path.dentry ||
@@ -10160,13 +10158,13 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
        if (state != IF_STATE_ACTION)
                goto fail;
 
+       kfree(filename);
        kfree(orig);
 
        return 0;
 
-fail_free_name:
-       kfree(filename);
 fail:
+       kfree(filename);
        free_filters_list(filters);
        kfree(orig);
 
index 32083db7a2a23e93bf2ed9786c92769a0e9c7136..6d266388d3804ce75e2983cce13f91fb20d53c5b 100644 (file)
@@ -2167,14 +2167,9 @@ static __latent_entropy struct task_struct *copy_process(
        /* ok, now we should be set up.. */
        p->pid = pid_nr(pid);
        if (clone_flags & CLONE_THREAD) {
-               p->exit_signal = -1;
                p->group_leader = current->group_leader;
                p->tgid = current->tgid;
        } else {
-               if (clone_flags & CLONE_PARENT)
-                       p->exit_signal = current->group_leader->exit_signal;
-               else
-                       p->exit_signal = args->exit_signal;
                p->group_leader = p;
                p->tgid = p->pid;
        }
@@ -2218,9 +2213,14 @@ static __latent_entropy struct task_struct *copy_process(
        if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
                p->real_parent = current->real_parent;
                p->parent_exec_id = current->parent_exec_id;
+               if (clone_flags & CLONE_THREAD)
+                       p->exit_signal = -1;
+               else
+                       p->exit_signal = current->group_leader->exit_signal;
        } else {
                p->real_parent = current;
                p->parent_exec_id = current->self_exec_id;
+               p->exit_signal = args->exit_signal;
        }
 
        klp_copy_process(p);
index be68ac0d49adf6cf2eeff7c9c3514dc03ffcb5a9..ac328874f6e583c29c652f2980202f56877cfa60 100644 (file)
@@ -1503,8 +1503,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_
         */
        newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
 
-       if (unlikely(should_fail_futex(true)))
+       if (unlikely(should_fail_futex(true))) {
                ret = -EFAULT;
+               goto out_unlock;
+       }
 
        ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
        if (!ret && (curval != uval)) {
@@ -2378,10 +2380,22 @@ retry:
                }
 
                /*
-                * Since we just failed the trylock; there must be an owner.
+                * The trylock just failed, so either there is an owner or
+                * there is a higher priority waiter than this one.
                 */
                newowner = rt_mutex_owner(&pi_state->pi_mutex);
-               BUG_ON(!newowner);
+               /*
+                * If the higher priority waiter has not yet taken over the
+                * rtmutex then newowner is NULL. We can't return here with
+                * that state because it's inconsistent vs. the user space
+                * state. So drop the locks and try again. It's a valid
+                * situation and not any different from the other retry
+                * conditions.
+                */
+               if (unlikely(!newowner)) {
+                       err = -EAGAIN;
+                       goto handle_err;
+               }
        } else {
                WARN_ON_ONCE(argowner != current);
                if (oldowner == current) {
index ce76f490126cccb310750c6b32f2a7b67bd5eb60..396ebaebea3fea3578fe295c73cf041530a91d93 100644 (file)
@@ -225,8 +225,7 @@ static long hung_timeout_jiffies(unsigned long last_checked,
  * Process updating of timeout sysctl
  */
 int proc_dohung_task_timeout_secs(struct ctl_table *table, int write,
-                                 void __user *buffer,
-                                 size_t *lenp, loff_t *ppos)
+                                 void *buffer, size_t *lenp, loff_t *ppos)
 {
        int ret;
 
index 10a5aff4eecc880d50677e4ce30adbb9eb01395e..164a031cfdb66e8fd4240ace61f1bbd5d1d7e884 100644 (file)
@@ -82,6 +82,7 @@ config IRQ_FASTEOI_HIERARCHY_HANDLERS
 # Generic IRQ IPI support
 config GENERIC_IRQ_IPI
        bool
+       select IRQ_DOMAIN_HIERARCHY
 
 # Generic MSI interrupt support
 config GENERIC_MSI_IRQ
index 8a12a25fa40d5e1c12303a6d395949d0ad4c135d..41fdbb7953c60f878049b2a5807abb4aecf95320 100644 (file)
@@ -1249,7 +1249,13 @@ __acquires(hlist_lock)
 
        *head = &kretprobe_inst_table[hash];
        hlist_lock = kretprobe_table_lock_ptr(hash);
-       raw_spin_lock_irqsave(hlist_lock, *flags);
+       /*
+        * Nested is a workaround that will soon not be needed.
+        * There's other protections that make sure the same lock
+        * is not taken on the same CPU that lockdep is unaware of.
+        * Differentiate when it is taken in NMI context.
+        */
+       raw_spin_lock_irqsave_nested(hlist_lock, *flags, !!in_nmi());
 }
 NOKPROBE_SYMBOL(kretprobe_hash_lock);
 
@@ -1258,7 +1264,13 @@ static void kretprobe_table_lock(unsigned long hash,
 __acquires(hlist_lock)
 {
        raw_spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
-       raw_spin_lock_irqsave(hlist_lock, *flags);
+       /*
+        * Nested is a workaround that will soon not be needed.
+        * There's other protections that make sure the same lock
+        * is not taken on the same CPU that lockdep is unaware of.
+        * Differentiate when it is taken in NMI context.
+        */
+       raw_spin_lock_irqsave_nested(hlist_lock, *flags, !!in_nmi());
 }
 NOKPROBE_SYMBOL(kretprobe_table_lock);
 
@@ -2028,7 +2040,12 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
 
        /* TODO: consider to only swap the RA after the last pre_handler fired */
        hash = hash_ptr(current, KPROBE_HASH_BITS);
-       raw_spin_lock_irqsave(&rp->lock, flags);
+       /*
+        * Nested is a workaround that will soon not be needed.
+        * There's other protections that make sure the same lock
+        * is not taken on the same CPU that lockdep is unaware of.
+        */
+       raw_spin_lock_irqsave_nested(&rp->lock, flags, 1);
        if (!hlist_empty(&rp->free_instances)) {
                ri = hlist_entry(rp->free_instances.first,
                                struct kretprobe_instance, hlist);
@@ -2039,7 +2056,7 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs)
                ri->task = current;
 
                if (rp->entry_handler && rp->entry_handler(ri, regs)) {
-                       raw_spin_lock_irqsave(&rp->lock, flags);
+                       raw_spin_lock_irqsave_nested(&rp->lock, flags, 1);
                        hlist_add_head(&ri->hlist, &rp->free_instances);
                        raw_spin_unlock_irqrestore(&rp->lock, flags);
                        return 0;
index e29773c82b70c26fff598f864642f7dee010efab..933a625621b8dbef0564919bf6f76aa30735372f 100644 (file)
@@ -897,7 +897,8 @@ void kthread_delayed_work_timer_fn(struct timer_list *t)
        /* Move the work from worker->delayed_work_list. */
        WARN_ON_ONCE(list_empty(&work->node));
        list_del_init(&work->node);
-       kthread_insert_work(worker, work, &worker->work_list);
+       if (!work->canceling)
+               kthread_insert_work(worker, work, &worker->work_list);
 
        raw_spin_unlock_irqrestore(&worker->lock, flags);
 }
index 3e99dfef84084695a5ff440112eb41c38159fb60..b71ad8d9f1c9a7f090fc45b7da7d412858541fb6 100644 (file)
@@ -84,7 +84,7 @@ static inline bool lockdep_enabled(void)
        if (!debug_locks)
                return false;
 
-       if (raw_cpu_read(lockdep_recursion))
+       if (this_cpu_read(lockdep_recursion))
                return false;
 
        if (current->lockdep_recursion)
@@ -4057,7 +4057,7 @@ void lockdep_hardirqs_on_prepare(unsigned long ip)
        if (unlikely(in_nmi()))
                return;
 
-       if (unlikely(__this_cpu_read(lockdep_recursion)))
+       if (unlikely(this_cpu_read(lockdep_recursion)))
                return;
 
        if (unlikely(lockdep_hardirqs_enabled())) {
@@ -4126,7 +4126,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip)
                goto skip_checks;
        }
 
-       if (unlikely(__this_cpu_read(lockdep_recursion)))
+       if (unlikely(this_cpu_read(lockdep_recursion)))
                return;
 
        if (lockdep_hardirqs_enabled()) {
@@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
        if (unlikely(hlock_class(this)->usage_mask & new_mask))
                goto unlock;
 
+       if (!hlock_class(this)->usage_mask)
+               debug_atomic_dec(nr_unused_locks);
+
        hlock_class(this)->usage_mask |= new_mask;
 
        if (new_bit < LOCK_TRACE_STATES) {
@@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
                        return 0;
        }
 
-       switch (new_bit) {
-       case 0 ... LOCK_USED-1:
+       if (new_bit < LOCK_USED) {
                ret = mark_lock_irq(curr, this, new_bit);
                if (!ret)
                        return 0;
-               break;
-
-       case LOCK_USED:
-               debug_atomic_dec(nr_unused_locks);
-               break;
-
-       default:
-               break;
        }
 
 unlock:
index 3835fb82c64bda060af746930350e3d40529a86a..164d79330849a0a3c213b2802ac41b02eb96f5a6 100644 (file)
@@ -530,7 +530,7 @@ struct module_param_attrs
 {
        unsigned int num;
        struct attribute_group grp;
-       struct param_attribute attrs[0];
+       struct param_attribute attrs[];
 };
 
 #ifdef CONFIG_SYSFS
index 4b6a54da7e65bdd662e8f485363352e6236f3ad2..45b054b7b5ec81f814f6bf12c9462318424e6e01 100644 (file)
@@ -146,7 +146,7 @@ int freeze_processes(void)
        BUG_ON(in_atomic());
 
        /*
-        * Now that the whole userspace is frozen we need to disbale
+        * Now that the whole userspace is frozen we need to disable
         * the OOM killer to disallow any further interference with
         * killable tasks. There is no guarantee oom victims will
         * ever reach a point they go away we have to wait with a timeout.
index 24a960a89aa890e2b6c8ae467970b2d792f12b97..6b152568527708ed618e947520fbbafe96c1237d 100644 (file)
@@ -345,7 +345,7 @@ DESC_ID((id) - DESCS_COUNT(desc_ring))
  */
 struct prb_data_block {
        unsigned long   id;
-       char            data[0];
+       char            data[];
 };
 
 /*
index 946e7c0c4cf7537d427af793f1dfd319e1250846..bd04b09b84b327cde1aa8472986dfc0a5ff39719 100644 (file)
@@ -409,7 +409,7 @@ bool rcu_eqs_special_set(int cpu)
  *
  * The caller must have disabled interrupts and must not be idle.
  */
-void rcu_momentary_dyntick_idle(void)
+notrace void rcu_momentary_dyntick_idle(void)
 {
        int special;
 
index e254745a82cb851e0f695edfc628fbbf519b8e40..d73bccde2720bcb7563dc6427692c0ab631c1bf3 100644 (file)
@@ -102,8 +102,12 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
 static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
                                   unsigned int next_freq)
 {
-       if (sg_policy->next_freq == next_freq)
-               return false;
+       if (!sg_policy->need_freq_update) {
+               if (sg_policy->next_freq == next_freq)
+                       return false;
+       } else {
+               sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
+       }
 
        sg_policy->next_freq = next_freq;
        sg_policy->last_freq_update_time = time;
@@ -164,7 +168,6 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
        if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update)
                return sg_policy->next_freq;
 
-       sg_policy->need_freq_update = false;
        sg_policy->cached_raw_freq = freq;
        return cpufreq_driver_resolve_freq(policy, freq);
 }
@@ -440,7 +443,6 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
        struct sugov_policy *sg_policy = sg_cpu->sg_policy;
        unsigned long util, max;
        unsigned int next_f;
-       bool busy;
        unsigned int cached_freq = sg_policy->cached_raw_freq;
 
        sugov_iowait_boost(sg_cpu, time, flags);
@@ -451,9 +453,6 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
        if (!sugov_should_update_freq(sg_policy, time))
                return;
 
-       /* Limits may have changed, don't skip frequency update */
-       busy = !sg_policy->need_freq_update && sugov_cpu_is_busy(sg_cpu);
-
        util = sugov_get_util(sg_cpu);
        max = sg_cpu->max;
        util = sugov_iowait_apply(sg_cpu, time, util, max);
@@ -462,7 +461,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
         * Do not reduce the frequency if the CPU has not been idle
         * recently, as the reduction is likely to be premature then.
         */
-       if (busy && next_f < sg_policy->next_freq) {
+       if (sugov_cpu_is_busy(sg_cpu) && next_f < sg_policy->next_freq) {
                next_f = sg_policy->next_freq;
 
                /* Restore cached freq as next_freq has changed */
@@ -827,9 +826,10 @@ static int sugov_start(struct cpufreq_policy *policy)
        sg_policy->next_freq                    = 0;
        sg_policy->work_in_progress             = false;
        sg_policy->limits_changed               = false;
-       sg_policy->need_freq_update             = false;
        sg_policy->cached_raw_freq              = 0;
 
+       sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
+
        for_each_cpu(cpu, policy->cpus) {
                struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
 
index 4ff4a7ba0094f737e7730e1fcfc02b00fbcfb4fb..e2a71fc82fa0686c48bb62f7d559e47445096237 100644 (file)
@@ -5,26 +5,49 @@
  * Copyright (C) 2019 Google LLC
  */
 
+#include <linux/cpuhotplug.h>
 #include <linux/kasan.h>
 #include <linux/mm.h>
 #include <linux/scs.h>
-#include <linux/slab.h>
+#include <linux/vmalloc.h>
 #include <linux/vmstat.h>
 
-static struct kmem_cache *scs_cache;
-
 static void __scs_account(void *s, int account)
 {
-       struct page *scs_page = virt_to_page(s);
+       struct page *scs_page = vmalloc_to_page(s);
 
        mod_node_page_state(page_pgdat(scs_page), NR_KERNEL_SCS_KB,
                            account * (SCS_SIZE / SZ_1K));
 }
 
-static void *scs_alloc(int node)
+/* Matches NR_CACHED_STACKS for VMAP_STACK */
+#define NR_CACHED_SCS 2
+static DEFINE_PER_CPU(void *, scs_cache[NR_CACHED_SCS]);
+
+static void *__scs_alloc(int node)
 {
-       void *s = kmem_cache_alloc_node(scs_cache, GFP_SCS, node);
+       int i;
+       void *s;
+
+       for (i = 0; i < NR_CACHED_SCS; i++) {
+               s = this_cpu_xchg(scs_cache[i], NULL);
+               if (s) {
+                       kasan_unpoison_vmalloc(s, SCS_SIZE);
+                       memset(s, 0, SCS_SIZE);
+                       return s;
+               }
+       }
+
+       return __vmalloc_node_range(SCS_SIZE, 1, VMALLOC_START, VMALLOC_END,
+                                   GFP_SCS, PAGE_KERNEL, 0, node,
+                                   __builtin_return_address(0));
+}
 
+void *scs_alloc(int node)
+{
+       void *s;
+
+       s = __scs_alloc(node);
        if (!s)
                return NULL;
 
@@ -34,21 +57,47 @@ static void *scs_alloc(int node)
         * Poison the allocation to catch unintentional accesses to
         * the shadow stack when KASAN is enabled.
         */
-       kasan_poison_object_data(scs_cache, s);
+       kasan_poison_vmalloc(s, SCS_SIZE);
        __scs_account(s, 1);
        return s;
 }
 
-static void scs_free(void *s)
+void scs_free(void *s)
 {
+       int i;
+
        __scs_account(s, -1);
-       kasan_unpoison_object_data(scs_cache, s);
-       kmem_cache_free(scs_cache, s);
+
+       /*
+        * We cannot sleep as this can be called in interrupt context,
+        * so use this_cpu_cmpxchg to update the cache, and vfree_atomic
+        * to free the stack.
+        */
+
+       for (i = 0; i < NR_CACHED_SCS; i++)
+               if (this_cpu_cmpxchg(scs_cache[i], 0, s) == NULL)
+                       return;
+
+       vfree_atomic(s);
+}
+
+static int scs_cleanup(unsigned int cpu)
+{
+       int i;
+       void **cache = per_cpu_ptr(scs_cache, cpu);
+
+       for (i = 0; i < NR_CACHED_SCS; i++) {
+               vfree(cache[i]);
+               cache[i] = NULL;
+       }
+
+       return 0;
 }
 
 void __init scs_init(void)
 {
-       scs_cache = kmem_cache_create("scs_cache", SCS_SIZE, 0, 0, NULL);
+       cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "scs:scs_cache", NULL,
+                         scs_cleanup);
 }
 
 int scs_prepare(struct task_struct *tsk, int node)
index a38b3edc68511c3419a68b96d9867f000bb18d83..26018c59821dfb7ff35714747dd22ef286289c2c 100644 (file)
@@ -391,16 +391,17 @@ static bool task_participate_group_stop(struct task_struct *task)
 
 void task_join_group_stop(struct task_struct *task)
 {
+       unsigned long mask = current->jobctl & JOBCTL_STOP_SIGMASK;
+       struct signal_struct *sig = current->signal;
+
+       if (sig->group_stop_count) {
+               sig->group_stop_count++;
+               mask |= JOBCTL_STOP_CONSUME;
+       } else if (!(sig->flags & SIGNAL_STOP_STOPPED))
+               return;
+
        /* Have the new thread join an on-going signal group stop */
-       unsigned long jobctl = current->jobctl;
-       if (jobctl & JOBCTL_STOP_PENDING) {
-               struct signal_struct *sig = current->signal;
-               unsigned long signr = jobctl & JOBCTL_STOP_SIGMASK;
-               unsigned long gstop = JOBCTL_STOP_PENDING | JOBCTL_STOP_CONSUME;
-               if (task_set_jobctl_pending(task, signr | gstop)) {
-                       sig->group_stop_count++;
-               }
-       }
+       task_set_jobctl_pending(task, mask | JOBCTL_STOP_PENDING);
 }
 
 /*
@@ -2523,6 +2524,26 @@ static int ptrace_signal(int signr, kernel_siginfo_t *info)
        return signr;
 }
 
+static void hide_si_addr_tag_bits(struct ksignal *ksig)
+{
+       switch (siginfo_layout(ksig->sig, ksig->info.si_code)) {
+       case SIL_FAULT:
+       case SIL_FAULT_MCEERR:
+       case SIL_FAULT_BNDERR:
+       case SIL_FAULT_PKUERR:
+               ksig->info.si_addr = arch_untagged_si_addr(
+                       ksig->info.si_addr, ksig->sig, ksig->info.si_code);
+               break;
+       case SIL_KILL:
+       case SIL_TIMER:
+       case SIL_POLL:
+       case SIL_CHLD:
+       case SIL_RT:
+       case SIL_SYS:
+               break;
+       }
+}
+
 bool get_signal(struct ksignal *ksig)
 {
        struct sighand_struct *sighand = current->sighand;
@@ -2760,6 +2781,10 @@ relock:
        spin_unlock_irq(&sighand->siglock);
 
        ksig->sig = signr;
+
+       if (!(ksig->ka.sa.sa_flags & SA_EXPOSE_TAGBITS))
+               hide_si_addr_tag_bits(ksig);
+
        return ksig->sig > 0;
 }
 
@@ -3984,6 +4009,22 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
        if (oact)
                *oact = *k;
 
+       /*
+        * Make sure that we never accidentally claim to support SA_UNSUPPORTED,
+        * e.g. by having an architecture use the bit in their uapi.
+        */
+       BUILD_BUG_ON(UAPI_SA_FLAGS & SA_UNSUPPORTED);
+
+       /*
+        * Clear unknown flag bits in order to allow userspace to detect missing
+        * support for flag bits and to allow the kernel to use non-uapi bits
+        * internally.
+        */
+       if (act)
+               act->sa.sa_flags &= UAPI_SA_FLAGS;
+       if (oact)
+               oact->sa.sa_flags &= UAPI_SA_FLAGS;
+
        sigaction_compat_abi(act, oact);
 
        if (act) {
index 865bb0228ab667d9407a889c45e47afd1e35d383..890b79cf0e7c311c94e1ce5aa882a5f7f7d4e335 100644 (file)
@@ -178,7 +178,7 @@ static void ack_state(struct multi_stop_data *msdata)
                set_state(msdata, msdata->state + 1);
 }
 
-void __weak stop_machine_yield(const struct cpumask *cpumask)
+notrace void __weak stop_machine_yield(const struct cpumask *cpumask)
 {
        cpu_relax();
 }
index 3624b9b5835de548df2eafd78f986447e798e0fb..387b4bef7dd14118892dae9f030edf53fecc0913 100644 (file)
@@ -425,11 +425,6 @@ static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
        debug_object_deactivate(timer, &hrtimer_debug_descr);
 }
 
-static inline void debug_hrtimer_free(struct hrtimer *timer)
-{
-       debug_object_free(timer, &hrtimer_debug_descr);
-}
-
 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
                           enum hrtimer_mode mode);
 
index ca4e6d57d68b9128662bf61d4ef4e5c138e43034..00629e658ca196ec1b2c06c4d15fd7e700903ac2 100644 (file)
@@ -172,10 +172,6 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
        u64 oval, nval, ointerval, ninterval;
        struct cpu_itimer *it = &tsk->signal->it[clock_id];
 
-       /*
-        * Use the to_ktime conversion because that clamps the maximum
-        * value to KTIME_MAX and avoid multiplication overflows.
-        */
        nval = timespec64_to_ns(&value->it_value);
        ninterval = timespec64_to_ns(&value->it_interval);
 
index 0642013dace49bb4e652259c84096729b2930c6b..b1b9b12899f5e43571e9cc39740f545cd6fad795 100644 (file)
@@ -68,13 +68,13 @@ static inline u64 notrace cyc_to_ns(u64 cyc, u32 mult, u32 shift)
        return (cyc * mult) >> shift;
 }
 
-struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
+notrace struct clock_read_data *sched_clock_read_begin(unsigned int *seq)
 {
        *seq = raw_read_seqcount_latch(&cd.seq);
        return cd.read_data + (*seq & 1);
 }
 
-int sched_clock_read_retry(unsigned int seq)
+notrace int sched_clock_read_retry(unsigned int seq)
 {
        return read_seqcount_latch_retry(&cd.seq, seq);
 }
index de37e33a868dc0efa2c947804ebd7f4d01e07eba..c3ad64fb9d8bd12151cb460e9142976b2460d1f4 100644 (file)
@@ -732,11 +732,6 @@ static inline void debug_timer_deactivate(struct timer_list *timer)
        debug_object_deactivate(timer, &timer_debug_descr);
 }
 
-static inline void debug_timer_free(struct timer_list *timer)
-{
-       debug_object_free(timer, &timer_debug_descr);
-}
-
 static inline void debug_timer_assert_init(struct timer_list *timer)
 {
        debug_object_assert_init(timer, &timer_debug_descr);
index 7f45fd9d5a4504286176045051c6ef73806abfb7..dc83b3fa9fe7498885205cd234a163b1ffd375ed 100644 (file)
@@ -438,14 +438,16 @@ enum {
 };
 /*
  * Used for which event context the event is in.
- *  NMI     = 0
- *  IRQ     = 1
- *  SOFTIRQ = 2
- *  NORMAL  = 3
+ *  TRANSITION = 0
+ *  NMI     = 1
+ *  IRQ     = 2
+ *  SOFTIRQ = 3
+ *  NORMAL  = 4
  *
  * See trace_recursive_lock() comment below for more details.
  */
 enum {
+       RB_CTX_TRANSITION,
        RB_CTX_NMI,
        RB_CTX_IRQ,
        RB_CTX_SOFTIRQ,
@@ -3014,10 +3016,10 @@ rb_wakeups(struct trace_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer)
  * a bit of overhead in something as critical as function tracing,
  * we use a bitmask trick.
  *
- *  bit 0 =  NMI context
- *  bit 1 =  IRQ context
- *  bit 2 =  SoftIRQ context
- *  bit 3 =  normal context.
+ *  bit 1 =  NMI context
+ *  bit 2 =  IRQ context
+ *  bit 3 =  SoftIRQ context
+ *  bit 4 =  normal context.
  *
  * This works because this is the order of contexts that can
  * preempt other contexts. A SoftIRQ never preempts an IRQ
@@ -3040,6 +3042,30 @@ rb_wakeups(struct trace_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer)
  * The least significant bit can be cleared this way, and it
  * just so happens that it is the same bit corresponding to
  * the current context.
+ *
+ * Now the TRANSITION bit breaks the above slightly. The TRANSITION bit
+ * is set when a recursion is detected at the current context, and if
+ * the TRANSITION bit is already set, it will fail the recursion.
+ * This is needed because there's a lag between the changing of
+ * interrupt context and updating the preempt count. In this case,
+ * a false positive will be found. To handle this, one extra recursion
+ * is allowed, and this is done by the TRANSITION bit. If the TRANSITION
+ * bit is already set, then it is considered a recursion and the function
+ * ends. Otherwise, the TRANSITION bit is set, and that bit is returned.
+ *
+ * On the trace_recursive_unlock(), the TRANSITION bit will be the first
+ * to be cleared. Even if it wasn't the context that set it. That is,
+ * if an interrupt comes in while NORMAL bit is set and the ring buffer
+ * is called before preempt_count() is updated, since the check will
+ * be on the NORMAL bit, the TRANSITION bit will then be set. If an
+ * NMI then comes in, it will set the NMI bit, but when the NMI code
+ * does the trace_recursive_unlock() it will clear the TRANSTION bit
+ * and leave the NMI bit set. But this is fine, because the interrupt
+ * code that set the TRANSITION bit will then clear the NMI bit when it
+ * calls trace_recursive_unlock(). If another NMI comes in, it will
+ * set the TRANSITION bit and continue.
+ *
+ * Note: The TRANSITION bit only handles a single transition between context.
  */
 
 static __always_inline int
@@ -3055,8 +3081,16 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer)
                bit = pc & NMI_MASK ? RB_CTX_NMI :
                        pc & HARDIRQ_MASK ? RB_CTX_IRQ : RB_CTX_SOFTIRQ;
 
-       if (unlikely(val & (1 << (bit + cpu_buffer->nest))))
-               return 1;
+       if (unlikely(val & (1 << (bit + cpu_buffer->nest)))) {
+               /*
+                * It is possible that this was called by transitioning
+                * between interrupt context, and preempt_count() has not
+                * been updated yet. In this case, use the TRANSITION bit.
+                */
+               bit = RB_CTX_TRANSITION;
+               if (val & (1 << (bit + cpu_buffer->nest)))
+                       return 1;
+       }
 
        val |= (1 << (bit + cpu_buffer->nest));
        cpu_buffer->current_context = val;
@@ -3071,8 +3105,8 @@ trace_recursive_unlock(struct ring_buffer_per_cpu *cpu_buffer)
                cpu_buffer->current_context - (1 << cpu_buffer->nest);
 }
 
-/* The recursive locking above uses 4 bits */
-#define NESTED_BITS 4
+/* The recursive locking above uses 5 bits */
+#define NESTED_BITS 5
 
 /**
  * ring_buffer_nest_start - Allow to trace while nested
index 528971714fc65d30346c6fb0f4d2d05b0457f1a3..410cfeb16db518b4032b7fc997650adb0d8751dd 100644 (file)
@@ -2750,7 +2750,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb,
        /*
         * If tracing is off, but we have triggers enabled
         * we still need to look at the event data. Use the temp_buffer
-        * to store the trace event for the tigger to use. It's recusive
+        * to store the trace event for the trigger to use. It's recursive
         * safe and will not be recorded anywhere.
         */
        if (!entry && trace_file->flags & EVENT_FILE_FL_TRIGGER_COND) {
@@ -2952,7 +2952,7 @@ static void __ftrace_trace_stack(struct trace_buffer *buffer,
        stackidx = __this_cpu_inc_return(ftrace_stack_reserve) - 1;
 
        /* This should never happen. If it does, yell once and skip */
-       if (WARN_ON_ONCE(stackidx > FTRACE_KSTACK_NESTING))
+       if (WARN_ON_ONCE(stackidx >= FTRACE_KSTACK_NESTING))
                goto out;
 
        /*
@@ -3132,7 +3132,7 @@ static char *get_trace_buf(void)
 
        /* Interrupts must see nesting incremented before we use the buffer */
        barrier();
-       return &buffer->buffer[buffer->nesting][0];
+       return &buffer->buffer[buffer->nesting - 1][0];
 }
 
 static void put_trace_buf(void)
index f3f5e77123ad75d284fd99d7a3bf6e4e43386f39..1dadef445cd1e860cc68142fe8a6e657eae81fff 100644 (file)
@@ -637,6 +637,12 @@ enum {
         * function is called to clear it.
         */
        TRACE_GRAPH_NOTRACE_BIT,
+
+       /*
+        * When transitioning between context, the preempt_count() may
+        * not be correct. Allow for a single recursion to cover this case.
+        */
+       TRACE_TRANSITION_BIT,
 };
 
 #define trace_recursion_set(bit)       do { (current)->trace_recursion |= (1<<(bit)); } while (0)
@@ -691,14 +697,27 @@ static __always_inline int trace_test_and_set_recursion(int start, int max)
                return 0;
 
        bit = trace_get_context_bit() + start;
-       if (unlikely(val & (1 << bit)))
-               return -1;
+       if (unlikely(val & (1 << bit))) {
+               /*
+                * It could be that preempt_count has not been updated during
+                * a switch between contexts. Allow for a single recursion.
+                */
+               bit = TRACE_TRANSITION_BIT;
+               if (trace_recursion_test(bit))
+                       return -1;
+               trace_recursion_set(bit);
+               barrier();
+               return bit + 1;
+       }
+
+       /* Normal check passed, clear the transition to allow it again */
+       trace_recursion_clear(TRACE_TRANSITION_BIT);
 
        val |= 1 << bit;
        current->trace_recursion = val;
        barrier();
 
-       return bit;
+       return bit + 1;
 }
 
 static __always_inline void trace_clear_recursion(int bit)
@@ -708,6 +727,7 @@ static __always_inline void trace_clear_recursion(int bit)
        if (!bit)
                return;
 
+       bit--;
        bit = 1 << bit;
        val &= ~bit;
 
index 3212e2c653b35c1eac5a20d496f319465adff124..881df991742ab18c3f38fbf86886e4ef5a6fec62 100644 (file)
@@ -584,7 +584,8 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
 {
        struct synth_field *field;
        const char *prefix = NULL, *field_type = argv[0], *field_name, *array;
-       int len, ret = 0;
+       int len, ret = -ENOMEM;
+       struct seq_buf s;
        ssize_t size;
 
        if (field_type[0] == ';')
@@ -616,10 +617,9 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
                len--;
 
        field->name = kmemdup_nul(field_name, len, GFP_KERNEL);
-       if (!field->name) {
-               ret = -ENOMEM;
+       if (!field->name)
                goto free;
-       }
+
        if (!is_good_name(field->name)) {
                synth_err(SYNTH_ERR_BAD_NAME, errpos(field_name));
                ret = -EINVAL;
@@ -630,29 +630,29 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
                field_type++;
        len = strlen(field_type) + 1;
 
-        if (array) {
-                int l = strlen(array);
+       if (array)
+               len += strlen(array);
 
-                if (l && array[l - 1] == ';')
-                        l--;
-                len += l;
-        }
        if (prefix)
                len += strlen(prefix);
 
        field->type = kzalloc(len, GFP_KERNEL);
-       if (!field->type) {
-               ret = -ENOMEM;
+       if (!field->type)
                goto free;
-       }
+
+       seq_buf_init(&s, field->type, len);
        if (prefix)
-               strcat(field->type, prefix);
-       strcat(field->type, field_type);
+               seq_buf_puts(&s, prefix);
+       seq_buf_puts(&s, field_type);
        if (array) {
-               strcat(field->type, array);
-               if (field->type[len - 1] == ';')
-                       field->type[len - 1] = '\0';
+               seq_buf_puts(&s, array);
+               if (s.buffer[s.len - 1] == ';')
+                       s.len--;
        }
+       if (WARN_ON_ONCE(!seq_buf_buffer_left(&s)))
+               goto free;
+
+       s.buffer[s.len] = '\0';
 
        size = synth_field_size(field->type);
        if (size < 0) {
@@ -663,14 +663,19 @@ static struct synth_field *parse_synth_field(int argc, const char **argv,
                if (synth_field_is_string(field->type)) {
                        char *type;
 
-                       type = kzalloc(sizeof("__data_loc ") + strlen(field->type) + 1, GFP_KERNEL);
-                       if (!type) {
-                               ret = -ENOMEM;
+                       len = sizeof("__data_loc ") + strlen(field->type) + 1;
+                       type = kzalloc(len, GFP_KERNEL);
+                       if (!type)
                                goto free;
-                       }
 
-                       strcat(type, "__data_loc ");
-                       strcat(type, field->type);
+                       seq_buf_init(&s, type, len);
+                       seq_buf_puts(&s, "__data_loc ");
+                       seq_buf_puts(&s, field->type);
+
+                       if (WARN_ON_ONCE(!seq_buf_buffer_left(&s)))
+                               goto free;
+                       s.buffer[s.len] = '\0';
+
                        kfree(field->type);
                        field->type = type;
 
index b5e3496cf8033df69a33307db09a8bd0f34bca2e..4738ad48a66740fb72d77872a34b58f0a41f98f3 100644 (file)
@@ -492,8 +492,13 @@ trace_selftest_function_recursion(void)
        unregister_ftrace_function(&test_rec_probe);
 
        ret = -1;
-       if (trace_selftest_recursion_cnt != 1) {
-               pr_cont("*callback not called once (%d)* ",
+       /*
+        * Recursion allows for transitions between context,
+        * and may call the callback twice.
+        */
+       if (trace_selftest_recursion_cnt != 1 &&
+           trace_selftest_recursion_cnt != 2) {
+               pr_cont("*callback not called once (or twice) (%d)* ",
                        trace_selftest_recursion_cnt);
                goto out;
        }
index 26efd22f063396dc6c488da618c54020ecea682a..3f659f8550741011273a10c89b5053c474b66614 100644 (file)
@@ -50,7 +50,7 @@ static bool ok_to_free_tracepoints;
  */
 struct tp_probes {
        struct rcu_head rcu;
-       struct tracepoint_func probes[0];
+       struct tracepoint_func probes[];
 };
 
 static inline void *allocate_probes(int count)
index d7a7bc3b6098287dc7af87b2c94d5304675401f3..c789b39ed527173219adefcca72f0f7778d15aa2 100644 (file)
@@ -2446,4 +2446,6 @@ config HYPERV_TESTING
 
 endmenu # "Kernel Testing and Coverage"
 
+source "Documentation/Kconfig"
+
 endmenu # Kernel hacking
index 97d6a57cefcc5d281a7c75e8fff8ae4bdbac1a05..61ddce2cff77749e254188ed07e339a4812274dd 100644 (file)
@@ -683,7 +683,6 @@ static int __init crc32c_test(void)
 
        /* reduce OS noise */
        local_irq_save(flags);
-       local_irq_disable();
 
        nsec = ktime_get_ns();
        for (i = 0; i < 100; i++) {
@@ -694,7 +693,6 @@ static int __init crc32c_test(void)
        nsec = ktime_get_ns() - nsec;
 
        local_irq_restore(flags);
-       local_irq_enable();
 
        pr_info("crc32c: CRC_LE_BITS = %d\n", CRC_LE_BITS);
 
@@ -768,7 +766,6 @@ static int __init crc32_test(void)
 
        /* reduce OS noise */
        local_irq_save(flags);
-       local_irq_disable();
 
        nsec = ktime_get_ns();
        for (i = 0; i < 100; i++) {
@@ -783,7 +780,6 @@ static int __init crc32_test(void)
        nsec = ktime_get_ns() - nsec;
 
        local_irq_restore(flags);
-       local_irq_enable();
 
        pr_info("crc32: CRC_LE_BITS = %d, CRC_BE BITS = %d\n",
                 CRC_LE_BITS, CRC_BE_BITS);
index 0e2deac97da0dc251ff22cb91ea22947750318a5..e02f9df24d1ee1e5f02d9ff6e4e4b356c3e346e1 100644 (file)
@@ -8,7 +8,7 @@
 
 #define FONTDATAMAX 9216
 
-static struct font_data fontdata_10x18 = {
+static const struct font_data fontdata_10x18 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, 0x00, /* 0000000000 */
index 87da8acd07db0c2700ca311820ff1f244ec72bde..6e3c4b7691c85e0a12f7c3209ede7e6c17a7226f 100644 (file)
@@ -3,7 +3,7 @@
 
 #define FONTDATAMAX 2560
 
-static struct font_data fontdata_6x10 = {
+static const struct font_data fontdata_6x10 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 00000000 */
index 5e975dfa10a53a3dd257738f8cc5c1340dd0cbe6..2d22a24e816f0d80f59a9e1e109be624ebe7cf5c 100644 (file)
@@ -9,7 +9,7 @@
 
 #define FONTDATAMAX (11*256)
 
-static struct font_data fontdata_6x11 = {
+static const struct font_data fontdata_6x11 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 00000000 */
index 700039a9ceaec00a5316dcd3b443ab43ca737b08..e7442a0d183dc5aee0d16c89a99d2afaed905b71 100644 (file)
@@ -3,7 +3,7 @@
 
 #define FONTDATAMAX 2048
 
-static struct font_data fontdata_6x8 = {
+static const struct font_data fontdata_6x8 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 000000 */
index 86d298f38505886cc36c4af28ba0107b1dc7a1de..9cc7ae2e03f7d23c5f0e2584494ddf7a6609517e 100644 (file)
@@ -8,7 +8,7 @@
 
 #define FONTDATAMAX 3584
 
-static struct font_data fontdata_7x14 = {
+static const struct font_data fontdata_7x14 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 0000000 */
index 37cedd36ca5ef236d544eb70e09ead940de97e5f..bab25dc59e8ddf785668851da1a313ced23233f3 100644 (file)
@@ -10,7 +10,7 @@
 
 #define FONTDATAMAX 4096
 
-static struct font_data fontdata_8x16 = {
+static const struct font_data fontdata_8x16 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 00000000 */
index 8ab695538395df9f7c573a8d62aaa323b7bf35e4..109d0572368f445ce8950e5bebcdb857b58f389a 100644 (file)
@@ -9,7 +9,7 @@
 
 #define FONTDATAMAX 2048
 
-static struct font_data fontdata_8x8 = {
+static const struct font_data fontdata_8x8 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, /* 00000000 */
index 069b3e80c43449270f0937e60fe3c5dce1fdbdbd..fb395f0d40317f46f80445d3219f6d7fead87262 100644 (file)
@@ -5,7 +5,7 @@
 
 #define FONTDATAMAX 2048
 
-static struct font_data acorndata_8x8 = {
+static const struct font_data acorndata_8x8 = {
 { 0, 0, FONTDATAMAX, 0 }, {
 /* 00 */  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ^@ */
 /* 01 */  0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, /* ^A */
index 1449876c6a27027b7a3cb1af2c4bb2cbc1296917..592774a90917b450098477f334901943ff5c8389 100644 (file)
@@ -43,7 +43,7 @@ __END__;
 
 #define FONTDATAMAX 1536
 
-static struct font_data fontdata_mini_4x6 = {
+static const struct font_data fontdata_mini_4x6 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /*{*/
                /*   Char 0: ' '  */
index 32d65551e7ed29be9265cd73e4f48aee5d816934..a6f95ebce95077e2a0242533d5bca29c13a3dca1 100644 (file)
@@ -14,7 +14,7 @@
 
 #define FONTDATAMAX 2048
 
-static struct font_data fontdata_pearl8x8 = {
+static const struct font_data fontdata_pearl8x8 = {
    { 0, 0, FONTDATAMAX, 0 }, {
    /* 0 0x00 '^@' */
    0x00, /* 00000000 */
index 641a6b4dca424fb6843126d9d2cc6d1585d04d79..a5b65bd496045cc695cac6cc11d7488e99633a46 100644 (file)
@@ -3,7 +3,7 @@
 
 #define FONTDATAMAX 11264
 
-static struct font_data fontdata_sun12x22 = {
+static const struct font_data fontdata_sun12x22 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        /* 0 0x00 '^@' */
        0x00, 0x00, /* 000000000000 */
index 193fe6d988e08e95d1b172d34651ee920f4674a5..e577e76a6a7c0b7a0d0a8ed0586f4f649a444b38 100644 (file)
@@ -3,7 +3,7 @@
 
 #define FONTDATAMAX 4096
 
-static struct font_data fontdata_sun8x16 = {
+static const struct font_data fontdata_sun8x16 = {
 { 0, 0, FONTDATAMAX, 0 }, {
 /* */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 /* */ 0x00,0x00,0x7e,0x81,0xa5,0x81,0x81,0xbd,0x99,0x81,0x81,0x7e,0x00,0x00,0x00,0x00,
index 91b9c283bd9cc5f9f95504f909d10957ad450d7e..f7c3abb6b99e20c31c84b28a1d26f1612419bd0f 100644 (file)
@@ -4,7 +4,7 @@
 
 #define FONTDATAMAX 16384
 
-static struct font_data fontdata_ter16x32 = {
+static const struct font_data fontdata_ter16x32 = {
        { 0, 0, FONTDATAMAX, 0 }, {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x7f, 0xfc, 0x7f, 0xfc,
index 0a482ef988e56e87d77d40392092e894b29084ae..a5977894640434b909f63f852a21ec7ec14a6ee2 100644 (file)
@@ -933,7 +933,7 @@ size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents, void *buf,
        sg_miter_start(&miter, sgl, nents, sg_flags);
 
        if (!sg_miter_skip(&miter, skip))
-               return false;
+               return 0;
 
        while ((offset < buflen) && sg_miter_next(&miter)) {
                unsigned int len;
index 63c26171a791cf69bc223865a9ea49e25a886f61..662f862702fc8da9f3180adc48636360c6edad71 100644 (file)
@@ -216,6 +216,12 @@ static void kmalloc_oob_16(struct kunit *test)
                u64 words[2];
        } *ptr1, *ptr2;
 
+       /* This test is specifically crafted for the generic mode. */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_GENERIC required\n");
+               return;
+       }
+
        ptr1 = kmalloc(sizeof(*ptr1) - 3, GFP_KERNEL);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1);
 
@@ -227,6 +233,23 @@ static void kmalloc_oob_16(struct kunit *test)
        kfree(ptr2);
 }
 
+static void kmalloc_uaf_16(struct kunit *test)
+{
+       struct {
+               u64 words[2];
+       } *ptr1, *ptr2;
+
+       ptr1 = kmalloc(sizeof(*ptr1), GFP_KERNEL);
+       KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr1);
+
+       ptr2 = kmalloc(sizeof(*ptr2), GFP_KERNEL);
+       KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr2);
+       kfree(ptr2);
+
+       KUNIT_EXPECT_KASAN_FAIL(test, *ptr1 = *ptr2);
+       kfree(ptr1);
+}
+
 static void kmalloc_oob_memset_2(struct kunit *test)
 {
        char *ptr;
@@ -429,6 +452,12 @@ static void kasan_global_oob(struct kunit *test)
        volatile int i = 3;
        char *p = &global_array[ARRAY_SIZE(global_array) + i];
 
+       /* Only generic mode instruments globals. */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_GENERIC required");
+               return;
+       }
+
        KUNIT_EXPECT_KASAN_FAIL(test, *(volatile char *)p);
 }
 
@@ -467,6 +496,12 @@ static void kasan_alloca_oob_left(struct kunit *test)
        char alloca_array[i];
        char *p = alloca_array - 1;
 
+       /* Only generic mode instruments dynamic allocas. */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_GENERIC required");
+               return;
+       }
+
        if (!IS_ENABLED(CONFIG_KASAN_STACK)) {
                kunit_info(test, "CONFIG_KASAN_STACK is not enabled");
                return;
@@ -481,6 +516,12 @@ static void kasan_alloca_oob_right(struct kunit *test)
        char alloca_array[i];
        char *p = alloca_array + i;
 
+       /* Only generic mode instruments dynamic allocas. */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_GENERIC required");
+               return;
+       }
+
        if (!IS_ENABLED(CONFIG_KASAN_STACK)) {
                kunit_info(test, "CONFIG_KASAN_STACK is not enabled");
                return;
@@ -551,6 +592,9 @@ static void kasan_memchr(struct kunit *test)
                return;
        }
 
+       if (OOB_TAG_OFF)
+               size = round_up(size, OOB_TAG_OFF);
+
        ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
 
@@ -573,6 +617,9 @@ static void kasan_memcmp(struct kunit *test)
                return;
        }
 
+       if (OOB_TAG_OFF)
+               size = round_up(size, OOB_TAG_OFF);
+
        ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr);
        memset(arr, 0, sizeof(arr));
@@ -619,13 +666,50 @@ static void kasan_strings(struct kunit *test)
        KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = strnlen(ptr, 1));
 }
 
-static void kasan_bitops(struct kunit *test)
+static void kasan_bitops_modify(struct kunit *test, int nr, void *addr)
+{
+       KUNIT_EXPECT_KASAN_FAIL(test, set_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __set_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, clear_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __clear_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, clear_bit_unlock(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __clear_bit_unlock(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, change_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __change_bit(nr, addr));
+}
+
+static void kasan_bitops_test_and_modify(struct kunit *test, int nr, void *addr)
+{
+       KUNIT_EXPECT_KASAN_FAIL(test, test_and_set_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __test_and_set_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, test_and_set_bit_lock(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, test_and_clear_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __test_and_clear_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, test_and_change_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, __test_and_change_bit(nr, addr));
+       KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result = test_bit(nr, addr));
+
+#if defined(clear_bit_unlock_is_negative_byte)
+       KUNIT_EXPECT_KASAN_FAIL(test, kasan_int_result =
+                               clear_bit_unlock_is_negative_byte(nr, addr));
+#endif
+}
+
+static void kasan_bitops_generic(struct kunit *test)
 {
+       long *bits;
+
+       /* This test is specifically crafted for the generic mode. */
+       if (!IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_GENERIC required\n");
+               return;
+       }
+
        /*
         * Allocate 1 more byte, which causes kzalloc to round up to 16-bytes;
         * this way we do not actually corrupt other memory.
         */
-       long *bits = kzalloc(sizeof(*bits) + 1, GFP_KERNEL);
+       bits = kzalloc(sizeof(*bits) + 1, GFP_KERNEL);
        KUNIT_ASSERT_NOT_ERR_OR_NULL(test, bits);
 
        /*
@@ -633,55 +717,34 @@ static void kasan_bitops(struct kunit *test)
         * below accesses are still out-of-bounds, since bitops are defined to
         * operate on the whole long the bit is in.
         */
-       KUNIT_EXPECT_KASAN_FAIL(test, set_bit(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, __set_bit(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, clear_bit(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, __clear_bit(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, clear_bit_unlock(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, __clear_bit_unlock(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, change_bit(BITS_PER_LONG, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test, __change_bit(BITS_PER_LONG, bits));
+       kasan_bitops_modify(test, BITS_PER_LONG, bits);
 
        /*
         * Below calls try to access bit beyond allocated memory.
         */
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               test_and_set_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               __test_and_set_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
-
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               test_and_set_bit_lock(BITS_PER_LONG + BITS_PER_BYTE, bits));
+       kasan_bitops_test_and_modify(test, BITS_PER_LONG + BITS_PER_BYTE, bits);
 
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               test_and_clear_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
+       kfree(bits);
+}
 
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               __test_and_clear_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
+static void kasan_bitops_tags(struct kunit *test)
+{
+       long *bits;
 
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               test_and_change_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
+       /* This test is specifically crafted for the tag-based mode. */
+       if (IS_ENABLED(CONFIG_KASAN_GENERIC)) {
+               kunit_info(test, "CONFIG_KASAN_SW_TAGS required\n");
+               return;
+       }
 
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               __test_and_change_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
+       /* Allocation size will be rounded to up granule size, which is 16. */
+       bits = kzalloc(sizeof(*bits), GFP_KERNEL);
+       KUNIT_ASSERT_NOT_ERR_OR_NULL(test, bits);
 
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               kasan_int_result =
-                       test_bit(BITS_PER_LONG + BITS_PER_BYTE, bits));
+       /* Do the accesses past the 16 allocated bytes. */
+       kasan_bitops_modify(test, BITS_PER_LONG, &bits[1]);
+       kasan_bitops_test_and_modify(test, BITS_PER_LONG + BITS_PER_BYTE, &bits[1]);
 
-#if defined(clear_bit_unlock_is_negative_byte)
-       KUNIT_EXPECT_KASAN_FAIL(test,
-               kasan_int_result = clear_bit_unlock_is_negative_byte(
-                       BITS_PER_LONG + BITS_PER_BYTE, bits));
-#endif
        kfree(bits);
 }
 
@@ -728,6 +791,7 @@ static struct kunit_case kasan_kunit_test_cases[] = {
        KUNIT_CASE(kmalloc_oob_krealloc_more),
        KUNIT_CASE(kmalloc_oob_krealloc_less),
        KUNIT_CASE(kmalloc_oob_16),
+       KUNIT_CASE(kmalloc_uaf_16),
        KUNIT_CASE(kmalloc_oob_in_memset),
        KUNIT_CASE(kmalloc_oob_memset_2),
        KUNIT_CASE(kmalloc_oob_memset_4),
@@ -751,7 +815,8 @@ static struct kunit_case kasan_kunit_test_cases[] = {
        KUNIT_CASE(kasan_memchr),
        KUNIT_CASE(kasan_memcmp),
        KUNIT_CASE(kasan_strings),
-       KUNIT_CASE(kasan_bitops),
+       KUNIT_CASE(kasan_bitops_generic),
+       KUNIT_CASE(kasan_bitops_tags),
        KUNIT_CASE(kmalloc_double_kzfree),
        KUNIT_CASE(vmalloc_oob),
        {}
index fe76f8fd5a732c5f1301fab8600dd081cdc4498e..5a620f6909114792a7e1698adab010f1a59b4f6a 100644 (file)
@@ -648,6 +648,8 @@ retry:
                        }
 
                        del += t - f;
+                       hugetlb_cgroup_uncharge_file_region(
+                               resv, rg, t - f);
 
                        /* New entry for end of split region */
                        nrg->from = t;
@@ -660,9 +662,6 @@ retry:
                        /* Original entry is trimmed */
                        rg->to = f;
 
-                       hugetlb_cgroup_uncharge_file_region(
-                               resv, rg, nrg->to - nrg->from);
-
                        list_add(&nrg->link, &rg->link);
                        nrg = NULL;
                        break;
@@ -678,17 +677,17 @@ retry:
                }
 
                if (f <= rg->from) {    /* Trim beginning of region */
-                       del += t - rg->from;
-                       rg->from = t;
-
                        hugetlb_cgroup_uncharge_file_region(resv, rg,
                                                            t - rg->from);
-               } else {                /* Trim end of region */
-                       del += rg->to - f;
-                       rg->to = f;
 
+                       del += t - rg->from;
+                       rg->from = t;
+               } else {                /* Trim end of region */
                        hugetlb_cgroup_uncharge_file_region(resv, rg,
                                                            rg->to - f);
+
+                       del += rg->to - f;
+                       rg->to = f;
                }
        }
 
@@ -2443,6 +2442,9 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,
 
                rsv_adjust = hugepage_subpool_put_pages(spool, 1);
                hugetlb_acct_memory(h, -rsv_adjust);
+               if (deferred_reserve)
+                       hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h),
+                                       pages_per_huge_page(h), page);
        }
        return page;
 
index 3a24e3b619f567efc5f0c5625974c0da854edcae..3dcbf24d2227a3350e855f5fd3015a0cbc20e070 100644 (file)
@@ -4110,11 +4110,17 @@ static int memcg_stat_show(struct seq_file *m, void *v)
                           (u64)memsw * PAGE_SIZE);
 
        for (i = 0; i < ARRAY_SIZE(memcg1_stats); i++) {
+               unsigned long nr;
+
                if (memcg1_stats[i] == MEMCG_SWAP && !do_memsw_account())
                        continue;
+               nr = memcg_page_state(memcg, memcg1_stats[i]);
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+               if (memcg1_stats[i] == NR_ANON_THPS)
+                       nr *= HPAGE_PMD_NR;
+#endif
                seq_printf(m, "total_%s %llu\n", memcg1_stat_names[i],
-                          (u64)memcg_page_state(memcg, memcg1_stats[i]) *
-                          PAGE_SIZE);
+                                               (u64)nr * PAGE_SIZE);
        }
 
        for (i = 0; i < ARRAY_SIZE(memcg1_events); i++)
@@ -5339,17 +5345,22 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
                memcg->swappiness = mem_cgroup_swappiness(parent);
                memcg->oom_kill_disable = parent->oom_kill_disable;
        }
-       if (parent && parent->use_hierarchy) {
+       if (!parent) {
+               page_counter_init(&memcg->memory, NULL);
+               page_counter_init(&memcg->swap, NULL);
+               page_counter_init(&memcg->kmem, NULL);
+               page_counter_init(&memcg->tcpmem, NULL);
+       } else if (parent->use_hierarchy) {
                memcg->use_hierarchy = true;
                page_counter_init(&memcg->memory, &parent->memory);
                page_counter_init(&memcg->swap, &parent->swap);
                page_counter_init(&memcg->kmem, &parent->kmem);
                page_counter_init(&memcg->tcpmem, &parent->tcpmem);
        } else {
-               page_counter_init(&memcg->memory, NULL);
-               page_counter_init(&memcg->swap, NULL);
-               page_counter_init(&memcg->kmem, NULL);
-               page_counter_init(&memcg->tcpmem, NULL);
+               page_counter_init(&memcg->memory, &root_mem_cgroup->memory);
+               page_counter_init(&memcg->swap, &root_mem_cgroup->swap);
+               page_counter_init(&memcg->kmem, &root_mem_cgroup->kmem);
+               page_counter_init(&memcg->tcpmem, &root_mem_cgroup->tcpmem);
                /*
                 * Deeper hierachy with use_hierarchy == false doesn't make
                 * much sense so let cgroup subsystem know about this
index 3fde772ef5ef5bdb297869844ef4f616ebd90bae..3ca4898f3f249f3e18bcf7ed4f3d49cfdf0ef439 100644 (file)
@@ -525,7 +525,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
        unsigned long flags = qp->flags;
        int ret;
        bool has_unmovable = false;
-       pte_t *pte;
+       pte_t *pte, *mapped_pte;
        spinlock_t *ptl;
 
        ptl = pmd_trans_huge_lock(pmd, vma);
@@ -539,7 +539,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
        if (pmd_trans_unstable(pmd))
                return 0;
 
-       pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
+       mapped_pte = pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
        for (; addr != end; pte++, addr += PAGE_SIZE) {
                if (!pte_present(*pte))
                        continue;
@@ -571,7 +571,7 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
                } else
                        break;
        }
-       pte_unmap_unlock(pte - 1, ptl);
+       pte_unmap_unlock(mapped_pte, ptl);
        cond_resched();
 
        if (has_unmovable)
index 73a206d0f64542e0f28a52da3b52ce3c7b4635ae..16b2fb482da11245092e732c858264ada92d2364 100644 (file)
@@ -41,28 +41,24 @@ EXPORT_SYMBOL_GPL(memremap_compat_align);
 DEFINE_STATIC_KEY_FALSE(devmap_managed_key);
 EXPORT_SYMBOL(devmap_managed_key);
 
-static void devmap_managed_enable_put(void)
+static void devmap_managed_enable_put(struct dev_pagemap *pgmap)
 {
-       static_branch_dec(&devmap_managed_key);
+       if (pgmap->type == MEMORY_DEVICE_PRIVATE ||
+           pgmap->type == MEMORY_DEVICE_FS_DAX)
+               static_branch_dec(&devmap_managed_key);
 }
 
-static int devmap_managed_enable_get(struct dev_pagemap *pgmap)
+static void devmap_managed_enable_get(struct dev_pagemap *pgmap)
 {
-       if (pgmap->type == MEMORY_DEVICE_PRIVATE &&
-           (!pgmap->ops || !pgmap->ops->page_free)) {
-               WARN(1, "Missing page_free method\n");
-               return -EINVAL;
-       }
-
-       static_branch_inc(&devmap_managed_key);
-       return 0;
+       if (pgmap->type == MEMORY_DEVICE_PRIVATE ||
+           pgmap->type == MEMORY_DEVICE_FS_DAX)
+               static_branch_inc(&devmap_managed_key);
 }
 #else
-static int devmap_managed_enable_get(struct dev_pagemap *pgmap)
+static void devmap_managed_enable_get(struct dev_pagemap *pgmap)
 {
-       return -EINVAL;
 }
-static void devmap_managed_enable_put(void)
+static void devmap_managed_enable_put(struct dev_pagemap *pgmap)
 {
 }
 #endif /* CONFIG_DEV_PAGEMAP_OPS */
@@ -169,7 +165,7 @@ void memunmap_pages(struct dev_pagemap *pgmap)
                pageunmap_range(pgmap, i);
 
        WARN_ONCE(pgmap->altmap.alloc, "failed to free all reserved pages\n");
-       devmap_managed_enable_put();
+       devmap_managed_enable_put(pgmap);
 }
 EXPORT_SYMBOL_GPL(memunmap_pages);
 
@@ -307,7 +303,6 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
                .pgprot = PAGE_KERNEL,
        };
        const int nr_range = pgmap->nr_range;
-       bool need_devmap_managed = true;
        int error, i;
 
        if (WARN_ONCE(!nr_range, "nr_range must be specified\n"))
@@ -323,6 +318,10 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
                        WARN(1, "Missing migrate_to_ram method\n");
                        return ERR_PTR(-EINVAL);
                }
+               if (!pgmap->ops->page_free) {
+                       WARN(1, "Missing page_free method\n");
+                       return ERR_PTR(-EINVAL);
+               }
                if (!pgmap->owner) {
                        WARN(1, "Missing owner\n");
                        return ERR_PTR(-EINVAL);
@@ -336,11 +335,9 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
                }
                break;
        case MEMORY_DEVICE_GENERIC:
-               need_devmap_managed = false;
                break;
        case MEMORY_DEVICE_PCI_P2PDMA:
                params.pgprot = pgprot_noncached(params.pgprot);
-               need_devmap_managed = false;
                break;
        default:
                WARN(1, "Invalid pgmap type %d\n", pgmap->type);
@@ -364,11 +361,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
                }
        }
 
-       if (need_devmap_managed) {
-               error = devmap_managed_enable_get(pgmap);
-               if (error)
-                       return ERR_PTR(error);
-       }
+       devmap_managed_enable_get(pgmap);
 
        /*
         * Clear the pgmap nr_range as it will be incremented for each
index fd12da80b6f27bab90763d9cca7c43d38f226b06..702250f148e73adc34a6d036c33cdaaedd46b924 100644 (file)
@@ -5,6 +5,7 @@
  * Copyright (C) 2010-2011 Christopher Yeoh <cyeoh@au1.ibm.com>, IBM Corp.
  */
 
+#include <linux/compat.h>
 #include <linux/mm.h>
 #include <linux/uio.h>
 #include <linux/sched.h>
@@ -273,7 +274,8 @@ static ssize_t process_vm_rw(pid_t pid,
                return rc;
        if (!iov_iter_count(&iter))
                goto free_iov_l;
-       iov_r = iovec_from_user(rvec, riovcnt, UIO_FASTIOV, iovstack_r, false);
+       iov_r = iovec_from_user(rvec, riovcnt, UIO_FASTIOV, iovstack_r,
+                               in_compat_syscall());
        if (IS_ERR(iov_r)) {
                rc = PTR_ERR(iov_r);
                goto free_iov_l;
index 18cec39a9f53e48447e278785c2e6443f9357afa..960edf5803ca97fa22e94d65ff76be49b8d4be3b 100644 (file)
@@ -528,7 +528,7 @@ void truncate_inode_pages_final(struct address_space *mapping)
 }
 EXPORT_SYMBOL(truncate_inode_pages_final);
 
-unsigned long __invalidate_mapping_pages(struct address_space *mapping,
+static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
                pgoff_t start, pgoff_t end, unsigned long *nr_pagevec)
 {
        pgoff_t indices[PAGEVEC_SIZE];
index dbabb65d8b6773acc95fc9047453ec0118da2ce1..7226c784dbe0c70e4d6899634cb3821ff5a61960 100644 (file)
@@ -954,9 +954,8 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        struct lec_state *state = seq->private;
 
-       v = lec_get_idx(state, 1);
-       *pos += !!PTR_ERR(v);
-       return v;
+       ++*pos;
+       return lec_get_idx(state, 1);
 }
 
 static int lec_seq_show(struct seq_file *seq, void *v)
index 8579bfeb283640a4c2a9f6154218d80c87d19660..4b39534a14a18cbd8f1a55d949a21aea20b45a01 100644 (file)
 struct msft_cp_read_supported_features {
        __u8   sub_opcode;
 } __packed;
+
 struct msft_rp_read_supported_features {
        __u8   status;
        __u8   sub_opcode;
        __le64 features;
        __u8   evt_prefix_len;
-       __u8   evt_prefix[0];
+       __u8   evt_prefix[];
 } __packed;
 
 struct msft_data {
index 224e5e0283a986d9444948122479977d8107d1e9..7c9958df91d353c8a86dcd61a0c99e557fbfa16a 100644 (file)
@@ -62,8 +62,9 @@ config CAN_ISOTP
          communication between CAN nodes via two defined CAN Identifiers.
          As CAN frames can only transport a small amount of data bytes
          (max. 8 bytes for 'classic' CAN and max. 64 bytes for CAN FD) this
-         segmentation is needed to transport longer PDUs as needed e.g. for
-         vehicle diagnosis (UDS, ISO 14229) or IP-over-CAN traffic.
+         segmentation is needed to transport longer Protocol Data Units (PDU)
+         as needed e.g. for vehicle diagnosis (UDS, ISO 14229) or IP-over-CAN
+         traffic.
          This protocol driver implements data transfers according to
          ISO 15765-2:2016 for 'classic' CAN and CAN FD frame types.
          If you want to perform automotive vehicle diagnostic services (UDS),
index 4c2062875893fd14c4c814bb8f787be75f6d1393..d78ab13bd8be99554a5d4873e4d6b7081cf289d3 100644 (file)
@@ -252,14 +252,16 @@ static void isotp_rcv_skb(struct sk_buff *skb, struct sock *sk)
 
 static u8 padlen(u8 datalen)
 {
-       const u8 plen[] = {8, 8, 8, 8, 8, 8, 8, 8, 8,           /* 0 - 8 */
-                          12, 12, 12, 12,                      /* 9 - 12 */
-                          16, 16, 16, 16,                      /* 13 - 16 */
-                          20, 20, 20, 20,                      /* 17 - 20 */
-                          24, 24, 24, 24,                      /* 21 - 24 */
-                          32, 32, 32, 32, 32, 32, 32, 32,      /* 25 - 32 */
-                          48, 48, 48, 48, 48, 48, 48, 48,      /* 33 - 40 */
-                          48, 48, 48, 48, 48, 48, 48, 48};     /* 41 - 48 */
+       static const u8 plen[] = {
+               8, 8, 8, 8, 8, 8, 8, 8, 8,      /* 0 - 8 */
+               12, 12, 12, 12,                 /* 9 - 12 */
+               16, 16, 16, 16,                 /* 13 - 16 */
+               20, 20, 20, 20,                 /* 17 - 20 */
+               24, 24, 24, 24,                 /* 21 - 24 */
+               32, 32, 32, 32, 32, 32, 32, 32, /* 25 - 32 */
+               48, 48, 48, 48, 48, 48, 48, 48, /* 33 - 40 */
+               48, 48, 48, 48, 48, 48, 48, 48  /* 41 - 48 */
+       };
 
        if (datalen > 48)
                return 64;
@@ -569,10 +571,6 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
                return 0;
        }
 
-       /* no creation of flow control frames */
-       if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
-               return 0;
-
        /* perform blocksize handling, if enabled */
        if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
                /* start rx timeout watchdog */
@@ -581,6 +579,10 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
                return 0;
        }
 
+       /* no creation of flow control frames */
+       if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)
+               return 0;
+
        /* we reached the specified blocksize so->rxfc.bs */
        isotp_send_fc(sk, ae, ISOTP_FC_CTS);
        return 0;
index 1be4c898b2fa884b96c3363a1dca09279f541e89..f23966526a88589d95fdc97143c0c4f8f4b99860 100644 (file)
@@ -475,6 +475,12 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
                        goto out_release_sock;
                }
 
+               if (!(ndev->flags & IFF_UP)) {
+                       dev_put(ndev);
+                       ret = -ENETDOWN;
+                       goto out_release_sock;
+               }
+
                priv = j1939_netdev_start(ndev);
                dev_put(ndev);
                if (IS_ERR(priv)) {
index 550928b8b8a2c988270411ffdad80ab1f5b9dc03..5ea8695f507eb650cb51e0a81ccd27bb67683e18 100644 (file)
@@ -462,6 +462,9 @@ void can_init_proc(struct net *net)
  */
 void can_remove_proc(struct net *net)
 {
+       if (!net->can.proc_dir)
+               return;
+
        if (net->can.pde_stats)
                remove_proc_entry(CAN_PROC_STATS, net->can.proc_dir);
 
@@ -486,6 +489,5 @@ void can_remove_proc(struct net *net)
        if (net->can.pde_rcvlist_sff)
                remove_proc_entry(CAN_PROC_RCVLIST_SFF, net->can.proc_dir);
 
-       if (net->can.proc_dir)
-               remove_proc_entry("can", net->proc_net);
+       remove_proc_entry("can", net->proc_net);
 }
index a578634052a3c77366bee7922e8fd16eee564ec7..a932d95be798474e660d9b2dd3849999da69264f 100644 (file)
@@ -4213,10 +4213,12 @@ static int devlink_nl_region_fill(struct sk_buff *msg, struct devlink *devlink,
        if (err)
                goto nla_put_failure;
 
-       if (region->port)
-               if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX,
-                               region->port->index))
+       if (region->port) {
+               err = nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX,
+                                 region->port->index);
+               if (err)
                        goto nla_put_failure;
+       }
 
        err = nla_put_string(msg, DEVLINK_ATTR_REGION_NAME, region->ops->name);
        if (err)
@@ -4265,10 +4267,12 @@ devlink_nl_region_notify_build(struct devlink_region *region,
        if (err)
                goto out_cancel_msg;
 
-       if (region->port)
-               if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX,
-                               region->port->index))
+       if (region->port) {
+               err = nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX,
+                                 region->port->index);
+               if (err)
                        goto out_cancel_msg;
+       }
 
        err = nla_put_string(msg, DEVLINK_ATTR_REGION_NAME,
                             region->ops->name);
@@ -4915,8 +4919,10 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
                index = nla_get_u32(info->attrs[DEVLINK_ATTR_PORT_INDEX]);
 
                port = devlink_port_get_by_index(devlink, index);
-               if (!port)
-                       return -ENODEV;
+               if (!port) {
+                       err = -ENODEV;
+                       goto out_unlock;
+               }
        }
 
        region_name = nla_data(attrs[DEVLINK_ATTR_REGION_NAME]);
@@ -4962,10 +4968,12 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
        if (err)
                goto nla_put_failure;
 
-       if (region->port)
-               if (nla_put_u32(skb, DEVLINK_ATTR_PORT_INDEX,
-                               region->port->index))
+       if (region->port) {
+               err = nla_put_u32(skb, DEVLINK_ATTR_PORT_INDEX,
+                                 region->port->index);
+               if (err)
                        goto nla_put_failure;
+       }
 
        err = nla_put_string(skb, DEVLINK_ATTR_REGION_NAME, region_name);
        if (err)
index 8b04d1dcfec4eb5d0fb697497e0e5599ce8704f1..ee65c9225178d66948a7b70b3d243499eadbc168 100644 (file)
@@ -608,9 +608,6 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
                        ttl = ip4_dst_hoplimit(&rt->dst);
        }
 
-       if (!df && skb->protocol == htons(ETH_P_IP))
-               df = inner_iph->frag_off & htons(IP_DF);
-
        headroom += LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len;
        if (headroom > dev->needed_headroom)
                dev->needed_headroom = headroom;
index a058213b77a787a1aa1c0779ae9017932eaff785..7c841037c53349855f9711a70bd0ac333b8bd716 100644 (file)
 #include <net/netfilter/nf_queue.h>
 
 /* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */
-int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned int addr_type)
+int ip_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb, unsigned int addr_type)
 {
        const struct iphdr *iph = ip_hdr(skb);
        struct rtable *rt;
        struct flowi4 fl4 = {};
        __be32 saddr = iph->saddr;
-       const struct sock *sk = skb_to_full_sk(skb);
-       __u8 flags = sk ? inet_sk_flowi_flags(sk) : 0;
+       __u8 flags;
        struct net_device *dev = skb_dst(skb)->dev;
        unsigned int hh_len;
 
+       sk = sk_to_full_sk(sk);
+       flags = sk ? inet_sk_flowi_flags(sk) : 0;
+
        if (addr_type == RTN_UNSPEC)
                addr_type = inet_addr_type_dev_table(net, dev, saddr);
        if (addr_type == RTN_LOCAL || addr_type == RTN_UNICAST)
index f703a717ab1d23bdf94ee0b47d4182ddd7810a4c..83307958927307845951ef5cb2682f05e7b2024b 100644 (file)
@@ -62,7 +62,7 @@ ipt_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
                    iph->daddr != daddr ||
                    skb->mark != mark ||
                    iph->tos != tos) {
-                       err = ip_route_me_harder(state->net, skb, RTN_UNSPEC);
+                       err = ip_route_me_harder(state->net, state->sk, skb, RTN_UNSPEC);
                        if (err < 0)
                                ret = NF_DROP_ERR(err);
                }
index 9dcfa4e461b65aaada32b4d5e11946ae3ae919c8..93b07739807b270854e663b16ac103b159009d72 100644 (file)
@@ -145,7 +145,7 @@ void nf_send_reset(struct net *net, struct sk_buff *oldskb, int hook)
                                   ip4_dst_hoplimit(skb_dst(nskb)));
        nf_reject_ip_tcphdr_put(nskb, oldskb, oth);
 
-       if (ip_route_me_harder(net, nskb, RTN_UNSPEC))
+       if (ip_route_me_harder(net, nskb->sk, nskb, RTN_UNSPEC))
                goto free_nskb;
 
        niph = ip_hdr(nskb);
index bae4284bf542437fab45b32d5cb5a464d88a63ee..b2bc3d7fe9e806718f6e20ad9fa775ffb83806fb 100644 (file)
@@ -485,6 +485,8 @@ static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
                        return true;
                if (tcp_rmem_pressure(sk))
                        return true;
+               if (tcp_receive_window(tp) <= inet_csk(sk)->icsk_ack.rcv_mss)
+                       return true;
        }
        if (sk->sk_prot->stream_memory_read)
                return sk->sk_prot->stream_memory_read(sk);
index fc445833b5e508d20aa52ff68fb4b698b21c4cd7..389d1b34024854a9bdcbe861d4820d1bfb495e24 100644 (file)
@@ -4908,7 +4908,8 @@ void tcp_data_ready(struct sock *sk)
        int avail = tp->rcv_nxt - tp->copied_seq;
 
        if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) &&
-           !sock_flag(sk, SOCK_DONE))
+           !sock_flag(sk, SOCK_DONE) &&
+           tcp_receive_window(tp) > inet_csk(sk)->icsk_ack.rcv_mss)
                return;
 
        sk->sk_data_ready(sk);
index dc19aff7c2e0055711597d7dd423fd107cd21ef7..fb0648e7fb32f9b0715030b7eb0049df81f0deea 100644 (file)
@@ -64,14 +64,14 @@ static int xfrm_tunnel_err(struct sk_buff *skb, u32 info)
 static struct xfrm_tunnel xfrm_tunnel_handler __read_mostly = {
        .handler        =       xfrm_tunnel_rcv,
        .err_handler    =       xfrm_tunnel_err,
-       .priority       =       3,
+       .priority       =       4,
 };
 
 #if IS_ENABLED(CONFIG_IPV6)
 static struct xfrm_tunnel xfrm64_tunnel_handler __read_mostly = {
        .handler        =       xfrm_tunnel_rcv,
        .err_handler    =       xfrm_tunnel_err,
-       .priority       =       2,
+       .priority       =       3,
 };
 #endif
 
index ec448b71bf9ae7758c0d85a830bea5a408287e08..8956144ea65e8a8d64574cdb51fb09df41705170 100644 (file)
@@ -158,7 +158,13 @@ static bool is_ineligible(const struct sk_buff *skb)
                tp = skb_header_pointer(skb,
                        ptr+offsetof(struct icmp6hdr, icmp6_type),
                        sizeof(_type), &_type);
-               if (!tp || !(*tp & ICMPV6_INFOMSG_MASK))
+
+               /* Based on RFC 8200, Section 4.5 Fragment Header, return
+                * false if this is a fragment packet with no icmp header info.
+                */
+               if (!tp && frag_off != 0)
+                       return false;
+               else if (!tp || !(*tp & ICMPV6_INFOMSG_MASK))
                        return true;
        }
        return false;
index a0217e5bf3bc1132969e0ed7421cf5eceff54d69..648db3fe508f03f269b9a16bc2340f536ad6bb7c 100644 (file)
@@ -1271,6 +1271,8 @@ route_lookup:
        if (max_headroom > dev->needed_headroom)
                dev->needed_headroom = max_headroom;
 
+       skb_set_inner_ipproto(skb, proto);
+
        err = ip6_tnl_encap(skb, t, &proto, fl6);
        if (err)
                return err;
@@ -1280,8 +1282,6 @@ route_lookup:
                ipv6_push_frag_opts(skb, &opt.ops, &proto);
        }
 
-       skb_set_inner_ipproto(skb, proto);
-
        skb_push(skb, sizeof(struct ipv6hdr));
        skb_reset_network_header(skb);
        ipv6h = ipv6_hdr(skb);
index 6d0e942d082d4ec0f66cb97fb20a7c466a0a0dfa..ab9a279dd6d47d34a3ad68e7cb88d588f2c6eaef 100644 (file)
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 #include "../bridge/br_private.h"
 
-int ip6_route_me_harder(struct net *net, struct sk_buff *skb)
+int ip6_route_me_harder(struct net *net, struct sock *sk_partial, struct sk_buff *skb)
 {
        const struct ipv6hdr *iph = ipv6_hdr(skb);
-       struct sock *sk = sk_to_full_sk(skb->sk);
+       struct sock *sk = sk_to_full_sk(sk_partial);
        unsigned int hh_len;
        struct dst_entry *dst;
        int strict = (ipv6_addr_type(&iph->daddr) &
@@ -84,7 +84,7 @@ static int nf_ip6_reroute(struct sk_buff *skb,
                if (!ipv6_addr_equal(&iph->daddr, &rt_info->daddr) ||
                    !ipv6_addr_equal(&iph->saddr, &rt_info->saddr) ||
                    skb->mark != rt_info->mark)
-                       return ip6_route_me_harder(entry->state.net, skb);
+                       return ip6_route_me_harder(entry->state.net, entry->state.sk, skb);
        }
        return 0;
 }
index 1a2748611e00388abf30a4127a24adc516cdcd2e..cee74803d7a1ce649c01c71f4d7b6860ff156aa3 100644 (file)
@@ -57,7 +57,7 @@ ip6t_mangle_out(struct sk_buff *skb, const struct nf_hook_state *state)
             skb->mark != mark ||
             ipv6_hdr(skb)->hop_limit != hop_limit ||
             flowlabel != *((u_int32_t *)ipv6_hdr(skb)))) {
-               err = ip6_route_me_harder(state->net, skb);
+               err = ip6_route_me_harder(state->net, state->sk, skb);
                if (err < 0)
                        ret = NF_DROP_ERR(err);
        }
index 1f5d4d196dccee12ee979f305b1b904864ff246e..c8cf1bbad74a241f8867ca41328406bcd06e0c35 100644 (file)
@@ -42,6 +42,8 @@
 #include <linux/skbuff.h>
 #include <linux/slab.h>
 #include <linux/export.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
@@ -322,7 +324,9 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
        struct frag_queue *fq;
        const struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct net *net = dev_net(skb_dst(skb)->dev);
-       int iif;
+       __be16 frag_off;
+       int iif, offset;
+       u8 nexthdr;
 
        if (IP6CB(skb)->flags & IP6SKB_FRAGMENTED)
                goto fail_hdr;
@@ -351,6 +355,33 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
                return 1;
        }
 
+       /* RFC 8200, Section 4.5 Fragment Header:
+        * If the first fragment does not include all headers through an
+        * Upper-Layer header, then that fragment should be discarded and
+        * an ICMP Parameter Problem, Code 3, message should be sent to
+        * the source of the fragment, with the Pointer field set to zero.
+        */
+       nexthdr = hdr->nexthdr;
+       offset = ipv6_skip_exthdr(skb, skb_transport_offset(skb), &nexthdr, &frag_off);
+       if (offset >= 0) {
+               /* Check some common protocols' header */
+               if (nexthdr == IPPROTO_TCP)
+                       offset += sizeof(struct tcphdr);
+               else if (nexthdr == IPPROTO_UDP)
+                       offset += sizeof(struct udphdr);
+               else if (nexthdr == IPPROTO_ICMPV6)
+                       offset += sizeof(struct icmp6hdr);
+               else
+                       offset += 1;
+
+               if (!(frag_off & htons(IP6_OFFSET)) && offset > skb->len) {
+                       __IP6_INC_STATS(net, __in6_dev_get_safely(skb->dev),
+                                       IPSTATS_MIB_INHDRERRORS);
+                       icmpv6_param_prob(skb, ICMPV6_HDR_INCOMP, 0);
+                       return -1;
+               }
+       }
+
        iif = skb->dev ? skb->dev->ifindex : 0;
        fq = fq_find(net, fhdr->identification, hdr, iif);
        if (fq) {
index 25b7ebda2fabf157ecd1a12972e6d1cd28a1cc48..f696d46e6910068d1c15b487f7e68feecad5452a 100644 (file)
@@ -303,13 +303,13 @@ static const struct xfrm_type xfrm6_tunnel_type = {
 static struct xfrm6_tunnel xfrm6_tunnel_handler __read_mostly = {
        .handler        = xfrm6_tunnel_rcv,
        .err_handler    = xfrm6_tunnel_err,
-       .priority       = 2,
+       .priority       = 3,
 };
 
 static struct xfrm6_tunnel xfrm46_tunnel_handler __read_mostly = {
        .handler        = xfrm6_tunnel_rcv,
        .err_handler    = xfrm6_tunnel_err,
-       .priority       = 2,
+       .priority       = 3,
 };
 
 static int __net_init xfrm6_tunnel_net_init(struct net *net)
index f400240a556f571229b5d1e9f112de3753971082..6adfcb9c06dcc516cf215cdc5b0ea7ed1524099e 100644 (file)
@@ -5464,6 +5464,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
                        struct cfg80211_assoc_request *req)
 {
        bool is_6ghz = req->bss->channel->band == NL80211_BAND_6GHZ;
+       bool is_5ghz = req->bss->channel->band == NL80211_BAND_5GHZ;
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
        struct ieee80211_bss *bss = (void *)req->bss->priv;
@@ -5616,7 +5617,7 @@ int ieee80211_mgd_assoc(struct ieee80211_sub_if_data *sdata,
        if (vht_ie && vht_ie[1] >= sizeof(struct ieee80211_vht_cap))
                memcpy(&assoc_data->ap_vht_cap, vht_ie + 2,
                       sizeof(struct ieee80211_vht_cap));
-       else if (!is_6ghz)
+       else if (is_5ghz)
                ifmgd->flags |= IEEE80211_STA_DISABLE_VHT |
                                IEEE80211_STA_DISABLE_HE;
        rcu_read_unlock();
index fb4f2b9b294f03cc3aa28dbf2f5d11e78c0936a0..4fe284ff1ea3d702e175fbedf689a276b0034941 100644 (file)
@@ -258,6 +258,24 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata,
  */
 void sta_info_free(struct ieee80211_local *local, struct sta_info *sta)
 {
+       /*
+        * If we had used sta_info_pre_move_state() then we might not
+        * have gone through the state transitions down again, so do
+        * it here now (and warn if it's inserted).
+        *
+        * This will clear state such as fast TX/RX that may have been
+        * allocated during state transitions.
+        */
+       while (sta->sta_state > IEEE80211_STA_NONE) {
+               int ret;
+
+               WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED));
+
+               ret = sta_info_move_state(sta, sta->sta_state - 1);
+               if (WARN_ONCE(ret, "sta_info_move_state() returned %d\n", ret))
+                       break;
+       }
+
        if (sta->rate_ctrl)
                rate_control_free_sta(sta);
 
index 00ae81e9e1a12d9756a39b490e53a6b300d1f28f..7afd07636b81da4fcc12b702a8af852d7eb80b2b 100644 (file)
@@ -785,7 +785,7 @@ int sta_info_init(struct ieee80211_local *local);
 void sta_info_stop(struct ieee80211_local *local);
 
 /**
- * sta_info_flush - flush matching STA entries from the STA table
+ * __sta_info_flush - flush matching STA entries from the STA table
  *
  * Returns the number of removed STA entries.
  *
@@ -794,6 +794,13 @@ void sta_info_stop(struct ieee80211_local *local);
  */
 int __sta_info_flush(struct ieee80211_sub_if_data *sdata, bool vlans);
 
+/**
+ * sta_info_flush - flush matching STA entries from the STA table
+ *
+ * Returns the number of removed STA entries.
+ *
+ * @sdata: sdata to remove all stations from
+ */
 static inline int sta_info_flush(struct ieee80211_sub_if_data *sdata)
 {
        return __sta_info_flush(sdata, false);
index 8ba10a48ded4cab1c80e7da7026b2c19a3941035..56a4d0d20a267a9cadf246945f0373ddea39a1a7 100644 (file)
@@ -1942,19 +1942,24 @@ static bool ieee80211_tx(struct ieee80211_sub_if_data *sdata,
 
 /* device xmit handlers */
 
+enum ieee80211_encrypt {
+       ENCRYPT_NO,
+       ENCRYPT_MGMT,
+       ENCRYPT_DATA,
+};
+
 static int ieee80211_skb_resize(struct ieee80211_sub_if_data *sdata,
                                struct sk_buff *skb,
-                               int head_need, bool may_encrypt)
+                               int head_need,
+                               enum ieee80211_encrypt encrypt)
 {
        struct ieee80211_local *local = sdata->local;
-       struct ieee80211_hdr *hdr;
        bool enc_tailroom;
        int tail_need = 0;
 
-       hdr = (struct ieee80211_hdr *) skb->data;
-       enc_tailroom = may_encrypt &&
-                      (sdata->crypto_tx_tailroom_needed_cnt ||
-                       ieee80211_is_mgmt(hdr->frame_control));
+       enc_tailroom = encrypt == ENCRYPT_MGMT ||
+                      (encrypt == ENCRYPT_DATA &&
+                       sdata->crypto_tx_tailroom_needed_cnt);
 
        if (enc_tailroom) {
                tail_need = IEEE80211_ENCRYPT_TAILROOM;
@@ -1985,23 +1990,29 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 {
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
-       struct ieee80211_hdr *hdr;
+       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
        int headroom;
-       bool may_encrypt;
+       enum ieee80211_encrypt encrypt;
 
-       may_encrypt = !(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT);
+       if (info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)
+               encrypt = ENCRYPT_NO;
+       else if (ieee80211_is_mgmt(hdr->frame_control))
+               encrypt = ENCRYPT_MGMT;
+       else
+               encrypt = ENCRYPT_DATA;
 
        headroom = local->tx_headroom;
-       if (may_encrypt)
+       if (encrypt != ENCRYPT_NO)
                headroom += sdata->encrypt_headroom;
        headroom -= skb_headroom(skb);
        headroom = max_t(int, 0, headroom);
 
-       if (ieee80211_skb_resize(sdata, skb, headroom, may_encrypt)) {
+       if (ieee80211_skb_resize(sdata, skb, headroom, encrypt)) {
                ieee80211_free_txskb(&local->hw, skb);
                return;
        }
 
+       /* reload after potential resize */
        hdr = (struct ieee80211_hdr *) skb->data;
        info->control.vif = &sdata->vif;
 
@@ -2828,7 +2839,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
                head_need += sdata->encrypt_headroom;
                head_need += local->tx_headroom;
                head_need = max_t(int, 0, head_need);
-               if (ieee80211_skb_resize(sdata, skb, head_need, true)) {
+               if (ieee80211_skb_resize(sdata, skb, head_need, ENCRYPT_DATA)) {
                        ieee80211_free_txskb(&local->hw, skb);
                        skb = NULL;
                        return ERR_PTR(-ENOMEM);
@@ -3502,7 +3513,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
        if (unlikely(ieee80211_skb_resize(sdata, skb,
                                          max_t(int, extra_head + hw_headroom -
                                                     skb_headroom(skb), 0),
-                                         false))) {
+                                         ENCRYPT_NO))) {
                kfree_skb(skb);
                return true;
        }
@@ -3619,13 +3630,14 @@ begin:
        tx.skb = skb;
        tx.sdata = vif_to_sdata(info->control.vif);
 
-       if (txq->sta && !(info->flags & IEEE80211_TX_CTL_INJECTED)) {
+       if (txq->sta) {
                tx.sta = container_of(txq->sta, struct sta_info, sta);
                /*
                 * Drop unicast frames to unauthorised stations unless they are
-                * EAPOL frames from the local station.
+                * injected frames or EAPOL frames from the local station.
                 */
-               if (unlikely(ieee80211_is_data(hdr->frame_control) &&
+               if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) &&
+                            ieee80211_is_data(hdr->frame_control) &&
                             !ieee80211_vif_is_mesh(&tx.sdata->vif) &&
                             tx.sdata->vif.type != NL80211_IFTYPE_OCB &&
                             !is_multicast_ether_addr(hdr->addr1) &&
index 185dacb3978196c040fc208a8bbeabc56715c7cd..e7419fd15d84c95e87c8834aab4339f2dc883f76 100644 (file)
@@ -274,6 +274,15 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
        skb_ext_reset(skb);
        skb_orphan(skb);
 
+       /* try to fetch required memory from subflow */
+       if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
+               if (ssk->sk_forward_alloc < skb->truesize)
+                       goto drop;
+               __sk_mem_reclaim(ssk, skb->truesize);
+               if (!sk_rmem_schedule(sk, skb, skb->truesize))
+                       goto drop;
+       }
+
        /* the skb map_seq accounts for the skb offset:
         * mptcp_subflow_get_mapped_dsn() is based on the current tp->copied_seq
         * value
@@ -301,6 +310,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
         * will retransmit as needed, if needed.
         */
        MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_DUPDATA);
+drop:
        mptcp_drop(sk, skb);
        return false;
 }
index 8b47c4bb1c6bed37887f970b59eb5635586450d1..feb4b9ffd46258fed457742a25cbfbde8e0e87d4 100644 (file)
@@ -291,7 +291,7 @@ struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot,
 {
        struct mptcp_sock *ret = NULL;
        struct hlist_nulls_node *pos;
-       int slot, num;
+       int slot, num = 0;
 
        for (slot = *s_slot; slot <= token_mask; *s_num = 0, slot++) {
                struct token_bucket *bucket = &token_hash[slot];
index 6f35832f0de384b4f969b2e9a8ac0c3e54eaa0de..7cff6e5e74453e9e7e428e8badaaba558ae60240 100644 (file)
@@ -637,13 +637,14 @@ ip_set_match_extensions(struct ip_set *set, const struct ip_set_ext *ext,
        if (SET_WITH_COUNTER(set)) {
                struct ip_set_counter *counter = ext_counter(data, set);
 
+               ip_set_update_counter(counter, ext, flags);
+
                if (flags & IPSET_FLAG_MATCH_COUNTERS &&
                    !(ip_set_match_counter(ip_set_get_packets(counter),
                                mext->packets, mext->packets_op) &&
                      ip_set_match_counter(ip_set_get_bytes(counter),
                                mext->bytes, mext->bytes_op)))
                        return false;
-               ip_set_update_counter(counter, ext, flags);
        }
        if (SET_WITH_SKBINFO(set))
                ip_set_get_skbinfo(ext_skbinfo(data, set),
index cc3c275934f47f4817280897e1bc9f8b5424f178..c0b8215ab3d47a6719cbb0d57cffb7b73326ecad 100644 (file)
@@ -742,12 +742,12 @@ static int ip_vs_route_me_harder(struct netns_ipvs *ipvs, int af,
                struct dst_entry *dst = skb_dst(skb);
 
                if (dst->dev && !(dst->dev->flags & IFF_LOOPBACK) &&
-                   ip6_route_me_harder(ipvs->net, skb) != 0)
+                   ip6_route_me_harder(ipvs->net, skb->sk, skb) != 0)
                        return 1;
        } else
 #endif
                if (!(skb_rtable(skb)->rt_flags & RTCF_LOCAL) &&
-                   ip_route_me_harder(ipvs->net, skb, RTN_LOCAL) != 0)
+                   ip_route_me_harder(ipvs->net, skb->sk, skb, RTN_LOCAL) != 0)
                        return 1;
 
        return 0;
index 59151dc07fdc14fe6fa640cdd0448723d96bcb48..e87b6bd6b3cdb6b79b2d229df4ce3d74f8e374d8 100644 (file)
@@ -715,7 +715,7 @@ nf_nat_ipv4_local_fn(void *priv, struct sk_buff *skb,
 
                if (ct->tuplehash[dir].tuple.dst.u3.ip !=
                    ct->tuplehash[!dir].tuple.src.u3.ip) {
-                       err = ip_route_me_harder(state->net, skb, RTN_UNSPEC);
+                       err = ip_route_me_harder(state->net, state->sk, skb, RTN_UNSPEC);
                        if (err < 0)
                                ret = NF_DROP_ERR(err);
                }
@@ -953,7 +953,7 @@ nf_nat_ipv6_local_fn(void *priv, struct sk_buff *skb,
 
                if (!nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.dst.u3,
                                      &ct->tuplehash[!dir].tuple.src.u3)) {
-                       err = nf_ip6_route_me_harder(state->net, skb);
+                       err = nf_ip6_route_me_harder(state->net, state->sk, skb);
                        if (err < 0)
                                ret = NF_DROP_ERR(err);
                }
index 9cca35d22927382e0323cc7cb8cd16913e8d3e87..d7d34a62d3bf5fb5d7919d855a02a2c1c935b8a0 100644 (file)
@@ -446,7 +446,7 @@ synproxy_send_tcp(struct net *net,
 
        skb_dst_set_noref(nskb, skb_dst(skb));
        nskb->protocol = htons(ETH_P_IP);
-       if (ip_route_me_harder(net, nskb, RTN_UNSPEC))
+       if (ip_route_me_harder(net, nskb->sk, nskb, RTN_UNSPEC))
                goto free_nskb;
 
        if (nfct) {
index 65cb8e3c13d901e4c6b1b8d63f1c048d36dbb2cf..0f58e98542be269a8dffc8b0f5c740d6534b2b15 100644 (file)
@@ -7137,7 +7137,7 @@ static void nf_tables_flowtable_notify(struct nft_ctx *ctx,
                        GFP_KERNEL);
        kfree(buf);
 
-       if (ctx->report &&
+       if (!ctx->report &&
            !nfnetlink_has_listeners(ctx->net, NFNLGRP_NFTABLES))
                return;
 
@@ -7259,7 +7259,7 @@ static void nf_tables_gen_notify(struct net *net, struct sk_buff *skb,
        audit_log_nfcfg("?:0;?:0", 0, net->nft.base_seq,
                        AUDIT_NFT_OP_GEN_REGISTER, GFP_KERNEL);
 
-       if (nlmsg_report(nlh) &&
+       if (!nlmsg_report(nlh) &&
            !nfnetlink_has_listeners(net, NFNLGRP_NFTABLES))
                return;
 
@@ -8053,12 +8053,16 @@ static void nf_tables_abort_release(struct nft_trans *trans)
        kfree(trans);
 }
 
-static int __nf_tables_abort(struct net *net, bool autoload)
+static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)
 {
        struct nft_trans *trans, *next;
        struct nft_trans_elem *te;
        struct nft_hook *hook;
 
+       if (action == NFNL_ABORT_VALIDATE &&
+           nf_tables_validate(net) < 0)
+               return -EAGAIN;
+
        list_for_each_entry_safe_reverse(trans, next, &net->nft.commit_list,
                                         list) {
                switch (trans->msg_type) {
@@ -8190,7 +8194,7 @@ static int __nf_tables_abort(struct net *net, bool autoload)
                nf_tables_abort_release(trans);
        }
 
-       if (autoload)
+       if (action == NFNL_ABORT_AUTOLOAD)
                nf_tables_module_autoload(net);
        else
                nf_tables_module_autoload_cleanup(net);
@@ -8203,9 +8207,10 @@ 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, bool autoload)
+static int nf_tables_abort(struct net *net, struct sk_buff *skb,
+                          enum nfnl_abort_action action)
 {
-       int ret = __nf_tables_abort(net, autoload);
+       int ret = __nf_tables_abort(net, action);
 
        mutex_unlock(&net->nft.commit_mutex);
 
@@ -8836,7 +8841,7 @@ static void __net_exit nf_tables_exit_net(struct net *net)
 {
        mutex_lock(&net->nft.commit_mutex);
        if (!list_empty(&net->nft.commit_list))
-               __nf_tables_abort(net, false);
+               __nf_tables_abort(net, NFNL_ABORT_NONE);
        __nft_release_tables(net);
        mutex_unlock(&net->nft.commit_mutex);
        WARN_ON_ONCE(!list_empty(&net->nft.tables));
index 2daa1f6ae344113b2031c4488595e9b9640dd9fe..d3df66a39b5e004b4e583d56ee4c0c40bbb2cdd9 100644 (file)
@@ -333,7 +333,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
                return netlink_ack(skb, nlh, -EINVAL, NULL);
 replay:
        status = 0;
-
+replay_abort:
        skb = netlink_skb_clone(oskb, GFP_KERNEL);
        if (!skb)
                return netlink_ack(oskb, nlh, -ENOMEM, NULL);
@@ -499,7 +499,7 @@ ack:
        }
 done:
        if (status & NFNL_BATCH_REPLAY) {
-               ss->abort(net, oskb, true);
+               ss->abort(net, oskb, NFNL_ABORT_AUTOLOAD);
                nfnl_err_reset(&err_list);
                kfree_skb(skb);
                module_put(ss->owner);
@@ -510,11 +510,25 @@ done:
                        status |= NFNL_BATCH_REPLAY;
                        goto done;
                } else if (err) {
-                       ss->abort(net, oskb, false);
+                       ss->abort(net, oskb, NFNL_ABORT_NONE);
                        netlink_ack(oskb, nlmsg_hdr(oskb), err, NULL);
                }
        } else {
-               ss->abort(net, oskb, false);
+               enum nfnl_abort_action abort_action;
+
+               if (status & NFNL_BATCH_FAILURE)
+                       abort_action = NFNL_ABORT_NONE;
+               else
+                       abort_action = NFNL_ABORT_VALIDATE;
+
+               err = ss->abort(net, oskb, abort_action);
+               if (err == -EAGAIN) {
+                       nfnl_err_reset(&err_list);
+                       kfree_skb(skb);
+                       module_put(ss->owner);
+                       status |= NFNL_BATCH_FAILURE;
+                       goto replay_abort;
+               }
        }
        if (ss->cleanup)
                ss->cleanup(net);
index 8826bbe71136c86bd1020e0598bb4509aa793421..edd02cda57fca8713c29f749ceae7e26e83aa9ff 100644 (file)
@@ -42,7 +42,7 @@ static unsigned int nf_route_table_hook4(void *priv,
                    iph->daddr != daddr ||
                    skb->mark != mark ||
                    iph->tos != tos) {
-                       err = ip_route_me_harder(state->net, skb, RTN_UNSPEC);
+                       err = ip_route_me_harder(state->net, state->sk, skb, RTN_UNSPEC);
                        if (err < 0)
                                ret = NF_DROP_ERR(err);
                }
@@ -92,7 +92,7 @@ static unsigned int nf_route_table_hook6(void *priv,
             skb->mark != mark ||
             ipv6_hdr(skb)->hop_limit != hop_limit ||
             flowlabel != *((u32 *)ipv6_hdr(skb)))) {
-               err = nf_ip6_route_me_harder(state->net, skb);
+               err = nf_ip6_route_me_harder(state->net, state->sk, skb);
                if (err < 0)
                        ret = NF_DROP_ERR(err);
        }
index cedf47ab3c6f98d13f0397e27a4beeca44d28854..2182d361e273f18818e312e47dda770bf9b4b625 100644 (file)
@@ -191,8 +191,8 @@ static int nf_ip_reroute(struct sk_buff *skb, const struct nf_queue_entry *entry
                      skb->mark == rt_info->mark &&
                      iph->daddr == rt_info->daddr &&
                      iph->saddr == rt_info->saddr))
-                       return ip_route_me_harder(entry->state.net, skb,
-                                                 RTN_UNSPEC);
+                       return ip_route_me_harder(entry->state.net, entry->state.sk,
+                                                 skb, RTN_UNSPEC);
        }
 #endif
        return 0;
index 832f898edb6adc46aed452f2224be683427e6e8e..9d6ef6cb9b26334fa1dc9036d336e44d07946370 100644 (file)
@@ -1703,13 +1703,13 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
        parms.port_no = OVSP_LOCAL;
        parms.upcall_portids = a[OVS_DP_ATTR_UPCALL_PID];
 
-       err = ovs_dp_change(dp, a);
-       if (err)
-               goto err_destroy_meters;
-
        /* So far only local changes have been made, now need the lock. */
        ovs_lock();
 
+       err = ovs_dp_change(dp, a);
+       if (err)
+               goto err_unlock_and_destroy_meters;
+
        vport = new_vport(&parms);
        if (IS_ERR(vport)) {
                err = PTR_ERR(vport);
@@ -1725,8 +1725,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
                                ovs_dp_reset_user_features(skb, info);
                }
 
-               ovs_unlock();
-               goto err_destroy_meters;
+               goto err_unlock_and_destroy_meters;
        }
 
        err = ovs_dp_cmd_fill_info(dp, reply, info->snd_portid,
@@ -1741,7 +1740,8 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
        ovs_notify(&dp_datapath_genl_family, reply, info);
        return 0;
 
-err_destroy_meters:
+err_unlock_and_destroy_meters:
+       ovs_unlock();
        ovs_meters_exit(dp);
 err_destroy_ports:
        kfree(dp->ports);
index f3486a37361a63875529f1250864ee18b836964d..c89c8da99f1a2ea234b5a5cbbc40c2635d181d4a 100644 (file)
@@ -390,7 +390,7 @@ static struct mask_cache *tbl_mask_cache_alloc(u32 size)
 }
 int ovs_flow_tbl_masks_cache_resize(struct flow_table *table, u32 size)
 {
-       struct mask_cache *mc = rcu_dereference(table->mask_cache);
+       struct mask_cache *mc = rcu_dereference_ovsl(table->mask_cache);
        struct mask_cache *new;
 
        if (size == mc->cache_size)
index 06603dd1c8aa38d260644f66fa076febcbbdc8b9..b36b60668b1da9d6714f29e8e64e8facfeae434a 100644 (file)
@@ -956,9 +956,10 @@ int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id, bool isv6)
        rds_ib_cm_fill_conn_param(conn, &conn_param, &dp,
                                  conn->c_proposed_version,
                                  UINT_MAX, UINT_MAX, isv6);
-       ret = rdma_connect(cm_id, &conn_param);
+       ret = rdma_connect_locked(cm_id, &conn_param);
        if (ret)
-               rds_ib_conn_error(conn, "rdma_connect failed (%d)\n", ret);
+               rds_ib_conn_error(conn, "rdma_connect_locked failed (%d)\n",
+                                 ret);
 
 out:
        /* Beware - returning non-zero tells the rdma_cm to destroy
index f40bf9771cb9eb3e030c33147dc2a96d8637f5f6..5c7456e5b5cf04643c5421a05467092c75398f44 100644 (file)
@@ -426,6 +426,7 @@ static void __exit mpls_cleanup_module(void)
 module_init(mpls_init_module);
 module_exit(mpls_cleanup_module);
 
+MODULE_SOFTDEP("post: mpls_gso");
 MODULE_AUTHOR("Netronome Systems <oss-drivers@netronome.com>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("MPLS manipulation actions");
index faeabff283a2b6cb97ad84ff90af38455eae3292..838b3fd94d77683cf3164734300cf5d7b5631c47 100644 (file)
@@ -652,12 +652,12 @@ static void tc_block_indr_cleanup(struct flow_block_cb *block_cb)
                               block_cb->indr.binder_type,
                               &block->flow_block, tcf_block_shared(block),
                               &extack);
+       rtnl_lock();
        down_write(&block->cb_lock);
        list_del(&block_cb->driver_list);
        list_move(&block_cb->list, &bo.cb_list);
-       up_write(&block->cb_lock);
-       rtnl_lock();
        tcf_block_unbind(block, &bo);
+       up_write(&block->cb_lock);
        rtnl_unlock();
 }
 
index 84f82771cdf5dce6552bd790242a8c0b8b320e06..0c345e43a09a3738e15ab5de81ae37effcff01e5 100644 (file)
@@ -330,7 +330,7 @@ static s64 tabledist(s64 mu, s32 sigma,
 
        /* default uniform distribution */
        if (dist == NULL)
-               return ((rnd % (2 * sigma)) + mu) - sigma;
+               return ((rnd % (2 * (u32)sigma)) + mu) - sigma;
 
        t = dist->table[rnd % dist->size];
        x = (sigma % NETEM_DIST_SCALE) * t;
@@ -812,6 +812,10 @@ static void get_slot(struct netem_sched_data *q, const struct nlattr *attr)
                q->slot_config.max_packets = INT_MAX;
        if (q->slot_config.max_bytes == 0)
                q->slot_config.max_bytes = INT_MAX;
+
+       /* capping dist_jitter to the range acceptable by tabledist() */
+       q->slot_config.dist_jitter = min_t(__s64, INT_MAX, abs(q->slot_config.dist_jitter));
+
        q->slot.packets_left = q->slot_config.max_packets;
        q->slot.bytes_left = q->slot_config.max_bytes;
        if (q->slot_config.min_delay | q->slot_config.max_delay |
@@ -1037,6 +1041,9 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
        if (tb[TCA_NETEM_SLOT])
                get_slot(q, tb[TCA_NETEM_SLOT]);
 
+       /* capping jitter to the range acceptable by tabledist() */
+       q->jitter = min_t(s64, abs(q->jitter), INT_MAX);
+
        return ret;
 
 get_table_failure:
index aa821e71f05e77532cd42237233820099dc2b80d..813d30767204158d53d2bfcf285c267453047f71 100644 (file)
@@ -1601,12 +1601,12 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
                        break;
 
                case SCTP_CMD_INIT_FAILED:
-                       sctp_cmd_init_failed(commands, asoc, cmd->obj.u32);
+                       sctp_cmd_init_failed(commands, asoc, cmd->obj.u16);
                        break;
 
                case SCTP_CMD_ASSOC_FAILED:
                        sctp_cmd_assoc_failed(commands, asoc, event_type,
-                                             subtype, chunk, cmd->obj.u32);
+                                             subtype, chunk, cmd->obj.u16);
                        break;
 
                case SCTP_CMD_INIT_COUNTER_INC:
index 82be0bd0f6e8135a5d159e8a1620ef23c3986413..e9f487c8c6d55d3c6b335a5b105f3b382ff1d8ca 100644 (file)
@@ -1317,10 +1317,10 @@ static void smc_listen_out_err(struct smc_sock *new_smc)
 
 /* listen worker: decline and fall back if possible */
 static void smc_listen_decline(struct smc_sock *new_smc, int reason_code,
-                              struct smc_init_info *ini, u8 version)
+                              int local_first, u8 version)
 {
        /* RDMA setup failed, switch back to TCP */
-       if (ini->first_contact_local)
+       if (local_first)
                smc_lgr_cleanup_early(&new_smc->conn);
        else
                smc_conn_free(&new_smc->conn);
@@ -1768,7 +1768,8 @@ static void smc_listen_work(struct work_struct *work)
 out_unlock:
        mutex_unlock(&smc_server_lgr_pending);
 out_decl:
-       smc_listen_decline(new_smc, rc, ini, version);
+       smc_listen_decline(new_smc, rc, ini ? ini->first_contact_local : 0,
+                          version);
 out_free:
        kfree(ini);
        kfree(buf);
index b3f46ab79e47217b02c983bec0fd6f17a210ced6..c579d1d5995a9e94c608eb4f3db521c97d471f5d 100644 (file)
@@ -124,7 +124,7 @@ struct smc_clc_v2_extension {
        struct smc_clnt_opts_area_hdr hdr;
        u8 roce[16];            /* RoCEv2 GID */
        u8 reserved[16];
-       u8 user_eids[0][SMC_MAX_EID_LEN];
+       u8 user_eids[][SMC_MAX_EID_LEN];
 };
 
 struct smc_clc_msg_proposal_prefix {   /* prefix part of clc proposal message*/
@@ -143,7 +143,7 @@ struct smc_clc_msg_smcd {   /* SMC-D GID information */
 struct smc_clc_smcd_v2_extension {
        u8 system_eid[SMC_MAX_EID_LEN];
        u8 reserved[16];
-       struct smc_clc_smcd_gid_chid gidchid[0];
+       struct smc_clc_smcd_gid_chid gidchid[];
 };
 
 struct smc_clc_msg_proposal {  /* clc proposal message sent by Linux */
index d790c43c473f2a5881d572d11a74067e3ae878f6..2b19863f7171b0acb27d76d1e99f62939c22722a 100644 (file)
@@ -1615,8 +1615,11 @@ static struct smc_buf_desc *smcd_new_buf_create(struct smc_link_group *lgr,
                rc = smc_ism_register_dmb(lgr, bufsize, buf_desc);
                if (rc) {
                        kfree(buf_desc);
-                       return (rc == -ENOMEM) ? ERR_PTR(-EAGAIN) :
-                                                ERR_PTR(-EIO);
+                       if (rc == -ENOMEM)
+                               return ERR_PTR(-EAGAIN);
+                       if (rc == -ENOSPC)
+                               return ERR_PTR(-ENOSPC);
+                       return ERR_PTR(-EIO);
                }
                buf_desc->pages = virt_to_page(buf_desc->cpu_addr);
                /* CDC header stored in buf. So, pretend it was smaller */
index 2a78aa70157281f1e9771f0bcc426fa73d862cb3..32c79c59052b688e93e9697f67623831169a1299 100644 (file)
@@ -150,12 +150,11 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
        if (fragid == FIRST_FRAGMENT) {
                if (unlikely(head))
                        goto err;
-               if (skb_cloned(frag))
-                       frag = skb_copy(frag, GFP_ATOMIC);
+               *buf = NULL;
+               frag = skb_unshare(frag, GFP_ATOMIC);
                if (unlikely(!frag))
                        goto err;
                head = *headbuf = frag;
-               *buf = NULL;
                TIPC_SKB_CB(head)->tail = NULL;
                if (skb_is_nonlinear(head)) {
                        skb_walk_frags(head, tail) {
index 9e93bc201cc07b26285e7f10d5502a2a6166db6b..b4d7b8aba0037b7fb00e0f8015c3f7b95e1ea42a 100644 (file)
@@ -739,7 +739,7 @@ static struct sock *__vsock_create(struct net *net,
                vsk->buffer_min_size = psk->buffer_min_size;
                vsk->buffer_max_size = psk->buffer_max_size;
        } else {
-               vsk->trusted = capable(CAP_NET_ADMIN);
+               vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN);
                vsk->owner = get_current_cred();
                vsk->connect_timeout = VSOCK_DEFAULT_CONNECT_TIMEOUT;
                vsk->buffer_size = VSOCK_DEFAULT_BUFFER_SIZE;
index 9f23923e8d29b781d66bd264da00ac7ef2807c94..240282c083aa746a55f5998dbfd6ec356a404985 100644 (file)
@@ -1250,8 +1250,7 @@ void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
 }
 EXPORT_SYMBOL(cfg80211_stop_iface);
 
-void cfg80211_init_wdev(struct cfg80211_registered_device *rdev,
-                       struct wireless_dev *wdev)
+void cfg80211_init_wdev(struct wireless_dev *wdev)
 {
        mutex_init(&wdev->mtx);
        INIT_LIST_HEAD(&wdev->event_list);
@@ -1262,6 +1261,30 @@ void cfg80211_init_wdev(struct cfg80211_registered_device *rdev,
        spin_lock_init(&wdev->pmsr_lock);
        INIT_WORK(&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk);
 
+#ifdef CONFIG_CFG80211_WEXT
+       wdev->wext.default_key = -1;
+       wdev->wext.default_mgmt_key = -1;
+       wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
+#endif
+
+       if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
+               wdev->ps = true;
+       else
+               wdev->ps = false;
+       /* allow mac80211 to determine the timeout */
+       wdev->ps_timeout = -1;
+
+       if ((wdev->iftype == NL80211_IFTYPE_STATION ||
+            wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
+            wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
+               wdev->netdev->priv_flags |= IFF_DONT_BRIDGE;
+
+       INIT_WORK(&wdev->disconnect_wk, cfg80211_autodisconnect_wk);
+}
+
+void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
+                           struct wireless_dev *wdev)
+{
        /*
         * We get here also when the interface changes network namespaces,
         * as it's registered into the new one, but we don't want it to
@@ -1295,6 +1318,11 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
        switch (state) {
        case NETDEV_POST_INIT:
                SET_NETDEV_DEVTYPE(dev, &wiphy_type);
+               wdev->netdev = dev;
+               /* can only change netns with wiphy */
+               dev->features |= NETIF_F_NETNS_LOCAL;
+
+               cfg80211_init_wdev(wdev);
                break;
        case NETDEV_REGISTER:
                /*
@@ -1302,35 +1330,12 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
                 * called within code protected by it when interfaces
                 * are added with nl80211.
                 */
-               /* can only change netns with wiphy */
-               dev->features |= NETIF_F_NETNS_LOCAL;
-
                if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
                                      "phy80211")) {
                        pr_err("failed to add phy80211 symlink to netdev!\n");
                }
-               wdev->netdev = dev;
-#ifdef CONFIG_CFG80211_WEXT
-               wdev->wext.default_key = -1;
-               wdev->wext.default_mgmt_key = -1;
-               wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
-#endif
-
-               if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
-                       wdev->ps = true;
-               else
-                       wdev->ps = false;
-               /* allow mac80211 to determine the timeout */
-               wdev->ps_timeout = -1;
-
-               if ((wdev->iftype == NL80211_IFTYPE_STATION ||
-                    wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
-                    wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
-                       dev->priv_flags |= IFF_DONT_BRIDGE;
-
-               INIT_WORK(&wdev->disconnect_wk, cfg80211_autodisconnect_wk);
 
-               cfg80211_init_wdev(rdev, wdev);
+               cfg80211_register_wdev(rdev, wdev);
                break;
        case NETDEV_GOING_DOWN:
                cfg80211_leave(rdev, wdev);
index e1ec9ac8e608bdf03962663dc3ecc8ef918a4502..e3e9686859d459d9d6750695695b05339a50d49a 100644 (file)
@@ -209,8 +209,9 @@ struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx);
 int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
                          struct net *net);
 
-void cfg80211_init_wdev(struct cfg80211_registered_device *rdev,
-                       struct wireless_dev *wdev);
+void cfg80211_init_wdev(struct wireless_dev *wdev);
+void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
+                           struct wireless_dev *wdev);
 
 static inline void wdev_lock(struct wireless_dev *wdev)
        __acquires(wdev)
index 554796a6c6fe5dcb3461d688f12a08a19a4a92cf..a77174b99b07e8fbd863e50c159501e5d26e0224 100644 (file)
@@ -3885,7 +3885,8 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info)
                 * P2P Device and NAN do not have a netdev, so don't go
                 * through the netdev notifier and must be added here
                 */
-               cfg80211_init_wdev(rdev, wdev);
+               cfg80211_init_wdev(wdev);
+               cfg80211_register_wdev(rdev, wdev);
                break;
        default:
                break;
index 3dab859641e1a0e7f5a66ab1ca560d862754b1c5..a04fdfb35f070eeed7b558f8a696db27daf4afa9 100644 (file)
@@ -3616,7 +3616,7 @@ static void print_rd_rules(const struct ieee80211_regdomain *rd)
                power_rule = &reg_rule->power_rule;
 
                if (reg_rule->flags & NL80211_RRF_AUTO_BW)
-                       snprintf(bw, sizeof(bw), "%d KHz, %d KHz AUTO",
+                       snprintf(bw, sizeof(bw), "%d KHz, %u KHz AUTO",
                                 freq_range->max_bandwidth_khz,
                                 reg_get_max_bandwidth(rd, reg_rule));
                else
index aa4cdcf69d471e63ec712810edaa78008572a9e9..9b8e292a7c6a7525f509d9ae730652769892f1ce 100644 (file)
@@ -803,14 +803,14 @@ static struct xfrm6_tunnel xfrmi_ipv6_handler __read_mostly = {
        .handler        =       xfrmi6_rcv_tunnel,
        .cb_handler     =       xfrmi_rcv_cb,
        .err_handler    =       xfrmi6_err,
-       .priority       =       -1,
+       .priority       =       2,
 };
 
 static struct xfrm6_tunnel xfrmi_ip6ip_handler __read_mostly = {
        .handler        =       xfrmi6_rcv_tunnel,
        .cb_handler     =       xfrmi_rcv_cb,
        .err_handler    =       xfrmi6_err,
-       .priority       =       -1,
+       .priority       =       2,
 };
 #endif
 
@@ -848,14 +848,14 @@ static struct xfrm_tunnel xfrmi_ipip_handler __read_mostly = {
        .handler        =       xfrmi4_rcv_tunnel,
        .cb_handler     =       xfrmi_rcv_cb,
        .err_handler    =       xfrmi4_err,
-       .priority       =       -1,
+       .priority       =       3,
 };
 
 static struct xfrm_tunnel xfrmi_ipip6_handler __read_mostly = {
        .handler        =       xfrmi4_rcv_tunnel,
        .cb_handler     =       xfrmi_rcv_cb,
        .err_handler    =       xfrmi4_err,
-       .priority       =       -1,
+       .priority       =       2,
 };
 #endif
 
index bbd4643d7e824f17d6d9e45e242b000239227b3b..a77da7aae6fe845a6fd1253a4e6d98be53ec6aec 100644 (file)
@@ -2004,6 +2004,7 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high)
        int err = -ENOENT;
        __be32 minspi = htonl(low);
        __be32 maxspi = htonl(high);
+       __be32 newspi = 0;
        u32 mark = x->mark.v & x->mark.m;
 
        spin_lock_bh(&x->lock);
@@ -2022,21 +2023,22 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high)
                        xfrm_state_put(x0);
                        goto unlock;
                }
-               x->id.spi = minspi;
+               newspi = minspi;
        } else {
                u32 spi = 0;
                for (h = 0; h < high-low+1; h++) {
                        spi = low + prandom_u32()%(high-low+1);
                        x0 = xfrm_state_lookup(net, mark, &x->id.daddr, htonl(spi), x->id.proto, x->props.family);
                        if (x0 == NULL) {
-                               x->id.spi = htonl(spi);
+                               newspi = htonl(spi);
                                break;
                        }
                        xfrm_state_put(x0);
                }
        }
-       if (x->id.spi) {
+       if (newspi) {
                spin_lock_bh(&net->xfrm.xfrm_state_lock);
+               x->id.spi = newspi;
                h = xfrm_spi_hash(net, &x->id.daddr, x->id.spi, x->id.proto, x->props.family);
                hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h);
                spin_unlock_bh(&net->xfrm.xfrm_state_lock);
diff --git a/samples/mic/mpssd/.gitignore b/samples/mic/mpssd/.gitignore
deleted file mode 100644 (file)
index aa03f1e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-mpssd
diff --git a/samples/mic/mpssd/Makefile b/samples/mic/mpssd/Makefile
deleted file mode 100644 (file)
index a7a6e0c..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-ifndef CROSS_COMPILE
-uname_M := $(shell uname -m 2>/dev/null || echo not)
-ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
-
-ifeq ($(ARCH),x86)
-
-PROGS := mpssd
-CC = $(CROSS_COMPILE)gcc
-CFLAGS := -I../../../usr/include -I../../../tools/include
-
-ifdef DEBUG
-CFLAGS += -DDEBUG=$(DEBUG)
-endif
-
-all: $(PROGS)
-mpssd: mpssd.c sysfs.c
-       $(CC) $(CFLAGS) mpssd.c sysfs.c -o mpssd -lpthread
-
-install:
-       install mpssd /usr/sbin/mpssd
-       install micctrl /usr/sbin/micctrl
-
-clean:
-       rm -fr $(PROGS)
-
-endif
-endif
diff --git a/samples/mic/mpssd/micctrl b/samples/mic/mpssd/micctrl
deleted file mode 100755 (executable)
index 030a60b..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0-only
-# Intel MIC Platform Software Stack (MPSS)
-#
-# Copyright(c) 2013 Intel Corporation.
-#
-# Intel MIC User Space Tools.
-#
-# micctrl - Controls MIC boot/start/stop.
-#
-# chkconfig: 2345 95 05
-# description: start MPSS stack processing.
-#
-### BEGIN INIT INFO
-# Provides: micctrl
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-sysfs="/sys/class/mic"
-
-_status()
-{
-       f=$sysfs/$1
-       echo -e $1 state: "`cat $f/state`" shutdown_status: "`cat $f/shutdown_status`"
-}
-
-status()
-{
-       if [ "`echo $1 | head -c3`" == "mic" ]; then
-               _status $1
-               return $?
-       fi
-       for f in $sysfs/*
-       do
-               _status `basename $f`
-               RETVAL=$?
-               [ $RETVAL -ne 0 ] && return $RETVAL
-       done
-       return 0
-}
-
-_reset()
-{
-       f=$sysfs/$1
-       echo reset > $f/state
-}
-
-reset()
-{
-       if [ "`echo $1 | head -c3`" == "mic" ]; then
-               _reset $1
-               return $?
-       fi
-       for f in $sysfs/*
-       do
-               _reset `basename $f`
-               RETVAL=$?
-               [ $RETVAL -ne 0 ] && return $RETVAL
-       done
-       return 0
-}
-
-_boot()
-{
-       f=$sysfs/$1
-       echo "linux" > $f/bootmode
-       echo "mic/uos.img" > $f/firmware
-       echo "mic/$1.image" > $f/ramdisk
-       echo "boot" > $f/state
-}
-
-boot()
-{
-       if [ "`echo $1 | head -c3`" == "mic" ]; then
-               _boot $1
-               return $?
-       fi
-       for f in $sysfs/*
-       do
-               _boot `basename $f`
-               RETVAL=$?
-               [ $RETVAL -ne 0 ] && return $RETVAL
-       done
-       return 0
-}
-
-_shutdown()
-{
-       f=$sysfs/$1
-       echo shutdown > $f/state
-}
-
-shutdown()
-{
-       if [ "`echo $1 | head -c3`" == "mic" ]; then
-               _shutdown $1
-               return $?
-       fi
-       for f in $sysfs/*
-       do
-               _shutdown `basename $f`
-               RETVAL=$?
-               [ $RETVAL -ne 0 ] && return $RETVAL
-       done
-       return 0
-}
-
-_wait()
-{
-       f=$sysfs/$1
-       while [ "`cat $f/state`" != "offline" -a "`cat $f/state`" != "online" ]
-       do
-               sleep 1
-               echo -e "Waiting for $1 to go offline"
-       done
-}
-
-wait()
-{
-       if [ "`echo $1 | head -c3`" == "mic" ]; then
-               _wait $1
-               return $?
-       fi
-       # Wait for the cards to go offline
-       for f in $sysfs/*
-       do
-               _wait `basename $f`
-               RETVAL=$?
-               [ $RETVAL -ne 0 ] && return $RETVAL
-       done
-       return 0
-}
-
-if [ ! -d "$sysfs" ]; then
-       echo -e $"Module unloaded "
-       exit 3
-fi
-
-case $1 in
-       -s)
-               status $2
-               ;;
-       -r)
-               reset $2
-               ;;
-       -b)
-               boot $2
-               ;;
-       -S)
-               shutdown $2
-               ;;
-       -w)
-               wait $2
-               ;;
-       *)
-               echo $"Usage: $0 {-s (status) |-r (reset) |-b (boot) |-S (shutdown) |-w (wait)}"
-               exit 2
-esac
-
-exit $?
diff --git a/samples/mic/mpssd/mpss b/samples/mic/mpssd/mpss
deleted file mode 100755 (executable)
index 248ac73..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0-only
-# Intel MIC Platform Software Stack (MPSS)
-#
-# Copyright(c) 2013 Intel Corporation.
-#
-# Intel MIC User Space Tools.
-#
-# mpss Start mpssd.
-#
-# chkconfig: 2345 95 05
-# description: start MPSS stack processing.
-#
-### BEGIN INIT INFO
-# Provides: mpss
-# Required-Start:
-# Required-Stop:
-# Short-Description: MPSS stack control
-# Description: MPSS stack control
-### END INIT INFO
-
-# Source function library.
-. /etc/init.d/functions
-
-exec=/usr/sbin/mpssd
-sysfs="/sys/class/mic"
-mic_modules="mic_host mic_x100_dma scif vop"
-
-start()
-{
-       [ -x $exec ] || exit 5
-
-       if [ "`ps -e | awk '{print $4}' | grep mpssd | head -1`" = "mpssd" ]; then
-               echo -e $"MPSSD already running! "
-               success
-               echo
-               return 0
-       fi
-
-       echo -e $"Starting MPSS Stack"
-       echo -e $"Loading MIC drivers:" $mic_modules
-
-       modprobe -a $mic_modules
-       RETVAL=$?
-       if [ $RETVAL -ne 0 ]; then
-               failure
-               echo
-               return $RETVAL
-       fi
-
-       # Start the daemon
-       echo -n $"Starting MPSSD "
-       $exec
-       RETVAL=$?
-       if [ $RETVAL -ne 0 ]; then
-               failure
-               echo
-               return $RETVAL
-       fi
-       success
-       echo
-
-       sleep 5
-
-       # Boot the cards
-       micctrl -b
-
-       # Wait till ping works
-       for f in $sysfs/*
-       do
-               count=100
-               ipaddr=`cat $f/cmdline`
-               ipaddr=${ipaddr#*address,}
-               ipaddr=`echo $ipaddr | cut -d, -f1 | cut -d\; -f1`
-               while [ $count -ge 0 ]
-               do
-                       echo -e "Pinging "`basename $f`" "
-                       ping -c 1 $ipaddr &> /dev/null
-                       RETVAL=$?
-                       if [ $RETVAL -eq 0 ]; then
-                               success
-                               break
-                       fi
-                       sleep 1
-                       count=`expr $count - 1`
-               done
-               [ $RETVAL -ne 0 ] && failure || success
-               echo
-       done
-       return $RETVAL
-}
-
-stop()
-{
-       echo -e $"Shutting down MPSS Stack: "
-
-       # Bail out if module is unloaded
-       if [ ! -d "$sysfs" ]; then
-               echo -n $"Module unloaded "
-               success
-               echo
-               return 0
-       fi
-
-       # Shut down the cards.
-       micctrl -S
-
-       # Wait for the cards to go offline
-       for f in $sysfs/*
-       do
-               while [ "`cat $f/state`" != "ready" ]
-               do
-                       sleep 1
-                       echo -e "Waiting for "`basename $f`" to become ready"
-               done
-       done
-
-       # Display the status of the cards
-       micctrl -s
-
-       # Kill MPSSD now
-       echo -n $"Killing MPSSD"
-       killall -9 mpssd 2>/dev/null
-       RETVAL=$?
-       [ $RETVAL -ne 0 ] && failure || success
-       echo
-       return $RETVAL
-}
-
-restart()
-{
-       stop
-       sleep 5
-       start
-}
-
-status()
-{
-       micctrl -s
-       if [ "`ps -e | awk '{print $4}' | grep mpssd | head -n 1`" = "mpssd" ]; then
-               echo "mpssd is running"
-       else
-               echo "mpssd is stopped"
-       fi
-       return 0
-}
-
-unload()
-{
-       if [ ! -d "$sysfs" ]; then
-               echo -n $"No MIC_HOST Module: "
-               success
-               echo
-               return
-       fi
-
-       stop
-
-       sleep 5
-       echo -n $"Removing MIC drivers:" $mic_modules
-       modprobe -r $mic_modules
-       RETVAL=$?
-       [ $RETVAL -ne 0 ] && failure || success
-       echo
-       return $RETVAL
-}
-
-case $1 in
-       start)
-               start
-               ;;
-       stop)
-               stop
-               ;;
-       restart)
-               restart
-               ;;
-       status)
-               status
-               ;;
-       unload)
-               unload
-               ;;
-       *)
-               echo $"Usage: $0 {start|stop|restart|status|unload}"
-               exit 2
-esac
-
-exit $?
diff --git a/samples/mic/mpssd/mpssd.c b/samples/mic/mpssd/mpssd.c
deleted file mode 100644 (file)
index c03a05d..0000000
+++ /dev/null
@@ -1,1815 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC User Space Tools.
- */
-
-#define _GNU_SOURCE
-
-#include <stdlib.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <assert.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <signal.h>
-#include <poll.h>
-#include <features.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/socket.h>
-#include <linux/virtio_ring.h>
-#include <linux/virtio_net.h>
-#include <linux/virtio_console.h>
-#include <linux/virtio_blk.h>
-#include <linux/version.h>
-#include "mpssd.h"
-#include <linux/mic_ioctl.h>
-#include <linux/mic_common.h>
-#include <tools/endian.h>
-
-static void *init_mic(void *arg);
-
-static FILE *logfp;
-static struct mic_info mic_list;
-
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
-#define min_t(type, x, y) ({                           \
-               type __min1 = (x);                      \
-               type __min2 = (y);                      \
-               __min1 < __min2 ? __min1 : __min2; })
-
-/* align addr on a size boundary - adjust address up/down if needed */
-#define _ALIGN_DOWN(addr, size)  ((addr)&(~((size)-1)))
-#define _ALIGN_UP(addr, size)    _ALIGN_DOWN(addr + size - 1, size)
-
-/* align addr on a size boundary - adjust address up if needed */
-#define _ALIGN(addr, size)     _ALIGN_UP(addr, size)
-
-/* to align the pointer to the (next) page boundary */
-#define PAGE_ALIGN(addr)        _ALIGN(addr, PAGE_SIZE)
-
-#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
-
-#define GSO_ENABLED            1
-#define MAX_GSO_SIZE           (64 * 1024)
-#define ETH_H_LEN              14
-#define MAX_NET_PKT_SIZE       (_ALIGN_UP(MAX_GSO_SIZE + ETH_H_LEN, 64))
-#define MIC_DEVICE_PAGE_END    0x1000
-
-#ifndef VIRTIO_NET_HDR_F_DATA_VALID
-#define VIRTIO_NET_HDR_F_DATA_VALID    2       /* Csum is valid */
-#endif
-
-static struct {
-       struct mic_device_desc dd;
-       struct mic_vqconfig vqconfig[2];
-       __u32 host_features, guest_acknowledgements;
-       struct virtio_console_config cons_config;
-} virtcons_dev_page = {
-       .dd = {
-               .type = VIRTIO_ID_CONSOLE,
-               .num_vq = ARRAY_SIZE(virtcons_dev_page.vqconfig),
-               .feature_len = sizeof(virtcons_dev_page.host_features),
-               .config_len = sizeof(virtcons_dev_page.cons_config),
-       },
-       .vqconfig[0] = {
-               .num = htole16(MIC_VRING_ENTRIES),
-       },
-       .vqconfig[1] = {
-               .num = htole16(MIC_VRING_ENTRIES),
-       },
-};
-
-static struct {
-       struct mic_device_desc dd;
-       struct mic_vqconfig vqconfig[2];
-       __u32 host_features, guest_acknowledgements;
-       struct virtio_net_config net_config;
-} virtnet_dev_page = {
-       .dd = {
-               .type = VIRTIO_ID_NET,
-               .num_vq = ARRAY_SIZE(virtnet_dev_page.vqconfig),
-               .feature_len = sizeof(virtnet_dev_page.host_features),
-               .config_len = sizeof(virtnet_dev_page.net_config),
-       },
-       .vqconfig[0] = {
-               .num = htole16(MIC_VRING_ENTRIES),
-       },
-       .vqconfig[1] = {
-               .num = htole16(MIC_VRING_ENTRIES),
-       },
-#if GSO_ENABLED
-       .host_features = htole32(
-               1 << VIRTIO_NET_F_CSUM |
-               1 << VIRTIO_NET_F_GSO |
-               1 << VIRTIO_NET_F_GUEST_TSO4 |
-               1 << VIRTIO_NET_F_GUEST_TSO6 |
-               1 << VIRTIO_NET_F_GUEST_ECN),
-#else
-               .host_features = 0,
-#endif
-};
-
-static const char *mic_config_dir = "/etc/mpss";
-static const char *virtblk_backend = "VIRTBLK_BACKEND";
-static struct {
-       struct mic_device_desc dd;
-       struct mic_vqconfig vqconfig[1];
-       __u32 host_features, guest_acknowledgements;
-       struct virtio_blk_config blk_config;
-} virtblk_dev_page = {
-       .dd = {
-               .type = VIRTIO_ID_BLOCK,
-               .num_vq = ARRAY_SIZE(virtblk_dev_page.vqconfig),
-               .feature_len = sizeof(virtblk_dev_page.host_features),
-               .config_len = sizeof(virtblk_dev_page.blk_config),
-       },
-       .vqconfig[0] = {
-               .num = htole16(MIC_VRING_ENTRIES),
-       },
-       .host_features =
-               htole32(1<<VIRTIO_BLK_F_SEG_MAX),
-       .blk_config = {
-               .seg_max = htole32(MIC_VRING_ENTRIES - 2),
-               .capacity = htole64(0),
-        }
-};
-
-static char *myname;
-
-static int
-tap_configure(struct mic_info *mic, char *dev)
-{
-       pid_t pid;
-       char *ifargv[7];
-       char ipaddr[IFNAMSIZ];
-       int ret = 0;
-
-       pid = fork();
-       if (pid == 0) {
-               ifargv[0] = "ip";
-               ifargv[1] = "link";
-               ifargv[2] = "set";
-               ifargv[3] = dev;
-               ifargv[4] = "up";
-               ifargv[5] = NULL;
-               mpsslog("Configuring %s\n", dev);
-               ret = execvp("ip", ifargv);
-               if (ret < 0) {
-                       mpsslog("%s execvp failed errno %s\n",
-                               mic->name, strerror(errno));
-                       return ret;
-               }
-       }
-       if (pid < 0) {
-               mpsslog("%s fork failed errno %s\n",
-                       mic->name, strerror(errno));
-               return ret;
-       }
-
-       ret = waitpid(pid, NULL, 0);
-       if (ret < 0) {
-               mpsslog("%s waitpid failed errno %s\n",
-                       mic->name, strerror(errno));
-               return ret;
-       }
-
-       snprintf(ipaddr, IFNAMSIZ, "172.31.%d.254/24", mic->id + 1);
-
-       pid = fork();
-       if (pid == 0) {
-               ifargv[0] = "ip";
-               ifargv[1] = "addr";
-               ifargv[2] = "add";
-               ifargv[3] = ipaddr;
-               ifargv[4] = "dev";
-               ifargv[5] = dev;
-               ifargv[6] = NULL;
-               mpsslog("Configuring %s ipaddr %s\n", dev, ipaddr);
-               ret = execvp("ip", ifargv);
-               if (ret < 0) {
-                       mpsslog("%s execvp failed errno %s\n",
-                               mic->name, strerror(errno));
-                       return ret;
-               }
-       }
-       if (pid < 0) {
-               mpsslog("%s fork failed errno %s\n",
-                       mic->name, strerror(errno));
-               return ret;
-       }
-
-       ret = waitpid(pid, NULL, 0);
-       if (ret < 0) {
-               mpsslog("%s waitpid failed errno %s\n",
-                       mic->name, strerror(errno));
-               return ret;
-       }
-       mpsslog("MIC name %s %s %d DONE!\n",
-               mic->name, __func__, __LINE__);
-       return 0;
-}
-
-static int tun_alloc(struct mic_info *mic, char *dev)
-{
-       struct ifreq ifr;
-       int fd, err;
-#if GSO_ENABLED
-       unsigned offload;
-#endif
-       fd = open("/dev/net/tun", O_RDWR);
-       if (fd < 0) {
-               mpsslog("Could not open /dev/net/tun %s\n", strerror(errno));
-               goto done;
-       }
-
-       memset(&ifr, 0, sizeof(ifr));
-
-       ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_VNET_HDR;
-       if (*dev)
-               strncpy(ifr.ifr_name, dev, IFNAMSIZ);
-
-       err = ioctl(fd, TUNSETIFF, (void *)&ifr);
-       if (err < 0) {
-               mpsslog("%s %s %d TUNSETIFF failed %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               close(fd);
-               return err;
-       }
-#if GSO_ENABLED
-       offload = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 | TUN_F_TSO_ECN;
-
-       err = ioctl(fd, TUNSETOFFLOAD, offload);
-       if (err < 0) {
-               mpsslog("%s %s %d TUNSETOFFLOAD failed %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               close(fd);
-               return err;
-       }
-#endif
-       strcpy(dev, ifr.ifr_name);
-       mpsslog("Created TAP %s\n", dev);
-done:
-       return fd;
-}
-
-#define NET_FD_VIRTIO_NET 0
-#define NET_FD_TUN 1
-#define MAX_NET_FD 2
-
-static void set_dp(struct mic_info *mic, int type, void *dp)
-{
-       switch (type) {
-       case VIRTIO_ID_CONSOLE:
-               mic->mic_console.console_dp = dp;
-               return;
-       case VIRTIO_ID_NET:
-               mic->mic_net.net_dp = dp;
-               return;
-       case VIRTIO_ID_BLOCK:
-               mic->mic_virtblk.block_dp = dp;
-               return;
-       }
-       mpsslog("%s %s %d not found\n", mic->name, __func__, type);
-       assert(0);
-}
-
-static void *get_dp(struct mic_info *mic, int type)
-{
-       switch (type) {
-       case VIRTIO_ID_CONSOLE:
-               return mic->mic_console.console_dp;
-       case VIRTIO_ID_NET:
-               return mic->mic_net.net_dp;
-       case VIRTIO_ID_BLOCK:
-               return mic->mic_virtblk.block_dp;
-       }
-       mpsslog("%s %s %d not found\n", mic->name, __func__, type);
-       assert(0);
-       return NULL;
-}
-
-static struct mic_device_desc *get_device_desc(struct mic_info *mic, int type)
-{
-       struct mic_device_desc *d;
-       int i;
-       void *dp = get_dp(mic, type);
-
-       for (i = sizeof(struct mic_bootparam); i < PAGE_SIZE;
-               i += mic_total_desc_size(d)) {
-               d = dp + i;
-
-               /* End of list */
-               if (d->type == 0)
-                       break;
-
-               if (d->type == -1)
-                       continue;
-
-               mpsslog("%s %s d-> type %d d %p\n",
-                       mic->name, __func__, d->type, d);
-
-               if (d->type == (__u8)type)
-                       return d;
-       }
-       mpsslog("%s %s %d not found\n", mic->name, __func__, type);
-       return NULL;
-}
-
-/* See comments in vhost.c for explanation of next_desc() */
-static unsigned next_desc(struct vring_desc *desc)
-{
-       unsigned int next;
-
-       if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT))
-               return -1U;
-       next = le16toh(desc->next);
-       return next;
-}
-
-/* Sum up all the IOVEC length */
-static ssize_t
-sum_iovec_len(struct mic_copy_desc *copy)
-{
-       ssize_t sum = 0;
-       unsigned int i;
-
-       for (i = 0; i < copy->iovcnt; i++)
-               sum += copy->iov[i].iov_len;
-       return sum;
-}
-
-static inline void verify_out_len(struct mic_info *mic,
-       struct mic_copy_desc *copy)
-{
-       if (copy->out_len != sum_iovec_len(copy)) {
-               mpsslog("%s %s %d BUG copy->out_len 0x%x len 0x%zx\n",
-                       mic->name, __func__, __LINE__,
-                       copy->out_len, sum_iovec_len(copy));
-               assert(copy->out_len == sum_iovec_len(copy));
-       }
-}
-
-/* Display an iovec */
-static void
-disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy,
-          const char *s, int line)
-{
-       unsigned int i;
-
-       for (i = 0; i < copy->iovcnt; i++)
-               mpsslog("%s %s %d copy->iov[%d] addr %p len 0x%zx\n",
-                       mic->name, s, line, i,
-                       copy->iov[i].iov_base, copy->iov[i].iov_len);
-}
-
-static inline __u16 read_avail_idx(struct mic_vring *vr)
-{
-       return READ_ONCE(vr->info->avail_idx);
-}
-
-static inline void txrx_prepare(int type, bool tx, struct mic_vring *vr,
-                               struct mic_copy_desc *copy, ssize_t len)
-{
-       copy->vr_idx = tx ? 0 : 1;
-       copy->update_used = true;
-       if (type == VIRTIO_ID_NET)
-               copy->iov[1].iov_len = len - sizeof(struct virtio_net_hdr);
-       else
-               copy->iov[0].iov_len = len;
-}
-
-/* Central API which triggers the copies */
-static int
-mic_virtio_copy(struct mic_info *mic, int fd,
-               struct mic_vring *vr, struct mic_copy_desc *copy)
-{
-       int ret;
-
-       ret = ioctl(fd, MIC_VIRTIO_COPY_DESC, copy);
-       if (ret) {
-               mpsslog("%s %s %d errno %s ret %d\n",
-                       mic->name, __func__, __LINE__,
-                       strerror(errno), ret);
-       }
-       return ret;
-}
-
-static inline unsigned _vring_size(unsigned int num, unsigned long align)
-{
-       return _ALIGN_UP(((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
-                               + align - 1) & ~(align - 1))
-               + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num, 4);
-}
-
-/*
- * This initialization routine requires at least one
- * vring i.e. vr0. vr1 is optional.
- */
-static void *
-init_vr(struct mic_info *mic, int fd, int type,
-       struct mic_vring *vr0, struct mic_vring *vr1, int num_vq)
-{
-       int vr_size;
-       char *va;
-
-       vr_size = PAGE_ALIGN(_vring_size(MIC_VRING_ENTRIES,
-                                        MIC_VIRTIO_RING_ALIGN) +
-                            sizeof(struct _mic_vring_info));
-       va = mmap(NULL, MIC_DEVICE_PAGE_END + vr_size * num_vq,
-               PROT_READ, MAP_SHARED, fd, 0);
-       if (MAP_FAILED == va) {
-               mpsslog("%s %s %d mmap failed errno %s\n",
-                       mic->name, __func__, __LINE__,
-                       strerror(errno));
-               goto done;
-       }
-       set_dp(mic, type, va);
-       vr0->va = (struct mic_vring *)&va[MIC_DEVICE_PAGE_END];
-       vr0->info = vr0->va +
-               _vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN);
-       vring_init(&vr0->vr,
-                  MIC_VRING_ENTRIES, vr0->va, MIC_VIRTIO_RING_ALIGN);
-       mpsslog("%s %s vr0 %p vr0->info %p vr_size 0x%x vring 0x%x ",
-               __func__, mic->name, vr0->va, vr0->info, vr_size,
-               _vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
-       mpsslog("magic 0x%x expected 0x%x\n",
-               le32toh(vr0->info->magic), MIC_MAGIC + type);
-       assert(le32toh(vr0->info->magic) == MIC_MAGIC + type);
-       if (vr1) {
-               vr1->va = (struct mic_vring *)
-                       &va[MIC_DEVICE_PAGE_END + vr_size];
-               vr1->info = vr1->va + _vring_size(MIC_VRING_ENTRIES,
-                       MIC_VIRTIO_RING_ALIGN);
-               vring_init(&vr1->vr,
-                          MIC_VRING_ENTRIES, vr1->va, MIC_VIRTIO_RING_ALIGN);
-               mpsslog("%s %s vr1 %p vr1->info %p vr_size 0x%x vring 0x%x ",
-                       __func__, mic->name, vr1->va, vr1->info, vr_size,
-                       _vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
-               mpsslog("magic 0x%x expected 0x%x\n",
-                       le32toh(vr1->info->magic), MIC_MAGIC + type + 1);
-               assert(le32toh(vr1->info->magic) == MIC_MAGIC + type + 1);
-       }
-done:
-       return va;
-}
-
-static int
-wait_for_card_driver(struct mic_info *mic, int fd, int type)
-{
-       struct pollfd pollfd;
-       int err;
-       struct mic_device_desc *desc = get_device_desc(mic, type);
-       __u8 prev_status;
-
-       if (!desc)
-               return -ENODEV;
-       prev_status = desc->status;
-       pollfd.fd = fd;
-       mpsslog("%s %s Waiting .... desc-> type %d status 0x%x\n",
-               mic->name, __func__, type, desc->status);
-
-       while (1) {
-               pollfd.events = POLLIN;
-               pollfd.revents = 0;
-               err = poll(&pollfd, 1, -1);
-               if (err < 0) {
-                       mpsslog("%s %s poll failed %s\n",
-                               mic->name, __func__, strerror(errno));
-                       continue;
-               }
-
-               if (pollfd.revents) {
-                       if (desc->status != prev_status) {
-                               mpsslog("%s %s Waiting... desc-> type %d "
-                                       "status 0x%x\n",
-                                       mic->name, __func__, type,
-                                       desc->status);
-                               prev_status = desc->status;
-                       }
-                       if (desc->status & VIRTIO_CONFIG_S_DRIVER_OK) {
-                               mpsslog("%s %s poll.revents %d\n",
-                                       mic->name, __func__, pollfd.revents);
-                               mpsslog("%s %s desc-> type %d status 0x%x\n",
-                                       mic->name, __func__, type,
-                                       desc->status);
-                               break;
-                       }
-               }
-       }
-       return 0;
-}
-
-/* Spin till we have some descriptors */
-static void
-spin_for_descriptors(struct mic_info *mic, struct mic_vring *vr)
-{
-       __u16 avail_idx = read_avail_idx(vr);
-
-       while (avail_idx == le16toh(READ_ONCE(vr->vr.avail->idx))) {
-#ifdef DEBUG
-               mpsslog("%s %s waiting for desc avail %d info_avail %d\n",
-                       mic->name, __func__,
-                       le16toh(vr->vr.avail->idx), vr->info->avail_idx);
-#endif
-               sched_yield();
-       }
-}
-
-static void *
-virtio_net(void *arg)
-{
-       static __u8 vnet_hdr[2][sizeof(struct virtio_net_hdr)];
-       static __u8 vnet_buf[2][MAX_NET_PKT_SIZE] __attribute__ ((aligned(64)));
-       struct iovec vnet_iov[2][2] = {
-               { { .iov_base = vnet_hdr[0], .iov_len = sizeof(vnet_hdr[0]) },
-                 { .iov_base = vnet_buf[0], .iov_len = sizeof(vnet_buf[0]) } },
-               { { .iov_base = vnet_hdr[1], .iov_len = sizeof(vnet_hdr[1]) },
-                 { .iov_base = vnet_buf[1], .iov_len = sizeof(vnet_buf[1]) } },
-       };
-       struct iovec *iov0 = vnet_iov[0], *iov1 = vnet_iov[1];
-       struct mic_info *mic = (struct mic_info *)arg;
-       char if_name[IFNAMSIZ];
-       struct pollfd net_poll[MAX_NET_FD];
-       struct mic_vring tx_vr, rx_vr;
-       struct mic_copy_desc copy;
-       struct mic_device_desc *desc;
-       int err;
-
-       snprintf(if_name, IFNAMSIZ, "mic%d", mic->id);
-       mic->mic_net.tap_fd = tun_alloc(mic, if_name);
-       if (mic->mic_net.tap_fd < 0)
-               goto done;
-
-       if (tap_configure(mic, if_name))
-               goto done;
-       mpsslog("MIC name %s id %d\n", mic->name, mic->id);
-
-       net_poll[NET_FD_VIRTIO_NET].fd = mic->mic_net.virtio_net_fd;
-       net_poll[NET_FD_VIRTIO_NET].events = POLLIN;
-       net_poll[NET_FD_TUN].fd = mic->mic_net.tap_fd;
-       net_poll[NET_FD_TUN].events = POLLIN;
-
-       if (MAP_FAILED == init_vr(mic, mic->mic_net.virtio_net_fd,
-                                 VIRTIO_ID_NET, &tx_vr, &rx_vr,
-               virtnet_dev_page.dd.num_vq)) {
-               mpsslog("%s init_vr failed %s\n",
-                       mic->name, strerror(errno));
-               goto done;
-       }
-
-       copy.iovcnt = 2;
-       desc = get_device_desc(mic, VIRTIO_ID_NET);
-
-       while (1) {
-               ssize_t len;
-
-               net_poll[NET_FD_VIRTIO_NET].revents = 0;
-               net_poll[NET_FD_TUN].revents = 0;
-
-               /* Start polling for data from tap and virtio net */
-               err = poll(net_poll, 2, -1);
-               if (err < 0) {
-                       mpsslog("%s poll failed %s\n",
-                               __func__, strerror(errno));
-                       continue;
-               }
-               if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
-                       err = wait_for_card_driver(mic,
-                                                  mic->mic_net.virtio_net_fd,
-                                                  VIRTIO_ID_NET);
-                       if (err) {
-                               mpsslog("%s %s %d Exiting...\n",
-                                       mic->name, __func__, __LINE__);
-                               break;
-                       }
-               }
-               /*
-                * Check if there is data to be read from TUN and write to
-                * virtio net fd if there is.
-                */
-               if (net_poll[NET_FD_TUN].revents & POLLIN) {
-                       copy.iov = iov0;
-                       len = readv(net_poll[NET_FD_TUN].fd,
-                               copy.iov, copy.iovcnt);
-                       if (len > 0) {
-                               struct virtio_net_hdr *hdr
-                                       = (struct virtio_net_hdr *)vnet_hdr[0];
-
-                               /* Disable checksums on the card since we are on
-                                  a reliable PCIe link */
-                               hdr->flags |= VIRTIO_NET_HDR_F_DATA_VALID;
-#ifdef DEBUG
-                               mpsslog("%s %s %d hdr->flags 0x%x ", mic->name,
-                                       __func__, __LINE__, hdr->flags);
-                               mpsslog("copy.out_len %d hdr->gso_type 0x%x\n",
-                                       copy.out_len, hdr->gso_type);
-#endif
-#ifdef DEBUG
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d read from tap 0x%lx\n",
-                                       mic->name, __func__, __LINE__,
-                                       len);
-#endif
-                               spin_for_descriptors(mic, &tx_vr);
-                               txrx_prepare(VIRTIO_ID_NET, 1, &tx_vr, &copy,
-                                            len);
-
-                               err = mic_virtio_copy(mic,
-                                       mic->mic_net.virtio_net_fd, &tx_vr,
-                                       &copy);
-                               if (err < 0) {
-                                       mpsslog("%s %s %d mic_virtio_copy %s\n",
-                                               mic->name, __func__, __LINE__,
-                                               strerror(errno));
-                               }
-                               if (!err)
-                                       verify_out_len(mic, &copy);
-#ifdef DEBUG
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d wrote to net 0x%lx\n",
-                                       mic->name, __func__, __LINE__,
-                                       sum_iovec_len(&copy));
-#endif
-                               /* Reinitialize IOV for next run */
-                               iov0[1].iov_len = MAX_NET_PKT_SIZE;
-                       } else if (len < 0) {
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d read failed %s ", mic->name,
-                                       __func__, __LINE__, strerror(errno));
-                               mpsslog("cnt %d sum %zd\n",
-                                       copy.iovcnt, sum_iovec_len(&copy));
-                       }
-               }
-
-               /*
-                * Check if there is data to be read from virtio net and
-                * write to TUN if there is.
-                */
-               if (net_poll[NET_FD_VIRTIO_NET].revents & POLLIN) {
-                       while (rx_vr.info->avail_idx !=
-                               le16toh(rx_vr.vr.avail->idx)) {
-                               copy.iov = iov1;
-                               txrx_prepare(VIRTIO_ID_NET, 0, &rx_vr, &copy,
-                                            MAX_NET_PKT_SIZE
-                                       + sizeof(struct virtio_net_hdr));
-
-                               err = mic_virtio_copy(mic,
-                                       mic->mic_net.virtio_net_fd, &rx_vr,
-                                       &copy);
-                               if (!err) {
-#ifdef DEBUG
-                                       struct virtio_net_hdr *hdr
-                                               = (struct virtio_net_hdr *)
-                                                       vnet_hdr[1];
-
-                                       mpsslog("%s %s %d hdr->flags 0x%x, ",
-                                               mic->name, __func__, __LINE__,
-                                               hdr->flags);
-                                       mpsslog("out_len %d gso_type 0x%x\n",
-                                               copy.out_len,
-                                               hdr->gso_type);
-#endif
-                                       /* Set the correct output iov_len */
-                                       iov1[1].iov_len = copy.out_len -
-                                               sizeof(struct virtio_net_hdr);
-                                       verify_out_len(mic, &copy);
-#ifdef DEBUG
-                                       disp_iovec(mic, &copy, __func__,
-                                                  __LINE__);
-                                       mpsslog("%s %s %d ",
-                                               mic->name, __func__, __LINE__);
-                                       mpsslog("read from net 0x%lx\n",
-                                               sum_iovec_len(&copy));
-#endif
-                                       len = writev(net_poll[NET_FD_TUN].fd,
-                                               copy.iov, copy.iovcnt);
-                                       if (len != sum_iovec_len(&copy)) {
-                                               mpsslog("Tun write failed %s ",
-                                                       strerror(errno));
-                                               mpsslog("len 0x%zx ", len);
-                                               mpsslog("read_len 0x%zx\n",
-                                                       sum_iovec_len(&copy));
-                                       } else {
-#ifdef DEBUG
-                                               disp_iovec(mic, &copy, __func__,
-                                                          __LINE__);
-                                               mpsslog("%s %s %d ",
-                                                       mic->name, __func__,
-                                                       __LINE__);
-                                               mpsslog("wrote to tap 0x%lx\n",
-                                                       len);
-#endif
-                                       }
-                               } else {
-                                       mpsslog("%s %s %d mic_virtio_copy %s\n",
-                                               mic->name, __func__, __LINE__,
-                                               strerror(errno));
-                                       break;
-                               }
-                       }
-               }
-               if (net_poll[NET_FD_VIRTIO_NET].revents & POLLERR)
-                       mpsslog("%s: %s: POLLERR\n", __func__, mic->name);
-       }
-done:
-       pthread_exit(NULL);
-}
-
-/* virtio_console */
-#define VIRTIO_CONSOLE_FD 0
-#define MONITOR_FD (VIRTIO_CONSOLE_FD + 1)
-#define MAX_CONSOLE_FD (MONITOR_FD + 1)  /* must be the last one + 1 */
-#define MAX_BUFFER_SIZE PAGE_SIZE
-
-static void *
-virtio_console(void *arg)
-{
-       static __u8 vcons_buf[2][PAGE_SIZE];
-       struct iovec vcons_iov[2] = {
-               { .iov_base = vcons_buf[0], .iov_len = sizeof(vcons_buf[0]) },
-               { .iov_base = vcons_buf[1], .iov_len = sizeof(vcons_buf[1]) },
-       };
-       struct iovec *iov0 = &vcons_iov[0], *iov1 = &vcons_iov[1];
-       struct mic_info *mic = (struct mic_info *)arg;
-       int err;
-       struct pollfd console_poll[MAX_CONSOLE_FD];
-       int pty_fd;
-       char *pts_name;
-       ssize_t len;
-       struct mic_vring tx_vr, rx_vr;
-       struct mic_copy_desc copy;
-       struct mic_device_desc *desc;
-
-       pty_fd = posix_openpt(O_RDWR);
-       if (pty_fd < 0) {
-               mpsslog("can't open a pseudoterminal master device: %s\n",
-                       strerror(errno));
-               goto _return;
-       }
-       pts_name = ptsname(pty_fd);
-       if (pts_name == NULL) {
-               mpsslog("can't get pts name\n");
-               goto _close_pty;
-       }
-       printf("%s console message goes to %s\n", mic->name, pts_name);
-       mpsslog("%s console message goes to %s\n", mic->name, pts_name);
-       err = grantpt(pty_fd);
-       if (err < 0) {
-               mpsslog("can't grant access: %s %s\n",
-                       pts_name, strerror(errno));
-               goto _close_pty;
-       }
-       err = unlockpt(pty_fd);
-       if (err < 0) {
-               mpsslog("can't unlock a pseudoterminal: %s %s\n",
-                       pts_name, strerror(errno));
-               goto _close_pty;
-       }
-       console_poll[MONITOR_FD].fd = pty_fd;
-       console_poll[MONITOR_FD].events = POLLIN;
-
-       console_poll[VIRTIO_CONSOLE_FD].fd = mic->mic_console.virtio_console_fd;
-       console_poll[VIRTIO_CONSOLE_FD].events = POLLIN;
-
-       if (MAP_FAILED == init_vr(mic, mic->mic_console.virtio_console_fd,
-                                 VIRTIO_ID_CONSOLE, &tx_vr, &rx_vr,
-               virtcons_dev_page.dd.num_vq)) {
-               mpsslog("%s init_vr failed %s\n",
-                       mic->name, strerror(errno));
-               goto _close_pty;
-       }
-
-       copy.iovcnt = 1;
-       desc = get_device_desc(mic, VIRTIO_ID_CONSOLE);
-
-       for (;;) {
-               console_poll[MONITOR_FD].revents = 0;
-               console_poll[VIRTIO_CONSOLE_FD].revents = 0;
-               err = poll(console_poll, MAX_CONSOLE_FD, -1);
-               if (err < 0) {
-                       mpsslog("%s %d: poll failed: %s\n", __func__, __LINE__,
-                               strerror(errno));
-                       continue;
-               }
-               if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
-                       err = wait_for_card_driver(mic,
-                                       mic->mic_console.virtio_console_fd,
-                                       VIRTIO_ID_CONSOLE);
-                       if (err) {
-                               mpsslog("%s %s %d Exiting...\n",
-                                       mic->name, __func__, __LINE__);
-                               break;
-                       }
-               }
-
-               if (console_poll[MONITOR_FD].revents & POLLIN) {
-                       copy.iov = iov0;
-                       len = readv(pty_fd, copy.iov, copy.iovcnt);
-                       if (len > 0) {
-#ifdef DEBUG
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d read from tap 0x%lx\n",
-                                       mic->name, __func__, __LINE__,
-                                       len);
-#endif
-                               spin_for_descriptors(mic, &tx_vr);
-                               txrx_prepare(VIRTIO_ID_CONSOLE, 1, &tx_vr,
-                                            &copy, len);
-
-                               err = mic_virtio_copy(mic,
-                                       mic->mic_console.virtio_console_fd,
-                                       &tx_vr, &copy);
-                               if (err < 0) {
-                                       mpsslog("%s %s %d mic_virtio_copy %s\n",
-                                               mic->name, __func__, __LINE__,
-                                               strerror(errno));
-                               }
-                               if (!err)
-                                       verify_out_len(mic, &copy);
-#ifdef DEBUG
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d wrote to net 0x%lx\n",
-                                       mic->name, __func__, __LINE__,
-                                       sum_iovec_len(&copy));
-#endif
-                               /* Reinitialize IOV for next run */
-                               iov0->iov_len = PAGE_SIZE;
-                       } else if (len < 0) {
-                               disp_iovec(mic, &copy, __func__, __LINE__);
-                               mpsslog("%s %s %d read failed %s ",
-                                       mic->name, __func__, __LINE__,
-                                       strerror(errno));
-                               mpsslog("cnt %d sum %zd\n",
-                                       copy.iovcnt, sum_iovec_len(&copy));
-                       }
-               }
-
-               if (console_poll[VIRTIO_CONSOLE_FD].revents & POLLIN) {
-                       while (rx_vr.info->avail_idx !=
-                               le16toh(rx_vr.vr.avail->idx)) {
-                               copy.iov = iov1;
-                               txrx_prepare(VIRTIO_ID_CONSOLE, 0, &rx_vr,
-                                            &copy, PAGE_SIZE);
-
-                               err = mic_virtio_copy(mic,
-                                       mic->mic_console.virtio_console_fd,
-                                       &rx_vr, &copy);
-                               if (!err) {
-                                       /* Set the correct output iov_len */
-                                       iov1->iov_len = copy.out_len;
-                                       verify_out_len(mic, &copy);
-#ifdef DEBUG
-                                       disp_iovec(mic, &copy, __func__,
-                                                  __LINE__);
-                                       mpsslog("%s %s %d ",
-                                               mic->name, __func__, __LINE__);
-                                       mpsslog("read from net 0x%lx\n",
-                                               sum_iovec_len(&copy));
-#endif
-                                       len = writev(pty_fd,
-                                               copy.iov, copy.iovcnt);
-                                       if (len != sum_iovec_len(&copy)) {
-                                               mpsslog("Tun write failed %s ",
-                                                       strerror(errno));
-                                               mpsslog("len 0x%zx ", len);
-                                               mpsslog("read_len 0x%zx\n",
-                                                       sum_iovec_len(&copy));
-                                       } else {
-#ifdef DEBUG
-                                               disp_iovec(mic, &copy, __func__,
-                                                          __LINE__);
-                                               mpsslog("%s %s %d ",
-                                                       mic->name, __func__,
-                                                       __LINE__);
-                                               mpsslog("wrote to tap 0x%lx\n",
-                                                       len);
-#endif
-                                       }
-                               } else {
-                                       mpsslog("%s %s %d mic_virtio_copy %s\n",
-                                               mic->name, __func__, __LINE__,
-                                               strerror(errno));
-                                       break;
-                               }
-                       }
-               }
-               if (console_poll[NET_FD_VIRTIO_NET].revents & POLLERR)
-                       mpsslog("%s: %s: POLLERR\n", __func__, mic->name);
-       }
-_close_pty:
-       close(pty_fd);
-_return:
-       pthread_exit(NULL);
-}
-
-static void
-add_virtio_device(struct mic_info *mic, struct mic_device_desc *dd)
-{
-       char path[PATH_MAX];
-       int fd, err;
-
-       snprintf(path, PATH_MAX, "/dev/vop_virtio%d", mic->id);
-       fd = open(path, O_RDWR);
-       if (fd < 0) {
-               mpsslog("Could not open %s %s\n", path, strerror(errno));
-               return;
-       }
-
-       err = ioctl(fd, MIC_VIRTIO_ADD_DEVICE, dd);
-       if (err < 0) {
-               mpsslog("Could not add %d %s\n", dd->type, strerror(errno));
-               close(fd);
-               return;
-       }
-       switch (dd->type) {
-       case VIRTIO_ID_NET:
-               mic->mic_net.virtio_net_fd = fd;
-               mpsslog("Added VIRTIO_ID_NET for %s\n", mic->name);
-               break;
-       case VIRTIO_ID_CONSOLE:
-               mic->mic_console.virtio_console_fd = fd;
-               mpsslog("Added VIRTIO_ID_CONSOLE for %s\n", mic->name);
-               break;
-       case VIRTIO_ID_BLOCK:
-               mic->mic_virtblk.virtio_block_fd = fd;
-               mpsslog("Added VIRTIO_ID_BLOCK for %s\n", mic->name);
-               break;
-       }
-}
-
-static bool
-set_backend_file(struct mic_info *mic)
-{
-       FILE *config;
-       char buff[PATH_MAX], *line, *evv, *p;
-
-       snprintf(buff, PATH_MAX, "%s/mpssd%03d.conf", mic_config_dir, mic->id);
-       config = fopen(buff, "r");
-       if (config == NULL)
-               return false;
-       do {  /* look for "virtblk_backend=XXXX" */
-               line = fgets(buff, PATH_MAX, config);
-               if (line == NULL)
-                       break;
-               if (*line == '#')
-                       continue;
-               p = strchr(line, '\n');
-               if (p)
-                       *p = '\0';
-       } while (strncmp(line, virtblk_backend, strlen(virtblk_backend)) != 0);
-       fclose(config);
-       if (line == NULL)
-               return false;
-       evv = strchr(line, '=');
-       if (evv == NULL)
-               return false;
-       mic->mic_virtblk.backend_file = malloc(strlen(evv) + 1);
-       if (mic->mic_virtblk.backend_file == NULL) {
-               mpsslog("%s %d can't allocate memory\n", mic->name, mic->id);
-               return false;
-       }
-       strcpy(mic->mic_virtblk.backend_file, evv + 1);
-       return true;
-}
-
-#define SECTOR_SIZE 512
-static bool
-set_backend_size(struct mic_info *mic)
-{
-       mic->mic_virtblk.backend_size = lseek(mic->mic_virtblk.backend, 0,
-               SEEK_END);
-       if (mic->mic_virtblk.backend_size < 0) {
-               mpsslog("%s: can't seek: %s\n",
-                       mic->name, mic->mic_virtblk.backend_file);
-               return false;
-       }
-       virtblk_dev_page.blk_config.capacity =
-               mic->mic_virtblk.backend_size / SECTOR_SIZE;
-       if ((mic->mic_virtblk.backend_size % SECTOR_SIZE) != 0)
-               virtblk_dev_page.blk_config.capacity++;
-
-       virtblk_dev_page.blk_config.capacity =
-               htole64(virtblk_dev_page.blk_config.capacity);
-
-       return true;
-}
-
-static bool
-open_backend(struct mic_info *mic)
-{
-       if (!set_backend_file(mic))
-               goto _error_exit;
-       mic->mic_virtblk.backend = open(mic->mic_virtblk.backend_file, O_RDWR);
-       if (mic->mic_virtblk.backend < 0) {
-               mpsslog("%s: can't open: %s\n", mic->name,
-                       mic->mic_virtblk.backend_file);
-               goto _error_free;
-       }
-       if (!set_backend_size(mic))
-               goto _error_close;
-       mic->mic_virtblk.backend_addr = mmap(NULL,
-               mic->mic_virtblk.backend_size,
-               PROT_READ|PROT_WRITE, MAP_SHARED,
-               mic->mic_virtblk.backend, 0L);
-       if (mic->mic_virtblk.backend_addr == MAP_FAILED) {
-               mpsslog("%s: can't map: %s %s\n",
-                       mic->name, mic->mic_virtblk.backend_file,
-                       strerror(errno));
-               goto _error_close;
-       }
-       return true;
-
- _error_close:
-       close(mic->mic_virtblk.backend);
- _error_free:
-       free(mic->mic_virtblk.backend_file);
- _error_exit:
-       return false;
-}
-
-static void
-close_backend(struct mic_info *mic)
-{
-       munmap(mic->mic_virtblk.backend_addr, mic->mic_virtblk.backend_size);
-       close(mic->mic_virtblk.backend);
-       free(mic->mic_virtblk.backend_file);
-}
-
-static bool
-start_virtblk(struct mic_info *mic, struct mic_vring *vring)
-{
-       if (((unsigned long)&virtblk_dev_page.blk_config % 8) != 0) {
-               mpsslog("%s: blk_config is not 8 byte aligned.\n",
-                       mic->name);
-               return false;
-       }
-       add_virtio_device(mic, &virtblk_dev_page.dd);
-       if (MAP_FAILED == init_vr(mic, mic->mic_virtblk.virtio_block_fd,
-                                 VIRTIO_ID_BLOCK, vring, NULL,
-                                 virtblk_dev_page.dd.num_vq)) {
-               mpsslog("%s init_vr failed %s\n",
-                       mic->name, strerror(errno));
-               return false;
-       }
-       return true;
-}
-
-static void
-stop_virtblk(struct mic_info *mic)
-{
-       int vr_size, ret;
-
-       vr_size = PAGE_ALIGN(_vring_size(MIC_VRING_ENTRIES,
-                                        MIC_VIRTIO_RING_ALIGN) +
-                            sizeof(struct _mic_vring_info));
-       ret = munmap(mic->mic_virtblk.block_dp,
-               MIC_DEVICE_PAGE_END + vr_size * virtblk_dev_page.dd.num_vq);
-       if (ret < 0)
-               mpsslog("%s munmap errno %d\n", mic->name, errno);
-       close(mic->mic_virtblk.virtio_block_fd);
-}
-
-static __u8
-header_error_check(struct vring_desc *desc)
-{
-       if (le32toh(desc->len) != sizeof(struct virtio_blk_outhdr)) {
-               mpsslog("%s() %d: length is not sizeof(virtio_blk_outhd)\n",
-                       __func__, __LINE__);
-               return -EIO;
-       }
-       if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT)) {
-               mpsslog("%s() %d: alone\n",
-                       __func__, __LINE__);
-               return -EIO;
-       }
-       if (le16toh(desc->flags) & VRING_DESC_F_WRITE) {
-               mpsslog("%s() %d: not read\n",
-                       __func__, __LINE__);
-               return -EIO;
-       }
-       return 0;
-}
-
-static int
-read_header(int fd, struct virtio_blk_outhdr *hdr, __u32 desc_idx)
-{
-       struct iovec iovec;
-       struct mic_copy_desc copy;
-
-       iovec.iov_len = sizeof(*hdr);
-       iovec.iov_base = hdr;
-       copy.iov = &iovec;
-       copy.iovcnt = 1;
-       copy.vr_idx = 0;  /* only one vring on virtio_block */
-       copy.update_used = false;  /* do not update used index */
-       return ioctl(fd, MIC_VIRTIO_COPY_DESC, &copy);
-}
-
-static int
-transfer_blocks(int fd, struct iovec *iovec, __u32 iovcnt)
-{
-       struct mic_copy_desc copy;
-
-       copy.iov = iovec;
-       copy.iovcnt = iovcnt;
-       copy.vr_idx = 0;  /* only one vring on virtio_block */
-       copy.update_used = false;  /* do not update used index */
-       return ioctl(fd, MIC_VIRTIO_COPY_DESC, &copy);
-}
-
-static __u8
-status_error_check(struct vring_desc *desc)
-{
-       if (le32toh(desc->len) != sizeof(__u8)) {
-               mpsslog("%s() %d: length is not sizeof(status)\n",
-                       __func__, __LINE__);
-               return -EIO;
-       }
-       return 0;
-}
-
-static int
-write_status(int fd, __u8 *status)
-{
-       struct iovec iovec;
-       struct mic_copy_desc copy;
-
-       iovec.iov_base = status;
-       iovec.iov_len = sizeof(*status);
-       copy.iov = &iovec;
-       copy.iovcnt = 1;
-       copy.vr_idx = 0;  /* only one vring on virtio_block */
-       copy.update_used = true; /* Update used index */
-       return ioctl(fd, MIC_VIRTIO_COPY_DESC, &copy);
-}
-
-#ifndef VIRTIO_BLK_T_GET_ID
-#define VIRTIO_BLK_T_GET_ID    8
-#endif
-
-static void *
-virtio_block(void *arg)
-{
-       struct mic_info *mic = (struct mic_info *)arg;
-       int ret;
-       struct pollfd block_poll;
-       struct mic_vring vring;
-       __u16 avail_idx;
-       __u32 desc_idx;
-       struct vring_desc *desc;
-       struct iovec *iovec, *piov;
-       __u8 status;
-       __u32 buffer_desc_idx;
-       struct virtio_blk_outhdr hdr;
-       void *fos;
-
-       for (;;) {  /* forever */
-               if (!open_backend(mic)) { /* No virtblk */
-                       for (mic->mic_virtblk.signaled = 0;
-                               !mic->mic_virtblk.signaled;)
-                               sleep(1);
-                       continue;
-               }
-
-               /* backend file is specified. */
-               if (!start_virtblk(mic, &vring))
-                       goto _close_backend;
-               iovec = malloc(sizeof(*iovec) *
-                       le32toh(virtblk_dev_page.blk_config.seg_max));
-               if (!iovec) {
-                       mpsslog("%s: can't alloc iovec: %s\n",
-                               mic->name, strerror(ENOMEM));
-                       goto _stop_virtblk;
-               }
-
-               block_poll.fd = mic->mic_virtblk.virtio_block_fd;
-               block_poll.events = POLLIN;
-               for (mic->mic_virtblk.signaled = 0;
-                    !mic->mic_virtblk.signaled;) {
-                       block_poll.revents = 0;
-                                       /* timeout in 1 sec to see signaled */
-                       ret = poll(&block_poll, 1, 1000);
-                       if (ret < 0) {
-                               mpsslog("%s %d: poll failed: %s\n",
-                                       __func__, __LINE__,
-                                       strerror(errno));
-                               continue;
-                       }
-
-                       if (!(block_poll.revents & POLLIN)) {
-#ifdef DEBUG
-                               mpsslog("%s %d: block_poll.revents=0x%x\n",
-                                       __func__, __LINE__, block_poll.revents);
-#endif
-                               continue;
-                       }
-
-                       /* POLLIN */
-                       while (vring.info->avail_idx !=
-                               le16toh(vring.vr.avail->idx)) {
-                               /* read header element */
-                               avail_idx =
-                                       vring.info->avail_idx &
-                                       (vring.vr.num - 1);
-                               desc_idx = le16toh(
-                                       vring.vr.avail->ring[avail_idx]);
-                               desc = &vring.vr.desc[desc_idx];
-#ifdef DEBUG
-                               mpsslog("%s() %d: avail_idx=%d ",
-                                       __func__, __LINE__,
-                                       vring.info->avail_idx);
-                               mpsslog("vring.vr.num=%d desc=%p\n",
-                                       vring.vr.num, desc);
-#endif
-                               status = header_error_check(desc);
-                               ret = read_header(
-                                       mic->mic_virtblk.virtio_block_fd,
-                                       &hdr, desc_idx);
-                               if (ret < 0) {
-                                       mpsslog("%s() %d %s: ret=%d %s\n",
-                                               __func__, __LINE__,
-                                               mic->name, ret,
-                                               strerror(errno));
-                                       break;
-                               }
-                               /* buffer element */
-                               piov = iovec;
-                               status = 0;
-                               fos = mic->mic_virtblk.backend_addr +
-                                       (hdr.sector * SECTOR_SIZE);
-                               buffer_desc_idx = next_desc(desc);
-                               desc_idx = buffer_desc_idx;
-                               for (desc = &vring.vr.desc[buffer_desc_idx];
-                                    desc->flags & VRING_DESC_F_NEXT;
-                                    desc_idx = next_desc(desc),
-                                            desc = &vring.vr.desc[desc_idx]) {
-                                       piov->iov_len = desc->len;
-                                       piov->iov_base = fos;
-                                       piov++;
-                                       fos += desc->len;
-                               }
-                               /* Returning NULLs for VIRTIO_BLK_T_GET_ID. */
-                               if (hdr.type & ~(VIRTIO_BLK_T_OUT |
-                                       VIRTIO_BLK_T_GET_ID)) {
-                                       /*
-                                         VIRTIO_BLK_T_IN - does not do
-                                         anything. Probably for documenting.
-                                         VIRTIO_BLK_T_SCSI_CMD - for
-                                         virtio_scsi.
-                                         VIRTIO_BLK_T_FLUSH - turned off in
-                                         config space.
-                                         VIRTIO_BLK_T_BARRIER - defined but not
-                                         used in anywhere.
-                                       */
-                                       mpsslog("%s() %d: type %x ",
-                                               __func__, __LINE__,
-                                               hdr.type);
-                                       mpsslog("is not supported\n");
-                                       status = -ENOTSUP;
-
-                               } else {
-                                       ret = transfer_blocks(
-                                       mic->mic_virtblk.virtio_block_fd,
-                                               iovec,
-                                               piov - iovec);
-                                       if (ret < 0 &&
-                                           status != 0)
-                                               status = ret;
-                               }
-                               /* write status and update used pointer */
-                               if (status != 0)
-                                       status = status_error_check(desc);
-                               ret = write_status(
-                                       mic->mic_virtblk.virtio_block_fd,
-                                       &status);
-#ifdef DEBUG
-                               mpsslog("%s() %d: write status=%d on desc=%p\n",
-                                       __func__, __LINE__,
-                                       status, desc);
-#endif
-                       }
-               }
-               free(iovec);
-_stop_virtblk:
-               stop_virtblk(mic);
-_close_backend:
-               close_backend(mic);
-       }  /* forever */
-
-       pthread_exit(NULL);
-}
-
-static void
-reset(struct mic_info *mic)
-{
-#define RESET_TIMEOUT 120
-       int i = RESET_TIMEOUT;
-       setsysfs(mic->name, "state", "reset");
-       while (i) {
-               char *state;
-               state = readsysfs(mic->name, "state");
-               if (!state)
-                       goto retry;
-               mpsslog("%s: %s %d state %s\n",
-                       mic->name, __func__, __LINE__, state);
-
-               if (!strcmp(state, "ready")) {
-                       free(state);
-                       break;
-               }
-               free(state);
-retry:
-               sleep(1);
-               i--;
-       }
-}
-
-static int
-get_mic_shutdown_status(struct mic_info *mic, char *shutdown_status)
-{
-       if (!strcmp(shutdown_status, "nop"))
-               return MIC_NOP;
-       if (!strcmp(shutdown_status, "crashed"))
-               return MIC_CRASHED;
-       if (!strcmp(shutdown_status, "halted"))
-               return MIC_HALTED;
-       if (!strcmp(shutdown_status, "poweroff"))
-               return MIC_POWER_OFF;
-       if (!strcmp(shutdown_status, "restart"))
-               return MIC_RESTART;
-       mpsslog("%s: BUG invalid status %s\n", mic->name, shutdown_status);
-       /* Invalid state */
-       assert(0);
-};
-
-static int get_mic_state(struct mic_info *mic)
-{
-       char *state = NULL;
-       enum mic_states mic_state;
-
-       while (!state) {
-               state = readsysfs(mic->name, "state");
-               sleep(1);
-       }
-       mpsslog("%s: %s %d state %s\n",
-               mic->name, __func__, __LINE__, state);
-
-       if (!strcmp(state, "ready")) {
-               mic_state = MIC_READY;
-       } else if (!strcmp(state, "booting")) {
-               mic_state = MIC_BOOTING;
-       } else if (!strcmp(state, "online")) {
-               mic_state = MIC_ONLINE;
-       } else if (!strcmp(state, "shutting_down")) {
-               mic_state = MIC_SHUTTING_DOWN;
-       } else if (!strcmp(state, "reset_failed")) {
-               mic_state = MIC_RESET_FAILED;
-       } else if (!strcmp(state, "resetting")) {
-               mic_state = MIC_RESETTING;
-       } else {
-               mpsslog("%s: BUG invalid state %s\n", mic->name, state);
-               assert(0);
-       }
-
-       free(state);
-       return mic_state;
-};
-
-static void mic_handle_shutdown(struct mic_info *mic)
-{
-#define SHUTDOWN_TIMEOUT 60
-       int i = SHUTDOWN_TIMEOUT;
-       char *shutdown_status;
-       while (i) {
-               shutdown_status = readsysfs(mic->name, "shutdown_status");
-               if (!shutdown_status) {
-                       sleep(1);
-                       continue;
-               }
-               mpsslog("%s: %s %d shutdown_status %s\n",
-                       mic->name, __func__, __LINE__, shutdown_status);
-               switch (get_mic_shutdown_status(mic, shutdown_status)) {
-               case MIC_RESTART:
-                       mic->restart = 1;
-               case MIC_HALTED:
-               case MIC_POWER_OFF:
-               case MIC_CRASHED:
-                       free(shutdown_status);
-                       goto reset;
-               default:
-                       break;
-               }
-               free(shutdown_status);
-               sleep(1);
-               i--;
-       }
-reset:
-       if (!i)
-               mpsslog("%s: %s %d timing out waiting for shutdown_status %s\n",
-                       mic->name, __func__, __LINE__, shutdown_status);
-       reset(mic);
-}
-
-static int open_state_fd(struct mic_info *mic)
-{
-       char pathname[PATH_MAX];
-       int fd;
-
-       snprintf(pathname, PATH_MAX - 1, "%s/%s/%s",
-                MICSYSFSDIR, mic->name, "state");
-
-       fd = open(pathname, O_RDONLY);
-       if (fd < 0)
-               mpsslog("%s: opening file %s failed %s\n",
-                       mic->name, pathname, strerror(errno));
-       return fd;
-}
-
-static int block_till_state_change(int fd, struct mic_info *mic)
-{
-       struct pollfd ufds[1];
-       char value[PAGE_SIZE];
-       int ret;
-
-       ufds[0].fd = fd;
-       ufds[0].events = POLLERR | POLLPRI;
-       ret = poll(ufds, 1, -1);
-       if (ret < 0) {
-               mpsslog("%s: %s %d poll failed %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               return ret;
-       }
-
-       ret = lseek(fd, 0, SEEK_SET);
-       if (ret < 0) {
-               mpsslog("%s: %s %d Failed to seek to 0: %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               return ret;
-       }
-
-       ret = read(fd, value, sizeof(value));
-       if (ret < 0) {
-               mpsslog("%s: %s %d Failed to read sysfs entry: %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               return ret;
-       }
-
-       return 0;
-}
-
-static void *
-mic_config(void *arg)
-{
-       struct mic_info *mic = (struct mic_info *)arg;
-       int fd, ret, stat = 0;
-
-       fd = open_state_fd(mic);
-       if (fd < 0) {
-               mpsslog("%s: %s %d open state fd failed %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               goto exit;
-       }
-
-       do {
-               ret = block_till_state_change(fd, mic);
-               if (ret < 0) {
-                       mpsslog("%s: %s %d block_till_state_change error %s\n",
-                               mic->name, __func__, __LINE__, strerror(errno));
-                       goto close_exit;
-               }
-
-               switch (get_mic_state(mic)) {
-               case MIC_SHUTTING_DOWN:
-                       mic_handle_shutdown(mic);
-                       break;
-               case MIC_READY:
-               case MIC_RESET_FAILED:
-                       ret = kill(mic->pid, SIGTERM);
-                       mpsslog("%s: %s %d kill pid %d ret %d\n",
-                               mic->name, __func__, __LINE__,
-                               mic->pid, ret);
-                       if (!ret) {
-                               ret = waitpid(mic->pid, &stat,
-                                             WIFSIGNALED(stat));
-                               mpsslog("%s: %s %d waitpid ret %d pid %d\n",
-                                       mic->name, __func__, __LINE__,
-                                       ret, mic->pid);
-                       }
-                       if (mic->boot_on_resume) {
-                               setsysfs(mic->name, "state", "boot");
-                               mic->boot_on_resume = 0;
-                       }
-                       goto close_exit;
-               default:
-                       break;
-               }
-       } while (1);
-
-close_exit:
-       close(fd);
-exit:
-       init_mic(mic);
-       pthread_exit(NULL);
-}
-
-static void
-set_cmdline(struct mic_info *mic)
-{
-       char buffer[PATH_MAX];
-       int len;
-
-       len = snprintf(buffer, PATH_MAX,
-               "clocksource=tsc highres=off nohz=off ");
-       len += snprintf(buffer + len, PATH_MAX - len,
-               "cpufreq_on;corec6_off;pc3_off;pc6_off ");
-       len += snprintf(buffer + len, PATH_MAX - len,
-               "ifcfg=static;address,172.31.%d.1;netmask,255.255.255.0",
-               mic->id + 1);
-
-       setsysfs(mic->name, "cmdline", buffer);
-       mpsslog("%s: Command line: \"%s\"\n", mic->name, buffer);
-       snprintf(buffer, PATH_MAX, "172.31.%d.1", mic->id + 1);
-       mpsslog("%s: IPADDR: \"%s\"\n", mic->name, buffer);
-}
-
-static void
-set_log_buf_info(struct mic_info *mic)
-{
-       int fd;
-       off_t len;
-       char system_map[] = "/lib/firmware/mic/System.map";
-       char *map, *temp, log_buf[17] = {'\0'};
-
-       fd = open(system_map, O_RDONLY);
-       if (fd < 0) {
-               mpsslog("%s: Opening System.map failed: %d\n",
-                       mic->name, errno);
-               return;
-       }
-       len = lseek(fd, 0, SEEK_END);
-       if (len < 0) {
-               mpsslog("%s: Reading System.map size failed: %d\n",
-                       mic->name, errno);
-               close(fd);
-               return;
-       }
-       map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
-       if (map == MAP_FAILED) {
-               mpsslog("%s: mmap of System.map failed: %d\n",
-                       mic->name, errno);
-               close(fd);
-               return;
-       }
-       temp = strstr(map, "__log_buf");
-       if (!temp) {
-               mpsslog("%s: __log_buf not found: %d\n", mic->name, errno);
-               munmap(map, len);
-               close(fd);
-               return;
-       }
-       strncpy(log_buf, temp - 19, 16);
-       setsysfs(mic->name, "log_buf_addr", log_buf);
-       mpsslog("%s: log_buf_addr: %s\n", mic->name, log_buf);
-       temp = strstr(map, "log_buf_len");
-       if (!temp) {
-               mpsslog("%s: log_buf_len not found: %d\n", mic->name, errno);
-               munmap(map, len);
-               close(fd);
-               return;
-       }
-       strncpy(log_buf, temp - 19, 16);
-       setsysfs(mic->name, "log_buf_len", log_buf);
-       mpsslog("%s: log_buf_len: %s\n", mic->name, log_buf);
-       munmap(map, len);
-       close(fd);
-}
-
-static void
-change_virtblk_backend(int x, siginfo_t *siginfo, void *p)
-{
-       struct mic_info *mic;
-
-       for (mic = mic_list.next; mic != NULL; mic = mic->next)
-               mic->mic_virtblk.signaled = 1/* true */;
-}
-
-static void
-set_mic_boot_params(struct mic_info *mic)
-{
-       set_log_buf_info(mic);
-       set_cmdline(mic);
-}
-
-static void *
-init_mic(void *arg)
-{
-       struct mic_info *mic = (struct mic_info *)arg;
-       struct sigaction ignore = {
-               .sa_flags = 0,
-               .sa_handler = SIG_IGN
-       };
-       struct sigaction act = {
-               .sa_flags = SA_SIGINFO,
-               .sa_sigaction = change_virtblk_backend,
-       };
-       char buffer[PATH_MAX];
-       int err, fd;
-
-       /*
-        * Currently, one virtio block device is supported for each MIC card
-        * at a time. Any user (or test) can send a SIGUSR1 to the MIC daemon.
-        * The signal informs the virtio block backend about a change in the
-        * configuration file which specifies the virtio backend file name on
-        * the host. Virtio block backend then re-reads the configuration file
-        * and switches to the new block device. This signalling mechanism may
-        * not be required once multiple virtio block devices are supported by
-        * the MIC daemon.
-        */
-       sigaction(SIGUSR1, &ignore, NULL);
-retry:
-       fd = open_state_fd(mic);
-       if (fd < 0) {
-               mpsslog("%s: %s %d open state fd failed %s\n",
-                       mic->name, __func__, __LINE__, strerror(errno));
-               sleep(2);
-               goto retry;
-       }
-
-       if (mic->restart) {
-               snprintf(buffer, PATH_MAX, "boot");
-               setsysfs(mic->name, "state", buffer);
-               mpsslog("%s restarting mic %d\n",
-                       mic->name, mic->restart);
-               mic->restart = 0;
-       }
-
-       while (1) {
-               while (block_till_state_change(fd, mic)) {
-                       mpsslog("%s: %s %d block_till_state_change error %s\n",
-                               mic->name, __func__, __LINE__, strerror(errno));
-                       sleep(2);
-                       continue;
-               }
-
-               if (get_mic_state(mic) == MIC_BOOTING)
-                       break;
-       }
-
-       mic->pid = fork();
-       switch (mic->pid) {
-       case 0:
-               add_virtio_device(mic, &virtcons_dev_page.dd);
-               add_virtio_device(mic, &virtnet_dev_page.dd);
-               err = pthread_create(&mic->mic_console.console_thread, NULL,
-                       virtio_console, mic);
-               if (err)
-                       mpsslog("%s virtcons pthread_create failed %s\n",
-                               mic->name, strerror(err));
-               err = pthread_create(&mic->mic_net.net_thread, NULL,
-                       virtio_net, mic);
-               if (err)
-                       mpsslog("%s virtnet pthread_create failed %s\n",
-                               mic->name, strerror(err));
-               err = pthread_create(&mic->mic_virtblk.block_thread, NULL,
-                       virtio_block, mic);
-               if (err)
-                       mpsslog("%s virtblk pthread_create failed %s\n",
-                               mic->name, strerror(err));
-               sigemptyset(&act.sa_mask);
-               err = sigaction(SIGUSR1, &act, NULL);
-               if (err)
-                       mpsslog("%s sigaction SIGUSR1 failed %s\n",
-                               mic->name, strerror(errno));
-               while (1)
-                       sleep(60);
-       case -1:
-               mpsslog("fork failed MIC name %s id %d errno %d\n",
-                       mic->name, mic->id, errno);
-               break;
-       default:
-               err = pthread_create(&mic->config_thread, NULL,
-                                    mic_config, mic);
-               if (err)
-                       mpsslog("%s mic_config pthread_create failed %s\n",
-                               mic->name, strerror(err));
-       }
-
-       return NULL;
-}
-
-static void
-start_daemon(void)
-{
-       struct mic_info *mic;
-       int err;
-
-       for (mic = mic_list.next; mic; mic = mic->next) {
-               set_mic_boot_params(mic);
-               err = pthread_create(&mic->init_thread, NULL, init_mic, mic);
-               if (err)
-                       mpsslog("%s init_mic pthread_create failed %s\n",
-                               mic->name, strerror(err));
-       }
-
-       while (1)
-               sleep(60);
-}
-
-static int
-init_mic_list(void)
-{
-       struct mic_info *mic = &mic_list;
-       struct dirent *file;
-       DIR *dp;
-       int cnt = 0;
-
-       dp = opendir(MICSYSFSDIR);
-       if (!dp)
-               return 0;
-
-       while ((file = readdir(dp)) != NULL) {
-               if (!strncmp(file->d_name, "mic", 3)) {
-                       mic->next = calloc(1, sizeof(struct mic_info));
-                       if (mic->next) {
-                               mic = mic->next;
-                               mic->id = atoi(&file->d_name[3]);
-                               mic->name = malloc(strlen(file->d_name) + 16);
-                               if (mic->name)
-                                       strcpy(mic->name, file->d_name);
-                               mpsslog("MIC name %s id %d\n", mic->name,
-                                       mic->id);
-                               cnt++;
-                       }
-               }
-       }
-
-       closedir(dp);
-       return cnt;
-}
-
-void
-mpsslog(char *format, ...)
-{
-       va_list args;
-       char buffer[4096];
-       char ts[52], *ts1;
-       time_t t;
-
-       if (logfp == NULL)
-               return;
-
-       va_start(args, format);
-       vsprintf(buffer, format, args);
-       va_end(args);
-
-       time(&t);
-       ts1 = ctime_r(&t, ts);
-       ts1[strlen(ts1) - 1] = '\0';
-       fprintf(logfp, "%s: %s", ts1, buffer);
-
-       fflush(logfp);
-}
-
-int
-main(int argc, char *argv[])
-{
-       int cnt;
-       pid_t pid;
-
-       myname = argv[0];
-
-       logfp = fopen(LOGFILE_NAME, "a+");
-       if (!logfp) {
-               fprintf(stderr, "cannot open logfile '%s'\n", LOGFILE_NAME);
-               exit(1);
-       }
-       pid = fork();
-       switch (pid) {
-       case 0:
-               break;
-       case -1:
-               exit(2);
-       default:
-               exit(0);
-       }
-
-       mpsslog("MIC Daemon start\n");
-
-       cnt = init_mic_list();
-       if (cnt == 0) {
-               mpsslog("MIC module not loaded\n");
-               exit(3);
-       }
-       mpsslog("MIC found %d devices\n", cnt);
-
-       start_daemon();
-
-       exit(0);
-}
diff --git a/samples/mic/mpssd/mpssd.h b/samples/mic/mpssd/mpssd.h
deleted file mode 100644 (file)
index 5f98bda..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC User Space Tools.
- */
-#ifndef _MPSSD_H_
-#define _MPSSD_H_
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <libgen.h>
-#include <pthread.h>
-#include <stdarg.h>
-#include <time.h>
-#include <errno.h>
-#include <sys/dir.h>
-#include <sys/ioctl.h>
-#include <sys/poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/utsname.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <signal.h>
-#include <limits.h>
-#include <syslog.h>
-#include <getopt.h>
-#include <net/if.h>
-#include <linux/if_tun.h>
-#include <linux/virtio_ids.h>
-
-#define MICSYSFSDIR "/sys/class/mic"
-#define LOGFILE_NAME "/var/log/mpssd"
-#define PAGE_SIZE 4096
-
-struct mic_console_info {
-       pthread_t       console_thread;
-       int             virtio_console_fd;
-       void            *console_dp;
-};
-
-struct mic_net_info {
-       pthread_t       net_thread;
-       int             virtio_net_fd;
-       int             tap_fd;
-       void            *net_dp;
-};
-
-struct mic_virtblk_info {
-       pthread_t       block_thread;
-       int             virtio_block_fd;
-       void            *block_dp;
-       volatile sig_atomic_t   signaled;
-       char            *backend_file;
-       int             backend;
-       void            *backend_addr;
-       long            backend_size;
-};
-
-struct mic_info {
-       int             id;
-       char            *name;
-       pthread_t       config_thread;
-       pthread_t       init_thread;
-       pid_t           pid;
-       struct mic_console_info mic_console;
-       struct mic_net_info     mic_net;
-       struct mic_virtblk_info mic_virtblk;
-       int             restart;
-       int             boot_on_resume;
-       struct mic_info *next;
-};
-
-__attribute__((format(printf, 1, 2)))
-void mpsslog(char *format, ...);
-char *readsysfs(char *dir, char *entry);
-int setsysfs(char *dir, char *entry, char *value);
-#endif
diff --git a/samples/mic/mpssd/sysfs.c b/samples/mic/mpssd/sysfs.c
deleted file mode 100644 (file)
index 3fb08eb..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Intel MIC Platform Software Stack (MPSS)
- *
- * Copyright(c) 2013 Intel Corporation.
- *
- * Intel MIC User Space Tools.
- */
-
-#include "mpssd.h"
-
-#define PAGE_SIZE 4096
-
-char *
-readsysfs(char *dir, char *entry)
-{
-       char filename[PATH_MAX];
-       char value[PAGE_SIZE];
-       char *string = NULL;
-       int fd;
-       int len;
-
-       if (dir == NULL)
-               snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
-       else
-               snprintf(filename, PATH_MAX,
-                        "%s/%s/%s", MICSYSFSDIR, dir, entry);
-
-       fd = open(filename, O_RDONLY);
-       if (fd < 0) {
-               mpsslog("Failed to open sysfs entry '%s': %s\n",
-                       filename, strerror(errno));
-               return NULL;
-       }
-
-       len = read(fd, value, sizeof(value));
-       if (len < 0) {
-               mpsslog("Failed to read sysfs entry '%s': %s\n",
-                       filename, strerror(errno));
-               goto readsys_ret;
-       }
-       if (len == 0)
-               goto readsys_ret;
-
-       value[len - 1] = '\0';
-
-       string = malloc(strlen(value) + 1);
-       if (string)
-               strcpy(string, value);
-
-readsys_ret:
-       close(fd);
-       return string;
-}
-
-int
-setsysfs(char *dir, char *entry, char *value)
-{
-       char filename[PATH_MAX];
-       char *oldvalue;
-       int fd, ret = 0;
-
-       if (dir == NULL)
-               snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
-       else
-               snprintf(filename, PATH_MAX, "%s/%s/%s",
-                        MICSYSFSDIR, dir, entry);
-
-       oldvalue = readsysfs(dir, entry);
-
-       fd = open(filename, O_RDWR);
-       if (fd < 0) {
-               ret = errno;
-               mpsslog("Failed to open sysfs entry '%s': %s\n",
-                       filename, strerror(errno));
-               goto done;
-       }
-
-       if (!oldvalue || strcmp(value, oldvalue)) {
-               if (write(fd, value, strlen(value)) < 0) {
-                       ret = errno;
-                       mpsslog("Failed to write new sysfs entry '%s': %s\n",
-                               filename, strerror(errno));
-               }
-       }
-       close(fd);
-done:
-       if (oldvalue)
-               free(oldvalue);
-       return ret;
-}
index c738cb79551411ad5c3bd3d183f75e8ca5e62c44..68dab828a722d1ef670f39fae398947b60701420 100755 (executable)
@@ -2,18 +2,28 @@
 # SPDX-License-Identifier: GPL-2.0
 
 use strict;
+use warnings;
+use utf8;
 use Pod::Usage;
 use Getopt::Long;
 use File::Find;
 use Fcntl ':mode';
 
-my $help;
-my $man;
-my $debug;
+my $help = 0;
+my $man = 0;
+my $debug = 0;
+my $enable_lineno = 0;
 my $prefix="Documentation/ABI";
 
+#
+# If true, assumes that the description is formatted with ReST
+#
+my $description_is_rst = 1;
+
 GetOptions(
        "debug|d+" => \$debug,
+       "enable-lineno" => \$enable_lineno,
+       "rst-source!" => \$description_is_rst,
        "dir=s" => \$prefix,
        'help|?' => \$help,
        man => \$man
@@ -32,6 +42,7 @@ pod2usage(2) if ($cmd eq "search" && !$arg);
 require Data::Dumper if ($debug);
 
 my %data;
+my %symbols;
 
 #
 # Displays an error message, printing file name and line
@@ -39,7 +50,15 @@ my %data;
 sub parse_error($$$$) {
        my ($file, $ln, $msg, $data) = @_;
 
-       print STDERR "file $file#$ln: $msg at\n\t$data";
+       $data =~ s/\s+$/\n/;
+
+       print STDERR "Warning: file $file#$ln:\n\t$msg";
+
+       if ($data ne "") {
+               print STDERR ". Line\n\t\t$data";
+       } else {
+           print STDERR "\n";
+       }
 }
 
 #
@@ -55,24 +74,28 @@ sub parse_abi {
        my $name = $file;
        $name =~ s,.*/,,;
 
-       my $nametag = "File $name";
+       my $fn = $file;
+       $fn =~ s,Documentation/ABI/,,;
+
+       my $nametag = "File $fn";
        $data{$nametag}->{what} = "File $name";
        $data{$nametag}->{type} = "File";
        $data{$nametag}->{file} = $name;
        $data{$nametag}->{filepath} = $file;
        $data{$nametag}->{is_file} = 1;
+       $data{$nametag}->{line_no} = 1;
 
        my $type = $file;
        $type =~ s,.*/(.*)/.*,$1,;
 
        my $what;
        my $new_what;
-       my $tag;
+       my $tag = "";
        my $ln;
        my $xrefs;
        my $space;
        my @labels;
-       my $label;
+       my $label = "";
 
        print STDERR "Opening $file\n" if ($debug > 1);
        open IN, $file;
@@ -95,16 +118,26 @@ sub parse_abi {
 
                        # Invalid, but it is a common mistake
                        if ($new_tag eq "where") {
-                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", $_);
+                               parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", "");
                                $new_tag = "what";
                        }
 
                        if ($new_tag =~ m/what/) {
                                $space = "";
+                               $content =~ s/[,.;]$//;
+
+                               push @{$symbols{$content}->{file}}, " $file:" . ($ln - 1);
+
                                if ($tag =~ m/what/) {
                                        $what .= ", " . $content;
                                } else {
-                                       parse_error($file, $ln, "What '$what' doesn't have a description", "") if ($what && !$data{$what}->{description});
+                                       if ($what) {
+                                               parse_error($file, $ln, "What '$what' doesn't have a description", "") if (!$data{$what}->{description});
+
+                                               foreach my $w(split /, /, $what) {
+                                                       $symbols{$w}->{xref} = $what;
+                                               };
+                                       }
 
                                        $what = $content;
                                        $label = $content;
@@ -113,7 +146,7 @@ sub parse_abi {
                                push @labels, [($content, $label)];
                                $tag = $new_tag;
 
-                               push @{$data{$nametag}->{xrefs}}, [($content, $label)] if ($data{$nametag}->{what});
+                               push @{$data{$nametag}->{symbols}}, $content if ($data{$nametag}->{what});
                                next;
                        }
 
@@ -121,30 +154,44 @@ sub parse_abi {
                                $tag = $new_tag;
 
                                if ($new_what) {
-                                       @{$data{$what}->{label}} = @labels if ($data{$nametag}->{what});
+                                       @{$data{$what}->{label_list}} = @labels if ($data{$nametag}->{what});
                                        @labels = ();
                                        $label = "";
                                        $new_what = 0;
 
                                        $data{$what}->{type} = $type;
-                                       $data{$what}->{file} = $name;
-                                       $data{$what}->{filepath} = $file;
+                                       if (!defined($data{$what}->{file})) {
+                                               $data{$what}->{file} = $name;
+                                               $data{$what}->{filepath} = $file;
+                                       } else {
+                                               if ($name ne $data{$what}->{file}) {
+                                                       $data{$what}->{file} .= " " . $name;
+                                                       $data{$what}->{filepath} .= " " . $file;
+                                               }
+                                       }
                                        print STDERR "\twhat: $what\n" if ($debug > 1);
+                                       $data{$what}->{line_no} = $ln;
+                               } else {
+                                       $data{$what}->{line_no} = $ln if (!defined($data{$what}->{line_no}));
                                }
 
                                if (!$what) {
                                        parse_error($file, $ln, "'What:' should come first:", $_);
                                        next;
                                }
-                               if ($tag eq "description") {
-                                       next if ($content =~ m/^\s*$/);
-                                       if ($content =~ m/^(\s*)(.*)/) {
-                                               my $new_content = $2;
-                                               $space = $new_tag . $sep . $1;
-                                               while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
-                                               $space =~ s/./ /g;
-                                               $data{$what}->{$tag} .= "$new_content\n";
+                               if ($new_tag eq "description") {
+                                       $sep =~ s,:, ,;
+                                       $content = ' ' x length($new_tag) . $sep . $content;
+                                       while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
+                                       if ($content =~ m/^(\s*)(\S.*)$/) {
+                                               # Preserve initial spaces for the first line
+                                               $space = $1;
+                                               $content = "$2\n";
+                                               $data{$what}->{$tag} .= $content;
+                                       } else {
+                                               undef($space);
                                        }
+
                                } else {
                                        $data{$what}->{$tag} = $content;
                                }
@@ -159,29 +206,24 @@ sub parse_abi {
                }
 
                if ($tag eq "description") {
-                       if (!$data{$what}->{description}) {
-                               next if (m/^\s*\n/);
-                               if (m/^(\s*)(.*)/) {
+                       my $content = $_;
+                       while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
+                       if (m/^\s*\n/) {
+                               $data{$what}->{$tag} .= "\n";
+                               next;
+                       }
+
+                       if (!defined($space)) {
+                               # Preserve initial spaces for the first line
+                               if ($content =~ m/^(\s*)(\S.*)$/) {
                                        $space = $1;
-                                       while ($space =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
-                                       $data{$what}->{$tag} .= "$2\n";
+                                       $content = "$2\n";
                                }
                        } else {
-                               my $content = $_;
-                               if (m/^\s*\n/) {
-                                       $data{$what}->{$tag} .= $content;
-                                       next;
-                               }
-
-                               while ($content =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {}
                                $space = "" if (!($content =~ s/^($space)//));
-
-                               # Compress spaces with tabs
-                               $content =~ s<^ {8}> <\t>;
-                               $content =~ s<^ {1,7}\t> <\t>;
-                               $content =~ s< {1,7}\t> <\t>;
-                               $data{$what}->{$tag} .= $content;
                        }
+                       $data{$what}->{$tag} .= $content;
+
                        next;
                }
                if (m/^\s*(.*)/) {
@@ -191,32 +233,26 @@ sub parse_abi {
                }
 
                # Everything else is error
-               parse_error($file, $ln, "Unexpected line:", $_);
+               parse_error($file, $ln, "Unexpected content", $_);
+       }
+       $data{$nametag}->{description} =~ s/^\n+// if ($data{$nametag}->{description});
+       if ($what) {
+               parse_error($file, $ln, "What '$what' doesn't have a description", "") if (!$data{$what}->{description});
+
+               foreach my $w(split /, /,$what) {
+                       $symbols{$w}->{xref} = $what;
+               };
        }
-       $data{$nametag}->{description} =~ s/^\n+//;
        close IN;
 }
 
-#
-# Outputs the book on ReST format
-#
+sub create_labels {
+       my %labels;
 
-my %labels;
+       foreach my $what (keys %data) {
+               next if ($data{$what}->{file} eq "File");
 
-sub output_rest {
-       foreach my $what (sort {
-                               ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") ||
-                               $a cmp $b
-                              } keys %data) {
-               my $type = $data{$what}->{type};
-               my $file = $data{$what}->{file};
-               my $filepath = $data{$what}->{filepath};
-
-               my $w = $what;
-               $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
-
-
-               foreach my $p (@{$data{$what}->{label}}) {
+               foreach my $p (@{$data{$what}->{label_list}}) {
                        my ($content, $label) = @{$p};
                        $label = "abi_" . $label . " ";
                        $label =~ tr/A-Z/a-z/;
@@ -233,81 +269,167 @@ sub output_rest {
                        }
                        $labels{$label} = 1;
 
-                       $data{$what}->{label} .= $label;
-
-                       printf ".. _%s:\n\n", $label;
+                       $data{$what}->{label} = $label;
 
                        # only one label is enough
                        last;
                }
+       }
+}
 
+#
+# Outputs the book on ReST format
+#
 
-               $filepath =~ s,.*/(.*/.*),\1,;;
-               $filepath =~ s,[/\-],_,g;;
-               my $fileref = "abi_file_".$filepath;
+# \b doesn't work well with paths. So, we need to define something else
+my $bondary = qr { (?<![\w\/\`\{])(?=[\w\/\`\{])|(?<=[\w\/\`\{])(?![\w\/\`\{]) }x;
 
-               if ($type eq "File") {
-                       my $bar = $w;
-                       $bar =~ s/./-/g;
+sub output_rest {
+       create_labels();
 
-                       print ".. _$fileref:\n\n";
-                       print "$w\n$bar\n\n";
-               } else {
-                       my @names = split /\s*,\s*/,$w;
+       my $part = "";
+
+       foreach my $what (sort {
+                               ($data{$a}->{type} eq "File") cmp ($data{$b}->{type} eq "File") ||
+                               $a cmp $b
+                              } keys %data) {
+               my $type = $data{$what}->{type};
+
+               my @file = split / /, $data{$what}->{file};
+               my @filepath = split / /, $data{$what}->{filepath};
+
+               if ($enable_lineno) {
+                       printf "#define LINENO %s%s#%s\n\n",
+                              $prefix, $file[0],
+                              $data{$what}->{line_no};
+               }
+
+               my $w = $what;
+               $w =~ s/([\(\)\_\-\*\=\^\~\\])/\\$1/g;
+
+               if ($type ne "File") {
+                       my $cur_part = $what;
+                       if ($what =~ '/') {
+                               if ($what =~ m#^(\/?(?:[\w\-]+\/?){1,2})#) {
+                                       $cur_part = "Symbols under $1";
+                                       $cur_part =~ s,/$,,;
+                               }
+                       }
+
+                       if ($cur_part ne "" && $part ne $cur_part) {
+                           $part = $cur_part;
+                           my $bar = $part;
+                           $bar =~ s/./-/g;
+                           print "$part\n$bar\n\n";
+                       }
+
+                       printf ".. _%s:\n\n", $data{$what}->{label};
 
+                       my @names = split /, /,$w;
                        my $len = 0;
 
                        foreach my $name (@names) {
+                               $name = "**$name**";
                                $len = length($name) if (length($name) > $len);
                        }
 
-                       print "What:\n\n";
-
                        print "+-" . "-" x $len . "-+\n";
                        foreach my $name (@names) {
                                printf "| %s", $name . " " x ($len - length($name)) . " |\n";
                                print "+-" . "-" x $len . "-+\n";
                        }
+
                        print "\n";
                }
 
-               print "Defined on file :ref:`$file <$fileref>`\n\n" if ($type ne "File");
+               for (my $i = 0; $i < scalar(@filepath); $i++) {
+                       my $path = $filepath[$i];
+                       my $f = $file[$i];
+
+                       $path =~ s,.*/(.*/.*),$1,;;
+                       $path =~ s,[/\-],_,g;;
+                       my $fileref = "abi_file_".$path;
+
+                       if ($type eq "File") {
+                               print ".. _$fileref:\n\n";
+                       } else {
+                               print "Defined on file :ref:`$f <$fileref>`\n\n";
+                       }
+               }
 
-               my $desc = $data{$what}->{description};
-               $desc =~ s/^\s+//;
+               if ($type eq "File") {
+                       my $bar = $w;
+                       $bar =~ s/./-/g;
+                       print "$w\n$bar\n\n";
+               }
 
-               # Remove title markups from the description, as they won't work
-               $desc =~ s/\n[\-\*\=\^\~]+\n/\n/g;
+               my $desc = "";
+               $desc = $data{$what}->{description} if (defined($data{$what}->{description}));
+               $desc =~ s/\s+$/\n/;
 
                if (!($desc =~ /^\s*$/)) {
-                       if ($desc =~ m/\:\n/ || $desc =~ m/\n[\t ]+/  || $desc =~ m/[\x00-\x08\x0b-\x1f\x7b-\xff]/) {
-                               # put everything inside a code block
-                               $desc =~ s/\n/\n /g;
+                       if ($description_is_rst) {
+                               # Remove title markups from the description
+                               # Having titles inside ABI files will only work if extra
+                               # care would be taken in order to strictly follow the same
+                               # level order for each markup.
+                               $desc =~ s/\n[\-\*\=\^\~]+\n/\n\n/g;
+
+                               # Enrich text by creating cross-references
+
+                               $desc =~ s,Documentation/(?!devicetree)(\S+)\.rst,:doc:`/$1`,g;
+
+                               my @matches = $desc =~ m,Documentation/ABI/([\w\/\-]+),;
+                               foreach my $f (@matches) {
+                                       my $xref = $f;
+                                       my $path = $f;
+                                       $path =~ s,.*/(.*/.*),$1,;;
+                                       $path =~ s,[/\-],_,g;;
+                                       $xref .= " <abi_file_" . $path . ">";
+                                       $desc =~ s,\bDocumentation/ABI/$f\b,:ref:`$xref`,g;
+                               }
 
-                               print "::\n\n";
-                               print " $desc\n\n";
-                       } else {
-                               # Escape any special chars from description
-                               $desc =~s/([\x00-\x08\x0b-\x1f\x21-\x2a\x2d\x2f\x3c-\x40\x5c\x5e-\x60\x7b-\xff])/\\$1/g;
+                               @matches = $desc =~ m,$bondary(/sys/[^\s\.\,\;\:\*\s\`\'\(\)]+)$bondary,;
+
+                               foreach my $s (@matches) {
+                                       if (defined($data{$s}) && defined($data{$s}->{label})) {
+                                               my $xref = $s;
+
+                                               $xref =~ s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g;
+                                               $xref = ":ref:`$xref <" . $data{$s}->{label} . ">`";
+
+                                               $desc =~ s,$bondary$s$bondary,$xref,g;
+                                       }
+                               }
 
                                print "$desc\n\n";
+                       } else {
+                               $desc =~ s/^\s+//;
+
+                               # Remove title markups from the description, as they won't work
+                               $desc =~ s/\n[\-\*\=\^\~]+\n/\n\n/g;
+
+                               if ($desc =~ m/\:\n/ || $desc =~ m/\n[\t ]+/  || $desc =~ m/[\x00-\x08\x0b-\x1f\x7b-\xff]/) {
+                                       # put everything inside a code block
+                                       $desc =~ s/\n/\n /g;
+
+                                       print "::\n\n";
+                                       print " $desc\n\n";
+                               } else {
+                                       # Escape any special chars from description
+                                       $desc =~s/([\x00-\x08\x0b-\x1f\x21-\x2a\x2d\x2f\x3c-\x40\x5c\x5e-\x60\x7b-\xff])/\\$1/g;
+                                       print "$desc\n\n";
+                               }
                        }
                } else {
                        print "DESCRIPTION MISSING for $what\n\n" if (!$data{$what}->{is_file});
                }
 
-               if ($data{$what}->{xrefs}) {
+               if ($data{$what}->{symbols}) {
                        printf "Has the following ABI:\n\n";
 
-                       foreach my $p(@{$data{$what}->{xrefs}}) {
-                               my ($content, $label) = @{$p};
-                               $label = "abi_" . $label . " ";
-                               $label =~ tr/A-Z/a-z/;
-
-                               # Convert special chars to "_"
-                               $label =~s/([\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xff])/_/g;
-                               $label =~ s,_+,_,g;
-                               $label =~ s,_$,,;
+                       foreach my $content(@{$data{$what}->{symbols}}) {
+                               my $label = $data{$symbols{$content}->{xref}}->{label};
 
                                # Escape special chars from content
                                $content =~s/([\x00-\x1f\x21-\x2f\x3a-\x40\x7b-\xff])/\\$1/g;
@@ -315,6 +437,14 @@ sub output_rest {
                                print "- :ref:`$content <$label>`\n\n";
                        }
                }
+
+               if (defined($data{$what}->{users})) {
+                       my $users = $data{$what}->{users};
+
+                       $users =~ s/\n/\n\t/g;
+                       printf "Users:\n\t%s\n\n", $users if ($users ne "");
+               }
+
        }
 }
 
@@ -335,27 +465,34 @@ sub search_symbols {
 
                print "\n$what\n$bar\n\n";
 
-               my $kernelversion = $data{$what}->{kernelversion};
-               my $contact = $data{$what}->{contact};
-               my $users = $data{$what}->{users};
-               my $date = $data{$what}->{date};
-               my $desc = $data{$what}->{description};
-               $kernelversion =~ s/^\s+//;
-               $contact =~ s/^\s+//;
-               $users =~ s/^\s+//;
-               $users =~ s/\n//g;
-               $date =~ s/^\s+//;
-               $desc =~ s/^\s+//;
+               my $kernelversion = $data{$what}->{kernelversion} if (defined($data{$what}->{kernelversion}));
+               my $contact = $data{$what}->{contact} if (defined($data{$what}->{contact}));
+               my $users = $data{$what}->{users} if (defined($data{$what}->{users}));
+               my $date = $data{$what}->{date} if (defined($data{$what}->{date}));
+               my $desc = $data{$what}->{description} if (defined($data{$what}->{description}));
+
+               $kernelversion =~ s/^\s+// if ($kernelversion);
+               $contact =~ s/^\s+// if ($contact);
+               if ($users) {
+                       $users =~ s/^\s+//;
+                       $users =~ s/\n//g;
+               }
+               $date =~ s/^\s+// if ($date);
+               $desc =~ s/^\s+// if ($desc);
 
                printf "Kernel version:\t\t%s\n", $kernelversion if ($kernelversion);
                printf "Date:\t\t\t%s\n", $date if ($date);
                printf "Contact:\t\t%s\n", $contact if ($contact);
                printf "Users:\t\t\t%s\n", $users if ($users);
-               print "Defined on file:\t$file\n\n";
+               print "Defined on file(s):\t$file\n\n";
                print "Description:\n\n$desc";
        }
 }
 
+# Ensure that the prefix will always end with a slash
+# While this is not needed for find, it makes the patch nicer
+# with --enable-lineno
+$prefix =~ s,/?$,/,;
 
 #
 # Parses all ABI files located at $prefix dir
@@ -367,12 +504,23 @@ print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug);
 #
 # Handles the command
 #
-if ($cmd eq "rest") {
-       output_rest;
-} elsif ($cmd eq "search") {
+if ($cmd eq "search") {
        search_symbols;
-}
+} else {
+       if ($cmd eq "rest") {
+               output_rest;
+       }
+
+       # Warn about duplicated ABI entries
+       foreach my $what(sort keys %symbols) {
+               my @files = @{$symbols{$what}->{file}};
 
+               next if (scalar(@files) == 1);
+
+               printf STDERR "Warning: $what is defined %d times: @files\n",
+                   scalar(@files);
+       }
+}
 
 __END__
 
@@ -382,7 +530,8 @@ abi_book.pl - parse the Linux ABI files and produce a ReST book.
 
 =head1 SYNOPSIS
 
-B<abi_book.pl> [--debug] [--man] [--help] [--dir=<dir>] <COMAND> [<ARGUMENT>]
+B<abi_book.pl> [--debug] [--enable-lineno] [--man] [--help]
+              [--(no-)rst-source] [--dir=<dir>] <COMAND> [<ARGUMENT>]
 
 Where <COMMAND> can be:
 
@@ -405,6 +554,17 @@ B<validate>              - validate the ABI contents
 Changes the location of the ABI search. By default, it uses
 the Documentation/ABI directory.
 
+=item B<--rst-source> and B<--no-rst-source>
+
+The input file may be using ReST syntax or not. Those two options allow
+selecting between a rst-compliant source ABI (--rst-source), or a
+plain text that may be violating ReST spec, so it requres some escaping
+logic (--no-rst-source).
+
+=item B<--enable-lineno>
+
+Enable output of #define LINENO lines.
+
 =item B<--debug>
 
 Put the script in verbose mode, useful for debugging. Can be called multiple
index c8f6b11d5da17125e6308fe1899f503a639b3a57..f699cf05d40985a79f1d54a9b51812f07bddfd98 100755 (executable)
@@ -1092,7 +1092,11 @@ sub output_struct_rst(%) {
        print "\n\n.. c:type:: " . $name . "\n\n";
     } else {
        my $name = $args{'struct'};
-       print "\n\n.. c:struct:: " . $name . "\n\n";
+       if ($args{'type'} eq 'union') {
+           print "\n\n.. c:union:: " . $name . "\n\n";
+       } else {
+           print "\n\n.. c:struct:: " . $name . "\n\n";
+       }
     }
     print_lineno($declaration_start_line);
     $lineprefix = "   ";
@@ -1427,20 +1431,25 @@ sub dump_enum($$) {
     }
 }
 
+my $typedef_type = qr { ((?:\s+[\w\*]+){1,8})\s* }x;
+my $typedef_ident = qr { \*?\s*(\w\S+)\s* }x;
+my $typedef_args = qr { \s*\((.*)\); }x;
+
+my $typedef1 = qr { typedef$typedef_type\($typedef_ident\)$typedef_args }x;
+my $typedef2 = qr { typedef$typedef_type$typedef_ident$typedef_args }x;
+
 sub dump_typedef($$) {
     my $x = shift;
     my $file = shift;
 
     $x =~ s@/\*.*?\*/@@gos;    # strip comments.
 
-    # Parse function prototypes
-    if ($x =~ /typedef\s+(\w+)\s*\(\*\s*(\w\S+)\s*\)\s*\((.*)\);/ ||
-       $x =~ /typedef\s+(\w+)\s*(\w\S+)\s*\s*\((.*)\);/) {
-
-       # Function typedefs
+    # Parse function typedef prototypes
+    if ($x =~ $typedef1 || $x =~ $typedef2) {
        $return_type = $1;
        $declaration_name = $2;
        my $args = $3;
+       $return_type =~ s/^\s+//;
 
        create_parameterlist($args, ',', $file, $declaration_name);
 
index 38043074ce5e4459d3a71805ca58e0a78062263f..6ebefec616e442c7271e346ae85ecbb998b65cb6 100644 (file)
@@ -101,7 +101,7 @@ struct ima_template_entry {
        struct tpm_digest *digests;
        struct ima_template_desc *template_desc; /* template descriptor */
        u32 template_data_len;
-       struct ima_field_data template_data[0]; /* template related data */
+       struct ima_field_data template_data[];  /* template related data */
 };
 
 struct ima_queue_entry {
index 421ddc76f264fcec7d08bea37234b2b59c63c4e1..4373de42a5a0443c05eca018d8ac73f2e6a4319e 100644 (file)
@@ -1925,8 +1925,8 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl);
 
 #ifdef CONFIG_COMPAT
 /**
- * snd_ctl_unregister_ioctl - de-register the device-specific compat 32bit
- * control-ioctls
+ * snd_ctl_unregister_ioctl_compat - de-register the device-specific compat
+ * 32bit control-ioctls
  * @fcn: ioctl callback function to unregister
  */
 int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn)
index 4d059ff2b2e4facaae4d7191665bbf6e7795db8c..4d0e8fe535a1e8087b677c2571d38ae17a08e11b 100644 (file)
@@ -356,7 +356,8 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
 EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
 
 /**
- * snd_dmaengine_pcm_release_chan_close - Close a dmaengine based PCM substream and release channel
+ * snd_dmaengine_pcm_close_release_chan - Close a dmaengine based PCM
+ *                                       substream and release channel
  * @substream: PCM substream
  *
  * Releases the DMA channel associated with the PCM substream.
index d531e1bc2b8138267e547331e1be8d9e7e55a3e8..bda3514c7b2d91e8974005ad88c66150af6c47c6 100644 (file)
@@ -490,7 +490,7 @@ void snd_pcm_set_ops(struct snd_pcm *pcm, int direction,
 EXPORT_SYMBOL(snd_pcm_set_ops);
 
 /**
- * snd_pcm_sync - set the PCM sync id
+ * snd_pcm_set_sync - set the PCM sync id
  * @substream: the pcm substream
  *
  * Sets the PCM sync identifier for the card.
index 9e0b2d73faf6bfb066bb0c980b0311a4083fdedd..47b155a49226f4978bbe123952260fa31c3013fc 100644 (file)
@@ -112,7 +112,7 @@ void snd_pcm_stream_lock(struct snd_pcm_substream *substream)
 EXPORT_SYMBOL_GPL(snd_pcm_stream_lock);
 
 /**
- * snd_pcm_stream_lock - Unlock the PCM stream
+ * snd_pcm_stream_unlock - Unlock the PCM stream
  * @substream: PCM substream
  *
  * This unlocks the PCM stream that has been locked via snd_pcm_stream_lock().
@@ -595,7 +595,7 @@ static void snd_pcm_sync_stop(struct snd_pcm_substream *substream)
 }
 
 /**
- * snd_pcm_hw_param_choose - choose a configuration defined by @params
+ * snd_pcm_hw_params_choose - choose a configuration defined by @params
  * @pcm: PCM instance
  * @params: the hw_params instance
  *
index 4d060d5b1db6dc7eabfd5d44c3ef965792925537..b0c0ef824d7d914f5748f01bed8616fb876f146f 100644 (file)
@@ -148,6 +148,8 @@ struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_bus *bus,
                return NULL;
        if (bus->idx != bus_idx)
                return NULL;
+       if (addr < 0 || addr > 31)
+               return NULL;
 
        list_for_each_entry(hlink, &bus->hlink_list, list) {
                for (i = 0; i < HDA_MAX_CODECS; i++) {
index a356c21edb90ff38bc402c86cb2f724846d7165d..4bb58e8b08a858ad70d136d6513ed44c1a9ff198 100644 (file)
@@ -2934,7 +2934,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
        snd_hdac_leave_pm(&codec->core);
 }
 
-static int hda_codec_runtime_suspend(struct device *dev)
+static int hda_codec_suspend(struct device *dev)
 {
        struct hda_codec *codec = dev_to_hda_codec(dev);
        unsigned int state;
@@ -2953,7 +2953,7 @@ static int hda_codec_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int hda_codec_runtime_resume(struct device *dev)
+static int hda_codec_resume(struct device *dev)
 {
        struct hda_codec *codec = dev_to_hda_codec(dev);
 
@@ -2967,57 +2967,70 @@ static int hda_codec_runtime_resume(struct device *dev)
        pm_runtime_mark_last_busy(dev);
        return 0;
 }
+
+static int hda_codec_runtime_suspend(struct device *dev)
+{
+       return hda_codec_suspend(dev);
+}
+
+static int hda_codec_runtime_resume(struct device *dev)
+{
+       return hda_codec_resume(dev);
+}
+
 #endif /* CONFIG_PM */
 
 #ifdef CONFIG_PM_SLEEP
-static int hda_codec_force_resume(struct device *dev)
+static int hda_codec_pm_prepare(struct device *dev)
+{
+       return pm_runtime_suspended(dev);
+}
+
+static void hda_codec_pm_complete(struct device *dev)
 {
        struct hda_codec *codec = dev_to_hda_codec(dev);
-       int ret;
 
-       ret = pm_runtime_force_resume(dev);
-       /* schedule jackpoll work for jack detection update */
-       if (codec->jackpoll_interval ||
-           (pm_runtime_suspended(dev) && hda_codec_need_resume(codec)))
-               schedule_delayed_work(&codec->jackpoll_work,
-                                     codec->jackpoll_interval);
-       return ret;
+       if (pm_runtime_suspended(dev) && (codec->jackpoll_interval ||
+           hda_codec_need_resume(codec) || codec->forced_resume))
+               pm_request_resume(dev);
 }
 
 static int hda_codec_pm_suspend(struct device *dev)
 {
        dev->power.power_state = PMSG_SUSPEND;
-       return pm_runtime_force_suspend(dev);
+       return hda_codec_suspend(dev);
 }
 
 static int hda_codec_pm_resume(struct device *dev)
 {
        dev->power.power_state = PMSG_RESUME;
-       return hda_codec_force_resume(dev);
+       return hda_codec_resume(dev);
 }
 
 static int hda_codec_pm_freeze(struct device *dev)
 {
        dev->power.power_state = PMSG_FREEZE;
-       return pm_runtime_force_suspend(dev);
+       return hda_codec_suspend(dev);
 }
 
 static int hda_codec_pm_thaw(struct device *dev)
 {
        dev->power.power_state = PMSG_THAW;
-       return hda_codec_force_resume(dev);
+       return hda_codec_resume(dev);
 }
 
 static int hda_codec_pm_restore(struct device *dev)
 {
        dev->power.power_state = PMSG_RESTORE;
-       return hda_codec_force_resume(dev);
+       return hda_codec_resume(dev);
 }
 #endif /* CONFIG_PM_SLEEP */
 
 /* referred in hda_bind.c */
 const struct dev_pm_ops hda_codec_driver_pm = {
 #ifdef CONFIG_PM_SLEEP
+       .prepare = hda_codec_pm_prepare,
+       .complete = hda_codec_pm_complete,
        .suspend = hda_codec_pm_suspend,
        .resume = hda_codec_pm_resume,
        .freeze = hda_codec_pm_freeze,
index be63ead8161f80e49c85023094eeff8e0e5148f7..68f9668788ea2d469041390d79f9c5d1d52e895d 100644 (file)
@@ -41,7 +41,7 @@
 /* 24 unused */
 #define AZX_DCAPS_COUNT_LPIB_DELAY  (1 << 25)  /* Take LPIB as delay */
 #define AZX_DCAPS_PM_RUNTIME   (1 << 26)       /* runtime PM support */
-#define AZX_DCAPS_SUSPEND_SPURIOUS_WAKEUP (1 << 27) /* Workaround for spurious wakeups after suspend */
+/* 27 unused */
 #define AZX_DCAPS_CORBRP_SELF_CLEAR (1 << 28)  /* CORBRP clears itself after reset */
 #define AZX_DCAPS_NO_MSI64      (1 << 29)      /* Stick to 32-bit MSIs */
 #define AZX_DCAPS_SEPARATE_STREAM_TAG  (1 << 30) /* capture and playback use separate stream tag */
@@ -143,6 +143,7 @@ struct azx {
        unsigned int align_buffer_size:1;
        unsigned int region_requested:1;
        unsigned int disabled:1; /* disabled by vga_switcheroo */
+       unsigned int pm_prepared:1;
 
        /* GTS present */
        unsigned int gts_present:1;
index 749b880909703f80a40392ab33623c3ae3d2d029..d539f52009a170fbf9c2ab2ff402c41e3f43ad70 100644 (file)
@@ -297,8 +297,7 @@ enum {
 /* PCH for HSW/BDW; with runtime PM */
 /* no i915 binding for this as HSW/BDW has another controller for HDMI */
 #define AZX_DCAPS_INTEL_PCH \
-       (AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME |\
-        AZX_DCAPS_SUSPEND_SPURIOUS_WAKEUP)
+       (AZX_DCAPS_INTEL_PCH_BASE | AZX_DCAPS_PM_RUNTIME)
 
 /* HSW HDMI */
 #define AZX_DCAPS_INTEL_HASWELL \
@@ -985,7 +984,7 @@ static void __azx_runtime_suspend(struct azx *chip)
        display_power(chip, false);
 }
 
-static void __azx_runtime_resume(struct azx *chip, bool from_rt)
+static void __azx_runtime_resume(struct azx *chip)
 {
        struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
        struct hdac_bus *bus = azx_bus(chip);
@@ -1002,7 +1001,8 @@ static void __azx_runtime_resume(struct azx *chip, bool from_rt)
        azx_init_pci(chip);
        hda_intel_init_chip(chip, true);
 
-       if (from_rt) {
+       /* Avoid codec resume if runtime resume is for system suspend */
+       if (!chip->pm_prepared) {
                list_for_each_codec(codec, &chip->bus) {
                        if (codec->relaxed_resume)
                                continue;
@@ -1018,6 +1018,29 @@ static void __azx_runtime_resume(struct azx *chip, bool from_rt)
 }
 
 #ifdef CONFIG_PM_SLEEP
+static int azx_prepare(struct device *dev)
+{
+       struct snd_card *card = dev_get_drvdata(dev);
+       struct azx *chip;
+
+       chip = card->private_data;
+       chip->pm_prepared = 1;
+
+       /* HDA controller always requires different WAKEEN for runtime suspend
+        * and system suspend, so don't use direct-complete here.
+        */
+       return 0;
+}
+
+static void azx_complete(struct device *dev)
+{
+       struct snd_card *card = dev_get_drvdata(dev);
+       struct azx *chip;
+
+       chip = card->private_data;
+       chip->pm_prepared = 0;
+}
+
 static int azx_suspend(struct device *dev)
 {
        struct snd_card *card = dev_get_drvdata(dev);
@@ -1029,15 +1052,7 @@ static int azx_suspend(struct device *dev)
 
        chip = card->private_data;
        bus = azx_bus(chip);
-       snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
-       /* An ugly workaround: direct call of __azx_runtime_suspend() and
-        * __azx_runtime_resume() for old Intel platforms that suffer from
-        * spurious wakeups after S3 suspend
-        */
-       if (chip->driver_caps & AZX_DCAPS_SUSPEND_SPURIOUS_WAKEUP)
-               __azx_runtime_suspend(chip);
-       else
-               pm_runtime_force_suspend(dev);
+       __azx_runtime_suspend(chip);
        if (bus->irq >= 0) {
                free_irq(bus->irq, chip);
                bus->irq = -1;
@@ -1066,11 +1081,7 @@ static int azx_resume(struct device *dev)
        if (azx_acquire_irq(chip, 1) < 0)
                return -EIO;
 
-       if (chip->driver_caps & AZX_DCAPS_SUSPEND_SPURIOUS_WAKEUP)
-               __azx_runtime_resume(chip, false);
-       else
-               pm_runtime_force_resume(dev);
-       snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+       __azx_runtime_resume(chip);
 
        trace_azx_resume(chip);
        return 0;
@@ -1118,10 +1129,7 @@ static int azx_runtime_suspend(struct device *dev)
        chip = card->private_data;
 
        /* enable controller wake up event */
-       if (snd_power_get_state(card) == SNDRV_CTL_POWER_D0) {
-               azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
-                          STATESTS_INT_MASK);
-       }
+       azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) | STATESTS_INT_MASK);
 
        __azx_runtime_suspend(chip);
        trace_azx_runtime_suspend(chip);
@@ -1132,18 +1140,14 @@ static int azx_runtime_resume(struct device *dev)
 {
        struct snd_card *card = dev_get_drvdata(dev);
        struct azx *chip;
-       bool from_rt = snd_power_get_state(card) == SNDRV_CTL_POWER_D0;
 
        if (!azx_is_pm_ready(card))
                return 0;
        chip = card->private_data;
-       __azx_runtime_resume(chip, from_rt);
+       __azx_runtime_resume(chip);
 
        /* disable controller Wake Up event*/
-       if (from_rt) {
-               azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
-                          ~STATESTS_INT_MASK);
-       }
+       azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) & ~STATESTS_INT_MASK);
 
        trace_azx_runtime_resume(chip);
        return 0;
@@ -1177,6 +1181,8 @@ static int azx_runtime_idle(struct device *dev)
 static const struct dev_pm_ops azx_pm = {
        SET_SYSTEM_SLEEP_PM_OPS(azx_suspend, azx_resume)
 #ifdef CONFIG_PM_SLEEP
+       .prepare = azx_prepare,
+       .complete = azx_complete,
        .freeze_noirq = azx_freeze_noirq,
        .thaw_noirq = azx_thaw_noirq,
 #endif
@@ -2356,6 +2362,7 @@ static int azx_probe_continue(struct azx *chip)
 
        if (azx_has_pm_runtime(chip)) {
                pm_runtime_use_autosuspend(&pci->dev);
+               pm_runtime_allow(&pci->dev);
                pm_runtime_put_autosuspend(&pci->dev);
        }
 
index f2398721ac1efc49566bddb7bd579ce7f14f08da..6899089d132e715e39541717557e9ea0f3ce5610 100644 (file)
@@ -6008,6 +6008,27 @@ static void alc285_fixup_invalidate_dacs(struct hda_codec *codec,
        snd_hda_override_wcaps(codec, 0x03, 0);
 }
 
+static void alc_combo_jack_hp_jd_restart(struct hda_codec *codec)
+{
+       switch (codec->core.vendor_id) {
+       case 0x10ec0274:
+       case 0x10ec0294:
+       case 0x10ec0225:
+       case 0x10ec0295:
+       case 0x10ec0299:
+               alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
+               alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
+               break;
+       case 0x10ec0235:
+       case 0x10ec0236:
+       case 0x10ec0255:
+       case 0x10ec0256:
+               alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
+               alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
+               break;
+       }
+}
+
 static void alc295_fixup_chromebook(struct hda_codec *codec,
                                    const struct hda_fixup *fix, int action)
 {
@@ -6018,16 +6039,7 @@ static void alc295_fixup_chromebook(struct hda_codec *codec,
                spec->ultra_low_power = true;
                break;
        case HDA_FIXUP_ACT_INIT:
-               switch (codec->core.vendor_id) {
-               case 0x10ec0295:
-                       alc_update_coef_idx(codec, 0x4a, 0x8000, 1 << 15); /* Reset HP JD */
-                       alc_update_coef_idx(codec, 0x4a, 0x8000, 0 << 15);
-                       break;
-               case 0x10ec0236:
-                       alc_update_coef_idx(codec, 0x1b, 0x8000, 1 << 15); /* Reset HP JD */
-                       alc_update_coef_idx(codec, 0x1b, 0x8000, 0 << 15);
-                       break;
-               }
+               alc_combo_jack_hp_jd_restart(codec);
                break;
        }
 }
@@ -6083,6 +6095,16 @@ static void  alc285_fixup_hp_gpio_amp_init(struct hda_codec *codec,
        alc_write_coef_idx(codec, 0x65, 0x0);
 }
 
+static void alc274_fixup_hp_headset_mic(struct hda_codec *codec,
+                                   const struct hda_fixup *fix, int action)
+{
+       switch (action) {
+       case HDA_FIXUP_ACT_INIT:
+               alc_combo_jack_hp_jd_restart(codec);
+               break;
+       }
+}
+
 /* for hda_fixup_thinkpad_acpi() */
 #include "thinkpad_helper.c"
 
@@ -6277,6 +6299,8 @@ enum {
        ALC256_FIXUP_INTEL_NUC8_RUGGED,
        ALC255_FIXUP_XIAOMI_HEADSET_MIC,
        ALC274_FIXUP_HP_MIC,
+       ALC274_FIXUP_HP_HEADSET_MIC,
+       ALC256_FIXUP_ASUS_HPE,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -7664,6 +7688,23 @@ static const struct hda_fixup alc269_fixups[] = {
                        { }
                },
        },
+       [ALC274_FIXUP_HP_HEADSET_MIC] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc274_fixup_hp_headset_mic,
+               .chained = true,
+               .chain_id = ALC274_FIXUP_HP_MIC
+       },
+       [ALC256_FIXUP_ASUS_HPE] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       /* Set EAPD high */
+                       { 0x20, AC_VERB_SET_COEF_INDEX, 0x0f },
+                       { 0x20, AC_VERB_SET_PROC_COEF, 0x7778 },
+                       { }
+               },
+               .chained = true,
+               .chain_id = ALC294_FIXUP_ASUS_HEADSET_MIC
+       },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7815,7 +7856,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED),
        SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED),
        SND_PCI_QUIRK(0x103c, 0x8736, "HP", ALC285_FIXUP_HP_GPIO_AMP_INIT),
-       SND_PCI_QUIRK(0x103c, 0x874e, "HP", ALC274_FIXUP_HP_MIC),
        SND_PCI_QUIRK(0x103c, 0x8760, "HP", ALC285_FIXUP_HP_MUTE_LED),
        SND_PCI_QUIRK(0x103c, 0x877a, "HP", ALC285_FIXUP_HP_MUTE_LED),
        SND_PCI_QUIRK(0x103c, 0x877d, "HP", ALC236_FIXUP_HP_MUTE_LED),
@@ -7848,6 +7888,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1043, 0x1bbd, "ASUS Z550MA", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
        SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC),
+       SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE),
        SND_PCI_QUIRK(0x1043, 0x1e11, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA502),
        SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401),
        SND_PCI_QUIRK(0x1043, 0x1881, "ASUS Zephyrus S/M", ALC294_FIXUP_ASUS_GX502_PINS),
@@ -8339,6 +8380,10 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
                {0x1a, 0x90a70130},
                {0x1b, 0x90170110},
                {0x21, 0x03211020}),
+       SND_HDA_PIN_QUIRK(0x10ec0274, 0x103c, "HP", ALC274_FIXUP_HP_HEADSET_MIC,
+               {0x17, 0x90170110},
+               {0x19, 0x03a11030},
+               {0x21, 0x03211020}),
        SND_HDA_PIN_QUIRK(0x10ec0280, 0x103c, "HP", ALC280_FIXUP_HP_GPIO4,
                {0x12, 0x90a60130},
                {0x14, 0x90170110},
index 82c1eecd2528500eeaa69d8101277600a7001197..3bd350afb74348010d54f9e59b1a1961d7b9fcc8 100644 (file)
@@ -487,7 +487,6 @@ static int mchp_spdiftx_hw_params(struct snd_pcm_substream *substream,
        }
        mchp_spdiftx_channel_status_write(dev);
        spin_unlock_irqrestore(&ctrl->lock, flags);
-       mr |= SPDIFTX_MR_VALID1 | SPDIFTX_MR_VALID2;
 
        if (dev->gclk_enabled) {
                clk_disable_unprepare(dev->gclk);
index 097c4e8d9950535de336647a42fc37acc0016124..c61b17dc2af876e2d4055f3a3f483317185271d9 100644 (file)
@@ -254,8 +254,28 @@ static const struct snd_soc_dapm_widget cs42l51_dapm_widgets[] = {
                &cs42l51_adcr_mux_controls),
 };
 
+static int mclk_event(struct snd_soc_dapm_widget *w,
+                     struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
+       struct cs42l51_private *cs42l51 = snd_soc_component_get_drvdata(comp);
+
+       switch (event) {
+       case SND_SOC_DAPM_PRE_PMU:
+               return clk_prepare_enable(cs42l51->mclk_handle);
+       case SND_SOC_DAPM_POST_PMD:
+               /* Delay mclk shutdown to fulfill power-down sequence requirements */
+               msleep(20);
+               clk_disable_unprepare(cs42l51->mclk_handle);
+               break;
+       }
+
+       return 0;
+}
+
 static const struct snd_soc_dapm_widget cs42l51_dapm_mclk_widgets[] = {
-       SND_SOC_DAPM_CLOCK_SUPPLY("MCLK")
+       SND_SOC_DAPM_SUPPLY("MCLK", SND_SOC_NOPM, 0, 0, mclk_event,
+                           SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
 };
 
 static const struct snd_soc_dapm_route cs42l51_routes[] = {
index f2d9d52ee171b81a5ffc4304b8e4914e67b55add..4d2b1ec7c03bb800de8a4138292694f2d7dc2cb4 100644 (file)
@@ -618,7 +618,7 @@ static const char * const sb_tx8_mux_text[] = {
        "ZERO", "RX_MIX_TX8", "DEC8", "DEC8_192"
 };
 
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
+static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
 static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
 static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
 static const DECLARE_TLV_DB_SCALE(ear_pa_gain, 0, 150, 0);
index 35697b072367aced19099f6b90b84d48f19e6d19..40f682f5dab8bde1d1a6e7345336314032052e13 100644 (file)
@@ -551,7 +551,7 @@ struct wcd_iir_filter_ctl {
        struct soc_bytes_ext bytes_ext;
 };
 
-static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
+static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
 static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
 static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
 static const DECLARE_TLV_DB_SCALE(ear_pa_gain, 0, 150, 0);
index 68e774e69c850f18c2ee5547b9f708c53a02c35c..4530b74f5921b74a52667c65b32396f8426e8520 100644 (file)
@@ -1026,6 +1026,8 @@ static struct snd_soc_dai_driver wsa881x_dais[] = {
                .id = 0,
                .playback = {
                        .stream_name = "SPKR Playback",
+                       .rates = SNDRV_PCM_RATE_48000,
+                       .formats = SNDRV_PCM_FMTBIT_S16_LE,
                        .rate_max = 48000,
                        .rate_min = 48000,
                        .channels_min = 1,
index d5bae5d1ab6fd863e47326f36e18203816ca1cf4..a5b446d5af19fc2d0c4bd1a67334e39bf37ad805 100644 (file)
@@ -15,22 +15,6 @@ config SND_SOC_INTEL_SST_TOPLEVEL
 
 if SND_SOC_INTEL_SST_TOPLEVEL
 
-config SND_SST_IPC
-       tristate
-       # This option controls the IPC core for HiFi2 platforms
-
-config SND_SST_IPC_PCI
-       tristate
-       select SND_SST_IPC
-       # This option controls the PCI-based IPC for HiFi2 platforms
-       #  (Medfield, Merrifield).
-
-config SND_SST_IPC_ACPI
-       tristate
-       select SND_SST_IPC
-       # This option controls the ACPI-based IPC for HiFi2 platforms
-       # (Baytrail, Cherrytrail)
-
 config SND_SOC_INTEL_SST
        tristate
 
@@ -57,7 +41,6 @@ config SND_SST_ATOM_HIFI2_PLATFORM
 config SND_SST_ATOM_HIFI2_PLATFORM_PCI
        tristate "PCI HiFi2 (Merrifield) Platforms"
        depends on X86 && PCI
-       select SND_SST_IPC_PCI
        select SND_SST_ATOM_HIFI2_PLATFORM
        help
          If you have a Intel Merrifield/Edison platform, then
@@ -70,7 +53,6 @@ config SND_SST_ATOM_HIFI2_PLATFORM_ACPI
        tristate "ACPI HiFi2 (Baytrail, Cherrytrail) Platforms"
        default ACPI
        depends on X86 && ACPI && PCI
-       select SND_SST_IPC_ACPI
        select SND_SST_ATOM_HIFI2_PLATFORM
        select SND_SOC_ACPI_INTEL_MATCH
        select IOSF_MBI
index a9326d5ec44cbbfd816f58bffea58acb1e82d77d..c66f03f5d8d6d462ea4021544424d76d0af375f6 100644 (file)
@@ -6,4 +6,4 @@ snd-soc-sst-atom-hifi2-platform-objs := sst-mfld-platform-pcm.o \
 obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += snd-soc-sst-atom-hifi2-platform.o
 
 # DSP driver
-obj-$(CONFIG_SND_SST_IPC) += sst/
+obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += sst/
index f17c905df3e2c312f8db5c3353fd7a1cb5fd6bfb..5761d30a5f9d1e0cfc20ca8a23127ee0eda63a82 100644 (file)
@@ -3,6 +3,6 @@ snd-intel-sst-core-objs := sst.o sst_ipc.o sst_stream.o sst_drv_interface.o sst_
 snd-intel-sst-pci-objs += sst_pci.o
 snd-intel-sst-acpi-objs += sst_acpi.o
 
-obj-$(CONFIG_SND_SST_IPC) += snd-intel-sst-core.o
-obj-$(CONFIG_SND_SST_IPC_PCI) += snd-intel-sst-pci.o
-obj-$(CONFIG_SND_SST_IPC_ACPI) += snd-intel-sst-acpi.o
+obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += snd-intel-sst-core.o
+obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_PCI) += snd-intel-sst-pci.o
+obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM_ACPI) += snd-intel-sst-acpi.o
index 3ea4602dfb3ee0c1e2a59de237b7258915810fc4..9a4b3d0973f651b072fb637887fd15cea9b18b29 100644 (file)
@@ -401,17 +401,40 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
        struct snd_interval *chan = hw_param_interval(params,
                        SNDRV_PCM_HW_PARAM_CHANNELS);
        struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
-       struct snd_soc_dpcm *dpcm = container_of(
-                       params, struct snd_soc_dpcm, hw_params);
-       struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link;
-       struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link;
+       struct snd_soc_dpcm *dpcm, *rtd_dpcm = NULL;
+
+       /*
+        * The following loop will be called only for playback stream
+        * In this platform, there is only one playback device on every SSP
+        */
+       for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_PLAYBACK, dpcm) {
+               rtd_dpcm = dpcm;
+               break;
+       }
+
+       /*
+        * This following loop will be called only for capture stream
+        * In this platform, there is only one capture device on every SSP
+        */
+       for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) {
+               rtd_dpcm = dpcm;
+               break;
+       }
+
+       if (!rtd_dpcm)
+               return -EINVAL;
+
+       /*
+        * The above 2 loops are mutually exclusive based on the stream direction,
+        * thus rtd_dpcm variable will never be overwritten
+        */
 
        /*
         * The ADSP will convert the FE rate to 48k, stereo, 24 bit
         */
-       if (!strcmp(fe_dai_link->name, "Kbl Audio Port") ||
-           !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") ||
-           !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) {
+       if (!strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Port") ||
+           !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Headset Playback") ||
+           !strcmp(rtd_dpcm->fe->dai_link->name, "Kbl Audio Capture Port")) {
                rate->min = rate->max = 48000;
                chan->min = chan->max = 2;
                snd_mask_none(fmt);
@@ -421,7 +444,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd,
         * The speaker on the SSP0 supports S16_LE and not S24_LE.
         * thus changing the mask here
         */
-       if (!strcmp(be_dai_link->name, "SSP0-Codec"))
+       if (!strcmp(rtd_dpcm->be->dai_link->name, "SSP0-Codec"))
                snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
 
        return 0;
index 7d2968571951b38b185ce1b33690a62ff22e23e8..9e807b94173219c687758db9b5510bd9d423beab 100644 (file)
@@ -267,9 +267,12 @@ static int catpt_dsp_select_lpclock(struct catpt_dev *cdev, bool lp, bool waiti)
                                            reg, (reg & CATPT_ISD_DCPWM),
                                            500, 10000);
                if (ret) {
-                       dev_err(cdev->dev, "await WAITI timeout\n");
-                       mutex_unlock(&cdev->clk_mutex);
-                       return ret;
+                       dev_warn(cdev->dev, "await WAITI timeout\n");
+                       /* no signal - only high clock selection allowed */
+                       if (lp) {
+                               mutex_unlock(&cdev->clk_mutex);
+                               return 0;
+                       }
                }
        }
 
index f78018c857b8d06d3012ff028e1c1b7ad485b8b7..ba653ebea7d1c9ba5ef0f6189758542f8439d2c3 100644 (file)
@@ -667,7 +667,17 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm,
                break;
        }
 
+       /* see if this is a new configuration */
+       if (!memcmp(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt)))
+               return 0;
+
+       pm_runtime_get_sync(cdev->dev);
+
        ret = catpt_ipc_set_device_format(cdev, &devfmt);
+
+       pm_runtime_mark_last_busy(cdev->dev);
+       pm_runtime_put_autosuspend(cdev->dev);
+
        if (ret)
                return CATPT_IPC_ERROR(ret);
 
index c2c1eb16fcc0ca5ada6f0ef378b1a43bb2e723ca..26e7d9a7198f807911b4d54d65641380013cff96 100644 (file)
@@ -630,15 +630,34 @@ static struct snd_soc_codec_conf mt8183_da7219_rt1015_codec_conf[] = {
        },
 };
 
+static const struct snd_kcontrol_new mt8183_da7219_rt1015_snd_controls[] = {
+       SOC_DAPM_PIN_SWITCH("Left Spk"),
+       SOC_DAPM_PIN_SWITCH("Right Spk"),
+};
+
+static const
+struct snd_soc_dapm_widget mt8183_da7219_rt1015_dapm_widgets[] = {
+       SND_SOC_DAPM_SPK("Left Spk", NULL),
+       SND_SOC_DAPM_SPK("Right Spk", NULL),
+       SND_SOC_DAPM_PINCTRL("TDM_OUT_PINCTRL",
+                            "aud_tdm_out_on", "aud_tdm_out_off"),
+};
+
+static const struct snd_soc_dapm_route mt8183_da7219_rt1015_dapm_routes[] = {
+       {"Left Spk", NULL, "Left SPO"},
+       {"Right Spk", NULL, "Right SPO"},
+       {"I2S Playback", NULL, "TDM_OUT_PINCTRL"},
+};
+
 static struct snd_soc_card mt8183_da7219_rt1015_card = {
        .name = "mt8183_da7219_rt1015",
        .owner = THIS_MODULE,
-       .controls = mt8183_da7219_max98357_snd_controls,
-       .num_controls = ARRAY_SIZE(mt8183_da7219_max98357_snd_controls),
-       .dapm_widgets = mt8183_da7219_max98357_dapm_widgets,
-       .num_dapm_widgets = ARRAY_SIZE(mt8183_da7219_max98357_dapm_widgets),
-       .dapm_routes = mt8183_da7219_max98357_dapm_routes,
-       .num_dapm_routes = ARRAY_SIZE(mt8183_da7219_max98357_dapm_routes),
+       .controls = mt8183_da7219_rt1015_snd_controls,
+       .num_controls = ARRAY_SIZE(mt8183_da7219_rt1015_snd_controls),
+       .dapm_widgets = mt8183_da7219_rt1015_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(mt8183_da7219_rt1015_dapm_widgets),
+       .dapm_routes = mt8183_da7219_rt1015_dapm_routes,
+       .num_dapm_routes = ARRAY_SIZE(mt8183_da7219_rt1015_dapm_routes),
        .dai_link = mt8183_da7219_dai_links,
        .num_links = ARRAY_SIZE(mt8183_da7219_dai_links),
        .aux_dev = &mt8183_da7219_max98357_headset_dev,
index ba2aca301a9b25426ad226bd3167d5d72c4483cc..9d17c87445a9bc60cdd0bac7a818d74bb86db4df 100644 (file)
@@ -80,6 +80,12 @@ static int lpass_cpu_daiops_startup(struct snd_pcm_substream *substream,
                dev_err(dai->dev, "error in enabling mi2s osr clk: %d\n", ret);
                return ret;
        }
+       ret = clk_prepare(drvdata->mi2s_bit_clk[dai->driver->id]);
+       if (ret) {
+               dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret);
+               clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
+               return ret;
+       }
        return 0;
 }
 
@@ -88,9 +94,8 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream,
 {
        struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai);
 
-       clk_disable_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]);
-
        clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]);
+       clk_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]);
 }
 
 static int lpass_cpu_daiops_hw_params(struct snd_pcm_substream *substream,
@@ -303,10 +308,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream,
                        dev_err(dai->dev, "error writing to i2sctl reg: %d\n",
                                ret);
 
-               ret = clk_prepare_enable(drvdata->mi2s_bit_clk[id]);
+               ret = clk_enable(drvdata->mi2s_bit_clk[id]);
                if (ret) {
                        dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret);
-                       clk_disable_unprepare(drvdata->mi2s_osr_clk[id]);
+                       clk_disable(drvdata->mi2s_osr_clk[id]);
                        return ret;
                }
 
@@ -324,6 +329,7 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream,
                if (ret)
                        dev_err(dai->dev, "error writing to i2sctl reg: %d\n",
                                ret);
+               clk_disable(drvdata->mi2s_bit_clk[dai->driver->id]);
                break;
        }
 
index c6292f9e613f24ecbbde90cc80b113e6a37b5c67..bc998d50160000b4e1ff216491081504e48052cf 100644 (file)
@@ -188,7 +188,7 @@ static struct lpass_variant sc7180_data = {
        .micmode                = REG_FIELD_ID(0x1000, 4, 8, 3, 0x1000),
        .micmono                = REG_FIELD_ID(0x1000, 3, 3, 3, 0x1000),
        .wssrc                  = REG_FIELD_ID(0x1000, 2, 2, 3, 0x1000),
-       .bitwidth               = REG_FIELD_ID(0x1000, 0, 0, 3, 0x1000),
+       .bitwidth               = REG_FIELD_ID(0x1000, 0, 1, 3, 0x1000),
 
        .rdma_dyncclk           = REG_FIELD_ID(0xC000, 21, 21, 5, 0x1000),
        .rdma_bursten           = REG_FIELD_ID(0xC000, 20, 20, 5, 0x1000),
index ab1bf23c21a6847eaacec2978179ee19cc9c0ee0..6c2760e27ea6fdbab1651e9f1ccbdc07887c73d7 100644 (file)
@@ -17,6 +17,7 @@
 #include "qdsp6/q6afe.h"
 #include "../codecs/rt5663.h"
 
+#define DRIVER_NAME    "sdm845"
 #define DEFAULT_SAMPLE_RATE_48K                48000
 #define DEFAULT_MCLK_RATE              24576000
 #define TDM_BCLK_RATE          6144000
@@ -552,6 +553,7 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)
        if (!data)
                return -ENOMEM;
 
+       card->driver_name = DRIVER_NAME;
        card->dapm_widgets = sdm845_snd_widgets;
        card->num_dapm_widgets = ARRAY_SIZE(sdm845_snd_widgets);
        card->dev = dev;
index ea3986a46c12a8325e430d618b1f65422593235c..05a085f6dc7ce7d1234278023e24e45488bc55c2 100644 (file)
@@ -2341,7 +2341,7 @@ struct snd_soc_dai *snd_soc_register_dai(struct snd_soc_component *component,
 }
 
 /**
- * snd_soc_unregister_dai - Unregister DAIs from the ASoC core
+ * snd_soc_unregister_dais - Unregister DAIs from the ASoC core
  *
  * @component: The component for which the DAIs should be unregistered
  */
index 980f2c330b87ff595efe20fd54614cdad231d8bb..7f87b449f950b8a55c9cc526a925aef1d9e27b1a 100644 (file)
@@ -1276,7 +1276,7 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
 }
 
 /**
- * snd_soc_dapm_get_connected_widgets - query audio path and it's widgets.
+ * snd_soc_dapm_dai_get_connected_widgets - query audio path and it's widgets.
  * @dai: the soc DAI.
  * @stream: stream direction.
  * @list: list of active widgets for this stream.
index 68ed454f7ddf1b5b2af8d63f83ae1043334b7100..ba9ed66f98bc7607741fefa0a00ae3509116d71e 100644 (file)
@@ -118,6 +118,11 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset)
                case SOF_IPC_EXT_CC_INFO:
                        ret = get_cc_info(sdev, ext_hdr);
                        break;
+               case SOF_IPC_EXT_UNUSED:
+               case SOF_IPC_EXT_PROBE_INFO:
+               case SOF_IPC_EXT_USER_ABI_INFO:
+                       /* They are supported but we don't do anything here */
+                       break;
                default:
                        dev_warn(sdev->dev, "warning: unknown ext header type %d size 0x%x\n",
                                 ext_hdr->type, ext_hdr->hdr.size);
index b401ee894e1bb6978b595c750d12254e7b775618..a860303cc52225cd1a61287c177678f34430ce5f 100644 (file)
@@ -336,6 +336,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
        switch (subs->stream->chip->usb_id) {
        case USB_ID(0x0763, 0x2030): /* M-Audio Fast Track C400 */
        case USB_ID(0x0763, 0x2031): /* M-Audio Fast Track C600 */
+       case USB_ID(0x22f0, 0x0006): /* Allen&Heath Qu-16 */
                ep = 0x81;
                ifnum = 3;
                goto add_sync_ep_from_ifnum;
@@ -345,6 +346,7 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
                ifnum = 2;
                goto add_sync_ep_from_ifnum;
        case USB_ID(0x2466, 0x8003): /* Fractal Audio Axe-Fx II */
+       case USB_ID(0x0499, 0x172a): /* Yamaha MODX */
                ep = 0x86;
                ifnum = 2;
                goto add_sync_ep_from_ifnum;
@@ -352,6 +354,10 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
                ep = 0x81;
                ifnum = 2;
                goto add_sync_ep_from_ifnum;
+       case USB_ID(0x1686, 0xf029): /* Zoom UAC-2 */
+               ep = 0x82;
+               ifnum = 2;
+               goto add_sync_ep_from_ifnum;
        case USB_ID(0x1397, 0x0001): /* Behringer UFX1604 */
        case USB_ID(0x1397, 0x0002): /* Behringer UFX1204 */
                ep = 0x81;
index b4fa80ef730d96c2ba20f23b41110e5d85e2642c..c989ad8052aebde328e89a4b43745727e881e38f 100644 (file)
@@ -1800,6 +1800,7 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
        case 0x278b:  /* Rotel? */
        case 0x292b:  /* Gustard/Ess based devices */
        case 0x2ab6:  /* T+A devices */
+       case 0x3353:  /* Khadas devices */
        case 0x3842:  /* EVGA */
        case 0xc502:  /* HiBy devices */
                if (fp->dsd_raw)
index ba85bb23f06017b4ed401da32167c057d526b1d0..1c17c3a24411d6b0dfd33424d1b493d4750d0221 100644 (file)
@@ -159,6 +159,21 @@ struct kvm_sync_regs {
 struct kvm_arch_memory_slot {
 };
 
+/*
+ * PMU filter structure. Describe a range of events with a particular
+ * action. To be used with KVM_ARM_VCPU_PMU_V3_FILTER.
+ */
+struct kvm_pmu_event_filter {
+       __u16   base_event;
+       __u16   nevents;
+
+#define KVM_PMU_EVENT_ALLOW    0
+#define KVM_PMU_EVENT_DENY     1
+
+       __u8    action;
+       __u8    pad[3];
+};
+
 /* for KVM_GET/SET_VCPU_EVENTS */
 struct kvm_vcpu_events {
        struct {
@@ -242,6 +257,15 @@ struct kvm_vcpu_events {
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_AVAIL          0
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_AVAIL              1
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1_NOT_REQUIRED       2
+
+/*
+ * Only two states can be presented by the host kernel:
+ * - NOT_REQUIRED: the guest doesn't need to do anything
+ * - NOT_AVAIL: the guest isn't mitigated (it can still use SSBS if available)
+ *
+ * All the other values are deprecated. The host still accepts all
+ * values (they are ABI), but will narrow them to the above two.
+ */
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2    KVM_REG_ARM_FW_REG(2)
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_AVAIL          0
 #define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN            1
@@ -329,6 +353,7 @@ struct kvm_vcpu_events {
 #define KVM_ARM_VCPU_PMU_V3_CTRL       0
 #define   KVM_ARM_VCPU_PMU_V3_IRQ      0
 #define   KVM_ARM_VCPU_PMU_V3_INIT     1
+#define   KVM_ARM_VCPU_PMU_V3_FILTER   2
 #define KVM_ARM_VCPU_TIMER_CTRL                1
 #define   KVM_ARM_VCPU_TIMER_IRQ_VTIMER                0
 #define   KVM_ARM_VCPU_TIMER_IRQ_PTIMER                1
index 6ca1e68d7103139f1ef6029980aea2f3198072be..ede318653c87dd82ea64add7bec8ff8d38efaac7 100644 (file)
@@ -29,7 +29,7 @@
        { 0x13, "SIGP conditional emergency signal" },          \
        { 0x15, "SIGP sense running" },                         \
        { 0x16, "SIGP set multithreading"},                     \
-       { 0x17, "SIGP store additional status ait address"}
+       { 0x17, "SIGP store additional status at address"}
 
 #define icpt_prog_codes                                                \
        { 0x0001, "Prog Operation" },                           \
index 2901d5df4366c0409e6d295d0eb1585aa1568ea9..dad350d42ecfbf3063c64138375e81591729b092 100644 (file)
@@ -96,7 +96,7 @@
 #define X86_FEATURE_SYSCALL32          ( 3*32+14) /* "" syscall in IA32 userspace */
 #define X86_FEATURE_SYSENTER32         ( 3*32+15) /* "" sysenter in IA32 userspace */
 #define X86_FEATURE_REP_GOOD           ( 3*32+16) /* REP microcode works well */
-/* free                                        ( 3*32+17) */
+#define X86_FEATURE_SME_COHERENT       ( 3*32+17) /* "" AMD hardware-enforced cache coherency */
 #define X86_FEATURE_LFENCE_RDTSC       ( 3*32+18) /* "" LFENCE synchronizes RDTSC */
 #define X86_FEATURE_ACC_POWER          ( 3*32+19) /* AMD Accumulated Power Mechanism */
 #define X86_FEATURE_NOPL               ( 3*32+20) /* The NOPL (0F 1F) instructions */
 #define X86_FEATURE_EPT_AD             ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
 #define X86_FEATURE_VMCALL             ( 8*32+18) /* "" Hypervisor supports the VMCALL instruction */
 #define X86_FEATURE_VMW_VMMCALL                ( 8*32+19) /* "" VMware prefers VMMCALL hypercall instruction */
+#define X86_FEATURE_SEV_ES             ( 8*32+20) /* AMD Secure Encrypted Virtualization - Encrypted State */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
 #define X86_FEATURE_FSGSBASE           ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
 #define X86_FEATURE_FENCE_SWAPGS_USER  (11*32+ 4) /* "" LFENCE in user entry SWAPGS path */
 #define X86_FEATURE_FENCE_SWAPGS_KERNEL        (11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */
 #define X86_FEATURE_SPLIT_LOCK_DETECT  (11*32+ 6) /* #AC for split lock */
+#define X86_FEATURE_PER_THREAD_MBA     (11*32+ 7) /* "" Per-thread Memory Bandwidth Allocation */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
 #define X86_FEATURE_AVX512_BF16                (12*32+ 5) /* AVX512 BFLOAT16 instructions */
 #define X86_FEATURE_CLDEMOTE           (16*32+25) /* CLDEMOTE instruction */
 #define X86_FEATURE_MOVDIRI            (16*32+27) /* MOVDIRI instruction */
 #define X86_FEATURE_MOVDIR64B          (16*32+28) /* MOVDIR64B instruction */
+#define X86_FEATURE_ENQCMD             (16*32+29) /* ENQCMD and ENQCMDS instructions */
 
 /* AMD-defined CPU features, CPUID level 0x80000007 (EBX), word 17 */
 #define X86_FEATURE_OVERFLOW_RECOV     (17*32+ 0) /* MCA overflow recovery support */
 #define X86_FEATURE_MD_CLEAR           (18*32+10) /* VERW clears CPU buffers */
 #define X86_FEATURE_TSX_FORCE_ABORT    (18*32+13) /* "" TSX_FORCE_ABORT */
 #define X86_FEATURE_SERIALIZE          (18*32+14) /* SERIALIZE instruction */
+#define X86_FEATURE_TSXLDTRK           (18*32+16) /* TSX Suspend Load Address Tracking */
 #define X86_FEATURE_PCONFIG            (18*32+18) /* Intel PCONFIG */
 #define X86_FEATURE_ARCH_LBR           (18*32+19) /* Intel ARCH LBR */
 #define X86_FEATURE_SPEC_CTRL          (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
index 4ea8584682f9982662e34db1f9df77377f4a3662..5861d34f977182983ab4d0834f109acaca323d0f 100644 (file)
 # define DISABLE_PTI           (1 << (X86_FEATURE_PTI & 31))
 #endif
 
+#ifdef CONFIG_IOMMU_SUPPORT
+# define DISABLE_ENQCMD        0
+#else
+# define DISABLE_ENQCMD (1 << (X86_FEATURE_ENQCMD & 31))
+#endif
+
 /*
  * Make sure to add features to the correct mask
  */
@@ -75,7 +81,8 @@
 #define DISABLED_MASK13        0
 #define DISABLED_MASK14        0
 #define DISABLED_MASK15        0
-#define DISABLED_MASK16        (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP)
+#define DISABLED_MASK16        (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \
+                        DISABLE_ENQCMD)
 #define DISABLED_MASK17        0
 #define DISABLED_MASK18        0
 #define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
index 2859ee4f39a83fa4d73cc0f261e3effff7a455e7..972a34d935059aa49d01db8f20c3e598fffb22ac 100644 (file)
 #define MSR_IA32_LASTINTFROMIP         0x000001dd
 #define MSR_IA32_LASTINTTOIP           0x000001de
 
+#define MSR_IA32_PASID                 0x00000d93
+#define MSR_IA32_PASID_VALID           BIT_ULL(31)
+
 /* DEBUGCTLMSR bits (others vary by model): */
 #define DEBUGCTLMSR_LBR                        (1UL <<  0) /* last branch recording */
 #define DEBUGCTLMSR_BTF_SHIFT          1
 #define MSR_AMD64_IBSOP_REG_MASK       ((1UL<<MSR_AMD64_IBSOP_REG_COUNT)-1)
 #define MSR_AMD64_IBSCTL               0xc001103a
 #define MSR_AMD64_IBSBRTARGET          0xc001103b
+#define MSR_AMD64_ICIBSEXTDCTL         0xc001103c
 #define MSR_AMD64_IBSOPDATA4           0xc001103d
 #define MSR_AMD64_IBS_REG_COUNT_MAX    8 /* includes MSR_AMD64_IBSBRTARGET */
+#define MSR_AMD64_SEV_ES_GHCB          0xc0010130
 #define MSR_AMD64_SEV                  0xc0010131
 #define MSR_AMD64_SEV_ENABLED_BIT      0
+#define MSR_AMD64_SEV_ES_ENABLED_BIT   1
 #define MSR_AMD64_SEV_ENABLED          BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT)
+#define MSR_AMD64_SEV_ES_ENABLED       BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT)
 
 #define MSR_AMD64_VIRT_SPEC_CTRL       0xc001011f
 
 #define MSR_CORE_PERF_FIXED_CTR0       0x00000309
 #define MSR_CORE_PERF_FIXED_CTR1       0x0000030a
 #define MSR_CORE_PERF_FIXED_CTR2       0x0000030b
+#define MSR_CORE_PERF_FIXED_CTR3       0x0000030c
 #define MSR_CORE_PERF_FIXED_CTR_CTRL   0x0000038d
 #define MSR_CORE_PERF_GLOBAL_STATUS    0x0000038e
 #define MSR_CORE_PERF_GLOBAL_CTRL      0x0000038f
 #define MSR_CORE_PERF_GLOBAL_OVF_CTRL  0x00000390
 
+#define MSR_PERF_METRICS               0x00000329
+
 /* PERF_GLOBAL_OVF_CTL bits */
 #define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT       55
 #define MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI           (1ULL << MSR_CORE_PERF_GLOBAL_OVF_CTRL_TRACE_TOPA_PMI_BIT)
index 6847d85400a8b738ca2adf00ea95fdf8f349fafc..3ff0d48469f281fb104fe164c2b3c0b7dea9cae8 100644 (file)
@@ -54,7 +54,7 @@
 #endif
 
 #ifdef CONFIG_X86_64
-#ifdef CONFIG_PARAVIRT
+#ifdef CONFIG_PARAVIRT_XXL
 /* Paravirtualized systems may not have PSE or PGE available */
 #define NEED_PSE       0
 #define NEED_PGE       0
index 0780f97c185088ce214bf7f57d917fda7aff730b..89e5f3d1bba86b8bbb0e7a80cbed2d1373d093af 100644 (file)
@@ -192,6 +192,26 @@ struct kvm_msr_list {
        __u32 indices[0];
 };
 
+/* Maximum size of any access bitmap in bytes */
+#define KVM_MSR_FILTER_MAX_BITMAP_SIZE 0x600
+
+/* for KVM_X86_SET_MSR_FILTER */
+struct kvm_msr_filter_range {
+#define KVM_MSR_FILTER_READ  (1 << 0)
+#define KVM_MSR_FILTER_WRITE (1 << 1)
+       __u32 flags;
+       __u32 nmsrs; /* number of msrs in bitmap */
+       __u32 base;  /* MSR index the bitmap starts at */
+       __u8 *bitmap; /* a 1 bit allows the operations in flags, 0 denies */
+};
+
+#define KVM_MSR_FILTER_MAX_RANGES 16
+struct kvm_msr_filter {
+#define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
+#define KVM_MSR_FILTER_DEFAULT_DENY  (1 << 0)
+       __u32 flags;
+       struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
+};
 
 struct kvm_cpuid_entry {
        __u32 function;
index 2e8a30f06c74641cead87f4f460089f081c63ea7..f1d8307454e0c166fa244e65e81261c78687c1aa 100644 (file)
@@ -29,6 +29,7 @@
 #define SVM_EXIT_WRITE_DR6     0x036
 #define SVM_EXIT_WRITE_DR7     0x037
 #define SVM_EXIT_EXCP_BASE     0x040
+#define SVM_EXIT_LAST_EXCP     0x05f
 #define SVM_EXIT_INTR          0x060
 #define SVM_EXIT_NMI           0x061
 #define SVM_EXIT_SMI           0x062
 #define SVM_EXIT_MWAIT_COND    0x08c
 #define SVM_EXIT_XSETBV        0x08d
 #define SVM_EXIT_RDPRU         0x08e
+#define SVM_EXIT_INVPCID       0x0a2
 #define SVM_EXIT_NPF           0x400
 #define SVM_EXIT_AVIC_INCOMPLETE_IPI           0x401
 #define SVM_EXIT_AVIC_UNACCELERATED_ACCESS     0x402
 
+/* SEV-ES software-defined VMGEXIT events */
+#define SVM_VMGEXIT_MMIO_READ                  0x80000001
+#define SVM_VMGEXIT_MMIO_WRITE                 0x80000002
+#define SVM_VMGEXIT_NMI_COMPLETE               0x80000003
+#define SVM_VMGEXIT_AP_HLT_LOOP                        0x80000004
+#define SVM_VMGEXIT_AP_JUMP_TABLE              0x80000005
+#define SVM_VMGEXIT_SET_AP_JUMP_TABLE          0
+#define SVM_VMGEXIT_GET_AP_JUMP_TABLE          1
+#define SVM_VMGEXIT_UNSUPPORTED_EVENT          0x8000ffff
+
 #define SVM_EXIT_ERR           -1
 
 #define SVM_EXIT_REASONS \
        { SVM_EXIT_MONITOR,     "monitor" }, \
        { SVM_EXIT_MWAIT,       "mwait" }, \
        { SVM_EXIT_XSETBV,      "xsetbv" }, \
+       { SVM_EXIT_INVPCID,     "invpcid" }, \
        { SVM_EXIT_NPF,         "npf" }, \
        { SVM_EXIT_AVIC_INCOMPLETE_IPI,         "avic_incomplete_ipi" }, \
        { SVM_EXIT_AVIC_UNACCELERATED_ACCESS,   "avic_unaccelerated_access" }, \
index a04e81321c665f195d129e25f5d6086a27e47cfe..464873883396e9c7e85795174f019ed8106a3192 100644 (file)
@@ -185,7 +185,6 @@ int main(int argc, char *argv[])
        main_test_libperl();
        main_test_hello();
        main_test_libelf();
-       main_test_libelf_mmap();
        main_test_get_current_dir_name();
        main_test_gettid();
        main_test_glibc();
index b9d4322e1e6551f3e987624073a08a9b3368b7f8..95c072b70d0e832f70a4ac07470bcd0d1ed46deb 100644 (file)
 #define  __pure                __attribute__((pure))
 #endif
 #define  noinline      __attribute__((noinline))
-#ifdef __has_attribute
-#if __has_attribute(disable_tail_calls)
-#define __no_tail_call __attribute__((disable_tail_calls))
-#endif
-#endif
-#ifndef __no_tail_call
-#if GCC_VERSION > 40201
-#define __no_tail_call __attribute__((optimize("no-optimize-sibling-calls")))
-#else
-#define __no_tail_call
-#endif
-#endif
 #ifndef __packed
 #define __packed       __attribute__((packed))
 #endif
index 2b3f7353e891f5ad8ab63aae9ef78dab4a23449e..d22a974372c0e212433a512611ddbef78c2c74f5 100644 (file)
@@ -47,9 +47,6 @@
 #ifndef noinline
 #define noinline
 #endif
-#ifndef __no_tail_call
-#define __no_tail_call
-#endif
 
 /* Are two types/vars the same type (ignoring qualifiers)? */
 #ifndef __same_type
index f2b5d72a46c23b9f9abd6b439b29e1192bf59dff..2056318988f774931c4e0a3104144bf4a75ff52f 100644 (file)
@@ -857,9 +857,11 @@ __SYSCALL(__NR_openat2, sys_openat2)
 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd)
 #define __NR_faccessat2 439
 __SYSCALL(__NR_faccessat2, sys_faccessat2)
+#define __NR_process_madvise 440
+__SYSCALL(__NR_process_madvise, sys_process_madvise)
 
 #undef __NR_syscalls
-#define __NR_syscalls 440
+#define __NR_syscalls 441
 
 /*
  * 32 bit systems traditionally used different
index 00546062e0235d9b445c5288573e3bd1854aa04a..fa1f3d62f9a6cebb300c63bf82955af91ab2a6ed 100644 (file)
@@ -619,6 +619,12 @@ typedef struct drm_i915_irq_wait {
  */
 #define I915_PARAM_PERF_REVISION       54
 
+/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
+ * timeline syncobj through drm_i915_gem_execbuffer_ext_timeline_fences. See
+ * I915_EXEC_USE_EXTENSIONS.
+ */
+#define I915_PARAM_HAS_EXEC_TIMELINE_FENCES 55
+
 /* Must be kept compact -- no holes and well documented */
 
 typedef struct drm_i915_getparam {
@@ -1046,6 +1052,38 @@ struct drm_i915_gem_exec_fence {
        __u32 flags;
 };
 
+/**
+ * See drm_i915_gem_execbuffer_ext_timeline_fences.
+ */
+#define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0
+
+/**
+ * This structure describes an array of drm_syncobj and associated points for
+ * timeline variants of drm_syncobj. It is invalid to append this structure to
+ * the execbuf if I915_EXEC_FENCE_ARRAY is set.
+ */
+struct drm_i915_gem_execbuffer_ext_timeline_fences {
+       struct i915_user_extension base;
+
+       /**
+        * Number of element in the handles_ptr & value_ptr arrays.
+        */
+       __u64 fence_count;
+
+       /**
+        * Pointer to an array of struct drm_i915_gem_exec_fence of length
+        * fence_count.
+        */
+       __u64 handles_ptr;
+
+       /**
+        * Pointer to an array of u64 values of length fence_count. Values
+        * must be 0 for a binary drm_syncobj. A Value of 0 for a timeline
+        * drm_syncobj is invalid as it turns a drm_syncobj into a binary one.
+        */
+       __u64 values_ptr;
+};
+
 struct drm_i915_gem_execbuffer2 {
        /**
         * List of gem_exec_object2 structs
@@ -1062,8 +1100,14 @@ struct drm_i915_gem_execbuffer2 {
        __u32 num_cliprects;
        /**
         * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
-        * is not set.  If I915_EXEC_FENCE_ARRAY is set, then this is a
-        * struct drm_i915_gem_exec_fence *fences.
+        * & I915_EXEC_USE_EXTENSIONS are not set.
+        *
+        * If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array
+        * of struct drm_i915_gem_exec_fence and num_cliprects is the length
+        * of the array.
+        *
+        * If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a
+        * single struct i915_user_extension and num_cliprects is 0.
         */
        __u64 cliprects_ptr;
 #define I915_EXEC_RING_MASK              (0x3f)
@@ -1181,7 +1225,16 @@ struct drm_i915_gem_execbuffer2 {
  */
 #define I915_EXEC_FENCE_SUBMIT         (1 << 20)
 
-#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SUBMIT << 1))
+/*
+ * Setting I915_EXEC_USE_EXTENSIONS implies that
+ * drm_i915_gem_execbuffer2.cliprects_ptr is treated as a pointer to an linked
+ * list of i915_user_extension. Each i915_user_extension node is the base of a
+ * larger structure. The list of supported structures are listed in the
+ * drm_i915_gem_execbuffer_ext enum.
+ */
+#define I915_EXEC_USE_EXTENSIONS       (1 << 21)
+
+#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1))
 
 #define I915_EXEC_CONTEXT_ID_MASK      (0xffffffff)
 #define i915_execbuffer2_set_context_id(eb2, context) \
index 7875709ccfebff2a5903f73e753a015015729c5d..e5de60336938121f0584e0b43e9fc01fcb3d356c 100644 (file)
@@ -45,7 +45,6 @@ struct fscrypt_policy_v1 {
        __u8 flags;
        __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
 };
-#define fscrypt_policy fscrypt_policy_v1
 
 /*
  * Process-subscribed "logon" key description prefix and payload format.
@@ -156,9 +155,9 @@ struct fscrypt_get_key_status_arg {
        __u32 __out_reserved[13];
 };
 
-#define FS_IOC_SET_ENCRYPTION_POLICY           _IOR('f', 19, struct fscrypt_policy)
+#define FS_IOC_SET_ENCRYPTION_POLICY           _IOR('f', 19, struct fscrypt_policy_v1)
 #define FS_IOC_GET_ENCRYPTION_PWSALT           _IOW('f', 20, __u8[16])
-#define FS_IOC_GET_ENCRYPTION_POLICY           _IOW('f', 21, struct fscrypt_policy)
+#define FS_IOC_GET_ENCRYPTION_POLICY           _IOW('f', 21, struct fscrypt_policy_v1)
 #define FS_IOC_GET_ENCRYPTION_POLICY_EX                _IOWR('f', 22, __u8[9]) /* size + version */
 #define FS_IOC_ADD_ENCRYPTION_KEY              _IOWR('f', 23, struct fscrypt_add_key_arg)
 #define FS_IOC_REMOVE_ENCRYPTION_KEY           _IOWR('f', 24, struct fscrypt_remove_key_arg)
@@ -170,6 +169,7 @@ struct fscrypt_get_key_status_arg {
 
 /* old names; don't add anything new here! */
 #ifndef __KERNEL__
+#define fscrypt_policy                 fscrypt_policy_v1
 #define FS_KEY_DESCRIPTOR_SIZE         FSCRYPT_KEY_DESCRIPTOR_SIZE
 #define FS_POLICY_FLAGS_PAD_4          FSCRYPT_POLICY_FLAGS_PAD_4
 #define FS_POLICY_FLAGS_PAD_8          FSCRYPT_POLICY_FLAGS_PAD_8
index 7d8eced6f459b065c445ba8dcbc107f785dc24fa..ca41220b40b8b25c8f1044496f8024458768868b 100644 (file)
@@ -248,6 +248,8 @@ struct kvm_hyperv_exit {
 #define KVM_EXIT_IOAPIC_EOI       26
 #define KVM_EXIT_HYPERV           27
 #define KVM_EXIT_ARM_NISV         28
+#define KVM_EXIT_X86_RDMSR        29
+#define KVM_EXIT_X86_WRMSR        30
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 /* Emulate instruction failed. */
@@ -413,6 +415,17 @@ struct kvm_run {
                        __u64 esr_iss;
                        __u64 fault_ipa;
                } arm_nisv;
+               /* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */
+               struct {
+                       __u8 error; /* user -> kernel */
+                       __u8 pad[7];
+#define KVM_MSR_EXIT_REASON_INVAL      (1 << 0)
+#define KVM_MSR_EXIT_REASON_UNKNOWN    (1 << 1)
+#define KVM_MSR_EXIT_REASON_FILTER     (1 << 2)
+                       __u32 reason; /* kernel -> user */
+                       __u32 index; /* kernel -> user */
+                       __u64 data; /* kernel <-> user */
+               } msr;
                /* Fix the size of the union. */
                char padding[256];
        };
@@ -1037,6 +1050,9 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_SMALLER_MAXPHYADDR 185
 #define KVM_CAP_S390_DIAG318 186
 #define KVM_CAP_STEAL_TIME 187
+#define KVM_CAP_X86_USER_SPACE_MSR 188
+#define KVM_CAP_X86_MSR_FILTER 189
+#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -1538,6 +1554,9 @@ struct kvm_pv_cmd {
 /* Available with KVM_CAP_S390_PROTECTED */
 #define KVM_S390_PV_COMMAND            _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
 
+/* Available with KVM_CAP_X86_MSR_FILTER */
+#define KVM_X86_SET_MSR_FILTER _IOW(KVMIO,  0xc6, struct kvm_msr_filter)
+
 /* Secure Encrypted Virtualization command */
 enum sev_cmd_id {
        /* Guest initialization commands */
index 923cc162609c016dd6360d834b34abfe6e1ba459..f55bc680b5b0a45eefca46732e265a8bfe2f46aa 100644 (file)
@@ -27,6 +27,7 @@
 #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
 #define MAP_HUGE_MASK  HUGETLB_FLAG_ENCODE_MASK
 
+#define MAP_HUGE_16KB  HUGETLB_FLAG_ENCODE_16KB
 #define MAP_HUGE_64KB  HUGETLB_FLAG_ENCODE_64KB
 #define MAP_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB
 #define MAP_HUGE_1MB   HUGETLB_FLAG_ENCODE_1MB
index 96a0240f23fed37be9430b72d2f2d9ffd6d42237..dd8306ea336c19b695fa9a748c14f5ad92fe3e63 100644 (file)
@@ -16,6 +16,7 @@
 #define MS_REMOUNT     32      /* Alter flags of a mounted FS */
 #define MS_MANDLOCK    64      /* Allow mandatory locks on an FS */
 #define MS_DIRSYNC     128     /* Directory modifications are synchronous */
+#define MS_NOSYMFOLLOW 256     /* Do not follow symlinks */
 #define MS_NOATIME     1024    /* Do not update access times. */
 #define MS_NODIRATIME  2048    /* Do not update directory access times */
 #define MS_BIND                4096
index 3e5dcdd48a4998ddc3b59ee77b376d909e345e84..b95d3c485d27e10f5a1b04354a1bb4ba7cc41146 100644 (file)
@@ -1196,7 +1196,7 @@ union perf_mem_data_src {
 
 #define PERF_MEM_SNOOPX_FWD    0x01 /* forward */
 /* 1 free */
-#define PERF_MEM_SNOOPX_SHIFT  38
+#define PERF_MEM_SNOOPX_SHIFT  38
 
 /* locked instruction */
 #define PERF_MEM_LOCK_NA       0x01 /* not available */
index 07b4f8131e362bdc815f37cea0c9067a9464f256..7f0827705c9a461fcf0af8bf070a283f4bd708c1 100644 (file)
@@ -233,6 +233,15 @@ struct prctl_mm_map {
 #define PR_SET_TAGGED_ADDR_CTRL                55
 #define PR_GET_TAGGED_ADDR_CTRL                56
 # define PR_TAGGED_ADDR_ENABLE         (1UL << 0)
+/* MTE tag check fault modes */
+# define PR_MTE_TCF_SHIFT              1
+# define PR_MTE_TCF_NONE               (0UL << PR_MTE_TCF_SHIFT)
+# define PR_MTE_TCF_SYNC               (1UL << PR_MTE_TCF_SHIFT)
+# define PR_MTE_TCF_ASYNC              (2UL << PR_MTE_TCF_SHIFT)
+# define PR_MTE_TCF_MASK               (3UL << PR_MTE_TCF_SHIFT)
+/* MTE tag inclusion mask */
+# define PR_MTE_TAG_SHIFT              3
+# define PR_MTE_TAG_MASK               (0xffffUL << PR_MTE_TAG_SHIFT)
 
 /* Control reclaim behavior when allocating memory */
 #define PR_SET_IO_FLUSHER              57
index 75232185324abb8bf16521b525ed007306ab582f..c998860d7bbc4351c37c702ea69ea88a814b19cf 100644 (file)
 
 /* Set event fd for config interrupt*/
 #define VHOST_VDPA_SET_CONFIG_CALL     _IOW(VHOST_VIRTIO, 0x77, int)
+
+/* Get the valid iova range */
+#define VHOST_VDPA_GET_IOVA_RANGE      _IOR(VHOST_VIRTIO, 0x78, \
+                                            struct vhost_vdpa_iova_range)
 #endif
index 6890fc4b063a4a6021ad8530136745130349d483..ce8516e4de34fa60ee50c3fedc0190c625f8f3ac 100644 (file)
@@ -749,6 +749,7 @@ else
   PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
   PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
   PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
+  PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
   PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
   FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
 
index 347809649ba28fa15be86511d563ff9d427ecaea..379819244b91d275b2c98f7ff38a59049c24b42a 100644 (file)
 437    common  openat2                 sys_openat2
 438    common  pidfd_getfd             sys_pidfd_getfd
 439    common  faccessat2              sys_faccessat2
+440    common  process_madvise         sys_process_madvise
 
 #
-# x32-specific system call numbers start at 512 to avoid cache impact
-# for native 64-bit operation. The __x32_compat_sys stubs are created
-# on-the-fly for compat_sys_*() compatibility system calls if X86_X32
-# is defined.
+# Due to a historical design error, certain syscalls are numbered differently
+# in x32 as compared to native x86_64.  These syscalls have numbers 512-547.
+# Do not add new syscalls to this range.  Numbers 548 and above are available
+# for non-x32 use.
 #
 512    x32     rt_sigaction            compat_sys_rt_sigaction
 513    x32     rt_sigreturn            compat_sys_x32_rt_sigreturn
 545    x32     execveat                compat_sys_execveat
 546    x32     preadv2                 compat_sys_preadv64v2
 547    x32     pwritev2                compat_sys_pwritev64v2
+# This is the end of the legacy x32 range.  Numbers 548 and above are
+# not special and are not to be used for x32-specific syscalls.
index 44a75f234db17c6cb18e133521e0d0d9f112ec03..de80534473afa5fe9da8af543b438fcebd540bf3 100644 (file)
@@ -4639,9 +4639,9 @@ do_concat:
        err = 0;
 
        if (lists[0]) {
-               struct option o = OPT_CALLBACK('e', "event", &trace->evlist, "event",
-                                              "event selector. use 'perf list' to list available events",
-                                              parse_events_option);
+               struct option o = {
+                       .value = &trace->evlist,
+               };
                err = parse_events_option(&o, lists[0], 0);
        }
 out:
@@ -4655,9 +4655,12 @@ static int trace__parse_cgroups(const struct option *opt, const char *str, int u
 {
        struct trace *trace = opt->value;
 
-       if (!list_empty(&trace->evlist->core.entries))
-               return parse_cgroups(opt, str, unset);
-
+       if (!list_empty(&trace->evlist->core.entries)) {
+               struct option o = {
+                       .value = &trace->evlist,
+               };
+               return parse_cgroups(&o, str, unset);
+       }
        trace->cgroup = evlist__findnew_cgroup(trace->evlist, str);
 
        return 0;
index de3193552277c1ac892ed61daa6f6bf99fef3235..00f4fcffa81584bab4756537821551ba5dd725f3 100644 (file)
     },
     {
         "BriefDescription": "Average external Memory Bandwidth Use for reads and writes [GB / sec]",
-        "MetricExpr": "( 64 * ( uncore_imc@cas_count_read@ + uncore_imc@cas_count_write@ ) / 1000000000 ) / duration_time",
+        "MetricExpr": "( ( ( uncore_imc@cas_count_read@ + uncore_imc@cas_count_write@ ) * 1048576 ) / 1000000000 ) / duration_time",
         "MetricGroup": "Memory_BW;SoC",
         "MetricName": "DRAM_BW_Use"
     },
index f31794d3b9261e78b8edda6e20431e8b868f3d4d..0dd8b13b5cfb07ee2494512c18b619da038e58d7 100644 (file)
     },
     {
         "BriefDescription": "Average external Memory Bandwidth Use for reads and writes [GB / sec]",
-        "MetricExpr": "( 64 * ( uncore_imc@cas_count_read@ + uncore_imc@cas_count_write@ ) / 1000000000 ) / duration_time",
+        "MetricExpr": "( ( ( uncore_imc@cas_count_read@ + uncore_imc@cas_count_write@ ) * 1048576 ) / 1000000000 ) / duration_time",
         "MetricGroup": "Memory_BW;SoC",
         "MetricName": "DRAM_BW_Use"
     },
index 2491d167bf764f13d20a6f40e37068f0b7f30e6b..83638097c3bc19f8b9fc9e498432238548798aea 100644 (file)
@@ -95,7 +95,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)
        return strcmp((const char *) symbol, funcs[idx]);
 }
 
-__no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread)
+noinline int test_dwarf_unwind__thread(struct thread *thread)
 {
        struct perf_sample sample;
        unsigned long cnt = 0;
@@ -126,7 +126,7 @@ __no_tail_call noinline int test_dwarf_unwind__thread(struct thread *thread)
 
 static int global_unwind_retval = -INT_MAX;
 
-__no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2)
+noinline int test_dwarf_unwind__compare(void *p1, void *p2)
 {
        /* Any possible value should be 'thread' */
        struct thread *thread = *(struct thread **)p1;
@@ -145,7 +145,7 @@ __no_tail_call noinline int test_dwarf_unwind__compare(void *p1, void *p2)
        return p1 - p2;
 }
 
-__no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread)
+noinline int test_dwarf_unwind__krava_3(struct thread *thread)
 {
        struct thread *array[2] = {thread, thread};
        void *fp = &bsearch;
@@ -164,12 +164,12 @@ __no_tail_call noinline int test_dwarf_unwind__krava_3(struct thread *thread)
        return global_unwind_retval;
 }
 
-__no_tail_call noinline int test_dwarf_unwind__krava_2(struct thread *thread)
+noinline int test_dwarf_unwind__krava_2(struct thread *thread)
 {
        return test_dwarf_unwind__krava_3(thread);
 }
 
-__no_tail_call noinline int test_dwarf_unwind__krava_1(struct thread *thread)
+noinline int test_dwarf_unwind__krava_1(struct thread *thread)
 {
        return test_dwarf_unwind__krava_2(thread);
 }
index a07626f072087d78738a81139a063597ccf0e02b..b0e1880cf992b15150ac645595aba7e86d4367e1 100644 (file)
@@ -2963,7 +2963,7 @@ static int perf_evsel__hists_browse(struct evsel *evsel, int nr_events,
        struct popup_action actions[MAX_OPTIONS];
        int nr_options = 0;
        int key = -1;
-       char buf[64];
+       char buf[128];
        int delay_secs = hbt ? hbt->refresh : 0;
 
 #define HIST_BROWSER_HELP_COMMON                                       \
index 8763772f1095e9774cfa30cafadaab6b180ac0c1..6b410c3d52dca948253eca99716536c4761a809a 100644 (file)
@@ -102,6 +102,8 @@ int build_id__sprintf(const struct build_id *build_id, char *bf)
        const u8 *raw = build_id->data;
        size_t i;
 
+       bf[0] = 0x0;
+
        for (i = 0; i < build_id->size; ++i) {
                sprintf(bid, "%02x", *raw);
                ++raw;
index a405dad068f59dd6ab96a40759adc683fdcbf2c2..3c20b126d60d869aa136b24d4b01c93d6302938e 100644 (file)
@@ -15,6 +15,9 @@
 /* make sure libbpf doesn't use kernel-only integer typedefs */
 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
 
+/* prevent accidental re-addition of reallocarray() */
+#pragma GCC poison reallocarray
+
 /* start with 4 buckets */
 #define HASHMAP_MIN_CAP_BITS 2
 
index e0af36b0e5d839e2fdd57f0f921c8ba17e4a3629..d9b385fe808c695ebd473ea27903da1f343f658a 100644 (file)
@@ -25,6 +25,18 @@ static inline size_t hash_bits(size_t h, int bits)
 #endif
 }
 
+/* generic C-string hashing function */
+static inline size_t str_hash(const char *s)
+{
+       size_t h = 0;
+
+       while (*s) {
+               h = h * 31 + *s;
+               s++;
+       }
+       return h;
+}
+
 typedef size_t (*hashmap_hash_fn)(const void *key, void *ctx);
 typedef bool (*hashmap_equal_fn)(const void *key1, const void *key2, void *ctx);
 
index 7d4194ffc5b081bb805f259737f64057f5527f68..15385ea00190fe21125b748c7d11801c14a3ce22 100644 (file)
@@ -786,11 +786,20 @@ static int machine__process_ksymbol_unregister(struct machine *machine,
                                               union perf_event *event,
                                               struct perf_sample *sample __maybe_unused)
 {
+       struct symbol *sym;
        struct map *map;
 
        map = maps__find(&machine->kmaps, event->ksymbol.addr);
-       if (map)
+       if (!map)
+               return 0;
+
+       if (map != machine->vmlinux_map)
                maps__remove(&machine->kmaps, map);
+       else {
+               sym = dso__find_symbol(map->dso, map->map_ip(map, map->start));
+               if (sym)
+                       dso__delete_symbol(map->dso, sym);
+       }
 
        return 0;
 }
index 7cbd024e3e634433a22b105d746d147c69a66153..c83c2c6564e010895845a243f564750b15789eba 100644 (file)
@@ -1592,7 +1592,6 @@ static void _free_command_line(wchar_t **command_line, int num)
 static int python_start_script(const char *script, int argc, const char **argv)
 {
        struct tables *tables = &tables_global;
-       PyMODINIT_FUNC (*initfunc)(void);
 #if PY_MAJOR_VERSION < 3
        const char **command_line;
 #else
@@ -1607,20 +1606,18 @@ static int python_start_script(const char *script, int argc, const char **argv)
        FILE *fp;
 
 #if PY_MAJOR_VERSION < 3
-       initfunc = initperf_trace_context;
        command_line = malloc((argc + 1) * sizeof(const char *));
        command_line[0] = script;
        for (i = 1; i < argc + 1; i++)
                command_line[i] = argv[i - 1];
+       PyImport_AppendInittab(name, initperf_trace_context);
 #else
-       initfunc = PyInit_perf_trace_context;
        command_line = malloc((argc + 1) * sizeof(wchar_t *));
        command_line[0] = Py_DecodeLocale(script, NULL);
        for (i = 1; i < argc + 1; i++)
                command_line[i] = Py_DecodeLocale(argv[i - 1], NULL);
+       PyImport_AppendInittab(name, PyInit_perf_trace_context);
 #endif
-
-       PyImport_AppendInittab(name, initfunc);
        Py_Initialize();
 
 #if PY_MAJOR_VERSION < 3
index 7a5f03764702bfb56b470e5eb7a6958d2a0ec387..098080287c687697768e4fb27fb2ced4fe1e38a8 100644 (file)
@@ -595,6 +595,7 @@ static void perf_event__mmap2_swap(union perf_event *event,
        event->mmap2.maj   = bswap_32(event->mmap2.maj);
        event->mmap2.min   = bswap_32(event->mmap2.min);
        event->mmap2.ino   = bswap_64(event->mmap2.ino);
+       event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation);
 
        if (sample_id_all) {
                void *data = &event->mmap2.filename;
@@ -710,6 +711,18 @@ static void perf_event__namespaces_swap(union perf_event *event,
                swap_sample_id_all(event, &event->namespaces.link_info[i]);
 }
 
+static void perf_event__cgroup_swap(union perf_event *event, bool sample_id_all)
+{
+       event->cgroup.id = bswap_64(event->cgroup.id);
+
+       if (sample_id_all) {
+               void *data = &event->cgroup.path;
+
+               data += PERF_ALIGN(strlen(data) + 1, sizeof(u64));
+               swap_sample_id_all(event, data);
+       }
+}
+
 static u8 revbyte(u8 b)
 {
        int rev = (b >> 4) | ((b & 0xf) << 4);
@@ -952,6 +965,7 @@ static perf_event__swap_op perf_event__swap_ops[] = {
        [PERF_RECORD_SWITCH]              = perf_event__switch_swap,
        [PERF_RECORD_SWITCH_CPU_WIDE]     = perf_event__switch_swap,
        [PERF_RECORD_NAMESPACES]          = perf_event__namespaces_swap,
+       [PERF_RECORD_CGROUP]              = perf_event__cgroup_swap,
        [PERF_RECORD_TEXT_POKE]           = perf_event__text_poke_swap,
        [PERF_RECORD_HEADER_ATTR]         = perf_event__hdr_attr_swap,
        [PERF_RECORD_HEADER_EVENT_TYPE]   = perf_event__event_type_swap,
index 6138866665df0b105934c7e284e58139eceee19a..0d14abdf3d722f63031af608978891139d76e226 100644 (file)
@@ -515,6 +515,13 @@ void dso__insert_symbol(struct dso *dso, struct symbol *sym)
        }
 }
 
+void dso__delete_symbol(struct dso *dso, struct symbol *sym)
+{
+       rb_erase_cached(&sym->rb_node, &dso->symbols);
+       symbol__delete(sym);
+       dso__reset_find_symbol_cache(dso);
+}
+
 struct symbol *dso__find_symbol(struct dso *dso, u64 addr)
 {
        if (dso->last_find_result.addr != addr || dso->last_find_result.symbol == NULL) {
index f4801c488def850ba2da730925a494312f18795e..954d6a049ee2386fba1b648065e01117d6284b3c 100644 (file)
@@ -131,6 +131,8 @@ int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map);
 
 void dso__insert_symbol(struct dso *dso,
                        struct symbol *sym);
+void dso__delete_symbol(struct dso *dso,
+                       struct symbol *sym);
 
 struct symbol *dso__find_symbol(struct dso *dso, u64 addr);
 struct symbol *dso__find_symbol_by_name(struct dso *dso, const char *name);
index 8019e3dd4c32f13e5e0f157fad059bef804d9499..84a1af2581f58c9ff82c036cd5098970f250884a 100644 (file)
@@ -66,7 +66,6 @@ def isolate_kunit_output(kernel_output):
 def raw_output(kernel_output):
        for line in kernel_output:
                print(line)
-               yield line
 
 DIVIDER = '=' * 60
 
@@ -242,7 +241,7 @@ def parse_test_suite(lines: List[str], expected_suite_index: int) -> TestSuite:
                return None
        test_suite.name = name
        expected_test_case_num = parse_subtest_plan(lines)
-       if not expected_test_case_num:
+       if expected_test_case_num is None:
                return None
        while expected_test_case_num > 0:
                test_case = parse_test_case(lines)
index 99c3c5671ea48a8a09d300f11db8218afad9dee7..0b60855fb8198b0183349e8c87d81d697d9c5845 100755 (executable)
@@ -179,7 +179,7 @@ class KUnitParserTest(unittest.TestCase):
                print_mock = mock.patch('builtins.print').start()
                result = kunit_parser.parse_run_tests(
                        kunit_parser.isolate_kunit_output(file.readlines()))
-               print_mock.assert_any_call(StrContains("no kunit output detected"))
+               print_mock.assert_any_call(StrContains('no tests run!'))
                print_mock.stop()
                file.close()
 
@@ -198,39 +198,57 @@ class KUnitParserTest(unittest.TestCase):
                        'test_data/test_config_printk_time.log')
                with open(prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_ignores_multiple_prefixes(self):
                prefix_log = get_absolute_path(
                        'test_data/test_multiple_prefixes.log')
                with open(prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_prefix_mixed_kernel_output(self):
                mixed_prefix_log = get_absolute_path(
                        'test_data/test_interrupted_tap_output.log')
                with open(mixed_prefix_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_prefix_poundsign(self):
                pound_log = get_absolute_path('test_data/test_pound_sign.log')
                with open(pound_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_kernel_panic_end(self):
                panic_log = get_absolute_path('test_data/test_kernel_panic_interrupt.log')
                with open(panic_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.TEST_CRASHED,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
        def test_pound_no_prefix(self):
                pound_log = get_absolute_path('test_data/test_pound_no_prefix.log')
                with open(pound_log) as file:
                        result = kunit_parser.parse_run_tests(file.readlines())
-               self.assertEqual('kunit-resource-test', result.suites[0].name)
+                       self.assertEqual(
+                               kunit_parser.TestStatus.SUCCESS,
+                               result.status)
+                       self.assertEqual('kunit-resource-test', result.suites[0].name)
 
 class KUnitJsonTest(unittest.TestCase):
 
index c02ca773946d641291e27d44d73174cc16a17d9d..6bdb57f76eacef0396e68942cb3fa983b6992bab 100644 (file)
@@ -1,6 +1,7 @@
 [    0.060000] printk: console [mc-1] enabled
 [    0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
 [    0.060000] TAP version 14
+[    0.060000] 1..3
 [    0.060000]         # Subtest: kunit-resource-test
 [    0.060000]         1..5
 [    0.060000]         ok 1 - kunit_resource_test_init_resources
@@ -28,4 +29,4 @@
 [    0.060000] Stack:
 [    0.060000]  602086f8 601bc260 705c0000 705c0000
 [    0.060000]  602086f8 6005fcec 705c0000 6002c6ab
-[    0.060000]  6005fcec 601bc260 705c0000 3000000010
\ No newline at end of file
+[    0.060000]  6005fcec 601bc260 705c0000 3000000010
index 5c73fb3a1c6fd13a9b163a48d02eb33b0315a375..1fb677728abeb0fe6aa5edb3a0387c05906b9815 100644 (file)
@@ -1,6 +1,7 @@
 [    0.060000] printk: console [mc-1] enabled
 [    0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
 [    0.060000] TAP version 14
+[    0.060000] 1..3
 [    0.060000]         # Subtest: kunit-resource-test
 [    0.060000]         1..5
 [    0.060000]         ok 1 - kunit_resource_test_init_resources
@@ -34,4 +35,4 @@
 [    0.060000] Stack:
 [    0.060000]  602086f8 601bc260 705c0000 705c0000
 [    0.060000]  602086f8 6005fcec 705c0000 6002c6ab
-[    0.060000]  6005fcec 601bc260 705c0000 3000000010
\ No newline at end of file
+[    0.060000]  6005fcec 601bc260 705c0000 3000000010
index c045eee75f27fefaabf3ba073d9e282721c19a67..a014ffe9725e3c4e81697f742cee2652a41b2108 100644 (file)
@@ -1,6 +1,7 @@
 [    0.060000] printk: console [mc-1] enabled
 [    0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
 [    0.060000] TAP version 14
+[    0.060000] 1..3
 [    0.060000]         # Subtest: kunit-resource-test
 [    0.060000]         1..5
 [    0.060000]         ok 1 - kunit_resource_test_init_resources
@@ -22,4 +23,4 @@
 [    0.060000] Stack:
 [    0.060000]  602086f8 601bc260 705c0000 705c0000
 [    0.060000]  602086f8 6005fcec 705c0000 6002c6ab
-[    0.060000]  6005fcec 601bc260 705c0000 3000000010
\ No newline at end of file
+[    0.060000]  6005fcec 601bc260 705c0000 3000000010
index bc48407dcc36c44665c7d2ac620e42e7caf98481..0ad78481a0b450bf463ca7aaab0ae739d4e43018 100644 (file)
@@ -1,6 +1,7 @@
 [    0.060000][    T1] printk: console [mc-1] enabled
 [    0.060000][    T1] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
 [    0.060000][    T1] TAP version 14
+[    0.060000][    T1] 1..3
 [    0.060000][    T1]         # Subtest: kunit-resource-test
 [    0.060000][    T1]         1..5
 [    0.060000][    T1]         ok 1 - kunit_resource_test_init_resources
@@ -28,4 +29,4 @@
 [    0.060000][    T1] Stack:
 [    0.060000][    T1]  602086f8 601bc260 705c0000 705c0000
 [    0.060000][    T1]  602086f8 6005fcec 705c0000 6002c6ab
-[    0.060000][    T1]  6005fcec 601bc260 705c0000 3000000010
\ No newline at end of file
+[    0.060000][    T1]  6005fcec 601bc260 705c0000 3000000010
index 2ceb360be7d52cbee4b0a5a426456605ded7466e..dc4cf09a96d077bbc0b5fbcb312251742e390379 100644 (file)
@@ -1,6 +1,7 @@
  printk: console [mc-1] enabled
  random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
  TAP version 14
+ 1..3
        # Subtest: kunit-resource-test
        1..5
        ok 1 - kunit_resource_test_init_resources
@@ -30,4 +31,4 @@
  Stack:
   602086f8 601bc260 705c0000 705c0000
   602086f8 6005fcec 705c0000 6002c6ab
-  6005fcec 601bc260 705c0000 3000000010
\ No newline at end of file
+  6005fcec 601bc260 705c0000 3000000010
index 28ffa5ba03bfa81ea02ea9d38e7de7acf3dd9e5d..3f358e3a7ba0d118c1dc15e5f637fb8ffb5aa388 100644 (file)
@@ -1,6 +1,7 @@
 [    0.060000] printk: console [mc-1] enabled
 [    0.060000] random: get_random_bytes called from init_oops_id+0x35/0x40 with crng_init=0
 [    0.060000] TAP version 14
+[    0.060000] 1..3
 [    0.060000]         # Subtest: kunit-resource-test
 [    0.060000]         1..5
 [    0.060000]         ok 1 - kunit_resource_test_init_resources
index 55bd387ce7ec6ae45b2999652d7d7fbe13d56c5c..52d3f0364bdaa1b1ecf744247de63c77f3c2079f 100644 (file)
@@ -145,7 +145,7 @@ TEST(clone3_cap_checkpoint_restore)
        test_clone3_supported();
 
        EXPECT_EQ(getuid(), 0)
-               XFAIL(return, "Skipping all tests as non-root\n");
+               SKIP(return, "Skipping all tests as non-root");
 
        memset(&set_tid, 0, sizeof(set_tid));
 
index c99b98b0d461fb6e49aa07b14fa798061694bb75..575b391ddc78d31bcfc424e40c5a540428d98e09 100644 (file)
@@ -44,7 +44,7 @@ TEST(close_range)
                fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
                ASSERT_GE(fd, 0) {
                        if (errno == ENOENT)
-                               XFAIL(return, "Skipping test since /dev/null does not exist");
+                               SKIP(return, "Skipping test since /dev/null does not exist");
                }
 
                open_fds[i] = fd;
@@ -52,7 +52,7 @@ TEST(close_range)
 
        EXPECT_EQ(-1, sys_close_range(open_fds[0], open_fds[100], -1)) {
                if (errno == ENOSYS)
-                       XFAIL(return, "close_range() syscall not supported");
+                       SKIP(return, "close_range() syscall not supported");
        }
 
        EXPECT_EQ(0, sys_close_range(open_fds[0], open_fds[50], 0));
@@ -108,7 +108,7 @@ TEST(close_range_unshare)
                fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
                ASSERT_GE(fd, 0) {
                        if (errno == ENOENT)
-                               XFAIL(return, "Skipping test since /dev/null does not exist");
+                               SKIP(return, "Skipping test since /dev/null does not exist");
                }
 
                open_fds[i] = fd;
@@ -197,7 +197,7 @@ TEST(close_range_unshare_capped)
                fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
                ASSERT_GE(fd, 0) {
                        if (errno == ENOENT)
-                               XFAIL(return, "Skipping test since /dev/null does not exist");
+                               SKIP(return, "Skipping test since /dev/null does not exist");
                }
 
                open_fds[i] = fd;
index 1d27f52c61e61a1b297082abb5d65848cd40a773..477cbb042f5badec5361ffa6abd1d739fd578edb 100644 (file)
@@ -74,7 +74,7 @@ static int __do_binderfs_test(struct __test_metadata *_metadata)
        ret = mount(NULL, binderfs_mntpt, "binder", 0, 0);
        EXPECT_EQ(ret, 0) {
                if (errno == ENODEV)
-                       XFAIL(goto out, "binderfs missing");
+                       SKIP(goto out, "binderfs missing");
                TH_LOG("%s - Failed to mount binderfs", strerror(errno));
                goto rmdir;
        }
@@ -475,10 +475,10 @@ TEST(binderfs_stress)
 TEST(binderfs_test_privileged)
 {
        if (geteuid() != 0)
-               XFAIL(return, "Tests are not run as root. Skipping privileged tests");
+               SKIP(return, "Tests are not run as root. Skipping privileged tests");
 
        if (__do_binderfs_test(_metadata))
-               XFAIL(return, "The Android binderfs filesystem is not available");
+               SKIP(return, "The Android binderfs filesystem is not available");
 }
 
 TEST(binderfs_test_unprivileged)
@@ -511,7 +511,7 @@ TEST(binderfs_test_unprivileged)
        ret = wait_for_pid(pid);
        if (ret) {
                if (ret == 2)
-                       XFAIL(return, "The Android binderfs filesystem is not available");
+                       SKIP(return, "The Android binderfs filesystem is not available");
                ASSERT_EQ(ret, 0) {
                        TH_LOG("wait_for_pid() failed");
                }
index d979ff14775ad87a3a3077c487c6ca08906261c6..8f82f99f7748aff7596f2d6a4de4e4ce9be98bde 100644 (file)
@@ -3282,4 +3282,99 @@ TEST(epoll60)
        close(ctx.epfd);
 }
 
+struct epoll61_ctx {
+       int epfd;
+       int evfd;
+};
+
+static void *epoll61_write_eventfd(void *ctx_)
+{
+       struct epoll61_ctx *ctx = ctx_;
+       int64_t l = 1;
+
+       usleep(10950);
+       write(ctx->evfd, &l, sizeof(l));
+       return NULL;
+}
+
+static void *epoll61_epoll_with_timeout(void *ctx_)
+{
+       struct epoll61_ctx *ctx = ctx_;
+       struct epoll_event events[1];
+       int n;
+
+       n = epoll_wait(ctx->epfd, events, 1, 11);
+       /*
+        * If epoll returned the eventfd, write on the eventfd to wake up the
+        * blocking poller.
+        */
+       if (n == 1) {
+               int64_t l = 1;
+
+               write(ctx->evfd, &l, sizeof(l));
+       }
+       return NULL;
+}
+
+static void *epoll61_blocking_epoll(void *ctx_)
+{
+       struct epoll61_ctx *ctx = ctx_;
+       struct epoll_event events[1];
+
+       epoll_wait(ctx->epfd, events, 1, -1);
+       return NULL;
+}
+
+TEST(epoll61)
+{
+       struct epoll61_ctx ctx;
+       struct epoll_event ev;
+       int i, r;
+
+       ctx.epfd = epoll_create1(0);
+       ASSERT_GE(ctx.epfd, 0);
+       ctx.evfd = eventfd(0, EFD_NONBLOCK);
+       ASSERT_GE(ctx.evfd, 0);
+
+       ev.events = EPOLLIN | EPOLLET | EPOLLERR | EPOLLHUP;
+       ev.data.ptr = NULL;
+       r = epoll_ctl(ctx.epfd, EPOLL_CTL_ADD, ctx.evfd, &ev);
+       ASSERT_EQ(r, 0);
+
+       /*
+        * We are testing a race.  Repeat the test case 1000 times to make it
+        * more likely to fail in case of a bug.
+        */
+       for (i = 0; i < 1000; i++) {
+               pthread_t threads[3];
+               int n;
+
+               /*
+                * Start 3 threads:
+                * Thread 1 sleeps for 10.9ms and writes to the evenfd.
+                * Thread 2 calls epoll with a timeout of 11ms.
+                * Thread 3 calls epoll with a timeout of -1.
+                *
+                * The eventfd write by Thread 1 should either wakeup Thread 2
+                * or Thread 3.  If it wakes up Thread 2, Thread 2 writes on the
+                * eventfd to wake up Thread 3.
+                *
+                * If no events are missed, all three threads should eventually
+                * be joinable.
+                */
+               ASSERT_EQ(pthread_create(&threads[0], NULL,
+                                        epoll61_write_eventfd, &ctx), 0);
+               ASSERT_EQ(pthread_create(&threads[1], NULL,
+                                        epoll61_epoll_with_timeout, &ctx), 0);
+               ASSERT_EQ(pthread_create(&threads[2], NULL,
+                                        epoll61_blocking_epoll, &ctx), 0);
+
+               for (n = 0; n < ARRAY_SIZE(threads); ++n)
+                       ASSERT_EQ(pthread_join(threads[n], NULL), 0);
+       }
+
+       close(ctx.epfd);
+       close(ctx.evfd);
+}
+
 TEST_HARNESS_MAIN
index 3bcd4c3624ee0303fe0ed6bff4ddd5f1fdfcc085..b4da41d126d583d9dc92a777ffc88406d6040bb5 100644 (file)
@@ -6,7 +6,7 @@
 echo 0 > events/enable
 echo > dynamic_events
 
-PLACE=kernel_clone
+PLACE=$FUNCTION_FORK
 
 echo "p:myevent1 $PLACE" >> dynamic_events
 echo "r:myevent2 $PLACE" >> dynamic_events
index 438961971b7e170a09fbfd25ed6ea0e69bc8fb00..3a0e2885fff5894bc80f96d210f13b17f56fe13e 100644 (file)
@@ -6,7 +6,7 @@
 echo 0 > events/enable
 echo > dynamic_events
 
-PLACE=kernel_clone
+PLACE=$FUNCTION_FORK
 
 setup_events() {
 echo "p:myevent1 $PLACE" >> dynamic_events
index a8603bd23e0d803da48786e3aae1f9687f65aced..d3e138e8377f53ac23c2731d996c3ed9d6fcc30e 100644 (file)
@@ -6,7 +6,7 @@
 echo 0 > events/enable
 echo > dynamic_events
 
-PLACE=kernel_clone
+PLACE=$FUNCTION_FORK
 
 setup_events() {
 echo "p:myevent1 $PLACE" >> dynamic_events
index acb17ce543d2e6fb617e0d71eb722ebb9edebc33..80541964b9270b0619c6b0689c90ee50cf77482b 100644 (file)
@@ -39,7 +39,7 @@ do_test() {
     disable_tracing
 
     echo do_execve* > set_ftrace_filter
-    echo *do_fork >> set_ftrace_filter
+    echo $FUNCTION_FORK >> set_ftrace_filter
 
     echo $PID > set_ftrace_notrace_pid
     echo function > current_tracer
index 9f0a9687c773a566818261dc2e273ce3ab90c77f..2f7211254529ba13b3225bec3c5c29e887e77812 100644 (file)
@@ -39,7 +39,7 @@ do_test() {
     disable_tracing
 
     echo do_execve* > set_ftrace_filter
-    echo *do_fork >> set_ftrace_filter
+    echo $FUNCTION_FORK >> set_ftrace_filter
 
     echo $PID > set_ftrace_pid
     echo function > current_tracer
index 98305d76bd04f7a17639b7a829c11f2d1759f805..191d116b788324188773c98a351e66d707d85cff 100644 (file)
@@ -4,9 +4,9 @@
 # requires: set_ftrace_filter
 # flags: instance
 
-echo kernel_clone:stacktrace >> set_ftrace_filter
+echo $FUNCTION_FORK:stacktrace >> set_ftrace_filter
 
-grep -q "kernel_clone:stacktrace:unlimited" set_ftrace_filter
+grep -q "$FUNCTION_FORK:stacktrace:unlimited" set_ftrace_filter
 
 (echo "forked"; sleep 1)
 
index c5dec55b7d95d266ad159477fc4692151da11766..a6fac927ee82f68703d1bb29c8d7c4cf3ef9c03f 100644 (file)
@@ -133,6 +133,13 @@ yield() {
     ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1
 }
 
+# The fork function in the kernel was renamed from "_do_fork" to
+# "kernel_fork". As older tests should still work with older kernels
+# as well as newer kernels, check which version of fork is used on this
+# kernel so that the tests can use the fork function for the running kernel.
+FUNCTION_FORK=`(if grep '\bkernel_clone\b' /proc/kallsyms > /dev/null; then
+                echo kernel_clone; else echo '_do_fork'; fi)`
+
 # Since probe event command may include backslash, explicitly use printf "%s"
 # to NOT interpret it.
 ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
index 9737cd0578a7fab07e29ff984b8ff526d19532e7..2428a3ed78c95d8e0e1559206bc9c66be1bb9bae 100644 (file)
@@ -3,7 +3,7 @@
 # description: Kprobe dynamic event - adding and removing
 # requires: kprobe_events
 
-echo p:myevent kernel_clone > kprobe_events
+echo p:myevent $FUNCTION_FORK > kprobe_events
 grep myevent kprobe_events
 test -d events/kprobes/myevent
 echo > kprobe_events
index f9a40af76888e37cd85ec849f29454377fcbf699..010a8b1d6c1d56c8cb9187d80391ec7bd5532bf7 100644 (file)
@@ -3,7 +3,7 @@
 # description: Kprobe dynamic event - busy event check
 # requires: kprobe_events
 
-echo p:myevent kernel_clone > kprobe_events
+echo p:myevent $FUNCTION_FORK > kprobe_events
 test -d events/kprobes/myevent
 echo 1 > events/kprobes/myevent/enable
 echo > kprobe_events && exit_fail # this must fail
index eb543d3cfe5f4c45c80c2b4148edb899c0b95fa2..a96a1dc7014fb5660bd8fffc5be5b373c0300d1d 100644 (file)
@@ -3,13 +3,13 @@
 # description: Kprobe dynamic event with arguments
 # requires: kprobe_events
 
-echo 'p:testprobe kernel_clone $stack $stack0 +0($stack)' > kprobe_events
+echo "p:testprobe $FUNCTION_FORK \$stack \$stack0 +0(\$stack)" > kprobe_events
 grep testprobe kprobe_events | grep -q 'arg1=\$stack arg2=\$stack0 arg3=+0(\$stack)'
 test -d events/kprobes/testprobe
 
 echo 1 > events/kprobes/testprobe/enable
 ( echo "forked")
-grep testprobe trace | grep 'kernel_clone' | \
+grep testprobe trace | grep "$FUNCTION_FORK" | \
   grep -q 'arg1=0x[[:xdigit:]]* arg2=0x[[:xdigit:]]* arg3=0x[[:xdigit:]]*$'
 
 echo 0 > events/kprobes/testprobe/enable
index 4e5b63be51c9484396f824523f3dd4525e2920a5..a053ee2e7d779e20ce645f0dda1e95f5b9315927 100644 (file)
@@ -5,7 +5,7 @@
 
 grep -A1 "fetcharg:" README | grep -q "\$comm" || exit_unsupported # this is too old
 
-echo 'p:testprobe kernel_clone comm=$comm ' > kprobe_events
+echo "p:testprobe $FUNCTION_FORK comm=\$comm " > kprobe_events
 grep testprobe kprobe_events | grep -q 'comm=$comm'
 test -d events/kprobes/testprobe
 
index a1d70588ab2166aba2f752aab0119b4eaee68217..84285a6f60b079346a5c527ea99a5d400c678c0a 100644 (file)
@@ -30,13 +30,13 @@ esac
 : "Test get argument (1)"
 echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events
 echo 1 > events/kprobes/testprobe/enable
-echo "p:test kernel_clone" >> kprobe_events
+echo "p:test $FUNCTION_FORK" >> kprobe_events
 grep -qe "testprobe.* arg1=\"test\"" trace
 
 echo 0 > events/kprobes/testprobe/enable
 : "Test get argument (2)"
 echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events
 echo 1 > events/kprobes/testprobe/enable
-echo "p:test kernel_clone" >> kprobe_events
+echo "p:test $FUNCTION_FORK" >> kprobe_events
 grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace
 
index bd25dd0ba0d0c984a79918ba1795608dc03b71f9..717130ed4feb28e0c34ebbd357aa8fca86f5f921 100644 (file)
@@ -14,12 +14,12 @@ elif ! grep "$SYMBOL\$" /proc/kallsyms; then
 fi
 
 : "Test get basic types symbol argument"
-echo "p:testprobe_u kernel_clone arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events
-echo "p:testprobe_s kernel_clone arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events
+echo "p:testprobe_u $FUNCTION_FORK arg1=@linux_proc_banner:u64 arg2=@linux_proc_banner:u32 arg3=@linux_proc_banner:u16 arg4=@linux_proc_banner:u8" > kprobe_events
+echo "p:testprobe_s $FUNCTION_FORK arg1=@linux_proc_banner:s64 arg2=@linux_proc_banner:s32 arg3=@linux_proc_banner:s16 arg4=@linux_proc_banner:s8" >> kprobe_events
 if grep -q "x8/16/32/64" README; then
-  echo "p:testprobe_x kernel_clone arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events
+  echo "p:testprobe_x $FUNCTION_FORK arg1=@linux_proc_banner:x64 arg2=@linux_proc_banner:x32 arg3=@linux_proc_banner:x16 arg4=@linux_proc_banner:x8" >> kprobe_events
 fi
-echo "p:testprobe_bf kernel_clone arg1=@linux_proc_banner:b8@4/32" >> kprobe_events
+echo "p:testprobe_bf $FUNCTION_FORK arg1=@linux_proc_banner:b8@4/32" >> kprobe_events
 echo 1 > events/kprobes/enable
 (echo "forked")
 echo 0 > events/kprobes/enable
@@ -27,7 +27,7 @@ grep "testprobe_[usx]:.* arg1=.* arg2=.* arg3=.* arg4=.*" trace
 grep "testprobe_bf:.* arg1=.*" trace
 
 : "Test get string symbol argument"
-echo "p:testprobe_str kernel_clone arg1=@linux_proc_banner:string" > kprobe_events
+echo "p:testprobe_str $FUNCTION_FORK arg1=@linux_proc_banner:string" > kprobe_events
 echo 1 > events/kprobes/enable
 (echo "forked")
 echo 0 > events/kprobes/enable
index 91fcce1c241cc7f9ec546961bfc901809d627b6f..25b7708eb55946a890e0020ba65deb668795a0c0 100644 (file)
@@ -4,7 +4,7 @@
 # requires: kprobe_events "x8/16/32/64":README
 
 gen_event() { # Bitsize
-  echo "p:testprobe kernel_clone \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
+  echo "p:testprobe $FUNCTION_FORK \$stack0:s$1 \$stack0:u$1 \$stack0:x$1 \$stack0:b4@4/$1"
 }
 
 check_types() { # s-type u-type x-type bf-type width
index a30a9c07290d0f8efef694199f2a3f7849c7a36f..d25d01a19778127b74858db84c3a330ae40897b9 100644 (file)
@@ -9,12 +9,16 @@ grep -A10 "fetcharg:" README | grep -q '\[u\]<offset>' || exit_unsupported
 :;: "user-memory access syntax and ustring working on user memory";:
 echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \
        > kprobe_events
+echo 'p:myevent2 do_sys_openat2 path=+0($arg2):ustring path2=+u0($arg2):string' \
+       >> kprobe_events
 
 grep myevent kprobe_events | \
        grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string'
 echo 1 > events/kprobes/myevent/enable
+echo 1 > events/kprobes/myevent2/enable
 echo > /dev/null
 echo 0 > events/kprobes/myevent/enable
+echo 0 > events/kprobes/myevent2/enable
 
 grep myevent trace | grep -q 'path="/dev/null" path2="/dev/null"'
 
index 0d179094191f5e71a4d859acdff195704cc2e4a5..5556292601a48186087d5d7e834396de7b0aff78 100644 (file)
@@ -5,29 +5,29 @@
 
 # prepare
 echo nop > current_tracer
-echo kernel_clone > set_ftrace_filter
-echo 'p:testprobe kernel_clone' > kprobe_events
+echo $FUNCTION_FORK > set_ftrace_filter
+echo "p:testprobe $FUNCTION_FORK" > kprobe_events
 
 # kprobe on / ftrace off
 echo 1 > events/kprobes/testprobe/enable
 echo > trace
 ( echo "forked")
 grep testprobe trace
-! grep 'kernel_clone <-' trace
+! grep "$FUNCTION_FORK <-" trace
 
 # kprobe on / ftrace on
 echo function > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-grep 'kernel_clone <-' trace
+grep "$FUNCTION_FORK <-" trace
 
 # kprobe off / ftrace on
 echo 0 > events/kprobes/testprobe/enable
 echo > trace
 ( echo "forked")
 ! grep testprobe trace
-grep 'kernel_clone <-' trace
+grep "$FUNCTION_FORK <-" trace
 
 # kprobe on / ftrace on
 echo 1 > events/kprobes/testprobe/enable
@@ -35,11 +35,11 @@ echo function > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-grep 'kernel_clone <-' trace
+grep "$FUNCTION_FORK <-" trace
 
 # kprobe on / ftrace off
 echo nop > current_tracer
 echo > trace
 ( echo "forked")
 grep testprobe trace
-! grep 'kernel_clone <-' trace
+! grep "$FUNCTION_FORK <-" trace
index 45d90b6c763d822491e843835f55658fb87904f4..f0d5b7777ed76bb9df973919943fdaa7b6e5555f 100644 (file)
@@ -4,7 +4,7 @@
 # requires: kprobe_events "Create/append/":README
 
 # Choose 2 symbols for target
-SYM1=kernel_clone
+SYM1=$FUNCTION_FORK
 SYM2=do_exit
 EVENT_NAME=kprobes/testevent
 
index 1b5550ef8a9b9146549f624ddf177d6916b4b881..fa928b431555ca1b21d43231233cf2c304d3aef6 100644 (file)
@@ -86,15 +86,15 @@ esac
 
 # multiprobe errors
 if grep -q "Create/append/" README && grep -q "imm-value" README; then
-echo 'p:kprobes/testevent kernel_clone' > kprobe_events
+echo "p:kprobes/testevent $FUNCTION_FORK" > kprobe_events
 check_error '^r:kprobes/testevent do_exit'     # DIFF_PROBE_TYPE
 
 # Explicitly use printf "%s" to not interpret \1
-printf "%s" 'p:kprobes/testevent kernel_clone abcd=\1' > kprobe_events
-check_error 'p:kprobes/testevent kernel_clone ^bcd=\1' # DIFF_ARG_TYPE
-check_error 'p:kprobes/testevent kernel_clone ^abcd=\1:u8'     # DIFF_ARG_TYPE
-check_error 'p:kprobes/testevent kernel_clone ^abcd=\"foo"'    # DIFF_ARG_TYPE
-check_error '^p:kprobes/testevent kernel_clone abcd=\1'        # SAME_PROBE
+printf "%s" "p:kprobes/testevent $FUNCTION_FORK abcd=\\1" > kprobe_events
+check_error "p:kprobes/testevent $FUNCTION_FORK ^bcd=\\1"      # DIFF_ARG_TYPE
+check_error "p:kprobes/testevent $FUNCTION_FORK ^abcd=\\1:u8"  # DIFF_ARG_TYPE
+check_error "p:kprobes/testevent $FUNCTION_FORK ^abcd=\\\"foo\"" # DIFF_ARG_TYPE
+check_error "^p:kprobes/testevent $FUNCTION_FORK abcd=\\1"     # SAME_PROBE
 fi
 
 # %return suffix errors
index 7ae492c204a43595f72eb6568bef699179a8ea95..197cc2afd4046b3c48fe9321aeac9d508e0079b6 100644 (file)
@@ -4,14 +4,14 @@
 # requires: kprobe_events
 
 # Add new kretprobe event
-echo 'r:testprobe2 kernel_clone $retval' > kprobe_events
+echo "r:testprobe2 $FUNCTION_FORK \$retval" > kprobe_events
 grep testprobe2 kprobe_events | grep -q 'arg1=\$retval'
 test -d events/kprobes/testprobe2
 
 echo 1 > events/kprobes/testprobe2/enable
 ( echo "forked")
 
-cat trace | grep testprobe2 | grep -q '<- kernel_clone'
+cat trace | grep testprobe2 | grep -q "<- $FUNCTION_FORK"
 
 echo 0 > events/kprobes/testprobe2/enable
 echo '-:testprobe2' >> kprobe_events
index c4093fc1a77336b228c70d64a31fe5e03263a6ea..98166fa3eb91ccbbef854d9ad8c5c5a605b594f9 100644 (file)
@@ -4,7 +4,7 @@
 # requires: kprobe_events
 
 ! grep -q 'myevent' kprobe_profile
-echo p:myevent kernel_clone > kprobe_events
+echo "p:myevent $FUNCTION_FORK" > kprobe_events
 grep -q 'myevent[[:space:]]*0[[:space:]]*0$' kprobe_profile
 echo 1 > events/kprobes/myevent/enable
 ( echo "forked" )
index f19804df244c08669ef5241c18fa27efd5a6f100..edce85420d1934e3892f5ffe1d5c6d06c0df593f 100644 (file)
        snprintf(_metadata->results->reason, \
                 sizeof(_metadata->results->reason), fmt, ##__VA_ARGS__); \
        if (TH_LOG_ENABLED) { \
-               fprintf(TH_LOG_STREAM, "#      SKIP     %s\n", \
+               fprintf(TH_LOG_STREAM, "#      SKIP      %s\n", \
                        _metadata->results->reason); \
        } \
        _metadata->passed = 1; \
  */
 
 /**
- * ASSERT_EQ(expected, seen)
+ * ASSERT_EQ()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, ==, 1)
 
 /**
- * ASSERT_NE(expected, seen)
+ * ASSERT_NE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, !=, 1)
 
 /**
- * ASSERT_LT(expected, seen)
+ * ASSERT_LT()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, <, 1)
 
 /**
- * ASSERT_LE(expected, seen)
+ * ASSERT_LE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, <=, 1)
 
 /**
- * ASSERT_GT(expected, seen)
+ * ASSERT_GT()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, >, 1)
 
 /**
- * ASSERT_GE(expected, seen)
+ * ASSERT_GE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, >=, 1)
 
 /**
- * ASSERT_NULL(seen)
+ * ASSERT_NULL()
  *
  * @seen: measured value
  *
        __EXPECT(NULL, "NULL", seen, #seen, ==, 1)
 
 /**
- * ASSERT_TRUE(seen)
+ * ASSERT_TRUE()
  *
  * @seen: measured value
  *
        __EXPECT(0, "0", seen, #seen, !=, 1)
 
 /**
- * ASSERT_FALSE(seen)
+ * ASSERT_FALSE()
  *
  * @seen: measured value
  *
        __EXPECT(0, "0", seen, #seen, ==, 1)
 
 /**
- * ASSERT_STREQ(expected, seen)
+ * ASSERT_STREQ()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT_STR(expected, seen, ==, 1)
 
 /**
- * ASSERT_STRNE(expected, seen)
+ * ASSERT_STRNE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT_STR(expected, seen, !=, 1)
 
 /**
- * EXPECT_EQ(expected, seen)
+ * EXPECT_EQ()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, ==, 0)
 
 /**
- * EXPECT_NE(expected, seen)
+ * EXPECT_NE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, !=, 0)
 
 /**
- * EXPECT_LT(expected, seen)
+ * EXPECT_LT()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, <, 0)
 
 /**
- * EXPECT_LE(expected, seen)
+ * EXPECT_LE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, <=, 0)
 
 /**
- * EXPECT_GT(expected, seen)
+ * EXPECT_GT()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, >, 0)
 
 /**
- * EXPECT_GE(expected, seen)
+ * EXPECT_GE()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT(expected, #expected, seen, #seen, >=, 0)
 
 /**
- * EXPECT_NULL(seen)
+ * EXPECT_NULL()
  *
  * @seen: measured value
  *
        __EXPECT(NULL, "NULL", seen, #seen, ==, 0)
 
 /**
- * EXPECT_TRUE(seen)
+ * EXPECT_TRUE()
  *
  * @seen: measured value
  *
        __EXPECT(0, "0", seen, #seen, !=, 0)
 
 /**
- * EXPECT_FALSE(seen)
+ * EXPECT_FALSE()
  *
  * @seen: measured value
  *
        __EXPECT(0, "0", seen, #seen, ==, 0)
 
 /**
- * EXPECT_STREQ(expected, seen)
+ * EXPECT_STREQ()
  *
  * @expected: expected value
  * @seen: measured value
        __EXPECT_STR(expected, seen, ==, 0)
 
 /**
- * EXPECT_STRNE(expected, seen)
+ * EXPECT_STRNE()
  *
  * @expected: expected value
  * @seen: measured value
index 307ceaadbbb993664047ca469f40bb67b5816cfc..d2c2d6205008cd1a1fb7efeb8ab009094ced2cf4 100644 (file)
@@ -15,6 +15,7 @@
 /x86_64/vmx_preemption_timer_test
 /x86_64/svm_vmcall_test
 /x86_64/sync_regs_test
+/x86_64/vmx_apic_access_test
 /x86_64/vmx_close_while_nested_test
 /x86_64/vmx_dirty_log_test
 /x86_64/vmx_set_nested_state_test
index 7ebe71fbca534b8720056308008cf18086da5096..30afbad36cd5516509beae779c03d7ab4c0bfd3c 100644 (file)
@@ -49,6 +49,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/state_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_preemption_timer_test
 TEST_GEN_PROGS_x86_64 += x86_64/svm_vmcall_test
 TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test
+TEST_GEN_PROGS_x86_64 += x86_64/vmx_apic_access_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_close_while_nested_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_dirty_log_test
 TEST_GEN_PROGS_x86_64 += x86_64/vmx_set_nested_state_test
index 54d624dd6c104410ea3ee33286829cc5300202a4..e78d7e26ba61187f240e8665beb8f3ab749f0770 100644 (file)
@@ -573,6 +573,10 @@ struct vmx_pages {
        void *eptp_hva;
        uint64_t eptp_gpa;
        void *eptp;
+
+       void *apic_access_hva;
+       uint64_t apic_access_gpa;
+       void *apic_access;
 };
 
 union vmx_basic {
@@ -615,5 +619,7 @@ void nested_map_memslot(struct vmx_pages *vmx, struct kvm_vm *vm,
                        uint32_t memslot, uint32_t eptp_memslot);
 void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm,
                  uint32_t eptp_memslot);
+void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm,
+                                     uint32_t eptp_memslot);
 
 #endif /* SELFTEST_KVM_VMX_H */
index 74776ee228f2d0d7d9421d7acb3adf4ab0cc95c9..3327cebc1095f9e393ad3a1cb56891bc82f6a87c 100644 (file)
@@ -14,6 +14,7 @@
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <unistd.h>
 #include <linux/kernel.h>
 
 #define KVM_UTIL_PGS_PER_HUGEPG 512
@@ -664,13 +665,21 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
 
        /* As needed perform madvise */
        if (src_type == VM_MEM_SRC_ANONYMOUS || src_type == VM_MEM_SRC_ANONYMOUS_THP) {
-               ret = madvise(region->host_mem, npages * vm->page_size,
-                            src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : MADV_HUGEPAGE);
-               TEST_ASSERT(ret == 0, "madvise failed,\n"
-                           "  addr: %p\n"
-                           "  length: 0x%lx\n"
-                           "  src_type: %x",
-                           region->host_mem, npages * vm->page_size, src_type);
+               struct stat statbuf;
+
+               ret = stat("/sys/kernel/mm/transparent_hugepage", &statbuf);
+               TEST_ASSERT(ret == 0 || (ret == -1 && errno == ENOENT),
+                           "stat /sys/kernel/mm/transparent_hugepage");
+
+               TEST_ASSERT(ret == 0 || src_type != VM_MEM_SRC_ANONYMOUS_THP,
+                           "VM_MEM_SRC_ANONYMOUS_THP requires THP to be configured in the host kernel");
+
+               if (ret == 0) {
+                       ret = madvise(region->host_mem, npages * vm->page_size,
+                                     src_type == VM_MEM_SRC_ANONYMOUS ? MADV_NOHUGEPAGE : MADV_HUGEPAGE);
+                       TEST_ASSERT(ret == 0, "madvise failed, addr: %p length: 0x%lx src_type: %x",
+                                   region->host_mem, npages * vm->page_size, src_type);
+               }
        }
 
        region->unused_phy_pages = sparsebit_alloc();
index f1e00d43eea2e0bc0a98c900d067958802346948..2448b30e8efae6f7e6c65d201a0bf408225ab535 100644 (file)
@@ -542,3 +542,12 @@ void prepare_eptp(struct vmx_pages *vmx, struct kvm_vm *vm,
        vmx->eptp_hva = addr_gva2hva(vm, (uintptr_t)vmx->eptp);
        vmx->eptp_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->eptp);
 }
+
+void prepare_virtualize_apic_accesses(struct vmx_pages *vmx, struct kvm_vm *vm,
+                                     uint32_t eptp_memslot)
+{
+       vmx->apic_access = (void *)vm_vaddr_alloc(vm, getpagesize(),
+                                                 0x10000, 0, 0);
+       vmx->apic_access_hva = addr_gva2hva(vm, (uintptr_t)vmx->apic_access);
+       vmx->apic_access_gpa = addr_gva2gpa(vm, (uintptr_t)vmx->apic_access);
+}
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c
new file mode 100644 (file)
index 0000000..1f65342
--- /dev/null
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * vmx_apic_access_test
+ *
+ * Copyright (C) 2020, Google LLC.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
+ *
+ * The first subtest simply checks to see that an L2 guest can be
+ * launched with a valid APIC-access address that is backed by a
+ * page of L1 physical memory.
+ *
+ * The second subtest sets the APIC-access address to a (valid) L1
+ * physical address that is not backed by memory. KVM can't handle
+ * this situation, so resuming L2 should result in a KVM exit for
+ * internal error (emulation). This is not an architectural
+ * requirement. It is just a shortcoming of KVM. The internal error
+ * is unfortunate, but it's better than what used to happen!
+ */
+
+#include "test_util.h"
+#include "kvm_util.h"
+#include "processor.h"
+#include "vmx.h"
+
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "kselftest.h"
+
+#define VCPU_ID                0
+
+/* The virtual machine object. */
+static struct kvm_vm *vm;
+
+static void l2_guest_code(void)
+{
+       /* Exit to L1 */
+       __asm__ __volatile__("vmcall");
+}
+
+static void l1_guest_code(struct vmx_pages *vmx_pages, unsigned long high_gpa)
+{
+#define L2_GUEST_STACK_SIZE 64
+       unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE];
+       uint32_t control;
+
+       GUEST_ASSERT(prepare_for_vmx_operation(vmx_pages));
+       GUEST_ASSERT(load_vmcs(vmx_pages));
+
+       /* Prepare the VMCS for L2 execution. */
+       prepare_vmcs(vmx_pages, l2_guest_code,
+                    &l2_guest_stack[L2_GUEST_STACK_SIZE]);
+       control = vmreadz(CPU_BASED_VM_EXEC_CONTROL);
+       control |= CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
+       vmwrite(CPU_BASED_VM_EXEC_CONTROL, control);
+       control = vmreadz(SECONDARY_VM_EXEC_CONTROL);
+       control |= SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
+       vmwrite(SECONDARY_VM_EXEC_CONTROL, control);
+       vmwrite(APIC_ACCESS_ADDR, vmx_pages->apic_access_gpa);
+
+       /* Try to launch L2 with the memory-backed APIC-access address. */
+       GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
+       GUEST_ASSERT(!vmlaunch());
+       GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
+
+       vmwrite(APIC_ACCESS_ADDR, high_gpa);
+
+       /* Try to resume L2 with the unbacked APIC-access address. */
+       GUEST_SYNC(vmreadz(APIC_ACCESS_ADDR));
+       GUEST_ASSERT(!vmresume());
+       GUEST_ASSERT(vmreadz(VM_EXIT_REASON) == EXIT_REASON_VMCALL);
+
+       GUEST_DONE();
+}
+
+int main(int argc, char *argv[])
+{
+       unsigned long apic_access_addr = ~0ul;
+       unsigned int paddr_width;
+       unsigned int vaddr_width;
+       vm_vaddr_t vmx_pages_gva;
+       unsigned long high_gpa;
+       struct vmx_pages *vmx;
+       bool done = false;
+
+       nested_vmx_check_supported();
+
+       vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code);
+       vcpu_set_cpuid(vm, VCPU_ID, kvm_get_supported_cpuid());
+
+       kvm_get_cpu_address_width(&paddr_width, &vaddr_width);
+       high_gpa = (1ul << paddr_width) - getpagesize();
+       if ((unsigned long)DEFAULT_GUEST_PHY_PAGES * getpagesize() > high_gpa) {
+               print_skip("No unbacked physical page available");
+               exit(KSFT_SKIP);
+       }
+
+       vmx = vcpu_alloc_vmx(vm, &vmx_pages_gva);
+       prepare_virtualize_apic_accesses(vmx, vm, 0);
+       vcpu_args_set(vm, VCPU_ID, 2, vmx_pages_gva, high_gpa);
+
+       while (!done) {
+               volatile struct kvm_run *run = vcpu_state(vm, VCPU_ID);
+               struct ucall uc;
+
+               vcpu_run(vm, VCPU_ID);
+               if (apic_access_addr == high_gpa) {
+                       TEST_ASSERT(run->exit_reason ==
+                                   KVM_EXIT_INTERNAL_ERROR,
+                                   "Got exit reason other than KVM_EXIT_INTERNAL_ERROR: %u (%s)\n",
+                                   run->exit_reason,
+                                   exit_reason_str(run->exit_reason));
+                       TEST_ASSERT(run->internal.suberror ==
+                                   KVM_INTERNAL_ERROR_EMULATION,
+                                   "Got internal suberror other than KVM_INTERNAL_ERROR_EMULATION: %u\n",
+                                   run->internal.suberror);
+                       break;
+               }
+               TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
+                           "Got exit_reason other than KVM_EXIT_IO: %u (%s)\n",
+                           run->exit_reason,
+                           exit_reason_str(run->exit_reason));
+
+               switch (get_ucall(vm, VCPU_ID, &uc)) {
+               case UCALL_ABORT:
+                       TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
+                                 __FILE__, uc.args[1]);
+                       /* NOT REACHED */
+               case UCALL_SYNC:
+                       apic_access_addr = uc.args[1];
+                       break;
+               case UCALL_DONE:
+                       done = true;
+                       break;
+               default:
+                       TEST_ASSERT(false, "Unknown ucall %lu", uc.cmd);
+               }
+       }
+       kvm_vm_free(vm);
+       return 0;
+}
index 30848ca3655598a92e3729722f6d65d992b41cfd..a5ce26d548e4f37c67c9ea71f2eec470a7378c61 100644 (file)
@@ -136,7 +136,7 @@ endif
 ifeq ($(OVERRIDE_TARGETS),)
 LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
 $(OUTPUT)/%:%.c $(LOCAL_HDRS)
-       $(LINK.c) $^ $(LDLIBS) -o $@
+       $(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@
 
 $(OUTPUT)/%.o:%.S
        $(COMPILE.S) $^ -o $@
index bb11de90c0c9ed51a396a2cc127c7ea809e454c9..f6f2965e17af1f4518c840fb57a25f25bee06ca5 100644 (file)
@@ -4,3 +4,4 @@ CONFIG_USER_NS=y
 CONFIG_PID_NS=y
 CONFIG_NET_NS=y
 CONFIG_CGROUPS=y
+CONFIG_CHECKPOINT_RESTORE=y
index 7758c98be0158483ea6d40d2c37d0a5a1d4b3c6a..0930e2411dfb9a1337988e4cb815e14bfa4464b5 100644 (file)
@@ -204,7 +204,10 @@ TEST_F(child, fetch_fd)
        fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0);
        ASSERT_GE(fd, 0);
 
-       EXPECT_EQ(0, sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd));
+       ret = sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd);
+       if (ret < 0 && errno == ENOSYS)
+               SKIP(return, "kcmp() syscall not supported");
+       EXPECT_EQ(ret, 0);
 
        ret = fcntl(fd, F_GETFD);
        ASSERT_GE(ret, 0);
index b9fe75fc3e517b75d9a70c9ac3f1d60f492392a0..8a59438ccc78bf38e8a8f0b2407cf8af61fc9215 100644 (file)
@@ -6,7 +6,6 @@
 #include <inttypes.h>
 #include <limits.h>
 #include <linux/types.h>
-#include <linux/wait.h>
 #include <sched.h>
 #include <signal.h>
 #include <stdbool.h>
index 4b115444dfe901bb8696bb0059ab645120846219..6108112753573dc4b77e611f6bfcaddefe8c2670 100644 (file)
@@ -3,7 +3,6 @@
 #define _GNU_SOURCE
 #include <errno.h>
 #include <linux/types.h>
-#include <linux/wait.h>
 #include <poll.h>
 #include <signal.h>
 #include <stdbool.h>
index 1f085b922c6ec1ccfe3422870f3d497039c60d15..6e2f2cd400caa5a4be93bf0353282bba63d7b132 100644 (file)
@@ -16,7 +16,6 @@
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#include <linux/kcmp.h>
 
 #include "pidfd.h"
 #include "../clone3/clone3_selftests.h"
index c585aaa2acd8a8ac4a7b33e1391ea23f5dd31563..529eb700ac26a39833a4e2c4c25b4caeb57af272 100644 (file)
@@ -330,7 +330,7 @@ static int test_pidfd_send_signal_recycled_pid_fail(void)
                ksft_exit_fail_msg("%s test: Failed to recycle pid %d\n",
                                   test_name, PID_RECYCLE);
        case PIDFD_SKIP:
-               ksft_print_msg("%s test: Skipping test\n", test_name);
+               ksft_test_result_skip("%s test: Skipping test\n", test_name);
                ret = 0;
                break;
        case PIDFD_XFAIL:
index 471e2aa280776fce48921d8ecda7e92d5f5e876e..fb4fe9188806e41ee4e401e9d46d36c5cc996af7 100644 (file)
@@ -14,7 +14,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 /* Test that /proc/loadavg correctly reports last pid in pid namespace. */
-#define _GNU_SOURCE
 #include <errno.h>
 #include <sched.h>
 #include <sys/types.h>
index 9f6d000c02455135d713709f54268ea10bf64900..8511dcfe67c755719ecf9f58da6dfe7910b904cd 100644 (file)
@@ -13,7 +13,6 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
-#define _GNU_SOURCE
 #include <unistd.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
index 30e2b78490898351a97e507018a0298e8a40e664..e7ceabed7f51f5c4588fa13653602b7340a173e5 100644 (file)
@@ -15,7 +15,6 @@
  */
 // Test that values in /proc/uptime increment monotonically
 // while shifting across CPUs.
-#define _GNU_SOURCE
 #undef NDEBUG
 #include <assert.h>
 #include <unistd.h>
index d77f4829f1e0702fa63f4019683101df9fac9e60..74c69b75f6f5ab944c6f055692b3684ca1a554d2 100755 (executable)
@@ -316,6 +316,14 @@ pp sleep 3
 n2 ping -W 1 -c 1 192.168.241.1
 n1 wg set wg0 peer "$pub2" persistent-keepalive 0
 
+# Test that sk_bound_dev_if works
+n1 ping -I wg0 -c 1 -W 1 192.168.241.2
+# What about when the mark changes and the packet must be rerouted?
+n1 iptables -t mangle -I OUTPUT -j MARK --set-xmark 1
+n1 ping -c 1 -W 1 192.168.241.2 # First the boring case
+n1 ping -I wg0 -c 1 -W 1 192.168.241.2 # Then the sk_bound_dev_if case
+n1 iptables -t mangle -D OUTPUT -j MARK --set-xmark 1
+
 # Test that onion routing works, even when it loops
 n1 wg set wg0 peer "$pub3" allowed-ips 192.168.242.2/32 endpoint 192.168.241.2:5
 ip1 addr add 192.168.242.1/24 dev wg0
index d531de13c95b06aba2f3596627673a0482bdbd09..4eecb432a66c1c2c2c40e01149088a884bfc8679 100644 (file)
@@ -18,10 +18,12 @@ CONFIG_NF_NAT=y
 CONFIG_NETFILTER_XTABLES=y
 CONFIG_NETFILTER_XT_NAT=y
 CONFIG_NETFILTER_XT_MATCH_LENGTH=y
+CONFIG_NETFILTER_XT_MARK=y
 CONFIG_NF_CONNTRACK_IPV4=y
 CONFIG_NF_NAT_IPV4=y
 CONFIG_IP_NF_IPTABLES=y
 CONFIG_IP_NF_FILTER=y
+CONFIG_IP_NF_MANGLE=y
 CONFIG_IP_NF_NAT=y
 CONFIG_IP_ADVANCED_ROUTER=y
 CONFIG_IP_MULTIPLE_TABLES=y