Merge tag 'soundwire-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 20:59:55 +0000 (22:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 20:59:55 +0000 (22:59 +0200)
Vinod writes:

soundwire updates for 5.10-rc1

This round of update includes:
 - Generic bandwidth allocation algorithm from Intel folks
 - PM support for Intel chipsets
 - Updates to Intel drivers which makes sdw usable on latest laptops
 - Support for MMIO SDW controllers found in QC chipsets
 - Update to subsystem to use helpers in bitfield.h to manage register
   bits

* tag 'soundwire-5.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: (66 commits)
  soundwire: sysfs: add slave status and device number before probe
  soundwire: bus: add enumerated Slave device to device list
  soundwire: remove an unnecessary NULL check
  soundwire: cadence: add data port test fail interrupt
  soundwire: intel: enable test modes
  soundwire: enable Data Port test modes
  soundwire: intel: use {u32|u16}p_replace_bits
  soundwire: cadence: use u32p_replace_bits
  soundwire: qcom: get max rows and cols info from compatible
  soundwire: qcom: add support to block packing mode
  soundwire: qcom: clear BIT FIELDs before value set.
  soundwire: Add generic bandwidth allocation algorithm
  soundwire: cadence: add parity error injection through debugfs
  soundwire: bus: export broadcast read/write capability for tests
  ASoC: codecs: realtek-soundwire: ignore initial PARITY errors
  soundwire: bus: use quirk to filter out invalid parity errors
  soundwire: slave: add first_interrupt_done status
  soundwire: bus: filter-out unwanted interrupt reports
  ASoC/soundwire: bus: use property to set interrupt masks
  soundwire: qcom: fix SLIBMUS/SLIMBUS typo
  ...

2374 files changed:
.clang-format
.mailmap
Documentation/ABI/testing/sysfs-bus-dfl [new file with mode: 0644]
Documentation/ABI/testing/sysfs-bus-event_source-devices-hv_24x7
Documentation/ABI/testing/sysfs-bus-fsi
Documentation/ABI/testing/sysfs-bus-mei
Documentation/ABI/testing/sysfs-driver-habanalabs
Documentation/RCU/lockdep.rst
Documentation/admin-guide/devices.txt
Documentation/admin-guide/dynamic-debug-howto.rst
Documentation/admin-guide/ext4.rst
Documentation/admin-guide/kernel-parameters.txt
Documentation/admin-guide/laptops/thinkpad-acpi.rst
Documentation/admin-guide/pm/intel_pstate.rst
Documentation/bpf/index.rst
Documentation/devicetree/bindings/clock/imx23-clock.yaml
Documentation/devicetree/bindings/clock/imx28-clock.yaml
Documentation/devicetree/bindings/fsi/fsi-master-aspeed.txt
Documentation/devicetree/bindings/gpio/gpio-mxs.yaml
Documentation/devicetree/bindings/i2c/i2c-mxs.yaml
Documentation/devicetree/bindings/interconnect/interconnect.txt
Documentation/devicetree/bindings/interconnect/qcom,bcm-voter.yaml
Documentation/devicetree/bindings/interconnect/qcom,osm-l3.yaml
Documentation/devicetree/bindings/interconnect/qcom,rpmh.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/interconnect/qcom,sc7180.yaml [deleted file]
Documentation/devicetree/bindings/interconnect/qcom,sdm845.yaml [deleted file]
Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.txt [deleted file]
Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.txt [deleted file]
Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/mmc/arasan,sdhci.yaml
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
Documentation/devicetree/bindings/mmc/mtk-sd.txt
Documentation/devicetree/bindings/mmc/mxs-mmc.yaml
Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
Documentation/devicetree/bindings/net/dsa/dsa.txt
Documentation/devicetree/bindings/net/ethernet-controller.yaml
Documentation/devicetree/bindings/net/renesas,ether.yaml
Documentation/devicetree/bindings/pci/intel-gw-pcie.yaml
Documentation/devicetree/bindings/pwm/mxs-pwm.yaml
Documentation/devicetree/bindings/spi/brcm,spi-bcm-qspi.txt
Documentation/devicetree/bindings/spi/fsl-imx-cspi.yaml
Documentation/devicetree/bindings/spi/spi-fsl-lpspi.yaml
Documentation/devicetree/bindings/thermal/imx-thermal.yaml
Documentation/devicetree/bindings/timer/sifive,clint.yaml [new file with mode: 0644]
Documentation/devicetree/bindings/vendor-prefixes.yaml
Documentation/devicetree/writing-schema.rst
Documentation/driver-api/dma-buf.rst
Documentation/driver-api/fpga/fpga-bridge.rst
Documentation/driver-api/fpga/fpga-mgr.rst
Documentation/driver-api/fpga/fpga-programming.rst
Documentation/driver-api/fpga/fpga-region.rst
Documentation/driver-api/iio/core.rst
Documentation/driver-api/mei/mei.rst
Documentation/fault-injection/nvme-fault-injection.rst
Documentation/filesystems/affs.rst
Documentation/filesystems/ext4/about.rst
Documentation/hwmon/abituguru-datasheet.rst
Documentation/hwmon/abituguru.rst
Documentation/hwmon/abituguru3.rst
Documentation/kbuild/llvm.rst
Documentation/kbuild/makefiles.rst
Documentation/locking/locktypes.rst
Documentation/maintainer/maintainer-entry-profile.rst
Documentation/networking/bonding.rst
Documentation/networking/dsa/configuration.rst
Documentation/powerpc/syscall64-abi.rst
Documentation/process/deprecated.rst
Documentation/sound/cards/audigy-mixer.rst
Documentation/sound/cards/sb-live-mixer.rst
Documentation/sound/designs/timestamping.rst
Documentation/translations/it_IT/process/deprecated.rst
Documentation/userspace-api/ioctl/ioctl-number.rst
Documentation/virt/index.rst
Documentation/virt/kvm/api.rst
Documentation/virt/ne_overview.rst [new file with mode: 0644]
MAINTAINERS
Makefile
arch/alpha/kernel/module.c
arch/alpha/kernel/signal.c
arch/alpha/kernel/traps.c
arch/arc/boot/dts/hsdk.dts
arch/arc/include/asm/pgalloc.h
arch/arc/kernel/disasm.c
arch/arc/kernel/perf_event.c
arch/arc/kernel/signal.c
arch/arc/kernel/troubleshoot.c
arch/arc/kernel/unwind.c
arch/arc/mm/init.c
arch/arc/plat-eznps/include/plat/ctop.h
arch/arm/boot/dts/bcm-hr2.dtsi
arch/arm/boot/dts/bcm-nsp.dtsi
arch/arm/boot/dts/bcm5301x.dtsi
arch/arm/boot/dts/imx6q-logicpd.dts
arch/arm/boot/dts/imx6q-prtwd2.dts
arch/arm/boot/dts/imx6qdl-gw51xx.dtsi
arch/arm/boot/dts/imx6sx-pinfunc.h
arch/arm/boot/dts/imx7d-zii-rmu2.dts
arch/arm/boot/dts/imx7ulp.dtsi
arch/arm/boot/dts/logicpd-som-lv-baseboard.dtsi
arch/arm/boot/dts/logicpd-torpedo-baseboard.dtsi
arch/arm/boot/dts/ls1021a.dtsi
arch/arm/boot/dts/omap5.dtsi
arch/arm/boot/dts/socfpga_arria10.dtsi
arch/arm/boot/dts/vfxxx.dtsi
arch/arm/configs/integrator_defconfig
arch/arm/kernel/hw_breakpoint.c
arch/arm/kernel/signal.c
arch/arm/mach-ep93xx/crunch.c
arch/arm/mach-mmp/pm-mmp2.c
arch/arm/mach-mmp/pm-pxa910.c
arch/arm/mach-omap2/id.c
arch/arm/mach-omap2/omap-iommu.c
arch/arm/mach-omap2/omap_device.c
arch/arm/mach-omap2/pm34xx.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-rpc/riscpc.c
arch/arm/mach-tegra/reset.c
arch/arm/mm/alignment.c
arch/arm/mm/proc-v7-bugs.c
arch/arm/plat-omap/dma.c
arch/arm/probes/decode.c
arch/arm/probes/kprobes/core.c
arch/arm64/Makefile
arch/arm64/boot/dts/broadcom/northstar2/ns2.dtsi
arch/arm64/boot/dts/freescale/Makefile
arch/arm64/boot/dts/freescale/imx8mp.dtsi
arch/arm64/boot/dts/freescale/imx8mq.dtsi
arch/arm64/boot/dts/mediatek/mt7622.dtsi
arch/arm64/boot/dts/nvidia/tegra186.dtsi
arch/arm64/boot/dts/nvidia/tegra194.dtsi
arch/arm64/boot/dts/nvidia/tegra210.dtsi
arch/arm64/boot/dts/ti/k3-am65-main.dtsi
arch/arm64/boot/dts/ti/k3-am65-mcu.dtsi
arch/arm64/boot/dts/ti/k3-am65-wakeup.dtsi
arch/arm64/boot/dts/ti/k3-am654-base-board.dts
arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dts
arch/arm64/boot/dts/ti/k3-j721e-main.dtsi
arch/arm64/boot/dts/ti/k3-j721e-mcu-wakeup.dtsi
arch/arm64/boot/dts/xilinx/zynqmp.dtsi
arch/arm64/configs/defconfig
arch/arm64/include/asm/compiler.h
arch/arm64/include/asm/irqflags.h
arch/arm64/include/asm/kvm_arm.h
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/include/asm/tlbflush.h
arch/arm64/kernel/acpi.c
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/cpuinfo.c
arch/arm64/kernel/entry.S
arch/arm64/kernel/hw_breakpoint.c
arch/arm64/kernel/image-vars.h
arch/arm64/kernel/module-plts.c
arch/arm64/kernel/module.c
arch/arm64/kernel/process.c
arch/arm64/kernel/setup.c
arch/arm64/kernel/smp.c
arch/arm64/kernel/vdso32/Makefile
arch/arm64/kernel/vmlinux.lds.S
arch/arm64/kvm/arm.c
arch/arm64/kvm/handle_exit.c
arch/arm64/kvm/hyp/entry.S
arch/arm64/kvm/hyp/hyp-entry.S
arch/arm64/kvm/hyp/include/hyp/debug-sr.h
arch/arm64/kvm/hyp/include/hyp/switch.h
arch/arm64/kvm/hyp/nvhe/switch.c
arch/arm64/kvm/hyp/vgic-v3-sr.c
arch/arm64/kvm/hyp/vhe/switch.c
arch/arm64/kvm/mmu.c
arch/arm64/kvm/pvtime.c
arch/arm64/kvm/trace_arm.h
arch/arm64/kvm/trace_handle_exit.h
arch/arm64/mm/context.c
arch/c6x/kernel/signal.c
arch/csky/kernel/signal.c
arch/h8300/kernel/signal.c
arch/hexagon/kernel/module.c
arch/hexagon/kernel/signal.c
arch/ia64/include/asm/pgtable.h
arch/ia64/kernel/crash.c
arch/ia64/kernel/ia64_ksyms.c
arch/ia64/kernel/module.c
arch/ia64/kernel/perfmon.c
arch/ia64/kernel/signal.c
arch/ia64/kernel/unaligned.c
arch/ia64/kernel/unwind.c
arch/m68k/atari/atakeyb.c
arch/m68k/kernel/signal.c
arch/m68k/mac/config.c
arch/m68k/mac/via.c
arch/m68k/mm/fault.c
arch/microblaze/kernel/signal.c
arch/microblaze/mm/init.c
arch/mips/include/asm/irqflags.h
arch/mips/include/asm/kvm_host.h
arch/mips/include/asm/mach-loongson64/cpu-feature-overrides.h
arch/mips/include/asm/mach-loongson64/irq.h
arch/mips/include/asm/mach-loongson64/mmzone.h
arch/mips/include/asm/unroll.h
arch/mips/kernel/perf_event_mipsxx.c
arch/mips/kernel/smp-bmips.c
arch/mips/kernel/traps.c
arch/mips/kvm/mips.c
arch/mips/kvm/mmu.c
arch/mips/mm/c-r4k.c
arch/mips/oprofile/op_model_mipsxx.c
arch/mips/sni/a20r.c
arch/nds32/include/asm/irqflags.h
arch/nds32/kernel/fpu.c
arch/nds32/kernel/signal.c
arch/openrisc/include/asm/uaccess.h
arch/openrisc/kernel/setup.c
arch/openrisc/kernel/signal.c
arch/openrisc/mm/cache.c
arch/parisc/kernel/signal.c
arch/parisc/kernel/traps.c
arch/parisc/mm/fault.c
arch/powerpc/Kconfig
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/cputable.h
arch/powerpc/include/asm/fixmap.h
arch/powerpc/include/asm/hw_irq.h
arch/powerpc/include/asm/kasan.h
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/include/asm/mce.h
arch/powerpc/include/asm/mman.h
arch/powerpc/include/asm/nohash/64/pgtable.h
arch/powerpc/include/asm/perf_event.h
arch/powerpc/include/asm/perf_event_server.h
arch/powerpc/include/uapi/asm/mman.h
arch/powerpc/include/uapi/asm/perf_regs.h
arch/powerpc/kernel/cputable.c
arch/powerpc/kernel/dt_cpu_ftrs.c
arch/powerpc/kernel/entry_64.S
arch/powerpc/kernel/process.c
arch/powerpc/kernel/setup-common.c
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/e500_mmu_host.c
arch/powerpc/mm/book3s32/mmu.c
arch/powerpc/mm/book3s64/hash_utils.c
arch/powerpc/net/bpf_jit_comp.c
arch/powerpc/perf/core-book3s.c
arch/powerpc/perf/hv-24x7.c
arch/powerpc/perf/imc-pmu.c
arch/powerpc/perf/perf_regs.c
arch/powerpc/perf/power10-pmu.c
arch/powerpc/perf/power9-pmu.c
arch/powerpc/platforms/Kconfig.cputype
arch/powerpc/platforms/powernv/idle.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/pseries/hotplug-cpu.c
arch/powerpc/platforms/pseries/ras.c
arch/riscv/Kconfig
arch/riscv/Kconfig.socs
arch/riscv/configs/nommu_virt_defconfig
arch/riscv/configs/rv32_defconfig
arch/riscv/include/asm/clint.h [deleted file]
arch/riscv/include/asm/smp.h
arch/riscv/include/asm/timex.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/clint.c [deleted file]
arch/riscv/kernel/sbi.c
arch/riscv/kernel/setup.c
arch/riscv/kernel/signal.c
arch/riscv/kernel/smp.c
arch/riscv/kernel/smpboot.c
arch/riscv/net/bpf_jit_comp32.c
arch/s390/Kconfig
arch/s390/configs/debug_defconfig
arch/s390/configs/defconfig
arch/s390/configs/zfcpdump_defconfig
arch/s390/include/asm/percpu.h
arch/s390/kernel/idle.c
arch/s390/kernel/ptrace.c
arch/s390/kernel/runtime_instr.c
arch/s390/mm/vmem.c
arch/s390/pci/pci.c
arch/s390/pci/pci_bus.c
arch/s390/pci/pci_bus.h
arch/s390/pci/pci_event.c
arch/sh/drivers/platform_early.c
arch/sh/kernel/disassemble.c
arch/sh/kernel/kgdb.c
arch/sh/kernel/signal_32.c
arch/sparc/kernel/auxio_64.c
arch/sparc/kernel/central.c
arch/sparc/kernel/kgdb_32.c
arch/sparc/kernel/kgdb_64.c
arch/sparc/kernel/pcr.c
arch/sparc/kernel/prom_32.c
arch/sparc/kernel/signal32.c
arch/sparc/kernel/signal_32.c
arch/sparc/kernel/signal_64.c
arch/sparc/math-emu/math_32.c
arch/sparc/net/bpf_jit_comp_32.c
arch/um/kernel/signal.c
arch/x86/boot/cmdline.c
arch/x86/boot/compressed/kaslr.c
arch/x86/boot/compressed/misc.c
arch/x86/boot/string.h
arch/x86/entry/calling.h
arch/x86/entry/common.c
arch/x86/entry/thunk_32.S
arch/x86/events/intel/core.c
arch/x86/events/intel/lbr.c
arch/x86/events/intel/uncore_snb.c
arch/x86/include/asm/efi.h
arch/x86/include/asm/entry-common.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/mmu.h
arch/x86/include/asm/ptrace.h
arch/x86/kernel/alternative.c
arch/x86/kernel/apic/io_apic.c
arch/x86/kernel/apic/probe_32.c
arch/x86/kernel/apic/vector.c
arch/x86/kernel/cpu/cacheinfo.c
arch/x86/kernel/cpu/mce/inject.c
arch/x86/kernel/cpu/mce/intel.c
arch/x86/kernel/cpu/mtrr/cyrix.c
arch/x86/kernel/hw_breakpoint.c
arch/x86/kernel/kgdb.c
arch/x86/kernel/kvm.c
arch/x86/kernel/mpparse.c
arch/x86/kernel/process.c
arch/x86/kernel/ptrace.c
arch/x86/kernel/reboot.c
arch/x86/kernel/signal.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/traps.c
arch/x86/kernel/uprobes.c
arch/x86/kvm/emulate.c
arch/x86/kvm/hyperv.c
arch/x86/kvm/irq_comm.c
arch/x86/kvm/lapic.c
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h
arch/x86/kvm/x86.c
arch/x86/lib/Makefile
arch/x86/lib/cmdline.c
arch/x86/lib/insn-eval.c
arch/x86/math-emu/errors.c
arch/x86/math-emu/fpu_trig.c
arch/x86/mm/fault.c
arch/x86/mm/ioremap.c
arch/x86/mm/numa_emulation.c
arch/x86/mm/tlb.c
arch/x86/pci/xen.c
arch/x86/platform/efi/efi.c
arch/x86/platform/efi/efi_32.c
arch/x86/platform/efi/efi_64.c
arch/xtensa/kernel/signal.c
block/badblocks.c
block/bfq-cgroup.c
block/bfq-iosched.c
block/bfq-iosched.h
block/bfq-wf2q.c
block/bio.c
block/blk-cgroup.c
block/blk-core.c
block/blk-iocost.c
block/blk-merge.c
block/blk-mq-sched.c
block/blk-mq-sched.h
block/blk-mq.c
block/blk-stat.c
block/blk-wbt.c
block/bsg-lib.c
block/ioprio.c
block/partitions/core.c
crypto/af_alg.c
crypto/drbg.c
crypto/tcrypt.c
drivers/accessibility/braille/braille_console.c
drivers/accessibility/speakup/Kconfig
drivers/accessibility/speakup/Makefile
drivers/accessibility/speakup/serialio.c
drivers/accessibility/speakup/spk_priv.h
drivers/accessibility/speakup/spk_ttyio.c
drivers/accessibility/speakup/spk_types.h
drivers/accessibility/speakup/synth.c
drivers/acpi/acpi_apd.c
drivers/acpi/osl.c
drivers/android/binder.c
drivers/android/binder_alloc.c
drivers/android/binder_alloc.h
drivers/android/binder_alloc_selftest.c
drivers/android/binderfs.c
drivers/ata/ahci.c
drivers/ata/ahci_brcm.c
drivers/ata/libahci_platform.c
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
drivers/ata/libata-scsi.c
drivers/ata/pata_atp867x.c
drivers/ata/pata_serverworks.c
drivers/ata/sata_mv.c
drivers/ata/sata_promise.c
drivers/ata/sata_sx4.c
drivers/atm/firestream.c
drivers/atm/fore200e.c
drivers/atm/he.c
drivers/atm/idt77105.c
drivers/atm/lanai.c
drivers/atm/zatm.c
drivers/auxdisplay/arm-charlcd.c
drivers/auxdisplay/panel.c
drivers/base/core.c
drivers/base/firmware_loader/fallback.c
drivers/base/firmware_loader/firmware.h
drivers/base/firmware_loader/main.c
drivers/base/power/main.c
drivers/block/aoe/aoecmd.c
drivers/block/ataflop.c
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c
drivers/block/drbd/drbd_nl.c
drivers/block/drbd/drbd_receiver.c
drivers/block/drbd/drbd_req.c
drivers/block/floppy.c
drivers/block/loop.c
drivers/block/nbd.c
drivers/block/null_blk_main.c
drivers/block/paride/pd.c
drivers/block/pktcdvd.c
drivers/block/rbd.c
drivers/block/rnbd/rnbd-srv.c
drivers/block/rsxx/core.c
drivers/block/skd_main.c
drivers/block/virtio_blk.c
drivers/block/xen-blkback/blkback.c
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/bus/ti-sysc.c
drivers/char/Kconfig
drivers/char/agp/ali-agp.c
drivers/char/hw_random/ingenic-rng.c
drivers/char/ipmi/kcs_bmc.c
drivers/char/lp.c
drivers/char/mem.c
drivers/char/mspec.c
drivers/char/nvram.c
drivers/clocksource/Kconfig
drivers/clocksource/Makefile
drivers/clocksource/timer-cadence-ttc.c
drivers/clocksource/timer-clint.c [new file with mode: 0644]
drivers/clocksource/timer-riscv.c
drivers/counter/microchip-tcb-capture.c
drivers/cpufreq/cpufreq.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/p4-clockmod.c
drivers/cpufreq/speedstep-lib.c
drivers/cpufreq/tegra194-cpufreq.c
drivers/cpufreq/ti-cpufreq.c
drivers/cpuidle/cpuidle.c
drivers/crypto/Kconfig
drivers/crypto/axis/artpec6_crypto.c
drivers/crypto/cavium/cpt/cptvf_reqmanager.c
drivers/crypto/chelsio/chcr_ktls.c
drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c
drivers/crypto/qat/qat_common/adf_admin.c
drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
drivers/crypto/qat/qat_common/qat_uclo.c
drivers/crypto/ux500/cryp/cryp.c
drivers/dax/device.c
drivers/dax/super.c
drivers/dma-buf/dma-buf.c
drivers/dma-buf/dma-fence-chain.c
drivers/dma/acpi-dma.c
drivers/dma/amba-pl08x.c
drivers/dma/at_hdmac.c
drivers/dma/dma-jz4780.c
drivers/dma/dw-edma/dw-edma-core.c
drivers/dma/fsldma.c
drivers/dma/fsldma.h
drivers/dma/idxd/device.c
drivers/dma/idxd/irq.c
drivers/dma/imx-dma.c
drivers/dma/iop-adma.h
drivers/dma/nbpfaxi.c
drivers/dma/of-dma.c
drivers/dma/pl330.c
drivers/dma/sh/shdma-base.c
drivers/dma/ti/k3-udma.c
drivers/edac/amd64_edac.c
drivers/edac/ghes_edac.c
drivers/edac/i7core_edac.c
drivers/edac/pnd2_edac.c
drivers/edac/sb_edac.c
drivers/edac/skx_common.c
drivers/firewire/core-device.c
drivers/firewire/core-iso.c
drivers/firewire/core-topology.c
drivers/firewire/core-transaction.c
drivers/firewire/ohci.c
drivers/firmware/efi/efi.c
drivers/firmware/efi/embedded-firmware.c
drivers/firmware/efi/libstub/efi-stub-helper.c
drivers/firmware/ti_sci.c
drivers/fpga/dfl-fme-perf.c
drivers/fpga/dfl-pci.c
drivers/fpga/dfl.c
drivers/fpga/dfl.h
drivers/fpga/fpga-region.c
drivers/fpga/stratix10-soc.c
drivers/fpga/xilinx-spi.c
drivers/fsi/fsi-core.c
drivers/fsi/fsi-master-aspeed.c
drivers/fsi/fsi-master-ast-cf.c
drivers/fsi/fsi-master-gpio.c
drivers/fsi/fsi-master-hub.c
drivers/fsi/fsi-master.h
drivers/fsi/fsi-occ.c
drivers/fsi/fsi-sbefifo.c
drivers/fsi/fsi-scom.c
drivers/gpio/gpio-aspeed-sgpio.c
drivers/gpio/gpio-aspeed.c
drivers/gpio/gpio-ath79.c
drivers/gpio/gpio-eic-sprd.c
drivers/gpio/gpio-stmpe.c
drivers/gpio/gpiolib-acpi.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v10_3.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/gfxhub_v2_1.c
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
drivers/gpu/drm/amd/amdgpu/si_dpm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
drivers/gpu/drm/amd/display/dc/bios/command_table2.c
drivers/gpu/drm/amd/display/dc/bios/command_table2.h
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/dc_bios_types.h
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dio_link_encoder.h
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr.h
drivers/gpu/drm/amd/display/include/bios_parser_types.h
drivers/gpu/drm/amd/display/include/fixed31_32.h
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega12_thermal.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/sienna_cichlid_ppt.c
drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
drivers/gpu/drm/arm/malidp_hw.c
drivers/gpu/drm/ast/ast_main.c
drivers/gpu/drm/bridge/nwl-dsi.c
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
drivers/gpu/drm/bridge/ti-sn65dsi86.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_bufs.c
drivers/gpu/drm/drm_color_mgmt.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_dp_helper.c
drivers/gpu/drm/drm_dp_mst_topology.c
drivers/gpu/drm/drm_mode_object.c
drivers/gpu/drm/drm_modes.c
drivers/gpu/drm/drm_plane.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_sched.c
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
drivers/gpu/drm/exynos/exynos_drm_gem.h
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
drivers/gpu/drm/i915/display/icl_dsi.c
drivers/gpu/drm/i915/display/intel_bios.c
drivers/gpu/drm/i915/display/intel_cdclk.c
drivers/gpu/drm/i915/display/intel_combo_phy.c
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display_debugfs.c
drivers/gpu/drm/i915/display/intel_display_power.c
drivers/gpu/drm/i915/display/intel_dpll_mgr.c
drivers/gpu/drm/i915/display/intel_hdcp.c
drivers/gpu/drm/i915/display/intel_panel.c
drivers/gpu/drm/i915/display/intel_sdvo.c
drivers/gpu/drm/i915/display/intel_sprite.c
drivers/gpu/drm/i915/display/intel_tc.c
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
drivers/gpu/drm/i915/gem/i915_gem_mman.c
drivers/gpu/drm/i915/gem/i915_gem_object.h
drivers/gpu/drm/i915/gem/i915_gem_pages.c
drivers/gpu/drm/i915/gem/i915_gem_stolen.c
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
drivers/gpu/drm/i915/gem/selftests/i915_gem_execbuffer.c
drivers/gpu/drm/i915/gt/intel_engine_cs.c
drivers/gpu/drm/i915/gt/intel_ggtt.c
drivers/gpu/drm/i915/gt/intel_ring_submission.c
drivers/gpu/drm/i915/gvt/cfg_space.c
drivers/gpu/drm/i915/gvt/gtt.c
drivers/gpu/drm/i915/gvt/gtt.h
drivers/gpu/drm/i915/gvt/gvt.h
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/vgpu.c
drivers/gpu/drm/i915/i915_cmd_parser.c
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/i915_pmu.c
drivers/gpu/drm/i915/selftests/i915_buddy.c
drivers/gpu/drm/i915/selftests/mock_gem_device.c
drivers/gpu/drm/imx/ipuv3-plane.c
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
drivers/gpu/drm/meson/meson_osd_afbcd.c
drivers/gpu/drm/meson/meson_overlay.c
drivers/gpu/drm/msm/adreno/a2xx_gpu.c
drivers/gpu/drm/msm/adreno/a3xx_gpu.c
drivers/gpu/drm/msm/adreno/a4xx_gpu.c
drivers/gpu/drm/msm/adreno/a5xx_gpu.c
drivers/gpu/drm/msm/adreno/a5xx_gpu.h
drivers/gpu/drm/msm/adreno/a5xx_preempt.c
drivers/gpu/drm/msm/adreno/a6xx_gmu.c
drivers/gpu/drm/msm/adreno/a6xx_gpu.c
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.h
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/adreno/adreno_gpu.c
drivers/gpu/drm/msm/adreno/adreno_gpu.h
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
drivers/gpu/drm/msm/msm_atomic.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_gpu.c
drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_ringbuffer.c
drivers/gpu/drm/nouveau/dispnv50/core507d.c
drivers/gpu/drm/nouveau/dispnv50/crcc37d.c
drivers/gpu/drm/nouveau/dispnv50/disp.c
drivers/gpu/drm/nouveau/include/nvif/push507c.h
drivers/gpu/drm/omapdrm/dss/venc.c
drivers/gpu/drm/omapdrm/omap_crtc.c
drivers/gpu/drm/radeon/ci_dpm.c
drivers/gpu/drm/radeon/r300.c
drivers/gpu/drm/radeon/r420.c
drivers/gpu/drm/radeon/r600_cs.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_uvd.c
drivers/gpu/drm/radeon/si_dpm.c
drivers/gpu/drm/radeon/uvd_v1_0.c
drivers/gpu/drm/savage/savage_state.c
drivers/gpu/drm/sti/sti_hdmi.c
drivers/gpu/drm/sun4i/sun4i_backend.c
drivers/gpu/drm/sun4i/sun4i_tcon.c
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
drivers/gpu/drm/sun4i/sun8i_vi_layer.c
drivers/gpu/drm/tegra/dc.c
drivers/gpu/drm/tilcdc/tilcdc_crtc.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
drivers/gpu/drm/tve200/tve200_display.c
drivers/gpu/drm/via/via_dmablit.c
drivers/gpu/drm/virtio/virtgpu_display.c
drivers/gpu/drm/virtio/virtgpu_drv.h
drivers/gpu/drm/virtio/virtgpu_ioctl.c
drivers/gpu/drm/virtio/virtgpu_object.c
drivers/gpu/drm/virtio/virtgpu_plane.c
drivers/gpu/drm/xen/xen_drm_front.c
drivers/gpu/drm/xen/xen_drm_front_gem.c
drivers/gpu/drm/xlnx/Kconfig
drivers/gpu/ipu-v3/ipu-dc.c
drivers/greybus/interface.c
drivers/hid/hid-core.c
drivers/hid/hid-cougar.c
drivers/hid/hid-elan.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-lg-g15.c
drivers/hid/hid-logitech-dj.c
drivers/hid/hid-macally.c
drivers/hid/hid-microsoft.c
drivers/hid/hid-multitouch.c
drivers/hid/hid-quirks.c
drivers/hid/hid-rmi.c
drivers/hid/hid-roccat-kone.c
drivers/hid/hid-uclogic-params.c
drivers/hid/hid-wiimote-core.c
drivers/hid/i2c-hid/i2c-hid-core.c
drivers/hid/usbhid/hid-core.c
drivers/hid/usbhid/hiddev.c
drivers/hid/usbhid/usbhid.h
drivers/hid/wacom_wac.c
drivers/hsi/clients/ssi_protocol.c
drivers/hsi/controllers/omap_ssi_core.c
drivers/hv/hv_kvp.c
drivers/hv/hv_util.c
drivers/hwmon/adt7462.c
drivers/hwmon/applesmc.c
drivers/hwmon/emc1403.c
drivers/hwmon/f71882fg.c
drivers/hwmon/gsc-hwmon.c
drivers/hwmon/hwmon-vid.c
drivers/hwmon/ina3221.c
drivers/hwmon/nct6775.c
drivers/hwmon/nct7904.c
drivers/hwmon/occ/common.c
drivers/hwmon/pmbus/isl68137.c
drivers/hwmon/w83627hf.c
drivers/hwmon/w83781d.c
drivers/hwmon/w83795.c
drivers/hwtracing/coresight/Kconfig
drivers/hwtracing/coresight/Makefile
drivers/hwtracing/coresight/coresight-catu.c
drivers/hwtracing/coresight/coresight-catu.h
drivers/hwtracing/coresight/coresight-core.c [new file with mode: 0644]
drivers/hwtracing/coresight/coresight-cpu-debug.c
drivers/hwtracing/coresight/coresight-cti-core.c [new file with mode: 0644]
drivers/hwtracing/coresight/coresight-cti.c [deleted file]
drivers/hwtracing/coresight/coresight-etb10.c
drivers/hwtracing/coresight/coresight-etm-perf.c
drivers/hwtracing/coresight/coresight-etm-perf.h
drivers/hwtracing/coresight/coresight-etm3x-core.c [new file with mode: 0644]
drivers/hwtracing/coresight/coresight-etm3x.c [deleted file]
drivers/hwtracing/coresight/coresight-etm4x-core.c [new file with mode: 0644]
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
drivers/hwtracing/coresight/coresight-etm4x.c [deleted file]
drivers/hwtracing/coresight/coresight-etm4x.h
drivers/hwtracing/coresight/coresight-funnel.c
drivers/hwtracing/coresight/coresight-platform.c
drivers/hwtracing/coresight/coresight-priv.h
drivers/hwtracing/coresight/coresight-replicator.c
drivers/hwtracing/coresight/coresight-stm.c
drivers/hwtracing/coresight/coresight-sysfs.c
drivers/hwtracing/coresight/coresight-tmc-core.c [new file with mode: 0644]
drivers/hwtracing/coresight/coresight-tmc-etf.c
drivers/hwtracing/coresight/coresight-tmc-etr.c
drivers/hwtracing/coresight/coresight-tmc.c [deleted file]
drivers/hwtracing/coresight/coresight-tmc.h
drivers/hwtracing/coresight/coresight-tpiu.c
drivers/hwtracing/coresight/coresight.c [deleted file]
drivers/hwtracing/intel_th/sth.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/busses/i2c-bcm-iproc.c
drivers/i2c/busses/i2c-npcm7xx.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-opal.c
drivers/i2c/busses/i2c-rcar.c
drivers/i2c/i2c-core-acpi.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core.h
drivers/i3c/master/dw-i3c-master.c
drivers/ide/hpt366.c
drivers/ide/ide-cd.c
drivers/ide/ide-floppy.c
drivers/ide/ide-probe.c
drivers/ide/ide-taskfile.c
drivers/ide/sis5513.c
drivers/idle/intel_idle.c
drivers/iio/accel/bmc150-accel-core.c
drivers/iio/accel/kxsd9.c
drivers/iio/accel/mma7455_core.c
drivers/iio/accel/mma8452.c
drivers/iio/adc/Kconfig
drivers/iio/adc/ab8500-gpadc.c
drivers/iio/adc/cpcap-adc.c
drivers/iio/adc/ina2xx-adc.c
drivers/iio/adc/max1118.c
drivers/iio/adc/mcp3422.c
drivers/iio/adc/meson_saradc.c
drivers/iio/adc/ti-adc081c.c
drivers/iio/adc/ti-adc084s021.c
drivers/iio/adc/ti-ads1015.c
drivers/iio/chemical/ccs811.c
drivers/iio/chemical/sps30.c
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c
drivers/iio/dac/ad5592r-base.c
drivers/iio/dac/dpot-dac.c
drivers/iio/health/max30102.c
drivers/iio/imu/adis.c
drivers/iio/industrialio-core.c
drivers/iio/light/ltr501.c
drivers/iio/light/max44000.c
drivers/iio/light/si1145.c
drivers/iio/magnetometer/ak8974.c
drivers/iio/magnetometer/ak8975.c
drivers/iio/proximity/mb1232.c
drivers/infiniband/core/cm.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/cq.c
drivers/infiniband/core/device.c
drivers/infiniband/core/rw.c
drivers/infiniband/core/ucma.c
drivers/infiniband/core/uverbs_ioctl.c
drivers/infiniband/core/verbs.c
drivers/infiniband/hw/bnxt_re/ib_verbs.c
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/bnxt_re/qplib_fp.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h
drivers/infiniband/hw/bnxt_re/qplib_sp.c
drivers/infiniband/hw/bnxt_re/qplib_sp.h
drivers/infiniband/hw/cxgb4/cm.c
drivers/infiniband/hw/cxgb4/qp.c
drivers/infiniband/hw/hfi1/pio_copy.c
drivers/infiniband/hw/hfi1/tid_rdma.c
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v1.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.h
drivers/infiniband/hw/hns/hns_roce_qp.c
drivers/infiniband/hw/hns/hns_roce_srq.c
drivers/infiniband/hw/i40iw/i40iw_cm.c
drivers/infiniband/hw/i40iw/i40iw_ctrl.c
drivers/infiniband/hw/i40iw/i40iw_hw.c
drivers/infiniband/hw/i40iw/i40iw_main.c
drivers/infiniband/hw/i40iw/i40iw_puda.c
drivers/infiniband/hw/i40iw/i40iw_utils.c
drivers/infiniband/hw/i40iw/i40iw_verbs.c
drivers/infiniband/hw/mlx4/cq.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/mcg.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx5/cq.c
drivers/infiniband/hw/mlx5/mad.c
drivers/infiniband/hw/mlx5/main.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/mthca/mthca_av.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/qib/qib_iba6120.c
drivers/infiniband/hw/qib/qib_iba7220.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_mad.c
drivers/infiniband/hw/qib/qib_rc.c
drivers/infiniband/hw/qib/qib_sdma.c
drivers/infiniband/hw/qib/qib_uc.c
drivers/infiniband/hw/qib/qib_verbs.c
drivers/infiniband/hw/usnic/usnic_ib_main.c
drivers/infiniband/hw/vmw_pvrdma/pvrdma_qp.c
drivers/infiniband/sw/rdmavt/qp.c
drivers/infiniband/sw/rxe/rxe.c
drivers/infiniband/sw/rxe/rxe.h
drivers/infiniband/sw/rxe/rxe_comp.c
drivers/infiniband/sw/rxe/rxe_mr.c
drivers/infiniband/sw/rxe/rxe_sysfs.c
drivers/infiniband/sw/rxe/rxe_task.c
drivers/infiniband/sw/rxe/rxe_verbs.c
drivers/infiniband/sw/siw/siw_cm.c
drivers/infiniband/sw/siw/siw_qp_rx.c
drivers/infiniband/sw/siw/siw_qp_tx.c
drivers/infiniband/ulp/ipoib/ipoib_cm.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/iser/iser_verbs.c
drivers/infiniband/ulp/isert/ib_isert.c
drivers/infiniband/ulp/isert/ib_isert.h
drivers/infiniband/ulp/opa_vnic/opa_vnic_vema.c
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c
drivers/infiniband/ulp/rtrs/rtrs-srv.c
drivers/input/joystick/fsia6b.c
drivers/input/joystick/gamecon.c
drivers/input/tablet/wacom_serial4.c
drivers/input/touchscreen/atmel_mxt_ts.c
drivers/input/touchscreen/wm831x-ts.c
drivers/interconnect/Makefile
drivers/interconnect/bulk.c [new file with mode: 0644]
drivers/interconnect/core.c
drivers/interconnect/imx/imx.c
drivers/interconnect/qcom/Kconfig
drivers/interconnect/qcom/Makefile
drivers/interconnect/qcom/bcm-voter.c
drivers/interconnect/qcom/icc-rpmh.c
drivers/interconnect/qcom/icc-rpmh.h
drivers/interconnect/qcom/osm-l3.c
drivers/interconnect/qcom/sc7180.c
drivers/interconnect/qcom/sdm845.c
drivers/interconnect/qcom/sm8150.c [new file with mode: 0644]
drivers/interconnect/qcom/sm8150.h [new file with mode: 0644]
drivers/interconnect/qcom/sm8250.c [new file with mode: 0644]
drivers/interconnect/qcom/sm8250.h [new file with mode: 0644]
drivers/iommu/amd/Kconfig
drivers/iommu/amd/init.c
drivers/iommu/amd/iommu.c
drivers/iommu/amd/iommu_v2.c
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
drivers/iommu/dma-iommu.c
drivers/iommu/intel/iommu.c
drivers/iommu/intel/irq_remapping.c
drivers/iommu/virtio-iommu.c
drivers/irqchip/Kconfig
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-imx-gpcv2.c
drivers/irqchip/irq-ingenic.c
drivers/irqchip/irq-mips-gic.c
drivers/irqchip/irq-mtk-cirq.c
drivers/irqchip/irq-mtk-sysirq.c
drivers/irqchip/irq-stm32-exti.c
drivers/irqchip/irq-ti-sci-inta.c
drivers/irqchip/irq-ti-sci-intr.c
drivers/irqchip/irq-vic.c
drivers/irqchip/irqchip.c
drivers/irqchip/qcom-pdc.c
drivers/isdn/hardware/mISDN/avmfritz.c
drivers/isdn/hardware/mISDN/hfc_multi_8xx.h
drivers/isdn/hardware/mISDN/hfcpci.c
drivers/isdn/hardware/mISDN/hfcsusb.c
drivers/isdn/hardware/mISDN/isdnhdlc.c
drivers/isdn/hardware/mISDN/mISDNinfineon.c
drivers/isdn/hardware/mISDN/mISDNisar.c
drivers/isdn/mISDN/stack.c
drivers/lightnvm/pblk-core.c
drivers/macintosh/adbhid.c
drivers/macintosh/smu.c
drivers/md/bcache/journal.c
drivers/md/bcache/util.c
drivers/md/dm-cache-metadata.c
drivers/md/dm-crypt.c
drivers/md/dm-integrity.c
drivers/md/dm-mpath.c
drivers/md/dm-thin-metadata.c
drivers/md/dm-writecache.c
drivers/md/dm.c
drivers/md/md-autodetect.c
drivers/md/md-bitmap.c
drivers/md/persistent-data/dm-block-manager.c
drivers/md/raid5.c
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
drivers/media/dvb-core/dvb_net.c
drivers/media/dvb-frontends/bcm3510.c
drivers/media/dvb-frontends/dib0090.c
drivers/media/dvb-frontends/dib3000mb.c
drivers/media/dvb-frontends/dib7000p.c
drivers/media/dvb-frontends/drx39xyj/drxj.c
drivers/media/dvb-frontends/drxd_hard.c
drivers/media/dvb-frontends/drxk_hard.c
drivers/media/dvb-frontends/lgdt3306a.c
drivers/media/dvb-frontends/mt352.c
drivers/media/dvb-frontends/mxl5xx.c
drivers/media/dvb-frontends/or51132.c
drivers/media/dvb-frontends/s5h1411.c
drivers/media/dvb-frontends/zl10353.c
drivers/media/i2c/Kconfig
drivers/media/pci/cx23885/cx23885-cards.c
drivers/media/pci/ddbridge/ddbridge-core.c
drivers/media/pci/meye/meye.c
drivers/media/pci/ttpci/av7110.c
drivers/media/pci/ttpci/av7110_hw.c
drivers/media/pci/ttpci/av7110_ipack.c
drivers/media/pci/ttpci/budget-av.c
drivers/media/pci/ttpci/budget.c
drivers/media/platform/sh_vou.c
drivers/media/platform/ti-vpe/cal.h
drivers/media/radio/radio-si476x.c
drivers/media/radio/tea575x.c
drivers/media/rc/bpf-lirc.c
drivers/media/rc/gpio-ir-tx.c
drivers/media/rc/ir-rc6-decoder.c
drivers/media/rc/ir-sony-decoder.c
drivers/media/rc/mceusb.c
drivers/media/rc/rc-main.c
drivers/media/test-drivers/vicodec/vicodec-core.c
drivers/media/tuners/xc5000.c
drivers/media/usb/b2c2/flexcop-usb.c
drivers/media/usb/cpia2/cpia2_core.c
drivers/media/usb/cx231xx/cx231xx-video.c
drivers/media/usb/dvb-usb/dib0700_devices.c
drivers/media/usb/dvb-usb/dw2102.c
drivers/media/v4l2-core/v4l2-ctrls.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/videobuf-core.c
drivers/memory/omap-gpmc.c
drivers/memstick/core/ms_block.c
drivers/memstick/host/jmb38x_ms.c
drivers/memstick/host/tifm_ms.c
drivers/message/fusion/mptbase.c
drivers/message/fusion/mptsas.c
drivers/message/fusion/mptscsih.c
drivers/mfd/db8500-prcmu.c
drivers/mfd/iqs62x.c
drivers/mfd/mfd-core.c
drivers/mfd/mxs-lradc.c
drivers/mfd/omap-usb-host.c
drivers/mfd/rave-sp.c
drivers/mfd/syscon.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/cardreader/rts5227.c
drivers/misc/cardreader/rts5228.c
drivers/misc/cardreader/rts5249.c
drivers/misc/cardreader/rts5260.c
drivers/misc/cardreader/rtsx_pcr.c
drivers/misc/cardreader/rtsx_pcr.h
drivers/misc/eeprom/at24.c
drivers/misc/eeprom/at25.c
drivers/misc/eeprom/eeprom_93xx46.c
drivers/misc/fastrpc.c
drivers/misc/habanalabs/Kconfig
drivers/misc/habanalabs/common/Makefile
drivers/misc/habanalabs/common/command_buffer.c
drivers/misc/habanalabs/common/command_submission.c
drivers/misc/habanalabs/common/context.c
drivers/misc/habanalabs/common/debugfs.c
drivers/misc/habanalabs/common/device.c
drivers/misc/habanalabs/common/firmware_if.c
drivers/misc/habanalabs/common/habanalabs.h
drivers/misc/habanalabs/common/habanalabs_drv.c
drivers/misc/habanalabs/common/habanalabs_ioctl.c
drivers/misc/habanalabs/common/hw_queue.c
drivers/misc/habanalabs/common/hwmon.c
drivers/misc/habanalabs/common/irq.c
drivers/misc/habanalabs/common/memory.c
drivers/misc/habanalabs/common/mmu.c
drivers/misc/habanalabs/common/mmu_v1.c [new file with mode: 0644]
drivers/misc/habanalabs/common/pci.c
drivers/misc/habanalabs/common/sysfs.c
drivers/misc/habanalabs/gaudi/gaudi.c
drivers/misc/habanalabs/gaudi/gaudiP.h
drivers/misc/habanalabs/gaudi/gaudi_coresight.c
drivers/misc/habanalabs/gaudi/gaudi_security.c
drivers/misc/habanalabs/goya/goya.c
drivers/misc/habanalabs/goya/goyaP.h
drivers/misc/habanalabs/goya/goya_coresight.c
drivers/misc/habanalabs/include/common/armcp_if.h [deleted file]
drivers/misc/habanalabs/include/common/cpucp_if.h [new file with mode: 0644]
drivers/misc/habanalabs/include/common/qman_if.h
drivers/misc/habanalabs/include/gaudi/gaudi.h
drivers/misc/habanalabs/include/gaudi/gaudi_masks.h
drivers/misc/habanalabs/include/gaudi/gaudi_reg_map.h
drivers/misc/habanalabs/include/goya/goya_reg_map.h
drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h
drivers/misc/hisi_hikey_usb.c [new file with mode: 0644]
drivers/misc/mei/Kconfig
drivers/misc/mei/Makefile
drivers/misc/mei/bus-fixup.c
drivers/misc/mei/bus.c
drivers/misc/mei/client.c
drivers/misc/mei/client.h
drivers/misc/mei/debugfs.c
drivers/misc/mei/hbm.c
drivers/misc/mei/hbm.h
drivers/misc/mei/hdcp/mei_hdcp.c
drivers/misc/mei/hw-virtio.c [new file with mode: 0644]
drivers/misc/mei/hw.h
drivers/misc/mei/interrupt.c
drivers/misc/mei/main.c
drivers/misc/mei/mei_dev.h
drivers/misc/mic/scif/scif_api.c
drivers/misc/mic/scif/scif_nodeqp.c
drivers/misc/mic/scif/scif_rma.c
drivers/misc/pvpanic.c
drivers/misc/sgi-gru/grukservices.c
drivers/misc/sgi-xp/xpc_main.c
drivers/misc/sgi-xp/xpc_partition.c
drivers/misc/sgi-xp/xpc_uv.c
drivers/misc/uacce/uacce.c
drivers/misc/vmw_vmci/vmci_queue_pair.c
drivers/mmc/core/host.c
drivers/mmc/core/sdio_ops.c
drivers/mmc/host/Kconfig
drivers/mmc/host/atmel-mci.c
drivers/mmc/host/davinci_mmc.c
drivers/mmc/host/dw_mmc-k3.c
drivers/mmc/host/dw_mmc.c
drivers/mmc/host/jz4740_mmc.c
drivers/mmc/host/meson-mx-sdio.c
drivers/mmc/host/mmc_spi.c
drivers/mmc/host/mtk-sd.c
drivers/mmc/host/renesas_sdhi_core.c
drivers/mmc/host/sdhci-acpi.c
drivers/mmc/host/sdhci-esdhc-imx.c
drivers/mmc/host/sdhci-msm.c
drivers/mmc/host/sdhci-of-esdhc.c
drivers/mmc/host/sdhci-pci-core.c
drivers/mmc/host/sdhci-s3c.c
drivers/mmc/host/sdhci-sprd.c
drivers/mmc/host/sdhci-tegra.c
drivers/mmc/host/sdhci-xenon-phy.c
drivers/mmc/host/sdhci.c
drivers/mmc/host/tifm_sd.c
drivers/mmc/host/usdhi6rol0.c
drivers/mux/adgs1408.c
drivers/net/appletalk/cops.c
drivers/net/arcnet/arc-rimi.c
drivers/net/arcnet/com20020-isa.c
drivers/net/arcnet/com90io.c
drivers/net/arcnet/com90xx.c
drivers/net/bonding/bond_3ad.c
drivers/net/bonding/bond_alb.c
drivers/net/bonding/bond_main.c
drivers/net/can/at91_can.c
drivers/net/can/peak_canfd/peak_pciefd_main.c
drivers/net/can/sja1000/sja1000_platform.c
drivers/net/can/slcan.c
drivers/net/can/spi/mcp251x.c
drivers/net/can/usb/peak_usb/pcan_usb.c
drivers/net/can/usb/peak_usb/pcan_usb_core.c
drivers/net/can/usb/peak_usb/pcan_usb_pro.c
drivers/net/dsa/b53/b53_common.c
drivers/net/dsa/b53/b53_serdes.c
drivers/net/dsa/bcm_sf2.c
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/mt7530.c
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/ocelot/Kconfig
drivers/net/dsa/ocelot/felix.c
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/ethernet/3com/3c509.c
drivers/net/ethernet/3com/3c574_cs.c
drivers/net/ethernet/8390/axnet_cs.c
drivers/net/ethernet/8390/pcnet_cs.c
drivers/net/ethernet/alacritech/slicoss.c
drivers/net/ethernet/alteon/acenic.c
drivers/net/ethernet/amazon/ena/ena_netdev.c
drivers/net/ethernet/amd/amd8111e.c
drivers/net/ethernet/amd/xgbe/xgbe-drv.c
drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c
drivers/net/ethernet/arc/emac_mdio.c
drivers/net/ethernet/broadcom/bcmsysport.c
drivers/net/ethernet/broadcom/bgmac-bcma.c
drivers/net/ethernet/broadcom/bgmac-platform.c
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/genet/bcmmii.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/brocade/bna/bfa_ioc.c
drivers/net/ethernet/brocade/bna/bna_enet.c
drivers/net/ethernet/brocade/bna/bna_tx_rx.c
drivers/net/ethernet/cadence/macb_ptp.c
drivers/net/ethernet/cavium/liquidio/lio_main.c
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c
drivers/net/ethernet/cavium/thunder/nicvf_main.c
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
drivers/net/ethernet/chelsio/cxgb3/l2t.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_thermal.c
drivers/net/ethernet/chelsio/cxgb4/l2t.c
drivers/net/ethernet/chelsio/cxgb4/sge.c
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
drivers/net/ethernet/cisco/enic/enic_main.c
drivers/net/ethernet/cortina/gemini.c
drivers/net/ethernet/davicom/dm9000.c
drivers/net/ethernet/dec/tulip/de4x5.c
drivers/net/ethernet/dec/tulip/tulip_core.c
drivers/net/ethernet/dec/tulip/winbond-840.c
drivers/net/ethernet/emulex/benet/be_ethtool.c
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/dpaa/dpaa_ethtool.c
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
drivers/net/ethernet/freescale/fec_main.c
drivers/net/ethernet/freescale/fman/fman_memac.c
drivers/net/ethernet/freescale/fman/fman_port.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/hisilicon/hns/hns_enet.c
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
drivers/net/ethernet/ibm/ehea/ehea_main.c
drivers/net/ethernet/ibm/emac/core.c
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
drivers/net/ethernet/intel/i40e/i40e_common.c
drivers/net/ethernet/intel/i40e/i40e_main.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igc/igc_main.c
drivers/net/ethernet/intel/igc/igc_ptp.c
drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
drivers/net/ethernet/marvell/skge.c
drivers/net/ethernet/marvell/sky2.c
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mellanox/mlx4/mr.c
drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
drivers/net/ethernet/mellanox/mlxsw/core.c
drivers/net/ethernet/mellanox/mlxsw/core_env.c
drivers/net/ethernet/mellanox/mlxsw/core_hwmon.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/microchip/lan743x_ethtool.c
drivers/net/ethernet/mscc/ocelot.c
drivers/net/ethernet/natsemi/natsemi.c
drivers/net/ethernet/neterion/vxge/vxge-config.c
drivers/net/ethernet/netronome/nfp/crypto/tls.c
drivers/net/ethernet/netronome/nfp/flower/action.c
drivers/net/ethernet/netronome/nfp/flower/cmsg.c
drivers/net/ethernet/netronome/nfp/flower/offload.c
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
drivers/net/ethernet/netronome/nfp/nfp_asm.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfpcore/nfp6000_pcie.c
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c
drivers/net/ethernet/packetengines/yellowfin.c
drivers/net/ethernet/pensando/ionic/ionic_txrx.c
drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c
drivers/net/ethernet/qlogic/qed/qed_cxt.c
drivers/net/ethernet/qlogic/qed/qed_dev.c
drivers/net/ethernet/qlogic/qed/qed_main.c
drivers/net/ethernet/qlogic/qed/qed_mcp.c
drivers/net/ethernet/qlogic/qla3xxx.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_ethtool.c
drivers/net/ethernet/realtek/r8169_main.c
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/ethernet/rocker/rocker_main.c
drivers/net/ethernet/samsung/sxgbe/sxgbe_ethtool.c
drivers/net/ethernet/sfc/ef100.c
drivers/net/ethernet/sfc/ef100_nic.c
drivers/net/ethernet/sfc/ef100_rx.c
drivers/net/ethernet/sfc/ef100_rx.h
drivers/net/ethernet/sfc/efx.h
drivers/net/ethernet/sfc/falcon/ethtool.c
drivers/net/ethernet/sfc/falcon/farch.c
drivers/net/ethernet/sfc/farch.c
drivers/net/ethernet/sfc/mcdi_filters.c
drivers/net/ethernet/sfc/mcdi_port_common.c
drivers/net/ethernet/sfc/net_driver.h
drivers/net/ethernet/sfc/nic.c
drivers/net/ethernet/sfc/rx.c
drivers/net/ethernet/sfc/rx_common.c
drivers/net/ethernet/sis/sis900.c
drivers/net/ethernet/smsc/smc911x.c
drivers/net/ethernet/socionext/netsec.c
drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
drivers/net/ethernet/sun/cassini.c
drivers/net/ethernet/sun/niu.c
drivers/net/ethernet/sun/sungem.c
drivers/net/ethernet/ti/am65-cpsw-nuss.c
drivers/net/ethernet/ti/cpsw-phy-sel.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/cpsw_new.c
drivers/net/ethernet/ti/cpsw_priv.c
drivers/net/ethernet/ti/tlan.c
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
drivers/net/ethernet/toshiba/spider_net.c
drivers/net/ethernet/xircom/xirc2ps_cs.c
drivers/net/fddi/skfp/cfm.c
drivers/net/fddi/skfp/fplustm.c
drivers/net/fddi/skfp/hwmtm.c
drivers/net/fddi/skfp/pcmplc.c
drivers/net/fddi/skfp/smt.c
drivers/net/fjes/fjes_main.c
drivers/net/gtp.c
drivers/net/hamradio/baycom_epp.c
drivers/net/hamradio/mkiss.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/ipvlan/ipvlan_main.c
drivers/net/macvlan.c
drivers/net/mii.c
drivers/net/netdevsim/bus.c
drivers/net/netdevsim/fib.c
drivers/net/phy/adin.c
drivers/net/phy/dp83640.c
drivers/net/phy/dp83867.c
drivers/net/phy/dp83869.c
drivers/net/phy/fixed_phy.c
drivers/net/phy/mscc/mscc_main.c
drivers/net/phy/phy.c
drivers/net/phy/phy_device.c
drivers/net/phy/phylink.c
drivers/net/phy/sfp-bus.c
drivers/net/phy/sfp.c
drivers/net/plip/plip.c
drivers/net/tun.c
drivers/net/usb/Kconfig
drivers/net/usb/aqc111.c
drivers/net/usb/asix_common.c
drivers/net/usb/catc.c
drivers/net/usb/cdc-phonet.c
drivers/net/usb/dm9601.c
drivers/net/usb/lan78xx.c
drivers/net/usb/pegasus.c
drivers/net/usb/r8152.c
drivers/net/usb/rtl8150.c
drivers/net/usb/usbnet.c
drivers/net/veth.c
drivers/net/virtio_net.c
drivers/net/vmxnet3/vmxnet3_ethtool.c
drivers/net/wan/dlci.c
drivers/net/wan/hdlc.c
drivers/net/wan/hdlc_cisco.c
drivers/net/wan/hdlc_x25.c
drivers/net/wan/lapbether.c
drivers/net/wan/sdla.c
drivers/net/wan/x25_asy.c
drivers/net/wimax/i2400m/control.c
drivers/net/wimax/i2400m/usb-fw.c
drivers/net/wimax/i2400m/usb-tx.c
drivers/net/wimax/i2400m/usb.c
drivers/net/xen-netback/hash.c
drivers/net/xen-netback/xenbus.c
drivers/net/xen-netfront.c
drivers/nfc/pn533/pn533.c
drivers/nfc/st21nfca/dep.c
drivers/nfc/st95hf/core.c
drivers/nfc/trf7970a.c
drivers/ntb/ntb_transport.c
drivers/nvdimm/dimm_devs.c
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.c
drivers/nvme/host/fc.c
drivers/nvme/host/multipath.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c
drivers/nvme/host/rdma.c
drivers/nvme/host/tcp.c
drivers/nvme/target/configfs.c
drivers/nvme/target/core.c
drivers/nvme/target/fc.c
drivers/nvme/target/fcloop.c
drivers/nvme/target/io-cmd-bdev.c
drivers/nvme/target/loop.c
drivers/nvme/target/passthru.c
drivers/nvme/target/rdma.c
drivers/nvme/target/tcp.c
drivers/nvmem/core.c
drivers/nvmem/mtk-efuse.c
drivers/of/address.c
drivers/opp/core.c
drivers/opp/opp.h
drivers/parport/ieee1284.c
drivers/parport/parport_pc.c
drivers/pci/controller/dwc/pci-imx6.c
drivers/pci/controller/pci-rcar-gen2.c
drivers/pci/hotplug/ibmphp_res.c
drivers/pci/hotplug/pciehp_ctrl.c
drivers/pci/hotplug/s390_pci_hpc.c
drivers/pci/hotplug/shpchp_ctrl.c
drivers/pci/p2pdma.c
drivers/pci/pci.c
drivers/pci/proc.c
drivers/pci/quirks.c
drivers/pci/setup-bus.c
drivers/pci/xen-pcifront.c
drivers/pcmcia/db1xxx_ss.c
drivers/perf/arm-ccn.c
drivers/perf/arm_spe_pmu.c
drivers/phy/qualcomm/phy-qcom-ipq806x-usb.c
drivers/phy/qualcomm/phy-qcom-qmp.c
drivers/phy/qualcomm/phy-qcom-qmp.h
drivers/phy/qualcomm/phy-qcom-usb-hs.c
drivers/phy/rockchip/phy-rockchip-inno-usb2.c
drivers/phy/ti/phy-omap-usb2.c
drivers/platform/olpc/olpc-xo175-ec.c
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/surfacepro3_button.c
drivers/platform/x86/thinkpad_acpi.c
drivers/platform/x86/toshiba_acpi.c
drivers/power/supply/ab8500_charger.c
drivers/power/supply/ab8500_fg.c
drivers/power/supply/abx500_chargalg.c
drivers/power/supply/axp20x_usb_power.c
drivers/power/supply/cros_usbpd-charger.c
drivers/power/supply/max8925_power.c
drivers/power/supply/wm831x_power.c
drivers/power/supply/wm8350_power.c
drivers/powercap/intel_rapl_common.c
drivers/ps3/ps3av.c
drivers/ps3/ps3av_cmd.c
drivers/ptp/ptp_clockmatrix.c
drivers/ptp/ptp_clockmatrix.h
drivers/rapidio/Kconfig
drivers/rapidio/devices/rio_mport_cdev.c
drivers/regulator/axp20x-regulator.c
drivers/regulator/core.c
drivers/regulator/cros-ec-regulator.c
drivers/regulator/fixed.c
drivers/regulator/pwm-regulator.c
drivers/regulator/slg51000-regulator.c
drivers/regulator/twl6030-regulator.c
drivers/remoteproc/omap_remoteproc.c
drivers/reset/reset-imx7.c
drivers/rpmsg/qcom_glink_native.c
drivers/rtc/rtc-m41t80.c
drivers/rtc/rtc-pcf85063.c
drivers/rtc/rtc-pcf8523.c
drivers/rtc/rtc-stmp3xxx.c
drivers/s390/cio/css.c
drivers/s390/net/ctcm_fsms.c
drivers/s390/net/ctcm_mpc.c
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_ethtool.c
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c
drivers/s390/scsi/zfcp_fsf.c
drivers/scsi/53c700.c
drivers/scsi/BusLogic.c
drivers/scsi/FlashPoint.c
drivers/scsi/NCR5380.c
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/commsup.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aic7xxx/aic79xx_core.c
drivers/scsi/aic7xxx/aic79xx_osm.c
drivers/scsi/aic7xxx/aic7xxx_core.c
drivers/scsi/aic94xx/aic94xx_scb.c
drivers/scsi/aic94xx/aic94xx_tmf.c
drivers/scsi/arcmsr/arcmsr_hba.c
drivers/scsi/arm/fas216.c
drivers/scsi/be2iscsi/be_iscsi.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bfa/bfa_fcpim.c
drivers/scsi/bfa/bfa_fcs_lport.c
drivers/scsi/bfa/bfa_fcs_rport.c
drivers/scsi/bfa/bfa_ioc.c
drivers/scsi/bfa/bfa_svc.c
drivers/scsi/bnx2fc/bnx2fc_hwi.c
drivers/scsi/csiostor/csio_hw.c
drivers/scsi/csiostor/csio_lnode.c
drivers/scsi/csiostor/csio_wr.c
drivers/scsi/cxgbi/cxgb3i/cxgb3i.c
drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
drivers/scsi/cxgbi/libcxgbi.c
drivers/scsi/cxlflash/main.c
drivers/scsi/cxlflash/superpipe.c
drivers/scsi/device_handler/scsi_dh_hp_sw.c
drivers/scsi/esas2r/esas2r_flash.c
drivers/scsi/esas2r/esas2r_init.c
drivers/scsi/esp_scsi.c
drivers/scsi/fcoe/fcoe_ctlr.c
drivers/scsi/g_NCR5380.c
drivers/scsi/hisi_sas/hisi_sas_main.c
drivers/scsi/hpsa.c
drivers/scsi/ibmvscsi/ibmvfc.c
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
drivers/scsi/imm.c
drivers/scsi/isci/phy.c
drivers/scsi/isci/remote_device.c
drivers/scsi/isci/remote_node_context.c
drivers/scsi/isci/request.c
drivers/scsi/libfc/fc_disc.c
drivers/scsi/libfc/fc_exch.c
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/libfc/fc_lport.c
drivers/scsi/libfc/fc_rport.c
drivers/scsi/libiscsi.c
drivers/scsi/libiscsi_tcp.c
drivers/scsi/libsas/sas_ata.c
drivers/scsi/libsas/sas_discover.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/libsas/sas_scsi_host.c
drivers/scsi/lpfc/lpfc_ct.c
drivers/scsi/lpfc/lpfc_els.c
drivers/scsi/lpfc/lpfc_hbadisc.c
drivers/scsi/lpfc/lpfc_hw4.h
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_nportdisc.c
drivers/scsi/lpfc/lpfc_nvme.c
drivers/scsi/lpfc/lpfc_scsi.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_version.h
drivers/scsi/megaraid.c
drivers/scsi/megaraid/megaraid_mbox.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/mesh.c
drivers/scsi/mpt3sas/mpt3sas_base.c
drivers/scsi/mpt3sas/mpt3sas_ctl.c
drivers/scsi/mpt3sas/mpt3sas_scsih.c
drivers/scsi/myrb.c
drivers/scsi/ncr53c8xx.c
drivers/scsi/pcmcia/nsp_cs.c
drivers/scsi/pm8001/pm8001_sas.c
drivers/scsi/ppa.c
drivers/scsi/qedf/qedf_main.c
drivers/scsi/qla2xxx/qla_dbg.h
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_gs.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/qla2xxx/qla_nvme.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_sup.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/qlogicpti.c
drivers/scsi/scsi_debug.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_ioctl.c
drivers/scsi/scsi_lib.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/scsi/sr.c
drivers/scsi/st.c
drivers/scsi/sun3_scsi.c
drivers/scsi/sym53c8xx_2/sym_fw.c
drivers/scsi/sym53c8xx_2/sym_hipd.c
drivers/scsi/sym53c8xx_2/sym_nvram.c
drivers/scsi/ufs/ti-j721e-ufs.c
drivers/scsi/ufs/ufs-mediatek.c
drivers/scsi/ufs/ufs_bsg.c
drivers/scsi/ufs/ufshcd-pci.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/ufs/ufshcd.h
drivers/scsi/virtio_scsi.c
drivers/scsi/vmw_pvscsi.c
drivers/scsi/wd33c93.c
drivers/scsi/xen-scsifront.c
drivers/slimbus/core.c
drivers/slimbus/qcom-ngd-ctrl.c
drivers/soc/qcom/socinfo.c
drivers/soc/tegra/pmc.c
drivers/soundwire/bus.c
drivers/soundwire/stream.c
drivers/spi/Kconfig
drivers/spi/spi-bcm2835aux.c
drivers/spi/spi-cadence-quadspi.c
drivers/spi/spi-fsl-cpm.c
drivers/spi/spi-loopback-test.c
drivers/spi/spi-sprd-adi.c
drivers/spi/spi-stm32.c
drivers/spi/spi.c
drivers/ssb/driver_chipcommon.c
drivers/ssb/driver_mipscore.c
drivers/ssb/scan.c
drivers/staging/greybus/audio_helper.c
drivers/staging/greybus/audio_topology.c
drivers/staging/media/atomisp/pci/atomisp_cmd.c
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
drivers/staging/media/atomisp/pci/atomisp_ioctl.c
drivers/staging/media/atomisp/pci/atomisp_v4l2.c
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
drivers/staging/media/atomisp/pci/sh_css.c
drivers/staging/media/hantro/hantro_g1_mpeg2_dec.c
drivers/staging/media/hantro/rk3399_vpu_hw_mpeg2_dec.c
drivers/staging/media/imx/imx-media-csi.c
drivers/staging/media/sunxi/cedrus/cedrus.c
drivers/staging/media/usbvision/usbvision-i2c.c
drivers/staging/wlan-ng/hfa384x_usb.c
drivers/staging/wlan-ng/prism2usb.c
drivers/target/iscsi/cxgbit/cxgbit_main.c
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_login.c
drivers/target/iscsi/iscsi_target_login.h
drivers/target/iscsi/iscsi_target_nego.c
drivers/target/target_core_pr.c
drivers/target/target_core_sbc.c
drivers/target/target_core_transport.c
drivers/target/tcm_fc/tfc_cmd.c
drivers/thermal/qcom/qcom-spmi-temp-alarm.c
drivers/thermal/qcom/tsens-v0_1.c
drivers/thermal/qcom/tsens-v1.c
drivers/thermal/thermal_core.c
drivers/thermal/ti-soc-thermal/omap4-thermal-data.c
drivers/thermal/ti-soc-thermal/omap4xxx-bandgap.h
drivers/thunderbolt/ctl.c
drivers/thunderbolt/switch.c
drivers/thunderbolt/tb.h
drivers/thunderbolt/tunnel.c
drivers/tty/hvc/hvc_xen.c
drivers/tty/mips_ejtag_fdc.c
drivers/tty/n_gsm.c
drivers/tty/n_hdlc.c
drivers/tty/n_r3964.c
drivers/tty/serial/8250/8250_em.c
drivers/tty/serial/8250/8250_exar.c
drivers/tty/serial/8250/8250_fintek.c
drivers/tty/serial/8250/8250_pci.c
drivers/tty/serial/8250/8250_port.c
drivers/tty/serial/8250/8250_uniphier.c
drivers/tty/serial/Kconfig
drivers/tty/serial/Makefile
drivers/tty/serial/amba-pl011.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/omap-serial.c
drivers/tty/serial/qcom_geni_serial.c
drivers/tty/serial/rda-uart.c
drivers/tty/serial/samsung_tty.c
drivers/tty/serial/serial-tegra.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/stm32-usart.c
drivers/tty/serial/sunsu.c
drivers/tty/serial/sunzilog.c
drivers/tty/serial/xilinx_uartps.c
drivers/tty/tty_ioctl.c
drivers/tty/vt/vt.c
drivers/tty/vt/vt_ioctl.c
drivers/uio/uio.c
drivers/usb/c67x00/c67x00-sched.c
drivers/usb/class/cdc-acm.c
drivers/usb/core/driver.c
drivers/usb/core/generic.c
drivers/usb/core/hcd-pci.c
drivers/usb/core/hub.c
drivers/usb/core/message.c
drivers/usb/core/quirks.c
drivers/usb/core/sysfs.c
drivers/usb/dwc3/core.c
drivers/usb/dwc3/dwc3-meson-g12a.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/function/f_mass_storage.c
drivers/usb/gadget/function/f_ncm.c
drivers/usb/gadget/function/f_tcm.c
drivers/usb/gadget/u_f.h
drivers/usb/gadget/udc/atmel_usba_udc.c
drivers/usb/gadget/udc/fsl_udc_core.c
drivers/usb/gadget/udc/pxa25x_udc.c
drivers/usb/host/isp116x-hcd.c
drivers/usb/host/ohci-exynos.c
drivers/usb/host/pci-quirks.c
drivers/usb/host/xhci-dbgcap.c
drivers/usb/host/xhci-debugfs.c
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci-pci-renesas.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci-tegra.c
drivers/usb/host/xhci.c
drivers/usb/misc/lvstest.c
drivers/usb/misc/yurex.c
drivers/usb/musb/cppi_dma.c
drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_dsps.c
drivers/usb/musb/musb_gadget_ep0.c
drivers/usb/musb/musb_host.c
drivers/usb/musb/musb_virthub.c
drivers/usb/musb/omap2430.c
drivers/usb/musb/tusb6010.c
drivers/usb/phy/phy-jz4770.c
drivers/usb/serial/ftdi_sio.c
drivers/usb/serial/ftdi_sio_ids.h
drivers/usb/serial/option.c
drivers/usb/storage/sddr55.c
drivers/usb/storage/uas.c
drivers/usb/storage/unusual_devs.h
drivers/usb/storage/unusual_uas.h
drivers/usb/typec/mux/intel_pmc_mux.c
drivers/usb/typec/tcpm/tcpci.c
drivers/usb/typec/tcpm/tcpm.c
drivers/usb/typec/ucsi/displayport.c
drivers/usb/typec/ucsi/ucsi.c
drivers/usb/typec/ucsi/ucsi_acpi.c
drivers/usb/usbip/stub_dev.c
drivers/vdpa/ifcvf/ifcvf_base.h
drivers/vdpa/ifcvf/ifcvf_main.c
drivers/vdpa/mlx5/net/mlx5_vnet.c
drivers/vfio/pci/vfio_pci.c
drivers/vfio/pci/vfio_pci_private.h
drivers/vfio/pci/vfio_pci_rdwr.c
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/iotlb.c
drivers/vhost/vhost.c
drivers/video/backlight/adp8860_bl.c
drivers/video/fbdev/acornfb.c
drivers/video/fbdev/arcfb.c
drivers/video/fbdev/atmel_lcdfb.c
drivers/video/fbdev/aty/radeon_pm.c
drivers/video/fbdev/cirrusfb.c
drivers/video/fbdev/controlfb.c
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbmem.c
drivers/video/fbdev/efifb.c
drivers/video/fbdev/fsl-diu-fb.c
drivers/video/fbdev/gxt4500.c
drivers/video/fbdev/hyperv_fb.c
drivers/video/fbdev/i740fb.c
drivers/video/fbdev/mmp/fb/mmpfb.c
drivers/video/fbdev/nvidia/nv_hw.c
drivers/video/fbdev/offb.c
drivers/video/fbdev/omap/lcdc.c
drivers/video/fbdev/omap/omapfb_main.c
drivers/video/fbdev/omap2/omapfb/dss/dispc.c
drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
drivers/video/fbdev/omap2/omapfb/omapfb-main.c
drivers/video/fbdev/pm2fb.c
drivers/video/fbdev/pxa168fb.c
drivers/video/fbdev/pxafb.c
drivers/video/fbdev/riva/fbdev.c
drivers/video/fbdev/s3c-fb.c
drivers/video/fbdev/sa1100fb.c
drivers/video/fbdev/savage/savagefb_driver.c
drivers/video/fbdev/sh_mobile_lcdcfb.c
drivers/video/fbdev/sis/sis_main.c
drivers/video/fbdev/sm501fb.c
drivers/video/fbdev/stifb.c
drivers/video/fbdev/tdfxfb.c
drivers/video/fbdev/vga16fb.c
drivers/video/fbdev/via/lcd.c
drivers/video/fbdev/xen-fbfront.c
drivers/virt/Kconfig
drivers/virt/Makefile
drivers/virt/fsl_hypervisor.c
drivers/virt/nitro_enclaves/Kconfig [new file with mode: 0644]
drivers/virt/nitro_enclaves/Makefile [new file with mode: 0644]
drivers/virt/nitro_enclaves/ne_misc_dev.c [new file with mode: 0644]
drivers/virt/nitro_enclaves/ne_misc_dev.h [new file with mode: 0644]
drivers/virt/nitro_enclaves/ne_pci_dev.c [new file with mode: 0644]
drivers/virt/nitro_enclaves/ne_pci_dev.h [new file with mode: 0644]
drivers/virt/vboxguest/vboxguest_linux.c
drivers/watchdog/sc1200wdt.c
drivers/watchdog/wdrtas.c
drivers/xen/Kconfig
drivers/xen/Makefile
drivers/xen/balloon.c
drivers/xen/events/events_base.c
drivers/xen/grant-table.c
drivers/xen/privcmd.c
drivers/xen/pvcalls-front.c
drivers/xen/unpopulated-alloc.c [new file with mode: 0644]
drivers/xen/xen-acpi-memhotplug.c
drivers/xen/xen-pciback/xenbus.c
drivers/xen/xen-scsiback.c
drivers/xen/xenbus/xenbus_client.c
drivers/xen/xenbus/xenbus_probe_frontend.c
drivers/xen/xlate_mmu.c
fs/9p/vfs_file.c
fs/adfs/dir_f.c
fs/affs/amigaffs.c
fs/affs/file.c
fs/affs/inode.c
fs/affs/super.c
fs/afs/cmservice.c
fs/afs/dynroot.c
fs/afs/file.c
fs/afs/flock.c
fs/afs/fs_operation.c
fs/afs/fs_probe.c
fs/afs/fsclient.c
fs/afs/internal.h
fs/afs/misc.c
fs/afs/proc.c
fs/afs/rotate.c
fs/afs/rxrpc.c
fs/afs/vl_list.c
fs/afs/vl_probe.c
fs/afs/vl_rotate.c
fs/afs/vlclient.c
fs/afs/write.c
fs/afs/yfsclient.c
fs/aio.c
fs/binfmt_flat.c
fs/btrfs/block-group.c
fs/btrfs/ctree.c
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/file.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-tree.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/print-tree.c
fs/btrfs/scrub.c
fs/btrfs/super.c
fs/btrfs/transaction.c
fs/btrfs/tree-checker.c
fs/btrfs/tree-log.c
fs/btrfs/volumes.c
fs/buffer.c
fs/ceph/caps.c
fs/ceph/debugfs.c
fs/ceph/dir.c
fs/ceph/file.c
fs/ceph/inode.c
fs/ceph/mds_client.h
fs/ceph/quota.c
fs/ceph/super.h
fs/cifs/cifsglob.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/inode.c
fs/cifs/sess.c
fs/cifs/smb2pdu.c
fs/configfs/dir.c
fs/dax.c
fs/debugfs/file.c
fs/dlm/lock.c
fs/erofs/zmap.c
fs/eventpoll.c
fs/ext2/file.c
fs/ext2/inode.c
fs/ext2/super.c
fs/ext4/Kconfig
fs/ext4/balloc.c
fs/ext4/block_validity.c
fs/ext4/ext4.h
fs/ext4/ext4_jbd2.c
fs/ext4/extents.c
fs/ext4/file.c
fs/ext4/hash.c
fs/ext4/indirect.c
fs/ext4/inline.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/mballoc.c
fs/ext4/mballoc.h
fs/ext4/move_extent.c
fs/ext4/namei.c
fs/ext4/readpage.c
fs/ext4/super.c
fs/ext4/sysfs.c
fs/ext4/xattr.c
fs/f2fs/data.c
fs/f2fs/f2fs.h
fs/f2fs/node.c
fs/f2fs/segment.c
fs/fcntl.c
fs/fs-writeback.c
fs/fs_context.c
fs/fsopen.c
fs/gfs2/bmap.c
fs/gfs2/log.c
fs/gfs2/quota.c
fs/gfs2/trans.c
fs/hfsplus/wrapper.c
fs/io-wq.c
fs/io_uring.c
fs/iomap/seek.c
fs/jbd2/journal.c
fs/jbd2/recovery.c
fs/jbd2/transaction.c
fs/jffs2/fs.c
fs/jffs2/readinode.c
fs/libfs.c
fs/locks.c
fs/nfs/blocklayout/blocklayout.c
fs/nfs/dir.c
fs/nfs/filelayout/filelayout.c
fs/nfs/flexfilelayout/flexfilelayout.c
fs/nfs/fs_context.c
fs/nfs/nfs3acl.c
fs/nfs/nfs4file.c
fs/nfs/nfs4idmap.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c
fs/nfs/pagelist.c
fs/nfs/pnfs.c
fs/nfs_common/nfsacl.c
fs/nfsd/blocklayout.c
fs/nfsd/nfs4callback.c
fs/nfsd/nfs4layouts.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/nfsfh.c
fs/nfsd/nfsproc.c
fs/nfsd/nfssvc.c
fs/nfsd/vfs.c
fs/nilfs2/bmap.c
fs/nilfs2/recovery.c
fs/nilfs2/segment.c
fs/notify/fanotify/fanotify_user.c
fs/ocfs2/cluster/quorum.c
fs/pstore/zone.c
fs/quota/quota.c
fs/romfs/storage.c
fs/seq_file.c
fs/signalfd.c
fs/squashfs/block.c
fs/ubifs/lprops.c
fs/udf/symlink.c
fs/ufs/util.h
fs/vboxsf/utils.c
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_trans_inode.c
fs/xfs/libxfs/xfs_trans_space.h
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_file.c
include/drm/drm_hdcp.h
include/drm/drm_modeset_lock.h
include/dt-bindings/interconnect/qcom,icc.h [new file with mode: 0644]
include/dt-bindings/interconnect/qcom,osm-l3.h
include/dt-bindings/interconnect/qcom,sm8150.h [new file with mode: 0644]
include/dt-bindings/interconnect/qcom,sm8250.h [new file with mode: 0644]
include/linux/bvec.h
include/linux/ceph/ceph_features.h
include/linux/compat.h
include/linux/compiler_attributes.h
include/linux/compiler_types.h
include/linux/coresight.h
include/linux/cpufreq.h
include/linux/cpuhotplug.h
include/linux/cpuidle.h
include/linux/device.h
include/linux/dma-direct.h
include/linux/dma-mapping.h
include/linux/dynamic_debug.h
include/linux/efi_embedded_fw.h
include/linux/entry-common.h
include/linux/filter.h
include/linux/fs.h
include/linux/hid.h
include/linux/i2c-algo-pca.h
include/linux/interconnect-provider.h
include/linux/interconnect.h
include/linux/irqflags.h
include/linux/jbd2.h
include/linux/jhash.h
include/linux/kernel.h
include/linux/ksm.h
include/linux/kvm_host.h
include/linux/libata.h
include/linux/lockdep.h
include/linux/log2.h
include/linux/memremap.h
include/linux/miscdevice.h
include/linux/mm.h
include/linux/mmu_context.h
include/linux/netfilter/nf_conntrack_sctp.h
include/linux/netfilter/nfnetlink.h
include/linux/netfilter_ipv6.h
include/linux/nitro_enclaves.h [new file with mode: 0644]
include/linux/pgtable.h
include/linux/phylink.h
include/linux/powercap.h
include/linux/sched.h
include/linux/sched/user.h
include/linux/signal.h
include/linux/skbuff.h
include/linux/soc/ti/ti_sci_protocol.h
include/linux/spi/eeprom.h
include/linux/vm_event_item.h
include/math-emu/op-common.h
include/net/addrconf.h
include/net/af_rxrpc.h
include/net/ndisc.h
include/net/netfilter/nf_tables.h
include/soc/nps/common.h
include/trace/events/ext4.h
include/trace/events/mmflags.h
include/trace/events/rxrpc.h
include/trace/events/writeback.h
include/uapi/linux/bpf.h
include/uapi/linux/coresight-stm.h
include/uapi/linux/in.h
include/uapi/linux/kvm.h
include/uapi/linux/mei.h
include/uapi/linux/netfilter/nf_tables.h
include/uapi/linux/nitro_enclaves.h [new file with mode: 0644]
include/uapi/misc/fastrpc.h
include/uapi/misc/habanalabs.h
include/xen/arm/page.h
include/xen/balloon.h
include/xen/xen.h
init/initramfs.c
ipc/ipc_sysctl.c
ipc/sem.c
ipc/shm.c
kernel/auditfilter.c
kernel/bpf/bpf_iter.c
kernel/bpf/cgroup.c
kernel/bpf/cpumap.c
kernel/bpf/stackmap.c
kernel/bpf/syscall.c
kernel/bpf/task_iter.c
kernel/bpf/verifier.c
kernel/capability.c
kernel/compat.c
kernel/debug/gdbstub.c
kernel/debug/kdb/kdb_keyboard.c
kernel/debug/kdb/kdb_support.c
kernel/dma/direct.c
kernel/dma/pool.c
kernel/entry/common.c
kernel/events/core.c
kernel/events/uprobes.c
kernel/fork.c
kernel/gcov/gcc_4_7.c
kernel/irq/handle.c
kernel/irq/manage.c
kernel/irq/matrix.c
kernel/kallsyms.c
kernel/locking/lockdep.c
kernel/padata.c
kernel/power/hibernate.c
kernel/power/qos.c
kernel/relay.c
kernel/sched/core.c
kernel/sched/idle.c
kernel/sched/topology.c
kernel/seccomp.c
kernel/signal.c
kernel/sys.c
kernel/sysctl.c
kernel/time/hrtimer.c
kernel/time/posix-timers.c
kernel/time/tick-broadcast.c
kernel/time/timer.c
kernel/trace/blktrace.c
kernel/trace/trace_events_filter.c
kernel/watch_queue.c
lib/Makefile
lib/bootconfig.c
lib/dynamic_debug.c
lib/glob.c
lib/kobject.c
lib/test_firmware.c
lib/vsprintf.c
lib/xz/xz_dec_lzma2.c
lib/xz/xz_dec_stream.c
lib/zstd/decompress.c
mm/gup.c
mm/huge_memory.c
mm/hugetlb.c
mm/hugetlb_cgroup.c
mm/khugepaged.c
mm/ksm.c
mm/madvise.c
mm/memcontrol.c
mm/memory.c
mm/memremap.c
mm/migrate.c
mm/page_alloc.c
mm/rmap.c
mm/rodata_test.c
mm/slub.c
mm/vmalloc.c
mm/vmscan.c
mm/vmstat.c
net/8021q/vlan_dev.c
net/9p/trans_xen.c
net/atm/common.c
net/atm/lec.c
net/atm/resources.c
net/batman-adv/bat_v_ogm.c
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/gateway_client.c
net/bpf/test_run.c
net/bridge/netfilter/ebtables.c
net/bridge/netfilter/nf_conntrack_bridge.c
net/caif/cfrfml.c
net/can/j1939/socket.c
net/can/j1939/transport.c
net/ceph/ceph_hash.c
net/ceph/crush/mapper.c
net/ceph/messenger.c
net/ceph/mon_client.c
net/ceph/osd_client.c
net/core/dev.c
net/core/dev_ioctl.c
net/core/devlink.c
net/core/drop_monitor.c
net/core/filter.c
net/core/netpoll.c
net/core/pktgen.c
net/core/skbuff.c
net/core/skmsg.c
net/core/sock.c
net/dccp/ccids/ccid3.c
net/dccp/feat.c
net/dccp/input.c
net/dccp/options.c
net/dccp/output.c
net/dccp/proto.c
net/decnet/af_decnet.c
net/decnet/dn_nsp_in.c
net/decnet/dn_table.c
net/decnet/sysctl_net_decnet.c
net/dsa/slave.c
net/ethtool/features.c
net/ieee802154/6lowpan/reassembly.c
net/ieee802154/6lowpan/rx.c
net/ipv4/Kconfig
net/ipv4/fib_trie.c
net/ipv4/netfilter/nf_nat_pptp.c
net/ipv4/nexthop.c
net/ipv4/raw.c
net/ipv6/addrconf.c
net/ipv6/ip6_tunnel.c
net/ipv6/netfilter.c
net/ipv6/sysctl_net_ipv6.c
net/iucv/af_iucv.c
net/l3mdev/l3mdev.c
net/mac80211/airtime.c
net/mac80211/sta_info.h
net/mac80211/status.c
net/mpls/af_mpls.c
net/mptcp/protocol.c
net/ncsi/ncsi-manage.c
net/netfilter/ipvs/ip_vs_proto_tcp.c
net/netfilter/ipvs/ip_vs_proto_udp.c
net/netfilter/nf_conntrack_pptp.c
net/netfilter/nf_conntrack_proto_sctp.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_proto_udp.c
net/netfilter/nf_tables_api.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_log.c
net/netfilter/nfnetlink_queue.c
net/netfilter/nft_compat.c
net/netfilter/nft_exthdr.c
net/netfilter/nft_flow_offload.c
net/netfilter/nft_payload.c
net/netfilter/nft_set_rbtree.c
net/netfilter/xt_recent.c
net/netlabel/netlabel_domainhash.c
net/netlink/af_netlink.c
net/netlink/policy.c
net/netrom/nr_in.c
net/netrom/nr_route.c
net/openvswitch/conntrack.c
net/openvswitch/flow.c
net/packet/af_packet.c
net/phonet/pep.c
net/qrtr/qrtr.c
net/rds/send.c
net/rose/rose_in.c
net/rose/rose_route.c
net/rxrpc/af_rxrpc.c
net/rxrpc/ar-internal.h
net/rxrpc/call_accept.c
net/rxrpc/call_object.c
net/rxrpc/conn_client.c
net/rxrpc/input.c
net/rxrpc/local_object.c
net/rxrpc/output.c
net/rxrpc/peer_event.c
net/rxrpc/peer_object.c
net/rxrpc/recvmsg.c
net/rxrpc/rtt.c
net/rxrpc/rxkad.c
net/rxrpc/sendmsg.c
net/sched/act_ct.c
net/sched/sch_cake.c
net/sched/sch_red.c
net/sched/sch_taprio.c
net/sctp/ipv6.c
net/sctp/outqueue.c
net/sctp/sm_make_chunk.c
net/sctp/sm_sideeffect.c
net/sctp/sm_statefuns.c
net/sctp/socket.c
net/sctp/stream.c
net/smc/smc_close.c
net/smc/smc_core.c
net/smc/smc_diag.c
net/smc/smc_llc.c
net/socket.c
net/sunrpc/auth_gss/gss_krb5_wrap.c
net/sunrpc/auth_gss/trace.c
net/sunrpc/clnt.c
net/sunrpc/rpcb_clnt.c
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtsock.c
net/tipc/Kconfig
net/tipc/bearer.c
net/tipc/crypto.c
net/tipc/group.c
net/tipc/link.c
net/tipc/netlink_compat.c
net/tipc/socket.c
net/tipc/udp_media.c
net/unix/af_unix.c
net/wireless/chan.c
net/wireless/mlme.c
net/wireless/nl80211.c
net/wireless/reg.c
net/wireless/scan.c
net/wireless/sme.c
net/wireless/util.c
net/wireless/wext-compat.c
net/x25/x25_facilities.c
net/x25/x25_in.c
net/xfrm/xfrm_policy.c
samples/bpf/hbm.c
samples/nitro_enclaves/.gitignore [new file with mode: 0644]
samples/nitro_enclaves/Makefile [new file with mode: 0644]
samples/nitro_enclaves/ne_ioctl_sample.c [new file with mode: 0644]
scripts/Makefile.extrawarn
scripts/checkpatch.pl
scripts/extract-cert.c
scripts/genksyms/keywords.c
scripts/kconfig/nconf.c
scripts/kconfig/qconf.cc
scripts/kconfig/qconf.h
scripts/kconfig/streamline_config.pl
scripts/tags.sh
security/apparmor/domain.c
security/apparmor/lib.c
security/integrity/ima/ima_appraise.c
security/integrity/ima/ima_policy.c
security/integrity/ima/ima_template_lib.c
security/keys/process_keys.c
security/keys/request_key.c
security/selinux/hooks.c
security/selinux/ss/mls.c
security/smack/smack_lsm.c
security/tomoyo/common.c
security/tomoyo/file.c
sound/core/oss/mulaw.c
sound/core/timer.c
sound/firewire/amdtp-stream.c
sound/firewire/digi00x/digi00x.c
sound/firewire/tascam/tascam.c
sound/hda/hdac_bus.c
sound/hda/hdac_controller.c
sound/hda/hdac_device.c
sound/hda/intel-dsp-config.c
sound/isa/sscape.c
sound/pci/asihpi/asihpi.c
sound/pci/ca0106/ca0106_main.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_tegra.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/riptide/riptide.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/ppc/snd_ps3.c
sound/soc/amd/acp3x-rt5682-max9836.c
sound/soc/amd/renoir/acp3x-pdm-dma.c
sound/soc/atmel/mchp-i2s-mcc.c
sound/soc/codecs/jz4770.c
sound/soc/codecs/msm8916-wcd-analog.c
sound/soc/codecs/pcm186x.c
sound/soc/codecs/wm8958-dsp2.c
sound/soc/codecs/wm8962.c
sound/soc/codecs/wm8994.c
sound/soc/fsl/fsl-asoc-card.c
sound/soc/fsl/fsl_esai.c
sound/soc/fsl/fsl_ssi.c
sound/soc/fsl/mpc5200_dma.c
sound/soc/hisilicon/hi6210-i2s.c
sound/soc/intel/atom/sst-mfld-platform-pcm.c
sound/soc/intel/baytrail/sst-baytrail-pcm.c
sound/soc/intel/boards/bytcht_es8316.c
sound/soc/intel/boards/bytcr_rt5651.c
sound/soc/intel/skylake/skl-pcm.c
sound/soc/meson/axg-tdm-interface.c
sound/soc/pxa/pxa-ssp.c
sound/soc/qcom/qdsp6/q6afe-dai.c
sound/soc/qcom/qdsp6/q6routing.c
sound/soc/rockchip/rockchip_pdm.c
sound/soc/samsung/i2s.c
sound/soc/sh/siu_pcm.c
sound/soc/soc-component.c
sound/soc/soc-core.c
sound/soc/soc-topology.c
sound/soc/sof/intel/hda-dai.c
sound/soc/sof/pcm.c
sound/soc/tegra/tegra186_dspk.c
sound/soc/tegra/tegra210_admaif.c
sound/soc/tegra/tegra210_ahub.c
sound/soc/tegra/tegra210_dmic.c
sound/soc/tegra/tegra210_i2s.c
sound/soc/ti/davinci-i2s.c
sound/soc/ti/n810.c
sound/soc/ti/omap-dmic.c
sound/soc/ti/omap-mcpdm.c
sound/soc/ti/rx51.c
sound/soc/txx9/txx9aclc.c
sound/soc/zte/zx-i2s.c
sound/soc/zte/zx-spdif.c
sound/usb/midi.c
sound/usb/misc/ua101.c
sound/usb/mixer.c
sound/usb/pcm.c
sound/usb/quirks-table.h
sound/usb/quirks.c
sound/usb/usbaudio.h
sound/x86/Kconfig
tools/bpf/bpftool/btf_dumper.c
tools/bpf/bpftool/gen.c
tools/bpf/bpftool/link.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/pids.c
tools/bpf/bpftool/prog.c
tools/bpf/resolve_btfids/main.c
tools/include/uapi/linux/bpf.h
tools/include/uapi/linux/perf_event.h
tools/lib/bpf/bpf_helpers.h
tools/lib/bpf/btf.c
tools/lib/bpf/btf.h
tools/lib/bpf/btf_dump.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.map
tools/lib/traceevent/event-parse.c
tools/perf/Documentation/perf-record.txt
tools/perf/Documentation/perf-stat.txt
tools/perf/bench/synthesize.c
tools/perf/builtin-record.c
tools/perf/builtin-report.c
tools/perf/builtin-sched.c
tools/perf/builtin-stat.c
tools/perf/builtin-top.c
tools/perf/pmu-events/jevents.c
tools/perf/tests/bpf.c
tools/perf/tests/parse-events.c
tools/perf/tests/parse-metric.c
tools/perf/ui/browsers/hists.c
tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
tools/perf/util/cs-etm.c
tools/perf/util/intel-pt.c
tools/perf/util/machine.c
tools/perf/util/map.c
tools/perf/util/map.h
tools/perf/util/parse-events.c
tools/perf/util/parse-events.y
tools/perf/util/session.c
tools/perf/util/stat-display.c
tools/perf/util/stat.h
tools/perf/util/symbol.c
tools/perf/util/zstd.c
tools/testing/selftests/bpf/.gitignore
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c
tools/testing/selftests/bpf/prog_tests/btf_dump.c
tools/testing/selftests/bpf/prog_tests/core_extern.c
tools/testing/selftests/bpf/prog_tests/core_reloc.c
tools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c
tools/testing/selftests/bpf/prog_tests/flow_dissector.c
tools/testing/selftests/bpf/prog_tests/global_data.c
tools/testing/selftests/bpf/prog_tests/mmap.c
tools/testing/selftests/bpf/prog_tests/prog_run_xattr.c
tools/testing/selftests/bpf/prog_tests/sk_lookup.c
tools/testing/selftests/bpf/prog_tests/skb_ctx.c
tools/testing/selftests/bpf/prog_tests/test_global_funcs.c
tools/testing/selftests/bpf/prog_tests/varlen.c
tools/testing/selftests/bpf/progs/core_reloc_types.h
tools/testing/selftests/bpf/progs/test_tcpbpf_kern.c
tools/testing/selftests/bpf/progs/test_varlen.c
tools/testing/selftests/bpf/test_btf.c
tools/testing/selftests/bpf/test_maps.c
tools/testing/selftests/bpf/test_progs.c
tools/testing/selftests/bpf/test_progs.h
tools/testing/selftests/kvm/x86_64/debug_regs.c
tools/testing/selftests/lkdtm/run.sh
tools/testing/selftests/net/icmp_redirect.sh
tools/testing/selftests/netfilter/nft_flowtable.sh
tools/testing/selftests/powerpc/mm/.gitignore
tools/testing/selftests/powerpc/mm/Makefile
tools/testing/selftests/powerpc/mm/prot_sao.c [new file with mode: 0644]
tools/testing/selftests/timers/Makefile
tools/testing/selftests/timers/settings [new file with mode: 0644]
tools/testing/selftests/x86/test_vsyscall.c
tools/usb/Build [new file with mode: 0644]
tools/usb/Makefile
virt/kvm/kvm_main.c

index a0a9608..badfc1b 100644 (file)
@@ -111,6 +111,7 @@ ForEachMacros:
   - 'css_for_each_descendant_pre'
   - 'device_for_each_child_node'
   - 'dma_fence_chain_for_each'
+  - 'do_for_each_ftrace_op'
   - 'drm_atomic_crtc_for_each_plane'
   - 'drm_atomic_crtc_state_for_each_plane'
   - 'drm_atomic_crtc_state_for_each_plane_state'
@@ -136,6 +137,7 @@ ForEachMacros:
   - 'for_each_active_dev_scope'
   - 'for_each_active_drhd_unit'
   - 'for_each_active_iommu'
+  - 'for_each_aggr_pgid'
   - 'for_each_available_child_of_node'
   - 'for_each_bio'
   - 'for_each_board_func_rsrc'
@@ -234,6 +236,7 @@ ForEachMacros:
   - 'for_each_node_state'
   - 'for_each_node_with_cpus'
   - 'for_each_node_with_property'
+  - 'for_each_nonreserved_multicast_dest_pgid'
   - 'for_each_of_allnodes'
   - 'for_each_of_allnodes_from'
   - 'for_each_of_cpu_node'
@@ -256,6 +259,7 @@ ForEachMacros:
   - 'for_each_pci_dev'
   - 'for_each_pci_msi_entry'
   - 'for_each_pcm_streams'
+  - 'for_each_physmem_range'
   - 'for_each_populated_zone'
   - 'for_each_possible_cpu'
   - 'for_each_present_cpu'
@@ -265,6 +269,8 @@ ForEachMacros:
   - 'for_each_process_thread'
   - 'for_each_property_of_node'
   - 'for_each_registered_fb'
+  - 'for_each_requested_gpio'
+  - 'for_each_requested_gpio_in_range'
   - 'for_each_reserved_mem_region'
   - 'for_each_rtd_codec_dais'
   - 'for_each_rtd_codec_dais_rollback'
@@ -278,12 +284,17 @@ ForEachMacros:
   - 'for_each_sg'
   - 'for_each_sg_dma_page'
   - 'for_each_sg_page'
+  - 'for_each_sgtable_dma_page'
+  - 'for_each_sgtable_dma_sg'
+  - 'for_each_sgtable_page'
+  - 'for_each_sgtable_sg'
   - 'for_each_sibling_event'
   - 'for_each_subelement'
   - 'for_each_subelement_extid'
   - 'for_each_subelement_id'
   - '__for_each_thread'
   - 'for_each_thread'
+  - 'for_each_unicast_dest_pgid'
   - 'for_each_wakeup_source'
   - 'for_each_zone'
   - 'for_each_zone_zonelist'
@@ -464,6 +475,7 @@ ForEachMacros:
   - 'v4l2_m2m_for_each_src_buf'
   - 'v4l2_m2m_for_each_src_buf_safe'
   - 'virtio_device_for_each_vq'
+  - 'while_for_each_ftrace_op'
   - 'xa_for_each'
   - 'xa_for_each_marked'
   - 'xa_for_each_range'
index 57fe008..50096b9 100644 (file)
--- a/.mailmap
+++ b/.mailmap
 Aaron Durbin <adurbin@google.com>
 Adam Oldham <oldhamca@gmail.com>
 Adam Radford <aradford@gmail.com>
-Adrian Bunk <bunk@stusta.de>
 Adriana Reus <adi.reus@gmail.com> <adriana.reus@intel.com>
+Adrian Bunk <bunk@stusta.de>
 Alan Cox <alan@lxorguk.ukuu.org.uk>
 Alan Cox <root@hraefn.swansea.linux.org.uk>
-Aleksey Gorelov <aleksey_gorelov@phoenix.com>
 Aleksandar Markovic <aleksandar.markovic@mips.com> <aleksandar.markovic@imgtec.com>
-Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@intel.com>
-Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@linaro.org>
+Aleksey Gorelov <aleksey_gorelov@phoenix.com>
 Alexander Lobakin <alobakin@pm.me> <alobakin@dlink.ru>
 Alexander Lobakin <alobakin@pm.me> <alobakin@marvell.com>
 Alexander Lobakin <alobakin@pm.me> <bloodyreaper@yandex.ru>
 Alexandre Belloni <alexandre.belloni@bootlin.com> <alexandre.belloni@free-electrons.com>
-Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>
 Alexei Starovoitov <ast@kernel.org> <alexei.starovoitov@gmail.com>
 Alexei Starovoitov <ast@kernel.org> <ast@fb.com>
+Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>
+Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@intel.com>
+Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@linaro.org>
 Al Viro <viro@ftp.linux.org.uk>
 Al Viro <viro@zenIV.linux.org.uk>
+Andi Kleen <ak@linux.intel.com> <ak@suse.de>
 Andi Shyti <andi@etezian.org> <andi.shyti@samsung.com>
 Andreas Herrmann <aherrman@de.ibm.com>
-Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com>
 Andrew Morton <akpm@linux-foundation.org>
-Andrew Murray <amurray@thegoodpenguin.co.uk> <andrew.murray@arm.com>
 Andrew Murray <amurray@thegoodpenguin.co.uk> <amurray@embedded-bits.co.uk>
+Andrew Murray <amurray@thegoodpenguin.co.uk> <andrew.murray@arm.com>
 Andrew Vasquez <andrew.vasquez@qlogic.com>
+Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com>
 Andy Adamson <andros@citi.umich.edu>
 Antoine Tenart <antoine.tenart@free-electrons.com>
 Antonio Ospite <ao2@ao2.it> <ao2@amarulasolutions.com>
@@ -48,40 +49,42 @@ Arnaud Patard <arnaud.patard@rtp-net.org>
 Arnd Bergmann <arnd@arndb.de>
 Axel Dyks <xl@xlsigned.net>
 Axel Lin <axel.lin@gmail.com>
-Bart Van Assche <bvanassche@acm.org> <bart.vanassche@wdc.com>
 Bart Van Assche <bvanassche@acm.org> <bart.vanassche@sandisk.com>
+Bart Van Assche <bvanassche@acm.org> <bart.vanassche@wdc.com>
 Ben Gardner <bgardner@wabtec.com>
 Ben M Cahill <ben.m.cahill@intel.com>
 Björn Steinbrink <B.Steinbrink@gmx.de>
-Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@bootlin.com>
-Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@free-electrons.com>
 Boris Brezillon <bbrezillon@kernel.org> <b.brezillon.dev@gmail.com>
 Boris Brezillon <bbrezillon@kernel.org> <b.brezillon@overkiz.com>
+Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@bootlin.com>
+Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@free-electrons.com>
 Brian Avery <b.avery@hp.com>
 Brian King <brking@us.ibm.com>
+Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>
+Changbin Du <changbin.du@intel.com> <changbin.du@intel.com>
 Chao Yu <chao@kernel.org> <chao2.yu@samsung.com>
 Chao Yu <chao@kernel.org> <yuchao0@huawei.com>
-Christoph Hellwig <hch@lst.de>
 Christophe Ricard <christophe.ricard@gmail.com>
+Christoph Hellwig <hch@lst.de>
 Corey Minyard <minyard@acm.org>
 Damian Hobson-Garcia <dhobsong@igel.co.jp>
-Daniel Borkmann <daniel@iogearbox.net> <dborkman@redhat.com>
-Daniel Borkmann <daniel@iogearbox.net> <dborkmann@redhat.com>
+Daniel Borkmann <daniel@iogearbox.net> <danborkmann@googlemail.com>
 Daniel Borkmann <daniel@iogearbox.net> <danborkmann@iogearbox.net>
 Daniel Borkmann <daniel@iogearbox.net> <daniel.borkmann@tik.ee.ethz.ch>
-Daniel Borkmann <daniel@iogearbox.net> <danborkmann@googlemail.com>
+Daniel Borkmann <daniel@iogearbox.net> <dborkmann@redhat.com>
+Daniel Borkmann <daniel@iogearbox.net> <dborkman@redhat.com>
 Daniel Borkmann <daniel@iogearbox.net> <dxchgb@gmail.com>
 David Brownell <david-b@pacbell.net>
 David Woodhouse <dwmw2@shinybook.infradead.org>
-Dengcheng Zhu <dzhu@wavecomp.com> <dengcheng.zhu@mips.com>
-Dengcheng Zhu <dzhu@wavecomp.com> <dengcheng.zhu@imgtec.com>
 Dengcheng Zhu <dzhu@wavecomp.com> <dczhu@mips.com>
 Dengcheng Zhu <dzhu@wavecomp.com> <dengcheng.zhu@gmail.com>
+Dengcheng Zhu <dzhu@wavecomp.com> <dengcheng.zhu@imgtec.com>
+Dengcheng Zhu <dzhu@wavecomp.com> <dengcheng.zhu@mips.com>
 <dev.kurt@vandijck-laurijssen.be> <kurt.van.dijck@eia.be>
 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
-Dmitry Safonov <0x7f454c46@gmail.com> <dsafonov@virtuozzo.com>
-Dmitry Safonov <0x7f454c46@gmail.com> <d.safonov@partner.samsung.com>
 Dmitry Safonov <0x7f454c46@gmail.com> <dima@arista.com>
+Dmitry Safonov <0x7f454c46@gmail.com> <d.safonov@partner.samsung.com>
+Dmitry Safonov <0x7f454c46@gmail.com> <dsafonov@virtuozzo.com>
 Domen Puncer <domen@coderock.org>
 Douglas Gilbert <dougg@torque.net>
 Ed L. Cashin <ecashin@coraid.com>
@@ -92,20 +95,22 @@ Felix Kuhling <fxkuehl@gmx.de>
 Felix Moeller <felix@derklecks.de>
 Filipe Lautert <filipe@icewall.org>
 Franck Bui-Huu <vagabon.xyz@gmail.com>
-Frank Rowand <frowand.list@gmail.com> <frowand@mvista.com>
 Frank Rowand <frowand.list@gmail.com> <frank.rowand@am.sony.com>
 Frank Rowand <frowand.list@gmail.com> <frank.rowand@sonymobile.com>
+Frank Rowand <frowand.list@gmail.com> <frowand@mvista.com>
 Frank Zago <fzago@systemfabricworks.com>
 Gao Xiang <xiang@kernel.org> <gaoxiang25@huawei.com>
 Gao Xiang <xiang@kernel.org> <hsiangkao@aol.com>
-Gerald Schaefer <gerald.schaefer@linux.ibm.com> <gerald.schaefer@de.ibm.com>
 Gerald Schaefer <gerald.schaefer@linux.ibm.com> <geraldsc@de.ibm.com>
+Gerald Schaefer <gerald.schaefer@linux.ibm.com> <gerald.schaefer@de.ibm.com>
 Gerald Schaefer <gerald.schaefer@linux.ibm.com> <geraldsc@linux.vnet.ibm.com>
 Greg Kroah-Hartman <greg@echidna.(none)>
 Greg Kroah-Hartman <gregkh@suse.de>
 Greg Kroah-Hartman <greg@kroah.com>
 Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com>
 Gregory CLEMENT <gregory.clement@bootlin.com> <gregory.clement@free-electrons.com>
+Gustavo Padovan <gustavo@las.ic.unicamp.br>
+Gustavo Padovan <padovan@profusion.mobi>
 Hanjun Guo <guohanjun@huawei.com> <hanjun.guo@linaro.org>
 Heiko Carstens <hca@linux.ibm.com> <h.carstens@de.ibm.com>
 Heiko Carstens <hca@linux.ibm.com> <heiko.carstens@de.ibm.com>
@@ -115,32 +120,33 @@ Henrik Rydberg <rydberg@bitmath.org>
 Herbert Xu <herbert@gondor.apana.org.au>
 Jacob Shin <Jacob.Shin@amd.com>
 Jaegeuk Kim <jaegeuk@kernel.org> <jaegeuk@google.com>
-Jaegeuk Kim <jaegeuk@kernel.org> <jaegeuk@motorola.com>
 Jaegeuk Kim <jaegeuk@kernel.org> <jaegeuk.kim@samsung.com>
+Jaegeuk Kim <jaegeuk@kernel.org> <jaegeuk@motorola.com>
 Jakub Kicinski <kuba@kernel.org> <jakub.kicinski@netronome.com>
 James Bottomley <jejb@mulgrave.(none)>
 James Bottomley <jejb@titanic.il.steeleye.com>
 James E Wilson <wilson@specifix.com>
-James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
 James Hogan <jhogan@kernel.org> <james@albanarts.com>
+James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
 James Ketrenos <jketreno@io.(none)>
 Jan Glauber <jan.glauber@gmail.com> <jang@de.ibm.com>
 Jan Glauber <jan.glauber@gmail.com> <jang@linux.vnet.ibm.com>
 Jan Glauber <jan.glauber@gmail.com> <jglauber@cavium.com>
 Jason Gunthorpe <jgg@ziepe.ca> <jgg@mellanox.com>
+Jason Gunthorpe <jgg@ziepe.ca> <jgg@nvidia.com>
 Jason Gunthorpe <jgg@ziepe.ca> <jgunthorpe@obsidianresearch.com>
-Javi Merino <javi.merino@kernel.org> <javi.merino@arm.com>
 <javier@osg.samsung.com> <javier.martinez@collabora.co.uk>
+Javi Merino <javi.merino@kernel.org> <javi.merino@arm.com>
 Jayachandran C <c.jayachandran@gmail.com> <jayachandranc@netlogicmicro.com>
 Jayachandran C <c.jayachandran@gmail.com> <jchandra@broadcom.com>
 Jayachandran C <c.jayachandran@gmail.com> <jchandra@digeo.com>
 Jayachandran C <c.jayachandran@gmail.com> <jnair@caviumnetworks.com>
-Jean Tourrilhes <jt@hpl.hp.com>
 <jean-philippe@linaro.org> <jean-philippe.brucker@arm.com>
+Jean Tourrilhes <jt@hpl.hp.com>
 Jeff Garzik <jgarzik@pretzel.yyz.us>
-Jeff Layton <jlayton@kernel.org> <jlayton@redhat.com>
 Jeff Layton <jlayton@kernel.org> <jlayton@poochiereds.net>
 Jeff Layton <jlayton@kernel.org> <jlayton@primarydata.com>
+Jeff Layton <jlayton@kernel.org> <jlayton@redhat.com>
 Jens Axboe <axboe@suse.de>
 Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
 Jiri Slaby <jirislaby@kernel.org> <jirislaby@gmail.com>
@@ -164,30 +170,31 @@ Julien Thierry <julien.thierry.kdev@gmail.com> <julien.thierry@arm.com>
 Kamil Konieczny <k.konieczny@samsung.com> <k.konieczny@partner.samsung.com>
 Kay Sievers <kay.sievers@vrfy.org>
 Kenneth W Chen <kenneth.w.chen@intel.com>
-Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>
 Konstantin Khlebnikov <koct9i@gmail.com> <khlebnikov@yandex-team.ru>
+Konstantin Khlebnikov <koct9i@gmail.com> <k.khlebnikov@samsung.com>
 Koushik <raghavendra.koushik@neterion.com>
-Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski@samsung.com>
 Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski.k@gmail.com>
+Krzysztof Kozlowski <krzk@kernel.org> <k.kozlowski@samsung.com>
 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
-Leon Romanovsky <leon@kernel.org> <leon@leon.nu>
-Leon Romanovsky <leon@kernel.org> <leonro@mellanox.com>
 Leonardo Bras <leobras.c@gmail.com> <leonardo@linux.ibm.com>
 Leonid I Ananiev <leonid.i.ananiev@intel.com>
+Leon Romanovsky <leon@kernel.org> <leon@leon.nu>
+Leon Romanovsky <leon@kernel.org> <leonro@mellanox.com>
+Leon Romanovsky <leon@kernel.org> <leonro@nvidia.com>
 Linas Vepstas <linas@austin.ibm.com>
-Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@web.de>
 Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@ascom.ch>
-Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org>
+Linus Lüssing <linus.luessing@c0d3.blue> <linus.luessing@web.de>
 Li Yang <leoyang.li@nxp.com> <leoli@freescale.com>
+Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org>
 Lukasz Luba <lukasz.luba@arm.com> <l.luba@partner.samsung.com>
 Maciej W. Rozycki <macro@mips.com> <macro@imgtec.com>
-Marc Zyngier <maz@kernel.org> <marc.zyngier@arm.com>
 Marcin Nowakowski <marcin.nowakowski@mips.com> <marcin.nowakowski@imgtec.com>
+Marc Zyngier <maz@kernel.org> <marc.zyngier@arm.com>
 Mark Brown <broonie@sirena.org.uk>
 Mark Yao <markyao0591@gmail.com> <mark.yao@rock-chips.com>
-Martin Kepplinger <martink@posteo.de> <martin.kepplinger@theobroma-systems.com>
 Martin Kepplinger <martink@posteo.de> <martin.kepplinger@ginzinger.com>
 Martin Kepplinger <martink@posteo.de> <martin.kepplinger@puri.sm>
+Martin Kepplinger <martink@posteo.de> <martin.kepplinger@theobroma-systems.com>
 Mathieu Othacehe <m.othacehe@gmail.com>
 Matthew Wilcox <willy@infradead.org> <matthew.r.wilcox@intel.com>
 Matthew Wilcox <willy@infradead.org> <matthew@wil.cx>
@@ -197,17 +204,17 @@ Matthew Wilcox <willy@infradead.org> <willy@debian.org>
 Matthew Wilcox <willy@infradead.org> <willy@linux.intel.com>
 Matthew Wilcox <willy@infradead.org> <willy@parisc-linux.org>
 Matthieu CASTET <castet.matthieu@free.fr>
-Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@brturbo.com.br>
+Matt Ranostay <matt.ranostay@konsulko.com> <matt@ranostay.consulting>
+Matt Ranostay <mranostay@gmail.com> Matthew Ranostay <mranostay@embeddedalley.com>
+Matt Ranostay <mranostay@gmail.com> <matt.ranostay@intel.com>
+Matt Redfearn <matt.redfearn@mips.com> <matt.redfearn@imgtec.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <maurochehab@gmail.com>
+Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@brturbo.com.br>
 Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@infradead.org>
+Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@osg.samsung.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@redhat.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <m.chehab@samsung.com>
-Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@osg.samsung.com>
 Mauro Carvalho Chehab <mchehab@kernel.org> <mchehab@s-opensource.com>
-Matt Ranostay <mranostay@gmail.com> Matthew Ranostay <mranostay@embeddedalley.com>
-Matt Ranostay <mranostay@gmail.com> <matt.ranostay@intel.com>
-Matt Ranostay <matt.ranostay@konsulko.com> <matt@ranostay.consulting>
-Matt Redfearn <matt.redfearn@mips.com> <matt.redfearn@imgtec.com>
 Maxime Ripard <mripard@kernel.org> <maxime.ripard@bootlin.com>
 Maxime Ripard <mripard@kernel.org> <maxime.ripard@free-electrons.com>
 Mayuresh Janorkar <mayur@ti.com>
@@ -239,13 +246,13 @@ Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
 Patrick Mochel <mochel@digitalimplant.org>
 Paul Burton <paulburton@kernel.org> <paul.burton@imgtec.com>
 Paul Burton <paulburton@kernel.org> <paul.burton@mips.com>
+Paul E. McKenney <paulmck@kernel.org> <paul.mckenney@linaro.org>
 Paul E. McKenney <paulmck@kernel.org> <paulmck@linux.ibm.com>
 Paul E. McKenney <paulmck@kernel.org> <paulmck@linux.vnet.ibm.com>
-Paul E. McKenney <paulmck@kernel.org> <paul.mckenney@linaro.org>
 Paul E. McKenney <paulmck@kernel.org> <paulmck@us.ibm.com>
 Peter A Jonsson <pj@ludd.ltu.se>
-Peter Oruba <peter@oruba.de>
 Peter Oruba <peter.oruba@amd.com>
+Peter Oruba <peter@oruba.de>
 Pratyush Anand <pratyush.anand@gmail.com> <pratyush.anand@st.com>
 Praveen BP <praveenbp@ti.com>
 Punit Agrawal <punitagrawal@gmail.com> <punit.agrawal@arm.com>
@@ -258,23 +265,23 @@ Ralf Baechle <ralf@linux-mips.org>
 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
 Randy Dunlap <rdunlap@infradead.org> <rdunlap@xenotime.net>
 Rémi Denis-Courmont <rdenis@simphalempin.com>
-Ricardo Ribalda <ribalda@kernel.org> <ricardo.ribalda@gmail.com>
 Ricardo Ribalda <ribalda@kernel.org> <ricardo@ribalda.com>
 Ricardo Ribalda <ribalda@kernel.org> Ricardo Ribalda Delgado <ribalda@kernel.org>
+Ricardo Ribalda <ribalda@kernel.org> <ricardo.ribalda@gmail.com>
 Ross Zwisler <zwisler@kernel.org> <ross.zwisler@linux.intel.com>
 Rudolf Marek <R.Marek@sh.cvut.cz>
 Rui Saraiva <rmps@joel.ist.utl.pt>
 Sachin P Sant <ssant@in.ibm.com>
-Sarangdhar Joshi <spjoshi@codeaurora.org>
+Sakari Ailus <sakari.ailus@linux.intel.com> <sakari.ailus@iki.fi>
 Sam Ravnborg <sam@mars.ravnborg.org>
-Santosh Shilimkar <ssantosh@kernel.org>
 Santosh Shilimkar <santosh.shilimkar@oracle.org>
+Santosh Shilimkar <ssantosh@kernel.org>
+Sarangdhar Joshi <spjoshi@codeaurora.org>
 Sascha Hauer <s.hauer@pengutronix.de>
 S.ÇaÄŸlar Onur <caglar@pardus.org.tr>
-Sakari Ailus <sakari.ailus@linux.intel.com> <sakari.ailus@iki.fi>
 Sean Nyekjaer <sean@geanix.com> <sean.nyekjaer@prevas.dk>
-Sebastian Reichel <sre@kernel.org> <sre@debian.org>
 Sebastian Reichel <sre@kernel.org> <sebastian.reichel@collabora.co.uk>
+Sebastian Reichel <sre@kernel.org> <sre@debian.org>
 Sedat Dilek <sedat.dilek@gmail.com> <sedat.dilek@credativ.de>
 Shiraz Hashim <shiraz.linux.kernel@gmail.com> <shiraz.hashim@st.com>
 Shuah Khan <shuah@kernel.org> <shuahkhan@gmail.com>
@@ -285,19 +292,23 @@ Simon Arlott <simon@octiron.net> <simon@fire.lp0.eu>
 Simon Kelley <simon@thekelleys.org.uk>
 Stéphane Witzmann <stephane.witzmann@ubpmes.univ-bpclermont.fr>
 Stephen Hemminger <shemminger@osdl.org>
+Steve Wise <larrystevenwise@gmail.com> <swise@chelsio.com>
+Steve Wise <larrystevenwise@gmail.com> <swise@opengridcomputing.com>
 Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
 Subhash Jadavani <subhashj@codeaurora.org>
 Sudeep Holla <sudeep.holla@arm.com> Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
 Sumit Semwal <sumit.semwal@ti.com>
+Takashi YOSHII <takashi.yoshii.zj@renesas.com>
 Tejun Heo <htejun@gmail.com>
 Thomas Graf <tgraf@suug.ch>
 Thomas Pedersen <twp@codeaurora.org>
 Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>
 Todor Tomov <todor.too@gmail.com> <todor.tomov@linaro.org>
 Tony Luck <tony.luck@intel.com>
-TripleX Chung <xxx.phy@gmail.com> <zhongyu@18mail.cn>
 TripleX Chung <xxx.phy@gmail.com> <triplex@zh-kernel.org>
+TripleX Chung <xxx.phy@gmail.com> <zhongyu@18mail.cn>
 Tsuneo Yoshioka <Tsuneo.Yoshioka@f-secure.com>
+Tycho Andersen <tycho@tycho.pizza> <tycho@tycho.ws>
 Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
 Uwe Kleine-König <ukl@pengutronix.de>
 Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
@@ -305,22 +316,16 @@ Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
 Vinod Koul <vkoul@kernel.org> <vinod.koul@intel.com>
 Vinod Koul <vkoul@kernel.org> <vinod.koul@linux.intel.com>
 Vinod Koul <vkoul@kernel.org> <vkoul@infradead.org>
+Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com>
 Viresh Kumar <vireshk@kernel.org> <viresh.kumar@st.com>
 Viresh Kumar <vireshk@kernel.org> <viresh.linux@gmail.com>
-Viresh Kumar <vireshk@kernel.org> <viresh.kumar2@arm.com>
 Vivien Didelot <vivien.didelot@gmail.com> <vivien.didelot@savoirfairelinux.com>
 Vlad Dogaru <ddvlad@gmail.com> <vlad.dogaru@intel.com>
-Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com>
 Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@parallels.com>
-Takashi YOSHII <takashi.yoshii.zj@renesas.com>
+Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com>
+WeiXiong Liao <gmpy.liaowx@gmail.com> <liaoweixiong@allwinnertech.com>
 Will Deacon <will@kernel.org> <will.deacon@arm.com>
-Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>
 Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de>
+Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de>
 Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com>
 Yusuke Goda <goda.yusuke@renesas.com>
-Gustavo Padovan <gustavo@las.ic.unicamp.br>
-Gustavo Padovan <padovan@profusion.mobi>
-Changbin Du <changbin.du@intel.com> <changbin.du@intel.com>
-Changbin Du <changbin.du@intel.com> <changbin.du@gmail.com>
-Steve Wise <larrystevenwise@gmail.com> <swise@chelsio.com>
-Steve Wise <larrystevenwise@gmail.com> <swise@opengridcomputing.com>
diff --git a/Documentation/ABI/testing/sysfs-bus-dfl b/Documentation/ABI/testing/sysfs-bus-dfl
new file mode 100644 (file)
index 0000000..23543be
--- /dev/null
@@ -0,0 +1,15 @@
+What:          /sys/bus/dfl/devices/dfl_dev.X/type
+Date:          Aug 2020
+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
+Date:          Aug 2020
+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 f7e32f2..e82fc37 100644 (file)
@@ -43,7 +43,7 @@ Description:  read only
                This sysfs interface exposes the number of cores per chip
                present in the system.
 
-What:          /sys/devices/hv_24x7/interface/cpumask
+What:          /sys/devices/hv_24x7/cpumask
 Date:          July 2020
 Contact:       Linux on PowerPC Developer List <linuxppc-dev@lists.ozlabs.org>
 Description:   read only
index 320697b..d148214 100644 (file)
@@ -36,3 +36,11 @@ Contact:        linux-fsi@lists.ozlabs.org
 Description:
                Provides a means of reading/writing a 32 bit value from/to a
                specified FSI bus address.
+
+What:           /sys/bus/platform/devices/../cfam_reset
+Date:          Sept 2020
+KernelVersion:  5.10
+Contact:        linux-fsi@lists.ozlabs.org
+Description:
+               Provides a means of resetting the cfam that is attached to the
+               FSI device.
index 3d37e27..6e9a105 100644 (file)
@@ -41,6 +41,13 @@ Contact:     Tomas Winkler <tomas.winkler@intel.com>
 Description:   Stores mei client fixed address, if any
                Format: %d
 
+What:          /sys/bus/mei/devices/.../vtag
+Date:          Nov 2020
+KernelVersion: 5.9
+Contact:       Tomas Winkler <tomas.winkler@intel.com>
+Description:   Stores mei client vtag support status
+               Format: %d
+
 What:          /sys/bus/mei/devices/.../max_len
 Date:          Nov 2019
 KernelVersion: 5.5
index 1a14bf9..169ae4b 100644 (file)
@@ -2,13 +2,17 @@ What:           /sys/class/habanalabs/hl<n>/armcp_kernel_ver
 Date:           Jan 2019
 KernelVersion:  5.1
 Contact:        oded.gabbay@gmail.com
-Description:    Version of the Linux kernel running on the device's CPU
+Description:    Version of the Linux kernel running on the device's CPU.
+                Will be DEPRECATED in Linux kernel version 5.10, and be
+                replaced with cpucp_kernel_ver
 
 What:           /sys/class/habanalabs/hl<n>/armcp_ver
 Date:           Jan 2019
 KernelVersion:  5.1
 Contact:        oded.gabbay@gmail.com
 Description:    Version of the application running on the device's CPU
+                Will be DEPRECATED in Linux kernel version 5.10, and be
+                replaced with cpucp_ver
 
 What:           /sys/class/habanalabs/hl<n>/clk_max_freq_mhz
 Date:           Jun 2019
@@ -33,6 +37,18 @@ KernelVersion:  5.1
 Contact:        oded.gabbay@gmail.com
 Description:    Version of the Device's CPLD F/W
 
+What:           /sys/class/habanalabs/hl<n>/cpucp_kernel_ver
+Date:           Oct 2020
+KernelVersion:  5.10
+Contact:        oded.gabbay@gmail.com
+Description:    Version of the Linux kernel running on the device's CPU
+
+What:           /sys/class/habanalabs/hl<n>/cpucp_ver
+Date:           Oct 2020
+KernelVersion:  5.10
+Contact:        oded.gabbay@gmail.com
+Description:    Version of the application running on the device's CPU
+
 What:           /sys/class/habanalabs/hl<n>/device_type
 Date:           Jan 2019
 KernelVersion:  5.1
index f1fc8ae..cc860a0 100644 (file)
@@ -49,7 +49,7 @@ checking of rcu_dereference() primitives:
                is invoked by both RCU-sched readers and updaters.
        srcu_dereference_check(p, c):
                Use explicit check expression "c" along with
-               srcu_read_lock_held()().  This is useful in code that
+               srcu_read_lock_held().  This is useful in code that
                is invoked by both SRCU readers and updaters.
        rcu_dereference_raw(p):
                Don't check.  (Use sparingly, if at all.)
index d336f3f..63fd4e6 100644 (file)
 
   98 block     User-mode virtual block device
                  0 = /dev/ubda         First user-mode block device
-                16 = /dev/udbb         Second user-mode block device
+                16 = /dev/ubdb         Second user-mode block device
                    ...
 
                Partitions are handled in the same way as for IDE
index e5a8def..6c04aea 100644 (file)
@@ -156,7 +156,6 @@ against.  Possible keywords are:::
   ``line-range`` cannot contain space, e.g.
   "1-30" is valid range but "1 - 30" is not.
 
-  ``module=foo`` combined keyword=value form is interchangably accepted
 
 The meanings of each keyword are:
 
index a683976..d2795ca 100644 (file)
@@ -489,6 +489,9 @@ Files in /sys/fs/ext4/<devname>:
         multiple of this tuning parameter if the stripe size is not set in the
         ext4 superblock
 
+  mb_max_inode_prealloc
+        The maximum length of per-inode ext4_prealloc_space list.
+
   mb_max_to_scan
         The maximum number of extents the multiblock allocator will search to
         find the best extent.
@@ -529,21 +532,21 @@ Files in /sys/fs/ext4/<devname>:
 Ioctls
 ======
 
-There is some Ext4 specific functionality which can be accessed by applications
-through the system call interfaces. The list of all Ext4 specific ioctls are
-shown in the table below.
+Ext4 implements various ioctls which can be used by applications to access
+ext4-specific functionality. An incomplete list of these ioctls is shown in the
+table below. This list includes truly ext4-specific ioctls (``EXT4_IOC_*``) as
+well as ioctls that may have been ext4-specific originally but are now supported
+by some other filesystem(s) too (``FS_IOC_*``).
 
-Table of Ext4 specific ioctls
+Table of Ext4 ioctls
 
-  EXT4_IOC_GETFLAGS
+  FS_IOC_GETFLAGS
         Get additional attributes associated with inode.  The ioctl argument is
-        an integer bitfield, with bit values described in ext4.h. This ioctl is
-        an alias for FS_IOC_GETFLAGS.
+        an integer bitfield, with bit values described in ext4.h.
 
-  EXT4_IOC_SETFLAGS
+  FS_IOC_SETFLAGS
         Set additional attributes associated with inode.  The ioctl argument is
-        an integer bitfield, with bit values described in ext4.h. This ioctl is
-        an alias for FS_IOC_SETFLAGS.
+        an integer bitfield, with bit values described in ext4.h.
 
   EXT4_IOC_GETVERSION, EXT4_IOC_GETVERSION_OLD
         Get the inode i_generation number stored for each inode. The
index bdc1f33..a106874 100644 (file)
        efi=            [EFI]
                        Format: { "debug", "disable_early_pci_dma",
                                  "nochunk", "noruntime", "nosoftreserve",
-                                 "novamap", "no_disable_early_pci_dma",
-                                 "old_map" }
+                                 "novamap", "no_disable_early_pci_dma" }
                        debug: enable misc debug output.
                        disable_early_pci_dma: disable the busmaster bit on all
                        PCI bridges while in the EFI boot stub.
                        novamap: do not call SetVirtualAddressMap().
                        no_disable_early_pci_dma: Leave the busmaster bit set
                        on all PCI bridges while in the EFI boot stub
-                       old_map [X86-64]: switch to the old ioremap-based EFI
-                       runtime services mapping. [Needs CONFIG_X86_UV=y]
 
        efi_no_storage_paranoia [EFI; X86]
                        Using this parameter you can use more than 50% of
index 5e47786..5fe1ade 100644 (file)
@@ -1434,7 +1434,7 @@ on the feature, restricting the viewing angles.
 
 
 DYTC Lapmode sensor
-------------------
+-------------------
 
 sysfs: dytc_lapmode
 
index 7adef96..5072e70 100644 (file)
@@ -123,7 +123,9 @@ Energy-Performance Bias (EPB) knob (otherwise), which means that the processor's
 internal P-state selection logic is expected to focus entirely on performance.
 
 This will override the EPP/EPB setting coming from the ``sysfs`` interface
-(see `Energy vs Performance Hints`_ below).
+(see `Energy vs Performance Hints`_ below).  Moreover, any attempts to change
+the EPP/EPB to a value different from 0 ("performance") via ``sysfs`` in this
+configuration will be rejected.
 
 Also, in this configuration the range of P-states available to the processor's
 internal P-state selection logic is always restricted to the upper boundary
@@ -564,8 +566,8 @@ Energy-Performance Preference (EPP) knob (if supported) or its
 Energy-Performance Bias (EPB) knob. It is also possible to write a positive
 integer value between 0 to 255, if the EPP feature is present. If the EPP
 feature is not present, writing integer value to this attribute is not
-supported. In this case, user can use
- "/sys/devices/system/cpu/cpu*/power/energy_perf_bias" interface.
+supported. In this case, user can use the
+"/sys/devices/system/cpu/cpu*/power/energy_perf_bias" interface.
 
 [Note that tasks may by migrated from one CPU to another by the scheduler's
 load-balancing algorithm and if different energy vs performance hints are
index d46429b..7df2465 100644 (file)
@@ -36,6 +36,12 @@ Two sets of Questions and Answers (Q&A) are maintained.
    bpf_devel_QA
 
 
+Helper functions
+================
+
+* `bpf-helpers(7)`_ maintains a list of helpers available to eBPF programs.
+
+
 Program types
 =============
 
@@ -79,4 +85,5 @@ Other
 .. _networking-filter: ../networking/filter.rst
 .. _man-pages: https://www.kernel.org/doc/man-pages/
 .. _bpf(2): https://man7.org/linux/man-pages/man2/bpf.2.html
+.. _bpf-helpers(7): https://man7.org/linux/man-pages/man7/bpf-helpers.7.html
 .. _BPF and XDP Reference Guide: https://docs.cilium.io/en/latest/bpf/
index 66cb238..ad21899 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Clock bindings for Freescale i.MX23
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 description: |
   The clock consumer should specify the desired clock by having the clock
index 72328d5..f1af110 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Clock bindings for Freescale i.MX28
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 description: |
   The clock consumer should specify the desired clock by having the clock
index b758f91..9853fef 100644 (file)
@@ -12,6 +12,13 @@ Required properties:
  - pinctrl-0: phandle to pinctrl node
  - pinctrl-names: pinctrl state
 
+Optional properties:
+ - cfam-reset-gpios: GPIO for CFAM reset
+
+ - fsi-routing-gpios: GPIO for setting the FSI mux (internal or cabled)
+ - fsi-mux-gpios: GPIO for detecting the desired FSI mux state
+
+
 Examples:
 
     fsi-master {
@@ -21,4 +28,9 @@ Examples:
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_fsi1_default>;
        clocks = <&syscon ASPEED_CLK_GATE_FSICLK>;
+
+       fsi-routing-gpios = <&gpio0 ASPEED_GPIO(Q, 7) GPIO_ACTIVE_HIGH>;
+       fsi-mux-gpios = <&gpio0 ASPEED_GPIO(B, 0) GPIO_ACTIVE_HIGH>;
+
+       cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 0) GPIO_ACTIVE_LOW>;
     };
index ccf5b50..dfa1133 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale MXS GPIO controller
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
   - Anson Huang <Anson.Huang@nxp.com>
 
 description: |
index d3134ed..21ae7bc 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale MXS Inter IC (I2C) Controller
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 properties:
   compatible:
index 6f5d23a..138c544 100644 (file)
@@ -19,7 +19,8 @@ directly.
 Required properties:
 - compatible : contains the interconnect provider compatible string
 - #interconnect-cells : number of cells in a interconnect specifier needed to
-                       encode the interconnect node id
+                       encode the interconnect node id and optionally add a
+                       path tag
 
 Example:
 
@@ -44,6 +45,10 @@ components it has to interact with.
 Required properties:
 interconnects : Pairs of phandles and interconnect provider specifier to denote
                the edge source and destination ports of the interconnect path.
+               An optional path tag value could specified as additional argument
+               to both endpoints and in such cases, this information will be passed
+               to the interconnect framework to do aggregation based on the attached
+               tag.
 
 Optional properties:
 interconnect-names : List of interconnect path name strings sorted in the same
@@ -62,3 +67,20 @@ Example:
                interconnects = <&pnoc MASTER_SDCC_1 &bimc SLAVE_EBI_CH0>;
                interconnect-names = "sdhc-mem";
        };
+
+Example with path tags:
+
+       gnoc: interconnect@17900000 {
+               ...
+               interconnect-cells = <2>;
+       };
+
+       mnoc: interconnect@1380000 {
+               ...
+               interconnect-cells = <2>;
+       };
+
+       cpu@0 {
+               ...
+               interconnects = <&gnoc MASTER_APPSS_PROC 3 &mnoc SLAVE_EBI1 3>;
+       }
index 5971fc1..e23df48 100644 (file)
@@ -21,6 +21,23 @@ properties:
     enum:
       - qcom,bcm-voter
 
+  qcom,tcs-wait:
+    description: |
+      Optional mask of which TCSs (Triggered Command Sets) wait for completion
+      upon triggering. If not specified, then the AMC and WAKE sets wait for
+      completion. The mask bits are available in the QCOM_ICC_TAG_* defines.
+
+      The AMC TCS is triggered immediately when icc_set_bw() is called. The
+      WAKE/SLEEP TCSs are triggered when the RSC transitions between active and
+      sleep modes.
+
+      In most cases, it's necessary to wait in both the AMC and WAKE sets to
+      ensure resources are available before use. If a specific RSC and its use
+      cases can ensure sufficient delay by other means, then this can be
+      overridden to reduce latencies.
+
+    $ref: /schemas/types.yaml#/definitions/uint32
+
 required:
   - compatible
 
@@ -39,7 +56,10 @@ examples:
   # as defined in Documentation/devicetree/bindings/soc/qcom/rpmh-rsc.txt
   - |
 
+    #include <dt-bindings/interconnect/qcom,icc.h>
+
     disp_bcm_voter: bcm_voter {
         compatible = "qcom,bcm-voter";
+        qcom,tcs-wait = <QCOM_ICC_TAG_AMC>;
     };
 ...
index 91f70c9..d6a95c3 100644 (file)
@@ -19,6 +19,8 @@ properties:
     enum:
       - qcom,sc7180-osm-l3
       - qcom,sdm845-osm-l3
+      - qcom,sm8150-osm-l3
+      - qcom,sm8250-epss-l3
 
   reg:
     maxItems: 1
diff --git a/Documentation/devicetree/bindings/interconnect/qcom,rpmh.yaml b/Documentation/devicetree/bindings/interconnect/qcom,rpmh.yaml
new file mode 100644 (file)
index 0000000..30c2a09
--- /dev/null
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interconnect/qcom,rpmh.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm RPMh Network-On-Chip Interconnect
+
+maintainers:
+  - Georgi Djakov <georgi.djakov@linaro.org>
+  - Odelu Kukatla <okukatla@codeaurora.org>
+
+description: |
+   RPMh interconnect providers support system bandwidth requirements through
+   RPMh hardware accelerators known as Bus Clock Manager (BCM). The provider is
+   able to communicate with the BCM through the Resource State Coordinator (RSC)
+   associated with each execution environment. Provider nodes must point to at
+   least one RPMh device child node pertaining to their RSC and each provider
+   can map to multiple RPMh resources.
+
+properties:
+  reg:
+    maxItems: 1
+
+  compatible:
+    enum:
+      - qcom,sc7180-aggre1-noc
+      - qcom,sc7180-aggre2-noc
+      - qcom,sc7180-camnoc-virt
+      - qcom,sc7180-compute-noc
+      - qcom,sc7180-config-noc
+      - qcom,sc7180-dc-noc
+      - qcom,sc7180-gem-noc
+      - qcom,sc7180-ipa-virt
+      - qcom,sc7180-mc-virt
+      - qcom,sc7180-mmss-noc
+      - qcom,sc7180-npu-noc
+      - qcom,sc7180-qup-virt
+      - qcom,sc7180-system-noc
+      - qcom,sdm845-aggre1-noc
+      - qcom,sdm845-aggre2-noc
+      - qcom,sdm845-config-noc
+      - qcom,sdm845-dc-noc
+      - qcom,sdm845-gladiator-noc
+      - qcom,sdm845-mem-noc
+      - qcom,sdm845-mmss-noc
+      - qcom,sdm845-system-noc
+      - qcom,sm8150-aggre1-noc
+      - qcom,sm8150-aggre2-noc
+      - qcom,sm8150-camnoc-noc
+      - qcom,sm8150-compute-noc
+      - qcom,sm8150-config-noc
+      - qcom,sm8150-dc-noc
+      - qcom,sm8150-gem-noc
+      - qcom,sm8150-ipa-virt
+      - qcom,sm8150-mc-virt
+      - qcom,sm8150-mmss-noc
+      - qcom,sm8150-system-noc
+      - qcom,sm8250-aggre1-noc
+      - qcom,sm8250-aggre2-noc
+      - qcom,sm8250-compute-noc
+      - qcom,sm8250-config-noc
+      - qcom,sm8250-dc-noc
+      - qcom,sm8250-gem-noc
+      - qcom,sm8250-ipa-virt
+      - qcom,sm8250-mc-virt
+      - qcom,sm8250-mmss-noc
+      - qcom,sm8250-npu-noc
+      - qcom,sm8250-system-noc
+
+  '#interconnect-cells':
+    const: 1
+
+  qcom,bcm-voters:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    description: |
+      List of phandles to qcom,bcm-voter nodes that are required by
+      this interconnect to send RPMh commands.
+
+  qcom,bcm-voter-names:
+    $ref: /schemas/types.yaml#/definitions/string-array
+    description: |
+      Names for each of the qcom,bcm-voters specified.
+
+required:
+  - compatible
+  - reg
+  - '#interconnect-cells'
+  - qcom,bcm-voters
+
+additionalProperties: false
+
+examples:
+  - |
+      #include <dt-bindings/interconnect/qcom,sdm845.h>
+
+      mem_noc: interconnect@1380000 {
+             compatible = "qcom,sdm845-mem-noc";
+             reg = <0x01380000 0x27200>;
+             #interconnect-cells = <1>;
+             qcom,bcm-voters = <&apps_bcm_voter>;
+      };
+
+      mmss_noc: interconnect@1740000 {
+             compatible = "qcom,sdm845-mmss-noc";
+             reg = <0x01740000 0x1c1000>;
+             #interconnect-cells = <1>;
+             qcom,bcm-voter-names = "apps", "disp";
+             qcom,bcm-voters = <&apps_bcm_voter>, <&disp_bcm_voter>;
+      };
diff --git a/Documentation/devicetree/bindings/interconnect/qcom,sc7180.yaml b/Documentation/devicetree/bindings/interconnect/qcom,sc7180.yaml
deleted file mode 100644 (file)
index 8659048..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/interconnect/qcom,sc7180.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Qualcomm SC7180 Network-On-Chip Interconnect
-
-maintainers:
-  - Odelu Kukatla <okukatla@codeaurora.org>
-
-description: |
-   SC7180 interconnect providers support system bandwidth requirements through
-   RPMh hardware accelerators known as Bus Clock Manager (BCM). The provider is
-   able to communicate with the BCM through the Resource State Coordinator (RSC)
-   associated with each execution environment. Provider nodes must point to at
-   least one RPMh device child node pertaining to their RSC and each provider
-   can map to multiple RPMh resources.
-
-properties:
-  reg:
-    maxItems: 1
-
-  compatible:
-    enum:
-      - qcom,sc7180-aggre1-noc
-      - qcom,sc7180-aggre2-noc
-      - qcom,sc7180-camnoc-virt
-      - qcom,sc7180-compute-noc
-      - qcom,sc7180-config-noc
-      - qcom,sc7180-dc-noc
-      - qcom,sc7180-gem-noc
-      - qcom,sc7180-ipa-virt
-      - qcom,sc7180-mc-virt
-      - qcom,sc7180-mmss-noc
-      - qcom,sc7180-npu-noc
-      - qcom,sc7180-qup-virt
-      - qcom,sc7180-system-noc
-
-  '#interconnect-cells':
-    const: 1
-
-  qcom,bcm-voters:
-    $ref: /schemas/types.yaml#/definitions/phandle-array
-    description: |
-      List of phandles to qcom,bcm-voter nodes that are required by
-      this interconnect to send RPMh commands.
-
-  qcom,bcm-voter-names:
-    $ref: /schemas/types.yaml#/definitions/string-array
-    description: |
-      Names for each of the qcom,bcm-voters specified.
-
-required:
-  - compatible
-  - reg
-  - '#interconnect-cells'
-  - qcom,bcm-voters
-
-additionalProperties: false
-
-examples:
-  - |
-      #include <dt-bindings/interconnect/qcom,sc7180.h>
-
-      config_noc: interconnect@1500000 {
-            compatible = "qcom,sc7180-config-noc";
-            reg = <0x01500000 0x28000>;
-            #interconnect-cells = <1>;
-            qcom,bcm-voters = <&apps_bcm_voter>;
-      };
-
-      system_noc: interconnect@1620000 {
-            compatible = "qcom,sc7180-system-noc";
-            reg = <0x01620000 0x17080>;
-            #interconnect-cells = <1>;
-            qcom,bcm-voters = <&apps_bcm_voter>;
-      };
-
-      mmss_noc: interconnect@1740000 {
-            compatible = "qcom,sc7180-mmss-noc";
-            reg = <0x01740000 0x1c100>;
-            #interconnect-cells = <1>;
-            qcom,bcm-voters = <&apps_bcm_voter>;
-      };
diff --git a/Documentation/devicetree/bindings/interconnect/qcom,sdm845.yaml b/Documentation/devicetree/bindings/interconnect/qcom,sdm845.yaml
deleted file mode 100644 (file)
index dab17c0..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
-%YAML 1.2
----
-$id: http://devicetree.org/schemas/interconnect/qcom,sdm845.yaml#
-$schema: http://devicetree.org/meta-schemas/core.yaml#
-
-title: Qualcomm SDM845 Network-On-Chip Interconnect
-
-maintainers:
-  - Georgi Djakov <georgi.djakov@linaro.org>
-
-description: |
-   SDM845 interconnect providers support system bandwidth requirements through
-   RPMh hardware accelerators known as Bus Clock Manager (BCM). The provider is
-   able to communicate with the BCM through the Resource State Coordinator (RSC)
-   associated with each execution environment. Provider nodes must point to at
-   least one RPMh device child node pertaining to their RSC and each provider
-   can map to multiple RPMh resources.
-
-properties:
-  reg:
-    maxItems: 1
-
-  compatible:
-    enum:
-      - qcom,sdm845-aggre1-noc
-      - qcom,sdm845-aggre2-noc
-      - qcom,sdm845-config-noc
-      - qcom,sdm845-dc-noc
-      - qcom,sdm845-gladiator-noc
-      - qcom,sdm845-mem-noc
-      - qcom,sdm845-mmss-noc
-      - qcom,sdm845-system-noc
-
-  '#interconnect-cells':
-    const: 1
-
-  qcom,bcm-voters:
-    $ref: /schemas/types.yaml#/definitions/phandle-array
-    description: |
-      List of phandles to qcom,bcm-voter nodes that are required by
-      this interconnect to send RPMh commands.
-
-  qcom,bcm-voter-names:
-    $ref: /schemas/types.yaml#/definitions/string-array
-    description: |
-      Names for each of the qcom,bcm-voters specified.
-
-required:
-  - compatible
-  - reg
-  - '#interconnect-cells'
-  - qcom,bcm-voters
-
-additionalProperties: false
-
-examples:
-  - |
-      #include <dt-bindings/interconnect/qcom,sdm845.h>
-
-      mem_noc: interconnect@1380000 {
-             compatible = "qcom,sdm845-mem-noc";
-             reg = <0x01380000 0x27200>;
-             #interconnect-cells = <1>;
-             qcom,bcm-voters = <&apps_bcm_voter>;
-      };
-
-      mmss_noc: interconnect@1740000 {
-             compatible = "qcom,sdm845-mmss-noc";
-             reg = <0x01740000 0x1c1000>;
-             #interconnect-cells = <1>;
-             qcom,bcm-voter-names = "apps", "disp";
-             qcom,bcm-voters = <&apps_bcm_voter>, <&disp_bcm_voter>;
-      };
diff --git a/Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.txt b/Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.txt
deleted file mode 100644 (file)
index 7841cb0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-Texas Instruments K3 Interrupt Aggregator
-=========================================
-
-The Interrupt Aggregator (INTA) provides a centralized machine
-which handles the termination of system events to that they can
-be coherently processed by the host(s) in the system. A maximum
-of 64 events can be mapped to a single interrupt.
-
-
-                              Interrupt Aggregator
-                     +-----------------------------------------+
-                     |      Intmap            VINT             |
-                     | +--------------+  +------------+        |
-            m ------>| | vint  | bit  |  | 0 |.....|63| vint0  |
-               .     | +--------------+  +------------+        |       +------+
-               .     |         .               .               |       | HOST |
-Globalevents  ------>|         .               .               |------>| IRQ  |
-               .     |         .               .               |       | CTRL |
-               .     |         .               .               |       +------+
-            n ------>| +--------------+  +------------+        |
-                     | | vint  | bit  |  | 0 |.....|63| vintx  |
-                     | +--------------+  +------------+        |
-                     |                                         |
-                     +-----------------------------------------+
-
-Configuration of these Intmap registers that maps global events to vint is done
-by a system controller (like the Device Memory and Security Controller on K3
-AM654 SoC). Driver should request the system controller to get the range
-of global events and vints assigned to the requesting host. Management
-of these requested resources should be handled by driver and requests
-system controller to map specific global event to vint, bit pair.
-
-Communication between the host processor running an OS and the system
-controller happens through a protocol called TI System Control Interface
-(TISCI protocol). For more details refer:
-Documentation/devicetree/bindings/arm/keystone/ti,sci.txt
-
-TISCI Interrupt Aggregator Node:
--------------------------------
-- compatible:          Must be "ti,sci-inta".
-- reg:                 Should contain registers location and length.
-- interrupt-controller:        Identifies the node as an interrupt controller
-- msi-controller:      Identifies the node as an MSI controller.
-- interrupt-parent:    phandle of irq parent.
-- ti,sci:              Phandle to TI-SCI compatible System controller node.
-- ti,sci-dev-id:       TISCI device ID of the Interrupt Aggregator.
-- ti,sci-rm-range-vint:        Array of TISCI subtype ids representing vints(inta
-                       outputs) range within this INTA, assigned to the
-                       requesting host context.
-- ti,sci-rm-range-global-event:        Array of TISCI subtype ids representing the
-                       global events range reaching this IA and are assigned
-                       to the requesting host context.
-
-Example:
---------
-main_udmass_inta: interrupt-controller@33d00000 {
-       compatible = "ti,sci-inta";
-       reg = <0x0 0x33d00000 0x0 0x100000>;
-       interrupt-controller;
-       msi-controller;
-       interrupt-parent = <&main_navss_intr>;
-       ti,sci = <&dmsc>;
-       ti,sci-dev-id = <179>;
-       ti,sci-rm-range-vint = <0x0>;
-       ti,sci-rm-range-global-event = <0x1>;
-};
diff --git a/Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml b/Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml
new file mode 100644 (file)
index 0000000..c7cd056
--- /dev/null
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/ti,sci-inta.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Interrupt Aggregator
+
+maintainers:
+  - Lokesh Vutla <lokeshvutla@ti.com>
+
+allOf:
+  - $ref: /schemas/arm/keystone/ti,k3-sci-common.yaml#
+
+description: |
+  The Interrupt Aggregator (INTA) provides a centralized machine
+  which handles the termination of system events to that they can
+  be coherently processed by the host(s) in the system. A maximum
+  of 64 events can be mapped to a single interrupt.
+
+                                Interrupt Aggregator
+                       +-----------------------------------------+
+                       |      Intmap            VINT             |
+                       | +--------------+  +------------+        |
+              m ------>| | vint  | bit  |  | 0 |.....|63| vint0  |
+                 .     | +--------------+  +------------+        |      +------+
+                 .     |         .               .               |      | HOST |
+  Globalevents  ------>|         .               .               |----->| IRQ  |
+                 .     |         .               .               |      | CTRL |
+                 .     |         .               .               |      +------+
+              n ------>| +--------------+  +------------+        |
+                       | | vint  | bit  |  | 0 |.....|63| vintx  |
+                       | +--------------+  +------------+        |
+                       |                                         |
+                       +-----------------------------------------+
+
+  Configuration of these Intmap registers that maps global events to vint is
+  done by a system controller (like the Device Memory and Security Controller
+  on AM654 SoC). Driver should request the system controller to get the range
+  of global events and vints assigned to the requesting host. Management
+  of these requested resources should be handled by driver and requests
+  system controller to map specific global event to vint, bit pair.
+
+  Communication between the host processor running an OS and the system
+  controller happens through a protocol called TI System Control Interface
+  (TISCI protocol).
+
+properties:
+  compatible:
+    const: ti,sci-inta
+
+  reg:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  msi-controller: true
+
+  ti,interrupt-ranges:
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+    description: |
+      Interrupt ranges that converts the INTA output hw irq numbers
+      to parents's input interrupt numbers.
+    items:
+      items:
+        - description: |
+            "output_irq" specifies the base for inta output irq
+        - description: |
+            "parent's input irq" specifies the base for parent irq
+        - description: |
+            "limit" specifies the limit for translation
+
+required:
+  - compatible
+  - reg
+  - interrupt-controller
+  - msi-controller
+  - ti,sci
+  - ti,sci-dev-id
+  - ti,interrupt-ranges
+
+examples:
+  - |
+    bus {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        main_udmass_inta: msi-controller@33d00000 {
+            compatible = "ti,sci-inta";
+            reg = <0x0 0x33d00000 0x0 0x100000>;
+            interrupt-controller;
+            msi-controller;
+            interrupt-parent = <&main_navss_intr>;
+            ti,sci = <&dmsc>;
+            ti,sci-dev-id = <179>;
+            ti,interrupt-ranges = <0 0 256>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.txt b/Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.txt
deleted file mode 100644 (file)
index 178fca0..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-Texas Instruments K3 Interrupt Router
-=====================================
-
-The Interrupt Router (INTR) module provides a mechanism to mux M
-interrupt inputs to N interrupt outputs, where all M inputs are selectable
-to be driven per N output. An Interrupt Router can either handle edge triggered
-or level triggered interrupts and that is fixed in hardware.
-
-                                 Interrupt Router
-                             +----------------------+
-                             |  Inputs     Outputs  |
-        +-------+            | +------+    +-----+  |
-        | GPIO  |----------->| | irq0 |    |  0  |  |       Host IRQ
-        +-------+            | +------+    +-----+  |      controller
-                             |    .           .     |      +-------+
-        +-------+            |    .           .     |----->|  IRQ  |
-        | INTA  |----------->|    .           .     |      +-------+
-        +-------+            |    .        +-----+  |
-                             | +------+    |  N  |  |
-                             | | irqM |    +-----+  |
-                             | +------+             |
-                             |                      |
-                             +----------------------+
-
-There is one register per output (MUXCNTL_N) that controls the selection.
-Configuration of these MUXCNTL_N registers is done by a system controller
-(like the Device Memory and Security Controller on K3 AM654 SoC). System
-controller will keep track of the used and unused registers within the Router.
-Driver should request the system controller to get the range of GIC IRQs
-assigned to the requesting hosts. It is the drivers responsibility to keep
-track of Host IRQs.
-
-Communication between the host processor running an OS and the system
-controller happens through a protocol called TI System Control Interface
-(TISCI protocol). For more details refer:
-Documentation/devicetree/bindings/arm/keystone/ti,sci.txt
-
-TISCI Interrupt Router Node:
-----------------------------
-Required Properties:
-- compatible:          Must be "ti,sci-intr".
-- ti,intr-trigger-type:        Should be one of the following:
-                       1: If intr supports edge triggered interrupts.
-                       4: If intr supports level triggered interrupts.
-- interrupt-controller:        Identifies the node as an interrupt controller
-- #interrupt-cells:    Specifies the number of cells needed to encode an
-                       interrupt source. The value should be 2.
-                       First cell should contain the TISCI device ID of source
-                       Second cell should contain the interrupt source offset
-                       within the device.
-- ti,sci:              Phandle to TI-SCI compatible System controller node.
-- ti,sci-dst-id:       TISCI device ID of the destination IRQ controller.
-- ti,sci-rm-range-girq:        Array of TISCI subtype ids representing the host irqs
-                       assigned to this interrupt router. Each subtype id
-                       corresponds to a range of host irqs.
-
-For more details on TISCI IRQ resource management refer:
-https://downloads.ti.com/tisci/esd/latest/2_tisci_msgs/rm/rm_irq.html
-
-Example:
---------
-The following example demonstrates both interrupt router node and the consumer
-node(main gpio) on the AM654 SoC:
-
-main_intr: interrupt-controller0 {
-       compatible = "ti,sci-intr";
-       ti,intr-trigger-type = <1>;
-       interrupt-controller;
-       interrupt-parent = <&gic500>;
-       #interrupt-cells = <2>;
-       ti,sci = <&dmsc>;
-       ti,sci-dst-id = <56>;
-       ti,sci-rm-range-girq = <0x1>;
-};
-
-main_gpio0: gpio@600000 {
-       ...
-       interrupt-parent = <&main_intr>;
-       interrupts = <57 256>, <57 257>, <57 258>,
-                    <57 259>, <57 260>, <57 261>;
-       ...
-};
diff --git a/Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml b/Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml
new file mode 100644 (file)
index 0000000..cff6a95
--- /dev/null
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/interrupt-controller/ti,sci-intr.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 Interrupt Router
+
+maintainers:
+  - Lokesh Vutla <lokeshvutla@ti.com>
+
+allOf:
+  - $ref: /schemas/arm/keystone/ti,k3-sci-common.yaml#
+
+description: |
+  The Interrupt Router (INTR) module provides a mechanism to mux M
+  interrupt inputs to N interrupt outputs, where all M inputs are selectable
+  to be driven per N output. An Interrupt Router can either handle edge
+  triggered or level triggered interrupts and that is fixed in hardware.
+
+                                   Interrupt Router
+                               +----------------------+
+                               |  Inputs     Outputs  |
+          +-------+            | +------+    +-----+  |
+          | GPIO  |----------->| | irq0 |    |  0  |  |       Host IRQ
+          +-------+            | +------+    +-----+  |      controller
+                               |    .           .     |      +-------+
+          +-------+            |    .           .     |----->|  IRQ  |
+          | INTA  |----------->|    .           .     |      +-------+
+          +-------+            |    .        +-----+  |
+                               | +------+    |  N  |  |
+                               | | irqM |    +-----+  |
+                               | +------+             |
+                               |                      |
+                               +----------------------+
+
+  There is one register per output (MUXCNTL_N) that controls the selection.
+  Configuration of these MUXCNTL_N registers is done by a system controller
+  (like the Device Memory and Security Controller on K3 AM654 SoC). System
+  controller will keep track of the used and unused registers within the Router.
+  Driver should request the system controller to get the range of GIC IRQs
+  assigned to the requesting hosts. It is the drivers responsibility to keep
+  track of Host IRQs.
+
+  Communication between the host processor running an OS and the system
+  controller happens through a protocol called TI System Control Interface
+  (TISCI protocol).
+
+properties:
+  compatible:
+    const: ti,sci-intr
+
+  ti,intr-trigger-type:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [1, 4]
+    description: |
+      Should be one of the following.
+        1 = If intr supports edge triggered interrupts.
+        4 = If intr supports level triggered interrupts.
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+    description: |
+      The 1st cell should contain interrupt router input hw number.
+
+  ti,interrupt-ranges:
+    $ref: /schemas/types.yaml#/definitions/uint32-matrix
+    description: |
+      Interrupt ranges that converts the INTR output hw irq numbers
+      to parents's input interrupt numbers.
+    items:
+      items:
+        - description: |
+            "output_irq" specifies the base for intr output irq
+        - description: |
+            "parent's input irq" specifies the base for parent irq
+        - description: |
+            "limit" specifies the limit for translation
+
+required:
+  - compatible
+  - ti,intr-trigger-type
+  - interrupt-controller
+  - '#interrupt-cells'
+  - ti,sci
+  - ti,sci-dev-id
+  - ti,interrupt-ranges
+
+examples:
+  - |
+    main_gpio_intr: interrupt-controller0 {
+        compatible = "ti,sci-intr";
+        ti,intr-trigger-type = <1>;
+        interrupt-controller;
+        interrupt-parent = <&gic500>;
+        #interrupt-cells = <1>;
+        ti,sci = <&dmsc>;
+        ti,sci-dev-id = <131>;
+        ti,interrupt-ranges = <0 360 32>;
+    };
index 5887c91..58fe9d0 100644 (file)
@@ -30,9 +30,13 @@ allOf:
     then:
       properties:
         clock-output-names:
-          items:
-            - const: clk_out_sd0
-            - const: clk_in_sd0
+          oneOf:
+            - items:
+              - const: clk_out_sd0
+              - const: clk_in_sd0
+            - items:
+              - const: clk_out_sd1
+              - const: clk_in_sd1
 
 properties:
   compatible:
index 75dc116..10b4596 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale Enhanced Secure Digital Host Controller (eSDHC) for i.MX
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 allOf:
   - $ref: "mmc-controller.yaml"
index 0c9cf6a..26a8f32 100644 (file)
@@ -50,6 +50,8 @@ Optional properties:
                     error caused by stop clock(fifo full)
                     Valid range = [0:0x7]. if not present, default value is 0.
                     applied to compatible "mediatek,mt2701-mmc".
+- resets: Phandle and reset specifier pair to softreset line of MSDC IP.
+- reset-names: Should be "hrst".
 
 Examples:
 mmc0: mmc@11230000 {
index 1cccc04..bec8f8c 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale MXS MMC controller
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 description: |
   The Freescale MXS Synchronous Serial Ports (SSP) can act as a MMC controller
index 2cf3aff..96c0b14 100644 (file)
@@ -15,8 +15,15 @@ Required properties:
   - "nvidia,tegra210-sdhci": for Tegra210
   - "nvidia,tegra186-sdhci": for Tegra186
   - "nvidia,tegra194-sdhci": for Tegra194
-- clocks : Must contain one entry, for the module clock.
-  See ../clocks/clock-bindings.txt for details.
+- clocks: For Tegra210, Tegra186 and Tegra194 must contain two entries.
+         One for the module clock and one for the timeout clock.
+         For all other Tegra devices, must contain a single entry for
+         the module clock. See ../clocks/clock-bindings.txt for details.
+- clock-names: For Tegra210, Tegra186 and Tegra194 must contain the
+              strings 'sdhci' and 'tmclk' to represent the module and
+              the timeout clocks, respectively.
+              For all other Tegra devices must contain the string 'sdhci'
+              to represent the module clock.
 - resets : Must contain an entry for each entry in reset-names.
   See ../reset/reset.txt for details.
 - reset-names : Must include the following entries:
@@ -99,7 +106,7 @@ Optional properties for Tegra210, Tegra186 and Tegra194:
 
 Example:
 sdhci@700b0000 {
-       compatible = "nvidia,tegra210-sdhci", "nvidia,tegra124-sdhci";
+       compatible = "nvidia,tegra124-sdhci";
        reg = <0x0 0x700b0000 0x0 0x200>;
        interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
        clocks = <&tegra_car TEGRA210_CLK_SDMMC1>;
@@ -115,3 +122,22 @@ sdhci@700b0000 {
        nvidia,pad-autocal-pull-down-offset-1v8 = <0x7b>;
        status = "disabled";
 };
+
+sdhci@700b0000 {
+       compatible = "nvidia,tegra210-sdhci";
+       reg = <0x0 0x700b0000 0x0 0x200>;
+       interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
+       clocks = <&tegra_car TEGRA210_CLK_SDMMC1>,
+                <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
+       clock-names = "sdhci", "tmclk";
+       resets = <&tegra_car 14>;
+       reset-names = "sdhci";
+       pinctrl-names = "sdmmc-3v3", "sdmmc-1v8";
+       pinctrl-0 = <&sdmmc1_3v3>;
+       pinctrl-1 = <&sdmmc1_1v8>;
+       nvidia,pad-autocal-pull-up-offset-3v3 = <0x00>;
+       nvidia,pad-autocal-pull-down-offset-3v3 = <0x7d>;
+       nvidia,pad-autocal-pull-up-offset-1v8 = <0x7b>;
+       nvidia,pad-autocal-pull-down-offset-1v8 = <0x7b>;
+       status = "disabled";
+};
index bf7328a..dab208b 100644 (file)
@@ -1,4 +1,4 @@
 Distributed Switch Architecture Device Tree Bindings
 ----------------------------------------------------
 
-See Documentation/devicetree/bindings/net/dsa/dsa.yaml for the documenation.
+See Documentation/devicetree/bindings/net/dsa/dsa.yaml for the documentation.
index 1c44740..fa2baca 100644 (file)
@@ -54,7 +54,8 @@ properties:
 
   phy-connection-type:
     description:
-      Operation mode of the PHY interface
+      Specifies interface type between the Ethernet device and a physical
+      layer (PHY) device.
     enum:
       # There is not a standard bus between the MAC and the PHY,
       # something proprietary is being used to embed the PHY in the
index 08678af..8ce5ed8 100644 (file)
@@ -59,9 +59,15 @@ properties:
   clocks:
     maxItems: 1
 
-  pinctrl-0: true
+  power-domains:
+    maxItems: 1
+
+  resets:
+    maxItems: 1
 
-  pinctrl-names: true
+  phy-mode: true
+
+  phy-handle: true
 
   renesas,no-ether-link:
     type: boolean
@@ -74,6 +80,11 @@ properties:
       specify when the Ether LINK signal is active-low instead of normal
       active-high
 
+patternProperties:
+  "^ethernet-phy@[0-9a-f]$":
+    type: object
+    $ref: ethernet-phy.yaml#
+
 required:
   - compatible
   - reg
@@ -83,7 +94,8 @@ required:
   - '#address-cells'
   - '#size-cells'
   - clocks
-  - pinctrl-0
+
+additionalProperties: false
 
 examples:
   # Lager board
@@ -99,8 +111,6 @@ examples:
         clocks = <&mstp8_clks R8A7790_CLK_ETHER>;
         phy-mode = "rmii";
         phy-handle = <&phy1>;
-        pinctrl-0 = <&ether_pins>;
-        pinctrl-names = "default";
         renesas,ether-link-active-low;
         #address-cells = <1>;
         #size-cells = <0>;
@@ -109,7 +119,5 @@ examples:
             reg = <1>;
             interrupt-parent = <&irqc0>;
             interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
-            pinctrl-0 = <&phy1_pins>;
-            pinctrl-names = "default";
         };
     };
index 64b2c64..a1e2be7 100644 (file)
@@ -9,6 +9,14 @@ title: PCIe RC controller on Intel Gateway SoCs
 maintainers:
   - Dilip Kota <eswara.kota@linux.intel.com>
 
+select:
+  properties:
+    compatible:
+      contains:
+        const: intel,lgm-pcie
+  required:
+    - compatible
+
 properties:
   compatible:
     items:
index da68f4a..8740e07 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale MXS PWM controller
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
   - Anson Huang <anson.huang@nxp.com>
 
 properties:
index f5e518d..62d4ed2 100644 (file)
@@ -23,8 +23,8 @@ Required properties:
 
 - compatible:
     Must be one of :
-    "brcm,spi-bcm-qspi", "brcm,spi-brcmstb-qspi" : MSPI+BSPI on BRCMSTB SoCs
-    "brcm,spi-bcm-qspi", "brcm,spi-brcmstb-mspi" : Second Instance of MSPI
+    "brcm,spi-brcmstb-qspi", "brcm,spi-bcm-qspi" : MSPI+BSPI on BRCMSTB SoCs
+    "brcm,spi-brcmstb-mspi", "brcm,spi-bcm-qspi" : Second Instance of MSPI
                                                   BRCMSTB  SoCs
     "brcm,spi-bcm7425-qspi", "brcm,spi-bcm-qspi", "brcm,spi-brcmstb-mspi" : Second Instance of MSPI
                                                                            BRCMSTB  SoCs
@@ -36,8 +36,8 @@ Required properties:
                                                                            BRCMSTB  SoCs
     "brcm,spi-bcm7278-qspi", "brcm,spi-bcm-qspi", "brcm,spi-brcmstb-mspi" : Second Instance of MSPI
                                                                            BRCMSTB  SoCs
-    "brcm,spi-bcm-qspi", "brcm,spi-nsp-qspi"     : MSPI+BSPI on Cygnus, NSP
-    "brcm,spi-bcm-qspi", "brcm,spi-ns2-qspi"     : NS2 SoCs
+    "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi"     : MSPI+BSPI on Cygnus, NSP
+    "brcm,spi-ns2-qspi", "brcm,spi-bcm-qspi"     : NS2 SoCs
 
 - reg:
     Define the bases and ranges of the associated I/O address spaces.
@@ -86,7 +86,7 @@ BRCMSTB SoC Example:
     spi@f03e3400 {
                #address-cells = <0x1>;
                #size-cells = <0x0>;
-               compatible = "brcm,spi-brcmstb-qspi", "brcm,spi-brcmstb-qspi";
+               compatible = "brcm,spi-brcmstb-qspi", "brcm,spi-bcm-qspi";
                reg = <0xf03e0920 0x4 0xf03e3400 0x188 0xf03e3200 0x50>;
                reg-names = "cs_reg", "mspi", "bspi";
                interrupts = <0x6 0x5 0x4 0x3 0x2 0x1 0x0>;
@@ -149,7 +149,7 @@ BRCMSTB SoC Example:
                #address-cells = <1>;
                #size-cells = <0>;
                clocks = <&upg_fixed>;
-               compatible = "brcm,spi-brcmstb-qspi", "brcm,spi-brcmstb-mspi";
+               compatible = "brcm,spi-brcmstb-mspi", "brcm,spi-bcm-qspi";
                reg = <0xf0416000 0x180>;
                reg-names = "mspi";
                interrupts = <0x14>;
@@ -160,7 +160,7 @@ BRCMSTB SoC Example:
 iProc SoC Example:
 
     qspi: spi@18027200 {
-       compatible = "brcm,spi-bcm-qspi", "brcm,spi-nsp-qspi";
+       compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi";
        reg = <0x18027200 0x184>,
              <0x18027000 0x124>,
              <0x1811c408 0x004>,
@@ -191,7 +191,7 @@ iProc SoC Example:
  NS2 SoC Example:
 
               qspi: spi@66470200 {
-                      compatible = "brcm,spi-bcm-qspi", "brcm,spi-ns2-qspi";
+                      compatible = "brcm,spi-ns2-qspi", "brcm,spi-bcm-qspi";
                       reg = <0x66470200 0x184>,
                             <0x66470000 0x124>,
                             <0x67017408 0x004>,
index 1b50ced..50df1a4 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: Freescale (Enhanced) Configurable Serial Peripheral Interface (CSPI/eCSPI) for i.MX
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
 
 allOf:
   - $ref: "/schemas/spi/spi-controller.yaml#"
index 22882e7..312d8fe 100644 (file)
@@ -39,6 +39,7 @@ properties:
       spi common code does not support use of CS signals discontinuously.
       i.MX8DXL-EVK board only uses CS1 without using CS0. Therefore, add
       this property to re-config the chipselect value in the LPSPI driver.
+    type: boolean
 
 required:
   - compatible
index aedac16..16b57f5 100644 (file)
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 title: NXP i.MX Thermal Binding
 
 maintainers:
-  - Shawn Guo <shawn.guo@linaro.org>
+  - Shawn Guo <shawnguo@kernel.org>
   - Anson Huang <Anson.Huang@nxp.com>
 
 properties:
diff --git a/Documentation/devicetree/bindings/timer/sifive,clint.yaml b/Documentation/devicetree/bindings/timer/sifive,clint.yaml
new file mode 100644 (file)
index 0000000..2a0e9cd
--- /dev/null
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/sifive,clint.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SiFive Core Local Interruptor
+
+maintainers:
+  - Palmer Dabbelt <palmer@dabbelt.com>
+  - Anup Patel <anup.patel@wdc.com>
+
+description:
+  SiFive (and other RISC-V) SOCs include an implementation of the SiFive
+  Core Local Interruptor (CLINT) for M-mode timer and M-mode inter-processor
+  interrupts. It directly connects to the timer and inter-processor interrupt
+  lines of various HARTs (or CPUs) so RISC-V per-HART (or per-CPU) local
+  interrupt controller is the parent interrupt controller for CLINT device.
+  The clock frequency of CLINT is specified via "timebase-frequency" DT
+  property of "/cpus" DT node. The "timebase-frequency" DT property is
+  described in Documentation/devicetree/bindings/riscv/cpus.yaml
+
+properties:
+  compatible:
+    items:
+      - const: sifive,fu540-c000-clint
+      - const: sifive,clint0
+
+    description:
+      Should be "sifive,<chip>-clint" and "sifive,clint<version>".
+      Supported compatible strings are -
+      "sifive,fu540-c000-clint" for the SiFive CLINT v0 as integrated
+      onto the SiFive FU540 chip, and "sifive,clint0" for the SiFive
+      CLINT v0 IP block with no chip integration tweaks.
+      Please refer to sifive-blocks-ip-versioning.txt for details
+
+  reg:
+    maxItems: 1
+
+  interrupts-extended:
+    minItems: 1
+
+additionalProperties: false
+
+required:
+  - compatible
+  - reg
+  - interrupts-extended
+
+examples:
+  - |
+    timer@2000000 {
+      compatible = "sifive,fu540-c000-clint", "sifive,clint0";
+      interrupts-extended = <&cpu1intc 3 &cpu1intc 7
+                             &cpu2intc 3 &cpu2intc 7
+                             &cpu3intc 3 &cpu3intc 7
+                             &cpu4intc 3 &cpu4intc 7>;
+       reg = <0x2000000 0x10000>;
+    };
+...
index 2baee2c..63996ab 100644 (file)
@@ -993,7 +993,7 @@ patternProperties:
   "^sst,.*":
     description: Silicon Storage Technology, Inc.
   "^sstar,.*":
-    description: Xiamen Xingchen(SigmaStar) Technology Co., Ltd. 
+    description: Xiamen Xingchen(SigmaStar) Technology Co., Ltd.
       (formerly part of MStar Semiconductor, Inc.)
   "^st,.*":
     description: STMicroelectronics
index 8c74a99..16f21e1 100644 (file)
@@ -5,7 +5,7 @@ Writing DeviceTree Bindings in json-schema
 
 Devicetree bindings are written using json-schema vocabulary. Schema files are
 written in a JSON compatible subset of YAML. YAML is used instead of JSON as it
-considered more human readable and has some advantages such as allowing
+is considered more human readable and has some advantages such as allowing
 comments (Prefixed with '#').
 
 Schema Contents
@@ -19,7 +19,7 @@ $id
   A json-schema unique identifier string. The string must be a valid
   URI typically containing the binding's filename and path. For DT schema, it must
   begin with "http://devicetree.org/schemas/". The URL is used in constructing
-  references to other files specified in schema "$ref" properties. A $ref values
+  references to other files specified in schema "$ref" properties. A $ref value
   with a leading '/' will have the hostname prepended. A $ref value a relative
   path or filename only will be prepended with the hostname and path components
   of the current schema file's '$id' value. A URL is used even for local files,
index 100bfd2..13ea0cc 100644 (file)
@@ -179,7 +179,7 @@ DMA Fence uABI/Sync File
    :internal:
 
 Indefinite DMA Fences
-~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~
 
 At various times &dma_fence with an indefinite time until dma_fence_wait()
 finishes have been proposed. Examples include:
index 71c5a40..ccd677b 100644 (file)
@@ -6,9 +6,9 @@ API to implement a new FPGA bridge
 
 * struct :c:type:`fpga_bridge` â€” The FPGA Bridge structure
 * struct :c:type:`fpga_bridge_ops` â€” Low level Bridge driver ops
-* :c:func:`devm_fpga_bridge_create()` â€” Allocate and init a bridge struct
-* :c:func:`fpga_bridge_register()` â€” Register a bridge
-* :c:func:`fpga_bridge_unregister()` â€” Unregister a bridge
+* devm_fpga_bridge_create() â€” Allocate and init a bridge struct
+* fpga_bridge_register() â€” Register a bridge
+* fpga_bridge_unregister() â€” Unregister a bridge
 
 .. kernel-doc:: include/linux/fpga/fpga-bridge.h
    :functions: fpga_bridge
index 576f194..af5382a 100644 (file)
@@ -104,9 +104,9 @@ API for implementing a new FPGA Manager driver
 * ``fpga_mgr_states`` â€”  Values for :c:member:`fpga_manager->state`.
 * struct :c:type:`fpga_manager` â€”  the FPGA manager struct
 * struct :c:type:`fpga_manager_ops` â€”  Low level FPGA manager driver ops
-* :c:func:`devm_fpga_mgr_create` â€”  Allocate and init a manager struct
-* :c:func:`fpga_mgr_register` â€”  Register an FPGA manager
-* :c:func:`fpga_mgr_unregister` â€”  Unregister an FPGA manager
+* devm_fpga_mgr_create() â€”  Allocate and init a manager struct
+* fpga_mgr_register() â€”  Register an FPGA manager
+* fpga_mgr_unregister() â€”  Unregister an FPGA manager
 
 .. kernel-doc:: include/linux/fpga/fpga-mgr.h
    :functions: fpga_mgr_states
index b5484df..f487ad6 100644 (file)
@@ -6,9 +6,9 @@ Overview
 
 The in-kernel API for FPGA programming is a combination of APIs from
 FPGA manager, bridge, and regions.  The actual function used to
-trigger FPGA programming is :c:func:`fpga_region_program_fpga()`.
+trigger FPGA programming is fpga_region_program_fpga().
 
-:c:func:`fpga_region_program_fpga()` uses functionality supplied by
+fpga_region_program_fpga() uses functionality supplied by
 the FPGA manager and bridges.  It will:
 
  * lock the region's mutex
@@ -20,8 +20,8 @@ the FPGA manager and bridges.  It will:
  * release the locks
 
 The struct fpga_image_info specifies what FPGA image to program.  It is
-allocated/freed by :c:func:`fpga_image_info_alloc()` and freed with
-:c:func:`fpga_image_info_free()`
+allocated/freed by fpga_image_info_alloc() and freed with
+fpga_image_info_free()
 
 How to program an FPGA using a region
 -------------------------------------
@@ -84,10 +84,10 @@ will generate that list.  Here's some sample code of what to do next::
 API for programming an FPGA
 ---------------------------
 
-* :c:func:`fpga_region_program_fpga` â€”  Program an FPGA
-* :c:type:`fpga_image_info` â€”  Specifies what FPGA image to program
-* :c:func:`fpga_image_info_alloc()` â€”  Allocate an FPGA image info struct
-* :c:func:`fpga_image_info_free()` â€”  Free an FPGA image info struct
+* fpga_region_program_fpga() â€”  Program an FPGA
+* fpga_image_info() â€”  Specifies what FPGA image to program
+* fpga_image_info_alloc() â€”  Allocate an FPGA image info struct
+* fpga_image_info_free() â€”  Free an FPGA image info struct
 
 .. kernel-doc:: drivers/fpga/fpga-region.c
    :functions: fpga_region_program_fpga
index 0529b2d..31118a8 100644 (file)
@@ -46,18 +46,18 @@ API to add a new FPGA region
 ----------------------------
 
 * struct :c:type:`fpga_region` â€” The FPGA region struct
-* :c:func:`devm_fpga_region_create` â€” Allocate and init a region struct
-* :c:func:`fpga_region_register` â€”  Register an FPGA region
-* :c:func:`fpga_region_unregister` â€”  Unregister an FPGA region
+* devm_fpga_region_create() â€” Allocate and init a region struct
+* fpga_region_register() â€”  Register an FPGA region
+* fpga_region_unregister() â€”  Unregister an FPGA region
 
 The FPGA region's probe function will need to get a reference to the FPGA
 Manager it will be using to do the programming.  This usually would happen
 during the region's probe function.
 
-* :c:func:`fpga_mgr_get` â€” Get a reference to an FPGA manager, raise ref count
-* :c:func:`of_fpga_mgr_get` â€”  Get a reference to an FPGA manager, raise ref count,
+* fpga_mgr_get() â€” Get a reference to an FPGA manager, raise ref count
+* of_fpga_mgr_get() â€”  Get a reference to an FPGA manager, raise ref count,
   given a device node.
-* :c:func:`fpga_mgr_put` â€” Put an FPGA manager
+* fpga_mgr_put() â€” Put an FPGA manager
 
 The FPGA region will need to specify which bridges to control while programming
 the FPGA.  The region driver can build a list of bridges during probe time
@@ -66,11 +66,11 @@ the list of bridges to program just before programming
 (:c:member:`fpga_region->get_bridges`).  The FPGA bridge framework supplies the
 following APIs to handle building or tearing down that list.
 
-* :c:func:`fpga_bridge_get_to_list` â€” Get a ref of an FPGA bridge, add it to a
+* fpga_bridge_get_to_list() â€” Get a ref of an FPGA bridge, add it to a
   list
-* :c:func:`of_fpga_bridge_get_to_list` â€” Get a ref of an FPGA bridge, add it to a
+* of_fpga_bridge_get_to_list() â€” Get a ref of an FPGA bridge, add it to a
   list, given a device node
-* :c:func:`fpga_bridges_put` â€” Given a list of bridges, put them
+* fpga_bridges_put() â€” Given a list of bridges, put them
 
 .. kernel-doc:: include/linux/fpga/fpga-region.h
    :functions: fpga_region
index b0bc0c0..51b21e0 100644 (file)
@@ -11,10 +11,10 @@ Industrial I/O Devices
 ----------------------
 
 * struct :c:type:`iio_dev` - industrial I/O device
-* :c:func:`iio_device_alloc()` - allocate an :c:type:`iio_dev` from a driver
-* :c:func:`iio_device_free()` - free an :c:type:`iio_dev` from a driver
-* :c:func:`iio_device_register()` - register a device with the IIO subsystem
-* :c:func:`iio_device_unregister()` - unregister a device from the IIO
+* iio_device_alloc() - allocate an :c:type:`iio_dev` from a driver
+* iio_device_free() - free an :c:type:`iio_dev` from a driver
+* iio_device_register() - register a device with the IIO subsystem
+* iio_device_unregister() - unregister a device from the IIO
   subsystem
 
 An IIO device usually corresponds to a single hardware sensor and it
@@ -34,17 +34,17 @@ A typical IIO driver will register itself as an :doc:`I2C <../i2c>` or
 
 At probe:
 
-1. Call :c:func:`iio_device_alloc()`, which allocates memory for an IIO device.
+1. Call iio_device_alloc(), which allocates memory for an IIO device.
 2. Initialize IIO device fields with driver specific information (e.g.
    device name, device channels).
-3. Call :c:func:`iio_device_register()`, this registers the device with the
+3. Call iio_device_register(), this registers the device with the
    IIO core. After this call the device is ready to accept requests from user
    space applications.
 
 At remove, we free the resources allocated in probe in reverse order:
 
-1. :c:func:`iio_device_unregister()`, unregister the device from the IIO core.
-2. :c:func:`iio_device_free()`, free the memory allocated for the IIO device.
+1. iio_device_unregister(), unregister the device from the IIO core.
+2. iio_device_free(), free the memory allocated for the IIO device.
 
 IIO device sysfs interface
 ==========================
index c800d8e..cea0b69 100644 (file)
@@ -42,6 +42,11 @@ The session is terminated calling :c:func:`close(int fd)`.
 
 A code snippet for an application communicating with Intel AMTHI client:
 
+In order to support virtualization or sandboxing a trusted supervisor
+can use :c:macro:`MEI_CONNECT_CLIENT_IOCTL_VTAG` to create
+virtual channels with an Intel ME feature. Not all features support
+virtual channels such client with answer EOPNOTSUPP.
+
 .. code-block:: C
 
        struct mei_connect_client_data data;
@@ -110,6 +115,38 @@ Connect to firmware Feature/Client.
         data that can be sent or received. (e.g. if MTU=2K, can send
         requests up to bytes 2k and received responses up to 2k bytes).
 
+IOCTL_MEI_CONNECT_CLIENT_VTAG:
+------------------------------
+
+.. code-block:: none
+
+        Usage:
+
+        struct mei_connect_client_data_vtag client_data_vtag;
+
+        ioctl(fd, IOCTL_MEI_CONNECT_CLIENT_VTAG, &client_data_vtag);
+
+        Inputs:
+
+        struct mei_connect_client_data_vtag - contain the following
+        Input field:
+
+                in_client_uuid -  GUID of the FW Feature that needs
+                                  to connect to.
+                vtag - virtual tag [1, 255]
+
+         Outputs:
+                out_client_properties - Client Properties: MTU and Protocol Version.
+
+         Error returns:
+
+                ENOTTY No such client (i.e. wrong GUID) or connection is not allowed.
+                EINVAL Wrong IOCTL Number or tag == 0
+                ENODEV Device or Connection is not initialized or ready.
+                ENOMEM Unable to allocate memory to client internal data.
+                EFAULT Fatal Error (e.g. Unable to access user input data)
+                EBUSY  Connection Already Open
+                EOPNOTSUPP Vtag is not supported
 
 IOCTL_MEI_NOTIFY_SET
 ---------------------
index cdb2e82..1d44278 100644 (file)
@@ -3,7 +3,7 @@ NVMe Fault Injection
 Linux's fault injection framework provides a systematic way to support
 error injection via debugfs in the /sys/kernel/debug directory. When
 enabled, the default NVME_SC_INVALID_OPCODE with no retry will be
-injected into the nvme_end_request. Users can change the default status
+injected into the nvme_try_complete_req. Users can change the default status
 code and no retry flag via the debugfs. The list of Generic Command
 Status can be found in include/linux/nvme.h
 
index 7f1a40d..5776cbd 100644 (file)
@@ -110,13 +110,15 @@ The Amiga protection flags RWEDRWEDHSPARWED are handled as follows:
 
   - R maps to r for user, group and others. On directories, R implies x.
 
-  - If both W and D are allowed, w will be set.
+  - W maps to w.
 
   - E maps to x.
 
-  - H and P are always retained and ignored under Linux.
+  - D is ignored.
 
-  - A is always reset when a file is written to.
+  - H, S and P are always retained and ignored under Linux.
+
+  - A is cleared when a file is written to.
 
 User id and group id will be used unless set[gu]id are given as mount
 options. Since most of the Amiga file systems are single user systems
@@ -128,11 +130,13 @@ Linux -> Amiga:
 
 The Linux rwxrwxrwx file mode is handled as follows:
 
-  - r permission will set R for user, group and others.
+  - r permission will allow R for user, group and others.
+
+  - w permission will allow W for user, group and others.
 
-  - w permission will set W and D for user, group and others.
+  - x permission of the user will allow E for plain files.
 
-  - x permission of the user will set E for plain files.
+  - D will be allowed for user, group and others.
 
   - All other flags (suid, sgid, ...) are ignored and will
     not be retained.
index 0aadba0..cc76b57 100644 (file)
@@ -39,6 +39,6 @@ entry.
 Other References
 ----------------
 
-Also see http://www.nongnu.org/ext2-doc/ for quite a collection of
+Also see https://www.nongnu.org/ext2-doc/ for quite a collection of
 information about ext2/3. Here's another old reference:
 http://wiki.osdev.org/Ext2
index 6d5253e..0cd6147 100644 (file)
@@ -68,7 +68,7 @@ See below for all known bank addresses, numbers of sensors in that bank,
 number of bytes data per sensor and contents/meaning of those bytes.
 
 Although both this document and the kernel driver have kept the sensor
-terminoligy for the addressing within a bank this is not 100% correct, in
+terminology for the addressing within a bank this is not 100% correct, in
 bank 0x24 for example the addressing within the bank selects a PWM output not
 a sensor.
 
@@ -155,7 +155,7 @@ After wider testing of the Linux kernel driver some variants of the uGuru have
 turned up which do not hold 0x08 at DATA within 250 reads after writing the
 bank address. With these versions this happens quite frequent, using larger
 timeouts doesn't help, they just go offline for a second or 2, doing some
-internal callibration or whatever. Your code should be prepared to handle
+internal calibration or whatever. Your code should be prepared to handle
 this and in case of no response in this specific case just goto sleep for a
 while and then retry.
 
@@ -331,6 +331,6 @@ the voltage / clock programming out, I tried reading and only reading banks
 0-0x30 with the reading code used for the sensor banks (0x20-0x28) and this
 resulted in a _permanent_ reprogramming of the voltages, luckily I had the
 sensors part configured so that it would shutdown my system on any out of spec
-voltages which proprably safed my computer (after a reboot I managed to
+voltages which probably safed my computer (after a reboot I managed to
 immediately enter the bios and reload the defaults). This probably means that
 the read/write cycle for the non sensor part is different from the sensor part.
index d8243c8..cfda60b 100644 (file)
@@ -17,7 +17,7 @@ Supported chips:
     Note:
        The uGuru is a microcontroller with onboard firmware which programs
        it to behave as a hwmon IC. There are many different revisions of the
-       firmware and thus effectivly many different revisions of the uGuru.
+       firmware and thus effectively many different revisions of the uGuru.
        Below is an incomplete list with which revisions are used for which
        Motherboards:
 
@@ -33,7 +33,7 @@ Supported chips:
        sensortype (Volt or Temp) for bank1 sensors, for revision 1 uGuru's
        this does not always work. For these uGuru's the autodetection can
        be overridden with the bank1_types module param. For all 3 known
-       revison 1 motherboards the correct use of this param is:
+       revision 1 motherboards the correct use of this param is:
        bank1_types=1,1,0,0,0,0,0,2,0,0,0,0,2,0,0,1
        You may also need to specify the fan_sensors option for these boards
        fan_sensors=5
index 514f11f..88046d8 100644 (file)
@@ -13,7 +13,7 @@ Supported chips:
     Note:
        The uGuru is a microcontroller with onboard firmware which programs
        it to behave as a hwmon IC. There are many different revisions of the
-       firmware and thus effectivly many different revisions of the uGuru.
+       firmware and thus effectively many different revisions of the uGuru.
        Below is an incomplete list with which revisions are used for which
        Motherboards:
 
@@ -24,7 +24,7 @@ Supported chips:
        - uGuru 3.0.0.0 ~ 3.0.x.x (AW8, AL8, AT8, NI8 SLI, AT8 32X, AN8 32X,
          AW9D-MAX)
 
-       The abituguru3 driver is only for revison 3.0.x.x motherboards,
+       The abituguru3 driver is only for revision 3.0.x.x motherboards,
        this driver will not work on older motherboards. For older
        motherboards use the abituguru (without the 3 !) driver.
 
index 2aac50b..334df75 100644 (file)
@@ -23,8 +23,8 @@ supports C and the GNU C extensions required by the kernel, and is pronounced
 Clang
 -----
 
-The compiler used can be swapped out via `CC=` command line argument to `make`.
-`CC=` should be set when selecting a config and during a build.
+The compiler used can be swapped out via ``CC=`` command line argument to ``make``.
+``CC=`` should be set when selecting a config and during a build. ::
 
        make CC=clang defconfig
 
@@ -34,33 +34,33 @@ Cross Compiling
 ---------------
 
 A single Clang compiler binary will typically contain all supported backends,
-which can help simplify cross compiling.
+which can help simplify cross compiling. ::
 
        ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang
 
-`CROSS_COMPILE` is not used to prefix the Clang compiler binary, instead
-`CROSS_COMPILE` is used to set a command line flag: `--target <triple>`. For
-example:
+``CROSS_COMPILE`` is not used to prefix the Clang compiler binary, instead
+``CROSS_COMPILE`` is used to set a command line flag: ``--target <triple>``. For
+example: ::
 
        clang --target aarch64-linux-gnu foo.c
 
 LLVM Utilities
 --------------
 
-LLVM has substitutes for GNU binutils utilities. Kbuild supports `LLVM=1`
-to enable them.
+LLVM has substitutes for GNU binutils utilities. Kbuild supports ``LLVM=1``
+to enable them. ::
 
        make LLVM=1
 
-They can be enabled individually. The full list of the parameters:
+They can be enabled individually. The full list of the parameters: ::
 
-       make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \\
-         OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size \\
-         READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \\
+       make CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \
+         OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size \
+         READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \
          HOSTLD=ld.lld
 
 Currently, the integrated assembler is disabled by default. You can pass
-`LLVM_IAS=1` to enable it.
+``LLVM_IAS=1`` to enable it.
 
 Getting Help
 ------------
index b81b891..58d513a 100644 (file)
@@ -16,7 +16,7 @@ This document describes the Linux kernel Makefiles.
           --- 3.5 Library file goals - lib-y
           --- 3.6 Descending down in directories
           --- 3.7 Compilation flags
-          --- 3.8 Command line dependency
+          --- 3.8 <deleted>
           --- 3.9 Dependency tracking
           --- 3.10 Special Rules
           --- 3.11 $(CC) support functions
@@ -39,8 +39,8 @@ This document describes the Linux kernel Makefiles.
 
        === 7 Architecture Makefiles
           --- 7.1 Set variables to tweak the build to the architecture
-          --- 7.2 Add prerequisites to archheaders:
-          --- 7.3 Add prerequisites to archprepare:
+          --- 7.2 Add prerequisites to archheaders
+          --- 7.3 Add prerequisites to archprepare
           --- 7.4 List directories to visit when descending
           --- 7.5 Architecture-specific boot images
           --- 7.6 Building non-kbuild targets
@@ -129,7 +129,7 @@ The preferred name for the kbuild files are 'Makefile' but 'Kbuild' can
 be used and if both a 'Makefile' and a 'Kbuild' file exists, then the 'Kbuild'
 file will be used.
 
-Section 3.1 "Goal definitions" is a quick intro, further chapters provide
+Section 3.1 "Goal definitions" is a quick intro; further chapters provide
 more details, with real examples.
 
 3.1 Goal definitions
@@ -965,7 +965,7 @@ When kbuild executes, the following steps are followed (roughly):
                KBUILD_LDFLAGS         := -m elf_s390
 
        Note: ldflags-y can be used to further customise
-       the flags used. See chapter 3.7.
+       the flags used. See section 3.7.
 
     LDFLAGS_vmlinux
        Options for $(LD) when linking vmlinux
@@ -1121,7 +1121,7 @@ When kbuild executes, the following steps are followed (roughly):
 
        In this example, the file target maketools will be processed
        before descending down in the subdirectories.
-       See also chapter XXX-TODO that describe how kbuild supports
+       See also chapter XXX-TODO that describes how kbuild supports
        generating offset header files.
 
 
@@ -1261,7 +1261,7 @@ When kbuild executes, the following steps are followed (roughly):
        always be built.
        Assignments to $(targets) are without $(obj)/ prefix.
        if_changed may be used in conjunction with custom commands as
-       defined in 6.8 "Custom kbuild commands".
+       defined in 7.8 "Custom kbuild commands".
 
        Note: It is a typical mistake to forget the FORCE prerequisite.
        Another common pitfall is that whitespace is sometimes
@@ -1411,7 +1411,7 @@ When kbuild executes, the following steps are followed (roughly):
        that may be shared between individual architectures.
        The recommended approach how to use a generic header file is
        to list the file in the Kbuild file.
-       See "7.2 generic-y" for further info on syntax etc.
+       See "8.2 generic-y" for further info on syntax etc.
 
 7.11 Post-link pass
 -------------------
@@ -1601,4 +1601,4 @@ is the right choice.
 
 - Describe how kbuild supports shipped files with _shipped.
 - Generating offset header files.
-- Add more variables to section 7?
+- Add more variables to chapters 7 or 9?
index 4cefed8..ddada4a 100644 (file)
@@ -164,14 +164,14 @@ by disabling preemption or interrupts.
 On non-PREEMPT_RT kernels local_lock operations map to the preemption and
 interrupt disabling and enabling primitives:
 
- =========================== ======================
- local_lock(&llock)          preempt_disable()
- local_unlock(&llock)        preempt_enable()
- local_lock_irq(&llock)      local_irq_disable()
- local_unlock_irq(&llock)    local_irq_enable()
- local_lock_save(&llock)     local_irq_save()
- local_lock_restore(&llock)  local_irq_save()
- =========================== ======================
+ ===============================  ======================
+ local_lock(&llock)               preempt_disable()
+ local_unlock(&llock)             preempt_enable()
+ local_lock_irq(&llock)           local_irq_disable()
+ local_unlock_irq(&llock)         local_irq_enable()
+ local_lock_irqsave(&llock)       local_irq_save()
+ local_unlock_irqrestore(&llock)  local_irq_restore()
+ ===============================  ======================
 
 The named scope of local_lock has two advantages over the regular
 primitives:
@@ -353,14 +353,14 @@ protection scope. So the following substitution is wrong::
   {
     local_irq_save(flags);    -> local_lock_irqsave(&local_lock_1, flags);
     func3();
-    local_irq_restore(flags); -> local_lock_irqrestore(&local_lock_1, flags);
+    local_irq_restore(flags); -> local_unlock_irqrestore(&local_lock_1, flags);
   }
 
   func2()
   {
     local_irq_save(flags);    -> local_lock_irqsave(&local_lock_2, flags);
     func3();
-    local_irq_restore(flags); -> local_lock_irqrestore(&local_lock_2, flags);
+    local_irq_restore(flags); -> local_unlock_irqrestore(&local_lock_2, flags);
   }
 
   func3()
@@ -379,14 +379,14 @@ PREEMPT_RT-specific semantics of spinlock_t. The correct substitution is::
   {
     local_irq_save(flags);    -> local_lock_irqsave(&local_lock, flags);
     func3();
-    local_irq_restore(flags); -> local_lock_irqrestore(&local_lock, flags);
+    local_irq_restore(flags); -> local_unlock_irqrestore(&local_lock, flags);
   }
 
   func2()
   {
     local_irq_save(flags);    -> local_lock_irqsave(&local_lock, flags);
     func3();
-    local_irq_restore(flags); -> local_lock_irqrestore(&local_lock, flags);
+    local_irq_restore(flags); -> local_unlock_irqrestore(&local_lock, flags);
   }
 
   func3()
index 227f427..b7a627d 100644 (file)
@@ -101,3 +101,4 @@ to do something different in the near future.
 
    ../doc-guide/maintainer-profile
    ../nvdimm/maintainer-entry-profile
+   ../riscv/patch-acceptance
index 24168b0..adc3146 100644 (file)
@@ -2860,17 +2860,6 @@ version of the linux kernel, found on http://kernel.org
 The latest version of this document can be found in the latest kernel
 source (named Documentation/networking/bonding.rst).
 
-Discussions regarding the usage of the bonding driver take place on the
-bonding-devel mailing list, hosted at sourceforge.net. If you have questions or
-problems, post them to the list.  The list address is:
-
-bonding-devel@lists.sourceforge.net
-
-The administrative interface (to subscribe or unsubscribe) can
-be found at:
-
-https://lists.sourceforge.net/lists/listinfo/bonding-devel
-
 Discussions regarding the development of the bonding driver take place
 on the main Linux network mailing list, hosted at vger.kernel.org. The list
 address is:
@@ -2881,10 +2870,3 @@ The administrative interface (to subscribe or unsubscribe) can
 be found at:
 
 http://vger.kernel.org/vger-lists.html#netdev
-
-Donald Becker's Ethernet Drivers and diag programs may be found at :
-
- - http://web.archive.org/web/%2E/http://www.scyld.com/network/
-
-You will also find a lot of information regarding Ethernet, NWay, MII,
-etc. at www.scyld.com.
index af029b3..11bd5e6 100644 (file)
@@ -180,7 +180,7 @@ The configuration can only be set up via VLAN tagging and bridge setup.
 
   # bring up the slave interfaces
   ip link set lan1 up
-  ip link set lan1 up
+  ip link set lan2 up
   ip link set lan3 up
 
   # create bridge
index 46caaad..379817c 100644 (file)
@@ -49,16 +49,18 @@ Register preservation rules
 Register preservation rules match the ELF ABI calling sequence with the
 following differences:
 
-=========== ============= ========================================
 --- For the sc instruction, differences with the ELF ABI ---
+=========== ============= ========================================
 r0          Volatile      (System call number.)
 r3          Volatile      (Parameter 1, and return value.)
 r4-r8       Volatile      (Parameters 2-6.)
 cr0         Volatile      (cr0.SO is the return error condition.)
 cr1, cr5-7  Nonvolatile
 lr          Nonvolatile
+=========== ============= ========================================
 
 --- For the scv 0 instruction, differences with the ELF ABI ---
+=========== ============= ========================================
 r0          Volatile      (System call number.)
 r3          Volatile      (Parameter 1, and return value.)
 r4-r8       Volatile      (Parameters 2-6.)
index 4a9aa4f..918e32d 100644 (file)
@@ -142,7 +142,7 @@ only NUL-terminated strings. The safe replacement is strscpy().
 (Users of strscpy() still needing NUL-padding should instead
 use strscpy_pad().)
 
-If a caller is using non-NUL-terminated strings, strncpy()() can
+If a caller is using non-NUL-terminated strings, strncpy() can
 still be used, but destinations should be marked with the `__nonstring
 <https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html>`_
 attribute to avoid future compiler warnings.
index 998f76e..f3f4640 100644 (file)
@@ -332,7 +332,7 @@ WO 9901953 (A1)
 
 
 US Patents (https://www.uspto.gov/)
-----------------------------------
+-----------------------------------
 
 US 5925841
        Digital Sampling Instrument employing cache memory (Jul. 20, 1999)
index eccb0f0..2ce41d3 100644 (file)
@@ -337,7 +337,7 @@ WO 9901953 (A1)
 
 
 US Patents (https://www.uspto.gov/)
-----------------------------------
+-----------------------------------
 
 US 5925841
        Digital Sampling Instrument employing cache memory (Jul. 20, 1999)
index 2b0fff5..7c7ecf5 100644 (file)
@@ -143,7 +143,7 @@ timestamp shows when the information is put together by the driver
 before returning from the ``STATUS`` and ``STATUS_EXT`` ioctl. in most cases
 this driver_timestamp will be identical to the regular system tstamp.
 
-Examples of typestamping with HDaudio:
+Examples of timestamping with HDAudio:
 
 1. DMA timestamp, no compensation for DMA+analog delay
 ::
index e108eaf..a642ff3 100644 (file)
@@ -130,7 +130,7 @@ chi usa solo stringe terminate. La versione sicura da usare Ã¨
 strscpy(). (chi usa strscpy() e necessita di estendere la
 terminazione con NUL deve aggiungere una chiamata a memset())
 
-Se il chiamate no usa stringhe terminate con NUL, allore strncpy()()
+Se il chiamate no usa stringhe terminate con NUL, allore strncpy()
 può continuare ad essere usata, ma i buffer di destinazione devono essere
 marchiati con l'attributo `__nonstring <https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html>`_
 per evitare avvisi durante la compilazione.
index 2a19883..5f7ff00 100644 (file)
@@ -328,8 +328,11 @@ Code  Seq#    Include File                                           Comments
 0xAC  00-1F  linux/raw.h
 0xAD  00                                                             Netfilter device in development:
                                                                      <mailto:rusty@rustcorp.com.au>
-0xAE  all    linux/kvm.h                                             Kernel-based Virtual Machine
+0xAE  00-1F  linux/kvm.h                                             Kernel-based Virtual Machine
                                                                      <mailto:kvm@vger.kernel.org>
+0xAE  40-FF  linux/kvm.h                                             Kernel-based Virtual Machine
+                                                                     <mailto:kvm@vger.kernel.org>
+0xAE  20-3F  linux/nitro_enclaves.h                                  Nitro Enclaves
 0xAF  00-1F  linux/fsl_hypervisor.h                                  Freescale hypervisor
 0xB0  all                                                            RATIO devices in development:
                                                                      <mailto:vgo@ratio.de>
index de1ab81..e422430 100644 (file)
@@ -11,6 +11,7 @@ Linux Virtualization Support
    uml/user_mode_linux
    paravirt_ops
    guest-halt-polling
+   ne_overview
 
 .. only:: html and subproject
 
index eb3a131..d2b733d 100644 (file)
@@ -6130,7 +6130,7 @@ HvCallSendSyntheticClusterIpi, HvCallSendSyntheticClusterIpiEx.
 8.21 KVM_CAP_HYPERV_DIRECT_TLBFLUSH
 -----------------------------------
 
-:Architecture: x86
+:Architectures: x86
 
 This capability indicates that KVM running on top of Hyper-V hypervisor
 enables Direct TLB flush for its guests meaning that TLB flush
@@ -6143,19 +6143,33 @@ in CPUID and only exposes Hyper-V identification. In this case, guest
 thinks it's running on Hyper-V and only use Hyper-V hypercalls.
 
 8.22 KVM_CAP_S390_VCPU_RESETS
+-----------------------------
 
-Architectures: s390
+:Architectures: s390
 
 This capability indicates that the KVM_S390_NORMAL_RESET and
 KVM_S390_CLEAR_RESET ioctls are available.
 
 8.23 KVM_CAP_S390_PROTECTED
+---------------------------
 
-Architecture: s390
-
+:Architectures: s390
 
 This capability indicates that the Ultravisor has been initialized and
 KVM can therefore start protected VMs.
 This capability governs the KVM_S390_PV_COMMAND ioctl and the
 KVM_MP_STATE_LOAD MP_STATE. KVM_SET_MP_STATE can fail for protected
 guests when the state change is invalid.
+
+8.24 KVM_CAP_STEAL_TIME
+-----------------------
+
+:Architectures: arm64, x86
+
+This capability indicates that KVM supports steal time accounting.
+When steal time accounting is supported it may be enabled with
+architecture-specific interfaces.  This capability and the architecture-
+specific interfaces must be consistent, i.e. if one says the feature
+is supported, than the other should as well and vice versa.  For arm64
+see Documentation/virt/kvm/devices/vcpu.rst "KVM_ARM_VCPU_PVTIME_CTRL".
+For x86 see Documentation/virt/kvm/msr.rst "MSR_KVM_STEAL_TIME".
diff --git a/Documentation/virt/ne_overview.rst b/Documentation/virt/ne_overview.rst
new file mode 100644 (file)
index 0000000..39b0c8f
--- /dev/null
@@ -0,0 +1,95 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==============
+Nitro Enclaves
+==============
+
+Overview
+========
+
+Nitro Enclaves (NE) is a new Amazon Elastic Compute Cloud (EC2) capability
+that allows customers to carve out isolated compute environments within EC2
+instances [1].
+
+For example, an application that processes sensitive data and runs in a VM,
+can be separated from other applications running in the same VM. This
+application then runs in a separate VM than the primary VM, namely an enclave.
+
+An enclave runs alongside the VM that spawned it. This setup matches low latency
+applications needs. The resources that are allocated for the enclave, such as
+memory and CPUs, are carved out of the primary VM. Each enclave is mapped to a
+process running in the primary VM, that communicates with the NE driver via an
+ioctl interface.
+
+In this sense, there are two components:
+
+1. An enclave abstraction process - a user space process running in the primary
+VM guest that uses the provided ioctl interface of the NE driver to spawn an
+enclave VM (that's 2 below).
+
+There is a NE emulated PCI device exposed to the primary VM. The driver for this
+new PCI device is included in the NE driver.
+
+The ioctl logic is mapped to PCI device commands e.g. the NE_START_ENCLAVE ioctl
+maps to an enclave start PCI command. The PCI device commands are then
+translated into  actions taken on the hypervisor side; that's the Nitro
+hypervisor running on the host where the primary VM is running. The Nitro
+hypervisor is based on core KVM technology.
+
+2. The enclave itself - a VM running on the same host as the primary VM that
+spawned it. Memory and CPUs are carved out of the primary VM and are dedicated
+for the enclave VM. An enclave does not have persistent storage attached.
+
+The memory regions carved out of the primary VM and given to an enclave need to
+be aligned 2 MiB / 1 GiB physically contiguous memory regions (or multiple of
+this size e.g. 8 MiB). The memory can be allocated e.g. by using hugetlbfs from
+user space [2][3]. The memory size for an enclave needs to be at least 64 MiB.
+The enclave memory and CPUs need to be from the same NUMA node.
+
+An enclave runs on dedicated cores. CPU 0 and its CPU siblings need to remain
+available for the primary VM. A CPU pool has to be set for NE purposes by an
+user with admin capability. See the cpu list section from the kernel
+documentation [4] for how a CPU pool format looks.
+
+An enclave communicates with the primary VM via a local communication channel,
+using virtio-vsock [5]. The primary VM has virtio-pci vsock emulated device,
+while the enclave VM has a virtio-mmio vsock emulated device. The vsock device
+uses eventfd for signaling. The enclave VM sees the usual interfaces - local
+APIC and IOAPIC - to get interrupts from virtio-vsock device. The virtio-mmio
+device is placed in memory below the typical 4 GiB.
+
+The application that runs in the enclave needs to be packaged in an enclave
+image together with the OS ( e.g. kernel, ramdisk, init ) that will run in the
+enclave VM. The enclave VM has its own kernel and follows the standard Linux
+boot protocol [6].
+
+The kernel bzImage, the kernel command line, the ramdisk(s) are part of the
+Enclave Image Format (EIF); plus an EIF header including metadata such as magic
+number, eif version, image size and CRC.
+
+Hash values are computed for the entire enclave image (EIF), the kernel and
+ramdisk(s). That's used, for example, to check that the enclave image that is
+loaded in the enclave VM is the one that was intended to be run.
+
+These crypto measurements are included in a signed attestation document
+generated by the Nitro Hypervisor and further used to prove the identity of the
+enclave; KMS is an example of service that NE is integrated with and that checks
+the attestation doc.
+
+The enclave image (EIF) is loaded in the enclave memory at offset 8 MiB. The
+init process in the enclave connects to the vsock CID of the primary VM and a
+predefined port - 9000 - to send a heartbeat value - 0xb7. This mechanism is
+used to check in the primary VM that the enclave has booted. The CID of the
+primary VM is 3.
+
+If the enclave VM crashes or gracefully exits, an interrupt event is received by
+the NE driver. This event is sent further to the user space enclave process
+running in the primary VM via a poll notification mechanism. Then the user space
+enclave process can exit.
+
+[1] https://aws.amazon.com/ec2/nitro/nitro-enclaves/
+[2] https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
+[3] https://lwn.net/Articles/807108/
+[4] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
+[5] https://man7.org/linux/man-pages/man7/vsock.7.html
+[6] https://www.kernel.org/doc/html/latest/x86/boot.html
index deaafb6..a6f0a3e 100644 (file)
@@ -1694,7 +1694,6 @@ F:        arch/arm/mach-cns3xxx/
 
 ARM/CAVIUM THUNDER NETWORK DRIVER
 M:     Sunil Goutham <sgoutham@marvell.com>
-M:     Robert Richter <rrichter@marvell.com>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Supported
 F:     drivers/net/ethernet/cavium/thunder/
@@ -1747,6 +1746,7 @@ ARM/CORESIGHT FRAMEWORK AND DRIVERS
 M:     Mathieu Poirier <mathieu.poirier@linaro.org>
 R:     Suzuki K Poulose <suzuki.poulose@arm.com>
 R:     Mike Leach <mike.leach@linaro.org>
+L:     coresight@lists.linaro.org (moderated for non-subscribers)
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 F:     Documentation/ABI/testing/sysfs-bus-coresight-devices-*
@@ -3205,6 +3205,7 @@ S:        Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git
 F:     block/
 F:     drivers/block/
+F:     include/linux/blk*
 F:     kernel/trace/blktrace.c
 F:     lib/sbitmap.c
 
@@ -3388,6 +3389,7 @@ M:        Florian Fainelli <f.fainelli@gmail.com>
 L:     netdev@vger.kernel.org
 L:     openwrt-devel@lists.openwrt.org (subscribers-only)
 S:     Supported
+F:     Documentation/devicetree/bindings/net/dsa/b53.txt
 F:     drivers/net/dsa/b53/*
 F:     include/linux/platform_data/b53.h
 
@@ -3573,13 +3575,28 @@ L:      bcm-kernel-feedback-list@broadcom.com
 S:     Maintained
 F:     drivers/phy/broadcom/phy-brcm-usb*
 
+BROADCOM ETHERNET PHY DRIVERS
+M:     Florian Fainelli <f.fainelli@gmail.com>
+L:     bcm-kernel-feedback-list@broadcom.com
+L:     netdev@vger.kernel.org
+S:     Supported
+F:     Documentation/devicetree/bindings/net/broadcom-bcm87xx.txt
+F:     drivers/net/phy/bcm*.[ch]
+F:     drivers/net/phy/broadcom.c
+F:     include/linux/brcmphy.h
+
 BROADCOM GENET ETHERNET DRIVER
 M:     Doug Berger <opendmb@gmail.com>
 M:     Florian Fainelli <f.fainelli@gmail.com>
 L:     bcm-kernel-feedback-list@broadcom.com
 L:     netdev@vger.kernel.org
 S:     Supported
+F:     Documentation/devicetree/bindings/net/brcm,bcmgenet.txt
+F:     Documentation/devicetree/bindings/net/brcm,unimac-mdio.txt
 F:     drivers/net/ethernet/broadcom/genet/
+F:     drivers/net/mdio/mdio-bcm-unimac.c
+F:     include/linux/platform_data/bcmgenet.h
+F:     include/linux/platform_data/mdio-bcm-unimac.h
 
 BROADCOM IPROC ARM ARCHITECTURE
 M:     Ray Jui <rjui@broadcom.com>
@@ -3931,8 +3948,8 @@ W:        https://wireless.wiki.kernel.org/en/users/Drivers/carl9170
 F:     drivers/net/wireless/ath/carl9170/
 
 CAVIUM I2C DRIVER
-M:     Robert Richter <rrichter@marvell.com>
-S:     Supported
+M:     Robert Richter <rric@kernel.org>
+S:     Odd Fixes
 W:     http://www.marvell.com
 F:     drivers/i2c/busses/i2c-octeon*
 F:     drivers/i2c/busses/i2c-thunderx*
@@ -3947,8 +3964,8 @@ W:        http://www.marvell.com
 F:     drivers/net/ethernet/cavium/liquidio/
 
 CAVIUM MMC DRIVER
-M:     Robert Richter <rrichter@marvell.com>
-S:     Supported
+M:     Robert Richter <rric@kernel.org>
+S:     Odd Fixes
 W:     http://www.marvell.com
 F:     drivers/mmc/host/cavium*
 
@@ -3960,9 +3977,9 @@ W:        http://www.marvell.com
 F:     drivers/crypto/cavium/cpt/
 
 CAVIUM THUNDERX2 ARM64 SOC
-M:     Robert Richter <rrichter@marvell.com>
+M:     Robert Richter <rric@kernel.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
-S:     Maintained
+S:     Odd Fixes
 F:     Documentation/devicetree/bindings/arm/cavium-thunder2.txt
 F:     arch/arm64/boot/dts/cavium/thunder2-99xx*
 
@@ -4084,6 +4101,11 @@ T:       git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F:     drivers/char/
 F:     drivers/misc/
 F:     include/linux/miscdevice.h
+X:     drivers/char/agp/
+X:     drivers/char/hw_random/
+X:     drivers/char/ipmi/
+X:     drivers/char/random.c
+X:     drivers/char/tpm/
 
 CHECKPATCH
 M:     Andy Whitcroft <apw@canonical.com>
@@ -4241,6 +4263,8 @@ S:        Maintained
 F:     .clang-format
 
 CLANG/LLVM BUILD SUPPORT
+M:     Nathan Chancellor <natechancellor@gmail.com>
+M:     Nick Desaulniers <ndesaulniers@google.com>
 L:     clang-built-linux@googlegroups.com
 S:     Supported
 W:     https://clangbuiltlinux.github.io/
@@ -5050,7 +5074,7 @@ F:        include/linux/dm-*.h
 F:     include/uapi/linux/dm-*.h
 
 DEVLINK
-M:     Jiri Pirko <jiri@mellanox.com>
+M:     Jiri Pirko <jiri@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 F:     Documentation/networking/devlink
@@ -5239,6 +5263,7 @@ DOCUMENTATION
 M:     Jonathan Corbet <corbet@lwn.net>
 L:     linux-doc@vger.kernel.org
 S:     Maintained
+P:     Documentation/doc-guide/maintainer-profile.rst
 T:     git git://git.lwn.net/linux.git docs-next
 F:     Documentation/
 F:     scripts/documentation-file-ref-check
@@ -6081,7 +6106,7 @@ F:        include/linux/dynamic_debug.h
 F:     lib/dynamic_debug.c
 
 DYNAMIC INTERRUPT MODERATION
-M:     Tal Gilboa <talgi@mellanox.com>
+M:     Tal Gilboa <talgi@nvidia.com>
 S:     Maintained
 F:     Documentation/networking/net_dim.rst
 F:     include/linux/dim.h
@@ -6161,7 +6186,7 @@ F:        Documentation/devicetree/bindings/edac/aspeed-sdram-edac.txt
 F:     drivers/edac/aspeed_edac.c
 
 EDAC-BLUEFIELD
-M:     Shravan Kumar Ramani <sramani@mellanox.com>
+M:     Shravan Kumar Ramani <sramani@nvidia.com>
 S:     Supported
 F:     drivers/edac/bluefield_edac.c
 
@@ -6173,16 +6198,15 @@ F:      drivers/edac/highbank*
 
 EDAC-CAVIUM OCTEON
 M:     Ralf Baechle <ralf@linux-mips.org>
-M:     Robert Richter <rrichter@marvell.com>
 L:     linux-edac@vger.kernel.org
 L:     linux-mips@vger.kernel.org
 S:     Supported
 F:     drivers/edac/octeon_edac*
 
 EDAC-CAVIUM THUNDERX
-M:     Robert Richter <rrichter@marvell.com>
+M:     Robert Richter <rric@kernel.org>
 L:     linux-edac@vger.kernel.org
-S:     Supported
+S:     Odd Fixes
 F:     drivers/edac/thunderx_edac*
 
 EDAC-CORE
@@ -6190,7 +6214,7 @@ M:        Borislav Petkov <bp@alien8.de>
 M:     Mauro Carvalho Chehab <mchehab@kernel.org>
 M:     Tony Luck <tony.luck@intel.com>
 R:     James Morse <james.morse@arm.com>
-R:     Robert Richter <rrichter@marvell.com>
+R:     Robert Richter <rric@kernel.org>
 L:     linux-edac@vger.kernel.org
 S:     Supported
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/ras/ras.git edac-for-next
@@ -6483,8 +6507,8 @@ S:        Odd Fixes
 F:     drivers/net/ethernet/agere/
 
 ETHERNET BRIDGE
-M:     Roopa Prabhu <roopa@cumulusnetworks.com>
-M:     Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
+M:     Roopa Prabhu <roopa@nvidia.com>
+M:     Nikolay Aleksandrov <nikolay@nvidia.com>
 L:     bridge@lists.linux-foundation.org (moderated for non-subscribers)
 L:     netdev@vger.kernel.org
 S:     Maintained
@@ -6494,7 +6518,6 @@ F:        net/bridge/
 
 ETHERNET PHY LIBRARY
 M:     Andrew Lunn <andrew@lunn.ch>
-M:     Florian Fainelli <f.fainelli@gmail.com>
 M:     Heiner Kallweit <hkallweit1@gmail.com>
 R:     Russell King <linux@armlinux.org.uk>
 L:     netdev@vger.kernel.org
@@ -6599,7 +6622,7 @@ F:        drivers/iommu/exynos-iommu.c
 
 EZchip NPS platform support
 M:     Vineet Gupta <vgupta@synopsys.com>
-M:     Ofer Levi <oferle@mellanox.com>
+M:     Ofer Levi <oferle@nvidia.com>
 S:     Supported
 F:     arch/arc/boot/dts/eznps.dts
 F:     arch/arc/plat-eznps
@@ -6811,14 +6834,17 @@ F:      drivers/net/ethernet/nvidia/*
 
 FPGA DFL DRIVERS
 M:     Wu Hao <hao.wu@intel.com>
+R:     Tom Rix <trix@redhat.com>
 L:     linux-fpga@vger.kernel.org
 S:     Maintained
+F:     Documentation/ABI/testing/sysfs-bus-dfl
 F:     Documentation/fpga/dfl.rst
 F:     drivers/fpga/dfl*
 F:     include/uapi/linux/fpga-dfl.h
 
 FPGA MANAGER FRAMEWORK
 M:     Moritz Fischer <mdf@kernel.org>
+R:     Tom Rix <trix@redhat.com>
 L:     linux-fpga@vger.kernel.org
 S:     Maintained
 W:     http://www.rocketboards.org
@@ -6884,6 +6910,14 @@ L:       linuxppc-dev@lists.ozlabs.org
 S:     Maintained
 F:     drivers/dma/fsldma.*
 
+FREESCALE DSPI DRIVER
+M:     Vladimir Oltean <olteanv@gmail.com>
+L:     linux-spi@vger.kernel.org
+S:     Maintained
+F:     Documentation/devicetree/bindings/spi/spi-fsl-dspi.txt
+F:     drivers/spi/spi-fsl-dspi.c
+F:     include/linux/spi/spi-fsl-dspi.h
+
 FREESCALE ENETC ETHERNET DRIVERS
 M:     Claudiu Manoil <claudiu.manoil@nxp.com>
 L:     netdev@vger.kernel.org
@@ -7860,6 +7894,13 @@ W:       http://www.hisilicon.com
 F:     Documentation/devicetree/bindings/net/hisilicon*.txt
 F:     drivers/net/ethernet/hisilicon/
 
+HIKEY960 ONBOARD USB GPIO HUB DRIVER
+M:     John Stultz <john.stultz@linaro.org>
+L:     linux-kernel@vger.kernel.org
+S:     Maintained
+F:     drivers/misc/hisi_hikey_usb.c
+F:     Documentation/devicetree/bindings/misc/hisilicon-hikey-usb.yaml
+
 HISILICON PMU DRIVER
 M:     Shaokun Zhang <zhangshaokun@hisilicon.com>
 S:     Supported
@@ -8255,7 +8296,7 @@ IA64 (Itanium) PLATFORM
 M:     Tony Luck <tony.luck@intel.com>
 M:     Fenghua Yu <fenghua.yu@intel.com>
 L:     linux-ia64@vger.kernel.org
-S:     Maintained
+S:     Odd Fixes
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git
 F:     Documentation/ia64/
 F:     arch/ia64/
@@ -8563,7 +8604,7 @@ F:        drivers/iio/pressure/dps310.c
 
 INFINIBAND SUBSYSTEM
 M:     Doug Ledford <dledford@redhat.com>
-M:     Jason Gunthorpe <jgg@mellanox.com>
+M:     Jason Gunthorpe <jgg@nvidia.com>
 L:     linux-rdma@vger.kernel.org
 S:     Supported
 W:     https://github.com/linux-rdma/rdma-core
@@ -9226,7 +9267,7 @@ F:        drivers/firmware/iscsi_ibft*
 
 ISCSI EXTENSIONS FOR RDMA (ISER) INITIATOR
 M:     Sagi Grimberg <sagi@grimberg.me>
-M:     Max Gurtovoy <maxg@mellanox.com>
+M:     Max Gurtovoy <maxg@nvidia.com>
 L:     linux-rdma@vger.kernel.org
 S:     Supported
 W:     http://www.openfabrics.org
@@ -9775,7 +9816,7 @@ F:        drivers/scsi/53c700*
 
 LEAKING_ADDRESSES
 M:     Tobin C. Harding <me@tobin.cc>
-M:     Tycho Andersen <tycho@tycho.ws>
+M:     Tycho Andersen <tycho@tycho.pizza>
 L:     kernel-hardening@lists.openwall.com
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tobin/leaks.git
@@ -11072,7 +11113,7 @@ F:      Documentation/devicetree/bindings/input/touchscreen/melfas_mip4.txt
 F:     drivers/input/touchscreen/melfas_mip4.c
 
 MELLANOX ETHERNET DRIVER (mlx4_en)
-M:     Tariq Toukan <tariqt@mellanox.com>
+M:     Tariq Toukan <tariqt@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11080,7 +11121,7 @@ Q:      http://patchwork.ozlabs.org/project/netdev/list/
 F:     drivers/net/ethernet/mellanox/mlx4/en_*
 
 MELLANOX ETHERNET DRIVER (mlx5e)
-M:     Saeed Mahameed <saeedm@mellanox.com>
+M:     Saeed Mahameed <saeedm@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11088,7 +11129,7 @@ Q:      http://patchwork.ozlabs.org/project/netdev/list/
 F:     drivers/net/ethernet/mellanox/mlx5/core/en_*
 
 MELLANOX ETHERNET INNOVA DRIVERS
-R:     Boris Pismenny <borisp@mellanox.com>
+R:     Boris Pismenny <borisp@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11099,8 +11140,8 @@ F:      drivers/net/ethernet/mellanox/mlx5/core/fpga/*
 F:     include/linux/mlx5/mlx5_ifc_fpga.h
 
 MELLANOX ETHERNET SWITCH DRIVERS
-M:     Jiri Pirko <jiri@mellanox.com>
-M:     Ido Schimmel <idosch@mellanox.com>
+M:     Jiri Pirko <jiri@nvidia.com>
+M:     Ido Schimmel <idosch@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11109,7 +11150,7 @@ F:      drivers/net/ethernet/mellanox/mlxsw/
 F:     tools/testing/selftests/drivers/net/mlxsw/
 
 MELLANOX FIRMWARE FLASH LIBRARY (mlxfw)
-M:     mlxsw@mellanox.com
+M:     mlxsw@nvidia.com
 L:     netdev@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11119,7 +11160,7 @@ F:      drivers/net/ethernet/mellanox/mlxfw/
 MELLANOX HARDWARE PLATFORM SUPPORT
 M:     Andy Shevchenko <andy@infradead.org>
 M:     Darren Hart <dvhart@infradead.org>
-M:     Vadim Pasternak <vadimp@mellanox.com>
+M:     Vadim Pasternak <vadimp@nvidia.com>
 L:     platform-driver-x86@vger.kernel.org
 S:     Supported
 F:     Documentation/ABI/testing/sysfs-platform-mellanox-bootctl
@@ -11127,7 +11168,7 @@ F:      drivers/platform/mellanox/
 F:     include/linux/platform_data/mlxreg.h
 
 MELLANOX MLX4 core VPI driver
-M:     Tariq Toukan <tariqt@mellanox.com>
+M:     Tariq Toukan <tariqt@nvidia.com>
 L:     netdev@vger.kernel.org
 L:     linux-rdma@vger.kernel.org
 S:     Supported
@@ -11137,7 +11178,7 @@ F:      drivers/net/ethernet/mellanox/mlx4/
 F:     include/linux/mlx4/
 
 MELLANOX MLX4 IB driver
-M:     Yishai Hadas <yishaih@mellanox.com>
+M:     Yishai Hadas <yishaih@nvidia.com>
 L:     linux-rdma@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11147,8 +11188,8 @@ F:      include/linux/mlx4/
 F:     include/uapi/rdma/mlx4-abi.h
 
 MELLANOX MLX5 core VPI driver
-M:     Saeed Mahameed <saeedm@mellanox.com>
-M:     Leon Romanovsky <leonro@mellanox.com>
+M:     Saeed Mahameed <saeedm@nvidia.com>
+M:     Leon Romanovsky <leonro@nvidia.com>
 L:     netdev@vger.kernel.org
 L:     linux-rdma@vger.kernel.org
 S:     Supported
@@ -11159,7 +11200,7 @@ F:      drivers/net/ethernet/mellanox/mlx5/core/
 F:     include/linux/mlx5/
 
 MELLANOX MLX5 IB driver
-M:     Leon Romanovsky <leonro@mellanox.com>
+M:     Leon Romanovsky <leonro@nvidia.com>
 L:     linux-rdma@vger.kernel.org
 S:     Supported
 W:     http://www.mellanox.com
@@ -11169,8 +11210,8 @@ F:      include/linux/mlx5/
 F:     include/uapi/rdma/mlx5-abi.h
 
 MELLANOX MLXCPLD I2C AND MUX DRIVER
-M:     Vadim Pasternak <vadimp@mellanox.com>
-M:     Michael Shych <michaelsh@mellanox.com>
+M:     Vadim Pasternak <vadimp@nvidia.com>
+M:     Michael Shych <michaelsh@nvidia.com>
 L:     linux-i2c@vger.kernel.org
 S:     Supported
 F:     Documentation/i2c/busses/i2c-mlxcpld.rst
@@ -11178,7 +11219,7 @@ F:      drivers/i2c/busses/i2c-mlxcpld.c
 F:     drivers/i2c/muxes/i2c-mux-mlxcpld.c
 
 MELLANOX MLXCPLD LED DRIVER
-M:     Vadim Pasternak <vadimp@mellanox.com>
+M:     Vadim Pasternak <vadimp@nvidia.com>
 L:     linux-leds@vger.kernel.org
 S:     Supported
 F:     Documentation/leds/leds-mlxcpld.rst
@@ -11186,7 +11227,7 @@ F:      drivers/leds/leds-mlxcpld.c
 F:     drivers/leds/leds-mlxreg.c
 
 MELLANOX PLATFORM DRIVER
-M:     Vadim Pasternak <vadimp@mellanox.com>
+M:     Vadim Pasternak <vadimp@nvidia.com>
 L:     platform-driver-x86@vger.kernel.org
 S:     Supported
 F:     drivers/platform/x86/mlx-platform.c
@@ -12167,8 +12208,8 @@ F:      net/ipv6/syncookies.c
 F:     net/ipv6/tcp*.c
 
 NETWORKING [TLS]
-M:     Boris Pismenny <borisp@mellanox.com>
-M:     Aviad Yehezkel <aviadye@mellanox.com>
+M:     Boris Pismenny <borisp@nvidia.com>
+M:     Aviad Yehezkel <aviadye@nvidia.com>
 M:     John Fastabend <john.fastabend@gmail.com>
 M:     Daniel Borkmann <daniel@iogearbox.net>
 M:     Jakub Kicinski <kuba@kernel.org>
@@ -12268,6 +12309,19 @@ S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/lftan/nios2.git
 F:     arch/nios2/
 
+NITRO ENCLAVES (NE)
+M:     Andra Paraschiv <andraprs@amazon.com>
+M:     Alexandru Vasile <lexnv@amazon.com>
+M:     Alexandru Ciobotaru <alcioa@amazon.com>
+L:     linux-kernel@vger.kernel.org
+S:     Supported
+W:     https://aws.amazon.com/ec2/nitro/nitro-enclaves/
+F:     Documentation/virt/ne_overview.rst
+F:     drivers/virt/nitro_enclaves/
+F:     include/linux/nitro_enclaves.h
+F:     include/uapi/linux/nitro_enclaves.h
+F:     samples/nitro_enclaves/
+
 NOHZ, DYNTICKS SUPPORT
 M:     Frederic Weisbecker <fweisbec@gmail.com>
 M:     Thomas Gleixner <tglx@linutronix.de>
@@ -12468,7 +12522,7 @@ S:      Supported
 F:     drivers/nfc/nxp-nci
 
 OBJAGG
-M:     Jiri Pirko <jiri@mellanox.com>
+M:     Jiri Pirko <jiri@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 F:     include/linux/objagg.h
@@ -13110,7 +13164,7 @@ F:      drivers/video/logo/logo_parisc*
 F:     include/linux/hp_sdc.h
 
 PARMAN
-M:     Jiri Pirko <jiri@mellanox.com>
+M:     Jiri Pirko <jiri@nvidia.com>
 L:     netdev@vger.kernel.org
 S:     Supported
 F:     include/linux/parman.h
@@ -13429,10 +13483,10 @@ F:    Documentation/devicetree/bindings/pci/axis,artpec*
 F:     drivers/pci/controller/dwc/*artpec*
 
 PCIE DRIVER FOR CAVIUM THUNDERX
-M:     Robert Richter <rrichter@marvell.com>
+M:     Robert Richter <rric@kernel.org>
 L:     linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
-S:     Supported
+S:     Odd Fixes
 F:     drivers/pci/controller/pci-thunder-*
 
 PCIE DRIVER FOR HISILICON
@@ -13569,12 +13623,18 @@ F:    kernel/events/*
 F:     tools/lib/perf/
 F:     tools/perf/
 
-PERFORMANCE EVENTS SUBSYSTEM ARM64 PMU EVENTS
+PERFORMANCE EVENTS TOOLING ARM64
 R:     John Garry <john.garry@huawei.com>
 R:     Will Deacon <will@kernel.org>
+R:     Mathieu Poirier <mathieu.poirier@linaro.org>
+R:     Leo Yan <leo.yan@linaro.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Supported
+F:     tools/build/feature/test-libopencsd.c
+F:     tools/perf/arch/arm*/
 F:     tools/perf/pmu-events/arch/arm64/
+F:     tools/perf/util/arm-spe*
+F:     tools/perf/util/cs-etm*
 
 PERSONALITY HANDLING
 M:     Christoph Hellwig <hch@infradead.org>
@@ -14365,7 +14425,7 @@ M:      Rob Clark <robdclark@gmail.com>
 L:     iommu@lists.linux-foundation.org
 L:     linux-arm-msm@vger.kernel.org
 S:     Maintained
-F:     drivers/iommu/qcom_iommu.c
+F:     drivers/iommu/arm/arm-smmu/qcom_iommu.c
 
 QUALCOMM IPCC MAILBOX DRIVER
 M:     Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
@@ -15546,6 +15606,7 @@ F:      include/uapi/linux/sed*
 SECURITY CONTACT
 M:     Security Officers <security@kernel.org>
 S:     Supported
+F:     Documentation/admin-guide/security-bugs.rst
 
 SECURITY SUBSYSTEM
 M:     James Morris <jmorris@namei.org>
@@ -16034,7 +16095,7 @@ F:      drivers/infiniband/sw/siw/
 F:     include/uapi/rdma/siw-abi.h
 
 SOFT-ROCE DRIVER (rxe)
-M:     Zhu Yanjun <yanjunz@mellanox.com>
+M:     Zhu Yanjun <yanjunz@nvidia.com>
 L:     linux-rdma@vger.kernel.org
 S:     Supported
 F:     drivers/infiniband/sw/rxe/
@@ -17116,8 +17177,8 @@ S:      Maintained
 F:     Documentation/devicetree/bindings/arm/keystone/ti,k3-sci-common.yaml
 F:     Documentation/devicetree/bindings/arm/keystone/ti,sci.txt
 F:     Documentation/devicetree/bindings/clock/ti,sci-clk.txt
-F:     Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.txt
-F:     Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.txt
+F:     Documentation/devicetree/bindings/interrupt-controller/ti,sci-inta.yaml
+F:     Documentation/devicetree/bindings/interrupt-controller/ti,sci-intr.yaml
 F:     Documentation/devicetree/bindings/reset/ti,sci-reset.txt
 F:     Documentation/devicetree/bindings/soc/ti/sci-pm-domain.txt
 F:     drivers/clk/keystone/sci-clk.c
@@ -17214,8 +17275,8 @@ S:      Maintained
 F:     drivers/net/thunderbolt.c
 
 THUNDERX GPIO DRIVER
-M:     Robert Richter <rrichter@marvell.com>
-S:     Maintained
+M:     Robert Richter <rric@kernel.org>
+S:     Odd Fixes
 F:     drivers/gpio/gpio-thunderx.c
 
 TI AM437X VPFE DRIVER
@@ -18874,6 +18935,15 @@ S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core
 F:     arch/x86/platform
 
+X86 PLATFORM UV HPE SUPERDOME FLEX
+M:     Steve Wahl <steve.wahl@hpe.com>
+R:     Dimitri Sivanich <dimitri.sivanich@hpe.com>
+R:     Russ Anderson <russ.anderson@hpe.com>
+S:     Supported
+F:     arch/x86/include/asm/uv/
+F:     arch/x86/kernel/apic/x2apic_uv_x.c
+F:     arch/x86/platform/uv/
+
 X86 VDSO
 M:     Andy Lutomirski <luto@kernel.org>
 L:     linux-kernel@vger.kernel.org
index 9cac6fd..19d0128 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 VERSION = 5
 PATCHLEVEL = 9
 SUBLEVEL = 0
-EXTRAVERSION = -rc1
+EXTRAVERSION = -rc5
 NAME = Kleptomaniac Octopus
 
 # *DOCUMENTATION*
@@ -265,8 +265,7 @@ no-dot-config-targets := $(clean-targets) \
                         $(version_h) headers headers_% archheaders archscripts \
                         %asm-generic kernelversion %src-pkg dt_binding_check \
                         outputmakefile
-no-sync-config-targets := $(no-dot-config-targets) install %install \
-                          kernelrelease
+no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
 single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
 
 config-build   :=
@@ -292,7 +291,7 @@ ifneq ($(KBUILD_EXTMOD),)
 endif
 
 ifeq ($(KBUILD_EXTMOD),)
-        ifneq ($(filter config %config,$(MAKECMDGOALS)),)
+        ifneq ($(filter %config,$(MAKECMDGOALS)),)
                config-build := 1
                 ifneq ($(words $(MAKECMDGOALS)),1)
                        mixed-build := 1
@@ -883,10 +882,6 @@ KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
 LDFLAGS_vmlinux += --gc-sections
 endif
 
-ifdef CONFIG_LIVEPATCH
-KBUILD_CFLAGS += $(call cc-option, -flive-patching=inline-clone)
-endif
-
 ifdef CONFIG_SHADOW_CALL_STACK
 CC_FLAGS_SCS   := -fsanitize=shadow-call-stack
 KBUILD_CFLAGS  += $(CC_FLAGS_SCS)
index ac110ae..5b60c24 100644 (file)
@@ -212,7 +212,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
                            STO_ALPHA_STD_GPLOAD)
                                /* Omit the prologue. */
                                value += 8;
-                       /* FALLTHRU */
+                       fallthrough;
                case R_ALPHA_BRADDR:
                        value -= (u64)location + 4;
                        if (value & 3)
index a813020..15bc9d1 100644 (file)
@@ -453,7 +453,7 @@ syscall_restart(unsigned long r0, unsigned long r19,
                        regs->r0 = EINTR;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case ERESTARTNOINTR:
                regs->r0 = r0;  /* reset v0 and a3 and replay syscall */
                regs->r19 = r19;
index 49754e0..921d4b6 100644 (file)
@@ -883,7 +883,7 @@ do_entUnaUser(void __user * va, unsigned long opcode,
 
        case 0x26: /* sts */
                fake_reg = s_reg_to_mem(alpha_read_fp_reg(reg));
-               /* FALLTHRU */
+               fallthrough;
 
        case 0x2c: /* stl */
                __asm__ __volatile__(
@@ -911,7 +911,7 @@ do_entUnaUser(void __user * va, unsigned long opcode,
 
        case 0x27: /* stt */
                fake_reg = alpha_read_fp_reg(reg);
-               /* FALLTHRU */
+               fallthrough;
 
        case 0x2d: /* stq */
                __asm__ __volatile__(
index 9acbeba..dcaa44e 100644 (file)
@@ -88,6 +88,8 @@
 
        arcpct: pct {
                compatible = "snps,archs-pct";
+               interrupt-parent = <&cpu_intc>;
+               interrupts = <20>;
        };
 
        /* TIMER0 with interrupt for clockevent */
                        reg = <0x8000 0x2000>;
                        interrupts = <10>;
                        interrupt-names = "macirq";
-                       phy-mode = "rgmii";
+                       phy-mode = "rgmii-id";
                        snps,pbl = <32>;
                        snps,multicast-filter-bins = <256>;
                        clocks = <&gmacclk>;
                                #address-cells = <1>;
                                #size-cells = <0>;
                                compatible = "snps,dwmac-mdio";
-                               phy0: ethernet-phy@0 {
+                               phy0: ethernet-phy@0 { /* Micrel KSZ9031 */
                                        reg = <0>;
                                };
                        };
index b747f2e..6147db9 100644 (file)
  * vineetg: April 2010
  *  -Switched pgtable_t from being struct page * to unsigned long
  *      =Needed so that Page Table allocator (pte_alloc_one) is not forced to
- *       to deal with struct page. Thay way in future we can make it allocate
+ *       deal with struct page. That way in future we can make it allocate
  *       multiple PG Tbls in one Page Frame
  *      =sweet side effect is avoiding calls to ugly page_address( ) from the
- *       pg-tlb allocator sub-sys (pte_alloc_one, ptr_free, pmd_populate
+ *       pg-tlb allocator sub-sys (pte_alloc_one, ptr_free, pmd_populate)
  *
  *  Amit Bhor, Sameer Dhavale: Codito Technologies 2004
  */
index d04837d..03f8b1b 100644 (file)
@@ -339,7 +339,7 @@ void __kprobes disasm_instr(unsigned long addr, struct disasm_state *state,
 
        case op_LDWX_S: /* LDWX_S c, [b, u6] */
                state->x = 1;
-               /* intentional fall-through */
+               fallthrough;
 
        case op_LDW_S:  /* LDW_S c, [b, u6] */
                state->zz = 2;
index 661fd84..79849f3 100644 (file)
@@ -562,7 +562,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
 {
        struct arc_reg_pct_build pct_bcr;
        struct arc_reg_cc_build cc_bcr;
-       int i, has_interrupts;
+       int i, has_interrupts, irq;
        int counter_size;       /* in bits */
 
        union cc_name {
@@ -637,13 +637,7 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
                .attr_groups    = arc_pmu->attr_groups,
        };
 
-       if (has_interrupts) {
-               int irq = platform_get_irq(pdev, 0);
-
-               if (irq < 0) {
-                       pr_err("Cannot get IRQ number for the platform\n");
-                       return -ENODEV;
-               }
+       if (has_interrupts && (irq = platform_get_irq(pdev, 0) >= 0)) {
 
                arc_pmu->irq = irq;
 
@@ -652,9 +646,9 @@ static int arc_pmu_device_probe(struct platform_device *pdev)
                                   this_cpu_ptr(&arc_pmu_cpu));
 
                on_each_cpu(arc_cpu_pmu_irq_init, &irq, 1);
-
-       } else
+       } else {
                arc_pmu->pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT;
+       }
 
        /*
         * perf parser doesn't really like '-' symbol in events name, so let's
index 3d57ed0..8222f8c 100644 (file)
@@ -321,7 +321,7 @@ static void arc_restart_syscall(struct k_sigaction *ka, struct pt_regs *regs)
                        regs->r0 = -EINTR;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
 
        case -ERESTARTNOINTR:
                /*
index 28e8bf0..a331bb5 100644 (file)
 
 #define ARC_PATH_MAX   256
 
-/*
- * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25)
- *   -Prints 3 regs per line and a CR.
- *   -To continue, callee regs right after scratch, special handling of CR
- */
-static noinline void print_reg_file(long *reg_rev, int start_num)
+static noinline void print_regs_scratch(struct pt_regs *regs)
 {
-       unsigned int i;
-       char buf[512];
-       int n = 0, len = sizeof(buf);
-
-       for (i = start_num; i < start_num + 13; i++) {
-               n += scnprintf(buf + n, len - n, "r%02u: 0x%08lx\t",
-                              i, (unsigned long)*reg_rev);
-
-               if (((i + 1) % 3) == 0)
-                       n += scnprintf(buf + n, len - n, "\n");
-
-               /* because pt_regs has regs reversed: r12..r0, r25..r13 */
-               if (is_isa_arcv2() && start_num == 0)
-                       reg_rev++;
-               else
-                       reg_rev--;
-       }
-
-       if (start_num != 0)
-               n += scnprintf(buf + n, len - n, "\n\n");
+       pr_cont("BTA: 0x%08lx\n SP: 0x%08lx  FP: 0x%08lx BLK: %pS\n",
+               regs->bta, regs->sp, regs->fp, (void *)regs->blink);
+       pr_cont("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
+               regs->lp_start, regs->lp_end, regs->lp_count);
 
-       /* To continue printing callee regs on same line as scratch regs */
-       if (start_num == 0)
-               pr_info("%s", buf);
-       else
-               pr_cont("%s\n", buf);
+       pr_info("r00: 0x%08lx\tr01: 0x%08lx\tr02: 0x%08lx\n"    \
+               "r03: 0x%08lx\tr04: 0x%08lx\tr05: 0x%08lx\n"    \
+               "r06: 0x%08lx\tr07: 0x%08lx\tr08: 0x%08lx\n"    \
+               "r09: 0x%08lx\tr10: 0x%08lx\tr11: 0x%08lx\n"    \
+               "r12: 0x%08lx\t",
+               regs->r0, regs->r1, regs->r2,
+               regs->r3, regs->r4, regs->r5,
+               regs->r6, regs->r7, regs->r8,
+               regs->r9, regs->r10, regs->r11,
+               regs->r12);
 }
 
-static void show_callee_regs(struct callee_regs *cregs)
+static void print_regs_callee(struct callee_regs *regs)
 {
-       print_reg_file(&(cregs->r13), 13);
+       pr_cont("r13: 0x%08lx\tr14: 0x%08lx\n"                  \
+               "r15: 0x%08lx\tr16: 0x%08lx\tr17: 0x%08lx\n"    \
+               "r18: 0x%08lx\tr19: 0x%08lx\tr20: 0x%08lx\n"    \
+               "r21: 0x%08lx\tr22: 0x%08lx\tr23: 0x%08lx\n"    \
+               "r24: 0x%08lx\tr25: 0x%08lx\n",
+               regs->r13, regs->r14,
+               regs->r15, regs->r16, regs->r17,
+               regs->r18, regs->r19, regs->r20,
+               regs->r21, regs->r22, regs->r23,
+               regs->r24, regs->r25);
 }
 
 static void print_task_path_n_nm(struct task_struct *tsk)
@@ -175,7 +168,7 @@ static void show_ecr_verbose(struct pt_regs *regs)
 void show_regs(struct pt_regs *regs)
 {
        struct task_struct *tsk = current;
-       struct callee_regs *cregs;
+       struct callee_regs *cregs = (struct callee_regs *)tsk->thread.callee_reg;
 
        /*
         * generic code calls us with preemption disabled, but some calls
@@ -204,25 +197,15 @@ void show_regs(struct pt_regs *regs)
                        STS_BIT(regs, A2), STS_BIT(regs, A1),
                        STS_BIT(regs, E2), STS_BIT(regs, E1));
 #else
-       pr_cont(" [%2s%2s%2s%2s]",
+       pr_cont(" [%2s%2s%2s%2s]   ",
                        STS_BIT(regs, IE),
                        (regs->status32 & STATUS_U_MASK) ? "U " : "K ",
                        STS_BIT(regs, DE), STS_BIT(regs, AE));
 #endif
-       pr_cont("  BTA: 0x%08lx\n  SP: 0x%08lx  FP: 0x%08lx BLK: %pS\n",
-               regs->bta, regs->sp, regs->fp, (void *)regs->blink);
-       pr_info("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n",
-               regs->lp_start, regs->lp_end, regs->lp_count);
-
-       /* print regs->r0 thru regs->r12
-        * Sequential printing was generating horrible code
-        */
-       print_reg_file(&(regs->r0), 0);
 
-       /* If Callee regs were saved, display them too */
-       cregs = (struct callee_regs *)current->thread.callee_reg;
+       print_regs_scratch(regs);
        if (cregs)
-               show_callee_regs(cregs);
+               print_regs_callee(cregs);
 
        preempt_disable();
 }
index f87758a..74ad425 100644 (file)
@@ -572,7 +572,7 @@ static unsigned long read_pointer(const u8 **pLoc, const void *end,
 #else
                BUILD_BUG_ON(sizeof(u32) != sizeof(value));
 #endif
-               /* Fall through */
+               fallthrough;
        case DW_EH_PE_native:
                if (end < (const void *)(ptr.pul + 1))
                        return 0;
@@ -827,7 +827,7 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc,
                        case DW_CFA_def_cfa:
                                state->cfa.reg = get_uleb128(&ptr.p8, end);
                                unw_debug("cfa_def_cfa: r%lu ", state->cfa.reg);
-                               /* fall through */
+                               fallthrough;
                        case DW_CFA_def_cfa_offset:
                                state->cfa.offs = get_uleb128(&ptr.p8, end);
                                unw_debug("cfa_def_cfa_offset: 0x%lx ",
@@ -835,7 +835,7 @@ static int processCFI(const u8 *start, const u8 *end, unsigned long targetLoc,
                                break;
                        case DW_CFA_def_cfa_sf:
                                state->cfa.reg = get_uleb128(&ptr.p8, end);
-                               /* fall through */
+                               fallthrough;
                        case DW_CFA_def_cfa_offset_sf:
                                state->cfa.offs = get_sleb128(&ptr.p8, end)
                                    * state->dataAlign;
index f886ac6..3a35b82 100644 (file)
@@ -26,8 +26,8 @@ static unsigned long low_mem_sz;
 
 #ifdef CONFIG_HIGHMEM
 static unsigned long min_high_pfn, max_high_pfn;
-static u64 high_mem_start;
-static u64 high_mem_sz;
+static phys_addr_t high_mem_start;
+static phys_addr_t high_mem_sz;
 #endif
 
 #ifdef CONFIG_DISCONTIGMEM
@@ -69,6 +69,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
                high_mem_sz = size;
                in_use = 1;
                memblock_add_node(base, size, 1);
+               memblock_reserve(base, size);
 #endif
        }
 
@@ -157,7 +158,7 @@ void __init setup_arch_memory(void)
        min_high_pfn = PFN_DOWN(high_mem_start);
        max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
 
-       max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
+       max_zone_pfn[ZONE_HIGHMEM] = min_low_pfn;
 
        high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
        kmap_init();
@@ -166,22 +167,26 @@ void __init setup_arch_memory(void)
        free_area_init(max_zone_pfn);
 }
 
-/*
- * mem_init - initializes memory
- *
- * Frees up bootmem
- * Calculates and displays memory available/used
- */
-void __init mem_init(void)
+static void __init highmem_init(void)
 {
 #ifdef CONFIG_HIGHMEM
        unsigned long tmp;
 
-       reset_all_zones_managed_pages();
+       memblock_free(high_mem_start, high_mem_sz);
        for (tmp = min_high_pfn; tmp < max_high_pfn; tmp++)
                free_highmem_page(pfn_to_page(tmp));
 #endif
+}
 
+/*
+ * mem_init - initializes memory
+ *
+ * Frees up bootmem
+ * Calculates and displays memory available/used
+ */
+void __init mem_init(void)
+{
        memblock_free_all();
+       highmem_init();
        mem_init_print_info(NULL);
 }
index a4a6153..77712c5 100644 (file)
@@ -33,7 +33,6 @@
 #define CTOP_AUX_DPC                           (CTOP_AUX_BASE + 0x02C)
 #define CTOP_AUX_LPC                           (CTOP_AUX_BASE + 0x030)
 #define CTOP_AUX_EFLAGS                                (CTOP_AUX_BASE + 0x080)
-#define CTOP_AUX_IACK                          (CTOP_AUX_BASE + 0x088)
 #define CTOP_AUX_GPA1                          (CTOP_AUX_BASE + 0x08C)
 #define CTOP_AUX_UDMC                          (CTOP_AUX_BASE + 0x300)
 
index cbebed5..e8df458 100644 (file)
                };
 
                qspi: spi@27200 {
-                       compatible = "brcm,spi-bcm-qspi", "brcm,spi-nsp-qspi";
+                       compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi";
                        reg = <0x027200 0x184>,
                              <0x027000 0x124>,
                              <0x11c408 0x004>,
index 0346ea6..c846fa3 100644 (file)
                };
 
                qspi: spi@27200 {
-                       compatible = "brcm,spi-bcm-qspi", "brcm,spi-nsp-qspi";
+                       compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi";
                        reg = <0x027200 0x184>,
                              <0x027000 0x124>,
                              <0x11c408 0x004>,
index 2d9b4dd..0016720 100644 (file)
        };
 
        spi@18029200 {
-               compatible = "brcm,spi-bcm-qspi", "brcm,spi-nsp-qspi";
+               compatible = "brcm,spi-nsp-qspi", "brcm,spi-bcm-qspi";
                reg = <0x18029200 0x184>,
                      <0x18029000 0x124>,
                      <0x1811b408 0x004>,
index 7a3d1d3..8f94364 100644 (file)
@@ -13,7 +13,7 @@
 
        backlight: backlight-lvds {
                compatible = "pwm-backlight";
-               pwms = <&pwm3 0 20000>;
+               pwms = <&pwm3 0 20000 0>;
                brightness-levels = <0 4 8 16 32 64 128 255>;
                default-brightness-level = <6>;
                power-supply = <&reg_lcd>;
index dffafbc..349959d 100644 (file)
@@ -30,7 +30,7 @@
        };
 
        /* PRTWD2 rev 1 bitbang I2C for Ethernet Switch */
-       i2c@4 {
+       i2c {
                compatible = "i2c-gpio";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_i2c4>;
index 7705285..4d01c33 100644 (file)
@@ -22,8 +22,6 @@
 
        gpio-keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                user-pb {
                        label = "user_pb";
index 0b02c7e..f4dc462 100644 (file)
 #define MX6SX_PAD_QSPI1B_DQS__SIM_M_HADDR_15                      0x01B0 0x04F8 0x0000 0x7 0x0
 #define MX6SX_PAD_QSPI1B_SCLK__QSPI1_B_SCLK                       0x01B4 0x04FC 0x0000 0x0 0x0
 #define MX6SX_PAD_QSPI1B_SCLK__UART3_DCE_RX                       0x01B4 0x04FC 0x0840 0x1 0x4
-#define MX6SX_PAD_QSPI1B_SCLK__UART3_DTE_TX                       0x01B4 0x04FC 0x0000 0x0 0x0
+#define MX6SX_PAD_QSPI1B_SCLK__UART3_DTE_TX                       0x01B4 0x04FC 0x0000 0x1 0x0
 #define MX6SX_PAD_QSPI1B_SCLK__ECSPI3_SCLK                        0x01B4 0x04FC 0x0730 0x2 0x1
 #define MX6SX_PAD_QSPI1B_SCLK__ESAI_RX_HF_CLK                     0x01B4 0x04FC 0x0780 0x3 0x2
 #define MX6SX_PAD_QSPI1B_SCLK__CSI1_DATA_16                       0x01B4 0x04FC 0x06DC 0x4 0x1
index e5e20b0..7cb6153 100644 (file)
@@ -58,7 +58,7 @@
                          <&clks IMX7D_ENET1_TIME_ROOT_CLK>;
        assigned-clock-parents = <&clks IMX7D_PLL_ENET_MAIN_100M_CLK>;
        assigned-clock-rates = <0>, <100000000>;
-       phy-mode = "rgmii";
+       phy-mode = "rgmii-id";
        phy-handle = <&fec1_phy>;
        status = "okay";
 
index 3674396..b7ea37a 100644 (file)
                        clocks = <&pcc2 IMX7ULP_CLK_RGPIO2P1>,
                                 <&pcc3 IMX7ULP_CLK_PCTLC>;
                        clock-names = "gpio", "port";
-                       gpio-ranges = <&iomuxc1 0 0 32>;
+                       gpio-ranges = <&iomuxc1 0 0 20>;
                };
 
                gpio_ptd: gpio@40af0000 {
                        clocks = <&pcc2 IMX7ULP_CLK_RGPIO2P1>,
                                 <&pcc3 IMX7ULP_CLK_PCTLD>;
                        clock-names = "gpio", "port";
-                       gpio-ranges = <&iomuxc1 0 32 32>;
+                       gpio-ranges = <&iomuxc1 0 32 12>;
                };
 
                gpio_pte: gpio@40b00000 {
                        clocks = <&pcc2 IMX7ULP_CLK_RGPIO2P1>,
                                 <&pcc3 IMX7ULP_CLK_PCTLE>;
                        clock-names = "gpio", "port";
-                       gpio-ranges = <&iomuxc1 0 64 32>;
+                       gpio-ranges = <&iomuxc1 0 64 16>;
                };
 
                gpio_ptf: gpio@40b10000 {
                        clocks = <&pcc2 IMX7ULP_CLK_RGPIO2P1>,
                                 <&pcc3 IMX7ULP_CLK_PCTLF>;
                        clock-names = "gpio", "port";
-                       gpio-ranges = <&iomuxc1 0 96 32>;
+                       gpio-ranges = <&iomuxc1 0 96 20>;
                };
        };
 
index 100396f..395e05f 100644 (file)
@@ -51,6 +51,8 @@
 
 &mcbsp2 {
        status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mcbsp2_pins>;
 };
 
 &charger {
                regulator-max-microvolt = <3300000>;
        };
 
-       lcd0: display@0 {
-               compatible = "panel-dpi";
-               label = "28";
-               status = "okay";
-               /* default-on; */
+       lcd0: display {
+               /* This isn't the exact LCD, but the timings meet spec */
+               compatible = "logicpd,type28";
                pinctrl-names = "default";
                pinctrl-0 = <&lcd_enable_pin>;
-               enable-gpios = <&gpio5 27 GPIO_ACTIVE_HIGH>;    /* gpio155, lcd INI */
+               backlight = <&bl>;
+               enable-gpios = <&gpio5 27 GPIO_ACTIVE_HIGH>;
                port {
                        lcd_in: endpoint {
                                remote-endpoint = <&dpi_out>;
                        };
                };
-
-               panel-timing {
-                       clock-frequency = <9000000>;
-                       hactive = <480>;
-                       vactive = <272>;
-                       hfront-porch = <3>;
-                       hback-porch = <2>;
-                       hsync-len = <42>;
-                       vback-porch = <3>;
-                       vfront-porch = <2>;
-                       vsync-len = <11>;
-                       hsync-active = <1>;
-                       vsync-active = <1>;
-                       de-active = <1>;
-                       pixelclk-active = <0>;
-               };
        };
 
        bl: backlight {
index 381f0e8..b0f6613 100644 (file)
@@ -81,6 +81,8 @@
 };
 
 &mcbsp2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mcbsp2_pins>;
        status = "okay";
 };
 
index 069af9a..827373e 100644 (file)
                        #address-cells = <1>;
                        #size-cells = <0>;
                        reg = <0x0 0x1550000 0x0 0x10000>,
-                             <0x0 0x40000000 0x0 0x40000000>;
+                             <0x0 0x40000000 0x0 0x20000000>;
                        reg-names = "QuadSPI", "QuadSPI-memory";
                        interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
                        clock-names = "qspi_en", "qspi";
index 5da9cff..a82c962 100644 (file)
                                        };
                                };
 
-                               target-module@5000 {
+                               target-module@4000 {
                                        compatible = "ti,sysc-omap2", "ti,sysc";
-                                       reg = <0x5000 0x4>,
-                                             <0x5010 0x4>,
-                                             <0x5014 0x4>;
+                                       reg = <0x4000 0x4>,
+                                             <0x4010 0x4>,
+                                             <0x4014 0x4>;
                                        reg-names = "rev", "sysc", "syss";
                                        ti,sysc-sidle = <SYSC_IDLE_FORCE>,
                                                        <SYSC_IDLE_NO>,
                                        ti,syss-mask = <1>;
                                        #address-cells = <1>;
                                        #size-cells = <1>;
-                                       ranges = <0 0x5000 0x1000>;
+                                       ranges = <0 0x4000 0x1000>;
 
                                        dsi1: encoder@0 {
                                                compatible = "ti,omap5-dsi";
                                                reg-names = "proto", "phy", "pll";
                                                interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;
                                                status = "disabled";
-                                               clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>;
-                                               clock-names = "fck";
+                                               clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
+                                                        <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
+                                               clock-names = "fck", "sys_clk";
                                        };
                                };
 
                                                reg-names = "proto", "phy", "pll";
                                                interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
                                                status = "disabled";
-                                               clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>;
-                                               clock-names = "fck";
+                                               clocks = <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 8>,
+                                                        <&dss_clkctrl OMAP5_DSS_CORE_CLKCTRL 10>;
+                                               clock-names = "fck", "sys_clk";
                                        };
                                };
 
index fc4abef..0013ec3 100644 (file)
                timer3: timer3@ffd00100 {
                        compatible = "snps,dw-apb-timer";
                        interrupts = <0 118 IRQ_TYPE_LEVEL_HIGH>;
-                       reg = <0xffd01000 0x100>;
+                       reg = <0xffd00100 0x100>;
                        clocks = <&l4_sys_free_clk>;
                        clock-names = "timer";
                        resets = <&rst L4SYSTIMER1_RESET>;
index 0fe03aa..2259d11 100644 (file)
                        };
 
                        ocotp: ocotp@400a5000 {
-                               compatible = "fsl,vf610-ocotp";
+                               compatible = "fsl,vf610-ocotp", "syscon";
                                reg = <0x400a5000 0x1000>;
                                clocks = <&clks VF610_CLK_OCOTP>;
                        };
index a9755c5..b06e537 100644 (file)
@@ -1,13 +1,11 @@
 CONFIG_SYSVIPC=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
+CONFIG_PREEMPT=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
 CONFIG_LOG_BUF_SHIFT=14
 CONFIG_BLK_DEV_INITRD=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-CONFIG_PARTITION_ADVANCED=y
 CONFIG_ARCH_MULTI_V4T=y
 CONFIG_ARCH_MULTI_V5=y
 # CONFIG_ARCH_MULTI_V7 is not set
@@ -15,19 +13,17 @@ CONFIG_ARCH_INTEGRATOR=y
 CONFIG_ARCH_INTEGRATOR_AP=y
 CONFIG_INTEGRATOR_IMPD1=y
 CONFIG_ARCH_INTEGRATOR_CP=y
-CONFIG_PCI=y
-CONFIG_PREEMPT=y
 CONFIG_AEABI=y
 # CONFIG_ATAGS is not set
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_CMDLINE="console=ttyAM0,38400n8 root=/dev/nfs ip=bootp"
 CONFIG_CPU_FREQ=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
 CONFIG_CPU_FREQ_GOV_USERSPACE=y
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPUFREQ_DT=y
-CONFIG_CMA=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_PARTITION_ADVANCED=y
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -37,6 +33,7 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_IP_PNP_BOOTP=y
 # CONFIG_IPV6 is not set
+CONFIG_PCI=y
 CONFIG_MTD=y
 CONFIG_MTD_CMDLINE_PARTS=y
 CONFIG_MTD_AFS_PARTS=y
@@ -52,9 +49,12 @@ CONFIG_BLK_DEV_RAM_SIZE=8192
 CONFIG_NETDEVICES=y
 CONFIG_E100=y
 CONFIG_SMC91X=y
+CONFIG_INPUT_EVDEV=y
 # CONFIG_KEYBOARD_ATKBD is not set
+CONFIG_KEYBOARD_GPIO=y
 # CONFIG_SERIO_SERPORT is not set
 CONFIG_DRM=y
+CONFIG_DRM_DISPLAY_CONNECTOR=y
 CONFIG_DRM_SIMPLE_BRIDGE=y
 CONFIG_DRM_PL111=y
 CONFIG_FB_MODE_HELPERS=y
index 7fff88e..7a4853b 100644 (file)
@@ -547,7 +547,7 @@ static int arch_build_bp_info(struct perf_event *bp,
                if ((hw->ctrl.type != ARM_BREAKPOINT_EXECUTE)
                        && max_watchpoint_len >= 8)
                        break;
-               /* Else, fall through */
+               fallthrough;
        default:
                return -EINVAL;
        }
@@ -612,12 +612,12 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
                /* Allow halfword watchpoints and breakpoints. */
                if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2)
                        break;
-               /* Else, fall through */
+               fallthrough;
        case 3:
                /* Allow single byte watchpoint. */
                if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1)
                        break;
-               /* Else, fall through */
+               fallthrough;
        default:
                ret = -EINVAL;
                goto out;
@@ -884,7 +884,7 @@ static int hw_breakpoint_pending(unsigned long addr, unsigned int fsr,
                break;
        case ARM_ENTRY_ASYNC_WATCHPOINT:
                WARN(1, "Asynchronous watchpoint exception taken. Debugging results may be unreliable\n");
-               /* Fall through */
+               fallthrough;
        case ARM_ENTRY_SYNC_WATCHPOINT:
                watchpoint_handler(addr, fsr, regs);
                break;
@@ -933,7 +933,7 @@ static bool core_has_os_save_restore(void)
                ARM_DBG_READ(c1, c1, 4, oslsr);
                if (oslsr & ARM_OSLSR_OSLM0)
                        return true;
-               /* Else, fall through */
+               fallthrough;
        default:
                return false;
        }
index c9dc912..c1892f7 100644 (file)
@@ -596,7 +596,7 @@ static int do_signal(struct pt_regs *regs, int syscall)
                switch (retval) {
                case -ERESTART_RESTARTBLOCK:
                        restart -= 2;
-                       /* Fall through */
+                       fallthrough;
                case -ERESTARTNOHAND:
                case -ERESTARTSYS:
                case -ERESTARTNOINTR:
index 1c05c5b..757032d 100644 (file)
@@ -49,7 +49,7 @@ static int crunch_do(struct notifier_block *self, unsigned long cmd, void *t)
                 * FALLTHROUGH: Ensure we don't try to overwrite our newly
                 * initialised state information on the first fault.
                 */
-               /* Fall through */
+               fallthrough;
 
        case THREAD_NOTIFY_EXIT:
                crunch_task_release(thread);
index 2d86381..7a6f74c 100644 (file)
@@ -123,19 +123,19 @@ void mmp2_pm_enter_lowpower_mode(int state)
        case POWER_MODE_SYS_SLEEP:
                apcr |= MPMU_PCR_PJ_SLPEN;              /* set the SLPEN bit */
                apcr |= MPMU_PCR_PJ_VCTCXOSD;           /* set VCTCXOSD */
-               /* fall through */
+               fallthrough;
        case POWER_MODE_CHIP_SLEEP:
                apcr |= MPMU_PCR_PJ_SLPEN;
-               /* fall through */
+               fallthrough;
        case POWER_MODE_APPS_SLEEP:
                apcr |= MPMU_PCR_PJ_APBSD;              /* set APBSD */
-               /* fall through */
+               fallthrough;
        case POWER_MODE_APPS_IDLE:
                apcr |= MPMU_PCR_PJ_AXISD;              /* set AXISDD bit */
                apcr |= MPMU_PCR_PJ_DDRCORSD;           /* set DDRCORSD bit */
                idle_cfg |= APMU_PJ_IDLE_CFG_PJ_PWRDWN; /* PJ power down */
                apcr |= MPMU_PCR_PJ_SPSD;
-               /* fall through */
+               fallthrough;
        case POWER_MODE_CORE_EXTIDLE:
                idle_cfg |= APMU_PJ_IDLE_CFG_PJ_IDLE;   /* set the IDLE bit */
                idle_cfg &= ~APMU_PJ_IDLE_CFG_ISO_MODE_CNTRL_MASK;
index 69ebe18..1d71d73 100644 (file)
@@ -145,23 +145,23 @@ void pxa910_pm_enter_lowpower_mode(int state)
        case POWER_MODE_UDR:
                /* only shutdown APB in UDR */
                apcr |= MPMU_APCR_STBYEN | MPMU_APCR_APBSD;
-               /* fall through */
+               fallthrough;
        case POWER_MODE_SYS_SLEEP:
                apcr |= MPMU_APCR_SLPEN;                /* set the SLPEN bit */
                apcr |= MPMU_APCR_VCTCXOSD;             /* set VCTCXOSD */
-               /* fall through */
+               fallthrough;
        case POWER_MODE_APPS_SLEEP:
                apcr |= MPMU_APCR_DDRCORSD;             /* set DDRCORSD */
-               /* fall through */
+               fallthrough;
        case POWER_MODE_APPS_IDLE:
                apcr |= MPMU_APCR_AXISD;                /* set AXISDD bit */
-               /* fall through */
+               fallthrough;
        case POWER_MODE_CORE_EXTIDLE:
                idle_cfg |= APMU_MOH_IDLE_CFG_MOH_IDLE;
                idle_cfg |= APMU_MOH_IDLE_CFG_MOH_PWRDWN;
                idle_cfg |= APMU_MOH_IDLE_CFG_MOH_PWR_SW(3)
                        | APMU_MOH_IDLE_CFG_MOH_L2_PWR_SW(3);
-               /* fall through */
+               fallthrough;
        case POWER_MODE_CORE_INTIDLE:
                break;
        }
index 1d119b9..59755b5 100644 (file)
@@ -396,7 +396,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "3.1";
                        break;
                case 7:
-               /* FALLTHROUGH */
                default:
                        /* Use the latest known revision as default */
                        omap_revision = OMAP3430_REV_ES3_1_2;
@@ -416,7 +415,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "1.0";
                        break;
                case 1:
-               /* FALLTHROUGH */
                default:
                        omap_revision = AM35XX_REV_ES1_1;
                        cpu_rev = "1.1";
@@ -435,7 +433,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "1.1";
                        break;
                case 2:
-               /* FALLTHROUGH */
                default:
                        omap_revision = OMAP3630_REV_ES1_2;
                        cpu_rev = "1.2";
@@ -456,7 +453,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "2.0";
                        break;
                case 3:
-                       /* FALLTHROUGH */
                default:
                        omap_revision = TI8168_REV_ES2_1;
                        cpu_rev = "2.1";
@@ -473,7 +469,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "2.0";
                        break;
                case 2:
-               /* FALLTHROUGH */
                default:
                        omap_revision = AM335X_REV_ES2_1;
                        cpu_rev = "2.1";
@@ -491,7 +486,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "1.1";
                        break;
                case 2:
-               /* FALLTHROUGH */
                default:
                        omap_revision = AM437X_REV_ES1_2;
                        cpu_rev = "1.2";
@@ -502,7 +496,6 @@ void __init omap3xxx_check_revision(void)
        case 0xb968:
                switch (rev) {
                case 0:
-               /* FALLTHROUGH */
                case 1:
                        omap_revision = TI8148_REV_ES1_0;
                        cpu_rev = "1.0";
@@ -512,7 +505,6 @@ void __init omap3xxx_check_revision(void)
                        cpu_rev = "2.0";
                        break;
                case 3:
-               /* FALLTHROUGH */
                default:
                        omap_revision = TI8148_REV_ES2_1;
                        cpu_rev = "2.1";
index 54aff33..bfa5e1b 100644 (file)
@@ -74,7 +74,7 @@ static struct powerdomain *_get_pwrdm(struct device *dev)
                return pwrdm;
 
        clk = of_clk_get(dev->of_node->parent, 0);
-       if (!clk) {
+       if (IS_ERR(clk)) {
                dev_err(dev, "no fck found\n");
                return NULL;
        }
index 6b4548f..fc7bb2c 100644 (file)
@@ -240,7 +240,7 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
                if (pdev->dev.of_node)
                        omap_device_build_from_dt(pdev);
                omap_auxdata_legacy_init(dev);
-               /* fall through */
+               fallthrough;
        default:
                od = to_omap_device(pdev);
                if (od)
index 6df395f..f5dfddf 100644 (file)
@@ -298,11 +298,7 @@ static void omap3_pm_idle(void)
        if (omap_irq_pending())
                return;
 
-       trace_cpu_idle_rcuidle(1, smp_processor_id());
-
        omap_sram_idle();
-
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_SUSPEND
index d13344b..87cb472 100644 (file)
@@ -624,7 +624,7 @@ static void __init dns323_init(void)
                 dns323ab_leds[0].active_low = 1;
                 gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable");
                 gpio_direction_output(DNS323_GPIO_LED_POWER1, 0);
-               /* Fall through */
+               fallthrough;
        case DNS323_REV_B1:
                i2c_register_board_info(0, dns323ab_i2c_devices,
                                ARRAY_SIZE(dns323ab_i2c_devices));
index ea2c842..d23970b 100644 (file)
@@ -46,7 +46,7 @@ static int __init parse_tag_acorn(const struct tag *tag)
        switch (tag->u.acorn.vram_pages) {
        case 512:
                vram_size += PAGE_SIZE * 256;
-               /* Fall through - ??? */
+               fallthrough;    /* ??? */
        case 256:
                vram_size += PAGE_SIZE * 256;
        default:
index 76a65df..d5c805a 100644 (file)
@@ -70,7 +70,7 @@ static void __init tegra_cpu_reset_handler_enable(void)
        switch (err) {
        case -ENOSYS:
                tegra_cpu_reset_handler_set(reset_address);
-               /* fall through */
+               fallthrough;
        case 0:
                is_enabled = true;
                break;
index f4bfc1c..ea81e89 100644 (file)
@@ -694,7 +694,7 @@ thumb2arm(u16 tinstr)
                        return subset[(L<<1) | ((tinstr & (1<<8)) >> 8)] |
                            (tinstr & 255);             /* register_list */
                }
-               /* Else, fall through - for illegal instruction case */
+               fallthrough;    /* for illegal instruction case */
 
        default:
                return BAD_INSTR;
@@ -750,7 +750,7 @@ do_alignment_t32_to_handler(u32 *pinstr, struct pt_regs *regs,
        case 0xe8e0:
        case 0xe9e0:
                poffset->un = (tinst2 & 0xff) << 2;
-               /* Fall through */
+               fallthrough;
 
        case 0xe940:
        case 0xe9c0:
index c0fbfca..114c05a 100644 (file)
@@ -71,7 +71,7 @@ static void cpu_v7_spectre_init(void)
                /* Other ARM CPUs require no workaround */
                if (read_cpuid_implementor() == ARM_CPU_IMP_ARM)
                        break;
-               /* fallthrough */
+               fallthrough;
                /* Cortex A57/A72 require firmware workaround */
        case ARM_CPU_PART_CORTEX_A57:
        case ARM_CPU_PART_CORTEX_A72: {
index b2e9e82..1eb5900 100644 (file)
@@ -309,14 +309,14 @@ void omap_set_dma_src_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
                 * not supported by current hardware on OMAP1
                 * w |= (0x03 << 7);
                 */
-               /* fall through */
+               fallthrough;
        case OMAP_DMA_DATA_BURST_16:
                if (dma_omap2plus()) {
                        burst = 0x3;
                        break;
                }
                /* OMAP1 don't support burst 16 */
-               /* fall through */
+               fallthrough;
        default:
                BUG();
        }
@@ -393,7 +393,7 @@ void omap_set_dma_dest_burst_mode(int lch, enum omap_dma_burst_mode burst_mode)
                        break;
                }
                /* OMAP1 don't support burst 16 */
-               /* fall through */
+               fallthrough;
        default:
                printk(KERN_ERR "Invalid DMA burst mode\n");
                BUG();
index fe81a9c..c84053a 100644 (file)
@@ -307,7 +307,7 @@ static bool __kprobes decode_regs(probes_opcode_t *pinsn, u32 regs, bool modify)
                case REG_TYPE_NOPCWB:
                        if (!is_writeback(insn))
                                break; /* No writeback, so any register is OK */
-                       /* fall through... */
+                       fallthrough;
                case REG_TYPE_NOPC:
                case REG_TYPE_NOPCX:
                        /* Reject PC (R15) */
index 90b5bc7..feefa20 100644 (file)
@@ -280,7 +280,7 @@ void __kprobes kprobe_handler(struct pt_regs *regs)
                                /* A nested probe was hit in FIQ, it is a BUG */
                                pr_warn("Unrecoverable kprobe detected.\n");
                                dump_kprobe(p);
-                               /* fall through */
+                               fallthrough;
                        default:
                                /* impossible cases */
                                BUG();
index 55bc854..130569f 100644 (file)
@@ -82,8 +82,8 @@ endif
 # compiler to generate them and consequently to break the single image contract
 # we pass it only to the assembler. This option is utilized only in case of non
 # integrated assemblers.
-ifneq ($(CONFIG_AS_HAS_ARMV8_4), y)
-branch-prot-flags-$(CONFIG_AS_HAS_PAC) += -Wa,-march=armv8.3-a
+ifeq ($(CONFIG_AS_HAS_PAC), y)
+asm-arch := armv8.3-a
 endif
 endif
 
@@ -91,7 +91,12 @@ KBUILD_CFLAGS += $(branch-prot-flags-y)
 
 ifeq ($(CONFIG_AS_HAS_ARMV8_4), y)
 # make sure to pass the newest target architecture to -march.
-KBUILD_CFLAGS  += -Wa,-march=armv8.4-a
+asm-arch := armv8.4-a
+endif
+
+ifdef asm-arch
+KBUILD_CFLAGS  += -Wa,-march=$(asm-arch) \
+                  -DARM64_ASM_ARCH='"$(asm-arch)"'
 endif
 
 ifeq ($(CONFIG_SHADOW_CALL_STACK), y)
@@ -165,6 +170,8 @@ zinstall install:
 PHONY += vdso_install
 vdso_install:
        $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso $@
+       $(if $(CONFIG_COMPAT_VDSO), \
+               $(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso32 $@)
 
 # We use MRPROPER_FILES and CLEAN_FILES now
 archclean:
index 15f7b0e..3980206 100644 (file)
                };
 
                qspi: spi@66470200 {
-                       compatible = "brcm,spi-bcm-qspi", "brcm,spi-ns2-qspi";
+                       compatible = "brcm,spi-ns2-qspi", "brcm,spi-bcm-qspi";
                        reg = <0x66470200 0x184>,
                                <0x66470000 0x124>,
                                <0x67017408 0x004>,
index a39f0a1..903c0eb 100644 (file)
@@ -28,6 +28,7 @@ dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-lx2160a-honeycomb.dtb
 dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-lx2160a-qds.dtb
 dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-lx2160a-rdb.dtb
 
+dtb-$(CONFIG_ARCH_MXC) += imx8mm-beacon-kit.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mm-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mn-evk.dtb
 dtb-$(CONFIG_ARCH_MXC) += imx8mn-ddr4-evk.dtb
index 9de2aa1..a5154f1 100644 (file)
                                reg = <0x30bd0000 0x10000>;
                                interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clk IMX8MP_CLK_SDMA1_ROOT>,
-                                        <&clk IMX8MP_CLK_SDMA1_ROOT>;
+                                        <&clk IMX8MP_CLK_AHB>;
                                clock-names = "ipg", "ahb";
                                #dma-cells = <3>;
                                fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin";
index f70435c..561fa79 100644 (file)
                        tmu: tmu@30260000 {
                                compatible = "fsl,imx8mq-tmu";
                                reg = <0x30260000 0x10000>;
-                               interrupt = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+                               interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&clk IMX8MQ_CLK_TMU_ROOT>;
                                little-endian;
                                fsl,tmu-range = <0xb0000 0xa0026 0x80048 0x70061>;
index 1a39e0e..5b9ec03 100644 (file)
                clocks = <&pericfg CLK_PERI_MSDC30_0_PD>,
                         <&topckgen CLK_TOP_MSDC50_0_SEL>;
                clock-names = "source", "hclk";
+               resets = <&pericfg MT7622_PERI_MSDC0_SW_RST>;
+               reset-names = "hrst";
                status = "disabled";
        };
 
index 34d249d..8eb61dd 100644 (file)
                compatible = "nvidia,tegra186-sdhci";
                reg = <0x0 0x03400000 0x0 0x10000>;
                interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&bpmp TEGRA186_CLK_SDMMC1>;
-               clock-names = "sdhci";
+               clocks = <&bpmp TEGRA186_CLK_SDMMC1>,
+                        <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
+               clock-names = "sdhci", "tmclk";
                resets = <&bpmp TEGRA186_RESET_SDMMC1>;
                reset-names = "sdhci";
                interconnects = <&mc TEGRA186_MEMORY_CLIENT_SDMMCRA &emc>,
                compatible = "nvidia,tegra186-sdhci";
                reg = <0x0 0x03420000 0x0 0x10000>;
                interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&bpmp TEGRA186_CLK_SDMMC2>;
-               clock-names = "sdhci";
+               clocks = <&bpmp TEGRA186_CLK_SDMMC2>,
+                        <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
+               clock-names = "sdhci", "tmclk";
                resets = <&bpmp TEGRA186_RESET_SDMMC2>;
                reset-names = "sdhci";
                interconnects = <&mc TEGRA186_MEMORY_CLIENT_SDMMCRAA &emc>,
                compatible = "nvidia,tegra186-sdhci";
                reg = <0x0 0x03440000 0x0 0x10000>;
                interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&bpmp TEGRA186_CLK_SDMMC3>;
-               clock-names = "sdhci";
+               clocks = <&bpmp TEGRA186_CLK_SDMMC3>,
+                        <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
+               clock-names = "sdhci", "tmclk";
                resets = <&bpmp TEGRA186_RESET_SDMMC3>;
                reset-names = "sdhci";
                interconnects = <&mc TEGRA186_MEMORY_CLIENT_SDMMCR &emc>,
                compatible = "nvidia,tegra186-sdhci";
                reg = <0x0 0x03460000 0x0 0x10000>;
                interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&bpmp TEGRA186_CLK_SDMMC4>;
-               clock-names = "sdhci";
+               clocks = <&bpmp TEGRA186_CLK_SDMMC4>,
+                        <&bpmp TEGRA186_CLK_SDMMC_LEGACY_TM>;
+               clock-names = "sdhci", "tmclk";
                assigned-clocks = <&bpmp TEGRA186_CLK_SDMMC4>,
                                  <&bpmp TEGRA186_CLK_PLLC4_VCO>;
                assigned-clock-parents = <&bpmp TEGRA186_CLK_PLLC4_VCO>;
index 48160f4..ca5cb6a 100644 (file)
                        compatible = "nvidia,tegra194-sdhci";
                        reg = <0x03400000 0x10000>;
                        interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&bpmp TEGRA194_CLK_SDMMC1>;
-                       clock-names = "sdhci";
+                       clocks = <&bpmp TEGRA194_CLK_SDMMC1>,
+                                <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
+                       clock-names = "sdhci", "tmclk";
                        resets = <&bpmp TEGRA194_RESET_SDMMC1>;
                        reset-names = "sdhci";
                        interconnects = <&mc TEGRA194_MEMORY_CLIENT_SDMMCRA &emc>,
                        compatible = "nvidia,tegra194-sdhci";
                        reg = <0x03440000 0x10000>;
                        interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&bpmp TEGRA194_CLK_SDMMC3>;
-                       clock-names = "sdhci";
+                       clocks = <&bpmp TEGRA194_CLK_SDMMC3>,
+                                <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
+                       clock-names = "sdhci", "tmclk";
                        resets = <&bpmp TEGRA194_RESET_SDMMC3>;
                        reset-names = "sdhci";
                        interconnects = <&mc TEGRA194_MEMORY_CLIENT_SDMMCR &emc>,
                        compatible = "nvidia,tegra194-sdhci";
                        reg = <0x03460000 0x10000>;
                        interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&bpmp TEGRA194_CLK_SDMMC4>;
-                       clock-names = "sdhci";
+                       clocks = <&bpmp TEGRA194_CLK_SDMMC4>,
+                                <&bpmp TEGRA194_CLK_SDMMC_LEGACY_TM>;
+                       clock-names = "sdhci", "tmclk";
                        assigned-clocks = <&bpmp TEGRA194_CLK_SDMMC4>,
                                          <&bpmp TEGRA194_CLK_PLLC4>;
                        assigned-clock-parents =
index 829f786..8cca216 100644 (file)
                compatible = "nvidia,tegra210-sdhci";
                reg = <0x0 0x700b0000 0x0 0x200>;
                interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&tegra_car TEGRA210_CLK_SDMMC1>;
-               clock-names = "sdhci";
+               clocks = <&tegra_car TEGRA210_CLK_SDMMC1>,
+                        <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
+               clock-names = "sdhci", "tmclk";
                resets = <&tegra_car 14>;
                reset-names = "sdhci";
                pinctrl-names = "sdmmc-3v3", "sdmmc-1v8",
                compatible = "nvidia,tegra210-sdhci";
                reg = <0x0 0x700b0200 0x0 0x200>;
                interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&tegra_car TEGRA210_CLK_SDMMC2>;
-               clock-names = "sdhci";
+               clocks = <&tegra_car TEGRA210_CLK_SDMMC2>,
+                        <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
+               clock-names = "sdhci", "tmclk";
                resets = <&tegra_car 9>;
                reset-names = "sdhci";
                pinctrl-names = "sdmmc-1v8-drv";
                compatible = "nvidia,tegra210-sdhci";
                reg = <0x0 0x700b0400 0x0 0x200>;
                interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&tegra_car TEGRA210_CLK_SDMMC3>;
-               clock-names = "sdhci";
+               clocks = <&tegra_car TEGRA210_CLK_SDMMC3>,
+                        <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
+               clock-names = "sdhci", "tmclk";
                resets = <&tegra_car 69>;
                reset-names = "sdhci";
                pinctrl-names = "sdmmc-3v3", "sdmmc-1v8",
                compatible = "nvidia,tegra210-sdhci";
                reg = <0x0 0x700b0600 0x0 0x200>;
                interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&tegra_car TEGRA210_CLK_SDMMC4>;
-               clock-names = "sdhci";
+               clocks = <&tegra_car TEGRA210_CLK_SDMMC4>,
+                        <&tegra_car TEGRA210_CLK_SDMMC_LEGACY>;
+               clock-names = "sdhci", "tmclk";
                resets = <&tegra_car 15>;
                reset-names = "sdhci";
                pinctrl-names = "sdmmc-3v3-drv", "sdmmc-1v8-drv";
index 9edfae5..24ef18f 100644 (file)
                ti,intr-trigger-type = <1>;
                interrupt-controller;
                interrupt-parent = <&gic500>;
-               #interrupt-cells = <2>;
+               #interrupt-cells = <1>;
                ti,sci = <&dmsc>;
-               ti,sci-dst-id = <56>;
-               ti,sci-rm-range-girq = <0x1>;
+               ti,sci-dev-id = <100>;
+               ti,interrupt-ranges = <0 392 32>;
        };
 
        main_navss {
                        ti,intr-trigger-type = <4>;
                        interrupt-controller;
                        interrupt-parent = <&gic500>;
-                       #interrupt-cells = <2>;
+                       #interrupt-cells = <1>;
                        ti,sci = <&dmsc>;
-                       ti,sci-dst-id = <56>;
-                       ti,sci-rm-range-girq = <0x0>, <0x2>;
+                       ti,sci-dev-id = <182>;
+                       ti,interrupt-ranges = <0 64 64>,
+                                             <64 448 64>;
                };
 
                inta_main_udmass: interrupt-controller@33d00000 {
                        msi-controller;
                        ti,sci = <&dmsc>;
                        ti,sci-dev-id = <179>;
-                       ti,sci-rm-range-vint = <0x0>;
-                       ti,sci-rm-range-global-event = <0x1>;
+                       ti,interrupt-ranges = <0 0 256>;
                };
 
                secure_proxy_main: mailbox@32c00000 {
                                <0x0 0x33000000 0x0 0x40000>;
                        reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target";
                        ti,num-rings = <818>;
-                       ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
+                       ti,sci-rm-range-gp-rings = <0x1>; /* GP ring range */
                        ti,dma-ring-reset-quirk;
                        ti,sci = <&dmsc>;
                        ti,sci-dev-id = <187>;
                        ti,sci-dev-id = <188>;
                        ti,ringacc = <&ringacc>;
 
-                       ti,sci-rm-range-tchan = <0x1>, /* TX_HCHAN */
-                                               <0x2>; /* TX_CHAN */
-                       ti,sci-rm-range-rchan = <0x4>, /* RX_HCHAN */
-                                               <0x5>; /* RX_CHAN */
-                       ti,sci-rm-range-rflow = <0x6>; /* GP RFLOW */
+                       ti,sci-rm-range-tchan = <0xf>, /* TX_HCHAN */
+                                               <0xd>; /* TX_CHAN */
+                       ti,sci-rm-range-rchan = <0xb>, /* RX_HCHAN */
+                                               <0xa>; /* RX_CHAN */
+                       ti,sci-rm-range-rflow = <0x0>; /* GP RFLOW */
                };
 
                cpts@310d0000 {
                        reg-names = "cpts";
                        clocks = <&main_cpts_mux>;
                        clock-names = "cpts";
-                       interrupts-extended = <&intr_main_navss 163 0>;
+                       interrupts-extended = <&intr_main_navss 391>;
                        interrupt-names = "cpts";
                        ti,cpts-periodic-outputs = <6>;
                        ti,cpts-ext-ts-inputs = <8>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&intr_main_gpio>;
-               interrupts = <57 256>, <57 257>, <57 258>, <57 259>, <57 260>,
-                               <57 261>;
+               interrupts = <192>, <193>, <194>, <195>, <196>, <197>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <96>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&intr_main_gpio>;
-               interrupts = <58 256>, <58 257>, <58 258>, <58 259>, <58 260>,
-                               <58 261>;
+               interrupts = <200>, <201>, <202>, <203>, <204>, <205>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <90>;
index 8c1abcf..51ca4b4 100644 (file)
                                <0x0 0x2a500000 0x0 0x40000>;
                        reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target";
                        ti,num-rings = <286>;
-                       ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
+                       ti,sci-rm-range-gp-rings = <0x1>; /* GP ring range */
                        ti,dma-ring-reset-quirk;
                        ti,sci = <&dmsc>;
                        ti,sci-dev-id = <195>;
                        ti,sci-dev-id = <194>;
                        ti,ringacc = <&mcu_ringacc>;
 
-                       ti,sci-rm-range-tchan = <0x1>, /* TX_HCHAN */
-                                               <0x2>; /* TX_CHAN */
-                       ti,sci-rm-range-rchan = <0x3>, /* RX_HCHAN */
-                                               <0x4>; /* RX_CHAN */
-                       ti,sci-rm-range-rflow = <0x5>; /* GP RFLOW */
+                       ti,sci-rm-range-tchan = <0xf>, /* TX_HCHAN */
+                                               <0xd>; /* TX_CHAN */
+                       ti,sci-rm-range-rchan = <0xb>, /* RX_HCHAN */
+                                               <0xa>; /* RX_CHAN */
+                       ti,sci-rm-range-rflow = <0x0>; /* GP RFLOW */
                };
        };
 
index 5f55b9e..a1ffe88 100644 (file)
                ti,intr-trigger-type = <1>;
                interrupt-controller;
                interrupt-parent = <&gic500>;
-               #interrupt-cells = <2>;
+               #interrupt-cells = <1>;
                ti,sci = <&dmsc>;
-               ti,sci-dst-id = <56>;
-               ti,sci-rm-range-girq = <0x4>;
+               ti,sci-dev-id = <156>;
+               ti,interrupt-ranges = <0 712 16>;
        };
 
        wkup_gpio0: wkup_gpio0@42110000 {
@@ -86,7 +86,7 @@
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&intr_wkup_gpio>;
-               interrupts = <59 128>, <59 129>, <59 130>, <59 131>;
+               interrupts = <60>, <61>, <62>, <63>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <56>;
index 611e662..b8a8a0f 100644 (file)
 };
 
 &mailbox0_cluster0 {
-       interrupts = <164 0>;
+       interrupts = <436>;
 
        mbox_mcu_r5fss0_core0: mbox-mcu-r5fss0-core0 {
                ti,mbox-tx = <1 0 0>;
 };
 
 &mailbox0_cluster1 {
-       interrupts = <165 0>;
+       interrupts = <432>;
 
        mbox_mcu_r5fss0_core1: mbox-mcu-r5fss0-core1 {
                ti,mbox-tx = <1 0 0>;
index 8bc1e6e..e8fc01d 100644 (file)
 };
 
 &mailbox0_cluster0 {
-       interrupts = <214 0>;
+       interrupts = <436>;
 
        mbox_mcu_r5fss0_core0: mbox-mcu-r5fss0-core0 {
                ti,mbox-rx = <0 0 0>;
 };
 
 &mailbox0_cluster1 {
-       interrupts = <215 0>;
+       interrupts = <432>;
 
        mbox_main_r5fss0_core0: mbox-main-r5fss0-core0 {
                ti,mbox-rx = <0 0 0>;
 };
 
 &mailbox0_cluster2 {
-       interrupts = <216 0>;
+       interrupts = <428>;
 
        mbox_main_r5fss1_core0: mbox-main-r5fss1-core0 {
                ti,mbox-rx = <0 0 0>;
 };
 
 &mailbox0_cluster3 {
-       interrupts = <217 0>;
+       interrupts = <424>;
 
        mbox_c66_0: mbox-c66-0 {
                ti,mbox-rx = <0 0 0>;
 };
 
 &mailbox0_cluster4 {
-       interrupts = <218 0>;
+       interrupts = <420>;
 
        mbox_c71_0: mbox-c71-0 {
                ti,mbox-rx = <0 0 0>;
index d140602..12ceea9 100644 (file)
                ti,intr-trigger-type = <1>;
                interrupt-controller;
                interrupt-parent = <&gic500>;
-               #interrupt-cells = <2>;
+               #interrupt-cells = <1>;
                ti,sci = <&dmsc>;
-               ti,sci-dst-id = <14>;
-               ti,sci-rm-range-girq = <0x1>;
+               ti,sci-dev-id = <131>;
+               ti,interrupt-ranges = <8 392 56>;
        };
 
        main_navss {
                        ti,intr-trigger-type = <4>;
                        interrupt-controller;
                        interrupt-parent = <&gic500>;
-                       #interrupt-cells = <2>;
+                       #interrupt-cells = <1>;
                        ti,sci = <&dmsc>;
-                       ti,sci-dst-id = <14>;
-                       ti,sci-rm-range-girq = <0>, <2>;
+                       ti,sci-dev-id = <213>;
+                       ti,interrupt-ranges = <0 64 64>,
+                                             <64 448 64>,
+                                             <128 672 64>;
                };
 
                main_udmass_inta: interrupt-controller@33d00000 {
                        msi-controller;
                        ti,sci = <&dmsc>;
                        ti,sci-dev-id = <209>;
-                       ti,sci-rm-range-vint = <0xa>;
-                       ti,sci-rm-range-global-event = <0xd>;
+                       ti,interrupt-ranges = <0 0 256>;
                };
 
                secure_proxy_main: mailbox@32c00000 {
                        reg-names = "cpts";
                        clocks = <&k3_clks 201 1>;
                        clock-names = "cpts";
-                       interrupts-extended = <&main_navss_intr 201 0>;
+                       interrupts-extended = <&main_navss_intr 391>;
                        interrupt-names = "cpts";
                        ti,cpts-periodic-outputs = <6>;
                        ti,cpts-ext-ts-inputs = <8>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <105 0>, <105 1>, <105 2>, <105 3>,
-                            <105 4>, <105 5>, <105 6>, <105 7>;
+               interrupts = <256>, <257>, <258>, <259>,
+                            <260>, <261>, <262>, <263>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <128>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <106 0>, <106 1>, <106 2>;
+               interrupts = <288>, <289>, <290>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <36>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <107 0>, <107 1>, <107 2>, <107 3>,
-                            <107 4>, <107 5>, <107 6>, <107 7>;
+               interrupts = <264>, <265>, <266>, <267>,
+                            <268>, <269>, <270>, <271>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <128>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <108 0>, <108 1>, <108 2>;
+               interrupts = <292>, <293>, <294>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <36>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <109 0>, <109 1>, <109 2>, <109 3>,
-                            <109 4>, <109 5>, <109 6>, <109 7>;
+               interrupts = <272>, <273>, <274>, <275>,
+                            <276>, <277>, <278>, <279>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <128>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <110 0>, <110 1>, <110 2>;
+               interrupts = <296>, <297>, <298>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <36>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <111 0>, <111 1>, <111 2>, <111 3>,
-                            <111 4>, <111 5>, <111 6>, <111 7>;
+               interrupts = <280>, <281>, <282>, <283>,
+                            <284>, <285>, <286>, <287>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <128>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&main_gpio_intr>;
-               interrupts = <112 0>, <112 1>, <112 2>;
+               interrupts = <300>, <301>, <302>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <36>;
index 30a735b..c4a48e8 100644 (file)
                ti,intr-trigger-type = <1>;
                interrupt-controller;
                interrupt-parent = <&gic500>;
-               #interrupt-cells = <2>;
+               #interrupt-cells = <1>;
                ti,sci = <&dmsc>;
-               ti,sci-dst-id = <14>;
-               ti,sci-rm-range-girq = <0x5>;
+               ti,sci-dev-id = <137>;
+               ti,interrupt-ranges = <16 960 16>;
        };
 
        wkup_gpio0: gpio@42110000 {
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&wkup_gpio_intr>;
-               interrupts = <113 0>, <113 1>, <113 2>,
-                            <113 3>, <113 4>, <113 5>;
+               interrupts = <103>, <104>, <105>, <106>, <107>, <108>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <84>;
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&wkup_gpio_intr>;
-               interrupts = <114 0>, <114 1>, <114 2>,
-                            <114 3>, <114 4>, <114 5>;
+               interrupts = <112>, <113>, <114>, <115>, <116>, <117>;
                interrupt-controller;
                #interrupt-cells = <2>;
                ti,ngpio = <84>;
index 9174ddc..3ec99f1 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <dt-bindings/power/xlnx-zynqmp-power.h>
+#include <dt-bindings/reset/xlnx-zynqmp-resets.h>
 
 / {
        compatible = "xlnx,zynqmp";
                        };
                };
 
+               psgtr: phy@fd400000 {
+                       compatible = "xlnx,zynqmp-psgtr-v1.1";
+                       status = "disabled";
+                       reg = <0x0 0xfd400000 0x0 0x40000>,
+                             <0x0 0xfd3d0000 0x0 0x1000>;
+                       reg-names = "serdes", "siou";
+                       #phy-cells = <4>;
+               };
+
                rtc: rtc@ffa60000 {
                        compatible = "xlnx,zynqmp-rtc";
                        status = "disabled";
                        power-domains = <&zynqmp_firmware PD_SD_1>;
                };
 
-               smmu: smmu@fd800000 {
+               smmu: iommu@fd800000 {
                        compatible = "arm,mmu-500";
                        reg = <0x0 0xfd800000 0x0 0x20000>;
                        status = "disabled";
index e0f3382..6d04b95 100644 (file)
@@ -724,6 +724,17 @@ CONFIG_USB_GADGET=y
 CONFIG_USB_RENESAS_USBHS_UDC=m
 CONFIG_USB_RENESAS_USB3=m
 CONFIG_USB_TEGRA_XUDC=m
+CONFIG_USB_CONFIGFS=m
+CONFIG_USB_CONFIGFS_SERIAL=y
+CONFIG_USB_CONFIGFS_ACM=y
+CONFIG_USB_CONFIGFS_OBEX=y
+CONFIG_USB_CONFIGFS_NCM=y
+CONFIG_USB_CONFIGFS_ECM=y
+CONFIG_USB_CONFIGFS_ECM_SUBSET=y
+CONFIG_USB_CONFIGFS_RNDIS=y
+CONFIG_USB_CONFIGFS_EEM=y
+CONFIG_USB_CONFIGFS_MASS_STORAGE=y
+CONFIG_USB_CONFIGFS_F_FS=y
 CONFIG_TYPEC=m
 CONFIG_TYPEC_TCPM=m
 CONFIG_TYPEC_FUSB302=m
@@ -914,6 +925,7 @@ CONFIG_ARCH_TEGRA_194_SOC=y
 CONFIG_ARCH_K3_AM6_SOC=y
 CONFIG_ARCH_K3_J721E_SOC=y
 CONFIG_TI_SCI_PM_DOMAINS=y
+CONFIG_EXTCON_PTN5150=m
 CONFIG_EXTCON_USB_GPIO=y
 CONFIG_EXTCON_USBC_CROS_EC=y
 CONFIG_IIO=y
index 51a7ce8..6fb2e6b 100644 (file)
@@ -2,6 +2,12 @@
 #ifndef __ASM_COMPILER_H
 #define __ASM_COMPILER_H
 
+#ifdef ARM64_ASM_ARCH
+#define ARM64_ASM_PREAMBLE ".arch " ARM64_ASM_ARCH "\n"
+#else
+#define ARM64_ASM_PREAMBLE
+#endif
+
 /*
  * The EL0/EL1 pointer bits used by a pointer authentication code.
  * This is dependent on TBI0/TBI1 being enabled, or bits 63:56 would also apply.
index aa4b652..ff328e5 100644 (file)
@@ -95,6 +95,11 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
        return res;
 }
 
+static inline int arch_irqs_disabled(void)
+{
+       return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
 static inline unsigned long arch_local_irq_save(void)
 {
        unsigned long flags;
index 51c1d99..1da8e3d 100644 (file)
  * IMO:                Override CPSR.I and enable signaling with VI
  * FMO:                Override CPSR.F and enable signaling with VF
  * SWIO:       Turn set/way invalidates into set/way clean+invalidate
+ * PTW:                Take a stage2 fault if a stage1 walk steps in device memory
  */
 #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
                         HCR_BSU_IS | HCR_FB | HCR_TAC | \
                         HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
-                        HCR_FMO | HCR_IMO)
+                        HCR_FMO | HCR_IMO | HCR_PTW )
 #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF)
 #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK)
 #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
index fb1a922..6f98fbd 100644 (file)
@@ -169,6 +169,34 @@ extern char __smccc_workaround_1_smc[__SMCCC_WORKAROUND_1_SMC_SZ];
                *__hyp_this_cpu_ptr(sym);                               \
         })
 
+#define __KVM_EXTABLE(from, to)                                                \
+       "       .pushsection    __kvm_ex_table, \"a\"\n"                \
+       "       .align          3\n"                                    \
+       "       .long           (" #from " - .), (" #to " - .)\n"       \
+       "       .popsection\n"
+
+
+#define __kvm_at(at_op, addr)                                          \
+( {                                                                    \
+       int __kvm_at_err = 0;                                           \
+       u64 spsr, elr;                                                  \
+       asm volatile(                                                   \
+       "       mrs     %1, spsr_el2\n"                                 \
+       "       mrs     %2, elr_el2\n"                                  \
+       "1:     at      "at_op", %3\n"                                  \
+       "       isb\n"                                                  \
+       "       b       9f\n"                                           \
+       "2:     msr     spsr_el2, %1\n"                                 \
+       "       msr     elr_el2, %2\n"                                  \
+       "       mov     %w0, %4\n"                                      \
+       "9:\n"                                                          \
+       __KVM_EXTABLE(1b, 2b)                                           \
+       : "+r" (__kvm_at_err), "=&r" (spsr), "=&r" (elr)                \
+       : "r" (addr), "i" (-EFAULT));                                   \
+       __kvm_at_err;                                                   \
+} )
+
+
 #else /* __ASSEMBLY__ */
 
 .macro hyp_adr_this_cpu reg, sym, tmp
@@ -193,6 +221,21 @@ extern char __smccc_workaround_1_smc[__SMCCC_WORKAROUND_1_SMC_SZ];
        ldr     \vcpu, [\ctxt, #HOST_CONTEXT_VCPU]
 .endm
 
+/*
+ * KVM extable for unexpected exceptions.
+ * In the same format _asm_extable, but output to a different section so that
+ * it can be mapped to EL2. The KVM version is not sorted. The caller must
+ * ensure:
+ * x18 has the hypervisor value to allow any Shadow-Call-Stack instrumented
+ * code to write to it, and that SPSR_EL2 and ELR_EL2 are restored by the fixup.
+ */
+.macro _kvm_extable, from, to
+       .pushsection    __kvm_ex_table, "a"
+       .align          3
+       .long           (\from - .), (\to - .)
+       .popsection
+.endm
+
 #endif
 
 #endif /* __ARM_KVM_ASM_H__ */
index 65568b2..905c2b8 100644 (file)
@@ -368,7 +368,6 @@ struct kvm_vcpu_arch {
 
        /* Guest PV state */
        struct {
-               u64 steal;
                u64 last_steal;
                gpa_t base;
        } steal;
@@ -473,7 +472,7 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
 
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 int kvm_unmap_hva_range(struct kvm *kvm,
-                       unsigned long start, unsigned long end);
+                       unsigned long start, unsigned long end, unsigned flags);
 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
@@ -544,6 +543,7 @@ long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu);
 gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu);
 void kvm_update_stolen_time(struct kvm_vcpu *vcpu);
 
+bool kvm_arm_pvtime_supported(void);
 int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
                            struct kvm_device_attr *attr);
 int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu,
index d493174..cc3f5a3 100644 (file)
  * not. The macros handles invoking the asm with or without the
  * register argument as appropriate.
  */
-#define __TLBI_0(op, arg) asm ("tlbi " #op "\n"                                       \
+#define __TLBI_0(op, arg) asm (ARM64_ASM_PREAMBLE                             \
+                              "tlbi " #op "\n"                                \
                   ALTERNATIVE("nop\n                   nop",                  \
                               "dsb ish\n               tlbi " #op,            \
                               ARM64_WORKAROUND_REPEAT_TLBI,                   \
                               CONFIG_ARM64_WORKAROUND_REPEAT_TLBI)            \
                            : : )
 
-#define __TLBI_1(op, arg) asm ("tlbi " #op ", %0\n"                           \
+#define __TLBI_1(op, arg) asm (ARM64_ASM_PREAMBLE                             \
+                              "tlbi " #op ", %0\n"                            \
                   ALTERNATIVE("nop\n                   nop",                  \
                               "dsb ish\n               tlbi " #op ", %0",     \
                               ARM64_WORKAROUND_REPEAT_TLBI,                   \
index 4559664..a85174d 100644 (file)
@@ -322,7 +322,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
                         */
                        if (memblock_is_map_memory(phys))
                                return (void __iomem *)__phys_to_virt(phys);
-                       /* fall through */
+                       fallthrough;
 
                default:
                        if (region->attribute & EFI_MEMORY_WB)
index 6bd1d3a..c332d49 100644 (file)
@@ -910,6 +910,8 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
                .desc = "ARM erratum 1418040",
                .capability = ARM64_WORKAROUND_1418040,
                ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
+               .type = (ARM64_CPUCAP_SCOPE_LOCAL_CPU |
+                        ARM64_CPUCAP_PERMITTED_FOR_LATE_CPU),
        },
 #endif
 #ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT
index a389b99..6424584 100644 (file)
@@ -686,7 +686,7 @@ static s64 arm64_ftr_safe_value(const struct arm64_ftr_bits *ftrp, s64 new,
        case FTR_HIGHER_OR_ZERO_SAFE:
                if (!cur || !new)
                        break;
-               /* Fallthrough */
+               fallthrough;
        case FTR_HIGHER_SAFE:
                ret = new > cur ? new : cur;
                break;
index 393c6fb..d0076c2 100644 (file)
@@ -327,7 +327,6 @@ static void cpuinfo_detect_icache_policy(struct cpuinfo_arm64 *info)
                set_bit(ICACHEF_VPIPT, &__icache_flags);
                break;
        default:
-               /* Fallthrough */
        case ICACHE_POLICY_VIPT:
                /* Assume aliasing */
                set_bit(ICACHEF_ALIASING, &__icache_flags);
index 2646178..55af8b5 100644 (file)
@@ -170,19 +170,6 @@ alternative_cb_end
        stp     x28, x29, [sp, #16 * 14]
 
        .if     \el == 0
-       .if     \regsize == 32
-       /*
-        * If we're returning from a 32-bit task on a system affected by
-        * 1418040 then re-enable userspace access to the virtual counter.
-        */
-#ifdef CONFIG_ARM64_ERRATUM_1418040
-alternative_if ARM64_WORKAROUND_1418040
-       mrs     x0, cntkctl_el1
-       orr     x0, x0, #2      // ARCH_TIMER_USR_VCT_ACCESS_EN
-       msr     cntkctl_el1, x0
-alternative_else_nop_endif
-#endif
-       .endif
        clear_gp_regs
        mrs     x21, sp_el0
        ldr_this_cpu    tsk, __entry_task, x20
@@ -294,14 +281,6 @@ alternative_else_nop_endif
        tst     x22, #PSR_MODE32_BIT            // native task?
        b.eq    3f
 
-#ifdef CONFIG_ARM64_ERRATUM_1418040
-alternative_if ARM64_WORKAROUND_1418040
-       mrs     x0, cntkctl_el1
-       bic     x0, x0, #2                      // ARCH_TIMER_USR_VCT_ACCESS_EN
-       msr     cntkctl_el1, x0
-alternative_else_nop_endif
-#endif
-
 #ifdef CONFIG_ARM64_ERRATUM_845719
 alternative_if ARM64_WORKAROUND_845719
 #ifdef CONFIG_PID_IN_CONTEXTIDR
index af234a1..712e97c 100644 (file)
@@ -257,7 +257,7 @@ static int hw_breakpoint_control(struct perf_event *bp,
                 * level.
                 */
                enable_debug_monitors(dbg_el);
-               /* Fall through */
+               fallthrough;
        case HW_BREAKPOINT_RESTORE:
                /* Setup the address register. */
                write_wb_reg(val_reg, i, info->address);
@@ -541,13 +541,13 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
                        if (hw->ctrl.len == ARM_BREAKPOINT_LEN_2)
                                break;
 
-                       /* Fallthrough */
+                       fallthrough;
                case 3:
                        /* Allow single byte watchpoint. */
                        if (hw->ctrl.len == ARM_BREAKPOINT_LEN_1)
                                break;
 
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        return -EINVAL;
                }
index 9e897c5..8982b68 100644 (file)
@@ -103,6 +103,10 @@ KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
 KVM_NVHE_ALIAS(gic_pmr_sync);
 #endif
 
+/* EL2 exception handling */
+KVM_NVHE_ALIAS(__start___kvm_ex_table);
+KVM_NVHE_ALIAS(__stop___kvm_ex_table);
+
 #endif /* CONFIG_KVM */
 
 #endif /* __ARM64_KERNEL_IMAGE_VARS_H */
index 0ce3a28..2e22443 100644 (file)
@@ -305,8 +305,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs,
                        mod->arch.core.plt_shndx = i;
                else if (!strcmp(secstrings + sechdrs[i].sh_name, ".init.plt"))
                        mod->arch.init.plt_shndx = i;
-               else if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE) &&
-                        !strcmp(secstrings + sechdrs[i].sh_name,
+               else if (!strcmp(secstrings + sechdrs[i].sh_name,
                                 ".text.ftrace_trampoline"))
                        tramp = sechdrs + i;
                else if (sechdrs[i].sh_type == SHT_SYMTAB)
index 1cd1a4d..2a1ad95 100644 (file)
@@ -315,21 +315,21 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
                /* MOVW instruction relocations. */
                case R_AARCH64_MOVW_UABS_G0_NC:
                        overflow_check = false;
-                       /* Fall through */
+                       fallthrough;
                case R_AARCH64_MOVW_UABS_G0:
                        ovf = reloc_insn_movw(RELOC_OP_ABS, loc, val, 0,
                                              AARCH64_INSN_IMM_MOVKZ);
                        break;
                case R_AARCH64_MOVW_UABS_G1_NC:
                        overflow_check = false;
-                       /* Fall through */
+                       fallthrough;
                case R_AARCH64_MOVW_UABS_G1:
                        ovf = reloc_insn_movw(RELOC_OP_ABS, loc, val, 16,
                                              AARCH64_INSN_IMM_MOVKZ);
                        break;
                case R_AARCH64_MOVW_UABS_G2_NC:
                        overflow_check = false;
-                       /* Fall through */
+                       fallthrough;
                case R_AARCH64_MOVW_UABS_G2:
                        ovf = reloc_insn_movw(RELOC_OP_ABS, loc, val, 32,
                                              AARCH64_INSN_IMM_MOVKZ);
@@ -397,7 +397,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
                        break;
                case R_AARCH64_ADR_PREL_PG_HI21_NC:
                        overflow_check = false;
-                       /* Fall through */
+                       fallthrough;
                case R_AARCH64_ADR_PREL_PG_HI21:
                        ovf = reloc_insn_adrp(me, sechdrs, loc, val);
                        if (ovf && ovf != -ERANGE)
index 84ec630..f180449 100644 (file)
@@ -123,10 +123,8 @@ void arch_cpu_idle(void)
         * This should do all the clock switching and wait for interrupt
         * tricks
         */
-       trace_cpu_idle_rcuidle(1, smp_processor_id());
        cpu_do_idle();
        local_irq_enable();
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
@@ -515,6 +513,39 @@ static void entry_task_switch(struct task_struct *next)
        __this_cpu_write(__entry_task, next);
 }
 
+/*
+ * ARM erratum 1418040 handling, affecting the 32bit view of CNTVCT.
+ * Assuming the virtual counter is enabled at the beginning of times:
+ *
+ * - disable access when switching from a 64bit task to a 32bit task
+ * - enable access when switching from a 32bit task to a 64bit task
+ */
+static void erratum_1418040_thread_switch(struct task_struct *prev,
+                                         struct task_struct *next)
+{
+       bool prev32, next32;
+       u64 val;
+
+       if (!(IS_ENABLED(CONFIG_ARM64_ERRATUM_1418040) &&
+             cpus_have_const_cap(ARM64_WORKAROUND_1418040)))
+               return;
+
+       prev32 = is_compat_thread(task_thread_info(prev));
+       next32 = is_compat_thread(task_thread_info(next));
+
+       if (prev32 == next32)
+               return;
+
+       val = read_sysreg(cntkctl_el1);
+
+       if (!next32)
+               val |= ARCH_TIMER_USR_VCT_ACCESS_EN;
+       else
+               val &= ~ARCH_TIMER_USR_VCT_ACCESS_EN;
+
+       write_sysreg(val, cntkctl_el1);
+}
+
 /*
  * Thread switching.
  */
@@ -530,6 +561,7 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
        entry_task_switch(next);
        uao_thread_switch(next);
        ssbs_thread_switch(next);
+       erratum_1418040_thread_switch(prev, next);
 
        /*
         * Complete any pending TLB or cache maintenance on this CPU in case
index 77c4c9b..53acbec 100644 (file)
@@ -280,7 +280,6 @@ u64 cpu_logical_map(int cpu)
 {
        return __cpu_logical_map[cpu];
 }
-EXPORT_SYMBOL_GPL(cpu_logical_map);
 
 void __init __no_sanitize_address setup_arch(char **cmdline_p)
 {
index 03957a1..355ee9e 100644 (file)
@@ -151,7 +151,7 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
                        break;
                }
                pr_crit("CPU%u: may not have shut down cleanly\n", cpu);
-               /* Fall through */
+               fallthrough;
        case CPU_STUCK_IN_KERNEL:
                pr_crit("CPU%u: is stuck in kernel\n", cpu);
                if (status & CPU_STUCK_REASON_52_BIT_VA)
index 5139a5f..d6adb46 100644 (file)
@@ -208,7 +208,7 @@ quiet_cmd_vdsosym = VDSOSYM $@
       cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@
 
 # Install commands for the unstripped file
-quiet_cmd_vdso_install = INSTALL $@
+quiet_cmd_vdso_install = INSTALL32 $@
       cmd_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/vdso/vdso32.so
 
 vdso.so: $(obj)/vdso.so.dbg
index ec8e894..7cba762 100644 (file)
@@ -20,6 +20,13 @@ ENTRY(_text)
 
 jiffies = jiffies_64;
 
+
+#define HYPERVISOR_EXTABLE                                     \
+       . = ALIGN(SZ_8);                                        \
+       __start___kvm_ex_table = .;                             \
+       *(__kvm_ex_table)                                       \
+       __stop___kvm_ex_table = .;
+
 #define HYPERVISOR_TEXT                                        \
        /*                                              \
         * Align to 4 KB so that                        \
@@ -35,6 +42,7 @@ jiffies = jiffies_64;
        __hyp_idmap_text_end = .;                       \
        __hyp_text_start = .;                           \
        *(.hyp.text)                                    \
+       HYPERVISOR_EXTABLE                              \
        __hyp_text_end = .;
 
 #define IDMAP_TEXT                                     \
index 691d21e..b588c3b 100644 (file)
@@ -206,6 +206,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
                 */
                r = 1;
                break;
+       case KVM_CAP_STEAL_TIME:
+               r = kvm_arm_pvtime_supported();
+               break;
        default:
                r = kvm_arch_vm_ioctl_check_extension(kvm, ext);
                break;
@@ -1640,6 +1643,10 @@ int kvm_arch_init(void *opaque)
                return -ENODEV;
        }
 
+       if (cpus_have_final_cap(ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE))
+               kvm_info("Guests without required CPU erratum workarounds can deadlock system!\n" \
+                        "Only trusted guests should be used on this system.\n");
+
        for_each_online_cpu(cpu) {
                smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
                if (ret < 0) {
index fe6c7d7..5d690d6 100644 (file)
@@ -128,7 +128,7 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
        switch (ESR_ELx_EC(esr)) {
        case ESR_ELx_EC_WATCHPT_LOW:
                run->debug.arch.far = vcpu->arch.fault.far_el2;
-               /* fall through */
+               fallthrough;
        case ESR_ELx_EC_SOFTSTP_LOW:
        case ESR_ELx_EC_BREAKPT_LOW:
        case ESR_ELx_EC_BKPT32:
index ee32a77..76e7eaf 100644 (file)
@@ -196,20 +196,23 @@ alternative_endif
        // This is our single instruction exception window. A pending
        // SError is guaranteed to occur at the earliest when we unmask
        // it, and at the latest just after the ISB.
-       .global abort_guest_exit_start
 abort_guest_exit_start:
 
        isb
 
-       .global abort_guest_exit_end
 abort_guest_exit_end:
 
        msr     daifset, #4     // Mask aborts
+       ret
+
+       _kvm_extable    abort_guest_exit_start, 9997f
+       _kvm_extable    abort_guest_exit_end, 9997f
+9997:
+       msr     daifset, #4     // Mask aborts
+       mov     x0, #(1 << ARM_EXIT_WITH_SERROR_BIT)
 
-       // If the exception took place, restore the EL1 exception
-       // context so that we can report some information.
-       // Merge the exception code with the SError pending bit.
-       tbz     x0, #ARM_EXIT_WITH_SERROR_BIT, 1f
+       // restore the EL1 exception context so that we can report some
+       // information. Merge the exception code with the SError pending bit.
        msr     elr_el2, x2
        msr     esr_el2, x3
        msr     spsr_el2, x4
index 689fccb..46b4dab 100644 (file)
 #include <asm/kvm_mmu.h>
 #include <asm/mmu.h>
 
+.macro save_caller_saved_regs_vect
+       /* x0 and x1 were saved in the vector entry */
+       stp     x2, x3,   [sp, #-16]!
+       stp     x4, x5,   [sp, #-16]!
+       stp     x6, x7,   [sp, #-16]!
+       stp     x8, x9,   [sp, #-16]!
+       stp     x10, x11, [sp, #-16]!
+       stp     x12, x13, [sp, #-16]!
+       stp     x14, x15, [sp, #-16]!
+       stp     x16, x17, [sp, #-16]!
+.endm
+
+.macro restore_caller_saved_regs_vect
+       ldp     x16, x17, [sp], #16
+       ldp     x14, x15, [sp], #16
+       ldp     x12, x13, [sp], #16
+       ldp     x10, x11, [sp], #16
+       ldp     x8, x9,   [sp], #16
+       ldp     x6, x7,   [sp], #16
+       ldp     x4, x5,   [sp], #16
+       ldp     x2, x3,   [sp], #16
+       ldp     x0, x1,   [sp], #16
+.endm
+
        .text
 
 .macro do_el2_call
@@ -143,13 +167,19 @@ el1_error:
        b       __guest_exit
 
 el2_sync:
-       /* Check for illegal exception return, otherwise panic */
+       /* Check for illegal exception return */
        mrs     x0, spsr_el2
+       tbnz    x0, #20, 1f
 
-       /* if this was something else, then panic! */
-       tst     x0, #PSR_IL_BIT
-       b.eq    __hyp_panic
+       save_caller_saved_regs_vect
+       stp     x29, x30, [sp, #-16]!
+       bl      kvm_unexpected_el2_exception
+       ldp     x29, x30, [sp], #16
+       restore_caller_saved_regs_vect
 
+       eret
+
+1:
        /* Let's attempt a recovery from the illegal exception return */
        get_vcpu_ptr    x1, x0
        mov     x0, #ARM_EXCEPTION_IL
@@ -157,27 +187,14 @@ el2_sync:
 
 
 el2_error:
-       ldp     x0, x1, [sp], #16
+       save_caller_saved_regs_vect
+       stp     x29, x30, [sp, #-16]!
+
+       bl      kvm_unexpected_el2_exception
+
+       ldp     x29, x30, [sp], #16
+       restore_caller_saved_regs_vect
 
-       /*
-        * Only two possibilities:
-        * 1) Either we come from the exit path, having just unmasked
-        *    PSTATE.A: change the return code to an EL2 fault, and
-        *    carry on, as we're already in a sane state to handle it.
-        * 2) Or we come from anywhere else, and that's a bug: we panic.
-        *
-        * For (1), x0 contains the original return code and x1 doesn't
-        * contain anything meaningful at that stage. We can reuse them
-        * as temp registers.
-        * For (2), who cares?
-        */
-       mrs     x0, elr_el2
-       adr     x1, abort_guest_exit_start
-       cmp     x0, x1
-       adr     x1, abort_guest_exit_end
-       ccmp    x0, x1, #4, ne
-       b.ne    __hyp_panic
-       mov     x0, #(1 << ARM_EXIT_WITH_SERROR_BIT)
        eret
        sb
 
index 0297dc6..5e28ea6 100644 (file)
 #define save_debug(ptr,reg,nr)                                         \
        switch (nr) {                                                   \
        case 15:        ptr[15] = read_debug(reg, 15);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 14:        ptr[14] = read_debug(reg, 14);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 13:        ptr[13] = read_debug(reg, 13);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 12:        ptr[12] = read_debug(reg, 12);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 11:        ptr[11] = read_debug(reg, 11);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 10:        ptr[10] = read_debug(reg, 10);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 9:         ptr[9] = read_debug(reg, 9);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 8:         ptr[8] = read_debug(reg, 8);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 7:         ptr[7] = read_debug(reg, 7);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 6:         ptr[6] = read_debug(reg, 6);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 5:         ptr[5] = read_debug(reg, 5);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 4:         ptr[4] = read_debug(reg, 4);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 3:         ptr[3] = read_debug(reg, 3);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 2:         ptr[2] = read_debug(reg, 2);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 1:         ptr[1] = read_debug(reg, 1);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        default:        ptr[0] = read_debug(reg, 0);                    \
        }
 
 #define restore_debug(ptr,reg,nr)                                      \
        switch (nr) {                                                   \
        case 15:        write_debug(ptr[15], reg, 15);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 14:        write_debug(ptr[14], reg, 14);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 13:        write_debug(ptr[13], reg, 13);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 12:        write_debug(ptr[12], reg, 12);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 11:        write_debug(ptr[11], reg, 11);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 10:        write_debug(ptr[10], reg, 10);                  \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 9:         write_debug(ptr[9], reg, 9);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 8:         write_debug(ptr[8], reg, 8);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 7:         write_debug(ptr[7], reg, 7);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 6:         write_debug(ptr[6], reg, 6);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 5:         write_debug(ptr[5], reg, 5);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 4:         write_debug(ptr[4], reg, 4);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 3:         write_debug(ptr[3], reg, 3);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 2:         write_debug(ptr[2], reg, 2);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        case 1:         write_debug(ptr[1], reg, 1);                    \
-                       /* Fall through */                              \
+                       fallthrough;                                    \
        default:        write_debug(ptr[0], reg, 0);                    \
        }
 
index 426ef65..5b6b8fa 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <asm/barrier.h>
 #include <asm/cpufeature.h>
+#include <asm/extable.h>
 #include <asm/kprobes.h>
 #include <asm/kvm_asm.h>
 #include <asm/kvm_emulate.h>
@@ -29,6 +30,9 @@
 
 extern const char __hyp_panic_string[];
 
+extern struct exception_table_entry __start___kvm_ex_table;
+extern struct exception_table_entry __stop___kvm_ex_table;
+
 /* Check whether the FP regs were dirtied while in the host-side run loop: */
 static inline bool update_fp_enabled(struct kvm_vcpu *vcpu)
 {
@@ -142,10 +146,10 @@ static inline bool __translate_far_to_hpfar(u64 far, u64 *hpfar)
         * saved the guest context yet, and we may return early...
         */
        par = read_sysreg(par_el1);
-       asm volatile("at s1e1r, %0" : : "r" (far));
-       isb();
-
-       tmp = read_sysreg(par_el1);
+       if (!__kvm_at("s1e1r", far))
+               tmp = read_sysreg(par_el1);
+       else
+               tmp = SYS_PAR_EL1_F; /* back to the guest */
        write_sysreg(par, par_el1);
 
        if (unlikely(tmp & SYS_PAR_EL1_F))
@@ -508,4 +512,31 @@ static inline void __set_host_arch_workaround_state(struct kvm_vcpu *vcpu)
 #endif
 }
 
+static inline void __kvm_unexpected_el2_exception(void)
+{
+       unsigned long addr, fixup;
+       struct kvm_cpu_context *host_ctxt;
+       struct exception_table_entry *entry, *end;
+       unsigned long elr_el2 = read_sysreg(elr_el2);
+
+       entry = hyp_symbol_addr(__start___kvm_ex_table);
+       end = hyp_symbol_addr(__stop___kvm_ex_table);
+       host_ctxt = &__hyp_this_cpu_ptr(kvm_host_data)->host_ctxt;
+
+       while (entry < end) {
+               addr = (unsigned long)&entry->insn + entry->insn;
+               fixup = (unsigned long)&entry->fixup + entry->fixup;
+
+               if (addr != elr_el2) {
+                       entry++;
+                       continue;
+               }
+
+               write_sysreg(fixup, elr_el2);
+               return;
+       }
+
+       hyp_panic(host_ctxt);
+}
+
 #endif /* __ARM64_KVM_HYP_SWITCH_H__ */
index 341be2f..0970442 100644 (file)
@@ -270,3 +270,8 @@ void __noreturn hyp_panic(struct kvm_cpu_context *host_ctxt)
                       read_sysreg(hpfar_el2), par, vcpu);
        unreachable();
 }
+
+asmlinkage void kvm_unexpected_el2_exception(void)
+{
+       return __kvm_unexpected_el2_exception();
+}
index 5a00735..452f4ca 100644 (file)
@@ -340,10 +340,10 @@ void __vgic_v3_save_aprs(struct vgic_v3_cpu_if *cpu_if)
        case 7:
                cpu_if->vgic_ap0r[3] = __vgic_v3_read_ap0rn(3);
                cpu_if->vgic_ap0r[2] = __vgic_v3_read_ap0rn(2);
-               /* Fall through */
+               fallthrough;
        case 6:
                cpu_if->vgic_ap0r[1] = __vgic_v3_read_ap0rn(1);
-               /* Fall through */
+               fallthrough;
        default:
                cpu_if->vgic_ap0r[0] = __vgic_v3_read_ap0rn(0);
        }
@@ -352,10 +352,10 @@ void __vgic_v3_save_aprs(struct vgic_v3_cpu_if *cpu_if)
        case 7:
                cpu_if->vgic_ap1r[3] = __vgic_v3_read_ap1rn(3);
                cpu_if->vgic_ap1r[2] = __vgic_v3_read_ap1rn(2);
-               /* Fall through */
+               fallthrough;
        case 6:
                cpu_if->vgic_ap1r[1] = __vgic_v3_read_ap1rn(1);
-               /* Fall through */
+               fallthrough;
        default:
                cpu_if->vgic_ap1r[0] = __vgic_v3_read_ap1rn(0);
        }
@@ -373,10 +373,10 @@ void __vgic_v3_restore_aprs(struct vgic_v3_cpu_if *cpu_if)
        case 7:
                __vgic_v3_write_ap0rn(cpu_if->vgic_ap0r[3], 3);
                __vgic_v3_write_ap0rn(cpu_if->vgic_ap0r[2], 2);
-               /* Fall through */
+               fallthrough;
        case 6:
                __vgic_v3_write_ap0rn(cpu_if->vgic_ap0r[1], 1);
-               /* Fall through */
+               fallthrough;
        default:
                __vgic_v3_write_ap0rn(cpu_if->vgic_ap0r[0], 0);
        }
@@ -385,10 +385,10 @@ void __vgic_v3_restore_aprs(struct vgic_v3_cpu_if *cpu_if)
        case 7:
                __vgic_v3_write_ap1rn(cpu_if->vgic_ap1r[3], 3);
                __vgic_v3_write_ap1rn(cpu_if->vgic_ap1r[2], 2);
-               /* Fall through */
+               fallthrough;
        case 6:
                __vgic_v3_write_ap1rn(cpu_if->vgic_ap1r[1], 1);
-               /* Fall through */
+               fallthrough;
        default:
                __vgic_v3_write_ap1rn(cpu_if->vgic_ap1r[0], 0);
        }
index c52d714..c1da4f8 100644 (file)
@@ -217,3 +217,8 @@ void __noreturn hyp_panic(struct kvm_cpu_context *host_ctxt)
        __hyp_call_panic(spsr, elr, par, host_ctxt);
        unreachable();
 }
+
+asmlinkage void kvm_unexpected_el2_exception(void)
+{
+       return __kvm_unexpected_el2_exception();
+}
index 0121ef2..9a636b8 100644 (file)
@@ -343,7 +343,8 @@ static void unmap_stage2_p4ds(struct kvm_s2_mmu *mmu, pgd_t *pgd,
  * destroying the VM), otherwise another faulting VCPU may come in and mess
  * with things behind our backs.
  */
-static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size)
+static void __unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size,
+                                bool may_block)
 {
        struct kvm *kvm = mmu->kvm;
        pgd_t *pgd;
@@ -369,11 +370,16 @@ static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 si
                 * If the range is too large, release the kvm->mmu_lock
                 * to prevent starvation and lockup detector warnings.
                 */
-               if (next != end)
+               if (may_block && next != end)
                        cond_resched_lock(&kvm->mmu_lock);
        } while (pgd++, addr = next, addr != end);
 }
 
+static void unmap_stage2_range(struct kvm_s2_mmu *mmu, phys_addr_t start, u64 size)
+{
+       __unmap_stage2_range(mmu, start, size, true);
+}
+
 static void stage2_flush_ptes(struct kvm_s2_mmu *mmu, pmd_t *pmd,
                              phys_addr_t addr, phys_addr_t end)
 {
@@ -1871,6 +1877,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
            !fault_supports_stage2_huge_mapping(memslot, hva, vma_pagesize)) {
                force_pte = true;
                vma_pagesize = PAGE_SIZE;
+               vma_shift = PAGE_SHIFT;
        }
 
        /*
@@ -1964,7 +1971,12 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
                (fault_status == FSC_PERM &&
                 stage2_is_exec(mmu, fault_ipa, vma_pagesize));
 
-       if (vma_pagesize == PUD_SIZE) {
+       /*
+        * If PUD_SIZE == PMD_SIZE, there is no real PUD level, and
+        * all we have is a 2-level page table. Trying to map a PUD in
+        * this case would be fatally wrong.
+        */
+       if (PUD_SIZE != PMD_SIZE && vma_pagesize == PUD_SIZE) {
                pud_t new_pud = kvm_pfn_pud(pfn, mem_type);
 
                new_pud = kvm_pud_mkhuge(new_pud);
@@ -2208,18 +2220,21 @@ static int handle_hva_to_gpa(struct kvm *kvm,
 
 static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t gpa, u64 size, void *data)
 {
-       unmap_stage2_range(&kvm->arch.mmu, gpa, size);
+       unsigned flags = *(unsigned *)data;
+       bool may_block = flags & MMU_NOTIFIER_RANGE_BLOCKABLE;
+
+       __unmap_stage2_range(&kvm->arch.mmu, gpa, size, may_block);
        return 0;
 }
 
 int kvm_unmap_hva_range(struct kvm *kvm,
-                       unsigned long start, unsigned long end)
+                       unsigned long start, unsigned long end, unsigned flags)
 {
        if (!kvm->arch.mmu.pgd)
                return 0;
 
        trace_kvm_unmap_hva_range(start, end);
-       handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
+       handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, &flags);
        return 0;
 }
 
index f7b52ce..920ac43 100644 (file)
 void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
 {
        struct kvm *kvm = vcpu->kvm;
-       u64 steal;
-       __le64 steal_le;
-       u64 offset;
-       int idx;
        u64 base = vcpu->arch.steal.base;
+       u64 last_steal = vcpu->arch.steal.last_steal;
+       u64 offset = offsetof(struct pvclock_vcpu_stolen_time, stolen_time);
+       u64 steal = 0;
+       int idx;
 
        if (base == GPA_INVALID)
                return;
 
-       /* Let's do the local bookkeeping */
-       steal = vcpu->arch.steal.steal;
-       steal += current->sched_info.run_delay - vcpu->arch.steal.last_steal;
-       vcpu->arch.steal.last_steal = current->sched_info.run_delay;
-       vcpu->arch.steal.steal = steal;
-
-       steal_le = cpu_to_le64(steal);
        idx = srcu_read_lock(&kvm->srcu);
-       offset = offsetof(struct pvclock_vcpu_stolen_time, stolen_time);
-       kvm_put_guest(kvm, base + offset, steal_le, u64);
+       if (!kvm_get_guest(kvm, base + offset, steal)) {
+               steal = le64_to_cpu(steal);
+               vcpu->arch.steal.last_steal = READ_ONCE(current->sched_info.run_delay);
+               steal += vcpu->arch.steal.last_steal - last_steal;
+               kvm_put_guest(kvm, base + offset, cpu_to_le64(steal));
+       }
        srcu_read_unlock(&kvm->srcu, idx);
 }
 
@@ -43,7 +40,8 @@ long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
        switch (feature) {
        case ARM_SMCCC_HV_PV_TIME_FEATURES:
        case ARM_SMCCC_HV_PV_TIME_ST:
-               val = SMCCC_RET_SUCCESS;
+               if (vcpu->arch.steal.base != GPA_INVALID)
+                       val = SMCCC_RET_SUCCESS;
                break;
        }
 
@@ -64,7 +62,6 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
         * Start counting stolen time from the time the guest requests
         * the feature enabled.
         */
-       vcpu->arch.steal.steal = 0;
        vcpu->arch.steal.last_steal = current->sched_info.run_delay;
 
        idx = srcu_read_lock(&kvm->srcu);
@@ -74,7 +71,7 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
        return base;
 }
 
-static bool kvm_arm_pvtime_supported(void)
+bool kvm_arm_pvtime_supported(void)
 {
        return !!sched_info_on();
 }
index 4691053..ff04443 100644 (file)
@@ -23,7 +23,7 @@ TRACE_EVENT(kvm_entry,
                __entry->vcpu_pc                = vcpu_pc;
        ),
 
-       TP_printk("PC: 0x%08lx", __entry->vcpu_pc)
+       TP_printk("PC: 0x%016lx", __entry->vcpu_pc)
 );
 
 TRACE_EVENT(kvm_exit,
@@ -42,7 +42,7 @@ TRACE_EVENT(kvm_exit,
                __entry->vcpu_pc                = vcpu_pc;
        ),
 
-       TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%08lx",
+       TP_printk("%s: HSR_EC: 0x%04x (%s), PC: 0x%016lx",
                  __print_symbolic(__entry->ret, kvm_arm_exception_type),
                  __entry->esr_ec,
                  __print_symbolic(__entry->esr_ec, kvm_arm_exception_class),
@@ -69,7 +69,7 @@ TRACE_EVENT(kvm_guest_fault,
                __entry->ipa                    = ipa;
        ),
 
-       TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#08lx",
+       TP_printk("ipa %#llx, hsr %#08lx, hxfar %#08lx, pc %#016lx",
                  __entry->ipa, __entry->hsr,
                  __entry->hxfar, __entry->vcpu_pc)
 );
@@ -131,7 +131,7 @@ TRACE_EVENT(kvm_mmio_emulate,
                __entry->cpsr                   = cpsr;
        ),
 
-       TP_printk("Emulate MMIO at: 0x%08lx (instr: %08lx, cpsr: %08lx)",
+       TP_printk("Emulate MMIO at: 0x%016lx (instr: %08lx, cpsr: %08lx)",
                  __entry->vcpu_pc, __entry->instr, __entry->cpsr)
 );
 
@@ -149,7 +149,7 @@ TRACE_EVENT(kvm_unmap_hva_range,
                __entry->end            = end;
        ),
 
-       TP_printk("mmu notifier unmap range: %#08lx -- %#08lx",
+       TP_printk("mmu notifier unmap range: %#016lx -- %#016lx",
                  __entry->start, __entry->end)
 );
 
@@ -165,7 +165,7 @@ TRACE_EVENT(kvm_set_spte_hva,
                __entry->hva            = hva;
        ),
 
-       TP_printk("mmu notifier set pte hva: %#08lx", __entry->hva)
+       TP_printk("mmu notifier set pte hva: %#016lx", __entry->hva)
 );
 
 TRACE_EVENT(kvm_age_hva,
@@ -182,7 +182,7 @@ TRACE_EVENT(kvm_age_hva,
                __entry->end            = end;
        ),
 
-       TP_printk("mmu notifier age hva: %#08lx -- %#08lx",
+       TP_printk("mmu notifier age hva: %#016lx -- %#016lx",
                  __entry->start, __entry->end)
 );
 
@@ -198,7 +198,7 @@ TRACE_EVENT(kvm_test_age_hva,
                __entry->hva            = hva;
        ),
 
-       TP_printk("mmu notifier test age hva: %#08lx", __entry->hva)
+       TP_printk("mmu notifier test age hva: %#016lx", __entry->hva)
 );
 
 TRACE_EVENT(kvm_set_way_flush,
index 2c56d1e..8d78acc 100644 (file)
@@ -22,7 +22,7 @@ TRACE_EVENT(kvm_wfx_arm64,
                __entry->is_wfe  = is_wfe;
        ),
 
-       TP_printk("guest executed wf%c at: 0x%08lx",
+       TP_printk("guest executed wf%c at: 0x%016lx",
                  __entry->is_wfe ? 'e' : 'i', __entry->vcpu_pc)
 );
 
@@ -42,7 +42,7 @@ TRACE_EVENT(kvm_hvc_arm64,
                __entry->imm = imm;
        ),
 
-       TP_printk("HVC at 0x%08lx (r0: 0x%08lx, imm: 0x%lx)",
+       TP_printk("HVC at 0x%016lx (r0: 0x%016lx, imm: 0x%lx)",
                  __entry->vcpu_pc, __entry->r0, __entry->imm)
 );
 
@@ -135,7 +135,7 @@ TRACE_EVENT(trap_reg,
                __entry->write_value = write_value;
        ),
 
-       TP_printk("%s %s reg %d (0x%08llx)", __entry->fn,  __entry->is_write?"write to":"read from", __entry->reg, __entry->write_value)
+       TP_printk("%s %s reg %d (0x%016llx)", __entry->fn,  __entry->is_write?"write to":"read from", __entry->reg, __entry->write_value)
 );
 
 TRACE_EVENT(kvm_handle_sys_reg,
index a206655..9b11c09 100644 (file)
@@ -45,7 +45,7 @@ static u32 get_cpu_asid_bits(void)
        default:
                pr_warn("CPU%d: Unknown ASID size (%d); assuming 8-bit\n",
                                        smp_processor_id(),  fld);
-               /* Fallthrough */
+               fallthrough;
        case 0:
                asid = 8;
                break;
index e456652..d05c78e 100644 (file)
@@ -220,7 +220,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
                        regs->a4 = -EINTR;
                        break;
                }
-       /* fallthrough */
+               fallthrough;
        case -ERESTARTNOINTR:
 do_restart:
                regs->a4 = regs->orig_a4;
@@ -252,7 +252,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs,
                                break;
                        }
 
-                       /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->a4 = regs->orig_a4;
                        regs->pc -= 4;
index 9452d65..970895d 100644 (file)
@@ -194,7 +194,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                regs->a0 = -EINTR;
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->a0 = regs->orig_a0;
                        regs->pc -= TRAP0_SIZE;
index 38d3354..69e6894 100644 (file)
@@ -227,7 +227,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka)
                        regs->er0 = -EINTR;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case -ERESTARTNOINTR:
 do_restart:
                regs->er0 = regs->orig_er0;
index cf99fb7..cb3bf19 100644 (file)
@@ -120,7 +120,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
                }
                case R_HEXAGON_HI16:
                        value = (value>>16) & 0xffff;
-                       /* fallthrough */
+                       fallthrough;
                case R_HEXAGON_LO16:
                        *location &= ~0x00c03fff;
                        *location |= value & 0x3fff;
index d48864c..94cc7ff 100644 (file)
@@ -155,7 +155,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                regs->r00 = -EINTR;
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->r06 = regs->syscall_nr;
                        pt_set_elr(regs, pt_elr(regs) - 4);
index 1085089..779b697 100644 (file)
@@ -366,6 +366,15 @@ pgd_index (unsigned long address)
 }
 #define pgd_index pgd_index
 
+/*
+ * In the kernel's mapped region we know everything is in region number 5, so
+ * as an optimisation its PGD already points to the area for that region.
+ * However, this also means that we cannot use pgd_index() and we must
+ * never add the region here.
+ */
+#define pgd_offset_k(addr) \
+       (init_mm.pgd + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1)))
+
 /* Look up a pgd entry in the gate area.  On IA-64, the gate-area
    resides in the kernel-mapped segment, hence we use pgd_offset_k()
    here.  */
index bec762a..fec70d6 100644 (file)
@@ -163,7 +163,7 @@ kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data)
                case DIE_INIT_MONARCH_LEAVE:
                        if (!kdump_freeze_monarch)
                                break;
-                       /* fall through */
+                       fallthrough;
                case DIE_INIT_SLAVE_LEAVE:
                case DIE_INIT_MONARCH_ENTER:
                case DIE_MCA_RENDZVOUS_LEAVE:
index b49fe6f..f8150ee 100644 (file)
@@ -3,7 +3,7 @@
  * Architecture-specific kernel symbols
  */
 
-#ifdef CONFIG_VIRTUAL_MEM_MAP
+#if defined(CONFIG_VIRTUAL_MEM_MAP) || defined(CONFIG_DISCONTIGMEM)
 #include <linux/compiler.h>
 #include <linux/export.h>
 #include <linux/memblock.h>
index 1a42ba8..00a496c 100644 (file)
@@ -654,7 +654,7 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
                                }
                        } else if (!is_internal(mod, val))
                                val = get_plt(mod, location, val, &ok);
-                       /* FALL THROUGH */
+                       fallthrough;
                      default:
                        val -= bundle(location);
                        break;
index 971f166..0dc3611 100644 (file)
@@ -3472,7 +3472,7 @@ pfm_restart(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
                        break;
                case PFM_CTX_LOADED: 
                        if (CTX_HAS_SMPL(ctx) && fmt->fmt_restart_active) break;
-                       /* fall through */
+                       fallthrough;
                case PFM_CTX_UNLOADED:
                case PFM_CTX_ZOMBIE:
                        DPRINT(("invalid state=%d\n", state));
index d07ed65..e67b22f 100644 (file)
@@ -374,7 +374,7 @@ ia64_do_signal (struct sigscratch *scr, long in_syscall)
                                        /* note: scr->pt.r10 is already -1 */
                                        break;
                                }
-                               /*FALLTHRU*/
+                               fallthrough;
                        case ERESTARTNOINTR:
                                ia64_decrement_ip(&scr->pt);
                                restart = 0; /* don't restart twice if handle_signal() fails... */
index 2d4e65b..6c1a895 100644 (file)
@@ -1431,7 +1431,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
                if (u.insn.x)
                        /* oops, really a semaphore op (cmpxchg, etc) */
                        goto failure;
-               /*FALLTHRU*/
+               fallthrough;
              case LDS_IMM_OP:
              case LDSA_IMM_OP:
              case LDFS_OP:
@@ -1459,7 +1459,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
                if (u.insn.x)
                        /* oops, really a semaphore op (cmpxchg, etc) */
                        goto failure;
-               /*FALLTHRU*/
+               fallthrough;
              case LD_IMM_OP:
              case LDA_IMM_OP:
              case LDBIAS_IMM_OP:
@@ -1475,7 +1475,7 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
                if (u.insn.x)
                        /* oops, really a semaphore op (cmpxchg, etc) */
                        goto failure;
-               /*FALLTHRU*/
+               fallthrough;
              case ST_IMM_OP:
              case STREL_IMM_OP:
                ret = emulate_store_int(ifa, u.insn, regs);
index 7601fe0..6bd64c3 100644 (file)
@@ -324,7 +324,7 @@ unw_access_gr (struct unw_frame_info *info, int regnum, unsigned long *val, char
                                                        return 0;
                                                }
                                        }
-                                       /* fall through */
+                                       fallthrough;
                                      case UNW_NAT_NONE:
                                        dummy_nat = 0;
                                        nat_addr = &dummy_nat;
index 3709189..5e0e682 100644 (file)
@@ -207,7 +207,7 @@ repeat:
                                        self_test_last_rcv = jiffies;
                                        break;
                                }
-                               /* FALL THROUGH */
+                               fallthrough;
 
                        default:
                                break_flag = scancode & BREAK_MASK;
index fc034fd..a98fca9 100644 (file)
@@ -1067,7 +1067,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
                        regs->d0 = -EINTR;
                        break;
                }
-       /* fallthrough */
+               fallthrough;
        case -ERESTARTNOINTR:
        do_restart:
                regs->d0 = regs->orig_d0;
index 5c9f3a2..a621fcc 100644 (file)
@@ -1018,7 +1018,7 @@ int __init mac_platform_init(void)
                 */
                platform_device_register_simple("mac_scsi", 1,
                        mac_scsi_duo_rsrc, ARRAY_SIZE(mac_scsi_duo_rsrc));
-               /* fall through */
+               fallthrough;
        case MAC_SCSI_OLD:
                /* Addresses from Developer Notes for Duo System,
                 * PowerBook 180 & 160, 140 & 170, Macintosh IIsi
index 1f0fad2..ac77d73 100644 (file)
@@ -370,7 +370,7 @@ void via_nubus_irq_startup(int irq)
                        /* Allow NuBus slots 9 through F. */
                        via2[vDirA] &= 0x80 | ~(1 << irq_idx);
                }
-               /* fall through */
+               fallthrough;
        case MAC_VIA_IICI:
                via_irq_enable(irq);
                break;
index 795f483..ef46e77 100644 (file)
@@ -118,7 +118,7 @@ good_area:
        pr_debug("do_page_fault: good_area\n");
        switch (error_code & 3) {
                default:        /* 3: write, present */
-                       /* fall through */
+                       fallthrough;
                case 2:         /* write, not present */
                        if (!(vma->vm_flags & VM_WRITE))
                                goto acc_err;
index 65bf5fd..4a96b59 100644 (file)
@@ -249,7 +249,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
                        regs->r3 = -EINTR;
                        break;
        }
-       /* fallthrough */
+               fallthrough;
        case -ERESTARTNOINTR:
 do_restart:
                /* offset of 4 bytes to re-execute trap (brki) instruction */
index 0880a00..3344d4a 100644 (file)
@@ -46,6 +46,9 @@ unsigned long memory_size;
 EXPORT_SYMBOL(memory_size);
 unsigned long lowmem_size;
 
+EXPORT_SYMBOL(min_low_pfn);
+EXPORT_SYMBOL(max_low_pfn);
+
 #ifdef CONFIG_HIGHMEM
 pte_t *kmap_pte;
 EXPORT_SYMBOL(kmap_pte);
index 47a8ffc..f5b8300 100644 (file)
@@ -137,6 +137,11 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
        return !(flags & 1);
 }
 
+static inline int arch_irqs_disabled(void)
+{
+       return arch_irqs_disabled_flags(arch_local_save_flags());
+}
+
 #endif /* #ifndef __ASSEMBLY__ */
 
 /*
index d35eaed..825d337 100644 (file)
@@ -969,7 +969,7 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu,
 
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 int kvm_unmap_hva_range(struct kvm *kvm,
-                       unsigned long start, unsigned long end);
+                       unsigned long start, unsigned long end, unsigned flags);
 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
index b6e9c99..eb18122 100644 (file)
@@ -26,7 +26,6 @@
 #define cpu_has_counter                1
 #define cpu_has_dc_aliases     (PAGE_SIZE < 0x4000)
 #define cpu_has_divec          0
-#define cpu_has_ejtag          0
 #define cpu_has_inclusive_pcaches      1
 #define cpu_has_llsc           1
 #define cpu_has_mcheck         0
@@ -42,7 +41,6 @@
 #define cpu_has_veic           0
 #define cpu_has_vint           0
 #define cpu_has_vtag_icache    0
-#define cpu_has_watch          1
 #define cpu_has_wsbh           1
 #define cpu_has_ic_fills_f_dc  1
 #define cpu_hwrena_impl_bits   0xc0000000
index f5e362f..bf24809 100644 (file)
@@ -2,8 +2,6 @@
 #ifndef __ASM_MACH_LOONGSON64_IRQ_H_
 #define __ASM_MACH_LOONGSON64_IRQ_H_
 
-#include <boot_param.h>
-
 /* cpu core interrupt numbers */
 #define NR_IRQS_LEGACY         16
 #define NR_MIPS_CPU_IRQS       8
index 3a25dbd..5eaca4f 100644 (file)
@@ -9,7 +9,6 @@
 #ifndef _ASM_MACH_LOONGSON64_MMZONE_H
 #define _ASM_MACH_LOONGSON64_MMZONE_H
 
-#include <boot_param.h>
 #define NODE_ADDRSPACE_SHIFT 44
 #define NODE0_ADDRSPACE_OFFSET 0x000000000000UL
 #define NODE1_ADDRSPACE_OFFSET 0x100000000000UL
index 7dd4a80..6f4ac85 100644 (file)
        BUILD_BUG_ON(!__builtin_constant_p(times));             \
                                                                \
        switch (times) {                                        \
-       case 32: fn(__VA_ARGS__); /* fall through */            \
-       case 31: fn(__VA_ARGS__); /* fall through */            \
-       case 30: fn(__VA_ARGS__); /* fall through */            \
-       case 29: fn(__VA_ARGS__); /* fall through */            \
-       case 28: fn(__VA_ARGS__); /* fall through */            \
-       case 27: fn(__VA_ARGS__); /* fall through */            \
-       case 26: fn(__VA_ARGS__); /* fall through */            \
-       case 25: fn(__VA_ARGS__); /* fall through */            \
-       case 24: fn(__VA_ARGS__); /* fall through */            \
-       case 23: fn(__VA_ARGS__); /* fall through */            \
-       case 22: fn(__VA_ARGS__); /* fall through */            \
-       case 21: fn(__VA_ARGS__); /* fall through */            \
-       case 20: fn(__VA_ARGS__); /* fall through */            \
-       case 19: fn(__VA_ARGS__); /* fall through */            \
-       case 18: fn(__VA_ARGS__); /* fall through */            \
-       case 17: fn(__VA_ARGS__); /* fall through */            \
-       case 16: fn(__VA_ARGS__); /* fall through */            \
-       case 15: fn(__VA_ARGS__); /* fall through */            \
-       case 14: fn(__VA_ARGS__); /* fall through */            \
-       case 13: fn(__VA_ARGS__); /* fall through */            \
-       case 12: fn(__VA_ARGS__); /* fall through */            \
-       case 11: fn(__VA_ARGS__); /* fall through */            \
-       case 10: fn(__VA_ARGS__); /* fall through */            \
-       case 9: fn(__VA_ARGS__); /* fall through */             \
-       case 8: fn(__VA_ARGS__); /* fall through */             \
-       case 7: fn(__VA_ARGS__); /* fall through */             \
-       case 6: fn(__VA_ARGS__); /* fall through */             \
-       case 5: fn(__VA_ARGS__); /* fall through */             \
-       case 4: fn(__VA_ARGS__); /* fall through */             \
-       case 3: fn(__VA_ARGS__); /* fall through */             \
-       case 2: fn(__VA_ARGS__); /* fall through */             \
-       case 1: fn(__VA_ARGS__); /* fall through */             \
+       case 32: fn(__VA_ARGS__); fallthrough;                  \
+       case 31: fn(__VA_ARGS__); fallthrough;                  \
+       case 30: fn(__VA_ARGS__); fallthrough;                  \
+       case 29: fn(__VA_ARGS__); fallthrough;                  \
+       case 28: fn(__VA_ARGS__); fallthrough;                  \
+       case 27: fn(__VA_ARGS__); fallthrough;                  \
+       case 26: fn(__VA_ARGS__); fallthrough;                  \
+       case 25: fn(__VA_ARGS__); fallthrough;                  \
+       case 24: fn(__VA_ARGS__); fallthrough;                  \
+       case 23: fn(__VA_ARGS__); fallthrough;                  \
+       case 22: fn(__VA_ARGS__); fallthrough;                  \
+       case 21: fn(__VA_ARGS__); fallthrough;                  \
+       case 20: fn(__VA_ARGS__); fallthrough;                  \
+       case 19: fn(__VA_ARGS__); fallthrough;                  \
+       case 18: fn(__VA_ARGS__); fallthrough;                  \
+       case 17: fn(__VA_ARGS__); fallthrough;                  \
+       case 16: fn(__VA_ARGS__); fallthrough;                  \
+       case 15: fn(__VA_ARGS__); fallthrough;                  \
+       case 14: fn(__VA_ARGS__); fallthrough;                  \
+       case 13: fn(__VA_ARGS__); fallthrough;                  \
+       case 12: fn(__VA_ARGS__); fallthrough;                  \
+       case 11: fn(__VA_ARGS__); fallthrough;                  \
+       case 10: fn(__VA_ARGS__); fallthrough;                  \
+       case 9: fn(__VA_ARGS__); fallthrough;                   \
+       case 8: fn(__VA_ARGS__); fallthrough;                   \
+       case 7: fn(__VA_ARGS__); fallthrough;                   \
+       case 6: fn(__VA_ARGS__); fallthrough;                   \
+       case 5: fn(__VA_ARGS__); fallthrough;                   \
+       case 4: fn(__VA_ARGS__); fallthrough;                   \
+       case 3: fn(__VA_ARGS__); fallthrough;                   \
+       case 2: fn(__VA_ARGS__); fallthrough;                   \
+       case 1: fn(__VA_ARGS__); fallthrough;                   \
        case 0: break;                                          \
                                                                \
        default:                                                \
index efce5de..011eb6b 100644 (file)
@@ -1898,8 +1898,8 @@ static const struct mips_perf_event *mipsxx_pmu_map_raw_event(u64 config)
                                (base_id >= 64 && base_id < 90) ||
                                (base_id >= 128 && base_id < 164) ||
                                (base_id >= 192 && base_id < 200) ||
-                               (base_id >= 256 && base_id < 274) ||
-                               (base_id >= 320 && base_id < 358) ||
+                               (base_id >= 256 && base_id < 275) ||
+                               (base_id >= 320 && base_id < 361) ||
                                (base_id >= 384 && base_id < 574))
                                break;
 
index 2f51350..1dbfb5a 100644 (file)
@@ -239,6 +239,8 @@ static int bmips_boot_secondary(int cpu, struct task_struct *idle)
  */
 static void bmips_init_secondary(void)
 {
+       bmips_cpu_setup();
+
        switch (current_cpu_type()) {
        case CPU_BMIPS4350:
        case CPU_BMIPS4380:
index 38aa07c..cf78859 100644 (file)
@@ -1287,6 +1287,18 @@ static int enable_restore_fp_context(int msa)
                err = own_fpu_inatomic(1);
                if (msa && !err) {
                        enable_msa();
+                       /*
+                        * with MSA enabled, userspace can see MSACSR
+                        * and MSA regs, but the values in them are from
+                        * other task before current task, restore them
+                        * from saved fp/msa context
+                        */
+                       write_msa_csr(current->thread.fpu.msacsr);
+                       /*
+                        * own_fpu_inatomic(1) just restore low 64bit,
+                        * fix the high 64bit
+                        */
+                       init_msa_upper();
                        set_thread_flag(TIF_USEDMSA);
                        set_thread_flag(TIF_MSA_CTX_LIVE);
                }
index 7de85d2..0c50ac4 100644 (file)
@@ -137,6 +137,8 @@ extern void kvm_init_loongson_ipi(struct kvm *kvm);
 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 {
        switch (type) {
+       case KVM_VM_MIPS_AUTO:
+               break;
 #ifdef CONFIG_KVM_MIPS_VZ
        case KVM_VM_MIPS_VZ:
 #else
index 87fa8d8..28c366d 100644 (file)
@@ -486,7 +486,8 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gfn_t gfn, gfn_t gfn_end,
        return 1;
 }
 
-int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
+                       unsigned flags)
 {
        handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
 
index fc5a6d2..0ef7170 100644 (file)
@@ -1712,7 +1712,11 @@ static void setup_scache(void)
                                printk("MIPS secondary cache %ldkB, %s, linesize %d bytes.\n",
                                       scache_size >> 10,
                                       way_string[c->scache.ways], c->scache.linesz);
+
+                               if (current_cpu_type() == CPU_BMIPS5000)
+                                       c->options |= MIPS_CPU_INCLUSIVE_CACHES;
                        }
+
 #else
                        if (!(c->scache.flags & MIPS_CACHE_NOT_PRESENT))
                                panic("Dunno how to handle MIPS32 / MIPS64 second level cache");
index 1493c49..55d7b7f 100644 (file)
@@ -245,7 +245,6 @@ static int mipsxx_perfcount_handler(void)
 
        switch (counters) {
 #define HANDLE_COUNTER(n)                                              \
-       fallthrough;                                                    \
        case n + 1:                                                     \
                control = r_c0_perfctrl ## n();                         \
                counter = r_c0_perfcntr ## n();                         \
@@ -256,8 +255,11 @@ static int mipsxx_perfcount_handler(void)
                        handled = IRQ_HANDLED;                          \
                }
        HANDLE_COUNTER(3)
+       fallthrough;
        HANDLE_COUNTER(2)
+       fallthrough;
        HANDLE_COUNTER(1)
+       fallthrough;
        HANDLE_COUNTER(0)
        }
 
index 0ecffb6..b09dc84 100644 (file)
@@ -222,8 +222,8 @@ void __init sni_a20r_irq_init(void)
                irq_set_chip_and_handler(i, &a20r_irq_type, handle_level_irq);
        sni_hwint = a20r_hwint;
        change_c0_status(ST0_IM, IE_IRQ0);
-       if (request_irq(SNI_A20R_IRQ_BASE + 3, sni_isa_irq_handler, 0, "ISA",
-                       NULL))
+       if (request_irq(SNI_A20R_IRQ_BASE + 3, sni_isa_irq_handler,
+                       IRQF_SHARED, "ISA", sni_isa_irq_handler))
                pr_err("Failed to register ISA interrupt\n");
 }
 
index fb45ec4..51ef800 100644 (file)
@@ -34,3 +34,8 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
 {
        return !flags;
 }
+
+static inline int arch_irqs_disabled(void)
+{
+       return arch_irqs_disabled_flags(arch_local_save_flags());
+}
index 62bdafb..9edd7ed 100644 (file)
@@ -45,7 +45,7 @@ void save_fpu(struct task_struct *tsk)
                              : /* no output */
                              : "r" (&tsk->thread.fpu)
                              : "memory");
-               /* fall through */
+               fallthrough;
        case SP32_DP16_reg:
                asm volatile ("fsdi $fd15, [%0+0x78]\n\t"
                              "fsdi $fd14, [%0+0x70]\n\t"
@@ -58,7 +58,7 @@ void save_fpu(struct task_struct *tsk)
                              : /* no output */
                              : "r" (&tsk->thread.fpu)
                              : "memory");
-               /* fall through */
+               fallthrough;
        case SP16_DP8_reg:
                asm volatile ("fsdi $fd7,  [%0+0x38]\n\t"
                              "fsdi $fd6,  [%0+0x30]\n\t"
@@ -67,7 +67,7 @@ void save_fpu(struct task_struct *tsk)
                              : /* no output */
                              : "r" (&tsk->thread.fpu)
                              : "memory");
-               /* fall through */
+               fallthrough;
        case SP8_DP4_reg:
                asm volatile ("fsdi $fd3,  [%1+0x18]\n\t"
                              "fsdi $fd2,  [%1+0x10]\n\t"
@@ -108,7 +108,7 @@ void load_fpu(const struct fpu_struct *fpregs)
                              "fldi $fd16, [%0+0x80]\n\t"
                              : /* no output */
                              : "r" (fpregs));
-               /* fall through */
+               fallthrough;
        case SP32_DP16_reg:
                asm volatile ("fldi $fd15, [%0+0x78]\n\t"
                              "fldi $fd14, [%0+0x70]\n\t"
@@ -120,7 +120,7 @@ void load_fpu(const struct fpu_struct *fpregs)
                              "fldi $fd8,  [%0+0x40]\n\t"
                              : /* no output */
                              : "r" (fpregs));
-               /* fall through */
+               fallthrough;
        case SP16_DP8_reg:
                asm volatile ("fldi $fd7,  [%0+0x38]\n\t"
                              "fldi $fd6,  [%0+0x30]\n\t"
@@ -128,7 +128,7 @@ void load_fpu(const struct fpu_struct *fpregs)
                              "fldi $fd4,  [%0+0x20]\n\t"
                              : /* no output */
                              : "r" (fpregs));
-               /* fall through */
+               fallthrough;
        case SP8_DP4_reg:
                asm volatile ("fldi $fd3,  [%1+0x18]\n\t"
                              "fldi $fd2,  [%1+0x10]\n\t"
index 330b19f..36e25a4 100644 (file)
@@ -316,7 +316,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                regs->uregs[0] = -EINTR;
                                break;
                        }
-                       /* Else, fall through */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->uregs[0] = regs->orig_r0;
                        regs->ipc -= 4;
@@ -361,7 +361,7 @@ static void do_signal(struct pt_regs *regs)
                switch (regs->uregs[0]) {
                case -ERESTART_RESTARTBLOCK:
                        regs->uregs[15] = __NR_restart_syscall;
-                       /* Fall through */
+                       fallthrough;
                case -ERESTARTNOHAND:
                case -ERESTARTSYS:
                case -ERESTARTNOINTR:
index f039021..120f500 100644 (file)
@@ -165,19 +165,19 @@ struct __large_struct {
 
 #define __get_user_nocheck(x, ptr, size)                       \
 ({                                                             \
-       long __gu_err, __gu_val;                                \
-       __get_user_size(__gu_val, (ptr), (size), __gu_err);     \
-       (x) = (__force __typeof__(*(ptr)))__gu_val;             \
+       long __gu_err;                                          \
+       __get_user_size((x), (ptr), (size), __gu_err);          \
        __gu_err;                                               \
 })
 
 #define __get_user_check(x, ptr, size)                                 \
 ({                                                                     \
-       long __gu_err = -EFAULT, __gu_val = 0;                          \
+       long __gu_err = -EFAULT;                                        \
        const __typeof__(*(ptr)) __user *__gu_addr = (ptr);             \
-       if (access_ok(__gu_addr, size))                 \
-               __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
-       (x) = (__force __typeof__(*(ptr)))__gu_val;                     \
+       if (access_ok(__gu_addr, size))                                 \
+               __get_user_size((x), __gu_addr, (size), __gu_err);      \
+       else                                                            \
+               (x) = (__typeof__(*(ptr))) 0;                           \
        __gu_err;                                                       \
 })
 
@@ -191,11 +191,13 @@ do {                                                                      \
        case 2: __get_user_asm(x, ptr, retval, "l.lhz"); break;         \
        case 4: __get_user_asm(x, ptr, retval, "l.lwz"); break;         \
        case 8: __get_user_asm2(x, ptr, retval); break;                 \
-       default: (x) = __get_user_bad();                                \
+       default: (x) = (__typeof__(*(ptr)))__get_user_bad();            \
        }                                                               \
 } while (0)
 
 #define __get_user_asm(x, addr, err, op)               \
+{                                                      \
+       unsigned long __gu_tmp;                         \
        __asm__ __volatile__(                           \
                "1:     "op" %1,0(%2)\n"                \
                "2:\n"                                  \
@@ -209,10 +211,14 @@ do {                                                                      \
                "       .align 2\n"                     \
                "       .long 1b,3b\n"                  \
                ".previous"                             \
-               : "=r"(err), "=r"(x)                    \
-               : "r"(addr), "i"(-EFAULT), "0"(err))
+               : "=r"(err), "=r"(__gu_tmp)             \
+               : "r"(addr), "i"(-EFAULT), "0"(err));   \
+       (x) = (__typeof__(*(addr)))__gu_tmp;            \
+}
 
 #define __get_user_asm2(x, addr, err)                  \
+{                                                      \
+       unsigned long long __gu_tmp;                    \
        __asm__ __volatile__(                           \
                "1:     l.lwz %1,0(%2)\n"               \
                "2:     l.lwz %H1,4(%2)\n"              \
@@ -229,8 +235,11 @@ do {                                                                       \
                "       .long 1b,4b\n"                  \
                "       .long 2b,4b\n"                  \
                ".previous"                             \
-               : "=r"(err), "=&r"(x)                   \
-               : "r"(addr), "i"(-EFAULT), "0"(err))
+               : "=r"(err), "=&r"(__gu_tmp)            \
+               : "r"(addr), "i"(-EFAULT), "0"(err));   \
+       (x) = (__typeof__(*(addr)))(                    \
+               (__typeof__((x)-(x)))__gu_tmp);         \
+}
 
 /* more complex routines */
 
index b18e775..13c87f1 100644 (file)
@@ -80,6 +80,16 @@ static void __init setup_memory(void)
         */
        memblock_reserve(__pa(_stext), _end - _stext);
 
+#ifdef CONFIG_BLK_DEV_INITRD
+       /* Then reserve the initrd, if any */
+       if (initrd_start && (initrd_end > initrd_start)) {
+               unsigned long aligned_start = ALIGN_DOWN(initrd_start, PAGE_SIZE);
+               unsigned long aligned_end = ALIGN(initrd_end, PAGE_SIZE);
+
+               memblock_reserve(__pa(aligned_start), aligned_end - aligned_start);
+       }
+#endif /* CONFIG_BLK_DEV_INITRD */
+
        early_init_fdt_reserve_self();
        early_init_fdt_scan_reserved_mem();
 
index 97804f2..c779364 100644 (file)
@@ -244,7 +244,7 @@ int do_signal(struct pt_regs *regs, int syscall)
                switch (retval) {
                case -ERESTART_RESTARTBLOCK:
                        restart = -2;
-                       /* Fall through */
+                       fallthrough;
                case -ERESTARTNOHAND:
                case -ERESTARTSYS:
                case -ERESTARTNOINTR:
index 08f56af..534a52e 100644 (file)
@@ -16,7 +16,7 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
-static void cache_loop(struct page *page, const unsigned int reg)
+static __always_inline void cache_loop(struct page *page, const unsigned int reg)
 {
        unsigned long paddr = page_to_pfn(page) << PAGE_SHIFT;
        unsigned long line = paddr & ~(L1_CACHE_BYTES - 1);
index 5df5d4c..3c037fc 100644 (file)
@@ -502,7 +502,7 @@ syscall_restart(struct pt_regs *regs, struct k_sigaction *ka)
                        regs->gr[28] = -EINTR;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case -ERESTARTNOINTR:
                check_syscallno_in_delay_branch(regs);
                break;
index 43875c2..a52c7ab 100644 (file)
@@ -437,7 +437,6 @@ void parisc_terminate(char *msg, struct pt_regs *regs, int code, unsigned long o
                break;
 
        default:
-               /* Fall through */
                break;
 
        }
@@ -644,12 +643,12 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
 
        case 15:
                /* Data TLB miss fault/Data page fault */
-               /* Fall through */
+               fallthrough;
        case 16:
                /* Non-access instruction TLB miss fault */
                /* The instruction TLB entry needed for the target address of the FIC
                   is absent, and hardware can't find it, so we get to cleanup */
-               /* Fall through */
+               fallthrough;
        case 17:
                /* Non-access data TLB miss fault/Non-access data page fault */
                /* FIXME: 
@@ -673,7 +672,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
                        handle_unaligned(regs);
                        return;
                }
-               /* Fall Through */
+               fallthrough;
        case 26: 
                /* PCXL: Data memory access rights trap */
                fault_address = regs->ior;
@@ -683,7 +682,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
        case 19:
                /* Data memory break trap */
                regs->gr[0] |= PSW_X; /* So we can single-step over the trap */
-               /* fall thru */
+               fallthrough;
        case 21:
                /* Page reference trap */
                handle_gdb_break(regs, TRAP_HWBKPT);
@@ -730,7 +729,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
                        }
                        mmap_read_unlock(current->mm);
                }
-               /* Fall Through */
+               fallthrough;
        case 27: 
                /* Data memory protection ID trap */
                if (code == 27 && !user_mode(regs) &&
index 4bfe2da..716960f 100644 (file)
@@ -67,7 +67,7 @@ parisc_acctyp(unsigned long code, unsigned int inst)
        case 0x30000000: /* coproc2 */
                if (bit22set(inst))
                        return VM_WRITE;
-               /* fall through */
+               fallthrough;
 
        case 0x0: /* indexed/memory management */
                if (bit22set(inst)) {
@@ -370,7 +370,7 @@ bad_area:
                        }
 
                        /* probably address is outside of mapped file */
-                       /* fall through */
+                       fallthrough;
                case 17:        /* NA data TLB miss / page fault */
                case 18:        /* Unaligned access - PCXS only */
                        signo = SIGBUS;
index 1f48bbf..65bed1f 100644 (file)
@@ -860,6 +860,18 @@ config PPC_SUBPAGE_PROT
 
          If unsure, say N here.
 
+config PPC_PROT_SAO_LPAR
+       bool "Support PROT_SAO mappings in LPARs"
+       depends on PPC_BOOK3S_64
+       help
+         This option adds support for PROT_SAO mappings from userspace
+         inside LPARs on supported CPUs.
+
+         This may cause issues when performing guest migration from
+         a CPU that supports SAO to one that does not.
+
+         If unsure, say N here.
+
 config PPC_COPRO_BASE
        bool
 
index 6de56c3..495fc0c 100644 (file)
 #define _PAGE_RW               (_PAGE_READ | _PAGE_WRITE)
 #define _PAGE_RWX              (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
 #define _PAGE_PRIVILEGED       0x00008 /* kernel access only */
-
-#define _PAGE_CACHE_CTL                0x00030 /* Bits for the folowing cache modes */
-                       /*      No bits set is normal cacheable memory */
-                       /*      0x00010 unused, is SAO bit on radix POWER9 */
+#define _PAGE_SAO              0x00010 /* Strong access order */
 #define _PAGE_NON_IDEMPOTENT   0x00020 /* non idempotent memory */
 #define _PAGE_TOLERANT         0x00030 /* tolerant memory, cache inhibited */
-
 #define _PAGE_DIRTY            0x00080 /* C: page changed */
 #define _PAGE_ACCESSED         0x00100 /* R: page referenced */
 /*
@@ -828,6 +824,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
        return hash__set_pte_at(mm, addr, ptep, pte, percpu);
 }
 
+#define _PAGE_CACHE_CTL        (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
+
 #define pgprot_noncached pgprot_noncached
 static inline pgprot_t pgprot_noncached(pgprot_t prot)
 {
index fdddb82..32a15dc 100644 (file)
@@ -9,6 +9,11 @@
 
 #ifndef __ASSEMBLY__
 
+/*
+ * Added to include __machine_check_early_realmode_* functions
+ */
+#include <asm/mce.h>
+
 /* This structure can grow, it's real size is used by head.S code
  * via the mkdefs mechanism.
  */
@@ -191,7 +196,7 @@ static inline void cpu_feature_keys_init(void) { }
 #define CPU_FTR_SPURR                  LONG_ASM_CONST(0x0000000001000000)
 #define CPU_FTR_DSCR                   LONG_ASM_CONST(0x0000000002000000)
 #define CPU_FTR_VSX                    LONG_ASM_CONST(0x0000000004000000)
-// Free                                        LONG_ASM_CONST(0x0000000008000000)
+#define CPU_FTR_SAO                    LONG_ASM_CONST(0x0000000008000000)
 #define CPU_FTR_CP_USE_DCBTZ           LONG_ASM_CONST(0x0000000010000000)
 #define CPU_FTR_UNALIGNED_LD_STD       LONG_ASM_CONST(0x0000000020000000)
 #define CPU_FTR_ASYM_SMT               LONG_ASM_CONST(0x0000000040000000)
@@ -436,7 +441,7 @@ static inline void cpu_feature_keys_init(void) { }
            CPU_FTR_MMCRA | CPU_FTR_SMT | \
            CPU_FTR_COHERENT_ICACHE | \
            CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-           CPU_FTR_DSCR | CPU_FTR_ASYM_SMT | \
+           CPU_FTR_DSCR | CPU_FTR_SAO  | CPU_FTR_ASYM_SMT | \
            CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
            CPU_FTR_CFAR | CPU_FTR_HVMODE | \
            CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR | CPU_FTR_DABRX )
@@ -445,7 +450,7 @@ static inline void cpu_feature_keys_init(void) { }
            CPU_FTR_MMCRA | CPU_FTR_SMT | \
            CPU_FTR_COHERENT_ICACHE | \
            CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-           CPU_FTR_DSCR | \
+           CPU_FTR_DSCR | CPU_FTR_SAO  | \
            CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
            CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
            CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \
@@ -456,7 +461,7 @@ static inline void cpu_feature_keys_init(void) { }
            CPU_FTR_MMCRA | CPU_FTR_SMT | \
            CPU_FTR_COHERENT_ICACHE | \
            CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-           CPU_FTR_DSCR | \
+           CPU_FTR_DSCR | CPU_FTR_SAO  | \
            CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
            CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
            CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
@@ -474,7 +479,7 @@ static inline void cpu_feature_keys_init(void) { }
            CPU_FTR_MMCRA | CPU_FTR_SMT | \
            CPU_FTR_COHERENT_ICACHE | \
            CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-           CPU_FTR_DSCR | \
+           CPU_FTR_DSCR | CPU_FTR_SAO  | \
            CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
            CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
            CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
index 925cf89..6bfc879 100644 (file)
@@ -52,7 +52,7 @@ enum fixed_addresses {
        FIX_HOLE,
        /* reserve the top 128K for early debugging purposes */
        FIX_EARLY_DEBUG_TOP = FIX_HOLE,
-       FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128, PAGE_SIZE)/PAGE_SIZE)-1,
+       FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+(ALIGN(SZ_128K, PAGE_SIZE)/PAGE_SIZE)-1,
 #ifdef CONFIG_HIGHMEM
        FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
        FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
index 3a0db7b..35060be 100644 (file)
@@ -200,17 +200,14 @@ static inline bool arch_irqs_disabled(void)
 #define powerpc_local_irq_pmu_save(flags)                      \
         do {                                                   \
                raw_local_irq_pmu_save(flags);                  \
-               trace_hardirqs_off();                           \
+               if (!raw_irqs_disabled_flags(flags))            \
+                       trace_hardirqs_off();                   \
        } while(0)
 #define powerpc_local_irq_pmu_restore(flags)                   \
        do {                                                    \
-               if (raw_irqs_disabled_flags(flags)) {           \
-                       raw_local_irq_pmu_restore(flags);       \
-                       trace_hardirqs_off();                   \
-               } else {                                        \
+               if (!raw_irqs_disabled_flags(flags))            \
                        trace_hardirqs_on();                    \
-                       raw_local_irq_pmu_restore(flags);       \
-               }                                               \
+               raw_local_irq_pmu_restore(flags);               \
        } while(0)
 #else
 #define powerpc_local_irq_pmu_save(flags)                      \
index d635b96..7355ed0 100644 (file)
 #ifndef __ASSEMBLY__
 
 #include <asm/page.h>
+#include <linux/sizes.h>
 
 #define KASAN_SHADOW_SCALE_SHIFT       3
 
+#if defined(CONFIG_PPC_BOOK3S_32) && defined(CONFIG_MODULES) && defined(CONFIG_STRICT_KERNEL_RWX)
+#define KASAN_KERN_START       ALIGN_DOWN(PAGE_OFFSET - SZ_256M, SZ_256M)
+#else
+#define KASAN_KERN_START       PAGE_OFFSET
+#endif
+
 #define KASAN_SHADOW_START     (KASAN_SHADOW_OFFSET + \
-                                (PAGE_OFFSET >> KASAN_SHADOW_SCALE_SHIFT))
+                                (KASAN_KERN_START >> KASAN_SHADOW_SCALE_SHIFT))
 
 #define KASAN_SHADOW_OFFSET    ASM_CONST(CONFIG_KASAN_SHADOW_OFFSET)
 
index e020d26..10ded83 100644 (file)
@@ -58,7 +58,8 @@
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 
 extern int kvm_unmap_hva_range(struct kvm *kvm,
-                              unsigned long start, unsigned long end);
+                              unsigned long start, unsigned long end,
+                              unsigned flags);
 extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 extern int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
index adf2cda..89aa824 100644 (file)
@@ -210,6 +210,9 @@ struct mce_error_info {
 #define MCE_EVENT_RELEASE      true
 #define MCE_EVENT_DONTRELEASE  false
 
+struct pt_regs;
+struct notifier_block;
+
 extern void save_mce_event(struct pt_regs *regs, long handled,
                           struct mce_error_info *mce_err, uint64_t nip,
                           uint64_t addr, uint64_t phys_addr);
@@ -225,5 +228,9 @@ int mce_register_notifier(struct notifier_block *nb);
 int mce_unregister_notifier(struct notifier_block *nb);
 #ifdef CONFIG_PPC_BOOK3S_64
 void flush_and_reload_slb(void);
+long __machine_check_early_realmode_p7(struct pt_regs *regs);
+long __machine_check_early_realmode_p8(struct pt_regs *regs);
+long __machine_check_early_realmode_p9(struct pt_regs *regs);
+long __machine_check_early_realmode_p10(struct pt_regs *regs);
 #endif /* CONFIG_PPC_BOOK3S_64 */
 #endif /* __ASM_PPC64_MCE_H__ */
index 7c07728..7cb6d18 100644 (file)
 #include <linux/pkeys.h>
 #include <asm/cpu_has_feature.h>
 
-#ifdef CONFIG_PPC_MEM_KEYS
 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
                unsigned long pkey)
 {
-       return pkey_to_vmflag_bits(pkey);
+#ifdef CONFIG_PPC_MEM_KEYS
+       return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
+#else
+       return ((prot & PROT_SAO) ? VM_SAO : 0);
+#endif
 }
 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
 
 static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
 {
-       return __pgprot(vmflag_to_pte_pkey_bits(vm_flags));
+#ifdef CONFIG_PPC_MEM_KEYS
+       return (vm_flags & VM_SAO) ?
+               __pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) :
+               __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags));
+#else
+       return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
+#endif
 }
 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
-#endif
+
+static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
+{
+       if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
+               return false;
+       if (prot & PROT_SAO) {
+               if (!cpu_has_feature(CPU_FTR_SAO))
+                       return false;
+               if (firmware_has_feature(FW_FEATURE_LPAR) &&
+                   !IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR))
+                       return false;
+       }
+       return true;
+}
+#define arch_validate_prot arch_validate_prot
 
 #endif /* CONFIG_PPC64 */
 #endif /* _ASM_POWERPC_MMAN_H */
index 59ee9fa..6cb8aa3 100644 (file)
@@ -82,6 +82,8 @@
  */
 #include <asm/nohash/pte-book3e.h>
 
+#define _PAGE_SAO      0
+
 #define PTE_RPN_MASK   (~((1UL << PTE_RPN_SHIFT) - 1))
 
 /*
index 1e8b2e1..daec64d 100644 (file)
@@ -40,4 +40,7 @@ static inline bool is_sier_available(void) { return false; }
 
 /* To support perf_regs sier update */
 extern bool is_sier_available(void);
+/* To define perf extended regs mask value */
+extern u64 PERF_REG_EXTENDED_MASK;
+#define PERF_REG_EXTENDED_MASK PERF_REG_EXTENDED_MASK
 #endif
index 86c9eb0..f6acabb 100644 (file)
@@ -62,6 +62,11 @@ struct power_pmu {
        int             *blacklist_ev;
        /* BHRB entries in the PMU */
        int             bhrb_nr;
+       /*
+        * set this flag with `PERF_PMU_CAP_EXTENDED_REGS` if
+        * the pmu supports extended perf regs capability
+        */
+       int             capabilities;
 };
 
 /*
index 3a70035..c0c7372 100644 (file)
@@ -11,7 +11,7 @@
 #include <asm-generic/mman-common.h>
 
 
-#define PROT_SAO       0x10            /* Unsupported since v5.9 */
+#define PROT_SAO       0x10            /* Strong Access Ordering */
 
 #define MAP_RENAME      MAP_ANONYMOUS   /* In SunOS terminology */
 #define MAP_NORESERVE   0x40            /* don't reserve swap pages */
index f599064..bdf5f10 100644 (file)
@@ -48,6 +48,24 @@ enum perf_event_powerpc_regs {
        PERF_REG_POWERPC_DSISR,
        PERF_REG_POWERPC_SIER,
        PERF_REG_POWERPC_MMCRA,
-       PERF_REG_POWERPC_MAX,
+       /* Extended registers */
+       PERF_REG_POWERPC_MMCR0,
+       PERF_REG_POWERPC_MMCR1,
+       PERF_REG_POWERPC_MMCR2,
+       PERF_REG_POWERPC_MMCR3,
+       PERF_REG_POWERPC_SIER2,
+       PERF_REG_POWERPC_SIER3,
+       /* Max regs without the extended regs */
+       PERF_REG_POWERPC_MAX = PERF_REG_POWERPC_MMCRA + 1,
 };
+
+#define PERF_REG_PMU_MASK      ((1ULL << PERF_REG_POWERPC_MAX) - 1)
+
+/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_300 */
+#define PERF_REG_PMU_MASK_300   (((1ULL << (PERF_REG_POWERPC_MMCR2 + 1)) - 1) - PERF_REG_PMU_MASK)
+/* PERF_REG_EXTENDED_MASK value for CPU_FTR_ARCH_31 */
+#define PERF_REG_PMU_MASK_31   (((1ULL << (PERF_REG_POWERPC_SIER3 + 1)) - 1) - PERF_REG_PMU_MASK)
+
+#define PERF_REG_MAX_ISA_300   (PERF_REG_POWERPC_MMCR2 + 1)
+#define PERF_REG_MAX_ISA_31    (PERF_REG_POWERPC_SIER3 + 1)
 #endif /* _UAPI_ASM_POWERPC_PERF_REGS_H */
index 3d406a9..2aa89c6 100644 (file)
@@ -72,9 +72,6 @@ extern void __setup_cpu_power9(unsigned long offset, struct cpu_spec* spec);
 extern void __restore_cpu_power9(void);
 extern void __setup_cpu_power10(unsigned long offset, struct cpu_spec* spec);
 extern void __restore_cpu_power10(void);
-extern long __machine_check_early_realmode_p7(struct pt_regs *regs);
-extern long __machine_check_early_realmode_p8(struct pt_regs *regs);
-extern long __machine_check_early_realmode_p9(struct pt_regs *regs);
 #endif /* CONFIG_PPC64 */
 #if defined(CONFIG_E500)
 extern void __setup_cpu_e5500(unsigned long offset, struct cpu_spec* spec);
@@ -542,6 +539,25 @@ static struct cpu_spec __initdata cpu_specs[] = {
                .machine_check_early    = __machine_check_early_realmode_p9,
                .platform               = "power9",
        },
+       {       /* Power10 */
+               .pvr_mask               = 0xffff0000,
+               .pvr_value              = 0x00800000,
+               .cpu_name               = "POWER10 (raw)",
+               .cpu_features           = CPU_FTRS_POWER10,
+               .cpu_user_features      = COMMON_USER_POWER10,
+               .cpu_user_features2     = COMMON_USER2_POWER10,
+               .mmu_features           = MMU_FTRS_POWER10,
+               .icache_bsize           = 128,
+               .dcache_bsize           = 128,
+               .num_pmcs               = 6,
+               .pmc_type               = PPC_PMC_IBM,
+               .oprofile_cpu_type      = "ppc64/power10",
+               .oprofile_type          = PPC_OPROFILE_INVALID,
+               .cpu_setup              = __setup_cpu_power10,
+               .cpu_restore            = __restore_cpu_power10,
+               .machine_check_early    = __machine_check_early_realmode_p10,
+               .platform               = "power10",
+       },
        {       /* Cell Broadband Engine */
                .pvr_mask               = 0xffff0000,
                .pvr_value              = 0x00700000,
index 6f8c0c6..f204ad7 100644 (file)
@@ -64,10 +64,6 @@ struct dt_cpu_feature {
  * Set up the base CPU
  */
 
-extern long __machine_check_early_realmode_p8(struct pt_regs *regs);
-extern long __machine_check_early_realmode_p9(struct pt_regs *regs);
-extern long __machine_check_early_realmode_p10(struct pt_regs *regs);
-
 static int hv_mode;
 
 static struct {
@@ -657,7 +653,7 @@ static struct dt_cpu_feature_match __initdata
        {"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},
        {"processor-utilization-of-resources-register", feat_enable_purr, 0},
        {"no-execute", feat_enable, 0},
-       /* strong-access-ordering is unused */
+       {"strong-access-ordering", feat_enable, CPU_FTR_SAO},
        {"cache-inhibited-large-page", feat_enable_large_ci, 0},
        {"coprocessor-icswx", feat_enable, 0},
        {"hypervisor-virtualization-interrupt", feat_enable_hvi, 0},
index 33a42e4..733e40e 100644 (file)
@@ -113,6 +113,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)
        ld      r11,exception_marker@toc(r2)
        std     r11,-16(r10)            /* "regshere" marker */
 
+BEGIN_FTR_SECTION
+       HMT_MEDIUM
+END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
+
        /*
         * RECONCILE_IRQ_STATE without calling trace_hardirqs_off(), which
         * would clobber syscall parameters. Also we always enter with IRQs
index 016bd83..73a5704 100644 (file)
@@ -548,7 +548,7 @@ void notrace restore_math(struct pt_regs *regs)
         * are live for the user thread).
         */
        if ((!(msr & MSR_FP)) && should_restore_fp())
-               new_msr |= MSR_FP | current->thread.fpexc_mode;
+               new_msr |= MSR_FP;
 
        if ((!(msr & MSR_VEC)) && should_restore_altivec())
                new_msr |= MSR_VEC;
@@ -559,11 +559,17 @@ void notrace restore_math(struct pt_regs *regs)
        }
 
        if (new_msr) {
+               unsigned long fpexc_mode = 0;
+
                msr_check_and_set(new_msr);
 
-               if (new_msr & MSR_FP)
+               if (new_msr & MSR_FP) {
                        do_restore_fp();
 
+                       // This also covers VSX, because VSX implies FP
+                       fpexc_mode = current->thread.fpexc_mode;
+               }
+
                if (new_msr & MSR_VEC)
                        do_restore_altivec();
 
@@ -572,7 +578,7 @@ void notrace restore_math(struct pt_regs *regs)
 
                msr_check_and_clear(new_msr);
 
-               regs->msr |= new_msr;
+               regs->msr |= new_msr | fpexc_mode;
        }
 }
 #endif
index b198b0f..808ec9f 100644 (file)
@@ -311,6 +311,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                                min = pvr & 0xFF;
                                break;
                        case 0x004e: /* POWER9 bits 12-15 give chip type */
+                       case 0x0080: /* POWER10 bit 12 gives SMT8/4 */
                                maj = (pvr >> 8) & 0x0F;
                                min = pvr & 0xFF;
                                break;
index 41fedec..49db50d 100644 (file)
@@ -834,7 +834,8 @@ void kvmppc_core_commit_memory_region(struct kvm *kvm,
        kvm->arch.kvm_ops->commit_memory_region(kvm, mem, old, new, change);
 }
 
-int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
+                       unsigned flags)
 {
        return kvm->arch.kvm_ops->unmap_hva_range(kvm, start, end);
 }
index d6c1069..ed0c9c4 100644 (file)
@@ -734,7 +734,8 @@ static int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
        return 0;
 }
 
-int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
+                       unsigned flags)
 {
        /* kvm_unmap_hva flushes everything anyways */
        kvm_unmap_hva(kvm, start);
index c016291..d426eaf 100644 (file)
@@ -191,10 +191,17 @@ static bool is_module_segment(unsigned long addr)
 {
        if (!IS_ENABLED(CONFIG_MODULES))
                return false;
+#ifdef MODULES_VADDR
+       if (addr < ALIGN_DOWN(MODULES_VADDR, SZ_256M))
+               return false;
+       if (addr > ALIGN(MODULES_END, SZ_256M) - 1)
+               return false;
+#else
        if (addr < ALIGN_DOWN(VMALLOC_START, SZ_256M))
                return false;
-       if (addr >= ALIGN(VMALLOC_END, SZ_256M))
+       if (addr > ALIGN(VMALLOC_END, SZ_256M) - 1)
                return false;
+#endif
        return true;
 }
 
index 1da9dbb..c663e7b 100644 (file)
@@ -232,6 +232,8 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
                rflags |= HPTE_R_I;
        else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT)
                rflags |= (HPTE_R_I | HPTE_R_G);
+       else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_SAO)
+               rflags |= (HPTE_R_W | HPTE_R_I | HPTE_R_M);
        else
                /*
                 * Add memory coherence if cache inhibited is not set
@@ -1115,8 +1117,10 @@ void hash__early_init_mmu_secondary(void)
                        && cpu_has_feature(CPU_FTR_HVMODE))
                tlbiel_all();
 
-       if (IS_ENABLED(CONFIG_PPC_MEM_KEYS) && mmu_has_feature(MMU_FTR_PKEY))
+#ifdef CONFIG_PPC_MEM_KEYS
+       if (mmu_has_feature(MMU_FTR_PKEY))
                mtspr(SPRN_UAMOR, default_uamor);
+#endif
 }
 #endif /* CONFIG_SMP */
 
index 16d09b3..78d61f9 100644 (file)
@@ -475,7 +475,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
                case BPF_JMP | BPF_JSET | BPF_K:
                case BPF_JMP | BPF_JSET | BPF_X:
                        true_cond = COND_NE;
-                       /* Fall through */
+                       fallthrough;
                cond_branch:
                        /* same targets, can avoid doing the test :) */
                        if (filter[i].jt == filter[i].jf) {
index 78fe349..08643cb 100644 (file)
@@ -1557,9 +1557,16 @@ nocheck:
        ret = 0;
  out:
        if (has_branch_stack(event)) {
-               power_pmu_bhrb_enable(event);
-               cpuhw->bhrb_filter = ppmu->bhrb_filter_map(
-                                       event->attr.branch_sample_type);
+               u64 bhrb_filter = -1;
+
+               if (ppmu->bhrb_filter_map)
+                       bhrb_filter = ppmu->bhrb_filter_map(
+                               event->attr.branch_sample_type);
+
+               if (bhrb_filter != -1) {
+                       cpuhw->bhrb_filter = bhrb_filter;
+                       power_pmu_bhrb_enable(event);
+               }
        }
 
        perf_pmu_enable(event->pmu);
@@ -1881,7 +1888,6 @@ static int power_pmu_event_init(struct perf_event *event)
        int n;
        int err;
        struct cpu_hw_events *cpuhw;
-       u64 bhrb_filter;
 
        if (!ppmu)
                return -ENOENT;
@@ -1987,7 +1993,10 @@ static int power_pmu_event_init(struct perf_event *event)
        err = power_check_constraints(cpuhw, events, cflags, n + 1);
 
        if (has_branch_stack(event)) {
-               bhrb_filter = ppmu->bhrb_filter_map(
+               u64 bhrb_filter = -1;
+
+               if (ppmu->bhrb_filter_map)
+                       bhrb_filter = ppmu->bhrb_filter_map(
                                        event->attr.branch_sample_type);
 
                if (bhrb_filter == -1) {
@@ -2141,6 +2150,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
 
                if (perf_event_overflow(event, &data, regs))
                        power_pmu_stop(event, 0);
+       } else if (period) {
+               /* Account for interrupt in case of invalid SIAR */
+               if (perf_event_account_interrupt(event))
+                       power_pmu_stop(event, 0);
        }
 }
 
@@ -2323,6 +2336,7 @@ int register_power_pmu(struct power_pmu *pmu)
                pmu->name);
 
        power_pmu.attr_groups = ppmu->attr_groups;
+       power_pmu.capabilities |= (ppmu->capabilities & PERF_PMU_CAP_EXTENDED_REGS);
 
 #ifdef MSR_HV
        /*
index cdb7bfb..6e7e820 100644 (file)
@@ -1128,6 +1128,15 @@ static struct bin_attribute *if_bin_attrs[] = {
        NULL,
 };
 
+static struct attribute *cpumask_attrs[] = {
+       &dev_attr_cpumask.attr,
+       NULL,
+};
+
+static struct attribute_group cpumask_attr_group = {
+       .attrs = cpumask_attrs,
+};
+
 static struct attribute *if_attrs[] = {
        &dev_attr_catalog_len.attr,
        &dev_attr_catalog_version.attr,
@@ -1135,7 +1144,6 @@ static struct attribute *if_attrs[] = {
        &dev_attr_sockets.attr,
        &dev_attr_chipspersocket.attr,
        &dev_attr_coresperchip.attr,
-       &dev_attr_cpumask.attr,
        NULL,
 };
 
@@ -1151,6 +1159,7 @@ static const struct attribute_group *attr_groups[] = {
        &event_desc_group,
        &event_long_desc_group,
        &if_group,
+       &cpumask_attr_group,
        NULL,
 };
 
index a45d694..62d0b54 100644 (file)
@@ -1289,7 +1289,7 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem,
        header->misc = 0;
 
        if (cpu_has_feature(CPU_FTR_ARCH_31)) {
-               switch (IMC_TRACE_RECORD_VAL_HVPR(mem->val)) {
+               switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) {
                case 0:/* when MSR HV and PR not set in the trace-record */
                        header->misc |= PERF_RECORD_MISC_GUEST_KERNEL;
                        break;
@@ -1297,7 +1297,7 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem,
                        header->misc |= PERF_RECORD_MISC_GUEST_USER;
                        break;
                case 2: /* MSR HV is 1 and PR is 0 */
-                       header->misc |= PERF_RECORD_MISC_HYPERVISOR;
+                       header->misc |= PERF_RECORD_MISC_KERNEL;
                        break;
                case 3: /* MSR HV is 1 and PR is 1 */
                        header->misc |= PERF_RECORD_MISC_USER;
index a213a0a..8e53f2f 100644 (file)
 #include <asm/ptrace.h>
 #include <asm/perf_regs.h>
 
+u64 PERF_REG_EXTENDED_MASK;
+
 #define PT_REGS_OFFSET(id, r) [id] = offsetof(struct pt_regs, r)
 
-#define REG_RESERVED (~((1ULL << PERF_REG_POWERPC_MAX) - 1))
+#define REG_RESERVED (~(PERF_REG_EXTENDED_MASK | PERF_REG_PMU_MASK))
 
 static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
        PT_REGS_OFFSET(PERF_REG_POWERPC_R0,  gpr[0]),
@@ -69,10 +71,36 @@ static unsigned int pt_regs_offset[PERF_REG_POWERPC_MAX] = {
        PT_REGS_OFFSET(PERF_REG_POWERPC_MMCRA, dsisr),
 };
 
+/* Function to return the extended register values */
+static u64 get_ext_regs_value(int idx)
+{
+       switch (idx) {
+       case PERF_REG_POWERPC_MMCR0:
+               return mfspr(SPRN_MMCR0);
+       case PERF_REG_POWERPC_MMCR1:
+               return mfspr(SPRN_MMCR1);
+       case PERF_REG_POWERPC_MMCR2:
+               return mfspr(SPRN_MMCR2);
+#ifdef CONFIG_PPC64
+       case PERF_REG_POWERPC_MMCR3:
+               return mfspr(SPRN_MMCR3);
+       case PERF_REG_POWERPC_SIER2:
+               return mfspr(SPRN_SIER2);
+       case PERF_REG_POWERPC_SIER3:
+               return mfspr(SPRN_SIER3);
+#endif
+       default: return 0;
+       }
+}
+
 u64 perf_reg_value(struct pt_regs *regs, int idx)
 {
-       if (WARN_ON_ONCE(idx >= PERF_REG_POWERPC_MAX))
-               return 0;
+       u64 perf_reg_extended_max = PERF_REG_POWERPC_MAX;
+
+       if (cpu_has_feature(CPU_FTR_ARCH_31))
+               perf_reg_extended_max = PERF_REG_MAX_ISA_31;
+       else if (cpu_has_feature(CPU_FTR_ARCH_300))
+               perf_reg_extended_max = PERF_REG_MAX_ISA_300;
 
        if (idx == PERF_REG_POWERPC_SIER &&
           (IS_ENABLED(CONFIG_FSL_EMB_PERF_EVENT) ||
@@ -85,6 +113,16 @@ u64 perf_reg_value(struct pt_regs *regs, int idx)
            IS_ENABLED(CONFIG_PPC32)))
                return 0;
 
+       if (idx >= PERF_REG_POWERPC_MAX && idx < perf_reg_extended_max)
+               return get_ext_regs_value(idx);
+
+       /*
+        * If the idx is referring to value beyond the
+        * supported registers, return 0 with a warning
+        */
+       if (WARN_ON_ONCE(idx >= perf_reg_extended_max))
+               return 0;
+
        return regs_get_register(regs, pt_regs_offset[idx]);
 }
 
index f7cff7f..8314865 100644 (file)
@@ -87,6 +87,8 @@
 #define POWER10_MMCRA_IFM3             0x00000000C0000000UL
 #define POWER10_MMCRA_BHRB_MASK                0x00000000C0000000UL
 
+extern u64 PERF_REG_EXTENDED_MASK;
+
 /* Table of alternatives, sorted by column 0 */
 static const unsigned int power10_event_alternatives[][MAX_ALT] = {
        { PM_RUN_CYC_ALT,               PM_RUN_CYC },
@@ -397,6 +399,7 @@ static struct power_pmu power10_pmu = {
        .cache_events           = &power10_cache_events,
        .attr_groups            = power10_pmu_attr_groups,
        .bhrb_nr                = 32,
+       .capabilities           = PERF_PMU_CAP_EXTENDED_REGS,
 };
 
 int init_power10_pmu(void)
@@ -408,6 +411,9 @@ int init_power10_pmu(void)
            strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10"))
                return -ENODEV;
 
+       /* Set the PERF_REG_EXTENDED_MASK here */
+       PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_31;
+
        rc = register_power_pmu(&power10_pmu);
        if (rc)
                return rc;
index 05dae38..2a57e93 100644 (file)
@@ -90,6 +90,8 @@ enum {
 #define POWER9_MMCRA_IFM3              0x00000000C0000000UL
 #define POWER9_MMCRA_BHRB_MASK         0x00000000C0000000UL
 
+extern u64 PERF_REG_EXTENDED_MASK;
+
 /* Nasty Power9 specific hack */
 #define PVR_POWER9_CUMULUS             0x00002000
 
@@ -434,6 +436,7 @@ static struct power_pmu power9_pmu = {
        .cache_events           = &power9_cache_events,
        .attr_groups            = power9_pmu_attr_groups,
        .bhrb_nr                = 32,
+       .capabilities           = PERF_PMU_CAP_EXTENDED_REGS,
 };
 
 int init_power9_pmu(void)
@@ -457,6 +460,9 @@ int init_power9_pmu(void)
                }
        }
 
+       /* Set the PERF_REG_EXTENDED_MASK here */
+       PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_300;
+
        rc = register_power_pmu(&power9_pmu);
        if (rc)
                return rc;
index 87737ec..1dc9d3c 100644 (file)
@@ -36,7 +36,7 @@ config PPC_BOOK3S_6xx
        select PPC_HAVE_PMU_SUPPORT
        select PPC_HAVE_KUEP
        select PPC_HAVE_KUAP
-       select HAVE_ARCH_VMAP_STACK
+       select HAVE_ARCH_VMAP_STACK if !ADB_PMU
 
 config PPC_BOOK3S_601
        bool "PowerPC 601"
index 77513a8..345ab06 100644 (file)
@@ -1223,7 +1223,7 @@ static void __init pnv_probe_idle_states(void)
                return;
        }
 
-       if (pvr_version_is(PVR_POWER9))
+       if (cpu_has_feature(CPU_FTR_ARCH_300))
                pnv_power9_idle_init();
 
        for (i = 0; i < nr_pnv_idle_states; i++)
index c9c25fb..023a4f9 100644 (file)
@@ -2705,7 +2705,7 @@ void pnv_pci_ioda2_release_pe_dma(struct pnv_ioda_pe *pe)
        struct iommu_table *tbl = pe->table_group.tables[0];
        int64_t rc;
 
-       if (pe->dma_setup_done)
+       if (!pe->dma_setup_done)
                return;
 
        rc = pnv_pci_ioda2_unset_window(&pe->table_group, 0);
index c6e0d8a..7a974ed 100644 (file)
@@ -107,22 +107,28 @@ static int pseries_cpu_disable(void)
  */
 static void pseries_cpu_die(unsigned int cpu)
 {
-       int tries;
        int cpu_status = 1;
        unsigned int pcpu = get_hard_smp_processor_id(cpu);
+       unsigned long timeout = jiffies + msecs_to_jiffies(120000);
 
-       for (tries = 0; tries < 25; tries++) {
+       while (true) {
                cpu_status = smp_query_cpu_stopped(pcpu);
                if (cpu_status == QCSS_STOPPED ||
                    cpu_status == QCSS_HARDWARE_ERROR)
                        break;
-               cpu_relax();
 
+               if (time_after(jiffies, timeout)) {
+                       pr_warn("CPU %i (hwid %i) didn't die after 120 seconds\n",
+                               cpu, pcpu);
+                       timeout = jiffies + msecs_to_jiffies(120000);
+               }
+
+               cond_resched();
        }
 
-       if (cpu_status != 0) {
-               printk("Querying DEAD? cpu %i (%i) shows %i\n",
-                      cpu, pcpu, cpu_status);
+       if (cpu_status == QCSS_HARDWARE_ERROR) {
+               pr_warn("CPU %i (hwid %i) reported error while dying\n",
+                       cpu, pcpu);
        }
 
        /* Isolation and deallocation are definitely done by
index f3736fc..13c86a2 100644 (file)
@@ -184,7 +184,6 @@ static void handle_system_shutdown(char event_modifier)
        case EPOW_SHUTDOWN_ON_UPS:
                pr_emerg("Loss of system power detected. System is running on"
                         " UPS/battery. Check RTAS error log for details\n");
-               orderly_poweroff(true);
                break;
 
        case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS:
index 7b59055..df18372 100644 (file)
@@ -81,7 +81,7 @@ config RISCV
        select PCI_DOMAINS_GENERIC if PCI
        select PCI_MSI if PCI
        select RISCV_INTC
-       select RISCV_TIMER
+       select RISCV_TIMER if RISCV_SBI
        select SPARSEMEM_STATIC if 32BIT
        select SPARSE_IRQ
        select SYSCTL_EXCEPTION_TRACE
index 6c88148..8a55f61 100644 (file)
@@ -12,6 +12,7 @@ config SOC_SIFIVE
 
 config SOC_VIRT
        bool "QEMU Virt Machine"
+       select CLINT_TIMER if RISCV_M_MODE
        select POWER_RESET
        select POWER_RESET_SYSCON
        select POWER_RESET_SYSCON_POWEROFF
@@ -24,6 +25,7 @@ config SOC_VIRT
 config SOC_KENDRYTE
        bool "Kendryte K210 SoC"
        depends on !MMU
+       select CLINT_TIMER if RISCV_M_MODE
        select SERIAL_SIFIVE if TTY
        select SERIAL_SIFIVE_CONSOLE if TTY
        select SIFIVE_PLIC
index f27596e..e046a0b 100644 (file)
@@ -26,6 +26,7 @@ CONFIG_EXPERT=y
 CONFIG_SLOB=y
 # CONFIG_SLAB_MERGE_DEFAULT is not set
 # CONFIG_MMU is not set
+CONFIG_SOC_VIRT=y
 CONFIG_MAXPHYSMEM_2GB=y
 CONFIG_SMP=y
 CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
@@ -49,7 +50,6 @@ CONFIG_VIRTIO_BLK=y
 # CONFIG_SERIO is not set
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_LDISC_AUTOLOAD is not set
-# CONFIG_DEVMEM is not set
 CONFIG_SERIAL_8250=y
 # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
 CONFIG_SERIAL_8250_CONSOLE=y
@@ -57,16 +57,13 @@ CONFIG_SERIAL_8250_NR_UARTS=1
 CONFIG_SERIAL_8250_RUNTIME_UARTS=1
 CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
+# CONFIG_DEVMEM is not set
 # CONFIG_HWMON is not set
-# CONFIG_LCD_CLASS_DEVICE is not set
-# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
 CONFIG_VIRTIO_MMIO=y
 CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
-CONFIG_SIFIVE_PLIC=y
-# CONFIG_VALIDATE_FS_PARSER is not set
 CONFIG_EXT2_FS=y
 # CONFIG_DNOTIFY is not set
 # CONFIG_INOTIFY_USER is not set
index 3a55f0e..2c2cda6 100644 (file)
@@ -14,6 +14,7 @@ CONFIG_CHECKPOINT_RESTORE=y
 CONFIG_BLK_DEV_INITRD=y
 CONFIG_EXPERT=y
 CONFIG_BPF_SYSCALL=y
+CONFIG_SOC_SIFIVE=y
 CONFIG_SOC_VIRT=y
 CONFIG_ARCH_RV32I=y
 CONFIG_SMP=y
@@ -62,6 +63,8 @@ CONFIG_HVC_RISCV_SBI=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_VIRTIO=y
+CONFIG_SPI=y
+CONFIG_SPI_SIFIVE=y
 # CONFIG_PTP_1588_CLOCK is not set
 CONFIG_POWER_RESET=y
 CONFIG_DRM=y
@@ -77,6 +80,8 @@ CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_HCD_PLATFORM=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_UAS=y
+CONFIG_MMC=y
+CONFIG_MMC_SPI=y
 CONFIG_RTC_CLASS=y
 CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_BALLOON=y
diff --git a/arch/riscv/include/asm/clint.h b/arch/riscv/include/asm/clint.h
deleted file mode 100644 (file)
index a279b17..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_RISCV_CLINT_H
-#define _ASM_RISCV_CLINT_H 1
-
-#include <linux/io.h>
-#include <linux/smp.h>
-
-#ifdef CONFIG_RISCV_M_MODE
-extern u32 __iomem *clint_ipi_base;
-
-void clint_init_boot_cpu(void);
-
-static inline void clint_send_ipi_single(unsigned long hartid)
-{
-       writel(1, clint_ipi_base + hartid);
-}
-
-static inline void clint_send_ipi_mask(const struct cpumask *mask)
-{
-       int cpu;
-
-       for_each_cpu(cpu, mask)
-               clint_send_ipi_single(cpuid_to_hartid_map(cpu));
-}
-
-static inline void clint_clear_ipi(unsigned long hartid)
-{
-       writel(0, clint_ipi_base + hartid);
-}
-#else /* CONFIG_RISCV_M_MODE */
-#define clint_init_boot_cpu()  do { } while (0)
-
-/* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_M_MODE): */
-void clint_send_ipi_single(unsigned long hartid);
-void clint_send_ipi_mask(const struct cpumask *hartid_mask);
-void clint_clear_ipi(unsigned long hartid);
-#endif /* CONFIG_RISCV_M_MODE */
-
-#endif /* _ASM_RISCV_CLINT_H */
index 6dfd2a1..df1f7c4 100644 (file)
 struct seq_file;
 extern unsigned long boot_cpu_hartid;
 
+struct riscv_ipi_ops {
+       void (*ipi_inject)(const struct cpumask *target);
+       void (*ipi_clear)(void);
+};
+
 #ifdef CONFIG_SMP
 /*
  * Mapping between linux logical cpu index and hartid.
@@ -40,6 +45,12 @@ void arch_send_call_function_single_ipi(int cpu);
 int riscv_hartid_to_cpuid(int hartid);
 void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
 
+/* Set custom IPI operations */
+void riscv_set_ipi_ops(struct riscv_ipi_ops *ops);
+
+/* Clear IPI for current CPU */
+void riscv_clear_ipi(void);
+
 /* Secondary hart entry */
 asmlinkage void smp_callin(void);
 
@@ -81,6 +92,14 @@ static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
        cpumask_set_cpu(boot_cpu_hartid, out);
 }
 
+static inline void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
+{
+}
+
+static inline void riscv_clear_ipi(void)
+{
+}
+
 #endif /* CONFIG_SMP */
 
 #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP)
index bad2a7c..a3fb85d 100644 (file)
@@ -7,41 +7,27 @@
 #define _ASM_RISCV_TIMEX_H
 
 #include <asm/csr.h>
-#include <asm/mmio.h>
 
 typedef unsigned long cycles_t;
 
-extern u64 __iomem *riscv_time_val;
-extern u64 __iomem *riscv_time_cmp;
-
-#ifdef CONFIG_64BIT
-#define mmio_get_cycles()      readq_relaxed(riscv_time_val)
-#else
-#define mmio_get_cycles()      readl_relaxed(riscv_time_val)
-#define mmio_get_cycles_hi()   readl_relaxed(((u32 *)riscv_time_val) + 1)
-#endif
-
 static inline cycles_t get_cycles(void)
 {
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               return csr_read(CSR_TIME);
-       return mmio_get_cycles();
+       return csr_read(CSR_TIME);
 }
 #define get_cycles get_cycles
 
+static inline u32 get_cycles_hi(void)
+{
+       return csr_read(CSR_TIMEH);
+}
+#define get_cycles_hi get_cycles_hi
+
 #ifdef CONFIG_64BIT
 static inline u64 get_cycles64(void)
 {
        return get_cycles();
 }
 #else /* CONFIG_64BIT */
-static inline u32 get_cycles_hi(void)
-{
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               return csr_read(CSR_TIMEH);
-       return mmio_get_cycles_hi();
-}
-
 static inline u64 get_cycles64(void)
 {
        u32 hi, lo;
index a5287ab..dc93710 100644 (file)
@@ -31,7 +31,7 @@ obj-y += cacheinfo.o
 obj-y  += patch.o
 obj-$(CONFIG_MMU) += vdso.o vdso/
 
-obj-$(CONFIG_RISCV_M_MODE)     += clint.o traps_misaligned.o
+obj-$(CONFIG_RISCV_M_MODE)     += traps_misaligned.o
 obj-$(CONFIG_FPU)              += fpu.o
 obj-$(CONFIG_SMP)              += smpboot.o
 obj-$(CONFIG_SMP)              += smp.o
diff --git a/arch/riscv/kernel/clint.c b/arch/riscv/kernel/clint.c
deleted file mode 100644 (file)
index 3647980..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2019 Christoph Hellwig.
- */
-
-#include <linux/io.h>
-#include <linux/of_address.h>
-#include <linux/types.h>
-#include <asm/clint.h>
-#include <asm/csr.h>
-#include <asm/timex.h>
-#include <asm/smp.h>
-
-/*
- * This is the layout used by the SiFive clint, which is also shared by the qemu
- * virt platform, and the Kendryte KD210 at least.
- */
-#define CLINT_IPI_OFF          0
-#define CLINT_TIME_CMP_OFF     0x4000
-#define CLINT_TIME_VAL_OFF     0xbff8
-
-u32 __iomem *clint_ipi_base;
-
-void clint_init_boot_cpu(void)
-{
-       struct device_node *np;
-       void __iomem *base;
-
-       np = of_find_compatible_node(NULL, NULL, "riscv,clint0");
-       if (!np) {
-               panic("clint not found");
-               return;
-       }
-
-       base = of_iomap(np, 0);
-       if (!base)
-               panic("could not map CLINT");
-
-       clint_ipi_base = base + CLINT_IPI_OFF;
-       riscv_time_cmp = base + CLINT_TIME_CMP_OFF;
-       riscv_time_val = base + CLINT_TIME_VAL_OFF;
-
-       clint_clear_ipi(boot_cpu_hartid);
-}
index f383ef5..226ccce 100644 (file)
@@ -547,6 +547,18 @@ static inline long sbi_get_firmware_version(void)
        return __sbi_base_ecall(SBI_EXT_BASE_GET_IMP_VERSION);
 }
 
+static void sbi_send_cpumask_ipi(const struct cpumask *target)
+{
+       struct cpumask hartid_mask;
+
+       riscv_cpuid_to_hartid_mask(target, &hartid_mask);
+
+       sbi_send_ipi(cpumask_bits(&hartid_mask));
+}
+
+static struct riscv_ipi_ops sbi_ipi_ops = {
+       .ipi_inject = sbi_send_cpumask_ipi
+};
 
 int __init sbi_init(void)
 {
@@ -587,5 +599,7 @@ int __init sbi_init(void)
                __sbi_rfence    = __sbi_rfence_v01;
        }
 
+       riscv_set_ipi_ops(&sbi_ipi_ops);
+
        return 0;
 }
index f04373b..2c6dd32 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/swiotlb.h>
 #include <linux/smp.h>
 
-#include <asm/clint.h>
 #include <asm/cpu_ops.h>
 #include <asm/setup.h>
 #include <asm/sections.h>
@@ -79,7 +78,6 @@ void __init setup_arch(char **cmdline_p)
 #else
        unflatten_device_tree();
 #endif
-       clint_init_boot_cpu();
 
 #ifdef CONFIG_SWIOTLB
        swiotlb_init(1);
index 17ba190..e996e08 100644 (file)
@@ -250,7 +250,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                regs->a0 = -EINTR;
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                         regs->a0 = regs->orig_a0;
                        regs->epc -= 0x4;
index 554b0fb..ea028d9 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/delay.h>
 #include <linux/irq_work.h>
 
-#include <asm/clint.h>
 #include <asm/sbi.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
@@ -86,9 +85,25 @@ static void ipi_stop(void)
                wait_for_interrupt();
 }
 
+static struct riscv_ipi_ops *ipi_ops;
+
+void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
+{
+       ipi_ops = ops;
+}
+EXPORT_SYMBOL_GPL(riscv_set_ipi_ops);
+
+void riscv_clear_ipi(void)
+{
+       if (ipi_ops && ipi_ops->ipi_clear)
+               ipi_ops->ipi_clear();
+
+       csr_clear(CSR_IP, IE_SIE);
+}
+EXPORT_SYMBOL_GPL(riscv_clear_ipi);
+
 static void send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op)
 {
-       struct cpumask hartid_mask;
        int cpu;
 
        smp_mb__before_atomic();
@@ -96,33 +111,22 @@ static void send_ipi_mask(const struct cpumask *mask, enum ipi_message_type op)
                set_bit(op, &ipi_data[cpu].bits);
        smp_mb__after_atomic();
 
-       riscv_cpuid_to_hartid_mask(mask, &hartid_mask);
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               sbi_send_ipi(cpumask_bits(&hartid_mask));
+       if (ipi_ops && ipi_ops->ipi_inject)
+               ipi_ops->ipi_inject(mask);
        else
-               clint_send_ipi_mask(mask);
+               pr_warn("SMP: IPI inject method not available\n");
 }
 
 static void send_ipi_single(int cpu, enum ipi_message_type op)
 {
-       int hartid = cpuid_to_hartid_map(cpu);
-
        smp_mb__before_atomic();
        set_bit(op, &ipi_data[cpu].bits);
        smp_mb__after_atomic();
 
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               sbi_send_ipi(cpumask_bits(cpumask_of(hartid)));
-       else
-               clint_send_ipi_single(hartid);
-}
-
-static inline void clear_ipi(void)
-{
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               csr_clear(CSR_IP, IE_SIE);
+       if (ipi_ops && ipi_ops->ipi_inject)
+               ipi_ops->ipi_inject(cpumask_of(cpu));
        else
-               clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id()));
+               pr_warn("SMP: IPI inject method not available\n");
 }
 
 #ifdef CONFIG_IRQ_WORK
@@ -140,7 +144,7 @@ void handle_IPI(struct pt_regs *regs)
 
        irq_enter();
 
-       clear_ipi();
+       riscv_clear_ipi();
 
        while (true) {
                unsigned long ops;
index 356825a..96167d5 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/of.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sched/mm.h>
-#include <asm/clint.h>
 #include <asm/cpu_ops.h>
 #include <asm/irq.h>
 #include <asm/mmu_context.h>
@@ -147,8 +146,7 @@ asmlinkage __visible void smp_callin(void)
        struct mm_struct *mm = &init_mm;
        unsigned int curr_cpuid = smp_processor_id();
 
-       if (!IS_ENABLED(CONFIG_RISCV_SBI))
-               clint_clear_ipi(cpuid_to_hartid_map(smp_processor_id()));
+       riscv_clear_ipi();
 
        /* All kernel threads share the same mm context.  */
        mmgrab(mm);
index bc5f220..579575f 100644 (file)
@@ -1020,7 +1020,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
                        emit_zext64(dst, ctx);
                        break;
                }
-               /* Fallthrough. */
+               fallthrough;
 
        case BPF_ALU | BPF_ADD | BPF_X:
        case BPF_ALU | BPF_SUB | BPF_X:
@@ -1079,7 +1079,7 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
                case 16:
                        emit(rv_slli(lo(rd), lo(rd), 16), ctx);
                        emit(rv_srli(lo(rd), lo(rd), 16), ctx);
-                       /* Fallthrough. */
+                       fallthrough;
                case 32:
                        if (!ctx->prog->aux->verifier_zext)
                                emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx);
index 3d86e12..b29fcc6 100644 (file)
@@ -30,7 +30,7 @@ config GENERIC_BUG_RELATIVE_POINTERS
        def_bool y
 
 config GENERIC_LOCKBREAK
-       def_bool y if PREEMPTTION
+       def_bool y if PREEMPTION
 
 config PGSTE
        def_bool y if KVM
index 0cf9a82..7228aab 100644 (file)
@@ -626,6 +626,7 @@ CONFIG_NTFS_RW=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_TMPFS_INODE64=y
 CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=m
 CONFIG_ECRYPT_FS=m
@@ -807,6 +808,7 @@ CONFIG_DEBUG_NOTIFIERS=y
 CONFIG_BUG_ON_DATA_CORRUPTION=y
 CONFIG_DEBUG_CREDENTIALS=y
 CONFIG_RCU_TORTURE_TEST=m
+CONFIG_RCU_REF_SCALE_TEST=m
 CONFIG_RCU_CPU_STALL_TIMEOUT=300
 # CONFIG_RCU_TRACE is not set
 CONFIG_LATENCYTOP=y
@@ -818,6 +820,7 @@ CONFIG_PREEMPT_TRACER=y
 CONFIG_SCHED_TRACER=y
 CONFIG_FTRACE_SYSCALLS=y
 CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_BPF_KPROBE_OVERRIDE=y
 CONFIG_HIST_TRIGGERS=y
 CONFIG_S390_PTDUMP=y
 CONFIG_NOTIFIER_ERROR_INJECTION=m
@@ -829,6 +832,7 @@ CONFIG_FAIL_MAKE_REQUEST=y
 CONFIG_FAIL_IO_TIMEOUT=y
 CONFIG_FAIL_FUTEX=y
 CONFIG_FAULT_INJECTION_DEBUG_FS=y
+CONFIG_FAIL_FUNCTION=y
 CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
 CONFIG_LKDTM=m
 CONFIG_TEST_LIST_SORT=y
index 5df9759..fab03b7 100644 (file)
@@ -617,6 +617,7 @@ CONFIG_NTFS_RW=y
 CONFIG_PROC_KCORE=y
 CONFIG_TMPFS=y
 CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_TMPFS_INODE64=y
 CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=m
 CONFIG_ECRYPT_FS=m
@@ -763,6 +764,7 @@ CONFIG_PANIC_ON_OOPS=y
 CONFIG_TEST_LOCKUP=m
 CONFIG_BUG_ON_DATA_CORRUPTION=y
 CONFIG_RCU_TORTURE_TEST=m
+CONFIG_RCU_REF_SCALE_TEST=m
 CONFIG_RCU_CPU_STALL_TIMEOUT=60
 CONFIG_LATENCYTOP=y
 CONFIG_BOOTTIME_TRACING=y
@@ -771,6 +773,7 @@ CONFIG_STACK_TRACER=y
 CONFIG_SCHED_TRACER=y
 CONFIG_FTRACE_SYSCALLS=y
 CONFIG_BLK_DEV_IO_TRACE=y
+CONFIG_BPF_KPROBE_OVERRIDE=y
 CONFIG_HIST_TRIGGERS=y
 CONFIG_S390_PTDUMP=y
 CONFIG_LKDTM=m
index 4091c50..8f67c55 100644 (file)
@@ -74,5 +74,6 @@ CONFIG_DEBUG_KERNEL=y
 CONFIG_PANIC_ON_OOPS=y
 # CONFIG_SCHED_DEBUG is not set
 CONFIG_RCU_CPU_STALL_TIMEOUT=60
+# CONFIG_RCU_TRACE is not set
 # CONFIG_FTRACE is not set
 # CONFIG_RUNTIME_TESTING_MENU is not set
index 50b4ce8..918f0ba 100644 (file)
@@ -29,7 +29,7 @@
        typedef typeof(pcp) pcp_op_T__;                                 \
        pcp_op_T__ old__, new__, prev__;                                \
        pcp_op_T__ *ptr__;                                              \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                                    \
        prev__ = *ptr__;                                                \
        do {                                                            \
@@ -37,7 +37,7 @@
                new__ = old__ op (val);                                 \
                prev__ = cmpxchg(ptr__, old__, new__);                  \
        } while (prev__ != old__);                                      \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
        new__;                                                          \
 })
 
@@ -68,7 +68,7 @@
        typedef typeof(pcp) pcp_op_T__;                                 \
        pcp_op_T__ val__ = (val);                                       \
        pcp_op_T__ old__, *ptr__;                                       \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                            \
        if (__builtin_constant_p(val__) &&                              \
            ((szcast)val__ > -129) && ((szcast)val__ < 128)) {          \
@@ -84,7 +84,7 @@
                        : [val__] "d" (val__)                           \
                        : "cc");                                        \
        }                                                               \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
 }
 
 #define this_cpu_add_4(pcp, val) arch_this_cpu_add(pcp, val, "laa", "asi", int)
        typedef typeof(pcp) pcp_op_T__;                                 \
        pcp_op_T__ val__ = (val);                                       \
        pcp_op_T__ old__, *ptr__;                                       \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                                    \
        asm volatile(                                                   \
                op "    %[old__],%[val__],%[ptr__]\n"                   \
                : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__)           \
                : [val__] "d" (val__)                                   \
                : "cc");                                                \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                               \
        old__ + val__;                                                  \
 })
 
        typedef typeof(pcp) pcp_op_T__;                                 \
        pcp_op_T__ val__ = (val);                                       \
        pcp_op_T__ old__, *ptr__;                                       \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                                    \
        asm volatile(                                                   \
                op "    %[old__],%[val__],%[ptr__]\n"                   \
                : [old__] "=d" (old__), [ptr__] "+Q" (*ptr__)           \
                : [val__] "d" (val__)                                   \
                : "cc");                                                \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
 }
 
 #define this_cpu_and_4(pcp, val)       arch_this_cpu_to_op(pcp, val, "lan")
        typedef typeof(pcp) pcp_op_T__;                                 \
        pcp_op_T__ ret__;                                               \
        pcp_op_T__ *ptr__;                                              \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                                    \
        ret__ = cmpxchg(ptr__, oval, nval);                             \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
        ret__;                                                          \
 })
 
 ({                                                                     \
        typeof(pcp) *ptr__;                                             \
        typeof(pcp) ret__;                                              \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        ptr__ = raw_cpu_ptr(&(pcp));                                    \
        ret__ = xchg(ptr__, nval);                                      \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
        ret__;                                                          \
 })
 
        typeof(pcp1) *p1__;                                             \
        typeof(pcp2) *p2__;                                             \
        int ret__;                                                      \
-       preempt_disable();                                              \
+       preempt_disable_notrace();                                      \
        p1__ = raw_cpu_ptr(&(pcp1));                                    \
        p2__ = raw_cpu_ptr(&(pcp2));                                    \
        ret__ = __cmpxchg_double(p1__, p2__, o1__, o2__, n1__, n2__);   \
-       preempt_enable();                                               \
+       preempt_enable_notrace();                                       \
        ret__;                                                          \
 })
 
index 88bb42c..c73f506 100644 (file)
@@ -33,14 +33,13 @@ void enabled_wait(void)
                PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
        clear_cpu_flag(CIF_NOHZ_DELAY);
 
-       trace_cpu_idle_rcuidle(1, smp_processor_id());
        local_irq_save(flags);
        /* Call the assembler magic in entry.S */
        psw_idle(idle, psw_mask);
        local_irq_restore(flags);
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 
        /* Account time spent with enabled wait psw loaded as idle time. */
+       /* XXX seqcount has tracepoints that require RCU */
        write_seqcount_begin(&idle->seqcount);
        idle_time = idle->clock_idle_exit - idle->clock_idle_enter;
        idle->clock_idle_enter = idle->clock_idle_exit = 0ULL;
index 11d2f7d..a76dd27 100644 (file)
@@ -1268,7 +1268,6 @@ static bool is_ri_cb_valid(struct runtime_instr_cb *cb)
                cb->pc == 1 &&
                cb->qc == 0 &&
                cb->reserved2 == 0 &&
-               cb->key == PAGE_DEFAULT_KEY &&
                cb->reserved3 == 0 &&
                cb->reserved4 == 0 &&
                cb->reserved5 == 0 &&
@@ -1330,7 +1329,11 @@ static int s390_runtime_instr_set(struct task_struct *target,
                kfree(data);
                return -EINVAL;
        }
-
+       /*
+        * Override access key in any case, since user space should
+        * not be able to set it, nor should it care about it.
+        */
+       ri_cb.key = PAGE_DEFAULT_KEY >> 4;
        preempt_disable();
        if (!target->thread.ri_cb)
                target->thread.ri_cb = data;
index 125c7f6..1788a54 100644 (file)
@@ -57,7 +57,7 @@ static void init_runtime_instr_cb(struct runtime_instr_cb *cb)
        cb->k = 1;
        cb->ps = 1;
        cb->pc = 1;
-       cb->key = PAGE_DEFAULT_KEY;
+       cb->key = PAGE_DEFAULT_KEY >> 4;
        cb->v = 1;
 }
 
index 1aed1a4..eddf71c 100644 (file)
@@ -402,6 +402,7 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end,
                        pud = vmem_crst_alloc(_REGION3_ENTRY_EMPTY);
                        if (!pud)
                                goto out;
+                       p4d_populate(&init_mm, p4d, pud);
                }
                ret = modify_pud_table(p4d, addr, next, add, direct);
                if (ret)
index 3902c9f..4b62d6b 100644 (file)
@@ -672,6 +672,19 @@ int zpci_disable_device(struct zpci_dev *zdev)
 }
 EXPORT_SYMBOL_GPL(zpci_disable_device);
 
+void zpci_remove_device(struct zpci_dev *zdev)
+{
+       struct zpci_bus *zbus = zdev->zbus;
+       struct pci_dev *pdev;
+
+       pdev = pci_get_slot(zbus->bus, zdev->devfn);
+       if (pdev) {
+               if (pdev->is_virtfn)
+                       return zpci_remove_virtfn(pdev, zdev->vfn);
+               pci_stop_and_remove_bus_device_locked(pdev);
+       }
+}
+
 int zpci_create_device(struct zpci_dev *zdev)
 {
        int rc;
@@ -716,13 +729,8 @@ void zpci_release_device(struct kref *kref)
 {
        struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref);
 
-       if (zdev->zbus->bus) {
-               struct pci_dev *pdev;
-
-               pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
-               if (pdev)
-                       pci_stop_and_remove_bus_device_locked(pdev);
-       }
+       if (zdev->zbus->bus)
+               zpci_remove_device(zdev);
 
        switch (zdev->state) {
        case ZPCI_FN_STATE_ONLINE:
index 642a993..5967f30 100644 (file)
@@ -132,13 +132,14 @@ static int zpci_bus_link_virtfn(struct pci_dev *pdev,
 {
        int rc;
 
-       virtfn->physfn = pci_dev_get(pdev);
        rc = pci_iov_sysfs_link(pdev, virtfn, vfid);
-       if (rc) {
-               pci_dev_put(pdev);
-               virtfn->physfn = NULL;
+       if (rc)
                return rc;
-       }
+
+       virtfn->is_virtfn = 1;
+       virtfn->multifunction = 0;
+       virtfn->physfn = pci_dev_get(pdev);
+
        return 0;
 }
 
@@ -151,9 +152,9 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
        int vfid = vfn - 1; /* Linux' vfid's start at 0 vfn at 1*/
        int rc = 0;
 
-       virtfn->is_virtfn = 1;
-       virtfn->multifunction = 0;
-       WARN_ON(vfid < 0);
+       if (!zbus->multifunction)
+               return 0;
+
        /* If the parent PF for the given VF is also configured in the
         * instance, it must be on the same zbus.
         * We can then identify the parent PF by checking what
@@ -165,11 +166,17 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
                zdev = zbus->function[i];
                if (zdev && zdev->is_physfn) {
                        pdev = pci_get_slot(zbus->bus, zdev->devfn);
+                       if (!pdev)
+                               continue;
                        cand_devfn = pci_iov_virtfn_devfn(pdev, vfid);
                        if (cand_devfn == virtfn->devfn) {
                                rc = zpci_bus_link_virtfn(pdev, virtfn, vfid);
+                               /* balance pci_get_slot() */
+                               pci_dev_put(pdev);
                                break;
                        }
+                       /* balance pci_get_slot() */
+                       pci_dev_put(pdev);
                }
        }
        return rc;
@@ -178,12 +185,23 @@ static int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
 static inline int zpci_bus_setup_virtfn(struct zpci_bus *zbus,
                struct pci_dev *virtfn, int vfn)
 {
-       virtfn->is_virtfn = 1;
-       virtfn->multifunction = 0;
        return 0;
 }
 #endif
 
+void pcibios_bus_add_device(struct pci_dev *pdev)
+{
+       struct zpci_dev *zdev = to_zpci(pdev);
+
+       /*
+        * With pdev->no_vf_scan the common PCI probing code does not
+        * perform PF/VF linking.
+        */
+       if (zdev->vfn)
+               zpci_bus_setup_virtfn(zdev->zbus, pdev, zdev->vfn);
+
+}
+
 static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
 {
        struct pci_bus *bus;
@@ -214,20 +232,10 @@ static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
        }
 
        pdev = pci_scan_single_device(bus, zdev->devfn);
-       if (pdev) {
-               if (!zdev->is_physfn) {
-                       rc = zpci_bus_setup_virtfn(zbus, pdev, zdev->vfn);
-                       if (rc)
-                               goto failed_with_pdev;
-               }
+       if (pdev)
                pci_bus_add_device(pdev);
-       }
-       return 0;
 
-failed_with_pdev:
-       pci_stop_and_remove_bus_device(pdev);
-       pci_dev_put(pdev);
-       return rc;
+       return 0;
 }
 
 static void zpci_bus_add_devices(struct zpci_bus *zbus)
index 89be3c3..4972433 100644 (file)
@@ -29,3 +29,16 @@ static inline struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus,
 
        return (devfn >= ZPCI_FUNCTIONS_PER_BUS) ? NULL : zbus->function[devfn];
 }
+
+#ifdef CONFIG_PCI_IOV
+static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn)
+{
+
+       pci_lock_rescan_remove();
+       /* Linux' vfid's start at 0 vfn at 1 */
+       pci_iov_remove_virtfn(pdev->physfn, vfn - 1);
+       pci_unlock_rescan_remove();
+}
+#else /* CONFIG_PCI_IOV */
+static inline void zpci_remove_virtfn(struct pci_dev *pdev, int vfn) {}
+#endif /* CONFIG_PCI_IOV */
index fdebd28..9a3a291 100644 (file)
@@ -92,6 +92,9 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
                        ret = clp_add_pci_device(ccdf->fid, ccdf->fh, 1);
                        break;
                }
+               /* the configuration request may be stale */
+               if (zdev->state != ZPCI_FN_STATE_STANDBY)
+                       break;
                zdev->fh = ccdf->fh;
                zdev->state = ZPCI_FN_STATE_CONFIGURED;
                ret = zpci_enable_device(zdev);
@@ -118,7 +121,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
                if (!zdev)
                        break;
                if (pdev)
-                       pci_stop_and_remove_bus_device_locked(pdev);
+                       zpci_remove_device(zdev);
 
                ret = zpci_disable_device(zdev);
                if (ret)
@@ -137,7 +140,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)
                        /* Give the driver a hint that the function is
                         * already unusable. */
                        pdev->error_state = pci_channel_io_perm_failure;
-                       pci_stop_and_remove_bus_device_locked(pdev);
+                       zpci_remove_device(zdev);
                }
 
                zdev->state = ZPCI_FN_STATE_STANDBY;
index f3dc3f2..143747c 100644 (file)
@@ -246,7 +246,7 @@ static int __init sh_early_platform_driver_probe_id(char *class_str,
                case EARLY_PLATFORM_ID_ERROR:
                        pr_warn("%s: unable to parse %s parameter\n",
                                class_str, epdrv->pdrv->driver.name);
-                       /* fall-through */
+                       fallthrough;
                case EARLY_PLATFORM_ID_UNSET:
                        match = NULL;
                        break;
index 08e1af6..34e25a4 100644 (file)
@@ -486,7 +486,7 @@ static void print_sh_insn(u32 memaddr, u16 insn)
                                        pr_cont("xd%d", rn & ~1);
                                        break;
                                }
-                               /* else, fall through */
+                               fallthrough;
                        case D_REG_N:
                                pr_cont("dr%d", rn);
                                break;
@@ -495,7 +495,7 @@ static void print_sh_insn(u32 memaddr, u16 insn)
                                        pr_cont("xd%d", rm & ~1);
                                        break;
                                }
-                               /* else, fall through */
+                               fallthrough;
                        case D_REG_M:
                                pr_cont("dr%d", rm);
                                break;
index 0d5f3c9..e4147ef 100644 (file)
@@ -266,7 +266,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
                ptr = &remcomInBuffer[1];
                if (kgdb_hex2long(&ptr, &addr))
                        linux_regs->pc = addr;
-               /* fallthrough */
+               fallthrough;
        case 'D':
        case 'k':
                atomic_set(&kgdb_cpu_doing_single_step, -1);
index a0fbb84..4fe3f00 100644 (file)
@@ -418,7 +418,7 @@ handle_syscall_restart(unsigned long save_r0, struct pt_regs *regs,
                case -ERESTARTSYS:
                        if (!(sa->sa_flags & SA_RESTART))
                                goto no_system_call_restart;
-               /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->regs[0] = save_r0;
                        regs->pc -= instruction_size(__raw_readw(regs->pc - 4));
index 4843f48..774a82b 100644 (file)
@@ -87,7 +87,6 @@ void auxio_set_lte(int on)
                __auxio_sbus_set_lte(on);
                break;
        case AUXIO_TYPE_EBUS:
-               /* FALL-THROUGH */
        default:
                break;
        }
index bfae98a..23f8838 100644 (file)
@@ -55,7 +55,7 @@ static int clock_board_calc_nslots(struct clock_board *p)
                        else
                                return 5;
                }
-               /* Fallthrough */
+               fallthrough;
        default:
                return 4;
        }
index 7580775..58ad3f7 100644 (file)
@@ -122,7 +122,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
                        linux_regs->pc = addr;
                        linux_regs->npc = addr + 4;
                }
-               /* fall through */
+               fallthrough;
 
        case 'D':
        case 'k':
index 5d6c2d2..177746a 100644 (file)
@@ -148,7 +148,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
                        linux_regs->tpc = addr;
                        linux_regs->tnpc = addr + 4;
                }
-               /* fall through */
+               fallthrough;
 
        case 'D':
        case 'k':
index c0886b4..2a12c86 100644 (file)
@@ -359,7 +359,7 @@ int __init pcr_arch_init(void)
                 * counter overflow interrupt so we can't make use of
                 * their hardware currently.
                 */
-               /* fallthrough */
+               fallthrough;
        default:
                err = -ENODEV;
                goto out_unregister;
index da89022..3df960c 100644 (file)
@@ -224,7 +224,7 @@ void __init of_console_init(void)
 
                case PROMDEV_TTYB:
                        skip = 1;
-                       /* FALLTHRU */
+                       fallthrough;
 
                case PROMDEV_TTYA:
                        type = "serial";
index e2c6f0a..e9695a0 100644 (file)
@@ -646,7 +646,7 @@ static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs
        case ERESTARTSYS:
                if (!(sa->sa_flags & SA_RESTART))
                        goto no_system_call_restart;
-               /* fallthrough */
+               fallthrough;
        case ERESTARTNOINTR:
                regs->u_regs[UREG_I0] = orig_i0;
                regs->tpc -= 4;
@@ -686,7 +686,7 @@ void do_signal32(struct pt_regs * regs)
                                regs->tpc -= 4;
                                regs->tnpc -= 4;
                                pt_regs_clear_syscall(regs);
-                               /* fall through */
+                               fallthrough;
                        case ERESTART_RESTARTBLOCK:
                                regs->u_regs[UREG_G1] = __NR_restart_syscall;
                                regs->tpc -= 4;
index f1f8c8e..d0e0025 100644 (file)
@@ -440,7 +440,7 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
        case ERESTARTSYS:
                if (!(sa->sa_flags & SA_RESTART))
                        goto no_system_call_restart;
-               /* fallthrough */
+               fallthrough;
        case ERESTARTNOINTR:
                regs->u_regs[UREG_I0] = orig_i0;
                regs->pc -= 4;
@@ -506,7 +506,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
                                regs->pc -= 4;
                                regs->npc -= 4;
                                pt_regs_clear_syscall(regs);
-                               /* fall through */
+                               fallthrough;
                        case ERESTART_RESTARTBLOCK:
                                regs->u_regs[UREG_G1] = __NR_restart_syscall;
                                regs->pc -= 4;
index 6937339..255264b 100644 (file)
@@ -461,7 +461,7 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
        case ERESTARTSYS:
                if (!(sa->sa_flags & SA_RESTART))
                        goto no_system_call_restart;
-               /* fallthrough */
+               fallthrough;
        case ERESTARTNOINTR:
                regs->u_regs[UREG_I0] = orig_i0;
                regs->tpc -= 4;
@@ -532,7 +532,7 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
                                regs->tpc -= 4;
                                regs->tnpc -= 4;
                                pt_regs_clear_syscall(regs);
-                               /* fall through */
+                               fallthrough;
                        case ERESTART_RESTARTBLOCK:
                                regs->u_regs[UREG_G1] = __NR_restart_syscall;
                                regs->tpc -= 4;
index 72e560e..d5beec8 100644 (file)
@@ -359,7 +359,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
                        *pfsr |= (6 << 14);
                        return 0;                       /* simulate invalid_fp_register exception */
                }
-       /* fall through */
+               fallthrough;
        case 2:
                if (freg & 1) {                         /* doublewords must have bit 5 zeroed */
                        *pfsr |= (6 << 14);
@@ -380,7 +380,7 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
                        *pfsr |= (6 << 14);
                        return 0;                       /* simulate invalid_fp_register exception */
                }
-       /* fall through */
+               fallthrough;
        case 2:
                if (freg & 1) {                         /* doublewords must have bit 5 zeroed */
                        *pfsr |= (6 << 14);
@@ -408,13 +408,13 @@ static int do_one_mathemu(u32 insn, unsigned long *pfsr, unsigned long *fregs)
                        *pfsr |= (6 << 14);
                        return 0;                       /* simulate invalid_fp_register exception */
                }
-       /* fall through */
+               fallthrough;
        case 2:
                if (freg & 1) {                         /* doublewords must have bit 5 zeroed */
                        *pfsr |= (6 << 14);
                        return 0;
                }
-       /* fall through */
+               fallthrough;
        case 1:
                rd = (void *)&fregs[freg];
                break;
index c8eabb9..b1dbf2f 100644 (file)
@@ -491,7 +491,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
                                } else {
                                        emit_loadimm(K, r_A);
                                }
-                               /* Fallthrough */
+                               fallthrough;
                        case BPF_RET | BPF_A:
                                if (seen_or_pass0) {
                                        if (i != flen - 1) {
index 3d57c71..88cd9b5 100644 (file)
@@ -70,7 +70,7 @@ static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                PT_REGS_SYSCALL_RET(regs) = -EINTR;
                                break;
                        }
-               /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        PT_REGS_RESTART_SYSCALL(regs);
                        PT_REGS_ORIG_SYSCALL(regs) = PT_REGS_SYSCALL_NR(regs);
index 4ff0117..21d56ae 100644 (file)
@@ -54,7 +54,7 @@ int __cmdline_find_option(unsigned long cmdline_ptr, const char *option, char *b
                        /* else */
                        state = st_wordcmp;
                        opptr = option;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordcmp:
                        if (c == '=' && !*opptr) {
@@ -129,7 +129,7 @@ int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option)
                        state = st_wordcmp;
                        opptr = option;
                        wstart = pos;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordcmp:
                        if (!*opptr)
index 0048269..dde7cb3 100644 (file)
@@ -178,7 +178,7 @@ parse_memmap(char *p, unsigned long long *start, unsigned long long *size,
                        }
                        *size = 0;
                }
-               /* Fall through */
+               fallthrough;
        default:
                /*
                 * If w/o offset, only size specified, memmap=nn[KMG] has the
index 39e592d..e478e40 100644 (file)
 #define STATIC         static
 
 /*
- * Use normal definitions of mem*() from string.c. There are already
- * included header files which expect a definition of memset() and by
- * the time we define memset macro, it is too late.
+ * Provide definitions of memzero and memmove as some of the decompressors will
+ * try to define their own functions if these are not defined as macros.
  */
-#undef memcpy
-#undef memset
 #define memzero(s, n)  memset((s), 0, (n))
 #define memmove                memmove
 
index 995f7b7..a232da4 100644 (file)
@@ -11,10 +11,7 @@ void *memcpy(void *dst, const void *src, size_t len);
 void *memset(void *dst, int c, size_t len);
 int memcmp(const void *s1, const void *s2, size_t len);
 
-/*
- * Access builtin version by default. If one needs to use optimized version,
- * do "undef memcpy" in .c file and link against right string.c
- */
+/* Access builtin version by default. */
 #define memcpy(d,s,l) __builtin_memcpy(d,s,l)
 #define memset(d,c,l) __builtin_memset(d,c,l)
 #define memcmp __builtin_memcmp
index 98e4d88..ae9b0d4 100644 (file)
@@ -374,12 +374,14 @@ For 32-bit we have the following conventions - kernel is built with
  * Fetch the per-CPU GSBASE value for this processor and put it in @reg.
  * We normally use %gs for accessing per-CPU data, but we are setting up
  * %gs here and obviously can not use %gs itself to access per-CPU data.
+ *
+ * Do not use RDPID, because KVM loads guest's TSC_AUX on vm-entry and
+ * may not restore the host's value until the CPU returns to userspace.
+ * Thus the kernel would consume a guest's TSC_AUX if an NMI arrives
+ * while running KVM's run loop.
  */
 .macro GET_PERCPU_BASE reg:req
-       ALTERNATIVE \
-               "LOAD_CPU_AND_NODE_SEG_LIMIT \reg", \
-               "RDPID  \reg", \
-               X86_FEATURE_RDPID
+       LOAD_CPU_AND_NODE_SEG_LIMIT \reg
        andq    $VDSO_CPUNODE_MASK, \reg
        movq    __per_cpu_offset(, \reg, 8), \reg
 .endm
index 48512c7..2f84c7c 100644 (file)
@@ -60,16 +60,10 @@ __visible noinstr void do_syscall_64(unsigned long nr, struct pt_regs *regs)
 #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
 static __always_inline unsigned int syscall_32_enter(struct pt_regs *regs)
 {
-       unsigned int nr = (unsigned int)regs->orig_ax;
-
        if (IS_ENABLED(CONFIG_IA32_EMULATION))
                current_thread_info()->status |= TS_COMPAT;
-       /*
-        * Subtlety here: if ptrace pokes something larger than 2^32-1 into
-        * orig_ax, the unsigned int return value truncates it.  This may
-        * or may not be necessary, but it matches the old asm behavior.
-        */
-       return (unsigned int)syscall_enter_from_user_mode(regs, nr);
+
+       return (unsigned int)regs->orig_ax;
 }
 
 /*
@@ -91,15 +85,29 @@ __visible noinstr void do_int80_syscall_32(struct pt_regs *regs)
 {
        unsigned int nr = syscall_32_enter(regs);
 
+       /*
+        * Subtlety here: if ptrace pokes something larger than 2^32-1 into
+        * orig_ax, the unsigned int return value truncates it.  This may
+        * or may not be necessary, but it matches the old asm behavior.
+        */
+       nr = (unsigned int)syscall_enter_from_user_mode(regs, nr);
+
        do_syscall_32_irqs_on(regs, nr);
        syscall_exit_to_user_mode(regs);
 }
 
 static noinstr bool __do_fast_syscall_32(struct pt_regs *regs)
 {
-       unsigned int nr = syscall_32_enter(regs);
+       unsigned int nr = syscall_32_enter(regs);
        int res;
 
+       /*
+        * This cannot use syscall_enter_from_user_mode() as it has to
+        * fetch EBP before invoking any of the syscall entry work
+        * functions.
+        */
+       syscall_enter_from_user_mode_prepare(regs);
+
        instrumentation_begin();
        /* Fetch EBP from where the vDSO stashed it. */
        if (IS_ENABLED(CONFIG_X86_64)) {
@@ -122,6 +130,9 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs *regs)
                return false;
        }
 
+       /* The case truncates any ptrace induced syscall nr > 2^32 -1 */
+       nr = (unsigned int)syscall_enter_from_user_mode_work(regs, nr);
+
        /* Now this is just like a normal syscall. */
        do_syscall_32_irqs_on(regs, nr);
        syscall_exit_to_user_mode(regs);
index 3a07ce3..f1f96d4 100644 (file)
@@ -29,11 +29,6 @@ SYM_CODE_START_NOALIGN(\name)
 SYM_CODE_END(\name)
        .endm
 
-#ifdef CONFIG_TRACE_IRQFLAGS
-       THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
-       THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
-#endif
-
 #ifdef CONFIG_PREEMPTION
        THUNK preempt_schedule_thunk, preempt_schedule
        THUNK preempt_schedule_notrace_thunk, preempt_schedule_notrace
index 5096347..31e6887 100644 (file)
@@ -4682,7 +4682,7 @@ __init int intel_pmu_init(void)
 
        case INTEL_FAM6_CORE2_MEROM:
                x86_add_quirk(intel_clovertown_quirk);
-               /* fall through */
+               fallthrough;
 
        case INTEL_FAM6_CORE2_MEROM_L:
        case INTEL_FAM6_CORE2_PENRYN:
@@ -5062,7 +5062,7 @@ __init int intel_pmu_init(void)
 
        case INTEL_FAM6_SKYLAKE_X:
                pmem = true;
-               /* fall through */
+               fallthrough;
        case INTEL_FAM6_SKYLAKE_L:
        case INTEL_FAM6_SKYLAKE:
        case INTEL_FAM6_KABYLAKE_L:
@@ -5114,7 +5114,7 @@ __init int intel_pmu_init(void)
        case INTEL_FAM6_ICELAKE_X:
        case INTEL_FAM6_ICELAKE_D:
                pmem = true;
-               /* fall through */
+               fallthrough;
        case INTEL_FAM6_ICELAKE_L:
        case INTEL_FAM6_ICELAKE:
        case INTEL_FAM6_TIGERLAKE_L:
index 63f58bd..8961653 100644 (file)
@@ -1268,7 +1268,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort)
                        ret = X86_BR_ZERO_CALL;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case 0x9a: /* call far absolute */
                ret = X86_BR_CALL;
                break;
index cb94ba8..6a4ca27 100644 (file)
@@ -390,6 +390,18 @@ static struct uncore_event_desc snb_uncore_imc_events[] = {
        INTEL_UNCORE_EVENT_DESC(data_writes.scale, "6.103515625e-5"),
        INTEL_UNCORE_EVENT_DESC(data_writes.unit, "MiB"),
 
+       INTEL_UNCORE_EVENT_DESC(gt_requests, "event=0x03"),
+       INTEL_UNCORE_EVENT_DESC(gt_requests.scale, "6.103515625e-5"),
+       INTEL_UNCORE_EVENT_DESC(gt_requests.unit, "MiB"),
+
+       INTEL_UNCORE_EVENT_DESC(ia_requests, "event=0x04"),
+       INTEL_UNCORE_EVENT_DESC(ia_requests.scale, "6.103515625e-5"),
+       INTEL_UNCORE_EVENT_DESC(ia_requests.unit, "MiB"),
+
+       INTEL_UNCORE_EVENT_DESC(io_requests, "event=0x05"),
+       INTEL_UNCORE_EVENT_DESC(io_requests.scale, "6.103515625e-5"),
+       INTEL_UNCORE_EVENT_DESC(io_requests.unit, "MiB"),
+
        { /* end: all zeroes */ },
 };
 
@@ -405,13 +417,35 @@ static struct uncore_event_desc snb_uncore_imc_events[] = {
 #define SNB_UNCORE_PCI_IMC_DATA_WRITES_BASE    0x5054
 #define SNB_UNCORE_PCI_IMC_CTR_BASE            SNB_UNCORE_PCI_IMC_DATA_READS_BASE
 
+/* BW break down- legacy counters */
+#define SNB_UNCORE_PCI_IMC_GT_REQUESTS         0x3
+#define SNB_UNCORE_PCI_IMC_GT_REQUESTS_BASE    0x5040
+#define SNB_UNCORE_PCI_IMC_IA_REQUESTS         0x4
+#define SNB_UNCORE_PCI_IMC_IA_REQUESTS_BASE    0x5044
+#define SNB_UNCORE_PCI_IMC_IO_REQUESTS         0x5
+#define SNB_UNCORE_PCI_IMC_IO_REQUESTS_BASE    0x5048
+
 enum perf_snb_uncore_imc_freerunning_types {
-       SNB_PCI_UNCORE_IMC_DATA         = 0,
+       SNB_PCI_UNCORE_IMC_DATA_READS           = 0,
+       SNB_PCI_UNCORE_IMC_DATA_WRITES,
+       SNB_PCI_UNCORE_IMC_GT_REQUESTS,
+       SNB_PCI_UNCORE_IMC_IA_REQUESTS,
+       SNB_PCI_UNCORE_IMC_IO_REQUESTS,
+
        SNB_PCI_UNCORE_IMC_FREERUNNING_TYPE_MAX,
 };
 
 static struct freerunning_counters snb_uncore_imc_freerunning[] = {
-       [SNB_PCI_UNCORE_IMC_DATA]     = { SNB_UNCORE_PCI_IMC_DATA_READS_BASE, 0x4, 0x0, 2, 32 },
+       [SNB_PCI_UNCORE_IMC_DATA_READS]         = { SNB_UNCORE_PCI_IMC_DATA_READS_BASE,
+                                                       0x0, 0x0, 1, 32 },
+       [SNB_PCI_UNCORE_IMC_DATA_READS]         = { SNB_UNCORE_PCI_IMC_DATA_WRITES_BASE,
+                                                       0x0, 0x0, 1, 32 },
+       [SNB_PCI_UNCORE_IMC_GT_REQUESTS]        = { SNB_UNCORE_PCI_IMC_GT_REQUESTS_BASE,
+                                                       0x0, 0x0, 1, 32 },
+       [SNB_PCI_UNCORE_IMC_IA_REQUESTS]        = { SNB_UNCORE_PCI_IMC_IA_REQUESTS_BASE,
+                                                       0x0, 0x0, 1, 32 },
+       [SNB_PCI_UNCORE_IMC_IO_REQUESTS]        = { SNB_UNCORE_PCI_IMC_IO_REQUESTS_BASE,
+                                                       0x0, 0x0, 1, 32 },
 };
 
 static struct attribute *snb_uncore_imc_formats_attr[] = {
@@ -525,6 +559,18 @@ static int snb_uncore_imc_event_init(struct perf_event *event)
                base = SNB_UNCORE_PCI_IMC_DATA_WRITES_BASE;
                idx = UNCORE_PMC_IDX_FREERUNNING;
                break;
+       case SNB_UNCORE_PCI_IMC_GT_REQUESTS:
+               base = SNB_UNCORE_PCI_IMC_GT_REQUESTS_BASE;
+               idx = UNCORE_PMC_IDX_FREERUNNING;
+               break;
+       case SNB_UNCORE_PCI_IMC_IA_REQUESTS:
+               base = SNB_UNCORE_PCI_IMC_IA_REQUESTS_BASE;
+               idx = UNCORE_PMC_IDX_FREERUNNING;
+               break;
+       case SNB_UNCORE_PCI_IMC_IO_REQUESTS:
+               base = SNB_UNCORE_PCI_IMC_IO_REQUESTS_BASE;
+               idx = UNCORE_PMC_IDX_FREERUNNING;
+               break;
        default:
                return -EINVAL;
        }
@@ -598,7 +644,7 @@ static struct intel_uncore_ops snb_uncore_imc_ops = {
 
 static struct intel_uncore_type snb_uncore_imc = {
        .name           = "imc",
-       .num_counters   = 2,
+       .num_counters   = 5,
        .num_boxes      = 1,
        .num_freerunning_types  = SNB_PCI_UNCORE_IMC_FREERUNNING_TYPE_MAX,
        .mmio_map_size  = SNB_UNCORE_PCI_IMC_MAP_SIZE,
index b9c2667..bc9758e 100644 (file)
@@ -81,11 +81,8 @@ extern unsigned long efi_fw_vendor, efi_config_table;
        kernel_fpu_end();                                               \
 })
 
-
 #define arch_efi_call_virt(p, f, args...)      p->f(args)
 
-#define efi_ioremap(addr, size, type, attr)    ioremap_cache(addr, size)
-
 #else /* !CONFIG_X86_32 */
 
 #define EFI_LOADER_SIGNATURE   "EL64"
@@ -125,9 +122,6 @@ struct efi_scratch {
        kernel_fpu_end();                                               \
 })
 
-extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
-                                       u32 type, u64 attribute);
-
 #ifdef CONFIG_KASAN
 /*
  * CONFIG_KASAN may redefine memset to __memset.  __memset function is present
@@ -143,17 +137,13 @@ extern void __iomem *__init efi_ioremap(unsigned long addr, unsigned long size,
 #endif /* CONFIG_X86_32 */
 
 extern struct efi_scratch efi_scratch;
-extern void __init efi_set_executable(efi_memory_desc_t *md, bool executable);
 extern int __init efi_memblock_x86_reserve_range(void);
 extern void __init efi_print_memmap(void);
-extern void __init efi_memory_uc(u64 addr, unsigned long size);
 extern void __init efi_map_region(efi_memory_desc_t *md);
 extern void __init efi_map_region_fixed(efi_memory_desc_t *md);
 extern void efi_sync_low_kernel_mappings(void);
 extern int __init efi_alloc_page_tables(void);
 extern int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages);
-extern void __init old_map_region(efi_memory_desc_t *md);
-extern void __init runtime_code_page_mkexec(void);
 extern void __init efi_runtime_update_mappings(void);
 extern void __init efi_dump_pagetable(void);
 extern void __init efi_apply_memmap_quirks(void);
index a8f9315..6fe54b2 100644 (file)
@@ -18,8 +18,16 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
                 * state, not the interrupt state as imagined by Xen.
                 */
                unsigned long flags = native_save_fl();
-               WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
-                                     X86_EFLAGS_NT));
+               unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
+
+               /*
+                * For !SMAP hardware we patch out CLAC on entry.
+                */
+               if (boot_cpu_has(X86_FEATURE_SMAP) ||
+                   (IS_ENABLED(CONFIG_64_BIT) && boot_cpu_has(X86_FEATURE_XENPV)))
+                       mask |= X86_EFLAGS_AC;
+
+               WARN_ON_ONCE(flags & mask);
 
                /* We think we came from user mode. Make sure pt_regs agrees. */
                WARN_ON_ONCE(!user_mode(regs));
index 5ab3af7..5303dbc 100644 (file)
@@ -1596,7 +1596,8 @@ asmlinkage void kvm_spurious_fault(void);
        _ASM_EXTABLE(666b, 667b)
 
 #define KVM_ARCH_WANT_MMU_NOTIFIER
-int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end);
+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
+                       unsigned flags);
 int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
 int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
 int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
index 0a301ad..9257667 100644 (file)
@@ -59,5 +59,6 @@ typedef struct {
        }
 
 void leave_mm(int cpu);
+#define leave_mm leave_mm
 
 #endif /* _ASM_X86_MMU_H */
index 40aa69d..d8324a2 100644 (file)
@@ -327,8 +327,8 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,
        static const unsigned int argument_offs[] = {
 #ifdef __i386__
                offsetof(struct pt_regs, ax),
-               offsetof(struct pt_regs, cx),
                offsetof(struct pt_regs, dx),
+               offsetof(struct pt_regs, cx),
 #define NR_REG_ARGUMENTS 3
 #else
                offsetof(struct pt_regs, di),
index c3daf0a..cdaab30 100644 (file)
@@ -239,7 +239,7 @@ void __init arch_init_ideal_nops(void)
                        return;
                }
 
-               /* fall through */
+               fallthrough;
 
        default:
 #ifdef CONFIG_X86_64
index 21325a4..779a89e 100644 (file)
@@ -800,7 +800,7 @@ static int irq_polarity(int idx)
                return IOAPIC_POL_HIGH;
        case MP_IRQPOL_RESERVED:
                pr_warn("IOAPIC: Invalid polarity: 2, defaulting to low\n");
-               /* fall through */
+               fallthrough;
        case MP_IRQPOL_ACTIVE_LOW:
        default: /* Pointless default required due to do gcc stupidity */
                return IOAPIC_POL_LOW;
@@ -848,7 +848,7 @@ static int irq_trigger(int idx)
                return IOAPIC_EDGE;
        case MP_IRQTRIG_RESERVED:
                pr_warn("IOAPIC: Invalid trigger mode 2 defaulting to level\n");
-               /* fall through */
+               fallthrough;
        case MP_IRQTRIG_LEVEL:
        default: /* Pointless default required due to do gcc stupidity */
                return IOAPIC_LEVEL;
index 7bda71d..99ee61c 100644 (file)
@@ -149,7 +149,7 @@ void __init default_setup_apic_routing(void)
                                break;
                        }
                        /* P4 and above */
-                       /* fall through */
+                       fallthrough;
                case X86_VENDOR_HYGON:
                case X86_VENDOR_AMD:
                        def_to_bigsmp = 1;
index dae32d9..f8a56b5 100644 (file)
@@ -161,6 +161,7 @@ static void apic_update_vector(struct irq_data *irqd, unsigned int newvec,
                apicd->move_in_progress = true;
                apicd->prev_vector = apicd->vector;
                apicd->prev_cpu = apicd->cpu;
+               WARN_ON_ONCE(apicd->cpu == newcpu);
        } else {
                irq_matrix_free(vector_matrix, apicd->cpu, apicd->vector,
                                managed);
@@ -910,7 +911,7 @@ void send_cleanup_vector(struct irq_cfg *cfg)
                __send_cleanup_vector(apicd);
 }
 
-static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
+void irq_complete_move(struct irq_cfg *cfg)
 {
        struct apic_chip_data *apicd;
 
@@ -918,15 +919,16 @@ static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector)
        if (likely(!apicd->move_in_progress))
                return;
 
-       if (vector == apicd->vector && apicd->cpu == smp_processor_id())
+       /*
+        * If the interrupt arrived on the new target CPU, cleanup the
+        * vector on the old target CPU. A vector check is not required
+        * because an interrupt can never move from one vector to another
+        * on the same CPU.
+        */
+       if (apicd->cpu == smp_processor_id())
                __send_cleanup_vector(apicd);
 }
 
-void irq_complete_move(struct irq_cfg *cfg)
-{
-       __irq_complete_move(cfg, ~get_irq_regs()->orig_ax);
-}
-
 /*
  * Called from fixup_irqs() with @desc->lock held and interrupts disabled.
  */
index c7503be..57074cf 100644 (file)
@@ -248,7 +248,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
        switch (leaf) {
        case 1:
                l1 = &l1i;
-               /* fall through */
+               fallthrough;
        case 0:
                if (!l1->val)
                        return;
index 7843ab3..3a44346 100644 (file)
@@ -199,7 +199,7 @@ static int raise_local(void)
                         * calling irq_enter, but the necessary
                         * machinery isn't exported currently.
                         */
-                       /*FALL THROUGH*/
+                       fallthrough;
                case MCJ_CTX_PROCESS:
                        raise_exception(m, NULL);
                        break;
index d8f9230..abe9fe0 100644 (file)
@@ -193,7 +193,7 @@ unsigned long cmci_intel_adjust_timer(unsigned long interval)
                if (!atomic_sub_return(1, &cmci_storm_on_cpus))
                        pr_notice("CMCI storm subsided: switching to interrupt mode\n");
 
-               /* FALLTHROUGH */
+               fallthrough;
 
        case CMCI_STORM_SUBSIDED:
                /*
index 7218280..ca67091 100644 (file)
@@ -98,7 +98,7 @@ cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg)
        case 7:
                if (size < 0x40)
                        break;
-               /* Else, fall through */
+               fallthrough;
        case 6:
        case 5:
        case 4:
index 8cdf29f..b98ff62 100644 (file)
@@ -349,7 +349,7 @@ static int arch_build_bp_info(struct perf_event *bp,
                        hw->len = X86_BREAKPOINT_LEN_X;
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        default:
                return -EINVAL;
        }
index 68acd30..c2f02f3 100644 (file)
@@ -450,7 +450,7 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
                ptr = &remcomInBuffer[1];
                if (kgdb_hex2long(&ptr, &addr))
                        linux_regs->ip = addr;
-               /* fall through */
+               fallthrough;
        case 'D':
        case 'k':
                /* clear the trace bit */
@@ -539,7 +539,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
                         * a system call which should be ignored
                         */
                        return NOTIFY_DONE;
-               /* fall through */
+               fallthrough;
        default:
                if (user_mode(regs))
                        return NOTIFY_DONE;
index 08320b0..1b51b72 100644 (file)
@@ -270,9 +270,8 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_asyncpf_interrupt)
 {
        struct pt_regs *old_regs = set_irq_regs(regs);
        u32 token;
-       irqentry_state_t state;
 
-       state = irqentry_enter(regs);
+       ack_APIC_irq();
 
        inc_irq_stat(irq_hv_callback_count);
 
@@ -283,7 +282,6 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_asyncpf_interrupt)
                wrmsrl(MSR_KVM_ASYNC_PF_ACK, 1);
        }
 
-       irqentry_exit(regs, state);
        set_irq_regs(old_regs);
 }
 
@@ -654,7 +652,6 @@ static void __init kvm_guest_init(void)
        }
 
        if (pv_tlb_flush_supported()) {
-               pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
                pv_ops.mmu.tlb_remove_table = tlb_remove_table;
                pr_info("KVM setup pv remote TLB flush\n");
        }
@@ -767,6 +764,14 @@ static __init int activate_jump_labels(void)
 }
 arch_initcall(activate_jump_labels);
 
+static void kvm_free_pv_cpu_mask(void)
+{
+       unsigned int cpu;
+
+       for_each_possible_cpu(cpu)
+               free_cpumask_var(per_cpu(__pv_cpu_mask, cpu));
+}
+
 static __init int kvm_alloc_cpumask(void)
 {
        int cpu;
@@ -785,11 +790,20 @@ static __init int kvm_alloc_cpumask(void)
 
        if (alloc)
                for_each_possible_cpu(cpu) {
-                       zalloc_cpumask_var_node(per_cpu_ptr(&__pv_cpu_mask, cpu),
-                               GFP_KERNEL, cpu_to_node(cpu));
+                       if (!zalloc_cpumask_var_node(
+                               per_cpu_ptr(&__pv_cpu_mask, cpu),
+                               GFP_KERNEL, cpu_to_node(cpu))) {
+                               goto zalloc_cpumask_fail;
+                       }
                }
 
+       apic->send_IPI_mask_allbutself = kvm_send_ipi_mask_allbutself;
+       pv_ops.mmu.flush_tlb_others = kvm_flush_tlb_others;
        return 0;
+
+zalloc_cpumask_fail:
+       kvm_free_pv_cpu_mask();
+       return -ENOMEM;
 }
 arch_initcall(kvm_alloc_cpumask);
 
index 411af4a..baa2109 100644 (file)
@@ -312,7 +312,7 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
                case 2:
                        if (i == 0 || i == 13)
                                continue;       /* IRQ0 & IRQ13 not connected */
-                       /* fall through */
+                       fallthrough;
                default:
                        if (i == 2)
                                continue;       /* IRQ2 is never connected */
@@ -356,7 +356,7 @@ static void __init construct_ioapic_table(int mpc_default_type)
        default:
                pr_err("???\nUnknown standard configuration %d\n",
                       mpc_default_type);
-               /* fall through */
+               fallthrough;
        case 1:
        case 5:
                memcpy(bus.bustype, "ISA   ", 6);
index 994d839..13ce616 100644 (file)
@@ -684,9 +684,7 @@ void arch_cpu_idle(void)
  */
 void __cpuidle default_idle(void)
 {
-       trace_cpu_idle_rcuidle(1, smp_processor_id());
        safe_halt();
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
 }
 #if defined(CONFIG_APM_MODULE) || defined(CONFIG_HALTPOLL_CPUIDLE_MODULE)
 EXPORT_SYMBOL(default_idle);
@@ -792,7 +790,6 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
 static __cpuidle void mwait_idle(void)
 {
        if (!current_set_polling_and_test()) {
-               trace_cpu_idle_rcuidle(1, smp_processor_id());
                if (this_cpu_has(X86_BUG_CLFLUSH_MONITOR)) {
                        mb(); /* quirk */
                        clflush((void *)&current_thread_info()->flags);
@@ -804,7 +801,6 @@ static __cpuidle void mwait_idle(void)
                        __sti_mwait(0, 0);
                else
                        local_irq_enable();
-               trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
        } else {
                local_irq_enable();
        }
index 5679aa3..e7537c5 100644 (file)
@@ -204,7 +204,7 @@ static int set_segment_reg(struct task_struct *task,
        case offsetof(struct user_regs_struct, ss):
                if (unlikely(value == 0))
                        return -EIO;
-               /* Else, fall through */
+               fallthrough;
 
        default:
                *pt_regs_access(task_pt_regs(task), offset) = value;
index 0ec7ced..a515e2d 100644 (file)
@@ -654,7 +654,7 @@ static void native_machine_emergency_restart(void)
 
                case BOOT_CF9_FORCE:
                        port_cf9_safe = true;
-                       /* Fall through */
+                       fallthrough;
 
                case BOOT_CF9_SAFE:
                        if (port_cf9_safe) {
index d5fa494..be0d7d4 100644 (file)
@@ -726,7 +726,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
                                regs->ax = -EINTR;
                                break;
                        }
-               /* fallthrough */
+                       fallthrough;
                case -ERESTARTNOINTR:
                        regs->ax = regs->orig_ax;
                        regs->ip -= 2;
index 27aa04a..f5ef689 100644 (file)
@@ -1594,14 +1594,28 @@ int native_cpu_disable(void)
        if (ret)
                return ret;
 
-       /*
-        * Disable the local APIC. Otherwise IPI broadcasts will reach
-        * it. It still responds normally to INIT, NMI, SMI, and SIPI
-        * messages.
-        */
-       apic_soft_disable();
        cpu_disable_common();
 
+        /*
+         * Disable the local APIC. Otherwise IPI broadcasts will reach
+         * it. It still responds normally to INIT, NMI, SMI, and SIPI
+         * messages.
+         *
+         * Disabling the APIC must happen after cpu_disable_common()
+         * which invokes fixup_irqs().
+         *
+         * Disabling the APIC preserves already set bits in IRR, but
+         * an interrupt arriving after disabling the local APIC does not
+         * set the corresponding IRR bit.
+         *
+         * fixup_irqs() scans IRR for set bits so it can raise a not
+         * yet handled interrupt on the new destination CPU via an IPI
+         * but obviously it can't do so for IRR bits which are not set.
+         * IOW, interrupts arriving after disabling the local APIC will
+         * be lost.
+         */
+       apic_soft_disable();
+
        return 0;
 }
 
index 1f66d2d..81a2fb7 100644 (file)
@@ -729,20 +729,9 @@ static bool is_sysenter_singlestep(struct pt_regs *regs)
 #endif
 }
 
-static __always_inline void debug_enter(unsigned long *dr6, unsigned long *dr7)
+static __always_inline unsigned long debug_read_clear_dr6(void)
 {
-       /*
-        * Disable breakpoints during exception handling; recursive exceptions
-        * are exceedingly 'fun'.
-        *
-        * Since this function is NOKPROBE, and that also applies to
-        * HW_BREAKPOINT_X, we can't hit a breakpoint before this (XXX except a
-        * HW_BREAKPOINT_W on our stack)
-        *
-        * Entry text is excluded for HW_BP_X and cpu_entry_area, which
-        * includes the entry stack is excluded for everything.
-        */
-       *dr7 = local_db_save();
+       unsigned long dr6;
 
        /*
         * The Intel SDM says:
@@ -755,15 +744,12 @@ static __always_inline void debug_enter(unsigned long *dr6, unsigned long *dr7)
         *
         * Keep it simple: clear DR6 immediately.
         */
-       get_debugreg(*dr6, 6);
+       get_debugreg(dr6, 6);
        set_debugreg(0, 6);
        /* Filter out all the reserved bits which are preset to 1 */
-       *dr6 &= ~DR6_RESERVED;
-}
+       dr6 &= ~DR6_RESERVED;
 
-static __always_inline void debug_exit(unsigned long dr7)
-{
-       local_db_restore(dr7);
+       return dr6;
 }
 
 /*
@@ -863,6 +849,18 @@ out:
 static __always_inline void exc_debug_kernel(struct pt_regs *regs,
                                             unsigned long dr6)
 {
+       /*
+        * Disable breakpoints during exception handling; recursive exceptions
+        * are exceedingly 'fun'.
+        *
+        * Since this function is NOKPROBE, and that also applies to
+        * HW_BREAKPOINT_X, we can't hit a breakpoint before this (XXX except a
+        * HW_BREAKPOINT_W on our stack)
+        *
+        * Entry text is excluded for HW_BP_X and cpu_entry_area, which
+        * includes the entry stack is excluded for everything.
+        */
+       unsigned long dr7 = local_db_save();
        bool irq_state = idtentry_enter_nmi(regs);
        instrumentation_begin();
 
@@ -883,6 +881,8 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
 
        instrumentation_end();
        idtentry_exit_nmi(regs, irq_state);
+
+       local_db_restore(dr7);
 }
 
 static __always_inline void exc_debug_user(struct pt_regs *regs,
@@ -894,6 +894,15 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
         */
        WARN_ON_ONCE(!user_mode(regs));
 
+       /*
+        * NB: We can't easily clear DR7 here because
+        * idtentry_exit_to_usermode() can invoke ptrace, schedule, access
+        * user memory, etc.  This means that a recursive #DB is possible.  If
+        * this happens, that #DB will hit exc_debug_kernel() and clear DR7.
+        * Since we're not on the IST stack right now, everything will be
+        * fine.
+        */
+
        irqentry_enter_from_user_mode(regs);
        instrumentation_begin();
 
@@ -907,36 +916,24 @@ static __always_inline void exc_debug_user(struct pt_regs *regs,
 /* IST stack entry */
 DEFINE_IDTENTRY_DEBUG(exc_debug)
 {
-       unsigned long dr6, dr7;
-
-       debug_enter(&dr6, &dr7);
-       exc_debug_kernel(regs, dr6);
-       debug_exit(dr7);
+       exc_debug_kernel(regs, debug_read_clear_dr6());
 }
 
 /* User entry, runs on regular task stack */
 DEFINE_IDTENTRY_DEBUG_USER(exc_debug)
 {
-       unsigned long dr6, dr7;
-
-       debug_enter(&dr6, &dr7);
-       exc_debug_user(regs, dr6);
-       debug_exit(dr7);
+       exc_debug_user(regs, debug_read_clear_dr6());
 }
 #else
 /* 32 bit does not have separate entry points. */
 DEFINE_IDTENTRY_RAW(exc_debug)
 {
-       unsigned long dr6, dr7;
-
-       debug_enter(&dr6, &dr7);
+       unsigned long dr6 = debug_read_clear_dr6();
 
        if (user_mode(regs))
                exc_debug_user(regs, dr6);
        else
                exc_debug_kernel(regs, dr6);
-
-       debug_exit(dr7);
 }
 #endif
 
index 15e5aad..3fdaa04 100644 (file)
@@ -735,7 +735,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
                 * OPCODE1() of the "short" jmp which checks the same condition.
                 */
                opc1 = OPCODE2(insn) - 0x10;
-               /* fall through */
+               fallthrough;
        default:
                if (!is_cond_jmp_opcode(opc1))
                        return -ENOSYS;
@@ -892,7 +892,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
                        fix_ip_or_call = 0;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                riprel_analyze(auprobe, &insn);
        }
index d0e2825..2f6510d 100644 (file)
@@ -2505,9 +2505,14 @@ static int rsm_load_state_32(struct x86_emulate_ctxt *ctxt,
                *reg_write(ctxt, i) = GET_SMSTATE(u32, smstate, 0x7fd0 + i * 4);
 
        val = GET_SMSTATE(u32, smstate, 0x7fcc);
-       ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1);
+
+       if (ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1))
+               return X86EMUL_UNHANDLEABLE;
+
        val = GET_SMSTATE(u32, smstate, 0x7fc8);
-       ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1);
+
+       if (ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1))
+               return X86EMUL_UNHANDLEABLE;
 
        selector =                 GET_SMSTATE(u32, smstate, 0x7fc4);
        set_desc_base(&desc,       GET_SMSTATE(u32, smstate, 0x7f64));
@@ -2560,16 +2565,23 @@ static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt,
        ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7f70) | X86_EFLAGS_FIXED;
 
        val = GET_SMSTATE(u32, smstate, 0x7f68);
-       ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1);
+
+       if (ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1))
+               return X86EMUL_UNHANDLEABLE;
+
        val = GET_SMSTATE(u32, smstate, 0x7f60);
-       ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1);
+
+       if (ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1))
+               return X86EMUL_UNHANDLEABLE;
 
        cr0 =                       GET_SMSTATE(u64, smstate, 0x7f58);
        cr3 =                       GET_SMSTATE(u64, smstate, 0x7f50);
        cr4 =                       GET_SMSTATE(u64, smstate, 0x7f48);
        ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7f00));
        val =                       GET_SMSTATE(u64, smstate, 0x7ed0);
-       ctxt->ops->set_msr(ctxt, MSR_EFER, val & ~EFER_LMA);
+
+       if (ctxt->ops->set_msr(ctxt, MSR_EFER, val & ~EFER_LMA))
+               return X86EMUL_UNHANDLEABLE;
 
        selector =                  GET_SMSTATE(u32, smstate, 0x7e90);
        rsm_set_desc_flags(&desc,   GET_SMSTATE(u32, smstate, 0x7e92) << 8);
@@ -3016,7 +3028,7 @@ static void string_registers_quirk(struct x86_emulate_ctxt *ctxt)
        case 0xa4:      /* movsb */
        case 0xa5:      /* movsd/w */
                *reg_rmw(ctxt, VCPU_REGS_RSI) &= (u32)-1;
-               /* fall through */
+               fallthrough;
        case 0xaa:      /* stosb */
        case 0xab:      /* stosd/w */
                *reg_rmw(ctxt, VCPU_REGS_RDI) &= (u32)-1;
index 814d3ae..1d33056 100644 (file)
@@ -1779,7 +1779,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
                ret = kvm_hvcall_signal_event(vcpu, fast, ingpa);
                if (ret != HV_STATUS_INVALID_PORT_ID)
                        break;
-               /* fall through - maybe userspace knows this conn_id. */
+               fallthrough;    /* maybe userspace knows this conn_id */
        case HVCALL_POST_MESSAGE:
                /* don't bother userspace if it has no way to handle it */
                if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) {
index c47d2ac..4aa1c2e 100644 (file)
@@ -285,7 +285,7 @@ int kvm_set_routing_entry(struct kvm *kvm,
                switch (ue->u.irqchip.irqchip) {
                case KVM_IRQCHIP_PIC_SLAVE:
                        e->irqchip.pin += PIC_NUM_PINS / 2;
-                       /* fall through */
+                       fallthrough;
                case KVM_IRQCHIP_PIC_MASTER:
                        if (ue->u.irqchip.pin >= PIC_NUM_PINS / 2)
                                return -EINVAL;
index 5ccbee7..35cca2e 100644 (file)
@@ -1053,7 +1053,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
        switch (delivery_mode) {
        case APIC_DM_LOWEST:
                vcpu->arch.apic_arb_prio++;
-               /* fall through */
+               fallthrough;
        case APIC_DM_FIXED:
                if (unlikely(trig_mode && !level))
                        break;
@@ -1341,7 +1341,7 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
                break;
        case APIC_TASKPRI:
                report_tpr_access(apic, false);
-               /* fall thru */
+               fallthrough;
        default:
                val = kvm_lapic_get_reg(apic, offset);
                break;
@@ -2027,7 +2027,7 @@ int kvm_lapic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val)
 
        case APIC_LVT0:
                apic_manage_nmi_watchdog(apic, val);
-               /* fall through */
+               fallthrough;
        case APIC_LVTTHMR:
        case APIC_LVTPC:
        case APIC_LVT1:
index 4e03841..71aa3da 100644 (file)
@@ -1916,7 +1916,8 @@ static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
        return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler);
 }
 
-int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end)
+int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
+                       unsigned flags)
 {
        return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp);
 }
@@ -2468,7 +2469,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
                }
 
                if (sp->unsync_children)
-                       kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu);
+                       kvm_make_request(KVM_REQ_MMU_SYNC, vcpu);
 
                __clear_sp_write_flooding_count(sp);
 
@@ -4421,7 +4422,7 @@ __reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
                        rsvd_bits(maxphyaddr, 51);
                rsvd_check->rsvd_bits_mask[1][4] =
                        rsvd_check->rsvd_bits_mask[0][4];
-               /* fall through */
+               fallthrough;
        case PT64_ROOT_4LEVEL:
                rsvd_check->rsvd_bits_mask[0][3] = exb_bit_rsvd |
                        nonleaf_bit8_rsvd | rsvd_bits(7, 7) |
index fb68467..e90bc43 100644 (file)
@@ -586,7 +586,6 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
        svm->vcpu.arch.mp_state = KVM_MP_STATE_RUNNABLE;
 
        /* Give the current vmcb to the guest */
-       svm_set_gif(svm, false);
 
        nested_vmcb->save.es     = vmcb->save.es;
        nested_vmcb->save.cs     = vmcb->save.cs;
@@ -632,6 +631,9 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
        /* Restore the original control entries */
        copy_vmcb_control_area(&vmcb->control, &hsave->control);
 
+       /* On vmexit the  GIF is set to false */
+       svm_set_gif(svm, false);
+
        svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset =
                svm->vcpu.arch.l1_tsc_offset;
 
@@ -1132,6 +1134,9 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
        load_nested_vmcb_control(svm, &ctl);
        nested_prepare_vmcb_control(svm);
 
+       if (!nested_svm_vmrun_msrpm(svm))
+               return -EINVAL;
+
 out_set_gif:
        svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET));
        return 0;
index 402dc42..7bf7bf7 100644 (file)
@@ -1106,6 +1106,7 @@ void sev_vm_destroy(struct kvm *kvm)
                list_for_each_safe(pos, q, head) {
                        __unregister_enc_region_locked(kvm,
                                list_entry(pos, struct enc_region, list));
+                       cond_resched();
                }
        }
 
index 03dd7ba..c44f3e9 100644 (file)
@@ -2668,7 +2668,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
        case MSR_IA32_APICBASE:
                if (kvm_vcpu_apicv_active(vcpu))
                        avic_update_vapic_bar(to_svm(vcpu), data);
-               /* Fall through */
+               fallthrough;
        default:
                return kvm_set_msr_common(vcpu, msr);
        }
@@ -2938,8 +2938,6 @@ static int handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
        if (npt_enabled)
                vcpu->arch.cr3 = svm->vmcb->save.cr3;
 
-       svm_complete_interrupts(svm);
-
        if (is_guest_mode(vcpu)) {
                int vmexit;
 
@@ -3504,7 +3502,6 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
        stgi();
 
        /* Any pending NMI will happen here */
-       exit_fastpath = svm_exit_handlers_fastpath(vcpu);
 
        if (unlikely(svm->vmcb->control.exit_code == SVM_EXIT_NMI))
                kvm_after_interrupt(&svm->vcpu);
@@ -3518,6 +3515,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
        }
 
        svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
+       vmcb_mark_all_clean(svm->vmcb);
 
        /* if exit due to PF check for async PF */
        if (svm->vmcb->control.exit_code == SVM_EXIT_EXCP_BASE + PF_VECTOR)
@@ -3537,7 +3535,8 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu)
                     SVM_EXIT_EXCP_BASE + MC_VECTOR))
                svm_handle_mce(svm);
 
-       vmcb_mark_all_clean(svm->vmcb);
+       svm_complete_interrupts(svm);
+       exit_fastpath = svm_exit_handlers_fastpath(vcpu);
        return exit_fastpath;
 }
 
@@ -3900,21 +3899,28 @@ static int svm_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
 static int svm_pre_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
 {
        struct vcpu_svm *svm = to_svm(vcpu);
-       struct vmcb *nested_vmcb;
        struct kvm_host_map map;
-       u64 guest;
-       u64 vmcb;
        int ret = 0;
 
-       guest = GET_SMSTATE(u64, smstate, 0x7ed8);
-       vmcb = GET_SMSTATE(u64, smstate, 0x7ee0);
+       if (guest_cpuid_has(vcpu, X86_FEATURE_LM)) {
+               u64 saved_efer = GET_SMSTATE(u64, smstate, 0x7ed0);
+               u64 guest = GET_SMSTATE(u64, smstate, 0x7ed8);
+               u64 vmcb = GET_SMSTATE(u64, smstate, 0x7ee0);
 
-       if (guest) {
-               if (kvm_vcpu_map(&svm->vcpu, gpa_to_gfn(vmcb), &map) == -EINVAL)
-                       return 1;
-               nested_vmcb = map.hva;
-               ret = enter_svm_guest_mode(svm, vmcb, nested_vmcb);
-               kvm_vcpu_unmap(&svm->vcpu, &map, true);
+               if (guest) {
+                       if (!guest_cpuid_has(vcpu, X86_FEATURE_SVM))
+                               return 1;
+
+                       if (!(saved_efer & EFER_SVME))
+                               return 1;
+
+                       if (kvm_vcpu_map(&svm->vcpu,
+                                        gpa_to_gfn(vmcb), &map) == -EINVAL)
+                               return 1;
+
+                       ret = enter_svm_guest_mode(svm, vmcb, map.hva);
+                       kvm_vcpu_unmap(&svm->vcpu, &map, true);
+               }
        }
 
        return ret;
index 23b58c2..1bb6b31 100644 (file)
@@ -4404,6 +4404,14 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 vm_exit_reason,
        if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu))
                kvm_vcpu_flush_tlb_current(vcpu);
 
+       /*
+        * VCPU_EXREG_PDPTR will be clobbered in arch/x86/kvm/vmx/vmx.h between
+        * now and the new vmentry.  Ensure that the VMCS02 PDPTR fields are
+        * up-to-date before switching to L1.
+        */
+       if (enable_ept && is_pae_paging(vcpu))
+               vmx_ept_load_pdptrs(vcpu);
+
        leave_guest_mode(vcpu);
 
        if (nested_cpu_has_preemption_timer(vmcs12))
@@ -4668,7 +4676,7 @@ void nested_vmx_pmu_entry_exit_ctls_update(struct kvm_vcpu *vcpu)
                vmx->nested.msrs.entry_ctls_high &=
                                ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
                vmx->nested.msrs.exit_ctls_high &=
-                               ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
+                               ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
        }
 }
 
index 46ba2e0..8646a79 100644 (file)
@@ -2971,7 +2971,7 @@ static void vmx_flush_tlb_guest(struct kvm_vcpu *vcpu)
        vpid_sync_context(to_vmx(vcpu)->vpid);
 }
 
-static void ept_load_pdptrs(struct kvm_vcpu *vcpu)
+void vmx_ept_load_pdptrs(struct kvm_vcpu *vcpu)
 {
        struct kvm_mmu *mmu = vcpu->arch.walk_mmu;
 
@@ -3114,7 +3114,7 @@ static void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long pgd,
                        guest_cr3 = vcpu->arch.cr3;
                else /* vmcs01.GUEST_CR3 is already up-to-date. */
                        update_guest_cr3 = false;
-               ept_load_pdptrs(vcpu);
+               vmx_ept_load_pdptrs(vcpu);
        } else {
                guest_cr3 = pgd;
        }
@@ -4654,7 +4654,7 @@ static bool rmode_exception(struct kvm_vcpu *vcpu, int vec)
                        vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
                if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP)
                        return false;
-               /* fall through */
+               fallthrough;
        case DB_VECTOR:
                return !(vcpu->guest_debug &
                        (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP));
@@ -4827,7 +4827,7 @@ static int handle_exception_nmi(struct kvm_vcpu *vcpu)
                }
                kvm_run->debug.arch.dr6 = dr6 | DR6_FIXED_1 | DR6_RTM;
                kvm_run->debug.arch.dr7 = vmcs_readl(GUEST_DR7);
-               /* fall through */
+               fallthrough;
        case BP_VECTOR:
                /*
                 * Update instruction length as we may reinject #BP from
@@ -5257,7 +5257,7 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
                                error_code =
                                        vmcs_read32(IDT_VECTORING_ERROR_CODE);
                        }
-                       /* fall through */
+                       fallthrough;
                case INTR_TYPE_SOFT_EXCEPTION:
                        kvm_clear_exception_queue(vcpu);
                        break;
@@ -5610,7 +5610,7 @@ static int handle_invpcid(struct kvm_vcpu *vcpu)
                 * keeping track of global entries in shadow page tables.
                 */
 
-               /* fall-through */
+               fallthrough;
        case INVPCID_TYPE_ALL_INCL_GLOBAL:
                kvm_mmu_unload(vcpu);
                return kvm_skip_emulated_instruction(vcpu);
@@ -6054,6 +6054,7 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
                        (exit_reason != EXIT_REASON_EXCEPTION_NMI &&
                        exit_reason != EXIT_REASON_EPT_VIOLATION &&
                        exit_reason != EXIT_REASON_PML_FULL &&
+                       exit_reason != EXIT_REASON_APIC_ACCESS &&
                        exit_reason != EXIT_REASON_TASK_SWITCH)) {
                vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
                vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_DELIVERY_EV;
@@ -6578,7 +6579,7 @@ static void __vmx_complete_interrupts(struct kvm_vcpu *vcpu,
                break;
        case INTR_TYPE_SOFT_EXCEPTION:
                vcpu->arch.event_exit_inst_len = vmcs_read32(instr_len_field);
-               /* fall through */
+               fallthrough;
        case INTR_TYPE_HARD_EXCEPTION:
                if (idt_vectoring_info & VECTORING_INFO_DELIVER_CODE_MASK) {
                        u32 err = vmcs_read32(error_code_field);
@@ -6588,7 +6589,7 @@ static void __vmx_complete_interrupts(struct kvm_vcpu *vcpu,
                break;
        case INTR_TYPE_SOFT_INTR:
                vcpu->arch.event_exit_inst_len = vmcs_read32(instr_len_field);
-               /* fall through */
+               fallthrough;
        case INTR_TYPE_EXT_INTR:
                kvm_queue_interrupt(vcpu, vector, type == INTR_TYPE_SOFT_INTR);
                break;
index 26175a4..a2f8212 100644 (file)
@@ -356,6 +356,7 @@ void vmx_update_host_rsp(struct vcpu_vmx *vmx, unsigned long host_rsp);
 int vmx_find_msr_index(struct vmx_msrs *m, u32 msr);
 int vmx_handle_memory_failure(struct kvm_vcpu *vcpu, int r,
                              struct x86_exception *e);
+void vmx_ept_load_pdptrs(struct kvm_vcpu *vcpu);
 
 #define POSTED_INTR_ON  0
 #define POSTED_INTR_SN  1
index 599d732..1994602 100644 (file)
@@ -975,7 +975,7 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
 {
        unsigned long old_cr4 = kvm_read_cr4(vcpu);
        unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE |
-                                  X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_PKE;
+                                  X86_CR4_SMEP;
 
        if (kvm_valid_cr4(vcpu, cr4))
                return 1;
@@ -1116,14 +1116,12 @@ static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)
                        vcpu->arch.eff_db[dr] = val;
                break;
        case 4:
-               /* fall through */
        case 6:
                if (!kvm_dr6_valid(val))
                        return -1; /* #GP */
                vcpu->arch.dr6 = (val & DR6_VOLATILE) | kvm_dr6_fixed(vcpu);
                break;
        case 5:
-               /* fall through */
        default: /* 7 */
                if (!kvm_dr7_valid(val))
                        return -1; /* #GP */
@@ -1154,12 +1152,10 @@ int kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val)
                *val = vcpu->arch.db[array_index_nospec(dr, size)];
                break;
        case 4:
-               /* fall through */
        case 6:
                *val = vcpu->arch.dr6;
                break;
        case 5:
-               /* fall through */
        default: /* 7 */
                *val = vcpu->arch.dr7;
                break;
@@ -2735,7 +2731,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
                return 1;
 
        if (!lapic_in_kernel(vcpu))
-               return 1;
+               return data ? 1 : 0;
 
        vcpu->arch.apf.msr_en_val = data;
 
@@ -3051,7 +3047,8 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 
        case MSR_K7_PERFCTR0 ... MSR_K7_PERFCTR3:
        case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR1:
-               pr = true; /* fall through */
+               pr = true;
+               fallthrough;
        case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
        case MSR_P6_EVNTSEL0 ... MSR_P6_EVNTSEL1:
                if (kvm_pmu_is_valid_msr(vcpu, msr))
@@ -3581,6 +3578,9 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_SMALLER_MAXPHYADDR:
                r = (int) allow_smaller_maxphyaddr;
                break;
+       case KVM_CAP_STEAL_TIME:
+               r = sched_info_on();
+               break;
        default:
                break;
        }
@@ -4359,7 +4359,7 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
        case KVM_CAP_HYPERV_SYNIC2:
                if (cap->args[0])
                        return -EINVAL;
-               /* fall through */
+               fallthrough;
 
        case KVM_CAP_HYPERV_SYNIC:
                if (!irqchip_in_kernel(vcpu->kvm))
@@ -8672,7 +8672,7 @@ static inline int vcpu_block(struct kvm *kvm, struct kvm_vcpu *vcpu)
                vcpu->arch.pv.pv_unhalted = false;
                vcpu->arch.mp_state =
                        KVM_MP_STATE_RUNNABLE;
-               /* fall through */
+               fallthrough;
        case KVM_MP_STATE_RUNNABLE:
                vcpu->arch.apf.halted = false;
                break;
@@ -10751,9 +10751,11 @@ EXPORT_SYMBOL_GPL(kvm_spec_ctrl_test_value);
 void kvm_fixup_and_inject_pf_error(struct kvm_vcpu *vcpu, gva_t gva, u16 error_code)
 {
        struct x86_exception fault;
+       u32 access = error_code &
+               (PFERR_WRITE_MASK | PFERR_FETCH_MASK | PFERR_USER_MASK);
 
        if (!(error_code & PFERR_PRESENT_MASK) ||
-           vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, error_code, &fault) != UNMAPPED_GVA) {
+           vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, &fault) != UNMAPPED_GVA) {
                /*
                 * If vcpu->arch.walk_mmu->gva_to_gpa succeeded, the page
                 * tables probably do not match the TLB.  Just proceed
index d46fff1..aa06785 100644 (file)
@@ -24,7 +24,7 @@ ifdef CONFIG_FUNCTION_TRACER
 CFLAGS_REMOVE_cmdline.o = -pg
 endif
 
-CFLAGS_cmdline.o := -fno-stack-protector
+CFLAGS_cmdline.o := -fno-stack-protector -fno-jump-tables
 endif
 
 inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
index 4f1719e..b6da093 100644 (file)
@@ -58,7 +58,7 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size,
                        state = st_wordcmp;
                        opptr = option;
                        wstart = pos;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordcmp:
                        if (!*opptr) {
@@ -89,7 +89,7 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size,
                                break;
                        }
                        state = st_wordskip;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordskip:
                        if (!c)
@@ -151,7 +151,7 @@ __cmdline_find_option(const char *cmdline, int max_cmdline_size,
 
                        state = st_wordcmp;
                        opptr = option;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordcmp:
                        if ((c == '=') && !*opptr) {
@@ -172,7 +172,7 @@ __cmdline_find_option(const char *cmdline, int max_cmdline_size,
                                break;
                        }
                        state = st_wordskip;
-                       /* fall through */
+                       fallthrough;
 
                case st_wordskip:
                        if (myisspace(c))
index 31600d8..5e69603 100644 (file)
@@ -179,7 +179,7 @@ static int resolve_default_seg(struct insn *insn, struct pt_regs *regs, int off)
                if (insn->addr_bytes == 2)
                        return -EINVAL;
 
-               /* fall through */
+               fallthrough;
 
        case -EDOM:
        case offsetof(struct pt_regs, bx):
@@ -362,7 +362,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)
                case INAT_SEG_REG_GS:
                        return vm86regs->gs;
                case INAT_SEG_REG_IGNORE:
-                       /* fall through */
                default:
                        return -EINVAL;
                }
@@ -386,7 +385,6 @@ static short get_segment_selector(struct pt_regs *regs, int seg_reg_idx)
                 */
                return get_user_gs(regs);
        case INAT_SEG_REG_IGNORE:
-               /* fall through */
        default:
                return -EINVAL;
        }
@@ -786,7 +784,7 @@ int insn_get_code_seg_params(struct pt_regs *regs)
                 */
                return INSN_CODE_SEG_PARAMS(4, 8);
        case 3: /* Invalid setting. CS.L=1, CS.D=1 */
-               /* fall through */
+               fallthrough;
        default:
                return -EINVAL;
        }
index 73dc66d..ec071cb 100644 (file)
@@ -186,7 +186,7 @@ void FPU_printall(void)
                case TAG_Special:
                        /* Update tagi for the printk below */
                        tagi = FPU_Special(r);
-                       /* fall through */
+                       fallthrough;
                case TAG_Valid:
                        printk("st(%d)  %c .%04lx %04lx %04lx %04lx e%+-6d ", i,
                               getsign(r) ? '-' : '+',
index 127ea54..4a98878 100644 (file)
@@ -1352,7 +1352,7 @@ static void fyl2xp1(FPU_REG *st0_ptr, u_char st0_tag)
                case TW_Denormal:
                        if (denormal_operand() < 0)
                                return;
-                       /* fall through */
+                       fallthrough;
                case TAG_Zero:
                case TAG_Valid:
                        setsign(st0_ptr, getsign(st0_ptr) ^ getsign(st1_ptr));
index 35f1498..6e3e8a1 100644 (file)
@@ -190,6 +190,53 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
        return pmd_k;
 }
 
+/*
+ *   Handle a fault on the vmalloc or module mapping area
+ *
+ *   This is needed because there is a race condition between the time
+ *   when the vmalloc mapping code updates the PMD to the point in time
+ *   where it synchronizes this update with the other page-tables in the
+ *   system.
+ *
+ *   In this race window another thread/CPU can map an area on the same
+ *   PMD, finds it already present and does not synchronize it with the
+ *   rest of the system yet. As a result v[mz]alloc might return areas
+ *   which are not mapped in every page-table in the system, causing an
+ *   unhandled page-fault when they are accessed.
+ */
+static noinline int vmalloc_fault(unsigned long address)
+{
+       unsigned long pgd_paddr;
+       pmd_t *pmd_k;
+       pte_t *pte_k;
+
+       /* Make sure we are in vmalloc area: */
+       if (!(address >= VMALLOC_START && address < VMALLOC_END))
+               return -1;
+
+       /*
+        * Synchronize this task's top level page-table
+        * with the 'reference' page table.
+        *
+        * Do _not_ use "current" here. We might be inside
+        * an interrupt in the middle of a task switch..
+        */
+       pgd_paddr = read_cr3_pa();
+       pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
+       if (!pmd_k)
+               return -1;
+
+       if (pmd_large(*pmd_k))
+               return 0;
+
+       pte_k = pte_offset_kernel(pmd_k, address);
+       if (!pte_present(*pte_k))
+               return -1;
+
+       return 0;
+}
+NOKPROBE_SYMBOL(vmalloc_fault);
+
 void arch_sync_kernel_mappings(unsigned long start, unsigned long end)
 {
        unsigned long addr;
@@ -1110,6 +1157,37 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
         */
        WARN_ON_ONCE(hw_error_code & X86_PF_PK);
 
+#ifdef CONFIG_X86_32
+       /*
+        * We can fault-in kernel-space virtual memory on-demand. The
+        * 'reference' page table is init_mm.pgd.
+        *
+        * NOTE! We MUST NOT take any locks for this case. We may
+        * be in an interrupt or a critical region, and should
+        * only copy the information from the master page table,
+        * nothing more.
+        *
+        * Before doing this on-demand faulting, ensure that the
+        * fault is not any of the following:
+        * 1. A fault on a PTE with a reserved bit set.
+        * 2. A fault caused by a user-mode access.  (Do not demand-
+        *    fault kernel memory due to user-mode accesses).
+        * 3. A fault caused by a page-level protection violation.
+        *    (A demand fault would be on a non-present page which
+        *     would have X86_PF_PROT==0).
+        *
+        * This is only needed to close a race condition on x86-32 in
+        * the vmalloc mapping/unmapping code. See the comment above
+        * vmalloc_fault() for details. On x86-64 the race does not
+        * exist as the vmalloc mappings don't need to be synchronized
+        * there.
+        */
+       if (!(hw_error_code & (X86_PF_RSVD | X86_PF_USER | X86_PF_PROT))) {
+               if (vmalloc_fault(address) >= 0)
+                       return;
+       }
+#endif
+
        /* Was the fault spurious, caused by lazy TLB invalidation? */
        if (spurious_kernel_fault(hw_error_code, address))
                return;
index 84d85db..9e5ccc5 100644 (file)
@@ -574,7 +574,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,
                /* For SEV, these areas are encrypted */
                if (sev_active())
                        break;
-               /* Fallthrough */
+               fallthrough;
 
        case E820_TYPE_PRAM:
                return true;
index c5174b4..683cd12 100644 (file)
@@ -321,7 +321,7 @@ static int __init split_nodes_size_interleave(struct numa_meminfo *ei,
                                              u64 addr, u64 max_addr, u64 size)
 {
        return split_nodes_size_interleave_uniform(ei, pi, addr, max_addr, size,
-                       0, NULL, NUMA_NO_NODE);
+                       0, NULL, 0);
 }
 
 static int __init setup_emu2phys_nid(int *dfl_phys_nid)
index 1a3569b..0951b47 100644 (file)
@@ -555,21 +555,12 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next,
                this_cpu_write(cpu_tlbstate.ctxs[new_asid].tlb_gen, next_tlb_gen);
                load_new_mm_cr3(next->pgd, new_asid, true);
 
-               /*
-                * NB: This gets called via leave_mm() in the idle path
-                * where RCU functions differently.  Tracing normally
-                * uses RCU, so we need to use the _rcuidle variant.
-                *
-                * (There is no good reason for this.  The idle code should
-                *  be rearranged to call this before rcu_idle_enter().)
-                */
-               trace_tlb_flush_rcuidle(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
+               trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, TLB_FLUSH_ALL);
        } else {
                /* The new ASID is already up to date. */
                load_new_mm_cr3(next->pgd, new_asid, false);
 
-               /* See above wrt _rcuidle. */
-               trace_tlb_flush_rcuidle(TLB_FLUSH_ON_TASK_SWITCH, 0);
+               trace_tlb_flush(TLB_FLUSH_ON_TASK_SWITCH, 0);
        }
 
        /* Make sure we write CR3 before loaded_mm. */
index 9f9aad4..89395a5 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/xen/pci.h>
 #include <asm/xen/cpuid.h>
 #include <asm/apic.h>
+#include <asm/acpi.h>
 #include <asm/i8259.h>
 
 static int xen_pcifront_enable_irq(struct pci_dev *dev)
index f6ea8f1..d37ebe6 100644 (file)
@@ -49,7 +49,6 @@
 #include <asm/efi.h>
 #include <asm/e820/api.h>
 #include <asm/time.h>
-#include <asm/set_memory.h>
 #include <asm/tlbflush.h>
 #include <asm/x86_init.h>
 #include <asm/uv/uv.h>
@@ -496,74 +495,6 @@ void __init efi_init(void)
                efi_print_memmap();
 }
 
-#if defined(CONFIG_X86_32)
-
-void __init efi_set_executable(efi_memory_desc_t *md, bool executable)
-{
-       u64 addr, npages;
-
-       addr = md->virt_addr;
-       npages = md->num_pages;
-
-       memrange_efi_to_native(&addr, &npages);
-
-       if (executable)
-               set_memory_x(addr, npages);
-       else
-               set_memory_nx(addr, npages);
-}
-
-void __init runtime_code_page_mkexec(void)
-{
-       efi_memory_desc_t *md;
-
-       /* Make EFI runtime service code area executable */
-       for_each_efi_memory_desc(md) {
-               if (md->type != EFI_RUNTIME_SERVICES_CODE)
-                       continue;
-
-               efi_set_executable(md, true);
-       }
-}
-
-void __init efi_memory_uc(u64 addr, unsigned long size)
-{
-       unsigned long page_shift = 1UL << EFI_PAGE_SHIFT;
-       u64 npages;
-
-       npages = round_up(size, page_shift) / page_shift;
-       memrange_efi_to_native(&addr, &npages);
-       set_memory_uc(addr, npages);
-}
-
-void __init old_map_region(efi_memory_desc_t *md)
-{
-       u64 start_pfn, end_pfn, end;
-       unsigned long size;
-       void *va;
-
-       start_pfn = PFN_DOWN(md->phys_addr);
-       size      = md->num_pages << PAGE_SHIFT;
-       end       = md->phys_addr + size;
-       end_pfn   = PFN_UP(end);
-
-       if (pfn_range_is_mapped(start_pfn, end_pfn)) {
-               va = __va(md->phys_addr);
-
-               if (!(md->attribute & EFI_MEMORY_WB))
-                       efi_memory_uc((u64)(unsigned long)va, size);
-       } else
-               va = efi_ioremap(md->phys_addr, size,
-                                md->type, md->attribute);
-
-       md->virt_addr = (u64) (unsigned long) va;
-       if (!va)
-               pr_err("ioremap of 0x%llX failed!\n",
-                      (unsigned long long)md->phys_addr);
-}
-
-#endif
-
 /* Merge contiguous regions of the same type and attribute */
 static void __init efi_merge_regions(void)
 {
index 826ead6..e06a199 100644 (file)
 #include <asm/io.h>
 #include <asm/desc.h>
 #include <asm/page.h>
+#include <asm/set_memory.h>
 #include <asm/tlbflush.h>
 #include <asm/efi.h>
 
+void __init efi_map_region(efi_memory_desc_t *md)
+{
+       u64 start_pfn, end_pfn, end;
+       unsigned long size;
+       void *va;
+
+       start_pfn       = PFN_DOWN(md->phys_addr);
+       size            = md->num_pages << PAGE_SHIFT;
+       end             = md->phys_addr + size;
+       end_pfn         = PFN_UP(end);
+
+       if (pfn_range_is_mapped(start_pfn, end_pfn)) {
+               va = __va(md->phys_addr);
+
+               if (!(md->attribute & EFI_MEMORY_WB))
+                       set_memory_uc((unsigned long)va, md->num_pages);
+       } else {
+               va = ioremap_cache(md->phys_addr, size);
+       }
+
+       md->virt_addr = (unsigned long)va;
+       if (!va)
+               pr_err("ioremap of 0x%llX failed!\n", md->phys_addr);
+}
+
 /*
  * To make EFI call EFI runtime service in physical addressing mode we need
  * prolog/epilog before/after the invocation to claim the EFI runtime service
@@ -58,11 +84,6 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
        return 0;
 }
 
-void __init efi_map_region(efi_memory_desc_t *md)
-{
-       old_map_region(md);
-}
-
 void __init efi_map_region_fixed(efi_memory_desc_t *md) {}
 void __init parse_efi_setup(u64 phys_addr, u32 data_len) {}
 
@@ -107,6 +128,15 @@ efi_status_t __init efi_set_virtual_address_map(unsigned long memory_map_size,
 
 void __init efi_runtime_update_mappings(void)
 {
-       if (__supported_pte_mask & _PAGE_NX)
-               runtime_code_page_mkexec();
+       if (__supported_pte_mask & _PAGE_NX) {
+               efi_memory_desc_t *md;
+
+               /* Make EFI runtime service code area executable */
+               for_each_efi_memory_desc(md) {
+                       if (md->type != EFI_RUNTIME_SERVICES_CODE)
+                               continue;
+
+                       set_memory_x(md->virt_addr, md->num_pages);
+               }
+       }
 }
index 413583f..6af4da1 100644 (file)
@@ -259,6 +259,8 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
        npages = (__end_rodata - __start_rodata) >> PAGE_SHIFT;
        rodata = __pa(__start_rodata);
        pfn = rodata >> PAGE_SHIFT;
+
+       pf = _PAGE_NX | _PAGE_ENC;
        if (kernel_map_pages_in_pgd(pgd, pfn, rodata, npages, pf)) {
                pr_err("Failed to map kernel rodata 1:1\n");
                return 1;
index 76cee34..b3b17d6 100644 (file)
@@ -448,7 +448,7 @@ static void do_signal(struct pt_regs *regs)
                                                regs->areg[2] = -EINTR;
                                                break;
                                        }
-                                       /* fallthrough */
+                                       fallthrough;
                                case -ERESTARTNOINTR:
                                        regs->areg[2] = regs->syscall;
                                        regs->pc -= 3;
index 2e5f569..d390566 100644 (file)
@@ -525,7 +525,7 @@ ssize_t badblocks_store(struct badblocks *bb, const char *page, size_t len,
        case 3:
                if (newline != '\n')
                        return -EINVAL;
-               /* fall through */
+               fallthrough;
        case 2:
                if (length <= 0)
                        return -EINVAL;
index 68882b9..b791e20 100644 (file)
@@ -332,7 +332,7 @@ static void bfqg_put(struct bfq_group *bfqg)
                kfree(bfqg);
 }
 
-void bfqg_and_blkg_get(struct bfq_group *bfqg)
+static void bfqg_and_blkg_get(struct bfq_group *bfqg)
 {
        /* see comments in bfq_bic_update_cgroup for why refcounting bfqg */
        bfqg_get(bfqg);
index a4c0bec..fa98470 100644 (file)
@@ -4980,7 +4980,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
                pr_err("bdi %s: bfq: bad prio class %d\n",
                                bdi_dev_name(bfqq->bfqd->queue->backing_dev_info),
                                ioprio_class);
-               /* fall through */
+               fallthrough;
        case IOPRIO_CLASS_NONE:
                /*
                 * No prio set, inherit CPU scheduling settings.
@@ -5112,7 +5112,7 @@ static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd,
                return &bfqg->async_bfqq[0][ioprio];
        case IOPRIO_CLASS_NONE:
                ioprio = IOPRIO_NORM;
-               /* fall through */
+               fallthrough;
        case IOPRIO_CLASS_BE:
                return &bfqg->async_bfqq[1][ioprio];
        case IOPRIO_CLASS_IDLE:
@@ -5895,18 +5895,6 @@ static void bfq_finish_requeue_request(struct request *rq)
        struct bfq_queue *bfqq = RQ_BFQQ(rq);
        struct bfq_data *bfqd;
 
-       /*
-        * Requeue and finish hooks are invoked in blk-mq without
-        * checking whether the involved request is actually still
-        * referenced in the scheduler. To handle this fact, the
-        * following two checks make this function exit in case of
-        * spurious invocations, for which there is nothing to do.
-        *
-        * First, check whether rq has nothing to do with an elevator.
-        */
-       if (unlikely(!(rq->rq_flags & RQF_ELVPRIV)))
-               return;
-
        /*
         * rq either is not associated with any icq, or is an already
         * requeued request that has not (yet) been re-inserted into
index cd224aa..7038952 100644 (file)
@@ -986,7 +986,6 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd,
 struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg);
 struct bfq_group *bfqq_group(struct bfq_queue *bfqq);
 struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node);
-void bfqg_and_blkg_get(struct bfq_group *bfqg);
 void bfqg_and_blkg_put(struct bfq_group *bfqg);
 
 #ifdef CONFIG_BFQ_GROUP_IOSCHED
index eb0e2a6..26776bd 100644 (file)
@@ -533,9 +533,7 @@ static void bfq_get_entity(struct bfq_entity *entity)
                bfqq->ref++;
                bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d",
                             bfqq, bfqq->ref);
-       } else
-               bfqg_and_blkg_get(container_of(entity, struct bfq_group,
-                                              entity));
+       }
 }
 
 /**
@@ -649,14 +647,8 @@ static void bfq_forget_entity(struct bfq_service_tree *st,
 
        entity->on_st_or_in_serv = false;
        st->wsum -= entity->weight;
-       if (is_in_service)
-               return;
-
-       if (bfqq)
+       if (bfqq && !is_in_service)
                bfq_put_queue(bfqq);
-       else
-               bfqg_and_blkg_put(container_of(entity, struct bfq_group,
-                                              entity));
 }
 
 /**
index c63ba04..e865ea5 100644 (file)
@@ -740,8 +740,8 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
                struct page *page, unsigned int len, unsigned int off,
                bool *same_page)
 {
-       phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) +
-               bv->bv_offset + bv->bv_len - 1;
+       size_t bv_end = bv->bv_offset + bv->bv_len;
+       phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + bv_end - 1;
        phys_addr_t page_addr = page_to_phys(page);
 
        if (vec_end_addr + 1 != page_addr + off)
@@ -750,9 +750,9 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
                return false;
 
        *same_page = ((vec_end_addr & PAGE_MASK) == page_addr);
-       if (!*same_page && pfn_to_page(PFN_DOWN(vec_end_addr)) + 1 != page)
-               return false;
-       return true;
+       if (*same_page)
+               return true;
+       return (bv->bv_page + bv_end / PAGE_SIZE) == (page + off / PAGE_SIZE);
 }
 
 /*
@@ -879,8 +879,10 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
                struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
 
                if (page_is_mergeable(bv, page, len, off, same_page)) {
-                       if (bio->bi_iter.bi_size > UINT_MAX - len)
+                       if (bio->bi_iter.bi_size > UINT_MAX - len) {
+                               *same_page = false;
                                return false;
+                       }
                        bv->bv_len += len;
                        bio->bi_iter.bi_size += len;
                        return true;
index 619a79b..c195365 100644 (file)
@@ -1152,13 +1152,15 @@ int blkcg_init_queue(struct request_queue *q)
        if (preloaded)
                radix_tree_preload_end();
 
-       ret = blk_iolatency_init(q);
+       ret = blk_throtl_init(q);
        if (ret)
                goto err_destroy_all;
 
-       ret = blk_throtl_init(q);
-       if (ret)
+       ret = blk_iolatency_init(q);
+       if (ret) {
+               blk_throtl_exit(q);
                goto err_destroy_all;
+       }
        return 0;
 
 err_destroy_all:
index d9d6326..10c08ac 100644 (file)
@@ -539,6 +539,7 @@ struct request_queue *blk_alloc_queue(int node_id)
                goto fail_stats;
 
        q->backing_dev_info->ra_pages = VM_READAHEAD_PAGES;
+       q->backing_dev_info->io_pages = VM_READAHEAD_PAGES;
        q->backing_dev_info->capabilities = BDI_CAP_CGROUP_WRITEBACK;
        q->node = node_id;
 
index 413e0b5..d37b55d 100644 (file)
@@ -2092,14 +2092,15 @@ static void ioc_pd_free(struct blkg_policy_data *pd)
 {
        struct ioc_gq *iocg = pd_to_iocg(pd);
        struct ioc *ioc = iocg->ioc;
+       unsigned long flags;
 
        if (ioc) {
-               spin_lock(&ioc->lock);
+               spin_lock_irqsave(&ioc->lock, flags);
                if (!list_empty(&iocg->active_list)) {
                        propagate_active_weight(iocg, 0, 0);
                        list_del_init(&iocg->active_list);
                }
-               spin_unlock(&ioc->lock);
+               spin_unlock_irqrestore(&ioc->lock, flags);
 
                hrtimer_cancel(&iocg->waitq_timer);
                hrtimer_cancel(&iocg->delay_timer);
index 6529e3a..f685d63 100644 (file)
@@ -154,7 +154,7 @@ static inline unsigned get_max_io_size(struct request_queue *q,
        if (max_sectors > start_offset)
                return max_sectors - start_offset;
 
-       return sectors & (lbs - 1);
+       return sectors & ~(lbs - 1);
 }
 
 static inline unsigned get_max_segment_size(const struct request_queue *q,
@@ -533,10 +533,17 @@ int __blk_rq_map_sg(struct request_queue *q, struct request *rq,
 }
 EXPORT_SYMBOL(__blk_rq_map_sg);
 
+static inline unsigned int blk_rq_get_max_segments(struct request *rq)
+{
+       if (req_op(rq) == REQ_OP_DISCARD)
+               return queue_max_discard_segments(rq->q);
+       return queue_max_segments(rq->q);
+}
+
 static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
                unsigned int nr_phys_segs)
 {
-       if (req->nr_phys_segments + nr_phys_segs > queue_max_segments(req->q))
+       if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
                goto no_merge;
 
        if (blk_integrity_merge_bio(req->q, req, bio) == false)
@@ -624,7 +631,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
                return 0;
 
        total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
-       if (total_phys_segments > queue_max_segments(q))
+       if (total_phys_segments > blk_rq_get_max_segments(req))
                return 0;
 
        if (blk_integrity_merge_rq(q, req, next) == false)
index a19cdf1..d2790e5 100644 (file)
@@ -78,6 +78,15 @@ void blk_mq_sched_restart(struct blk_mq_hw_ctx *hctx)
                return;
        clear_bit(BLK_MQ_S_SCHED_RESTART, &hctx->state);
 
+       /*
+        * Order clearing SCHED_RESTART and list_empty_careful(&hctx->dispatch)
+        * in blk_mq_run_hw_queue(). Its pair is the barrier in
+        * blk_mq_dispatch_rq_list(). So dispatch code won't see SCHED_RESTART,
+        * meantime new request added to hctx->dispatch is missed to check in
+        * blk_mq_run_hw_queue().
+        */
+       smp_mb();
+
        blk_mq_run_hw_queue(hctx, true);
 }
 
index 126021f..e81ca1b 100644 (file)
@@ -66,7 +66,7 @@ static inline void blk_mq_sched_requeue_request(struct request *rq)
        struct request_queue *q = rq->q;
        struct elevator_queue *e = q->elevator;
 
-       if (e && e->type->ops.requeue_request)
+       if ((rq->rq_flags & RQF_ELVPRIV) && e && e->type->ops.requeue_request)
                e->type->ops.requeue_request(rq);
 }
 
index 0015a18..b3d2785 100644 (file)
@@ -1437,6 +1437,15 @@ out:
                list_splice_tail_init(list, &hctx->dispatch);
                spin_unlock(&hctx->lock);
 
+               /*
+                * Order adding requests to hctx->dispatch and checking
+                * SCHED_RESTART flag. The pair of this smp_mb() is the one
+                * in blk_mq_sched_restart(). Avoid restart code path to
+                * miss the new added requests to hctx->dispatch, meantime
+                * SCHED_RESTART is observed here.
+                */
+               smp_mb();
+
                /*
                 * If SCHED_RESTART was set by the caller of this function and
                 * it is no longer set that means that it was cleared by another
@@ -1834,6 +1843,7 @@ void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
 /**
  * blk_mq_request_bypass_insert - Insert a request at dispatch list.
  * @rq: Pointer to request to be inserted.
+ * @at_head: true if the request should be inserted at the head of the list.
  * @run_queue: If we should run the hardware queue after inserting the request.
  *
  * Should only be used carefully, when the caller knows we want to
@@ -2016,7 +2026,8 @@ insert:
        if (bypass_insert)
                return BLK_STS_RESOURCE;
 
-       blk_mq_request_bypass_insert(rq, false, run_queue);
+       blk_mq_sched_insert_request(rq, false, run_queue, false);
+
        return BLK_STS_OK;
 }
 
index 7da302f..ae3dd1f 100644 (file)
@@ -137,6 +137,7 @@ void blk_stat_add_callback(struct request_queue *q,
                           struct blk_stat_callback *cb)
 {
        unsigned int bucket;
+       unsigned long flags;
        int cpu;
 
        for_each_possible_cpu(cpu) {
@@ -147,20 +148,22 @@ void blk_stat_add_callback(struct request_queue *q,
                        blk_rq_stat_init(&cpu_stat[bucket]);
        }
 
-       spin_lock(&q->stats->lock);
+       spin_lock_irqsave(&q->stats->lock, flags);
        list_add_tail_rcu(&cb->list, &q->stats->callbacks);
        blk_queue_flag_set(QUEUE_FLAG_STATS, q);
-       spin_unlock(&q->stats->lock);
+       spin_unlock_irqrestore(&q->stats->lock, flags);
 }
 
 void blk_stat_remove_callback(struct request_queue *q,
                              struct blk_stat_callback *cb)
 {
-       spin_lock(&q->stats->lock);
+       unsigned long flags;
+
+       spin_lock_irqsave(&q->stats->lock, flags);
        list_del_rcu(&cb->list);
        if (list_empty(&q->stats->callbacks) && !q->stats->enable_accounting)
                blk_queue_flag_clear(QUEUE_FLAG_STATS, q);
-       spin_unlock(&q->stats->lock);
+       spin_unlock_irqrestore(&q->stats->lock, flags);
 
        del_timer_sync(&cb->timer);
 }
@@ -183,10 +186,12 @@ void blk_stat_free_callback(struct blk_stat_callback *cb)
 
 void blk_stat_enable_accounting(struct request_queue *q)
 {
-       spin_lock(&q->stats->lock);
+       unsigned long flags;
+
+       spin_lock_irqsave(&q->stats->lock, flags);
        q->stats->enable_accounting = true;
        blk_queue_flag_set(QUEUE_FLAG_STATS, q);
-       spin_unlock(&q->stats->lock);
+       spin_unlock_irqrestore(&q->stats->lock, flags);
 }
 EXPORT_SYMBOL_GPL(blk_stat_enable_accounting);
 
index 0fa615e..fd41008 100644 (file)
@@ -528,7 +528,7 @@ static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio)
                if ((bio->bi_opf & (REQ_SYNC | REQ_IDLE)) ==
                    (REQ_SYNC | REQ_IDLE))
                        return false;
-               /* fallthrough */
+               fallthrough;
        case REQ_OP_DISCARD:
                return true;
        default:
index fb7b347..d185396 100644 (file)
@@ -378,7 +378,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
        bset->timeout_fn = timeout;
 
        set = &bset->tag_set;
-       set->ops = &bsg_mq_ops,
+       set->ops = &bsg_mq_ops;
        set->nr_hw_queues = 1;
        set->queue_depth = 128;
        set->numa_node = NUMA_NO_NODE;
index 77bcab1..04ebd37 100644 (file)
@@ -71,7 +71,7 @@ int ioprio_check_cap(int ioprio)
                case IOPRIO_CLASS_RT:
                        if (!capable(CAP_SYS_ADMIN))
                                return -EPERM;
-                       /* fall through */
+                       fallthrough;
                        /* rt has prio field too */
                case IOPRIO_CLASS_BE:
                        if (data >= IOPRIO_BE_NR || data < 0)
index e62a98a..722406b 100644 (file)
@@ -278,6 +278,15 @@ static void hd_struct_free_work(struct work_struct *work)
 {
        struct hd_struct *part =
                container_of(to_rcu_work(work), struct hd_struct, rcu_work);
+       struct gendisk *disk = part_to_disk(part);
+
+       /*
+        * Release the disk reference acquired in delete_partition here.
+        * We can't release it in hd_struct_free because the final put_device
+        * needs process context and thus can't be run directly from a
+        * percpu_ref ->release handler.
+        */
+       put_device(disk_to_dev(disk));
 
        part->start_sect = 0;
        part->nr_sects = 0;
@@ -293,7 +302,6 @@ static void hd_struct_free(struct percpu_ref *ref)
                rcu_dereference_protected(disk->part_tbl, 1);
 
        rcu_assign_pointer(ptbl->last_lookup, NULL);
-       put_device(disk_to_dev(disk));
 
        INIT_RCU_WORK(&part->rcu_work, hd_struct_free_work);
        queue_rcu_work(system_wq, &part->rcu_work);
@@ -524,19 +532,20 @@ int bdev_add_partition(struct block_device *bdev, int partno,
 int bdev_del_partition(struct block_device *bdev, int partno)
 {
        struct block_device *bdevp;
-       struct hd_struct *part;
-       int ret = 0;
+       struct hd_struct *part = NULL;
+       int ret;
 
-       part = disk_get_part(bdev->bd_disk, partno);
-       if (!part)
-               return -ENXIO;
-
-       ret = -ENOMEM;
-       bdevp = bdget(part_devt(part));
+       bdevp = bdget_disk(bdev->bd_disk, partno);
        if (!bdevp)
-               goto out_put_part;
+               return -ENXIO;
 
        mutex_lock(&bdevp->bd_mutex);
+       mutex_lock_nested(&bdev->bd_mutex, 1);
+
+       ret = -ENXIO;
+       part = disk_get_part(bdev->bd_disk, partno);
+       if (!part)
+               goto out_unlock;
 
        ret = -EBUSY;
        if (bdevp->bd_openers)
@@ -545,16 +554,14 @@ int bdev_del_partition(struct block_device *bdev, int partno)
        sync_blockdev(bdevp);
        invalidate_bdev(bdevp);
 
-       mutex_lock_nested(&bdev->bd_mutex, 1);
        delete_partition(bdev->bd_disk, part);
-       mutex_unlock(&bdev->bd_mutex);
-
        ret = 0;
 out_unlock:
+       mutex_unlock(&bdev->bd_mutex);
        mutex_unlock(&bdevp->bd_mutex);
        bdput(bdevp);
-out_put_part:
-       disk_put_part(part);
+       if (part)
+               disk_put_part(part);
        return ret;
 }
 
index a6f581a..8be8bec 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/module.h>
 #include <linux/net.h>
 #include <linux/rwsem.h>
+#include <linux/sched.h>
 #include <linux/sched/signal.h>
 #include <linux/security.h>
 
@@ -845,9 +846,15 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
        }
 
        lock_sock(sk);
-       if (ctx->init && (init || !ctx->more)) {
-               err = -EINVAL;
-               goto unlock;
+       if (ctx->init && !ctx->more) {
+               if (ctx->used) {
+                       err = -EINVAL;
+                       goto unlock;
+               }
+
+               pr_info_once(
+                       "%s sent an empty control message without MSG_MORE.\n",
+                       current->comm);
        }
        ctx->init = true;
 
index e99fe34..3132967 100644 (file)
@@ -1521,7 +1521,7 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)
 
        case -EALREADY:
                err = 0;
-               /* fall through */
+               fallthrough;
 
        default:
                drbg->random_ready.func = NULL;
index ba0b770..12e82a6 100644 (file)
@@ -2348,121 +2348,121 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
                        test_hash_speed(alg, sec, generic_hash_speed_template);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case 301:
                test_hash_speed("md4", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 302:
                test_hash_speed("md5", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 303:
                test_hash_speed("sha1", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 304:
                test_hash_speed("sha256", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 305:
                test_hash_speed("sha384", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 306:
                test_hash_speed("sha512", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 307:
                test_hash_speed("wp256", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 308:
                test_hash_speed("wp384", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 309:
                test_hash_speed("wp512", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 310:
                test_hash_speed("tgr128", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 311:
                test_hash_speed("tgr160", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 312:
                test_hash_speed("tgr192", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 313:
                test_hash_speed("sha224", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 314:
                test_hash_speed("rmd128", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 315:
                test_hash_speed("rmd160", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 316:
                test_hash_speed("rmd256", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 317:
                test_hash_speed("rmd320", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 318:
                test_hash_speed("ghash-generic", sec, hash_speed_template_16);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 319:
                test_hash_speed("crc32c", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 320:
                test_hash_speed("crct10dif", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 321:
                test_hash_speed("poly1305", sec, poly1305_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 322:
                test_hash_speed("sha3-224", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 323:
                test_hash_speed("sha3-256", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 324:
                test_hash_speed("sha3-384", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 325:
                test_hash_speed("sha3-512", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 326:
                test_hash_speed("sm3", sec, generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 327:
                test_hash_speed("streebog256", sec,
                                generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 328:
                test_hash_speed("streebog512", sec,
                                generic_hash_speed_template);
                if (mode > 300 && mode < 400) break;
-               /* fall through */
+               fallthrough;
        case 399:
                break;
 
@@ -2471,121 +2471,121 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
                        test_ahash_speed(alg, sec, generic_hash_speed_template);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case 401:
                test_ahash_speed("md4", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 402:
                test_ahash_speed("md5", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 403:
                test_ahash_speed("sha1", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 404:
                test_ahash_speed("sha256", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 405:
                test_ahash_speed("sha384", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 406:
                test_ahash_speed("sha512", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 407:
                test_ahash_speed("wp256", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 408:
                test_ahash_speed("wp384", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 409:
                test_ahash_speed("wp512", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 410:
                test_ahash_speed("tgr128", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 411:
                test_ahash_speed("tgr160", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 412:
                test_ahash_speed("tgr192", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 413:
                test_ahash_speed("sha224", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 414:
                test_ahash_speed("rmd128", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 415:
                test_ahash_speed("rmd160", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 416:
                test_ahash_speed("rmd256", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 417:
                test_ahash_speed("rmd320", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 418:
                test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 419:
                test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 420:
                test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 421:
                test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 422:
                test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
                                    num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 423:
                test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
                                    num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 424:
                test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
                                    num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 425:
                test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
                                    num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 426:
                test_mb_ahash_speed("streebog256", sec,
                                    generic_hash_speed_template, num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 427:
                test_mb_ahash_speed("streebog512", sec,
                                    generic_hash_speed_template, num_mb);
                if (mode > 400 && mode < 500) break;
-               /* fall through */
+               fallthrough;
        case 499:
                break;
 
index c2b452a..9861302 100644 (file)
@@ -290,7 +290,7 @@ static int vt_notifier_call(struct notifier_block *blk,
                        break;
                case '\t':
                        c = ' ';
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        if (c < 32)
                                /* Ignore other control sequences */
index 0803c20..07ecbbd 100644 (file)
@@ -42,6 +42,11 @@ config SPEAKUP
                one of the listed synthesizers, you should say n.
 
 if SPEAKUP
+
+config SPEAKUP_SERIALIO
+       def_bool y
+       depends on ISA || COMPILE_TEST
+
 config SPEAKUP_SYNTH_ACNTSA
        tristate "Accent SA synthesizer support"
        help
@@ -52,7 +57,7 @@ config SPEAKUP_SYNTH_ACNTSA
 
 config SPEAKUP_SYNTH_ACNTPC
        tristate "Accent PC synthesizer support"
-       depends on ISA || COMPILE_TEST
+       depends on SPEAKUP_SERIALIO
        help
                This is the Speakup driver for the accent pc
                synthesizer.  You can say y to build it into the kernel,
@@ -104,7 +109,7 @@ config SPEAKUP_SYNTH_DECEXT
 
 config SPEAKUP_SYNTH_DECPC
        depends on m
-       depends on ISA || COMPILE_TEST
+       depends on SPEAKUP_SERIALIO
        tristate "DECtalk PC (big ISA card) synthesizer support"
        help
 
@@ -127,7 +132,7 @@ config SPEAKUP_SYNTH_DECPC
 
 config SPEAKUP_SYNTH_DTLK
        tristate "DoubleTalk PC synthesizer support"
-       depends on ISA || COMPILE_TEST
+       depends on SPEAKUP_SERIALIO
        help
 
                This is the Speakup driver for the internal DoubleTalk
@@ -138,7 +143,7 @@ config SPEAKUP_SYNTH_DTLK
 
 config SPEAKUP_SYNTH_KEYPC
        tristate "Keynote Gold PC synthesizer support"
-       depends on ISA || COMPILE_TEST
+       depends on SPEAKUP_SERIALIO
        help
 
                This is the Speakup driver for the Keynote Gold
index 5befb49..6e4bfac 100644 (file)
@@ -25,8 +25,8 @@ speakup-y := \
        keyhelp.o \
        kobjects.o \
        selection.o \
-       serialio.o \
        spk_ttyio.o \
        synth.o \
        thread.o \
        varhandlers.o
+speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o
index 177a298..403b01d 100644 (file)
@@ -32,6 +32,7 @@ static void spk_serial_tiocmset(unsigned int set, unsigned int clear);
 static unsigned char spk_serial_in(void);
 static unsigned char spk_serial_in_nowait(void);
 static void spk_serial_flush_buffer(void);
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_serial_io_ops = {
        .synth_out = spk_serial_out,
@@ -40,6 +41,7 @@ struct spk_io_ops spk_serial_io_ops = {
        .synth_in = spk_serial_in,
        .synth_in_nowait = spk_serial_in_nowait,
        .flush_buffer = spk_serial_flush_buffer,
+       .wait_for_xmitr = spk_serial_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_serial_io_ops);
 
@@ -211,7 +213,7 @@ void spk_stop_serial_interrupt(void)
 }
 EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt);
 
-int spk_wait_for_xmitr(struct spk_synth *in_synth)
+static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth)
 {
        int tmout = SPK_XMITR_TIMEOUT;
 
@@ -280,7 +282,7 @@ static void spk_serial_flush_buffer(void)
 
 static int spk_serial_out(struct spk_synth *in_synth, const char ch)
 {
-       if (in_synth->alive && spk_wait_for_xmitr(in_synth)) {
+       if (in_synth->alive && spk_serial_wait_for_xmitr(in_synth)) {
                outb_p(ch, speakup_info.port_tts);
                return 1;
        }
@@ -295,7 +297,7 @@ const char *spk_serial_synth_immediate(struct spk_synth *synth,
        while ((ch = *buff)) {
                if (ch == '\n')
                        ch = synth->procspeech;
-               if (spk_wait_for_xmitr(synth))
+               if (spk_serial_wait_for_xmitr(synth))
                        outb(ch, speakup_info.port_tts);
                else
                        return buff;
index c75b408..0f4bcbe 100644 (file)
@@ -34,7 +34,6 @@
 
 const struct old_serial_port *spk_serial_init(int index);
 void spk_stop_serial_interrupt(void);
-int spk_wait_for_xmitr(struct spk_synth *in_synth);
 void spk_serial_release(void);
 void spk_ttyio_release(void);
 void spk_ttyio_register_ldisc(void);
index 9b95f77..a831ff6 100644 (file)
@@ -116,6 +116,7 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear);
 static unsigned char spk_ttyio_in(void);
 static unsigned char spk_ttyio_in_nowait(void);
 static void spk_ttyio_flush_buffer(void);
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth);
 
 struct spk_io_ops spk_ttyio_ops = {
        .synth_out = spk_ttyio_out,
@@ -125,6 +126,7 @@ struct spk_io_ops spk_ttyio_ops = {
        .synth_in = spk_ttyio_in,
        .synth_in_nowait = spk_ttyio_in_nowait,
        .flush_buffer = spk_ttyio_flush_buffer,
+       .wait_for_xmitr = spk_ttyio_wait_for_xmitr,
 };
 EXPORT_SYMBOL_GPL(spk_ttyio_ops);
 
@@ -286,6 +288,11 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear)
        mutex_unlock(&speakup_tty_mutex);
 }
 
+static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth)
+{
+       return 1;
+}
+
 static unsigned char ttyio_in(int timeout)
 {
        struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
index d3272c6..7398f11 100644 (file)
@@ -158,6 +158,7 @@ struct spk_io_ops {
        unsigned char (*synth_in)(void);
        unsigned char (*synth_in_nowait)(void);
        void (*flush_buffer)(void);
+       int (*wait_for_xmitr)(struct spk_synth *synth);
 };
 
 struct spk_synth {
index 3568bfb..ac47dba 100644 (file)
@@ -159,7 +159,7 @@ int spk_synth_is_alive_restart(struct spk_synth *synth)
 {
        if (synth->alive)
                return 1;
-       if (spk_wait_for_xmitr(synth) > 0) {
+       if (synth->io_ops->wait_for_xmitr(synth) > 0) {
                /* restart */
                synth->alive = 1;
                synth_printf("%s", synth->init);
index 4c34837..806b8ce 100644 (file)
@@ -99,8 +99,8 @@ static int fch_misc_setup(struct apd_private_data *pdata)
        if (ret < 0)
                return -ENOENT;
 
-       acpi_dev_get_property(adev, "is-rv", ACPI_TYPE_INTEGER, &obj);
-       clk_data->is_rv = obj->integer.value;
+       if (!acpi_dev_get_property(adev, "is-rv", ACPI_TYPE_INTEGER, &obj))
+               clk_data->is_rv = obj->integer.value;
 
        list_for_each_entry(rentry, &resource_list, node) {
                clk_data->base = devm_ioremap(&adev->dev, rentry->res->start,
index 6ad8cb0..4a0b077 100644 (file)
@@ -350,7 +350,7 @@ void __iomem __ref
 
        pg_off = round_down(phys, PAGE_SIZE);
        pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
-       virt = acpi_map(pg_off, pg_sz);
+       virt = acpi_map(phys, size);
        if (!virt) {
                mutex_unlock(&acpi_ioremap_lock);
                kfree(map);
@@ -358,7 +358,7 @@ void __iomem __ref
        }
 
        INIT_LIST_HEAD(&map->list);
-       map->virt = virt;
+       map->virt = (void __iomem __force *)((unsigned long)virt & PAGE_MASK);
        map->phys = pg_off;
        map->size = pg_sz;
        map->track.refcount = 1;
@@ -1575,11 +1575,26 @@ static acpi_status acpi_deactivate_mem_region(acpi_handle handle, u32 level,
 acpi_status acpi_release_memory(acpi_handle handle, struct resource *res,
                                u32 level)
 {
+       acpi_status status;
+
        if (!(res->flags & IORESOURCE_MEM))
                return AE_TYPE;
 
-       return acpi_walk_namespace(ACPI_TYPE_REGION, handle, level,
-                                  acpi_deactivate_mem_region, NULL, res, NULL);
+       status = acpi_walk_namespace(ACPI_TYPE_REGION, handle, level,
+                                    acpi_deactivate_mem_region, NULL,
+                                    res, NULL);
+       if (ACPI_FAILURE(status))
+               return status;
+
+       /*
+        * Wait for all of the mappings queued up for removal by
+        * acpi_deactivate_mem_region() to actually go away.
+        */
+       synchronize_rcu();
+       rcu_barrier();
+       flush_scheduled_work();
+
+       return AE_OK;
 }
 EXPORT_SYMBOL_GPL(acpi_release_memory);
 
index f936530..37a505c 100644 (file)
@@ -2344,8 +2344,6 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
                         * file is done when the transaction is torn
                         * down.
                         */
-                       WARN_ON(failed_at &&
-                               proc->tsk == current->group_leader);
                } break;
                case BINDER_TYPE_PTR:
                        /*
@@ -3136,7 +3134,7 @@ static void binder_transaction(struct binder_proc *proc,
 
        t->buffer = binder_alloc_new_buf(&target_proc->alloc, tr->data_size,
                tr->offsets_size, extra_buffers_size,
-               !reply && (t->flags & TF_ONE_WAY));
+               !reply && (t->flags & TF_ONE_WAY), current->tgid);
        if (IS_ERR(t->buffer)) {
                /*
                 * -ESRCH indicates VMA cleared. The target is dying.
index 6960969..2f846b7 100644 (file)
@@ -338,12 +338,50 @@ static inline struct vm_area_struct *binder_alloc_get_vma(
        return vma;
 }
 
+static void debug_low_async_space_locked(struct binder_alloc *alloc, int pid)
+{
+       /*
+        * Find the amount and size of buffers allocated by the current caller;
+        * The idea is that once we cross the threshold, whoever is responsible
+        * for the low async space is likely to try to send another async txn,
+        * and at some point we'll catch them in the act. This is more efficient
+        * than keeping a map per pid.
+        */
+       struct rb_node *n;
+       struct binder_buffer *buffer;
+       size_t total_alloc_size = 0;
+       size_t num_buffers = 0;
+
+       for (n = rb_first(&alloc->allocated_buffers); n != NULL;
+                n = rb_next(n)) {
+               buffer = rb_entry(n, struct binder_buffer, rb_node);
+               if (buffer->pid != pid)
+                       continue;
+               if (!buffer->async_transaction)
+                       continue;
+               total_alloc_size += binder_alloc_buffer_size(alloc, buffer)
+                       + sizeof(struct binder_buffer);
+               num_buffers++;
+       }
+
+       /*
+        * Warn if this pid has more than 50 transactions, or more than 50% of
+        * async space (which is 25% of total buffer size).
+        */
+       if (num_buffers > 50 || total_alloc_size > alloc->buffer_size / 4) {
+               binder_alloc_debug(BINDER_DEBUG_USER_ERROR,
+                            "%d: pid %d spamming oneway? %zd buffers allocated for a total size of %zd\n",
+                             alloc->pid, pid, num_buffers, total_alloc_size);
+       }
+}
+
 static struct binder_buffer *binder_alloc_new_buf_locked(
                                struct binder_alloc *alloc,
                                size_t data_size,
                                size_t offsets_size,
                                size_t extra_buffers_size,
-                               int is_async)
+                               int is_async,
+                               int pid)
 {
        struct rb_node *n = alloc->free_buffers.rb_node;
        struct binder_buffer *buffer;
@@ -486,11 +524,20 @@ static struct binder_buffer *binder_alloc_new_buf_locked(
        buffer->offsets_size = offsets_size;
        buffer->async_transaction = is_async;
        buffer->extra_buffers_size = extra_buffers_size;
+       buffer->pid = pid;
        if (is_async) {
                alloc->free_async_space -= size + sizeof(struct binder_buffer);
                binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
                             "%d: binder_alloc_buf size %zd async free %zd\n",
                              alloc->pid, size, alloc->free_async_space);
+               if (alloc->free_async_space < alloc->buffer_size / 10) {
+                       /*
+                        * Start detecting spammers once we have less than 20%
+                        * of async space left (which is less than 10% of total
+                        * buffer size).
+                        */
+                       debug_low_async_space_locked(alloc, pid);
+               }
        }
        return buffer;
 
@@ -508,6 +555,7 @@ err_alloc_buf_struct_failed:
  * @offsets_size:       user specified buffer offset
  * @extra_buffers_size: size of extra space for meta-data (eg, security context)
  * @is_async:           buffer for async transaction
+ * @pid:                               pid to attribute allocation to (used for debugging)
  *
  * Allocate a new buffer given the requested sizes. Returns
  * the kernel version of the buffer pointer. The size allocated
@@ -520,13 +568,14 @@ struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
                                           size_t data_size,
                                           size_t offsets_size,
                                           size_t extra_buffers_size,
-                                          int is_async)
+                                          int is_async,
+                                          int pid)
 {
        struct binder_buffer *buffer;
 
        mutex_lock(&alloc->mutex);
        buffer = binder_alloc_new_buf_locked(alloc, data_size, offsets_size,
-                                            extra_buffers_size, is_async);
+                                            extra_buffers_size, is_async, pid);
        mutex_unlock(&alloc->mutex);
        return buffer;
 }
@@ -652,7 +701,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,
  * @alloc:     binder_alloc for this proc
  * @buffer:    kernel pointer to buffer
  *
- * Free the buffer allocated via binder_alloc_new_buffer()
+ * Free the buffer allocated via binder_alloc_new_buf()
  */
 void binder_alloc_free_buf(struct binder_alloc *alloc,
                            struct binder_buffer *buffer)
index db9c1b9..55d8b41 100644 (file)
@@ -32,6 +32,7 @@ struct binder_transaction;
  * @offsets_size:       size of array of offsets
  * @extra_buffers_size: size of space for other objects (like sg lists)
  * @user_data:          user pointer to base of buffer space
+ * @pid:                pid to attribute the buffer to (caller)
  *
  * Bookkeeping structure for binder transaction buffers
  */
@@ -51,6 +52,7 @@ struct binder_buffer {
        size_t offsets_size;
        size_t extra_buffers_size;
        void __user *user_data;
+       int    pid;
 };
 
 /**
@@ -117,7 +119,8 @@ extern struct binder_buffer *binder_alloc_new_buf(struct binder_alloc *alloc,
                                                  size_t data_size,
                                                  size_t offsets_size,
                                                  size_t extra_buffers_size,
-                                                 int is_async);
+                                                 int is_async,
+                                                 int pid);
 extern void binder_alloc_init(struct binder_alloc *alloc);
 extern int binder_alloc_shrinker_init(void);
 extern void binder_alloc_vma_close(struct binder_alloc *alloc);
index 4151d99..c2b323b 100644 (file)
@@ -119,7 +119,7 @@ static void binder_selftest_alloc_buf(struct binder_alloc *alloc,
        int i;
 
        for (i = 0; i < BUFFER_NUM; i++) {
-               buffers[i] = binder_alloc_new_buf(alloc, sizes[i], 0, 0, 0);
+               buffers[i] = binder_alloc_new_buf(alloc, sizes[i], 0, 0, 0, 0);
                if (IS_ERR(buffers[i]) ||
                    !check_buffer_pages_allocated(alloc, buffers[i],
                                                  sizes[i])) {
index 7b76fef..7b4f154 100644 (file)
@@ -63,7 +63,7 @@ static const struct constant_table binderfs_param_stats[] = {
        {}
 };
 
-const struct fs_parameter_spec binderfs_fs_parameters[] = {
+static const struct fs_parameter_spec binderfs_fs_parameters[] = {
        fsparam_u32("max",      Opt_max),
        fsparam_enum("stats",   Opt_stats_mode, binderfs_param_stats),
        {}
index 0c0a736..fbd8eaa 100644 (file)
@@ -807,8 +807,7 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
                                (sstatus & 0xf) != 1)
                        break;
 
-               ata_link_printk(link, KERN_INFO, "avn bounce port%d\n",
-                               port);
+               ata_link_info(link,  "avn bounce port%d\n", port);
 
                pci_read_config_word(pdev, 0x92, &val);
                val &= ~(1 << port);
index 6853dbb..49f7acb 100644 (file)
@@ -470,7 +470,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
        switch (priv->version) {
        case BRCM_SATA_BCM7425:
                hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE;
-               /* fall through */
+               fallthrough;
        case BRCM_SATA_NSP:
                hpriv->flags |= AHCI_HFLAG_NO_NCQ;
                priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
index 129556f..86261de 100644 (file)
@@ -326,7 +326,7 @@ static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
                                node);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case -ENODEV:
                /* continue normally */
                hpriv->phys[port] = NULL;
index b1cd4d9..f546a57 100644 (file)
@@ -190,7 +190,7 @@ struct ata_link *ata_link_next(struct ata_link *link, struct ata_port *ap,
                case ATA_LITER_PMP_FIRST:
                        if (sata_pmp_attached(ap))
                                return ap->pmp_link;
-                       /* fall through */
+                       fallthrough;
                case ATA_LITER_HOST_FIRST:
                        return &ap->link;
                }
@@ -201,11 +201,11 @@ struct ata_link *ata_link_next(struct ata_link *link, struct ata_port *ap,
                case ATA_LITER_HOST_FIRST:
                        if (sata_pmp_attached(ap))
                                return ap->pmp_link;
-                       /* fall through */
+                       fallthrough;
                case ATA_LITER_PMP_FIRST:
                        if (unlikely(ap->slave_link))
                                return ap->slave_link;
-                       /* fall through */
+                       fallthrough;
                case ATA_LITER_EDGE:
                        return NULL;
                }
@@ -523,7 +523,7 @@ int atapi_cmd_type(u8 opcode)
        case ATA_12:
                if (atapi_passthru16)
                        return ATAPI_PASS_THRU;
-               /* fall thru */
+               fallthrough;
        default:
                return ATAPI_MISC;
        }
@@ -1800,7 +1800,7 @@ retry:
        switch (class) {
        case ATA_DEV_SEMB:
                class = ATA_DEV_ATA;    /* some hard drives report SEMB sig */
-               /* fall through */
+               fallthrough;
        case ATA_DEV_ATA:
        case ATA_DEV_ZAC:
                tf.command = ATA_CMD_ID_ATA;
@@ -2907,7 +2907,7 @@ int ata_bus_probe(struct ata_port *ap)
        case -ENODEV:
                /* give it just one more chance */
                tries[dev->devno] = min(tries[dev->devno], 1);
-               /* fall through */
+               fallthrough;
        case -EIO:
                if (tries[dev->devno] == 1) {
                        /* This is the last chance, better to slow
@@ -3158,7 +3158,7 @@ int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel)
 
        case ATA_DNXFER_FORCE_PIO0:
                pio_mask &= 1;
-               /* fall through */
+               fallthrough;
        case ATA_DNXFER_FORCE_PIO:
                mwdma_mask = 0;
                udma_mask = 0;
@@ -3868,9 +3868,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        /* https://bugzilla.kernel.org/show_bug.cgi?id=15573 */
        { "C300-CTFDDAC128MAG", "0001",         ATA_HORKAGE_NONCQ, },
 
-       /* Some Sandisk SSDs lock up hard with NCQ enabled.  Reported on
-          SD7SN6S256G and SD8SN8U256G */
-       { "SanDisk SD[78]SN*G", NULL,           ATA_HORKAGE_NONCQ, },
+       /* Sandisk SD7/8/9s lock up hard on large trims */
+       { "SanDisk SD[789]*",   NULL,           ATA_HORKAGE_MAX_TRIM_128M, },
 
        /* devices which puke on READ_NATIVE_MAX */
        { "HDS724040KLSA80",    "KFAOA20N",     ATA_HORKAGE_BROKEN_HPA, },
@@ -4694,7 +4693,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc)
                            qc->tf.feature != SETFEATURES_RA_ON &&
                            qc->tf.feature != SETFEATURES_RA_OFF)
                                break;
-                       /* fall through */
+                       fallthrough;
                case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
                case ATA_CMD_SET_MULTI: /* multi_count changed */
                        /* revalidate device */
index 474c6c3..d912eaa 100644 (file)
@@ -1576,7 +1576,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
        case ATA_DEV_ZAC:
                if (stat & ATA_SENSE)
                        ata_eh_request_sense(qc, qc->scsicmd);
-               /* fall through */
+               fallthrough;
        case ATA_DEV_ATA:
                if (err & ATA_ICRC)
                        qc->err_mask |= AC_ERR_ATA_BUS;
@@ -3473,11 +3473,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
        case -ENODEV:
                /* device missing or wrong IDENTIFY data, schedule probing */
                ehc->i.probe_mask |= (1 << dev->devno);
-               /* fall through */
+               fallthrough;
        case -EINVAL:
                /* give it just one more chance */
                ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
-               /* fall through */
+               fallthrough;
        case -EIO:
                if (ehc->tries[dev->devno] == 1) {
                        /* This is the last chance, better to slow
index ec23320..7043191 100644 (file)
@@ -2080,6 +2080,7 @@ static unsigned int ata_scsiop_inq_89(struct ata_scsi_args *args, u8 *rbuf)
 
 static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
 {
+       struct ata_device *dev = args->dev;
        u16 min_io_sectors;
 
        rbuf[1] = 0xb0;
@@ -2105,7 +2106,12 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
         * with the unmap bit set.
         */
        if (ata_id_has_trim(args->id)) {
-               put_unaligned_be64(65535 * ATA_MAX_TRIM_RNUM, &rbuf[36]);
+               u64 max_blocks = 65535 * ATA_MAX_TRIM_RNUM;
+
+               if (dev->horkage & ATA_HORKAGE_MAX_TRIM_128M)
+                       max_blocks = 128 << (20 - SECTOR_SHIFT);
+
+               put_unaligned_be64(max_blocks, &rbuf[36]);
                put_unaligned_be32(1, &rbuf[28]);
        }
 
@@ -4162,7 +4168,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
                                ata_scsi_rbuf_fill(&args, ata_scsiop_inq_b6);
                                break;
                        }
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
                        break;
@@ -4198,7 +4204,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)
         * turning this into a no-op.
         */
        case SYNCHRONIZE_CACHE:
-               /* fall through */
+               fallthrough;
 
        /* no-op's, complete with success */
        case REZERO_UNIT:
index e01a3a6..2bc5fc8 100644 (file)
@@ -157,7 +157,7 @@ static int atp867x_get_active_clocks_shifted(struct ata_port *ap,
        default:
                printk(KERN_WARNING "ATP867X: active %dclk is invalid. "
                        "Using 12clk.\n", clk);
-               /* fall through */
+               fallthrough;
        case 9 ... 12:
                clocks = 7;     /* 12 clk */
                break;
@@ -190,7 +190,7 @@ static int atp867x_get_recover_clocks_shifted(unsigned int clk)
        default:
                printk(KERN_WARNING "ATP867X: recover %dclk is invalid. "
                        "Using default 12clk.\n", clk);
-               /* fall through */
+               fallthrough;
        case 12:        /* default 12 clk */
                clocks = 0;
                break;
index 916bf02..7511e11 100644 (file)
@@ -369,7 +369,7 @@ static int serverworks_fixup(struct pci_dev *pdev)
                break;
        case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE:
                ata_pci_bmdma_clear_simplex(pdev);
-               /* fall through */
+               fallthrough;
        case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE:
        case PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2:
                rc = serverworks_fixup_csb(pdev);
index d7228f8..664ef65 100644 (file)
@@ -2010,7 +2010,7 @@ static void mv_rw_multi_errata_sata24(struct ata_queued_cmd *qc)
                                break;
                        case ATA_CMD_WRITE_MULTI_FUA_EXT:
                                tf->flags &= ~ATA_TFLAG_FUA; /* ugh */
-                               /* fall through */
+                               fallthrough;
                        case ATA_CMD_WRITE_MULTI_EXT:
                                tf->command = ATA_CMD_PIO_WRITE_EXT;
                                break;
@@ -2044,7 +2044,7 @@ static enum ata_completion_errors mv_qc_prep(struct ata_queued_cmd *qc)
        case ATA_PROT_DMA:
                if (tf->command == ATA_CMD_DSM)
                        return AC_ERR_OK;
-               /* fall-thru */
+               fallthrough;
        case ATA_PROT_NCQ:
                break;  /* continue below */
        case ATA_PROT_PIO:
@@ -2296,7 +2296,7 @@ static unsigned int mv_qc_issue_fis(struct ata_queued_cmd *qc)
        switch (qc->tf.protocol) {
        case ATAPI_PROT_PIO:
                pp->pp_flags |= MV_PP_FLAG_FAKE_ATA_BUSY;
-               /* fall through */
+               fallthrough;
        case ATAPI_PROT_NODATA:
                ap->hsm_task_state = HSM_ST_FIRST;
                break;
@@ -2347,7 +2347,7 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
                                return AC_ERR_OTHER;
                        break;  /* use bmdma for this */
                }
-               /* fall thru */
+               fallthrough;
        case ATA_PROT_NCQ:
                mv_start_edma(ap, port_mmio, pp, qc->tf.protocol);
                pp->req_idx = (pp->req_idx + 1) & MV_MAX_Q_DEPTH_MASK;
@@ -2376,7 +2376,7 @@ static unsigned int mv_qc_issue(struct ata_queued_cmd *qc)
                                      ": attempting PIO w/multiple DRQ: "
                                      "this may fail due to h/w errata\n");
                }
-               /* fall through */
+               fallthrough;
        case ATA_PROT_NODATA:
        case ATAPI_PROT_PIO:
        case ATAPI_PROT_NODATA:
@@ -3864,7 +3864,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
                                " and avoid the final two gigabytes on"
                                " all RocketRAID BIOS initialized drives.\n");
                }
-               /* fall through */
+               fallthrough;
        case chip_6042:
                hpriv->ops = &mv6xxx_ops;
                hp_flags |= MV_HP_GEN_IIE;
index 8729f78..7815da8 100644 (file)
@@ -637,7 +637,7 @@ static enum ata_completion_errors pdc_qc_prep(struct ata_queued_cmd *qc)
        switch (qc->tf.protocol) {
        case ATA_PROT_DMA:
                pdc_fill_sg(qc);
-               /*FALLTHROUGH*/
+               fallthrough;
        case ATA_PROT_NODATA:
                i = pdc_pkt_header(&qc->tf, qc->ap->bmdma_prd_dma,
                                   qc->dev->devno, pp->pkt);
@@ -652,7 +652,7 @@ static enum ata_completion_errors pdc_qc_prep(struct ata_queued_cmd *qc)
                break;
        case ATAPI_PROT_DMA:
                pdc_fill_sg(qc);
-               /*FALLTHROUGH*/
+               fallthrough;
        case ATAPI_PROT_NODATA:
                pdc_atapi_pkt(qc);
                break;
@@ -1022,11 +1022,11 @@ static unsigned int pdc_qc_issue(struct ata_queued_cmd *qc)
        case ATAPI_PROT_NODATA:
                if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
                        break;
-               /*FALLTHROUGH*/
+               fallthrough;
        case ATA_PROT_NODATA:
                if (qc->tf.flags & ATA_TFLAG_POLLING)
                        break;
-               /*FALLTHROUGH*/
+               fallthrough;
        case ATAPI_PROT_DMA:
        case ATA_PROT_DMA:
                pdc_packet_start(qc);
index 2c7b30c..4c01190 100644 (file)
@@ -669,7 +669,7 @@ static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc)
        case ATA_PROT_NODATA:
                if (qc->tf.flags & ATA_TFLAG_POLLING)
                        break;
-               /*FALLTHROUGH*/
+               fallthrough;
        case ATA_PROT_DMA:
                pdc20621_packet_start(qc);
                return 0;
index 2ca9ec8..0ddd611 100644 (file)
@@ -711,7 +711,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
 
                switch (STATUS_CODE (qe)) {
                case 0x01: /* This is for AAL0 where we put the chip in streaming mode */
-                       /* Fall through */
+                       fallthrough;
                case 0x02:
                        /* Process a real txdone entry. */
                        tmp = qe->p0;
@@ -998,6 +998,7 @@ static int fs_open(struct atm_vcc *atm_vcc)
                                error = make_rate (pcr, r, &tmc0, NULL);
                                if (error) {
                                        kfree(tc);
+                                       kfree(vcc);
                                        return error;
                                }
                        }
index a81bc49..9a70bee 100644 (file)
@@ -376,33 +376,33 @@ fore200e_shutdown(struct fore200e* fore200e)
     case FORE200E_STATE_COMPLETE:
        kfree(fore200e->stats);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_IRQ:
        free_irq(fore200e->irq, fore200e->atm_dev);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_ALLOC_BUF:
        fore200e_free_rx_buf(fore200e);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_INIT_BSQ:
        fore200e_uninit_bs_queue(fore200e);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_INIT_RXQ:
        fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.status);
        fore200e_dma_chunk_free(fore200e, &fore200e->host_rxq.rpd);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_INIT_TXQ:
        fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.status);
        fore200e_dma_chunk_free(fore200e, &fore200e->host_txq.tpd);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_INIT_CMDQ:
        fore200e_dma_chunk_free(fore200e, &fore200e->host_cmdq.status);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_INITIALIZE:
        /* nothing to do for that state */
 
@@ -415,7 +415,7 @@ fore200e_shutdown(struct fore200e* fore200e)
     case FORE200E_STATE_MAP:
        fore200e->bus->unmap(fore200e);
 
-       /* fall through */
+       fallthrough;
     case FORE200E_STATE_CONFIGURE:
        /* nothing to do for that state */
 
index 8af793f..17f44ab 100644 (file)
@@ -1944,14 +1944,14 @@ he_tasklet(unsigned long data)
                switch (type) {
                        case ITYPE_RBRQ_THRESH:
                                HPRINTK("rbrq%d threshold\n", group);
-                               /* fall through */
+                               fallthrough;
                        case ITYPE_RBRQ_TIMER:
                                if (he_service_rbrq(he_dev, group))
                                        he_service_rbpl(he_dev, group);
                                break;
                        case ITYPE_TBRQ_THRESH:
                                HPRINTK("tbrq%d threshold\n", group);
-                               /* fall through */
+                               fallthrough;
                        case ITYPE_TPD_COMPLETE:
                                he_service_tbrq(he_dev, group);
                                break;
index 6387185..3c081b6 100644 (file)
@@ -192,7 +192,7 @@ static int idt77105_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
        switch (cmd) {
                case IDT77105_GETSTATZ:
                        if (!capable(CAP_NET_ADMIN)) return -EPERM;
-                       /* fall through */
+                       fallthrough;
                case IDT77105_GETSTAT:
                        return fetch_stats(dev, arg, cmd == IDT77105_GETSTATZ);
                case ATM_SETLOOP:
index 986c131..ac811cf 100644 (file)
@@ -2019,7 +2019,7 @@ static int lanai_normalize_ci(struct lanai_dev *lanai,
        switch (*vpip) {
                case ATM_VPI_ANY:
                        *vpip = 0;
-                       /* FALLTHROUGH */
+                       fallthrough;
                case 0:
                        break;
                default:
index ee059c7..cf5fffc 100644 (file)
@@ -1447,7 +1447,7 @@ static int zatm_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
        switch (cmd) {
                case ZATM_GETPOOLZ:
                        if (!capable(CAP_NET_ADMIN)) return -EPERM;
-                       /* fall through */
+                       fallthrough;
                case ZATM_GETPOOL:
                        {
                                struct zatm_pool_info info;
index dea0314..0b1c99c 100644 (file)
@@ -2,7 +2,7 @@
 /*
  * Driver for the on-board character LCD found on some ARM reference boards
  * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it
- * http://en.wikipedia.org/wiki/HD44780_Character_LCD
+ * https://en.wikipedia.org/wiki/HD44780_Character_LCD
  * Currently it will just display the text "ARM Linux" and the linux version
  *
  * Author: Linus Walleij <triad@df.lth.se>
index 99980aa..1c82d82 100644 (file)
@@ -1365,7 +1365,7 @@ static void panel_process_inputs(void)
                                break;
                        input->rise_timer = 0;
                        input->state = INPUT_ST_RISING;
-                       /* fall through */
+                       fallthrough;
                case INPUT_ST_RISING:
                        if ((phys_curr & input->mask) != input->value) {
                                input->state = INPUT_ST_LOW;
@@ -1378,11 +1378,11 @@ static void panel_process_inputs(void)
                        }
                        input->high_timer = 0;
                        input->state = INPUT_ST_HIGH;
-                       /* fall through */
+                       fallthrough;
                case INPUT_ST_HIGH:
                        if (input_state_high(input))
                                break;
-                       /* fall through */
+                       fallthrough;
                case INPUT_ST_FALLING:
                        input_state_falling(input);
                }
index ac1046a..bb5806a 100644 (file)
@@ -807,9 +807,7 @@ static void device_link_put_kref(struct device_link *link)
 void device_link_del(struct device_link *link)
 {
        device_links_write_lock();
-       device_pm_lock();
        device_link_put_kref(link);
-       device_pm_unlock();
        device_links_write_unlock();
 }
 EXPORT_SYMBOL_GPL(device_link_del);
@@ -830,7 +828,6 @@ void device_link_remove(void *consumer, struct device *supplier)
                return;
 
        device_links_write_lock();
-       device_pm_lock();
 
        list_for_each_entry(link, &supplier->links.consumers, s_node) {
                if (link->consumer == consumer) {
@@ -839,7 +836,6 @@ void device_link_remove(void *consumer, struct device *supplier)
                }
        }
 
-       device_pm_unlock();
        device_links_write_unlock();
 }
 EXPORT_SYMBOL_GPL(device_link_remove);
@@ -4237,10 +4233,10 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
        vaf.va = &args;
 
        if (err != -EPROBE_DEFER) {
-               dev_err(dev, "error %d: %pV", err, &vaf);
+               dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
        } else {
                device_set_deferred_probe_reason(dev, &vaf);
-               dev_dbg(dev, "error %d: %pV", err, &vaf);
+               dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
        }
 
        va_end(args);
@@ -4264,9 +4260,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
  */
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 {
-       if (fwnode) {
-               struct fwnode_handle *fn = dev->fwnode;
+       struct fwnode_handle *fn = dev->fwnode;
 
+       if (fwnode) {
                if (fwnode_is_primary(fn))
                        fn = fn->secondary;
 
@@ -4276,8 +4272,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
                }
                dev->fwnode = fwnode;
        } else {
-               dev->fwnode = fwnode_is_primary(dev->fwnode) ?
-                       dev->fwnode->secondary : NULL;
+               if (fwnode_is_primary(fn)) {
+                       dev->fwnode = fn->secondary;
+                       fn->secondary = NULL;
+               } else {
+                       dev->fwnode = NULL;
+               }
        }
 }
 EXPORT_SYMBOL_GPL(set_primary_fwnode);
index 5327bfc..283ca2d 100644 (file)
@@ -289,10 +289,10 @@ static ssize_t firmware_loading_store(struct device *dev,
                        }
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        default:
                dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
-               /* fallthrough */
+               fallthrough;
        case -1:
                fw_load_abort(fw_sysfs);
                break;
index 933e219..d08efc7 100644 (file)
@@ -142,10 +142,12 @@ int assign_fw(struct firmware *fw, struct device *device, u32 opt_flags);
 void fw_free_paged_buf(struct fw_priv *fw_priv);
 int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed);
 int fw_map_paged_buf(struct fw_priv *fw_priv);
+bool fw_is_paged_buf(struct fw_priv *fw_priv);
 #else
 static inline void fw_free_paged_buf(struct fw_priv *fw_priv) {}
 static inline int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed) { return -ENXIO; }
 static inline int fw_map_paged_buf(struct fw_priv *fw_priv) { return -ENXIO; }
+static inline bool fw_is_paged_buf(struct fw_priv *fw_priv) { return false; }
 #endif
 
 #endif /* __FIRMWARE_LOADER_H */
index 9da0c9d..63b9714 100644 (file)
@@ -252,9 +252,11 @@ static void __free_fw_priv(struct kref *ref)
        list_del(&fw_priv->list);
        spin_unlock(&fwc->lock);
 
-       fw_free_paged_buf(fw_priv); /* free leftover pages */
-       if (!fw_priv->allocated_size)
+       if (fw_is_paged_buf(fw_priv))
+               fw_free_paged_buf(fw_priv);
+       else if (!fw_priv->allocated_size)
                vfree(fw_priv->data);
+
        kfree_const(fw_priv->fw_name);
        kfree(fw_priv);
 }
@@ -268,6 +270,11 @@ static void free_fw_priv(struct fw_priv *fw_priv)
 }
 
 #ifdef CONFIG_FW_LOADER_PAGED_BUF
+bool fw_is_paged_buf(struct fw_priv *fw_priv)
+{
+       return fw_priv->is_paged_buf;
+}
+
 void fw_free_paged_buf(struct fw_priv *fw_priv)
 {
        int i;
@@ -275,6 +282,8 @@ void fw_free_paged_buf(struct fw_priv *fw_priv)
        if (!fw_priv->pages)
                return;
 
+       vunmap(fw_priv->data);
+
        for (i = 0; i < fw_priv->nr_pages; i++)
                __free_page(fw_priv->pages[i]);
        kvfree(fw_priv->pages);
@@ -328,10 +337,6 @@ int fw_map_paged_buf(struct fw_priv *fw_priv)
        if (!fw_priv->data)
                return -ENOMEM;
 
-       /* page table is no longer needed after mapping, let's free */
-       kvfree(fw_priv->pages);
-       fw_priv->pages = NULL;
-
        return 0;
 }
 #endif
index 9dd85be..205a067 100644 (file)
@@ -1606,13 +1606,17 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
        }
 
        /*
-        * If a device configured to wake up the system from sleep states
-        * has been suspended at run time and there's a resume request pending
-        * for it, this is equivalent to the device signaling wakeup, so the
-        * system suspend operation should be aborted.
+        * Wait for possible runtime PM transitions of the device in progress
+        * to complete and if there's a runtime resume request pending for it,
+        * resume it before proceeding with invoking the system-wide suspend
+        * callbacks for it.
+        *
+        * If the system-wide suspend callbacks below change the configuration
+        * of the device, they must disable runtime PM for it or otherwise
+        * ensure that its runtime-resume callbacks will not be confused by that
+        * change in case they are invoked going forward.
         */
-       if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
-               pm_wakeup_event(dev, 0);
+       pm_runtime_barrier(dev);
 
        if (pm_wakeup_pending()) {
                dev->power.direct_complete = false;
index 3cf9bc5..6dba413 100644 (file)
@@ -1135,7 +1135,7 @@ noskb:            if (buf)
                        break;
                }
                bvcpy(skb, f->buf->bio, f->iter, n);
-               /* fall through */
+               fallthrough;
        case ATA_CMD_PIO_WRITE:
        case ATA_CMD_PIO_WRITE_EXT:
                spin_lock_irq(&d->lock);
index 1553d41..a50e13a 100644 (file)
@@ -1726,7 +1726,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
                /* MSch: invalidate default_params */
                default_params[drive].blocks  = 0;
                set_capacity(floppy->disk, MAX_DISK_SIZE * 2);
-               /* Fall through */
+               fallthrough;
        case FDFMTEND:
        case FDFLUSH:
                /* invalidate the buffer track to force a reread */
index fe6cb99..740e93b 100644 (file)
@@ -1733,7 +1733,7 @@ static inline void __drbd_chk_io_error_(struct drbd_device *device,
                                _drbd_set_state(_NS(device, disk, D_INCONSISTENT), CS_HARD, NULL);
                        break;
                }
-               /* fall through - for DRBD_META_IO_ERROR or DRBD_FORCE_DETACH */
+               fallthrough;    /* for DRBD_META_IO_ERROR or DRBD_FORCE_DETACH */
        case EP_DETACH:
        case EP_CALL_HELPER:
                /* Remember whether we saw a READ or WRITE error.
index cb687cc..04b6bde 100644 (file)
@@ -430,7 +430,7 @@ int drbd_thread_start(struct drbd_thread *thi)
                thi->t_state = RESTARTING;
                drbd_info(resource, "Restarting %s thread (from %s [%d])\n",
                                thi->name, current->comm, current->pid);
-               /* fall through */
+               fallthrough;
        case RUNNING:
        case RESTARTING:
        default:
index 28eb078..43c8ae4 100644 (file)
@@ -3883,7 +3883,7 @@ static int nla_put_status_info(struct sk_buff *skb, struct drbd_device *device,
                        if (nla_put_u32(skb, T_helper_exit_code,
                                        sib->helper_exit_code))
                                goto nla_put_failure;
-                       /* fall through */
+                       fallthrough;
                case SIB_HELPER_PRE:
                        if (nla_put_string(skb, T_helper, sib->helper_name))
                                goto nla_put_failure;
index 1d17593..422363d 100644 (file)
@@ -1797,7 +1797,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
                        break;
                else
                        drbd_warn(connection, "Allocation of an epoch failed, slowing down\n");
-                       /* Fall through */
+               fallthrough;
 
        case WO_BDEV_FLUSH:
        case WO_DRAIN_IO:
@@ -2917,7 +2917,7 @@ static int receive_DataRequest(struct drbd_connection *connection, struct packet
                   then we would do something smarter here than reading
                   the block... */
                peer_req->flags |= EE_RS_THIN_REQ;
-               /* fall through */
+               fallthrough;
        case P_RS_DATA_REQUEST:
                peer_req->w.cb = w_e_end_rsdata_req;
                fault_type = DRBD_FAULT_RS_RD;
@@ -3083,7 +3083,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
                        rv =  1;
                        break;
                }
-               /* Else fall through - to one of the other strategies... */
+               fallthrough;    /* to one of the other strategies */
        case ASB_DISCARD_OLDER_PRI:
                if (self == 0 && peer == 1) {
                        rv = 1;
@@ -3096,7 +3096,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
                /* Else fall through to one of the other strategies... */
                drbd_warn(device, "Discard younger/older primary did not find a decision\n"
                     "Using discard-least-changes instead\n");
-               /* fall through */
+               fallthrough;
        case ASB_DISCARD_ZERO_CHG:
                if (ch_peer == 0 && ch_self == 0) {
                        rv = test_bit(RESOLVE_CONFLICTS, &peer_device->connection->flags)
@@ -3108,7 +3108,7 @@ static int drbd_asb_recover_0p(struct drbd_peer_device *peer_device) __must_hold
                }
                if (after_sb_0p == ASB_DISCARD_ZERO_CHG)
                        break;
-               /* else, fall through */
+               fallthrough;
        case ASB_DISCARD_LEAST_CHG:
                if      (ch_self < ch_peer)
                        rv = -1;
@@ -3608,7 +3608,7 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_peer_device *peer_device,
                switch (rr_conflict) {
                case ASB_CALL_HELPER:
                        drbd_khelper(device, "pri-lost");
-                       /* fall through */
+                       fallthrough;
                case ASB_DISCONNECT:
                        drbd_err(device, "I shall become SyncTarget, but I am primary!\n");
                        return C_MASK;
index 674be09..5c975af 100644 (file)
@@ -611,7 +611,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
                drbd_set_out_of_sync(device, req->i.sector, req->i.size);
                drbd_report_io_error(device, req);
                __drbd_chk_io_error(device, DRBD_READ_ERROR);
-               /* fall through. */
+               fallthrough;
        case READ_AHEAD_COMPLETED_WITH_ERROR:
                /* it is legal to fail read-ahead, no __drbd_chk_io_error in that case. */
                mod_rq_state(req, m, RQ_LOCAL_PENDING, RQ_LOCAL_COMPLETED);
@@ -836,7 +836,7 @@ int __req_mod(struct drbd_request *req, enum drbd_req_event what,
                        } /* else: FIXME can this happen? */
                        break;
                }
-               /* else, fall through - to BARRIER_ACKED */
+               fallthrough;    /* to BARRIER_ACKED */
 
        case BARRIER_ACKED:
                /* barrier ack for READ requests does not make sense */
index 09079ae..a563b02 100644 (file)
@@ -1680,7 +1680,7 @@ static void recal_interrupt(void)
                        clear_bit(FD_DISK_NEWCHANGE_BIT,
                                  &drive_state[current_drive].flags);
                        drive_state[current_drive].select_date = jiffies;
-                       /* fall through */
+                       fallthrough;
                default:
                        debugt(__func__, "default");
                        /* Recalibrate moves the head by at
@@ -3592,7 +3592,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
                        return -EINTR;
                process_fd_request();
-               /* fall through */
+               fallthrough;
        case FDGETDRVSTAT:
                outparam = &drive_state[drive];
                break;
index 2f137d6..d339419 100644 (file)
@@ -878,6 +878,7 @@ static void loop_config_discard(struct loop_device *lo)
        struct file *file = lo->lo_backing_file;
        struct inode *inode = file->f_mapping->host;
        struct request_queue *q = lo->lo_queue;
+       u32 granularity, max_discard_sectors;
 
        /*
         * If the backing device is a block device, mirror its zeroing
@@ -890,11 +891,10 @@ static void loop_config_discard(struct loop_device *lo)
                struct request_queue *backingq;
 
                backingq = bdev_get_queue(inode->i_bdev);
-               blk_queue_max_discard_sectors(q,
-                       backingq->limits.max_write_zeroes_sectors);
 
-               blk_queue_max_write_zeroes_sectors(q,
-                       backingq->limits.max_write_zeroes_sectors);
+               max_discard_sectors = backingq->limits.max_write_zeroes_sectors;
+               granularity = backingq->limits.discard_granularity ?:
+                       queue_physical_block_size(backingq);
 
        /*
         * We use punch hole to reclaim the free space used by the
@@ -903,23 +903,26 @@ static void loop_config_discard(struct loop_device *lo)
         * useful information.
         */
        } else if (!file->f_op->fallocate || lo->lo_encrypt_key_size) {
-               q->limits.discard_granularity = 0;
-               q->limits.discard_alignment = 0;
-               blk_queue_max_discard_sectors(q, 0);
-               blk_queue_max_write_zeroes_sectors(q, 0);
+               max_discard_sectors = 0;
+               granularity = 0;
 
        } else {
-               q->limits.discard_granularity = inode->i_sb->s_blocksize;
-               q->limits.discard_alignment = 0;
-
-               blk_queue_max_discard_sectors(q, UINT_MAX >> 9);
-               blk_queue_max_write_zeroes_sectors(q, UINT_MAX >> 9);
+               max_discard_sectors = UINT_MAX >> 9;
+               granularity = inode->i_sb->s_blocksize;
        }
 
-       if (q->limits.max_write_zeroes_sectors)
+       if (max_discard_sectors) {
+               q->limits.discard_granularity = granularity;
+               blk_queue_max_discard_sectors(q, max_discard_sectors);
+               blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
                blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
-       else
+       } else {
+               q->limits.discard_granularity = 0;
+               blk_queue_max_discard_sectors(q, 0);
+               blk_queue_max_write_zeroes_sectors(q, 0);
                blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q);
+       }
+       q->limits.discard_alignment = 0;
 }
 
 static void loop_unprepare_queue(struct loop_device *lo)
@@ -1111,8 +1114,6 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
        mapping = file->f_mapping;
        inode = mapping->host;
 
-       size = get_loop_size(lo, file);
-
        if ((config->info.lo_flags & ~LOOP_CONFIGURE_SETTABLE_FLAGS) != 0) {
                error = -EINVAL;
                goto out_unlock;
@@ -1162,6 +1163,8 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
        loop_update_rotational(lo);
        loop_update_dio(lo);
        loop_sysfs_init(lo);
+
+       size = get_loop_size(lo, file);
        loop_set_size(lo, size);
 
        set_blocksize(bdev, S_ISBLK(inode->i_mode) ?
@@ -1719,7 +1722,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
        case LOOP_SET_BLOCK_SIZE:
                if (!(mode & FMODE_WRITE) && !capable(CAP_SYS_ADMIN))
                        return -EPERM;
-               /* Fall through */
+               fallthrough;
        default:
                err = lo_simple_ioctl(lo, cmd, arg);
                break;
@@ -1867,7 +1870,7 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,
        case LOOP_SET_STATUS64:
        case LOOP_CONFIGURE:
                arg = (unsigned long) compat_ptr(arg);
-               /* fall through */
+               fallthrough;
        case LOOP_SET_FD:
        case LOOP_CHANGE_FD:
        case LOOP_SET_BLOCK_SIZE:
index 3ff4054..edf8b63 100644 (file)
@@ -1363,6 +1363,8 @@ static void nbd_set_cmd_timeout(struct nbd_device *nbd, u64 timeout)
        nbd->tag_set.timeout = timeout * HZ;
        if (timeout)
                blk_queue_rq_timeout(nbd->disk->queue, timeout * HZ);
+       else
+               blk_queue_rq_timeout(nbd->disk->queue, 30 * HZ);
 }
 
 /* Must be called with config_lock held */
index 47a9dad..d74443a 100644 (file)
@@ -1147,7 +1147,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
                len = bvec.bv_len;
                err = null_transfer(nullb, bvec.bv_page, len, bvec.bv_offset,
                                     op_is_write(req_op(rq)), sector,
-                                    req_op(rq) & REQ_FUA);
+                                    rq->cmd_flags & REQ_FUA);
                if (err) {
                        spin_unlock_irq(&nullb->lock);
                        return err;
index c096750..a7af4f2 100644 (file)
@@ -440,7 +440,7 @@ static void run_fsm(void)
                                pd_claimed = 1;
                                if (!pi_schedule_claimed(pi_current, run_fsm))
                                        return;
-                               /* fall through */
+                               fallthrough;
                        case 1:
                                pd_claimed = 2;
                                pi_current->proto->connect(pi_current);
@@ -465,7 +465,7 @@ static void run_fsm(void)
                                if (stop)
                                        return;
                                }
-                               /* fall through */
+                               fallthrough;
                        case Hold:
                                schedule_fsm();
                                return;
index 4becc1e..1034e44 100644 (file)
@@ -2641,7 +2641,7 @@ static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
                 */
                if (pd->refcnt == 1)
                        pkt_lock_door(pd, 0);
-               /* fall through */
+               fallthrough;
        /*
         * forward selected CDROM ioctls to CD-ROM, for UDF
         */
index d9c0e7d..e77eaab 100644 (file)
@@ -3293,7 +3293,7 @@ again:
        case __RBD_OBJ_COPYUP_OBJECT_MAPS:
                if (!pending_result_dec(&obj_req->pending, result))
                        return false;
-               /* fall through */
+               fallthrough;
        case RBD_OBJ_COPYUP_OBJECT_MAPS:
                if (*result) {
                        rbd_warn(rbd_dev, "snap object map update failed: %d",
@@ -3312,7 +3312,7 @@ again:
        case __RBD_OBJ_COPYUP_WRITE_OBJECT:
                if (!pending_result_dec(&obj_req->pending, result))
                        return false;
-               /* fall through */
+               fallthrough;
        case RBD_OBJ_COPYUP_WRITE_OBJECT:
                return true;
        default:
@@ -3399,7 +3399,7 @@ again:
        case __RBD_OBJ_WRITE_COPYUP:
                if (!rbd_obj_advance_copyup(obj_req, result))
                        return false;
-               /* fall through */
+               fallthrough;
        case RBD_OBJ_WRITE_COPYUP:
                if (*result) {
                        rbd_warn(rbd_dev, "copyup failed: %d", *result);
@@ -3592,7 +3592,7 @@ again:
        case __RBD_IMG_OBJECT_REQUESTS:
                if (!pending_result_dec(&img_req->pending, result))
                        return false;
-               /* fall through */
+               fallthrough;
        case RBD_IMG_OBJECT_REQUESTS:
                return true;
        default:
@@ -5120,6 +5120,9 @@ static ssize_t rbd_config_info_show(struct device *dev,
 {
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
        return sprintf(buf, "%s\n", rbd_dev->config_info);
 }
 
@@ -5231,6 +5234,9 @@ static ssize_t rbd_image_refresh(struct device *dev,
        struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
        int ret;
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
        ret = rbd_dev_refresh(rbd_dev);
        if (ret)
                return ret;
@@ -7059,6 +7065,9 @@ static ssize_t do_rbd_add(struct bus_type *bus,
        struct rbd_client *rbdc;
        int rc;
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
        if (!try_module_get(THIS_MODULE))
                return -ENODEV;
 
@@ -7209,6 +7218,9 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
        bool force = false;
        int ret;
 
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
        dev_id = -1;
        opt_buf[0] = '\0';
        sscanf(buf, "%d %5s", &dev_id, opt_buf);
index 0fb9484..e1bc8b4 100644 (file)
@@ -148,7 +148,8 @@ static int process_rdma(struct rtrs_srv *sess,
        /* Generate bio with pages pointing to the rdma buffer */
        bio = rnbd_bio_map_kern(data, sess_dev->rnbd_dev->ibd_bio_set, datalen, GFP_KERNEL);
        if (IS_ERR(bio)) {
-               rnbd_srv_err(sess_dev, "Failed to generate bio, err: %ld\n", PTR_ERR(bio));
+               err = PTR_ERR(bio);
+               rnbd_srv_err(sess_dev, "Failed to generate bio, err: %d\n", err);
                goto sess_dev_put;
        }
 
index 7e26122..8799e3b 100644 (file)
@@ -425,7 +425,7 @@ static void card_state_change(struct rsxx_cardinfo *card,
                 * Fall through so the DMA devices can be attached and
                 * the user can attempt to pull off their data.
                 */
-               /* fall through */
+               fallthrough;
        case CARD_STATE_GOOD:
                st = rsxx_get_card_size8(card, &card->size8);
                if (st)
index 3a476dc..ae6454c 100644 (file)
@@ -1436,7 +1436,7 @@ static void skd_resolve_req_exception(struct skd_device *skdev,
                        blk_mq_requeue_request(req, true);
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case SKD_CHECK_STATUS_REPORT_ERROR:
        default:
index 63b213e..b2e48da 100644 (file)
@@ -126,16 +126,31 @@ static int virtblk_setup_discard_write_zeroes(struct request *req, bool unmap)
        if (!range)
                return -ENOMEM;
 
-       __rq_for_each_bio(bio, req) {
-               u64 sector = bio->bi_iter.bi_sector;
-               u32 num_sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT;
-
-               range[n].flags = cpu_to_le32(flags);
-               range[n].num_sectors = cpu_to_le32(num_sectors);
-               range[n].sector = cpu_to_le64(sector);
-               n++;
+       /*
+        * Single max discard segment means multi-range discard isn't
+        * supported, and block layer only runs contiguity merge like
+        * normal RW request. So we can't reply on bio for retrieving
+        * each range info.
+        */
+       if (queue_max_discard_segments(req->q) == 1) {
+               range[0].flags = cpu_to_le32(flags);
+               range[0].num_sectors = cpu_to_le32(blk_rq_sectors(req));
+               range[0].sector = cpu_to_le64(blk_rq_pos(req));
+               n = 1;
+       } else {
+               __rq_for_each_bio(bio, req) {
+                       u64 sector = bio->bi_iter.bi_sector;
+                       u32 num_sectors = bio->bi_iter.bi_size >> SECTOR_SHIFT;
+
+                       range[n].flags = cpu_to_le32(flags);
+                       range[n].num_sectors = cpu_to_le32(num_sectors);
+                       range[n].sector = cpu_to_le64(sector);
+                       n++;
+               }
        }
 
+       WARN_ON_ONCE(n != segments);
+
        req->special_vec.bv_page = virt_to_page(range);
        req->special_vec.bv_offset = offset_in_page(range);
        req->special_vec.bv_len = sizeof(*range) * segments;
index c2f7126..adfc935 100644 (file)
@@ -1260,7 +1260,7 @@ static int dispatch_rw_block_io(struct xen_blkif_ring *ring,
                break;
        case BLKIF_OP_WRITE_BARRIER:
                drain = true;
-               /* fall through */
+               fallthrough;
        case BLKIF_OP_FLUSH_DISKCACHE:
                ring->st_f_req++;
                operation = REQ_OP_WRITE;
index 42944d4..b9aa5d1 100644 (file)
@@ -843,7 +843,7 @@ static void frontend_changed(struct xenbus_device *dev,
                xenbus_switch_state(dev, XenbusStateClosed);
                if (xenbus_dev_is_online(dev))
                        break;
-               /* fall through */
+               fallthrough;
                /* if not online */
        case XenbusStateUnknown:
                /* implies xen_blkif_disconnect() via xen_blkbk_remove() */
index 3bb3dd8..91de2e0 100644 (file)
@@ -1403,7 +1403,6 @@ static enum blk_req_status blkif_rsp_to_req_status(int rsp)
        case BLKIF_RSP_EOPNOTSUPP:
                return REQ_EOPNOTSUPP;
        case BLKIF_RSP_ERROR:
-               /* Fallthrough. */
        default:
                return REQ_ERROR;
        }
@@ -1643,7 +1642,7 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
                                info->feature_flush = 0;
                                xlvbd_flush(info);
                        }
-                       /* fall through */
+                       fallthrough;
                case BLKIF_OP_READ:
                case BLKIF_OP_WRITE:
                        if (unlikely(bret->status != BLKIF_RSP_OKAY))
@@ -2484,7 +2483,7 @@ static void blkback_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* fall through */
+               fallthrough;
        case XenbusStateClosing:
                if (info)
                        blkfront_closing(info);
index fb5a901..efb088d 100644 (file)
@@ -1849,7 +1849,7 @@ static int sysc_clockdomain_init(struct sysc *ddata)
        switch (ddata->nr_clocks) {
        case 2:
                ick = ddata->clocks[SYSC_ICK];
-               /* fallthrough */
+               fallthrough;
        case 1:
                fck = ddata->clocks[SYSC_FCK];
                break;
index b1bd336..d229a2d 100644 (file)
@@ -93,8 +93,9 @@ config PPDEV
 
 config VIRTIO_CONSOLE
        tristate "Virtio console"
-       depends on VIRTIO && TTY
+       depends on TTY
        select HVC_DRIVER
+       select VIRTIO
        help
          Virtio console for use with hypervisors.
 
index 89527ba..760d9a9 100644 (file)
@@ -357,7 +357,7 @@ found:
                default:
                        break;
                }
-               /*FALLTHROUGH*/
+               fallthrough;
        default:
                bridge->driver = &ali_generic_bridge;
        }
index d704cef..055cfe5 100644 (file)
@@ -92,8 +92,7 @@ static int ingenic_rng_probe(struct platform_device *pdev)
        priv->base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(priv->base)) {
                pr_err("%s: Failed to map RNG registers\n", __func__);
-               ret = PTR_ERR(priv->base);
-               goto err_free_rng;
+               return PTR_ERR(priv->base);
        }
 
        priv->version = (enum ingenic_rng_version)of_device_get_match_data(&pdev->dev);
@@ -106,17 +105,13 @@ static int ingenic_rng_probe(struct platform_device *pdev)
        ret = hwrng_register(&priv->rng);
        if (ret) {
                dev_err(&pdev->dev, "Failed to register hwrng\n");
-               goto err_free_rng;
+               return ret;
        }
 
        platform_set_drvdata(pdev, priv);
 
        dev_info(&pdev->dev, "Ingenic RNG driver registered\n");
        return 0;
-
-err_free_rng:
-       kfree(priv);
-       return ret;
 }
 
 static int ingenic_rng_remove(struct platform_device *pdev)
index ed4dc3b..f292e74 100644 (file)
@@ -99,7 +99,7 @@ static void kcs_bmc_handle_data(struct kcs_bmc *kcs_bmc)
        switch (kcs_bmc->phase) {
        case KCS_PHASE_WRITE_START:
                kcs_bmc->phase = KCS_PHASE_WRITE_DATA;
-               /* fall through */
+               fallthrough;
 
        case KCS_PHASE_WRITE_DATA:
                if (kcs_bmc->data_in_idx < KCS_MSG_BUFSIZ) {
index bd95aba..0ec7391 100644 (file)
@@ -734,7 +734,7 @@ static long lp_ioctl(struct file *file, unsigned int cmd,
                        ret = lp_set_timeout32(minor, (void __user *)arg);
                        break;
                }
-               /* fall through - for 64-bit */
+               fallthrough;    /* for 64-bit */
        case LPSETTIMEOUT_NEW:
                ret = lp_set_timeout64(minor, (void __user *)arg);
                break;
@@ -762,7 +762,7 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd,
                        ret = lp_set_timeout32(minor, (void __user *)arg);
                        break;
                }
-               /* fall through - for x32 mode */
+               fallthrough;    /* for x32 mode */
        case LPSETTIMEOUT_NEW:
                ret = lp_set_timeout64(minor, (void __user *)arg);
                break;
@@ -853,8 +853,10 @@ static void lp_console_write(struct console *co, const char *s,
                        count--;
                        do {
                                written = parport_write(port, crlf, i);
-                               if (written > 0)
-                                       i -= written, crlf += written;
+                               if (written > 0) {
+                                       i -= written;
+                                       crlf += written;
+                               }
                        } while (i > 0 && (CONSOLE_LP_STRICT || written > 0));
                }
        } while (count > 0 && (CONSOLE_LP_STRICT || written > 0));
index 687d4af..94c2b55 100644 (file)
@@ -726,6 +726,33 @@ static ssize_t read_iter_zero(struct kiocb *iocb, struct iov_iter *iter)
        return written;
 }
 
+static ssize_t read_zero(struct file *file, char __user *buf,
+                        size_t count, loff_t *ppos)
+{
+       size_t cleared = 0;
+
+       while (count) {
+               size_t chunk = min_t(size_t, count, PAGE_SIZE);
+               size_t left;
+
+               left = clear_user(buf + cleared, chunk);
+               if (unlikely(left)) {
+                       cleared += (chunk - left);
+                       if (!cleared)
+                               return -EFAULT;
+                       break;
+               }
+               cleared += chunk;
+               count -= chunk;
+
+               if (signal_pending(current))
+                       break;
+               cond_resched();
+       }
+
+       return cleared;
+}
+
 static int mmap_zero(struct file *file, struct vm_area_struct *vma)
 {
 #ifndef CONFIG_MMU
@@ -791,7 +818,7 @@ static loff_t memory_lseek(struct file *file, loff_t offset, int orig)
        switch (orig) {
        case SEEK_CUR:
                offset += file->f_pos;
-               /* fall through */
+               fallthrough;
        case SEEK_SET:
                /* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
                if ((unsigned long long)offset >= -MAX_ERRNO) {
@@ -921,6 +948,7 @@ static const struct file_operations zero_fops = {
        .llseek         = zero_lseek,
        .write          = write_zero,
        .read_iter      = read_iter_zero,
+       .read           = read_zero,
        .write_iter     = write_iter_zero,
        .mmap           = mmap_zero,
        .get_unmapped_area = get_unmapped_area_zero,
index 0fae333..f8231e2 100644 (file)
@@ -195,10 +195,7 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
 
        pages = vma_pages(vma);
        vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
-       if (vdata_size <= PAGE_SIZE)
-               vdata = kzalloc(vdata_size, GFP_KERNEL);
-       else
-               vdata = vzalloc(vdata_size);
+       vdata = kvzalloc(vdata_size, GFP_KERNEL);
        if (!vdata)
                return -ENOMEM;
 
index 8206412..e9f694b 100644 (file)
@@ -286,7 +286,7 @@ static long nvram_misc_ioctl(struct file *file, unsigned int cmd,
 #ifdef CONFIG_PPC
        case OBSOLETE_PMAC_NVRAM_GET_OFFSET:
                pr_warn("nvram: Using obsolete PMAC_NVRAM_GET_OFFSET ioctl\n");
-               /* fall through */
+               fallthrough;
        case IOC_NVRAM_GET_OFFSET:
                ret = -EINVAL;
 #ifdef CONFIG_PPC_PMAC
index 3576ad7..68b087b 100644 (file)
@@ -653,9 +653,8 @@ config ATCPIT100_TIMER
          This option enables support for the Andestech ATCPIT100 timers.
 
 config RISCV_TIMER
-       bool "Timer for the RISC-V platform"
+       bool "Timer for the RISC-V platform" if COMPILE_TEST
        depends on GENERIC_SCHED_CLOCK && RISCV
-       default y
        select TIMER_PROBE
        select TIMER_OF
        help
@@ -663,6 +662,15 @@ config RISCV_TIMER
          is accessed via both the SBI and the rdcycle instruction.  This is
          required for all RISC-V systems.
 
+config CLINT_TIMER
+       bool "CLINT Timer for the RISC-V platform" if COMPILE_TEST
+       depends on GENERIC_SCHED_CLOCK && RISCV
+       select TIMER_PROBE
+       select TIMER_OF
+       help
+         This option enables the CLINT timer for RISC-V systems.  The CLINT
+         driver is usually used for NoMMU RISC-V systems.
+
 config CSKY_MP_TIMER
        bool "SMP Timer for the C-SKY platform" if COMPILE_TEST
        depends on CSKY
index eaedb72..1c444cc 100644 (file)
@@ -89,6 +89,7 @@ obj-$(CONFIG_CLKSRC_ST_LPC)           += clksrc_st_lpc.o
 obj-$(CONFIG_X86_NUMACHIP)             += numachip.o
 obj-$(CONFIG_ATCPIT100_TIMER)          += timer-atcpit100.o
 obj-$(CONFIG_RISCV_TIMER)              += timer-riscv.o
+obj-$(CONFIG_CLINT_TIMER)              += timer-clint.o
 obj-$(CONFIG_CSKY_MP_TIMER)            += timer-mp-csky.o
 obj-$(CONFIG_GX6605S_TIMER)            += timer-gx6605s.o
 obj-$(CONFIG_HYPERV_TIMER)             += hyperv_timer.o
index 38858e1..80e9606 100644 (file)
@@ -309,7 +309,7 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
                /* restore original register value */
                writel_relaxed(ttccs->scale_clk_ctrl_reg_old,
                               ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
-               /* fall through */
+               fallthrough;
        default:
                return NOTIFY_DONE;
        }
@@ -392,7 +392,7 @@ static int ttc_rate_change_clockevent_cb(struct notifier_block *nb,
 
                clockevents_update_freq(&ttcce->ce, ndata->new_rate / PRESCALE);
 
-               /* fall through */
+               fallthrough;
        case PRE_RATE_CHANGE:
        case ABORT_RATE_CHANGE:
        default:
diff --git a/drivers/clocksource/timer-clint.c b/drivers/clocksource/timer-clint.c
new file mode 100644 (file)
index 0000000..8eeafa8
--- /dev/null
@@ -0,0 +1,226 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Western Digital Corporation or its affiliates.
+ *
+ * Most of the M-mode (i.e. NoMMU) RISC-V systems usually have a
+ * CLINT MMIO timer device.
+ */
+
+#define pr_fmt(fmt) "clint: " fmt
+#include <linux/bitops.h>
+#include <linux/clocksource.h>
+#include <linux/clockchips.h>
+#include <linux/cpu.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/sched_clock.h>
+#include <linux/io-64-nonatomic-lo-hi.h>
+#include <linux/interrupt.h>
+#include <linux/of_irq.h>
+#include <linux/smp.h>
+
+#define CLINT_IPI_OFF          0
+#define CLINT_TIMER_CMP_OFF    0x4000
+#define CLINT_TIMER_VAL_OFF    0xbff8
+
+/* CLINT manages IPI and Timer for RISC-V M-mode  */
+static u32 __iomem *clint_ipi_base;
+static u64 __iomem *clint_timer_cmp;
+static u64 __iomem *clint_timer_val;
+static unsigned long clint_timer_freq;
+static unsigned int clint_timer_irq;
+
+static void clint_send_ipi(const struct cpumask *target)
+{
+       unsigned int cpu;
+
+       for_each_cpu(cpu, target)
+               writel(1, clint_ipi_base + cpuid_to_hartid_map(cpu));
+}
+
+static void clint_clear_ipi(void)
+{
+       writel(0, clint_ipi_base + cpuid_to_hartid_map(smp_processor_id()));
+}
+
+static struct riscv_ipi_ops clint_ipi_ops = {
+       .ipi_inject = clint_send_ipi,
+       .ipi_clear = clint_clear_ipi,
+};
+
+#ifdef CONFIG_64BIT
+#define clint_get_cycles()     readq_relaxed(clint_timer_val)
+#else
+#define clint_get_cycles()     readl_relaxed(clint_timer_val)
+#define clint_get_cycles_hi()  readl_relaxed(((u32 *)clint_timer_val) + 1)
+#endif
+
+#ifdef CONFIG_64BIT
+static u64 notrace clint_get_cycles64(void)
+{
+       return clint_get_cycles();
+}
+#else /* CONFIG_64BIT */
+static u64 notrace clint_get_cycles64(void)
+{
+       u32 hi, lo;
+
+       do {
+               hi = clint_get_cycles_hi();
+               lo = clint_get_cycles();
+       } while (hi != clint_get_cycles_hi());
+
+       return ((u64)hi << 32) | lo;
+}
+#endif /* CONFIG_64BIT */
+
+static u64 clint_rdtime(struct clocksource *cs)
+{
+       return clint_get_cycles64();
+}
+
+static struct clocksource clint_clocksource = {
+       .name           = "clint_clocksource",
+       .rating         = 300,
+       .mask           = CLOCKSOURCE_MASK(64),
+       .flags          = CLOCK_SOURCE_IS_CONTINUOUS,
+       .read           = clint_rdtime,
+};
+
+static int clint_clock_next_event(unsigned long delta,
+                                  struct clock_event_device *ce)
+{
+       void __iomem *r = clint_timer_cmp +
+                         cpuid_to_hartid_map(smp_processor_id());
+
+       csr_set(CSR_IE, IE_TIE);
+       writeq_relaxed(clint_get_cycles64() + delta, r);
+       return 0;
+}
+
+static DEFINE_PER_CPU(struct clock_event_device, clint_clock_event) = {
+       .name           = "clint_clockevent",
+       .features       = CLOCK_EVT_FEAT_ONESHOT,
+       .rating         = 100,
+       .set_next_event = clint_clock_next_event,
+};
+
+static int clint_timer_starting_cpu(unsigned int cpu)
+{
+       struct clock_event_device *ce = per_cpu_ptr(&clint_clock_event, cpu);
+
+       ce->cpumask = cpumask_of(cpu);
+       clockevents_config_and_register(ce, clint_timer_freq, 100, 0x7fffffff);
+
+       enable_percpu_irq(clint_timer_irq,
+                         irq_get_trigger_type(clint_timer_irq));
+       return 0;
+}
+
+static int clint_timer_dying_cpu(unsigned int cpu)
+{
+       disable_percpu_irq(clint_timer_irq);
+       return 0;
+}
+
+static irqreturn_t clint_timer_interrupt(int irq, void *dev_id)
+{
+       struct clock_event_device *evdev = this_cpu_ptr(&clint_clock_event);
+
+       csr_clear(CSR_IE, IE_TIE);
+       evdev->event_handler(evdev);
+
+       return IRQ_HANDLED;
+}
+
+static int __init clint_timer_init_dt(struct device_node *np)
+{
+       int rc;
+       u32 i, nr_irqs;
+       void __iomem *base;
+       struct of_phandle_args oirq;
+
+       /*
+        * Ensure that CLINT device interrupts are either RV_IRQ_TIMER or
+        * RV_IRQ_SOFT. If it's anything else then we ignore the device.
+        */
+       nr_irqs = of_irq_count(np);
+       for (i = 0; i < nr_irqs; i++) {
+               if (of_irq_parse_one(np, i, &oirq)) {
+                       pr_err("%pOFP: failed to parse irq %d.\n", np, i);
+                       continue;
+               }
+
+               if ((oirq.args_count != 1) ||
+                   (oirq.args[0] != RV_IRQ_TIMER &&
+                    oirq.args[0] != RV_IRQ_SOFT)) {
+                       pr_err("%pOFP: invalid irq %d (hwirq %d)\n",
+                              np, i, oirq.args[0]);
+                       return -ENODEV;
+               }
+
+               /* Find parent irq domain and map timer irq */
+               if (!clint_timer_irq &&
+                   oirq.args[0] == RV_IRQ_TIMER &&
+                   irq_find_host(oirq.np))
+                       clint_timer_irq = irq_of_parse_and_map(np, i);
+       }
+
+       /* If CLINT timer irq not found then fail */
+       if (!clint_timer_irq) {
+               pr_err("%pOFP: timer irq not found\n", np);
+               return -ENODEV;
+       }
+
+       base = of_iomap(np, 0);
+       if (!base) {
+               pr_err("%pOFP: could not map registers\n", np);
+               return -ENODEV;
+       }
+
+       clint_ipi_base = base + CLINT_IPI_OFF;
+       clint_timer_cmp = base + CLINT_TIMER_CMP_OFF;
+       clint_timer_val = base + CLINT_TIMER_VAL_OFF;
+       clint_timer_freq = riscv_timebase;
+
+       pr_info("%pOFP: timer running at %ld Hz\n", np, clint_timer_freq);
+
+       rc = clocksource_register_hz(&clint_clocksource, clint_timer_freq);
+       if (rc) {
+               pr_err("%pOFP: clocksource register failed [%d]\n", np, rc);
+               goto fail_iounmap;
+       }
+
+       sched_clock_register(clint_get_cycles64, 64, clint_timer_freq);
+
+       rc = request_percpu_irq(clint_timer_irq, clint_timer_interrupt,
+                                "clint-timer", &clint_clock_event);
+       if (rc) {
+               pr_err("registering percpu irq failed [%d]\n", rc);
+               goto fail_iounmap;
+       }
+
+       rc = cpuhp_setup_state(CPUHP_AP_CLINT_TIMER_STARTING,
+                               "clockevents/clint/timer:starting",
+                               clint_timer_starting_cpu,
+                               clint_timer_dying_cpu);
+       if (rc) {
+               pr_err("%pOFP: cpuhp setup state failed [%d]\n", np, rc);
+               goto fail_free_irq;
+       }
+
+       riscv_set_ipi_ops(&clint_ipi_ops);
+       clint_clear_ipi();
+
+       return 0;
+
+fail_free_irq:
+       free_irq(clint_timer_irq, &clint_clock_event);
+fail_iounmap:
+       iounmap(base);
+       return rc;
+}
+
+TIMER_OF_DECLARE(clint_timer, "riscv,clint0", clint_timer_init_dt);
+TIMER_OF_DECLARE(clint_timer1, "sifive,clint0", clint_timer_init_dt);
index 9de1dab..c51c5ed 100644 (file)
 #include <linux/of_irq.h>
 #include <asm/smp.h>
 #include <asm/sbi.h>
-
-u64 __iomem *riscv_time_cmp;
-u64 __iomem *riscv_time_val;
-
-static inline void mmio_set_timer(u64 val)
-{
-       void __iomem *r;
-
-       r = riscv_time_cmp + cpuid_to_hartid_map(smp_processor_id());
-       writeq_relaxed(val, r);
-}
+#include <asm/timex.h>
 
 static int riscv_clock_next_event(unsigned long delta,
                struct clock_event_device *ce)
 {
        csr_set(CSR_IE, IE_TIE);
-       if (IS_ENABLED(CONFIG_RISCV_SBI))
-               sbi_set_timer(get_cycles64() + delta);
-       else
-               mmio_set_timer(get_cycles64() + delta);
+       sbi_set_timer(get_cycles64() + delta);
        return 0;
 }
 
index f7b7743..b7b252c 100644 (file)
@@ -320,8 +320,8 @@ static int mchp_tc_probe(struct platform_device *pdev)
        }
 
        regmap = syscon_node_to_regmap(np->parent);
-       if (IS_ERR(priv->regmap))
-               return PTR_ERR(priv->regmap);
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
 
        /* max. channels number is 2 when in QDEC mode */
        priv->num_channels = of_property_count_u32_elems(np, "reg");
index 02ab56b..47aa90f 100644 (file)
@@ -703,8 +703,7 @@ static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
        freq = arch_freq_get_on_cpu(policy->cpu);
        if (freq)
                ret = sprintf(buf, "%u\n", freq);
-       else if (cpufreq_driver && cpufreq_driver->setpolicy &&
-                       cpufreq_driver->get)
+       else if (cpufreq_driver->setpolicy && cpufreq_driver->get)
                ret = sprintf(buf, "%u\n", cpufreq_driver->get(policy->cpu));
        else
                ret = sprintf(buf, "%u\n", policy->cur);
index e0220a6..a827b00 100644 (file)
@@ -219,14 +219,13 @@ struct global_params {
  * @epp_policy:                Last saved policy used to set EPP/EPB
  * @epp_default:       Power on default HWP energy performance
  *                     preference/bias
- * @epp_saved:         Saved EPP/EPB during system suspend or CPU offline
- *                     operation
  * @epp_cached         Cached HWP energy-performance preference value
  * @hwp_req_cached:    Cached value of the last HWP Request MSR
  * @hwp_cap_cached:    Cached value of the last HWP Capabilities MSR
  * @last_io_update:    Last time when IO wake flag was set
  * @sched_flags:       Store scheduler flags for possible cross CPU update
  * @hwp_boost_min:     Last HWP boosted min performance
+ * @suspended:         Whether or not the driver has been suspended.
  *
  * This structure stores per CPU instance data for all CPUs.
  */
@@ -258,13 +257,13 @@ struct cpudata {
        s16 epp_powersave;
        s16 epp_policy;
        s16 epp_default;
-       s16 epp_saved;
        s16 epp_cached;
        u64 hwp_req_cached;
        u64 hwp_cap_cached;
        u64 last_io_update;
        unsigned int sched_flags;
        u32 hwp_boost_min;
+       bool suspended;
 };
 
 static struct cpudata **all_cpu_data;
@@ -644,6 +643,8 @@ static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data, int *raw
 
 static int intel_pstate_set_epp(struct cpudata *cpu, u32 epp)
 {
+       int ret;
+
        /*
         * Use the cached HWP Request MSR value, because in the active mode the
         * register itself may be updated by intel_pstate_hwp_boost_up() or
@@ -659,7 +660,11 @@ static int intel_pstate_set_epp(struct cpudata *cpu, u32 epp)
         * function, so it cannot run in parallel with the update below.
         */
        WRITE_ONCE(cpu->hwp_req_cached, value);
-       return wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value);
+       ret = wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value);
+       if (!ret)
+               cpu->epp_cached = epp;
+
+       return ret;
 }
 
 static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
@@ -678,6 +683,14 @@ static int intel_pstate_set_energy_pref_index(struct cpudata *cpu_data,
                else if (epp == -EINVAL)
                        epp = epp_values[pref_index - 1];
 
+               /*
+                * To avoid confusion, refuse to set EPP to any values different
+                * from 0 (performance) if the current policy is "performance",
+                * because those values would be overridden.
+                */
+               if (epp > 0 && cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE)
+                       return -EBUSY;
+
                ret = intel_pstate_set_epp(cpu_data, epp);
        } else {
                if (epp == -EINVAL)
@@ -762,10 +775,8 @@ static ssize_t store_energy_performance_preference(
                        cpufreq_stop_governor(policy);
                        ret = intel_pstate_set_epp(cpu, epp);
                        err = cpufreq_start_governor(policy);
-                       if (!ret) {
-                               cpu->epp_cached = epp;
+                       if (!ret)
                                ret = err;
-                       }
                }
        }
 
@@ -825,7 +836,7 @@ static void intel_pstate_get_hwp_max(unsigned int cpu, int *phy_max,
 
        rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap);
        WRITE_ONCE(all_cpu_data[cpu]->hwp_cap_cached, cap);
-       if (global.no_turbo)
+       if (global.no_turbo || global.turbo_disabled)
                *current_max = HWP_GUARANTEED_PERF(cap);
        else
                *current_max = HWP_HIGHEST_PERF(cap);
@@ -859,12 +870,6 @@ static void intel_pstate_hwp_set(unsigned int cpu)
 
        cpu_data->epp_policy = cpu_data->policy;
 
-       if (cpu_data->epp_saved >= 0) {
-               epp = cpu_data->epp_saved;
-               cpu_data->epp_saved = -EINVAL;
-               goto update_epp;
-       }
-
        if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) {
                epp = intel_pstate_get_epp(cpu_data, value);
                cpu_data->epp_powersave = epp;
@@ -891,7 +896,6 @@ static void intel_pstate_hwp_set(unsigned int cpu)
 
                epp = cpu_data->epp_powersave;
        }
-update_epp:
        if (boot_cpu_has(X86_FEATURE_HWP_EPP)) {
                value &= ~GENMASK_ULL(31, 24);
                value |= (u64)epp << 24;
@@ -903,14 +907,24 @@ skip_epp:
        wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
 }
 
-static void intel_pstate_hwp_force_min_perf(int cpu)
+static void intel_pstate_hwp_offline(struct cpudata *cpu)
 {
-       u64 value;
+       u64 value = READ_ONCE(cpu->hwp_req_cached);
        int min_perf;
 
-       value = all_cpu_data[cpu]->hwp_req_cached;
+       if (boot_cpu_has(X86_FEATURE_HWP_EPP)) {
+               /*
+                * In case the EPP has been set to "performance" by the
+                * active mode "performance" scaling algorithm, replace that
+                * temporary value with the cached EPP one.
+                */
+               value &= ~GENMASK_ULL(31, 24);
+               value |= HWP_ENERGY_PERF_PREFERENCE(cpu->epp_cached);
+               WRITE_ONCE(cpu->hwp_req_cached, value);
+       }
+
        value &= ~GENMASK_ULL(31, 0);
-       min_perf = HWP_LOWEST_PERF(all_cpu_data[cpu]->hwp_cap_cached);
+       min_perf = HWP_LOWEST_PERF(cpu->hwp_cap_cached);
 
        /* Set hwp_max = hwp_min */
        value |= HWP_MAX_PERF(min_perf);
@@ -920,19 +934,7 @@ static void intel_pstate_hwp_force_min_perf(int cpu)
        if (boot_cpu_has(X86_FEATURE_HWP_EPP))
                value |= HWP_ENERGY_PERF_PREFERENCE(HWP_EPP_POWERSAVE);
 
-       wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
-}
-
-static int intel_pstate_hwp_save_state(struct cpufreq_policy *policy)
-{
-       struct cpudata *cpu_data = all_cpu_data[policy->cpu];
-
-       if (!hwp_active)
-               return 0;
-
-       cpu_data->epp_saved = intel_pstate_get_epp(cpu_data, 0);
-
-       return 0;
+       wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, value);
 }
 
 #define POWER_CTL_EE_ENABLE    1
@@ -959,8 +961,28 @@ static void set_power_ctl_ee_state(bool input)
 
 static void intel_pstate_hwp_enable(struct cpudata *cpudata);
 
+static void intel_pstate_hwp_reenable(struct cpudata *cpu)
+{
+       intel_pstate_hwp_enable(cpu);
+       wrmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, READ_ONCE(cpu->hwp_req_cached));
+}
+
+static int intel_pstate_suspend(struct cpufreq_policy *policy)
+{
+       struct cpudata *cpu = all_cpu_data[policy->cpu];
+
+       pr_debug("CPU %d suspending\n", cpu->cpu);
+
+       cpu->suspended = true;
+
+       return 0;
+}
+
 static int intel_pstate_resume(struct cpufreq_policy *policy)
 {
+       struct cpudata *cpu = all_cpu_data[policy->cpu];
+
+       pr_debug("CPU %d resuming\n", cpu->cpu);
 
        /* Only restore if the system default is changed */
        if (power_ctl_ee_state == POWER_CTL_EE_ENABLE)
@@ -968,18 +990,16 @@ static int intel_pstate_resume(struct cpufreq_policy *policy)
        else if (power_ctl_ee_state == POWER_CTL_EE_DISABLE)
                set_power_ctl_ee_state(false);
 
-       if (!hwp_active)
-               return 0;
+       if (cpu->suspended && hwp_active) {
+               mutex_lock(&intel_pstate_limits_lock);
 
-       mutex_lock(&intel_pstate_limits_lock);
+               /* Re-enable HWP, because "online" has not done that. */
+               intel_pstate_hwp_reenable(cpu);
 
-       if (policy->cpu == 0)
-               intel_pstate_hwp_enable(all_cpu_data[policy->cpu]);
+               mutex_unlock(&intel_pstate_limits_lock);
+       }
 
-       all_cpu_data[policy->cpu]->epp_policy = 0;
-       intel_pstate_hwp_set(policy->cpu);
-
-       mutex_unlock(&intel_pstate_limits_lock);
+       cpu->suspended = false;
 
        return 0;
 }
@@ -1428,7 +1448,6 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
                wrmsrl_on_cpu(cpudata->cpu, MSR_HWP_INTERRUPT, 0x00);
 
        wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1);
-       cpudata->epp_policy = 0;
        if (cpudata->epp_default == -EINVAL)
                cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
 }
@@ -2097,25 +2116,31 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
 
                all_cpu_data[cpunum] = cpu;
 
-               cpu->epp_default = -EINVAL;
-               cpu->epp_powersave = -EINVAL;
-               cpu->epp_saved = -EINVAL;
-       }
-
-       cpu = all_cpu_data[cpunum];
+               cpu->cpu = cpunum;
 
-       cpu->cpu = cpunum;
+               cpu->epp_default = -EINVAL;
 
-       if (hwp_active) {
-               const struct x86_cpu_id *id;
+               if (hwp_active) {
+                       const struct x86_cpu_id *id;
 
-               intel_pstate_hwp_enable(cpu);
+                       intel_pstate_hwp_enable(cpu);
 
-               id = x86_match_cpu(intel_pstate_hwp_boost_ids);
-               if (id && intel_pstate_acpi_pm_profile_server())
-                       hwp_boost = true;
+                       id = x86_match_cpu(intel_pstate_hwp_boost_ids);
+                       if (id && intel_pstate_acpi_pm_profile_server())
+                               hwp_boost = true;
+               }
+       } else if (hwp_active) {
+               /*
+                * Re-enable HWP in case this happens after a resume from ACPI
+                * S3 if the CPU was offline during the whole system/resume
+                * cycle.
+                */
+               intel_pstate_hwp_reenable(cpu);
        }
 
+       cpu->epp_powersave = -EINVAL;
+       cpu->epp_policy = 0;
+
        intel_pstate_get_cpu_pstates(cpu);
 
        pr_debug("controlling: cpu %d\n", cpunum);
@@ -2296,28 +2321,61 @@ static int intel_pstate_verify_policy(struct cpufreq_policy_data *policy)
        return 0;
 }
 
-static void intel_cpufreq_stop_cpu(struct cpufreq_policy *policy)
+static int intel_pstate_cpu_offline(struct cpufreq_policy *policy)
 {
+       struct cpudata *cpu = all_cpu_data[policy->cpu];
+
+       pr_debug("CPU %d going offline\n", cpu->cpu);
+
+       if (cpu->suspended)
+               return 0;
+
+       /*
+        * If the CPU is an SMT thread and it goes offline with the performance
+        * settings different from the minimum, it will prevent its sibling
+        * from getting to lower performance levels, so force the minimum
+        * performance on CPU offline to prevent that from happening.
+        */
        if (hwp_active)
-               intel_pstate_hwp_force_min_perf(policy->cpu);
+               intel_pstate_hwp_offline(cpu);
        else
-               intel_pstate_set_min_pstate(all_cpu_data[policy->cpu]);
+               intel_pstate_set_min_pstate(cpu);
+
+       intel_pstate_exit_perf_limits(policy);
+
+       return 0;
+}
+
+static int intel_pstate_cpu_online(struct cpufreq_policy *policy)
+{
+       struct cpudata *cpu = all_cpu_data[policy->cpu];
+
+       pr_debug("CPU %d going online\n", cpu->cpu);
+
+       intel_pstate_init_acpi_perf_limits(policy);
+
+       if (hwp_active) {
+               /*
+                * Re-enable HWP and clear the "suspended" flag to let "resume"
+                * know that it need not do that.
+                */
+               intel_pstate_hwp_reenable(cpu);
+               cpu->suspended = false;
+       }
+
+       return 0;
 }
 
 static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 {
-       pr_debug("CPU %d exiting\n", policy->cpu);
+       pr_debug("CPU %d stopping\n", policy->cpu);
 
        intel_pstate_clear_update_util_hook(policy->cpu);
-       if (hwp_active)
-               intel_pstate_hwp_save_state(policy);
-
-       intel_cpufreq_stop_cpu(policy);
 }
 
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
 {
-       intel_pstate_exit_perf_limits(policy);
+       pr_debug("CPU %d exiting\n", policy->cpu);
 
        policy->fast_switch_possible = false;
 
@@ -2378,6 +2436,12 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy)
         */
        policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
+       if (hwp_active) {
+               struct cpudata *cpu = all_cpu_data[policy->cpu];
+
+               cpu->epp_cached = intel_pstate_get_epp(cpu, 0);
+       }
+
        return 0;
 }
 
@@ -2385,11 +2449,13 @@ static struct cpufreq_driver intel_pstate = {
        .flags          = CPUFREQ_CONST_LOOPS,
        .verify         = intel_pstate_verify_policy,
        .setpolicy      = intel_pstate_set_policy,
-       .suspend        = intel_pstate_hwp_save_state,
+       .suspend        = intel_pstate_suspend,
        .resume         = intel_pstate_resume,
        .init           = intel_pstate_cpu_init,
        .exit           = intel_pstate_cpu_exit,
        .stop_cpu       = intel_pstate_stop_cpu,
+       .offline        = intel_pstate_cpu_offline,
+       .online         = intel_pstate_cpu_online,
        .update_limits  = intel_pstate_update_limits,
        .name           = "intel_pstate",
 };
@@ -2585,7 +2651,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)
                policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY_HWP;
                rdmsrl_on_cpu(cpu->cpu, MSR_HWP_REQUEST, &value);
                WRITE_ONCE(cpu->hwp_req_cached, value);
-               cpu->epp_cached = (value & GENMASK_ULL(31, 24)) >> 24;
+               cpu->epp_cached = intel_pstate_get_epp(cpu, value);
        } else {
                turbo_max = cpu->pstate.turbo_pstate;
                policy->transition_delay_us = INTEL_CPUFREQ_TRANSITION_DELAY;
@@ -2644,7 +2710,10 @@ static struct cpufreq_driver intel_cpufreq = {
        .fast_switch    = intel_cpufreq_fast_switch,
        .init           = intel_cpufreq_cpu_init,
        .exit           = intel_cpufreq_cpu_exit,
-       .stop_cpu       = intel_cpufreq_stop_cpu,
+       .offline        = intel_pstate_cpu_offline,
+       .online         = intel_pstate_cpu_online,
+       .suspend        = intel_pstate_suspend,
+       .resume         = intel_pstate_resume,
        .update_limits  = intel_pstate_update_limits,
        .name           = "intel_cpufreq",
 };
@@ -2667,9 +2736,6 @@ static void intel_pstate_driver_cleanup(void)
        }
        put_online_cpus();
 
-       if (intel_pstate_driver == &intel_pstate)
-               intel_pstate_sysfs_hide_hwp_dynamic_boost();
-
        intel_pstate_driver = NULL;
 }
 
@@ -2695,14 +2761,6 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
        return 0;
 }
 
-static int intel_pstate_unregister_driver(void)
-{
-       cpufreq_unregister_driver(intel_pstate_driver);
-       intel_pstate_driver_cleanup();
-
-       return 0;
-}
-
 static ssize_t intel_pstate_show_status(char *buf)
 {
        if (!intel_pstate_driver)
@@ -2714,20 +2772,23 @@ static ssize_t intel_pstate_show_status(char *buf)
 
 static int intel_pstate_update_status(const char *buf, size_t size)
 {
-       int ret;
+       if (size == 3 && !strncmp(buf, "off", size)) {
+               if (!intel_pstate_driver)
+                       return -EINVAL;
+
+               if (hwp_active)
+                       return -EBUSY;
 
-       if (size == 3 && !strncmp(buf, "off", size))
-               return intel_pstate_driver ?
-                       intel_pstate_unregister_driver() : -EINVAL;
+               cpufreq_unregister_driver(intel_pstate_driver);
+               intel_pstate_driver_cleanup();
+       }
 
        if (size == 6 && !strncmp(buf, "active", size)) {
                if (intel_pstate_driver) {
                        if (intel_pstate_driver == &intel_pstate)
                                return 0;
 
-                       ret = intel_pstate_unregister_driver();
-                       if (ret)
-                               return ret;
+                       cpufreq_unregister_driver(intel_pstate_driver);
                }
 
                return intel_pstate_register_driver(&intel_pstate);
@@ -2738,9 +2799,8 @@ static int intel_pstate_update_status(const char *buf, size_t size)
                        if (intel_pstate_driver == &intel_cpufreq)
                                return 0;
 
-                       ret = intel_pstate_unregister_driver();
-                       if (ret)
-                               return ret;
+                       cpufreq_unregister_driver(intel_pstate_driver);
+                       intel_pstate_sysfs_hide_hwp_dynamic_boost();
                }
 
                return intel_pstate_register_driver(&intel_cpufreq);
index bb61677..ef0a321 100644 (file)
@@ -129,7 +129,7 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
                        return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
                case 0x0D: /* Pentium M (Dothan) */
                        p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
-                       /* fall through */
+                       fallthrough;
                case 0x09: /* Pentium M (Banias) */
                        return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
                }
index 5c4f8f0..a13a2d1 100644 (file)
@@ -366,7 +366,7 @@ enum speedstep_processor speedstep_detect_processor(void)
                        } else
                                return SPEEDSTEP_CPU_PIII_C;
                }
-               /* fall through */
+               fallthrough;
        default:
                return 0;
        }
index bae527e..e1d931c 100644 (file)
@@ -56,9 +56,11 @@ struct read_counters_work {
 
 static struct workqueue_struct *read_counters_wq;
 
-static enum cluster get_cpu_cluster(u8 cpu)
+static void get_cpu_cluster(void *cluster)
 {
-       return MPIDR_AFFINITY_LEVEL(cpu_logical_map(cpu), 1);
+       u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
+
+       *((uint32_t *)cluster) = MPIDR_AFFINITY_LEVEL(mpidr, 1);
 }
 
 /*
@@ -186,8 +188,10 @@ static unsigned int tegra194_get_speed(u32 cpu)
 static int tegra194_cpufreq_init(struct cpufreq_policy *policy)
 {
        struct tegra194_cpufreq_data *data = cpufreq_get_driver_data();
-       int cl = get_cpu_cluster(policy->cpu);
        u32 cpu;
+       u32 cl;
+
+       smp_call_function_single(policy->cpu, get_cpu_cluster, &cl, true);
 
        if (cl >= data->num_clusters)
                return -EINVAL;
index ab0de27..8f9fdd8 100644 (file)
@@ -86,11 +86,11 @@ static unsigned long dra7_efuse_xlate(struct ti_cpufreq_data *opp_data,
        case DRA76_EFUSE_HAS_PLUS_MPU_OPP:
        case DRA76_EFUSE_HAS_ALL_MPU_OPP:
                calculated_efuse |= DRA76_EFUSE_PLUS_MPU_OPP;
-               /* Fall through */
+               fallthrough;
        case DRA7_EFUSE_HAS_ALL_MPU_OPP:
        case DRA7_EFUSE_HAS_HIGH_MPU_OPP:
                calculated_efuse |= DRA7_EFUSE_HIGH_MPU_OPP;
-               /* Fall through */
+               fallthrough;
        case DRA7_EFUSE_HAS_OD_MPU_OPP:
                calculated_efuse |= DRA7_EFUSE_OD_MPU_OPP;
        }
index 8719731..04becd7 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/module.h>
 #include <linux/suspend.h>
 #include <linux/tick.h>
+#include <linux/mmu_context.h>
 #include <trace/events/power.h>
 
 #include "cpuidle.h"
@@ -145,21 +146,24 @@ static void enter_s2idle_proper(struct cpuidle_driver *drv,
         * executing it contains RCU usage regarded as invalid in the idle
         * context, so tell RCU about that.
         */
-       RCU_NONIDLE(tick_freeze());
+       tick_freeze();
        /*
         * The state used here cannot be a "coupled" one, because the "coupled"
         * cpuidle mechanism enables interrupts and doing that with timekeeping
         * suspended is generally unsafe.
         */
        stop_critical_timings();
+       rcu_idle_enter();
        drv->states[index].enter_s2idle(dev, drv, index);
-       WARN_ON(!irqs_disabled());
+       if (WARN_ON_ONCE(!irqs_disabled()))
+               local_irq_disable();
        /*
         * timekeeping_resume() that will be called by tick_unfreeze() for the
         * first CPU executing it calls functions containing RCU read-side
         * critical sections, so tell RCU about that.
         */
-       RCU_NONIDLE(tick_unfreeze());
+       rcu_idle_exit();
+       tick_unfreeze();
        start_critical_timings();
 
        time_end = ns_to_ktime(local_clock());
@@ -225,19 +229,24 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
                broadcast = false;
        }
 
+       if (target_state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
+               leave_mm(dev->cpu);
+
        /* Take note of the planned idle state. */
        sched_idle_set_state(target_state);
 
-       trace_cpu_idle_rcuidle(index, dev->cpu);
+       trace_cpu_idle(index, dev->cpu);
        time_start = ns_to_ktime(local_clock());
 
        stop_critical_timings();
+       rcu_idle_enter();
        entered_state = target_state->enter(dev, drv, index);
+       rcu_idle_exit();
        start_critical_timings();
 
        sched_clock_idle_wakeup_event();
        time_end = ns_to_ktime(local_clock());
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, dev->cpu);
+       trace_cpu_idle(PWR_EVENT_EXIT, dev->cpu);
 
        /* The cpu is no longer idle or about to enter idle. */
        sched_idle_set_state(NULL);
index aa3a4ed..52a9b7c 100644 (file)
@@ -873,6 +873,9 @@ config CRYPTO_DEV_SA2UL
        select CRYPTO_AES
        select CRYPTO_AES_ARM64
        select CRYPTO_ALGAPI
+       select CRYPTO_SHA1
+       select CRYPTO_SHA256
+       select CRYPTO_SHA512
        select HW_RANDOM
        select SG_SPLIT
        help
index 1a46eed..809c303 100644 (file)
@@ -2310,7 +2310,7 @@ static int artpec6_crypto_prepare_submit_hash(struct ahash_request *req)
 
        case ARTPEC6_CRYPTO_PREPARE_HASH_NO_START:
                ret = 0;
-               /* Fallthrough */
+               fallthrough;
 
        default:
                artpec6_crypto_common_destroy(&req_ctx->common);
index dc5fda5..4fe7898 100644 (file)
@@ -90,11 +90,11 @@ static int setup_sgio_components(struct cpt_vf *cptvf, struct buf_ptr *list,
        case 3:
                sg_ptr->u.s.len2 = cpu_to_be16(list[i * 4 + 2].size);
                sg_ptr->ptr2 = cpu_to_be64(list[i * 4 + 2].dma_addr);
-               /* Fall through */
+               fallthrough;
        case 2:
                sg_ptr->u.s.len1 = cpu_to_be16(list[i * 4 + 1].size);
                sg_ptr->ptr1 = cpu_to_be64(list[i * 4 + 1].dma_addr);
-               /* Fall through */
+               fallthrough;
        case 1:
                sg_ptr->u.s.len0 = cpu_to_be16(list[i * 4 + 0].size);
                sg_ptr->ptr0 = cpu_to_be64(list[i * 4 + 0].dma_addr);
index 91dee61..c5cce02 100644 (file)
@@ -135,7 +135,7 @@ static int chcr_ktls_update_connection_state(struct chcr_ktls_info *tx_info,
                        break;
                /* update to the next state and also initialize TCB */
                tx_info->connection_state = new_state;
-               /* FALLTHRU */
+               fallthrough;
        case KTLS_CONN_ACT_OPEN_RPL:
                /* if we are stuck in this state, means tcb init might not
                 * received by HW, try sending it again.
@@ -150,7 +150,7 @@ static int chcr_ktls_update_connection_state(struct chcr_ktls_info *tx_info,
                        break;
                /* update to the next state and check if l2t_state is valid  */
                tx_info->connection_state = new_state;
-               /* FALLTHRU */
+               fallthrough;
        case KTLS_CONN_SET_TCB_RPL:
                /* Check if l2t state is valid, then move to ready state. */
                if (cxgb4_check_l2t_valid(tx_info->l2te)) {
index cbc3d78..c80baf1 100644 (file)
@@ -140,11 +140,11 @@ static inline int setup_sgio_components(struct pci_dev *pdev,
        case 3:
                sg_ptr->u.s.len2 = cpu_to_be16(list[i * 4 + 2].size);
                sg_ptr->ptr2 = cpu_to_be64(list[i * 4 + 2].dma_addr);
-               /* Fall through */
+               fallthrough;
        case 2:
                sg_ptr->u.s.len1 = cpu_to_be16(list[i * 4 + 1].size);
                sg_ptr->ptr1 = cpu_to_be64(list[i * 4 + 1].dma_addr);
-               /* Fall through */
+               fallthrough;
        case 1:
                sg_ptr->u.s.len0 = cpu_to_be16(list[i * 4 + 0].size);
                sg_ptr->ptr0 = cpu_to_be64(list[i * 4 + 0].dma_addr);
index 1c8ca15..ec9b390 100644 (file)
@@ -131,9 +131,10 @@ static int adf_put_admin_msg_sync(struct adf_accel_dev *accel_dev, u32 ae,
        memcpy(admin->virt_addr + offset, in, ADF_ADMINMSG_LEN);
        ADF_CSR_WR(mailbox, mb_offset, 1);
 
-       ret = readl_poll_timeout(mailbox + mb_offset, status,
-                                status == 0, ADF_ADMIN_POLL_DELAY_US,
-                                ADF_ADMIN_POLL_TIMEOUT_US);
+       ret = read_poll_timeout(ADF_CSR_RD, status, status == 0,
+                               ADF_ADMIN_POLL_DELAY_US,
+                               ADF_ADMIN_POLL_TIMEOUT_US, true,
+                               mailbox, mb_offset);
        if (ret < 0) {
                /* Response timeout */
                dev_err(&GET_DEV(accel_dev),
index 519fd5a..8b090b7 100644 (file)
@@ -340,7 +340,7 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
                /* VF is newer than PF and decides whether it is compatible */
                if (accel_dev->vf.pf_version >= hw_data->min_iov_compat_ver)
                        break;
-               /* fall through */
+               fallthrough;
        case ADF_PF2VF_VF_INCOMPATIBLE:
                dev_err(&GET_DEV(accel_dev),
                        "PF (vers %d) and VF (vers %d) are not compatible\n",
index bff759e..00c615f 100644 (file)
@@ -752,7 +752,7 @@ static int qat_uclo_init_reg(struct icp_qat_fw_loader_handle *handle,
        case ICP_GPA_ABS:
        case ICP_GPB_ABS:
                ctx_mask = 0;
-               /* fall through */
+               fallthrough;
        case ICP_GPA_REL:
        case ICP_GPB_REL:
                return qat_hal_init_gpr(handle, ae, ctx_mask, reg_type,
@@ -762,7 +762,7 @@ static int qat_uclo_init_reg(struct icp_qat_fw_loader_handle *handle,
        case ICP_SR_RD_ABS:
        case ICP_DR_RD_ABS:
                ctx_mask = 0;
-               /* fall through */
+               fallthrough;
        case ICP_SR_REL:
        case ICP_DR_REL:
        case ICP_SR_RD_REL:
@@ -772,7 +772,7 @@ static int qat_uclo_init_reg(struct icp_qat_fw_loader_handle *handle,
        case ICP_SR_WR_ABS:
        case ICP_DR_WR_ABS:
                ctx_mask = 0;
-               /* fall through */
+               fallthrough;
        case ICP_SR_WR_REL:
        case ICP_DR_WR_REL:
                return qat_hal_init_wr_xfer(handle, ae, ctx_mask, reg_type,
index f22f6fa..9866c2a 100644 (file)
@@ -314,17 +314,17 @@ void cryp_save_device_context(struct cryp_device_data *device_data,
        case CRYP_KEY_SIZE_256:
                ctx->key_4_l = readl_relaxed(&src_reg->key_4_l);
                ctx->key_4_r = readl_relaxed(&src_reg->key_4_r);
-               /* Fall through */
+               fallthrough;
 
        case CRYP_KEY_SIZE_192:
                ctx->key_3_l = readl_relaxed(&src_reg->key_3_l);
                ctx->key_3_r = readl_relaxed(&src_reg->key_3_r);
-               /* Fall through */
+               fallthrough;
 
        case CRYP_KEY_SIZE_128:
                ctx->key_2_l = readl_relaxed(&src_reg->key_2_l);
                ctx->key_2_r = readl_relaxed(&src_reg->key_2_r);
-               /* Fall through */
+               fallthrough;
 
        default:
                ctx->key_1_l = readl_relaxed(&src_reg->key_1_l);
@@ -364,17 +364,17 @@ void cryp_restore_device_context(struct cryp_device_data *device_data,
        case CRYP_KEY_SIZE_256:
                writel_relaxed(ctx->key_4_l, &reg->key_4_l);
                writel_relaxed(ctx->key_4_r, &reg->key_4_r);
-               /* Fall through */
+               fallthrough;
 
        case CRYP_KEY_SIZE_192:
                writel_relaxed(ctx->key_3_l, &reg->key_3_l);
                writel_relaxed(ctx->key_3_r, &reg->key_3_r);
-               /* Fall through */
+               fallthrough;
 
        case CRYP_KEY_SIZE_128:
                writel_relaxed(ctx->key_2_l, &reg->key_2_l);
                writel_relaxed(ctx->key_2_r, &reg->key_2_r);
-               /* Fall through */
+               fallthrough;
 
        default:
                writel_relaxed(ctx->key_1_l, &reg->key_1_l);
index 4c0af2e..1e89513 100644 (file)
@@ -429,7 +429,7 @@ int dev_dax_probe(struct device *dev)
                return -EBUSY;
        }
 
-       dev_dax->pgmap.type = MEMORY_DEVICE_DEVDAX;
+       dev_dax->pgmap.type = MEMORY_DEVICE_GENERIC;
        addr = devm_memremap_pages(dev, &dev_dax->pgmap);
        if (IS_ERR(addr))
                return PTR_ERR(addr);
index c82cbcb..e5767c8 100644 (file)
@@ -100,6 +100,12 @@ bool __generic_fsdax_supported(struct dax_device *dax_dev,
                return false;
        }
 
+       if (!dax_dev || !bdev_dax_supported(bdev, blocksize)) {
+               pr_debug("%s: error: dax unsupported by block device\n",
+                               bdevname(bdev, buf));
+               return false;
+       }
+
        id = dax_read_lock();
        len = dax_direct_access(dax_dev, pgoff, 1, &kaddr, &pfn);
        len2 = dax_direct_access(dax_dev, pgoff_end, 1, &end_kaddr, &end_pfn);
index 1699a8e..58564d8 100644 (file)
@@ -316,9 +316,9 @@ out:
  * name of the dma-buf if the same piece of memory is used for multiple
  * purpose between different devices.
  *
- * @dmabuf [in]     dmabuf buffer that will be renamed.
- * @buf:   [in]     A piece of userspace memory that contains the name of
- *                  the dma-buf.
+ * @dmabuf: [in]     dmabuf buffer that will be renamed.
+ * @buf:    [in]     A piece of userspace memory that contains the name of
+ *                   the dma-buf.
  *
  * Returns 0 on success. If the dma-buf buffer is already attached to
  * devices, return -EBUSY.
index 3d12350..7d129e6 100644 (file)
@@ -222,6 +222,7 @@ EXPORT_SYMBOL(dma_fence_chain_ops);
  * @chain: the chain node to initialize
  * @prev: the previous fence
  * @fence: the current fence
+ * @seqno: the sequence number to use for the fence chain
  *
  * Initialize a new chain node and either start a new chain or add the node to
  * the existing chain of the previous fence.
index 35f4804..235f139 100644 (file)
@@ -135,11 +135,13 @@ static void acpi_dma_parse_csrt(struct acpi_device *adev, struct acpi_dma *adma)
                if (ret < 0) {
                        dev_warn(&adev->dev,
                                 "error in parsing resource group\n");
-                       return;
+                       break;
                }
 
                grp = (struct acpi_csrt_group *)((void *)grp + grp->length);
        }
+
+       acpi_put_table((struct acpi_table_header *)csrt);
 }
 
 /**
index 9adc7a2..a24882b 100644 (file)
@@ -1767,7 +1767,7 @@ static u32 pl08x_memcpy_cctl(struct pl08x_driver_data *pl08x)
        default:
                dev_err(&pl08x->adev->dev,
                        "illegal burst size for memcpy, set to 1\n");
-               /* Fall through */
+               fallthrough;
        case PL08X_BURST_SZ_1:
                cctl |= PL080_BSIZE_1 << PL080_CONTROL_SB_SIZE_SHIFT |
                        PL080_BSIZE_1 << PL080_CONTROL_DB_SIZE_SHIFT;
@@ -1806,7 +1806,7 @@ static u32 pl08x_memcpy_cctl(struct pl08x_driver_data *pl08x)
        default:
                dev_err(&pl08x->adev->dev,
                        "illegal bus width for memcpy, set to 8 bits\n");
-               /* Fall through */
+               fallthrough;
        case PL08X_BUS_WIDTH_8_BITS:
                cctl |= PL080_WIDTH_8BIT << PL080_CONTROL_SWIDTH_SHIFT |
                        PL080_WIDTH_8BIT << PL080_CONTROL_DWIDTH_SHIFT;
@@ -1850,7 +1850,7 @@ static u32 pl08x_ftdmac020_memcpy_cctl(struct pl08x_driver_data *pl08x)
        default:
                dev_err(&pl08x->adev->dev,
                        "illegal bus width for memcpy, set to 8 bits\n");
-               /* Fall through */
+               fallthrough;
        case PL08X_BUS_WIDTH_8_BITS:
                cctl |= PL080_WIDTH_8BIT << FTDMAC020_LLI_SRC_WIDTH_SHIFT |
                        PL080_WIDTH_8BIT << FTDMAC020_LLI_DST_WIDTH_SHIFT;
@@ -2612,7 +2612,7 @@ static int pl08x_of_probe(struct amba_device *adev,
        switch (val) {
        default:
                dev_err(&adev->dev, "illegal burst size for memcpy, set to 1\n");
-               /* Fall through */
+               fallthrough;
        case 1:
                pd->memcpy_burst_size = PL08X_BURST_SZ_1;
                break;
@@ -2647,7 +2647,7 @@ static int pl08x_of_probe(struct amba_device *adev,
        switch (val) {
        default:
                dev_err(&adev->dev, "illegal bus width for memcpy, set to 8 bits\n");
-               /* Fall through */
+               fallthrough;
        case 8:
                pd->memcpy_bus_width = PL08X_BUS_WIDTH_8_BITS;
                break;
index 45bbcd6..a2cf25c 100644 (file)
@@ -1650,13 +1650,17 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
                return NULL;
 
        dmac_pdev = of_find_device_by_node(dma_spec->np);
+       if (!dmac_pdev)
+               return NULL;
 
        dma_cap_zero(mask);
        dma_cap_set(DMA_SLAVE, mask);
 
        atslave = kmalloc(sizeof(*atslave), GFP_KERNEL);
-       if (!atslave)
+       if (!atslave) {
+               put_device(&dmac_pdev->dev);
                return NULL;
+       }
 
        atslave->cfg = ATC_DST_H2SEL_HW | ATC_SRC_H2SEL_HW;
        /*
@@ -1685,8 +1689,11 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
        atslave->dma_dev = &dmac_pdev->dev;
 
        chan = dma_request_channel(mask, at_dma_filter, atslave);
-       if (!chan)
+       if (!chan) {
+               put_device(&dmac_pdev->dev);
+               kfree(atslave);
                return NULL;
+       }
 
        atchan = to_at_dma_chan(chan);
        atchan->per_if = dma_spec->args[0] & 0xff;
index 448f663..8beed91 100644 (file)
@@ -879,24 +879,11 @@ static int jz4780_dma_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       ret = platform_get_irq(pdev, 0);
-       if (ret < 0)
-               return ret;
-
-       jzdma->irq = ret;
-
-       ret = request_irq(jzdma->irq, jz4780_dma_irq_handler, 0, dev_name(dev),
-                         jzdma);
-       if (ret) {
-               dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
-               return ret;
-       }
-
        jzdma->clk = devm_clk_get(dev, NULL);
        if (IS_ERR(jzdma->clk)) {
                dev_err(dev, "failed to get clock\n");
                ret = PTR_ERR(jzdma->clk);
-               goto err_free_irq;
+               return ret;
        }
 
        clk_prepare_enable(jzdma->clk);
@@ -949,10 +936,23 @@ static int jz4780_dma_probe(struct platform_device *pdev)
                jzchan->vchan.desc_free = jz4780_dma_desc_free;
        }
 
+       ret = platform_get_irq(pdev, 0);
+       if (ret < 0)
+               goto err_disable_clk;
+
+       jzdma->irq = ret;
+
+       ret = request_irq(jzdma->irq, jz4780_dma_irq_handler, 0, dev_name(dev),
+                         jzdma);
+       if (ret) {
+               dev_err(dev, "failed to request IRQ %u!\n", jzdma->irq);
+               goto err_disable_clk;
+       }
+
        ret = dmaenginem_async_device_register(dd);
        if (ret) {
                dev_err(dev, "failed to register device\n");
-               goto err_disable_clk;
+               goto err_free_irq;
        }
 
        /* Register with OF DMA helpers. */
@@ -960,17 +960,17 @@ static int jz4780_dma_probe(struct platform_device *pdev)
                                         jzdma);
        if (ret) {
                dev_err(dev, "failed to register OF DMA controller\n");
-               goto err_disable_clk;
+               goto err_free_irq;
        }
 
        dev_info(dev, "JZ4780 DMA controller initialised\n");
        return 0;
 
-err_disable_clk:
-       clk_disable_unprepare(jzdma->clk);
-
 err_free_irq:
        free_irq(jzdma->irq, jzdma);
+
+err_disable_clk:
+       clk_disable_unprepare(jzdma->clk);
        return ret;
 }
 
index ed430ad..b971505 100644 (file)
@@ -405,7 +405,7 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
                        if (xfer->cyclic) {
                                burst->dar = xfer->xfer.cyclic.paddr;
                        } else {
-                               burst->dar = sg_dma_address(sg);
+                               burst->dar = dst_addr;
                                /* Unlike the typical assumption by other
                                 * drivers/IPs the peripheral memory isn't
                                 * a FIFO memory, in this case, it's a
@@ -413,14 +413,13 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
                                 * and destination addresses are increased
                                 * by the same portion (data length)
                                 */
-                               src_addr += sg_dma_len(sg);
                        }
                } else {
                        burst->dar = dst_addr;
                        if (xfer->cyclic) {
                                burst->sar = xfer->xfer.cyclic.paddr;
                        } else {
-                               burst->sar = sg_dma_address(sg);
+                               burst->sar = src_addr;
                                /* Unlike the typical assumption by other
                                 * drivers/IPs the peripheral memory isn't
                                 * a FIFO memory, in this case, it's a
@@ -428,12 +427,14 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer)
                                 * and destination addresses are increased
                                 * by the same portion (data length)
                                 */
-                               dst_addr += sg_dma_len(sg);
                        }
                }
 
-               if (!xfer->cyclic)
+               if (!xfer->cyclic) {
+                       src_addr += sg_dma_len(sg);
+                       dst_addr += sg_dma_len(sg);
                        sg = sg_next(sg);
+               }
        }
 
        return vchan_tx_prep(&chan->vc, &desc->vd, xfer->flags);
index ad72b3f..e342cf5 100644 (file)
@@ -1163,7 +1163,7 @@ static int fsl_dma_chan_probe(struct fsldma_device *fdev,
        switch (chan->feature & FSL_DMA_IP_MASK) {
        case FSL_DMA_IP_85XX:
                chan->toggle_ext_pause = fsl_chan_toggle_ext_pause;
-               /* Fall through */
+               fallthrough;
        case FSL_DMA_IP_83XX:
                chan->toggle_ext_start = fsl_chan_toggle_ext_start;
                chan->set_src_loop_size = fsl_chan_set_src_loop_size;
index 56f18ae..308bed0 100644 (file)
@@ -205,10 +205,10 @@ struct fsldma_chan {
 #else
 static u64 fsl_ioread64(const u64 __iomem *addr)
 {
-       u32 fsl_addr = lower_32_bits(addr);
-       u64 fsl_addr_hi = (u64)in_le32((u32 *)(fsl_addr + 1)) << 32;
+       u32 val_lo = in_le32((u32 __iomem *)addr);
+       u32 val_hi = in_le32((u32 __iomem *)addr + 1);
 
-       return fsl_addr_hi | in_le32((u32 *)fsl_addr);
+       return ((u64)val_hi << 32) + val_lo;
 }
 
 static void fsl_iowrite64(u64 val, u64 __iomem *addr)
@@ -219,10 +219,10 @@ static void fsl_iowrite64(u64 val, u64 __iomem *addr)
 
 static u64 fsl_ioread64be(const u64 __iomem *addr)
 {
-       u32 fsl_addr = lower_32_bits(addr);
-       u64 fsl_addr_hi = (u64)in_be32((u32 *)fsl_addr) << 32;
+       u32 val_hi = in_be32((u32 __iomem *)addr);
+       u32 val_lo = in_be32((u32 __iomem *)addr + 1);
 
-       return fsl_addr_hi | in_be32((u32 *)(fsl_addr + 1));
+       return ((u64)val_hi << 32) + val_lo;
 }
 
 static void fsl_iowrite64be(u64 val, u64 __iomem *addr)
index 14b4585..b75d699 100644 (file)
@@ -410,10 +410,27 @@ int idxd_device_enable(struct idxd_device *idxd)
        return 0;
 }
 
+void idxd_device_wqs_clear_state(struct idxd_device *idxd)
+{
+       int i;
+
+       lockdep_assert_held(&idxd->dev_lock);
+
+       for (i = 0; i < idxd->max_wqs; i++) {
+               struct idxd_wq *wq = &idxd->wqs[i];
+
+               if (wq->state == IDXD_WQ_ENABLED) {
+                       idxd_wq_disable_cleanup(wq);
+                       wq->state = IDXD_WQ_DISABLED;
+               }
+       }
+}
+
 int idxd_device_disable(struct idxd_device *idxd)
 {
        struct device *dev = &idxd->pdev->dev;
        u32 status;
+       unsigned long flags;
 
        if (!idxd_is_enabled(idxd)) {
                dev_dbg(dev, "Device is not enabled\n");
@@ -429,13 +446,22 @@ int idxd_device_disable(struct idxd_device *idxd)
                return -ENXIO;
        }
 
+       spin_lock_irqsave(&idxd->dev_lock, flags);
+       idxd_device_wqs_clear_state(idxd);
        idxd->state = IDXD_DEV_CONF_READY;
+       spin_unlock_irqrestore(&idxd->dev_lock, flags);
        return 0;
 }
 
 void idxd_device_reset(struct idxd_device *idxd)
 {
+       unsigned long flags;
+
        idxd_cmd_exec(idxd, IDXD_CMD_RESET_DEVICE, 0, NULL);
+       spin_lock_irqsave(&idxd->dev_lock, flags);
+       idxd_device_wqs_clear_state(idxd);
+       idxd->state = IDXD_DEV_CONF_READY;
+       spin_unlock_irqrestore(&idxd->dev_lock, flags);
 }
 
 /* Device configuration bits */
index b514255..1e9e699 100644 (file)
 #include "idxd.h"
 #include "registers.h"
 
-void idxd_device_wqs_clear_state(struct idxd_device *idxd)
-{
-       int i;
-
-       lockdep_assert_held(&idxd->dev_lock);
-       for (i = 0; i < idxd->max_wqs; i++) {
-               struct idxd_wq *wq = &idxd->wqs[i];
-
-               wq->state = IDXD_WQ_DISABLED;
-       }
-}
-
 static void idxd_device_reinit(struct work_struct *work)
 {
        struct idxd_device *idxd = container_of(work, struct idxd_device, work);
index 5c0fb31..8871750 100644 (file)
@@ -556,7 +556,7 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
                 * We fall-through here intentionally, since a 2D transfer is
                 * similar to MEMCPY just adding the 2D slot configuration.
                 */
-               /* Fall through */
+               fallthrough;
        case IMXDMA_DESC_MEMCPY:
                imx_dmav1_writel(imxdma, d->src, DMA_SAR(imxdmac->channel));
                imx_dmav1_writel(imxdma, d->dest, DMA_DAR(imxdmac->channel));
index c499c95..d44eabb 100644 (file)
@@ -496,7 +496,7 @@ iop3xx_desc_init_xor(struct iop3xx_desc_aau *hw_desc, int src_cnt,
                }
                hw_desc->src_edc[AAU_EDCR2_IDX].e_desc_ctrl = edcr;
                src_cnt = 24;
-               /* fall through */
+               fallthrough;
        case 17 ... 24:
                if (!u_desc_ctrl.field.blk_ctrl) {
                        hw_desc->src_edc[AAU_EDCR2_IDX].e_desc_ctrl = 0;
@@ -510,7 +510,7 @@ iop3xx_desc_init_xor(struct iop3xx_desc_aau *hw_desc, int src_cnt,
                }
                hw_desc->src_edc[AAU_EDCR1_IDX].e_desc_ctrl = edcr;
                src_cnt = 16;
-               /* fall through */
+               fallthrough;
        case 9 ... 16:
                if (!u_desc_ctrl.field.blk_ctrl)
                        u_desc_ctrl.field.blk_ctrl = 0x2; /* use EDCR0 */
@@ -522,7 +522,7 @@ iop3xx_desc_init_xor(struct iop3xx_desc_aau *hw_desc, int src_cnt,
                }
                hw_desc->src_edc[AAU_EDCR0_IDX].e_desc_ctrl = edcr;
                src_cnt = 8;
-               /* fall through */
+               fallthrough;
        case 2 ... 8:
                shift = 1;
                for (i = 0; i < src_cnt; i++) {
@@ -602,19 +602,19 @@ iop_desc_init_null_xor(struct iop_adma_desc_slot *desc, int src_cnt,
        case 25 ... 32:
                u_desc_ctrl.field.blk_ctrl = 0x3; /* use EDCR[2:0] */
                hw_desc->src_edc[AAU_EDCR2_IDX].e_desc_ctrl = 0;
-               /* fall through */
+               fallthrough;
        case 17 ... 24:
                if (!u_desc_ctrl.field.blk_ctrl) {
                        hw_desc->src_edc[AAU_EDCR2_IDX].e_desc_ctrl = 0;
                        u_desc_ctrl.field.blk_ctrl = 0x3; /* use EDCR[2:0] */
                }
                hw_desc->src_edc[AAU_EDCR1_IDX].e_desc_ctrl = 0;
-               /* fall through */
+               fallthrough;
        case 9 ... 16:
                if (!u_desc_ctrl.field.blk_ctrl)
                        u_desc_ctrl.field.blk_ctrl = 0x2; /* use EDCR0 */
                hw_desc->src_edc[AAU_EDCR0_IDX].e_desc_ctrl = 0;
-               /* fall through */
+               fallthrough;
        case 1 ... 8:
                if (!u_desc_ctrl.field.blk_ctrl && src_cnt > 4)
                        u_desc_ctrl.field.blk_ctrl = 0x1; /* use mini-desc */
index 74df621..ca4e093 100644 (file)
@@ -483,7 +483,7 @@ static size_t nbpf_xfer_size(struct nbpf_device *nbpf,
 
        default:
                pr_warn("%s(): invalid bus width %u\n", __func__, width);
-               /* fall through */
+               fallthrough;
        case DMA_SLAVE_BUSWIDTH_1_BYTE:
                size = burst;
        }
index 863f2aa..8a4f608 100644 (file)
@@ -71,12 +71,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec,
                return NULL;
 
        chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target);
-       if (chan) {
-               chan->router = ofdma->dma_router;
-               chan->route_data = route_data;
-       } else {
+       if (IS_ERR_OR_NULL(chan)) {
                ofdma->dma_router->route_free(ofdma->dma_router->dev,
                                              route_data);
+       } else {
+               chan->router = ofdma->dma_router;
+               chan->route_data = route_data;
        }
 
        /*
index 2c508ee..5274a07 100644 (file)
@@ -1061,16 +1061,16 @@ static bool _start(struct pl330_thread *thrd)
 
                if (_state(thrd) == PL330_STATE_KILLING)
                        UNTIL(thrd, PL330_STATE_STOPPED)
-               /* fall through */
+               fallthrough;
 
        case PL330_STATE_FAULTING:
                _stop(thrd);
-               /* fall through */
+               fallthrough;
 
        case PL330_STATE_KILLING:
        case PL330_STATE_COMPLETING:
                UNTIL(thrd, PL330_STATE_STOPPED)
-               /* fall through */
+               fallthrough;
 
        case PL330_STATE_STOPPED:
                return _trigger(thrd);
@@ -1121,7 +1121,6 @@ static u32 _emit_load(unsigned int dry_run, u8 buf[],
 
        switch (direction) {
        case DMA_MEM_TO_MEM:
-               /* fall through */
        case DMA_MEM_TO_DEV:
                off += _emit_LD(dry_run, &buf[off], cond);
                break;
@@ -1155,7 +1154,6 @@ static inline u32 _emit_store(unsigned int dry_run, u8 buf[],
 
        switch (direction) {
        case DMA_MEM_TO_MEM:
-               /* fall through */
        case DMA_DEV_TO_MEM:
                off += _emit_ST(dry_run, &buf[off], cond);
                break;
@@ -1216,7 +1214,6 @@ static int _bursts(struct pl330_dmac *pl330, unsigned dry_run, u8 buf[],
 
        switch (pxs->desc->rqtype) {
        case DMA_MEM_TO_DEV:
-               /* fall through */
        case DMA_DEV_TO_MEM:
                off += _ldst_peripheral(pl330, dry_run, &buf[off], pxs, cyc,
                        cond);
@@ -1266,7 +1263,6 @@ static int _dregs(struct pl330_dmac *pl330, unsigned int dry_run, u8 buf[],
 
        switch (pxs->desc->rqtype) {
        case DMA_MEM_TO_DEV:
-               /* fall through */
        case DMA_DEV_TO_MEM:
                off += _emit_MOV(dry_run, &buf[off], CCR, dregs_ccr);
                off += _ldst_peripheral(pl330, dry_run, &buf[off], pxs, 1,
@@ -2801,6 +2797,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
        while (burst != (1 << desc->rqcfg.brst_size))
                desc->rqcfg.brst_size++;
 
+       desc->rqcfg.brst_len = get_burst_len(desc, len);
        /*
         * If burst size is smaller than bus width then make sure we only
         * transfer one at a time to avoid a burst stradling an MFIFO entry.
@@ -2808,7 +2805,6 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
        if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width)
                desc->rqcfg.brst_len = 1;
 
-       desc->rqcfg.brst_len = get_burst_len(desc, len);
        desc->bytes_requested = len;
 
        desc->txd.flags = flags;
index 2deeaab..788d696 100644 (file)
@@ -383,7 +383,7 @@ static dma_async_tx_callback __ld_cleanup(struct shdma_chan *schan, bool all)
                        switch (desc->mark) {
                        case DESC_COMPLETED:
                                desc->mark = DESC_WAITING;
-                               /* Fall through */
+                               fallthrough;
                        case DESC_WAITING:
                                if (head_acked)
                                        async_tx_ack(&desc->async_tx);
index c14e6cb..d86dba0 100644 (file)
@@ -2059,9 +2059,9 @@ udma_prep_slave_sg_tr(struct udma_chan *uc, struct scatterlist *sgl,
                        return NULL;
                }
 
-               cppi5_tr_init(&tr_req[i].flags, CPPI5_TR_TYPE1, false, false,
-                             CPPI5_TR_EVENT_SIZE_COMPLETION, 0);
-               cppi5_tr_csf_set(&tr_req[i].flags, CPPI5_TR_CSF_SUPR_EVT);
+               cppi5_tr_init(&tr_req[tr_idx].flags, CPPI5_TR_TYPE1, false,
+                             false, CPPI5_TR_EVENT_SIZE_COMPLETION, 0);
+               cppi5_tr_csf_set(&tr_req[tr_idx].flags, CPPI5_TR_CSF_SUPR_EVT);
 
                tr_req[tr_idx].addr = sg_addr;
                tr_req[tr_idx].icnt0 = tr0_cnt0;
@@ -3101,14 +3101,14 @@ static struct udma_match_data am654_main_data = {
        .psil_base = 0x1000,
        .enable_memcpy_support = true,
        .statictr_z_mask = GENMASK(11, 0),
-       .rchan_oes_offset = 0x2000,
+       .rchan_oes_offset = 0x200,
 };
 
 static struct udma_match_data am654_mcu_data = {
        .psil_base = 0x6000,
        .enable_memcpy_support = false,
        .statictr_z_mask = GENMASK(11, 0),
-       .rchan_oes_offset = 0x2000,
+       .rchan_oes_offset = 0x200,
 };
 
 static struct udma_match_data j721e_main_data = {
index 6262f63..fcc08bb 100644 (file)
@@ -3375,7 +3375,7 @@ static struct amd64_family_type *per_family_init(struct amd64_pvt *pvt)
                        pvt->ops = &family_types[F17_M70H_CPUS].ops;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case 0x18:
                fam_type        = &family_types[F17_CPUS];
                pvt->ops        = &family_types[F17_CPUS].ops;
index da60c29..54ebc8a 100644 (file)
@@ -55,6 +55,8 @@ static DEFINE_SPINLOCK(ghes_lock);
 static bool __read_mostly force_load;
 module_param(force_load, bool, 0);
 
+static bool system_scanned;
+
 /* Memory Device - Type 17 of SMBIOS spec */
 struct memdev_dmi_entry {
        u8 type;
@@ -225,14 +227,12 @@ static void enumerate_dimms(const struct dmi_header *dh, void *arg)
 
 static void ghes_scan_system(void)
 {
-       static bool scanned;
-
-       if (scanned)
+       if (system_scanned)
                return;
 
        dmi_walk(enumerate_dimms, &ghes_hw);
 
-       scanned = true;
+       system_scanned = true;
 }
 
 void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err)
@@ -631,6 +631,8 @@ void ghes_edac_unregister(struct ghes *ghes)
 
        mutex_lock(&ghes_reg_mutex);
 
+       system_scanned = false;
+
        if (!refcount_dec_and_test(&ghes_refcount))
                goto unlock;
 
index 5860ca4..2acd9f9 100644 (file)
@@ -1710,9 +1710,9 @@ static void i7core_mce_output_error(struct mem_ctl_info *mci,
        if (uncorrected_error) {
                core_err_cnt = 1;
                if (ripv)
-                       tp_event = HW_EVENT_ERR_FATAL;
-               else
                        tp_event = HW_EVENT_ERR_UNCORRECTED;
+               else
+                       tp_event = HW_EVENT_ERR_FATAL;
        } else {
                tp_event = HW_EVENT_ERR_CORRECTED;
        }
index fd36374..928f63a 100644 (file)
@@ -198,7 +198,7 @@ static int apl_rd_reg(int port, int off, int op, void *data, size_t sz, char *na
        switch (sz) {
        case 8:
                ret = _apl_rd_reg(port, off + 4, op, (u32 *)(data + 4));
-               /* fall through */
+               fallthrough;
        case 4:
                ret |= _apl_rd_reg(port, off, op, (u32 *)data);
                pnd2_printk(KERN_DEBUG, "%s=%x%08x ret=%d\n", name,
@@ -1155,7 +1155,7 @@ static void pnd2_mce_output_error(struct mem_ctl_info *mci, const struct mce *m,
        u32 optypenum = GET_BITFIELD(m->status, 4, 6);
        int rc;
 
-       tp_event = uc_err ? (ripv ? HW_EVENT_ERR_FATAL : HW_EVENT_ERR_UNCORRECTED) :
+       tp_event = uc_err ? (ripv ? HW_EVENT_ERR_UNCORRECTED : HW_EVENT_ERR_FATAL) :
                                                 HW_EVENT_ERR_CORRECTED;
 
        /*
index d414698..c5ab634 100644 (file)
@@ -2982,9 +2982,9 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
        if (uncorrected_error) {
                core_err_cnt = 1;
                if (ripv) {
-                       tp_event = HW_EVENT_ERR_FATAL;
-               } else {
                        tp_event = HW_EVENT_ERR_UNCORRECTED;
+               } else {
+                       tp_event = HW_EVENT_ERR_FATAL;
                }
        } else {
                tp_event = HW_EVENT_ERR_CORRECTED;
index 6d8d6dc..2b4ce8e 100644 (file)
@@ -493,9 +493,9 @@ static void skx_mce_output_error(struct mem_ctl_info *mci,
        if (uncorrected_error) {
                core_err_cnt = 1;
                if (ripv) {
-                       tp_event = HW_EVENT_ERR_FATAL;
-               } else {
                        tp_event = HW_EVENT_ERR_UNCORRECTED;
+               } else {
+                       tp_event = HW_EVENT_ERR_FATAL;
                }
        } else {
                tp_event = HW_EVENT_ERR_CORRECTED;
index b785e93..80db43a 100644 (file)
@@ -957,7 +957,7 @@ static void set_broadcast_channel(struct fw_device *device, int generation)
                                device->bc_implemented = BC_IMPLEMENTED;
                                break;
                        }
-                       /* else, fall through - to case address error */
+                       fallthrough;    /* to case address error */
                case RCODE_ADDRESS_ERROR:
                        device->bc_implemented = BC_UNIMPLEMENTED;
                }
index 185b0b7..af70e74 100644 (file)
@@ -277,7 +277,7 @@ static int manage_channel(struct fw_card *card, int irm_id, int generation,
                        if ((data[0] & bit) == (data[1] & bit))
                                continue;
 
-                       /* fall through - It's a 1394-1995 IRM, retry. */
+                       fallthrough;    /* It's a 1394-1995 IRM, retry */
                default:
                        if (retry) {
                                retry--;
index 94a13fc..ec68ed2 100644 (file)
@@ -54,7 +54,7 @@ static u32 *count_ports(u32 *sid, int *total_port_count, int *child_port_count)
                switch (port_type) {
                case SELFID_PORT_CHILD:
                        (*child_port_count)++;
-                       /* fall through */
+                       fallthrough;
                case SELFID_PORT_PARENT:
                case SELFID_PORT_NCONN:
                        (*total_port_count)++;
index 439d918..ac487c9 100644 (file)
@@ -1097,14 +1097,14 @@ static void handle_registers(struct fw_card *card, struct fw_request *request,
                        rcode = RCODE_ADDRESS_ERROR;
                        break;
                }
-               /* else fall through */
+               fallthrough;
 
        case CSR_NODE_IDS:
                /*
                 * per IEEE 1394-2008 8.3.22.3, not IEEE 1394.1-2004 3.2.8
                 * and 9.6, but interoperable with IEEE 1394.1-2004 bridges
                 */
-               /* fall through */
+               fallthrough;
 
        case CSR_STATE_CLEAR:
        case CSR_STATE_SET:
index 7dde21b..020cb15 100644 (file)
@@ -1495,7 +1495,7 @@ static int handle_at_packet(struct context *context,
                        packet->ack = RCODE_GENERATION;
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        default:
                packet->ack = RCODE_SEND_ERROR;
@@ -3054,7 +3054,7 @@ static int ohci_start_iso(struct fw_iso_context *base,
 
        case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
                control |= IR_CONTEXT_BUFFER_FILL|IR_CONTEXT_MULTI_CHANNEL_MODE;
-               /* fall through */
+               fallthrough;
        case FW_ISO_CONTEXT_RECEIVE:
                index = ctx - ohci->ir_context_list;
                match = (tags << 28) | (sync << 8) | ctx->base.channel;
index fdd1db0..3aa07c3 100644 (file)
@@ -381,6 +381,7 @@ static int __init efisubsys_init(void)
        efi_kobj = kobject_create_and_add("efi", firmware_kobj);
        if (!efi_kobj) {
                pr_err("efi: Firmware registration failed.\n");
+               destroy_workqueue(efi_rts_wq);
                return -ENOMEM;
        }
 
@@ -424,6 +425,7 @@ err_unregister:
                generic_ops_unregister();
 err_put:
        kobject_put(efi_kobj);
+       destroy_workqueue(efi_rts_wq);
        return error;
 }
 
index e97a9c9..21ae0c4 100644 (file)
@@ -16,9 +16,9 @@
 
 /* Exported for use by lib/test_firmware.c only */
 LIST_HEAD(efi_embedded_fw_list);
-EXPORT_SYMBOL_GPL(efi_embedded_fw_list);
-
-static bool checked_for_fw;
+EXPORT_SYMBOL_NS_GPL(efi_embedded_fw_list, TEST_FIRMWARE);
+bool efi_embedded_fw_checked;
+EXPORT_SYMBOL_NS_GPL(efi_embedded_fw_checked, TEST_FIRMWARE);
 
 static const struct dmi_system_id * const embedded_fw_table[] = {
 #ifdef CONFIG_TOUCHSCREEN_DMI
@@ -116,14 +116,14 @@ void __init efi_check_for_embedded_firmwares(void)
                }
        }
 
-       checked_for_fw = true;
+       efi_embedded_fw_checked = true;
 }
 
 int efi_get_embedded_fw(const char *name, const u8 **data, size_t *size)
 {
        struct efi_embedded_fw *iter, *fw = NULL;
 
-       if (!checked_for_fw) {
+       if (!efi_embedded_fw_checked) {
                pr_warn("Warning %s called while we did not check for embedded fw\n",
                        __func__);
                return -ENOENT;
index 6bca70b..f735db5 100644 (file)
@@ -187,20 +187,28 @@ int efi_printk(const char *fmt, ...)
  */
 efi_status_t efi_parse_options(char const *cmdline)
 {
-       size_t len = strlen(cmdline) + 1;
+       size_t len;
        efi_status_t status;
        char *str, *buf;
 
+       if (!cmdline)
+               return EFI_SUCCESS;
+
+       len = strnlen(cmdline, COMMAND_LINE_SIZE - 1) + 1;
        status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, len, (void **)&buf);
        if (status != EFI_SUCCESS)
                return status;
 
-       str = skip_spaces(memcpy(buf, cmdline, len));
+       memcpy(buf, cmdline, len - 1);
+       buf[len - 1] = '\0';
+       str = skip_spaces(buf);
 
        while (*str) {
                char *param, *val;
 
                str = next_arg(str, &param, &val);
+               if (!val && !strcmp(param, "--"))
+                       break;
 
                if (!strcmp(param, "nokaslr")) {
                        efi_nokaslr = true;
index 53cee17..722af9e 100644 (file)
@@ -64,22 +64,6 @@ struct ti_sci_xfers_info {
        spinlock_t xfer_lock;
 };
 
-/**
- * struct ti_sci_rm_type_map - Structure representing TISCI Resource
- *                             management representation of dev_ids.
- * @dev_id:    TISCI device ID
- * @type:      Corresponding id as identified by TISCI RM.
- *
- * Note: This is used only as a work around for using RM range apis
- *     for AM654 SoC. For future SoCs dev_id will be used as type
- *     for RM range APIs. In order to maintain ABI backward compatibility
- *     type is not being changed for AM654 SoC.
- */
-struct ti_sci_rm_type_map {
-       u32 dev_id;
-       u16 type;
-};
-
 /**
  * struct ti_sci_desc - Description of SoC integration
  * @default_host_id:   Host identifier representing the compute entity
@@ -87,14 +71,12 @@ struct ti_sci_rm_type_map {
  * @max_msgs: Maximum number of messages that can be pending
  *               simultaneously in the system
  * @max_msg_size: Maximum size of data per message that can be handled.
- * @rm_type_map: RM resource type mapping structure.
  */
 struct ti_sci_desc {
        u8 default_host_id;
        int max_rx_timeout_ms;
        int max_msgs;
        int max_msg_size;
-       struct ti_sci_rm_type_map *rm_type_map;
 };
 
 /**
@@ -1710,33 +1692,6 @@ fail:
        return ret;
 }
 
-static int ti_sci_get_resource_type(struct ti_sci_info *info, u16 dev_id,
-                                   u16 *type)
-{
-       struct ti_sci_rm_type_map *rm_type_map = info->desc->rm_type_map;
-       bool found = false;
-       int i;
-
-       /* If map is not provided then assume dev_id is used as type */
-       if (!rm_type_map) {
-               *type = dev_id;
-               return 0;
-       }
-
-       for (i = 0; rm_type_map[i].dev_id; i++) {
-               if (rm_type_map[i].dev_id == dev_id) {
-                       *type = rm_type_map[i].type;
-                       found = true;
-                       break;
-               }
-       }
-
-       if (!found)
-               return -EINVAL;
-
-       return 0;
-}
-
 /**
  * ti_sci_get_resource_range - Helper to get a range of resources assigned
  *                            to a host. Resource is uniquely identified by
@@ -1760,7 +1715,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
        struct ti_sci_xfer *xfer;
        struct ti_sci_info *info;
        struct device *dev;
-       u16 type;
        int ret = 0;
 
        if (IS_ERR(handle))
@@ -1780,15 +1734,9 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,
                return ret;
        }
 
-       ret = ti_sci_get_resource_type(info, dev_id, &type);
-       if (ret) {
-               dev_err(dev, "rm type lookup failed for %u\n", dev_id);
-               goto fail;
-       }
-
        req = (struct ti_sci_msg_req_get_resource_range *)xfer->xfer_buf;
        req->secondary_host = s_host;
-       req->type = type & MSG_RM_RESOURCE_TYPE_MASK;
+       req->type = dev_id & MSG_RM_RESOURCE_TYPE_MASK;
        req->subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK;
 
        ret = ti_sci_do_xfer(info, xfer);
@@ -3260,61 +3208,50 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res)
 EXPORT_SYMBOL_GPL(ti_sci_get_num_resources);
 
 /**
- * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
+ * devm_ti_sci_get_resource_sets() - Get a TISCI resources assigned to a device
  * @handle:    TISCI handle
  * @dev:       Device pointer to which the resource is assigned
  * @dev_id:    TISCI device id to which the resource is assigned
- * @of_prop:   property name by which the resource are represented
+ * @sub_types: Array of sub_types assigned corresponding to device
+ * @sets:      Number of sub_types
  *
  * Return: Pointer to ti_sci_resource if all went well else appropriate
  *        error pointer.
  */
-struct ti_sci_resource *
-devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
-                           struct device *dev, u32 dev_id, char *of_prop)
+static struct ti_sci_resource *
+devm_ti_sci_get_resource_sets(const struct ti_sci_handle *handle,
+                             struct device *dev, u32 dev_id, u32 *sub_types,
+                             u32 sets)
 {
        struct ti_sci_resource *res;
        bool valid_set = false;
-       u32 resource_subtype;
        int i, ret;
 
        res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL);
        if (!res)
                return ERR_PTR(-ENOMEM);
 
-       ret = of_property_count_elems_of_size(dev_of_node(dev), of_prop,
-                                             sizeof(u32));
-       if (ret < 0) {
-               dev_err(dev, "%s resource type ids not available\n", of_prop);
-               return ERR_PTR(ret);
-       }
-       res->sets = ret;
-
+       res->sets = sets;
        res->desc = devm_kcalloc(dev, res->sets, sizeof(*res->desc),
                                 GFP_KERNEL);
        if (!res->desc)
                return ERR_PTR(-ENOMEM);
 
        for (i = 0; i < res->sets; i++) {
-               ret = of_property_read_u32_index(dev_of_node(dev), of_prop, i,
-                                                &resource_subtype);
-               if (ret)
-                       return ERR_PTR(-EINVAL);
-
                ret = handle->ops.rm_core_ops.get_range(handle, dev_id,
-                                                       resource_subtype,
+                                                       sub_types[i],
                                                        &res->desc[i].start,
                                                        &res->desc[i].num);
                if (ret) {
                        dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n",
-                               dev_id, resource_subtype);
+                               dev_id, sub_types[i]);
                        res->desc[i].start = 0;
                        res->desc[i].num = 0;
                        continue;
                }
 
                dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
-                       dev_id, resource_subtype, res->desc[i].start,
+                       dev_id, sub_types[i], res->desc[i].start,
                        res->desc[i].num);
 
                valid_set = true;
@@ -3332,6 +3269,62 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
        return ERR_PTR(-EINVAL);
 }
 
+/**
+ * devm_ti_sci_get_of_resource() - Get a TISCI resource assigned to a device
+ * @handle:    TISCI handle
+ * @dev:       Device pointer to which the resource is assigned
+ * @dev_id:    TISCI device id to which the resource is assigned
+ * @of_prop:   property name by which the resource are represented
+ *
+ * Return: Pointer to ti_sci_resource if all went well else appropriate
+ *        error pointer.
+ */
+struct ti_sci_resource *
+devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
+                           struct device *dev, u32 dev_id, char *of_prop)
+{
+       struct ti_sci_resource *res;
+       u32 *sub_types;
+       int sets;
+
+       sets = of_property_count_elems_of_size(dev_of_node(dev), of_prop,
+                                              sizeof(u32));
+       if (sets < 0) {
+               dev_err(dev, "%s resource type ids not available\n", of_prop);
+               return ERR_PTR(sets);
+       }
+
+       sub_types = kcalloc(sets, sizeof(*sub_types), GFP_KERNEL);
+       if (!sub_types)
+               return ERR_PTR(-ENOMEM);
+
+       of_property_read_u32_array(dev_of_node(dev), of_prop, sub_types, sets);
+       res = devm_ti_sci_get_resource_sets(handle, dev, dev_id, sub_types,
+                                           sets);
+
+       kfree(sub_types);
+       return res;
+}
+EXPORT_SYMBOL_GPL(devm_ti_sci_get_of_resource);
+
+/**
+ * devm_ti_sci_get_resource() - Get a resource range assigned to the device
+ * @handle:    TISCI handle
+ * @dev:       Device pointer to which the resource is assigned
+ * @dev_id:    TISCI device id to which the resource is assigned
+ * @suub_type: TISCI resource subytpe representing the resource.
+ *
+ * Return: Pointer to ti_sci_resource if all went well else appropriate
+ *        error pointer.
+ */
+struct ti_sci_resource *
+devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
+                        u32 dev_id, u32 sub_type)
+{
+       return devm_ti_sci_get_resource_sets(handle, dev, dev_id, &sub_type, 1);
+}
+EXPORT_SYMBOL_GPL(devm_ti_sci_get_resource);
+
 static int tisci_reboot_handler(struct notifier_block *nb, unsigned long mode,
                                void *cmd)
 {
@@ -3352,17 +3345,6 @@ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = {
        /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */
        .max_msgs = 20,
        .max_msg_size = 64,
-       .rm_type_map = NULL,
-};
-
-static struct ti_sci_rm_type_map ti_sci_am654_rm_type_map[] = {
-       {.dev_id = 56, .type = 0x00b}, /* GIC_IRQ */
-       {.dev_id = 179, .type = 0x000}, /* MAIN_NAV_UDMASS_IA0 */
-       {.dev_id = 187, .type = 0x009}, /* MAIN_NAV_RA */
-       {.dev_id = 188, .type = 0x006}, /* MAIN_NAV_UDMAP */
-       {.dev_id = 194, .type = 0x007}, /* MCU_NAV_UDMAP */
-       {.dev_id = 195, .type = 0x00a}, /* MCU_NAV_RA */
-       {.dev_id = 0, .type = 0x000}, /* end of table */
 };
 
 /* Description for AM654 */
@@ -3373,7 +3355,6 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = {
        /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */
        .max_msgs = 20,
        .max_msg_size = 60,
-       .rm_type_map = ti_sci_am654_rm_type_map,
 };
 
 static const struct of_device_id ti_sci_of_match[] = {
index 6ce1ed2..5312662 100644 (file)
@@ -148,7 +148,7 @@ struct fme_perf_priv {
        struct device *dev;
        void __iomem *ioaddr;
        struct pmu pmu;
-       u64 id;
+       u16 id;
 
        u32 fab_users;
        u32 fab_port_id;
index e220bec..a2203d0 100644 (file)
@@ -31,12 +31,12 @@ struct cci_drvdata {
        struct dfl_fpga_cdev *cdev;     /* container device */
 };
 
-static void __iomem *cci_pci_ioremap_bar(struct pci_dev *pcidev, int bar)
+static void __iomem *cci_pci_ioremap_bar0(struct pci_dev *pcidev)
 {
-       if (pcim_iomap_regions(pcidev, BIT(bar), DRV_NAME))
+       if (pcim_iomap_regions(pcidev, BIT(0), DRV_NAME))
                return NULL;
 
-       return pcim_iomap_table(pcidev)[bar];
+       return pcim_iomap_table(pcidev)[0];
 }
 
 static int cci_pci_alloc_irq(struct pci_dev *pcidev)
@@ -156,8 +156,8 @@ static int cci_enumerate_feature_devs(struct pci_dev *pcidev)
                        goto irq_free_exit;
        }
 
-       /* start to find Device Feature List from Bar 0 */
-       base = cci_pci_ioremap_bar(pcidev, 0);
+       /* start to find Device Feature List in Bar 0 */
+       base = cci_pci_ioremap_bar0(pcidev);
        if (!base) {
                ret = -ENOMEM;
                goto irq_free_exit;
@@ -172,7 +172,7 @@ static int cci_enumerate_feature_devs(struct pci_dev *pcidev)
                start = pci_resource_start(pcidev, 0);
                len = pci_resource_len(pcidev, 0);
 
-               dfl_fpga_enum_info_add_dfl(info, start, len, base);
+               dfl_fpga_enum_info_add_dfl(info, start, len);
 
                /*
                 * find more Device Feature Lists (e.g. Ports) per information
@@ -196,26 +196,24 @@ static int cci_enumerate_feature_devs(struct pci_dev *pcidev)
                         */
                        bar = FIELD_GET(FME_PORT_OFST_BAR_ID, v);
                        offset = FIELD_GET(FME_PORT_OFST_DFH_OFST, v);
-                       base = cci_pci_ioremap_bar(pcidev, bar);
-                       if (!base)
-                               continue;
-
                        start = pci_resource_start(pcidev, bar) + offset;
                        len = pci_resource_len(pcidev, bar) - offset;
 
-                       dfl_fpga_enum_info_add_dfl(info, start, len,
-                                                  base + offset);
+                       dfl_fpga_enum_info_add_dfl(info, start, len);
                }
        } else if (dfl_feature_is_port(base)) {
                start = pci_resource_start(pcidev, 0);
                len = pci_resource_len(pcidev, 0);
 
-               dfl_fpga_enum_info_add_dfl(info, start, len, base);
+               dfl_fpga_enum_info_add_dfl(info, start, len);
        } else {
                ret = -ENODEV;
                goto irq_free_exit;
        }
 
+       /* release I/O mappings for next step enumeration */
+       pcim_iounmap_regions(pcidev, BIT(0));
+
        /* start enumeration with prepared enumeration information */
        cdev = dfl_fpga_feature_devs_enumerate(info);
        if (IS_ERR(cdev)) {
index 649958a..b450870 100644 (file)
@@ -30,12 +30,6 @@ static DEFINE_MUTEX(dfl_id_mutex);
  * index to dfl_chardevs table. If no chardev support just set devt_type
  * as one invalid index (DFL_FPGA_DEVT_MAX).
  */
-enum dfl_id_type {
-       FME_ID,         /* fme id allocation and mapping */
-       PORT_ID,        /* port id allocation and mapping */
-       DFL_ID_MAX,
-};
-
 enum dfl_fpga_devt_type {
        DFL_FPGA_DEVT_FME,
        DFL_FPGA_DEVT_PORT,
@@ -58,7 +52,7 @@ static const char *dfl_pdata_key_strings[DFL_ID_MAX] = {
  */
 struct dfl_dev_info {
        const char *name;
-       u32 dfh_id;
+       u16 dfh_id;
        struct idr id;
        enum dfl_fpga_devt_type devt_type;
 };
@@ -134,7 +128,7 @@ static enum dfl_id_type feature_dev_id_type(struct platform_device *pdev)
        return DFL_ID_MAX;
 }
 
-static enum dfl_id_type dfh_id_to_type(u32 id)
+static enum dfl_id_type dfh_id_to_type(u16 id)
 {
        int i;
 
@@ -250,6 +244,249 @@ int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id)
 }
 EXPORT_SYMBOL_GPL(dfl_fpga_check_port_id);
 
+static DEFINE_IDA(dfl_device_ida);
+
+static const struct dfl_device_id *
+dfl_match_one_device(const struct dfl_device_id *id, struct dfl_device *ddev)
+{
+       if (id->type == ddev->type && id->feature_id == ddev->feature_id)
+               return id;
+
+       return NULL;
+}
+
+static int dfl_bus_match(struct device *dev, struct device_driver *drv)
+{
+       struct dfl_device *ddev = to_dfl_dev(dev);
+       struct dfl_driver *ddrv = to_dfl_drv(drv);
+       const struct dfl_device_id *id_entry;
+
+       id_entry = ddrv->id_table;
+       if (id_entry) {
+               while (id_entry->feature_id) {
+                       if (dfl_match_one_device(id_entry, ddev)) {
+                               ddev->id_entry = id_entry;
+                               return 1;
+                       }
+                       id_entry++;
+               }
+       }
+
+       return 0;
+}
+
+static int dfl_bus_probe(struct device *dev)
+{
+       struct dfl_driver *ddrv = to_dfl_drv(dev->driver);
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       return ddrv->probe(ddev);
+}
+
+static int dfl_bus_remove(struct device *dev)
+{
+       struct dfl_driver *ddrv = to_dfl_drv(dev->driver);
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       if (ddrv->remove)
+               ddrv->remove(ddev);
+
+       return 0;
+}
+
+static int dfl_bus_uevent(struct device *dev, struct kobj_uevent_env *env)
+{
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       /* The type has 4 valid bits and feature_id has 12 valid bits */
+       return add_uevent_var(env, "MODALIAS=dfl:t%01Xf%03X",
+                             ddev->type, ddev->feature_id);
+}
+
+static ssize_t
+type_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       return sprintf(buf, "0x%x\n", ddev->type);
+}
+static DEVICE_ATTR_RO(type);
+
+static ssize_t
+feature_id_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       return sprintf(buf, "0x%x\n", ddev->feature_id);
+}
+static DEVICE_ATTR_RO(feature_id);
+
+static struct attribute *dfl_dev_attrs[] = {
+       &dev_attr_type.attr,
+       &dev_attr_feature_id.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(dfl_dev);
+
+static struct bus_type dfl_bus_type = {
+       .name           = "dfl",
+       .match          = dfl_bus_match,
+       .probe          = dfl_bus_probe,
+       .remove         = dfl_bus_remove,
+       .uevent         = dfl_bus_uevent,
+       .dev_groups     = dfl_dev_groups,
+};
+
+static void release_dfl_dev(struct device *dev)
+{
+       struct dfl_device *ddev = to_dfl_dev(dev);
+
+       if (ddev->mmio_res.parent)
+               release_resource(&ddev->mmio_res);
+
+       ida_simple_remove(&dfl_device_ida, ddev->id);
+       kfree(ddev->irqs);
+       kfree(ddev);
+}
+
+static struct dfl_device *
+dfl_dev_add(struct dfl_feature_platform_data *pdata,
+           struct dfl_feature *feature)
+{
+       struct platform_device *pdev = pdata->dev;
+       struct resource *parent_res;
+       struct dfl_device *ddev;
+       int id, i, ret;
+
+       ddev = kzalloc(sizeof(*ddev), GFP_KERNEL);
+       if (!ddev)
+               return ERR_PTR(-ENOMEM);
+
+       id = ida_simple_get(&dfl_device_ida, 0, 0, GFP_KERNEL);
+       if (id < 0) {
+               dev_err(&pdev->dev, "unable to get id\n");
+               kfree(ddev);
+               return ERR_PTR(id);
+       }
+
+       /* freeing resources by put_device() after device_initialize() */
+       device_initialize(&ddev->dev);
+       ddev->dev.parent = &pdev->dev;
+       ddev->dev.bus = &dfl_bus_type;
+       ddev->dev.release = release_dfl_dev;
+       ddev->id = id;
+       ret = dev_set_name(&ddev->dev, "dfl_dev.%d", id);
+       if (ret)
+               goto put_dev;
+
+       ddev->type = feature_dev_id_type(pdev);
+       ddev->feature_id = feature->id;
+       ddev->cdev = pdata->dfl_cdev;
+
+       /* add mmio resource */
+       parent_res = &pdev->resource[feature->resource_index];
+       ddev->mmio_res.flags = IORESOURCE_MEM;
+       ddev->mmio_res.start = parent_res->start;
+       ddev->mmio_res.end = parent_res->end;
+       ddev->mmio_res.name = dev_name(&ddev->dev);
+       ret = insert_resource(parent_res, &ddev->mmio_res);
+       if (ret) {
+               dev_err(&pdev->dev, "%s failed to claim resource: %pR\n",
+                       dev_name(&ddev->dev), &ddev->mmio_res);
+               goto put_dev;
+       }
+
+       /* then add irq resource */
+       if (feature->nr_irqs) {
+               ddev->irqs = kcalloc(feature->nr_irqs,
+                                    sizeof(*ddev->irqs), GFP_KERNEL);
+               if (!ddev->irqs) {
+                       ret = -ENOMEM;
+                       goto put_dev;
+               }
+
+               for (i = 0; i < feature->nr_irqs; i++)
+                       ddev->irqs[i] = feature->irq_ctx[i].irq;
+
+               ddev->num_irqs = feature->nr_irqs;
+       }
+
+       ret = device_add(&ddev->dev);
+       if (ret)
+               goto put_dev;
+
+       dev_dbg(&pdev->dev, "add dfl_dev: %s\n", dev_name(&ddev->dev));
+       return ddev;
+
+put_dev:
+       /* calls release_dfl_dev() which does the clean up  */
+       put_device(&ddev->dev);
+       return ERR_PTR(ret);
+}
+
+static void dfl_devs_remove(struct dfl_feature_platform_data *pdata)
+{
+       struct dfl_feature *feature;
+
+       dfl_fpga_dev_for_each_feature(pdata, feature) {
+               if (feature->ddev) {
+                       device_unregister(&feature->ddev->dev);
+                       feature->ddev = NULL;
+               }
+       }
+}
+
+static int dfl_devs_add(struct dfl_feature_platform_data *pdata)
+{
+       struct dfl_feature *feature;
+       struct dfl_device *ddev;
+       int ret;
+
+       dfl_fpga_dev_for_each_feature(pdata, feature) {
+               if (feature->ioaddr)
+                       continue;
+
+               if (feature->ddev) {
+                       ret = -EEXIST;
+                       goto err;
+               }
+
+               ddev = dfl_dev_add(pdata, feature);
+               if (IS_ERR(ddev)) {
+                       ret = PTR_ERR(ddev);
+                       goto err;
+               }
+
+               feature->ddev = ddev;
+       }
+
+       return 0;
+
+err:
+       dfl_devs_remove(pdata);
+       return ret;
+}
+
+int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner)
+{
+       if (!dfl_drv || !dfl_drv->probe || !dfl_drv->id_table)
+               return -EINVAL;
+
+       dfl_drv->drv.owner = owner;
+       dfl_drv->drv.bus = &dfl_bus_type;
+
+       return driver_register(&dfl_drv->drv);
+}
+EXPORT_SYMBOL(__dfl_driver_register);
+
+void dfl_driver_unregister(struct dfl_driver *dfl_drv)
+{
+       driver_unregister(&dfl_drv->drv);
+}
+EXPORT_SYMBOL(dfl_driver_unregister);
+
+#define is_header_feature(feature) ((feature)->id == FEATURE_ID_FIU_HEADER)
+
 /**
  * dfl_fpga_dev_feature_uinit - uinit for sub features of dfl feature device
  * @pdev: feature device.
@@ -259,12 +496,15 @@ void dfl_fpga_dev_feature_uinit(struct platform_device *pdev)
        struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
        struct dfl_feature *feature;
 
-       dfl_fpga_dev_for_each_feature(pdata, feature)
+       dfl_devs_remove(pdata);
+
+       dfl_fpga_dev_for_each_feature(pdata, feature) {
                if (feature->ops) {
                        if (feature->ops->uinit)
                                feature->ops->uinit(pdev, feature);
                        feature->ops = NULL;
                }
+       }
 }
 EXPORT_SYMBOL_GPL(dfl_fpga_dev_feature_uinit);
 
@@ -273,8 +513,22 @@ static int dfl_feature_instance_init(struct platform_device *pdev,
                                     struct dfl_feature *feature,
                                     struct dfl_feature_driver *drv)
 {
+       void __iomem *base;
        int ret = 0;
 
+       if (!is_header_feature(feature)) {
+               base = devm_platform_ioremap_resource(pdev,
+                                                     feature->resource_index);
+               if (IS_ERR(base)) {
+                       dev_err(&pdev->dev,
+                               "ioremap failed for feature 0x%x!\n",
+                               feature->id);
+                       return PTR_ERR(base);
+               }
+
+               feature->ioaddr = base;
+       }
+
        if (drv->ops->init) {
                ret = drv->ops->init(pdev, feature);
                if (ret)
@@ -331,6 +585,10 @@ int dfl_fpga_dev_feature_init(struct platform_device *pdev,
                drv++;
        }
 
+       ret = dfl_devs_add(pdata);
+       if (ret)
+               goto exit;
+
        return 0;
 exit:
        dfl_fpga_dev_feature_uinit(pdev);
@@ -427,7 +685,9 @@ EXPORT_SYMBOL_GPL(dfl_fpga_dev_ops_unregister);
  * @irq_table: Linux IRQ numbers for all irqs, indexed by local irq index of
  *            this device.
  * @feature_dev: current feature device.
- * @ioaddr: header register region address of feature device in enumeration.
+ * @ioaddr: header register region address of current FIU in enumeration.
+ * @start: register resource start of current FIU.
+ * @len: max register resource length of current FIU.
  * @sub_features: a sub features linked list for feature device in enumeration.
  * @feature_num: number of sub features for feature device in enumeration.
  */
@@ -439,6 +699,8 @@ struct build_feature_devs_info {
 
        struct platform_device *feature_dev;
        void __iomem *ioaddr;
+       resource_size_t start;
+       resource_size_t len;
        struct list_head sub_features;
        int feature_num;
 };
@@ -454,7 +716,7 @@ struct build_feature_devs_info {
  * @nr_irqs: number of irqs of this sub feature.
  */
 struct dfl_feature_info {
-       u64 fid;
+       u16 fid;
        struct resource mmio_res;
        void __iomem *ioaddr;
        struct list_head node;
@@ -484,10 +746,7 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo)
        struct dfl_feature_platform_data *pdata;
        struct dfl_feature_info *finfo, *p;
        enum dfl_id_type type;
-       int ret, index = 0;
-
-       if (!fdev)
-               return 0;
+       int ret, index = 0, res_idx = 0;
 
        type = feature_dev_id_type(fdev);
        if (WARN_ON_ONCE(type >= DFL_ID_MAX))
@@ -530,16 +789,32 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo)
 
        /* fill features and resource information for feature dev */
        list_for_each_entry_safe(finfo, p, &binfo->sub_features, node) {
-               struct dfl_feature *feature = &pdata->features[index];
+               struct dfl_feature *feature = &pdata->features[index++];
                struct dfl_feature_irq_ctx *ctx;
                unsigned int i;
 
                /* save resource information for each feature */
                feature->dev = fdev;
                feature->id = finfo->fid;
-               feature->resource_index = index;
-               feature->ioaddr = finfo->ioaddr;
-               fdev->resource[index++] = finfo->mmio_res;
+
+               /*
+                * the FIU header feature has some fundamental functions (sriov
+                * set, port enable/disable) needed for the dfl bus device and
+                * other sub features. So its mmio resource should be mapped by
+                * DFL bus device. And we should not assign it to feature
+                * devices (dfl-fme/afu) again.
+                */
+               if (is_header_feature(feature)) {
+                       feature->resource_index = -1;
+                       feature->ioaddr =
+                               devm_ioremap_resource(binfo->dev,
+                                                     &finfo->mmio_res);
+                       if (IS_ERR(feature->ioaddr))
+                               return PTR_ERR(feature->ioaddr);
+               } else {
+                       feature->resource_index = res_idx;
+                       fdev->resource[res_idx++] = finfo->mmio_res;
+               }
 
                if (finfo->nr_irqs) {
                        ctx = devm_kcalloc(binfo->dev, finfo->nr_irqs,
@@ -582,19 +857,13 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo)
 
 static int
 build_info_create_dev(struct build_feature_devs_info *binfo,
-                     enum dfl_id_type type, void __iomem *ioaddr)
+                     enum dfl_id_type type)
 {
        struct platform_device *fdev;
-       int ret;
 
        if (type >= DFL_ID_MAX)
                return -EINVAL;
 
-       /* we will create a new device, commit current device first */
-       ret = build_info_commit_dev(binfo);
-       if (ret)
-               return ret;
-
        /*
         * we use -ENODEV as the initialization indicator which indicates
         * whether the id need to be reclaimed
@@ -605,7 +874,7 @@ build_info_create_dev(struct build_feature_devs_info *binfo,
 
        binfo->feature_dev = fdev;
        binfo->feature_num = 0;
-       binfo->ioaddr = ioaddr;
+
        INIT_LIST_HEAD(&binfo->sub_features);
 
        fdev->id = dfl_id_alloc(type, &fdev->dev);
@@ -649,7 +918,7 @@ static inline u32 feature_size(void __iomem *start)
        return ofst ? ofst : 4096;
 }
 
-static u64 feature_id(void __iomem *start)
+static u16 feature_id(void __iomem *start)
 {
        u64 v = readq(start + DFH);
        u16 id = FIELD_GET(DFH_ID, v);
@@ -667,7 +936,7 @@ static u64 feature_id(void __iomem *start)
 }
 
 static int parse_feature_irqs(struct build_feature_devs_info *binfo,
-                             resource_size_t ofst, u64 fid,
+                             resource_size_t ofst, u16 fid,
                              unsigned int *irq_base, unsigned int *nr_irqs)
 {
        void __iomem *base = binfo->ioaddr + ofst;
@@ -713,12 +982,12 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
                return 0;
        }
 
-       dev_dbg(binfo->dev, "feature: 0x%llx, irq_base: %u, nr_irqs: %u\n",
+       dev_dbg(binfo->dev, "feature: 0x%x, irq_base: %u, nr_irqs: %u\n",
                fid, ibase, inr);
 
        if (ibase + inr > binfo->nr_irqs) {
                dev_err(binfo->dev,
-                       "Invalid interrupt number in feature 0x%llx\n", fid);
+                       "Invalid interrupt number in feature 0x%x\n", fid);
                return -EINVAL;
        }
 
@@ -726,7 +995,7 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
                virq = binfo->irq_table[ibase + i];
                if (virq < 0 || virq > NR_IRQS) {
                        dev_err(binfo->dev,
-                               "Invalid irq table entry for feature 0x%llx\n",
+                               "Invalid irq table entry for feature 0x%x\n",
                                fid);
                        return -EINVAL;
                }
@@ -747,18 +1016,17 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo,
  */
 static int
 create_feature_instance(struct build_feature_devs_info *binfo,
-                       struct dfl_fpga_enum_dfl *dfl, resource_size_t ofst,
-                       resource_size_t size, u64 fid)
+                       resource_size_t ofst, resource_size_t size, u16 fid)
 {
        unsigned int irq_base, nr_irqs;
        struct dfl_feature_info *finfo;
        int ret;
 
        /* read feature size and id if inputs are invalid */
-       size = size ? size : feature_size(dfl->ioaddr + ofst);
-       fid = fid ? fid : feature_id(dfl->ioaddr + ofst);
+       size = size ? size : feature_size(binfo->ioaddr + ofst);
+       fid = fid ? fid : feature_id(binfo->ioaddr + ofst);
 
-       if (dfl->len - ofst < size)
+       if (binfo->len - ofst < size)
                return -EINVAL;
 
        ret = parse_feature_irqs(binfo, ofst, fid, &irq_base, &nr_irqs);
@@ -770,12 +1038,11 @@ create_feature_instance(struct build_feature_devs_info *binfo,
                return -ENOMEM;
 
        finfo->fid = fid;
-       finfo->mmio_res.start = dfl->start + ofst;
+       finfo->mmio_res.start = binfo->start + ofst;
        finfo->mmio_res.end = finfo->mmio_res.start + size - 1;
        finfo->mmio_res.flags = IORESOURCE_MEM;
        finfo->irq_base = irq_base;
        finfo->nr_irqs = nr_irqs;
-       finfo->ioaddr = dfl->ioaddr + ofst;
 
        list_add_tail(&finfo->node, &binfo->sub_features);
        binfo->feature_num++;
@@ -784,7 +1051,6 @@ create_feature_instance(struct build_feature_devs_info *binfo,
 }
 
 static int parse_feature_port_afu(struct build_feature_devs_info *binfo,
-                                 struct dfl_fpga_enum_dfl *dfl,
                                  resource_size_t ofst)
 {
        u64 v = readq(binfo->ioaddr + PORT_HDR_CAP);
@@ -792,21 +1058,22 @@ static int parse_feature_port_afu(struct build_feature_devs_info *binfo,
 
        WARN_ON(!size);
 
-       return create_feature_instance(binfo, dfl, ofst, size, FEATURE_ID_AFU);
+       return create_feature_instance(binfo, ofst, size, FEATURE_ID_AFU);
 }
 
+#define is_feature_dev_detected(binfo) (!!(binfo)->feature_dev)
+
 static int parse_feature_afu(struct build_feature_devs_info *binfo,
-                            struct dfl_fpga_enum_dfl *dfl,
                             resource_size_t ofst)
 {
-       if (!binfo->feature_dev) {
+       if (!is_feature_dev_detected(binfo)) {
                dev_err(binfo->dev, "this AFU does not belong to any FIU.\n");
                return -EINVAL;
        }
 
        switch (feature_dev_id_type(binfo->feature_dev)) {
        case PORT_ID:
-               return parse_feature_port_afu(binfo, dfl, ofst);
+               return parse_feature_port_afu(binfo, ofst);
        default:
                dev_info(binfo->dev, "AFU belonging to FIU %s is not supported yet.\n",
                         binfo->feature_dev->name);
@@ -815,35 +1082,79 @@ static int parse_feature_afu(struct build_feature_devs_info *binfo,
        return 0;
 }
 
+static int build_info_prepare(struct build_feature_devs_info *binfo,
+                             resource_size_t start, resource_size_t len)
+{
+       struct device *dev = binfo->dev;
+       void __iomem *ioaddr;
+
+       if (!devm_request_mem_region(dev, start, len, dev_name(dev))) {
+               dev_err(dev, "request region fail, start:%pa, len:%pa\n",
+                       &start, &len);
+               return -EBUSY;
+       }
+
+       ioaddr = devm_ioremap(dev, start, len);
+       if (!ioaddr) {
+               dev_err(dev, "ioremap region fail, start:%pa, len:%pa\n",
+                       &start, &len);
+               return -ENOMEM;
+       }
+
+       binfo->start = start;
+       binfo->len = len;
+       binfo->ioaddr = ioaddr;
+
+       return 0;
+}
+
+static void build_info_complete(struct build_feature_devs_info *binfo)
+{
+       devm_iounmap(binfo->dev, binfo->ioaddr);
+       devm_release_mem_region(binfo->dev, binfo->start, binfo->len);
+}
+
 static int parse_feature_fiu(struct build_feature_devs_info *binfo,
-                            struct dfl_fpga_enum_dfl *dfl,
                             resource_size_t ofst)
 {
-       u32 id, offset;
-       u64 v;
        int ret = 0;
+       u32 offset;
+       u16 id;
+       u64 v;
+
+       if (is_feature_dev_detected(binfo)) {
+               build_info_complete(binfo);
+
+               ret = build_info_commit_dev(binfo);
+               if (ret)
+                       return ret;
 
-       v = readq(dfl->ioaddr + ofst + DFH);
+               ret = build_info_prepare(binfo, binfo->start + ofst,
+                                        binfo->len - ofst);
+               if (ret)
+                       return ret;
+       }
+
+       v = readq(binfo->ioaddr + DFH);
        id = FIELD_GET(DFH_ID, v);
 
        /* create platform device for dfl feature dev */
-       ret = build_info_create_dev(binfo, dfh_id_to_type(id),
-                                   dfl->ioaddr + ofst);
+       ret = build_info_create_dev(binfo, dfh_id_to_type(id));
        if (ret)
                return ret;
 
-       ret = create_feature_instance(binfo, dfl, ofst, 0, 0);
+       ret = create_feature_instance(binfo, 0, 0, 0);
        if (ret)
                return ret;
        /*
         * find and parse FIU's child AFU via its NEXT_AFU register.
         * please note that only Port has valid NEXT_AFU pointer per spec.
         */
-       v = readq(dfl->ioaddr + ofst + NEXT_AFU);
+       v = readq(binfo->ioaddr + NEXT_AFU);
 
        offset = FIELD_GET(NEXT_AFU_NEXT_DFH_OFST, v);
        if (offset)
-               return parse_feature_afu(binfo, dfl, ofst + offset);
+               return parse_feature_afu(binfo, offset);
 
        dev_dbg(binfo->dev, "No AFUs detected on FIU %d\n", id);
 
@@ -851,41 +1162,39 @@ static int parse_feature_fiu(struct build_feature_devs_info *binfo,
 }
 
 static int parse_feature_private(struct build_feature_devs_info *binfo,
-                                struct dfl_fpga_enum_dfl *dfl,
                                 resource_size_t ofst)
 {
-       if (!binfo->feature_dev) {
-               dev_err(binfo->dev, "the private feature %llx does not belong to any AFU.\n",
-                       (unsigned long long)feature_id(dfl->ioaddr + ofst));
+       if (!is_feature_dev_detected(binfo)) {
+               dev_err(binfo->dev, "the private feature 0x%x does not belong to any AFU.\n",
+                       feature_id(binfo->ioaddr + ofst));
                return -EINVAL;
        }
 
-       return create_feature_instance(binfo, dfl, ofst, 0, 0);
+       return create_feature_instance(binfo, ofst, 0, 0);
 }
 
 /**
  * parse_feature - parse a feature on given device feature list
  *
  * @binfo: build feature devices information.
- * @dfl: device feature list to parse
- * @ofst: offset to feature header on this device feature list
+ * @ofst: offset to current FIU header
  */
 static int parse_feature(struct build_feature_devs_info *binfo,
-                        struct dfl_fpga_enum_dfl *dfl, resource_size_t ofst)
+                        resource_size_t ofst)
 {
        u64 v;
        u32 type;
 
-       v = readq(dfl->ioaddr + ofst + DFH);
+       v = readq(binfo->ioaddr + ofst + DFH);
        type = FIELD_GET(DFH_TYPE, v);
 
        switch (type) {
        case DFH_TYPE_AFU:
-               return parse_feature_afu(binfo, dfl, ofst);
+               return parse_feature_afu(binfo, ofst);
        case DFH_TYPE_PRIVATE:
-               return parse_feature_private(binfo, dfl, ofst);
+               return parse_feature_private(binfo, ofst);
        case DFH_TYPE_FIU:
-               return parse_feature_fiu(binfo, dfl, ofst);
+               return parse_feature_fiu(binfo, ofst);
        default:
                dev_info(binfo->dev,
                         "Feature Type %x is not supported.\n", type);
@@ -895,14 +1204,17 @@ static int parse_feature(struct build_feature_devs_info *binfo,
 }
 
 static int parse_feature_list(struct build_feature_devs_info *binfo,
-                             struct dfl_fpga_enum_dfl *dfl)
+                             resource_size_t start, resource_size_t len)
 {
-       void __iomem *start = dfl->ioaddr;
-       void __iomem *end = dfl->ioaddr + dfl->len;
+       resource_size_t end = start + len;
        int ret = 0;
        u32 ofst = 0;
        u64 v;
 
+       ret = build_info_prepare(binfo, start, len);
+       if (ret)
+               return ret;
+
        /* walk through the device feature list via DFH's next DFH pointer. */
        for (; start < end; start += ofst) {
                if (end - start < DFH_SIZE) {
@@ -910,11 +1222,11 @@ static int parse_feature_list(struct build_feature_devs_info *binfo,
                        return -EINVAL;
                }
 
-               ret = parse_feature(binfo, dfl, start - dfl->ioaddr);
+               ret = parse_feature(binfo, start - binfo->start);
                if (ret)
                        return ret;
 
-               v = readq(start + DFH);
+               v = readq(binfo->ioaddr + start - binfo->start + DFH);
                ofst = FIELD_GET(DFH_NEXT_HDR_OFST, v);
 
                /* stop parsing if EOL(End of List) is set or offset is 0 */
@@ -923,7 +1235,12 @@ static int parse_feature_list(struct build_feature_devs_info *binfo,
        }
 
        /* commit current feature device when reach the end of list */
-       return build_info_commit_dev(binfo);
+       build_info_complete(binfo);
+
+       if (is_feature_dev_detected(binfo))
+               ret = build_info_commit_dev(binfo);
+
+       return ret;
 }
 
 struct dfl_fpga_enum_info *dfl_fpga_enum_info_alloc(struct device *dev)
@@ -976,7 +1293,6 @@ EXPORT_SYMBOL_GPL(dfl_fpga_enum_info_free);
  * @info: ptr to dfl_fpga_enum_info
  * @start: mmio resource address of the device feature list.
  * @len: mmio resource length of the device feature list.
- * @ioaddr: mapped mmio resource address of the device feature list.
  *
  * One FPGA device may have one or more Device Feature Lists (DFLs), use this
  * function to add information of each DFL to common data structure for next
@@ -985,8 +1301,7 @@ EXPORT_SYMBOL_GPL(dfl_fpga_enum_info_free);
  * Return: 0 on success, negative error code otherwise.
  */
 int dfl_fpga_enum_info_add_dfl(struct dfl_fpga_enum_info *info,
-                              resource_size_t start, resource_size_t len,
-                              void __iomem *ioaddr)
+                              resource_size_t start, resource_size_t len)
 {
        struct dfl_fpga_enum_dfl *dfl;
 
@@ -996,7 +1311,6 @@ int dfl_fpga_enum_info_add_dfl(struct dfl_fpga_enum_info *info,
 
        dfl->start = start;
        dfl->len = len;
-       dfl->ioaddr = ioaddr;
 
        list_add_tail(&dfl->node, &info->dfls);
 
@@ -1119,7 +1433,7 @@ dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info)
         * Lists.
         */
        list_for_each_entry(dfl, &info->dfls, node) {
-               ret = parse_feature_list(binfo, dfl);
+               ret = parse_feature_list(binfo, dfl->start, dfl->len);
                if (ret) {
                        remove_feature_devs(cdev);
                        build_info_free(binfo);
@@ -1212,11 +1526,17 @@ static int __init dfl_fpga_init(void)
 {
        int ret;
 
+       ret = bus_register(&dfl_bus_type);
+       if (ret)
+               return ret;
+
        dfl_ids_init();
 
        ret = dfl_chardev_init();
-       if (ret)
+       if (ret) {
                dfl_ids_destroy();
+               bus_unregister(&dfl_bus_type);
+       }
 
        return ret;
 }
@@ -1424,7 +1744,7 @@ static int do_set_irq_trigger(struct dfl_feature *feature, unsigned int idx,
                return 0;
 
        feature->irq_ctx[idx].name =
-               kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%llx)", idx,
+               kasprintf(GFP_KERNEL, "fpga-irq[%u](%s-%x)", idx,
                          dev_name(&pdev->dev), feature->id);
        if (!feature->irq_ctx[idx].name)
                return -ENOMEM;
@@ -1554,6 +1874,7 @@ static void __exit dfl_fpga_exit(void)
 {
        dfl_chardev_uinit();
        dfl_ids_destroy();
+       bus_unregister(&dfl_bus_type);
 }
 
 module_init(dfl_fpga_init);
index a32dfba..5dc758f 100644 (file)
@@ -197,7 +197,7 @@ int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);
  * @id: unique dfl private feature id.
  */
 struct dfl_feature_id {
-       u64 id;
+       u16 id;
 };
 
 /**
@@ -236,16 +236,18 @@ struct dfl_feature_irq_ctx {
  * @irq_ctx: interrupt context list.
  * @nr_irqs: number of interrupt contexts.
  * @ops: ops of this sub feature.
+ * @ddev: ptr to the dfl device of this sub feature.
  * @priv: priv data of this feature.
  */
 struct dfl_feature {
        struct platform_device *dev;
-       u64 id;
+       u16 id;
        int resource_index;
        void __iomem *ioaddr;
        struct dfl_feature_irq_ctx *irq_ctx;
        unsigned int nr_irqs;
        const struct dfl_feature_ops *ops;
+       struct dfl_device *ddev;
        void *priv;
 };
 
@@ -365,7 +367,7 @@ struct platform_device *dfl_fpga_inode_to_feature_dev(struct inode *inode)
           (feature) < (pdata)->features + (pdata)->num; (feature)++)
 
 static inline
-struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id)
+struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u16 id)
 {
        struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
        struct dfl_feature *feature;
@@ -378,7 +380,7 @@ struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u64 id)
 }
 
 static inline
-void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id)
+void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u16 id)
 {
        struct dfl_feature *feature = dfl_get_feature_by_id(dev, id);
 
@@ -389,7 +391,7 @@ void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u64 id)
        return NULL;
 }
 
-static inline bool is_dfl_feature_present(struct device *dev, u64 id)
+static inline bool is_dfl_feature_present(struct device *dev, u16 id)
 {
        return !!dfl_get_feature_ioaddr_by_id(dev, id);
 }
@@ -441,22 +443,17 @@ struct dfl_fpga_enum_info {
  *
  * @start: base address of this device feature list.
  * @len: size of this device feature list.
- * @ioaddr: mapped base address of this device feature list.
  * @node: node in list of device feature lists.
  */
 struct dfl_fpga_enum_dfl {
        resource_size_t start;
        resource_size_t len;
-
-       void __iomem *ioaddr;
-
        struct list_head node;
 };
 
 struct dfl_fpga_enum_info *dfl_fpga_enum_info_alloc(struct device *dev);
 int dfl_fpga_enum_info_add_dfl(struct dfl_fpga_enum_info *info,
-                              resource_size_t start, resource_size_t len,
-                              void __iomem *ioaddr);
+                              resource_size_t start, resource_size_t len);
 int dfl_fpga_enum_info_add_irq(struct dfl_fpga_enum_info *info,
                               unsigned int nr_irqs, int *irq_table);
 void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info);
@@ -519,4 +516,88 @@ long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
                               struct dfl_feature *feature,
                               unsigned long arg);
 
+/**
+ * enum dfl_id_type - define the DFL FIU types
+ */
+enum dfl_id_type {
+       FME_ID,
+       PORT_ID,
+       DFL_ID_MAX,
+};
+
+/**
+ * struct dfl_device_id -  dfl device identifier
+ * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
+ * @feature_id: contains 12 bits feature identifier local to its DFL FIU type.
+ * @driver_data: driver specific data.
+ */
+struct dfl_device_id {
+       u8 type;
+       u16 feature_id;
+       unsigned long driver_data;
+};
+
+/**
+ * struct dfl_device - represent an dfl device on dfl bus
+ *
+ * @dev: generic device interface.
+ * @id: id of the dfl device.
+ * @type: type of DFL FIU of the device. See enum dfl_id_type.
+ * @feature_id: 16 bits feature identifier local to its DFL FIU type.
+ * @mmio_res: mmio resource of this dfl device.
+ * @irqs: list of Linux IRQ numbers of this dfl device.
+ * @num_irqs: number of IRQs supported by this dfl device.
+ * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
+ * @id_entry: matched id entry in dfl driver's id table.
+ */
+struct dfl_device {
+       struct device dev;
+       int id;
+       u8 type;
+       u16 feature_id;
+       struct resource mmio_res;
+       int *irqs;
+       unsigned int num_irqs;
+       struct dfl_fpga_cdev *cdev;
+       const struct dfl_device_id *id_entry;
+};
+
+/**
+ * struct dfl_driver - represent an dfl device driver
+ *
+ * @drv: driver model structure.
+ * @id_table: pointer to table of device IDs the driver is interested in.
+ *           { } member terminated.
+ * @probe: mandatory callback for device binding.
+ * @remove: callback for device unbinding.
+ */
+struct dfl_driver {
+       struct device_driver drv;
+       const struct dfl_device_id *id_table;
+
+       int (*probe)(struct dfl_device *dfl_dev);
+       void (*remove)(struct dfl_device *dfl_dev);
+};
+
+#define to_dfl_dev(d) container_of(d, struct dfl_device, dev)
+#define to_dfl_drv(d) container_of(d, struct dfl_driver, drv)
+
+/*
+ * use a macro to avoid include chaining to get THIS_MODULE.
+ */
+#define dfl_driver_register(drv) \
+       __dfl_driver_register(drv, THIS_MODULE)
+int __dfl_driver_register(struct dfl_driver *dfl_drv, struct module *owner);
+void dfl_driver_unregister(struct dfl_driver *dfl_drv);
+
+/*
+ * module_dfl_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_dfl_driver(__dfl_driver) \
+       module_driver(__dfl_driver, dfl_driver_register, \
+                     dfl_driver_unregister)
+
 #endif /* __FPGA_DFL_H */
index bde5a9d..c3134b8 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * FPGA Region - Device Tree support for FPGA programming under Linux
+ * FPGA Region - Support for FPGA programming under Linux
  *
  *  Copyright (C) 2013-2016 Altera Corporation
  *  Copyright (C) 2017 Intel Corporation
index 44b7c56..657a70c 100644 (file)
@@ -196,17 +196,13 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
        if (ret < 0)
                goto init_done;
 
-       ret = wait_for_completion_interruptible_timeout(
+       ret = wait_for_completion_timeout(
                &priv->status_return_completion, S10_RECONFIG_TIMEOUT);
        if (!ret) {
                dev_err(dev, "timeout waiting for RECONFIG_REQUEST\n");
                ret = -ETIMEDOUT;
                goto init_done;
        }
-       if (ret < 0) {
-               dev_err(dev, "error (%d) waiting for RECONFIG_REQUEST\n", ret);
-               goto init_done;
-       }
 
        ret = 0;
        if (!test_and_clear_bit(SVC_STATUS_OK, &priv->status)) {
@@ -318,7 +314,7 @@ static int s10_ops_write(struct fpga_manager *mgr, const char *buf,
                 */
                wait_status = 1; /* not timed out */
                if (!priv->status)
-                       wait_status = wait_for_completion_interruptible_timeout(
+                       wait_status = wait_for_completion_timeout(
                                &priv->status_return_completion,
                                S10_BUFFER_TIMEOUT);
 
@@ -340,13 +336,6 @@ static int s10_ops_write(struct fpga_manager *mgr, const char *buf,
                        ret = -ETIMEDOUT;
                        break;
                }
-               if (wait_status < 0) {
-                       ret = wait_status;
-                       dev_err(dev,
-                               "error (%d) waiting for svc layer buffers\n",
-                               ret);
-                       break;
-               }
        }
 
        if (!s10_free_buffers(mgr))
@@ -372,7 +361,7 @@ static int s10_ops_write_complete(struct fpga_manager *mgr,
                if (ret < 0)
                        break;
 
-               ret = wait_for_completion_interruptible_timeout(
+               ret = wait_for_completion_timeout(
                        &priv->status_return_completion, timeout);
                if (!ret) {
                        dev_err(dev,
@@ -380,12 +369,6 @@ static int s10_ops_write_complete(struct fpga_manager *mgr,
                        ret = -ETIMEDOUT;
                        break;
                }
-               if (ret < 0) {
-                       dev_err(dev,
-                               "error (%d) waiting for RECONFIG_COMPLETED\n",
-                               ret);
-                       break;
-               }
                /* Not error or timeout, so ret is # of jiffies until timeout */
                timeout = ret;
                ret = 0;
index 2967aa2..824abbb 100644 (file)
@@ -27,11 +27,22 @@ struct xilinx_spi_conf {
        struct gpio_desc *done;
 };
 
-static enum fpga_mgr_states xilinx_spi_state(struct fpga_manager *mgr)
+static int get_done_gpio(struct fpga_manager *mgr)
 {
        struct xilinx_spi_conf *conf = mgr->priv;
+       int ret;
+
+       ret = gpiod_get_value(conf->done);
+
+       if (ret < 0)
+               dev_err(&mgr->dev, "Error reading DONE (%d)\n", ret);
+
+       return ret;
+}
 
-       if (!gpiod_get_value(conf->done))
+static enum fpga_mgr_states xilinx_spi_state(struct fpga_manager *mgr)
+{
+       if (!get_done_gpio(mgr))
                return FPGA_MGR_STATE_RESET;
 
        return FPGA_MGR_STATE_UNKNOWN;
@@ -57,11 +68,21 @@ static int wait_for_init_b(struct fpga_manager *mgr, int value,
 
        if (conf->init_b) {
                while (time_before(jiffies, timeout)) {
-                       /* dump_state(conf, "wait for init_d .."); */
-                       if (gpiod_get_value(conf->init_b) == value)
+                       int ret = gpiod_get_value(conf->init_b);
+
+                       if (ret == value)
                                return 0;
+
+                       if (ret < 0) {
+                               dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret);
+                               return ret;
+                       }
+
                        usleep_range(100, 400);
                }
+
+               dev_err(&mgr->dev, "Timeout waiting for INIT_B to %s\n",
+                       value ? "assert" : "deassert");
                return -ETIMEDOUT;
        }
 
@@ -78,7 +99,7 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr,
        int err;
 
        if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) {
-               dev_err(&mgr->dev, "Partial reconfiguration not supported.\n");
+               dev_err(&mgr->dev, "Partial reconfiguration not supported\n");
                return -EINVAL;
        }
 
@@ -86,7 +107,6 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr,
 
        err = wait_for_init_b(mgr, 1, 1); /* min is 500 ns */
        if (err) {
-               dev_err(&mgr->dev, "INIT_B pin did not go low\n");
                gpiod_set_value(conf->prog_b, 0);
                return err;
        }
@@ -94,12 +114,10 @@ static int xilinx_spi_write_init(struct fpga_manager *mgr,
        gpiod_set_value(conf->prog_b, 0);
 
        err = wait_for_init_b(mgr, 0, 0);
-       if (err) {
-               dev_err(&mgr->dev, "INIT_B pin did not go high\n");
+       if (err)
                return err;
-       }
 
-       if (gpiod_get_value(conf->done)) {
+       if (get_done_gpio(mgr)) {
                dev_err(&mgr->dev, "Unexpected DONE pin state...\n");
                return -EIO;
        }
@@ -152,25 +170,46 @@ static int xilinx_spi_write_complete(struct fpga_manager *mgr,
                                     struct fpga_image_info *info)
 {
        struct xilinx_spi_conf *conf = mgr->priv;
-       unsigned long timeout;
+       unsigned long timeout = jiffies + usecs_to_jiffies(info->config_complete_timeout_us);
+       bool expired = false;
+       int done;
        int ret;
 
-       if (gpiod_get_value(conf->done))
-               return xilinx_spi_apply_cclk_cycles(conf);
+       /*
+        * This loop is carefully written such that if the driver is
+        * scheduled out for more than 'timeout', we still check for DONE
+        * before giving up and we apply 8 extra CCLK cycles in all cases.
+        */
+       while (!expired) {
+               expired = time_after(jiffies, timeout);
 
-       timeout = jiffies + usecs_to_jiffies(info->config_complete_timeout_us);
-
-       while (time_before(jiffies, timeout)) {
+               done = get_done_gpio(mgr);
+               if (done < 0)
+                       return done;
 
                ret = xilinx_spi_apply_cclk_cycles(conf);
                if (ret)
                        return ret;
 
-               if (gpiod_get_value(conf->done))
-                       return xilinx_spi_apply_cclk_cycles(conf);
+               if (done)
+                       return 0;
+       }
+
+       if (conf->init_b) {
+               ret = gpiod_get_value(conf->init_b);
+
+               if (ret < 0) {
+                       dev_err(&mgr->dev, "Error reading INIT_B (%d)\n", ret);
+                       return ret;
+               }
+
+               dev_err(&mgr->dev,
+                       ret ? "CRC error or invalid device\n"
+                       : "Missing sync word or incomplete bitstream\n");
+       } else {
+               dev_err(&mgr->dev, "Timeout after config data transfer\n");
        }
 
-       dev_err(&mgr->dev, "Timeout after config data transfer.\n");
        return -ETIMEDOUT;
 }
 
index 8244da8..4e60e84 100644 (file)
@@ -50,6 +50,7 @@ static const int engine_page_size = 0x400;
 #define FSI_SMODE              0x0     /* R/W: Mode register */
 #define FSI_SISC               0x8     /* R/W: Interrupt condition */
 #define FSI_SSTAT              0x14    /* R  : Slave status */
+#define FSI_SLBUS              0x30    /* W  : LBUS Ownership */
 #define FSI_LLMODE             0x100   /* R/W: Link layer mode register */
 
 /*
@@ -66,6 +67,11 @@ static const int engine_page_size = 0x400;
 #define FSI_SMODE_LBCRR_SHIFT  8               /* Clk ratio shift */
 #define FSI_SMODE_LBCRR_MASK   0xf             /* Clk ratio mask */
 
+/*
+ * SLBUS fields
+ */
+#define FSI_SLBUS_FORCE                0x80000000      /* Force LBUS ownership */
+
 /*
  * LLMODE fields
  */
@@ -981,7 +987,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
        uint32_t cfam_id;
        struct fsi_slave *slave;
        uint8_t crc;
-       __be32 data, llmode;
+       __be32 data, llmode, slbus;
        int rc;
 
        /* Currently, we only support single slaves on a link, and use the
@@ -1052,6 +1058,14 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
 
        }
 
+       slbus = cpu_to_be32(FSI_SLBUS_FORCE);
+       rc = fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SLBUS,
+                             &slbus, sizeof(slbus));
+       if (rc)
+               dev_warn(&master->dev,
+                        "can't set slbus on slave:%02x:%02x %d\n", link, id,
+                        rc);
+
        rc = fsi_slave_set_smode(slave);
        if (rc) {
                dev_warn(&master->dev,
@@ -1154,10 +1168,18 @@ static int fsi_master_write(struct fsi_master *master, int link,
        return rc;
 }
 
+static int fsi_master_link_disable(struct fsi_master *master, int link)
+{
+       if (master->link_enable)
+               return master->link_enable(master, link, false);
+
+       return 0;
+}
+
 static int fsi_master_link_enable(struct fsi_master *master, int link)
 {
        if (master->link_enable)
-               return master->link_enable(master, link);
+               return master->link_enable(master, link, true);
 
        return 0;
 }
@@ -1192,12 +1214,15 @@ static int fsi_master_scan(struct fsi_master *master)
                }
                rc = fsi_master_break(master, link);
                if (rc) {
+                       fsi_master_link_disable(master, link);
                        dev_dbg(&master->dev,
                                "break to link %d failed: %d\n", link, rc);
                        continue;
                }
 
-               fsi_slave_init(master, link, 0);
+               rc = fsi_slave_init(master, link, 0);
+               if (rc)
+                       fsi_master_link_disable(master, link);
        }
 
        return 0;
index f49742b..c006ec0 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/iopoll.h>
+#include <linux/gpio/consumer.h>
 
 #include "fsi-master.h"
 
@@ -21,6 +22,7 @@ struct fsi_master_aspeed {
        struct device           *dev;
        void __iomem            *base;
        struct clk              *clk;
+       struct gpio_desc        *cfam_reset_gpio;
 };
 
 #define to_fsi_master_aspeed(m) \
@@ -82,7 +84,12 @@ static const u32 fsi_base = 0xa0000000;
 
 #define FSI_LINK_ENABLE_SETUP_TIME     10      /* in mS */
 
-#define DEFAULT_DIVISOR                        14
+/* Run the bus at maximum speed by default */
+#define FSI_DIVISOR_DEFAULT            1
+#define FSI_DIVISOR_CABLED             2
+static u16 aspeed_fsi_divisor = FSI_DIVISOR_DEFAULT;
+module_param_named(bus_div,aspeed_fsi_divisor, ushort, 0);
+
 #define OPB_POLL_TIMEOUT               10000
 
 static int __opb_write(struct fsi_master_aspeed *aspeed, u32 addr,
@@ -241,9 +248,10 @@ static int aspeed_master_read(struct fsi_master *master, int link,
        struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master);
        int ret;
 
-       if (id != 0)
+       if (id > 0x3)
                return -EINVAL;
 
+       addr |= id << 21;
        addr += link * FSI_HUB_LINK_SIZE;
 
        switch (size) {
@@ -273,9 +281,10 @@ static int aspeed_master_write(struct fsi_master *master, int link,
        struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master);
        int ret;
 
-       if (id != 0)
+       if (id > 0x3)
                return -EINVAL;
 
+       addr |= id << 21;
        addr += link * FSI_HUB_LINK_SIZE;
 
        switch (size) {
@@ -299,32 +308,28 @@ static int aspeed_master_write(struct fsi_master *master, int link,
        return 0;
 }
 
-static int aspeed_master_link_enable(struct fsi_master *master, int link)
+static int aspeed_master_link_enable(struct fsi_master *master, int link,
+                                    bool enable)
 {
        struct fsi_master_aspeed *aspeed = to_fsi_master_aspeed(master);
        int idx, bit, ret;
-       __be32 reg, result;
+       __be32 reg;
 
        idx = link / 32;
        bit = link % 32;
 
        reg = cpu_to_be32(0x80000000 >> bit);
 
+       if (!enable)
+               return opb_writel(aspeed, ctrl_base + FSI_MCENP0 + (4 * idx),
+                                 reg);
+
        ret = opb_writel(aspeed, ctrl_base + FSI_MSENP0 + (4 * idx), reg);
        if (ret)
                return ret;
 
        mdelay(FSI_LINK_ENABLE_SETUP_TIME);
 
-       ret = opb_readl(aspeed, ctrl_base + FSI_MENP0 + (4 * idx), &result);
-       if (ret)
-               return ret;
-
-       if (result != reg) {
-               dev_err(aspeed->dev, "%s failed: %08x\n", __func__, result);
-               return -EIO;
-       }
-
        return 0;
 }
 
@@ -386,9 +391,11 @@ static int aspeed_master_init(struct fsi_master_aspeed *aspeed)
        opb_writel(aspeed, ctrl_base + FSI_MECTRL, reg);
 
        reg = cpu_to_be32(FSI_MMODE_ECRC | FSI_MMODE_EPC | FSI_MMODE_RELA
-                       | fsi_mmode_crs0(DEFAULT_DIVISOR)
-                       | fsi_mmode_crs1(DEFAULT_DIVISOR)
+                       | fsi_mmode_crs0(aspeed_fsi_divisor)
+                       | fsi_mmode_crs1(aspeed_fsi_divisor)
                        | FSI_MMODE_P8_TO_LSB);
+       dev_info(aspeed->dev, "mmode set to %08x (divisor %d)\n",
+                       be32_to_cpu(reg), aspeed_fsi_divisor);
        opb_writel(aspeed, ctrl_base + FSI_MMODE, reg);
 
        reg = cpu_to_be32(0xffff0000);
@@ -419,6 +426,90 @@ static int aspeed_master_init(struct fsi_master_aspeed *aspeed)
        return 0;
 }
 
+static ssize_t cfam_reset_store(struct device *dev, struct device_attribute *attr,
+                               const char *buf, size_t count)
+{
+       struct fsi_master_aspeed *aspeed = dev_get_drvdata(dev);
+
+       gpiod_set_value(aspeed->cfam_reset_gpio, 1);
+       usleep_range(900, 1000);
+       gpiod_set_value(aspeed->cfam_reset_gpio, 0);
+
+       return count;
+}
+
+static DEVICE_ATTR(cfam_reset, 0200, NULL, cfam_reset_store);
+
+static int setup_cfam_reset(struct fsi_master_aspeed *aspeed)
+{
+       struct device *dev = aspeed->dev;
+       struct gpio_desc *gpio;
+       int rc;
+
+       gpio = devm_gpiod_get_optional(dev, "cfam-reset", GPIOD_OUT_LOW);
+       if (IS_ERR(gpio))
+               return PTR_ERR(gpio);
+       if (!gpio)
+               return 0;
+
+       aspeed->cfam_reset_gpio = gpio;
+
+       rc = device_create_file(dev, &dev_attr_cfam_reset);
+       if (rc) {
+               devm_gpiod_put(dev, gpio);
+               return rc;
+       }
+
+       return 0;
+}
+
+static int tacoma_cabled_fsi_fixup(struct device *dev)
+{
+       struct gpio_desc *routing_gpio, *mux_gpio;
+       int gpio;
+
+       /*
+        * The routing GPIO is a jumper indicating we should mux for the
+        * externally connected FSI cable.
+        */
+       routing_gpio = devm_gpiod_get_optional(dev, "fsi-routing",
+                       GPIOD_IN | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
+       if (IS_ERR(routing_gpio))
+               return PTR_ERR(routing_gpio);
+       if (!routing_gpio)
+               return 0;
+
+       mux_gpio = devm_gpiod_get_optional(dev, "fsi-mux", GPIOD_ASIS);
+       if (IS_ERR(mux_gpio))
+               return PTR_ERR(mux_gpio);
+       if (!mux_gpio)
+               return 0;
+
+       gpio = gpiod_get_value(routing_gpio);
+       if (gpio < 0)
+               return gpio;
+
+       /* If the routing GPIO is high we should set the mux to low. */
+       if (gpio) {
+               /*
+                * Cable signal integrity means we should run the bus
+                * slightly slower. Do not override if a kernel param
+                * has already overridden.
+                */
+               if (aspeed_fsi_divisor == FSI_DIVISOR_DEFAULT)
+                       aspeed_fsi_divisor = FSI_DIVISOR_CABLED;
+
+               gpiod_direction_output(mux_gpio, 0);
+               dev_info(dev, "FSI configured for external cable\n");
+       } else {
+               gpiod_direction_output(mux_gpio, 1);
+       }
+
+       devm_gpiod_put(dev, routing_gpio);
+
+       return 0;
+}
+
 static int fsi_master_aspeed_probe(struct platform_device *pdev)
 {
        struct fsi_master_aspeed *aspeed;
@@ -426,6 +517,12 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
        int rc, links, reg;
        __be32 raw;
 
+       rc = tacoma_cabled_fsi_fixup(&pdev->dev);
+       if (rc) {
+               dev_err(&pdev->dev, "Tacoma FSI cable fixup failed\n");
+               return rc;
+       }
+
        aspeed = devm_kzalloc(&pdev->dev, sizeof(*aspeed), GFP_KERNEL);
        if (!aspeed)
                return -ENOMEM;
@@ -448,6 +545,11 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
                return rc;
        }
 
+       rc = setup_cfam_reset(aspeed);
+       if (rc) {
+               dev_err(&pdev->dev, "CFAM reset GPIO setup failed\n");
+       }
+
        writel(0x1, aspeed->base + OPB_CLK_SYNC);
        writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN,
                        aspeed->base + OPB_IRQ_MASK);
index 04d10ea..57a779a 100644 (file)
@@ -838,7 +838,7 @@ static int load_copro_firmware(struct fsi_master_acf *master)
        rc = request_firmware(&fw, FW_FILE_NAME, master->dev);
        if (rc) {
                dev_err(
-                       master->dev, "Error %d to load firwmare '%s' !\n",
+                       master->dev, "Error %d to load firmware '%s' !\n",
                        rc, FW_FILE_NAME);
                return rc;
        }
@@ -1039,7 +1039,8 @@ static void fsi_master_acf_setup_external(struct fsi_master_acf *master)
        gpiod_direction_input(master->gpio_data);
 }
 
-static int fsi_master_acf_link_enable(struct fsi_master *_master, int link)
+static int fsi_master_acf_link_enable(struct fsi_master *_master, int link,
+                                     bool enable)
 {
        struct fsi_master_acf *master = to_fsi_master_acf(_master);
        int rc = -EBUSY;
@@ -1049,7 +1050,7 @@ static int fsi_master_acf_link_enable(struct fsi_master *_master, int link)
 
        mutex_lock(&master->lock);
        if (!master->external_mode) {
-               gpiod_set_value(master->gpio_enable, 1);
+               gpiod_set_value(master->gpio_enable, enable ? 1 : 0);
                rc = 0;
        }
        mutex_unlock(&master->lock);
index 4dcce17..aa97c4a 100644 (file)
@@ -678,7 +678,8 @@ static void fsi_master_gpio_init_external(struct fsi_master_gpio *master)
        gpiod_direction_input(master->gpio_data);
 }
 
-static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
+static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link,
+                                      bool enable)
 {
        struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
        int rc = -EBUSY;
@@ -688,7 +689,7 @@ static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
 
        mutex_lock(&master->cmd_lock);
        if (!master->external_mode) {
-               gpiod_set_value(master->gpio_enable, 1);
+               gpiod_set_value(master->gpio_enable, enable ? 1 : 0);
                rc = 0;
        }
        mutex_unlock(&master->cmd_lock);
index def35cf..01f0a79 100644 (file)
@@ -77,7 +77,8 @@ static int hub_master_break(struct fsi_master *master, int link)
        return hub_master_write(master, link, 0, addr, &cmd, sizeof(cmd));
 }
 
-static int hub_master_link_enable(struct fsi_master *master, int link)
+static int hub_master_link_enable(struct fsi_master *master, int link,
+                                 bool enable)
 {
        struct fsi_master_hub *hub = to_fsi_master_hub(master);
        int idx, bit;
@@ -89,13 +90,17 @@ static int hub_master_link_enable(struct fsi_master *master, int link)
 
        reg = cpu_to_be32(0x80000000 >> bit);
 
+       if (!enable)
+               return fsi_device_write(hub->upstream, FSI_MCENP0 + (4 * idx),
+                                       &reg, 4);
+
        rc = fsi_device_write(hub->upstream, FSI_MSENP0 + (4 * idx), &reg, 4);
+       if (rc)
+               return rc;
 
        mdelay(FSI_LINK_ENABLE_SETUP_TIME);
 
-       fsi_device_read(hub->upstream, FSI_MENP0 + (4 * idx), &reg, 4);
-
-       return rc;
+       return 0;
 }
 
 static void hub_master_release(struct device *dev)
@@ -271,7 +276,7 @@ static int hub_master_remove(struct device *dev)
        return 0;
 }
 
-static struct fsi_device_id hub_master_ids[] = {
+static const struct fsi_device_id hub_master_ids[] = {
        {
                .engine_type = FSI_ENGID_HUB_MASTER,
                .version = FSI_VERSION_ANY,
index 6e8d4d4..cd6bee5 100644 (file)
@@ -130,7 +130,8 @@ struct fsi_master {
                                uint32_t addr, const void *val, size_t size);
        int             (*term)(struct fsi_master *, int link, uint8_t id);
        int             (*send_break)(struct fsi_master *, int link);
-       int             (*link_enable)(struct fsi_master *, int link);
+       int             (*link_enable)(struct fsi_master *, int link,
+                                      bool enable);
        int             (*link_config)(struct fsi_master *, int link,
                                       u8 t_send_delay, u8 t_echo_delay);
 };
index 7da9c81..9eeb856 100644 (file)
@@ -555,7 +555,7 @@ static int occ_probe(struct platform_device *pdev)
 
        hwmon_dev_info.id = occ->idx;
        hwmon_dev = platform_device_register_full(&hwmon_dev_info);
-       if (!hwmon_dev)
+       if (IS_ERR(hwmon_dev))
                dev_warn(dev, "failed to create hwmon device\n");
 
        return 0;
index f54df9e..bfd5e5d 100644 (file)
@@ -1028,7 +1028,7 @@ static int sbefifo_remove(struct device *dev)
        return 0;
 }
 
-static struct fsi_device_id sbefifo_ids[] = {
+static const struct fsi_device_id sbefifo_ids[] = {
        {
                .engine_type = FSI_ENGID_SBE,
                .version = FSI_VERSION_ANY,
index 004dc03..b45bfab 100644 (file)
@@ -627,7 +627,7 @@ static int scom_remove(struct device *dev)
        return 0;
 }
 
-static struct fsi_device_id scom_ids[] = {
+static const struct fsi_device_id scom_ids[] = {
        {
                .engine_type = FSI_ENGID_SCOM,
                .version = FSI_VERSION_ANY,
index d16645c..3aa4593 100644 (file)
@@ -303,16 +303,16 @@ static int aspeed_sgpio_set_type(struct irq_data *d, unsigned int type)
        switch (type & IRQ_TYPE_SENSE_MASK) {
        case IRQ_TYPE_EDGE_BOTH:
                type2 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_EDGE_RISING:
                type0 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_EDGE_FALLING:
                handler = handle_edge_irq;
                break;
        case IRQ_TYPE_LEVEL_HIGH:
                type0 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_LEVEL_LOW:
                type1 |= bit;
                handler = handle_level_irq;
index 879db23..bf08b45 100644 (file)
@@ -611,16 +611,16 @@ static int aspeed_gpio_set_type(struct irq_data *d, unsigned int type)
        switch (type & IRQ_TYPE_SENSE_MASK) {
        case IRQ_TYPE_EDGE_BOTH:
                type2 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_EDGE_RISING:
                type0 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_EDGE_FALLING:
                handler = handle_edge_irq;
                break;
        case IRQ_TYPE_LEVEL_HIGH:
                type0 |= bit;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_LEVEL_LOW:
                type1 |= bit;
                handler = handle_level_irq;
index 53fae02..d535934 100644 (file)
@@ -129,7 +129,7 @@ static int ath79_gpio_irq_set_type(struct irq_data *data,
 
        case IRQ_TYPE_LEVEL_HIGH:
                polarity |= mask;
-               /* fall through */
+               fallthrough;
        case IRQ_TYPE_LEVEL_LOW:
                type |= mask;
                break;
index 8c97577..ad61daf 100644 (file)
@@ -617,14 +617,12 @@ static int sprd_eic_probe(struct platform_device *pdev)
                sprd_eic->chip.free = sprd_eic_free;
                sprd_eic->chip.set_config = sprd_eic_set_config;
                sprd_eic->chip.set = sprd_eic_set;
-               /* fall-through */
+               fallthrough;
        case SPRD_EIC_ASYNC:
-               /* fall-through */
        case SPRD_EIC_SYNC:
                sprd_eic->chip.get = sprd_eic_get;
                break;
        case SPRD_EIC_LATCH:
-               /* fall-through */
        default:
                break;
        }
index 6c48809..b0155d6 100644 (file)
@@ -308,7 +308,7 @@ static void stmpe_dbg_show_one(struct seq_file *s,
                        if (ret < 0)
                                return;
                        edge_det = !!(ret & mask);
-                       /* fall through */
+                       fallthrough;
                case STMPE1801:
                        rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB + bank];
                        fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB + bank];
@@ -321,7 +321,7 @@ static void stmpe_dbg_show_one(struct seq_file *s,
                        if (ret < 0)
                                return;
                        fall = !!(ret & mask);
-                       /* fall through */
+                       fallthrough;
                case STMPE801:
                case STMPE1600:
                        irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB + bank];
index 9276051..54ca3c1 100644 (file)
@@ -1264,7 +1264,7 @@ static int acpi_gpio_package_count(const union acpi_object *obj)
                switch (element->type) {
                case ACPI_TYPE_LOCAL_REFERENCE:
                        element += 3;
-                       /* Fallthrough */
+                       fallthrough;
                case ACPI_TYPE_INTEGER:
                        element++;
                        count++;
index 7e59e47..cdea133 100644 (file)
@@ -152,7 +152,7 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
                dev_warn(adev->dev,
                         "Invalid sdma engine id (%d), using engine id 0\n",
                         engine_id);
-               /* fall through */
+               fallthrough;
        case 0:
                sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0,
                                mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;
index c7fd0c4..1102de7 100644 (file)
@@ -195,19 +195,32 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
                                unsigned int engine_id,
                                unsigned int queue_id)
 {
-       uint32_t sdma_engine_reg_base[2] = {
-               SOC15_REG_OFFSET(SDMA0, 0,
-                                mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL,
-               SOC15_REG_OFFSET(SDMA1, 0,
-                                mmSDMA1_RLC0_RB_CNTL) - mmSDMA1_RLC0_RB_CNTL
-       };
-       uint32_t retval = sdma_engine_reg_base[engine_id]
+       uint32_t sdma_engine_reg_base = 0;
+       uint32_t sdma_rlc_reg_offset;
+
+       switch (engine_id) {
+       default:
+               dev_warn(adev->dev,
+                        "Invalid sdma engine id (%d), using engine id 0\n",
+                        engine_id);
+               fallthrough;
+       case 0:
+               sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0, 0,
+                               mmSDMA0_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;
+               break;
+       case 1:
+               sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA1, 0,
+                               mmSDMA1_RLC0_RB_CNTL) - mmSDMA0_RLC0_RB_CNTL;
+               break;
+       }
+
+       sdma_rlc_reg_offset = sdma_engine_reg_base
                + queue_id * (mmSDMA0_RLC1_RB_CNTL - mmSDMA0_RLC0_RB_CNTL);
 
        pr_debug("RLC register offset for SDMA%d RLC%d: 0x%x\n", engine_id,
-                       queue_id, retval);
+                queue_id, sdma_rlc_reg_offset);
 
-       return retval;
+       return sdma_rlc_reg_offset;
 }
 
 static inline struct v9_mqd *get_mqd(void *mqd)
index 0047da0..4145480 100644 (file)
@@ -179,6 +179,7 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
                case CHIP_VEGA20:
                case CHIP_ARCTURUS:
                case CHIP_SIENNA_CICHLID:
+               case CHIP_NAVY_FLOUNDER:
                        /* enable runpm if runpm=1 */
                        if (amdgpu_runtime_pm > 0)
                                adev->runpm = true;
@@ -678,8 +679,12 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file
                 * in the bitfields */
                if (se_num == AMDGPU_INFO_MMR_SE_INDEX_MASK)
                        se_num = 0xffffffff;
+               else if (se_num >= AMDGPU_GFX_MAX_SE)
+                       return -EINVAL;
                if (sh_num == AMDGPU_INFO_MMR_SH_INDEX_MASK)
                        sh_num = 0xffffffff;
+               else if (sh_num >= AMDGPU_GFX_MAX_SH_PER_SE)
+                       return -EINVAL;
 
                if (info->read_mmr_reg.count > 128)
                        return -EINVAL;
index 7fe5642..d8c6520 100644 (file)
@@ -522,8 +522,7 @@ static int psp_asd_load(struct psp_context *psp)
         * add workaround to bypass it for sriov now.
         * TODO: add version check to make it common
         */
-       if (amdgpu_sriov_vf(psp->adev) ||
-           (psp->adev->asic_type == CHIP_NAVY_FLOUNDER))
+       if (amdgpu_sriov_vf(psp->adev) || !psp->asd_fw)
                return 0;
 
        cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
index bcce4c0..1bedb41 100644 (file)
@@ -1243,7 +1243,6 @@ void amdgpu_ras_debugfs_remove(struct amdgpu_device *adev,
        if (!obj || !obj->ent)
                return;
 
-       debugfs_remove(obj->ent);
        obj->ent = NULL;
        put_obj(obj);
 }
@@ -1257,7 +1256,6 @@ static void amdgpu_ras_debugfs_remove_all(struct amdgpu_device *adev)
                amdgpu_ras_debugfs_remove(adev, &obj->head);
        }
 
-       debugfs_remove_recursive(con->dir);
        con->dir = NULL;
 }
 /* debugfs end */
index 134cc36..0739e25 100644 (file)
@@ -462,7 +462,7 @@ int amdgpu_vram_mgr_alloc_sgt(struct amdgpu_device *adev,
        unsigned int pages;
        int i, r;
 
-       *sgt = kmalloc(sizeof(*sg), GFP_KERNEL);
+       *sgt = kmalloc(sizeof(**sgt), GFP_KERNEL);
        if (!*sgt)
                return -ENOMEM;
 
index 65997ff..037a187 100644 (file)
@@ -7263,10 +7263,8 @@ static void gfx_v10_0_update_medium_grain_clock_gating(struct amdgpu_device *ade
                def = data = RREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE);
                data &= ~(RLC_CGTT_MGCG_OVERRIDE__GRBM_CGTT_SCLK_OVERRIDE_MASK |
                          RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGCG_OVERRIDE_MASK |
-                         RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK);
-
-               /* only for Vega10 & Raven1 */
-               data |= RLC_CGTT_MGCG_OVERRIDE__RLC_CGTT_SCLK_OVERRIDE_MASK;
+                         RLC_CGTT_MGCG_OVERRIDE__GFXIP_MGLS_OVERRIDE_MASK |
+                         RLC_CGTT_MGCG_OVERRIDE__ENABLE_CGTS_LEGACY_MASK);
 
                if (def != data)
                        WREG32_SOC15(GC, 0, mmRLC_CGTT_MGCG_OVERRIDE, data);
index 33f1c4a..88f63d7 100644 (file)
@@ -3250,7 +3250,7 @@ static void gfx_v8_0_tiling_mode_table_init(struct amdgpu_device *adev)
                dev_warn(adev->dev,
                         "Unknown chip type (%d) in function gfx_v8_0_tiling_mode_table_init() falling through to CHIP_CARRIZO\n",
                         adev->asic_type);
-               /* fall through */
+               fallthrough;
 
        case CHIP_CARRIZO:
                modearray[0] = (ARRAY_MODE(ARRAY_2D_TILED_THIN1) |
index cb9d60a..b95f222 100644 (file)
@@ -691,6 +691,7 @@ static const struct soc15_reg_golden golden_settings_gc_9_4_1_arct[] =
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_CHAN_STEER_5_ARCT, 0x3ff, 0x135),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_CONFIG, 0xffffffff, 0x011A0000),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmSQ_FIFO_SIZES, 0xffffffff, 0x00000f00),
+       SOC15_REG_GOLDEN_VALUE(GC, 0, mmTCP_UTCL1_CNTL1, 0x30000000, 0x30000000)
 };
 
 static const struct soc15_reg_rlcg rlcg_access_gc_9_0[] = {
index fa0bca3..5d25059 100644 (file)
@@ -135,6 +135,12 @@ static void gfxhub_v2_1_init_cache_regs(struct amdgpu_device *adev)
 {
        uint32_t tmp;
 
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        /* Setup L2 cache */
        tmp = RREG32_SOC15(GC, 0, mmGCVM_L2_CNTL);
        tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL, ENABLE_L2_CACHE, 1);
@@ -190,6 +196,12 @@ static void gfxhub_v2_1_enable_system_domain(struct amdgpu_device *adev)
 
 static void gfxhub_v2_1_disable_identity_aperture(struct amdgpu_device *adev)
 {
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        WREG32_SOC15(GC, 0, mmGCVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_LO32,
                     0xFFFFFFFF);
        WREG32_SOC15(GC, 0, mmGCVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_HI32,
@@ -326,6 +338,13 @@ void gfxhub_v2_1_set_fault_enable_default(struct amdgpu_device *adev,
                                          bool value)
 {
        u32 tmp;
+
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        tmp = RREG32_SOC15(GC, 0, mmGCVM_L2_PROTECTION_FAULT_CNTL);
        tmp = REG_SET_FIELD(tmp, GCVM_L2_PROTECTION_FAULT_CNTL,
                            RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
index 6e4f3ff..b67ba38 100644 (file)
@@ -1297,7 +1297,7 @@ static void gmc_v9_0_init_golden_registers(struct amdgpu_device *adev)
        case CHIP_VEGA10:
                if (amdgpu_sriov_vf(adev))
                        break;
-               /* fall through */
+               fallthrough;
        case CHIP_VEGA20:
                soc15_program_register_sequence(adev,
                                                golden_settings_mmhub_1_0_0,
index 757fa8e..c79fc54 100644 (file)
@@ -134,6 +134,12 @@ static void mmhub_v2_0_init_cache_regs(struct amdgpu_device *adev)
 {
        uint32_t tmp;
 
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        /* Setup L2 cache */
        tmp = RREG32_SOC15(MMHUB, 0, mmMMVM_L2_CNTL);
        tmp = REG_SET_FIELD(tmp, MMVM_L2_CNTL, ENABLE_L2_CACHE, 1);
@@ -189,6 +195,12 @@ static void mmhub_v2_0_enable_system_domain(struct amdgpu_device *adev)
 
 static void mmhub_v2_0_disable_identity_aperture(struct amdgpu_device *adev)
 {
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        WREG32_SOC15(MMHUB, 0,
                     mmMMVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_LO32,
                     0xFFFFFFFF);
@@ -318,6 +330,13 @@ void mmhub_v2_0_gart_disable(struct amdgpu_device *adev)
 void mmhub_v2_0_set_fault_enable_default(struct amdgpu_device *adev, bool value)
 {
        u32 tmp;
+
+       /* These registers are not accessible to VF-SRIOV.
+        * The PF will program them instead.
+        */
+       if (amdgpu_sriov_vf(adev))
+               return;
+
        tmp = RREG32_SOC15(MMHUB, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL);
        tmp = REG_SET_FIELD(tmp, MMVM_L2_PROTECTION_FAULT_CNTL,
                            RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
index da8024c..ca11253 100644 (file)
@@ -364,6 +364,7 @@ nv_asic_reset_method(struct amdgpu_device *adev)
 
        switch (adev->asic_type) {
        case CHIP_SIENNA_CICHLID:
+       case CHIP_NAVY_FLOUNDER:
                return AMD_RESET_METHOD_MODE1;
        default:
                if (smu_baco_is_support(smu))
index d488d25..e16874f 100644 (file)
@@ -179,12 +179,11 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
                }
                break;
        case CHIP_SIENNA_CICHLID:
+       case CHIP_NAVY_FLOUNDER:
                err = psp_init_ta_microcode(&adev->psp, chip_name);
                if (err)
                        return err;
                break;
-       case CHIP_NAVY_FLOUNDER:
-               break;
        default:
                BUG();
        }
index ea914b2..b5986d1 100644 (file)
@@ -6196,7 +6196,7 @@ static void si_request_link_speed_change_before_state_change(struct amdgpu_devic
                        si_pi->force_pcie_gen = AMDGPU_PCIE_GEN2;
                        if (current_link_speed == AMDGPU_PCIE_GEN2)
                                break;
-                       /* fall through */
+                       fallthrough;
                case AMDGPU_PCIE_GEN2:
                        if (amdgpu_acpi_pcie_performance_request(adev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
                                break;
index e4b33c6..b51c527 100644 (file)
@@ -2196,6 +2196,7 @@ void amdgpu_dm_update_connector_after_detect(
 
                        drm_connector_update_edid_property(connector,
                                                           aconnector->edid);
+                       drm_add_edid_modes(connector, aconnector->edid);
 
                        if (aconnector->dc_link->aux_mode)
                                drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
@@ -2833,12 +2834,18 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
                                    &dm_atomic_state_funcs);
 
        r = amdgpu_display_modeset_create_props(adev);
-       if (r)
+       if (r) {
+               dc_release_state(state->context);
+               kfree(state);
                return r;
+       }
 
        r = amdgpu_dm_audio_init(adev);
-       if (r)
+       if (r) {
+               dc_release_state(state->context);
+               kfree(state);
                return r;
+       }
 
        return 0;
 }
@@ -2855,6 +2862,8 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)
 #if defined(CONFIG_ACPI)
        struct amdgpu_dm_backlight_caps caps;
 
+       memset(&caps, 0, sizeof(caps));
+
        if (dm->backlight_caps.caps_valid)
                return;
 
@@ -2893,51 +2902,50 @@ static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)
        return rc ? 0 : 1;
 }
 
-static u32 convert_brightness(const struct amdgpu_dm_backlight_caps *caps,
-                             const uint32_t user_brightness)
+static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
+                               unsigned *min, unsigned *max)
 {
-       u32 min, max, conversion_pace;
-       u32 brightness = user_brightness;
-
        if (!caps)
-               goto out;
+               return 0;
 
-       if (!caps->aux_support) {
-               max = caps->max_input_signal;
-               min = caps->min_input_signal;
-               /*
-                * The brightness input is in the range 0-255
-                * It needs to be rescaled to be between the
-                * requested min and max input signal
-                * It also needs to be scaled up by 0x101 to
-                * match the DC interface which has a range of
-                * 0 to 0xffff
-                */
-               conversion_pace = 0x101;
-               brightness =
-                       user_brightness
-                       * conversion_pace
-                       * (max - min)
-                       / AMDGPU_MAX_BL_LEVEL
-                       + min * conversion_pace;
+       if (caps->aux_support) {
+               // Firmware limits are in nits, DC API wants millinits.
+               *max = 1000 * caps->aux_max_input_signal;
+               *min = 1000 * caps->aux_min_input_signal;
        } else {
-               /* TODO
-                * We are doing a linear interpolation here, which is OK but
-                * does not provide the optimal result. We probably want
-                * something close to the Perceptual Quantizer (PQ) curve.
-                */
-               max = caps->aux_max_input_signal;
-               min = caps->aux_min_input_signal;
-
-               brightness = (AMDGPU_MAX_BL_LEVEL - user_brightness) * min
-                              + user_brightness * max;
-               // Multiple the value by 1000 since we use millinits
-               brightness *= 1000;
-               brightness = DIV_ROUND_CLOSEST(brightness, AMDGPU_MAX_BL_LEVEL);
+               // Firmware limits are 8-bit, PWM control is 16-bit.
+               *max = 0x101 * caps->max_input_signal;
+               *min = 0x101 * caps->min_input_signal;
        }
+       return 1;
+}
 
-out:
-       return brightness;
+static u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
+                                       uint32_t brightness)
+{
+       unsigned min, max;
+
+       if (!get_brightness_range(caps, &min, &max))
+               return brightness;
+
+       // Rescale 0..255 to min..max
+       return min + DIV_ROUND_CLOSEST((max - min) * brightness,
+                                      AMDGPU_MAX_BL_LEVEL);
+}
+
+static u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
+                                     uint32_t brightness)
+{
+       unsigned min, max;
+
+       if (!get_brightness_range(caps, &min, &max))
+               return brightness;
+
+       if (brightness < min)
+               return 0;
+       // Rescale min..max to 0..255
+       return DIV_ROUND_CLOSEST(AMDGPU_MAX_BL_LEVEL * (brightness - min),
+                                max - min);
 }
 
 static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
@@ -2953,7 +2961,7 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 
        link = (struct dc_link *)dm->backlight_link;
 
-       brightness = convert_brightness(&caps, bd->props.brightness);
+       brightness = convert_brightness_from_user(&caps, bd->props.brightness);
        // Change brightness based on AUX property
        if (caps.aux_support)
                return set_backlight_via_aux(link, brightness);
@@ -2970,7 +2978,7 @@ static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
 
        if (ret == DC_ERROR_UNEXPECTED)
                return bd->props.brightness;
-       return ret;
+       return convert_brightness_to_user(&dm->backlight_caps, ret);
 }
 
 static const struct backlight_ops amdgpu_dm_backlight_ops = {
index e85b58f..336aaa0 100644 (file)
@@ -67,7 +67,7 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
        result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload,
                                      &operation_result);
 
-       if (payload.write)
+       if (payload.write && result >= 0)
                result = msg->size;
 
        if (result < 0)
index 078b7e3..2d5c7da 100644 (file)
@@ -1108,6 +1108,18 @@ static enum bp_result bios_parser_enable_disp_power_gating(
                action);
 }
 
+static enum bp_result bios_parser_enable_lvtma_control(
+       struct dc_bios *dcb,
+       uint8_t uc_pwr_on)
+{
+       struct bios_parser *bp = BP_FROM_DCB(dcb);
+
+       if (!bp->cmd_tbl.enable_lvtma_control)
+               return BP_RESULT_FAILURE;
+
+       return bp->cmd_tbl.enable_lvtma_control(bp, uc_pwr_on);
+}
+
 static bool bios_parser_is_accelerated_mode(
        struct dc_bios *dcb)
 {
@@ -2208,7 +2220,9 @@ static const struct dc_vbios_funcs vbios_funcs = {
        .get_board_layout_info = bios_get_board_layout_info,
        .pack_data_tables = bios_parser_pack_data_tables,
 
-       .get_atom_dc_golden_table = bios_get_atom_dc_golden_table
+       .get_atom_dc_golden_table = bios_get_atom_dc_golden_table,
+
+       .enable_lvtma_control = bios_parser_enable_lvtma_control
 };
 
 static bool bios_parser2_construct(
index bed9157..eb3ae5c 100644 (file)
@@ -904,6 +904,33 @@ static unsigned int get_smu_clock_info_v3_1(struct bios_parser *bp, uint8_t id)
        return 0;
 }
 
+/******************************************************************************
+ ******************************************************************************
+ **
+ **                  LVTMA CONTROL
+ **
+ ******************************************************************************
+ *****************************************************************************/
+
+static enum bp_result enable_lvtma_control(
+       struct bios_parser *bp,
+       uint8_t uc_pwr_on);
+
+static void init_enable_lvtma_control(struct bios_parser *bp)
+{
+       /* TODO add switch for table vrsion */
+       bp->cmd_tbl.enable_lvtma_control = enable_lvtma_control;
+
+}
+
+static enum bp_result enable_lvtma_control(
+       struct bios_parser *bp,
+       uint8_t uc_pwr_on)
+{
+       enum bp_result result = BP_RESULT_FAILURE;
+       return result;
+}
+
 void dal_firmware_parser_init_cmd_tbl(struct bios_parser *bp)
 {
        init_dig_encoder_control(bp);
@@ -919,4 +946,5 @@ void dal_firmware_parser_init_cmd_tbl(struct bios_parser *bp)
        init_set_dce_clock(bp);
        init_get_smu_clock_info(bp);
 
+       init_enable_lvtma_control(bp);
 }
index 7a2af24..7bdce01 100644 (file)
@@ -94,7 +94,8 @@ struct cmd_tbl {
                struct bp_set_dce_clock_parameters *bp_params);
        unsigned int (*get_smu_clock_info)(
                        struct bios_parser *bp, uint8_t id);
-
+       enum bp_result (*enable_lvtma_control)(struct bios_parser *bp,
+                       uint8_t uc_pwr_on);
 };
 
 void dal_firmware_parser_init_cmd_tbl(struct bios_parser *bp);
index c664404..543afa3 100644 (file)
@@ -94,6 +94,15 @@ int rn_get_active_display_cnt_wa(
        return display_count;
 }
 
+void rn_set_low_power_state(struct clk_mgr *clk_mgr_base)
+{
+       struct clk_mgr_internal *clk_mgr = TO_CLK_MGR_INTERNAL(clk_mgr_base);
+
+       rn_vbios_smu_set_dcn_low_power_state(clk_mgr, DCN_PWR_STATE_LOW_POWER);
+       /* update power state */
+       clk_mgr_base->clks.pwr_state = DCN_PWR_STATE_LOW_POWER;
+}
+
 void rn_update_clocks(struct clk_mgr *clk_mgr_base,
                        struct dc_state *context,
                        bool safe_to_lower)
@@ -516,6 +525,7 @@ static struct clk_mgr_funcs dcn21_funcs = {
        .init_clocks = rn_init_clocks,
        .enable_pme_wa = rn_enable_pme_wa,
        .are_clock_states_equal = rn_are_clock_states_equal,
+       .set_low_power_state = rn_set_low_power_state,
        .notify_wm_ranges = rn_notify_wm_ranges,
        .notify_link_rate_change = rn_notify_link_rate_change,
 };
index 4bd6e03..437d1a7 100644 (file)
@@ -763,6 +763,7 @@ static bool detect_dp(struct dc_link *link,
                sink_caps->signal = dp_passive_dongle_detection(link->ddc,
                                                                sink_caps,
                                                                audio_support);
+               link->dpcd_caps.dongle_type = sink_caps->dongle_type;
        }
 
        return true;
@@ -3289,7 +3290,6 @@ void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
 #if defined(CONFIG_DRM_AMD_DC_HDCP)
        update_psp_stream_config(pipe_ctx, true);
 #endif
-
        dc->hwss.blank_stream(pipe_ctx);
 
        if (pipe_ctx->stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST)
index 9bc03f2..b2be6ad 100644 (file)
@@ -4409,9 +4409,9 @@ bool dc_link_get_backlight_level_nits(struct dc_link *link,
                        link->connector_signal != SIGNAL_TYPE_DISPLAY_PORT))
                return false;
 
-       if (!core_link_read_dpcd(link, DP_SOURCE_BACKLIGHT_CURRENT_PEAK,
+       if (core_link_read_dpcd(link, DP_SOURCE_BACKLIGHT_CURRENT_PEAK,
                        dpcd_backlight_get.raw,
-                       sizeof(union dpcd_source_backlight_get)))
+                       sizeof(union dpcd_source_backlight_get)) != DC_OK)
                return false;
 
        *backlight_millinits_avg =
@@ -4450,9 +4450,9 @@ bool dc_link_read_default_bl_aux(struct dc_link *link, uint32_t *backlight_milli
                link->connector_signal != SIGNAL_TYPE_DISPLAY_PORT))
                return false;
 
-       if (!core_link_read_dpcd(link, DP_SOURCE_BACKLIGHT_LEVEL,
+       if (core_link_read_dpcd(link, DP_SOURCE_BACKLIGHT_LEVEL,
                (uint8_t *) backlight_millinits,
-               sizeof(uint32_t)))
+               sizeof(uint32_t)) != DC_OK)
                return false;
 
        return true;
index d06d070..0811f94 100644 (file)
@@ -136,6 +136,10 @@ struct dc_vbios_funcs {
 
        enum bp_result (*get_atom_dc_golden_table)(
                        struct dc_bios *dcb);
+
+       enum bp_result (*enable_lvtma_control)(
+               struct dc_bios *bios,
+               uint8_t uc_pwr_on);
 };
 
 struct bios_registers {
index 633442b..d9888f3 100644 (file)
@@ -233,7 +233,7 @@ struct dc_stream_state {
        union stream_update_flags update_flags;
 };
 
-#define ABM_LEVEL_IMMEDIATE_DISABLE 0xFFFFFFFF
+#define ABM_LEVEL_IMMEDIATE_DISABLE 255
 
 struct dc_stream_update {
        struct dc_stream_state *stream;
index 70ec691..99c68ca 100644 (file)
@@ -49,7 +49,7 @@
 #define DCN_PANEL_CNTL_REG_LIST()\
        DCN_PANEL_CNTL_SR(PWRSEQ_CNTL, LVTMA), \
        DCN_PANEL_CNTL_SR(PWRSEQ_STATE, LVTMA), \
-       DCE_PANEL_CNTL_SR(PWRSEQ_REF_DIV, LVTMA), \
+       DCN_PANEL_CNTL_SR(PWRSEQ_REF_DIV, LVTMA), \
        SR(BL_PWM_CNTL), \
        SR(BL_PWM_CNTL2), \
        SR(BL_PWM_PERIOD_CNTL), \
index 49380ed..45c9e90 100644 (file)
@@ -842,6 +842,17 @@ void dce110_edp_power_control(
                cntl.coherent = false;
                cntl.lanes_number = LANE_COUNT_FOUR;
                cntl.hpd_sel = link->link_enc->hpd_source;
+
+               if (ctx->dc->ctx->dmub_srv &&
+                               ctx->dc->debug.dmub_command_table) {
+                       if (cntl.action == TRANSMITTER_CONTROL_POWER_ON)
+                               bp_result = ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
+                                               LVTMA_CONTROL_POWER_ON);
+                       else
+                               bp_result = ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
+                                               LVTMA_CONTROL_POWER_OFF);
+               }
+
                bp_result = link_transmitter_control(ctx->dc_bios, &cntl);
 
                if (!power_up)
@@ -919,8 +930,21 @@ void dce110_edp_backlight_control(
                /*edp 1.2*/
        if (cntl.action == TRANSMITTER_CONTROL_BACKLIGHT_ON)
                edp_receiver_ready_T7(link);
+
+       if (ctx->dc->ctx->dmub_srv &&
+                       ctx->dc->debug.dmub_command_table) {
+               if (cntl.action == TRANSMITTER_CONTROL_BACKLIGHT_ON)
+                       ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
+                                       LVTMA_CONTROL_LCD_BLON);
+               else
+                       ctx->dc_bios->funcs->enable_lvtma_control(ctx->dc_bios,
+                                       LVTMA_CONTROL_LCD_BLOFF);
+       }
+
        link_transmitter_control(ctx->dc_bios, &cntl);
 
+
+
        if (enable && link->dpcd_sink_ext_caps.bits.oled)
                msleep(OLED_POST_T7_DELAY);
 
index a643927..fa643ec 100644 (file)
@@ -1450,33 +1450,42 @@ void dcn10_init_hw(struct dc *dc)
 void dcn10_power_down_on_boot(struct dc *dc)
 {
        int i = 0;
+       struct dc_link *edp_link;
 
-       if (dc->config.power_down_display_on_boot) {
-               struct dc_link *edp_link = get_edp_link(dc);
-
-               if (edp_link &&
-                               edp_link->link_enc->funcs->is_dig_enabled &&
-                               edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
-                               dc->hwseq->funcs.edp_backlight_control &&
-                               dc->hwss.power_down &&
-                               dc->hwss.edp_power_control) {
-                       dc->hwseq->funcs.edp_backlight_control(edp_link, false);
-                       dc->hwss.power_down(dc);
-                       dc->hwss.edp_power_control(edp_link, false);
-               } else {
-                       for (i = 0; i < dc->link_count; i++) {
-                               struct dc_link *link = dc->links[i];
-
-                               if (link->link_enc->funcs->is_dig_enabled &&
-                                               link->link_enc->funcs->is_dig_enabled(link->link_enc) &&
-                                               dc->hwss.power_down) {
-                                       dc->hwss.power_down(dc);
-                                       break;
-                               }
+       if (!dc->config.power_down_display_on_boot)
+               return;
+
+       edp_link = get_edp_link(dc);
+       if (edp_link &&
+                       edp_link->link_enc->funcs->is_dig_enabled &&
+                       edp_link->link_enc->funcs->is_dig_enabled(edp_link->link_enc) &&
+                       dc->hwseq->funcs.edp_backlight_control &&
+                       dc->hwss.power_down &&
+                       dc->hwss.edp_power_control) {
+               dc->hwseq->funcs.edp_backlight_control(edp_link, false);
+               dc->hwss.power_down(dc);
+               dc->hwss.edp_power_control(edp_link, false);
+       } else {
+               for (i = 0; i < dc->link_count; i++) {
+                       struct dc_link *link = dc->links[i];
 
+                       if (link->link_enc->funcs->is_dig_enabled &&
+                                       link->link_enc->funcs->is_dig_enabled(link->link_enc) &&
+                                       dc->hwss.power_down) {
+                               dc->hwss.power_down(dc);
+                               break;
                        }
+
                }
        }
+
+       /*
+        * Call update_clocks with empty context
+        * to send DISPLAY_OFF
+        * Otherwise DISPLAY_OFF may not be asserted
+        */
+       if (dc->clk_mgr->funcs->set_low_power_state)
+               dc->clk_mgr->funcs->set_low_power_state(dc->clk_mgr);
 }
 
 void dcn10_reset_hw_ctx_wrap(
index 17d5cb4..8939541 100644 (file)
@@ -1213,6 +1213,7 @@ static enum dc_status dcn10_validate_global(struct dc *dc, struct dc_state *cont
        bool video_large = false;
        bool desktop_large = false;
        bool dcc_disabled = false;
+       bool mpo_enabled = false;
 
        for (i = 0; i < context->stream_count; i++) {
                if (context->stream_status[i].plane_count == 0)
@@ -1221,6 +1222,9 @@ static enum dc_status dcn10_validate_global(struct dc *dc, struct dc_state *cont
                if (context->stream_status[i].plane_count > 2)
                        return DC_FAIL_UNSUPPORTED_1;
 
+               if (context->stream_status[i].plane_count > 1)
+                       mpo_enabled = true;
+
                for (j = 0; j < context->stream_status[i].plane_count; j++) {
                        struct dc_plane_state *plane =
                                context->stream_status[i].plane_states[j];
@@ -1244,6 +1248,10 @@ static enum dc_status dcn10_validate_global(struct dc *dc, struct dc_state *cont
                }
        }
 
+       /* Disable MPO in multi-display configurations. */
+       if (context->stream_count > 1 && mpo_enabled)
+               return DC_FAIL_UNSUPPORTED_1;
+
        /*
         * Workaround: On DCN10 there is UMC issue that causes underflow when
         * playing 4k video on 4k desktop with video downscaled and single channel
index 07b2f93..842abb4 100644 (file)
@@ -121,35 +121,35 @@ void enc1_update_generic_info_packet(
        switch (packet_index) {
        case 0:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC0_FRAME_UPDATE, 1);
+                               AFMT_GENERIC0_IMMEDIATE_UPDATE, 1);
                break;
        case 1:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC1_FRAME_UPDATE, 1);
+                               AFMT_GENERIC1_IMMEDIATE_UPDATE, 1);
                break;
        case 2:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC2_FRAME_UPDATE, 1);
+                               AFMT_GENERIC2_IMMEDIATE_UPDATE, 1);
                break;
        case 3:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC3_FRAME_UPDATE, 1);
+                               AFMT_GENERIC3_IMMEDIATE_UPDATE, 1);
                break;
        case 4:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC4_FRAME_UPDATE, 1);
+                               AFMT_GENERIC4_IMMEDIATE_UPDATE, 1);
                break;
        case 5:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC5_FRAME_UPDATE, 1);
+                               AFMT_GENERIC5_IMMEDIATE_UPDATE, 1);
                break;
        case 6:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC6_FRAME_UPDATE, 1);
+                               AFMT_GENERIC6_IMMEDIATE_UPDATE, 1);
                break;
        case 7:
                REG_UPDATE(AFMT_VBI_PACKET_CONTROL1,
-                               AFMT_GENERIC7_FRAME_UPDATE, 1);
+                               AFMT_GENERIC7_IMMEDIATE_UPDATE, 1);
                break;
        default:
                break;
index ed385b1..30eae74 100644 (file)
@@ -281,7 +281,14 @@ struct dcn10_stream_enc_registers {
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_FRAME_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_FRAME_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_FRAME_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC0_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC1_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC2_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC3_IMMEDIATE_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC4_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_IMMEDIATE_UPDATE, mask_sh),\
+       SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_IMMEDIATE_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC5_FRAME_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC6_FRAME_UPDATE, mask_sh),\
        SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_FRAME_UPDATE, mask_sh),\
@@ -345,7 +352,14 @@ struct dcn10_stream_enc_registers {
        type AFMT_GENERIC2_FRAME_UPDATE;\
        type AFMT_GENERIC3_FRAME_UPDATE;\
        type AFMT_GENERIC4_FRAME_UPDATE;\
+       type AFMT_GENERIC0_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC1_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC2_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC3_IMMEDIATE_UPDATE;\
        type AFMT_GENERIC4_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC5_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC6_IMMEDIATE_UPDATE;\
+       type AFMT_GENERIC7_IMMEDIATE_UPDATE;\
        type AFMT_GENERIC5_FRAME_UPDATE;\
        type AFMT_GENERIC6_FRAME_UPDATE;\
        type AFMT_GENERIC7_FRAME_UPDATE;\
index 66180b4..c8cfd3b 100644 (file)
@@ -1457,8 +1457,8 @@ static void dcn20_update_dchubp_dpp(
 
        /* Any updates are handled in dc interface, just need to apply existing for plane enable */
        if ((pipe_ctx->update_flags.bits.enable || pipe_ctx->update_flags.bits.opp_changed ||
-                       pipe_ctx->update_flags.bits.scaler || pipe_ctx->update_flags.bits.viewport)
-                       && pipe_ctx->stream->cursor_attributes.address.quad_part != 0) {
+                       pipe_ctx->update_flags.bits.scaler || viewport_changed == true) &&
+                       pipe_ctx->stream->cursor_attributes.address.quad_part != 0) {
                dc->hwss.set_cursor_position(pipe_ctx);
                dc->hwss.set_cursor_attribute(pipe_ctx);
 
index bf0044f..dcbf28d 100644 (file)
        LE_SF(DCIO_SOFT_RESET, UNIPHYB_SOFT_RESET, mask_sh),\
        LE_SF(DCIO_SOFT_RESET, UNIPHYC_SOFT_RESET, mask_sh),\
        LE_SF(DCIO_SOFT_RESET, UNIPHYD_SOFT_RESET, mask_sh),\
-       LE_SF(DCIO_SOFT_RESET, UNIPHYE_SOFT_RESET, mask_sh)
+       LE_SF(DCIO_SOFT_RESET, UNIPHYE_SOFT_RESET, mask_sh),\
+       LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DP4, mask_sh),\
+       LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DISABLE, mask_sh)
 
 #define LINK_ENCODER_MASK_SH_LIST_DCN20(mask_sh)\
        LINK_ENCODER_MASK_SH_LIST_DCN10(mask_sh),\
index 790baf5..9140b3f 100644 (file)
@@ -3141,7 +3141,7 @@ static bool dcn20_validate_bandwidth_internal(struct dc *dc, struct dc_state *co
        int vlevel = 0;
        int pipe_split_from[MAX_PIPES];
        int pipe_cnt = 0;
-       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_KERNEL);
+       display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_ATOMIC);
        DC_LOGGER_INIT(dc->ctx->logger);
 
        BW_VAL_TRACE_COUNT();
index 8e9fd59..2fbf879 100644 (file)
        DPCS_DCN2_MASK_SH_LIST(mask_sh),\
        LE_SF(DPCSTX0_DPCSTX_TX_CNTL, DPCS_TX_DATA_ORDER_INVERT_18_BIT, mask_sh),\
        LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL0, RDPCS_PHY_TX_VBOOST_LVL, mask_sh),\
-       LE_SF(RDPCSTX0_RDPCSTX_CLOCK_CNTL, RDPCS_TX_CLK_EN, mask_sh)
+       LE_SF(RDPCSTX0_RDPCSTX_CLOCK_CNTL, RDPCS_TX_CLK_EN, mask_sh),\
+       LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DP4, mask_sh),\
+       LE_SF(RDPCSTX0_RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DISABLE, mask_sh)
+
 
 void dcn30_link_encoder_construct(
        struct dcn20_link_encoder *enc20,
index 653a571..ebe0cc5 100644 (file)
@@ -491,6 +491,7 @@ static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
 [id] = {\
        LE_DCN3_REG_LIST(id), \
        UNIPHY_DCN2_REG_LIST(phyid), \
+       SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
 }
 
 static const struct dce110_aux_registers_shift aux_shift = {
index b54814f..2beb284 100644 (file)
@@ -63,6 +63,7 @@ typedef struct {
 
 #define BPP_INVALID 0
 #define BPP_BLENDED_PIPE 0xffffffff
+#define DCN30_MAX_DSC_IMAGE_WIDTH 5184
 
 static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib);
 static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
@@ -3984,6 +3985,9 @@ void dml30_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_l
                                } else if (v->PlaneRequiredDISPCLKWithoutODMCombine > v->MaxDispclkRoundedDownToDFSGranularity) {
                                        v->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1;
                                        v->PlaneRequiredDISPCLK = v->PlaneRequiredDISPCLKWithODMCombine2To1;
+                               } else if (v->DSCEnabled[k] && (v->HActive[k] > DCN30_MAX_DSC_IMAGE_WIDTH)) {
+                                       v->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_2to1;
+                                       v->PlaneRequiredDISPCLK = v->PlaneRequiredDISPCLKWithODMCombine2To1;
                                } else {
                                        v->ODMCombineEnablePerState[i][k] = dm_odm_combine_mode_disabled;
                                        v->PlaneRequiredDISPCLK = v->PlaneRequiredDISPCLKWithoutODMCombine;
index 5994d2a..947d610 100644 (file)
@@ -230,6 +230,8 @@ struct clk_mgr_funcs {
 
        int (*get_dp_ref_clk_frequency)(struct clk_mgr *clk_mgr);
 
+       void (*set_low_power_state)(struct clk_mgr *clk_mgr);
+
        void (*init_clocks)(struct clk_mgr *clk_mgr);
 
        void (*enable_pme_wa) (struct clk_mgr *clk_mgr);
index c30437a..21011ed 100644 (file)
@@ -101,6 +101,13 @@ enum bp_pipe_control_action {
        ASIC_PIPE_INIT
 };
 
+enum bp_lvtma_control_action {
+       LVTMA_CONTROL_LCD_BLOFF = 2,
+       LVTMA_CONTROL_LCD_BLON = 3,
+       LVTMA_CONTROL_POWER_ON = 12,
+       LVTMA_CONTROL_POWER_OFF = 13
+};
+
 struct bp_encoder_control {
        enum bp_encoder_control_action action;
        enum engine_id engine_id;
index 89ef9f6..16df2a4 100644 (file)
@@ -431,6 +431,9 @@ struct fixed31_32 dc_fixpt_log(struct fixed31_32 arg);
  */
 static inline struct fixed31_32 dc_fixpt_pow(struct fixed31_32 arg1, struct fixed31_32 arg2)
 {
+       if (arg1.value == 0)
+               return arg2.value == 0 ? dc_fixpt_one : dc_fixpt_zero;
+
        return dc_fixpt_exp(
                dc_fixpt_mul(
                        dc_fixpt_log(arg1),
index 81820f3..d988533 100644 (file)
@@ -324,22 +324,44 @@ static void apply_below_the_range(struct core_freesync *core_freesync,
 
                /* Choose number of frames to insert based on how close it
                 * can get to the mid point of the variable range.
+                *  - Delta for CEIL: delta_from_mid_point_in_us_1
+                *  - Delta for FLOOR: delta_from_mid_point_in_us_2
                 */
-               if ((frame_time_in_us / mid_point_frames_ceil) > in_out_vrr->min_duration_in_us &&
-                               (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2 ||
-                                               mid_point_frames_floor < 2)) {
+               if ((last_render_time_in_us / mid_point_frames_ceil) < in_out_vrr->min_duration_in_us) {
+                       /* Check for out of range.
+                        * If using CEIL produces a value that is out of range,
+                        * then we are forced to use FLOOR.
+                        */
+                       frames_to_insert = mid_point_frames_floor;
+               } else if (mid_point_frames_floor < 2) {
+                       /* Check if FLOOR would result in non-LFC. In this case
+                        * choose to use CEIL
+                        */
+                       frames_to_insert = mid_point_frames_ceil;
+               } else if (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2) {
+                       /* If choosing CEIL results in a frame duration that is
+                        * closer to the mid point of the range.
+                        * Choose CEIL
+                        */
                        frames_to_insert = mid_point_frames_ceil;
-                       delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_2 -
-                                       delta_from_mid_point_in_us_1;
                } else {
+                       /* If choosing FLOOR results in a frame duration that is
+                        * closer to the mid point of the range.
+                        * Choose FLOOR
+                        */
                        frames_to_insert = mid_point_frames_floor;
-                       delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_1 -
-                                       delta_from_mid_point_in_us_2;
                }
 
                /* Prefer current frame multiplier when BTR is enabled unless it drifts
                 * too far from the midpoint
                 */
+               if (delta_from_mid_point_in_us_1 < delta_from_mid_point_in_us_2) {
+                       delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_2 -
+                                       delta_from_mid_point_in_us_1;
+               } else {
+                       delta_from_mid_point_delta_in_us = delta_from_mid_point_in_us_1 -
+                                       delta_from_mid_point_in_us_2;
+               }
                if (in_out_vrr->btr.frames_to_insert != 0 &&
                                delta_from_mid_point_delta_in_us < BTR_DRIFT_MARGIN) {
                        if (((last_render_time_in_us / in_out_vrr->btr.frames_to_insert) <
index 6c991de..9582b38 100644 (file)
@@ -1840,10 +1840,14 @@ static bool arcturus_is_dpm_running(struct smu_context *smu)
 {
        int ret = 0;
        uint32_t feature_mask[2];
-       unsigned long feature_enabled;
+       uint64_t feature_enabled;
+
        ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-       feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
-                          ((uint64_t)feature_mask[1] << 32));
+       if (ret)
+               return false;
+
+       feature_enabled = (uint64_t)feature_mask[1] << 32 | feature_mask[0];
+
        return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
@@ -2204,14 +2208,17 @@ static const struct throttling_logging_label {
 };
 static void arcturus_log_thermal_throttling_event(struct smu_context *smu)
 {
+       int ret;
        int throttler_idx, throtting_events = 0, buf_idx = 0;
        struct amdgpu_device *adev = smu->adev;
        uint32_t throttler_status;
        char log_buf[256];
 
-       arcturus_get_smu_metrics_data(smu,
-                                     METRICS_THROTTLER_STATUS,
-                                     &throttler_status);
+       ret = arcturus_get_smu_metrics_data(smu,
+                                           METRICS_THROTTLER_STATUS,
+                                           &throttler_status);
+       if (ret)
+               return;
 
        memset(log_buf, 0, sizeof(log_buf));
        for (throttler_idx = 0; throttler_idx < ARRAY_SIZE(logging_label);
index c9cfe90..9ee8cf8 100644 (file)
@@ -204,8 +204,7 @@ static int smu10_set_min_deep_sleep_dcefclk(struct pp_hwmgr *hwmgr, uint32_t clo
 {
        struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
 
-       if (smu10_data->need_min_deep_sleep_dcefclk &&
-               smu10_data->deep_sleep_dcefclk != clock) {
+       if (clock && smu10_data->deep_sleep_dcefclk != clock) {
                smu10_data->deep_sleep_dcefclk = clock;
                smum_send_msg_to_smc_with_parameter(hwmgr,
                                        PPSMC_MSG_SetMinDeepSleepDcefclk,
@@ -219,8 +218,7 @@ static int smu10_set_hard_min_dcefclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t c
 {
        struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
 
-       if (smu10_data->dcf_actual_hard_min_freq &&
-               smu10_data->dcf_actual_hard_min_freq != clock) {
+       if (clock && smu10_data->dcf_actual_hard_min_freq != clock) {
                smu10_data->dcf_actual_hard_min_freq = clock;
                smum_send_msg_to_smc_with_parameter(hwmgr,
                                        PPSMC_MSG_SetHardMinDcefclkByFreq,
@@ -234,8 +232,7 @@ static int smu10_set_hard_min_fclk_by_freq(struct pp_hwmgr *hwmgr, uint32_t cloc
 {
        struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
 
-       if (smu10_data->f_actual_hard_min_freq &&
-               smu10_data->f_actual_hard_min_freq != clock) {
+       if (clock && smu10_data->f_actual_hard_min_freq != clock) {
                smu10_data->f_actual_hard_min_freq = clock;
                smum_send_msg_to_smc_with_parameter(hwmgr,
                                        PPSMC_MSG_SetHardMinFclkByFreq,
index ffe05b7..4a3b64a 100644 (file)
@@ -3581,7 +3581,8 @@ static int smu7_read_sensor(struct pp_hwmgr *hwmgr, int idx,
        case AMDGPU_PP_SENSOR_GPU_POWER:
                return smu7_get_gpu_power(hwmgr, (uint32_t *)value);
        case AMDGPU_PP_SENSOR_VDDGFX:
-               if ((data->vr_config & 0xff) == 0x2)
+               if ((data->vr_config & VRCONF_VDDGFX_MASK) ==
+                   (VR_SVI2_PLANE_2 << VRCONF_VDDGFX_SHIFT))
                        val_vid = PHM_READ_INDIRECT_FIELD(hwmgr->device,
                                        CGS_IND_REG__SMC, PWR_SVI2_STATUS, PLANE2_VID);
                else
index 468bdd6..952cd3d 100644 (file)
@@ -363,17 +363,29 @@ int vega10_thermal_get_temperature(struct pp_hwmgr *hwmgr)
 static int vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
                struct PP_TemperatureRange *range)
 {
+       struct phm_ppt_v2_information *pp_table_info =
+               (struct phm_ppt_v2_information *)(hwmgr->pptable);
+       struct phm_tdp_table *tdp_table = pp_table_info->tdp_table;
        struct amdgpu_device *adev = hwmgr->adev;
-       int low = VEGA10_THERMAL_MINIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
-       int high = VEGA10_THERMAL_MAXIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+       int low = VEGA10_THERMAL_MINIMUM_ALERT_TEMP;
+       int high = VEGA10_THERMAL_MAXIMUM_ALERT_TEMP;
        uint32_t val;
 
-       if (low < range->min)
-               low = range->min;
-       if (high > range->max)
-               high = range->max;
+       /* compare them in unit celsius degree */
+       if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
+               low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+       /*
+        * As a common sense, usSoftwareShutdownTemp should be bigger
+        * than ThotspotLimit. For any invalid usSoftwareShutdownTemp,
+        * we will just use the max possible setting VEGA10_THERMAL_MAXIMUM_ALERT_TEMP
+        * to avoid false alarms.
+        */
+       if ((tdp_table->usSoftwareShutdownTemp >
+            range->hotspot_crit_max / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)) {
+               if (high > tdp_table->usSoftwareShutdownTemp)
+                       high = tdp_table->usSoftwareShutdownTemp;
+       }
 
        if (low > high)
                return -EINVAL;
@@ -382,8 +394,8 @@ static int vega10_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
 
        val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
        val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
-       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
-       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
+       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
        val &= (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK) &
                        (~THM_THERMAL_INT_CTRL__THERM_INTH_MASK_MASK) &
                        (~THM_THERMAL_INT_CTRL__THERM_INTL_MASK_MASK);
index c15b975..7ace439 100644 (file)
@@ -170,17 +170,18 @@ int vega12_thermal_get_temperature(struct pp_hwmgr *hwmgr)
 static int vega12_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
                struct PP_TemperatureRange *range)
 {
+       struct phm_ppt_v3_information *pptable_information =
+               (struct phm_ppt_v3_information *)hwmgr->pptable;
        struct amdgpu_device *adev = hwmgr->adev;
-       int low = VEGA12_THERMAL_MINIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
-       int high = VEGA12_THERMAL_MAXIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+       int low = VEGA12_THERMAL_MINIMUM_ALERT_TEMP;
+       int high = VEGA12_THERMAL_MAXIMUM_ALERT_TEMP;
        uint32_t val;
 
-       if (low < range->min)
-               low = range->min;
-       if (high > range->max)
-               high = range->max;
+       /* compare them in unit celsius degree */
+       if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
+               low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+       if (high > pptable_information->us_software_shutdown_temp)
+               high = pptable_information->us_software_shutdown_temp;
 
        if (low > high)
                return -EINVAL;
@@ -189,8 +190,8 @@ static int vega12_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
 
        val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
        val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
-       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
-       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
+       val = REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
        val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
 
        WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);
index 3b88396..ea70d73 100644 (file)
@@ -979,10 +979,7 @@ static int vega20_disable_all_smu_features(struct pp_hwmgr *hwmgr)
 {
        struct vega20_hwmgr *data =
                        (struct vega20_hwmgr *)(hwmgr->backend);
-       uint64_t features_enabled;
-       int i;
-       bool enabled;
-       int ret = 0;
+       int i, ret = 0;
 
        PP_ASSERT_WITH_CODE((ret = smum_send_msg_to_smc(hwmgr,
                        PPSMC_MSG_DisableAllSmuFeatures,
@@ -990,17 +987,8 @@ static int vega20_disable_all_smu_features(struct pp_hwmgr *hwmgr)
                        "[DisableAllSMUFeatures] Failed to disable all smu features!",
                        return ret);
 
-       ret = vega20_get_enabled_smc_features(hwmgr, &features_enabled);
-       PP_ASSERT_WITH_CODE(!ret,
-                       "[DisableAllSMUFeatures] Failed to get enabled smc features!",
-                       return ret);
-
-       for (i = 0; i < GNLD_FEATURES_MAX; i++) {
-               enabled = (features_enabled & data->smu_features[i].smu_feature_bitmap) ?
-                       true : false;
-               data->smu_features[i].enabled = enabled;
-               data->smu_features[i].supported = enabled;
-       }
+       for (i = 0; i < GNLD_FEATURES_MAX; i++)
+               data->smu_features[i].enabled = 0;
 
        return 0;
 }
@@ -1652,12 +1640,6 @@ static void vega20_init_powergate_state(struct pp_hwmgr *hwmgr)
 
        data->uvd_power_gated = true;
        data->vce_power_gated = true;
-
-       if (data->smu_features[GNLD_DPM_UVD].enabled)
-               data->uvd_power_gated = false;
-
-       if (data->smu_features[GNLD_DPM_VCE].enabled)
-               data->vce_power_gated = false;
 }
 
 static int vega20_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
@@ -3230,10 +3212,11 @@ static int vega20_get_ppfeature_status(struct pp_hwmgr *hwmgr, char *buf)
 
 static int vega20_set_ppfeature_status(struct pp_hwmgr *hwmgr, uint64_t new_ppfeature_masks)
 {
-       uint64_t features_enabled;
-       uint64_t features_to_enable;
-       uint64_t features_to_disable;
-       int ret = 0;
+       struct vega20_hwmgr *data =
+                       (struct vega20_hwmgr *)(hwmgr->backend);
+       uint64_t features_enabled, features_to_enable, features_to_disable;
+       int i, ret = 0;
+       bool enabled;
 
        if (new_ppfeature_masks >= (1ULL << GNLD_FEATURES_MAX))
                return -EINVAL;
@@ -3262,6 +3245,17 @@ static int vega20_set_ppfeature_status(struct pp_hwmgr *hwmgr, uint64_t new_ppfe
                        return ret;
        }
 
+       /* Update the cached feature enablement state */
+       ret = vega20_get_enabled_smc_features(hwmgr, &features_enabled);
+       if (ret)
+               return ret;
+
+       for (i = 0; i < GNLD_FEATURES_MAX; i++) {
+               enabled = (features_enabled & data->smu_features[i].smu_feature_bitmap) ?
+                       true : false;
+               data->smu_features[i].enabled = enabled;
+       }
+
        return 0;
 }
 
index 7add2f6..364162d 100644 (file)
@@ -240,17 +240,18 @@ int vega20_thermal_get_temperature(struct pp_hwmgr *hwmgr)
 static int vega20_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
                struct PP_TemperatureRange *range)
 {
+       struct phm_ppt_v3_information *pptable_information =
+               (struct phm_ppt_v3_information *)hwmgr->pptable;
        struct amdgpu_device *adev = hwmgr->adev;
-       int low = VEGA20_THERMAL_MINIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
-       int high = VEGA20_THERMAL_MAXIMUM_ALERT_TEMP *
-                       PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+       int low = VEGA20_THERMAL_MINIMUM_ALERT_TEMP;
+       int high = VEGA20_THERMAL_MAXIMUM_ALERT_TEMP;
        uint32_t val;
 
-       if (low < range->min)
-               low = range->min;
-       if (high > range->max)
-               high = range->max;
+       /* compare them in unit celsius degree */
+       if (low < range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES)
+               low = range->min / PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+       if (high > pptable_information->us_software_shutdown_temp)
+               high = pptable_information->us_software_shutdown_temp;
 
        if (low > high)
                return -EINVAL;
@@ -259,8 +260,8 @@ static int vega20_thermal_set_temperature_range(struct pp_hwmgr *hwmgr,
 
        val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, MAX_IH_CREDIT, 5);
        val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, THERM_IH_HW_ENA, 1);
-       val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, (high / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
-       val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, (low / PP_TEMPERATURE_UNITS_PER_CENTIGRADES));
+       val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTH, high);
+       val = CGS_REG_SET_FIELD(val, THM_THERMAL_INT_CTRL, DIG_THERM_INTL, low);
        val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK);
 
        WREG32_SOC15(THM, 0, mmTHM_THERMAL_INT_CTRL, val);
index 9f62af9..3d5eae9 100644 (file)
@@ -1331,10 +1331,14 @@ static bool navi10_is_dpm_running(struct smu_context *smu)
 {
        int ret = 0;
        uint32_t feature_mask[2];
-       unsigned long feature_enabled;
+       uint64_t feature_enabled;
+
        ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-       feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
-                          ((uint64_t)feature_mask[1] << 32));
+       if (ret)
+               return false;
+
+       feature_enabled = (uint64_t)feature_mask[1] << 32 | feature_mask[0];
+
        return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
index 3865dbe..61f4dda 100644 (file)
@@ -68,7 +68,8 @@
        FEATURE_MASK(FEATURE_DPM_LINK_BIT)       | \
        FEATURE_MASK(FEATURE_DPM_SOCCLK_BIT)     | \
        FEATURE_MASK(FEATURE_DPM_FCLK_BIT)       | \
-       FEATURE_MASK(FEATURE_DPM_DCEFCLK_BIT))
+       FEATURE_MASK(FEATURE_DPM_DCEFCLK_BIT)    | \
+       FEATURE_MASK(FEATURE_DPM_MP0CLK_BIT))
 
 #define SMU_11_0_7_GFX_BUSY_THRESHOLD 15
 
@@ -95,6 +96,7 @@ static struct cmn2asic_msg_mapping sienna_cichlid_message_map[SMU_MSG_MAX_COUNT]
        MSG_MAP(TransferTableSmu2Dram,          PPSMC_MSG_TransferTableSmu2Dram,       0),
        MSG_MAP(TransferTableDram2Smu,          PPSMC_MSG_TransferTableDram2Smu,       0),
        MSG_MAP(UseDefaultPPTable,              PPSMC_MSG_UseDefaultPPTable,           0),
+       MSG_MAP(RunDcBtc,                       PPSMC_MSG_RunDcBtc,                    0),
        MSG_MAP(EnterBaco,                      PPSMC_MSG_EnterBaco,                   0),
        MSG_MAP(SetSoftMinByFreq,               PPSMC_MSG_SetSoftMinByFreq,            0),
        MSG_MAP(SetSoftMaxByFreq,               PPSMC_MSG_SetSoftMaxByFreq,            0),
@@ -228,6 +230,7 @@ sienna_cichlid_get_allowed_feature_mask(struct smu_context *smu,
 
        *(uint64_t *)feature_mask |= FEATURE_MASK(FEATURE_DPM_PREFETCHER_BIT)
                                | FEATURE_MASK(FEATURE_DPM_FCLK_BIT)
+                               | FEATURE_MASK(FEATURE_DPM_MP0CLK_BIT)
                                | FEATURE_MASK(FEATURE_DS_SOCCLK_BIT)
                                | FEATURE_MASK(FEATURE_DS_DCEFCLK_BIT)
                                | FEATURE_MASK(FEATURE_DS_FCLK_BIT)
@@ -775,7 +778,7 @@ static int sienna_cichlid_dpm_set_vcn_enable(struct smu_context *smu, bool enabl
                        ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpVcn, 0, NULL);
                        if (ret)
                                return ret;
-                       if (adev->asic_type == CHIP_SIENNA_CICHLID) {
+                       if (adev->vcn.num_vcn_inst > 1) {
                                ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpVcn,
                                                                  0x10000, NULL);
                                if (ret)
@@ -787,7 +790,7 @@ static int sienna_cichlid_dpm_set_vcn_enable(struct smu_context *smu, bool enabl
                        ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerDownVcn, 0, NULL);
                        if (ret)
                                return ret;
-                       if (adev->asic_type == CHIP_SIENNA_CICHLID) {
+                       if (adev->vcn.num_vcn_inst > 1) {
                                ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerDownVcn,
                                                                  0x10000, NULL);
                                if (ret)
@@ -1146,10 +1149,14 @@ static bool sienna_cichlid_is_dpm_running(struct smu_context *smu)
 {
        int ret = 0;
        uint32_t feature_mask[2];
-       unsigned long feature_enabled;
+       uint64_t feature_enabled;
+
        ret = smu_cmn_get_enabled_mask(smu, feature_mask, 2);
-       feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
-                          ((uint64_t)feature_mask[1] << 32));
+       if (ret)
+               return false;
+
+       feature_enabled = (uint64_t)feature_mask[1] << 32 | feature_mask[0];
+
        return !!(feature_enabled & SMC_DPM_FEATURE);
 }
 
@@ -1732,6 +1739,11 @@ static int sienna_cichlid_get_dpm_ultimate_freq(struct smu_context *smu,
        return ret;
 }
 
+static int sienna_cichlid_run_btc(struct smu_context *smu)
+{
+       return smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+}
+
 static bool sienna_cichlid_is_baco_supported(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
@@ -2719,6 +2731,7 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = {
        .mode1_reset = smu_v11_0_mode1_reset,
        .get_dpm_ultimate_freq = sienna_cichlid_get_dpm_ultimate_freq,
        .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range,
+       .run_btc = sienna_cichlid_run_btc,
        .get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
        .set_pp_feature_mask = smu_cmn_set_pp_feature_mask,
 };
index c18169a..e4d1f3d 100644 (file)
@@ -37,6 +37,7 @@
 #include "cgs_common.h"
 #include "atombios.h"
 #include "pppcielanes.h"
+#include "smu7_smumgr.h"
 
 #include "smu/smu_7_0_1_d.h"
 #include "smu/smu_7_0_1_sh_mask.h"
@@ -2948,6 +2949,7 @@ const struct pp_smumgr_func ci_smu_funcs = {
        .request_smu_load_specific_fw = NULL,
        .send_msg_to_smc = ci_send_msg_to_smc,
        .send_msg_to_smc_with_parameter = ci_send_msg_to_smc_with_parameter,
+       .get_argument = smu7_get_argument,
        .download_pptable_settings = NULL,
        .upload_pptable_settings = NULL,
        .get_offsetof = ci_get_offsetof,
index ca570b1..e9de542 100644 (file)
@@ -532,7 +532,7 @@ static int malidp500_enable_memwrite(struct malidp_hw_device *hwdev,
                malidp_hw_write(hwdev, lower_32_bits(addrs[1]), base + MALIDP_MW_P2_PTR_LOW);
                malidp_hw_write(hwdev, upper_32_bits(addrs[1]), base + MALIDP_MW_P2_PTR_HIGH);
                malidp_hw_write(hwdev, pitches[1], base + MALIDP_MW_P2_STRIDE);
-               /* fall through */
+               fallthrough;
        case 1:
                malidp_hw_write(hwdev, lower_32_bits(addrs[0]), base + MALIDP_MW_P1_PTR_LOW);
                malidp_hw_write(hwdev, upper_32_bits(addrs[0]), base + MALIDP_MW_P1_PTR_HIGH);
@@ -869,7 +869,7 @@ static int malidp550_enable_memwrite(struct malidp_hw_device *hwdev,
                malidp_hw_write(hwdev, lower_32_bits(addrs[1]), base + MALIDP_MW_P2_PTR_LOW);
                malidp_hw_write(hwdev, upper_32_bits(addrs[1]), base + MALIDP_MW_P2_PTR_HIGH);
                malidp_hw_write(hwdev, pitches[1], base + MALIDP_MW_P2_STRIDE);
-               /* fall through */
+               fallthrough;
        case 1:
                malidp_hw_write(hwdev, lower_32_bits(addrs[0]), base + MALIDP_MW_P1_PTR_LOW);
                malidp_hw_write(hwdev, upper_32_bits(addrs[0]), base + MALIDP_MW_P1_PTR_HIGH);
@@ -1324,7 +1324,7 @@ static irqreturn_t malidp_se_irq(int irq, void *arg)
                        break;
                case MW_RESTART:
                        drm_writeback_signal_completion(&malidp->mw_connector, 0);
-                       /* fall through - to a new start */
+                       fallthrough;    /* to a new start */
                case MW_START:
                        /* writeback started, need to emulate one-shot mode */
                        hw->disable_memwrite(hwdev);
index dd12b55..6a9fba0 100644 (file)
@@ -238,7 +238,7 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
                                        ast->dp501_fw_addr = NULL;
                                }
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 0x0c:
                        ast->tx_chip_type = AST_TX_DP501;
                }
index ce94f79..66b6740 100644 (file)
@@ -409,7 +409,6 @@ static bool nwl_dsi_read_packet(struct nwl_dsi *dsi, u32 status)
 
                switch (data_type) {
                case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE:
-                       fallthrough;
                case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE:
                        if (xfer->msg->rx_len > 1) {
                                /* read second byte */
@@ -418,7 +417,6 @@ static bool nwl_dsi_read_packet(struct nwl_dsi *dsi, u32 status)
                        }
                        fallthrough;
                case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE:
-                       fallthrough;
                case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
                        if (xfer->msg->rx_len > 0) {
                                /* read first byte */
index d7e65c8..9fef641 100644 (file)
@@ -61,10 +61,10 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
        switch (hparms->channels) {
        case 7 ... 8:
                conf0 |= HDMI_AUD_CONF0_I2S_EN3;
-               /* Fall-thru */
+               fallthrough;
        case 5 ... 6:
                conf0 |= HDMI_AUD_CONF0_I2S_EN2;
-               /* Fall-thru */
+               fallthrough;
        case 3 ... 4:
                conf0 |= HDMI_AUD_CONF0_I2S_EN1;
                /* Fall-thru */
index 86b9f0f..5b6e19e 100644 (file)
@@ -604,13 +604,13 @@ static void ti_sn_bridge_read_valid_rates(struct ti_sn_bridge *pdata,
                DRM_DEV_ERROR(pdata->dev,
                              "Unexpected max rate (%#x); assuming 5.4 GHz\n",
                              (int)dpcd_val);
-               /* fall through */
+               fallthrough;
        case DP_LINK_BW_5_4:
                rate_valid[7] = 1;
-               /* fall through */
+               fallthrough;
        case DP_LINK_BW_2_7:
                rate_valid[4] = 1;
-               /* fall through */
+               fallthrough;
        case DP_LINK_BW_1_62:
                rate_valid[1] = 1;
                break;
index f68c69a..9e1ad49 100644 (file)
@@ -34,6 +34,7 @@
 #include <drm/drm_bridge.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_device.h>
+#include <drm/drm_drv.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_self_refresh_helper.h>
@@ -3106,7 +3107,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
        if (ret)
                DRM_ERROR("Disabling all crtc's during unload failed with %i\n", ret);
 
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
 }
 EXPORT_SYMBOL(drm_atomic_helper_shutdown);
 
@@ -3246,7 +3247,7 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
        }
 
 unlock:
-       DRM_MODESET_LOCK_ALL_END(ctx, err);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
        if (err)
                return ERR_PTR(err);
 
@@ -3327,7 +3328,7 @@ int drm_atomic_helper_resume(struct drm_device *dev,
 
        err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
 
-       DRM_MODESET_LOCK_ALL_END(ctx, err);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
        drm_atomic_state_put(state);
 
        return err;
index a0735fb..7a01d09 100644 (file)
@@ -537,7 +537,7 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
        switch (map->type) {
        case _DRM_REGISTERS:
                iounmap(map->handle);
-               /* FALLTHROUGH */
+               fallthrough;
        case _DRM_FRAME_BUFFER:
                arch_phys_wc_del(map->mtrr);
                break;
index c93123f..138ff34 100644 (file)
@@ -294,7 +294,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
                                     crtc->gamma_size, &ctx);
 
 out:
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
        return ret;
 
 }
index 283bcc4..aecdd7e 100644 (file)
@@ -588,7 +588,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
        if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
                return -EACCES;
 
-       mutex_lock(&crtc->dev->mode_config.mutex);
        DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx,
                                   DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);
 
@@ -756,8 +755,7 @@ out:
        fb = NULL;
        mode = NULL;
 
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
-       mutex_unlock(&crtc->dev->mode_config.mutex);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
 
        return ret;
 }
index a3c82e7..092c8c9 100644 (file)
@@ -492,7 +492,7 @@ int drm_dp_downstream_max_bpc(const u8 dpcd[DP_RECEIVER_CAP_SIZE],
                case DP_DS_16BPC:
                        return 16;
                }
-               /* fall through */
+               fallthrough;
        default:
                return 0;
        }
index b23cb2f..67dd72e 100644 (file)
@@ -5040,8 +5040,8 @@ int drm_dp_mst_add_affected_dsc_crtcs(struct drm_atomic_state *state, struct drm
 
                crtc = conn_state->crtc;
 
-               if (WARN_ON(!crtc))
-                       return -EINVAL;
+               if (!crtc)
+                       continue;
 
                if (!drm_dp_mst_dsc_aux_for_port(pos->port))
                        continue;
index 901b078..db05f38 100644 (file)
@@ -428,7 +428,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
 out_unref:
        drm_mode_object_put(obj);
 out:
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
        return ret;
 }
 
@@ -470,7 +470,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
                break;
        }
        drm_property_change_valid_put(prop, ref);
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
+       DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
 
        return ret;
 }
index 14b6f76..501b4fe 100644 (file)
@@ -1930,7 +1930,7 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
        default:
                WARN(1, "Invalid aspect ratio (0%x) on mode\n",
                     in->picture_aspect_ratio);
-               /* fall through */
+               fallthrough;
        case HDMI_PICTURE_ASPECT_NONE:
                out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
                break;
index b7b90b3..affe1cf 100644 (file)
@@ -792,7 +792,7 @@ static int setplane_internal(struct drm_plane *plane,
                                          crtc_x, crtc_y, crtc_w, crtc_h,
                                          src_x, src_y, src_w, src_h, &ctx);
 
-       DRM_MODESET_LOCK_ALL_END(ctx, ret);
+       DRM_MODESET_LOCK_ALL_END(plane->dev, ctx, ret);
 
        return ret;
 }
index d5a4cd8..c6404b8 100644 (file)
@@ -337,9 +337,16 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
 
                gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
                gpu->identity.revision = gpu_read(gpu, VIVS_HI_CHIP_REV);
-               gpu->identity.product_id = gpu_read(gpu, VIVS_HI_CHIP_PRODUCT_ID);
                gpu->identity.customer_id = gpu_read(gpu, VIVS_HI_CHIP_CUSTOMER_ID);
-               gpu->identity.eco_id = gpu_read(gpu, VIVS_HI_CHIP_ECO_ID);
+
+               /*
+                * Reading these two registers on GC600 rev 0x19 result in a
+                * unhandled fault: external abort on non-linefetch
+                */
+               if (!etnaviv_is_model_rev(gpu, GC600, 0x19)) {
+                       gpu->identity.product_id = gpu_read(gpu, VIVS_HI_CHIP_PRODUCT_ID);
+                       gpu->identity.eco_id = gpu_read(gpu, VIVS_HI_CHIP_ECO_ID);
+               }
 
                /*
                 * !!!! HACK ALERT !!!!
index 4e3e95d..cd46c88 100644 (file)
@@ -89,12 +89,15 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
        u32 dma_addr;
        int change;
 
+       /* block scheduler */
+       drm_sched_stop(&gpu->sched, sched_job);
+
        /*
         * If the GPU managed to complete this jobs fence, the timout is
         * spurious. Bail out.
         */
        if (dma_fence_is_signaled(submit->out_fence))
-               return;
+               goto out_no_timeout;
 
        /*
         * If the GPU is still making forward progress on the front-end (which
@@ -105,12 +108,9 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
        change = dma_addr - gpu->hangcheck_dma_addr;
        if (change < 0 || change > 16) {
                gpu->hangcheck_dma_addr = dma_addr;
-               return;
+               goto out_no_timeout;
        }
 
-       /* block scheduler */
-       drm_sched_stop(&gpu->sched, sched_job);
-
        if(sched_job)
                drm_sched_increase_karma(sched_job);
 
@@ -120,6 +120,7 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
 
        drm_sched_resubmit_jobs(&gpu->sched);
 
+out_no_timeout:
        /* restart scheduler after GPU is usable again */
        drm_sched_start(&gpu->sched, true);
 }
index 7a6f6df..b38e9b5 100644 (file)
@@ -987,10 +987,10 @@ static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
        switch (length) {
        case 3:
                reg |= payload[2] << 16;
-               /* Fall through */
+               fallthrough;
        case 2:
                reg |= payload[1] << 8;
-               /* Fall through */
+               fallthrough;
        case 1:
                reg |= payload[0];
                exynos_dsi_write(dsi, DSIM_PAYLOAD_REG, reg);
@@ -1038,7 +1038,7 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
                                payload[1] = reg >> 16;
                                ++xfer->rx_done;
                        }
-                       /* Fall through */
+                       fallthrough;
                case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE:
                case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
                        payload[0] = reg >> 8;
@@ -1082,10 +1082,10 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
                switch (length) {
                case 3:
                        payload[2] = (reg >> 16) & 0xff;
-                       /* Fall through */
+                       fallthrough;
                case 2:
                        payload[1] = (reg >> 8) & 0xff;
-                       /* Fall through */
+                       fallthrough;
                case 1:
                        payload[0] = reg & 0xff;
                }
index 56a2b47..5147f59 100644 (file)
@@ -92,7 +92,7 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
        offset = fbi->var.xoffset * fb->format->cpp[0];
        offset += fbi->var.yoffset * fb->pitches[0];
 
-       fbi->screen_base = exynos_gem->kvaddr + offset;
+       fbi->screen_buffer = exynos_gem->kvaddr + offset;
        fbi->screen_size = size;
        fbi->fix.smem_len = size;
 
index 7445748..74e926a 100644 (file)
@@ -40,7 +40,7 @@ struct exynos_drm_gem {
        unsigned int            flags;
        unsigned long           size;
        void                    *cookie;
-       void __iomem            *kvaddr;
+       void                    *kvaddr;
        dma_addr_t              dma_addr;
        unsigned long           dma_attrs;
        struct sg_table         *sgt;
index 86fac67..3c6d9f3 100644 (file)
@@ -101,19 +101,19 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
                break;
        case DRM_FORMAT_ARGB8888:
                alpha = DCU_LAYER_AB_WHOLE_FRAME;
-               /* fall-through */
+               fallthrough;
        case DRM_FORMAT_XRGB8888:
                bpp = FSL_DCU_ARGB8888;
                break;
        case DRM_FORMAT_ARGB4444:
                alpha = DCU_LAYER_AB_WHOLE_FRAME;
-               /* fall-through */
+               fallthrough;
        case DRM_FORMAT_XRGB4444:
                bpp = FSL_DCU_ARGB4444;
                break;
        case DRM_FORMAT_ARGB1555:
                alpha = DCU_LAYER_AB_WHOLE_FRAME;
-               /* fall-through */
+               fallthrough;
        case DRM_FORMAT_XRGB1555:
                bpp = FSL_DCU_ARGB1555;
                break;
index 8c55f5b..f4053dd 100644 (file)
@@ -712,7 +712,7 @@ gen11_dsi_configure_transcoder(struct intel_encoder *encoder,
                        switch (intel_dsi->pixel_format) {
                        default:
                                MISSING_CASE(intel_dsi->pixel_format);
-                               /* fallthrough */
+                               fallthrough;
                        case MIPI_DSI_FMT_RGB565:
                                tmp |= PIX_FMT_RGB565;
                                break;
@@ -739,7 +739,7 @@ gen11_dsi_configure_transcoder(struct intel_encoder *encoder,
                        switch (intel_dsi->video_mode_format) {
                        default:
                                MISSING_CASE(intel_dsi->video_mode_format);
-                               /* fallthrough */
+                               fallthrough;
                        case VIDEO_MODE_NON_BURST_WITH_SYNC_EVENTS:
                                tmp |= VIDEO_MODE_SYNC_EVENT;
                                break;
@@ -792,7 +792,7 @@ gen11_dsi_configure_transcoder(struct intel_encoder *encoder,
                switch (pipe) {
                default:
                        MISSING_CASE(pipe);
-                       /* fallthrough */
+                       fallthrough;
                case PIPE_A:
                        tmp |= TRANS_DDI_EDP_INPUT_A_ON;
                        break;
index c53c85d..a0a41ec 100644 (file)
@@ -905,7 +905,7 @@ parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
                        drm_dbg_kms(&dev_priv->drm,
                                    "VBT tp1 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
                                    psr_table->tp1_wakeup_time);
-                       /* fallthrough */
+                       fallthrough;
                case 2:
                        dev_priv->vbt.psr.tp1_wakeup_time_us = 2500;
                        break;
@@ -925,7 +925,7 @@ parse_psr(struct drm_i915_private *dev_priv, const struct bdb_header *bdb)
                        drm_dbg_kms(&dev_priv->drm,
                                    "VBT tp2_tp3 wakeup time value %d is outside range[0-3], defaulting to max value 2500us\n",
                                    psr_table->tp2_tp3_wakeup_time);
-                       /* fallthrough */
+                       fallthrough;
                case 2:
                        dev_priv->vbt.psr.tp2_tp3_wakeup_time_us = 2500;
                break;
@@ -1775,7 +1775,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv,
                switch (child->hdmi_max_data_rate) {
                default:
                        MISSING_CASE(child->hdmi_max_data_rate);
-                       /* fall through */
+                       fallthrough;
                case HDMI_MAX_DATA_RATE_PLATFORM:
                        max_tmds_clock = 0;
                        break;
index bb91dac..91a8161 100644 (file)
@@ -326,7 +326,7 @@ static void pnv_get_cdclk(struct drm_i915_private *dev_priv,
        default:
                drm_err(&dev_priv->drm,
                        "Unknown pnv display core clock 0x%04x\n", gcfgc);
-               /* fall through */
+               fallthrough;
        case GC_DISPLAY_CLOCK_133_MHZ_PNV:
                cdclk_config->cdclk = 133333;
                break;
@@ -766,7 +766,7 @@ static void bdw_set_cdclk(struct drm_i915_private *dev_priv,
        switch (cdclk) {
        default:
                MISSING_CASE(cdclk);
-               /* fall through */
+               fallthrough;
        case 337500:
                val |= LCPLL_CLK_FREQ_337_5_BDW;
                break;
@@ -1042,7 +1042,7 @@ static void skl_set_cdclk(struct drm_i915_private *dev_priv,
                drm_WARN_ON(&dev_priv->drm,
                            cdclk != dev_priv->cdclk.hw.bypass);
                drm_WARN_ON(&dev_priv->drm, vco != 0);
-               /* fall through */
+               fallthrough;
        case 308571:
        case 337500:
                freq_select = CDCLK_FREQ_337_308;
@@ -1333,7 +1333,7 @@ static void icl_readout_refclk(struct drm_i915_private *dev_priv,
        switch (dssm) {
        default:
                MISSING_CASE(dssm);
-               /* fall through */
+               fallthrough;
        case ICL_DSSM_CDCLK_PLL_REFCLK_24MHz:
                cdclk_config->ref = 24000;
                break;
@@ -1561,7 +1561,7 @@ static void bxt_set_cdclk(struct drm_i915_private *dev_priv,
                drm_WARN_ON(&dev_priv->drm,
                            cdclk != dev_priv->cdclk.hw.bypass);
                drm_WARN_ON(&dev_priv->drm, vco != 0);
-               /* fall through */
+               fallthrough;
        case 2:
                divider = BXT_CDCLK_CD2X_DIV_SEL_1;
                break;
index eccaa79..157d8c8 100644 (file)
@@ -52,7 +52,7 @@ cnl_get_procmon_ref_values(struct drm_i915_private *dev_priv, enum phy phy)
        switch (val & (PROCESS_INFO_MASK | VOLTAGE_INFO_MASK)) {
        default:
                MISSING_CASE(val);
-               /* fall through */
+               fallthrough;
        case VOLTAGE_INFO_0_85V | PROCESS_INFO_DOT_0:
                procmon = &cnl_procmon_values[PROCMON_0_85V_DOT_0];
                break;
@@ -258,7 +258,7 @@ static bool phy_is_master(struct drm_i915_private *dev_priv, enum phy phy)
 static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
                                       enum phy phy)
 {
-       bool ret;
+       bool ret = true;
        u32 expected_val = 0;
 
        if (!icl_combo_phy_enabled(dev_priv, phy))
@@ -276,7 +276,7 @@ static bool icl_combo_phy_verify_state(struct drm_i915_private *dev_priv,
                                     DCC_MODE_SELECT_CONTINUOSLY);
        }
 
-       ret = cnl_verify_procmon_ref_values(dev_priv, phy);
+       ret &= cnl_verify_procmon_ref_values(dev_priv, phy);
 
        if (phy_is_master(dev_priv, phy)) {
                ret &= check_phy_reg(dev_priv, phy, ICL_PORT_COMP_DW8(phy),
@@ -320,7 +320,7 @@ void intel_combo_phy_power_up_lanes(struct drm_i915_private *dev_priv,
                        break;
                default:
                        MISSING_CASE(lane_count);
-                       /* fall-through */
+                       fallthrough;
                case 4:
                        lane_mask = PWR_UP_ALL_LANES;
                        break;
@@ -337,7 +337,7 @@ void intel_combo_phy_power_up_lanes(struct drm_i915_private *dev_priv,
                        break;
                default:
                        MISSING_CASE(lane_count);
-                       /* fall-through */
+                       fallthrough;
                case 4:
                        lane_mask = PWR_UP_ALL_LANES;
                        break;
index 2c484b5..a49ff3a 100644 (file)
@@ -1888,7 +1888,7 @@ static void intel_ddi_get_encoder_pipes(struct intel_encoder *encoder,
                switch (tmp & TRANS_DDI_EDP_INPUT_MASK) {
                default:
                        MISSING_CASE(tmp & TRANS_DDI_EDP_INPUT_MASK);
-                       /* fallthrough */
+                       fallthrough;
                case TRANS_DDI_EDP_INPUT_A_ON:
                case TRANS_DDI_EDP_INPUT_A_ONOFF:
                        *pipe_mask = BIT(PIPE_A);
@@ -4268,7 +4268,7 @@ void intel_ddi_get_config(struct intel_encoder *encoder,
                        pipe_config->hdmi_scrambling = true;
                if (temp & TRANS_DDI_HIGH_TMDS_CHAR_RATE)
                        pipe_config->hdmi_high_tmds_clock_ratio = true;
-               /* fall through */
+               fallthrough;
        case TRANS_DDI_MODE_SELECT_DVI:
                pipe_config->output_types |= BIT(INTEL_OUTPUT_HDMI);
                pipe_config->lane_count = 4;
index 729ec6e..b18c5ac 100644 (file)
@@ -2029,12 +2029,12 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
        case I915_FORMAT_MOD_Y_TILED_CCS:
                if (is_ccs_plane(fb, color_plane))
                        return 128;
-               /* fall through */
+               fallthrough;
        case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
        case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS:
                if (is_ccs_plane(fb, color_plane))
                        return 64;
-               /* fall through */
+               fallthrough;
        case I915_FORMAT_MOD_Y_TILED:
                if (IS_GEN(dev_priv, 2) || HAS_128_BYTE_Y_TILING(dev_priv))
                        return 128;
@@ -2043,7 +2043,7 @@ intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane)
        case I915_FORMAT_MOD_Yf_TILED_CCS:
                if (is_ccs_plane(fb, color_plane))
                        return 128;
-               /* fall through */
+               fallthrough;
        case I915_FORMAT_MOD_Yf_TILED:
                switch (cpp) {
                case 1:
@@ -2185,7 +2185,7 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
        case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS:
                if (is_semiplanar_uv_plane(fb, color_plane))
                        return intel_tile_row_size(fb, color_plane);
-               /* Fall-through */
+               fallthrough;
        case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS:
                return 16 * 1024;
        case I915_FORMAT_MOD_Y_TILED_CCS:
@@ -2194,7 +2194,7 @@ static unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
                if (INTEL_GEN(dev_priv) >= 12 &&
                    is_semiplanar_uv_plane(fb, color_plane))
                        return intel_tile_row_size(fb, color_plane);
-               /* Fall-through */
+               fallthrough;
        case I915_FORMAT_MOD_Yf_TILED:
                return 1 * 1024 * 1024;
        default:
@@ -6211,7 +6211,7 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
        case DRM_FORMAT_ARGB16161616F:
                if (INTEL_GEN(dev_priv) >= 11)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                drm_dbg_kms(&dev_priv->drm,
                            "[PLANE:%d:%s] FB:%d unsupported scaling format 0x%x\n",
@@ -10896,7 +10896,7 @@ static void hsw_get_ddi_pll(struct drm_i915_private *dev_priv, enum port port,
                break;
        default:
                MISSING_CASE(ddi_pll_sel);
-               /* fall through */
+               fallthrough;
        case PORT_CLK_SEL_NONE:
                return;
        }
@@ -10956,10 +10956,10 @@ static bool hsw_get_transcoder_state(struct intel_crtc *crtc,
                        drm_WARN(dev, 1,
                                 "unknown pipe linked to transcoder %s\n",
                                 transcoder_name(panel_transcoder));
-                       /* fall through */
+                       fallthrough;
                case TRANS_DDI_EDP_INPUT_A_ONOFF:
                        force_thru = true;
-                       /* fall through */
+                       fallthrough;
                case TRANS_DDI_EDP_INPUT_A_ON:
                        trans_pipe = PIPE_A;
                        break;
@@ -13183,7 +13183,7 @@ static bool check_digital_port_conflicts(struct intel_atomic_state *state)
                case INTEL_OUTPUT_DDI:
                        if (drm_WARN_ON(dev, !HAS_DDI(to_i915(dev))))
                                break;
-                       /* else, fall through */
+                       fallthrough;
                case INTEL_OUTPUT_DP:
                case INTEL_OUTPUT_HDMI:
                case INTEL_OUTPUT_EDP:
@@ -14930,7 +14930,7 @@ static int intel_atomic_check(struct drm_device *dev,
        if (any_ms && !check_digital_port_conflicts(state)) {
                drm_dbg_kms(&dev_priv->drm,
                            "rejecting conflicting digital port configuration\n");
-               ret = EINVAL;
+               ret = -EINVAL;
                goto fail;
        }
 
@@ -14956,12 +14956,6 @@ static int intel_atomic_check(struct drm_device *dev,
        if (dev_priv->wm.distrust_bios_wm)
                any_ms = true;
 
-       if (any_ms) {
-               ret = intel_modeset_checks(state);
-               if (ret)
-                       goto fail;
-       }
-
        intel_fbc_choose_crtc(dev_priv, state);
        ret = calc_watermark_data(state);
        if (ret)
@@ -14976,6 +14970,10 @@ static int intel_atomic_check(struct drm_device *dev,
                goto fail;
 
        if (any_ms) {
+               ret = intel_modeset_checks(state);
+               if (ret)
+                       goto fail;
+
                ret = intel_modeset_calc_cdclk(state);
                if (ret)
                        return ret;
index 3644752..5a5cfe2 100644 (file)
@@ -2044,9 +2044,12 @@ DEFINE_SHOW_ATTRIBUTE(i915_hdcp_sink_capability);
 static int i915_lpsp_capability_show(struct seq_file *m, void *data)
 {
        struct drm_connector *connector = m->private;
-       struct intel_encoder *encoder =
-                       intel_attached_encoder(to_intel_connector(connector));
        struct drm_i915_private *i915 = to_i915(connector->dev);
+       struct intel_encoder *encoder;
+
+       encoder = intel_attached_encoder(to_intel_connector(connector));
+       if (!encoder)
+               return -ENODEV;
 
        if (connector->status != connector_status_connected)
                return -ENODEV;
index 0c713e8..e0fcb89 100644 (file)
@@ -4146,6 +4146,12 @@ static const struct i915_power_well_desc tgl_power_wells[] = {
                        .hsw.idx = TGL_PW_CTL_IDX_DDI_TC6,
                },
        },
+       {
+               .name = "TC cold off",
+               .domains = TGL_TC_COLD_OFF_POWER_DOMAINS,
+               .ops = &tgl_tc_cold_off_ops,
+               .id = DISP_PW_ID_NONE,
+       },
        {
                .name = "AUX A",
                .domains = TGL_AUX_A_IO_POWER_DOMAINS,
@@ -4332,12 +4338,6 @@ static const struct i915_power_well_desc tgl_power_wells[] = {
                        .hsw.irq_pipe_mask = BIT(PIPE_D),
                },
        },
-       {
-               .name = "TC cold off",
-               .domains = TGL_TC_COLD_OFF_POWER_DOMAINS,
-               .ops = &tgl_tc_cold_off_ops,
-               .id = DISP_PW_ID_NONE,
-       },
 };
 
 static const struct i915_power_well_desc rkl_power_wells[] = {
@@ -5240,10 +5240,10 @@ struct buddy_page_mask {
 };
 
 static const struct buddy_page_mask tgl_buddy_page_masks[] = {
-       { .num_channels = 1, .type = INTEL_DRAM_LPDDR4, .page_mask = 0xE },
        { .num_channels = 1, .type = INTEL_DRAM_DDR4,   .page_mask = 0xF },
        { .num_channels = 2, .type = INTEL_DRAM_LPDDR4, .page_mask = 0x1C },
        { .num_channels = 2, .type = INTEL_DRAM_DDR4,   .page_mask = 0x1F },
+       { .num_channels = 4, .type = INTEL_DRAM_LPDDR4, .page_mask = 0x38 },
        {}
 };
 
index aeb6ee3..afa7a37 100644 (file)
@@ -892,7 +892,7 @@ static int hsw_ddi_wrpll_get_freq(struct drm_i915_private *dev_priv,
                        refclk = dev_priv->dpll.ref_clks.nssc;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case WRPLL_REF_PCH_SSC:
                /*
                 * We could calculate spread here, but our checking
@@ -2977,7 +2977,7 @@ static bool icl_calc_tbt_pll(struct intel_crtc_state *crtc_state,
                switch (dev_priv->dpll.ref_clks.nssc) {
                default:
                        MISSING_CASE(dev_priv->dpll.ref_clks.nssc);
-                       /* fall-through */
+                       fallthrough;
                case 19200:
                        *pll_params = tgl_tbt_pll_19_2MHz_values;
                        break;
@@ -2992,7 +2992,7 @@ static bool icl_calc_tbt_pll(struct intel_crtc_state *crtc_state,
                switch (dev_priv->dpll.ref_clks.nssc) {
                default:
                        MISSING_CASE(dev_priv->dpll.ref_clks.nssc);
-                       /* fall-through */
+                       fallthrough;
                case 19200:
                case 38400:
                        *pll_params = icl_tbt_pll_19_2MHz_values;
@@ -3120,7 +3120,7 @@ static bool icl_mg_pll_find_divisors(int clock_khz, bool is_dp, bool use_ssc,
                        switch (div1) {
                        default:
                                MISSING_CASE(div1);
-                               /* fall through */
+                               fallthrough;
                        case 2:
                                hsdiv = MG_CLKTOP2_HSCLKCTL_HSDIV_RATIO_2;
                                break;
index 89a4d29..1a0d49a 100644 (file)
@@ -336,8 +336,10 @@ int intel_hdcp_validate_v_prime(struct intel_connector *connector,
 
                /* Fill up the empty slots in sha_text and write it out */
                sha_empty = sizeof(sha_text) - sha_leftovers;
-               for (j = 0; j < sha_empty; j++)
-                       sha_text |= ksv[j] << ((sizeof(sha_text) - j - 1) * 8);
+               for (j = 0; j < sha_empty; j++) {
+                       u8 off = ((sizeof(sha_text) - j - 1 - sha_leftovers) * 8);
+                       sha_text |= ksv[j] << off;
+               }
 
                ret = intel_write_sha_text(dev_priv, sha_text);
                if (ret < 0)
@@ -435,7 +437,7 @@ int intel_hdcp_validate_v_prime(struct intel_connector *connector,
                /* Write 32 bits of text */
                intel_de_write(dev_priv, HDCP_REP_CTL,
                               rep_ctl | HDCP_SHA1_TEXT_32);
-               sha_text |= bstatus[0] << 24 | bstatus[1] << 16;
+               sha_text |= bstatus[0] << 8 | bstatus[1];
                ret = intel_write_sha_text(dev_priv, sha_text);
                if (ret < 0)
                        return ret;
@@ -450,17 +452,29 @@ int intel_hdcp_validate_v_prime(struct intel_connector *connector,
                                return ret;
                        sha_idx += sizeof(sha_text);
                }
+
+               /*
+                * Terminate the SHA-1 stream by hand. For the other leftover
+                * cases this is appended by the hardware.
+                */
+               intel_de_write(dev_priv, HDCP_REP_CTL,
+                              rep_ctl | HDCP_SHA1_TEXT_32);
+               sha_text = DRM_HDCP_SHA1_TERMINATOR << 24;
+               ret = intel_write_sha_text(dev_priv, sha_text);
+               if (ret < 0)
+                       return ret;
+               sha_idx += sizeof(sha_text);
        } else if (sha_leftovers == 3) {
-               /* Write 32 bits of text */
+               /* Write 32 bits of text (filled from LSB) */
                intel_de_write(dev_priv, HDCP_REP_CTL,
                               rep_ctl | HDCP_SHA1_TEXT_32);
-               sha_text |= bstatus[0] << 24;
+               sha_text |= bstatus[0];
                ret = intel_write_sha_text(dev_priv, sha_text);
                if (ret < 0)
                        return ret;
                sha_idx += sizeof(sha_text);
 
-               /* Write 8 bits of text, 24 bits of M0 */
+               /* Write 8 bits of text (filled from LSB), 24 bits of M0 */
                intel_de_write(dev_priv, HDCP_REP_CTL,
                               rep_ctl | HDCP_SHA1_TEXT_8);
                ret = intel_write_sha_text(dev_priv, bstatus[1]);
@@ -781,6 +795,7 @@ static int _intel_hdcp_disable(struct intel_connector *connector)
        struct intel_hdcp *hdcp = &connector->hdcp;
        enum port port = dig_port->base.port;
        enum transcoder cpu_transcoder = hdcp->cpu_transcoder;
+       u32 repeater_ctl;
        int ret;
 
        drm_dbg_kms(&dev_priv->drm, "[%s:%d] HDCP is being disabled...\n",
@@ -796,6 +811,11 @@ static int _intel_hdcp_disable(struct intel_connector *connector)
                return -ETIMEDOUT;
        }
 
+       repeater_ctl = intel_hdcp_get_repeater_ctl(dev_priv, cpu_transcoder,
+                                                  port);
+       intel_de_write(dev_priv, HDCP_REP_CTL,
+                      intel_de_read(dev_priv, HDCP_REP_CTL) & ~repeater_ctl);
+
        ret = hdcp->shim->toggle_signalling(dig_port, false);
        if (ret) {
                drm_err(&dev_priv->drm, "Failed to disable HDCP signalling\n");
index bbde3b1..4072d70 100644 (file)
@@ -229,7 +229,7 @@ int intel_pch_panel_fitting(struct intel_crtc_state *crtc_state,
        case DRM_MODE_SCALE_NONE:
                WARN_ON(adjusted_mode->crtc_hdisplay != crtc_state->pipe_src_w);
                WARN_ON(adjusted_mode->crtc_vdisplay != crtc_state->pipe_src_h);
-               /* fall through */
+               fallthrough;
        case DRM_MODE_SCALE_FULLSCREEN:
                x = y = 0;
                width = adjusted_mode->crtc_hdisplay;
index 2da4388..5e9fb34 100644 (file)
@@ -1531,7 +1531,7 @@ static void intel_sdvo_pre_enable(struct intel_atomic_state *state,
        default:
                drm_WARN(&dev_priv->drm, 1,
                         "unknown pixel multiplier specified\n");
-               /* fall through */
+               fallthrough;
        case 1: rate = SDVO_CLOCK_RATE_MULT_1X; break;
        case 2: rate = SDVO_CLOCK_RATE_MULT_2X; break;
        case 4: rate = SDVO_CLOCK_RATE_MULT_4X; break;
@@ -2549,19 +2549,19 @@ intel_sdvo_guess_ddc_bus(struct intel_sdvo *sdvo)
        switch (sdvo->controlled_output) {
        case SDVO_OUTPUT_LVDS1:
                mask |= SDVO_OUTPUT_LVDS1;
-               /* fall through */
+               fallthrough;
        case SDVO_OUTPUT_LVDS0:
                mask |= SDVO_OUTPUT_LVDS0;
-               /* fall through */
+               fallthrough;
        case SDVO_OUTPUT_TMDS1:
                mask |= SDVO_OUTPUT_TMDS1;
-               /* fall through */
+               fallthrough;
        case SDVO_OUTPUT_TMDS0:
                mask |= SDVO_OUTPUT_TMDS0;
-               /* fall through */
+               fallthrough;
        case SDVO_OUTPUT_RGB1:
                mask |= SDVO_OUTPUT_RGB1;
-               /* fall through */
+               fallthrough;
        case SDVO_OUTPUT_RGB0:
                mask |= SDVO_OUTPUT_RGB0;
                break;
index d03860f..c89f5f7 100644 (file)
@@ -2147,7 +2147,7 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state,
                case DRM_FORMAT_RGB565:
                        if (INTEL_GEN(dev_priv) >= 11)
                                break;
-                       /* fall through */
+                       fallthrough;
                case DRM_FORMAT_C8:
                case DRM_FORMAT_XRGB16161616F:
                case DRM_FORMAT_XBGR16161616F:
@@ -2702,7 +2702,7 @@ static bool g4x_sprite_format_mod_supported(struct drm_plane *_plane,
                if (modifier == DRM_FORMAT_MOD_LINEAR ||
                    modifier == I915_FORMAT_MOD_X_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
@@ -2733,7 +2733,7 @@ static bool snb_sprite_format_mod_supported(struct drm_plane *_plane,
                if (modifier == DRM_FORMAT_MOD_LINEAR ||
                    modifier == I915_FORMAT_MOD_X_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
@@ -2768,7 +2768,7 @@ static bool vlv_sprite_format_mod_supported(struct drm_plane *_plane,
                if (modifier == DRM_FORMAT_MOD_LINEAR ||
                    modifier == I915_FORMAT_MOD_X_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
@@ -2801,7 +2801,7 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_ABGR8888:
                if (is_ccs_modifier(modifier))
                        return true;
-               /* fall through */
+               fallthrough;
        case DRM_FORMAT_RGB565:
        case DRM_FORMAT_XRGB2101010:
        case DRM_FORMAT_XBGR2101010:
@@ -2819,7 +2819,7 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_XVYU2101010:
                if (modifier == I915_FORMAT_MOD_Yf_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        case DRM_FORMAT_C8:
        case DRM_FORMAT_XBGR16161616F:
        case DRM_FORMAT_ABGR16161616F:
@@ -2834,7 +2834,7 @@ static bool skl_plane_format_mod_supported(struct drm_plane *_plane,
                    modifier == I915_FORMAT_MOD_X_TILED ||
                    modifier == I915_FORMAT_MOD_Y_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
@@ -2860,7 +2860,7 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
        case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS:
                if (!gen12_plane_supports_mc_ccs(dev_priv, plane->id))
                        return false;
-               /* fall through */
+               fallthrough;
        case DRM_FORMAT_MOD_LINEAR:
        case I915_FORMAT_MOD_X_TILED:
        case I915_FORMAT_MOD_Y_TILED:
@@ -2877,7 +2877,7 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_ABGR8888:
                if (is_ccs_modifier(modifier))
                        return true;
-               /* fall through */
+               fallthrough;
        case DRM_FORMAT_YUYV:
        case DRM_FORMAT_YVYU:
        case DRM_FORMAT_UYVY:
@@ -2889,7 +2889,7 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
        case DRM_FORMAT_P016:
                if (modifier == I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS)
                        return true;
-               /* fall through */
+               fallthrough;
        case DRM_FORMAT_RGB565:
        case DRM_FORMAT_XRGB2101010:
        case DRM_FORMAT_XBGR2101010:
@@ -2910,7 +2910,7 @@ static bool gen12_plane_format_mod_supported(struct drm_plane *_plane,
                    modifier == I915_FORMAT_MOD_X_TILED ||
                    modifier == I915_FORMAT_MOD_Y_TILED)
                        return true;
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
index 5b5dc86..8f67aef 100644 (file)
@@ -159,7 +159,7 @@ int intel_tc_port_fia_max_lane_count(struct intel_digital_port *dig_port)
        switch (lane_mask) {
        default:
                MISSING_CASE(lane_mask);
-               /* fall-through */
+               fallthrough;
        case 0x1:
        case 0x2:
        case 0x4:
index 6b4ec66..446e76e 100644 (file)
@@ -45,6 +45,13 @@ struct eb_vma_array {
        struct eb_vma vma[];
 };
 
+enum {
+       FORCE_CPU_RELOC = 1,
+       FORCE_GTT_RELOC,
+       FORCE_GPU_RELOC,
+#define DBG_FORCE_RELOC 0 /* choose one of the above! */
+};
+
 #define __EXEC_OBJECT_HAS_PIN          BIT(31)
 #define __EXEC_OBJECT_HAS_FENCE                BIT(30)
 #define __EXEC_OBJECT_NEEDS_MAP                BIT(29)
@@ -253,6 +260,8 @@ struct i915_execbuffer {
         */
        struct reloc_cache {
                struct drm_mm_node node; /** temporary GTT binding */
+               unsigned long vaddr; /** Current kmap address */
+               unsigned long page; /** Currently mapped page index */
                unsigned int gen; /** Cached value of INTEL_GEN */
                bool use_64bit_reloc : 1;
                bool has_llc : 1;
@@ -596,6 +605,23 @@ eb_add_vma(struct i915_execbuffer *eb,
        }
 }
 
+static inline int use_cpu_reloc(const struct reloc_cache *cache,
+                               const struct drm_i915_gem_object *obj)
+{
+       if (!i915_gem_object_has_struct_page(obj))
+               return false;
+
+       if (DBG_FORCE_RELOC == FORCE_CPU_RELOC)
+               return true;
+
+       if (DBG_FORCE_RELOC == FORCE_GTT_RELOC)
+               return false;
+
+       return (cache->has_llc ||
+               obj->cache_dirty ||
+               obj->cache_level != I915_CACHE_NONE);
+}
+
 static int eb_reserve_vma(const struct i915_execbuffer *eb,
                          struct eb_vma *ev,
                          u64 pin_flags)
@@ -926,6 +952,8 @@ relocation_target(const struct drm_i915_gem_relocation_entry *reloc,
 static void reloc_cache_init(struct reloc_cache *cache,
                             struct drm_i915_private *i915)
 {
+       cache->page = -1;
+       cache->vaddr = 0;
        /* Must be a variable in the struct to allow GCC to unroll. */
        cache->gen = INTEL_GEN(i915);
        cache->has_llc = HAS_LLC(i915);
@@ -937,6 +965,25 @@ static void reloc_cache_init(struct reloc_cache *cache,
        cache->target = NULL;
 }
 
+static inline void *unmask_page(unsigned long p)
+{
+       return (void *)(uintptr_t)(p & PAGE_MASK);
+}
+
+static inline unsigned int unmask_flags(unsigned long p)
+{
+       return p & ~PAGE_MASK;
+}
+
+#define KMAP 0x4 /* after CLFLUSH_FLAGS */
+
+static inline struct i915_ggtt *cache_to_ggtt(struct reloc_cache *cache)
+{
+       struct drm_i915_private *i915 =
+               container_of(cache, struct i915_execbuffer, reloc_cache)->i915;
+       return &i915->ggtt;
+}
+
 #define RELOC_TAIL 4
 
 static int reloc_gpu_chain(struct reloc_cache *cache)
@@ -1049,6 +1096,181 @@ static int reloc_gpu_flush(struct reloc_cache *cache)
        return err;
 }
 
+static void reloc_cache_reset(struct reloc_cache *cache)
+{
+       void *vaddr;
+
+       if (!cache->vaddr)
+               return;
+
+       vaddr = unmask_page(cache->vaddr);
+       if (cache->vaddr & KMAP) {
+               if (cache->vaddr & CLFLUSH_AFTER)
+                       mb();
+
+               kunmap_atomic(vaddr);
+               i915_gem_object_finish_access((struct drm_i915_gem_object *)cache->node.mm);
+       } else {
+               struct i915_ggtt *ggtt = cache_to_ggtt(cache);
+
+               intel_gt_flush_ggtt_writes(ggtt->vm.gt);
+               io_mapping_unmap_atomic((void __iomem *)vaddr);
+
+               if (drm_mm_node_allocated(&cache->node)) {
+                       ggtt->vm.clear_range(&ggtt->vm,
+                                            cache->node.start,
+                                            cache->node.size);
+                       mutex_lock(&ggtt->vm.mutex);
+                       drm_mm_remove_node(&cache->node);
+                       mutex_unlock(&ggtt->vm.mutex);
+               } else {
+                       i915_vma_unpin((struct i915_vma *)cache->node.mm);
+               }
+       }
+
+       cache->vaddr = 0;
+       cache->page = -1;
+}
+
+static void *reloc_kmap(struct drm_i915_gem_object *obj,
+                       struct reloc_cache *cache,
+                       unsigned long page)
+{
+       void *vaddr;
+
+       if (cache->vaddr) {
+               kunmap_atomic(unmask_page(cache->vaddr));
+       } else {
+               unsigned int flushes;
+               int err;
+
+               err = i915_gem_object_prepare_write(obj, &flushes);
+               if (err)
+                       return ERR_PTR(err);
+
+               BUILD_BUG_ON(KMAP & CLFLUSH_FLAGS);
+               BUILD_BUG_ON((KMAP | CLFLUSH_FLAGS) & PAGE_MASK);
+
+               cache->vaddr = flushes | KMAP;
+               cache->node.mm = (void *)obj;
+               if (flushes)
+                       mb();
+       }
+
+       vaddr = kmap_atomic(i915_gem_object_get_dirty_page(obj, page));
+       cache->vaddr = unmask_flags(cache->vaddr) | (unsigned long)vaddr;
+       cache->page = page;
+
+       return vaddr;
+}
+
+static void *reloc_iomap(struct drm_i915_gem_object *obj,
+                        struct reloc_cache *cache,
+                        unsigned long page)
+{
+       struct i915_ggtt *ggtt = cache_to_ggtt(cache);
+       unsigned long offset;
+       void *vaddr;
+
+       if (cache->vaddr) {
+               intel_gt_flush_ggtt_writes(ggtt->vm.gt);
+               io_mapping_unmap_atomic((void __force __iomem *) unmask_page(cache->vaddr));
+       } else {
+               struct i915_vma *vma;
+               int err;
+
+               if (i915_gem_object_is_tiled(obj))
+                       return ERR_PTR(-EINVAL);
+
+               if (use_cpu_reloc(cache, obj))
+                       return NULL;
+
+               i915_gem_object_lock(obj);
+               err = i915_gem_object_set_to_gtt_domain(obj, true);
+               i915_gem_object_unlock(obj);
+               if (err)
+                       return ERR_PTR(err);
+
+               vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
+                                              PIN_MAPPABLE |
+                                              PIN_NONBLOCK /* NOWARN */ |
+                                              PIN_NOEVICT);
+               if (IS_ERR(vma)) {
+                       memset(&cache->node, 0, sizeof(cache->node));
+                       mutex_lock(&ggtt->vm.mutex);
+                       err = drm_mm_insert_node_in_range
+                               (&ggtt->vm.mm, &cache->node,
+                                PAGE_SIZE, 0, I915_COLOR_UNEVICTABLE,
+                                0, ggtt->mappable_end,
+                                DRM_MM_INSERT_LOW);
+                       mutex_unlock(&ggtt->vm.mutex);
+                       if (err) /* no inactive aperture space, use cpu reloc */
+                               return NULL;
+               } else {
+                       cache->node.start = vma->node.start;
+                       cache->node.mm = (void *)vma;
+               }
+       }
+
+       offset = cache->node.start;
+       if (drm_mm_node_allocated(&cache->node)) {
+               ggtt->vm.insert_page(&ggtt->vm,
+                                    i915_gem_object_get_dma_address(obj, page),
+                                    offset, I915_CACHE_NONE, 0);
+       } else {
+               offset += page << PAGE_SHIFT;
+       }
+
+       vaddr = (void __force *)io_mapping_map_atomic_wc(&ggtt->iomap,
+                                                        offset);
+       cache->page = page;
+       cache->vaddr = (unsigned long)vaddr;
+
+       return vaddr;
+}
+
+static void *reloc_vaddr(struct drm_i915_gem_object *obj,
+                        struct reloc_cache *cache,
+                        unsigned long page)
+{
+       void *vaddr;
+
+       if (cache->page == page) {
+               vaddr = unmask_page(cache->vaddr);
+       } else {
+               vaddr = NULL;
+               if ((cache->vaddr & KMAP) == 0)
+                       vaddr = reloc_iomap(obj, cache, page);
+               if (!vaddr)
+                       vaddr = reloc_kmap(obj, cache, page);
+       }
+
+       return vaddr;
+}
+
+static void clflush_write32(u32 *addr, u32 value, unsigned int flushes)
+{
+       if (unlikely(flushes & (CLFLUSH_BEFORE | CLFLUSH_AFTER))) {
+               if (flushes & CLFLUSH_BEFORE) {
+                       clflushopt(addr);
+                       mb();
+               }
+
+               *addr = value;
+
+               /*
+                * Writes to the same cacheline are serialised by the CPU
+                * (including clflush). On the write path, we only require
+                * that it hits memory in an orderly fashion and place
+                * mb barriers at the start and end of the relocation phase
+                * to ensure ordering of clflush wrt to the system.
+                */
+               if (flushes & CLFLUSH_AFTER)
+                       clflushopt(addr);
+       } else
+               *addr = value;
+}
+
 static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
 {
        struct drm_i915_gem_object *obj = vma->obj;
@@ -1214,6 +1436,17 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
        return cmd;
 }
 
+static inline bool use_reloc_gpu(struct i915_vma *vma)
+{
+       if (DBG_FORCE_RELOC == FORCE_GPU_RELOC)
+               return true;
+
+       if (DBG_FORCE_RELOC)
+               return false;
+
+       return !dma_resv_test_signaled_rcu(vma->resv, true);
+}
+
 static unsigned long vma_phys_addr(struct i915_vma *vma, u32 offset)
 {
        struct page *page;
@@ -1228,10 +1461,10 @@ static unsigned long vma_phys_addr(struct i915_vma *vma, u32 offset)
        return addr + offset_in_page(offset);
 }
 
-static int __reloc_entry_gpu(struct i915_execbuffer *eb,
-                            struct i915_vma *vma,
-                            u64 offset,
-                            u64 target_addr)
+static bool __reloc_entry_gpu(struct i915_execbuffer *eb,
+                             struct i915_vma *vma,
+                             u64 offset,
+                             u64 target_addr)
 {
        const unsigned int gen = eb->reloc_cache.gen;
        unsigned int len;
@@ -1247,7 +1480,7 @@ static int __reloc_entry_gpu(struct i915_execbuffer *eb,
 
        batch = reloc_gpu(eb, vma, len);
        if (IS_ERR(batch))
-               return PTR_ERR(batch);
+               return false;
 
        addr = gen8_canonical_addr(vma->node.start + offset);
        if (gen >= 8) {
@@ -1296,21 +1529,55 @@ static int __reloc_entry_gpu(struct i915_execbuffer *eb,
                *batch++ = target_addr;
        }
 
-       return 0;
+       return true;
+}
+
+static bool reloc_entry_gpu(struct i915_execbuffer *eb,
+                           struct i915_vma *vma,
+                           u64 offset,
+                           u64 target_addr)
+{
+       if (eb->reloc_cache.vaddr)
+               return false;
+
+       if (!use_reloc_gpu(vma))
+               return false;
+
+       return __reloc_entry_gpu(eb, vma, offset, target_addr);
 }
 
 static u64
-relocate_entry(struct i915_execbuffer *eb,
-              struct i915_vma *vma,
+relocate_entry(struct i915_vma *vma,
               const struct drm_i915_gem_relocation_entry *reloc,
+              struct i915_execbuffer *eb,
               const struct i915_vma *target)
 {
        u64 target_addr = relocation_target(reloc, target);
-       int err;
-
-       err = __reloc_entry_gpu(eb, vma, reloc->offset, target_addr);
-       if (err)
-               return err;
+       u64 offset = reloc->offset;
+
+       if (!reloc_entry_gpu(eb, vma, offset, target_addr)) {
+               bool wide = eb->reloc_cache.use_64bit_reloc;
+               void *vaddr;
+
+repeat:
+               vaddr = reloc_vaddr(vma->obj,
+                                   &eb->reloc_cache,
+                                   offset >> PAGE_SHIFT);
+               if (IS_ERR(vaddr))
+                       return PTR_ERR(vaddr);
+
+               GEM_BUG_ON(!IS_ALIGNED(offset, sizeof(u32)));
+               clflush_write32(vaddr + offset_in_page(offset),
+                               lower_32_bits(target_addr),
+                               eb->reloc_cache.vaddr);
+
+               if (wide) {
+                       offset += sizeof(u32);
+                       target_addr >>= 32;
+                       wide = false;
+                       goto repeat;
+               }
+       }
 
        return target->node.start | UPDATE;
 }
@@ -1375,7 +1642,8 @@ eb_relocate_entry(struct i915_execbuffer *eb,
         * If the relocation already has the right value in it, no
         * more work needs to be done.
         */
-       if (gen8_canonical_addr(target->vma->node.start) == reloc->presumed_offset)
+       if (!DBG_FORCE_RELOC &&
+           gen8_canonical_addr(target->vma->node.start) == reloc->presumed_offset)
                return 0;
 
        /* Check that the relocation address is valid... */
@@ -1407,7 +1675,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,
        ev->flags &= ~EXEC_OBJECT_ASYNC;
 
        /* and update the user's relocation entry */
-       return relocate_entry(eb, ev->vma, reloc, target->vma);
+       return relocate_entry(ev->vma, reloc, eb, target->vma);
 }
 
 static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
@@ -1445,8 +1713,10 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
                 * this is bad and so lockdep complains vehemently.
                 */
                copied = __copy_from_user(r, urelocs, count * sizeof(r[0]));
-               if (unlikely(copied))
-                       return -EFAULT;
+               if (unlikely(copied)) {
+                       remain = -EFAULT;
+                       goto out;
+               }
 
                remain -= count;
                do {
@@ -1454,7 +1724,8 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 
                        if (likely(offset == 0)) {
                        } else if ((s64)offset < 0) {
-                               return (int)offset;
+                               remain = (int)offset;
+                               goto out;
                        } else {
                                /*
                                 * Note that reporting an error now
@@ -1484,8 +1755,9 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
                } while (r++, --count);
                urelocs += ARRAY_SIZE(stack);
        } while (remain);
-
-       return 0;
+out:
+       reloc_cache_reset(&eb->reloc_cache);
+       return remain;
 }
 
 static int eb_relocate(struct i915_execbuffer *eb)
@@ -2392,7 +2664,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
        eb.i915 = i915;
        eb.file = file;
        eb.args = args;
-       if (!(args->flags & I915_EXEC_NO_RELOC))
+       if (DBG_FORCE_RELOC || !(args->flags & I915_EXEC_NO_RELOC))
                args->flags |= __EXEC_HAS_RELOC;
 
        eb.exec = exec;
index b233685..753f82d 100644 (file)
@@ -209,7 +209,7 @@ static vm_fault_t i915_error_to_vmf_fault(int err)
        switch (err) {
        default:
                WARN_ONCE(err, "unhandled error in %s: %i\n", __func__, err);
-               /* fallthrough */
+               fallthrough;
        case -EIO: /* shmemfs failure from swap device */
        case -EFAULT: /* purged object */
        case -ENODEV: /* bad object, how did you get here! */
index e5b9276..9cf4ad7 100644 (file)
@@ -258,6 +258,10 @@ struct page *
 i915_gem_object_get_page(struct drm_i915_gem_object *obj,
                         unsigned int n);
 
+struct page *
+i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj,
+                              unsigned int n);
+
 dma_addr_t
 i915_gem_object_get_dma_address_len(struct drm_i915_gem_object *obj,
                                    unsigned long n,
index 7050519..e8a0837 100644 (file)
@@ -276,7 +276,7 @@ static void *i915_gem_object_map(struct drm_i915_gem_object *obj,
        switch (type) {
        default:
                MISSING_CASE(type);
-               /* fallthrough - to use PAGE_KERNEL anyway */
+               fallthrough;    /* to use PAGE_KERNEL anyway */
        case I915_MAP_WB:
                pgprot = PAGE_KERNEL;
                break;
@@ -548,6 +548,20 @@ i915_gem_object_get_page(struct drm_i915_gem_object *obj, unsigned int n)
        return nth_page(sg_page(sg), offset);
 }
 
+/* Like i915_gem_object_get_page(), but mark the returned page dirty */
+struct page *
+i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj,
+                              unsigned int n)
+{
+       struct page *page;
+
+       page = i915_gem_object_get_page(obj, n);
+       if (!obj->mm.dirty)
+               set_page_dirty(page);
+
+       return page;
+}
+
 dma_addr_t
 i915_gem_object_get_dma_address_len(struct drm_i915_gem_object *obj,
                                    unsigned long n,
index e0f21f1..0be5e86 100644 (file)
@@ -249,7 +249,7 @@ static void vlv_get_stolen_reserved(struct drm_i915_private *i915,
        switch (reg_val & GEN7_STOLEN_RESERVED_SIZE_MASK) {
        default:
                MISSING_CASE(reg_val & GEN7_STOLEN_RESERVED_SIZE_MASK);
-               /* fall through */
+               fallthrough;
        case GEN7_STOLEN_RESERVED_1M:
                *size = 1024 * 1024;
                break;
@@ -416,7 +416,7 @@ static int i915_gem_init_stolen(struct drm_i915_private *i915)
        case 4:
                if (!IS_G4X(i915))
                        break;
-               /* fall through */
+               fallthrough;
        case 5:
                g4x_get_stolen_reserved(i915, uncore,
                                        &reserved_base, &reserved_size);
@@ -445,7 +445,7 @@ static int i915_gem_init_stolen(struct drm_i915_private *i915)
                break;
        default:
                MISSING_CASE(INTEL_GEN(i915));
-               /* fall-through */
+               fallthrough;
        case 11:
        case 12:
                icl_get_stolen_reserved(i915, uncore,
index 2c2bf24..12b3007 100644 (file)
@@ -596,14 +596,6 @@ static int i915_gem_userptr_get_pages(struct drm_i915_gem_object *obj)
                                      GFP_KERNEL |
                                      __GFP_NORETRY |
                                      __GFP_NOWARN);
-               /*
-                * Using __get_user_pages_fast() with a read-only
-                * access is questionable. A read-only page may be
-                * COW-broken, and then this might end up giving
-                * the wrong side of the COW..
-                *
-                * We may or may not care.
-                */
                if (pvec) {
                        /* defer to worker if malloc fails */
                        if (!i915_gem_object_is_readonly(obj))
index 57c14d3..a49016f 100644 (file)
@@ -37,14 +37,20 @@ static int __igt_gpu_reloc(struct i915_execbuffer *eb,
                return err;
 
        /* 8-Byte aligned */
-       err = __reloc_entry_gpu(eb, vma, offsets[0] * sizeof(u32), 0);
-       if (err)
+       if (!__reloc_entry_gpu(eb, vma,
+                              offsets[0] * sizeof(u32),
+                              0)) {
+               err = -EIO;
                goto unpin_vma;
+       }
 
        /* !8-Byte aligned */
-       err = __reloc_entry_gpu(eb, vma, offsets[1] * sizeof(u32), 1);
-       if (err)
+       if (!__reloc_entry_gpu(eb, vma,
+                              offsets[1] * sizeof(u32),
+                              1)) {
+               err = -EIO;
                goto unpin_vma;
+       }
 
        /* Skip to the end of the cmd page */
        i = PAGE_SIZE / sizeof(u32) - RELOC_TAIL - 1;
@@ -54,9 +60,12 @@ static int __igt_gpu_reloc(struct i915_execbuffer *eb,
        eb->reloc_cache.rq_size += i;
 
        /* Force batch chaining */
-       err = __reloc_entry_gpu(eb, vma, offsets[2] * sizeof(u32), 2);
-       if (err)
+       if (!__reloc_entry_gpu(eb, vma,
+                              offsets[2] * sizeof(u32),
+                              2)) {
+               err = -EIO;
                goto unpin_vma;
+       }
 
        GEM_BUG_ON(!eb->reloc_cache.rq);
        rq = i915_request_get(eb->reloc_cache.rq);
index dd1a42c..26087dd 100644 (file)
@@ -213,7 +213,7 @@ u32 intel_engine_context_size(struct intel_gt *gt, u8 class)
                break;
        default:
                MISSING_CASE(class);
-               /* fall through */
+               fallthrough;
        case VIDEO_DECODE_CLASS:
        case VIDEO_ENHANCEMENT_CLASS:
        case COPY_ENGINE_CLASS:
index 62979ea..99e28d9 100644 (file)
@@ -1437,7 +1437,7 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma)
        switch (vma->ggtt_view.type) {
        default:
                GEM_BUG_ON(vma->ggtt_view.type);
-               /* fall through */
+               fallthrough;
        case I915_GGTT_VIEW_NORMAL:
                vma->pages = vma->obj->mm.pages;
                return 0;
index 94915f6..898593c 100644 (file)
@@ -100,7 +100,7 @@ static void set_hwsp(struct intel_engine_cs *engine, u32 offset)
                 */
                default:
                        GEM_BUG_ON(engine->id);
-                       /* fallthrough */
+                       fallthrough;
                case RCS0:
                        hwsp = RENDER_HWS_PGA_GEN7;
                        break;
index 072725a..ad86c5e 100644 (file)
@@ -70,6 +70,7 @@ static void vgpu_pci_cfg_mem_write(struct intel_vgpu *vgpu, unsigned int off,
 {
        u8 *cfg_base = vgpu_cfg_space(vgpu);
        u8 mask, new, old;
+       pci_power_t pwr;
        int i = 0;
 
        for (; i < bytes && (off + i < sizeof(pci_cfg_space_rw_bmp)); i++) {
@@ -91,6 +92,15 @@ static void vgpu_pci_cfg_mem_write(struct intel_vgpu *vgpu, unsigned int off,
        /* For other configuration space directly copy as it is. */
        if (i < bytes)
                memcpy(cfg_base + off + i, src + i, bytes - i);
+
+       if (off == vgpu->cfg_space.pmcsr_off && vgpu->cfg_space.pmcsr_off) {
+               pwr = (pci_power_t __force)(*(u16*)(&vgpu_cfg_space(vgpu)[off])
+                       & PCI_PM_CTRL_STATE_MASK);
+               if (pwr == PCI_D3hot)
+                       vgpu->d3_entered = true;
+               gvt_dbg_core("vgpu-%d power status changed to %d\n",
+                            vgpu->id, pwr);
+       }
 }
 
 /**
@@ -366,6 +376,7 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
        struct intel_gvt *gvt = vgpu->gvt;
        const struct intel_gvt_device_info *info = &gvt->device_info;
        u16 *gmch_ctl;
+       u8 next;
 
        memcpy(vgpu_cfg_space(vgpu), gvt->firmware.cfg_space,
               info->cfg_space_size);
@@ -401,6 +412,19 @@ void intel_vgpu_init_cfg_space(struct intel_vgpu *vgpu,
                pci_resource_len(gvt->gt->i915->drm.pdev, 2);
 
        memset(vgpu_cfg_space(vgpu) + PCI_ROM_ADDRESS, 0, 4);
+
+       /* PM Support */
+       vgpu->cfg_space.pmcsr_off = 0;
+       if (vgpu_cfg_space(vgpu)[PCI_STATUS] & PCI_STATUS_CAP_LIST) {
+               next = vgpu_cfg_space(vgpu)[PCI_CAPABILITY_LIST];
+               do {
+                       if (vgpu_cfg_space(vgpu)[next + PCI_CAP_LIST_ID] == PCI_CAP_ID_PM) {
+                               vgpu->cfg_space.pmcsr_off = next + PCI_PM_CTRL;
+                               break;
+                       }
+                       next = vgpu_cfg_space(vgpu)[next + PCI_CAP_LIST_NEXT];
+               } while (next);
+       }
 }
 
 /**
index 2100161..a3a4305 100644 (file)
@@ -2501,7 +2501,7 @@ int intel_vgpu_init_gtt(struct intel_vgpu *vgpu)
        return create_scratch_page_tree(vgpu);
 }
 
-static void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu)
+void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu)
 {
        struct list_head *pos, *n;
        struct intel_vgpu_mm *mm;
index 320b8d6..52d0d88 100644 (file)
@@ -279,4 +279,6 @@ int intel_vgpu_emulate_ggtt_mmio_read(struct intel_vgpu *vgpu,
 int intel_vgpu_emulate_ggtt_mmio_write(struct intel_vgpu *vgpu,
        unsigned int off, void *p_data, unsigned int bytes);
 
+void intel_vgpu_destroy_all_ppgtt_mm(struct intel_vgpu *vgpu);
+
 #endif /* _GVT_GTT_H_ */
index a4a6db6..ff7f251 100644 (file)
@@ -106,6 +106,7 @@ struct intel_vgpu_pci_bar {
 struct intel_vgpu_cfg_space {
        unsigned char virtual_cfg_space[PCI_CFG_SPACE_EXP_SIZE];
        struct intel_vgpu_pci_bar bar[INTEL_GVT_MAX_BAR_NUM];
+       u32 pmcsr_off;
 };
 
 #define vgpu_cfg_space(vgpu) ((vgpu)->cfg_space.virtual_cfg_space)
@@ -198,6 +199,8 @@ struct intel_vgpu {
        struct intel_vgpu_submission submission;
        struct radix_tree_root page_track_tree;
        u32 hws_pga[I915_NUM_ENGINES];
+       /* Set on PCI_D3, reset on DMLR, not reflecting the actual PM state */
+       bool d3_entered;
 
        struct dentry *debugfs;
 
index 63bba7b..05f3bc9 100644 (file)
@@ -1226,7 +1226,7 @@ static int handle_g2v_notification(struct intel_vgpu *vgpu, int notification)
        switch (notification) {
        case VGT_G2V_PPGTT_L3_PAGE_TABLE_CREATE:
                root_entry_type = GTT_TYPE_PPGTT_ROOT_L3_ENTRY;
-               /* fall through */
+               fallthrough;
        case VGT_G2V_PPGTT_L4_PAGE_TABLE_CREATE:
                mm = intel_vgpu_get_ppgtt_mm(vgpu, root_entry_type, pdps);
                return PTR_ERR_OR_ZERO(mm);
index 7d36162..8fa9b31 100644 (file)
@@ -257,6 +257,7 @@ void intel_gvt_release_vgpu(struct intel_vgpu *vgpu)
        intel_gvt_deactivate_vgpu(vgpu);
 
        mutex_lock(&vgpu->vgpu_lock);
+       vgpu->d3_entered = false;
        intel_vgpu_clean_workloads(vgpu, ALL_ENGINES);
        intel_vgpu_dmabuf_cleanup(vgpu);
        mutex_unlock(&vgpu->vgpu_lock);
@@ -393,6 +394,7 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt,
        INIT_RADIX_TREE(&vgpu->page_track_tree, GFP_KERNEL);
        idr_init(&vgpu->object_idr);
        intel_vgpu_init_cfg_space(vgpu, param->primary);
+       vgpu->d3_entered = false;
 
        ret = intel_vgpu_init_mmio(vgpu);
        if (ret)
@@ -557,10 +559,15 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
        /* full GPU reset or device model level reset */
        if (engine_mask == ALL_ENGINES || dmlr) {
                intel_vgpu_select_submission_ops(vgpu, ALL_ENGINES, 0);
-               intel_vgpu_invalidate_ppgtt(vgpu);
+               if (engine_mask == ALL_ENGINES)
+                       intel_vgpu_invalidate_ppgtt(vgpu);
                /*fence will not be reset during virtual reset */
                if (dmlr) {
-                       intel_vgpu_reset_gtt(vgpu);
+                       if(!vgpu->d3_entered) {
+                               intel_vgpu_invalidate_ppgtt(vgpu);
+                               intel_vgpu_destroy_all_ppgtt_mm(vgpu);
+                       }
+                       intel_vgpu_reset_ggtt(vgpu, true);
                        intel_vgpu_reset_resource(vgpu);
                }
 
@@ -572,7 +579,14 @@ void intel_gvt_reset_vgpu_locked(struct intel_vgpu *vgpu, bool dmlr,
                        intel_vgpu_reset_cfg_space(vgpu);
                        /* only reset the failsafe mode when dmlr reset */
                        vgpu->failsafe = false;
-                       vgpu->pv_notified = false;
+                       /*
+                        * PCI_D0 is set before dmlr, so reset d3_entered here
+                        * after done using.
+                        */
+                       if(vgpu->d3_entered)
+                               vgpu->d3_entered = false;
+                       else
+                               vgpu->pv_notified = false;
                }
        }
 
index 372354d..5ac4a99 100644 (file)
@@ -1204,6 +1204,12 @@ static u32 *copy_batch(struct drm_i915_gem_object *dst_obj,
        return dst;
 }
 
+static inline bool cmd_desc_is(const struct drm_i915_cmd_descriptor * const desc,
+                              const u32 cmd)
+{
+       return desc->cmd.value == (cmd & desc->cmd.mask);
+}
+
 static bool check_cmd(const struct intel_engine_cs *engine,
                      const struct drm_i915_cmd_descriptor *desc,
                      const u32 *cmd, u32 length)
@@ -1242,19 +1248,19 @@ static bool check_cmd(const struct intel_engine_cs *engine,
                         * allowed mask/value pair given in the whitelist entry.
                         */
                        if (reg->mask) {
-                               if (desc->cmd.value == MI_LOAD_REGISTER_MEM) {
+                               if (cmd_desc_is(desc, MI_LOAD_REGISTER_MEM)) {
                                        DRM_DEBUG("CMD: Rejected LRM to masked register 0x%08X\n",
                                                  reg_addr);
                                        return false;
                                }
 
-                               if (desc->cmd.value == MI_LOAD_REGISTER_REG) {
+                               if (cmd_desc_is(desc, MI_LOAD_REGISTER_REG)) {
                                        DRM_DEBUG("CMD: Rejected LRR to masked register 0x%08X\n",
                                                  reg_addr);
                                        return false;
                                }
 
-                               if (desc->cmd.value == MI_LOAD_REGISTER_IMM(1) &&
+                               if (cmd_desc_is(desc, MI_LOAD_REGISTER_IMM(1)) &&
                                    (offset + 2 > length ||
                                     (cmd[offset + 1] & reg->mask) != reg->value)) {
                                        DRM_DEBUG("CMD: Rejected LRI to masked register 0x%08X\n",
@@ -1478,7 +1484,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,
                        break;
                }
 
-               if (desc->cmd.value == MI_BATCH_BUFFER_START) {
+               if (cmd_desc_is(desc, MI_BATCH_BUFFER_START)) {
                        ret = check_bbstart(cmd, offset, length, batch_length,
                                            batch_addr, shadow_addr,
                                            jump_whitelist);
index 6a3a2ce..3e6cbb0 100644 (file)
@@ -1159,7 +1159,7 @@ static void engine_record_registers(struct intel_engine_coredump *ee)
                        switch (engine->id) {
                        default:
                                MISSING_CASE(engine->id);
-                               /* fall through */
+                               fallthrough;
                        case RCS0:
                                mmio = RENDER_HWS_PGA_GEN7;
                                break;
index 28bc5f1..69c0fa2 100644 (file)
@@ -445,8 +445,6 @@ static void i915_pmu_event_destroy(struct perf_event *event)
                container_of(event->pmu, typeof(*i915), pmu.base);
 
        drm_WARN_ON(&i915->drm, event->parent);
-
-       module_put(THIS_MODULE);
 }
 
 static int
@@ -476,7 +474,7 @@ config_status(struct drm_i915_private *i915, u64 config)
                if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
                        /* Requires a mutex for sampling! */
                        return -ENODEV;
-               /* Fall-through. */
+               fallthrough;
        case I915_PMU_REQUESTED_FREQUENCY:
                if (INTEL_GEN(i915) < 6)
                        return -ENODEV;
@@ -538,10 +536,8 @@ static int i915_pmu_event_init(struct perf_event *event)
        if (ret)
                return ret;
 
-       if (!event->parent) {
-               __module_get(THIS_MODULE);
+       if (!event->parent)
                event->destroy = i915_pmu_event_destroy;
-       }
 
        return 0;
 }
@@ -1130,6 +1126,7 @@ void i915_pmu_register(struct drm_i915_private *i915)
        if (!pmu->base.attr_groups)
                goto err_attr;
 
+       pmu->base.module        = THIS_MODULE;
        pmu->base.task_ctx_nr   = perf_invalid_context;
        pmu->base.event_init    = i915_pmu_event_init;
        pmu->base.add           = i915_pmu_event_add;
index 939a6ca..632b912 100644 (file)
@@ -8,8 +8,6 @@
 #include "../i915_selftest.h"
 #include "i915_random.h"
 
-#define SZ_8G (1ULL << 33)
-
 static void __igt_dump_block(struct i915_buddy_mm *mm,
                             struct i915_buddy_block *block,
                             bool buddy)
@@ -281,18 +279,22 @@ static int igt_check_mm(struct i915_buddy_mm *mm)
 static void igt_mm_config(u64 *size, u64 *chunk_size)
 {
        I915_RND_STATE(prng);
-       u64 s, ms;
+       u32 s, ms;
 
        /* Nothing fancy, just try to get an interesting bit pattern */
 
        prandom_seed_state(&prng, i915_selftest.random_seed);
 
-       s = i915_prandom_u64_state(&prng) & (SZ_8G - 1);
-       ms = BIT_ULL(12 + (prandom_u32_state(&prng) % ilog2(s >> 12)));
-       s = max(s & -ms, ms);
+       /* Let size be a random number of pages up to 8 GB (2M pages) */
+       s = 1 + i915_prandom_u32_max_state((BIT(33 - 12)) - 1, &prng);
+       /* Let the chunk size be a random power of 2 less than size */
+       ms = BIT(i915_prandom_u32_max_state(ilog2(s), &prng));
+       /* Round size down to the chunk size */
+       s &= -ms;
 
-       *chunk_size = ms;
-       *size = s;
+       /* Convert from pages to bytes */
+       *chunk_size = (u64)ms << 12;
+       *size = (u64)s << 12;
 }
 
 static int igt_buddy_alloc_smoke(void *arg)
index b9810bf..f127e63 100644 (file)
@@ -78,6 +78,7 @@ static void mock_device_release(struct drm_device *dev)
        drm_mode_config_cleanup(&i915->drm);
 
 out:
+       i915_params_free(&i915->params);
        put_device(&i915->drm.pdev->dev);
        i915->drm.pdev = NULL;
 }
@@ -165,6 +166,8 @@ struct drm_i915_private *mock_gem_device(void)
        i915->drm.pdev = pdev;
        drmm_add_final_kfree(&i915->drm, i915);
 
+       i915_params_copy(&i915->params, &i915_modparams);
+
        intel_runtime_pm_init_early(&i915->runtime_pm);
 
        /* Using the global GTT may ask questions about KMS users, so prepare */
index 6776ebb..8a4235d 100644 (file)
@@ -447,7 +447,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
                if (fb->pitches[1] != fb->pitches[2])
                        return -EINVAL;
 
-               /* fall-through */
+               fallthrough;
        case DRM_FORMAT_NV12:
        case DRM_FORMAT_NV16:
                ubo = drm_plane_state_to_ubo(state);
index ada990a..b707416 100644 (file)
@@ -673,7 +673,7 @@ static void ingenic_drm_unbind_all(void *d)
        component_unbind_all(priv->dev, &priv->drm);
 }
 
-static int ingenic_drm_bind(struct device *dev)
+static int ingenic_drm_bind(struct device *dev, bool has_components)
 {
        struct platform_device *pdev = to_platform_device(dev);
        const struct jz_soc_info *soc_info;
@@ -808,7 +808,7 @@ static int ingenic_drm_bind(struct device *dev)
                        return ret;
                }
 
-               if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU)) {
+               if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && has_components) {
                        ret = component_bind_all(dev, drm);
                        if (ret) {
                                if (ret != -EPROBE_DEFER)
@@ -939,6 +939,11 @@ err_pixclk_disable:
        return ret;
 }
 
+static int ingenic_drm_bind_with_components(struct device *dev)
+{
+       return ingenic_drm_bind(dev, true);
+}
+
 static int compare_of(struct device *dev, void *data)
 {
        return dev->of_node == data;
@@ -957,7 +962,7 @@ static void ingenic_drm_unbind(struct device *dev)
 }
 
 static const struct component_master_ops ingenic_master_ops = {
-       .bind = ingenic_drm_bind,
+       .bind = ingenic_drm_bind_with_components,
        .unbind = ingenic_drm_unbind,
 };
 
@@ -968,16 +973,15 @@ static int ingenic_drm_probe(struct platform_device *pdev)
        struct device_node *np;
 
        if (!IS_ENABLED(CONFIG_DRM_INGENIC_IPU))
-               return ingenic_drm_bind(dev);
+               return ingenic_drm_bind(dev, false);
 
        /* IPU is at port address 8 */
        np = of_graph_get_remote_node(dev->of_node, 8, 0);
-       if (!np) {
-               dev_err(dev, "Unable to get IPU node\n");
-               return -EINVAL;
-       }
+       if (!np)
+               return ingenic_drm_bind(dev, false);
 
        drm_of_component_match_add(dev, &match, compare_of, np);
+       of_node_put(np);
 
        return component_master_add_with_match(dev, &ingenic_master_ops, match);
 }
index f12e027..ffc6b58 100644 (file)
@@ -205,7 +205,7 @@ static int meson_g12a_afbcd_pixel_fmt(u64 modifier, uint32_t format)
                /* YTR is forbidden for non XBGR formats */
                if (modifier & AFBC_FORMAT_MOD_YTR)
                        return -EINVAL;
-       /* fall through */
+               fallthrough;
        case DRM_FORMAT_XBGR8888:
        case DRM_FORMAT_ABGR8888:
                return MAFBC_FMT_RGBA8888;
index a8bcc70..1ffbbec 100644 (file)
@@ -654,7 +654,7 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,
                         priv->viu.vd1_addr2,
                         priv->viu.vd1_stride2,
                         priv->viu.vd1_height2);
-       /* fallthrough */
+               fallthrough;
        case 2:
                gem = drm_fb_cma_get_gem_obj(fb, 1);
                priv->viu.vd1_addr1 = gem->paddr + fb->offsets[1];
@@ -666,7 +666,7 @@ static void meson_overlay_atomic_update(struct drm_plane *plane,
                         priv->viu.vd1_addr1,
                         priv->viu.vd1_stride1,
                         priv->viu.vd1_height1);
-       /* fallthrough */
+               fallthrough;
        case 1:
                gem = drm_fb_cma_get_gem_obj(fb, 0);
                priv->viu.vd1_addr0 = gem->paddr + fb->offsets[0];
index 6021f8d..48fa49f 100644 (file)
@@ -164,6 +164,11 @@ static int a2xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                return ret;
 
+       gpu_write(gpu, REG_AXXX_CP_RB_CNTL,
+               MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE);
+
+       gpu_write(gpu, REG_AXXX_CP_RB_BASE, lower_32_bits(gpu->rb[0]->iova));
+
        /* NOTE: PM4/micro-engine firmware registers look to be the same
         * for a2xx and a3xx.. we could possibly push that part down to
         * adreno_gpu base class.  Or push both PM4 and PFP but
index 0a5ea9f..f647114 100644 (file)
@@ -211,6 +211,16 @@ static int a3xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                return ret;
 
+       /*
+        * Use the default ringbuffer size and block size but disable the RPTR
+        * shadow
+        */
+       gpu_write(gpu, REG_AXXX_CP_RB_CNTL,
+               MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE);
+
+       /* Set the ringbuffer address */
+       gpu_write(gpu, REG_AXXX_CP_RB_BASE, lower_32_bits(gpu->rb[0]->iova));
+
        /* setup access protection: */
        gpu_write(gpu, REG_A3XX_CP_PROTECT_CTRL, 0x00000007);
 
index b9b26b2..9547536 100644 (file)
@@ -267,6 +267,16 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                return ret;
 
+       /*
+        * Use the default ringbuffer size and block size but disable the RPTR
+        * shadow
+        */
+       gpu_write(gpu, REG_A4XX_CP_RB_CNTL,
+               MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE);
+
+       /* Set the ringbuffer address */
+       gpu_write(gpu, REG_A4XX_CP_RB_BASE, lower_32_bits(gpu->rb[0]->iova));
+
        /* Load PM4: */
        ptr = (uint32_t *)(adreno_gpu->fw[ADRENO_FW_PM4]->data);
        len = adreno_gpu->fw[ADRENO_FW_PM4]->size / 4;
index 9e63a19..91726da 100644 (file)
@@ -59,7 +59,7 @@ static void a5xx_submit_in_rb(struct msm_gpu *gpu, struct msm_gem_submit *submit
                case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
                        if (priv->lastctx == ctx)
                                break;
-                       /* fall-thru */
+                       fallthrough;
                case MSM_SUBMIT_CMD_BUF:
                        /* copy commands into RB: */
                        obj = submit->bos[submit->cmd[i].idx].obj;
@@ -150,7 +150,7 @@ static void a5xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
                case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
                        if (priv->lastctx == ctx)
                                break;
-                       /* fall-thru */
+                       fallthrough;
                case MSM_SUBMIT_CMD_BUF:
                        OUT_PKT7(ring, CP_INDIRECT_BUFFER_PFE, 3);
                        OUT_RING(ring, lower_32_bits(submit->cmd[i].iova));
@@ -703,8 +703,6 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                return ret;
 
-       a5xx_preempt_hw_init(gpu);
-
        if (!adreno_is_a510(adreno_gpu))
                a5xx_gpmu_ucode_init(gpu);
 
@@ -712,6 +710,15 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                return ret;
 
+       /* Set the ringbuffer address */
+       gpu_write64(gpu, REG_A5XX_CP_RB_BASE, REG_A5XX_CP_RB_BASE_HI,
+               gpu->rb[0]->iova);
+
+       gpu_write(gpu, REG_A5XX_CP_RB_CNTL,
+               MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE);
+
+       a5xx_preempt_hw_init(gpu);
+
        /* Disable the interrupts through the initial bringup stage */
        gpu_write(gpu, REG_A5XX_RBBM_INT_0_MASK, A5XX_INT_MASK);
 
@@ -1511,7 +1518,8 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev)
 
        check_speed_bin(&pdev->dev);
 
-       ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 4);
+       /* Restricting nr_rings to 1 to temporarily disable preemption */
+       ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1);
        if (ret) {
                a5xx_destroy(&(a5xx_gpu->base.base));
                return ERR_PTR(ret);
index 54868d4..1e5b1a1 100644 (file)
@@ -31,6 +31,7 @@ struct a5xx_gpu {
        struct msm_ringbuffer *next_ring;
 
        struct drm_gem_object *preempt_bo[MSM_GPU_MAX_RINGS];
+       struct drm_gem_object *preempt_counters_bo[MSM_GPU_MAX_RINGS];
        struct a5xx_preempt_record *preempt[MSM_GPU_MAX_RINGS];
        uint64_t preempt_iova[MSM_GPU_MAX_RINGS];
 
index 9cf9353..9f3fe17 100644 (file)
@@ -226,19 +226,31 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,
        struct adreno_gpu *adreno_gpu = &a5xx_gpu->base;
        struct msm_gpu *gpu = &adreno_gpu->base;
        struct a5xx_preempt_record *ptr;
-       struct drm_gem_object *bo = NULL;
-       u64 iova = 0;
+       void *counters;
+       struct drm_gem_object *bo = NULL, *counters_bo = NULL;
+       u64 iova = 0, counters_iova = 0;
 
        ptr = msm_gem_kernel_new(gpu->dev,
                A5XX_PREEMPT_RECORD_SIZE + A5XX_PREEMPT_COUNTER_SIZE,
-               MSM_BO_UNCACHED, gpu->aspace, &bo, &iova);
+               MSM_BO_UNCACHED | MSM_BO_MAP_PRIV, gpu->aspace, &bo, &iova);
 
        if (IS_ERR(ptr))
                return PTR_ERR(ptr);
 
+       /* The buffer to store counters needs to be unprivileged */
+       counters = msm_gem_kernel_new(gpu->dev,
+               A5XX_PREEMPT_COUNTER_SIZE,
+               MSM_BO_UNCACHED, gpu->aspace, &counters_bo, &counters_iova);
+       if (IS_ERR(counters)) {
+               msm_gem_kernel_put(bo, gpu->aspace, true);
+               return PTR_ERR(counters);
+       }
+
        msm_gem_object_set_name(bo, "preempt");
+       msm_gem_object_set_name(counters_bo, "preempt_counters");
 
        a5xx_gpu->preempt_bo[ring->id] = bo;
+       a5xx_gpu->preempt_counters_bo[ring->id] = counters_bo;
        a5xx_gpu->preempt_iova[ring->id] = iova;
        a5xx_gpu->preempt[ring->id] = ptr;
 
@@ -249,7 +261,7 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,
        ptr->data = 0;
        ptr->cntl = MSM_GPU_RB_CNTL_DEFAULT;
        ptr->rptr_addr = rbmemptr(ring, rptr);
-       ptr->counter = iova + A5XX_PREEMPT_RECORD_SIZE;
+       ptr->counter = counters_iova;
 
        return 0;
 }
@@ -260,8 +272,11 @@ void a5xx_preempt_fini(struct msm_gpu *gpu)
        struct a5xx_gpu *a5xx_gpu = to_a5xx_gpu(adreno_gpu);
        int i;
 
-       for (i = 0; i < gpu->nr_rings; i++)
+       for (i = 0; i < gpu->nr_rings; i++) {
                msm_gem_kernel_put(a5xx_gpu->preempt_bo[i], gpu->aspace, true);
+               msm_gem_kernel_put(a5xx_gpu->preempt_counters_bo[i],
+                       gpu->aspace, true);
+       }
 }
 
 void a5xx_preempt_init(struct msm_gpu *gpu)
index b67b38c..e1c7bcd 100644 (file)
@@ -133,7 +133,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
 
        if (!gmu->legacy) {
                a6xx_hfi_set_freq(gmu, perf_index);
-               icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+               dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
                pm_runtime_put(gmu->dev);
                return;
        }
@@ -157,11 +157,7 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct dev_pm_opp *opp)
        if (ret)
                dev_err(gmu->dev, "GMU set GPU frequency error: %d\n", ret);
 
-       /*
-        * Eventually we will want to scale the path vote with the frequency but
-        * for now leave it at max so that the performance is nominal.
-        */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+       dev_pm_opp_set_bw(&gpu->pdev->dev, opp);
        pm_runtime_put(gmu->dev);
 }
 
@@ -204,6 +200,16 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)
 {
        int ret;
        u32 val;
+       u32 mask, reset_val;
+
+       val = gmu_read(gmu, REG_A6XX_GMU_CM3_DTCM_START + 0xff8);
+       if (val <= 0x20010004) {
+               mask = 0xffffffff;
+               reset_val = 0xbabeface;
+       } else {
+               mask = 0x1ff;
+               reset_val = 0x100;
+       }
 
        gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 1);
 
@@ -215,7 +221,7 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu)
        gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 0);
 
        ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_CM3_FW_INIT_RESULT, val,
-               val == 0xbabeface, 100, 10000);
+               (val & mask) == reset_val, 100, 10000);
 
        if (ret)
                DRM_DEV_ERROR(gmu->dev, "GMU firmware initialization timed out\n");
@@ -602,7 +608,7 @@ static void a6xx_gmu_power_config(struct a6xx_gmu *gmu)
                gmu_rmw(gmu, REG_A6XX_GMU_PWR_COL_INTER_FRAME_CTRL, 0,
                        A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_IFPC_ENABLE |
                        A6XX_GMU_PWR_COL_INTER_FRAME_CTRL_HM_POWER_COLLAPSE_ENABLE);
-               /* Fall through */
+               fallthrough;
        case GMU_IDLE_STATE_SPTP:
                gmu_write(gmu, REG_A6XX_GMU_PWR_COL_SPTPRAC_HYST,
                        GMU_PWR_COL_HYST);
@@ -845,10 +851,24 @@ static void a6xx_gmu_set_initial_freq(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
        if (IS_ERR_OR_NULL(gpu_opp))
                return;
 
+       gmu->freq = 0; /* so a6xx_gmu_set_freq() doesn't exit early */
        a6xx_gmu_set_freq(gpu, gpu_opp);
        dev_pm_opp_put(gpu_opp);
 }
 
+static void a6xx_gmu_set_initial_bw(struct msm_gpu *gpu, struct a6xx_gmu *gmu)
+{
+       struct dev_pm_opp *gpu_opp;
+       unsigned long gpu_freq = gmu->gpu_freqs[gmu->current_perf_index];
+
+       gpu_opp = dev_pm_opp_find_freq_exact(&gpu->pdev->dev, gpu_freq, true);
+       if (IS_ERR_OR_NULL(gpu_opp))
+               return;
+
+       dev_pm_opp_set_bw(&gpu->pdev->dev, gpu_opp);
+       dev_pm_opp_put(gpu_opp);
+}
+
 int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
 {
        struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
@@ -882,7 +902,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)
        }
 
        /* Set the bus quota to a reasonable value for boot */
-       icc_set_bw(gpu->icc_path, 0, MBps_to_icc(3072));
+       a6xx_gmu_set_initial_bw(gpu, gmu);
 
        /* Enable the GMU interrupt */
        gmu_write(gmu, REG_A6XX_GMU_AO_HOST_INTERRUPT_CLR, ~0);
@@ -1051,7 +1071,7 @@ int a6xx_gmu_stop(struct a6xx_gpu *a6xx_gpu)
                a6xx_gmu_shutdown(gmu);
 
        /* Remove the bus vote */
-       icc_set_bw(gpu->icc_path, 0, 0);
+       dev_pm_opp_set_bw(&gpu->pdev->dev, NULL);
 
        /*
         * Make sure the GX domain is off before turning off the GMU (CX)
index c5a3e4d..66a95e2 100644 (file)
@@ -117,7 +117,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
                case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
                        if (priv->lastctx == ctx)
                                break;
-                       /* fall-thru */
+                       fallthrough;
                case MSM_SUBMIT_CMD_BUF:
                        OUT_PKT7(ring, CP_INDIRECT_BUFFER_PFE, 3);
                        OUT_RING(ring, lower_32_bits(submit->cmd[i].iova));
@@ -678,7 +678,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
                        A6XX_PROTECT_RDONLY(0x980, 0x4));
        gpu_write(gpu, REG_A6XX_CP_PROTECT(25), A6XX_PROTECT_RW(0xa630, 0x0));
 
-       if (adreno_is_a650(adreno_gpu)) {
+       /* Enable expanded apriv for targets that support it */
+       if (gpu->hw_apriv) {
                gpu_write(gpu, REG_A6XX_CP_APRIV_CNTL,
                        (1 << 6) | (1 << 5) | (1 << 3) | (1 << 2) | (1 << 1));
        }
@@ -694,6 +695,13 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
        if (ret)
                goto out;
 
+       /* Set the ringbuffer address */
+       gpu_write64(gpu, REG_A6XX_CP_RB_BASE, REG_A6XX_CP_RB_BASE_HI,
+               gpu->rb[0]->iova);
+
+       gpu_write(gpu, REG_A6XX_CP_RB_CNTL,
+               MSM_GPU_RB_CNTL_DEFAULT | AXXX_CP_RB_CNTL_NO_UPDATE);
+
        /* Always come up on rb 0 */
        a6xx_gpu->cur_ring = gpu->rb[0];
 
@@ -1056,6 +1064,9 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)
        adreno_gpu->registers = NULL;
        adreno_gpu->reg_offsets = a6xx_register_offsets;
 
+       if (adreno_is_a650(adreno_gpu))
+               adreno_gpu->base.hw_apriv = true;
+
        ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1);
        if (ret) {
                a6xx_destroy(&(a6xx_gpu->base.base));
index 959656a..b12f5b4 100644 (file)
@@ -938,7 +938,8 @@ struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu)
                msm_gem_kernel_put(dumper.bo, gpu->aspace, true);
        }
 
-       a6xx_get_debugbus(gpu, a6xx_state);
+       if (snapshot_debugbus)
+               a6xx_get_debugbus(gpu, a6xx_state);
 
        return  &a6xx_state->base;
 }
index 846fd5b..2fb58b7 100644 (file)
@@ -372,7 +372,7 @@ static const struct a6xx_indexed_registers {
        u32 data;
        u32 count;
 } a6xx_indexed_reglist[] = {
-       { "CP_SEQ_STAT", REG_A6XX_CP_SQE_STAT_ADDR,
+       { "CP_SQE_STAT", REG_A6XX_CP_SQE_STAT_ADDR,
                REG_A6XX_CP_SQE_STAT_DATA, 0x33 },
        { "CP_DRAW_STATE", REG_A6XX_CP_DRAW_STATE_ADDR,
                REG_A6XX_CP_DRAW_STATE_DATA, 0x100 },
index 4e84f3c..9eeb46b 100644 (file)
@@ -14,6 +14,10 @@ bool hang_debug = false;
 MODULE_PARM_DESC(hang_debug, "Dump registers when hang is detected (can be slow!)");
 module_param_named(hang_debug, hang_debug, bool, 0600);
 
+bool snapshot_debugbus = false;
+MODULE_PARM_DESC(snapshot_debugbus, "Include debugbus sections in GPU devcoredump (if not fused off)");
+module_param_named(snapshot_debugbus, snapshot_debugbus, bool, 0600);
+
 static const struct adreno_info gpulist[] = {
        {
                .rev   = ADRENO_REV(2, 0, 0, 0),
index e23641a..862dd35 100644 (file)
@@ -396,30 +396,10 @@ int adreno_hw_init(struct msm_gpu *gpu)
                ring->next = ring->start;
 
                /* reset completed fence seqno: */
-               ring->memptrs->fence = ring->seqno;
+               ring->memptrs->fence = ring->fctx->completed_fence;
                ring->memptrs->rptr = 0;
        }
 
-       /*
-        * Setup REG_CP_RB_CNTL.  The same value is used across targets (with
-        * the excpetion of A430 that disables the RPTR shadow) - the cacluation
-        * for the ringbuffer size and block size is moved to msm_gpu.h for the
-        * pre-processor to deal with and the A430 variant is ORed in here
-        */
-       adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_CNTL,
-               MSM_GPU_RB_CNTL_DEFAULT |
-               (adreno_is_a430(adreno_gpu) ? AXXX_CP_RB_CNTL_NO_UPDATE : 0));
-
-       /* Setup ringbuffer address - use ringbuffer[0] for GPU init */
-       adreno_gpu_write64(adreno_gpu, REG_ADRENO_CP_RB_BASE,
-               REG_ADRENO_CP_RB_BASE_HI, gpu->rb[0]->iova);
-
-       if (!adreno_is_a430(adreno_gpu)) {
-               adreno_gpu_write64(adreno_gpu, REG_ADRENO_CP_RB_RPTR_ADDR,
-                       REG_ADRENO_CP_RB_RPTR_ADDR_HI,
-                       rbmemptr(gpu->rb[0], rptr));
-       }
-
        return 0;
 }
 
@@ -427,11 +407,8 @@ int adreno_hw_init(struct msm_gpu *gpu)
 static uint32_t get_rptr(struct adreno_gpu *adreno_gpu,
                struct msm_ringbuffer *ring)
 {
-       if (adreno_is_a430(adreno_gpu))
-               return ring->memptrs->rptr = adreno_gpu_read(
-                       adreno_gpu, REG_ADRENO_CP_RB_RPTR);
-       else
-               return ring->memptrs->rptr;
+       return ring->memptrs->rptr = adreno_gpu_read(
+               adreno_gpu, REG_ADRENO_CP_RB_RPTR);
 }
 
 struct msm_ringbuffer *adreno_active_ring(struct msm_gpu *gpu)
@@ -474,7 +451,7 @@ void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
                        /* ignore if there has not been a ctx switch: */
                        if (priv->lastctx == ctx)
                                break;
-                       /* fall-thru */
+                       fallthrough;
                case MSM_SUBMIT_CMD_BUF:
                        OUT_PKT3(ring, adreno_is_a4xx(adreno_gpu) ?
                                CP_INDIRECT_BUFFER_PFE : CP_INDIRECT_BUFFER_PFD, 2);
index 99bb468..e55abae 100644 (file)
@@ -21,6 +21,8 @@
 #define REG_SKIP ~0
 #define REG_ADRENO_SKIP(_offset) [_offset] = REG_SKIP
 
+extern bool snapshot_debugbus;
+
 /**
  * adreno_regs: List of registers that are used in across all
  * 3D devices. Each device type has different offset value for the same
index f272a8d..c2729f7 100644 (file)
@@ -827,7 +827,7 @@ static void dpu_crtc_enable(struct drm_crtc *crtc,
 {
        struct dpu_crtc *dpu_crtc;
        struct drm_encoder *encoder;
-       bool request_bandwidth;
+       bool request_bandwidth = false;
 
        if (!crtc) {
                DPU_ERROR("invalid crtc\n");
index a97f6d2..bd6def4 100644 (file)
@@ -599,7 +599,10 @@ static int dpu_encoder_virt_atomic_check(
        dpu_kms = to_dpu_kms(priv->kms);
        mode = &crtc_state->mode;
        adj_mode = &crtc_state->adjusted_mode;
-       global_state = dpu_kms_get_existing_global_state(dpu_kms);
+       global_state = dpu_kms_get_global_state(crtc_state->state);
+       if (IS_ERR(global_state))
+               return PTR_ERR(global_state);
+
        trace_dpu_enc_atomic_check(DRMID(drm_enc));
 
        /* perform atomic check on the first physical encoder (master) */
@@ -625,12 +628,15 @@ static int dpu_encoder_virt_atomic_check(
        /* Reserve dynamic resources now. */
        if (!ret) {
                /*
-                * Avoid reserving resources when mode set is pending. Topology
-                * info may not be available to complete reservation.
+                * Release and Allocate resources on every modeset
+                * Dont allocate when active is false.
                 */
                if (drm_atomic_crtc_needs_modeset(crtc_state)) {
-                       ret = dpu_rm_reserve(&dpu_kms->rm, global_state,
-                                       drm_enc, crtc_state, topology);
+                       dpu_rm_release(global_state, drm_enc);
+
+                       if (!crtc_state->active_changed || crtc_state->active)
+                               ret = dpu_rm_reserve(&dpu_kms->rm, global_state,
+                                               drm_enc, crtc_state, topology);
                }
        }
 
@@ -1181,7 +1187,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
        struct dpu_encoder_virt *dpu_enc = NULL;
        struct msm_drm_private *priv;
        struct dpu_kms *dpu_kms;
-       struct dpu_global_state *global_state;
        int i = 0;
 
        if (!drm_enc) {
@@ -1200,7 +1205,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
 
        priv = drm_enc->dev->dev_private;
        dpu_kms = to_dpu_kms(priv->kms);
-       global_state = dpu_kms_get_existing_global_state(dpu_kms);
 
        trace_dpu_enc_disable(DRMID(drm_enc));
 
@@ -1230,8 +1234,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc)
 
        DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n");
 
-       dpu_rm_release(global_state, drm_enc);
-
        mutex_unlock(&dpu_enc->enc_lock);
 }
 
index 33f6c56..29e373d 100644 (file)
@@ -866,9 +866,9 @@ static int dpu_plane_atomic_check(struct drm_plane *plane,
                crtc_state = drm_atomic_get_new_crtc_state(state->state,
                                                           state->crtc);
 
-       min_scale = FRAC_16_16(1, pdpu->pipe_sblk->maxdwnscale);
+       min_scale = FRAC_16_16(1, pdpu->pipe_sblk->maxupscale);
        ret = drm_atomic_helper_check_plane_state(state, crtc_state, min_scale,
-                                         pdpu->pipe_sblk->maxupscale << 16,
+                                         pdpu->pipe_sblk->maxdwnscale << 16,
                                          true, true);
        if (ret) {
                DPU_DEBUG_PLANE(pdpu, "Check plane state failed (%d)\n", ret);
index 5ccfad7..561bfa4 100644 (file)
@@ -27,6 +27,34 @@ int msm_atomic_prepare_fb(struct drm_plane *plane,
        return msm_framebuffer_prepare(new_state->fb, kms->aspace);
 }
 
+/*
+ * Helpers to control vblanks while we flush.. basically just to ensure
+ * that vblank accounting is switched on, so we get valid seqn/timestamp
+ * on pageflip events (if requested)
+ */
+
+static void vblank_get(struct msm_kms *kms, unsigned crtc_mask)
+{
+       struct drm_crtc *crtc;
+
+       for_each_crtc_mask(kms->dev, crtc, crtc_mask) {
+               if (!crtc->state->active)
+                       continue;
+               drm_crtc_vblank_get(crtc);
+       }
+}
+
+static void vblank_put(struct msm_kms *kms, unsigned crtc_mask)
+{
+       struct drm_crtc *crtc;
+
+       for_each_crtc_mask(kms->dev, crtc, crtc_mask) {
+               if (!crtc->state->active)
+                       continue;
+               drm_crtc_vblank_put(crtc);
+       }
+}
+
 static void msm_atomic_async_commit(struct msm_kms *kms, int crtc_idx)
 {
        unsigned crtc_mask = BIT(crtc_idx);
@@ -44,6 +72,8 @@ static void msm_atomic_async_commit(struct msm_kms *kms, int crtc_idx)
 
        kms->funcs->enable_commit(kms);
 
+       vblank_get(kms, crtc_mask);
+
        /*
         * Flush hardware updates:
         */
@@ -58,6 +88,8 @@ static void msm_atomic_async_commit(struct msm_kms *kms, int crtc_idx)
        kms->funcs->wait_flush(kms, crtc_mask);
        trace_msm_atomic_wait_flush_finish(crtc_mask);
 
+       vblank_put(kms, crtc_mask);
+
        mutex_lock(&kms->commit_lock);
        kms->funcs->complete_commit(kms, crtc_mask);
        mutex_unlock(&kms->commit_lock);
@@ -221,6 +253,8 @@ void msm_atomic_commit_tail(struct drm_atomic_state *state)
         */
        kms->pending_crtc_mask &= ~crtc_mask;
 
+       vblank_get(kms, crtc_mask);
+
        /*
         * Flush hardware updates:
         */
@@ -235,6 +269,8 @@ void msm_atomic_commit_tail(struct drm_atomic_state *state)
        kms->funcs->wait_flush(kms, crtc_mask);
        trace_msm_atomic_wait_flush_finish(crtc_mask);
 
+       vblank_put(kms, crtc_mask);
+
        mutex_lock(&kms->commit_lock);
        kms->funcs->complete_commit(kms, crtc_mask);
        mutex_unlock(&kms->commit_lock);
index 7d641c7..7933384 100644 (file)
@@ -1320,6 +1320,13 @@ static int msm_pdev_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void msm_pdev_shutdown(struct platform_device *pdev)
+{
+       struct drm_device *drm = platform_get_drvdata(pdev);
+
+       drm_atomic_helper_shutdown(drm);
+}
+
 static const struct of_device_id dt_match[] = {
        { .compatible = "qcom,mdp4", .data = (void *)KMS_MDP4 },
        { .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
@@ -1332,6 +1339,7 @@ MODULE_DEVICE_TABLE(of, dt_match);
 static struct platform_driver msm_platform_driver = {
        .probe      = msm_pdev_probe,
        .remove     = msm_pdev_remove,
+       .shutdown   = msm_pdev_shutdown,
        .driver     = {
                .name   = "msm",
                .of_match_table = dt_match,
index d564547..57ddc94 100644 (file)
@@ -908,7 +908,7 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,
 
        memptrs = msm_gem_kernel_new(drm,
                sizeof(struct msm_rbmemptrs) * nr_rings,
-               MSM_BO_UNCACHED, gpu->aspace, &gpu->memptrs_bo,
+               check_apriv(gpu, MSM_BO_UNCACHED), gpu->aspace, &gpu->memptrs_bo,
                &memptrs_iova);
 
        if (IS_ERR(memptrs)) {
index 0db117a..37cffac 100644 (file)
@@ -15,6 +15,7 @@
 #include "msm_drv.h"
 #include "msm_fence.h"
 #include "msm_ringbuffer.h"
+#include "msm_gem.h"
 
 struct msm_gem_submit;
 struct msm_gpu_perfcntr;
@@ -139,6 +140,8 @@ struct msm_gpu {
        } devfreq;
 
        struct msm_gpu_state *crashstate;
+       /* True if the hardware supports expanded apriv (a650 and newer) */
+       bool hw_apriv;
 };
 
 /* It turns out that all targets use the same ringbuffer size */
@@ -327,4 +330,12 @@ static inline void msm_gpu_crashstate_put(struct msm_gpu *gpu)
        mutex_unlock(&gpu->dev->struct_mutex);
 }
 
+/*
+ * Simple macro to semi-cleanly add the MAP_PRIV flag for targets that can
+ * support expanded privileges
+ */
+#define check_apriv(gpu, flags) \
+       (((gpu)->hw_apriv ? MSM_BO_MAP_PRIV : 0) | (flags))
+
+
 #endif /* __MSM_GPU_H__ */
index e397c44..935bf9b 100644 (file)
@@ -27,7 +27,8 @@ struct msm_ringbuffer *msm_ringbuffer_new(struct msm_gpu *gpu, int id,
        ring->id = id;
 
        ring->start = msm_gem_kernel_new(gpu->dev, MSM_GPU_RINGBUFFER_SZ,
-               MSM_BO_WC, gpu->aspace, &ring->bo, &ring->iova);
+               check_apriv(gpu, MSM_BO_WC | MSM_BO_GPU_READONLY),
+               gpu->aspace, &ring->bo, &ring->iova);
 
        if (IS_ERR(ring->start)) {
                ret = PTR_ERR(ring->start);
index ad1f09a..248edf6 100644 (file)
@@ -50,7 +50,10 @@ core507d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
                                        interlock[NV50_DISP_INTERLOCK_OVLY] |
                  NVDEF(NV507D, UPDATE, NOT_DRIVER_FRIENDLY, FALSE) |
                  NVDEF(NV507D, UPDATE, NOT_DRIVER_UNFRIENDLY, FALSE) |
-                 NVDEF(NV507D, UPDATE, INHIBIT_INTERRUPTS, FALSE));
+                 NVDEF(NV507D, UPDATE, INHIBIT_INTERRUPTS, FALSE),
+
+                               SET_NOTIFIER_CONTROL,
+                 NVDEF(NV507D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
 
        return PUSH_KICK(push);
 }
index 9afe9a8..814e5bd 100644 (file)
@@ -6,7 +6,7 @@
 #include "disp.h"
 #include "head.h"
 
-#include <nvif/push507c.h>
+#include <nvif/pushc37b.h>
 
 #include <nvhw/class/clc37d.h>
 
index e787487..1ed2420 100644 (file)
@@ -257,6 +257,12 @@ nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
        dmac->push->end = dmac->push->bgn;
        dmac->max = 0x1000/4 - 1;
 
+       /* EVO channels are affected by a HW bug where the last 12 DWORDs
+        * of the push buffer aren't able to be used safely.
+        */
+       if (disp->oclass < GV100_DISP)
+               dmac->max -= 12;
+
        args->pushbuf = nvif_handle(&dmac->_push.mem.object);
 
        ret = nv50_chan_create(device, disp, oclass, head, data, size,
index 889467f..7917bea 100644 (file)
@@ -20,6 +20,6 @@
         PUSH_ASSERT(!((o) & ~DRF_SMASK(NV507C_DMA_JUMP_OFFSET)), "offset"); \
        PUSH_DATA__((p), NVDEF(NV507C, DMA, OPCODE, JUMP) |                 \
                         NVVAL(NV507C, DMA, JUMP_OFFSET, (o) >> 2),         \
-                   "jump 0x%08x - %s", (u32)(o), __func__);                \
+                   " jump 0x%08x - %s", (u32)(o), __func__);               \
 } while(0)
 #endif
index e081793..bd12eae 100644 (file)
@@ -597,7 +597,7 @@ static void venc_bridge_mode_set(struct drm_bridge *bridge,
        switch (venc_mode) {
        default:
                WARN_ON_ONCE(1);
-               /* Fall-through */
+               fallthrough;
        case VENC_MODE_PAL:
                venc->config = &venc_config_pal_trm;
                break;
index 6d40914..328a4a7 100644 (file)
@@ -451,11 +451,12 @@ static void omap_crtc_atomic_enable(struct drm_crtc *crtc,
        if (omap_state->manually_updated)
                return;
 
-       spin_lock_irq(&crtc->dev->event_lock);
        drm_crtc_vblank_on(crtc);
+
        ret = drm_crtc_vblank_get(crtc);
        WARN_ON(ret != 0);
 
+       spin_lock_irq(&crtc->dev->event_lock);
        omap_crtc_arm_event(crtc);
        spin_unlock_irq(&crtc->dev->event_lock);
 }
index ba20c6f..886e995 100644 (file)
@@ -4856,7 +4856,7 @@ static void ci_request_link_speed_change_before_state_change(struct radeon_devic
                        pi->force_pcie_gen = RADEON_PCIE_GEN2;
                        if (current_link_speed == RADEON_PCIE_GEN2)
                                break;
-                       /* fall through */
+                       fallthrough;
                case RADEON_PCIE_GEN2:
                        if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
                                break;
index 3b7ead5..73f67bf 100644 (file)
@@ -820,7 +820,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                                          ((idx_value >> 21) & 0xF));
                                return -EINVAL;
                        }
-                       /* Fall through. */
+                       fallthrough;
                case 6:
                        track->cb[i].cpp = 4;
                        break;
@@ -971,7 +971,7 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
                                return -EINVAL;
                        }
                        /* The same rules apply as for DXT3/5. */
-                       /* Fall through. */
+                       fallthrough;
                case R300_TX_FORMAT_DXT3:
                case R300_TX_FORMAT_DXT5:
                        track->textures[i].cpp = 1;
index 1d4c04e..50b89b6 100644 (file)
@@ -115,7 +115,7 @@ void r420_pipes_init(struct radeon_device *rdev)
        default:
                /* force to 1 pipe */
                num_pipes = 1;
-               /* fall through */
+               fallthrough;
        case 1:
                tmp = (0 << 1);
                break;
index 49e8266..390a962 100644 (file)
@@ -487,7 +487,7 @@ static int r600_cs_track_validate_cb(struct radeon_cs_parser *p, int i)
                                return -EINVAL;
                        }
                }
-               /* fall through */
+               fallthrough;
        case V_0280A0_CLEAR_ENABLE:
        {
                uint32_t block_max = G_028100_CMASK_BLOCK_MAX(track->cb_color_mask[i]);
@@ -1535,7 +1535,7 @@ static int r600_check_texture_resource(struct radeon_cs_parser *p,  u32 idx,
                break;
        case V_038000_SQ_TEX_DIM_2D_ARRAY_MSAA:
                is_array = true;
-               /* fall through */
+               fallthrough;
        case V_038000_SQ_TEX_DIM_2D_MSAA:
                array_check.nsamples = 1 << llevel;
                llevel = 0;
index e0ae911..7b69d6d 100644 (file)
@@ -933,7 +933,7 @@ static void avivo_get_fb_ref_div(unsigned nom, unsigned den, unsigned post_div,
 
        /* get matching reference and feedback divider */
        *ref_div = min(max(den/post_div, 1u), ref_div_max);
-       *fb_div = DIV_ROUND_CLOSEST(nom * *ref_div * post_div, den);
+       *fb_div = max(nom * *ref_div * post_div / den, 1u);
 
        /* limit fb divider to its maximum */
        if (*fb_div > fb_div_max) {
index 1ad5c3b..57fb3eb 100644 (file)
@@ -454,7 +454,7 @@ static int radeon_uvd_validate_codec(struct radeon_cs_parser *p,
                if (p->rdev->family >= CHIP_PALM)
                        return 0;
 
-               /* fall through */
+               fallthrough;
        default:
                DRM_ERROR("UVD codec not supported by hardware %d!\n",
                          stream_type);
index a167e1c..d1c73e9 100644 (file)
@@ -5744,7 +5744,7 @@ static void si_request_link_speed_change_before_state_change(struct radeon_devic
                        si_pi->force_pcie_gen = RADEON_PCIE_GEN2;
                        if (current_link_speed == RADEON_PCIE_GEN2)
                                break;
-                       /* fall through */
+                       fallthrough;
                case RADEON_PCIE_GEN2:
                        if (radeon_acpi_pcie_performance_request(rdev, PCIE_PERF_REQ_PECI_GEN2, false) == 0)
                                break;
index f858d8d..8007211 100644 (file)
@@ -219,7 +219,7 @@ done:
                        WREG32(RS_DQ_RD_RET_CONF, 0x3f);
                        WREG32(MC_CONFIG, 0x1f);
 
-                       /* fall through */
+                       fallthrough;
                case CHIP_RV670:
                case CHIP_RV635:
 
index a2ac25c..e0d40ae 100644 (file)
@@ -306,7 +306,7 @@ static int savage_dispatch_dma_prim(drm_savage_private_t * dev_priv,
        case SAVAGE_PRIM_TRILIST_201:
                reorder = 1;
                prim = SAVAGE_PRIM_TRILIST;
-               /* fall through */
+               fallthrough;
        case SAVAGE_PRIM_TRILIST:
                if (n % 3 != 0) {
                        DRM_ERROR("wrong number of vertices %u in TRILIST\n",
@@ -444,7 +444,7 @@ static int savage_dispatch_vb_prim(drm_savage_private_t * dev_priv,
        case SAVAGE_PRIM_TRILIST_201:
                reorder = 1;
                prim = SAVAGE_PRIM_TRILIST;
-               /* fall through */
+               fallthrough;
        case SAVAGE_PRIM_TRILIST:
                if (n % 3 != 0) {
                        DRM_ERROR("wrong number of vertices %u in TRILIST\n",
@@ -566,7 +566,7 @@ static int savage_dispatch_dma_idx(drm_savage_private_t * dev_priv,
        case SAVAGE_PRIM_TRILIST_201:
                reorder = 1;
                prim = SAVAGE_PRIM_TRILIST;
-               /* fall through */
+               fallthrough;
        case SAVAGE_PRIM_TRILIST:
                if (n % 3 != 0) {
                        DRM_ERROR("wrong number of indices %u in TRILIST\n", n);
@@ -705,7 +705,7 @@ static int savage_dispatch_vb_idx(drm_savage_private_t * dev_priv,
        case SAVAGE_PRIM_TRILIST_201:
                reorder = 1;
                prim = SAVAGE_PRIM_TRILIST;
-               /* fall through */
+               fallthrough;
        case SAVAGE_PRIM_TRILIST:
                if (n % 3 != 0) {
                        DRM_ERROR("wrong number of indices %u in TRILIST\n", n);
@@ -1066,7 +1066,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
                                ret = -EINVAL;
                                goto done;
                        }
-                       /* fall through */
+                       fallthrough;
                case SAVAGE_CMD_DMA_PRIM:
                case SAVAGE_CMD_VB_PRIM:
                        if (!first_draw_cmd)
index 008f079..38a5587 100644 (file)
@@ -850,13 +850,13 @@ static int hdmi_audio_configure(struct sti_hdmi *hdmi)
        switch (info->channels) {
        case 8:
                audio_cfg |= HDMI_AUD_CFG_CH78_VALID;
-               /* fall through */
+               fallthrough;
        case 6:
                audio_cfg |= HDMI_AUD_CFG_CH56_VALID;
-               /* fall through */
+               fallthrough;
        case 4:
                audio_cfg |= HDMI_AUD_CFG_CH34_VALID | HDMI_AUD_CFG_8CH;
-               /* fall through */
+               fallthrough;
        case 2:
                audio_cfg |= HDMI_AUD_CFG_CH12_VALID;
                break;
index 072ea11..ed5d866 100644 (file)
@@ -589,8 +589,7 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
 
        /* We can't have an alpha plane at the lowest position */
        if (!backend->quirks->supports_lowest_plane_alpha &&
-           (plane_states[0]->fb->format->has_alpha ||
-           (plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE)))
+           (plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE))
                return -EINVAL;
 
        for (i = 1; i < num_planes; i++) {
@@ -995,7 +994,6 @@ static const struct sun4i_backend_quirks sun6i_backend_quirks = {
 
 static const struct sun4i_backend_quirks sun7i_backend_quirks = {
        .needs_output_muxing = true,
-       .supports_lowest_plane_alpha = true,
 };
 
 static const struct sun4i_backend_quirks sun8i_a33_backend_quirks = {
index 359b56e..e40c542 100644 (file)
@@ -195,7 +195,7 @@ void sun4i_tcon_set_status(struct sun4i_tcon *tcon,
        switch (encoder->encoder_type) {
        case DRM_MODE_ENCODER_LVDS:
                is_lvds = true;
-               /* Fallthrough */
+               fallthrough;
        case DRM_MODE_ENCODER_DSI:
        case DRM_MODE_ENCODER_NONE:
                channel = 0;
@@ -342,7 +342,7 @@ static void sun4i_tcon0_mode_set_dithering(struct sun4i_tcon *tcon,
                /* R and B components are only 5 bits deep */
                val |= SUN4I_TCON0_FRM_CTL_MODE_R;
                val |= SUN4I_TCON0_FRM_CTL_MODE_B;
-               /* Fall through */
+               fallthrough;
        case MEDIA_BUS_FMT_RGB666_1X18:
        case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
                /* Fall through: enable dithering */
@@ -1433,14 +1433,18 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
        if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
            encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
                ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
-               if (ret)
+               if (ret) {
+                       put_device(&pdev->dev);
                        return ret;
+               }
        }
 
        if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP)) {
                ret = sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
-               if (ret)
+               if (ret) {
+                       put_device(&pdev->dev);
                        return ret;
+               }
        }
 
        return 0;
index aa67cb0..de8a11a 100644 (file)
@@ -889,7 +889,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
        regmap_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(0),
                     sun6i_dsi_dcs_build_pkt_hdr(dsi, msg));
 
-       bounce = kzalloc(msg->tx_len + sizeof(crc), GFP_KERNEL);
+       bounce = kzalloc(ALIGN(msg->tx_len + sizeof(crc), 4), GFP_KERNEL);
        if (!bounce)
                return -ENOMEM;
 
@@ -900,7 +900,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
        memcpy((u8 *)bounce + msg->tx_len, &crc, sizeof(crc));
        len += sizeof(crc);
 
-       regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, len);
+       regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, DIV_ROUND_UP(len, 4));
        regmap_write(dsi->regs, SUN6I_DSI_CMD_CTL_REG, len + 4 - 1);
        kfree(bounce);
 
@@ -1027,7 +1027,7 @@ static ssize_t sun6i_dsi_transfer(struct mipi_dsi_host *host,
                        ret = sun6i_dsi_dcs_read(dsi, msg);
                        break;
                }
-               /* Else, fall through */
+               fallthrough;
 
        default:
                ret = -EINVAL;
index 22c8c53..c0147af 100644 (file)
@@ -211,7 +211,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
        return 0;
 }
 
-static bool sun8i_vi_layer_get_csc_mode(const struct drm_format_info *format)
+static u32 sun8i_vi_layer_get_csc_mode(const struct drm_format_info *format)
 {
        if (!format->is_yuv)
                return SUN8I_CSC_MODE_OFF;
index 9a0b324..424ad60 100644 (file)
@@ -135,7 +135,7 @@ static inline u32 compute_dda_inc(unsigned int in, unsigned int out, bool v,
 
                default:
                        WARN_ON_ONCE(1);
-                       /* fallthrough */
+                       fallthrough;
                case 4:
                        max = 4;
                        break;
index 1856962..518220b 100644 (file)
@@ -386,7 +386,7 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
                case DRM_FORMAT_XBGR8888:
                case DRM_FORMAT_XRGB8888:
                        reg |= LCDC_V2_TFT_24BPP_UNPACK;
-                       /* fallthrough */
+                       fallthrough;
                case DRM_FORMAT_BGR888:
                case DRM_FORMAT_RGB888:
                        reg |= LCDC_V2_TFT_24BPP_MODE;
index 33526c5..4732dcc 100644 (file)
@@ -525,7 +525,7 @@ int ttm_bo_vm_access(struct vm_area_struct *vma, unsigned long addr,
                        if (unlikely(ret != 0))
                                return ret;
                }
-               /* fall through */
+               fallthrough;
        case TTM_PL_TT:
                ret = ttm_bo_vm_access_kmap(bo, offset, buf, len, write);
                break;
index d733bbc..17ff24d 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/version.h>
 #include <linux/dma-buf.h>
 #include <linux/of_graph.h>
+#include <linux/delay.h>
 
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_fourcc.h>
@@ -130,9 +131,25 @@ static void tve200_display_enable(struct drm_simple_display_pipe *pipe,
        struct drm_connector *connector = priv->connector;
        u32 format = fb->format->format;
        u32 ctrl1 = 0;
+       int retries;
 
        clk_prepare_enable(priv->clk);
 
+       /* Reset the TVE200 and wait for it to come back online */
+       writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4);
+       for (retries = 0; retries < 5; retries++) {
+               usleep_range(30000, 50000);
+               if (readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET)
+                       continue;
+               else
+                       break;
+       }
+       if (retries == 5 &&
+           readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) {
+               dev_err(drm->dev, "can't get hardware out of reset\n");
+               return;
+       }
+
        /* Function 1 */
        ctrl1 |= TVE200_CTRL_CSMODE;
        /* Interlace mode for CCIR656: parameterize? */
@@ -230,8 +247,9 @@ static void tve200_display_disable(struct drm_simple_display_pipe *pipe)
 
        drm_crtc_vblank_off(crtc);
 
-       /* Disable and Power Down */
+       /* Disable put into reset and Power Down */
        writel(0, priv->regs + TVE200_CTRL);
+       writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4);
 
        clk_disable_unprepare(priv->clk);
 }
@@ -279,6 +297,8 @@ static int tve200_display_enable_vblank(struct drm_simple_display_pipe *pipe)
        struct drm_device *drm = crtc->dev;
        struct tve200_drm_dev_private *priv = drm->dev_private;
 
+       /* Clear any IRQs and enable */
+       writel(0xFF, priv->regs + TVE200_INT_CLR);
        writel(TVE200_INT_V_STATUS, priv->regs + TVE200_INT_EN);
        return 0;
 }
index 551fa31..5771bb5 100644 (file)
@@ -179,21 +179,21 @@ via_free_sg_info(struct pci_dev *pdev, drm_via_sg_info_t *vsg)
        switch (vsg->state) {
        case dr_via_device_mapped:
                via_unmap_blit_from_device(pdev, vsg);
-               /* fall through */
+               fallthrough;
        case dr_via_desc_pages_alloc:
                for (i = 0; i < vsg->num_desc_pages; ++i) {
                        if (vsg->desc_pages[i] != NULL)
                                free_page((unsigned long)vsg->desc_pages[i]);
                }
                kfree(vsg->desc_pages);
-               /* fall through */
+               fallthrough;
        case dr_via_pages_locked:
                unpin_user_pages_dirty_lock(vsg->pages, vsg->num_pages,
                                           (vsg->direction == DMA_FROM_DEVICE));
-               /* fall through */
+               fallthrough;
        case dr_via_pages_alloc:
                vfree(vsg->pages);
-               /* fall through */
+               fallthrough;
        default:
                vsg->state = dr_via_sg_init;
        }
index af55b33..afd0f92 100644 (file)
@@ -97,9 +97,6 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
                                          struct drm_crtc_state *old_state)
 {
-       struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
-
-       output->enabled = true;
 }
 
 static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -111,7 +108,6 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
 
        virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
        virtio_gpu_notify(vgdev);
-       output->enabled = false;
 }
 
 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
@@ -123,6 +119,17 @@ static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
 static void virtio_gpu_crtc_atomic_flush(struct drm_crtc *crtc,
                                         struct drm_crtc_state *old_state)
 {
+       struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
+
+       /*
+        * virtio-gpu can't do modeset and plane update operations
+        * independent from each other.  So the actual modeset happens
+        * in the plane update callback, and here we just check
+        * whenever we must force the modeset.
+        */
+       if (drm_atomic_crtc_needs_modeset(crtc->state)) {
+               output->needs_modeset = true;
+       }
 }
 
 static const struct drm_crtc_helper_funcs virtio_gpu_crtc_helper_funcs = {
index 9ff9f4a..fbc0427 100644 (file)
@@ -137,7 +137,7 @@ struct virtio_gpu_output {
        struct edid *edid;
        int cur_x;
        int cur_y;
-       bool enabled;
+       bool needs_modeset;
 };
 #define drm_crtc_to_virtio_gpu_output(x) \
        container_of(x, struct virtio_gpu_output, crtc)
index 7a2430e..c8da7ad 100644 (file)
@@ -179,6 +179,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
 
        virtio_gpu_cmd_submit(vgdev, buf, exbuf->size,
                              vfpriv->ctx_id, buflist, out_fence);
+       dma_fence_put(&out_fence->f);
        virtio_gpu_notify(vgdev);
        return 0;
 
index 2cdd3cd..842f8b6 100644 (file)
@@ -79,6 +79,7 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo)
                        }
 
                        sg_free_table(shmem->pages);
+                       kfree(shmem->pages);
                        shmem->pages = NULL;
                        drm_gem_shmem_unpin(&bo->base.base);
                }
@@ -150,7 +151,13 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
        if (ret < 0)
                return -EINVAL;
 
-       shmem->pages = drm_gem_shmem_get_pages_sgt(&bo->base.base);
+       /*
+        * virtio_gpu uses drm_gem_shmem_get_sg_table instead of
+        * drm_gem_shmem_get_pages_sgt because virtio has it's own set of
+        * dma-ops. This is discouraged for other drivers, but should be fine
+        * since virtio_gpu doesn't support dma-buf import from other devices.
+        */
+       shmem->pages = drm_gem_shmem_get_sg_table(&bo->base.base);
        if (!shmem->pages) {
                drm_gem_shmem_unpin(&bo->base.base);
                return -EINVAL;
index 52d2417..6a311cd 100644 (file)
@@ -142,7 +142,7 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
        if (WARN_ON(!output))
                return;
 
-       if (!plane->state->fb || !output->enabled) {
+       if (!plane->state->fb || !output->crtc.state->active) {
                DRM_DEBUG("nofb\n");
                virtio_gpu_cmd_set_scanout(vgdev, output->index, 0,
                                           plane->state->src_w >> 16,
@@ -163,7 +163,9 @@ static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
            plane->state->src_w != old_state->src_w ||
            plane->state->src_h != old_state->src_h ||
            plane->state->src_x != old_state->src_x ||
-           plane->state->src_y != old_state->src_y) {
+           plane->state->src_y != old_state->src_y ||
+           output->needs_modeset) {
+               output->needs_modeset = false;
                DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
                          bo->hw_res_handle,
                          plane->state->crtc_w, plane->state->crtc_h,
index 013c9e0..cc93a8c 100644 (file)
@@ -649,9 +649,7 @@ static void displback_changed(struct xenbus_device *xb_dev,
 
        switch (backend_state) {
        case XenbusStateReconfiguring:
-               /* fall through */
        case XenbusStateReconfigured:
-               /* fall through */
        case XenbusStateInitialised:
                break;
 
@@ -701,7 +699,6 @@ static void displback_changed(struct xenbus_device *xb_dev,
                break;
 
        case XenbusStateUnknown:
-               /* fall through */
        case XenbusStateClosed:
                if (xb_dev->state == XenbusStateClosed)
                        break;
index 39ff95b..534daf3 100644 (file)
@@ -18,6 +18,7 @@
 #include <drm/drm_probe_helper.h>
 
 #include <xen/balloon.h>
+#include <xen/xen.h>
 
 #include "xen_drm_front.h"
 #include "xen_drm_front_gem.h"
@@ -99,8 +100,8 @@ static struct xen_gem_object *gem_create(struct drm_device *dev, size_t size)
                 * allocate ballooned pages which will be used to map
                 * grant references provided by the backend
                 */
-               ret = alloc_xenballooned_pages(xen_obj->num_pages,
-                                              xen_obj->pages);
+               ret = xen_alloc_unpopulated_pages(xen_obj->num_pages,
+                                                 xen_obj->pages);
                if (ret < 0) {
                        DRM_ERROR("Cannot allocate %zu ballooned pages: %d\n",
                                  xen_obj->num_pages, ret);
@@ -152,8 +153,8 @@ void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj)
        } else {
                if (xen_obj->pages) {
                        if (xen_obj->be_alloc) {
-                               free_xenballooned_pages(xen_obj->num_pages,
-                                                       xen_obj->pages);
+                               xen_free_unpopulated_pages(xen_obj->num_pages,
+                                                          xen_obj->pages);
                                gem_free_pages_array(xen_obj);
                        } else {
                                drm_gem_put_pages(&xen_obj->base,
index aa6cd88..b52c6cd 100644 (file)
@@ -2,6 +2,7 @@ config DRM_ZYNQMP_DPSUB
        tristate "ZynqMP DisplayPort Controller Driver"
        depends on ARCH_ZYNQMP || COMPILE_TEST
        depends on COMMON_CLK && DRM && OF
+       depends on DMADEVICES
        select DMA_ENGINE
        select DRM_GEM_CMA_HELPER
        select DRM_KMS_CMA_HELPER
index dbcc167..34b4075 100644 (file)
@@ -141,7 +141,7 @@ static int ipu_bus_format_to_map(u32 fmt)
        switch (fmt) {
        default:
                WARN_ON(1);
-               /* fall-through */
+               fallthrough;
        case MEDIA_BUS_FMT_RGB888_1X24:
                return IPU_DC_MAP_RGB24;
        case MEDIA_BUS_FMT_RGB565_1X16:
index 58ea374..9ec949a 100644 (file)
@@ -620,7 +620,7 @@ static struct attribute *interface_common_attrs[] = {
 static umode_t interface_unipro_is_visible(struct kobject *kobj,
                                           struct attribute *attr, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct gb_interface *intf = to_gb_interface(dev);
 
        switch (intf->type) {
@@ -635,7 +635,7 @@ static umode_t interface_unipro_is_visible(struct kobject *kobj,
 static umode_t interface_greybus_is_visible(struct kobject *kobj,
                                            struct attribute *attr, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct gb_interface *intf = to_gb_interface(dev);
 
        switch (intf->type) {
@@ -649,7 +649,7 @@ static umode_t interface_greybus_is_visible(struct kobject *kobj,
 static umode_t interface_power_is_visible(struct kobject *kobj,
                                          struct attribute *attr, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct gb_interface *intf = to_gb_interface(dev);
 
        switch (intf->type) {
index 359616e..d2ecc9c 100644 (file)
@@ -1597,6 +1597,17 @@ static void hid_output_field(const struct hid_device *hid,
        }
 }
 
+/*
+ * Compute the size of a report.
+ */
+static size_t hid_compute_report_size(struct hid_report *report)
+{
+       if (report->size)
+               return ((report->size - 1) >> 3) + 1;
+
+       return 0;
+}
+
 /*
  * Create a report. 'data' has to be allocated using
  * hid_alloc_report_buf() so that it has proper size.
@@ -1609,7 +1620,7 @@ void hid_output_report(struct hid_report *report, __u8 *data)
        if (report->id > 0)
                *data++ = report->id;
 
-       memset(data, 0, ((report->size - 1) >> 3) + 1);
+       memset(data, 0, hid_compute_report_size(report));
        for (n = 0; n < report->maxfield; n++)
                hid_output_field(report->device, report->field[n], data);
 }
@@ -1739,7 +1750,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
                csize--;
        }
 
-       rsize = ((report->size - 1) >> 3) + 1;
+       rsize = hid_compute_report_size(report);
 
        if (report_enum->numbered && rsize >= HID_MAX_BUFFER_SIZE)
                rsize = HID_MAX_BUFFER_SIZE - 1;
index 4ff3bc1..28d671c 100644 (file)
@@ -321,7 +321,7 @@ static const struct kernel_param_ops cougar_g6_is_space_ops = {
 };
 module_param_cb(g6_is_space, &cougar_g6_is_space_ops, &g6_is_space, 0644);
 
-static struct hid_device_id cougar_id_table[] = {
+static const struct hid_device_id cougar_id_table[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
                         USB_DEVICE_ID_COUGAR_500K_GAMING_KEYBOARD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
index 45c4f88..dae1937 100644 (file)
@@ -188,6 +188,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
        ret = input_mt_init_slots(input, ELAN_MAX_FINGERS, INPUT_MT_POINTER);
        if (ret) {
                hid_err(hdev, "Failed to init elan MT slots: %d\n", ret);
+               input_free_device(input);
                return ret;
        }
 
@@ -198,6 +199,7 @@ static int elan_input_configured(struct hid_device *hdev, struct hid_input *hi)
        if (ret) {
                hid_err(hdev, "Failed to register elan input device: %d\n",
                        ret);
+               input_mt_destroy_slots(input);
                input_free_device(input);
                return ret;
        }
index 6221888..74fc1df 100644 (file)
 #define USB_DEVICE_ID_LENOVO_TPPRODOCK 0x6067
 #define USB_DEVICE_ID_LENOVO_X1_COVER  0x6085
 #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D     0x608d
+#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019     0x6019
+#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E     0x602e
+#define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6093     0x6093
 
 #define USB_VENDOR_ID_LG               0x1fd2
 #define USB_DEVICE_ID_LG_MULTITOUCH    0x0064
 #define USB_DEVICE_ID_MS_POWER_COVER     0x07da
 #define USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER 0x02fd
 #define USB_DEVICE_ID_MS_PIXART_MOUSE    0x00cb
+#define USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS      0x02e0
 
 #define USB_VENDOR_ID_MOJO             0x8282
 #define USB_DEVICE_ID_RETRO_ADAPTER    0x3201
 #define USB_DEVICE_ID_SAITEK_RAT9      0x0cfa
 #define USB_DEVICE_ID_SAITEK_MMO7      0x0cd0
 #define USB_DEVICE_ID_SAITEK_X52       0x075c
+#define USB_DEVICE_ID_SAITEK_X52_2     0x0255
+#define USB_DEVICE_ID_SAITEK_X52_PRO   0x0762
 
 #define USB_VENDOR_ID_SAMSUNG          0x0419
 #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE        0x0001
index b8eabf2..88e1999 100644 (file)
@@ -1132,6 +1132,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
        }
 
 mapped:
+       /* Mapping failed, bail out */
+       if (!bit)
+               return;
+
        if (device->driver->input_mapped &&
            device->driver->input_mapped(device, hidinput, field, usage,
                                         &bit, &max) < 0) {
index ef0cbcd..fcaf846 100644 (file)
@@ -680,7 +680,7 @@ static int lg_g15_register_led(struct lg_g15_data *g15, int i)
                         * but it does have a separate power-on (reset) value.
                         */
                        g15->leds[i].cdev.name = "g15::power_on_backlight_val";
-                       /* fall through */
+                       fallthrough;
                case LG_G15_KBD_BRIGHTNESS:
                        g15->leds[i].cdev.brightness_set_blocking =
                                lg_g510_kbd_led_set;
index a78c13c..38ee25a 100644 (file)
@@ -844,7 +844,7 @@ static void logi_dj_recv_queue_notification(struct dj_receiver_dev *djrcv_dev,
                        workitem.type = WORKITEM_TYPE_EMPTY;
                        break;
                }
-               /* fall-through */
+               fallthrough;
        case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
                workitem.quad_id_msb =
                        dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB];
index 9a4fc7d..aea46e5 100644 (file)
@@ -29,7 +29,7 @@ static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc,
        return rdesc;
 }
 
-static struct hid_device_id macally_id_table[] = {
+static const struct hid_device_id macally_id_table[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR,
                         USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) },
        { }
index 2d8b589..071fd09 100644 (file)
@@ -163,16 +163,13 @@ static int ms_surface_dial_quirk(struct hid_input *hi, struct hid_field *field,
 {
        switch (usage->hid & HID_USAGE_PAGE) {
        case 0xff070000:
-               /* fall-through */
        case HID_UP_DIGITIZER:
                /* ignore those axis */
                return -1;
        case HID_UP_GENDESK:
                switch (usage->hid) {
                case HID_GD_X:
-                       /* fall-through */
                case HID_GD_Y:
-                       /* fall-through */
                case HID_GD_RFKILL_BTN:
                        /* ignore those axis */
                        return -1;
@@ -451,6 +448,8 @@ static const struct hid_device_id ms_devices[] = {
                .driver_data = MS_SURFACE_DIAL },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER),
                .driver_data = MS_QUIRK_FF },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS),
+               .driver_data = MS_QUIRK_FF },
        { }
 };
 MODULE_DEVICE_TABLE(hid, ms_devices);
index 3f94b49..e315215 100644 (file)
@@ -856,6 +856,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
                        code = BTN_0  + ((usage->hid - 1) & HID_USAGE);
 
                hid_map_usage(hi, usage, bit, max, EV_KEY, code);
+               if (!*bit)
+                       return -1;
                input_set_capability(hi->input, EV_KEY, code);
                return 1;
 
index c242150..7a2be02 100644 (file)
@@ -105,6 +105,9 @@ static const struct hid_device_id hid_quirks[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT },
        { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D), HID_QUIRK_ALWAYS_POLL },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019), HID_QUIRK_ALWAYS_POLL },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E), HID_QUIRK_ALWAYS_POLL },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6093), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C007), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KEYBOARD_G710_PLUS), HID_QUIRK_NOGET },
@@ -147,6 +150,8 @@ static const struct hid_device_id hid_quirks[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_RETROUSB, USB_DEVICE_ID_RETROUSB_SNES_RETROPORT), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE },
        { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD), HID_QUIRK_BADPAD },
        { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE },
+       { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE },
+       { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_PRO), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE },
        { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD2), HID_QUIRK_NO_INIT_REPORTS },
        { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS },
        { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET },
index 8cffa84..7f41213 100644 (file)
@@ -428,7 +428,6 @@ static void rmi_report(struct hid_device *hid, struct hid_report *report)
 
        switch (report->id) {
        case RMI_READ_DATA_REPORT_ID:
-               /* fall-through */
        case RMI_ATTN_REPORT_ID:
                return;
        }
index 1a6e600..2ff4c8e 100644 (file)
@@ -780,7 +780,7 @@ static void kone_keep_values_up_to_date(struct kone_device *kone,
        case kone_mouse_event_switch_profile:
                kone->actual_dpi = kone->profiles[event->value - 1].
                                startup_dpi;
-               /* fall through */
+               fallthrough;
        case kone_mouse_event_osd_profile:
                kone->actual_profile = event->value;
                break;
index 78a364a..7d20d1f 100644 (file)
@@ -974,7 +974,7 @@ int uclogic_params_init(struct uclogic_params *params,
                        }
                        break;
                }
-               /* FALL THROUGH */
+               fallthrough;
        case VID_PID(USB_VENDOR_ID_HUION,
                     USB_DEVICE_ID_HUION_TABLET):
        case VID_PID(USB_VENDOR_ID_HUION,
index 679e142..e484c36 100644 (file)
@@ -1672,7 +1672,6 @@ static ssize_t wiimote_ext_show(struct device *dev,
        case WIIMOTE_EXT_GUITAR:
                return sprintf(buf, "guitar\n");
        case WIIMOTE_EXT_UNKNOWN:
-               /* fallthrough */
        default:
                return sprintf(buf, "unknown\n");
        }
@@ -1722,7 +1721,6 @@ static ssize_t wiimote_dev_show(struct device *dev,
        case WIIMOTE_DEV_PENDING:
                return sprintf(buf, "pending\n");
        case WIIMOTE_DEV_UNKNOWN:
-               /* fallthrough */
        default:
                return sprintf(buf, "unknown\n");
        }
index 294c84e..dbd0449 100644 (file)
@@ -420,6 +420,19 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
                dev_err(&client->dev, "failed to change power setting.\n");
 
 set_pwr_exit:
+
+       /*
+        * The HID over I2C specification states that if a DEVICE needs time
+        * after the PWR_ON request, it should utilise CLOCK stretching.
+        * However, it has been observered that the Windows driver provides a
+        * 1ms sleep between the PWR_ON and RESET requests.
+        * According to Goodix Windows even waits 60 ms after (other?)
+        * PWR_ON requests. Testing has confirmed that several devices
+        * will not work properly without a delay after a PWR_ON request.
+        */
+       if (!ret && power_state == I2C_HID_PWR_ON)
+               msleep(60);
+
        return ret;
 }
 
@@ -441,15 +454,6 @@ static int i2c_hid_hwreset(struct i2c_client *client)
        if (ret)
                goto out_unlock;
 
-       /*
-        * The HID over I2C specification states that if a DEVICE needs time
-        * after the PWR_ON request, it should utilise CLOCK stretching.
-        * However, it has been observered that the Windows driver provides a
-        * 1ms sleep between the PWR_ON and RESET requests and that some devices
-        * rely on this.
-        */
-       usleep_range(1000, 5000);
-
        i2c_hid_dbg(ihid, "resetting...\n");
 
        ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
index 492dd64..17a29ee 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/wait.h>
 #include <linux/workqueue.h>
 #include <linux/string.h>
-#include <linux/timekeeping.h>
 
 #include <linux/usb.h>
 
@@ -96,18 +95,6 @@ static int hid_start_in(struct hid_device *hid)
                                set_bit(HID_NO_BANDWIDTH, &usbhid->iofl);
                } else {
                        clear_bit(HID_NO_BANDWIDTH, &usbhid->iofl);
-
-                       if (test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) {
-                               /*
-                                * In case events are generated while nobody was
-                                * listening, some are released when the device
-                                * is re-opened. Wait 50 msec for the queue to
-                                * empty before allowing events to go through
-                                * hid.
-                                */
-                               usbhid->input_start_time =
-                                       ktime_add_ms(ktime_get_coarse(), 50);
-                       }
                }
        }
        spin_unlock_irqrestore(&usbhid->lock, flags);
@@ -293,23 +280,20 @@ static void hid_irq_in(struct urb *urb)
                if (!test_bit(HID_OPENED, &usbhid->iofl))
                        break;
                usbhid_mark_busy(usbhid);
-               if (test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) {
-                       if (ktime_before(ktime_get_coarse(),
-                                        usbhid->input_start_time))
-                               break;
-                       clear_bit(HID_RESUME_RUNNING, &usbhid->iofl);
+               if (!test_bit(HID_RESUME_RUNNING, &usbhid->iofl)) {
+                       hid_input_report(urb->context, HID_INPUT_REPORT,
+                                        urb->transfer_buffer,
+                                        urb->actual_length, 1);
+                       /*
+                        * autosuspend refused while keys are pressed
+                        * because most keyboards don't wake up when
+                        * a key is released
+                        */
+                       if (hid_check_keys_pressed(hid))
+                               set_bit(HID_KEYS_PRESSED, &usbhid->iofl);
+                       else
+                               clear_bit(HID_KEYS_PRESSED, &usbhid->iofl);
                }
-               hid_input_report(urb->context, HID_INPUT_REPORT,
-                                urb->transfer_buffer, urb->actual_length, 1);
-               /*
-                * autosuspend refused while keys are pressed
-                * because most keyboards don't wake up when
-                * a key is released
-                */
-               if (hid_check_keys_pressed(hid))
-                       set_bit(HID_KEYS_PRESSED, &usbhid->iofl);
-               else
-                       clear_bit(HID_KEYS_PRESSED, &usbhid->iofl);
                break;
        case -EPIPE:            /* stall */
                usbhid_mark_busy(usbhid);
@@ -736,6 +720,17 @@ static int usbhid_open(struct hid_device *hid)
 
        usb_autopm_put_interface(usbhid->intf);
 
+       /*
+        * In case events are generated while nobody was listening,
+        * some are released when the device is re-opened.
+        * Wait 50 msec for the queue to empty before allowing events
+        * to go through hid.
+        */
+       if (res == 0)
+               msleep(50);
+
+       clear_bit(HID_RESUME_RUNNING, &usbhid->iofl);
+
  Done:
        mutex_unlock(&usbhid->mutex);
        return res;
index 4140dea..45e0b1c 100644 (file)
@@ -519,12 +519,16 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
 
                switch (cmd) {
                case HIDIOCGUSAGE:
+                       if (uref->usage_index >= field->report_count)
+                               goto inval;
                        uref->value = field->value[uref->usage_index];
                        if (copy_to_user(user_arg, uref, sizeof(*uref)))
                                goto fault;
                        goto goodreturn;
 
                case HIDIOCSUSAGE:
+                       if (uref->usage_index >= field->report_count)
+                               goto inval;
                        field->value[uref->usage_index] = uref->value;
                        goto goodreturn;
 
@@ -781,7 +785,6 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                break;
 
        case HIDIOCGUCODE:
-               /* fall through */
        case HIDIOCGUSAGE:
        case HIDIOCSUSAGE:
        case HIDIOCGUSAGES:
index c6ad684..75fe85d 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <linux/types.h>
 #include <linux/slab.h>
-#include <linux/ktime.h>
 #include <linux/list.h>
 #include <linux/mutex.h>
 #include <linux/timer.h>
@@ -84,7 +83,6 @@ struct usbhid_device {
        struct mutex mutex;                                             /* start/stop/open/close */
        spinlock_t lock;                                                /* fifo spinlock */
        unsigned long iofl;                                             /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
-       ktime_t input_start_time;                                       /* When to start handling input */
        struct timer_list io_retry;                                     /* Retry timer */
        unsigned long stop_retry;                                       /* Time to give up, in jiffies */
        unsigned int retry_delay;                                       /* Delay length in ms */
index 1c96809..83dfec3 100644 (file)
@@ -341,7 +341,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 
                        case 2: /* Mouse with wheel */
                                input_report_key(input, BTN_MIDDLE, data[1] & 0x04);
-                               /* fall through */
+                               fallthrough;
 
                        case 3: /* Mouse without wheel */
                                wacom->tool[0] = BTN_TOOL_MOUSE;
@@ -1201,7 +1201,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
        case 0x04:
                wacom_intuos_bt_process_data(wacom, data + i);
                i += 10;
-               /* fall through */
+               fallthrough;
        case 0x03:
                wacom_intuos_bt_process_data(wacom, data + i);
                i += 10;
@@ -2148,7 +2148,7 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
                for (i = 0; i < wacom->led.count; i++)
                        wacom_update_led(wacom, features->numbered_buttons,
                                         value, i);
-                /* fall through*/
+               fallthrough;
        default:
                do_report = true;
                break;
@@ -3602,14 +3602,14 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
        switch (features->type) {
        case GRAPHIRE_BT:
                __clear_bit(ABS_MISC, input_dev->absbit);
-               /* fall through */
+               fallthrough;
 
        case WACOM_MO:
        case WACOM_G4:
                input_set_abs_params(input_dev, ABS_DISTANCE, 0,
                                              features->distance_max,
                                              features->distance_fuzz, 0);
-               /* fall through */
+               fallthrough;
 
        case GRAPHIRE:
                input_set_capability(input_dev, EV_REL, REL_WHEEL);
@@ -3649,7 +3649,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
        case INTUOS4S:
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                input_abs_set_res(input_dev, ABS_Z, 287);
-               /* fall through */
+               fallthrough;
 
        case INTUOS:
                wacom_setup_intuos(wacom_wac);
@@ -3682,7 +3682,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
        case TABLETPC:
        case TABLETPCE:
                __clear_bit(ABS_MISC, input_dev->absbit);
-               /* fall through */
+               fallthrough;
 
        case DTUS:
        case DTUSX:
@@ -3696,7 +3696,7 @@ int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
 
        case PTU:
                __set_bit(BTN_STYLUS2, input_dev->keybit);
-               /* fall through */
+               fallthrough;
 
        case PENPARTNER:
                __set_bit(BTN_TOOL_PEN, input_dev->keybit);
@@ -3799,7 +3799,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
                input_abs_set_res(input_dev, ABS_MT_POSITION_X, 40);
                input_abs_set_res(input_dev, ABS_MT_POSITION_Y, 40);
 
-               /* fall through */
+               fallthrough;
 
        case INTUOS5:
        case INTUOS5L:
@@ -3817,7 +3817,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
                input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
                input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
                input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
-               /* fall through */
+               fallthrough;
 
        case WACOM_27QHDT:
                if (wacom_wac->shared->touch->product == 0x32C ||
@@ -3826,14 +3826,14 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
                        __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
                        wacom_wac->shared->has_mute_touch_switch = true;
                }
-               /* fall through */
+               fallthrough;
 
        case MTSCREEN:
        case MTTPC:
        case MTTPC_B:
        case TABLETPC2FG:
                input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
-               /*fall through */
+               fallthrough;
 
        case TABLETPC:
        case TABLETPCE:
@@ -3843,7 +3843,7 @@ int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
        case INTUOSHT2:
                input_dev->evbit[0] |= BIT_MASK(EV_SW);
                __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
-               /* fall through */
+               fallthrough;
 
        case BAMBOO_PT:
        case BAMBOO_TOUCH:
@@ -4099,7 +4099,7 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
 
                __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
                __set_bit(KEY_INFO, input_dev->keybit);
-               /* fall through */
+               fallthrough;
 
        case WACOM_21UX2:
        case WACOM_BEE:
@@ -4115,7 +4115,7 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
        case INTUOS3:
        case INTUOS3L:
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
-               /* fall through */
+               fallthrough;
 
        case INTUOS3S:
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
@@ -4139,7 +4139,7 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
                 * ID_INPUT_TABLET to be set.
                 */
                __set_bit(BTN_STYLUS, input_dev->keybit);
-               /* fall through */
+               fallthrough;
 
        case INTUOS4:
        case INTUOS4L:
index 365b5d5..96d0ecc 100644 (file)
@@ -291,7 +291,7 @@ static void ssip_set_rxstate(struct ssi_protocol *ssi, unsigned int state)
                /* CMT speech workaround */
                if (atomic_read(&ssi->tx_usecnt))
                        break;
-               /* Else, fall through */
+               fallthrough;
        case RECEIVING:
                mod_timer(&ssi->keep_alive, jiffies +
                                                msecs_to_jiffies(SSIP_KATOUT));
@@ -466,7 +466,7 @@ static void ssip_keep_alive(struct timer_list *t)
                case SEND_READY:
                        if (atomic_read(&ssi->tx_usecnt) == 0)
                                break;
-                       /* Fall through */
+                       fallthrough;
                        /*
                         * Workaround for cmt-speech in that case
                         * we relay on audio timers.
@@ -668,7 +668,7 @@ static void ssip_rx_bootinforeq(struct hsi_client *cl, u32 cmd)
        case ACTIVE:
                dev_err(&cl->device, "Boot info req on active state\n");
                ssip_error(cl);
-               /* Fall through */
+               fallthrough;
        case INIT:
        case HANDSHAKE:
                spin_lock_bh(&ssi->lock);
index 4bc4a20..fa69b94 100644 (file)
@@ -296,7 +296,7 @@ static int ssi_clk_event(struct notifier_block *nb, unsigned long event,
                break;
        case ABORT_RATE_CHANGE:
                dev_dbg(&ssi->device, "abort rate change\n");
-               /* Fall through */
+               fallthrough;
        case POST_RATE_CHANGE:
                dev_dbg(&ssi->device, "post rate change (%lu -> %lu)\n",
                        clk_data->old_rate, clk_data->new_rate);
index e74b144..754d35a 100644 (file)
@@ -354,7 +354,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, int op)
 
                out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled;
 
-               /* fallthrough */
+               fallthrough;
 
        case KVP_OP_GET_IP_INFO:
                utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id,
index 92ee0fe..a4e8d96 100644 (file)
@@ -282,26 +282,52 @@ static struct {
        spinlock_t                      lock;
 } host_ts;
 
-static struct timespec64 hv_get_adj_host_time(void)
+static inline u64 reftime_to_ns(u64 reftime)
 {
-       struct timespec64 ts;
-       u64 newtime, reftime;
+       return (reftime - WLTIMEDELTA) * 100;
+}
+
+/*
+ * Hard coded threshold for host timesync delay: 600 seconds
+ */
+static const u64 HOST_TIMESYNC_DELAY_THRESH = 600 * (u64)NSEC_PER_SEC;
+
+static int hv_get_adj_host_time(struct timespec64 *ts)
+{
+       u64 newtime, reftime, timediff_adj;
        unsigned long flags;
+       int ret = 0;
 
        spin_lock_irqsave(&host_ts.lock, flags);
        reftime = hv_read_reference_counter();
-       newtime = host_ts.host_time + (reftime - host_ts.ref_time);
-       ts = ns_to_timespec64((newtime - WLTIMEDELTA) * 100);
+
+       /*
+        * We need to let the caller know that last update from host
+        * is older than the max allowable threshold. clock_gettime()
+        * and PTP ioctl do not have a documented error that we could
+        * return for this specific case. Use ESTALE to report this.
+        */
+       timediff_adj = reftime - host_ts.ref_time;
+       if (timediff_adj * 100 > HOST_TIMESYNC_DELAY_THRESH) {
+               pr_warn_once("TIMESYNC IC: Stale time stamp, %llu nsecs old\n",
+                            (timediff_adj * 100));
+               ret = -ESTALE;
+       }
+
+       newtime = host_ts.host_time + timediff_adj;
+       *ts = ns_to_timespec64(reftime_to_ns(newtime));
        spin_unlock_irqrestore(&host_ts.lock, flags);
 
-       return ts;
+       return ret;
 }
 
 static void hv_set_host_time(struct work_struct *work)
 {
-       struct timespec64 ts = hv_get_adj_host_time();
 
-       do_settimeofday64(&ts);
+       struct timespec64 ts;
+
+       if (!hv_get_adj_host_time(&ts))
+               do_settimeofday64(&ts);
 }
 
 /*
@@ -361,10 +387,23 @@ static void timesync_onchannelcallback(void *context)
        struct ictimesync_ref_data *refdata;
        u8 *time_txf_buf = util_timesynch.recv_buffer;
 
-       vmbus_recvpacket(channel, time_txf_buf,
-                        HV_HYP_PAGE_SIZE, &recvlen, &requestid);
+       /*
+        * Drain the ring buffer and use the last packet to update
+        * host_ts
+        */
+       while (1) {
+               int ret = vmbus_recvpacket(channel, time_txf_buf,
+                                          HV_HYP_PAGE_SIZE, &recvlen,
+                                          &requestid);
+               if (ret) {
+                       pr_warn_once("TimeSync IC pkt recv failed (Err: %d)\n",
+                                    ret);
+                       break;
+               }
+
+               if (!recvlen)
+                       break;
 
-       if (recvlen > 0) {
                icmsghdrp = (struct icmsg_hdr *)&time_txf_buf[
                                sizeof(struct vmbuspipe_hdr)];
 
@@ -622,9 +661,7 @@ static int hv_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 
 static int hv_ptp_gettime(struct ptp_clock_info *info, struct timespec64 *ts)
 {
-       *ts = hv_get_adj_host_time();
-
-       return 0;
+       return hv_get_adj_host_time(ts);
 }
 
 static struct ptp_clock_info ptp_hyperv_info = {
index 319a051..2088131 100644 (file)
@@ -435,7 +435,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
                case 3:
                        return "+1.5V";
                }
-               /* fall through */
+               fallthrough;
        case 2:
                if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
                        return "+12V3";
@@ -493,7 +493,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
                case 3:
                        return "+1.5";
                }
-               /* fall through */
+               fallthrough;
        case 11:
                if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT ==
                                        ADT7462_PIN28_VOLT &&
@@ -531,7 +531,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
                case 3:
                        return 7800;
                }
-               /* fall through */
+               fallthrough;
        case 2:
                if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
                        return 62500;
@@ -589,7 +589,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
                case 3:
                        return 7800;
                }
-               /* fall through */
+               fallthrough;
        case 11:
        case 12:
                if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT ==
index 3166184..a188879 100644 (file)
@@ -753,15 +753,18 @@ static ssize_t applesmc_light_show(struct device *dev,
        }
 
        ret = applesmc_read_key(LIGHT_SENSOR_LEFT_KEY, buffer, data_length);
+       if (ret)
+               goto out;
        /* newer macbooks report a single 10-bit bigendian value */
        if (data_length == 10) {
                left = be16_to_cpu(*(__be16 *)(buffer + 6)) >> 2;
                goto out;
        }
        left = buffer[2];
+
+       ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length);
        if (ret)
                goto out;
-       ret = applesmc_read_key(LIGHT_SENSOR_RIGHT_KEY, buffer, data_length);
        right = buffer[2];
 
 out:
@@ -810,12 +813,11 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
                  to_index(attr));
 
        ret = applesmc_read_key(newkey, buffer, 2);
-       speed = ((buffer[0] << 8 | buffer[1]) >> 2);
-
        if (ret)
                return ret;
-       else
-               return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed);
+
+       speed = ((buffer[0] << 8 | buffer[1]) >> 2);
+       return snprintf(sysfsbuf, PAGE_SIZE, "%u\n", speed);
 }
 
 static ssize_t applesmc_store_fan_speed(struct device *dev,
@@ -851,12 +853,11 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
        u8 buffer[2];
 
        ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
-       manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;
-
        if (ret)
                return ret;
-       else
-               return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual);
+
+       manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;
+       return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", manual);
 }
 
 static ssize_t applesmc_store_fan_manual(struct device *dev,
@@ -872,10 +873,11 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
                return -EINVAL;
 
        ret = applesmc_read_key(FANS_MANUAL, buffer, 2);
-       val = (buffer[0] << 8 | buffer[1]);
        if (ret)
                goto out;
 
+       val = (buffer[0] << 8 | buffer[1]);
+
        if (input)
                val = val | (0x01 << to_index(attr));
        else
@@ -951,13 +953,12 @@ static ssize_t applesmc_key_count_show(struct device *dev,
        u32 count;
 
        ret = applesmc_read_key(KEY_COUNT_KEY, buffer, 4);
-       count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
-                                               ((u32)buffer[2]<<8) + buffer[3];
-
        if (ret)
                return ret;
-       else
-               return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count);
+
+       count = ((u32)buffer[0]<<24) + ((u32)buffer[1]<<16) +
+                                               ((u32)buffer[2]<<8) + buffer[3];
+       return snprintf(sysfsbuf, PAGE_SIZE, "%d\n", count);
 }
 
 static ssize_t applesmc_key_at_index_read_show(struct device *dev,
index cf0962f..e9c0bbc 100644 (file)
@@ -406,10 +406,10 @@ static int emc1403_probe(struct i2c_client *client,
        switch (id->driver_data) {
        case emc1404:
                data->groups[2] = &emc1404_group;
-               /* fall through */
+               fallthrough;
        case emc1403:
                data->groups[1] = &emc1403_group;
-               /* fall through */
+               fallthrough;
        case emc1402:
                data->groups[0] = &emc1402_group;
        }
index d09deb4..4dec793 100644 (file)
@@ -1285,7 +1285,7 @@ static struct f71882fg_data *f71882fg_update_device(struct device *dev)
                                data->pwm_auto_point_pwm[nr][0] =
                                        f71882fg_read8(data,
                                                F71882FG_REG_POINT_PWM(nr, 0));
-                               /* Fall through */
+                               fallthrough;
                        case f71862fg:
                                data->pwm_auto_point_pwm[nr][1] =
                                        f71882fg_read8(data,
@@ -2442,7 +2442,7 @@ static int f71882fg_probe(struct platform_device *pdev)
                case f71869a:
                        /* These always have signed auto point temps */
                        data->auto_point_temp_signed = 1;
-                       /* Fall through - to select correct fan/pwm reg bank! */
+                       fallthrough;    /* to select correct fan/pwm reg bank! */
                case f71889fg:
                case f71889ed:
                case f71889a:
index 3dfe2ca..c6d4567 100644 (file)
@@ -172,6 +172,7 @@ gsc_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr,
        case mode_temperature:
                if (tmp > 0x8000)
                        tmp -= 0xffff;
+               tmp *= 100; /* convert to millidegrees celsius */
                break;
        case mode_voltage_raw:
                tmp = clamp_val(tmp, 0, BIT(GSC_HWMON_RESOLUTION));
index eb72e39..6d1175a 100644 (file)
@@ -96,7 +96,7 @@ int vid_from_reg(int val, u8 vrm)
                val &= 0x1f;
                if (val == 0x1f)
                        return 0;
-                               /* fall through */
+               fallthrough;
        case 25:                /* AMD NPT 0Fh */
                val &= 0x3f;
                return (val < 32) ? 1550 - 25 * val
@@ -122,7 +122,7 @@ int vid_from_reg(int val, u8 vrm)
 
        case 84:                /* VRM 8.4 */
                val &= 0x0f;
-                               /* fall through */
+               fallthrough;
        case 82:                /* VRM 8.2 */
                val &= 0x1f;
                return val == 0x1f ? 0 :
index 7fc5b06..81e1556 100644 (file)
@@ -352,7 +352,7 @@ static int ina3221_read_curr(struct device *dev, u32 attr,
                if (ret)
                        return ret;
 
-               /* fall through */
+               fallthrough;
        case hwmon_curr_crit:
        case hwmon_curr_max:
                if (!resistance_uo)
index 750b087..5bd1562 100644 (file)
@@ -2669,7 +2669,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)
        case thermal_cruise:
                nct6775_write_value(data, data->REG_TARGET[nr],
                                    data->target_temp[nr]);
-               /* fall through  */
+               fallthrough;
        default:
                reg = nct6775_read_value(data, data->REG_FAN_MODE[nr]);
                reg = (reg & ~data->tolerance_mask) |
index b042569..242ff8b 100644 (file)
@@ -231,7 +231,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
                if (ret < 0)
                        return ret;
                cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
-               if (cnt == 0x1fff)
+               if (cnt == 0 || cnt == 0x1fff)
                        rpm = 0;
                else
                        rpm = 1350000 / cnt;
@@ -243,7 +243,7 @@ static int nct7904_read_fan(struct device *dev, u32 attr, int channel,
                if (ret < 0)
                        return ret;
                cnt = ((ret & 0xff00) >> 3) | (ret & 0x1f);
-               if (cnt == 0x1fff)
+               if (cnt == 0 || cnt == 0x1fff)
                        rpm = 0;
                else
                        rpm = 1350000 / cnt;
index 30e18eb..a717779 100644 (file)
@@ -752,7 +752,7 @@ static int occ_setup_sensor_attrs(struct occ *occ)
        switch (sensors->freq.version) {
        case 2:
                show_freq = occ_show_freq_2;
-               /* fall through */
+               fallthrough;
        case 1:
                num_attrs += (sensors->freq.num_sensors * 2);
                break;
@@ -763,7 +763,7 @@ static int occ_setup_sensor_attrs(struct occ *occ)
        switch (sensors->power.version) {
        case 2:
                show_power = occ_show_power_2;
-               /* fall through */
+               fallthrough;
        case 1:
                num_attrs += (sensors->power.num_sensors * 4);
                break;
@@ -781,7 +781,7 @@ static int occ_setup_sensor_attrs(struct occ *occ)
                break;
        case 3:
                show_caps = occ_show_caps_3;
-               /* fall through */
+               fallthrough;
        case 2:
                num_attrs += (sensors->caps.num_sensors * 8);
                break;
index 0c62271..58aa95a 100644 (file)
@@ -67,6 +67,7 @@ enum variants {
        raa_dmpvr1_2rail,
        raa_dmpvr2_1rail,
        raa_dmpvr2_2rail,
+       raa_dmpvr2_2rail_nontc,
        raa_dmpvr2_3rail,
        raa_dmpvr2_hv,
 };
@@ -241,6 +242,10 @@ static int isl68137_probe(struct i2c_client *client,
                info->pages = 1;
                info->read_word_data = raa_dmpvr2_read_word_data;
                break;
+       case raa_dmpvr2_2rail_nontc:
+               info->func[0] &= ~PMBUS_HAVE_TEMP;
+               info->func[1] &= ~PMBUS_HAVE_TEMP;
+               fallthrough;
        case raa_dmpvr2_2rail:
                info->pages = 2;
                info->read_word_data = raa_dmpvr2_read_word_data;
@@ -304,7 +309,7 @@ static const struct i2c_device_id raa_dmpvr_id[] = {
        {"raa228000", raa_dmpvr2_hv},
        {"raa228004", raa_dmpvr2_hv},
        {"raa228006", raa_dmpvr2_hv},
-       {"raa228228", raa_dmpvr2_2rail},
+       {"raa228228", raa_dmpvr2_2rail_nontc},
        {"raa229001", raa_dmpvr2_2rail},
        {"raa229004", raa_dmpvr2_2rail},
        {}
index e1d10a6..a07b974 100644 (file)
@@ -1213,7 +1213,7 @@ temp_type_store(struct device *dev, struct device_attribute *devattr,
        case W83781D_DEFAULT_BETA:
                dev_warn(dev, "Sensor type %d is deprecated, please use 4 "
                         "instead\n", W83781D_DEFAULT_BETA);
-               /* fall through */
+               fallthrough;
        case 4:         /* thermistor */
                tmp = w83627hf_read_value(data, W83781D_REG_SCFG1);
                w83627hf_write_value(data, W83781D_REG_SCFG1,
index 015f1ea..d833a4f 100644 (file)
@@ -814,7 +814,7 @@ store_sensor(struct device *dev, struct device_attribute *da,
                dev_warn(dev,
                         "Sensor type %d is deprecated, please use 4 instead\n",
                         W83781D_DEFAULT_BETA);
-               /* fall through */
+               fallthrough;
        case 4:         /* thermistor */
                tmp = w83781d_read_value(data, W83781D_REG_SCFG1);
                w83781d_write_value(data, W83781D_REG_SCFG1,
index 44f68b9..6d52b53 100644 (file)
@@ -2127,7 +2127,7 @@ static void w83795_apply_temp_config(struct w83795_data *data, u8 config,
                if (temp_chan >= 4)
                        break;
                data->temp_mode |= 1 << temp_chan;
-               /* fall through */
+               fallthrough;
        case 0x3: /* Thermistor */
                data->has_temp |= 1 << temp_chan;
                break;
index 02dbb5c..c119824 100644 (file)
@@ -3,7 +3,7 @@
 # Coresight configuration
 #
 menuconfig CORESIGHT
-       bool "CoreSight Tracing Support"
+       tristate "CoreSight Tracing Support"
        depends on ARM || ARM64
        depends on OF || ACPI
        select ARM_AMBA
@@ -15,17 +15,24 @@ menuconfig CORESIGHT
          specification and configure the right series of components when a
          trace source gets enabled.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight.
+
 if CORESIGHT
 config CORESIGHT_LINKS_AND_SINKS
-       bool "CoreSight Link and Sink drivers"
+       tristate "CoreSight Link and Sink drivers"
        help
          This enables support for CoreSight link and sink drivers that are
          responsible for transporting and collecting the trace data
          respectively.  Link and sinks are dynamically aggregated with a trace
          entity at run time to form a complete trace path.
 
+         To compile these drivers as modules, choose M here: the
+         modules will be called coresight-funnel and coresight-replicator.
+
 config CORESIGHT_LINK_AND_SINK_TMC
-       bool "Coresight generic TMC driver"
+       tristate "Coresight generic TMC driver"
+
        depends on CORESIGHT_LINKS_AND_SINKS
        help
          This enables support for the Trace Memory Controller driver.
@@ -34,8 +41,11 @@ config CORESIGHT_LINK_AND_SINK_TMC
          complies with the generic implementation of the component without
          special enhancement or added features.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-tmc.
+
 config CORESIGHT_CATU
-       bool "Coresight Address Translation Unit (CATU) driver"
+       tristate "Coresight Address Translation Unit (CATU) driver"
        depends on CORESIGHT_LINK_AND_SINK_TMC
        help
           Enable support for the Coresight Address Translation Unit (CATU).
@@ -45,8 +55,11 @@ config CORESIGHT_CATU
           by looking up the provided table. CATU can also be used in pass-through
           mode where the address is not translated.
 
+          To compile this driver as a module, choose M here: the
+          module will be called coresight-catu.
+
 config CORESIGHT_SINK_TPIU
-       bool "Coresight generic TPIU driver"
+       tristate "Coresight generic TPIU driver"
        depends on CORESIGHT_LINKS_AND_SINKS
        help
          This enables support for the Trace Port Interface Unit driver,
@@ -56,16 +69,22 @@ config CORESIGHT_SINK_TPIU
          connected to an external host for use case capturing more traces than
          the on-board coresight memory can handle.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-tpiu.
+
 config CORESIGHT_SINK_ETBV10
-       bool "Coresight ETBv1.0 driver"
+       tristate "Coresight ETBv1.0 driver"
        depends on CORESIGHT_LINKS_AND_SINKS
        help
          This enables support for the Embedded Trace Buffer version 1.0 driver
          that complies with the generic implementation of the component without
          special enhancement or added features.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-etb10.
+
 config CORESIGHT_SOURCE_ETM3X
-       bool "CoreSight Embedded Trace Macrocell 3.x driver"
+       tristate "CoreSight Embedded Trace Macrocell 3.x driver"
        depends on !ARM64
        select CORESIGHT_LINKS_AND_SINKS
        help
@@ -74,8 +93,11 @@ config CORESIGHT_SOURCE_ETM3X
          This is primarily useful for instruction level tracing.  Depending
          the ETM version data tracing may also be available.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-etm3x.
+
 config CORESIGHT_SOURCE_ETM4X
-       bool "CoreSight Embedded Trace Macrocell 4.x driver"
+       tristate "CoreSight Embedded Trace Macrocell 4.x driver"
        depends on ARM64
        select CORESIGHT_LINKS_AND_SINKS
        select PID_IN_CONTEXTIDR
@@ -85,8 +107,11 @@ config CORESIGHT_SOURCE_ETM4X
          for instruction level tracing. Depending on the implemented version
          data tracing may also be available.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-etm4x.
+
 config CORESIGHT_STM
-       bool "CoreSight System Trace Macrocell driver"
+       tristate "CoreSight System Trace Macrocell driver"
        depends on (ARM && !(CPU_32v3 || CPU_32v4 || CPU_32v4T)) || ARM64
        select CORESIGHT_LINKS_AND_SINKS
        select STM
@@ -96,6 +121,9 @@ config CORESIGHT_STM
          logging useful software events or data coming from various entities
          in the system, possibly running different OSs
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-stm.
+
 config CORESIGHT_CPU_DEBUG
        tristate "CoreSight CPU Debug driver"
        depends on ARM || ARM64
@@ -110,8 +138,11 @@ config CORESIGHT_CPU_DEBUG
          properly, please refer Documentation/trace/coresight/coresight-cpu-debug.rst
          for detailed description and the example for usage.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-cpu-debug.
+
 config CORESIGHT_CTI
-       bool "CoreSight Cross Trigger Interface (CTI) driver"
+       tristate "CoreSight Cross Trigger Interface (CTI) driver"
        depends on ARM || ARM64
        help
          This driver provides support for CoreSight CTI and CTM components.
@@ -122,6 +153,9 @@ config CORESIGHT_CTI
          halt compared to disabling sources and sinks normally in driver
          software.
 
+         To compile this driver as a module, choose M here: the
+         module will be called coresight-cti.
+
 config CORESIGHT_CTI_INTEGRATION_REGS
        bool "Access CTI CoreSight Integration Registers"
        depends on CORESIGHT_CTI
index 19497d1..f20e357 100644 (file)
@@ -2,22 +2,24 @@
 #
 # Makefile for CoreSight drivers.
 #
-obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o \
-                          coresight-platform.o coresight-sysfs.o
-obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \
-                                            coresight-tmc-etf.o \
-                                            coresight-tmc-etr.o
+obj-$(CONFIG_CORESIGHT) += coresight.o
+coresight-y := coresight-core.o  coresight-etm-perf.o coresight-platform.o \
+               coresight-sysfs.o
+obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o
+coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
+                     coresight-tmc-etr.o
 obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o
 obj-$(CONFIG_CORESIGHT_SINK_ETBV10) += coresight-etb10.o
 obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \
                                           coresight-replicator.o
-obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o coresight-etm-cp14.o \
-                                       coresight-etm3x-sysfs.o
-obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o \
-                                       coresight-etm4x-sysfs.o
+obj-$(CONFIG_CORESIGHT_SOURCE_ETM3X) += coresight-etm3x.o
+coresight-etm3x-y := coresight-etm3x-core.o coresight-etm-cp14.o \
+                    coresight-etm3x-sysfs.o
+obj-$(CONFIG_CORESIGHT_SOURCE_ETM4X) += coresight-etm4x.o
+coresight-etm4x-y := coresight-etm4x-core.o coresight-etm4x-sysfs.o
 obj-$(CONFIG_CORESIGHT_STM) += coresight-stm.o
 obj-$(CONFIG_CORESIGHT_CPU_DEBUG) += coresight-cpu-debug.o
 obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o
-obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o \
-                               coresight-cti-platform.o \
-                               coresight-cti-sysfs.o
+obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o
+coresight-cti-y := coresight-cti-core.o        coresight-cti-platform.o \
+                  coresight-cti-sysfs.o
index 1801804..99430f6 100644 (file)
@@ -358,7 +358,7 @@ static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata,
        return 0;
 }
 
-const struct etr_buf_operations etr_catu_buf_ops = {
+static const struct etr_buf_operations etr_catu_buf_ops = {
        .alloc = catu_alloc_etr_buf,
        .free = catu_free_etr_buf,
        .sync = catu_sync_etr_buf,
@@ -567,11 +567,21 @@ out:
        return ret;
 }
 
+static int __exit catu_remove(struct amba_device *adev)
+{
+       struct catu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       coresight_unregister(drvdata->csdev);
+       return 0;
+}
+
 static struct amba_id catu_ids[] = {
        CS_AMBA_ID(0x000bb9ee),
        {},
 };
 
+MODULE_DEVICE_TABLE(amba, catu_ids);
+
 static struct amba_driver catu_driver = {
        .drv = {
                .name                   = "coresight-catu",
@@ -579,7 +589,30 @@ static struct amba_driver catu_driver = {
                .suppress_bind_attrs    = true,
        },
        .probe                          = catu_probe,
+       .remove                         = catu_remove,
        .id_table                       = catu_ids,
 };
 
-builtin_amba_driver(catu_driver);
+static int __init catu_init(void)
+{
+       int ret;
+
+       ret = amba_driver_register(&catu_driver);
+       if (ret)
+               pr_info("Error registering catu driver\n");
+       tmc_etr_set_catu_ops(&etr_catu_buf_ops);
+       return ret;
+}
+
+static void __exit catu_exit(void)
+{
+       tmc_etr_remove_catu_ops();
+       amba_driver_unregister(&catu_driver);
+}
+
+module_init(catu_init);
+module_exit(catu_exit);
+
+MODULE_AUTHOR("Suzuki K Poulose <suzuki.poulose@arm.com>");
+MODULE_DESCRIPTION("Arm CoreSight Address Translation Unit (CATU) Driver");
+MODULE_LICENSE("GPL v2");
index 80ceee3..6160c2d 100644 (file)
@@ -108,6 +108,4 @@ static inline bool coresight_is_catu_device(struct coresight_device *csdev)
        return true;
 }
 
-extern const struct etr_buf_operations etr_catu_buf_ops;
-
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
new file mode 100644 (file)
index 0000000..6994c13
--- /dev/null
@@ -0,0 +1,1694 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/export.h>
+#include <linux/slab.h>
+#include <linux/stringhash.h>
+#include <linux/mutex.h>
+#include <linux/clk.h>
+#include <linux/coresight.h>
+#include <linux/of_platform.h>
+#include <linux/delay.h>
+#include <linux/pm_runtime.h>
+
+#include "coresight-etm-perf.h"
+#include "coresight-priv.h"
+
+static DEFINE_MUTEX(coresight_mutex);
+
+/**
+ * struct coresight_node - elements of a path, from source to sink
+ * @csdev:     Address of an element.
+ * @link:      hook to the list.
+ */
+struct coresight_node {
+       struct coresight_device *csdev;
+       struct list_head link;
+};
+
+/*
+ * When operating Coresight drivers from the sysFS interface, only a single
+ * path can exist from a tracer (associated to a CPU) to a sink.
+ */
+static DEFINE_PER_CPU(struct list_head *, tracer_path);
+
+/*
+ * As of this writing only a single STM can be found in CS topologies.  Since
+ * there is no way to know if we'll ever see more and what kind of
+ * configuration they will enact, for the time being only define a single path
+ * for STM.
+ */
+static struct list_head *stm_path;
+
+/*
+ * When losing synchronisation a new barrier packet needs to be inserted at the
+ * beginning of the data collected in a buffer.  That way the decoder knows that
+ * it needs to look for another sync sequence.
+ */
+const u32 coresight_barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
+EXPORT_SYMBOL_GPL(coresight_barrier_pkt);
+
+static const struct cti_assoc_op *cti_assoc_ops;
+
+void coresight_set_cti_ops(const struct cti_assoc_op *cti_op)
+{
+       cti_assoc_ops = cti_op;
+}
+EXPORT_SYMBOL_GPL(coresight_set_cti_ops);
+
+void coresight_remove_cti_ops(void)
+{
+       cti_assoc_ops = NULL;
+}
+EXPORT_SYMBOL_GPL(coresight_remove_cti_ops);
+
+static int coresight_id_match(struct device *dev, void *data)
+{
+       int trace_id, i_trace_id;
+       struct coresight_device *csdev, *i_csdev;
+
+       csdev = data;
+       i_csdev = to_coresight_device(dev);
+
+       /*
+        * No need to care about oneself and components that are not
+        * sources or not enabled
+        */
+       if (i_csdev == csdev || !i_csdev->enable ||
+           i_csdev->type != CORESIGHT_DEV_TYPE_SOURCE)
+               return 0;
+
+       /* Get the source ID for both compoment */
+       trace_id = source_ops(csdev)->trace_id(csdev);
+       i_trace_id = source_ops(i_csdev)->trace_id(i_csdev);
+
+       /* All you need is one */
+       if (trace_id == i_trace_id)
+               return 1;
+
+       return 0;
+}
+
+static int coresight_source_is_unique(struct coresight_device *csdev)
+{
+       int trace_id = source_ops(csdev)->trace_id(csdev);
+
+       /* this shouldn't happen */
+       if (trace_id < 0)
+               return 0;
+
+       return !bus_for_each_dev(&coresight_bustype, NULL,
+                                csdev, coresight_id_match);
+}
+
+static int coresight_find_link_inport(struct coresight_device *csdev,
+                                     struct coresight_device *parent)
+{
+       int i;
+       struct coresight_connection *conn;
+
+       for (i = 0; i < parent->pdata->nr_outport; i++) {
+               conn = &parent->pdata->conns[i];
+               if (conn->child_dev == csdev)
+                       return conn->child_port;
+       }
+
+       dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n",
+               dev_name(&parent->dev), dev_name(&csdev->dev));
+
+       return -ENODEV;
+}
+
+static int coresight_find_link_outport(struct coresight_device *csdev,
+                                      struct coresight_device *child)
+{
+       int i;
+       struct coresight_connection *conn;
+
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               conn = &csdev->pdata->conns[i];
+               if (conn->child_dev == child)
+                       return conn->outport;
+       }
+
+       dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n",
+               dev_name(&csdev->dev), dev_name(&child->dev));
+
+       return -ENODEV;
+}
+
+static inline u32 coresight_read_claim_tags(void __iomem *base)
+{
+       return readl_relaxed(base + CORESIGHT_CLAIMCLR);
+}
+
+static inline bool coresight_is_claimed_self_hosted(void __iomem *base)
+{
+       return coresight_read_claim_tags(base) == CORESIGHT_CLAIM_SELF_HOSTED;
+}
+
+static inline bool coresight_is_claimed_any(void __iomem *base)
+{
+       return coresight_read_claim_tags(base) != 0;
+}
+
+static inline void coresight_set_claim_tags(void __iomem *base)
+{
+       writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMSET);
+       isb();
+}
+
+static inline void coresight_clear_claim_tags(void __iomem *base)
+{
+       writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMCLR);
+       isb();
+}
+
+/*
+ * coresight_claim_device_unlocked : Claim the device for self-hosted usage
+ * to prevent an external tool from touching this device. As per PSCI
+ * standards, section "Preserving the execution context" => "Debug and Trace
+ * save and Restore", DBGCLAIM[1] is reserved for Self-hosted debug/trace and
+ * DBGCLAIM[0] is reserved for external tools.
+ *
+ * Called with CS_UNLOCKed for the component.
+ * Returns : 0 on success
+ */
+int coresight_claim_device_unlocked(void __iomem *base)
+{
+       if (coresight_is_claimed_any(base))
+               return -EBUSY;
+
+       coresight_set_claim_tags(base);
+       if (coresight_is_claimed_self_hosted(base))
+               return 0;
+       /* There was a race setting the tags, clean up and fail */
+       coresight_clear_claim_tags(base);
+       return -EBUSY;
+}
+EXPORT_SYMBOL_GPL(coresight_claim_device_unlocked);
+
+int coresight_claim_device(void __iomem *base)
+{
+       int rc;
+
+       CS_UNLOCK(base);
+       rc = coresight_claim_device_unlocked(base);
+       CS_LOCK(base);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(coresight_claim_device);
+
+/*
+ * coresight_disclaim_device_unlocked : Clear the claim tags for the device.
+ * Called with CS_UNLOCKed for the component.
+ */
+void coresight_disclaim_device_unlocked(void __iomem *base)
+{
+
+       if (coresight_is_claimed_self_hosted(base))
+               coresight_clear_claim_tags(base);
+       else
+               /*
+                * The external agent may have not honoured our claim
+                * and has manipulated it. Or something else has seriously
+                * gone wrong in our driver.
+                */
+               WARN_ON_ONCE(1);
+}
+EXPORT_SYMBOL_GPL(coresight_disclaim_device_unlocked);
+
+void coresight_disclaim_device(void __iomem *base)
+{
+       CS_UNLOCK(base);
+       coresight_disclaim_device_unlocked(base);
+       CS_LOCK(base);
+}
+EXPORT_SYMBOL_GPL(coresight_disclaim_device);
+
+/* enable or disable an associated CTI device of the supplied CS device */
+static int
+coresight_control_assoc_ectdev(struct coresight_device *csdev, bool enable)
+{
+       int ect_ret = 0;
+       struct coresight_device *ect_csdev = csdev->ect_dev;
+       struct module *mod;
+
+       if (!ect_csdev)
+               return 0;
+       if ((!ect_ops(ect_csdev)->enable) || (!ect_ops(ect_csdev)->disable))
+               return 0;
+
+       mod = ect_csdev->dev.parent->driver->owner;
+       if (enable) {
+               if (try_module_get(mod)) {
+                       ect_ret = ect_ops(ect_csdev)->enable(ect_csdev);
+                       if (ect_ret) {
+                               module_put(mod);
+                       } else {
+                               get_device(ect_csdev->dev.parent);
+                               csdev->ect_enabled = true;
+                       }
+               } else
+                       ect_ret = -ENODEV;
+       } else {
+               if (csdev->ect_enabled) {
+                       ect_ret = ect_ops(ect_csdev)->disable(ect_csdev);
+                       put_device(ect_csdev->dev.parent);
+                       module_put(mod);
+                       csdev->ect_enabled = false;
+               }
+       }
+
+       /* output warning if ECT enable is preventing trace operation */
+       if (ect_ret)
+               dev_info(&csdev->dev, "Associated ECT device (%s) %s failed\n",
+                        dev_name(&ect_csdev->dev),
+                        enable ? "enable" : "disable");
+       return ect_ret;
+}
+
+/*
+ * Set the associated ect / cti device while holding the coresight_mutex
+ * to avoid a race with coresight_enable that may try to use this value.
+ */
+void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev,
+                                     struct coresight_device *ect_csdev)
+{
+       mutex_lock(&coresight_mutex);
+       csdev->ect_dev = ect_csdev;
+       mutex_unlock(&coresight_mutex);
+}
+EXPORT_SYMBOL_GPL(coresight_set_assoc_ectdev_mutex);
+
+static int coresight_enable_sink(struct coresight_device *csdev,
+                                u32 mode, void *data)
+{
+       int ret;
+
+       /*
+        * We need to make sure the "new" session is compatible with the
+        * existing "mode" of operation.
+        */
+       if (!sink_ops(csdev)->enable)
+               return -EINVAL;
+
+       ret = coresight_control_assoc_ectdev(csdev, true);
+       if (ret)
+               return ret;
+       ret = sink_ops(csdev)->enable(csdev, mode, data);
+       if (ret) {
+               coresight_control_assoc_ectdev(csdev, false);
+               return ret;
+       }
+       csdev->enable = true;
+
+       return 0;
+}
+
+static void coresight_disable_sink(struct coresight_device *csdev)
+{
+       int ret;
+
+       if (!sink_ops(csdev)->disable)
+               return;
+
+       ret = sink_ops(csdev)->disable(csdev);
+       if (ret)
+               return;
+       coresight_control_assoc_ectdev(csdev, false);
+       csdev->enable = false;
+}
+
+static int coresight_enable_link(struct coresight_device *csdev,
+                                struct coresight_device *parent,
+                                struct coresight_device *child)
+{
+       int ret = 0;
+       int link_subtype;
+       int inport, outport;
+
+       if (!parent || !child)
+               return -EINVAL;
+
+       inport = coresight_find_link_inport(csdev, parent);
+       outport = coresight_find_link_outport(csdev, child);
+       link_subtype = csdev->subtype.link_subtype;
+
+       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG && inport < 0)
+               return inport;
+       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT && outport < 0)
+               return outport;
+
+       if (link_ops(csdev)->enable) {
+               ret = coresight_control_assoc_ectdev(csdev, true);
+               if (!ret) {
+                       ret = link_ops(csdev)->enable(csdev, inport, outport);
+                       if (ret)
+                               coresight_control_assoc_ectdev(csdev, false);
+               }
+       }
+
+       if (!ret)
+               csdev->enable = true;
+
+       return ret;
+}
+
+static void coresight_disable_link(struct coresight_device *csdev,
+                                  struct coresight_device *parent,
+                                  struct coresight_device *child)
+{
+       int i, nr_conns;
+       int link_subtype;
+       int inport, outport;
+
+       if (!parent || !child)
+               return;
+
+       inport = coresight_find_link_inport(csdev, parent);
+       outport = coresight_find_link_outport(csdev, child);
+       link_subtype = csdev->subtype.link_subtype;
+
+       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) {
+               nr_conns = csdev->pdata->nr_inport;
+       } else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT) {
+               nr_conns = csdev->pdata->nr_outport;
+       } else {
+               nr_conns = 1;
+       }
+
+       if (link_ops(csdev)->disable) {
+               link_ops(csdev)->disable(csdev, inport, outport);
+               coresight_control_assoc_ectdev(csdev, false);
+       }
+
+       for (i = 0; i < nr_conns; i++)
+               if (atomic_read(&csdev->refcnt[i]) != 0)
+                       return;
+
+       csdev->enable = false;
+}
+
+static int coresight_enable_source(struct coresight_device *csdev, u32 mode)
+{
+       int ret;
+
+       if (!coresight_source_is_unique(csdev)) {
+               dev_warn(&csdev->dev, "traceID %d not unique\n",
+                        source_ops(csdev)->trace_id(csdev));
+               return -EINVAL;
+       }
+
+       if (!csdev->enable) {
+               if (source_ops(csdev)->enable) {
+                       ret = coresight_control_assoc_ectdev(csdev, true);
+                       if (ret)
+                               return ret;
+                       ret = source_ops(csdev)->enable(csdev, NULL, mode);
+                       if (ret) {
+                               coresight_control_assoc_ectdev(csdev, false);
+                               return ret;
+                       };
+               }
+               csdev->enable = true;
+       }
+
+       atomic_inc(csdev->refcnt);
+
+       return 0;
+}
+
+/**
+ *  coresight_disable_source - Drop the reference count by 1 and disable
+ *  the device if there are no users left.
+ *
+ *  @csdev - The coresight device to disable
+ *
+ *  Returns true if the device has been disabled.
+ */
+static bool coresight_disable_source(struct coresight_device *csdev)
+{
+       if (atomic_dec_return(csdev->refcnt) == 0) {
+               if (source_ops(csdev)->disable)
+                       source_ops(csdev)->disable(csdev, NULL);
+               coresight_control_assoc_ectdev(csdev, false);
+               csdev->enable = false;
+       }
+       return !csdev->enable;
+}
+
+/*
+ * coresight_disable_path_from : Disable components in the given path beyond
+ * @nd in the list. If @nd is NULL, all the components, except the SOURCE are
+ * disabled.
+ */
+static void coresight_disable_path_from(struct list_head *path,
+                                       struct coresight_node *nd)
+{
+       u32 type;
+       struct coresight_device *csdev, *parent, *child;
+
+       if (!nd)
+               nd = list_first_entry(path, struct coresight_node, link);
+
+       list_for_each_entry_continue(nd, path, link) {
+               csdev = nd->csdev;
+               type = csdev->type;
+
+               /*
+                * ETF devices are tricky... They can be a link or a sink,
+                * depending on how they are configured.  If an ETF has been
+                * "activated" it will be configured as a sink, otherwise
+                * go ahead with the link configuration.
+                */
+               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
+                       type = (csdev == coresight_get_sink(path)) ?
+                                               CORESIGHT_DEV_TYPE_SINK :
+                                               CORESIGHT_DEV_TYPE_LINK;
+
+               switch (type) {
+               case CORESIGHT_DEV_TYPE_SINK:
+                       coresight_disable_sink(csdev);
+                       break;
+               case CORESIGHT_DEV_TYPE_SOURCE:
+                       /*
+                        * We skip the first node in the path assuming that it
+                        * is the source. So we don't expect a source device in
+                        * the middle of a path.
+                        */
+                       WARN_ON(1);
+                       break;
+               case CORESIGHT_DEV_TYPE_LINK:
+                       parent = list_prev_entry(nd, link)->csdev;
+                       child = list_next_entry(nd, link)->csdev;
+                       coresight_disable_link(csdev, parent, child);
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+void coresight_disable_path(struct list_head *path)
+{
+       coresight_disable_path_from(path, NULL);
+}
+EXPORT_SYMBOL_GPL(coresight_disable_path);
+
+int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data)
+{
+
+       int ret = 0;
+       u32 type;
+       struct coresight_node *nd;
+       struct coresight_device *csdev, *parent, *child;
+
+       list_for_each_entry_reverse(nd, path, link) {
+               csdev = nd->csdev;
+               type = csdev->type;
+
+               /*
+                * ETF devices are tricky... They can be a link or a sink,
+                * depending on how they are configured.  If an ETF has been
+                * "activated" it will be configured as a sink, otherwise
+                * go ahead with the link configuration.
+                */
+               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
+                       type = (csdev == coresight_get_sink(path)) ?
+                                               CORESIGHT_DEV_TYPE_SINK :
+                                               CORESIGHT_DEV_TYPE_LINK;
+
+               switch (type) {
+               case CORESIGHT_DEV_TYPE_SINK:
+                       ret = coresight_enable_sink(csdev, mode, sink_data);
+                       /*
+                        * Sink is the first component turned on. If we
+                        * failed to enable the sink, there are no components
+                        * that need disabling. Disabling the path here
+                        * would mean we could disrupt an existing session.
+                        */
+                       if (ret)
+                               goto out;
+                       break;
+               case CORESIGHT_DEV_TYPE_SOURCE:
+                       /* sources are enabled from either sysFS or Perf */
+                       break;
+               case CORESIGHT_DEV_TYPE_LINK:
+                       parent = list_prev_entry(nd, link)->csdev;
+                       child = list_next_entry(nd, link)->csdev;
+                       ret = coresight_enable_link(csdev, parent, child);
+                       if (ret)
+                               goto err;
+                       break;
+               default:
+                       goto err;
+               }
+       }
+
+out:
+       return ret;
+err:
+       coresight_disable_path_from(path, nd);
+       goto out;
+}
+
+struct coresight_device *coresight_get_sink(struct list_head *path)
+{
+       struct coresight_device *csdev;
+
+       if (!path)
+               return NULL;
+
+       csdev = list_last_entry(path, struct coresight_node, link)->csdev;
+       if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
+           csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
+               return NULL;
+
+       return csdev;
+}
+
+static struct coresight_device *
+coresight_find_enabled_sink(struct coresight_device *csdev)
+{
+       int i;
+       struct coresight_device *sink;
+
+       if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
+            csdev->activated)
+               return csdev;
+
+       /*
+        * Recursively explore each port found on this element.
+        */
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_device *child_dev;
+
+               child_dev = csdev->pdata->conns[i].child_dev;
+               if (child_dev)
+                       sink = coresight_find_enabled_sink(child_dev);
+               if (sink)
+                       return sink;
+       }
+
+       return NULL;
+}
+
+/**
+ * coresight_get_enabled_sink - returns the first enabled sink using
+ * connection based search starting from the source reference
+ *
+ * @source: Coresight source device reference
+ */
+struct coresight_device *
+coresight_get_enabled_sink(struct coresight_device *source)
+{
+       if (!source)
+               return NULL;
+
+       return coresight_find_enabled_sink(source);
+}
+
+static int coresight_sink_by_id(struct device *dev, const void *data)
+{
+       struct coresight_device *csdev = to_coresight_device(dev);
+       unsigned long hash;
+
+       if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+
+               if (!csdev->ea)
+                       return 0;
+               /*
+                * See function etm_perf_add_symlink_sink() to know where
+                * this comes from.
+                */
+               hash = (unsigned long)csdev->ea->var;
+
+               if ((u32)hash == *(u32 *)data)
+                       return 1;
+       }
+
+       return 0;
+}
+
+/**
+ * coresight_get_sink_by_id - returns the sink that matches the id
+ * @id: Id of the sink to match
+ *
+ * The name of a sink is unique, whether it is found on the AMBA bus or
+ * otherwise.  As such the hash of that name can easily be used to identify
+ * a sink.
+ */
+struct coresight_device *coresight_get_sink_by_id(u32 id)
+{
+       struct device *dev = NULL;
+
+       dev = bus_find_device(&coresight_bustype, NULL, &id,
+                             coresight_sink_by_id);
+
+       return dev ? to_coresight_device(dev) : NULL;
+}
+
+/**
+ * coresight_get_ref- Helper function to increase reference count to module
+ * and device.
+ * Return true in successful case and power up the device.
+ * Return false when failed to get reference of module.
+ */
+static inline bool coresight_get_ref(struct coresight_device *csdev)
+{
+       struct device *dev = csdev->dev.parent;
+
+       /* Make sure the driver can't be removed */
+       if (!try_module_get(dev->driver->owner))
+               return false;
+       /* Make sure the device can't go away */
+       get_device(dev);
+       pm_runtime_get_sync(dev);
+       return true;
+}
+
+/**
+ * coresight_put_ref- Helper function to decrease reference count to module
+ * and device. Power off the device.
+ */
+static inline void coresight_put_ref(struct coresight_device *csdev)
+{
+       struct device *dev = csdev->dev.parent;
+
+       pm_runtime_put(dev);
+       put_device(dev);
+       module_put(dev->driver->owner);
+}
+
+/*
+ * coresight_grab_device - Power up this device and any of the helper
+ * devices connected to it for trace operation. Since the helper devices
+ * don't appear on the trace path, they should be handled along with the
+ * the master device.
+ */
+static int coresight_grab_device(struct coresight_device *csdev)
+{
+       int i;
+
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_device *child;
+
+               child  = csdev->pdata->conns[i].child_dev;
+               if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
+                       if (!coresight_get_ref(child))
+                               goto err;
+       }
+       if (coresight_get_ref(csdev))
+               return 0;
+err:
+       for (i--; i >= 0; i--) {
+               struct coresight_device *child;
+
+               child  = csdev->pdata->conns[i].child_dev;
+               if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
+                       coresight_put_ref(child);
+       }
+       return -ENODEV;
+}
+
+/*
+ * coresight_drop_device - Release this device and any of the helper
+ * devices connected to it.
+ */
+static void coresight_drop_device(struct coresight_device *csdev)
+{
+       int i;
+
+       coresight_put_ref(csdev);
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_device *child;
+
+               child  = csdev->pdata->conns[i].child_dev;
+               if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
+                       coresight_put_ref(child);
+       }
+}
+
+/**
+ * _coresight_build_path - recursively build a path from a @csdev to a sink.
+ * @csdev:     The device to start from.
+ * @path:      The list to add devices to.
+ *
+ * The tree of Coresight device is traversed until an activated sink is
+ * found.  From there the sink is added to the list along with all the
+ * devices that led to that point - the end result is a list from source
+ * to sink. In that list the source is the first device and the sink the
+ * last one.
+ */
+static int _coresight_build_path(struct coresight_device *csdev,
+                                struct coresight_device *sink,
+                                struct list_head *path)
+{
+       int i, ret;
+       bool found = false;
+       struct coresight_node *node;
+
+       /* An activated sink has been found.  Enqueue the element */
+       if (csdev == sink)
+               goto out;
+
+       /* Not a sink - recursively explore each port found on this element */
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_device *child_dev;
+
+               child_dev = csdev->pdata->conns[i].child_dev;
+               if (child_dev &&
+                   _coresight_build_path(child_dev, sink, path) == 0) {
+                       found = true;
+                       break;
+               }
+       }
+
+       if (!found)
+               return -ENODEV;
+
+out:
+       /*
+        * A path from this element to a sink has been found.  The elements
+        * leading to the sink are already enqueued, all that is left to do
+        * is tell the PM runtime core we need this element and add a node
+        * for it.
+        */
+       ret = coresight_grab_device(csdev);
+       if (ret)
+               return ret;
+
+       node = kzalloc(sizeof(struct coresight_node), GFP_KERNEL);
+       if (!node)
+               return -ENOMEM;
+
+       node->csdev = csdev;
+       list_add(&node->link, path);
+
+       return 0;
+}
+
+struct list_head *coresight_build_path(struct coresight_device *source,
+                                      struct coresight_device *sink)
+{
+       struct list_head *path;
+       int rc;
+
+       if (!sink)
+               return ERR_PTR(-EINVAL);
+
+       path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
+       if (!path)
+               return ERR_PTR(-ENOMEM);
+
+       INIT_LIST_HEAD(path);
+
+       rc = _coresight_build_path(source, sink, path);
+       if (rc) {
+               kfree(path);
+               return ERR_PTR(rc);
+       }
+
+       return path;
+}
+
+/**
+ * coresight_release_path - release a previously built path.
+ * @path:      the path to release.
+ *
+ * Go through all the elements of a path and 1) removed it from the list and
+ * 2) free the memory allocated for each node.
+ */
+void coresight_release_path(struct list_head *path)
+{
+       struct coresight_device *csdev;
+       struct coresight_node *nd, *next;
+
+       list_for_each_entry_safe(nd, next, path, link) {
+               csdev = nd->csdev;
+
+               coresight_drop_device(csdev);
+               list_del(&nd->link);
+               kfree(nd);
+       }
+
+       kfree(path);
+       path = NULL;
+}
+
+/* return true if the device is a suitable type for a default sink */
+static inline bool coresight_is_def_sink_type(struct coresight_device *csdev)
+{
+       /* sink & correct subtype */
+       if (((csdev->type == CORESIGHT_DEV_TYPE_SINK) ||
+            (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) &&
+           (csdev->subtype.sink_subtype >= CORESIGHT_DEV_SUBTYPE_SINK_BUFFER))
+               return true;
+       return false;
+}
+
+/**
+ * coresight_select_best_sink - return the best sink for use as default from
+ * the two provided.
+ *
+ * @sink:      current best sink.
+ * @depth:      search depth where current sink was found.
+ * @new_sink:  new sink for comparison with current sink.
+ * @new_depth:  search depth where new sink was found.
+ *
+ * Sinks prioritised according to coresight_dev_subtype_sink, with only
+ * subtypes CORESIGHT_DEV_SUBTYPE_SINK_BUFFER or higher being used.
+ *
+ * Where two sinks of equal priority are found, the sink closest to the
+ * source is used (smallest search depth).
+ *
+ * return @new_sink & update @depth if better than @sink, else return @sink.
+ */
+static struct coresight_device *
+coresight_select_best_sink(struct coresight_device *sink, int *depth,
+                          struct coresight_device *new_sink, int new_depth)
+{
+       bool update = false;
+
+       if (!sink) {
+               /* first found at this level */
+               update = true;
+       } else if (new_sink->subtype.sink_subtype >
+                  sink->subtype.sink_subtype) {
+               /* found better sink */
+               update = true;
+       } else if ((new_sink->subtype.sink_subtype ==
+                   sink->subtype.sink_subtype) &&
+                  (*depth > new_depth)) {
+               /* found same but closer sink */
+               update = true;
+       }
+
+       if (update)
+               *depth = new_depth;
+       return update ? new_sink : sink;
+}
+
+/**
+ * coresight_find_sink - recursive function to walk trace connections from
+ * source to find a suitable default sink.
+ *
+ * @csdev: source / current device to check.
+ * @depth: [in] search depth of calling dev, [out] depth of found sink.
+ *
+ * This will walk the connection path from a source (ETM) till a suitable
+ * sink is encountered and return that sink to the original caller.
+ *
+ * If current device is a plain sink return that & depth, otherwise recursively
+ * call child connections looking for a sink. Select best possible using
+ * coresight_select_best_sink.
+ *
+ * return best sink found, or NULL if not found at this node or child nodes.
+ */
+static struct coresight_device *
+coresight_find_sink(struct coresight_device *csdev, int *depth)
+{
+       int i, curr_depth = *depth + 1, found_depth = 0;
+       struct coresight_device *found_sink = NULL;
+
+       if (coresight_is_def_sink_type(csdev)) {
+               found_depth = curr_depth;
+               found_sink = csdev;
+               if (csdev->type == CORESIGHT_DEV_TYPE_SINK)
+                       goto return_def_sink;
+               /* look past LINKSINK for something better */
+       }
+
+       /*
+        * Not a sink we want - or possible child sink may be better.
+        * recursively explore each port found on this element.
+        */
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_device *child_dev, *sink = NULL;
+               int child_depth = curr_depth;
+
+               child_dev = csdev->pdata->conns[i].child_dev;
+               if (child_dev)
+                       sink = coresight_find_sink(child_dev, &child_depth);
+
+               if (sink)
+                       found_sink = coresight_select_best_sink(found_sink,
+                                                               &found_depth,
+                                                               sink,
+                                                               child_depth);
+       }
+
+return_def_sink:
+       /* return found sink and depth */
+       if (found_sink)
+               *depth = found_depth;
+       return found_sink;
+}
+
+/**
+ * coresight_find_default_sink: Find a sink suitable for use as a
+ * default sink.
+ *
+ * @csdev: starting source to find a connected sink.
+ *
+ * Walks connections graph looking for a suitable sink to enable for the
+ * supplied source. Uses CoreSight device subtypes and distance from source
+ * to select the best sink.
+ *
+ * If a sink is found, then the default sink for this device is set and
+ * will be automatically used in future.
+ *
+ * Used in cases where the CoreSight user (perf / sysfs) has not selected a
+ * sink.
+ */
+struct coresight_device *
+coresight_find_default_sink(struct coresight_device *csdev)
+{
+       int depth = 0;
+
+       /* look for a default sink if we have not found for this device */
+       if (!csdev->def_sink)
+               csdev->def_sink = coresight_find_sink(csdev, &depth);
+       return csdev->def_sink;
+}
+
+static int coresight_remove_sink_ref(struct device *dev, void *data)
+{
+       struct coresight_device *sink = data;
+       struct coresight_device *source = to_coresight_device(dev);
+
+       if (source->def_sink == sink)
+               source->def_sink = NULL;
+       return 0;
+}
+
+/**
+ * coresight_clear_default_sink: Remove all default sink references to the
+ * supplied sink.
+ *
+ * If supplied device is a sink, then check all the bus devices and clear
+ * out all the references to this sink from the coresight_device def_sink
+ * parameter.
+ *
+ * @csdev: coresight sink - remove references to this from all sources.
+ */
+static void coresight_clear_default_sink(struct coresight_device *csdev)
+{
+       if ((csdev->type == CORESIGHT_DEV_TYPE_SINK) ||
+           (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) {
+               bus_for_each_dev(&coresight_bustype, NULL, csdev,
+                                coresight_remove_sink_ref);
+       }
+}
+
+/** coresight_validate_source - make sure a source has the right credentials
+ *  @csdev:    the device structure for a source.
+ *  @function: the function this was called from.
+ *
+ * Assumes the coresight_mutex is held.
+ */
+static int coresight_validate_source(struct coresight_device *csdev,
+                                    const char *function)
+{
+       u32 type, subtype;
+
+       type = csdev->type;
+       subtype = csdev->subtype.source_subtype;
+
+       if (type != CORESIGHT_DEV_TYPE_SOURCE) {
+               dev_err(&csdev->dev, "wrong device type in %s\n", function);
+               return -EINVAL;
+       }
+
+       if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC &&
+           subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) {
+               dev_err(&csdev->dev, "wrong device subtype in %s\n", function);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+int coresight_enable(struct coresight_device *csdev)
+{
+       int cpu, ret = 0;
+       struct coresight_device *sink;
+       struct list_head *path;
+       enum coresight_dev_subtype_source subtype;
+
+       subtype = csdev->subtype.source_subtype;
+
+       mutex_lock(&coresight_mutex);
+
+       ret = coresight_validate_source(csdev, __func__);
+       if (ret)
+               goto out;
+
+       if (csdev->enable) {
+               /*
+                * There could be multiple applications driving the software
+                * source. So keep the refcount for each such user when the
+                * source is already enabled.
+                */
+               if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
+                       atomic_inc(csdev->refcnt);
+               goto out;
+       }
+
+       sink = coresight_get_enabled_sink(csdev);
+       if (!sink) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       path = coresight_build_path(csdev, sink);
+       if (IS_ERR(path)) {
+               pr_err("building path(s) failed\n");
+               ret = PTR_ERR(path);
+               goto out;
+       }
+
+       ret = coresight_enable_path(path, CS_MODE_SYSFS, NULL);
+       if (ret)
+               goto err_path;
+
+       ret = coresight_enable_source(csdev, CS_MODE_SYSFS);
+       if (ret)
+               goto err_source;
+
+       switch (subtype) {
+       case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
+               /*
+                * When working from sysFS it is important to keep track
+                * of the paths that were created so that they can be
+                * undone in 'coresight_disable()'.  Since there can only
+                * be a single session per tracer (when working from sysFS)
+                * a per-cpu variable will do just fine.
+                */
+               cpu = source_ops(csdev)->cpu_id(csdev);
+               per_cpu(tracer_path, cpu) = path;
+               break;
+       case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
+               stm_path = path;
+               break;
+       default:
+               /* We can't be here */
+               break;
+       }
+
+out:
+       mutex_unlock(&coresight_mutex);
+       return ret;
+
+err_source:
+       coresight_disable_path(path);
+
+err_path:
+       coresight_release_path(path);
+       goto out;
+}
+EXPORT_SYMBOL_GPL(coresight_enable);
+
+void coresight_disable(struct coresight_device *csdev)
+{
+       int cpu, ret;
+       struct list_head *path = NULL;
+
+       mutex_lock(&coresight_mutex);
+
+       ret = coresight_validate_source(csdev, __func__);
+       if (ret)
+               goto out;
+
+       if (!csdev->enable || !coresight_disable_source(csdev))
+               goto out;
+
+       switch (csdev->subtype.source_subtype) {
+       case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
+               cpu = source_ops(csdev)->cpu_id(csdev);
+               path = per_cpu(tracer_path, cpu);
+               per_cpu(tracer_path, cpu) = NULL;
+               break;
+       case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
+               path = stm_path;
+               stm_path = NULL;
+               break;
+       default:
+               /* We can't be here */
+               break;
+       }
+
+       coresight_disable_path(path);
+       coresight_release_path(path);
+
+out:
+       mutex_unlock(&coresight_mutex);
+}
+EXPORT_SYMBOL_GPL(coresight_disable);
+
+static ssize_t enable_sink_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct coresight_device *csdev = to_coresight_device(dev);
+
+       return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->activated);
+}
+
+static ssize_t enable_sink_store(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t size)
+{
+       int ret;
+       unsigned long val;
+       struct coresight_device *csdev = to_coresight_device(dev);
+
+       ret = kstrtoul(buf, 10, &val);
+       if (ret)
+               return ret;
+
+       if (val)
+               csdev->activated = true;
+       else
+               csdev->activated = false;
+
+       return size;
+
+}
+static DEVICE_ATTR_RW(enable_sink);
+
+static ssize_t enable_source_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
+{
+       struct coresight_device *csdev = to_coresight_device(dev);
+
+       return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->enable);
+}
+
+static ssize_t enable_source_store(struct device *dev,
+                                  struct device_attribute *attr,
+                                  const char *buf, size_t size)
+{
+       int ret = 0;
+       unsigned long val;
+       struct coresight_device *csdev = to_coresight_device(dev);
+
+       ret = kstrtoul(buf, 10, &val);
+       if (ret)
+               return ret;
+
+       if (val) {
+               ret = coresight_enable(csdev);
+               if (ret)
+                       return ret;
+       } else {
+               coresight_disable(csdev);
+       }
+
+       return size;
+}
+static DEVICE_ATTR_RW(enable_source);
+
+static struct attribute *coresight_sink_attrs[] = {
+       &dev_attr_enable_sink.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(coresight_sink);
+
+static struct attribute *coresight_source_attrs[] = {
+       &dev_attr_enable_source.attr,
+       NULL,
+};
+ATTRIBUTE_GROUPS(coresight_source);
+
+static struct device_type coresight_dev_type[] = {
+       {
+               .name = "none",
+       },
+       {
+               .name = "sink",
+               .groups = coresight_sink_groups,
+       },
+       {
+               .name = "link",
+       },
+       {
+               .name = "linksink",
+               .groups = coresight_sink_groups,
+       },
+       {
+               .name = "source",
+               .groups = coresight_source_groups,
+       },
+       {
+               .name = "helper",
+       },
+       {
+               .name = "ect",
+       },
+};
+
+static void coresight_device_release(struct device *dev)
+{
+       struct coresight_device *csdev = to_coresight_device(dev);
+
+       fwnode_handle_put(csdev->dev.fwnode);
+       kfree(csdev->refcnt);
+       kfree(csdev);
+}
+
+static int coresight_orphan_match(struct device *dev, void *data)
+{
+       int i, ret = 0;
+       bool still_orphan = false;
+       struct coresight_device *csdev, *i_csdev;
+       struct coresight_connection *conn;
+
+       csdev = data;
+       i_csdev = to_coresight_device(dev);
+
+       /* No need to check oneself */
+       if (csdev == i_csdev)
+               return 0;
+
+       /* Move on to another component if no connection is orphan */
+       if (!i_csdev->orphan)
+               return 0;
+       /*
+        * Circle throuch all the connection of that component.  If we find
+        * an orphan connection whose name matches @csdev, link it.
+        */
+       for (i = 0; i < i_csdev->pdata->nr_outport; i++) {
+               conn = &i_csdev->pdata->conns[i];
+
+               /* Skip the port if FW doesn't describe it */
+               if (!conn->child_fwnode)
+                       continue;
+               /* We have found at least one orphan connection */
+               if (conn->child_dev == NULL) {
+                       /* Does it match this newly added device? */
+                       if (conn->child_fwnode == csdev->dev.fwnode) {
+                               ret = coresight_make_links(i_csdev,
+                                                          conn, csdev);
+                               if (ret)
+                                       return ret;
+                       } else {
+                               /* This component still has an orphan */
+                               still_orphan = true;
+                       }
+               }
+       }
+
+       i_csdev->orphan = still_orphan;
+
+       /*
+        * Returning '0' in case we didn't encounter any error,
+        * ensures that all known component on the bus will be checked.
+        */
+       return 0;
+}
+
+static int coresight_fixup_orphan_conns(struct coresight_device *csdev)
+{
+       return bus_for_each_dev(&coresight_bustype, NULL,
+                        csdev, coresight_orphan_match);
+}
+
+
+static int coresight_fixup_device_conns(struct coresight_device *csdev)
+{
+       int i, ret = 0;
+
+       for (i = 0; i < csdev->pdata->nr_outport; i++) {
+               struct coresight_connection *conn = &csdev->pdata->conns[i];
+
+               if (!conn->child_fwnode)
+                       continue;
+               conn->child_dev =
+                       coresight_find_csdev_by_fwnode(conn->child_fwnode);
+               if (conn->child_dev) {
+                       ret = coresight_make_links(csdev, conn,
+                                                  conn->child_dev);
+                       if (ret)
+                               break;
+               } else {
+                       csdev->orphan = true;
+               }
+       }
+
+       return 0;
+}
+
+static int coresight_remove_match(struct device *dev, void *data)
+{
+       int i;
+       struct coresight_device *csdev, *iterator;
+       struct coresight_connection *conn;
+
+       csdev = data;
+       iterator = to_coresight_device(dev);
+
+       /* No need to check oneself */
+       if (csdev == iterator)
+               return 0;
+
+       /*
+        * Circle throuch all the connection of that component.  If we find
+        * a connection whose name matches @csdev, remove it.
+        */
+       for (i = 0; i < iterator->pdata->nr_outport; i++) {
+               conn = &iterator->pdata->conns[i];
+
+               if (conn->child_dev == NULL || conn->child_fwnode == NULL)
+                       continue;
+
+               if (csdev->dev.fwnode == conn->child_fwnode) {
+                       iterator->orphan = true;
+                       coresight_remove_links(iterator, conn);
+                       /*
+                        * Drop the reference to the handle for the remote
+                        * device acquired in parsing the connections from
+                        * platform data.
+                        */
+                       fwnode_handle_put(conn->child_fwnode);
+                       /* No need to continue */
+                       break;
+               }
+       }
+
+       /*
+        * Returning '0' ensures that all known component on the
+        * bus will be checked.
+        */
+       return 0;
+}
+
+/*
+ * coresight_remove_conns - Remove references to this given devices
+ * from the connections of other devices.
+ */
+static void coresight_remove_conns(struct coresight_device *csdev)
+{
+       /*
+        * Another device will point to this device only if there is
+        * an output port connected to this one. i.e, if the device
+        * doesn't have at least one input port, there is no point
+        * in searching all the devices.
+        */
+       if (csdev->pdata->nr_inport)
+               bus_for_each_dev(&coresight_bustype, NULL,
+                                csdev, coresight_remove_match);
+}
+
+/**
+ * coresight_timeout - loop until a bit has changed to a specific state.
+ * @addr: base address of the area of interest.
+ * @offset: address of a register, starting from @addr.
+ * @position: the position of the bit of interest.
+ * @value: the value the bit should have.
+ *
+ * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if
+ * TIMEOUT_US has elapsed, which ever happens first.
+ */
+
+int coresight_timeout(void __iomem *addr, u32 offset, int position, int value)
+{
+       int i;
+       u32 val;
+
+       for (i = TIMEOUT_US; i > 0; i--) {
+               val = __raw_readl(addr + offset);
+               /* waiting on the bit to go from 0 to 1 */
+               if (value) {
+                       if (val & BIT(position))
+                               return 0;
+               /* waiting on the bit to go from 1 to 0 */
+               } else {
+                       if (!(val & BIT(position)))
+                               return 0;
+               }
+
+               /*
+                * Delay is arbitrary - the specification doesn't say how long
+                * we are expected to wait.  Extra check required to make sure
+                * we don't wait needlessly on the last iteration.
+                */
+               if (i - 1)
+                       udelay(1);
+       }
+
+       return -EAGAIN;
+}
+EXPORT_SYMBOL_GPL(coresight_timeout);
+
+/*
+ * coresight_release_platform_data: Release references to the devices connected
+ * to the output port of this device.
+ */
+void coresight_release_platform_data(struct coresight_device *csdev,
+                                    struct coresight_platform_data *pdata)
+{
+       int i;
+       struct coresight_connection *conns = pdata->conns;
+
+       for (i = 0; i < pdata->nr_outport; i++) {
+               /* If we have made the links, remove them now */
+               if (csdev && conns[i].child_dev)
+                       coresight_remove_links(csdev, &conns[i]);
+               /*
+                * Drop the refcount and clear the handle as this device
+                * is going away
+                */
+               if (conns[i].child_fwnode) {
+                       fwnode_handle_put(conns[i].child_fwnode);
+                       pdata->conns[i].child_fwnode = NULL;
+               }
+       }
+       if (csdev)
+               coresight_remove_conns_sysfs_group(csdev);
+}
+
+struct coresight_device *coresight_register(struct coresight_desc *desc)
+{
+       int ret;
+       int link_subtype;
+       int nr_refcnts = 1;
+       atomic_t *refcnts = NULL;
+       struct coresight_device *csdev;
+
+       csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
+       if (!csdev) {
+               ret = -ENOMEM;
+               goto err_out;
+       }
+
+       if (desc->type == CORESIGHT_DEV_TYPE_LINK ||
+           desc->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+               link_subtype = desc->subtype.link_subtype;
+
+               if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG)
+                       nr_refcnts = desc->pdata->nr_inport;
+               else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT)
+                       nr_refcnts = desc->pdata->nr_outport;
+       }
+
+       refcnts = kcalloc(nr_refcnts, sizeof(*refcnts), GFP_KERNEL);
+       if (!refcnts) {
+               ret = -ENOMEM;
+               goto err_free_csdev;
+       }
+
+       csdev->refcnt = refcnts;
+
+       csdev->pdata = desc->pdata;
+
+       csdev->type = desc->type;
+       csdev->subtype = desc->subtype;
+       csdev->ops = desc->ops;
+       csdev->orphan = false;
+
+       csdev->dev.type = &coresight_dev_type[desc->type];
+       csdev->dev.groups = desc->groups;
+       csdev->dev.parent = desc->dev;
+       csdev->dev.release = coresight_device_release;
+       csdev->dev.bus = &coresight_bustype;
+       /*
+        * Hold the reference to our parent device. This will be
+        * dropped only in coresight_device_release().
+        */
+       csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev));
+       dev_set_name(&csdev->dev, "%s", desc->name);
+
+       ret = device_register(&csdev->dev);
+       if (ret) {
+               put_device(&csdev->dev);
+               /*
+                * All resources are free'd explicitly via
+                * coresight_device_release(), triggered from put_device().
+                */
+               goto err_out;
+       }
+
+       if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
+           csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
+               ret = etm_perf_add_symlink_sink(csdev);
+
+               if (ret) {
+                       device_unregister(&csdev->dev);
+                       /*
+                        * As with the above, all resources are free'd
+                        * explicitly via coresight_device_release() triggered
+                        * from put_device(), which is in turn called from
+                        * function device_unregister().
+                        */
+                       goto err_out;
+               }
+       }
+
+       mutex_lock(&coresight_mutex);
+
+       ret = coresight_create_conns_sysfs_group(csdev);
+       if (!ret)
+               ret = coresight_fixup_device_conns(csdev);
+       if (!ret)
+               ret = coresight_fixup_orphan_conns(csdev);
+       if (!ret && cti_assoc_ops && cti_assoc_ops->add)
+               cti_assoc_ops->add(csdev);
+
+       mutex_unlock(&coresight_mutex);
+       if (ret) {
+               coresight_unregister(csdev);
+               return ERR_PTR(ret);
+       }
+
+       return csdev;
+
+err_free_csdev:
+       kfree(csdev);
+err_out:
+       /* Cleanup the connection information */
+       coresight_release_platform_data(NULL, desc->pdata);
+       return ERR_PTR(ret);
+}
+EXPORT_SYMBOL_GPL(coresight_register);
+
+void coresight_unregister(struct coresight_device *csdev)
+{
+       etm_perf_del_symlink_sink(csdev);
+       /* Remove references of that device in the topology */
+       if (cti_assoc_ops && cti_assoc_ops->remove)
+               cti_assoc_ops->remove(csdev);
+       coresight_remove_conns(csdev);
+       coresight_clear_default_sink(csdev);
+       coresight_release_platform_data(csdev, csdev->pdata);
+       device_unregister(&csdev->dev);
+}
+EXPORT_SYMBOL_GPL(coresight_unregister);
+
+
+/*
+ * coresight_search_device_idx - Search the fwnode handle of a device
+ * in the given dev_idx list. Must be called with the coresight_mutex held.
+ *
+ * Returns the index of the entry, when found. Otherwise, -ENOENT.
+ */
+static inline int coresight_search_device_idx(struct coresight_dev_list *dict,
+                                             struct fwnode_handle *fwnode)
+{
+       int i;
+
+       for (i = 0; i < dict->nr_idx; i++)
+               if (dict->fwnode_list[i] == fwnode)
+                       return i;
+       return -ENOENT;
+}
+
+bool coresight_loses_context_with_cpu(struct device *dev)
+{
+       return fwnode_property_present(dev_fwnode(dev),
+                                      "arm,coresight-loses-context-with-cpu");
+}
+EXPORT_SYMBOL_GPL(coresight_loses_context_with_cpu);
+
+/*
+ * coresight_alloc_device_name - Get an index for a given device in the
+ * device index list specific to a driver. An index is allocated for a
+ * device and is tracked with the fwnode_handle to prevent allocating
+ * duplicate indices for the same device (e.g, if we defer probing of
+ * a device due to dependencies), in case the index is requested again.
+ */
+char *coresight_alloc_device_name(struct coresight_dev_list *dict,
+                                 struct device *dev)
+{
+       int idx;
+       char *name = NULL;
+       struct fwnode_handle **list;
+
+       mutex_lock(&coresight_mutex);
+
+       idx = coresight_search_device_idx(dict, dev_fwnode(dev));
+       if (idx < 0) {
+               /* Make space for the new entry */
+               idx = dict->nr_idx;
+               list = krealloc(dict->fwnode_list,
+                               (idx + 1) * sizeof(*dict->fwnode_list),
+                               GFP_KERNEL);
+               if (ZERO_OR_NULL_PTR(list)) {
+                       idx = -ENOMEM;
+                       goto done;
+               }
+
+               list[idx] = dev_fwnode(dev);
+               dict->fwnode_list = list;
+               dict->nr_idx = idx + 1;
+       }
+
+       name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
+done:
+       mutex_unlock(&coresight_mutex);
+       return name;
+}
+EXPORT_SYMBOL_GPL(coresight_alloc_device_name);
+
+struct bus_type coresight_bustype = {
+       .name   = "coresight",
+};
+
+static int __init coresight_init(void)
+{
+       int ret;
+
+       ret = bus_register(&coresight_bustype);
+       if (ret)
+               return ret;
+
+       ret = etm_perf_init();
+       if (ret)
+               bus_unregister(&coresight_bustype);
+
+       return ret;
+}
+
+static void __exit coresight_exit(void)
+{
+       etm_perf_exit();
+       bus_unregister(&coresight_bustype);
+}
+
+module_init(coresight_init);
+module_exit(coresight_exit);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight tracer driver");
index 96544b3..e1d2324 100644 (file)
@@ -346,10 +346,10 @@ static void debug_init_arch_data(void *info)
        switch (mode) {
        case EDDEVID_IMPL_FULL:
                drvdata->edvidsr_present = true;
-               /* Fall through */
+               fallthrough;
        case EDDEVID_IMPL_EDPCSR_EDCIDSR:
                drvdata->edcidsr_present = true;
-               /* Fall through */
+               fallthrough;
        case EDDEVID_IMPL_EDPCSR:
                /*
                 * In ARM DDI 0487A.k, the EDDEVID1.PCSROffset is used to
@@ -665,6 +665,8 @@ static const struct amba_id debug_ids[] = {
        {},
 };
 
+MODULE_DEVICE_TABLE(amba, debug_ids);
+
 static struct amba_driver debug_driver = {
        .drv = {
                .name   = "coresight-cpu-debug",
diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c
new file mode 100644 (file)
index 0000000..d28eae9
--- /dev/null
@@ -0,0 +1,1006 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018 Linaro Limited, All rights reserved.
+ * Author: Mike Leach <mike.leach@linaro.org>
+ */
+
+#include <linux/amba/bus.h>
+#include <linux/atomic.h>
+#include <linux/bits.h>
+#include <linux/coresight.h>
+#include <linux/cpu_pm.h>
+#include <linux/cpuhotplug.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/pm_runtime.h>
+#include <linux/property.h>
+#include <linux/spinlock.h>
+
+#include "coresight-priv.h"
+#include "coresight-cti.h"
+
+/**
+ * CTI devices can be associated with a PE, or be connected to CoreSight
+ * hardware. We have a list of all CTIs irrespective of CPU bound or
+ * otherwise.
+ *
+ * We assume that the non-CPU CTIs are always powered as we do with sinks etc.
+ *
+ * We leave the client to figure out if all the CTIs are interconnected with
+ * the same CTM, in general this is the case but does not always have to be.
+ */
+
+/* net of CTI devices connected via CTM */
+static LIST_HEAD(ect_net);
+
+/* protect the list */
+static DEFINE_MUTEX(ect_mutex);
+
+#define csdev_to_cti_drvdata(csdev)    \
+       dev_get_drvdata(csdev->dev.parent)
+
+/* power management handling */
+static int nr_cti_cpu;
+
+/* quick lookup list for CPU bound CTIs when power handling */
+static struct cti_drvdata *cti_cpu_drvdata[NR_CPUS];
+
+/*
+ * CTI naming. CTI bound to cores will have the name cti_cpu<N> where
+ * N is the CPU ID. System CTIs will have the name cti_sys<I> where I
+ * is an index allocated by order of discovery.
+ *
+ * CTI device name list - for CTI not bound to cores.
+ */
+DEFINE_CORESIGHT_DEVLIST(cti_sys_devs, "cti_sys");
+
+/* write set of regs to hardware - call with spinlock claimed */
+void cti_write_all_hw_regs(struct cti_drvdata *drvdata)
+{
+       struct cti_config *config = &drvdata->config;
+       int i;
+
+       CS_UNLOCK(drvdata->base);
+
+       /* disable CTI before writing registers */
+       writel_relaxed(0, drvdata->base + CTICONTROL);
+
+       /* write the CTI trigger registers */
+       for (i = 0; i < config->nr_trig_max; i++) {
+               writel_relaxed(config->ctiinen[i], drvdata->base + CTIINEN(i));
+               writel_relaxed(config->ctiouten[i],
+                              drvdata->base + CTIOUTEN(i));
+       }
+
+       /* other regs */
+       writel_relaxed(config->ctigate, drvdata->base + CTIGATE);
+       writel_relaxed(config->asicctl, drvdata->base + ASICCTL);
+       writel_relaxed(config->ctiappset, drvdata->base + CTIAPPSET);
+
+       /* re-enable CTI */
+       writel_relaxed(1, drvdata->base + CTICONTROL);
+
+       CS_LOCK(drvdata->base);
+}
+
+/* write regs to hardware and enable */
+static int cti_enable_hw(struct cti_drvdata *drvdata)
+{
+       struct cti_config *config = &drvdata->config;
+       struct device *dev = &drvdata->csdev->dev;
+       unsigned long flags;
+       int rc = 0;
+
+       pm_runtime_get_sync(dev->parent);
+       spin_lock_irqsave(&drvdata->spinlock, flags);
+
+       /* no need to do anything if enabled or unpowered*/
+       if (config->hw_enabled || !config->hw_powered)
+               goto cti_state_unchanged;
+
+       /* claim the device */
+       rc = coresight_claim_device(drvdata->base);
+       if (rc)
+               goto cti_err_not_enabled;
+
+       cti_write_all_hw_regs(drvdata);
+
+       config->hw_enabled = true;
+       atomic_inc(&drvdata->config.enable_req_count);
+       spin_unlock_irqrestore(&drvdata->spinlock, flags);
+       return rc;
+
+cti_state_unchanged:
+       atomic_inc(&drvdata->config.enable_req_count);
+
+       /* cannot enable due to error */
+cti_err_not_enabled:
+       spin_unlock_irqrestore(&drvdata->spinlock, flags);
+       pm_runtime_put(dev->parent);
+       return rc;
+}
+
+/* re-enable CTI on CPU when using CPU hotplug */
+static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
+{
+       struct cti_config *config = &drvdata->config;
+
+       spin_lock(&drvdata->spinlock);
+       config->hw_powered = true;
+
+       /* no need to do anything if no enable request */
+       if (!atomic_read(&drvdata->config.enable_req_count))
+               goto cti_hp_not_enabled;
+
+       /* try to claim the device */
+       if (coresight_claim_device(drvdata->base))
+               goto cti_hp_not_enabled;
+
+       cti_write_all_hw_regs(drvdata);
+       config->hw_enabled = true;
+       spin_unlock(&drvdata->spinlock);
+       return;
+
+       /* did not re-enable due to no claim / no request */
+cti_hp_not_enabled:
+       spin_unlock(&drvdata->spinlock);
+}
+
+/* disable hardware */
+static int cti_disable_hw(struct cti_drvdata *drvdata)
+{
+       struct cti_config *config = &drvdata->config;
+       struct device *dev = &drvdata->csdev->dev;
+
+       spin_lock(&drvdata->spinlock);
+
+       /* check refcount - disable on 0 */
+       if (atomic_dec_return(&drvdata->config.enable_req_count) > 0)
+               goto cti_not_disabled;
+
+       /* no need to do anything if disabled or cpu unpowered */
+       if (!config->hw_enabled || !config->hw_powered)
+               goto cti_not_disabled;
+
+       CS_UNLOCK(drvdata->base);
+
+       /* disable CTI */
+       writel_relaxed(0, drvdata->base + CTICONTROL);
+       config->hw_enabled = false;
+
+       coresight_disclaim_device_unlocked(drvdata->base);
+       CS_LOCK(drvdata->base);
+       spin_unlock(&drvdata->spinlock);
+       pm_runtime_put(dev);
+       return 0;
+
+       /* not disabled this call */
+cti_not_disabled:
+       spin_unlock(&drvdata->spinlock);
+       return 0;
+}
+
+void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value)
+{
+       CS_UNLOCK(drvdata->base);
+       writel_relaxed(value, drvdata->base + offset);
+       CS_LOCK(drvdata->base);
+}
+
+void cti_write_intack(struct device *dev, u32 ackval)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       struct cti_config *config = &drvdata->config;
+
+       spin_lock(&drvdata->spinlock);
+       /* write if enabled */
+       if (cti_active(config))
+               cti_write_single_reg(drvdata, CTIINTACK, ackval);
+       spin_unlock(&drvdata->spinlock);
+}
+
+/*
+ * Look at the HW DEVID register for some of the HW settings.
+ * DEVID[15:8] - max number of in / out triggers.
+ */
+#define CTI_DEVID_MAXTRIGS(devid_val) ((int) BMVAL(devid_val, 8, 15))
+
+/* DEVID[19:16] - number of CTM channels */
+#define CTI_DEVID_CTMCHANNELS(devid_val) ((int) BMVAL(devid_val, 16, 19))
+
+static void cti_set_default_config(struct device *dev,
+                                  struct cti_drvdata *drvdata)
+{
+       struct cti_config *config = &drvdata->config;
+       u32 devid;
+
+       devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
+       config->nr_trig_max = CTI_DEVID_MAXTRIGS(devid);
+
+       /*
+        * no current hardware should exceed this, but protect the driver
+        * in case of fault / out of spec hw
+        */
+       if (config->nr_trig_max > CTIINOUTEN_MAX) {
+               dev_warn_once(dev,
+                       "Limiting HW MaxTrig value(%d) to driver max(%d)\n",
+                       config->nr_trig_max, CTIINOUTEN_MAX);
+               config->nr_trig_max = CTIINOUTEN_MAX;
+       }
+
+       config->nr_ctm_channels = CTI_DEVID_CTMCHANNELS(devid);
+
+       /* Most regs default to 0 as zalloc'ed except...*/
+       config->trig_filter_enable = true;
+       config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0);
+       atomic_set(&config->enable_req_count, 0);
+}
+
+/*
+ * Add a connection entry to the list of connections for this
+ * CTI device.
+ */
+int cti_add_connection_entry(struct device *dev, struct cti_drvdata *drvdata,
+                            struct cti_trig_con *tc,
+                            struct coresight_device *csdev,
+                            const char *assoc_dev_name)
+{
+       struct cti_device *cti_dev = &drvdata->ctidev;
+
+       tc->con_dev = csdev;
+       /*
+        * Prefer actual associated CS device dev name to supplied value -
+        * which is likely to be node name / other conn name.
+        */
+       if (csdev)
+               tc->con_dev_name = dev_name(&csdev->dev);
+       else if (assoc_dev_name != NULL) {
+               tc->con_dev_name = devm_kstrdup(dev,
+                                               assoc_dev_name, GFP_KERNEL);
+               if (!tc->con_dev_name)
+                       return -ENOMEM;
+       }
+       list_add_tail(&tc->node, &cti_dev->trig_cons);
+       cti_dev->nr_trig_con++;
+
+       /* add connection usage bit info to overall info */
+       drvdata->config.trig_in_use |= tc->con_in->used_mask;
+       drvdata->config.trig_out_use |= tc->con_out->used_mask;
+
+       return 0;
+}
+
+/* create a trigger connection with appropriately sized signal groups */
+struct cti_trig_con *cti_allocate_trig_con(struct device *dev, int in_sigs,
+                                          int out_sigs)
+{
+       struct cti_trig_con *tc = NULL;
+       struct cti_trig_grp *in = NULL, *out = NULL;
+
+       tc = devm_kzalloc(dev, sizeof(struct cti_trig_con), GFP_KERNEL);
+       if (!tc)
+               return tc;
+
+       in = devm_kzalloc(dev,
+                         offsetof(struct cti_trig_grp, sig_types[in_sigs]),
+                         GFP_KERNEL);
+       if (!in)
+               return NULL;
+
+       out = devm_kzalloc(dev,
+                          offsetof(struct cti_trig_grp, sig_types[out_sigs]),
+                          GFP_KERNEL);
+       if (!out)
+               return NULL;
+
+       tc->con_in = in;
+       tc->con_out = out;
+       tc->con_in->nr_sigs = in_sigs;
+       tc->con_out->nr_sigs = out_sigs;
+       return tc;
+}
+
+/*
+ * Add a default connection if nothing else is specified.
+ * single connection based on max in/out info, no assoc device
+ */
+int cti_add_default_connection(struct device *dev, struct cti_drvdata *drvdata)
+{
+       int ret = 0;
+       int n_trigs = drvdata->config.nr_trig_max;
+       u32 n_trig_mask = GENMASK(n_trigs - 1, 0);
+       struct cti_trig_con *tc = NULL;
+
+       /*
+        * Assume max trigs for in and out,
+        * all used, default sig types allocated
+        */
+       tc = cti_allocate_trig_con(dev, n_trigs, n_trigs);
+       if (!tc)
+               return -ENOMEM;
+
+       tc->con_in->used_mask = n_trig_mask;
+       tc->con_out->used_mask = n_trig_mask;
+       ret = cti_add_connection_entry(dev, drvdata, tc, NULL, "default");
+       return ret;
+}
+
+/** cti channel api **/
+/* attach/detach channel from trigger - write through if enabled. */
+int cti_channel_trig_op(struct device *dev, enum cti_chan_op op,
+                       enum cti_trig_dir direction, u32 channel_idx,
+                       u32 trigger_idx)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       struct cti_config *config = &drvdata->config;
+       u32 trig_bitmask;
+       u32 chan_bitmask;
+       u32 reg_value;
+       int reg_offset;
+
+       /* ensure indexes in range */
+       if ((channel_idx >= config->nr_ctm_channels) ||
+          (trigger_idx >= config->nr_trig_max))
+               return -EINVAL;
+
+       trig_bitmask = BIT(trigger_idx);
+
+       /* ensure registered triggers and not out filtered */
+       if (direction == CTI_TRIG_IN)   {
+               if (!(trig_bitmask & config->trig_in_use))
+                       return -EINVAL;
+       } else {
+               if (!(trig_bitmask & config->trig_out_use))
+                       return -EINVAL;
+
+               if ((config->trig_filter_enable) &&
+                   (config->trig_out_filter & trig_bitmask))
+                       return -EINVAL;
+       }
+
+       /* update the local register values */
+       chan_bitmask = BIT(channel_idx);
+       reg_offset = (direction == CTI_TRIG_IN ? CTIINEN(trigger_idx) :
+                     CTIOUTEN(trigger_idx));
+
+       spin_lock(&drvdata->spinlock);
+
+       /* read - modify write - the trigger / channel enable value */
+       reg_value = direction == CTI_TRIG_IN ? config->ctiinen[trigger_idx] :
+                    config->ctiouten[trigger_idx];
+       if (op == CTI_CHAN_ATTACH)
+               reg_value |= chan_bitmask;
+       else
+               reg_value &= ~chan_bitmask;
+
+       /* write local copy */
+       if (direction == CTI_TRIG_IN)
+               config->ctiinen[trigger_idx] = reg_value;
+       else
+               config->ctiouten[trigger_idx] = reg_value;
+
+       /* write through if enabled */
+       if (cti_active(config))
+               cti_write_single_reg(drvdata, reg_offset, reg_value);
+       spin_unlock(&drvdata->spinlock);
+       return 0;
+}
+
+int cti_channel_gate_op(struct device *dev, enum cti_chan_gate_op op,
+                       u32 channel_idx)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       struct cti_config *config = &drvdata->config;
+       u32 chan_bitmask;
+       u32 reg_value;
+       int err = 0;
+
+       if (channel_idx >= config->nr_ctm_channels)
+               return -EINVAL;
+
+       chan_bitmask = BIT(channel_idx);
+
+       spin_lock(&drvdata->spinlock);
+       reg_value = config->ctigate;
+       switch (op) {
+       case CTI_GATE_CHAN_ENABLE:
+               reg_value |= chan_bitmask;
+               break;
+
+       case CTI_GATE_CHAN_DISABLE:
+               reg_value &= ~chan_bitmask;
+               break;
+
+       default:
+               err = -EINVAL;
+               break;
+       }
+       if (err == 0) {
+               config->ctigate = reg_value;
+               if (cti_active(config))
+                       cti_write_single_reg(drvdata, CTIGATE, reg_value);
+       }
+       spin_unlock(&drvdata->spinlock);
+       return err;
+}
+
+int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
+                     u32 channel_idx)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       struct cti_config *config = &drvdata->config;
+       u32 chan_bitmask;
+       u32 reg_value;
+       u32 reg_offset;
+       int err = 0;
+
+       if (channel_idx >= config->nr_ctm_channels)
+               return -EINVAL;
+
+       chan_bitmask = BIT(channel_idx);
+
+       spin_lock(&drvdata->spinlock);
+       reg_value = config->ctiappset;
+       switch (op) {
+       case CTI_CHAN_SET:
+               config->ctiappset |= chan_bitmask;
+               reg_value  = config->ctiappset;
+               reg_offset = CTIAPPSET;
+               break;
+
+       case CTI_CHAN_CLR:
+               config->ctiappset &= ~chan_bitmask;
+               reg_value = chan_bitmask;
+               reg_offset = CTIAPPCLEAR;
+               break;
+
+       case CTI_CHAN_PULSE:
+               config->ctiappset &= ~chan_bitmask;
+               reg_value = chan_bitmask;
+               reg_offset = CTIAPPPULSE;
+               break;
+
+       default:
+               err = -EINVAL;
+               break;
+       }
+
+       if ((err == 0) && cti_active(config))
+               cti_write_single_reg(drvdata, reg_offset, reg_value);
+       spin_unlock(&drvdata->spinlock);
+
+       return err;
+}
+
+static bool cti_add_sysfs_link(struct cti_drvdata *drvdata,
+                              struct cti_trig_con *tc)
+{
+       struct coresight_sysfs_link link_info;
+       int link_err = 0;
+
+       link_info.orig = drvdata->csdev;
+       link_info.orig_name = tc->con_dev_name;
+       link_info.target = tc->con_dev;
+       link_info.target_name = dev_name(&drvdata->csdev->dev);
+
+       link_err = coresight_add_sysfs_link(&link_info);
+       if (link_err)
+               dev_warn(&drvdata->csdev->dev,
+                        "Failed to set CTI sysfs link %s<=>%s\n",
+                        link_info.orig_name, link_info.target_name);
+       return !link_err;
+}
+
+static void cti_remove_sysfs_link(struct cti_drvdata *drvdata,
+                                 struct cti_trig_con *tc)
+{
+       struct coresight_sysfs_link link_info;
+
+       link_info.orig = drvdata->csdev;
+       link_info.orig_name = tc->con_dev_name;
+       link_info.target = tc->con_dev;
+       link_info.target_name = dev_name(&drvdata->csdev->dev);
+       coresight_remove_sysfs_link(&link_info);
+}
+
+/*
+ * Look for a matching connection device name in the list of connections.
+ * If found then swap in the csdev name, set trig con association pointer
+ * and return found.
+ */
+static bool
+cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
+                     struct coresight_device *csdev)
+{
+       struct cti_trig_con *tc;
+       struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata,
+                                                  ctidev);
+
+       list_for_each_entry(tc, &ctidev->trig_cons, node) {
+               if (tc->con_dev_name) {
+                       if (!strcmp(node_name, tc->con_dev_name)) {
+                               /* match: so swap in csdev name & dev */
+                               tc->con_dev_name = dev_name(&csdev->dev);
+                               tc->con_dev = csdev;
+                               /* try to set sysfs link */
+                               if (cti_add_sysfs_link(drvdata, tc))
+                                       return true;
+                               /* link failed - remove CTI reference */
+                               tc->con_dev = NULL;
+                               break;
+                       }
+               }
+       }
+       return false;
+}
+
+/*
+ * Search the cti list to add an associated CTI into the supplied CS device
+ * This will set the association if CTI declared before the CS device.
+ * (called from coresight_register() with coresight_mutex locked).
+ */
+static void cti_add_assoc_to_csdev(struct coresight_device *csdev)
+{
+       struct cti_drvdata *ect_item;
+       struct cti_device *ctidev;
+       const char *node_name = NULL;
+
+       /* protect the list */
+       mutex_lock(&ect_mutex);
+
+       /* exit if current is an ECT device.*/
+       if ((csdev->type == CORESIGHT_DEV_TYPE_ECT) || list_empty(&ect_net))
+               goto cti_add_done;
+
+       /* if we didn't find the csdev previously we used the fwnode name */
+       node_name = cti_plat_get_node_name(dev_fwnode(csdev->dev.parent));
+       if (!node_name)
+               goto cti_add_done;
+
+       /* for each CTI in list... */
+       list_for_each_entry(ect_item, &ect_net, node) {
+               ctidev = &ect_item->ctidev;
+               if (cti_match_fixup_csdev(ctidev, node_name, csdev)) {
+                       /*
+                        * if we found a matching csdev then update the ECT
+                        * association pointer for the device with this CTI.
+                        */
+                       csdev->ect_dev = ect_item->csdev;
+                       break;
+               }
+       }
+cti_add_done:
+       mutex_unlock(&ect_mutex);
+}
+
+/*
+ * Removing the associated devices is easier.
+ * A CTI will not have a value for csdev->ect_dev.
+ */
+static void cti_remove_assoc_from_csdev(struct coresight_device *csdev)
+{
+       struct cti_drvdata *ctidrv;
+       struct cti_trig_con *tc;
+       struct cti_device *ctidev;
+
+       mutex_lock(&ect_mutex);
+       if (csdev->ect_dev) {
+               ctidrv = csdev_to_cti_drvdata(csdev->ect_dev);
+               ctidev = &ctidrv->ctidev;
+               list_for_each_entry(tc, &ctidev->trig_cons, node) {
+                       if (tc->con_dev == csdev) {
+                               cti_remove_sysfs_link(ctidrv, tc);
+                               tc->con_dev = NULL;
+                               break;
+                       }
+               }
+               csdev->ect_dev = NULL;
+       }
+       mutex_unlock(&ect_mutex);
+}
+
+/*
+ * Operations to add and remove associated CTI.
+ * Register to coresight core driver as call back function.
+ */
+static struct cti_assoc_op cti_assoc_ops = {
+       .add = cti_add_assoc_to_csdev,
+       .remove = cti_remove_assoc_from_csdev
+};
+
+/*
+ * Update the cross references where the associated device was found
+ * while we were building the connection info. This will occur if the
+ * assoc device was registered before the CTI.
+ */
+static void cti_update_conn_xrefs(struct cti_drvdata *drvdata)
+{
+       struct cti_trig_con *tc;
+       struct cti_device *ctidev = &drvdata->ctidev;
+
+       list_for_each_entry(tc, &ctidev->trig_cons, node) {
+               if (tc->con_dev) {
+                       /* if we can set the sysfs link */
+                       if (cti_add_sysfs_link(drvdata, tc))
+                               /* set the CTI/csdev association */
+                               coresight_set_assoc_ectdev_mutex(tc->con_dev,
+                                                        drvdata->csdev);
+                       else
+                               /* otherwise remove reference from CTI */
+                               tc->con_dev = NULL;
+               }
+       }
+}
+
+static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
+{
+       struct cti_trig_con *tc;
+       struct cti_device *ctidev = &drvdata->ctidev;
+
+       list_for_each_entry(tc, &ctidev->trig_cons, node) {
+               if (tc->con_dev) {
+                       coresight_set_assoc_ectdev_mutex(tc->con_dev,
+                                                        NULL);
+                       cti_remove_sysfs_link(drvdata, tc);
+                       tc->con_dev = NULL;
+               }
+       }
+}
+
+/** cti PM callbacks **/
+static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
+                            void *v)
+{
+       struct cti_drvdata *drvdata;
+       unsigned int cpu = smp_processor_id();
+       int notify_res = NOTIFY_OK;
+
+       if (!cti_cpu_drvdata[cpu])
+               return NOTIFY_OK;
+
+       drvdata = cti_cpu_drvdata[cpu];
+
+       if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
+               return NOTIFY_BAD;
+
+       spin_lock(&drvdata->spinlock);
+
+       switch (cmd) {
+       case CPU_PM_ENTER:
+               /* CTI regs all static - we have a copy & nothing to save */
+               drvdata->config.hw_powered = false;
+               if (drvdata->config.hw_enabled)
+                       coresight_disclaim_device(drvdata->base);
+               break;
+
+       case CPU_PM_ENTER_FAILED:
+               drvdata->config.hw_powered = true;
+               if (drvdata->config.hw_enabled) {
+                       if (coresight_claim_device(drvdata->base))
+                               drvdata->config.hw_enabled = false;
+               }
+               break;
+
+       case CPU_PM_EXIT:
+               /* write hardware registers to re-enable. */
+               drvdata->config.hw_powered = true;
+               drvdata->config.hw_enabled = false;
+
+               /* check enable reference count to enable HW */
+               if (atomic_read(&drvdata->config.enable_req_count)) {
+                       /* check we can claim the device as we re-power */
+                       if (coresight_claim_device(drvdata->base))
+                               goto cti_notify_exit;
+
+                       drvdata->config.hw_enabled = true;
+                       cti_write_all_hw_regs(drvdata);
+               }
+               break;
+
+       default:
+               notify_res = NOTIFY_DONE;
+               break;
+       }
+
+cti_notify_exit:
+       spin_unlock(&drvdata->spinlock);
+       return notify_res;
+}
+
+static struct notifier_block cti_cpu_pm_nb = {
+       .notifier_call = cti_cpu_pm_notify,
+};
+
+/* CPU HP handlers */
+static int cti_starting_cpu(unsigned int cpu)
+{
+       struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
+
+       if (!drvdata)
+               return 0;
+
+       cti_cpuhp_enable_hw(drvdata);
+       return 0;
+}
+
+static int cti_dying_cpu(unsigned int cpu)
+{
+       struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
+
+       if (!drvdata)
+               return 0;
+
+       spin_lock(&drvdata->spinlock);
+       drvdata->config.hw_powered = false;
+       if (drvdata->config.hw_enabled)
+               coresight_disclaim_device(drvdata->base);
+       spin_unlock(&drvdata->spinlock);
+       return 0;
+}
+
+static int cti_pm_setup(struct cti_drvdata *drvdata)
+{
+       int ret;
+
+       if (drvdata->ctidev.cpu == -1)
+               return 0;
+
+       if (nr_cti_cpu)
+               goto done;
+
+       cpus_read_lock();
+       ret = cpuhp_setup_state_nocalls_cpuslocked(
+                       CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
+                       "arm/coresight_cti:starting",
+                       cti_starting_cpu, cti_dying_cpu);
+       if (ret) {
+               cpus_read_unlock();
+               return ret;
+       }
+
+       ret = cpu_pm_register_notifier(&cti_cpu_pm_nb);
+       cpus_read_unlock();
+       if (ret) {
+               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
+               return ret;
+       }
+
+done:
+       nr_cti_cpu++;
+       cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;
+
+       return 0;
+}
+
+/* release PM registrations */
+static void cti_pm_release(struct cti_drvdata *drvdata)
+{
+       if (drvdata->ctidev.cpu == -1)
+               return;
+
+       cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;
+       if (--nr_cti_cpu == 0) {
+               cpu_pm_unregister_notifier(&cti_cpu_pm_nb);
+               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
+       }
+}
+
+/** cti ect operations **/
+int cti_enable(struct coresight_device *csdev)
+{
+       struct cti_drvdata *drvdata = csdev_to_cti_drvdata(csdev);
+
+       return cti_enable_hw(drvdata);
+}
+
+int cti_disable(struct coresight_device *csdev)
+{
+       struct cti_drvdata *drvdata = csdev_to_cti_drvdata(csdev);
+
+       return cti_disable_hw(drvdata);
+}
+
+static const struct coresight_ops_ect cti_ops_ect = {
+       .enable = cti_enable,
+       .disable = cti_disable,
+};
+
+static const struct coresight_ops cti_ops = {
+       .ect_ops = &cti_ops_ect,
+};
+
+/*
+ * Free up CTI specific resources
+ * called by dev->release, need to call down to underlying csdev release.
+ */
+static void cti_device_release(struct device *dev)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       struct cti_drvdata *ect_item, *ect_tmp;
+
+       mutex_lock(&ect_mutex);
+       cti_pm_release(drvdata);
+
+       /* remove from the list */
+       list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) {
+               if (ect_item == drvdata) {
+                       list_del(&ect_item->node);
+                       break;
+               }
+       }
+       mutex_unlock(&ect_mutex);
+
+       if (drvdata->csdev_release)
+               drvdata->csdev_release(dev);
+}
+static int __exit cti_remove(struct amba_device *adev)
+{
+       struct cti_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       mutex_lock(&ect_mutex);
+       cti_remove_conn_xrefs(drvdata);
+       mutex_unlock(&ect_mutex);
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
+static int cti_probe(struct amba_device *adev, const struct amba_id *id)
+{
+       int ret = 0;
+       void __iomem *base;
+       struct device *dev = &adev->dev;
+       struct cti_drvdata *drvdata = NULL;
+       struct coresight_desc cti_desc;
+       struct coresight_platform_data *pdata = NULL;
+       struct resource *res = &adev->res;
+
+       /* driver data*/
+       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
+               return -ENOMEM;
+
+       /* Validity for the resource is already checked by the AMBA core */
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       drvdata->base = base;
+
+       dev_set_drvdata(dev, drvdata);
+
+       /* default CTI device info  */
+       drvdata->ctidev.cpu = -1;
+       drvdata->ctidev.nr_trig_con = 0;
+       drvdata->ctidev.ctm_id = 0;
+       INIT_LIST_HEAD(&drvdata->ctidev.trig_cons);
+
+       spin_lock_init(&drvdata->spinlock);
+
+       /* initialise CTI driver config values */
+       cti_set_default_config(dev, drvdata);
+
+       pdata = coresight_cti_get_platform_data(dev);
+       if (IS_ERR(pdata)) {
+               dev_err(dev, "coresight_cti_get_platform_data err\n");
+               return  PTR_ERR(pdata);
+       }
+
+       /* default to powered - could change on PM notifications */
+       drvdata->config.hw_powered = true;
+
+       /* set up device name - will depend if cpu bound or otherwise */
+       if (drvdata->ctidev.cpu >= 0)
+               cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d",
+                                              drvdata->ctidev.cpu);
+       else
+               cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev);
+       if (!cti_desc.name)
+               return -ENOMEM;
+
+       /* setup CPU power management handling for CPU bound CTI devices. */
+       ret = cti_pm_setup(drvdata);
+       if (ret)
+               return ret;
+
+       /* create dynamic attributes for connections */
+       ret = cti_create_cons_sysfs(dev, drvdata);
+       if (ret) {
+               dev_err(dev, "%s: create dynamic sysfs entries failed\n",
+                       cti_desc.name);
+               goto pm_release;
+       }
+
+       /* set up coresight component description */
+       cti_desc.pdata = pdata;
+       cti_desc.type = CORESIGHT_DEV_TYPE_ECT;
+       cti_desc.subtype.ect_subtype = CORESIGHT_DEV_SUBTYPE_ECT_CTI;
+       cti_desc.ops = &cti_ops;
+       cti_desc.groups = drvdata->ctidev.con_groups;
+       cti_desc.dev = dev;
+       drvdata->csdev = coresight_register(&cti_desc);
+       if (IS_ERR(drvdata->csdev)) {
+               ret = PTR_ERR(drvdata->csdev);
+               goto pm_release;
+       }
+
+       /* add to list of CTI devices */
+       mutex_lock(&ect_mutex);
+       list_add(&drvdata->node, &ect_net);
+       /* set any cross references */
+       cti_update_conn_xrefs(drvdata);
+       mutex_unlock(&ect_mutex);
+
+       /* set up release chain */
+       drvdata->csdev_release = drvdata->csdev->dev.release;
+       drvdata->csdev->dev.release = cti_device_release;
+
+       /* all done - dec pm refcount */
+       pm_runtime_put(&adev->dev);
+       dev_info(&drvdata->csdev->dev, "CTI initialized\n");
+       return 0;
+
+pm_release:
+       cti_pm_release(drvdata);
+       return ret;
+}
+
+static struct amba_cs_uci_id uci_id_cti[] = {
+       {
+               /*  CTI UCI data */
+               .devarch        = 0x47701a14, /* CTI v2 */
+               .devarch_mask   = 0xfff0ffff,
+               .devtype        = 0x00000014, /* maj(0x4-debug) min(0x1-ECT) */
+       }
+};
+
+static const struct amba_id cti_ids[] = {
+       CS_AMBA_ID(0x000bb906), /* Coresight CTI (SoC 400), C-A72, C-A57 */
+       CS_AMBA_ID(0x000bb922), /* CTI - C-A8 */
+       CS_AMBA_ID(0x000bb9a8), /* CTI - C-A53 */
+       CS_AMBA_ID(0x000bb9aa), /* CTI - C-A73 */
+       CS_AMBA_UCI_ID(0x000bb9da, uci_id_cti), /* CTI - C-A35 */
+       CS_AMBA_UCI_ID(0x000bb9ed, uci_id_cti), /* Coresight CTI (SoC 600) */
+       { 0, 0},
+};
+
+MODULE_DEVICE_TABLE(amba, cti_ids);
+
+static struct amba_driver cti_driver = {
+       .drv = {
+               .name   = "coresight-cti",
+               .owner = THIS_MODULE,
+               .suppress_bind_attrs = true,
+       },
+       .probe          = cti_probe,
+       .remove         = cti_remove,
+       .id_table       = cti_ids,
+};
+
+static int __init cti_init(void)
+{
+       int ret;
+
+       ret = amba_driver_register(&cti_driver);
+       if (ret)
+               pr_info("Error registering cti driver\n");
+       coresight_set_cti_ops(&cti_assoc_ops);
+       return ret;
+}
+
+static void __exit cti_exit(void)
+{
+       coresight_remove_cti_ops();
+       amba_driver_unregister(&cti_driver);
+}
+
+module_init(cti_init);
+module_exit(cti_exit);
+
+MODULE_AUTHOR("Mike Leach <mike.leach@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight CTI Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c
deleted file mode 100644 (file)
index 3ccc703..0000000
+++ /dev/null
@@ -1,975 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2018 Linaro Limited, All rights reserved.
- * Author: Mike Leach <mike.leach@linaro.org>
- */
-
-#include <linux/amba/bus.h>
-#include <linux/atomic.h>
-#include <linux/bits.h>
-#include <linux/coresight.h>
-#include <linux/cpu_pm.h>
-#include <linux/cpuhotplug.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/mutex.h>
-#include <linux/pm_runtime.h>
-#include <linux/property.h>
-#include <linux/spinlock.h>
-
-#include "coresight-priv.h"
-#include "coresight-cti.h"
-
-/**
- * CTI devices can be associated with a PE, or be connected to CoreSight
- * hardware. We have a list of all CTIs irrespective of CPU bound or
- * otherwise.
- *
- * We assume that the non-CPU CTIs are always powered as we do with sinks etc.
- *
- * We leave the client to figure out if all the CTIs are interconnected with
- * the same CTM, in general this is the case but does not always have to be.
- */
-
-/* net of CTI devices connected via CTM */
-static LIST_HEAD(ect_net);
-
-/* protect the list */
-static DEFINE_MUTEX(ect_mutex);
-
-#define csdev_to_cti_drvdata(csdev)    \
-       dev_get_drvdata(csdev->dev.parent)
-
-/* power management handling */
-static int nr_cti_cpu;
-
-/* quick lookup list for CPU bound CTIs when power handling */
-static struct cti_drvdata *cti_cpu_drvdata[NR_CPUS];
-
-/*
- * CTI naming. CTI bound to cores will have the name cti_cpu<N> where
- * N is the CPU ID. System CTIs will have the name cti_sys<I> where I
- * is an index allocated by order of discovery.
- *
- * CTI device name list - for CTI not bound to cores.
- */
-DEFINE_CORESIGHT_DEVLIST(cti_sys_devs, "cti_sys");
-
-/* write set of regs to hardware - call with spinlock claimed */
-void cti_write_all_hw_regs(struct cti_drvdata *drvdata)
-{
-       struct cti_config *config = &drvdata->config;
-       int i;
-
-       CS_UNLOCK(drvdata->base);
-
-       /* disable CTI before writing registers */
-       writel_relaxed(0, drvdata->base + CTICONTROL);
-
-       /* write the CTI trigger registers */
-       for (i = 0; i < config->nr_trig_max; i++) {
-               writel_relaxed(config->ctiinen[i], drvdata->base + CTIINEN(i));
-               writel_relaxed(config->ctiouten[i],
-                              drvdata->base + CTIOUTEN(i));
-       }
-
-       /* other regs */
-       writel_relaxed(config->ctigate, drvdata->base + CTIGATE);
-       writel_relaxed(config->asicctl, drvdata->base + ASICCTL);
-       writel_relaxed(config->ctiappset, drvdata->base + CTIAPPSET);
-
-       /* re-enable CTI */
-       writel_relaxed(1, drvdata->base + CTICONTROL);
-
-       CS_LOCK(drvdata->base);
-}
-
-static void cti_enable_hw_smp_call(void *info)
-{
-       struct cti_drvdata *drvdata = info;
-
-       cti_write_all_hw_regs(drvdata);
-}
-
-/* write regs to hardware and enable */
-static int cti_enable_hw(struct cti_drvdata *drvdata)
-{
-       struct cti_config *config = &drvdata->config;
-       struct device *dev = &drvdata->csdev->dev;
-       int rc = 0;
-
-       pm_runtime_get_sync(dev->parent);
-       spin_lock(&drvdata->spinlock);
-
-       /* no need to do anything if enabled or unpowered*/
-       if (config->hw_enabled || !config->hw_powered)
-               goto cti_state_unchanged;
-
-       /* claim the device */
-       rc = coresight_claim_device(drvdata->base);
-       if (rc)
-               goto cti_err_not_enabled;
-
-       if (drvdata->ctidev.cpu >= 0) {
-               rc = smp_call_function_single(drvdata->ctidev.cpu,
-                                             cti_enable_hw_smp_call,
-                                             drvdata, 1);
-               if (rc)
-                       goto cti_err_not_enabled;
-       } else {
-               cti_write_all_hw_regs(drvdata);
-       }
-
-       config->hw_enabled = true;
-       atomic_inc(&drvdata->config.enable_req_count);
-       spin_unlock(&drvdata->spinlock);
-       return rc;
-
-cti_state_unchanged:
-       atomic_inc(&drvdata->config.enable_req_count);
-
-       /* cannot enable due to error */
-cti_err_not_enabled:
-       spin_unlock(&drvdata->spinlock);
-       pm_runtime_put(dev->parent);
-       return rc;
-}
-
-/* re-enable CTI on CPU when using CPU hotplug */
-static void cti_cpuhp_enable_hw(struct cti_drvdata *drvdata)
-{
-       struct cti_config *config = &drvdata->config;
-       struct device *dev = &drvdata->csdev->dev;
-
-       pm_runtime_get_sync(dev->parent);
-       spin_lock(&drvdata->spinlock);
-       config->hw_powered = true;
-
-       /* no need to do anything if no enable request */
-       if (!atomic_read(&drvdata->config.enable_req_count))
-               goto cti_hp_not_enabled;
-
-       /* try to claim the device */
-       if (coresight_claim_device(drvdata->base))
-               goto cti_hp_not_enabled;
-
-       cti_write_all_hw_regs(drvdata);
-       config->hw_enabled = true;
-       spin_unlock(&drvdata->spinlock);
-       return;
-
-       /* did not re-enable due to no claim / no request */
-cti_hp_not_enabled:
-       spin_unlock(&drvdata->spinlock);
-       pm_runtime_put(dev->parent);
-}
-
-/* disable hardware */
-static int cti_disable_hw(struct cti_drvdata *drvdata)
-{
-       struct cti_config *config = &drvdata->config;
-       struct device *dev = &drvdata->csdev->dev;
-
-       spin_lock(&drvdata->spinlock);
-
-       /* check refcount - disable on 0 */
-       if (atomic_dec_return(&drvdata->config.enable_req_count) > 0)
-               goto cti_not_disabled;
-
-       /* no need to do anything if disabled or cpu unpowered */
-       if (!config->hw_enabled || !config->hw_powered)
-               goto cti_not_disabled;
-
-       CS_UNLOCK(drvdata->base);
-
-       /* disable CTI */
-       writel_relaxed(0, drvdata->base + CTICONTROL);
-       config->hw_enabled = false;
-
-       coresight_disclaim_device_unlocked(drvdata->base);
-       CS_LOCK(drvdata->base);
-       spin_unlock(&drvdata->spinlock);
-       pm_runtime_put(dev);
-       return 0;
-
-       /* not disabled this call */
-cti_not_disabled:
-       spin_unlock(&drvdata->spinlock);
-       return 0;
-}
-
-void cti_write_single_reg(struct cti_drvdata *drvdata, int offset, u32 value)
-{
-       CS_UNLOCK(drvdata->base);
-       writel_relaxed(value, drvdata->base + offset);
-       CS_LOCK(drvdata->base);
-}
-
-void cti_write_intack(struct device *dev, u32 ackval)
-{
-       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       struct cti_config *config = &drvdata->config;
-
-       spin_lock(&drvdata->spinlock);
-       /* write if enabled */
-       if (cti_active(config))
-               cti_write_single_reg(drvdata, CTIINTACK, ackval);
-       spin_unlock(&drvdata->spinlock);
-}
-
-/*
- * Look at the HW DEVID register for some of the HW settings.
- * DEVID[15:8] - max number of in / out triggers.
- */
-#define CTI_DEVID_MAXTRIGS(devid_val) ((int) BMVAL(devid_val, 8, 15))
-
-/* DEVID[19:16] - number of CTM channels */
-#define CTI_DEVID_CTMCHANNELS(devid_val) ((int) BMVAL(devid_val, 16, 19))
-
-static void cti_set_default_config(struct device *dev,
-                                  struct cti_drvdata *drvdata)
-{
-       struct cti_config *config = &drvdata->config;
-       u32 devid;
-
-       devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
-       config->nr_trig_max = CTI_DEVID_MAXTRIGS(devid);
-
-       /*
-        * no current hardware should exceed this, but protect the driver
-        * in case of fault / out of spec hw
-        */
-       if (config->nr_trig_max > CTIINOUTEN_MAX) {
-               dev_warn_once(dev,
-                       "Limiting HW MaxTrig value(%d) to driver max(%d)\n",
-                       config->nr_trig_max, CTIINOUTEN_MAX);
-               config->nr_trig_max = CTIINOUTEN_MAX;
-       }
-
-       config->nr_ctm_channels = CTI_DEVID_CTMCHANNELS(devid);
-
-       /* Most regs default to 0 as zalloc'ed except...*/
-       config->trig_filter_enable = true;
-       config->ctigate = GENMASK(config->nr_ctm_channels - 1, 0);
-       atomic_set(&config->enable_req_count, 0);
-}
-
-/*
- * Add a connection entry to the list of connections for this
- * CTI device.
- */
-int cti_add_connection_entry(struct device *dev, struct cti_drvdata *drvdata,
-                            struct cti_trig_con *tc,
-                            struct coresight_device *csdev,
-                            const char *assoc_dev_name)
-{
-       struct cti_device *cti_dev = &drvdata->ctidev;
-
-       tc->con_dev = csdev;
-       /*
-        * Prefer actual associated CS device dev name to supplied value -
-        * which is likely to be node name / other conn name.
-        */
-       if (csdev)
-               tc->con_dev_name = dev_name(&csdev->dev);
-       else if (assoc_dev_name != NULL) {
-               tc->con_dev_name = devm_kstrdup(dev,
-                                               assoc_dev_name, GFP_KERNEL);
-               if (!tc->con_dev_name)
-                       return -ENOMEM;
-       }
-       list_add_tail(&tc->node, &cti_dev->trig_cons);
-       cti_dev->nr_trig_con++;
-
-       /* add connection usage bit info to overall info */
-       drvdata->config.trig_in_use |= tc->con_in->used_mask;
-       drvdata->config.trig_out_use |= tc->con_out->used_mask;
-
-       return 0;
-}
-
-/* create a trigger connection with appropriately sized signal groups */
-struct cti_trig_con *cti_allocate_trig_con(struct device *dev, int in_sigs,
-                                          int out_sigs)
-{
-       struct cti_trig_con *tc = NULL;
-       struct cti_trig_grp *in = NULL, *out = NULL;
-
-       tc = devm_kzalloc(dev, sizeof(struct cti_trig_con), GFP_KERNEL);
-       if (!tc)
-               return tc;
-
-       in = devm_kzalloc(dev,
-                         offsetof(struct cti_trig_grp, sig_types[in_sigs]),
-                         GFP_KERNEL);
-       if (!in)
-               return NULL;
-
-       out = devm_kzalloc(dev,
-                          offsetof(struct cti_trig_grp, sig_types[out_sigs]),
-                          GFP_KERNEL);
-       if (!out)
-               return NULL;
-
-       tc->con_in = in;
-       tc->con_out = out;
-       tc->con_in->nr_sigs = in_sigs;
-       tc->con_out->nr_sigs = out_sigs;
-       return tc;
-}
-
-/*
- * Add a default connection if nothing else is specified.
- * single connection based on max in/out info, no assoc device
- */
-int cti_add_default_connection(struct device *dev, struct cti_drvdata *drvdata)
-{
-       int ret = 0;
-       int n_trigs = drvdata->config.nr_trig_max;
-       u32 n_trig_mask = GENMASK(n_trigs - 1, 0);
-       struct cti_trig_con *tc = NULL;
-
-       /*
-        * Assume max trigs for in and out,
-        * all used, default sig types allocated
-        */
-       tc = cti_allocate_trig_con(dev, n_trigs, n_trigs);
-       if (!tc)
-               return -ENOMEM;
-
-       tc->con_in->used_mask = n_trig_mask;
-       tc->con_out->used_mask = n_trig_mask;
-       ret = cti_add_connection_entry(dev, drvdata, tc, NULL, "default");
-       return ret;
-}
-
-/** cti channel api **/
-/* attach/detach channel from trigger - write through if enabled. */
-int cti_channel_trig_op(struct device *dev, enum cti_chan_op op,
-                       enum cti_trig_dir direction, u32 channel_idx,
-                       u32 trigger_idx)
-{
-       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       struct cti_config *config = &drvdata->config;
-       u32 trig_bitmask;
-       u32 chan_bitmask;
-       u32 reg_value;
-       int reg_offset;
-
-       /* ensure indexes in range */
-       if ((channel_idx >= config->nr_ctm_channels) ||
-          (trigger_idx >= config->nr_trig_max))
-               return -EINVAL;
-
-       trig_bitmask = BIT(trigger_idx);
-
-       /* ensure registered triggers and not out filtered */
-       if (direction == CTI_TRIG_IN)   {
-               if (!(trig_bitmask & config->trig_in_use))
-                       return -EINVAL;
-       } else {
-               if (!(trig_bitmask & config->trig_out_use))
-                       return -EINVAL;
-
-               if ((config->trig_filter_enable) &&
-                   (config->trig_out_filter & trig_bitmask))
-                       return -EINVAL;
-       }
-
-       /* update the local register values */
-       chan_bitmask = BIT(channel_idx);
-       reg_offset = (direction == CTI_TRIG_IN ? CTIINEN(trigger_idx) :
-                     CTIOUTEN(trigger_idx));
-
-       spin_lock(&drvdata->spinlock);
-
-       /* read - modify write - the trigger / channel enable value */
-       reg_value = direction == CTI_TRIG_IN ? config->ctiinen[trigger_idx] :
-                    config->ctiouten[trigger_idx];
-       if (op == CTI_CHAN_ATTACH)
-               reg_value |= chan_bitmask;
-       else
-               reg_value &= ~chan_bitmask;
-
-       /* write local copy */
-       if (direction == CTI_TRIG_IN)
-               config->ctiinen[trigger_idx] = reg_value;
-       else
-               config->ctiouten[trigger_idx] = reg_value;
-
-       /* write through if enabled */
-       if (cti_active(config))
-               cti_write_single_reg(drvdata, reg_offset, reg_value);
-       spin_unlock(&drvdata->spinlock);
-       return 0;
-}
-
-int cti_channel_gate_op(struct device *dev, enum cti_chan_gate_op op,
-                       u32 channel_idx)
-{
-       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       struct cti_config *config = &drvdata->config;
-       u32 chan_bitmask;
-       u32 reg_value;
-       int err = 0;
-
-       if (channel_idx >= config->nr_ctm_channels)
-               return -EINVAL;
-
-       chan_bitmask = BIT(channel_idx);
-
-       spin_lock(&drvdata->spinlock);
-       reg_value = config->ctigate;
-       switch (op) {
-       case CTI_GATE_CHAN_ENABLE:
-               reg_value |= chan_bitmask;
-               break;
-
-       case CTI_GATE_CHAN_DISABLE:
-               reg_value &= ~chan_bitmask;
-               break;
-
-       default:
-               err = -EINVAL;
-               break;
-       }
-       if (err == 0) {
-               config->ctigate = reg_value;
-               if (cti_active(config))
-                       cti_write_single_reg(drvdata, CTIGATE, reg_value);
-       }
-       spin_unlock(&drvdata->spinlock);
-       return err;
-}
-
-int cti_channel_setop(struct device *dev, enum cti_chan_set_op op,
-                     u32 channel_idx)
-{
-       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       struct cti_config *config = &drvdata->config;
-       u32 chan_bitmask;
-       u32 reg_value;
-       u32 reg_offset;
-       int err = 0;
-
-       if (channel_idx >= config->nr_ctm_channels)
-               return -EINVAL;
-
-       chan_bitmask = BIT(channel_idx);
-
-       spin_lock(&drvdata->spinlock);
-       reg_value = config->ctiappset;
-       switch (op) {
-       case CTI_CHAN_SET:
-               config->ctiappset |= chan_bitmask;
-               reg_value  = config->ctiappset;
-               reg_offset = CTIAPPSET;
-               break;
-
-       case CTI_CHAN_CLR:
-               config->ctiappset &= ~chan_bitmask;
-               reg_value = chan_bitmask;
-               reg_offset = CTIAPPCLEAR;
-               break;
-
-       case CTI_CHAN_PULSE:
-               config->ctiappset &= ~chan_bitmask;
-               reg_value = chan_bitmask;
-               reg_offset = CTIAPPPULSE;
-               break;
-
-       default:
-               err = -EINVAL;
-               break;
-       }
-
-       if ((err == 0) && cti_active(config))
-               cti_write_single_reg(drvdata, reg_offset, reg_value);
-       spin_unlock(&drvdata->spinlock);
-
-       return err;
-}
-
-static bool cti_add_sysfs_link(struct cti_drvdata *drvdata,
-                              struct cti_trig_con *tc)
-{
-       struct coresight_sysfs_link link_info;
-       int link_err = 0;
-
-       link_info.orig = drvdata->csdev;
-       link_info.orig_name = tc->con_dev_name;
-       link_info.target = tc->con_dev;
-       link_info.target_name = dev_name(&drvdata->csdev->dev);
-
-       link_err = coresight_add_sysfs_link(&link_info);
-       if (link_err)
-               dev_warn(&drvdata->csdev->dev,
-                        "Failed to set CTI sysfs link %s<=>%s\n",
-                        link_info.orig_name, link_info.target_name);
-       return !link_err;
-}
-
-static void cti_remove_sysfs_link(struct cti_trig_con *tc)
-{
-       struct coresight_sysfs_link link_info;
-
-       link_info.orig_name = tc->con_dev_name;
-       link_info.target = tc->con_dev;
-       coresight_remove_sysfs_link(&link_info);
-}
-
-/*
- * Look for a matching connection device name in the list of connections.
- * If found then swap in the csdev name, set trig con association pointer
- * and return found.
- */
-static bool
-cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name,
-                     struct coresight_device *csdev)
-{
-       struct cti_trig_con *tc;
-       struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata,
-                                                  ctidev);
-
-       list_for_each_entry(tc, &ctidev->trig_cons, node) {
-               if (tc->con_dev_name) {
-                       if (!strcmp(node_name, tc->con_dev_name)) {
-                               /* match: so swap in csdev name & dev */
-                               tc->con_dev_name = dev_name(&csdev->dev);
-                               tc->con_dev = csdev;
-                               /* try to set sysfs link */
-                               if (cti_add_sysfs_link(drvdata, tc))
-                                       return true;
-                               /* link failed - remove CTI reference */
-                               tc->con_dev = NULL;
-                               break;
-                       }
-               }
-       }
-       return false;
-}
-
-/*
- * Search the cti list to add an associated CTI into the supplied CS device
- * This will set the association if CTI declared before the CS device.
- * (called from coresight_register() with coresight_mutex locked).
- */
-void cti_add_assoc_to_csdev(struct coresight_device *csdev)
-{
-       struct cti_drvdata *ect_item;
-       struct cti_device *ctidev;
-       const char *node_name = NULL;
-
-       /* protect the list */
-       mutex_lock(&ect_mutex);
-
-       /* exit if current is an ECT device.*/
-       if ((csdev->type == CORESIGHT_DEV_TYPE_ECT) || list_empty(&ect_net))
-               goto cti_add_done;
-
-       /* if we didn't find the csdev previously we used the fwnode name */
-       node_name = cti_plat_get_node_name(dev_fwnode(csdev->dev.parent));
-       if (!node_name)
-               goto cti_add_done;
-
-       /* for each CTI in list... */
-       list_for_each_entry(ect_item, &ect_net, node) {
-               ctidev = &ect_item->ctidev;
-               if (cti_match_fixup_csdev(ctidev, node_name, csdev)) {
-                       /*
-                        * if we found a matching csdev then update the ECT
-                        * association pointer for the device with this CTI.
-                        */
-                       csdev->ect_dev = ect_item->csdev;
-                       break;
-               }
-       }
-cti_add_done:
-       mutex_unlock(&ect_mutex);
-}
-EXPORT_SYMBOL_GPL(cti_add_assoc_to_csdev);
-
-/*
- * Removing the associated devices is easier.
- * A CTI will not have a value for csdev->ect_dev.
- */
-void cti_remove_assoc_from_csdev(struct coresight_device *csdev)
-{
-       struct cti_drvdata *ctidrv;
-       struct cti_trig_con *tc;
-       struct cti_device *ctidev;
-
-       mutex_lock(&ect_mutex);
-       if (csdev->ect_dev) {
-               ctidrv = csdev_to_cti_drvdata(csdev->ect_dev);
-               ctidev = &ctidrv->ctidev;
-               list_for_each_entry(tc, &ctidev->trig_cons, node) {
-                       if (tc->con_dev == csdev->ect_dev) {
-                               cti_remove_sysfs_link(tc);
-                               tc->con_dev = NULL;
-                               break;
-                       }
-               }
-               csdev->ect_dev = NULL;
-       }
-       mutex_unlock(&ect_mutex);
-}
-EXPORT_SYMBOL_GPL(cti_remove_assoc_from_csdev);
-
-/*
- * Update the cross references where the associated device was found
- * while we were building the connection info. This will occur if the
- * assoc device was registered before the CTI.
- */
-static void cti_update_conn_xrefs(struct cti_drvdata *drvdata)
-{
-       struct cti_trig_con *tc;
-       struct cti_device *ctidev = &drvdata->ctidev;
-
-       list_for_each_entry(tc, &ctidev->trig_cons, node) {
-               if (tc->con_dev) {
-                       /* if we can set the sysfs link */
-                       if (cti_add_sysfs_link(drvdata, tc))
-                               /* set the CTI/csdev association */
-                               coresight_set_assoc_ectdev_mutex(tc->con_dev,
-                                                        drvdata->csdev);
-                       else
-                               /* otherwise remove reference from CTI */
-                               tc->con_dev = NULL;
-               }
-       }
-}
-
-static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata)
-{
-       struct cti_trig_con *tc;
-       struct cti_device *ctidev = &drvdata->ctidev;
-
-       list_for_each_entry(tc, &ctidev->trig_cons, node) {
-               if (tc->con_dev) {
-                       coresight_set_assoc_ectdev_mutex(tc->con_dev,
-                                                        NULL);
-                       cti_remove_sysfs_link(tc);
-                       tc->con_dev = NULL;
-               }
-       }
-}
-
-/** cti PM callbacks **/
-static int cti_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
-                            void *v)
-{
-       struct cti_drvdata *drvdata;
-       unsigned int cpu = smp_processor_id();
-       int notify_res = NOTIFY_OK;
-
-       if (!cti_cpu_drvdata[cpu])
-               return NOTIFY_OK;
-
-       drvdata = cti_cpu_drvdata[cpu];
-
-       if (WARN_ON_ONCE(drvdata->ctidev.cpu != cpu))
-               return NOTIFY_BAD;
-
-       spin_lock(&drvdata->spinlock);
-
-       switch (cmd) {
-       case CPU_PM_ENTER:
-               /* CTI regs all static - we have a copy & nothing to save */
-               drvdata->config.hw_powered = false;
-               if (drvdata->config.hw_enabled)
-                       coresight_disclaim_device(drvdata->base);
-               break;
-
-       case CPU_PM_ENTER_FAILED:
-               drvdata->config.hw_powered = true;
-               if (drvdata->config.hw_enabled) {
-                       if (coresight_claim_device(drvdata->base))
-                               drvdata->config.hw_enabled = false;
-               }
-               break;
-
-       case CPU_PM_EXIT:
-               /* write hardware registers to re-enable. */
-               drvdata->config.hw_powered = true;
-               drvdata->config.hw_enabled = false;
-
-               /* check enable reference count to enable HW */
-               if (atomic_read(&drvdata->config.enable_req_count)) {
-                       /* check we can claim the device as we re-power */
-                       if (coresight_claim_device(drvdata->base))
-                               goto cti_notify_exit;
-
-                       drvdata->config.hw_enabled = true;
-                       cti_write_all_hw_regs(drvdata);
-               }
-               break;
-
-       default:
-               notify_res = NOTIFY_DONE;
-               break;
-       }
-
-cti_notify_exit:
-       spin_unlock(&drvdata->spinlock);
-       return notify_res;
-}
-
-static struct notifier_block cti_cpu_pm_nb = {
-       .notifier_call = cti_cpu_pm_notify,
-};
-
-/* CPU HP handlers */
-static int cti_starting_cpu(unsigned int cpu)
-{
-       struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
-
-       if (!drvdata)
-               return 0;
-
-       cti_cpuhp_enable_hw(drvdata);
-       return 0;
-}
-
-static int cti_dying_cpu(unsigned int cpu)
-{
-       struct cti_drvdata *drvdata = cti_cpu_drvdata[cpu];
-
-       if (!drvdata)
-               return 0;
-
-       spin_lock(&drvdata->spinlock);
-       drvdata->config.hw_powered = false;
-       coresight_disclaim_device(drvdata->base);
-       spin_unlock(&drvdata->spinlock);
-       return 0;
-}
-
-static int cti_pm_setup(struct cti_drvdata *drvdata)
-{
-       int ret;
-
-       if (drvdata->ctidev.cpu == -1)
-               return 0;
-
-       if (nr_cti_cpu)
-               goto done;
-
-       cpus_read_lock();
-       ret = cpuhp_setup_state_nocalls_cpuslocked(
-                       CPUHP_AP_ARM_CORESIGHT_CTI_STARTING,
-                       "arm/coresight_cti:starting",
-                       cti_starting_cpu, cti_dying_cpu);
-       if (ret) {
-               cpus_read_unlock();
-               return ret;
-       }
-
-       ret = cpu_pm_register_notifier(&cti_cpu_pm_nb);
-       cpus_read_unlock();
-       if (ret) {
-               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
-               return ret;
-       }
-
-done:
-       nr_cti_cpu++;
-       cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata;
-
-       return 0;
-}
-
-/* release PM registrations */
-static void cti_pm_release(struct cti_drvdata *drvdata)
-{
-       if (drvdata->ctidev.cpu == -1)
-               return;
-
-       cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL;
-       if (--nr_cti_cpu == 0) {
-               cpu_pm_unregister_notifier(&cti_cpu_pm_nb);
-               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING);
-       }
-}
-
-/** cti ect operations **/
-int cti_enable(struct coresight_device *csdev)
-{
-       struct cti_drvdata *drvdata = csdev_to_cti_drvdata(csdev);
-
-       return cti_enable_hw(drvdata);
-}
-
-int cti_disable(struct coresight_device *csdev)
-{
-       struct cti_drvdata *drvdata = csdev_to_cti_drvdata(csdev);
-
-       return cti_disable_hw(drvdata);
-}
-
-static const struct coresight_ops_ect cti_ops_ect = {
-       .enable = cti_enable,
-       .disable = cti_disable,
-};
-
-static const struct coresight_ops cti_ops = {
-       .ect_ops = &cti_ops_ect,
-};
-
-/*
- * Free up CTI specific resources
- * called by dev->release, need to call down to underlying csdev release.
- */
-static void cti_device_release(struct device *dev)
-{
-       struct cti_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       struct cti_drvdata *ect_item, *ect_tmp;
-
-       mutex_lock(&ect_mutex);
-       cti_remove_conn_xrefs(drvdata);
-       cti_pm_release(drvdata);
-
-       /* remove from the list */
-       list_for_each_entry_safe(ect_item, ect_tmp, &ect_net, node) {
-               if (ect_item == drvdata) {
-                       list_del(&ect_item->node);
-                       break;
-               }
-       }
-       mutex_unlock(&ect_mutex);
-
-       if (drvdata->csdev_release)
-               drvdata->csdev_release(dev);
-}
-
-static int cti_probe(struct amba_device *adev, const struct amba_id *id)
-{
-       int ret = 0;
-       void __iomem *base;
-       struct device *dev = &adev->dev;
-       struct cti_drvdata *drvdata = NULL;
-       struct coresight_desc cti_desc;
-       struct coresight_platform_data *pdata = NULL;
-       struct resource *res = &adev->res;
-
-       /* driver data*/
-       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-       if (!drvdata)
-               return -ENOMEM;
-
-       /* Validity for the resource is already checked by the AMBA core */
-       base = devm_ioremap_resource(dev, res);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       drvdata->base = base;
-
-       dev_set_drvdata(dev, drvdata);
-
-       /* default CTI device info  */
-       drvdata->ctidev.cpu = -1;
-       drvdata->ctidev.nr_trig_con = 0;
-       drvdata->ctidev.ctm_id = 0;
-       INIT_LIST_HEAD(&drvdata->ctidev.trig_cons);
-
-       spin_lock_init(&drvdata->spinlock);
-
-       /* initialise CTI driver config values */
-       cti_set_default_config(dev, drvdata);
-
-       pdata = coresight_cti_get_platform_data(dev);
-       if (IS_ERR(pdata)) {
-               dev_err(dev, "coresight_cti_get_platform_data err\n");
-               return  PTR_ERR(pdata);
-       }
-
-       /* default to powered - could change on PM notifications */
-       drvdata->config.hw_powered = true;
-
-       /* set up device name - will depend if cpu bound or otherwise */
-       if (drvdata->ctidev.cpu >= 0)
-               cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d",
-                                              drvdata->ctidev.cpu);
-       else
-               cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev);
-       if (!cti_desc.name)
-               return -ENOMEM;
-
-       /* setup CPU power management handling for CPU bound CTI devices. */
-       ret = cti_pm_setup(drvdata);
-       if (ret)
-               return ret;
-
-       /* create dynamic attributes for connections */
-       ret = cti_create_cons_sysfs(dev, drvdata);
-       if (ret) {
-               dev_err(dev, "%s: create dynamic sysfs entries failed\n",
-                       cti_desc.name);
-               goto pm_release;
-       }
-
-       /* set up coresight component description */
-       cti_desc.pdata = pdata;
-       cti_desc.type = CORESIGHT_DEV_TYPE_ECT;
-       cti_desc.subtype.ect_subtype = CORESIGHT_DEV_SUBTYPE_ECT_CTI;
-       cti_desc.ops = &cti_ops;
-       cti_desc.groups = drvdata->ctidev.con_groups;
-       cti_desc.dev = dev;
-       drvdata->csdev = coresight_register(&cti_desc);
-       if (IS_ERR(drvdata->csdev)) {
-               ret = PTR_ERR(drvdata->csdev);
-               goto pm_release;
-       }
-
-       /* add to list of CTI devices */
-       mutex_lock(&ect_mutex);
-       list_add(&drvdata->node, &ect_net);
-       /* set any cross references */
-       cti_update_conn_xrefs(drvdata);
-       mutex_unlock(&ect_mutex);
-
-       /* set up release chain */
-       drvdata->csdev_release = drvdata->csdev->dev.release;
-       drvdata->csdev->dev.release = cti_device_release;
-
-       /* all done - dec pm refcount */
-       pm_runtime_put(&adev->dev);
-       dev_info(&drvdata->csdev->dev, "CTI initialized\n");
-       return 0;
-
-pm_release:
-       cti_pm_release(drvdata);
-       return ret;
-}
-
-static struct amba_cs_uci_id uci_id_cti[] = {
-       {
-               /*  CTI UCI data */
-               .devarch        = 0x47701a14, /* CTI v2 */
-               .devarch_mask   = 0xfff0ffff,
-               .devtype        = 0x00000014, /* maj(0x4-debug) min(0x1-ECT) */
-       }
-};
-
-static const struct amba_id cti_ids[] = {
-       CS_AMBA_ID(0x000bb906), /* Coresight CTI (SoC 400), C-A72, C-A57 */
-       CS_AMBA_ID(0x000bb922), /* CTI - C-A8 */
-       CS_AMBA_ID(0x000bb9a8), /* CTI - C-A53 */
-       CS_AMBA_ID(0x000bb9aa), /* CTI - C-A73 */
-       CS_AMBA_UCI_ID(0x000bb9da, uci_id_cti), /* CTI - C-A35 */
-       CS_AMBA_UCI_ID(0x000bb9ed, uci_id_cti), /* Coresight CTI (SoC 600) */
-       { 0, 0},
-};
-
-static struct amba_driver cti_driver = {
-       .drv = {
-               .name   = "coresight-cti",
-               .owner = THIS_MODULE,
-               .suppress_bind_attrs = true,
-       },
-       .probe          = cti_probe,
-       .id_table       = cti_ids,
-};
-builtin_amba_driver(cti_driver);
index 03e3f25..248cc82 100644 (file)
@@ -525,7 +525,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
 
        cur = buf->cur;
        offset = buf->offset;
-       barrier = barrier_pkt;
+       barrier = coresight_barrier_pkt;
 
        for (i = 0; i < to_read; i += 4) {
                buf_ptr = buf->data_pages[cur] + offset;
@@ -801,6 +801,21 @@ err_misc_register:
        return ret;
 }
 
+static int __exit etb_remove(struct amba_device *adev)
+{
+       struct etb_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       /*
+        * Since misc_open() holds a refcount on the f_ops, which is
+        * etb fops in this case, device is there until last file
+        * handler to this device is closed.
+        */
+       misc_deregister(&drvdata->miscdev);
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
 #ifdef CONFIG_PM
 static int etb_runtime_suspend(struct device *dev)
 {
@@ -835,6 +850,8 @@ static const struct amba_id etb_ids[] = {
        { 0, 0},
 };
 
+MODULE_DEVICE_TABLE(amba, etb_ids);
+
 static struct amba_driver etb_driver = {
        .drv = {
                .name   = "coresight-etb10",
@@ -844,6 +861,13 @@ static struct amba_driver etb_driver = {
 
        },
        .probe          = etb_probe,
+       .remove         = etb_remove,
        .id_table       = etb_ids,
 };
-builtin_amba_driver(etb_driver);
+
+module_amba_driver(etb_driver);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight Embedded Trace Buffer driver");
+MODULE_LICENSE("GPL v2");
index 1a3169e..c2c9b12 100644 (file)
@@ -126,10 +126,10 @@ static void free_sink_buffer(struct etm_event_data *event_data)
        cpumask_t *mask = &event_data->mask;
        struct coresight_device *sink;
 
-       if (WARN_ON(cpumask_empty(mask)))
+       if (!event_data->snk_config)
                return;
 
-       if (!event_data->snk_config)
+       if (WARN_ON(cpumask_empty(mask)))
                return;
 
        cpu = cpumask_first(mask);
@@ -222,8 +222,6 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
        if (event->attr.config2) {
                id = (u32)event->attr.config2;
                sink = coresight_get_sink_by_id(id);
-       } else {
-               sink = coresight_get_enabled_sink(true);
        }
 
        mask = &event_data->mask;
@@ -321,6 +319,16 @@ static void etm_event_start(struct perf_event *event, int flags)
        if (!event_data)
                goto fail;
 
+       /*
+        * Check if this ETM is allowed to trace, as decided
+        * at etm_setup_aux(). This could be due to an unreachable
+        * sink from this ETM. We can't do much in this case if
+        * the sink was specified or hinted to the driver. For
+        * now, simply don't record anything on this ETM.
+        */
+       if (!cpumask_test_cpu(cpu, &event_data->mask))
+               goto fail_end_stop;
+
        path = etm_event_cpu_path(event_data, cpu);
        /* We need a sink, no need to continue without one */
        sink = coresight_get_sink(path);
@@ -517,6 +525,7 @@ int etm_perf_symlink(struct coresight_device *csdev, bool link)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(etm_perf_symlink);
 
 static ssize_t etm_perf_sink_name_show(struct device *dev,
                                       struct device_attribute *dattr,
@@ -590,7 +599,7 @@ void etm_perf_del_symlink_sink(struct coresight_device *csdev)
        csdev->ea = NULL;
 }
 
-static int __init etm_perf_init(void)
+int __init etm_perf_init(void)
 {
        int ret;
 
@@ -617,4 +626,8 @@ static int __init etm_perf_init(void)
 
        return ret;
 }
-device_initcall(etm_perf_init);
+
+void __exit etm_perf_exit(void)
+{
+       perf_pmu_unregister(&etm_pmu);
+}
index 015213a..3e4f2ad 100644 (file)
@@ -57,7 +57,7 @@ struct etm_event_data {
        struct list_head * __percpu *path;
 };
 
-#ifdef CONFIG_CORESIGHT
+#if IS_ENABLED(CONFIG_CORESIGHT)
 int etm_perf_symlink(struct coresight_device *csdev, bool link);
 int etm_perf_add_symlink_sink(struct coresight_device *csdev);
 void etm_perf_del_symlink_sink(struct coresight_device *csdev);
@@ -82,4 +82,7 @@ static inline void *etm_perf_sink_config(struct perf_output_handle *handle)
 
 #endif /* CONFIG_CORESIGHT */
 
+int __init etm_perf_init(void);
+void __exit etm_perf_exit(void);
+
 #endif
diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c
new file mode 100644 (file)
index 0000000..47f610b
--- /dev/null
@@ -0,0 +1,1026 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+ *
+ * Description: CoreSight Program Flow Trace driver
+ */
+
+#include <linux/kernel.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/smp.h>
+#include <linux/sysfs.h>
+#include <linux/stat.h>
+#include <linux/pm_runtime.h>
+#include <linux/cpu.h>
+#include <linux/of.h>
+#include <linux/coresight.h>
+#include <linux/coresight-pmu.h>
+#include <linux/amba/bus.h>
+#include <linux/seq_file.h>
+#include <linux/uaccess.h>
+#include <linux/clk.h>
+#include <linux/perf_event.h>
+#include <asm/sections.h>
+
+#include "coresight-etm.h"
+#include "coresight-etm-perf.h"
+
+/*
+ * Not really modular but using module_param is the easiest way to
+ * remain consistent with existing use cases for now.
+ */
+static int boot_enable;
+module_param_named(boot_enable, boot_enable, int, S_IRUGO);
+
+static struct etm_drvdata *etmdrvdata[NR_CPUS];
+
+static enum cpuhp_state hp_online;
+
+/*
+ * Memory mapped writes to clear os lock are not supported on some processors
+ * and OS lock must be unlocked before any memory mapped access on such
+ * processors, otherwise memory mapped reads/writes will be invalid.
+ */
+static void etm_os_unlock(struct etm_drvdata *drvdata)
+{
+       /* Writing any value to ETMOSLAR unlocks the trace registers */
+       etm_writel(drvdata, 0x0, ETMOSLAR);
+       drvdata->os_unlock = true;
+       isb();
+}
+
+static void etm_set_pwrdwn(struct etm_drvdata *drvdata)
+{
+       u32 etmcr;
+
+       /* Ensure pending cp14 accesses complete before setting pwrdwn */
+       mb();
+       isb();
+       etmcr = etm_readl(drvdata, ETMCR);
+       etmcr |= ETMCR_PWD_DWN;
+       etm_writel(drvdata, etmcr, ETMCR);
+}
+
+static void etm_clr_pwrdwn(struct etm_drvdata *drvdata)
+{
+       u32 etmcr;
+
+       etmcr = etm_readl(drvdata, ETMCR);
+       etmcr &= ~ETMCR_PWD_DWN;
+       etm_writel(drvdata, etmcr, ETMCR);
+       /* Ensure pwrup completes before subsequent cp14 accesses */
+       mb();
+       isb();
+}
+
+static void etm_set_pwrup(struct etm_drvdata *drvdata)
+{
+       u32 etmpdcr;
+
+       etmpdcr = readl_relaxed(drvdata->base + ETMPDCR);
+       etmpdcr |= ETMPDCR_PWD_UP;
+       writel_relaxed(etmpdcr, drvdata->base + ETMPDCR);
+       /* Ensure pwrup completes before subsequent cp14 accesses */
+       mb();
+       isb();
+}
+
+static void etm_clr_pwrup(struct etm_drvdata *drvdata)
+{
+       u32 etmpdcr;
+
+       /* Ensure pending cp14 accesses complete before clearing pwrup */
+       mb();
+       isb();
+       etmpdcr = readl_relaxed(drvdata->base + ETMPDCR);
+       etmpdcr &= ~ETMPDCR_PWD_UP;
+       writel_relaxed(etmpdcr, drvdata->base + ETMPDCR);
+}
+
+/**
+ * coresight_timeout_etm - loop until a bit has changed to a specific state.
+ * @drvdata: etm's private data structure.
+ * @offset: address of a register, starting from @addr.
+ * @position: the position of the bit of interest.
+ * @value: the value the bit should have.
+ *
+ * Basically the same as @coresight_timeout except for the register access
+ * method where we have to account for CP14 configurations.
+
+ * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if
+ * TIMEOUT_US has elapsed, which ever happens first.
+ */
+
+static int coresight_timeout_etm(struct etm_drvdata *drvdata, u32 offset,
+                                 int position, int value)
+{
+       int i;
+       u32 val;
+
+       for (i = TIMEOUT_US; i > 0; i--) {
+               val = etm_readl(drvdata, offset);
+               /* Waiting on the bit to go from 0 to 1 */
+               if (value) {
+                       if (val & BIT(position))
+                               return 0;
+               /* Waiting on the bit to go from 1 to 0 */
+               } else {
+                       if (!(val & BIT(position)))
+                               return 0;
+               }
+
+               /*
+                * Delay is arbitrary - the specification doesn't say how long
+                * we are expected to wait.  Extra check required to make sure
+                * we don't wait needlessly on the last iteration.
+                */
+               if (i - 1)
+                       udelay(1);
+       }
+
+       return -EAGAIN;
+}
+
+
+static void etm_set_prog(struct etm_drvdata *drvdata)
+{
+       u32 etmcr;
+
+       etmcr = etm_readl(drvdata, ETMCR);
+       etmcr |= ETMCR_ETM_PRG;
+       etm_writel(drvdata, etmcr, ETMCR);
+       /*
+        * Recommended by spec for cp14 accesses to ensure etmcr write is
+        * complete before polling etmsr
+        */
+       isb();
+       if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 1)) {
+               dev_err(&drvdata->csdev->dev,
+                       "%s: timeout observed when probing at offset %#x\n",
+                       __func__, ETMSR);
+       }
+}
+
+static void etm_clr_prog(struct etm_drvdata *drvdata)
+{
+       u32 etmcr;
+
+       etmcr = etm_readl(drvdata, ETMCR);
+       etmcr &= ~ETMCR_ETM_PRG;
+       etm_writel(drvdata, etmcr, ETMCR);
+       /*
+        * Recommended by spec for cp14 accesses to ensure etmcr write is
+        * complete before polling etmsr
+        */
+       isb();
+       if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 0)) {
+               dev_err(&drvdata->csdev->dev,
+                       "%s: timeout observed when probing at offset %#x\n",
+                       __func__, ETMSR);
+       }
+}
+
+void etm_set_default(struct etm_config *config)
+{
+       int i;
+
+       if (WARN_ON_ONCE(!config))
+               return;
+
+       /*
+        * Taken verbatim from the TRM:
+        *
+        * To trace all memory:
+        *  set bit [24] in register 0x009, the ETMTECR1, to 1
+        *  set all other bits in register 0x009, the ETMTECR1, to 0
+        *  set all bits in register 0x007, the ETMTECR2, to 0
+        *  set register 0x008, the ETMTEEVR, to 0x6F (TRUE).
+        */
+       config->enable_ctrl1 = BIT(24);
+       config->enable_ctrl2 = 0x0;
+       config->enable_event = ETM_HARD_WIRE_RES_A;
+
+       config->trigger_event = ETM_DEFAULT_EVENT_VAL;
+       config->enable_event = ETM_HARD_WIRE_RES_A;
+
+       config->seq_12_event = ETM_DEFAULT_EVENT_VAL;
+       config->seq_21_event = ETM_DEFAULT_EVENT_VAL;
+       config->seq_23_event = ETM_DEFAULT_EVENT_VAL;
+       config->seq_31_event = ETM_DEFAULT_EVENT_VAL;
+       config->seq_32_event = ETM_DEFAULT_EVENT_VAL;
+       config->seq_13_event = ETM_DEFAULT_EVENT_VAL;
+       config->timestamp_event = ETM_DEFAULT_EVENT_VAL;
+
+       for (i = 0; i < ETM_MAX_CNTR; i++) {
+               config->cntr_rld_val[i] = 0x0;
+               config->cntr_event[i] = ETM_DEFAULT_EVENT_VAL;
+               config->cntr_rld_event[i] = ETM_DEFAULT_EVENT_VAL;
+               config->cntr_val[i] = 0x0;
+       }
+
+       config->seq_curr_state = 0x0;
+       config->ctxid_idx = 0x0;
+       for (i = 0; i < ETM_MAX_CTXID_CMP; i++)
+               config->ctxid_pid[i] = 0x0;
+
+       config->ctxid_mask = 0x0;
+       /* Setting default to 1024 as per TRM recommendation */
+       config->sync_freq = 0x400;
+}
+
+void etm_config_trace_mode(struct etm_config *config)
+{
+       u32 flags, mode;
+
+       mode = config->mode;
+
+       mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER);
+
+       /* excluding kernel AND user space doesn't make sense */
+       if (mode == (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
+               return;
+
+       /* nothing to do if neither flags are set */
+       if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
+               return;
+
+       flags = (1 << 0 |       /* instruction execute */
+                3 << 3 |       /* ARM instruction */
+                0 << 5 |       /* No data value comparison */
+                0 << 7 |       /* No exact mach */
+                0 << 8);       /* Ignore context ID */
+
+       /* No need to worry about single address comparators. */
+       config->enable_ctrl2 = 0x0;
+
+       /* Bit 0 is address range comparator 1 */
+       config->enable_ctrl1 = ETMTECR1_ADDR_COMP_1;
+
+       /*
+        * On ETMv3.5:
+        * ETMACTRn[13,11] == Non-secure state comparison control
+        * ETMACTRn[12,10] == Secure state comparison control
+        *
+        * b00 == Match in all modes in this state
+        * b01 == Do not match in any more in this state
+        * b10 == Match in all modes excepts user mode in this state
+        * b11 == Match only in user mode in this state
+        */
+
+       /* Tracing in secure mode is not supported at this time */
+       flags |= (0 << 12 | 1 << 10);
+
+       if (mode & ETM_MODE_EXCL_USER) {
+               /* exclude user, match all modes except user mode */
+               flags |= (1 << 13 | 0 << 11);
+       } else {
+               /* exclude kernel, match only in user mode */
+               flags |= (1 << 13 | 1 << 11);
+       }
+
+       /*
+        * The ETMEEVR register is already set to "hard wire A".  As such
+        * all there is to do is setup an address comparator that spans
+        * the entire address range and configure the state and mode bits.
+        */
+       config->addr_val[0] = (u32) 0x0;
+       config->addr_val[1] = (u32) ~0x0;
+       config->addr_acctype[0] = flags;
+       config->addr_acctype[1] = flags;
+       config->addr_type[0] = ETM_ADDR_TYPE_RANGE;
+       config->addr_type[1] = ETM_ADDR_TYPE_RANGE;
+}
+
+#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | \
+                                ETMCR_TIMESTAMP_EN | \
+                                ETMCR_RETURN_STACK)
+
+static int etm_parse_event_config(struct etm_drvdata *drvdata,
+                                 struct perf_event *event)
+{
+       struct etm_config *config = &drvdata->config;
+       struct perf_event_attr *attr = &event->attr;
+
+       if (!attr)
+               return -EINVAL;
+
+       /* Clear configuration from previous run */
+       memset(config, 0, sizeof(struct etm_config));
+
+       if (attr->exclude_kernel)
+               config->mode = ETM_MODE_EXCL_KERN;
+
+       if (attr->exclude_user)
+               config->mode = ETM_MODE_EXCL_USER;
+
+       /* Always start from the default config */
+       etm_set_default(config);
+
+       /*
+        * By default the tracers are configured to trace the whole address
+        * range.  Narrow the field only if requested by user space.
+        */
+       if (config->mode)
+               etm_config_trace_mode(config);
+
+       /*
+        * At this time only cycle accurate, return stack  and timestamp
+        * options are available.
+        */
+       if (attr->config & ~ETM3X_SUPPORTED_OPTIONS)
+               return -EINVAL;
+
+       config->ctrl = attr->config;
+
+       /*
+        * Possible to have cores with PTM (supports ret stack) and ETM
+        * (never has ret stack) on the same SoC. So if we have a request
+        * for return stack that can't be honoured on this core then
+        * clear the bit - trace will still continue normally
+        */
+       if ((config->ctrl & ETMCR_RETURN_STACK) &&
+           !(drvdata->etmccer & ETMCCER_RETSTACK))
+               config->ctrl &= ~ETMCR_RETURN_STACK;
+
+       return 0;
+}
+
+static int etm_enable_hw(struct etm_drvdata *drvdata)
+{
+       int i, rc;
+       u32 etmcr;
+       struct etm_config *config = &drvdata->config;
+
+       CS_UNLOCK(drvdata->base);
+
+       rc = coresight_claim_device_unlocked(drvdata->base);
+       if (rc)
+               goto done;
+
+       /* Turn engine on */
+       etm_clr_pwrdwn(drvdata);
+       /* Apply power to trace registers */
+       etm_set_pwrup(drvdata);
+       /* Make sure all registers are accessible */
+       etm_os_unlock(drvdata);
+
+       etm_set_prog(drvdata);
+
+       etmcr = etm_readl(drvdata, ETMCR);
+       /* Clear setting from a previous run if need be */
+       etmcr &= ~ETM3X_SUPPORTED_OPTIONS;
+       etmcr |= drvdata->port_size;
+       etmcr |= ETMCR_ETM_EN;
+       etm_writel(drvdata, config->ctrl | etmcr, ETMCR);
+       etm_writel(drvdata, config->trigger_event, ETMTRIGGER);
+       etm_writel(drvdata, config->startstop_ctrl, ETMTSSCR);
+       etm_writel(drvdata, config->enable_event, ETMTEEVR);
+       etm_writel(drvdata, config->enable_ctrl1, ETMTECR1);
+       etm_writel(drvdata, config->fifofull_level, ETMFFLR);
+       for (i = 0; i < drvdata->nr_addr_cmp; i++) {
+               etm_writel(drvdata, config->addr_val[i], ETMACVRn(i));
+               etm_writel(drvdata, config->addr_acctype[i], ETMACTRn(i));
+       }
+       for (i = 0; i < drvdata->nr_cntr; i++) {
+               etm_writel(drvdata, config->cntr_rld_val[i], ETMCNTRLDVRn(i));
+               etm_writel(drvdata, config->cntr_event[i], ETMCNTENRn(i));
+               etm_writel(drvdata, config->cntr_rld_event[i],
+                          ETMCNTRLDEVRn(i));
+               etm_writel(drvdata, config->cntr_val[i], ETMCNTVRn(i));
+       }
+       etm_writel(drvdata, config->seq_12_event, ETMSQ12EVR);
+       etm_writel(drvdata, config->seq_21_event, ETMSQ21EVR);
+       etm_writel(drvdata, config->seq_23_event, ETMSQ23EVR);
+       etm_writel(drvdata, config->seq_31_event, ETMSQ31EVR);
+       etm_writel(drvdata, config->seq_32_event, ETMSQ32EVR);
+       etm_writel(drvdata, config->seq_13_event, ETMSQ13EVR);
+       etm_writel(drvdata, config->seq_curr_state, ETMSQR);
+       for (i = 0; i < drvdata->nr_ext_out; i++)
+               etm_writel(drvdata, ETM_DEFAULT_EVENT_VAL, ETMEXTOUTEVRn(i));
+       for (i = 0; i < drvdata->nr_ctxid_cmp; i++)
+               etm_writel(drvdata, config->ctxid_pid[i], ETMCIDCVRn(i));
+       etm_writel(drvdata, config->ctxid_mask, ETMCIDCMR);
+       etm_writel(drvdata, config->sync_freq, ETMSYNCFR);
+       /* No external input selected */
+       etm_writel(drvdata, 0x0, ETMEXTINSELR);
+       etm_writel(drvdata, config->timestamp_event, ETMTSEVR);
+       /* No auxiliary control selected */
+       etm_writel(drvdata, 0x0, ETMAUXCR);
+       etm_writel(drvdata, drvdata->traceid, ETMTRACEIDR);
+       /* No VMID comparator value selected */
+       etm_writel(drvdata, 0x0, ETMVMIDCVR);
+
+       etm_clr_prog(drvdata);
+
+done:
+       CS_LOCK(drvdata->base);
+
+       dev_dbg(&drvdata->csdev->dev, "cpu: %d enable smp call done: %d\n",
+               drvdata->cpu, rc);
+       return rc;
+}
+
+struct etm_enable_arg {
+       struct etm_drvdata *drvdata;
+       int rc;
+};
+
+static void etm_enable_hw_smp_call(void *info)
+{
+       struct etm_enable_arg *arg = info;
+
+       if (WARN_ON(!arg))
+               return;
+       arg->rc = etm_enable_hw(arg->drvdata);
+}
+
+static int etm_cpu_id(struct coresight_device *csdev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       return drvdata->cpu;
+}
+
+int etm_get_trace_id(struct etm_drvdata *drvdata)
+{
+       unsigned long flags;
+       int trace_id = -1;
+       struct device *etm_dev;
+
+       if (!drvdata)
+               goto out;
+
+       etm_dev = drvdata->csdev->dev.parent;
+       if (!local_read(&drvdata->mode))
+               return drvdata->traceid;
+
+       pm_runtime_get_sync(etm_dev);
+
+       spin_lock_irqsave(&drvdata->spinlock, flags);
+
+       CS_UNLOCK(drvdata->base);
+       trace_id = (etm_readl(drvdata, ETMTRACEIDR) & ETM_TRACEID_MASK);
+       CS_LOCK(drvdata->base);
+
+       spin_unlock_irqrestore(&drvdata->spinlock, flags);
+       pm_runtime_put(etm_dev);
+
+out:
+       return trace_id;
+
+}
+
+static int etm_trace_id(struct coresight_device *csdev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       return etm_get_trace_id(drvdata);
+}
+
+static int etm_enable_perf(struct coresight_device *csdev,
+                          struct perf_event *event)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
+               return -EINVAL;
+
+       /* Configure the tracer based on the session's specifics */
+       etm_parse_event_config(drvdata, event);
+       /* And enable it */
+       return etm_enable_hw(drvdata);
+}
+
+static int etm_enable_sysfs(struct coresight_device *csdev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+       struct etm_enable_arg arg = { };
+       int ret;
+
+       spin_lock(&drvdata->spinlock);
+
+       /*
+        * Configure the ETM only if the CPU is online.  If it isn't online
+        * hw configuration will take place on the local CPU during bring up.
+        */
+       if (cpu_online(drvdata->cpu)) {
+               arg.drvdata = drvdata;
+               ret = smp_call_function_single(drvdata->cpu,
+                                              etm_enable_hw_smp_call, &arg, 1);
+               if (!ret)
+                       ret = arg.rc;
+               if (!ret)
+                       drvdata->sticky_enable = true;
+       } else {
+               ret = -ENODEV;
+       }
+
+       spin_unlock(&drvdata->spinlock);
+
+       if (!ret)
+               dev_dbg(&csdev->dev, "ETM tracing enabled\n");
+       return ret;
+}
+
+static int etm_enable(struct coresight_device *csdev,
+                     struct perf_event *event, u32 mode)
+{
+       int ret;
+       u32 val;
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode);
+
+       /* Someone is already using the tracer */
+       if (val)
+               return -EBUSY;
+
+       switch (mode) {
+       case CS_MODE_SYSFS:
+               ret = etm_enable_sysfs(csdev);
+               break;
+       case CS_MODE_PERF:
+               ret = etm_enable_perf(csdev, event);
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       /* The tracer didn't start */
+       if (ret)
+               local_set(&drvdata->mode, CS_MODE_DISABLED);
+
+       return ret;
+}
+
+static void etm_disable_hw(void *info)
+{
+       int i;
+       struct etm_drvdata *drvdata = info;
+       struct etm_config *config = &drvdata->config;
+
+       CS_UNLOCK(drvdata->base);
+       etm_set_prog(drvdata);
+
+       /* Read back sequencer and counters for post trace analysis */
+       config->seq_curr_state = (etm_readl(drvdata, ETMSQR) & ETM_SQR_MASK);
+
+       for (i = 0; i < drvdata->nr_cntr; i++)
+               config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
+
+       etm_set_pwrdwn(drvdata);
+       coresight_disclaim_device_unlocked(drvdata->base);
+
+       CS_LOCK(drvdata->base);
+
+       dev_dbg(&drvdata->csdev->dev,
+               "cpu: %d disable smp call done\n", drvdata->cpu);
+}
+
+static void etm_disable_perf(struct coresight_device *csdev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
+               return;
+
+       CS_UNLOCK(drvdata->base);
+
+       /* Setting the prog bit disables tracing immediately */
+       etm_set_prog(drvdata);
+
+       /*
+        * There is no way to know when the tracer will be used again so
+        * power down the tracer.
+        */
+       etm_set_pwrdwn(drvdata);
+       coresight_disclaim_device_unlocked(drvdata->base);
+
+       CS_LOCK(drvdata->base);
+}
+
+static void etm_disable_sysfs(struct coresight_device *csdev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       /*
+        * Taking hotplug lock here protects from clocks getting disabled
+        * with tracing being left on (crash scenario) if user disable occurs
+        * after cpu online mask indicates the cpu is offline but before the
+        * DYING hotplug callback is serviced by the ETM driver.
+        */
+       cpus_read_lock();
+       spin_lock(&drvdata->spinlock);
+
+       /*
+        * Executing etm_disable_hw on the cpu whose ETM is being disabled
+        * ensures that register writes occur when cpu is powered.
+        */
+       smp_call_function_single(drvdata->cpu, etm_disable_hw, drvdata, 1);
+
+       spin_unlock(&drvdata->spinlock);
+       cpus_read_unlock();
+
+       dev_dbg(&csdev->dev, "ETM tracing disabled\n");
+}
+
+static void etm_disable(struct coresight_device *csdev,
+                       struct perf_event *event)
+{
+       u32 mode;
+       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       /*
+        * For as long as the tracer isn't disabled another entity can't
+        * change its status.  As such we can read the status here without
+        * fearing it will change under us.
+        */
+       mode = local_read(&drvdata->mode);
+
+       switch (mode) {
+       case CS_MODE_DISABLED:
+               break;
+       case CS_MODE_SYSFS:
+               etm_disable_sysfs(csdev);
+               break;
+       case CS_MODE_PERF:
+               etm_disable_perf(csdev);
+               break;
+       default:
+               WARN_ON_ONCE(mode);
+               return;
+       }
+
+       if (mode)
+               local_set(&drvdata->mode, CS_MODE_DISABLED);
+}
+
+static const struct coresight_ops_source etm_source_ops = {
+       .cpu_id         = etm_cpu_id,
+       .trace_id       = etm_trace_id,
+       .enable         = etm_enable,
+       .disable        = etm_disable,
+};
+
+static const struct coresight_ops etm_cs_ops = {
+       .source_ops     = &etm_source_ops,
+};
+
+static int etm_online_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       if (etmdrvdata[cpu]->boot_enable && !etmdrvdata[cpu]->sticky_enable)
+               coresight_enable(etmdrvdata[cpu]->csdev);
+       return 0;
+}
+
+static int etm_starting_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       spin_lock(&etmdrvdata[cpu]->spinlock);
+       if (!etmdrvdata[cpu]->os_unlock) {
+               etm_os_unlock(etmdrvdata[cpu]);
+               etmdrvdata[cpu]->os_unlock = true;
+       }
+
+       if (local_read(&etmdrvdata[cpu]->mode))
+               etm_enable_hw(etmdrvdata[cpu]);
+       spin_unlock(&etmdrvdata[cpu]->spinlock);
+       return 0;
+}
+
+static int etm_dying_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       spin_lock(&etmdrvdata[cpu]->spinlock);
+       if (local_read(&etmdrvdata[cpu]->mode))
+               etm_disable_hw(etmdrvdata[cpu]);
+       spin_unlock(&etmdrvdata[cpu]->spinlock);
+       return 0;
+}
+
+static bool etm_arch_supported(u8 arch)
+{
+       switch (arch) {
+       case ETM_ARCH_V3_3:
+               break;
+       case ETM_ARCH_V3_5:
+               break;
+       case PFT_ARCH_V1_0:
+               break;
+       case PFT_ARCH_V1_1:
+               break;
+       default:
+               return false;
+       }
+       return true;
+}
+
+static void etm_init_arch_data(void *info)
+{
+       u32 etmidr;
+       u32 etmccr;
+       struct etm_drvdata *drvdata = info;
+
+       /* Make sure all registers are accessible */
+       etm_os_unlock(drvdata);
+
+       CS_UNLOCK(drvdata->base);
+
+       /* First dummy read */
+       (void)etm_readl(drvdata, ETMPDSR);
+       /* Provide power to ETM: ETMPDCR[3] == 1 */
+       etm_set_pwrup(drvdata);
+       /*
+        * Clear power down bit since when this bit is set writes to
+        * certain registers might be ignored.
+        */
+       etm_clr_pwrdwn(drvdata);
+       /*
+        * Set prog bit. It will be set from reset but this is included to
+        * ensure it is set
+        */
+       etm_set_prog(drvdata);
+
+       /* Find all capabilities */
+       etmidr = etm_readl(drvdata, ETMIDR);
+       drvdata->arch = BMVAL(etmidr, 4, 11);
+       drvdata->port_size = etm_readl(drvdata, ETMCR) & PORT_SIZE_MASK;
+
+       drvdata->etmccer = etm_readl(drvdata, ETMCCER);
+       etmccr = etm_readl(drvdata, ETMCCR);
+       drvdata->etmccr = etmccr;
+       drvdata->nr_addr_cmp = BMVAL(etmccr, 0, 3) * 2;
+       drvdata->nr_cntr = BMVAL(etmccr, 13, 15);
+       drvdata->nr_ext_inp = BMVAL(etmccr, 17, 19);
+       drvdata->nr_ext_out = BMVAL(etmccr, 20, 22);
+       drvdata->nr_ctxid_cmp = BMVAL(etmccr, 24, 25);
+
+       etm_set_pwrdwn(drvdata);
+       etm_clr_pwrup(drvdata);
+       CS_LOCK(drvdata->base);
+}
+
+static void etm_init_trace_id(struct etm_drvdata *drvdata)
+{
+       drvdata->traceid = coresight_get_trace_id(drvdata->cpu);
+}
+
+static int __init etm_hp_setup(void)
+{
+       int ret;
+
+       ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,
+                                                  "arm/coresight:starting",
+                                                  etm_starting_cpu, etm_dying_cpu);
+
+       if (ret)
+               return ret;
+
+       ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
+                                                  "arm/coresight:online",
+                                                  etm_online_cpu, NULL);
+
+       /* HP dyn state ID returned in ret on success */
+       if (ret > 0) {
+               hp_online = ret;
+               return 0;
+       }
+
+       /* failed dyn state - remove others */
+       cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
+
+       return ret;
+}
+
+static void etm_hp_clear(void)
+{
+       cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
+       if (hp_online) {
+               cpuhp_remove_state_nocalls(hp_online);
+               hp_online = 0;
+       }
+}
+
+static int etm_probe(struct amba_device *adev, const struct amba_id *id)
+{
+       int ret;
+       void __iomem *base;
+       struct device *dev = &adev->dev;
+       struct coresight_platform_data *pdata = NULL;
+       struct etm_drvdata *drvdata;
+       struct resource *res = &adev->res;
+       struct coresight_desc desc = { 0 };
+
+       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
+               return -ENOMEM;
+
+       drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
+       dev_set_drvdata(dev, drvdata);
+
+       /* Validity for the resource is already checked by the AMBA core */
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       drvdata->base = base;
+
+       spin_lock_init(&drvdata->spinlock);
+
+       drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
+       if (!IS_ERR(drvdata->atclk)) {
+               ret = clk_prepare_enable(drvdata->atclk);
+               if (ret)
+                       return ret;
+       }
+
+       drvdata->cpu = coresight_get_cpu(dev);
+       if (drvdata->cpu < 0)
+               return drvdata->cpu;
+
+       desc.name  = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
+       if (!desc.name)
+               return -ENOMEM;
+
+       if (smp_call_function_single(drvdata->cpu,
+                                    etm_init_arch_data,  drvdata, 1))
+               dev_err(dev, "ETM arch init failed\n");
+
+       if (etm_arch_supported(drvdata->arch) == false)
+               return -EINVAL;
+
+       etm_init_trace_id(drvdata);
+       etm_set_default(&drvdata->config);
+
+       pdata = coresight_get_platform_data(dev);
+       if (IS_ERR(pdata))
+               return PTR_ERR(pdata);
+
+       adev->dev.platform_data = pdata;
+
+       desc.type = CORESIGHT_DEV_TYPE_SOURCE;
+       desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
+       desc.ops = &etm_cs_ops;
+       desc.pdata = pdata;
+       desc.dev = dev;
+       desc.groups = coresight_etm_groups;
+       drvdata->csdev = coresight_register(&desc);
+       if (IS_ERR(drvdata->csdev))
+               return PTR_ERR(drvdata->csdev);
+
+       ret = etm_perf_symlink(drvdata->csdev, true);
+       if (ret) {
+               coresight_unregister(drvdata->csdev);
+               return ret;
+       }
+
+       etmdrvdata[drvdata->cpu] = drvdata;
+
+       pm_runtime_put(&adev->dev);
+       dev_info(&drvdata->csdev->dev,
+                "%s initialized\n", (char *)coresight_get_uci_data(id));
+       if (boot_enable) {
+               coresight_enable(drvdata->csdev);
+               drvdata->boot_enable = true;
+       }
+
+       return 0;
+}
+
+static void __exit clear_etmdrvdata(void *info)
+{
+       int cpu = *(int *)info;
+
+       etmdrvdata[cpu] = NULL;
+}
+
+static int __exit etm_remove(struct amba_device *adev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       etm_perf_symlink(drvdata->csdev, false);
+
+       /*
+        * Taking hotplug lock here to avoid racing between etm_remove and
+        * CPU hotplug call backs.
+        */
+       cpus_read_lock();
+       /*
+        * The readers for etmdrvdata[] are CPU hotplug call backs
+        * and PM notification call backs. Change etmdrvdata[i] on
+        * CPU i ensures these call backs has consistent view
+        * inside one call back function.
+        */
+       if (smp_call_function_single(drvdata->cpu, clear_etmdrvdata, &drvdata->cpu, 1))
+               etmdrvdata[drvdata->cpu] = NULL;
+
+       cpus_read_unlock();
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
+#ifdef CONFIG_PM
+static int etm_runtime_suspend(struct device *dev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(dev);
+
+       if (drvdata && !IS_ERR(drvdata->atclk))
+               clk_disable_unprepare(drvdata->atclk);
+
+       return 0;
+}
+
+static int etm_runtime_resume(struct device *dev)
+{
+       struct etm_drvdata *drvdata = dev_get_drvdata(dev);
+
+       if (drvdata && !IS_ERR(drvdata->atclk))
+               clk_prepare_enable(drvdata->atclk);
+
+       return 0;
+}
+#endif
+
+static const struct dev_pm_ops etm_dev_pm_ops = {
+       SET_RUNTIME_PM_OPS(etm_runtime_suspend, etm_runtime_resume, NULL)
+};
+
+static const struct amba_id etm_ids[] = {
+       /* ETM 3.3 */
+       CS_AMBA_ID_DATA(0x000bb921, "ETM 3.3"),
+       /* ETM 3.5 - Cortex-A5 */
+       CS_AMBA_ID_DATA(0x000bb955, "ETM 3.5"),
+       /* ETM 3.5 */
+       CS_AMBA_ID_DATA(0x000bb956, "ETM 3.5"),
+       /* PTM 1.0 */
+       CS_AMBA_ID_DATA(0x000bb950, "PTM 1.0"),
+       /* PTM 1.1 */
+       CS_AMBA_ID_DATA(0x000bb95f, "PTM 1.1"),
+       /* PTM 1.1 Qualcomm */
+       CS_AMBA_ID_DATA(0x000b006f, "PTM 1.1"),
+       { 0, 0},
+};
+
+MODULE_DEVICE_TABLE(amba, etm_ids);
+
+static struct amba_driver etm_driver = {
+       .drv = {
+               .name   = "coresight-etm3x",
+               .owner  = THIS_MODULE,
+               .pm     = &etm_dev_pm_ops,
+               .suppress_bind_attrs = true,
+       },
+       .probe          = etm_probe,
+       .remove         = etm_remove,
+       .id_table       = etm_ids,
+};
+
+static int __init etm_init(void)
+{
+       int ret;
+
+       ret = etm_hp_setup();
+
+       /* etm_hp_setup() does its own cleanup - exit on error */
+       if (ret)
+               return ret;
+
+       ret = amba_driver_register(&etm_driver);
+       if (ret) {
+               pr_err("Error registering etm3x driver\n");
+               etm_hp_clear();
+       }
+
+       return ret;
+}
+
+static void __exit etm_exit(void)
+{
+       amba_driver_unregister(&etm_driver);
+       etm_hp_clear();
+}
+
+module_init(etm_init);
+module_exit(etm_exit);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c
deleted file mode 100644 (file)
index bf22dcf..0000000
+++ /dev/null
@@ -1,950 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- *
- * Description: CoreSight Program Flow Trace driver
- */
-
-#include <linux/kernel.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/smp.h>
-#include <linux/sysfs.h>
-#include <linux/stat.h>
-#include <linux/pm_runtime.h>
-#include <linux/cpu.h>
-#include <linux/of.h>
-#include <linux/coresight.h>
-#include <linux/coresight-pmu.h>
-#include <linux/amba/bus.h>
-#include <linux/seq_file.h>
-#include <linux/uaccess.h>
-#include <linux/clk.h>
-#include <linux/perf_event.h>
-#include <asm/sections.h>
-
-#include "coresight-etm.h"
-#include "coresight-etm-perf.h"
-
-/*
- * Not really modular but using module_param is the easiest way to
- * remain consistent with existing use cases for now.
- */
-static int boot_enable;
-module_param_named(boot_enable, boot_enable, int, S_IRUGO);
-
-/* The number of ETM/PTM currently registered */
-static int etm_count;
-static struct etm_drvdata *etmdrvdata[NR_CPUS];
-
-static enum cpuhp_state hp_online;
-
-/*
- * Memory mapped writes to clear os lock are not supported on some processors
- * and OS lock must be unlocked before any memory mapped access on such
- * processors, otherwise memory mapped reads/writes will be invalid.
- */
-static void etm_os_unlock(struct etm_drvdata *drvdata)
-{
-       /* Writing any value to ETMOSLAR unlocks the trace registers */
-       etm_writel(drvdata, 0x0, ETMOSLAR);
-       drvdata->os_unlock = true;
-       isb();
-}
-
-static void etm_set_pwrdwn(struct etm_drvdata *drvdata)
-{
-       u32 etmcr;
-
-       /* Ensure pending cp14 accesses complete before setting pwrdwn */
-       mb();
-       isb();
-       etmcr = etm_readl(drvdata, ETMCR);
-       etmcr |= ETMCR_PWD_DWN;
-       etm_writel(drvdata, etmcr, ETMCR);
-}
-
-static void etm_clr_pwrdwn(struct etm_drvdata *drvdata)
-{
-       u32 etmcr;
-
-       etmcr = etm_readl(drvdata, ETMCR);
-       etmcr &= ~ETMCR_PWD_DWN;
-       etm_writel(drvdata, etmcr, ETMCR);
-       /* Ensure pwrup completes before subsequent cp14 accesses */
-       mb();
-       isb();
-}
-
-static void etm_set_pwrup(struct etm_drvdata *drvdata)
-{
-       u32 etmpdcr;
-
-       etmpdcr = readl_relaxed(drvdata->base + ETMPDCR);
-       etmpdcr |= ETMPDCR_PWD_UP;
-       writel_relaxed(etmpdcr, drvdata->base + ETMPDCR);
-       /* Ensure pwrup completes before subsequent cp14 accesses */
-       mb();
-       isb();
-}
-
-static void etm_clr_pwrup(struct etm_drvdata *drvdata)
-{
-       u32 etmpdcr;
-
-       /* Ensure pending cp14 accesses complete before clearing pwrup */
-       mb();
-       isb();
-       etmpdcr = readl_relaxed(drvdata->base + ETMPDCR);
-       etmpdcr &= ~ETMPDCR_PWD_UP;
-       writel_relaxed(etmpdcr, drvdata->base + ETMPDCR);
-}
-
-/**
- * coresight_timeout_etm - loop until a bit has changed to a specific state.
- * @drvdata: etm's private data structure.
- * @offset: address of a register, starting from @addr.
- * @position: the position of the bit of interest.
- * @value: the value the bit should have.
- *
- * Basically the same as @coresight_timeout except for the register access
- * method where we have to account for CP14 configurations.
-
- * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if
- * TIMEOUT_US has elapsed, which ever happens first.
- */
-
-static int coresight_timeout_etm(struct etm_drvdata *drvdata, u32 offset,
-                                 int position, int value)
-{
-       int i;
-       u32 val;
-
-       for (i = TIMEOUT_US; i > 0; i--) {
-               val = etm_readl(drvdata, offset);
-               /* Waiting on the bit to go from 0 to 1 */
-               if (value) {
-                       if (val & BIT(position))
-                               return 0;
-               /* Waiting on the bit to go from 1 to 0 */
-               } else {
-                       if (!(val & BIT(position)))
-                               return 0;
-               }
-
-               /*
-                * Delay is arbitrary - the specification doesn't say how long
-                * we are expected to wait.  Extra check required to make sure
-                * we don't wait needlessly on the last iteration.
-                */
-               if (i - 1)
-                       udelay(1);
-       }
-
-       return -EAGAIN;
-}
-
-
-static void etm_set_prog(struct etm_drvdata *drvdata)
-{
-       u32 etmcr;
-
-       etmcr = etm_readl(drvdata, ETMCR);
-       etmcr |= ETMCR_ETM_PRG;
-       etm_writel(drvdata, etmcr, ETMCR);
-       /*
-        * Recommended by spec for cp14 accesses to ensure etmcr write is
-        * complete before polling etmsr
-        */
-       isb();
-       if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 1)) {
-               dev_err(&drvdata->csdev->dev,
-                       "%s: timeout observed when probing at offset %#x\n",
-                       __func__, ETMSR);
-       }
-}
-
-static void etm_clr_prog(struct etm_drvdata *drvdata)
-{
-       u32 etmcr;
-
-       etmcr = etm_readl(drvdata, ETMCR);
-       etmcr &= ~ETMCR_ETM_PRG;
-       etm_writel(drvdata, etmcr, ETMCR);
-       /*
-        * Recommended by spec for cp14 accesses to ensure etmcr write is
-        * complete before polling etmsr
-        */
-       isb();
-       if (coresight_timeout_etm(drvdata, ETMSR, ETMSR_PROG_BIT, 0)) {
-               dev_err(&drvdata->csdev->dev,
-                       "%s: timeout observed when probing at offset %#x\n",
-                       __func__, ETMSR);
-       }
-}
-
-void etm_set_default(struct etm_config *config)
-{
-       int i;
-
-       if (WARN_ON_ONCE(!config))
-               return;
-
-       /*
-        * Taken verbatim from the TRM:
-        *
-        * To trace all memory:
-        *  set bit [24] in register 0x009, the ETMTECR1, to 1
-        *  set all other bits in register 0x009, the ETMTECR1, to 0
-        *  set all bits in register 0x007, the ETMTECR2, to 0
-        *  set register 0x008, the ETMTEEVR, to 0x6F (TRUE).
-        */
-       config->enable_ctrl1 = BIT(24);
-       config->enable_ctrl2 = 0x0;
-       config->enable_event = ETM_HARD_WIRE_RES_A;
-
-       config->trigger_event = ETM_DEFAULT_EVENT_VAL;
-       config->enable_event = ETM_HARD_WIRE_RES_A;
-
-       config->seq_12_event = ETM_DEFAULT_EVENT_VAL;
-       config->seq_21_event = ETM_DEFAULT_EVENT_VAL;
-       config->seq_23_event = ETM_DEFAULT_EVENT_VAL;
-       config->seq_31_event = ETM_DEFAULT_EVENT_VAL;
-       config->seq_32_event = ETM_DEFAULT_EVENT_VAL;
-       config->seq_13_event = ETM_DEFAULT_EVENT_VAL;
-       config->timestamp_event = ETM_DEFAULT_EVENT_VAL;
-
-       for (i = 0; i < ETM_MAX_CNTR; i++) {
-               config->cntr_rld_val[i] = 0x0;
-               config->cntr_event[i] = ETM_DEFAULT_EVENT_VAL;
-               config->cntr_rld_event[i] = ETM_DEFAULT_EVENT_VAL;
-               config->cntr_val[i] = 0x0;
-       }
-
-       config->seq_curr_state = 0x0;
-       config->ctxid_idx = 0x0;
-       for (i = 0; i < ETM_MAX_CTXID_CMP; i++)
-               config->ctxid_pid[i] = 0x0;
-
-       config->ctxid_mask = 0x0;
-       /* Setting default to 1024 as per TRM recommendation */
-       config->sync_freq = 0x400;
-}
-
-void etm_config_trace_mode(struct etm_config *config)
-{
-       u32 flags, mode;
-
-       mode = config->mode;
-
-       mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER);
-
-       /* excluding kernel AND user space doesn't make sense */
-       if (mode == (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER))
-               return;
-
-       /* nothing to do if neither flags are set */
-       if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
-               return;
-
-       flags = (1 << 0 |       /* instruction execute */
-                3 << 3 |       /* ARM instruction */
-                0 << 5 |       /* No data value comparison */
-                0 << 7 |       /* No exact mach */
-                0 << 8);       /* Ignore context ID */
-
-       /* No need to worry about single address comparators. */
-       config->enable_ctrl2 = 0x0;
-
-       /* Bit 0 is address range comparator 1 */
-       config->enable_ctrl1 = ETMTECR1_ADDR_COMP_1;
-
-       /*
-        * On ETMv3.5:
-        * ETMACTRn[13,11] == Non-secure state comparison control
-        * ETMACTRn[12,10] == Secure state comparison control
-        *
-        * b00 == Match in all modes in this state
-        * b01 == Do not match in any more in this state
-        * b10 == Match in all modes excepts user mode in this state
-        * b11 == Match only in user mode in this state
-        */
-
-       /* Tracing in secure mode is not supported at this time */
-       flags |= (0 << 12 | 1 << 10);
-
-       if (mode & ETM_MODE_EXCL_USER) {
-               /* exclude user, match all modes except user mode */
-               flags |= (1 << 13 | 0 << 11);
-       } else {
-               /* exclude kernel, match only in user mode */
-               flags |= (1 << 13 | 1 << 11);
-       }
-
-       /*
-        * The ETMEEVR register is already set to "hard wire A".  As such
-        * all there is to do is setup an address comparator that spans
-        * the entire address range and configure the state and mode bits.
-        */
-       config->addr_val[0] = (u32) 0x0;
-       config->addr_val[1] = (u32) ~0x0;
-       config->addr_acctype[0] = flags;
-       config->addr_acctype[1] = flags;
-       config->addr_type[0] = ETM_ADDR_TYPE_RANGE;
-       config->addr_type[1] = ETM_ADDR_TYPE_RANGE;
-}
-
-#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | \
-                                ETMCR_TIMESTAMP_EN | \
-                                ETMCR_RETURN_STACK)
-
-static int etm_parse_event_config(struct etm_drvdata *drvdata,
-                                 struct perf_event *event)
-{
-       struct etm_config *config = &drvdata->config;
-       struct perf_event_attr *attr = &event->attr;
-
-       if (!attr)
-               return -EINVAL;
-
-       /* Clear configuration from previous run */
-       memset(config, 0, sizeof(struct etm_config));
-
-       if (attr->exclude_kernel)
-               config->mode = ETM_MODE_EXCL_KERN;
-
-       if (attr->exclude_user)
-               config->mode = ETM_MODE_EXCL_USER;
-
-       /* Always start from the default config */
-       etm_set_default(config);
-
-       /*
-        * By default the tracers are configured to trace the whole address
-        * range.  Narrow the field only if requested by user space.
-        */
-       if (config->mode)
-               etm_config_trace_mode(config);
-
-       /*
-        * At this time only cycle accurate, return stack  and timestamp
-        * options are available.
-        */
-       if (attr->config & ~ETM3X_SUPPORTED_OPTIONS)
-               return -EINVAL;
-
-       config->ctrl = attr->config;
-
-       /*
-        * Possible to have cores with PTM (supports ret stack) and ETM
-        * (never has ret stack) on the same SoC. So if we have a request
-        * for return stack that can't be honoured on this core then
-        * clear the bit - trace will still continue normally
-        */
-       if ((config->ctrl & ETMCR_RETURN_STACK) &&
-           !(drvdata->etmccer & ETMCCER_RETSTACK))
-               config->ctrl &= ~ETMCR_RETURN_STACK;
-
-       return 0;
-}
-
-static int etm_enable_hw(struct etm_drvdata *drvdata)
-{
-       int i, rc;
-       u32 etmcr;
-       struct etm_config *config = &drvdata->config;
-
-       CS_UNLOCK(drvdata->base);
-
-       rc = coresight_claim_device_unlocked(drvdata->base);
-       if (rc)
-               goto done;
-
-       /* Turn engine on */
-       etm_clr_pwrdwn(drvdata);
-       /* Apply power to trace registers */
-       etm_set_pwrup(drvdata);
-       /* Make sure all registers are accessible */
-       etm_os_unlock(drvdata);
-
-       etm_set_prog(drvdata);
-
-       etmcr = etm_readl(drvdata, ETMCR);
-       /* Clear setting from a previous run if need be */
-       etmcr &= ~ETM3X_SUPPORTED_OPTIONS;
-       etmcr |= drvdata->port_size;
-       etmcr |= ETMCR_ETM_EN;
-       etm_writel(drvdata, config->ctrl | etmcr, ETMCR);
-       etm_writel(drvdata, config->trigger_event, ETMTRIGGER);
-       etm_writel(drvdata, config->startstop_ctrl, ETMTSSCR);
-       etm_writel(drvdata, config->enable_event, ETMTEEVR);
-       etm_writel(drvdata, config->enable_ctrl1, ETMTECR1);
-       etm_writel(drvdata, config->fifofull_level, ETMFFLR);
-       for (i = 0; i < drvdata->nr_addr_cmp; i++) {
-               etm_writel(drvdata, config->addr_val[i], ETMACVRn(i));
-               etm_writel(drvdata, config->addr_acctype[i], ETMACTRn(i));
-       }
-       for (i = 0; i < drvdata->nr_cntr; i++) {
-               etm_writel(drvdata, config->cntr_rld_val[i], ETMCNTRLDVRn(i));
-               etm_writel(drvdata, config->cntr_event[i], ETMCNTENRn(i));
-               etm_writel(drvdata, config->cntr_rld_event[i],
-                          ETMCNTRLDEVRn(i));
-               etm_writel(drvdata, config->cntr_val[i], ETMCNTVRn(i));
-       }
-       etm_writel(drvdata, config->seq_12_event, ETMSQ12EVR);
-       etm_writel(drvdata, config->seq_21_event, ETMSQ21EVR);
-       etm_writel(drvdata, config->seq_23_event, ETMSQ23EVR);
-       etm_writel(drvdata, config->seq_31_event, ETMSQ31EVR);
-       etm_writel(drvdata, config->seq_32_event, ETMSQ32EVR);
-       etm_writel(drvdata, config->seq_13_event, ETMSQ13EVR);
-       etm_writel(drvdata, config->seq_curr_state, ETMSQR);
-       for (i = 0; i < drvdata->nr_ext_out; i++)
-               etm_writel(drvdata, ETM_DEFAULT_EVENT_VAL, ETMEXTOUTEVRn(i));
-       for (i = 0; i < drvdata->nr_ctxid_cmp; i++)
-               etm_writel(drvdata, config->ctxid_pid[i], ETMCIDCVRn(i));
-       etm_writel(drvdata, config->ctxid_mask, ETMCIDCMR);
-       etm_writel(drvdata, config->sync_freq, ETMSYNCFR);
-       /* No external input selected */
-       etm_writel(drvdata, 0x0, ETMEXTINSELR);
-       etm_writel(drvdata, config->timestamp_event, ETMTSEVR);
-       /* No auxiliary control selected */
-       etm_writel(drvdata, 0x0, ETMAUXCR);
-       etm_writel(drvdata, drvdata->traceid, ETMTRACEIDR);
-       /* No VMID comparator value selected */
-       etm_writel(drvdata, 0x0, ETMVMIDCVR);
-
-       etm_clr_prog(drvdata);
-
-done:
-       CS_LOCK(drvdata->base);
-
-       dev_dbg(&drvdata->csdev->dev, "cpu: %d enable smp call done: %d\n",
-               drvdata->cpu, rc);
-       return rc;
-}
-
-struct etm_enable_arg {
-       struct etm_drvdata *drvdata;
-       int rc;
-};
-
-static void etm_enable_hw_smp_call(void *info)
-{
-       struct etm_enable_arg *arg = info;
-
-       if (WARN_ON(!arg))
-               return;
-       arg->rc = etm_enable_hw(arg->drvdata);
-}
-
-static int etm_cpu_id(struct coresight_device *csdev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       return drvdata->cpu;
-}
-
-int etm_get_trace_id(struct etm_drvdata *drvdata)
-{
-       unsigned long flags;
-       int trace_id = -1;
-       struct device *etm_dev;
-
-       if (!drvdata)
-               goto out;
-
-       etm_dev = drvdata->csdev->dev.parent;
-       if (!local_read(&drvdata->mode))
-               return drvdata->traceid;
-
-       pm_runtime_get_sync(etm_dev);
-
-       spin_lock_irqsave(&drvdata->spinlock, flags);
-
-       CS_UNLOCK(drvdata->base);
-       trace_id = (etm_readl(drvdata, ETMTRACEIDR) & ETM_TRACEID_MASK);
-       CS_LOCK(drvdata->base);
-
-       spin_unlock_irqrestore(&drvdata->spinlock, flags);
-       pm_runtime_put(etm_dev);
-
-out:
-       return trace_id;
-
-}
-
-static int etm_trace_id(struct coresight_device *csdev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       return etm_get_trace_id(drvdata);
-}
-
-static int etm_enable_perf(struct coresight_device *csdev,
-                          struct perf_event *event)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
-               return -EINVAL;
-
-       /* Configure the tracer based on the session's specifics */
-       etm_parse_event_config(drvdata, event);
-       /* And enable it */
-       return etm_enable_hw(drvdata);
-}
-
-static int etm_enable_sysfs(struct coresight_device *csdev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-       struct etm_enable_arg arg = { };
-       int ret;
-
-       spin_lock(&drvdata->spinlock);
-
-       /*
-        * Configure the ETM only if the CPU is online.  If it isn't online
-        * hw configuration will take place on the local CPU during bring up.
-        */
-       if (cpu_online(drvdata->cpu)) {
-               arg.drvdata = drvdata;
-               ret = smp_call_function_single(drvdata->cpu,
-                                              etm_enable_hw_smp_call, &arg, 1);
-               if (!ret)
-                       ret = arg.rc;
-               if (!ret)
-                       drvdata->sticky_enable = true;
-       } else {
-               ret = -ENODEV;
-       }
-
-       spin_unlock(&drvdata->spinlock);
-
-       if (!ret)
-               dev_dbg(&csdev->dev, "ETM tracing enabled\n");
-       return ret;
-}
-
-static int etm_enable(struct coresight_device *csdev,
-                     struct perf_event *event, u32 mode)
-{
-       int ret;
-       u32 val;
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode);
-
-       /* Someone is already using the tracer */
-       if (val)
-               return -EBUSY;
-
-       switch (mode) {
-       case CS_MODE_SYSFS:
-               ret = etm_enable_sysfs(csdev);
-               break;
-       case CS_MODE_PERF:
-               ret = etm_enable_perf(csdev, event);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       /* The tracer didn't start */
-       if (ret)
-               local_set(&drvdata->mode, CS_MODE_DISABLED);
-
-       return ret;
-}
-
-static void etm_disable_hw(void *info)
-{
-       int i;
-       struct etm_drvdata *drvdata = info;
-       struct etm_config *config = &drvdata->config;
-
-       CS_UNLOCK(drvdata->base);
-       etm_set_prog(drvdata);
-
-       /* Read back sequencer and counters for post trace analysis */
-       config->seq_curr_state = (etm_readl(drvdata, ETMSQR) & ETM_SQR_MASK);
-
-       for (i = 0; i < drvdata->nr_cntr; i++)
-               config->cntr_val[i] = etm_readl(drvdata, ETMCNTVRn(i));
-
-       etm_set_pwrdwn(drvdata);
-       coresight_disclaim_device_unlocked(drvdata->base);
-
-       CS_LOCK(drvdata->base);
-
-       dev_dbg(&drvdata->csdev->dev,
-               "cpu: %d disable smp call done\n", drvdata->cpu);
-}
-
-static void etm_disable_perf(struct coresight_device *csdev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
-               return;
-
-       CS_UNLOCK(drvdata->base);
-
-       /* Setting the prog bit disables tracing immediately */
-       etm_set_prog(drvdata);
-
-       /*
-        * There is no way to know when the tracer will be used again so
-        * power down the tracer.
-        */
-       etm_set_pwrdwn(drvdata);
-       coresight_disclaim_device_unlocked(drvdata->base);
-
-       CS_LOCK(drvdata->base);
-}
-
-static void etm_disable_sysfs(struct coresight_device *csdev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       /*
-        * Taking hotplug lock here protects from clocks getting disabled
-        * with tracing being left on (crash scenario) if user disable occurs
-        * after cpu online mask indicates the cpu is offline but before the
-        * DYING hotplug callback is serviced by the ETM driver.
-        */
-       cpus_read_lock();
-       spin_lock(&drvdata->spinlock);
-
-       /*
-        * Executing etm_disable_hw on the cpu whose ETM is being disabled
-        * ensures that register writes occur when cpu is powered.
-        */
-       smp_call_function_single(drvdata->cpu, etm_disable_hw, drvdata, 1);
-
-       spin_unlock(&drvdata->spinlock);
-       cpus_read_unlock();
-
-       dev_dbg(&csdev->dev, "ETM tracing disabled\n");
-}
-
-static void etm_disable(struct coresight_device *csdev,
-                       struct perf_event *event)
-{
-       u32 mode;
-       struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       /*
-        * For as long as the tracer isn't disabled another entity can't
-        * change its status.  As such we can read the status here without
-        * fearing it will change under us.
-        */
-       mode = local_read(&drvdata->mode);
-
-       switch (mode) {
-       case CS_MODE_DISABLED:
-               break;
-       case CS_MODE_SYSFS:
-               etm_disable_sysfs(csdev);
-               break;
-       case CS_MODE_PERF:
-               etm_disable_perf(csdev);
-               break;
-       default:
-               WARN_ON_ONCE(mode);
-               return;
-       }
-
-       if (mode)
-               local_set(&drvdata->mode, CS_MODE_DISABLED);
-}
-
-static const struct coresight_ops_source etm_source_ops = {
-       .cpu_id         = etm_cpu_id,
-       .trace_id       = etm_trace_id,
-       .enable         = etm_enable,
-       .disable        = etm_disable,
-};
-
-static const struct coresight_ops etm_cs_ops = {
-       .source_ops     = &etm_source_ops,
-};
-
-static int etm_online_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       if (etmdrvdata[cpu]->boot_enable && !etmdrvdata[cpu]->sticky_enable)
-               coresight_enable(etmdrvdata[cpu]->csdev);
-       return 0;
-}
-
-static int etm_starting_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       spin_lock(&etmdrvdata[cpu]->spinlock);
-       if (!etmdrvdata[cpu]->os_unlock) {
-               etm_os_unlock(etmdrvdata[cpu]);
-               etmdrvdata[cpu]->os_unlock = true;
-       }
-
-       if (local_read(&etmdrvdata[cpu]->mode))
-               etm_enable_hw(etmdrvdata[cpu]);
-       spin_unlock(&etmdrvdata[cpu]->spinlock);
-       return 0;
-}
-
-static int etm_dying_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       spin_lock(&etmdrvdata[cpu]->spinlock);
-       if (local_read(&etmdrvdata[cpu]->mode))
-               etm_disable_hw(etmdrvdata[cpu]);
-       spin_unlock(&etmdrvdata[cpu]->spinlock);
-       return 0;
-}
-
-static bool etm_arch_supported(u8 arch)
-{
-       switch (arch) {
-       case ETM_ARCH_V3_3:
-               break;
-       case ETM_ARCH_V3_5:
-               break;
-       case PFT_ARCH_V1_0:
-               break;
-       case PFT_ARCH_V1_1:
-               break;
-       default:
-               return false;
-       }
-       return true;
-}
-
-static void etm_init_arch_data(void *info)
-{
-       u32 etmidr;
-       u32 etmccr;
-       struct etm_drvdata *drvdata = info;
-
-       /* Make sure all registers are accessible */
-       etm_os_unlock(drvdata);
-
-       CS_UNLOCK(drvdata->base);
-
-       /* First dummy read */
-       (void)etm_readl(drvdata, ETMPDSR);
-       /* Provide power to ETM: ETMPDCR[3] == 1 */
-       etm_set_pwrup(drvdata);
-       /*
-        * Clear power down bit since when this bit is set writes to
-        * certain registers might be ignored.
-        */
-       etm_clr_pwrdwn(drvdata);
-       /*
-        * Set prog bit. It will be set from reset but this is included to
-        * ensure it is set
-        */
-       etm_set_prog(drvdata);
-
-       /* Find all capabilities */
-       etmidr = etm_readl(drvdata, ETMIDR);
-       drvdata->arch = BMVAL(etmidr, 4, 11);
-       drvdata->port_size = etm_readl(drvdata, ETMCR) & PORT_SIZE_MASK;
-
-       drvdata->etmccer = etm_readl(drvdata, ETMCCER);
-       etmccr = etm_readl(drvdata, ETMCCR);
-       drvdata->etmccr = etmccr;
-       drvdata->nr_addr_cmp = BMVAL(etmccr, 0, 3) * 2;
-       drvdata->nr_cntr = BMVAL(etmccr, 13, 15);
-       drvdata->nr_ext_inp = BMVAL(etmccr, 17, 19);
-       drvdata->nr_ext_out = BMVAL(etmccr, 20, 22);
-       drvdata->nr_ctxid_cmp = BMVAL(etmccr, 24, 25);
-
-       etm_set_pwrdwn(drvdata);
-       etm_clr_pwrup(drvdata);
-       CS_LOCK(drvdata->base);
-}
-
-static void etm_init_trace_id(struct etm_drvdata *drvdata)
-{
-       drvdata->traceid = coresight_get_trace_id(drvdata->cpu);
-}
-
-static int etm_probe(struct amba_device *adev, const struct amba_id *id)
-{
-       int ret;
-       void __iomem *base;
-       struct device *dev = &adev->dev;
-       struct coresight_platform_data *pdata = NULL;
-       struct etm_drvdata *drvdata;
-       struct resource *res = &adev->res;
-       struct coresight_desc desc = { 0 };
-
-       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-       if (!drvdata)
-               return -ENOMEM;
-
-       drvdata->use_cp14 = fwnode_property_read_bool(dev->fwnode, "arm,cp14");
-       dev_set_drvdata(dev, drvdata);
-
-       /* Validity for the resource is already checked by the AMBA core */
-       base = devm_ioremap_resource(dev, res);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       drvdata->base = base;
-
-       spin_lock_init(&drvdata->spinlock);
-
-       drvdata->atclk = devm_clk_get(&adev->dev, "atclk"); /* optional */
-       if (!IS_ERR(drvdata->atclk)) {
-               ret = clk_prepare_enable(drvdata->atclk);
-               if (ret)
-                       return ret;
-       }
-
-       drvdata->cpu = coresight_get_cpu(dev);
-       if (drvdata->cpu < 0)
-               return drvdata->cpu;
-
-       desc.name  = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
-       if (!desc.name)
-               return -ENOMEM;
-
-       cpus_read_lock();
-       etmdrvdata[drvdata->cpu] = drvdata;
-
-       if (smp_call_function_single(drvdata->cpu,
-                                    etm_init_arch_data,  drvdata, 1))
-               dev_err(dev, "ETM arch init failed\n");
-
-       if (!etm_count++) {
-               cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,
-                                                    "arm/coresight:starting",
-                                                    etm_starting_cpu, etm_dying_cpu);
-               ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
-                                                          "arm/coresight:online",
-                                                          etm_online_cpu, NULL);
-               if (ret < 0)
-                       goto err_arch_supported;
-               hp_online = ret;
-       }
-       cpus_read_unlock();
-
-       if (etm_arch_supported(drvdata->arch) == false) {
-               ret = -EINVAL;
-               goto err_arch_supported;
-       }
-
-       etm_init_trace_id(drvdata);
-       etm_set_default(&drvdata->config);
-
-       pdata = coresight_get_platform_data(dev);
-       if (IS_ERR(pdata)) {
-               ret = PTR_ERR(pdata);
-               goto err_arch_supported;
-       }
-       adev->dev.platform_data = pdata;
-
-       desc.type = CORESIGHT_DEV_TYPE_SOURCE;
-       desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
-       desc.ops = &etm_cs_ops;
-       desc.pdata = pdata;
-       desc.dev = dev;
-       desc.groups = coresight_etm_groups;
-       drvdata->csdev = coresight_register(&desc);
-       if (IS_ERR(drvdata->csdev)) {
-               ret = PTR_ERR(drvdata->csdev);
-               goto err_arch_supported;
-       }
-
-       ret = etm_perf_symlink(drvdata->csdev, true);
-       if (ret) {
-               coresight_unregister(drvdata->csdev);
-               goto err_arch_supported;
-       }
-
-       pm_runtime_put(&adev->dev);
-       dev_info(&drvdata->csdev->dev,
-                "%s initialized\n", (char *)coresight_get_uci_data(id));
-       if (boot_enable) {
-               coresight_enable(drvdata->csdev);
-               drvdata->boot_enable = true;
-       }
-
-       return 0;
-
-err_arch_supported:
-       if (--etm_count == 0) {
-               cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
-               if (hp_online)
-                       cpuhp_remove_state_nocalls(hp_online);
-       }
-       return ret;
-}
-
-#ifdef CONFIG_PM
-static int etm_runtime_suspend(struct device *dev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(dev);
-
-       if (drvdata && !IS_ERR(drvdata->atclk))
-               clk_disable_unprepare(drvdata->atclk);
-
-       return 0;
-}
-
-static int etm_runtime_resume(struct device *dev)
-{
-       struct etm_drvdata *drvdata = dev_get_drvdata(dev);
-
-       if (drvdata && !IS_ERR(drvdata->atclk))
-               clk_prepare_enable(drvdata->atclk);
-
-       return 0;
-}
-#endif
-
-static const struct dev_pm_ops etm_dev_pm_ops = {
-       SET_RUNTIME_PM_OPS(etm_runtime_suspend, etm_runtime_resume, NULL)
-};
-
-static const struct amba_id etm_ids[] = {
-       /* ETM 3.3 */
-       CS_AMBA_ID_DATA(0x000bb921, "ETM 3.3"),
-       /* ETM 3.5 - Cortex-A5 */
-       CS_AMBA_ID_DATA(0x000bb955, "ETM 3.5"),
-       /* ETM 3.5 */
-       CS_AMBA_ID_DATA(0x000bb956, "ETM 3.5"),
-       /* PTM 1.0 */
-       CS_AMBA_ID_DATA(0x000bb950, "PTM 1.0"),
-       /* PTM 1.1 */
-       CS_AMBA_ID_DATA(0x000bb95f, "PTM 1.1"),
-       /* PTM 1.1 Qualcomm */
-       CS_AMBA_ID_DATA(0x000b006f, "PTM 1.1"),
-       { 0, 0},
-};
-
-static struct amba_driver etm_driver = {
-       .drv = {
-               .name   = "coresight-etm3x",
-               .owner  = THIS_MODULE,
-               .pm     = &etm_dev_pm_ops,
-               .suppress_bind_attrs = true,
-       },
-       .probe          = etm_probe,
-       .id_table       = etm_ids,
-};
-builtin_amba_driver(etm_driver);
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
new file mode 100644 (file)
index 0000000..abd706b
--- /dev/null
@@ -0,0 +1,1659 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ */
+
+#include <linux/kernel.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/smp.h>
+#include <linux/sysfs.h>
+#include <linux/stat.h>
+#include <linux/clk.h>
+#include <linux/cpu.h>
+#include <linux/cpu_pm.h>
+#include <linux/coresight.h>
+#include <linux/coresight-pmu.h>
+#include <linux/pm_wakeup.h>
+#include <linux/amba/bus.h>
+#include <linux/seq_file.h>
+#include <linux/uaccess.h>
+#include <linux/perf_event.h>
+#include <linux/pm_runtime.h>
+#include <linux/property.h>
+#include <asm/sections.h>
+#include <asm/local.h>
+#include <asm/virt.h>
+
+#include "coresight-etm4x.h"
+#include "coresight-etm-perf.h"
+
+static int boot_enable;
+module_param(boot_enable, int, 0444);
+MODULE_PARM_DESC(boot_enable, "Enable tracing on boot");
+
+#define PARAM_PM_SAVE_FIRMWARE   0 /* save self-hosted state as per firmware */
+#define PARAM_PM_SAVE_NEVER      1 /* never save any state */
+#define PARAM_PM_SAVE_SELF_HOSTED 2 /* save self-hosted state only */
+
+static int pm_save_enable = PARAM_PM_SAVE_FIRMWARE;
+module_param(pm_save_enable, int, 0444);
+MODULE_PARM_DESC(pm_save_enable,
+       "Save/restore state on power down: 1 = never, 2 = self-hosted");
+
+static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
+static void etm4_set_default_config(struct etmv4_config *config);
+static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
+                                 struct perf_event *event);
+static u64 etm4_get_access_type(struct etmv4_config *config);
+
+static enum cpuhp_state hp_online;
+
+static void etm4_os_unlock(struct etmv4_drvdata *drvdata)
+{
+       /* Writing 0 to TRCOSLAR unlocks the trace registers */
+       writel_relaxed(0x0, drvdata->base + TRCOSLAR);
+       drvdata->os_unlock = true;
+       isb();
+}
+
+static void etm4_os_lock(struct etmv4_drvdata *drvdata)
+{
+       /* Writing 0x1 to TRCOSLAR locks the trace registers */
+       writel_relaxed(0x1, drvdata->base + TRCOSLAR);
+       drvdata->os_unlock = false;
+       isb();
+}
+
+static bool etm4_arch_supported(u8 arch)
+{
+       /* Mask out the minor version number */
+       switch (arch & 0xf0) {
+       case ETM_ARCH_V4:
+               break;
+       default:
+               return false;
+       }
+       return true;
+}
+
+static int etm4_cpu_id(struct coresight_device *csdev)
+{
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       return drvdata->cpu;
+}
+
+static int etm4_trace_id(struct coresight_device *csdev)
+{
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       return drvdata->trcid;
+}
+
+struct etm4_enable_arg {
+       struct etmv4_drvdata *drvdata;
+       int rc;
+};
+
+static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
+{
+       int i, rc;
+       struct etmv4_config *config = &drvdata->config;
+       struct device *etm_dev = &drvdata->csdev->dev;
+
+       CS_UNLOCK(drvdata->base);
+
+       etm4_os_unlock(drvdata);
+
+       rc = coresight_claim_device_unlocked(drvdata->base);
+       if (rc)
+               goto done;
+
+       /* Disable the trace unit before programming trace registers */
+       writel_relaxed(0, drvdata->base + TRCPRGCTLR);
+
+       /* wait for TRCSTATR.IDLE to go up */
+       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1))
+               dev_err(etm_dev,
+                       "timeout while waiting for Idle Trace Status\n");
+
+       writel_relaxed(config->pe_sel, drvdata->base + TRCPROCSELR);
+       writel_relaxed(config->cfg, drvdata->base + TRCCONFIGR);
+       /* nothing specific implemented */
+       writel_relaxed(0x0, drvdata->base + TRCAUXCTLR);
+       writel_relaxed(config->eventctrl0, drvdata->base + TRCEVENTCTL0R);
+       writel_relaxed(config->eventctrl1, drvdata->base + TRCEVENTCTL1R);
+       writel_relaxed(config->stall_ctrl, drvdata->base + TRCSTALLCTLR);
+       writel_relaxed(config->ts_ctrl, drvdata->base + TRCTSCTLR);
+       writel_relaxed(config->syncfreq, drvdata->base + TRCSYNCPR);
+       writel_relaxed(config->ccctlr, drvdata->base + TRCCCCTLR);
+       writel_relaxed(config->bb_ctrl, drvdata->base + TRCBBCTLR);
+       writel_relaxed(drvdata->trcid, drvdata->base + TRCTRACEIDR);
+       writel_relaxed(config->vinst_ctrl, drvdata->base + TRCVICTLR);
+       writel_relaxed(config->viiectlr, drvdata->base + TRCVIIECTLR);
+       writel_relaxed(config->vissctlr,
+                      drvdata->base + TRCVISSCTLR);
+       writel_relaxed(config->vipcssctlr,
+                      drvdata->base + TRCVIPCSSCTLR);
+       for (i = 0; i < drvdata->nrseqstate - 1; i++)
+               writel_relaxed(config->seq_ctrl[i],
+                              drvdata->base + TRCSEQEVRn(i));
+       writel_relaxed(config->seq_rst, drvdata->base + TRCSEQRSTEVR);
+       writel_relaxed(config->seq_state, drvdata->base + TRCSEQSTR);
+       writel_relaxed(config->ext_inp, drvdata->base + TRCEXTINSELR);
+       for (i = 0; i < drvdata->nr_cntr; i++) {
+               writel_relaxed(config->cntrldvr[i],
+                              drvdata->base + TRCCNTRLDVRn(i));
+               writel_relaxed(config->cntr_ctrl[i],
+                              drvdata->base + TRCCNTCTLRn(i));
+               writel_relaxed(config->cntr_val[i],
+                              drvdata->base + TRCCNTVRn(i));
+       }
+
+       /*
+        * Resource selector pair 0 is always implemented and reserved.  As
+        * such start at 2.
+        */
+       for (i = 2; i < drvdata->nr_resource * 2; i++)
+               writel_relaxed(config->res_ctrl[i],
+                              drvdata->base + TRCRSCTLRn(i));
+
+       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
+               /* always clear status bit on restart if using single-shot */
+               if (config->ss_ctrl[i] || config->ss_pe_cmp[i])
+                       config->ss_status[i] &= ~BIT(31);
+               writel_relaxed(config->ss_ctrl[i],
+                              drvdata->base + TRCSSCCRn(i));
+               writel_relaxed(config->ss_status[i],
+                              drvdata->base + TRCSSCSRn(i));
+               writel_relaxed(config->ss_pe_cmp[i],
+                              drvdata->base + TRCSSPCICRn(i));
+       }
+       for (i = 0; i < drvdata->nr_addr_cmp; i++) {
+               writeq_relaxed(config->addr_val[i],
+                              drvdata->base + TRCACVRn(i));
+               writeq_relaxed(config->addr_acc[i],
+                              drvdata->base + TRCACATRn(i));
+       }
+       for (i = 0; i < drvdata->numcidc; i++)
+               writeq_relaxed(config->ctxid_pid[i],
+                              drvdata->base + TRCCIDCVRn(i));
+       writel_relaxed(config->ctxid_mask0, drvdata->base + TRCCIDCCTLR0);
+       writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1);
+
+       for (i = 0; i < drvdata->numvmidc; i++)
+               writeq_relaxed(config->vmid_val[i],
+                              drvdata->base + TRCVMIDCVRn(i));
+       writel_relaxed(config->vmid_mask0, drvdata->base + TRCVMIDCCTLR0);
+       writel_relaxed(config->vmid_mask1, drvdata->base + TRCVMIDCCTLR1);
+
+       if (!drvdata->skip_power_up) {
+               /*
+                * Request to keep the trace unit powered and also
+                * emulation of powerdown
+                */
+               writel_relaxed(readl_relaxed(drvdata->base + TRCPDCR) |
+                              TRCPDCR_PU, drvdata->base + TRCPDCR);
+       }
+
+       /* Enable the trace unit */
+       writel_relaxed(1, drvdata->base + TRCPRGCTLR);
+
+       /* wait for TRCSTATR.IDLE to go back down to '0' */
+       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0))
+               dev_err(etm_dev,
+                       "timeout while waiting for Idle Trace Status\n");
+
+       /*
+        * As recommended by section 4.3.7 ("Synchronization when using the
+        * memory-mapped interface") of ARM IHI 0064D
+        */
+       dsb(sy);
+       isb();
+
+done:
+       CS_LOCK(drvdata->base);
+
+       dev_dbg(etm_dev, "cpu: %d enable smp call done: %d\n",
+               drvdata->cpu, rc);
+       return rc;
+}
+
+static void etm4_enable_hw_smp_call(void *info)
+{
+       struct etm4_enable_arg *arg = info;
+
+       if (WARN_ON(!arg))
+               return;
+       arg->rc = etm4_enable_hw(arg->drvdata);
+}
+
+/*
+ * The goal of function etm4_config_timestamp_event() is to configure a
+ * counter that will tell the tracer to emit a timestamp packet when it
+ * reaches zero.  This is done in order to get a more fine grained idea
+ * of when instructions are executed so that they can be correlated
+ * with execution on other CPUs.
+ *
+ * To do this the counter itself is configured to self reload and
+ * TRCRSCTLR1 (always true) used to get the counter to decrement.  From
+ * there a resource selector is configured with the counter and the
+ * timestamp control register to use the resource selector to trigger the
+ * event that will insert a timestamp packet in the stream.
+ */
+static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata)
+{
+       int ctridx, ret = -EINVAL;
+       int counter, rselector;
+       u32 val = 0;
+       struct etmv4_config *config = &drvdata->config;
+
+       /* No point in trying if we don't have at least one counter */
+       if (!drvdata->nr_cntr)
+               goto out;
+
+       /* Find a counter that hasn't been initialised */
+       for (ctridx = 0; ctridx < drvdata->nr_cntr; ctridx++)
+               if (config->cntr_val[ctridx] == 0)
+                       break;
+
+       /* All the counters have been configured already, bail out */
+       if (ctridx == drvdata->nr_cntr) {
+               pr_debug("%s: no available counter found\n", __func__);
+               ret = -ENOSPC;
+               goto out;
+       }
+
+       /*
+        * Searching for an available resource selector to use, starting at
+        * '2' since every implementation has at least 2 resource selector.
+        * ETMIDR4 gives the number of resource selector _pairs_,
+        * hence multiply by 2.
+        */
+       for (rselector = 2; rselector < drvdata->nr_resource * 2; rselector++)
+               if (!config->res_ctrl[rselector])
+                       break;
+
+       if (rselector == drvdata->nr_resource * 2) {
+               pr_debug("%s: no available resource selector found\n",
+                        __func__);
+               ret = -ENOSPC;
+               goto out;
+       }
+
+       /* Remember what counter we used */
+       counter = 1 << ctridx;
+
+       /*
+        * Initialise original and reload counter value to the smallest
+        * possible value in order to get as much precision as we can.
+        */
+       config->cntr_val[ctridx] = 1;
+       config->cntrldvr[ctridx] = 1;
+
+       /* Set the trace counter control register */
+       val =  0x1 << 16        |  /* Bit 16, reload counter automatically */
+              0x0 << 7         |  /* Select single resource selector */
+              0x1;                /* Resource selector 1, i.e always true */
+
+       config->cntr_ctrl[ctridx] = val;
+
+       val = 0x2 << 16         | /* Group 0b0010 - Counter and sequencers */
+             counter << 0;       /* Counter to use */
+
+       config->res_ctrl[rselector] = val;
+
+       val = 0x0 << 7          | /* Select single resource selector */
+             rselector;          /* Resource selector */
+
+       config->ts_ctrl = val;
+
+       ret = 0;
+out:
+       return ret;
+}
+
+static int etm4_parse_event_config(struct etmv4_drvdata *drvdata,
+                                  struct perf_event *event)
+{
+       int ret = 0;
+       struct etmv4_config *config = &drvdata->config;
+       struct perf_event_attr *attr = &event->attr;
+
+       if (!attr) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       /* Clear configuration from previous run */
+       memset(config, 0, sizeof(struct etmv4_config));
+
+       if (attr->exclude_kernel)
+               config->mode = ETM_MODE_EXCL_KERN;
+
+       if (attr->exclude_user)
+               config->mode = ETM_MODE_EXCL_USER;
+
+       /* Always start from the default config */
+       etm4_set_default_config(config);
+
+       /* Configure filters specified on the perf cmd line, if any. */
+       ret = etm4_set_event_filters(drvdata, event);
+       if (ret)
+               goto out;
+
+       /* Go from generic option to ETMv4 specifics */
+       if (attr->config & BIT(ETM_OPT_CYCACC)) {
+               config->cfg |= BIT(4);
+               /* TRM: Must program this for cycacc to work */
+               config->ccctlr = ETM_CYC_THRESHOLD_DEFAULT;
+       }
+       if (attr->config & BIT(ETM_OPT_TS)) {
+               /*
+                * Configure timestamps to be emitted at regular intervals in
+                * order to correlate instructions executed on different CPUs
+                * (CPU-wide trace scenarios).
+                */
+               ret = etm4_config_timestamp_event(drvdata);
+
+               /*
+                * No need to go further if timestamp intervals can't
+                * be configured.
+                */
+               if (ret)
+                       goto out;
+
+               /* bit[11], Global timestamp tracing bit */
+               config->cfg |= BIT(11);
+       }
+
+       if (attr->config & BIT(ETM_OPT_CTXTID))
+               /* bit[6], Context ID tracing bit */
+               config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
+
+       /* return stack - enable if selected and supported */
+       if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack)
+               /* bit[12], Return stack enable bit */
+               config->cfg |= BIT(12);
+
+out:
+       return ret;
+}
+
+static int etm4_enable_perf(struct coresight_device *csdev,
+                           struct perf_event *event)
+{
+       int ret = 0;
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       /* Configure the tracer based on the session's specifics */
+       ret = etm4_parse_event_config(drvdata, event);
+       if (ret)
+               goto out;
+       /* And enable it */
+       ret = etm4_enable_hw(drvdata);
+
+out:
+       return ret;
+}
+
+static int etm4_enable_sysfs(struct coresight_device *csdev)
+{
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+       struct etm4_enable_arg arg = { };
+       int ret;
+
+       spin_lock(&drvdata->spinlock);
+
+       /*
+        * Executing etm4_enable_hw on the cpu whose ETM is being enabled
+        * ensures that register writes occur when cpu is powered.
+        */
+       arg.drvdata = drvdata;
+       ret = smp_call_function_single(drvdata->cpu,
+                                      etm4_enable_hw_smp_call, &arg, 1);
+       if (!ret)
+               ret = arg.rc;
+       if (!ret)
+               drvdata->sticky_enable = true;
+       spin_unlock(&drvdata->spinlock);
+
+       if (!ret)
+               dev_dbg(&csdev->dev, "ETM tracing enabled\n");
+       return ret;
+}
+
+static int etm4_enable(struct coresight_device *csdev,
+                      struct perf_event *event, u32 mode)
+{
+       int ret;
+       u32 val;
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode);
+
+       /* Someone is already using the tracer */
+       if (val)
+               return -EBUSY;
+
+       switch (mode) {
+       case CS_MODE_SYSFS:
+               ret = etm4_enable_sysfs(csdev);
+               break;
+       case CS_MODE_PERF:
+               ret = etm4_enable_perf(csdev, event);
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       /* The tracer didn't start */
+       if (ret)
+               local_set(&drvdata->mode, CS_MODE_DISABLED);
+
+       return ret;
+}
+
+static void etm4_disable_hw(void *info)
+{
+       u32 control;
+       struct etmv4_drvdata *drvdata = info;
+       struct etmv4_config *config = &drvdata->config;
+       struct device *etm_dev = &drvdata->csdev->dev;
+       int i;
+
+       CS_UNLOCK(drvdata->base);
+
+       if (!drvdata->skip_power_up) {
+               /* power can be removed from the trace unit now */
+               control = readl_relaxed(drvdata->base + TRCPDCR);
+               control &= ~TRCPDCR_PU;
+               writel_relaxed(control, drvdata->base + TRCPDCR);
+       }
+
+       control = readl_relaxed(drvdata->base + TRCPRGCTLR);
+
+       /* EN, bit[0] Trace unit enable bit */
+       control &= ~0x1;
+
+       /*
+        * Make sure everything completes before disabling, as recommended
+        * by section 7.3.77 ("TRCVICTLR, ViewInst Main Control Register,
+        * SSTATUS") of ARM IHI 0064D
+        */
+       dsb(sy);
+       isb();
+       writel_relaxed(control, drvdata->base + TRCPRGCTLR);
+
+       /* wait for TRCSTATR.PMSTABLE to go to '1' */
+       if (coresight_timeout(drvdata->base, TRCSTATR,
+                             TRCSTATR_PMSTABLE_BIT, 1))
+               dev_err(etm_dev,
+                       "timeout while waiting for PM stable Trace Status\n");
+
+       /* read the status of the single shot comparators */
+       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
+               config->ss_status[i] =
+                       readl_relaxed(drvdata->base + TRCSSCSRn(i));
+       }
+
+       /* read back the current counter values */
+       for (i = 0; i < drvdata->nr_cntr; i++) {
+               config->cntr_val[i] =
+                       readl_relaxed(drvdata->base + TRCCNTVRn(i));
+       }
+
+       coresight_disclaim_device_unlocked(drvdata->base);
+
+       CS_LOCK(drvdata->base);
+
+       dev_dbg(&drvdata->csdev->dev,
+               "cpu: %d disable smp call done\n", drvdata->cpu);
+}
+
+static int etm4_disable_perf(struct coresight_device *csdev,
+                            struct perf_event *event)
+{
+       u32 control;
+       struct etm_filters *filters = event->hw.addr_filters;
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
+               return -EINVAL;
+
+       etm4_disable_hw(drvdata);
+
+       /*
+        * Check if the start/stop logic was active when the unit was stopped.
+        * That way we can re-enable the start/stop logic when the process is
+        * scheduled again.  Configuration of the start/stop logic happens in
+        * function etm4_set_event_filters().
+        */
+       control = readl_relaxed(drvdata->base + TRCVICTLR);
+       /* TRCVICTLR::SSSTATUS, bit[9] */
+       filters->ssstatus = (control & BIT(9));
+
+       return 0;
+}
+
+static void etm4_disable_sysfs(struct coresight_device *csdev)
+{
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       /*
+        * Taking hotplug lock here protects from clocks getting disabled
+        * with tracing being left on (crash scenario) if user disable occurs
+        * after cpu online mask indicates the cpu is offline but before the
+        * DYING hotplug callback is serviced by the ETM driver.
+        */
+       cpus_read_lock();
+       spin_lock(&drvdata->spinlock);
+
+       /*
+        * Executing etm4_disable_hw on the cpu whose ETM is being disabled
+        * ensures that register writes occur when cpu is powered.
+        */
+       smp_call_function_single(drvdata->cpu, etm4_disable_hw, drvdata, 1);
+
+       spin_unlock(&drvdata->spinlock);
+       cpus_read_unlock();
+
+       dev_dbg(&csdev->dev, "ETM tracing disabled\n");
+}
+
+static void etm4_disable(struct coresight_device *csdev,
+                        struct perf_event *event)
+{
+       u32 mode;
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
+
+       /*
+        * For as long as the tracer isn't disabled another entity can't
+        * change its status.  As such we can read the status here without
+        * fearing it will change under us.
+        */
+       mode = local_read(&drvdata->mode);
+
+       switch (mode) {
+       case CS_MODE_DISABLED:
+               break;
+       case CS_MODE_SYSFS:
+               etm4_disable_sysfs(csdev);
+               break;
+       case CS_MODE_PERF:
+               etm4_disable_perf(csdev, event);
+               break;
+       }
+
+       if (mode)
+               local_set(&drvdata->mode, CS_MODE_DISABLED);
+}
+
+static const struct coresight_ops_source etm4_source_ops = {
+       .cpu_id         = etm4_cpu_id,
+       .trace_id       = etm4_trace_id,
+       .enable         = etm4_enable,
+       .disable        = etm4_disable,
+};
+
+static const struct coresight_ops etm4_cs_ops = {
+       .source_ops     = &etm4_source_ops,
+};
+
+static void etm4_init_arch_data(void *info)
+{
+       u32 etmidr0;
+       u32 etmidr1;
+       u32 etmidr2;
+       u32 etmidr3;
+       u32 etmidr4;
+       u32 etmidr5;
+       struct etmv4_drvdata *drvdata = info;
+       int i;
+
+       /* Make sure all registers are accessible */
+       etm4_os_unlock(drvdata);
+
+       CS_UNLOCK(drvdata->base);
+
+       /* find all capabilities of the tracing unit */
+       etmidr0 = readl_relaxed(drvdata->base + TRCIDR0);
+
+       /* INSTP0, bits[2:1] P0 tracing support field */
+       if (BMVAL(etmidr0, 1, 1) && BMVAL(etmidr0, 2, 2))
+               drvdata->instrp0 = true;
+       else
+               drvdata->instrp0 = false;
+
+       /* TRCBB, bit[5] Branch broadcast tracing support bit */
+       if (BMVAL(etmidr0, 5, 5))
+               drvdata->trcbb = true;
+       else
+               drvdata->trcbb = false;
+
+       /* TRCCOND, bit[6] Conditional instruction tracing support bit */
+       if (BMVAL(etmidr0, 6, 6))
+               drvdata->trccond = true;
+       else
+               drvdata->trccond = false;
+
+       /* TRCCCI, bit[7] Cycle counting instruction bit */
+       if (BMVAL(etmidr0, 7, 7))
+               drvdata->trccci = true;
+       else
+               drvdata->trccci = false;
+
+       /* RETSTACK, bit[9] Return stack bit */
+       if (BMVAL(etmidr0, 9, 9))
+               drvdata->retstack = true;
+       else
+               drvdata->retstack = false;
+
+       /* NUMEVENT, bits[11:10] Number of events field */
+       drvdata->nr_event = BMVAL(etmidr0, 10, 11);
+       /* QSUPP, bits[16:15] Q element support field */
+       drvdata->q_support = BMVAL(etmidr0, 15, 16);
+       /* TSSIZE, bits[28:24] Global timestamp size field */
+       drvdata->ts_size = BMVAL(etmidr0, 24, 28);
+
+       /* base architecture of trace unit */
+       etmidr1 = readl_relaxed(drvdata->base + TRCIDR1);
+       /*
+        * TRCARCHMIN, bits[7:4] architecture the minor version number
+        * TRCARCHMAJ, bits[11:8] architecture major versin number
+        */
+       drvdata->arch = BMVAL(etmidr1, 4, 11);
+       drvdata->config.arch = drvdata->arch;
+
+       /* maximum size of resources */
+       etmidr2 = readl_relaxed(drvdata->base + TRCIDR2);
+       /* CIDSIZE, bits[9:5] Indicates the Context ID size */
+       drvdata->ctxid_size = BMVAL(etmidr2, 5, 9);
+       /* VMIDSIZE, bits[14:10] Indicates the VMID size */
+       drvdata->vmid_size = BMVAL(etmidr2, 10, 14);
+       /* CCSIZE, bits[28:25] size of the cycle counter in bits minus 12 */
+       drvdata->ccsize = BMVAL(etmidr2, 25, 28);
+
+       etmidr3 = readl_relaxed(drvdata->base + TRCIDR3);
+       /* CCITMIN, bits[11:0] minimum threshold value that can be programmed */
+       drvdata->ccitmin = BMVAL(etmidr3, 0, 11);
+       /* EXLEVEL_S, bits[19:16] Secure state instruction tracing */
+       drvdata->s_ex_level = BMVAL(etmidr3, 16, 19);
+       /* EXLEVEL_NS, bits[23:20] Non-secure state instruction tracing */
+       drvdata->ns_ex_level = BMVAL(etmidr3, 20, 23);
+
+       /*
+        * TRCERR, bit[24] whether a trace unit can trace a
+        * system error exception.
+        */
+       if (BMVAL(etmidr3, 24, 24))
+               drvdata->trc_error = true;
+       else
+               drvdata->trc_error = false;
+
+       /* SYNCPR, bit[25] implementation has a fixed synchronization period? */
+       if (BMVAL(etmidr3, 25, 25))
+               drvdata->syncpr = true;
+       else
+               drvdata->syncpr = false;
+
+       /* STALLCTL, bit[26] is stall control implemented? */
+       if (BMVAL(etmidr3, 26, 26))
+               drvdata->stallctl = true;
+       else
+               drvdata->stallctl = false;
+
+       /* SYSSTALL, bit[27] implementation can support stall control? */
+       if (BMVAL(etmidr3, 27, 27))
+               drvdata->sysstall = true;
+       else
+               drvdata->sysstall = false;
+
+       /* NUMPROC, bits[30:28] the number of PEs available for tracing */
+       drvdata->nr_pe = BMVAL(etmidr3, 28, 30);
+
+       /* NOOVERFLOW, bit[31] is trace overflow prevention supported */
+       if (BMVAL(etmidr3, 31, 31))
+               drvdata->nooverflow = true;
+       else
+               drvdata->nooverflow = false;
+
+       /* number of resources trace unit supports */
+       etmidr4 = readl_relaxed(drvdata->base + TRCIDR4);
+       /* NUMACPAIRS, bits[0:3] number of addr comparator pairs for tracing */
+       drvdata->nr_addr_cmp = BMVAL(etmidr4, 0, 3);
+       /* NUMPC, bits[15:12] number of PE comparator inputs for tracing */
+       drvdata->nr_pe_cmp = BMVAL(etmidr4, 12, 15);
+       /*
+        * NUMRSPAIR, bits[19:16]
+        * The number of resource pairs conveyed by the HW starts at 0, i.e a
+        * value of 0x0 indicate 1 resource pair, 0x1 indicate two and so on.
+        * As such add 1 to the value of NUMRSPAIR for a better representation.
+        *
+        * For ETM v4.3 and later, 0x0 means 0, and no pairs are available -
+        * the default TRUE and FALSE resource selectors are omitted.
+        * Otherwise for values 0x1 and above the number is N + 1 as per v4.2.
+        */
+       drvdata->nr_resource = BMVAL(etmidr4, 16, 19);
+       if ((drvdata->arch < ETM4X_ARCH_4V3) || (drvdata->nr_resource > 0))
+               drvdata->nr_resource += 1;
+       /*
+        * NUMSSCC, bits[23:20] the number of single-shot
+        * comparator control for tracing. Read any status regs as these
+        * also contain RO capability data.
+        */
+       drvdata->nr_ss_cmp = BMVAL(etmidr4, 20, 23);
+       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
+               drvdata->config.ss_status[i] =
+                       readl_relaxed(drvdata->base + TRCSSCSRn(i));
+       }
+       /* NUMCIDC, bits[27:24] number of Context ID comparators for tracing */
+       drvdata->numcidc = BMVAL(etmidr4, 24, 27);
+       /* NUMVMIDC, bits[31:28] number of VMID comparators for tracing */
+       drvdata->numvmidc = BMVAL(etmidr4, 28, 31);
+
+       etmidr5 = readl_relaxed(drvdata->base + TRCIDR5);
+       /* NUMEXTIN, bits[8:0] number of external inputs implemented */
+       drvdata->nr_ext_inp = BMVAL(etmidr5, 0, 8);
+       /* TRACEIDSIZE, bits[21:16] indicates the trace ID width */
+       drvdata->trcid_size = BMVAL(etmidr5, 16, 21);
+       /* ATBTRIG, bit[22] implementation can support ATB triggers? */
+       if (BMVAL(etmidr5, 22, 22))
+               drvdata->atbtrig = true;
+       else
+               drvdata->atbtrig = false;
+       /*
+        * LPOVERRIDE, bit[23] implementation supports
+        * low-power state override
+        */
+       if (BMVAL(etmidr5, 23, 23))
+               drvdata->lpoverride = true;
+       else
+               drvdata->lpoverride = false;
+       /* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */
+       drvdata->nrseqstate = BMVAL(etmidr5, 25, 27);
+       /* NUMCNTR, bits[30:28] number of counters available for tracing */
+       drvdata->nr_cntr = BMVAL(etmidr5, 28, 30);
+       CS_LOCK(drvdata->base);
+}
+
+/* Set ELx trace filter access in the TRCVICTLR register */
+static void etm4_set_victlr_access(struct etmv4_config *config)
+{
+       u64 access_type;
+
+       config->vinst_ctrl &= ~(ETM_EXLEVEL_S_VICTLR_MASK | ETM_EXLEVEL_NS_VICTLR_MASK);
+
+       /*
+        * TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering
+        * bits in vinst_ctrl, same bit pattern as TRCACATRn values returned by
+        * etm4_get_access_type() but with a relative shift in this register.
+        */
+       access_type = etm4_get_access_type(config) << ETM_EXLEVEL_LSHIFT_TRCVICTLR;
+       config->vinst_ctrl |= (u32)access_type;
+}
+
+static void etm4_set_default_config(struct etmv4_config *config)
+{
+       /* disable all events tracing */
+       config->eventctrl0 = 0x0;
+       config->eventctrl1 = 0x0;
+
+       /* disable stalling */
+       config->stall_ctrl = 0x0;
+
+       /* enable trace synchronization every 4096 bytes, if available */
+       config->syncfreq = 0xC;
+
+       /* disable timestamp event */
+       config->ts_ctrl = 0x0;
+
+       /* TRCVICTLR::EVENT = 0x01, select the always on logic */
+       config->vinst_ctrl = BIT(0);
+
+       /* TRCVICTLR::EXLEVEL_NS:EXLEVELS: Set kernel / user filtering */
+       etm4_set_victlr_access(config);
+}
+
+static u64 etm4_get_ns_access_type(struct etmv4_config *config)
+{
+       u64 access_type = 0;
+
+       /*
+        * EXLEVEL_NS, bits[15:12]
+        * The Exception levels are:
+        *   Bit[12] Exception level 0 - Application
+        *   Bit[13] Exception level 1 - OS
+        *   Bit[14] Exception level 2 - Hypervisor
+        *   Bit[15] Never implemented
+        */
+       if (!is_kernel_in_hyp_mode()) {
+               /* Stay away from hypervisor mode for non-VHE */
+               access_type =  ETM_EXLEVEL_NS_HYP;
+               if (config->mode & ETM_MODE_EXCL_KERN)
+                       access_type |= ETM_EXLEVEL_NS_OS;
+       } else if (config->mode & ETM_MODE_EXCL_KERN) {
+               access_type = ETM_EXLEVEL_NS_HYP;
+       }
+
+       if (config->mode & ETM_MODE_EXCL_USER)
+               access_type |= ETM_EXLEVEL_NS_APP;
+
+       return access_type;
+}
+
+static u64 etm4_get_access_type(struct etmv4_config *config)
+{
+       u64 access_type = etm4_get_ns_access_type(config);
+       u64 s_hyp = (config->arch & 0x0f) >= 0x4 ? ETM_EXLEVEL_S_HYP : 0;
+
+       /*
+        * EXLEVEL_S, bits[11:8], don't trace anything happening
+        * in secure state.
+        */
+       access_type |= (ETM_EXLEVEL_S_APP       |
+                       ETM_EXLEVEL_S_OS        |
+                       s_hyp                   |
+                       ETM_EXLEVEL_S_MON);
+
+       return access_type;
+}
+
+static void etm4_set_comparator_filter(struct etmv4_config *config,
+                                      u64 start, u64 stop, int comparator)
+{
+       u64 access_type = etm4_get_access_type(config);
+
+       /* First half of default address comparator */
+       config->addr_val[comparator] = start;
+       config->addr_acc[comparator] = access_type;
+       config->addr_type[comparator] = ETM_ADDR_TYPE_RANGE;
+
+       /* Second half of default address comparator */
+       config->addr_val[comparator + 1] = stop;
+       config->addr_acc[comparator + 1] = access_type;
+       config->addr_type[comparator + 1] = ETM_ADDR_TYPE_RANGE;
+
+       /*
+        * Configure the ViewInst function to include this address range
+        * comparator.
+        *
+        * @comparator is divided by two since it is the index in the
+        * etmv4_config::addr_val array but register TRCVIIECTLR deals with
+        * address range comparator _pairs_.
+        *
+        * Therefore:
+        *      index 0 -> compatator pair 0
+        *      index 2 -> comparator pair 1
+        *      index 4 -> comparator pair 2
+        *      ...
+        *      index 14 -> comparator pair 7
+        */
+       config->viiectlr |= BIT(comparator / 2);
+}
+
+static void etm4_set_start_stop_filter(struct etmv4_config *config,
+                                      u64 address, int comparator,
+                                      enum etm_addr_type type)
+{
+       int shift;
+       u64 access_type = etm4_get_access_type(config);
+
+       /* Configure the comparator */
+       config->addr_val[comparator] = address;
+       config->addr_acc[comparator] = access_type;
+       config->addr_type[comparator] = type;
+
+       /*
+        * Configure ViewInst Start-Stop control register.
+        * Addresses configured to start tracing go from bit 0 to n-1,
+        * while those configured to stop tracing from 16 to 16 + n-1.
+        */
+       shift = (type == ETM_ADDR_TYPE_START ? 0 : 16);
+       config->vissctlr |= BIT(shift + comparator);
+}
+
+static void etm4_set_default_filter(struct etmv4_config *config)
+{
+       /* Trace everything 'default' filter achieved by no filtering */
+       config->viiectlr = 0x0;
+
+       /*
+        * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
+        * in the started state
+        */
+       config->vinst_ctrl |= BIT(9);
+       config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
+
+       /* No start-stop filtering for ViewInst */
+       config->vissctlr = 0x0;
+}
+
+static void etm4_set_default(struct etmv4_config *config)
+{
+       if (WARN_ON_ONCE(!config))
+               return;
+
+       /*
+        * Make default initialisation trace everything
+        *
+        * This is done by a minimum default config sufficient to enable
+        * full instruction trace - with a default filter for trace all
+        * achieved by having no filtering.
+        */
+       etm4_set_default_config(config);
+       etm4_set_default_filter(config);
+}
+
+static int etm4_get_next_comparator(struct etmv4_drvdata *drvdata, u32 type)
+{
+       int nr_comparator, index = 0;
+       struct etmv4_config *config = &drvdata->config;
+
+       /*
+        * nr_addr_cmp holds the number of comparator _pair_, so time 2
+        * for the total number of comparators.
+        */
+       nr_comparator = drvdata->nr_addr_cmp * 2;
+
+       /* Go through the tally of comparators looking for a free one. */
+       while (index < nr_comparator) {
+               switch (type) {
+               case ETM_ADDR_TYPE_RANGE:
+                       if (config->addr_type[index] == ETM_ADDR_TYPE_NONE &&
+                           config->addr_type[index + 1] == ETM_ADDR_TYPE_NONE)
+                               return index;
+
+                       /* Address range comparators go in pairs */
+                       index += 2;
+                       break;
+               case ETM_ADDR_TYPE_START:
+               case ETM_ADDR_TYPE_STOP:
+                       if (config->addr_type[index] == ETM_ADDR_TYPE_NONE)
+                               return index;
+
+                       /* Start/stop address can have odd indexes */
+                       index += 1;
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       }
+
+       /* If we are here all the comparators have been used. */
+       return -ENOSPC;
+}
+
+static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
+                                 struct perf_event *event)
+{
+       int i, comparator, ret = 0;
+       u64 address;
+       struct etmv4_config *config = &drvdata->config;
+       struct etm_filters *filters = event->hw.addr_filters;
+
+       if (!filters)
+               goto default_filter;
+
+       /* Sync events with what Perf got */
+       perf_event_addr_filters_sync(event);
+
+       /*
+        * If there are no filters to deal with simply go ahead with
+        * the default filter, i.e the entire address range.
+        */
+       if (!filters->nr_filters)
+               goto default_filter;
+
+       for (i = 0; i < filters->nr_filters; i++) {
+               struct etm_filter *filter = &filters->etm_filter[i];
+               enum etm_addr_type type = filter->type;
+
+               /* See if a comparator is free. */
+               comparator = etm4_get_next_comparator(drvdata, type);
+               if (comparator < 0) {
+                       ret = comparator;
+                       goto out;
+               }
+
+               switch (type) {
+               case ETM_ADDR_TYPE_RANGE:
+                       etm4_set_comparator_filter(config,
+                                                  filter->start_addr,
+                                                  filter->stop_addr,
+                                                  comparator);
+                       /*
+                        * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
+                        * in the started state
+                        */
+                       config->vinst_ctrl |= BIT(9);
+
+                       /* No start-stop filtering for ViewInst */
+                       config->vissctlr = 0x0;
+                       break;
+               case ETM_ADDR_TYPE_START:
+               case ETM_ADDR_TYPE_STOP:
+                       /* Get the right start or stop address */
+                       address = (type == ETM_ADDR_TYPE_START ?
+                                  filter->start_addr :
+                                  filter->stop_addr);
+
+                       /* Configure comparator */
+                       etm4_set_start_stop_filter(config, address,
+                                                  comparator, type);
+
+                       /*
+                        * If filters::ssstatus == 1, trace acquisition was
+                        * started but the process was yanked away before the
+                        * the stop address was hit.  As such the start/stop
+                        * logic needs to be re-started so that tracing can
+                        * resume where it left.
+                        *
+                        * The start/stop logic status when a process is
+                        * scheduled out is checked in function
+                        * etm4_disable_perf().
+                        */
+                       if (filters->ssstatus)
+                               config->vinst_ctrl |= BIT(9);
+
+                       /* No include/exclude filtering for ViewInst */
+                       config->viiectlr = 0x0;
+                       break;
+               default:
+                       ret = -EINVAL;
+                       goto out;
+               }
+       }
+
+       goto out;
+
+
+default_filter:
+       etm4_set_default_filter(config);
+
+out:
+       return ret;
+}
+
+void etm4_config_trace_mode(struct etmv4_config *config)
+{
+       u32 mode;
+
+       mode = config->mode;
+       mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER);
+
+       /* excluding kernel AND user space doesn't make sense */
+       WARN_ON_ONCE(mode == (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER));
+
+       /* nothing to do if neither flags are set */
+       if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
+               return;
+
+       etm4_set_victlr_access(config);
+}
+
+static int etm4_online_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       if (etmdrvdata[cpu]->boot_enable && !etmdrvdata[cpu]->sticky_enable)
+               coresight_enable(etmdrvdata[cpu]->csdev);
+       return 0;
+}
+
+static int etm4_starting_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       spin_lock(&etmdrvdata[cpu]->spinlock);
+       if (!etmdrvdata[cpu]->os_unlock)
+               etm4_os_unlock(etmdrvdata[cpu]);
+
+       if (local_read(&etmdrvdata[cpu]->mode))
+               etm4_enable_hw(etmdrvdata[cpu]);
+       spin_unlock(&etmdrvdata[cpu]->spinlock);
+       return 0;
+}
+
+static int etm4_dying_cpu(unsigned int cpu)
+{
+       if (!etmdrvdata[cpu])
+               return 0;
+
+       spin_lock(&etmdrvdata[cpu]->spinlock);
+       if (local_read(&etmdrvdata[cpu]->mode))
+               etm4_disable_hw(etmdrvdata[cpu]);
+       spin_unlock(&etmdrvdata[cpu]->spinlock);
+       return 0;
+}
+
+static void etm4_init_trace_id(struct etmv4_drvdata *drvdata)
+{
+       drvdata->trcid = coresight_get_trace_id(drvdata->cpu);
+}
+
+static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
+{
+       int i, ret = 0;
+       struct etmv4_save_state *state;
+       struct device *etm_dev = &drvdata->csdev->dev;
+
+       /*
+        * As recommended by 3.4.1 ("The procedure when powering down the PE")
+        * of ARM IHI 0064D
+        */
+       dsb(sy);
+       isb();
+
+       CS_UNLOCK(drvdata->base);
+
+       /* Lock the OS lock to disable trace and external debugger access */
+       etm4_os_lock(drvdata);
+
+       /* wait for TRCSTATR.PMSTABLE to go up */
+       if (coresight_timeout(drvdata->base, TRCSTATR,
+                             TRCSTATR_PMSTABLE_BIT, 1)) {
+               dev_err(etm_dev,
+                       "timeout while waiting for PM Stable Status\n");
+               etm4_os_unlock(drvdata);
+               ret = -EBUSY;
+               goto out;
+       }
+
+       state = drvdata->save_state;
+
+       state->trcprgctlr = readl(drvdata->base + TRCPRGCTLR);
+       state->trcprocselr = readl(drvdata->base + TRCPROCSELR);
+       state->trcconfigr = readl(drvdata->base + TRCCONFIGR);
+       state->trcauxctlr = readl(drvdata->base + TRCAUXCTLR);
+       state->trceventctl0r = readl(drvdata->base + TRCEVENTCTL0R);
+       state->trceventctl1r = readl(drvdata->base + TRCEVENTCTL1R);
+       state->trcstallctlr = readl(drvdata->base + TRCSTALLCTLR);
+       state->trctsctlr = readl(drvdata->base + TRCTSCTLR);
+       state->trcsyncpr = readl(drvdata->base + TRCSYNCPR);
+       state->trcccctlr = readl(drvdata->base + TRCCCCTLR);
+       state->trcbbctlr = readl(drvdata->base + TRCBBCTLR);
+       state->trctraceidr = readl(drvdata->base + TRCTRACEIDR);
+       state->trcqctlr = readl(drvdata->base + TRCQCTLR);
+
+       state->trcvictlr = readl(drvdata->base + TRCVICTLR);
+       state->trcviiectlr = readl(drvdata->base + TRCVIIECTLR);
+       state->trcvissctlr = readl(drvdata->base + TRCVISSCTLR);
+       state->trcvipcssctlr = readl(drvdata->base + TRCVIPCSSCTLR);
+       state->trcvdctlr = readl(drvdata->base + TRCVDCTLR);
+       state->trcvdsacctlr = readl(drvdata->base + TRCVDSACCTLR);
+       state->trcvdarcctlr = readl(drvdata->base + TRCVDARCCTLR);
+
+       for (i = 0; i < drvdata->nrseqstate - 1; i++)
+               state->trcseqevr[i] = readl(drvdata->base + TRCSEQEVRn(i));
+
+       state->trcseqrstevr = readl(drvdata->base + TRCSEQRSTEVR);
+       state->trcseqstr = readl(drvdata->base + TRCSEQSTR);
+       state->trcextinselr = readl(drvdata->base + TRCEXTINSELR);
+
+       for (i = 0; i < drvdata->nr_cntr; i++) {
+               state->trccntrldvr[i] = readl(drvdata->base + TRCCNTRLDVRn(i));
+               state->trccntctlr[i] = readl(drvdata->base + TRCCNTCTLRn(i));
+               state->trccntvr[i] = readl(drvdata->base + TRCCNTVRn(i));
+       }
+
+       for (i = 0; i < drvdata->nr_resource * 2; i++)
+               state->trcrsctlr[i] = readl(drvdata->base + TRCRSCTLRn(i));
+
+       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
+               state->trcssccr[i] = readl(drvdata->base + TRCSSCCRn(i));
+               state->trcsscsr[i] = readl(drvdata->base + TRCSSCSRn(i));
+               state->trcsspcicr[i] = readl(drvdata->base + TRCSSPCICRn(i));
+       }
+
+       for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
+               state->trcacvr[i] = readq(drvdata->base + TRCACVRn(i));
+               state->trcacatr[i] = readq(drvdata->base + TRCACATRn(i));
+       }
+
+       /*
+        * Data trace stream is architecturally prohibited for A profile cores
+        * so we don't save (or later restore) trcdvcvr and trcdvcmr - As per
+        * section 1.3.4 ("Possible functional configurations of an ETMv4 trace
+        * unit") of ARM IHI 0064D.
+        */
+
+       for (i = 0; i < drvdata->numcidc; i++)
+               state->trccidcvr[i] = readq(drvdata->base + TRCCIDCVRn(i));
+
+       for (i = 0; i < drvdata->numvmidc; i++)
+               state->trcvmidcvr[i] = readq(drvdata->base + TRCVMIDCVRn(i));
+
+       state->trccidcctlr0 = readl(drvdata->base + TRCCIDCCTLR0);
+       state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1);
+
+       state->trcvmidcctlr0 = readl(drvdata->base + TRCVMIDCCTLR0);
+       state->trcvmidcctlr1 = readl(drvdata->base + TRCVMIDCCTLR1);
+
+       state->trcclaimset = readl(drvdata->base + TRCCLAIMCLR);
+
+       state->trcpdcr = readl(drvdata->base + TRCPDCR);
+
+       /* wait for TRCSTATR.IDLE to go up */
+       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1)) {
+               dev_err(etm_dev,
+                       "timeout while waiting for Idle Trace Status\n");
+               etm4_os_unlock(drvdata);
+               ret = -EBUSY;
+               goto out;
+       }
+
+       drvdata->state_needs_restore = true;
+
+       /*
+        * Power can be removed from the trace unit now. We do this to
+        * potentially save power on systems that respect the TRCPDCR_PU
+        * despite requesting software to save/restore state.
+        */
+       writel_relaxed((state->trcpdcr & ~TRCPDCR_PU),
+                       drvdata->base + TRCPDCR);
+
+out:
+       CS_LOCK(drvdata->base);
+       return ret;
+}
+
+static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
+{
+       int i;
+       struct etmv4_save_state *state = drvdata->save_state;
+
+       CS_UNLOCK(drvdata->base);
+
+       writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET);
+
+       writel_relaxed(state->trcprgctlr, drvdata->base + TRCPRGCTLR);
+       writel_relaxed(state->trcprocselr, drvdata->base + TRCPROCSELR);
+       writel_relaxed(state->trcconfigr, drvdata->base + TRCCONFIGR);
+       writel_relaxed(state->trcauxctlr, drvdata->base + TRCAUXCTLR);
+       writel_relaxed(state->trceventctl0r, drvdata->base + TRCEVENTCTL0R);
+       writel_relaxed(state->trceventctl1r, drvdata->base + TRCEVENTCTL1R);
+       writel_relaxed(state->trcstallctlr, drvdata->base + TRCSTALLCTLR);
+       writel_relaxed(state->trctsctlr, drvdata->base + TRCTSCTLR);
+       writel_relaxed(state->trcsyncpr, drvdata->base + TRCSYNCPR);
+       writel_relaxed(state->trcccctlr, drvdata->base + TRCCCCTLR);
+       writel_relaxed(state->trcbbctlr, drvdata->base + TRCBBCTLR);
+       writel_relaxed(state->trctraceidr, drvdata->base + TRCTRACEIDR);
+       writel_relaxed(state->trcqctlr, drvdata->base + TRCQCTLR);
+
+       writel_relaxed(state->trcvictlr, drvdata->base + TRCVICTLR);
+       writel_relaxed(state->trcviiectlr, drvdata->base + TRCVIIECTLR);
+       writel_relaxed(state->trcvissctlr, drvdata->base + TRCVISSCTLR);
+       writel_relaxed(state->trcvipcssctlr, drvdata->base + TRCVIPCSSCTLR);
+       writel_relaxed(state->trcvdctlr, drvdata->base + TRCVDCTLR);
+       writel_relaxed(state->trcvdsacctlr, drvdata->base + TRCVDSACCTLR);
+       writel_relaxed(state->trcvdarcctlr, drvdata->base + TRCVDARCCTLR);
+
+       for (i = 0; i < drvdata->nrseqstate - 1; i++)
+               writel_relaxed(state->trcseqevr[i],
+                              drvdata->base + TRCSEQEVRn(i));
+
+       writel_relaxed(state->trcseqrstevr, drvdata->base + TRCSEQRSTEVR);
+       writel_relaxed(state->trcseqstr, drvdata->base + TRCSEQSTR);
+       writel_relaxed(state->trcextinselr, drvdata->base + TRCEXTINSELR);
+
+       for (i = 0; i < drvdata->nr_cntr; i++) {
+               writel_relaxed(state->trccntrldvr[i],
+                              drvdata->base + TRCCNTRLDVRn(i));
+               writel_relaxed(state->trccntctlr[i],
+                              drvdata->base + TRCCNTCTLRn(i));
+               writel_relaxed(state->trccntvr[i],
+                              drvdata->base + TRCCNTVRn(i));
+       }
+
+       for (i = 0; i < drvdata->nr_resource * 2; i++)
+               writel_relaxed(state->trcrsctlr[i],
+                              drvdata->base + TRCRSCTLRn(i));
+
+       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
+               writel_relaxed(state->trcssccr[i],
+                              drvdata->base + TRCSSCCRn(i));
+               writel_relaxed(state->trcsscsr[i],
+                              drvdata->base + TRCSSCSRn(i));
+               writel_relaxed(state->trcsspcicr[i],
+                              drvdata->base + TRCSSPCICRn(i));
+       }
+
+       for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
+               writeq_relaxed(state->trcacvr[i],
+                              drvdata->base + TRCACVRn(i));
+               writeq_relaxed(state->trcacatr[i],
+                              drvdata->base + TRCACATRn(i));
+       }
+
+       for (i = 0; i < drvdata->numcidc; i++)
+               writeq_relaxed(state->trccidcvr[i],
+                              drvdata->base + TRCCIDCVRn(i));
+
+       for (i = 0; i < drvdata->numvmidc; i++)
+               writeq_relaxed(state->trcvmidcvr[i],
+                              drvdata->base + TRCVMIDCVRn(i));
+
+       writel_relaxed(state->trccidcctlr0, drvdata->base + TRCCIDCCTLR0);
+       writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1);
+
+       writel_relaxed(state->trcvmidcctlr0, drvdata->base + TRCVMIDCCTLR0);
+       writel_relaxed(state->trcvmidcctlr1, drvdata->base + TRCVMIDCCTLR1);
+
+       writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET);
+
+       writel_relaxed(state->trcpdcr, drvdata->base + TRCPDCR);
+
+       drvdata->state_needs_restore = false;
+
+       /*
+        * As recommended by section 4.3.7 ("Synchronization when using the
+        * memory-mapped interface") of ARM IHI 0064D
+        */
+       dsb(sy);
+       isb();
+
+       /* Unlock the OS lock to re-enable trace and external debug access */
+       etm4_os_unlock(drvdata);
+       CS_LOCK(drvdata->base);
+}
+
+static int etm4_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
+                             void *v)
+{
+       struct etmv4_drvdata *drvdata;
+       unsigned int cpu = smp_processor_id();
+
+       if (!etmdrvdata[cpu])
+               return NOTIFY_OK;
+
+       drvdata = etmdrvdata[cpu];
+
+       if (!drvdata->save_state)
+               return NOTIFY_OK;
+
+       if (WARN_ON_ONCE(drvdata->cpu != cpu))
+               return NOTIFY_BAD;
+
+       switch (cmd) {
+       case CPU_PM_ENTER:
+               /* save the state if self-hosted coresight is in use */
+               if (local_read(&drvdata->mode))
+                       if (etm4_cpu_save(drvdata))
+                               return NOTIFY_BAD;
+               break;
+       case CPU_PM_EXIT:
+       case CPU_PM_ENTER_FAILED:
+               if (drvdata->state_needs_restore)
+                       etm4_cpu_restore(drvdata);
+               break;
+       default:
+               return NOTIFY_DONE;
+       }
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block etm4_cpu_pm_nb = {
+       .notifier_call = etm4_cpu_pm_notify,
+};
+
+/* Setup PM. Deals with error conditions and counts */
+static int __init etm4_pm_setup(void)
+{
+       int ret;
+
+       ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
+       if (ret)
+               return ret;
+
+       ret = cpuhp_setup_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING,
+                                       "arm/coresight4:starting",
+                                       etm4_starting_cpu, etm4_dying_cpu);
+
+       if (ret)
+               goto unregister_notifier;
+
+       ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
+                                       "arm/coresight4:online",
+                                       etm4_online_cpu, NULL);
+
+       /* HP dyn state ID returned in ret on success */
+       if (ret > 0) {
+               hp_online = ret;
+               return 0;
+       }
+
+       /* failed dyn state - remove others */
+       cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
+
+unregister_notifier:
+       cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
+       return ret;
+}
+
+static void etm4_pm_clear(void)
+{
+       cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
+       cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
+       if (hp_online) {
+               cpuhp_remove_state_nocalls(hp_online);
+               hp_online = 0;
+       }
+}
+
+static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
+{
+       int ret;
+       void __iomem *base;
+       struct device *dev = &adev->dev;
+       struct coresight_platform_data *pdata = NULL;
+       struct etmv4_drvdata *drvdata;
+       struct resource *res = &adev->res;
+       struct coresight_desc desc = { 0 };
+
+       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
+               return -ENOMEM;
+
+       dev_set_drvdata(dev, drvdata);
+
+       if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE)
+               pm_save_enable = coresight_loses_context_with_cpu(dev) ?
+                              PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER;
+
+       if (pm_save_enable != PARAM_PM_SAVE_NEVER) {
+               drvdata->save_state = devm_kmalloc(dev,
+                               sizeof(struct etmv4_save_state), GFP_KERNEL);
+               if (!drvdata->save_state)
+                       return -ENOMEM;
+       }
+
+       if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
+               drvdata->skip_power_up = true;
+
+       /* Validity for the resource is already checked by the AMBA core */
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       drvdata->base = base;
+
+       spin_lock_init(&drvdata->spinlock);
+
+       drvdata->cpu = coresight_get_cpu(dev);
+       if (drvdata->cpu < 0)
+               return drvdata->cpu;
+
+       desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
+       if (!desc.name)
+               return -ENOMEM;
+
+       if (smp_call_function_single(drvdata->cpu,
+                               etm4_init_arch_data,  drvdata, 1))
+               dev_err(dev, "ETM arch init failed\n");
+
+       if (etm4_arch_supported(drvdata->arch) == false)
+               return -EINVAL;
+
+       etm4_init_trace_id(drvdata);
+       etm4_set_default(&drvdata->config);
+
+       pdata = coresight_get_platform_data(dev);
+       if (IS_ERR(pdata))
+               return PTR_ERR(pdata);
+
+       adev->dev.platform_data = pdata;
+
+       desc.type = CORESIGHT_DEV_TYPE_SOURCE;
+       desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
+       desc.ops = &etm4_cs_ops;
+       desc.pdata = pdata;
+       desc.dev = dev;
+       desc.groups = coresight_etmv4_groups;
+       drvdata->csdev = coresight_register(&desc);
+       if (IS_ERR(drvdata->csdev))
+               return PTR_ERR(drvdata->csdev);
+
+       ret = etm_perf_symlink(drvdata->csdev, true);
+       if (ret) {
+               coresight_unregister(drvdata->csdev);
+               return ret;
+       }
+
+       etmdrvdata[drvdata->cpu] = drvdata;
+
+       pm_runtime_put(&adev->dev);
+       dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n",
+                drvdata->cpu, drvdata->arch >> 4, drvdata->arch & 0xf);
+
+       if (boot_enable) {
+               coresight_enable(drvdata->csdev);
+               drvdata->boot_enable = true;
+       }
+
+       return 0;
+}
+
+static struct amba_cs_uci_id uci_id_etm4[] = {
+       {
+               /*  ETMv4 UCI data */
+               .devarch        = 0x47704a13,
+               .devarch_mask   = 0xfff0ffff,
+               .devtype        = 0x00000013,
+       }
+};
+
+static void __exit clear_etmdrvdata(void *info)
+{
+       int cpu = *(int *)info;
+
+       etmdrvdata[cpu] = NULL;
+}
+
+static int __exit etm4_remove(struct amba_device *adev)
+{
+       struct etmv4_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       etm_perf_symlink(drvdata->csdev, false);
+
+       /*
+        * Taking hotplug lock here to avoid racing between etm4_remove and
+        * CPU hotplug call backs.
+        */
+       cpus_read_lock();
+       /*
+        * The readers for etmdrvdata[] are CPU hotplug call backs
+        * and PM notification call backs. Change etmdrvdata[i] on
+        * CPU i ensures these call backs has consistent view
+        * inside one call back function.
+        */
+       if (smp_call_function_single(drvdata->cpu, clear_etmdrvdata, &drvdata->cpu, 1))
+               etmdrvdata[drvdata->cpu] = NULL;
+
+       cpus_read_unlock();
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
+static const struct amba_id etm4_ids[] = {
+       CS_AMBA_ID(0x000bb95d),                 /* Cortex-A53 */
+       CS_AMBA_ID(0x000bb95e),                 /* Cortex-A57 */
+       CS_AMBA_ID(0x000bb95a),                 /* Cortex-A72 */
+       CS_AMBA_ID(0x000bb959),                 /* Cortex-A73 */
+       CS_AMBA_UCI_ID(0x000bb9da, uci_id_etm4),/* Cortex-A35 */
+       CS_AMBA_UCI_ID(0x000bbd0c, uci_id_etm4),/* Neoverse N1 */
+       CS_AMBA_UCI_ID(0x000f0205, uci_id_etm4),/* Qualcomm Kryo */
+       CS_AMBA_UCI_ID(0x000f0211, uci_id_etm4),/* Qualcomm Kryo */
+       CS_AMBA_UCI_ID(0x000bb802, uci_id_etm4),/* Qualcomm Kryo 385 Cortex-A55 */
+       CS_AMBA_UCI_ID(0x000bb803, uci_id_etm4),/* Qualcomm Kryo 385 Cortex-A75 */
+       CS_AMBA_UCI_ID(0x000bb805, uci_id_etm4),/* Qualcomm Kryo 4XX Cortex-A55 */
+       CS_AMBA_UCI_ID(0x000bb804, uci_id_etm4),/* Qualcomm Kryo 4XX Cortex-A76 */
+       CS_AMBA_UCI_ID(0x000cc0af, uci_id_etm4),/* Marvell ThunderX2 */
+       CS_AMBA_UCI_ID(0x000b6d01, uci_id_etm4),/* HiSilicon-Hip08 */
+       CS_AMBA_UCI_ID(0x000b6d02, uci_id_etm4),/* HiSilicon-Hip09 */
+       {},
+};
+
+MODULE_DEVICE_TABLE(amba, etm4_ids);
+
+static struct amba_driver etm4x_driver = {
+       .drv = {
+               .name   = "coresight-etm4x",
+               .owner  = THIS_MODULE,
+               .suppress_bind_attrs = true,
+       },
+       .probe          = etm4_probe,
+       .remove         = etm4_remove,
+       .id_table       = etm4_ids,
+};
+
+static int __init etm4x_init(void)
+{
+       int ret;
+
+       ret = etm4_pm_setup();
+
+       /* etm4_pm_setup() does its own cleanup - exit on error */
+       if (ret)
+               return ret;
+
+       ret = amba_driver_register(&etm4x_driver);
+       if (ret) {
+               pr_err("Error registering etm4x driver\n");
+               etm4_pm_clear();
+       }
+
+       return ret;
+}
+
+static void __exit etm4x_exit(void)
+{
+       amba_driver_unregister(&etm4x_driver);
+       etm4_pm_clear();
+}
+
+module_init(etm4x_init);
+module_exit(etm4x_exit);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight Program Flow Trace v4.x driver");
+MODULE_LICENSE("GPL v2");
index b673e73..989ce7b 100644 (file)
@@ -206,7 +206,7 @@ static ssize_t reset_store(struct device *dev,
         * each trace run.
         */
        config->vinst_ctrl = BIT(0);
-       if (drvdata->nr_addr_cmp == true) {
+       if (drvdata->nr_addr_cmp > 0) {
                config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
                /* SSSTATUS, bit[9] */
                config->vinst_ctrl |= BIT(9);
@@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev,
        }
 
        config->res_idx = 0x0;
-       for (i = 0; i < drvdata->nr_resource; i++)
+       for (i = 2; i < 2 * drvdata->nr_resource; i++)
                config->res_ctrl[i] = 0x0;
 
        config->ss_idx = 0x0;
@@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev,
 
        if (kstrtoul(buf, 16, &val))
                return -EINVAL;
-       /* Resource selector pair 0 is always implemented and reserved */
-       if ((val == 0) || (val >= drvdata->nr_resource))
+       /*
+        * Resource selector pair 0 is always implemented and reserved,
+        * namely an idx with 0 and 1 is illegal.
+        */
+       if ((val < 2) || (val >= 2 * drvdata->nr_resource))
                return -EINVAL;
 
        /*
diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c
deleted file mode 100644 (file)
index 6d7d216..0000000
+++ /dev/null
@@ -1,1601 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
- */
-
-#include <linux/kernel.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/smp.h>
-#include <linux/sysfs.h>
-#include <linux/stat.h>
-#include <linux/clk.h>
-#include <linux/cpu.h>
-#include <linux/cpu_pm.h>
-#include <linux/coresight.h>
-#include <linux/coresight-pmu.h>
-#include <linux/pm_wakeup.h>
-#include <linux/amba/bus.h>
-#include <linux/seq_file.h>
-#include <linux/uaccess.h>
-#include <linux/perf_event.h>
-#include <linux/pm_runtime.h>
-#include <linux/property.h>
-#include <asm/sections.h>
-#include <asm/local.h>
-#include <asm/virt.h>
-
-#include "coresight-etm4x.h"
-#include "coresight-etm-perf.h"
-
-static int boot_enable;
-module_param(boot_enable, int, 0444);
-MODULE_PARM_DESC(boot_enable, "Enable tracing on boot");
-
-#define PARAM_PM_SAVE_FIRMWARE   0 /* save self-hosted state as per firmware */
-#define PARAM_PM_SAVE_NEVER      1 /* never save any state */
-#define PARAM_PM_SAVE_SELF_HOSTED 2 /* save self-hosted state only */
-
-static int pm_save_enable = PARAM_PM_SAVE_FIRMWARE;
-module_param(pm_save_enable, int, 0444);
-MODULE_PARM_DESC(pm_save_enable,
-       "Save/restore state on power down: 1 = never, 2 = self-hosted");
-
-/* The number of ETMv4 currently registered */
-static int etm4_count;
-static struct etmv4_drvdata *etmdrvdata[NR_CPUS];
-static void etm4_set_default_config(struct etmv4_config *config);
-static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
-                                 struct perf_event *event);
-
-static enum cpuhp_state hp_online;
-
-static void etm4_os_unlock(struct etmv4_drvdata *drvdata)
-{
-       /* Writing 0 to TRCOSLAR unlocks the trace registers */
-       writel_relaxed(0x0, drvdata->base + TRCOSLAR);
-       drvdata->os_unlock = true;
-       isb();
-}
-
-static void etm4_os_lock(struct etmv4_drvdata *drvdata)
-{
-       /* Writing 0x1 to TRCOSLAR locks the trace registers */
-       writel_relaxed(0x1, drvdata->base + TRCOSLAR);
-       drvdata->os_unlock = false;
-       isb();
-}
-
-static bool etm4_arch_supported(u8 arch)
-{
-       /* Mask out the minor version number */
-       switch (arch & 0xf0) {
-       case ETM_ARCH_V4:
-               break;
-       default:
-               return false;
-       }
-       return true;
-}
-
-static int etm4_cpu_id(struct coresight_device *csdev)
-{
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       return drvdata->cpu;
-}
-
-static int etm4_trace_id(struct coresight_device *csdev)
-{
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       return drvdata->trcid;
-}
-
-struct etm4_enable_arg {
-       struct etmv4_drvdata *drvdata;
-       int rc;
-};
-
-static int etm4_enable_hw(struct etmv4_drvdata *drvdata)
-{
-       int i, rc;
-       struct etmv4_config *config = &drvdata->config;
-       struct device *etm_dev = &drvdata->csdev->dev;
-
-       CS_UNLOCK(drvdata->base);
-
-       etm4_os_unlock(drvdata);
-
-       rc = coresight_claim_device_unlocked(drvdata->base);
-       if (rc)
-               goto done;
-
-       /* Disable the trace unit before programming trace registers */
-       writel_relaxed(0, drvdata->base + TRCPRGCTLR);
-
-       /* wait for TRCSTATR.IDLE to go up */
-       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1))
-               dev_err(etm_dev,
-                       "timeout while waiting for Idle Trace Status\n");
-
-       writel_relaxed(config->pe_sel, drvdata->base + TRCPROCSELR);
-       writel_relaxed(config->cfg, drvdata->base + TRCCONFIGR);
-       /* nothing specific implemented */
-       writel_relaxed(0x0, drvdata->base + TRCAUXCTLR);
-       writel_relaxed(config->eventctrl0, drvdata->base + TRCEVENTCTL0R);
-       writel_relaxed(config->eventctrl1, drvdata->base + TRCEVENTCTL1R);
-       writel_relaxed(config->stall_ctrl, drvdata->base + TRCSTALLCTLR);
-       writel_relaxed(config->ts_ctrl, drvdata->base + TRCTSCTLR);
-       writel_relaxed(config->syncfreq, drvdata->base + TRCSYNCPR);
-       writel_relaxed(config->ccctlr, drvdata->base + TRCCCCTLR);
-       writel_relaxed(config->bb_ctrl, drvdata->base + TRCBBCTLR);
-       writel_relaxed(drvdata->trcid, drvdata->base + TRCTRACEIDR);
-       writel_relaxed(config->vinst_ctrl, drvdata->base + TRCVICTLR);
-       writel_relaxed(config->viiectlr, drvdata->base + TRCVIIECTLR);
-       writel_relaxed(config->vissctlr,
-                      drvdata->base + TRCVISSCTLR);
-       writel_relaxed(config->vipcssctlr,
-                      drvdata->base + TRCVIPCSSCTLR);
-       for (i = 0; i < drvdata->nrseqstate - 1; i++)
-               writel_relaxed(config->seq_ctrl[i],
-                              drvdata->base + TRCSEQEVRn(i));
-       writel_relaxed(config->seq_rst, drvdata->base + TRCSEQRSTEVR);
-       writel_relaxed(config->seq_state, drvdata->base + TRCSEQSTR);
-       writel_relaxed(config->ext_inp, drvdata->base + TRCEXTINSELR);
-       for (i = 0; i < drvdata->nr_cntr; i++) {
-               writel_relaxed(config->cntrldvr[i],
-                              drvdata->base + TRCCNTRLDVRn(i));
-               writel_relaxed(config->cntr_ctrl[i],
-                              drvdata->base + TRCCNTCTLRn(i));
-               writel_relaxed(config->cntr_val[i],
-                              drvdata->base + TRCCNTVRn(i));
-       }
-
-       /*
-        * Resource selector pair 0 is always implemented and reserved.  As
-        * such start at 2.
-        */
-       for (i = 2; i < drvdata->nr_resource * 2; i++)
-               writel_relaxed(config->res_ctrl[i],
-                              drvdata->base + TRCRSCTLRn(i));
-
-       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
-               /* always clear status bit on restart if using single-shot */
-               if (config->ss_ctrl[i] || config->ss_pe_cmp[i])
-                       config->ss_status[i] &= ~BIT(31);
-               writel_relaxed(config->ss_ctrl[i],
-                              drvdata->base + TRCSSCCRn(i));
-               writel_relaxed(config->ss_status[i],
-                              drvdata->base + TRCSSCSRn(i));
-               writel_relaxed(config->ss_pe_cmp[i],
-                              drvdata->base + TRCSSPCICRn(i));
-       }
-       for (i = 0; i < drvdata->nr_addr_cmp; i++) {
-               writeq_relaxed(config->addr_val[i],
-                              drvdata->base + TRCACVRn(i));
-               writeq_relaxed(config->addr_acc[i],
-                              drvdata->base + TRCACATRn(i));
-       }
-       for (i = 0; i < drvdata->numcidc; i++)
-               writeq_relaxed(config->ctxid_pid[i],
-                              drvdata->base + TRCCIDCVRn(i));
-       writel_relaxed(config->ctxid_mask0, drvdata->base + TRCCIDCCTLR0);
-       writel_relaxed(config->ctxid_mask1, drvdata->base + TRCCIDCCTLR1);
-
-       for (i = 0; i < drvdata->numvmidc; i++)
-               writeq_relaxed(config->vmid_val[i],
-                              drvdata->base + TRCVMIDCVRn(i));
-       writel_relaxed(config->vmid_mask0, drvdata->base + TRCVMIDCCTLR0);
-       writel_relaxed(config->vmid_mask1, drvdata->base + TRCVMIDCCTLR1);
-
-       if (!drvdata->skip_power_up) {
-               /*
-                * Request to keep the trace unit powered and also
-                * emulation of powerdown
-                */
-               writel_relaxed(readl_relaxed(drvdata->base + TRCPDCR) |
-                              TRCPDCR_PU, drvdata->base + TRCPDCR);
-       }
-
-       /* Enable the trace unit */
-       writel_relaxed(1, drvdata->base + TRCPRGCTLR);
-
-       /* wait for TRCSTATR.IDLE to go back down to '0' */
-       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0))
-               dev_err(etm_dev,
-                       "timeout while waiting for Idle Trace Status\n");
-
-       /*
-        * As recommended by section 4.3.7 ("Synchronization when using the
-        * memory-mapped interface") of ARM IHI 0064D
-        */
-       dsb(sy);
-       isb();
-
-done:
-       CS_LOCK(drvdata->base);
-
-       dev_dbg(etm_dev, "cpu: %d enable smp call done: %d\n",
-               drvdata->cpu, rc);
-       return rc;
-}
-
-static void etm4_enable_hw_smp_call(void *info)
-{
-       struct etm4_enable_arg *arg = info;
-
-       if (WARN_ON(!arg))
-               return;
-       arg->rc = etm4_enable_hw(arg->drvdata);
-}
-
-/*
- * The goal of function etm4_config_timestamp_event() is to configure a
- * counter that will tell the tracer to emit a timestamp packet when it
- * reaches zero.  This is done in order to get a more fine grained idea
- * of when instructions are executed so that they can be correlated
- * with execution on other CPUs.
- *
- * To do this the counter itself is configured to self reload and
- * TRCRSCTLR1 (always true) used to get the counter to decrement.  From
- * there a resource selector is configured with the counter and the
- * timestamp control register to use the resource selector to trigger the
- * event that will insert a timestamp packet in the stream.
- */
-static int etm4_config_timestamp_event(struct etmv4_drvdata *drvdata)
-{
-       int ctridx, ret = -EINVAL;
-       int counter, rselector;
-       u32 val = 0;
-       struct etmv4_config *config = &drvdata->config;
-
-       /* No point in trying if we don't have at least one counter */
-       if (!drvdata->nr_cntr)
-               goto out;
-
-       /* Find a counter that hasn't been initialised */
-       for (ctridx = 0; ctridx < drvdata->nr_cntr; ctridx++)
-               if (config->cntr_val[ctridx] == 0)
-                       break;
-
-       /* All the counters have been configured already, bail out */
-       if (ctridx == drvdata->nr_cntr) {
-               pr_debug("%s: no available counter found\n", __func__);
-               ret = -ENOSPC;
-               goto out;
-       }
-
-       /*
-        * Searching for an available resource selector to use, starting at
-        * '2' since every implementation has at least 2 resource selector.
-        * ETMIDR4 gives the number of resource selector _pairs_,
-        * hence multiply by 2.
-        */
-       for (rselector = 2; rselector < drvdata->nr_resource * 2; rselector++)
-               if (!config->res_ctrl[rselector])
-                       break;
-
-       if (rselector == drvdata->nr_resource * 2) {
-               pr_debug("%s: no available resource selector found\n",
-                        __func__);
-               ret = -ENOSPC;
-               goto out;
-       }
-
-       /* Remember what counter we used */
-       counter = 1 << ctridx;
-
-       /*
-        * Initialise original and reload counter value to the smallest
-        * possible value in order to get as much precision as we can.
-        */
-       config->cntr_val[ctridx] = 1;
-       config->cntrldvr[ctridx] = 1;
-
-       /* Set the trace counter control register */
-       val =  0x1 << 16        |  /* Bit 16, reload counter automatically */
-              0x0 << 7         |  /* Select single resource selector */
-              0x1;                /* Resource selector 1, i.e always true */
-
-       config->cntr_ctrl[ctridx] = val;
-
-       val = 0x2 << 16         | /* Group 0b0010 - Counter and sequencers */
-             counter << 0;       /* Counter to use */
-
-       config->res_ctrl[rselector] = val;
-
-       val = 0x0 << 7          | /* Select single resource selector */
-             rselector;          /* Resource selector */
-
-       config->ts_ctrl = val;
-
-       ret = 0;
-out:
-       return ret;
-}
-
-static int etm4_parse_event_config(struct etmv4_drvdata *drvdata,
-                                  struct perf_event *event)
-{
-       int ret = 0;
-       struct etmv4_config *config = &drvdata->config;
-       struct perf_event_attr *attr = &event->attr;
-
-       if (!attr) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       /* Clear configuration from previous run */
-       memset(config, 0, sizeof(struct etmv4_config));
-
-       if (attr->exclude_kernel)
-               config->mode = ETM_MODE_EXCL_KERN;
-
-       if (attr->exclude_user)
-               config->mode = ETM_MODE_EXCL_USER;
-
-       /* Always start from the default config */
-       etm4_set_default_config(config);
-
-       /* Configure filters specified on the perf cmd line, if any. */
-       ret = etm4_set_event_filters(drvdata, event);
-       if (ret)
-               goto out;
-
-       /* Go from generic option to ETMv4 specifics */
-       if (attr->config & BIT(ETM_OPT_CYCACC)) {
-               config->cfg |= BIT(4);
-               /* TRM: Must program this for cycacc to work */
-               config->ccctlr = ETM_CYC_THRESHOLD_DEFAULT;
-       }
-       if (attr->config & BIT(ETM_OPT_TS)) {
-               /*
-                * Configure timestamps to be emitted at regular intervals in
-                * order to correlate instructions executed on different CPUs
-                * (CPU-wide trace scenarios).
-                */
-               ret = etm4_config_timestamp_event(drvdata);
-
-               /*
-                * No need to go further if timestamp intervals can't
-                * be configured.
-                */
-               if (ret)
-                       goto out;
-
-               /* bit[11], Global timestamp tracing bit */
-               config->cfg |= BIT(11);
-       }
-
-       if (attr->config & BIT(ETM_OPT_CTXTID))
-               /* bit[6], Context ID tracing bit */
-               config->cfg |= BIT(ETM4_CFG_BIT_CTXTID);
-
-       /* return stack - enable if selected and supported */
-       if ((attr->config & BIT(ETM_OPT_RETSTK)) && drvdata->retstack)
-               /* bit[12], Return stack enable bit */
-               config->cfg |= BIT(12);
-
-out:
-       return ret;
-}
-
-static int etm4_enable_perf(struct coresight_device *csdev,
-                           struct perf_event *event)
-{
-       int ret = 0;
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       /* Configure the tracer based on the session's specifics */
-       ret = etm4_parse_event_config(drvdata, event);
-       if (ret)
-               goto out;
-       /* And enable it */
-       ret = etm4_enable_hw(drvdata);
-
-out:
-       return ret;
-}
-
-static int etm4_enable_sysfs(struct coresight_device *csdev)
-{
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-       struct etm4_enable_arg arg = { };
-       int ret;
-
-       spin_lock(&drvdata->spinlock);
-
-       /*
-        * Executing etm4_enable_hw on the cpu whose ETM is being enabled
-        * ensures that register writes occur when cpu is powered.
-        */
-       arg.drvdata = drvdata;
-       ret = smp_call_function_single(drvdata->cpu,
-                                      etm4_enable_hw_smp_call, &arg, 1);
-       if (!ret)
-               ret = arg.rc;
-       if (!ret)
-               drvdata->sticky_enable = true;
-       spin_unlock(&drvdata->spinlock);
-
-       if (!ret)
-               dev_dbg(&csdev->dev, "ETM tracing enabled\n");
-       return ret;
-}
-
-static int etm4_enable(struct coresight_device *csdev,
-                      struct perf_event *event, u32 mode)
-{
-       int ret;
-       u32 val;
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       val = local_cmpxchg(&drvdata->mode, CS_MODE_DISABLED, mode);
-
-       /* Someone is already using the tracer */
-       if (val)
-               return -EBUSY;
-
-       switch (mode) {
-       case CS_MODE_SYSFS:
-               ret = etm4_enable_sysfs(csdev);
-               break;
-       case CS_MODE_PERF:
-               ret = etm4_enable_perf(csdev, event);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       /* The tracer didn't start */
-       if (ret)
-               local_set(&drvdata->mode, CS_MODE_DISABLED);
-
-       return ret;
-}
-
-static void etm4_disable_hw(void *info)
-{
-       u32 control;
-       struct etmv4_drvdata *drvdata = info;
-       struct etmv4_config *config = &drvdata->config;
-       struct device *etm_dev = &drvdata->csdev->dev;
-       int i;
-
-       CS_UNLOCK(drvdata->base);
-
-       if (!drvdata->skip_power_up) {
-               /* power can be removed from the trace unit now */
-               control = readl_relaxed(drvdata->base + TRCPDCR);
-               control &= ~TRCPDCR_PU;
-               writel_relaxed(control, drvdata->base + TRCPDCR);
-       }
-
-       control = readl_relaxed(drvdata->base + TRCPRGCTLR);
-
-       /* EN, bit[0] Trace unit enable bit */
-       control &= ~0x1;
-
-       /*
-        * Make sure everything completes before disabling, as recommended
-        * by section 7.3.77 ("TRCVICTLR, ViewInst Main Control Register,
-        * SSTATUS") of ARM IHI 0064D
-        */
-       dsb(sy);
-       isb();
-       writel_relaxed(control, drvdata->base + TRCPRGCTLR);
-
-       /* wait for TRCSTATR.PMSTABLE to go to '1' */
-       if (coresight_timeout(drvdata->base, TRCSTATR,
-                             TRCSTATR_PMSTABLE_BIT, 1))
-               dev_err(etm_dev,
-                       "timeout while waiting for PM stable Trace Status\n");
-
-       /* read the status of the single shot comparators */
-       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
-               config->ss_status[i] =
-                       readl_relaxed(drvdata->base + TRCSSCSRn(i));
-       }
-
-       /* read back the current counter values */
-       for (i = 0; i < drvdata->nr_cntr; i++) {
-               config->cntr_val[i] =
-                       readl_relaxed(drvdata->base + TRCCNTVRn(i));
-       }
-
-       coresight_disclaim_device_unlocked(drvdata->base);
-
-       CS_LOCK(drvdata->base);
-
-       dev_dbg(&drvdata->csdev->dev,
-               "cpu: %d disable smp call done\n", drvdata->cpu);
-}
-
-static int etm4_disable_perf(struct coresight_device *csdev,
-                            struct perf_event *event)
-{
-       u32 control;
-       struct etm_filters *filters = event->hw.addr_filters;
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id()))
-               return -EINVAL;
-
-       etm4_disable_hw(drvdata);
-
-       /*
-        * Check if the start/stop logic was active when the unit was stopped.
-        * That way we can re-enable the start/stop logic when the process is
-        * scheduled again.  Configuration of the start/stop logic happens in
-        * function etm4_set_event_filters().
-        */
-       control = readl_relaxed(drvdata->base + TRCVICTLR);
-       /* TRCVICTLR::SSSTATUS, bit[9] */
-       filters->ssstatus = (control & BIT(9));
-
-       return 0;
-}
-
-static void etm4_disable_sysfs(struct coresight_device *csdev)
-{
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       /*
-        * Taking hotplug lock here protects from clocks getting disabled
-        * with tracing being left on (crash scenario) if user disable occurs
-        * after cpu online mask indicates the cpu is offline but before the
-        * DYING hotplug callback is serviced by the ETM driver.
-        */
-       cpus_read_lock();
-       spin_lock(&drvdata->spinlock);
-
-       /*
-        * Executing etm4_disable_hw on the cpu whose ETM is being disabled
-        * ensures that register writes occur when cpu is powered.
-        */
-       smp_call_function_single(drvdata->cpu, etm4_disable_hw, drvdata, 1);
-
-       spin_unlock(&drvdata->spinlock);
-       cpus_read_unlock();
-
-       dev_dbg(&csdev->dev, "ETM tracing disabled\n");
-}
-
-static void etm4_disable(struct coresight_device *csdev,
-                        struct perf_event *event)
-{
-       u32 mode;
-       struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
-
-       /*
-        * For as long as the tracer isn't disabled another entity can't
-        * change its status.  As such we can read the status here without
-        * fearing it will change under us.
-        */
-       mode = local_read(&drvdata->mode);
-
-       switch (mode) {
-       case CS_MODE_DISABLED:
-               break;
-       case CS_MODE_SYSFS:
-               etm4_disable_sysfs(csdev);
-               break;
-       case CS_MODE_PERF:
-               etm4_disable_perf(csdev, event);
-               break;
-       }
-
-       if (mode)
-               local_set(&drvdata->mode, CS_MODE_DISABLED);
-}
-
-static const struct coresight_ops_source etm4_source_ops = {
-       .cpu_id         = etm4_cpu_id,
-       .trace_id       = etm4_trace_id,
-       .enable         = etm4_enable,
-       .disable        = etm4_disable,
-};
-
-static const struct coresight_ops etm4_cs_ops = {
-       .source_ops     = &etm4_source_ops,
-};
-
-static void etm4_init_arch_data(void *info)
-{
-       u32 etmidr0;
-       u32 etmidr1;
-       u32 etmidr2;
-       u32 etmidr3;
-       u32 etmidr4;
-       u32 etmidr5;
-       struct etmv4_drvdata *drvdata = info;
-       int i;
-
-       /* Make sure all registers are accessible */
-       etm4_os_unlock(drvdata);
-
-       CS_UNLOCK(drvdata->base);
-
-       /* find all capabilities of the tracing unit */
-       etmidr0 = readl_relaxed(drvdata->base + TRCIDR0);
-
-       /* INSTP0, bits[2:1] P0 tracing support field */
-       if (BMVAL(etmidr0, 1, 1) && BMVAL(etmidr0, 2, 2))
-               drvdata->instrp0 = true;
-       else
-               drvdata->instrp0 = false;
-
-       /* TRCBB, bit[5] Branch broadcast tracing support bit */
-       if (BMVAL(etmidr0, 5, 5))
-               drvdata->trcbb = true;
-       else
-               drvdata->trcbb = false;
-
-       /* TRCCOND, bit[6] Conditional instruction tracing support bit */
-       if (BMVAL(etmidr0, 6, 6))
-               drvdata->trccond = true;
-       else
-               drvdata->trccond = false;
-
-       /* TRCCCI, bit[7] Cycle counting instruction bit */
-       if (BMVAL(etmidr0, 7, 7))
-               drvdata->trccci = true;
-       else
-               drvdata->trccci = false;
-
-       /* RETSTACK, bit[9] Return stack bit */
-       if (BMVAL(etmidr0, 9, 9))
-               drvdata->retstack = true;
-       else
-               drvdata->retstack = false;
-
-       /* NUMEVENT, bits[11:10] Number of events field */
-       drvdata->nr_event = BMVAL(etmidr0, 10, 11);
-       /* QSUPP, bits[16:15] Q element support field */
-       drvdata->q_support = BMVAL(etmidr0, 15, 16);
-       /* TSSIZE, bits[28:24] Global timestamp size field */
-       drvdata->ts_size = BMVAL(etmidr0, 24, 28);
-
-       /* base architecture of trace unit */
-       etmidr1 = readl_relaxed(drvdata->base + TRCIDR1);
-       /*
-        * TRCARCHMIN, bits[7:4] architecture the minor version number
-        * TRCARCHMAJ, bits[11:8] architecture major versin number
-        */
-       drvdata->arch = BMVAL(etmidr1, 4, 11);
-       drvdata->config.arch = drvdata->arch;
-
-       /* maximum size of resources */
-       etmidr2 = readl_relaxed(drvdata->base + TRCIDR2);
-       /* CIDSIZE, bits[9:5] Indicates the Context ID size */
-       drvdata->ctxid_size = BMVAL(etmidr2, 5, 9);
-       /* VMIDSIZE, bits[14:10] Indicates the VMID size */
-       drvdata->vmid_size = BMVAL(etmidr2, 10, 14);
-       /* CCSIZE, bits[28:25] size of the cycle counter in bits minus 12 */
-       drvdata->ccsize = BMVAL(etmidr2, 25, 28);
-
-       etmidr3 = readl_relaxed(drvdata->base + TRCIDR3);
-       /* CCITMIN, bits[11:0] minimum threshold value that can be programmed */
-       drvdata->ccitmin = BMVAL(etmidr3, 0, 11);
-       /* EXLEVEL_S, bits[19:16] Secure state instruction tracing */
-       drvdata->s_ex_level = BMVAL(etmidr3, 16, 19);
-       /* EXLEVEL_NS, bits[23:20] Non-secure state instruction tracing */
-       drvdata->ns_ex_level = BMVAL(etmidr3, 20, 23);
-
-       /*
-        * TRCERR, bit[24] whether a trace unit can trace a
-        * system error exception.
-        */
-       if (BMVAL(etmidr3, 24, 24))
-               drvdata->trc_error = true;
-       else
-               drvdata->trc_error = false;
-
-       /* SYNCPR, bit[25] implementation has a fixed synchronization period? */
-       if (BMVAL(etmidr3, 25, 25))
-               drvdata->syncpr = true;
-       else
-               drvdata->syncpr = false;
-
-       /* STALLCTL, bit[26] is stall control implemented? */
-       if (BMVAL(etmidr3, 26, 26))
-               drvdata->stallctl = true;
-       else
-               drvdata->stallctl = false;
-
-       /* SYSSTALL, bit[27] implementation can support stall control? */
-       if (BMVAL(etmidr3, 27, 27))
-               drvdata->sysstall = true;
-       else
-               drvdata->sysstall = false;
-
-       /* NUMPROC, bits[30:28] the number of PEs available for tracing */
-       drvdata->nr_pe = BMVAL(etmidr3, 28, 30);
-
-       /* NOOVERFLOW, bit[31] is trace overflow prevention supported */
-       if (BMVAL(etmidr3, 31, 31))
-               drvdata->nooverflow = true;
-       else
-               drvdata->nooverflow = false;
-
-       /* number of resources trace unit supports */
-       etmidr4 = readl_relaxed(drvdata->base + TRCIDR4);
-       /* NUMACPAIRS, bits[0:3] number of addr comparator pairs for tracing */
-       drvdata->nr_addr_cmp = BMVAL(etmidr4, 0, 3);
-       /* NUMPC, bits[15:12] number of PE comparator inputs for tracing */
-       drvdata->nr_pe_cmp = BMVAL(etmidr4, 12, 15);
-       /*
-        * NUMRSPAIR, bits[19:16]
-        * The number of resource pairs conveyed by the HW starts at 0, i.e a
-        * value of 0x0 indicate 1 resource pair, 0x1 indicate two and so on.
-        * As such add 1 to the value of NUMRSPAIR for a better representation.
-        */
-       drvdata->nr_resource = BMVAL(etmidr4, 16, 19) + 1;
-       /*
-        * NUMSSCC, bits[23:20] the number of single-shot
-        * comparator control for tracing. Read any status regs as these
-        * also contain RO capability data.
-        */
-       drvdata->nr_ss_cmp = BMVAL(etmidr4, 20, 23);
-       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
-               drvdata->config.ss_status[i] =
-                       readl_relaxed(drvdata->base + TRCSSCSRn(i));
-       }
-       /* NUMCIDC, bits[27:24] number of Context ID comparators for tracing */
-       drvdata->numcidc = BMVAL(etmidr4, 24, 27);
-       /* NUMVMIDC, bits[31:28] number of VMID comparators for tracing */
-       drvdata->numvmidc = BMVAL(etmidr4, 28, 31);
-
-       etmidr5 = readl_relaxed(drvdata->base + TRCIDR5);
-       /* NUMEXTIN, bits[8:0] number of external inputs implemented */
-       drvdata->nr_ext_inp = BMVAL(etmidr5, 0, 8);
-       /* TRACEIDSIZE, bits[21:16] indicates the trace ID width */
-       drvdata->trcid_size = BMVAL(etmidr5, 16, 21);
-       /* ATBTRIG, bit[22] implementation can support ATB triggers? */
-       if (BMVAL(etmidr5, 22, 22))
-               drvdata->atbtrig = true;
-       else
-               drvdata->atbtrig = false;
-       /*
-        * LPOVERRIDE, bit[23] implementation supports
-        * low-power state override
-        */
-       if (BMVAL(etmidr5, 23, 23))
-               drvdata->lpoverride = true;
-       else
-               drvdata->lpoverride = false;
-       /* NUMSEQSTATE, bits[27:25] number of sequencer states implemented */
-       drvdata->nrseqstate = BMVAL(etmidr5, 25, 27);
-       /* NUMCNTR, bits[30:28] number of counters available for tracing */
-       drvdata->nr_cntr = BMVAL(etmidr5, 28, 30);
-       CS_LOCK(drvdata->base);
-}
-
-static void etm4_set_default_config(struct etmv4_config *config)
-{
-       /* disable all events tracing */
-       config->eventctrl0 = 0x0;
-       config->eventctrl1 = 0x0;
-
-       /* disable stalling */
-       config->stall_ctrl = 0x0;
-
-       /* enable trace synchronization every 4096 bytes, if available */
-       config->syncfreq = 0xC;
-
-       /* disable timestamp event */
-       config->ts_ctrl = 0x0;
-
-       /* TRCVICTLR::EVENT = 0x01, select the always on logic */
-       config->vinst_ctrl = BIT(0);
-}
-
-static u64 etm4_get_ns_access_type(struct etmv4_config *config)
-{
-       u64 access_type = 0;
-
-       /*
-        * EXLEVEL_NS, bits[15:12]
-        * The Exception levels are:
-        *   Bit[12] Exception level 0 - Application
-        *   Bit[13] Exception level 1 - OS
-        *   Bit[14] Exception level 2 - Hypervisor
-        *   Bit[15] Never implemented
-        */
-       if (!is_kernel_in_hyp_mode()) {
-               /* Stay away from hypervisor mode for non-VHE */
-               access_type =  ETM_EXLEVEL_NS_HYP;
-               if (config->mode & ETM_MODE_EXCL_KERN)
-                       access_type |= ETM_EXLEVEL_NS_OS;
-       } else if (config->mode & ETM_MODE_EXCL_KERN) {
-               access_type = ETM_EXLEVEL_NS_HYP;
-       }
-
-       if (config->mode & ETM_MODE_EXCL_USER)
-               access_type |= ETM_EXLEVEL_NS_APP;
-
-       return access_type;
-}
-
-static u64 etm4_get_access_type(struct etmv4_config *config)
-{
-       u64 access_type = etm4_get_ns_access_type(config);
-       u64 s_hyp = (config->arch & 0x0f) >= 0x4 ? ETM_EXLEVEL_S_HYP : 0;
-
-       /*
-        * EXLEVEL_S, bits[11:8], don't trace anything happening
-        * in secure state.
-        */
-       access_type |= (ETM_EXLEVEL_S_APP       |
-                       ETM_EXLEVEL_S_OS        |
-                       s_hyp                   |
-                       ETM_EXLEVEL_S_MON);
-
-       return access_type;
-}
-
-static void etm4_set_comparator_filter(struct etmv4_config *config,
-                                      u64 start, u64 stop, int comparator)
-{
-       u64 access_type = etm4_get_access_type(config);
-
-       /* First half of default address comparator */
-       config->addr_val[comparator] = start;
-       config->addr_acc[comparator] = access_type;
-       config->addr_type[comparator] = ETM_ADDR_TYPE_RANGE;
-
-       /* Second half of default address comparator */
-       config->addr_val[comparator + 1] = stop;
-       config->addr_acc[comparator + 1] = access_type;
-       config->addr_type[comparator + 1] = ETM_ADDR_TYPE_RANGE;
-
-       /*
-        * Configure the ViewInst function to include this address range
-        * comparator.
-        *
-        * @comparator is divided by two since it is the index in the
-        * etmv4_config::addr_val array but register TRCVIIECTLR deals with
-        * address range comparator _pairs_.
-        *
-        * Therefore:
-        *      index 0 -> compatator pair 0
-        *      index 2 -> comparator pair 1
-        *      index 4 -> comparator pair 2
-        *      ...
-        *      index 14 -> comparator pair 7
-        */
-       config->viiectlr |= BIT(comparator / 2);
-}
-
-static void etm4_set_start_stop_filter(struct etmv4_config *config,
-                                      u64 address, int comparator,
-                                      enum etm_addr_type type)
-{
-       int shift;
-       u64 access_type = etm4_get_access_type(config);
-
-       /* Configure the comparator */
-       config->addr_val[comparator] = address;
-       config->addr_acc[comparator] = access_type;
-       config->addr_type[comparator] = type;
-
-       /*
-        * Configure ViewInst Start-Stop control register.
-        * Addresses configured to start tracing go from bit 0 to n-1,
-        * while those configured to stop tracing from 16 to 16 + n-1.
-        */
-       shift = (type == ETM_ADDR_TYPE_START ? 0 : 16);
-       config->vissctlr |= BIT(shift + comparator);
-}
-
-static void etm4_set_default_filter(struct etmv4_config *config)
-{
-       /* Trace everything 'default' filter achieved by no filtering */
-       config->viiectlr = 0x0;
-
-       /*
-        * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
-        * in the started state
-        */
-       config->vinst_ctrl |= BIT(9);
-       config->mode |= ETM_MODE_VIEWINST_STARTSTOP;
-
-       /* No start-stop filtering for ViewInst */
-       config->vissctlr = 0x0;
-}
-
-static void etm4_set_default(struct etmv4_config *config)
-{
-       if (WARN_ON_ONCE(!config))
-               return;
-
-       /*
-        * Make default initialisation trace everything
-        *
-        * This is done by a minimum default config sufficient to enable
-        * full instruction trace - with a default filter for trace all
-        * achieved by having no filtering.
-        */
-       etm4_set_default_config(config);
-       etm4_set_default_filter(config);
-}
-
-static int etm4_get_next_comparator(struct etmv4_drvdata *drvdata, u32 type)
-{
-       int nr_comparator, index = 0;
-       struct etmv4_config *config = &drvdata->config;
-
-       /*
-        * nr_addr_cmp holds the number of comparator _pair_, so time 2
-        * for the total number of comparators.
-        */
-       nr_comparator = drvdata->nr_addr_cmp * 2;
-
-       /* Go through the tally of comparators looking for a free one. */
-       while (index < nr_comparator) {
-               switch (type) {
-               case ETM_ADDR_TYPE_RANGE:
-                       if (config->addr_type[index] == ETM_ADDR_TYPE_NONE &&
-                           config->addr_type[index + 1] == ETM_ADDR_TYPE_NONE)
-                               return index;
-
-                       /* Address range comparators go in pairs */
-                       index += 2;
-                       break;
-               case ETM_ADDR_TYPE_START:
-               case ETM_ADDR_TYPE_STOP:
-                       if (config->addr_type[index] == ETM_ADDR_TYPE_NONE)
-                               return index;
-
-                       /* Start/stop address can have odd indexes */
-                       index += 1;
-                       break;
-               default:
-                       return -EINVAL;
-               }
-       }
-
-       /* If we are here all the comparators have been used. */
-       return -ENOSPC;
-}
-
-static int etm4_set_event_filters(struct etmv4_drvdata *drvdata,
-                                 struct perf_event *event)
-{
-       int i, comparator, ret = 0;
-       u64 address;
-       struct etmv4_config *config = &drvdata->config;
-       struct etm_filters *filters = event->hw.addr_filters;
-
-       if (!filters)
-               goto default_filter;
-
-       /* Sync events with what Perf got */
-       perf_event_addr_filters_sync(event);
-
-       /*
-        * If there are no filters to deal with simply go ahead with
-        * the default filter, i.e the entire address range.
-        */
-       if (!filters->nr_filters)
-               goto default_filter;
-
-       for (i = 0; i < filters->nr_filters; i++) {
-               struct etm_filter *filter = &filters->etm_filter[i];
-               enum etm_addr_type type = filter->type;
-
-               /* See if a comparator is free. */
-               comparator = etm4_get_next_comparator(drvdata, type);
-               if (comparator < 0) {
-                       ret = comparator;
-                       goto out;
-               }
-
-               switch (type) {
-               case ETM_ADDR_TYPE_RANGE:
-                       etm4_set_comparator_filter(config,
-                                                  filter->start_addr,
-                                                  filter->stop_addr,
-                                                  comparator);
-                       /*
-                        * TRCVICTLR::SSSTATUS == 1, the start-stop logic is
-                        * in the started state
-                        */
-                       config->vinst_ctrl |= BIT(9);
-
-                       /* No start-stop filtering for ViewInst */
-                       config->vissctlr = 0x0;
-                       break;
-               case ETM_ADDR_TYPE_START:
-               case ETM_ADDR_TYPE_STOP:
-                       /* Get the right start or stop address */
-                       address = (type == ETM_ADDR_TYPE_START ?
-                                  filter->start_addr :
-                                  filter->stop_addr);
-
-                       /* Configure comparator */
-                       etm4_set_start_stop_filter(config, address,
-                                                  comparator, type);
-
-                       /*
-                        * If filters::ssstatus == 1, trace acquisition was
-                        * started but the process was yanked away before the
-                        * the stop address was hit.  As such the start/stop
-                        * logic needs to be re-started so that tracing can
-                        * resume where it left.
-                        *
-                        * The start/stop logic status when a process is
-                        * scheduled out is checked in function
-                        * etm4_disable_perf().
-                        */
-                       if (filters->ssstatus)
-                               config->vinst_ctrl |= BIT(9);
-
-                       /* No include/exclude filtering for ViewInst */
-                       config->viiectlr = 0x0;
-                       break;
-               default:
-                       ret = -EINVAL;
-                       goto out;
-               }
-       }
-
-       goto out;
-
-
-default_filter:
-       etm4_set_default_filter(config);
-
-out:
-       return ret;
-}
-
-void etm4_config_trace_mode(struct etmv4_config *config)
-{
-       u32 addr_acc, mode;
-
-       mode = config->mode;
-       mode &= (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER);
-
-       /* excluding kernel AND user space doesn't make sense */
-       WARN_ON_ONCE(mode == (ETM_MODE_EXCL_KERN | ETM_MODE_EXCL_USER));
-
-       /* nothing to do if neither flags are set */
-       if (!(mode & ETM_MODE_EXCL_KERN) && !(mode & ETM_MODE_EXCL_USER))
-               return;
-
-       addr_acc = config->addr_acc[ETM_DEFAULT_ADDR_COMP];
-       /* clear default config */
-       addr_acc &= ~(ETM_EXLEVEL_NS_APP | ETM_EXLEVEL_NS_OS |
-                     ETM_EXLEVEL_NS_HYP);
-
-       addr_acc |= etm4_get_ns_access_type(config);
-
-       config->addr_acc[ETM_DEFAULT_ADDR_COMP] = addr_acc;
-       config->addr_acc[ETM_DEFAULT_ADDR_COMP + 1] = addr_acc;
-}
-
-static int etm4_online_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       if (etmdrvdata[cpu]->boot_enable && !etmdrvdata[cpu]->sticky_enable)
-               coresight_enable(etmdrvdata[cpu]->csdev);
-       return 0;
-}
-
-static int etm4_starting_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       spin_lock(&etmdrvdata[cpu]->spinlock);
-       if (!etmdrvdata[cpu]->os_unlock)
-               etm4_os_unlock(etmdrvdata[cpu]);
-
-       if (local_read(&etmdrvdata[cpu]->mode))
-               etm4_enable_hw(etmdrvdata[cpu]);
-       spin_unlock(&etmdrvdata[cpu]->spinlock);
-       return 0;
-}
-
-static int etm4_dying_cpu(unsigned int cpu)
-{
-       if (!etmdrvdata[cpu])
-               return 0;
-
-       spin_lock(&etmdrvdata[cpu]->spinlock);
-       if (local_read(&etmdrvdata[cpu]->mode))
-               etm4_disable_hw(etmdrvdata[cpu]);
-       spin_unlock(&etmdrvdata[cpu]->spinlock);
-       return 0;
-}
-
-static void etm4_init_trace_id(struct etmv4_drvdata *drvdata)
-{
-       drvdata->trcid = coresight_get_trace_id(drvdata->cpu);
-}
-
-static int etm4_cpu_save(struct etmv4_drvdata *drvdata)
-{
-       int i, ret = 0;
-       struct etmv4_save_state *state;
-       struct device *etm_dev = &drvdata->csdev->dev;
-
-       /*
-        * As recommended by 3.4.1 ("The procedure when powering down the PE")
-        * of ARM IHI 0064D
-        */
-       dsb(sy);
-       isb();
-
-       CS_UNLOCK(drvdata->base);
-
-       /* Lock the OS lock to disable trace and external debugger access */
-       etm4_os_lock(drvdata);
-
-       /* wait for TRCSTATR.PMSTABLE to go up */
-       if (coresight_timeout(drvdata->base, TRCSTATR,
-                             TRCSTATR_PMSTABLE_BIT, 1)) {
-               dev_err(etm_dev,
-                       "timeout while waiting for PM Stable Status\n");
-               etm4_os_unlock(drvdata);
-               ret = -EBUSY;
-               goto out;
-       }
-
-       state = drvdata->save_state;
-
-       state->trcprgctlr = readl(drvdata->base + TRCPRGCTLR);
-       state->trcprocselr = readl(drvdata->base + TRCPROCSELR);
-       state->trcconfigr = readl(drvdata->base + TRCCONFIGR);
-       state->trcauxctlr = readl(drvdata->base + TRCAUXCTLR);
-       state->trceventctl0r = readl(drvdata->base + TRCEVENTCTL0R);
-       state->trceventctl1r = readl(drvdata->base + TRCEVENTCTL1R);
-       state->trcstallctlr = readl(drvdata->base + TRCSTALLCTLR);
-       state->trctsctlr = readl(drvdata->base + TRCTSCTLR);
-       state->trcsyncpr = readl(drvdata->base + TRCSYNCPR);
-       state->trcccctlr = readl(drvdata->base + TRCCCCTLR);
-       state->trcbbctlr = readl(drvdata->base + TRCBBCTLR);
-       state->trctraceidr = readl(drvdata->base + TRCTRACEIDR);
-       state->trcqctlr = readl(drvdata->base + TRCQCTLR);
-
-       state->trcvictlr = readl(drvdata->base + TRCVICTLR);
-       state->trcviiectlr = readl(drvdata->base + TRCVIIECTLR);
-       state->trcvissctlr = readl(drvdata->base + TRCVISSCTLR);
-       state->trcvipcssctlr = readl(drvdata->base + TRCVIPCSSCTLR);
-       state->trcvdctlr = readl(drvdata->base + TRCVDCTLR);
-       state->trcvdsacctlr = readl(drvdata->base + TRCVDSACCTLR);
-       state->trcvdarcctlr = readl(drvdata->base + TRCVDARCCTLR);
-
-       for (i = 0; i < drvdata->nrseqstate; i++)
-               state->trcseqevr[i] = readl(drvdata->base + TRCSEQEVRn(i));
-
-       state->trcseqrstevr = readl(drvdata->base + TRCSEQRSTEVR);
-       state->trcseqstr = readl(drvdata->base + TRCSEQSTR);
-       state->trcextinselr = readl(drvdata->base + TRCEXTINSELR);
-
-       for (i = 0; i < drvdata->nr_cntr; i++) {
-               state->trccntrldvr[i] = readl(drvdata->base + TRCCNTRLDVRn(i));
-               state->trccntctlr[i] = readl(drvdata->base + TRCCNTCTLRn(i));
-               state->trccntvr[i] = readl(drvdata->base + TRCCNTVRn(i));
-       }
-
-       for (i = 0; i < drvdata->nr_resource * 2; i++)
-               state->trcrsctlr[i] = readl(drvdata->base + TRCRSCTLRn(i));
-
-       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
-               state->trcssccr[i] = readl(drvdata->base + TRCSSCCRn(i));
-               state->trcsscsr[i] = readl(drvdata->base + TRCSSCSRn(i));
-               state->trcsspcicr[i] = readl(drvdata->base + TRCSSPCICRn(i));
-       }
-
-       for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
-               state->trcacvr[i] = readq(drvdata->base + TRCACVRn(i));
-               state->trcacatr[i] = readq(drvdata->base + TRCACATRn(i));
-       }
-
-       /*
-        * Data trace stream is architecturally prohibited for A profile cores
-        * so we don't save (or later restore) trcdvcvr and trcdvcmr - As per
-        * section 1.3.4 ("Possible functional configurations of an ETMv4 trace
-        * unit") of ARM IHI 0064D.
-        */
-
-       for (i = 0; i < drvdata->numcidc; i++)
-               state->trccidcvr[i] = readq(drvdata->base + TRCCIDCVRn(i));
-
-       for (i = 0; i < drvdata->numvmidc; i++)
-               state->trcvmidcvr[i] = readq(drvdata->base + TRCVMIDCVRn(i));
-
-       state->trccidcctlr0 = readl(drvdata->base + TRCCIDCCTLR0);
-       state->trccidcctlr1 = readl(drvdata->base + TRCCIDCCTLR1);
-
-       state->trcvmidcctlr0 = readl(drvdata->base + TRCVMIDCCTLR0);
-       state->trcvmidcctlr0 = readl(drvdata->base + TRCVMIDCCTLR1);
-
-       state->trcclaimset = readl(drvdata->base + TRCCLAIMCLR);
-
-       state->trcpdcr = readl(drvdata->base + TRCPDCR);
-
-       /* wait for TRCSTATR.IDLE to go up */
-       if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 1)) {
-               dev_err(etm_dev,
-                       "timeout while waiting for Idle Trace Status\n");
-               etm4_os_unlock(drvdata);
-               ret = -EBUSY;
-               goto out;
-       }
-
-       drvdata->state_needs_restore = true;
-
-       /*
-        * Power can be removed from the trace unit now. We do this to
-        * potentially save power on systems that respect the TRCPDCR_PU
-        * despite requesting software to save/restore state.
-        */
-       writel_relaxed((state->trcpdcr & ~TRCPDCR_PU),
-                       drvdata->base + TRCPDCR);
-
-out:
-       CS_LOCK(drvdata->base);
-       return ret;
-}
-
-static void etm4_cpu_restore(struct etmv4_drvdata *drvdata)
-{
-       int i;
-       struct etmv4_save_state *state = drvdata->save_state;
-
-       CS_UNLOCK(drvdata->base);
-
-       writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET);
-
-       writel_relaxed(state->trcprgctlr, drvdata->base + TRCPRGCTLR);
-       writel_relaxed(state->trcprocselr, drvdata->base + TRCPROCSELR);
-       writel_relaxed(state->trcconfigr, drvdata->base + TRCCONFIGR);
-       writel_relaxed(state->trcauxctlr, drvdata->base + TRCAUXCTLR);
-       writel_relaxed(state->trceventctl0r, drvdata->base + TRCEVENTCTL0R);
-       writel_relaxed(state->trceventctl1r, drvdata->base + TRCEVENTCTL1R);
-       writel_relaxed(state->trcstallctlr, drvdata->base + TRCSTALLCTLR);
-       writel_relaxed(state->trctsctlr, drvdata->base + TRCTSCTLR);
-       writel_relaxed(state->trcsyncpr, drvdata->base + TRCSYNCPR);
-       writel_relaxed(state->trcccctlr, drvdata->base + TRCCCCTLR);
-       writel_relaxed(state->trcbbctlr, drvdata->base + TRCBBCTLR);
-       writel_relaxed(state->trctraceidr, drvdata->base + TRCTRACEIDR);
-       writel_relaxed(state->trcqctlr, drvdata->base + TRCQCTLR);
-
-       writel_relaxed(state->trcvictlr, drvdata->base + TRCVICTLR);
-       writel_relaxed(state->trcviiectlr, drvdata->base + TRCVIIECTLR);
-       writel_relaxed(state->trcvissctlr, drvdata->base + TRCVISSCTLR);
-       writel_relaxed(state->trcvipcssctlr, drvdata->base + TRCVIPCSSCTLR);
-       writel_relaxed(state->trcvdctlr, drvdata->base + TRCVDCTLR);
-       writel_relaxed(state->trcvdsacctlr, drvdata->base + TRCVDSACCTLR);
-       writel_relaxed(state->trcvdarcctlr, drvdata->base + TRCVDARCCTLR);
-
-       for (i = 0; i < drvdata->nrseqstate; i++)
-               writel_relaxed(state->trcseqevr[i],
-                              drvdata->base + TRCSEQEVRn(i));
-
-       writel_relaxed(state->trcseqrstevr, drvdata->base + TRCSEQRSTEVR);
-       writel_relaxed(state->trcseqstr, drvdata->base + TRCSEQSTR);
-       writel_relaxed(state->trcextinselr, drvdata->base + TRCEXTINSELR);
-
-       for (i = 0; i < drvdata->nr_cntr; i++) {
-               writel_relaxed(state->trccntrldvr[i],
-                              drvdata->base + TRCCNTRLDVRn(i));
-               writel_relaxed(state->trccntctlr[i],
-                              drvdata->base + TRCCNTCTLRn(i));
-               writel_relaxed(state->trccntvr[i],
-                              drvdata->base + TRCCNTVRn(i));
-       }
-
-       for (i = 0; i < drvdata->nr_resource * 2; i++)
-               writel_relaxed(state->trcrsctlr[i],
-                              drvdata->base + TRCRSCTLRn(i));
-
-       for (i = 0; i < drvdata->nr_ss_cmp; i++) {
-               writel_relaxed(state->trcssccr[i],
-                              drvdata->base + TRCSSCCRn(i));
-               writel_relaxed(state->trcsscsr[i],
-                              drvdata->base + TRCSSCSRn(i));
-               writel_relaxed(state->trcsspcicr[i],
-                              drvdata->base + TRCSSPCICRn(i));
-       }
-
-       for (i = 0; i < drvdata->nr_addr_cmp * 2; i++) {
-               writeq_relaxed(state->trcacvr[i],
-                              drvdata->base + TRCACVRn(i));
-               writeq_relaxed(state->trcacatr[i],
-                              drvdata->base + TRCACATRn(i));
-       }
-
-       for (i = 0; i < drvdata->numcidc; i++)
-               writeq_relaxed(state->trccidcvr[i],
-                              drvdata->base + TRCCIDCVRn(i));
-
-       for (i = 0; i < drvdata->numvmidc; i++)
-               writeq_relaxed(state->trcvmidcvr[i],
-                              drvdata->base + TRCVMIDCVRn(i));
-
-       writel_relaxed(state->trccidcctlr0, drvdata->base + TRCCIDCCTLR0);
-       writel_relaxed(state->trccidcctlr1, drvdata->base + TRCCIDCCTLR1);
-
-       writel_relaxed(state->trcvmidcctlr0, drvdata->base + TRCVMIDCCTLR0);
-       writel_relaxed(state->trcvmidcctlr0, drvdata->base + TRCVMIDCCTLR1);
-
-       writel_relaxed(state->trcclaimset, drvdata->base + TRCCLAIMSET);
-
-       writel_relaxed(state->trcpdcr, drvdata->base + TRCPDCR);
-
-       drvdata->state_needs_restore = false;
-
-       /*
-        * As recommended by section 4.3.7 ("Synchronization when using the
-        * memory-mapped interface") of ARM IHI 0064D
-        */
-       dsb(sy);
-       isb();
-
-       /* Unlock the OS lock to re-enable trace and external debug access */
-       etm4_os_unlock(drvdata);
-       CS_LOCK(drvdata->base);
-}
-
-static int etm4_cpu_pm_notify(struct notifier_block *nb, unsigned long cmd,
-                             void *v)
-{
-       struct etmv4_drvdata *drvdata;
-       unsigned int cpu = smp_processor_id();
-
-       if (!etmdrvdata[cpu])
-               return NOTIFY_OK;
-
-       drvdata = etmdrvdata[cpu];
-
-       if (!drvdata->save_state)
-               return NOTIFY_OK;
-
-       if (WARN_ON_ONCE(drvdata->cpu != cpu))
-               return NOTIFY_BAD;
-
-       switch (cmd) {
-       case CPU_PM_ENTER:
-               /* save the state if self-hosted coresight is in use */
-               if (local_read(&drvdata->mode))
-                       if (etm4_cpu_save(drvdata))
-                               return NOTIFY_BAD;
-               break;
-       case CPU_PM_EXIT:
-               /* fallthrough */
-       case CPU_PM_ENTER_FAILED:
-               if (drvdata->state_needs_restore)
-                       etm4_cpu_restore(drvdata);
-               break;
-       default:
-               return NOTIFY_DONE;
-       }
-
-       return NOTIFY_OK;
-}
-
-static struct notifier_block etm4_cpu_pm_nb = {
-       .notifier_call = etm4_cpu_pm_notify,
-};
-
-/* Setup PM. Called with cpus locked. Deals with error conditions and counts */
-static int etm4_pm_setup_cpuslocked(void)
-{
-       int ret;
-
-       if (etm4_count++)
-               return 0;
-
-       ret = cpu_pm_register_notifier(&etm4_cpu_pm_nb);
-       if (ret)
-               goto reduce_count;
-
-       ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING,
-                                                  "arm/coresight4:starting",
-                                                  etm4_starting_cpu, etm4_dying_cpu);
-
-       if (ret)
-               goto unregister_notifier;
-
-       ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
-                                                  "arm/coresight4:online",
-                                                  etm4_online_cpu, NULL);
-
-       /* HP dyn state ID returned in ret on success */
-       if (ret > 0) {
-               hp_online = ret;
-               return 0;
-       }
-
-       /* failed dyn state - remove others */
-       cpuhp_remove_state_nocalls_cpuslocked(CPUHP_AP_ARM_CORESIGHT_STARTING);
-
-unregister_notifier:
-       cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
-
-reduce_count:
-       --etm4_count;
-       return ret;
-}
-
-static void etm4_pm_clear(void)
-{
-       if (--etm4_count != 0)
-               return;
-
-       cpu_pm_unregister_notifier(&etm4_cpu_pm_nb);
-       cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_STARTING);
-       if (hp_online) {
-               cpuhp_remove_state_nocalls(hp_online);
-               hp_online = 0;
-       }
-}
-
-static int etm4_probe(struct amba_device *adev, const struct amba_id *id)
-{
-       int ret;
-       void __iomem *base;
-       struct device *dev = &adev->dev;
-       struct coresight_platform_data *pdata = NULL;
-       struct etmv4_drvdata *drvdata;
-       struct resource *res = &adev->res;
-       struct coresight_desc desc = { 0 };
-
-       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-       if (!drvdata)
-               return -ENOMEM;
-
-       dev_set_drvdata(dev, drvdata);
-
-       if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE)
-               pm_save_enable = coresight_loses_context_with_cpu(dev) ?
-                              PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER;
-
-       if (pm_save_enable != PARAM_PM_SAVE_NEVER) {
-               drvdata->save_state = devm_kmalloc(dev,
-                               sizeof(struct etmv4_save_state), GFP_KERNEL);
-               if (!drvdata->save_state)
-                       return -ENOMEM;
-       }
-
-       if (fwnode_property_present(dev_fwnode(dev), "qcom,skip-power-up"))
-               drvdata->skip_power_up = true;
-
-       /* Validity for the resource is already checked by the AMBA core */
-       base = devm_ioremap_resource(dev, res);
-       if (IS_ERR(base))
-               return PTR_ERR(base);
-
-       drvdata->base = base;
-
-       spin_lock_init(&drvdata->spinlock);
-
-       drvdata->cpu = coresight_get_cpu(dev);
-       if (drvdata->cpu < 0)
-               return drvdata->cpu;
-
-       desc.name = devm_kasprintf(dev, GFP_KERNEL, "etm%d", drvdata->cpu);
-       if (!desc.name)
-               return -ENOMEM;
-
-       cpus_read_lock();
-       etmdrvdata[drvdata->cpu] = drvdata;
-
-       if (smp_call_function_single(drvdata->cpu,
-                               etm4_init_arch_data,  drvdata, 1))
-               dev_err(dev, "ETM arch init failed\n");
-
-       ret = etm4_pm_setup_cpuslocked();
-       cpus_read_unlock();
-
-       /* etm4_pm_setup_cpuslocked() does its own cleanup - exit on error */
-       if (ret) {
-               etmdrvdata[drvdata->cpu] = NULL;
-               return ret;
-       }
-
-       if (etm4_arch_supported(drvdata->arch) == false) {
-               ret = -EINVAL;
-               goto err_arch_supported;
-       }
-
-       etm4_init_trace_id(drvdata);
-       etm4_set_default(&drvdata->config);
-
-       pdata = coresight_get_platform_data(dev);
-       if (IS_ERR(pdata)) {
-               ret = PTR_ERR(pdata);
-               goto err_arch_supported;
-       }
-       adev->dev.platform_data = pdata;
-
-       desc.type = CORESIGHT_DEV_TYPE_SOURCE;
-       desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_PROC;
-       desc.ops = &etm4_cs_ops;
-       desc.pdata = pdata;
-       desc.dev = dev;
-       desc.groups = coresight_etmv4_groups;
-       drvdata->csdev = coresight_register(&desc);
-       if (IS_ERR(drvdata->csdev)) {
-               ret = PTR_ERR(drvdata->csdev);
-               goto err_arch_supported;
-       }
-
-       ret = etm_perf_symlink(drvdata->csdev, true);
-       if (ret) {
-               coresight_unregister(drvdata->csdev);
-               goto err_arch_supported;
-       }
-
-       pm_runtime_put(&adev->dev);
-       dev_info(&drvdata->csdev->dev, "CPU%d: ETM v%d.%d initialized\n",
-                drvdata->cpu, drvdata->arch >> 4, drvdata->arch & 0xf);
-
-       if (boot_enable) {
-               coresight_enable(drvdata->csdev);
-               drvdata->boot_enable = true;
-       }
-
-       return 0;
-
-err_arch_supported:
-       etmdrvdata[drvdata->cpu] = NULL;
-       etm4_pm_clear();
-       return ret;
-}
-
-static struct amba_cs_uci_id uci_id_etm4[] = {
-       {
-               /*  ETMv4 UCI data */
-               .devarch        = 0x47704a13,
-               .devarch_mask   = 0xfff0ffff,
-               .devtype        = 0x00000013,
-       }
-};
-
-static const struct amba_id etm4_ids[] = {
-       CS_AMBA_ID(0x000bb95d),                 /* Cortex-A53 */
-       CS_AMBA_ID(0x000bb95e),                 /* Cortex-A57 */
-       CS_AMBA_ID(0x000bb95a),                 /* Cortex-A72 */
-       CS_AMBA_ID(0x000bb959),                 /* Cortex-A73 */
-       CS_AMBA_UCI_ID(0x000bb9da, uci_id_etm4),/* Cortex-A35 */
-       CS_AMBA_UCI_ID(0x000bbd0c, uci_id_etm4),/* Neoverse N1 */
-       CS_AMBA_UCI_ID(0x000f0205, uci_id_etm4),/* Qualcomm Kryo */
-       CS_AMBA_UCI_ID(0x000f0211, uci_id_etm4),/* Qualcomm Kryo */
-       CS_AMBA_UCI_ID(0x000bb802, uci_id_etm4),/* Qualcomm Kryo 385 Cortex-A55 */
-       CS_AMBA_UCI_ID(0x000bb803, uci_id_etm4),/* Qualcomm Kryo 385 Cortex-A75 */
-       CS_AMBA_UCI_ID(0x000bb805, uci_id_etm4),/* Qualcomm Kryo 4XX Cortex-A55 */
-       CS_AMBA_UCI_ID(0x000bb804, uci_id_etm4),/* Qualcomm Kryo 4XX Cortex-A76 */
-       CS_AMBA_UCI_ID(0x000cc0af, uci_id_etm4),/* Marvell ThunderX2 */
-       {},
-};
-
-static struct amba_driver etm4x_driver = {
-       .drv = {
-               .name   = "coresight-etm4x",
-               .suppress_bind_attrs = true,
-       },
-       .probe          = etm4_probe,
-       .id_table       = etm4_ids,
-};
-builtin_amba_driver(etm4x_driver);
index b8283e1..eefc737 100644 (file)
 #define ETM_EXLEVEL_NS_HYP             BIT(14)
 #define ETM_EXLEVEL_NS_NA              BIT(15)
 
+/* access level control in TRCVICTLR - same bits as TRCACATRn but shifted */
+#define ETM_EXLEVEL_LSHIFT_TRCVICTLR   8
+
 /* secure / non secure masks - TRCVICTLR, IDR3 */
 #define ETM_EXLEVEL_S_VICTLR_MASK      GENMASK(19, 16)
 /* NS MON (EL3) mode never implemented */
 #define ETM_EXLEVEL_NS_VICTLR_MASK     GENMASK(22, 20)
 
+/* Interpretation of resource numbers change at ETM v4.3 architecture */
+#define ETM4X_ARCH_4V3 0x43
+
 /**
  * struct etmv4_config - configuration information related to an ETMv4
  * @mode:      Controls various modes supported by this ETM.
index 900690a..af40814 100644 (file)
@@ -274,6 +274,15 @@ out_disable_clk:
        return ret;
 }
 
+static int __exit funnel_remove(struct device *dev)
+{
+       struct funnel_drvdata *drvdata = dev_get_drvdata(dev);
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
 #ifdef CONFIG_PM
 static int funnel_runtime_suspend(struct device *dev)
 {
@@ -319,29 +328,41 @@ static int static_funnel_probe(struct platform_device *pdev)
        return ret;
 }
 
+static int __exit static_funnel_remove(struct platform_device *pdev)
+{
+       funnel_remove(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+       return 0;
+}
+
 static const struct of_device_id static_funnel_match[] = {
        {.compatible = "arm,coresight-static-funnel"},
        {}
 };
 
+MODULE_DEVICE_TABLE(of, static_funnel_match);
+
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id static_funnel_ids[] = {
        {"ARMHC9FE", 0},
        {},
 };
+
+MODULE_DEVICE_TABLE(acpi, static_funnel_ids);
 #endif
 
 static struct platform_driver static_funnel_driver = {
        .probe          = static_funnel_probe,
+       .remove          = static_funnel_remove,
        .driver         = {
                .name   = "coresight-static-funnel",
+               .owner  = THIS_MODULE,
                .of_match_table = static_funnel_match,
                .acpi_match_table = ACPI_PTR(static_funnel_ids),
                .pm     = &funnel_dev_pm_ops,
                .suppress_bind_attrs = true,
        },
 };
-builtin_platform_driver(static_funnel_driver);
 
 static int dynamic_funnel_probe(struct amba_device *adev,
                                const struct amba_id *id)
@@ -349,6 +370,11 @@ static int dynamic_funnel_probe(struct amba_device *adev,
        return funnel_probe(&adev->dev, &adev->res);
 }
 
+static int __exit dynamic_funnel_remove(struct amba_device *adev)
+{
+       return funnel_remove(&adev->dev);
+}
+
 static const struct amba_id dynamic_funnel_ids[] = {
        {
                .id     = 0x000bb908,
@@ -362,6 +388,8 @@ static const struct amba_id dynamic_funnel_ids[] = {
        { 0, 0},
 };
 
+MODULE_DEVICE_TABLE(amba, dynamic_funnel_ids);
+
 static struct amba_driver dynamic_funnel_driver = {
        .drv = {
                .name   = "coresight-dynamic-funnel",
@@ -370,6 +398,39 @@ static struct amba_driver dynamic_funnel_driver = {
                .suppress_bind_attrs = true,
        },
        .probe          = dynamic_funnel_probe,
+       .remove         = dynamic_funnel_remove,
        .id_table       = dynamic_funnel_ids,
 };
-builtin_amba_driver(dynamic_funnel_driver);
+
+static int __init funnel_init(void)
+{
+       int ret;
+
+       ret = platform_driver_register(&static_funnel_driver);
+       if (ret) {
+               pr_info("Error registering platform driver\n");
+               return ret;
+       }
+
+       ret = amba_driver_register(&dynamic_funnel_driver);
+       if (ret) {
+               pr_info("Error registering amba driver\n");
+               platform_driver_unregister(&static_funnel_driver);
+       }
+
+       return ret;
+}
+
+static void __exit funnel_exit(void)
+{
+       platform_driver_unregister(&static_funnel_driver);
+       amba_driver_unregister(&dynamic_funnel_driver);
+}
+
+module_init(funnel_init);
+module_exit(funnel_exit);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight Funnel Driver");
+MODULE_LICENSE("GPL v2");
index bfd4423..3629b78 100644 (file)
@@ -75,6 +75,7 @@ coresight_find_csdev_by_fwnode(struct fwnode_handle *r_fwnode)
        }
        return csdev;
 }
+EXPORT_SYMBOL_GPL(coresight_find_csdev_by_fwnode);
 
 #ifdef CONFIG_OF
 static inline bool of_coresight_legacy_ep_is_input(struct device_node *ep)
@@ -711,11 +712,11 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev,
                        return dir;
 
                if (dir == ACPI_CORESIGHT_LINK_MASTER) {
-                       if (ptr->outport > pdata->nr_outport)
-                               pdata->nr_outport = ptr->outport;
+                       if (ptr->outport >= pdata->nr_outport)
+                               pdata->nr_outport = ptr->outport + 1;
                        ptr++;
                } else {
-                       WARN_ON(pdata->nr_inport == ptr->child_port);
+                       WARN_ON(pdata->nr_inport == ptr->child_port + 1);
                        /*
                         * We do not track input port connections for a device.
                         * However we need the highest port number described,
@@ -723,8 +724,8 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev,
                         * record for an output connection. Hence, do not move
                         * the ptr for input connections
                         */
-                       if (ptr->child_port > pdata->nr_inport)
-                               pdata->nr_inport = ptr->child_port;
+                       if (ptr->child_port >= pdata->nr_inport)
+                               pdata->nr_inport = ptr->child_port + 1;
                }
        }
 
index f2dc625..65a2929 100644 (file)
@@ -66,8 +66,8 @@ static DEVICE_ATTR_RO(name)
 #define coresight_simple_reg64(type, name, lo_off, hi_off)             \
        __coresight_simple_func(type, NULL, name, lo_off, hi_off)
 
-extern const u32 barrier_pkt[4];
-#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(barrier_pkt))
+extern const u32 coresight_barrier_pkt[4];
+#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(coresight_barrier_pkt))
 
 enum etm_addr_type {
        ETM_ADDR_TYPE_NONE,
@@ -104,10 +104,9 @@ struct cs_buffers {
 static inline void coresight_insert_barrier_packet(void *buf)
 {
        if (buf)
-               memcpy(buf, barrier_pkt, CORESIGHT_BARRIER_PKT_SIZE);
+               memcpy(buf, coresight_barrier_pkt, CORESIGHT_BARRIER_PKT_SIZE);
 }
 
-
 static inline void CS_LOCK(void __iomem *addr)
 {
        do {
@@ -148,7 +147,8 @@ static inline void coresight_write_reg_pair(void __iomem *addr, u64 val,
 void coresight_disable_path(struct list_head *path);
 int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data);
 struct coresight_device *coresight_get_sink(struct list_head *path);
-struct coresight_device *coresight_get_enabled_sink(bool reset);
+struct coresight_device *
+coresight_get_enabled_sink(struct coresight_device *source);
 struct coresight_device *coresight_get_sink_by_id(u32 id);
 struct coresight_device *
 coresight_find_default_sink(struct coresight_device *csdev);
@@ -165,7 +165,7 @@ int coresight_make_links(struct coresight_device *orig,
 void coresight_remove_links(struct coresight_device *orig,
                            struct coresight_connection *conn);
 
-#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X
+#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X)
 extern int etm_readl_cp14(u32 off, unsigned int *val);
 extern int etm_writel_cp14(u32 off, u32 val);
 #else
@@ -173,15 +173,13 @@ static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; }
 static inline int etm_writel_cp14(u32 off, u32 val) { return 0; }
 #endif
 
-#ifdef CONFIG_CORESIGHT_CTI
-extern void cti_add_assoc_to_csdev(struct coresight_device *csdev);
-extern void cti_remove_assoc_from_csdev(struct coresight_device *csdev);
+struct cti_assoc_op {
+       void (*add)(struct coresight_device *csdev);
+       void (*remove)(struct coresight_device *csdev);
+};
 
-#else
-static inline void cti_add_assoc_to_csdev(struct coresight_device *csdev) {}
-static inline void
-cti_remove_assoc_from_csdev(struct coresight_device *csdev) {}
-#endif
+extern void coresight_set_cti_ops(const struct cti_assoc_op *cti_op);
+extern void coresight_remove_cti_ops(void);
 
 /*
  * Macros and inline functions to handle CoreSight UCI data and driver
index 78acf29..62afdde 100644 (file)
@@ -291,6 +291,14 @@ out_disable_clk:
        return ret;
 }
 
+static int __exit replicator_remove(struct device *dev)
+{
+       struct replicator_drvdata *drvdata = dev_get_drvdata(dev);
+
+       coresight_unregister(drvdata->csdev);
+       return 0;
+}
+
 static int static_replicator_probe(struct platform_device *pdev)
 {
        int ret;
@@ -310,6 +318,13 @@ static int static_replicator_probe(struct platform_device *pdev)
        return ret;
 }
 
+static int __exit static_replicator_remove(struct platform_device *pdev)
+{
+       replicator_remove(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
+       return 0;
+}
+
 #ifdef CONFIG_PM
 static int replicator_runtime_suspend(struct device *dev)
 {
@@ -343,24 +358,29 @@ static const struct of_device_id static_replicator_match[] = {
        {}
 };
 
+MODULE_DEVICE_TABLE(of, static_replicator_match);
+
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id static_replicator_acpi_ids[] = {
        {"ARMHC985", 0}, /* ARM CoreSight Static Replicator */
        {}
 };
+
+MODULE_DEVICE_TABLE(acpi, static_replicator_acpi_ids);
 #endif
 
 static struct platform_driver static_replicator_driver = {
        .probe          = static_replicator_probe,
+       .remove         = static_replicator_remove,
        .driver         = {
                .name   = "coresight-static-replicator",
+               .owner  = THIS_MODULE,
                .of_match_table = of_match_ptr(static_replicator_match),
                .acpi_match_table = ACPI_PTR(static_replicator_acpi_ids),
                .pm     = &replicator_dev_pm_ops,
                .suppress_bind_attrs = true,
        },
 };
-builtin_platform_driver(static_replicator_driver);
 
 static int dynamic_replicator_probe(struct amba_device *adev,
                                    const struct amba_id *id)
@@ -368,19 +388,60 @@ static int dynamic_replicator_probe(struct amba_device *adev,
        return replicator_probe(&adev->dev, &adev->res);
 }
 
+static int __exit dynamic_replicator_remove(struct amba_device *adev)
+{
+       return replicator_remove(&adev->dev);
+}
+
 static const struct amba_id dynamic_replicator_ids[] = {
        CS_AMBA_ID(0x000bb909),
        CS_AMBA_ID(0x000bb9ec),         /* Coresight SoC-600 */
        {},
 };
 
+MODULE_DEVICE_TABLE(amba, dynamic_replicator_ids);
+
 static struct amba_driver dynamic_replicator_driver = {
        .drv = {
                .name   = "coresight-dynamic-replicator",
                .pm     = &replicator_dev_pm_ops,
+               .owner  = THIS_MODULE,
                .suppress_bind_attrs = true,
        },
        .probe          = dynamic_replicator_probe,
+       .remove         = dynamic_replicator_remove,
        .id_table       = dynamic_replicator_ids,
 };
-builtin_amba_driver(dynamic_replicator_driver);
+
+static int __init replicator_init(void)
+{
+       int ret;
+
+       ret = platform_driver_register(&static_replicator_driver);
+       if (ret) {
+               pr_info("Error registering platform driver\n");
+               return ret;
+       }
+
+       ret = amba_driver_register(&dynamic_replicator_driver);
+       if (ret) {
+               pr_info("Error registering amba driver\n");
+               platform_driver_unregister(&static_replicator_driver);
+       }
+
+       return ret;
+}
+
+static void __exit replicator_exit(void)
+{
+       platform_driver_unregister(&static_replicator_driver);
+       amba_driver_unregister(&dynamic_replicator_driver);
+}
+
+module_init(replicator_init);
+module_exit(replicator_exit);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight Replicator Driver");
+MODULE_LICENSE("GPL v2");
index 673d2f5..b0ad912 100644 (file)
@@ -412,6 +412,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
        void __iomem *ch_addr;
        struct stm_drvdata *drvdata = container_of(stm_data,
                                                   struct stm_drvdata, stm);
+       unsigned int stm_flags;
 
        if (!(drvdata && local_read(&drvdata->mode)))
                return -EACCES;
@@ -421,8 +422,9 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
 
        ch_addr = stm_channel_addr(drvdata, channel);
 
-       flags = (flags == STP_PACKET_TIMESTAMPED) ? STM_FLAG_TIMESTAMPED : 0;
-       flags |= test_bit(channel, drvdata->chs.guaranteed) ?
+       stm_flags = (flags & STP_PACKET_TIMESTAMPED) ?
+                       STM_FLAG_TIMESTAMPED : 0;
+       stm_flags |= test_bit(channel, drvdata->chs.guaranteed) ?
                           STM_FLAG_GUARANTEED : 0;
 
        if (size > drvdata->write_bytes)
@@ -432,7 +434,7 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
 
        switch (packet) {
        case STP_PACKET_FLAG:
-               ch_addr += stm_channel_off(STM_PKT_TYPE_FLAG, flags);
+               ch_addr += stm_channel_off(STM_PKT_TYPE_FLAG, stm_flags);
 
                /*
                 * The generic STM core sets a size of '0' on flag packets.
@@ -444,7 +446,8 @@ static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
                break;
 
        case STP_PACKET_DATA:
-               ch_addr += stm_channel_off(STM_PKT_TYPE_DATA, flags);
+               stm_flags |= (flags & STP_PACKET_MARKED) ? STM_FLAG_MARKED : 0;
+               ch_addr += stm_channel_off(STM_PKT_TYPE_DATA, stm_flags);
                stm_send(ch_addr, payload, size,
                                drvdata->write_bytes);
                break;
@@ -948,6 +951,17 @@ stm_unregister:
        return ret;
 }
 
+static int __exit stm_remove(struct amba_device *adev)
+{
+       struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       coresight_unregister(drvdata->csdev);
+
+       stm_unregister_device(&drvdata->stm);
+
+       return 0;
+}
+
 #ifdef CONFIG_PM
 static int stm_runtime_suspend(struct device *dev)
 {
@@ -980,6 +994,8 @@ static const struct amba_id stm_ids[] = {
        { 0, 0},
 };
 
+MODULE_DEVICE_TABLE(amba, stm_ids);
+
 static struct amba_driver stm_driver = {
        .drv = {
                .name   = "coresight-stm",
@@ -988,7 +1004,12 @@ static struct amba_driver stm_driver = {
                .suppress_bind_attrs = true,
        },
        .probe          = stm_probe,
+       .remove         = stm_remove,
        .id_table       = stm_ids,
 };
 
-builtin_amba_driver(stm_driver);
+module_amba_driver(stm_driver);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_DESCRIPTION("Arm CoreSight System Trace Macrocell driver");
+MODULE_LICENSE("GPL v2");
index 82afeaf..34d2a2d 100644 (file)
@@ -102,6 +102,7 @@ int coresight_add_sysfs_link(struct coresight_sysfs_link *info)
 
        return ret;
 }
+EXPORT_SYMBOL_GPL(coresight_add_sysfs_link);
 
 void coresight_remove_sysfs_link(struct coresight_sysfs_link *info)
 {
@@ -122,6 +123,7 @@ void coresight_remove_sysfs_link(struct coresight_sysfs_link *info)
        info->orig->nr_links--;
        info->target->nr_links--;
 }
+EXPORT_SYMBOL_GPL(coresight_remove_sysfs_link);
 
 /*
  * coresight_make_links: Make a link for a connection from a @orig
diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
new file mode 100644 (file)
index 0000000..5653e09
--- /dev/null
@@ -0,0 +1,606 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ *
+ * Description: CoreSight Trace Memory Controller driver
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/idr.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/mutex.h>
+#include <linux/property.h>
+#include <linux/uaccess.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/coresight.h>
+#include <linux/amba/bus.h>
+
+#include "coresight-priv.h"
+#include "coresight-tmc.h"
+
+DEFINE_CORESIGHT_DEVLIST(etb_devs, "tmc_etb");
+DEFINE_CORESIGHT_DEVLIST(etf_devs, "tmc_etf");
+DEFINE_CORESIGHT_DEVLIST(etr_devs, "tmc_etr");
+
+void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata)
+{
+       /* Ensure formatter, unformatter and hardware fifo are empty */
+       if (coresight_timeout(drvdata->base,
+                             TMC_STS, TMC_STS_TMCREADY_BIT, 1)) {
+               dev_err(&drvdata->csdev->dev,
+                       "timeout while waiting for TMC to be Ready\n");
+       }
+}
+
+void tmc_flush_and_stop(struct tmc_drvdata *drvdata)
+{
+       u32 ffcr;
+
+       ffcr = readl_relaxed(drvdata->base + TMC_FFCR);
+       ffcr |= TMC_FFCR_STOP_ON_FLUSH;
+       writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
+       ffcr |= BIT(TMC_FFCR_FLUSHMAN_BIT);
+       writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
+       /* Ensure flush completes */
+       if (coresight_timeout(drvdata->base,
+                             TMC_FFCR, TMC_FFCR_FLUSHMAN_BIT, 0)) {
+               dev_err(&drvdata->csdev->dev,
+               "timeout while waiting for completion of Manual Flush\n");
+       }
+
+       tmc_wait_for_tmcready(drvdata);
+}
+
+void tmc_enable_hw(struct tmc_drvdata *drvdata)
+{
+       writel_relaxed(TMC_CTL_CAPT_EN, drvdata->base + TMC_CTL);
+}
+
+void tmc_disable_hw(struct tmc_drvdata *drvdata)
+{
+       writel_relaxed(0x0, drvdata->base + TMC_CTL);
+}
+
+u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)
+{
+       u32 mask = 0;
+
+       /*
+        * When moving RRP or an offset address forward, the new values must
+        * be byte-address aligned to the width of the trace memory databus
+        * _and_ to a frame boundary (16 byte), whichever is the biggest. For
+        * example, for 32-bit, 64-bit and 128-bit wide trace memory, the four
+        * LSBs must be 0s. For 256-bit wide trace memory, the five LSBs must
+        * be 0s.
+        */
+       switch (drvdata->memwidth) {
+       case TMC_MEM_INTF_WIDTH_32BITS:
+       case TMC_MEM_INTF_WIDTH_64BITS:
+       case TMC_MEM_INTF_WIDTH_128BITS:
+               mask = GENMASK(31, 4);
+               break;
+       case TMC_MEM_INTF_WIDTH_256BITS:
+               mask = GENMASK(31, 5);
+               break;
+       }
+
+       return mask;
+}
+
+static int tmc_read_prepare(struct tmc_drvdata *drvdata)
+{
+       int ret = 0;
+
+       switch (drvdata->config_type) {
+       case TMC_CONFIG_TYPE_ETB:
+       case TMC_CONFIG_TYPE_ETF:
+               ret = tmc_read_prepare_etb(drvdata);
+               break;
+       case TMC_CONFIG_TYPE_ETR:
+               ret = tmc_read_prepare_etr(drvdata);
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       if (!ret)
+               dev_dbg(&drvdata->csdev->dev, "TMC read start\n");
+
+       return ret;
+}
+
+static int tmc_read_unprepare(struct tmc_drvdata *drvdata)
+{
+       int ret = 0;
+
+       switch (drvdata->config_type) {
+       case TMC_CONFIG_TYPE_ETB:
+       case TMC_CONFIG_TYPE_ETF:
+               ret = tmc_read_unprepare_etb(drvdata);
+               break;
+       case TMC_CONFIG_TYPE_ETR:
+               ret = tmc_read_unprepare_etr(drvdata);
+               break;
+       default:
+               ret = -EINVAL;
+       }
+
+       if (!ret)
+               dev_dbg(&drvdata->csdev->dev, "TMC read end\n");
+
+       return ret;
+}
+
+static int tmc_open(struct inode *inode, struct file *file)
+{
+       int ret;
+       struct tmc_drvdata *drvdata = container_of(file->private_data,
+                                                  struct tmc_drvdata, miscdev);
+
+       ret = tmc_read_prepare(drvdata);
+       if (ret)
+               return ret;
+
+       nonseekable_open(inode, file);
+
+       dev_dbg(&drvdata->csdev->dev, "%s: successfully opened\n", __func__);
+       return 0;
+}
+
+static inline ssize_t tmc_get_sysfs_trace(struct tmc_drvdata *drvdata,
+                                         loff_t pos, size_t len, char **bufpp)
+{
+       switch (drvdata->config_type) {
+       case TMC_CONFIG_TYPE_ETB:
+       case TMC_CONFIG_TYPE_ETF:
+               return tmc_etb_get_sysfs_trace(drvdata, pos, len, bufpp);
+       case TMC_CONFIG_TYPE_ETR:
+               return tmc_etr_get_sysfs_trace(drvdata, pos, len, bufpp);
+       }
+
+       return -EINVAL;
+}
+
+static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
+                       loff_t *ppos)
+{
+       char *bufp;
+       ssize_t actual;
+       struct tmc_drvdata *drvdata = container_of(file->private_data,
+                                                  struct tmc_drvdata, miscdev);
+       actual = tmc_get_sysfs_trace(drvdata, *ppos, len, &bufp);
+       if (actual <= 0)
+               return 0;
+
+       if (copy_to_user(data, bufp, actual)) {
+               dev_dbg(&drvdata->csdev->dev,
+                       "%s: copy_to_user failed\n", __func__);
+               return -EFAULT;
+       }
+
+       *ppos += actual;
+       dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual);
+
+       return actual;
+}
+
+static int tmc_release(struct inode *inode, struct file *file)
+{
+       int ret;
+       struct tmc_drvdata *drvdata = container_of(file->private_data,
+                                                  struct tmc_drvdata, miscdev);
+
+       ret = tmc_read_unprepare(drvdata);
+       if (ret)
+               return ret;
+
+       dev_dbg(&drvdata->csdev->dev, "%s: released\n", __func__);
+       return 0;
+}
+
+static const struct file_operations tmc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = tmc_open,
+       .read           = tmc_read,
+       .release        = tmc_release,
+       .llseek         = no_llseek,
+};
+
+static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
+{
+       enum tmc_mem_intf_width memwidth;
+
+       /*
+        * Excerpt from the TRM:
+        *
+        * DEVID::MEMWIDTH[10:8]
+        * 0x2 Memory interface databus is 32 bits wide.
+        * 0x3 Memory interface databus is 64 bits wide.
+        * 0x4 Memory interface databus is 128 bits wide.
+        * 0x5 Memory interface databus is 256 bits wide.
+        */
+       switch (BMVAL(devid, 8, 10)) {
+       case 0x2:
+               memwidth = TMC_MEM_INTF_WIDTH_32BITS;
+               break;
+       case 0x3:
+               memwidth = TMC_MEM_INTF_WIDTH_64BITS;
+               break;
+       case 0x4:
+               memwidth = TMC_MEM_INTF_WIDTH_128BITS;
+               break;
+       case 0x5:
+               memwidth = TMC_MEM_INTF_WIDTH_256BITS;
+               break;
+       default:
+               memwidth = 0;
+       }
+
+       return memwidth;
+}
+
+#define coresight_tmc_reg(name, offset)                        \
+       coresight_simple_reg32(struct tmc_drvdata, name, offset)
+#define coresight_tmc_reg64(name, lo_off, hi_off)      \
+       coresight_simple_reg64(struct tmc_drvdata, name, lo_off, hi_off)
+
+coresight_tmc_reg(rsz, TMC_RSZ);
+coresight_tmc_reg(sts, TMC_STS);
+coresight_tmc_reg(trg, TMC_TRG);
+coresight_tmc_reg(ctl, TMC_CTL);
+coresight_tmc_reg(ffsr, TMC_FFSR);
+coresight_tmc_reg(ffcr, TMC_FFCR);
+coresight_tmc_reg(mode, TMC_MODE);
+coresight_tmc_reg(pscr, TMC_PSCR);
+coresight_tmc_reg(axictl, TMC_AXICTL);
+coresight_tmc_reg(authstatus, TMC_AUTHSTATUS);
+coresight_tmc_reg(devid, CORESIGHT_DEVID);
+coresight_tmc_reg64(rrp, TMC_RRP, TMC_RRPHI);
+coresight_tmc_reg64(rwp, TMC_RWP, TMC_RWPHI);
+coresight_tmc_reg64(dba, TMC_DBALO, TMC_DBAHI);
+
+static struct attribute *coresight_tmc_mgmt_attrs[] = {
+       &dev_attr_rsz.attr,
+       &dev_attr_sts.attr,
+       &dev_attr_rrp.attr,
+       &dev_attr_rwp.attr,
+       &dev_attr_trg.attr,
+       &dev_attr_ctl.attr,
+       &dev_attr_ffsr.attr,
+       &dev_attr_ffcr.attr,
+       &dev_attr_mode.attr,
+       &dev_attr_pscr.attr,
+       &dev_attr_devid.attr,
+       &dev_attr_dba.attr,
+       &dev_attr_axictl.attr,
+       &dev_attr_authstatus.attr,
+       NULL,
+};
+
+static ssize_t trigger_cntr_show(struct device *dev,
+                                struct device_attribute *attr, char *buf)
+{
+       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+       unsigned long val = drvdata->trigger_cntr;
+
+       return sprintf(buf, "%#lx\n", val);
+}
+
+static ssize_t trigger_cntr_store(struct device *dev,
+                            struct device_attribute *attr,
+                            const char *buf, size_t size)
+{
+       int ret;
+       unsigned long val;
+       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+
+       ret = kstrtoul(buf, 16, &val);
+       if (ret)
+               return ret;
+
+       drvdata->trigger_cntr = val;
+       return size;
+}
+static DEVICE_ATTR_RW(trigger_cntr);
+
+static ssize_t buffer_size_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+
+       return sprintf(buf, "%#x\n", drvdata->size);
+}
+
+static ssize_t buffer_size_store(struct device *dev,
+                                struct device_attribute *attr,
+                                const char *buf, size_t size)
+{
+       int ret;
+       unsigned long val;
+       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
+
+       /* Only permitted for TMC-ETRs */
+       if (drvdata->config_type != TMC_CONFIG_TYPE_ETR)
+               return -EPERM;
+
+       ret = kstrtoul(buf, 0, &val);
+       if (ret)
+               return ret;
+       /* The buffer size should be page aligned */
+       if (val & (PAGE_SIZE - 1))
+               return -EINVAL;
+       drvdata->size = val;
+       return size;
+}
+
+static DEVICE_ATTR_RW(buffer_size);
+
+static struct attribute *coresight_tmc_attrs[] = {
+       &dev_attr_trigger_cntr.attr,
+       &dev_attr_buffer_size.attr,
+       NULL,
+};
+
+static const struct attribute_group coresight_tmc_group = {
+       .attrs = coresight_tmc_attrs,
+};
+
+static const struct attribute_group coresight_tmc_mgmt_group = {
+       .attrs = coresight_tmc_mgmt_attrs,
+       .name = "mgmt",
+};
+
+static const struct attribute_group *coresight_tmc_groups[] = {
+       &coresight_tmc_group,
+       &coresight_tmc_mgmt_group,
+       NULL,
+};
+
+static inline bool tmc_etr_can_use_sg(struct device *dev)
+{
+       return fwnode_property_present(dev->fwnode, "arm,scatter-gather");
+}
+
+static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)
+{
+       u32 auth = readl_relaxed(drvdata->base + TMC_AUTHSTATUS);
+
+       return (auth & TMC_AUTH_NSID_MASK) == 0x3;
+}
+
+/* Detect and initialise the capabilities of a TMC ETR */
+static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps)
+{
+       int rc;
+       u32 dma_mask = 0;
+       struct tmc_drvdata *drvdata = dev_get_drvdata(parent);
+
+       if (!tmc_etr_has_non_secure_access(drvdata))
+               return -EACCES;
+
+       /* Set the unadvertised capabilities */
+       tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps);
+
+       if (!(devid & TMC_DEVID_NOSCAT) && tmc_etr_can_use_sg(parent))
+               tmc_etr_set_cap(drvdata, TMC_ETR_SG);
+
+       /* Check if the AXI address width is available */
+       if (devid & TMC_DEVID_AXIAW_VALID)
+               dma_mask = ((devid >> TMC_DEVID_AXIAW_SHIFT) &
+                               TMC_DEVID_AXIAW_MASK);
+
+       /*
+        * Unless specified in the device configuration, ETR uses a 40-bit
+        * AXI master in place of the embedded SRAM of ETB/ETF.
+        */
+       switch (dma_mask) {
+       case 32:
+       case 40:
+       case 44:
+       case 48:
+       case 52:
+               dev_info(parent, "Detected dma mask %dbits\n", dma_mask);
+               break;
+       default:
+               dma_mask = 40;
+       }
+
+       rc = dma_set_mask_and_coherent(parent, DMA_BIT_MASK(dma_mask));
+       if (rc)
+               dev_err(parent, "Failed to setup DMA mask: %d\n", rc);
+       return rc;
+}
+
+static u32 tmc_etr_get_default_buffer_size(struct device *dev)
+{
+       u32 size;
+
+       if (fwnode_property_read_u32(dev->fwnode, "arm,buffer-size", &size))
+               size = SZ_1M;
+       return size;
+}
+
+static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
+{
+       int ret = 0;
+       u32 devid;
+       void __iomem *base;
+       struct device *dev = &adev->dev;
+       struct coresight_platform_data *pdata = NULL;
+       struct tmc_drvdata *drvdata;
+       struct resource *res = &adev->res;
+       struct coresight_desc desc = { 0 };
+       struct coresight_dev_list *dev_list = NULL;
+
+       ret = -ENOMEM;
+       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+       if (!drvdata)
+               goto out;
+
+       dev_set_drvdata(dev, drvdata);
+
+       /* Validity for the resource is already checked by the AMBA core */
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base)) {
+               ret = PTR_ERR(base);
+               goto out;
+       }
+
+       drvdata->base = base;
+
+       spin_lock_init(&drvdata->spinlock);
+
+       devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
+       drvdata->config_type = BMVAL(devid, 6, 7);
+       drvdata->memwidth = tmc_get_memwidth(devid);
+       /* This device is not associated with a session */
+       drvdata->pid = -1;
+
+       if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
+               drvdata->size = tmc_etr_get_default_buffer_size(dev);
+       else
+               drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
+
+       desc.dev = dev;
+       desc.groups = coresight_tmc_groups;
+
+       switch (drvdata->config_type) {
+       case TMC_CONFIG_TYPE_ETB:
+               desc.type = CORESIGHT_DEV_TYPE_SINK;
+               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
+               desc.ops = &tmc_etb_cs_ops;
+               dev_list = &etb_devs;
+               break;
+       case TMC_CONFIG_TYPE_ETR:
+               desc.type = CORESIGHT_DEV_TYPE_SINK;
+               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
+               desc.ops = &tmc_etr_cs_ops;
+               ret = tmc_etr_setup_caps(dev, devid,
+                                        coresight_get_uci_data(id));
+               if (ret)
+                       goto out;
+               idr_init(&drvdata->idr);
+               mutex_init(&drvdata->idr_mutex);
+               dev_list = &etr_devs;
+               break;
+       case TMC_CONFIG_TYPE_ETF:
+               desc.type = CORESIGHT_DEV_TYPE_LINKSINK;
+               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
+               desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
+               desc.ops = &tmc_etf_cs_ops;
+               dev_list = &etf_devs;
+               break;
+       default:
+               pr_err("%s: Unsupported TMC config\n", desc.name);
+               ret = -EINVAL;
+               goto out;
+       }
+
+       desc.name = coresight_alloc_device_name(dev_list, dev);
+       if (!desc.name) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       pdata = coresight_get_platform_data(dev);
+       if (IS_ERR(pdata)) {
+               ret = PTR_ERR(pdata);
+               goto out;
+       }
+       adev->dev.platform_data = pdata;
+       desc.pdata = pdata;
+
+       drvdata->csdev = coresight_register(&desc);
+       if (IS_ERR(drvdata->csdev)) {
+               ret = PTR_ERR(drvdata->csdev);
+               goto out;
+       }
+
+       drvdata->miscdev.name = desc.name;
+       drvdata->miscdev.minor = MISC_DYNAMIC_MINOR;
+       drvdata->miscdev.fops = &tmc_fops;
+       ret = misc_register(&drvdata->miscdev);
+       if (ret)
+               coresight_unregister(drvdata->csdev);
+       else
+               pm_runtime_put(&adev->dev);
+out:
+       return ret;
+}
+
+static void tmc_shutdown(struct amba_device *adev)
+{
+       unsigned long flags;
+       struct tmc_drvdata *drvdata = amba_get_drvdata(adev);
+
+       spin_lock_irqsave(&drvdata->spinlock, flags);
+
+       if (drvdata->mode == CS_MODE_DISABLED)
+               goto out;
+
+       if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
+               tmc_etr_disable_hw(drvdata);
+
+       /*
+        * We do not care about coresight unregister here unlike remove
+        * callback which is required for making coresight modular since
+        * the system is going down after this.
+        */
+out:
+       spin_unlock_irqrestore(&drvdata->spinlock, flags);
+}
+
+static int __exit tmc_remove(struct amba_device *adev)
+{
+       struct tmc_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       /*
+        * Since misc_open() holds a refcount on the f_ops, which is
+        * etb fops in this case, device is there until last file
+        * handler to this device is closed.
+        */
+       misc_deregister(&drvdata->miscdev);
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
+static const struct amba_id tmc_ids[] = {
+       CS_AMBA_ID(0x000bb961),
+       /* Coresight SoC 600 TMC-ETR/ETS */
+       CS_AMBA_ID_DATA(0x000bb9e8, (unsigned long)CORESIGHT_SOC_600_ETR_CAPS),
+       /* Coresight SoC 600 TMC-ETB */
+       CS_AMBA_ID(0x000bb9e9),
+       /* Coresight SoC 600 TMC-ETF */
+       CS_AMBA_ID(0x000bb9ea),
+       { 0, 0},
+};
+
+MODULE_DEVICE_TABLE(amba, tmc_ids);
+
+static struct amba_driver tmc_driver = {
+       .drv = {
+               .name   = "coresight-tmc",
+               .owner  = THIS_MODULE,
+               .suppress_bind_attrs = true,
+       },
+       .probe          = tmc_probe,
+       .shutdown       = tmc_shutdown,
+       .remove         = tmc_remove,
+       .id_table       = tmc_ids,
+};
+
+module_amba_driver(tmc_driver);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_DESCRIPTION("Arm CoreSight Trace Memory Controller driver");
+MODULE_LICENSE("GPL v2");
index 6375504..44402d4 100644 (file)
@@ -519,7 +519,7 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,
 
        cur = buf->cur;
        offset = buf->offset;
-       barrier = barrier_pkt;
+       barrier = coresight_barrier_pkt;
 
        /* for every byte to read */
        for (i = 0; i < to_read; i += 4) {
index b29c2db..714f9e8 100644 (file)
@@ -255,6 +255,7 @@ void tmc_free_sg_table(struct tmc_sg_table *sg_table)
        tmc_free_table_pages(sg_table);
        tmc_free_data_pages(sg_table);
 }
+EXPORT_SYMBOL_GPL(tmc_free_sg_table);
 
 /*
  * Alloc pages for the table. Since this will be used by the device,
@@ -340,6 +341,7 @@ struct tmc_sg_table *tmc_alloc_sg_table(struct device *dev,
 
        return sg_table;
 }
+EXPORT_SYMBOL_GPL(tmc_alloc_sg_table);
 
 /*
  * tmc_sg_table_sync_data_range: Sync the data buffer written
@@ -360,6 +362,7 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table,
                                        PAGE_SIZE, DMA_FROM_DEVICE);
        }
 }
+EXPORT_SYMBOL_GPL(tmc_sg_table_sync_data_range);
 
 /* tmc_sg_sync_table: Sync the page table */
 void tmc_sg_table_sync_table(struct tmc_sg_table *sg_table)
@@ -372,6 +375,7 @@ void tmc_sg_table_sync_table(struct tmc_sg_table *sg_table)
                dma_sync_single_for_device(real_dev, table_pages->daddrs[i],
                                           PAGE_SIZE, DMA_TO_DEVICE);
 }
+EXPORT_SYMBOL_GPL(tmc_sg_table_sync_table);
 
 /*
  * tmc_sg_table_get_data: Get the buffer pointer for data @offset
@@ -401,6 +405,7 @@ ssize_t tmc_sg_table_get_data(struct tmc_sg_table *sg_table,
                *bufpp = page_address(data_pages->pages[pg_idx]) + pg_offset;
        return len;
 }
+EXPORT_SYMBOL_GPL(tmc_sg_table_get_data);
 
 #ifdef ETR_SG_DEBUG
 /* Map a dma address to virtual address */
@@ -766,6 +771,7 @@ tmc_etr_get_catu_device(struct tmc_drvdata *drvdata)
 
        return NULL;
 }
+EXPORT_SYMBOL_GPL(tmc_etr_get_catu_device);
 
 static inline int tmc_etr_enable_catu(struct tmc_drvdata *drvdata,
                                      struct etr_buf *etr_buf)
@@ -788,10 +794,21 @@ static inline void tmc_etr_disable_catu(struct tmc_drvdata *drvdata)
 static const struct etr_buf_operations *etr_buf_ops[] = {
        [ETR_MODE_FLAT] = &etr_flat_buf_ops,
        [ETR_MODE_ETR_SG] = &etr_sg_buf_ops,
-       [ETR_MODE_CATU] = IS_ENABLED(CONFIG_CORESIGHT_CATU)
-                                               ? &etr_catu_buf_ops : NULL,
+       [ETR_MODE_CATU] = NULL,
 };
 
+void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu)
+{
+       etr_buf_ops[ETR_MODE_CATU] = catu;
+}
+EXPORT_SYMBOL_GPL(tmc_etr_set_catu_ops);
+
+void tmc_etr_remove_catu_ops(void)
+{
+       etr_buf_ops[ETR_MODE_CATU] = NULL;
+}
+EXPORT_SYMBOL_GPL(tmc_etr_remove_catu_ops);
+
 static inline int tmc_etr_mode_alloc_buf(int mode,
                                         struct tmc_drvdata *drvdata,
                                         struct etr_buf *etr_buf, int node,
diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c
deleted file mode 100644 (file)
index 7040d58..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Description: CoreSight Trace Memory Controller driver
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/device.h>
-#include <linux/idr.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/property.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <linux/dma-mapping.h>
-#include <linux/spinlock.h>
-#include <linux/pm_runtime.h>
-#include <linux/of.h>
-#include <linux/coresight.h>
-#include <linux/amba/bus.h>
-
-#include "coresight-priv.h"
-#include "coresight-tmc.h"
-
-DEFINE_CORESIGHT_DEVLIST(etb_devs, "tmc_etb");
-DEFINE_CORESIGHT_DEVLIST(etf_devs, "tmc_etf");
-DEFINE_CORESIGHT_DEVLIST(etr_devs, "tmc_etr");
-
-void tmc_wait_for_tmcready(struct tmc_drvdata *drvdata)
-{
-       /* Ensure formatter, unformatter and hardware fifo are empty */
-       if (coresight_timeout(drvdata->base,
-                             TMC_STS, TMC_STS_TMCREADY_BIT, 1)) {
-               dev_err(&drvdata->csdev->dev,
-                       "timeout while waiting for TMC to be Ready\n");
-       }
-}
-
-void tmc_flush_and_stop(struct tmc_drvdata *drvdata)
-{
-       u32 ffcr;
-
-       ffcr = readl_relaxed(drvdata->base + TMC_FFCR);
-       ffcr |= TMC_FFCR_STOP_ON_FLUSH;
-       writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
-       ffcr |= BIT(TMC_FFCR_FLUSHMAN_BIT);
-       writel_relaxed(ffcr, drvdata->base + TMC_FFCR);
-       /* Ensure flush completes */
-       if (coresight_timeout(drvdata->base,
-                             TMC_FFCR, TMC_FFCR_FLUSHMAN_BIT, 0)) {
-               dev_err(&drvdata->csdev->dev,
-               "timeout while waiting for completion of Manual Flush\n");
-       }
-
-       tmc_wait_for_tmcready(drvdata);
-}
-
-void tmc_enable_hw(struct tmc_drvdata *drvdata)
-{
-       writel_relaxed(TMC_CTL_CAPT_EN, drvdata->base + TMC_CTL);
-}
-
-void tmc_disable_hw(struct tmc_drvdata *drvdata)
-{
-       writel_relaxed(0x0, drvdata->base + TMC_CTL);
-}
-
-u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)
-{
-       u32 mask = 0;
-
-       /*
-        * When moving RRP or an offset address forward, the new values must
-        * be byte-address aligned to the width of the trace memory databus
-        * _and_ to a frame boundary (16 byte), whichever is the biggest. For
-        * example, for 32-bit, 64-bit and 128-bit wide trace memory, the four
-        * LSBs must be 0s. For 256-bit wide trace memory, the five LSBs must
-        * be 0s.
-        */
-       switch (drvdata->memwidth) {
-       case TMC_MEM_INTF_WIDTH_32BITS:
-       /* fallthrough */
-       case TMC_MEM_INTF_WIDTH_64BITS:
-       /* fallthrough */
-       case TMC_MEM_INTF_WIDTH_128BITS:
-               mask = GENMASK(31, 4);
-               break;
-       case TMC_MEM_INTF_WIDTH_256BITS:
-               mask = GENMASK(31, 5);
-               break;
-       }
-
-       return mask;
-}
-
-static int tmc_read_prepare(struct tmc_drvdata *drvdata)
-{
-       int ret = 0;
-
-       switch (drvdata->config_type) {
-       case TMC_CONFIG_TYPE_ETB:
-       case TMC_CONFIG_TYPE_ETF:
-               ret = tmc_read_prepare_etb(drvdata);
-               break;
-       case TMC_CONFIG_TYPE_ETR:
-               ret = tmc_read_prepare_etr(drvdata);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       if (!ret)
-               dev_dbg(&drvdata->csdev->dev, "TMC read start\n");
-
-       return ret;
-}
-
-static int tmc_read_unprepare(struct tmc_drvdata *drvdata)
-{
-       int ret = 0;
-
-       switch (drvdata->config_type) {
-       case TMC_CONFIG_TYPE_ETB:
-       case TMC_CONFIG_TYPE_ETF:
-               ret = tmc_read_unprepare_etb(drvdata);
-               break;
-       case TMC_CONFIG_TYPE_ETR:
-               ret = tmc_read_unprepare_etr(drvdata);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-
-       if (!ret)
-               dev_dbg(&drvdata->csdev->dev, "TMC read end\n");
-
-       return ret;
-}
-
-static int tmc_open(struct inode *inode, struct file *file)
-{
-       int ret;
-       struct tmc_drvdata *drvdata = container_of(file->private_data,
-                                                  struct tmc_drvdata, miscdev);
-
-       ret = tmc_read_prepare(drvdata);
-       if (ret)
-               return ret;
-
-       nonseekable_open(inode, file);
-
-       dev_dbg(&drvdata->csdev->dev, "%s: successfully opened\n", __func__);
-       return 0;
-}
-
-static inline ssize_t tmc_get_sysfs_trace(struct tmc_drvdata *drvdata,
-                                         loff_t pos, size_t len, char **bufpp)
-{
-       switch (drvdata->config_type) {
-       case TMC_CONFIG_TYPE_ETB:
-       case TMC_CONFIG_TYPE_ETF:
-               return tmc_etb_get_sysfs_trace(drvdata, pos, len, bufpp);
-       case TMC_CONFIG_TYPE_ETR:
-               return tmc_etr_get_sysfs_trace(drvdata, pos, len, bufpp);
-       }
-
-       return -EINVAL;
-}
-
-static ssize_t tmc_read(struct file *file, char __user *data, size_t len,
-                       loff_t *ppos)
-{
-       char *bufp;
-       ssize_t actual;
-       struct tmc_drvdata *drvdata = container_of(file->private_data,
-                                                  struct tmc_drvdata, miscdev);
-       actual = tmc_get_sysfs_trace(drvdata, *ppos, len, &bufp);
-       if (actual <= 0)
-               return 0;
-
-       if (copy_to_user(data, bufp, actual)) {
-               dev_dbg(&drvdata->csdev->dev,
-                       "%s: copy_to_user failed\n", __func__);
-               return -EFAULT;
-       }
-
-       *ppos += actual;
-       dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual);
-
-       return actual;
-}
-
-static int tmc_release(struct inode *inode, struct file *file)
-{
-       int ret;
-       struct tmc_drvdata *drvdata = container_of(file->private_data,
-                                                  struct tmc_drvdata, miscdev);
-
-       ret = tmc_read_unprepare(drvdata);
-       if (ret)
-               return ret;
-
-       dev_dbg(&drvdata->csdev->dev, "%s: released\n", __func__);
-       return 0;
-}
-
-static const struct file_operations tmc_fops = {
-       .owner          = THIS_MODULE,
-       .open           = tmc_open,
-       .read           = tmc_read,
-       .release        = tmc_release,
-       .llseek         = no_llseek,
-};
-
-static enum tmc_mem_intf_width tmc_get_memwidth(u32 devid)
-{
-       enum tmc_mem_intf_width memwidth;
-
-       /*
-        * Excerpt from the TRM:
-        *
-        * DEVID::MEMWIDTH[10:8]
-        * 0x2 Memory interface databus is 32 bits wide.
-        * 0x3 Memory interface databus is 64 bits wide.
-        * 0x4 Memory interface databus is 128 bits wide.
-        * 0x5 Memory interface databus is 256 bits wide.
-        */
-       switch (BMVAL(devid, 8, 10)) {
-       case 0x2:
-               memwidth = TMC_MEM_INTF_WIDTH_32BITS;
-               break;
-       case 0x3:
-               memwidth = TMC_MEM_INTF_WIDTH_64BITS;
-               break;
-       case 0x4:
-               memwidth = TMC_MEM_INTF_WIDTH_128BITS;
-               break;
-       case 0x5:
-               memwidth = TMC_MEM_INTF_WIDTH_256BITS;
-               break;
-       default:
-               memwidth = 0;
-       }
-
-       return memwidth;
-}
-
-#define coresight_tmc_reg(name, offset)                        \
-       coresight_simple_reg32(struct tmc_drvdata, name, offset)
-#define coresight_tmc_reg64(name, lo_off, hi_off)      \
-       coresight_simple_reg64(struct tmc_drvdata, name, lo_off, hi_off)
-
-coresight_tmc_reg(rsz, TMC_RSZ);
-coresight_tmc_reg(sts, TMC_STS);
-coresight_tmc_reg(trg, TMC_TRG);
-coresight_tmc_reg(ctl, TMC_CTL);
-coresight_tmc_reg(ffsr, TMC_FFSR);
-coresight_tmc_reg(ffcr, TMC_FFCR);
-coresight_tmc_reg(mode, TMC_MODE);
-coresight_tmc_reg(pscr, TMC_PSCR);
-coresight_tmc_reg(axictl, TMC_AXICTL);
-coresight_tmc_reg(authstatus, TMC_AUTHSTATUS);
-coresight_tmc_reg(devid, CORESIGHT_DEVID);
-coresight_tmc_reg64(rrp, TMC_RRP, TMC_RRPHI);
-coresight_tmc_reg64(rwp, TMC_RWP, TMC_RWPHI);
-coresight_tmc_reg64(dba, TMC_DBALO, TMC_DBAHI);
-
-static struct attribute *coresight_tmc_mgmt_attrs[] = {
-       &dev_attr_rsz.attr,
-       &dev_attr_sts.attr,
-       &dev_attr_rrp.attr,
-       &dev_attr_rwp.attr,
-       &dev_attr_trg.attr,
-       &dev_attr_ctl.attr,
-       &dev_attr_ffsr.attr,
-       &dev_attr_ffcr.attr,
-       &dev_attr_mode.attr,
-       &dev_attr_pscr.attr,
-       &dev_attr_devid.attr,
-       &dev_attr_dba.attr,
-       &dev_attr_axictl.attr,
-       &dev_attr_authstatus.attr,
-       NULL,
-};
-
-static ssize_t trigger_cntr_show(struct device *dev,
-                                struct device_attribute *attr, char *buf)
-{
-       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
-       unsigned long val = drvdata->trigger_cntr;
-
-       return sprintf(buf, "%#lx\n", val);
-}
-
-static ssize_t trigger_cntr_store(struct device *dev,
-                            struct device_attribute *attr,
-                            const char *buf, size_t size)
-{
-       int ret;
-       unsigned long val;
-       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
-
-       ret = kstrtoul(buf, 16, &val);
-       if (ret)
-               return ret;
-
-       drvdata->trigger_cntr = val;
-       return size;
-}
-static DEVICE_ATTR_RW(trigger_cntr);
-
-static ssize_t buffer_size_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
-{
-       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
-
-       return sprintf(buf, "%#x\n", drvdata->size);
-}
-
-static ssize_t buffer_size_store(struct device *dev,
-                                struct device_attribute *attr,
-                                const char *buf, size_t size)
-{
-       int ret;
-       unsigned long val;
-       struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent);
-
-       /* Only permitted for TMC-ETRs */
-       if (drvdata->config_type != TMC_CONFIG_TYPE_ETR)
-               return -EPERM;
-
-       ret = kstrtoul(buf, 0, &val);
-       if (ret)
-               return ret;
-       /* The buffer size should be page aligned */
-       if (val & (PAGE_SIZE - 1))
-               return -EINVAL;
-       drvdata->size = val;
-       return size;
-}
-
-static DEVICE_ATTR_RW(buffer_size);
-
-static struct attribute *coresight_tmc_attrs[] = {
-       &dev_attr_trigger_cntr.attr,
-       &dev_attr_buffer_size.attr,
-       NULL,
-};
-
-static const struct attribute_group coresight_tmc_group = {
-       .attrs = coresight_tmc_attrs,
-};
-
-static const struct attribute_group coresight_tmc_mgmt_group = {
-       .attrs = coresight_tmc_mgmt_attrs,
-       .name = "mgmt",
-};
-
-static const struct attribute_group *coresight_tmc_groups[] = {
-       &coresight_tmc_group,
-       &coresight_tmc_mgmt_group,
-       NULL,
-};
-
-static inline bool tmc_etr_can_use_sg(struct device *dev)
-{
-       return fwnode_property_present(dev->fwnode, "arm,scatter-gather");
-}
-
-static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)
-{
-       u32 auth = readl_relaxed(drvdata->base + TMC_AUTHSTATUS);
-
-       return (auth & TMC_AUTH_NSID_MASK) == 0x3;
-}
-
-/* Detect and initialise the capabilities of a TMC ETR */
-static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps)
-{
-       int rc;
-       u32 dma_mask = 0;
-       struct tmc_drvdata *drvdata = dev_get_drvdata(parent);
-
-       if (!tmc_etr_has_non_secure_access(drvdata))
-               return -EACCES;
-
-       /* Set the unadvertised capabilities */
-       tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps);
-
-       if (!(devid & TMC_DEVID_NOSCAT) && tmc_etr_can_use_sg(parent))
-               tmc_etr_set_cap(drvdata, TMC_ETR_SG);
-
-       /* Check if the AXI address width is available */
-       if (devid & TMC_DEVID_AXIAW_VALID)
-               dma_mask = ((devid >> TMC_DEVID_AXIAW_SHIFT) &
-                               TMC_DEVID_AXIAW_MASK);
-
-       /*
-        * Unless specified in the device configuration, ETR uses a 40-bit
-        * AXI master in place of the embedded SRAM of ETB/ETF.
-        */
-       switch (dma_mask) {
-       case 32:
-       case 40:
-       case 44:
-       case 48:
-       case 52:
-               dev_info(parent, "Detected dma mask %dbits\n", dma_mask);
-               break;
-       default:
-               dma_mask = 40;
-       }
-
-       rc = dma_set_mask_and_coherent(parent, DMA_BIT_MASK(dma_mask));
-       if (rc)
-               dev_err(parent, "Failed to setup DMA mask: %d\n", rc);
-       return rc;
-}
-
-static u32 tmc_etr_get_default_buffer_size(struct device *dev)
-{
-       u32 size;
-
-       if (fwnode_property_read_u32(dev->fwnode, "arm,buffer-size", &size))
-               size = SZ_1M;
-       return size;
-}
-
-static int tmc_probe(struct amba_device *adev, const struct amba_id *id)
-{
-       int ret = 0;
-       u32 devid;
-       void __iomem *base;
-       struct device *dev = &adev->dev;
-       struct coresight_platform_data *pdata = NULL;
-       struct tmc_drvdata *drvdata;
-       struct resource *res = &adev->res;
-       struct coresight_desc desc = { 0 };
-       struct coresight_dev_list *dev_list = NULL;
-
-       ret = -ENOMEM;
-       drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
-       if (!drvdata)
-               goto out;
-
-       dev_set_drvdata(dev, drvdata);
-
-       /* Validity for the resource is already checked by the AMBA core */
-       base = devm_ioremap_resource(dev, res);
-       if (IS_ERR(base)) {
-               ret = PTR_ERR(base);
-               goto out;
-       }
-
-       drvdata->base = base;
-
-       spin_lock_init(&drvdata->spinlock);
-
-       devid = readl_relaxed(drvdata->base + CORESIGHT_DEVID);
-       drvdata->config_type = BMVAL(devid, 6, 7);
-       drvdata->memwidth = tmc_get_memwidth(devid);
-       /* This device is not associated with a session */
-       drvdata->pid = -1;
-
-       if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
-               drvdata->size = tmc_etr_get_default_buffer_size(dev);
-       else
-               drvdata->size = readl_relaxed(drvdata->base + TMC_RSZ) * 4;
-
-       desc.dev = dev;
-       desc.groups = coresight_tmc_groups;
-
-       switch (drvdata->config_type) {
-       case TMC_CONFIG_TYPE_ETB:
-               desc.type = CORESIGHT_DEV_TYPE_SINK;
-               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
-               desc.ops = &tmc_etb_cs_ops;
-               dev_list = &etb_devs;
-               break;
-       case TMC_CONFIG_TYPE_ETR:
-               desc.type = CORESIGHT_DEV_TYPE_SINK;
-               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
-               desc.ops = &tmc_etr_cs_ops;
-               ret = tmc_etr_setup_caps(dev, devid,
-                                        coresight_get_uci_data(id));
-               if (ret)
-                       goto out;
-               idr_init(&drvdata->idr);
-               mutex_init(&drvdata->idr_mutex);
-               dev_list = &etr_devs;
-               break;
-       case TMC_CONFIG_TYPE_ETF:
-               desc.type = CORESIGHT_DEV_TYPE_LINKSINK;
-               desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_BUFFER;
-               desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_FIFO;
-               desc.ops = &tmc_etf_cs_ops;
-               dev_list = &etf_devs;
-               break;
-       default:
-               pr_err("%s: Unsupported TMC config\n", desc.name);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       desc.name = coresight_alloc_device_name(dev_list, dev);
-       if (!desc.name) {
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       pdata = coresight_get_platform_data(dev);
-       if (IS_ERR(pdata)) {
-               ret = PTR_ERR(pdata);
-               goto out;
-       }
-       adev->dev.platform_data = pdata;
-       desc.pdata = pdata;
-
-       drvdata->csdev = coresight_register(&desc);
-       if (IS_ERR(drvdata->csdev)) {
-               ret = PTR_ERR(drvdata->csdev);
-               goto out;
-       }
-
-       drvdata->miscdev.name = desc.name;
-       drvdata->miscdev.minor = MISC_DYNAMIC_MINOR;
-       drvdata->miscdev.fops = &tmc_fops;
-       ret = misc_register(&drvdata->miscdev);
-       if (ret)
-               coresight_unregister(drvdata->csdev);
-       else
-               pm_runtime_put(&adev->dev);
-out:
-       return ret;
-}
-
-static void tmc_shutdown(struct amba_device *adev)
-{
-       unsigned long flags;
-       struct tmc_drvdata *drvdata = amba_get_drvdata(adev);
-
-       spin_lock_irqsave(&drvdata->spinlock, flags);
-
-       if (drvdata->mode == CS_MODE_DISABLED)
-               goto out;
-
-       if (drvdata->config_type == TMC_CONFIG_TYPE_ETR)
-               tmc_etr_disable_hw(drvdata);
-
-       /*
-        * We do not care about coresight unregister here unlike remove
-        * callback which is required for making coresight modular since
-        * the system is going down after this.
-        */
-out:
-       spin_unlock_irqrestore(&drvdata->spinlock, flags);
-}
-
-static const struct amba_id tmc_ids[] = {
-       CS_AMBA_ID(0x000bb961),
-       /* Coresight SoC 600 TMC-ETR/ETS */
-       CS_AMBA_ID_DATA(0x000bb9e8, (unsigned long)CORESIGHT_SOC_600_ETR_CAPS),
-       /* Coresight SoC 600 TMC-ETB */
-       CS_AMBA_ID(0x000bb9e9),
-       /* Coresight SoC 600 TMC-ETF */
-       CS_AMBA_ID(0x000bb9ea),
-       { 0, 0},
-};
-
-static struct amba_driver tmc_driver = {
-       .drv = {
-               .name   = "coresight-tmc",
-               .owner  = THIS_MODULE,
-               .suppress_bind_attrs = true,
-       },
-       .probe          = tmc_probe,
-       .shutdown       = tmc_shutdown,
-       .id_table       = tmc_ids,
-};
-builtin_amba_driver(tmc_driver);
index 6e8d2dc..b91ec7d 100644 (file)
@@ -326,4 +326,7 @@ tmc_sg_table_buf_size(struct tmc_sg_table *sg_table)
 
 struct coresight_device *tmc_etr_get_catu_device(struct tmc_drvdata *drvdata);
 
+void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu);
+void tmc_etr_remove_catu_ops(void);
+
 #endif
index f8583e4..566c57e 100644 (file)
@@ -173,6 +173,15 @@ static int tpiu_probe(struct amba_device *adev, const struct amba_id *id)
        return PTR_ERR(drvdata->csdev);
 }
 
+static int __exit tpiu_remove(struct amba_device *adev)
+{
+       struct tpiu_drvdata *drvdata = dev_get_drvdata(&adev->dev);
+
+       coresight_unregister(drvdata->csdev);
+
+       return 0;
+}
+
 #ifdef CONFIG_PM
 static int tpiu_runtime_suspend(struct device *dev)
 {
@@ -216,6 +225,8 @@ static const struct amba_id tpiu_ids[] = {
        { 0, 0},
 };
 
+MODULE_DEVICE_TABLE(amba, tpiu_ids);
+
 static struct amba_driver tpiu_driver = {
        .drv = {
                .name   = "coresight-tpiu",
@@ -224,6 +235,13 @@ static struct amba_driver tpiu_driver = {
                .suppress_bind_attrs = true,
        },
        .probe          = tpiu_probe,
+       .remove         = tpiu_remove,
        .id_table       = tpiu_ids,
 };
-builtin_amba_driver(tpiu_driver);
+
+module_amba_driver(tpiu_driver);
+
+MODULE_AUTHOR("Pratik Patel <pratikp@codeaurora.org>");
+MODULE_AUTHOR("Mathieu Poirier <mathieu.poirier@linaro.org>");
+MODULE_DESCRIPTION("Arm CoreSight TPIU (Trace Port Interface Unit) driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
deleted file mode 100644 (file)
index e9c90f2..0000000
+++ /dev/null
@@ -1,1594 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- */
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/export.h>
-#include <linux/slab.h>
-#include <linux/stringhash.h>
-#include <linux/mutex.h>
-#include <linux/clk.h>
-#include <linux/coresight.h>
-#include <linux/of_platform.h>
-#include <linux/delay.h>
-#include <linux/pm_runtime.h>
-
-#include "coresight-etm-perf.h"
-#include "coresight-priv.h"
-
-static DEFINE_MUTEX(coresight_mutex);
-
-/**
- * struct coresight_node - elements of a path, from source to sink
- * @csdev:     Address of an element.
- * @link:      hook to the list.
- */
-struct coresight_node {
-       struct coresight_device *csdev;
-       struct list_head link;
-};
-
-/*
- * When operating Coresight drivers from the sysFS interface, only a single
- * path can exist from a tracer (associated to a CPU) to a sink.
- */
-static DEFINE_PER_CPU(struct list_head *, tracer_path);
-
-/*
- * As of this writing only a single STM can be found in CS topologies.  Since
- * there is no way to know if we'll ever see more and what kind of
- * configuration they will enact, for the time being only define a single path
- * for STM.
- */
-static struct list_head *stm_path;
-
-/*
- * When losing synchronisation a new barrier packet needs to be inserted at the
- * beginning of the data collected in a buffer.  That way the decoder knows that
- * it needs to look for another sync sequence.
- */
-const u32 barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
-
-static int coresight_id_match(struct device *dev, void *data)
-{
-       int trace_id, i_trace_id;
-       struct coresight_device *csdev, *i_csdev;
-
-       csdev = data;
-       i_csdev = to_coresight_device(dev);
-
-       /*
-        * No need to care about oneself and components that are not
-        * sources or not enabled
-        */
-       if (i_csdev == csdev || !i_csdev->enable ||
-           i_csdev->type != CORESIGHT_DEV_TYPE_SOURCE)
-               return 0;
-
-       /* Get the source ID for both compoment */
-       trace_id = source_ops(csdev)->trace_id(csdev);
-       i_trace_id = source_ops(i_csdev)->trace_id(i_csdev);
-
-       /* All you need is one */
-       if (trace_id == i_trace_id)
-               return 1;
-
-       return 0;
-}
-
-static int coresight_source_is_unique(struct coresight_device *csdev)
-{
-       int trace_id = source_ops(csdev)->trace_id(csdev);
-
-       /* this shouldn't happen */
-       if (trace_id < 0)
-               return 0;
-
-       return !bus_for_each_dev(&coresight_bustype, NULL,
-                                csdev, coresight_id_match);
-}
-
-static int coresight_find_link_inport(struct coresight_device *csdev,
-                                     struct coresight_device *parent)
-{
-       int i;
-       struct coresight_connection *conn;
-
-       for (i = 0; i < parent->pdata->nr_outport; i++) {
-               conn = &parent->pdata->conns[i];
-               if (conn->child_dev == csdev)
-                       return conn->child_port;
-       }
-
-       dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n",
-               dev_name(&parent->dev), dev_name(&csdev->dev));
-
-       return -ENODEV;
-}
-
-static int coresight_find_link_outport(struct coresight_device *csdev,
-                                      struct coresight_device *child)
-{
-       int i;
-       struct coresight_connection *conn;
-
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               conn = &csdev->pdata->conns[i];
-               if (conn->child_dev == child)
-                       return conn->outport;
-       }
-
-       dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n",
-               dev_name(&csdev->dev), dev_name(&child->dev));
-
-       return -ENODEV;
-}
-
-static inline u32 coresight_read_claim_tags(void __iomem *base)
-{
-       return readl_relaxed(base + CORESIGHT_CLAIMCLR);
-}
-
-static inline bool coresight_is_claimed_self_hosted(void __iomem *base)
-{
-       return coresight_read_claim_tags(base) == CORESIGHT_CLAIM_SELF_HOSTED;
-}
-
-static inline bool coresight_is_claimed_any(void __iomem *base)
-{
-       return coresight_read_claim_tags(base) != 0;
-}
-
-static inline void coresight_set_claim_tags(void __iomem *base)
-{
-       writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMSET);
-       isb();
-}
-
-static inline void coresight_clear_claim_tags(void __iomem *base)
-{
-       writel_relaxed(CORESIGHT_CLAIM_SELF_HOSTED, base + CORESIGHT_CLAIMCLR);
-       isb();
-}
-
-/*
- * coresight_claim_device_unlocked : Claim the device for self-hosted usage
- * to prevent an external tool from touching this device. As per PSCI
- * standards, section "Preserving the execution context" => "Debug and Trace
- * save and Restore", DBGCLAIM[1] is reserved for Self-hosted debug/trace and
- * DBGCLAIM[0] is reserved for external tools.
- *
- * Called with CS_UNLOCKed for the component.
- * Returns : 0 on success
- */
-int coresight_claim_device_unlocked(void __iomem *base)
-{
-       if (coresight_is_claimed_any(base))
-               return -EBUSY;
-
-       coresight_set_claim_tags(base);
-       if (coresight_is_claimed_self_hosted(base))
-               return 0;
-       /* There was a race setting the tags, clean up and fail */
-       coresight_clear_claim_tags(base);
-       return -EBUSY;
-}
-
-int coresight_claim_device(void __iomem *base)
-{
-       int rc;
-
-       CS_UNLOCK(base);
-       rc = coresight_claim_device_unlocked(base);
-       CS_LOCK(base);
-
-       return rc;
-}
-
-/*
- * coresight_disclaim_device_unlocked : Clear the claim tags for the device.
- * Called with CS_UNLOCKed for the component.
- */
-void coresight_disclaim_device_unlocked(void __iomem *base)
-{
-
-       if (coresight_is_claimed_self_hosted(base))
-               coresight_clear_claim_tags(base);
-       else
-               /*
-                * The external agent may have not honoured our claim
-                * and has manipulated it. Or something else has seriously
-                * gone wrong in our driver.
-                */
-               WARN_ON_ONCE(1);
-}
-
-void coresight_disclaim_device(void __iomem *base)
-{
-       CS_UNLOCK(base);
-       coresight_disclaim_device_unlocked(base);
-       CS_LOCK(base);
-}
-
-/* enable or disable an associated CTI device of the supplied CS device */
-static int
-coresight_control_assoc_ectdev(struct coresight_device *csdev, bool enable)
-{
-       int ect_ret = 0;
-       struct coresight_device *ect_csdev = csdev->ect_dev;
-
-       if (!ect_csdev)
-               return 0;
-
-       if (enable) {
-               if (ect_ops(ect_csdev)->enable)
-                       ect_ret = ect_ops(ect_csdev)->enable(ect_csdev);
-       } else {
-               if (ect_ops(ect_csdev)->disable)
-                       ect_ret = ect_ops(ect_csdev)->disable(ect_csdev);
-       }
-
-       /* output warning if ECT enable is preventing trace operation */
-       if (ect_ret)
-               dev_info(&csdev->dev, "Associated ECT device (%s) %s failed\n",
-                        dev_name(&ect_csdev->dev),
-                        enable ? "enable" : "disable");
-       return ect_ret;
-}
-
-/*
- * Set the associated ect / cti device while holding the coresight_mutex
- * to avoid a race with coresight_enable that may try to use this value.
- */
-void coresight_set_assoc_ectdev_mutex(struct coresight_device *csdev,
-                                     struct coresight_device *ect_csdev)
-{
-       mutex_lock(&coresight_mutex);
-       csdev->ect_dev = ect_csdev;
-       mutex_unlock(&coresight_mutex);
-}
-
-static int coresight_enable_sink(struct coresight_device *csdev,
-                                u32 mode, void *data)
-{
-       int ret;
-
-       /*
-        * We need to make sure the "new" session is compatible with the
-        * existing "mode" of operation.
-        */
-       if (!sink_ops(csdev)->enable)
-               return -EINVAL;
-
-       ret = coresight_control_assoc_ectdev(csdev, true);
-       if (ret)
-               return ret;
-       ret = sink_ops(csdev)->enable(csdev, mode, data);
-       if (ret) {
-               coresight_control_assoc_ectdev(csdev, false);
-               return ret;
-       }
-       csdev->enable = true;
-
-       return 0;
-}
-
-static void coresight_disable_sink(struct coresight_device *csdev)
-{
-       int ret;
-
-       if (!sink_ops(csdev)->disable)
-               return;
-
-       ret = sink_ops(csdev)->disable(csdev);
-       if (ret)
-               return;
-       coresight_control_assoc_ectdev(csdev, false);
-       csdev->enable = false;
-}
-
-static int coresight_enable_link(struct coresight_device *csdev,
-                                struct coresight_device *parent,
-                                struct coresight_device *child)
-{
-       int ret = 0;
-       int link_subtype;
-       int inport, outport;
-
-       if (!parent || !child)
-               return -EINVAL;
-
-       inport = coresight_find_link_inport(csdev, parent);
-       outport = coresight_find_link_outport(csdev, child);
-       link_subtype = csdev->subtype.link_subtype;
-
-       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG && inport < 0)
-               return inport;
-       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT && outport < 0)
-               return outport;
-
-       if (link_ops(csdev)->enable) {
-               ret = coresight_control_assoc_ectdev(csdev, true);
-               if (!ret) {
-                       ret = link_ops(csdev)->enable(csdev, inport, outport);
-                       if (ret)
-                               coresight_control_assoc_ectdev(csdev, false);
-               }
-       }
-
-       if (!ret)
-               csdev->enable = true;
-
-       return ret;
-}
-
-static void coresight_disable_link(struct coresight_device *csdev,
-                                  struct coresight_device *parent,
-                                  struct coresight_device *child)
-{
-       int i, nr_conns;
-       int link_subtype;
-       int inport, outport;
-
-       if (!parent || !child)
-               return;
-
-       inport = coresight_find_link_inport(csdev, parent);
-       outport = coresight_find_link_outport(csdev, child);
-       link_subtype = csdev->subtype.link_subtype;
-
-       if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG) {
-               nr_conns = csdev->pdata->nr_inport;
-       } else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT) {
-               nr_conns = csdev->pdata->nr_outport;
-       } else {
-               nr_conns = 1;
-       }
-
-       if (link_ops(csdev)->disable) {
-               link_ops(csdev)->disable(csdev, inport, outport);
-               coresight_control_assoc_ectdev(csdev, false);
-       }
-
-       for (i = 0; i < nr_conns; i++)
-               if (atomic_read(&csdev->refcnt[i]) != 0)
-                       return;
-
-       csdev->enable = false;
-}
-
-static int coresight_enable_source(struct coresight_device *csdev, u32 mode)
-{
-       int ret;
-
-       if (!coresight_source_is_unique(csdev)) {
-               dev_warn(&csdev->dev, "traceID %d not unique\n",
-                        source_ops(csdev)->trace_id(csdev));
-               return -EINVAL;
-       }
-
-       if (!csdev->enable) {
-               if (source_ops(csdev)->enable) {
-                       ret = coresight_control_assoc_ectdev(csdev, true);
-                       if (ret)
-                               return ret;
-                       ret = source_ops(csdev)->enable(csdev, NULL, mode);
-                       if (ret) {
-                               coresight_control_assoc_ectdev(csdev, false);
-                               return ret;
-                       };
-               }
-               csdev->enable = true;
-       }
-
-       atomic_inc(csdev->refcnt);
-
-       return 0;
-}
-
-/**
- *  coresight_disable_source - Drop the reference count by 1 and disable
- *  the device if there are no users left.
- *
- *  @csdev - The coresight device to disable
- *
- *  Returns true if the device has been disabled.
- */
-static bool coresight_disable_source(struct coresight_device *csdev)
-{
-       if (atomic_dec_return(csdev->refcnt) == 0) {
-               if (source_ops(csdev)->disable)
-                       source_ops(csdev)->disable(csdev, NULL);
-               coresight_control_assoc_ectdev(csdev, false);
-               csdev->enable = false;
-       }
-       return !csdev->enable;
-}
-
-/*
- * coresight_disable_path_from : Disable components in the given path beyond
- * @nd in the list. If @nd is NULL, all the components, except the SOURCE are
- * disabled.
- */
-static void coresight_disable_path_from(struct list_head *path,
-                                       struct coresight_node *nd)
-{
-       u32 type;
-       struct coresight_device *csdev, *parent, *child;
-
-       if (!nd)
-               nd = list_first_entry(path, struct coresight_node, link);
-
-       list_for_each_entry_continue(nd, path, link) {
-               csdev = nd->csdev;
-               type = csdev->type;
-
-               /*
-                * ETF devices are tricky... They can be a link or a sink,
-                * depending on how they are configured.  If an ETF has been
-                * "activated" it will be configured as a sink, otherwise
-                * go ahead with the link configuration.
-                */
-               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
-                       type = (csdev == coresight_get_sink(path)) ?
-                                               CORESIGHT_DEV_TYPE_SINK :
-                                               CORESIGHT_DEV_TYPE_LINK;
-
-               switch (type) {
-               case CORESIGHT_DEV_TYPE_SINK:
-                       coresight_disable_sink(csdev);
-                       break;
-               case CORESIGHT_DEV_TYPE_SOURCE:
-                       /*
-                        * We skip the first node in the path assuming that it
-                        * is the source. So we don't expect a source device in
-                        * the middle of a path.
-                        */
-                       WARN_ON(1);
-                       break;
-               case CORESIGHT_DEV_TYPE_LINK:
-                       parent = list_prev_entry(nd, link)->csdev;
-                       child = list_next_entry(nd, link)->csdev;
-                       coresight_disable_link(csdev, parent, child);
-                       break;
-               default:
-                       break;
-               }
-       }
-}
-
-void coresight_disable_path(struct list_head *path)
-{
-       coresight_disable_path_from(path, NULL);
-}
-
-int coresight_enable_path(struct list_head *path, u32 mode, void *sink_data)
-{
-
-       int ret = 0;
-       u32 type;
-       struct coresight_node *nd;
-       struct coresight_device *csdev, *parent, *child;
-
-       list_for_each_entry_reverse(nd, path, link) {
-               csdev = nd->csdev;
-               type = csdev->type;
-
-               /*
-                * ETF devices are tricky... They can be a link or a sink,
-                * depending on how they are configured.  If an ETF has been
-                * "activated" it will be configured as a sink, otherwise
-                * go ahead with the link configuration.
-                */
-               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
-                       type = (csdev == coresight_get_sink(path)) ?
-                                               CORESIGHT_DEV_TYPE_SINK :
-                                               CORESIGHT_DEV_TYPE_LINK;
-
-               switch (type) {
-               case CORESIGHT_DEV_TYPE_SINK:
-                       ret = coresight_enable_sink(csdev, mode, sink_data);
-                       /*
-                        * Sink is the first component turned on. If we
-                        * failed to enable the sink, there are no components
-                        * that need disabling. Disabling the path here
-                        * would mean we could disrupt an existing session.
-                        */
-                       if (ret)
-                               goto out;
-                       break;
-               case CORESIGHT_DEV_TYPE_SOURCE:
-                       /* sources are enabled from either sysFS or Perf */
-                       break;
-               case CORESIGHT_DEV_TYPE_LINK:
-                       parent = list_prev_entry(nd, link)->csdev;
-                       child = list_next_entry(nd, link)->csdev;
-                       ret = coresight_enable_link(csdev, parent, child);
-                       if (ret)
-                               goto err;
-                       break;
-               default:
-                       goto err;
-               }
-       }
-
-out:
-       return ret;
-err:
-       coresight_disable_path_from(path, nd);
-       goto out;
-}
-
-struct coresight_device *coresight_get_sink(struct list_head *path)
-{
-       struct coresight_device *csdev;
-
-       if (!path)
-               return NULL;
-
-       csdev = list_last_entry(path, struct coresight_node, link)->csdev;
-       if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
-           csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
-               return NULL;
-
-       return csdev;
-}
-
-static int coresight_enabled_sink(struct device *dev, const void *data)
-{
-       const bool *reset = data;
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
-            csdev->activated) {
-               /*
-                * Now that we have a handle on the sink for this session,
-                * disable the sysFS "enable_sink" flag so that possible
-                * concurrent perf session that wish to use another sink don't
-                * trip on it.  Doing so has no ramification for the current
-                * session.
-                */
-               if (*reset)
-                       csdev->activated = false;
-
-               return 1;
-       }
-
-       return 0;
-}
-
-/**
- * coresight_get_enabled_sink - returns the first enabled sink found on the bus
- * @deactivate:        Whether the 'enable_sink' flag should be reset
- *
- * When operated from perf the deactivate parameter should be set to 'true'.
- * That way the "enabled_sink" flag of the sink that was selected can be reset,
- * allowing for other concurrent perf sessions to choose a different sink.
- *
- * When operated from sysFS users have full control and as such the deactivate
- * parameter should be set to 'false', hence mandating users to explicitly
- * clear the flag.
- */
-struct coresight_device *coresight_get_enabled_sink(bool deactivate)
-{
-       struct device *dev = NULL;
-
-       dev = bus_find_device(&coresight_bustype, NULL, &deactivate,
-                             coresight_enabled_sink);
-
-       return dev ? to_coresight_device(dev) : NULL;
-}
-
-static int coresight_sink_by_id(struct device *dev, const void *data)
-{
-       struct coresight_device *csdev = to_coresight_device(dev);
-       unsigned long hash;
-
-       if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
-
-               if (!csdev->ea)
-                       return 0;
-               /*
-                * See function etm_perf_add_symlink_sink() to know where
-                * this comes from.
-                */
-               hash = (unsigned long)csdev->ea->var;
-
-               if ((u32)hash == *(u32 *)data)
-                       return 1;
-       }
-
-       return 0;
-}
-
-/**
- * coresight_get_sink_by_id - returns the sink that matches the id
- * @id: Id of the sink to match
- *
- * The name of a sink is unique, whether it is found on the AMBA bus or
- * otherwise.  As such the hash of that name can easily be used to identify
- * a sink.
- */
-struct coresight_device *coresight_get_sink_by_id(u32 id)
-{
-       struct device *dev = NULL;
-
-       dev = bus_find_device(&coresight_bustype, NULL, &id,
-                             coresight_sink_by_id);
-
-       return dev ? to_coresight_device(dev) : NULL;
-}
-
-/*
- * coresight_grab_device - Power up this device and any of the helper
- * devices connected to it for trace operation. Since the helper devices
- * don't appear on the trace path, they should be handled along with the
- * the master device.
- */
-static void coresight_grab_device(struct coresight_device *csdev)
-{
-       int i;
-
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               struct coresight_device *child;
-
-               child  = csdev->pdata->conns[i].child_dev;
-               if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
-                       pm_runtime_get_sync(child->dev.parent);
-       }
-       pm_runtime_get_sync(csdev->dev.parent);
-}
-
-/*
- * coresight_drop_device - Release this device and any of the helper
- * devices connected to it.
- */
-static void coresight_drop_device(struct coresight_device *csdev)
-{
-       int i;
-
-       pm_runtime_put(csdev->dev.parent);
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               struct coresight_device *child;
-
-               child  = csdev->pdata->conns[i].child_dev;
-               if (child && child->type == CORESIGHT_DEV_TYPE_HELPER)
-                       pm_runtime_put(child->dev.parent);
-       }
-}
-
-/**
- * _coresight_build_path - recursively build a path from a @csdev to a sink.
- * @csdev:     The device to start from.
- * @path:      The list to add devices to.
- *
- * The tree of Coresight device is traversed until an activated sink is
- * found.  From there the sink is added to the list along with all the
- * devices that led to that point - the end result is a list from source
- * to sink. In that list the source is the first device and the sink the
- * last one.
- */
-static int _coresight_build_path(struct coresight_device *csdev,
-                                struct coresight_device *sink,
-                                struct list_head *path)
-{
-       int i;
-       bool found = false;
-       struct coresight_node *node;
-
-       /* An activated sink has been found.  Enqueue the element */
-       if (csdev == sink)
-               goto out;
-
-       /* Not a sink - recursively explore each port found on this element */
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               struct coresight_device *child_dev;
-
-               child_dev = csdev->pdata->conns[i].child_dev;
-               if (child_dev &&
-                   _coresight_build_path(child_dev, sink, path) == 0) {
-                       found = true;
-                       break;
-               }
-       }
-
-       if (!found)
-               return -ENODEV;
-
-out:
-       /*
-        * A path from this element to a sink has been found.  The elements
-        * leading to the sink are already enqueued, all that is left to do
-        * is tell the PM runtime core we need this element and add a node
-        * for it.
-        */
-       node = kzalloc(sizeof(struct coresight_node), GFP_KERNEL);
-       if (!node)
-               return -ENOMEM;
-
-       coresight_grab_device(csdev);
-       node->csdev = csdev;
-       list_add(&node->link, path);
-
-       return 0;
-}
-
-struct list_head *coresight_build_path(struct coresight_device *source,
-                                      struct coresight_device *sink)
-{
-       struct list_head *path;
-       int rc;
-
-       if (!sink)
-               return ERR_PTR(-EINVAL);
-
-       path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
-       if (!path)
-               return ERR_PTR(-ENOMEM);
-
-       INIT_LIST_HEAD(path);
-
-       rc = _coresight_build_path(source, sink, path);
-       if (rc) {
-               kfree(path);
-               return ERR_PTR(rc);
-       }
-
-       return path;
-}
-
-/**
- * coresight_release_path - release a previously built path.
- * @path:      the path to release.
- *
- * Go through all the elements of a path and 1) removed it from the list and
- * 2) free the memory allocated for each node.
- */
-void coresight_release_path(struct list_head *path)
-{
-       struct coresight_device *csdev;
-       struct coresight_node *nd, *next;
-
-       list_for_each_entry_safe(nd, next, path, link) {
-               csdev = nd->csdev;
-
-               coresight_drop_device(csdev);
-               list_del(&nd->link);
-               kfree(nd);
-       }
-
-       kfree(path);
-       path = NULL;
-}
-
-/* return true if the device is a suitable type for a default sink */
-static inline bool coresight_is_def_sink_type(struct coresight_device *csdev)
-{
-       /* sink & correct subtype */
-       if (((csdev->type == CORESIGHT_DEV_TYPE_SINK) ||
-            (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) &&
-           (csdev->subtype.sink_subtype >= CORESIGHT_DEV_SUBTYPE_SINK_BUFFER))
-               return true;
-       return false;
-}
-
-/**
- * coresight_select_best_sink - return the best sink for use as default from
- * the two provided.
- *
- * @sink:      current best sink.
- * @depth:      search depth where current sink was found.
- * @new_sink:  new sink for comparison with current sink.
- * @new_depth:  search depth where new sink was found.
- *
- * Sinks prioritised according to coresight_dev_subtype_sink, with only
- * subtypes CORESIGHT_DEV_SUBTYPE_SINK_BUFFER or higher being used.
- *
- * Where two sinks of equal priority are found, the sink closest to the
- * source is used (smallest search depth).
- *
- * return @new_sink & update @depth if better than @sink, else return @sink.
- */
-static struct coresight_device *
-coresight_select_best_sink(struct coresight_device *sink, int *depth,
-                          struct coresight_device *new_sink, int new_depth)
-{
-       bool update = false;
-
-       if (!sink) {
-               /* first found at this level */
-               update = true;
-       } else if (new_sink->subtype.sink_subtype >
-                  sink->subtype.sink_subtype) {
-               /* found better sink */
-               update = true;
-       } else if ((new_sink->subtype.sink_subtype ==
-                   sink->subtype.sink_subtype) &&
-                  (*depth > new_depth)) {
-               /* found same but closer sink */
-               update = true;
-       }
-
-       if (update)
-               *depth = new_depth;
-       return update ? new_sink : sink;
-}
-
-/**
- * coresight_find_sink - recursive function to walk trace connections from
- * source to find a suitable default sink.
- *
- * @csdev: source / current device to check.
- * @depth: [in] search depth of calling dev, [out] depth of found sink.
- *
- * This will walk the connection path from a source (ETM) till a suitable
- * sink is encountered and return that sink to the original caller.
- *
- * If current device is a plain sink return that & depth, otherwise recursively
- * call child connections looking for a sink. Select best possible using
- * coresight_select_best_sink.
- *
- * return best sink found, or NULL if not found at this node or child nodes.
- */
-static struct coresight_device *
-coresight_find_sink(struct coresight_device *csdev, int *depth)
-{
-       int i, curr_depth = *depth + 1, found_depth = 0;
-       struct coresight_device *found_sink = NULL;
-
-       if (coresight_is_def_sink_type(csdev)) {
-               found_depth = curr_depth;
-               found_sink = csdev;
-               if (csdev->type == CORESIGHT_DEV_TYPE_SINK)
-                       goto return_def_sink;
-               /* look past LINKSINK for something better */
-       }
-
-       /*
-        * Not a sink we want - or possible child sink may be better.
-        * recursively explore each port found on this element.
-        */
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               struct coresight_device *child_dev, *sink = NULL;
-               int child_depth = curr_depth;
-
-               child_dev = csdev->pdata->conns[i].child_dev;
-               if (child_dev)
-                       sink = coresight_find_sink(child_dev, &child_depth);
-
-               if (sink)
-                       found_sink = coresight_select_best_sink(found_sink,
-                                                               &found_depth,
-                                                               sink,
-                                                               child_depth);
-       }
-
-return_def_sink:
-       /* return found sink and depth */
-       if (found_sink)
-               *depth = found_depth;
-       return found_sink;
-}
-
-/**
- * coresight_find_default_sink: Find a sink suitable for use as a
- * default sink.
- *
- * @csdev: starting source to find a connected sink.
- *
- * Walks connections graph looking for a suitable sink to enable for the
- * supplied source. Uses CoreSight device subtypes and distance from source
- * to select the best sink.
- *
- * If a sink is found, then the default sink for this device is set and
- * will be automatically used in future.
- *
- * Used in cases where the CoreSight user (perf / sysfs) has not selected a
- * sink.
- */
-struct coresight_device *
-coresight_find_default_sink(struct coresight_device *csdev)
-{
-       int depth = 0;
-
-       /* look for a default sink if we have not found for this device */
-       if (!csdev->def_sink)
-               csdev->def_sink = coresight_find_sink(csdev, &depth);
-       return csdev->def_sink;
-}
-
-static int coresight_remove_sink_ref(struct device *dev, void *data)
-{
-       struct coresight_device *sink = data;
-       struct coresight_device *source = to_coresight_device(dev);
-
-       if (source->def_sink == sink)
-               source->def_sink = NULL;
-       return 0;
-}
-
-/**
- * coresight_clear_default_sink: Remove all default sink references to the
- * supplied sink.
- *
- * If supplied device is a sink, then check all the bus devices and clear
- * out all the references to this sink from the coresight_device def_sink
- * parameter.
- *
- * @csdev: coresight sink - remove references to this from all sources.
- */
-static void coresight_clear_default_sink(struct coresight_device *csdev)
-{
-       if ((csdev->type == CORESIGHT_DEV_TYPE_SINK) ||
-           (csdev->type == CORESIGHT_DEV_TYPE_LINKSINK)) {
-               bus_for_each_dev(&coresight_bustype, NULL, csdev,
-                                coresight_remove_sink_ref);
-       }
-}
-
-/** coresight_validate_source - make sure a source has the right credentials
- *  @csdev:    the device structure for a source.
- *  @function: the function this was called from.
- *
- * Assumes the coresight_mutex is held.
- */
-static int coresight_validate_source(struct coresight_device *csdev,
-                                    const char *function)
-{
-       u32 type, subtype;
-
-       type = csdev->type;
-       subtype = csdev->subtype.source_subtype;
-
-       if (type != CORESIGHT_DEV_TYPE_SOURCE) {
-               dev_err(&csdev->dev, "wrong device type in %s\n", function);
-               return -EINVAL;
-       }
-
-       if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC &&
-           subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) {
-               dev_err(&csdev->dev, "wrong device subtype in %s\n", function);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-int coresight_enable(struct coresight_device *csdev)
-{
-       int cpu, ret = 0;
-       struct coresight_device *sink;
-       struct list_head *path;
-       enum coresight_dev_subtype_source subtype;
-
-       subtype = csdev->subtype.source_subtype;
-
-       mutex_lock(&coresight_mutex);
-
-       ret = coresight_validate_source(csdev, __func__);
-       if (ret)
-               goto out;
-
-       if (csdev->enable) {
-               /*
-                * There could be multiple applications driving the software
-                * source. So keep the refcount for each such user when the
-                * source is already enabled.
-                */
-               if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE)
-                       atomic_inc(csdev->refcnt);
-               goto out;
-       }
-
-       /*
-        * Search for a valid sink for this session but don't reset the
-        * "enable_sink" flag in sysFS.  Users get to do that explicitly.
-        */
-       sink = coresight_get_enabled_sink(false);
-       if (!sink) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       path = coresight_build_path(csdev, sink);
-       if (IS_ERR(path)) {
-               pr_err("building path(s) failed\n");
-               ret = PTR_ERR(path);
-               goto out;
-       }
-
-       ret = coresight_enable_path(path, CS_MODE_SYSFS, NULL);
-       if (ret)
-               goto err_path;
-
-       ret = coresight_enable_source(csdev, CS_MODE_SYSFS);
-       if (ret)
-               goto err_source;
-
-       switch (subtype) {
-       case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
-               /*
-                * When working from sysFS it is important to keep track
-                * of the paths that were created so that they can be
-                * undone in 'coresight_disable()'.  Since there can only
-                * be a single session per tracer (when working from sysFS)
-                * a per-cpu variable will do just fine.
-                */
-               cpu = source_ops(csdev)->cpu_id(csdev);
-               per_cpu(tracer_path, cpu) = path;
-               break;
-       case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
-               stm_path = path;
-               break;
-       default:
-               /* We can't be here */
-               break;
-       }
-
-out:
-       mutex_unlock(&coresight_mutex);
-       return ret;
-
-err_source:
-       coresight_disable_path(path);
-
-err_path:
-       coresight_release_path(path);
-       goto out;
-}
-EXPORT_SYMBOL_GPL(coresight_enable);
-
-void coresight_disable(struct coresight_device *csdev)
-{
-       int cpu, ret;
-       struct list_head *path = NULL;
-
-       mutex_lock(&coresight_mutex);
-
-       ret = coresight_validate_source(csdev, __func__);
-       if (ret)
-               goto out;
-
-       if (!csdev->enable || !coresight_disable_source(csdev))
-               goto out;
-
-       switch (csdev->subtype.source_subtype) {
-       case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC:
-               cpu = source_ops(csdev)->cpu_id(csdev);
-               path = per_cpu(tracer_path, cpu);
-               per_cpu(tracer_path, cpu) = NULL;
-               break;
-       case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE:
-               path = stm_path;
-               stm_path = NULL;
-               break;
-       default:
-               /* We can't be here */
-               break;
-       }
-
-       coresight_disable_path(path);
-       coresight_release_path(path);
-
-out:
-       mutex_unlock(&coresight_mutex);
-}
-EXPORT_SYMBOL_GPL(coresight_disable);
-
-static ssize_t enable_sink_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
-{
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->activated);
-}
-
-static ssize_t enable_sink_store(struct device *dev,
-                                struct device_attribute *attr,
-                                const char *buf, size_t size)
-{
-       int ret;
-       unsigned long val;
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       ret = kstrtoul(buf, 10, &val);
-       if (ret)
-               return ret;
-
-       if (val)
-               csdev->activated = true;
-       else
-               csdev->activated = false;
-
-       return size;
-
-}
-static DEVICE_ATTR_RW(enable_sink);
-
-static ssize_t enable_source_show(struct device *dev,
-                                 struct device_attribute *attr, char *buf)
-{
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->enable);
-}
-
-static ssize_t enable_source_store(struct device *dev,
-                                  struct device_attribute *attr,
-                                  const char *buf, size_t size)
-{
-       int ret = 0;
-       unsigned long val;
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       ret = kstrtoul(buf, 10, &val);
-       if (ret)
-               return ret;
-
-       if (val) {
-               ret = coresight_enable(csdev);
-               if (ret)
-                       return ret;
-       } else {
-               coresight_disable(csdev);
-       }
-
-       return size;
-}
-static DEVICE_ATTR_RW(enable_source);
-
-static struct attribute *coresight_sink_attrs[] = {
-       &dev_attr_enable_sink.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(coresight_sink);
-
-static struct attribute *coresight_source_attrs[] = {
-       &dev_attr_enable_source.attr,
-       NULL,
-};
-ATTRIBUTE_GROUPS(coresight_source);
-
-static struct device_type coresight_dev_type[] = {
-       {
-               .name = "none",
-       },
-       {
-               .name = "sink",
-               .groups = coresight_sink_groups,
-       },
-       {
-               .name = "link",
-       },
-       {
-               .name = "linksink",
-               .groups = coresight_sink_groups,
-       },
-       {
-               .name = "source",
-               .groups = coresight_source_groups,
-       },
-       {
-               .name = "helper",
-       },
-       {
-               .name = "ect",
-       },
-};
-
-static void coresight_device_release(struct device *dev)
-{
-       struct coresight_device *csdev = to_coresight_device(dev);
-
-       cti_remove_assoc_from_csdev(csdev);
-       fwnode_handle_put(csdev->dev.fwnode);
-       kfree(csdev->refcnt);
-       kfree(csdev);
-}
-
-static int coresight_orphan_match(struct device *dev, void *data)
-{
-       int i, ret = 0;
-       bool still_orphan = false;
-       struct coresight_device *csdev, *i_csdev;
-       struct coresight_connection *conn;
-
-       csdev = data;
-       i_csdev = to_coresight_device(dev);
-
-       /* No need to check oneself */
-       if (csdev == i_csdev)
-               return 0;
-
-       /* Move on to another component if no connection is orphan */
-       if (!i_csdev->orphan)
-               return 0;
-       /*
-        * Circle throuch all the connection of that component.  If we find
-        * an orphan connection whose name matches @csdev, link it.
-        */
-       for (i = 0; i < i_csdev->pdata->nr_outport; i++) {
-               conn = &i_csdev->pdata->conns[i];
-
-               /* Skip the port if FW doesn't describe it */
-               if (!conn->child_fwnode)
-                       continue;
-               /* We have found at least one orphan connection */
-               if (conn->child_dev == NULL) {
-                       /* Does it match this newly added device? */
-                       if (conn->child_fwnode == csdev->dev.fwnode) {
-                               ret = coresight_make_links(i_csdev,
-                                                          conn, csdev);
-                               if (ret)
-                                       return ret;
-                       } else {
-                               /* This component still has an orphan */
-                               still_orphan = true;
-                       }
-               }
-       }
-
-       i_csdev->orphan = still_orphan;
-
-       /*
-        * Returning '0' in case we didn't encounter any error,
-        * ensures that all known component on the bus will be checked.
-        */
-       return 0;
-}
-
-static int coresight_fixup_orphan_conns(struct coresight_device *csdev)
-{
-       return bus_for_each_dev(&coresight_bustype, NULL,
-                        csdev, coresight_orphan_match);
-}
-
-
-static int coresight_fixup_device_conns(struct coresight_device *csdev)
-{
-       int i, ret = 0;
-
-       for (i = 0; i < csdev->pdata->nr_outport; i++) {
-               struct coresight_connection *conn = &csdev->pdata->conns[i];
-
-               if (!conn->child_fwnode)
-                       continue;
-               conn->child_dev =
-                       coresight_find_csdev_by_fwnode(conn->child_fwnode);
-               if (conn->child_dev) {
-                       ret = coresight_make_links(csdev, conn,
-                                                  conn->child_dev);
-                       if (ret)
-                               break;
-               } else {
-                       csdev->orphan = true;
-               }
-       }
-
-       return 0;
-}
-
-static int coresight_remove_match(struct device *dev, void *data)
-{
-       int i;
-       struct coresight_device *csdev, *iterator;
-       struct coresight_connection *conn;
-
-       csdev = data;
-       iterator = to_coresight_device(dev);
-
-       /* No need to check oneself */
-       if (csdev == iterator)
-               return 0;
-
-       /*
-        * Circle throuch all the connection of that component.  If we find
-        * a connection whose name matches @csdev, remove it.
-        */
-       for (i = 0; i < iterator->pdata->nr_outport; i++) {
-               conn = &iterator->pdata->conns[i];
-
-               if (conn->child_dev == NULL || conn->child_fwnode == NULL)
-                       continue;
-
-               if (csdev->dev.fwnode == conn->child_fwnode) {
-                       iterator->orphan = true;
-                       coresight_remove_links(iterator, conn);
-                       /*
-                        * Drop the reference to the handle for the remote
-                        * device acquired in parsing the connections from
-                        * platform data.
-                        */
-                       fwnode_handle_put(conn->child_fwnode);
-                       /* No need to continue */
-                       break;
-               }
-       }
-
-       /*
-        * Returning '0' ensures that all known component on the
-        * bus will be checked.
-        */
-       return 0;
-}
-
-/*
- * coresight_remove_conns - Remove references to this given devices
- * from the connections of other devices.
- */
-static void coresight_remove_conns(struct coresight_device *csdev)
-{
-       /*
-        * Another device will point to this device only if there is
-        * an output port connected to this one. i.e, if the device
-        * doesn't have at least one input port, there is no point
-        * in searching all the devices.
-        */
-       if (csdev->pdata->nr_inport)
-               bus_for_each_dev(&coresight_bustype, NULL,
-                                csdev, coresight_remove_match);
-}
-
-/**
- * coresight_timeout - loop until a bit has changed to a specific state.
- * @addr: base address of the area of interest.
- * @offset: address of a register, starting from @addr.
- * @position: the position of the bit of interest.
- * @value: the value the bit should have.
- *
- * Return: 0 as soon as the bit has taken the desired state or -EAGAIN if
- * TIMEOUT_US has elapsed, which ever happens first.
- */
-
-int coresight_timeout(void __iomem *addr, u32 offset, int position, int value)
-{
-       int i;
-       u32 val;
-
-       for (i = TIMEOUT_US; i > 0; i--) {
-               val = __raw_readl(addr + offset);
-               /* waiting on the bit to go from 0 to 1 */
-               if (value) {
-                       if (val & BIT(position))
-                               return 0;
-               /* waiting on the bit to go from 1 to 0 */
-               } else {
-                       if (!(val & BIT(position)))
-                               return 0;
-               }
-
-               /*
-                * Delay is arbitrary - the specification doesn't say how long
-                * we are expected to wait.  Extra check required to make sure
-                * we don't wait needlessly on the last iteration.
-                */
-               if (i - 1)
-                       udelay(1);
-       }
-
-       return -EAGAIN;
-}
-
-struct bus_type coresight_bustype = {
-       .name   = "coresight",
-};
-
-static int __init coresight_init(void)
-{
-       return bus_register(&coresight_bustype);
-}
-postcore_initcall(coresight_init);
-
-/*
- * coresight_release_platform_data: Release references to the devices connected
- * to the output port of this device.
- */
-void coresight_release_platform_data(struct coresight_device *csdev,
-                                    struct coresight_platform_data *pdata)
-{
-       int i;
-       struct coresight_connection *conns = pdata->conns;
-
-       for (i = 0; i < pdata->nr_outport; i++) {
-               /* If we have made the links, remove them now */
-               if (csdev && conns[i].child_dev)
-                       coresight_remove_links(csdev, &conns[i]);
-               /*
-                * Drop the refcount and clear the handle as this device
-                * is going away
-                */
-               if (conns[i].child_fwnode) {
-                       fwnode_handle_put(conns[i].child_fwnode);
-                       pdata->conns[i].child_fwnode = NULL;
-               }
-       }
-       if (csdev)
-               coresight_remove_conns_sysfs_group(csdev);
-}
-
-struct coresight_device *coresight_register(struct coresight_desc *desc)
-{
-       int ret;
-       int link_subtype;
-       int nr_refcnts = 1;
-       atomic_t *refcnts = NULL;
-       struct coresight_device *csdev;
-
-       csdev = kzalloc(sizeof(*csdev), GFP_KERNEL);
-       if (!csdev) {
-               ret = -ENOMEM;
-               goto err_out;
-       }
-
-       if (desc->type == CORESIGHT_DEV_TYPE_LINK ||
-           desc->type == CORESIGHT_DEV_TYPE_LINKSINK) {
-               link_subtype = desc->subtype.link_subtype;
-
-               if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_MERG)
-                       nr_refcnts = desc->pdata->nr_inport;
-               else if (link_subtype == CORESIGHT_DEV_SUBTYPE_LINK_SPLIT)
-                       nr_refcnts = desc->pdata->nr_outport;
-       }
-
-       refcnts = kcalloc(nr_refcnts, sizeof(*refcnts), GFP_KERNEL);
-       if (!refcnts) {
-               ret = -ENOMEM;
-               goto err_free_csdev;
-       }
-
-       csdev->refcnt = refcnts;
-
-       csdev->pdata = desc->pdata;
-
-       csdev->type = desc->type;
-       csdev->subtype = desc->subtype;
-       csdev->ops = desc->ops;
-       csdev->orphan = false;
-
-       csdev->dev.type = &coresight_dev_type[desc->type];
-       csdev->dev.groups = desc->groups;
-       csdev->dev.parent = desc->dev;
-       csdev->dev.release = coresight_device_release;
-       csdev->dev.bus = &coresight_bustype;
-       /*
-        * Hold the reference to our parent device. This will be
-        * dropped only in coresight_device_release().
-        */
-       csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev));
-       dev_set_name(&csdev->dev, "%s", desc->name);
-
-       ret = device_register(&csdev->dev);
-       if (ret) {
-               put_device(&csdev->dev);
-               /*
-                * All resources are free'd explicitly via
-                * coresight_device_release(), triggered from put_device().
-                */
-               goto err_out;
-       }
-
-       if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-           csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
-               ret = etm_perf_add_symlink_sink(csdev);
-
-               if (ret) {
-                       device_unregister(&csdev->dev);
-                       /*
-                        * As with the above, all resources are free'd
-                        * explicitly via coresight_device_release() triggered
-                        * from put_device(), which is in turn called from
-                        * function device_unregister().
-                        */
-                       goto err_out;
-               }
-       }
-
-       mutex_lock(&coresight_mutex);
-
-       ret = coresight_create_conns_sysfs_group(csdev);
-       if (!ret)
-               ret = coresight_fixup_device_conns(csdev);
-       if (!ret)
-               ret = coresight_fixup_orphan_conns(csdev);
-       if (!ret)
-               cti_add_assoc_to_csdev(csdev);
-
-       mutex_unlock(&coresight_mutex);
-       if (ret) {
-               coresight_unregister(csdev);
-               return ERR_PTR(ret);
-       }
-
-       return csdev;
-
-err_free_csdev:
-       kfree(csdev);
-err_out:
-       /* Cleanup the connection information */
-       coresight_release_platform_data(NULL, desc->pdata);
-       return ERR_PTR(ret);
-}
-EXPORT_SYMBOL_GPL(coresight_register);
-
-void coresight_unregister(struct coresight_device *csdev)
-{
-       etm_perf_del_symlink_sink(csdev);
-       /* Remove references of that device in the topology */
-       coresight_remove_conns(csdev);
-       coresight_clear_default_sink(csdev);
-       coresight_release_platform_data(csdev, csdev->pdata);
-       device_unregister(&csdev->dev);
-}
-EXPORT_SYMBOL_GPL(coresight_unregister);
-
-
-/*
- * coresight_search_device_idx - Search the fwnode handle of a device
- * in the given dev_idx list. Must be called with the coresight_mutex held.
- *
- * Returns the index of the entry, when found. Otherwise, -ENOENT.
- */
-static inline int coresight_search_device_idx(struct coresight_dev_list *dict,
-                                             struct fwnode_handle *fwnode)
-{
-       int i;
-
-       for (i = 0; i < dict->nr_idx; i++)
-               if (dict->fwnode_list[i] == fwnode)
-                       return i;
-       return -ENOENT;
-}
-
-bool coresight_loses_context_with_cpu(struct device *dev)
-{
-       return fwnode_property_present(dev_fwnode(dev),
-                                      "arm,coresight-loses-context-with-cpu");
-}
-
-/*
- * coresight_alloc_device_name - Get an index for a given device in the
- * device index list specific to a driver. An index is allocated for a
- * device and is tracked with the fwnode_handle to prevent allocating
- * duplicate indices for the same device (e.g, if we defer probing of
- * a device due to dependencies), in case the index is requested again.
- */
-char *coresight_alloc_device_name(struct coresight_dev_list *dict,
-                                 struct device *dev)
-{
-       int idx;
-       char *name = NULL;
-       struct fwnode_handle **list;
-
-       mutex_lock(&coresight_mutex);
-
-       idx = coresight_search_device_idx(dict, dev_fwnode(dev));
-       if (idx < 0) {
-               /* Make space for the new entry */
-               idx = dict->nr_idx;
-               list = krealloc(dict->fwnode_list,
-                               (idx + 1) * sizeof(*dict->fwnode_list),
-                               GFP_KERNEL);
-               if (ZERO_OR_NULL_PTR(list)) {
-                       idx = -ENOMEM;
-                       goto done;
-               }
-
-               list[idx] = dev_fwnode(dev);
-               dict->fwnode_list = list;
-               dict->nr_idx = idx + 1;
-       }
-
-       name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
-done:
-       mutex_unlock(&coresight_mutex);
-       return name;
-}
-EXPORT_SYMBOL_GPL(coresight_alloc_device_name);
index a1529f5..9ca8c4e 100644 (file)
@@ -84,11 +84,11 @@ static ssize_t notrace sth_stm_packet(struct stm_data *stm_data,
        /* Global packets (GERR, XSYNC, TRIG) are sent with register writes */
        case STP_PACKET_GERR:
                reg += 4;
-               /* fall through */
+               fallthrough;
 
        case STP_PACKET_XSYNC:
                reg += 8;
-               /* fall through */
+               fallthrough;
 
        case STP_PACKET_TRIG:
                if (flags & STP_PACKET_TIMESTAMPED)
index 710fbef..384af88 100644 (file)
@@ -41,8 +41,22 @@ static void pca_reset(struct i2c_algo_pca_data *adap)
                pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_IPRESET);
                pca_outw(adap, I2C_PCA_IND, 0xA5);
                pca_outw(adap, I2C_PCA_IND, 0x5A);
+
+               /*
+                * After a reset we need to re-apply any configuration
+                * (calculated in pca_init) to get the bus in a working state.
+                */
+               pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_IMODE);
+               pca_outw(adap, I2C_PCA_IND, adap->bus_settings.mode);
+               pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_ISCLL);
+               pca_outw(adap, I2C_PCA_IND, adap->bus_settings.tlow);
+               pca_outw(adap, I2C_PCA_INDPTR, I2C_PCA_ISCLH);
+               pca_outw(adap, I2C_PCA_IND, adap->bus_settings.thi);
+
+               pca_set_con(adap, I2C_PCA_CON_ENSIO);
        } else {
                adap->reset_chip(adap->data);
+               pca_set_con(adap, I2C_PCA_CON_ENSIO | adap->bus_settings.clock_freq);
        }
 }
 
@@ -423,13 +437,14 @@ static int pca_init(struct i2c_adapter *adap)
                                " Use the nominal frequency.\n", adap->name);
                }
 
-               pca_reset(pca_data);
-
                clock = pca_clock(pca_data);
                printk(KERN_INFO "%s: Clock frequency is %dkHz\n",
                     adap->name, freqs[clock]);
 
-               pca_set_con(pca_data, I2C_PCA_CON_ENSIO | clock);
+               /* Store settings as these will be needed when the PCA chip is reset */
+               pca_data->bus_settings.clock_freq = clock;
+
+               pca_reset(pca_data);
        } else {
                int clock;
                int mode;
@@ -496,19 +511,15 @@ static int pca_init(struct i2c_adapter *adap)
                        thi = tlow * min_thi / min_tlow;
                }
 
+               /* Store settings as these will be needed when the PCA chip is reset */
+               pca_data->bus_settings.mode = mode;
+               pca_data->bus_settings.tlow = tlow;
+               pca_data->bus_settings.thi = thi;
+
                pca_reset(pca_data);
 
                printk(KERN_INFO
                     "%s: Clock frequency is %dHz\n", adap->name, clock * 100);
-
-               pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_IMODE);
-               pca_outw(pca_data, I2C_PCA_IND, mode);
-               pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_ISCLL);
-               pca_outw(pca_data, I2C_PCA_IND, tlow);
-               pca_outw(pca_data, I2C_PCA_INDPTR, I2C_PCA_ISCLH);
-               pca_outw(pca_data, I2C_PCA_IND, thi);
-
-               pca_set_con(pca_data, I2C_PCA_CON_ENSIO);
        }
        udelay(500); /* 500 us for oscillator to stabilise */
 
index 688e928..d8295b1 100644 (file)
@@ -720,7 +720,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c,
 
                        /* mark the last byte */
                        if (!process_call && (i == msg->len - 1))
-                               val |= 1 << M_TX_WR_STATUS_SHIFT;
+                               val |= BIT(M_TX_WR_STATUS_SHIFT);
 
                        iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val);
                }
@@ -738,7 +738,7 @@ static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c,
                 */
                addr = i2c_8bit_addr_from_msg(msg);
                /* mark it the last byte out */
-               val = addr | (1 << M_TX_WR_STATUS_SHIFT);
+               val = addr | BIT(M_TX_WR_STATUS_SHIFT);
                iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val);
        }
 
index 75f0713..dfcf04e 100644 (file)
@@ -2093,8 +2093,12 @@ static int npcm_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                }
        }
 
-       /* Adaptive TimeOut: astimated time in usec + 100% margin */
-       timeout_usec = (2 * 10000 / bus->bus_freq) * (2 + nread + nwrite);
+       /*
+        * Adaptive TimeOut: estimated time in usec + 100% margin:
+        * 2: double the timeout for clock stretching case
+        * 9: bits per transaction (including the ack/nack)
+        */
+       timeout_usec = (2 * 9 * USEC_PER_SEC / bus->bus_freq) * (2 + nread + nwrite);
        timeout = max(msecs_to_jiffies(35), usecs_to_jiffies(timeout_usec));
        if (nwrite >= 32 * 1024 || nread >= 32 * 1024) {
                dev_err(bus->dev, "i2c%d buffer too big\n", bus->num);
index 175c590..12ac421 100644 (file)
@@ -1425,7 +1425,6 @@ omap_i2c_probe(struct platform_device *pdev)
                major = OMAP_I2C_REV_SCHEME_0_MAJOR(omap->rev);
                break;
        case OMAP_I2C_SCHEME_1:
-               /* FALLTHROUGH */
        default:
                omap->regs = (u8 *)reg_map_ip_v2;
                rev = (rev << 16) |
index 1c4c9bb..6eb0f50 100644 (file)
@@ -125,7 +125,7 @@ static int i2c_opal_smbus_xfer(struct i2c_adapter *adap, u16 addr,
        case I2C_SMBUS_BYTE:
                req.buffer_ra = cpu_to_be64(__pa(&data->byte));
                req.size = cpu_to_be32(1);
-               /* Fall through */
+               fallthrough;
        case I2C_SMBUS_QUICK:
                req.type = (read_write == I2C_SMBUS_READ) ?
                        OPAL_I2C_RAW_READ : OPAL_I2C_RAW_WRITE;
index 9e88347..c7c5434 100644 (file)
@@ -590,6 +590,7 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
        /* master sent stop */
        if (ssr_filtered & SSR) {
                i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value);
+               rcar_i2c_write(priv, ICSCR, SIE | SDBS); /* clear our NACK */
                rcar_i2c_write(priv, ICSIER, SAR);
                rcar_i2c_write(priv, ICSSR, ~SSR & 0xff);
        }
index 2ade99b..e627d7b 100644 (file)
@@ -276,16 +276,6 @@ void i2c_acpi_register_devices(struct i2c_adapter *adap)
                dev_warn(&adap->dev, "failed to enumerate I2C slaves\n");
 }
 
-const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
-                     struct i2c_client *client)
-{
-       if (!(client && matches))
-               return NULL;
-
-       return acpi_match_device(matches, &client->dev);
-}
-
 static const struct acpi_device_id i2c_acpi_force_400khz_device_ids[] = {
        /*
         * These Silead touchscreen controllers only work at 400KHz, for
index 34a9609..5ec082e 100644 (file)
@@ -480,7 +480,7 @@ static int i2c_device_probe(struct device *dev)
         * or ACPI ID table is supplied for the probing device.
         */
        if (!driver->id_table &&
-           !i2c_acpi_match_device(dev->driver->acpi_match_table, client) &&
+           !acpi_driver_match_device(dev, dev->driver) &&
            !i2c_of_match_device(dev->driver->of_match_table, client)) {
                status = -ENODEV;
                goto put_sync_adapter;
index 94ff169..8ce2611 100644 (file)
@@ -59,20 +59,11 @@ static inline int __i2c_check_suspended(struct i2c_adapter *adap)
 }
 
 #ifdef CONFIG_ACPI
-const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
-                     struct i2c_client *client);
 void i2c_acpi_register_devices(struct i2c_adapter *adap);
 
 int i2c_acpi_get_irq(struct i2c_client *client);
 #else /* CONFIG_ACPI */
 static inline void i2c_acpi_register_devices(struct i2c_adapter *adap) { }
-static inline const struct acpi_device_id *
-i2c_acpi_match_device(const struct acpi_device_id *matches,
-                     struct i2c_client *client)
-{
-       return NULL;
-}
 
 static inline int i2c_acpi_get_irq(struct i2c_client *client)
 {
index 5c5306c..8513bd3 100644 (file)
@@ -603,7 +603,7 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m)
                ret = dw_i2c_clk_cfg(master);
                if (ret)
                        return ret;
-               /* fall through */
+               fallthrough;
        case I3C_BUS_MODE_PURE:
                ret = dw_i3c_clk_cfg(master);
                if (ret)
index fd3b5da..50c9a41 100644 (file)
@@ -575,14 +575,14 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive)
                if (!HPT370_ALLOW_ATA100_5 ||
                    check_in_drive_list(drive, bad_ata100_5))
                        return ATA_UDMA4;
-               /* fall through */
+               fallthrough;
        case HPT372 :
        case HPT372A:
        case HPT372N:
        case HPT374 :
                if (ata_id_is_sata(drive->id))
                        mask &= ~0x0e;
-               /* fall through */
+               fallthrough;
        default:
                return mask;
        }
@@ -602,7 +602,7 @@ static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
        case HPT374 :
                if (ata_id_is_sata(drive->id))
                        return 0x00;
-               /* fall through */
+               fallthrough;
        default:
                return 0x07;
        }
index 7f17f83..212bb2d 100644 (file)
@@ -350,7 +350,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
                 */
                if (scsi_req(rq)->cmd[0] == GPCMD_START_STOP_UNIT)
                        break;
-               /* fall-through */
+               fallthrough;
        case DATA_PROTECT:
                /*
                 * No point in retrying after an illegal request or data
@@ -750,7 +750,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        case REQ_OP_DRV_IN:
        case REQ_OP_DRV_OUT:
                expiry = ide_cd_expiry;
-               /*FALLTHRU*/
+               fallthrough;
        default:
                timeout = ATAPI_WAIT_PC;
                break;
index 1fe1f9d..af7503b 100644 (file)
@@ -428,7 +428,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
                                 * (maintains previous driver behaviour)
                                 */
                                break;
-                       /* fall through */
+                       fallthrough;
                case CAPACITY_CURRENT:
                        /* Normal Zip/LS-120 disks */
                        if (memcmp(cap_desc, &floppy->cap_desc, 8))
index e867129..1ddc45a 100644 (file)
@@ -143,7 +143,7 @@ static void ide_classify_atapi_dev(ide_drive_t *drive)
                }
                /* Early cdrom models used zero */
                type = ide_cdrom;
-               /* fall through */
+               fallthrough;
        case ide_cdrom:
                drive->dev_flags |= IDE_DFLAG_REMOVABLE;
 #ifdef CONFIG_PPC
index a26f85a..d016cbe 100644 (file)
@@ -129,7 +129,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
                        return pre_task_out_intr(drive, cmd);
                }
                handler = task_pio_intr;
-               /* fall through */
+               fallthrough;
        case ATA_PROT_NODATA:
                if (handler == NULL)
                        handler = task_no_data_intr;
@@ -141,7 +141,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
                hwif->expiry = dma_ops->dma_timer_expiry;
                ide_execute_command(drive, cmd, ide_dma_intr, 2 * WAIT_CMD);
                dma_ops->dma_start(drive);
-               /* fall through */
+               fallthrough;
        default:
                return ide_started;
        }
@@ -579,10 +579,10 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
                        goto abort;
                }
                cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
-               /* fall through */
+               fallthrough;
        case TASKFILE_OUT:
                cmd.protocol = ATA_PROT_PIO;
-               /* fall through */
+               fallthrough;
        case TASKFILE_OUT_DMAQ:
        case TASKFILE_OUT_DMA:
                cmd.tf_flags |= IDE_TFLAG_WRITE;
@@ -598,10 +598,10 @@ int ide_taskfile_ioctl(ide_drive_t *drive, unsigned long arg)
                        goto abort;
                }
                cmd.tf_flags |= IDE_TFLAG_MULTI_PIO;
-               /* fall through */
+               fallthrough;
        case TASKFILE_IN:
                cmd.protocol = ATA_PROT_PIO;
-               /* fall through */
+               fallthrough;
        case TASKFILE_IN_DMAQ:
        case TASKFILE_IN_DMA:
                nsect = taskin / SECTOR_SIZE;
index 024bc7b..1a700be 100644 (file)
@@ -494,7 +494,7 @@ static int init_chipset_sis5513(struct pci_dev *dev)
                pci_read_config_byte(dev, 0x09, &reg);
                if ((reg & 0x0f) != 0x00)
                        pci_write_config_byte(dev, 0x09, reg&0xf0);
-               /* fall through */
+               fallthrough;
        case ATA_16:
                /* force per drive recovery and active timings
                   needed on ATA_33 and below chips */
index 8e0fb1a..9a810e4 100644 (file)
@@ -89,14 +89,6 @@ static unsigned int mwait_substates __initdata;
  */
 #define CPUIDLE_FLAG_ALWAYS_ENABLE     BIT(15)
 
-/*
- * Set this flag for states where the HW flushes the TLB for us
- * and so we don't need cross-calls to keep it consistent.
- * If this flag is set, SW flushes the TLB, so even if the
- * HW doesn't do the flushing, this flag is safe to use.
- */
-#define CPUIDLE_FLAG_TLB_FLUSHED       BIT(16)
-
 /*
  * MWAIT takes an 8-bit "hint" in EAX "suggesting"
  * the C-state (top nibble) and sub-state (bottom nibble)
@@ -131,14 +123,6 @@ static __cpuidle int intel_idle(struct cpuidle_device *dev,
        unsigned long eax = flg2MWAIT(state->flags);
        unsigned long ecx = 1; /* break on interrupt flag */
        bool tick;
-       int cpu = smp_processor_id();
-
-       /*
-        * leave_mm() to avoid costly and often unnecessary wakeups
-        * for flushing the user TLB's associated with the active mm.
-        */
-       if (state->flags & CPUIDLE_FLAG_TLB_FLUSHED)
-               leave_mm(cpu);
 
        if (!static_cpu_has(X86_FEATURE_ARAT)) {
                /*
index 24864d9..4843586 100644 (file)
@@ -189,6 +189,14 @@ struct bmc150_accel_data {
        struct mutex mutex;
        u8 fifo_mode, watermark;
        s16 buffer[8];
+       /*
+        * Ensure there is sufficient space and correct alignment for
+        * the timestamp if enabled
+        */
+       struct {
+               __le16 channels[3];
+               s64 ts __aligned(8);
+       } scan;
        u8 bw_bits;
        u32 slope_dur;
        u32 slope_thres;
@@ -922,15 +930,16 @@ static int __bmc150_accel_fifo_flush(struct iio_dev *indio_dev,
         * now.
         */
        for (i = 0; i < count; i++) {
-               u16 sample[8];
                int j, bit;
 
                j = 0;
                for_each_set_bit(bit, indio_dev->active_scan_mask,
                                 indio_dev->masklength)
-                       memcpy(&sample[j++], &buffer[i * 3 + bit], 2);
+                       memcpy(&data->scan.channels[j++], &buffer[i * 3 + bit],
+                              sizeof(data->scan.channels[0]));
 
-               iio_push_to_buffers_with_timestamp(indio_dev, sample, tstamp);
+               iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
+                                                  tstamp);
 
                tstamp += sample_period;
        }
index 66b2e4c..0e18b92 100644 (file)
@@ -209,14 +209,20 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
        const struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct kxsd9_state *st = iio_priv(indio_dev);
+       /*
+        * Ensure correct positioning and alignment of timestamp.
+        * No need to zero initialize as all elements written.
+        */
+       struct {
+               __be16 chan[4];
+               s64 ts __aligned(8);
+       } hw_values;
        int ret;
-       /* 4 * 16bit values AND timestamp */
-       __be16 hw_values[8];
 
        ret = regmap_bulk_read(st->map,
                               KXSD9_REG_X,
-                              &hw_values,
-                              8);
+                              hw_values.chan,
+                              sizeof(hw_values.chan));
        if (ret) {
                dev_err(st->dev,
                        "error reading data\n");
@@ -224,7 +230,7 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
        }
 
        iio_push_to_buffers_with_timestamp(indio_dev,
-                                          hw_values,
+                                          &hw_values,
                                           iio_get_time_ns(indio_dev));
        iio_trigger_notify_done(indio_dev->trig);
 
index 7e99bcb..922bd38 100644 (file)
 
 struct mma7455_data {
        struct regmap *regmap;
+       /*
+        * Used to reorganize data.  Will ensure correct alignment of
+        * the timestamp if present
+        */
+       struct {
+               __le16 channels[3];
+               s64 ts __aligned(8);
+       } scan;
 };
 
 static int mma7455_drdy(struct mma7455_data *mma7455)
@@ -82,19 +90,19 @@ static irqreturn_t mma7455_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct mma7455_data *mma7455 = iio_priv(indio_dev);
-       u8 buf[16]; /* 3 x 16-bit channels + padding + ts */
        int ret;
 
        ret = mma7455_drdy(mma7455);
        if (ret)
                goto done;
 
-       ret = regmap_bulk_read(mma7455->regmap, MMA7455_REG_XOUTL, buf,
-                              sizeof(__le16) * 3);
+       ret = regmap_bulk_read(mma7455->regmap, MMA7455_REG_XOUTL,
+                              mma7455->scan.channels,
+                              sizeof(mma7455->scan.channels));
        if (ret)
                goto done;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buf,
+       iio_push_to_buffers_with_timestamp(indio_dev, &mma7455->scan,
                                           iio_get_time_ns(indio_dev));
 
 done:
index ba27f86..853febc 100644 (file)
@@ -110,6 +110,12 @@ struct mma8452_data {
        int sleep_val;
        struct regulator *vdd_reg;
        struct regulator *vddio_reg;
+
+       /* Ensure correct alignment of time stamp when present */
+       struct {
+               __be16 channels[3];
+               s64 ts __aligned(8);
+       } buffer;
 };
 
  /**
@@ -1091,14 +1097,13 @@ static irqreturn_t mma8452_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct mma8452_data *data = iio_priv(indio_dev);
-       u8 buffer[16]; /* 3 16-bit channels + padding + ts */
        int ret;
 
-       ret = mma8452_read(data, (__be16 *)buffer);
+       ret = mma8452_read(data, data->buffer.channels);
        if (ret < 0)
                goto done;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buffer,
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->buffer,
                                           iio_get_time_ns(indio_dev));
 
 done:
@@ -1580,7 +1585,7 @@ static int mma8452_probe(struct i2c_client *client,
        case FXLS8471_DEVICE_ID:
                if (ret == data->chip_info->chip_id)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                ret = -ENODEV;
                goto disable_regulators;
index 66d9cc0..d94dc80 100644 (file)
@@ -865,6 +865,8 @@ config ROCKCHIP_SARADC
        tristate "Rockchip SARADC driver"
        depends on ARCH_ROCKCHIP || (ARM && COMPILE_TEST)
        depends on RESET_CONTROLLER
+       select IIO_BUFFER
+       select IIO_TRIGGERED_BUFFER
        help
          Say yes here to build support for the SARADC found in SoCs from
          Rockchip.
index 7fdc5d2..1bb987a 100644 (file)
@@ -484,7 +484,7 @@ static int ab8500_gpadc_read(struct ab8500_gpadc *gpadc,
                        delay_max = 10000; /* large range optimises sleepmode */
                        break;
                }
-               /* Fall through */
+               fallthrough;
        default:
                ctrl1 |= AB8500_GPADC_CTRL1_BUF_ENA;
                break;
index 84a1733..64c3cc3 100644 (file)
@@ -690,7 +690,7 @@ static void cpcap_adc_phase(struct cpcap_adc_request *req)
                break;
        case CPCAP_ADC_BATTI_PI17:
                index = req->bank_index;
-               /* fallthrough */
+               fallthrough;
        default:
                req->result += conv_tbl[index].cal_offset;
                req->result += conv_tbl[index].align_offset;
index 5ed63e8..b573ec6 100644 (file)
@@ -146,6 +146,11 @@ struct ina2xx_chip_info {
        int range_vbus; /* Bus voltage maximum in V */
        int pga_gain_vshunt; /* Shunt voltage PGA gain */
        bool allow_async_readout;
+       /* data buffer needs space for channel data and timestamp */
+       struct {
+               u16 chan[4];
+               u64 ts __aligned(8);
+       } scan;
 };
 
 static const struct ina2xx_config ina2xx_config[] = {
@@ -738,8 +743,6 @@ static int ina2xx_conversion_ready(struct iio_dev *indio_dev)
 static int ina2xx_work_buffer(struct iio_dev *indio_dev)
 {
        struct ina2xx_chip_info *chip = iio_priv(indio_dev);
-       /* data buffer needs space for channel data and timestap */
-       unsigned short data[4 + sizeof(s64)/sizeof(short)];
        int bit, ret, i = 0;
        s64 time;
 
@@ -758,10 +761,10 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
                if (ret < 0)
                        return ret;
 
-               data[i++] = val;
+               chip->scan.chan[i++] = val;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, data, time);
+       iio_push_to_buffers_with_timestamp(indio_dev, &chip->scan, time);
 
        return 0;
 };
index 01b20e4..6efb0b4 100644 (file)
@@ -36,6 +36,11 @@ struct max1118 {
        struct spi_device *spi;
        struct mutex lock;
        struct regulator *reg;
+       /* Ensure natural alignment of buffer elements */
+       struct {
+               u8 channels[2];
+               s64 ts __aligned(8);
+       } scan;
 
        u8 data ____cacheline_aligned;
 };
@@ -166,7 +171,6 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct max1118 *adc = iio_priv(indio_dev);
-       u8 data[16] = { }; /* 2x 8-bit ADC data + padding + 8 bytes timestamp */
        int scan_index;
        int i = 0;
 
@@ -184,10 +188,10 @@ static irqreturn_t max1118_trigger_handler(int irq, void *p)
                        goto out;
                }
 
-               data[i] = ret;
+               adc->scan.channels[i] = ret;
                i++;
        }
-       iio_push_to_buffers_with_timestamp(indio_dev, data,
+       iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan,
                                           iio_get_time_ns(indio_dev));
 out:
        mutex_unlock(&adc->lock);
index 5f1706d..da353dc 100644 (file)
@@ -96,16 +96,12 @@ static int mcp3422_update_config(struct mcp3422 *adc, u8 newconfig)
 {
        int ret;
 
-       mutex_lock(&adc->lock);
-
        ret = i2c_master_send(adc->i2c, &newconfig, 1);
        if (ret > 0) {
                adc->config = newconfig;
                ret = 0;
        }
 
-       mutex_unlock(&adc->lock);
-
        return ret;
 }
 
@@ -138,6 +134,8 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
        u8 config;
        u8 req_channel = channel->channel;
 
+       mutex_lock(&adc->lock);
+
        if (req_channel != MCP3422_CHANNEL(adc->config)) {
                config = adc->config;
                config &= ~MCP3422_CHANNEL_MASK;
@@ -145,12 +143,18 @@ static int mcp3422_read_channel(struct mcp3422 *adc,
                config &= ~MCP3422_PGA_MASK;
                config |= MCP3422_PGA_VALUE(adc->pga[req_channel]);
                ret = mcp3422_update_config(adc, config);
-               if (ret < 0)
+               if (ret < 0) {
+                       mutex_unlock(&adc->lock);
                        return ret;
+               }
                msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]);
        }
 
-       return mcp3422_read(adc, value, &config);
+       ret = mcp3422_read(adc, value, &config);
+
+       mutex_unlock(&adc->lock);
+
+       return ret;
 }
 
 static int mcp3422_read_raw(struct iio_dev *iio,
index 93c2252..1a9189b 100644 (file)
@@ -707,7 +707,7 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
        size_t read_len;
        int ret;
 
-       temperature_calib = devm_nvmem_cell_get(&indio_dev->dev,
+       temperature_calib = devm_nvmem_cell_get(indio_dev->dev.parent,
                                                "temperature_calib");
        if (IS_ERR(temperature_calib)) {
                ret = PTR_ERR(temperature_calib);
index 9426f70..cf63983 100644 (file)
@@ -33,6 +33,12 @@ struct adc081c {
 
        /* 8, 10 or 12 */
        int bits;
+
+       /* Ensure natural alignment of buffer elements */
+       struct {
+               u16 channel;
+               s64 ts __aligned(8);
+       } scan;
 };
 
 #define REG_CONV_RES 0x00
@@ -128,14 +134,13 @@ static irqreturn_t adc081c_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct adc081c *data = iio_priv(indio_dev);
-       u16 buf[8]; /* 2 bytes data + 6 bytes padding + 8 bytes timestamp */
        int ret;
 
        ret = i2c_smbus_read_word_swapped(data->i2c, REG_CONV_RES);
        if (ret < 0)
                goto out;
-       buf[0] = ret;
-       iio_push_to_buffers_with_timestamp(indio_dev, buf,
+       data->scan.channel = ret;
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
                                           iio_get_time_ns(indio_dev));
 out:
        iio_trigger_notify_done(indio_dev->trig);
index 9017e1e..dfba348 100644 (file)
@@ -26,6 +26,11 @@ struct adc084s021 {
        struct spi_transfer spi_trans;
        struct regulator *reg;
        struct mutex lock;
+       /* Buffer used to align data */
+       struct {
+               __be16 channels[4];
+               s64 ts __aligned(8);
+       } scan;
        /*
         * DMA (thus cache coherency maintenance) requires the
         * transfer buffers to live in their own cache line.
@@ -141,14 +146,13 @@ static irqreturn_t adc084s021_buffer_trigger_handler(int irq, void *pollfunc)
        struct iio_poll_func *pf = pollfunc;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct adc084s021 *adc = iio_priv(indio_dev);
-       __be16 data[8] = {0}; /* 4 * 16-bit words of data + 8 bytes timestamp */
 
        mutex_lock(&adc->lock);
 
-       if (adc084s021_adc_conversion(adc, &data) < 0)
+       if (adc084s021_adc_conversion(adc, adc->scan.channels) < 0)
                dev_err(&adc->spi->dev, "Failed to read data\n");
 
-       iio_push_to_buffers_with_timestamp(indio_dev, data,
+       iio_push_to_buffers_with_timestamp(indio_dev, &adc->scan,
                                           iio_get_time_ns(indio_dev));
        mutex_unlock(&adc->lock);
        iio_trigger_notify_done(indio_dev->trig);
index f42ab11..9fef39b 100644 (file)
@@ -316,6 +316,7 @@ static const struct iio_chan_spec ads1115_channels[] = {
        IIO_CHAN_SOFT_TIMESTAMP(ADS1015_TIMESTAMP),
 };
 
+#ifdef CONFIG_PM
 static int ads1015_set_power_state(struct ads1015_data *data, bool on)
 {
        int ret;
@@ -333,6 +334,15 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on)
        return ret < 0 ? ret : 0;
 }
 
+#else /* !CONFIG_PM */
+
+static int ads1015_set_power_state(struct ads1015_data *data, bool on)
+{
+       return 0;
+}
+
+#endif /* !CONFIG_PM */
+
 static
 int ads1015_get_adc_result(struct ads1015_data *data, int chan, int *val)
 {
index 2b007e7..60dd87e 100644 (file)
@@ -78,6 +78,11 @@ struct ccs811_data {
        struct iio_trigger *drdy_trig;
        struct gpio_desc *wakeup_gpio;
        bool drdy_trig_on;
+       /* Ensures correct alignment of timestamp if present */
+       struct {
+               s16 channels[2];
+               s64 ts __aligned(8);
+       } scan;
 };
 
 static const struct iio_chan_spec ccs811_channels[] = {
@@ -327,17 +332,17 @@ static irqreturn_t ccs811_trigger_handler(int irq, void *p)
        struct iio_dev *indio_dev = pf->indio_dev;
        struct ccs811_data *data = iio_priv(indio_dev);
        struct i2c_client *client = data->client;
-       s16 buf[8]; /* s16 eCO2 + s16 TVOC + padding + 8 byte timestamp */
        int ret;
 
-       ret = i2c_smbus_read_i2c_block_data(client, CCS811_ALG_RESULT_DATA, 4,
-                                           (u8 *)&buf);
+       ret = i2c_smbus_read_i2c_block_data(client, CCS811_ALG_RESULT_DATA,
+                                           sizeof(data->scan.channels),
+                                           (u8 *)data->scan.channels);
        if (ret != 4) {
                dev_err(&client->dev, "cannot read sensor data\n");
                goto err;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buf,
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
                                           iio_get_time_ns(indio_dev));
 
 err:
index 5a29e32..2ea9a5c 100644 (file)
@@ -118,7 +118,7 @@ static int sps30_do_cmd(struct sps30_state *state, u16 cmd, u8 *data, int size)
        case SPS30_READ_AUTO_CLEANING_PERIOD:
                buf[0] = SPS30_AUTO_CLEANING_PERIOD >> 8;
                buf[1] = (u8)(SPS30_AUTO_CLEANING_PERIOD & 0xff);
-               /* fall through */
+               fallthrough;
        case SPS30_READ_DATA_READY_FLAG:
        case SPS30_READ_DATA:
        case SPS30_READ_SERIAL:
index ea480c1..1bc6efa 100644 (file)
@@ -72,10 +72,13 @@ static void get_default_min_max_freq(enum motionsensor_type type,
 
        switch (type) {
        case MOTIONSENSE_TYPE_ACCEL:
-       case MOTIONSENSE_TYPE_GYRO:
                *min_freq = 12500;
                *max_freq = 100000;
                break;
+       case MOTIONSENSE_TYPE_GYRO:
+               *min_freq = 25000;
+               *max_freq = 100000;
+               break;
        case MOTIONSENSE_TYPE_MAG:
                *min_freq = 5000;
                *max_freq = 25000;
index cc48756..1fd75c0 100644 (file)
@@ -220,7 +220,6 @@ static int ad5592r_set_channel_modes(struct ad5592r_state *st)
                        break;
 
                case CH_MODE_UNUSED:
-                       /* fall-through */
                default:
                        switch (st->channel_offstate[i]) {
                        case CH_OFFSTATE_OUT_TRISTATE:
@@ -237,7 +236,6 @@ static int ad5592r_set_channel_modes(struct ad5592r_state *st)
                                break;
 
                        case CH_OFFSTATE_PULLDOWN:
-                               /* fall-through */
                        default:
                                pulldown |= BIT(i);
                                break;
index b3835fb..1a9609e 100644 (file)
@@ -74,11 +74,12 @@ static int dpot_dac_read_raw(struct iio_dev *indio_dev,
                case IIO_VAL_INT:
                        /*
                         * Convert integer scale to fractional scale by
-                        * setting the denominator (val2) to one, and...
+                        * setting the denominator (val2) to one...
                         */
                        *val2 = 1;
                        ret = IIO_VAL_FRACTIONAL;
-                       /* fall through */
+                       /* ...and fall through. Say it again for GCC. */
+                       fallthrough;
                case IIO_VAL_FRACTIONAL:
                        *val *= regulator_get_voltage(dac->vref) / 1000;
                        *val2 *= dac->max_ohms;
index 9b47d94..d9b2ed8 100644 (file)
@@ -273,10 +273,10 @@ static int max30102_read_measurement(struct max30102_data *data,
        switch (measurements) {
        case 3:
                MAX30102_COPY_DATA(2);
-               /* fall through */
+               fallthrough;
        case 2:
                MAX30102_COPY_DATA(1);
-               /* fall through */
+               fallthrough;
        case 1:
                MAX30102_COPY_DATA(0);
                break;
index c539dfa..319b64b 100644 (file)
@@ -97,11 +97,11 @@ int __adis_write_reg(struct adis *adis, unsigned int reg,
                adis->tx[9] = (value >> 24) & 0xff;
                adis->tx[6] = ADIS_WRITE_REG(reg + 2);
                adis->tx[7] = (value >> 16) & 0xff;
-               /* fall through */
+               fallthrough;
        case 2:
                adis->tx[4] = ADIS_WRITE_REG(reg + 1);
                adis->tx[5] = (value >> 8) & 0xff;
-               /* fall through */
+               fallthrough;
        case 1:
                adis->tx[2] = ADIS_WRITE_REG(reg);
                adis->tx[3] = value & 0xff;
@@ -191,7 +191,7 @@ int __adis_read_reg(struct adis *adis, unsigned int reg,
                adis->tx[2] = ADIS_READ_REG(reg + 2);
                adis->tx[3] = 0;
                spi_message_add_tail(&xfers[1], &msg);
-               /* fall through */
+               fallthrough;
        case 2:
                adis->tx[4] = ADIS_READ_REG(reg);
                adis->tx[5] = 0;
index 606d5e6..cdcd16f 100644 (file)
@@ -599,7 +599,7 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type,
                return scnprintf(buf, len, "%d", vals[0]);
        case IIO_VAL_INT_PLUS_MICRO_DB:
                scale_db = true;
-               /* fall through */
+               fallthrough;
        case IIO_VAL_INT_PLUS_MICRO:
                if (vals[1] < 0)
                        return scnprintf(buf, len, "-%d.%06u%s", abs(vals[0]),
@@ -918,7 +918,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
                        break;
                case IIO_VAL_INT_PLUS_MICRO_DB:
                        scale_db = true;
-                       /* fall through */
+                       fallthrough;
                case IIO_VAL_INT_PLUS_MICRO:
                        fract_mult = 100000;
                        break;
index 4bac064..b4323d2 100644 (file)
@@ -1243,13 +1243,16 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct ltr501_data *data = iio_priv(indio_dev);
-       u16 buf[8];
+       struct {
+               u16 channels[3];
+               s64 ts __aligned(8);
+       } scan;
        __le16 als_buf[2];
        u8 mask = 0;
        int j = 0;
        int ret, psdata;
 
-       memset(buf, 0, sizeof(buf));
+       memset(&scan, 0, sizeof(scan));
 
        /* figure out which data needs to be ready */
        if (test_bit(0, indio_dev->active_scan_mask) ||
@@ -1268,9 +1271,9 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
                if (ret < 0)
                        return ret;
                if (test_bit(0, indio_dev->active_scan_mask))
-                       buf[j++] = le16_to_cpu(als_buf[1]);
+                       scan.channels[j++] = le16_to_cpu(als_buf[1]);
                if (test_bit(1, indio_dev->active_scan_mask))
-                       buf[j++] = le16_to_cpu(als_buf[0]);
+                       scan.channels[j++] = le16_to_cpu(als_buf[0]);
        }
 
        if (mask & LTR501_STATUS_PS_RDY) {
@@ -1278,10 +1281,10 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
                                       &psdata, 2);
                if (ret < 0)
                        goto done;
-               buf[j++] = psdata & LTR501_PS_DATA_MASK;
+               scan.channels[j++] = psdata & LTR501_PS_DATA_MASK;
        }
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buf,
+       iio_push_to_buffers_with_timestamp(indio_dev, &scan,
                                           iio_get_time_ns(indio_dev));
 
 done:
index aa8ed1e..b8e721b 100644 (file)
 struct max44000_data {
        struct mutex lock;
        struct regmap *regmap;
+       /* Ensure naturally aligned timestamp */
+       struct {
+               u16 channels[2];
+               s64 ts __aligned(8);
+       } scan;
 };
 
 /* Default scale is set to the minimum of 0.03125 or 1 / (1 << 5) lux */
@@ -488,7 +493,6 @@ static irqreturn_t max44000_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct max44000_data *data = iio_priv(indio_dev);
-       u16 buf[8]; /* 2x u16 + padding + 8 bytes timestamp */
        int index = 0;
        unsigned int regval;
        int ret;
@@ -498,17 +502,17 @@ static irqreturn_t max44000_trigger_handler(int irq, void *p)
                ret = max44000_read_alsval(data);
                if (ret < 0)
                        goto out_unlock;
-               buf[index++] = ret;
+               data->scan.channels[index++] = ret;
        }
        if (test_bit(MAX44000_SCAN_INDEX_PRX, indio_dev->active_scan_mask)) {
                ret = regmap_read(data->regmap, MAX44000_REG_PRX_DATA, &regval);
                if (ret < 0)
                        goto out_unlock;
-               buf[index] = regval;
+               data->scan.channels[index] = regval;
        }
        mutex_unlock(&data->lock);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buf,
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
                                           iio_get_time_ns(indio_dev));
        iio_trigger_notify_done(indio_dev->trig);
        return IRQ_HANDLED;
index 155faae..8f5f857 100644 (file)
@@ -1042,7 +1042,7 @@ static int si1145_initialize(struct si1145_data *data)
                                                SI1145_LED_CURRENT_45mA);
                if (ret < 0)
                        return ret;
-               /* fallthrough */
+               fallthrough;
        case 2:
                ret = i2c_smbus_write_byte_data(client,
                                                SI1145_REG_PS_LED21,
index 6a8ae14..cbb44e4 100644 (file)
@@ -499,7 +499,7 @@ static int ak8974_detect(struct ak8974 *ak8974)
        switch (whoami) {
        case AK8974_WHOAMI_VALUE_AMI306:
                name = "ami306";
-               /* fall-through */
+               fallthrough;
        case AK8974_WHOAMI_VALUE_AMI305:
                ret = regmap_read(ak8974->map, AMI305_VER, &fw);
                if (ret)
index 03d71f7..623766f 100644 (file)
@@ -366,6 +366,12 @@ struct ak8975_data {
        struct iio_mount_matrix orientation;
        struct regulator        *vdd;
        struct regulator        *vid;
+
+       /* Ensure natural alignment of timestamp */
+       struct {
+               s16 channels[3];
+               s64 ts __aligned(8);
+       } scan;
 };
 
 /* Enable attached power regulator if any. */
@@ -793,7 +799,6 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev)
        const struct i2c_client *client = data->client;
        const struct ak_def *def = data->def;
        int ret;
-       s16 buff[8]; /* 3 x 16 bits axis values + 1 aligned 64 bits timestamp */
        __le16 fval[3];
 
        mutex_lock(&data->lock);
@@ -816,12 +821,13 @@ static void ak8975_fill_buffer(struct iio_dev *indio_dev)
        mutex_unlock(&data->lock);
 
        /* Clamp to valid range. */
-       buff[0] = clamp_t(s16, le16_to_cpu(fval[0]), -def->range, def->range);
-       buff[1] = clamp_t(s16, le16_to_cpu(fval[1]), -def->range, def->range);
-       buff[2] = clamp_t(s16, le16_to_cpu(fval[2]), -def->range, def->range);
+       data->scan.channels[0] = clamp_t(s16, le16_to_cpu(fval[0]), -def->range, def->range);
+       data->scan.channels[1] = clamp_t(s16, le16_to_cpu(fval[1]), -def->range, def->range);
+       data->scan.channels[2] = clamp_t(s16, le16_to_cpu(fval[2]), -def->range, def->range);
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buff,
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
                                           iio_get_time_ns(indio_dev));
+
        return;
 
 unlock:
index 654564c..ad4b1fb 100644 (file)
@@ -40,6 +40,11 @@ struct mb1232_data {
         */
        struct completion       ranging;
        int                     irqnr;
+       /* Ensure correct alignment of data to push to IIO buffer */
+       struct {
+               s16 distance;
+               s64 ts __aligned(8);
+       } scan;
 };
 
 static irqreturn_t mb1232_handle_irq(int irq, void *dev_id)
@@ -113,17 +118,13 @@ static irqreturn_t mb1232_trigger_handler(int irq, void *p)
        struct iio_poll_func *pf = p;
        struct iio_dev *indio_dev = pf->indio_dev;
        struct mb1232_data *data = iio_priv(indio_dev);
-       /*
-        * triggered buffer
-        * 16-bit channel + 48-bit padding + 64-bit timestamp
-        */
-       s16 buffer[8] = { 0 };
 
-       buffer[0] = mb1232_read_distance(data);
-       if (buffer[0] < 0)
+       data->scan.distance = mb1232_read_distance(data);
+       if (data->scan.distance < 0)
                goto err;
 
-       iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp);
+       iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
+                                          pf->timestamp);
 
 err:
        iio_trigger_notify_done(indio_dev->trig);
index dc0558b..fbc28f1 100644 (file)
@@ -3034,7 +3034,7 @@ static int cm_rej_handler(struct cm_work *work)
        case IB_CM_REP_SENT:
        case IB_CM_MRA_REP_RCVD:
                ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
-               /* fall through */
+               fallthrough;
        case IB_CM_REQ_RCVD:
        case IB_CM_MRA_REQ_SENT:
                if (IBA_GET(CM_REJ_REASON, rej_msg) == IB_CM_REJ_STALE_CONN)
@@ -3044,7 +3044,7 @@ static int cm_rej_handler(struct cm_work *work)
                break;
        case IB_CM_DREQ_SENT:
                ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
-               /* fall through */
+               fallthrough;
        case IB_CM_REP_RCVD:
        case IB_CM_MRA_REP_SENT:
                cm_enter_timewait(cm_id_priv);
@@ -3058,7 +3058,7 @@ static int cm_rej_handler(struct cm_work *work)
                        cm_enter_timewait(cm_id_priv);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                pr_debug("%s: local_id %d, cm_id_priv->id.state: %d\n",
                         __func__, be32_to_cpu(cm_id_priv->id.local_id),
@@ -3116,7 +3116,7 @@ int ib_send_cm_mra(struct ib_cm_id *cm_id,
                        msg_response = CM_MSG_RESPONSE_OTHER;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                pr_debug("%s: local_id %d, cm_id_priv->id.state: %d\n",
                         __func__, be32_to_cpu(cm_id_priv->id.local_id),
@@ -3227,7 +3227,7 @@ static int cm_mra_handler(struct cm_work *work)
        case IB_CM_MRA_REP_RCVD:
                atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
                                counter[CM_MRA_COUNTER]);
-               /* fall through */
+               fallthrough;
        default:
                pr_debug("%s local_id %d, cm_id_priv->id.state: %d\n",
                         __func__, be32_to_cpu(cm_id_priv->id.local_id),
@@ -4214,7 +4214,7 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
                                qp_attr->retry_cnt = cm_id_priv->retry_count;
                                qp_attr->rnr_retry = cm_id_priv->rnr_retry_count;
                                qp_attr->max_rd_atomic = cm_id_priv->initiator_depth;
-                               /* fall through */
+                               fallthrough;
                        case IB_QPT_XRC_TGT:
                                *qp_attr_mask |= IB_QP_TIMEOUT;
                                qp_attr->timeout = cm_id_priv->av.timeout;
index 26de0da..7f0e91e 100644 (file)
@@ -1985,7 +1985,8 @@ static int cma_ib_handler(struct ib_cm_id *cm_id,
                event.event = RDMA_CM_EVENT_ESTABLISHED;
                break;
        case IB_CM_DREQ_ERROR:
-               event.status = -ETIMEDOUT; /* fall through */
+               event.status = -ETIMEDOUT;
+               fallthrough;
        case IB_CM_DREQ_RECEIVED:
        case IB_CM_DREP_RECEIVED:
                if (!cma_comp_exch(id_priv, RDMA_CM_CONNECT,
index 513825e..a92fc3f 100644 (file)
@@ -379,7 +379,7 @@ static int ib_alloc_cqs(struct ib_device *dev, unsigned int nr_cqes,
 {
        LIST_HEAD(tmp_list);
        unsigned int nr_cqs, i;
-       struct ib_cq *cq;
+       struct ib_cq *cq, *n;
        int ret;
 
        if (poll_ctx > IB_POLL_LAST_POOL_TYPE) {
@@ -412,7 +412,7 @@ static int ib_alloc_cqs(struct ib_device *dev, unsigned int nr_cqes,
        return 0;
 
 out_free_cqs:
-       list_for_each_entry(cq, &tmp_list, pool_entry) {
+       list_for_each_entry_safe(cq, n, &tmp_list, pool_entry) {
                cq->shared = false;
                ib_free_cq(cq);
        }
index ef0cd29..c36b4d2 100644 (file)
@@ -2751,7 +2751,7 @@ static int __init ib_core_init(void)
 
        ret = addr_init();
        if (ret) {
-               pr_warn("Could't init IB address resolution\n");
+               pr_warn("Couldn't init IB address resolution\n");
                goto err_ibnl;
        }
 
index 614cff8..13f43ab 100644 (file)
@@ -510,7 +510,6 @@ struct ib_send_wr *rdma_rw_ctx_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp,
        switch (ctx->type) {
        case RDMA_RW_SIG_MR:
        case RDMA_RW_MR:
-               /* fallthrough */
                for (i = 0; i < ctx->nr_ops; i++) {
                        rdma_rw_update_lkey(&ctx->reg[i],
                                ctx->reg[i].wr.wr.opcode !=
index d03daca..1d184ea 100644 (file)
@@ -794,7 +794,7 @@ static void ucma_copy_ib_route(struct rdma_ucm_query_route_resp *resp,
        case 2:
                ib_copy_path_rec_to_user(&resp->ib_route[1],
                                         &route->path_rec[1]);
-               /* fall through */
+               fallthrough;
        case 1:
                ib_copy_path_rec_to_user(&resp->ib_route[0],
                                         &route->path_rec[0]);
@@ -820,7 +820,7 @@ static void ucma_copy_iboe_route(struct rdma_ucm_query_route_resp *resp,
        case 2:
                ib_copy_path_rec_to_user(&resp->ib_route[1],
                                         &route->path_rec[1]);
-               /* fall through */
+               fallthrough;
        case 1:
                ib_copy_path_rec_to_user(&resp->ib_route[0],
                                         &route->path_rec[0]);
index ef04a26..e47c594 100644 (file)
@@ -259,7 +259,7 @@ static int uverbs_process_attr(struct bundle_priv *pbundle,
                        return -EOPNOTSUPP;
 
                e->ptr_attr.enum_id = uattr->attr_data.enum_data.elem_id;
-       /* fall through */
+               fallthrough;
        case UVERBS_ATTR_TYPE_PTR_IN:
                /* Ensure that any data provided by userspace beyond the known
                 * struct is zero. Userspace that knows how to use some future
@@ -271,7 +271,7 @@ static int uverbs_process_attr(struct bundle_priv *pbundle,
                    !uverbs_is_attr_cleared(uattr, val_spec->u.ptr.len))
                        return -EOPNOTSUPP;
 
-       /* fall through */
+               fallthrough;
        case UVERBS_ATTR_TYPE_PTR_OUT:
                if (uattr->len < val_spec->u.ptr.min_len ||
                    (!val_spec->zero_trailing &&
index 3096e73..3078867 100644 (file)
@@ -1801,7 +1801,7 @@ int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u8 *speed, u8 *width)
 
        dev_put(netdev);
 
-       if (!rc) {
+       if (!rc && lksettings.base.speed != (u32)SPEED_UNKNOWN) {
                netdev_speed = lksettings.base.speed;
        } else {
                netdev_speed = SPEED_1000;
index 3f18efc..1d7a9ca 100644 (file)
@@ -752,12 +752,6 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
        gsi_sqp = rdev->gsi_ctx.gsi_sqp;
        gsi_sah = rdev->gsi_ctx.gsi_sah;
 
-       /* remove from active qp list */
-       mutex_lock(&rdev->qp_lock);
-       list_del(&gsi_sqp->list);
-       mutex_unlock(&rdev->qp_lock);
-       atomic_dec(&rdev->qp_count);
-
        ibdev_dbg(&rdev->ibdev, "Destroy the shadow AH\n");
        bnxt_qplib_destroy_ah(&rdev->qplib_res,
                              &gsi_sah->qplib_ah,
@@ -772,6 +766,12 @@ static int bnxt_re_destroy_gsi_sqp(struct bnxt_re_qp *qp)
        }
        bnxt_qplib_free_qp_res(&rdev->qplib_res, &gsi_sqp->qplib_qp);
 
+       /* remove from active qp list */
+       mutex_lock(&rdev->qp_lock);
+       list_del(&gsi_sqp->list);
+       mutex_unlock(&rdev->qp_lock);
+       atomic_dec(&rdev->qp_count);
+
        kfree(rdev->gsi_ctx.sqp_tbl);
        kfree(gsi_sah);
        kfree(gsi_sqp);
@@ -792,11 +792,6 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
        unsigned int flags;
        int rc;
 
-       mutex_lock(&rdev->qp_lock);
-       list_del(&qp->list);
-       mutex_unlock(&rdev->qp_lock);
-       atomic_dec(&rdev->qp_count);
-
        bnxt_qplib_flush_cqn_wq(&qp->qplib_qp);
 
        rc = bnxt_qplib_destroy_qp(&rdev->qplib_res, &qp->qplib_qp);
@@ -819,6 +814,11 @@ int bnxt_re_destroy_qp(struct ib_qp *ib_qp, struct ib_udata *udata)
                        goto sh_fail;
        }
 
+       mutex_lock(&rdev->qp_lock);
+       list_del(&qp->list);
+       mutex_unlock(&rdev->qp_lock);
+       atomic_dec(&rdev->qp_count);
+
        ib_umem_release(qp->rumem);
        ib_umem_release(qp->sumem);
 
@@ -2657,7 +2657,7 @@ int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr,
                        default:
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                case IB_WR_SEND_WITH_INV:
                        rc = bnxt_re_build_send_wqe(qp, wr, &wqe);
                        break;
@@ -3264,6 +3264,19 @@ static void bnxt_re_process_res_rawqp1_wc(struct ib_wc *wc,
        wc->wc_flags |= IB_WC_GRH;
 }
 
+static bool bnxt_re_check_if_vlan_valid(struct bnxt_re_dev *rdev,
+                                       u16 vlan_id)
+{
+       /*
+        * Check if the vlan is configured in the host.  If not configured, it
+        * can be a transparent VLAN. So dont report the vlan id.
+        */
+       if (!__vlan_find_dev_deep_rcu(rdev->netdev,
+                                     htons(ETH_P_8021Q), vlan_id))
+               return false;
+       return true;
+}
+
 static bool bnxt_re_is_vlan_pkt(struct bnxt_qplib_cqe *orig_cqe,
                                u16 *vid, u8 *sl)
 {
@@ -3332,9 +3345,11 @@ static void bnxt_re_process_res_shadow_qp_wc(struct bnxt_re_qp *gsi_sqp,
        wc->src_qp = orig_cqe->src_qp;
        memcpy(wc->smac, orig_cqe->smac, ETH_ALEN);
        if (bnxt_re_is_vlan_pkt(orig_cqe, &vlan_id, &sl)) {
-               wc->vlan_id = vlan_id;
-               wc->sl = sl;
-               wc->wc_flags |= IB_WC_WITH_VLAN;
+               if (bnxt_re_check_if_vlan_valid(rdev, vlan_id)) {
+                       wc->vlan_id = vlan_id;
+                       wc->sl = sl;
+                       wc->wc_flags |= IB_WC_WITH_VLAN;
+               }
        }
        wc->port_num = 1;
        wc->vendor_err = orig_cqe->status;
index dad0df8..53aee5a 100644 (file)
@@ -821,7 +821,8 @@ static int bnxt_re_handle_qp_async_event(struct creq_qp_event *qp_event,
        struct ib_event event;
        unsigned int flags;
 
-       if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR) {
+       if (qp->qplib_qp.state == CMDQ_MODIFY_QP_NEW_STATE_ERR &&
+           rdma_is_kernel_res(&qp->ib_qp.res)) {
                flags = bnxt_re_lock_cqs(qp);
                bnxt_qplib_add_flush_qp(&qp->qplib_qp);
                bnxt_re_unlock_cqs(qp, flags);
@@ -1008,7 +1009,6 @@ static void bnxt_re_free_res(struct bnxt_re_dev *rdev)
 static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
 {
        struct bnxt_re_ring_attr rattr = {};
-       struct bnxt_qplib_ctx *qplib_ctx;
        int num_vec_created = 0;
        int rc = 0, i;
        u8 type;
@@ -1031,13 +1031,11 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
        if (rc)
                goto dealloc_res;
 
-       qplib_ctx = &rdev->qplib_ctx;
        for (i = 0; i < rdev->num_msix - 1; i++) {
                struct bnxt_qplib_nq *nq;
 
                nq = &rdev->nq[i];
-               nq->hwq.max_elements = (qplib_ctx->cq_count +
-                                       qplib_ctx->srqc_count + 2);
+               nq->hwq.max_elements = BNXT_QPLIB_NQE_MAX_CNT;
                rc = bnxt_qplib_alloc_nq(&rdev->qplib_res, &rdev->nq[i]);
                if (rc) {
                        ibdev_err(&rdev->ibdev, "Alloc Failed NQ%d rc:%#x",
index 117b423..f78da54 100644 (file)
@@ -818,6 +818,7 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
        u16 cmd_flags = 0;
        u32 qp_flags = 0;
        u8 pg_sz_lvl;
+       u32 tbl_indx;
        int rc;
 
        RCFW_CMD_PREP(req, CREATE_QP1, cmd_flags);
@@ -907,8 +908,9 @@ int bnxt_qplib_create_qp1(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
                rq->dbinfo.db = qp->dpi->dbr;
                rq->dbinfo.max_slot = bnxt_qplib_set_rq_max_slot(rq->wqe_size);
        }
-       rcfw->qp_tbl[qp->id].qp_id = qp->id;
-       rcfw->qp_tbl[qp->id].qp_handle = (void *)qp;
+       tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
+       rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
+       rcfw->qp_tbl[tbl_indx].qp_handle = (void *)qp;
 
        return 0;
 
@@ -935,10 +937,10 @@ static void bnxt_qplib_init_psn_ptr(struct bnxt_qplib_qp *qp, int size)
 
        sq = &qp->sq;
        hwq = &sq->hwq;
+       /* First psn entry */
        fpsne = (u64)bnxt_qplib_get_qe(hwq, hwq->depth, &psn_pg);
        if (!IS_ALIGNED(fpsne, PAGE_SIZE))
-               indx_pad = ALIGN(fpsne, PAGE_SIZE) / size;
-
+               indx_pad = (fpsne & ~PAGE_MASK) / size;
        hwq->pad_pgofft = indx_pad;
        hwq->pad_pg = (u64 *)psn_pg;
        hwq->pad_stride = size;
@@ -959,6 +961,7 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
        u16 cmd_flags = 0;
        u32 qp_flags = 0;
        u8 pg_sz_lvl;
+       u32 tbl_indx;
        u16 nsge;
 
        RCFW_CMD_PREP(req, CREATE_QP, cmd_flags);
@@ -1111,8 +1114,9 @@ int bnxt_qplib_create_qp(struct bnxt_qplib_res *res, struct bnxt_qplib_qp *qp)
                rq->dbinfo.db = qp->dpi->dbr;
                rq->dbinfo.max_slot = bnxt_qplib_set_rq_max_slot(rq->wqe_size);
        }
-       rcfw->qp_tbl[qp->id].qp_id = qp->id;
-       rcfw->qp_tbl[qp->id].qp_handle = (void *)qp;
+       tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
+       rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
+       rcfw->qp_tbl[tbl_indx].qp_handle = (void *)qp;
 
        return 0;
 fail:
@@ -1457,10 +1461,12 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,
        struct cmdq_destroy_qp req;
        struct creq_destroy_qp_resp resp;
        u16 cmd_flags = 0;
+       u32 tbl_indx;
        int rc;
 
-       rcfw->qp_tbl[qp->id].qp_id = BNXT_QPLIB_QP_ID_INVALID;
-       rcfw->qp_tbl[qp->id].qp_handle = NULL;
+       tbl_indx = map_qp_id_to_tbl_indx(qp->id, rcfw);
+       rcfw->qp_tbl[tbl_indx].qp_id = BNXT_QPLIB_QP_ID_INVALID;
+       rcfw->qp_tbl[tbl_indx].qp_handle = NULL;
 
        RCFW_CMD_PREP(req, DESTROY_QP, cmd_flags);
 
@@ -1468,8 +1474,8 @@ int bnxt_qplib_destroy_qp(struct bnxt_qplib_res *res,
        rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req,
                                          (void *)&resp, NULL, 0);
        if (rc) {
-               rcfw->qp_tbl[qp->id].qp_id = qp->id;
-               rcfw->qp_tbl[qp->id].qp_handle = qp;
+               rcfw->qp_tbl[tbl_indx].qp_id = qp->id;
+               rcfw->qp_tbl[tbl_indx].qp_handle = qp;
                return rc;
        }
 
@@ -1779,7 +1785,7 @@ int bnxt_qplib_post_send(struct bnxt_qplib_qp *qp,
 
                        break;
                }
-               /* fall thru */
+               fallthrough;
        case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_IMM:
        case BNXT_QPLIB_SWQE_TYPE_SEND_WITH_INV:
        {
index 4e21116..f7736e3 100644 (file)
@@ -307,14 +307,15 @@ static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw,
        __le16  mcookie;
        u16 cookie;
        int rc = 0;
-       u32 qp_id;
+       u32 qp_id, tbl_indx;
 
        pdev = rcfw->pdev;
        switch (qp_event->event) {
        case CREQ_QP_EVENT_EVENT_QP_ERROR_NOTIFICATION:
                err_event = (struct creq_qp_error_notification *)qp_event;
                qp_id = le32_to_cpu(err_event->xid);
-               qp = rcfw->qp_tbl[qp_id].qp_handle;
+               tbl_indx = map_qp_id_to_tbl_indx(qp_id, rcfw);
+               qp = rcfw->qp_tbl[tbl_indx].qp_handle;
                dev_dbg(&pdev->dev, "Received QP error notification\n");
                dev_dbg(&pdev->dev,
                        "qpid 0x%x, req_err=0x%x, resp_err=0x%x\n",
@@ -615,8 +616,9 @@ int bnxt_qplib_alloc_rcfw_channel(struct bnxt_qplib_res *res,
 
        cmdq->bmap_size = bmap_size;
 
-       rcfw->qp_tbl_size = qp_tbl_sz;
-       rcfw->qp_tbl = kcalloc(qp_tbl_sz, sizeof(struct bnxt_qplib_qp_node),
+       /* Allocate one extra to hold the QP1 entries */
+       rcfw->qp_tbl_size = qp_tbl_sz + 1;
+       rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node),
                               GFP_KERNEL);
        if (!rcfw->qp_tbl)
                goto fail;
index 1573876..5f2f0a5 100644 (file)
@@ -216,4 +216,9 @@ int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw);
 int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw,
                         struct bnxt_qplib_ctx *ctx, int is_virtfn);
 void bnxt_qplib_mark_qp_error(void *qp_handle);
+static inline u32 map_qp_id_to_tbl_indx(u32 qid, struct bnxt_qplib_rcfw *rcfw)
+{
+       /* Last index of the qp_tbl is for QP1 ie. qp_tbl_size - 1*/
+       return (qid == 1) ? rcfw->qp_tbl_size - 1 : qid % rcfw->qp_tbl_size - 2;
+}
 #endif /* __BNXT_QPLIB_RCFW_H__ */
index 4cd475e..64d44f5 100644 (file)
@@ -149,7 +149,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw,
        attr->max_inline_data = le32_to_cpu(sb->max_inline_data);
        attr->l2_db_size = (sb->l2_db_space_size + 1) *
                            (0x01 << RCFW_DBR_BASE_PAGE_SHIFT);
-       attr->max_sgid = le32_to_cpu(sb->max_gid);
+       attr->max_sgid = BNXT_QPLIB_NUM_GIDS_SUPPORTED;
 
        bnxt_qplib_query_version(rcfw, attr->fw_ver);
 
index 6404f0d..967890c 100644 (file)
@@ -47,6 +47,7 @@
 struct bnxt_qplib_dev_attr {
 #define FW_VER_ARR_LEN                 4
        u8                              fw_ver[FW_VER_ARR_LEN];
+#define BNXT_QPLIB_NUM_GIDS_SUPPORTED  256
        u16                             max_sgid;
        u16                             max_mrw;
        u32                             max_qp;
index 77bc02a..1f288c7 100644 (file)
@@ -2885,7 +2885,7 @@ static int peer_abort(struct c4iw_dev *dev, struct sk_buff *skb)
        case MORIBUND:
        case CLOSING:
                stop_ep_timer(ep);
-               /*FALLTHROUGH*/
+               fallthrough;
        case FPDU_MODE:
                if (ep->com.qp && ep->com.qp->srq) {
                        srqidx = ABORT_RSS_SRQIDX_G(
@@ -3759,7 +3759,7 @@ static void active_ofld_conn_reply(struct c4iw_dev *dev, struct sk_buff *skb,
                        send_fw_act_open_req(ep, atid);
                        return;
                }
-               /* fall through */
+               fallthrough;
        case FW_EADDRINUSE:
                set_bit(ACT_RETRY_INUSE, &ep->com.history);
                if (ep->retry_count++ < ACT_OPEN_RETRY_COUNT) {
index ac48012..cbddb20 100644 (file)
@@ -1165,7 +1165,7 @@ int c4iw_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
                                break;
                        }
                        fw_flags |= FW_RI_RDMA_WRITE_WITH_IMMEDIATE;
-                       /*FALLTHROUGH*/
+                       fallthrough;
                case IB_WR_RDMA_WRITE:
                        fw_opcode = FW_RI_RDMA_WRITE_WR;
                        swsqe->opcode = FW_RI_RDMA_WRITE;
index b12e466..4a4ec23 100644 (file)
@@ -209,7 +209,6 @@ static inline void jcopy(u8 *dest, const u8 *src, u32 n)
                fallthrough;
        case 1:
                *dest++ = *src++;
-               /* fall through */
        }
 }
 
index 9af82ff..73d197e 100644 (file)
@@ -3215,6 +3215,7 @@ bool hfi1_tid_rdma_wqe_interlock(struct rvt_qp *qp, struct rvt_swqe *wqe)
        case IB_WR_ATOMIC_CMP_AND_SWP:
        case IB_WR_ATOMIC_FETCH_AND_ADD:
        case IB_WR_RDMA_WRITE:
+       case IB_WR_RDMA_WRITE_WITH_IMM:
                switch (prev->wr.opcode) {
                case IB_WR_TID_RDMA_WRITE:
                        req = wqe_to_tid_req(prev);
index da9888d..6edcbdc 100644 (file)
@@ -65,8 +65,6 @@
 #define HNS_ROCE_CQE_WCMD_EMPTY_BIT            0x2
 #define HNS_ROCE_MIN_CQE_CNT                   16
 
-#define HNS_ROCE_RESERVED_SGE                  1
-
 #define HNS_ROCE_MAX_IRQ_NUM                   128
 
 #define HNS_ROCE_SGE_IN_WQE                    2
index 07b4c85..aeb3a6f 100644 (file)
@@ -535,7 +535,7 @@ static void hns_roce_set_sdb_ext(struct hns_roce_dev *hr_dev, u32 ext_sdb_alept,
        roce_write(hr_dev, ROCEE_EXT_DB_SQ_H_REG, val);
 
        dev_dbg(dev, "ext SDB depth: 0x%x\n", db->ext_db->esdb_dep);
-       dev_dbg(dev, "ext SDB threshold: epmty: 0x%x, ful: 0x%x\n",
+       dev_dbg(dev, "ext SDB threshold: empty: 0x%x, ful: 0x%x\n",
                ext_sdb_alept, ext_sdb_alful);
 }
 
index d296859..4cda95e 100644 (file)
@@ -633,7 +633,7 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
 
                wqe_idx = (hr_qp->rq.head + nreq) & (hr_qp->rq.wqe_cnt - 1);
 
-               if (unlikely(wr->num_sge >= hr_qp->rq.max_gs)) {
+               if (unlikely(wr->num_sge > hr_qp->rq.max_gs)) {
                        ibdev_err(ibdev, "rq:num_sge=%d >= qp->sq.max_gs=%d\n",
                                  wr->num_sge, hr_qp->rq.max_gs);
                        ret = -EINVAL;
@@ -653,7 +653,6 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp,
                if (wr->num_sge < hr_qp->rq.max_gs) {
                        dseg->lkey = cpu_to_le32(HNS_ROCE_INVALID_LKEY);
                        dseg->addr = 0;
-                       dseg->len = cpu_to_le32(HNS_ROCE_INVALID_SGE_LENGTH);
                }
 
                /* rq support inline data */
@@ -787,8 +786,8 @@ static int hns_roce_v2_post_srq_recv(struct ib_srq *ibsrq,
                }
 
                if (wr->num_sge < srq->max_gs) {
-                       dseg[i].len = cpu_to_le32(HNS_ROCE_INVALID_SGE_LENGTH);
-                       dseg[i].lkey = cpu_to_le32(HNS_ROCE_INVALID_LKEY);
+                       dseg[i].len = 0;
+                       dseg[i].lkey = cpu_to_le32(0x100);
                        dseg[i].addr = 0;
                }
 
@@ -5070,7 +5069,7 @@ static int hns_roce_v2_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr)
 
        attr->srq_limit = limit_wl;
        attr->max_wr = srq->wqe_cnt - 1;
-       attr->max_sge = srq->max_gs - HNS_ROCE_RESERVED_SGE;
+       attr->max_sge = srq->max_gs;
 
 out:
        hns_roce_free_cmd_mailbox(hr_dev, mailbox);
index 1fb1c58..ac29be4 100644 (file)
@@ -92,9 +92,7 @@
 #define HNS_ROCE_V2_CQC_TIMER_ENTRY_SZ         PAGE_SIZE
 #define HNS_ROCE_V2_PAGE_SIZE_SUPPORTED                0xFFFFF000
 #define HNS_ROCE_V2_MAX_INNER_MTPT_NUM         2
-#define HNS_ROCE_INVALID_LKEY                  0x0
-#define HNS_ROCE_INVALID_SGE_LENGTH            0x80000000
-
+#define HNS_ROCE_INVALID_LKEY                  0x100
 #define HNS_ROCE_CMQ_TX_TIMEOUT                        30000
 #define HNS_ROCE_V2_UC_RC_SGE_NUM_IN_WQE       2
 #define HNS_ROCE_V2_RSV_QPS                    8
index e94ca13..c063c45 100644 (file)
@@ -386,8 +386,7 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap,
                return -EINVAL;
        }
 
-       hr_qp->rq.max_gs = roundup_pow_of_two(max(1U, cap->max_recv_sge) +
-                                             HNS_ROCE_RESERVED_SGE);
+       hr_qp->rq.max_gs = roundup_pow_of_two(max(1U, cap->max_recv_sge));
 
        if (hr_dev->caps.max_rq_sg <= HNS_ROCE_SGE_IN_WQE)
                hr_qp->rq.wqe_shift = ilog2(hr_dev->caps.max_rq_desc_sz);
@@ -402,7 +401,7 @@ static int set_rq_size(struct hns_roce_dev *hr_dev, struct ib_qp_cap *cap,
                hr_qp->rq_inl_buf.wqe_cnt = 0;
 
        cap->max_recv_wr = cnt;
-       cap->max_recv_sge = hr_qp->rq.max_gs - HNS_ROCE_RESERVED_SGE;
+       cap->max_recv_sge = hr_qp->rq.max_gs;
 
        return 0;
 }
index f40a000..b9e2dbd 100644 (file)
@@ -297,7 +297,7 @@ int hns_roce_create_srq(struct ib_srq *ib_srq,
        spin_lock_init(&srq->lock);
 
        srq->wqe_cnt = roundup_pow_of_two(init_attr->attr.max_wr + 1);
-       srq->max_gs = init_attr->attr.max_sge + HNS_ROCE_RESERVED_SGE;
+       srq->max_gs = init_attr->attr.max_sge;
 
        if (udata) {
                ret = ib_copy_from_udata(&ucmd, udata, sizeof(ucmd));
index fa7a5ff..a3b9580 100644 (file)
@@ -2443,7 +2443,7 @@ static void i40iw_handle_rst_pkt(struct i40iw_cm_node *cm_node,
        case I40IW_CM_STATE_FIN_WAIT1:
        case I40IW_CM_STATE_LAST_ACK:
                cm_node->cm_id->rem_ref(cm_node->cm_id);
-               /* fall through */
+               fallthrough;
        case I40IW_CM_STATE_TIME_WAIT:
                cm_node->state = I40IW_CM_STATE_CLOSED;
                i40iw_rem_ref_cm_node(cm_node);
index 688f196..86d3f8a 100644 (file)
@@ -1964,7 +1964,6 @@ static enum i40iw_status_code i40iw_sc_get_next_aeqe(struct i40iw_sc_aeq *aeq,
                info->out_rdrsp = true;
                break;
        case I40IW_AE_SOURCE_RSVD:
-               /* fallthrough */
        default:
                break;
        }
@@ -3762,14 +3761,14 @@ static enum i40iw_status_code cqp_sds_wqe_fill(struct i40iw_sc_cqp *cqp,
                                        LS_64(1, I40IW_CQPSQ_UPESD_ENTRY_VALID)));
 
                set_64bit_val(wqe, 56, info->entry[2].data);
-               /* fallthrough */
+               fallthrough;
        case 2:
                set_64bit_val(wqe, 32,
                              (LS_64(info->entry[1].cmd, I40IW_CQPSQ_UPESD_SDCMD) |
                                        LS_64(1, I40IW_CQPSQ_UPESD_ENTRY_VALID)));
 
                set_64bit_val(wqe, 40, info->entry[1].data);
-               /* fallthrough */
+               fallthrough;
        case 1:
                set_64bit_val(wqe, 0,
                              LS_64(info->entry[0].cmd, I40IW_CQPSQ_UPESD_SDCMD));
index ae8b97c..e108563 100644 (file)
@@ -353,7 +353,6 @@ void i40iw_process_aeq(struct i40iw_device *iwdev)
                                i40iw_cm_disconn(iwqp);
                        break;
                case I40IW_AE_BAD_CLOSE:
-                       /* fall through */
                case I40IW_AE_RESET_SENT:
                        i40iw_next_iw_state(iwqp, I40IW_QP_STATE_ERROR, 1, 0, 0);
                        i40iw_cm_disconn(iwqp);
@@ -413,7 +412,7 @@ void i40iw_process_aeq(struct i40iw_device *iwdev)
                case I40IW_AE_UDA_XMIT_DGRAM_TOO_LONG:
                case I40IW_AE_UDA_XMIT_DGRAM_TOO_SHORT:
                        ctx_info->err_rq_idx_valid = false;
-                       /* fall through */
+                       fallthrough;
                default:
                        if (!info->sq && ctx_info->err_rq_idx_valid) {
                                ctx_info->err_rq_idx = info->wqe_idx;
index 9c96ece..58a4331 100644 (file)
@@ -1489,36 +1489,35 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev)
                iwdev->iw_status = 0;
                i40iw_port_ibevent(iwdev);
                i40iw_destroy_rdma_device(iwdev->iwibdev);
-               /* fallthrough */
+               fallthrough;
        case IP_ADDR_REGISTERED:
                if (!iwdev->reset)
                        i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
-               /* fallthrough */
-               /* fallthrough */
+               fallthrough;
        case PBLE_CHUNK_MEM:
                i40iw_destroy_pble_pool(dev, iwdev->pble_rsrc);
-               /* fallthrough */
+               fallthrough;
        case CEQ_CREATED:
                i40iw_dele_ceqs(iwdev);
-               /* fallthrough */
+               fallthrough;
        case AEQ_CREATED:
                i40iw_destroy_aeq(iwdev);
-               /* fallthrough */
+               fallthrough;
        case IEQ_CREATED:
                i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_IEQ, iwdev->reset);
-               /* fallthrough */
+               fallthrough;
        case ILQ_CREATED:
                i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_ILQ, iwdev->reset);
-               /* fallthrough */
+               fallthrough;
        case CCQ_CREATED:
                i40iw_destroy_ccq(iwdev);
-               /* fallthrough */
+               fallthrough;
        case HMC_OBJS_CREATED:
                i40iw_del_hmc_objects(dev, dev->hmc_info, true, iwdev->reset);
-               /* fallthrough */
+               fallthrough;
        case CQP_CREATED:
                i40iw_destroy_cqp(iwdev, true);
-               /* fallthrough */
+               fallthrough;
        case INITIAL_STATE:
                i40iw_cleanup_cm_core(&iwdev->cm_core);
                if (iwdev->vsi.pestat) {
@@ -1528,7 +1527,6 @@ static void i40iw_deinit_device(struct i40iw_device *iwdev)
                i40iw_del_init_mem(iwdev);
                break;
        case INVALID_STATE:
-               /* fallthrough */
        default:
                i40iw_pr_err("bad init_state = %d\n", iwdev->init_state);
                break;
index d9c7ae6..924be4b 100644 (file)
@@ -814,13 +814,13 @@ void i40iw_puda_dele_resources(struct i40iw_sc_vsi *vsi,
        switch (rsrc->completion) {
        case PUDA_HASH_CRC_COMPLETE:
                i40iw_free_hash_desc(rsrc->hash_desc);
-               /* fall through */
+               fallthrough;
        case PUDA_QP_CREATED:
                if (!reset)
                        i40iw_puda_free_qp(rsrc);
 
                i40iw_free_dma_mem(dev->hw, &rsrc->qpmem);
-               /* fallthrough */
+               fallthrough;
        case PUDA_CQ_CREATED:
                if (!reset)
                        i40iw_puda_free_cq(rsrc);
index 0165246..e07fb37 100644 (file)
@@ -190,9 +190,8 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,
        switch (event) {
        case NETDEV_DOWN:
                action = I40IW_ARP_DELETE;
-               /* Fall through */
+               fallthrough;
        case NETDEV_UP:
-               /* Fall through */
        case NETDEV_CHANGEADDR:
 
                /* Just skip if no need to handle ARP cache */
@@ -247,9 +246,8 @@ int i40iw_inet6addr_event(struct notifier_block *notifier,
        switch (event) {
        case NETDEV_DOWN:
                action = I40IW_ARP_DELETE;
-               /* Fall through */
+               fallthrough;
        case NETDEV_UP:
-               /* Fall through */
        case NETDEV_CHANGEADDR:
                i40iw_manage_arp_cache(iwdev,
                                       netdev->dev_addr,
@@ -344,7 +342,7 @@ int i40iw_netdevice_event(struct notifier_block *notifier,
        switch (event) {
        case NETDEV_DOWN:
                iwdev->iw_status = 0;
-               /* Fall through */
+               fallthrough;
        case NETDEV_UP:
                i40iw_port_ibevent(iwdev);
                break;
index 6957e4f..b513393 100644 (file)
@@ -810,7 +810,7 @@ void i40iw_hw_modify_qp(struct i40iw_device *iwdev, struct i40iw_qp *iwqp,
        case I40IW_QP_STATE_RTS:
                if (iwqp->iwarp_state == I40IW_QP_STATE_IDLE)
                        i40iw_send_reset(iwqp->cm_node);
-               /* fall through */
+               fallthrough;
        case I40IW_QP_STATE_IDLE:
        case I40IW_QP_STATE_TERMINATE:
        case I40IW_QP_STATE_CLOSING:
@@ -2144,7 +2144,6 @@ static int i40iw_post_send(struct ib_qp *ibqp,
 
                switch (ib_wr->opcode) {
                case IB_WR_SEND:
-                       /* fall-through */
                case IB_WR_SEND_WITH_INV:
                        if (ib_wr->opcode == IB_WR_SEND) {
                                if (ib_wr->send_flags & IB_SEND_SOLICITED)
@@ -2201,7 +2200,7 @@ static int i40iw_post_send(struct ib_qp *ibqp,
                        break;
                case IB_WR_RDMA_READ_WITH_INV:
                        inv_stag = true;
-                       /* fall-through*/
+                       fallthrough;
                case IB_WR_RDMA_READ:
                        if (ib_wr->num_sge > I40IW_MAX_SGE_RD) {
                                err = -EINVAL;
index f8b936b..8a34369 100644 (file)
@@ -765,13 +765,13 @@ repoll:
                switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
                case MLX4_OPCODE_RDMA_WRITE_IMM:
                        wc->wc_flags |= IB_WC_WITH_IMM;
-                       /* fall through */
+                       fallthrough;
                case MLX4_OPCODE_RDMA_WRITE:
                        wc->opcode    = IB_WC_RDMA_WRITE;
                        break;
                case MLX4_OPCODE_SEND_IMM:
                        wc->wc_flags |= IB_WC_WITH_IMM;
-                       /* fall through */
+                       fallthrough;
                case MLX4_OPCODE_SEND:
                case MLX4_OPCODE_SEND_INVAL:
                        wc->opcode    = IB_WC_SEND;
index 5e7910a..bd4f975 100644 (file)
@@ -784,7 +784,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
        props->ip_gids = true;
        props->gid_tbl_len      = mdev->dev->caps.gid_table_len[port];
        props->max_msg_sz       = mdev->dev->caps.max_msg_sz;
-       props->pkey_tbl_len     = 1;
+       if (mdev->dev->caps.pkey_table_len[port])
+               props->pkey_tbl_len = 1;
        props->max_mtu          = IB_MTU_4096;
        props->max_vl_num       = 2;
        props->state            = IB_PORT_DOWN;
index d844831..5e4ec97 100644 (file)
@@ -944,7 +944,7 @@ int mlx4_ib_mcg_multiplex_handler(struct ib_device *ibdev, int port,
        switch (sa_mad->mad_hdr.method) {
        case IB_MGMT_METHOD_SET:
                may_create = 1;
-               /* fall through */
+               fallthrough;
        case IB_SA_METHOD_DELETE:
                req = kzalloc(sizeof *req, GFP_KERNEL);
                if (!req)
index f9ca6e0..2975f35 100644 (file)
@@ -1578,12 +1578,12 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
                pd = to_mxrcd(init_attr->xrcd)->pd;
                xrcdn = to_mxrcd(init_attr->xrcd)->xrcdn;
                init_attr->send_cq = to_mxrcd(init_attr->xrcd)->cq;
-               /* fall through */
+               fallthrough;
        case IB_QPT_XRC_INI:
                if (!(to_mdev(pd->device)->dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC))
                        return ERR_PTR(-ENOSYS);
                init_attr->recv_cq = init_attr->send_cq;
-               /* fall through */
+               fallthrough;
        case IB_QPT_RC:
        case IB_QPT_UC:
        case IB_QPT_RAW_PACKET:
@@ -1592,7 +1592,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd,
                        return ERR_PTR(-ENOMEM);
                qp->pri.vid = 0xFFFF;
                qp->alt.vid = 0xFFFF;
-               /* fall through */
+               fallthrough;
        case IB_QPT_UD:
        {
                err = create_qp_common(pd, init_attr, udata, 0, &qp);
index 0133ebb..dceb0eb 100644 (file)
@@ -121,13 +121,13 @@ static void handle_good_req(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
        switch (be32_to_cpu(cqe->sop_drop_qpn) >> 24) {
        case MLX5_OPCODE_RDMA_WRITE_IMM:
                wc->wc_flags |= IB_WC_WITH_IMM;
-               /* fall through */
+               fallthrough;
        case MLX5_OPCODE_RDMA_WRITE:
                wc->opcode    = IB_WC_RDMA_WRITE;
                break;
        case MLX5_OPCODE_SEND_IMM:
                wc->wc_flags |= IB_WC_WITH_IMM;
-               /* fall through */
+               fallthrough;
        case MLX5_OPCODE_SEND:
        case MLX5_OPCODE_SEND_INVAL:
                wc->opcode    = IB_WC_SEND;
index 454ce5d..9bb9bb0 100644 (file)
@@ -250,9 +250,8 @@ int mlx5_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
                if (MLX5_CAP_GEN(dev->mdev, vport_counters) &&
                    method == IB_MGMT_METHOD_GET)
                        return process_pma_cmd(dev, port_num, in, out);
-               /* fallthrough */
+               fallthrough;
        case MLX5_IB_VENDOR_CLASS1:
-               /* fallthrough */
        case MLX5_IB_VENDOR_CLASS2:
        case IB_MGMT_CLASS_CONG_MGMT: {
                if (method != IB_MGMT_METHOD_GET &&
index fbc45a5..d60d632 100644 (file)
@@ -2872,7 +2872,7 @@ static void mlx5_ib_handle_event(struct work_struct *_work)
                break;
        case MLX5_EVENT_TYPE_GENERAL_EVENT:
                handle_general_event(ibdev, work->param, &ibev);
-               /* fall through */
+               fallthrough;
        default:
                goto out;
        }
index 59fce5f..5758dbe 100644 (file)
@@ -416,7 +416,7 @@ static int sq_overhead(struct ib_qp_init_attr *attr)
        switch (attr->qp_type) {
        case IB_QPT_XRC_INI:
                size += sizeof(struct mlx5_wqe_xrc_seg);
-               /* fall through */
+               fallthrough;
        case IB_QPT_RC:
                size += sizeof(struct mlx5_wqe_ctrl_seg) +
                        max(sizeof(struct mlx5_wqe_atomic_seg) +
@@ -441,7 +441,7 @@ static int sq_overhead(struct ib_qp_init_attr *attr)
                if (attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
                        size += sizeof(struct mlx5_wqe_eth_pad) +
                                sizeof(struct mlx5_wqe_eth_seg);
-               /* fall through */
+               fallthrough;
        case IB_QPT_SMI:
        case MLX5_IB_QPT_HW_GSI:
                size += sizeof(struct mlx5_wqe_ctrl_seg) +
index 0823c0b..f051f4e 100644 (file)
@@ -115,7 +115,7 @@ static u8 ib_rate_to_memfree(u8 req_rate, u8 cur_rate)
        switch ((cur_rate - 1) / req_rate) {
        case 0:  return MTHCA_RATE_MEMFREE_FULL;
        case 1:  return MTHCA_RATE_MEMFREE_HALF;
-       case 2:  /* fall through */
+       case 2:
        case 3:  return MTHCA_RATE_MEMFREE_QUARTER;
        default: return MTHCA_RATE_MEMFREE_EIGHTH;
        }
index 6cdbec1..c1751c9 100644 (file)
@@ -2134,7 +2134,7 @@ int ocrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
                case IB_WR_SEND_WITH_IMM:
                        hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT);
                        hdr->immdt = ntohl(wr->ex.imm_data);
-                       /* fall through */
+                       fallthrough;
                case IB_WR_SEND:
                        hdr->cw |= (OCRDMA_SEND << OCRDMA_WQE_OPCODE_SHIFT);
                        ocrdma_build_send(qp, hdr, wr);
@@ -2148,7 +2148,7 @@ int ocrdma_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
                case IB_WR_RDMA_WRITE_WITH_IMM:
                        hdr->cw |= (OCRDMA_FLAG_IMM << OCRDMA_WQE_FLAGS_SHIFT);
                        hdr->immdt = ntohl(wr->ex.imm_data);
-                       /* fall through */
+                       fallthrough;
                case IB_WR_RDMA_WRITE:
                        hdr->cw |= (OCRDMA_WRITE << OCRDMA_WQE_OPCODE_SHIFT);
                        status = ocrdma_build_write(qp, hdr, wr);
index 4ce4e2e..b49bef9 100644 (file)
@@ -3528,7 +3528,7 @@ static int __qedr_post_send(struct ib_qp *ibqp, const struct ib_send_wr *wr,
                break;
        case IB_WR_RDMA_READ_WITH_INV:
                SET_FIELD2(wqe->flags, RDMA_SQ_RDMA_WQE_1ST_READ_INV_FLG, 1);
-               /* fallthrough -- same is identical to RDMA READ */
+               fallthrough;    /* same is identical to RDMA READ */
 
        case IB_WR_RDMA_READ:
                wqe->req_type = RDMA_SQ_REQ_TYPE_RDMA_RD;
index ca5ea73..44150be 100644 (file)
@@ -2973,11 +2973,11 @@ static u32 qib_6120_iblink_state(u64 ibcs)
                state = IB_PORT_ARMED;
                break;
        case IB_6120_L_STATE_ACTIVE:
-               /* fall through */
        case IB_6120_L_STATE_ACT_DEFER:
                state = IB_PORT_ACTIVE;
                break;
-       default: /* fall through */
+       default:
+               fallthrough;
        case IB_6120_L_STATE_DOWN:
                state = IB_PORT_DOWN;
                break;
index ea3ddb0..0a6f26d 100644 (file)
@@ -3586,11 +3586,11 @@ static u32 qib_7220_iblink_state(u64 ibcs)
                state = IB_PORT_ARMED;
                break;
        case IB_7220_L_STATE_ACTIVE:
-               /* fall through */
        case IB_7220_L_STATE_ACT_DEFER:
                state = IB_PORT_ACTIVE;
                break;
-       default: /* fall through */
+       default:
+               fallthrough;
        case IB_7220_L_STATE_DOWN:
                state = IB_PORT_DOWN;
                break;
index 8bcbc88..a10eab8 100644 (file)
@@ -5508,11 +5508,11 @@ static u32 qib_7322_iblink_state(u64 ibcs)
                state = IB_PORT_ARMED;
                break;
        case IB_7322_L_STATE_ACTIVE:
-               /* fall through */
        case IB_7322_L_STATE_ACT_DEFER:
                state = IB_PORT_ACTIVE;
                break;
-       default: /* fall through */
+       default:
+               fallthrough;
        case IB_7322_L_STATE_DOWN:
                state = IB_PORT_DOWN;
                break;
@@ -6533,7 +6533,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
                                    "Invalid num_vls %u, using 4 VLs\n",
                                    qib_num_cfg_vls);
                        qib_num_cfg_vls = 4;
-                       /* fall through */
+                       fallthrough;
                case 4:
                        ppd->vls_supported = IB_VL_VL0_3;
                        break;
index 79bb832..e7789e7 100644 (file)
@@ -433,7 +433,7 @@ static int check_mkey(struct qib_ibport *ibp, struct ib_smp *smp, int mad_flags)
                        /* Bad mkey not a violation below level 2 */
                        if (ibp->rvp.mkeyprot < 2)
                                break;
-                       /* fall through */
+                       fallthrough;
                case IB_MGMT_METHOD_SET:
                case IB_MGMT_METHOD_TRAP_REPRESS:
                        if (ibp->rvp.mkey_violations != 0xFFFF)
@@ -828,7 +828,7 @@ static int subn_set_portinfo(struct ib_smp *smp, struct ib_device *ibdev,
        case IB_PORT_NOP:
                if (lstate == 0)
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        case IB_PORT_DOWN:
                if (lstate == 0)
                        lstate = QIB_IB_LINKDOWN_ONLY;
@@ -1928,7 +1928,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags,
                                ret = IB_MAD_RESULT_SUCCESS;
                                goto bail;
                        }
-                       /* FALLTHROUGH */
+                       fallthrough;
                default:
                        smp->status |= IB_SMP_UNSUP_METH_ATTR;
                        ret = reply(smp);
@@ -1962,7 +1962,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags,
                                ret = IB_MAD_RESULT_SUCCESS;
                                goto bail;
                        }
-                       /* FALLTHROUGH */
+                       fallthrough;
                default:
                        smp->status |= IB_SMP_UNSUP_METH_ATTR;
                        ret = reply(smp);
@@ -2322,7 +2322,7 @@ static int process_cc(struct ib_device *ibdev, int mad_flags,
                        ret = cc_get_congestion_control_table(ccp, ibdev, port);
                        goto bail;
 
-                       /* FALLTHROUGH */
+                       fallthrough;
                default:
                        ccp->status |= IB_SMP_UNSUP_METH_ATTR;
                        ret = reply((struct ib_smp *) ccp);
@@ -2339,7 +2339,7 @@ static int process_cc(struct ib_device *ibdev, int mad_flags,
                        ret = cc_set_congestion_control_table(ccp, ibdev, port);
                        goto bail;
 
-                       /* FALLTHROUGH */
+                       fallthrough;
                default:
                        ccp->status |= IB_SMP_UNSUP_METH_ATTR;
                        ret = reply((struct ib_smp *) ccp);
index aaf7438..3915e5b 100644 (file)
@@ -83,7 +83,7 @@ static int qib_make_rc_ack(struct qib_ibdev *dev, struct rvt_qp *qp,
                        rvt_put_mr(e->rdma_sge.mr);
                        e->rdma_sge.mr = NULL;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(ATOMIC_ACKNOWLEDGE):
                /*
                 * We can increment the tail pointer now that the last
@@ -92,7 +92,7 @@ static int qib_make_rc_ack(struct qib_ibdev *dev, struct rvt_qp *qp,
                 */
                if (++qp->s_tail_ack_queue > QIB_MAX_RDMA_ATOMIC)
                        qp->s_tail_ack_queue = 0;
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_ONLY):
        case OP(ACKNOWLEDGE):
                /* Check for no next entry in the queue. */
@@ -149,7 +149,7 @@ static int qib_make_rc_ack(struct qib_ibdev *dev, struct rvt_qp *qp,
 
        case OP(RDMA_READ_RESPONSE_FIRST):
                qp->s_ack_state = OP(RDMA_READ_RESPONSE_MIDDLE);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(RDMA_READ_RESPONSE_MIDDLE):
                qp->s_cur_sge = &qp->s_ack_rdma_sge;
                qp->s_rdma_mr = qp->s_ack_rdma_sge.sge.mr;
@@ -471,10 +471,10 @@ no_flow_control:
                 * See qib_restart_rc().
                 */
                qp->s_len = restart_sge(&qp->s_sge, wqe, qp->s_psn, pmtu);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_FIRST):
                qp->s_state = OP(SEND_MIDDLE);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_MIDDLE):
                bth2 = qp->s_psn++ & QIB_PSN_MASK;
                ss = &qp->s_sge;
@@ -510,10 +510,10 @@ no_flow_control:
                 * See qib_restart_rc().
                 */
                qp->s_len = restart_sge(&qp->s_sge, wqe, qp->s_psn, pmtu);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(RDMA_WRITE_FIRST):
                qp->s_state = OP(RDMA_WRITE_MIDDLE);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(RDMA_WRITE_MIDDLE):
                bth2 = qp->s_psn++ & QIB_PSN_MASK;
                ss = &qp->s_sge;
@@ -1807,7 +1807,7 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
                if (!ret)
                        goto rnr_nak;
                qp->r_rcv_len = 0;
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_MIDDLE):
        case OP(RDMA_WRITE_MIDDLE):
 send_middle:
@@ -1839,7 +1839,7 @@ send_middle:
                qp->r_rcv_len = 0;
                if (opcode == OP(SEND_ONLY))
                        goto no_immediate_data;
-               /* fall through -- for SEND_ONLY_WITH_IMMEDIATE */
+               fallthrough;    /* for SEND_ONLY_WITH_IMMEDIATE */
        case OP(SEND_LAST_WITH_IMMEDIATE):
 send_last_imm:
                wc.ex.imm_data = ohdr->u.imm_data;
index 99e11c3..8f8d617 100644 (file)
@@ -763,7 +763,7 @@ void __qib_sdma_process_event(struct qib_pportdata *ppd,
                         * bringing the link up with traffic active on
                         * 7220, e.g. */
                        ss->go_s99_running = 1;
-                       /* fall through -- and start dma engine */
+                       fallthrough;    /* and start dma engine */
                case qib_sdma_event_e10_go_hw_start:
                        /* This reference means the state machine is started */
                        sdma_get(&ppd->sdma_state);
index e17b91e..554af42 100644 (file)
@@ -161,7 +161,7 @@ int qib_make_uc_req(struct rvt_qp *qp, unsigned long *flags)
 
        case OP(SEND_FIRST):
                qp->s_state = OP(SEND_MIDDLE);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_MIDDLE):
                len = qp->s_len;
                if (len > pmtu) {
@@ -185,7 +185,7 @@ int qib_make_uc_req(struct rvt_qp *qp, unsigned long *flags)
 
        case OP(RDMA_WRITE_FIRST):
                qp->s_state = OP(RDMA_WRITE_MIDDLE);
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(RDMA_WRITE_MIDDLE):
                len = qp->s_len;
                if (len > pmtu) {
@@ -351,7 +351,7 @@ send_first:
                        goto no_immediate_data;
                else if (opcode == OP(SEND_ONLY_WITH_IMMEDIATE))
                        goto send_last_imm;
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(SEND_MIDDLE):
                /* Check for invalid length PMTU or posted rwqe len. */
                if (unlikely(tlen != (hdrsize + pmtu + 4)))
@@ -440,7 +440,7 @@ rdma_first:
                        wc.ex.imm_data = ohdr->u.rc.imm_data;
                        goto rdma_last_imm;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case OP(RDMA_WRITE_MIDDLE):
                /* Check for invalid length PMTU or posted rwqe len. */
                if (unlikely(tlen != (hdrsize + pmtu + 4)))
index 7acf9ba..f6c01ba 100644 (file)
@@ -237,7 +237,7 @@ static void qib_qp_rcv(struct qib_ctxtdata *rcd, struct ib_header *hdr,
        case IB_QPT_GSI:
                if (ib_qib_disable_sma)
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        case IB_QPT_UD:
                qib_ud_rcv(ibp, hdr, has_grh, data, tlen, qp);
                break;
index c9abe1c..662e7fc 100644 (file)
@@ -120,7 +120,7 @@ static void usnic_ib_qp_grp_modify_active_to_err(struct usnic_ib_dev *us_ibdev)
                                                                IB_QPS_ERR,
                                                                NULL);
                                if (status) {
-                                       usnic_err("Failed to transistion qp grp %u from %s to %s\n",
+                                       usnic_err("Failed to transition qp grp %u from %s to %s\n",
                                                qp_grp->grp_id,
                                                usnic_ib_qp_grp_state_to_string
                                                (cur_state),
index afcc2ab..9a8f2a9 100644 (file)
@@ -238,7 +238,7 @@ struct ib_qp *pvrdma_create_qp(struct ib_pd *pd,
                        ret = -EINVAL;
                        goto err_qp;
                }
-               /* fall through */
+               fallthrough;
        case IB_QPT_RC:
        case IB_QPT_UD:
                qp = kzalloc(sizeof(*qp), GFP_KERNEL);
index 332a8ba..ee48bef 100644 (file)
@@ -1111,7 +1111,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
                if (init_attr->port_num == 0 ||
                    init_attr->port_num > ibpd->device->phys_port_cnt)
                        return ERR_PTR(-EINVAL);
-               /* fall through */
+               fallthrough;
        case IB_QPT_UC:
        case IB_QPT_RC:
        case IB_QPT_UD:
index 907203a..77f2c7c 100644 (file)
@@ -40,6 +40,8 @@ MODULE_AUTHOR("Bob Pearson, Frank Zago, John Groves, Kamal Heib");
 MODULE_DESCRIPTION("Soft RDMA transport");
 MODULE_LICENSE("Dual BSD/GPL");
 
+bool rxe_initialized;
+
 /* free resources for a rxe device all objects created for this device must
  * have been destroyed
  */
@@ -315,6 +317,7 @@ static int __init rxe_module_init(void)
                return err;
 
        rdma_link_register(&rxe_link_ops);
+       rxe_initialized = true;
        pr_info("loaded\n");
        return 0;
 }
@@ -326,6 +329,7 @@ static void __exit rxe_module_exit(void)
        rxe_net_exit();
        rxe_cache_exit();
 
+       rxe_initialized = false;
        pr_info("unloaded\n");
 }
 
index fb07eed..cae1b0a 100644 (file)
@@ -67,6 +67,8 @@
 
 #define RXE_ROCE_V2_SPORT              (0xc000)
 
+extern bool rxe_initialized;
+
 static inline u32 rxe_crc32(struct rxe_dev *rxe,
                            u32 crc, void *next, size_t len)
 {
index 4bc8870..7b4df00 100644 (file)
@@ -282,7 +282,7 @@ static inline enum comp_state check_ack(struct rxe_qp *qp,
                if ((syn & AETH_TYPE_MASK) != AETH_ACK)
                        return COMPST_ERROR;
 
-               /* fall through */
+               fallthrough;
                /* (IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE doesn't have an AETH)
                 */
        case IB_OPCODE_RC_RDMA_READ_RESPONSE_MIDDLE:
index cdd811a..ce24144 100644 (file)
@@ -205,6 +205,7 @@ int rxe_mem_init_user(struct rxe_pd *pd, u64 start,
                        vaddr = page_address(sg_page_iter_page(&sg_iter));
                        if (!vaddr) {
                                pr_warn("null vaddr\n");
+                               ib_umem_release(umem);
                                err = -ENOMEM;
                                goto err1;
                        }
index ccda5f5..2af31d4 100644 (file)
@@ -61,6 +61,11 @@ static int rxe_param_set_add(const char *val, const struct kernel_param *kp)
        struct net_device *ndev;
        struct rxe_dev *exists;
 
+       if (!rxe_initialized) {
+               pr_err("Module parameters are not supported, use rdma link add or rxe_cfg\n");
+               return -EAGAIN;
+       }
+
        len = sanitize_arg(val, intf, sizeof(intf));
        if (!len) {
                pr_err("add: invalid interface name\n");
index 08f05ac..ecdac3f 100644 (file)
@@ -71,7 +71,7 @@ void rxe_do_task(unsigned long data)
 
        case TASK_STATE_BUSY:
                task->state = TASK_STATE_ARMED;
-               /* fall through */
+               fallthrough;
        case TASK_STATE_ARMED:
                spin_unlock_irqrestore(&task->state_lock, flags);
                return;
index bb61e53..8522e9a 100644 (file)
@@ -540,7 +540,7 @@ static void init_send_wr(struct rxe_qp *qp, struct rxe_send_wr *wr,
                switch (wr->opcode) {
                case IB_WR_RDMA_WRITE_WITH_IMM:
                        wr->ex.imm_data = ibwr->ex.imm_data;
-                       /* fall through */
+                       fallthrough;
                case IB_WR_RDMA_READ:
                case IB_WR_RDMA_WRITE:
                        wr->wr.rdma.remote_addr = rdma_wr(ibwr)->remote_addr;
@@ -1056,7 +1056,7 @@ static ssize_t parent_show(struct device *device,
        struct rxe_dev *rxe =
                rdma_device_to_drv_device(device, struct rxe_dev, ib_dev);
 
-       return snprintf(buf, 16, "%s\n", rxe_parent_name(rxe, 1));
+       return scnprintf(buf, PAGE_SIZE, "%s\n", rxe_parent_name(rxe, 1));
 }
 
 static DEVICE_ATTR_RO(parent);
index 1662216..66764f7 100644 (file)
@@ -1224,12 +1224,10 @@ static void siw_cm_llp_data_ready(struct sock *sk)
 
        switch (cep->state) {
        case SIW_EPSTATE_RDMA_MODE:
-               /* fall through */
        case SIW_EPSTATE_LISTENING:
                break;
 
        case SIW_EPSTATE_AWAIT_MPAREQ:
-               /* fall through */
        case SIW_EPSTATE_AWAIT_MPAREP:
                siw_cm_queue_work(cep, SIW_CM_WORK_READ_MPAHDR);
                break;
index 857be5a..4bd1f1f 100644 (file)
@@ -1215,7 +1215,7 @@ static int siw_rdmap_complete(struct siw_qp *qp, int error)
        case RDMAP_SEND_SE:
        case RDMAP_SEND_SE_INVAL:
                wqe->rqe.flags |= SIW_WQE_SOLICITED;
-               /* Fall through */
+               fallthrough;
 
        case RDMAP_SEND:
        case RDMAP_SEND_INVAL:
@@ -1386,7 +1386,7 @@ int siw_tcp_rx_data(read_descriptor_t *rd_desc, struct sk_buff *skb,
                         * DDP segment.
                         */
                        qp->rx_fpdu->first_ddp_seg = 0;
-                       /* Fall through */
+                       fallthrough;
 
                case SIW_GET_DATA_START:
                        /*
index 9f53aa4..d19d832 100644 (file)
@@ -1042,7 +1042,7 @@ next_wqe:
                case SIW_OP_SEND_REMOTE_INV:
                case SIW_OP_WRITE:
                        siw_wqe_put_mem(wqe, tx_type);
-                       /* Fall through */
+                       fallthrough;
 
                case SIW_OP_INVAL_STAG:
                case SIW_OP_REG_MR:
@@ -1128,7 +1128,7 @@ next_wqe:
                case SIW_OP_READ:
                case SIW_OP_READ_LOCAL_INV:
                        siw_wqe_put_mem(wqe, tx_type);
-                       /* Fall through */
+                       fallthrough;
 
                case SIW_OP_INVAL_STAG:
                case SIW_OP_REG_MR:
index 9bf0fa3..7c41fb0 100644 (file)
@@ -512,13 +512,13 @@ static int ipoib_cm_rx_handler(struct ib_cm_id *cm_id,
                return ipoib_cm_req_handler(cm_id, event);
        case IB_CM_DREQ_RECEIVED:
                ib_send_cm_drep(cm_id, NULL, 0);
-               /* Fall through */
+               fallthrough;
        case IB_CM_REJ_RECEIVED:
                p = cm_id->context;
                priv = ipoib_priv(p->dev);
                if (ib_modify_qp(p->qp, &ipoib_cm_err_attr, IB_QP_STATE))
                        ipoib_warn(priv, "unable to move qp to error state\n");
-               /* Fall through */
+               fallthrough;
        default:
                return 0;
        }
index 752581a..ab75b7f 100644 (file)
@@ -502,7 +502,7 @@ static struct net_device *ipoib_get_net_dev_by_params(
        default:
                dev_warn_ratelimited(&dev->dev,
                                     "duplicate IP address detected\n");
-               /* Fall through */
+               fallthrough;
        case 1:
                return net_dev;
        }
index 699e075..2f3ebc0 100644 (file)
@@ -711,7 +711,7 @@ static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *eve
        case RDMA_CM_EVENT_REJECTED:
                iser_info("Connection rejected: %s\n",
                         rdma_reject_msg(cma_id, event->status));
-               /* FALLTHROUGH */
+               fallthrough;
        case RDMA_CM_EVENT_ADDR_ERROR:
        case RDMA_CM_EVENT_ROUTE_ERROR:
        case RDMA_CM_EVENT_CONNECT_ERROR:
index 61e2f7f..695f701 100644 (file)
@@ -140,15 +140,15 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn)
        rx_desc = isert_conn->rx_descs;
 
        for (i = 0; i < ISERT_QP_MAX_RECV_DTOS; i++, rx_desc++)  {
-               dma_addr = ib_dma_map_single(ib_dev, (void *)rx_desc,
-                                       ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+               dma_addr = ib_dma_map_single(ib_dev, rx_desc->buf,
+                                       ISER_RX_SIZE, DMA_FROM_DEVICE);
                if (ib_dma_mapping_error(ib_dev, dma_addr))
                        goto dma_map_fail;
 
                rx_desc->dma_addr = dma_addr;
 
                rx_sg = &rx_desc->rx_sg;
-               rx_sg->addr = rx_desc->dma_addr;
+               rx_sg->addr = rx_desc->dma_addr + isert_get_hdr_offset(rx_desc);
                rx_sg->length = ISER_RX_PAYLOAD_SIZE;
                rx_sg->lkey = device->pd->local_dma_lkey;
                rx_desc->rx_cqe.done = isert_recv_done;
@@ -160,7 +160,7 @@ dma_map_fail:
        rx_desc = isert_conn->rx_descs;
        for (j = 0; j < i; j++, rx_desc++) {
                ib_dma_unmap_single(ib_dev, rx_desc->dma_addr,
-                                   ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+                                   ISER_RX_SIZE, DMA_FROM_DEVICE);
        }
        kfree(isert_conn->rx_descs);
        isert_conn->rx_descs = NULL;
@@ -181,7 +181,7 @@ isert_free_rx_descriptors(struct isert_conn *isert_conn)
        rx_desc = isert_conn->rx_descs;
        for (i = 0; i < ISERT_QP_MAX_RECV_DTOS; i++, rx_desc++)  {
                ib_dma_unmap_single(ib_dev, rx_desc->dma_addr,
-                                   ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+                                   ISER_RX_SIZE, DMA_FROM_DEVICE);
        }
 
        kfree(isert_conn->rx_descs);
@@ -299,10 +299,9 @@ isert_free_login_buf(struct isert_conn *isert_conn)
                            ISER_RX_PAYLOAD_SIZE, DMA_TO_DEVICE);
        kfree(isert_conn->login_rsp_buf);
 
-       ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma,
-                           ISER_RX_PAYLOAD_SIZE,
-                           DMA_FROM_DEVICE);
-       kfree(isert_conn->login_req_buf);
+       ib_dma_unmap_single(ib_dev, isert_conn->login_desc->dma_addr,
+                           ISER_RX_SIZE, DMA_FROM_DEVICE);
+       kfree(isert_conn->login_desc);
 }
 
 static int
@@ -311,25 +310,25 @@ isert_alloc_login_buf(struct isert_conn *isert_conn,
 {
        int ret;
 
-       isert_conn->login_req_buf = kzalloc(sizeof(*isert_conn->login_req_buf),
+       isert_conn->login_desc = kzalloc(sizeof(*isert_conn->login_desc),
                        GFP_KERNEL);
-       if (!isert_conn->login_req_buf)
+       if (!isert_conn->login_desc)
                return -ENOMEM;
 
-       isert_conn->login_req_dma = ib_dma_map_single(ib_dev,
-                               isert_conn->login_req_buf,
-                               ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
-       ret = ib_dma_mapping_error(ib_dev, isert_conn->login_req_dma);
+       isert_conn->login_desc->dma_addr = ib_dma_map_single(ib_dev,
+                               isert_conn->login_desc->buf,
+                               ISER_RX_SIZE, DMA_FROM_DEVICE);
+       ret = ib_dma_mapping_error(ib_dev, isert_conn->login_desc->dma_addr);
        if (ret) {
-               isert_err("login_req_dma mapping error: %d\n", ret);
-               isert_conn->login_req_dma = 0;
-               goto out_free_login_req_buf;
+               isert_err("login_desc dma mapping error: %d\n", ret);
+               isert_conn->login_desc->dma_addr = 0;
+               goto out_free_login_desc;
        }
 
        isert_conn->login_rsp_buf = kzalloc(ISER_RX_PAYLOAD_SIZE, GFP_KERNEL);
        if (!isert_conn->login_rsp_buf) {
                ret = -ENOMEM;
-               goto out_unmap_login_req_buf;
+               goto out_unmap_login_desc;
        }
 
        isert_conn->login_rsp_dma = ib_dma_map_single(ib_dev,
@@ -346,11 +345,11 @@ isert_alloc_login_buf(struct isert_conn *isert_conn,
 
 out_free_login_rsp_buf:
        kfree(isert_conn->login_rsp_buf);
-out_unmap_login_req_buf:
-       ib_dma_unmap_single(ib_dev, isert_conn->login_req_dma,
-                           ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
-out_free_login_req_buf:
-       kfree(isert_conn->login_req_buf);
+out_unmap_login_desc:
+       ib_dma_unmap_single(ib_dev, isert_conn->login_desc->dma_addr,
+                           ISER_RX_SIZE, DMA_FROM_DEVICE);
+out_free_login_desc:
+       kfree(isert_conn->login_desc);
        return ret;
 }
 
@@ -476,7 +475,7 @@ isert_connect_release(struct isert_conn *isert_conn)
        if (isert_conn->qp)
                isert_destroy_qp(isert_conn);
 
-       if (isert_conn->login_req_buf)
+       if (isert_conn->login_desc)
                isert_free_login_buf(isert_conn);
 
        isert_device_put(device);
@@ -664,8 +663,8 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
        case RDMA_CM_EVENT_ESTABLISHED:
                isert_connected_handler(cma_id);
                break;
-       case RDMA_CM_EVENT_ADDR_CHANGE:    /* FALLTHRU */
-       case RDMA_CM_EVENT_DISCONNECTED:   /* FALLTHRU */
+       case RDMA_CM_EVENT_ADDR_CHANGE:
+       case RDMA_CM_EVENT_DISCONNECTED:
        case RDMA_CM_EVENT_TIMEWAIT_EXIT:  /* FALLTHRU */
                ret = isert_disconnected_handler(cma_id, event->event);
                break;
@@ -684,7 +683,7 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
        case RDMA_CM_EVENT_REJECTED:
                isert_info("Connection rejected: %s\n",
                           rdma_reject_msg(cma_id, event->status));
-               /* fall through */
+               fallthrough;
        case RDMA_CM_EVENT_UNREACHABLE:
        case RDMA_CM_EVENT_CONNECT_ERROR:
                ret = isert_connect_error(cma_id);
@@ -862,17 +861,18 @@ isert_login_post_recv(struct isert_conn *isert_conn)
        int ret;
 
        memset(&sge, 0, sizeof(struct ib_sge));
-       sge.addr = isert_conn->login_req_dma;
+       sge.addr = isert_conn->login_desc->dma_addr +
+               isert_get_hdr_offset(isert_conn->login_desc);
        sge.length = ISER_RX_PAYLOAD_SIZE;
        sge.lkey = isert_conn->device->pd->local_dma_lkey;
 
        isert_dbg("Setup sge: addr: %llx length: %d 0x%08x\n",
                sge.addr, sge.length, sge.lkey);
 
-       isert_conn->login_req_buf->rx_cqe.done = isert_login_recv_done;
+       isert_conn->login_desc->rx_cqe.done = isert_login_recv_done;
 
        memset(&rx_wr, 0, sizeof(struct ib_recv_wr));
-       rx_wr.wr_cqe = &isert_conn->login_req_buf->rx_cqe;
+       rx_wr.wr_cqe = &isert_conn->login_desc->rx_cqe;
        rx_wr.sg_list = &sge;
        rx_wr.num_sge = 1;
 
@@ -949,7 +949,7 @@ post_send:
 static void
 isert_rx_login_req(struct isert_conn *isert_conn)
 {
-       struct iser_rx_desc *rx_desc = isert_conn->login_req_buf;
+       struct iser_rx_desc *rx_desc = isert_conn->login_desc;
        int rx_buflen = isert_conn->login_req_len;
        struct iscsi_conn *conn = isert_conn->conn;
        struct iscsi_login *login = conn->conn_login;
@@ -961,7 +961,7 @@ isert_rx_login_req(struct isert_conn *isert_conn)
 
        if (login->first_request) {
                struct iscsi_login_req *login_req =
-                       (struct iscsi_login_req *)&rx_desc->iscsi_header;
+                       (struct iscsi_login_req *)isert_get_iscsi_hdr(rx_desc);
                /*
                 * Setup the initial iscsi_login values from the leading
                 * login request PDU.
@@ -980,13 +980,13 @@ isert_rx_login_req(struct isert_conn *isert_conn)
                login->tsih             = be16_to_cpu(login_req->tsih);
        }
 
-       memcpy(&login->req[0], (void *)&rx_desc->iscsi_header, ISCSI_HDR_LEN);
+       memcpy(&login->req[0], isert_get_iscsi_hdr(rx_desc), ISCSI_HDR_LEN);
 
        size = min(rx_buflen, MAX_KEY_VALUE_PAIRS);
        isert_dbg("Using login payload size: %d, rx_buflen: %d "
                  "MAX_KEY_VALUE_PAIRS: %d\n", size, rx_buflen,
                  MAX_KEY_VALUE_PAIRS);
-       memcpy(login->req_buf, &rx_desc->data[0], size);
+       memcpy(login->req_buf, isert_get_data(rx_desc), size);
 
        if (login->first_request) {
                complete(&isert_conn->login_comp);
@@ -1051,14 +1051,15 @@ isert_handle_scsi_cmd(struct isert_conn *isert_conn,
        if (imm_data_len != data_len) {
                sg_nents = max(1UL, DIV_ROUND_UP(imm_data_len, PAGE_SIZE));
                sg_copy_from_buffer(cmd->se_cmd.t_data_sg, sg_nents,
-                                   &rx_desc->data[0], imm_data_len);
+                                   isert_get_data(rx_desc), imm_data_len);
                isert_dbg("Copy Immediate sg_nents: %u imm_data_len: %d\n",
                          sg_nents, imm_data_len);
        } else {
                sg_init_table(&isert_cmd->sg, 1);
                cmd->se_cmd.t_data_sg = &isert_cmd->sg;
                cmd->se_cmd.t_data_nents = 1;
-               sg_set_buf(&isert_cmd->sg, &rx_desc->data[0], imm_data_len);
+               sg_set_buf(&isert_cmd->sg, isert_get_data(rx_desc),
+                               imm_data_len);
                isert_dbg("Transfer Immediate imm_data_len: %d\n",
                          imm_data_len);
        }
@@ -1127,9 +1128,9 @@ isert_handle_iscsi_dataout(struct isert_conn *isert_conn,
        }
        isert_dbg("Copying DataOut: sg_start: %p, sg_off: %u "
                  "sg_nents: %u from %p %u\n", sg_start, sg_off,
-                 sg_nents, &rx_desc->data[0], unsol_data_len);
+                 sg_nents, isert_get_data(rx_desc), unsol_data_len);
 
-       sg_copy_from_buffer(sg_start, sg_nents, &rx_desc->data[0],
+       sg_copy_from_buffer(sg_start, sg_nents, isert_get_data(rx_desc),
                            unsol_data_len);
 
        rc = iscsit_check_dataout_payload(cmd, hdr, false);
@@ -1188,7 +1189,7 @@ isert_handle_text_cmd(struct isert_conn *isert_conn, struct isert_cmd *isert_cmd
        }
        cmd->text_in_ptr = text_in;
 
-       memcpy(cmd->text_in_ptr, &rx_desc->data[0], payload_length);
+       memcpy(cmd->text_in_ptr, isert_get_data(rx_desc), payload_length);
 
        return iscsit_process_text_cmd(conn, cmd, hdr);
 }
@@ -1198,7 +1199,7 @@ isert_rx_opcode(struct isert_conn *isert_conn, struct iser_rx_desc *rx_desc,
                uint32_t read_stag, uint64_t read_va,
                uint32_t write_stag, uint64_t write_va)
 {
-       struct iscsi_hdr *hdr = &rx_desc->iscsi_header;
+       struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc);
        struct iscsi_conn *conn = isert_conn->conn;
        struct iscsi_cmd *cmd;
        struct isert_cmd *isert_cmd;
@@ -1296,8 +1297,8 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc)
        struct isert_conn *isert_conn = wc->qp->qp_context;
        struct ib_device *ib_dev = isert_conn->cm_id->device;
        struct iser_rx_desc *rx_desc = cqe_to_rx_desc(wc->wr_cqe);
-       struct iscsi_hdr *hdr = &rx_desc->iscsi_header;
-       struct iser_ctrl *iser_ctrl = &rx_desc->iser_header;
+       struct iscsi_hdr *hdr = isert_get_iscsi_hdr(rx_desc);
+       struct iser_ctrl *iser_ctrl = isert_get_iser_hdr(rx_desc);
        uint64_t read_va = 0, write_va = 0;
        uint32_t read_stag = 0, write_stag = 0;
 
@@ -1311,7 +1312,7 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc)
        rx_desc->in_use = true;
 
        ib_dma_sync_single_for_cpu(ib_dev, rx_desc->dma_addr,
-                       ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+                       ISER_RX_SIZE, DMA_FROM_DEVICE);
 
        isert_dbg("DMA: 0x%llx, iSCSI opcode: 0x%02x, ITT: 0x%08x, flags: 0x%02x dlen: %d\n",
                 rx_desc->dma_addr, hdr->opcode, hdr->itt, hdr->flags,
@@ -1346,7 +1347,7 @@ isert_recv_done(struct ib_cq *cq, struct ib_wc *wc)
                        read_stag, read_va, write_stag, write_va);
 
        ib_dma_sync_single_for_device(ib_dev, rx_desc->dma_addr,
-                       ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+                       ISER_RX_SIZE, DMA_FROM_DEVICE);
 }
 
 static void
@@ -1360,8 +1361,8 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)
                return;
        }
 
-       ib_dma_sync_single_for_cpu(ib_dev, isert_conn->login_req_dma,
-                       ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+       ib_dma_sync_single_for_cpu(ib_dev, isert_conn->login_desc->dma_addr,
+                       ISER_RX_SIZE, DMA_FROM_DEVICE);
 
        isert_conn->login_req_len = wc->byte_len - ISER_HEADERS_LEN;
 
@@ -1376,8 +1377,8 @@ isert_login_recv_done(struct ib_cq *cq, struct ib_wc *wc)
        complete(&isert_conn->login_req_comp);
        mutex_unlock(&isert_conn->mutex);
 
-       ib_dma_sync_single_for_device(ib_dev, isert_conn->login_req_dma,
-                               ISER_RX_PAYLOAD_SIZE, DMA_FROM_DEVICE);
+       ib_dma_sync_single_for_device(ib_dev, isert_conn->login_desc->dma_addr,
+                               ISER_RX_SIZE, DMA_FROM_DEVICE);
 }
 
 static void
@@ -1470,7 +1471,7 @@ isert_put_cmd(struct isert_cmd *isert_cmd, bool comp_err)
                        transport_generic_free_cmd(&cmd->se_cmd, 0);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                iscsit_release_cmd(cmd);
                break;
@@ -1648,7 +1649,7 @@ isert_do_control_comp(struct work_struct *work)
        switch (cmd->i_state) {
        case ISTATE_SEND_TASKMGTRSP:
                iscsit_tmr_post_handler(cmd, cmd->conn);
-               /* fall through */
+               fallthrough;
        case ISTATE_SEND_REJECT:
        case ISTATE_SEND_TEXTRSP:
                cmd->i_state = ISTATE_SENT_STATUS;
index c55f7d9..7fee4a6 100644 (file)
                                ISERT_MAX_TX_MISC_PDUS  + \
                                ISERT_MAX_RX_MISC_PDUS)
 
-#define ISER_RX_PAD_SIZE       (ISCSI_DEF_MAX_RECV_SEG_LEN + 4096 - \
-               (ISER_RX_PAYLOAD_SIZE + sizeof(u64) + sizeof(struct ib_sge) + \
-                sizeof(struct ib_cqe) + sizeof(bool)))
+/*
+ * RX size is default of 8k plus headers, but data needs to align to
+ * 512 boundary, so use 1024 to have the extra space for alignment.
+ */
+#define ISER_RX_SIZE           (ISCSI_DEF_MAX_RECV_SEG_LEN + 1024)
 
 /* Maximum support is 16MB I/O size */
 #define ISCSI_ISER_MAX_SG_TABLESIZE    4096
@@ -81,21 +83,41 @@ enum iser_conn_state {
 };
 
 struct iser_rx_desc {
-       struct iser_ctrl iser_header;
-       struct iscsi_hdr iscsi_header;
-       char            data[ISCSI_DEF_MAX_RECV_SEG_LEN];
+       char            buf[ISER_RX_SIZE];
        u64             dma_addr;
        struct ib_sge   rx_sg;
        struct ib_cqe   rx_cqe;
        bool            in_use;
-       char            pad[ISER_RX_PAD_SIZE];
-} __packed;
+};
 
 static inline struct iser_rx_desc *cqe_to_rx_desc(struct ib_cqe *cqe)
 {
        return container_of(cqe, struct iser_rx_desc, rx_cqe);
 }
 
+static void *isert_get_iser_hdr(struct iser_rx_desc *desc)
+{
+       return PTR_ALIGN(desc->buf + ISER_HEADERS_LEN, 512) - ISER_HEADERS_LEN;
+}
+
+static size_t isert_get_hdr_offset(struct iser_rx_desc *desc)
+{
+       return isert_get_iser_hdr(desc) - (void *)desc->buf;
+}
+
+static void *isert_get_iscsi_hdr(struct iser_rx_desc *desc)
+{
+       return isert_get_iser_hdr(desc) + sizeof(struct iser_ctrl);
+}
+
+static void *isert_get_data(struct iser_rx_desc *desc)
+{
+       void *data = isert_get_iser_hdr(desc) + ISER_HEADERS_LEN;
+
+       WARN_ON((uintptr_t)data & 511);
+       return data;
+}
+
 struct iser_tx_desc {
        struct iser_ctrl iser_header;
        struct iscsi_hdr iscsi_header;
@@ -142,9 +164,8 @@ struct isert_conn {
        u32                     responder_resources;
        u32                     initiator_depth;
        bool                    pi_support;
-       struct iser_rx_desc     *login_req_buf;
+       struct iser_rx_desc     *login_desc;
        char                    *login_rsp_buf;
-       u64                     login_req_dma;
        int                     login_req_len;
        u64                     login_rsp_dma;
        struct iser_rx_desc     *rx_descs;
index 874a8eb..4933085 100644 (file)
@@ -547,7 +547,6 @@ static void vema_get(struct opa_vnic_vema_port *port,
                vema_get_mac_entries(port, recvd_mad, rsp_mad);
                break;
        case OPA_EM_ATTR_IFACE_UCAST_MACS:
-               /* fall through */
        case OPA_EM_ATTR_IFACE_MCAST_MACS:
                vema_get_mac_list(port, recvd_mad, rsp_mad, attr_id);
                break;
index 3d78775..cf6a2be 100644 (file)
@@ -152,13 +152,6 @@ static struct attribute_group rtrs_srv_stats_attr_group = {
        .attrs = rtrs_srv_stats_attrs,
 };
 
-static void rtrs_srv_dev_release(struct device *dev)
-{
-       struct rtrs_srv *srv = container_of(dev, struct rtrs_srv, dev);
-
-       kfree(srv);
-}
-
 static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
 {
        struct rtrs_srv *srv = sess->srv;
@@ -172,7 +165,6 @@ static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
                goto unlock;
        }
        srv->dev.class = rtrs_dev_class;
-       srv->dev.release = rtrs_srv_dev_release;
        err = dev_set_name(&srv->dev, "%s", sess->s.sessname);
        if (err)
                goto unlock;
@@ -182,16 +174,16 @@ static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
         * sysfs files are created
         */
        dev_set_uevent_suppress(&srv->dev, true);
-       err = device_register(&srv->dev);
+       err = device_add(&srv->dev);
        if (err) {
-               pr_err("device_register(): %d\n", err);
+               pr_err("device_add(): %d\n", err);
                goto put;
        }
        srv->kobj_paths = kobject_create_and_add("paths", &srv->dev.kobj);
        if (!srv->kobj_paths) {
                err = -ENOMEM;
                pr_err("kobject_create_and_add(): %d\n", err);
-               device_unregister(&srv->dev);
+               device_del(&srv->dev);
                goto unlock;
        }
        dev_set_uevent_suppress(&srv->dev, false);
@@ -216,7 +208,7 @@ rtrs_srv_destroy_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
                kobject_del(srv->kobj_paths);
                kobject_put(srv->kobj_paths);
                mutex_unlock(&srv->paths_mutex);
-               device_unregister(&srv->dev);
+               device_del(&srv->dev);
        } else {
                mutex_unlock(&srv->paths_mutex);
        }
index a219bd1..28f6414 100644 (file)
@@ -1319,6 +1319,13 @@ static int rtrs_srv_get_next_cq_vector(struct rtrs_srv_sess *sess)
        return sess->cur_cq_vector;
 }
 
+static void rtrs_srv_dev_release(struct device *dev)
+{
+       struct rtrs_srv *srv = container_of(dev, struct rtrs_srv, dev);
+
+       kfree(srv);
+}
+
 static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx,
                                     const uuid_t *paths_uuid)
 {
@@ -1336,6 +1343,8 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx,
        uuid_copy(&srv->paths_uuid, paths_uuid);
        srv->queue_depth = sess_queue_depth;
        srv->ctx = ctx;
+       device_initialize(&srv->dev);
+       srv->dev.release = rtrs_srv_dev_release;
 
        srv->chunks = kcalloc(srv->queue_depth, sizeof(*srv->chunks),
                              GFP_KERNEL);
index e78c4c7..76ffdec 100644 (file)
@@ -102,12 +102,12 @@ static irqreturn_t fsia6b_serio_irq(struct serio *serio,
                                        input_report_key(fsia6b->dev,
                                                         sw_id++,
                                                         sw_state == 0);
-                                       /* fall-through */
+                                       fallthrough;
                                case '2':
                                        input_report_key(fsia6b->dev,
                                                         sw_id++,
                                                         sw_state == 1);
-                                       /* fall-through */
+                                       fallthrough;
                                case '1':
                                        input_report_key(fsia6b->dev,
                                                         sw_id++,
index 88df68c..d37645e 100644 (file)
@@ -885,7 +885,6 @@ static int gc_setup_pad(struct gc *gc, int idx, int pad_type)
 
        case GC_MULTI:
                input_set_capability(input_dev, EV_KEY, BTN_TRIGGER);
-               /* fall through */
                break;
 
        case GC_PSX:
index 959c1d8..1cedb45 100644 (file)
@@ -213,7 +213,7 @@ static void wacom_handle_model_response(struct wacom *wacom)
                case 0x3731: /* PL-710 */
                        wacom->res_x = 2540;
                        wacom->res_y = 2540;
-                       /* fall through */
+                       fallthrough;
                case 0x3535: /* PL-550 */
                case 0x3830: /* PL-800 */
                        wacom->extra_z_bits = 2;
index 6b71b0a..98f17fa 100644 (file)
@@ -477,7 +477,7 @@ static int mxt_lookup_bootloader_address(struct mxt_data *data, bool retry)
                        bootloader = appmode - 0x24;
                        break;
                }
-               /* Fall through - for normal case */
+               fallthrough;    /* for normal case */
        case 0x4c:
        case 0x4d:
        case 0x5a:
index 607d1ae..bb1699e 100644 (file)
@@ -290,7 +290,7 @@ static int wm831x_ts_probe(struct platform_device *pdev)
                default:
                        dev_err(&pdev->dev, "Unsupported ISEL setting: %d\n",
                                pdata->isel);
-                       /* Fall through */
+                       fallthrough;
                case 200:
                case 0:
                        wm831x_set_bits(wm831x, WM831X_TOUCH_CONTROL_2,
index 4825c28..d203520 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 CFLAGS_core.o                          := -I$(src)
-icc-core-objs                          := core.o
+icc-core-objs                          := core.o bulk.o
 
 obj-$(CONFIG_INTERCONNECT)             += icc-core.o
 obj-$(CONFIG_INTERCONNECT_IMX)         += imx/
diff --git a/drivers/interconnect/bulk.c b/drivers/interconnect/bulk.c
new file mode 100644 (file)
index 0000000..73e2c8d
--- /dev/null
@@ -0,0 +1,117 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <linux/interconnect-provider.h>
+#include <linux/device.h>
+#include <linux/export.h>
+
+/**
+ * of_icc_bulk_get() - get interconnect paths
+ * @dev: the device requesting the path
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the table with the paths we want to get
+ *
+ * Returns 0 on success or negative errno otherwise.
+ */
+int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
+                                struct icc_bulk_data *paths)
+{
+       int ret, i;
+
+       for (i = 0; i < num_paths; i++) {
+               paths[i].path = of_icc_get(dev, paths[i].name);
+               if (IS_ERR(paths[i].path)) {
+                       ret = PTR_ERR(paths[i].path);
+                       if (ret != -EPROBE_DEFER)
+                               dev_err(dev, "of_icc_get() failed on path %s (%d)\n",
+                                       paths[i].name, ret);
+                       paths[i].path = NULL;
+                       goto err;
+               }
+       }
+
+       return 0;
+
+err:
+       icc_bulk_put(i, paths);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(of_icc_bulk_get);
+
+/**
+ * icc_bulk_put() - put a list of interconnect paths
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the icc_bulk_data table with the paths being put
+ */
+void icc_bulk_put(int num_paths, struct icc_bulk_data *paths)
+{
+       while (--num_paths >= 0) {
+               icc_put(paths[num_paths].path);
+               paths[num_paths].path = NULL;
+       }
+}
+EXPORT_SYMBOL_GPL(icc_bulk_put);
+
+/**
+ * icc_bulk_set() - set bandwidth to a set of paths
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the icc_bulk_data table containing the paths and bandwidth
+ *
+ * Returns 0 on success or negative errno otherwise.
+ */
+int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths)
+{
+       int ret = 0;
+       int i;
+
+       for (i = 0; i < num_paths; i++) {
+               ret = icc_set_bw(paths[i].path, paths[i].avg_bw, paths[i].peak_bw);
+               if (ret) {
+                       pr_err("icc_set_bw() failed on path %s (%d)\n", paths[i].name, ret);
+                       return ret;
+               }
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(icc_bulk_set_bw);
+
+/**
+ * icc_bulk_enable() - enable a previously disabled set of paths
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the icc_bulk_data table containing the paths and bandwidth
+ *
+ * Returns 0 on success or negative errno otherwise.
+ */
+int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths)
+{
+       int ret, i;
+
+       for (i = 0; i < num_paths; i++) {
+               ret = icc_enable(paths[i].path);
+               if (ret) {
+                       pr_err("icc_enable() failed on path %s (%d)\n", paths[i].name, ret);
+                       goto err;
+               }
+       }
+
+       return 0;
+
+err:
+       icc_bulk_disable(i, paths);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(icc_bulk_enable);
+
+/**
+ * icc_bulk_disable() - disable a set of interconnect paths
+ * @num_paths: the number of icc_bulk_data
+ * @paths: the icc_bulk_data table containing the paths and bandwidth
+ */
+void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths)
+{
+       while (--num_paths >= 0)
+               icc_disable(paths[num_paths].path);
+}
+EXPORT_SYMBOL_GPL(icc_bulk_disable);
index befd111..eea47b4 100644 (file)
@@ -26,6 +26,8 @@
 
 static DEFINE_IDR(icc_idr);
 static LIST_HEAD(icc_providers);
+static int providers_count;
+static bool synced_state;
 static DEFINE_MUTEX(icc_lock);
 static struct dentry *icc_debugfs_dir;
 
@@ -55,12 +57,18 @@ static int icc_summary_show(struct seq_file *s, void *data)
 
                        icc_summary_show_one(s, n);
                        hlist_for_each_entry(r, &n->req_list, req_node) {
+                               u32 avg_bw = 0, peak_bw = 0;
+
                                if (!r->dev)
                                        continue;
 
+                               if (r->enabled) {
+                                       avg_bw = r->avg_bw;
+                                       peak_bw = r->peak_bw;
+                               }
+
                                seq_printf(s, "  %-27s %12u %12u %12u\n",
-                                          dev_name(r->dev), r->tag, r->avg_bw,
-                                          r->peak_bw);
+                                          dev_name(r->dev), r->tag, avg_bw, peak_bw);
                        }
                }
        }
@@ -261,6 +269,12 @@ static int aggregate_requests(struct icc_node *node)
                }
                p->aggregate(node, r->tag, avg_bw, peak_bw,
                             &node->avg_bw, &node->peak_bw);
+
+               /* during boot use the initial bandwidth as a floor value */
+               if (!synced_state) {
+                       node->avg_bw = max(node->avg_bw, node->init_avg);
+                       node->peak_bw = max(node->peak_bw, node->init_peak);
+               }
        }
 
        return 0;
@@ -336,12 +350,13 @@ EXPORT_SYMBOL_GPL(of_icc_xlate_onecell);
  * Looks for interconnect provider under the node specified by @spec and if
  * found, uses xlate function of the provider to map phandle args to node.
  *
- * Returns a valid pointer to struct icc_node on success or ERR_PTR()
+ * Returns a valid pointer to struct icc_node_data on success or ERR_PTR()
  * on failure.
  */
-struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
+struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
 {
        struct icc_node *node = ERR_PTR(-EPROBE_DEFER);
+       struct icc_node_data *data = NULL;
        struct icc_provider *provider;
 
        if (!spec)
@@ -349,14 +364,33 @@ struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
 
        mutex_lock(&icc_lock);
        list_for_each_entry(provider, &icc_providers, provider_list) {
-               if (provider->dev->of_node == spec->np)
-                       node = provider->xlate(spec, provider->data);
-               if (!IS_ERR(node))
-                       break;
+               if (provider->dev->of_node == spec->np) {
+                       if (provider->xlate_extended) {
+                               data = provider->xlate_extended(spec, provider->data);
+                               if (!IS_ERR(data)) {
+                                       node = data->node;
+                                       break;
+                               }
+                       } else {
+                               node = provider->xlate(spec, provider->data);
+                               if (!IS_ERR(node))
+                                       break;
+                       }
+               }
        }
        mutex_unlock(&icc_lock);
 
-       return node;
+       if (IS_ERR(node))
+               return ERR_CAST(node);
+
+       if (!data) {
+               data = kzalloc(sizeof(*data), GFP_KERNEL);
+               if (!data)
+                       return ERR_PTR(-ENOMEM);
+               data->node = node;
+       }
+
+       return data;
 }
 EXPORT_SYMBOL_GPL(of_icc_get_from_provider);
 
@@ -403,7 +437,7 @@ EXPORT_SYMBOL_GPL(devm_of_icc_get);
 struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
 {
        struct icc_path *path;
-       struct icc_node *src_node, *dst_node;
+       struct icc_node_data *src_data, *dst_data;
        struct device_node *np;
        struct of_phandle_args src_args, dst_args;
        int ret;
@@ -441,39 +475,42 @@ struct icc_path *of_icc_get_by_index(struct device *dev, int idx)
 
        of_node_put(dst_args.np);
 
-       src_node = of_icc_get_from_provider(&src_args);
+       src_data = of_icc_get_from_provider(&src_args);
 
-       if (IS_ERR(src_node)) {
-               if (PTR_ERR(src_node) != -EPROBE_DEFER)
-                       dev_err(dev, "error finding src node: %ld\n",
-                               PTR_ERR(src_node));
-               return ERR_CAST(src_node);
+       if (IS_ERR(src_data)) {
+               dev_err_probe(dev, PTR_ERR(src_data), "error finding src node\n");
+               return ERR_CAST(src_data);
        }
 
-       dst_node = of_icc_get_from_provider(&dst_args);
+       dst_data = of_icc_get_from_provider(&dst_args);
 
-       if (IS_ERR(dst_node)) {
-               if (PTR_ERR(dst_node) != -EPROBE_DEFER)
-                       dev_err(dev, "error finding dst node: %ld\n",
-                               PTR_ERR(dst_node));
-               return ERR_CAST(dst_node);
+       if (IS_ERR(dst_data)) {
+               dev_err_probe(dev, PTR_ERR(dst_data), "error finding dst node\n");
+               kfree(src_data);
+               return ERR_CAST(dst_data);
        }
 
        mutex_lock(&icc_lock);
-       path = path_find(dev, src_node, dst_node);
+       path = path_find(dev, src_data->node, dst_data->node);
        mutex_unlock(&icc_lock);
        if (IS_ERR(path)) {
                dev_err(dev, "%s: invalid path=%ld\n", __func__, PTR_ERR(path));
-               return path;
+               goto free_icc_data;
        }
 
+       if (src_data->tag && src_data->tag == dst_data->tag)
+               icc_set_tag(path, src_data->tag);
+
        path->name = kasprintf(GFP_KERNEL, "%s-%s",
-                              src_node->name, dst_node->name);
+                              src_data->node->name, dst_data->node->name);
        if (!path->name) {
                kfree(path);
-               return ERR_PTR(-ENOMEM);
+               path = ERR_PTR(-ENOMEM);
        }
 
+free_icc_data:
+       kfree(src_data);
+       kfree(dst_data);
        return path;
 }
 EXPORT_SYMBOL_GPL(of_icc_get_by_index);
@@ -925,6 +962,19 @@ void icc_node_add(struct icc_node *node, struct icc_provider *provider)
        node->provider = provider;
        list_add_tail(&node->node_list, &provider->nodes);
 
+       /* get the initial bandwidth values and sync them with hardware */
+       if (provider->get_bw) {
+               provider->get_bw(node, &node->init_avg, &node->init_peak);
+       } else {
+               node->init_avg = INT_MAX;
+               node->init_peak = INT_MAX;
+       }
+       node->avg_bw = node->init_avg;
+       node->peak_bw = node->init_peak;
+       provider->set(node, node);
+       node->avg_bw = 0;
+       node->peak_bw = 0;
+
        mutex_unlock(&icc_lock);
 }
 EXPORT_SYMBOL_GPL(icc_node_add);
@@ -975,7 +1025,7 @@ int icc_provider_add(struct icc_provider *provider)
 {
        if (WARN_ON(!provider->set))
                return -EINVAL;
-       if (WARN_ON(!provider->xlate))
+       if (WARN_ON(!provider->xlate && !provider->xlate_extended))
                return -EINVAL;
 
        mutex_lock(&icc_lock);
@@ -1020,8 +1070,54 @@ int icc_provider_del(struct icc_provider *provider)
 }
 EXPORT_SYMBOL_GPL(icc_provider_del);
 
+static int of_count_icc_providers(struct device_node *np)
+{
+       struct device_node *child;
+       int count = 0;
+
+       for_each_available_child_of_node(np, child) {
+               if (of_property_read_bool(child, "#interconnect-cells"))
+                       count++;
+               count += of_count_icc_providers(child);
+       }
+       of_node_put(np);
+
+       return count;
+}
+
+void icc_sync_state(struct device *dev)
+{
+       struct icc_provider *p;
+       struct icc_node *n;
+       static int count;
+
+       count++;
+
+       if (count < providers_count)
+               return;
+
+       mutex_lock(&icc_lock);
+       synced_state = true;
+       list_for_each_entry(p, &icc_providers, provider_list) {
+               dev_dbg(p->dev, "interconnect provider is in synced state\n");
+               list_for_each_entry(n, &p->nodes, node_list) {
+                       if (n->init_avg || n->init_peak) {
+                               aggregate_requests(n);
+                               p->set(n, n);
+                       }
+               }
+       }
+       mutex_unlock(&icc_lock);
+}
+EXPORT_SYMBOL_GPL(icc_sync_state);
+
 static int __init icc_init(void)
 {
+       struct device_node *root = of_find_node_by_path("/");
+
+       providers_count = of_count_icc_providers(root);
+       of_node_put(root);
+
        icc_debugfs_dir = debugfs_create_dir("interconnect", NULL);
        debugfs_create_file("interconnect_summary", 0444,
                            icc_debugfs_dir, NULL, &icc_summary_fops);
index ac420f8..41dba70 100644 (file)
@@ -184,10 +184,8 @@ static int imx_icc_register_nodes(struct icc_provider *provider,
 
                node = imx_icc_node_add(provider, node_desc);
                if (IS_ERR(node)) {
-                       ret = PTR_ERR(node);
-                       if (ret != -EPROBE_DEFER)
-                               dev_err(provider->dev, "failed to add %s: %d\n",
-                                       node_desc->name, ret);
+                       ret = dev_err_probe(provider->dev, PTR_ERR(node),
+                                           "failed to add %s\n", node_desc->name);
                        goto err;
                }
                provider_data->nodes[node->id] = node;
@@ -269,15 +267,10 @@ EXPORT_SYMBOL_GPL(imx_icc_register);
 int imx_icc_unregister(struct platform_device *pdev)
 {
        struct icc_provider *provider = platform_get_drvdata(pdev);
-       int ret;
 
        imx_icc_unregister_nodes(provider);
 
-       ret = icc_provider_del(provider);
-       if (ret)
-               return ret;
-
-       return 0;
+       return icc_provider_del(provider);
 }
 EXPORT_SYMBOL_GPL(imx_icc_unregister);
 
index a88f2f0..a8f93ba 100644 (file)
@@ -65,5 +65,25 @@ config INTERCONNECT_QCOM_SDM845
          This is a driver for the Qualcomm Network-on-Chip on sdm845-based
          platforms.
 
+config INTERCONNECT_QCOM_SM8150
+       tristate "Qualcomm SM8150 interconnect driver"
+       depends on INTERCONNECT_QCOM
+       depends on (QCOM_RPMH && QCOM_COMMAND_DB && OF) || COMPILE_TEST
+       select INTERCONNECT_QCOM_RPMH
+       select INTERCONNECT_QCOM_BCM_VOTER
+       help
+         This is a driver for the Qualcomm Network-on-Chip on sm8150-based
+         platforms.
+
+config INTERCONNECT_QCOM_SM8250
+       tristate "Qualcomm SM8250 interconnect driver"
+       depends on INTERCONNECT_QCOM
+       depends on (QCOM_RPMH && QCOM_COMMAND_DB && OF) || COMPILE_TEST
+       select INTERCONNECT_QCOM_RPMH
+       select INTERCONNECT_QCOM_BCM_VOTER
+       help
+         This is a driver for the Qualcomm Network-on-Chip on sm8250-based
+         platforms.
+
 config INTERCONNECT_QCOM_SMD_RPM
        tristate
index 3a047fe..cf628f7 100644 (file)
@@ -8,6 +8,8 @@ qnoc-qcs404-objs                        := qcs404.o
 icc-rpmh-obj                           := icc-rpmh.o
 qnoc-sc7180-objs                       := sc7180.o
 qnoc-sdm845-objs                       := sdm845.o
+qnoc-sm8150-objs                       := sm8150.o
+qnoc-sm8250-objs                       := sm8250.o
 icc-smd-rpm-objs                       := smd-rpm.o
 
 obj-$(CONFIG_INTERCONNECT_QCOM_BCM_VOTER) += icc-bcm-voter.o
@@ -18,4 +20,6 @@ obj-$(CONFIG_INTERCONNECT_QCOM_QCS404) += qnoc-qcs404.o
 obj-$(CONFIG_INTERCONNECT_QCOM_RPMH) += icc-rpmh.o
 obj-$(CONFIG_INTERCONNECT_QCOM_SC7180) += qnoc-sc7180.o
 obj-$(CONFIG_INTERCONNECT_QCOM_SDM845) += qnoc-sdm845.o
+obj-$(CONFIG_INTERCONNECT_QCOM_SM8150) += qnoc-sm8150.o
+obj-$(CONFIG_INTERCONNECT_QCOM_SM8250) += qnoc-sm8250.o
 obj-$(CONFIG_INTERCONNECT_QCOM_SMD_RPM) += icc-smd-rpm.o
index a3d2ef1..887d137 100644 (file)
@@ -27,6 +27,7 @@ static DEFINE_MUTEX(bcm_voter_lock);
  * @commit_list: list containing bcms to be committed to hardware
  * @ws_list: list containing bcms that have different wake/sleep votes
  * @voter_node: list of bcm voters
+ * @tcs_wait: mask for which buckets require TCS completion
  */
 struct bcm_voter {
        struct device *dev;
@@ -35,6 +36,7 @@ struct bcm_voter {
        struct list_head commit_list;
        struct list_head ws_list;
        struct list_head voter_node;
+       u32 tcs_wait;
 };
 
 static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
@@ -52,8 +54,20 @@ static int cmp_vcd(void *priv, struct list_head *a, struct list_head *b)
                return 1;
 }
 
+static u64 bcm_div(u64 num, u32 base)
+{
+       /* Ensure that small votes aren't lost. */
+       if (num && num < base)
+               return 1;
+
+       do_div(num, base);
+
+       return num;
+}
+
 static void bcm_aggregate(struct qcom_icc_bcm *bcm)
 {
+       struct qcom_icc_node *node;
        size_t i, bucket;
        u64 agg_avg[QCOM_ICC_NUM_BUCKETS] = {0};
        u64 agg_peak[QCOM_ICC_NUM_BUCKETS] = {0};
@@ -61,22 +75,21 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
 
        for (bucket = 0; bucket < QCOM_ICC_NUM_BUCKETS; bucket++) {
                for (i = 0; i < bcm->num_nodes; i++) {
-                       temp = bcm->nodes[i]->sum_avg[bucket] * bcm->aux_data.width;
-                       do_div(temp, bcm->nodes[i]->buswidth * bcm->nodes[i]->channels);
+                       node = bcm->nodes[i];
+                       temp = bcm_div(node->sum_avg[bucket] * bcm->aux_data.width,
+                                      node->buswidth * node->channels);
                        agg_avg[bucket] = max(agg_avg[bucket], temp);
 
-                       temp = bcm->nodes[i]->max_peak[bucket] * bcm->aux_data.width;
-                       do_div(temp, bcm->nodes[i]->buswidth);
+                       temp = bcm_div(node->max_peak[bucket] * bcm->aux_data.width,
+                                      node->buswidth);
                        agg_peak[bucket] = max(agg_peak[bucket], temp);
                }
 
-               temp = agg_avg[bucket] * 1000ULL;
-               do_div(temp, bcm->aux_data.unit);
-               bcm->vote_x[bucket] = temp;
+               temp = agg_avg[bucket] * bcm->vote_scale;
+               bcm->vote_x[bucket] = bcm_div(temp, bcm->aux_data.unit);
 
-               temp = agg_peak[bucket] * 1000ULL;
-               do_div(temp, bcm->aux_data.unit);
-               bcm->vote_y[bucket] = temp;
+               temp = agg_peak[bucket] * bcm->vote_scale;
+               bcm->vote_y[bucket] = bcm_div(temp, bcm->aux_data.unit);
        }
 
        if (bcm->keepalive && bcm->vote_x[QCOM_ICC_BUCKET_AMC] == 0 &&
@@ -89,7 +102,7 @@ static void bcm_aggregate(struct qcom_icc_bcm *bcm)
 }
 
 static inline void tcs_cmd_gen(struct tcs_cmd *cmd, u64 vote_x, u64 vote_y,
-                              u32 addr, bool commit)
+                              u32 addr, bool commit, bool wait)
 {
        bool valid = true;
 
@@ -114,15 +127,16 @@ static inline void tcs_cmd_gen(struct tcs_cmd *cmd, u64 vote_x, u64 vote_y,
         * Set the wait for completion flag on command that need to be completed
         * before the next command.
         */
-       cmd->wait = commit;
+       cmd->wait = wait;
 }
 
-static void tcs_list_gen(struct list_head *bcm_list, int bucket,
-                        struct tcs_cmd tcs_list[MAX_BCMS],
+static void tcs_list_gen(struct bcm_voter *voter, int bucket,
+                        struct tcs_cmd tcs_list[MAX_VCD],
                         int n[MAX_VCD + 1])
 {
+       struct list_head *bcm_list = &voter->commit_list;
        struct qcom_icc_bcm *bcm;
-       bool commit;
+       bool commit, wait;
        size_t idx = 0, batch = 0, cur_vcd_size = 0;
 
        memset(n, 0, sizeof(int) * (MAX_VCD + 1));
@@ -135,8 +149,11 @@ static void tcs_list_gen(struct list_head *bcm_list, int bucket,
                        commit = true;
                        cur_vcd_size = 0;
                }
+
+               wait = commit && (voter->tcs_wait & BIT(bucket));
+
                tcs_cmd_gen(&tcs_list[idx], bcm->vote_x[bucket],
-                           bcm->vote_y[bucket], bcm->addr, commit);
+                           bcm->vote_y[bucket], bcm->addr, commit, wait);
                idx++;
                n[batch]++;
                /*
@@ -261,8 +278,7 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
         * Construct the command list based on a pre ordered list of BCMs
         * based on VCD.
         */
-       tcs_list_gen(&voter->commit_list, QCOM_ICC_BUCKET_AMC, cmds, commit_idx);
-
+       tcs_list_gen(voter, QCOM_ICC_BUCKET_AMC, cmds, commit_idx);
        if (!commit_idx[0])
                goto out;
 
@@ -298,7 +314,7 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
 
        list_sort(NULL, &voter->commit_list, cmp_vcd);
 
-       tcs_list_gen(&voter->commit_list, QCOM_ICC_BUCKET_WAKE, cmds, commit_idx);
+       tcs_list_gen(voter, QCOM_ICC_BUCKET_WAKE, cmds, commit_idx);
 
        ret = rpmh_write_batch(voter->dev, RPMH_WAKE_ONLY_STATE, cmds, commit_idx);
        if (ret) {
@@ -306,7 +322,7 @@ int qcom_icc_bcm_voter_commit(struct bcm_voter *voter)
                goto out;
        }
 
-       tcs_list_gen(&voter->commit_list, QCOM_ICC_BUCKET_SLEEP, cmds, commit_idx);
+       tcs_list_gen(voter, QCOM_ICC_BUCKET_SLEEP, cmds, commit_idx);
 
        ret = rpmh_write_batch(voter->dev, RPMH_SLEEP_STATE, cmds, commit_idx);
        if (ret) {
@@ -325,6 +341,7 @@ EXPORT_SYMBOL_GPL(qcom_icc_bcm_voter_commit);
 
 static int qcom_icc_bcm_voter_probe(struct platform_device *pdev)
 {
+       struct device_node *np = pdev->dev.of_node;
        struct bcm_voter *voter;
 
        voter = devm_kzalloc(&pdev->dev, sizeof(*voter), GFP_KERNEL);
@@ -332,7 +349,11 @@ static int qcom_icc_bcm_voter_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        voter->dev = &pdev->dev;
-       voter->np = pdev->dev.of_node;
+       voter->np = np;
+
+       if (of_property_read_u32(np, "qcom,tcs-wait", &voter->tcs_wait))
+               voter->tcs_wait = QCOM_ICC_TAG_ACTIVE_ONLY;
+
        mutex_init(&voter->lock);
        INIT_LIST_HEAD(&voter->commit_list);
        INIT_LIST_HEAD(&voter->ws_list);
index 3ac5182..cf10a4b 100644 (file)
@@ -6,6 +6,8 @@
 #include <linux/interconnect.h>
 #include <linux/interconnect-provider.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/slab.h>
 
 #include "bcm-voter.h"
 #include "icc-rpmh.h"
@@ -92,6 +94,31 @@ int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
 }
 EXPORT_SYMBOL_GPL(qcom_icc_set);
 
+struct icc_node_data *qcom_icc_xlate_extended(struct of_phandle_args *spec, void *data)
+{
+       struct icc_node_data *ndata;
+       struct icc_node *node;
+
+       node = of_icc_xlate_onecell(spec, data);
+       if (IS_ERR(node))
+               return ERR_CAST(node);
+
+       ndata = kzalloc(sizeof(*ndata), GFP_KERNEL);
+       if (!ndata)
+               return ERR_PTR(-ENOMEM);
+
+       ndata->node = node;
+
+       if (spec->args_count == 2)
+               ndata->tag = spec->args[1];
+
+       if (spec->args_count > 2)
+               pr_warn("%pOF: Too many arguments, path tag is not parsed\n", spec->np);
+
+       return ndata;
+}
+EXPORT_SYMBOL_GPL(qcom_icc_xlate_extended);
+
 /**
  * qcom_icc_bcm_init - populates bcm aux data and connect qnodes
  * @bcm: bcm to be initialized
@@ -136,6 +163,9 @@ int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev)
        INIT_LIST_HEAD(&bcm->list);
        INIT_LIST_HEAD(&bcm->ws_list);
 
+       if (!bcm->vote_scale)
+               bcm->vote_scale = 1000;
+
        /* Link Qnodes to their respective BCMs */
        for (i = 0; i < bcm->num_nodes; i++) {
                qn = bcm->nodes[i];
index 903d25e..e5f61ab 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
 #define __DRIVERS_INTERCONNECT_QCOM_ICC_RPMH_H__
 
+#include <dt-bindings/interconnect/qcom,icc.h>
+
 #define to_qcom_provider(_provider) \
        container_of(_provider, struct qcom_icc_provider, provider)
 
@@ -44,22 +46,6 @@ struct bcm_db {
 #define MAX_BCM_PER_NODE       3
 #define MAX_VCD                        10
 
-/*
- * The AMC bucket denotes constraints that are applied to hardware when
- * icc_set_bw() completes, whereas the WAKE and SLEEP constraints are applied
- * when the execution environment transitions between active and low power mode.
- */
-#define QCOM_ICC_BUCKET_AMC            0
-#define QCOM_ICC_BUCKET_WAKE           1
-#define QCOM_ICC_BUCKET_SLEEP          2
-#define QCOM_ICC_NUM_BUCKETS           3
-#define QCOM_ICC_TAG_AMC               BIT(QCOM_ICC_BUCKET_AMC)
-#define QCOM_ICC_TAG_WAKE              BIT(QCOM_ICC_BUCKET_WAKE)
-#define QCOM_ICC_TAG_SLEEP             BIT(QCOM_ICC_BUCKET_SLEEP)
-#define QCOM_ICC_TAG_ACTIVE_ONLY       (QCOM_ICC_TAG_AMC | QCOM_ICC_TAG_WAKE)
-#define QCOM_ICC_TAG_ALWAYS            (QCOM_ICC_TAG_AMC | QCOM_ICC_TAG_WAKE |\
-                                        QCOM_ICC_TAG_SLEEP)
-
 /**
  * struct qcom_icc_node - Qualcomm specific interconnect nodes
  * @name: the node name used in debugfs
@@ -94,6 +80,7 @@ struct qcom_icc_node {
  * @addr: address offsets used when voting to RPMH
  * @vote_x: aggregated threshold values, represents sum_bw when @type is bw bcm
  * @vote_y: aggregated threshold values, represents peak_bw when @type is bw bcm
+ * @vote_scale: scaling factor for vote_x and vote_y
  * @dirty: flag used to indicate whether the bcm needs to be committed
  * @keepalive: flag used to indicate whether a keepalive is required
  * @aux_data: auxiliary data used when calculating threshold values and
@@ -109,6 +96,7 @@ struct qcom_icc_bcm {
        u32 addr;
        u64 vote_x[QCOM_ICC_NUM_BUCKETS];
        u64 vote_y[QCOM_ICC_NUM_BUCKETS];
+       u64 vote_scale;
        bool dirty;
        bool keepalive;
        struct bcm_db aux_data;
@@ -143,6 +131,7 @@ struct qcom_icc_desc {
 int qcom_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
                       u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
 int qcom_icc_set(struct icc_node *src, struct icc_node *dst);
+struct icc_node_data *qcom_icc_xlate_extended(struct of_phandle_args *spec, void *data);
 int qcom_icc_bcm_init(struct qcom_icc_bcm *bcm, struct device *dev);
 void qcom_icc_pre_aggregate(struct icc_node *node);
 
index 96fb9ff..695f287 100644 (file)
 
 #include "sc7180.h"
 #include "sdm845.h"
+#include "sm8150.h"
+#include "sm8250.h"
 
 #define LUT_MAX_ENTRIES                        40U
 #define LUT_SRC                                GENMASK(31, 30)
 #define LUT_L_VAL                      GENMASK(7, 0)
-#define LUT_ROW_SIZE                   32
 #define CLK_HW_DIV                     2
 
-/* Register offsets */
+/* OSM Register offsets */
 #define REG_ENABLE                     0x0
-#define REG_FREQ_LUT                   0x110
-#define REG_PERF_STATE                 0x920
+#define OSM_LUT_ROW_SIZE               32
+#define OSM_REG_FREQ_LUT               0x110
+#define OSM_REG_PERF_STATE             0x920
+
+/* EPSS Register offsets */
+#define EPSS_LUT_ROW_SIZE              4
+#define EPSS_REG_FREQ_LUT              0x100
+#define EPSS_REG_PERF_STATE            0x320
 
 #define OSM_L3_MAX_LINKS               1
 
@@ -36,6 +43,7 @@
 struct qcom_osm_l3_icc_provider {
        void __iomem *base;
        unsigned int max_state;
+       unsigned int reg_perf_state;
        unsigned long lut_tables[LUT_MAX_ENTRIES];
        struct icc_provider provider;
 };
@@ -57,12 +65,15 @@ struct qcom_icc_node {
 };
 
 struct qcom_icc_desc {
-       struct qcom_icc_node **nodes;
+       const struct qcom_icc_node **nodes;
        size_t num_nodes;
+       unsigned int lut_row_size;
+       unsigned int reg_freq_lut;
+       unsigned int reg_perf_state;
 };
 
 #define DEFINE_QNODE(_name, _id, _buswidth, ...)                       \
-               static struct qcom_icc_node _name = {                   \
+       static const struct qcom_icc_node _name = {                     \
                .name = #_name,                                         \
                .id = _id,                                              \
                .buswidth = _buswidth,                                  \
@@ -73,7 +84,7 @@ struct qcom_icc_desc {
 DEFINE_QNODE(sdm845_osm_apps_l3, SDM845_MASTER_OSM_L3_APPS, 16, SDM845_SLAVE_OSM_L3);
 DEFINE_QNODE(sdm845_osm_l3, SDM845_SLAVE_OSM_L3, 16);
 
-static struct qcom_icc_node *sdm845_osm_l3_nodes[] = {
+static const struct qcom_icc_node *sdm845_osm_l3_nodes[] = {
        [MASTER_OSM_L3_APPS] = &sdm845_osm_apps_l3,
        [SLAVE_OSM_L3] = &sdm845_osm_l3,
 };
@@ -81,12 +92,15 @@ static struct qcom_icc_node *sdm845_osm_l3_nodes[] = {
 static const struct qcom_icc_desc sdm845_icc_osm_l3 = {
        .nodes = sdm845_osm_l3_nodes,
        .num_nodes = ARRAY_SIZE(sdm845_osm_l3_nodes),
+       .lut_row_size = OSM_LUT_ROW_SIZE,
+       .reg_freq_lut = OSM_REG_FREQ_LUT,
+       .reg_perf_state = OSM_REG_PERF_STATE,
 };
 
 DEFINE_QNODE(sc7180_osm_apps_l3, SC7180_MASTER_OSM_L3_APPS, 16, SC7180_SLAVE_OSM_L3);
 DEFINE_QNODE(sc7180_osm_l3, SC7180_SLAVE_OSM_L3, 16);
 
-static struct qcom_icc_node *sc7180_osm_l3_nodes[] = {
+static const struct qcom_icc_node *sc7180_osm_l3_nodes[] = {
        [MASTER_OSM_L3_APPS] = &sc7180_osm_apps_l3,
        [SLAVE_OSM_L3] = &sc7180_osm_l3,
 };
@@ -94,13 +108,48 @@ static struct qcom_icc_node *sc7180_osm_l3_nodes[] = {
 static const struct qcom_icc_desc sc7180_icc_osm_l3 = {
        .nodes = sc7180_osm_l3_nodes,
        .num_nodes = ARRAY_SIZE(sc7180_osm_l3_nodes),
+       .lut_row_size = OSM_LUT_ROW_SIZE,
+       .reg_freq_lut = OSM_REG_FREQ_LUT,
+       .reg_perf_state = OSM_REG_PERF_STATE,
+};
+
+DEFINE_QNODE(sm8150_osm_apps_l3, SM8150_MASTER_OSM_L3_APPS, 32, SM8150_SLAVE_OSM_L3);
+DEFINE_QNODE(sm8150_osm_l3, SM8150_SLAVE_OSM_L3, 32);
+
+static const struct qcom_icc_node *sm8150_osm_l3_nodes[] = {
+       [MASTER_OSM_L3_APPS] = &sm8150_osm_apps_l3,
+       [SLAVE_OSM_L3] = &sm8150_osm_l3,
+};
+
+static const struct qcom_icc_desc sm8150_icc_osm_l3 = {
+       .nodes = sm8150_osm_l3_nodes,
+       .num_nodes = ARRAY_SIZE(sm8150_osm_l3_nodes),
+       .lut_row_size = OSM_LUT_ROW_SIZE,
+       .reg_freq_lut = OSM_REG_FREQ_LUT,
+       .reg_perf_state = OSM_REG_PERF_STATE,
+};
+
+DEFINE_QNODE(sm8250_epss_apps_l3, SM8250_MASTER_EPSS_L3_APPS, 32, SM8250_SLAVE_EPSS_L3);
+DEFINE_QNODE(sm8250_epss_l3, SM8250_SLAVE_EPSS_L3, 32);
+
+static const struct qcom_icc_node *sm8250_epss_l3_nodes[] = {
+       [MASTER_EPSS_L3_APPS] = &sm8250_epss_apps_l3,
+       [SLAVE_EPSS_L3_SHARED] = &sm8250_epss_l3,
+};
+
+static const struct qcom_icc_desc sm8250_icc_epss_l3 = {
+       .nodes = sm8250_epss_l3_nodes,
+       .num_nodes = ARRAY_SIZE(sm8250_epss_l3_nodes),
+       .lut_row_size = EPSS_LUT_ROW_SIZE,
+       .reg_freq_lut = EPSS_REG_FREQ_LUT,
+       .reg_perf_state = EPSS_REG_PERF_STATE,
 };
 
 static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
 {
        struct qcom_osm_l3_icc_provider *qp;
        struct icc_provider *provider;
-       struct qcom_icc_node *qn;
+       const struct qcom_icc_node *qn;
        struct icc_node *n;
        unsigned int index;
        u32 agg_peak = 0;
@@ -124,7 +173,7 @@ static int qcom_icc_set(struct icc_node *src, struct icc_node *dst)
                        break;
        }
 
-       writel_relaxed(index, qp->base + REG_PERF_STATE);
+       writel_relaxed(index, qp->base + qp->reg_perf_state);
 
        return 0;
 }
@@ -145,7 +194,7 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
        const struct qcom_icc_desc *desc;
        struct icc_onecell_data *data;
        struct icc_provider *provider;
-       struct qcom_icc_node **qnodes;
+       const struct qcom_icc_node **qnodes;
        struct icc_node *node;
        size_t num_nodes;
        struct clk *clk;
@@ -179,9 +228,15 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
+       desc = device_get_match_data(&pdev->dev);
+       if (!desc)
+               return -EINVAL;
+
+       qp->reg_perf_state = desc->reg_perf_state;
+
        for (i = 0; i < LUT_MAX_ENTRIES; i++) {
-               info = readl_relaxed(qp->base + REG_FREQ_LUT +
-                                    i * LUT_ROW_SIZE);
+               info = readl_relaxed(qp->base + desc->reg_freq_lut +
+                                    i * desc->lut_row_size);
                src = FIELD_GET(LUT_SRC, info);
                lval = FIELD_GET(LUT_L_VAL, info);
                if (src)
@@ -200,10 +255,6 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
        }
        qp->max_state = i;
 
-       desc = device_get_match_data(&pdev->dev);
-       if (!desc)
-               return -EINVAL;
-
        qnodes = desc->nodes;
        num_nodes = desc->num_nodes;
 
@@ -235,7 +286,8 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
                }
 
                node->name = qnodes[i]->name;
-               node->data = qnodes[i];
+               /* Cast away const and add it back in qcom_icc_set() */
+               node->data = (void *)qnodes[i];
                icc_node_add(node, provider);
 
                for (j = 0; j < qnodes[i]->num_links; j++)
@@ -258,6 +310,8 @@ err:
 static const struct of_device_id osm_l3_of_match[] = {
        { .compatible = "qcom,sc7180-osm-l3", .data = &sc7180_icc_osm_l3 },
        { .compatible = "qcom,sdm845-osm-l3", .data = &sdm845_icc_osm_l3 },
+       { .compatible = "qcom,sm8150-osm-l3", .data = &sm8150_icc_osm_l3 },
+       { .compatible = "qcom,sm8250-epss-l3", .data = &sm8250_icc_epss_l3 },
        { }
 };
 MODULE_DEVICE_TABLE(of, osm_l3_of_match);
@@ -268,6 +322,7 @@ static struct platform_driver osm_l3_driver = {
        .driver = {
                .name = "osm-l3",
                .of_match_table = osm_l3_of_match,
+               .sync_state = icc_sync_state,
        },
 };
 module_platform_driver(osm_l3_driver);
index dcf493d..bf11b82 100644 (file)
@@ -535,7 +535,7 @@ static int qnoc_probe(struct platform_device *pdev)
        provider->set = qcom_icc_set;
        provider->pre_aggregate = qcom_icc_pre_aggregate;
        provider->aggregate = qcom_icc_aggregate;
-       provider->xlate = of_icc_xlate_onecell;
+       provider->xlate_extended = qcom_icc_xlate_extended;
        INIT_LIST_HEAD(&provider->nodes);
        provider->data = data;
 
@@ -633,6 +633,7 @@ static struct platform_driver qnoc_driver = {
        .driver = {
                .name = "qnoc-sc7180",
                .of_match_table = qnoc_of_match,
+               .sync_state = icc_sync_state,
        },
 };
 module_platform_driver(qnoc_driver);
index f6c7b96..d79e316 100644 (file)
@@ -469,7 +469,7 @@ static int qnoc_probe(struct platform_device *pdev)
        provider->set = qcom_icc_set;
        provider->pre_aggregate = qcom_icc_pre_aggregate;
        provider->aggregate = qcom_icc_aggregate;
-       provider->xlate = of_icc_xlate_onecell;
+       provider->xlate_extended = qcom_icc_xlate_extended;
        INIT_LIST_HEAD(&provider->nodes);
        provider->data = data;
 
@@ -559,6 +559,7 @@ static struct platform_driver qnoc_driver = {
        .driver = {
                .name = "qnoc-sdm845",
                .of_match_table = qnoc_of_match,
+               .sync_state = icc_sync_state,
        },
 };
 module_platform_driver(qnoc_driver);
diff --git a/drivers/interconnect/qcom/sm8150.c b/drivers/interconnect/qcom/sm8150.c
new file mode 100644 (file)
index 0000000..9218efe
--- /dev/null
@@ -0,0 +1,635 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/interconnect.h>
+#include <linux/interconnect-provider.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <dt-bindings/interconnect/qcom,sm8150.h>
+
+#include "bcm-voter.h"
+#include "icc-rpmh.h"
+#include "sm8150.h"
+
+DEFINE_QNODE(qhm_a1noc_cfg, SM8150_MASTER_A1NOC_CFG, 1, 4, SM8150_SLAVE_SERVICE_A1NOC);
+DEFINE_QNODE(qhm_qup0, SM8150_MASTER_QUP_0, 1, 4, SM8150_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_emac, SM8150_MASTER_EMAC, 1, 8, SM8150_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_ufs_mem, SM8150_MASTER_UFS_MEM, 1, 8, SM8150_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_usb3_0, SM8150_MASTER_USB3, 1, 8, SM8150_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_usb3_1, SM8150_MASTER_USB3_1, 1, 8, SM8150_A1NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_a2noc_cfg, SM8150_MASTER_A2NOC_CFG, 1, 4, SM8150_SLAVE_SERVICE_A2NOC);
+DEFINE_QNODE(qhm_qdss_bam, SM8150_MASTER_QDSS_BAM, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qspi, SM8150_MASTER_QSPI, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qup1, SM8150_MASTER_QUP_1, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qup2, SM8150_MASTER_QUP_2, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_sensorss_ahb, SM8150_MASTER_SENSORS_AHB, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_tsif, SM8150_MASTER_TSIF, 1, 4, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qnm_cnoc, SM8150_MASTER_CNOC_A2NOC, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qxm_crypto, SM8150_MASTER_CRYPTO_CORE_0, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qxm_ipa, SM8150_MASTER_IPA, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_pcie3_0, SM8150_MASTER_PCIE, 1, 8, SM8150_SLAVE_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(xm_pcie3_1, SM8150_MASTER_PCIE_1, 1, 8, SM8150_SLAVE_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(xm_qdss_etr, SM8150_MASTER_QDSS_ETR, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_sdc2, SM8150_MASTER_SDCC_2, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_sdc4, SM8150_MASTER_SDCC_4, 1, 8, SM8150_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qxm_camnoc_hf0_uncomp, SM8150_MASTER_CAMNOC_HF0_UNCOMP, 1, 32, SM8150_SLAVE_CAMNOC_UNCOMP);
+DEFINE_QNODE(qxm_camnoc_hf1_uncomp, SM8150_MASTER_CAMNOC_HF1_UNCOMP, 1, 32, SM8150_SLAVE_CAMNOC_UNCOMP);
+DEFINE_QNODE(qxm_camnoc_sf_uncomp, SM8150_MASTER_CAMNOC_SF_UNCOMP, 1, 32, SM8150_SLAVE_CAMNOC_UNCOMP);
+DEFINE_QNODE(qnm_npu, SM8150_MASTER_NPU, 1, 32, SM8150_SLAVE_CDSP_MEM_NOC);
+DEFINE_QNODE(qhm_spdm, SM8150_MASTER_SPDM, 1, 4, SM8150_SLAVE_CNOC_A2NOC);
+DEFINE_QNODE(qnm_snoc, SM8150_SNOC_CNOC_MAS, 1, 8, SM8150_SLAVE_TLMM_SOUTH, SM8150_SLAVE_CDSP_CFG, SM8150_SLAVE_SPSS_CFG, SM8150_SLAVE_CAMERA_CFG, SM8150_SLAVE_SDCC_4, SM8150_SLAVE_SDCC_2, SM8150_SLAVE_CNOC_MNOC_CFG, SM8150_SLAVE_EMAC_CFG, SM8150_SLAVE_UFS_MEM_CFG, SM8150_SLAVE_TLMM_EAST, SM8150_SLAVE_SSC_CFG, SM8150_SLAVE_SNOC_CFG, SM8150_SLAVE_NORTH_PHY_CFG, SM8150_SLAVE_QUP_0, SM8150_SLAVE_GLM, SM8150_SLAVE_PCIE_1_CFG, SM8150_SLAVE_A2NOC_CFG, SM8150_SLAVE_QDSS_CFG, SM8150_SLAVE_DISPLAY_CFG, SM8150_SLAVE_TCSR, SM8150_SLAVE_CNOC_DDRSS, SM8150_SLAVE_RBCPR_MMCX_CFG, SM8150_SLAVE_NPU_CFG, SM8150_SLAVE_PCIE_0_CFG, SM8150_SLAVE_GRAPHICS_3D_CFG, SM8150_SLAVE_VENUS_CFG, SM8150_SLAVE_TSIF, SM8150_SLAVE_IPA_CFG, SM8150_SLAVE_CLK_CTL, SM8150_SLAVE_AOP, SM8150_SLAVE_QUP_1, SM8150_SLAVE_AHB2PHY_SOUTH, SM8150_SLAVE_USB3_1, SM8150_SLAVE_SERVICE_CNOC, SM8150_SLAVE_UFS_CARD_CFG, SM8150_SLAVE_QUP_2, SM8150_SLAVE_RBCPR_CX_CFG, SM8150_SLAVE_TLMM_WEST, SM8150_SLAVE_A1NOC_CFG, SM8150_SLAVE_AOSS, SM8150_SLAVE_PRNG, SM8150_SLAVE_VSENSE_CTRL_CFG, SM8150_SLAVE_QSPI, SM8150_SLAVE_USB3, SM8150_SLAVE_SPDM_WRAPPER, SM8150_SLAVE_CRYPTO_0_CFG, SM8150_SLAVE_PIMEM_CFG, SM8150_SLAVE_TLMM_NORTH, SM8150_SLAVE_RBCPR_MX_CFG, SM8150_SLAVE_IMEM_CFG);
+DEFINE_QNODE(xm_qdss_dap, SM8150_MASTER_QDSS_DAP, 1, 8, SM8150_SLAVE_TLMM_SOUTH, SM8150_SLAVE_CDSP_CFG, SM8150_SLAVE_SPSS_CFG, SM8150_SLAVE_CAMERA_CFG, SM8150_SLAVE_SDCC_4, SM8150_SLAVE_SDCC_2, SM8150_SLAVE_CNOC_MNOC_CFG, SM8150_SLAVE_EMAC_CFG, SM8150_SLAVE_UFS_MEM_CFG, SM8150_SLAVE_TLMM_EAST, SM8150_SLAVE_SSC_CFG, SM8150_SLAVE_SNOC_CFG, SM8150_SLAVE_NORTH_PHY_CFG, SM8150_SLAVE_QUP_0, SM8150_SLAVE_GLM, SM8150_SLAVE_PCIE_1_CFG, SM8150_SLAVE_A2NOC_CFG, SM8150_SLAVE_QDSS_CFG, SM8150_SLAVE_DISPLAY_CFG, SM8150_SLAVE_TCSR, SM8150_SLAVE_CNOC_DDRSS, SM8150_SLAVE_CNOC_A2NOC, SM8150_SLAVE_RBCPR_MMCX_CFG, SM8150_SLAVE_NPU_CFG, SM8150_SLAVE_PCIE_0_CFG, SM8150_SLAVE_GRAPHICS_3D_CFG, SM8150_SLAVE_VENUS_CFG, SM8150_SLAVE_TSIF, SM8150_SLAVE_IPA_CFG, SM8150_SLAVE_CLK_CTL, SM8150_SLAVE_AOP, SM8150_SLAVE_QUP_1, SM8150_SLAVE_AHB2PHY_SOUTH, SM8150_SLAVE_USB3_1, SM8150_SLAVE_SERVICE_CNOC, SM8150_SLAVE_UFS_CARD_CFG, SM8150_SLAVE_QUP_2, SM8150_SLAVE_RBCPR_CX_CFG, SM8150_SLAVE_TLMM_WEST, SM8150_SLAVE_A1NOC_CFG, SM8150_SLAVE_AOSS, SM8150_SLAVE_PRNG, SM8150_SLAVE_VSENSE_CTRL_CFG, SM8150_SLAVE_QSPI, SM8150_SLAVE_USB3, SM8150_SLAVE_SPDM_WRAPPER, SM8150_SLAVE_CRYPTO_0_CFG, SM8150_SLAVE_PIMEM_CFG, SM8150_SLAVE_TLMM_NORTH, SM8150_SLAVE_RBCPR_MX_CFG, SM8150_SLAVE_IMEM_CFG);
+DEFINE_QNODE(qhm_cnoc_dc_noc, SM8150_MASTER_CNOC_DC_NOC, 1, 4, SM8150_SLAVE_GEM_NOC_CFG, SM8150_SLAVE_LLCC_CFG);
+DEFINE_QNODE(acm_apps, SM8150_MASTER_AMPSS_M0, 2, 32, SM8150_SLAVE_ECC, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(acm_gpu_tcu, SM8150_MASTER_GPU_TCU, 1, 8, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(acm_sys_tcu, SM8150_MASTER_SYS_TCU, 1, 8, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qhm_gemnoc_cfg, SM8150_MASTER_GEM_NOC_CFG, 1, 4, SM8150_SLAVE_SERVICE_GEM_NOC, SM8150_SLAVE_MSS_PROC_MS_MPU_CFG);
+DEFINE_QNODE(qnm_cmpnoc, SM8150_MASTER_COMPUTE_NOC, 2, 32, SM8150_SLAVE_ECC, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_gpu, SM8150_MASTER_GRAPHICS_3D, 2, 32, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_mnoc_hf, SM8150_MASTER_MNOC_HF_MEM_NOC, 2, 32, SM8150_SLAVE_LLCC);
+DEFINE_QNODE(qnm_mnoc_sf, SM8150_MASTER_MNOC_SF_MEM_NOC, 1, 32, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_pcie, SM8150_MASTER_GEM_NOC_PCIE_SNOC, 1, 16, SM8150_SLAVE_LLCC, SM8150_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_snoc_gc, SM8150_MASTER_SNOC_GC_MEM_NOC, 1, 8, SM8150_SLAVE_LLCC);
+DEFINE_QNODE(qnm_snoc_sf, SM8150_MASTER_SNOC_SF_MEM_NOC, 1, 16, SM8150_SLAVE_LLCC);
+DEFINE_QNODE(qxm_ecc, SM8150_MASTER_ECC, 2, 32, SM8150_SLAVE_LLCC);
+DEFINE_QNODE(ipa_core_master, SM8150_MASTER_IPA_CORE, 1, 8, SM8150_SLAVE_IPA_CORE);
+DEFINE_QNODE(llcc_mc, SM8150_MASTER_LLCC, 4, 4, SM8150_SLAVE_EBI_CH0);
+DEFINE_QNODE(qhm_mnoc_cfg, SM8150_MASTER_CNOC_MNOC_CFG, 1, 4, SM8150_SLAVE_SERVICE_MNOC);
+DEFINE_QNODE(qxm_camnoc_hf0, SM8150_MASTER_CAMNOC_HF0, 1, 32, SM8150_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_camnoc_hf1, SM8150_MASTER_CAMNOC_HF1, 1, 32, SM8150_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_camnoc_sf, SM8150_MASTER_CAMNOC_SF, 1, 32, SM8150_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxm_mdp0, SM8150_MASTER_MDP_PORT0, 1, 32, SM8150_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_mdp1, SM8150_MASTER_MDP_PORT1, 1, 32, SM8150_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_rot, SM8150_MASTER_ROTATOR, 1, 32, SM8150_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxm_venus0, SM8150_MASTER_VIDEO_P0, 1, 32, SM8150_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxm_venus1, SM8150_MASTER_VIDEO_P1, 1, 32, SM8150_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxm_venus_arm9, SM8150_MASTER_VIDEO_PROC, 1, 8, SM8150_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qhm_snoc_cfg, SM8150_MASTER_SNOC_CFG, 1, 4, SM8150_SLAVE_SERVICE_SNOC);
+DEFINE_QNODE(qnm_aggre1_noc, SM8150_A1NOC_SNOC_MAS, 1, 16, SM8150_SLAVE_SNOC_GEM_NOC_SF, SM8150_SLAVE_PIMEM, SM8150_SLAVE_OCIMEM, SM8150_SLAVE_APPSS, SM8150_SNOC_CNOC_SLV, SM8150_SLAVE_QDSS_STM);
+DEFINE_QNODE(qnm_aggre2_noc, SM8150_A2NOC_SNOC_MAS, 1, 16, SM8150_SLAVE_SNOC_GEM_NOC_SF, SM8150_SLAVE_PIMEM, SM8150_SLAVE_OCIMEM, SM8150_SLAVE_APPSS, SM8150_SNOC_CNOC_SLV, SM8150_SLAVE_PCIE_0, SM8150_SLAVE_PCIE_1, SM8150_SLAVE_TCU, SM8150_SLAVE_QDSS_STM);
+DEFINE_QNODE(qnm_gemnoc, SM8150_MASTER_GEM_NOC_SNOC, 1, 8, SM8150_SLAVE_PIMEM, SM8150_SLAVE_OCIMEM, SM8150_SLAVE_APPSS, SM8150_SNOC_CNOC_SLV, SM8150_SLAVE_TCU, SM8150_SLAVE_QDSS_STM);
+DEFINE_QNODE(qxm_pimem, SM8150_MASTER_PIMEM, 1, 8, SM8150_SLAVE_SNOC_GEM_NOC_GC, SM8150_SLAVE_OCIMEM);
+DEFINE_QNODE(xm_gic, SM8150_MASTER_GIC, 1, 8, SM8150_SLAVE_SNOC_GEM_NOC_GC, SM8150_SLAVE_OCIMEM);
+DEFINE_QNODE(qns_a1noc_snoc, SM8150_A1NOC_SNOC_SLV, 1, 16, SM8150_A1NOC_SNOC_MAS);
+DEFINE_QNODE(srvc_aggre1_noc, SM8150_SLAVE_SERVICE_A1NOC, 1, 4);
+DEFINE_QNODE(qns_a2noc_snoc, SM8150_A2NOC_SNOC_SLV, 1, 16, SM8150_A2NOC_SNOC_MAS);
+DEFINE_QNODE(qns_pcie_mem_noc, SM8150_SLAVE_ANOC_PCIE_GEM_NOC, 1, 16, SM8150_MASTER_GEM_NOC_PCIE_SNOC);
+DEFINE_QNODE(srvc_aggre2_noc, SM8150_SLAVE_SERVICE_A2NOC, 1, 4);
+DEFINE_QNODE(qns_camnoc_uncomp, SM8150_SLAVE_CAMNOC_UNCOMP, 1, 32);
+DEFINE_QNODE(qns_cdsp_mem_noc, SM8150_SLAVE_CDSP_MEM_NOC, 2, 32, SM8150_MASTER_COMPUTE_NOC);
+DEFINE_QNODE(qhs_a1_noc_cfg, SM8150_SLAVE_A1NOC_CFG, 1, 4, SM8150_MASTER_A1NOC_CFG);
+DEFINE_QNODE(qhs_a2_noc_cfg, SM8150_SLAVE_A2NOC_CFG, 1, 4, SM8150_MASTER_A2NOC_CFG);
+DEFINE_QNODE(qhs_ahb2phy_south, SM8150_SLAVE_AHB2PHY_SOUTH, 1, 4);
+DEFINE_QNODE(qhs_aop, SM8150_SLAVE_AOP, 1, 4);
+DEFINE_QNODE(qhs_aoss, SM8150_SLAVE_AOSS, 1, 4);
+DEFINE_QNODE(qhs_camera_cfg, SM8150_SLAVE_CAMERA_CFG, 1, 4);
+DEFINE_QNODE(qhs_clk_ctl, SM8150_SLAVE_CLK_CTL, 1, 4);
+DEFINE_QNODE(qhs_compute_dsp, SM8150_SLAVE_CDSP_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_cx, SM8150_SLAVE_RBCPR_CX_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_mmcx, SM8150_SLAVE_RBCPR_MMCX_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_mx, SM8150_SLAVE_RBCPR_MX_CFG, 1, 4);
+DEFINE_QNODE(qhs_crypto0_cfg, SM8150_SLAVE_CRYPTO_0_CFG, 1, 4);
+DEFINE_QNODE(qhs_ddrss_cfg, SM8150_SLAVE_CNOC_DDRSS, 1, 4, SM8150_MASTER_CNOC_DC_NOC);
+DEFINE_QNODE(qhs_display_cfg, SM8150_SLAVE_DISPLAY_CFG, 1, 4);
+DEFINE_QNODE(qhs_emac_cfg, SM8150_SLAVE_EMAC_CFG, 1, 4);
+DEFINE_QNODE(qhs_glm, SM8150_SLAVE_GLM, 1, 4);
+DEFINE_QNODE(qhs_gpuss_cfg, SM8150_SLAVE_GRAPHICS_3D_CFG, 1, 8);
+DEFINE_QNODE(qhs_imem_cfg, SM8150_SLAVE_IMEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_ipa, SM8150_SLAVE_IPA_CFG, 1, 4);
+DEFINE_QNODE(qhs_mnoc_cfg, SM8150_SLAVE_CNOC_MNOC_CFG, 1, 4, SM8150_MASTER_CNOC_MNOC_CFG);
+DEFINE_QNODE(qhs_npu_cfg, SM8150_SLAVE_NPU_CFG, 1, 4);
+DEFINE_QNODE(qhs_pcie0_cfg, SM8150_SLAVE_PCIE_0_CFG, 1, 4);
+DEFINE_QNODE(qhs_pcie1_cfg, SM8150_SLAVE_PCIE_1_CFG, 1, 4);
+DEFINE_QNODE(qhs_phy_refgen_north, SM8150_SLAVE_NORTH_PHY_CFG, 1, 4);
+DEFINE_QNODE(qhs_pimem_cfg, SM8150_SLAVE_PIMEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_prng, SM8150_SLAVE_PRNG, 1, 4);
+DEFINE_QNODE(qhs_qdss_cfg, SM8150_SLAVE_QDSS_CFG, 1, 4);
+DEFINE_QNODE(qhs_qspi, SM8150_SLAVE_QSPI, 1, 4);
+DEFINE_QNODE(qhs_qupv3_east, SM8150_SLAVE_QUP_2, 1, 4);
+DEFINE_QNODE(qhs_qupv3_north, SM8150_SLAVE_QUP_1, 1, 4);
+DEFINE_QNODE(qhs_qupv3_south, SM8150_SLAVE_QUP_0, 1, 4);
+DEFINE_QNODE(qhs_sdc2, SM8150_SLAVE_SDCC_2, 1, 4);
+DEFINE_QNODE(qhs_sdc4, SM8150_SLAVE_SDCC_4, 1, 4);
+DEFINE_QNODE(qhs_snoc_cfg, SM8150_SLAVE_SNOC_CFG, 1, 4, SM8150_MASTER_SNOC_CFG);
+DEFINE_QNODE(qhs_spdm, SM8150_SLAVE_SPDM_WRAPPER, 1, 4);
+DEFINE_QNODE(qhs_spss_cfg, SM8150_SLAVE_SPSS_CFG, 1, 4);
+DEFINE_QNODE(qhs_ssc_cfg, SM8150_SLAVE_SSC_CFG, 1, 4);
+DEFINE_QNODE(qhs_tcsr, SM8150_SLAVE_TCSR, 1, 4);
+DEFINE_QNODE(qhs_tlmm_east, SM8150_SLAVE_TLMM_EAST, 1, 4);
+DEFINE_QNODE(qhs_tlmm_north, SM8150_SLAVE_TLMM_NORTH, 1, 4);
+DEFINE_QNODE(qhs_tlmm_south, SM8150_SLAVE_TLMM_SOUTH, 1, 4);
+DEFINE_QNODE(qhs_tlmm_west, SM8150_SLAVE_TLMM_WEST, 1, 4);
+DEFINE_QNODE(qhs_tsif, SM8150_SLAVE_TSIF, 1, 4);
+DEFINE_QNODE(qhs_ufs_card_cfg, SM8150_SLAVE_UFS_CARD_CFG, 1, 4);
+DEFINE_QNODE(qhs_ufs_mem_cfg, SM8150_SLAVE_UFS_MEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_usb3_0, SM8150_SLAVE_USB3, 1, 4);
+DEFINE_QNODE(qhs_usb3_1, SM8150_SLAVE_USB3_1, 1, 4);
+DEFINE_QNODE(qhs_venus_cfg, SM8150_SLAVE_VENUS_CFG, 1, 4);
+DEFINE_QNODE(qhs_vsense_ctrl_cfg, SM8150_SLAVE_VSENSE_CTRL_CFG, 1, 4);
+DEFINE_QNODE(qns_cnoc_a2noc, SM8150_SLAVE_CNOC_A2NOC, 1, 8, SM8150_MASTER_CNOC_A2NOC);
+DEFINE_QNODE(srvc_cnoc, SM8150_SLAVE_SERVICE_CNOC, 1, 4);
+DEFINE_QNODE(qhs_llcc, SM8150_SLAVE_LLCC_CFG, 1, 4);
+DEFINE_QNODE(qhs_memnoc, SM8150_SLAVE_GEM_NOC_CFG, 1, 4, SM8150_MASTER_GEM_NOC_CFG);
+DEFINE_QNODE(qhs_mdsp_ms_mpu_cfg, SM8150_SLAVE_MSS_PROC_MS_MPU_CFG, 1, 4);
+DEFINE_QNODE(qns_ecc, SM8150_SLAVE_ECC, 1, 32);
+DEFINE_QNODE(qns_gem_noc_snoc, SM8150_SLAVE_GEM_NOC_SNOC, 1, 8, SM8150_MASTER_GEM_NOC_SNOC);
+DEFINE_QNODE(qns_llcc, SM8150_SLAVE_LLCC, 4, 16, SM8150_MASTER_LLCC);
+DEFINE_QNODE(srvc_gemnoc, SM8150_SLAVE_SERVICE_GEM_NOC, 1, 4);
+DEFINE_QNODE(ipa_core_slave, SM8150_SLAVE_IPA_CORE, 1, 8);
+DEFINE_QNODE(ebi, SM8150_SLAVE_EBI_CH0, 4, 4);
+DEFINE_QNODE(qns2_mem_noc, SM8150_SLAVE_MNOC_SF_MEM_NOC, 1, 32, SM8150_MASTER_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qns_mem_noc_hf, SM8150_SLAVE_MNOC_HF_MEM_NOC, 2, 32, SM8150_MASTER_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(srvc_mnoc, SM8150_SLAVE_SERVICE_MNOC, 1, 4);
+DEFINE_QNODE(qhs_apss, SM8150_SLAVE_APPSS, 1, 8);
+DEFINE_QNODE(qns_cnoc, SM8150_SNOC_CNOC_SLV, 1, 8, SM8150_SNOC_CNOC_MAS);
+DEFINE_QNODE(qns_gemnoc_gc, SM8150_SLAVE_SNOC_GEM_NOC_GC, 1, 8, SM8150_MASTER_SNOC_GC_MEM_NOC);
+DEFINE_QNODE(qns_gemnoc_sf, SM8150_SLAVE_SNOC_GEM_NOC_SF, 1, 16, SM8150_MASTER_SNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxs_imem, SM8150_SLAVE_OCIMEM, 1, 8);
+DEFINE_QNODE(qxs_pimem, SM8150_SLAVE_PIMEM, 1, 8);
+DEFINE_QNODE(srvc_snoc, SM8150_SLAVE_SERVICE_SNOC, 1, 4);
+DEFINE_QNODE(xs_pcie_0, SM8150_SLAVE_PCIE_0, 1, 8);
+DEFINE_QNODE(xs_pcie_1, SM8150_SLAVE_PCIE_1, 1, 8);
+DEFINE_QNODE(xs_qdss_stm, SM8150_SLAVE_QDSS_STM, 1, 4);
+DEFINE_QNODE(xs_sys_tcu_cfg, SM8150_SLAVE_TCU, 1, 8);
+
+DEFINE_QBCM(bcm_acv, "ACV", false, &ebi);
+DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi);
+DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc);
+DEFINE_QBCM(bcm_mm0, "MM0", true, &qns_mem_noc_hf);
+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_sh2, "SH2", false, &qns_gem_noc_snoc);
+DEFINE_QBCM(bcm_mm2, "MM2", false, &qxm_camnoc_sf, &qns2_mem_noc);
+DEFINE_QBCM(bcm_sh3, "SH3", false, &acm_gpu_tcu, &acm_sys_tcu);
+DEFINE_QBCM(bcm_mm3, "MM3", false, &qxm_rot, &qxm_venus0, &qxm_venus1, &qxm_venus_arm9);
+DEFINE_QBCM(bcm_sh4, "SH4", false, &qnm_cmpnoc);
+DEFINE_QBCM(bcm_sh5, "SH5", false, &acm_apps);
+DEFINE_QBCM(bcm_sn0, "SN0", true, &qns_gemnoc_sf);
+DEFINE_QBCM(bcm_co0, "CO0", false, &qns_cdsp_mem_noc);
+DEFINE_QBCM(bcm_ce0, "CE0", false, &qxm_crypto);
+DEFINE_QBCM(bcm_sn1, "SN1", false, &qxs_imem);
+DEFINE_QBCM(bcm_co1, "CO1", false, &qnm_npu);
+DEFINE_QBCM(bcm_ip0, "IP0", false, &ipa_core_slave);
+DEFINE_QBCM(bcm_cn0, "CN0", true, &qhm_spdm, &qnm_snoc, &qhs_a1_noc_cfg, &qhs_a2_noc_cfg, &qhs_ahb2phy_south, &qhs_aop, &qhs_aoss, &qhs_camera_cfg, &qhs_clk_ctl, &qhs_compute_dsp, &qhs_cpr_cx, &qhs_cpr_mmcx, &qhs_cpr_mx, &qhs_crypto0_cfg, &qhs_ddrss_cfg, &qhs_display_cfg, &qhs_emac_cfg, &qhs_glm, &qhs_gpuss_cfg, &qhs_imem_cfg, &qhs_ipa, &qhs_mnoc_cfg, &qhs_npu_cfg, &qhs_pcie0_cfg, &qhs_pcie1_cfg, &qhs_phy_refgen_north, &qhs_pimem_cfg, &qhs_prng, &qhs_qdss_cfg, &qhs_qspi, &qhs_qupv3_east, &qhs_qupv3_north, &qhs_qupv3_south, &qhs_sdc2, &qhs_sdc4, &qhs_snoc_cfg, &qhs_spdm, &qhs_spss_cfg, &qhs_ssc_cfg, &qhs_tcsr, &qhs_tlmm_east, &qhs_tlmm_north, &qhs_tlmm_south, &qhs_tlmm_west, &qhs_tsif, &qhs_ufs_card_cfg, &qhs_ufs_mem_cfg, &qhs_usb3_0, &qhs_usb3_1, &qhs_venus_cfg, &qhs_vsense_ctrl_cfg, &qns_cnoc_a2noc, &srvc_cnoc);
+DEFINE_QBCM(bcm_qup0, "QUP0", false, &qhm_qup0, &qhm_qup1, &qhm_qup2);
+DEFINE_QBCM(bcm_sn2, "SN2", false, &qns_gemnoc_gc);
+DEFINE_QBCM(bcm_sn3, "SN3", false, &srvc_aggre1_noc, &srvc_aggre2_noc, &qns_cnoc);
+DEFINE_QBCM(bcm_sn4, "SN4", false, &qxs_pimem);
+DEFINE_QBCM(bcm_sn5, "SN5", false, &xs_qdss_stm);
+DEFINE_QBCM(bcm_sn8, "SN8", false, &xs_pcie_0, &xs_pcie_1);
+DEFINE_QBCM(bcm_sn9, "SN9", false, &qnm_aggre1_noc);
+DEFINE_QBCM(bcm_sn11, "SN11", false, &qnm_aggre2_noc);
+DEFINE_QBCM(bcm_sn12, "SN12", false, &qxm_pimem, &xm_gic);
+DEFINE_QBCM(bcm_sn14, "SN14", false, &qns_pcie_mem_noc);
+DEFINE_QBCM(bcm_sn15, "SN15", false, &qnm_gemnoc);
+
+static struct qcom_icc_bcm *aggre1_noc_bcms[] = {
+       &bcm_qup0,
+       &bcm_sn3,
+};
+
+static struct qcom_icc_node *aggre1_noc_nodes[] = {
+       [MASTER_A1NOC_CFG] = &qhm_a1noc_cfg,
+       [MASTER_QUP_0] = &qhm_qup0,
+       [MASTER_EMAC] = &xm_emac,
+       [MASTER_UFS_MEM] = &xm_ufs_mem,
+       [MASTER_USB3] = &xm_usb3_0,
+       [MASTER_USB3_1] = &xm_usb3_1,
+       [A1NOC_SNOC_SLV] = &qns_a1noc_snoc,
+       [SLAVE_SERVICE_A1NOC] = &srvc_aggre1_noc,
+};
+
+static struct qcom_icc_desc sm8150_aggre1_noc = {
+       .nodes = aggre1_noc_nodes,
+       .num_nodes = ARRAY_SIZE(aggre1_noc_nodes),
+       .bcms = aggre1_noc_bcms,
+       .num_bcms = ARRAY_SIZE(aggre1_noc_bcms),
+};
+
+static struct qcom_icc_bcm *aggre2_noc_bcms[] = {
+       &bcm_ce0,
+       &bcm_qup0,
+       &bcm_sn14,
+       &bcm_sn3,
+};
+
+static struct qcom_icc_node *aggre2_noc_nodes[] = {
+       [MASTER_A2NOC_CFG] = &qhm_a2noc_cfg,
+       [MASTER_QDSS_BAM] = &qhm_qdss_bam,
+       [MASTER_QSPI] = &qhm_qspi,
+       [MASTER_QUP_1] = &qhm_qup1,
+       [MASTER_QUP_2] = &qhm_qup2,
+       [MASTER_SENSORS_AHB] = &qhm_sensorss_ahb,
+       [MASTER_TSIF] = &qhm_tsif,
+       [MASTER_CNOC_A2NOC] = &qnm_cnoc,
+       [MASTER_CRYPTO_CORE_0] = &qxm_crypto,
+       [MASTER_IPA] = &qxm_ipa,
+       [MASTER_PCIE] = &xm_pcie3_0,
+       [MASTER_PCIE_1] = &xm_pcie3_1,
+       [MASTER_QDSS_ETR] = &xm_qdss_etr,
+       [MASTER_SDCC_2] = &xm_sdc2,
+       [MASTER_SDCC_4] = &xm_sdc4,
+       [A2NOC_SNOC_SLV] = &qns_a2noc_snoc,
+       [SLAVE_ANOC_PCIE_GEM_NOC] = &qns_pcie_mem_noc,
+       [SLAVE_SERVICE_A2NOC] = &srvc_aggre2_noc,
+};
+
+static struct qcom_icc_desc sm8150_aggre2_noc = {
+       .nodes = aggre2_noc_nodes,
+       .num_nodes = ARRAY_SIZE(aggre2_noc_nodes),
+       .bcms = aggre2_noc_bcms,
+       .num_bcms = ARRAY_SIZE(aggre2_noc_bcms),
+};
+
+static struct qcom_icc_bcm *camnoc_virt_bcms[] = {
+       &bcm_mm1,
+};
+
+static struct qcom_icc_node *camnoc_virt_nodes[] = {
+       [MASTER_CAMNOC_HF0_UNCOMP] = &qxm_camnoc_hf0_uncomp,
+       [MASTER_CAMNOC_HF1_UNCOMP] = &qxm_camnoc_hf1_uncomp,
+       [MASTER_CAMNOC_SF_UNCOMP] = &qxm_camnoc_sf_uncomp,
+       [SLAVE_CAMNOC_UNCOMP] = &qns_camnoc_uncomp,
+};
+
+static struct qcom_icc_desc sm8150_camnoc_virt = {
+       .nodes = camnoc_virt_nodes,
+       .num_nodes = ARRAY_SIZE(camnoc_virt_nodes),
+       .bcms = camnoc_virt_bcms,
+       .num_bcms = ARRAY_SIZE(camnoc_virt_bcms),
+};
+
+static struct qcom_icc_bcm *compute_noc_bcms[] = {
+       &bcm_co0,
+       &bcm_co1,
+};
+
+static struct qcom_icc_node *compute_noc_nodes[] = {
+       [MASTER_NPU] = &qnm_npu,
+       [SLAVE_CDSP_MEM_NOC] = &qns_cdsp_mem_noc,
+};
+
+static struct qcom_icc_desc sm8150_compute_noc = {
+       .nodes = compute_noc_nodes,
+       .num_nodes = ARRAY_SIZE(compute_noc_nodes),
+       .bcms = compute_noc_bcms,
+       .num_bcms = ARRAY_SIZE(compute_noc_bcms),
+};
+
+static struct qcom_icc_bcm *config_noc_bcms[] = {
+       &bcm_cn0,
+};
+
+static struct qcom_icc_node *config_noc_nodes[] = {
+       [MASTER_SPDM] = &qhm_spdm,
+       [SNOC_CNOC_MAS] = &qnm_snoc,
+       [MASTER_QDSS_DAP] = &xm_qdss_dap,
+       [SLAVE_A1NOC_CFG] = &qhs_a1_noc_cfg,
+       [SLAVE_A2NOC_CFG] = &qhs_a2_noc_cfg,
+       [SLAVE_AHB2PHY_SOUTH] = &qhs_ahb2phy_south,
+       [SLAVE_AOP] = &qhs_aop,
+       [SLAVE_AOSS] = &qhs_aoss,
+       [SLAVE_CAMERA_CFG] = &qhs_camera_cfg,
+       [SLAVE_CLK_CTL] = &qhs_clk_ctl,
+       [SLAVE_CDSP_CFG] = &qhs_compute_dsp,
+       [SLAVE_RBCPR_CX_CFG] = &qhs_cpr_cx,
+       [SLAVE_RBCPR_MMCX_CFG] = &qhs_cpr_mmcx,
+       [SLAVE_RBCPR_MX_CFG] = &qhs_cpr_mx,
+       [SLAVE_CRYPTO_0_CFG] = &qhs_crypto0_cfg,
+       [SLAVE_CNOC_DDRSS] = &qhs_ddrss_cfg,
+       [SLAVE_DISPLAY_CFG] = &qhs_display_cfg,
+       [SLAVE_EMAC_CFG] = &qhs_emac_cfg,
+       [SLAVE_GLM] = &qhs_glm,
+       [SLAVE_GRAPHICS_3D_CFG] = &qhs_gpuss_cfg,
+       [SLAVE_IMEM_CFG] = &qhs_imem_cfg,
+       [SLAVE_IPA_CFG] = &qhs_ipa,
+       [SLAVE_CNOC_MNOC_CFG] = &qhs_mnoc_cfg,
+       [SLAVE_NPU_CFG] = &qhs_npu_cfg,
+       [SLAVE_PCIE_0_CFG] = &qhs_pcie0_cfg,
+       [SLAVE_PCIE_1_CFG] = &qhs_pcie1_cfg,
+       [SLAVE_NORTH_PHY_CFG] = &qhs_phy_refgen_north,
+       [SLAVE_PIMEM_CFG] = &qhs_pimem_cfg,
+       [SLAVE_PRNG] = &qhs_prng,
+       [SLAVE_QDSS_CFG] = &qhs_qdss_cfg,
+       [SLAVE_QSPI] = &qhs_qspi,
+       [SLAVE_QUP_2] = &qhs_qupv3_east,
+       [SLAVE_QUP_1] = &qhs_qupv3_north,
+       [SLAVE_QUP_0] = &qhs_qupv3_south,
+       [SLAVE_SDCC_2] = &qhs_sdc2,
+       [SLAVE_SDCC_4] = &qhs_sdc4,
+       [SLAVE_SNOC_CFG] = &qhs_snoc_cfg,
+       [SLAVE_SPDM_WRAPPER] = &qhs_spdm,
+       [SLAVE_SPSS_CFG] = &qhs_spss_cfg,
+       [SLAVE_SSC_CFG] = &qhs_ssc_cfg,
+       [SLAVE_TCSR] = &qhs_tcsr,
+       [SLAVE_TLMM_EAST] = &qhs_tlmm_east,
+       [SLAVE_TLMM_NORTH] = &qhs_tlmm_north,
+       [SLAVE_TLMM_SOUTH] = &qhs_tlmm_south,
+       [SLAVE_TLMM_WEST] = &qhs_tlmm_west,
+       [SLAVE_TSIF] = &qhs_tsif,
+       [SLAVE_UFS_CARD_CFG] = &qhs_ufs_card_cfg,
+       [SLAVE_UFS_MEM_CFG] = &qhs_ufs_mem_cfg,
+       [SLAVE_USB3] = &qhs_usb3_0,
+       [SLAVE_USB3_1] = &qhs_usb3_1,
+       [SLAVE_VENUS_CFG] = &qhs_venus_cfg,
+       [SLAVE_VSENSE_CTRL_CFG] = &qhs_vsense_ctrl_cfg,
+       [SLAVE_CNOC_A2NOC] = &qns_cnoc_a2noc,
+       [SLAVE_SERVICE_CNOC] = &srvc_cnoc,
+};
+
+static struct qcom_icc_desc sm8150_config_noc = {
+       .nodes = config_noc_nodes,
+       .num_nodes = ARRAY_SIZE(config_noc_nodes),
+       .bcms = config_noc_bcms,
+       .num_bcms = ARRAY_SIZE(config_noc_bcms),
+};
+
+static struct qcom_icc_bcm *dc_noc_bcms[] = {
+};
+
+static struct qcom_icc_node *dc_noc_nodes[] = {
+       [MASTER_CNOC_DC_NOC] = &qhm_cnoc_dc_noc,
+       [SLAVE_LLCC_CFG] = &qhs_llcc,
+       [SLAVE_GEM_NOC_CFG] = &qhs_memnoc,
+};
+
+static struct qcom_icc_desc sm8150_dc_noc = {
+       .nodes = dc_noc_nodes,
+       .num_nodes = ARRAY_SIZE(dc_noc_nodes),
+       .bcms = dc_noc_bcms,
+       .num_bcms = ARRAY_SIZE(dc_noc_bcms),
+};
+
+static struct qcom_icc_bcm *gem_noc_bcms[] = {
+       &bcm_sh0,
+       &bcm_sh2,
+       &bcm_sh3,
+       &bcm_sh4,
+       &bcm_sh5,
+};
+
+static struct qcom_icc_node *gem_noc_nodes[] = {
+       [MASTER_AMPSS_M0] = &acm_apps,
+       [MASTER_GPU_TCU] = &acm_gpu_tcu,
+       [MASTER_SYS_TCU] = &acm_sys_tcu,
+       [MASTER_GEM_NOC_CFG] = &qhm_gemnoc_cfg,
+       [MASTER_COMPUTE_NOC] = &qnm_cmpnoc,
+       [MASTER_GRAPHICS_3D] = &qnm_gpu,
+       [MASTER_MNOC_HF_MEM_NOC] = &qnm_mnoc_hf,
+       [MASTER_MNOC_SF_MEM_NOC] = &qnm_mnoc_sf,
+       [MASTER_GEM_NOC_PCIE_SNOC] = &qnm_pcie,
+       [MASTER_SNOC_GC_MEM_NOC] = &qnm_snoc_gc,
+       [MASTER_SNOC_SF_MEM_NOC] = &qnm_snoc_sf,
+       [MASTER_ECC] = &qxm_ecc,
+       [SLAVE_MSS_PROC_MS_MPU_CFG] = &qhs_mdsp_ms_mpu_cfg,
+       [SLAVE_ECC] = &qns_ecc,
+       [SLAVE_GEM_NOC_SNOC] = &qns_gem_noc_snoc,
+       [SLAVE_LLCC] = &qns_llcc,
+       [SLAVE_SERVICE_GEM_NOC] = &srvc_gemnoc,
+};
+
+static struct qcom_icc_desc sm8150_gem_noc = {
+       .nodes = gem_noc_nodes,
+       .num_nodes = ARRAY_SIZE(gem_noc_nodes),
+       .bcms = gem_noc_bcms,
+       .num_bcms = ARRAY_SIZE(gem_noc_bcms),
+};
+
+static struct qcom_icc_bcm *ipa_virt_bcms[] = {
+       &bcm_ip0,
+};
+
+static struct qcom_icc_node *ipa_virt_nodes[] = {
+       [MASTER_IPA_CORE] = &ipa_core_master,
+       [SLAVE_IPA_CORE] = &ipa_core_slave,
+};
+
+static struct qcom_icc_desc sm8150_ipa_virt = {
+       .nodes = ipa_virt_nodes,
+       .num_nodes = ARRAY_SIZE(ipa_virt_nodes),
+       .bcms = ipa_virt_bcms,
+       .num_bcms = ARRAY_SIZE(ipa_virt_bcms),
+};
+
+static struct qcom_icc_bcm *mc_virt_bcms[] = {
+       &bcm_acv,
+       &bcm_mc0,
+};
+
+static struct qcom_icc_node *mc_virt_nodes[] = {
+       [MASTER_LLCC] = &llcc_mc,
+       [SLAVE_EBI_CH0] = &ebi,
+};
+
+static struct qcom_icc_desc sm8150_mc_virt = {
+       .nodes = mc_virt_nodes,
+       .num_nodes = ARRAY_SIZE(mc_virt_nodes),
+       .bcms = mc_virt_bcms,
+       .num_bcms = ARRAY_SIZE(mc_virt_bcms),
+};
+
+static struct qcom_icc_bcm *mmss_noc_bcms[] = {
+       &bcm_mm0,
+       &bcm_mm1,
+       &bcm_mm2,
+       &bcm_mm3,
+};
+
+static struct qcom_icc_node *mmss_noc_nodes[] = {
+       [MASTER_CNOC_MNOC_CFG] = &qhm_mnoc_cfg,
+       [MASTER_CAMNOC_HF0] = &qxm_camnoc_hf0,
+       [MASTER_CAMNOC_HF1] = &qxm_camnoc_hf1,
+       [MASTER_CAMNOC_SF] = &qxm_camnoc_sf,
+       [MASTER_MDP_PORT0] = &qxm_mdp0,
+       [MASTER_MDP_PORT1] = &qxm_mdp1,
+       [MASTER_ROTATOR] = &qxm_rot,
+       [MASTER_VIDEO_P0] = &qxm_venus0,
+       [MASTER_VIDEO_P1] = &qxm_venus1,
+       [MASTER_VIDEO_PROC] = &qxm_venus_arm9,
+       [SLAVE_MNOC_SF_MEM_NOC] = &qns2_mem_noc,
+       [SLAVE_MNOC_HF_MEM_NOC] = &qns_mem_noc_hf,
+       [SLAVE_SERVICE_MNOC] = &srvc_mnoc,
+};
+
+static struct qcom_icc_desc sm8150_mmss_noc = {
+       .nodes = mmss_noc_nodes,
+       .num_nodes = ARRAY_SIZE(mmss_noc_nodes),
+       .bcms = mmss_noc_bcms,
+       .num_bcms = ARRAY_SIZE(mmss_noc_bcms),
+};
+
+static struct qcom_icc_bcm *system_noc_bcms[] = {
+       &bcm_sn0,
+       &bcm_sn1,
+       &bcm_sn11,
+       &bcm_sn12,
+       &bcm_sn15,
+       &bcm_sn2,
+       &bcm_sn3,
+       &bcm_sn4,
+       &bcm_sn5,
+       &bcm_sn8,
+       &bcm_sn9,
+};
+
+static struct qcom_icc_node *system_noc_nodes[] = {
+       [MASTER_SNOC_CFG] = &qhm_snoc_cfg,
+       [A1NOC_SNOC_MAS] = &qnm_aggre1_noc,
+       [A2NOC_SNOC_MAS] = &qnm_aggre2_noc,
+       [MASTER_GEM_NOC_SNOC] = &qnm_gemnoc,
+       [MASTER_PIMEM] = &qxm_pimem,
+       [MASTER_GIC] = &xm_gic,
+       [SLAVE_APPSS] = &qhs_apss,
+       [SNOC_CNOC_SLV] = &qns_cnoc,
+       [SLAVE_SNOC_GEM_NOC_GC] = &qns_gemnoc_gc,
+       [SLAVE_SNOC_GEM_NOC_SF] = &qns_gemnoc_sf,
+       [SLAVE_OCIMEM] = &qxs_imem,
+       [SLAVE_PIMEM] = &qxs_pimem,
+       [SLAVE_SERVICE_SNOC] = &srvc_snoc,
+       [SLAVE_PCIE_0] = &xs_pcie_0,
+       [SLAVE_PCIE_1] = &xs_pcie_1,
+       [SLAVE_QDSS_STM] = &xs_qdss_stm,
+       [SLAVE_TCU] = &xs_sys_tcu_cfg,
+};
+
+static struct qcom_icc_desc sm8150_system_noc = {
+       .nodes = system_noc_nodes,
+       .num_nodes = ARRAY_SIZE(system_noc_nodes),
+       .bcms = system_noc_bcms,
+       .num_bcms = ARRAY_SIZE(system_noc_bcms),
+};
+
+static int qnoc_probe(struct platform_device *pdev)
+{
+       const struct qcom_icc_desc *desc;
+       struct icc_onecell_data *data;
+       struct icc_provider *provider;
+       struct qcom_icc_node **qnodes;
+       struct qcom_icc_provider *qp;
+       struct icc_node *node;
+       size_t num_nodes, i;
+       int ret;
+
+       desc = device_get_match_data(&pdev->dev);
+       if (!desc)
+               return -EINVAL;
+
+       qnodes = desc->nodes;
+       num_nodes = desc->num_nodes;
+
+       qp = devm_kzalloc(&pdev->dev, sizeof(*qp), GFP_KERNEL);
+       if (!qp)
+               return -ENOMEM;
+
+       data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       provider = &qp->provider;
+       provider->dev = &pdev->dev;
+       provider->set = qcom_icc_set;
+       provider->pre_aggregate = qcom_icc_pre_aggregate;
+       provider->aggregate = qcom_icc_aggregate;
+       provider->xlate = of_icc_xlate_onecell;
+       INIT_LIST_HEAD(&provider->nodes);
+       provider->data = data;
+
+       qp->dev = &pdev->dev;
+       qp->bcms = desc->bcms;
+       qp->num_bcms = desc->num_bcms;
+
+       qp->voter = of_bcm_voter_get(qp->dev, NULL);
+       if (IS_ERR(qp->voter))
+               return PTR_ERR(qp->voter);
+
+       ret = icc_provider_add(provider);
+       if (ret) {
+               dev_err(&pdev->dev, "error adding interconnect provider\n");
+               return ret;
+       }
+
+       for (i = 0; i < num_nodes; i++) {
+               size_t j;
+
+               if (!qnodes[i])
+                       continue;
+
+               node = icc_node_create(qnodes[i]->id);
+               if (IS_ERR(node)) {
+                       ret = PTR_ERR(node);
+                       goto err;
+               }
+
+               node->name = qnodes[i]->name;
+               node->data = qnodes[i];
+               icc_node_add(node, provider);
+
+               for (j = 0; j < qnodes[i]->num_links; j++)
+                       icc_link_create(node, qnodes[i]->links[j]);
+
+               data->nodes[i] = node;
+       }
+       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;
+err:
+       icc_nodes_remove(provider);
+       icc_provider_del(provider);
+       return ret;
+}
+
+static int qnoc_remove(struct platform_device *pdev)
+{
+       struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
+
+       icc_nodes_remove(&qp->provider);
+       return icc_provider_del(&qp->provider);
+}
+
+static const struct of_device_id qnoc_of_match[] = {
+       { .compatible = "qcom,sm8150-aggre1-noc",
+         .data = &sm8150_aggre1_noc},
+       { .compatible = "qcom,sm8150-aggre2-noc",
+         .data = &sm8150_aggre2_noc},
+       { .compatible = "qcom,sm8150-camnoc-virt",
+         .data = &sm8150_camnoc_virt},
+       { .compatible = "qcom,sm8150-compute-noc",
+         .data = &sm8150_compute_noc},
+       { .compatible = "qcom,sm8150-config-noc",
+         .data = &sm8150_config_noc},
+       { .compatible = "qcom,sm8150-dc-noc",
+         .data = &sm8150_dc_noc},
+       { .compatible = "qcom,sm8150-gem-noc",
+         .data = &sm8150_gem_noc},
+       { .compatible = "qcom,sm8150-ipa-virt",
+         .data = &sm8150_ipa_virt},
+       { .compatible = "qcom,sm8150-mc-virt",
+         .data = &sm8150_mc_virt},
+       { .compatible = "qcom,sm8150-mmss-noc",
+         .data = &sm8150_mmss_noc},
+       { .compatible = "qcom,sm8150-system-noc",
+         .data = &sm8150_system_noc},
+       { }
+};
+MODULE_DEVICE_TABLE(of, qnoc_of_match);
+
+static struct platform_driver qnoc_driver = {
+       .probe = qnoc_probe,
+       .remove = qnoc_remove,
+       .driver = {
+               .name = "qnoc-sm8150",
+               .of_match_table = qnoc_of_match,
+       },
+};
+module_platform_driver(qnoc_driver);
+
+MODULE_DESCRIPTION("Qualcomm SM8150 NoC driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/interconnect/qcom/sm8150.h b/drivers/interconnect/qcom/sm8150.h
new file mode 100644 (file)
index 0000000..97996f6
--- /dev/null
@@ -0,0 +1,154 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Qualcomm #define SM8250 interconnect IDs
+ *
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DRIVERS_INTERCONNECT_QCOM_SM8150_H
+#define __DRIVERS_INTERCONNECT_QCOM_SM8150_H
+
+#define SM8150_A1NOC_SNOC_MAS                  0
+#define SM8150_A1NOC_SNOC_SLV                  1
+#define SM8150_A2NOC_SNOC_MAS                  2
+#define SM8150_A2NOC_SNOC_SLV                  3
+#define SM8150_MASTER_A1NOC_CFG                        4
+#define SM8150_MASTER_A2NOC_CFG                        5
+#define SM8150_MASTER_AMPSS_M0                 6
+#define SM8150_MASTER_CAMNOC_HF0               7
+#define SM8150_MASTER_CAMNOC_HF0_UNCOMP                8
+#define SM8150_MASTER_CAMNOC_HF1               9
+#define SM8150_MASTER_CAMNOC_HF1_UNCOMP                10
+#define SM8150_MASTER_CAMNOC_SF                        11
+#define SM8150_MASTER_CAMNOC_SF_UNCOMP         12
+#define SM8150_MASTER_CNOC_A2NOC               13
+#define SM8150_MASTER_CNOC_DC_NOC              14
+#define SM8150_MASTER_CNOC_MNOC_CFG            15
+#define SM8150_MASTER_COMPUTE_NOC              16
+#define SM8150_MASTER_CRYPTO_CORE_0            17
+#define SM8150_MASTER_ECC                      18
+#define SM8150_MASTER_EMAC                     19
+#define SM8150_MASTER_GEM_NOC_CFG              20
+#define SM8150_MASTER_GEM_NOC_PCIE_SNOC                21
+#define SM8150_MASTER_GEM_NOC_SNOC             22
+#define SM8150_MASTER_GIC                      23
+#define SM8150_MASTER_GPU_TCU                  24
+#define SM8150_MASTER_GRAPHICS_3D              25
+#define SM8150_MASTER_IPA                      26
+#define SM8150_MASTER_IPA_CORE                 27
+#define SM8150_MASTER_LLCC                     28
+#define SM8150_MASTER_MDP_PORT0                        29
+#define SM8150_MASTER_MDP_PORT1                        30
+#define SM8150_MASTER_MNOC_HF_MEM_NOC          31
+#define SM8150_MASTER_MNOC_SF_MEM_NOC          32
+#define SM8150_MASTER_NPU                      33
+#define SM8150_MASTER_PCIE                     34
+#define SM8150_MASTER_PCIE_1                   35
+#define SM8150_MASTER_PIMEM                    36
+#define SM8150_MASTER_QDSS_BAM                 37
+#define SM8150_MASTER_QDSS_DAP                 38
+#define SM8150_MASTER_QDSS_ETR                 39
+#define SM8150_MASTER_QSPI                     40
+#define SM8150_MASTER_QUP_0                    41
+#define SM8150_MASTER_QUP_1                    42
+#define SM8150_MASTER_QUP_2                    43
+#define SM8150_MASTER_ROTATOR                  44
+#define SM8150_MASTER_SDCC_2                   45
+#define SM8150_MASTER_SDCC_4                   46
+#define SM8150_MASTER_SENSORS_AHB              47
+#define SM8150_MASTER_SNOC_CFG                 48
+#define SM8150_MASTER_SNOC_GC_MEM_NOC          49
+#define SM8150_MASTER_SNOC_SF_MEM_NOC          50
+#define SM8150_MASTER_SPDM                     51
+#define SM8150_MASTER_SYS_TCU                  52
+#define SM8150_MASTER_TSIF                     53
+#define SM8150_MASTER_UFS_MEM                  54
+#define SM8150_MASTER_USB3                     55
+#define SM8150_MASTER_USB3_1                   56
+#define SM8150_MASTER_VIDEO_P0                 57
+#define SM8150_MASTER_VIDEO_P1                 58
+#define SM8150_MASTER_VIDEO_PROC               59
+#define SM8150_SLAVE_A1NOC_CFG                 60
+#define SM8150_SLAVE_A2NOC_CFG                 61
+#define SM8150_SLAVE_AHB2PHY_SOUTH             62
+#define SM8150_SLAVE_ANOC_PCIE_GEM_NOC         63
+#define SM8150_SLAVE_AOP                       64
+#define SM8150_SLAVE_AOSS                      65
+#define SM8150_SLAVE_APPSS                     66
+#define SM8150_SLAVE_CAMERA_CFG                        67
+#define SM8150_SLAVE_CAMNOC_UNCOMP             68
+#define SM8150_SLAVE_CDSP_CFG                  69
+#define SM8150_SLAVE_CDSP_MEM_NOC              70
+#define SM8150_SLAVE_CLK_CTL                   71
+#define SM8150_SLAVE_CNOC_A2NOC                        72
+#define SM8150_SLAVE_CNOC_DDRSS                        73
+#define SM8150_SLAVE_CNOC_MNOC_CFG             74
+#define SM8150_SLAVE_CRYPTO_0_CFG              75
+#define SM8150_SLAVE_DISPLAY_CFG               76
+#define SM8150_SLAVE_EBI_CH0                   77
+#define SM8150_SLAVE_ECC                       78
+#define SM8150_SLAVE_EMAC_CFG                  79
+#define SM8150_SLAVE_GEM_NOC_CFG               80
+#define SM8150_SLAVE_GEM_NOC_SNOC              81
+#define SM8150_SLAVE_GLM                       82
+#define SM8150_SLAVE_GRAPHICS_3D_CFG           83
+#define SM8150_SLAVE_IMEM_CFG                  84
+#define SM8150_SLAVE_IPA_CFG                   85
+#define SM8150_SLAVE_IPA_CORE                  86
+#define SM8150_SLAVE_LLCC                      87
+#define SM8150_SLAVE_LLCC_CFG                  88
+#define SM8150_SLAVE_MNOC_HF_MEM_NOC           89
+#define SM8150_SLAVE_MNOC_SF_MEM_NOC           90
+#define SM8150_SLAVE_MSS_PROC_MS_MPU_CFG       91
+#define SM8150_SLAVE_NORTH_PHY_CFG             92
+#define SM8150_SLAVE_NPU_CFG                   93
+#define SM8150_SLAVE_OCIMEM                    94
+#define SM8150_SLAVE_PCIE_0                    95
+#define SM8150_SLAVE_PCIE_0_CFG                        96
+#define SM8150_SLAVE_PCIE_1                    97
+#define SM8150_SLAVE_PCIE_1_CFG                        98
+#define SM8150_SLAVE_PIMEM                     99
+#define SM8150_SLAVE_PIMEM_CFG                 100
+#define SM8150_SLAVE_PRNG                      101
+#define SM8150_SLAVE_QDSS_CFG                  102
+#define SM8150_SLAVE_QDSS_STM                  103
+#define SM8150_SLAVE_QSPI                      104
+#define SM8150_SLAVE_QUP_0                     105
+#define SM8150_SLAVE_QUP_1                     106
+#define SM8150_SLAVE_QUP_2                     107
+#define SM8150_SLAVE_RBCPR_CX_CFG              108
+#define SM8150_SLAVE_RBCPR_MMCX_CFG            109
+#define SM8150_SLAVE_RBCPR_MX_CFG              110
+#define SM8150_SLAVE_SDCC_2                    111
+#define SM8150_SLAVE_SDCC_4                    112
+#define SM8150_SLAVE_SERVICE_A1NOC             113
+#define SM8150_SLAVE_SERVICE_A2NOC             114
+#define SM8150_SLAVE_SERVICE_CNOC              115
+#define SM8150_SLAVE_SERVICE_GEM_NOC           116
+#define SM8150_SLAVE_SERVICE_MNOC              117
+#define SM8150_SLAVE_SERVICE_SNOC              118
+#define SM8150_SLAVE_SNOC_CFG                  119
+#define SM8150_SLAVE_SNOC_GEM_NOC_GC           120
+#define SM8150_SLAVE_SNOC_GEM_NOC_SF           121
+#define SM8150_SLAVE_SPDM_WRAPPER              122
+#define SM8150_SLAVE_SPSS_CFG                  123
+#define SM8150_SLAVE_SSC_CFG                   124
+#define SM8150_SLAVE_TCSR                      125
+#define SM8150_SLAVE_TCU                       126
+#define SM8150_SLAVE_TLMM_EAST                 127
+#define SM8150_SLAVE_TLMM_NORTH                        128
+#define SM8150_SLAVE_TLMM_SOUTH                        129
+#define SM8150_SLAVE_TLMM_WEST                 130
+#define SM8150_SLAVE_TSIF                      131
+#define SM8150_SLAVE_UFS_CARD_CFG              132
+#define SM8150_SLAVE_UFS_MEM_CFG               133
+#define SM8150_SLAVE_USB3                      134
+#define SM8150_SLAVE_USB3_1                    135
+#define SM8150_SLAVE_VENUS_CFG                 136
+#define SM8150_SLAVE_VSENSE_CTRL_CFG           137
+#define SM8150_SNOC_CNOC_MAS                   138
+#define SM8150_SNOC_CNOC_SLV                   139
+#define SM8150_MASTER_OSM_L3_APPS              140
+#define SM8150_SLAVE_OSM_L3                    141
+
+#endif
diff --git a/drivers/interconnect/qcom/sm8250.c b/drivers/interconnect/qcom/sm8250.c
new file mode 100644 (file)
index 0000000..9b58946
--- /dev/null
@@ -0,0 +1,651 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/interconnect.h>
+#include <linux/interconnect-provider.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <dt-bindings/interconnect/qcom,sm8250.h>
+
+#include "bcm-voter.h"
+#include "icc-rpmh.h"
+#include "sm8250.h"
+
+DEFINE_QNODE(qhm_a1noc_cfg, SM8250_MASTER_A1NOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_A1NOC);
+DEFINE_QNODE(qhm_qspi, SM8250_MASTER_QSPI_0, 1, 4, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qup1, SM8250_MASTER_QUP_1, 1, 4, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qup2, SM8250_MASTER_QUP_2, 1, 4, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_tsif, SM8250_MASTER_TSIF, 1, 4, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_pcie3_modem, SM8250_MASTER_PCIE_2, 1, 8, SM8250_SLAVE_ANOC_PCIE_GEM_NOC_1);
+DEFINE_QNODE(xm_sdc4, SM8250_MASTER_SDCC_4, 1, 8, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_ufs_mem, SM8250_MASTER_UFS_MEM, 1, 8, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_usb3_0, SM8250_MASTER_USB3, 1, 8, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(xm_usb3_1, SM8250_MASTER_USB3_1, 1, 8, SM8250_A1NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_a2noc_cfg, SM8250_MASTER_A2NOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_A2NOC);
+DEFINE_QNODE(qhm_qdss_bam, SM8250_MASTER_QDSS_BAM, 1, 4, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qhm_qup0, SM8250_MASTER_QUP_0, 1, 4, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qnm_cnoc, SM8250_MASTER_CNOC_A2NOC, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qxm_crypto, SM8250_MASTER_CRYPTO_CORE_0, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qxm_ipa, SM8250_MASTER_IPA, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_pcie3_0, SM8250_MASTER_PCIE, 1, 8, SM8250_SLAVE_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(xm_pcie3_1, SM8250_MASTER_PCIE_1, 1, 8, SM8250_SLAVE_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(xm_qdss_etr, SM8250_MASTER_QDSS_ETR, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_sdc2, SM8250_MASTER_SDCC_2, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(xm_ufs_card, SM8250_MASTER_UFS_CARD, 1, 8, SM8250_A2NOC_SNOC_SLV);
+DEFINE_QNODE(qnm_npu, SM8250_MASTER_NPU, 2, 32, SM8250_SLAVE_CDSP_MEM_NOC);
+DEFINE_QNODE(qnm_snoc, SM8250_SNOC_CNOC_MAS, 1, 8, SM8250_SLAVE_CDSP_CFG, SM8250_SLAVE_CAMERA_CFG, SM8250_SLAVE_TLMM_SOUTH, SM8250_SLAVE_TLMM_NORTH, SM8250_SLAVE_SDCC_4, SM8250_SLAVE_TLMM_WEST, SM8250_SLAVE_SDCC_2, SM8250_SLAVE_CNOC_MNOC_CFG, SM8250_SLAVE_UFS_MEM_CFG, SM8250_SLAVE_SNOC_CFG, SM8250_SLAVE_PDM, SM8250_SLAVE_CX_RDPM, SM8250_SLAVE_PCIE_1_CFG, SM8250_SLAVE_A2NOC_CFG, SM8250_SLAVE_QDSS_CFG, SM8250_SLAVE_DISPLAY_CFG, SM8250_SLAVE_PCIE_2_CFG, SM8250_SLAVE_TCSR, SM8250_SLAVE_DCC_CFG, SM8250_SLAVE_CNOC_DDRSS, SM8250_SLAVE_IPC_ROUTER_CFG, SM8250_SLAVE_PCIE_0_CFG, SM8250_SLAVE_RBCPR_MMCX_CFG, SM8250_SLAVE_NPU_CFG, SM8250_SLAVE_AHB2PHY_SOUTH, SM8250_SLAVE_AHB2PHY_NORTH, SM8250_SLAVE_GRAPHICS_3D_CFG, SM8250_SLAVE_VENUS_CFG, SM8250_SLAVE_TSIF, SM8250_SLAVE_IPA_CFG, SM8250_SLAVE_IMEM_CFG, SM8250_SLAVE_USB3, SM8250_SLAVE_SERVICE_CNOC, SM8250_SLAVE_UFS_CARD_CFG, SM8250_SLAVE_USB3_1, SM8250_SLAVE_LPASS, SM8250_SLAVE_RBCPR_CX_CFG, SM8250_SLAVE_A1NOC_CFG, SM8250_SLAVE_AOSS, SM8250_SLAVE_PRNG, SM8250_SLAVE_VSENSE_CTRL_CFG, SM8250_SLAVE_QSPI_0, SM8250_SLAVE_CRYPTO_0_CFG, SM8250_SLAVE_PIMEM_CFG, SM8250_SLAVE_RBCPR_MX_CFG, SM8250_SLAVE_QUP_0, SM8250_SLAVE_QUP_1, SM8250_SLAVE_QUP_2, SM8250_SLAVE_CLK_CTL);
+DEFINE_QNODE(xm_qdss_dap, SM8250_MASTER_QDSS_DAP, 1, 8, SM8250_SLAVE_CDSP_CFG, SM8250_SLAVE_CAMERA_CFG, SM8250_SLAVE_TLMM_SOUTH, SM8250_SLAVE_TLMM_NORTH, SM8250_SLAVE_SDCC_4, SM8250_SLAVE_TLMM_WEST, SM8250_SLAVE_SDCC_2, SM8250_SLAVE_CNOC_MNOC_CFG, SM8250_SLAVE_UFS_MEM_CFG, SM8250_SLAVE_SNOC_CFG, SM8250_SLAVE_PDM, SM8250_SLAVE_CX_RDPM, SM8250_SLAVE_PCIE_1_CFG, SM8250_SLAVE_A2NOC_CFG, SM8250_SLAVE_QDSS_CFG, SM8250_SLAVE_DISPLAY_CFG, SM8250_SLAVE_PCIE_2_CFG, SM8250_SLAVE_TCSR, SM8250_SLAVE_DCC_CFG, SM8250_SLAVE_CNOC_DDRSS, SM8250_SLAVE_IPC_ROUTER_CFG, SM8250_SLAVE_CNOC_A2NOC, SM8250_SLAVE_PCIE_0_CFG, SM8250_SLAVE_RBCPR_MMCX_CFG, SM8250_SLAVE_NPU_CFG, SM8250_SLAVE_AHB2PHY_SOUTH, SM8250_SLAVE_AHB2PHY_NORTH, SM8250_SLAVE_GRAPHICS_3D_CFG, SM8250_SLAVE_VENUS_CFG, SM8250_SLAVE_TSIF, SM8250_SLAVE_IPA_CFG, SM8250_SLAVE_IMEM_CFG, SM8250_SLAVE_USB3, SM8250_SLAVE_SERVICE_CNOC, SM8250_SLAVE_UFS_CARD_CFG, SM8250_SLAVE_USB3_1, SM8250_SLAVE_LPASS, SM8250_SLAVE_RBCPR_CX_CFG, SM8250_SLAVE_A1NOC_CFG, SM8250_SLAVE_AOSS, SM8250_SLAVE_PRNG, SM8250_SLAVE_VSENSE_CTRL_CFG, SM8250_SLAVE_QSPI_0, SM8250_SLAVE_CRYPTO_0_CFG, SM8250_SLAVE_PIMEM_CFG, SM8250_SLAVE_RBCPR_MX_CFG, SM8250_SLAVE_QUP_0, SM8250_SLAVE_QUP_1, SM8250_SLAVE_QUP_2, SM8250_SLAVE_CLK_CTL);
+DEFINE_QNODE(qhm_cnoc_dc_noc, SM8250_MASTER_CNOC_DC_NOC, 1, 4, SM8250_SLAVE_GEM_NOC_CFG, SM8250_SLAVE_LLCC_CFG);
+DEFINE_QNODE(alm_gpu_tcu, SM8250_MASTER_GPU_TCU, 1, 8, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(alm_sys_tcu, SM8250_MASTER_SYS_TCU, 1, 8, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(chm_apps, SM8250_MASTER_AMPSS_M0, 2, 32, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC, SM8250_SLAVE_MEM_NOC_PCIE_SNOC);
+DEFINE_QNODE(qhm_gemnoc_cfg, SM8250_MASTER_GEM_NOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_GEM_NOC_2, SM8250_SLAVE_SERVICE_GEM_NOC_1, SM8250_SLAVE_SERVICE_GEM_NOC);
+DEFINE_QNODE(qnm_cmpnoc, SM8250_MASTER_COMPUTE_NOC, 2, 32, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_gpu, SM8250_MASTER_GRAPHICS_3D, 2, 32, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_mnoc_hf, SM8250_MASTER_MNOC_HF_MEM_NOC, 2, 32, SM8250_SLAVE_LLCC);
+DEFINE_QNODE(qnm_mnoc_sf, SM8250_MASTER_MNOC_SF_MEM_NOC, 2, 32, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_pcie, SM8250_MASTER_ANOC_PCIE_GEM_NOC, 1, 16, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC);
+DEFINE_QNODE(qnm_snoc_gc, SM8250_MASTER_SNOC_GC_MEM_NOC, 1, 8, SM8250_SLAVE_LLCC);
+DEFINE_QNODE(qnm_snoc_sf, SM8250_MASTER_SNOC_SF_MEM_NOC, 1, 16, SM8250_SLAVE_LLCC, SM8250_SLAVE_GEM_NOC_SNOC, SM8250_SLAVE_MEM_NOC_PCIE_SNOC);
+DEFINE_QNODE(ipa_core_master, SM8250_MASTER_IPA_CORE, 1, 8, SM8250_SLAVE_IPA_CORE);
+DEFINE_QNODE(llcc_mc, SM8250_MASTER_LLCC, 4, 4, SM8250_SLAVE_EBI_CH0);
+DEFINE_QNODE(qhm_mnoc_cfg, SM8250_MASTER_CNOC_MNOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_MNOC);
+DEFINE_QNODE(qnm_camnoc_hf, SM8250_MASTER_CAMNOC_HF, 2, 32, SM8250_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qnm_camnoc_icp, SM8250_MASTER_CAMNOC_ICP, 1, 8, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qnm_camnoc_sf, SM8250_MASTER_CAMNOC_SF, 2, 32, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qnm_video0, SM8250_MASTER_VIDEO_P0, 1, 32, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qnm_video1, SM8250_MASTER_VIDEO_P1, 1, 32, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qnm_video_cvp, SM8250_MASTER_VIDEO_PROC, 1, 32, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxm_mdp0, SM8250_MASTER_MDP_PORT0, 1, 32, SM8250_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_mdp1, SM8250_MASTER_MDP_PORT1, 1, 32, SM8250_SLAVE_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qxm_rot, SM8250_MASTER_ROTATOR, 1, 32, SM8250_SLAVE_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(amm_npu_sys, SM8250_MASTER_NPU_SYS, 4, 32, SM8250_SLAVE_NPU_COMPUTE_NOC);
+DEFINE_QNODE(amm_npu_sys_cdp_w, SM8250_MASTER_NPU_CDP, 2, 16, SM8250_SLAVE_NPU_COMPUTE_NOC);
+DEFINE_QNODE(qhm_cfg, SM8250_MASTER_NPU_NOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_NPU_NOC, SM8250_SLAVE_ISENSE_CFG, SM8250_SLAVE_NPU_LLM_CFG, SM8250_SLAVE_NPU_INT_DMA_BWMON_CFG, SM8250_SLAVE_NPU_CP, SM8250_SLAVE_NPU_TCM, SM8250_SLAVE_NPU_CAL_DP0, SM8250_SLAVE_NPU_CAL_DP1, SM8250_SLAVE_NPU_DPM);
+DEFINE_QNODE(qhm_snoc_cfg, SM8250_MASTER_SNOC_CFG, 1, 4, SM8250_SLAVE_SERVICE_SNOC);
+DEFINE_QNODE(qnm_aggre1_noc, SM8250_A1NOC_SNOC_MAS, 1, 16, SM8250_SLAVE_SNOC_GEM_NOC_SF);
+DEFINE_QNODE(qnm_aggre2_noc, SM8250_A2NOC_SNOC_MAS, 1, 16, SM8250_SLAVE_SNOC_GEM_NOC_SF);
+DEFINE_QNODE(qnm_gemnoc, SM8250_MASTER_GEM_NOC_SNOC, 1, 16, SM8250_SLAVE_PIMEM, SM8250_SLAVE_OCIMEM, SM8250_SLAVE_APPSS, SM8250_SNOC_CNOC_SLV, SM8250_SLAVE_TCU, SM8250_SLAVE_QDSS_STM);
+DEFINE_QNODE(qnm_gemnoc_pcie, SM8250_MASTER_GEM_NOC_PCIE_SNOC, 1, 8, SM8250_SLAVE_PCIE_2, SM8250_SLAVE_PCIE_0, SM8250_SLAVE_PCIE_1);
+DEFINE_QNODE(qxm_pimem, SM8250_MASTER_PIMEM, 1, 8, SM8250_SLAVE_SNOC_GEM_NOC_GC);
+DEFINE_QNODE(xm_gic, SM8250_MASTER_GIC, 1, 8, SM8250_SLAVE_SNOC_GEM_NOC_GC);
+DEFINE_QNODE(qns_a1noc_snoc, SM8250_A1NOC_SNOC_SLV, 1, 16, SM8250_A1NOC_SNOC_MAS);
+DEFINE_QNODE(qns_pcie_modem_mem_noc, SM8250_SLAVE_ANOC_PCIE_GEM_NOC_1, 1, 16, SM8250_MASTER_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(srvc_aggre1_noc, SM8250_SLAVE_SERVICE_A1NOC, 1, 4);
+DEFINE_QNODE(qns_a2noc_snoc, SM8250_A2NOC_SNOC_SLV, 1, 16, SM8250_A2NOC_SNOC_MAS);
+DEFINE_QNODE(qns_pcie_mem_noc, SM8250_SLAVE_ANOC_PCIE_GEM_NOC, 1, 16, SM8250_MASTER_ANOC_PCIE_GEM_NOC);
+DEFINE_QNODE(srvc_aggre2_noc, SM8250_SLAVE_SERVICE_A2NOC, 1, 4);
+DEFINE_QNODE(qns_cdsp_mem_noc, SM8250_SLAVE_CDSP_MEM_NOC, 2, 32, SM8250_MASTER_COMPUTE_NOC);
+DEFINE_QNODE(qhs_a1_noc_cfg, SM8250_SLAVE_A1NOC_CFG, 1, 4, SM8250_MASTER_A1NOC_CFG);
+DEFINE_QNODE(qhs_a2_noc_cfg, SM8250_SLAVE_A2NOC_CFG, 1, 4, SM8250_MASTER_A2NOC_CFG);
+DEFINE_QNODE(qhs_ahb2phy0, SM8250_SLAVE_AHB2PHY_SOUTH, 1, 4);
+DEFINE_QNODE(qhs_ahb2phy1, SM8250_SLAVE_AHB2PHY_NORTH, 1, 4);
+DEFINE_QNODE(qhs_aoss, SM8250_SLAVE_AOSS, 1, 4);
+DEFINE_QNODE(qhs_camera_cfg, SM8250_SLAVE_CAMERA_CFG, 1, 4);
+DEFINE_QNODE(qhs_clk_ctl, SM8250_SLAVE_CLK_CTL, 1, 4);
+DEFINE_QNODE(qhs_compute_dsp, SM8250_SLAVE_CDSP_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_cx, SM8250_SLAVE_RBCPR_CX_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_mmcx, SM8250_SLAVE_RBCPR_MMCX_CFG, 1, 4);
+DEFINE_QNODE(qhs_cpr_mx, SM8250_SLAVE_RBCPR_MX_CFG, 1, 4);
+DEFINE_QNODE(qhs_crypto0_cfg, SM8250_SLAVE_CRYPTO_0_CFG, 1, 4);
+DEFINE_QNODE(qhs_cx_rdpm, SM8250_SLAVE_CX_RDPM, 1, 4);
+DEFINE_QNODE(qhs_dcc_cfg, SM8250_SLAVE_DCC_CFG, 1, 4);
+DEFINE_QNODE(qhs_ddrss_cfg, SM8250_SLAVE_CNOC_DDRSS, 1, 4, SM8250_MASTER_CNOC_DC_NOC);
+DEFINE_QNODE(qhs_display_cfg, SM8250_SLAVE_DISPLAY_CFG, 1, 4);
+DEFINE_QNODE(qhs_gpuss_cfg, SM8250_SLAVE_GRAPHICS_3D_CFG, 1, 8);
+DEFINE_QNODE(qhs_imem_cfg, SM8250_SLAVE_IMEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_ipa, SM8250_SLAVE_IPA_CFG, 1, 4);
+DEFINE_QNODE(qhs_ipc_router, SM8250_SLAVE_IPC_ROUTER_CFG, 1, 4);
+DEFINE_QNODE(qhs_lpass_cfg, SM8250_SLAVE_LPASS, 1, 4);
+DEFINE_QNODE(qhs_mnoc_cfg, SM8250_SLAVE_CNOC_MNOC_CFG, 1, 4, SM8250_MASTER_CNOC_MNOC_CFG);
+DEFINE_QNODE(qhs_npu_cfg, SM8250_SLAVE_NPU_CFG, 1, 4, SM8250_MASTER_NPU_NOC_CFG);
+DEFINE_QNODE(qhs_pcie0_cfg, SM8250_SLAVE_PCIE_0_CFG, 1, 4);
+DEFINE_QNODE(qhs_pcie1_cfg, SM8250_SLAVE_PCIE_1_CFG, 1, 4);
+DEFINE_QNODE(qhs_pcie_modem_cfg, SM8250_SLAVE_PCIE_2_CFG, 1, 4);
+DEFINE_QNODE(qhs_pdm, SM8250_SLAVE_PDM, 1, 4);
+DEFINE_QNODE(qhs_pimem_cfg, SM8250_SLAVE_PIMEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_prng, SM8250_SLAVE_PRNG, 1, 4);
+DEFINE_QNODE(qhs_qdss_cfg, SM8250_SLAVE_QDSS_CFG, 1, 4);
+DEFINE_QNODE(qhs_qspi, SM8250_SLAVE_QSPI_0, 1, 4);
+DEFINE_QNODE(qhs_qup0, SM8250_SLAVE_QUP_0, 1, 4);
+DEFINE_QNODE(qhs_qup1, SM8250_SLAVE_QUP_1, 1, 4);
+DEFINE_QNODE(qhs_qup2, SM8250_SLAVE_QUP_2, 1, 4);
+DEFINE_QNODE(qhs_sdc2, SM8250_SLAVE_SDCC_2, 1, 4);
+DEFINE_QNODE(qhs_sdc4, SM8250_SLAVE_SDCC_4, 1, 4);
+DEFINE_QNODE(qhs_snoc_cfg, SM8250_SLAVE_SNOC_CFG, 1, 4, SM8250_MASTER_SNOC_CFG);
+DEFINE_QNODE(qhs_tcsr, SM8250_SLAVE_TCSR, 1, 4);
+DEFINE_QNODE(qhs_tlmm0, SM8250_SLAVE_TLMM_NORTH, 1, 4);
+DEFINE_QNODE(qhs_tlmm1, SM8250_SLAVE_TLMM_SOUTH, 1, 4);
+DEFINE_QNODE(qhs_tlmm2, SM8250_SLAVE_TLMM_WEST, 1, 4);
+DEFINE_QNODE(qhs_tsif, SM8250_SLAVE_TSIF, 1, 4);
+DEFINE_QNODE(qhs_ufs_card_cfg, SM8250_SLAVE_UFS_CARD_CFG, 1, 4);
+DEFINE_QNODE(qhs_ufs_mem_cfg, SM8250_SLAVE_UFS_MEM_CFG, 1, 4);
+DEFINE_QNODE(qhs_usb3_0, SM8250_SLAVE_USB3, 1, 4);
+DEFINE_QNODE(qhs_usb3_1, SM8250_SLAVE_USB3_1, 1, 4);
+DEFINE_QNODE(qhs_venus_cfg, SM8250_SLAVE_VENUS_CFG, 1, 4);
+DEFINE_QNODE(qhs_vsense_ctrl_cfg, SM8250_SLAVE_VSENSE_CTRL_CFG, 1, 4);
+DEFINE_QNODE(qns_cnoc_a2noc, SM8250_SLAVE_CNOC_A2NOC, 1, 8, SM8250_MASTER_CNOC_A2NOC);
+DEFINE_QNODE(srvc_cnoc, SM8250_SLAVE_SERVICE_CNOC, 1, 4);
+DEFINE_QNODE(qhs_llcc, SM8250_SLAVE_LLCC_CFG, 1, 4);
+DEFINE_QNODE(qhs_memnoc, SM8250_SLAVE_GEM_NOC_CFG, 1, 4, SM8250_MASTER_GEM_NOC_CFG);
+DEFINE_QNODE(qns_gem_noc_snoc, SM8250_SLAVE_GEM_NOC_SNOC, 1, 16, SM8250_MASTER_GEM_NOC_SNOC);
+DEFINE_QNODE(qns_llcc, SM8250_SLAVE_LLCC, 4, 16, SM8250_MASTER_LLCC);
+DEFINE_QNODE(qns_sys_pcie, SM8250_SLAVE_MEM_NOC_PCIE_SNOC, 1, 8, SM8250_MASTER_GEM_NOC_PCIE_SNOC);
+DEFINE_QNODE(srvc_even_gemnoc, SM8250_SLAVE_SERVICE_GEM_NOC_1, 1, 4);
+DEFINE_QNODE(srvc_odd_gemnoc, SM8250_SLAVE_SERVICE_GEM_NOC_2, 1, 4);
+DEFINE_QNODE(srvc_sys_gemnoc, SM8250_SLAVE_SERVICE_GEM_NOC, 1, 4);
+DEFINE_QNODE(ipa_core_slave, SM8250_SLAVE_IPA_CORE, 1, 8);
+DEFINE_QNODE(ebi, SM8250_SLAVE_EBI_CH0, 4, 4);
+DEFINE_QNODE(qns_mem_noc_hf, SM8250_SLAVE_MNOC_HF_MEM_NOC, 2, 32, SM8250_MASTER_MNOC_HF_MEM_NOC);
+DEFINE_QNODE(qns_mem_noc_sf, SM8250_SLAVE_MNOC_SF_MEM_NOC, 2, 32, SM8250_MASTER_MNOC_SF_MEM_NOC);
+DEFINE_QNODE(srvc_mnoc, SM8250_SLAVE_SERVICE_MNOC, 1, 4);
+DEFINE_QNODE(qhs_cal_dp0, SM8250_SLAVE_NPU_CAL_DP0, 1, 4);
+DEFINE_QNODE(qhs_cal_dp1, SM8250_SLAVE_NPU_CAL_DP1, 1, 4);
+DEFINE_QNODE(qhs_cp, SM8250_SLAVE_NPU_CP, 1, 4);
+DEFINE_QNODE(qhs_dma_bwmon, SM8250_SLAVE_NPU_INT_DMA_BWMON_CFG, 1, 4);
+DEFINE_QNODE(qhs_dpm, SM8250_SLAVE_NPU_DPM, 1, 4);
+DEFINE_QNODE(qhs_isense, SM8250_SLAVE_ISENSE_CFG, 1, 4);
+DEFINE_QNODE(qhs_llm, SM8250_SLAVE_NPU_LLM_CFG, 1, 4);
+DEFINE_QNODE(qhs_tcm, SM8250_SLAVE_NPU_TCM, 1, 4);
+DEFINE_QNODE(qns_npu_sys, SM8250_SLAVE_NPU_COMPUTE_NOC, 2, 32);
+DEFINE_QNODE(srvc_noc, SM8250_SLAVE_SERVICE_NPU_NOC, 1, 4);
+DEFINE_QNODE(qhs_apss, SM8250_SLAVE_APPSS, 1, 8);
+DEFINE_QNODE(qns_cnoc, SM8250_SNOC_CNOC_SLV, 1, 8, SM8250_SNOC_CNOC_MAS);
+DEFINE_QNODE(qns_gemnoc_gc, SM8250_SLAVE_SNOC_GEM_NOC_GC, 1, 8, SM8250_MASTER_SNOC_GC_MEM_NOC);
+DEFINE_QNODE(qns_gemnoc_sf, SM8250_SLAVE_SNOC_GEM_NOC_SF, 1, 16, SM8250_MASTER_SNOC_SF_MEM_NOC);
+DEFINE_QNODE(qxs_imem, SM8250_SLAVE_OCIMEM, 1, 8);
+DEFINE_QNODE(qxs_pimem, SM8250_SLAVE_PIMEM, 1, 8);
+DEFINE_QNODE(srvc_snoc, SM8250_SLAVE_SERVICE_SNOC, 1, 4);
+DEFINE_QNODE(xs_pcie_0, SM8250_SLAVE_PCIE_0, 1, 8);
+DEFINE_QNODE(xs_pcie_1, SM8250_SLAVE_PCIE_1, 1, 8);
+DEFINE_QNODE(xs_pcie_modem, SM8250_SLAVE_PCIE_2, 1, 8);
+DEFINE_QNODE(xs_qdss_stm, SM8250_SLAVE_QDSS_STM, 1, 4);
+DEFINE_QNODE(xs_sys_tcu_cfg, SM8250_SLAVE_TCU, 1, 8);
+
+DEFINE_QBCM(bcm_acv, "ACV", false, &ebi);
+DEFINE_QBCM(bcm_mc0, "MC0", true, &ebi);
+DEFINE_QBCM(bcm_sh0, "SH0", true, &qns_llcc);
+DEFINE_QBCM(bcm_mm0, "MM0", true, &qns_mem_noc_hf);
+DEFINE_QBCM(bcm_ce0, "CE0", false, &qxm_crypto);
+DEFINE_QBCM(bcm_ip0, "IP0", false, &ipa_core_slave);
+DEFINE_QBCM(bcm_mm1, "MM1", false, &qnm_camnoc_hf, &qxm_mdp0, &qxm_mdp1);
+DEFINE_QBCM(bcm_sh2, "SH2", false, &alm_gpu_tcu, &alm_sys_tcu);
+DEFINE_QBCM(bcm_mm2, "MM2", false, &qns_mem_noc_sf);
+DEFINE_QBCM(bcm_qup0, "QUP0", false, &qhm_qup1, &qhm_qup2, &qhm_qup0);
+DEFINE_QBCM(bcm_sh3, "SH3", false, &qnm_cmpnoc);
+DEFINE_QBCM(bcm_mm3, "MM3", false, &qnm_camnoc_icp, &qnm_camnoc_sf, &qnm_video0, &qnm_video1, &qnm_video_cvp);
+DEFINE_QBCM(bcm_sh4, "SH4", false, &chm_apps);
+DEFINE_QBCM(bcm_sn0, "SN0", true, &qns_gemnoc_sf);
+DEFINE_QBCM(bcm_co0, "CO0", false, &qns_cdsp_mem_noc);
+DEFINE_QBCM(bcm_cn0, "CN0", true, &qnm_snoc, &xm_qdss_dap, &qhs_a1_noc_cfg, &qhs_a2_noc_cfg, &qhs_ahb2phy0, &qhs_ahb2phy1, &qhs_aoss, &qhs_camera_cfg, &qhs_clk_ctl, &qhs_compute_dsp, &qhs_cpr_cx, &qhs_cpr_mmcx, &qhs_cpr_mx, &qhs_crypto0_cfg, &qhs_cx_rdpm, &qhs_dcc_cfg, &qhs_ddrss_cfg, &qhs_display_cfg, &qhs_gpuss_cfg, &qhs_imem_cfg, &qhs_ipa, &qhs_ipc_router, &qhs_lpass_cfg, &qhs_mnoc_cfg, &qhs_npu_cfg, &qhs_pcie0_cfg, &qhs_pcie1_cfg, &qhs_pcie_modem_cfg, &qhs_pdm, &qhs_pimem_cfg, &qhs_prng, &qhs_qdss_cfg, &qhs_qspi, &qhs_qup0, &qhs_qup1, &qhs_qup2, &qhs_sdc2, &qhs_sdc4, &qhs_snoc_cfg, &qhs_tcsr, &qhs_tlmm0, &qhs_tlmm1, &qhs_tlmm2, &qhs_tsif, &qhs_ufs_card_cfg, &qhs_ufs_mem_cfg, &qhs_usb3_0, &qhs_usb3_1, &qhs_venus_cfg, &qhs_vsense_ctrl_cfg, &qns_cnoc_a2noc, &srvc_cnoc);
+DEFINE_QBCM(bcm_sn1, "SN1", false, &qxs_imem);
+DEFINE_QBCM(bcm_sn2, "SN2", false, &qns_gemnoc_gc);
+DEFINE_QBCM(bcm_co2, "CO2", false, &qnm_npu);
+DEFINE_QBCM(bcm_sn3, "SN3", false, &qxs_pimem);
+DEFINE_QBCM(bcm_sn4, "SN4", false, &xs_qdss_stm);
+DEFINE_QBCM(bcm_sn5, "SN5", false, &xs_pcie_modem);
+DEFINE_QBCM(bcm_sn6, "SN6", false, &xs_pcie_0, &xs_pcie_1);
+DEFINE_QBCM(bcm_sn7, "SN7", false, &qnm_aggre1_noc);
+DEFINE_QBCM(bcm_sn8, "SN8", false, &qnm_aggre2_noc);
+DEFINE_QBCM(bcm_sn9, "SN9", false, &qnm_gemnoc_pcie);
+DEFINE_QBCM(bcm_sn11, "SN11", false, &qnm_gemnoc);
+DEFINE_QBCM(bcm_sn12, "SN12", false, &qns_pcie_modem_mem_noc, &qns_pcie_mem_noc);
+
+static struct qcom_icc_bcm *aggre1_noc_bcms[] = {
+       &bcm_qup0,
+       &bcm_sn12,
+};
+
+static struct qcom_icc_node *aggre1_noc_nodes[] = {
+       [MASTER_A1NOC_CFG] = &qhm_a1noc_cfg,
+       [MASTER_QSPI_0] = &qhm_qspi,
+       [MASTER_QUP_1] = &qhm_qup1,
+       [MASTER_QUP_2] = &qhm_qup2,
+       [MASTER_TSIF] = &qhm_tsif,
+       [MASTER_PCIE_2] = &xm_pcie3_modem,
+       [MASTER_SDCC_4] = &xm_sdc4,
+       [MASTER_UFS_MEM] = &xm_ufs_mem,
+       [MASTER_USB3] = &xm_usb3_0,
+       [MASTER_USB3_1] = &xm_usb3_1,
+       [A1NOC_SNOC_SLV] = &qns_a1noc_snoc,
+       [SLAVE_ANOC_PCIE_GEM_NOC_1] = &qns_pcie_modem_mem_noc,
+       [SLAVE_SERVICE_A1NOC] = &srvc_aggre1_noc,
+};
+
+static struct qcom_icc_desc sm8250_aggre1_noc = {
+       .nodes = aggre1_noc_nodes,
+       .num_nodes = ARRAY_SIZE(aggre1_noc_nodes),
+       .bcms = aggre1_noc_bcms,
+       .num_bcms = ARRAY_SIZE(aggre1_noc_bcms),
+};
+
+static struct qcom_icc_bcm *aggre2_noc_bcms[] = {
+       &bcm_ce0,
+       &bcm_qup0,
+       &bcm_sn12,
+};
+
+static struct qcom_icc_node *aggre2_noc_nodes[] = {
+       [MASTER_A2NOC_CFG] = &qhm_a2noc_cfg,
+       [MASTER_QDSS_BAM] = &qhm_qdss_bam,
+       [MASTER_QUP_0] = &qhm_qup0,
+       [MASTER_CNOC_A2NOC] = &qnm_cnoc,
+       [MASTER_CRYPTO_CORE_0] = &qxm_crypto,
+       [MASTER_IPA] = &qxm_ipa,
+       [MASTER_PCIE] = &xm_pcie3_0,
+       [MASTER_PCIE_1] = &xm_pcie3_1,
+       [MASTER_QDSS_ETR] = &xm_qdss_etr,
+       [MASTER_SDCC_2] = &xm_sdc2,
+       [MASTER_UFS_CARD] = &xm_ufs_card,
+       [A2NOC_SNOC_SLV] = &qns_a2noc_snoc,
+       [SLAVE_ANOC_PCIE_GEM_NOC] = &qns_pcie_mem_noc,
+       [SLAVE_SERVICE_A2NOC] = &srvc_aggre2_noc,
+};
+
+static struct qcom_icc_desc sm8250_aggre2_noc = {
+       .nodes = aggre2_noc_nodes,
+       .num_nodes = ARRAY_SIZE(aggre2_noc_nodes),
+       .bcms = aggre2_noc_bcms,
+       .num_bcms = ARRAY_SIZE(aggre2_noc_bcms),
+};
+
+static struct qcom_icc_bcm *compute_noc_bcms[] = {
+       &bcm_co0,
+       &bcm_co2,
+};
+
+static struct qcom_icc_node *compute_noc_nodes[] = {
+       [MASTER_NPU] = &qnm_npu,
+       [SLAVE_CDSP_MEM_NOC] = &qns_cdsp_mem_noc,
+};
+
+static struct qcom_icc_desc sm8250_compute_noc = {
+       .nodes = compute_noc_nodes,
+       .num_nodes = ARRAY_SIZE(compute_noc_nodes),
+       .bcms = compute_noc_bcms,
+       .num_bcms = ARRAY_SIZE(compute_noc_bcms),
+};
+
+static struct qcom_icc_bcm *config_noc_bcms[] = {
+       &bcm_cn0,
+};
+
+static struct qcom_icc_node *config_noc_nodes[] = {
+       [SNOC_CNOC_MAS] = &qnm_snoc,
+       [MASTER_QDSS_DAP] = &xm_qdss_dap,
+       [SLAVE_A1NOC_CFG] = &qhs_a1_noc_cfg,
+       [SLAVE_A2NOC_CFG] = &qhs_a2_noc_cfg,
+       [SLAVE_AHB2PHY_SOUTH] = &qhs_ahb2phy0,
+       [SLAVE_AHB2PHY_NORTH] = &qhs_ahb2phy1,
+       [SLAVE_AOSS] = &qhs_aoss,
+       [SLAVE_CAMERA_CFG] = &qhs_camera_cfg,
+       [SLAVE_CLK_CTL] = &qhs_clk_ctl,
+       [SLAVE_CDSP_CFG] = &qhs_compute_dsp,
+       [SLAVE_RBCPR_CX_CFG] = &qhs_cpr_cx,
+       [SLAVE_RBCPR_MMCX_CFG] = &qhs_cpr_mmcx,
+       [SLAVE_RBCPR_MX_CFG] = &qhs_cpr_mx,
+       [SLAVE_CRYPTO_0_CFG] = &qhs_crypto0_cfg,
+       [SLAVE_CX_RDPM] = &qhs_cx_rdpm,
+       [SLAVE_DCC_CFG] = &qhs_dcc_cfg,
+       [SLAVE_CNOC_DDRSS] = &qhs_ddrss_cfg,
+       [SLAVE_DISPLAY_CFG] = &qhs_display_cfg,
+       [SLAVE_GRAPHICS_3D_CFG] = &qhs_gpuss_cfg,
+       [SLAVE_IMEM_CFG] = &qhs_imem_cfg,
+       [SLAVE_IPA_CFG] = &qhs_ipa,
+       [SLAVE_IPC_ROUTER_CFG] = &qhs_ipc_router,
+       [SLAVE_LPASS] = &qhs_lpass_cfg,
+       [SLAVE_CNOC_MNOC_CFG] = &qhs_mnoc_cfg,
+       [SLAVE_NPU_CFG] = &qhs_npu_cfg,
+       [SLAVE_PCIE_0_CFG] = &qhs_pcie0_cfg,
+       [SLAVE_PCIE_1_CFG] = &qhs_pcie1_cfg,
+       [SLAVE_PCIE_2_CFG] = &qhs_pcie_modem_cfg,
+       [SLAVE_PDM] = &qhs_pdm,
+       [SLAVE_PIMEM_CFG] = &qhs_pimem_cfg,
+       [SLAVE_PRNG] = &qhs_prng,
+       [SLAVE_QDSS_CFG] = &qhs_qdss_cfg,
+       [SLAVE_QSPI_0] = &qhs_qspi,
+       [SLAVE_QUP_0] = &qhs_qup0,
+       [SLAVE_QUP_1] = &qhs_qup1,
+       [SLAVE_QUP_2] = &qhs_qup2,
+       [SLAVE_SDCC_2] = &qhs_sdc2,
+       [SLAVE_SDCC_4] = &qhs_sdc4,
+       [SLAVE_SNOC_CFG] = &qhs_snoc_cfg,
+       [SLAVE_TCSR] = &qhs_tcsr,
+       [SLAVE_TLMM_NORTH] = &qhs_tlmm0,
+       [SLAVE_TLMM_SOUTH] = &qhs_tlmm1,
+       [SLAVE_TLMM_WEST] = &qhs_tlmm2,
+       [SLAVE_TSIF] = &qhs_tsif,
+       [SLAVE_UFS_CARD_CFG] = &qhs_ufs_card_cfg,
+       [SLAVE_UFS_MEM_CFG] = &qhs_ufs_mem_cfg,
+       [SLAVE_USB3] = &qhs_usb3_0,
+       [SLAVE_USB3_1] = &qhs_usb3_1,
+       [SLAVE_VENUS_CFG] = &qhs_venus_cfg,
+       [SLAVE_VSENSE_CTRL_CFG] = &qhs_vsense_ctrl_cfg,
+       [SLAVE_CNOC_A2NOC] = &qns_cnoc_a2noc,
+       [SLAVE_SERVICE_CNOC] = &srvc_cnoc,
+};
+
+static struct qcom_icc_desc sm8250_config_noc = {
+       .nodes = config_noc_nodes,
+       .num_nodes = ARRAY_SIZE(config_noc_nodes),
+       .bcms = config_noc_bcms,
+       .num_bcms = ARRAY_SIZE(config_noc_bcms),
+};
+
+static struct qcom_icc_bcm *dc_noc_bcms[] = {
+};
+
+static struct qcom_icc_node *dc_noc_nodes[] = {
+       [MASTER_CNOC_DC_NOC] = &qhm_cnoc_dc_noc,
+       [SLAVE_LLCC_CFG] = &qhs_llcc,
+       [SLAVE_GEM_NOC_CFG] = &qhs_memnoc,
+};
+
+static struct qcom_icc_desc sm8250_dc_noc = {
+       .nodes = dc_noc_nodes,
+       .num_nodes = ARRAY_SIZE(dc_noc_nodes),
+       .bcms = dc_noc_bcms,
+       .num_bcms = ARRAY_SIZE(dc_noc_bcms),
+};
+
+static struct qcom_icc_bcm *gem_noc_bcms[] = {
+       &bcm_sh0,
+       &bcm_sh2,
+       &bcm_sh3,
+       &bcm_sh4,
+};
+
+static struct qcom_icc_node *gem_noc_nodes[] = {
+       [MASTER_GPU_TCU] = &alm_gpu_tcu,
+       [MASTER_SYS_TCU] = &alm_sys_tcu,
+       [MASTER_AMPSS_M0] = &chm_apps,
+       [MASTER_GEM_NOC_CFG] = &qhm_gemnoc_cfg,
+       [MASTER_COMPUTE_NOC] = &qnm_cmpnoc,
+       [MASTER_GRAPHICS_3D] = &qnm_gpu,
+       [MASTER_MNOC_HF_MEM_NOC] = &qnm_mnoc_hf,
+       [MASTER_MNOC_SF_MEM_NOC] = &qnm_mnoc_sf,
+       [MASTER_ANOC_PCIE_GEM_NOC] = &qnm_pcie,
+       [MASTER_SNOC_GC_MEM_NOC] = &qnm_snoc_gc,
+       [MASTER_SNOC_SF_MEM_NOC] = &qnm_snoc_sf,
+       [SLAVE_GEM_NOC_SNOC] = &qns_gem_noc_snoc,
+       [SLAVE_LLCC] = &qns_llcc,
+       [SLAVE_MEM_NOC_PCIE_SNOC] = &qns_sys_pcie,
+       [SLAVE_SERVICE_GEM_NOC_1] = &srvc_even_gemnoc,
+       [SLAVE_SERVICE_GEM_NOC_2] = &srvc_odd_gemnoc,
+       [SLAVE_SERVICE_GEM_NOC] = &srvc_sys_gemnoc,
+};
+
+static struct qcom_icc_desc sm8250_gem_noc = {
+       .nodes = gem_noc_nodes,
+       .num_nodes = ARRAY_SIZE(gem_noc_nodes),
+       .bcms = gem_noc_bcms,
+       .num_bcms = ARRAY_SIZE(gem_noc_bcms),
+};
+
+static struct qcom_icc_bcm *ipa_virt_bcms[] = {
+       &bcm_ip0,
+};
+
+static struct qcom_icc_node *ipa_virt_nodes[] = {
+       [MASTER_IPA_CORE] = &ipa_core_master,
+       [SLAVE_IPA_CORE] = &ipa_core_slave,
+};
+
+static struct qcom_icc_desc sm8250_ipa_virt = {
+       .nodes = ipa_virt_nodes,
+       .num_nodes = ARRAY_SIZE(ipa_virt_nodes),
+       .bcms = ipa_virt_bcms,
+       .num_bcms = ARRAY_SIZE(ipa_virt_bcms),
+};
+
+static struct qcom_icc_bcm *mc_virt_bcms[] = {
+       &bcm_acv,
+       &bcm_mc0,
+};
+
+static struct qcom_icc_node *mc_virt_nodes[] = {
+       [MASTER_LLCC] = &llcc_mc,
+       [SLAVE_EBI_CH0] = &ebi,
+};
+
+static struct qcom_icc_desc sm8250_mc_virt = {
+       .nodes = mc_virt_nodes,
+       .num_nodes = ARRAY_SIZE(mc_virt_nodes),
+       .bcms = mc_virt_bcms,
+       .num_bcms = ARRAY_SIZE(mc_virt_bcms),
+};
+
+static struct qcom_icc_bcm *mmss_noc_bcms[] = {
+       &bcm_mm0,
+       &bcm_mm1,
+       &bcm_mm2,
+       &bcm_mm3,
+};
+
+static struct qcom_icc_node *mmss_noc_nodes[] = {
+       [MASTER_CNOC_MNOC_CFG] = &qhm_mnoc_cfg,
+       [MASTER_CAMNOC_HF] = &qnm_camnoc_hf,
+       [MASTER_CAMNOC_ICP] = &qnm_camnoc_icp,
+       [MASTER_CAMNOC_SF] = &qnm_camnoc_sf,
+       [MASTER_VIDEO_P0] = &qnm_video0,
+       [MASTER_VIDEO_P1] = &qnm_video1,
+       [MASTER_VIDEO_PROC] = &qnm_video_cvp,
+       [MASTER_MDP_PORT0] = &qxm_mdp0,
+       [MASTER_MDP_PORT1] = &qxm_mdp1,
+       [MASTER_ROTATOR] = &qxm_rot,
+       [SLAVE_MNOC_HF_MEM_NOC] = &qns_mem_noc_hf,
+       [SLAVE_MNOC_SF_MEM_NOC] = &qns_mem_noc_sf,
+       [SLAVE_SERVICE_MNOC] = &srvc_mnoc,
+};
+
+static struct qcom_icc_desc sm8250_mmss_noc = {
+       .nodes = mmss_noc_nodes,
+       .num_nodes = ARRAY_SIZE(mmss_noc_nodes),
+       .bcms = mmss_noc_bcms,
+       .num_bcms = ARRAY_SIZE(mmss_noc_bcms),
+};
+
+static struct qcom_icc_bcm *npu_noc_bcms[] = {
+};
+
+static struct qcom_icc_node *npu_noc_nodes[] = {
+       [MASTER_NPU_SYS] = &amm_npu_sys,
+       [MASTER_NPU_CDP] = &amm_npu_sys_cdp_w,
+       [MASTER_NPU_NOC_CFG] = &qhm_cfg,
+       [SLAVE_NPU_CAL_DP0] = &qhs_cal_dp0,
+       [SLAVE_NPU_CAL_DP1] = &qhs_cal_dp1,
+       [SLAVE_NPU_CP] = &qhs_cp,
+       [SLAVE_NPU_INT_DMA_BWMON_CFG] = &qhs_dma_bwmon,
+       [SLAVE_NPU_DPM] = &qhs_dpm,
+       [SLAVE_ISENSE_CFG] = &qhs_isense,
+       [SLAVE_NPU_LLM_CFG] = &qhs_llm,
+       [SLAVE_NPU_TCM] = &qhs_tcm,
+       [SLAVE_NPU_COMPUTE_NOC] = &qns_npu_sys,
+       [SLAVE_SERVICE_NPU_NOC] = &srvc_noc,
+};
+
+static struct qcom_icc_desc sm8250_npu_noc = {
+       .nodes = npu_noc_nodes,
+       .num_nodes = ARRAY_SIZE(npu_noc_nodes),
+       .bcms = npu_noc_bcms,
+       .num_bcms = ARRAY_SIZE(npu_noc_bcms),
+};
+
+static struct qcom_icc_bcm *system_noc_bcms[] = {
+       &bcm_sn0,
+       &bcm_sn1,
+       &bcm_sn11,
+       &bcm_sn2,
+       &bcm_sn3,
+       &bcm_sn4,
+       &bcm_sn5,
+       &bcm_sn6,
+       &bcm_sn7,
+       &bcm_sn8,
+       &bcm_sn9,
+};
+
+static struct qcom_icc_node *system_noc_nodes[] = {
+       [MASTER_SNOC_CFG] = &qhm_snoc_cfg,
+       [A1NOC_SNOC_MAS] = &qnm_aggre1_noc,
+       [A2NOC_SNOC_MAS] = &qnm_aggre2_noc,
+       [MASTER_GEM_NOC_SNOC] = &qnm_gemnoc,
+       [MASTER_GEM_NOC_PCIE_SNOC] = &qnm_gemnoc_pcie,
+       [MASTER_PIMEM] = &qxm_pimem,
+       [MASTER_GIC] = &xm_gic,
+       [SLAVE_APPSS] = &qhs_apss,
+       [SNOC_CNOC_SLV] = &qns_cnoc,
+       [SLAVE_SNOC_GEM_NOC_GC] = &qns_gemnoc_gc,
+       [SLAVE_SNOC_GEM_NOC_SF] = &qns_gemnoc_sf,
+       [SLAVE_OCIMEM] = &qxs_imem,
+       [SLAVE_PIMEM] = &qxs_pimem,
+       [SLAVE_SERVICE_SNOC] = &srvc_snoc,
+       [SLAVE_PCIE_0] = &xs_pcie_0,
+       [SLAVE_PCIE_1] = &xs_pcie_1,
+       [SLAVE_PCIE_2] = &xs_pcie_modem,
+       [SLAVE_QDSS_STM] = &xs_qdss_stm,
+       [SLAVE_TCU] = &xs_sys_tcu_cfg,
+};
+
+static struct qcom_icc_desc sm8250_system_noc = {
+       .nodes = system_noc_nodes,
+       .num_nodes = ARRAY_SIZE(system_noc_nodes),
+       .bcms = system_noc_bcms,
+       .num_bcms = ARRAY_SIZE(system_noc_bcms),
+};
+
+static int qnoc_probe(struct platform_device *pdev)
+{
+       const struct qcom_icc_desc *desc;
+       struct icc_onecell_data *data;
+       struct icc_provider *provider;
+       struct qcom_icc_node **qnodes;
+       struct qcom_icc_provider *qp;
+       struct icc_node *node;
+       size_t num_nodes, i;
+       int ret;
+
+       desc = device_get_match_data(&pdev->dev);
+       if (!desc)
+               return -EINVAL;
+
+       qnodes = desc->nodes;
+       num_nodes = desc->num_nodes;
+
+       qp = devm_kzalloc(&pdev->dev, sizeof(*qp), GFP_KERNEL);
+       if (!qp)
+               return -ENOMEM;
+
+       data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       provider = &qp->provider;
+       provider->dev = &pdev->dev;
+       provider->set = qcom_icc_set;
+       provider->pre_aggregate = qcom_icc_pre_aggregate;
+       provider->aggregate = qcom_icc_aggregate;
+       provider->xlate = of_icc_xlate_onecell;
+       INIT_LIST_HEAD(&provider->nodes);
+       provider->data = data;
+
+       qp->dev = &pdev->dev;
+       qp->bcms = desc->bcms;
+       qp->num_bcms = desc->num_bcms;
+
+       qp->voter = of_bcm_voter_get(qp->dev, NULL);
+       if (IS_ERR(qp->voter))
+               return PTR_ERR(qp->voter);
+
+       ret = icc_provider_add(provider);
+       if (ret) {
+               dev_err(&pdev->dev, "error adding interconnect provider\n");
+               return ret;
+       }
+
+       for (i = 0; i < num_nodes; i++) {
+               size_t j;
+
+               if (!qnodes[i])
+                       continue;
+
+               node = icc_node_create(qnodes[i]->id);
+               if (IS_ERR(node)) {
+                       ret = PTR_ERR(node);
+                       goto err;
+               }
+
+               node->name = qnodes[i]->name;
+               node->data = qnodes[i];
+               icc_node_add(node, provider);
+
+               for (j = 0; j < qnodes[i]->num_links; j++)
+                       icc_link_create(node, qnodes[i]->links[j]);
+
+               data->nodes[i] = node;
+       }
+       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;
+err:
+       icc_nodes_remove(provider);
+       icc_provider_del(provider);
+       return ret;
+}
+
+static int qnoc_remove(struct platform_device *pdev)
+{
+       struct qcom_icc_provider *qp = platform_get_drvdata(pdev);
+
+       icc_nodes_remove(&qp->provider);
+       return icc_provider_del(&qp->provider);
+}
+
+static const struct of_device_id qnoc_of_match[] = {
+       { .compatible = "qcom,sm8250-aggre1-noc",
+         .data = &sm8250_aggre1_noc},
+       { .compatible = "qcom,sm8250-aggre2-noc",
+         .data = &sm8250_aggre2_noc},
+       { .compatible = "qcom,sm8250-compute-noc",
+         .data = &sm8250_compute_noc},
+       { .compatible = "qcom,sm8250-config-noc",
+         .data = &sm8250_config_noc},
+       { .compatible = "qcom,sm8250-dc-noc",
+         .data = &sm8250_dc_noc},
+       { .compatible = "qcom,sm8250-gem-noc",
+         .data = &sm8250_gem_noc},
+       { .compatible = "qcom,sm8250-ipa-virt",
+         .data = &sm8250_ipa_virt},
+       { .compatible = "qcom,sm8250-mc-virt",
+         .data = &sm8250_mc_virt},
+       { .compatible = "qcom,sm8250-mmss-noc",
+         .data = &sm8250_mmss_noc},
+       { .compatible = "qcom,sm8250-npu-noc",
+         .data = &sm8250_npu_noc},
+       { .compatible = "qcom,sm8250-system-noc",
+         .data = &sm8250_system_noc},
+       { }
+};
+MODULE_DEVICE_TABLE(of, qnoc_of_match);
+
+static struct platform_driver qnoc_driver = {
+       .probe = qnoc_probe,
+       .remove = qnoc_remove,
+       .driver = {
+               .name = "qnoc-sm8250",
+               .of_match_table = qnoc_of_match,
+       },
+};
+module_platform_driver(qnoc_driver);
+
+MODULE_DESCRIPTION("Qualcomm SM8250 NoC driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/interconnect/qcom/sm8250.h b/drivers/interconnect/qcom/sm8250.h
new file mode 100644 (file)
index 0000000..b31fb43
--- /dev/null
@@ -0,0 +1,164 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Qualcomm #define SM8250 interconnect IDs
+ *
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DRIVERS_INTERCONNECT_QCOM_SM8250_H
+#define __DRIVERS_INTERCONNECT_QCOM_SM8250_H
+
+#define SM8250_A1NOC_SNOC_MAS                  0
+#define SM8250_A1NOC_SNOC_SLV                  1
+#define SM8250_A2NOC_SNOC_MAS                  2
+#define SM8250_A2NOC_SNOC_SLV                  3
+#define SM8250_MASTER_A1NOC_CFG                        4
+#define SM8250_MASTER_A2NOC_CFG                        5
+#define SM8250_MASTER_AMPSS_M0                 6
+#define SM8250_MASTER_ANOC_PCIE_GEM_NOC                7
+#define SM8250_MASTER_CAMNOC_HF                        8
+#define SM8250_MASTER_CAMNOC_ICP               9
+#define SM8250_MASTER_CAMNOC_SF                        10
+#define SM8250_MASTER_CNOC_A2NOC               11
+#define SM8250_MASTER_CNOC_DC_NOC              12
+#define SM8250_MASTER_CNOC_MNOC_CFG            13
+#define SM8250_MASTER_COMPUTE_NOC              14
+#define SM8250_MASTER_CRYPTO_CORE_0            15
+#define SM8250_MASTER_GEM_NOC_CFG              16
+#define SM8250_MASTER_GEM_NOC_PCIE_SNOC                17
+#define SM8250_MASTER_GEM_NOC_SNOC             18
+#define SM8250_MASTER_GIC                      19
+#define SM8250_MASTER_GPU_TCU                  20
+#define SM8250_MASTER_GRAPHICS_3D              21
+#define SM8250_MASTER_IPA                      22
+#define SM8250_MASTER_IPA_CORE                 23
+#define SM8250_MASTER_LLCC                     24
+#define SM8250_MASTER_MDP_PORT0                        25
+#define SM8250_MASTER_MDP_PORT1                        26
+#define SM8250_MASTER_MNOC_HF_MEM_NOC          27
+#define SM8250_MASTER_MNOC_SF_MEM_NOC          28
+#define SM8250_MASTER_NPU                      29
+#define SM8250_MASTER_NPU_CDP                  30
+#define SM8250_MASTER_NPU_NOC_CFG              31
+#define SM8250_MASTER_NPU_SYS                  32
+#define SM8250_MASTER_PCIE                     33
+#define SM8250_MASTER_PCIE_1                   34
+#define SM8250_MASTER_PCIE_2                   35
+#define SM8250_MASTER_PIMEM                    36
+#define SM8250_MASTER_QDSS_BAM                 37
+#define SM8250_MASTER_QDSS_DAP                 38
+#define SM8250_MASTER_QDSS_ETR                 39
+#define SM8250_MASTER_QSPI_0                   40
+#define SM8250_MASTER_QUP_0                    41
+#define SM8250_MASTER_QUP_1                    42
+#define SM8250_MASTER_QUP_2                    43
+#define SM8250_MASTER_ROTATOR                  44
+#define SM8250_MASTER_SDCC_2                   45
+#define SM8250_MASTER_SDCC_4                   46
+#define SM8250_MASTER_SNOC_CFG                 47
+#define SM8250_MASTER_SNOC_GC_MEM_NOC          48
+#define SM8250_MASTER_SNOC_SF_MEM_NOC          49
+#define SM8250_MASTER_SYS_TCU                  50
+#define SM8250_MASTER_TSIF                     51
+#define SM8250_MASTER_UFS_CARD                 52
+#define SM8250_MASTER_UFS_MEM                  53
+#define SM8250_MASTER_USB3                     54
+#define SM8250_MASTER_USB3_1                   55
+#define SM8250_MASTER_VIDEO_P0                 56
+#define SM8250_MASTER_VIDEO_P1                 57
+#define SM8250_MASTER_VIDEO_PROC               58
+#define SM8250_SLAVE_A1NOC_CFG                 59
+#define SM8250_SLAVE_A2NOC_CFG                 60
+#define SM8250_SLAVE_AHB2PHY_NORTH             61
+#define SM8250_SLAVE_AHB2PHY_SOUTH             62
+#define SM8250_SLAVE_ANOC_PCIE_GEM_NOC         63
+#define SM8250_SLAVE_ANOC_PCIE_GEM_NOC_1       64
+#define SM8250_SLAVE_AOSS                      65
+#define SM8250_SLAVE_APPSS                     66
+#define SM8250_SLAVE_CAMERA_CFG                        67
+#define SM8250_SLAVE_CDSP_CFG                  68
+#define SM8250_SLAVE_CDSP_MEM_NOC              69
+#define SM8250_SLAVE_CLK_CTL                   70
+#define SM8250_SLAVE_CNOC_A2NOC                        71
+#define SM8250_SLAVE_CNOC_DDRSS                        72
+#define SM8250_SLAVE_CNOC_MNOC_CFG             73
+#define SM8250_SLAVE_CRYPTO_0_CFG              74
+#define SM8250_SLAVE_CX_RDPM                   75
+#define SM8250_SLAVE_DCC_CFG                   76
+#define SM8250_SLAVE_DISPLAY_CFG               77
+#define SM8250_SLAVE_EBI_CH0                   78
+#define SM8250_SLAVE_GEM_NOC_CFG               79
+#define SM8250_SLAVE_GEM_NOC_SNOC              80
+#define SM8250_SLAVE_GRAPHICS_3D_CFG           81
+#define SM8250_SLAVE_IMEM_CFG                  82
+#define SM8250_SLAVE_IPA_CFG                   83
+#define SM8250_SLAVE_IPA_CORE                  84
+#define SM8250_SLAVE_IPC_ROUTER_CFG            85
+#define SM8250_SLAVE_ISENSE_CFG                        86
+#define SM8250_SLAVE_LLCC                      87
+#define SM8250_SLAVE_LLCC_CFG                  88
+#define SM8250_SLAVE_LPASS                     89
+#define SM8250_SLAVE_MEM_NOC_PCIE_SNOC         90
+#define SM8250_SLAVE_MNOC_HF_MEM_NOC           91
+#define SM8250_SLAVE_MNOC_SF_MEM_NOC           92
+#define SM8250_SLAVE_NPU_CAL_DP0               93
+#define SM8250_SLAVE_NPU_CAL_DP1               94
+#define SM8250_SLAVE_NPU_CFG                   95
+#define SM8250_SLAVE_NPU_COMPUTE_NOC           96
+#define SM8250_SLAVE_NPU_CP                    97
+#define SM8250_SLAVE_NPU_DPM                   98
+#define SM8250_SLAVE_NPU_INT_DMA_BWMON_CFG     99
+#define SM8250_SLAVE_NPU_LLM_CFG               100
+#define SM8250_SLAVE_NPU_TCM                   101
+#define SM8250_SLAVE_OCIMEM                    102
+#define SM8250_SLAVE_PCIE_0                    103
+#define SM8250_SLAVE_PCIE_0_CFG                        104
+#define SM8250_SLAVE_PCIE_1                    105
+#define SM8250_SLAVE_PCIE_1_CFG                        106
+#define SM8250_SLAVE_PCIE_2                    107
+#define SM8250_SLAVE_PCIE_2_CFG                        108
+#define SM8250_SLAVE_PDM                       109
+#define SM8250_SLAVE_PIMEM                     110
+#define SM8250_SLAVE_PIMEM_CFG                 111
+#define SM8250_SLAVE_PRNG                      112
+#define SM8250_SLAVE_QDSS_CFG                  113
+#define SM8250_SLAVE_QDSS_STM                  114
+#define SM8250_SLAVE_QSPI_0                    115
+#define SM8250_SLAVE_QUP_0                     116
+#define SM8250_SLAVE_QUP_1                     117
+#define SM8250_SLAVE_QUP_2                     118
+#define SM8250_SLAVE_RBCPR_CX_CFG              119
+#define SM8250_SLAVE_RBCPR_MMCX_CFG            120
+#define SM8250_SLAVE_RBCPR_MX_CFG              121
+#define SM8250_SLAVE_SDCC_2                    122
+#define SM8250_SLAVE_SDCC_4                    123
+#define SM8250_SLAVE_SERVICE_A1NOC             124
+#define SM8250_SLAVE_SERVICE_A2NOC             125
+#define SM8250_SLAVE_SERVICE_CNOC              126
+#define SM8250_SLAVE_SERVICE_GEM_NOC           127
+#define SM8250_SLAVE_SERVICE_GEM_NOC_1         128
+#define SM8250_SLAVE_SERVICE_GEM_NOC_2         129
+#define SM8250_SLAVE_SERVICE_MNOC              130
+#define SM8250_SLAVE_SERVICE_NPU_NOC           131
+#define SM8250_SLAVE_SERVICE_SNOC              132
+#define SM8250_SLAVE_SNOC_CFG                  133
+#define SM8250_SLAVE_SNOC_GEM_NOC_GC           134
+#define SM8250_SLAVE_SNOC_GEM_NOC_SF           135
+#define SM8250_SLAVE_TCSR                      136
+#define SM8250_SLAVE_TCU                       137
+#define SM8250_SLAVE_TLMM_NORTH                        138
+#define SM8250_SLAVE_TLMM_SOUTH                        139
+#define SM8250_SLAVE_TLMM_WEST                 140
+#define SM8250_SLAVE_TSIF                      141
+#define SM8250_SLAVE_UFS_CARD_CFG              142
+#define SM8250_SLAVE_UFS_MEM_CFG               143
+#define SM8250_SLAVE_USB3                      144
+#define SM8250_SLAVE_USB3_1                    145
+#define SM8250_SLAVE_VENUS_CFG                 146
+#define SM8250_SLAVE_VSENSE_CTRL_CFG           147
+#define SM8250_SNOC_CNOC_MAS                   148
+#define SM8250_SNOC_CNOC_SLV                   149
+#define SM8250_MASTER_EPSS_L3_APPS             150
+#define SM8250_SLAVE_EPSS_L3                   151
+
+#endif
index 1f061d9..626b97d 100644 (file)
@@ -10,7 +10,7 @@ config AMD_IOMMU
        select IOMMU_API
        select IOMMU_IOVA
        select IOMMU_DMA
-       depends on X86_64 && PCI && ACPI
+       depends on X86_64 && PCI && ACPI && HAVE_CMPXCHG_DOUBLE
        help
          With this option you can enable support for AMD IOMMU hardware in
          your system. An IOMMU is a hardware component which provides
index 958050c..445a08d 100644 (file)
@@ -1511,7 +1511,14 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
                        iommu->mmio_phys_end = MMIO_REG_END_OFFSET;
                else
                        iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
-               if (((h->efr_attr & (0x1 << IOMMU_FEAT_GASUP_SHIFT)) == 0))
+
+               /*
+                * Note: GA (128-bit IRTE) mode requires cmpxchg16b supports.
+                * GAM also requires GA mode. Therefore, we need to
+                * check cmpxchg16b support before enabling it.
+                */
+               if (!boot_cpu_has(X86_FEATURE_CX16) ||
+                   ((h->efr_attr & (0x1 << IOMMU_FEAT_GASUP_SHIFT)) == 0))
                        amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
                break;
        case 0x11:
@@ -1520,8 +1527,18 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h)
                        iommu->mmio_phys_end = MMIO_REG_END_OFFSET;
                else
                        iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
-               if (((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0))
+
+               /*
+                * Note: GA (128-bit IRTE) mode requires cmpxchg16b supports.
+                * XT, GAM also requires GA mode. Therefore, we need to
+                * check cmpxchg16b support before enabling them.
+                */
+               if (!boot_cpu_has(X86_FEATURE_CX16) ||
+                   ((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0)) {
                        amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
+                       break;
+               }
+
                /*
                 * Note: Since iommu_update_intcapxt() leverages
                 * the IOMMU MMIO access to MSI capability block registers
@@ -2258,7 +2275,7 @@ static void iommu_enable_ga(struct amd_iommu *iommu)
        switch (amd_iommu_guest_ir) {
        case AMD_IOMMU_GUEST_IR_VAPIC:
                iommu_feature_enable(iommu, CONTROL_GAM_EN);
-               /* Fall through */
+               fallthrough;
        case AMD_IOMMU_GUEST_IR_LEGACY_GA:
                iommu_feature_enable(iommu, CONTROL_GA_EN);
                iommu->irte_ops = &irte_128_ops;
index ba9f3db..07ae8b9 100644 (file)
@@ -2659,7 +2659,12 @@ static int amd_iommu_def_domain_type(struct device *dev)
        if (!dev_data)
                return 0;
 
-       if (dev_data->iommu_v2)
+       /*
+        * Do not identity map IOMMUv2 capable devices when memory encryption is
+        * active, because some of those devices (AMD GPUs) don't have the
+        * encryption bit in their DMA-mask and require remapping.
+        */
+       if (!mem_encrypt_active() && dev_data->iommu_v2)
                return IOMMU_DOMAIN_IDENTITY;
 
        return 0;
@@ -3292,6 +3297,7 @@ out:
 static int modify_irte_ga(u16 devid, int index, struct irte_ga *irte,
                          struct amd_ir_data *data)
 {
+       bool ret;
        struct irq_remap_table *table;
        struct amd_iommu *iommu;
        unsigned long flags;
@@ -3309,10 +3315,18 @@ static int modify_irte_ga(u16 devid, int index, struct irte_ga *irte,
 
        entry = (struct irte_ga *)table->table;
        entry = &entry[index];
-       entry->lo.fields_remap.valid = 0;
-       entry->hi.val = irte->hi.val;
-       entry->lo.val = irte->lo.val;
-       entry->lo.fields_remap.valid = 1;
+
+       ret = cmpxchg_double(&entry->lo.val, &entry->hi.val,
+                            entry->lo.val, entry->hi.val,
+                            irte->lo.val, irte->hi.val);
+       /*
+        * We use cmpxchg16 to atomically update the 128-bit IRTE,
+        * and it cannot be updated by the hardware or other processors
+        * behind us, so the return value of cmpxchg16 should be the
+        * same as the old value.
+        */
+       WARN_ON(!ret);
+
        if (data)
                data->ref = entry;
 
@@ -3850,6 +3864,7 @@ int amd_iommu_deactivate_guest_mode(void *data)
        struct amd_ir_data *ir_data = (struct amd_ir_data *)data;
        struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
        struct irq_cfg *cfg = ir_data->cfg;
+       u64 valid = entry->lo.fields_remap.valid;
 
        if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
            !entry || !entry->lo.fields_vapic.guest_mode)
@@ -3858,6 +3873,7 @@ int amd_iommu_deactivate_guest_mode(void *data)
        entry->lo.val = 0;
        entry->hi.val = 0;
 
+       entry->lo.fields_remap.valid       = valid;
        entry->lo.fields_remap.dm          = apic->irq_dest_mode;
        entry->lo.fields_remap.int_type    = apic->irq_delivery_mode;
        entry->hi.fields.vector            = cfg->vector;
index c259108..0d175ae 100644 (file)
@@ -737,6 +737,13 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids)
 
        might_sleep();
 
+       /*
+        * When memory encryption is active the device is likely not in a
+        * direct-mapped domain. Forbid using IOMMUv2 functionality for now.
+        */
+       if (mem_encrypt_active())
+               return -ENODEV;
+
        if (!amd_iommu_v2_supported())
                return -ENODEV;
 
index 7196207..c192544 100644 (file)
@@ -903,7 +903,7 @@ static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent)
                break;
        case CMDQ_OP_CFGI_CD:
                cmd[0] |= FIELD_PREP(CMDQ_CFGI_0_SSID, ent->cfgi.ssid);
-               /* Fallthrough */
+               fallthrough;
        case CMDQ_OP_CFGI_STE:
                cmd[0] |= FIELD_PREP(CMDQ_CFGI_0_SID, ent->cfgi.sid);
                cmd[1] |= FIELD_PREP(CMDQ_CFGI_1_LEAF, ent->cfgi.leaf);
@@ -936,7 +936,7 @@ static int arm_smmu_cmdq_build_cmd(u64 *cmd, struct arm_smmu_cmdq_ent *ent)
                break;
        case CMDQ_OP_TLBI_NH_ASID:
                cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_ASID, ent->tlbi.asid);
-               /* Fallthrough */
+               fallthrough;
        case CMDQ_OP_TLBI_S12_VMALL:
                cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_VMID, ent->tlbi.vmid);
                break;
@@ -1036,7 +1036,6 @@ static void arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu)
                 */
                return;
        case CMDQ_ERR_CERROR_ILL_IDX:
-               /* Fallthrough */
        default:
                break;
        }
@@ -3758,7 +3757,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
        switch (FIELD_GET(IDR0_STALL_MODEL, reg)) {
        case IDR0_STALL_MODEL_FORCE:
                smmu->features |= ARM_SMMU_FEAT_STALL_FORCE;
-               /* Fallthrough */
+               fallthrough;
        case IDR0_STALL_MODEL_STALL:
                smmu->features |= ARM_SMMU_FEAT_STALLS;
        }
@@ -3778,7 +3777,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
        switch (FIELD_GET(IDR0_TTF, reg)) {
        case IDR0_TTF_AARCH32_64:
                smmu->ias = 40;
-               /* Fallthrough */
+               fallthrough;
        case IDR0_TTF_AARCH64:
                break;
        default:
@@ -3875,7 +3874,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
        default:
                dev_info(smmu->dev,
                        "unknown output address size. Truncating to 48-bit\n");
-               /* Fallthrough */
+               fallthrough;
        case IDR5_OAS_48_BIT:
                smmu->oas = 48;
        }
index 4959f5d..5141d49 100644 (file)
@@ -1035,8 +1035,8 @@ static void *iommu_dma_alloc(struct device *dev, size_t size,
 
        if (IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
            !gfpflags_allow_blocking(gfp) && !coherent)
-               cpu_addr = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &page,
-                                              gfp);
+               page = dma_alloc_from_pool(dev, PAGE_ALIGN(size), &cpu_addr,
+                                              gfp, NULL);
        else
                cpu_addr = iommu_dma_alloc_pages(dev, size, &page, gfp, attrs);
        if (!cpu_addr)
index e9864e5..87b17ba 100644 (file)
@@ -123,29 +123,29 @@ static inline unsigned int level_to_offset_bits(int level)
        return (level - 1) * LEVEL_STRIDE;
 }
 
-static inline int pfn_level_offset(unsigned long pfn, int level)
+static inline int pfn_level_offset(u64 pfn, int level)
 {
        return (pfn >> level_to_offset_bits(level)) & LEVEL_MASK;
 }
 
-static inline unsigned long level_mask(int level)
+static inline u64 level_mask(int level)
 {
-       return -1UL << level_to_offset_bits(level);
+       return -1ULL << level_to_offset_bits(level);
 }
 
-static inline unsigned long level_size(int level)
+static inline u64 level_size(int level)
 {
-       return 1UL << level_to_offset_bits(level);
+       return 1ULL << level_to_offset_bits(level);
 }
 
-static inline unsigned long align_to_level(unsigned long pfn, int level)
+static inline u64 align_to_level(u64 pfn, int level)
 {
        return (pfn + level_size(level) - 1) & level_mask(level);
 }
 
 static inline unsigned long lvl_to_nr_pages(unsigned int lvl)
 {
-       return  1 << min_t(int, (lvl - 1) * LEVEL_STRIDE, MAX_AGAW_PFN_WIDTH);
+       return 1UL << min_t(int, (lvl - 1) * LEVEL_STRIDE, MAX_AGAW_PFN_WIDTH);
 }
 
 /* VT-d pages must always be _smaller_ than MM pages. Otherwise things
@@ -364,7 +364,6 @@ static int iommu_skip_te_disable;
 int intel_iommu_gfx_mapped;
 EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped);
 
-#define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1))
 #define DEFER_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-2))
 struct device_domain_info *get_domain_info(struct device *dev)
 {
@@ -374,8 +373,7 @@ struct device_domain_info *get_domain_info(struct device *dev)
                return NULL;
 
        info = dev_iommu_priv_get(dev);
-       if (unlikely(info == DUMMY_DEVICE_DOMAIN_INFO ||
-                    info == DEFER_DEVICE_DOMAIN_INFO))
+       if (unlikely(info == DEFER_DEVICE_DOMAIN_INFO))
                return NULL;
 
        return info;
@@ -742,11 +740,6 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
        return &context[devfn];
 }
 
-static int iommu_dummy(struct device *dev)
-{
-       return dev_iommu_priv_get(dev) == DUMMY_DEVICE_DOMAIN_INFO;
-}
-
 static bool attach_deferred(struct device *dev)
 {
        return dev_iommu_priv_get(dev) == DEFER_DEVICE_DOMAIN_INFO;
@@ -779,6 +772,53 @@ is_downstream_to_pci_bridge(struct device *dev, struct device *bridge)
        return false;
 }
 
+static bool quirk_ioat_snb_local_iommu(struct pci_dev *pdev)
+{
+       struct dmar_drhd_unit *drhd;
+       u32 vtbar;
+       int rc;
+
+       /* We know that this device on this chipset has its own IOMMU.
+        * If we find it under a different IOMMU, then the BIOS is lying
+        * to us. Hope that the IOMMU for this device is actually
+        * disabled, and it needs no translation...
+        */
+       rc = pci_bus_read_config_dword(pdev->bus, PCI_DEVFN(0, 0), 0xb0, &vtbar);
+       if (rc) {
+               /* "can't" happen */
+               dev_info(&pdev->dev, "failed to run vt-d quirk\n");
+               return false;
+       }
+       vtbar &= 0xffff0000;
+
+       /* we know that the this iommu should be at offset 0xa000 from vtbar */
+       drhd = dmar_find_matched_drhd_unit(pdev);
+       if (!drhd || drhd->reg_base_addr - vtbar != 0xa000) {
+               pr_warn_once(FW_BUG "BIOS assigned incorrect VT-d unit for Intel(R) QuickData Technology device\n");
+               add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
+               return true;
+       }
+
+       return false;
+}
+
+static bool iommu_is_dummy(struct intel_iommu *iommu, struct device *dev)
+{
+       if (!iommu || iommu->drhd->ignored)
+               return true;
+
+       if (dev_is_pci(dev)) {
+               struct pci_dev *pdev = to_pci_dev(dev);
+
+               if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
+                   pdev->device == PCI_DEVICE_ID_INTEL_IOAT_SNB &&
+                   quirk_ioat_snb_local_iommu(pdev))
+                       return true;
+       }
+
+       return false;
+}
+
 struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
 {
        struct dmar_drhd_unit *drhd = NULL;
@@ -788,7 +828,7 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
        u16 segment = 0;
        int i;
 
-       if (!dev || iommu_dummy(dev))
+       if (!dev)
                return NULL;
 
        if (dev_is_pci(dev)) {
@@ -805,7 +845,7 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
                dev = &ACPI_COMPANION(dev)->dev;
 
        rcu_read_lock();
-       for_each_active_iommu(iommu, drhd) {
+       for_each_iommu(iommu, drhd) {
                if (pdev && segment != drhd->segment)
                        continue;
 
@@ -841,6 +881,9 @@ struct intel_iommu *device_to_iommu(struct device *dev, u8 *bus, u8 *devfn)
        }
        iommu = NULL;
  out:
+       if (iommu_is_dummy(iommu, dev))
+               iommu = NULL;
+
        rcu_read_unlock();
 
        return iommu;
@@ -2447,7 +2490,7 @@ struct dmar_domain *find_domain(struct device *dev)
 {
        struct device_domain_info *info;
 
-       if (unlikely(attach_deferred(dev) || iommu_dummy(dev)))
+       if (unlikely(attach_deferred(dev)))
                return NULL;
 
        /* No lock here, assumes no domain exit in normal case */
@@ -3989,35 +4032,6 @@ static void __init iommu_exit_mempool(void)
        iova_cache_put();
 }
 
-static void quirk_ioat_snb_local_iommu(struct pci_dev *pdev)
-{
-       struct dmar_drhd_unit *drhd;
-       u32 vtbar;
-       int rc;
-
-       /* We know that this device on this chipset has its own IOMMU.
-        * If we find it under a different IOMMU, then the BIOS is lying
-        * to us. Hope that the IOMMU for this device is actually
-        * disabled, and it needs no translation...
-        */
-       rc = pci_bus_read_config_dword(pdev->bus, PCI_DEVFN(0, 0), 0xb0, &vtbar);
-       if (rc) {
-               /* "can't" happen */
-               dev_info(&pdev->dev, "failed to run vt-d quirk\n");
-               return;
-       }
-       vtbar &= 0xffff0000;
-
-       /* we know that the this iommu should be at offset 0xa000 from vtbar */
-       drhd = dmar_find_matched_drhd_unit(pdev);
-       if (!drhd || drhd->reg_base_addr - vtbar != 0xa000) {
-               pr_warn_once(FW_BUG "BIOS assigned incorrect VT-d unit for Intel(R) QuickData Technology device\n");
-               add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
-               dev_iommu_priv_set(&pdev->dev, DUMMY_DEVICE_DOMAIN_INFO);
-       }
-}
-DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IOAT_SNB, quirk_ioat_snb_local_iommu);
-
 static void __init init_no_remapping_devices(void)
 {
        struct dmar_drhd_unit *drhd;
@@ -4049,12 +4063,8 @@ static void __init init_no_remapping_devices(void)
                /* This IOMMU has *only* gfx devices. Either bypass it or
                   set the gfx_mapped flag, as appropriate */
                drhd->gfx_dedicated = 1;
-               if (!dmar_map_gfx) {
+               if (!dmar_map_gfx)
                        drhd->ignored = 1;
-                       for_each_active_dev_scope(drhd->devices,
-                                                 drhd->devices_cnt, i, dev)
-                               dev_iommu_priv_set(dev, DUMMY_DEVICE_DOMAIN_INFO);
-               }
        }
 }
 
@@ -5070,7 +5080,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
 
        switch (type) {
        case IOMMU_DOMAIN_DMA:
-       /* fallthrough */
        case IOMMU_DOMAIN_UNMANAGED:
                dmar_domain = alloc_domain(0);
                if (!dmar_domain) {
index 23583b0..8f4ce72 100644 (file)
@@ -508,12 +508,18 @@ static void iommu_enable_irq_remapping(struct intel_iommu *iommu)
 
        /* Enable interrupt-remapping */
        iommu->gcmd |= DMA_GCMD_IRE;
-       iommu->gcmd &= ~DMA_GCMD_CFI;  /* Block compatibility-format MSIs */
        writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
-
        IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
                      readl, (sts & DMA_GSTS_IRES), sts);
 
+       /* Block compatibility-format MSIs */
+       if (sts & DMA_GSTS_CFIS) {
+               iommu->gcmd &= ~DMA_GCMD_CFI;
+               writel(iommu->gcmd, iommu->reg + DMAR_GCMD_REG);
+               IOMMU_WAIT_OP(iommu, DMAR_GSTS_REG,
+                             readl, !(sts & DMA_GSTS_CFIS), sts);
+       }
+
        /*
         * With CFI clear in the Global Command register, we should be
         * protected from dangerous (i.e. compatibility) interrupts
index b4da396..2bfdd57 100644 (file)
@@ -440,7 +440,7 @@ static int viommu_add_resv_mem(struct viommu_endpoint *vdev,
        default:
                dev_warn(vdev->dev, "unknown resv mem subtype 0x%x\n",
                         mem->subtype);
-               /* Fall-through */
+               fallthrough;
        case VIRTIO_IOMMU_RESV_MEM_T_RESERVED:
                region = iommu_alloc_resv_region(start, size, 0,
                                                 IOMMU_RESV_RESERVED);
index bb70b71..bfc9719 100644 (file)
@@ -425,7 +425,7 @@ config GOLDFISH_PIC
          for Goldfish based virtual platforms.
 
 config QCOM_PDC
-       tristate "QCOM PDC"
+       bool "QCOM PDC"
        depends on ARCH_QCOM
        select IRQ_DOMAIN_HIERARCHY
        help
index 95f0974..548de75 100644 (file)
@@ -2737,7 +2737,7 @@ static bool allocate_vpe_l2_table(int cpu, u32 id)
        switch (gpsz) {
        default:
                WARN_ON(1);
-               /* fall through */
+               fallthrough;
        case GIC_PAGE_SIZE_4K:
                psz = SZ_4K;
                break;
@@ -2832,7 +2832,7 @@ static int allocate_vpe_l1_table(void)
        switch (gpsz) {
        default:
                gpsz = GIC_PAGE_SIZE_4K;
-               /* fall through */
+               fallthrough;
        case GIC_PAGE_SIZE_4K:
                psz = SZ_4K;
                break;
index 324f280..850842f 100644 (file)
@@ -965,10 +965,10 @@ static void gic_cpu_sys_reg_init(void)
                case 7:
                        write_gicreg(0, ICC_AP0R3_EL1);
                        write_gicreg(0, ICC_AP0R2_EL1);
-               /* Fall through */
+                       fallthrough;
                case 6:
                        write_gicreg(0, ICC_AP0R1_EL1);
-               /* Fall through */
+                       fallthrough;
                case 5:
                case 4:
                        write_gicreg(0, ICC_AP0R0_EL1);
@@ -982,10 +982,10 @@ static void gic_cpu_sys_reg_init(void)
        case 7:
                write_gicreg(0, ICC_AP1R3_EL1);
                write_gicreg(0, ICC_AP1R2_EL1);
-               /* Fall through */
+               fallthrough;
        case 6:
                write_gicreg(0, ICC_AP1R1_EL1);
-               /* Fall through */
+               fallthrough;
        case 5:
        case 4:
                write_gicreg(0, ICC_AP1R0_EL1);
index 4f74c15..7031ef4 100644 (file)
@@ -259,7 +259,7 @@ static int __init imx_gpcv2_irqchip_init(struct device_node *node,
                case 4:
                        writel_relaxed(~0, reg + GPC_IMR1_CORE2);
                        writel_relaxed(~0, reg + GPC_IMR1_CORE3);
-                       /* fall through */
+                       fallthrough;
                case 2:
                        writel_relaxed(~0, reg + GPC_IMR1_CORE0);
                        writel_relaxed(~0, reg + GPC_IMR1_CORE1);
index 9f3da42..b61a890 100644 (file)
@@ -125,7 +125,7 @@ static int __init ingenic_intc_of_init(struct device_node *node,
                irq_reg_writel(gc, IRQ_MSK(32), JZ_REG_INTC_SET_MASK);
        }
 
-       if (request_irq(parent_irq, intc_cascade, 0,
+       if (request_irq(parent_irq, intc_cascade, IRQF_NO_SUSPEND,
                        "SoC intc cascade interrupt", NULL))
                pr_err("Failed to register SoC intc cascade interrupt\n");
        return 0;
index aacfa01..2158859 100644 (file)
@@ -480,7 +480,7 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,
        case GIC_LOCAL_INT_TIMER:
                /* CONFIG_MIPS_CMP workaround (see __gic_init) */
                map = GIC_MAP_PIN_MAP_TO_PIN | timer_cpu_pin;
-               /* fall-through */
+               fallthrough;
        case GIC_LOCAL_INT_PERFCTR:
        case GIC_LOCAL_INT_FDC:
                /*
index 62a6127..69ba8ce 100644 (file)
@@ -295,6 +295,4 @@ out_free:
        return ret;
 }
 
-IRQCHIP_PLATFORM_DRIVER_BEGIN(mtk_cirq)
-IRQCHIP_MATCH("mediatek,mtk-cirq", mtk_cirq_of_init)
-IRQCHIP_PLATFORM_DRIVER_END(mtk_cirq)
+IRQCHIP_DECLARE(mtk_cirq, "mediatek,mtk-cirq", mtk_cirq_of_init);
index 7299c5a..6ff98b8 100644 (file)
@@ -231,6 +231,4 @@ out_free_chip:
        kfree(chip_data);
        return ret;
 }
-IRQCHIP_PLATFORM_DRIVER_BEGIN(mtk_sysirq)
-IRQCHIP_MATCH("mediatek,mt6577-sysirq", mtk_sysirq_of_init)
-IRQCHIP_PLATFORM_DRIVER_END(mtk_sysirq)
+IRQCHIP_DECLARE(mtk_sysirq, "mediatek,mt6577-sysirq", mtk_sysirq_of_init);
index 03a36be..0c2c61d 100644 (file)
@@ -416,6 +416,16 @@ static void stm32_irq_ack(struct irq_data *d)
        irq_gc_unlock(gc);
 }
 
+/* directly set the target bit without reading first. */
+static inline void stm32_exti_write_bit(struct irq_data *d, u32 reg)
+{
+       struct stm32_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
+       void __iomem *base = chip_data->host_data->base;
+       u32 val = BIT(d->hwirq % IRQS_PER_BANK);
+
+       writel_relaxed(val, base + reg);
+}
+
 static inline u32 stm32_exti_set_bit(struct irq_data *d, u32 reg)
 {
        struct stm32_exti_chip_data *chip_data = irq_data_get_irq_chip_data(d);
@@ -449,9 +459,9 @@ static void stm32_exti_h_eoi(struct irq_data *d)
 
        raw_spin_lock(&chip_data->rlock);
 
-       stm32_exti_set_bit(d, stm32_bank->rpr_ofst);
+       stm32_exti_write_bit(d, stm32_bank->rpr_ofst);
        if (stm32_bank->fpr_ofst != UNDEF_REG)
-               stm32_exti_set_bit(d, stm32_bank->fpr_ofst);
+               stm32_exti_write_bit(d, stm32_bank->fpr_ofst);
 
        raw_spin_unlock(&chip_data->rlock);
 
index b7cc5d6..d4e9760 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/irq.h>
 #include <linux/irqchip.h>
 #include <linux/irqdomain.h>
 #include <linux/interrupt.h>
@@ -83,6 +84,7 @@ struct ti_sci_inta_vint_desc {
  * @vint_mutex:                Mutex to protect vint_list
  * @base:              Base address of the memory mapped IO registers
  * @pdev:              Pointer to platform device.
+ * @ti_sci_id:         TI-SCI device identifier
  */
 struct ti_sci_inta_irq_domain {
        const struct ti_sci_handle *sci;
@@ -93,6 +95,7 @@ struct ti_sci_inta_irq_domain {
        struct mutex vint_mutex;
        void __iomem *base;
        struct platform_device *pdev;
+       u32 ti_sci_id;
 };
 
 #define to_vint_desc(e, i) container_of(e, struct ti_sci_inta_vint_desc, \
@@ -128,6 +131,37 @@ static void ti_sci_inta_irq_handler(struct irq_desc *desc)
        chained_irq_exit(irq_desc_get_chip(desc), desc);
 }
 
+/**
+ * ti_sci_inta_xlate_irq() - Translate hwirq to parent's hwirq.
+ * @inta:      IRQ domain corresponding to Interrupt Aggregator
+ * @irq:       Hardware irq corresponding to the above irq domain
+ *
+ * Return parent irq number if translation is available else -ENOENT.
+ */
+static int ti_sci_inta_xlate_irq(struct ti_sci_inta_irq_domain *inta,
+                                u16 vint_id)
+{
+       struct device_node *np = dev_of_node(&inta->pdev->dev);
+       u32 base, parent_base, size;
+       const __be32 *range;
+       int len;
+
+       range = of_get_property(np, "ti,interrupt-ranges", &len);
+       if (!range)
+               return vint_id;
+
+       for (len /= sizeof(*range); len >= 3; len -= 3) {
+               base = be32_to_cpu(*range++);
+               parent_base = be32_to_cpu(*range++);
+               size = be32_to_cpu(*range++);
+
+               if (base <= vint_id && vint_id < base + size)
+                       return vint_id - base + parent_base;
+       }
+
+       return -ENOENT;
+}
+
 /**
  * ti_sci_inta_alloc_parent_irq() - Allocate parent irq to Interrupt aggregator
  * @domain:    IRQ domain corresponding to Interrupt Aggregator
@@ -139,30 +173,52 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
        struct ti_sci_inta_irq_domain *inta = domain->host_data;
        struct ti_sci_inta_vint_desc *vint_desc;
        struct irq_fwspec parent_fwspec;
+       struct device_node *parent_node;
        unsigned int parent_virq;
-       u16 vint_id;
+       u16 vint_id, p_hwirq;
+       int ret;
 
        vint_id = ti_sci_get_free_resource(inta->vint);
        if (vint_id == TI_SCI_RESOURCE_NULL)
                return ERR_PTR(-EINVAL);
 
+       p_hwirq = ti_sci_inta_xlate_irq(inta, vint_id);
+       if (p_hwirq < 0) {
+               ret = p_hwirq;
+               goto free_vint;
+       }
+
        vint_desc = kzalloc(sizeof(*vint_desc), GFP_KERNEL);
-       if (!vint_desc)
-               return ERR_PTR(-ENOMEM);
+       if (!vint_desc) {
+               ret = -ENOMEM;
+               goto free_vint;
+       }
 
        vint_desc->domain = domain;
        vint_desc->vint_id = vint_id;
        INIT_LIST_HEAD(&vint_desc->list);
 
-       parent_fwspec.fwnode = of_node_to_fwnode(of_irq_find_parent(dev_of_node(&inta->pdev->dev)));
-       parent_fwspec.param_count = 2;
-       parent_fwspec.param[0] = inta->pdev->id;
-       parent_fwspec.param[1] = vint_desc->vint_id;
+       parent_node = of_irq_find_parent(dev_of_node(&inta->pdev->dev));
+       parent_fwspec.fwnode = of_node_to_fwnode(parent_node);
+
+       if (of_device_is_compatible(parent_node, "arm,gic-v3")) {
+               /* Parent is GIC */
+               parent_fwspec.param_count = 3;
+               parent_fwspec.param[0] = 0;
+               parent_fwspec.param[1] = p_hwirq - 32;
+               parent_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH;
+       } else {
+               /* Parent is Interrupt Router */
+               parent_fwspec.param_count = 1;
+               parent_fwspec.param[0] = p_hwirq;
+       }
 
        parent_virq = irq_create_fwspec_mapping(&parent_fwspec);
        if (parent_virq == 0) {
-               kfree(vint_desc);
-               return ERR_PTR(-EINVAL);
+               dev_err(&inta->pdev->dev, "Parent IRQ allocation failed\n");
+               ret = -EINVAL;
+               goto free_vint_desc;
+
        }
        vint_desc->parent_virq = parent_virq;
 
@@ -171,6 +227,11 @@ static struct ti_sci_inta_vint_desc *ti_sci_inta_alloc_parent_irq(struct irq_dom
                                         ti_sci_inta_irq_handler, vint_desc);
 
        return vint_desc;
+free_vint_desc:
+       kfree(vint_desc);
+free_vint:
+       ti_sci_release_resource(inta->vint, vint_id);
+       return ERR_PTR(ret);
 }
 
 /**
@@ -202,7 +263,7 @@ static struct ti_sci_inta_event_desc *ti_sci_inta_alloc_event(struct ti_sci_inta
 
        err = inta->sci->ops.rm_irq_ops.set_event_map(inta->sci,
                                                      dev_id, dev_index,
-                                                     inta->pdev->id,
+                                                     inta->ti_sci_id,
                                                      vint_desc->vint_id,
                                                      event_desc->global_event,
                                                      free_bit);
@@ -299,7 +360,7 @@ static void ti_sci_inta_free_irq(struct ti_sci_inta_event_desc *event_desc,
        inta->sci->ops.rm_irq_ops.free_event_map(inta->sci,
                                                 HWIRQ_TO_DEVID(hwirq),
                                                 HWIRQ_TO_IRQID(hwirq),
-                                                inta->pdev->id,
+                                                inta->ti_sci_id,
                                                 vint_desc->vint_id,
                                                 event_desc->global_event,
                                                 event_desc->vint_bit);
@@ -547,21 +608,21 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
                return ret;
        }
 
-       ret = of_property_read_u32(dev->of_node, "ti,sci-dev-id", &pdev->id);
+       ret = of_property_read_u32(dev->of_node, "ti,sci-dev-id", &inta->ti_sci_id);
        if (ret) {
                dev_err(dev, "missing 'ti,sci-dev-id' property\n");
                return -EINVAL;
        }
 
-       inta->vint = devm_ti_sci_get_of_resource(inta->sci, dev, pdev->id,
-                                                "ti,sci-rm-range-vint");
+       inta->vint = devm_ti_sci_get_resource(inta->sci, dev, inta->ti_sci_id,
+                                             TI_SCI_RESASG_SUBTYPE_IA_VINT);
        if (IS_ERR(inta->vint)) {
                dev_err(dev, "VINT resource allocation failed\n");
                return PTR_ERR(inta->vint);
        }
 
-       inta->global_event = devm_ti_sci_get_of_resource(inta->sci, dev, pdev->id,
-                                               "ti,sci-rm-range-global-event");
+       inta->global_event = devm_ti_sci_get_resource(inta->sci, dev, inta->ti_sci_id,
+                                                     TI_SCI_RESASG_SUBTYPE_GLOBAL_EVENT_SEVT);
        if (IS_ERR(inta->global_event)) {
                dev_err(dev, "Global event resource allocation failed\n");
                return PTR_ERR(inta->global_event);
@@ -592,6 +653,8 @@ static int ti_sci_inta_irq_domain_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&inta->vint_list);
        mutex_init(&inta->vint_mutex);
 
+       dev_info(dev, "Interrupt Aggregator domain %d created\n", pdev->id);
+
        return 0;
 }
 
index 5ea148f..cbc1758 100644 (file)
 #include <linux/of_irq.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 
-#define TI_SCI_DEV_ID_MASK     0xffff
-#define TI_SCI_DEV_ID_SHIFT    16
-#define TI_SCI_IRQ_ID_MASK     0xffff
-#define TI_SCI_IRQ_ID_SHIFT    0
-#define HWIRQ_TO_DEVID(hwirq)  (((hwirq) >> (TI_SCI_DEV_ID_SHIFT)) & \
-                                (TI_SCI_DEV_ID_MASK))
-#define HWIRQ_TO_IRQID(hwirq)  ((hwirq) & (TI_SCI_IRQ_ID_MASK))
-#define TO_HWIRQ(dev, index)   ((((dev) & TI_SCI_DEV_ID_MASK) << \
-                                TI_SCI_DEV_ID_SHIFT) | \
-                               ((index) & TI_SCI_IRQ_ID_MASK))
-
 /**
  * struct ti_sci_intr_irq_domain - Structure representing a TISCI based
  *                                Interrupt Router IRQ domain.
  * @sci:       Pointer to TISCI handle
- * @dst_irq:   TISCI resource pointer representing GIC irq controller.
- * @dst_id:    TISCI device ID of the GIC irq controller.
+ * @out_irqs:  TISCI resource pointer representing INTR irqs.
+ * @dev:       Struct device pointer.
+ * @ti_sci_id: TI-SCI device identifier
  * @type:      Specifies the trigger type supported by this Interrupt Router
  */
 struct ti_sci_intr_irq_domain {
        const struct ti_sci_handle *sci;
-       struct ti_sci_resource *dst_irq;
-       u32 dst_id;
+       struct ti_sci_resource *out_irqs;
+       struct device *dev;
+       u32 ti_sci_id;
        u32 type;
 };
 
@@ -70,15 +61,44 @@ static int ti_sci_intr_irq_domain_translate(struct irq_domain *domain,
 {
        struct ti_sci_intr_irq_domain *intr = domain->host_data;
 
-       if (fwspec->param_count != 2)
+       if (fwspec->param_count != 1)
                return -EINVAL;
 
-       *hwirq = TO_HWIRQ(fwspec->param[0], fwspec->param[1]);
+       *hwirq = fwspec->param[0];
        *type = intr->type;
 
        return 0;
 }
 
+/**
+ * ti_sci_intr_xlate_irq() - Translate hwirq to parent's hwirq.
+ * @intr:      IRQ domain corresponding to Interrupt Router
+ * @irq:       Hardware irq corresponding to the above irq domain
+ *
+ * Return parent irq number if translation is available else -ENOENT.
+ */
+static int ti_sci_intr_xlate_irq(struct ti_sci_intr_irq_domain *intr, u32 irq)
+{
+       struct device_node *np = dev_of_node(intr->dev);
+       u32 base, pbase, size, len;
+       const __be32 *range;
+
+       range = of_get_property(np, "ti,interrupt-ranges", &len);
+       if (!range)
+               return irq;
+
+       for (len /= sizeof(*range); len >= 3; len -= 3) {
+               base = be32_to_cpu(*range++);
+               pbase = be32_to_cpu(*range++);
+               size = be32_to_cpu(*range++);
+
+               if (base <= irq && irq < base + size)
+                       return irq - base + pbase;
+       }
+
+       return -ENOENT;
+}
+
 /**
  * ti_sci_intr_irq_domain_free() - Free the specified IRQs from the domain.
  * @domain:    Domain to which the irqs belong
@@ -89,66 +109,76 @@ static void ti_sci_intr_irq_domain_free(struct irq_domain *domain,
                                        unsigned int virq, unsigned int nr_irqs)
 {
        struct ti_sci_intr_irq_domain *intr = domain->host_data;
-       struct irq_data *data, *parent_data;
-       u16 dev_id, irq_index;
+       struct irq_data *data;
+       int out_irq;
 
-       parent_data = irq_domain_get_irq_data(domain->parent, virq);
        data = irq_domain_get_irq_data(domain, virq);
-       irq_index = HWIRQ_TO_IRQID(data->hwirq);
-       dev_id = HWIRQ_TO_DEVID(data->hwirq);
+       out_irq = (uintptr_t)data->chip_data;
 
-       intr->sci->ops.rm_irq_ops.free_irq(intr->sci, dev_id, irq_index,
-                                          intr->dst_id, parent_data->hwirq);
-       ti_sci_release_resource(intr->dst_irq, parent_data->hwirq);
+       intr->sci->ops.rm_irq_ops.free_irq(intr->sci,
+                                          intr->ti_sci_id, data->hwirq,
+                                          intr->ti_sci_id, out_irq);
+       ti_sci_release_resource(intr->out_irqs, out_irq);
        irq_domain_free_irqs_parent(domain, virq, 1);
        irq_domain_reset_irq_data(data);
 }
 
 /**
- * ti_sci_intr_alloc_gic_irq() - Allocate GIC specific IRQ
+ * ti_sci_intr_alloc_parent_irq() - Allocate parent IRQ
  * @domain:    Pointer to the interrupt router IRQ domain
  * @virq:      Corresponding Linux virtual IRQ number
  * @hwirq:     Corresponding hwirq for the IRQ within this IRQ domain
  *
- * Returns 0 if all went well else appropriate error pointer.
+ * Returns parent irq if all went well else appropriate error pointer.
  */
-static int ti_sci_intr_alloc_gic_irq(struct irq_domain *domain,
-                                    unsigned int virq, u32 hwirq)
+static int ti_sci_intr_alloc_parent_irq(struct irq_domain *domain,
+                                       unsigned int virq, u32 hwirq)
 {
        struct ti_sci_intr_irq_domain *intr = domain->host_data;
+       struct device_node *parent_node;
        struct irq_fwspec fwspec;
-       u16 dev_id, irq_index;
-       u16 dst_irq;
-       int err;
-
-       dev_id = HWIRQ_TO_DEVID(hwirq);
-       irq_index = HWIRQ_TO_IRQID(hwirq);
+       u16 out_irq, p_hwirq;
+       int err = 0;
 
-       dst_irq = ti_sci_get_free_resource(intr->dst_irq);
-       if (dst_irq == TI_SCI_RESOURCE_NULL)
+       out_irq = ti_sci_get_free_resource(intr->out_irqs);
+       if (out_irq == TI_SCI_RESOURCE_NULL)
                return -EINVAL;
 
-       fwspec.fwnode = domain->parent->fwnode;
-       fwspec.param_count = 3;
-       fwspec.param[0] = 0;    /* SPI */
-       fwspec.param[1] = dst_irq - 32; /* SPI offset */
-       fwspec.param[2] = intr->type;
+       p_hwirq = ti_sci_intr_xlate_irq(intr, out_irq);
+       if (p_hwirq < 0)
+               goto err_irqs;
+
+       parent_node = of_irq_find_parent(dev_of_node(intr->dev));
+       fwspec.fwnode = of_node_to_fwnode(parent_node);
+
+       if (of_device_is_compatible(parent_node, "arm,gic-v3")) {
+               /* Parent is GIC */
+               fwspec.param_count = 3;
+               fwspec.param[0] = 0;    /* SPI */
+               fwspec.param[1] = p_hwirq - 32; /* SPI offset */
+               fwspec.param[2] = intr->type;
+       } else {
+               /* Parent is Interrupt Router */
+               fwspec.param_count = 1;
+               fwspec.param[0] = p_hwirq;
+       }
 
        err = irq_domain_alloc_irqs_parent(domain, virq, 1, &fwspec);
        if (err)
                goto err_irqs;
 
-       err = intr->sci->ops.rm_irq_ops.set_irq(intr->sci, dev_id, irq_index,
-                                               intr->dst_id, dst_irq);
+       err = intr->sci->ops.rm_irq_ops.set_irq(intr->sci,
+                                               intr->ti_sci_id, hwirq,
+                                               intr->ti_sci_id, out_irq);
        if (err)
                goto err_msg;
 
-       return 0;
+       return p_hwirq;
 
 err_msg:
        irq_domain_free_irqs_parent(domain, virq, 1);
 err_irqs:
-       ti_sci_release_resource(intr->dst_irq, dst_irq);
+       ti_sci_release_resource(intr->out_irqs, out_irq);
        return err;
 }
 
@@ -168,18 +198,19 @@ static int ti_sci_intr_irq_domain_alloc(struct irq_domain *domain,
        struct irq_fwspec *fwspec = data;
        unsigned long hwirq;
        unsigned int flags;
-       int err;
+       int err, p_hwirq;
 
        err = ti_sci_intr_irq_domain_translate(domain, fwspec, &hwirq, &flags);
        if (err)
                return err;
 
-       err = ti_sci_intr_alloc_gic_irq(domain, virq, hwirq);
-       if (err)
-               return err;
+       p_hwirq = ti_sci_intr_alloc_parent_irq(domain, virq, hwirq);
+       if (p_hwirq < 0)
+               return p_hwirq;
 
        irq_domain_set_hwirq_and_chip(domain, virq, hwirq,
-                                     &ti_sci_intr_irq_chip, NULL);
+                                     &ti_sci_intr_irq_chip,
+                                     (void *)(uintptr_t)p_hwirq);
 
        return 0;
 }
@@ -214,6 +245,7 @@ static int ti_sci_intr_irq_domain_probe(struct platform_device *pdev)
        if (!intr)
                return -ENOMEM;
 
+       intr->dev = dev;
        ret = of_property_read_u32(dev_of_node(dev), "ti,intr-trigger-type",
                                   &intr->type);
        if (ret) {
@@ -230,19 +262,19 @@ static int ti_sci_intr_irq_domain_probe(struct platform_device *pdev)
                return ret;
        }
 
-       ret = of_property_read_u32(dev_of_node(dev), "ti,sci-dst-id",
-                                  &intr->dst_id);
+       ret = of_property_read_u32(dev_of_node(dev), "ti,sci-dev-id",
+                                  &intr->ti_sci_id);
        if (ret) {
-               dev_err(dev, "missing 'ti,sci-dst-id' property\n");
+               dev_err(dev, "missing 'ti,sci-dev-id' property\n");
                return -EINVAL;
        }
 
-       intr->dst_irq = devm_ti_sci_get_of_resource(intr->sci, dev,
-                                                   intr->dst_id,
-                                                   "ti,sci-rm-range-girq");
-       if (IS_ERR(intr->dst_irq)) {
+       intr->out_irqs = devm_ti_sci_get_resource(intr->sci, dev,
+                                                 intr->ti_sci_id,
+                                                 TI_SCI_RESASG_SUBTYPE_IR_OUTPUT);
+       if (IS_ERR(intr->out_irqs)) {
                dev_err(dev, "Destination irq resource allocation failed\n");
-               return PTR_ERR(intr->dst_irq);
+               return PTR_ERR(intr->out_irqs);
        }
 
        domain = irq_domain_add_hierarchy(parent_domain, 0, 0, dev_of_node(dev),
@@ -252,6 +284,8 @@ static int ti_sci_intr_irq_domain_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       dev_info(dev, "Interrupt Router %d domain created\n", intr->ti_sci_id);
+
        return 0;
 }
 
index bc235db..e460363 100644 (file)
@@ -455,7 +455,7 @@ static void __init __vic_init(void __iomem *base, int parent_irq, int irq_start,
                return;
        default:
                printk(KERN_WARNING "VIC: unknown vendor, continuing anyways\n");
-               /* fall through */
+               fallthrough;
        case AMBA_VENDOR_ARM:
                break;
        }
index 1bb0e36..d234115 100644 (file)
@@ -52,7 +52,7 @@ int platform_irqchip_probe(struct platform_device *pdev)
         * interrupt controller. The actual initialization callback of this
         * interrupt controller can check for specific domains as necessary.
         */
-       if (par_np && !irq_find_matching_host(np, DOMAIN_BUS_ANY))
+       if (par_np && !irq_find_matching_host(par_np, DOMAIN_BUS_ANY))
                return -EPROBE_DEFER;
 
        return irq_init_cb(np, par_np);
index c1c5dfa..6ae9e1f 100644 (file)
 #include <linux/irqdomain.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
-#include <linux/of_irq.h>
 #include <linux/soc/qcom/irq.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
@@ -432,8 +430,4 @@ fail:
        return ret;
 }
 
-IRQCHIP_PLATFORM_DRIVER_BEGIN(qcom_pdc)
-IRQCHIP_MATCH("qcom,pdc", qcom_pdc_init)
-IRQCHIP_PLATFORM_DRIVER_END(qcom_pdc)
-MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Power Domain Controller");
-MODULE_LICENSE("GPL v2");
+IRQCHIP_DECLARE(qcom_pdc, "qcom,pdc", qcom_pdc_init);
index ecc1ef6..f68569b 100644 (file)
@@ -348,7 +348,7 @@ modehdlc(struct bchannel *bch, int protocol)
        switch (protocol) {
        case -1: /* used for init */
                bch->state = -1;
-               /* fall through */
+               fallthrough;
        case ISDN_P_NONE:
                if (bch->state == ISDN_P_NONE)
                        break;
index b0d7723..448ded8 100644 (file)
@@ -121,7 +121,6 @@ setup_embedded(struct hfc_multi *hc, struct hm_map *m)
        case HFC_IO_MODE_EMBSD:
                test_and_set_bit(HFC_CHIP_EMBSD, &hc->chip);
                hc->slots = 128; /* required */
-               /* fall through */
                hc->HFC_outb = HFC_outb_embsd;
                hc->HFC_inb = HFC_inb_embsd;
                hc->HFC_inw = HFC_inw_embsd;
index 904a4f4..56bd2e9 100644 (file)
@@ -1280,7 +1280,7 @@ mode_hfcpci(struct bchannel *bch, int bc, int protocol)
        case (-1): /* used for init */
                bch->state = -1;
                bch->nr = bc;
-               /* fall through */
+               fallthrough;
        case (ISDN_P_NONE):
                if (bch->state == ISDN_P_NONE)
                        return 0;
index 4274906..7006199 100644 (file)
@@ -695,7 +695,7 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol)
        switch (protocol) {
        case (-1):      /* used for init */
                bch->state = -1;
-               /* fall through */
+               fallthrough;
        case (ISDN_P_NONE):
                if (bch->state == ISDN_P_NONE)
                        return 0; /* already in idle state */
index 9fea16e..985367e 100644 (file)
@@ -397,7 +397,7 @@ int isdnhdlc_encode(struct isdnhdlc_vars *hdlc, const u8 *src, u16 slen,
                                dsize--;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                case HDLC_SENDFLAG_ONE:
                        if (hdlc->bit_shift == 8) {
                                hdlc->cbin = hdlc->ffvalue >>
index f4cb297..a16c7a2 100644 (file)
@@ -875,7 +875,7 @@ release_card(struct inf_hw *card) {
                                release_card(card->sc[i]);
                        card->sc[i] = NULL;
                }
-               /* fall through */
+               fallthrough;
        default:
                pci_disable_device(card->pdev);
                pci_set_drvdata(card->pdev, NULL);
index 11e8c7d..5694340 100644 (file)
@@ -957,7 +957,7 @@ isar_pump_statev_fax(struct isar_ch *ch, u8 devt) {
                                break;
                        case PCTRL_CMD_FTM:
                                p1 = 2;
-                               /* fall through */
+                               fallthrough;
                        case PCTRL_CMD_FTH:
                                send_mbox(ch->is, dps | ISAR_HIS_PUMPCTRL,
                                          PCTRL_CMD_SILON, 1, &p1);
@@ -1163,7 +1163,7 @@ setup_pump(struct isar_ch *ch) {
                        send_mbox(ch->is, dps | ISAR_HIS_PUMPCFG,
                                  PMOD_DTMF, 1, param);
                }
-               /* fall through */
+               fallthrough;
        case ISDN_P_B_MODEM_ASYNC:
                ctrl = PMOD_DATAMODEM;
                if (test_bit(FLG_ORIGIN, &ch->bch.Flags)) {
@@ -1255,7 +1255,7 @@ setup_iom2(struct isar_ch *ch) {
        case ISDN_P_B_MODEM_ASYNC:
        case ISDN_P_B_T30_FAX:
                cmsb |= IOM_CTRL_RCV;
-               /* fall through */
+               fallthrough;
        case ISDN_P_B_L2DTMF:
                if (test_bit(FLG_DTMFSEND, &ch->bch.Flags))
                        cmsb |= IOM_CTRL_RCV;
@@ -1548,7 +1548,7 @@ isar_l2l1(struct mISDNchannel *ch, struct sk_buff *skb)
                                ich->is->name, hh->id);
                        ret = -EINVAL;
                }
-               /* fall through */
+               fallthrough;
        default:
                pr_info("%s: %s unknown prim(%x,%x)\n",
                        ich->is->name, __func__, hh->prim, hh->id);
index 27aa329..c2f76f3 100644 (file)
@@ -528,7 +528,7 @@ create_l2entity(struct mISDNdevice *dev, struct mISDNchannel *ch,
                rq.protocol = ISDN_P_NT_S0;
                if (dev->Dprotocols & (1 << ISDN_P_NT_E1))
                        rq.protocol = ISDN_P_NT_E1;
-               /* fall through */
+               fallthrough;
        case ISDN_P_LAPD_TE:
                ch->recv = mISDN_queue_message;
                ch->peer = &dev->D.st->own;
index b413baf..97c6873 100644 (file)
@@ -301,7 +301,7 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type)
        switch (type) {
        case PBLK_WRITE:
                kfree(((struct pblk_c_ctx *)nvm_rq_to_pdu(rqd))->lun_bitmap);
-               /* fall through */
+               fallthrough;
        case PBLK_WRITE_INT:
                pool = &pblk->w_rq_pool;
                break;
index 75482ee..994ba5c 100644 (file)
@@ -881,7 +881,7 @@ adbhid_input_register(int id, int default_id, int original_handler_id,
                }
                if (hid->name[0])
                        break;
-               /* else fall through */
+               fallthrough;
 
        default:
                pr_info("Trying to register unknown ADB device to input layer.\n");
index 23f1f41..9668458 100644 (file)
@@ -852,7 +852,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd)
                break;
        case SMU_I2C_TRANSFER_COMBINED:
                cmd->info.devaddr &= 0xfe;
-               /* fall through */
+               fallthrough;
        case SMU_I2C_TRANSFER_STDSUB:
                if (cmd->info.sublen > 3)
                        return -EINVAL;
index 77fbfd5..c1227bd 100644 (file)
@@ -608,7 +608,7 @@ static void do_journal_discard(struct cache *ca)
                        ca->sb.njournal_buckets;
 
                atomic_set(&ja->discard_in_flight, DISCARD_READY);
-               /* fallthrough */
+               fallthrough;
 
        case DISCARD_READY:
                if (ja->discard_idx == ja->last_idx)
index 62fb917..ae380bc 100644 (file)
@@ -33,27 +33,27 @@ int bch_ ## name ## _h(const char *cp, type *res)           \
        case 'y':                                               \
        case 'z':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 'e':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 'p':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 't':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 'g':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 'm':                                               \
                u++;                                            \
-               /* fall through */                              \
+               fallthrough;                                    \
        case 'k':                                               \
                u++;                                            \
                if (e++ == cp)                                  \
                        return -EINVAL;                         \
-               /* fall through */                              \
+               fallthrough;                                    \
        case '\n':                                              \
        case '\0':                                              \
                if (*e == '\n')                                 \
index 151aa95..af6d4f8 100644 (file)
@@ -537,12 +537,16 @@ static int __create_persistent_data_objects(struct dm_cache_metadata *cmd,
                                          CACHE_MAX_CONCURRENT_LOCKS);
        if (IS_ERR(cmd->bm)) {
                DMERR("could not create block manager");
-               return PTR_ERR(cmd->bm);
+               r = PTR_ERR(cmd->bm);
+               cmd->bm = NULL;
+               return r;
        }
 
        r = __open_or_format_metadata(cmd, may_format_device);
-       if (r)
+       if (r) {
                dm_block_manager_destroy(cmd->bm);
+               cmd->bm = NULL;
+       }
 
        return r;
 }
index 1489607..380386c 100644 (file)
@@ -739,7 +739,7 @@ static int crypt_iv_eboiv_gen(struct crypt_config *cc, u8 *iv,
        u8 buf[MAX_CIPHER_BLOCKSIZE] __aligned(__alignof__(__le64));
        struct skcipher_request *req;
        struct scatterlist src, dst;
-       struct crypto_wait wait;
+       DECLARE_CRYPTO_WAIT(wait);
        int err;
 
        req = skcipher_request_alloc(any_tfm(cc), GFP_NOIO);
@@ -936,7 +936,7 @@ static int crypt_iv_elephant(struct crypt_config *cc, struct dm_crypt_request *d
        u8 *es, *ks, *data, *data2, *data_offset;
        struct skcipher_request *req;
        struct scatterlist *sg, *sg2, src, dst;
-       struct crypto_wait wait;
+       DECLARE_CRYPTO_WAIT(wait);
        int i, r;
 
        req = skcipher_request_alloc(elephant->tfm, GFP_NOIO);
@@ -1552,7 +1552,7 @@ static blk_status_t crypt_convert(struct crypt_config *cc,
                case -EBUSY:
                        wait_for_completion(&ctx->restart);
                        reinit_completion(&ctx->restart);
-                       /* fall through */
+                       fallthrough;
                /*
                 * The request is queued and processed asynchronously,
                 * completion function kcryptd_async_done() will be called.
index 8c8d940..3fc3757 100644 (file)
@@ -2487,6 +2487,7 @@ next_chunk:
        range.logical_sector = le64_to_cpu(ic->sb->recalc_sector);
        if (unlikely(range.logical_sector >= ic->provided_data_sectors)) {
                if (ic->mode == 'B') {
+                       block_bitmap_op(ic, ic->recalc_bitmap, 0, ic->provided_data_sectors, BITMAP_OP_CLEAR);
                        DEBUG_print("queue_delayed_work: bitmap_flush_work\n");
                        queue_delayed_work(ic->commit_wq, &ic->bitmap_flush_work, 0);
                }
@@ -2564,6 +2565,17 @@ next_chunk:
                goto err;
        }
 
+       if (ic->mode == 'B') {
+               sector_t start, end;
+               start = (range.logical_sector >>
+                        (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit)) <<
+                       (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit);
+               end = ((range.logical_sector + range.n_sectors) >>
+                      (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit)) <<
+                       (ic->sb->log2_sectors_per_block + ic->log2_blocks_per_bitmap_bit);
+               block_bitmap_op(ic, ic->recalc_bitmap, start, end - start, BITMAP_OP_CLEAR);
+       }
+
 advance_and_next:
        cond_resched();
 
index 53645a6..de4da82 100644 (file)
@@ -1287,17 +1287,25 @@ static void multipath_wait_for_pg_init_completion(struct multipath *m)
 static void flush_multipath_work(struct multipath *m)
 {
        if (m->hw_handler_name) {
-               set_bit(MPATHF_PG_INIT_DISABLED, &m->flags);
-               smp_mb__after_atomic();
+               unsigned long flags;
+
+               if (!atomic_read(&m->pg_init_in_progress))
+                       goto skip;
+
+               spin_lock_irqsave(&m->lock, flags);
+               if (atomic_read(&m->pg_init_in_progress) &&
+                   !test_and_set_bit(MPATHF_PG_INIT_DISABLED, &m->flags)) {
+                       spin_unlock_irqrestore(&m->lock, flags);
 
-               if (atomic_read(&m->pg_init_in_progress))
                        flush_workqueue(kmpath_handlerd);
-               multipath_wait_for_pg_init_completion(m);
+                       multipath_wait_for_pg_init_completion(m);
 
-               clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags);
-               smp_mb__after_atomic();
+                       spin_lock_irqsave(&m->lock, flags);
+                       clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags);
+               }
+               spin_unlock_irqrestore(&m->lock, flags);
        }
-
+skip:
        if (m->queue_mode == DM_TYPE_BIO_BASED)
                flush_work(&m->process_queued_bios);
        flush_work(&m->trigger_event);
@@ -1554,7 +1562,7 @@ static void pg_init_done(void *data, int errors)
        case SCSI_DH_RETRY:
                /* Wait before retrying. */
                delay_retry = true;
-               /* fall through */
+               fallthrough;
        case SCSI_DH_IMM_RETRY:
        case SCSI_DH_RES_TEMP_UNAVAIL:
                if (pg_init_limit_reached(m, pgpath))
index 76b6b32..b461836 100644 (file)
@@ -739,12 +739,16 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool f
                                          THIN_MAX_CONCURRENT_LOCKS);
        if (IS_ERR(pmd->bm)) {
                DMERR("could not create block manager");
-               return PTR_ERR(pmd->bm);
+               r = PTR_ERR(pmd->bm);
+               pmd->bm = NULL;
+               return r;
        }
 
        r = __open_or_format_metadata(pmd, format_device);
-       if (r)
+       if (r) {
                dm_block_manager_destroy(pmd->bm);
+               pmd->bm = NULL;
+       }
 
        return r;
 }
@@ -954,7 +958,7 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
        }
 
        pmd_write_lock_in_core(pmd);
-       if (!dm_bm_is_read_only(pmd->bm) && !pmd->fail_io) {
+       if (!pmd->fail_io && !dm_bm_is_read_only(pmd->bm)) {
                r = __commit_transaction(pmd);
                if (r < 0)
                        DMWARN("%s: __commit_transaction() failed, error = %d",
index 86dbe0c..6271d1e 100644 (file)
@@ -231,6 +231,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
        pfn_t pfn;
        int id;
        struct page **pages;
+       sector_t offset;
 
        wc->memory_vmapped = false;
 
@@ -245,9 +246,16 @@ static int persistent_memory_claim(struct dm_writecache *wc)
                goto err1;
        }
 
+       offset = get_start_sect(wc->ssd_dev->bdev);
+       if (offset & (PAGE_SIZE / 512 - 1)) {
+               r = -EINVAL;
+               goto err1;
+       }
+       offset >>= PAGE_SHIFT - 9;
+
        id = dax_read_lock();
 
-       da = dax_direct_access(wc->ssd_dev->dax_dev, 0, p, &wc->memory_map, &pfn);
+       da = dax_direct_access(wc->ssd_dev->dax_dev, offset, p, &wc->memory_map, &pfn);
        if (da < 0) {
                wc->memory_map = NULL;
                r = da;
@@ -269,7 +277,7 @@ static int persistent_memory_claim(struct dm_writecache *wc)
                i = 0;
                do {
                        long daa;
-                       daa = dax_direct_access(wc->ssd_dev->dax_dev, i, p - i,
+                       daa = dax_direct_access(wc->ssd_dev->dax_dev, offset + i, p - i,
                                                NULL, &pfn);
                        if (daa <= 0) {
                                r = daa ? daa : -EINVAL;
index 32fa649..fb0255d 100644 (file)
@@ -1021,7 +1021,7 @@ static void clone_endio(struct bio *bio)
                switch (r) {
                case DM_ENDIO_REQUEUE:
                        error = BLK_STS_DM_REQUEUE;
-                       /*FALLTHRU*/
+                       fallthrough;
                case DM_ENDIO_DONE:
                        break;
                case DM_ENDIO_INCOMPLETE:
index 6bbec89..2cf9737 100644 (file)
@@ -102,10 +102,10 @@ static int __init md_setup(char *str)
                                pername = "raid0";
                        break;
                }
-               /* FALL THROUGH */
+               fallthrough;
        case 1: /* the first device is numeric */
                str = str1;
-               /* FALL THROUGH */
+               fallthrough;
        case 0:
                md_setup_args[ent].level = LEVEL_NONE;
                pername="super-block";
index d61b524..b10c519 100644 (file)
@@ -1433,7 +1433,7 @@ int md_bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long s
                case 0:
                        md_bitmap_file_set_bit(bitmap, offset);
                        md_bitmap_count_page(&bitmap->counts, offset, 1);
-                       /* fall through */
+                       fallthrough;
                case 1:
                        *bmc = 2;
                }
index 749ec26..54c089a 100644 (file)
@@ -493,7 +493,7 @@ int dm_bm_write_lock(struct dm_block_manager *bm,
        void *p;
        int r;
 
-       if (bm->read_only)
+       if (dm_bm_is_read_only(bm))
                return -EPERM;
 
        p = dm_bufio_read(bm->bufio, b, (struct dm_buffer **) result);
@@ -562,7 +562,7 @@ int dm_bm_write_lock_zero(struct dm_block_manager *bm,
        struct buffer_aux *aux;
        void *p;
 
-       if (bm->read_only)
+       if (dm_bm_is_read_only(bm))
                return -EPERM;
 
        p = dm_bufio_new(bm->bufio, b, (struct dm_buffer **) result);
@@ -602,7 +602,7 @@ EXPORT_SYMBOL_GPL(dm_bm_unlock);
 
 int dm_bm_flush(struct dm_block_manager *bm)
 {
-       if (bm->read_only)
+       if (dm_bm_is_read_only(bm))
                return -EPERM;
 
        return dm_bufio_write_dirty_buffers(bm->bufio);
@@ -616,19 +616,21 @@ void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b)
 
 bool dm_bm_is_read_only(struct dm_block_manager *bm)
 {
-       return bm->read_only;
+       return (bm ? bm->read_only : true);
 }
 EXPORT_SYMBOL_GPL(dm_bm_is_read_only);
 
 void dm_bm_set_read_only(struct dm_block_manager *bm)
 {
-       bm->read_only = true;
+       if (bm)
+               bm->read_only = true;
 }
 EXPORT_SYMBOL_GPL(dm_bm_set_read_only);
 
 void dm_bm_set_read_write(struct dm_block_manager *bm)
 {
-       bm->read_only = false;
+       if (bm)
+               bm->read_only = false;
 }
 EXPORT_SYMBOL_GPL(dm_bm_set_read_write);
 
index ef0fd48..225380e 100644 (file)
@@ -4083,7 +4083,7 @@ static void handle_parity_checks5(struct r5conf *conf, struct stripe_head *sh,
                        break;
                }
                dev = &sh->dev[s->failed_num[0]];
-               /* fall through */
+               fallthrough;
        case check_state_compute_result:
                sh->check_state = check_state_idle;
                if (!dev)
@@ -4214,7 +4214,7 @@ static void handle_parity_checks6(struct r5conf *conf, struct stripe_head *sh,
 
                /* we have 2-disk failure */
                BUG_ON(s->failed != 2);
-               /* fall through */
+               fallthrough;
        case check_state_compute_result:
                sh->check_state = check_state_idle;
 
@@ -6514,9 +6514,12 @@ raid5_store_stripe_size(struct mddev  *mddev, const char *page, size_t len)
 
        /*
         * The value should not be bigger than PAGE_SIZE. It requires to
-        * be multiple of DEFAULT_STRIPE_SIZE.
+        * be multiple of DEFAULT_STRIPE_SIZE and the value should be power
+        * of two.
         */
-       if (new % DEFAULT_STRIPE_SIZE != 0 || new > PAGE_SIZE || new == 0)
+       if (new % DEFAULT_STRIPE_SIZE != 0 ||
+                       new > PAGE_SIZE || new == 0 ||
+                       new != roundup_pow_of_two(new))
                return -EINVAL;
 
        err = mddev_lock(mddev);
index 630a75e..7607b51 100644 (file)
@@ -210,7 +210,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
                tpg->vdownsampling[1] = 1;
                tpg->hdownsampling[1] = 1;
                tpg->planes = 2;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_RGB332:
        case V4L2_PIX_FMT_RGB565:
        case V4L2_PIX_FMT_RGB565X:
@@ -271,7 +271,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_YUV420M:
        case V4L2_PIX_FMT_YVU420M:
                tpg->buffers = 3;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_YUV420:
        case V4L2_PIX_FMT_YVU420:
                tpg->vdownsampling[1] = 2;
@@ -284,7 +284,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_YUV422M:
        case V4L2_PIX_FMT_YVU422M:
                tpg->buffers = 3;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_YUV422P:
                tpg->vdownsampling[1] = 1;
                tpg->vdownsampling[2] = 1;
@@ -296,7 +296,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_NV16M:
        case V4L2_PIX_FMT_NV61M:
                tpg->buffers = 2;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_NV16:
        case V4L2_PIX_FMT_NV61:
                tpg->vdownsampling[1] = 1;
@@ -308,7 +308,7 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
        case V4L2_PIX_FMT_NV12M:
        case V4L2_PIX_FMT_NV21M:
                tpg->buffers = 2;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
                tpg->vdownsampling[1] = 2;
@@ -1275,7 +1275,7 @@ static void gen_twopix(struct tpg_data *tpg,
        case V4L2_PIX_FMT_RGB444:
        case V4L2_PIX_FMT_XRGB444:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_YUV444:
        case V4L2_PIX_FMT_ARGB444:
                buf[0][offset] = (g_u_s << 4) | b_v;
@@ -1283,21 +1283,21 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_RGBX444:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_RGBA444:
                buf[0][offset] = (b_v << 4) | (alpha >> 4);
                buf[0][offset + 1] = (r_y_h << 4) | g_u_s;
                break;
        case V4L2_PIX_FMT_XBGR444:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_ABGR444:
                buf[0][offset] = (g_u_s << 4) | r_y_h;
                buf[0][offset + 1] = (alpha & 0xf0) | b_v;
                break;
        case V4L2_PIX_FMT_BGRX444:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_BGRA444:
                buf[0][offset] = (r_y_h << 4) | (alpha >> 4);
                buf[0][offset + 1] = (b_v << 4) | g_u_s;
@@ -1305,7 +1305,7 @@ static void gen_twopix(struct tpg_data *tpg,
        case V4L2_PIX_FMT_RGB555:
        case V4L2_PIX_FMT_XRGB555:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_YUV555:
        case V4L2_PIX_FMT_ARGB555:
                buf[0][offset] = (g_u_s << 5) | b_v;
@@ -1314,7 +1314,7 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_RGBX555:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_RGBA555:
                buf[0][offset] = (g_u_s << 6) | (b_v << 1) |
                                 ((alpha & 0x80) >> 7);
@@ -1322,7 +1322,7 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_XBGR555:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_ABGR555:
                buf[0][offset] = (g_u_s << 5) | r_y_h;
                buf[0][offset + 1] = (alpha & 0x80) | (b_v << 2)
@@ -1330,7 +1330,7 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_BGRX555:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_BGRA555:
                buf[0][offset] = (g_u_s << 6) | (r_y_h << 1) |
                                 ((alpha & 0x80) >> 7);
@@ -1339,7 +1339,7 @@ static void gen_twopix(struct tpg_data *tpg,
        case V4L2_PIX_FMT_RGB555X:
        case V4L2_PIX_FMT_XRGB555X:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_ARGB555X:
                buf[0][offset] = (alpha & 0x80) | (r_y_h << 2) | (g_u_s >> 3);
                buf[0][offset + 1] = (g_u_s << 5) | b_v;
@@ -1366,7 +1366,7 @@ static void gen_twopix(struct tpg_data *tpg,
        case V4L2_PIX_FMT_HSV32:
        case V4L2_PIX_FMT_XYUV32:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_YUV32:
        case V4L2_PIX_FMT_ARGB32:
        case V4L2_PIX_FMT_AYUV32:
@@ -1377,7 +1377,7 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_RGBX32:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_RGBA32:
                buf[0][offset] = r_y_h;
                buf[0][offset + 1] = g_u_s;
@@ -1388,7 +1388,7 @@ static void gen_twopix(struct tpg_data *tpg,
        case V4L2_PIX_FMT_XBGR32:
        case V4L2_PIX_FMT_VUYX32:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_ABGR32:
        case V4L2_PIX_FMT_VUYA32:
                buf[0][offset] = b_v;
@@ -1398,7 +1398,7 @@ static void gen_twopix(struct tpg_data *tpg,
                break;
        case V4L2_PIX_FMT_BGRX32:
                alpha = 0;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_BGRA32:
                buf[0][offset] = alpha;
                buf[0][offset + 1] = b_v;
index 630509e..89620da 100644 (file)
@@ -546,7 +546,7 @@ static int dvb_net_ule_new_payload(struct dvb_net_ule_handle *h)
                h->priv->ule_sndu_type_1 = 1;
                h->ts_remain -= 1;
                h->from_where += 1;
-               /* fallthrough */
+               fallthrough;
        case 0:
                h->new_ts = 1;
                h->ts += TS_SZ;
index e92542b..da0ff7b 100644 (file)
@@ -773,7 +773,7 @@ static int bcm3510_init(struct dvb_frontend* fe)
                        deb_info("attempting to download firmware\n");
                        if ((ret = bcm3510_init_cold(st)) < 0)
                                return ret;
-                       /* fall-through */
+                       fallthrough;
                case JDEC_EEPROM_LOAD_WAIT:
                        deb_info("firmware is loaded\n");
                        bcm3510_check_firmware_version(st);
index bc37475..08a8583 100644 (file)
@@ -1693,7 +1693,7 @@ static int dib0090_dc_offset_calibration(struct dib0090_state *state, enum front
                if (state->identity.p1g)
                        state->dc = dc_p1g_table;
 
-               /* fall through */
+               fallthrough;
        case CT_TUNER_STEP_0:
                dprintk("Start/continue DC calibration for %s path\n",
                        (state->dc->i == 1) ? "I" : "Q");
index 0f0480d..a6c2fc4 100644 (file)
@@ -224,7 +224,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
        switch (c->hierarchy) {
                case HIERARCHY_NONE:
                        deb_setf("hierarchy: none\n");
-                       /* fall through */
+                       fallthrough;
                case HIERARCHY_1:
                        deb_setf("hierarchy: alpha=1\n");
                        wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1);
index 0a7790c..55bee50 100644 (file)
@@ -276,7 +276,7 @@ static int dib7000p_set_power_mode(struct dib7000p_state *state, enum dib7000p_p
                if (state->version != SOC7090)
                        reg_1280 &= ~((1 << 11));
                reg_1280 &= ~(1 << 6);
-               /* fall-through */
+               fallthrough;
        case DIB7000P_POWER_INTERFACE_ONLY:
                /* just leave power on the control-interfaces: GPIO and (I2C or SDIO) */
                /* TODO power up either SDIO or I2C */
index 5de0164..237b9d0 100644 (file)
@@ -2306,7 +2306,7 @@ hi_command(struct i2c_device_addr *dev_addr, const struct drxj_hi_cmd *cmd, u16
                        pr_err("error %d\n", rc);
                        goto rw_error;
                }
-               /* fallthrough */
+               fallthrough;
        case SIO_HI_RA_RAM_CMD_BRDCTRL:
                rc = drxj_dap_write_reg16(dev_addr, SIO_HI_RA_RAM_PAR_2__A, cmd->param2, 0);
                if (rc != 0) {
@@ -2318,7 +2318,7 @@ hi_command(struct i2c_device_addr *dev_addr, const struct drxj_hi_cmd *cmd, u16
                        pr_err("error %d\n", rc);
                        goto rw_error;
                }
-               /* fallthrough */
+               fallthrough;
        case SIO_HI_RA_RAM_CMD_NULL:
                /* No parameters */
                break;
@@ -2841,7 +2841,7 @@ ctrl_set_cfg_mpeg_output(struct drx_demod_instance *demod, struct drx_cfg_mpeg_o
                        /* coef = 188/204                          */
                        max_bit_rate =
                            (ext_attr->curr_symbol_rate / 8) * nr_bits * 188;
-                       /* fall-through - as b/c Annex A/C need following settings */
+                       fallthrough;    /* as b/c Annex A/C need following settings */
                case DRX_STANDARD_ITU_B:
                        rc = drxj_dap_write_reg16(dev_addr, FEC_OC_FCT_USAGE__A, FEC_OC_FCT_USAGE__PRE, 0);
                        if (rc != 0) {
@@ -3555,8 +3555,8 @@ static int ctrl_set_uio_cfg(struct drx_demod_instance *demod, struct drxuio_cfg
                if (!ext_attr->has_smatx)
                        return -EIO;
                switch (uio_cfg->mode) {
-               case DRX_UIO_MODE_FIRMWARE_SMA: /* fall through */
-               case DRX_UIO_MODE_FIRMWARE_SAW: /* fall through */
+               case DRX_UIO_MODE_FIRMWARE_SMA:
+               case DRX_UIO_MODE_FIRMWARE_SAW:
                case DRX_UIO_MODE_READWRITE:
                        ext_attr->uio_sma_tx_mode = uio_cfg->mode;
                        break;
@@ -3579,7 +3579,7 @@ static int ctrl_set_uio_cfg(struct drx_demod_instance *demod, struct drxuio_cfg
                if (!ext_attr->has_smarx)
                        return -EIO;
                switch (uio_cfg->mode) {
-               case DRX_UIO_MODE_FIRMWARE0:    /* fall through */
+               case DRX_UIO_MODE_FIRMWARE0:
                case DRX_UIO_MODE_READWRITE:
                        ext_attr->uio_sma_rx_mode = uio_cfg->mode;
                        break;
@@ -3603,7 +3603,7 @@ static int ctrl_set_uio_cfg(struct drx_demod_instance *demod, struct drxuio_cfg
                if (!ext_attr->has_gpio)
                        return -EIO;
                switch (uio_cfg->mode) {
-               case DRX_UIO_MODE_FIRMWARE0:    /* fall through */
+               case DRX_UIO_MODE_FIRMWARE0:
                case DRX_UIO_MODE_READWRITE:
                        ext_attr->uio_gpio_mode = uio_cfg->mode;
                        break;
@@ -3639,7 +3639,7 @@ static int ctrl_set_uio_cfg(struct drx_demod_instance *demod, struct drxuio_cfg
                        }
                        ext_attr->uio_irqn_mode = uio_cfg->mode;
                        break;
-               case DRX_UIO_MODE_FIRMWARE0:    /* fall through */
+               case DRX_UIO_MODE_FIRMWARE0:
                default:
                        return -EINVAL;
                        break;
@@ -4004,31 +4004,36 @@ static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd
                if (rc != 0) {
                        pr_err("error %d\n", rc);
                        goto rw_error;
-               }       /* fallthrough */
+               }
+               fallthrough;
        case 4:
                rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_3__A, *(cmd->parameter + 3), 0);
                if (rc != 0) {
                        pr_err("error %d\n", rc);
                        goto rw_error;
-               }       /* fallthrough */
+               }
+               fallthrough;
        case 3:
                rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_2__A, *(cmd->parameter + 2), 0);
                if (rc != 0) {
                        pr_err("error %d\n", rc);
                        goto rw_error;
-               }       /* fallthrough */
+               }
+               fallthrough;
        case 2:
                rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_1__A, *(cmd->parameter + 1), 0);
                if (rc != 0) {
                        pr_err("error %d\n", rc);
                        goto rw_error;
-               }       /* fallthrough */
+               }
+               fallthrough;
        case 1:
                rc = drxj_dap_write_reg16(dev_addr, SCU_RAM_PARAM_0__A, *(cmd->parameter + 0), 0);
                if (rc != 0) {
                        pr_err("error %d\n", rc);
                        goto rw_error;
-               }       /* fallthrough */
+               }
+               fallthrough;
        case 0:
                /* do nothing */
                break;
@@ -4068,25 +4073,29 @@ static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd
                        if (rc != 0) {
                                pr_err("error %d\n", rc);
                                goto rw_error;
-                       }       /* fallthrough */
+                       }
+                       fallthrough;
                case 3:
                        rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_2__A, cmd->result + 2, 0);
                        if (rc != 0) {
                                pr_err("error %d\n", rc);
                                goto rw_error;
-                       }       /* fallthrough */
+                       }
+                       fallthrough;
                case 2:
                        rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_1__A, cmd->result + 1, 0);
                        if (rc != 0) {
                                pr_err("error %d\n", rc);
                                goto rw_error;
-                       }       /* fallthrough */
+                       }
+                       fallthrough;
                case 1:
                        rc = drxj_dap_read_reg16(dev_addr, SCU_RAM_PARAM_0__A, cmd->result + 0, 0);
                        if (rc != 0) {
                                pr_err("error %d\n", rc);
                                goto rw_error;
-                       }       /* fallthrough */
+                       }
+                       fallthrough;
                case 0:
                        /* do nothing */
                        break;
@@ -4791,7 +4800,7 @@ set_frequency(struct drx_demod_instance *demod,
                   Sound carrier is already 3Mhz above centre frequency due
                   to tuner setting so now add an extra shift of 1MHz... */
                fm_frequency_shift = 1000;
-               /*fall through */
+               fallthrough;
        case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_NTSC:
        case DRX_STANDARD_PAL_SECAM_BG:
@@ -10475,11 +10484,11 @@ ctrl_set_channel(struct drx_demod_instance *demod, struct drx_channel *channel)
            (standard == DRX_STANDARD_NTSC)) {
                switch (channel->bandwidth) {
                case DRX_BANDWIDTH_6MHZ:
-               case DRX_BANDWIDTH_UNKNOWN:     /* fall through */
+               case DRX_BANDWIDTH_UNKNOWN:
                        channel->bandwidth = DRX_BANDWIDTH_6MHZ;
                        break;
-               case DRX_BANDWIDTH_8MHZ:        /* fall through */
-               case DRX_BANDWIDTH_7MHZ:        /* fall through */
+               case DRX_BANDWIDTH_8MHZ:
+               case DRX_BANDWIDTH_7MHZ:
                default:
                        return -EINVAL;
                }
@@ -10511,10 +10520,10 @@ ctrl_set_channel(struct drx_demod_instance *demod, struct drx_channel *channel)
                }
 
                switch (channel->constellation) {
-               case DRX_CONSTELLATION_QAM16:   /* fall through */
-               case DRX_CONSTELLATION_QAM32:   /* fall through */
-               case DRX_CONSTELLATION_QAM64:   /* fall through */
-               case DRX_CONSTELLATION_QAM128:  /* fall through */
+               case DRX_CONSTELLATION_QAM16:
+               case DRX_CONSTELLATION_QAM32:
+               case DRX_CONSTELLATION_QAM64:
+               case DRX_CONSTELLATION_QAM128:
                case DRX_CONSTELLATION_QAM256:
                        bandwidth_temp = channel->symbolrate * bw_rolloff_factor;
                        bandwidth = bandwidth_temp / 100;
@@ -10628,8 +10637,8 @@ ctrl_set_channel(struct drx_demod_instance *demod, struct drx_channel *channel)
                }
                break;
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
                rc = set_qam_channel(demod, channel, tuner_freq_offset);
                if (rc != 0) {
@@ -10820,7 +10829,7 @@ ctrl_lock_status(struct drx_demod_instance *demod, enum drx_lock_status *lock_st
                    SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK;
                break;
 #endif
-       case DRX_STANDARD_UNKNOWN:      /* fallthrough */
+       case DRX_STANDARD_UNKNOWN:
        default:
                return -EIO;
        }
@@ -10888,8 +10897,8 @@ ctrl_set_standard(struct drx_demod_instance *demod, enum drx_standard *standard)
         */
        switch (prev_standard) {
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
                rc = power_down_qam(demod, false);
                if (rc != 0) {
@@ -10908,7 +10917,7 @@ ctrl_set_standard(struct drx_demod_instance *demod, enum drx_standard *standard)
        case DRX_STANDARD_UNKNOWN:
                /* Do nothing */
                break;
-       case DRX_STANDARD_AUTO: /* fallthrough */
+       case DRX_STANDARD_AUTO:
        default:
                return -EINVAL;
        }
@@ -10921,8 +10930,8 @@ ctrl_set_standard(struct drx_demod_instance *demod, enum drx_standard *standard)
 
        switch (*standard) {
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
                do {
                        u16 dummy;
@@ -11111,12 +11120,12 @@ ctrl_power_mode(struct drx_demod_instance *demod, enum drx_power_mode *mode)
                                goto rw_error;
                        }
                        break;
-               case DRX_STANDARD_PAL_SECAM_BG: /* fallthrough */
-               case DRX_STANDARD_PAL_SECAM_DK: /* fallthrough */
-               case DRX_STANDARD_PAL_SECAM_I:  /* fallthrough */
-               case DRX_STANDARD_PAL_SECAM_L:  /* fallthrough */
-               case DRX_STANDARD_PAL_SECAM_LP: /* fallthrough */
-               case DRX_STANDARD_NTSC: /* fallthrough */
+               case DRX_STANDARD_PAL_SECAM_BG:
+               case DRX_STANDARD_PAL_SECAM_DK:
+               case DRX_STANDARD_PAL_SECAM_I:
+               case DRX_STANDARD_PAL_SECAM_L:
+               case DRX_STANDARD_PAL_SECAM_LP:
+               case DRX_STANDARD_NTSC:
                case DRX_STANDARD_FM:
                        rc = power_down_atv(demod, ext_attr->standard, true);
                        if (rc != 0) {
@@ -11127,7 +11136,7 @@ ctrl_power_mode(struct drx_demod_instance *demod, enum drx_power_mode *mode)
                case DRX_STANDARD_UNKNOWN:
                        /* Do nothing */
                        break;
-               case DRX_STANDARD_AUTO: /* fallthrough */
+               case DRX_STANDARD_AUTO:
                default:
                        return -EIO;
                }
@@ -11220,8 +11229,8 @@ ctrl_set_cfg_pre_saw(struct drx_demod_instance *demod, struct drxj_cfg_pre_saw *
                ext_attr->vsb_pre_saw_cfg = *pre_saw;
                break;
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
                ext_attr->qam_pre_saw_cfg = *pre_saw;
                break;
@@ -11264,10 +11273,10 @@ ctrl_set_cfg_afe_gain(struct drx_demod_instance *demod, struct drxj_cfg_afe_gain
        ext_attr = (struct drxj_data *) demod->my_ext_attr;
 
        switch (afe_gain->standard) {
-       case DRX_STANDARD_8VSB: /* fallthrough */
+       case DRX_STANDARD_8VSB: fallthrough;
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
 #endif
                /* Do nothing */
@@ -11301,8 +11310,8 @@ ctrl_set_cfg_afe_gain(struct drx_demod_instance *demod, struct drxj_cfg_afe_gain
                ext_attr->vsb_pga_cfg = gain * 13 + 140;
                break;
 #ifndef DRXJ_VSB_ONLY
-       case DRX_STANDARD_ITU_A:        /* fallthrough */
-       case DRX_STANDARD_ITU_B:        /* fallthrough */
+       case DRX_STANDARD_ITU_A:
+       case DRX_STANDARD_ITU_B:
        case DRX_STANDARD_ITU_C:
                ext_attr->qam_pga_cfg = gain * 13 + 140;
                break;
index fae6f37..45f9828 100644 (file)
@@ -1512,14 +1512,14 @@ static int SetDeviceTypeId(struct drxd_state *state)
                        switch (deviceId) {
                        case 4:
                                state->diversity = 1;
-                               /* fall through */
+                               fallthrough;
                        case 3:
                        case 7:
                                state->PGA = 1;
                                break;
                        case 6:
                                state->diversity = 1;
-                               /* fall through */
+                               fallthrough;
                        case 5:
                        case 8:
                                break;
@@ -1966,7 +1966,7 @@ static int DRX_Start(struct drxd_state *state, s32 off)
                switch (p->transmission_mode) {
                default:        /* Not set, detect it automatically */
                        operationMode |= SC_RA_RAM_OP_AUTO_MODE__M;
-                       /* fall through - try first guess DRX_FFTMODE_8K */
+                       fallthrough;    /* try first guess DRX_FFTMODE_8K */
                case TRANSMISSION_MODE_8K:
                        transmissionParams |= SC_RA_RAM_OP_PARAM_MODE_8K;
                        if (state->type_A) {
@@ -2139,7 +2139,7 @@ static int DRX_Start(struct drxd_state *state, s32 off)
                switch (p->modulation) {
                default:
                        operationMode |= SC_RA_RAM_OP_AUTO_CONST__M;
-                       /* fall through - try first guess DRX_CONSTELLATION_QAM64 */
+                       fallthrough;    /* try first guess DRX_CONSTELLATION_QAM64 */
                case QAM_64:
                        transmissionParams |= SC_RA_RAM_OP_PARAM_CONST_QAM64;
                        if (state->type_A) {
@@ -2266,7 +2266,7 @@ static int DRX_Start(struct drxd_state *state, s32 off)
                        break;
                default:
                        operationMode |= SC_RA_RAM_OP_AUTO_RATE__M;
-                       /* fall through */
+                       fallthrough;
                case FEC_2_3:
                        transmissionParams |= SC_RA_RAM_OP_PARAM_RATE_2_3;
                        if (state->type_A)
@@ -2301,7 +2301,7 @@ static int DRX_Start(struct drxd_state *state, s32 off)
                switch (p->bandwidth_hz) {
                case 0:
                        p->bandwidth_hz = 8000000;
-                       /* fall through */
+                       fallthrough;
                case 8000000:
                        /* (64/7)*(8/8)*1000000 */
                        bandwidth = DRXD_BANDWIDTH_8MHZ_IN_HZ;
index 0ae9d8c..32f9346 100644 (file)
@@ -1756,7 +1756,7 @@ static int setoperation_mode(struct drxk_state *state,
                        goto error;
                state->m_operation_mode = OM_NONE;
                break;
-       case OM_QAM_ITU_A:      /* fallthrough */
+       case OM_QAM_ITU_A:
        case OM_QAM_ITU_C:
                status = mpegts_stop(state);
                if (status < 0)
@@ -1783,7 +1783,7 @@ static int setoperation_mode(struct drxk_state *state,
                if (status < 0)
                        goto error;
                break;
-       case OM_QAM_ITU_A:      /* fallthrough */
+       case OM_QAM_ITU_A:
        case OM_QAM_ITU_C:
                dprintk(1, ": DVB-C Annex %c\n",
                        (state->m_operation_mode == OM_QAM_ITU_A) ? 'A' : 'C');
@@ -2012,7 +2012,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
                fec_oc_rcn_ctl_rate = 0xC00000;
                static_clk = state->m_dvbt_static_clk;
                break;
-       case OM_QAM_ITU_A:      /* fallthrough */
+       case OM_QAM_ITU_A:
        case OM_QAM_ITU_C:
                fec_oc_tmd_mode = 0x0004;
                fec_oc_rcn_ctl_rate = 0xD2B4EE; /* good for >63 Mb/s */
@@ -3249,11 +3249,11 @@ static int dvbt_sc_command(struct drxk_state *state,
        case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM:
        case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM:
                status |= write16(state, OFDM_SC_RA_RAM_PARAM1__A, param1);
-               /* fall through - All commands using 1 parameters */
+               fallthrough;    /* All commands using 1 parameters */
        case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING:
        case OFDM_SC_RA_RAM_CMD_USER_IO:
                status |= write16(state, OFDM_SC_RA_RAM_PARAM0__A, param0);
-               /* fall through - All commands using 0 parameters */
+               fallthrough;    /* All commands using 0 parameters */
        case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM:
        case OFDM_SC_RA_RAM_CMD_NULL:
                /* Write command */
@@ -3761,7 +3761,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
        case TRANSMISSION_MODE_AUTO:
        default:
                operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_MODE__M;
-               /* fall through - try first guess DRX_FFTMODE_8K */
+               fallthrough;    /* try first guess DRX_FFTMODE_8K */
        case TRANSMISSION_MODE_8K:
                transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_MODE_8K;
                break;
@@ -3775,7 +3775,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
        default:
        case GUARD_INTERVAL_AUTO:
                operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_GUARD__M;
-               /* fall through - try first guess DRX_GUARD_1DIV4 */
+               fallthrough;    /* try first guess DRX_GUARD_1DIV4 */
        case GUARD_INTERVAL_1_4:
                transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_GUARD_4;
                break;
@@ -3798,7 +3798,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
                operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_HIER__M;
                /* try first guess SC_RA_RAM_OP_PARAM_HIER_NO */
                /* transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_NO; */
-               /* fall through */
+               fallthrough;
        case HIERARCHY_1:
                transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_A1;
                break;
@@ -3816,7 +3816,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
        case QAM_AUTO:
        default:
                operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_CONST__M;
-               /* fall through - try first guess DRX_CONSTELLATION_QAM64 */
+               fallthrough;    /* try first guess DRX_CONSTELLATION_QAM64 */
        case QAM_64:
                transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM64;
                break;
@@ -3841,7 +3841,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
                WR16(dev_addr, OFDM_EC_SB_PRIOR__A,
                        OFDM_EC_SB_PRIOR_HI));
                break;
-       case DRX_PRIORITY_UNKNOWN:      /* fall through */
+       case DRX_PRIORITY_UNKNOWN:
        default:
                status = -EINVAL;
                goto error;
@@ -3859,7 +3859,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
        case FEC_AUTO:
        default:
                operation_mode |= OFDM_SC_RA_RAM_OP_AUTO_RATE__M;
-               /* fall through - try first guess DRX_CODERATE_2DIV3 */
+               fallthrough;    /* try first guess DRX_CODERATE_2DIV3 */
        case FEC_2_3:
                transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_RATE_2_3;
                break;
@@ -3893,7 +3893,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
        switch (state->props.bandwidth_hz) {
        case 0:
                state->props.bandwidth_hz = 8000000;
-               /* fall through */
+               fallthrough;
        case 8000000:
                bandwidth = DRXK_BANDWIDTH_8MHZ_IN_HZ;
                status = write16(state, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A,
index d3c330e..722576f 100644 (file)
@@ -768,7 +768,7 @@ static int lgdt3306a_set_if(struct lgdt3306a_state *state,
        default:
                pr_warn("IF=%d KHz is not supported, 3250 assumed\n",
                        if_freq_khz);
-               /* fallthrough */
+               fallthrough;
        case 3250: /* 3.25Mhz */
                nco1 = 0x34;
                nco2 = 0x00;
index 8818975..399d5c5 100644 (file)
@@ -201,7 +201,7 @@ static int mt352_set_parameters(struct dvb_frontend *fe)
                        if (op->hierarchy == HIERARCHY_AUTO ||
                            op->hierarchy == HIERARCHY_NONE)
                                break;
-                       /* fall through */
+                       fallthrough;
                default:
                        return -EINVAL;
        }
index 290b9ea..4404ace 100644 (file)
@@ -739,7 +739,7 @@ static int get_frontend(struct dvb_frontend *fe,
                default:
                        break;
                }
-               /* Fall through */
+               fallthrough;
        case SYS_DVBS:
                switch ((enum MXL_HYDRA_MODULATION_E)
                        reg_data[DMD_MODULATION_SCHEME_ADDR]) {
index 35a3e47..24de1b1 100644 (file)
@@ -482,7 +482,7 @@ start:
        switch (reg&0xff) {
        case 0x06:
                if (reg & 0x1000) usK = 3 << 24;
-               /* fall through */
+               fallthrough;
        case 0x43: /* QAM64 */
                c = 150204167;
                break;
index 8940291..c1334d7 100644 (file)
@@ -398,7 +398,7 @@ static int s5h1411_set_if_freq(struct dvb_frontend *fe, int KHz)
        default:
                dprintk("%s(%d KHz) Invalid, defaulting to 5380\n",
                        __func__, KHz);
-               /* fall through */
+               fallthrough;
        case 5380:
        case 44000:
                s5h1411_writereg(state, S5H1411_I2C_TOP_ADDR, 0x38, 0x1be4);
index 2fc6aea..2a2cf20 100644 (file)
@@ -201,7 +201,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe)
                break;
        default:
                c->bandwidth_hz = 8000000;
-               /* fall through */
+               fallthrough;
        case 8000000:
                zl10353_single_write(fe, MCLK_RATIO, 0x75);
                zl10353_single_write(fe, 0x64, 0x36);
@@ -258,7 +258,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe)
                if (c->hierarchy == HIERARCHY_AUTO ||
                    c->hierarchy == HIERARCHY_NONE)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                return -EINVAL;
        }
index 48ae60a..c7ba76f 100644 (file)
@@ -467,7 +467,7 @@ config VIDEO_VPX3220
 config VIDEO_MAX9286
        tristate "Maxim MAX9286 GMSL deserializer support"
        depends on I2C && I2C_MUX
-       depends on OF
+       depends on OF_GPIO
        select V4L2_FWNODE
        select VIDEO_V4L2_SUBDEV_API
        select MEDIA_CONTROLLER
@@ -741,7 +741,7 @@ config VIDEO_HI556
 config VIDEO_IMX214
        tristate "Sony IMX214 sensor support"
        depends on GPIOLIB && I2C && VIDEO_V4L2
-       depends on V4L2_FWNODE
+       select V4L2_FWNODE
        select MEDIA_CONTROLLER
        select VIDEO_V4L2_SUBDEV_API
        select REGMAP_I2C
index 570a4a0..03eee60 100644 (file)
@@ -2209,7 +2209,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
                ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
                ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
                ts2->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
-               /* fall-through */
+               fallthrough;
        case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
                ts1->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
                ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
@@ -2370,7 +2370,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
                /* Currently only enabled for the integrated IR controller */
                if (!enable_885_ir)
                        break;
-               /* fall-through */
+               fallthrough;
        case CX23885_BOARD_HAUPPAUGE_HVR1250:
        case CX23885_BOARD_HAUPPAUGE_HVR1800:
        case CX23885_BOARD_HAUPPAUGE_IMPACTVCBE:
index 7cabb9e..92fe051 100644 (file)
@@ -1310,7 +1310,7 @@ static void dvb_input_detach(struct ddb_input *input)
                        dvb_unregister_frontend(dvb->fe2);
                if (dvb->fe)
                        dvb_unregister_frontend(dvb->fe);
-               /* fallthrough */
+               fallthrough;
        case 0x30:
                dvb_module_release(dvb->i2c_client[0]);
                dvb->i2c_client[0] = NULL;
@@ -1321,22 +1321,22 @@ static void dvb_input_detach(struct ddb_input *input)
                        dvb_frontend_detach(dvb->fe);
                dvb->fe = NULL;
                dvb->fe2 = NULL;
-               /* fallthrough */
+               fallthrough;
        case 0x20:
                dvb_net_release(&dvb->dvbnet);
-               /* fallthrough */
+               fallthrough;
        case 0x12:
                dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
                                              &dvb->hw_frontend);
                dvbdemux->dmx.remove_frontend(&dvbdemux->dmx,
                                              &dvb->mem_frontend);
-               /* fallthrough */
+               fallthrough;
        case 0x11:
                dvb_dmxdev_release(&dvb->dmxdev);
-               /* fallthrough */
+               fallthrough;
        case 0x10:
                dvb_dmx_release(&dvb->demux);
-               /* fallthrough */
+               fallthrough;
        case 0x01:
                break;
        }
@@ -1559,7 +1559,7 @@ static int dvb_input_attach(struct ddb_input *input)
                        osc24 = 0;
                else
                        osc24 = 1;
-               /* fall-through */
+               fallthrough;
        case DDB_TUNER_DVBCT2_SONY_P:
        case DDB_TUNER_DVBC2T2_SONY_P:
        case DDB_TUNER_ISDBT_SONY_P:
@@ -1575,7 +1575,7 @@ static int dvb_input_attach(struct ddb_input *input)
                break;
        case DDB_TUNER_DVBC2T2I_SONY:
                osc24 = 1;
-               /* fall-through */
+               fallthrough;
        case DDB_TUNER_DVBCT2_SONY:
        case DDB_TUNER_DVBC2T2_SONY:
        case DDB_TUNER_ISDBT_SONY:
@@ -2036,7 +2036,7 @@ static int ddb_port_attach(struct ddb_port *port)
                ret = ddb_ci_attach(port, ci_bitrate);
                if (ret < 0)
                        break;
-               /* fall-through */
+               fallthrough;
        case DDB_PORT_LOOP:
                ret = dvb_register_device(port->dvb[0].adap,
                                          &port->dvb[0].dev,
@@ -2432,7 +2432,8 @@ void ddb_ports_init(struct ddb *dev)
                                        ddb_input_init(port, 4 + i, 1, 4 + i);
                                        ddb_output_init(port, i);
                                        break;
-                               } /* fallthrough */
+                               }
+                               fallthrough;
                        case DDB_OCTOPUS:
                                ddb_input_init(port, 2 * i, 0, 2 * i);
                                ddb_input_init(port, 2 * i + 1, 1, 2 * i + 1);
@@ -3417,7 +3418,7 @@ int ddb_exit_ddbridge(int stage, int error)
        default:
        case 2:
                destroy_workqueue(ddb_wq);
-               /* fall-through */
+               fallthrough;
        case 1:
                ddb_class_destroy();
                break;
index 7fb3b18..8944e4b 100644 (file)
@@ -952,7 +952,7 @@ static int meyeioc_sync(struct file *file, void *fh, int *i)
                        mutex_unlock(&meye.lock);
                        return -EINTR;
                }
-               /* fall through */
+               fallthrough;
        case MEYE_BUF_DONE:
                meye.grab_buffer[*i].state = MEYE_BUF_UNUSED;
                if (kfifo_out_locked(&meye.doneq, (unsigned char *)&unused,
index bf36b1e..45228f4 100644 (file)
@@ -637,7 +637,7 @@ static void gpioirq(unsigned long cookie)
                        iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case DATA_TS_RECORD:
        case DATA_PES_RECORD:
@@ -2176,7 +2176,7 @@ static int frontend_init(struct av7110 *av7110)
                                break;
                        }
                }
-               /* fall-thru */
+                       fallthrough;
 
                case 0x0008: // Hauppauge/TT DVB-T
                        // Grundig 29504-401
index e8a8ec5..93ca31e 100644 (file)
@@ -1107,7 +1107,7 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
                break;
        case OSD_SetRow:
                dc->y1 = dc->y0;
-               /* fall through */
+               fallthrough;
        case OSD_SetBlock:
                ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
                break;
index ec528fa..30330ed 100644 (file)
@@ -182,7 +182,7 @@ int av7110_ipack_instant_repack (const u8 *buf, int count, struct ipack *p)
                        case DSM_CC_STREAM  :
                        case ISO13522_STREAM:
                                p->done = 1;
-                               /* fall through */
+                               fallthrough;
                        case PRIVATE_STREAM1:
                        case VIDEO_STREAM_S ... VIDEO_STREAM_E:
                        case AUDIO_STREAM_S ... AUDIO_STREAM_E:
index 38cac50..3cb8300 100644 (file)
@@ -1226,7 +1226,7 @@ static void frontend_init(struct budget_av *budget_av)
                 * but so far it has been only confirmed for this type
                 */
                budget_av->reinitialise_demod = 1;
-               /* fall through */
+               fallthrough;
        case SUBID_DVBS_KNC1_PLUS:
        case SUBID_DVBS_EASYWATCH_1:
                if (saa->pci->subsystem_vendor == 0x1894) {
index 9c81127..a88711a 100644 (file)
@@ -613,7 +613,7 @@ static void frontend_init(struct budget *budget)
                        break;
                }
        }
-       /* fall through */
+               fallthrough;
        case 0x1018: // TT Budget-S-1401 (philips tda10086/philips tda8262)
        {
                struct dvb_frontend *fe;
@@ -638,7 +638,7 @@ static void frontend_init(struct budget *budget)
                        break;
                }
        }
-       /* fall through */
+               fallthrough;
 
        case 0x101c: { /* TT S2-1600 */
                        const struct stv6110x_devctl *ctl;
index 36e5f2f..b22dc1d 100644 (file)
@@ -220,7 +220,7 @@ static void sh_vou_stream_config(struct sh_vou_device *vou_dev)
                break;
        case V4L2_PIX_FMT_RGB565:
                dataswap ^= 1;
-               /* fall through */
+               fallthrough;
        case V4L2_PIX_FMT_RGB565X:
                row_coeff = 2;
                break;
@@ -802,7 +802,7 @@ static u32 sh_vou_ntsc_mode(enum sh_vou_bus_fmt bus_fmt)
        default:
                pr_warn("%s(): Invalid bus-format code %d, using default 8-bit\n",
                        __func__, bus_fmt);
-               /* fall through */
+               fallthrough;
        case SH_VOU_BUS_8BIT:
                return 1;
        case SH_VOU_BUS_16BIT:
index e496083..4123405 100644 (file)
@@ -226,7 +226,7 @@ static inline void cal_write_field(struct cal_dev *cal, u32 offset, u32 value,
        u32 val = cal_read(cal, offset);
 
        val &= ~mask;
-       val |= FIELD_PREP(mask, value);
+       val |= (value << __ffs(mask)) & mask;
        cal_write(cal, offset, val);
 }
 
index b203296..7e24602 100644 (file)
@@ -105,7 +105,8 @@ static inline enum phase_diversity_modes_idx
 si476x_phase_diversity_mode_to_idx(enum si476x_phase_diversity_mode mode)
 {
        switch (mode) {
-       default:                /* FALLTHROUGH */
+       default:
+               fallthrough;
        case SI476X_PHDIV_DISABLED:
                return SI476X_IDX_PHDIV_DISABLED;
        case SI476X_PHDIV_PRIMARY_COMBINING:
index b0303cf..c373152 100644 (file)
@@ -249,7 +249,7 @@ int snd_tea575x_enum_freq_bands(struct snd_tea575x *tea,
                        index = BAND_AM;
                        break;
                }
-               /* Fall through */
+               fallthrough;
        default:
                return -EINVAL;
        }
index 5bb1444..3fe3edd 100644 (file)
@@ -112,7 +112,7 @@ lirc_mode2_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
        case BPF_FUNC_trace_printk:
                if (perfmon_capable())
                        return bpf_get_trace_printk_proto();
-               /* fall through */
+               fallthrough;
        default:
                return NULL;
        }
index f33b443..c6cd2e6 100644 (file)
@@ -19,8 +19,6 @@ struct gpio_ir {
        struct gpio_desc *gpio;
        unsigned int carrier;
        unsigned int duty_cycle;
-       /* we need a spinlock to hold the cpu while transmitting */
-       spinlock_t lock;
 };
 
 static const struct of_device_id gpio_ir_tx_of_match[] = {
@@ -53,12 +51,11 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
 static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
                                   uint count)
 {
-       unsigned long flags;
        ktime_t edge;
        s32 delta;
        int i;
 
-       spin_lock_irqsave(&gpio_ir->lock, flags);
+       local_irq_disable();
 
        edge = ktime_get();
 
@@ -72,14 +69,11 @@ static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
        }
 
        gpiod_set_value(gpio_ir->gpio, 0);
-
-       spin_unlock_irqrestore(&gpio_ir->lock, flags);
 }
 
 static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
                                 uint count)
 {
-       unsigned long flags;
        ktime_t edge;
        /*
         * delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on
@@ -95,7 +89,7 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
        space = DIV_ROUND_CLOSEST((100 - gpio_ir->duty_cycle) *
                                  (NSEC_PER_SEC / 100), gpio_ir->carrier);
 
-       spin_lock_irqsave(&gpio_ir->lock, flags);
+       local_irq_disable();
 
        edge = ktime_get();
 
@@ -128,19 +122,20 @@ static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
                        edge = last;
                }
        }
-
-       spin_unlock_irqrestore(&gpio_ir->lock, flags);
 }
 
 static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
                      unsigned int count)
 {
        struct gpio_ir *gpio_ir = dev->priv;
+       unsigned long flags;
 
+       local_irq_save(flags);
        if (gpio_ir->carrier)
                gpio_ir_tx_modulated(gpio_ir, txbuf, count);
        else
                gpio_ir_tx_unmodulated(gpio_ir, txbuf, count);
+       local_irq_restore(flags);
 
        return count;
 }
@@ -176,7 +171,6 @@ static int gpio_ir_tx_probe(struct platform_device *pdev)
 
        gpio_ir->carrier = 38000;
        gpio_ir->duty_cycle = 50;
-       spin_lock_init(&gpio_ir->lock);
 
        rc = devm_rc_register_device(&pdev->dev, rcdev);
        if (rc < 0)
index 95727ca..0cda78f 100644 (file)
@@ -64,7 +64,7 @@ static enum rc6_mode rc6_mode(struct rc6_dec *data)
        case 6:
                if (!data->toggle)
                        return RC6_MODE_6A;
-               /* fall through */
+               fallthrough;
        default:
                return RC6_MODE_UNKNOWN;
        }
index 9fa58d9..7d9a7c0 100644 (file)
@@ -102,7 +102,7 @@ static int ir_sony_decode(struct rc_dev *dev, struct ir_raw_event ev)
                }
 
                data->state = STATE_FINISHED;
-               /* Fall through */
+               fallthrough;
 
        case STATE_FINISHED:
                if (ev.pulse)
index f961615..98681ba 100644 (file)
@@ -1726,7 +1726,7 @@ static int mceusb_dev_probe(struct usb_interface *intf,
                goto mem_alloc_fail;
 
        ir->pipe_in = pipe;
-       ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_ATOMIC, &ir->dma_in);
+       ir->buf_in = usb_alloc_coherent(dev, maxp, GFP_KERNEL, &ir->dma_in);
        if (!ir->buf_in)
                goto buf_in_alloc_fail;
 
index 7b53066..dee8a9f 100644 (file)
@@ -1292,6 +1292,10 @@ static ssize_t store_protocols(struct device *device,
        }
 
        mutex_lock(&dev->lock);
+       if (!dev->registered) {
+               mutex_unlock(&dev->lock);
+               return -ENODEV;
+       }
 
        old_protocols = *current_protocols;
        new_protocols = old_protocols;
@@ -1430,6 +1434,10 @@ static ssize_t store_filter(struct device *device,
                return -EINVAL;
 
        mutex_lock(&dev->lock);
+       if (!dev->registered) {
+               mutex_unlock(&dev->lock);
+               return -ENODEV;
+       }
 
        new_filter = *filter;
        if (fattr->mask)
@@ -1544,6 +1552,10 @@ static ssize_t store_wakeup_protocols(struct device *device,
        int i;
 
        mutex_lock(&dev->lock);
+       if (!dev->registered) {
+               mutex_unlock(&dev->lock);
+               return -ENODEV;
+       }
 
        allowed = dev->allowed_wakeup_protocols;
 
@@ -1601,25 +1613,25 @@ static void rc_dev_release(struct device *device)
        kfree(dev);
 }
 
-#define ADD_HOTPLUG_VAR(fmt, val...)                                   \
-       do {                                                            \
-               int err = add_uevent_var(env, fmt, val);                \
-               if (err)                                                \
-                       return err;                                     \
-       } while (0)
-
 static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env)
 {
        struct rc_dev *dev = to_rc_dev(device);
+       int ret = 0;
 
-       if (dev->rc_map.name)
-               ADD_HOTPLUG_VAR("NAME=%s", dev->rc_map.name);
-       if (dev->driver_name)
-               ADD_HOTPLUG_VAR("DRV_NAME=%s", dev->driver_name);
-       if (dev->device_name)
-               ADD_HOTPLUG_VAR("DEV_NAME=%s", dev->device_name);
+       mutex_lock(&dev->lock);
 
-       return 0;
+       if (!dev->registered)
+               ret = -ENODEV;
+       if (ret == 0 && dev->rc_map.name)
+               ret = add_uevent_var(env, "NAME=%s", dev->rc_map.name);
+       if (ret == 0 && dev->driver_name)
+               ret = add_uevent_var(env, "DRV_NAME=%s", dev->driver_name);
+       if (ret == 0 && dev->device_name)
+               ret = add_uevent_var(env, "DEV_NAME=%s", dev->device_name);
+
+       mutex_unlock(&dev->lock);
+
+       return ret;
 }
 
 /*
@@ -2011,14 +2023,14 @@ void rc_unregister_device(struct rc_dev *dev)
        del_timer_sync(&dev->timer_keyup);
        del_timer_sync(&dev->timer_repeat);
 
-       rc_free_rx_device(dev);
-
        mutex_lock(&dev->lock);
        if (dev->users && dev->close)
                dev->close(dev);
        dev->registered = false;
        mutex_unlock(&dev->lock);
 
+       rc_free_rx_device(dev);
+
        /*
         * lirc device should be freed with dev->registered = false, so
         * that userspace polling will get notified.
index 8941d73..71928e3 100644 (file)
@@ -1994,6 +1994,7 @@ static int vicodec_request_validate(struct media_request *req)
        }
        ctrl = v4l2_ctrl_request_hdl_ctrl_find(hdl,
                                               vicodec_ctrl_stateless_state.id);
+       v4l2_ctrl_request_hdl_put(hdl);
        if (!ctrl) {
                v4l2_info(&ctx->dev->v4l2_dev,
                          "Missing required codec control\n");
index 734a92c..7b7d9fe 100644 (file)
@@ -756,7 +756,7 @@ static int xc5000_set_digital_params(struct dvb_frontend *fe)
                if (!bw)
                        bw = 6000000;
                /* fall to OFDM handling */
-               /* fall through */
+               fallthrough;
        case SYS_DMBTH:
        case SYS_DVBT:
        case SYS_DVBT2:
index 198ddfb..e3234d1 100644 (file)
@@ -525,7 +525,7 @@ static int flexcop_usb_init(struct flexcop_usb *fc_usb)
        case USB_SPEED_HIGH:
                info("running at HIGH speed.");
                break;
-       case USB_SPEED_UNKNOWN: /* fall through */
+       case USB_SPEED_UNKNOWN:
        default:
                err("cannot handle USB speed because it is unknown.");
                return -ENODEV;
index 20c50c2..e747548 100644 (file)
@@ -165,7 +165,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_BRIGHTNESS:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_BRIGHTNESS:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -176,7 +176,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_CONTRAST:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_CONTRAST:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -184,7 +184,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_SATURATION:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_SATURATION:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -195,7 +195,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_GPIO_DATA:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_GPIO_DATA:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -203,7 +203,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_GPIO_DIRECTION:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_GPIO_DIRECTION:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -211,7 +211,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VC_MP_GPIO_DATA:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VC_MP_GPIO_DATA:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
                cmd.reg_count = 1;
@@ -219,7 +219,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VC_MP_GPIO_DIRECTION:
                cmd.buffer.block_data[0] = param;
-               /*fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VC_MP_GPIO_DIRECTION:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
                cmd.reg_count = 1;
@@ -234,7 +234,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_FLICKER_MODES:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_FLICKER_MODES:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -281,7 +281,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_USER_MODE:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_USER_MODE:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -301,7 +301,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_WAKEUP:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_WAKEUP:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
                cmd.reg_count = 1;
@@ -309,7 +309,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_PW_CONTROL:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_PW_CONTROL:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
                cmd.reg_count = 1;
@@ -322,7 +322,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_SYSTEM_CTRL:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_SYSTEM_CTRL:
                cmd.req_mode =
                    CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_SYSTEM;
@@ -331,7 +331,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_SYSTEM_CTRL:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_SYSTEM_CTRL:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -339,7 +339,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VP_EXP_MODES:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VP_EXP_MODES:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -347,7 +347,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_DEVICE_CONFIG:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_DEVICE_CONFIG:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -368,7 +368,7 @@ int cpia2_do_command(struct camera_data *cam,
                break;
        case CPIA2_CMD_SET_VC_CONTROL:
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_VC_CONTROL:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VC;
                cmd.reg_count = 1;
@@ -403,7 +403,7 @@ int cpia2_do_command(struct camera_data *cam,
                                             this register can also affect
                                             flicker modes */
                cmd.buffer.block_data[0] = param;
-               /* fall through */
+               fallthrough;
        case CPIA2_CMD_GET_USER_EFFECTS:
                cmd.req_mode = CAMERAACCESS_TYPE_BLOCK | CAMERAACCESS_VP;
                cmd.reg_count = 1;
@@ -1751,7 +1751,7 @@ int cpia2_set_fps(struct camera_data *cam, int framerate)
                                                    CPIA2_VP_SENSOR_FLAGS_500) {
                                return -EINVAL;
                        }
-                       /* Fall through */
+                       fallthrough;
                case CPIA2_VP_FRAMERATE_15:
                case CPIA2_VP_FRAMERATE_12_5:
                case CPIA2_VP_FRAMERATE_7_5:
index d9f953f..425e470 100644 (file)
@@ -996,7 +996,7 @@ void cx231xx_v4l2_create_entities(struct cx231xx *dev)
                        /* The DVB core will handle it */
                        if (dev->tuner_type == TUNER_ABSENT)
                                continue;
-                       /* fall through */
+                       fallthrough;
                default: /* just to shut up a gcc warning */
                        ent->function = MEDIA_ENT_F_CONN_RF;
                        break;
index 4ef3fa9..52e648e 100644 (file)
@@ -1659,14 +1659,14 @@ static int dib8096_set_param_override(struct dvb_frontend *fe)
 
        switch (band) {
        default:
-                       deb_info("Warning : Rf frequency  (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
-                       /* fall through */
+               deb_info("Warning : Rf frequency  (%iHz) is not in the supported range, using VHF switch ", fe->dtv_property_cache.frequency);
+               fallthrough;
        case BAND_VHF:
-                       state->dib8000_ops.set_gpio(fe, 3, 0, 1);
-                       break;
+               state->dib8000_ops.set_gpio(fe, 3, 0, 1);
+               break;
        case BAND_UHF:
-                       state->dib8000_ops.set_gpio(fe, 3, 0, 0);
-                       break;
+               state->dib8000_ops.set_gpio(fe, 3, 0, 0);
+               break;
        }
 
        ret = state->set_param_save(fe);
index f96626f..a27a684 100644 (file)
@@ -1886,12 +1886,12 @@ static int dw2102_load_firmware(struct usb_device *dev,
                switch (le16_to_cpu(dev->descriptor.idProduct)) {
                case USB_PID_TEVII_S650:
                        dw2104_properties.rc.core.rc_codes = RC_MAP_TEVII_NEC;
-                       /* fall through */
+                       fallthrough;
                case USB_PID_DW2104:
                        reset = 1;
                        dw210x_op_rw(dev, 0xc4, 0x0000, 0, &reset, 1,
                                        DW210X_WRITE_MSG);
-                       /* fall through */
+                       fallthrough;
                case USB_PID_DW3101:
                        reset = 0;
                        dw210x_op_rw(dev, 0xbf, 0x0040, 0, &reset, 0,
@@ -1924,7 +1924,7 @@ static int dw2102_load_firmware(struct usb_device *dev,
                                        break;
                                }
                        }
-                       /* fall through */
+                       fallthrough;
                case 0x2101:
                        dw210x_op_rw(dev, 0xbc, 0x0030, 0, &reset16[0], 2,
                                        DW210X_READ_MSG);
index 3f3fbcd..45a2403 100644 (file)
@@ -2200,7 +2200,7 @@ static int check_range(enum v4l2_ctrl_type type,
        case V4L2_CTRL_TYPE_BOOLEAN:
                if (step != 1 || max > 1 || min < 0)
                        return -ERANGE;
-               /* fall through */
+               fallthrough;
        case V4L2_CTRL_TYPE_U8:
        case V4L2_CTRL_TYPE_U16:
        case V4L2_CTRL_TYPE_U32:
index a556880..f74b422 100644 (file)
@@ -782,7 +782,6 @@ static void v4l_print_frmsizeenum(const void *arg, bool write_only)
                                p->stepwise.step_height);
                break;
        case V4L2_FRMSIZE_TYPE_CONTINUOUS:
-               /* fall through */
        default:
                pr_cont("\n");
                break;
@@ -816,7 +815,6 @@ static void v4l_print_frmivalenum(const void *arg, bool write_only)
                                p->stepwise.step.denominator);
                break;
        case V4L2_FRMIVAL_TYPE_CONTINUOUS:
-               /* fall through */
        default:
                pr_cont("\n");
                break;
@@ -3189,14 +3187,16 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd)
 #ifdef CONFIG_COMPAT_32BIT_TIME
        case VIDIOC_DQEVENT_TIME32: {
                struct v4l2_event *ev = parg;
-               struct v4l2_event_time32 ev32 = {
-                       .type           = ev->type,
-                       .pending        = ev->pending,
-                       .sequence       = ev->sequence,
-                       .timestamp.tv_sec  = ev->timestamp.tv_sec,
-                       .timestamp.tv_nsec = ev->timestamp.tv_nsec,
-                       .id             = ev->id,
-               };
+               struct v4l2_event_time32 ev32;
+
+               memset(&ev32, 0, sizeof(ev32));
+
+               ev32.type       = ev->type;
+               ev32.pending    = ev->pending;
+               ev32.sequence   = ev->sequence;
+               ev32.timestamp.tv_sec   = ev->timestamp.tv_sec;
+               ev32.timestamp.tv_nsec  = ev->timestamp.tv_nsec;
+               ev32.id         = ev->id;
 
                memcpy(&ev32.u, &ev->u, sizeof(ev->u));
                memcpy(&ev32.reserved, &ev->reserved, sizeof(ev->reserved));
@@ -3210,21 +3210,23 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd)
        case VIDIOC_DQBUF_TIME32:
        case VIDIOC_PREPARE_BUF_TIME32: {
                struct v4l2_buffer *vb = parg;
-               struct v4l2_buffer_time32 vb32 = {
-                       .index          = vb->index,
-                       .type           = vb->type,
-                       .bytesused      = vb->bytesused,
-                       .flags          = vb->flags,
-                       .field          = vb->field,
-                       .timestamp.tv_sec       = vb->timestamp.tv_sec,
-                       .timestamp.tv_usec      = vb->timestamp.tv_usec,
-                       .timecode       = vb->timecode,
-                       .sequence       = vb->sequence,
-                       .memory         = vb->memory,
-                       .m.userptr      = vb->m.userptr,
-                       .length         = vb->length,
-                       .request_fd     = vb->request_fd,
-               };
+               struct v4l2_buffer_time32 vb32;
+
+               memset(&vb32, 0, sizeof(vb32));
+
+               vb32.index      = vb->index;
+               vb32.type       = vb->type;
+               vb32.bytesused  = vb->bytesused;
+               vb32.flags      = vb->flags;
+               vb32.field      = vb->field;
+               vb32.timestamp.tv_sec   = vb->timestamp.tv_sec;
+               vb32.timestamp.tv_usec  = vb->timestamp.tv_usec;
+               vb32.timecode   = vb->timecode;
+               vb32.sequence   = vb->sequence;
+               vb32.memory     = vb->memory;
+               vb32.m.userptr  = vb->m.userptr;
+               vb32.length     = vb->length;
+               vb32.request_fd = vb->request_fd;
 
                if (copy_to_user(arg, &vb32, sizeof(vb32)))
                        return -EFAULT;
index 5c91fc3..606a271 100644 (file)
@@ -354,7 +354,7 @@ static void videobuf_status(struct videobuf_queue *q, struct v4l2_buffer *b,
                break;
        case VIDEOBUF_ERROR:
                b->flags |= V4L2_BUF_FLAG_ERROR;
-               /* fall through */
+               fallthrough;
        case VIDEOBUF_DONE:
                b->flags |= V4L2_BUF_FLAG_DONE;
                break;
index f512cbc..ca00976 100644 (file)
@@ -313,7 +313,6 @@ static unsigned long gpmc_get_clk_period(int cs, enum gpmc_clk_domain cd)
                tick_ps *= div;
                break;
        case GPMC_CD_FCLK:
-               /* FALL-THROUGH */
        default:
                break;
        }
index d9ee8e3..1789542 100644 (file)
@@ -371,7 +371,7 @@ again:
                        serial mode), then just fall through */
                if (msb_read_int_reg(msb, -1))
                        return 0;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_RP_RECEIVE_INT_REQ_RESULT:
                intreg = mrq->data[0];
@@ -403,7 +403,7 @@ again:
        case MSB_RP_RECEIVE_STATUS_REG:
                msb->regs.status = *(struct ms_status_register *)mrq->data;
                msb->state = MSB_RP_SEND_OOB_READ;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_RP_SEND_OOB_READ:
                if (!msb_read_regs(msb,
@@ -418,7 +418,7 @@ again:
                msb->regs.extra_data =
                        *(struct ms_extra_data_register *) mrq->data;
                msb->state = MSB_RP_SEND_READ_DATA;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_RP_SEND_READ_DATA:
                /* Skip that state if we only read the oob */
@@ -518,7 +518,7 @@ again:
                msb->state = MSB_WB_RECEIVE_INT_REQ;
                if (msb_read_int_reg(msb, -1))
                        return 0;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_WB_RECEIVE_INT_REQ:
                intreg = mrq->data[0];
@@ -549,7 +549,7 @@ again:
 
                msb->int_polling = false;
                msb->state = MSB_WB_SEND_WRITE_DATA;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_WB_SEND_WRITE_DATA:
                sg_init_table(sg, ARRAY_SIZE(sg));
@@ -628,7 +628,7 @@ again:
                msb->state = MSB_SC_RECEIVE_INT_REQ;
                if (msb_read_int_reg(msb, -1))
                        return 0;
-               /* fallthrough */
+               fallthrough;
 
        case MSB_SC_RECEIVE_INT_REQ:
                intreg = mrq->data[0];
index 4a6b866..e83c3ad 100644 (file)
@@ -255,11 +255,11 @@ static unsigned int jmb38x_ms_write_data(struct jmb38x_ms_host *host,
        case 3:
                host->io_word[0] |= buf[off + 2] << 16;
                host->io_pos++;
-               /* fall through */
+               fallthrough;
        case 2:
                host->io_word[0] |= buf[off + 1] << 8;
                host->io_pos++;
-               /* fall through */
+               fallthrough;
        case 1:
                host->io_word[0] |= buf[off];
                host->io_pos++;
index fc35c74..786e467 100644 (file)
@@ -162,11 +162,11 @@ static unsigned int tifm_ms_write_data(struct tifm_ms *host,
        case 3:
                host->io_word |= buf[off + 2] << 16;
                host->io_pos++;
-               /* fall through */
+               fallthrough;
        case 2:
                host->io_word |= buf[off + 1] << 8;
                host->io_pos++;
-               /* fall through */
+               fallthrough;
        case 1:
                host->io_word |= buf[off];
                host->io_pos++;
index 5216487..9903e96 100644 (file)
@@ -642,7 +642,7 @@ mptbase_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *req, MPT_FRAME_HDR *reply)
                        freereq = 0;
                if (event != MPI_EVENT_EVENT_CHANGE)
                        break;
-               /* fall through */
+               fallthrough;
        case MPI_FUNCTION_CONFIG:
        case MPI_FUNCTION_SAS_IO_UNIT_CONTROL:
                ioc->mptbase_cmds.status |= MPT_MGMT_STATUS_COMMAND_GOOD;
@@ -1887,7 +1887,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
        case MPI_MANUFACTPAGE_DEVICEID_FC939X:
        case MPI_MANUFACTPAGE_DEVICEID_FC949X:
                ioc->errata_flag_1064 = 1;
-               /* fall through */
+               fallthrough;
        case MPI_MANUFACTPAGE_DEVICEID_FC909:
        case MPI_MANUFACTPAGE_DEVICEID_FC929:
        case MPI_MANUFACTPAGE_DEVICEID_FC919:
@@ -1932,7 +1932,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
                        pcixcmd &= 0x8F;
                        pci_write_config_byte(pdev, 0x6a, pcixcmd);
                }
-               /* fall through */
+               fallthrough;
 
        case MPI_MANUFACTPAGE_DEVID_1030_53C1035:
                ioc->bus_type = SPI;
index 6a79cd0..18b91ea 100644 (file)
@@ -4326,7 +4326,7 @@ mptsas_hotplug_work(MPT_ADAPTER *ioc, struct fw_event_work *fw_event,
                        }
                }
                mpt_findImVolumes(ioc);
-               /* fall through */
+               fallthrough;
 
        case MPTSAS_ADD_DEVICE:
                memset(&sas_device, 0, sizeof(struct mptsas_devinfo));
index 1491561..8543f03 100644 (file)
@@ -784,7 +784,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
                        /*
                         * Allow non-SAS & non-NEXUS_LOSS to drop into below code
                         */
-                       /* Fall through */
+                       fallthrough;
 
                case MPI_IOCSTATUS_SCSI_TASK_TERMINATED:        /* 0x0048 */
                        /* Linux handles an unsolicited DID_RESET better
@@ -881,7 +881,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
 
                case MPI_IOCSTATUS_SCSI_DATA_OVERRUN:           /* 0x0044 */
                        scsi_set_resid(sc, 0);
-                       /* Fall through */
+                       fallthrough;
                case MPI_IOCSTATUS_SCSI_RECOVERED_ERROR:        /* 0x0040 */
                case MPI_IOCSTATUS_SUCCESS:                     /* 0x0000 */
                        sc->result = (DID_OK << 16) | scsi_status;
index a9d9c1c..a5983d5 100644 (file)
@@ -1515,10 +1515,10 @@ static unsigned long dsiclk_rate(u8 n)
        switch (divsel) {
        case PRCM_DSI_PLLOUT_SEL_PHI_4:
                div *= 2;
-               /* Fall through */
+               fallthrough;
        case PRCM_DSI_PLLOUT_SEL_PHI_2:
                div *= 2;
-               /* Fall through */
+               fallthrough;
        case PRCM_DSI_PLLOUT_SEL_PHI:
                return pll_rate(PRCM_PLLDSI_FREQ, clock_rate(PRCMU_HDMICLK),
                        PLL_RAW) / div;
index af764bc..761b4ef 100644 (file)
@@ -136,7 +136,7 @@ static int iqs62x_dev_init(struct iqs62x_core *iqs62x)
                if (val & IQS620_PROX_SETTINGS_4_SAR_EN)
                        iqs62x->ui_sel = IQS62X_UI_SAR1;
 
-               /* fall through */
+               fallthrough;
 
        case IQS621_PROD_NUM:
                ret = regmap_write(iqs62x->regmap, IQS620_GLBL_EVENT_MASK,
@@ -470,7 +470,7 @@ static irqreturn_t iqs62x_irq(int irq, void *context)
                case IQS62X_EVENT_UI_LO:
                        event_data.ui_data = get_unaligned_le16(&event_map[i]);
 
-                       /* fall through */
+                       fallthrough;
 
                case IQS62X_EVENT_UI_HI:
                case IQS62X_EVENT_NONE:
@@ -491,7 +491,7 @@ static irqreturn_t iqs62x_irq(int irq, void *context)
                case IQS62X_EVENT_HYST:
                        event_map[i] <<= iqs62x->dev_desc->hyst_shift;
 
-                       /* fall through */
+                       fallthrough;
 
                case IQS62X_EVENT_WHEEL:
                case IQS62X_EVENT_HALL:
index c3651f0..fc00aac 100644 (file)
@@ -126,10 +126,6 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
        const __be32 *reg;
        u64 of_node_addr;
 
-       /* Skip devices 'disabled' by Device Tree */
-       if (!of_device_is_available(np))
-               return -ENODEV;
-
        /* Skip if OF node has previously been allocated to a device */
        list_for_each_entry(of_entry, &mfd_of_node_list, list)
                if (of_entry->np == np)
@@ -212,6 +208,12 @@ static int mfd_add_device(struct device *parent, int id,
        if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) {
                for_each_child_of_node(parent->of_node, np) {
                        if (of_device_is_compatible(np, cell->of_compatible)) {
+                               /* Ignore 'disabled' devices error free */
+                               if (!of_device_is_available(np)) {
+                                       ret = 0;
+                                       goto fail_alias;
+                               }
+
                                ret = mfd_match_of_node_to_dev(pdev, np, cell);
                                if (ret == -EAGAIN)
                                        continue;
@@ -370,8 +372,6 @@ static int mfd_remove_devices_fn(struct device *dev, void *data)
        regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies,
                                               cell->num_parent_supplies);
 
-       kfree(cell);
-
        platform_device_unregister(pdev);
        return 0;
 }
index 5bef142..111d11f 100644 (file)
@@ -172,7 +172,7 @@ static int mxs_lradc_probe(struct platform_device *pdev)
                                        MXS_LRADC_TOUCHSCREEN_5WIRE;
                                break;
                        }
-                       /* fall through - to an error message for i.MX23 */
+                       fallthrough;    /* to an error message for i.MX23 */
                default:
                        dev_err(&pdev->dev,
                                "Unsupported number of touchscreen wires (%d)\n"
index 1e6431c..2a3a240 100644 (file)
@@ -308,7 +308,7 @@ static int usbhs_runtime_resume(struct device *dev)
                                         i, r);
                                }
                        }
-               /* Fall through - as HSIC mode needs utmi_clk */
+                       fallthrough;    /* as HSIC mode needs utmi_clk */
 
                case OMAP_EHCI_PORT_MODE_TLL:
                        if (!IS_ERR(omap->utmi_clk[i])) {
@@ -344,7 +344,7 @@ static int usbhs_runtime_suspend(struct device *dev)
 
                        if (!IS_ERR(omap->hsic480m_clk[i]))
                                clk_disable_unprepare(omap->hsic480m_clk[i]);
-               /* Fall through - as utmi_clks were used in HSIC mode */
+                       fallthrough;    /* as utmi_clks were used in HSIC mode */
 
                case OMAP_EHCI_PORT_MODE_TLL:
                        if (!IS_ERR(omap->utmi_clk[i]))
index abaab54..545196c 100644 (file)
@@ -270,7 +270,7 @@ static void *stuff(unsigned char *dest, const unsigned char *src, size_t n)
                case RAVE_SP_ETX:
                case RAVE_SP_DLE:
                        *dest++ = RAVE_SP_DLE;
-                       /* FALLTHROUGH */
+                       fallthrough;
                default:
                        *dest++ = byte;
                }
@@ -541,7 +541,7 @@ static int rave_sp_receive_buf(struct serdev_device *serdev,
                         * deframer buffer
                         */
 
-                       /* FALLTHROUGH */
+                       fallthrough;
 
                case RAVE_SP_EXPECT_ESCAPED_DATA:
                        if (deframer->length == sizeof(deframer->data)) {
index 75859e4..df5cebb 100644 (file)
@@ -95,7 +95,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
                        break;
                default:
                        pr_err("Failed to retrieve valid hwlock: %d\n", ret);
-                       /* fall-through */
+                       fallthrough;
                case -EPROBE_DEFER:
                        goto err_regmap;
                }
index ce136d6..e19e1dc 100644 (file)
@@ -456,6 +456,15 @@ config PVPANIC
          a paravirtualized device provided by QEMU; it lets a virtual machine
          (guest) communicate panic events to the host.
 
+config HISI_HIKEY_USB
+       tristate "USB GPIO Hub on HiSilicon Hikey 960/970 Platform"
+       depends on (OF && GPIOLIB) || COMPILE_TEST
+       help
+         If you say yes here this adds support for the on-board USB GPIO hub
+         found on HiKey 960/970 boards, which is necessary to support
+         switching between the dual-role USB-C port and the USB-A host ports
+         using only one USB controller.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
index c7bd01a..2521359 100644 (file)
@@ -57,3 +57,4 @@ obj-$(CONFIG_PVPANIC)         += pvpanic.o
 obj-$(CONFIG_HABANA_AI)                += habanalabs/
 obj-$(CONFIG_UACCE)            += uacce/
 obj-$(CONFIG_XILINX_SDFEC)     += xilinx_sdfec.o
+obj-$(CONFIG_HISI_HIKEY_USB)   += hisi_hikey_usb.o
index f5f392d..8859011 100644 (file)
@@ -72,28 +72,80 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr)
 
        pci_read_config_dword(pdev, PCR_SETTING_REG2, &reg);
        pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+       if (rtsx_check_mmc_support(reg))
+               pcr->extra_caps |= EXTRA_CAPS_NO_MMC;
        pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
        if (rtsx_reg_check_reverse_socket(reg))
                pcr->flags |= PCR_REVERSE_SOCKET;
 }
 
-static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
+static void rts5227_init_from_cfg(struct rtsx_pcr *pcr)
 {
-       /* Set relink_time to 0 */
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
+       struct pci_dev *pdev = pcr->pci;
+       int l1ss;
+       u32 lval;
+       struct rtsx_cr_option *option = &pcr->option;
+
+       l1ss = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_L1SS);
+       if (!l1ss)
+               return;
+
+       pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL1, &lval);
 
-       if (pm_state == HOST_ENTER_S3)
-               rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x10);
+       if (CHK_PCI_PID(pcr, 0x522A)) {
+               if (0 == (lval & 0x0F))
+                       rtsx_pci_enable_oobs_polling(pcr);
+               else
+                       rtsx_pci_disable_oobs_polling(pcr);
+       }
+
+       if (lval & PCI_L1SS_CTL1_ASPM_L1_1)
+               rtsx_set_dev_flag(pcr, ASPM_L1_1_EN);
+       else
+               rtsx_clear_dev_flag(pcr, ASPM_L1_1_EN);
+
+       if (lval & PCI_L1SS_CTL1_ASPM_L1_2)
+               rtsx_set_dev_flag(pcr, ASPM_L1_2_EN);
+       else
+               rtsx_clear_dev_flag(pcr, ASPM_L1_2_EN);
+
+       if (lval & PCI_L1SS_CTL1_PCIPM_L1_1)
+               rtsx_set_dev_flag(pcr, PM_L1_1_EN);
+       else
+               rtsx_clear_dev_flag(pcr, PM_L1_1_EN);
+
+       if (lval & PCI_L1SS_CTL1_PCIPM_L1_2)
+               rtsx_set_dev_flag(pcr, PM_L1_2_EN);
+       else
+               rtsx_clear_dev_flag(pcr, PM_L1_2_EN);
+
+       if (option->ltr_en) {
+               u16 val;
+
+               pcie_capability_read_word(pcr->pci, PCI_EXP_DEVCTL2, &val);
+               if (val & PCI_EXP_DEVCTL2_LTR_EN) {
+                       option->ltr_enabled = true;
+                       option->ltr_active = true;
+                       rtsx_set_ltr_latency(pcr, option->ltr_active_latency);
+               } else {
+                       option->ltr_enabled = false;
+               }
+       }
+
+       if (rtsx_check_dev_flag(pcr, ASPM_L1_1_EN | ASPM_L1_2_EN
+                               | PM_L1_1_EN | PM_L1_2_EN))
+               option->force_clkreq_0 = false;
+       else
+               option->force_clkreq_0 = true;
 
-       rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
 }
 
 static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
 {
        u16 cap;
+       struct rtsx_cr_option *option = &pcr->option;
 
+       rts5227_init_from_cfg(pcr);
        rtsx_pci_init_cmd(pcr);
 
        /* Configure GPIO as output */
@@ -115,9 +167,17 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
        rts5227_fill_driving(pcr, OUTPUT_3V3);
        /* Configure force_clock_req */
        if (pcr->flags & PCR_REVERSE_SOCKET)
-               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0xB8);
+               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x30, 0x30);
+       else
+               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x30, 0x00);
+
+       if (option->force_clkreq_0)
+               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
+                               FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_LOW);
        else
-               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0x88);
+               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
+                               FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_HIGH);
+
        rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, pcr->reg_pm_ctrl3, 0x10, 0x00);
 
        return rtsx_pci_send_cmd(pcr, 100);
@@ -239,7 +299,6 @@ static const struct pcr_ops rts5227_pcr_ops = {
        .switch_output_voltage = rts5227_switch_output_voltage,
        .cd_deglitch = NULL,
        .conv_clk_and_div_n = NULL,
-       .force_power_down = rts5227_force_power_down,
 };
 
 /* SD Pull Control Enable:
@@ -373,6 +432,27 @@ static int rts522a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
        return rtsx_pci_send_cmd(pcr, 100);
 }
 
+static void rts522a_set_l1off_cfg_sub_d0(struct rtsx_pcr *pcr, int active)
+{
+       struct rtsx_cr_option *option = &pcr->option;
+       int aspm_L1_1, aspm_L1_2;
+       u8 val = 0;
+
+       aspm_L1_1 = rtsx_check_dev_flag(pcr, ASPM_L1_1_EN);
+       aspm_L1_2 = rtsx_check_dev_flag(pcr, ASPM_L1_2_EN);
+
+       if (active) {
+               /* run, latency: 60us */
+               if (aspm_L1_1)
+                       val = option->ltr_l1off_snooze_sspwrgate;
+       } else {
+               /* l1off, latency: 300us */
+               if (aspm_L1_2)
+                       val = option->ltr_l1off_sspwrgate;
+       }
+
+       rtsx_set_l1off_sub(pcr, val);
+}
 
 /* rts522a operations mainly derived from rts5227, except phy/hw init setting.
  */
@@ -389,16 +469,29 @@ static const struct pcr_ops rts522a_pcr_ops = {
        .switch_output_voltage = rts522a_switch_output_voltage,
        .cd_deglitch = NULL,
        .conv_clk_and_div_n = NULL,
-       .force_power_down = rts5227_force_power_down,
+       .set_l1off_cfg_sub_d0 = rts522a_set_l1off_cfg_sub_d0,
 };
 
 void rts522a_init_params(struct rtsx_pcr *pcr)
 {
+       struct rtsx_cr_option *option = &pcr->option;
+
        rts5227_init_params(pcr);
        pcr->ops = &rts522a_pcr_ops;
        pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11);
        pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
 
+       option->dev_flags = LTR_L1SS_PWR_GATE_EN;
+       option->ltr_en = true;
+
+       /* init latency of active, idle, L1OFF to 60us, 300us, 3ms */
+       option->ltr_active_latency = LTR_ACTIVE_LATENCY_DEF;
+       option->ltr_idle_latency = LTR_IDLE_LATENCY_DEF;
+       option->ltr_l1off_latency = LTR_L1OFF_LATENCY_DEF;
+       option->l1_snooze_delay = L1_SNOOZE_DELAY_DEF;
+       option->ltr_l1off_sspwrgate = 0x7F;
+       option->ltr_l1off_snooze_sspwrgate = 0x78;
+
        pcr->option.ocp_en = 1;
        if (pcr->option.ocp_en)
                pcr->hw_param.interrupt_en |= SD_OC_INT_EN;
index 28feab1..781a86d 100644 (file)
@@ -99,9 +99,8 @@ static void rts5228_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
        rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3,
                                RELINK_TIME_MASK, 0);
 
-       if (pm_state == HOST_ENTER_S3)
-               rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3,
-                                       D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+       rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3,
+                       D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
 
        rtsx_pci_write_register(pcr, FPDCTL,
                SSC_POWER_DOWN, SSC_POWER_DOWN);
index 941b3d7..b85279f 100644 (file)
@@ -73,25 +73,13 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)
 
        pci_read_config_dword(pdev, PCR_SETTING_REG2, &reg);
        pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+       if (rtsx_check_mmc_support(reg))
+               pcr->extra_caps |= EXTRA_CAPS_NO_MMC;
        pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
        if (rtsx_reg_check_reverse_socket(reg))
                pcr->flags |= PCR_REVERSE_SOCKET;
 }
 
-static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
-{
-       /* Set relink_time to 0 */
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, 0xFF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, 0xFF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0);
-
-       if (pm_state == HOST_ENTER_S3)
-               rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3,
-                       D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
-
-       rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03);
-}
-
 static void rts5249_init_from_cfg(struct rtsx_pcr *pcr)
 {
        struct pci_dev *pdev = pcr->pci;
@@ -105,6 +93,14 @@ static void rts5249_init_from_cfg(struct rtsx_pcr *pcr)
 
        pci_read_config_dword(pdev, l1ss + PCI_L1SS_CTL1, &lval);
 
+       if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A)) {
+               if (0 == (lval & 0x0F))
+                       rtsx_pci_enable_oobs_polling(pcr);
+               else
+                       rtsx_pci_disable_oobs_polling(pcr);
+       }
+
+
        if (lval & PCI_L1SS_CTL1_ASPM_L1_1)
                rtsx_set_dev_flag(pcr, ASPM_L1_1_EN);
 
@@ -144,6 +140,112 @@ static int rts5249_init_from_hw(struct rtsx_pcr *pcr)
        return 0;
 }
 
+static void rts52xa_save_content_from_efuse(struct rtsx_pcr *pcr)
+{
+       u8 cnt, sv;
+       u16 j = 0;
+       u8 tmp;
+       u8 val;
+       int i;
+
+       rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL,
+                               REG_EFUSE_BYPASS | REG_EFUSE_POR, REG_EFUSE_POR);
+       udelay(1);
+
+       pcr_dbg(pcr, "Enable efuse por!");
+       pcr_dbg(pcr, "save efuse to autoload");
+
+       rtsx_pci_write_register(pcr, RTS525A_EFUSE_ADD, REG_EFUSE_ADD_MASK, 0x00);
+       rtsx_pci_write_register(pcr, RTS525A_EFUSE_CTL,
+                               REG_EFUSE_ENABLE | REG_EFUSE_MODE, REG_EFUSE_ENABLE);
+       /* Wait transfer end */
+       for (j = 0; j < 1024; j++) {
+               rtsx_pci_read_register(pcr, RTS525A_EFUSE_CTL, &tmp);
+               if ((tmp & 0x80) == 0)
+                       break;
+       }
+       rtsx_pci_read_register(pcr, RTS525A_EFUSE_DATA, &val);
+       cnt = val & 0x0F;
+       sv = val & 0x10;
+
+       if (sv) {
+               for (i = 0; i < 4; i++) {
+                       rtsx_pci_write_register(pcr, RTS525A_EFUSE_ADD,
+                               REG_EFUSE_ADD_MASK, 0x04 + i);
+                       rtsx_pci_write_register(pcr, RTS525A_EFUSE_CTL,
+                               REG_EFUSE_ENABLE | REG_EFUSE_MODE, REG_EFUSE_ENABLE);
+                       /* Wait transfer end */
+                       for (j = 0; j < 1024; j++) {
+                               rtsx_pci_read_register(pcr, RTS525A_EFUSE_CTL, &tmp);
+                               if ((tmp & 0x80) == 0)
+                                       break;
+                       }
+                       rtsx_pci_read_register(pcr, RTS525A_EFUSE_DATA, &val);
+                       rtsx_pci_write_register(pcr, 0xFF04 + i, 0xFF, val);
+               }
+       } else {
+               rtsx_pci_write_register(pcr, 0xFF04, 0xFF, (u8)PCI_VID(pcr));
+               rtsx_pci_write_register(pcr, 0xFF05, 0xFF, (u8)(PCI_VID(pcr) >> 8));
+               rtsx_pci_write_register(pcr, 0xFF06, 0xFF, (u8)PCI_PID(pcr));
+               rtsx_pci_write_register(pcr, 0xFF07, 0xFF, (u8)(PCI_PID(pcr) >> 8));
+       }
+
+       for (i = 0; i < cnt * 4; i++) {
+               if (sv)
+                       rtsx_pci_write_register(pcr, RTS525A_EFUSE_ADD,
+                               REG_EFUSE_ADD_MASK, 0x08 + i);
+               else
+                       rtsx_pci_write_register(pcr, RTS525A_EFUSE_ADD,
+                               REG_EFUSE_ADD_MASK, 0x04 + i);
+               rtsx_pci_write_register(pcr, RTS525A_EFUSE_CTL,
+                               REG_EFUSE_ENABLE | REG_EFUSE_MODE, REG_EFUSE_ENABLE);
+               /* Wait transfer end */
+               for (j = 0; j < 1024; j++) {
+                       rtsx_pci_read_register(pcr, RTS525A_EFUSE_CTL, &tmp);
+                       if ((tmp & 0x80) == 0)
+                               break;
+               }
+               rtsx_pci_read_register(pcr, RTS525A_EFUSE_DATA, &val);
+               rtsx_pci_write_register(pcr, 0xFF08 + i, 0xFF, val);
+       }
+       rtsx_pci_write_register(pcr, 0xFF00, 0xFF, (cnt & 0x7F) | 0x80);
+       rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL,
+               REG_EFUSE_BYPASS | REG_EFUSE_POR, REG_EFUSE_BYPASS);
+       pcr_dbg(pcr, "Disable efuse por!");
+}
+
+static void rts52xa_save_content_to_autoload_space(struct rtsx_pcr *pcr)
+{
+       u8 val;
+
+       rtsx_pci_read_register(pcr, RESET_LOAD_REG, &val);
+       if (val & 0x02) {
+               rtsx_pci_read_register(pcr, RTS525A_BIOS_CFG, &val);
+               if (val & RTS525A_LOAD_BIOS_FLAG) {
+                       rtsx_pci_write_register(pcr, RTS525A_BIOS_CFG,
+                               RTS525A_LOAD_BIOS_FLAG, RTS525A_CLEAR_BIOS_FLAG);
+
+                       rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL,
+                               REG_EFUSE_POWER_MASK, REG_EFUSE_POWERON);
+
+                       pcr_dbg(pcr, "Power ON efuse!");
+                       mdelay(1);
+                       rts52xa_save_content_from_efuse(pcr);
+               } else {
+                       rtsx_pci_read_register(pcr, RTS524A_PME_FORCE_CTL, &val);
+                       if (!(val & 0x08))
+                               rts52xa_save_content_from_efuse(pcr);
+               }
+       } else {
+               pcr_dbg(pcr, "Load from autoload");
+               rtsx_pci_write_register(pcr, 0xFF00, 0xFF, 0x80);
+               rtsx_pci_write_register(pcr, 0xFF04, 0xFF, (u8)PCI_VID(pcr));
+               rtsx_pci_write_register(pcr, 0xFF05, 0xFF, (u8)(PCI_VID(pcr) >> 8));
+               rtsx_pci_write_register(pcr, 0xFF06, 0xFF, (u8)PCI_PID(pcr));
+               rtsx_pci_write_register(pcr, 0xFF07, 0xFF, (u8)(PCI_PID(pcr) >> 8));
+       }
+}
+
 static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
 {
        struct rtsx_cr_option *option = &(pcr->option);
@@ -153,6 +255,9 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
 
        rtsx_pci_init_cmd(pcr);
 
+       if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A))
+               rts52xa_save_content_to_autoload_space(pcr);
+
        /* Rest L1SUB Config */
        rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, L1SUB_CONFIG3, 0xFF, 0x00);
        /* Configure GPIO as output */
@@ -171,18 +276,36 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)
        else
                rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80);
 
+       rtsx_pci_send_cmd(pcr, CMD_TIMEOUT_DEF);
+
+       if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A)) {
+               rtsx_pci_write_register(pcr, REG_VREF, PWD_SUSPND_EN, PWD_SUSPND_EN);
+               rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, 0x01, 0x00);
+               rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL, 0x30, 0x20);
+       } else {
+               rtsx_pci_write_register(pcr, PME_FORCE_CTL, 0xFF, 0x30);
+               rtsx_pci_write_register(pcr, PM_CTRL3, 0x01, 0x00);
+       }
+
        /*
         * If u_force_clkreq_0 is enabled, CLKREQ# PIN will be forced
         * to drive low, and we forcibly request clock.
         */
        if (option->force_clkreq_0)
-               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
+               rtsx_pci_write_register(pcr, PETXCFG,
                        FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_LOW);
        else
-               rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
+               rtsx_pci_write_register(pcr, PETXCFG,
                        FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_HIGH);
 
-       return rtsx_pci_send_cmd(pcr, CMD_TIMEOUT_DEF);
+       rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x00);
+       if (CHK_PCI_PID(pcr, PID_524A) || CHK_PCI_PID(pcr, PID_525A)) {
+               rtsx_pci_write_register(pcr, RTS524A_PME_FORCE_CTL,
+                               REG_EFUSE_POWER_MASK, REG_EFUSE_POWEROFF);
+               pcr_dbg(pcr, "Power OFF efuse!");
+       }
+
+       return 0;
 }
 
 static int rts5249_optimize_phy(struct rtsx_pcr *pcr)
@@ -360,7 +483,6 @@ static const struct pcr_ops rts5249_pcr_ops = {
        .card_power_on = rtsx_base_card_power_on,
        .card_power_off = rtsx_base_card_power_off,
        .switch_output_voltage = rtsx_base_switch_output_voltage,
-       .force_power_down = rtsx_base_force_power_down,
 };
 
 /* SD Pull Control Enable:
@@ -585,7 +707,6 @@ static const struct pcr_ops rts524a_pcr_ops = {
        .card_power_on = rtsx_base_card_power_on,
        .card_power_off = rtsx_base_card_power_off,
        .switch_output_voltage = rtsx_base_switch_output_voltage,
-       .force_power_down = rtsx_base_force_power_down,
        .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0,
 };
 
@@ -668,6 +789,8 @@ static int rts525a_extra_init_hw(struct rtsx_pcr *pcr)
 {
        rts5249_extra_init_hw(pcr);
 
+       rtsx_pci_write_register(pcr, RTS5250_CLK_CFG3, RTS525A_CFG_MEM_PD, RTS525A_CFG_MEM_PD);
+
        rtsx_pci_write_register(pcr, PCLK_CTL, PCLK_MODE_SEL, PCLK_MODE_SEL);
        if (is_version(pcr, 0x525A, IC_VER_A)) {
                rtsx_pci_write_register(pcr, L1SUB_CONFIG2,
@@ -700,7 +823,6 @@ static const struct pcr_ops rts525a_pcr_ops = {
        .card_power_on = rts525a_card_power_on,
        .card_power_off = rtsx_base_card_power_off,
        .switch_output_voltage = rts525a_switch_output_voltage,
-       .force_power_down = rtsx_base_force_power_down,
        .set_l1off_cfg_sub_d0 = rts5250_set_l1off_cfg_sub_d0,
 };
 
index b9f66b1..080a7d6 100644 (file)
@@ -26,21 +26,17 @@ static u8 rts5260_get_ic_version(struct rtsx_pcr *pcr)
 
 static void rts5260_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
 {
-       u8 driving_3v3[6][3] = {
-               {0x94, 0x94, 0x94},
-               {0x11, 0x11, 0x18},
-               {0x55, 0x55, 0x5C},
-               {0x94, 0x94, 0x94},
-               {0x94, 0x94, 0x94},
-               {0xFF, 0xFF, 0xFF},
+       u8 driving_3v3[4][3] = {
+               {0x11, 0x11, 0x11},
+               {0x22, 0x22, 0x22},
+               {0x55, 0x55, 0x55},
+               {0x33, 0x33, 0x33},
        };
-       u8 driving_1v8[6][3] = {
-               {0x9A, 0x89, 0x89},
-               {0xC4, 0xC4, 0xC4},
-               {0x3C, 0x3C, 0x3C},
+       u8 driving_1v8[4][3] = {
+               {0x35, 0x33, 0x33},
+               {0x8A, 0x88, 0x88},
+               {0xBD, 0xBB, 0xBB},
                {0x9B, 0x99, 0x99},
-               {0x9A, 0x89, 0x89},
-               {0xFE, 0xFE, 0xFE},
        };
        u8 (*driving)[3], drive_sel;
 
@@ -58,7 +54,7 @@ static void rts5260_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
        rtsx_pci_write_register(pcr, SD30_CMD_DRIVE_SEL,
                         0xFF, driving[drive_sel][1]);
 
-       rtsx_pci_write_register(pcr, SD30_CMD_DRIVE_SEL,
+       rtsx_pci_write_register(pcr, SD30_DAT_DRIVE_SEL,
                         0xFF, driving[drive_sel][2]);
 }
 
@@ -82,26 +78,13 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)
 
        pci_read_config_dword(pdev, PCR_SETTING_REG2, &reg);
        pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
+       if (rtsx_check_mmc_support(reg))
+               pcr->extra_caps |= EXTRA_CAPS_NO_MMC;
        pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
        if (rtsx_reg_check_reverse_socket(reg))
                pcr->flags |= PCR_REVERSE_SOCKET;
 }
 
-static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
-{
-       /* Set relink_time to 0 */
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0);
-       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3,
-                               RELINK_TIME_MASK, 0);
-
-       if (pm_state == HOST_ENTER_S3)
-               rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3,
-                                       D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
-
-       rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN);
-}
-
 static int rtsx_base_enable_auto_blink(struct rtsx_pcr *pcr)
 {
        return rtsx_pci_write_register(pcr, OLT_LED_CTL,
@@ -574,6 +557,8 @@ static int rts5260_extra_init_hw(struct rtsx_pcr *pcr)
                rtsx_pci_write_register(pcr, PETXCFG,
                                 FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_HIGH);
 
+       rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x00);
+
        return 0;
 }
 
@@ -620,7 +605,6 @@ static const struct pcr_ops rts5260_pcr_ops = {
        .card_power_on = rts5260_card_power_on,
        .card_power_off = rts5260_card_power_off,
        .switch_output_voltage = rts5260_switch_output_voltage,
-       .force_power_down = rtsx_base_force_power_down,
        .stop_cmd = rts5260_stop_cmd,
        .set_l1off_cfg_sub_d0 = rts5260_set_l1off_cfg_sub_d0,
        .enable_ocp = rts5260_enable_ocp,
index 37ccc67..5d15607 100644 (file)
@@ -1096,6 +1096,20 @@ static void rtsx_pci_idle_work(struct work_struct *work)
        mutex_unlock(&pcr->pcr_mutex);
 }
 
+static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)
+{
+       /* Set relink_time to 0 */
+       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0);
+       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0);
+       rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3,
+                       RELINK_TIME_MASK, 0);
+
+       rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3,
+                       D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
+
+       rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN);
+}
+
 static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
 {
        if (pcr->ops->turn_off_led)
@@ -1109,6 +1123,8 @@ static void __maybe_unused rtsx_pci_power_off(struct rtsx_pcr *pcr, u8 pm_state)
 
        if (pcr->ops->force_power_down)
                pcr->ops->force_power_down(pcr, pm_state);
+       else
+               rtsx_base_force_power_down(pcr, pm_state);
 }
 
 void rtsx_pci_enable_ocp(struct rtsx_pcr *pcr)
@@ -1155,10 +1171,6 @@ void rtsx_pci_init_ocp(struct rtsx_pcr *pcr)
                        rtsx_pci_write_register(pcr, REG_OCPGLITCH,
                                SD_OCP_GLITCH_MASK, pcr->hw_param.ocp_glitch);
                        rtsx_pci_enable_ocp(pcr);
-               } else {
-                       /* OC power down */
-                       rtsx_pci_write_register(pcr, FPDCTL, OC_POWER_DOWN,
-                               OC_POWER_DOWN);
                }
        }
 }
@@ -1562,12 +1574,14 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
        ret = mfd_add_devices(&pcidev->dev, pcr->id, rtsx_pcr_cells,
                        ARRAY_SIZE(rtsx_pcr_cells), NULL, 0, NULL);
        if (ret < 0)
-               goto disable_irq;
+               goto free_slots;
 
        schedule_delayed_work(&pcr->idle_work, msecs_to_jiffies(200));
 
        return 0;
 
+free_slots:
+       kfree(pcr->slots);
 disable_irq:
        free_irq(pcr->irq, (void *)pcr);
 disable_msi:
index 6b322db..fe5f4ca 100644 (file)
 #define RTS522A_PM_CTRL3               0xFF7E
 
 #define RTS524A_PME_FORCE_CTL          0xFF78
+#define REG_EFUSE_BYPASS               0x08
+#define REG_EFUSE_POR                  0x04
+#define REG_EFUSE_POWER_MASK           0x03
+#define REG_EFUSE_POWERON              0x03
+#define REG_EFUSE_POWEROFF             0x00
+#define RTS5250_CLK_CFG3               0xFF79
+#define RTS525A_CFG_MEM_PD             0xF0
 #define RTS524A_PM_CTRL3               0xFF7E
+#define RTS525A_BIOS_CFG               0xFF2D
+#define RTS525A_LOAD_BIOS_FLAG 0x01
+#define RTS525A_CLEAR_BIOS_FLAG        0x00
+
+#define RTS525A_EFUSE_CTL              0xFC32
+#define REG_EFUSE_ENABLE               0x80
+#define REG_EFUSE_MODE                 0x40
+#define RTS525A_EFUSE_ADD              0xFC33
+#define REG_EFUSE_ADD_MASK             0x3F
+#define RTS525A_EFUSE_DATA             0xFC35
 
 #define LTR_ACTIVE_LATENCY_DEF         0x883C
 #define LTR_IDLE_LATENCY_DEF           0x892C
index 2591c21..26a23ab 100644 (file)
@@ -692,10 +692,6 @@ static int at24_probe(struct i2c_client *client)
        nvmem_config.word_size = 1;
        nvmem_config.size = byte_len;
 
-       at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
-       if (IS_ERR(at24->nvmem))
-               return PTR_ERR(at24->nvmem);
-
        i2c_set_clientdata(client, at24);
 
        err = regulator_enable(at24->vcc_reg);
@@ -708,6 +704,13 @@ static int at24_probe(struct i2c_client *client)
        pm_runtime_set_active(dev);
        pm_runtime_enable(dev);
 
+       at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
+       if (IS_ERR(at24->nvmem)) {
+               pm_runtime_disable(dev);
+               regulator_disable(at24->vcc_reg);
+               return PTR_ERR(at24->nvmem);
+       }
+
        /*
         * Perform a one-byte test read to verify that the
         * chip is functional.
index cde9a2f..3b7d8b7 100644 (file)
@@ -90,10 +90,10 @@ static int at25_ee_read(void *priv, unsigned int offset,
        switch (at25->addrlen) {
        default:        /* case 3 */
                *cp++ = offset >> 16;
-               /* fall through */
+               fallthrough;
        case 2:
                *cp++ = offset >> 8;
-               /* fall through */
+               fallthrough;
        case 1:
        case 0: /* can't happen: for better codegen */
                *cp++ = offset >> 0;
@@ -178,10 +178,10 @@ static int at25_ee_write(void *priv, unsigned int off, void *val, size_t count)
                switch (at25->addrlen) {
                default:        /* case 3 */
                        *cp++ = offset >> 16;
-                       /* fall through */
+                       fallthrough;
                case 2:
                        *cp++ = offset >> 8;
-                       /* fall through */
+                       fallthrough;
                case 1:
                case 0: /* can't happen: for better codegen */
                        *cp++ = offset >> 0;
@@ -261,7 +261,7 @@ static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip)
 
        if (device_property_read_u32(dev, "pagesize", &val) == 0 ||
            device_property_read_u32(dev, "at25,page-size", &val) == 0) {
-               chip->page_size = (u16)val;
+               chip->page_size = val;
        } else {
                dev_err(dev, "Error: missing \"pagesize\" property\n");
                return -ENODEV;
@@ -278,7 +278,7 @@ static int at25_fw_to_chip(struct device *dev, struct spi_eeprom *chip)
                switch (val) {
                case 9:
                        chip->flags |= EE_INSTR_BIT3_IS_ADDR;
-                       /* fall through */
+                       fallthrough;
                case 8:
                        chip->flags |= EE_ADDR1;
                        break;
@@ -348,6 +348,7 @@ static int at25_probe(struct spi_device *spi)
        spi_set_drvdata(spi, at25);
        at25->addrlen = addrlen;
 
+       at25->nvmem_config.type = NVMEM_TYPE_EEPROM;
        at25->nvmem_config.name = dev_name(&spi->dev);
        at25->nvmem_config.dev = &spi->dev;
        at25->nvmem_config.read_only = chip.flags & EE_READONLY;
@@ -358,7 +359,7 @@ static int at25_probe(struct spi_device *spi)
        at25->nvmem_config.reg_read = at25_ee_read;
        at25->nvmem_config.reg_write = at25_ee_write;
        at25->nvmem_config.priv = at25;
-       at25->nvmem_config.stride = 4;
+       at25->nvmem_config.stride = 1;
        at25->nvmem_config.word_size = 1;
        at25->nvmem_config.size = chip.byte_len;
 
index 94cfb67..7c45f82 100644 (file)
@@ -455,6 +455,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi)
        edev->pdata = pd;
 
        edev->size = 128;
+       edev->nvmem_config.type = NVMEM_TYPE_EEPROM;
        edev->nvmem_config.name = dev_name(&spi->dev);
        edev->nvmem_config.dev = &spi->dev;
        edev->nvmem_config.read_only = pd->flags & EE_READONLY;
index 7939c55..994ab67 100644 (file)
 #define FASTRPC_RMID_INIT_CREATE_ATTR  7
 #define FASTRPC_RMID_INIT_CREATE_STATIC        8
 
+/* Protection Domain(PD) ids */
+#define AUDIO_PD       (0) /* also GUEST_OS PD? */
+#define USER_PD                (1)
+#define SENSORS_PD     (2)
+
 #define miscdev_to_cctx(d) container_of(d, struct fastrpc_channel_ctx, miscdev)
 
 static const char *domains[FASTRPC_DEV_MAX] = { "adsp", "mdsp",
@@ -518,7 +523,7 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
 
        table = &a->sgt;
 
-       if (!dma_map_sg(attachment->dev, table->sgl, table->nents, dir))
+       if (!dma_map_sgtable(attachment->dev, table, dir, 0))
                return ERR_PTR(-ENOMEM);
 
        return table;
@@ -528,7 +533,7 @@ static void fastrpc_unmap_dma_buf(struct dma_buf_attachment *attach,
                                  struct sg_table *table,
                                  enum dma_data_direction dir)
 {
-       dma_unmap_sg(attach->dev, table->sgl, table->nents, dir);
+       dma_unmap_sgtable(attach->dev, table, dir, 0);
 }
 
 static void fastrpc_release(struct dma_buf *dmabuf)
@@ -1037,7 +1042,7 @@ static int fastrpc_init_create_process(struct fastrpc_user *fl,
        inbuf.pageslen = 1;
        inbuf.attrs = init.attrs;
        inbuf.siglen = init.siglen;
-       fl->pd = 1;
+       fl->pd = USER_PD;
 
        if (init.filelen && init.filefd) {
                err = fastrpc_map_create(fl, init.filefd, init.filelen, &map);
@@ -1276,7 +1281,7 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
        return 0;
 }
 
-static int fastrpc_init_attach(struct fastrpc_user *fl)
+static int fastrpc_init_attach(struct fastrpc_user *fl, int pd)
 {
        struct fastrpc_invoke_args args[1];
        int tgid = fl->tgid;
@@ -1287,7 +1292,7 @@ static int fastrpc_init_attach(struct fastrpc_user *fl)
        args[0].fd = -1;
        args[0].reserved = 0;
        sc = FASTRPC_SCALARS(FASTRPC_RMID_INIT_ATTACH, 1, 0);
-       fl->pd = 0;
+       fl->pd = pd;
 
        return fastrpc_internal_invoke(fl, true, FASTRPC_INIT_HANDLE,
                                       sc, &args[0]);
@@ -1477,7 +1482,10 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
                err = fastrpc_invoke(fl, argp);
                break;
        case FASTRPC_IOCTL_INIT_ATTACH:
-               err = fastrpc_init_attach(fl);
+               err = fastrpc_init_attach(fl, AUDIO_PD);
+               break;
+       case FASTRPC_IOCTL_INIT_ATTACH_SNS:
+               err = fastrpc_init_attach(fl, SENSORS_PD);
                break;
        case FASTRPC_IOCTL_INIT_CREATE:
                err = fastrpc_init_create_process(fl, argp);
index 8eb5d38..1640340 100644 (file)
@@ -7,7 +7,6 @@ config HABANA_AI
        tristate "HabanaAI accelerators (habanalabs)"
        depends on PCI && HAS_IOMEM
        select FRAME_VECTOR
-       select DMA_SHARED_BUFFER
        select GENERIC_ALLOCATOR
        select HWMON
        help
index b984bfa..eccd8c7 100644 (file)
@@ -3,5 +3,5 @@ HL_COMMON_FILES := common/habanalabs_drv.o common/device.o common/context.o \
                common/asid.o common/habanalabs_ioctl.o \
                common/command_buffer.o common/hw_queue.o common/irq.o \
                common/sysfs.o common/hwmon.o common/memory.o \
-               common/command_submission.o common/mmu.o common/firmware_if.o \
-               common/pci.o
+               common/command_submission.o common/mmu.o common/mmu_v1.o \
+               common/firmware_if.o common/pci.o
index 7c38c4f..901e213 100644 (file)
 
 #include <linux/mm.h>
 #include <linux/slab.h>
+#include <linux/uaccess.h>
 #include <linux/genalloc.h>
 
+static int cb_map_mem(struct hl_ctx *ctx, struct hl_cb *cb)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       struct hl_vm_va_block *va_block, *tmp;
+       dma_addr_t bus_addr;
+       u64 virt_addr;
+       u32 page_size = prop->pmmu.page_size;
+       s32 offset;
+       int rc;
+
+       if (!hdev->supports_cb_mapping) {
+               dev_err_ratelimited(hdev->dev,
+                               "Cannot map CB because no VA range is allocated for CB mapping\n");
+               return -EINVAL;
+       }
+
+       if (!hdev->mmu_enable) {
+               dev_err_ratelimited(hdev->dev,
+                               "Cannot map CB because MMU is disabled\n");
+               return -EINVAL;
+       }
+
+       INIT_LIST_HEAD(&cb->va_block_list);
+
+       for (bus_addr = cb->bus_address;
+                       bus_addr < cb->bus_address + cb->size;
+                       bus_addr += page_size) {
+
+               virt_addr = (u64) gen_pool_alloc(ctx->cb_va_pool, page_size);
+               if (!virt_addr) {
+                       dev_err(hdev->dev,
+                               "Failed to allocate device virtual address for CB\n");
+                       rc = -ENOMEM;
+                       goto err_va_pool_free;
+               }
+
+               va_block = kzalloc(sizeof(*va_block), GFP_KERNEL);
+               if (!va_block) {
+                       rc = -ENOMEM;
+                       gen_pool_free(ctx->cb_va_pool, virt_addr, page_size);
+                       goto err_va_pool_free;
+               }
+
+               va_block->start = virt_addr;
+               va_block->end = virt_addr + page_size;
+               va_block->size = page_size;
+               list_add_tail(&va_block->node, &cb->va_block_list);
+       }
+
+       mutex_lock(&ctx->mmu_lock);
+
+       bus_addr = cb->bus_address;
+       offset = 0;
+       list_for_each_entry(va_block, &cb->va_block_list, node) {
+               rc = hl_mmu_map(ctx, va_block->start, bus_addr, va_block->size,
+                               list_is_last(&va_block->node,
+                                               &cb->va_block_list));
+               if (rc) {
+                       dev_err(hdev->dev, "Failed to map VA %#llx to CB\n",
+                               va_block->start);
+                       goto err_va_umap;
+               }
+
+               bus_addr += va_block->size;
+               offset += va_block->size;
+       }
+
+       hdev->asic_funcs->mmu_invalidate_cache(hdev, false, VM_TYPE_USERPTR);
+
+       mutex_unlock(&ctx->mmu_lock);
+
+       cb->is_mmu_mapped = true;
+
+       return 0;
+
+err_va_umap:
+       list_for_each_entry(va_block, &cb->va_block_list, node) {
+               if (offset <= 0)
+                       break;
+               hl_mmu_unmap(ctx, va_block->start, va_block->size,
+                               offset <= va_block->size);
+               offset -= va_block->size;
+       }
+
+       hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
+
+       mutex_unlock(&ctx->mmu_lock);
+
+err_va_pool_free:
+       list_for_each_entry_safe(va_block, tmp, &cb->va_block_list, node) {
+               gen_pool_free(ctx->cb_va_pool, va_block->start, va_block->size);
+               list_del(&va_block->node);
+               kfree(va_block);
+       }
+
+       return rc;
+}
+
+static void cb_unmap_mem(struct hl_ctx *ctx, struct hl_cb *cb)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct hl_vm_va_block *va_block, *tmp;
+
+       mutex_lock(&ctx->mmu_lock);
+
+       list_for_each_entry(va_block, &cb->va_block_list, node)
+               if (hl_mmu_unmap(ctx, va_block->start, va_block->size,
+                               list_is_last(&va_block->node,
+                                               &cb->va_block_list)))
+                       dev_warn_ratelimited(hdev->dev,
+                                       "Failed to unmap CB's va 0x%llx\n",
+                                       va_block->start);
+
+       hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
+
+       mutex_unlock(&ctx->mmu_lock);
+
+       list_for_each_entry_safe(va_block, tmp, &cb->va_block_list, node) {
+               gen_pool_free(ctx->cb_va_pool, va_block->start, va_block->size);
+               list_del(&va_block->node);
+               kfree(va_block);
+       }
+}
+
 static void cb_fini(struct hl_device *hdev, struct hl_cb *cb)
 {
        if (cb->is_internal)
@@ -46,6 +172,11 @@ static void cb_release(struct kref *ref)
 
        hl_debugfs_remove_cb(cb);
 
+       if (cb->is_mmu_mapped)
+               cb_unmap_mem(cb->ctx, cb);
+
+       hl_ctx_put(cb->ctx);
+
        cb_do_release(hdev, cb);
 }
 
@@ -106,11 +237,12 @@ static struct hl_cb *hl_cb_alloc(struct hl_device *hdev, u32 cb_size,
 }
 
 int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
-                       u32 cb_size, u64 *handle, int ctx_id, bool internal_cb)
+                       struct hl_ctx *ctx, u32 cb_size, bool internal_cb,
+                       bool map_cb, u64 *handle)
 {
        struct hl_cb *cb;
        bool alloc_new_cb = true;
-       int rc;
+       int rc, ctx_id = ctx->asid;
 
        /*
         * Can't use generic function to check this because of special case
@@ -162,7 +294,21 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
        }
 
        cb->hdev = hdev;
-       cb->ctx_id = ctx_id;
+       cb->ctx = ctx;
+       hl_ctx_get(hdev, cb->ctx);
+
+       if (map_cb) {
+               if (ctx_id == HL_KERNEL_ASID_ID) {
+                       dev_err(hdev->dev,
+                               "CB mapping is not supported for kernel context\n");
+                       rc = -EINVAL;
+                       goto release_cb;
+               }
+
+               rc = cb_map_mem(ctx, cb);
+               if (rc)
+                       goto release_cb;
+       }
 
        spin_lock(&mgr->cb_lock);
        rc = idr_alloc(&mgr->cb_handles, cb, 1, 0, GFP_ATOMIC);
@@ -170,10 +316,10 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
 
        if (rc < 0) {
                dev_err(hdev->dev, "Failed to allocate IDR for a new CB\n");
-               goto release_cb;
+               goto unmap_mem;
        }
 
-       cb->id = rc;
+       cb->id = (u64) rc;
 
        kref_init(&cb->refcount);
        spin_lock_init(&cb->lock);
@@ -182,14 +328,18 @@ int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
         * idr is 32-bit so we can safely OR it with a mask that is above
         * 32 bit
         */
-       *handle = cb->id | HL_MMAP_CB_MASK;
+       *handle = cb->id | HL_MMAP_TYPE_CB;
        *handle <<= PAGE_SHIFT;
 
        hl_debugfs_add_cb(cb);
 
        return 0;
 
+unmap_mem:
+       if (cb->is_mmu_mapped)
+               cb_unmap_mem(cb->ctx, cb);
 release_cb:
+       hl_ctx_put(cb->ctx);
        cb_do_release(hdev, cb);
 out_err:
        *handle = 0;
@@ -249,9 +399,10 @@ int hl_cb_ioctl(struct hl_fpriv *hpriv, void *data)
                                args->in.cb_size, HL_MAX_CB_SIZE);
                        rc = -EINVAL;
                } else {
-                       rc = hl_cb_create(hdev, &hpriv->cb_mgr,
-                                       args->in.cb_size, &handle,
-                                       hpriv->ctx->asid, false);
+                       rc = hl_cb_create(hdev, &hpriv->cb_mgr, hpriv->ctx,
+                                       args->in.cb_size, false,
+                                       !!(args->in.flags & HL_CB_FLAGS_MAP),
+                                       &handle);
                }
 
                memset(args, 0, sizeof(*args));
@@ -299,11 +450,14 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
 {
        struct hl_device *hdev = hpriv->hdev;
        struct hl_cb *cb;
-       phys_addr_t address;
-       u32 handle;
+       u32 handle, user_cb_size;
        int rc;
 
+       /* We use the page offset to hold the idr and thus we need to clear
+        * it before doing the mmap itself
+        */
        handle = vma->vm_pgoff;
+       vma->vm_pgoff = 0;
 
        /* reference was taken here */
        cb = hl_cb_get(hdev, &hpriv->cb_mgr, handle);
@@ -314,7 +468,8 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
        }
 
        /* Validation check */
-       if ((vma->vm_end - vma->vm_start) != ALIGN(cb->size, PAGE_SIZE)) {
+       user_cb_size = vma->vm_end - vma->vm_start;
+       if (user_cb_size != ALIGN(cb->size, PAGE_SIZE)) {
                dev_err(hdev->dev,
                        "CB mmap failed, mmap size 0x%lx != 0x%x cb size\n",
                        vma->vm_end - vma->vm_start, cb->size);
@@ -322,6 +477,16 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
                goto put_cb;
        }
 
+       if (!access_ok((void __user *) (uintptr_t) vma->vm_start,
+                                                       user_cb_size)) {
+               dev_err(hdev->dev,
+                       "user pointer is invalid - 0x%lx\n",
+                       vma->vm_start);
+
+               rc = -EINVAL;
+               goto put_cb;
+       }
+
        spin_lock(&cb->lock);
 
        if (cb->mmap) {
@@ -344,12 +509,8 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
 
        vma->vm_private_data = cb;
 
-       /* Calculate address for CB */
-       address = virt_to_phys((void *) (uintptr_t) cb->kernel_address);
-
-       rc = hdev->asic_funcs->cb_mmap(hdev, vma, cb->kernel_address,
-                                       address, cb->size);
-
+       rc = hdev->asic_funcs->cb_mmap(hdev, vma, (void *) cb->kernel_address,
+                                       cb->bus_address, cb->size);
        if (rc) {
                spin_lock(&cb->lock);
                cb->mmap = false;
@@ -413,7 +574,7 @@ void hl_cb_mgr_fini(struct hl_device *hdev, struct hl_cb_mgr *mgr)
                if (kref_put(&cb->refcount, cb_release) != 1)
                        dev_err(hdev->dev,
                                "CB %d for CTX ID %d is still alive\n",
-                               id, cb->ctx_id);
+                               id, cb->ctx->asid);
        }
 
        idr_destroy(&mgr->cb_handles);
@@ -426,8 +587,8 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size,
        struct hl_cb *cb;
        int rc;
 
-       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, cb_size, &cb_handle,
-                       HL_KERNEL_ASID_ID, internal_cb);
+       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx, cb_size,
+                               internal_cb, false, &cb_handle);
        if (rc) {
                dev_err(hdev->dev,
                        "Failed to allocate CB for the kernel driver %d\n", rc);
@@ -483,3 +644,45 @@ int hl_cb_pool_fini(struct hl_device *hdev)
 
        return 0;
 }
+
+int hl_cb_va_pool_init(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       int rc;
+
+       if (!hdev->supports_cb_mapping)
+               return 0;
+
+       ctx->cb_va_pool = gen_pool_create(__ffs(prop->pmmu.page_size), -1);
+       if (!ctx->cb_va_pool) {
+               dev_err(hdev->dev,
+                       "Failed to create VA gen pool for CB mapping\n");
+               return -ENOMEM;
+       }
+
+       rc = gen_pool_add(ctx->cb_va_pool, prop->cb_va_start_addr,
+                       prop->cb_va_end_addr - prop->cb_va_start_addr, -1);
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Failed to add memory to VA gen pool for CB mapping\n");
+               goto err_pool_destroy;
+       }
+
+       return 0;
+
+err_pool_destroy:
+       gen_pool_destroy(ctx->cb_va_pool);
+
+       return rc;
+}
+
+void hl_cb_va_pool_fini(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+
+       if (!hdev->supports_cb_mapping)
+               return;
+
+       gen_pool_destroy(ctx->cb_va_pool);
+}
index b9840e3..b2b974e 100644 (file)
@@ -38,26 +38,10 @@ void hl_sob_reset_error(struct kref *ref)
                        hw_sob->q_idx, hw_sob->sob_id);
 }
 
-static const char *hl_fence_get_driver_name(struct dma_fence *fence)
-{
-       return "HabanaLabs";
-}
-
-static const char *hl_fence_get_timeline_name(struct dma_fence *fence)
-{
-       struct hl_cs_compl *hl_cs_compl =
-               container_of(fence, struct hl_cs_compl, base_fence);
-
-       return dev_name(hl_cs_compl->hdev->dev);
-}
-
-static bool hl_fence_enable_signaling(struct dma_fence *fence)
-{
-       return true;
-}
-
-static void hl_fence_release(struct dma_fence *fence)
+static void hl_fence_release(struct kref *kref)
 {
+       struct hl_fence *fence =
+               container_of(kref, struct hl_fence, refcount);
        struct hl_cs_compl *hl_cs_cmpl =
                container_of(fence, struct hl_cs_compl, base_fence);
        struct hl_device *hdev = hl_cs_cmpl->hdev;
@@ -99,15 +83,27 @@ static void hl_fence_release(struct dma_fence *fence)
        }
 
 free:
-       kfree_rcu(hl_cs_cmpl, base_fence.rcu);
+       kfree(hl_cs_cmpl);
+}
+
+void hl_fence_put(struct hl_fence *fence)
+{
+       if (fence)
+               kref_put(&fence->refcount, hl_fence_release);
+}
+
+void hl_fence_get(struct hl_fence *fence)
+{
+       if (fence)
+               kref_get(&fence->refcount);
 }
 
-static const struct dma_fence_ops hl_fence_ops = {
-       .get_driver_name = hl_fence_get_driver_name,
-       .get_timeline_name = hl_fence_get_timeline_name,
-       .enable_signaling = hl_fence_enable_signaling,
-       .release = hl_fence_release
-};
+static void hl_fence_init(struct hl_fence *fence)
+{
+       kref_init(&fence->refcount);
+       fence->error = 0;
+       init_completion(&fence->completion);
+}
 
 static void cs_get(struct hl_cs *cs)
 {
@@ -256,6 +252,8 @@ static void cs_counters_aggregate(struct hl_device *hdev, struct hl_ctx *ctx)
                        ctx->cs_counters.parsing_drop_cnt;
        hdev->aggregated_cs_counters.queue_full_drop_cnt +=
                        ctx->cs_counters.queue_full_drop_cnt;
+       hdev->aggregated_cs_counters.max_cs_in_flight_drop_cnt +=
+                       ctx->cs_counters.max_cs_in_flight_drop_cnt;
 }
 
 static void cs_do_release(struct kref *ref)
@@ -336,7 +334,7 @@ static void cs_do_release(struct kref *ref)
                 * In case the wait for signal CS was submitted, the put occurs
                 * in init_signal_wait_cs() right before hanging on the PQ.
                 */
-               dma_fence_put(cs->signal_fence);
+               hl_fence_put(cs->signal_fence);
        }
 
        /*
@@ -348,19 +346,18 @@ static void cs_do_release(struct kref *ref)
        hl_ctx_put(cs->ctx);
 
        /* We need to mark an error for not submitted because in that case
-        * the dma fence release flow is different. Mainly, we don't need
+        * the hl fence release flow is different. Mainly, we don't need
         * to handle hw_sob for signal/wait
         */
        if (cs->timedout)
-               dma_fence_set_error(cs->fence, -ETIMEDOUT);
+               cs->fence->error = -ETIMEDOUT;
        else if (cs->aborted)
-               dma_fence_set_error(cs->fence, -EIO);
+               cs->fence->error = -EIO;
        else if (!cs->submitted)
-               dma_fence_set_error(cs->fence, -EBUSY);
-
-       dma_fence_signal(cs->fence);
-       dma_fence_put(cs->fence);
+               cs->fence->error = -EBUSY;
 
+       complete_all(&cs->fence->completion);
+       hl_fence_put(cs->fence);
        cs_counters_aggregate(hdev, cs->ctx);
 
        kfree(cs->jobs_in_queue_cnt);
@@ -401,7 +398,7 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
                        enum hl_cs_type cs_type, struct hl_cs **cs_new)
 {
        struct hl_cs_compl *cs_cmpl;
-       struct dma_fence *other = NULL;
+       struct hl_fence *other = NULL;
        struct hl_cs *cs;
        int rc;
 
@@ -434,9 +431,11 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
        cs_cmpl->cs_seq = ctx->cs_sequence;
        other = ctx->cs_pending[cs_cmpl->cs_seq &
                                (hdev->asic_prop.max_pending_cs - 1)];
-       if ((other) && (!dma_fence_is_signaled(other))) {
-               dev_dbg(hdev->dev,
+
+       if (other && !completion_done(&other->completion)) {
+               dev_dbg_ratelimited(hdev->dev,
                        "Rejecting CS because of too many in-flights CS\n");
+               ctx->cs_counters.max_cs_in_flight_drop_cnt++;
                rc = -EAGAIN;
                goto free_fence;
        }
@@ -448,8 +447,8 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
                goto free_fence;
        }
 
-       dma_fence_init(&cs_cmpl->base_fence, &hl_fence_ops, &cs_cmpl->lock,
-                       ctx->asid, ctx->cs_sequence);
+       /* init hl_fence */
+       hl_fence_init(&cs_cmpl->base_fence);
 
        cs->sequence = cs_cmpl->cs_seq;
 
@@ -458,9 +457,9 @@ static int allocate_cs(struct hl_device *hdev, struct hl_ctx *ctx,
                                                        &cs_cmpl->base_fence;
        ctx->cs_sequence++;
 
-       dma_fence_get(&cs_cmpl->base_fence);
+       hl_fence_get(&cs_cmpl->base_fence);
 
-       dma_fence_put(other);
+       hl_fence_put(other);
 
        spin_unlock(&ctx->cs_lock);
 
@@ -690,8 +689,8 @@ static int cs_ioctl_default(struct hl_fpriv *hpriv, void __user *chunks,
                        rc = -ENOMEM;
                        if (is_kernel_allocated_cb)
                                goto release_cb;
-                       else
-                               goto free_cs_object;
+
+                       goto free_cs_object;
                }
 
                job->id = i + 1;
@@ -773,7 +772,7 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
        struct hl_ctx *ctx = hpriv->ctx;
        struct hl_cs_chunk *cs_chunk_array, *chunk;
        struct hw_queue_properties *hw_queue_prop;
-       struct dma_fence *sig_fence = NULL;
+       struct hl_fence *sig_fence = NULL;
        struct hl_cs_job *job;
        struct hl_cs *cs;
        struct hl_cb *cb;
@@ -808,6 +807,14 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
 
        /* currently it is guaranteed to have only one chunk */
        chunk = &cs_chunk_array[0];
+
+       if (chunk->queue_index >= hdev->asic_prop.max_queues) {
+               dev_err(hdev->dev, "Queue index %d is invalid\n",
+                       chunk->queue_index);
+               rc = -EINVAL;
+               goto free_cs_chunk_array;
+       }
+
        q_idx = chunk->queue_index;
        hw_queue_prop = &hdev->asic_prop.hw_queues_props[q_idx];
        q_type = hw_queue_prop->type;
@@ -875,14 +882,14 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
                        dev_err(hdev->dev,
                                "CS seq 0x%llx is not of a signal CS\n",
                                signal_seq);
-                       dma_fence_put(sig_fence);
+                       hl_fence_put(sig_fence);
                        rc = -EINVAL;
                        goto free_signal_seq_array;
                }
 
-               if (dma_fence_is_signaled(sig_fence)) {
+               if (completion_done(&sig_fence->completion)) {
                        /* signal CS already finished */
-                       dma_fence_put(sig_fence);
+                       hl_fence_put(sig_fence);
                        rc = 0;
                        goto free_signal_seq_array;
                }
@@ -894,7 +901,7 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
        rc = allocate_cs(hdev, ctx, cs_type, &cs);
        if (rc) {
                if (cs_type == CS_TYPE_WAIT)
-                       dma_fence_put(sig_fence);
+                       hl_fence_put(sig_fence);
                hl_ctx_put(ctx);
                goto free_signal_seq_array;
        }
@@ -1154,7 +1161,7 @@ out:
 static long _hl_cs_wait_ioctl(struct hl_device *hdev,
                struct hl_ctx *ctx, u64 timeout_us, u64 seq)
 {
-       struct dma_fence *fence;
+       struct hl_fence *fence;
        unsigned long timeout;
        long rc;
 
@@ -1173,12 +1180,18 @@ static long _hl_cs_wait_ioctl(struct hl_device *hdev,
                                "Can't wait on CS %llu because current CS is at seq %llu\n",
                                seq, ctx->cs_sequence);
        } else if (fence) {
-               rc = dma_fence_wait_timeout(fence, true, timeout);
+               if (!timeout_us)
+                       rc = completion_done(&fence->completion);
+               else
+                       rc = wait_for_completion_interruptible_timeout(
+                                       &fence->completion, timeout);
+
                if (fence->error == -ETIMEDOUT)
                        rc = -ETIMEDOUT;
                else if (fence->error == -EIO)
                        rc = -EIO;
-               dma_fence_put(fence);
+
+               hl_fence_put(fence);
        } else {
                dev_dbg(hdev->dev,
                        "Can't wait on seq %llu because current CS is at seq %llu (Fence is gone)\n",
index 3e37595..7a59dd7 100644 (file)
@@ -12,6 +12,7 @@
 static void hl_ctx_fini(struct hl_ctx *ctx)
 {
        struct hl_device *hdev = ctx->hdev;
+       u64 idle_mask = 0;
        int i;
 
        /*
@@ -23,11 +24,13 @@ static void hl_ctx_fini(struct hl_ctx *ctx)
         */
 
        for (i = 0 ; i < hdev->asic_prop.max_pending_cs ; i++)
-               dma_fence_put(ctx->cs_pending[i]);
+               hl_fence_put(ctx->cs_pending[i]);
 
        kfree(ctx->cs_pending);
 
        if (ctx->asid != HL_KERNEL_ASID_ID) {
+               dev_dbg(hdev->dev, "closing user context %d\n", ctx->asid);
+
                /* The engines are stopped as there is no executing CS, but the
                 * Coresight might be still working by accessing addresses
                 * related to the stopped engines. Hence stop it explicitly.
@@ -37,9 +40,18 @@ static void hl_ctx_fini(struct hl_ctx *ctx)
                if ((hdev->in_debug) && (hdev->compute_ctx == ctx))
                        hl_device_set_debug_mode(hdev, false);
 
+               hl_cb_va_pool_fini(ctx);
                hl_vm_ctx_fini(ctx);
                hl_asid_free(hdev, ctx->asid);
+
+               if ((!hdev->pldm) && (hdev->pdev) &&
+                               (!hdev->asic_funcs->is_device_idle(hdev,
+                                                       &idle_mask, NULL)))
+                       dev_notice(hdev->dev,
+                               "device not idle after user context is closed (0x%llx)\n",
+                               idle_mask);
        } else {
+               dev_dbg(hdev->dev, "closing kernel context\n");
                hl_mmu_ctx_fini(ctx);
        }
 }
@@ -128,7 +140,7 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
        atomic_set(&ctx->thread_ctx_switch_token, 1);
        ctx->thread_ctx_switch_wait_token = 0;
        ctx->cs_pending = kcalloc(hdev->asic_prop.max_pending_cs,
-                               sizeof(struct dma_fence *),
+                               sizeof(struct hl_fence *),
                                GFP_KERNEL);
        if (!ctx->cs_pending)
                return -ENOMEM;
@@ -155,15 +167,26 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)
                        goto err_asid_free;
                }
 
+               rc = hl_cb_va_pool_init(ctx);
+               if (rc) {
+                       dev_err(hdev->dev,
+                               "Failed to init VA pool for mapped CB\n");
+                       goto err_vm_ctx_fini;
+               }
+
                rc = hdev->asic_funcs->ctx_init(ctx);
                if (rc) {
                        dev_err(hdev->dev, "ctx_init failed\n");
-                       goto err_vm_ctx_fini;
+                       goto err_cb_va_pool_fini;
                }
+
+               dev_dbg(hdev->dev, "create user context %d\n", ctx->asid);
        }
 
        return 0;
 
+err_cb_va_pool_fini:
+       hl_cb_va_pool_fini(ctx);
 err_vm_ctx_fini:
        hl_vm_ctx_fini(ctx);
 err_asid_free:
@@ -184,10 +207,10 @@ int hl_ctx_put(struct hl_ctx *ctx)
        return kref_put(&ctx->refcount, hl_ctx_do_release);
 }
 
-struct dma_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq)
+struct hl_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq)
 {
        struct asic_fixed_properties *asic_prop = &ctx->hdev->asic_prop;
-       struct dma_fence *fence;
+       struct hl_fence *fence;
 
        spin_lock(&ctx->cs_lock);
 
@@ -201,8 +224,9 @@ struct dma_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq)
                return NULL;
        }
 
-       fence = dma_fence_get(
-                       ctx->cs_pending[seq & (asic_prop->max_pending_cs - 1)]);
+       fence = ctx->cs_pending[seq & (asic_prop->max_pending_cs - 1)];
+       hl_fence_get(fence);
+
        spin_unlock(&ctx->cs_lock);
 
        return fence;
index c50c6fc..912ddfa 100644 (file)
@@ -19,9 +19,9 @@
 static struct dentry *hl_debug_root;
 
 static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
-                               u8 i2c_reg, u32 *val)
+                               u8 i2c_reg, long *val)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        if (hl_device_disabled_or_in_reset(hdev))
@@ -29,14 +29,14 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_I2C_RD <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_I2C_RD <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.i2c_bus = i2c_bus;
        pkt.i2c_addr = i2c_addr;
        pkt.i2c_reg = i2c_reg;
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                               0, (long *) val);
+                                               0, val);
 
        if (rc)
                dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
@@ -47,7 +47,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
 static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
                                u8 i2c_reg, u32 val)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        if (hl_device_disabled_or_in_reset(hdev))
@@ -55,8 +55,8 @@ static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_I2C_WR <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_I2C_WR <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.i2c_bus = i2c_bus;
        pkt.i2c_addr = i2c_addr;
        pkt.i2c_reg = i2c_reg;
@@ -73,7 +73,7 @@ static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
 
 static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        if (hl_device_disabled_or_in_reset(hdev))
@@ -81,8 +81,8 @@ static void hl_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state)
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_LED_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_LED_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.led_index = cpu_to_le32(led);
        pkt.value = cpu_to_le64(state);
 
@@ -110,8 +110,8 @@ static int command_buffers_show(struct seq_file *s, void *data)
                        seq_puts(s, "---------------------------------------------------------------\n");
                }
                seq_printf(s,
-                       "   %03d        %d    0x%08x      %d          %d          %d\n",
-                       cb->id, cb->ctx_id, cb->size,
+                       "   %03llu        %d    0x%08x      %d          %d          %d\n",
+                       cb->id, cb->ctx->asid, cb->size,
                        kref_read(&cb->refcount),
                        cb->mmap, cb->cs_cnt);
        }
@@ -354,6 +354,14 @@ static inline u64 get_hop4_pte_addr(struct hl_ctx *ctx,
                                        mmu_specs->hop4_shift);
 }
 
+static inline u64 get_hop5_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_specs,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_specs->hop5_mask,
+                                       mmu_specs->hop5_shift);
+}
+
 static inline u64 get_next_hop_addr(u64 curr_pte)
 {
        if (curr_pte & PAGE_PRESENT_MASK)
@@ -377,6 +385,7 @@ static int mmu_show(struct seq_file *s, void *data)
                hop2_addr = 0, hop2_pte_addr = 0, hop2_pte = 0,
                hop3_addr = 0, hop3_pte_addr = 0, hop3_pte = 0,
                hop4_addr = 0, hop4_pte_addr = 0, hop4_pte = 0,
+               hop5_addr = 0, hop5_pte_addr = 0, hop5_pte = 0,
                virt_addr = dev_entry->mmu_addr;
 
        if (!hdev->mmu_enable)
@@ -428,20 +437,49 @@ static int mmu_show(struct seq_file *s, void *data)
        hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr);
        hop3_pte = hdev->asic_funcs->read_pte(hdev, hop3_pte_addr);
 
-       if (!(hop3_pte & LAST_MASK)) {
+       if (mmu_prop->num_hops == MMU_ARCH_5_HOPS) {
+               if (!(hop3_pte & LAST_MASK)) {
+                       hop4_addr = get_next_hop_addr(hop3_pte);
+
+                       if (hop4_addr == ULLONG_MAX)
+                               goto not_mapped;
+
+                       hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop,
+                                                       hop4_addr, virt_addr);
+                       hop4_pte = hdev->asic_funcs->read_pte(hdev,
+                                                               hop4_pte_addr);
+                       if (!(hop4_pte & PAGE_PRESENT_MASK))
+                               goto not_mapped;
+               } else {
+                       if (!(hop3_pte & PAGE_PRESENT_MASK))
+                               goto not_mapped;
+               }
+       } else {
                hop4_addr = get_next_hop_addr(hop3_pte);
 
                if (hop4_addr == ULLONG_MAX)
                        goto not_mapped;
 
-               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop4_addr,
-                                                       virt_addr);
-               hop4_pte = hdev->asic_funcs->read_pte(hdev, hop4_pte_addr);
-               if (!(hop4_pte & PAGE_PRESENT_MASK))
-                       goto not_mapped;
-       } else {
-               if (!(hop3_pte & PAGE_PRESENT_MASK))
-                       goto not_mapped;
+               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop,
+                                               hop4_addr, virt_addr);
+               hop4_pte = hdev->asic_funcs->read_pte(hdev,
+                                                       hop4_pte_addr);
+               if (!(hop4_pte & LAST_MASK)) {
+                       hop5_addr = get_next_hop_addr(hop4_pte);
+
+                       if (hop5_addr == ULLONG_MAX)
+                               goto not_mapped;
+
+                       hop5_pte_addr = get_hop5_pte_addr(ctx, mmu_prop,
+                                                       hop5_addr, virt_addr);
+                       hop5_pte = hdev->asic_funcs->read_pte(hdev,
+                                                               hop5_pte_addr);
+                       if (!(hop5_pte & PAGE_PRESENT_MASK))
+                               goto not_mapped;
+               } else {
+                       if (!(hop4_pte & PAGE_PRESENT_MASK))
+                               goto not_mapped;
+               }
        }
 
        seq_printf(s, "asid: %u, virt_addr: 0x%llx\n",
@@ -463,10 +501,22 @@ static int mmu_show(struct seq_file *s, void *data)
        seq_printf(s, "hop3_pte_addr: 0x%llx\n", hop3_pte_addr);
        seq_printf(s, "hop3_pte: 0x%llx\n", hop3_pte);
 
-       if (!(hop3_pte & LAST_MASK)) {
+       if (mmu_prop->num_hops == MMU_ARCH_5_HOPS) {
+               if (!(hop3_pte & LAST_MASK)) {
+                       seq_printf(s, "hop4_addr: 0x%llx\n", hop4_addr);
+                       seq_printf(s, "hop4_pte_addr: 0x%llx\n", hop4_pte_addr);
+                       seq_printf(s, "hop4_pte: 0x%llx\n", hop4_pte);
+               }
+       } else {
                seq_printf(s, "hop4_addr: 0x%llx\n", hop4_addr);
                seq_printf(s, "hop4_pte_addr: 0x%llx\n", hop4_pte_addr);
                seq_printf(s, "hop4_pte: 0x%llx\n", hop4_pte);
+
+               if (!(hop4_pte & LAST_MASK)) {
+                       seq_printf(s, "hop5_addr: 0x%llx\n", hop5_addr);
+                       seq_printf(s, "hop5_pte_addr: 0x%llx\n", hop5_pte_addr);
+                       seq_printf(s, "hop5_pte: 0x%llx\n", hop5_pte);
+               }
        }
 
        goto out;
@@ -827,7 +877,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
        struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
        struct hl_device *hdev = entry->hdev;
        char tmp_buf[32];
-       u32 val;
+       long val;
        ssize_t rc;
 
        if (*ppos)
@@ -842,7 +892,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
                return rc;
        }
 
-       sprintf(tmp_buf, "0x%02x\n", val);
+       sprintf(tmp_buf, "0x%02lx\n", val);
        rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
                        strlen(tmp_buf));
 
@@ -982,7 +1032,7 @@ static ssize_t hl_clk_gate_read(struct file *f, char __user *buf,
                return 0;
 
        sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask);
-       rc = simple_read_from_buffer(buf, strlen(tmp_buf) + 1, ppos, tmp_buf,
+       rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
                        strlen(tmp_buf) + 1);
 
        return rc;
index be16b75..2057222 100644 (file)
@@ -123,9 +123,13 @@ static int hl_device_release_ctrl(struct inode *inode, struct file *filp)
 static int hl_mmap(struct file *filp, struct vm_area_struct *vma)
 {
        struct hl_fpriv *hpriv = filp->private_data;
+       unsigned long vm_pgoff;
 
-       if ((vma->vm_pgoff & HL_MMAP_CB_MASK) == HL_MMAP_CB_MASK) {
-               vma->vm_pgoff ^= HL_MMAP_CB_MASK;
+       vm_pgoff = vma->vm_pgoff;
+       vma->vm_pgoff = HL_MMAP_OFFSET_VALUE_GET(vm_pgoff);
+
+       switch (vm_pgoff & HL_MMAP_TYPE_MASK) {
+       case HL_MMAP_TYPE_CB:
                return hl_cb_mmap(hpriv, vma);
        }
 
@@ -286,9 +290,9 @@ static int device_early_init(struct hl_device *hdev)
        }
 
        for (i = 0 ; i < hdev->asic_prop.completion_queues_count ; i++) {
-               snprintf(workq_name, 32, "hl-free-jobs-%u", i);
+               snprintf(workq_name, 32, "hl-free-jobs-%u", (u32) i);
                hdev->cq_wq[i] = create_singlethread_workqueue(workq_name);
-               if (hdev->cq_wq == NULL) {
+               if (hdev->cq_wq[i] == NULL) {
                        dev_err(hdev->dev, "Failed to allocate CQ workqueue\n");
                        rc = -ENOMEM;
                        goto free_cq_wq;
@@ -317,6 +321,10 @@ static int device_early_init(struct hl_device *hdev)
                goto free_chip_info;
        }
 
+       rc = hl_mmu_if_set_funcs(hdev);
+       if (rc)
+               goto free_idle_busy_ts_arr;
+
        hl_cb_mgr_init(&hdev->kernel_cb_mgr);
 
        mutex_init(&hdev->send_cpu_message_lock);
@@ -330,6 +338,8 @@ static int device_early_init(struct hl_device *hdev)
 
        return 0;
 
+free_idle_busy_ts_arr:
+       kfree(hdev->idle_busy_ts_arr);
 free_chip_info:
        kfree(hdev->hl_chip_info);
 free_eq_wq:
@@ -871,7 +881,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
                         * so this message won't be sent
                         */
                        if (hl_fw_send_pci_access_msg(hdev,
-                                       ARMCP_PACKET_DISABLE_PCI_ACCESS))
+                                       CPUCP_PACKET_DISABLE_PCI_ACCESS))
                                dev_warn(hdev->dev,
                                        "Failed to disable PCI access by F/W\n");
                }
@@ -957,14 +967,13 @@ again:
                flush_workqueue(hdev->eq_wq);
        }
 
-       /* Release kernel context */
-       if ((hard_reset) && (hl_ctx_put(hdev->kernel_ctx) == 1))
-               hdev->kernel_ctx = NULL;
-
        /* Reset the H/W. It will be in idle state after this returns */
        hdev->asic_funcs->hw_fini(hdev, hard_reset);
 
        if (hard_reset) {
+               /* Release kernel context */
+               if (hl_ctx_put(hdev->kernel_ctx) == 1)
+                       hdev->kernel_ctx = NULL;
                hl_vm_fini(hdev);
                hl_mmu_fini(hdev);
                hl_eq_reset(hdev, &hdev->event_queue);
@@ -1069,7 +1078,7 @@ again:
                        goto out_err;
                }
 
-               hl_set_max_power(hdev, hdev->max_power);
+               hl_set_max_power(hdev);
        } else {
                rc = hdev->asic_funcs->soft_reset_late_init(hdev);
                if (rc) {
@@ -1318,6 +1327,11 @@ int hl_device_init(struct hl_device *hdev, struct class *hclass)
                goto out_disabled;
        }
 
+       /* Need to call this again because the max power might change,
+        * depending on card type for certain ASICs
+        */
+       hl_set_max_power(hdev);
+
        /*
         * hl_hwmon_init() must be called after device_late_init(), because only
         * there we get the information from the device about which
@@ -1450,13 +1464,13 @@ void hl_device_fini(struct hl_device *hdev)
 
        hl_cb_pool_fini(hdev);
 
+       /* Reset the H/W. It will be in idle state after this returns */
+       hdev->asic_funcs->hw_fini(hdev, true);
+
        /* Release kernel context */
        if ((hdev->kernel_ctx) && (hl_ctx_put(hdev->kernel_ctx) != 1))
                dev_err(hdev->dev, "kernel ctx is still alive\n");
 
-       /* Reset the H/W. It will be in idle state after this returns */
-       hdev->asic_funcs->hw_fini(hdev, true);
-
        hl_vm_fini(hdev);
 
        hl_mmu_fini(hdev);
index f70302c..cd41c7c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/slab.h>
 
+#define FW_FILE_MAX_SIZE       0x1400000 /* maximum size of 20MB */
 /**
  * hl_fw_load_fw_to_device() - Load F/W code to device's memory.
  *
@@ -48,6 +49,14 @@ int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name,
 
        dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size);
 
+       if (fw_size > FW_FILE_MAX_SIZE) {
+               dev_err(hdev->dev,
+                       "FW file size %zu exceeds maximum of %u bytes\n",
+                       fw_size, FW_FILE_MAX_SIZE);
+               rc = -EINVAL;
+               goto out;
+       }
+
        fw_data = (const u64 *) fw->data;
 
        memcpy_toio(dst, fw_data, fw_size);
@@ -59,9 +68,9 @@ out:
 
 int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode)
 {
-       struct armcp_packet pkt = {};
+       struct cpucp_packet pkt = {};
 
-       pkt.ctl = cpu_to_le32(opcode << ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(opcode << CPUCP_PKT_CTL_OPCODE_SHIFT);
 
        return hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt,
                                                sizeof(pkt), 0, NULL);
@@ -70,7 +79,7 @@ int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode)
 int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
                                u16 len, u32 timeout, long *result)
 {
-       struct armcp_packet *pkt;
+       struct cpucp_packet *pkt;
        dma_addr_t pkt_dma_addr;
        u32 tmp;
        int rc = 0;
@@ -102,7 +111,7 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
        }
 
        rc = hl_poll_timeout_memory(hdev, &pkt->fence, tmp,
-                               (tmp == ARMCP_PACKET_FENCE_VAL), 1000,
+                               (tmp == CPUCP_PACKET_FENCE_VAL), 1000,
                                timeout, true);
 
        hl_hw_queue_inc_ci_kernel(hdev, hw_queue_id);
@@ -115,12 +124,12 @@ int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg,
 
        tmp = le32_to_cpu(pkt->ctl);
 
-       rc = (tmp & ARMCP_PKT_CTL_RC_MASK) >> ARMCP_PKT_CTL_RC_SHIFT;
+       rc = (tmp & CPUCP_PKT_CTL_RC_MASK) >> CPUCP_PKT_CTL_RC_SHIFT;
        if (rc) {
                dev_err(hdev->dev, "F/W ERROR %d for CPU packet %d\n",
                        rc,
-                       (tmp & ARMCP_PKT_CTL_OPCODE_MASK)
-                                               >> ARMCP_PKT_CTL_OPCODE_SHIFT);
+                       (tmp & CPUCP_PKT_CTL_OPCODE_MASK)
+                                               >> CPUCP_PKT_CTL_OPCODE_SHIFT);
                rc = -EIO;
        } else if (result) {
                *result = (long) le64_to_cpu(pkt->result);
@@ -136,14 +145,14 @@ out:
 
 int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        long result;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.value = cpu_to_le64(event_type);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
@@ -158,15 +167,15 @@ int hl_fw_unmask_irq(struct hl_device *hdev, u16 event_type)
 int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
                size_t irq_arr_size)
 {
-       struct armcp_unmask_irq_arr_packet *pkt;
+       struct cpucp_unmask_irq_arr_packet *pkt;
        size_t total_pkt_size;
        long result;
        int rc;
 
-       total_pkt_size = sizeof(struct armcp_unmask_irq_arr_packet) +
+       total_pkt_size = sizeof(struct cpucp_unmask_irq_arr_packet) +
                        irq_arr_size;
 
-       /* data should be aligned to 8 bytes in order to ArmCP to copy it */
+       /* data should be aligned to 8 bytes in order to CPU-CP to copy it */
        total_pkt_size = (total_pkt_size + 0x7) & ~0x7;
 
        /* total_pkt_size is casted to u16 later on */
@@ -182,8 +191,8 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
        pkt->length = cpu_to_le32(irq_arr_size / sizeof(irq_arr[0]));
        memcpy(&pkt->irqs, irq_arr, irq_arr_size);
 
-       pkt->armcp_pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY <<
-                                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY <<
+                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt,
                                                total_pkt_size, 0, &result);
@@ -198,19 +207,19 @@ int hl_fw_unmask_irq_arr(struct hl_device *hdev, const u32 *irq_arr,
 
 int hl_fw_test_cpu_queue(struct hl_device *hdev)
 {
-       struct armcp_packet test_pkt = {};
+       struct cpucp_packet test_pkt = {};
        long result;
        int rc;
 
-       test_pkt.ctl = cpu_to_le32(ARMCP_PACKET_TEST <<
-                                       ARMCP_PKT_CTL_OPCODE_SHIFT);
-       test_pkt.value = cpu_to_le64(ARMCP_PACKET_FENCE_VAL);
+       test_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST <<
+                                       CPUCP_PKT_CTL_OPCODE_SHIFT);
+       test_pkt.value = cpu_to_le64(CPUCP_PACKET_FENCE_VAL);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &test_pkt,
                                                sizeof(test_pkt), 0, &result);
 
        if (!rc) {
-               if (result != ARMCP_PACKET_FENCE_VAL)
+               if (result != CPUCP_PACKET_FENCE_VAL)
                        dev_err(hdev->dev,
                                "CPU queue test failed (0x%08lX)\n", result);
        } else {
@@ -242,61 +251,61 @@ void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,
 
 int hl_fw_send_heartbeat(struct hl_device *hdev)
 {
-       struct armcp_packet hb_pkt = {};
+       struct cpucp_packet hb_pkt = {};
        long result;
        int rc;
 
-       hb_pkt.ctl = cpu_to_le32(ARMCP_PACKET_TEST <<
-                                       ARMCP_PKT_CTL_OPCODE_SHIFT);
-       hb_pkt.value = cpu_to_le64(ARMCP_PACKET_FENCE_VAL);
+       hb_pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEST <<
+                                       CPUCP_PKT_CTL_OPCODE_SHIFT);
+       hb_pkt.value = cpu_to_le64(CPUCP_PACKET_FENCE_VAL);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &hb_pkt,
                                                sizeof(hb_pkt), 0, &result);
 
-       if ((rc) || (result != ARMCP_PACKET_FENCE_VAL))
+       if ((rc) || (result != CPUCP_PACKET_FENCE_VAL))
                rc = -EIO;
 
        return rc;
 }
 
-int hl_fw_armcp_info_get(struct hl_device *hdev)
+int hl_fw_cpucp_info_get(struct hl_device *hdev)
 {
        struct asic_fixed_properties *prop = &hdev->asic_prop;
-       struct armcp_packet pkt = {};
-       void *armcp_info_cpu_addr;
-       dma_addr_t armcp_info_dma_addr;
+       struct cpucp_packet pkt = {};
+       void *cpucp_info_cpu_addr;
+       dma_addr_t cpucp_info_dma_addr;
        long result;
        int rc;
 
-       armcp_info_cpu_addr =
+       cpucp_info_cpu_addr =
                        hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev,
-                                       sizeof(struct armcp_info),
-                                       &armcp_info_dma_addr);
-       if (!armcp_info_cpu_addr) {
+                                       sizeof(struct cpucp_info),
+                                       &cpucp_info_dma_addr);
+       if (!cpucp_info_cpu_addr) {
                dev_err(hdev->dev,
-                       "Failed to allocate DMA memory for ArmCP info packet\n");
+                       "Failed to allocate DMA memory for CPU-CP info packet\n");
                return -ENOMEM;
        }
 
-       memset(armcp_info_cpu_addr, 0, sizeof(struct armcp_info));
+       memset(cpucp_info_cpu_addr, 0, sizeof(struct cpucp_info));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_INFO_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
-       pkt.addr = cpu_to_le64(armcp_info_dma_addr);
-       pkt.data_max_size = cpu_to_le32(sizeof(struct armcp_info));
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_INFO_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.addr = cpu_to_le64(cpucp_info_dma_addr);
+       pkt.data_max_size = cpu_to_le32(sizeof(struct cpucp_info));
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                                       HL_ARMCP_INFO_TIMEOUT_USEC, &result);
+                                       HL_CPUCP_INFO_TIMEOUT_USEC, &result);
        if (rc) {
                dev_err(hdev->dev,
-                       "Failed to handle ArmCP info pkt, error %d\n", rc);
+                       "Failed to handle CPU-CP info pkt, error %d\n", rc);
                goto out;
        }
 
-       memcpy(&prop->armcp_info, armcp_info_cpu_addr,
-                       sizeof(prop->armcp_info));
+       memcpy(&prop->cpucp_info, cpucp_info_cpu_addr,
+                       sizeof(prop->cpucp_info));
 
-       rc = hl_build_hwmon_channel_info(hdev, prop->armcp_info.sensors);
+       rc = hl_build_hwmon_channel_info(hdev, prop->cpucp_info.sensors);
        if (rc) {
                dev_err(hdev->dev,
                        "Failed to build hwmon channel info, error %d\n", rc);
@@ -306,14 +315,14 @@ int hl_fw_armcp_info_get(struct hl_device *hdev)
 
 out:
        hdev->asic_funcs->cpu_accessible_dma_pool_free(hdev,
-                       sizeof(struct armcp_info), armcp_info_cpu_addr);
+                       sizeof(struct cpucp_info), cpucp_info_cpu_addr);
 
        return rc;
 }
 
 int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size)
 {
-       struct armcp_packet pkt = {};
+       struct cpucp_packet pkt = {};
        void *eeprom_info_cpu_addr;
        dma_addr_t eeprom_info_dma_addr;
        long result;
@@ -324,23 +333,24 @@ int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size)
                                        max_size, &eeprom_info_dma_addr);
        if (!eeprom_info_cpu_addr) {
                dev_err(hdev->dev,
-                       "Failed to allocate DMA memory for ArmCP EEPROM packet\n");
+                       "Failed to allocate DMA memory for CPU-CP EEPROM packet\n");
                return -ENOMEM;
        }
 
        memset(eeprom_info_cpu_addr, 0, max_size);
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_EEPROM_DATA_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_EEPROM_DATA_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.addr = cpu_to_le64(eeprom_info_dma_addr);
        pkt.data_max_size = cpu_to_le32(max_size);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
-                       HL_ARMCP_EEPROM_TIMEOUT_USEC, &result);
+                       HL_CPUCP_EEPROM_TIMEOUT_USEC, &result);
 
        if (rc) {
                dev_err(hdev->dev,
-                       "Failed to handle ArmCP EEPROM packet, error %d\n", rc);
+                       "Failed to handle CPU-CP EEPROM packet, error %d\n",
+                       rc);
                goto out;
        }
 
@@ -354,6 +364,77 @@ out:
        return rc;
 }
 
+int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev,
+               struct hl_info_pci_counters *counters)
+{
+       struct cpucp_packet pkt = {};
+       long result;
+       int rc;
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_PCIE_THROUGHPUT_GET <<
+                       CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+       /* Fetch PCI rx counter */
+       pkt.index = cpu_to_le32(cpucp_pcie_throughput_rx);
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+                                       HL_CPUCP_INFO_TIMEOUT_USEC, &result);
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Failed to handle CPU-CP PCI info pkt, error %d\n", rc);
+               return rc;
+       }
+       counters->rx_throughput = result;
+
+       /* Fetch PCI tx counter */
+       pkt.index = cpu_to_le32(cpucp_pcie_throughput_tx);
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+                                       HL_CPUCP_INFO_TIMEOUT_USEC, &result);
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Failed to handle CPU-CP PCI info pkt, error %d\n", rc);
+               return rc;
+       }
+       counters->tx_throughput = result;
+
+       /* Fetch PCI replay counter */
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_PCIE_REPLAY_CNT_GET <<
+                       CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+                       HL_CPUCP_INFO_TIMEOUT_USEC, &result);
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Failed to handle CPU-CP PCI info pkt, error %d\n", rc);
+               return rc;
+       }
+       counters->replay_cnt = (u32) result;
+
+       return rc;
+}
+
+int hl_fw_cpucp_total_energy_get(struct hl_device *hdev, u64 *total_energy)
+{
+       struct cpucp_packet pkt = {};
+       long result;
+       int rc;
+
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_TOTAL_ENERGY_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
+
+       rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
+                                       HL_CPUCP_INFO_TIMEOUT_USEC, &result);
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Failed to handle CpuCP total energy pkt, error %d\n",
+                               rc);
+               return rc;
+       }
+
+       *total_energy = result;
+
+       return rc;
+}
+
 static void fw_read_errors(struct hl_device *hdev, u32 boot_err0_reg)
 {
        u32 err_val;
@@ -393,8 +474,11 @@ static void fw_read_errors(struct hl_device *hdev, u32 boot_err0_reg)
                        "Device boot error - NIC F/W initialization failed\n");
 }
 
-static void hl_detect_cpu_boot_status(struct hl_device *hdev, u32 status)
+static void detect_cpu_boot_status(struct hl_device *hdev, u32 status)
 {
+       /* Some of the status codes below are deprecated in newer f/w
+        * versions but we keep them here for backward compatibility
+        */
        switch (status) {
        case CPU_BOOT_STATUS_NA:
                dev_err(hdev->dev,
@@ -440,6 +524,48 @@ static void hl_detect_cpu_boot_status(struct hl_device *hdev, u32 status)
        }
 }
 
+int hl_fw_read_preboot_ver(struct hl_device *hdev, u32 cpu_boot_status_reg,
+                               u32 boot_err0_reg, u32 timeout)
+{
+       u32 status;
+       int rc;
+
+       if (!hdev->cpu_enable)
+               return 0;
+
+       /* Need to check two possible scenarios:
+        *
+        * CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT - for newer firmwares where
+        * the preboot is waiting for the boot fit
+        *
+        * All other status values - for older firmwares where the uboot was
+        * loaded from the FLASH
+        */
+       rc = hl_poll_timeout(
+               hdev,
+               cpu_boot_status_reg,
+               status,
+               (status == CPU_BOOT_STATUS_IN_UBOOT) ||
+               (status == CPU_BOOT_STATUS_DRAM_RDY) ||
+               (status == CPU_BOOT_STATUS_NIC_FW_RDY) ||
+               (status == CPU_BOOT_STATUS_READY_TO_BOOT) ||
+               (status == CPU_BOOT_STATUS_SRAM_AVAIL) ||
+               (status == CPU_BOOT_STATUS_WAITING_FOR_BOOT_FIT),
+               10000,
+               timeout);
+
+       if (rc) {
+               dev_err(hdev->dev, "Failed to read preboot version\n");
+               detect_cpu_boot_status(hdev, status);
+               fw_read_errors(hdev, boot_err0_reg);
+               return -EIO;
+       }
+
+       hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_PREBOOT);
+
+       return 0;
+}
+
 int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
                        u32 msg_to_cpu_reg, u32 cpu_msg_status_reg,
                        u32 boot_err0_reg, bool skip_bmc,
@@ -505,15 +631,11 @@ int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
                10000,
                cpu_timeout);
 
-       /* Read U-Boot, preboot versions now in case we will later fail */
+       /* Read U-Boot version now in case we will later fail */
        hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_UBOOT);
-       hdev->asic_funcs->read_device_fw_version(hdev, FW_COMP_PREBOOT);
 
-       /* Some of the status codes below are deprecated in newer f/w
-        * versions but we keep them here for backward compatibility
-        */
        if (rc) {
-               hl_detect_cpu_boot_status(hdev, status);
+               detect_cpu_boot_status(hdev, status);
                rc = -EIO;
                goto out;
        }
index 018d9d6..80d4d73 100644 (file)
@@ -8,21 +8,33 @@
 #ifndef HABANALABSP_H_
 #define HABANALABSP_H_
 
-#include "../include/common/armcp_if.h"
+#include "../include/common/cpucp_if.h"
 #include "../include/common/qman_if.h"
 #include <uapi/misc/habanalabs.h>
 
 #include <linux/cdev.h>
 #include <linux/iopoll.h>
 #include <linux/irqreturn.h>
-#include <linux/dma-fence.h>
 #include <linux/dma-direction.h>
 #include <linux/scatterlist.h>
 #include <linux/hashtable.h>
+#include <linux/bitfield.h>
 
 #define HL_NAME                                "habanalabs"
 
-#define HL_MMAP_CB_MASK                        (0x8000000000000000ull >> PAGE_SHIFT)
+/* Use upper bits of mmap offset to store habana driver specific information.
+ * bits[63:62] - Encode mmap type
+ * bits[45:0]  - mmap offset value
+ *
+ * NOTE: struct vm_area_struct.vm_pgoff uses offset in pages. Hence, these
+ *  defines are w.r.t to PAGE_SIZE
+ */
+#define HL_MMAP_TYPE_SHIFT             (62 - PAGE_SHIFT)
+#define HL_MMAP_TYPE_MASK              (0x3ull << HL_MMAP_TYPE_SHIFT)
+#define HL_MMAP_TYPE_CB                        (0x2ull << HL_MMAP_TYPE_SHIFT)
+
+#define HL_MMAP_OFFSET_VALUE_MASK      (0x3FFFFFFFFFFFull >> PAGE_SHIFT)
+#define HL_MMAP_OFFSET_VALUE_GET(off)  (off & HL_MMAP_OFFSET_VALUE_MASK)
 
 #define HL_PENDING_RESET_PER_SEC       30
 
@@ -34,8 +46,8 @@
 
 #define HL_PLL_LOW_JOB_FREQ_USEC       5000000 /* 5 s */
 
-#define HL_ARMCP_INFO_TIMEOUT_USEC     10000000 /* 10s */
-#define HL_ARMCP_EEPROM_TIMEOUT_USEC   10000000 /* 10s */
+#define HL_CPUCP_INFO_TIMEOUT_USEC     10000000 /* 10s */
+#define HL_CPUCP_EEPROM_TIMEOUT_USEC   10000000 /* 10s */
 
 #define HL_PCI_ELBI_TIMEOUT_MSEC       10 /* 10ms */
 
@@ -66,6 +78,8 @@
 
 #define HL_PCI_NUM_BARS                        6
 
+#define HL_MAX_DCORES                  4
+
 /**
  * struct pgt_info - MMU hop page info.
  * @node: hash linked-list node for the pgts shadow hash of pgts.
@@ -222,12 +236,15 @@ enum hl_device_hw_state {
  * @hop2_shift: shift of hop 2 mask.
  * @hop3_shift: shift of hop 3 mask.
  * @hop4_shift: shift of hop 4 mask.
+ * @hop5_shift: shift of hop 5 mask.
  * @hop0_mask: mask to get the PTE address in hop 0.
  * @hop1_mask: mask to get the PTE address in hop 1.
  * @hop2_mask: mask to get the PTE address in hop 2.
  * @hop3_mask: mask to get the PTE address in hop 3.
  * @hop4_mask: mask to get the PTE address in hop 4.
+ * @hop5_mask: mask to get the PTE address in hop 5.
  * @page_size: default page size used to allocate memory.
+ * @num_hops: The amount of hops supported by the translation table.
  */
 struct hl_mmu_properties {
        u64     start_addr;
@@ -237,18 +254,21 @@ struct hl_mmu_properties {
        u64     hop2_shift;
        u64     hop3_shift;
        u64     hop4_shift;
+       u64     hop5_shift;
        u64     hop0_mask;
        u64     hop1_mask;
        u64     hop2_mask;
        u64     hop3_mask;
        u64     hop4_mask;
+       u64     hop5_mask;
        u32     page_size;
+       u32     num_hops;
 };
 
 /**
  * struct asic_fixed_properties - ASIC specific immutable properties.
  * @hw_queues_props: H/W queues properties.
- * @armcp_info: received various information from ArmCP regarding the H/W, e.g.
+ * @cpucp_info: received various information from CPU-CP regarding the H/W, e.g.
  *             available sensors.
  * @uboot_ver: F/W U-boot version.
  * @preboot_ver: F/W Preboot version.
@@ -271,6 +291,10 @@ struct hl_mmu_properties {
  * @pcie_aux_dbi_reg_addr: Address of the PCIE_AUX DBI register.
  * @mmu_pgt_addr: base physical address in DRAM of MMU page tables.
  * @mmu_dram_default_page_addr: DRAM default page physical address.
+ * @cb_va_start_addr: virtual start address of command buffers which are mapped
+ *                    to the device's MMU.
+ * @cb_va_end_addr: virtual end address of command buffers which are mapped to
+ *                  the device's MMU.
  * @mmu_pgt_size: MMU page tables total size.
  * @mmu_pte_size: PTE size in MMU page tables.
  * @mmu_hop_table_size: MMU hop table size.
@@ -292,12 +316,16 @@ struct hl_mmu_properties {
  * @max_queues: maximum amount of queues in the system
  * @sync_stream_first_sob: first sync object available for sync stream use
  * @sync_stream_first_mon: first monitor available for sync stream use
+ * @first_available_user_sob: first sob available for the user
+ * @first_available_user_mon: first monitor available for the user
  * @tpc_enabled_mask: which TPCs are enabled.
  * @completion_queues_count: number of completion queues.
+ * @fw_security_disabled: true if security measures are disabled in firmware,
+ *                        false otherwise
  */
 struct asic_fixed_properties {
        struct hw_queue_properties      *hw_queues_props;
-       struct armcp_info               armcp_info;
+       struct cpucp_info               cpucp_info;
        char                            uboot_ver[VERSION_MAX_LEN];
        char                            preboot_ver[VERSION_MAX_LEN];
        struct hl_mmu_properties        dmmu;
@@ -317,6 +345,8 @@ struct asic_fixed_properties {
        u64                             pcie_aux_dbi_reg_addr;
        u64                             mmu_pgt_addr;
        u64                             mmu_dram_default_page_addr;
+       u64                             cb_va_start_addr;
+       u64                             cb_va_end_addr;
        u32                             mmu_pgt_size;
        u32                             mmu_pte_size;
        u32                             mmu_hop_table_size;
@@ -338,13 +368,29 @@ struct asic_fixed_properties {
        u32                             max_queues;
        u16                             sync_stream_first_sob;
        u16                             sync_stream_first_mon;
+       u16                             first_available_user_sob[HL_MAX_DCORES];
+       u16                             first_available_user_mon[HL_MAX_DCORES];
        u8                              tpc_enabled_mask;
        u8                              completion_queues_count;
+       u8                              fw_security_disabled;
+};
+
+/**
+ * struct hl_fence - software synchronization primitive
+ * @completion: fence is implemented using completion
+ * @refcount: refcount for this fence
+ * @error: mark this fence with error
+ *
+ */
+struct hl_fence {
+       struct completion       completion;
+       struct kref             refcount;
+       int                     error;
 };
 
 /**
  * struct hl_cs_compl - command submission completion object.
- * @base_fence: kernel fence object.
+ * @base_fence: hl fence object.
  * @lock: spinlock to protect fence.
  * @hdev: habanalabs device structure.
  * @hw_sob: the H/W SOB used in this signal/wait CS.
@@ -353,7 +399,7 @@ struct asic_fixed_properties {
  * @sob_val: the SOB value that is used in this signal/wait CS.
  */
 struct hl_cs_compl {
-       struct dma_fence        base_fence;
+       struct hl_fence         base_fence;
        spinlock_t              lock;
        struct hl_device        *hdev;
        struct hl_hw_sob        *hw_sob;
@@ -380,36 +426,41 @@ struct hl_cb_mgr {
  * struct hl_cb - describes a Command Buffer.
  * @refcount: reference counter for usage of the CB.
  * @hdev: pointer to device this CB belongs to.
+ * @ctx: pointer to the CB owner's context.
  * @lock: spinlock to protect mmap/cs flows.
  * @debugfs_list: node in debugfs list of command buffers.
  * @pool_list: node in pool list of command buffers.
+ * @va_block_list: list of virtual addresses blocks of the CB if it is mapped to
+ *                 the device's MMU.
+ * @id: the CB's ID.
  * @kernel_address: Holds the CB's kernel virtual address.
  * @bus_address: Holds the CB's DMA address.
  * @mmap_size: Holds the CB's size that was mmaped.
  * @size: holds the CB's size.
- * @id: the CB's ID.
  * @cs_cnt: holds number of CS that this CB participates in.
- * @ctx_id: holds the ID of the owner's context.
  * @mmap: true if the CB is currently mmaped to user.
  * @is_pool: true if CB was acquired from the pool, false otherwise.
  * @is_internal: internaly allocated
+ * @is_mmu_mapped: true if the CB is mapped to the device's MMU.
  */
 struct hl_cb {
        struct kref             refcount;
        struct hl_device        *hdev;
+       struct hl_ctx           *ctx;
        spinlock_t              lock;
        struct list_head        debugfs_list;
        struct list_head        pool_list;
+       struct list_head        va_block_list;
+       u64                     id;
        u64                     kernel_address;
        dma_addr_t              bus_address;
        u32                     mmap_size;
        u32                     size;
-       u32                     id;
        u32                     cs_cnt;
-       u32                     ctx_id;
        u8                      mmap;
        u8                      is_pool;
        u8                      is_internal;
+       u8                      is_mmu_mapped;
 };
 
 
@@ -435,7 +486,7 @@ struct hl_cs_job;
 #define HL_EQ_LENGTH                   64
 #define HL_EQ_SIZE_IN_BYTES            (HL_EQ_LENGTH * HL_EQ_ENTRY_SIZE)
 
-/* Host <-> ArmCP shared memory size */
+/* Host <-> CPU-CP shared memory size */
 #define HL_CPU_ACCESSIBLE_MEM_SIZE     SZ_2M
 
 /**
@@ -617,7 +668,7 @@ enum div_select_defs {
  * @debugfs_read32: debug interface for reading u32 from DRAM/SRAM.
  * @debugfs_write32: debug interface for writing u32 to DRAM/SRAM.
  * @add_device_attr: add ASIC specific device attributes.
- * @handle_eqe: handle event queue entry (IRQ) from ArmCP.
+ * @handle_eqe: handle event queue entry (IRQ) from CPU-CP.
  * @set_pll_profile: change PLL profile (manual/automatic).
  * @get_events_stat: retrieve event queue entries histogram.
  * @read_pte: read MMU page table entry from DRAM.
@@ -626,7 +677,7 @@ enum div_select_defs {
  *                        (L1 only) or hard (L0 & L1) flush.
  * @mmu_invalidate_cache_range: flush specific MMU STLB cache lines with
  *                              ASID-VA-size mask.
- * @send_heartbeat: send is-alive packet to ArmCP and verify response.
+ * @send_heartbeat: send is-alive packet to CPU-CP and verify response.
  * @set_clock_gating: enable/disable clock gating per engine according to
  *                    clock gating mask in hdev
  * @disable_clock_gating: disable clock gating completely
@@ -644,8 +695,6 @@ enum div_select_defs {
  *                    ASIC
  * @get_hw_state: retrieve the H/W state
  * @pci_bars_map: Map PCI BARs.
- * @set_dram_bar_base: Set DRAM BAR to map specific device address. Returns
- *                     old address the bar pointed to or U64_MAX for failure
  * @init_iatu: Initialize the iATU unit inside the PCI controller.
  * @rreg: Read a register. Needed for simulator support.
  * @wreg: Write a register. Needed for simulator support.
@@ -679,7 +728,7 @@ struct hl_asic_funcs {
        int (*suspend)(struct hl_device *hdev);
        int (*resume)(struct hl_device *hdev);
        int (*cb_mmap)(struct hl_device *hdev, struct vm_area_struct *vma,
-                       u64 kaddress, phys_addr_t paddress, u32 size);
+                       void *cpu_addr, dma_addr_t dma_addr, size_t size);
        void (*ring_doorbell)(struct hl_device *hdev, u32 hw_queue_id, u32 pi);
        void (*pqe_write)(struct hl_device *hdev, __le64 *pqe,
                        struct hl_bd *bd);
@@ -736,7 +785,7 @@ struct hl_asic_funcs {
        void (*set_clock_gating)(struct hl_device *hdev);
        void (*disable_clock_gating)(struct hl_device *hdev);
        int (*debug_coresight)(struct hl_device *hdev, void *data);
-       bool (*is_device_idle)(struct hl_device *hdev, u32 *mask,
+       bool (*is_device_idle)(struct hl_device *hdev, u64 *mask,
                                struct seq_file *s);
        int (*soft_reset_late_init)(struct hl_device *hdev);
        void (*hw_queues_lock)(struct hl_device *hdev);
@@ -748,7 +797,6 @@ struct hl_asic_funcs {
                                u16 len, u32 timeout, long *result);
        enum hl_device_hw_state (*get_hw_state)(struct hl_device *hdev);
        int (*pci_bars_map)(struct hl_device *hdev);
-       u64 (*set_dram_bar_base)(struct hl_device *hdev, u64 addr);
        int (*init_iatu)(struct hl_device *hdev);
        u32 (*rreg)(struct hl_device *hdev, u32 reg);
        void (*wreg)(struct hl_device *hdev, u32 reg, u32 val);
@@ -800,7 +848,7 @@ struct hl_va_range {
  * @hdev: pointer to the device structure.
  * @refcount: reference counter for the context. Context is released only when
  *             this hits 0l. It is incremented on CS and CS_WAIT.
- * @cs_pending: array of DMA fence objects representing pending CS.
+ * @cs_pending: array of hl fence objects representing pending CS.
  * @host_va_range: holds available virtual addresses for host mappings.
  * @host_huge_va_range: holds available virtual addresses for host mappings
  *                      with huge pages.
@@ -809,6 +857,8 @@ struct hl_va_range {
  * @mmu_lock: protects the MMU page tables. Any change to the PGT, modifying the
  *            MMU hash or walking the PGT requires talking this lock.
  * @debugfs_list: node in debugfs list of contexts.
+ * @cb_va_pool: device VA pool for command buffers which are mapped to the
+ *              device's MMU.
  * @cs_sequence: sequence number for CS. Value is assigned to a CS and passed
  *                     to user so user could inquire about CS. It is used as
  *                     index to cs_pending array.
@@ -832,7 +882,7 @@ struct hl_ctx {
        struct hl_fpriv         *hpriv;
        struct hl_device        *hdev;
        struct kref             refcount;
-       struct dma_fence        **cs_pending;
+       struct hl_fence         **cs_pending;
        struct hl_va_range      *host_va_range;
        struct hl_va_range      *host_huge_va_range;
        struct hl_va_range      *dram_va_range;
@@ -840,6 +890,7 @@ struct hl_ctx {
        struct mutex            mmu_lock;
        struct list_head        debugfs_list;
        struct hl_cs_counters   cs_counters;
+       struct gen_pool         *cb_va_pool;
        u64                     cs_sequence;
        u64                     *dram_default_hops;
        spinlock_t              cs_lock;
@@ -919,8 +970,8 @@ struct hl_cs {
        struct list_head        job_list;
        spinlock_t              job_lock;
        struct kref             refcount;
-       struct dma_fence        *fence;
-       struct dma_fence        *signal_fence;
+       struct hl_fence         *fence;
+       struct hl_fence         *signal_fence;
        struct work_struct      finish_work;
        struct delayed_work     work_tdr;
        struct list_head        mirror_node;
@@ -1395,6 +1446,44 @@ struct hl_device_idle_busy_ts {
        ktime_t                         busy_to_idle_ts;
 };
 
+
+/**
+ * struct hl_mmu_priv - used for holding per-device mmu internal information.
+ * @mmu_pgt_pool: pool of page tables used by MMU for allocating hops.
+ * @mmu_shadow_hop0: shadow array of hop0 tables.
+ */
+struct hl_mmu_priv {
+       struct gen_pool *mmu_pgt_pool;
+       void *mmu_shadow_hop0;
+};
+
+/**
+ * struct hl_mmu_funcs - Device related MMU functions.
+ * @init: initialize the MMU module.
+ * @fini: release the MMU module.
+ * @ctx_init: Initialize a context for using the MMU module.
+ * @ctx_fini: disable a ctx from using the mmu module.
+ * @map: maps a virtual address to physical address for a context.
+ * @unmap: unmap a virtual address of a context.
+ * @flush: flush all writes from all cores to reach device MMU.
+ * @swap_out: marks all mapping of the given context as swapped out.
+ * @swap_in: marks all mapping of the given context as swapped in.
+ */
+struct hl_mmu_funcs {
+       int (*init)(struct hl_device *hdev);
+       void (*fini)(struct hl_device *hdev);
+       int (*ctx_init)(struct hl_ctx *ctx);
+       void (*ctx_fini)(struct hl_ctx *ctx);
+       int (*map)(struct hl_ctx *ctx,
+                       u64 virt_addr, u64 phys_addr, u32 page_size,
+                       bool is_dram_addr);
+       int (*unmap)(struct hl_ctx *ctx,
+                       u64 virt_addr, bool is_dram_addr);
+       void (*flush)(struct hl_ctx *ctx);
+       void (*swap_out)(struct hl_ctx *ctx);
+       void (*swap_in)(struct hl_ctx *ctx);
+};
+
 /**
  * struct hl_device - habanalabs device structure.
  * @pdev: pointer to PCI device, can be NULL in case of simulator device.
@@ -1407,8 +1496,8 @@ struct hl_device_idle_busy_ts {
  * @dev: related kernel basic device structure.
  * @dev_ctrl: related kernel device structure for the control device
  * @work_freq: delayed work to lower device frequency if possible.
- * @work_heartbeat: delayed work for ArmCP is-alive check.
- * @asic_name: ASIC specific nmae.
+ * @work_heartbeat: delayed work for CPU-CP is-alive check.
+ * @asic_name: ASIC specific name.
  * @asic_type: ASIC specific type.
  * @completion_queue: array of hl_cq.
  * @cq_wq: work queues of completion queues for executing work in process
@@ -1419,22 +1508,20 @@ struct hl_device_idle_busy_ts {
  * @hw_queues_mirror_list: CS mirror list for TDR.
  * @hw_queues_mirror_lock: protects hw_queues_mirror_list.
  * @kernel_cb_mgr: command buffer manager for creating/destroying/handling CGs.
- * @event_queue: event queue for IRQ from ArmCP.
+ * @event_queue: event queue for IRQ from CPU-CP.
  * @dma_pool: DMA pool for small allocations.
- * @cpu_accessible_dma_mem: Host <-> ArmCP shared memory CPU address.
- * @cpu_accessible_dma_address: Host <-> ArmCP shared memory DMA address.
- * @cpu_accessible_dma_pool: Host <-> ArmCP shared memory pool.
+ * @cpu_accessible_dma_mem: Host <-> CPU-CP shared memory CPU address.
+ * @cpu_accessible_dma_address: Host <-> CPU-CP shared memory DMA address.
+ * @cpu_accessible_dma_pool: Host <-> CPU-CP shared memory pool.
  * @asid_bitmap: holds used/available ASIDs.
  * @asid_mutex: protects asid_bitmap.
- * @send_cpu_message_lock: enforces only one message in Host <-> ArmCP queue.
+ * @send_cpu_message_lock: enforces only one message in Host <-> CPU-CP queue.
  * @debug_lock: protects critical section of setting debug mode for device
  * @asic_prop: ASIC specific immutable properties.
  * @asic_funcs: ASIC specific functions.
  * @asic_specific: ASIC specific information to use only from ASIC files.
- * @mmu_pgt_pool: pool of available MMU hops.
  * @vm: virtual memory manager for MMU.
  * @mmu_cache_lock: protects MMU cache invalidation as it can serve one context.
- * @mmu_shadow_hop0: shadow mapping of the MMU hop 0 zone.
  * @hwmon_dev: H/W monitor device.
  * @pm_mng_profile: current power management profile.
  * @hl_chip_info: ASIC's sensors information.
@@ -1452,6 +1539,8 @@ struct hl_device_idle_busy_ts {
  * @idle_busy_ts_arr: array to hold time stamps of transitions from idle to busy
  *                    and vice-versa
  * @aggregated_cs_counters: aggregated cs counters among all contexts
+ * @mmu_priv: device-specific MMU data.
+ * @mmu_func: device-related MMU functions.
  * @dram_used_mem: current DRAM memory consumption.
  * @timeout_jiffies: device CS timeout value.
  * @max_power: the max power of the device, as configured by the sysadmin. This
@@ -1462,6 +1551,8 @@ struct hl_device_idle_busy_ts {
  *                     details.
  * @in_reset: is device in reset flow.
  * @curr_pll_profile: current PLL profile.
+ * @card_type: Various ASICs have several card types. This indicates the card
+ *             type of the current device.
  * @cs_active_cnt: number of active command submissions on this device (active
  *                 means already in H/W queues)
  * @major: habanalabs kernel driver major.
@@ -1469,6 +1560,7 @@ struct hl_device_idle_busy_ts {
  * @soft_reset_cnt: number of soft reset since the driver was loaded.
  * @hard_reset_cnt: number of hard reset since the driver was loaded.
  * @idle_busy_ts_idx: index of current entry in idle_busy_ts_arr
+ * @clk_throttling_reason: bitmask represents the current clk throttling reasons
  * @id: device minor.
  * @id_control: minor of the control device
  * @cpu_pci_msb_addr: 50-bit extension bits for the device CPU's 40-bit
@@ -1477,7 +1569,7 @@ struct hl_device_idle_busy_ts {
  * @late_init_done: is late init stage was done during initialization.
  * @hwmon_initialized: is H/W monitor sensors was initialized.
  * @hard_reset_pending: is there a hard reset work pending.
- * @heartbeat: is heartbeat sanity check towards ArmCP enabled.
+ * @heartbeat: is heartbeat sanity check towards CPU-CP enabled.
  * @reset_on_lockup: true if a reset should be done in case of stuck CS, false
  *                   otherwise.
  * @dram_supports_virtual_memory: is MMU enabled towards DRAM.
@@ -1499,6 +1591,7 @@ struct hl_device_idle_busy_ts {
  * @sync_stream_queue_idx: helper index for sync stream queues initialization.
  * @supports_coresight: is CoreSight supported.
  * @supports_soft_reset: is soft reset supported.
+ * @supports_cb_mapping: is mapping a CB to the device's MMU supported.
  */
 struct hl_device {
        struct pci_dev                  *pdev;
@@ -1511,7 +1604,7 @@ struct hl_device {
        struct device                   *dev_ctrl;
        struct delayed_work             work_freq;
        struct delayed_work             work_heartbeat;
-       char                            asic_name[16];
+       char                            asic_name[32];
        enum hl_asic_type               asic_type;
        struct hl_cq                    *completion_queue;
        struct workqueue_struct         **cq_wq;
@@ -1533,10 +1626,8 @@ struct hl_device {
        struct asic_fixed_properties    asic_prop;
        const struct hl_asic_funcs      *asic_funcs;
        void                            *asic_specific;
-       struct gen_pool                 *mmu_pgt_pool;
        struct hl_vm                    vm;
        struct mutex                    mmu_cache_lock;
-       void                            *mmu_shadow_hop0;
        struct device                   *hwmon_dev;
        enum hl_pm_mng_profile          pm_mng_profile;
        struct hwmon_chip_info          *hl_chip_info;
@@ -1560,18 +1651,23 @@ struct hl_device {
 
        struct hl_cs_counters           aggregated_cs_counters;
 
+       struct hl_mmu_priv              mmu_priv;
+       struct hl_mmu_funcs             mmu_func;
+
        atomic64_t                      dram_used_mem;
        u64                             timeout_jiffies;
        u64                             max_power;
        u64                             clock_gating_mask;
        atomic_t                        in_reset;
        enum hl_pll_frequency           curr_pll_profile;
+       enum cpucp_card_types           card_type;
        int                             cs_active_cnt;
        u32                             major;
        u32                             high_pll;
        u32                             soft_reset_cnt;
        u32                             hard_reset_cnt;
        u32                             idle_busy_ts_idx;
+       u32                             clk_throttling_reason;
        u16                             id;
        u16                             id_control;
        u16                             cpu_pci_msb_addr;
@@ -1595,6 +1691,7 @@ struct hl_device {
        u8                              sync_stream_queue_idx;
        u8                              supports_coresight;
        u8                              supports_soft_reset;
+       u8                              supports_cb_mapping;
 
        /* Parameters for bring-up */
        u8                              mmu_enable;
@@ -1651,7 +1748,7 @@ struct hl_ioctl_desc {
  *
  * Return: true if the area is inside the valid range, false otherwise.
  */
-static inline bool hl_mem_area_inside_range(u64 address, u32 size,
+static inline bool hl_mem_area_inside_range(u64 address, u64 size,
                                u64 range_start_address, u64 range_end_address)
 {
        u64 end_address = address + size;
@@ -1736,7 +1833,7 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx);
 void hl_ctx_do_release(struct kref *ref);
 void hl_ctx_get(struct hl_device *hdev,        struct hl_ctx *ctx);
 int hl_ctx_put(struct hl_ctx *ctx);
-struct dma_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq);
+struct hl_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq);
 void hl_ctx_mgr_init(struct hl_ctx_mgr *mgr);
 void hl_ctx_mgr_fini(struct hl_device *hdev, struct hl_ctx_mgr *mgr);
 
@@ -1752,7 +1849,7 @@ int hl_device_set_frequency(struct hl_device *hdev, enum hl_pll_frequency freq);
 uint32_t hl_device_utilization(struct hl_device *hdev, uint32_t period_ms);
 
 int hl_build_hwmon_channel_info(struct hl_device *hdev,
-               struct armcp_sensor *sensors_arr);
+               struct cpucp_sensor *sensors_arr);
 
 int hl_sysfs_init(struct hl_device *hdev);
 void hl_sysfs_fini(struct hl_device *hdev);
@@ -1760,8 +1857,9 @@ void hl_sysfs_fini(struct hl_device *hdev);
 int hl_hwmon_init(struct hl_device *hdev);
 void hl_hwmon_fini(struct hl_device *hdev);
 
-int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr, u32 cb_size,
-               u64 *handle, int ctx_id, bool internal_cb);
+int hl_cb_create(struct hl_device *hdev, struct hl_cb_mgr *mgr,
+                       struct hl_ctx *ctx, u32 cb_size, bool internal_cb,
+                       bool map_cb, u64 *handle);
 int hl_cb_destroy(struct hl_device *hdev, struct hl_cb_mgr *mgr, u64 cb_handle);
 int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma);
 struct hl_cb *hl_cb_get(struct hl_device *hdev,        struct hl_cb_mgr *mgr,
@@ -1773,11 +1871,15 @@ struct hl_cb *hl_cb_kernel_create(struct hl_device *hdev, u32 cb_size,
                                        bool internal_cb);
 int hl_cb_pool_init(struct hl_device *hdev);
 int hl_cb_pool_fini(struct hl_device *hdev);
+int hl_cb_va_pool_init(struct hl_ctx *ctx);
+void hl_cb_va_pool_fini(struct hl_ctx *ctx);
 
 void hl_cs_rollback_all(struct hl_device *hdev);
 struct hl_cs_job *hl_cs_allocate_job(struct hl_device *hdev,
                enum hl_queue_type queue_type, bool is_kernel_allocated_cb);
 void hl_sob_reset_error(struct kref *ref);
+void hl_fence_put(struct hl_fence *fence);
+void hl_fence_get(struct hl_fence *fence);
 
 void goya_set_asic_funcs(struct hl_device *hdev);
 void gaudi_set_asic_funcs(struct hl_device *hdev);
@@ -1807,6 +1909,8 @@ int hl_mmu_unmap(struct hl_ctx *ctx, u64 virt_addr, u32 page_size,
                bool flush_pte);
 void hl_mmu_swap_out(struct hl_ctx *ctx);
 void hl_mmu_swap_in(struct hl_ctx *ctx);
+int hl_mmu_if_set_funcs(struct hl_device *hdev);
+void hl_mmu_v1_set_funcs(struct hl_device *hdev);
 
 int hl_fw_load_fw_to_device(struct hl_device *hdev, const char *fw_name,
                                void __iomem *dst);
@@ -1822,23 +1926,28 @@ void *hl_fw_cpu_accessible_dma_pool_alloc(struct hl_device *hdev, size_t size,
 void hl_fw_cpu_accessible_dma_pool_free(struct hl_device *hdev, size_t size,
                                        void *vaddr);
 int hl_fw_send_heartbeat(struct hl_device *hdev);
-int hl_fw_armcp_info_get(struct hl_device *hdev);
+int hl_fw_cpucp_info_get(struct hl_device *hdev);
 int hl_fw_get_eeprom_data(struct hl_device *hdev, void *data, size_t max_size);
+int hl_fw_cpucp_pci_counters_get(struct hl_device *hdev,
+               struct hl_info_pci_counters *counters);
+int hl_fw_cpucp_total_energy_get(struct hl_device *hdev,
+                       u64 *total_energy);
 int hl_fw_init_cpu(struct hl_device *hdev, u32 cpu_boot_status_reg,
                        u32 msg_to_cpu_reg, u32 cpu_msg_status_reg,
                        u32 boot_err0_reg, bool skip_bmc,
                        u32 cpu_timeout, u32 boot_fit_timeout);
+int hl_fw_read_preboot_ver(struct hl_device *hdev, u32 cpu_boot_status_reg,
+                               u32 boot_err0_reg, u32 timeout);
 
 int hl_pci_bars_map(struct hl_device *hdev, const char * const name[3],
                        bool is_wc[3]);
 int hl_pci_iatu_write(struct hl_device *hdev, u32 addr, u32 data);
-int hl_pci_set_dram_bar_base(struct hl_device *hdev, u8 inbound_region, u8 bar,
-                               u64 addr);
 int hl_pci_set_inbound_region(struct hl_device *hdev, u8 region,
                struct hl_inbound_pci_region *pci_region);
 int hl_pci_set_outbound_region(struct hl_device *hdev,
                struct hl_outbound_pci_region *pci_region);
-int hl_pci_init(struct hl_device *hdev);
+int hl_pci_init(struct hl_device *hdev, u32 cpu_boot_status_reg,
+               u32 boot_err0_reg, u32 preboot_ver_timeout);
 void hl_pci_fini(struct hl_device *hdev);
 
 long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr);
@@ -1858,7 +1967,7 @@ int hl_get_pwm_info(struct hl_device *hdev,
 void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
                        long value);
 u64 hl_get_max_power(struct hl_device *hdev);
-void hl_set_max_power(struct hl_device *hdev, u64 value);
+void hl_set_max_power(struct hl_device *hdev);
 int hl_set_voltage(struct hl_device *hdev,
                        int sensor_index, u32 attr, long value);
 int hl_set_current(struct hl_device *hdev,
index c6b31e9..f9067d3 100644 (file)
@@ -11,6 +11,7 @@
 #include "habanalabs.h"
 
 #include <linux/pci.h>
+#include <linux/aer.h>
 #include <linux/module.h>
 
 #define HL_DRIVER_AUTHOR       "HabanaLabs Kernel Driver Team"
@@ -408,6 +409,8 @@ static int hl_pci_probe(struct pci_dev *pdev,
 
        pci_set_drvdata(pdev, hdev);
 
+       pci_enable_pcie_error_reporting(pdev);
+
        rc = hl_device_init(hdev, hl_class);
        if (rc) {
                dev_err(&pdev->dev, "Fatal error during habanalabs device init\n");
@@ -440,22 +443,93 @@ static void hl_pci_remove(struct pci_dev *pdev)
                return;
 
        hl_device_fini(hdev);
+       pci_disable_pcie_error_reporting(pdev);
        pci_set_drvdata(pdev, NULL);
-
        destroy_hdev(hdev);
 }
 
+/**
+ * hl_pci_err_detected - a PCI bus error detected on this device
+ *
+ * @pdev: pointer to pci device
+ * @state: PCI error type
+ *
+ * Called by the PCI subsystem whenever a non-correctable
+ * PCI bus error is detected
+ */
+static pci_ers_result_t
+hl_pci_err_detected(struct pci_dev *pdev, pci_channel_state_t state)
+{
+       struct hl_device *hdev = pci_get_drvdata(pdev);
+       enum pci_ers_result result;
+
+       switch (state) {
+       case pci_channel_io_normal:
+               return PCI_ERS_RESULT_CAN_RECOVER;
+
+       case pci_channel_io_frozen:
+               dev_warn(hdev->dev, "frozen state error detected\n");
+               result = PCI_ERS_RESULT_NEED_RESET;
+               break;
+
+       case pci_channel_io_perm_failure:
+               dev_warn(hdev->dev, "failure state error detected\n");
+               result = PCI_ERS_RESULT_DISCONNECT;
+               break;
+
+       default:
+               result = PCI_ERS_RESULT_NONE;
+       }
+
+       hdev->asic_funcs->halt_engines(hdev, true);
+
+       return result;
+}
+
+/**
+ * hl_pci_err_resume - resume after a PCI slot reset
+ *
+ * @pdev: pointer to pci device
+ *
+ */
+static void hl_pci_err_resume(struct pci_dev *pdev)
+{
+       struct hl_device *hdev = pci_get_drvdata(pdev);
+
+       dev_warn(hdev->dev, "Resuming device after PCI slot reset\n");
+       hl_device_resume(hdev);
+}
+
+/**
+ * hl_pci_err_slot_reset - a PCI slot reset has just happened
+ *
+ * @pdev: pointer to pci device
+ *
+ * Determine if the driver can recover from the PCI slot reset
+ */
+static pci_ers_result_t hl_pci_err_slot_reset(struct pci_dev *pdev)
+{
+       return PCI_ERS_RESULT_RECOVERED;
+}
+
 static const struct dev_pm_ops hl_pm_ops = {
        .suspend = hl_pmops_suspend,
        .resume = hl_pmops_resume,
 };
 
+static const struct pci_error_handlers hl_pci_err_handler = {
+       .error_detected = hl_pci_err_detected,
+       .slot_reset = hl_pci_err_slot_reset,
+       .resume = hl_pci_err_resume,
+};
+
 static struct pci_driver hl_pci_driver = {
        .name = HL_NAME,
        .id_table = ids,
        .probe = hl_pci_probe,
        .remove = hl_pci_remove,
        .driver.pm = &hl_pm_ops,
+       .err_handler = &hl_pci_err_handler,
 };
 
 /*
index 5af1c03..07317ea 100644 (file)
@@ -8,6 +8,7 @@
 #include <uapi/misc/habanalabs.h>
 #include "habanalabs.h"
 
+#include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
@@ -64,14 +65,14 @@ static int hw_ip_info(struct hl_device *hdev, struct hl_info_args *args)
                hw_ip.dram_enabled = 1;
        hw_ip.num_of_events = prop->num_of_events;
 
-       memcpy(hw_ip.armcp_version, prop->armcp_info.armcp_version,
+       memcpy(hw_ip.cpucp_version, prop->cpucp_info.cpucp_version,
                min(VERSION_MAX_LEN, HL_INFO_VERSION_MAX_LEN));
 
-       memcpy(hw_ip.card_name, prop->armcp_info.card_name,
+       memcpy(hw_ip.card_name, prop->cpucp_info.card_name,
                min(CARD_NAME_MAX_LEN, HL_INFO_CARD_NAME_MAX_LEN));
 
-       hw_ip.armcp_cpld_version = le32_to_cpu(prop->armcp_info.cpld_version);
-       hw_ip.module_id = le32_to_cpu(prop->armcp_info.card_location);
+       hw_ip.cpld_version = le32_to_cpu(prop->cpucp_info.cpld_version);
+       hw_ip.module_id = le32_to_cpu(prop->cpucp_info.card_location);
 
        hw_ip.psoc_pci_pll_nr = prop->psoc_pci_pll_nr;
        hw_ip.psoc_pci_pll_nf = prop->psoc_pci_pll_nf;
@@ -131,7 +132,7 @@ static int hw_idle(struct hl_device *hdev, struct hl_info_args *args)
                return -EINVAL;
 
        hw_idle.is_idle = hdev->asic_funcs->is_device_idle(hdev,
-                                       &hw_idle.busy_engines_mask, NULL);
+                                       &hw_idle.busy_engines_mask_ext, NULL);
 
        return copy_to_user(out, &hw_idle,
                min((size_t) max_size, sizeof(hw_idle))) ? -EFAULT : 0;
@@ -276,10 +277,45 @@ static int time_sync_info(struct hl_device *hdev, struct hl_info_args *args)
                min((size_t) max_size, sizeof(time_sync))) ? -EFAULT : 0;
 }
 
+static int pci_counters_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
+{
+       struct hl_device *hdev = hpriv->hdev;
+       struct hl_info_pci_counters pci_counters = {0};
+       u32 max_size = args->return_size;
+       void __user *out = (void __user *) (uintptr_t) args->return_pointer;
+       int rc;
+
+       if ((!max_size) || (!out))
+               return -EINVAL;
+
+       rc = hl_fw_cpucp_pci_counters_get(hdev, &pci_counters);
+       if (rc)
+               return rc;
+
+       return copy_to_user(out, &pci_counters,
+               min((size_t) max_size, sizeof(pci_counters))) ? -EFAULT : 0;
+}
+
+static int clk_throttle_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
+{
+       struct hl_device *hdev = hpriv->hdev;
+       struct hl_info_clk_throttle clk_throttle = {0};
+       u32 max_size = args->return_size;
+       void __user *out = (void __user *) (uintptr_t) args->return_pointer;
+
+       if ((!max_size) || (!out))
+               return -EINVAL;
+
+       clk_throttle.clk_throttling_reason = hdev->clk_throttling_reason;
+
+       return copy_to_user(out, &clk_throttle,
+               min((size_t) max_size, sizeof(clk_throttle))) ? -EFAULT : 0;
+}
+
 static int cs_counters_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
 {
        struct hl_device *hdev = hpriv->hdev;
-       struct hl_info_cs_counters cs_counters = {0};
+       struct hl_info_cs_counters cs_counters = { {0} };
        u32 max_size = args->return_size;
        void __user *out = (void __user *) (uintptr_t) args->return_pointer;
 
@@ -297,6 +333,51 @@ static int cs_counters_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
                min((size_t) max_size, sizeof(cs_counters))) ? -EFAULT : 0;
 }
 
+static int sync_manager_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
+{
+       struct hl_device *hdev = hpriv->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       struct hl_info_sync_manager sm_info = {0};
+       u32 max_size = args->return_size;
+       void __user *out = (void __user *) (uintptr_t) args->return_pointer;
+
+       if ((!max_size) || (!out))
+               return -EINVAL;
+
+       if (args->dcore_id >= HL_MAX_DCORES)
+               return -EINVAL;
+
+       sm_info.first_available_sync_object =
+                       prop->first_available_user_sob[args->dcore_id];
+       sm_info.first_available_monitor =
+                       prop->first_available_user_mon[args->dcore_id];
+
+
+       return copy_to_user(out, &sm_info, min_t(size_t, (size_t) max_size,
+                       sizeof(sm_info))) ? -EFAULT : 0;
+}
+
+static int total_energy_consumption_info(struct hl_fpriv *hpriv,
+                       struct hl_info_args *args)
+{
+       struct hl_device *hdev = hpriv->hdev;
+       struct hl_info_energy total_energy = {0};
+       u32 max_size = args->return_size;
+       void __user *out = (void __user *) (uintptr_t) args->return_pointer;
+       int rc;
+
+       if ((!max_size) || (!out))
+               return -EINVAL;
+
+       rc = hl_fw_cpucp_total_energy_get(hdev,
+                       &total_energy.total_energy_consumption);
+       if (rc)
+               return rc;
+
+       return copy_to_user(out, &total_energy,
+               min((size_t) max_size, sizeof(total_energy))) ? -EFAULT : 0;
+}
+
 static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
                                struct device *dev)
 {
@@ -360,6 +441,18 @@ static int _hl_info_ioctl(struct hl_fpriv *hpriv, void *data,
        case HL_INFO_CS_COUNTERS:
                return cs_counters_info(hpriv, args);
 
+       case HL_INFO_PCI_COUNTERS:
+               return pci_counters_info(hpriv, args);
+
+       case HL_INFO_CLK_THROTTLE_REASON:
+               return clk_throttle_info(hpriv, args);
+
+       case HL_INFO_SYNC_MANAGER:
+               return sync_manager_info(hpriv, args);
+
+       case HL_INFO_TOTAL_ENERGY:
+               return total_energy_consumption_info(hpriv, args);
+
        default:
                dev_err(dev, "Invalid request %d\n", args->op);
                rc = -ENOTTY;
index 2876816..5e66c98 100644 (file)
@@ -288,10 +288,10 @@ static void ext_queue_schedule_job(struct hl_cs_job *job)
        ptr = cb->bus_address;
 
        cq_pkt.data = cpu_to_le32(
-                               ((q->pi << CQ_ENTRY_SHADOW_INDEX_SHIFT)
-                                       & CQ_ENTRY_SHADOW_INDEX_MASK) |
-                               (1 << CQ_ENTRY_SHADOW_INDEX_VALID_SHIFT) |
-                               (1 << CQ_ENTRY_READY_SHIFT));
+                       ((q->pi << CQ_ENTRY_SHADOW_INDEX_SHIFT)
+                               & CQ_ENTRY_SHADOW_INDEX_MASK) |
+                       FIELD_PREP(CQ_ENTRY_SHADOW_INDEX_VALID_MASK, 1) |
+                       FIELD_PREP(CQ_ENTRY_READY_MASK, 1));
 
        /*
         * No need to protect pi_offset because scheduling to the
@@ -474,7 +474,7 @@ static void init_signal_wait_cs(struct hl_cs *cs)
                 * wait CS was submitted.
                 */
                mb();
-               dma_fence_put(cs->signal_fence);
+               hl_fence_put(cs->signal_fence);
                cs->signal_fence = NULL;
        }
 }
index b997336..2ac29cb 100644 (file)
@@ -13,7 +13,7 @@
 #define HWMON_NR_SENSOR_TYPES          (hwmon_pwm + 1)
 
 int hl_build_hwmon_channel_info(struct hl_device *hdev,
-                               struct armcp_sensor *sensors_arr)
+                               struct cpucp_sensor *sensors_arr)
 {
        u32 counts[HWMON_NR_SENSOR_TYPES] = {0};
        u32 *sensors_by_type[HWMON_NR_SENSOR_TYPES] = {NULL};
@@ -24,7 +24,7 @@ int hl_build_hwmon_channel_info(struct hl_device *hdev,
        enum hwmon_sensor_types type;
        int rc, i, j;
 
-       for (i = 0 ; i < ARMCP_MAX_SENSORS ; i++) {
+       for (i = 0 ; i < CPUCP_MAX_SENSORS ; i++) {
                type = le32_to_cpu(sensors_arr[i].type);
 
                if ((type == 0) && (sensors_arr[i].flags == 0))
@@ -311,13 +311,13 @@ static const struct hwmon_ops hl_hwmon_ops = {
 int hl_get_temperature(struct hl_device *hdev,
                        int sensor_index, u32 attr, long *value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_TEMPERATURE_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEMPERATURE_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
 
@@ -337,13 +337,13 @@ int hl_get_temperature(struct hl_device *hdev,
 int hl_set_temperature(struct hl_device *hdev,
                        int sensor_index, u32 attr, long value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_TEMPERATURE_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_TEMPERATURE_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
        pkt.value = __cpu_to_le64(value);
@@ -362,13 +362,13 @@ int hl_set_temperature(struct hl_device *hdev,
 int hl_get_voltage(struct hl_device *hdev,
                        int sensor_index, u32 attr, long *value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_VOLTAGE_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_VOLTAGE_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
 
@@ -388,13 +388,13 @@ int hl_get_voltage(struct hl_device *hdev,
 int hl_get_current(struct hl_device *hdev,
                        int sensor_index, u32 attr, long *value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_CURRENT_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_CURRENT_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
 
@@ -414,13 +414,13 @@ int hl_get_current(struct hl_device *hdev,
 int hl_get_fan_speed(struct hl_device *hdev,
                        int sensor_index, u32 attr, long *value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_FAN_SPEED_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_FAN_SPEED_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
 
@@ -440,13 +440,13 @@ int hl_get_fan_speed(struct hl_device *hdev,
 int hl_get_pwm_info(struct hl_device *hdev,
                        int sensor_index, u32 attr, long *value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_PWM_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_PWM_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
 
@@ -466,13 +466,13 @@ int hl_get_pwm_info(struct hl_device *hdev,
 void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
                        long value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_PWM_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_PWM_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
        pkt.value = cpu_to_le64(value);
@@ -489,13 +489,13 @@ void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
 int hl_set_voltage(struct hl_device *hdev,
                        int sensor_index, u32 attr, long value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_VOLTAGE_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_VOLTAGE_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
        pkt.value = __cpu_to_le64(value);
@@ -514,13 +514,13 @@ int hl_set_voltage(struct hl_device *hdev,
 int hl_set_current(struct hl_device *hdev,
                        int sensor_index, u32 attr, long value)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_CURRENT_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_CURRENT_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.sensor_index = __cpu_to_le16(sensor_index);
        pkt.type = __cpu_to_le16(attr);
        pkt.value = __cpu_to_le64(value);
@@ -549,7 +549,7 @@ int hl_hwmon_init(struct hl_device *hdev)
                hdev->hl_chip_info->ops = &hl_hwmon_ops;
 
                hdev->hwmon_dev = hwmon_device_register_with_info(dev,
-                                       prop->armcp_info.card_name, hdev,
+                                       prop->cpucp_info.card_name, hdev,
                                        hdev->hl_chip_info, NULL);
                if (IS_ERR(hdev->hwmon_dev)) {
                        rc = PTR_ERR(hdev->hwmon_dev);
index c8db717..d20e40a 100644 (file)
@@ -11,7 +11,7 @@
 
 /**
  * struct hl_eqe_work - This structure is used to schedule work of EQ
- *                      entry and armcp_reset event
+ *                      entry and cpucp_reset event
  *
  * @eq_work:          workqueue object to run when EQ entry is received
  * @hdev:             pointer to device structure
index dce9273..8422781 100644 (file)
@@ -66,14 +66,19 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
        num_pgs = (args->alloc.mem_size + (page_size - 1)) >> page_shift;
        total_size = num_pgs << page_shift;
 
+       if (!total_size) {
+               dev_err(hdev->dev, "Cannot allocate 0 bytes\n");
+               return -EINVAL;
+       }
+
        contiguous = args->flags & HL_MEM_CONTIGUOUS;
 
        if (contiguous) {
                paddr = (u64) gen_pool_alloc(vm->dram_pg_pool, total_size);
                if (!paddr) {
                        dev_err(hdev->dev,
-                               "failed to allocate %llu huge contiguous pages\n",
-                               num_pgs);
+                               "failed to allocate %llu contiguous pages with total size of %llu\n",
+                               num_pgs, total_size);
                        return -ENOMEM;
                }
        }
@@ -93,7 +98,7 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args,
        phys_pg_pack->contiguous = contiguous;
 
        phys_pg_pack->pages = kvmalloc_array(num_pgs, sizeof(u64), GFP_KERNEL);
-       if (!phys_pg_pack->pages) {
+       if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
                rc = -ENOMEM;
                goto pages_arr_err;
        }
@@ -500,41 +505,32 @@ static inline int add_va_block(struct hl_device *hdev,
 }
 
 /*
- * get_va_block - get a virtual block with the requested size
- *
- * @hdev            : pointer to the habanalabs device structure
- * @va_range        : pointer to the virtual addresses range
- * @size            : requested block size
- * @hint_addr       : hint for request address by the user
- * @is_userptr      : is host or DRAM memory
+ * get_va_block() - get a virtual block for the given size and alignment.
+ * @hdev: pointer to the habanalabs device structure.
+ * @va_range: pointer to the virtual addresses range.
+ * @size: requested block size.
+ * @hint_addr: hint for requested address by the user.
+ * @va_block_align: required alignment of the virtual block start address.
  *
  * This function does the following:
  * - Iterate on the virtual block list to find a suitable virtual block for the
- *   requested size
- * - Reserve the requested block and update the list
- * - Return the start address of the virtual block
+ *   given size and alignment.
+ * - Reserve the requested block and update the list.
+ * - Return the start address of the virtual block.
  */
-static u64 get_va_block(struct hl_device *hdev,
-                       struct hl_va_range *va_range, u64 size, u64 hint_addr,
-                       bool is_userptr)
+static u64 get_va_block(struct hl_device *hdev, struct hl_va_range *va_range,
+                       u64 size, u64 hint_addr, u32 va_block_align)
 {
        struct hl_vm_va_block *va_block, *new_va_block = NULL;
-       u64 valid_start, valid_size, prev_start, prev_end, page_mask,
+       u64 valid_start, valid_size, prev_start, prev_end, align_mask,
                res_valid_start = 0, res_valid_size = 0;
-       u32 page_size;
        bool add_prev = false;
 
-       if (is_userptr)
-               /*
-                * We cannot know if the user allocated memory with huge pages
-                * or not, hence we continue with the biggest possible
-                * granularity.
-                */
-               page_size = hdev->asic_prop.pmmu_huge.page_size;
-       else
-               page_size = hdev->asic_prop.dmmu.page_size;
+       align_mask = ~((u64)va_block_align - 1);
 
-       page_mask = ~((u64)page_size - 1);
+       /* check if hint_addr is aligned */
+       if (hint_addr & (va_block_align - 1))
+               hint_addr = 0;
 
        mutex_lock(&va_range->lock);
 
@@ -544,9 +540,9 @@ static u64 get_va_block(struct hl_device *hdev,
                /* calc the first possible aligned addr */
                valid_start = va_block->start;
 
-               if (valid_start & (page_size - 1)) {
-                       valid_start &= page_mask;
-                       valid_start += page_size;
+               if (valid_start & (va_block_align - 1)) {
+                       valid_start &= align_mask;
+                       valid_start += va_block_align;
                        if (valid_start > va_block->end)
                                continue;
                }
@@ -683,7 +679,7 @@ static int init_phys_pg_pack_from_userptr(struct hl_ctx *ctx,
 
        phys_pg_pack->pages = kvmalloc_array(total_npages, sizeof(u64),
                                                GFP_KERNEL);
-       if (!phys_pg_pack->pages) {
+       if (ZERO_OR_NULL_PTR(phys_pg_pack->pages)) {
                rc = -ENOMEM;
                goto page_pack_arr_mem_err;
        }
@@ -858,7 +854,7 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
        struct hl_va_range *va_range;
        enum vm_type_t *vm_type;
        u64 ret_vaddr, hint_addr;
-       u32 handle = 0;
+       u32 handle = 0, va_block_align;
        int rc;
        bool is_userptr = args->flags & HL_MEM_USERPTR;
 
@@ -868,6 +864,8 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
        if (is_userptr) {
                u64 addr = args->map_host.host_virt_addr,
                        size = args->map_host.mem_size;
+               u32 page_size = hdev->asic_prop.pmmu.page_size,
+                       huge_page_size = hdev->asic_prop.pmmu_huge.page_size;
 
                rc = dma_map_host_va(hdev, addr, size, &userptr);
                if (rc) {
@@ -887,6 +885,27 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
                vm_type = (enum vm_type_t *) userptr;
                hint_addr = args->map_host.hint_addr;
                handle = phys_pg_pack->handle;
+
+               /* get required alignment */
+               if (phys_pg_pack->page_size == page_size) {
+                       va_range = ctx->host_va_range;
+
+                       /*
+                        * huge page alignment may be needed in case of regular
+                        * page mapping, depending on the host VA alignment
+                        */
+                       if (addr & (huge_page_size - 1))
+                               va_block_align = page_size;
+                       else
+                               va_block_align = huge_page_size;
+               } else {
+                       /*
+                        * huge page alignment is needed in case of huge page
+                        * mapping
+                        */
+                       va_range = ctx->host_huge_va_range;
+                       va_block_align = huge_page_size;
+               }
        } else {
                handle = lower_32_bits(args->map_device.handle);
 
@@ -907,6 +926,10 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
                vm_type = (enum vm_type_t *) phys_pg_pack;
 
                hint_addr = args->map_device.hint_addr;
+
+               /* DRAM VA alignment is the same as the DRAM page size */
+               va_range = ctx->dram_va_range;
+               va_block_align = hdev->asic_prop.dmmu.page_size;
        }
 
        /*
@@ -928,16 +951,8 @@ static int map_device_va(struct hl_ctx *ctx, struct hl_mem_in *args,
                goto hnode_err;
        }
 
-       if (is_userptr)
-               if (phys_pg_pack->page_size == hdev->asic_prop.pmmu.page_size)
-                       va_range = ctx->host_va_range;
-               else
-                       va_range = ctx->host_huge_va_range;
-       else
-               va_range = ctx->dram_va_range;
-
        ret_vaddr = get_va_block(hdev, va_range, phys_pg_pack->total_size,
-                                       hint_addr, is_userptr);
+                                       hint_addr, va_block_align);
        if (!ret_vaddr) {
                dev_err(hdev->dev, "no available va block for handle %u\n",
                                handle);
index edcc11d..b505879 100644 (file)
 // SPDX-License-Identifier: GPL-2.0
 
 /*
- * Copyright 2016-2019 HabanaLabs, Ltd.
+ * Copyright 2016-2020 HabanaLabs, Ltd.
  * All Rights Reserved.
  */
 
-#include "habanalabs.h"
-#include "../include/hw_ip/mmu/mmu_general.h"
-
-#include <linux/genalloc.h>
 #include <linux/slab.h>
 
-static inline u64 get_phys_addr(struct hl_ctx *ctx, u64 shadow_addr);
-
-static struct pgt_info *get_pgt_info(struct hl_ctx *ctx, u64 hop_addr)
-{
-       struct pgt_info *pgt_info = NULL;
-
-       hash_for_each_possible(ctx->mmu_shadow_hash, pgt_info, node,
-                               (unsigned long) hop_addr)
-               if (hop_addr == pgt_info->shadow_addr)
-                       break;
-
-       return pgt_info;
-}
-
-static void _free_hop(struct hl_ctx *ctx, struct pgt_info *pgt_info)
-{
-       struct hl_device *hdev = ctx->hdev;
-
-       gen_pool_free(hdev->mmu_pgt_pool, pgt_info->phys_addr,
-                       hdev->asic_prop.mmu_hop_table_size);
-       hash_del(&pgt_info->node);
-       kfree((u64 *) (uintptr_t) pgt_info->shadow_addr);
-       kfree(pgt_info);
-}
-
-static void free_hop(struct hl_ctx *ctx, u64 hop_addr)
-{
-       struct pgt_info *pgt_info = get_pgt_info(ctx, hop_addr);
-
-       _free_hop(ctx, pgt_info);
-}
-
-static u64 alloc_hop(struct hl_ctx *ctx)
-{
-       struct hl_device *hdev = ctx->hdev;
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       struct pgt_info *pgt_info;
-       u64 phys_addr, shadow_addr;
-
-       pgt_info = kmalloc(sizeof(*pgt_info), GFP_KERNEL);
-       if (!pgt_info)
-               return ULLONG_MAX;
-
-       phys_addr = (u64) gen_pool_alloc(hdev->mmu_pgt_pool,
-                                       prop->mmu_hop_table_size);
-       if (!phys_addr) {
-               dev_err(hdev->dev, "failed to allocate page\n");
-               goto pool_add_err;
-       }
-
-       shadow_addr = (u64) (uintptr_t) kzalloc(prop->mmu_hop_table_size,
-                                               GFP_KERNEL);
-       if (!shadow_addr)
-               goto shadow_err;
-
-       pgt_info->phys_addr = phys_addr;
-       pgt_info->shadow_addr = shadow_addr;
-       pgt_info->ctx = ctx;
-       pgt_info->num_of_ptes = 0;
-       hash_add(ctx->mmu_shadow_hash, &pgt_info->node, shadow_addr);
-
-       return shadow_addr;
-
-shadow_err:
-       gen_pool_free(hdev->mmu_pgt_pool, phys_addr, prop->mmu_hop_table_size);
-pool_add_err:
-       kfree(pgt_info);
-
-       return ULLONG_MAX;
-}
-
-static inline u64 get_phys_hop0_addr(struct hl_ctx *ctx)
-{
-       return ctx->hdev->asic_prop.mmu_pgt_addr +
-                       (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size);
-}
-
-static inline u64 get_hop0_addr(struct hl_ctx *ctx)
-{
-       return (u64) (uintptr_t) ctx->hdev->mmu_shadow_hop0 +
-                       (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size);
-}
-
-static inline void flush(struct hl_ctx *ctx)
-{
-       /* flush all writes from all cores to reach PCI */
-       mb();
-       ctx->hdev->asic_funcs->read_pte(ctx->hdev, get_phys_hop0_addr(ctx));
-}
-
-/* transform the value to physical address when writing to H/W */
-static inline void write_pte(struct hl_ctx *ctx, u64 shadow_pte_addr, u64 val)
-{
-       /*
-        * The value to write is actually the address of the next shadow hop +
-        * flags at the 12 LSBs.
-        * Hence in order to get the value to write to the physical PTE, we
-        * clear the 12 LSBs and translate the shadow hop to its associated
-        * physical hop, and add back the original 12 LSBs.
-        */
-       u64 phys_val = get_phys_addr(ctx, val & HOP_PHYS_ADDR_MASK) |
-                               (val & FLAGS_MASK);
-
-       ctx->hdev->asic_funcs->write_pte(ctx->hdev,
-                                       get_phys_addr(ctx, shadow_pte_addr),
-                                       phys_val);
-
-       *(u64 *) (uintptr_t) shadow_pte_addr = val;
-}
-
-/* do not transform the value to physical address when writing to H/W */
-static inline void write_final_pte(struct hl_ctx *ctx, u64 shadow_pte_addr,
-                                       u64 val)
-{
-       ctx->hdev->asic_funcs->write_pte(ctx->hdev,
-                                       get_phys_addr(ctx, shadow_pte_addr),
-                                       val);
-       *(u64 *) (uintptr_t) shadow_pte_addr = val;
-}
-
-/* clear the last and present bits */
-static inline void clear_pte(struct hl_ctx *ctx, u64 pte_addr)
-{
-       /* no need to transform the value to physical address */
-       write_final_pte(ctx, pte_addr, 0);
-}
-
-static inline void get_pte(struct hl_ctx *ctx, u64 hop_addr)
-{
-       get_pgt_info(ctx, hop_addr)->num_of_ptes++;
-}
-
-/*
- * put_pte - decrement the num of ptes and free the hop if possible
- *
- * @ctx: pointer to the context structure
- * @hop_addr: addr of the hop
- *
- * This function returns the number of ptes left on this hop. If the number is
- * 0, it means the pte was freed.
- */
-static inline int put_pte(struct hl_ctx *ctx, u64 hop_addr)
-{
-       struct pgt_info *pgt_info = get_pgt_info(ctx, hop_addr);
-       int num_of_ptes_left;
-
-       pgt_info->num_of_ptes--;
-
-       /*
-        * Need to save the number of ptes left because free_hop might free
-        * the pgt_info
-        */
-       num_of_ptes_left = pgt_info->num_of_ptes;
-       if (!num_of_ptes_left)
-               _free_hop(ctx, pgt_info);
-
-       return num_of_ptes_left;
-}
-
-static inline u64 get_hopN_pte_addr(struct hl_ctx *ctx, u64 hop_addr,
-                                       u64 virt_addr, u64 mask, u64 shift)
-{
-       return hop_addr + ctx->hdev->asic_prop.mmu_pte_size *
-                       ((virt_addr & mask) >> shift);
-}
-
-static inline u64 get_hop0_pte_addr(struct hl_ctx *ctx,
-                                       struct hl_mmu_properties *mmu_prop,
-                                       u64 hop_addr, u64 vaddr)
-{
-       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop0_mask,
-                                       mmu_prop->hop0_shift);
-}
-
-static inline u64 get_hop1_pte_addr(struct hl_ctx *ctx,
-                                       struct hl_mmu_properties *mmu_prop,
-                                       u64 hop_addr, u64 vaddr)
-{
-       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop1_mask,
-                                       mmu_prop->hop1_shift);
-}
-
-static inline u64 get_hop2_pte_addr(struct hl_ctx *ctx,
-                                       struct hl_mmu_properties *mmu_prop,
-                                       u64 hop_addr, u64 vaddr)
-{
-       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop2_mask,
-                                       mmu_prop->hop2_shift);
-}
-
-static inline u64 get_hop3_pte_addr(struct hl_ctx *ctx,
-                                       struct hl_mmu_properties *mmu_prop,
-                                       u64 hop_addr, u64 vaddr)
-{
-       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop3_mask,
-                                       mmu_prop->hop3_shift);
-}
-
-static inline u64 get_hop4_pte_addr(struct hl_ctx *ctx,
-                                       struct hl_mmu_properties *mmu_prop,
-                                       u64 hop_addr, u64 vaddr)
-{
-       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop4_mask,
-                                       mmu_prop->hop4_shift);
-}
-
-static inline u64 get_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte)
-{
-       if (curr_pte & PAGE_PRESENT_MASK)
-               return curr_pte & HOP_PHYS_ADDR_MASK;
-       else
-               return ULLONG_MAX;
-}
-
-static inline u64 get_alloc_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte,
-                                               bool *is_new_hop)
-{
-       u64 hop_addr = get_next_hop_addr(ctx, curr_pte);
-
-       if (hop_addr == ULLONG_MAX) {
-               hop_addr = alloc_hop(ctx);
-               *is_new_hop = (hop_addr != ULLONG_MAX);
-       }
-
-       return hop_addr;
-}
-
-/* translates shadow address inside hop to a physical address */
-static inline u64 get_phys_addr(struct hl_ctx *ctx, u64 shadow_addr)
-{
-       u64 page_mask = (ctx->hdev->asic_prop.mmu_hop_table_size - 1);
-       u64 shadow_hop_addr = shadow_addr & ~page_mask;
-       u64 pte_offset = shadow_addr & page_mask;
-       u64 phys_hop_addr;
-
-       if (shadow_hop_addr != get_hop0_addr(ctx))
-               phys_hop_addr = get_pgt_info(ctx, shadow_hop_addr)->phys_addr;
-       else
-               phys_hop_addr = get_phys_hop0_addr(ctx);
-
-       return phys_hop_addr + pte_offset;
-}
+#include "habanalabs.h"
 
 static bool is_dram_va(struct hl_device *hdev, u64 virt_addr)
 {
@@ -263,155 +18,6 @@ static bool is_dram_va(struct hl_device *hdev, u64 virt_addr)
                                        prop->dmmu.end_addr);
 }
 
-static int dram_default_mapping_init(struct hl_ctx *ctx)
-{
-       struct hl_device *hdev = ctx->hdev;
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       u64 num_of_hop3, total_hops, hop0_addr, hop1_addr, hop2_addr,
-               hop2_pte_addr, hop3_pte_addr, pte_val;
-       int rc, i, j, hop3_allocated = 0;
-
-       if ((!hdev->dram_supports_virtual_memory) ||
-                       (!hdev->dram_default_page_mapping) ||
-                       (ctx->asid == HL_KERNEL_ASID_ID))
-               return 0;
-
-       num_of_hop3 = prop->dram_size_for_default_page_mapping;
-       do_div(num_of_hop3, prop->dram_page_size);
-       do_div(num_of_hop3, PTE_ENTRIES_IN_HOP);
-
-       /* add hop1 and hop2 */
-       total_hops = num_of_hop3 + 2;
-
-       ctx->dram_default_hops = kzalloc(HL_PTE_SIZE * total_hops,  GFP_KERNEL);
-       if (!ctx->dram_default_hops)
-               return -ENOMEM;
-
-       hop0_addr = get_hop0_addr(ctx);
-
-       hop1_addr = alloc_hop(ctx);
-       if (hop1_addr == ULLONG_MAX) {
-               dev_err(hdev->dev, "failed to alloc hop 1\n");
-               rc = -ENOMEM;
-               goto hop1_err;
-       }
-
-       ctx->dram_default_hops[total_hops - 1] = hop1_addr;
-
-       hop2_addr = alloc_hop(ctx);
-       if (hop2_addr == ULLONG_MAX) {
-               dev_err(hdev->dev, "failed to alloc hop 2\n");
-               rc = -ENOMEM;
-               goto hop2_err;
-       }
-
-       ctx->dram_default_hops[total_hops - 2] = hop2_addr;
-
-       for (i = 0 ; i < num_of_hop3 ; i++) {
-               ctx->dram_default_hops[i] = alloc_hop(ctx);
-               if (ctx->dram_default_hops[i] == ULLONG_MAX) {
-                       dev_err(hdev->dev, "failed to alloc hop 3, i: %d\n", i);
-                       rc = -ENOMEM;
-                       goto hop3_err;
-               }
-               hop3_allocated++;
-       }
-
-       /* need only pte 0 in hops 0 and 1 */
-       pte_val = (hop1_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
-       write_pte(ctx, hop0_addr, pte_val);
-
-       pte_val = (hop2_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
-       write_pte(ctx, hop1_addr, pte_val);
-       get_pte(ctx, hop1_addr);
-
-       hop2_pte_addr = hop2_addr;
-       for (i = 0 ; i < num_of_hop3 ; i++) {
-               pte_val = (ctx->dram_default_hops[i] & HOP_PHYS_ADDR_MASK) |
-                               PAGE_PRESENT_MASK;
-               write_pte(ctx, hop2_pte_addr, pte_val);
-               get_pte(ctx, hop2_addr);
-               hop2_pte_addr += HL_PTE_SIZE;
-       }
-
-       pte_val = (prop->mmu_dram_default_page_addr & HOP_PHYS_ADDR_MASK) |
-                       LAST_MASK | PAGE_PRESENT_MASK;
-
-       for (i = 0 ; i < num_of_hop3 ; i++) {
-               hop3_pte_addr = ctx->dram_default_hops[i];
-               for (j = 0 ; j < PTE_ENTRIES_IN_HOP ; j++) {
-                       write_final_pte(ctx, hop3_pte_addr, pte_val);
-                       get_pte(ctx, ctx->dram_default_hops[i]);
-                       hop3_pte_addr += HL_PTE_SIZE;
-               }
-       }
-
-       flush(ctx);
-
-       return 0;
-
-hop3_err:
-       for (i = 0 ; i < hop3_allocated ; i++)
-               free_hop(ctx, ctx->dram_default_hops[i]);
-
-       free_hop(ctx, hop2_addr);
-hop2_err:
-       free_hop(ctx, hop1_addr);
-hop1_err:
-       kfree(ctx->dram_default_hops);
-
-       return rc;
-}
-
-static void dram_default_mapping_fini(struct hl_ctx *ctx)
-{
-       struct hl_device *hdev = ctx->hdev;
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       u64 num_of_hop3, total_hops, hop0_addr, hop1_addr, hop2_addr,
-               hop2_pte_addr, hop3_pte_addr;
-       int i, j;
-
-       if ((!hdev->dram_supports_virtual_memory) ||
-                       (!hdev->dram_default_page_mapping) ||
-                       (ctx->asid == HL_KERNEL_ASID_ID))
-               return;
-
-       num_of_hop3 = prop->dram_size_for_default_page_mapping;
-       do_div(num_of_hop3, prop->dram_page_size);
-       do_div(num_of_hop3, PTE_ENTRIES_IN_HOP);
-
-       hop0_addr = get_hop0_addr(ctx);
-       /* add hop1 and hop2 */
-       total_hops = num_of_hop3 + 2;
-       hop1_addr = ctx->dram_default_hops[total_hops - 1];
-       hop2_addr = ctx->dram_default_hops[total_hops - 2];
-
-       for (i = 0 ; i < num_of_hop3 ; i++) {
-               hop3_pte_addr = ctx->dram_default_hops[i];
-               for (j = 0 ; j < PTE_ENTRIES_IN_HOP ; j++) {
-                       clear_pte(ctx, hop3_pte_addr);
-                       put_pte(ctx, ctx->dram_default_hops[i]);
-                       hop3_pte_addr += HL_PTE_SIZE;
-               }
-       }
-
-       hop2_pte_addr = hop2_addr;
-       hop2_pte_addr = hop2_addr;
-       for (i = 0 ; i < num_of_hop3 ; i++) {
-               clear_pte(ctx, hop2_pte_addr);
-               put_pte(ctx, hop2_addr);
-               hop2_pte_addr += HL_PTE_SIZE;
-       }
-
-       clear_pte(ctx, hop1_addr);
-       put_pte(ctx, hop1_addr);
-       clear_pte(ctx, hop0_addr);
-
-       kfree(ctx->dram_default_hops);
-
-       flush(ctx);
-}
-
 /**
  * hl_mmu_init() - initialize the MMU module.
  * @hdev: habanalabs device structure.
@@ -424,45 +30,10 @@ static void dram_default_mapping_fini(struct hl_ctx *ctx)
  */
 int hl_mmu_init(struct hl_device *hdev)
 {
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       int rc;
-
-       if (!hdev->mmu_enable)
-               return 0;
-
-       hdev->mmu_pgt_pool =
-                       gen_pool_create(__ffs(prop->mmu_hop_table_size), -1);
-
-       if (!hdev->mmu_pgt_pool) {
-               dev_err(hdev->dev, "Failed to create page gen pool\n");
-               return -ENOMEM;
-       }
-
-       rc = gen_pool_add(hdev->mmu_pgt_pool, prop->mmu_pgt_addr +
-                       prop->mmu_hop0_tables_total_size,
-                       prop->mmu_pgt_size - prop->mmu_hop0_tables_total_size,
-                       -1);
-       if (rc) {
-               dev_err(hdev->dev, "Failed to add memory to page gen pool\n");
-               goto err_pool_add;
-       }
-
-       hdev->mmu_shadow_hop0 = kvmalloc_array(prop->max_asid,
-                                       prop->mmu_hop_table_size,
-                                       GFP_KERNEL | __GFP_ZERO);
-       if (!hdev->mmu_shadow_hop0) {
-               rc = -ENOMEM;
-               goto err_pool_add;
-       }
-
-       /* MMU H/W init will be done in device hw_init() */
+       if (hdev->mmu_enable)
+               return hdev->mmu_func.init(hdev);
 
        return 0;
-
-err_pool_add:
-       gen_pool_destroy(hdev->mmu_pgt_pool);
-
-       return rc;
 }
 
 /**
@@ -477,13 +48,8 @@ err_pool_add:
  */
 void hl_mmu_fini(struct hl_device *hdev)
 {
-       if (!hdev->mmu_enable)
-               return;
-
-       /* MMU H/W fini was already done in device hw_fini() */
-
-       kvfree(hdev->mmu_shadow_hop0);
-       gen_pool_destroy(hdev->mmu_pgt_pool);
+       if (hdev->mmu_enable)
+               hdev->mmu_func.fini(hdev);
 }
 
 /**
@@ -498,13 +64,10 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
 {
        struct hl_device *hdev = ctx->hdev;
 
-       if (!hdev->mmu_enable)
-               return 0;
+       if (hdev->mmu_enable)
+               return hdev->mmu_func.ctx_init(ctx);
 
-       mutex_init(&ctx->mmu_lock);
-       hash_init(ctx->mmu_shadow_hash);
-
-       return dram_default_mapping_init(ctx);
+       return 0;
 }
 
 /*
@@ -520,160 +83,9 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
 void hl_mmu_ctx_fini(struct hl_ctx *ctx)
 {
        struct hl_device *hdev = ctx->hdev;
-       struct pgt_info *pgt_info;
-       struct hlist_node *tmp;
-       int i;
-
-       if (!hdev->mmu_enable)
-               return;
-
-       dram_default_mapping_fini(ctx);
-
-       if (!hash_empty(ctx->mmu_shadow_hash))
-               dev_err(hdev->dev, "ctx %d is freed while it has pgts in use\n",
-                       ctx->asid);
-
-       hash_for_each_safe(ctx->mmu_shadow_hash, i, tmp, pgt_info, node) {
-               dev_err_ratelimited(hdev->dev,
-                       "pgt_info of addr 0x%llx of asid %d was not destroyed, num_ptes: %d\n",
-                       pgt_info->phys_addr, ctx->asid, pgt_info->num_of_ptes);
-               _free_hop(ctx, pgt_info);
-       }
-
-       mutex_destroy(&ctx->mmu_lock);
-}
-
-static int _hl_mmu_unmap(struct hl_ctx *ctx, u64 virt_addr, bool is_dram_addr)
-{
-       struct hl_device *hdev = ctx->hdev;
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       struct hl_mmu_properties *mmu_prop;
-       u64 hop0_addr = 0, hop0_pte_addr = 0,
-               hop1_addr = 0, hop1_pte_addr = 0,
-               hop2_addr = 0, hop2_pte_addr = 0,
-               hop3_addr = 0, hop3_pte_addr = 0,
-               hop4_addr = 0, hop4_pte_addr = 0,
-               curr_pte;
-       bool is_huge, clear_hop3 = true;
-
-       /* shifts and masks are the same in PMMU and HPMMU, use one of them */
-       mmu_prop = is_dram_addr ? &prop->dmmu : &prop->pmmu;
-
-       hop0_addr = get_hop0_addr(ctx);
-       hop0_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop0_addr, virt_addr);
-
-       curr_pte = *(u64 *) (uintptr_t) hop0_pte_addr;
-
-       hop1_addr = get_next_hop_addr(ctx, curr_pte);
-
-       if (hop1_addr == ULLONG_MAX)
-               goto not_mapped;
-
-       hop1_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop1_addr, virt_addr);
-
-       curr_pte = *(u64 *) (uintptr_t) hop1_pte_addr;
-
-       hop2_addr = get_next_hop_addr(ctx, curr_pte);
-
-       if (hop2_addr == ULLONG_MAX)
-               goto not_mapped;
-
-       hop2_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop2_addr, virt_addr);
-
-       curr_pte = *(u64 *) (uintptr_t) hop2_pte_addr;
-
-       hop3_addr = get_next_hop_addr(ctx, curr_pte);
-
-       if (hop3_addr == ULLONG_MAX)
-               goto not_mapped;
-
-       hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr);
-
-       curr_pte = *(u64 *) (uintptr_t) hop3_pte_addr;
-
-       is_huge = curr_pte & LAST_MASK;
-
-       if (is_dram_addr && !is_huge) {
-               dev_err(hdev->dev,
-                               "DRAM unmapping should use huge pages only\n");
-               return -EFAULT;
-       }
-
-       if (!is_huge) {
-               hop4_addr = get_next_hop_addr(ctx, curr_pte);
-
-               if (hop4_addr == ULLONG_MAX)
-                       goto not_mapped;
-
-               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop4_addr,
-                                                       virt_addr);
-
-               curr_pte = *(u64 *) (uintptr_t) hop4_pte_addr;
-
-               clear_hop3 = false;
-       }
-
-       if (hdev->dram_default_page_mapping && is_dram_addr) {
-               u64 default_pte = (prop->mmu_dram_default_page_addr &
-                               HOP_PHYS_ADDR_MASK) | LAST_MASK |
-                                       PAGE_PRESENT_MASK;
-               if (curr_pte == default_pte) {
-                       dev_err(hdev->dev,
-                               "DRAM: hop3 PTE points to zero page, can't unmap, va: 0x%llx\n",
-                                       virt_addr);
-                       goto not_mapped;
-               }
-
-               if (!(curr_pte & PAGE_PRESENT_MASK)) {
-                       dev_err(hdev->dev,
-                               "DRAM: hop3 PTE is cleared! can't unmap, va: 0x%llx\n",
-                                       virt_addr);
-                       goto not_mapped;
-               }
-
-               write_final_pte(ctx, hop3_pte_addr, default_pte);
-               put_pte(ctx, hop3_addr);
-       } else {
-               if (!(curr_pte & PAGE_PRESENT_MASK))
-                       goto not_mapped;
-
-               if (hop4_addr)
-                       clear_pte(ctx, hop4_pte_addr);
-               else
-                       clear_pte(ctx, hop3_pte_addr);
-
-               if (hop4_addr && !put_pte(ctx, hop4_addr))
-                       clear_hop3 = true;
-
-               if (!clear_hop3)
-                       goto mapped;
-
-               clear_pte(ctx, hop3_pte_addr);
 
-               if (put_pte(ctx, hop3_addr))
-                       goto mapped;
-
-               clear_pte(ctx, hop2_pte_addr);
-
-               if (put_pte(ctx, hop2_addr))
-                       goto mapped;
-
-               clear_pte(ctx, hop1_pte_addr);
-
-               if (put_pte(ctx, hop1_addr))
-                       goto mapped;
-
-               clear_pte(ctx, hop0_pte_addr);
-       }
-
-mapped:
-       return 0;
-
-not_mapped:
-       dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n",
-               virt_addr);
-
-       return -EINVAL;
+       if (hdev->mmu_enable)
+               hdev->mmu_func.ctx_fini(ctx);
 }
 
 /*
@@ -738,7 +150,7 @@ int hl_mmu_unmap(struct hl_ctx *ctx, u64 virt_addr, u32 page_size,
        real_virt_addr = virt_addr;
 
        for (i = 0 ; i < npages ; i++) {
-               rc = _hl_mmu_unmap(ctx, real_virt_addr, is_dram_addr);
+               rc = hdev->mmu_func.unmap(ctx, real_virt_addr, is_dram_addr);
                if (rc)
                        break;
 
@@ -746,172 +158,7 @@ int hl_mmu_unmap(struct hl_ctx *ctx, u64 virt_addr, u32 page_size,
        }
 
        if (flush_pte)
-               flush(ctx);
-
-       return rc;
-}
-
-static int _hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr,
-                       u32 page_size, bool is_dram_addr)
-{
-       struct hl_device *hdev = ctx->hdev;
-       struct asic_fixed_properties *prop = &hdev->asic_prop;
-       struct hl_mmu_properties *mmu_prop;
-       u64 hop0_addr = 0, hop0_pte_addr = 0,
-               hop1_addr = 0, hop1_pte_addr = 0,
-               hop2_addr = 0, hop2_pte_addr = 0,
-               hop3_addr = 0, hop3_pte_addr = 0,
-               hop4_addr = 0, hop4_pte_addr = 0,
-               curr_pte = 0;
-       bool hop1_new = false, hop2_new = false, hop3_new = false,
-               hop4_new = false, is_huge;
-       int rc = -ENOMEM;
-
-       /*
-        * This mapping function can map a page or a huge page. For huge page
-        * there are only 3 hops rather than 4. Currently the DRAM allocation
-        * uses huge pages only but user memory could have been allocated with
-        * one of the two page sizes. Since this is a common code for all the
-        * three cases, we need this hugs page check.
-        */
-       if (is_dram_addr) {
-               mmu_prop = &prop->dmmu;
-               is_huge = true;
-       } else if (page_size == prop->pmmu_huge.page_size) {
-               mmu_prop = &prop->pmmu_huge;
-               is_huge = true;
-       } else {
-               mmu_prop = &prop->pmmu;
-               is_huge = false;
-       }
-
-       hop0_addr = get_hop0_addr(ctx);
-       hop0_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop0_addr, virt_addr);
-       curr_pte = *(u64 *) (uintptr_t) hop0_pte_addr;
-
-       hop1_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop1_new);
-       if (hop1_addr == ULLONG_MAX)
-               goto err;
-
-       hop1_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop1_addr, virt_addr);
-       curr_pte = *(u64 *) (uintptr_t) hop1_pte_addr;
-
-       hop2_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop2_new);
-       if (hop2_addr == ULLONG_MAX)
-               goto err;
-
-       hop2_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop2_addr, virt_addr);
-       curr_pte = *(u64 *) (uintptr_t) hop2_pte_addr;
-
-       hop3_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop3_new);
-       if (hop3_addr == ULLONG_MAX)
-               goto err;
-
-       hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr);
-       curr_pte = *(u64 *) (uintptr_t) hop3_pte_addr;
-
-       if (!is_huge) {
-               hop4_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop4_new);
-               if (hop4_addr == ULLONG_MAX)
-                       goto err;
-
-               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop4_addr,
-                                                       virt_addr);
-               curr_pte = *(u64 *) (uintptr_t) hop4_pte_addr;
-       }
-
-       if (hdev->dram_default_page_mapping && is_dram_addr) {
-               u64 default_pte = (prop->mmu_dram_default_page_addr &
-                                       HOP_PHYS_ADDR_MASK) | LAST_MASK |
-                                               PAGE_PRESENT_MASK;
-
-               if (curr_pte != default_pte) {
-                       dev_err(hdev->dev,
-                               "DRAM: mapping already exists for virt_addr 0x%llx\n",
-                                       virt_addr);
-                       rc = -EINVAL;
-                       goto err;
-               }
-
-               if (hop1_new || hop2_new || hop3_new || hop4_new) {
-                       dev_err(hdev->dev,
-                               "DRAM mapping should not allocate more hops\n");
-                       rc = -EFAULT;
-                       goto err;
-               }
-       } else if (curr_pte & PAGE_PRESENT_MASK) {
-               dev_err(hdev->dev,
-                       "mapping already exists for virt_addr 0x%llx\n",
-                               virt_addr);
-
-               dev_dbg(hdev->dev, "hop0 pte: 0x%llx (0x%llx)\n",
-                       *(u64 *) (uintptr_t) hop0_pte_addr, hop0_pte_addr);
-               dev_dbg(hdev->dev, "hop1 pte: 0x%llx (0x%llx)\n",
-                       *(u64 *) (uintptr_t) hop1_pte_addr, hop1_pte_addr);
-               dev_dbg(hdev->dev, "hop2 pte: 0x%llx (0x%llx)\n",
-                       *(u64 *) (uintptr_t) hop2_pte_addr, hop2_pte_addr);
-               dev_dbg(hdev->dev, "hop3 pte: 0x%llx (0x%llx)\n",
-                       *(u64 *) (uintptr_t) hop3_pte_addr, hop3_pte_addr);
-
-               if (!is_huge)
-                       dev_dbg(hdev->dev, "hop4 pte: 0x%llx (0x%llx)\n",
-                               *(u64 *) (uintptr_t) hop4_pte_addr,
-                               hop4_pte_addr);
-
-               rc = -EINVAL;
-               goto err;
-       }
-
-       curr_pte = (phys_addr & HOP_PHYS_ADDR_MASK) | LAST_MASK
-                       | PAGE_PRESENT_MASK;
-
-       if (is_huge)
-               write_final_pte(ctx, hop3_pte_addr, curr_pte);
-       else
-               write_final_pte(ctx, hop4_pte_addr, curr_pte);
-
-       if (hop1_new) {
-               curr_pte =
-                       (hop1_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
-               write_pte(ctx, hop0_pte_addr, curr_pte);
-       }
-       if (hop2_new) {
-               curr_pte =
-                       (hop2_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
-               write_pte(ctx, hop1_pte_addr, curr_pte);
-               get_pte(ctx, hop1_addr);
-       }
-       if (hop3_new) {
-               curr_pte =
-                       (hop3_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
-               write_pte(ctx, hop2_pte_addr, curr_pte);
-               get_pte(ctx, hop2_addr);
-       }
-
-       if (!is_huge) {
-               if (hop4_new) {
-                       curr_pte = (hop4_addr & HOP_PHYS_ADDR_MASK) |
-                                       PAGE_PRESENT_MASK;
-                       write_pte(ctx, hop3_pte_addr, curr_pte);
-                       get_pte(ctx, hop3_addr);
-               }
-
-               get_pte(ctx, hop4_addr);
-       } else {
-               get_pte(ctx, hop3_addr);
-       }
-
-       return 0;
-
-err:
-       if (hop4_new)
-               free_hop(ctx, hop4_addr);
-       if (hop3_new)
-               free_hop(ctx, hop3_addr);
-       if (hop2_new)
-               free_hop(ctx, hop2_addr);
-       if (hop1_new)
-               free_hop(ctx, hop1_addr);
+               hdev->mmu_func.flush(ctx);
 
        return rc;
 }
@@ -984,7 +231,7 @@ int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size,
        real_phys_addr = phys_addr;
 
        for (i = 0 ; i < npages ; i++) {
-               rc = _hl_mmu_map(ctx, real_virt_addr, real_phys_addr,
+               rc = hdev->mmu_func.map(ctx, real_virt_addr, real_phys_addr,
                                real_page_size, is_dram_addr);
                if (rc)
                        goto err;
@@ -995,21 +242,21 @@ int hl_mmu_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr, u32 page_size,
        }
 
        if (flush_pte)
-               flush(ctx);
+               hdev->mmu_func.flush(ctx);
 
        return 0;
 
 err:
        real_virt_addr = virt_addr;
        for (i = 0 ; i < mapped_cnt ; i++) {
-               if (_hl_mmu_unmap(ctx, real_virt_addr, is_dram_addr))
+               if (hdev->mmu_func.unmap(ctx, real_virt_addr, is_dram_addr))
                        dev_warn_ratelimited(hdev->dev,
                                "failed to unmap va: 0x%llx\n", real_virt_addr);
 
                real_virt_addr += real_page_size;
        }
 
-       flush(ctx);
+       hdev->mmu_func.flush(ctx);
 
        return rc;
 }
@@ -1022,7 +269,10 @@ err:
  */
 void hl_mmu_swap_out(struct hl_ctx *ctx)
 {
+       struct hl_device *hdev = ctx->hdev;
 
+       if (hdev->mmu_enable)
+               hdev->mmu_func.swap_out(ctx);
 }
 
 /*
@@ -1033,5 +283,27 @@ void hl_mmu_swap_out(struct hl_ctx *ctx)
  */
 void hl_mmu_swap_in(struct hl_ctx *ctx)
 {
+       struct hl_device *hdev = ctx->hdev;
+
+       if (hdev->mmu_enable)
+               hdev->mmu_func.swap_in(ctx);
+}
+
+int hl_mmu_if_set_funcs(struct hl_device *hdev)
+{
+       if (!hdev->mmu_enable)
+               return 0;
+
+       switch (hdev->asic_type) {
+       case ASIC_GOYA:
+       case ASIC_GAUDI:
+               hl_mmu_v1_set_funcs(hdev);
+               break;
+       default:
+               dev_err(hdev->dev, "Unrecognized ASIC type %d\n",
+                       hdev->asic_type);
+               return -EOPNOTSUPP;
+       }
 
+       return 0;
 }
diff --git a/drivers/misc/habanalabs/common/mmu_v1.c b/drivers/misc/habanalabs/common/mmu_v1.c
new file mode 100644 (file)
index 0000000..8d1eb52
--- /dev/null
@@ -0,0 +1,863 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Copyright 2016-2019 HabanaLabs, Ltd.
+ * All Rights Reserved.
+ */
+
+#include "habanalabs.h"
+#include "../include/hw_ip/mmu/mmu_general.h"
+
+#include <linux/genalloc.h>
+#include <linux/slab.h>
+
+static inline u64 get_phys_addr(struct hl_ctx *ctx, u64 shadow_addr);
+
+static struct pgt_info *get_pgt_info(struct hl_ctx *ctx, u64 hop_addr)
+{
+       struct pgt_info *pgt_info = NULL;
+
+       hash_for_each_possible(ctx->mmu_shadow_hash, pgt_info, node,
+                               (unsigned long) hop_addr)
+               if (hop_addr == pgt_info->shadow_addr)
+                       break;
+
+       return pgt_info;
+}
+
+static void _free_hop(struct hl_ctx *ctx, struct pgt_info *pgt_info)
+{
+       struct hl_device *hdev = ctx->hdev;
+
+       gen_pool_free(hdev->mmu_priv.mmu_pgt_pool, pgt_info->phys_addr,
+                       hdev->asic_prop.mmu_hop_table_size);
+       hash_del(&pgt_info->node);
+       kfree((u64 *) (uintptr_t) pgt_info->shadow_addr);
+       kfree(pgt_info);
+}
+
+static void free_hop(struct hl_ctx *ctx, u64 hop_addr)
+{
+       struct pgt_info *pgt_info = get_pgt_info(ctx, hop_addr);
+
+       _free_hop(ctx, pgt_info);
+}
+
+static u64 alloc_hop(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       struct pgt_info *pgt_info;
+       u64 phys_addr, shadow_addr;
+
+       pgt_info = kmalloc(sizeof(*pgt_info), GFP_KERNEL);
+       if (!pgt_info)
+               return ULLONG_MAX;
+
+       phys_addr = (u64) gen_pool_alloc(hdev->mmu_priv.mmu_pgt_pool,
+                                       prop->mmu_hop_table_size);
+       if (!phys_addr) {
+               dev_err(hdev->dev, "failed to allocate page\n");
+               goto pool_add_err;
+       }
+
+       shadow_addr = (u64) (uintptr_t) kzalloc(prop->mmu_hop_table_size,
+                                               GFP_KERNEL);
+       if (!shadow_addr)
+               goto shadow_err;
+
+       pgt_info->phys_addr = phys_addr;
+       pgt_info->shadow_addr = shadow_addr;
+       pgt_info->ctx = ctx;
+       pgt_info->num_of_ptes = 0;
+       hash_add(ctx->mmu_shadow_hash, &pgt_info->node, shadow_addr);
+
+       return shadow_addr;
+
+shadow_err:
+       gen_pool_free(hdev->mmu_priv.mmu_pgt_pool, phys_addr,
+                       prop->mmu_hop_table_size);
+pool_add_err:
+       kfree(pgt_info);
+
+       return ULLONG_MAX;
+}
+
+static inline u64 get_phys_hop0_addr(struct hl_ctx *ctx)
+{
+       return ctx->hdev->asic_prop.mmu_pgt_addr +
+                       (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size);
+}
+
+static inline u64 get_hop0_addr(struct hl_ctx *ctx)
+{
+       return (u64) (uintptr_t) ctx->hdev->mmu_priv.mmu_shadow_hop0 +
+                       (ctx->asid * ctx->hdev->asic_prop.mmu_hop_table_size);
+}
+
+static void flush(struct hl_ctx *ctx)
+{
+       /* flush all writes from all cores to reach PCI */
+       mb();
+       ctx->hdev->asic_funcs->read_pte(ctx->hdev, get_phys_hop0_addr(ctx));
+}
+
+/* transform the value to physical address when writing to H/W */
+static inline void write_pte(struct hl_ctx *ctx, u64 shadow_pte_addr, u64 val)
+{
+       /*
+        * The value to write is actually the address of the next shadow hop +
+        * flags at the 12 LSBs.
+        * Hence in order to get the value to write to the physical PTE, we
+        * clear the 12 LSBs and translate the shadow hop to its associated
+        * physical hop, and add back the original 12 LSBs.
+        */
+       u64 phys_val = get_phys_addr(ctx, val & HOP_PHYS_ADDR_MASK) |
+                               (val & FLAGS_MASK);
+
+       ctx->hdev->asic_funcs->write_pte(ctx->hdev,
+                                       get_phys_addr(ctx, shadow_pte_addr),
+                                       phys_val);
+
+       *(u64 *) (uintptr_t) shadow_pte_addr = val;
+}
+
+/* do not transform the value to physical address when writing to H/W */
+static inline void write_final_pte(struct hl_ctx *ctx, u64 shadow_pte_addr,
+                                       u64 val)
+{
+       ctx->hdev->asic_funcs->write_pte(ctx->hdev,
+                                       get_phys_addr(ctx, shadow_pte_addr),
+                                       val);
+       *(u64 *) (uintptr_t) shadow_pte_addr = val;
+}
+
+/* clear the last and present bits */
+static inline void clear_pte(struct hl_ctx *ctx, u64 pte_addr)
+{
+       /* no need to transform the value to physical address */
+       write_final_pte(ctx, pte_addr, 0);
+}
+
+static inline void get_pte(struct hl_ctx *ctx, u64 hop_addr)
+{
+       get_pgt_info(ctx, hop_addr)->num_of_ptes++;
+}
+
+/*
+ * put_pte - decrement the num of ptes and free the hop if possible
+ *
+ * @ctx: pointer to the context structure
+ * @hop_addr: addr of the hop
+ *
+ * This function returns the number of ptes left on this hop. If the number is
+ * 0, it means the pte was freed.
+ */
+static inline int put_pte(struct hl_ctx *ctx, u64 hop_addr)
+{
+       struct pgt_info *pgt_info = get_pgt_info(ctx, hop_addr);
+       int num_of_ptes_left;
+
+       pgt_info->num_of_ptes--;
+
+       /*
+        * Need to save the number of ptes left because free_hop might free
+        * the pgt_info
+        */
+       num_of_ptes_left = pgt_info->num_of_ptes;
+       if (!num_of_ptes_left)
+               _free_hop(ctx, pgt_info);
+
+       return num_of_ptes_left;
+}
+
+static inline u64 get_hopN_pte_addr(struct hl_ctx *ctx, u64 hop_addr,
+                                       u64 virt_addr, u64 mask, u64 shift)
+{
+       return hop_addr + ctx->hdev->asic_prop.mmu_pte_size *
+                       ((virt_addr & mask) >> shift);
+}
+
+static inline u64 get_hop0_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_prop,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop0_mask,
+                                       mmu_prop->hop0_shift);
+}
+
+static inline u64 get_hop1_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_prop,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop1_mask,
+                                       mmu_prop->hop1_shift);
+}
+
+static inline u64 get_hop2_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_prop,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop2_mask,
+                                       mmu_prop->hop2_shift);
+}
+
+static inline u64 get_hop3_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_prop,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop3_mask,
+                                       mmu_prop->hop3_shift);
+}
+
+static inline u64 get_hop4_pte_addr(struct hl_ctx *ctx,
+                                       struct hl_mmu_properties *mmu_prop,
+                                       u64 hop_addr, u64 vaddr)
+{
+       return get_hopN_pte_addr(ctx, hop_addr, vaddr, mmu_prop->hop4_mask,
+                                       mmu_prop->hop4_shift);
+}
+
+static inline u64 get_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte)
+{
+       if (curr_pte & PAGE_PRESENT_MASK)
+               return curr_pte & HOP_PHYS_ADDR_MASK;
+       else
+               return ULLONG_MAX;
+}
+
+static inline u64 get_alloc_next_hop_addr(struct hl_ctx *ctx, u64 curr_pte,
+                                               bool *is_new_hop)
+{
+       u64 hop_addr = get_next_hop_addr(ctx, curr_pte);
+
+       if (hop_addr == ULLONG_MAX) {
+               hop_addr = alloc_hop(ctx);
+               *is_new_hop = (hop_addr != ULLONG_MAX);
+       }
+
+       return hop_addr;
+}
+
+/* translates shadow address inside hop to a physical address */
+static inline u64 get_phys_addr(struct hl_ctx *ctx, u64 shadow_addr)
+{
+       u64 page_mask = (ctx->hdev->asic_prop.mmu_hop_table_size - 1);
+       u64 shadow_hop_addr = shadow_addr & ~page_mask;
+       u64 pte_offset = shadow_addr & page_mask;
+       u64 phys_hop_addr;
+
+       if (shadow_hop_addr != get_hop0_addr(ctx))
+               phys_hop_addr = get_pgt_info(ctx, shadow_hop_addr)->phys_addr;
+       else
+               phys_hop_addr = get_phys_hop0_addr(ctx);
+
+       return phys_hop_addr + pte_offset;
+}
+
+static int dram_default_mapping_init(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       u64 num_of_hop3, total_hops, hop0_addr, hop1_addr, hop2_addr,
+               hop2_pte_addr, hop3_pte_addr, pte_val;
+       int rc, i, j, hop3_allocated = 0;
+
+       if ((!hdev->dram_supports_virtual_memory) ||
+                       (!hdev->dram_default_page_mapping) ||
+                       (ctx->asid == HL_KERNEL_ASID_ID))
+               return 0;
+
+       num_of_hop3 = prop->dram_size_for_default_page_mapping;
+       do_div(num_of_hop3, prop->dram_page_size);
+       do_div(num_of_hop3, PTE_ENTRIES_IN_HOP);
+
+       /* add hop1 and hop2 */
+       total_hops = num_of_hop3 + 2;
+
+       ctx->dram_default_hops = kzalloc(HL_PTE_SIZE * total_hops,  GFP_KERNEL);
+       if (!ctx->dram_default_hops)
+               return -ENOMEM;
+
+       hop0_addr = get_hop0_addr(ctx);
+
+       hop1_addr = alloc_hop(ctx);
+       if (hop1_addr == ULLONG_MAX) {
+               dev_err(hdev->dev, "failed to alloc hop 1\n");
+               rc = -ENOMEM;
+               goto hop1_err;
+       }
+
+       ctx->dram_default_hops[total_hops - 1] = hop1_addr;
+
+       hop2_addr = alloc_hop(ctx);
+       if (hop2_addr == ULLONG_MAX) {
+               dev_err(hdev->dev, "failed to alloc hop 2\n");
+               rc = -ENOMEM;
+               goto hop2_err;
+       }
+
+       ctx->dram_default_hops[total_hops - 2] = hop2_addr;
+
+       for (i = 0 ; i < num_of_hop3 ; i++) {
+               ctx->dram_default_hops[i] = alloc_hop(ctx);
+               if (ctx->dram_default_hops[i] == ULLONG_MAX) {
+                       dev_err(hdev->dev, "failed to alloc hop 3, i: %d\n", i);
+                       rc = -ENOMEM;
+                       goto hop3_err;
+               }
+               hop3_allocated++;
+       }
+
+       /* need only pte 0 in hops 0 and 1 */
+       pte_val = (hop1_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
+       write_pte(ctx, hop0_addr, pte_val);
+
+       pte_val = (hop2_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
+       write_pte(ctx, hop1_addr, pte_val);
+       get_pte(ctx, hop1_addr);
+
+       hop2_pte_addr = hop2_addr;
+       for (i = 0 ; i < num_of_hop3 ; i++) {
+               pte_val = (ctx->dram_default_hops[i] & HOP_PHYS_ADDR_MASK) |
+                               PAGE_PRESENT_MASK;
+               write_pte(ctx, hop2_pte_addr, pte_val);
+               get_pte(ctx, hop2_addr);
+               hop2_pte_addr += HL_PTE_SIZE;
+       }
+
+       pte_val = (prop->mmu_dram_default_page_addr & HOP_PHYS_ADDR_MASK) |
+                       LAST_MASK | PAGE_PRESENT_MASK;
+
+       for (i = 0 ; i < num_of_hop3 ; i++) {
+               hop3_pte_addr = ctx->dram_default_hops[i];
+               for (j = 0 ; j < PTE_ENTRIES_IN_HOP ; j++) {
+                       write_final_pte(ctx, hop3_pte_addr, pte_val);
+                       get_pte(ctx, ctx->dram_default_hops[i]);
+                       hop3_pte_addr += HL_PTE_SIZE;
+               }
+       }
+
+       flush(ctx);
+
+       return 0;
+
+hop3_err:
+       for (i = 0 ; i < hop3_allocated ; i++)
+               free_hop(ctx, ctx->dram_default_hops[i]);
+
+       free_hop(ctx, hop2_addr);
+hop2_err:
+       free_hop(ctx, hop1_addr);
+hop1_err:
+       kfree(ctx->dram_default_hops);
+
+       return rc;
+}
+
+static void dram_default_mapping_fini(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       u64 num_of_hop3, total_hops, hop0_addr, hop1_addr, hop2_addr,
+               hop2_pte_addr, hop3_pte_addr;
+       int i, j;
+
+       if ((!hdev->dram_supports_virtual_memory) ||
+                       (!hdev->dram_default_page_mapping) ||
+                       (ctx->asid == HL_KERNEL_ASID_ID))
+               return;
+
+       num_of_hop3 = prop->dram_size_for_default_page_mapping;
+       do_div(num_of_hop3, prop->dram_page_size);
+       do_div(num_of_hop3, PTE_ENTRIES_IN_HOP);
+
+       hop0_addr = get_hop0_addr(ctx);
+       /* add hop1 and hop2 */
+       total_hops = num_of_hop3 + 2;
+       hop1_addr = ctx->dram_default_hops[total_hops - 1];
+       hop2_addr = ctx->dram_default_hops[total_hops - 2];
+
+       for (i = 0 ; i < num_of_hop3 ; i++) {
+               hop3_pte_addr = ctx->dram_default_hops[i];
+               for (j = 0 ; j < PTE_ENTRIES_IN_HOP ; j++) {
+                       clear_pte(ctx, hop3_pte_addr);
+                       put_pte(ctx, ctx->dram_default_hops[i]);
+                       hop3_pte_addr += HL_PTE_SIZE;
+               }
+       }
+
+       hop2_pte_addr = hop2_addr;
+       hop2_pte_addr = hop2_addr;
+       for (i = 0 ; i < num_of_hop3 ; i++) {
+               clear_pte(ctx, hop2_pte_addr);
+               put_pte(ctx, hop2_addr);
+               hop2_pte_addr += HL_PTE_SIZE;
+       }
+
+       clear_pte(ctx, hop1_addr);
+       put_pte(ctx, hop1_addr);
+       clear_pte(ctx, hop0_addr);
+
+       kfree(ctx->dram_default_hops);
+
+       flush(ctx);
+}
+
+/**
+ * hl_mmu_v1_init() - initialize the MMU module.
+ * @hdev: habanalabs device structure.
+ *
+ * This function does the following:
+ * - Create a pool of pages for pgt_infos.
+ * - Create a shadow table for pgt
+ *
+ * Return: 0 for success, non-zero for failure.
+ */
+static int hl_mmu_v1_init(struct hl_device *hdev)
+{
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       int rc;
+
+       hdev->mmu_priv.mmu_pgt_pool =
+                       gen_pool_create(__ffs(prop->mmu_hop_table_size), -1);
+
+       if (!hdev->mmu_priv.mmu_pgt_pool) {
+               dev_err(hdev->dev, "Failed to create page gen pool\n");
+               return -ENOMEM;
+       }
+
+       rc = gen_pool_add(hdev->mmu_priv.mmu_pgt_pool, prop->mmu_pgt_addr +
+                       prop->mmu_hop0_tables_total_size,
+                       prop->mmu_pgt_size - prop->mmu_hop0_tables_total_size,
+                       -1);
+       if (rc) {
+               dev_err(hdev->dev, "Failed to add memory to page gen pool\n");
+               goto err_pool_add;
+       }
+
+       hdev->mmu_priv.mmu_shadow_hop0 = kvmalloc_array(prop->max_asid,
+                                               prop->mmu_hop_table_size,
+                                               GFP_KERNEL | __GFP_ZERO);
+       if (ZERO_OR_NULL_PTR(hdev->mmu_priv.mmu_shadow_hop0)) {
+               rc = -ENOMEM;
+               goto err_pool_add;
+       }
+
+       /* MMU H/W init will be done in device hw_init() */
+
+       return 0;
+
+err_pool_add:
+       gen_pool_destroy(hdev->mmu_priv.mmu_pgt_pool);
+
+       return rc;
+}
+
+/**
+ * hl_mmu_fini() - release the MMU module.
+ * @hdev: habanalabs device structure.
+ *
+ * This function does the following:
+ * - Disable MMU in H/W.
+ * - Free the pgt_infos pool.
+ *
+ * All contexts should be freed before calling this function.
+ */
+static void hl_mmu_v1_fini(struct hl_device *hdev)
+{
+       /* MMU H/W fini was already done in device hw_fini() */
+
+       kvfree(hdev->mmu_priv.mmu_shadow_hop0);
+       gen_pool_destroy(hdev->mmu_priv.mmu_pgt_pool);
+}
+
+/**
+ * hl_mmu_ctx_init() - initialize a context for using the MMU module.
+ * @ctx: pointer to the context structure to initialize.
+ *
+ * Initialize a mutex to protect the concurrent mapping flow, a hash to hold all
+ * page tables hops related to this context.
+ * Return: 0 on success, non-zero otherwise.
+ */
+static int hl_mmu_v1_ctx_init(struct hl_ctx *ctx)
+{
+       mutex_init(&ctx->mmu_lock);
+       hash_init(ctx->mmu_shadow_hash);
+
+       return dram_default_mapping_init(ctx);
+}
+
+/*
+ * hl_mmu_ctx_fini - disable a ctx from using the mmu module
+ *
+ * @ctx: pointer to the context structure
+ *
+ * This function does the following:
+ * - Free any pgts which were not freed yet
+ * - Free the mutex
+ * - Free DRAM default page mapping hops
+ */
+static void hl_mmu_v1_ctx_fini(struct hl_ctx *ctx)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct pgt_info *pgt_info;
+       struct hlist_node *tmp;
+       int i;
+
+       dram_default_mapping_fini(ctx);
+
+       if (!hash_empty(ctx->mmu_shadow_hash))
+               dev_err(hdev->dev, "ctx %d is freed while it has pgts in use\n",
+                       ctx->asid);
+
+       hash_for_each_safe(ctx->mmu_shadow_hash, i, tmp, pgt_info, node) {
+               dev_err_ratelimited(hdev->dev,
+                       "pgt_info of addr 0x%llx of asid %d was not destroyed, num_ptes: %d\n",
+                       pgt_info->phys_addr, ctx->asid, pgt_info->num_of_ptes);
+               _free_hop(ctx, pgt_info);
+       }
+
+       mutex_destroy(&ctx->mmu_lock);
+}
+
+static int _hl_mmu_v1_unmap(struct hl_ctx *ctx,
+                               u64 virt_addr, bool is_dram_addr)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       struct hl_mmu_properties *mmu_prop;
+       u64 hop0_addr = 0, hop0_pte_addr = 0,
+               hop1_addr = 0, hop1_pte_addr = 0,
+               hop2_addr = 0, hop2_pte_addr = 0,
+               hop3_addr = 0, hop3_pte_addr = 0,
+               hop4_addr = 0, hop4_pte_addr = 0,
+               curr_pte;
+       bool is_huge, clear_hop3 = true;
+
+       /* shifts and masks are the same in PMMU and HPMMU, use one of them */
+       mmu_prop = is_dram_addr ? &prop->dmmu : &prop->pmmu;
+
+       hop0_addr = get_hop0_addr(ctx);
+       hop0_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop0_addr, virt_addr);
+
+       curr_pte = *(u64 *) (uintptr_t) hop0_pte_addr;
+
+       hop1_addr = get_next_hop_addr(ctx, curr_pte);
+
+       if (hop1_addr == ULLONG_MAX)
+               goto not_mapped;
+
+       hop1_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop1_addr, virt_addr);
+
+       curr_pte = *(u64 *) (uintptr_t) hop1_pte_addr;
+
+       hop2_addr = get_next_hop_addr(ctx, curr_pte);
+
+       if (hop2_addr == ULLONG_MAX)
+               goto not_mapped;
+
+       hop2_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop2_addr, virt_addr);
+
+       curr_pte = *(u64 *) (uintptr_t) hop2_pte_addr;
+
+       hop3_addr = get_next_hop_addr(ctx, curr_pte);
+
+       if (hop3_addr == ULLONG_MAX)
+               goto not_mapped;
+
+       hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr);
+
+       curr_pte = *(u64 *) (uintptr_t) hop3_pte_addr;
+
+       is_huge = curr_pte & LAST_MASK;
+
+       if (is_dram_addr && !is_huge) {
+               dev_err(hdev->dev,
+                               "DRAM unmapping should use huge pages only\n");
+               return -EFAULT;
+       }
+
+       if (!is_huge) {
+               hop4_addr = get_next_hop_addr(ctx, curr_pte);
+
+               if (hop4_addr == ULLONG_MAX)
+                       goto not_mapped;
+
+               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop4_addr,
+                                                       virt_addr);
+
+               curr_pte = *(u64 *) (uintptr_t) hop4_pte_addr;
+
+               clear_hop3 = false;
+       }
+
+       if (hdev->dram_default_page_mapping && is_dram_addr) {
+               u64 default_pte = (prop->mmu_dram_default_page_addr &
+                               HOP_PHYS_ADDR_MASK) | LAST_MASK |
+                                       PAGE_PRESENT_MASK;
+               if (curr_pte == default_pte) {
+                       dev_err(hdev->dev,
+                               "DRAM: hop3 PTE points to zero page, can't unmap, va: 0x%llx\n",
+                                       virt_addr);
+                       goto not_mapped;
+               }
+
+               if (!(curr_pte & PAGE_PRESENT_MASK)) {
+                       dev_err(hdev->dev,
+                               "DRAM: hop3 PTE is cleared! can't unmap, va: 0x%llx\n",
+                                       virt_addr);
+                       goto not_mapped;
+               }
+
+               write_final_pte(ctx, hop3_pte_addr, default_pte);
+               put_pte(ctx, hop3_addr);
+       } else {
+               if (!(curr_pte & PAGE_PRESENT_MASK))
+                       goto not_mapped;
+
+               if (hop4_addr)
+                       clear_pte(ctx, hop4_pte_addr);
+               else
+                       clear_pte(ctx, hop3_pte_addr);
+
+               if (hop4_addr && !put_pte(ctx, hop4_addr))
+                       clear_hop3 = true;
+
+               if (!clear_hop3)
+                       goto mapped;
+
+               clear_pte(ctx, hop3_pte_addr);
+
+               if (put_pte(ctx, hop3_addr))
+                       goto mapped;
+
+               clear_pte(ctx, hop2_pte_addr);
+
+               if (put_pte(ctx, hop2_addr))
+                       goto mapped;
+
+               clear_pte(ctx, hop1_pte_addr);
+
+               if (put_pte(ctx, hop1_addr))
+                       goto mapped;
+
+               clear_pte(ctx, hop0_pte_addr);
+       }
+
+mapped:
+       return 0;
+
+not_mapped:
+       dev_err(hdev->dev, "virt addr 0x%llx is not mapped to phys addr\n",
+               virt_addr);
+
+       return -EINVAL;
+}
+
+static int _hl_mmu_v1_map(struct hl_ctx *ctx, u64 virt_addr, u64 phys_addr,
+                       u32 page_size, bool is_dram_addr)
+{
+       struct hl_device *hdev = ctx->hdev;
+       struct asic_fixed_properties *prop = &hdev->asic_prop;
+       struct hl_mmu_properties *mmu_prop;
+       u64 hop0_addr = 0, hop0_pte_addr = 0,
+               hop1_addr = 0, hop1_pte_addr = 0,
+               hop2_addr = 0, hop2_pte_addr = 0,
+               hop3_addr = 0, hop3_pte_addr = 0,
+               hop4_addr = 0, hop4_pte_addr = 0,
+               curr_pte = 0;
+       bool hop1_new = false, hop2_new = false, hop3_new = false,
+               hop4_new = false, is_huge;
+       int rc = -ENOMEM;
+
+       /*
+        * This mapping function can map a page or a huge page. For huge page
+        * there are only 3 hops rather than 4. Currently the DRAM allocation
+        * uses huge pages only but user memory could have been allocated with
+        * one of the two page sizes. Since this is a common code for all the
+        * three cases, we need this hugs page check.
+        */
+       if (is_dram_addr) {
+               mmu_prop = &prop->dmmu;
+               is_huge = true;
+       } else if (page_size == prop->pmmu_huge.page_size) {
+               mmu_prop = &prop->pmmu_huge;
+               is_huge = true;
+       } else {
+               mmu_prop = &prop->pmmu;
+               is_huge = false;
+       }
+
+       hop0_addr = get_hop0_addr(ctx);
+       hop0_pte_addr = get_hop0_pte_addr(ctx, mmu_prop, hop0_addr, virt_addr);
+       curr_pte = *(u64 *) (uintptr_t) hop0_pte_addr;
+
+       hop1_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop1_new);
+       if (hop1_addr == ULLONG_MAX)
+               goto err;
+
+       hop1_pte_addr = get_hop1_pte_addr(ctx, mmu_prop, hop1_addr, virt_addr);
+       curr_pte = *(u64 *) (uintptr_t) hop1_pte_addr;
+
+       hop2_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop2_new);
+       if (hop2_addr == ULLONG_MAX)
+               goto err;
+
+       hop2_pte_addr = get_hop2_pte_addr(ctx, mmu_prop, hop2_addr, virt_addr);
+       curr_pte = *(u64 *) (uintptr_t) hop2_pte_addr;
+
+       hop3_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop3_new);
+       if (hop3_addr == ULLONG_MAX)
+               goto err;
+
+       hop3_pte_addr = get_hop3_pte_addr(ctx, mmu_prop, hop3_addr, virt_addr);
+       curr_pte = *(u64 *) (uintptr_t) hop3_pte_addr;
+
+       if (!is_huge) {
+               hop4_addr = get_alloc_next_hop_addr(ctx, curr_pte, &hop4_new);
+               if (hop4_addr == ULLONG_MAX)
+                       goto err;
+
+               hop4_pte_addr = get_hop4_pte_addr(ctx, mmu_prop, hop4_addr,
+                                                       virt_addr);
+               curr_pte = *(u64 *) (uintptr_t) hop4_pte_addr;
+       }
+
+       if (hdev->dram_default_page_mapping && is_dram_addr) {
+               u64 default_pte = (prop->mmu_dram_default_page_addr &
+                                       HOP_PHYS_ADDR_MASK) | LAST_MASK |
+                                               PAGE_PRESENT_MASK;
+
+               if (curr_pte != default_pte) {
+                       dev_err(hdev->dev,
+                               "DRAM: mapping already exists for virt_addr 0x%llx\n",
+                                       virt_addr);
+                       rc = -EINVAL;
+                       goto err;
+               }
+
+               if (hop1_new || hop2_new || hop3_new || hop4_new) {
+                       dev_err(hdev->dev,
+                               "DRAM mapping should not allocate more hops\n");
+                       rc = -EFAULT;
+                       goto err;
+               }
+       } else if (curr_pte & PAGE_PRESENT_MASK) {
+               dev_err(hdev->dev,
+                       "mapping already exists for virt_addr 0x%llx\n",
+                               virt_addr);
+
+               dev_dbg(hdev->dev, "hop0 pte: 0x%llx (0x%llx)\n",
+                       *(u64 *) (uintptr_t) hop0_pte_addr, hop0_pte_addr);
+               dev_dbg(hdev->dev, "hop1 pte: 0x%llx (0x%llx)\n",
+                       *(u64 *) (uintptr_t) hop1_pte_addr, hop1_pte_addr);
+               dev_dbg(hdev->dev, "hop2 pte: 0x%llx (0x%llx)\n",
+                       *(u64 *) (uintptr_t) hop2_pte_addr, hop2_pte_addr);
+               dev_dbg(hdev->dev, "hop3 pte: 0x%llx (0x%llx)\n",
+                       *(u64 *) (uintptr_t) hop3_pte_addr, hop3_pte_addr);
+
+               if (!is_huge)
+                       dev_dbg(hdev->dev, "hop4 pte: 0x%llx (0x%llx)\n",
+                               *(u64 *) (uintptr_t) hop4_pte_addr,
+                               hop4_pte_addr);
+
+               rc = -EINVAL;
+               goto err;
+       }
+
+       curr_pte = (phys_addr & HOP_PHYS_ADDR_MASK) | LAST_MASK
+                       | PAGE_PRESENT_MASK;
+
+       if (is_huge)
+               write_final_pte(ctx, hop3_pte_addr, curr_pte);
+       else
+               write_final_pte(ctx, hop4_pte_addr, curr_pte);
+
+       if (hop1_new) {
+               curr_pte =
+                       (hop1_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
+               write_pte(ctx, hop0_pte_addr, curr_pte);
+       }
+       if (hop2_new) {
+               curr_pte =
+                       (hop2_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
+               write_pte(ctx, hop1_pte_addr, curr_pte);
+               get_pte(ctx, hop1_addr);
+       }
+       if (hop3_new) {
+               curr_pte =
+                       (hop3_addr & HOP_PHYS_ADDR_MASK) | PAGE_PRESENT_MASK;
+               write_pte(ctx, hop2_pte_addr, curr_pte);
+               get_pte(ctx, hop2_addr);
+       }
+
+       if (!is_huge) {
+               if (hop4_new) {
+                       curr_pte = (hop4_addr & HOP_PHYS_ADDR_MASK) |
+                                       PAGE_PRESENT_MASK;
+                       write_pte(ctx, hop3_pte_addr, curr_pte);
+                       get_pte(ctx, hop3_addr);
+               }
+
+               get_pte(ctx, hop4_addr);
+       } else {
+               get_pte(ctx, hop3_addr);
+       }
+
+       return 0;
+
+err:
+       if (hop4_new)
+               free_hop(ctx, hop4_addr);
+       if (hop3_new)
+               free_hop(ctx, hop3_addr);
+       if (hop2_new)
+               free_hop(ctx, hop2_addr);
+       if (hop1_new)
+               free_hop(ctx, hop1_addr);
+
+       return rc;
+}
+
+/*
+ * hl_mmu_v1_swap_out - marks all mapping of the given ctx as swapped out
+ *
+ * @ctx: pointer to the context structure
+ *
+ */
+static void hl_mmu_v1_swap_out(struct hl_ctx *ctx)
+{
+
+}
+
+/*
+ * hl_mmu_v1_swap_in - marks all mapping of the given ctx as swapped in
+ *
+ * @ctx: pointer to the context structure
+ *
+ */
+static void hl_mmu_v1_swap_in(struct hl_ctx *ctx)
+{
+
+}
+
+/*
+ * hl_mmu_v1_prepare - prepare mmu  for working with mmu v1
+ *
+ * @hdev: pointer to the device structure
+ */
+void hl_mmu_v1_set_funcs(struct hl_device *hdev)
+{
+       struct hl_mmu_funcs *mmu = &hdev->mmu_func;
+
+       mmu->init = hl_mmu_v1_init;
+       mmu->fini = hl_mmu_v1_fini;
+       mmu->ctx_init = hl_mmu_v1_ctx_init;
+       mmu->ctx_fini = hl_mmu_v1_ctx_fini;
+       mmu->map = _hl_mmu_v1_map;
+       mmu->unmap = _hl_mmu_v1_unmap;
+       mmu->flush = flush;
+       mmu->swap_out = hl_mmu_v1_swap_out;
+       mmu->swap_in = hl_mmu_v1_swap_in;
+}
index 7bd3737..4327e57 100644 (file)
@@ -9,7 +9,6 @@
 #include "../include/hw_ip/pci/pci_general.h"
 
 #include <linux/pci.h>
-#include <linux/bitfield.h>
 
 #define HL_PLDM_PCI_ELBI_TIMEOUT_MSEC  (HL_PCI_ELBI_TIMEOUT_MSEC * 10)
 
@@ -227,7 +226,7 @@ int hl_pci_set_inbound_region(struct hl_device *hdev, u8 region,
        }
 
        /* Point to the specified address */
-       rc = hl_pci_iatu_write(hdev, offset + 0x14,
+       rc |= hl_pci_iatu_write(hdev, offset + 0x14,
                        lower_32_bits(pci_region->addr));
        rc |= hl_pci_iatu_write(hdev, offset + 0x18,
                        upper_32_bits(pci_region->addr));
@@ -339,12 +338,17 @@ static int hl_pci_set_dma_mask(struct hl_device *hdev)
 /**
  * hl_pci_init() - PCI initialization code.
  * @hdev: Pointer to hl_device structure.
+ * @cpu_boot_status_reg: status register of the device's CPU
+ * @boot_err0_reg: boot error register of the device's CPU
+ * @preboot_ver_timeout: how much to wait before bailing out on reading
+ *                       the preboot version
  *
  * Set DMA masks, initialize the PCI controller and map the PCI BARs.
  *
  * Return: 0 on success, non-zero for failure.
  */
-int hl_pci_init(struct hl_device *hdev)
+int hl_pci_init(struct hl_device *hdev, u32 cpu_boot_status_reg,
+               u32 boot_err0_reg, u32 preboot_ver_timeout)
 {
        struct pci_dev *pdev = hdev->pdev;
        int rc;
@@ -369,15 +373,26 @@ int hl_pci_init(struct hl_device *hdev)
        rc = hdev->asic_funcs->init_iatu(hdev);
        if (rc) {
                dev_err(hdev->dev, "Failed to initialize iATU\n");
-               goto disable_device;
+               goto unmap_pci_bars;
        }
 
        rc = hl_pci_set_dma_mask(hdev);
        if (rc)
-               goto disable_device;
+               goto unmap_pci_bars;
+
+       /* Before continuing in the initialization, we need to read the preboot
+        * version to determine whether we run with a security-enabled firmware
+        * The check will be done in each ASIC's specific code
+        */
+       rc = hl_fw_read_preboot_ver(hdev, cpu_boot_status_reg, boot_err0_reg,
+                                       preboot_ver_timeout);
+       if (rc)
+               goto unmap_pci_bars;
 
        return 0;
 
+unmap_pci_bars:
+       hl_pci_bars_unmap(hdev);
 disable_device:
        pci_clear_master(pdev);
        pci_disable_device(pdev);
index b3cb0ac..3ceae87 100644 (file)
 
 long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        long result;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
        if (curr)
-               pkt.ctl = cpu_to_le32(ARMCP_PACKET_FREQUENCY_CURR_GET <<
-                                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_CURR_GET <<
+                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        else
-               pkt.ctl = cpu_to_le32(ARMCP_PACKET_FREQUENCY_GET <<
-                                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+               pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_GET <<
+                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.pll_index = cpu_to_le32(pll_index);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
@@ -40,13 +40,13 @@ long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr)
 
 void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_FREQUENCY_SET <<
-                                       ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_FREQUENCY_SET <<
+                                       CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.pll_index = cpu_to_le32(pll_index);
        pkt.value = cpu_to_le64(freq);
 
@@ -61,14 +61,14 @@ void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
 
 u64 hl_get_max_power(struct hl_device *hdev)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        long result;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_MAX_POWER_GET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_GET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
                                                0, &result);
@@ -81,16 +81,16 @@ u64 hl_get_max_power(struct hl_device *hdev)
        return result;
 }
 
-void hl_set_max_power(struct hl_device *hdev, u64 value)
+void hl_set_max_power(struct hl_device *hdev)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_MAX_POWER_SET <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
-       pkt.value = cpu_to_le64(value);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_MAX_POWER_SET <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.value = cpu_to_le64(hdev->max_power);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
                                                0, NULL);
@@ -112,7 +112,7 @@ static ssize_t armcp_kernel_ver_show(struct device *dev,
 {
        struct hl_device *hdev = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%s", hdev->asic_prop.armcp_info.kernel_version);
+       return sprintf(buf, "%s", hdev->asic_prop.cpucp_info.kernel_version);
 }
 
 static ssize_t armcp_ver_show(struct device *dev, struct device_attribute *attr,
@@ -120,7 +120,7 @@ static ssize_t armcp_ver_show(struct device *dev, struct device_attribute *attr,
 {
        struct hl_device *hdev = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%s\n", hdev->asic_prop.armcp_info.armcp_version);
+       return sprintf(buf, "%s\n", hdev->asic_prop.cpucp_info.cpucp_version);
 }
 
 static ssize_t cpld_ver_show(struct device *dev, struct device_attribute *attr,
@@ -129,7 +129,23 @@ static ssize_t cpld_ver_show(struct device *dev, struct device_attribute *attr,
        struct hl_device *hdev = dev_get_drvdata(dev);
 
        return sprintf(buf, "0x%08x\n",
-                       hdev->asic_prop.armcp_info.cpld_version);
+                       hdev->asic_prop.cpucp_info.cpld_version);
+}
+
+static ssize_t cpucp_kernel_ver_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       struct hl_device *hdev = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%s", hdev->asic_prop.cpucp_info.kernel_version);
+}
+
+static ssize_t cpucp_ver_show(struct device *dev, struct device_attribute *attr,
+                               char *buf)
+{
+       struct hl_device *hdev = dev_get_drvdata(dev);
+
+       return sprintf(buf, "%s\n", hdev->asic_prop.cpucp_info.cpucp_version);
 }
 
 static ssize_t infineon_ver_show(struct device *dev,
@@ -138,7 +154,7 @@ static ssize_t infineon_ver_show(struct device *dev,
        struct hl_device *hdev = dev_get_drvdata(dev);
 
        return sprintf(buf, "0x%04x\n",
-                       hdev->asic_prop.armcp_info.infineon_version);
+                       hdev->asic_prop.cpucp_info.infineon_version);
 }
 
 static ssize_t fuse_ver_show(struct device *dev, struct device_attribute *attr,
@@ -146,7 +162,7 @@ static ssize_t fuse_ver_show(struct device *dev, struct device_attribute *attr,
 {
        struct hl_device *hdev = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%s\n", hdev->asic_prop.armcp_info.fuse_version);
+       return sprintf(buf, "%s\n", hdev->asic_prop.cpucp_info.fuse_version);
 }
 
 static ssize_t thermal_ver_show(struct device *dev,
@@ -154,7 +170,7 @@ static ssize_t thermal_ver_show(struct device *dev,
 {
        struct hl_device *hdev = dev_get_drvdata(dev);
 
-       return sprintf(buf, "%s", hdev->asic_prop.armcp_info.thermal_version);
+       return sprintf(buf, "%s", hdev->asic_prop.cpucp_info.thermal_version);
 }
 
 static ssize_t preboot_btl_ver_show(struct device *dev,
@@ -316,7 +332,7 @@ static ssize_t max_power_store(struct device *dev,
        }
 
        hdev->max_power = value;
-       hl_set_max_power(hdev, value);
+       hl_set_max_power(hdev);
 
 out:
        return count;
@@ -356,6 +372,8 @@ out:
 static DEVICE_ATTR_RO(armcp_kernel_ver);
 static DEVICE_ATTR_RO(armcp_ver);
 static DEVICE_ATTR_RO(cpld_ver);
+static DEVICE_ATTR_RO(cpucp_kernel_ver);
+static DEVICE_ATTR_RO(cpucp_ver);
 static DEVICE_ATTR_RO(device_type);
 static DEVICE_ATTR_RO(fuse_ver);
 static DEVICE_ATTR_WO(hard_reset);
@@ -380,6 +398,8 @@ static struct attribute *hl_dev_attrs[] = {
        &dev_attr_armcp_kernel_ver.attr,
        &dev_attr_armcp_ver.attr,
        &dev_attr_cpld_ver.attr,
+       &dev_attr_cpucp_kernel_ver.attr,
+       &dev_attr_cpucp_ver.attr,
        &dev_attr_device_type.attr,
        &dev_attr_fuse_ver.attr,
        &dev_attr_hard_reset.attr,
@@ -422,6 +442,7 @@ int hl_sysfs_init(struct hl_device *hdev)
                hdev->pm_mng_profile = PM_AUTO;
        else
                hdev->pm_mng_profile = PM_MANUAL;
+
        hdev->max_power = hdev->asic_prop.max_power_default;
 
        hdev->asic_funcs->add_device_attr(hdev, &hl_dev_clks_attr_group);
index 00a0a72..5f65a16 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/iommu.h>
 #include <linux/seq_file.h>
-#include <linux/bitfield.h>
 
 /*
  * Gaudi security scheme:
@@ -154,6 +153,29 @@ static const u16 gaudi_packet_sizes[MAX_PACKET_ID] = {
        [PACKET_LOAD_AND_EXE]   = sizeof(struct packet_load_and_exe)
 };
 
+static inline bool validate_packet_id(enum packet_id id)
+{
+       switch (id) {
+       case PACKET_WREG_32:
+       case PACKET_WREG_BULK:
+       case PACKET_MSG_LONG:
+       case PACKET_MSG_SHORT:
+       case PACKET_CP_DMA:
+       case PACKET_REPEAT:
+       case PACKET_MSG_PROT:
+       case PACKET_FENCE:
+       case PACKET_LIN_DMA:
+       case PACKET_NOP:
+       case PACKET_STOP:
+       case PACKET_ARB_POINT:
+       case PACKET_WAIT:
+       case PACKET_LOAD_AND_EXE:
+               return true;
+       default:
+               return false;
+       }
+}
+
 static const char * const
 gaudi_tpc_interrupts_cause[GAUDI_NUM_OF_TPC_INTR_CAUSE] = {
        "tpc_address_exceed_slm",
@@ -337,13 +359,14 @@ static int gaudi_memset_device_memory(struct hl_device *hdev, u64 addr,
 static int gaudi_run_tpc_kernel(struct hl_device *hdev, u64 tpc_kernel,
                                u32 tpc_id);
 static int gaudi_mmu_clear_pgt_range(struct hl_device *hdev);
-static int gaudi_armcp_info_get(struct hl_device *hdev);
+static int gaudi_cpucp_info_get(struct hl_device *hdev);
 static void gaudi_disable_clock_gating(struct hl_device *hdev);
 static void gaudi_mmu_prepare(struct hl_device *hdev, u32 asid);
 
 static int gaudi_get_fixed_properties(struct hl_device *hdev)
 {
        struct asic_fixed_properties *prop = &hdev->asic_prop;
+       u32 num_sync_stream_queues = 0;
        int i;
 
        prop->max_queues = GAUDI_QUEUE_ID_SIZE;
@@ -360,6 +383,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
                        prop->hw_queues_props[i].driver_only = 0;
                        prop->hw_queues_props[i].requires_kernel_cb = 1;
                        prop->hw_queues_props[i].supports_sync_stream = 1;
+                       num_sync_stream_queues++;
                } else if (gaudi_queue_type[i] == QUEUE_TYPE_CPU) {
                        prop->hw_queues_props[i].type = QUEUE_TYPE_CPU;
                        prop->hw_queues_props[i].driver_only = 1;
@@ -417,6 +441,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
        prop->pmmu.end_addr =
                        (VA_HOST_SPACE_START + VA_HOST_SPACE_SIZE / 2) - 1;
        prop->pmmu.page_size = PAGE_SIZE_4KB;
+       prop->pmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* PMMU and HPMMU are the same except of page size */
        memcpy(&prop->pmmu_huge, &prop->pmmu, sizeof(prop->pmmu));
@@ -433,7 +458,7 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
        prop->num_of_events = GAUDI_EVENT_SIZE;
        prop->tpc_enabled_mask = TPC_ENABLED_MASK;
 
-       prop->max_power_default = MAX_POWER_DEFAULT;
+       prop->max_power_default = MAX_POWER_DEFAULT_PCI;
 
        prop->cb_pool_cb_cnt = GAUDI_CB_POOL_CB_CNT;
        prop->cb_pool_cb_size = GAUDI_CB_POOL_CB_SIZE;
@@ -441,11 +466,16 @@ static int gaudi_get_fixed_properties(struct hl_device *hdev)
        prop->pcie_dbi_base_address = mmPCIE_DBI_BASE;
        prop->pcie_aux_dbi_reg_addr = CFG_BASE + mmPCIE_AUX_DBI;
 
-       strncpy(prop->armcp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
+       strncpy(prop->cpucp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
                                        CARD_NAME_MAX_LEN);
 
        prop->max_pending_cs = GAUDI_MAX_PENDING_CS;
 
+       prop->first_available_user_sob[HL_GAUDI_WS_DCORE] =
+                       num_sync_stream_queues * HL_RSVD_SOBS;
+       prop->first_available_user_mon[HL_GAUDI_WS_DCORE] =
+                       num_sync_stream_queues * HL_RSVD_MONS;
+
        return 0;
 }
 
@@ -569,10 +599,15 @@ static int gaudi_early_init(struct hl_device *hdev)
 
        prop->dram_pci_bar_size = pci_resource_len(pdev, HBM_BAR_ID);
 
-       rc = hl_pci_init(hdev);
+       rc = hl_pci_init(hdev, mmPSOC_GLOBAL_CONF_CPU_BOOT_STATUS,
+                       mmCPU_BOOT_ERR0, GAUDI_BOOT_FIT_REQ_TIMEOUT_USEC);
        if (rc)
                goto free_queue_props;
 
+       /* GAUDI Firmware does not yet support security */
+       prop->fw_security_disabled = true;
+       dev_info(hdev->dev, "firmware-level security is disabled\n");
+
        return 0;
 
 free_queue_props:
@@ -652,10 +687,10 @@ static int _gaudi_init_tpc_mem(struct hl_device *hdev,
 
        init_tpc_mem_pkt->tsize = cpu_to_le32(tpc_kernel_size);
 
-       ctl = ((PACKET_LIN_DMA << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_LIN_DMA_CTL_LIN_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_RB_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT));
+       ctl = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_LIN_DMA);
+       ctl |= FIELD_PREP(GAUDI_PKT_LIN_DMA_CTL_LIN_MASK, 1);
+       ctl |= FIELD_PREP(GAUDI_PKT_CTL_RB_MASK, 1);
+       ctl |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
 
        init_tpc_mem_pkt->ctl = cpu_to_le32(ctl);
 
@@ -757,13 +792,13 @@ static int gaudi_late_init(struct hl_device *hdev)
        struct gaudi_device *gaudi = hdev->asic_specific;
        int rc;
 
-       rc = gaudi->armcp_info_get(hdev);
+       rc = gaudi->cpucp_info_get(hdev);
        if (rc) {
-               dev_err(hdev->dev, "Failed to get armcp info\n");
+               dev_err(hdev->dev, "Failed to get cpucp info\n");
                return rc;
        }
 
-       rc = hl_fw_send_pci_access_msg(hdev, ARMCP_PACKET_ENABLE_PCI_ACCESS);
+       rc = hl_fw_send_pci_access_msg(hdev, CPUCP_PACKET_ENABLE_PCI_ACCESS);
        if (rc) {
                dev_err(hdev->dev, "Failed to enable PCI access from CPU\n");
                return rc;
@@ -788,7 +823,7 @@ static int gaudi_late_init(struct hl_device *hdev)
        return 0;
 
 disable_pci_access:
-       hl_fw_send_pci_access_msg(hdev, ARMCP_PACKET_DISABLE_PCI_ACCESS);
+       hl_fw_send_pci_access_msg(hdev, CPUCP_PACKET_DISABLE_PCI_ACCESS);
 
        return rc;
 }
@@ -958,7 +993,7 @@ static int gaudi_sw_init(struct hl_device *hdev)
                }
        }
 
-       gaudi->armcp_info_get = gaudi_armcp_info_get;
+       gaudi->cpucp_info_get = gaudi_cpucp_info_get;
 
        gaudi->max_freq_value = GAUDI_MAX_CLK_FREQ;
 
@@ -1830,9 +1865,11 @@ static void gaudi_init_pci_dma_qman(struct hl_device *hdev, int dma_id,
        WREG32(mmDMA0_QM_PQ_PI_0 + q_off, 0);
        WREG32(mmDMA0_QM_PQ_CI_0 + q_off, 0);
 
-       WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x74);
-       WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x14);
-       WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+       WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, QMAN_LDMA_SIZE_OFFSET);
+       WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SRC_OFFSET);
+       WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_DST_OFFSET);
 
        WREG32(mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_0 + q_off, mtr_base_en_lo);
        WREG32(mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_0 + q_off, mtr_base_en_hi);
@@ -1888,6 +1925,9 @@ static void gaudi_init_dma_core(struct hl_device *hdev, int dma_id)
        WREG32(mmDMA0_CORE_RD_MAX_OUTSTAND + dma_offset, 0);
        WREG32(mmDMA0_CORE_RD_MAX_SIZE + dma_offset, 0);
 
+       /* WA for H/W bug H3-2116 */
+       WREG32(mmDMA0_CORE_LBW_MAX_OUTSTAND + dma_offset, 15);
+
        /* STOP_ON bit implies no completion to operation in case of RAZWI */
        if (hdev->stop_on_err)
                dma_err_cfg |= 1 << DMA0_CORE_ERR_CFG_STOP_ON_ERR_SHIFT;
@@ -1987,13 +2027,19 @@ static void gaudi_init_hbm_dma_qman(struct hl_device *hdev, int dma_id,
                WREG32(mmDMA0_QM_PQ_PI_0 + q_off, 0);
                WREG32(mmDMA0_QM_PQ_CI_0 + q_off, 0);
 
-               WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x81BC);
-               WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x81B4);
-               WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SIZE_OFFSET);
+               WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SRC_OFFSET);
+               WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_DST_OFFSET);
        } else {
-               WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x74);
-               WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x14);
-               WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SIZE_OFFSET);
+               WREG32(mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SRC_OFFSET);
+               WREG32(mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_DST_OFFSET);
 
                /* Configure RAZWI IRQ */
                dma_qm_err_cfg = HBM_DMA_QMAN_GLBL_ERR_CFG_MSG_EN_MASK;
@@ -2097,13 +2143,19 @@ static void gaudi_init_mme_qman(struct hl_device *hdev, u32 mme_offset,
                WREG32(mmMME0_QM_PQ_PI_0 + q_off, 0);
                WREG32(mmMME0_QM_PQ_CI_0 + q_off, 0);
 
-               WREG32(mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x81BC);
-               WREG32(mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x81B4);
-               WREG32(mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SIZE_OFFSET);
+               WREG32(mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SRC_OFFSET);
+               WREG32(mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_DST_OFFSET);
        } else {
-               WREG32(mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x74);
-               WREG32(mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x14);
-               WREG32(mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SIZE_OFFSET);
+               WREG32(mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SRC_OFFSET);
+               WREG32(mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_DST_OFFSET);
 
                /* Configure RAZWI IRQ */
                mme_id = mme_offset /
@@ -2211,13 +2263,19 @@ static void gaudi_init_tpc_qman(struct hl_device *hdev, u32 tpc_offset,
                WREG32(mmTPC0_QM_PQ_PI_0 + q_off, 0);
                WREG32(mmTPC0_QM_PQ_CI_0 + q_off, 0);
 
-               WREG32(mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x81BC);
-               WREG32(mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x81B4);
-               WREG32(mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SIZE_OFFSET);
+               WREG32(mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_SRC_OFFSET);
+               WREG32(mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_CPDMA_DST_OFFSET);
        } else {
-               WREG32(mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off, 0x74);
-               WREG32(mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off, 0x14);
-               WREG32(mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off, 0x1C);
+               WREG32(mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SIZE_OFFSET);
+               WREG32(mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_SRC_OFFSET);
+               WREG32(mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 + q_off,
+                                                       QMAN_LDMA_DST_OFFSET);
 
                /* Configure RAZWI IRQ */
                tpc_id = tpc_offset /
@@ -2298,7 +2356,8 @@ static void gaudi_init_tpc_qmans(struct hl_device *hdev)
 
                tpc_offset += mmTPC1_QM_GLBL_CFG0 - mmTPC0_QM_GLBL_CFG0;
 
-               gaudi->hw_cap_initialized |= 1 << (HW_CAP_TPC_SHIFT + tpc_id);
+               gaudi->hw_cap_initialized |=
+                               FIELD_PREP(HW_CAP_TPC_MASK, 1 << tpc_id);
        }
 }
 
@@ -2485,6 +2544,7 @@ static void gaudi_set_clock_gating(struct hl_device *hdev)
 {
        struct gaudi_device *gaudi = hdev->asic_specific;
        u32 qman_offset;
+       bool enable;
        int i;
 
        /* In case we are during debug session, don't enable the clock gate
@@ -2494,46 +2554,43 @@ static void gaudi_set_clock_gating(struct hl_device *hdev)
                return;
 
        for (i = GAUDI_PCI_DMA_1, qman_offset = 0 ; i < GAUDI_HBM_DMA_1 ; i++) {
-               if (!(hdev->clock_gating_mask &
-                                       (BIT_ULL(gaudi_dma_assignment[i]))))
-                       continue;
+               enable = !!(hdev->clock_gating_mask &
+                               (BIT_ULL(gaudi_dma_assignment[i])));
 
                qman_offset = gaudi_dma_assignment[i] * DMA_QMAN_OFFSET;
-               WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, QMAN_CGM1_PWR_GATE_EN);
+               WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset,
+                               enable ? QMAN_CGM1_PWR_GATE_EN : 0);
                WREG32(mmDMA0_QM_CGM_CFG + qman_offset,
-                               QMAN_UPPER_CP_CGM_PWR_GATE_EN);
+                               enable ? QMAN_UPPER_CP_CGM_PWR_GATE_EN : 0);
        }
 
        for (i = GAUDI_HBM_DMA_1 ; i < GAUDI_DMA_MAX ; i++) {
-               if (!(hdev->clock_gating_mask &
-                                       (BIT_ULL(gaudi_dma_assignment[i]))))
-                       continue;
+               enable = !!(hdev->clock_gating_mask &
+                               (BIT_ULL(gaudi_dma_assignment[i])));
 
                qman_offset = gaudi_dma_assignment[i] * DMA_QMAN_OFFSET;
-               WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset, QMAN_CGM1_PWR_GATE_EN);
+               WREG32(mmDMA0_QM_CGM_CFG1 + qman_offset,
+                               enable ? QMAN_CGM1_PWR_GATE_EN : 0);
                WREG32(mmDMA0_QM_CGM_CFG + qman_offset,
-                               QMAN_COMMON_CP_CGM_PWR_GATE_EN);
+                               enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0);
        }
 
-       if (hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_0))) {
-               WREG32(mmMME0_QM_CGM_CFG1, QMAN_CGM1_PWR_GATE_EN);
-               WREG32(mmMME0_QM_CGM_CFG, QMAN_COMMON_CP_CGM_PWR_GATE_EN);
-       }
+       enable = !!(hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_0)));
+       WREG32(mmMME0_QM_CGM_CFG1, enable ? QMAN_CGM1_PWR_GATE_EN : 0);
+       WREG32(mmMME0_QM_CGM_CFG, enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0);
 
-       if (hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_2))) {
-               WREG32(mmMME2_QM_CGM_CFG1, QMAN_CGM1_PWR_GATE_EN);
-               WREG32(mmMME2_QM_CGM_CFG, QMAN_COMMON_CP_CGM_PWR_GATE_EN);
-       }
+       enable = !!(hdev->clock_gating_mask & (BIT_ULL(GAUDI_ENGINE_ID_MME_2)));
+       WREG32(mmMME2_QM_CGM_CFG1, enable ? QMAN_CGM1_PWR_GATE_EN : 0);
+       WREG32(mmMME2_QM_CGM_CFG, enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0);
 
        for (i = 0, qman_offset = 0 ; i < TPC_NUMBER_OF_ENGINES ; i++) {
-               if (!(hdev->clock_gating_mask &
-                                       (BIT_ULL(GAUDI_ENGINE_ID_TPC_0 + i))))
-                       continue;
+               enable = !!(hdev->clock_gating_mask &
+                               (BIT_ULL(GAUDI_ENGINE_ID_TPC_0 + i)));
 
                WREG32(mmTPC0_QM_CGM_CFG1 + qman_offset,
-                               QMAN_CGM1_PWR_GATE_EN);
+                               enable ? QMAN_CGM1_PWR_GATE_EN : 0);
                WREG32(mmTPC0_QM_CGM_CFG + qman_offset,
-                               QMAN_COMMON_CP_CGM_PWR_GATE_EN);
+                               enable ? QMAN_COMMON_CP_CGM_PWR_GATE_EN : 0);
 
                qman_offset += TPC_QMAN_OFFSET;
        }
@@ -2826,7 +2883,7 @@ static int gaudi_init_cpu_queues(struct hl_device *hdev, u32 cpu_timeout)
 
        if (err) {
                dev_err(hdev->dev,
-                       "Failed to communicate with ARM CPU (ArmCP timeout)\n");
+                       "Failed to communicate with Device CPU (CPU-CP timeout)\n");
                return -EIO;
        }
 
@@ -2839,6 +2896,18 @@ static void gaudi_pre_hw_init(struct hl_device *hdev)
        /* Perform read from the device to make sure device is up */
        RREG32(mmPCIE_DBI_DEVICE_ID_VENDOR_ID_REG);
 
+       /* Set the access through PCI bars (Linux driver only) as
+        * secured
+        */
+       WREG32(mmPCIE_WRAP_LBW_PROT_OVR,
+                       (PCIE_WRAP_LBW_PROT_OVR_RD_EN_MASK |
+                       PCIE_WRAP_LBW_PROT_OVR_WR_EN_MASK));
+
+       /* Perform read to flush the waiting writes to ensure
+        * configuration was set in the device
+        */
+       RREG32(mmPCIE_WRAP_LBW_PROT_OVR);
+
        /*
         * Let's mark in the H/W that we have reached this point. We check
         * this value in the reset_before_init function to understand whether
@@ -2847,31 +2916,6 @@ static void gaudi_pre_hw_init(struct hl_device *hdev)
         */
        WREG32(mmHW_STATE, HL_DEVICE_HW_STATE_DIRTY);
 
-       /* Set the access through PCI bars (Linux driver only) as secured */
-       WREG32(mmPCIE_WRAP_LBW_PROT_OVR, (PCIE_WRAP_LBW_PROT_OVR_RD_EN_MASK |
-                                       PCIE_WRAP_LBW_PROT_OVR_WR_EN_MASK));
-
-       /* Perform read to flush the waiting writes to ensure configuration
-        * was set in the device
-        */
-       RREG32(mmPCIE_WRAP_LBW_PROT_OVR);
-
-       if (hdev->axi_drain) {
-               WREG32(mmPCIE_WRAP_LBW_DRAIN_CFG,
-                       1 << PCIE_WRAP_LBW_DRAIN_CFG_EN_SHIFT);
-               WREG32(mmPCIE_WRAP_HBW_DRAIN_CFG,
-                       1 << PCIE_WRAP_HBW_DRAIN_CFG_EN_SHIFT);
-
-               /* Perform read to flush the DRAIN cfg */
-               RREG32(mmPCIE_WRAP_HBW_DRAIN_CFG);
-       } else {
-               WREG32(mmPCIE_WRAP_LBW_DRAIN_CFG, 0);
-               WREG32(mmPCIE_WRAP_HBW_DRAIN_CFG, 0);
-
-               /* Perform read to flush the DRAIN cfg */
-               RREG32(mmPCIE_WRAP_HBW_DRAIN_CFG);
-       }
-
        /* Configure the reset registers. Must be done as early as possible
         * in case we fail during H/W initialization
         */
@@ -2879,13 +2923,13 @@ static void gaudi_pre_hw_init(struct hl_device *hdev)
                                        (CFG_RST_H_DMA_MASK |
                                        CFG_RST_H_MME_MASK |
                                        CFG_RST_H_SM_MASK |
-                                       CFG_RST_H_TPC_MASK));
+                                       CFG_RST_H_TPC_7_MASK));
 
        WREG32(mmPSOC_GLOBAL_CONF_SOFT_RST_CFG_L, CFG_RST_L_TPC_MASK);
 
        WREG32(mmPSOC_GLOBAL_CONF_SW_ALL_RST_CFG_H,
                                        (CFG_RST_H_HBM_MASK |
-                                       CFG_RST_H_TPC_MASK |
+                                       CFG_RST_H_TPC_7_MASK |
                                        CFG_RST_H_NIC_MASK |
                                        CFG_RST_H_SM_MASK |
                                        CFG_RST_H_DMA_MASK |
@@ -3050,7 +3094,7 @@ static int gaudi_suspend(struct hl_device *hdev)
 {
        int rc;
 
-       rc = hl_fw_send_pci_access_msg(hdev, ARMCP_PACKET_DISABLE_PCI_ACCESS);
+       rc = hl_fw_send_pci_access_msg(hdev, CPUCP_PACKET_DISABLE_PCI_ACCESS);
        if (rc)
                dev_err(hdev->dev, "Failed to disable PCI access from CPU\n");
 
@@ -3063,17 +3107,16 @@ static int gaudi_resume(struct hl_device *hdev)
 }
 
 static int gaudi_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma,
-               u64 kaddress, phys_addr_t paddress, u32 size)
+                       void *cpu_addr, dma_addr_t dma_addr, size_t size)
 {
        int rc;
 
        vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
                        VM_DONTCOPY | VM_NORESERVE;
 
-       rc = remap_pfn_range(vma, vma->vm_start, paddress >> PAGE_SHIFT,
-                               size, vma->vm_page_prot);
+       rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, dma_addr, size);
        if (rc)
-               dev_err(hdev->dev, "remap_pfn_range error %d", rc);
+               dev_err(hdev->dev, "dma_mmap_coherent error %d", rc);
 
        return rc;
 }
@@ -3420,7 +3463,8 @@ static int gaudi_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                                        &fence_dma_addr);
        if (!fence_ptr) {
                dev_err(hdev->dev,
-                       "Failed to allocate memory for queue testing\n");
+                       "Failed to allocate memory for H/W queue %d testing\n",
+                       hw_queue_id);
                return -ENOMEM;
        }
 
@@ -3431,14 +3475,16 @@ static int gaudi_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                        GFP_KERNEL, &pkt_dma_addr);
        if (!fence_pkt) {
                dev_err(hdev->dev,
-                       "Failed to allocate packet for queue testing\n");
+                       "Failed to allocate packet for H/W queue %d testing\n",
+                       hw_queue_id);
                rc = -ENOMEM;
                goto free_fence_ptr;
        }
 
-       tmp = (PACKET_MSG_PROT << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_EB_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT);
+       tmp = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_MSG_PROT);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_EB_MASK, 1);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
+
        fence_pkt->ctl = cpu_to_le32(tmp);
        fence_pkt->value = cpu_to_le32(fence_val);
        fence_pkt->addr = cpu_to_le64(fence_dma_addr);
@@ -3448,7 +3494,8 @@ static int gaudi_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                        pkt_dma_addr);
        if (rc) {
                dev_err(hdev->dev,
-                       "Failed to send fence packet\n");
+                       "Failed to send fence packet to H/W queue %d\n",
+                       hw_queue_id);
                goto free_pkt;
        }
 
@@ -3772,6 +3819,12 @@ static int gaudi_validate_cb(struct hl_device *hdev,
                                PACKET_HEADER_PACKET_ID_MASK) >>
                                        PACKET_HEADER_PACKET_ID_SHIFT);
 
+               if (!validate_packet_id(pkt_id)) {
+                       dev_err(hdev->dev, "Invalid packet id %u\n", pkt_id);
+                       rc = -EINVAL;
+                       break;
+               }
+
                pkt_size = gaudi_packet_sizes[pkt_id];
                cb_parsed_length += pkt_size;
                if (cb_parsed_length > parser->user_cb_size) {
@@ -3932,8 +3985,6 @@ static int gaudi_patch_dma_packet(struct hl_device *hdev,
                        }
                }
 
-               new_dma_pkt->ctl = user_dma_pkt->ctl;
-
                ctl = le32_to_cpu(user_dma_pkt->ctl);
                if (likely(dma_desc_cnt))
                        ctl &= ~GAUDI_PKT_CTL_EB_MASK;
@@ -3995,6 +4046,12 @@ static int gaudi_patch_cb(struct hl_device *hdev,
                                PACKET_HEADER_PACKET_ID_MASK) >>
                                        PACKET_HEADER_PACKET_ID_SHIFT);
 
+               if (!validate_packet_id(pkt_id)) {
+                       dev_err(hdev->dev, "Invalid packet id %u\n", pkt_id);
+                       rc = -EINVAL;
+                       break;
+               }
+
                pkt_size = gaudi_packet_sizes[pkt_id];
                cb_parsed_length += pkt_size;
                if (cb_parsed_length > parser->user_cb_size) {
@@ -4072,8 +4129,9 @@ static int gaudi_parse_cb_mmu(struct hl_device *hdev,
        parser->patched_cb_size = parser->user_cb_size +
                        sizeof(struct packet_msg_prot) * 2;
 
-       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size,
-                       &patched_cb_handle, HL_KERNEL_ASID_ID, false);
+       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx,
+                               parser->patched_cb_size, false, false,
+                               &patched_cb_handle);
 
        if (rc) {
                dev_err(hdev->dev,
@@ -4145,8 +4203,9 @@ static int gaudi_parse_cb_no_mmu(struct hl_device *hdev,
        if (rc)
                goto free_userptr;
 
-       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size,
-                       &patched_cb_handle, HL_KERNEL_ASID_ID, false);
+       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx,
+                               parser->patched_cb_size, false, false,
+                               &patched_cb_handle);
        if (rc) {
                dev_err(hdev->dev,
                        "Failed to allocate patched CB for DMA CS %d\n", rc);
@@ -4242,11 +4301,11 @@ static void gaudi_add_end_of_cb_packets(struct hl_device *hdev,
        cq_pkt = (struct packet_msg_prot *) (uintptr_t)
                (kernel_address + len - (sizeof(struct packet_msg_prot) * 2));
 
-       tmp = (PACKET_MSG_PROT << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT);
+       tmp = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_MSG_PROT);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
 
        if (eb)
-               tmp |= (1 << GAUDI_PKT_CTL_EB_SHIFT);
+               tmp |= FIELD_PREP(GAUDI_PKT_CTL_EB_MASK, 1);
 
        cq_pkt->ctl = cpu_to_le32(tmp);
        cq_pkt->value = cpu_to_le32(cq_val);
@@ -4254,8 +4313,8 @@ static void gaudi_add_end_of_cb_packets(struct hl_device *hdev,
 
        cq_pkt++;
 
-       tmp = (PACKET_MSG_PROT << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT);
+       tmp = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_MSG_PROT);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
        cq_pkt->ctl = cpu_to_le32(tmp);
        cq_pkt->value = cpu_to_le32(1);
 
@@ -4287,11 +4346,12 @@ static int gaudi_memset_device_memory(struct hl_device *hdev, u64 addr,
        memset(lin_dma_pkt, 0, sizeof(*lin_dma_pkt));
        cb_size = sizeof(*lin_dma_pkt);
 
-       ctl = ((PACKET_LIN_DMA << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_LIN_DMA_CTL_MEMSET_SHIFT) |
-                       (1 << GAUDI_PKT_LIN_DMA_CTL_LIN_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_RB_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT));
+       ctl = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_LIN_DMA);
+       ctl |= FIELD_PREP(GAUDI_PKT_LIN_DMA_CTL_MEMSET_MASK, 1);
+       ctl |= FIELD_PREP(GAUDI_PKT_LIN_DMA_CTL_LIN_MASK, 1);
+       ctl |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
+       ctl |= FIELD_PREP(GAUDI_PKT_CTL_RB_MASK, 1);
+
        lin_dma_pkt->ctl = cpu_to_le32(ctl);
        lin_dma_pkt->src_addr = cpu_to_le64(val);
        lin_dma_pkt->dst_addr |= cpu_to_le64(addr);
@@ -4897,9 +4957,10 @@ static int gaudi_send_job_on_qman0(struct hl_device *hdev,
        fence_pkt = (struct packet_msg_prot *) (uintptr_t) (cb->kernel_address +
                        job->job_cb_size - sizeof(struct packet_msg_prot));
 
-       tmp = (PACKET_MSG_PROT << GAUDI_PKT_CTL_OPCODE_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_EB_SHIFT) |
-                       (1 << GAUDI_PKT_CTL_MB_SHIFT);
+       tmp = FIELD_PREP(GAUDI_PKT_CTL_OPCODE_MASK, PACKET_MSG_PROT);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_EB_MASK, 1);
+       tmp |= FIELD_PREP(GAUDI_PKT_CTL_MB_MASK, 1);
+
        fence_pkt->ctl = cpu_to_le32(tmp);
        fence_pkt->value = cpu_to_le32(GAUDI_QMAN0_FENCE_VAL);
        fence_pkt->addr = cpu_to_le64(fence_dma_addr);
@@ -5215,7 +5276,7 @@ static int gaudi_extract_ecc_info(struct hl_device *hdev,
        *memory_wrapper_idx = 0xFF;
 
        /* Iterate through memory wrappers, a single bit must be set */
-       for (i = 0 ; i > num_mem_regs ; i++) {
+       for (i = 0 ; i < num_mem_regs ; i++) {
                err_addr += i * 4;
                err_word = RREG32(err_addr);
                if (err_word) {
@@ -5573,7 +5634,7 @@ static bool gaudi_tpc_read_interrupts(struct hl_device *hdev, u8 tpc_id,
        bool soft_reset_required = false;
 
        /* Accessing the TPC_INTR_CAUSE registers requires disabling the clock
-        * gating, and thus cannot be done in ArmCP and should be done instead
+        * gating, and thus cannot be done in CPU-CP and should be done instead
         * by the driver.
         */
 
@@ -5620,21 +5681,25 @@ static void gaudi_print_clk_change_info(struct hl_device *hdev,
 {
        switch (event_type) {
        case GAUDI_EVENT_FIX_POWER_ENV_S:
+               hdev->clk_throttling_reason |= HL_CLK_THROTTLE_POWER;
                dev_info_ratelimited(hdev->dev,
                        "Clock throttling due to power consumption\n");
                break;
 
        case GAUDI_EVENT_FIX_POWER_ENV_E:
+               hdev->clk_throttling_reason &= ~HL_CLK_THROTTLE_POWER;
                dev_info_ratelimited(hdev->dev,
                        "Power envelop is safe, back to optimal clock\n");
                break;
 
        case GAUDI_EVENT_FIX_THERMAL_ENV_S:
+               hdev->clk_throttling_reason |= HL_CLK_THROTTLE_THERMAL;
                dev_info_ratelimited(hdev->dev,
                        "Clock throttling due to overheating\n");
                break;
 
        case GAUDI_EVENT_FIX_THERMAL_ENV_E:
+               hdev->clk_throttling_reason &= ~HL_CLK_THROTTLE_THERMAL;
                dev_info_ratelimited(hdev->dev,
                        "Thermal envelop is safe, back to optimal clock\n");
                break;
@@ -6005,7 +6070,7 @@ static int gaudi_send_heartbeat(struct hl_device *hdev)
        return hl_fw_send_heartbeat(hdev);
 }
 
-static int gaudi_armcp_info_get(struct hl_device *hdev)
+static int gaudi_cpucp_info_get(struct hl_device *hdev)
 {
        struct gaudi_device *gaudi = hdev->asic_specific;
        struct asic_fixed_properties *prop = &hdev->asic_prop;
@@ -6014,18 +6079,27 @@ static int gaudi_armcp_info_get(struct hl_device *hdev)
        if (!(gaudi->hw_cap_initialized & HW_CAP_CPU_Q))
                return 0;
 
-       rc = hl_fw_armcp_info_get(hdev);
+       rc = hl_fw_cpucp_info_get(hdev);
        if (rc)
                return rc;
 
-       if (!strlen(prop->armcp_info.card_name))
-               strncpy(prop->armcp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
+       if (!strlen(prop->cpucp_info.card_name))
+               strncpy(prop->cpucp_info.card_name, GAUDI_DEFAULT_CARD_NAME,
                                CARD_NAME_MAX_LEN);
 
+       hdev->card_type = le32_to_cpu(hdev->asic_prop.cpucp_info.card_type);
+
+       if (hdev->card_type == cpucp_card_type_pci)
+               prop->max_power_default = MAX_POWER_DEFAULT_PCI;
+       else if (hdev->card_type == cpucp_card_type_pmc)
+               prop->max_power_default = MAX_POWER_DEFAULT_PMC;
+
+       hdev->max_power = prop->max_power_default;
+
        return 0;
 }
 
-static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask,
+static bool gaudi_is_device_idle(struct hl_device *hdev, u64 *mask,
                                        struct seq_file *s)
 {
        struct gaudi_device *gaudi = hdev->asic_specific;
@@ -6057,7 +6131,7 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask,
                is_idle &= is_eng_idle;
 
                if (mask)
-                       *mask |= !is_eng_idle <<
+                       *mask |= ((u64) !is_eng_idle) <<
                                        (GAUDI_ENGINE_ID_DMA_0 + dma_id);
                if (s)
                        seq_printf(s, fmt, dma_id,
@@ -6080,7 +6154,8 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask,
                is_idle &= is_eng_idle;
 
                if (mask)
-                       *mask |= !is_eng_idle << (GAUDI_ENGINE_ID_TPC_0 + i);
+                       *mask |= ((u64) !is_eng_idle) <<
+                                               (GAUDI_ENGINE_ID_TPC_0 + i);
                if (s)
                        seq_printf(s, fmt, i,
                                is_eng_idle ? "Y" : "N",
@@ -6108,7 +6183,8 @@ static bool gaudi_is_device_idle(struct hl_device *hdev, u32 *mask,
                is_idle &= is_eng_idle;
 
                if (mask)
-                       *mask |= !is_eng_idle << (GAUDI_ENGINE_ID_MME_0 + i);
+                       *mask |= ((u64) !is_eng_idle) <<
+                                               (GAUDI_ENGINE_ID_MME_0 + i);
                if (s) {
                        if (!is_slave)
                                seq_printf(s, fmt, i,
@@ -6246,6 +6322,15 @@ static int gaudi_run_tpc_kernel(struct hl_device *hdev, u64 tpc_kernel,
                1000,
                kernel_timeout);
 
+       if (rc) {
+               dev_err(hdev->dev,
+                       "Timeout while waiting for TPC%d vector pipe\n",
+                       tpc_id);
+               hdev->asic_funcs->set_clock_gating(hdev);
+               mutex_unlock(&gaudi->clk_gate_mutex);
+               return -EIO;
+       }
+
        rc = hl_poll_timeout(
                hdev,
                mmTPC0_CFG_WQ_INFLIGHT_CNTR + offset,
@@ -6575,7 +6660,6 @@ static const struct hl_asic_funcs gaudi_funcs = {
        .send_cpu_message = gaudi_send_cpu_message,
        .get_hw_state = gaudi_get_hw_state,
        .pci_bars_map = gaudi_pci_bars_map,
-       .set_dram_bar_base = gaudi_set_hbm_bar_base,
        .init_iatu = gaudi_init_iatu,
        .rreg = hl_rreg,
        .wreg = hl_wreg,
index 5dc99f6..83ad2b0 100644 (file)
 #error "Number of MSI interrupts must be smaller or equal to GAUDI_MSI_ENTRIES"
 #endif
 
-#define QMAN_FENCE_TIMEOUT_USEC                10000           /* 10 ms */
-
 #define CORESIGHT_TIMEOUT_USEC         100000          /* 100 ms */
 
 #define GAUDI_MAX_CLK_FREQ             2200000000ull   /* 2200 MHz */
 
-#define MAX_POWER_DEFAULT              200000          /* 200W */
+#define MAX_POWER_DEFAULT_PCI          200000          /* 200W */
+#define MAX_POWER_DEFAULT_PMC          350000          /* 350W */
 
-#define GAUDI_CPU_TIMEOUT_USEC         15000000        /* 15s */
+#define GAUDI_CPU_TIMEOUT_USEC         30000000        /* 30s */
 
 #define TPC_ENABLED_MASK               0xFF
 
 
 #define DMA_CORE_OFFSET                (mmDMA1_CORE_BASE - mmDMA0_CORE_BASE)
 
+#define QMAN_LDMA_SRC_OFFSET   (mmDMA0_CORE_SRC_BASE_LO - mmDMA0_CORE_CFG_0)
+#define QMAN_LDMA_DST_OFFSET   (mmDMA0_CORE_DST_BASE_LO - mmDMA0_CORE_CFG_0)
+#define QMAN_LDMA_SIZE_OFFSET  (mmDMA0_CORE_DST_TSIZE_0 - mmDMA0_CORE_CFG_0)
+
+#define QMAN_CPDMA_SRC_OFFSET  (mmDMA0_QM_CQ_PTR_LO_4 - mmDMA0_CORE_CFG_0)
+#define QMAN_CPDMA_DST_OFFSET  (mmDMA0_CORE_DST_BASE_LO - mmDMA0_CORE_CFG_0)
+#define QMAN_CPDMA_SIZE_OFFSET (mmDMA0_QM_CQ_TSIZE_4 - mmDMA0_CORE_CFG_0)
+
 #define SIF_RTR_CTRL_OFFSET    (mmSIF_RTR_CTRL_1_BASE - mmSIF_RTR_CTRL_0_BASE)
 
 #define NIF_RTR_CTRL_OFFSET    (mmNIF_RTR_CTRL_1_BASE - mmNIF_RTR_CTRL_0_BASE)
 #define VA_HOST_SPACE_SIZE     (VA_HOST_SPACE_END - \
                                        VA_HOST_SPACE_START) /* 767TB */
 
-#define HW_CAP_PLL             0x00000001
-#define HW_CAP_HBM             0x00000002
-#define HW_CAP_MMU             0x00000004
-#define HW_CAP_MME             0x00000008
-#define HW_CAP_CPU             0x00000010
-#define HW_CAP_PCI_DMA         0x00000020
-#define HW_CAP_MSI             0x00000040
-#define HW_CAP_CPU_Q           0x00000080
-#define HW_CAP_HBM_DMA         0x00000100
-#define HW_CAP_CLK_GATE                0x00000200
-#define HW_CAP_SRAM_SCRAMBLER  0x00000400
-#define HW_CAP_HBM_SCRAMBLER   0x00000800
-
-#define HW_CAP_TPC0            0x01000000
-#define HW_CAP_TPC1            0x02000000
-#define HW_CAP_TPC2            0x04000000
-#define HW_CAP_TPC3            0x08000000
-#define HW_CAP_TPC4            0x10000000
-#define HW_CAP_TPC5            0x20000000
-#define HW_CAP_TPC6            0x40000000
-#define HW_CAP_TPC7            0x80000000
-#define HW_CAP_TPC_MASK                0xFF000000
+#define HW_CAP_PLL             BIT(0)
+#define HW_CAP_HBM             BIT(1)
+#define HW_CAP_MMU             BIT(2)
+#define HW_CAP_MME             BIT(3)
+#define HW_CAP_CPU             BIT(4)
+#define HW_CAP_PCI_DMA         BIT(5)
+#define HW_CAP_MSI             BIT(6)
+#define HW_CAP_CPU_Q           BIT(7)
+#define HW_CAP_HBM_DMA         BIT(8)
+#define HW_CAP_CLK_GATE                BIT(9)
+#define HW_CAP_SRAM_SCRAMBLER  BIT(10)
+#define HW_CAP_HBM_SCRAMBLER   BIT(11)
+
+#define HW_CAP_TPC0            BIT(24)
+#define HW_CAP_TPC1            BIT(25)
+#define HW_CAP_TPC2            BIT(26)
+#define HW_CAP_TPC3            BIT(27)
+#define HW_CAP_TPC4            BIT(28)
+#define HW_CAP_TPC5            BIT(29)
+#define HW_CAP_TPC6            BIT(30)
+#define HW_CAP_TPC7            BIT(31)
+#define HW_CAP_TPC_MASK                GENMASK(31, 24)
 #define HW_CAP_TPC_SHIFT       24
 
 #define GAUDI_CPU_PCI_MSB_ADDR(addr)   (((addr) & GENMASK_ULL(49, 39)) >> 39)
@@ -215,7 +222,7 @@ struct gaudi_internal_qman_info {
 
 /**
  * struct gaudi_device - ASIC specific manage structure.
- * @armcp_info_get: get information on device from ArmCP
+ * @cpucp_info_get: get information on device from CPU-CP
  * @hw_queues_lock: protects the H/W queues from concurrent access.
  * @clk_gate_mutex: protects code areas that require clock gating to be disabled
  *                  temporarily
@@ -238,7 +245,7 @@ struct gaudi_internal_qman_info {
  *                    8-bit value so use u8.
  */
 struct gaudi_device {
-       int (*armcp_info_get)(struct hl_device *hdev);
+       int (*cpucp_info_get)(struct hl_device *hdev);
 
        /* TODO: remove hw_queues_lock after moving to scheduler code */
        spinlock_t                      hw_queues_lock;
index 5673ee4..881531d 100644 (file)
@@ -527,7 +527,7 @@ static int gaudi_config_etf(struct hl_device *hdev,
 }
 
 static bool gaudi_etr_validate_address(struct hl_device *hdev, u64 addr,
-                                       u32 size, bool *is_host)
+                                       u64 size, bool *is_host)
 {
        struct asic_fixed_properties *prop = &hdev->asic_prop;
        struct gaudi_device *gaudi = hdev->asic_specific;
@@ -539,6 +539,12 @@ static bool gaudi_etr_validate_address(struct hl_device *hdev, u64 addr,
                return false;
        }
 
+       if (addr > (addr + size)) {
+               dev_err(hdev->dev,
+                       "ETR buffer size %llu overflow\n", size);
+               return false;
+       }
+
        /* PMMU and HPMMU addresses are equal, check only one of them */
        if ((gaudi->hw_cap_initialized & HW_CAP_MMU) &&
                hl_mem_area_inside_range(addr, size,
index 8d5d6dd..2d7add0 100644 (file)
@@ -487,241 +487,241 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmMME0_CTRL_RESET & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_CTRL_RESET & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_CTRL_RESET & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_QM_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_LOG_SHADOW & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_MIN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_CTRL_RESET & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_QM_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_LOG_SHADOW & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_MIN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_CTRL_SHADOW_0_STATUS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_CTRL_SHADOW_0_STATUS & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME0_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -729,236 +729,235 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev)
                        PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 &
                        PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & ~0xFFF) +
                        PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_ARB_MST_CHOISE_PUSH_OFST_23 &
                        PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmMME0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmMME0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME0_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME0_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmMME0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME1_CTRL_RESET & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME1_CTRL_RESET & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME1_CTRL_RESET & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_QM_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_LOG_SHADOW & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_MIN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME1_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
+       mask = 1U << ((mmMME1_CTRL_RESET & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_QM_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_LOG_SHADOW & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_MIN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
+       mask |= 1U << ((mmMME1_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME1_CTRL_SHADOW_0_STATUS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME1_CTRL_SHADOW_0_STATUS & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME1_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
+       mask = 1U << ((mmMME1_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -966,241 +965,241 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmMME2_CTRL_RESET & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_CTRL_RESET & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_CTRL_RESET & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_QM_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_LOG_SHADOW & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_MIN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_CTRL_RESET & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_QM_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_LOG_SHADOW & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_MIN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_CTRL_SHADOW_0_STATUS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_CTRL_SHADOW_0_STATUS & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME2_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -1208,102 +1207,102 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev)
                        PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                        >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -1311,134 +1310,133 @@ static void gaudi_init_mme_protection_bits(struct hl_device *hdev)
                        PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_ARB_MST_CHOISE_PUSH_OFST_23 &
                        PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmMME2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmMME2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME2_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME2_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmMME2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME3_CTRL_RESET & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME3_CTRL_RESET & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmMME3_CTRL_RESET & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_QM_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_LOG_SHADOW & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_TH & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_MIN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
-       mask |= 1 << ((mmMME3_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
+       mask = 1U << ((mmMME3_CTRL_RESET & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_QM_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_SYNC_OBJECT_FIFO_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_EUS_ROLLUP_CNT_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_LOG_SHADOW & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_DESC0 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_TOKEN_UPDATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_TH & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_MIN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_CTRL_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_HISTORY_LOG_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_A_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_B_BF16 & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_A_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_A_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_B_FP32_ODD & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_DUMMY_B_FP32_EVEN & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_EU_POWER_SAVE_DISABLE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_CS_DBG_BLOCK_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_CS_DBG_STATUS_DROP_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_TE_CLOSE_CGATE & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_AGU_SM_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_AGU_SM_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_EZSYNC_OUT_CREDIT & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_PCU_RL_SAT_SEC & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_AGU_SYNC_MSG_AXI_USER & 0x7F) >> 2);
+       mask |= 1U << ((mmMME3_CTRL_QM_SLV_LBW_CLK_EN & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmMME3_CTRL_SHADOW_0_STATUS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmMME3_CTRL_SHADOW_0_STATUS & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmMME3_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
+       mask = 1U << ((mmMME3_CTRL_SHADOW_0_STATUS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -1486,199 +1484,199 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmDMA0_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -1687,102 +1685,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & ~0xFFF) +
@@ -1790,290 +1788,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2082,102 +2079,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2186,290 +2183,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA1_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA1_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA1_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2478,102 +2474,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2582,290 +2578,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA2_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2874,102 +2869,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -2978,290 +2973,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA3_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA3_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA3_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -3270,102 +3264,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -3374,290 +3368,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA4_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA4_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA4_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -3666,102 +3659,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -3770,290 +3763,289 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA5_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA5_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA5_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -4062,102 +4054,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -4166,290 +4158,290 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA6_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA6_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+
+       mask = 1U << ((mmDMA6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA6_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -4458,102 +4450,102 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -4562,606 +4554,605 @@ static void gaudi_init_dma_protection_bits(struct hl_device *hdev)
        word_offset =
                ((mmDMA7_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS) >> 7)
                << 2;
-       mask = 1 << ((mmDMA7_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA7_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA0_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA0_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA0_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA0_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA0_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA0_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA0_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA1_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA1_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA1_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA1_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA1_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA1_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA1_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA2_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA2_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA2_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA2_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA2_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA2_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA2_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA3_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA3_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA3_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA3_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA3_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA3_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA3_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA4_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA4_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA4_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA4_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA4_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA4_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA4_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA5_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA5_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA5_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA5_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA5_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA5_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA5_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA6_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA6_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA6_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA6_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA6_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA6_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA6_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_CORE_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_CORE_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_CORE_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_CORE_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_LBW_MAX_OUTSTAND & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_CORE_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_CORE_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_CORE_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_SECURE_PROPS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_CORE_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_SECURE_PROPS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_NON_SECURE_PROPS & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_CORE_RD_MAX_OUTSTAND & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_CORE_RD_MAX_OUTSTAND & PROT_BITS_OFFS) >> 7)
                        << 2;
-       mask = 1 << ((mmDMA7_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_ARCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_MAX_AWID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_AWCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_INFLIGHTS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_ERRMSG_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_CORE_RD_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_ARCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_ARUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_MAX_OUTSTAND & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_MAX_AWID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_AWCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_INFLIGHTS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_ERRMSG_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_ERRMSG_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_ERRMSG_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_CORE_STS0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_CORE_STS0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_CORE_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_STS1 & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_CORE_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_STS1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmDMA7_CORE_RD_DBGMEM_ADD & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmDMA7_CORE_RD_DBGMEM_ADD & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmDMA7_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_DESC_CNT & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
-       mask |= 1 << ((mmDMA7_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
+       mask = 1U << ((mmDMA7_CORE_RD_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_RD_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_HBW_AXI_AR_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_HBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_LBW_AXI_AW_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_DESC_CNT & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_RD_DESC_ID & 0x7F) >> 2);
+       mask |= 1U << ((mmDMA7_CORE_DBG_WR_DESC_ID & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 }
@@ -5185,199 +5176,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC0_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -5387,102 +5378,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
        word_offset = ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
 
-       mask = 1 << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -5491,150 +5482,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        word_offset = ((mmTPC0_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC0_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC0_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC0_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC0_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC0_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC0_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC0_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -5643,199 +5633,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC1_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -5843,102 +5833,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -5947,150 +5937,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        word_offset = ((mmTPC1_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC1_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC1_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC1_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC1_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC1_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC1_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC1_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC1_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6099,199 +6088,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC2_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6299,102 +6288,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6402,150 +6391,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC2_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC2_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC2_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                << 2;
-       mask = 1 << ((mmTPC2_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC2_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC2_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC2_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6554,199 +6542,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC3_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6754,102 +6742,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -6857,150 +6845,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC3_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC3_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC3_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC3_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC3_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC3_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC3_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC3_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7009,199 +6996,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC4_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7209,102 +7196,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7312,150 +7299,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC4_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC4_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC4_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC4_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC4_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC4_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC4_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC4_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7464,199 +7450,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC5_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7664,102 +7650,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7767,150 +7753,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC5_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC5_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC5_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC5_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC5_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC5_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC5_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC5_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -7919,199 +7904,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC6_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8119,102 +8104,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                                                                PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8223,85 +8208,84 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        word_offset = ((mmTPC6_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8309,65 +8293,65 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
        word_offset = ((mmTPC6_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
 
-       mask = 1 << ((mmTPC6_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC6_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC6_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC6_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC6_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC6_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC6_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC6_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8376,199 +8360,199 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
 
        pb_addr = (mmTPC7_QM_GLBL_CFG0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_GLBL_CFG0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_GLBL_CFG0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_CFG1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_ERR_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_STS1_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_GLBL_CFG0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_CFG1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_ERR_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_NON_SECURE_PROPS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_STS1_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_MSG_EN_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_MSG_EN_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_MSG_EN_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_MSG_EN_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_MSG_EN_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_LO_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_PQ_BASE_HI_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_PQ_BASE_HI_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_SIZE_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_SIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_SIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_SIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_PI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_PI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_PI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_PI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_CFG1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS0_3 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_PQ_BASE_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_BASE_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_SIZE_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_SIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_SIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_SIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_PI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_PI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_PI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_PI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_CFG1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS0_3 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_PQ_STS1_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_PQ_STS1_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_PQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_PQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS0_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS1_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS1_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS1_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_STS1_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_0 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_PQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_PQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS0_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS1_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS1_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS1_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_STS1_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_0 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CQ_CTL_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CQ_CTL_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_CQ_CTL_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CQ_CTL_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_LO_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_PTR_HI_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_TSIZE_STS_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CQ_CTL_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CQ_CTL_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CQ_CTL_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_CTL_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_IFIFO_CNT_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_IFIFO_CNT_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_IFIFO_CNT_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_IFIFO_CNT_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CQ_IFIFO_CNT_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE0_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE1_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_2 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE2_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_MSG_BASE3_ADDR_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_TSIZE_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_SRC_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8578,102 +8562,102 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
        word_offset = ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
 
-       mask = 1 << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_LDMA_DST_BASE_LO_OFFSET_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CP_STS_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CP_STS_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_CP_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CP_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_LO_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_LO_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_LO_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_LO_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_LO_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_HI_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_HI_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_HI_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_HI_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_CURRENT_INST_HI_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_BARRIER_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_BARRIER_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_BARRIER_CFG_2 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CP_BARRIER_CFG_3 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CP_BARRIER_CFG_3 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_DBG_0_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_DBG_0_1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CP_BARRIER_CFG_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_BARRIER_CFG_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_DBG_0_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_DBG_0_1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_CP_DBG_0_2 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_CP_DBG_0_2 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_CP_DBG_0_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_DBG_0_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_DBG_0_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_CP_DBG_0_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_DBG_0_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_DBG_0_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_ARUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_ARUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_ARUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_ARUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_ARUSER_31_11_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_AWUSER_31_11_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_AWUSER_31_11_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_AWUSER_31_11_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_AWUSER_31_11_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CP_AWUSER_31_11_4 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_ARB_CFG_0 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_ARB_CFG_0 & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_ARB_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_ARB_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_19 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_23 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_ARB_MST_AVAIL_CRED_24 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_ARB_MST_AVAIL_CRED_24 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_AVAIL_CRED_31 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
@@ -8681,150 +8665,149 @@ static void gaudi_init_tpc_protection_bits(struct hl_device *hdev)
                        PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_ARB_MST_CHOISE_PUSH_OFST_23 & PROT_BITS_OFFS)
                                                                >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_ARB_MST_QUIET_PER & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_ARB_SLV_CHOISE_WDT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MSG_MAX_INFLIGHT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MSG_AWUSER_31_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MSG_AWUSER_SEC_PROP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MSG_AWUSER_NON_SEC_PROP & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_ARB_STATE_STS & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_ARB_STATE_STS & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_ARB_STATE_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MSG_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_ARB_STATE_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_CHOISE_FULLNESS_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MSG_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_SLV_CHOISE_Q_HEAD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_ERR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_ERR_MSG_EN & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_ERR_STS_DRP & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_9 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_10 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_11 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_12 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_13 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_14 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_15 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_16 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_17 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_18 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_19 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_ARB_MST_CRED_STS_20 & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_ARB_MST_CRED_STS_20 & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CGM_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CGM_STS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CGM_CFG1 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_20 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_21 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_22 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_23 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_24 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_25 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_26 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_27 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_28 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_29 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_30 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_ARB_MST_CRED_STS_31 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CGM_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CGM_STS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CGM_CFG1 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_LOCAL_RANGE_BASE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_LOCAL_RANGE_BASE & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_AXCACHE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_IND_GW_APB_CFG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_LOCAL_RANGE_BASE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_LOCAL_RANGE_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_CSMR_STRICT_PRIO_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_HBW_RD_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_LBW_WR_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_LBW_WR_RATE_LIM_CFG_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_HBW_RD_RATE_LIM_CFG_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_AXCACHE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_IND_GW_APB_CFG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_IND_GW_APB_WDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_IND_GW_APB_RDATA & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_IND_GW_APB_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_ERR_ADDR_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_ERR_ADDR_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_QM_GLBL_ERR_WDATA & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_QM_GLBL_MEM_INIT_BUSY & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_QM_GLBL_MEM_INIT_BUSY & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC7_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_QM_GLBL_MEM_INIT_BUSY & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_CFG_ROUND_CSR & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_CFG_ROUND_CSR & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_CFG_ROUND_CSR & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_CFG_ROUND_CSR & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_CFG_PROT & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_CFG_PROT & PROT_BITS_OFFS) >> 7) << 2;
-       mask = 1 << ((mmTPC7_CFG_PROT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_VFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_SFLAGS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_STATUS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_TPC_STALL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_MSS_CONFIG & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_TPC_INTR_MASK & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_WQ_CREDITS & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_ARUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_ARUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_AWUSER_LO & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_AWUSER_HI & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_OPCODE_EXEC & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_CFG_PROT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_VFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_SFLAGS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_STATUS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_CFG_BASE_ADDRESS_HIGH & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_CFG_SUBTRACT_VALUE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_TPC_STALL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_RD_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_WR_RATE_LIMIT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_MSS_CONFIG & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_TPC_INTR_CAUSE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_TPC_INTR_MASK & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_WQ_CREDITS & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_ARUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_ARUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_AWUSER_LO & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_AWUSER_HI & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_OPCODE_EXEC & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 
        pb_addr = (mmTPC7_CFG_TSB_CFG_MAX_SIZE & ~0xFFF) + PROT_BITS_OFFS;
        word_offset = ((mmTPC7_CFG_TSB_CFG_MAX_SIZE & PROT_BITS_OFFS) >> 7)
                                                                        << 2;
-       mask = 1 << ((mmTPC7_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_DBGMEM_ADD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_DBGMEM_CTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_DBGMEM_RC & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
-       mask |= 1 << ((mmTPC7_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
+       mask = 1U << ((mmTPC7_CFG_TSB_CFG_MAX_SIZE & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_DBGMEM_ADD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_DBGMEM_DATA_WR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_DBGMEM_DATA_RD & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_DBGMEM_CTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_DBGMEM_RC & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_TSB_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_WQ_INFLIGHT_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_WQ_LBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_WQ_HBW_TOTAL_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_IRQ_OCCOUPY_CNTR & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_CNTRL & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_PAT & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_0 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_1 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_2 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_3 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_4 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_5 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_6 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_7 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_8 & 0x7F) >> 2);
+       mask |= 1U << ((mmTPC7_CFG_FUNC_MBIST_MEM_9 & 0x7F) >> 2);
 
        WREG32(pb_addr + word_offset, ~mask);
 }
index 8503075..5db5206 100644 (file)
@@ -139,6 +139,25 @@ static u16 goya_packet_sizes[MAX_PACKET_ID] = {
        [PACKET_STOP]           = sizeof(struct packet_stop)
 };
 
+static inline bool validate_packet_id(enum packet_id id)
+{
+       switch (id) {
+       case PACKET_WREG_32:
+       case PACKET_WREG_BULK:
+       case PACKET_MSG_LONG:
+       case PACKET_MSG_SHORT:
+       case PACKET_CP_DMA:
+       case PACKET_MSG_PROT:
+       case PACKET_FENCE:
+       case PACKET_LIN_DMA:
+       case PACKET_NOP:
+       case PACKET_STOP:
+               return true;
+       default:
+               return false;
+       }
+}
+
 static u64 goya_mmu_regs[GOYA_MMU_REGS_NUM] = {
        mmDMA_QM_0_GLBL_NON_SECURE_PROPS,
        mmDMA_QM_1_GLBL_NON_SECURE_PROPS,
@@ -407,12 +426,14 @@ int goya_get_fixed_properties(struct hl_device *hdev)
        prop->dmmu.start_addr = VA_DDR_SPACE_START;
        prop->dmmu.end_addr = VA_DDR_SPACE_END;
        prop->dmmu.page_size = PAGE_SIZE_2MB;
+       prop->dmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* shifts and masks are the same in PMMU and DMMU */
        memcpy(&prop->pmmu, &prop->dmmu, sizeof(prop->dmmu));
        prop->pmmu.start_addr = VA_HOST_SPACE_START;
        prop->pmmu.end_addr = VA_HOST_SPACE_END;
        prop->pmmu.page_size = PAGE_SIZE_4KB;
+       prop->pmmu.num_hops = MMU_ARCH_5_HOPS;
 
        /* PMMU and HPMMU are the same except of page size */
        memcpy(&prop->pmmu_huge, &prop->pmmu, sizeof(prop->pmmu));
@@ -430,7 +451,7 @@ int goya_get_fixed_properties(struct hl_device *hdev)
        prop->pcie_dbi_base_address = mmPCIE_DBI_BASE;
        prop->pcie_aux_dbi_reg_addr = CFG_BASE + mmPCIE_AUX_DBI;
 
-       strncpy(prop->armcp_info.card_name, GOYA_DEFAULT_CARD_NAME,
+       strncpy(prop->cpucp_info.card_name, GOYA_DEFAULT_CARD_NAME,
                CARD_NAME_MAX_LEN);
 
        prop->max_pending_cs = GOYA_MAX_PENDING_CS;
@@ -579,10 +600,15 @@ static int goya_early_init(struct hl_device *hdev)
 
        prop->dram_pci_bar_size = pci_resource_len(pdev, DDR_BAR_ID);
 
-       rc = hl_pci_init(hdev);
+       rc = hl_pci_init(hdev, mmPSOC_GLOBAL_CONF_CPU_BOOT_STATUS,
+                       mmCPU_BOOT_ERR0, GOYA_BOOT_FIT_REQ_TIMEOUT_USEC);
        if (rc)
                goto free_queue_props;
 
+       /* Goya Firmware does not support security */
+       prop->fw_security_disabled = true;
+       dev_info(hdev->dev, "firmware-level security is disabled\n");
+
        if (!hdev->pldm) {
                val = RREG32(mmPSOC_GLOBAL_CONF_BOOT_STRAP_PINS);
                if (val & PSOC_GLOBAL_CONF_BOOT_STRAP_PINS_SRIOV_EN_MASK)
@@ -708,9 +734,9 @@ int goya_late_init(struct hl_device *hdev)
        if (rc)
                return rc;
 
-       rc = goya_armcp_info_get(hdev);
+       rc = goya_cpucp_info_get(hdev);
        if (rc) {
-               dev_err(hdev->dev, "Failed to get armcp info %d\n", rc);
+               dev_err(hdev->dev, "Failed to get cpucp info %d\n", rc);
                return rc;
        }
 
@@ -720,7 +746,7 @@ int goya_late_init(struct hl_device *hdev)
         */
        WREG32(mmMMU_LOG2_DDR_SIZE, ilog2(prop->dram_size));
 
-       rc = hl_fw_send_pci_access_msg(hdev, ARMCP_PACKET_ENABLE_PCI_ACCESS);
+       rc = hl_fw_send_pci_access_msg(hdev, CPUCP_PACKET_ENABLE_PCI_ACCESS);
        if (rc) {
                dev_err(hdev->dev,
                        "Failed to enable PCI access from CPU %d\n", rc);
@@ -2629,7 +2655,7 @@ int goya_suspend(struct hl_device *hdev)
 {
        int rc;
 
-       rc = hl_fw_send_pci_access_msg(hdev, ARMCP_PACKET_DISABLE_PCI_ACCESS);
+       rc = hl_fw_send_pci_access_msg(hdev, CPUCP_PACKET_DISABLE_PCI_ACCESS);
        if (rc)
                dev_err(hdev->dev, "Failed to disable PCI access from CPU\n");
 
@@ -2642,17 +2668,16 @@ int goya_resume(struct hl_device *hdev)
 }
 
 static int goya_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma,
-               u64 kaddress, phys_addr_t paddress, u32 size)
+                       void *cpu_addr, dma_addr_t dma_addr, size_t size)
 {
        int rc;
 
        vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP |
                        VM_DONTCOPY | VM_NORESERVE;
 
-       rc = remap_pfn_range(vma, vma->vm_start, paddress >> PAGE_SHIFT,
-                               size, vma->vm_page_prot);
+       rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, dma_addr, size);
        if (rc)
-               dev_err(hdev->dev, "remap_pfn_range error %d", rc);
+               dev_err(hdev->dev, "dma_mmap_coherent error %d", rc);
 
        return rc;
 }
@@ -2927,7 +2952,8 @@ int goya_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                                        &fence_dma_addr);
        if (!fence_ptr) {
                dev_err(hdev->dev,
-                       "Failed to allocate memory for queue testing\n");
+                       "Failed to allocate memory for H/W queue %d testing\n",
+                       hw_queue_id);
                return -ENOMEM;
        }
 
@@ -2938,7 +2964,8 @@ int goya_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                        GFP_KERNEL, &pkt_dma_addr);
        if (!fence_pkt) {
                dev_err(hdev->dev,
-                       "Failed to allocate packet for queue testing\n");
+                       "Failed to allocate packet for H/W queue %d testing\n",
+                       hw_queue_id);
                rc = -ENOMEM;
                goto free_fence_ptr;
        }
@@ -2955,7 +2982,8 @@ int goya_test_queue(struct hl_device *hdev, u32 hw_queue_id)
                                        pkt_dma_addr);
        if (rc) {
                dev_err(hdev->dev,
-                       "Failed to send fence packet\n");
+                       "Failed to send fence packet to H/W queue %d\n",
+                       hw_queue_id);
                goto free_pkt;
        }
 
@@ -3455,6 +3483,12 @@ static int goya_validate_cb(struct hl_device *hdev,
                                PACKET_HEADER_PACKET_ID_MASK) >>
                                        PACKET_HEADER_PACKET_ID_SHIFT);
 
+               if (!validate_packet_id(pkt_id)) {
+                       dev_err(hdev->dev, "Invalid packet id %u\n", pkt_id);
+                       rc = -EINVAL;
+                       break;
+               }
+
                pkt_size = goya_packet_sizes[pkt_id];
                cb_parsed_length += pkt_size;
                if (cb_parsed_length > parser->user_cb_size) {
@@ -3690,6 +3724,12 @@ static int goya_patch_cb(struct hl_device *hdev,
                                PACKET_HEADER_PACKET_ID_MASK) >>
                                        PACKET_HEADER_PACKET_ID_SHIFT);
 
+               if (!validate_packet_id(pkt_id)) {
+                       dev_err(hdev->dev, "Invalid packet id %u\n", pkt_id);
+                       rc = -EINVAL;
+                       break;
+               }
+
                pkt_size = goya_packet_sizes[pkt_id];
                cb_parsed_length += pkt_size;
                if (cb_parsed_length > parser->user_cb_size) {
@@ -3775,8 +3815,9 @@ static int goya_parse_cb_mmu(struct hl_device *hdev,
        parser->patched_cb_size = parser->user_cb_size +
                        sizeof(struct packet_msg_prot) * 2;
 
-       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size,
-                       &patched_cb_handle, HL_KERNEL_ASID_ID, false);
+       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx,
+                               parser->patched_cb_size, false, false,
+                               &patched_cb_handle);
 
        if (rc) {
                dev_err(hdev->dev,
@@ -3848,8 +3889,9 @@ static int goya_parse_cb_no_mmu(struct hl_device *hdev,
        if (rc)
                goto free_userptr;
 
-       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, parser->patched_cb_size,
-                       &patched_cb_handle, HL_KERNEL_ASID_ID, false);
+       rc = hl_cb_create(hdev, &hdev->kernel_cb_mgr, hdev->kernel_ctx,
+                               parser->patched_cb_size, false, false,
+                               &patched_cb_handle);
        if (rc) {
                dev_err(hdev->dev,
                        "Failed to allocate patched CB for DMA CS %d\n", rc);
@@ -4466,17 +4508,17 @@ static void goya_print_irq_info(struct hl_device *hdev, u16 event_type,
 static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr,
                size_t irq_arr_size)
 {
-       struct armcp_unmask_irq_arr_packet *pkt;
+       struct cpucp_unmask_irq_arr_packet *pkt;
        size_t total_pkt_size;
        long result;
        int rc;
        int irq_num_entries, irq_arr_index;
        __le32 *goya_irq_arr;
 
-       total_pkt_size = sizeof(struct armcp_unmask_irq_arr_packet) +
+       total_pkt_size = sizeof(struct cpucp_unmask_irq_arr_packet) +
                        irq_arr_size;
 
-       /* data should be aligned to 8 bytes in order to ArmCP to copy it */
+       /* data should be aligned to 8 bytes in order to CPU-CP to copy it */
        total_pkt_size = (total_pkt_size + 0x7) & ~0x7;
 
        /* total_pkt_size is casted to u16 later on */
@@ -4500,8 +4542,8 @@ static int goya_unmask_irq_arr(struct hl_device *hdev, u32 *irq_arr,
                goya_irq_arr[irq_arr_index] =
                                cpu_to_le32(irq_arr[irq_arr_index]);
 
-       pkt->armcp_pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY <<
-                                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt->cpucp_pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY <<
+                                               CPUCP_PKT_CTL_OPCODE_SHIFT);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) pkt,
                                                total_pkt_size, 0, &result);
@@ -4526,14 +4568,14 @@ static int goya_soft_reset_late_init(struct hl_device *hdev)
 
 static int goya_unmask_irq(struct hl_device *hdev, u16 event_type)
 {
-       struct armcp_packet pkt;
+       struct cpucp_packet pkt;
        long result;
        int rc;
 
        memset(&pkt, 0, sizeof(pkt));
 
-       pkt.ctl = cpu_to_le32(ARMCP_PACKET_UNMASK_RAZWI_IRQ <<
-                               ARMCP_PKT_CTL_OPCODE_SHIFT);
+       pkt.ctl = cpu_to_le32(CPUCP_PACKET_UNMASK_RAZWI_IRQ <<
+                               CPUCP_PKT_CTL_OPCODE_SHIFT);
        pkt.value = cpu_to_le64(event_type);
 
        rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
@@ -4549,18 +4591,22 @@ static void goya_print_clk_change_info(struct hl_device *hdev, u16 event_type)
 {
        switch (event_type) {
        case GOYA_ASYNC_EVENT_ID_FIX_POWER_ENV_S:
+               hdev->clk_throttling_reason |= HL_CLK_THROTTLE_POWER;
                dev_info_ratelimited(hdev->dev,
                        "Clock throttling due to power consumption\n");
                break;
        case GOYA_ASYNC_EVENT_ID_FIX_POWER_ENV_E:
+               hdev->clk_throttling_reason &= ~HL_CLK_THROTTLE_POWER;
                dev_info_ratelimited(hdev->dev,
                        "Power envelop is safe, back to optimal clock\n");
                break;
        case GOYA_ASYNC_EVENT_ID_FIX_THERMAL_ENV_S:
+               hdev->clk_throttling_reason |= HL_CLK_THROTTLE_THERMAL;
                dev_info_ratelimited(hdev->dev,
                        "Clock throttling due to overheating\n");
                break;
        case GOYA_ASYNC_EVENT_ID_FIX_THERMAL_ENV_E:
+               hdev->clk_throttling_reason &= ~HL_CLK_THROTTLE_THERMAL;
                dev_info_ratelimited(hdev->dev,
                        "Thermal envelop is safe, back to optimal clock\n");
                break;
@@ -4607,7 +4653,8 @@ void goya_handle_eqe(struct hl_device *hdev, struct hl_eq_entry *eq_entry)
        case GOYA_ASYNC_EVENT_ID_L2_RAM_ECC:
        case GOYA_ASYNC_EVENT_ID_PSOC_GPIO_05_SW_RESET:
                goya_print_irq_info(hdev, event_type, false);
-               hl_device_reset(hdev, true, false);
+               if (hdev->hard_reset_on_fw_events)
+                       hl_device_reset(hdev, true, false);
                break;
 
        case GOYA_ASYNC_EVENT_ID_PCIE_DEC:
@@ -5065,7 +5112,7 @@ int goya_send_heartbeat(struct hl_device *hdev)
        return hl_fw_send_heartbeat(hdev);
 }
 
-int goya_armcp_info_get(struct hl_device *hdev)
+int goya_cpucp_info_get(struct hl_device *hdev)
 {
        struct goya_device *goya = hdev->asic_specific;
        struct asic_fixed_properties *prop = &hdev->asic_prop;
@@ -5075,11 +5122,11 @@ int goya_armcp_info_get(struct hl_device *hdev)
        if (!(goya->hw_cap_initialized & HW_CAP_CPU_Q))
                return 0;
 
-       rc = hl_fw_armcp_info_get(hdev);
+       rc = hl_fw_cpucp_info_get(hdev);
        if (rc)
                return rc;
 
-       dram_size = le64_to_cpu(prop->armcp_info.dram_size);
+       dram_size = le64_to_cpu(prop->cpucp_info.dram_size);
        if (dram_size) {
                if ((!is_power_of_2(dram_size)) ||
                                (dram_size < DRAM_PHYS_DEFAULT_SIZE)) {
@@ -5093,8 +5140,8 @@ int goya_armcp_info_get(struct hl_device *hdev)
                prop->dram_end_address = prop->dram_base_address + dram_size;
        }
 
-       if (!strlen(prop->armcp_info.card_name))
-               strncpy(prop->armcp_info.card_name, GOYA_DEFAULT_CARD_NAME,
+       if (!strlen(prop->cpucp_info.card_name))
+               strncpy(prop->cpucp_info.card_name, GOYA_DEFAULT_CARD_NAME,
                                CARD_NAME_MAX_LEN);
 
        return 0;
@@ -5110,7 +5157,7 @@ static void goya_disable_clock_gating(struct hl_device *hdev)
        /* clock gating not supported in Goya */
 }
 
-static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask,
+static bool goya_is_device_idle(struct hl_device *hdev, u64 *mask,
                                struct seq_file *s)
 {
        const char *fmt = "%-5d%-9s%#-14x%#-16x%#x\n";
@@ -5135,7 +5182,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask,
                is_idle &= is_eng_idle;
 
                if (mask)
-                       *mask |= !is_eng_idle << (GOYA_ENGINE_ID_DMA_0 + i);
+                       *mask |= ((u64) !is_eng_idle) <<
+                                               (GOYA_ENGINE_ID_DMA_0 + i);
                if (s)
                        seq_printf(s, dma_fmt, i, is_eng_idle ? "Y" : "N",
                                        qm_glbl_sts0, dma_core_sts0);
@@ -5158,7 +5206,8 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask,
                is_idle &= is_eng_idle;
 
                if (mask)
-                       *mask |= !is_eng_idle << (GOYA_ENGINE_ID_TPC_0 + i);
+                       *mask |= ((u64) !is_eng_idle) <<
+                                               (GOYA_ENGINE_ID_TPC_0 + i);
                if (s)
                        seq_printf(s, fmt, i, is_eng_idle ? "Y" : "N",
                                qm_glbl_sts0, cmdq_glbl_sts0, tpc_cfg_sts);
@@ -5178,7 +5227,7 @@ static bool goya_is_device_idle(struct hl_device *hdev, u32 *mask,
        is_idle &= is_eng_idle;
 
        if (mask)
-               *mask |= !is_eng_idle << GOYA_ENGINE_ID_MME_0;
+               *mask |= ((u64) !is_eng_idle) << GOYA_ENGINE_ID_MME_0;
        if (s) {
                seq_printf(s, fmt, 0, is_eng_idle ? "Y" : "N", qm_glbl_sts0,
                                cmdq_glbl_sts0, mme_arch_sts);
@@ -5338,7 +5387,6 @@ static const struct hl_asic_funcs goya_funcs = {
        .send_cpu_message = goya_send_cpu_message,
        .get_hw_state = goya_get_hw_state,
        .pci_bars_map = goya_pci_bars_map,
-       .set_dram_bar_base = goya_set_ddr_bar_base,
        .init_iatu = goya_init_iatu,
        .rreg = hl_rreg,
        .wreg = hl_wreg,
index bb7474e..09b4006 100644 (file)
@@ -207,7 +207,7 @@ void goya_set_max_power(struct hl_device *hdev, u64 value);
 void goya_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq);
 void goya_add_device_attr(struct hl_device *hdev,
                        struct attribute_group *dev_attr_grp);
-int goya_armcp_info_get(struct hl_device *hdev);
+int goya_cpucp_info_get(struct hl_device *hdev);
 int goya_debug_coresight(struct hl_device *hdev, void *data);
 void goya_halt_coresight(struct hl_device *hdev);
 
index b039124..4027a6a 100644 (file)
@@ -362,11 +362,17 @@ static int goya_config_etf(struct hl_device *hdev,
 }
 
 static int goya_etr_validate_address(struct hl_device *hdev, u64 addr,
-               u32 size)
+               u64 size)
 {
        struct asic_fixed_properties *prop = &hdev->asic_prop;
        u64 range_start, range_end;
 
+       if (addr > (addr + size)) {
+               dev_err(hdev->dev,
+                       "ETR buffer size %llu overflow\n", size);
+               return false;
+       }
+
        if (hdev->mmu_enable) {
                range_start = prop->dmmu.start_addr;
                range_end = prop->dmmu.end_addr;
diff --git a/drivers/misc/habanalabs/include/common/armcp_if.h b/drivers/misc/habanalabs/include/common/armcp_if.h
deleted file mode 100644 (file)
index 07f9972..0000000
+++ /dev/null
@@ -1,407 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- * Copyright 2016-2020 HabanaLabs, Ltd.
- * All Rights Reserved.
- *
- */
-
-#ifndef ARMCP_IF_H
-#define ARMCP_IF_H
-
-#include <linux/types.h>
-
-/*
- * EVENT QUEUE
- */
-
-struct hl_eq_header {
-       __le32 reserved;
-       __le32 ctl;
-};
-
-struct hl_eq_ecc_data {
-       __le64 ecc_address;
-       __le64 ecc_syndrom;
-       __u8 memory_wrapper_idx;
-       __u8 pad[7];
-};
-
-struct hl_eq_entry {
-       struct hl_eq_header hdr;
-       union {
-               struct hl_eq_ecc_data ecc_data;
-               __le64 data[7];
-       };
-};
-
-#define HL_EQ_ENTRY_SIZE               sizeof(struct hl_eq_entry)
-
-#define EQ_CTL_READY_SHIFT             31
-#define EQ_CTL_READY_MASK              0x80000000
-
-#define EQ_CTL_EVENT_TYPE_SHIFT                16
-#define EQ_CTL_EVENT_TYPE_MASK         0x03FF0000
-
-enum pq_init_status {
-       PQ_INIT_STATUS_NA = 0,
-       PQ_INIT_STATUS_READY_FOR_CP,
-       PQ_INIT_STATUS_READY_FOR_HOST,
-       PQ_INIT_STATUS_READY_FOR_CP_SINGLE_MSI
-};
-
-/*
- * ArmCP Primary Queue Packets
- *
- * During normal operation, the host's kernel driver needs to send various
- * messages to ArmCP, usually either to SET some value into a H/W periphery or
- * to GET the current value of some H/W periphery. For example, SET the
- * frequency of MME/TPC and GET the value of the thermal sensor.
- *
- * These messages can be initiated either by the User application or by the
- * host's driver itself, e.g. power management code. In either case, the
- * communication from the host's driver to ArmCP will *always* be in
- * synchronous mode, meaning that the host will send a single message and poll
- * until the message was acknowledged and the results are ready (if results are
- * needed).
- *
- * This means that only a single message can be sent at a time and the host's
- * driver must wait for its result before sending the next message. Having said
- * that, because these are control messages which are sent in a relatively low
- * frequency, this limitation seems acceptable. It's important to note that
- * in case of multiple devices, messages to different devices *can* be sent
- * at the same time.
- *
- * The message, inputs/outputs (if relevant) and fence object will be located
- * on the device DDR at an address that will be determined by the host's driver.
- * During device initialization phase, the host will pass to ArmCP that address.
- * Most of the message types will contain inputs/outputs inside the message
- * itself. The common part of each message will contain the opcode of the
- * message (its type) and a field representing a fence object.
- *
- * When the host's driver wishes to send a message to ArmCP, it will write the
- * message contents to the device DDR, clear the fence object and then write the
- * value 484 to the mmGIC_DISTRIBUTOR__5_GICD_SETSPI_NSR register to issue
- * the 484 interrupt-id to the ARM core.
- *
- * Upon receiving the 484 interrupt-id, ArmCP will read the message from the
- * DDR. In case the message is a SET operation, ArmCP will first perform the
- * operation and then write to the fence object on the device DDR. In case the
- * message is a GET operation, ArmCP will first fill the results section on the
- * device DDR and then write to the fence object. If an error occurred, ArmCP
- * will fill the rc field with the right error code.
- *
- * In the meantime, the host's driver will poll on the fence object. Once the
- * host sees that the fence object is signaled, it will read the results from
- * the device DDR (if relevant) and resume the code execution in the host's
- * driver.
- *
- * To use QMAN packets, the opcode must be the QMAN opcode, shifted by 8
- * so the value being put by the host's driver matches the value read by ArmCP
- *
- * Non-QMAN packets should be limited to values 1 through (2^8 - 1)
- *
- * Detailed description:
- *
- * ARMCP_PACKET_DISABLE_PCI_ACCESS -
- *       After receiving this packet the embedded CPU must NOT issue PCI
- *       transactions (read/write) towards the Host CPU. This also include
- *       sending MSI-X interrupts.
- *       This packet is usually sent before the device is moved to D3Hot state.
- *
- * ARMCP_PACKET_ENABLE_PCI_ACCESS -
- *       After receiving this packet the embedded CPU is allowed to issue PCI
- *       transactions towards the Host CPU, including sending MSI-X interrupts.
- *       This packet is usually send after the device is moved to D0 state.
- *
- * ARMCP_PACKET_TEMPERATURE_GET -
- *       Fetch the current temperature / Max / Max Hyst / Critical /
- *       Critical Hyst of a specified thermal sensor. The packet's
- *       arguments specify the desired sensor and the field to get.
- *
- * ARMCP_PACKET_VOLTAGE_GET -
- *       Fetch the voltage / Max / Min of a specified sensor. The packet's
- *       arguments specify the sensor and type.
- *
- * ARMCP_PACKET_CURRENT_GET -
- *       Fetch the current / Max / Min of a specified sensor. The packet's
- *       arguments specify the sensor and type.
- *
- * ARMCP_PACKET_FAN_SPEED_GET -
- *       Fetch the speed / Max / Min of a specified fan. The packet's
- *       arguments specify the sensor and type.
- *
- * ARMCP_PACKET_PWM_GET -
- *       Fetch the pwm value / mode of a specified pwm. The packet's
- *       arguments specify the sensor and type.
- *
- * ARMCP_PACKET_PWM_SET -
- *       Set the pwm value / mode of a specified pwm. The packet's
- *       arguments specify the sensor, type and value.
- *
- * ARMCP_PACKET_FREQUENCY_SET -
- *       Set the frequency of a specified PLL. The packet's arguments specify
- *       the PLL and the desired frequency. The actual frequency in the device
- *       might differ from the requested frequency.
- *
- * ARMCP_PACKET_FREQUENCY_GET -
- *       Fetch the frequency of a specified PLL. The packet's arguments specify
- *       the PLL.
- *
- * ARMCP_PACKET_LED_SET -
- *       Set the state of a specified led. The packet's arguments
- *       specify the led and the desired state.
- *
- * ARMCP_PACKET_I2C_WR -
- *       Write 32-bit value to I2C device. The packet's arguments specify the
- *       I2C bus, address and value.
- *
- * ARMCP_PACKET_I2C_RD -
- *       Read 32-bit value from I2C device. The packet's arguments specify the
- *       I2C bus and address.
- *
- * ARMCP_PACKET_INFO_GET -
- *       Fetch information from the device as specified in the packet's
- *       structure. The host's driver passes the max size it allows the ArmCP to
- *       write to the structure, to prevent data corruption in case of
- *       mismatched driver/FW versions.
- *
- * ARMCP_PACKET_FLASH_PROGRAM_REMOVED - this packet was removed
- *
- * ARMCP_PACKET_UNMASK_RAZWI_IRQ -
- *       Unmask the given IRQ. The IRQ number is specified in the value field.
- *       The packet is sent after receiving an interrupt and printing its
- *       relevant information.
- *
- * ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY -
- *       Unmask the given IRQs. The IRQs numbers are specified in an array right
- *       after the armcp_packet structure, where its first element is the array
- *       length. The packet is sent after a soft reset was done in order to
- *       handle any interrupts that were sent during the reset process.
- *
- * ARMCP_PACKET_TEST -
- *       Test packet for ArmCP connectivity. The CPU will put the fence value
- *       in the result field.
- *
- * ARMCP_PACKET_FREQUENCY_CURR_GET -
- *       Fetch the current frequency of a specified PLL. The packet's arguments
- *       specify the PLL.
- *
- * ARMCP_PACKET_MAX_POWER_GET -
- *       Fetch the maximal power of the device.
- *
- * ARMCP_PACKET_MAX_POWER_SET -
- *       Set the maximal power of the device. The packet's arguments specify
- *       the power.
- *
- * ARMCP_PACKET_EEPROM_DATA_GET -
- *       Get EEPROM data from the ArmCP kernel. The buffer is specified in the
- *       addr field. The CPU will put the returned data size in the result
- *       field. In addition, the host's driver passes the max size it allows the
- *       ArmCP to write to the structure, to prevent data corruption in case of
- *       mismatched driver/FW versions.
- *
- * ARMCP_PACKET_TEMPERATURE_SET -
- *       Set the value of the offset property of a specified thermal sensor.
- *       The packet's arguments specify the desired sensor and the field to
- *       set.
- *
- * ARMCP_PACKET_VOLTAGE_SET -
- *       Trigger the reset_history property of a specified voltage sensor.
- *       The packet's arguments specify the desired sensor and the field to
- *       set.
- *
- * ARMCP_PACKET_CURRENT_SET -
- *       Trigger the reset_history property of a specified current sensor.
- *       The packet's arguments specify the desired sensor and the field to
- *       set.
- */
-
-enum armcp_packet_id {
-       ARMCP_PACKET_DISABLE_PCI_ACCESS = 1,    /* internal */
-       ARMCP_PACKET_ENABLE_PCI_ACCESS,         /* internal */
-       ARMCP_PACKET_TEMPERATURE_GET,           /* sysfs */
-       ARMCP_PACKET_VOLTAGE_GET,               /* sysfs */
-       ARMCP_PACKET_CURRENT_GET,               /* sysfs */
-       ARMCP_PACKET_FAN_SPEED_GET,             /* sysfs */
-       ARMCP_PACKET_PWM_GET,                   /* sysfs */
-       ARMCP_PACKET_PWM_SET,                   /* sysfs */
-       ARMCP_PACKET_FREQUENCY_SET,             /* sysfs */
-       ARMCP_PACKET_FREQUENCY_GET,             /* sysfs */
-       ARMCP_PACKET_LED_SET,                   /* debugfs */
-       ARMCP_PACKET_I2C_WR,                    /* debugfs */
-       ARMCP_PACKET_I2C_RD,                    /* debugfs */
-       ARMCP_PACKET_INFO_GET,                  /* IOCTL */
-       ARMCP_PACKET_FLASH_PROGRAM_REMOVED,
-       ARMCP_PACKET_UNMASK_RAZWI_IRQ,          /* internal */
-       ARMCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY,    /* internal */
-       ARMCP_PACKET_TEST,                      /* internal */
-       ARMCP_PACKET_FREQUENCY_CURR_GET,        /* sysfs */
-       ARMCP_PACKET_MAX_POWER_GET,             /* sysfs */
-       ARMCP_PACKET_MAX_POWER_SET,             /* sysfs */
-       ARMCP_PACKET_EEPROM_DATA_GET,           /* sysfs */
-       ARMCP_RESERVED,
-       ARMCP_PACKET_TEMPERATURE_SET,           /* sysfs */
-       ARMCP_PACKET_VOLTAGE_SET,               /* sysfs */
-       ARMCP_PACKET_CURRENT_SET,               /* sysfs */
-};
-
-#define ARMCP_PACKET_FENCE_VAL 0xFE8CE7A5
-
-#define ARMCP_PKT_CTL_RC_SHIFT         12
-#define ARMCP_PKT_CTL_RC_MASK          0x0000F000
-
-#define ARMCP_PKT_CTL_OPCODE_SHIFT     16
-#define ARMCP_PKT_CTL_OPCODE_MASK      0x1FFF0000
-
-struct armcp_packet {
-       union {
-               __le64 value;   /* For SET packets */
-               __le64 result;  /* For GET packets */
-               __le64 addr;    /* For PQ */
-       };
-
-       __le32 ctl;
-
-       __le32 fence;           /* Signal to host that message is completed */
-
-       union {
-               struct {/* For temperature/current/voltage/fan/pwm get/set */
-                       __le16 sensor_index;
-                       __le16 type;
-               };
-
-               struct {        /* For I2C read/write */
-                       __u8 i2c_bus;
-                       __u8 i2c_addr;
-                       __u8 i2c_reg;
-                       __u8 pad; /* unused */
-               };
-
-               /* For frequency get/set */
-               __le32 pll_index;
-
-               /* For led set */
-               __le32 led_index;
-
-               /* For get Armcp info/EEPROM data */
-               __le32 data_max_size;
-       };
-
-       __le32 reserved;
-};
-
-struct armcp_unmask_irq_arr_packet {
-       struct armcp_packet armcp_pkt;
-       __le32 length;
-       __le32 irqs[0];
-};
-
-enum armcp_packet_rc {
-       armcp_packet_success,
-       armcp_packet_invalid,
-       armcp_packet_fault
-};
-
-/*
- * armcp_temp_type should adhere to hwmon_temp_attributes
- * defined in Linux kernel hwmon.h file
- */
-enum armcp_temp_type {
-       armcp_temp_input,
-       armcp_temp_max = 6,
-       armcp_temp_max_hyst,
-       armcp_temp_crit,
-       armcp_temp_crit_hyst,
-       armcp_temp_offset = 19,
-       armcp_temp_highest = 22,
-       armcp_temp_reset_history = 23
-};
-
-enum armcp_in_attributes {
-       armcp_in_input,
-       armcp_in_min,
-       armcp_in_max,
-       armcp_in_highest = 7,
-       armcp_in_reset_history
-};
-
-enum armcp_curr_attributes {
-       armcp_curr_input,
-       armcp_curr_min,
-       armcp_curr_max,
-       armcp_curr_highest = 7,
-       armcp_curr_reset_history
-};
-
-enum armcp_fan_attributes {
-       armcp_fan_input,
-       armcp_fan_min = 2,
-       armcp_fan_max
-};
-
-enum armcp_pwm_attributes {
-       armcp_pwm_input,
-       armcp_pwm_enable
-};
-
-/* Event Queue Packets */
-
-struct eq_generic_event {
-       __le64 data[7];
-};
-
-/*
- * ArmCP info
- */
-
-#define CARD_NAME_MAX_LEN              16
-#define VERSION_MAX_LEN                        128
-#define ARMCP_MAX_SENSORS              128
-
-struct armcp_sensor {
-       __le32 type;
-       __le32 flags;
-};
-
-/**
- * struct armcp_card_types - ASIC card type.
- * @armcp_card_type_pci: PCI card.
- * @armcp_card_type_pmc: PCI Mezzanine Card.
- */
-enum armcp_card_types {
-       armcp_card_type_pci,
-       armcp_card_type_pmc
-};
-
-/**
- * struct armcp_info - Info from ArmCP that is necessary to the host's driver
- * @sensors: available sensors description.
- * @kernel_version: ArmCP linux kernel version.
- * @reserved: reserved field.
- * @card_type: card configuration type.
- * @card_location: in a server, each card has different connections topology
- *                 depending on its location (relevant for PMC card type)
- * @cpld_version: CPLD programmed F/W version.
- * @infineon_version: Infineon main DC-DC version.
- * @fuse_version: silicon production FUSE information.
- * @thermal_version: thermald S/W version.
- * @armcp_version: ArmCP S/W version.
- * @dram_size: available DRAM size.
- * @card_name: card name that will be displayed in HWMON subsystem on the host
- */
-struct armcp_info {
-       struct armcp_sensor sensors[ARMCP_MAX_SENSORS];
-       __u8 kernel_version[VERSION_MAX_LEN];
-       __le32 reserved;
-       __le32 card_type;
-       __le32 card_location;
-       __le32 cpld_version;
-       __le32 infineon_version;
-       __u8 fuse_version[VERSION_MAX_LEN];
-       __u8 thermal_version[VERSION_MAX_LEN];
-       __u8 armcp_version[VERSION_MAX_LEN];
-       __le64 dram_size;
-       char card_name[CARD_NAME_MAX_LEN];
-};
-
-#endif /* ARMCP_IF_H */
diff --git a/drivers/misc/habanalabs/include/common/cpucp_if.h b/drivers/misc/habanalabs/include/common/cpucp_if.h
new file mode 100644 (file)
index 0000000..2a5c9cb
--- /dev/null
@@ -0,0 +1,443 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright 2020 HabanaLabs, Ltd.
+ * All Rights Reserved.
+ *
+ */
+
+#ifndef CPUCP_IF_H
+#define CPUCP_IF_H
+
+#include <linux/types.h>
+
+/*
+ * EVENT QUEUE
+ */
+
+struct hl_eq_header {
+       __le32 reserved;
+       __le32 ctl;
+};
+
+struct hl_eq_ecc_data {
+       __le64 ecc_address;
+       __le64 ecc_syndrom;
+       __u8 memory_wrapper_idx;
+       __u8 pad[7];
+};
+
+struct hl_eq_entry {
+       struct hl_eq_header hdr;
+       union {
+               struct hl_eq_ecc_data ecc_data;
+               __le64 data[7];
+       };
+};
+
+#define HL_EQ_ENTRY_SIZE               sizeof(struct hl_eq_entry)
+
+#define EQ_CTL_READY_SHIFT             31
+#define EQ_CTL_READY_MASK              0x80000000
+
+#define EQ_CTL_EVENT_TYPE_SHIFT                16
+#define EQ_CTL_EVENT_TYPE_MASK         0x03FF0000
+
+enum pq_init_status {
+       PQ_INIT_STATUS_NA = 0,
+       PQ_INIT_STATUS_READY_FOR_CP,
+       PQ_INIT_STATUS_READY_FOR_HOST,
+       PQ_INIT_STATUS_READY_FOR_CP_SINGLE_MSI
+};
+
+/*
+ * CpuCP Primary Queue Packets
+ *
+ * During normal operation, the host's kernel driver needs to send various
+ * messages to CpuCP, usually either to SET some value into a H/W periphery or
+ * to GET the current value of some H/W periphery. For example, SET the
+ * frequency of MME/TPC and GET the value of the thermal sensor.
+ *
+ * These messages can be initiated either by the User application or by the
+ * host's driver itself, e.g. power management code. In either case, the
+ * communication from the host's driver to CpuCP will *always* be in
+ * synchronous mode, meaning that the host will send a single message and poll
+ * until the message was acknowledged and the results are ready (if results are
+ * needed).
+ *
+ * This means that only a single message can be sent at a time and the host's
+ * driver must wait for its result before sending the next message. Having said
+ * that, because these are control messages which are sent in a relatively low
+ * frequency, this limitation seems acceptable. It's important to note that
+ * in case of multiple devices, messages to different devices *can* be sent
+ * at the same time.
+ *
+ * The message, inputs/outputs (if relevant) and fence object will be located
+ * on the device DDR at an address that will be determined by the host's driver.
+ * During device initialization phase, the host will pass to CpuCP that address.
+ * Most of the message types will contain inputs/outputs inside the message
+ * itself. The common part of each message will contain the opcode of the
+ * message (its type) and a field representing a fence object.
+ *
+ * When the host's driver wishes to send a message to CPU CP, it will write the
+ * message contents to the device DDR, clear the fence object and then write to
+ * the PSOC_ARC1_AUX_SW_INTR, to issue interrupt 121 to ARC Management CPU.
+ *
+ * Upon receiving the interrupt (#121), CpuCP will read the message from the
+ * DDR. In case the message is a SET operation, CpuCP will first perform the
+ * operation and then write to the fence object on the device DDR. In case the
+ * message is a GET operation, CpuCP will first fill the results section on the
+ * device DDR and then write to the fence object. If an error occurred, CpuCP
+ * will fill the rc field with the right error code.
+ *
+ * In the meantime, the host's driver will poll on the fence object. Once the
+ * host sees that the fence object is signaled, it will read the results from
+ * the device DDR (if relevant) and resume the code execution in the host's
+ * driver.
+ *
+ * To use QMAN packets, the opcode must be the QMAN opcode, shifted by 8
+ * so the value being put by the host's driver matches the value read by CpuCP
+ *
+ * Non-QMAN packets should be limited to values 1 through (2^8 - 1)
+ *
+ * Detailed description:
+ *
+ * CPUCP_PACKET_DISABLE_PCI_ACCESS -
+ *       After receiving this packet the embedded CPU must NOT issue PCI
+ *       transactions (read/write) towards the Host CPU. This also include
+ *       sending MSI-X interrupts.
+ *       This packet is usually sent before the device is moved to D3Hot state.
+ *
+ * CPUCP_PACKET_ENABLE_PCI_ACCESS -
+ *       After receiving this packet the embedded CPU is allowed to issue PCI
+ *       transactions towards the Host CPU, including sending MSI-X interrupts.
+ *       This packet is usually send after the device is moved to D0 state.
+ *
+ * CPUCP_PACKET_TEMPERATURE_GET -
+ *       Fetch the current temperature / Max / Max Hyst / Critical /
+ *       Critical Hyst of a specified thermal sensor. The packet's
+ *       arguments specify the desired sensor and the field to get.
+ *
+ * CPUCP_PACKET_VOLTAGE_GET -
+ *       Fetch the voltage / Max / Min of a specified sensor. The packet's
+ *       arguments specify the sensor and type.
+ *
+ * CPUCP_PACKET_CURRENT_GET -
+ *       Fetch the current / Max / Min of a specified sensor. The packet's
+ *       arguments specify the sensor and type.
+ *
+ * CPUCP_PACKET_FAN_SPEED_GET -
+ *       Fetch the speed / Max / Min of a specified fan. The packet's
+ *       arguments specify the sensor and type.
+ *
+ * CPUCP_PACKET_PWM_GET -
+ *       Fetch the pwm value / mode of a specified pwm. The packet's
+ *       arguments specify the sensor and type.
+ *
+ * CPUCP_PACKET_PWM_SET -
+ *       Set the pwm value / mode of a specified pwm. The packet's
+ *       arguments specify the sensor, type and value.
+ *
+ * CPUCP_PACKET_FREQUENCY_SET -
+ *       Set the frequency of a specified PLL. The packet's arguments specify
+ *       the PLL and the desired frequency. The actual frequency in the device
+ *       might differ from the requested frequency.
+ *
+ * CPUCP_PACKET_FREQUENCY_GET -
+ *       Fetch the frequency of a specified PLL. The packet's arguments specify
+ *       the PLL.
+ *
+ * CPUCP_PACKET_LED_SET -
+ *       Set the state of a specified led. The packet's arguments
+ *       specify the led and the desired state.
+ *
+ * CPUCP_PACKET_I2C_WR -
+ *       Write 32-bit value to I2C device. The packet's arguments specify the
+ *       I2C bus, address and value.
+ *
+ * CPUCP_PACKET_I2C_RD -
+ *       Read 32-bit value from I2C device. The packet's arguments specify the
+ *       I2C bus and address.
+ *
+ * CPUCP_PACKET_INFO_GET -
+ *       Fetch information from the device as specified in the packet's
+ *       structure. The host's driver passes the max size it allows the CpuCP to
+ *       write to the structure, to prevent data corruption in case of
+ *       mismatched driver/FW versions.
+ *
+ * CPUCP_PACKET_FLASH_PROGRAM_REMOVED - this packet was removed
+ *
+ * CPUCP_PACKET_UNMASK_RAZWI_IRQ -
+ *       Unmask the given IRQ. The IRQ number is specified in the value field.
+ *       The packet is sent after receiving an interrupt and printing its
+ *       relevant information.
+ *
+ * CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY -
+ *       Unmask the given IRQs. The IRQs numbers are specified in an array right
+ *       after the cpucp_packet structure, where its first element is the array
+ *       length. The packet is sent after a soft reset was done in order to
+ *       handle any interrupts that were sent during the reset process.
+ *
+ * CPUCP_PACKET_TEST -
+ *       Test packet for CpuCP connectivity. The CPU will put the fence value
+ *       in the result field.
+ *
+ * CPUCP_PACKET_FREQUENCY_CURR_GET -
+ *       Fetch the current frequency of a specified PLL. The packet's arguments
+ *       specify the PLL.
+ *
+ * CPUCP_PACKET_MAX_POWER_GET -
+ *       Fetch the maximal power of the device.
+ *
+ * CPUCP_PACKET_MAX_POWER_SET -
+ *       Set the maximal power of the device. The packet's arguments specify
+ *       the power.
+ *
+ * CPUCP_PACKET_EEPROM_DATA_GET -
+ *       Get EEPROM data from the CpuCP kernel. The buffer is specified in the
+ *       addr field. The CPU will put the returned data size in the result
+ *       field. In addition, the host's driver passes the max size it allows the
+ *       CpuCP to write to the structure, to prevent data corruption in case of
+ *       mismatched driver/FW versions.
+ *
+ * CPUCP_PACKET_TEMPERATURE_SET -
+ *       Set the value of the offset property of a specified thermal sensor.
+ *       The packet's arguments specify the desired sensor and the field to
+ *       set.
+ *
+ * CPUCP_PACKET_VOLTAGE_SET -
+ *       Trigger the reset_history property of a specified voltage sensor.
+ *       The packet's arguments specify the desired sensor and the field to
+ *       set.
+ *
+ * CPUCP_PACKET_CURRENT_SET -
+ *       Trigger the reset_history property of a specified current sensor.
+ *       The packet's arguments specify the desired sensor and the field to
+ *       set.
+ *
+ * CPUCP_PACKET_PLL_REG_GET
+ *       Fetch register of PLL from the required PLL IP.
+ *       The packet's arguments specify the PLL IP and the register to get.
+ *       Each register is 32-bit value which is returned in result field.
+ *
+ */
+
+enum cpucp_packet_id {
+       CPUCP_PACKET_DISABLE_PCI_ACCESS = 1,    /* internal */
+       CPUCP_PACKET_ENABLE_PCI_ACCESS,         /* internal */
+       CPUCP_PACKET_TEMPERATURE_GET,           /* sysfs */
+       CPUCP_PACKET_VOLTAGE_GET,               /* sysfs */
+       CPUCP_PACKET_CURRENT_GET,               /* sysfs */
+       CPUCP_PACKET_FAN_SPEED_GET,             /* sysfs */
+       CPUCP_PACKET_PWM_GET,                   /* sysfs */
+       CPUCP_PACKET_PWM_SET,                   /* sysfs */
+       CPUCP_PACKET_FREQUENCY_SET,             /* sysfs */
+       CPUCP_PACKET_FREQUENCY_GET,             /* sysfs */
+       CPUCP_PACKET_LED_SET,                   /* debugfs */
+       CPUCP_PACKET_I2C_WR,                    /* debugfs */
+       CPUCP_PACKET_I2C_RD,                    /* debugfs */
+       CPUCP_PACKET_INFO_GET,                  /* IOCTL */
+       CPUCP_PACKET_FLASH_PROGRAM_REMOVED,
+       CPUCP_PACKET_UNMASK_RAZWI_IRQ,          /* internal */
+       CPUCP_PACKET_UNMASK_RAZWI_IRQ_ARRAY,    /* internal */
+       CPUCP_PACKET_TEST,                      /* internal */
+       CPUCP_PACKET_FREQUENCY_CURR_GET,        /* sysfs */
+       CPUCP_PACKET_MAX_POWER_GET,             /* sysfs */
+       CPUCP_PACKET_MAX_POWER_SET,             /* sysfs */
+       CPUCP_PACKET_EEPROM_DATA_GET,           /* sysfs */
+       CPUCP_RESERVED,
+       CPUCP_PACKET_TEMPERATURE_SET,           /* sysfs */
+       CPUCP_PACKET_VOLTAGE_SET,               /* sysfs */
+       CPUCP_PACKET_CURRENT_SET,               /* sysfs */
+       CPUCP_PACKET_PCIE_THROUGHPUT_GET,               /* internal */
+       CPUCP_PACKET_PCIE_REPLAY_CNT_GET,               /* internal */
+       CPUCP_PACKET_TOTAL_ENERGY_GET,          /* internal */
+       CPUCP_PACKET_PLL_REG_GET,               /* internal */
+};
+
+#define CPUCP_PACKET_FENCE_VAL 0xFE8CE7A5
+
+#define CPUCP_PKT_CTL_RC_SHIFT         12
+#define CPUCP_PKT_CTL_RC_MASK          0x0000F000
+
+#define CPUCP_PKT_CTL_OPCODE_SHIFT     16
+#define CPUCP_PKT_CTL_OPCODE_MASK      0x1FFF0000
+
+struct cpucp_packet {
+       union {
+               __le64 value;   /* For SET packets */
+               __le64 result;  /* For GET packets */
+               __le64 addr;    /* For PQ */
+       };
+
+       __le32 ctl;
+
+       __le32 fence;           /* Signal to host that message is completed */
+
+       union {
+               struct {/* For temperature/current/voltage/fan/pwm get/set */
+                       __le16 sensor_index;
+                       __le16 type;
+               };
+
+               struct {        /* For I2C read/write */
+                       __u8 i2c_bus;
+                       __u8 i2c_addr;
+                       __u8 i2c_reg;
+                       __u8 pad; /* unused */
+               };
+
+               struct {/* For PLL register fetch */
+                       __le16 pll_type;
+                       __le16 pll_reg;
+               };
+
+               /* For any general request */
+               __le32 index;
+
+               /* For frequency get/set */
+               __le32 pll_index;
+
+               /* For led set */
+               __le32 led_index;
+
+               /* For get CpuCP info/EEPROM data */
+               __le32 data_max_size;
+       };
+
+       __le32 reserved;
+};
+
+struct cpucp_unmask_irq_arr_packet {
+       struct cpucp_packet cpucp_pkt;
+       __le32 length;
+       __le32 irqs[0];
+};
+
+enum cpucp_packet_rc {
+       cpucp_packet_success,
+       cpucp_packet_invalid,
+       cpucp_packet_fault
+};
+
+/*
+ * cpucp_temp_type should adhere to hwmon_temp_attributes
+ * defined in Linux kernel hwmon.h file
+ */
+enum cpucp_temp_type {
+       cpucp_temp_input,
+       cpucp_temp_max = 6,
+       cpucp_temp_max_hyst,
+       cpucp_temp_crit,
+       cpucp_temp_crit_hyst,
+       cpucp_temp_offset = 19,
+       cpucp_temp_highest = 22,
+       cpucp_temp_reset_history = 23
+};
+
+enum cpucp_in_attributes {
+       cpucp_in_input,
+       cpucp_in_min,
+       cpucp_in_max,
+       cpucp_in_highest = 7,
+       cpucp_in_reset_history
+};
+
+enum cpucp_curr_attributes {
+       cpucp_curr_input,
+       cpucp_curr_min,
+       cpucp_curr_max,
+       cpucp_curr_highest = 7,
+       cpucp_curr_reset_history
+};
+
+enum cpucp_fan_attributes {
+       cpucp_fan_input,
+       cpucp_fan_min = 2,
+       cpucp_fan_max
+};
+
+enum cpucp_pwm_attributes {
+       cpucp_pwm_input,
+       cpucp_pwm_enable
+};
+
+enum cpucp_pcie_throughput_attributes {
+       cpucp_pcie_throughput_tx,
+       cpucp_pcie_throughput_rx
+};
+
+enum cpucp_pll_reg_attributes {
+       cpucp_pll_nr_reg,
+       cpucp_pll_nf_reg,
+       cpucp_pll_od_reg,
+       cpucp_pll_div_factor_reg,
+       cpucp_pll_div_sel_reg
+};
+
+enum cpucp_pll_type_attributes {
+       cpucp_pll_cpu,
+       cpucp_pll_pci,
+};
+
+/* Event Queue Packets */
+
+struct eq_generic_event {
+       __le64 data[7];
+};
+
+/*
+ * CpuCP info
+ */
+
+#define CARD_NAME_MAX_LEN              16
+#define VERSION_MAX_LEN                        128
+#define CPUCP_MAX_SENSORS              128
+
+struct cpucp_sensor {
+       __le32 type;
+       __le32 flags;
+};
+
+/**
+ * struct cpucp_card_types - ASIC card type.
+ * @cpucp_card_type_pci: PCI card.
+ * @cpucp_card_type_pmc: PCI Mezzanine Card.
+ */
+enum cpucp_card_types {
+       cpucp_card_type_pci,
+       cpucp_card_type_pmc
+};
+
+/**
+ * struct cpucp_info - Info from CpuCP that is necessary to the host's driver
+ * @sensors: available sensors description.
+ * @kernel_version: CpuCP linux kernel version.
+ * @reserved: reserved field.
+ * @card_type: card configuration type.
+ * @card_location: in a server, each card has different connections topology
+ *                 depending on its location (relevant for PMC card type)
+ * @cpld_version: CPLD programmed F/W version.
+ * @infineon_version: Infineon main DC-DC version.
+ * @fuse_version: silicon production FUSE information.
+ * @thermal_version: thermald S/W version.
+ * @cpucp_version: CpuCP S/W version.
+ * @dram_size: available DRAM size.
+ * @card_name: card name that will be displayed in HWMON subsystem on the host
+ */
+struct cpucp_info {
+       struct cpucp_sensor sensors[CPUCP_MAX_SENSORS];
+       __u8 kernel_version[VERSION_MAX_LEN];
+       __le32 reserved;
+       __le32 card_type;
+       __le32 card_location;
+       __le32 cpld_version;
+       __le32 infineon_version;
+       __u8 fuse_version[VERSION_MAX_LEN];
+       __u8 thermal_version[VERSION_MAX_LEN];
+       __u8 cpucp_version[VERSION_MAX_LEN];
+       __le32 reserved2;
+       __le64 dram_size;
+       char card_name[CARD_NAME_MAX_LEN];
+};
+
+#endif /* CPUCP_IF_H */
index 0fdb491..7ed7739 100644 (file)
@@ -40,7 +40,7 @@ struct hl_bd {
  */
 
 #define BD_CTL_COMP_OFFSET_SHIFT       16
-#define BD_CTL_COMP_OFFSET_MASK                0x00FF0000
+#define BD_CTL_COMP_OFFSET_MASK                0x0FFF0000
 
 #define BD_CTL_COMP_DATA_SHIFT         0
 #define BD_CTL_COMP_DATA_MASK          0x0000FFFF
index 8829891..f9ea897 100644 (file)
@@ -44,6 +44,8 @@
 
 #define MME_NUMBER_OF_MASTER_ENGINES   2
 
+#define MME_NUMBER_OF_SLAVE_ENGINES    2
+
 #define TPC_NUMBER_OF_ENGINES  8
 
 #define DMA_NUMBER_OF_CHANNELS 8
index 13ef6b2..f395721 100644 (file)
 
 /* Useful masks for bits in various registers */
 #define PCI_DMA_QMAN_ENABLE            (\
-       (0xF << DMA0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_CFG0_CP_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_PQF_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_CQF_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_CP_EN_MASK, 0xF)))
 
 #define QMAN_EXTERNAL_MAKE_TRUSTED     (\
-       (0xF << DMA0_QM_GLBL_PROT_PQF_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_PROT_CQF_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_PROT_CP_SHIFT) | \
-       (0x1 << DMA0_QM_GLBL_PROT_ERR_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_PQF_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_CQF_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_CP_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_ERR_MASK, 0x1)))
 
 #define QMAN_INTERNAL_MAKE_TRUSTED     (\
-       (0xF << DMA0_QM_GLBL_PROT_PQF_SHIFT) | \
-       (0x1 << DMA0_QM_GLBL_PROT_ERR_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_PQF_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_PROT_ERR_MASK, 0x1)))
 
 #define HBM_DMA_QMAN_ENABLE            (\
-       (0xF << DMA0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_CFG0_CP_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_PQF_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_CQF_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_CFG0_CP_EN_MASK, 0x1F)))
 
 #define QMAN_MME_ENABLE                (\
-       (0xF << MME0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_CFG0_CP_EN_SHIFT))
+       (FIELD_PREP(MME0_QM_GLBL_CFG0_PQF_EN_MASK, 0xF)) | \
+       (FIELD_PREP(MME0_QM_GLBL_CFG0_CQF_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(MME0_QM_GLBL_CFG0_CP_EN_MASK, 0x1F)))
 
 #define QMAN_TPC_ENABLE                (\
-       (0xF << TPC0_QM_GLBL_CFG0_PQF_EN_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_CFG0_CQF_EN_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_CFG0_CP_EN_SHIFT))
+       (FIELD_PREP(TPC0_QM_GLBL_CFG0_PQF_EN_MASK, 0xF)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_CFG0_CQF_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_CFG0_CP_EN_MASK, 0x1F)))
 
 #define QMAN_UPPER_CP_CGM_PWR_GATE_EN  (\
-       (0x20 << DMA0_QM_CGM_CFG_IDLE_TH_SHIFT) | \
-       (0xA << DMA0_QM_CGM_CFG_G2F_TH_SHIFT) | \
-       (0x10 << DMA0_QM_CGM_CFG_CP_IDLE_MASK_SHIFT) | \
-       (1 << DMA0_QM_CGM_CFG_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_CGM_CFG_IDLE_TH_MASK, 0x20)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_G2F_TH_MASK, 0xA)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_CP_IDLE_MASK_MASK, 0x10)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_EN_MASK, 0x1)))
 
 #define QMAN_COMMON_CP_CGM_PWR_GATE_EN (\
-       (0x20 << DMA0_QM_CGM_CFG_IDLE_TH_SHIFT) | \
-       (0xA << DMA0_QM_CGM_CFG_G2F_TH_SHIFT) | \
-       (0xF << DMA0_QM_CGM_CFG_CP_IDLE_MASK_SHIFT) | \
-       (1 << DMA0_QM_CGM_CFG_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_CGM_CFG_IDLE_TH_MASK, 0x20)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_G2F_TH_MASK, 0xA)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_CP_IDLE_MASK_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_CGM_CFG_EN_MASK, 0x1)))
 
 #define PCI_DMA_QMAN_GLBL_ERR_CFG_MSG_EN_MASK  (\
-       (0xF << DMA0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_MASK, 0xF)))
 
 #define PCI_DMA_QMAN_GLBL_ERR_CFG_STOP_ON_ERR_EN_MASK  (\
-       (0xF << DMA0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_SHIFT) | \
-       (0xF << DMA0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_MASK, 0xF)))
 
 #define HBM_DMA_QMAN_GLBL_ERR_CFG_MSG_EN_MASK  (\
-       (0xF << DMA0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_MASK, 0x1F)))
 
 #define HBM_DMA_QMAN_GLBL_ERR_CFG_STOP_ON_ERR_EN_MASK  (\
-       (0xF << DMA0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << DMA0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT))
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_MASK, 0xF)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_MASK, 0x1F)) | \
+       (FIELD_PREP(DMA0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_MASK, 0x1F)))
 
 #define TPC_QMAN_GLBL_ERR_CFG_MSG_EN_MASK      (\
-       (0xF << TPC0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_SHIFT))
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_MASK, 0xF)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_MASK, 0x1F)))
 
 #define TPC_QMAN_GLBL_ERR_CFG_STOP_ON_ERR_EN_MASK      (\
-       (0xF << TPC0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << TPC0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT))
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_MASK, 0xF)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_MASK, 0x1F)) | \
+       (FIELD_PREP(TPC0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_MASK, 0x1F)))
 
 #define MME_QMAN_GLBL_ERR_CFG_MSG_EN_MASK      (\
-       (0xF << MME0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_SHIFT))
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_PQF_ERR_MSG_EN_MASK, 0xF)) | \
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_CQF_ERR_MSG_EN_MASK, 0x1F)) | \
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_CP_ERR_MSG_EN_MASK, 0x1F)))
 
 #define MME_QMAN_GLBL_ERR_CFG_STOP_ON_ERR_EN_MASK      (\
-       (0xF << MME0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_SHIFT) | \
-       (0x1F << MME0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_SHIFT))
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_PQF_STOP_ON_ERR_MASK, 0xF)) | \
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_CQF_STOP_ON_ERR_MASK, 0x1F)) | \
+       (FIELD_PREP(MME0_QM_GLBL_ERR_CFG_CP_STOP_ON_ERR_MASK, 0x1F)))
 
-#define QMAN_CGM1_PWR_GATE_EN  (0xA << DMA0_QM_CGM_CFG1_MASK_TH_SHIFT)
+#define QMAN_CGM1_PWR_GATE_EN  (FIELD_PREP(DMA0_QM_CGM_CFG1_MASK_TH_MASK, 0xA))
 
 /* RESET registers configuration */
-#define CFG_RST_L_PSOC_SHIFT           0
-#define CFG_RST_L_PCIE_SHIFT           1
-#define CFG_RST_L_PCIE_IF_SHIFT                2
-#define CFG_RST_L_HBM_S_PLL_SHIFT      3
-#define CFG_RST_L_TPC_S_PLL_SHIFT      4
-#define CFG_RST_L_MME_S_PLL_SHIFT      5
-#define CFG_RST_L_CPU_PLL_SHIFT                6
-#define CFG_RST_L_PCIE_PLL_SHIFT       7
-#define CFG_RST_L_NIC_S_PLL_SHIFT      8
-#define CFG_RST_L_HBM_N_PLL_SHIFT      9
-#define CFG_RST_L_TPC_N_PLL_SHIFT      10
-#define CFG_RST_L_MME_N_PLL_SHIFT      11
-#define CFG_RST_L_NIC_N_PLL_SHIFT      12
-#define CFG_RST_L_DMA_W_PLL_SHIFT      13
-#define CFG_RST_L_SIF_W_PLL_SHIFT      14
-#define CFG_RST_L_MESH_W_PLL_SHIFT     15
-#define CFG_RST_L_SRAM_W_PLL_SHIFT     16
-#define CFG_RST_L_DMA_E_PLL_SHIFT      17
-#define CFG_RST_L_SIF_E_PLL_SHIFT      18
-#define CFG_RST_L_MESH_E_PLL_SHIFT     19
-#define CFG_RST_L_SRAM_E_PLL_SHIFT     20
-#define CFG_RST_L_IF_1_SHIFT           21
-#define CFG_RST_L_IF_0_SHIFT           22
-#define CFG_RST_L_IF_2_SHIFT           23
-#define CFG_RST_L_IF_3_SHIFT           24
-#define CFG_RST_L_TPC_0_SHIFT          25
-#define CFG_RST_L_TPC_1_SHIFT          26
-#define CFG_RST_L_TPC_2_SHIFT          27
-#define CFG_RST_L_TPC_3_SHIFT          28
-#define CFG_RST_L_TPC_4_SHIFT          29
-#define CFG_RST_L_TPC_5_SHIFT          30
-#define CFG_RST_L_TPC_6_SHIFT          31
-#define CFG_RST_H_TPC_7_SHIFT          0
-#define CFG_RST_H_MME_0_SHIFT          1
-#define CFG_RST_H_MME_1_SHIFT          2
-#define CFG_RST_H_MME_2_SHIFT          3
-#define CFG_RST_H_MME_3_SHIFT          4
-#define CFG_RST_H_HBM_0_SHIFT          5
-#define CFG_RST_H_HBM_1_SHIFT          6
-#define CFG_RST_H_HBM_2_SHIFT          7
-#define CFG_RST_H_HBM_3_SHIFT          8
-#define CFG_RST_H_NIC_0_SHIFT          9
-#define CFG_RST_H_NIC_1_SHIFT          10
-#define CFG_RST_H_NIC_2_SHIFT          11
-#define CFG_RST_H_NIC_3_SHIFT          12
-#define CFG_RST_H_NIC_4_SHIFT          13
-#define CFG_RST_H_SM_0_SHIFT           14
-#define CFG_RST_H_SM_1_SHIFT           15
-#define CFG_RST_H_SM_2_SHIFT           16
-#define CFG_RST_H_SM_3_SHIFT           17
-#define CFG_RST_H_DMA_0_SHIFT          18
-#define CFG_RST_H_DMA_1_SHIFT          19
-#define CFG_RST_H_CPU_SHIFT            20
-#define CFG_RST_H_MMU_SHIFT            21
-
-
-#define CFG_RST_H_DMA_MASK             ((1 << CFG_RST_H_DMA_0_SHIFT) | \
-                                       (1 << CFG_RST_H_DMA_1_SHIFT))
-
-#define CFG_RST_H_CPU_MASK             (1 << CFG_RST_H_CPU_SHIFT)
-#define CFG_RST_H_MMU_MASK             (1 << CFG_RST_H_MMU_SHIFT)
-
-#define CFG_RST_H_HBM_MASK             ((1 << CFG_RST_H_HBM_0_SHIFT) | \
-                                       (1 << CFG_RST_H_HBM_1_SHIFT) | \
-                                       (1 << CFG_RST_H_HBM_2_SHIFT) | \
-                                       (1 << CFG_RST_H_HBM_3_SHIFT))
-
-#define CFG_RST_H_NIC_MASK             ((1 << CFG_RST_H_NIC_0_SHIFT) | \
-                                       (1 << CFG_RST_H_NIC_1_SHIFT) | \
-                                       (1 << CFG_RST_H_NIC_2_SHIFT) | \
-                                       (1 << CFG_RST_H_NIC_3_SHIFT) | \
-                                       (1 << CFG_RST_H_NIC_4_SHIFT))
-
-#define CFG_RST_H_SM_MASK              ((1 << CFG_RST_H_SM_0_SHIFT) | \
-                                       (1 << CFG_RST_H_SM_1_SHIFT) | \
-                                       (1 << CFG_RST_H_SM_2_SHIFT) | \
-                                       (1 << CFG_RST_H_SM_3_SHIFT))
-
-#define CFG_RST_H_MME_MASK             ((1 << CFG_RST_H_MME_0_SHIFT) | \
-                                       (1 << CFG_RST_H_MME_1_SHIFT) | \
-                                       (1 << CFG_RST_H_MME_2_SHIFT) | \
-                                       (1 << CFG_RST_H_MME_3_SHIFT))
-
-#define CFG_RST_L_PSOC_MASK            (1 << CFG_RST_L_PSOC_SHIFT)
-
-#define CFG_RST_L_IF_MASK              ((1 << CFG_RST_L_IF_0_SHIFT) | \
-                                       (1 << CFG_RST_L_IF_1_SHIFT) | \
-                                       (1 << CFG_RST_L_IF_2_SHIFT) | \
-                                       (1 << CFG_RST_L_IF_3_SHIFT))
-
-#define CFG_RST_L_TPC_MASK             ((1 << CFG_RST_L_TPC_0_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_1_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_2_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_3_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_4_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_5_SHIFT) | \
-                                       (1 << CFG_RST_L_TPC_6_SHIFT))
-
-#define CFG_RST_H_TPC_MASK             (1 << CFG_RST_H_TPC_7_SHIFT)
-
-#define CA53_RESET                     (1 << CFG_RST_H_CPU_SHIFT)
+#define CFG_RST_L_PSOC_MASK            BIT_MASK(0)
+#define CFG_RST_L_PCIE_MASK            BIT_MASK(1)
+#define CFG_RST_L_PCIE_IF_MASK         BIT_MASK(2)
+#define CFG_RST_L_HBM_S_PLL_MASK       BIT_MASK(3)
+#define CFG_RST_L_TPC_S_PLL_MASK       BIT_MASK(4)
+#define CFG_RST_L_MME_S_PLL_MASK       BIT_MASK(5)
+#define CFG_RST_L_CPU_PLL_MASK         BIT_MASK(6)
+#define CFG_RST_L_PCIE_PLL_MASK                BIT_MASK(7)
+#define CFG_RST_L_NIC_S_PLL_MASK       BIT_MASK(8)
+#define CFG_RST_L_HBM_N_PLL_MASK       BIT_MASK(9)
+#define CFG_RST_L_TPC_N_PLL_MASK       BIT_MASK(10)
+#define CFG_RST_L_MME_N_PLL_MASK       BIT_MASK(11)
+#define CFG_RST_L_NIC_N_PLL_MASK       BIT_MASK(12)
+#define CFG_RST_L_DMA_W_PLL_MASK       BIT_MASK(13)
+#define CFG_RST_L_SIF_W_PLL_MASK       BIT_MASK(14)
+#define CFG_RST_L_MESH_W_PLL_MASK      BIT_MASK(15)
+#define CFG_RST_L_SRAM_W_PLL_MASK      BIT_MASK(16)
+#define CFG_RST_L_DMA_E_PLL_MASK       BIT_MASK(17)
+#define CFG_RST_L_SIF_E_PLL_MASK       BIT_MASK(18)
+#define CFG_RST_L_MESH_E_PLL_MASK      BIT_MASK(19)
+#define CFG_RST_L_SRAM_E_PLL_MASK      BIT_MASK(20)
+
+#define CFG_RST_L_IF_1_MASK            BIT_MASK(21)
+#define CFG_RST_L_IF_0_MASK            BIT_MASK(22)
+#define CFG_RST_L_IF_2_MASK            BIT_MASK(23)
+#define CFG_RST_L_IF_3_MASK            BIT_MASK(24)
+#define CFG_RST_L_IF_MASK              GENMASK(24, 21)
+
+#define CFG_RST_L_TPC_0_MASK           BIT_MASK(25)
+#define CFG_RST_L_TPC_1_MASK           BIT_MASK(26)
+#define CFG_RST_L_TPC_2_MASK           BIT_MASK(27)
+#define CFG_RST_L_TPC_3_MASK           BIT_MASK(28)
+#define CFG_RST_L_TPC_4_MASK           BIT_MASK(29)
+#define CFG_RST_L_TPC_5_MASK           BIT_MASK(30)
+#define CFG_RST_L_TPC_6_MASK           BIT_MASK(31)
+#define CFG_RST_L_TPC_MASK             GENMASK(31, 25)
+
+#define CFG_RST_H_TPC_7_MASK           BIT_MASK(0)
+
+#define CFG_RST_H_MME_0_MASK           BIT_MASK(1)
+#define CFG_RST_H_MME_1_MASK           BIT_MASK(2)
+#define CFG_RST_H_MME_2_MASK           BIT_MASK(3)
+#define CFG_RST_H_MME_3_MASK           BIT_MASK(4)
+#define CFG_RST_H_MME_MASK             GENMASK(4, 1)
+
+#define CFG_RST_H_HBM_0_MASK           BIT_MASK(5)
+#define CFG_RST_H_HBM_1_MASK           BIT_MASK(6)
+#define CFG_RST_H_HBM_2_MASK           BIT_MASK(7)
+#define CFG_RST_H_HBM_3_MASK           BIT_MASK(8)
+#define CFG_RST_H_HBM_MASK             GENMASK(8, 5)
+
+#define CFG_RST_H_NIC_0_MASK           BIT_MASK(9)
+#define CFG_RST_H_NIC_1_MASK           BIT_MASK(10)
+#define CFG_RST_H_NIC_2_MASK           BIT_MASK(11)
+#define CFG_RST_H_NIC_3_MASK           BIT_MASK(12)
+#define CFG_RST_H_NIC_4_MASK           BIT_MASK(13)
+#define CFG_RST_H_NIC_MASK             GENMASK(13, 9)
+
+#define CFG_RST_H_SM_0_MASK            BIT_MASK(14)
+#define CFG_RST_H_SM_1_MASK            BIT_MASK(15)
+#define CFG_RST_H_SM_2_MASK            BIT_MASK(16)
+#define CFG_RST_H_SM_3_MASK            BIT_MASK(17)
+#define CFG_RST_H_SM_MASK              GENMASK(17, 14)
+
+#define CFG_RST_H_DMA_0_MASK           BIT_MASK(18)
+#define CFG_RST_H_DMA_1_MASK           BIT_MASK(19)
+#define CFG_RST_H_DMA_MASK             GENMASK(19, 18)
+
+#define CFG_RST_H_CPU_MASK             BIT_MASK(20)
+#define CFG_RST_H_MMU_MASK             BIT_MASK(21)
 
 #define UNIT_RST_L_PSOC_SHIFT          0
 #define UNIT_RST_L_PCIE_SHIFT          1
@@ -378,15 +347,15 @@ enum axi_id {
        ((((y) & RAZWI_INITIATOR_Y_MASK) << RAZWI_INITIATOR_Y_SHIFT) | \
                (((x) & RAZWI_INITIATOR_X_MASK) << RAZWI_INITIATOR_X_SHIFT))
 
-#define RAZWI_INITIATOR_ID_X_Y_TPC0_NIC0       RAZWI_INITIATOR_ID_X_Y(1, 0)
-#define RAZWI_INITIATOR_ID_X_Y_TPC1            RAZWI_INITIATOR_ID_X_Y(2, 0)
-#define RAZWI_INITIATOR_ID_X_Y_MME0_0          RAZWI_INITIATOR_ID_X_Y(3, 0)
-#define RAZWI_INITIATOR_ID_X_Y_MME0_1          RAZWI_INITIATOR_ID_X_Y(4, 0)
-#define RAZWI_INITIATOR_ID_X_Y_MME1_0          RAZWI_INITIATOR_ID_X_Y(5, 0)
-#define RAZWI_INITIATOR_ID_X_Y_MME1_1          RAZWI_INITIATOR_ID_X_Y(6, 0)
-#define RAZWI_INITIATOR_ID_X_Y_TPC2            RAZWI_INITIATOR_ID_X_Y(7, 0)
+#define RAZWI_INITIATOR_ID_X_Y_TPC0_NIC0       RAZWI_INITIATOR_ID_X_Y(1, 1)
+#define RAZWI_INITIATOR_ID_X_Y_TPC1            RAZWI_INITIATOR_ID_X_Y(2, 1)
+#define RAZWI_INITIATOR_ID_X_Y_MME0_0          RAZWI_INITIATOR_ID_X_Y(3, 1)
+#define RAZWI_INITIATOR_ID_X_Y_MME0_1          RAZWI_INITIATOR_ID_X_Y(4, 1)
+#define RAZWI_INITIATOR_ID_X_Y_MME1_0          RAZWI_INITIATOR_ID_X_Y(5, 1)
+#define RAZWI_INITIATOR_ID_X_Y_MME1_1          RAZWI_INITIATOR_ID_X_Y(6, 1)
+#define RAZWI_INITIATOR_ID_X_Y_TPC2            RAZWI_INITIATOR_ID_X_Y(7, 1)
 #define RAZWI_INITIATOR_ID_X_Y_TPC3_PCI_CPU_PSOC \
-                                               RAZWI_INITIATOR_ID_X_Y(8, 0)
+                                               RAZWI_INITIATOR_ID_X_Y(8, 1)
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_W_S_0    RAZWI_INITIATOR_ID_X_Y(0, 1)
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_E_S_0    RAZWI_INITIATOR_ID_X_Y(9, 1)
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_W_S_1    RAZWI_INITIATOR_ID_X_Y(0, 2)
@@ -395,14 +364,14 @@ enum axi_id {
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_E_N_0    RAZWI_INITIATOR_ID_X_Y(9, 3)
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_W_N_1    RAZWI_INITIATOR_ID_X_Y(0, 4)
 #define RAZWI_INITIATOR_ID_X_Y_DMA_IF_E_N_1    RAZWI_INITIATOR_ID_X_Y(9, 4)
-#define RAZWI_INITIATOR_ID_X_Y_TPC4_NIC1_NIC2  RAZWI_INITIATOR_ID_X_Y(1, 5)
-#define RAZWI_INITIATOR_ID_X_Y_TPC5            RAZWI_INITIATOR_ID_X_Y(2, 5)
-#define RAZWI_INITIATOR_ID_X_Y_MME2_0          RAZWI_INITIATOR_ID_X_Y(3, 5)
-#define RAZWI_INITIATOR_ID_X_Y_MME2_1          RAZWI_INITIATOR_ID_X_Y(4, 5)
-#define RAZWI_INITIATOR_ID_X_Y_MME3_0          RAZWI_INITIATOR_ID_X_Y(5, 5)
-#define RAZWI_INITIATOR_ID_X_Y_MME3_1          RAZWI_INITIATOR_ID_X_Y(6, 5)
-#define RAZWI_INITIATOR_ID_X_Y_TPC6            RAZWI_INITIATOR_ID_X_Y(7, 5)
-#define RAZWI_INITIATOR_ID_X_Y_TPC7_NIC4_NIC5  RAZWI_INITIATOR_ID_X_Y(8, 5)
+#define RAZWI_INITIATOR_ID_X_Y_TPC4_NIC1_NIC2  RAZWI_INITIATOR_ID_X_Y(1, 6)
+#define RAZWI_INITIATOR_ID_X_Y_TPC5            RAZWI_INITIATOR_ID_X_Y(2, 6)
+#define RAZWI_INITIATOR_ID_X_Y_MME2_0          RAZWI_INITIATOR_ID_X_Y(3, 6)
+#define RAZWI_INITIATOR_ID_X_Y_MME2_1          RAZWI_INITIATOR_ID_X_Y(4, 6)
+#define RAZWI_INITIATOR_ID_X_Y_MME3_0          RAZWI_INITIATOR_ID_X_Y(5, 6)
+#define RAZWI_INITIATOR_ID_X_Y_MME3_1          RAZWI_INITIATOR_ID_X_Y(6, 6)
+#define RAZWI_INITIATOR_ID_X_Y_TPC6            RAZWI_INITIATOR_ID_X_Y(7, 6)
+#define RAZWI_INITIATOR_ID_X_Y_TPC7_NIC4_NIC5  RAZWI_INITIATOR_ID_X_Y(8, 6)
 
 #define PSOC_ETR_AXICTL_PROTCTRLBIT1_SHIFT                           1
 
index f25c60a..977fb34 100644 (file)
@@ -12,6 +12,7 @@
  * PSOC scratch-pad registers
  */
 #define mmHW_STATE                     mmPSOC_GLOBAL_CONF_SCRATCHPAD_0
+#define mmFUSE_VER_OFFSET              mmPSOC_GLOBAL_CONF_SCRATCHPAD_22
 #define mmCPU_CMD_STATUS_TO_HOST       mmPSOC_GLOBAL_CONF_SCRATCHPAD_23
 #define mmCPU_BOOT_ERR0                        mmPSOC_GLOBAL_CONF_SCRATCHPAD_24
 #define mmCPU_BOOT_ERR1                        mmPSOC_GLOBAL_CONF_SCRATCHPAD_25
index 0195f62..e561242 100644 (file)
@@ -22,6 +22,7 @@
 #define mmCPU_CQ_BASE_ADDR_LOW         mmPSOC_GLOBAL_CONF_SCRATCHPAD_8
 #define mmCPU_CQ_BASE_ADDR_HIGH                mmPSOC_GLOBAL_CONF_SCRATCHPAD_9
 #define mmCPU_CQ_LENGTH                        mmPSOC_GLOBAL_CONF_SCRATCHPAD_10
+#define mmFUSE_VER_OFFSET              mmPSOC_GLOBAL_CONF_SCRATCHPAD_22
 #define mmCPU_CMD_STATUS_TO_HOST       mmPSOC_GLOBAL_CONF_SCRATCHPAD_23
 #define mmCPU_BOOT_ERR0                        mmPSOC_GLOBAL_CONF_SCRATCHPAD_24
 #define mmCPU_BOOT_ERR1                        mmPSOC_GLOBAL_CONF_SCRATCHPAD_25
index 468bb04..dedf20e 100644 (file)
@@ -29,6 +29,8 @@
 #define HOP3_SHIFT                     21
 #define HOP4_SHIFT                     12
 
+#define MMU_ARCH_5_HOPS                        5
+
 #define HOP_PHYS_ADDR_MASK             (~FLAGS_MASK)
 
 #define HL_PTE_SIZE                    sizeof(u64)
diff --git a/drivers/misc/hisi_hikey_usb.c b/drivers/misc/hisi_hikey_usb.c
new file mode 100644 (file)
index 0000000..cc93569
--- /dev/null
@@ -0,0 +1,273 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Support for usb functionality of Hikey series boards
+ * based on Hisilicon Kirin Soc.
+ *
+ * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd.
+ *             http://www.huawei.com
+ *
+ * Authors: Yu Chen <chenyu56@huawei.com>
+ */
+
+#include <linux/gpio/consumer.h>
+#include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/notifier.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/regulator/consumer.h>
+#include <linux/slab.h>
+#include <linux/usb/role.h>
+
+#define DEVICE_DRIVER_NAME "hisi_hikey_usb"
+
+#define HUB_VBUS_POWER_ON 1
+#define HUB_VBUS_POWER_OFF 0
+#define USB_SWITCH_TO_HUB 1
+#define USB_SWITCH_TO_TYPEC 0
+#define TYPEC_VBUS_POWER_ON 1
+#define TYPEC_VBUS_POWER_OFF 0
+
+struct hisi_hikey_usb {
+       struct device *dev;
+       struct gpio_desc *otg_switch;
+       struct gpio_desc *typec_vbus;
+       struct gpio_desc *hub_vbus;
+       struct gpio_desc *reset;
+
+       struct regulator *regulator;
+
+       struct usb_role_switch *hub_role_sw;
+
+       struct usb_role_switch *dev_role_sw;
+       enum usb_role role;
+
+       struct mutex lock;
+       struct work_struct work;
+
+       struct notifier_block nb;
+};
+
+static void hub_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb, int value)
+{
+       int ret, status;
+
+       if (hisi_hikey_usb->hub_vbus)
+               gpiod_set_value_cansleep(hisi_hikey_usb->hub_vbus, value);
+
+       if (!hisi_hikey_usb->regulator)
+               return;
+
+       status = regulator_is_enabled(hisi_hikey_usb->regulator);
+       if (status == !!value)
+               return;
+
+       if (value)
+               ret = regulator_enable(hisi_hikey_usb->regulator);
+       else
+               ret = regulator_disable(hisi_hikey_usb->regulator);
+
+       if (ret)
+               dev_err(hisi_hikey_usb->dev,
+                       "Can't switch regulator state to %s\n",
+                       value ? "enabled" : "disabled");
+}
+
+static void usb_switch_ctrl(struct hisi_hikey_usb *hisi_hikey_usb,
+                           int switch_to)
+{
+       if (!hisi_hikey_usb->otg_switch)
+               return;
+
+       gpiod_set_value_cansleep(hisi_hikey_usb->otg_switch, switch_to);
+}
+
+static void usb_typec_power_ctrl(struct hisi_hikey_usb *hisi_hikey_usb,
+                                int value)
+{
+       if (!hisi_hikey_usb->typec_vbus)
+               return;
+
+       gpiod_set_value_cansleep(hisi_hikey_usb->typec_vbus, value);
+}
+
+static void relay_set_role_switch(struct work_struct *work)
+{
+       struct hisi_hikey_usb *hisi_hikey_usb = container_of(work,
+                                                       struct hisi_hikey_usb,
+                                                       work);
+       struct usb_role_switch *sw;
+       enum usb_role role;
+
+       if (!hisi_hikey_usb || !hisi_hikey_usb->dev_role_sw)
+               return;
+
+       mutex_lock(&hisi_hikey_usb->lock);
+       switch (hisi_hikey_usb->role) {
+       case USB_ROLE_NONE:
+               usb_typec_power_ctrl(hisi_hikey_usb, TYPEC_VBUS_POWER_OFF);
+               usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_HUB);
+               hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_ON);
+               break;
+       case USB_ROLE_HOST:
+               hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_OFF);
+               usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_TYPEC);
+               usb_typec_power_ctrl(hisi_hikey_usb, TYPEC_VBUS_POWER_ON);
+               break;
+       case USB_ROLE_DEVICE:
+               hub_power_ctrl(hisi_hikey_usb, HUB_VBUS_POWER_OFF);
+               usb_typec_power_ctrl(hisi_hikey_usb, TYPEC_VBUS_POWER_OFF);
+               usb_switch_ctrl(hisi_hikey_usb, USB_SWITCH_TO_TYPEC);
+               break;
+       default:
+               break;
+       }
+       sw = hisi_hikey_usb->dev_role_sw;
+       role = hisi_hikey_usb->role;
+       mutex_unlock(&hisi_hikey_usb->lock);
+
+       usb_role_switch_set_role(sw, role);
+}
+
+static int hub_usb_role_switch_set(struct usb_role_switch *sw, enum usb_role role)
+{
+       struct hisi_hikey_usb *hisi_hikey_usb = usb_role_switch_get_drvdata(sw);
+
+       if (!hisi_hikey_usb || !hisi_hikey_usb->dev_role_sw)
+               return -EINVAL;
+
+       mutex_lock(&hisi_hikey_usb->lock);
+       hisi_hikey_usb->role = role;
+       mutex_unlock(&hisi_hikey_usb->lock);
+
+       schedule_work(&hisi_hikey_usb->work);
+
+       return 0;
+}
+
+static int hisi_hikey_usb_parse_kirin970(struct platform_device *pdev,
+                                        struct hisi_hikey_usb *hisi_hikey_usb)
+{
+       struct regulator *regulator;
+
+       regulator = devm_regulator_get(&pdev->dev, "hub-vdd");
+       if (IS_ERR(regulator)) {
+               if (PTR_ERR(regulator) == -EPROBE_DEFER) {
+                       dev_info(&pdev->dev,
+                                "waiting for hub-vdd-supply to be probed\n");
+                       return PTR_ERR(regulator);
+               }
+               dev_err(&pdev->dev,
+                       "get hub-vdd-supply failed with error %ld\n",
+                       PTR_ERR(regulator));
+               return PTR_ERR(regulator);
+       }
+       hisi_hikey_usb->regulator = regulator;
+
+       hisi_hikey_usb->reset = devm_gpiod_get(&pdev->dev, "hub_reset_en_gpio",
+                                              GPIOD_OUT_HIGH);
+       if (IS_ERR(hisi_hikey_usb->reset))
+               return PTR_ERR(hisi_hikey_usb->reset);
+
+       return 0;
+}
+
+static int hisi_hikey_usb_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct hisi_hikey_usb *hisi_hikey_usb;
+       struct usb_role_switch_desc hub_role_switch = {NULL};
+       int ret;
+
+       hisi_hikey_usb = devm_kzalloc(dev, sizeof(*hisi_hikey_usb), GFP_KERNEL);
+       if (!hisi_hikey_usb)
+               return -ENOMEM;
+
+       hisi_hikey_usb->dev = &pdev->dev;
+
+       hisi_hikey_usb->otg_switch = devm_gpiod_get(dev, "otg-switch",
+                                                   GPIOD_OUT_HIGH);
+       if (IS_ERR(hisi_hikey_usb->otg_switch))
+               return PTR_ERR(hisi_hikey_usb->otg_switch);
+
+       hisi_hikey_usb->typec_vbus = devm_gpiod_get(dev, "typec-vbus",
+                                                   GPIOD_OUT_LOW);
+       if (IS_ERR(hisi_hikey_usb->typec_vbus))
+               return PTR_ERR(hisi_hikey_usb->typec_vbus);
+
+       /* Parse Kirin 970-specific OF data */
+       if (of_device_is_compatible(pdev->dev.of_node,
+                                   "hisilicon,kirin970_hikey_usbhub")) {
+               ret = hisi_hikey_usb_parse_kirin970(pdev, hisi_hikey_usb);
+               if (ret)
+                       return ret;
+       } else {
+               /* hub-vdd33-en is optional */
+               hisi_hikey_usb->hub_vbus = devm_gpiod_get_optional(dev, "hub-vdd33-en",
+                                                                  GPIOD_OUT_HIGH);
+               if (IS_ERR(hisi_hikey_usb->hub_vbus))
+                       return PTR_ERR(hisi_hikey_usb->hub_vbus);
+       }
+
+       hisi_hikey_usb->dev_role_sw = usb_role_switch_get(dev);
+       if (!hisi_hikey_usb->dev_role_sw)
+               return -EPROBE_DEFER;
+       if (IS_ERR(hisi_hikey_usb->dev_role_sw))
+               return PTR_ERR(hisi_hikey_usb->dev_role_sw);
+
+       INIT_WORK(&hisi_hikey_usb->work, relay_set_role_switch);
+       mutex_init(&hisi_hikey_usb->lock);
+
+       hub_role_switch.fwnode = dev_fwnode(dev);
+       hub_role_switch.set = hub_usb_role_switch_set;
+       hub_role_switch.driver_data = hisi_hikey_usb;
+
+       hisi_hikey_usb->hub_role_sw = usb_role_switch_register(dev,
+                                                              &hub_role_switch);
+
+       if (IS_ERR(hisi_hikey_usb->hub_role_sw)) {
+               usb_role_switch_put(hisi_hikey_usb->dev_role_sw);
+               return PTR_ERR(hisi_hikey_usb->hub_role_sw);
+       }
+
+       platform_set_drvdata(pdev, hisi_hikey_usb);
+
+       return 0;
+}
+
+static int  hisi_hikey_usb_remove(struct platform_device *pdev)
+{
+       struct hisi_hikey_usb *hisi_hikey_usb = platform_get_drvdata(pdev);
+
+       if (hisi_hikey_usb->hub_role_sw)
+               usb_role_switch_unregister(hisi_hikey_usb->hub_role_sw);
+
+       if (hisi_hikey_usb->dev_role_sw)
+               usb_role_switch_put(hisi_hikey_usb->dev_role_sw);
+
+       return 0;
+}
+
+static const struct of_device_id id_table_hisi_hikey_usb[] = {
+       { .compatible = "hisilicon,gpio_hubv1" },
+       { .compatible = "hisilicon,kirin970_hikey_usbhub" },
+       {}
+};
+MODULE_DEVICE_TABLE(of, id_table_hisi_hikey_usb);
+
+static struct platform_driver hisi_hikey_usb_driver = {
+       .probe = hisi_hikey_usb_probe,
+       .remove = hisi_hikey_usb_remove,
+       .driver = {
+               .name = DEVICE_DRIVER_NAME,
+               .of_match_table = id_table_hisi_hikey_usb,
+       },
+};
+
+module_platform_driver(hisi_hikey_usb_driver);
+
+MODULE_AUTHOR("Yu Chen <chenyu56@huawei.com>");
+MODULE_DESCRIPTION("Driver Support for USB functionality of Hikey");
+MODULE_LICENSE("GPL v2");
index f5fd5b7..c06581f 100644 (file)
@@ -46,4 +46,14 @@ config INTEL_MEI_TXE
          Supported SoCs:
          Intel Bay Trail
 
+config INTEL_MEI_VIRTIO
+       tristate "Intel MEI interface emulation with virtio framework"
+       select INTEL_MEI
+       depends on X86 && PCI && VIRTIO_PCI
+       help
+         This module implements mei hw emulation over virtio transport.
+         The module will be called mei_virtio.
+         Enable this if your virtual machine supports virtual mei
+         device over virtio.
+
 source "drivers/misc/mei/hdcp/Kconfig"
index f1c76f7..52aefaa 100644 (file)
@@ -22,6 +22,9 @@ obj-$(CONFIG_INTEL_MEI_TXE) += mei-txe.o
 mei-txe-objs := pci-txe.o
 mei-txe-objs += hw-txe.o
 
+obj-$(CONFIG_INTEL_MEI_VIRTIO) += mei-virtio.o
+mei-virtio-objs := hw-virtio.o
+
 mei-$(CONFIG_EVENT_TRACING) += mei-trace.o
 CFLAGS_mei-trace.o = -I$(src)
 
index 07ba16d..4e30fa9 100644 (file)
@@ -463,6 +463,17 @@ out:
        dev_dbg(bus->dev, "end of fixup match = %d\n", cldev->do_match);
 }
 
+/**
+ * vt_support - enable on bus clients with vtag support
+ *
+ * @cldev: me clients device
+ */
+static void vt_support(struct mei_cl_device *cldev)
+{
+       if (cldev->me_cl->props.vt_supported == 1)
+               cldev->do_match = 1;
+}
+
 #define MEI_FIXUP(_uuid, _hook) { _uuid, _hook }
 
 static struct mei_fixup {
@@ -476,6 +487,7 @@ static struct mei_fixup {
        MEI_FIXUP(MEI_UUID_WD, mei_wd),
        MEI_FIXUP(MEI_UUID_MKHIF_FIX, mei_mkhi_fix),
        MEI_FIXUP(MEI_UUID_HDCP, whitelist),
+       MEI_FIXUP(MEI_UUID_ANY, vt_support),
 };
 
 /**
index a6dfc3c..9cdaa7f 100644 (file)
@@ -152,7 +152,7 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length,
                if (timeout) {
                        rets = wait_event_interruptible_timeout
                                        (cl->rx_wait,
-                                       (!list_empty(&cl->rd_completed)) ||
+                                       mei_cl_read_cb(cl, NULL) ||
                                        (!mei_cl_is_connected(cl)),
                                        msecs_to_jiffies(timeout));
                        if (rets == 0)
@@ -165,7 +165,7 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length,
                } else {
                        if (wait_event_interruptible
                                        (cl->rx_wait,
-                                       (!list_empty(&cl->rd_completed)) ||
+                                       mei_cl_read_cb(cl, NULL) ||
                                        (!mei_cl_is_connected(cl)))) {
                                if (signal_pending(current))
                                        return -EINTR;
@@ -198,7 +198,7 @@ copy:
        rets = r_length;
 
 free:
-       mei_io_cb_free(cb);
+       mei_cl_del_rd_completed(cl, cb);
 out:
        mutex_unlock(&bus->device_lock);
 
@@ -495,6 +495,68 @@ static void mei_cl_bus_module_put(struct mei_cl_device *cldev)
        module_put(cldev->bus->dev->driver->owner);
 }
 
+/**
+ * mei_cl_bus_vtag - get bus vtag entry wrapper
+ *     The tag for bus client is always first.
+ *
+ * @cl: host client
+ *
+ * Return: bus vtag or NULL
+ */
+static inline struct mei_cl_vtag *mei_cl_bus_vtag(struct mei_cl *cl)
+{
+       return list_first_entry_or_null(&cl->vtag_map,
+                                       struct mei_cl_vtag, list);
+}
+
+/**
+ * mei_cl_bus_vtag_alloc - add bus client entry to vtag map
+ *
+ * @cldev: me client device
+ *
+ * Return:
+ * * 0 on success
+ * * -ENOMEM if memory allocation failed
+ */
+static int mei_cl_bus_vtag_alloc(struct mei_cl_device *cldev)
+{
+       struct mei_cl *cl = cldev->cl;
+       struct mei_cl_vtag *cl_vtag;
+
+       /*
+        * Bail out if the client does not supports vtags
+        * or has already allocated one
+        */
+       if (mei_cl_vt_support_check(cl) || mei_cl_bus_vtag(cl))
+               return 0;
+
+       cl_vtag = mei_cl_vtag_alloc(NULL, 0);
+       if (IS_ERR(cl_vtag))
+               return -ENOMEM;
+
+       list_add_tail(&cl_vtag->list, &cl->vtag_map);
+
+       return 0;
+}
+
+/**
+ * mei_cl_bus_vtag_free - remove the bus entry from vtag map
+ *
+ * @cldev: me client device
+ */
+static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)
+{
+       struct mei_cl *cl = cldev->cl;
+       struct mei_cl_vtag *cl_vtag;
+
+       cl_vtag = mei_cl_bus_vtag(cl);
+       if (!cl_vtag)
+               return;
+
+       list_del(&cl_vtag->list);
+       kfree(cl_vtag);
+}
+
 /**
  * mei_cldev_enable - enable me client device
  *     create connection with me client
@@ -531,9 +593,15 @@ int mei_cldev_enable(struct mei_cl_device *cldev)
                goto out;
        }
 
+       ret = mei_cl_bus_vtag_alloc(cldev);
+       if (ret)
+               goto out;
+
        ret = mei_cl_connect(cl, cldev->me_cl, NULL);
-       if (ret < 0)
+       if (ret < 0) {
                dev_err(&cldev->dev, "cannot connect\n");
+               mei_cl_bus_vtag_free(cldev);
+       }
 
 out:
        mutex_unlock(&bus->device_lock);
@@ -586,6 +654,8 @@ int mei_cldev_disable(struct mei_cl_device *cldev)
 
        mutex_lock(&bus->device_lock);
 
+       mei_cl_bus_vtag_free(cldev);
+
        if (!mei_cl_is_connected(cl)) {
                dev_dbg(bus->dev, "Already disconnected\n");
                err = 0;
@@ -810,6 +880,16 @@ static ssize_t fixed_show(struct device *dev, struct device_attribute *a,
 }
 static DEVICE_ATTR_RO(fixed);
 
+static ssize_t vtag_show(struct device *dev, struct device_attribute *a,
+                        char *buf)
+{
+       struct mei_cl_device *cldev = to_mei_cl_device(dev);
+       bool vt = mei_me_cl_vt(cldev->me_cl);
+
+       return sprintf(buf, "%d", vt);
+}
+static DEVICE_ATTR_RO(vtag);
+
 static ssize_t max_len_show(struct device *dev, struct device_attribute *a,
                            char *buf)
 {
@@ -827,6 +907,7 @@ static struct attribute *mei_cldev_attrs[] = {
        &dev_attr_modalias.attr,
        &dev_attr_max_conn.attr,
        &dev_attr_fixed.attr,
+       &dev_attr_vtag.attr,
        &dev_attr_max_len.attr,
        NULL,
 };
index 2572887..d5c3f7d 100644 (file)
@@ -354,6 +354,27 @@ static inline void mei_tx_cb_dequeue(struct mei_cl_cb *cb)
        mei_io_cb_free(cb);
 }
 
+/**
+ * mei_cl_set_read_by_fp - set pending_read flag to vtag struct for given fp
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * @cl: mei client
+ * @fp: pointer to file structure
+ */
+static void mei_cl_set_read_by_fp(const struct mei_cl *cl,
+                                 const struct file *fp)
+{
+       struct mei_cl_vtag *cl_vtag;
+
+       list_for_each_entry(cl_vtag, &cl->vtag_map, list) {
+               if (cl_vtag->fp == fp) {
+                       cl_vtag->pending_read = true;
+                       return;
+               }
+       }
+}
+
 /**
  * mei_io_cb_init - allocate and initialize io callback
  *
@@ -378,6 +399,8 @@ static struct mei_cl_cb *mei_io_cb_init(struct mei_cl *cl,
        cb->cl = cl;
        cb->buf_idx = 0;
        cb->fop_type = type;
+       cb->vtag = 0;
+
        return cb;
 }
 
@@ -406,14 +429,16 @@ static void mei_io_list_flush_cl(struct list_head *head,
  *
  * @head: An instance of our list structure
  * @cl: host client
+ * @fp: file pointer (matching cb file object), may be NULL
  */
 static void mei_io_tx_list_free_cl(struct list_head *head,
-                                  const struct mei_cl *cl)
+                                  const struct mei_cl *cl,
+                                  const struct file *fp)
 {
        struct mei_cl_cb *cb, *next;
 
        list_for_each_entry_safe(cb, next, head, list) {
-               if (cl == cb->cl)
+               if (cl == cb->cl && (!fp || fp == cb->fp))
                        mei_tx_cb_dequeue(cb);
        }
 }
@@ -433,6 +458,19 @@ static void mei_io_list_free_fp(struct list_head *head, const struct file *fp)
                        mei_io_cb_free(cb);
 }
 
+/**
+ * mei_cl_free_pending - free pending cb
+ *
+ * @cl: host client
+ */
+static void mei_cl_free_pending(struct mei_cl *cl)
+{
+       struct mei_cl_cb *cb;
+
+       cb = list_first_entry_or_null(&cl->rd_pending, struct mei_cl_cb, list);
+       mei_io_cb_free(cb);
+}
+
 /**
  * mei_cl_alloc_cb - a convenient wrapper for allocating read cb
  *
@@ -505,15 +543,19 @@ struct mei_cl_cb *mei_cl_enqueue_ctrl_wr_cb(struct mei_cl *cl, size_t length,
  *
  * Return: cb on success, NULL if cb is not found
  */
-struct mei_cl_cb *mei_cl_read_cb(const struct mei_cl *cl, const struct file *fp)
+struct mei_cl_cb *mei_cl_read_cb(struct mei_cl *cl, const struct file *fp)
 {
        struct mei_cl_cb *cb;
+       struct mei_cl_cb *ret_cb = NULL;
 
+       spin_lock(&cl->rd_completed_lock);
        list_for_each_entry(cb, &cl->rd_completed, list)
-               if (!fp || fp == cb->fp)
-                       return cb;
-
-       return NULL;
+               if (!fp || fp == cb->fp) {
+                       ret_cb = cb;
+                       break;
+               }
+       spin_unlock(&cl->rd_completed_lock);
+       return ret_cb;
 }
 
 /**
@@ -534,12 +576,17 @@ int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp)
        dev = cl->dev;
 
        cl_dbg(dev, cl, "remove list entry belonging to cl\n");
-       mei_io_tx_list_free_cl(&cl->dev->write_list, cl);
-       mei_io_tx_list_free_cl(&cl->dev->write_waiting_list, cl);
-       mei_io_list_flush_cl(&cl->dev->ctrl_wr_list, cl);
-       mei_io_list_flush_cl(&cl->dev->ctrl_rd_list, cl);
-       mei_io_list_free_fp(&cl->rd_pending, fp);
+       mei_io_tx_list_free_cl(&cl->dev->write_list, cl, fp);
+       mei_io_tx_list_free_cl(&cl->dev->write_waiting_list, cl, fp);
+       /* free pending and control cb only in final flush */
+       if (!fp) {
+               mei_io_list_flush_cl(&cl->dev->ctrl_wr_list, cl);
+               mei_io_list_flush_cl(&cl->dev->ctrl_rd_list, cl);
+               mei_cl_free_pending(cl);
+       }
+       spin_lock(&cl->rd_completed_lock);
        mei_io_list_free_fp(&cl->rd_completed, fp);
+       spin_unlock(&cl->rd_completed_lock);
 
        return 0;
 }
@@ -557,6 +604,8 @@ static void mei_cl_init(struct mei_cl *cl, struct mei_device *dev)
        init_waitqueue_head(&cl->rx_wait);
        init_waitqueue_head(&cl->tx_wait);
        init_waitqueue_head(&cl->ev_wait);
+       INIT_LIST_HEAD(&cl->vtag_map);
+       spin_lock_init(&cl->rd_completed_lock);
        INIT_LIST_HEAD(&cl->rd_completed);
        INIT_LIST_HEAD(&cl->rd_pending);
        INIT_LIST_HEAD(&cl->link);
@@ -752,8 +801,8 @@ static void mei_cl_set_disconnected(struct mei_cl *cl)
                return;
 
        cl->state = MEI_FILE_DISCONNECTED;
-       mei_io_tx_list_free_cl(&dev->write_list, cl);
-       mei_io_tx_list_free_cl(&dev->write_waiting_list, cl);
+       mei_io_tx_list_free_cl(&dev->write_list, cl, NULL);
+       mei_io_tx_list_free_cl(&dev->write_waiting_list, cl, NULL);
        mei_io_list_flush_cl(&dev->ctrl_rd_list, cl);
        mei_io_list_flush_cl(&dev->ctrl_wr_list, cl);
        mei_cl_wake_all(cl);
@@ -1228,6 +1277,157 @@ static int mei_cl_tx_flow_ctrl_creds_reduce(struct mei_cl *cl)
        return 0;
 }
 
+/**
+ * mei_cl_vtag_alloc - allocate and fill the vtag structure
+ *
+ * @fp: pointer to file structure
+ * @vtag: vm tag
+ *
+ * Return:
+ * * Pointer to allocated struct - on success
+ * * ERR_PTR(-ENOMEM) on memory allocation failure
+ */
+struct mei_cl_vtag *mei_cl_vtag_alloc(struct file *fp, u8 vtag)
+{
+       struct mei_cl_vtag *cl_vtag;
+
+       cl_vtag = kzalloc(sizeof(*cl_vtag), GFP_KERNEL);
+       if (!cl_vtag)
+               return ERR_PTR(-ENOMEM);
+
+       INIT_LIST_HEAD(&cl_vtag->list);
+       cl_vtag->vtag = vtag;
+       cl_vtag->fp = fp;
+
+       return cl_vtag;
+}
+
+/**
+ * mei_cl_fp_by_vtag - obtain the file pointer by vtag
+ *
+ * @cl: host client
+ * @vtag: vm tag
+ *
+ * Return:
+ * * A file pointer - on success
+ * * ERR_PTR(-ENOENT) if vtag is not found in the client vtag list
+ */
+const struct file *mei_cl_fp_by_vtag(const struct mei_cl *cl, u8 vtag)
+{
+       struct mei_cl_vtag *vtag_l;
+
+       list_for_each_entry(vtag_l, &cl->vtag_map, list)
+               if (vtag_l->vtag == vtag)
+                       return vtag_l->fp;
+
+       return ERR_PTR(-ENOENT);
+}
+
+/**
+ * mei_cl_reset_read_by_vtag - reset pending_read flag by given vtag
+ *
+ * @cl: host client
+ * @vtag: vm tag
+ */
+static void mei_cl_reset_read_by_vtag(const struct mei_cl *cl, u8 vtag)
+{
+       struct mei_cl_vtag *vtag_l;
+
+       list_for_each_entry(vtag_l, &cl->vtag_map, list) {
+               if (vtag_l->vtag == vtag) {
+                       vtag_l->pending_read = false;
+                       break;
+               }
+       }
+}
+
+/**
+ * mei_cl_read_vtag_add_fc - add flow control for next pending reader
+ *                           in the vtag list
+ *
+ * @cl: host client
+ */
+static void mei_cl_read_vtag_add_fc(struct mei_cl *cl)
+{
+       struct mei_cl_vtag *cl_vtag;
+
+       list_for_each_entry(cl_vtag, &cl->vtag_map, list) {
+               if (cl_vtag->pending_read) {
+                       if (mei_cl_enqueue_ctrl_wr_cb(cl,
+                                                     mei_cl_mtu(cl),
+                                                     MEI_FOP_READ,
+                                                     cl_vtag->fp))
+                               cl->rx_flow_ctrl_creds++;
+                       break;
+               }
+       }
+}
+
+/**
+ * mei_cl_vt_support_check - check if client support vtags
+ *
+ * @cl: host client
+ *
+ * Return:
+ * * 0 - supported, or not connected at all
+ * * -EOPNOTSUPP - vtags are not supported by client
+ */
+int mei_cl_vt_support_check(const struct mei_cl *cl)
+{
+       struct mei_device *dev = cl->dev;
+
+       if (!dev->hbm_f_vt_supported)
+               return -EOPNOTSUPP;
+
+       if (!cl->me_cl)
+               return 0;
+
+       return cl->me_cl->props.vt_supported ? 0 : -EOPNOTSUPP;
+}
+
+/**
+ * mei_cl_add_rd_completed - add read completed callback to list with lock
+ *                           and vtag check
+ *
+ * @cl: host client
+ * @cb: callback block
+ *
+ */
+void mei_cl_add_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb)
+{
+       const struct file *fp;
+
+       if (!mei_cl_vt_support_check(cl)) {
+               fp = mei_cl_fp_by_vtag(cl, cb->vtag);
+               if (IS_ERR(fp)) {
+                       /* client already disconnected, discarding */
+                       mei_io_cb_free(cb);
+                       return;
+               }
+               cb->fp = fp;
+               mei_cl_reset_read_by_vtag(cl, cb->vtag);
+               mei_cl_read_vtag_add_fc(cl);
+       }
+
+       spin_lock(&cl->rd_completed_lock);
+       list_add_tail(&cb->list, &cl->rd_completed);
+       spin_unlock(&cl->rd_completed_lock);
+}
+
+/**
+ * mei_cl_del_rd_completed - free read completed callback with lock
+ *
+ * @cl: host client
+ * @cb: callback block
+ *
+ */
+void mei_cl_del_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb)
+{
+       spin_lock(&cl->rd_completed_lock);
+       mei_io_cb_free(cb);
+       spin_unlock(&cl->rd_completed_lock);
+}
+
 /**
  *  mei_cl_notify_fop2req - convert fop to proper request
  *
@@ -1483,13 +1683,17 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length, const struct file *fp)
                return 0;
 
        /* HW currently supports only one pending read */
-       if (cl->rx_flow_ctrl_creds)
+       if (cl->rx_flow_ctrl_creds) {
+               mei_cl_set_read_by_fp(cl, fp);
                return -EBUSY;
+       }
 
        cb = mei_cl_enqueue_ctrl_wr_cb(cl, length, MEI_FOP_READ, fp);
        if (!cb)
                return -ENOMEM;
 
+       mei_cl_set_read_by_fp(cl, fp);
+
        rets = pm_runtime_get(dev->dev);
        if (rets < 0 && rets != -EINPROGRESS) {
                pm_runtime_put_noidle(dev->dev);
@@ -1518,21 +1722,67 @@ nortpm:
        return rets;
 }
 
+static inline u8 mei_ext_hdr_set_vtag(struct mei_ext_hdr *ext, u8 vtag)
+{
+       ext->type = MEI_EXT_HDR_VTAG;
+       ext->ext_payload[0] = vtag;
+       ext->length = mei_data2slots(sizeof(*ext));
+       return ext->length;
+}
+
 /**
- * mei_msg_hdr_init - initialize mei message header
+ * mei_msg_hdr_init - allocate and initialize mei message header
  *
- * @mei_hdr: mei message header
  * @cb: message callback structure
+ *
+ * Return: a pointer to initialized header
  */
-static void mei_msg_hdr_init(struct mei_msg_hdr *mei_hdr, struct mei_cl_cb *cb)
+static struct mei_msg_hdr *mei_msg_hdr_init(const struct mei_cl_cb *cb)
 {
+       size_t hdr_len;
+       struct mei_ext_meta_hdr *meta;
+       struct mei_ext_hdr *ext;
+       struct mei_msg_hdr *mei_hdr;
+       bool is_ext, is_vtag;
+
+       if (!cb)
+               return ERR_PTR(-EINVAL);
+
+       /* Extended header for vtag is attached only on the first fragment */
+       is_vtag = (cb->vtag && cb->buf_idx == 0);
+       is_ext = is_vtag;
+
+       /* Compute extended header size */
+       hdr_len = sizeof(*mei_hdr);
+
+       if (!is_ext)
+               goto setup_hdr;
+
+       hdr_len += sizeof(*meta);
+       if (is_vtag)
+               hdr_len += sizeof(*ext);
+
+setup_hdr:
+       mei_hdr = kzalloc(hdr_len, GFP_KERNEL);
+       if (!mei_hdr)
+               return ERR_PTR(-ENOMEM);
+
        mei_hdr->host_addr = mei_cl_host_addr(cb->cl);
        mei_hdr->me_addr = mei_cl_me_id(cb->cl);
-       mei_hdr->length = 0;
-       mei_hdr->reserved = 0;
-       mei_hdr->msg_complete = 0;
-       mei_hdr->dma_ring = 0;
        mei_hdr->internal = cb->internal;
+       mei_hdr->extended = is_ext;
+
+       if (!is_ext)
+               goto out;
+
+       meta = (struct mei_ext_meta_hdr *)mei_hdr->extension;
+       if (is_vtag) {
+               meta->count++;
+               meta->size += mei_ext_hdr_set_vtag(meta->hdrs, cb->vtag);
+       }
+out:
+       mei_hdr->length = hdr_len - sizeof(*mei_hdr);
+       return mei_hdr;
 }
 
 /**
@@ -1550,10 +1800,11 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
 {
        struct mei_device *dev;
        struct mei_msg_data *buf;
-       struct mei_msg_hdr mei_hdr;
-       size_t hdr_len = sizeof(mei_hdr);
-       size_t len;
+       struct mei_msg_hdr *mei_hdr = NULL;
+       size_t hdr_len;
        size_t hbuf_len, dr_len;
+       size_t buf_len;
+       size_t data_len;
        int hbuf_slots;
        u32 dr_slots;
        u32 dma_len;
@@ -1579,7 +1830,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
                return 0;
        }
 
-       len = buf->size - cb->buf_idx;
+       buf_len = buf->size - cb->buf_idx;
        data = buf->data + cb->buf_idx;
        hbuf_slots = mei_hbuf_empty_slots(dev);
        if (hbuf_slots < 0) {
@@ -1591,42 +1842,54 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
        dr_slots = mei_dma_ring_empty_slots(dev);
        dr_len = mei_slots2data(dr_slots);
 
-       mei_msg_hdr_init(&mei_hdr, cb);
+       mei_hdr = mei_msg_hdr_init(cb);
+       if (IS_ERR(mei_hdr)) {
+               rets = PTR_ERR(mei_hdr);
+               mei_hdr = NULL;
+               goto err;
+       }
+
+       cl_dbg(dev, cl, "Extended Header %d vtag = %d\n",
+              mei_hdr->extended, cb->vtag);
+
+       hdr_len = sizeof(*mei_hdr) + mei_hdr->length;
 
        /**
         * Split the message only if we can write the whole host buffer
         * otherwise wait for next time the host buffer is empty.
         */
-       if (len + hdr_len <= hbuf_len) {
-               mei_hdr.length = len;
-               mei_hdr.msg_complete = 1;
+       if (hdr_len + buf_len <= hbuf_len) {
+               data_len = buf_len;
+               mei_hdr->msg_complete = 1;
        } else if (dr_slots && hbuf_len >= hdr_len + sizeof(dma_len)) {
-               mei_hdr.dma_ring = 1;
-               if (len > dr_len)
-                       len = dr_len;
+               mei_hdr->dma_ring = 1;
+               if (buf_len > dr_len)
+                       buf_len = dr_len;
                else
-                       mei_hdr.msg_complete = 1;
+                       mei_hdr->msg_complete = 1;
 
-               mei_hdr.length = sizeof(dma_len);
-               dma_len = len;
+               data_len = sizeof(dma_len);
+               dma_len = buf_len;
                data = &dma_len;
        } else if ((u32)hbuf_slots == mei_hbuf_depth(dev)) {
-               len = hbuf_len - hdr_len;
-               mei_hdr.length = len;
+               buf_len = hbuf_len - hdr_len;
+               data_len = buf_len;
        } else {
+               kfree(mei_hdr);
                return 0;
        }
+       mei_hdr->length += data_len;
 
-       if (mei_hdr.dma_ring)
-               mei_dma_ring_write(dev, buf->data + cb->buf_idx, len);
+       if (mei_hdr->dma_ring)
+               mei_dma_ring_write(dev, buf->data + cb->buf_idx, buf_len);
+       rets = mei_write_message(dev, mei_hdr, hdr_len, data, data_len);
 
-       rets = mei_write_message(dev, &mei_hdr, hdr_len, data, mei_hdr.length);
        if (rets)
                goto err;
 
        cl->status = 0;
        cl->writing_state = MEI_WRITING;
-       cb->buf_idx += len;
+       cb->buf_idx += buf_len;
 
        if (first_chunk) {
                if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
@@ -1635,12 +1898,14 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
                }
        }
 
-       if (mei_hdr.msg_complete)
+       if (mei_hdr->msg_complete)
                list_move_tail(&cb->list, &dev->write_waiting_list);
 
+       kfree(mei_hdr);
        return 0;
 
 err:
+       kfree(mei_hdr);
        cl->status = rets;
        list_move_tail(&cb->list, cmpl_list);
        return rets;
@@ -1659,9 +1924,11 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
 {
        struct mei_device *dev;
        struct mei_msg_data *buf;
-       struct mei_msg_hdr mei_hdr;
-       size_t hdr_len = sizeof(mei_hdr);
-       size_t len, hbuf_len, dr_len;
+       struct mei_msg_hdr *mei_hdr = NULL;
+       size_t hdr_len;
+       size_t hbuf_len, dr_len;
+       size_t buf_len;
+       size_t data_len;
        int hbuf_slots;
        u32 dr_slots;
        u32 dma_len;
@@ -1678,9 +1945,9 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
        dev = cl->dev;
 
        buf = &cb->buf;
-       len = buf->size;
+       buf_len = buf->size;
 
-       cl_dbg(dev, cl, "len=%zd\n", len);
+       cl_dbg(dev, cl, "buf_len=%zd\n", buf_len);
 
        blocking = cb->blocking;
        data = buf->data;
@@ -1700,17 +1967,27 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
        if (rets < 0)
                goto err;
 
-       mei_msg_hdr_init(&mei_hdr, cb);
+       mei_hdr = mei_msg_hdr_init(cb);
+       if (IS_ERR(mei_hdr)) {
+               rets = -PTR_ERR(mei_hdr);
+               mei_hdr = NULL;
+               goto err;
+       }
+
+       cl_dbg(dev, cl, "Extended Header %d vtag = %d\n",
+              mei_hdr->extended, cb->vtag);
+
+       hdr_len = sizeof(*mei_hdr) + mei_hdr->length;
 
        if (rets == 0) {
                cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
-               rets = len;
+               rets = buf_len;
                goto out;
        }
 
        if (!mei_hbuf_acquire(dev)) {
                cl_dbg(dev, cl, "Cannot acquire the host buffer: not sending.\n");
-               rets = len;
+               rets = buf_len;
                goto out;
        }
 
@@ -1724,29 +2001,30 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
        dr_slots = mei_dma_ring_empty_slots(dev);
        dr_len =  mei_slots2data(dr_slots);
 
-       if (len + hdr_len <= hbuf_len) {
-               mei_hdr.length = len;
-               mei_hdr.msg_complete = 1;
+       if (hdr_len + buf_len <= hbuf_len) {
+               data_len = buf_len;
+               mei_hdr->msg_complete = 1;
        } else if (dr_slots && hbuf_len >= hdr_len + sizeof(dma_len)) {
-               mei_hdr.dma_ring = 1;
-               if (len > dr_len)
-                       len = dr_len;
+               mei_hdr->dma_ring = 1;
+               if (buf_len > dr_len)
+                       buf_len = dr_len;
                else
-                       mei_hdr.msg_complete = 1;
+                       mei_hdr->msg_complete = 1;
 
-               mei_hdr.length = sizeof(dma_len);
-               dma_len = len;
+               data_len = sizeof(dma_len);
+               dma_len = buf_len;
                data = &dma_len;
        } else {
-               len = hbuf_len - hdr_len;
-               mei_hdr.length = len;
+               buf_len = hbuf_len - hdr_len;
+               data_len = buf_len;
        }
 
-       if (mei_hdr.dma_ring)
-               mei_dma_ring_write(dev, buf->data, len);
+       mei_hdr->length += data_len;
+
+       if (mei_hdr->dma_ring)
+               mei_dma_ring_write(dev, buf->data, buf_len);
+       rets = mei_write_message(dev, mei_hdr, hdr_len, data, data_len);
 
-       rets = mei_write_message(dev, &mei_hdr, hdr_len,
-                                data, mei_hdr.length);
        if (rets)
                goto err;
 
@@ -1755,12 +2033,12 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
                goto err;
 
        cl->writing_state = MEI_WRITING;
-       cb->buf_idx = len;
+       cb->buf_idx = buf_len;
        /* restore return value */
-       len = buf->size;
+       buf_len = buf->size;
 
 out:
-       if (mei_hdr.msg_complete)
+       if (mei_hdr->msg_complete)
                mei_tx_cb_enqueue(cb, &dev->write_waiting_list);
        else
                mei_tx_cb_enqueue(cb, &dev->write_list);
@@ -1785,7 +2063,7 @@ out:
                }
        }
 
-       rets = len;
+       rets = buf_len;
 err:
        cl_dbg(dev, cl, "rpm: autosuspend\n");
        pm_runtime_mark_last_busy(dev->dev);
@@ -1793,10 +2071,11 @@ err:
 free:
        mei_io_cb_free(cb);
 
+       kfree(mei_hdr);
+
        return rets;
 }
 
-
 /**
  * mei_cl_complete - processes completed operation for a client
  *
@@ -1820,7 +2099,7 @@ void mei_cl_complete(struct mei_cl *cl, struct mei_cl_cb *cb)
                break;
 
        case MEI_FOP_READ:
-               list_add_tail(&cb->list, &cl->rd_completed);
+               mei_cl_add_rd_completed(cl, cb);
                if (!mei_cl_is_fixed_address(cl) &&
                    !WARN_ON(!cl->rx_flow_ctrl_creds))
                        cl->rx_flow_ctrl_creds--;
index 2f8954d..64143d4 100644 (file)
@@ -93,6 +93,18 @@ static inline u8 mei_me_cl_fixed(const struct mei_me_client *me_cl)
        return me_cl->props.fixed_address;
 }
 
+/**
+ * mei_me_cl_vt - return me client vtag supported status
+ *
+ * @me_cl: me client
+ *
+ * Return: true if me client supports vt tagging
+ */
+static inline bool mei_me_cl_vt(const struct mei_me_client *me_cl)
+{
+       return me_cl->props.vt_supported == 1;
+}
+
 /**
  * mei_me_cl_max_len - return me client max msg length
  *
@@ -121,8 +133,11 @@ int mei_cl_unlink(struct mei_cl *cl);
 
 struct mei_cl *mei_cl_alloc_linked(struct mei_device *dev);
 
-struct mei_cl_cb *mei_cl_read_cb(const struct mei_cl *cl,
-                                const struct file *fp);
+struct mei_cl_cb *mei_cl_read_cb(struct mei_cl *cl, const struct file *fp);
+
+void mei_cl_add_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb);
+void mei_cl_del_rd_completed(struct mei_cl *cl, struct mei_cl_cb *cb);
+
 struct mei_cl_cb *mei_cl_alloc_cb(struct mei_cl *cl, size_t length,
                                  enum mei_cb_file_ops type,
                                  const struct file *fp);
@@ -131,6 +146,9 @@ struct mei_cl_cb *mei_cl_enqueue_ctrl_wr_cb(struct mei_cl *cl, size_t length,
                                            const struct file *fp);
 int mei_cl_flush_queues(struct mei_cl *cl, const struct file *fp);
 
+struct mei_cl_vtag *mei_cl_vtag_alloc(struct file *fp, u8 vtag);
+const struct file *mei_cl_fp_by_vtag(const struct mei_cl *cl, u8 vtag);
+int mei_cl_vt_support_check(const struct mei_cl *cl);
 /*
  *  MEI input output function prototype
  */
index a26c716..3ab1a43 100644 (file)
@@ -27,7 +27,7 @@ static int mei_dbgfs_meclients_show(struct seq_file *m, void *unused)
 
        down_read(&dev->me_clients_rwsem);
 
-       seq_puts(m, "  |id|fix|         UUID                       |con|msg len|sb|refc|\n");
+       seq_puts(m, "  |id|fix|         UUID                       |con|msg len|sb|refc|vt|\n");
 
        /*  if the driver is not enabled the list won't be consistent */
        if (dev->dev_state != MEI_DEV_ENABLED)
@@ -37,14 +37,15 @@ static int mei_dbgfs_meclients_show(struct seq_file *m, void *unused)
                if (!mei_me_cl_get(me_cl))
                        continue;
 
-               seq_printf(m, "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|%4d|\n",
+               seq_printf(m, "%2d|%2d|%3d|%pUl|%3d|%7d|%2d|%4d|%2d|\n",
                           i++, me_cl->client_id,
                           me_cl->props.fixed_address,
                           &me_cl->props.protocol_name,
                           me_cl->props.max_number_of_connections,
                           me_cl->props.max_msg_length,
                           me_cl->props.single_recv_buf,
-                          kref_read(&me_cl->refcnt));
+                          kref_read(&me_cl->refcnt),
+                          me_cl->props.vt_supported);
                mei_me_cl_put(me_cl);
        }
 
@@ -103,6 +104,8 @@ static int mei_dbgfs_devstate_show(struct seq_file *m, void *unused)
                seq_printf(m, "\tFA: %01d\n", dev->hbm_f_fa_supported);
                seq_printf(m, "\tOS: %01d\n", dev->hbm_f_os_supported);
                seq_printf(m, "\tDR: %01d\n", dev->hbm_f_dr_supported);
+               seq_printf(m, "\tVT: %01d\n", dev->hbm_f_vt_supported);
+               seq_printf(m, "\tCAP: %01d\n", dev->hbm_f_cap_supported);
        }
 
        seq_printf(m, "pg:  %s, %s\n",
index 308caee..a97eb5d 100644 (file)
@@ -125,19 +125,15 @@ void mei_hbm_reset(struct mei_device *dev)
 /**
  * mei_hbm_hdr - construct hbm header
  *
- * @hdr: hbm header
+ * @mei_hdr: hbm header
  * @length: payload length
  */
 
-static inline void mei_hbm_hdr(struct mei_msg_hdr *hdr, size_t length)
+static inline void mei_hbm_hdr(struct mei_msg_hdr *mei_hdr, size_t length)
 {
-       hdr->host_addr = 0;
-       hdr->me_addr = 0;
-       hdr->length = length;
-       hdr->msg_complete = 1;
-       hdr->dma_ring = 0;
-       hdr->reserved = 0;
-       hdr->internal = 0;
+       memset(mei_hdr, 0, sizeof(*mei_hdr));
+       mei_hdr->length = length;
+       mei_hdr->msg_complete = 1;
 }
 
 /**
@@ -325,6 +321,39 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev)
        return 0;
 }
 
+/**
+ * mei_hbm_capabilities_req - request capabilities
+ *
+ * @dev: the device structure
+ *
+ * Return: 0 on success and < 0 on failure
+ */
+static int mei_hbm_capabilities_req(struct mei_device *dev)
+{
+       struct mei_msg_hdr mei_hdr;
+       struct hbm_capability_request req;
+       int ret;
+
+       mei_hbm_hdr(&mei_hdr, sizeof(req));
+
+       memset(&req, 0, sizeof(req));
+       req.hbm_cmd = MEI_HBM_CAPABILITIES_REQ_CMD;
+       if (dev->hbm_f_vt_supported)
+               req.capability_requested[0] = HBM_CAP_VT;
+
+       ret = mei_hbm_write_message(dev, &mei_hdr, &req);
+       if (ret) {
+               dev_err(dev->dev,
+                       "capabilities request write failed: ret = %d.\n", ret);
+               return ret;
+       }
+
+       dev->hbm_state = MEI_HBM_CAP_SETUP;
+       dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
+       mei_schedule_stall_timer(dev);
+       return 0;
+}
+
 /**
  * mei_hbm_enum_clients_req - sends enumeration client request message.
  *
@@ -1042,6 +1071,20 @@ static void mei_hbm_config_features(struct mei_device *dev)
            (dev->version.major_version == HBM_MAJOR_VERSION_DR &&
             dev->version.minor_version >= HBM_MINOR_VERSION_DR))
                dev->hbm_f_dr_supported = 1;
+
+       /* VTag Support */
+       dev->hbm_f_vt_supported = 0;
+       if (dev->version.major_version > HBM_MAJOR_VERSION_VT ||
+           (dev->version.major_version == HBM_MAJOR_VERSION_VT &&
+            dev->version.minor_version >= HBM_MINOR_VERSION_VT))
+               dev->hbm_f_vt_supported = 1;
+
+       /* Capability message Support */
+       dev->hbm_f_cap_supported = 0;
+       if (dev->version.major_version > HBM_MAJOR_VERSION_CAP ||
+           (dev->version.major_version == HBM_MAJOR_VERSION_CAP &&
+            dev->version.minor_version >= HBM_MINOR_VERSION_CAP))
+               dev->hbm_f_cap_supported = 1;
 }
 
 /**
@@ -1075,6 +1118,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
        struct hbm_host_enum_response *enum_res;
        struct hbm_dma_setup_response *dma_setup_res;
        struct hbm_add_client_request *add_cl_req;
+       struct hbm_capability_response *capability_res;
        int ret;
 
        struct mei_hbm_cl_cmd *cl_cmd;
@@ -1138,6 +1182,13 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
                        return -EPROTO;
                }
 
+               if (dev->hbm_f_cap_supported) {
+                       if (mei_hbm_capabilities_req(dev))
+                               return -EIO;
+                       wake_up(&dev->wait_hbm_start);
+                       break;
+               }
+
                if (dev->hbm_f_dr_supported) {
                        if (mei_dmam_ring_alloc(dev))
                                dev_info(dev->dev, "running w/o dma ring\n");
@@ -1159,6 +1210,38 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
                wake_up(&dev->wait_hbm_start);
                break;
 
+       case MEI_HBM_CAPABILITIES_RES_CMD:
+               dev_dbg(dev->dev, "hbm: capabilities response: message received.\n");
+
+               dev->init_clients_timer = 0;
+
+               if (dev->hbm_state != MEI_HBM_CAP_SETUP) {
+                       dev_err(dev->dev, "hbm: capabilities response: state mismatch, [%d, %d]\n",
+                               dev->dev_state, dev->hbm_state);
+                       return -EPROTO;
+               }
+
+               capability_res = (struct hbm_capability_response *)mei_msg;
+               if (!(capability_res->capability_granted[0] & HBM_CAP_VT))
+                       dev->hbm_f_vt_supported = 0;
+
+               if (dev->hbm_f_dr_supported) {
+                       if (mei_dmam_ring_alloc(dev))
+                               dev_info(dev->dev, "running w/o dma ring\n");
+                       if (mei_dma_ring_is_allocated(dev)) {
+                               if (mei_hbm_dma_setup_req(dev))
+                                       return -EIO;
+                               break;
+                       }
+               }
+
+               dev->hbm_f_dr_supported = 0;
+               mei_dmam_ring_free(dev);
+
+               if (mei_hbm_enum_clients_req(dev))
+                       return -EIO;
+               break;
+
        case MEI_HBM_DMA_SETUP_RES_CMD:
                dev_dbg(dev->dev, "hbm: dma setup response: message received.\n");
 
index 5aa58cf..4d95e38 100644 (file)
@@ -16,6 +16,7 @@ struct mei_cl;
  *
  * @MEI_HBM_IDLE : protocol not started
  * @MEI_HBM_STARTING : start request message was sent
+ * @MEI_HBM_CAP_SETUP : capabilities request message was sent
  * @MEI_HBM_DR_SETUP : dma ring setup request message was sent
  * @MEI_HBM_ENUM_CLIENTS : enumeration request was sent
  * @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties
@@ -25,6 +26,7 @@ struct mei_cl;
 enum mei_hbm_state {
        MEI_HBM_IDLE = 0,
        MEI_HBM_STARTING,
+       MEI_HBM_CAP_SETUP,
        MEI_HBM_DR_SETUP,
        MEI_HBM_ENUM_CLIENTS,
        MEI_HBM_CLIENT_PROPERTIES,
index d1d3e02..9ae9669 100644 (file)
@@ -546,38 +546,46 @@ static int mei_hdcp_verify_mprime(struct device *dev,
                                  struct hdcp_port_data *data,
                                  struct hdcp2_rep_stream_ready *stream_ready)
 {
-       struct wired_cmd_repeater_auth_stream_req_in
-                                       verify_mprime_in = { { 0 } };
+       struct wired_cmd_repeater_auth_stream_req_in *verify_mprime_in;
        struct wired_cmd_repeater_auth_stream_req_out
                                        verify_mprime_out = { { 0 } };
        struct mei_cl_device *cldev;
        ssize_t byte;
+       size_t cmd_size;
 
        if (!dev || !stream_ready || !data)
                return -EINVAL;
 
        cldev = to_mei_cl_device(dev);
 
-       verify_mprime_in.header.api_version = HDCP_API_VERSION;
-       verify_mprime_in.header.command_id = WIRED_REPEATER_AUTH_STREAM_REQ;
-       verify_mprime_in.header.status = ME_HDCP_STATUS_SUCCESS;
-       verify_mprime_in.header.buffer_len =
+       cmd_size = struct_size(verify_mprime_in, streams, data->k);
+       if (cmd_size == SIZE_MAX)
+               return -EINVAL;
+
+       verify_mprime_in = kzalloc(cmd_size, GFP_KERNEL);
+       if (!verify_mprime_in)
+               return -ENOMEM;
+
+       verify_mprime_in->header.api_version = HDCP_API_VERSION;
+       verify_mprime_in->header.command_id = WIRED_REPEATER_AUTH_STREAM_REQ;
+       verify_mprime_in->header.status = ME_HDCP_STATUS_SUCCESS;
+       verify_mprime_in->header.buffer_len =
                        WIRED_CMD_BUF_LEN_REPEATER_AUTH_STREAM_REQ_MIN_IN;
 
-       verify_mprime_in.port.integrated_port_type = data->port_type;
-       verify_mprime_in.port.physical_port = (u8)data->fw_ddi;
-       verify_mprime_in.port.attached_transcoder = (u8)data->fw_tc;
+       verify_mprime_in->port.integrated_port_type = data->port_type;
+       verify_mprime_in->port.physical_port = (u8)data->fw_ddi;
+       verify_mprime_in->port.attached_transcoder = (u8)data->fw_tc;
+
+       memcpy(verify_mprime_in->m_prime, stream_ready->m_prime, HDCP_2_2_MPRIME_LEN);
+       drm_hdcp_cpu_to_be24(verify_mprime_in->seq_num_m, data->seq_num_m);
 
-       memcpy(verify_mprime_in.m_prime, stream_ready->m_prime,
-              HDCP_2_2_MPRIME_LEN);
-       drm_hdcp_cpu_to_be24(verify_mprime_in.seq_num_m, data->seq_num_m);
-       memcpy(verify_mprime_in.streams, data->streams,
+       memcpy(verify_mprime_in->streams, data->streams,
               array_size(data->k, sizeof(*data->streams)));
 
-       verify_mprime_in.k = cpu_to_be16(data->k);
+       verify_mprime_in->k = cpu_to_be16(data->k);
 
-       byte = mei_cldev_send(cldev, (u8 *)&verify_mprime_in,
-                             sizeof(verify_mprime_in));
+       byte = mei_cldev_send(cldev, (u8 *)verify_mprime_in, cmd_size);
+       kfree(verify_mprime_in);
        if (byte < 0) {
                dev_dbg(dev, "mei_cldev_send failed. %zd\n", byte);
                return byte;
diff --git a/drivers/misc/mei/hw-virtio.c b/drivers/misc/mei/hw-virtio.c
new file mode 100644 (file)
index 0000000..899dc1c
--- /dev/null
@@ -0,0 +1,874 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Intel Management Engine Interface (Intel MEI) Linux driver
+ * Copyright (c) 2018-2020, Intel Corporation.
+ */
+#include <linux/err.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/scatterlist.h>
+#include <linux/spinlock.h>
+#include <linux/slab.h>
+#include <linux/virtio.h>
+#include <linux/virtio_config.h>
+#include <linux/virtio_ids.h>
+#include <linux/atomic.h>
+
+#include "mei_dev.h"
+#include "hbm.h"
+#include "client.h"
+
+#define MEI_VIRTIO_RPM_TIMEOUT 500
+/* ACRN virtio device types */
+#ifndef VIRTIO_ID_MEI
+#define VIRTIO_ID_MEI 0xFFFE /* virtio mei */
+#endif
+
+/**
+ * struct mei_virtio_cfg - settings passed from the virtio backend
+ * @buf_depth: read buffer depth in slots (4bytes)
+ * @hw_ready: hw is ready for operation
+ * @host_reset: synchronize reset with virtio backend
+ * @reserved: reserved for alignment
+ * @fw_status: FW status
+ */
+struct mei_virtio_cfg {
+       u32 buf_depth;
+       u8 hw_ready;
+       u8 host_reset;
+       u8 reserved[2];
+       u32 fw_status[MEI_FW_STATUS_MAX];
+} __packed;
+
+struct mei_virtio_hw {
+       struct mei_device mdev;
+       char name[32];
+
+       struct virtqueue *in;
+       struct virtqueue *out;
+
+       bool host_ready;
+       struct work_struct intr_handler;
+
+       u32 *recv_buf;
+       u8 recv_rdy;
+       size_t recv_sz;
+       u32 recv_idx;
+       u32 recv_len;
+
+       /* send buffer */
+       atomic_t hbuf_ready;
+       const void *send_hdr;
+       const void *send_buf;
+
+       struct mei_virtio_cfg cfg;
+};
+
+#define to_virtio_hw(_dev) container_of(_dev, struct mei_virtio_hw, mdev)
+
+/**
+ * mei_virtio_fw_status() - read status register of mei
+ * @dev: mei device
+ * @fw_status: fw status register values
+ *
+ * Return: always 0
+ */
+static int mei_virtio_fw_status(struct mei_device *dev,
+                               struct mei_fw_status *fw_status)
+{
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       fw_status->count = MEI_FW_STATUS_MAX;
+       virtio_cread_bytes(vdev, offsetof(struct mei_virtio_cfg, fw_status),
+                          fw_status->status, sizeof(fw_status->status));
+       return 0;
+}
+
+/**
+ * mei_virtio_pg_state() - translate internal pg state
+ *   to the mei power gating state
+ *   There is no power management in ACRN mode always return OFF
+ * @dev: mei device
+ *
+ * Return:
+ * * MEI_PG_OFF - if aliveness is on (always)
+ * * MEI_PG_ON  - (never)
+ */
+static inline enum mei_pg_state mei_virtio_pg_state(struct mei_device *dev)
+{
+       return MEI_PG_OFF;
+}
+
+/**
+ * mei_virtio_hw_config() - configure hw dependent settings
+ *
+ * @dev: mei device
+ *
+ * Return: always 0
+ */
+static int mei_virtio_hw_config(struct mei_device *dev)
+{
+       return 0;
+}
+
+/**
+ * mei_virtio_hbuf_empty_slots() - counts write empty slots.
+ * @dev: the device structure
+ *
+ * Return: always return frontend buf size if buffer is ready, 0 otherwise
+ */
+static int mei_virtio_hbuf_empty_slots(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       return (atomic_read(&hw->hbuf_ready) == 1) ? hw->cfg.buf_depth : 0;
+}
+
+/**
+ * mei_virtio_hbuf_is_ready() - checks if write buffer is ready
+ * @dev: the device structure
+ *
+ * Return: true if hbuf is ready
+ */
+static bool mei_virtio_hbuf_is_ready(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       return atomic_read(&hw->hbuf_ready) == 1;
+}
+
+/**
+ * mei_virtio_hbuf_max_depth() - returns depth of FE write buffer.
+ * @dev: the device structure
+ *
+ * Return: size of frontend write buffer in bytes
+ */
+static u32 mei_virtio_hbuf_depth(const struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       return hw->cfg.buf_depth;
+}
+
+/**
+ * mei_virtio_intr_clear() - clear and stop interrupts
+ * @dev: the device structure
+ */
+static void mei_virtio_intr_clear(struct mei_device *dev)
+{
+       /*
+        * In our virtio solution, there are two types of interrupts,
+        * vq interrupt and config change interrupt.
+        *   1) start/reset rely on virtio config changed interrupt;
+        *   2) send/recv rely on virtio virtqueue interrupts.
+        * They are all virtual interrupts. So, we don't have corresponding
+        * operation to do here.
+        */
+}
+
+/**
+ * mei_virtio_intr_enable() - enables mei BE virtqueues callbacks
+ * @dev: the device structure
+ */
+static void mei_virtio_intr_enable(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       virtio_config_enable(vdev);
+
+       virtqueue_enable_cb(hw->in);
+       virtqueue_enable_cb(hw->out);
+}
+
+/**
+ * mei_virtio_intr_disable() - disables mei BE virtqueues callbacks
+ *
+ * @dev: the device structure
+ */
+static void mei_virtio_intr_disable(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       virtio_config_disable(vdev);
+
+       virtqueue_disable_cb(hw->in);
+       virtqueue_disable_cb(hw->out);
+}
+
+/**
+ * mei_virtio_synchronize_irq() - wait for pending IRQ handlers for all
+ *     virtqueue
+ * @dev: the device structure
+ */
+static void mei_virtio_synchronize_irq(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       /*
+        * Now, all IRQ handlers are converted to workqueue.
+        * Change synchronize irq to flush this work.
+        */
+       flush_work(&hw->intr_handler);
+}
+
+static void mei_virtio_free_outbufs(struct mei_virtio_hw *hw)
+{
+       kfree(hw->send_hdr);
+       kfree(hw->send_buf);
+       hw->send_hdr = NULL;
+       hw->send_buf = NULL;
+}
+
+/**
+ * mei_virtio_write_message() - writes a message to mei virtio back-end service.
+ * @dev: the device structure
+ * @hdr: mei header of message
+ * @hdr_len: header length
+ * @data: message payload will be written
+ * @data_len: message payload length
+ *
+ * Return:
+ * *  0: on success
+ * * -EIO: if write has failed
+ * * -ENOMEM: on memory allocation failure
+ */
+static int mei_virtio_write_message(struct mei_device *dev,
+                                   const void *hdr, size_t hdr_len,
+                                   const void *data, size_t data_len)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct scatterlist sg[2];
+       const void *hbuf, *dbuf;
+       int ret;
+
+       if (WARN_ON(!atomic_add_unless(&hw->hbuf_ready, -1, 0)))
+               return -EIO;
+
+       hbuf = kmemdup(hdr, hdr_len, GFP_KERNEL);
+       hw->send_hdr = hbuf;
+
+       dbuf = kmemdup(data, data_len, GFP_KERNEL);
+       hw->send_buf = dbuf;
+
+       if (!hbuf || !dbuf) {
+               ret = -ENOMEM;
+               goto fail;
+       }
+
+       sg_init_table(sg, 2);
+       sg_set_buf(&sg[0], hbuf, hdr_len);
+       sg_set_buf(&sg[1], dbuf, data_len);
+
+       ret = virtqueue_add_outbuf(hw->out, sg, 2, hw, GFP_KERNEL);
+       if (ret) {
+               dev_err(dev->dev, "failed to add outbuf\n");
+               goto fail;
+       }
+
+       virtqueue_kick(hw->out);
+       return 0;
+fail:
+
+       mei_virtio_free_outbufs(hw);
+
+       return ret;
+}
+
+/**
+ * mei_virtio_count_full_read_slots() - counts read full slots.
+ * @dev: the device structure
+ *
+ * Return: -EOVERFLOW if overflow, otherwise filled slots count
+ */
+static int mei_virtio_count_full_read_slots(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       if (hw->recv_idx > hw->recv_len)
+               return -EOVERFLOW;
+
+       return hw->recv_len - hw->recv_idx;
+}
+
+/**
+ * mei_virtio_read_hdr() - Reads 32bit dword from mei virtio receive buffer
+ *
+ * @dev: the device structure
+ *
+ * Return: 32bit dword of receive buffer (u32)
+ */
+static inline u32 mei_virtio_read_hdr(const struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       WARN_ON(hw->cfg.buf_depth < hw->recv_idx + 1);
+
+       return hw->recv_buf[hw->recv_idx++];
+}
+
+static int mei_virtio_read(struct mei_device *dev, unsigned char *buffer,
+                          unsigned long len)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       u32 slots = mei_data2slots(len);
+
+       if (WARN_ON(hw->cfg.buf_depth < hw->recv_idx + slots))
+               return -EOVERFLOW;
+
+       /*
+        * Assumption: There is only one MEI message in recv_buf each time.
+        * Backend service need follow this rule too.
+        */
+       memcpy(buffer, hw->recv_buf + hw->recv_idx, len);
+       hw->recv_idx += slots;
+
+       return 0;
+}
+
+static bool mei_virtio_pg_is_enabled(struct mei_device *dev)
+{
+       return false;
+}
+
+static bool mei_virtio_pg_in_transition(struct mei_device *dev)
+{
+       return false;
+}
+
+static void mei_virtio_add_recv_buf(struct mei_virtio_hw *hw)
+{
+       struct scatterlist sg;
+
+       if (hw->recv_rdy) /* not needed */
+               return;
+
+       /* refill the recv_buf to IN virtqueue to get next message */
+       sg_init_one(&sg, hw->recv_buf, mei_slots2data(hw->cfg.buf_depth));
+       hw->recv_len = 0;
+       hw->recv_idx = 0;
+       hw->recv_rdy = 1;
+       virtqueue_add_inbuf(hw->in, &sg, 1, hw->recv_buf, GFP_KERNEL);
+       virtqueue_kick(hw->in);
+}
+
+/**
+ * mei_virtio_hw_is_ready() - check whether the BE(hw) has turned ready
+ * @dev: mei device
+ * Return: bool
+ */
+static bool mei_virtio_hw_is_ready(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       virtio_cread(vdev, struct mei_virtio_cfg,
+                    hw_ready, &hw->cfg.hw_ready);
+
+       dev_dbg(dev->dev, "hw ready %d\n", hw->cfg.hw_ready);
+
+       return hw->cfg.hw_ready;
+}
+
+/**
+ * mei_virtio_hw_reset - resets virtio hw.
+ *
+ * @dev: the device structure
+ * @intr_enable: virtio use data/config callbacks
+ *
+ * Return: 0 on success an error code otherwise
+ */
+static int mei_virtio_hw_reset(struct mei_device *dev, bool intr_enable)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       dev_dbg(dev->dev, "hw reset\n");
+
+       dev->recvd_hw_ready = false;
+       hw->host_ready = false;
+       atomic_set(&hw->hbuf_ready, 0);
+       hw->recv_len = 0;
+       hw->recv_idx = 0;
+
+       hw->cfg.host_reset = 1;
+       virtio_cwrite(vdev, struct mei_virtio_cfg,
+                     host_reset, &hw->cfg.host_reset);
+
+       mei_virtio_hw_is_ready(dev);
+
+       if (intr_enable)
+               mei_virtio_intr_enable(dev);
+
+       return 0;
+}
+
+/**
+ * mei_virtio_hw_reset_release() - release device from the reset
+ * @dev: the device structure
+ */
+static void mei_virtio_hw_reset_release(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       struct virtio_device *vdev = dev_to_virtio(dev->dev);
+
+       dev_dbg(dev->dev, "hw reset release\n");
+       hw->cfg.host_reset = 0;
+       virtio_cwrite(vdev, struct mei_virtio_cfg,
+                     host_reset, &hw->cfg.host_reset);
+}
+
+/**
+ * mei_virtio_hw_ready_wait() - wait until the virtio(hw) has turned ready
+ *  or timeout is reached
+ * @dev: mei device
+ *
+ * Return: 0 on success, error otherwise
+ */
+static int mei_virtio_hw_ready_wait(struct mei_device *dev)
+{
+       mutex_unlock(&dev->device_lock);
+       wait_event_timeout(dev->wait_hw_ready,
+                          dev->recvd_hw_ready,
+                          mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT));
+       mutex_lock(&dev->device_lock);
+       if (!dev->recvd_hw_ready) {
+               dev_err(dev->dev, "wait hw ready failed\n");
+               return -ETIMEDOUT;
+       }
+
+       dev->recvd_hw_ready = false;
+       return 0;
+}
+
+/**
+ * mei_virtio_hw_start() - hw start routine
+ * @dev: mei device
+ *
+ * Return: 0 on success, error otherwise
+ */
+static int mei_virtio_hw_start(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+       int ret;
+
+       dev_dbg(dev->dev, "hw start\n");
+       mei_virtio_hw_reset_release(dev);
+
+       ret = mei_virtio_hw_ready_wait(dev);
+       if (ret)
+               return ret;
+
+       mei_virtio_add_recv_buf(hw);
+       atomic_set(&hw->hbuf_ready, 1);
+       dev_dbg(dev->dev, "hw is ready\n");
+       hw->host_ready = true;
+
+       return 0;
+}
+
+/**
+ * mei_virtio_host_is_ready() - check whether the FE has turned ready
+ * @dev: mei device
+ *
+ * Return: bool
+ */
+static bool mei_virtio_host_is_ready(struct mei_device *dev)
+{
+       struct mei_virtio_hw *hw = to_virtio_hw(dev);
+
+       dev_dbg(dev->dev, "host ready %d\n", hw->host_ready);
+
+       return hw->host_ready;
+}
+
+/**
+ * mei_virtio_data_in() - The callback of recv virtqueue of virtio mei
+ * @vq: receiving virtqueue
+ */
+static void mei_virtio_data_in(struct virtqueue *vq)
+{
+       struct mei_virtio_hw *hw = vq->vdev->priv;
+
+       /* disable interrupts (enabled again from in the interrupt worker) */
+       virtqueue_disable_cb(hw->in);
+
+       schedule_work(&hw->intr_handler);
+}
+
+/**
+ * mei_virtio_data_out() - The callback of send virtqueue of virtio mei
+ * @vq: transmitting virtqueue
+ */
+static void mei_virtio_data_out(struct virtqueue *vq)
+{
+       struct mei_virtio_hw *hw = vq->vdev->priv;
+
+       schedule_work(&hw->intr_handler);
+}
+
+static void mei_virtio_intr_handler(struct work_struct *work)
+{
+       struct mei_virtio_hw *hw =
+               container_of(work, struct mei_virtio_hw, intr_handler);
+       struct mei_device *dev = &hw->mdev;
+       LIST_HEAD(complete_list);
+       s32 slots;
+       int rets = 0;
+       void *data;
+       unsigned int len;
+
+       mutex_lock(&dev->device_lock);
+
+       if (dev->dev_state == MEI_DEV_DISABLED) {
+               dev_warn(dev->dev, "Interrupt in disabled state.\n");
+               mei_virtio_intr_disable(dev);
+               goto end;
+       }
+
+       /* check if ME wants a reset */
+       if (!mei_hw_is_ready(dev) && dev->dev_state != MEI_DEV_RESETTING) {
+               dev_warn(dev->dev, "BE service not ready: resetting.\n");
+               schedule_work(&dev->reset_work);
+               goto end;
+       }
+
+       /* check if we need to start the dev */
+       if (!mei_host_is_ready(dev)) {
+               if (mei_hw_is_ready(dev)) {
+                       dev_dbg(dev->dev, "we need to start the dev.\n");
+                       dev->recvd_hw_ready = true;
+                       wake_up(&dev->wait_hw_ready);
+               } else {
+                       dev_warn(dev->dev, "Spurious Interrupt\n");
+               }
+               goto end;
+       }
+
+       /* read */
+       if (hw->recv_rdy) {
+               data = virtqueue_get_buf(hw->in, &len);
+               if (!data || !len) {
+                       dev_dbg(dev->dev, "No data %d", len);
+               } else {
+                       dev_dbg(dev->dev, "data_in %d\n", len);
+                       WARN_ON(data != hw->recv_buf);
+                       hw->recv_len = mei_data2slots(len);
+                       hw->recv_rdy = 0;
+               }
+       }
+
+       /* write */
+       if (!atomic_read(&hw->hbuf_ready)) {
+               if (!virtqueue_get_buf(hw->out, &len)) {
+                       dev_warn(dev->dev, "Failed to getbuf\n");
+               } else {
+                       mei_virtio_free_outbufs(hw);
+                       atomic_inc(&hw->hbuf_ready);
+               }
+       }
+
+       /* check slots available for reading */
+       slots = mei_count_full_read_slots(dev);
+       while (slots > 0) {
+               dev_dbg(dev->dev, "slots to read = %08x\n", slots);
+               rets = mei_irq_read_handler(dev, &complete_list, &slots);
+
+               if (rets &&
+                   (dev->dev_state != MEI_DEV_RESETTING &&
+                    dev->dev_state != MEI_DEV_POWER_DOWN)) {
+                       dev_err(dev->dev, "mei_irq_read_handler ret = %d.\n",
+                               rets);
+                       schedule_work(&dev->reset_work);
+                       goto end;
+               }
+       }
+
+       dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
+
+       mei_irq_write_handler(dev, &complete_list);
+
+       dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
+
+       mei_irq_compl_handler(dev, &complete_list);
+
+       mei_virtio_add_recv_buf(hw);
+
+end:
+       if (dev->dev_state != MEI_DEV_DISABLED) {
+               if (!virtqueue_enable_cb(hw->in))
+                       schedule_work(&hw->intr_handler);
+       }
+
+       mutex_unlock(&dev->device_lock);
+}
+
+static void mei_virtio_config_changed(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw = vdev->priv;
+       struct mei_device *dev = &hw->mdev;
+
+       virtio_cread(vdev, struct mei_virtio_cfg,
+                    hw_ready, &hw->cfg.hw_ready);
+
+       if (dev->dev_state == MEI_DEV_DISABLED) {
+               dev_dbg(dev->dev, "disabled state don't start\n");
+               return;
+       }
+
+       /* Run intr handler once to handle reset notify */
+       schedule_work(&hw->intr_handler);
+}
+
+static void mei_virtio_remove_vqs(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw = vdev->priv;
+
+       virtqueue_detach_unused_buf(hw->in);
+       hw->recv_len = 0;
+       hw->recv_idx = 0;
+       hw->recv_rdy = 0;
+
+       virtqueue_detach_unused_buf(hw->out);
+
+       mei_virtio_free_outbufs(hw);
+
+       vdev->config->del_vqs(vdev);
+}
+
+/*
+ * There are two virtqueues, one is for send and another is for recv.
+ */
+static int mei_virtio_init_vqs(struct mei_virtio_hw *hw,
+                              struct virtio_device *vdev)
+{
+       struct virtqueue *vqs[2];
+
+       vq_callback_t *cbs[] = {
+               mei_virtio_data_in,
+               mei_virtio_data_out,
+       };
+       static const char * const names[] = {
+               "in",
+               "out",
+       };
+       int ret;
+
+       ret = virtio_find_vqs(vdev, 2, vqs, cbs, names, NULL);
+       if (ret)
+               return ret;
+
+       hw->in = vqs[0];
+       hw->out = vqs[1];
+
+       return 0;
+}
+
+static const struct mei_hw_ops mei_virtio_ops = {
+       .fw_status = mei_virtio_fw_status,
+       .pg_state  = mei_virtio_pg_state,
+
+       .host_is_ready = mei_virtio_host_is_ready,
+
+       .hw_is_ready = mei_virtio_hw_is_ready,
+       .hw_reset = mei_virtio_hw_reset,
+       .hw_config = mei_virtio_hw_config,
+       .hw_start = mei_virtio_hw_start,
+
+       .pg_in_transition = mei_virtio_pg_in_transition,
+       .pg_is_enabled = mei_virtio_pg_is_enabled,
+
+       .intr_clear = mei_virtio_intr_clear,
+       .intr_enable = mei_virtio_intr_enable,
+       .intr_disable = mei_virtio_intr_disable,
+       .synchronize_irq = mei_virtio_synchronize_irq,
+
+       .hbuf_free_slots = mei_virtio_hbuf_empty_slots,
+       .hbuf_is_ready = mei_virtio_hbuf_is_ready,
+       .hbuf_depth = mei_virtio_hbuf_depth,
+
+       .write = mei_virtio_write_message,
+
+       .rdbuf_full_slots = mei_virtio_count_full_read_slots,
+       .read_hdr = mei_virtio_read_hdr,
+       .read = mei_virtio_read,
+};
+
+static int mei_virtio_probe(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw;
+       int ret;
+
+       hw = devm_kzalloc(&vdev->dev, sizeof(*hw), GFP_KERNEL);
+       if (!hw)
+               return -ENOMEM;
+
+       vdev->priv = hw;
+
+       INIT_WORK(&hw->intr_handler, mei_virtio_intr_handler);
+
+       ret = mei_virtio_init_vqs(hw, vdev);
+       if (ret)
+               goto vqs_failed;
+
+       virtio_cread(vdev, struct mei_virtio_cfg,
+                    buf_depth, &hw->cfg.buf_depth);
+
+       hw->recv_buf = kzalloc(mei_slots2data(hw->cfg.buf_depth), GFP_KERNEL);
+       if (!hw->recv_buf) {
+               ret = -ENOMEM;
+               goto hbuf_failed;
+       }
+       atomic_set(&hw->hbuf_ready, 0);
+
+       virtio_device_ready(vdev);
+
+       mei_device_init(&hw->mdev, &vdev->dev, &mei_virtio_ops);
+
+       pm_runtime_get_noresume(&vdev->dev);
+       pm_runtime_set_active(&vdev->dev);
+       pm_runtime_enable(&vdev->dev);
+
+       ret = mei_start(&hw->mdev);
+       if (ret)
+               goto mei_start_failed;
+
+       pm_runtime_set_autosuspend_delay(&vdev->dev, MEI_VIRTIO_RPM_TIMEOUT);
+       pm_runtime_use_autosuspend(&vdev->dev);
+
+       ret = mei_register(&hw->mdev, &vdev->dev);
+       if (ret)
+               goto mei_failed;
+
+       pm_runtime_put(&vdev->dev);
+
+       return 0;
+
+mei_failed:
+       mei_stop(&hw->mdev);
+mei_start_failed:
+       mei_cancel_work(&hw->mdev);
+       mei_disable_interrupts(&hw->mdev);
+       kfree(hw->recv_buf);
+hbuf_failed:
+       vdev->config->del_vqs(vdev);
+vqs_failed:
+       return ret;
+}
+
+static int __maybe_unused mei_virtio_pm_runtime_idle(struct device *device)
+{
+       struct virtio_device *vdev = dev_to_virtio(device);
+       struct mei_virtio_hw *hw = vdev->priv;
+
+       dev_dbg(&vdev->dev, "rpm: mei_virtio : runtime_idle\n");
+
+       if (!hw)
+               return -ENODEV;
+
+       if (mei_write_is_idle(&hw->mdev))
+               pm_runtime_autosuspend(device);
+
+       return -EBUSY;
+}
+
+static int __maybe_unused mei_virtio_pm_runtime_suspend(struct device *device)
+{
+       return 0;
+}
+
+static int __maybe_unused mei_virtio_pm_runtime_resume(struct device *device)
+{
+       return 0;
+}
+
+static int __maybe_unused mei_virtio_freeze(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw = vdev->priv;
+
+       dev_dbg(&vdev->dev, "freeze\n");
+
+       if (!hw)
+               return -ENODEV;
+
+       mei_stop(&hw->mdev);
+       mei_disable_interrupts(&hw->mdev);
+       cancel_work_sync(&hw->intr_handler);
+       vdev->config->reset(vdev);
+       mei_virtio_remove_vqs(vdev);
+
+       return 0;
+}
+
+static int __maybe_unused mei_virtio_restore(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw = vdev->priv;
+       int ret;
+
+       dev_dbg(&vdev->dev, "restore\n");
+
+       if (!hw)
+               return -ENODEV;
+
+       ret = mei_virtio_init_vqs(hw, vdev);
+       if (ret)
+               return ret;
+
+       virtio_device_ready(vdev);
+
+       ret = mei_restart(&hw->mdev);
+       if (ret)
+               return ret;
+
+       /* Start timer if stopped in suspend */
+       schedule_delayed_work(&hw->mdev.timer_work, HZ);
+
+       return 0;
+}
+
+static const struct dev_pm_ops mei_virtio_pm_ops = {
+       SET_RUNTIME_PM_OPS(mei_virtio_pm_runtime_suspend,
+                          mei_virtio_pm_runtime_resume,
+                          mei_virtio_pm_runtime_idle)
+};
+
+static void mei_virtio_remove(struct virtio_device *vdev)
+{
+       struct mei_virtio_hw *hw = vdev->priv;
+
+       mei_stop(&hw->mdev);
+       mei_disable_interrupts(&hw->mdev);
+       cancel_work_sync(&hw->intr_handler);
+       mei_deregister(&hw->mdev);
+       vdev->config->reset(vdev);
+       mei_virtio_remove_vqs(vdev);
+       kfree(hw->recv_buf);
+       pm_runtime_disable(&vdev->dev);
+}
+
+static struct virtio_device_id id_table[] = {
+       { VIRTIO_ID_MEI, VIRTIO_DEV_ANY_ID },
+       { }
+};
+
+static struct virtio_driver mei_virtio_driver = {
+       .id_table = id_table,
+       .probe = mei_virtio_probe,
+       .remove = mei_virtio_remove,
+       .config_changed = mei_virtio_config_changed,
+       .driver = {
+               .name = KBUILD_MODNAME,
+               .owner = THIS_MODULE,
+               .pm = &mei_virtio_pm_ops,
+       },
+#ifdef CONFIG_PM_SLEEP
+       .freeze = mei_virtio_freeze,
+       .restore = mei_virtio_restore,
+#endif
+};
+
+module_virtio_driver(mei_virtio_driver);
+MODULE_DEVICE_TABLE(virtio, id_table);
+MODULE_DESCRIPTION("Virtio MEI frontend driver");
+MODULE_LICENSE("GPL v2");
index 26fa92c..8bac86c 100644 (file)
@@ -25,7 +25,7 @@
 /*
  * MEI Version
  */
-#define HBM_MINOR_VERSION                   1
+#define HBM_MINOR_VERSION                   2
 #define HBM_MAJOR_VERSION                   2
 
 /*
 #define HBM_MINOR_VERSION_DR               1
 #define HBM_MAJOR_VERSION_DR               2
 
+/*
+ * MEI version with vm tag support
+ */
+#define HBM_MINOR_VERSION_VT               2
+#define HBM_MAJOR_VERSION_VT               2
+
+/*
+ * MEI version with capabilities message support
+ */
+#define HBM_MINOR_VERSION_CAP              2
+#define HBM_MAJOR_VERSION_CAP              2
+
 /* Host bus message command opcode */
 #define MEI_HBM_CMD_OP_MSK                  0x7f
 /* Host bus message command RESPONSE */
 #define MEI_HBM_DMA_SETUP_REQ_CMD           0x12
 #define MEI_HBM_DMA_SETUP_RES_CMD           0x92
 
+#define MEI_HBM_CAPABILITIES_REQ_CMD        0x13
+#define MEI_HBM_CAPABILITIES_RES_CMD        0x93
+
 /*
  * MEI Stop Reason
  * used by hbm_host_stop_request.reason
@@ -182,10 +197,95 @@ enum mei_cl_connect_status {
 /*
  * Client Disconnect Status
  */
-enum  mei_cl_disconnect_status {
+enum mei_cl_disconnect_status {
        MEI_CL_DISCONN_SUCCESS = MEI_HBMS_SUCCESS
 };
 
+/**
+ * enum mei_ext_hdr_type - extended header type used in
+ *    extended header TLV
+ *
+ * @MEI_EXT_HDR_NONE: sentinel
+ * @MEI_EXT_HDR_VTAG: vtag header
+ */
+enum mei_ext_hdr_type {
+       MEI_EXT_HDR_NONE = 0,
+       MEI_EXT_HDR_VTAG = 1,
+};
+
+/**
+ * struct mei_ext_hdr - extend header descriptor (TLV)
+ * @type: enum mei_ext_hdr_type
+ * @length: length excluding descriptor
+ * @ext_payload: payload of the specific extended header
+ * @hdr: place holder for actual header
+ */
+struct mei_ext_hdr {
+       u8 type;
+       u8 length;
+       u8 ext_payload[2];
+       u8 hdr[0];
+};
+
+/**
+ * struct mei_ext_meta_hdr - extend header meta data
+ * @count: number of headers
+ * @size: total size of the extended header list excluding meta header
+ * @reserved: reserved
+ * @hdrs: extended headers TLV list
+ */
+struct mei_ext_meta_hdr {
+       u8 count;
+       u8 size;
+       u8 reserved[2];
+       struct mei_ext_hdr hdrs[0];
+};
+
+/*
+ * Extended header iterator functions
+ */
+/**
+ * mei_ext_hdr - extended header iterator begin
+ *
+ * @meta: meta header of the extended header list
+ *
+ * Return:
+ *     The first extended header
+ */
+static inline struct mei_ext_hdr *mei_ext_begin(struct mei_ext_meta_hdr *meta)
+{
+       return meta->hdrs;
+}
+
+/**
+ * mei_ext_last - check if the ext is the last one in the TLV list
+ *
+ * @meta: meta header of the extended header list
+ * @ext: a meta header on the list
+ *
+ * Return: true if ext is the last header on the list
+ */
+static inline bool mei_ext_last(struct mei_ext_meta_hdr *meta,
+                               struct mei_ext_hdr *ext)
+{
+       return (u8 *)ext >= (u8 *)meta + sizeof(*meta) + (meta->size * 4);
+}
+
+/**
+ *mei_ext_next - following extended header on the TLV list
+ *
+ * @ext: current extend header
+ *
+ * Context: The function does not check for the overflows,
+ *          one should call mei_ext_last before.
+ *
+ * Return: The following extend header after @ext
+ */
+static inline struct mei_ext_hdr *mei_ext_next(struct mei_ext_hdr *ext)
+{
+       return (struct mei_ext_hdr *)(ext->hdr + (ext->length * 4));
+}
+
 /**
  * struct mei_msg_hdr - MEI BUS Interface Section
  *
@@ -193,6 +293,7 @@ enum  mei_cl_disconnect_status {
  * @host_addr: host address
  * @length: message length
  * @reserved: reserved
+ * @extended: message has extended header
  * @dma_ring: message is on dma ring
  * @internal: message is internal
  * @msg_complete: last packet of the message
@@ -202,7 +303,8 @@ struct mei_msg_hdr {
        u32 me_addr:8;
        u32 host_addr:8;
        u32 length:9;
-       u32 reserved:4;
+       u32 reserved:3;
+       u32 extended:1;
        u32 dma_ring:1;
        u32 internal:1;
        u32 msg_complete:1;
@@ -212,8 +314,6 @@ struct mei_msg_hdr {
 /* The length is up to 9 bits */
 #define MEI_MSG_MAX_LEN_MASK GENMASK(9, 0)
 
-#define MEI_MSG_HDR_MAX 2
-
 struct mei_bus_message {
        u8 hbm_cmd;
        u8 data[];
@@ -299,13 +399,26 @@ struct hbm_host_enum_response {
        u8 valid_addresses[32];
 } __packed;
 
+/**
+ * struct mei_client_properties - mei client properties
+ *
+ * @protocol_name: guid of the client
+ * @protocol_version: client protocol version
+ * @max_number_of_connections: number of possible connections.
+ * @fixed_address: fixed me address (0 if the client is dynamic)
+ * @single_recv_buf: 1 if all connections share a single receive buffer.
+ * @vt_supported: the client support vtag
+ * @reserved: reserved
+ * @max_msg_length: MTU of the client
+ */
 struct mei_client_properties {
        uuid_le protocol_name;
        u8 protocol_version;
        u8 max_number_of_connections;
        u8 fixed_address;
        u8 single_recv_buf:1;
-       u8 reserved:7;
+       u8 vt_supported:1;
+       u8 reserved:6;
        u32 max_msg_length;
 } __packed;
 
@@ -533,4 +646,29 @@ struct hbm_dma_ring_ctrl {
        u32 reserved4;
 } __packed;
 
+/* virtual tag supported */
+#define HBM_CAP_VT BIT(0)
+
+/**
+ * struct hbm_capability_request - capability request from host to fw
+ *
+ * @hbm_cmd : bus message command header
+ * @capability_requested: bitmask of capabilities requested by host
+ */
+struct hbm_capability_request {
+       u8 hbm_cmd;
+       u8 capability_requested[3];
+} __packed;
+
+/**
+ * struct hbm_capability_response - capability response from fw to host
+ *
+ * @hbm_cmd : bus message command header
+ * @capability_granted: bitmask of capabilities granted by FW
+ */
+struct hbm_capability_response {
+       u8 hbm_cmd;
+       u8 capability_granted[3];
+} __packed;
+
 #endif
index c70a8c7..326955b 100644 (file)
@@ -61,16 +61,21 @@ static inline int mei_cl_hbm_equal(struct mei_cl *cl,
  *
  * @dev: mei device
  * @hdr: message header
+ * @discard_len: the length of the message to discard (excluding header)
  */
-static void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr)
+static void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr,
+                               size_t discard_len)
 {
-       if (hdr->dma_ring)
-               mei_dma_ring_read(dev, NULL, hdr->extension[0]);
+       if (hdr->dma_ring) {
+               mei_dma_ring_read(dev, NULL,
+                                 hdr->extension[dev->rd_msg_hdr_count - 2]);
+               discard_len = 0;
+       }
        /*
         * no need to check for size as it is guarantied
         * that length fits into rd_msg_buf
         */
-       mei_read_slots(dev, dev->rd_msg_buf, hdr->length);
+       mei_read_slots(dev, dev->rd_msg_buf, discard_len);
        dev_dbg(dev->dev, "discarding message " MEI_HDR_FMT "\n",
                MEI_HDR_PRM(hdr));
 }
@@ -80,18 +85,29 @@ static void mei_irq_discard_msg(struct mei_device *dev, struct mei_msg_hdr *hdr)
  *
  * @cl: reading client
  * @mei_hdr: header of mei client message
+ * @meta: extend meta header
  * @cmpl_list: completion list
  *
  * Return: always 0
  */
 static int mei_cl_irq_read_msg(struct mei_cl *cl,
                               struct mei_msg_hdr *mei_hdr,
+                              struct mei_ext_meta_hdr *meta,
                               struct list_head *cmpl_list)
 {
        struct mei_device *dev = cl->dev;
        struct mei_cl_cb *cb;
+
        size_t buf_sz;
        u32 length;
+       int ext_len;
+
+       length = mei_hdr->length;
+       ext_len = 0;
+       if (mei_hdr->extended) {
+               ext_len = sizeof(*meta) + mei_slots2data(meta->size);
+               length -= ext_len;
+       }
 
        cb = list_first_entry_or_null(&cl->rd_pending, struct mei_cl_cb, list);
        if (!cb) {
@@ -105,13 +121,50 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
                list_add_tail(&cb->list, &cl->rd_pending);
        }
 
+       if (mei_hdr->extended) {
+               struct mei_ext_hdr *ext;
+               struct mei_ext_hdr *vtag = NULL;
+
+               ext = mei_ext_begin(meta);
+               do {
+                       switch (ext->type) {
+                       case MEI_EXT_HDR_VTAG:
+                               vtag = ext;
+                               break;
+                       case MEI_EXT_HDR_NONE:
+                               fallthrough;
+                       default:
+                               cb->status = -EPROTO;
+                               break;
+                       }
+
+                       ext = mei_ext_next(ext);
+               } while (!mei_ext_last(meta, ext));
+
+               if (!vtag) {
+                       cl_dbg(dev, cl, "vtag not found in extended header.\n");
+                       cb->status = -EPROTO;
+                       goto discard;
+               }
+
+               cl_dbg(dev, cl, "vtag: %d\n", vtag->ext_payload[0]);
+               if (cb->vtag && cb->vtag != vtag->ext_payload[0]) {
+                       cl_err(dev, cl, "mismatched tag: %d != %d\n",
+                              cb->vtag, vtag->ext_payload[0]);
+                       cb->status = -EPROTO;
+                       goto discard;
+               }
+               cb->vtag = vtag->ext_payload[0];
+       }
+
        if (!mei_cl_is_connected(cl)) {
                cl_dbg(dev, cl, "not connected\n");
                cb->status = -ENODEV;
                goto discard;
        }
 
-       length = mei_hdr->dma_ring ? mei_hdr->extension[0] : mei_hdr->length;
+       if (mei_hdr->dma_ring)
+               length = mei_hdr->extension[mei_data2slots(ext_len)];
 
        buf_sz = length + cb->buf_idx;
        /* catch for integer overflow */
@@ -129,11 +182,13 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
                goto discard;
        }
 
-       if (mei_hdr->dma_ring)
+       if (mei_hdr->dma_ring) {
                mei_dma_ring_read(dev, cb->buf.data + cb->buf_idx, length);
-
-       /*  for DMA read 0 length to generate an interrupt to the device */
-       mei_read_slots(dev, cb->buf.data + cb->buf_idx, mei_hdr->length);
+               /*  for DMA read 0 length to generate interrupt to the device */
+               mei_read_slots(dev, cb->buf.data + cb->buf_idx, 0);
+       } else {
+               mei_read_slots(dev, cb->buf.data + cb->buf_idx, length);
+       }
 
        cb->buf_idx += length;
 
@@ -150,7 +205,7 @@ static int mei_cl_irq_read_msg(struct mei_cl *cl,
 discard:
        if (cb)
                list_move_tail(&cb->list, cmpl_list);
-       mei_irq_discard_msg(dev, mei_hdr);
+       mei_irq_discard_msg(dev, mei_hdr, length);
        return 0;
 }
 
@@ -265,11 +320,16 @@ int mei_irq_read_handler(struct mei_device *dev,
                         struct list_head *cmpl_list, s32 *slots)
 {
        struct mei_msg_hdr *mei_hdr;
+       struct mei_ext_meta_hdr *meta_hdr = NULL;
        struct mei_cl *cl;
        int ret;
+       u32 ext_meta_hdr_u32;
+       int i;
+       int ext_hdr_end;
 
        if (!dev->rd_msg_hdr[0]) {
                dev->rd_msg_hdr[0] = mei_read_hdr(dev);
+               dev->rd_msg_hdr_count = 1;
                (*slots)--;
                dev_dbg(dev->dev, "slots =%08x.\n", *slots);
 
@@ -292,10 +352,34 @@ int mei_irq_read_handler(struct mei_device *dev,
                goto end;
        }
 
+       ext_hdr_end = 1;
+
+       if (mei_hdr->extended) {
+               if (!dev->rd_msg_hdr[1]) {
+                       ext_meta_hdr_u32 = mei_read_hdr(dev);
+                       dev->rd_msg_hdr[1] = ext_meta_hdr_u32;
+                       dev->rd_msg_hdr_count++;
+                       (*slots)--;
+                       dev_dbg(dev->dev, "extended header is %08x\n",
+                               ext_meta_hdr_u32);
+               }
+               meta_hdr = ((struct mei_ext_meta_hdr *)
+                               dev->rd_msg_hdr + 1);
+               ext_hdr_end = meta_hdr->size + 2;
+               for (i = dev->rd_msg_hdr_count; i < ext_hdr_end; i++) {
+                       dev->rd_msg_hdr[i] = mei_read_hdr(dev);
+                       dev_dbg(dev->dev, "extended header %d is %08x\n", i,
+                               dev->rd_msg_hdr[i]);
+                       dev->rd_msg_hdr_count++;
+                       (*slots)--;
+               }
+       }
+
        if (mei_hdr->dma_ring) {
-               dev->rd_msg_hdr[1] = mei_read_hdr(dev);
+               dev->rd_msg_hdr[ext_hdr_end] = mei_read_hdr(dev);
+               dev->rd_msg_hdr_count++;
                (*slots)--;
-               mei_hdr->length = 0;
+               mei_hdr->length -= sizeof(dev->rd_msg_hdr[ext_hdr_end]);
        }
 
        /*  HBM message */
@@ -326,7 +410,7 @@ int mei_irq_read_handler(struct mei_device *dev,
                 */
                if (hdr_is_fixed(mei_hdr) ||
                    dev->dev_state == MEI_DEV_POWER_DOWN) {
-                       mei_irq_discard_msg(dev, mei_hdr);
+                       mei_irq_discard_msg(dev, mei_hdr, mei_hdr->length);
                        ret = 0;
                        goto reset_slots;
                }
@@ -336,12 +420,13 @@ int mei_irq_read_handler(struct mei_device *dev,
                goto end;
        }
 
-       ret = mei_cl_irq_read_msg(cl, mei_hdr, cmpl_list);
+       ret = mei_cl_irq_read_msg(cl, mei_hdr, meta_hdr, cmpl_list);
 
 
 reset_slots:
        /* reset the number of slots and header */
        memset(dev->rd_msg_hdr, 0, sizeof(dev->rd_msg_hdr));
+       dev->rd_msg_hdr_count = 0;
        *slots = mei_count_full_read_slots(dev);
        if (*slots == -EOVERFLOW) {
                /* overflow - reset */
index 86ef5c1..9f66820 100644 (file)
@@ -80,6 +80,27 @@ err_unlock:
        return err;
 }
 
+/**
+ * mei_cl_vtag_remove_by_fp - remove vtag that corresponds to fp from list
+ *
+ * @cl: host client
+ * @fp: pointer to file structure
+ *
+ */
+static void mei_cl_vtag_remove_by_fp(const struct mei_cl *cl,
+                                    const struct file *fp)
+{
+       struct mei_cl_vtag *vtag_l, *next;
+
+       list_for_each_entry_safe(vtag_l, next, &cl->vtag_map, list) {
+               if (vtag_l->fp == fp) {
+                       list_del(&vtag_l->list);
+                       kfree(vtag_l);
+                       return;
+               }
+       }
+}
+
 /**
  * mei_release - the release function
  *
@@ -101,17 +122,35 @@ static int mei_release(struct inode *inode, struct file *file)
 
        mutex_lock(&dev->device_lock);
 
+       mei_cl_vtag_remove_by_fp(cl, file);
+
+       if (!list_empty(&cl->vtag_map)) {
+               cl_dbg(dev, cl, "not the last vtag\n");
+               mei_cl_flush_queues(cl, file);
+               rets = 0;
+               goto out;
+       }
+
        rets = mei_cl_disconnect(cl);
+       /*
+        * Check again: This is necessary since disconnect releases the lock
+        * and another client can connect in the meantime.
+        */
+       if (!list_empty(&cl->vtag_map)) {
+               cl_dbg(dev, cl, "not the last vtag after disconnect\n");
+               mei_cl_flush_queues(cl, file);
+               goto out;
+       }
 
-       mei_cl_flush_queues(cl, file);
+       mei_cl_flush_queues(cl, NULL);
        cl_dbg(dev, cl, "removing\n");
 
        mei_cl_unlink(cl);
+       kfree(cl);
 
+out:
        file->private_data = NULL;
 
-       kfree(cl);
-
        mutex_unlock(&dev->device_lock);
        return rets;
 }
@@ -178,7 +217,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
 
        mutex_unlock(&dev->device_lock);
        if (wait_event_interruptible(cl->rx_wait,
-                                    !list_empty(&cl->rd_completed) ||
+                                    mei_cl_read_cb(cl, file) ||
                                     !mei_cl_is_connected(cl))) {
                if (signal_pending(current))
                        return -EINTR;
@@ -229,7 +268,7 @@ copy_buffer:
                goto out;
 
 free:
-       mei_io_cb_free(cb);
+       mei_cl_del_rd_completed(cl, cb);
        *offset = 0;
 
 out:
@@ -237,6 +276,28 @@ out:
        mutex_unlock(&dev->device_lock);
        return rets;
 }
+
+/**
+ * mei_cl_vtag_by_fp - obtain the vtag by file pointer
+ *
+ * @cl: host client
+ * @fp: pointer to file structure
+ *
+ * Return: vtag value on success, otherwise 0
+ */
+static u8 mei_cl_vtag_by_fp(const struct mei_cl *cl, const struct file *fp)
+{
+       struct mei_cl_vtag *cl_vtag;
+
+       if (!fp)
+               return 0;
+
+       list_for_each_entry(cl_vtag, &cl->vtag_map, list)
+               if (cl_vtag->fp == fp)
+                       return cl_vtag->vtag;
+       return 0;
+}
+
 /**
  * mei_write - the write function.
  *
@@ -314,6 +375,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
                rets = -ENOMEM;
                goto out;
        }
+       cb->vtag = mei_cl_vtag_by_fp(cl, file);
 
        rets = copy_from_user(cb->buf.data, ubuf, length);
        if (rets) {
@@ -333,17 +395,18 @@ out:
  * mei_ioctl_connect_client - the connect to fw client IOCTL function
  *
  * @file: private data of the file object
- * @data: IOCTL connect data, input and output parameters
+ * @in_client_uuid: requested UUID for connection
+ * @client: IOCTL connect data, output parameters
  *
  * Locking: called under "dev->device_lock" lock
  *
  * Return: 0 on success, <0 on failure.
  */
 static int mei_ioctl_connect_client(struct file *file,
-                       struct mei_connect_client_data *data)
+                                   const uuid_le *in_client_uuid,
+                                   struct mei_client *client)
 {
        struct mei_device *dev;
-       struct mei_client *client;
        struct mei_me_client *me_cl;
        struct mei_cl *cl;
        int rets;
@@ -351,18 +414,15 @@ static int mei_ioctl_connect_client(struct file *file,
        cl = file->private_data;
        dev = cl->dev;
 
-       if (dev->dev_state != MEI_DEV_ENABLED)
-               return -ENODEV;
-
        if (cl->state != MEI_FILE_INITIALIZING &&
            cl->state != MEI_FILE_DISCONNECTED)
                return  -EBUSY;
 
        /* find ME client we're trying to connect to */
-       me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
+       me_cl = mei_me_cl_by_uuid(dev, in_client_uuid);
        if (!me_cl) {
                dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n",
-                       &data->in_client_uuid);
+                       in_client_uuid);
                rets = -ENOTTY;
                goto end;
        }
@@ -372,7 +432,7 @@ static int mei_ioctl_connect_client(struct file *file,
                         !dev->allow_fixed_address : !dev->hbm_f_fa_supported;
                if (forbidden) {
                        dev_dbg(dev->dev, "Connection forbidden to FW Client UUID = %pUl\n",
-                               &data->in_client_uuid);
+                               in_client_uuid);
                        rets = -ENOTTY;
                        goto end;
                }
@@ -386,7 +446,6 @@ static int mei_ioctl_connect_client(struct file *file,
                        me_cl->props.max_msg_length);
 
        /* prepare the output buffer */
-       client = &data->out_client_properties;
        client->max_msg_length = me_cl->props.max_msg_length;
        client->protocol_version = me_cl->props.protocol_version;
        dev_dbg(dev->dev, "Can connect?\n");
@@ -398,6 +457,135 @@ end:
        return rets;
 }
 
+/**
+ * mei_vt_support_check - check if client support vtags
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * @dev: mei_device
+ * @uuid: client UUID
+ *
+ * Return:
+ *     0 - supported
+ *     -ENOTTY - no such client
+ *     -EOPNOTSUPP - vtags are not supported by client
+ */
+static int mei_vt_support_check(struct mei_device *dev, const uuid_le *uuid)
+{
+       struct mei_me_client *me_cl;
+       int ret;
+
+       if (!dev->hbm_f_vt_supported)
+               return -EOPNOTSUPP;
+
+       me_cl = mei_me_cl_by_uuid(dev, uuid);
+       if (!me_cl) {
+               dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n",
+                       uuid);
+               return -ENOTTY;
+       }
+       ret = me_cl->props.vt_supported ? 0 : -EOPNOTSUPP;
+       mei_me_cl_put(me_cl);
+
+       return ret;
+}
+
+/**
+ * mei_ioctl_connect_vtag - connect to fw client with vtag IOCTL function
+ *
+ * @file: private data of the file object
+ * @in_client_uuid: requested UUID for connection
+ * @client: IOCTL connect data, output parameters
+ * @vtag: vm tag
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
+ * Return: 0 on success, <0 on failure.
+ */
+static int mei_ioctl_connect_vtag(struct file *file,
+                                 const uuid_le *in_client_uuid,
+                                 struct mei_client *client,
+                                 u8 vtag)
+{
+       struct mei_device *dev;
+       struct mei_cl *cl;
+       struct mei_cl *pos;
+       struct mei_cl_vtag *cl_vtag;
+
+       cl = file->private_data;
+       dev = cl->dev;
+
+       dev_dbg(dev->dev, "FW Client %pUl vtag %d\n", in_client_uuid, vtag);
+
+       switch (cl->state) {
+       case MEI_FILE_DISCONNECTED:
+               if (mei_cl_vtag_by_fp(cl, file) != vtag) {
+                       dev_err(dev->dev, "reconnect with different vtag\n");
+                       return -EINVAL;
+               }
+               break;
+       case MEI_FILE_INITIALIZING:
+               /* malicious connect from another thread may push vtag */
+               if (!IS_ERR(mei_cl_fp_by_vtag(cl, vtag))) {
+                       dev_err(dev->dev, "vtag already filled\n");
+                       return -EINVAL;
+               }
+
+               list_for_each_entry(pos, &dev->file_list, link) {
+                       if (pos == cl)
+                               continue;
+                       if (!pos->me_cl)
+                               continue;
+
+                       /* only search for same UUID */
+                       if (uuid_le_cmp(*mei_cl_uuid(pos), *in_client_uuid))
+                               continue;
+
+                       /* if tag already exist try another fp */
+                       if (!IS_ERR(mei_cl_fp_by_vtag(pos, vtag)))
+                               continue;
+
+                       /* replace cl with acquired one */
+                       dev_dbg(dev->dev, "replacing with existing cl\n");
+                       mei_cl_unlink(cl);
+                       kfree(cl);
+                       file->private_data = pos;
+                       cl = pos;
+                       break;
+               }
+
+               cl_vtag = mei_cl_vtag_alloc(file, vtag);
+               if (IS_ERR(cl_vtag))
+                       return -ENOMEM;
+
+               list_add_tail(&cl_vtag->list, &cl->vtag_map);
+               break;
+       default:
+               return -EBUSY;
+       }
+
+       while (cl->state != MEI_FILE_INITIALIZING &&
+              cl->state != MEI_FILE_DISCONNECTED &&
+              cl->state != MEI_FILE_CONNECTED) {
+               mutex_unlock(&dev->device_lock);
+               wait_event_timeout(cl->wait,
+                                  (cl->state == MEI_FILE_CONNECTED ||
+                                   cl->state == MEI_FILE_DISCONNECTED ||
+                                   cl->state == MEI_FILE_DISCONNECT_REQUIRED ||
+                                   cl->state == MEI_FILE_DISCONNECT_REPLY),
+                                  mei_secs_to_jiffies(MEI_CL_CONNECT_TIMEOUT));
+               mutex_lock(&dev->device_lock);
+       }
+
+       if (!mei_cl_is_connected(cl))
+               return mei_ioctl_connect_client(file, in_client_uuid, client);
+
+       client->max_msg_length = cl->me_cl->props.max_msg_length;
+       client->protocol_version = cl->me_cl->props.protocol_version;
+
+       return 0;
+}
+
 /**
  * mei_ioctl_client_notify_request -
  *     propagate event notification request to client
@@ -454,7 +642,11 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
 {
        struct mei_device *dev;
        struct mei_cl *cl = file->private_data;
-       struct mei_connect_client_data connect_data;
+       struct mei_connect_client_data conn;
+       struct mei_connect_client_data_vtag conn_vtag;
+       const uuid_le *cl_uuid;
+       struct mei_client *props;
+       u8 vtag;
        u32 notify_get, notify_req;
        int rets;
 
@@ -475,20 +667,68 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
        switch (cmd) {
        case IOCTL_MEI_CONNECT_CLIENT:
                dev_dbg(dev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n");
-               if (copy_from_user(&connect_data, (char __user *)data,
-                                  sizeof(connect_data))) {
+               if (copy_from_user(&conn, (char __user *)data, sizeof(conn))) {
                        dev_dbg(dev->dev, "failed to copy data from userland\n");
                        rets = -EFAULT;
                        goto out;
                }
+               cl_uuid = &conn.in_client_uuid;
+               props = &conn.out_client_properties;
+               vtag = 0;
+
+               rets = mei_vt_support_check(dev, cl_uuid);
+               if (rets == -ENOTTY)
+                       goto out;
+               if (!rets)
+                       rets = mei_ioctl_connect_vtag(file, cl_uuid, props,
+                                                     vtag);
+               else
+                       rets = mei_ioctl_connect_client(file, cl_uuid, props);
+               if (rets)
+                       goto out;
+
+               /* if all is ok, copying the data back to user. */
+               if (copy_to_user((char __user *)data, &conn, sizeof(conn))) {
+                       dev_dbg(dev->dev, "failed to copy data to userland\n");
+                       rets = -EFAULT;
+                       goto out;
+               }
+
+               break;
+
+       case IOCTL_MEI_CONNECT_CLIENT_VTAG:
+               dev_dbg(dev->dev, "IOCTL_MEI_CONNECT_CLIENT_VTAG\n");
+               if (copy_from_user(&conn_vtag, (char __user *)data,
+                                  sizeof(conn_vtag))) {
+                       dev_dbg(dev->dev, "failed to copy data from userland\n");
+                       rets = -EFAULT;
+                       goto out;
+               }
+
+               cl_uuid = &conn_vtag.connect.in_client_uuid;
+               props = &conn_vtag.out_client_properties;
+               vtag = conn_vtag.connect.vtag;
+
+               rets = mei_vt_support_check(dev, cl_uuid);
+               if (rets == -EOPNOTSUPP)
+                       dev_dbg(dev->dev, "FW Client %pUl does not support vtags\n",
+                               cl_uuid);
+               if (rets)
+                       goto out;
+
+               if (!vtag) {
+                       dev_dbg(dev->dev, "vtag can't be zero\n");
+                       rets = -EINVAL;
+                       goto out;
+               }
 
-               rets = mei_ioctl_connect_client(file, &connect_data);
+               rets = mei_ioctl_connect_vtag(file, cl_uuid, props, vtag);
                if (rets)
                        goto out;
 
                /* if all is ok, copying the data back to user. */
-               if (copy_to_user((char __user *)data, &connect_data,
-                                sizeof(connect_data))) {
+               if (copy_to_user((char __user *)data, &conn_vtag,
+                                sizeof(conn_vtag))) {
                        dev_dbg(dev->dev, "failed to copy data to userland\n");
                        rets = -EFAULT;
                        goto out;
@@ -572,7 +812,7 @@ static __poll_t mei_poll(struct file *file, poll_table *wait)
        if (req_events & (EPOLLIN | EPOLLRDNORM)) {
                poll_wait(file, &cl->rx_wait, wait);
 
-               if (!list_empty(&cl->rd_completed))
+               if (mei_cl_read_cb(cl, file))
                        mask |= EPOLLIN | EPOLLRDNORM;
                else
                        mei_cl_read_start(cl, mei_cl_mtu(cl), file);
index d3a4f54..2f4cc1a 100644 (file)
@@ -174,6 +174,7 @@ struct mei_cl;
  * @fop_type: file operation type
  * @buf: buffer for data associated with the callback
  * @buf_idx: last read index
+ * @vtag: virtual tag
  * @fp: pointer to file structure
  * @status: io status of the cb
  * @internal: communication between driver and FW flag
@@ -185,12 +186,28 @@ struct mei_cl_cb {
        enum mei_cb_file_ops fop_type;
        struct mei_msg_data buf;
        size_t buf_idx;
+       u8 vtag;
        const struct file *fp;
        int status;
        u32 internal:1;
        u32 blocking:1;
 };
 
+/**
+ * struct mei_cl_vtag - file pointer to vtag mapping structure
+ *
+ * @list: link in map queue
+ * @fp: file pointer
+ * @vtag: corresponding vtag
+ * @pending_read: the read is pending on this file
+ */
+struct mei_cl_vtag {
+       struct list_head list;
+       const struct file *fp;
+       u8 vtag;
+       u8 pending_read:1;
+};
+
 /**
  * struct mei_cl - me client host representation
  *    carried in file->private_data
@@ -207,6 +224,7 @@ struct mei_cl_cb {
  * @me_cl: fw client connected
  * @fp: file associated with client
  * @host_client_id: host id
+ * @vtag_map: vtag map
  * @tx_flow_ctrl_creds: transmit flow credentials
  * @rx_flow_ctrl_creds: receive flow credentials
  * @timer_count:  watchdog timer for operation completion
@@ -215,6 +233,7 @@ struct mei_cl_cb {
  * @tx_cb_queued: number of tx callbacks in queue
  * @writing_state: state of the tx
  * @rd_pending: pending read credits
+ * @rd_completed_lock: protects rd_completed queue
  * @rd_completed: completed read
  *
  * @cldev: device on the mei client bus
@@ -232,6 +251,7 @@ struct mei_cl {
        struct mei_me_client *me_cl;
        const struct file *fp;
        u8 host_client_id;
+       struct list_head vtag_map;
        u8 tx_flow_ctrl_creds;
        u8 rx_flow_ctrl_creds;
        u8 timer_count;
@@ -240,6 +260,7 @@ struct mei_cl {
        u8 tx_cb_queued;
        enum mei_file_transaction_states writing_state;
        struct list_head rd_pending;
+       spinlock_t rd_completed_lock; /* protects rd_completed queue */
        struct list_head rd_completed;
 
        struct mei_cl_device *cldev;
@@ -413,6 +434,7 @@ struct mei_fw_version {
  *
  * @rd_msg_buf  : control messages buffer
  * @rd_msg_hdr  : read message header storage
+ * @rd_msg_hdr_count : how many dwords were already read from header
  *
  * @hbuf_is_ready : query if the host host/write buffer is ready
  * @dr_dscr: DMA ring descriptors: TX, RX, and CTRL
@@ -426,6 +448,8 @@ struct mei_fw_version {
  * @hbm_f_ie_supported  : hbm feature immediate reply to enum request
  * @hbm_f_os_supported  : hbm feature support OS ver message
  * @hbm_f_dr_supported  : hbm feature dma ring supported
+ * @hbm_f_vt_supported  : hbm feature vtag supported
+ * @hbm_f_cap_supported : hbm feature capabilities message supported
  *
  * @fw_ver : FW versions
  *
@@ -494,7 +518,8 @@ struct mei_device {
 #endif /* CONFIG_PM */
 
        unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE];
-       u32 rd_msg_hdr[MEI_MSG_HDR_MAX];
+       u32 rd_msg_hdr[MEI_RD_MSG_BUF_SIZE];
+       int rd_msg_hdr_count;
 
        /* write buffer */
        bool hbuf_is_ready;
@@ -510,6 +535,8 @@ struct mei_device {
        unsigned int hbm_f_ie_supported:1;
        unsigned int hbm_f_os_supported:1;
        unsigned int hbm_f_dr_supported:1;
+       unsigned int hbm_f_vt_supported:1;
+       unsigned int hbm_f_cap_supported:1;
 
        struct mei_fw_version fw_ver[MEI_MAX_FW_VER_BLOCKS];
 
@@ -746,10 +773,11 @@ static inline void mei_dbgfs_deregister(struct mei_device *dev) {}
 int mei_register(struct mei_device *dev, struct device *parent);
 void mei_deregister(struct mei_device *dev);
 
-#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d internal=%1d comp=%1d"
+#define MEI_HDR_FMT "hdr:host=%02d me=%02d len=%d dma=%1d ext=%1d internal=%1d comp=%1d"
 #define MEI_HDR_PRM(hdr)                  \
        (hdr)->host_addr, (hdr)->me_addr, \
-       (hdr)->length, (hdr)->dma_ring, (hdr)->internal, (hdr)->msg_complete
+       (hdr)->length, (hdr)->dma_ring, (hdr)->extended, \
+       (hdr)->internal, (hdr)->msg_complete
 
 ssize_t mei_fw_status2str(struct mei_fw_status *fw_sts, char *buf, size_t len);
 /**
index 9cc6b2a..304d6c8 100644 (file)
@@ -178,7 +178,7 @@ int scif_close(scif_epd_t epd)
        case SCIFEP_ZOMBIE:
                dev_err(scif_info.mdev.this_device,
                        "SCIFAPI close: zombie state unexpected\n");
-               /* fall through */
+               fallthrough;
        case SCIFEP_DISCONNECTED:
                spin_unlock(&ep->lock);
                scif_unregister_all_windows(epd);
@@ -645,7 +645,7 @@ int __scif_connect(scif_epd_t epd, struct scif_port_id *dst, bool non_block)
                ep->port.port = err;
                ep->port.node = scif_info.nodeid;
                ep->conn_async_state = ASYNC_CONN_IDLE;
-               /* Fall through */
+               fallthrough;
        case SCIFEP_BOUND:
                /*
                 * If a non-blocking connect has been already initiated
index e0748be..384ce08 100644 (file)
@@ -363,7 +363,7 @@ scif_p2p_setsg(phys_addr_t pa, int page_size, int page_cnt)
        struct page *page;
        int i;
 
-       sg = kcalloc(page_cnt, sizeof(struct scatterlist), GFP_KERNEL);
+       sg = kmalloc_array(page_cnt, sizeof(struct scatterlist), GFP_KERNEL);
        if (!sg)
                return NULL;
        sg_init_table(sg, page_cnt);
index de8f61e..18fb9d8 100644 (file)
@@ -657,7 +657,7 @@ int scif_unregister_window(struct scif_window *window)
                window->unreg_state = OP_IN_PROGRESS;
                send_msg = true;
        }
-               /* fall through */
+               fallthrough;
        case OP_IN_PROGRESS:
        {
                scif_get_window(window, 1);
@@ -1392,6 +1392,8 @@ retry:
                                (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);
@@ -1408,7 +1410,6 @@ retry:
 
        if (pinned_pages->nr_pages < nr_pages) {
                err = -EFAULT;
-               pinned_pages->nr_pages = nr_pages;
                goto dec_pinned;
        }
 
@@ -1421,7 +1422,6 @@ dec_pinned:
                __scif_dec_pinned_vm_lock(mm, nr_pages);
        /* Something went wrong! Rollback */
 error_unmap:
-       pinned_pages->nr_pages = nr_pages;
        scif_destroy_pinned_pages(pinned_pages);
        *pages = NULL;
        dev_dbg(scif_info.mdev.this_device,
index a6e1a89..e16a5e5 100644 (file)
@@ -143,13 +143,7 @@ static void pvpanic_unregister_acpi_driver(void) {}
 
 static int pvpanic_mmio_probe(struct platform_device *pdev)
 {
-       struct resource *mem;
-
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!mem)
-               return -EINVAL;
-
-       base = devm_ioremap_resource(&pdev->dev, mem);
+       base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(base))
                return PTR_ERR(base);
 
index f6e600b..0ea923f 100644 (file)
@@ -622,7 +622,7 @@ static int send_noop_message(void *cb, struct gru_message_queue_desc *mqd,
                        break;
                case CBSS_PAGE_OVERFLOW:
                        STAT(mesq_noop_page_overflow);
-                       /* fall through */
+                       fallthrough;
                default:
                        BUG();
                }
@@ -780,7 +780,7 @@ static int send_message_failure(void *cb, struct gru_message_queue_desc *mqd,
                break;
        case CBSS_PAGE_OVERFLOW:
                STAT(mesq_page_overflow);
-               /* fall through */
+               fallthrough;
        default:
                BUG();
        }
index d5e097c..8a495dc 100644 (file)
@@ -1173,7 +1173,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
                if (!xpc_kdebug_ignore)
                        break;
 
-               /* fall through */
+               fallthrough;
        case DIE_MCA_MONARCH_ENTER:
        case DIE_INIT_MONARCH_ENTER:
                xpc_arch_ops.offline_heartbeat();
@@ -1184,7 +1184,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
                if (!xpc_kdebug_ignore)
                        break;
 
-               /* fall through */
+               fallthrough;
        case DIE_MCA_MONARCH_LEAVE:
        case DIE_INIT_MONARCH_LEAVE:
                xpc_arch_ops.online_heartbeat();
index 21a04bc..099a53b 100644 (file)
@@ -441,10 +441,10 @@ xpc_discovery(void)
                switch (region_size) {
                case 128:
                        max_regions *= 2;
-                       /* fall through */
+                       fallthrough;
                case 64:
                        max_regions *= 2;
-                       /* fall through */
+                       fallthrough;
                case 32:
                        max_regions *= 2;
                        region_size = 16;
index 98c60f1..7791bde 100644 (file)
@@ -574,7 +574,7 @@ xpc_handle_activate_mq_msg_uv(struct xpc_partition *part,
 
                xpc_wakeup_channel_mgr(part);
        }
-               /* fall through */
+               fallthrough;
        case XPC_ACTIVATE_MQ_MSG_MARK_ENGAGED_UV:
                spin_lock_irqsave(&part_uv->flags_lock, irq_flags);
                part_uv->flags |= XPC_P_ENGAGED_UV;
index a5b8dab..a9da7b1 100644 (file)
@@ -370,7 +370,7 @@ static struct attribute *uacce_dev_attrs[] = {
 static umode_t uacce_dev_is_visible(struct kobject *kobj,
                                    struct attribute *attr, int n)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct uacce_device *uacce = to_uacce_device(dev);
 
        if (((attr == &dev_attr_region_mmio_size.attr) &&
index 8531ae7..c490658 100644 (file)
@@ -657,8 +657,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
        if (retval < (int)produce_q->kernel_if->num_pages) {
                pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
                        retval);
-               qp_release_pages(produce_q->kernel_if->u.h.header_page,
-                                retval, false);
+               if (retval > 0)
+                       qp_release_pages(produce_q->kernel_if->u.h.header_page,
+                                       retval, false);
                err = VMCI_ERROR_NO_MEM;
                goto out;
        }
@@ -670,8 +671,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
        if (retval < (int)consume_q->kernel_if->num_pages) {
                pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
                        retval);
-               qp_release_pages(consume_q->kernel_if->u.h.header_page,
-                                retval, false);
+               if (retval > 0)
+                       qp_release_pages(consume_q->kernel_if->u.h.header_page,
+                                       retval, false);
                qp_release_pages(produce_q->kernel_if->u.h.header_page,
                                 produce_q->kernel_if->num_pages, false);
                err = VMCI_ERROR_NO_MEM;
index ce43f75..c8fae66 100644 (file)
@@ -191,7 +191,7 @@ int mmc_of_parse(struct mmc_host *host)
        switch (bus_width) {
        case 8:
                host->caps |= MMC_CAP_8_BIT_DATA;
-               /* fall through - Hosts capable of 8-bit can also do 4 bits */
+               fallthrough;    /* Hosts capable of 8-bit can also do 4 bits */
        case 4:
                host->caps |= MMC_CAP_4_BIT_DATA;
                break;
index 93d346c..4c229dd 100644 (file)
@@ -121,6 +121,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
        struct sg_table sgtable;
        unsigned int nents, left_size, i;
        unsigned int seg_size = card->host->max_seg_size;
+       int err;
 
        WARN_ON(blksz == 0);
 
@@ -170,28 +171,32 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
 
        mmc_set_data_timeout(&data, card);
 
-       mmc_wait_for_req(card->host, &mrq);
+       mmc_pre_req(card->host, &mrq);
 
-       if (nents > 1)
-               sg_free_table(&sgtable);
+       mmc_wait_for_req(card->host, &mrq);
 
        if (cmd.error)
-               return cmd.error;
-       if (data.error)
-               return data.error;
-
-       if (mmc_host_is_spi(card->host)) {
+               err = cmd.error;
+       else if (data.error)
+               err = data.error;
+       else if (mmc_host_is_spi(card->host))
                /* host driver already reported errors */
-       } else {
-               if (cmd.resp[0] & R5_ERROR)
-                       return -EIO;
-               if (cmd.resp[0] & R5_FUNCTION_NUMBER)
-                       return -EINVAL;
-               if (cmd.resp[0] & R5_OUT_OF_RANGE)
-                       return -ERANGE;
-       }
+               err = 0;
+       else if (cmd.resp[0] & R5_ERROR)
+               err = -EIO;
+       else if (cmd.resp[0] & R5_FUNCTION_NUMBER)
+               err = -EINVAL;
+       else if (cmd.resp[0] & R5_OUT_OF_RANGE)
+               err = -ERANGE;
+       else
+               err = 0;
 
-       return 0;
+       mmc_post_req(card->host, &mrq, err);
+
+       if (nents > 1)
+               sg_free_table(&sgtable);
+
+       return err;
 }
 
 int sdio_reset(struct mmc_host *host)
index 9c89a5b..9a34c82 100644 (file)
@@ -602,7 +602,7 @@ config MMC_GOLDFISH
 
 config MMC_SPI
        tristate "MMC/SD/SDIO over SPI"
-       depends on SPI_MASTER && HAS_DMA
+       depends on SPI_MASTER
        select CRC7
        select CRC_ITU_T
        help
index 3009014..3fc3bbe 100644 (file)
@@ -2418,7 +2418,7 @@ static void atmci_get_cap(struct atmel_mci *host)
        case 0x600:
        case 0x500:
                host->caps.has_odd_clk_div = 1;
-               /* Fall through */
+               fallthrough;
        case 0x400:
        case 0x300:
                host->caps.has_dma_conf_reg = 1;
@@ -2426,16 +2426,16 @@ static void atmci_get_cap(struct atmel_mci *host)
                host->caps.has_cfg_reg = 1;
                host->caps.has_cstor_reg = 1;
                host->caps.has_highspeed = 1;
-               /* Fall through */
+               fallthrough;
        case 0x200:
                host->caps.has_rwproof = 1;
                host->caps.need_blksz_mul_4 = 0;
                host->caps.need_notbusy_for_read_ops = 1;
-               /* Fall through */
+               fallthrough;
        case 0x100:
                host->caps.has_bad_data_ordering = 0;
                host->caps.need_reset_after_xfer = 0;
-               /* Fall through */
+               fallthrough;
        case 0x0:
                break;
        default:
index f01fecd..e50a08b 100644 (file)
@@ -300,7 +300,7 @@ static void mmc_davinci_start_command(struct mmc_davinci_host *host,
                 * then it's harmless for us to allow it.
                 */
                cmd_reg |= MMCCMD_BSYEXP;
-               /* FALLTHROUGH */
+               fallthrough;
        case MMC_RSP_R1:                /* 48 bits, CRC */
                cmd_reg |= MMCCMD_RSPFMT_R1456;
                break;
index 50977ff..db1a84b 100644 (file)
@@ -238,7 +238,7 @@ static void dw_mci_hs_set_timing(struct dw_mci *host, int timing,
                if (smpl_phase >= USE_DLY_MIN_SMPL &&
                                smpl_phase <= USE_DLY_MAX_SMPL)
                        use_smpl_dly = 1;
-                       /* fallthrough */
+               fallthrough;
        case MMC_TIMING_UHS_SDR50:
                if (smpl_phase >= ENABLE_SHIFT_MIN_SMPL &&
                                smpl_phase <= ENABLE_SHIFT_MAX_SMPL)
index 35ae573..0fba940 100644 (file)
@@ -2030,7 +2030,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
                        }
 
                        prev_state = state = STATE_SENDING_DATA;
-                       /* fall through */
+                       fallthrough;
 
                case STATE_SENDING_DATA:
                        /*
@@ -2088,7 +2088,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
                        }
                        prev_state = state = STATE_DATA_BUSY;
 
-                       /* fall through */
+                       fallthrough;
 
                case STATE_DATA_BUSY:
                        if (!dw_mci_clear_pending_data_complete(host)) {
@@ -2141,7 +2141,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
                         */
                        prev_state = state = STATE_SENDING_STOP;
 
-                       /* fall through */
+                       fallthrough;
 
                case STATE_SENDING_STOP:
                        if (!dw_mci_clear_pending_cmd_complete(host))
index 447552a..81d7101 100644 (file)
@@ -739,7 +739,7 @@ static irqreturn_t jz_mmc_irq_worker(int irq, void *devid)
                        break;
 
                jz_mmc_prepare_data_transfer(host);
-               /* fall through */
+               fallthrough;
 
        case JZ4740_MMC_STATE_TRANSFER_DATA:
                if (host->use_dma) {
@@ -774,7 +774,7 @@ static irqreturn_t jz_mmc_irq_worker(int irq, void *devid)
                        break;
                }
                jz4740_mmc_write_irq_reg(host, JZ_MMC_IRQ_DATA_TRAN_DONE);
-               /* fall through */
+               fallthrough;
 
        case JZ4740_MMC_STATE_SEND_STOP:
                if (!req->stop)
index 9b2cf7a..703d583 100644 (file)
@@ -294,7 +294,7 @@ static void meson_mx_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        switch (ios->power_mode) {
        case MMC_POWER_OFF:
                vdd = 0;
-               /* fall through */
+               fallthrough;
        case MMC_POWER_UP:
                if (!IS_ERR(mmc->supply.vmmc)) {
                        host->error = mmc_regulator_set_ocr(mmc,
index 39bb1e3..5055a7e 100644 (file)
@@ -1278,6 +1278,52 @@ mmc_spi_detect_irq(int irq, void *mmc)
        return IRQ_HANDLED;
 }
 
+#ifdef CONFIG_HAS_DMA
+static int mmc_spi_dma_alloc(struct mmc_spi_host *host)
+{
+       struct spi_device *spi = host->spi;
+       struct device *dev;
+
+       if (!spi->master->dev.parent->dma_mask)
+               return 0;
+
+       dev = spi->master->dev.parent;
+
+       host->ones_dma = dma_map_single(dev, host->ones, MMC_SPI_BLOCKSIZE,
+                                       DMA_TO_DEVICE);
+       if (dma_mapping_error(dev, host->ones_dma))
+               return -ENOMEM;
+
+       host->data_dma = dma_map_single(dev, host->data, sizeof(*host->data),
+                                       DMA_BIDIRECTIONAL);
+       if (dma_mapping_error(dev, host->data_dma)) {
+               dma_unmap_single(dev, host->ones_dma, MMC_SPI_BLOCKSIZE,
+                                DMA_TO_DEVICE);
+               return -ENOMEM;
+       }
+
+       dma_sync_single_for_cpu(dev, host->data_dma, sizeof(*host->data),
+                               DMA_BIDIRECTIONAL);
+
+       host->dma_dev = dev;
+       return 0;
+}
+
+static void mmc_spi_dma_free(struct mmc_spi_host *host)
+{
+       if (!host->dma_dev)
+               return;
+
+       dma_unmap_single(host->dma_dev, host->ones_dma, MMC_SPI_BLOCKSIZE,
+                        DMA_TO_DEVICE);
+       dma_unmap_single(host->dma_dev, host->data_dma, sizeof(*host->data),
+                        DMA_BIDIRECTIONAL);
+}
+#else
+static inline mmc_spi_dma_alloc(struct mmc_spi_host *host) { return 0; }
+static inline void mmc_spi_dma_free(struct mmc_spi_host *host) {}
+#endif
+
 static int mmc_spi_probe(struct spi_device *spi)
 {
        void                    *ones;
@@ -1374,23 +1420,9 @@ static int mmc_spi_probe(struct spi_device *spi)
        if (!host->data)
                goto fail_nobuf1;
 
-       if (spi->master->dev.parent->dma_mask) {
-               struct device   *dev = spi->master->dev.parent;
-
-               host->dma_dev = dev;
-               host->ones_dma = dma_map_single(dev, ones,
-                               MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
-               if (dma_mapping_error(dev, host->ones_dma))
-                       goto fail_ones_dma;
-               host->data_dma = dma_map_single(dev, host->data,
-                               sizeof(*host->data), DMA_BIDIRECTIONAL);
-               if (dma_mapping_error(dev, host->data_dma))
-                       goto fail_data_dma;
-
-               dma_sync_single_for_cpu(host->dma_dev,
-                               host->data_dma, sizeof(*host->data),
-                               DMA_BIDIRECTIONAL);
-       }
+       status = mmc_spi_dma_alloc(host);
+       if (status)
+               goto fail_dma;
 
        /* setup message for status/busy readback */
        spi_message_init(&host->readback);
@@ -1458,20 +1490,12 @@ static int mmc_spi_probe(struct spi_device *spi)
 fail_add_host:
        mmc_remove_host(mmc);
 fail_glue_init:
-       if (host->dma_dev)
-               dma_unmap_single(host->dma_dev, host->data_dma,
-                               sizeof(*host->data), DMA_BIDIRECTIONAL);
-fail_data_dma:
-       if (host->dma_dev)
-               dma_unmap_single(host->dma_dev, host->ones_dma,
-                               MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
-fail_ones_dma:
+       mmc_spi_dma_free(host);
+fail_dma:
        kfree(host->data);
-
 fail_nobuf1:
        mmc_free_host(mmc);
        mmc_spi_put_pdata(spi);
-
 nomem:
        kfree(ones);
        return status;
@@ -1489,13 +1513,7 @@ static int mmc_spi_remove(struct spi_device *spi)
 
        mmc_remove_host(mmc);
 
-       if (host->dma_dev) {
-               dma_unmap_single(host->dma_dev, host->ones_dma,
-                       MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
-               dma_unmap_single(host->dma_dev, host->data_dma,
-                       sizeof(*host->data), DMA_BIDIRECTIONAL);
-       }
-
+       mmc_spi_dma_free(host);
        kfree(host->data);
        kfree(host->ones);
 
index 4e2583f..b0c2794 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
+#include <linux/reset.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/core.h>
@@ -419,6 +420,7 @@ struct msdc_host {
        struct pinctrl_state *pins_uhs;
        struct delayed_work req_timeout;
        int irq;                /* host interrupt */
+       struct reset_control *reset;
 
        struct clk *src_clk;    /* msdc source clock */
        struct clk *h_clk;      /* msdc h_clk */
@@ -1592,6 +1594,12 @@ static void msdc_init_hw(struct msdc_host *host)
        u32 val;
        u32 tune_reg = host->dev_comp->pad_tune_reg;
 
+       if (host->reset) {
+               reset_control_assert(host->reset);
+               usleep_range(10, 50);
+               reset_control_deassert(host->reset);
+       }
+
        /* Configure to MMC/SD mode, clock free running */
        sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_MODE | MSDC_CFG_CKPDN);
 
@@ -2390,6 +2398,11 @@ static int msdc_drv_probe(struct platform_device *pdev)
        if (IS_ERR(host->src_clk_cg))
                host->src_clk_cg = NULL;
 
+       host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
+                                                               "hrst");
+       if (IS_ERR(host->reset))
+               return PTR_ERR(host->reset);
+
        host->irq = platform_get_irq(pdev, 0);
        if (host->irq < 0) {
                ret = -EINVAL;
index 15e2189..904f523 100644 (file)
@@ -685,7 +685,7 @@ static int renesas_sdhi_write16_hook(struct tmio_mmc_host *host, int addr)
        case HOST_MODE:
                if (host->pdata->flags & TMIO_MMC_HAVE_CBSY)
                        bit = TMIO_STAT_CMD_BUSY;
-               /* fallthrough */
+               fallthrough;
        case CTL_SD_CARD_CLK_CTL:
                return renesas_sdhi_wait_idle(host, bit);
        }
index 48ecbd0..284cba1 100644 (file)
@@ -535,6 +535,11 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_qcom_sd = {
        .caps    = MMC_CAP_NONREMOVABLE,
 };
 
+struct amd_sdhci_host {
+       bool    tuned_clock;
+       bool    dll_enabled;
+};
+
 /* AMD sdhci reset dll register. */
 #define SDHCI_AMD_RESET_DLL_REGISTER    0x908
 
@@ -546,39 +551,96 @@ static int amd_select_drive_strength(struct mmc_card *card,
        return MMC_SET_DRIVER_TYPE_A;
 }
 
-static void sdhci_acpi_amd_hs400_dll(struct sdhci_host *host)
+static void sdhci_acpi_amd_hs400_dll(struct sdhci_host *host, bool enable)
 {
+       struct sdhci_acpi_host *acpi_host = sdhci_priv(host);
+       struct amd_sdhci_host *amd_host = sdhci_acpi_priv(acpi_host);
+
        /* AMD Platform requires dll setting */
        sdhci_writel(host, 0x40003210, SDHCI_AMD_RESET_DLL_REGISTER);
        usleep_range(10, 20);
-       sdhci_writel(host, 0x40033210, SDHCI_AMD_RESET_DLL_REGISTER);
+       if (enable)
+               sdhci_writel(host, 0x40033210, SDHCI_AMD_RESET_DLL_REGISTER);
+
+       amd_host->dll_enabled = enable;
 }
 
 /*
- * For AMD Platform it is required to disable the tuning
- * bit first controller to bring to HS Mode from HS200
- * mode, later enable to tune to HS400 mode.
+ * The initialization sequence for HS400 is:
+ *     HS->HS200->Perform Tuning->HS->HS400
+ *
+ * The re-tuning sequence is:
+ *     HS400->DDR52->HS->HS200->Perform Tuning->HS->HS400
+ *
+ * The AMD eMMC Controller can only use the tuned clock while in HS200 and HS400
+ * mode. If we switch to a different mode, we need to disable the tuned clock.
+ * If we have previously performed tuning and switch back to HS200 or
+ * HS400, we can re-enable the tuned clock.
+ *
  */
 static void amd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
        struct sdhci_host *host = mmc_priv(mmc);
+       struct sdhci_acpi_host *acpi_host = sdhci_priv(host);
+       struct amd_sdhci_host *amd_host = sdhci_acpi_priv(acpi_host);
        unsigned int old_timing = host->timing;
+       u16 val;
 
        sdhci_set_ios(mmc, ios);
-       if (old_timing == MMC_TIMING_MMC_HS200 &&
-           ios->timing == MMC_TIMING_MMC_HS)
-               sdhci_writew(host, 0x9, SDHCI_HOST_CONTROL2);
-       if (old_timing != MMC_TIMING_MMC_HS400 &&
-           ios->timing == MMC_TIMING_MMC_HS400) {
-               sdhci_writew(host, 0x80, SDHCI_HOST_CONTROL2);
-               sdhci_acpi_amd_hs400_dll(host);
+
+       if (old_timing != host->timing && amd_host->tuned_clock) {
+               if (host->timing == MMC_TIMING_MMC_HS400 ||
+                   host->timing == MMC_TIMING_MMC_HS200) {
+                       val = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+                       val |= SDHCI_CTRL_TUNED_CLK;
+                       sdhci_writew(host, val, SDHCI_HOST_CONTROL2);
+               } else {
+                       val = sdhci_readw(host, SDHCI_HOST_CONTROL2);
+                       val &= ~SDHCI_CTRL_TUNED_CLK;
+                       sdhci_writew(host, val, SDHCI_HOST_CONTROL2);
+               }
+
+               /* DLL is only required for HS400 */
+               if (host->timing == MMC_TIMING_MMC_HS400 &&
+                   !amd_host->dll_enabled)
+                       sdhci_acpi_amd_hs400_dll(host, true);
+       }
+}
+
+static int amd_sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
+{
+       int err;
+       struct sdhci_host *host = mmc_priv(mmc);
+       struct sdhci_acpi_host *acpi_host = sdhci_priv(host);
+       struct amd_sdhci_host *amd_host = sdhci_acpi_priv(acpi_host);
+
+       amd_host->tuned_clock = false;
+
+       err = sdhci_execute_tuning(mmc, opcode);
+
+       if (!err && !host->tuning_err)
+               amd_host->tuned_clock = true;
+
+       return err;
+}
+
+static void amd_sdhci_reset(struct sdhci_host *host, u8 mask)
+{
+       struct sdhci_acpi_host *acpi_host = sdhci_priv(host);
+       struct amd_sdhci_host *amd_host = sdhci_acpi_priv(acpi_host);
+
+       if (mask & SDHCI_RESET_ALL) {
+               amd_host->tuned_clock = false;
+               sdhci_acpi_amd_hs400_dll(host, false);
        }
+
+       sdhci_reset(host, mask);
 }
 
 static const struct sdhci_ops sdhci_acpi_ops_amd = {
        .set_clock      = sdhci_set_clock,
        .set_bus_width  = sdhci_set_bus_width,
-       .reset          = sdhci_reset,
+       .reset          = amd_sdhci_reset,
        .set_uhs_signaling = sdhci_set_uhs_signaling,
 };
 
@@ -602,6 +664,7 @@ static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev,
 
        host->mmc_host_ops.select_drive_strength = amd_select_drive_strength;
        host->mmc_host_ops.set_ios = amd_set_ios;
+       host->mmc_host_ops.execute_tuning = amd_sdhci_execute_tuning;
        return 0;
 }
 
@@ -613,6 +676,7 @@ static const struct sdhci_acpi_slot sdhci_acpi_slot_amd_emmc = {
                          SDHCI_QUIRK_32BIT_ADMA_SIZE,
        .quirks2        = SDHCI_QUIRK2_BROKEN_64_BIT_DMA,
        .probe_slot     = sdhci_acpi_emmc_amd_probe_slot,
+       .priv_size      = sizeof(struct amd_sdhci_host),
 };
 
 struct sdhci_acpi_uid_slot {
index a76b451..d738907 100644 (file)
@@ -1556,7 +1556,7 @@ static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
                                "failed to request card-detect gpio!\n");
                        return err;
                }
-               /* fall through */
+               fallthrough;
 
        case ESDHC_CD_CONTROLLER:
                /* we have a working card_detect back */
index 5a33389..729868a 100644 (file)
@@ -1166,7 +1166,7 @@ static void sdhci_msm_set_cdr(struct sdhci_host *host, bool enable)
 static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode)
 {
        struct sdhci_host *host = mmc_priv(mmc);
-       int tuning_seq_cnt = 3;
+       int tuning_seq_cnt = 10;
        u8 phase, tuned_phases[16], tuned_phase_cnt = 0;
        int rc;
        struct mmc_ios ios = host->mmc->ios;
@@ -1222,6 +1222,22 @@ retry:
        } while (++phase < ARRAY_SIZE(tuned_phases));
 
        if (tuned_phase_cnt) {
+               if (tuned_phase_cnt == ARRAY_SIZE(tuned_phases)) {
+                       /*
+                        * All phases valid is _almost_ as bad as no phases
+                        * valid.  Probably all phases are not really reliable
+                        * but we didn't detect where the unreliable place is.
+                        * That means we'll essentially be guessing and hoping
+                        * we get a good phase.  Better to try a few times.
+                        */
+                       dev_dbg(mmc_dev(mmc), "%s: All phases valid; try again\n",
+                               mmc_hostname(mmc));
+                       if (--tuning_seq_cnt) {
+                               tuned_phase_cnt = 0;
+                               goto retry;
+                       }
+               }
+
                rc = msm_find_most_appropriate_phase(host, tuned_phases,
                                                     tuned_phase_cnt);
                if (rc < 0)
index 7c73d24..45881b3 100644 (file)
@@ -81,6 +81,7 @@ struct sdhci_esdhc {
        bool quirk_tuning_erratum_type2;
        bool quirk_ignore_data_inhibit;
        bool quirk_delay_before_data_reset;
+       bool quirk_trans_complete_erratum;
        bool in_sw_tuning;
        unsigned int peripheral_clock;
        const struct esdhc_clk_fixup *clk_fixup;
@@ -1177,10 +1178,11 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host,
 
 static u32 esdhc_irq(struct sdhci_host *host, u32 intmask)
 {
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+       struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
        u32 command;
 
-       if (of_find_compatible_node(NULL, NULL,
-                               "fsl,p2020-esdhc")) {
+       if (esdhc->quirk_trans_complete_erratum) {
                command = SDHCI_GET_CMD(sdhci_readw(host,
                                        SDHCI_COMMAND));
                if (command == MMC_WRITE_MULTIPLE_BLOCK &&
@@ -1334,8 +1336,10 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
                esdhc->clk_fixup = match->data;
        np = pdev->dev.of_node;
 
-       if (of_device_is_compatible(np, "fsl,p2020-esdhc"))
+       if (of_device_is_compatible(np, "fsl,p2020-esdhc")) {
                esdhc->quirk_delay_before_data_reset = true;
+               esdhc->quirk_trans_complete_erratum = true;
+       }
 
        clk = of_clk_get(np, 0);
        if (!IS_ERR(clk)) {
index bb68024..af41380 100644 (file)
@@ -232,6 +232,14 @@ static void sdhci_pci_dumpregs(struct mmc_host *mmc)
        sdhci_dumpregs(mmc_priv(mmc));
 }
 
+static void sdhci_cqhci_reset(struct sdhci_host *host, u8 mask)
+{
+       if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) &&
+           host->mmc->cqe_private)
+               cqhci_deactivate(host->mmc);
+       sdhci_reset(host, mask);
+}
+
 /*****************************************************************************\
  *                                                                           *
  * Hardware specific quirk handling                                          *
@@ -718,7 +726,7 @@ static const struct sdhci_ops sdhci_intel_glk_ops = {
        .set_power              = sdhci_intel_set_power,
        .enable_dma             = sdhci_pci_enable_dma,
        .set_bus_width          = sdhci_set_bus_width,
-       .reset                  = sdhci_reset,
+       .reset                  = sdhci_cqhci_reset,
        .set_uhs_signaling      = sdhci_set_uhs_signaling,
        .hw_reset               = sdhci_pci_hw_reset,
        .irq                    = sdhci_cqhci_irq,
index 9194bb7..080ced1 100644 (file)
@@ -609,7 +609,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
        switch (pdata->max_width) {
        case 8:
                host->mmc->caps |= MMC_CAP_8_BIT_DATA;
-               /* Fall through */
+               fallthrough;
        case 4:
                host->mmc->caps |= MMC_CAP_4_BIT_DATA;
                break;
index a910cb4..bafa2e4 100644 (file)
@@ -470,7 +470,7 @@ static int sdhci_sprd_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
                break;
 
        default:
-               /* fall-through */
+               fallthrough;
        case MMC_SIGNAL_VOLTAGE_330:
                ret = pinctrl_select_state(sprd_host->pinctrl,
                                           sprd_host->pins_default);
index 0a3f9d0..13fbf70 100644 (file)
 #define NVQUIRK_DIS_CARD_CLK_CONFIG_TAP                        BIT(8)
 #define NVQUIRK_CQHCI_DCMD_R1B_CMD_TIMING              BIT(9)
 
+/*
+ * NVQUIRK_HAS_TMCLK is for SoC's having separate timeout clock for Tegra
+ * SDMMC hardware data timeout.
+ */
+#define NVQUIRK_HAS_TMCLK                              BIT(10)
+
 /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
 #define SDHCI_TEGRA_CQE_BASE_ADDR                      0xF000
 
@@ -140,6 +146,7 @@ struct sdhci_tegra_autocal_offsets {
 struct sdhci_tegra {
        const struct sdhci_tegra_soc_data *soc_data;
        struct gpio_desc *power_gpio;
+       struct clk *tmclk;
        bool ddr_signaling;
        bool pad_calib_required;
        bool pad_control_available;
@@ -1418,7 +1425,6 @@ static const struct sdhci_ops tegra210_sdhci_ops = {
 
 static const struct sdhci_pltfm_data sdhci_tegra210_pdata = {
        .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
-                 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
                  SDHCI_QUIRK_SINGLE_POWER_WRITE |
                  SDHCI_QUIRK_NO_HISPD_BIT |
                  SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
@@ -1434,7 +1440,8 @@ static const struct sdhci_tegra_soc_data soc_data_tegra210 = {
                    NVQUIRK_HAS_PADCALIB |
                    NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
                    NVQUIRK_ENABLE_SDR50 |
-                   NVQUIRK_ENABLE_SDR104,
+                   NVQUIRK_ENABLE_SDR104 |
+                   NVQUIRK_HAS_TMCLK,
        .min_tap_delay = 106,
        .max_tap_delay = 185,
 };
@@ -1456,7 +1463,6 @@ static const struct sdhci_ops tegra186_sdhci_ops = {
 
 static const struct sdhci_pltfm_data sdhci_tegra186_pdata = {
        .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL |
-                 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK |
                  SDHCI_QUIRK_SINGLE_POWER_WRITE |
                  SDHCI_QUIRK_NO_HISPD_BIT |
                  SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC |
@@ -1473,6 +1479,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra186 = {
                    NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
                    NVQUIRK_ENABLE_SDR50 |
                    NVQUIRK_ENABLE_SDR104 |
+                   NVQUIRK_HAS_TMCLK |
                    NVQUIRK_CQHCI_DCMD_R1B_CMD_TIMING,
        .min_tap_delay = 84,
        .max_tap_delay = 136,
@@ -1485,7 +1492,8 @@ static const struct sdhci_tegra_soc_data soc_data_tegra194 = {
                    NVQUIRK_HAS_PADCALIB |
                    NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
                    NVQUIRK_ENABLE_SDR50 |
-                   NVQUIRK_ENABLE_SDR104,
+                   NVQUIRK_ENABLE_SDR104 |
+                   NVQUIRK_HAS_TMCLK,
        .min_tap_delay = 96,
        .max_tap_delay = 139,
 };
@@ -1613,6 +1621,43 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
                goto err_power_req;
        }
 
+       /*
+        * Tegra210 has a separate SDMMC_LEGACY_TM clock used for host
+        * timeout clock and SW can choose TMCLK or SDCLK for hardware
+        * data timeout through the bit USE_TMCLK_FOR_DATA_TIMEOUT of
+        * the register SDHCI_TEGRA_VENDOR_SYS_SW_CTRL.
+        *
+        * USE_TMCLK_FOR_DATA_TIMEOUT bit default is set to 1 and SDMMC uses
+        * 12Mhz TMCLK which is advertised in host capability register.
+        * With TMCLK of 12Mhz provides maximum data timeout period that can
+        * be achieved is 11s better than using SDCLK for data timeout.
+        *
+        * So, TMCLK is set to 12Mhz and kept enabled all the time on SoC's
+        * supporting separate TMCLK.
+        */
+
+       if (soc_data->nvquirks & NVQUIRK_HAS_TMCLK) {
+               clk = devm_clk_get(&pdev->dev, "tmclk");
+               if (IS_ERR(clk)) {
+                       rc = PTR_ERR(clk);
+                       if (rc == -EPROBE_DEFER)
+                               goto err_power_req;
+
+                       dev_warn(&pdev->dev, "failed to get tmclk: %d\n", rc);
+                       clk = NULL;
+               }
+
+               clk_set_rate(clk, 12000000);
+               rc = clk_prepare_enable(clk);
+               if (rc) {
+                       dev_err(&pdev->dev,
+                               "failed to enable tmclk: %d\n", rc);
+                       goto err_power_req;
+               }
+
+               tegra_host->tmclk = clk;
+       }
+
        clk = devm_clk_get(mmc_dev(host->mmc), NULL);
        if (IS_ERR(clk)) {
                rc = PTR_ERR(clk);
@@ -1656,6 +1701,7 @@ err_add_host:
 err_rst_get:
        clk_disable_unprepare(pltfm_host->clk);
 err_clk_get:
+       clk_disable_unprepare(tegra_host->tmclk);
 err_power_req:
 err_parse_dt:
        sdhci_pltfm_free(pdev);
@@ -1673,6 +1719,7 @@ static int sdhci_tegra_remove(struct platform_device *pdev)
        reset_control_assert(tegra_host->rst);
        usleep_range(2000, 4000);
        clk_disable_unprepare(pltfm_host->clk);
+       clk_disable_unprepare(tegra_host->tmclk);
 
        sdhci_pltfm_free(pdev);
 
index e6e9e28..03ce57e 100644 (file)
@@ -527,7 +527,7 @@ static bool xenon_emmc_phy_slow_mode(struct sdhci_host *host,
                        ret = true;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                reg &= ~XENON_TIMING_ADJUST_SLOW_MODE;
                ret = false;
index 3ad394b..592a55a 100644 (file)
@@ -2825,7 +2825,7 @@ int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
        case MMC_TIMING_UHS_SDR50:
                if (host->flags & SDHCI_SDR50_NEEDS_TUNING)
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
 
        default:
                goto out;
index 5987656..fd8b72d 100644 (file)
@@ -335,7 +335,7 @@ static unsigned int tifm_sd_op_flags(struct mmc_command *cmd)
                break;
        case MMC_RSP_R1B:
                rc |= TIFM_MMCSD_RSP_BUSY;
-               /* fall-through */
+               fallthrough;
        case MMC_RSP_R1:
                rc |= TIFM_MMCSD_RSP_R1;
                break;
index 369b8de..7666c90 100644 (file)
@@ -1343,7 +1343,7 @@ static int usdhi6_stop_cmd(struct usdhi6_host *host)
                        host->wait = USDHI6_WAIT_FOR_STOP;
                        return 0;
                }
-               /* fall through - Unsupported STOP command. */
+               fallthrough;    /* Unsupported STOP command */
        default:
                dev_err(mmc_dev(host->mmc),
                        "unsupported stop CMD%d for CMD%d\n",
@@ -1691,7 +1691,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
        switch (host->wait) {
        default:
                dev_err(mmc_dev(host->mmc), "Invalid state %u\n", host->wait);
-               /* fall through - mrq can be NULL, but is impossible. */
+               fallthrough;    /* mrq can be NULL, but is impossible */
        case USDHI6_WAIT_FOR_CMD:
                usdhi6_error_code(host);
                if (mrq)
@@ -1713,7 +1713,7 @@ static void usdhi6_timeout_work(struct work_struct *work)
                        host->offset, data->blocks, data->blksz, data->sg_len,
                        sg_dma_len(sg), sg->offset);
                usdhi6_sg_unmap(host, true);
-               /* fall through - page unmapped in USDHI6_WAIT_FOR_DATA_END. */
+               fallthrough;    /* page unmapped in USDHI6_WAIT_FOR_DATA_END */
        case USDHI6_WAIT_FOR_DATA_END:
                usdhi6_error_code(host);
                data->error = -ETIMEDOUT;
index 12466b0..22ed051 100644 (file)
@@ -93,7 +93,7 @@ static int adgs1408_probe(struct spi_device *spi)
                        mux->idle_state = idle_state;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                dev_err(dev, "invalid idle-state %d\n", idle_state);
                return -EINVAL;
index 18428e1..1c6c27f 100644 (file)
@@ -301,7 +301,7 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr)
                        dev->irq = cops_irq(ioaddr, board);
                        if (dev->irq)
                                break;
-                       /* fall through - Once no IRQ found on this port. */
+                       fallthrough;    /* Once no IRQ found on this port */
                case 1:
                        retval = -EINVAL;
                        goto err_out;
index 14a5fb3..98df38f 100644 (file)
@@ -363,13 +363,13 @@ static int __init arcrimi_setup(char *s)
        switch (ints[0]) {
        default:                /* ERROR */
                pr_err("Too many arguments\n");
-               /* Fall through */
+               fallthrough;
        case 3:         /* Node ID */
                node = ints[3];
-               /* Fall through */
+               fallthrough;
        case 2:         /* IRQ */
                irq = ints[2];
-               /* Fall through */
+               fallthrough;
        case 1:         /* IO address */
                io = ints[1];
        }
index cd27fdc..f983c4c 100644 (file)
@@ -197,22 +197,22 @@ static int __init com20020isa_setup(char *s)
        switch (ints[0]) {
        default:                /* ERROR */
                pr_info("Too many arguments\n");
-               /* Fall through */
+               fallthrough;
        case 6:         /* Timeout */
                timeout = ints[6];
-               /* Fall through */
+               fallthrough;
        case 5:         /* CKP value */
                clockp = ints[5];
-               /* Fall through */
+               fallthrough;
        case 4:         /* Backplane flag */
                backplane = ints[4];
-               /* Fall through */
+               fallthrough;
        case 3:         /* Node ID */
                node = ints[3];
-               /* Fall through */
+               fallthrough;
        case 2:         /* IRQ */
                irq = ints[2];
-               /* Fall through */
+               fallthrough;
        case 1:         /* IO address */
                io = ints[1];
        }
index 186bbf8..cf214b7 100644 (file)
@@ -363,10 +363,10 @@ static int __init com90io_setup(char *s)
        switch (ints[0]) {
        default:                /* ERROR */
                pr_err("Too many arguments\n");
-               /* Fall through */
+               fallthrough;
        case 2:         /* IRQ */
                irq = ints[2];
-               /* Fall through */
+               fallthrough;
        case 1:         /* IO address */
                io = ints[1];
        }
index bd75d06..3dc3d53 100644 (file)
@@ -693,13 +693,13 @@ static int __init com90xx_setup(char *s)
        switch (ints[0]) {
        default:                /* ERROR */
                pr_err("Too many arguments\n");
-               /* Fall through */
+               fallthrough;
        case 3:         /* Mem address */
                shmem = ints[3];
-               /* Fall through */
+               fallthrough;
        case 2:         /* IRQ */
                irq = ints[2];
-               /* Fall through */
+               fallthrough;
        case 1:         /* IO address */
                io = ints[1];
        }
index 31e43a2..aa001b1 100644 (file)
@@ -130,7 +130,7 @@ static inline struct bonding *__get_bond_by_port(struct port *port)
 
 /**
  * __get_first_agg - get the first aggregator in the bond
- * @bond: the bond we're looking at
+ * @port: the port we're looking at
  *
  * Return the aggregator of the first slave in @bond, or %NULL if it can't be
  * found.
@@ -1149,7 +1149,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
                        port->actor_oper_port_state &= ~LACP_STATE_EXPIRED;
                        port->sm_rx_state = AD_RX_PORT_DISABLED;
 
-                       /* Fall Through */
+                       fallthrough;
                case AD_RX_PORT_DISABLED:
                        port->sm_vars &= ~AD_PORT_MATCHED;
                        break;
@@ -1588,7 +1588,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
                if (__agg_active_ports(curr) < __agg_active_ports(best))
                        return best;
 
-               /*FALLTHROUGH*/
+               fallthrough;
        case BOND_AD_STABLE:
        case BOND_AD_BANDWIDTH:
                if (__get_agg_bandwidth(curr) > __get_agg_bandwidth(best))
@@ -1626,7 +1626,7 @@ static int agg_device_up(const struct aggregator *agg)
 
 /**
  * ad_agg_selection_logic - select an aggregation group for a team
- * @aggregator: the aggregator we're looking at
+ * @agg: the aggregator we're looking at
  * @update_slave_arr: Does slave array need update?
  *
  * It is assumed that only one aggregator may be selected for a team.
@@ -1810,7 +1810,7 @@ static void ad_initialize_agg(struct aggregator *aggregator)
 
 /**
  * ad_initialize_port - initialize a given port's parameters
- * @aggregator: the aggregator we're looking at
+ * @port: the port we're looking at
  * @lacp_fast: boolean. whether fast periodic should be used
  */
 static void ad_initialize_port(struct port *port, int lacp_fast)
@@ -1967,6 +1967,7 @@ static void ad_marker_response_received(struct bond_marker *marker,
 /**
  * bond_3ad_initiate_agg_selection - initate aggregator selection
  * @bond: bonding struct
+ * @timeout: timeout value to set
  *
  * Set the aggregation selection timer, to initiate an agg selection in
  * the very near future.  Called during first initialization, and during
@@ -2259,7 +2260,7 @@ void bond_3ad_update_ad_actor_settings(struct bonding *bond)
 
 /**
  * bond_3ad_state_machine_handler - handle state machines timeout
- * @bond: bonding struct to work on
+ * @work: work context to fetch bonding struct to work on from
  *
  * The state machine handling concept in this module is to check every tick
  * which state machine should operate any function. The execution order is
@@ -2500,7 +2501,7 @@ void bond_3ad_adapter_speed_duplex_changed(struct slave *slave)
 /**
  * bond_3ad_handle_link_change - handle a slave's link status change indication
  * @slave: slave struct to work on
- * @status: whether the link is now up or down
+ * @link: whether the link is now up or down
  *
  * Handle reselection of aggregator (if needed) for this port.
  */
@@ -2551,7 +2552,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 
 /**
  * bond_3ad_set_carrier - set link state for bonding master
- * @bond - bonding structure
+ * @bond: bonding structure
  *
  * if we have an active aggregator, we're up, if not, we're down.
  * Presumes that we cannot have an active aggregator if there are
@@ -2664,7 +2665,7 @@ int bond_3ad_lacpdu_recv(const struct sk_buff *skb, struct bonding *bond,
 
 /**
  * bond_3ad_update_lacp_rate - change the lacp rate
- * @bond - bonding struct
+ * @bond: bonding struct
  *
  * When modify lacp_rate parameter via sysfs,
  * update actor_oper_port_state of each port.
index 095ea51..4e1b7de 100644 (file)
@@ -1206,8 +1206,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
 
 /**
  * alb_set_mac_address
- * @bond:
- * @addr:
+ * @bond: bonding we're working on
+ * @addr: MAC address to set
  *
  * In TLB mode all slaves are configured to the bond's hw address, but set
  * their dev_addr field to different addresses (based on their permanent hw
index 5ad43aa..42ef25e 100644 (file)
@@ -322,6 +322,7 @@ netdev_tx_t bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb,
 /**
  * bond_vlan_rx_add_vid - Propagates adding an id to slaves
  * @bond_dev: bonding net device that got called
+ * @proto: network protocol ID
  * @vid: vlan id being added
  */
 static int bond_vlan_rx_add_vid(struct net_device *bond_dev,
@@ -355,6 +356,7 @@ unwind:
 /**
  * bond_vlan_rx_kill_vid - Propagates deleting an id to slaves
  * @bond_dev: bonding net device that got called
+ * @proto: network protocol ID
  * @vid: vlan id being removed
  */
 static int bond_vlan_rx_kill_vid(struct net_device *bond_dev,
@@ -948,7 +950,7 @@ static bool bond_should_notify_peers(struct bonding *bond)
 /**
  * change_active_interface - change the active slave into the specified one
  * @bond: our bonding struct
- * @new: the new slave to make the active one
+ * @new_active: the new slave to make the active one
  *
  * Set the new slave to the bond's settings and unset them on the old
  * curr_active_slave.
@@ -2205,7 +2207,8 @@ static int bond_release_and_destroy(struct net_device *bond_dev,
        int ret;
 
        ret = __bond_release_one(bond_dev, slave_dev, false, true);
-       if (ret == 0 && !bond_has_slaves(bond)) {
+       if (ret == 0 && !bond_has_slaves(bond) &&
+           bond_dev->reg_state != NETREG_UNREGISTERING) {
                bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
                netdev_info(bond_dev, "Destroying bond\n");
                bond_remove_proc_entry(bond);
@@ -2271,7 +2274,7 @@ static int bond_miimon_inspect(struct bonding *bond)
                                             "active " : "backup ") : "",
                                           bond->params.downdelay * bond->params.miimon);
                        }
-                       /*FALLTHRU*/
+                       fallthrough;
                case BOND_LINK_FAIL:
                        if (link_state) {
                                /* recovered before downdelay expired */
@@ -2307,7 +2310,7 @@ static int bond_miimon_inspect(struct bonding *bond)
                                           bond->params.updelay *
                                           bond->params.miimon);
                        }
-                       /*FALLTHRU*/
+                       fallthrough;
                case BOND_LINK_BACK:
                        if (!link_state) {
                                bond_propose_link_state(slave, BOND_LINK_DOWN);
@@ -2945,6 +2948,9 @@ static int bond_ab_arp_inspect(struct bonding *bond)
                        if (bond_time_in_interval(bond, last_rx, 1)) {
                                bond_propose_link_state(slave, BOND_LINK_UP);
                                commit++;
+                       } else if (slave->link == BOND_LINK_BACK) {
+                               bond_propose_link_state(slave, BOND_LINK_FAIL);
+                               commit++;
                        }
                        continue;
                }
@@ -3053,6 +3059,19 @@ static void bond_ab_arp_commit(struct bonding *bond)
 
                        continue;
 
+               case BOND_LINK_FAIL:
+                       bond_set_slave_link_state(slave, BOND_LINK_FAIL,
+                                                 BOND_SLAVE_NOTIFY_NOW);
+                       bond_set_slave_inactive_flags(slave,
+                                                     BOND_SLAVE_NOTIFY_NOW);
+
+                       /* A slave has just been enslaved and has become
+                        * the current active slave.
+                        */
+                       if (rtnl_dereference(bond->curr_active_slave))
+                               RCU_INIT_POINTER(bond->current_arp_slave, NULL);
+                       continue;
+
                default:
                        slave_err(bond->dev, slave->dev,
                                  "impossible: link_new_state %d on slave\n",
@@ -3103,8 +3122,6 @@ static bool bond_ab_arp_probe(struct bonding *bond)
                        return should_notify_rtnl;
        }
 
-       bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER);
-
        bond_for_each_slave_rcu(bond, slave, iter) {
                if (!found && !before && bond_slave_is_up(slave))
                        before = slave;
@@ -3305,7 +3322,7 @@ static int bond_slave_netdev_event(unsigned long event,
 
                if (BOND_MODE(bond) == BOND_MODE_8023AD)
                        bond_3ad_adapter_speed_duplex_changed(slave);
-               /* Fallthrough */
+               fallthrough;
        case NETDEV_DOWN:
                /* Refresh slave-array if applicable!
                 * If the setup does not use miimon or arpmon (mode-specific!),
@@ -3743,7 +3760,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
                        return -EINVAL;
 
                mii->phy_id = 0;
-               /* Fall Through */
+               fallthrough;
        case SIOCGMIIREG:
                /* We do this again just in case we were called by SIOCGMIIREG
                 * instead of SIOCGMIIPHY.
@@ -4552,13 +4569,23 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
        return ret;
 }
 
+static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed)
+{
+       if (speed == 0 || speed == SPEED_UNKNOWN)
+               speed = slave->speed;
+       else
+               speed = min(speed, slave->speed);
+
+       return speed;
+}
+
 static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
                                           struct ethtool_link_ksettings *cmd)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       unsigned long speed = 0;
        struct list_head *iter;
        struct slave *slave;
+       u32 speed = 0;
 
        cmd->base.duplex = DUPLEX_UNKNOWN;
        cmd->base.port = PORT_OTHER;
@@ -4570,8 +4597,13 @@ static int bond_ethtool_get_link_ksettings(struct net_device *bond_dev,
         */
        bond_for_each_slave(bond, slave, iter) {
                if (bond_slave_can_tx(slave)) {
-                       if (slave->speed != SPEED_UNKNOWN)
-                               speed += slave->speed;
+                       if (slave->speed != SPEED_UNKNOWN) {
+                               if (BOND_MODE(bond) == BOND_MODE_BROADCAST)
+                                       speed = bond_mode_bcast_speed(slave,
+                                                                     speed);
+                               else
+                                       speed += slave->speed;
+                       }
                        if (cmd->base.duplex == DUPLEX_UNKNOWN &&
                            slave->duplex != DUPLEX_UNKNOWN)
                                cmd->base.duplex = slave->duplex;
index 9df2007..38e9f80 100644 (file)
@@ -898,7 +898,7 @@ static void at91_irq_err_state(struct net_device *dev,
                                CAN_ERR_CRTL_TX_WARNING :
                                CAN_ERR_CRTL_RX_WARNING;
                }
-               /* fall through */
+               fallthrough;
        case CAN_STATE_ERROR_WARNING:
                /*
                 * from: ERROR_ACTIVE, ERROR_WARNING
@@ -948,7 +948,7 @@ static void at91_irq_err_state(struct net_device *dev,
                netdev_dbg(dev, "Error Active\n");
                cf->can_id |= CAN_ERR_PROT;
                cf->data[2] = CAN_ERR_PROT_ACTIVE;
-               /* fall through */
+               fallthrough;
        case CAN_STATE_ERROR_WARNING:
                reg_idr = AT91_IRQ_ERRA | AT91_IRQ_WARN | AT91_IRQ_BOFF;
                reg_ier = AT91_IRQ_ERRP;
index 6ad83a8..9469d44 100644 (file)
@@ -659,7 +659,7 @@ static int pciefd_can_probe(struct pciefd_board *pciefd)
                pciefd_can_writereg(priv, CANFD_CLK_SEL_80MHZ,
                                    PCIEFD_REG_CAN_CLK_SEL);
 
-               /* fall through */
+               fallthrough;
        case CANFD_CLK_SEL_80MHZ:
                priv->ucan.can.clock.freq = 80 * 1000 * 1000;
                break;
index d7222ba..d7c2ec5 100644 (file)
@@ -150,7 +150,7 @@ static void sp_populate_of(struct sja1000_priv *priv, struct device_node *of)
                priv->read_reg = sp_read_reg16;
                priv->write_reg = sp_write_reg16;
                break;
-       case 1: /* fallthrough */
+       case 1:
        default:
                priv->read_reg = sp_read_reg8;
                priv->write_reg = sp_write_reg8;
index 91cdc0a..b4a39f0 100644 (file)
@@ -153,7 +153,7 @@ static void slc_bump(struct slcan *sl)
        switch (*cmd) {
        case 'r':
                cf.can_id = CAN_RTR_FLAG;
-               /* fallthrough */
+               fallthrough;
        case 't':
                /* store dlc ASCII value and terminate SFF CAN ID string */
                cf.can_dlc = sl->rbuff[SLC_CMD_LEN + SLC_SFF_ID_LEN];
@@ -163,7 +163,7 @@ static void slc_bump(struct slcan *sl)
                break;
        case 'R':
                cf.can_id = CAN_RTR_FLAG;
-               /* fallthrough */
+               fallthrough;
        case 'T':
                cf.can_id |= CAN_EFF_FLAG;
                /* store dlc ASCII value and terminate EFF CAN ID string */
index 5009ff2..d176088 100644 (file)
@@ -864,7 +864,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
                        if (new_state >= CAN_STATE_ERROR_WARNING &&
                            new_state <= CAN_STATE_BUS_OFF)
                                priv->can.can_stats.error_warning++;
-                       /* fall through */
+                       fallthrough;
                case CAN_STATE_ERROR_WARNING:
                        if (new_state >= CAN_STATE_ERROR_PASSIVE &&
                            new_state <= CAN_STATE_BUS_OFF)
index d2539c9..66d0198 100644 (file)
@@ -415,7 +415,7 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
                        new_state = CAN_STATE_ERROR_WARNING;
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case CAN_STATE_ERROR_WARNING:
                if (n & PCAN_USB_ERROR_BUS_HEAVY) {
index 0b7766b..d91df34 100644 (file)
@@ -345,7 +345,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
                default:
                        netdev_warn(netdev, "tx urb submitting failed err=%d\n",
                                    err);
-                       /* fall through */
+                       fallthrough;
                case -ENOENT:
                        /* cable unplugged */
                        stats->tx_dropped++;
index 53cb2f7..1689ab3 100644 (file)
@@ -133,10 +133,10 @@ static int pcan_msg_add_rec(struct pcan_usb_pro_msg *pm, int id, ...)
        switch (id) {
        case PCAN_USBPRO_TXMSG8:
                i += 4;
-               /* fall through */
+               fallthrough;
        case PCAN_USBPRO_TXMSG4:
                i += 4;
-               /* fall through */
+               fallthrough;
        case PCAN_USBPRO_TXMSG0:
                *pc++ = va_arg(ap, int);
                *pc++ = va_arg(ap, int);
index 6500179..e731db9 100644 (file)
@@ -1061,7 +1061,7 @@ static void b53_force_port_config(struct b53_device *dev, int port,
        switch (speed) {
        case 2000:
                reg |= PORT_OVERRIDE_SPEED_2000M;
-               /* fallthrough */
+               fallthrough;
        case SPEED_1000:
                reg |= PORT_OVERRIDE_SPEED_1000M;
                break;
@@ -1554,6 +1554,8 @@ static int b53_arl_op(struct b53_device *dev, int op, int port,
                return ret;
 
        switch (ret) {
+       case -ETIMEDOUT:
+               return ret;
        case -ENOSPC:
                dev_dbg(dev->dev, "{%pM,%.4d} no space left in ARL\n",
                        addr, vid);
index 629bf14..5ae3d97 100644 (file)
@@ -170,7 +170,7 @@ void b53_serdes_phylink_validate(struct b53_device *dev, int port,
        switch (lane) {
        case 0:
                phylink_set(supported, 2500baseX_Full);
-               /* fallthrough */
+               fallthrough;
        case 1:
                phylink_set(supported, 1000baseX_Full);
                break;
index bafddb3..5ebff98 100644 (file)
@@ -566,7 +566,7 @@ static void bcm_sf2_sw_mac_config(struct dsa_switch *ds, int port,
        switch (state->interface) {
        case PHY_INTERFACE_MODE_RGMII:
                id_mode_dis = 1;
-               /* fallthrough */
+               fallthrough;
        case PHY_INTERFACE_MODE_RGMII_TXID:
                port_mode = EXT_GPHY;
                break;
index dc99940..3cb22d1 100644 (file)
@@ -1083,7 +1083,7 @@ static phy_interface_t ksz9477_get_interface(struct ksz_device *dev, int port)
                interface = PHY_INTERFACE_MODE_GMII;
                if (gbit)
                        break;
-               /* fall through */
+               fallthrough;
        case 0:
                interface = PHY_INTERFACE_MODE_MII;
                break;
index 8dcb8a4..1aaf47a 100644 (file)
@@ -566,7 +566,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
        case P5_INTF_SEL_PHY_P0:
                /* MT7530_P5_MODE_GPHY_P0: 2nd GMAC -> P5 -> P0 */
                val |= MHWTRAP_PHY0_SEL;
-               /* fall through */
+               fallthrough;
        case P5_INTF_SEL_PHY_P4:
                /* MT7530_P5_MODE_GPHY_P4: 2nd GMAC -> P5 -> P4 */
                val &= ~MHWTRAP_P5_MAC_SEL & ~MHWTRAP_P5_DIS;
@@ -1326,14 +1326,17 @@ mt7530_setup(struct dsa_switch *ds)
 
                        if (phy_node->parent == priv->dev->of_node->parent) {
                                ret = of_get_phy_mode(mac_np, &interface);
-                               if (ret && ret != -ENODEV)
+                               if (ret && ret != -ENODEV) {
+                                       of_node_put(mac_np);
                                        return ret;
+                               }
                                id = of_mdio_parse_addr(ds->dev, phy_node);
                                if (id == 0)
                                        priv->p5_intf_sel = P5_INTF_SEL_PHY_P0;
                                if (id == 4)
                                        priv->p5_intf_sel = P5_INTF_SEL_PHY_P4;
                        }
+                       of_node_put(mac_np);
                        of_node_put(phy_node);
                        break;
                }
@@ -1501,7 +1504,7 @@ unsupported:
                phylink_set(mask, 100baseT_Full);
 
                if (state->interface != PHY_INTERFACE_MODE_MII) {
-                       phylink_set(mask, 1000baseT_Half);
+                       /* This switch only supports 1G full-duplex. */
                        phylink_set(mask, 1000baseT_Full);
                        if (port == 5)
                                phylink_set(mask, 1000baseX_Full);
index 7a71c99..f0dbc05 100644 (file)
@@ -875,7 +875,7 @@ static uint64_t _mv88e6xxx_get_ethtool_stat(struct mv88e6xxx_chip *chip,
                break;
        case STATS_TYPE_BANK1:
                reg = bank1_select;
-               /* fall through */
+               fallthrough;
        case STATS_TYPE_BANK0:
                reg |= s->reg | histogram;
                mv88e6xxx_g1_stats_read(chip, reg, &low);
index f121619..2d23cce 100644 (file)
@@ -9,7 +9,7 @@ config NET_DSA_MSCC_FELIX
        select NET_DSA_TAG_OCELOT
        select FSL_ENETC_MDIO
        help
-         This driver supports network switches from the the Vitesse /
+         This driver supports network switches from the Vitesse /
          Microsemi / Microchip Ocelot family of switching cores that are
          connected to their host CPU via Ethernet.
          The following switches are supported:
index c69d959..04bfa6e 100644 (file)
@@ -400,6 +400,7 @@ static int felix_parse_ports_node(struct felix *felix,
                if (err < 0) {
                        dev_err(dev, "Unsupported PHY mode %s on port %d\n",
                                phy_modes(phy_mode), port);
+                       of_node_put(child);
                        return err;
                }
 
index c3f6f12..5a28dfb 100644 (file)
@@ -3415,7 +3415,7 @@ static int sja1105_check_device_id(struct sja1105_private *priv)
 
        sja1105_unpack(prod_id, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID);
 
-       for (match = sja1105_dt_ids; match->compatible; match++) {
+       for (match = sja1105_dt_ids; match->compatible[0]; match++) {
                const struct sja1105_info *info = match->data;
 
                /* Is what's been probed in our match table at all? */
index 139d012..667f38c 100644 (file)
@@ -1259,14 +1259,14 @@ el3_up(struct net_device *dev)
                                        pr_cont("Forcing 3c5x9b full-duplex mode");
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        case 8:
                                /* set full-duplex mode based on eeprom config setting */
                                if ((sw_info & 0x000f) && (sw_info & 0x8000)) {
                                        pr_cont("Setting 3c5x9b full-duplex mode (from EEPROM configuration bit)");
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                /* xcvr=(0 || 4) OR user has an old 3c5x9 non "B" model */
                                pr_cont("Setting 3c5x9/3c5x9B half-duplex mode");
index ef1c315..f66e7fb 100644 (file)
@@ -951,7 +951,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
 static void update_stats(struct net_device *dev)
 {
        unsigned int ioaddr = dev->base_addr;
-       u8 rx, tx, up;
+       u8 up;
 
        pr_debug("%s: updating the statistics.\n", dev->name);
 
@@ -972,8 +972,8 @@ static void update_stats(struct net_device *dev)
        dev->stats.tx_packets                   += (up&0x30) << 4;
        /* Rx packets   */                         inb(ioaddr + 7);
        /* Tx deferrals */                         inb(ioaddr + 8);
-       rx                                       = inw(ioaddr + 10);
-       tx                                       = inw(ioaddr + 12);
+       /* rx */                                   inw(ioaddr + 10);
+       /* tx */                                   inw(ioaddr + 12);
 
        EL3WINDOW(4);
        /* BadSSD */                               inb(ioaddr + 12);
@@ -1046,7 +1046,7 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get the address of the PHY in use. */
                data->phy_id = phy;
-               /* fall through */
+               fallthrough;
        case SIOCGMIIREG:               /* Read the specified MII register. */
                {
                        int saved_window;
index aeae796..a00b36f 100644 (file)
@@ -610,7 +610,7 @@ static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
     switch (cmd) {
     case SIOCGMIIPHY:
        data->phy_id = info->phy_id;
-       /* Fall through */
+       fallthrough;
     case SIOCGMIIREG:          /* Read MII PHY register. */
        data->val_out = mdio_read(mii_addr, data->phy_id, data->reg_num & 0x1f);
        return 0;
@@ -898,6 +898,7 @@ static int ax_close(struct net_device *dev)
 /**
  * axnet_tx_timeout - handle transmit time out condition
  * @dev: network device which has apparently fallen asleep
+ * @txqueue: unused
  *
  * Called by kernel when device never acknowledges a transmit has
  * completed (or failed) - i.e. never posted a Tx related interrupt.
index 645efac..164c3ed 100644 (file)
@@ -1108,7 +1108,7 @@ static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
     switch (cmd) {
     case SIOCGMIIPHY:
        data->phy_id = info->phy_id;
-       /* fall through */
+       fallthrough;
     case SIOCGMIIREG:          /* Read MII PHY register. */
        data->val_out = mdio_read(mii_addr, data->phy_id, data->reg_num & 0x1f);
        return 0;
index 6234fcd..696517e 100644 (file)
@@ -1712,13 +1712,13 @@ static bool slic_is_fiber(unsigned short subdev)
 {
        switch (subdev) {
        /* Mojave */
-       case PCI_SUBDEVICE_ID_ALACRITECH_1000X1F: /* fallthrough */
-       case PCI_SUBDEVICE_ID_ALACRITECH_SES1001F: /* fallthrough */
+       case PCI_SUBDEVICE_ID_ALACRITECH_1000X1F:
+       case PCI_SUBDEVICE_ID_ALACRITECH_SES1001F: fallthrough;
        /* Oasis */
-       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF: /* fallthrough */
-       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF: /* fallthrough */
-       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF: /* fallthrough */
-       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF: /* fallthrough */
+       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2002XF:
+       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2001XF:
+       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2104EF:
+       case PCI_SUBDEVICE_ID_ALACRITECH_SEN2102EF:
                return true;
        }
        return false;
index ac86fca..8470c83 100644 (file)
@@ -547,7 +547,7 @@ static int acenic_probe_one(struct pci_dev *pdev,
                               ap->name);
                        break;
                }
-               /* Fall through */
+               fallthrough;
        case PCI_VENDOR_ID_SGI:
                printk(KERN_INFO "%s: SGI AceNIC ", ap->name);
                break;
index 2a6c972..a3a8edf 100644 (file)
@@ -2180,13 +2180,10 @@ static void ena_del_napi_in_range(struct ena_adapter *adapter,
        int i;
 
        for (i = first_index; i < first_index + count; i++) {
-               /* Check if napi was initialized before */
-               if (!ENA_IS_XDP_INDEX(adapter, i) ||
-                   adapter->ena_napi[i].xdp_ring)
-                       netif_napi_del(&adapter->ena_napi[i].napi);
-               else
-                       WARN_ON(ENA_IS_XDP_INDEX(adapter, i) &&
-                               adapter->ena_napi[i].xdp_ring);
+               netif_napi_del(&adapter->ena_napi[i].napi);
+
+               WARN_ON(!ENA_IS_XDP_INDEX(adapter, i) &&
+                       adapter->ena_napi[i].xdp_ring);
        }
 }
 
@@ -3601,16 +3598,14 @@ static void ena_fw_reset_device(struct work_struct *work)
 {
        struct ena_adapter *adapter =
                container_of(work, struct ena_adapter, reset_task);
-       struct pci_dev *pdev = adapter->pdev;
 
-       if (unlikely(!test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))) {
-               dev_err(&pdev->dev,
-                       "device reset schedule while reset bit is off\n");
-               return;
-       }
        rtnl_lock();
-       ena_destroy_device(adapter, false);
-       ena_restore_device(adapter);
+
+       if (likely(test_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags))) {
+               ena_destroy_device(adapter, false);
+               ena_restore_device(adapter);
+       }
+
        rtnl_unlock();
 }
 
@@ -3692,7 +3687,7 @@ static int check_missing_comp_in_tx_queue(struct ena_adapter *adapter,
        }
 
        u64_stats_update_begin(&tx_ring->syncp);
-       tx_ring->tx_stats.missed_tx = missed_tx;
+       tx_ring->tx_stats.missed_tx += missed_tx;
        u64_stats_update_end(&tx_ring->syncp);
 
        return rc;
@@ -4389,8 +4384,11 @@ static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
                netdev->rx_cpu_rmap = NULL;
        }
 #endif /* CONFIG_RFS_ACCEL */
-       del_timer_sync(&adapter->timer_service);
 
+       /* Make sure timer and reset routine won't be called after
+        * freeing device resources.
+        */
+       del_timer_sync(&adapter->timer_service);
        cancel_work_sync(&adapter->reset_task);
 
        rtnl_lock(); /* lock released inside the below if-else block */
@@ -4558,6 +4556,9 @@ static void ena_keep_alive_wd(void *adapter_data,
        tx_drops = ((u64)desc->tx_drops_high << 32) | desc->tx_drops_low;
 
        u64_stats_update_begin(&adapter->syncp);
+       /* These stats are accumulated by the device, so the counters indicate
+        * all drops since last reset.
+        */
        adapter->dev_stats.rx_drops = rx_drops;
        adapter->dev_stats.tx_drops = tx_drops;
        u64_stats_update_end(&adapter->syncp);
index b6c43b5..960d483 100644 (file)
@@ -1475,7 +1475,7 @@ static int amd8111e_ioctl(struct net_device *dev , struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                data->phy_id = lp->ext_phy_addr;
 
-       /* fallthru */
+               fallthrough;
        case SIOCGMIIREG:
 
                spin_lock_irq(&lp->lock);
index 43294a1..4ba7555 100644 (file)
@@ -1538,7 +1538,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
        /* PTP v2, UDP, any kind of event packet */
        case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
-               /* Fall through - to PTP v1, UDP, any kind of event packet */
+               fallthrough;    /* to PTP v1, UDP, any kind of event packet */
        case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
@@ -1549,7 +1549,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
        /* PTP v2, UDP, Sync packet */
        case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
-               /* Fall through - to PTP v1, UDP, Sync packet */
+               fallthrough;    /* to PTP v1, UDP, Sync packet */
        case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
@@ -1560,7 +1560,7 @@ static int xgbe_set_hwtstamp_settings(struct xgbe_prv_data *pdata,
        /* PTP v2, UDP, Delay_req packet */
        case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSVER2ENA, 1);
-               /* Fall through - to PTP v1, UDP, Delay_req packet */
+               fallthrough;    /* to PTP v1, UDP, Delay_req packet */
        case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV4ENA, 1);
                XGMAC_SET_BITS(mac_tscr, MAC_TSCR, TSIPV6ENA, 1);
index 46c3c1c..859ded0 100644 (file)
@@ -166,6 +166,7 @@ enum xgbe_port_mode {
        XGBE_PORT_MODE_10GBASE_T,
        XGBE_PORT_MODE_10GBASE_R,
        XGBE_PORT_MODE_SFP,
+       XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG,
        XGBE_PORT_MODE_MAX,
 };
 
@@ -1634,6 +1635,7 @@ static enum xgbe_mode xgbe_phy_an73_redrv_outcome(struct xgbe_prv_data *pdata)
        if (ad_reg & 0x80) {
                switch (phy_data->port_mode) {
                case XGBE_PORT_MODE_BACKPLANE:
+               case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                        mode = XGBE_MODE_KR;
                        break;
                default:
@@ -1643,6 +1645,7 @@ static enum xgbe_mode xgbe_phy_an73_redrv_outcome(struct xgbe_prv_data *pdata)
        } else if (ad_reg & 0x20) {
                switch (phy_data->port_mode) {
                case XGBE_PORT_MODE_BACKPLANE:
+               case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                        mode = XGBE_MODE_KX_1000;
                        break;
                case XGBE_PORT_MODE_1000BASE_X:
@@ -1782,6 +1785,7 @@ static void xgbe_phy_an_advertising(struct xgbe_prv_data *pdata,
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                XGBE_SET_ADV(dlks, 10000baseKR_Full);
                break;
        case XGBE_PORT_MODE_BACKPLANE_2500:
@@ -1874,6 +1878,7 @@ static enum xgbe_an_mode xgbe_phy_an_mode(struct xgbe_prv_data *pdata)
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
                return XGBE_AN_MODE_CL73;
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
        case XGBE_PORT_MODE_BACKPLANE_2500:
                return XGBE_AN_MODE_NONE;
        case XGBE_PORT_MODE_1000BASE_T:
@@ -2156,6 +2161,7 @@ static enum xgbe_mode xgbe_phy_switch_mode(struct xgbe_prv_data *pdata)
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                return xgbe_phy_switch_bp_mode(pdata);
        case XGBE_PORT_MODE_BACKPLANE_2500:
                return xgbe_phy_switch_bp_2500_mode(pdata);
@@ -2251,6 +2257,7 @@ static enum xgbe_mode xgbe_phy_get_mode(struct xgbe_prv_data *pdata,
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                return xgbe_phy_get_bp_mode(speed);
        case XGBE_PORT_MODE_BACKPLANE_2500:
                return xgbe_phy_get_bp_2500_mode(speed);
@@ -2426,6 +2433,7 @@ static bool xgbe_phy_use_mode(struct xgbe_prv_data *pdata, enum xgbe_mode mode)
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                return xgbe_phy_use_bp_mode(pdata, mode);
        case XGBE_PORT_MODE_BACKPLANE_2500:
                return xgbe_phy_use_bp_2500_mode(pdata, mode);
@@ -2515,6 +2523,7 @@ static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                return xgbe_phy_valid_speed_bp_mode(speed);
        case XGBE_PORT_MODE_BACKPLANE_2500:
                return xgbe_phy_valid_speed_bp_2500_mode(speed);
@@ -2792,6 +2801,7 @@ static bool xgbe_phy_port_mode_mismatch(struct xgbe_prv_data *pdata)
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                if ((phy_data->port_speeds & XGBE_PHY_PORT_SPEED_1000) ||
                    (phy_data->port_speeds & XGBE_PHY_PORT_SPEED_10000))
                        return false;
@@ -2844,6 +2854,7 @@ static bool xgbe_phy_conn_type_mismatch(struct xgbe_prv_data *pdata)
 
        switch (phy_data->port_mode) {
        case XGBE_PORT_MODE_BACKPLANE:
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
        case XGBE_PORT_MODE_BACKPLANE_2500:
                if (phy_data->conn_type == XGBE_CONN_TYPE_BACKPLANE)
                        return false;
@@ -3160,6 +3171,8 @@ static int xgbe_phy_init(struct xgbe_prv_data *pdata)
        /* Backplane support */
        case XGBE_PORT_MODE_BACKPLANE:
                XGBE_SET_SUP(lks, Autoneg);
+               fallthrough;
+       case XGBE_PORT_MODE_BACKPLANE_NO_AUTONEG:
                XGBE_SET_SUP(lks, Pause);
                XGBE_SET_SUP(lks, Asym_Pause);
                XGBE_SET_SUP(lks, Backplane);
index 16a9447..8941ac4 100644 (file)
@@ -1631,8 +1631,8 @@ static int hw_atl_b0_get_mac_temp(struct aq_hw_s *self, u32 *temp)
                hw_atl_ts_reset_set(self, 0);
        }
 
-       err = readx_poll_timeout_atomic(hw_atl_b0_ts_ready_and_latch_high_get,
-                                       self, val, val == 1, 10000U, 500000U);
+       err = readx_poll_timeout(hw_atl_b0_ts_ready_and_latch_high_get, self,
+                                val, val == 1, 10000U, 500000U);
        if (err)
                return err;
 
index 0187dbf..54cdafd 100644 (file)
@@ -153,6 +153,7 @@ int arc_mdio_probe(struct arc_emac_priv *priv)
        if (IS_ERR(data->reset_gpio)) {
                error = PTR_ERR(data->reset_gpio);
                dev_err(priv->dev, "Failed to request gpio: %d\n", error);
+               mdiobus_free(bus);
                return error;
        }
 
index dfed9ad..0762d5d 100644 (file)
@@ -2491,8 +2491,10 @@ static int bcm_sysport_probe(struct platform_device *pdev)
        priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
                                      sizeof(struct bcm_sysport_tx_ring),
                                      GFP_KERNEL);
-       if (!priv->tx_rings)
-               return -ENOMEM;
+       if (!priv->tx_rings) {
+               ret = -ENOMEM;
+               goto err_free_netdev;
+       }
 
        priv->is_lite = params->is_lite;
        priv->num_rx_desc_words = params->num_rx_desc_words;
index 34d1830..a5fd161 100644 (file)
@@ -217,7 +217,7 @@ static int bgmac_probe(struct bcma_device *core)
        /* BCM 471X/535X family */
        case BCMA_CHIP_ID_BCM4716:
                bgmac->feature_flags |= BGMAC_FEAT_CLKCTLST;
-               /* fallthrough */
+               fallthrough;
        case BCMA_CHIP_ID_BCM47162:
                bgmac->feature_flags |= BGMAC_FEAT_FLW_CTRL2;
                bgmac->feature_flags |= BGMAC_FEAT_SET_RXQ_CLK;
index 6795b6d..f37f1c5 100644 (file)
@@ -131,7 +131,7 @@ static void bgmac_nicpm_speed_set(struct net_device *net_dev)
        switch (bgmac->net_dev->phydev->speed) {
        default:
                netdev_err(net_dev, "Unsupported speed. Defaulting to 1000Mb\n");
-               /* fall through */
+               fallthrough;
        case SPEED_1000:
                val |= NICPM_IOMUX_CTRL_SPD_1000M << NICPM_IOMUX_CTRL_SPD_SHIFT;
                break;
index c8cc14e..3e8a179 100644 (file)
@@ -1337,13 +1337,13 @@ bnx2_set_mac_link(struct bnx2 *bp)
                                        val |= BNX2_EMAC_MODE_PORT_MII_10M;
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        case SPEED_100:
                                val |= BNX2_EMAC_MODE_PORT_MII;
                                break;
                        case SPEED_2500:
                                val |= BNX2_EMAC_MODE_25G_MODE;
-                               /* fall through */
+                               fallthrough;
                        case SPEED_1000:
                                val |= BNX2_EMAC_MODE_PORT_GMII;
                                break;
@@ -1995,26 +1995,26 @@ bnx2_remote_phy_event(struct bnx2 *bp)
                switch (speed) {
                        case BNX2_LINK_STATUS_10HALF:
                                bp->duplex = DUPLEX_HALF;
-                               /* fall through */
+                               fallthrough;
                        case BNX2_LINK_STATUS_10FULL:
                                bp->line_speed = SPEED_10;
                                break;
                        case BNX2_LINK_STATUS_100HALF:
                                bp->duplex = DUPLEX_HALF;
-                               /* fall through */
+                               fallthrough;
                        case BNX2_LINK_STATUS_100BASE_T4:
                        case BNX2_LINK_STATUS_100FULL:
                                bp->line_speed = SPEED_100;
                                break;
                        case BNX2_LINK_STATUS_1000HALF:
                                bp->duplex = DUPLEX_HALF;
-                               /* fall through */
+                               fallthrough;
                        case BNX2_LINK_STATUS_1000FULL:
                                bp->line_speed = SPEED_1000;
                                break;
                        case BNX2_LINK_STATUS_2500HALF:
                                bp->duplex = DUPLEX_HALF;
-                               /* fall through */
+                               fallthrough;
                        case BNX2_LINK_STATUS_2500FULL:
                                bp->line_speed = SPEED_2500;
                                break;
@@ -7856,7 +7856,7 @@ bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                data->phy_id = bp->phy_addr;
 
-               /* fallthru */
+               fallthrough;
        case SIOCGMIIREG: {
                u32 mii_regval;
 
index 1426c69..4e85e7d 100644 (file)
@@ -4712,14 +4712,14 @@ static void bnx2x_sync_link(struct link_params *params,
                        LINK_STATUS_SPEED_AND_DUPLEX_MASK) {
                case LINK_10THD:
                        vars->duplex = DUPLEX_HALF;
-                       /* Fall thru */
+                       fallthrough;
                case LINK_10TFD:
                        vars->line_speed = SPEED_10;
                        break;
 
                case LINK_100TXHD:
                        vars->duplex = DUPLEX_HALF;
-                       /* Fall thru */
+                       fallthrough;
                case LINK_100T4:
                case LINK_100TXFD:
                        vars->line_speed = SPEED_100;
@@ -4727,14 +4727,14 @@ static void bnx2x_sync_link(struct link_params *params,
 
                case LINK_1000THD:
                        vars->duplex = DUPLEX_HALF;
-                       /* Fall thru */
+                       fallthrough;
                case LINK_1000TFD:
                        vars->line_speed = SPEED_1000;
                        break;
 
                case LINK_2500THD:
                        vars->duplex = DUPLEX_HALF;
-                       /* Fall thru */
+                       fallthrough;
                case LINK_2500TFD:
                        vars->line_speed = SPEED_2500;
                        break;
@@ -6339,7 +6339,7 @@ int bnx2x_set_led(struct link_params *params,
                 */
                if (!vars->link_up)
                        break;
-               /* fall through */
+               fallthrough;
        case LED_MODE_ON:
                if (((params->phy[EXT_PHY1].type ==
                          PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM8727) ||
@@ -12508,13 +12508,13 @@ static void bnx2x_phy_def_cfg(struct link_params *params,
        switch (link_config  & PORT_FEATURE_LINK_SPEED_MASK) {
        case PORT_FEATURE_LINK_SPEED_10M_HALF:
                phy->req_duplex = DUPLEX_HALF;
-               /* fall through */
+               fallthrough;
        case PORT_FEATURE_LINK_SPEED_10M_FULL:
                phy->req_line_speed = SPEED_10;
                break;
        case PORT_FEATURE_LINK_SPEED_100M_HALF:
                phy->req_duplex = DUPLEX_HALF;
-               /* fall through */
+               fallthrough;
        case PORT_FEATURE_LINK_SPEED_100M_FULL:
                phy->req_line_speed = SPEED_100;
                break;
index 7f24d26..3c543dd 100644 (file)
@@ -8600,11 +8600,11 @@ int bnx2x_set_int_mode(struct bnx2x *bp)
                               bp->num_queues,
                               1 + bp->num_cnic_queues);
 
-               /* fall through */
+               fallthrough;
        case BNX2X_INT_MODE_MSI:
                bnx2x_enable_msi(bp);
 
-               /* fall through */
+               fallthrough;
        case BNX2X_INT_MODE_INTX:
                bp->num_ethernet_queues = 1;
                bp->num_queues = bp->num_ethernet_queues + bp->num_cnic_queues;
index 80d250a..e26f4da 100644 (file)
@@ -3258,7 +3258,7 @@ static int bnx2x_mcast_validate_e2(struct bnx2x *bp,
        /* DEL command deletes all currently configured MACs */
        case BNX2X_MCAST_CMD_DEL:
                o->set_registry_size(o, 0);
-               /* fall through */
+               fallthrough;
 
        /* RESTORE command will restore the entire multicast configuration */
        case BNX2X_MCAST_CMD_RESTORE:
@@ -3592,7 +3592,7 @@ static int bnx2x_mcast_validate_e1(struct bnx2x *bp,
        /* DEL command deletes all currently configured MACs */
        case BNX2X_MCAST_CMD_DEL:
                o->set_registry_size(o, 0);
-               /* fall through */
+               fallthrough;
 
        /* RESTORE command will restore the entire multicast configuration */
        case BNX2X_MCAST_CMD_RESTORE:
index b4476f4..9c2f51f 100644 (file)
@@ -1809,7 +1809,7 @@ get_vf:
                DP(BNX2X_MSG_IOV, "got VF [%d:%d] RSS update ramrod\n",
                   vf->abs_vfid, qidx);
                bnx2x_vf_handle_rss_update_eqe(bp, vf);
-               /* fall through */
+               fallthrough;
        case EVENT_RING_OPCODE_VF_FLR:
                /* Do nothing for now */
                return 0;
@@ -2207,7 +2207,7 @@ int bnx2x_vf_free(struct bnx2x *bp, struct bnx2x_virtf *vf)
                rc = bnx2x_vf_close(bp, vf);
                if (rc)
                        goto op_err;
-               /* Fall through - to release resources */
+               fallthrough;    /* to release resources */
        case VF_ACQUIRED:
                DP(BNX2X_MSG_IOV, "about to free resources\n");
                bnx2x_vf_free_resc(bp, vf);
index 31fb5a2..b167066 100644 (file)
@@ -1141,6 +1141,9 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
 
 static void bnxt_queue_fw_reset_work(struct bnxt *bp, unsigned long delay)
 {
+       if (!(test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)))
+               return;
+
        if (BNXT_PF(bp))
                queue_delayed_work(bnxt_pf_wq, &bp->fw_reset_task, delay);
        else
@@ -1157,10 +1160,12 @@ static void bnxt_queue_sp_work(struct bnxt *bp)
 
 static void bnxt_cancel_sp_work(struct bnxt *bp)
 {
-       if (BNXT_PF(bp))
+       if (BNXT_PF(bp)) {
                flush_workqueue(bnxt_pf_wq);
-       else
+       } 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)
@@ -1923,7 +1928,7 @@ u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx)
                break;
        case BNXT_FW_HEALTH_REG_TYPE_GRC:
                reg_off = fw_health->mapped_regs[reg_idx];
-               /* fall through */
+               fallthrough;
        case BNXT_FW_HEALTH_REG_TYPE_BAR0:
                val = readl(bp->bar0 + reg_off);
                break;
@@ -1966,11 +1971,11 @@ static int bnxt_async_event_process(struct bnxt *bp,
                }
                set_bit(BNXT_LINK_SPEED_CHNG_SP_EVENT, &bp->sp_event);
        }
-       /* fall through */
+               fallthrough;
        case ASYNC_EVENT_CMPL_EVENT_ID_LINK_SPEED_CHANGE:
        case ASYNC_EVENT_CMPL_EVENT_ID_PORT_PHY_CFG_CHANGE:
                set_bit(BNXT_LINK_CFG_CHANGE_SP_EVENT, &bp->sp_event);
-               /* fall through */
+               fallthrough;
        case ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE:
                set_bit(BNXT_LINK_CHNG_SP_EVENT, &bp->sp_event);
                break;
@@ -6102,6 +6107,21 @@ static int bnxt_get_func_stat_ctxs(struct bnxt *bp)
        return cp + ulp_stat;
 }
 
+/* Check if a default RSS map needs to be setup.  This function is only
+ * used on older firmware that does not require reserving RX rings.
+ */
+static void bnxt_check_rss_tbl_no_rmgr(struct bnxt *bp)
+{
+       struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
+
+       /* The RSS map is valid for RX rings set to resv_rx_rings */
+       if (hw_resc->resv_rx_rings != bp->rx_nr_rings) {
+               hw_resc->resv_rx_rings = bp->rx_nr_rings;
+               if (!netif_is_rxfh_configured(bp->dev))
+                       bnxt_set_dflt_rss_indir_tbl(bp);
+       }
+}
+
 static bool bnxt_need_reserve_rings(struct bnxt *bp)
 {
        struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
@@ -6110,22 +6130,28 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp)
        int rx = bp->rx_nr_rings, stat;
        int vnic = 1, grp = rx;
 
-       if (bp->hwrm_spec_code < 0x10601)
-               return false;
-
-       if (hw_resc->resv_tx_rings != bp->tx_nr_rings)
+       if (hw_resc->resv_tx_rings != bp->tx_nr_rings &&
+           bp->hwrm_spec_code >= 0x10601)
                return true;
 
+       /* Old firmware does not need RX ring reservations but we still
+        * need to setup a default RSS map when needed.  With new firmware
+        * we go through RX ring reservations first and then set up the
+        * RSS map for the successfully reserved RX rings when needed.
+        */
+       if (!BNXT_NEW_RM(bp)) {
+               bnxt_check_rss_tbl_no_rmgr(bp);
+               return false;
+       }
        if ((bp->flags & BNXT_FLAG_RFS) && !(bp->flags & BNXT_FLAG_CHIP_P5))
                vnic = rx + 1;
        if (bp->flags & BNXT_FLAG_AGG_RINGS)
                rx <<= 1;
        stat = bnxt_get_func_stat_ctxs(bp);
-       if (BNXT_NEW_RM(bp) &&
-           (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp ||
-            hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat ||
-            (hw_resc->resv_hw_ring_grps != grp &&
-             !(bp->flags & BNXT_FLAG_CHIP_P5))))
+       if (hw_resc->resv_rx_rings != rx || hw_resc->resv_cp_rings != cp ||
+           hw_resc->resv_vnics != vnic || hw_resc->resv_stat_ctxs != stat ||
+           (hw_resc->resv_hw_ring_grps != grp &&
+            !(bp->flags & BNXT_FLAG_CHIP_P5)))
                return true;
        if ((bp->flags & BNXT_FLAG_CHIP_P5) && BNXT_PF(bp) &&
            hw_resc->resv_irqs != nq)
@@ -6214,6 +6240,9 @@ static int __bnxt_reserve_rings(struct bnxt *bp)
        if (!tx || !rx || !cp || !grp || !vnic || !stat)
                return -ENOMEM;
 
+       if (!netif_is_rxfh_configured(bp->dev))
+               bnxt_set_dflt_rss_indir_tbl(bp);
+
        return rc;
 }
 
@@ -8495,9 +8524,6 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init)
                        rc = bnxt_init_int_mode(bp);
                bnxt_ulp_irq_restart(bp, rc);
        }
-       if (!netif_is_rxfh_configured(bp->dev))
-               bnxt_set_dflt_rss_indir_tbl(bp);
-
        if (rc) {
                netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc);
                return rc;
@@ -9284,16 +9310,19 @@ static ssize_t bnxt_show_temp(struct device *dev,
        struct hwrm_temp_monitor_query_input req = {0};
        struct hwrm_temp_monitor_query_output *resp;
        struct bnxt *bp = dev_get_drvdata(dev);
-       u32 temp = 0;
+       u32 len = 0;
 
        resp = bp->hwrm_cmd_resp_addr;
        bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_TEMP_MONITOR_QUERY, -1, -1);
        mutex_lock(&bp->hwrm_cmd_lock);
-       if (!_hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
-               temp = resp->temp * 1000; /* display millidegree */
+       if (!_hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT))
+               len = sprintf(buf, "%u\n", resp->temp * 1000); /* display millidegree */
        mutex_unlock(&bp->hwrm_cmd_lock);
 
-       return sprintf(buf, "%u\n", temp);
+       if (len)
+               return len;
+
+       return sprintf(buf, "unknown\n");
 }
 static SENSOR_DEVICE_ATTR(temp1_input, 0444, bnxt_show_temp, NULL, 0);
 
@@ -9475,15 +9504,15 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
                }
        }
 
-       bnxt_enable_napi(bp);
-       bnxt_debug_dev_init(bp);
-
        rc = bnxt_init_nic(bp, irq_re_init);
        if (rc) {
                netdev_err(bp->dev, "bnxt_init_nic err: %x\n", rc);
-               goto open_err;
+               goto open_err_irq;
        }
 
+       bnxt_enable_napi(bp);
+       bnxt_debug_dev_init(bp);
+
        if (link_re_init) {
                mutex_lock(&bp->link_lock);
                rc = bnxt_update_phy_setting(bp);
@@ -9514,10 +9543,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
                bnxt_vf_reps_open(bp);
        return 0;
 
-open_err:
-       bnxt_debug_dev_exit(bp);
-       bnxt_disable_napi(bp);
-
 open_err_irq:
        bnxt_del_napi(bp);
 
@@ -9765,7 +9790,7 @@ static int bnxt_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                mdio->phy_id = bp->link_info.phy_addr;
 
-               /* fallthru */
+               fallthrough;
        case SIOCGMIIREG: {
                u16 mii_regval = 0;
 
@@ -11022,7 +11047,7 @@ static void bnxt_fw_reset_writel(struct bnxt *bp, int reg_idx)
                writel(reg_off & BNXT_GRC_BASE_MASK,
                       bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 4);
                reg_off = (reg_off & BNXT_GRC_OFFSET_MASK) + 0x2000;
-               /* fall through */
+               fallthrough;
        case BNXT_FW_HEALTH_REG_TYPE_BAR0:
                writel(val, bp->bar0 + reg_off);
                break;
@@ -11135,7 +11160,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
                }
                bp->fw_reset_state = BNXT_FW_RESET_STATE_RESET_FW;
        }
-       /* fall through */
+               fallthrough;
        case BNXT_FW_RESET_STATE_RESET_FW:
                bnxt_reset_all(bp);
                bp->fw_reset_state = BNXT_FW_RESET_STATE_ENABLE_DEV;
@@ -11158,7 +11183,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
                }
                pci_set_master(bp->pdev);
                bp->fw_reset_state = BNXT_FW_RESET_STATE_POLL_FW;
-               /* fall through */
+               fallthrough;
        case BNXT_FW_RESET_STATE_POLL_FW:
                bp->hwrm_cmd_timeout = SHORT_HWRM_CMD_TIMEOUT;
                rc = __bnxt_hwrm_ver_get(bp, true);
@@ -11173,7 +11198,7 @@ static void bnxt_fw_reset_task(struct work_struct *work)
                }
                bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
                bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING;
-               /* fall through */
+               fallthrough;
        case BNXT_FW_RESET_STATE_OPENING:
                while (!rtnl_trylock()) {
                        bnxt_queue_fw_reset_work(bp, HZ / 10);
@@ -11761,6 +11786,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
        unregister_netdev(dev);
        bnxt_dl_unregister(bp);
        bnxt_shutdown_tc(bp);
+       clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
        bnxt_cancel_sp_work(bp);
        bp->sp_event = 0;
 
@@ -12200,6 +12226,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (BNXT_CHIP_P5(bp))
                bp->flags |= BNXT_FLAG_CHIP_P5;
 
+       rc = bnxt_alloc_rss_indir_tbl(bp);
+       if (rc)
+               goto init_err_pci_clean;
+
        rc = bnxt_fw_init_one_p2(bp);
        if (rc)
                goto init_err_pci_clean;
@@ -12304,11 +12334,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
         */
        bp->tx_nr_rings_per_tc = bp->tx_nr_rings;
 
-       rc = bnxt_alloc_rss_indir_tbl(bp);
-       if (rc)
-               goto init_err_pci_clean;
-       bnxt_set_dflt_rss_indir_tbl(bp);
-
        if (BNXT_PF(bp)) {
                if (!bnxt_pf_wq) {
                        bnxt_pf_wq =
@@ -12339,6 +12364,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                    (long)pci_resource_start(pdev, 0), dev->dev_addr);
        pcie_print_link_status(pdev);
 
+       pci_save_state(pdev);
        return 0;
 
 init_err_cleanup:
@@ -12536,6 +12562,8 @@ 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);
+               pci_restore_state(pdev);
+               pci_save_state(pdev);
 
                err = bnxt_hwrm_func_reset(bp);
                if (!err) {
index 64da654..d092833 100644 (file)
@@ -472,20 +472,13 @@ static int bnxt_get_num_tpa_ring_stats(struct bnxt *bp)
 static int bnxt_get_num_ring_stats(struct bnxt *bp)
 {
        int rx, tx, cmn;
-       bool sh = false;
-
-       if (bp->flags & BNXT_FLAG_SHARED_RINGS)
-               sh = true;
 
        rx = NUM_RING_RX_HW_STATS + NUM_RING_RX_SW_STATS +
             bnxt_get_num_tpa_ring_stats(bp);
        tx = NUM_RING_TX_HW_STATS;
        cmn = NUM_RING_CMN_SW_STATS;
-       if (sh)
-               return (rx + tx + cmn) * bp->cp_nr_rings;
-       else
-               return rx * bp->rx_nr_rings + tx * bp->tx_nr_rings +
-                      cmn * bp->cp_nr_rings;
+       return rx * bp->rx_nr_rings + tx * bp->tx_nr_rings +
+              cmn * bp->cp_nr_rings;
 }
 
 static int bnxt_get_num_stats(struct bnxt *bp)
@@ -806,7 +799,7 @@ static void bnxt_get_channels(struct net_device *dev,
        int max_tx_sch_inputs;
 
        /* Get the most up-to-date max_tx_sch_inputs. */
-       if (BNXT_NEW_RM(bp))
+       if (netif_running(dev) && BNXT_NEW_RM(bp))
                bnxt_hwrm_func_resc_qcaps(bp, false);
        max_tx_sch_inputs = hw_resc->max_tx_sch_inputs;
 
@@ -1073,7 +1066,7 @@ static int bnxt_grxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd)
                if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4)
                        cmd->data |= RXH_IP_SRC | RXH_IP_DST |
                                     RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* fall through */
+               fallthrough;
        case SCTP_V4_FLOW:
        case AH_ESP_V4_FLOW:
        case AH_V4_FLOW:
@@ -1092,7 +1085,7 @@ static int bnxt_grxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd)
                if (bp->rss_hash_cfg & VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6)
                        cmd->data |= RXH_IP_SRC | RXH_IP_DST |
                                     RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* fall through */
+               fallthrough;
        case SCTP_V6_FLOW:
        case AH_ESP_V6_FLOW:
        case AH_V6_FLOW:
@@ -2323,6 +2316,9 @@ static int bnxt_get_nvram_directory(struct net_device *dev, u32 len, u8 *data)
        if (rc != 0)
                return rc;
 
+       if (!dir_entries || !entry_length)
+               return -EIO;
+
        /* Insert 2 bytes of directory info (count and size of entries) */
        if (len < 2)
                return -EINVAL;
index 2704a47..fcc2620 100644 (file)
@@ -201,10 +201,10 @@ bool bnxt_rx_xdp(struct bnxt *bp, struct bnxt_rx_ring_info *rxr, u16 cons,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* Fall thru */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(bp->dev, xdp_prog, act);
-               /* Fall thru */
+               fallthrough;
        case XDP_DROP:
                bnxt_reuse_rx_data(rxr, cons, page);
                break;
index c5cca63..8453629 100644 (file)
@@ -3311,7 +3311,7 @@ static int cnic_ctl(void *data, struct cnic_ctl_info *info)
        }
        case CNIC_CTL_FCOE_STATS_GET_CMD:
                ulp_type = CNIC_ULP_FCOE;
-               /* fall through */
+               fallthrough;
        case CNIC_CTL_ISCSI_STATS_GET_CMD:
                cnic_hold(dev);
                cnic_copy_ulp_stats(dev, ulp_type);
@@ -4044,7 +4044,7 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe)
                            l4kcqe->status, l5kcqe->completion_status);
                opcode = L4_KCQE_OPCODE_VALUE_CLOSE_COMP;
        }
-               /* Fall through */
+               fallthrough;
        case L4_KCQE_OPCODE_VALUE_RESET_RECEIVED:
        case L4_KCQE_OPCODE_VALUE_CLOSE_COMP:
        case L4_KCQE_OPCODE_VALUE_RESET_COMP:
index 1fecc25..be85dad 100644 (file)
@@ -1185,10 +1185,10 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)
                        continue;
                case BCMGENET_STAT_RUNT:
                        offset += BCMGENET_STAT_OFFSET;
-                       /* fall through */
+                       fallthrough;
                case BCMGENET_STAT_MIB_TX:
                        offset += BCMGENET_STAT_OFFSET;
-                       /* fall through */
+                       fallthrough;
                case BCMGENET_STAT_MIB_RX:
                        val = bcmgenet_umac_readl(priv,
                                                  UMAC_MIB_START + j + offset);
@@ -1364,7 +1364,7 @@ static int bcmgenet_validate_flow(struct net_device *dev,
        case ETHER_FLOW:
                eth_mask = &cmd->fs.m_u.ether_spec;
                /* don't allow mask which isn't valid */
-               if (VALIDATE_MASK(eth_mask->h_source) ||
+               if (VALIDATE_MASK(eth_mask->h_dest) ||
                    VALIDATE_MASK(eth_mask->h_source) ||
                    VALIDATE_MASK(eth_mask->h_proto)) {
                        netdev_err(dev, "rxnfc: Unsupported mask\n");
index 511d553..6fb6c35 100644 (file)
@@ -192,7 +192,7 @@ int bcmgenet_mii_config(struct net_device *dev, bool init)
        switch (priv->phy_interface) {
        case PHY_INTERFACE_MODE_INTERNAL:
                phy_name = "internal PHY";
-               /* fall through */
+               fallthrough;
        case PHY_INTERFACE_MODE_MOCA:
                /* Irrespective of the actually configured PHY speed (100 or
                 * 1000) GENETv4 only has an internal GPHY so we will just end
index ebff1fc..5143cdd 100644 (file)
@@ -715,7 +715,7 @@ static int tg3_ape_lock(struct tg3 *tp, int locknum)
        case TG3_APE_LOCK_GPIO:
                if (tg3_asic_rev(tp) == ASIC_REV_5761)
                        return 0;
-               /* fall through */
+               fallthrough;
        case TG3_APE_LOCK_GRC:
        case TG3_APE_LOCK_MEM:
                if (!tp->pci_fn)
@@ -776,7 +776,7 @@ static void tg3_ape_unlock(struct tg3 *tp, int locknum)
        case TG3_APE_LOCK_GPIO:
                if (tg3_asic_rev(tp) == ASIC_REV_5761)
                        return;
-               /* fall through */
+               fallthrough;
        case TG3_APE_LOCK_GRC:
        case TG3_APE_LOCK_MEM:
                if (!tp->pci_fn)
@@ -1586,7 +1586,7 @@ static int tg3_mdio_init(struct tg3 *tp)
                        phydev->dev_flags |= PHY_BRCM_EXT_IBND_RX_ENABLE;
                if (tg3_flag(tp, RGMII_EXT_IBND_TX_EN))
                        phydev->dev_flags |= PHY_BRCM_EXT_IBND_TX_ENABLE;
-               /* fall through */
+               fallthrough;
        case PHY_ID_RTL8211C:
                phydev->interface = PHY_INTERFACE_MODE_RGMII;
                break;
@@ -2114,7 +2114,7 @@ static int tg3_phy_init(struct tg3 *tp)
                        phy_support_asym_pause(phydev);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case PHY_INTERFACE_MODE_MII:
                phy_set_max_speed(phydev, SPEED_100);
                phy_support_asym_pause(phydev);
@@ -4390,7 +4390,7 @@ static int tg3_phy_autoneg_cfg(struct tg3 *tp, u32 advertise, u32 flowctrl)
                                      MII_TG3_DSP_TAP26_RMRXSTO |
                                      MII_TG3_DSP_TAP26_OPCSINPT;
                        tg3_phydsp_write(tp, MII_TG3_DSP_TAP26, val);
-                       /* Fall through */
+                       fallthrough;
                case ASIC_REV_5720:
                case ASIC_REV_5762:
                        if (!tg3_phydsp_read(tp, MII_TG3_DSP_CH34TP2, &val))
@@ -4538,7 +4538,7 @@ static int tg3_phy_pull_config(struct tg3 *tp)
                                tp->link_config.speed = SPEED_1000;
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                default:
                        goto done;
                }
@@ -5209,7 +5209,7 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
                if (ap->flags & (MR_AN_ENABLE | MR_RESTART_AN))
                        ap->state = ANEG_STATE_AN_ENABLE;
 
-               /* fall through */
+               fallthrough;
        case ANEG_STATE_AN_ENABLE:
                ap->flags &= ~(MR_AN_COMPLETE | MR_PAGE_RX);
                if (ap->flags & MR_AN_ENABLE) {
@@ -5239,7 +5239,7 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
                ret = ANEG_TIMER_ENAB;
                ap->state = ANEG_STATE_RESTART;
 
-               /* fall through */
+               fallthrough;
        case ANEG_STATE_RESTART:
                delta = ap->cur_time - ap->link_time;
                if (delta > ANEG_STATE_SETTLE_TIME)
@@ -5282,7 +5282,7 @@ static int tg3_fiber_aneg_smachine(struct tg3 *tp,
 
                ap->state = ANEG_STATE_ACK_DETECT;
 
-               /* fall through */
+               fallthrough;
        case ANEG_STATE_ACK_DETECT:
                if (ap->ack_match != 0) {
                        if ((ap->rxconfig & ~ANEG_CFG_ACK) ==
@@ -7221,8 +7221,8 @@ static inline void tg3_reset_task_schedule(struct tg3 *tp)
 
 static inline void tg3_reset_task_cancel(struct tg3 *tp)
 {
-       cancel_work_sync(&tp->reset_task);
-       tg3_flag_clear(tp, RESET_TASK_PENDING);
+       if (test_and_clear_bit(TG3_FLAG_RESET_TASK_PENDING, tp->tg3_flags))
+               cancel_work_sync(&tp->reset_task);
        tg3_flag_clear(tp, TX_RECOVERY_PENDING);
 }
 
@@ -10720,40 +10720,40 @@ static int tg3_reset_hw(struct tg3 *tp, bool reset_phy)
        switch (limit) {
        case 16:
                tw32(MAC_RCV_RULE_15,  0); tw32(MAC_RCV_VALUE_15,  0);
-               /* fall through */
+               fallthrough;
        case 15:
                tw32(MAC_RCV_RULE_14,  0); tw32(MAC_RCV_VALUE_14,  0);
-               /* fall through */
+               fallthrough;
        case 14:
                tw32(MAC_RCV_RULE_13,  0); tw32(MAC_RCV_VALUE_13,  0);
-               /* fall through */
+               fallthrough;
        case 13:
                tw32(MAC_RCV_RULE_12,  0); tw32(MAC_RCV_VALUE_12,  0);
-               /* fall through */
+               fallthrough;
        case 12:
                tw32(MAC_RCV_RULE_11,  0); tw32(MAC_RCV_VALUE_11,  0);
-               /* fall through */
+               fallthrough;
        case 11:
                tw32(MAC_RCV_RULE_10,  0); tw32(MAC_RCV_VALUE_10,  0);
-               /* fall through */
+               fallthrough;
        case 10:
                tw32(MAC_RCV_RULE_9,  0); tw32(MAC_RCV_VALUE_9,  0);
-               /* fall through */
+               fallthrough;
        case 9:
                tw32(MAC_RCV_RULE_8,  0); tw32(MAC_RCV_VALUE_8,  0);
-               /* fall through */
+               fallthrough;
        case 8:
                tw32(MAC_RCV_RULE_7,  0); tw32(MAC_RCV_VALUE_7,  0);
-               /* fall through */
+               fallthrough;
        case 7:
                tw32(MAC_RCV_RULE_6,  0); tw32(MAC_RCV_VALUE_6,  0);
-               /* fall through */
+               fallthrough;
        case 6:
                tw32(MAC_RCV_RULE_5,  0); tw32(MAC_RCV_VALUE_5,  0);
-               /* fall through */
+               fallthrough;
        case 5:
                tw32(MAC_RCV_RULE_4,  0); tw32(MAC_RCV_VALUE_4,  0);
-               /* fall through */
+               fallthrough;
        case 4:
                /* tw32(MAC_RCV_RULE_3,  0); tw32(MAC_RCV_VALUE_3,  0); */
        case 3:
@@ -11209,18 +11209,27 @@ static void tg3_reset_task(struct work_struct *work)
 
        tg3_halt(tp, RESET_KIND_SHUTDOWN, 0);
        err = tg3_init_hw(tp, true);
-       if (err)
+       if (err) {
+               tg3_full_unlock(tp);
+               tp->irq_sync = 0;
+               tg3_napi_enable(tp);
+               /* Clear this flag so that tg3_reset_task_cancel() will not
+                * call cancel_work_sync() and wait forever.
+                */
+               tg3_flag_clear(tp, RESET_TASK_PENDING);
+               dev_close(tp->dev);
                goto out;
+       }
 
        tg3_netif_start(tp);
 
-out:
        tg3_full_unlock(tp);
 
        if (!err)
                tg3_phy_start(tp);
 
        tg3_flag_clear(tp, RESET_TASK_PENDING);
+out:
        rtnl_unlock();
 }
 
@@ -13998,7 +14007,7 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                data->phy_id = tp->phy_addr;
 
-               /* fall through */
+               fallthrough;
        case SIOCGMIIREG: {
                u32 mii_regval;
 
@@ -17136,7 +17145,7 @@ static u32 tg3_calc_dma_bndry(struct tg3 *tp, u32 val)
                                val |= DMA_RWCTRL_WRITE_BNDRY_64_PCIE;
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 128:
                default:
                        val &= ~DMA_RWCTRL_WRITE_BNDRY_DISAB_PCIE;
@@ -17151,28 +17160,28 @@ static u32 tg3_calc_dma_bndry(struct tg3 *tp, u32 val)
                                        DMA_RWCTRL_WRITE_BNDRY_16);
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 32:
                        if (goal == BOUNDARY_SINGLE_CACHELINE) {
                                val |= (DMA_RWCTRL_READ_BNDRY_32 |
                                        DMA_RWCTRL_WRITE_BNDRY_32);
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 64:
                        if (goal == BOUNDARY_SINGLE_CACHELINE) {
                                val |= (DMA_RWCTRL_READ_BNDRY_64 |
                                        DMA_RWCTRL_WRITE_BNDRY_64);
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 128:
                        if (goal == BOUNDARY_SINGLE_CACHELINE) {
                                val |= (DMA_RWCTRL_READ_BNDRY_128 |
                                        DMA_RWCTRL_WRITE_BNDRY_128);
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case 256:
                        val |= (DMA_RWCTRL_READ_BNDRY_256 |
                                DMA_RWCTRL_WRITE_BNDRY_256);
index 49358d4..b9dd06b 100644 (file)
@@ -321,7 +321,7 @@ bfa_ioc_sm_getattr(struct bfa_ioc *ioc, enum ioc_event event)
        case IOC_E_PFFAILED:
        case IOC_E_HWERROR:
                del_timer(&ioc->ioc_timer);
-               /* fall through */
+               fallthrough;
        case IOC_E_TIMEOUT:
                ioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);
                bfa_fsm_set_state(ioc, bfa_ioc_sm_fail);
@@ -780,7 +780,7 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf *iocpf, enum iocpf_event event)
 
        case IOCPF_E_INITFAIL:
                del_timer(&ioc->iocpf_timer);
-               /* fall through */
+               fallthrough;
 
        case IOCPF_E_TIMEOUT:
                bfa_nw_ioc_hw_sem_release(ioc);
@@ -849,7 +849,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf *iocpf, enum iocpf_event event)
 
        case IOCPF_E_FAIL:
                del_timer(&ioc->iocpf_timer);
-               /* fall through*/
+               fallthrough;
 
        case IOCPF_E_TIMEOUT:
                bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
index 40107a9..a2c983f 100644 (file)
@@ -1084,7 +1084,7 @@ bna_enet_sm_cfg_wait(struct bna_enet *enet,
 
        case ENET_E_CHLD_STOPPED:
                bna_enet_rx_start(enet);
-               /* Fall through */
+               fallthrough;
        case ENET_E_FWRESP_PAUSE:
                if (enet->flags & BNA_ENET_F_PAUSE_CHANGED) {
                        enet->flags &= ~BNA_ENET_F_PAUSE_CHANGED;
index b5ecbfe..2623a0d 100644 (file)
@@ -1636,7 +1636,7 @@ bna_bfi_rx_enet_start(struct bna_rx *rx)
                                                &q1->qpt);
                        cfg_req->q_cfg[i].qs.rx_buffer_size =
                                htons((u16)q1->buffer_size);
-                       /* Fall through */
+                       fallthrough;
 
                case BNA_RXP_SINGLE:
                        /* Large/Single RxQ */
index 31ebf3e..283918a 100644 (file)
@@ -460,7 +460,7 @@ int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd)
        case HWTSTAMP_TX_ONESTEP_SYNC:
                if (gem_ptp_set_one_step_sync(bp, 1) != 0)
                        return -ERANGE;
-               /* fall through */
+               fallthrough;
        case HWTSTAMP_TX_ON:
                tx_bd_control = TSTAMP_ALL_FRAMES;
                break;
index e73bc21..8e0ed01 100644 (file)
@@ -977,15 +977,14 @@ static void octeon_destroy_resources(struct octeon_device *oct)
 
                schedule_timeout_uninterruptible(HZ / 10);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_HOST_OK:
 
-               /* fallthrough */
        case OCT_DEV_CONSOLE_INIT_DONE:
                /* Remove any consoles */
                octeon_remove_consoles(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_IO_QUEUES_DONE:
                if (lio_wait_for_instr_fetch(oct))
                        dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n");
@@ -1027,7 +1026,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                octeon_free_sc_done_list(oct);
                octeon_free_sc_zombie_list(oct);
 
-       /* fallthrough */
+               fallthrough;
        case OCT_DEV_INTR_SET_DONE:
                /* Disable interrupts  */
                oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
@@ -1062,17 +1061,17 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                kfree(oct->irq_name_storage);
                oct->irq_name_storage = NULL;
 
-       /* fallthrough */
+               fallthrough;
        case OCT_DEV_MSIX_ALLOC_VECTOR_DONE:
                if (OCTEON_CN23XX_PF(oct))
                        octeon_free_ioq_vector(oct);
 
-       /* fallthrough */
+               fallthrough;
        case OCT_DEV_MBOX_SETUP_DONE:
                if (OCTEON_CN23XX_PF(oct))
                        oct->fn_list.free_mbox(oct);
 
-       /* fallthrough */
+               fallthrough;
        case OCT_DEV_IN_RESET:
        case OCT_DEV_DROQ_INIT_DONE:
                /* Wait for any pending operations */
@@ -1095,11 +1094,11 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                        }
                }
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_RESP_LIST_INIT_DONE:
                octeon_delete_response_list(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_INSTR_QUEUE_INIT_DONE:
                for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
                        if (!(oct->io_qmask.iq & BIT_ULL(i)))
@@ -1110,16 +1109,16 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                if (oct->sriov_info.sriov_enabled)
                        pci_disable_sriov(oct->pci_dev);
 #endif
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_SC_BUFF_POOL_INIT_DONE:
                octeon_free_sc_buffer_pool(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_DISPATCH_INIT_DONE:
                octeon_delete_dispatch_list(oct);
                cancel_delayed_work_sync(&oct->nic_poll_work.work);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_PCI_MAP_DONE:
                refcount = octeon_deregister_device(oct);
 
@@ -1137,13 +1136,13 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                octeon_unmap_pci_barx(oct, 0);
                octeon_unmap_pci_barx(oct, 1);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_PCI_ENABLE_DONE:
                pci_clear_master(oct->pci_dev);
                /* Disable the device, releasing the PCI INT */
                pci_disable_device(oct->pci_dev);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_BEGIN_STATE:
                /* Nothing to be done here either */
                break;
@@ -2168,7 +2167,7 @@ static int liquidio_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
        case SIOCSHWTSTAMP:
                if (lio->oct_dev->ptp_enable)
                        return hwtstamp_ioctl(netdev, ifr);
-               /* fall through */
+               fallthrough;
        default:
                return -EOPNOTSUPP;
        }
index 90ef210..8c5879e 100644 (file)
@@ -460,9 +460,8 @@ static void octeon_destroy_resources(struct octeon_device *oct)
 
                schedule_timeout_uninterruptible(HZ / 10);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_HOST_OK:
-               /* fallthrough */
        case OCT_DEV_IO_QUEUES_DONE:
                if (lio_wait_for_instr_fetch(oct))
                        dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n");
@@ -504,7 +503,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                octeon_free_sc_done_list(oct);
                octeon_free_sc_zombie_list(oct);
 
-       /* fall through */
+               fallthrough;
        case OCT_DEV_INTR_SET_DONE:
                /* Disable interrupts  */
                oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
@@ -533,15 +532,15 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                else
                        cn23xx_vf_ask_pf_to_do_flr(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_MSIX_ALLOC_VECTOR_DONE:
                octeon_free_ioq_vector(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_MBOX_SETUP_DONE:
                oct->fn_list.free_mbox(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_IN_RESET:
        case OCT_DEV_DROQ_INIT_DONE:
                mdelay(100);
@@ -551,11 +550,11 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                        octeon_delete_droq(oct, i);
                }
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_RESP_LIST_INIT_DONE:
                octeon_delete_response_list(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_INSTR_QUEUE_INIT_DONE:
                for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
                        if (!(oct->io_qmask.iq & BIT_ULL(i)))
@@ -563,27 +562,27 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                        octeon_delete_instr_queue(oct, i);
                }
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_SC_BUFF_POOL_INIT_DONE:
                octeon_free_sc_buffer_pool(oct);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_DISPATCH_INIT_DONE:
                octeon_delete_dispatch_list(oct);
                cancel_delayed_work_sync(&oct->nic_poll_work.work);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_PCI_MAP_DONE:
                octeon_unmap_pci_barx(oct, 0);
                octeon_unmap_pci_barx(oct, 1);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_PCI_ENABLE_DONE:
                pci_clear_master(oct->pci_dev);
                /* Disable the device, releasing the PCI INT */
                pci_disable_device(oct->pci_dev);
 
-               /* fallthrough */
+               fallthrough;
        case OCT_DEV_BEGIN_STATE:
                /* Nothing to be done here either */
                break;
index 83dabcf..c7bdac7 100644 (file)
@@ -522,7 +522,7 @@ static int nicvf_get_rss_hash_opts(struct nicvf *nic,
        case SCTP_V4_FLOW:
        case SCTP_V6_FLOW:
                info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* Fall through */
+               fallthrough;
        case IPV4_FLOW:
        case IPV6_FLOW:
                info->data |= RXH_IP_SRC | RXH_IP_DST;
index c1378b5..063e560 100644 (file)
@@ -594,10 +594,10 @@ static inline bool nicvf_xdp_rx(struct nicvf *nic, struct bpf_prog *prog,
                return true;
        default:
                bpf_warn_invalid_xdp_action(action);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(nic->netdev, prog, action);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
                /* Check if it's a recycled page, if not
                 * unmap the DMA mapping.
index 42c6e93..387c357 100644 (file)
@@ -2543,7 +2543,7 @@ static int cxgb_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
                    !(data->phy_id & 0xe0e0))
                        data->phy_id = mdio_phy_id_c45(data->phy_id >> 8,
                                                       data->phy_id & 0x1f);
-               /* FALLTHRU */
+               fallthrough;
        case SIOCGMIIPHY:
                return mdio_mii_ioctl(&pi->phy.mdio, data, cmd);
        case SIOCCHIOCTL:
index b3e4118..9749d12 100644 (file)
@@ -136,7 +136,7 @@ again:
                if (e->state == L2T_STATE_STALE)
                        e->state = L2T_STATE_VALID;
                spin_unlock_bh(&e->lock);
-               /* fall through */
+               fallthrough;
        case L2T_STATE_VALID:   /* fast-path, send the packet on */
                return cxgb3_ofld_send(dev, skb);
        case L2T_STATE_RESOLVING:
index e3510e9..9a6d652 100644 (file)
@@ -62,6 +62,7 @@ static struct thermal_zone_device_ops cxgb4_thermal_ops = {
 int cxgb4_thermal_init(struct adapter *adap)
 {
        struct ch_thermal *ch_thermal = &adap->ch_thermal;
+       char ch_tz_name[THERMAL_NAME_LENGTH];
        int num_trip = CXGB4_NUM_TRIPS;
        u32 param, val;
        int ret;
@@ -82,7 +83,8 @@ int cxgb4_thermal_init(struct adapter *adap)
                ch_thermal->trip_type = THERMAL_TRIP_CRITICAL;
        }
 
-       ch_thermal->tzdev = thermal_zone_device_register("cxgb4", num_trip,
+       snprintf(ch_tz_name, sizeof(ch_tz_name), "cxgb4_%s", adap->name);
+       ch_thermal->tzdev = thermal_zone_device_register(ch_tz_name, num_trip,
                                                         0, adap,
                                                         &cxgb4_thermal_ops,
                                                         NULL, 0, 0);
@@ -105,7 +107,9 @@ int cxgb4_thermal_init(struct adapter *adap)
 
 int cxgb4_thermal_remove(struct adapter *adap)
 {
-       if (adap->ch_thermal.tzdev)
+       if (adap->ch_thermal.tzdev) {
                thermal_zone_device_unregister(adap->ch_thermal.tzdev);
+               adap->ch_thermal.tzdev = NULL;
+       }
        return 0;
 }
index c486412..a10a686 100644 (file)
@@ -231,7 +231,7 @@ again:
                if (e->state == L2T_STATE_STALE)
                        e->state = L2T_STATE_VALID;
                spin_unlock_bh(&e->lock);
-               /* fall through */
+               fallthrough;
        case L2T_STATE_VALID:     /* fast-path, send the packet on */
                return t4_ofld_send(adap, skb);
        case L2T_STATE_RESOLVING:
index d2b587d..869431a 100644 (file)
@@ -2553,19 +2553,22 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev)
 
        pkt_len = ETH_HLEN + sizeof(CXGB4_SELFTEST_LB_STR);
 
-       flits = DIV_ROUND_UP(pkt_len + sizeof(struct cpl_tx_pkt) +
-                            sizeof(*wr), sizeof(__be64));
+       flits = DIV_ROUND_UP(pkt_len + sizeof(*cpl) + sizeof(*wr),
+                            sizeof(__be64));
        ndesc = flits_to_desc(flits);
 
        lb = &pi->ethtool_lb;
        lb->loopback = 1;
 
        q = &adap->sge.ethtxq[pi->first_qset];
+       __netif_tx_lock(q->txq, smp_processor_id());
 
        reclaim_completed_tx(adap, &q->q, -1, true);
        credits = txq_avail(&q->q) - ndesc;
-       if (unlikely(credits < 0))
+       if (unlikely(credits < 0)) {
+               __netif_tx_unlock(q->txq);
                return -ENOMEM;
+       }
 
        wr = (void *)&q->q.desc[q->q.pidx];
        memset(wr, 0, sizeof(struct tx_desc));
@@ -2598,6 +2601,7 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev)
        init_completion(&lb->completion);
        txq_advance(&q->q, ndesc);
        cxgb4_ring_tx_db(adap, &q->q, ndesc);
+       __netif_tx_unlock(q->txq);
 
        /* wait for the pkt to return */
        ret = wait_for_completion_timeout(&lb->completion, 10 * HZ);
index 8a56491..fa33679 100644 (file)
@@ -7656,13 +7656,13 @@ int t4_alloc_vi(struct adapter *adap, unsigned int mbox, unsigned int port,
                switch (nmac) {
                case 5:
                        memcpy(mac + 24, c.nmac3, sizeof(c.nmac3));
-                       /* Fall through */
+                       fallthrough;
                case 4:
                        memcpy(mac + 18, c.nmac2, sizeof(c.nmac2));
-                       /* Fall through */
+                       fallthrough;
                case 3:
                        memcpy(mac + 12, c.nmac1, sizeof(c.nmac1));
-                       /* Fall through */
+                       fallthrough;
                case 2:
                        memcpy(mac + 6,  c.nmac0, sizeof(c.nmac0));
                }
index dbe8ee7..e2fe78e 100644 (file)
@@ -517,7 +517,7 @@ static int fwevtq_handler(struct sge_rspq *rspq, const __be64 *rsp,
                }
                cpl = (void *)p;
        }
-               /* Fall through */
+               fallthrough;
 
        case CPL_SGE_EGR_UPDATE: {
                /*
index 6bc7e7b..552d89f 100644 (file)
@@ -272,7 +272,7 @@ static netdev_features_t enic_features_check(struct sk_buff *skb,
        case ntohs(ETH_P_IPV6):
                if (!(enic->vxlan.flags & ENIC_VXLAN_INNER_IPV6))
                        goto out;
-               /* Fall through */
+               fallthrough;
        case ntohs(ETH_P_IP):
                break;
        default:
index 66e67b2..ffec0f3 100644 (file)
@@ -2389,7 +2389,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
 
        dev_info(dev, "probe %s ID %d\n", dev_name(dev), id);
 
-       netdev = alloc_etherdev_mq(sizeof(*port), TX_QUEUE_NUM);
+       netdev = devm_alloc_etherdev_mqs(dev, sizeof(*port), TX_QUEUE_NUM, TX_QUEUE_NUM);
        if (!netdev) {
                dev_err(dev, "Can't allocate ethernet device #%d\n", id);
                return -ENOMEM;
@@ -2446,8 +2446,8 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
        port->reset = devm_reset_control_get_exclusive(dev, NULL);
        if (IS_ERR(port->reset)) {
                dev_err(dev, "no reset\n");
-               clk_disable_unprepare(port->pclk);
-               return PTR_ERR(port->reset);
+               ret = PTR_ERR(port->reset);
+               goto unprepare;
        }
        reset_control_reset(port->reset);
        usleep_range(100, 500);
@@ -2502,26 +2502,25 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
                                        IRQF_SHARED,
                                        port_names[port->id],
                                        port);
-       if (ret) {
-               clk_disable_unprepare(port->pclk);
-               return ret;
-       }
+       if (ret)
+               goto unprepare;
 
        ret = register_netdev(netdev);
-       if (!ret) {
+       if (ret)
+               goto unprepare;
+
+       netdev_info(netdev,
+                   "irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
+                   port->irq, &dmares->start,
+                   &gmacres->start);
+       ret = gmac_setup_phy(netdev);
+       if (ret)
                netdev_info(netdev,
-                           "irq %d, DMA @ 0x%pap, GMAC @ 0x%pap\n",
-                           port->irq, &dmares->start,
-                           &gmacres->start);
-               ret = gmac_setup_phy(netdev);
-               if (ret)
-                       netdev_info(netdev,
-                                   "PHY init failed, deferring to ifup time\n");
-               return 0;
-       }
+                           "PHY init failed, deferring to ifup time\n");
+       return 0;
 
-       port->netdev = NULL;
-       free_netdev(netdev);
+unprepare:
+       clk_disable_unprepare(port->pclk);
        return ret;
 }
 
@@ -2530,7 +2529,6 @@ static int gemini_ethernet_port_remove(struct platform_device *pdev)
        struct gemini_ethernet_port *port = platform_get_drvdata(pdev);
 
        gemini_port_remove(port);
-       free_netdev(port->netdev);
        return 0;
 }
 
index 7f77051..5c6c8c5 100644 (file)
@@ -385,7 +385,7 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
 
        case 3:
                dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
-               /* fall through */
+               fallthrough;
        case 2:
                db->dumpblk = dm9000_dumpblk_16bit;
                db->outblk  = dm9000_outblk_16bit;
index 0ccd999..f9dd1aa 100644 (file)
@@ -3203,7 +3203,7 @@ srom_map_media(struct net_device *dev)
       case SROM_10BASETF:
        if (!lp->params.fdx) return -1;
        lp->fdx = true;
-       /* fall through */
+       fallthrough;
 
       case SROM_10BASET:
        if (lp->params.fdx && !lp->fdx) return -1;
@@ -3225,7 +3225,7 @@ srom_map_media(struct net_device *dev)
       case SROM_100BASETF:
         if (!lp->params.fdx) return -1;
        lp->fdx = true;
-       /* fall through */
+       fallthrough;
 
       case SROM_100BASET:
        if (lp->params.fdx && !lp->fdx) return -1;
@@ -3239,7 +3239,7 @@ srom_map_media(struct net_device *dev)
       case SROM_100BASEFF:
        if (!lp->params.fdx) return -1;
        lp->fdx = true;
-       /* fall through */
+       fallthrough;
 
       case SROM_100BASEF:
        if (lp->params.fdx && !lp->fdx) return -1;
index 9db2352..3a8659c 100644 (file)
@@ -911,7 +911,7 @@ static int private_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
                        data->phy_id = 1;
                else
                        return -ENODEV;
-               /* Fall through */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                if (data->phy_id == 32 && (tp->flags & HAS_NWAY)) {
index 5dcc66f..5a43be3 100644 (file)
@@ -1443,7 +1443,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = ((struct netdev_private *)netdev_priv(dev))->phys[0] & 0x1f;
-               /* Fall Through */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                spin_lock_irq(&np->lock);
index d6ed1d9..99cc1c4 100644 (file)
@@ -571,7 +571,7 @@ static u32 convert_to_et_setting(struct be_adapter *adapter, u32 if_speeds)
                                break;
                        }
                }
-               /* fall through */
+               fallthrough;
        case PHY_TYPE_SFP_PLUS_10GB:
        case PHY_TYPE_XFP_10GB:
        case PHY_TYPE_SFP_1GB:
index 43570f4..fdff3b4 100644 (file)
@@ -945,7 +945,7 @@ static void dpaa_fq_setup(struct dpaa_priv *priv,
                        break;
                case FQ_TYPE_TX_CONF_MQ:
                        priv->conf_fqs[conf_cnt++] = &fq->fq_base;
-                       /* fall through */
+                       fallthrough;
                case FQ_TYPE_TX_CONFIRM:
                        dpaa_setup_ingress(priv, fq, &fq_cbs->tx_defq);
                        break;
index 9db2a02..1268996 100644 (file)
@@ -375,7 +375,7 @@ static int dpaa_get_hash_opts(struct net_device *dev,
        case UDP_V6_FLOW:
                if (priv->keygen_in_use)
                        cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* Fall through */
+               fallthrough;
        case IPV4_FLOW:
        case IPV6_FLOW:
        case SCTP_V4_FLOW:
index 457106e..cf5383b 100644 (file)
@@ -376,10 +376,10 @@ static u32 run_xdp(struct dpaa2_eth_priv *priv,
                break;
        default:
                bpf_warn_invalid_xdp_action(xdp_act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(priv->net_dev, xdp_prog, xdp_act);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
                xdp_release_buf(priv, ch, addr);
                ch->stats.xdp_drop++;
index 9934421..fb37816 100644 (file)
@@ -3715,11 +3715,11 @@ failed_mii_init:
 failed_irq:
 failed_init:
        fec_ptp_stop(pdev);
-       if (fep->reg_phy)
-               regulator_disable(fep->reg_phy);
 failed_reset:
        pm_runtime_put_noidle(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       if (fep->reg_phy)
+               regulator_disable(fep->reg_phy);
 failed_regulator:
        clk_disable_unprepare(fep->clk_ahb);
 failed_clk_ahb:
index 645764a..bb9887f 100644 (file)
@@ -528,7 +528,7 @@ static void setup_sgmii_internal_phy(struct fman_mac *memac,
                case 100:
                        tmp_reg16 |= IF_MODE_SGMII_SPEED_100M;
                break;
-               case 1000: /* fallthrough */
+               case 1000:
                default:
                        tmp_reg16 |= IF_MODE_SGMII_SPEED_1G;
                break;
index c27df15..624b2eb 100644 (file)
@@ -1344,10 +1344,10 @@ int fman_port_config(struct fman_port *port, struct fman_port_params *params)
        switch (port->port_type) {
        case FMAN_PORT_TYPE_RX:
                set_rx_dflt_cfg(port, params);
-               /* fall through */
+               fallthrough;
        case FMAN_PORT_TYPE_TX:
                set_tx_dflt_cfg(port, params, &port->dts_params);
-               /* fall through */
+               fallthrough;
        default:
                set_dflt_cfg(port, params);
        }
index b513b8c..41dd3d0 100644 (file)
@@ -750,8 +750,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
                                continue;
 
                        err = gfar_parse_group(child, priv, model);
-                       if (err)
+                       if (err) {
+                               of_node_put(child);
                                goto err_grp_init;
+                       }
                }
        } else { /* SQ_SG_MODE */
                err = gfar_parse_group(np, priv, model);
index db791f6..714b501 100644 (file)
@@ -1348,7 +1348,7 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
                switch (ugeth->max_speed) {
                case SPEED_10:
                        upsmr |= UCC_GETH_UPSMR_R10M;
-                       /* FALLTHROUGH */
+                       fallthrough;
                case SPEED_100:
                        if (ugeth->phy_interface != PHY_INTERFACE_MODE_RTBI)
                                upsmr |= UCC_GETH_UPSMR_RMM;
index 23f278e..22522f8 100644 (file)
@@ -2282,8 +2282,10 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
                        priv->enet_ver = AE_VERSION_1;
                else if (acpi_dev_found(hns_enet_acpi_match[1].id))
                        priv->enet_ver = AE_VERSION_2;
-               else
-                       return -ENXIO;
+               else {
+                       ret = -ENXIO;
+                       goto out_read_prop_fail;
+               }
 
                /* try to find port-idx-in-ae first */
                ret = acpi_node_get_property_reference(dev->fwnode,
@@ -2299,7 +2301,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
                priv->fwnode = args.fwnode;
        } else {
                dev_err(dev, "cannot read cfg data from OF or acpi\n");
-               return -ENXIO;
+               ret = -ENXIO;
+               goto out_read_prop_fail;
        }
 
        ret = device_property_read_u32(dev, "port-idx-in-ae", &port_id);
index 49624ac..4eb5029 100644 (file)
@@ -305,7 +305,7 @@ static int __lb_setup(struct net_device *ndev,
                break;
        case MAC_LOOP_PHY_NONE:
                ret = hns_nic_config_phy_loopback(phy_dev, 0x0);
-               /* fall through */
+               fallthrough;
        case MAC_LOOP_NONE:
                if (!ret && h->dev->ops->set_loopback) {
                        if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)
index 87776ce..a4f1d51 100644 (file)
@@ -21,6 +21,7 @@
 #include <net/pkt_cls.h>
 #include <net/tcp.h>
 #include <net/vxlan.h>
+#include <net/geneve.h>
 
 #include "hnae3.h"
 #include "hns3_enet.h"
@@ -780,7 +781,7 @@ static int hns3_get_l4_protocol(struct sk_buff *skb, u8 *ol4_proto,
  * and it is udp packet, which has a dest port as the IANA assigned.
  * the hardware is expected to do the checksum offload, but the
  * hardware will not do the checksum offload when udp dest port is
- * 4789.
+ * 4789 or 6081.
  */
 static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
 {
@@ -789,7 +790,8 @@ static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
        l4.hdr = skb_transport_header(skb);
 
        if (!(!skb->encapsulation &&
-             l4.udp->dest == htons(IANA_VXLAN_UDP_PORT)))
+             (l4.udp->dest == htons(IANA_VXLAN_UDP_PORT) ||
+             l4.udp->dest == htons(GENEVE_UDP_PORT))))
                return false;
 
        skb_checksum_help(skb);
@@ -2746,7 +2748,7 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
        case HNS3_OL4_TYPE_MAC_IN_UDP:
        case HNS3_OL4_TYPE_NVGRE:
                skb->csum_level = 1;
-               /* fall through */
+               fallthrough;
        case HNS3_OL4_TYPE_NO_TUN:
                l3_type = hnae3_get_field(l234info, HNS3_RXD_L3ID_M,
                                          HNS3_RXD_L3ID_S);
index 36575e7..d553ed7 100644 (file)
@@ -3061,7 +3061,7 @@ static irqreturn_t hclge_misc_irq_handle(int irq, void *data)
                 *    by first decoding the types of errors.
                 */
                set_bit(HNAE3_UNKNOWN_RESET, &hdev->reset_request);
-               /* fall through */
+               fallthrough;
        case HCLGE_VECTOR0_EVENT_RST:
                hclge_reset_task_schedule(hdev);
                break;
@@ -3686,12 +3686,10 @@ static int hclge_reset_prepare_up(struct hclge_dev *hdev)
 
        switch (hdev->reset_type) {
        case HNAE3_FUNC_RESET:
-               /* fall through */
        case HNAE3_FLR_RESET:
                ret = hclge_set_all_vf_rst(hdev, false);
                break;
        case HNAE3_GLOBAL_RESET:
-               /* fall through */
        case HNAE3_IMP_RESET:
                ret = hclge_set_rst_done(hdev);
                break;
index 0273fb7..3153d62 100644 (file)
@@ -3247,7 +3247,7 @@ static int ehea_mem_notifier(struct notifier_block *nb,
        switch (action) {
        case MEM_CANCEL_OFFLINE:
                pr_info("memory offlining canceled");
-               /* Fall through - re-add canceled memory block */
+               fallthrough;    /* re-add canceled memory block */
 
        case MEM_ONLINE:
                pr_info("memory is going online");
index 06248a7..c00b909 100644 (file)
@@ -2319,7 +2319,7 @@ static int emac_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:
                data->phy_id = dev->phy.address;
-               /* Fall through */
+               fallthrough;
        case SIOCGMIIREG:
                data->val_out = emac_mdio_read(ndev, dev->phy.address,
                                               data->reg_num);
index 5afb3c9..d3a7743 100644 (file)
@@ -479,6 +479,9 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
        int i, j, rc;
        u64 *size_array;
 
+       if (!adapter->rx_pool)
+               return -1;
+
        size_array = (u64 *)((u8 *)(adapter->login_rsp_buf) +
                be32_to_cpu(adapter->login_rsp_buf->off_rxadd_buff_size));
 
@@ -649,6 +652,9 @@ static int reset_tx_pools(struct ibmvnic_adapter *adapter)
        int tx_scrqs;
        int i, rc;
 
+       if (!adapter->tx_pool)
+               return -1;
+
        tx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
        for (i = 0; i < tx_scrqs; i++) {
                rc = reset_one_tx_pool(adapter, &adapter->tso_pool[i]);
@@ -2011,7 +2017,10 @@ static int do_reset(struct ibmvnic_adapter *adapter,
                    adapter->req_rx_add_entries_per_subcrq !=
                    old_num_rx_slots ||
                    adapter->req_tx_entries_per_subcrq !=
-                   old_num_tx_slots) {
+                   old_num_tx_slots ||
+                   !adapter->rx_pool ||
+                   !adapter->tso_pool ||
+                   !adapter->tx_pool) {
                        release_rx_pools(adapter);
                        release_tx_pools(adapter);
                        release_napi(adapter);
@@ -2024,10 +2033,14 @@ static int do_reset(struct ibmvnic_adapter *adapter,
                } else {
                        rc = reset_tx_pools(adapter);
                        if (rc)
+                               netdev_dbg(adapter->netdev, "reset tx pools failed (%d)\n",
+                                               rc);
                                goto out;
 
                        rc = reset_rx_pools(adapter);
                        if (rc)
+                               netdev_dbg(adapter->netdev, "reset rx pools failed (%d)\n",
+                                               rc);
                                goto out;
                }
                ibmvnic_disable_irqs(adapter);
index 63dde3b..664e8cc 100644 (file)
@@ -4079,7 +4079,6 @@ void e1000e_reset(struct e1000_adapter *adapter)
        case e1000_pch_lpt:
        case e1000_pch_spt:
        case e1000_pch_cnp:
-               fallthrough;
        case e1000_pch_tgp:
        case e1000_pch_adp:
                fc->refresh_time = 0xFFFF;
index a62ddd6..c0c8efe 100644 (file)
@@ -981,7 +981,7 @@ struct i40e_aqc_set_vsi_promiscuous_modes {
 #define I40E_AQC_SET_VSI_PROMISC_BROADCAST     0x04
 #define I40E_AQC_SET_VSI_DEFAULT               0x08
 #define I40E_AQC_SET_VSI_PROMISC_VLAN          0x10
-#define I40E_AQC_SET_VSI_PROMISC_TX            0x8000
+#define I40E_AQC_SET_VSI_PROMISC_RX_ONLY       0x8000
        __le16  seid;
        __le16  vlan_tag;
 #define I40E_AQC_SET_VSI_VLAN_VALID            0x8000
index afad5e9..6ab52cb 100644 (file)
@@ -1966,6 +1966,21 @@ i40e_status i40e_aq_set_phy_debug(struct i40e_hw *hw, u8 cmd_flags,
        return status;
 }
 
+/**
+ * i40e_is_aq_api_ver_ge
+ * @aq: pointer to AdminQ info containing HW API version to compare
+ * @maj: API major value
+ * @min: API minor value
+ *
+ * Assert whether current HW API version is greater/equal than provided.
+ **/
+static bool i40e_is_aq_api_ver_ge(struct i40e_adminq_info *aq, u16 maj,
+                                 u16 min)
+{
+       return (aq->api_maj_ver > maj ||
+               (aq->api_maj_ver == maj && aq->api_min_ver >= min));
+}
+
 /**
  * i40e_aq_add_vsi
  * @hw: pointer to the hw struct
@@ -2091,18 +2106,16 @@ i40e_status i40e_aq_set_vsi_unicast_promiscuous(struct i40e_hw *hw,
 
        if (set) {
                flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
-               if (rx_only_promisc &&
-                   (((hw->aq.api_maj_ver == 1) && (hw->aq.api_min_ver >= 5)) ||
-                    (hw->aq.api_maj_ver > 1)))
-                       flags |= I40E_AQC_SET_VSI_PROMISC_TX;
+               if (rx_only_promisc && i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+                       flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
        }
 
        cmd->promiscuous_flags = cpu_to_le16(flags);
 
        cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
-       if (((hw->aq.api_maj_ver >= 1) && (hw->aq.api_min_ver >= 5)) ||
-           (hw->aq.api_maj_ver > 1))
-               cmd->valid_flags |= cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_TX);
+       if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+               cmd->valid_flags |=
+                       cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
 
        cmd->seid = cpu_to_le16(seid);
        status = i40e_asq_send_command(hw, &desc, NULL, 0, cmd_details);
@@ -2199,11 +2212,17 @@ enum i40e_status_code i40e_aq_set_vsi_uc_promisc_on_vlan(struct i40e_hw *hw,
        i40e_fill_default_direct_cmd_desc(&desc,
                                          i40e_aqc_opc_set_vsi_promiscuous_modes);
 
-       if (enable)
+       if (enable) {
                flags |= I40E_AQC_SET_VSI_PROMISC_UNICAST;
+               if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+                       flags |= I40E_AQC_SET_VSI_PROMISC_RX_ONLY;
+       }
 
        cmd->promiscuous_flags = cpu_to_le16(flags);
        cmd->valid_flags = cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_UNICAST);
+       if (i40e_is_aq_api_ver_ge(&hw->aq, 1, 5))
+               cmd->valid_flags |=
+                       cpu_to_le16(I40E_AQC_SET_VSI_PROMISC_RX_ONLY);
        cmd->seid = cpu_to_le16(seid);
        cmd->vlan_tag = cpu_to_le16(vid | I40E_AQC_SET_VSI_VLAN_VALID);
 
index b539935..2e433fd 100644 (file)
@@ -15463,6 +15463,9 @@ static void i40e_remove(struct pci_dev *pdev)
        i40e_write_rx_ctl(hw, I40E_PFQF_HENA(0), 0);
        i40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), 0);
 
+       while (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state))
+               usleep_range(1000, 2000);
+
        /* no more scheduling of any task */
        set_bit(__I40E_SUSPENDED, pf->state);
        set_bit(__I40E_DOWN, pf->state);
index 4f05f6e..d9c3a6b 100644 (file)
@@ -718,7 +718,6 @@ static void igb_cache_ring_register(struct igb_adapter *adapter)
        case e1000_i354:
        case e1000_i210:
        case e1000_i211:
-               fallthrough;
        default:
                for (; i < adapter->num_rx_queues; i++)
                        adapter->rx_ring[i]->reg_idx = rbase_offset + i;
index 7a6f2a0..9593aa4 100644 (file)
@@ -5142,6 +5142,8 @@ static int igc_probe(struct pci_dev *pdev,
        device_set_wakeup_enable(&adapter->pdev->dev,
                                 adapter->flags & IGC_FLAG_WOL_SUPPORTED);
 
+       igc_ptp_init(adapter);
+
        /* reset the hardware with the new settings */
        igc_reset(adapter);
 
@@ -5158,9 +5160,6 @@ static int igc_probe(struct pci_dev *pdev,
         /* carrier off reporting is important to ethtool even BEFORE open */
        netif_carrier_off(netdev);
 
-       /* do hw tstamp init after resetting */
-       igc_ptp_init(adapter);
-
        /* Check if Media Autosense is enabled */
        adapter->ei = *ei;
 
index e67d465..36c9992 100644 (file)
@@ -496,8 +496,6 @@ void igc_ptp_init(struct igc_adapter *adapter)
        adapter->tstamp_config.rx_filter = HWTSTAMP_FILTER_NONE;
        adapter->tstamp_config.tx_type = HWTSTAMP_TX_OFF;
 
-       igc_ptp_reset(adapter);
-
        adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,
                                                &adapter->pdev->dev);
        if (IS_ERR(adapter->ptp_clock)) {
index e67b1a5..0fcd820 100644 (file)
@@ -193,7 +193,7 @@ static int ixgbe_fcoe_ddp_setup(struct net_device *netdev, u16 xid,
        }
 
        /* alloc the udl from per cpu ddp pool */
-       ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_KERNEL, &ddp->udp);
+       ddp->udl = dma_pool_alloc(ddp_pool->pool, GFP_ATOMIC, &ddp->udp);
        if (!ddp->udl) {
                e_err(drv, "failed allocated ddp context\n");
                goto out_noddp_unmap;
index 832bbb8..dfcb176 100644 (file)
@@ -2205,10 +2205,10 @@ mvneta_run_xdp(struct mvneta_port *pp, struct mvneta_rx_queue *rxq,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(pp->dev, prog, act);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
                mvneta_xdp_put_buff(pp, rxq, xdp, sync, true);
                ret = MVNETA_XDP_DROPPED;
index d4a4e24..41d935d 100644 (file)
@@ -1638,7 +1638,7 @@ int mvpp2_ethtool_rxfh_set(struct mvpp2_port *port, struct ethtool_rxnfc *info)
                        hash_opts |= MVPP22_CLS_HEK_OPT_L4SIP;
                if (info->data & RXH_L4_B_2_3)
                        hash_opts |= MVPP22_CLS_HEK_OPT_L4DIP;
-               /* Fallthrough */
+               fallthrough;
        case MVPP22_FLOW_IP4:
        case MVPP22_FLOW_IP6:
                if (info->data & RXH_L2DA)
index 2a8a584..6e140d1 100644 (file)
@@ -5437,7 +5437,7 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
                }
                if (state->interface != PHY_INTERFACE_MODE_NA)
                        break;
-               /* Fall-through */
+               fallthrough;
        case PHY_INTERFACE_MODE_RGMII:
        case PHY_INTERFACE_MODE_RGMII_ID:
        case PHY_INTERFACE_MODE_RGMII_RXID:
@@ -5451,7 +5451,7 @@ static void mvpp2_phylink_validate(struct phylink_config *config,
                phylink_set(mask, 1000baseX_Full);
                if (state->interface != PHY_INTERFACE_MODE_NA)
                        break;
-               /* Fall-through */
+               fallthrough;
        case PHY_INTERFACE_MODE_1000BASEX:
        case PHY_INTERFACE_MODE_2500BASEX:
                if (port->comphy ||
index 36953d4..01a7931 100644 (file)
@@ -737,7 +737,7 @@ static int rvu_nix_aq_enq_inst(struct rvu *rvu, struct nix_aq_enq_req *req,
                else if (req->ctype == NIX_AQ_CTYPE_MCE)
                        memcpy(mask, &req->mce_mask,
                               sizeof(struct nix_rx_mce_s));
-               /* Fall through */
+               fallthrough;
        case NIX_AQ_INSTOP_INIT:
                if (req->ctype == NIX_AQ_CTYPE_RQ)
                        memcpy(ctx, &req->rq, sizeof(struct nix_rq_ctx_s));
index 5975521..93c4cf7 100644 (file)
@@ -1226,8 +1226,8 @@ int otx2_config_npa(struct otx2_nic *pfvf)
        if (!hw->pool_cnt)
                return -EINVAL;
 
-       qset->pool = devm_kzalloc(pfvf->dev, sizeof(struct otx2_pool) *
-                                 hw->pool_cnt, GFP_KERNEL);
+       qset->pool = devm_kcalloc(pfvf->dev, hw->pool_cnt,
+                                 sizeof(struct otx2_pool), GFP_KERNEL);
        if (!qset->pool)
                return -ENOMEM;
 
index b792f63..6a93035 100644 (file)
@@ -2448,7 +2448,7 @@ static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                data->phy_id = hw->phy_addr;
 
-               /* fallthru */
+               fallthrough;
        case SIOCGMIIREG: {
                u16 val = 0;
                spin_lock_bh(&hw->phy_lock);
index cec8124..3448642 100644 (file)
@@ -1376,7 +1376,7 @@ static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCGMIIPHY:
                data->phy_id = PHY_ADDR_MARV;
 
-               /* fallthru */
+               fallthrough;
        case SIOCGMIIREG: {
                u16 val = 0;
 
@@ -2764,7 +2764,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
 
                case OP_RXCHKSVLAN:
                        sky2_rx_tag(sky2, length);
-                       /* fall through */
+                       fallthrough;
                case OP_RXCHKS:
                        if (likely(dev->features & NETIF_F_RXCSUM))
                                sky2_rx_checksum(sky2, status);
index 0870fe7..6d2d606 100644 (file)
@@ -228,7 +228,7 @@ static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
                        if (!MTK_HAS_CAPS(mac->hw->soc->caps,
                                          MTK_GMAC1_TRGMII))
                                goto err_phy;
-                       /* fall through */
+                       fallthrough;
                case PHY_INTERFACE_MODE_RGMII_TXID:
                case PHY_INTERFACE_MODE_RGMII_RXID:
                case PHY_INTERFACE_MODE_RGMII_ID:
@@ -501,11 +501,11 @@ static void mtk_validate(struct phylink_config *config,
        case PHY_INTERFACE_MODE_RGMII_RXID:
        case PHY_INTERFACE_MODE_RGMII_TXID:
                phylink_set(mask, 1000baseT_Half);
-               /* fall through */
+               fallthrough;
        case PHY_INTERFACE_MODE_SGMII:
                phylink_set(mask, 1000baseT_Full);
                phylink_set(mask, 1000baseX_Full);
-               /* fall through */
+               fallthrough;
        case PHY_INTERFACE_MODE_MII:
        case PHY_INTERFACE_MODE_RMII:
        case PHY_INTERFACE_MODE_REVMII:
index d2986f1..d744478 100644 (file)
@@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order)
                goto err_out;
 
        for (i = 0; i <= buddy->max_order; ++i) {
-               s = BITS_TO_LONGS(1 << (buddy->max_order - i));
+               s = BITS_TO_LONGS(1UL << (buddy->max_order - i));
                buddy->bits[i] = kvmalloc_array(s, sizeof(long), GFP_KERNEL | __GFP_ZERO);
                if (!buddy->bits[i])
                        goto err_out_free;
index 7a04c62..bcd1669 100644 (file)
@@ -72,7 +72,7 @@ static int mlxfw_fsm_state_err(struct mlxfw_dev *mlxfw_dev,
        case MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET:
                MLXFW_ERR_MSG(mlxfw_dev, extack, "pending reset", err);
                break;
-       case MLXFW_FSM_STATE_ERR_OK: /* fall through */
+       case MLXFW_FSM_STATE_ERR_OK:
        case MLXFW_FSM_STATE_ERR_MAX:
                MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown error", err);
                break;
@@ -155,7 +155,7 @@ mlxfw_fsm_reactivate_err(struct mlxfw_dev *mlxfw_dev,
        case MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED:
                MLXFW_REACT_ERR("fw already activated", err);
                break;
-       case MLXFW_FSM_REACTIVATE_STATUS_OK: /* fall through */
+       case MLXFW_FSM_REACTIVATE_STATUS_OK:
        case MLXFW_FSM_REACTIVATE_STATUS_MAX:
                MLXFW_REACT_ERR("unexpected error", err);
                break;
index 08d1011..ec45a03 100644 (file)
@@ -2289,21 +2289,21 @@ int mlxsw_core_module_max_width(struct mlxsw_core *mlxsw_core, u8 module)
        /* Here we need to get the module width according to the module type. */
 
        switch (module_type) {
-       case MLXSW_REG_PMTM_MODULE_TYPE_C2C8X: /* fall through */
-       case MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD: /* fall through */
+       case MLXSW_REG_PMTM_MODULE_TYPE_C2C8X:
+       case MLXSW_REG_PMTM_MODULE_TYPE_QSFP_DD:
        case MLXSW_REG_PMTM_MODULE_TYPE_OSFP:
                return 8;
-       case MLXSW_REG_PMTM_MODULE_TYPE_C2C4X: /* fall through */
-       case MLXSW_REG_PMTM_MODULE_TYPE_BP_4X: /* fall through */
+       case MLXSW_REG_PMTM_MODULE_TYPE_C2C4X:
+       case MLXSW_REG_PMTM_MODULE_TYPE_BP_4X:
        case MLXSW_REG_PMTM_MODULE_TYPE_QSFP:
                return 4;
-       case MLXSW_REG_PMTM_MODULE_TYPE_C2C2X: /* fall through */
-       case MLXSW_REG_PMTM_MODULE_TYPE_BP_2X: /* fall through */
-       case MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD: /* fall through */
+       case MLXSW_REG_PMTM_MODULE_TYPE_C2C2X:
+       case MLXSW_REG_PMTM_MODULE_TYPE_BP_2X:
+       case MLXSW_REG_PMTM_MODULE_TYPE_SFP_DD:
        case MLXSW_REG_PMTM_MODULE_TYPE_DSFP:
                return 2;
-       case MLXSW_REG_PMTM_MODULE_TYPE_C2C1X: /* fall through */
-       case MLXSW_REG_PMTM_MODULE_TYPE_BP_1X: /* fall through */
+       case MLXSW_REG_PMTM_MODULE_TYPE_C2C1X:
+       case MLXSW_REG_PMTM_MODULE_TYPE_BP_1X:
        case MLXSW_REG_PMTM_MODULE_TYPE_SFP:
                return 1;
        default:
index 44fa02c..056eeb8 100644 (file)
@@ -30,8 +30,8 @@ static int mlxsw_env_validate_cable_ident(struct mlxsw_core *core, int id,
        case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_SFP:
                *qsfp = false;
                break;
-       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP: /* fall-through */
-       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
+       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP:
+       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS:
        case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
                *qsfp = true;
                break;
@@ -205,7 +205,7 @@ int mlxsw_env_get_module_info(struct mlxsw_core *mlxsw_core, int module,
                modinfo->type       = ETH_MODULE_SFF_8436;
                modinfo->eeprom_len = ETH_MODULE_SFF_8436_MAX_LEN;
                break;
-       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS: /* fall-through */
+       case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP_PLUS:
        case MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28:
                if (module_id == MLXSW_REG_MCIA_EEPROM_MODULE_INFO_ID_QSFP28 ||
                    module_rev_id >=
index 3fe878d..61719ec 100644 (file)
@@ -259,8 +259,8 @@ static ssize_t mlxsw_hwmon_module_temp_fault_show(struct device *dev,
                 */
                fault = 1;
                break;
-       case MLXSW_REG_MTBR_NO_CONN: /* fall-through */
-       case MLXSW_REG_MTBR_NO_TEMP_SENS: /* fall-through */
+       case MLXSW_REG_MTBR_NO_CONN:
+       case MLXSW_REG_MTBR_NO_TEMP_SENS:
        case MLXSW_REG_MTBR_INDEX_NA:
        default:
                fault = 0;
index fdf9aa8..4186e29 100644 (file)
@@ -517,8 +517,8 @@ enum mlxsw_reg_spms_state mlxsw_sp_stp_spms_state(u8 state)
                return MLXSW_REG_SPMS_STATE_FORWARDING;
        case BR_STATE_LEARNING:
                return MLXSW_REG_SPMS_STATE_LEARNING;
-       case BR_STATE_LISTENING: /* fall-through */
-       case BR_STATE_DISABLED: /* fall-through */
+       case BR_STATE_LISTENING:
+       case BR_STATE_DISABLED:
        case BR_STATE_BLOCKING:
                return MLXSW_REG_SPMS_STATE_DISCARDING;
        default:
index f9ba596..5240bf1 100644 (file)
@@ -636,11 +636,11 @@ static inline unsigned int
 mlxsw_sp_kvdl_entry_size(enum mlxsw_sp_kvdl_entry_type type)
 {
        switch (type) {
-       case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ: /* fall through */
-       case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET: /* fall through */
-       case MLXSW_SP_KVDL_ENTRY_TYPE_PBS: /* fall through */
-       case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR: /* fall through */
-       case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT: /* fall through */
+       case MLXSW_SP_KVDL_ENTRY_TYPE_ADJ:
+       case MLXSW_SP_KVDL_ENTRY_TYPE_ACTSET:
+       case MLXSW_SP_KVDL_ENTRY_TYPE_PBS:
+       case MLXSW_SP_KVDL_ENTRY_TYPE_MCRIGR:
+       case MLXSW_SP_KVDL_ENTRY_TYPE_TNUMT:
        default:
                return 1;
        }
index 0521e9d..24f1fd1 100644 (file)
@@ -1164,7 +1164,7 @@ mlxsw_sp_router_ip2me_fib_entry_find(struct mlxsw_sp *mlxsw_sp, u32 tb_id,
                addr_len = 4;
                addr_prefix_len = 32;
                break;
-       case MLXSW_SP_L3_PROTO_IPV6: /* fall through */
+       case MLXSW_SP_L3_PROTO_IPV6:
        default:
                WARN_ON(1);
                return NULL;
@@ -4555,14 +4555,14 @@ mlxsw_sp_fib4_entry_type_set(struct mlxsw_sp *mlxsw_sp,
                        fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_NVE_DECAP;
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        case RTN_BROADCAST:
                fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_TRAP;
                return 0;
        case RTN_BLACKHOLE:
                fib_entry->type = MLXSW_SP_FIB_ENTRY_TYPE_BLACKHOLE;
                return 0;
-       case RTN_UNREACHABLE: /* fall through */
+       case RTN_UNREACHABLE:
        case RTN_PROHIBIT:
                /* Packets hitting these routes need to be trapped, but
                 * can do so with a lower priority than packets directed
@@ -5990,7 +5990,7 @@ static void mlxsw_sp_router_fib4_event_work(struct work_struct *work)
                mlxsw_sp_router_fib4_del(mlxsw_sp, &fib_work->fen_info);
                fib_info_put(fib_work->fen_info.fi);
                break;
-       case FIB_EVENT_NH_ADD: /* fall through */
+       case FIB_EVENT_NH_ADD:
        case FIB_EVENT_NH_DEL:
                mlxsw_sp_nexthop4_event(mlxsw_sp, fib_work->event,
                                        fib_work->fnh_info.fib_nh);
@@ -6050,7 +6050,7 @@ static void mlxsw_sp_router_fibmr_event_work(struct work_struct *work)
        rtnl_lock();
        mutex_lock(&mlxsw_sp->router->lock);
        switch (fib_work->event) {
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
        case FIB_EVENT_ENTRY_ADD:
                replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE;
 
@@ -6089,7 +6089,7 @@ static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
        struct fib_nh_notifier_info *fnh_info;
 
        switch (fib_work->event) {
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
        case FIB_EVENT_ENTRY_DEL:
                fen_info = container_of(info, struct fib_entry_notifier_info,
                                        info);
@@ -6099,7 +6099,7 @@ static void mlxsw_sp_router_fib4_event(struct mlxsw_sp_fib_event_work *fib_work,
                 */
                fib_info_hold(fib_work->fen_info.fi);
                break;
-       case FIB_EVENT_NH_ADD: /* fall through */
+       case FIB_EVENT_NH_ADD:
        case FIB_EVENT_NH_DEL:
                fnh_info = container_of(info, struct fib_nh_notifier_info,
                                        info);
@@ -6116,8 +6116,8 @@ static int mlxsw_sp_router_fib6_event(struct mlxsw_sp_fib_event_work *fib_work,
        int err;
 
        switch (fib_work->event) {
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
-       case FIB_EVENT_ENTRY_APPEND: /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
+       case FIB_EVENT_ENTRY_APPEND:
        case FIB_EVENT_ENTRY_DEL:
                fen6_info = container_of(info, struct fib6_entry_notifier_info,
                                         info);
@@ -6136,13 +6136,13 @@ mlxsw_sp_router_fibmr_event(struct mlxsw_sp_fib_event_work *fib_work,
                            struct fib_notifier_info *info)
 {
        switch (fib_work->event) {
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
-       case FIB_EVENT_ENTRY_ADD: /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
+       case FIB_EVENT_ENTRY_ADD:
        case FIB_EVENT_ENTRY_DEL:
                memcpy(&fib_work->men_info, info, sizeof(fib_work->men_info));
                mr_cache_hold(fib_work->men_info.mfc);
                break;
-       case FIB_EVENT_VIF_ADD: /* fall through */
+       case FIB_EVENT_VIF_ADD:
        case FIB_EVENT_VIF_DEL:
                memcpy(&fib_work->ven_info, info, sizeof(fib_work->ven_info));
                dev_hold(fib_work->ven_info.dev);
@@ -6215,13 +6215,13 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
        router = container_of(nb, struct mlxsw_sp_router, fib_nb);
 
        switch (event) {
-       case FIB_EVENT_RULE_ADD: /* fall through */
+       case FIB_EVENT_RULE_ADD:
        case FIB_EVENT_RULE_DEL:
                err = mlxsw_sp_router_fib_rule_event(event, info,
                                                     router->mlxsw_sp);
                return notifier_from_errno(err);
-       case FIB_EVENT_ENTRY_ADD: /* fall through */
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
+       case FIB_EVENT_ENTRY_ADD:
+       case FIB_EVENT_ENTRY_REPLACE:
        case FIB_EVENT_ENTRY_APPEND:
                if (router->aborted) {
                        NL_SET_ERR_MSG_MOD(info->extack, "FIB offload was aborted. Not configuring route");
@@ -7277,7 +7277,7 @@ int mlxsw_sp_netdevice_router_port_event(struct net_device *dev,
                goto out;
 
        switch (event) {
-       case NETDEV_CHANGEMTU: /* fall through */
+       case NETDEV_CHANGEMTU:
        case NETDEV_CHANGEADDR:
                err = mlxsw_sp_router_port_change_event(mlxsw_sp, rif);
                break;
index 5c959a9..1d18e41 100644 (file)
@@ -1523,12 +1523,12 @@ mlxsw_sp_span_trigger_ops_set(struct mlxsw_sp_span_trigger_entry *trigger_entry)
        enum mlxsw_sp_span_trigger_type type;
 
        switch (trigger_entry->trigger) {
-       case MLXSW_SP_SPAN_TRIGGER_INGRESS: /* fall-through */
+       case MLXSW_SP_SPAN_TRIGGER_INGRESS:
        case MLXSW_SP_SPAN_TRIGGER_EGRESS:
                type = MLXSW_SP_SPAN_TRIGGER_TYPE_PORT;
                break;
-       case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP: /* fall-through */
-       case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP: /* fall-through */
+       case MLXSW_SP_SPAN_TRIGGER_TAIL_DROP:
+       case MLXSW_SP_SPAN_TRIGGER_EARLY_DROP:
        case MLXSW_SP_SPAN_TRIGGER_ECN:
                type = MLXSW_SP_SPAN_TRIGGER_TYPE_GLOBAL;
                break;
index a26162b..72912af 100644 (file)
@@ -1297,7 +1297,7 @@ static int mlxsw_sp_port_fdb_tunnel_uc_op(struct mlxsw_sp *mlxsw_sp,
                uip = be32_to_cpu(addr->addr4);
                sfd_proto = MLXSW_REG_SFD_UC_TUNNEL_PROTOCOL_IPV4;
                break;
-       case MLXSW_SP_L3_PROTO_IPV6: /* fall through */
+       case MLXSW_SP_L3_PROTO_IPV6:
        default:
                WARN_ON(1);
                return -EOPNOTSUPP;
@@ -2870,7 +2870,7 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
                fdb_info = &switchdev_work->fdb_info;
                mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false);
                break;
-       case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */
+       case SWITCHDEV_FDB_ADD_TO_BRIDGE:
        case SWITCHDEV_FDB_DEL_TO_BRIDGE:
                /* These events are only used to potentially update an existing
                 * SPAN mirror.
@@ -3116,9 +3116,9 @@ static int mlxsw_sp_switchdev_event(struct notifier_block *unused,
        switchdev_work->event = event;
 
        switch (event) {
-       case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
-       case SWITCHDEV_FDB_DEL_TO_DEVICE: /* fall through */
-       case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */
+       case SWITCHDEV_FDB_ADD_TO_DEVICE:
+       case SWITCHDEV_FDB_DEL_TO_DEVICE:
+       case SWITCHDEV_FDB_ADD_TO_BRIDGE:
        case SWITCHDEV_FDB_DEL_TO_BRIDGE:
                fdb_info = container_of(info,
                                        struct switchdev_notifier_fdb_info,
@@ -3138,7 +3138,7 @@ static int mlxsw_sp_switchdev_event(struct notifier_block *unused,
                 */
                dev_hold(dev);
                break;
-       case SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE: /* fall through */
+       case SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE:
        case SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE:
                INIT_WORK(&switchdev_work->work,
                          mlxsw_sp_switchdev_vxlan_fdb_event_work);
index c533d06..dcde496 100644 (file)
@@ -548,7 +548,7 @@ static int lan743x_ethtool_get_rxnfc(struct net_device *netdev,
                case TCP_V4_FLOW:case UDP_V4_FLOW:
                case TCP_V6_FLOW:case UDP_V6_FLOW:
                        rxnfc->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-                       /* fall through */
+                       fallthrough;
                case IPV4_FLOW: case IPV6_FLOW:
                        rxnfc->data |= RXH_IP_SRC | RXH_IP_DST;
                        return 0;
index 867c680..5abb7d2 100644 (file)
@@ -859,7 +859,7 @@ void ocelot_bridge_stp_state_set(struct ocelot *ocelot, int port, u8 state)
        switch (state) {
        case BR_STATE_FORWARDING:
                ocelot->bridge_fwd_mask |= BIT(port);
-               /* Fallthrough */
+               fallthrough;
        case BR_STATE_LEARNING:
                port_cfg |= ANA_PORT_PORT_CFG_LEARN_ENA;
                break;
index c2867fe..3de8430 100644 (file)
@@ -3081,7 +3081,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = np->phy_addr_external;
-               /* Fall Through */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                /* The phy_id is not enough to uniquely identify
index 4f1f90f..78eba10 100644 (file)
@@ -3768,20 +3768,20 @@ vxge_hw_rts_rth_data0_data1_get(u32 j, u64 *data0, u64 *data1,
                        VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM0_ENTRY_EN |
                        VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM0_BUCKET_DATA(
                        itable[j]);
-               /* fall through */
+               fallthrough;
        case 2:
                *data0 |=
                        VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_BUCKET_NUM(j)|
                        VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_ENTRY_EN |
                        VXGE_HW_RTS_ACCESS_STEER_DATA0_RTH_ITEM1_BUCKET_DATA(
                        itable[j]);
-               /* fall through */
+               fallthrough;
        case 3:
                *data1 = VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_BUCKET_NUM(j)|
                        VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_ENTRY_EN |
                        VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM0_BUCKET_DATA(
                        itable[j]);
-               /* fall through */
+               fallthrough;
        case 4:
                *data1 |=
                        VXGE_HW_RTS_ACCESS_STEER_DATA1_RTH_ITEM1_BUCKET_NUM(j)|
index 7c50e3d..76c51da 100644 (file)
@@ -296,7 +296,7 @@ nfp_net_tls_add(struct net_device *netdev, struct sock *sk,
                        break;
                }
 #endif
-               /* fall through */
+               fallthrough;
        case AF_INET:
                req_sz = sizeof(struct nfp_crypto_req_add_v4);
                ipv6 = false;
index ff844e5..1cbe2c9 100644 (file)
@@ -297,7 +297,7 @@ nfp_fl_get_tun_from_act(struct nfp_app *app,
        case htons(GENEVE_UDP_PORT):
                if (priv->flower_ext_feats & NFP_FL_FEATS_GENEVE)
                        return NFP_FL_TUNNEL_GENEVE;
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                return NFP_FL_TUNNEL_NONE;
        }
index a050cb8..f21cf1f 100644 (file)
@@ -289,7 +289,7 @@ nfp_flower_cmsg_process_one_rx(struct nfp_app *app, struct sk_buff *skb)
                        skb_stored = nfp_flower_lag_unprocessed_msg(app, skb);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
 err_default:
                nfp_flower_cmsg_warn(app, "Cannot handle invalid repr control type %u\n",
index 4651fe4..36356f9 100644 (file)
@@ -784,7 +784,7 @@ nfp_flower_copy_pre_actions(char *act_dst, char *act_src, int len,
                case NFP_FL_ACTION_OPCODE_PRE_TUNNEL:
                        if (tunnel_act)
                                *tunnel_act = true;
-                       /* fall through */
+                       fallthrough;
                case NFP_FL_ACTION_OPCODE_PRE_LAG:
                        memcpy(act_dst + act_off, act_src + act_off, act_len);
                        break;
index 2df3dee..7248d24 100644 (file)
@@ -61,6 +61,7 @@ struct nfp_tun_active_tuns {
  * @flags:             options part of the request
  * @tun_info.ipv6:             dest IPv6 address of active route
  * @tun_info.egress_port:      port the encapsulated packet egressed
+ * @tun_info.extra:            reserved for future use
  * @tun_info:          tunnels that have sent traffic in reported period
  */
 struct nfp_tun_active_tuns_v6 {
@@ -70,6 +71,7 @@ struct nfp_tun_active_tuns_v6 {
        struct route_ip_info_v6 {
                struct in6_addr ipv6;
                __be32 egress_port;
+               __be32 extra[2];
        } tun_info[];
 };
 
index b04b836..2643ea5 100644 (file)
@@ -137,7 +137,7 @@ static u16 nfp_swreg_to_unreg(swreg reg, bool is_dst)
                                val;
                case NN_LM_MOD_DEC:
                        lm_dec = true;
-                       /* fall through */
+                       fallthrough;
                case NN_LM_MOD_INC:
                        if (val) {
                                pr_err("LM offset in inc/dev mode\n");
index 39ee23e..21ea226 100644 (file)
@@ -1940,10 +1940,10 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
                                continue;
                        default:
                                bpf_warn_invalid_xdp_action(act);
-                               /* fall through */
+                               fallthrough;
                        case XDP_ABORTED:
                                trace_xdp_exception(dp->netdev, xdp_prog, act);
-                               /* fall through */
+                               fallthrough;
                        case XDP_DROP:
                                nfp_net_rx_give_one(dp, rx_ring, rxbuf->frag,
                                                    rxbuf->dma_addr);
index a486008..252fe06 100644 (file)
@@ -340,12 +340,12 @@ static int matching_bar(struct nfp_bar *bar, u32 tgt, u32 act, u32 tok,
        switch (maptype) {
        case NFP_PCIE_BAR_PCIE2CPP_MapType_TARGET:
                bartok = -1;
-               /* FALLTHROUGH */
+               fallthrough;
        case NFP_PCIE_BAR_PCIE2CPP_MapType_BULK:
                baract = NFP_CPP_ACTION_RW;
                if (act == 0)
                        act = NFP_CPP_ACTION_RW;
-               /* FALLTHROUGH */
+               fallthrough;
        case NFP_PCIE_BAR_PCIE2CPP_MapType_FIXED:
                break;
        default:
index 75f0124..2260c24 100644 (file)
@@ -213,7 +213,7 @@ u64 nfp_rtsym_size(const struct nfp_rtsym *sym)
                return 0;
        default:
                pr_warn("rtsym '%s': unknown type: %d\n", sym->name, sym->type);
-               /* fall through */
+               fallthrough;
        case NFP_RTSYM_TYPE_OBJECT:
        case NFP_RTSYM_TYPE_FUNCTION:
                return sym->size;
index a26966f..dceec80 100644 (file)
@@ -410,7 +410,7 @@ static void pch_gbe_check_copper_options(struct pch_gbe_adapter *adapter)
        case SPEED_1000 + HALF_DUPLEX:
                netdev_dbg(adapter->netdev,
                           "Half Duplex is not supported at 1000 Mbps\n");
-               /* fall through */
+               fallthrough;
        case SPEED_1000 + FULL_DUPLEX:
 full_duplex_only:
                netdev_dbg(adapter->netdev,
index 647a143..3da0753 100644 (file)
@@ -1356,7 +1356,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = np->phys[0] & 0x1f;
-               /* Fall Through */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                data->val_out = mdio_read(ioaddr, data->phy_id & 0x1f, data->reg_num & 0x1f);
index 8107d32..def65fe 100644 (file)
@@ -496,9 +496,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
        struct ionic_cq *txcq;
        u32 rx_work_done = 0;
        u32 tx_work_done = 0;
-       u32 work_done = 0;
        u32 flags = 0;
-       bool unmask;
 
        lif = rxcq->bound_q->lif;
        idev = &lif->ionic->idev;
@@ -512,17 +510,12 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
        if (rx_work_done)
                ionic_rx_fill_cb(rxcq->bound_q);
 
-       unmask = (rx_work_done < budget) && (tx_work_done < lif->tx_budget);
-
-       if (unmask && napi_complete_done(napi, rx_work_done)) {
+       if (rx_work_done < budget && napi_complete_done(napi, rx_work_done)) {
                flags |= IONIC_INTR_CRED_UNMASK;
                DEBUG_STATS_INTR_REARM(rxcq->bound_intr);
-               work_done = rx_work_done;
-       } else {
-               work_done = budget;
        }
 
-       if (work_done || flags) {
+       if (rx_work_done || flags) {
                flags |= IONIC_INTR_CRED_RESET_COALESCE;
                ionic_intr_credits(idev->intr_ctrl, rxcq->bound_intr->index,
                                   tx_work_done + rx_work_done, flags);
@@ -531,7 +524,7 @@ int ionic_txrx_napi(struct napi_struct *napi, int budget)
        DEBUG_STATS_NAPI_POLL(qcq, rx_work_done);
        DEBUG_STATS_NAPI_POLL(qcq, tx_work_done);
 
-       return work_done;
+       return rx_work_done;
 }
 
 static dma_addr_t ionic_tx_map_single(struct ionic_queue *q,
index 66f45fc..c3f50dd 100644 (file)
@@ -153,7 +153,7 @@ skip:
        case NETXEN_BRDTYPE_P3_4_GB_MM:
                supported |= SUPPORTED_Autoneg;
                advertising |= ADVERTISED_Autoneg;
-               /* fall through */
+               fallthrough;
        case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
        case NETXEN_BRDTYPE_P3_10G_CX4:
        case NETXEN_BRDTYPE_P3_10G_CX4_LP:
@@ -182,7 +182,7 @@ skip:
                supported |= SUPPORTED_TP;
                check_sfp_module = netif_running(dev) &&
                        adapter->has_link_events;
-               /* fall through */
+               fallthrough;
        case NETXEN_BRDTYPE_P2_SB31_10G:
        case NETXEN_BRDTYPE_P3_10G_XFP:
                supported |= SUPPORTED_FIBRE;
index 876743a..0e4cd88 100644 (file)
@@ -2046,7 +2046,7 @@ int qed_cxt_set_pf_params(struct qed_hwfn *p_hwfn, u32 rdma_tasks)
                                               rdma_tasks);
                /* no need for break since RoCE coexist with Ethernet */
        }
-       /* fall through */
+               fallthrough;
        case QED_PCI_ETH:
        {
                struct qed_eth_pf_params *p_params =
index b3c9eba..b8f076e 100644 (file)
@@ -3109,14 +3109,14 @@ int qed_hw_init(struct qed_dev *cdev, struct qed_hw_init_params *p_params)
                                                p_hwfn->hw_info.hw_mode);
                        if (rc)
                                break;
-               /* Fall through */
+                       fallthrough;
                case FW_MSG_CODE_DRV_LOAD_PORT:
                        rc = qed_hw_init_port(p_hwfn, p_hwfn->p_main_ptt,
                                              p_hwfn->hw_info.hw_mode);
                        if (rc)
                                break;
 
-               /* Fall through */
+                       fallthrough;
                case FW_MSG_CODE_DRV_LOAD_FUNCTION:
                        rc = qed_hw_init_pf(p_hwfn, p_hwfn->p_main_ptt,
                                            p_params->p_tunn,
index 2558cb6..f39f629 100644 (file)
@@ -761,7 +761,7 @@ static int qed_set_int_mode(struct qed_dev *cdev, bool force_mode)
                kfree(int_params->msix_table);
                if (force_mode)
                        goto out;
-               /* Fallthrough */
+               fallthrough;
 
        case QED_INT_MODE_MSI:
                if (cdev->num_hwfns == 1) {
@@ -775,7 +775,7 @@ static int qed_set_int_mode(struct qed_dev *cdev, bool force_mode)
                        if (force_mode)
                                goto out;
                }
-               /* Fallthrough */
+               fallthrough;
 
        case QED_INT_MODE_INTA:
                        int_params->out.int_mode = QED_INT_MODE_INTA;
index 5be08f8..cd882c4 100644 (file)
@@ -1085,7 +1085,7 @@ int qed_mcp_unload_req(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
                DP_NOTICE(p_hwfn,
                          "Unknown WoL configuration %02x\n",
                          p_hwfn->cdev->wol_config);
-               /* Fallthrough */
+               fallthrough;
        case QED_OV_WOL_DEFAULT:
                wol_param = DRV_MB_PARAM_UNLOAD_WOL_MCP;
        }
@@ -1365,7 +1365,7 @@ static void qed_mcp_handle_link_change(struct qed_hwfn *p_hwfn,
                break;
        case LINK_STATUS_SPEED_AND_DUPLEX_1000THD:
                p_link->full_duplex = false;
-       /* Fall-through */
+               fallthrough;
        case LINK_STATUS_SPEED_AND_DUPLEX_1000TFD:
                p_link->speed = 1000;
                break;
@@ -2451,7 +2451,7 @@ qed_mcp_get_shmem_proto(struct qed_hwfn *p_hwfn,
                break;
        case FUNC_MF_CFG_PROTOCOL_ROCE:
                DP_NOTICE(p_hwfn, "RoCE personality is not a valid value!\n");
-       /* Fallthrough */
+               fallthrough;
        default:
                rc = -EINVAL;
        }
@@ -3546,7 +3546,7 @@ qed_mcp_resc_allocation_msg(struct qed_hwfn *p_hwfn,
        switch (p_in_params->cmd) {
        case DRV_MSG_SET_RESOURCE_VALUE_MSG:
                mfw_resc_info.size = p_in_params->resc_max_val;
-               /* Fallthrough */
+               fallthrough;
        case DRV_MSG_GET_RESOURCE_ALLOC_MSG:
                break;
        default:
@@ -3823,7 +3823,7 @@ qed_mcp_resc_unlock(struct qed_hwfn *p_hwfn,
                DP_INFO(p_hwfn,
                        "Resource unlock request for an already released resource [%d]\n",
                        p_params->resource);
-               /* Fallthrough */
+               fallthrough;
        case RESOURCE_OPCODE_RELEASED:
                p_params->b_released = true;
                break;
index 0d0e38d..569e2a7 100644 (file)
@@ -1542,7 +1542,7 @@ static void ql_link_state_machine_work(struct work_struct *work)
                if (test_bit(QL_LINK_MASTER, &qdev->flags))
                        ql_port_start(qdev);
                qdev->port_link_state = LS_DOWN;
-               /* Fall Through */
+               fallthrough;
 
        case LS_DOWN:
                if (curr_link_state == LS_UP) {
index 5c2a3ac..b9894d5 100644 (file)
@@ -353,7 +353,7 @@ skip:
        case QLCNIC_BRDTYPE_P3P_4_GB_MM:
                supported |= SUPPORTED_Autoneg;
                advertising |= ADVERTISED_Autoneg;
-               /* fall through */
+               fallthrough;
        case QLCNIC_BRDTYPE_P3P_10G_CX4:
        case QLCNIC_BRDTYPE_P3P_10G_CX4_LP:
        case QLCNIC_BRDTYPE_P3P_10000_BASE_T:
@@ -377,7 +377,7 @@ skip:
                supported |= SUPPORTED_TP;
                check_sfp_module = netif_running(adapter->netdev) &&
                                   ahw->has_link_events;
-               /* fall through */
+               fallthrough;
        case QLCNIC_BRDTYPE_P3P_10G_XFP:
                supported |= SUPPORTED_FIBRE;
                advertising |= ADVERTISED_FIBRE;
index d1da92a..fc9e662 100644 (file)
@@ -4994,7 +4994,7 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
                rtl_unlock_config_regs(tp);
                RTL_W8(tp, Config2, RTL_R8(tp, Config2) & ~MSIEnable);
                rtl_lock_config_regs(tp);
-               /* fall through */
+               fallthrough;
        case RTL_GIGA_MAC_VER_07 ... RTL_GIGA_MAC_VER_17:
                flags = PCI_IRQ_LEGACY;
                break;
@@ -5137,7 +5137,7 @@ static void rtl_hw_initialize(struct rtl8169_private *tp)
        switch (tp->mac_version) {
        case RTL_GIGA_MAC_VER_49 ... RTL_GIGA_MAC_VER_52:
                rtl8168ep_stop_cmac(tp);
-               /* fall through */
+               fallthrough;
        case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_48:
                rtl_hw_init_8168g(tp);
                break;
index 99f7aae..df89d09 100644 (file)
@@ -1342,6 +1342,51 @@ static inline int ravb_hook_irq(unsigned int irq, irq_handler_t handler,
        return error;
 }
 
+/* MDIO bus init function */
+static int ravb_mdio_init(struct ravb_private *priv)
+{
+       struct platform_device *pdev = priv->pdev;
+       struct device *dev = &pdev->dev;
+       int error;
+
+       /* Bitbang init */
+       priv->mdiobb.ops = &bb_ops;
+
+       /* MII controller setting */
+       priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
+       if (!priv->mii_bus)
+               return -ENOMEM;
+
+       /* Hook up MII support for ethtool */
+       priv->mii_bus->name = "ravb_mii";
+       priv->mii_bus->parent = dev;
+       snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+                pdev->name, pdev->id);
+
+       /* Register MDIO bus */
+       error = of_mdiobus_register(priv->mii_bus, dev->of_node);
+       if (error)
+               goto out_free_bus;
+
+       return 0;
+
+out_free_bus:
+       free_mdio_bitbang(priv->mii_bus);
+       return error;
+}
+
+/* MDIO bus release function */
+static int ravb_mdio_release(struct ravb_private *priv)
+{
+       /* Unregister mdio bus */
+       mdiobus_unregister(priv->mii_bus);
+
+       /* Free bitbang info */
+       free_mdio_bitbang(priv->mii_bus);
+
+       return 0;
+}
+
 /* Network device open function for Ethernet AVB */
 static int ravb_open(struct net_device *ndev)
 {
@@ -1350,6 +1395,13 @@ static int ravb_open(struct net_device *ndev)
        struct device *dev = &pdev->dev;
        int error;
 
+       /* MDIO bus init */
+       error = ravb_mdio_init(priv);
+       if (error) {
+               netdev_err(ndev, "failed to initialize MDIO\n");
+               return error;
+       }
+
        napi_enable(&priv->napi[RAVB_BE]);
        napi_enable(&priv->napi[RAVB_NC]);
 
@@ -1427,6 +1479,7 @@ out_free_irq:
 out_napi_off:
        napi_disable(&priv->napi[RAVB_NC]);
        napi_disable(&priv->napi[RAVB_BE]);
+       ravb_mdio_release(priv);
        return error;
 }
 
@@ -1736,6 +1789,8 @@ static int ravb_close(struct net_device *ndev)
        ravb_ring_free(ndev, RAVB_BE);
        ravb_ring_free(ndev, RAVB_NC);
 
+       ravb_mdio_release(priv);
+
        return 0;
 }
 
@@ -1887,51 +1942,6 @@ static const struct net_device_ops ravb_netdev_ops = {
        .ndo_set_features       = ravb_set_features,
 };
 
-/* MDIO bus init function */
-static int ravb_mdio_init(struct ravb_private *priv)
-{
-       struct platform_device *pdev = priv->pdev;
-       struct device *dev = &pdev->dev;
-       int error;
-
-       /* Bitbang init */
-       priv->mdiobb.ops = &bb_ops;
-
-       /* MII controller setting */
-       priv->mii_bus = alloc_mdio_bitbang(&priv->mdiobb);
-       if (!priv->mii_bus)
-               return -ENOMEM;
-
-       /* Hook up MII support for ethtool */
-       priv->mii_bus->name = "ravb_mii";
-       priv->mii_bus->parent = dev;
-       snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-                pdev->name, pdev->id);
-
-       /* Register MDIO bus */
-       error = of_mdiobus_register(priv->mii_bus, dev->of_node);
-       if (error)
-               goto out_free_bus;
-
-       return 0;
-
-out_free_bus:
-       free_mdio_bitbang(priv->mii_bus);
-       return error;
-}
-
-/* MDIO bus release function */
-static int ravb_mdio_release(struct ravb_private *priv)
-{
-       /* Unregister mdio bus */
-       mdiobus_unregister(priv->mii_bus);
-
-       /* Free bitbang info */
-       free_mdio_bitbang(priv->mii_bus);
-
-       return 0;
-}
-
 static const struct of_device_id ravb_match_table[] = {
        { .compatible = "renesas,etheravb-r8a7790", .data = (void *)RCAR_GEN2 },
        { .compatible = "renesas,etheravb-r8a7794", .data = (void *)RCAR_GEN2 },
@@ -2174,13 +2184,6 @@ static int ravb_probe(struct platform_device *pdev)
                eth_hw_addr_random(ndev);
        }
 
-       /* MDIO bus init */
-       error = ravb_mdio_init(priv);
-       if (error) {
-               dev_err(&pdev->dev, "failed to initialize MDIO\n");
-               goto out_dma_free;
-       }
-
        netif_napi_add(ndev, &priv->napi[RAVB_BE], ravb_poll, 64);
        netif_napi_add(ndev, &priv->napi[RAVB_NC], ravb_poll, 64);
 
@@ -2202,8 +2205,6 @@ static int ravb_probe(struct platform_device *pdev)
 out_napi_del:
        netif_napi_del(&priv->napi[RAVB_NC]);
        netif_napi_del(&priv->napi[RAVB_BE]);
-       ravb_mdio_release(priv);
-out_dma_free:
        dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
                          priv->desc_bat_dma);
 
@@ -2235,7 +2236,6 @@ static int ravb_remove(struct platform_device *pdev)
        unregister_netdev(ndev);
        netif_napi_del(&priv->napi[RAVB_NC]);
        netif_napi_del(&priv->napi[RAVB_BE]);
-       ravb_mdio_release(priv);
        pm_runtime_disable(&pdev->dev);
        free_netdev(ndev);
        platform_set_drvdata(pdev, NULL);
index fc99e71..42458a4 100644 (file)
@@ -2169,7 +2169,7 @@ static void rocker_router_fib_event_work(struct work_struct *work)
                rocker_world_fib4_del(rocker, &fib_work->fen_info);
                fib_info_put(fib_work->fen_info.fi);
                break;
-       case FIB_EVENT_RULE_ADD: /* fall through */
+       case FIB_EVENT_RULE_ADD:
        case FIB_EVENT_RULE_DEL:
                rule = fib_work->fr_info.rule;
                if (!fib4_rule_default(rule))
@@ -2201,7 +2201,7 @@ static int rocker_router_fib_event(struct notifier_block *nb,
        fib_work->event = event;
 
        switch (event) {
-       case FIB_EVENT_ENTRY_REPLACE: /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
        case FIB_EVENT_ENTRY_DEL:
                if (info->family == AF_INET) {
                        struct fib_entry_notifier_info *fen_info = ptr;
@@ -2224,7 +2224,7 @@ static int rocker_router_fib_event(struct notifier_block *nb,
                 */
                fib_info_hold(fib_work->fen_info.fi);
                break;
-       case FIB_EVENT_RULE_ADD: /* fall through */
+       case FIB_EVENT_RULE_ADD:
        case FIB_EVENT_RULE_DEL:
                memcpy(&fib_work->fr_info, ptr, sizeof(fib_work->fr_info));
                fib_rule_get(fib_work->fr_info.rule);
@@ -2811,7 +2811,7 @@ static int rocker_switchdev_event(struct notifier_block *unused,
        switchdev_work->event = event;
 
        switch (event) {
-       case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
+       case SWITCHDEV_FDB_ADD_TO_DEVICE:
        case SWITCHDEV_FDB_DEL_TO_DEVICE:
                memcpy(&switchdev_work->fdb_info, ptr,
                       sizeof(switchdev_work->fdb_info));
index 21465cb..7f8b10c 100644 (file)
@@ -316,7 +316,7 @@ static int sxgbe_get_rss_hash_opts(struct sxgbe_priv_data *priv,
        case TCP_V4_FLOW:
        case UDP_V4_FLOW:
                cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* Fall through */
+               fallthrough;
        case SCTP_V4_FLOW:
        case AH_ESP_V4_FLOW:
        case AH_V4_FLOW:
@@ -327,7 +327,7 @@ static int sxgbe_get_rss_hash_opts(struct sxgbe_priv_data *priv,
        case TCP_V6_FLOW:
        case UDP_V6_FLOW:
                cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-               /* Fall through */
+               fallthrough;
        case SCTP_V6_FLOW:
        case AH_ESP_V6_FLOW:
        case AH_V6_FLOW:
index 9729983..c54b7f8 100644 (file)
@@ -142,7 +142,7 @@ static int ef100_pci_parse_continue_entry(struct efx_nic *efx, int entry_locatio
 
                /* Temporarily map new BAR. */
                rc = efx_init_io(efx, bar,
-                                DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
+                                (dma_addr_t)DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
                                 pci_resource_len(efx->pci_dev, bar));
                if (rc) {
                        netif_err(efx, probe, efx->net_dev,
@@ -160,7 +160,7 @@ static int ef100_pci_parse_continue_entry(struct efx_nic *efx, int entry_locatio
 
                /* Put old BAR back. */
                rc = efx_init_io(efx, previous_bar,
-                                DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
+                                (dma_addr_t)DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
                                 pci_resource_len(efx->pci_dev, previous_bar));
                if (rc) {
                        netif_err(efx, probe, efx->net_dev,
@@ -334,7 +334,7 @@ static int ef100_pci_parse_xilinx_cap(struct efx_nic *efx, int vndr_cap,
 
        /* Temporarily map BAR. */
        rc = efx_init_io(efx, bar,
-                        DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
+                        (dma_addr_t)DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
                         pci_resource_len(efx->pci_dev, bar));
        if (rc) {
                netif_err(efx, probe, efx->net_dev,
@@ -495,7 +495,7 @@ static int ef100_pci_probe(struct pci_dev *pci_dev,
 
        /* Set up basic I/O (BAR mappings etc) */
        rc = efx_init_io(efx, fcw.bar,
-                        DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
+                        (dma_addr_t)DMA_BIT_MASK(ESF_GZ_TX_SEND_ADDR_WIDTH),
                         pci_resource_len(efx->pci_dev, fcw.bar));
        if (rc)
                goto fail;
index 206d70f..19fe86b 100644 (file)
@@ -431,18 +431,18 @@ static int ef100_reset(struct efx_nic *efx, enum reset_type reset_type)
                /* A RESET_TYPE_ALL will cause filters to be removed, so we remove filters
                 * and reprobe after reset to avoid removing filters twice
                 */
-               down_read(&efx->filter_sem);
+               down_write(&efx->filter_sem);
                ef100_filter_table_down(efx);
-               up_read(&efx->filter_sem);
+               up_write(&efx->filter_sem);
                rc = efx_mcdi_reset(efx, reset_type);
                if (rc)
                        return rc;
 
                netif_device_attach(efx->net_dev);
 
-               down_read(&efx->filter_sem);
+               down_write(&efx->filter_sem);
                rc = ef100_filter_table_up(efx);
-               up_read(&efx->filter_sem);
+               up_write(&efx->filter_sem);
                if (rc)
                        return rc;
 
@@ -739,6 +739,7 @@ const struct efx_nic_type ef100_pf_nic_type = {
        .rx_remove = efx_mcdi_rx_remove,
        .rx_write = ef100_rx_write,
        .rx_packet = __ef100_rx_packet,
+       .rx_buf_hash_valid = ef100_rx_buf_hash_valid,
        .fini_dmaq = efx_fini_dmaq,
        .max_rx_ip_filters = EFX_MCDI_FILTER_TBL_ROWS,
        .filter_table_probe = ef100_filter_table_up,
@@ -820,6 +821,7 @@ const struct efx_nic_type ef100_vf_nic_type = {
        .rx_remove = efx_mcdi_rx_remove,
        .rx_write = ef100_rx_write,
        .rx_packet = __ef100_rx_packet,
+       .rx_buf_hash_valid = ef100_rx_buf_hash_valid,
        .fini_dmaq = efx_fini_dmaq,
        .max_rx_ip_filters = EFX_MCDI_FILTER_TBL_ROWS,
        .filter_table_probe = ef100_filter_table_up,
index 13ba1a4..85207ac 100644 (file)
 #define ESF_GZ_RX_PREFIX_NT_OR_INNER_L3_CLASS_WIDTH    \
                ESF_GZ_RX_PREFIX_HCLASS_NT_OR_INNER_L3_CLASS_WIDTH
 
-static bool check_fcs(struct efx_channel *channel, u32 *prefix)
+bool ef100_rx_buf_hash_valid(const u8 *prefix)
+{
+       return PREFIX_FIELD(prefix, RSS_HASH_VALID);
+}
+
+static bool ef100_has_fcs_error(struct efx_channel *channel, u32 *prefix)
 {
        u16 rxclass;
        u8 l2status;
@@ -41,11 +46,11 @@ static bool check_fcs(struct efx_channel *channel, u32 *prefix)
 
        if (likely(l2status == ESE_GZ_RH_HCLASS_L2_STATUS_OK))
                /* Everything is ok */
-               return 0;
+               return false;
 
        if (l2status == ESE_GZ_RH_HCLASS_L2_STATUS_FCS_ERR)
                channel->n_rx_eth_crc_err++;
-       return 1;
+       return true;
 }
 
 void __ef100_rx_packet(struct efx_channel *channel)
@@ -58,7 +63,7 @@ void __ef100_rx_packet(struct efx_channel *channel)
 
        prefix = (u32 *)(eh - ESE_GZ_RX_PKT_PREFIX_LEN);
 
-       if (check_fcs(channel, prefix) &&
+       if (ef100_has_fcs_error(channel, prefix) &&
            unlikely(!(efx->net_dev->features & NETIF_F_RXALL)))
                goto out;
 
index f2f2668..fe45b36 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "net_driver.h"
 
+bool ef100_rx_buf_hash_valid(const u8 *prefix);
 void efx_ef100_ev_rx(struct efx_channel *channel, const efx_qword_t *p_event);
 void ef100_rx_write(struct efx_rx_queue *rx_queue);
 void __ef100_rx_packet(struct efx_channel *channel);
index a9808e8..daf0c00 100644 (file)
@@ -45,6 +45,14 @@ static inline void efx_rx_flush_packet(struct efx_channel *channel)
                                __ef100_rx_packet, __efx_rx_packet,
                                channel);
 }
+static inline bool efx_rx_buf_hash_valid(struct efx_nic *efx, const u8 *prefix)
+{
+       if (efx->type->rx_buf_hash_valid)
+               return INDIRECT_CALL_1(efx->type->rx_buf_hash_valid,
+                                      ef100_rx_buf_hash_valid,
+                                      prefix);
+       return true;
+}
 
 /* Maximum number of TCP segments we support for soft-TSO */
 #define EFX_TSO_MAX_SEGS       100
index db90d94..a6bae6a 100644 (file)
@@ -957,7 +957,7 @@ ef4_ethtool_get_rxnfc(struct net_device *net_dev,
                switch (info->flow_type) {
                case TCP_V4_FLOW:
                        info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-                       /* Fall through */
+                       fallthrough;
                case UDP_V4_FLOW:
                case SCTP_V4_FLOW:
                case AH_ESP_V4_FLOW:
index 3321832..fa1ade8 100644 (file)
@@ -1049,10 +1049,10 @@ ef4_farch_handle_rx_event(struct ef4_channel *channel, const ef4_qword_t *event)
                switch (rx_ev_hdr_type) {
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP:
                        flags |= EF4_RX_PKT_TCP;
-                       /* fall through */
+                       fallthrough;
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP:
                        flags |= EF4_RX_PKT_CSUMMED;
-                       /* fall through */
+                       fallthrough;
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER:
                case FSE_AZ_RX_EV_HDR_TYPE_OTHER:
                        break;
@@ -1310,7 +1310,7 @@ int ef4_farch_ev_process(struct ef4_channel *channel, int budget)
                        if (efx->type->handle_global_event &&
                            efx->type->handle_global_event(channel, &event))
                                break;
-                       /* else fall through */
+                       fallthrough;
                default:
                        netif_err(channel->efx, hw, channel->efx->net_dev,
                                  "channel %d unknown event type %d (data "
@@ -1983,7 +1983,7 @@ ef4_farch_filter_from_gen_spec(struct ef4_farch_filter_spec *spec,
              EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_LOC_PORT |
              EF4_FILTER_MATCH_REM_HOST | EF4_FILTER_MATCH_REM_PORT):
                is_full = true;
-               /* fall through */
+               fallthrough;
        case (EF4_FILTER_MATCH_ETHER_TYPE | EF4_FILTER_MATCH_IP_PROTO |
              EF4_FILTER_MATCH_LOC_HOST | EF4_FILTER_MATCH_LOC_PORT): {
                __be32 rhost, host1, host2;
@@ -2034,7 +2034,7 @@ ef4_farch_filter_from_gen_spec(struct ef4_farch_filter_spec *spec,
 
        case EF4_FILTER_MATCH_LOC_MAC | EF4_FILTER_MATCH_OUTER_VID:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EF4_FILTER_MATCH_LOC_MAC:
                spec->type = (is_full ? EF4_FARCH_FILTER_MAC_FULL :
                              EF4_FARCH_FILTER_MAC_WILD);
@@ -2081,7 +2081,7 @@ ef4_farch_filter_to_gen_spec(struct ef4_filter_spec *gen_spec,
        case EF4_FARCH_FILTER_TCP_FULL:
        case EF4_FARCH_FILTER_UDP_FULL:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EF4_FARCH_FILTER_TCP_WILD:
        case EF4_FARCH_FILTER_UDP_WILD: {
                __be32 host1, host2;
@@ -2125,7 +2125,7 @@ ef4_farch_filter_to_gen_spec(struct ef4_filter_spec *gen_spec,
 
        case EF4_FARCH_FILTER_MAC_FULL:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EF4_FARCH_FILTER_MAC_WILD:
                gen_spec->match_flags = EF4_FILTER_MATCH_LOC_MAC;
                if (is_full)
index d07eeaa..4002f9a 100644 (file)
@@ -1038,10 +1038,10 @@ efx_farch_handle_rx_event(struct efx_channel *channel, const efx_qword_t *event)
                switch (rx_ev_hdr_type) {
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_TCP:
                        flags |= EFX_RX_PKT_TCP;
-                       /* fall through */
+                       fallthrough;
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_UDP:
                        flags |= EFX_RX_PKT_CSUMMED;
-                       /* fall through */
+                       fallthrough;
                case FSE_CZ_RX_EV_HDR_TYPE_IPV4V6_OTHER:
                case FSE_AZ_RX_EV_HDR_TYPE_OTHER:
                        break;
@@ -1316,7 +1316,7 @@ int efx_farch_ev_process(struct efx_channel *channel, int budget)
                        if (efx->type->handle_global_event &&
                            efx->type->handle_global_event(channel, &event))
                                break;
-                       /* else fall through */
+                       fallthrough;
                default:
                        netif_err(channel->efx, hw, channel->efx->net_dev,
                                  "channel %d unknown event type %d (data "
@@ -2043,7 +2043,7 @@ efx_farch_filter_from_gen_spec(struct efx_farch_filter_spec *spec,
              EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT |
              EFX_FILTER_MATCH_REM_HOST | EFX_FILTER_MATCH_REM_PORT):
                is_full = true;
-               /* fall through */
+               fallthrough;
        case (EFX_FILTER_MATCH_ETHER_TYPE | EFX_FILTER_MATCH_IP_PROTO |
              EFX_FILTER_MATCH_LOC_HOST | EFX_FILTER_MATCH_LOC_PORT): {
                __be32 rhost, host1, host2;
@@ -2094,7 +2094,7 @@ efx_farch_filter_from_gen_spec(struct efx_farch_filter_spec *spec,
 
        case EFX_FILTER_MATCH_LOC_MAC | EFX_FILTER_MATCH_OUTER_VID:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EFX_FILTER_MATCH_LOC_MAC:
                spec->type = (is_full ? EFX_FARCH_FILTER_MAC_FULL :
                              EFX_FARCH_FILTER_MAC_WILD);
@@ -2141,7 +2141,7 @@ efx_farch_filter_to_gen_spec(struct efx_filter_spec *gen_spec,
        case EFX_FARCH_FILTER_TCP_FULL:
        case EFX_FARCH_FILTER_UDP_FULL:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EFX_FARCH_FILTER_TCP_WILD:
        case EFX_FARCH_FILTER_UDP_WILD: {
                __be32 host1, host2;
@@ -2185,7 +2185,7 @@ efx_farch_filter_to_gen_spec(struct efx_filter_spec *gen_spec,
 
        case EFX_FARCH_FILTER_MAC_FULL:
                is_full = true;
-               /* fall through */
+               fallthrough;
        case EFX_FARCH_FILTER_MAC_WILD:
                gen_spec->match_flags = EFX_FILTER_MATCH_LOC_MAC;
                if (is_full)
index 5a74d88..1523be7 100644 (file)
@@ -140,7 +140,7 @@ efx_mcdi_filter_push_prep_set_match_fields(struct efx_nic *efx,
                switch (encap_type & EFX_ENCAP_TYPES_MASK) {
                case EFX_ENCAP_TYPE_VXLAN:
                        vni_type = MC_CMD_FILTER_OP_EXT_IN_VNI_TYPE_VXLAN;
-                       /* fallthrough */
+                       fallthrough;
                case EFX_ENCAP_TYPE_GENEVE:
                        COPY_VALUE(ether_type, ETHER_TYPE);
                        outer_ip_proto = IPPROTO_UDP;
index 56af8b5..714d7f9 100644 (file)
@@ -282,7 +282,7 @@ void efx_mcdi_phy_decode_link(struct efx_nic *efx,
                break;
        default:
                WARN_ON(1);
-               /* Fall through */
+               fallthrough;
        case MC_CMD_FCNTL_OFF:
                link_state->fc = 0;
                break;
index 7bb7ecb..062462a 100644 (file)
@@ -846,6 +846,7 @@ struct efx_async_filter_insertion {
  * @timer_quantum_ns: Interrupt timer quantum, in nanoseconds
  * @timer_max_ns: Interrupt timer maximum value, in nanoseconds
  * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues
+ * @irqs_hooked: Channel interrupts are hooked
  * @irq_rx_mod_step_us: Step size for IRQ moderation for RX event queues
  * @irq_rx_moderation_us: IRQ moderation time for RX event queues
  * @msg_enable: Log message enable flags
@@ -1004,6 +1005,7 @@ struct efx_nic {
        unsigned int timer_quantum_ns;
        unsigned int timer_max_ns;
        bool irq_rx_adaptive;
+       bool irqs_hooked;
        unsigned int irq_mod_step_us;
        unsigned int irq_rx_moderation_us;
        u32 msg_enable;
@@ -1265,6 +1267,7 @@ struct efx_udp_tunnel {
  * @rx_write: Write RX descriptors and doorbell
  * @rx_defer_refill: Generate a refill reminder event
  * @rx_packet: Receive the queued RX buffer on a channel
+ * @rx_buf_hash_valid: Determine whether the RX prefix contains a valid hash
  * @ev_probe: Allocate resources for event queue
  * @ev_init: Initialise event queue on the NIC
  * @ev_fini: Deinitialise event queue on the NIC
@@ -1409,6 +1412,7 @@ struct efx_nic_type {
        void (*rx_write)(struct efx_rx_queue *rx_queue);
        void (*rx_defer_refill)(struct efx_rx_queue *rx_queue);
        void (*rx_packet)(struct efx_channel *channel);
+       bool (*rx_buf_hash_valid)(const u8 *prefix);
        int (*ev_probe)(struct efx_channel *channel);
        int (*ev_init)(struct efx_channel *channel);
        void (*ev_fini)(struct efx_channel *channel);
index d994d13..d1e9088 100644 (file)
@@ -129,6 +129,7 @@ int efx_nic_init_interrupt(struct efx_nic *efx)
 #endif
        }
 
+       efx->irqs_hooked = true;
        return 0;
 
  fail2:
@@ -154,6 +155,8 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
        efx->net_dev->rx_cpu_rmap = NULL;
 #endif
 
+       if (!efx->irqs_hooked)
+               return;
        if (EFX_INT_MODE_USE_MSI(efx)) {
                /* Disable MSI/MSI-X interrupts */
                efx_for_each_channel(channel, efx)
@@ -163,6 +166,7 @@ void efx_nic_fini_interrupt(struct efx_nic *efx)
                /* Disable legacy interrupt */
                free_irq(efx->legacy_irq, efx);
        }
+       efx->irqs_hooked = false;
 }
 
 /* Register dump */
index 59a43d5..aaa1128 100644 (file)
@@ -358,7 +358,7 @@ static bool efx_do_xdp(struct efx_nic *efx, struct efx_channel *channel,
 
        case XDP_ABORTED:
                trace_xdp_exception(efx->net_dev, xdp_prog, xdp_act);
-               /* Fall through */
+               fallthrough;
        case XDP_DROP:
                efx_free_rx_buffers(rx_queue, rx_buf, 1);
                channel->n_rx_xdp_drops++;
index fb77c7b..5e29284 100644 (file)
@@ -525,7 +525,8 @@ efx_rx_packet_gro(struct efx_channel *channel, struct efx_rx_buffer *rx_buf,
                return;
        }
 
-       if (efx->net_dev->features & NETIF_F_RXHASH)
+       if (efx->net_dev->features & NETIF_F_RXHASH &&
+           efx_rx_buf_hash_valid(efx, eh))
                skb_set_hash(skb, efx_rx_buf_hash(efx, eh),
                             PKT_HASH_TYPE_L3);
        if (csum) {
@@ -848,6 +849,7 @@ void efx_remove_filters(struct efx_nic *efx)
        efx_for_each_channel(channel, efx) {
                cancel_delayed_work_sync(&channel->filter_work);
                kfree(channel->rps_flow_id);
+               channel->rps_flow_id = NULL;
        }
 #endif
        down_write(&efx->filter_sem);
index 336105f..cfa460c 100644 (file)
@@ -2228,7 +2228,7 @@ static int mii_ioctl(struct net_device *net_dev, struct ifreq *rq, int cmd)
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = sis_priv->mii->phy_addr;
-               /* Fall Through */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                data->val_out = mdio_read(net_dev, data->phy_id & 0x1f, data->reg_num & 0x1f);
index 186c0bd..01069df 100644 (file)
@@ -712,7 +712,7 @@ static void smc911x_phy_detect(struct net_device *dev)
                                        /* Found an external PHY */
                                        break;
                        }
-                       /* Else, fall through */
+                       fallthrough;
                default:
                        /* Internal media only */
                        SMC_GET_PHY_ID1(lp, 1, id1);
index 25db667..806eb65 100644 (file)
@@ -919,10 +919,10 @@ static u32 netsec_run_xdp(struct netsec_priv *priv, struct bpf_prog *prog,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(priv->ndev, prog, act);
-               /* fall through -- handle aborts by dropping packet */
+               fallthrough;    /* handle aborts by dropping packet */
        case XDP_DROP:
                ret = NETSEC_XDP_CONSUMED;
                page = virt_to_head_page(xdp->data);
index d0d2d0f..08c7663 100644 (file)
@@ -84,9 +84,10 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev)
                return ERR_PTR(err);
 
        switch (phy_mode) {
-       case PHY_INTERFACE_MODE_RGMII:          /* Fall through */
-       case PHY_INTERFACE_MODE_RGMII_ID        /* Fall through */:
-       case PHY_INTERFACE_MODE_RGMII_RXID:     /* Fall through */
+       case PHY_INTERFACE_MODE_RGMII:
+               fallthrough;
+       case PHY_INTERFACE_MODE_RGMII_ID:
+       case PHY_INTERFACE_MODE_RGMII_RXID:
        case PHY_INTERFACE_MODE_RGMII_TXID:
                gmac->phy_intf_sel = GMAC_CONFIG_INTF_RGMII;
                break;
index e113b13..bf195ad 100644 (file)
@@ -1985,7 +1985,7 @@ void stmmac_selftest_run(struct net_device *dev,
                                ret = phy_loopback(dev->phydev, true);
                        if (!ret)
                                break;
-                       /* Fallthrough */
+                       fallthrough;
                case STMMAC_LOOPBACK_MAC:
                        ret = stmmac_set_mac_loopback(priv, priv->ioaddr, true);
                        break;
@@ -2018,7 +2018,7 @@ void stmmac_selftest_run(struct net_device *dev,
                                ret = phy_loopback(dev->phydev, false);
                        if (!ret)
                                break;
-                       /* Fallthrough */
+                       fallthrough;
                case STMMAC_LOOPBACK_MAC:
                        stmmac_set_mac_loopback(priv, priv->ioaddr, false);
                        break;
index 3d74784..cc27d66 100644 (file)
@@ -228,7 +228,7 @@ static int tc_setup_cls_u32(struct stmmac_priv *priv,
        switch (cls->command) {
        case TC_CLSU32_REPLACE_KNODE:
                tc_unfill_entry(priv, cls);
-               /* Fall through */
+               fallthrough;
        case TC_CLSU32_NEW_KNODE:
                return tc_config_knode(priv, cls);
        case TC_CLSU32_DELETE_KNODE:
index e2bc7a2..b624e17 100644 (file)
@@ -4759,7 +4759,7 @@ static int cas_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = cp->phy_addr;
-               /* Fallthrough... */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                spin_lock_irqsave(&cp->lock, flags);
index 9b5effb..68695d4 100644 (file)
@@ -8835,7 +8835,7 @@ static int walk_phys(struct niu *np, struct niu_parent *parent)
                        else
                                goto unknown_vg_1g_port;
 
-                       /* fallthru */
+                       fallthrough;
                case 0x22:
                        val = (phy_encode(PORT_TYPE_10G, 0) |
                               phy_encode(PORT_TYPE_10G, 1) |
@@ -8860,7 +8860,7 @@ static int walk_phys(struct niu *np, struct niu_parent *parent)
                        else
                                goto unknown_vg_1g_port;
 
-                       /* fallthru */
+                       fallthrough;
                case 0x13:
                        if ((lowest_10g & 0x7) == 0)
                                val = (phy_encode(PORT_TYPE_10G, 0) |
index eeb8518..8deb943 100644 (file)
@@ -2712,7 +2712,7 @@ static int gem_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
                data->phy_id = gp->mii_phy_addr;
-               /* Fallthrough... */
+               fallthrough;
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
                data->val_out = __sungem_phy_read(gp, data->phy_id & 0x1f,
index cb994f6..9baf3f3 100644 (file)
@@ -174,6 +174,8 @@ void am65_cpsw_nuss_adjust_link(struct net_device *ndev)
                if (phy->speed == 10 && phy_interface_is_rgmii(phy))
                        /* Can be used with in band mode only */
                        mac_control |= CPSW_SL_CTL_EXT_EN;
+               if (phy->speed == 100 && phy->interface == PHY_INTERFACE_MODE_RMII)
+                       mac_control |= CPSW_SL_CTL_IFCTL_A;
                if (phy->duplex)
                        mac_control |= CPSW_SL_CTL_FULLDUPLEX;
 
index 4e184ee..6e72ecb 100644 (file)
@@ -67,7 +67,7 @@ static void cpsw_gmii_sel_am3352(struct cpsw_phy_sel_priv *priv,
                dev_warn(priv->dev,
                         "Unsupported PHY mode: \"%s\". Defaulting to MII.\n",
                        phy_modes(phy_mode));
-               /* fallthrough */
+               fallthrough;
        case PHY_INTERFACE_MODE_MII:
                mode = AM33XX_GMII_SEL_MODE_MII;
                break;
@@ -122,7 +122,7 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
                dev_warn(priv->dev,
                         "Unsupported PHY mode: \"%s\". Defaulting to MII.\n",
                        phy_modes(phy_mode));
-               /* fallthrough */
+               fallthrough;
        case PHY_INTERFACE_MODE_MII:
                mode = AM33XX_GMII_SEL_MODE_MII;
                break;
index 9b17bbb..4a65edc 100644 (file)
@@ -1116,7 +1116,7 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
                                  HOST_PORT_NUM, ALE_VLAN, vid);
        ret |= cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
                                  0, ALE_VLAN, vid);
-       ret |= cpsw_ale_flush_multicast(cpsw->ale, 0, vid);
+       ret |= cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid);
 err:
        pm_runtime_put(cpsw->dev);
        return ret;
index 1247d35..8ed7857 100644 (file)
@@ -1032,19 +1032,34 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev,
                return ret;
        }
 
+       /* reset the return code as pm_runtime_get_sync() can return
+        * non zero values as well.
+        */
+       ret = 0;
        for (i = 0; i < cpsw->data.slaves; i++) {
                if (cpsw->slaves[i].ndev &&
-                   vid == cpsw->slaves[i].port_vlan)
+                   vid == cpsw->slaves[i].port_vlan) {
+                       ret = -EINVAL;
                        goto err;
+               }
        }
 
        dev_dbg(priv->dev, "removing vlanid %d from vlan filter\n", vid);
-       cpsw_ale_del_vlan(cpsw->ale, vid, 0);
-       cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
-                          HOST_PORT_NUM, ALE_VLAN, vid);
-       cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
-                          0, ALE_VLAN, vid);
-       cpsw_ale_flush_multicast(cpsw->ale, 0, vid);
+       ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0);
+       if (ret)
+               dev_err(priv->dev, "cpsw_ale_del_vlan() failed: ret %d\n", ret);
+       ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr,
+                                HOST_PORT_NUM, ALE_VLAN, vid);
+       if (ret)
+               dev_err(priv->dev, "cpsw_ale_del_ucast() failed: ret %d\n",
+                       ret);
+       ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast,
+                                0, ALE_VLAN, vid);
+       if (ret)
+               dev_err(priv->dev, "cpsw_ale_del_mcast failed. ret %d\n",
+                       ret);
+       cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid);
+       ret = 0;
 err:
        pm_runtime_put(cpsw->dev);
        return ret;
index d6d7a7d..482a1a4 100644 (file)
@@ -1371,10 +1371,10 @@ int cpsw_run_xdp(struct cpsw_priv *priv, int ch, struct xdp_buff *xdp,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(ndev, prog, act);
-               /* fall through -- handle aborts by dropping packet */
+               fallthrough;    /* handle aborts by dropping packet */
        case XDP_DROP:
                goto drop;
        }
index 58623e9..76a342e 100644 (file)
@@ -948,7 +948,7 @@ static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:               /* get address of MII PHY in use. */
                data->phy_id = phy;
-               /* fall through */
+               fallthrough;
 
 
        case SIOCGMIIREG:               /* read MII PHY register. */
index 2db546b..dc14a66 100644 (file)
@@ -877,7 +877,7 @@ static int gelic_wl_set_auth(struct net_device *netdev,
        case IW_AUTH_KEY_MGMT:
                if (param->value & IW_AUTH_KEY_MGMT_PSK)
                        break;
-               /* intentionally fall through */
+               fallthrough;
        default:
                ret = -EOPNOTSUPP;
                break;
index 0738970..5f5b33e 100644 (file)
@@ -786,7 +786,7 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
                        /* fallthrough, if we release the descriptors
                         * brutally (then we don't care about
                         * SPIDER_NET_DESCR_CARDOWNED) */
-                       /* Fall through */
+                       fallthrough;
 
                case SPIDER_NET_DESCR_RESPONSE_ERROR:
                case SPIDER_NET_DESCR_PROTECTION_ERROR:
@@ -1397,9 +1397,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
                show_error = 0;
                break;
 
-       case SPIDER_NET_GDDDEN0INT: /* fallthrough */
-       case SPIDER_NET_GDCDEN0INT: /* fallthrough */
-       case SPIDER_NET_GDBDEN0INT: /* fallthrough */
+       case SPIDER_NET_GDDDEN0INT:
+       case SPIDER_NET_GDCDEN0INT:
+       case SPIDER_NET_GDBDEN0INT:
        case SPIDER_NET_GDADEN0INT:
                /* someone has set RX_DMA_EN to 0 */
                show_error = 0;
@@ -1449,10 +1449,10 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
                 * Logging is not needed. */
                show_error = 0;
                break;
-       case SPIDER_NET_GRFDFLLINT: /* fallthrough */
-       case SPIDER_NET_GRFCFLLINT: /* fallthrough */
-       case SPIDER_NET_GRFBFLLINT: /* fallthrough */
-       case SPIDER_NET_GRFAFLLINT: /* fallthrough */
+       case SPIDER_NET_GRFDFLLINT:
+       case SPIDER_NET_GRFCFLLINT:
+       case SPIDER_NET_GRFBFLLINT:
+       case SPIDER_NET_GRFAFLLINT:
        case SPIDER_NET_GRMFLLINT:
                /* Could happen when rx chain is full */
                if (card->ignore_rx_ramfull == 0) {
@@ -1473,9 +1473,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
                break;
 
        /* chain end */
-       case SPIDER_NET_GDDDCEINT: /* fallthrough */
-       case SPIDER_NET_GDCDCEINT: /* fallthrough */
-       case SPIDER_NET_GDBDCEINT: /* fallthrough */
+       case SPIDER_NET_GDDDCEINT:
+       case SPIDER_NET_GDCDCEINT:
+       case SPIDER_NET_GDBDCEINT:
        case SPIDER_NET_GDADCEINT:
                spider_net_resync_head_ptr(card);
                spider_net_refill_rx_chain(card);
@@ -1486,9 +1486,9 @@ spider_net_handle_error_irq(struct spider_net_card *card, u32 status_reg,
                break;
 
        /* invalid descriptor */
-       case SPIDER_NET_GDDINVDINT: /* fallthrough */
-       case SPIDER_NET_GDCINVDINT: /* fallthrough */
-       case SPIDER_NET_GDBINVDINT: /* fallthrough */
+       case SPIDER_NET_GDDINVDINT:
+       case SPIDER_NET_GDCINVDINT:
+       case SPIDER_NET_GDBINVDINT:
        case SPIDER_NET_GDAINVDINT:
                /* Could happen when rx chain is full */
                spider_net_resync_head_ptr(card);
index 3e3883a..3e33714 100644 (file)
@@ -1434,7 +1434,7 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
     switch(cmd) {
       case SIOCGMIIPHY:                /* Get the address of the PHY in use. */
        data->phy_id = 0;       /* we have only this address */
-       /* fall through */
+       fallthrough;
       case SIOCGMIIREG:                /* Read the specified MII register. */
        data->val_out = mii_rd(ioaddr, data->phy_id & 0x1f,
                               data->reg_num & 0x1f);
index e9bf429..4eea340 100644 (file)
 #define KERNEL
 #include "h/smtstate.h"
 
-#ifndef        lint
-static const char ID_sccs[] = "@(#)cfm.c       2.18 98/10/06 (C) SK " ;
-#endif
-
 /*
  * FSM Macros
  */
@@ -208,7 +204,6 @@ void cfm(struct s_smc *smc, int event)
 {
        int     state ;         /* remember last state */
        int     cond ;
-       int     oldstate ;
 
        /* We will do the following: */
        /*  - compute the variable WC_Flag for every port (This is where */
@@ -222,7 +217,6 @@ void cfm(struct s_smc *smc, int event)
        /*  - change the portstates */
        cem_priv_state (smc, event);
 
-       oldstate = smc->mib.fddiSMTCF_State ;
        do {
                DB_CFM("CFM : state %s%s event %s",
                       smc->mib.fddiSMTCF_State & AFLAG ? "ACTIONS " : "",
@@ -250,18 +244,11 @@ void cfm(struct s_smc *smc, int event)
        if (cond != smc->mib.fddiSMTPeerWrapFlag)
                smt_srf_event(smc,SMT_COND_SMT_PEER_WRAP,0,cond) ;
 
-#if    0
        /*
-        * Don't send ever MAC_PATH_CHANGE events. Our MAC is hard-wired
+        * Don't ever send MAC_PATH_CHANGE events. Our MAC is hard-wired
         * to the primary path.
         */
-       /*
-        * path change
-        */
-       if (smc->mib.fddiSMTCF_State != oldstate) {
-               smt_srf_event(smc,SMT_EVENT_MAC_PATH_CHANGE,INDEX_MAC,0) ;
-       }
-#endif
+
 #endif /* no SLIM_SMT */
 
        /*
index 02966d1..4cbb145 100644 (file)
 #include <linux/bitrev.h>
 #include <linux/etherdevice.h>
 
-#ifndef        lint
-static const char ID_sccs[] = "@(#)fplustm.c   1.32 99/02/23 (C) SK " ;
-#endif
-
 #ifndef UNUSED
 #ifdef  lint
 #define UNUSED(x)      (x) = (x)
index 3412e0f..1070390 100644 (file)
  *
  ******************************************************************************/
 
-#ifndef        lint
-static char const ID_sccs[] = "@(#)hwmtm.c     1.40 99/05/31 (C) SK" ;
-#endif
-
 #define        HWMTM
 
 #ifndef FDDI
index 1be0395..554cde8 100644 (file)
@@ -847,7 +847,7 @@ static void pcm_fsm(struct s_smc *smc, struct s_phy *phy, int cmd)
 
        case ACTIONS(PC5_SIGNAL) :
                ACTIONS_DONE() ;
-               /* fall through */
+               fallthrough;
        case PC5_SIGNAL :
                if ((cmd != PC_SIGNAL) && (cmd != PC_TIMEOUT_LCT))
                        break ;
@@ -946,7 +946,7 @@ static void pcm_fsm(struct s_smc *smc, struct s_phy *phy, int cmd)
                SETMASK(PLC(np,PL_CNTRL_B),PL_PC_JOIN,PL_PC_JOIN) ;
                ACTIONS_DONE() ;
                cmd = 0 ;
-               /* fall thru */
+               fallthrough;
        case PC6_JOIN :
                switch (plc->p_state) {
                case PS_ACTIVE:
index b8c59d8..774a6e3 100644 (file)
 #define KERNEL
 #include "h/smtstate.h"
 
-#ifndef        lint
-static const char ID_sccs[] = "@(#)smt.c       2.43 98/11/23 (C) SK " ;
-#endif
-
 /*
  * FC in SMbuf
  */
@@ -1561,7 +1557,7 @@ u_long smt_get_tid(struct s_smc *smc)
        return tid & 0x3fffffffL;
 }
 
-
+#ifdef LITTLE_ENDIAN
 /*
  * table of parameter lengths
  */
@@ -1641,6 +1637,7 @@ static const struct smt_pdef {
 } ;
 
 #define N_SMT_PLEN     ARRAY_SIZE(smt_pdef)
+#endif
 
 int smt_check_para(struct s_smc *smc, struct smt_header        *sm,
                   const u_short list[])
index 8c810ed..4666226 100644 (file)
@@ -974,7 +974,7 @@ static void fjes_stop_req_irq(struct fjes_adapter *adapter, int src_epid)
                                FJES_RX_STOP_REQ_DONE;
                spin_unlock_irqrestore(&hw->rx_status_lock, flags);
                clear_bit(src_epid, &hw->txrx_stop_req_bit);
-               /* fall through */
+               fallthrough;
        case EP_PARTNER_UNSHARE:
        case EP_PARTNER_COMPLETE:
        default:
index 21640a0..8e47d01 100644 (file)
@@ -1179,6 +1179,7 @@ static int gtp_genl_fill_info(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,
                goto nlmsg_failure;
 
        if (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) ||
+           nla_put_u32(skb, GTPA_LINK, pctx->dev->ifindex) ||
            nla_put_be32(skb, GTPA_PEER_ADDRESS, pctx->peer_addr_ip4.s_addr) ||
            nla_put_be32(skb, GTPA_MS_ADDRESS, pctx->ms_addr_ip4.s_addr))
                goto nla_put_failure;
index 4476491..e4e4981 100644 (file)
@@ -500,7 +500,7 @@ static int transmit(struct baycom_state *bc, int cnt, unsigned char stat)
                                }
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
 
                default:
                        if (bc->hdlctx.calibrate <= 0)
index deef142..17be2bb 100644 (file)
@@ -482,7 +482,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
                case CRC_MODE_SMACK_TEST:
                        ax->crcmode  = CRC_MODE_FLEX_TEST;
                        printk(KERN_INFO "mkiss: %s: Trying crc-smack\n", ax->dev->name);
-                       // fall through
+                       fallthrough;
                case CRC_MODE_SMACK:
                        *p |= 0x80;
                        crc = swab16(crc16(0, p, len));
@@ -491,7 +491,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
                case CRC_MODE_FLEX_TEST:
                        ax->crcmode = CRC_MODE_NONE;
                        printk(KERN_INFO "mkiss: %s: Trying crc-flexnet\n", ax->dev->name);
-                       // fall through
+                       fallthrough;
                case CRC_MODE_FLEX:
                        *p |= 0x20;
                        crc = calc_crc_flex(p, len);
@@ -744,7 +744,6 @@ static int mkiss_open(struct tty_struct *tty)
                       ax->dev->name);
                break;
        case 0:
-               /* fall through */
        default:
                crc_force = 0;
                printk(KERN_INFO "mkiss: %s: crc mode is auto.\n",
index 787f17e..64b0a74 100644 (file)
@@ -367,7 +367,7 @@ static u16 netvsc_select_queue(struct net_device *ndev, struct sk_buff *skb,
        }
        rcu_read_unlock();
 
-       while (unlikely(txq >= ndev->real_num_tx_queues))
+       while (txq >= ndev->real_num_tx_queues)
                txq -= ndev->real_num_tx_queues;
 
        return txq;
@@ -502,7 +502,7 @@ static int netvsc_vf_xmit(struct net_device *net, struct net_device *vf_netdev,
        int rc;
 
        skb->dev = vf_netdev;
-       skb->queue_mapping = qdisc_skb_cb(skb)->slave_dev_queue_mapping;
+       skb_record_rx_queue(skb, qdisc_skb_cb(skb)->slave_dev_queue_mapping);
 
        rc = dev_queue_xmit(skb);
        if (likely(rc == NET_XMIT_SUCCESS || rc == NET_XMIT_CN)) {
index 15e87c0..5bca94c 100644 (file)
@@ -106,12 +106,21 @@ static void ipvlan_port_destroy(struct net_device *dev)
        kfree(port);
 }
 
+#define IPVLAN_ALWAYS_ON_OFLOADS \
+       (NETIF_F_SG | NETIF_F_HW_CSUM | \
+        NETIF_F_GSO_ROBUST | NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL)
+
+#define IPVLAN_ALWAYS_ON \
+       (IPVLAN_ALWAYS_ON_OFLOADS | NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED)
+
 #define IPVLAN_FEATURES \
-       (NETIF_F_SG | NETIF_F_CSUM_MASK | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
+       (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
         NETIF_F_GSO | NETIF_F_ALL_TSO | NETIF_F_GSO_ROBUST | \
         NETIF_F_GRO | NETIF_F_RXCSUM | \
         NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
 
+       /* NETIF_F_GSO_ENCAP_ALL NETIF_F_GSO_SOFTWARE Newly added */
+
 #define IPVLAN_STATE_MASK \
        ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
 
@@ -125,7 +134,9 @@ static int ipvlan_init(struct net_device *dev)
        dev->state = (dev->state & ~IPVLAN_STATE_MASK) |
                     (phy_dev->state & IPVLAN_STATE_MASK);
        dev->features = phy_dev->features & IPVLAN_FEATURES;
-       dev->features |= NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED;
+       dev->features |= IPVLAN_ALWAYS_ON;
+       dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
+       dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
        dev->hw_enc_features |= dev->features;
        dev->gso_max_size = phy_dev->gso_max_size;
        dev->gso_max_segs = phy_dev->gso_max_segs;
@@ -227,7 +238,14 @@ static netdev_features_t ipvlan_fix_features(struct net_device *dev,
 {
        struct ipvl_dev *ipvlan = netdev_priv(dev);
 
-       return features & (ipvlan->sfeatures | ~IPVLAN_FEATURES);
+       features |= NETIF_F_ALL_FOR_ALL;
+       features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
+       features = netdev_increment_features(ipvlan->phy_dev->features,
+                                            features, features);
+       features |= IPVLAN_ALWAYS_ON;
+       features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
+
+       return features;
 }
 
 static void ipvlan_change_rx_flags(struct net_device *dev, int change)
@@ -734,10 +752,9 @@ static int ipvlan_device_event(struct notifier_block *unused,
 
        case NETDEV_FEAT_CHANGE:
                list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
-                       ipvlan->dev->features = dev->features & IPVLAN_FEATURES;
                        ipvlan->dev->gso_max_size = dev->gso_max_size;
                        ipvlan->dev->gso_max_segs = dev->gso_max_segs;
-                       netdev_features_change(ipvlan->dev);
+                       netdev_update_features(ipvlan->dev);
                }
                break;
 
index 4942f61..c8d803d 100644 (file)
@@ -842,7 +842,7 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCSHWTSTAMP:
                if (!net_eq(dev_net(dev), &init_net))
                        break;
-               /* fall through */
+               fallthrough;
        case SIOCGHWTSTAMP:
                if (netif_device_present(real_dev) && ops->ndo_do_ioctl)
                        err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd);
@@ -1269,6 +1269,9 @@ static void macvlan_port_destroy(struct net_device *dev)
 static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
                            struct netlink_ext_ack *extack)
 {
+       struct nlattr *nla, *head;
+       int rem, len;
+
        if (tb[IFLA_ADDRESS]) {
                if (nla_len(tb[IFLA_ADDRESS]) != ETH_ALEN)
                        return -EINVAL;
@@ -1316,6 +1319,20 @@ static int macvlan_validate(struct nlattr *tb[], struct nlattr *data[],
                        return -EADDRNOTAVAIL;
        }
 
+       if (data[IFLA_MACVLAN_MACADDR_DATA]) {
+               head = nla_data(data[IFLA_MACVLAN_MACADDR_DATA]);
+               len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
+
+               nla_for_each_attr(nla, head, len, rem) {
+                       if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
+                           nla_len(nla) != ETH_ALEN)
+                               return -EINVAL;
+
+                       if (!is_valid_ether_addr(nla_data(nla)))
+                               return -EADDRNOTAVAIL;
+               }
+       }
+
        if (data[IFLA_MACVLAN_MACADDR_COUNT])
                return -EINVAL;
 
@@ -1372,10 +1389,6 @@ static int macvlan_changelink_sources(struct macvlan_dev *vlan, u32 mode,
                len = nla_len(data[IFLA_MACVLAN_MACADDR_DATA]);
 
                nla_for_each_attr(nla, head, len, rem) {
-                       if (nla_type(nla) != IFLA_MACVLAN_MACADDR ||
-                           nla_len(nla) != ETH_ALEN)
-                               continue;
-
                        addr = nla_data(nla);
                        ret = macvlan_hash_add_source(vlan, addr);
                        if (ret)
index 4461212..f6a97c8 100644 (file)
@@ -597,7 +597,7 @@ int generic_mii_ioctl(struct mii_if_info *mii_if,
        switch(cmd) {
        case SIOCGMIIPHY:
                mii_data->phy_id = mii_if->phy_id;
-               /* fall through */
+               fallthrough;
 
        case SIOCGMIIREG:
                mii_data->val_out =
index 7971dc4..0e95116 100644 (file)
@@ -193,7 +193,7 @@ new_device_store(struct bus_type *bus, const char *buf, size_t count)
        switch (err) {
        case 1:
                port_count = 1;
-               /* fall through */
+               fallthrough;
        case 2:
                if (id > INT_MAX) {
                        pr_err("Value of \"id\" is too big.\n");
index f32d56a..deea17a 100644 (file)
@@ -760,14 +760,14 @@ static int nsim_fib_event_nb(struct notifier_block *nb, unsigned long event,
        spin_lock_bh(&data->fib_lock);
 
        switch (event) {
-       case FIB_EVENT_RULE_ADD: /* fall through */
+       case FIB_EVENT_RULE_ADD:
        case FIB_EVENT_RULE_DEL:
                err = nsim_fib_rule_event(data, info,
                                          event == FIB_EVENT_RULE_ADD);
                break;
 
-       case FIB_EVENT_ENTRY_REPLACE:  /* fall through */
-       case FIB_EVENT_ENTRY_APPEND:  /* fall through */
+       case FIB_EVENT_ENTRY_REPLACE:
+       case FIB_EVENT_ENTRY_APPEND:
        case FIB_EVENT_ENTRY_DEL:
                err = nsim_fib_event(data, info, event);
                break;
index 7471a8b..307f0ac 100644 (file)
@@ -366,10 +366,10 @@ static int adin_set_edpd(struct phy_device *phydev, u16 tx_interval)
 
        switch (tx_interval) {
        case 1000: /* 1 second */
-               /* fallthrough */
+               fallthrough;
        case ETHTOOL_PHY_EDPD_DFLT_TX_MSECS:
                val |= ADIN1300_NRG_PD_TX_EN;
-               /* fallthrough */
+               fallthrough;
        case ETHTOOL_PHY_EDPD_NO_TX:
                break;
        default:
index 50fb7d1..79e67f2 100644 (file)
@@ -766,13 +766,13 @@ static int decode_evnt(struct dp83640_private *dp83640,
        switch (words) {
        case 3:
                dp83640->edata.sec_hi = phy_txts->sec_hi;
-               /* fall through */
+               fallthrough;
        case 2:
                dp83640->edata.sec_lo = phy_txts->sec_lo;
-               /* fall through */
+               fallthrough;
        case 1:
                dp83640->edata.ns_hi = phy_txts->ns_hi;
-               /* fall through */
+               fallthrough;
        case 0:
                dp83640->edata.ns_lo = phy_txts->ns_lo;
        }
@@ -1409,7 +1409,7 @@ static void dp83640_txtstamp(struct mii_timestamper *mii_ts,
                        kfree_skb(skb);
                        return;
                }
-               /* fall through */
+               fallthrough;
        case HWTSTAMP_TX_ON:
                skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
                skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT;
index f3c0498..cd70326 100644 (file)
@@ -215,9 +215,9 @@ static int dp83867_set_wol(struct phy_device *phydev,
                if (wol->wolopts & WAKE_MAGICSECURE) {
                        phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP1,
                                      (wol->sopass[1] << 8) | wol->sopass[0]);
-                       phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP1,
+                       phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP2,
                                      (wol->sopass[3] << 8) | wol->sopass[2]);
-                       phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP1,
+                       phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RXFSOP3,
                                      (wol->sopass[5] << 8) | wol->sopass[4]);
 
                        val_rxcfg |= DP83867_WOL_SEC_EN;
index 5810315..6b98d74 100644 (file)
@@ -427,18 +427,18 @@ static int dp83869_config_init(struct phy_device *phydev)
                        return ret;
 
                val = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIICTL);
-               val &= ~(DP83869_RGMII_TX_CLK_DELAY_EN |
-                        DP83869_RGMII_RX_CLK_DELAY_EN);
+               val |= (DP83869_RGMII_TX_CLK_DELAY_EN |
+                       DP83869_RGMII_RX_CLK_DELAY_EN);
 
                if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
-                       val |= (DP83869_RGMII_TX_CLK_DELAY_EN |
-                               DP83869_RGMII_RX_CLK_DELAY_EN);
+                       val &= ~(DP83869_RGMII_TX_CLK_DELAY_EN |
+                                DP83869_RGMII_RX_CLK_DELAY_EN);
 
                if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
-                       val |= DP83869_RGMII_TX_CLK_DELAY_EN;
+                       val &= ~DP83869_RGMII_TX_CLK_DELAY_EN;
 
                if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
-                       val |= DP83869_RGMII_RX_CLK_DELAY_EN;
+                       val &= ~DP83869_RGMII_RX_CLK_DELAY_EN;
 
                ret = phy_write_mmd(phydev, DP83869_DEVADDR, DP83869_RGMIICTL,
                                    val);
index c4641b1..18d81f4 100644 (file)
@@ -279,13 +279,13 @@ static struct phy_device *__fixed_phy_register(unsigned int irq,
                                 phy->supported);
                linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT,
                                 phy->supported);
-               /* fall through */
+               fallthrough;
        case SPEED_100:
                linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT,
                                 phy->supported);
                linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT,
                                 phy->supported);
-               /* fall through */
+               fallthrough;
        case SPEED_10:
        default:
                linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT,
index a4fbf3a..6bc7406 100644 (file)
@@ -1738,13 +1738,13 @@ static int __phy_write_mcb_s6g(struct phy_device *phydev, u32 reg, u8 mcb,
        return 0;
 }
 
-/* Trigger a read to the spcified MCB */
+/* Trigger a read to the specified MCB */
 static int phy_update_mcb_s6g(struct phy_device *phydev, u32 reg, u8 mcb)
 {
        return __phy_write_mcb_s6g(phydev, reg, mcb, PHY_MCB_S6G_READ);
 }
 
-/* Trigger a write to the spcified MCB */
+/* Trigger a write to the specified MCB */
 static int phy_commit_mcb_s6g(struct phy_device *phydev, u32 reg, u8 mcb)
 {
        return __phy_write_mcb_s6g(phydev, reg, mcb, PHY_MCB_S6G_WRITE);
index 79b4f35..735a806 100644 (file)
@@ -355,7 +355,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
        switch (cmd) {
        case SIOCGMIIPHY:
                mii_data->phy_id = phydev->mdio.addr;
-               /* fall through */
+               fallthrough;
 
        case SIOCGMIIREG:
                if (mdio_phy_id_is_c45(mii_data->phy_id)) {
@@ -433,7 +433,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
        case SIOCSHWTSTAMP:
                if (phydev->mii_ts && phydev->mii_ts->hwtstamp)
                        return phydev->mii_ts->hwtstamp(phydev->mii_ts, ifr);
-               /* fall through */
+               fallthrough;
 
        default:
                return -EOPNOTSUPP;
index 57d4464..8adfbad 100644 (file)
@@ -1979,7 +1979,7 @@ static int genphy_setup_master_slave(struct phy_device *phydev)
                break;
        case MASTER_SLAVE_CFG_MASTER_FORCE:
                ctl |= CTL1000_AS_MASTER;
-               /* fallthrough */
+               fallthrough;
        case MASTER_SLAVE_CFG_SLAVE_FORCE:
                ctl |= CTL1000_ENABLE_MASTER;
                break;
index 32b4bd6..32f4e8e 100644 (file)
@@ -1905,7 +1905,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
                switch (cmd) {
                case SIOCGMIIPHY:
                        mii->phy_id = pl->phydev->mdio.addr;
-                       /* fall through */
+                       fallthrough;
 
                case SIOCGMIIREG:
                        ret = phylink_phy_read(pl, mii->phy_id, mii->reg_num);
@@ -1928,7 +1928,7 @@ int phylink_mii_ioctl(struct phylink *pl, struct ifreq *ifr, int cmd)
                switch (cmd) {
                case SIOCGMIIPHY:
                        mii->phy_id = 0;
-                       /* fall through */
+                       fallthrough;
 
                case SIOCGMIIREG:
                        ret = phylink_mii_read(pl, mii->phy_id, mii->reg_num);
index 6900c68..58014fe 100644 (file)
@@ -149,7 +149,7 @@ int sfp_parse_port(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
                        port = PORT_TP;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case SFF8024_CONNECTOR_SG: /* guess */
        case SFF8024_CONNECTOR_HSSDC_II:
        case SFF8024_CONNECTOR_NOSEPARATE:
@@ -301,7 +301,7 @@ void sfp_parse_support(struct sfp_bus *bus, const struct sfp_eeprom_id *id,
                break;
        case SFF8024_ECC_100GBASE_CR4:
                phylink_set(modes, 100000baseCR4_Full);
-               /* fallthrough */
+               fallthrough;
        case SFF8024_ECC_25GBASE_CR_S:
        case SFF8024_ECC_25GBASE_CR_N:
                phylink_set(modes, 25000baseCR_Full);
index c24b0e8..cf83314 100644 (file)
@@ -552,7 +552,7 @@ static umode_t sfp_hwmon_is_visible(const void *data,
                case hwmon_temp_crit:
                        if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
                                return 0;
-                       /* fall through */
+                       fallthrough;
                case hwmon_temp_input:
                case hwmon_temp_label:
                        return 0444;
@@ -571,7 +571,7 @@ static umode_t sfp_hwmon_is_visible(const void *data,
                case hwmon_in_crit:
                        if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
                                return 0;
-                       /* fall through */
+                       fallthrough;
                case hwmon_in_input:
                case hwmon_in_label:
                        return 0444;
@@ -590,7 +590,7 @@ static umode_t sfp_hwmon_is_visible(const void *data,
                case hwmon_curr_crit:
                        if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
                                return 0;
-                       /* fall through */
+                       fallthrough;
                case hwmon_curr_input:
                case hwmon_curr_label:
                        return 0444;
@@ -618,7 +618,7 @@ static umode_t sfp_hwmon_is_visible(const void *data,
                case hwmon_power_crit:
                        if (!(sfp->id.ext.enhopts & SFP_ENHOPTS_ALARMWARN))
                                return 0;
-                       /* fall through */
+                       fallthrough;
                case hwmon_power_input:
                case hwmon_power_label:
                        return 0444;
@@ -1872,7 +1872,7 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
                        dev_warn(sfp->dev, "hwmon probe failed: %d\n", err);
 
                sfp_sm_mod_next(sfp, SFP_MOD_WAITDEV, 0);
-               /* fall through */
+               fallthrough;
        case SFP_MOD_WAITDEV:
                /* Ensure that the device is attached before proceeding */
                if (sfp->sm_dev_state < SFP_DEV_DOWN)
@@ -1890,7 +1890,7 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
                        goto insert;
 
                sfp_sm_mod_next(sfp, SFP_MOD_HPOWER, 0);
-               /* fall through */
+               fallthrough;
        case SFP_MOD_HPOWER:
                /* Enable high power mode */
                err = sfp_sm_mod_hpower(sfp, true);
index d82016d..4406b35 100644 (file)
@@ -498,7 +498,7 @@ plip_receive(unsigned short nibble_timeout, struct net_device *dev,
                *data_p = (c0 >> 3) & 0x0f;
                write_data (dev, 0x10); /* send ACK */
                *ns_p = PLIP_NB_1;
-               /* fall through */
+               fallthrough;
 
        case PLIP_NB_1:
                cx = nibble_timeout;
@@ -594,7 +594,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
                        printk(KERN_DEBUG "%s: receive start\n", dev->name);
                rcv->state = PLIP_PK_LENGTH_LSB;
                rcv->nibble = PLIP_NB_BEGIN;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_LENGTH_LSB:
                if (snd->state != PLIP_PK_DONE) {
@@ -615,7 +615,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
                                return TIMEOUT;
                }
                rcv->state = PLIP_PK_LENGTH_MSB;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_LENGTH_MSB:
                if (plip_receive(nibble_timeout, dev,
@@ -638,7 +638,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
                rcv->state = PLIP_PK_DATA;
                rcv->byte = 0;
                rcv->checksum = 0;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_DATA:
                lbuf = rcv->skb->data;
@@ -651,7 +651,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
                        rcv->checksum += lbuf[--rcv->byte];
                } while (rcv->byte);
                rcv->state = PLIP_PK_CHECKSUM;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_CHECKSUM:
                if (plip_receive(nibble_timeout, dev,
@@ -664,7 +664,7 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,
                        return ERROR;
                }
                rcv->state = PLIP_PK_DONE;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_DONE:
                /* Inform the upper layer for the arrival of a packet. */
@@ -710,7 +710,7 @@ plip_send(unsigned short nibble_timeout, struct net_device *dev,
        case PLIP_NB_BEGIN:
                write_data (dev, data & 0x0f);
                *ns_p = PLIP_NB_1;
-               /* fall through */
+               fallthrough;
 
        case PLIP_NB_1:
                write_data (dev, 0x10 | (data & 0x0f));
@@ -725,7 +725,7 @@ plip_send(unsigned short nibble_timeout, struct net_device *dev,
                }
                write_data (dev, 0x10 | (data >> 4));
                *ns_p = PLIP_NB_2;
-               /* fall through */
+               fallthrough;
 
        case PLIP_NB_2:
                write_data (dev, (data >> 4));
@@ -814,7 +814,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,
                              &snd->nibble, snd->length.b.lsb))
                        return TIMEOUT;
                snd->state = PLIP_PK_LENGTH_MSB;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_LENGTH_MSB:
                if (plip_send(nibble_timeout, dev,
@@ -823,7 +823,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,
                snd->state = PLIP_PK_DATA;
                snd->byte = 0;
                snd->checksum = 0;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_DATA:
                do {
@@ -835,7 +835,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,
                        snd->checksum += lbuf[--snd->byte];
                } while (snd->byte);
                snd->state = PLIP_PK_CHECKSUM;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_CHECKSUM:
                if (plip_send(nibble_timeout, dev,
@@ -846,7 +846,7 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,
                dev_kfree_skb(snd->skb);
                dev->stats.tx_packets++;
                snd->state = PLIP_PK_DONE;
-               /* fall through */
+               fallthrough;
 
        case PLIP_PK_DONE:
                /* Close the connection */
@@ -935,7 +935,7 @@ plip_interrupt(void *dev_id)
        switch (nl->connection) {
        case PLIP_CN_CLOSING:
                netif_wake_queue (dev);
-               /* fall through */
+               fallthrough;
        case PLIP_CN_NONE:
        case PLIP_CN_SEND:
                rcv->state = PLIP_PK_TRIGGER;
index 3c11a77..7959b5c 100644 (file)
@@ -1590,10 +1590,10 @@ static int tun_xdp_act(struct tun_struct *tun, struct bpf_prog *xdp_prog,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(tun->dev, xdp_prog, act);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
                this_cpu_inc(tun->pcpu_stats->rx_dropped);
                break;
@@ -2417,7 +2417,7 @@ static int tun_xdp_one(struct tun_struct *tun,
                switch (err) {
                case XDP_REDIRECT:
                        *flush = true;
-                       /* fall through */
+                       fallthrough;
                case XDP_TX:
                        return 0;
                case XDP_PASS:
index a7fbc3c..c7bcfca 100644 (file)
@@ -252,6 +252,7 @@ config USB_NET_CDC_EEM
 config USB_NET_CDC_NCM
        tristate "CDC NCM support"
        depends on USB_USBNET
+       select USB_NET_CDCETHER
        default y
        help
          This driver provides support for CDC NCM (Network Control Model
index 7e44110..0717c18 100644 (file)
@@ -333,13 +333,13 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
                switch (speed) {
                case SPEED_5000:
                        aqc111_data->phy_cfg |= AQ_ADV_5G;
-                       /* fall-through */
+                       fallthrough;
                case SPEED_2500:
                        aqc111_data->phy_cfg |= AQ_ADV_2G5;
-                       /* fall-through */
+                       fallthrough;
                case SPEED_1000:
                        aqc111_data->phy_cfg |= AQ_ADV_1G;
-                       /* fall-through */
+                       fallthrough;
                case SPEED_100:
                        aqc111_data->phy_cfg |= AQ_ADV_100M;
                        /* fall-through */
index e39f41e..7bc6e8f 100644 (file)
@@ -296,7 +296,7 @@ int asix_read_phy_addr(struct usbnet *dev, int internal)
 
        netdev_dbg(dev->net, "asix_get_phy_addr()\n");
 
-       if (ret < 0) {
+       if (ret < 2) {
                netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret);
                goto out;
        }
index d387bc7..97ba670 100644 (file)
@@ -858,7 +858,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
                default:
                        dev_warn(&intf->dev,
                                 "Couldn't detect memory size, assuming 32k\n");
-                       /* fall through */
+                       fallthrough;
                case 0x87654321:
                        catc_set_reg(catc, TxBufCount, 4);
                        catc_set_reg(catc, RxBufCount, 16);
index 9bdbd7b..dba847f 100644 (file)
@@ -97,7 +97,7 @@ static void tx_complete(struct urb *req)
        case -ECONNRESET:
        case -ESHUTDOWN:
                dev->stats.tx_aborted_errors++;
-               /* fall through */
+               fallthrough;
        default:
                dev->stats.tx_errors++;
                dev_dbg(&dev->dev, "TX error (%d)\n", status);
index b91f92e..915ac75 100644 (file)
@@ -625,6 +625,10 @@ static const struct usb_device_id products[] = {
         USB_DEVICE(0x0a46, 0x1269),    /* DM9621A USB to Fast Ethernet Adapter */
         .driver_info = (unsigned long)&dm9601_info,
        },
+       {
+        USB_DEVICE(0x0586, 0x3427),    /* ZyXEL Keenetic Plus DSL xDSL modem */
+        .driver_info = (unsigned long)&dm9601_info,
+       },
        {},                     // END
 };
 
index 442507f..65b315b 100644 (file)
@@ -3192,7 +3192,7 @@ static void rx_complete(struct urb *urb)
        case -EPIPE:
                dev->net->stats.rx_errors++;
                lan78xx_defer_kevent(dev, EVENT_RX_HALT);
-               /* FALLTHROUGH */
+               fallthrough;
        case -ECONNRESET:                               /* async unlink */
        case -ESHUTDOWN:                                /* hardware gone */
                netif_dbg(dev, ifdown, dev->net,
@@ -3213,7 +3213,7 @@ static void rx_complete(struct urb *urb)
        /* data overrun ... flush fifo? */
        case -EOVERFLOW:
                dev->net->stats.rx_over_errors++;
-               /* FALLTHROUGH */
+               fallthrough;
 
        default:
                state = rx_cleanup;
index 0ef7e1f..e92cb51 100644 (file)
@@ -629,7 +629,7 @@ static void write_bulk_callback(struct urb *urb)
                return;
        default:
                netif_info(pegasus, tx_err, net, "TX status %d\n", status);
-               /* FALL THROUGH */
+               fallthrough;
        case 0:
                break;
        }
@@ -1009,7 +1009,7 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
        switch (cmd) {
        case SIOCDEVPRIVATE:
                data[0] = pegasus->phy;
-               /* fall through */
+               fallthrough;
        case SIOCDEVPRIVATE + 1:
                read_mii_word(pegasus, data[0], data[1] & 0x1f, &data[3]);
                res = 0;
index 2b02fef..b177048 100644 (file)
@@ -1682,7 +1682,7 @@ static void intr_callback(struct urb *urb)
        case -ECONNRESET:       /* unlink */
        case -ESHUTDOWN:
                netif_device_detach(tp->netdev);
-               /* fall through */
+               fallthrough;
        case -ENOENT:
        case -EPROTO:
                netif_info(tp, intr, tp->netdev,
@@ -3251,7 +3251,7 @@ static void r8153b_ups_en(struct r8152 *tp, bool enable)
                        r8152_mdio_write(tp, MII_BMCR, data);
 
                        data = r8153_phy_status(tp, PHY_STAT_LAN_ON);
-                       /* fall through */
+                       fallthrough;
 
                default:
                        if (data != PHY_STAT_LAN_ON)
@@ -4849,7 +4849,7 @@ static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u32 speed, u8 duplex,
                                tp->ups_info.speed_duplex = NWAY_1000M_FULL;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        ret = -EINVAL;
                        goto out;
index e7c630d..733f120 100644 (file)
@@ -843,7 +843,7 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
        switch (cmd) {
        case SIOCDEVPRIVATE:
                data[0] = dev->phy;
-               /* fall through */
+               fallthrough;
        case SIOCDEVPRIVATE + 1:
                read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]);
                break;
index e45935a..2b2a841 100644 (file)
@@ -110,7 +110,7 @@ int usbnet_get_endpoints(struct usbnet *dev, struct usb_interface *intf)
                                if (!usb_endpoint_dir_in(&e->desc))
                                        continue;
                                intr = 1;
-                               /* FALLTHROUGH */
+                               fallthrough;
                        case USB_ENDPOINT_XFER_BULK:
                                break;
                        default:
@@ -628,7 +628,7 @@ block:
        /* data overrun ... flush fifo? */
        case -EOVERFLOW:
                dev->net->stats.rx_over_errors++;
-               // FALLTHROUGH
+               fallthrough;
 
        default:
                state = rx_cleanup;
@@ -1530,7 +1530,7 @@ static void usbnet_bh (struct timer_list *t)
                        continue;
                case tx_done:
                        kfree(entry->urb->sg);
-                       /* fall through */
+                       fallthrough;
                case rx_cleanup:
                        usb_free_urb (entry->urb);
                        dev_kfree_skb (skb);
index e56cd56..a475f48 100644 (file)
@@ -610,10 +610,10 @@ static struct sk_buff *veth_xdp_rcv_one(struct veth_rq *rq,
                        goto xdp_xmit;
                default:
                        bpf_warn_invalid_xdp_action(act);
-                       /* fall through */
+                       fallthrough;
                case XDP_ABORTED:
                        trace_xdp_exception(rq->dev, xdp_prog, act);
-                       /* fall through */
+                       fallthrough;
                case XDP_DROP:
                        stats->xdp_drops++;
                        goto err_xdp;
@@ -745,10 +745,10 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq,
                goto xdp_xmit;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(rq->dev, xdp_prog, act);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
                stats->xdp_drops++;
                goto xdp_drop;
index 0ada48e..263b005 100644 (file)
@@ -724,7 +724,7 @@ static struct sk_buff *receive_small(struct net_device *dev,
                        goto xdp_xmit;
                default:
                        bpf_warn_invalid_xdp_action(act);
-                       /* fall through */
+                       fallthrough;
                case XDP_ABORTED:
                        trace_xdp_exception(vi->dev, xdp_prog, act);
                case XDP_DROP:
@@ -922,10 +922,10 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
                        goto xdp_xmit;
                default:
                        bpf_warn_invalid_xdp_action(act);
-                       /* fall through */
+                       fallthrough;
                case XDP_ABORTED:
                        trace_xdp_exception(vi->dev, xdp_prog, act);
-                       /* fall through */
+                       fallthrough;
                case XDP_DROP:
                        if (unlikely(xdp_page != page))
                                __free_pages(xdp_page, 0);
index def27af..1014693 100644 (file)
@@ -743,7 +743,7 @@ vmxnet3_get_rss_hash_opts(struct vmxnet3_adapter *adapter,
        case ESP_V4_FLOW:
                if (rss_fields & VMXNET3_RSS_FIELDS_ESPIP4)
                        info->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3;
-                       /* fallthrough */
+               fallthrough;
        case SCTP_V4_FLOW:
        case IPV4_FLOW:
                info->data |= RXH_IP_SRC | RXH_IP_DST;
index 7bcee41..3ca4daf 100644 (file)
@@ -295,14 +295,13 @@ static int dlci_close(struct net_device *dev)
 {
        struct dlci_local       *dlp;
        struct frad_local       *flp;
-       int                     err;
 
        netif_stop_queue(dev);
 
        dlp = netdev_priv(dev);
 
        flp = netdev_priv(dlp->slave);
-       err = (*flp->deactivate)(dlp->slave, dev);
+       (*flp->deactivate)(dlp->slave, dev);
 
        return 0;
 }
index dfc1677..9b00708 100644 (file)
@@ -229,7 +229,8 @@ static void hdlc_setup_dev(struct net_device *dev)
        dev->min_mtu             = 68;
        dev->max_mtu             = HDLC_MAX_MTU;
        dev->type                = ARPHRD_RAWHDLC;
-       dev->hard_header_len     = 16;
+       dev->hard_header_len     = 0;
+       dev->needed_headroom     = 0;
        dev->addr_len            = 0;
        dev->header_ops          = &hdlc_null_ops;
 }
index d8cba36..4441306 100644 (file)
@@ -370,6 +370,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
                memcpy(&state(hdlc)->settings, &new_settings, size);
                spin_lock_init(&state(hdlc)->lock);
                dev->header_ops = &cisco_header_ops;
+               dev->hard_header_len = sizeof(struct hdlc_header);
                dev->type = ARPHRD_CISCO;
                call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
                netif_dormant_on(dev);
index f70336b..f52b9fe 100644 (file)
@@ -107,8 +107,14 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        int result;
 
+       /* There should be a pseudo header of 1 byte added by upper layers.
+        * Check to make sure it is there before reading it.
+        */
+       if (skb->len < 1) {
+               kfree_skb(skb);
+               return NETDEV_TX_OK;
+       }
 
-       /* X.25 to LAPB */
        switch (skb->data[0]) {
        case X25_IFACE_DATA:    /* Data to be transmitted */
                skb_pull(skb, 1);
@@ -294,6 +300,15 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
                        return result;
 
                memcpy(&state(hdlc)->settings, &new_settings, size);
+
+               /* There's no header_ops so hard_header_len should be 0. */
+               dev->hard_header_len = 0;
+               /* When transmitting data:
+                * first we'll remove a pseudo header of 1 byte,
+                * then we'll prepend an LAPB header of at most 3 bytes.
+                */
+               dev->needed_headroom = 3 - 1;
+
                dev->type = ARPHRD_X25;
                call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, dev);
                netif_dormant_off(dev);
index 1ea15f2..732a6c1 100644 (file)
@@ -173,7 +173,7 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
        case X25_IFACE_DISCONNECT:
                if ((err = lapb_disconnect_request(dev)) != LAPB_OK)
                        pr_err("lapb_disconnect_request err: %d\n", err);
-               /* Fall thru */
+               fallthrough;
        default:
                goto drop;
        }
@@ -210,6 +210,8 @@ static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb)
 
        skb->dev = dev = lapbeth->ethdev;
 
+       skb_reset_network_header(skb);
+
        dev_hard_header(skb, dev, ETH_P_DEC, bcast_addr, NULL, 0);
 
        dev_queue_xmit(skb);
@@ -340,6 +342,7 @@ static int lapbeth_new_device(struct net_device *dev)
         */
        ndev->needed_headroom = -1 + 3 + 2 + dev->hard_header_len
                                           + dev->needed_headroom;
+       ndev->needed_tailroom = dev->needed_tailroom;
 
        lapbeth = netdev_priv(ndev);
        lapbeth->axdev = ndev;
index 77ccf36..bc2c1c7 100644 (file)
@@ -413,7 +413,7 @@ static void sdla_errors(struct net_device *dev, int cmd, int dlci, int ret, int
                case SDLA_RET_NO_BUFS:
                        if (cmd == SDLA_INFORMATION_WRITE)
                                break;
-                       /* Else, fall through */
+                       fallthrough;
 
                default: 
                        netdev_dbg(dev, "Cmd 0x%02X generated return code 0x%02X\n",
index de79844..7ee9805 100644 (file)
@@ -330,7 +330,7 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
                if (err != LAPB_OK)
                        netdev_err(dev, "lapb_disconnect_request error: %d\n",
                                   err);
-               /* fall through */
+               fallthrough;
        default:
                kfree_skb(skb);
                return NETDEV_TX_OK;
index 4fe7c7e..9afed3b 100644 (file)
@@ -352,7 +352,7 @@ void i2400m_report_tlv_system_state(struct i2400m *i2400m,
 
        case I2400M_SS_IDLE:
                d_printf(1, dev, "entering BS-negotiated idle mode\n");
-               /* Fall through */
+               fallthrough;
        case I2400M_SS_DISCONNECTING:
        case I2400M_SS_DATA_PATH_CONNECTED:
                wimax_state_change(wimax_dev, WIMAX_ST_CONNECTED);
index 1f7709d..27ab233 100644 (file)
@@ -135,7 +135,7 @@ retry:
                        msleep(10);     /* give the device some time */
                        goto retry;
                }
-               /* fall through */
+               fallthrough;
        case -EINVAL:                   /* while removing driver */
        case -ENODEV:                   /* dev disconnect ... */
        case -ENOENT:                   /* just ignore it */
index 3a0e722..3ba9d70 100644 (file)
@@ -136,7 +136,7 @@ retry:
                        msleep(10);     /* give the device some time */
                        goto retry;
                }
-               /* fall through */
+               fallthrough;
        case -EINVAL:                   /* while removing driver */
        case -ENODEV:                   /* dev disconnect ... */
        case -ENOENT:                   /* just ignore it */
index 9659f9e..b684e97 100644 (file)
@@ -195,7 +195,7 @@ retry:
                        msleep(10);     /* give the device some time */
                        goto retry;
                }
-               /* fall through */
+               fallthrough;
        case -EINVAL:                   /* while removing driver */
        case -ENODEV:                   /* dev disconnect ... */
        case -ENOENT:                   /* just ignore it */
index 6b7532f..ff96f22 100644 (file)
@@ -393,7 +393,7 @@ void xenvif_dump_hash_info(struct xenvif *vif, struct seq_file *m)
 
        case XEN_NETIF_CTRL_HASH_ALGORITHM_NONE:
                seq_puts(m, "Hash Algorithm: NONE\n");
-               /* FALLTHRU */
+               fallthrough;
        default:
                return;
        }
index 7e62a6e..f1c1624 100644 (file)
@@ -448,7 +448,7 @@ static void frontend_changed(struct xenbus_device *dev,
                set_backend_state(be, XenbusStateClosed);
                if (xenbus_dev_is_online(dev))
                        break;
-               /* fall through - if not online */
+               fallthrough;    /* if not online */
        case XenbusStateUnknown:
                set_backend_state(be, XenbusStateClosed);
                device_unregister(&dev->dev);
index 458be68..3e9895b 100644 (file)
@@ -2341,7 +2341,7 @@ static void netback_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* Fall through - Missed the backend's CLOSING state. */
+               fallthrough;    /* Missed the backend's CLOSING state */
        case XenbusStateClosing:
                xenbus_frontend_closed(dev);
                break;
index 346e084..f7464bd 100644 (file)
@@ -2321,7 +2321,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
 
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                /* jumbo frame ? */
                if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
@@ -2448,7 +2448,7 @@ static void pn533_wq_mi_recv(struct work_struct *work)
 
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                skb_put_u8(skb, 1); /*TG*/
 
index 0b9ca6d..8874d60 100644 (file)
@@ -611,7 +611,7 @@ static void st21nfca_im_recv_dep_res_cb(void *context, struct sk_buff *skb,
                switch (ST21NFCA_NFC_DEP_PFB_TYPE(dep_res->pfb)) {
                case ST21NFCA_NFC_DEP_PFB_ACK_NACK_PDU:
                        pr_err("Received a ACK/NACK PDU\n");
-                       /* fall through */
+                       fallthrough;
                case ST21NFCA_NFC_DEP_PFB_I_PDU:
                        info->dep_info.curr_nfc_dep_pni =
                            ST21NFCA_NFC_DEP_PFB_PNI(dep_res->pfb + 1);
index 9642971..4578547 100644 (file)
@@ -966,7 +966,7 @@ static int st95hf_in_send_cmd(struct nfc_digital_dev *ddev,
        rc = down_killable(&stcontext->exchange_lock);
        if (rc) {
                WARN(1, "Semaphore is not found up in st95hf_in_send_cmd\n");
-               return rc;
+               goto free_skb_resp;
        }
 
        rc = st95hf_spi_send(&stcontext->spicontext, skb->data,
index e46adaa..3bd97c7 100644 (file)
@@ -1153,7 +1153,7 @@ static int trf7970a_switch_rf(struct nfc_digital_dev *ddev, bool on)
                        dev_err(trf->dev, "%s - Invalid request: %d %d\n",
                                __func__, trf->state, on);
                        ret = -EINVAL;
-                       /* FALLTHROUGH */
+                       fallthrough;
                case TRF7970A_ST_IDLE:
                case TRF7970A_ST_IDLE_RX_BLOCKED:
                case TRF7970A_ST_WAIT_FOR_RX_DATA:
@@ -1960,7 +1960,7 @@ static void trf7970a_shutdown(struct trf7970a *trf)
        case TRF7970A_ST_WAIT_TO_ISSUE_EOF:
        case TRF7970A_ST_LISTENING:
                trf7970a_send_err_upstream(trf, -ECANCELED);
-               /* FALLTHROUGH */
+               fallthrough;
        case TRF7970A_ST_IDLE:
        case TRF7970A_ST_IDLE_RX_BLOCKED:
                trf7970a_switch_rf_off(trf);
index e6d1f5b..4a02561 100644 (file)
@@ -1483,7 +1483,7 @@ static void ntb_rx_copy_callback(void *data,
                case DMA_TRANS_READ_FAILED:
                case DMA_TRANS_WRITE_FAILED:
                        entry->errors++;
-                       /* fall through */
+                       fallthrough;
                case DMA_TRANS_ABORTED:
                {
                        struct ntb_transport_qp *qp = entry->qp;
@@ -1739,7 +1739,7 @@ static void ntb_tx_copy_callback(void *data,
                case DMA_TRANS_READ_FAILED:
                case DMA_TRANS_WRITE_FAILED:
                        entry->errors++;
-                       /* fall through */
+                       fallthrough;
                case DMA_TRANS_ABORTED:
                {
                        void __iomem *offset =
index 61374de..b59032e 100644 (file)
@@ -529,6 +529,7 @@ static DEVICE_ATTR_ADMIN_RW(activate);
 static struct attribute *nvdimm_firmware_attributes[] = {
        &dev_attr_activate.attr,
        &dev_attr_result.attr,
+       NULL,
 };
 
 static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute *a, int n)
index 88cff30..f3a61a2 100644 (file)
@@ -241,17 +241,6 @@ static blk_status_t nvme_error_status(u16 status)
        }
 }
 
-static inline bool nvme_req_needs_retry(struct request *req)
-{
-       if (blk_noretry_request(req))
-               return false;
-       if (nvme_req(req)->status & NVME_SC_DNR)
-               return false;
-       if (nvme_req(req)->retries >= nvme_max_retries)
-               return false;
-       return true;
-}
-
 static void nvme_retry_req(struct request *req)
 {
        struct nvme_ns *ns = req->q->queuedata;
@@ -268,34 +257,67 @@ static void nvme_retry_req(struct request *req)
        blk_mq_delay_kick_requeue_list(req->q, delay);
 }
 
-void nvme_complete_rq(struct request *req)
+enum nvme_disposition {
+       COMPLETE,
+       RETRY,
+       FAILOVER,
+};
+
+static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
 {
-       blk_status_t status = nvme_error_status(nvme_req(req)->status);
+       if (likely(nvme_req(req)->status == 0))
+               return COMPLETE;
 
-       trace_nvme_complete_rq(req);
+       if (blk_noretry_request(req) ||
+           (nvme_req(req)->status & NVME_SC_DNR) ||
+           nvme_req(req)->retries >= nvme_max_retries)
+               return COMPLETE;
 
-       nvme_cleanup_cmd(req);
+       if (req->cmd_flags & REQ_NVME_MPATH) {
+               if (nvme_is_path_error(nvme_req(req)->status) ||
+                   blk_queue_dying(req->q))
+                       return FAILOVER;
+       } else {
+               if (blk_queue_dying(req->q))
+                       return COMPLETE;
+       }
 
-       if (nvme_req(req)->ctrl->kas)
-               nvme_req(req)->ctrl->comp_seen = true;
+       return RETRY;
+}
 
-       if (unlikely(status != BLK_STS_OK && nvme_req_needs_retry(req))) {
-               if ((req->cmd_flags & REQ_NVME_MPATH) && nvme_failover_req(req))
-                       return;
+static inline void nvme_end_req(struct request *req)
+{
+       blk_status_t status = nvme_error_status(nvme_req(req)->status);
 
-               if (!blk_queue_dying(req->q)) {
-                       nvme_retry_req(req);
-                       return;
-               }
-       } else if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
-                  req_op(req) == REQ_OP_ZONE_APPEND) {
+       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+           req_op(req) == REQ_OP_ZONE_APPEND)
                req->__sector = nvme_lba_to_sect(req->q->queuedata,
                        le64_to_cpu(nvme_req(req)->result.u64));
-       }
 
        nvme_trace_bio_complete(req, status);
        blk_mq_end_request(req, status);
 }
+
+void nvme_complete_rq(struct request *req)
+{
+       trace_nvme_complete_rq(req);
+       nvme_cleanup_cmd(req);
+
+       if (nvme_req(req)->ctrl->kas)
+               nvme_req(req)->ctrl->comp_seen = true;
+
+       switch (nvme_decide_disposition(req)) {
+       case COMPLETE:
+               nvme_end_req(req);
+               return;
+       case RETRY:
+               nvme_retry_req(req);
+               return;
+       case FAILOVER:
+               nvme_failover_req(req);
+               return;
+       }
+}
 EXPORT_SYMBOL_GPL(nvme_complete_rq);
 
 bool nvme_cancel_request(struct request *req, void *data, bool reserved)
@@ -330,7 +352,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                case NVME_CTRL_RESETTING:
                case NVME_CTRL_CONNECTING:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -340,7 +362,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                case NVME_CTRL_NEW:
                case NVME_CTRL_LIVE:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -350,7 +372,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                case NVME_CTRL_NEW:
                case NVME_CTRL_RESETTING:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -361,7 +383,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                case NVME_CTRL_RESETTING:
                case NVME_CTRL_CONNECTING:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -371,7 +393,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                case NVME_CTRL_DELETING:
                case NVME_CTRL_DEAD:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -380,7 +402,7 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
                switch (old_state) {
                case NVME_CTRL_DELETING:
                        changed = true;
-                       /* FALLTHRU */
+                       fallthrough;
                default:
                        break;
                }
@@ -2004,13 +2026,49 @@ static void nvme_update_disk_info(struct gendisk *disk,
        blk_mq_unfreeze_queue(disk->queue);
 }
 
+static inline bool nvme_first_scan(struct gendisk *disk)
+{
+       /* nvme_alloc_ns() scans the disk prior to adding it */
+       return !(disk->flags & GENHD_FL_UP);
+}
+
+static void nvme_set_chunk_sectors(struct nvme_ns *ns, struct nvme_id_ns *id)
+{
+       struct nvme_ctrl *ctrl = ns->ctrl;
+       u32 iob;
+
+       if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) &&
+           is_power_of_2(ctrl->max_hw_sectors))
+               iob = ctrl->max_hw_sectors;
+       else
+               iob = nvme_lba_to_sect(ns, le16_to_cpu(id->noiob));
+
+       if (!iob)
+               return;
+
+       if (!is_power_of_2(iob)) {
+               if (nvme_first_scan(ns->disk))
+                       pr_warn("%s: ignoring unaligned IO boundary:%u\n",
+                               ns->disk->disk_name, iob);
+               return;
+       }
+
+       if (blk_queue_is_zoned(ns->disk->queue)) {
+               if (nvme_first_scan(ns->disk))
+                       pr_warn("%s: ignoring zoned namespace IO boundary\n",
+                               ns->disk->disk_name);
+               return;
+       }
+
+       blk_queue_chunk_sectors(ns->queue, iob);
+}
+
 static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
 {
        unsigned lbaf = id->flbas & NVME_NS_FLBAS_LBA_MASK;
        struct nvme_ns *ns = disk->private_data;
        struct nvme_ctrl *ctrl = ns->ctrl;
        int ret;
-       u32 iob;
 
        /*
         * If identify namespace failed, use default 512 byte block size so
@@ -2038,12 +2096,6 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
                return -ENODEV;
        }
 
-       if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) &&
-           is_power_of_2(ctrl->max_hw_sectors))
-               iob = ctrl->max_hw_sectors;
-       else
-               iob = nvme_lba_to_sect(ns, le16_to_cpu(id->noiob));
-
        ns->features = 0;
        ns->ms = le16_to_cpu(id->lbaf[lbaf].ms);
        /* the PI implementation requires metadata equal t10 pi tuple size */
@@ -2075,8 +2127,7 @@ static int __nvme_revalidate_disk(struct gendisk *disk, struct nvme_id_ns *id)
                }
        }
 
-       if (iob)
-               blk_queue_chunk_sectors(ns->queue, rounddown_pow_of_two(iob));
+       nvme_set_chunk_sectors(ns, id);
        nvme_update_disk_info(disk, ns, id);
 #ifdef CONFIG_NVME_MULTIPATH
        if (ns->head->disk) {
@@ -2965,14 +3016,14 @@ static struct nvme_cel *nvme_find_cel(struct nvme_ctrl *ctrl, u8 csi)
 {
        struct nvme_cel *cel, *ret = NULL;
 
-       spin_lock(&ctrl->lock);
+       spin_lock_irq(&ctrl->lock);
        list_for_each_entry(cel, &ctrl->cels, entry) {
                if (cel->csi == csi) {
                        ret = cel;
                        break;
                }
        }
-       spin_unlock(&ctrl->lock);
+       spin_unlock_irq(&ctrl->lock);
 
        return ret;
 }
@@ -2999,9 +3050,9 @@ static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi,
 
        cel->csi = csi;
 
-       spin_lock(&ctrl->lock);
+       spin_lock_irq(&ctrl->lock);
        list_add_tail(&cel->entry, &ctrl->cels);
-       spin_unlock(&ctrl->lock);
+       spin_unlock_irq(&ctrl->lock);
 out:
        *log = &cel->log;
        return 0;
@@ -3474,10 +3525,6 @@ static ssize_t nvme_sysfs_delete(struct device *dev,
 {
        struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
 
-       /* Can't delete non-created controllers */
-       if (!ctrl->created)
-               return -EBUSY;
-
        if (device_remove_file_self(dev, attr))
                nvme_delete_ctrl_sync(ctrl);
        return count;
@@ -3654,6 +3701,10 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
                return 0;
        if (a == &dev_attr_hostid.attr && !ctrl->opts)
                return 0;
+       if (a == &dev_attr_ctrl_loss_tmo.attr && !ctrl->opts)
+               return 0;
+       if (a == &dev_attr_reconnect_delay.attr && !ctrl->opts)
+               return 0;
 
        return a->mode;
 }
@@ -4348,7 +4399,6 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl)
                nvme_queue_scan(ctrl);
                nvme_start_queues(ctrl);
        }
-       ctrl->created = true;
 }
 EXPORT_SYMBOL_GPL(nvme_start_ctrl);
 
@@ -4368,7 +4418,7 @@ static void nvme_free_ctrl(struct device *dev)
        struct nvme_subsystem *subsys = ctrl->subsys;
        struct nvme_cel *cel, *next;
 
-       if (subsys && ctrl->instance != subsys->instance)
+       if (!subsys || ctrl->instance != subsys->instance)
                ida_simple_remove(&nvme_instance_ida, ctrl->instance);
 
        list_for_each_entry_safe(cel, next, &ctrl->cels, entry) {
@@ -4512,7 +4562,7 @@ void nvme_unfreeze(struct nvme_ctrl *ctrl)
 }
 EXPORT_SYMBOL_GPL(nvme_unfreeze);
 
-void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
+int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
 {
        struct nvme_ns *ns;
 
@@ -4523,6 +4573,7 @@ void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
                        break;
        }
        up_read(&ctrl->namespaces_rwsem);
+       return timeout;
 }
 EXPORT_SYMBOL_GPL(nvme_wait_freeze_timeout);
 
index 4ec4829..8575724 100644 (file)
@@ -565,10 +565,14 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
        struct nvme_request *req = nvme_req(rq);
 
        /*
-        * If we are in some state of setup or teardown only allow
-        * internally generated commands.
+        * currently we have a problem sending passthru commands
+        * on the admin_q if the controller is not LIVE because we can't
+        * make sure that they are going out after the admin connect,
+        * controller enable and/or other commands in the initialization
+        * sequence. until the controller will be LIVE, fail with
+        * BLK_STS_RESOURCE so that they will be rescheduled.
         */
-       if (!blk_rq_is_passthrough(rq) || (req->flags & NVME_REQ_USERCMD))
+       if (rq->q == ctrl->admin_q && (req->flags & NVME_REQ_USERCMD))
                return false;
 
        /*
@@ -576,9 +580,8 @@ bool __nvmf_check_ready(struct nvme_ctrl *ctrl, struct request *rq,
         * which is require to set the queue live in the appropinquate states.
         */
        switch (ctrl->state) {
-       case NVME_CTRL_NEW:
        case NVME_CTRL_CONNECTING:
-               if (nvme_is_fabrics(req->cmd) &&
+               if (blk_rq_is_passthrough(rq) && nvme_is_fabrics(req->cmd) &&
                    req->cmd->fabrics.fctype == nvme_fabrics_type_connect)
                        return true;
                break;
index eae43bb..e8ef42b 100644 (file)
@@ -2035,7 +2035,7 @@ done:
        }
 
        __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate);
-       if (!nvme_end_request(rq, status, result))
+       if (!nvme_try_complete_req(rq, status, result))
                nvme_fc_complete_rq(rq);
 
 check_error:
@@ -2078,7 +2078,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
        if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.cmddma)) {
                dev_err(ctrl->dev,
                        "FCP Op failed - cmdiu dma mapping failed.\n");
-               ret = EFAULT;
+               ret = -EFAULT;
                goto out_on_error;
        }
 
@@ -2088,7 +2088,7 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
        if (fc_dma_mapping_error(ctrl->lport->dev, op->fcp_req.rspdma)) {
                dev_err(ctrl->dev,
                        "FCP Op failed - rspiu dma mapping failed.\n");
-               ret = EFAULT;
+               ret = -EFAULT;
        }
 
        atomic_set(&op->state, FCPOP_STATE_IDLE);
@@ -2160,6 +2160,7 @@ nvme_fc_term_aen_ops(struct nvme_fc_ctrl *ctrl)
        struct nvme_fc_fcp_op *aen_op;
        int i;
 
+       cancel_work_sync(&ctrl->ctrl.async_event_work);
        aen_op = ctrl->aen_ops;
        for (i = 0; i < NVME_NR_AEN_COMMANDS; i++, aen_op++) {
                __nvme_fc_exit_request(ctrl, aen_op);
index 3ded54d..d4ba736 100644 (file)
@@ -65,51 +65,30 @@ void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
        }
 }
 
-bool nvme_failover_req(struct request *req)
+void nvme_failover_req(struct request *req)
 {
        struct nvme_ns *ns = req->q->queuedata;
-       u16 status = nvme_req(req)->status;
+       u16 status = nvme_req(req)->status & 0x7ff;
        unsigned long flags;
 
-       switch (status & 0x7ff) {
-       case NVME_SC_ANA_TRANSITION:
-       case NVME_SC_ANA_INACCESSIBLE:
-       case NVME_SC_ANA_PERSISTENT_LOSS:
-               /*
-                * If we got back an ANA error we know the controller is alive,
-                * but not ready to serve this namespaces.  The spec suggests
-                * we should update our general state here, but due to the fact
-                * that the admin and I/O queues are not serialized that is
-                * fundamentally racy.  So instead just clear the current path,
-                * mark the the path as pending and kick of a re-read of the ANA
-                * log page ASAP.
-                */
-               nvme_mpath_clear_current_path(ns);
-               if (ns->ctrl->ana_log_buf) {
-                       set_bit(NVME_NS_ANA_PENDING, &ns->flags);
-                       queue_work(nvme_wq, &ns->ctrl->ana_work);
-               }
-               break;
-       case NVME_SC_HOST_PATH_ERROR:
-       case NVME_SC_HOST_ABORTED_CMD:
-               /*
-                * Temporary transport disruption in talking to the controller.
-                * Try to send on a new path.
-                */
-               nvme_mpath_clear_current_path(ns);
-               break;
-       default:
-               /* This was a non-ANA error so follow the normal error path. */
-               return false;
+       nvme_mpath_clear_current_path(ns);
+
+       /*
+        * If we got back an ANA error, we know the controller is alive but not
+        * ready to serve this namespace.  Kick of a re-read of the ANA
+        * information page, and just try any other available path for now.
+        */
+       if (nvme_is_ana_error(status) && ns->ctrl->ana_log_buf) {
+               set_bit(NVME_NS_ANA_PENDING, &ns->flags);
+               queue_work(nvme_wq, &ns->ctrl->ana_work);
        }
 
        spin_lock_irqsave(&ns->head->requeue_lock, flags);
        blk_steal_bios(&ns->head->requeue_list, req);
        spin_unlock_irqrestore(&ns->head->requeue_lock, flags);
-       blk_mq_end_request(req, 0);
 
+       blk_mq_end_request(req, 0);
        kblockd_schedule_work(&ns->head->requeue_work);
-       return true;
 }
 
 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
@@ -233,7 +212,7 @@ static struct nvme_ns *nvme_next_ns(struct nvme_ns_head *head,
 static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
                int node, struct nvme_ns *old)
 {
-       struct nvme_ns *ns, *found, *fallback = NULL;
+       struct nvme_ns *ns, *found = NULL;
 
        if (list_is_singular(&head->list)) {
                if (nvme_path_is_disabled(old))
@@ -252,18 +231,22 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head,
                        goto out;
                }
                if (ns->ana_state == NVME_ANA_NONOPTIMIZED)
-                       fallback = ns;
+                       found = ns;
        }
 
-       /* No optimized path found, re-check the current path */
+       /*
+        * The loop above skips the current path for round-robin semantics.
+        * Fall back to the current path if either:
+        *  - no other optimized path found and current is optimized,
+        *  - no other usable path found and current is usable.
+        */
        if (!nvme_path_is_disabled(old) &&
-           old->ana_state == NVME_ANA_OPTIMIZED) {
-               found = old;
-               goto out;
-       }
-       if (!fallback)
+           (old->ana_state == NVME_ANA_OPTIMIZED ||
+            (!found && old->ana_state == NVME_ANA_NONOPTIMIZED)))
+               return old;
+
+       if (!found)
                return NULL;
-       found = fallback;
 out:
        rcu_assign_pointer(head->current_path[node], found);
        return found;
index ebb8c3e..9fd45ff 100644 (file)
@@ -307,7 +307,6 @@ struct nvme_ctrl {
        struct nvme_command ka_cmd;
        struct work_struct fw_act_work;
        unsigned long events;
-       bool created;
 
 #ifdef CONFIG_NVME_MULTIPATH
        /* asymmetric namespace access: */
@@ -523,7 +522,31 @@ static inline u32 nvme_bytes_to_numd(size_t len)
        return (len >> 2) - 1;
 }
 
-static inline bool nvme_end_request(struct request *req, __le16 status,
+static inline bool nvme_is_ana_error(u16 status)
+{
+       switch (status & 0x7ff) {
+       case NVME_SC_ANA_TRANSITION:
+       case NVME_SC_ANA_INACCESSIBLE:
+       case NVME_SC_ANA_PERSISTENT_LOSS:
+               return true;
+       default:
+               return false;
+       }
+}
+
+static inline bool nvme_is_path_error(u16 status)
+{
+       /* check for a status code type of 'path related status' */
+       return (status & 0x700) == 0x300;
+}
+
+/*
+ * Fill in the status and result information from the CQE, and then figure out
+ * if blk-mq will need to use IPI magic to complete the request, and if yes do
+ * so.  If not let the caller complete the request without an indirect function
+ * call.
+ */
+static inline bool nvme_try_complete_req(struct request *req, __le16 status,
                union nvme_result result)
 {
        struct nvme_request *rq = nvme_req(req);
@@ -581,7 +604,7 @@ void nvme_kill_queues(struct nvme_ctrl *ctrl);
 void nvme_sync_queues(struct nvme_ctrl *ctrl);
 void nvme_unfreeze(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
-void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
+int nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 void nvme_start_freeze(struct nvme_ctrl *ctrl);
 
 #define NVME_QID_ANY -1
@@ -629,7 +652,7 @@ void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
 void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
 void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
                        struct nvme_ctrl *ctrl, int *flags);
-bool nvme_failover_req(struct request *req);
+void nvme_failover_req(struct request *req);
 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
 void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id);
@@ -688,9 +711,8 @@ static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
        sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
 }
 
-static inline bool nvme_failover_req(struct request *req)
+static inline void nvme_failover_req(struct request *req)
 {
-       return false;
 }
 static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
 {
index ba725ae..899d2f4 100644 (file)
@@ -120,7 +120,7 @@ struct nvme_dev {
        unsigned max_qid;
        unsigned io_queues[HCTX_MAX_TYPES];
        unsigned int num_vecs;
-       u16 q_depth;
+       u32 q_depth;
        int io_sqes;
        u32 db_stride;
        void __iomem *bar;
@@ -157,13 +157,13 @@ struct nvme_dev {
 static int io_queue_depth_set(const char *val, const struct kernel_param *kp)
 {
        int ret;
-       u16 n;
+       u32 n;
 
-       ret = kstrtou16(val, 10, &n);
+       ret = kstrtou32(val, 10, &n);
        if (ret != 0 || n < 2)
                return -EINVAL;
 
-       return param_set_ushort(val, kp);
+       return param_set_uint(val, kp);
 }
 
 static inline unsigned int sq_idx(unsigned int qid, u32 stride)
@@ -195,7 +195,7 @@ struct nvme_queue {
        dma_addr_t sq_dma_addr;
        dma_addr_t cq_dma_addr;
        u32 __iomem *q_db;
-       u16 q_depth;
+       u32 q_depth;
        u16 cq_vector;
        u16 sq_tail;
        u16 cq_head;
@@ -961,7 +961,7 @@ static inline void nvme_handle_cqe(struct nvme_queue *nvmeq, u16 idx)
 
        req = blk_mq_tag_to_rq(nvme_queue_tagset(nvmeq), cqe->command_id);
        trace_nvme_sq(req, cqe->sq_head, nvmeq->sq_tail);
-       if (!nvme_end_request(req, cqe->status, cqe->result))
+       if (!nvme_try_complete_req(req, cqe->status, cqe->result))
                nvme_pci_complete_rq(req);
 }
 
@@ -1244,13 +1244,13 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
        switch (dev->ctrl.state) {
        case NVME_CTRL_CONNECTING:
                nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_DELETING);
-               /* fall through */
+               fallthrough;
        case NVME_CTRL_DELETING:
                dev_warn_ratelimited(dev->ctrl.device,
                         "I/O %d QID %d timeout, disable controller\n",
                         req->tag, nvmeq->qid);
-               nvme_dev_disable(dev, true);
                nvme_req(req)->flags |= NVME_REQ_CANCELLED;
+               nvme_dev_disable(dev, true);
                return BLK_EH_DONE;
        case NVME_CTRL_RESETTING:
                return BLK_EH_RESET_TIMER;
@@ -1267,10 +1267,10 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
                dev_warn(dev->ctrl.device,
                         "I/O %d QID %d timeout, reset controller\n",
                         req->tag, nvmeq->qid);
+               nvme_req(req)->flags |= NVME_REQ_CANCELLED;
                nvme_dev_disable(dev, false);
                nvme_reset_ctrl(&dev->ctrl);
 
-               nvme_req(req)->flags |= NVME_REQ_CANCELLED;
                return BLK_EH_DONE;
        }
 
@@ -2320,7 +2320,7 @@ static int nvme_pci_enable(struct nvme_dev *dev)
 
        dev->ctrl.cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
 
-       dev->q_depth = min_t(u16, NVME_CAP_MQES(dev->ctrl.cap) + 1,
+       dev->q_depth = min_t(u32, NVME_CAP_MQES(dev->ctrl.cap) + 1,
                                io_queue_depth);
        dev->ctrl.sqsize = dev->q_depth - 1; /* 0's based queue depth */
        dev->db_stride = 1 << NVME_CAP_STRIDE(dev->ctrl.cap);
@@ -2460,7 +2460,8 @@ static int nvme_disable_prepare_reset(struct nvme_dev *dev, bool shutdown)
 static int nvme_setup_prp_pools(struct nvme_dev *dev)
 {
        dev->prp_page_pool = dma_pool_create("prp list page", dev->dev,
-                                               PAGE_SIZE, PAGE_SIZE, 0);
+                                               NVME_CTRL_PAGE_SIZE,
+                                               NVME_CTRL_PAGE_SIZE, 0);
        if (!dev->prp_page_pool)
                return -ENOMEM;
 
index 44c76ff..9e378d0 100644 (file)
@@ -122,6 +122,7 @@ 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];
 };
@@ -834,6 +835,7 @@ static void nvme_rdma_destroy_admin_queue(struct nvme_rdma_ctrl *ctrl,
                blk_mq_free_tag_set(ctrl->ctrl.admin_tagset);
        }
        if (ctrl->async_event_sqe.data) {
+               cancel_work_sync(&ctrl->ctrl.async_event_work);
                nvme_rdma_free_qe(ctrl->device->dev, &ctrl->async_event_sqe,
                                sizeof(struct nvme_command), DMA_TO_DEVICE);
                ctrl->async_event_sqe.data = NULL;
@@ -975,7 +977,15 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
 
        if (!new) {
                nvme_start_queues(&ctrl->ctrl);
-               nvme_wait_freeze(&ctrl->ctrl);
+               if (!nvme_wait_freeze_timeout(&ctrl->ctrl, NVME_IO_TIMEOUT)) {
+                       /*
+                        * If we timed out waiting for freeze we are likely to
+                        * be stuck.  Fail the controller initialization just
+                        * to be safe.
+                        */
+                       ret = -ENODEV;
+                       goto out_wait_freeze_timed_out;
+               }
                blk_mq_update_nr_hw_queues(ctrl->ctrl.tagset,
                        ctrl->ctrl.queue_count - 1);
                nvme_unfreeze(&ctrl->ctrl);
@@ -983,6 +993,9 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new)
 
        return 0;
 
+out_wait_freeze_timed_out:
+       nvme_stop_queues(&ctrl->ctrl);
+       nvme_rdma_stop_io_queues(ctrl);
 out_cleanup_connect_q:
        if (new)
                blk_cleanup_queue(ctrl->ctrl.connect_q);
@@ -997,6 +1010,7 @@ 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);
        nvme_rdma_stop_queue(&ctrl->queues[0]);
        if (ctrl->ctrl.admin_tagset) {
@@ -1007,11 +1021,13 @@ 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);
@@ -1025,6 +1041,7 @@ 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)
@@ -1180,6 +1197,7 @@ static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl)
        if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING))
                return;
 
+       dev_warn(ctrl->ctrl.device, "starting error recovery\n");
        queue_work(nvme_reset_wq, &ctrl->err_work);
 }
 
@@ -1189,7 +1207,7 @@ static void nvme_rdma_end_request(struct nvme_rdma_request *req)
 
        if (!refcount_dec_and_test(&req->ref))
                return;
-       if (!nvme_end_request(rq, req->status, req->result))
+       if (!nvme_try_complete_req(rq, req->status, req->result))
                nvme_rdma_complete_rq(rq);
 }
 
@@ -1915,7 +1933,7 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
        case RDMA_CM_EVENT_CONNECT_ERROR:
        case RDMA_CM_EVENT_UNREACHABLE:
                nvme_rdma_destroy_queue_ib(queue);
-               /* fall through */
+               fallthrough;
        case RDMA_CM_EVENT_ADDR_ERROR:
                dev_dbg(queue->ctrl->ctrl.device,
                        "CM error event %d\n", ev->event);
@@ -1946,6 +1964,22 @@ static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
        return 0;
 }
 
+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)) {
+               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
 nvme_rdma_timeout(struct request *rq, bool reserved)
 {
@@ -1956,29 +1990,29 @@ nvme_rdma_timeout(struct request *rq, bool reserved)
        dev_warn(ctrl->ctrl.device, "I/O %d QID %d timeout\n",
                 rq->tag, nvme_rdma_queue_idx(queue));
 
-       /*
-        * Restart the timer if a controller reset is already scheduled. Any
-        * timed out commands would be handled before entering the connecting
-        * state.
-        */
-       if (ctrl->ctrl.state == NVME_CTRL_RESETTING)
-               return BLK_EH_RESET_TIMER;
-
        if (ctrl->ctrl.state != NVME_CTRL_LIVE) {
                /*
-                * Teardown immediately if controller times out while starting
-                * or we are already started error recovery. all outstanding
-                * requests are completed on shutdown, so we return BLK_EH_DONE.
+                * If we are resetting, connecting or deleting we should
+                * complete immediately because we may block controller
+                * teardown or setup sequence
+                * - ctrl disable/shutdown fabrics requests
+                * - connect requests
+                * - initialization admin requests
+                * - I/O requests that entered after unquiescing and
+                *   the controller stopped responding
+                *
+                * All other requests should be cancelled by the error
+                * recovery work, so it's fine that we fail it here.
                 */
-               flush_work(&ctrl->err_work);
-               nvme_rdma_teardown_io_queues(ctrl, false);
-               nvme_rdma_teardown_admin_queue(ctrl, false);
+               nvme_rdma_complete_timed_out(rq);
                return BLK_EH_DONE;
        }
 
-       dev_warn(ctrl->ctrl.device, "starting error recovery\n");
+       /*
+        * LIVE state should trigger the normal error recovery which will
+        * handle completing this request.
+        */
        nvme_rdma_error_recovery(ctrl);
-
        return BLK_EH_RESET_TIMER;
 }
 
@@ -2278,6 +2312,7 @@ 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 62fbaec..8f4f29f 100644 (file)
@@ -124,6 +124,7 @@ 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;
@@ -464,6 +465,7 @@ static void nvme_tcp_error_recovery(struct nvme_ctrl *ctrl)
        if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_RESETTING))
                return;
 
+       dev_warn(ctrl->device, "starting error recovery\n");
        queue_work(nvme_reset_wq, &to_tcp_ctrl(ctrl)->err_work);
 }
 
@@ -481,7 +483,7 @@ static int nvme_tcp_process_nvme_cqe(struct nvme_tcp_queue *queue,
                return -EINVAL;
        }
 
-       if (!nvme_end_request(rq, cqe->status, cqe->result))
+       if (!nvme_try_complete_req(rq, cqe->status, cqe->result))
                nvme_complete_rq(rq);
        queue->nr_cqe++;
 
@@ -672,7 +674,7 @@ static inline void nvme_tcp_end_request(struct request *rq, u16 status)
 {
        union nvme_result res = {};
 
-       if (!nvme_end_request(rq, cpu_to_le16(status << 1), res))
+       if (!nvme_try_complete_req(rq, cpu_to_le16(status << 1), res))
                nvme_complete_rq(rq);
 }
 
@@ -866,7 +868,6 @@ static void nvme_tcp_state_change(struct sock *sk)
        case TCP_LAST_ACK:
        case TCP_FIN_WAIT1:
        case TCP_FIN_WAIT2:
-               /* fallthrough */
                nvme_tcp_error_recovery(&queue->ctrl->ctrl);
                break;
        default:
@@ -1527,7 +1528,6 @@ static void nvme_tcp_stop_queue(struct nvme_ctrl *nctrl, int qid)
 
        if (!test_and_clear_bit(NVME_TCP_Q_LIVE, &queue->flags))
                return;
-
        __nvme_tcp_stop_queue(queue);
 }
 
@@ -1596,6 +1596,7 @@ static struct blk_mq_tag_set *nvme_tcp_alloc_tagset(struct nvme_ctrl *nctrl,
 static void nvme_tcp_free_admin_queue(struct nvme_ctrl *ctrl)
 {
        if (to_tcp_ctrl(ctrl)->async_req.pdu) {
+               cancel_work_sync(&ctrl->async_event_work);
                nvme_tcp_free_async_req(to_tcp_ctrl(ctrl));
                to_tcp_ctrl(ctrl)->async_req.pdu = NULL;
        }
@@ -1782,7 +1783,15 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
 
        if (!new) {
                nvme_start_queues(ctrl);
-               nvme_wait_freeze(ctrl);
+               if (!nvme_wait_freeze_timeout(ctrl, NVME_IO_TIMEOUT)) {
+                       /*
+                        * If we timed out waiting for freeze we are likely to
+                        * be stuck.  Fail the controller initialization just
+                        * to be safe.
+                        */
+                       ret = -ENODEV;
+                       goto out_wait_freeze_timed_out;
+               }
                blk_mq_update_nr_hw_queues(ctrl->tagset,
                        ctrl->queue_count - 1);
                nvme_unfreeze(ctrl);
@@ -1790,6 +1799,9 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new)
 
        return 0;
 
+out_wait_freeze_timed_out:
+       nvme_stop_queues(ctrl);
+       nvme_tcp_stop_io_queues(ctrl);
 out_cleanup_connect_q:
        if (new)
                blk_cleanup_queue(ctrl->connect_q);
@@ -1875,6 +1887,7 @@ 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);
        nvme_tcp_stop_queue(ctrl, 0);
        if (ctrl->admin_tagset) {
@@ -1885,13 +1898,16 @@ 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)
-               return;
+               goto out;
+       blk_mq_quiesce_queue(ctrl->admin_q);
        nvme_start_freeze(ctrl);
        nvme_stop_queues(ctrl);
        nvme_tcp_stop_io_queues(ctrl);
@@ -1903,6 +1919,8 @@ 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)
@@ -2149,40 +2167,55 @@ static void nvme_tcp_submit_async_event(struct nvme_ctrl *arg)
        nvme_tcp_queue_request(&ctrl->async_req, true, true);
 }
 
+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)) {
+               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
 nvme_tcp_timeout(struct request *rq, bool reserved)
 {
        struct nvme_tcp_request *req = blk_mq_rq_to_pdu(rq);
-       struct nvme_tcp_ctrl *ctrl = req->queue->ctrl;
+       struct nvme_ctrl *ctrl = &req->queue->ctrl->ctrl;
        struct nvme_tcp_cmd_pdu *pdu = req->pdu;
 
-       /*
-        * Restart the timer if a controller reset is already scheduled. Any
-        * timed out commands would be handled before entering the connecting
-        * state.
-        */
-       if (ctrl->ctrl.state == NVME_CTRL_RESETTING)
-               return BLK_EH_RESET_TIMER;
-
-       dev_warn(ctrl->ctrl.device,
+       dev_warn(ctrl->device,
                "queue %d: timeout request %#x type %d\n",
                nvme_tcp_queue_id(req->queue), rq->tag, pdu->hdr.type);
 
-       if (ctrl->ctrl.state != NVME_CTRL_LIVE) {
+       if (ctrl->state != NVME_CTRL_LIVE) {
                /*
-                * Teardown immediately if controller times out while starting
-                * or we are already started error recovery. all outstanding
-                * requests are completed on shutdown, so we return BLK_EH_DONE.
+                * If we are resetting, connecting or deleting we should
+                * complete immediately because we may block controller
+                * teardown or setup sequence
+                * - ctrl disable/shutdown fabrics requests
+                * - connect requests
+                * - initialization admin requests
+                * - I/O requests that entered after unquiescing and
+                *   the controller stopped responding
+                *
+                * All other requests should be cancelled by the error
+                * recovery work, so it's fine that we fail it here.
                 */
-               flush_work(&ctrl->err_work);
-               nvme_tcp_teardown_io_queues(&ctrl->ctrl, false);
-               nvme_tcp_teardown_admin_queue(&ctrl->ctrl, false);
+               nvme_tcp_complete_timed_out(rq);
                return BLK_EH_DONE;
        }
 
-       dev_warn(ctrl->ctrl.device, "starting error recovery\n");
-       nvme_tcp_error_recovery(&ctrl->ctrl);
-
+       /*
+        * LIVE state should trigger the normal error recovery which will
+        * handle completing this request.
+        */
+       nvme_tcp_error_recovery(ctrl);
        return BLK_EH_RESET_TIMER;
 }
 
@@ -2423,6 +2456,7 @@ 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 74b2b61..37e1d77 100644 (file)
@@ -1136,6 +1136,7 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
        up_write(&nvmet_config_sem);
 
        kfree_rcu(new_model, rcuhead);
+       kfree(new_model_number);
 
        return count;
 }
index b92f45f..b7b6333 100644 (file)
@@ -73,7 +73,7 @@ inline u16 errno_to_nvme_status(struct nvmet_req *req, int errno)
                status = NVME_SC_ACCESS_DENIED;
                break;
        case -EIO:
-               /* FALLTHRU */
+               fallthrough;
        default:
                req->error_loc = offsetof(struct nvme_common_command, opcode);
                status = NVME_SC_INTERNAL | NVME_SC_DNR;
@@ -397,6 +397,9 @@ static void nvmet_keep_alive_timer(struct work_struct *work)
 
 static void nvmet_start_keep_alive_timer(struct nvmet_ctrl *ctrl)
 {
+       if (unlikely(ctrl->kato == 0))
+               return;
+
        pr_debug("ctrl %d start keep-alive timer for %d secs\n",
                ctrl->cntlid, ctrl->kato);
 
@@ -406,6 +409,9 @@ static void nvmet_start_keep_alive_timer(struct nvmet_ctrl *ctrl)
 
 static void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl)
 {
+       if (unlikely(ctrl->kato == 0))
+               return;
+
        pr_debug("ctrl %d stop keep-alive\n", ctrl->cntlid);
 
        cancel_delayed_work_sync(&ctrl->ka_work);
index 55bafd5..e6861cc 100644 (file)
@@ -2342,9 +2342,9 @@ nvmet_fc_fod_op_done(struct nvmet_fc_fcp_iod *fod)
                        return;
                if (fcpreq->fcp_error ||
                    fcpreq->transferred_length != fcpreq->transfer_length) {
-                       spin_lock(&fod->flock);
+                       spin_lock_irqsave(&fod->flock, flags);
                        fod->abort = true;
-                       spin_unlock(&fod->flock);
+                       spin_unlock_irqrestore(&fod->flock, flags);
 
                        nvmet_req_complete(&fod->req, NVME_SC_INTERNAL);
                        return;
index c97e60b..3da067a 100644 (file)
@@ -812,7 +812,7 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,
                        break;
 
                /* Fall-Thru to RSP handling */
-               /* FALLTHRU */
+               fallthrough;
 
        case NVMET_FCOP_RSP:
                if (fcpreq) {
index 3dd6f56..125dde3 100644 (file)
@@ -139,7 +139,6 @@ static u16 blk_to_nvme_status(struct nvmet_req *req, blk_status_t blk_sts)
                req->error_loc = offsetof(struct nvme_rw_command, nsid);
                break;
        case BLK_STS_IOERR:
-               /* fallthru */
        default:
                status = NVME_SC_INTERNAL | NVME_SC_DNR;
                req->error_loc = offsetof(struct nvme_common_command, opcode);
index 4884ef1..0d6008c 100644 (file)
@@ -115,7 +115,7 @@ static void nvme_loop_queue_response(struct nvmet_req *req)
                        return;
                }
 
-               if (!nvme_end_request(rq, cqe->status, cqe->result))
+               if (!nvme_try_complete_req(rq, cqe->status, cqe->result))
                        nvme_loop_complete_rq(rq);
        }
 }
index 89d91dc..8bd7f65 100644 (file)
@@ -165,7 +165,7 @@ static void nvmet_passthru_execute_cmd_work(struct work_struct *w)
 
        req->cqe->result = nvme_req(rq)->result;
        nvmet_req_complete(req, status);
-       blk_put_request(rq);
+       blk_mq_free_request(rq);
 }
 
 static void nvmet_passthru_req_done(struct request *rq,
@@ -175,7 +175,7 @@ static void nvmet_passthru_req_done(struct request *rq,
 
        req->cqe->result = nvme_req(rq)->result;
        nvmet_req_complete(req, nvme_req(rq)->status);
-       blk_put_request(rq);
+       blk_mq_free_request(rq);
 }
 
 static int nvmet_passthru_map_sg(struct nvmet_req *req, struct request *rq)
@@ -230,7 +230,7 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
                if (unlikely(!ns)) {
                        pr_err("failed to get passthru ns nsid:%u\n", nsid);
                        status = NVME_SC_INVALID_NS | NVME_SC_DNR;
-                       goto fail_out;
+                       goto out;
                }
 
                q = ns->queue;
@@ -238,16 +238,15 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
 
        rq = nvme_alloc_request(q, req->cmd, BLK_MQ_REQ_NOWAIT, NVME_QID_ANY);
        if (IS_ERR(rq)) {
-               rq = NULL;
                status = NVME_SC_INTERNAL;
-               goto fail_out;
+               goto out_put_ns;
        }
 
        if (req->sg_cnt) {
                ret = nvmet_passthru_map_sg(req, rq);
                if (unlikely(ret)) {
                        status = NVME_SC_INTERNAL;
-                       goto fail_out;
+                       goto out_put_req;
                }
        }
 
@@ -274,11 +273,13 @@ static void nvmet_passthru_execute_cmd(struct nvmet_req *req)
 
        return;
 
-fail_out:
+out_put_req:
+       blk_mq_free_request(rq);
+out_put_ns:
        if (ns)
                nvme_put_ns(ns);
+out:
        nvmet_req_complete(req, status);
-       blk_put_request(rq);
 }
 
 /*
@@ -326,6 +327,10 @@ static u16 nvmet_setup_passthru_command(struct nvmet_req *req)
 
 u16 nvmet_parse_passthru_io_cmd(struct nvmet_req *req)
 {
+       /* Reject any commands with non-sgl flags set (ie. fused commands) */
+       if (req->cmd->common.flags & ~NVME_CMD_SGL_ALL)
+               return NVME_SC_INVALID_FIELD;
+
        switch (req->cmd->common.opcode) {
        case nvme_cmd_resv_register:
        case nvme_cmd_resv_report:
@@ -396,6 +401,10 @@ static u16 nvmet_passthru_get_set_features(struct nvmet_req *req)
 
 u16 nvmet_parse_passthru_admin_cmd(struct nvmet_req *req)
 {
+       /* Reject any commands with non-sgl flags set (ie. fused commands) */
+       if (req->cmd->common.flags & ~NVME_CMD_SGL_ALL)
+               return NVME_SC_INVALID_FIELD;
+
        /*
         * Passthru all vendor specific commands
         */
index 3ccb592..ae66204 100644 (file)
@@ -1758,7 +1758,7 @@ static int nvmet_rdma_cm_handler(struct rdma_cm_id *cm_id,
                        schedule_delayed_work(&port->repair_work, 0);
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case RDMA_CM_EVENT_DISCONNECTED:
        case RDMA_CM_EVENT_TIMEWAIT_EXIT:
                nvmet_rdma_queue_disconnect(queue);
@@ -1769,7 +1769,7 @@ static int nvmet_rdma_cm_handler(struct rdma_cm_id *cm_id,
        case RDMA_CM_EVENT_REJECTED:
                pr_debug("Connection rejected: %s\n",
                         rdma_reject_msg(cm_id, event->status));
-               /* FALLTHROUGH */
+               fallthrough;
        case RDMA_CM_EVENT_UNREACHABLE:
        case RDMA_CM_EVENT_CONNECT_ERROR:
                nvmet_rdma_queue_connect_fail(cm_id, queue);
index 9eda911..8e0d766 100644 (file)
@@ -160,6 +160,11 @@ static void nvmet_tcp_finish_cmd(struct nvmet_tcp_cmd *cmd);
 static inline u16 nvmet_tcp_cmd_tag(struct nvmet_tcp_queue *queue,
                struct nvmet_tcp_cmd *cmd)
 {
+       if (unlikely(!queue->nr_cmds)) {
+               /* We didn't allocate cmds yet, send 0xffff */
+               return USHRT_MAX;
+       }
+
        return cmd - queue->cmds;
 }
 
@@ -866,7 +871,10 @@ static int nvmet_tcp_handle_h2c_data_pdu(struct nvmet_tcp_queue *queue)
        struct nvme_tcp_data_pdu *data = &queue->pdu.data;
        struct nvmet_tcp_cmd *cmd;
 
-       cmd = &queue->cmds[data->ttag];
+       if (likely(queue->nr_cmds))
+               cmd = &queue->cmds[data->ttag];
+       else
+               cmd = &queue->connect;
 
        if (le32_to_cpu(data->data_offset) != cmd->rbytes_done) {
                pr_err("ttag %u unexpected data offset %u (expected %u)\n",
index 6cd3edb..a09ff84 100644 (file)
@@ -128,7 +128,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
        if (attr->private)
                dev = attr->private;
        else
-               dev = container_of(kobj, struct device, kobj);
+               dev = kobj_to_dev(kobj);
        nvmem = to_nvmem_device(dev);
 
        /* Stop the user from reading */
@@ -168,7 +168,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
        if (attr->private)
                dev = attr->private;
        else
-               dev = container_of(kobj, struct device, kobj);
+               dev = kobj_to_dev(kobj);
        nvmem = to_nvmem_device(dev);
 
        /* Stop the user from writing */
@@ -219,7 +219,7 @@ static umode_t nvmem_bin_attr_get_umode(struct nvmem_device *nvmem)
 static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
                                         struct bin_attribute *attr, int i)
 {
-       struct device *dev = container_of(kobj, struct device, kobj);
+       struct device *dev = kobj_to_dev(kobj);
        struct nvmem_device *nvmem = to_nvmem_device(dev);
 
        return nvmem_bin_attr_get_umode(nvmem);
@@ -321,7 +321,7 @@ static void nvmem_release(struct device *dev)
 {
        struct nvmem_device *nvmem = to_nvmem_device(dev);
 
-       ida_simple_remove(&nvmem_ida, nvmem->id);
+       ida_free(&nvmem_ida, nvmem->id);
        gpiod_put(nvmem->wp_gpio);
        kfree(nvmem);
 }
@@ -361,16 +361,14 @@ static void nvmem_cell_add(struct nvmem_cell *cell)
        blocking_notifier_call_chain(&nvmem_notifier, NVMEM_CELL_ADD, cell);
 }
 
-static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
-                                  const struct nvmem_cell_info *info,
-                                  struct nvmem_cell *cell)
+static int nvmem_cell_info_to_nvmem_cell_nodup(struct nvmem_device *nvmem,
+                                       const struct nvmem_cell_info *info,
+                                       struct nvmem_cell *cell)
 {
        cell->nvmem = nvmem;
        cell->offset = info->offset;
        cell->bytes = info->bytes;
-       cell->name = kstrdup_const(info->name, GFP_KERNEL);
-       if (!cell->name)
-               return -ENOMEM;
+       cell->name = info->name;
 
        cell->bit_offset = info->bit_offset;
        cell->nbits = info->nbits;
@@ -382,13 +380,30 @@ static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
        if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
                dev_err(&nvmem->dev,
                        "cell %s unaligned to nvmem stride %d\n",
-                       cell->name, nvmem->stride);
+                       cell->name ?: "<unknown>", nvmem->stride);
                return -EINVAL;
        }
 
        return 0;
 }
 
+static int nvmem_cell_info_to_nvmem_cell(struct nvmem_device *nvmem,
+                               const struct nvmem_cell_info *info,
+                               struct nvmem_cell *cell)
+{
+       int err;
+
+       err = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, cell);
+       if (err)
+               return err;
+
+       cell->name = kstrdup_const(info->name, GFP_KERNEL);
+       if (!cell->name)
+               return -ENOMEM;
+
+       return 0;
+}
+
 /**
  * nvmem_add_cells() - Add cell information to an nvmem device
  *
@@ -596,7 +611,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
        if (!nvmem)
                return ERR_PTR(-ENOMEM);
 
-       rval  = ida_simple_get(&nvmem_ida, 0, 0, GFP_KERNEL);
+       rval  = ida_alloc(&nvmem_ida, GFP_KERNEL);
        if (rval < 0) {
                kfree(nvmem);
                return ERR_PTR(rval);
@@ -608,7 +623,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
                nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
                                                    GPIOD_OUT_HIGH);
        if (IS_ERR(nvmem->wp_gpio)) {
-               ida_simple_remove(&nvmem_ida, nvmem->id);
+               ida_free(&nvmem_ida, nvmem->id);
                rval = PTR_ERR(nvmem->wp_gpio);
                kfree(nvmem);
                return ERR_PTR(rval);
@@ -835,6 +850,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
 {
 
        struct device_node *nvmem_np;
+       struct nvmem_device *nvmem;
        int index = 0;
 
        if (id)
@@ -844,7 +860,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
        if (!nvmem_np)
                return ERR_PTR(-ENOENT);
 
-       return __nvmem_device_get(nvmem_np, device_match_of_node);
+       nvmem = __nvmem_device_get(nvmem_np, device_match_of_node);
+       of_node_put(nvmem_np);
+       return nvmem;
 }
 EXPORT_SYMBOL_GPL(of_nvmem_device_get);
 #endif
@@ -1460,7 +1478,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
        if (!nvmem)
                return -EINVAL;
 
-       rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
+       rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell);
        if (rc)
                return rc;
 
@@ -1490,7 +1508,7 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
        if (!nvmem)
                return -EINVAL;
 
-       rc = nvmem_cell_info_to_nvmem_cell(nvmem, info, &cell);
+       rc = nvmem_cell_info_to_nvmem_cell_nodup(nvmem, info, &cell);
        if (rc)
                return rc;
 
index 856d9c3..6a537d9 100644 (file)
@@ -28,19 +28,6 @@ static int mtk_reg_read(void *context,
        return 0;
 }
 
-static int mtk_reg_write(void *context,
-                        unsigned int reg, void *_val, size_t bytes)
-{
-       struct mtk_efuse_priv *priv = context;
-       u32 *val = _val;
-       int i = 0, words = bytes / 4;
-
-       while (words--)
-               writel(*val++, priv->base + reg + (i++ * 4));
-
-       return 0;
-}
-
 static int mtk_efuse_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
@@ -61,7 +48,6 @@ static int mtk_efuse_probe(struct platform_device *pdev)
        econfig.stride = 4;
        econfig.word_size = 4;
        econfig.reg_read = mtk_reg_read;
-       econfig.reg_write = mtk_reg_write;
        econfig.size = resource_size(res);
        econfig.priv = priv;
        econfig.dev = dev;
index 590493e..da4f734 100644 (file)
@@ -128,15 +128,29 @@ static unsigned int of_bus_pci_get_flags(const __be32 *addr)
  * PCI bus specific translator
  */
 
+static bool of_node_is_pcie(struct device_node *np)
+{
+       bool is_pcie = of_node_name_eq(np, "pcie");
+
+       if (is_pcie)
+               pr_warn_once("%pOF: Missing device_type\n", np);
+
+       return is_pcie;
+}
+
 static int of_bus_pci_match(struct device_node *np)
 {
        /*
         * "pciex" is PCI Express
         * "vci" is for the /chaos bridge on 1st-gen PCI powermacs
         * "ht" is hypertransport
+        *
+        * If none of the device_type match, and that the node name is
+        * "pcie", accept the device as PCI (with a warning).
         */
        return of_node_is_type(np, "pci") || of_node_is_type(np, "pciex") ||
-               of_node_is_type(np, "vci") || of_node_is_type(np, "ht");
+               of_node_is_type(np, "vci") || of_node_is_type(np, "ht") ||
+               of_node_is_pcie(np);
 }
 
 static void of_bus_pci_count_cells(struct device_node *np,
@@ -985,6 +999,11 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz
                        /* Don't error out as we'd break some existing DTs */
                        continue;
                }
+               if (range.cpu_addr == OF_BAD_ADDR) {
+                       pr_err("translation of DMA address(%llx) to CPU address failed node(%pOF)\n",
+                              range.bus_addr, node);
+                       continue;
+               }
                dma_offset = range.cpu_addr - range.bus_addr;
 
                /* Take lower and upper limits */
index 9d7fb45..3ca7543 100644 (file)
@@ -893,8 +893,10 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
                 * have OPP table for the device, while others don't and
                 * opp_set_rate() just needs to behave like clk_set_rate().
                 */
-               if (!_get_opp_count(opp_table))
-                       return 0;
+               if (!_get_opp_count(opp_table)) {
+                       ret = 0;
+                       goto put_opp_table;
+               }
 
                if (!opp_table->required_opp_tables && !opp_table->regulators &&
                    !opp_table->paths) {
@@ -905,7 +907,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 
                ret = _set_opp_bw(opp_table, NULL, dev, true);
                if (ret)
-                       return ret;
+                       goto put_opp_table;
 
                if (opp_table->regulator_enabled) {
                        regulator_disable(opp_table->regulators[0]);
@@ -932,10 +934,13 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
 
        /* Return early if nothing to do */
        if (old_freq == freq) {
-               dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n",
-                       __func__, freq);
-               ret = 0;
-               goto put_opp_table;
+               if (!opp_table->required_opp_tables && !opp_table->regulators &&
+                   !opp_table->paths) {
+                       dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n",
+                               __func__, freq);
+                       ret = 0;
+                       goto put_opp_table;
+               }
        }
 
        /*
@@ -1291,13 +1296,19 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_remove);
 
-void _opp_remove_all_static(struct opp_table *opp_table)
+bool _opp_remove_all_static(struct opp_table *opp_table)
 {
        struct dev_pm_opp *opp, *tmp;
+       bool ret = true;
 
        mutex_lock(&opp_table->lock);
 
-       if (!opp_table->parsed_static_opps || --opp_table->parsed_static_opps)
+       if (!opp_table->parsed_static_opps) {
+               ret = false;
+               goto unlock;
+       }
+
+       if (--opp_table->parsed_static_opps)
                goto unlock;
 
        list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
@@ -1307,6 +1318,8 @@ void _opp_remove_all_static(struct opp_table *opp_table)
 
 unlock:
        mutex_unlock(&opp_table->lock);
+
+       return ret;
 }
 
 /**
@@ -2409,13 +2422,15 @@ void _dev_pm_opp_find_and_remove_table(struct device *dev)
                return;
        }
 
-       _opp_remove_all_static(opp_table);
+       /*
+        * Drop the extra reference only if the OPP table was successfully added
+        * with dev_pm_opp_of_add_table() earlier.
+        **/
+       if (_opp_remove_all_static(opp_table))
+               dev_pm_opp_put_opp_table(opp_table);
 
        /* Drop reference taken by _find_opp_table() */
        dev_pm_opp_put_opp_table(opp_table);
-
-       /* Drop reference taken while the OPP table was added */
-       dev_pm_opp_put_opp_table(opp_table);
 }
 
 /**
index e51646f..c3fcd57 100644 (file)
@@ -212,7 +212,7 @@ struct opp_table {
 
 /* Routines internal to opp core */
 void dev_pm_opp_get(struct dev_pm_opp *opp);
-void _opp_remove_all_static(struct opp_table *opp_table);
+bool _opp_remove_all_static(struct opp_table *opp_table);
 void _get_opp_table_kref(struct opp_table *opp_table);
 int _get_opp_count(struct opp_table *opp_table);
 struct opp_table *_find_opp_table(struct device *dev);
index f28d6a3..4547ac4 100644 (file)
@@ -260,7 +260,7 @@ static void parport_ieee1284_terminate (struct parport *port)
                        port->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
                }
 
-               /* fall through */
+               fallthrough;
 
        default:
                /* Terminate from all other modes. */
@@ -598,7 +598,7 @@ ssize_t parport_write (struct parport *port, const void *buffer, size_t len)
        case IEEE1284_MODE_NIBBLE:
        case IEEE1284_MODE_BYTE:
                parport_negotiate (port, IEEE1284_MODE_COMPAT);
-               /* fall through */
+               fallthrough;
        case IEEE1284_MODE_COMPAT:
                pr_debug("%s: Using compatibility mode\n", port->name);
                fn = port->ops->compat_write_data;
@@ -702,7 +702,7 @@ ssize_t parport_read (struct parport *port, void *buffer, size_t len)
                if (parport_negotiate (port, IEEE1284_MODE_NIBBLE)) {
                        return -EIO;
                }
-               /* fall through - to NIBBLE */
+               fallthrough;    /* to NIBBLE */
        case IEEE1284_MODE_NIBBLE:
                pr_debug("%s: Using nibble mode\n", port->name);
                fn = port->ops->nibble_read_data;
index 77e37e3..eda4ded 100644 (file)
@@ -1647,7 +1647,7 @@ static int parport_ECP_supported(struct parport *pb)
                break;
        default:
                pr_warn("0x%lx: Unknown implementation ID\n", pb->base);
-               /* Fall through - Assume 1 */
+               fallthrough;    /* Assume 1 */
        case 1:
                pword = 1;
        }
index 90df28c..5fef261 100644 (file)
@@ -439,7 +439,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
                regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
                                   IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0);
                break;
-       case IMX6QP:            /* FALLTHROUGH */
+       case IMX6QP:
        case IMX6Q:
                /* power up core phy and enable ref clock */
                regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
@@ -642,7 +642,7 @@ static void imx6_pcie_init_phy(struct imx6_pcie *imx6_pcie)
                regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
                                   IMX6SX_GPR12_PCIE_RX_EQ_MASK,
                                   IMX6SX_GPR12_PCIE_RX_EQ_2);
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
                                   IMX6Q_GPR12_PCIE_CTL_2, 0 << 10);
@@ -1105,7 +1105,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
                        dev_err(dev, "pcie_aux clock source missing or invalid\n");
                        return PTR_ERR(imx6_pcie->pcie_aux);
                }
-               /* fall through */
+               fallthrough;
        case IMX7D:
                if (dbi_base->start == IMX8MQ_PCIE2_BASE_ADDR)
                        imx6_pcie->controller_id = 1;
index c953003..afde4aa 100644 (file)
@@ -223,7 +223,7 @@ static void rcar_pci_setup(struct rcar_pci_priv *priv)
                pr_warn("unknown window size %ld - defaulting to 256M\n",
                        window_size);
                window_size = SZ_256M;
-               /* fall-through */
+               fallthrough;
        case SZ_256M:
                val |= RCAR_USBCTR_PCIAHB_WIN1_256M;
                break;
index 5c93aa1..ae9acc7 100644 (file)
@@ -1941,7 +1941,7 @@ static int __init update_bridge_ranges(struct bus_node **bus)
                                                break;
                                        case PCI_HEADER_TYPE_BRIDGE:
                                                function = 0x8;
-                                               /* fall through */
+                                               fallthrough;
                                        case PCI_HEADER_TYPE_MULTIBRIDGE:
                                                /* We assume here that only 1 bus behind the bridge
                                                   TO DO: add functionality for several:
index 6503d15..9f85815 100644 (file)
@@ -236,7 +236,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
        switch (ctrl->state) {
        case BLINKINGOFF_STATE:
                cancel_delayed_work(&ctrl->button_work);
-               /* fall through */
+               fallthrough;
        case ON_STATE:
                ctrl->state = POWEROFF_STATE;
                mutex_unlock(&ctrl->state_lock);
@@ -265,7 +265,7 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
        switch (ctrl->state) {
        case BLINKINGON_STATE:
                cancel_delayed_work(&ctrl->button_work);
-               /* fall through */
+               fallthrough;
        case OFF_STATE:
                ctrl->state = POWERON_STATE;
                mutex_unlock(&ctrl->state_lock);
index b59f849..c9e790c 100644 (file)
@@ -83,21 +83,19 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
        struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev,
                                             hotplug_slot);
        struct pci_dev *pdev;
-       struct zpci_bus *zbus = zdev->zbus;
        int rc;
 
        if (!zpci_fn_configured(zdev->state))
                return -EIO;
 
-       pdev = pci_get_slot(zbus->bus, zdev->devfn);
-       if (pdev) {
-               if (pci_num_vf(pdev))
-                       return -EBUSY;
-
-               pci_stop_and_remove_bus_device_locked(pdev);
+       pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
+       if (pdev && pci_num_vf(pdev)) {
                pci_dev_put(pdev);
+               return -EBUSY;
        }
 
+       zpci_remove_device(zdev);
+
        rc = zpci_disable_device(zdev);
        if (rc)
                return rc;
index afdc52d..65502e3 100644 (file)
@@ -642,7 +642,7 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
        switch (p_slot->state) {
        case BLINKINGON_STATE:
                cancel_delayed_work(&p_slot->work);
-               /* fall through */
+               fallthrough;
        case STATIC_STATE:
                p_slot->state = POWERON_STATE;
                mutex_unlock(&p_slot->lock);
@@ -678,7 +678,7 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
        switch (p_slot->state) {
        case BLINKINGOFF_STATE:
                cancel_delayed_work(&p_slot->work);
-               /* fall through */
+               fallthrough;
        case STATIC_STATE:
                p_slot->state = POWEROFF_STATE;
                mutex_unlock(&p_slot->lock);
index 64ebed1..f357f9a 100644 (file)
@@ -556,13 +556,14 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,
                return -1;
 
        for (i = 0; i < num_clients; i++) {
-               if (IS_ENABLED(CONFIG_DMA_VIRT_OPS) &&
-                   clients[i]->dma_ops == &dma_virt_ops) {
+#ifdef CONFIG_DMA_VIRT_OPS
+               if (clients[i]->dma_ops == &dma_virt_ops) {
                        if (verbose)
                                dev_warn(clients[i],
                                         "cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\n");
                        return -1;
                }
+#endif
 
                pci_client = find_parent_pci_dev(clients[i]);
                if (!pci_client) {
@@ -842,9 +843,10 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap,
         * this should never happen because it will be prevented
         * by the check in pci_p2pdma_distance_many()
         */
-       if (WARN_ON_ONCE(IS_ENABLED(CONFIG_DMA_VIRT_OPS) &&
-                        dev->dma_ops == &dma_virt_ops))
+#ifdef CONFIG_DMA_VIRT_OPS
+       if (WARN_ON_ONCE(dev->dma_ops == &dma_virt_ops))
                return 0;
+#endif
 
        for_each_sg(sg, s, nents, i) {
                paddr = sg_phys(s);
index a458c46..e39c549 100644 (file)
@@ -1049,7 +1049,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
                if ((pmcsr & PCI_PM_CTRL_STATE_MASK) == PCI_D3hot
                 && !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
                        need_restore = true;
-               /* Fall-through - force to D0 */
+               fallthrough;    /* force to D0 */
        default:
                pmcsr = 0;
                break;
@@ -2541,7 +2541,7 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
                case PCI_D2:
                        if (pci_no_d1d2(dev))
                                break;
-                       /* else, fall through */
+                       fallthrough;
                default:
                        target_state = state;
                }
index bd2b691..d35186b 100644 (file)
@@ -231,7 +231,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
                }
                /* If arch decided it can't, fall through... */
 #endif /* HAVE_PCI_MMAP */
-               /* fall through */
+               fallthrough;
        default:
                ret = -EINVAL;
                break;
index bdf9b52..2a589b6 100644 (file)
@@ -1730,7 +1730,7 @@ static void quirk_jmicron_ata(struct pci_dev *pdev)
        case PCI_DEVICE_ID_JMICRON_JMB366:
                /* Redirect IDE second PATA port to the right spot */
                conf5 |= (1 << 24);
-               /* Fall through */
+               fallthrough;
        case PCI_DEVICE_ID_JMICRON_JMB361:
        case PCI_DEVICE_ID_JMICRON_JMB363:
        case PCI_DEVICE_ID_JMICRON_JMB369:
@@ -2224,7 +2224,7 @@ static void quirk_netmos(struct pci_dev *dev)
                if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
                                dev->subsystem_device == 0x0299)
                        return;
-               /* else, fall through */
+               fallthrough;
        case PCI_DEVICE_ID_NETMOS_9735:
        case PCI_DEVICE_ID_NETMOS_9745:
        case PCI_DEVICE_ID_NETMOS_9845:
index 3951e02..2ce6369 100644 (file)
@@ -1253,7 +1253,7 @@ void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
                        additional_mmio_size = pci_hotplug_mmio_size;
                        additional_mmio_pref_size = pci_hotplug_mmio_pref_size;
                }
-               /* Fall through */
+               fallthrough;
        default:
                pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
                             additional_io_size, realloc_head);
index fab267e..c0e85be 100644 (file)
@@ -1096,7 +1096,7 @@ static void __ref pcifront_backend_changed(struct xenbus_device *xdev,
        case XenbusStateClosed:
                if (xdev->state == XenbusStateClosed)
                        break;
-               /* fall through - Missed the backend's CLOSING state. */
+               fallthrough;    /* Missed the backend's CLOSING state */
        case XenbusStateClosing:
                dev_warn(&xdev->dev, "backend going away!\n");
                pcifront_try_disconnect(pdev);
index 590e594..a7c7c7c 100644 (file)
@@ -255,10 +255,10 @@ static int db1x_pcmcia_configure(struct pcmcia_socket *skt,
        switch (state->Vcc) {
        case 50:
                ++v;
-               /* fall through */
+               fallthrough;
        case 33:
                ++v;
-               /* fall through */
+               fallthrough;
        case 0:
                break;
        default:
@@ -269,11 +269,11 @@ static int db1x_pcmcia_configure(struct pcmcia_socket *skt,
        switch (state->Vpp) {
        case 12:
                ++p;
-               /* fall through */
+               fallthrough;
        case 33:
        case 50:
                ++p;
-               /* fall through */
+               fallthrough;
        case 0:
                break;
        default:
index 7b7d23f..a0a71c1 100644 (file)
@@ -1404,7 +1404,7 @@ static int arm_ccn_init_nodes(struct arm_ccn *ccn, int region,
                break;
        case CCN_TYPE_SBAS:
                ccn->sbas_present = 1;
-               /* Fall-through */
+               fallthrough;
        default:
                component = &ccn->node[id];
                break;
index e51ddb6..cc00915 100644 (file)
@@ -1002,7 +1002,7 @@ static void __arm_spe_pmu_dev_probe(void *info)
        default:
                dev_warn(dev, "unknown PMSIDR_EL1.Interval [%d]; assuming 8\n",
                         fld);
-               /* Fallthrough */
+               fallthrough;
        case 8:
                spe_pmu->min_period = 4096;
        }
@@ -1021,7 +1021,7 @@ static void __arm_spe_pmu_dev_probe(void *info)
        default:
                dev_warn(dev, "unknown PMSIDR_EL1.CountSize [%d]; assuming 2\n",
                         fld);
-               /* Fallthrough */
+               fallthrough;
        case 2:
                spe_pmu->counter_sz = 12;
        }
index 71f257b..9061ece 100644 (file)
@@ -505,9 +505,9 @@ static int qcom_ipq806x_usb_phy_probe(struct platform_device *pdev)
        size = resource_size(res);
        phy_dwc3->base = devm_ioremap(phy_dwc3->dev, res->start, size);
 
-       if (IS_ERR(phy_dwc3->base)) {
+       if (!phy_dwc3->base) {
                dev_err(phy_dwc3->dev, "failed to map reg\n");
-               return PTR_ERR(phy_dwc3->base);
+               return -ENOMEM;
        }
 
        phy_dwc3->ref_clk = devm_clk_get(phy_dwc3->dev, "ref");
@@ -557,7 +557,6 @@ static struct platform_driver qcom_ipq806x_usb_phy_driver = {
        .probe          = qcom_ipq806x_usb_phy_probe,
        .driver         = {
                .name   = "qcom-ipq806x-usb-phy",
-               .owner  = THIS_MODULE,
                .of_match_table = qcom_ipq806x_usb_phy_table,
        },
 };
index 562053c..6e6f992 100644 (file)
@@ -604,8 +604,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
        QMP_PHY_INIT_CFG(QSERDES_COM_BG_TRIM, 0xf),
        QMP_PHY_INIT_CFG(QSERDES_COM_LOCK_CMP_EN, 0x1),
        QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_MAP, 0x0),
-       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0x1f),
-       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x3f),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER1, 0xff),
+       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_TIMER2, 0x1f),
        QMP_PHY_INIT_CFG(QSERDES_COM_CMN_CONFIG, 0x6),
        QMP_PHY_INIT_CFG(QSERDES_COM_PLL_IVCO, 0xf),
        QMP_PHY_INIT_CFG(QSERDES_COM_HSCLK_SEL, 0x0),
@@ -631,7 +631,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
        QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN1_MODE0, 0x0),
        QMP_PHY_INIT_CFG(QSERDES_COM_INTEGLOOP_GAIN0_MODE0, 0x80),
        QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CTRL_BY_PSM, 0x1),
-       QMP_PHY_INIT_CFG(QSERDES_COM_VCO_TUNE_CTRL, 0xa),
        QMP_PHY_INIT_CFG(QSERDES_COM_SSC_EN_CENTER, 0x1),
        QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER1, 0x31),
        QMP_PHY_INIT_CFG(QSERDES_COM_SSC_PER2, 0x1),
@@ -640,7 +639,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_serdes_tbl[] = {
        QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE1, 0x2f),
        QMP_PHY_INIT_CFG(QSERDES_COM_SSC_STEP_SIZE2, 0x19),
        QMP_PHY_INIT_CFG(QSERDES_COM_CLK_EP_DIV, 0x19),
-       QMP_PHY_INIT_CFG(QSERDES_RX_SIGDET_CNTRL, 0x7),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
@@ -648,6 +646,8 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_tx_tbl[] = {
        QMP_PHY_INIT_CFG(QSERDES_TX_LANE_MODE, 0x6),
        QMP_PHY_INIT_CFG(QSERDES_TX_RES_CODE_LANE_OFFSET, 0x2),
        QMP_PHY_INIT_CFG(QSERDES_TX_RCV_DETECT_LVL_2, 0x12),
+       QMP_PHY_INIT_CFG(QSERDES_TX_EMP_POST1_LVL, 0x36),
+       QMP_PHY_INIT_CFG(QSERDES_TX_SLEW_CNTL, 0x0a),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
@@ -658,7 +658,6 @@ static const struct qmp_phy_init_tbl ipq8074_pcie_rx_tbl[] = {
        QMP_PHY_INIT_CFG(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL4, 0xdb),
        QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
        QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN, 0x4),
-       QMP_PHY_INIT_CFG(QSERDES_RX_UCDR_SO_GAIN_HALF, 0x4),
 };
 
 static const struct qmp_phy_init_tbl ipq8074_pcie_pcs_tbl[] = {
@@ -2046,6 +2045,9 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
        .pwrdn_ctrl             = SW_PWRDN,
 };
 
+static const char * const ipq8074_pciephy_clk_l[] = {
+       "aux", "cfg_ahb",
+};
 /* list of resets */
 static const char * const ipq8074_pciephy_reset_l[] = {
        "phy", "common",
@@ -2063,8 +2065,8 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = {
        .rx_tbl_num             = ARRAY_SIZE(ipq8074_pcie_rx_tbl),
        .pcs_tbl                = ipq8074_pcie_pcs_tbl,
        .pcs_tbl_num            = ARRAY_SIZE(ipq8074_pcie_pcs_tbl),
-       .clk_list               = NULL,
-       .num_clks               = 0,
+       .clk_list               = ipq8074_pciephy_clk_l,
+       .num_clks               = ARRAY_SIZE(ipq8074_pciephy_clk_l),
        .reset_list             = ipq8074_pciephy_reset_l,
        .num_resets             = ARRAY_SIZE(ipq8074_pciephy_reset_l),
        .vreg_list              = NULL,
index 4277f59..904b80a 100644 (file)
@@ -77,6 +77,8 @@
 #define QSERDES_COM_CORECLK_DIV_MODE1                  0x1bc
 
 /* Only for QMP V2 PHY - TX registers */
+#define QSERDES_TX_EMP_POST1_LVL                       0x018
+#define QSERDES_TX_SLEW_CNTL                           0x040
 #define QSERDES_TX_RES_CODE_LANE_OFFSET                        0x054
 #define QSERDES_TX_DEBUG_BUS_SEL                       0x064
 #define QSERDES_TX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN    0x068
index 6105427..327df1a 100644 (file)
@@ -53,7 +53,7 @@ static int qcom_usb_hs_phy_set_mode(struct phy *phy,
                case PHY_MODE_USB_OTG:
                case PHY_MODE_USB_HOST:
                        val |= ULPI_INT_IDGRD;
-                       /* fall through */
+                       fallthrough;
                case PHY_MODE_USB_DEVICE:
                        val |= ULPI_INT_SESS_VALID;
                default:
index a84e9f0..46ebdb1 100644 (file)
@@ -546,7 +546,7 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
                rport->state = OTG_STATE_B_IDLE;
                if (!vbus_attach)
                        rockchip_usb2phy_power_off(rport->phy);
-               /* fall through */
+               fallthrough;
        case OTG_STATE_B_IDLE:
                if (extcon_get_state(rphy->edev, EXTCON_USB_HOST) > 0) {
                        dev_dbg(&rport->phy->dev, "usb otg host connect\n");
@@ -754,11 +754,11 @@ static void rockchip_chg_detect_work(struct work_struct *work)
                        rphy->chg_type = POWER_SUPPLY_TYPE_USB_DCP;
                else
                        rphy->chg_type = POWER_SUPPLY_TYPE_USB_CDP;
-               /* fall through */
+               fallthrough;
        case USB_CHG_STATE_SECONDARY_DONE:
                rphy->chg_state = USB_CHG_STATE_DETECTED;
                delay = 0;
-               /* fall through */
+               fallthrough;
        case USB_CHG_STATE_DETECTED:
                /* put the controller in normal mode */
                property_enable(base, &rphy->phy_cfg->chg_det.opmode, true);
@@ -835,7 +835,7 @@ static void rockchip_usb2phy_sm_work(struct work_struct *work)
                        dev_dbg(&rport->phy->dev, "FS/LS online\n");
                        break;
                }
-               /* fall through */
+               fallthrough;
        case PHY_STATE_CONNECT:
                if (rport->suspended) {
                        dev_dbg(&rport->phy->dev, "Connected\n");
index cb2dd32..507f79d 100644 (file)
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 #include <linux/of_platform.h>
+#include <linux/sys_soc.h>
 
 #define USB2PHY_ANA_CONFIG1            0x4c
 #define USB2PHY_DISCON_BYP_LATCH       BIT(31)
 
+#define USB2PHY_CHRG_DET                       0x14
+#define USB2PHY_CHRG_DET_USE_CHG_DET_REG       BIT(29)
+#define USB2PHY_CHRG_DET_DIS_CHG_DET           BIT(28)
+
 /* SoC Specific USB2_OTG register definitions */
 #define AM654_USB2_OTG_PD              BIT(8)
 #define AM654_USB2_VBUS_DET_EN         BIT(5)
@@ -43,6 +48,7 @@
 #define OMAP_USB2_HAS_START_SRP                        BIT(0)
 #define OMAP_USB2_HAS_SET_VBUS                 BIT(1)
 #define OMAP_USB2_CALIBRATE_FALSE_DISCONNECT   BIT(2)
+#define OMAP_USB2_DISABLE_CHRG_DET             BIT(3)
 
 struct omap_usb {
        struct usb_phy          phy;
@@ -236,6 +242,13 @@ static int omap_usb_init(struct phy *x)
                omap_usb_writel(phy->phy_base, USB2PHY_ANA_CONFIG1, val);
        }
 
+       if (phy->flags & OMAP_USB2_DISABLE_CHRG_DET) {
+               val = omap_usb_readl(phy->phy_base, USB2PHY_CHRG_DET);
+               val |= USB2PHY_CHRG_DET_USE_CHG_DET_REG |
+                      USB2PHY_CHRG_DET_DIS_CHG_DET;
+               omap_usb_writel(phy->phy_base, USB2PHY_CHRG_DET, val);
+       }
+
        return 0;
 }
 
@@ -329,6 +342,26 @@ static const struct of_device_id omap_usb2_id_table[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_usb2_id_table);
 
+static void omap_usb2_init_errata(struct omap_usb *phy)
+{
+       static const struct soc_device_attribute am65x_sr10_soc_devices[] = {
+               { .family = "AM65X", .revision = "SR1.0" },
+               { /* sentinel */ }
+       };
+
+       /*
+        * Errata i2075: USB2PHY: USB2PHY Charger Detect is Enabled by
+        * Default Without VBUS Presence.
+        *
+        * AM654x SR1.0 has a silicon bug due to which D+ is pulled high after
+        * POR, which could cause enumeration failure with some USB hubs.
+        * Disabling the USB2_PHY Charger Detect function will put D+
+        * into the normal state.
+        */
+       if (soc_device_match(am65x_sr10_soc_devices))
+               phy->flags |= OMAP_USB2_DISABLE_CHRG_DET;
+}
+
 static int omap_usb2_probe(struct platform_device *pdev)
 {
        struct omap_usb *phy;
@@ -366,14 +399,14 @@ static int omap_usb2_probe(struct platform_device *pdev)
        phy->mask               = phy_data->mask;
        phy->power_on           = phy_data->power_on;
        phy->power_off          = phy_data->power_off;
+       phy->flags              = phy_data->flags;
 
-       if (phy_data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) {
-               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-               phy->phy_base = devm_ioremap_resource(&pdev->dev, res);
-               if (IS_ERR(phy->phy_base))
-                       return PTR_ERR(phy->phy_base);
-               phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT;
-       }
+       omap_usb2_init_errata(phy);
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       phy->phy_base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(phy->phy_base))
+               return PTR_ERR(phy->phy_base);
 
        phy->syscon_phy_power = syscon_regmap_lookup_by_phandle(node,
                                                        "syscon-phy-power");
index 5e1d14e..0d46706 100644 (file)
@@ -431,7 +431,7 @@ static void olpc_xo175_ec_complete(void *arg)
                        input_sync(priv->pwrbtn);
                        input_report_key(priv->pwrbtn, KEY_POWER, 0);
                        input_sync(priv->pwrbtn);
-                       /* fall through */
+                       fallthrough;
                case EVENT_POWER_PRESS_WAKE:
                case EVENT_TIMED_HOST_WAKE:
                        pm_wakeup_event(priv->pwrbtn->dev.parent,
index 60c18f2..49f4b73 100644 (file)
@@ -1001,7 +1001,7 @@ static acpi_status WMID_get_u32(u32 *value, u32 cap)
                        *value = tmp & 0x1;
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        default:
                return AE_ERROR;
        }
@@ -1328,7 +1328,7 @@ static acpi_status get_u32(u32 *value, u32 cap)
                        status = AMW0_get_u32(value, cap);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case ACER_WMID:
                status = WMID_get_u32(value, cap);
                break;
@@ -1371,7 +1371,7 @@ static acpi_status set_u32(u32 value, u32 cap)
 
                                return AMW0_set_u32(value, cap);
                        }
-                       /* fall through */
+                       fallthrough;
                case ACER_WMID:
                        return WMID_set_u32(value, cap);
                case ACER_WMID_v2:
@@ -1381,7 +1381,7 @@ static acpi_status set_u32(u32 value, u32 cap)
                                return wmid_v2_set_u32(value, cap);
                        else if (wmi_has_guid(WMID_GUID2))
                                return WMID_set_u32(value, cap);
-                       /* fall through */
+                       fallthrough;
                default:
                        return AE_BAD_PARAMETER;
                }
index 5e9c229..70edc5b 100644 (file)
@@ -1587,10 +1587,10 @@ static ssize_t kbd_led_timeout_store(struct device *dev,
                switch (unit) {
                case KBD_TIMEOUT_DAYS:
                        value *= 24;
-                       /* fall through */
+                       fallthrough;
                case KBD_TIMEOUT_HOURS:
                        value *= 60;
-                       /* fall through */
+                       fallthrough;
                case KBD_TIMEOUT_MINUTES:
                        value *= 60;
                        unit = KBD_TIMEOUT_SECONDS;
index ec51522..d8afed5 100644 (file)
@@ -84,28 +84,28 @@ static void surface_button_notify(struct acpi_device *device, u32 event)
        /* Power button press,release handle */
        case SURFACE_BUTTON_NOTIFY_PRESS_POWER:
                pressed = true;
-               /*fall through*/
+               fallthrough;
        case SURFACE_BUTTON_NOTIFY_RELEASE_POWER:
                key_code = KEY_POWER;
                break;
        /* Home button press,release handle */
        case SURFACE_BUTTON_NOTIFY_PRESS_HOME:
                pressed = true;
-               /*fall through*/
+               fallthrough;
        case SURFACE_BUTTON_NOTIFY_RELEASE_HOME:
                key_code = KEY_LEFTMETA;
                break;
        /* Volume up button press,release handle */
        case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_UP:
                pressed = true;
-               /*fall through*/
+               fallthrough;
        case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_UP:
                key_code = KEY_VOLUMEUP;
                break;
        /* Volume down button press,release handle */
        case SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN:
                pressed = true;
-               /*fall through*/
+               fallthrough;
        case SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN:
                key_code = KEY_VOLUMEDOWN;
                break;
index 4864a5c..9c4df41 100644 (file)
@@ -4060,7 +4060,7 @@ static bool hotkey_notify_6xxx(const u32 hkey,
                 * AC status changed; can be triggered by plugging or
                 * unplugging AC adapter, docking or undocking. */
 
-               /* fallthrough */
+               fallthrough;
 
        case TP_HKEY_EV_KEY_NUMLOCK:
        case TP_HKEY_EV_KEY_FN:
@@ -4176,7 +4176,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event)
                                known_ev = true;
                                break;
                        }
-                       /* fallthrough - to default */
+                       fallthrough;    /* to default */
                default:
                        known_ev = false;
                }
@@ -6266,7 +6266,7 @@ static int thermal_get_sensor(int idx, s32 *value)
                        idx -= 8;
                }
 #endif
-               /* fallthrough */
+               fallthrough;
        case TPACPI_THERMAL_TPEC_8:
                if (idx <= 7) {
                        if (!acpi_ec_read(t + idx, &tmp))
index 36fff00..e557d75 100644 (file)
@@ -2748,7 +2748,7 @@ static void toshiba_acpi_process_hotkeys(struct toshiba_acpi_dev *dev)
                                result = hci_write(dev, HCI_SYSTEM_EVENT, 1);
                                if (result == TOS_SUCCESS)
                                        pr_notice("Re-enabled hotkeys\n");
-                               /* Fall through */
+                               fallthrough;
                        default:
                                retries--;
                                break;
index 9469fe1..db65be0 100644 (file)
@@ -748,7 +748,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
                                                USB_CH_IP_CUR_LVL_1P5;
                        break;
                }
-               /* else, fall through */
+               fallthrough;
        case USB_STAT_HM_IDGND:
                dev_err(di->dev, "USB Type - Charging not allowed\n");
                di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05;
@@ -2410,7 +2410,7 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work)
                 * of 1sec for enabling charging
                 */
                msleep(1000);
-               /* Intentional fall through */
+               fallthrough;
        case AB8500_BM_USB_STATE_CONFIGURED:
                /*
                 * USB is configured, enable charging with the charging
index 751c4f6..7eec415 100644 (file)
@@ -1542,7 +1542,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di)
                ab8500_fg_discharge_state_to(di,
                        AB8500_FG_DISCHARGE_INITMEASURING);
 
-               /* Intentional fallthrough */
+               fallthrough;
        case AB8500_FG_DISCHARGE_INITMEASURING:
                /*
                 * Discard a number of samples during startup.
@@ -1572,7 +1572,7 @@ static void ab8500_fg_algorithm_discharging(struct ab8500_fg *di)
                ab8500_fg_discharge_state_to(di,
                        AB8500_FG_DISCHARGE_RECOVERY);
 
-               /* Intentional fallthrough */
+               fallthrough;
 
        case AB8500_FG_DISCHARGE_RECOVERY:
                sleep_time = di->bm->fg_params->recovery_sleep_timer;
index 2fb33a0..175c4f3 100644 (file)
@@ -1419,7 +1419,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
                abx500_chargalg_stop_charging(di);
                di->charge_status = POWER_SUPPLY_STATUS_DISCHARGING;
                abx500_chargalg_state_to(di, STATE_HANDHELD);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_HANDHELD:
                break;
@@ -1435,7 +1435,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
                di->maintenance_chg = false;
                abx500_chargalg_state_to(di, STATE_SUSPENDED);
                power_supply_changed(di->chargalg_psy);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_SUSPENDED:
                /* CHARGING is suspended */
@@ -1444,7 +1444,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_BATT_REMOVED_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_BATT_REMOVED);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_BATT_REMOVED:
                if (!di->events.batt_rem)
@@ -1454,7 +1454,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_HW_TEMP_PROTECT_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_HW_TEMP_PROTECT);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_HW_TEMP_PROTECT:
                if (!di->events.main_thermal_prot &&
@@ -1465,7 +1465,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_OVV_PROTECT_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_OVV_PROTECT);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_OVV_PROTECT:
                if (!di->events.vbus_ovv &&
@@ -1479,7 +1479,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_CHG_NOT_OK_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_CHG_NOT_OK);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_CHG_NOT_OK:
                if (!di->events.mainextchnotok &&
@@ -1490,7 +1490,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_SAFETY_TIMER_EXPIRED_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_SAFETY_TIMER_EXPIRED);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_SAFETY_TIMER_EXPIRED:
                /* We exit this state when charger is removed */
@@ -1537,7 +1537,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_WAIT_FOR_RECHARGE_INIT:
                abx500_chargalg_hold_charging(di);
                abx500_chargalg_state_to(di, STATE_WAIT_FOR_RECHARGE);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_WAIT_FOR_RECHARGE:
                if (di->batt_data.percent <=
@@ -1558,7 +1558,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
                                di->bm->batt_id].maint_a_cur_lvl);
                abx500_chargalg_state_to(di, STATE_MAINTENANCE_A);
                power_supply_changed(di->chargalg_psy);
-               /* Intentional fallthrough*/
+               fallthrough;
 
        case STATE_MAINTENANCE_A:
                if (di->events.maintenance_timer_expired) {
@@ -1578,7 +1578,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
                                di->bm->batt_id].maint_b_cur_lvl);
                abx500_chargalg_state_to(di, STATE_MAINTENANCE_B);
                power_supply_changed(di->chargalg_psy);
-               /* Intentional fallthrough*/
+               fallthrough;
 
        case STATE_MAINTENANCE_B:
                if (di->events.maintenance_timer_expired) {
@@ -1597,7 +1597,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
                di->charge_status = POWER_SUPPLY_STATUS_CHARGING;
                abx500_chargalg_state_to(di, STATE_TEMP_LOWHIGH);
                power_supply_changed(di->chargalg_psy);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_TEMP_LOWHIGH:
                if (!di->events.btemp_lowhigh)
@@ -1607,7 +1607,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_WD_EXPIRED_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_WD_EXPIRED);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_WD_EXPIRED:
                if (!di->events.ac_wd_expired &&
@@ -1618,7 +1618,7 @@ static void abx500_chargalg_algorithm(struct abx500_chargalg *di)
        case STATE_TEMP_UNDEROVER_INIT:
                abx500_chargalg_stop_charging(di);
                abx500_chargalg_state_to(di, STATE_TEMP_UNDEROVER);
-               /* Intentional fallthrough */
+               fallthrough;
 
        case STATE_TEMP_UNDEROVER:
                if (!di->events.btemp_underover)
index d01dc03..0eaa86c 100644 (file)
@@ -349,7 +349,7 @@ static int axp20x_usb_power_set_current_max(struct axp20x_usb_power *power,
        case 100000:
                if (power->axp20x_id == AXP221_ID)
                        return -EINVAL;
-               /* fall through */
+               fallthrough;
        case 500000:
        case 900000:
                val = (900000 - intval) / 400000;
index 2a45e84..d89e08e 100644 (file)
@@ -383,7 +383,7 @@ static int cros_usbpd_charger_get_prop(struct power_supply *psy,
                 */
                if (ec_device->mkbp_event_supported || port->psy_online)
                        break;
-               /* fall through */
+               fallthrough;
        case POWER_SUPPLY_PROP_CURRENT_MAX:
        case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
        case POWER_SUPPLY_PROP_VOLTAGE_NOW:
index 5fca496..8878f91 100644 (file)
@@ -121,7 +121,7 @@ static irqreturn_t max8925_charger_handler(int irq, void *data)
        case MAX8925_IRQ_VCHG_THM_OK_F:
                /* Battery is not ready yet */
                dev_dbg(chip->dev, "Battery temperature is out of range\n");
-               /* Fall through */
+               fallthrough;
        case MAX8925_IRQ_VCHG_DC_OVP:
                dev_dbg(chip->dev, "Error detection\n");
                __set_charger(info, 0);
index 65832bc..18b33f1 100644 (file)
@@ -665,7 +665,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
                break;
        default:
                dev_err(&pdev->dev, "Failed to find USB phy: %d\n", ret);
-               /* fall-through */
+               fallthrough;
        case -EPROBE_DEFER:
                goto err_bat_irq;
                break;
index 26923af..e05cee4 100644 (file)
@@ -227,7 +227,7 @@ static irqreturn_t wm8350_charger_handler(int irq, void *data)
        case WM8350_IRQ_EXT_USB_FB:
        case WM8350_IRQ_EXT_WALL_FB:
                wm8350_charger_config(wm8350, policy);
-               /* Fall through */
+               fallthrough;
        case WM8350_IRQ_EXT_BAT_FB:
                power_supply_changed(power->battery);
                power_supply_changed(power->usb);
index 6f55aae..25c7649 100644 (file)
@@ -1035,6 +1035,9 @@ static const struct x86_cpu_id rapl_ids[] __initconst = {
        X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE_L,         &rapl_defaults_core),
        X86_MATCH_INTEL_FAM6_MODEL(COMETLAKE,           &rapl_defaults_core),
        X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE_L,         &rapl_defaults_core),
+       X86_MATCH_INTEL_FAM6_MODEL(TIGERLAKE,           &rapl_defaults_core),
+       X86_MATCH_INTEL_FAM6_MODEL(ROCKETLAKE,          &rapl_defaults_core),
+       X86_MATCH_INTEL_FAM6_MODEL(ALDERLAKE,           &rapl_defaults_core),
        X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X,    &rapl_defaults_spr_server),
 
        X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT,     &rapl_defaults_byt),
index 24f04ff..9d66257 100644 (file)
@@ -769,7 +769,7 @@ static int ps3av_auto_videomode(struct ps3av_pkt_av_get_hw_conf *av_hw_conf)
                switch (info->monitor_type) {
                case PS3AV_MONITOR_TYPE_DVI:
                        dvi = PS3AV_MODE_DVI;
-                       /* fall through */
+                       fallthrough;
                case PS3AV_MONITOR_TYPE_HDMI:
                        id = ps3av_hdmi_get_id(info);
                        break;
index f0e650c..c222066 100644 (file)
@@ -693,11 +693,11 @@ void ps3av_cmd_set_audio_mode(struct ps3av_pkt_audio_mode *audio, u32 avport,
        switch (ch) {
        case PS3AV_CMD_AUDIO_NUM_OF_CH_8:
                audio->audio_enable[3] = 1;
-               /* fall through */
+               fallthrough;
        case PS3AV_CMD_AUDIO_NUM_OF_CH_6:
                audio->audio_enable[2] = 1;
                audio->audio_enable[1] = 1;
-               /* fall through */
+               fallthrough;
        case PS3AV_CMD_AUDIO_NUM_OF_CH_2:
        default:
                audio->audio_enable[0] = 1;
index 73aaae5..e020faf 100644 (file)
@@ -142,16 +142,15 @@ static int idtcm_strverscmp(const char *ver1, const char *ver2)
        return result;
 }
 
-static int idtcm_xfer(struct idtcm *idtcm,
-                     u8 regaddr,
-                     u8 *buf,
-                     u16 count,
-                     bool write)
+static int idtcm_xfer_read(struct idtcm *idtcm,
+                          u8 regaddr,
+                          u8 *buf,
+                          u16 count)
 {
        struct i2c_client *client = idtcm->client;
        struct i2c_msg msg[2];
        int cnt;
-       char *fmt = "i2c_transfer failed at %d in %s for %s, at addr: %04X!\n";
+       char *fmt = "i2c_transfer failed at %d in %s, at addr: %04X!\n";
 
        msg[0].addr = client->addr;
        msg[0].flags = 0;
@@ -159,7 +158,7 @@ static int idtcm_xfer(struct idtcm *idtcm,
        msg[0].buf = &regaddr;
 
        msg[1].addr = client->addr;
-       msg[1].flags = write ? 0 : I2C_M_RD;
+       msg[1].flags = I2C_M_RD;
        msg[1].len = count;
        msg[1].buf = buf;
 
@@ -170,7 +169,6 @@ static int idtcm_xfer(struct idtcm *idtcm,
                        fmt,
                        __LINE__,
                        __func__,
-                       write ? "write" : "read",
                        regaddr);
                return cnt;
        } else if (cnt != 2) {
@@ -182,6 +180,37 @@ static int idtcm_xfer(struct idtcm *idtcm,
        return 0;
 }
 
+static int idtcm_xfer_write(struct idtcm *idtcm,
+                           u8 regaddr,
+                           u8 *buf,
+                           u16 count)
+{
+       struct i2c_client *client = idtcm->client;
+       /* we add 1 byte for device register */
+       u8 msg[IDTCM_MAX_WRITE_COUNT + 1];
+       int cnt;
+       char *fmt = "i2c_master_send failed at %d in %s, at addr: %04X!\n";
+
+       if (count > IDTCM_MAX_WRITE_COUNT)
+               return -EINVAL;
+
+       msg[0] = regaddr;
+       memcpy(&msg[1], buf, count);
+
+       cnt = i2c_master_send(client, msg, count + 1);
+
+       if (cnt < 0) {
+               dev_err(&client->dev,
+                       fmt,
+                       __LINE__,
+                       __func__,
+                       regaddr);
+               return cnt;
+       }
+
+       return 0;
+}
+
 static int idtcm_page_offset(struct idtcm *idtcm, u8 val)
 {
        u8 buf[4];
@@ -195,7 +224,7 @@ static int idtcm_page_offset(struct idtcm *idtcm, u8 val)
        buf[2] = 0x10;
        buf[3] = 0x20;
 
-       err = idtcm_xfer(idtcm, PAGE_ADDR, buf, sizeof(buf), 1);
+       err = idtcm_xfer_write(idtcm, PAGE_ADDR, buf, sizeof(buf));
 
        if (err) {
                idtcm->page_offset = 0xff;
@@ -223,11 +252,12 @@ static int _idtcm_rdwr(struct idtcm *idtcm,
        err = idtcm_page_offset(idtcm, hi);
 
        if (err)
-               goto out;
+               return err;
 
-       err = idtcm_xfer(idtcm, lo, buf, count, write);
-out:
-       return err;
+       if (write)
+               return idtcm_xfer_write(idtcm, lo, buf, count);
+
+       return idtcm_xfer_read(idtcm, lo, buf, count);
 }
 
 static int idtcm_read(struct idtcm *idtcm,
index ffae56c..82840d7 100644 (file)
@@ -55,6 +55,8 @@
 
 #define PEROUT_ENABLE_OUTPUT_MASK              (0xdeadbeef)
 
+#define IDTCM_MAX_WRITE_COUNT                  (512)
+
 /* Values of DPLL_N.DPLL_MODE.PLL_MODE */
 enum pll_mode {
        PLL_MODE_MIN = 0,
index e4c422d..b9f8514 100644 (file)
@@ -37,7 +37,7 @@ config RAPIDIO_ENABLE_RX_TX_PORTS
 config RAPIDIO_DMA_ENGINE
        bool "DMA Engine support for RapidIO"
        depends on RAPIDIO
-       select DMADEVICES
+       depends on DMADEVICES
        select DMA_ENGINE
        help
          Say Y here if you want to use DMA Engine frameork for RapidIO data
index c07ceec..a303429 100644 (file)
@@ -2150,7 +2150,7 @@ static void mport_release_mapping(struct kref *ref)
        switch (map->dir) {
        case MAP_INBOUND:
                rio_unmap_inb_region(mport, map->phys_addr);
-               /* fall through */
+               fallthrough;
        case MAP_DMA:
                dma_free_coherent(mport->dev.parent, map->size,
                                  map->virt_addr, map->phys_addr);
index fbc95ca..1bacb37 100644 (file)
@@ -399,7 +399,7 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
                if (rate_count > 0)
                        break;
 
-               /* fall through */
+               fallthrough;
        default:
                /* Not supported for this regulator */
                return -ENOTSUPP;
@@ -1022,7 +1022,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
                 * (See include/linux/mfd/axp20x.h)
                 */
                reg = AXP803_DCDC_FREQ_CTRL;
-               /* Fall through - to the check below.*/
+               fallthrough;    /* to the check below */
        case AXP806_ID:
                /*
                 * AXP806 also have DCDC work frequency setting register at a
@@ -1030,7 +1030,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
                 */
                if (axp20x->variant == AXP806_ID)
                        reg = AXP806_DCDC_FREQ_CTRL;
-               /* Fall through */
+               fallthrough;
        case AXP221_ID:
        case AXP223_ID:
        case AXP809_ID:
@@ -1118,7 +1118,7 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
                 * (See include/linux/mfd/axp20x.h)
                 */
                reg = AXP806_DCDC_MODE_CTRL2;
-                /* Fall through - to the check below. */
+               fallthrough;    /* to the check below */
        case AXP221_ID:
        case AXP223_ID:
        case AXP809_ID:
index 75ff7c5..7ff507e 100644 (file)
@@ -236,8 +236,8 @@ static bool regulator_supply_is_couple(struct regulator_dev *rdev)
 static void regulator_unlock_recursive(struct regulator_dev *rdev,
                                       unsigned int n_coupled)
 {
-       struct regulator_dev *c_rdev;
-       int i;
+       struct regulator_dev *c_rdev, *supply_rdev;
+       int i, supply_n_coupled;
 
        for (i = n_coupled; i > 0; i--) {
                c_rdev = rdev->coupling_desc.coupled_rdevs[i - 1];
@@ -245,10 +245,13 @@ static void regulator_unlock_recursive(struct regulator_dev *rdev,
                if (!c_rdev)
                        continue;
 
-               if (c_rdev->supply && !regulator_supply_is_couple(c_rdev))
-                       regulator_unlock_recursive(
-                                       c_rdev->supply->rdev,
-                                       c_rdev->coupling_desc.n_coupled);
+               if (c_rdev->supply && !regulator_supply_is_couple(c_rdev)) {
+                       supply_rdev = c_rdev->supply->rdev;
+                       supply_n_coupled = supply_rdev->coupling_desc.n_coupled;
+
+                       regulator_unlock_recursive(supply_rdev,
+                                                  supply_n_coupled);
+               }
 
                regulator_unlock(c_rdev);
        }
@@ -1461,7 +1464,7 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
                                      const char *consumer_dev_name,
                                      const char *supply)
 {
-       struct regulator_map *node;
+       struct regulator_map *node, *new_node;
        int has_dev;
 
        if (supply == NULL)
@@ -1472,6 +1475,22 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
        else
                has_dev = 0;
 
+       new_node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
+       if (new_node == NULL)
+               return -ENOMEM;
+
+       new_node->regulator = rdev;
+       new_node->supply = supply;
+
+       if (has_dev) {
+               new_node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
+               if (new_node->dev_name == NULL) {
+                       kfree(new_node);
+                       return -ENOMEM;
+               }
+       }
+
+       mutex_lock(&regulator_list_mutex);
        list_for_each_entry(node, &regulator_map_list, list) {
                if (node->dev_name && consumer_dev_name) {
                        if (strcmp(node->dev_name, consumer_dev_name) != 0)
@@ -1489,26 +1508,19 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
                         node->regulator->desc->name,
                         supply,
                         dev_name(&rdev->dev), rdev_get_name(rdev));
-               return -EBUSY;
+               goto fail;
        }
 
-       node = kzalloc(sizeof(struct regulator_map), GFP_KERNEL);
-       if (node == NULL)
-               return -ENOMEM;
-
-       node->regulator = rdev;
-       node->supply = supply;
-
-       if (has_dev) {
-               node->dev_name = kstrdup(consumer_dev_name, GFP_KERNEL);
-               if (node->dev_name == NULL) {
-                       kfree(node);
-                       return -ENOMEM;
-               }
-       }
+       list_add(&new_node->list, &regulator_map_list);
+       mutex_unlock(&regulator_list_mutex);
 
-       list_add(&node->list, &regulator_map_list);
        return 0;
+
+fail:
+       mutex_unlock(&regulator_list_mutex);
+       kfree(new_node->dev_name);
+       kfree(new_node);
+       return -EBUSY;
 }
 
 static void unset_regulator_supplies(struct regulator_dev *rdev)
@@ -1580,44 +1592,53 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
                                          const char *supply_name)
 {
        struct regulator *regulator;
-       char buf[REG_STR_SIZE];
-       int err, size;
+       int err;
+
+       if (dev) {
+               char buf[REG_STR_SIZE];
+               int size;
+
+               size = snprintf(buf, REG_STR_SIZE, "%s-%s",
+                               dev->kobj.name, supply_name);
+               if (size >= REG_STR_SIZE)
+                       return NULL;
+
+               supply_name = kstrdup(buf, GFP_KERNEL);
+               if (supply_name == NULL)
+                       return NULL;
+       } else {
+               supply_name = kstrdup_const(supply_name, GFP_KERNEL);
+               if (supply_name == NULL)
+                       return NULL;
+       }
 
        regulator = kzalloc(sizeof(*regulator), GFP_KERNEL);
-       if (regulator == NULL)
+       if (regulator == NULL) {
+               kfree(supply_name);
                return NULL;
+       }
 
-       regulator_lock(rdev);
        regulator->rdev = rdev;
+       regulator->supply_name = supply_name;
+
+       regulator_lock(rdev);
        list_add(&regulator->list, &rdev->consumer_list);
+       regulator_unlock(rdev);
 
        if (dev) {
                regulator->dev = dev;
 
                /* Add a link to the device sysfs entry */
-               size = snprintf(buf, REG_STR_SIZE, "%s-%s",
-                               dev->kobj.name, supply_name);
-               if (size >= REG_STR_SIZE)
-                       goto overflow_err;
-
-               regulator->supply_name = kstrdup(buf, GFP_KERNEL);
-               if (regulator->supply_name == NULL)
-                       goto overflow_err;
-
                err = sysfs_create_link_nowarn(&rdev->dev.kobj, &dev->kobj,
-                                       buf);
+                                              supply_name);
                if (err) {
                        rdev_dbg(rdev, "could not add device link %s err %d\n",
                                  dev->kobj.name, err);
                        /* non-fatal */
                }
-       } else {
-               regulator->supply_name = kstrdup_const(supply_name, GFP_KERNEL);
-               if (regulator->supply_name == NULL)
-                       goto overflow_err;
        }
 
-       regulator->debugfs = debugfs_create_dir(regulator->supply_name,
+       regulator->debugfs = debugfs_create_dir(supply_name,
                                                rdev->debugfs);
        if (!regulator->debugfs) {
                rdev_dbg(rdev, "Failed to create debugfs directory\n");
@@ -1642,13 +1663,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev,
            _regulator_is_enabled(rdev))
                regulator->always_on = true;
 
-       regulator_unlock(rdev);
        return regulator;
-overflow_err:
-       list_del(&regulator->list);
-       kfree(regulator);
-       regulator_unlock(rdev);
-       return NULL;
 }
 
 static int _regulator_get_enable_time(struct regulator_dev *rdev)
@@ -1895,7 +1910,7 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
                case EXCLUSIVE_GET:
                        dev_warn(dev,
                                 "dummy supplies not allowed for exclusive requests\n");
-                       /* fall through */
+                       fallthrough;
 
                default:
                        return ERR_PTR(-ENODEV);
@@ -2230,10 +2245,13 @@ EXPORT_SYMBOL_GPL(regulator_bulk_unregister_supply_alias);
 static int regulator_ena_gpio_request(struct regulator_dev *rdev,
                                const struct regulator_config *config)
 {
-       struct regulator_enable_gpio *pin;
+       struct regulator_enable_gpio *pin, *new_pin;
        struct gpio_desc *gpiod;
 
        gpiod = config->ena_gpiod;
+       new_pin = kzalloc(sizeof(*new_pin), GFP_KERNEL);
+
+       mutex_lock(&regulator_list_mutex);
 
        list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
                if (pin->gpiod == gpiod) {
@@ -2242,9 +2260,13 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
                }
        }
 
-       pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
-       if (pin == NULL)
+       if (new_pin == NULL) {
+               mutex_unlock(&regulator_list_mutex);
                return -ENOMEM;
+       }
+
+       pin = new_pin;
+       new_pin = NULL;
 
        pin->gpiod = gpiod;
        list_add(&pin->list, &regulator_ena_gpio_list);
@@ -2252,6 +2274,10 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
 update_ena_gpio_to_rdev:
        pin->request_count++;
        rdev->ena_pin = pin;
+
+       mutex_unlock(&regulator_list_mutex);
+       kfree(new_pin);
+
        return 0;
 }
 
@@ -2264,19 +2290,19 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev)
 
        /* Free the GPIO only in case of no use */
        list_for_each_entry_safe(pin, n, &regulator_ena_gpio_list, list) {
-               if (pin->gpiod == rdev->ena_pin->gpiod) {
-                       if (pin->request_count <= 1) {
-                               pin->request_count = 0;
-                               gpiod_put(pin->gpiod);
-                               list_del(&pin->list);
-                               kfree(pin);
-                               rdev->ena_pin = NULL;
-                               return;
-                       } else {
-                               pin->request_count--;
-                       }
-               }
+               if (pin != rdev->ena_pin)
+                       continue;
+
+               if (--pin->request_count)
+                       break;
+
+               gpiod_put(pin->gpiod);
+               list_del(&pin->list);
+               kfree(pin);
+               break;
        }
+
+       rdev->ena_pin = NULL;
 }
 
 /**
@@ -4949,13 +4975,9 @@ static void regulator_resolve_coupling(struct regulator_dev *rdev)
                        return;
                }
 
-               regulator_lock(c_rdev);
-
                c_desc->coupled_rdevs[i] = c_rdev;
                c_desc->n_resolved++;
 
-               regulator_unlock(c_rdev);
-
                regulator_resolve_coupling(c_rdev);
        }
 }
@@ -5040,7 +5062,10 @@ static int regulator_init_coupling(struct regulator_dev *rdev)
        if (!of_check_coupling_data(rdev))
                return -EPERM;
 
+       mutex_lock(&regulator_list_mutex);
        rdev->coupling_desc.coupler = regulator_find_coupler(rdev);
+       mutex_unlock(&regulator_list_mutex);
+
        if (IS_ERR(rdev->coupling_desc.coupler)) {
                err = PTR_ERR(rdev->coupling_desc.coupler);
                rdev_err(rdev, "failed to get coupler: %d\n", err);
@@ -5141,6 +5166,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
                ret = -ENOMEM;
                goto rinse;
        }
+       device_initialize(&rdev->dev);
 
        /*
         * Duplicate the config so the driver could override it after
@@ -5148,9 +5174,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
         */
        config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL);
        if (config == NULL) {
-               kfree(rdev);
                ret = -ENOMEM;
-               goto rinse;
+               goto clean;
        }
 
        init_data = regulator_of_get_init_data(dev, regulator_desc, config,
@@ -5162,10 +5187,8 @@ regulator_register(const struct regulator_desc *regulator_desc,
         * from a gpio extender or something else.
         */
        if (PTR_ERR(init_data) == -EPROBE_DEFER) {
-               kfree(config);
-               kfree(rdev);
                ret = -EPROBE_DEFER;
-               goto rinse;
+               goto clean;
        }
 
        /*
@@ -5206,9 +5229,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
        }
 
        if (config->ena_gpiod) {
-               mutex_lock(&regulator_list_mutex);
                ret = regulator_ena_gpio_request(rdev, config);
-               mutex_unlock(&regulator_list_mutex);
                if (ret != 0) {
                        rdev_err(rdev, "Failed to request enable GPIO: %d\n",
                                 ret);
@@ -5220,7 +5241,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
        }
 
        /* register with sysfs */
-       device_initialize(&rdev->dev);
        rdev->dev.class = &regulator_class;
        rdev->dev.parent = dev;
        dev_set_name(&rdev->dev, "regulator.%lu",
@@ -5248,27 +5268,22 @@ regulator_register(const struct regulator_desc *regulator_desc,
        if (ret < 0)
                goto wash;
 
-       mutex_lock(&regulator_list_mutex);
        ret = regulator_init_coupling(rdev);
-       mutex_unlock(&regulator_list_mutex);
        if (ret < 0)
                goto wash;
 
        /* add consumers devices */
        if (init_data) {
-               mutex_lock(&regulator_list_mutex);
                for (i = 0; i < init_data->num_consumer_supplies; i++) {
                        ret = set_consumer_device_supply(rdev,
                                init_data->consumer_supplies[i].dev_name,
                                init_data->consumer_supplies[i].supply);
                        if (ret < 0) {
-                               mutex_unlock(&regulator_list_mutex);
                                dev_err(dev, "Failed to set supply %s\n",
                                        init_data->consumer_supplies[i].supply);
                                goto unset_supplies;
                        }
                }
-               mutex_unlock(&regulator_list_mutex);
        }
 
        if (!rdev->desc->ops->get_voltage &&
@@ -5303,13 +5318,11 @@ wash:
        mutex_lock(&regulator_list_mutex);
        regulator_ena_gpio_free(rdev);
        mutex_unlock(&regulator_list_mutex);
-       put_device(&rdev->dev);
-       rdev = NULL;
 clean:
        if (dangling_of_gpiod)
                gpiod_put(config->ena_gpiod);
-       kfree(rdev);
        kfree(config);
+       put_device(&rdev->dev);
 rinse:
        if (dangling_cfg_gpiod)
                gpiod_put(cfg->ena_gpiod);
index 3117bbd..eb3fc1d 100644 (file)
@@ -170,6 +170,9 @@ static int cros_ec_regulator_init_info(struct device *dev,
        data->voltages_mV =
                devm_kmemdup(dev, resp.voltages_mv,
                             sizeof(u16) * data->num_voltages, GFP_KERNEL);
+       if (!data->voltages_mV)
+               return -ENOMEM;
+
        data->desc.n_voltages = data->num_voltages;
 
        /* Make sure the returned name is always a valid string */
index d54830e..142a70a 100644 (file)
@@ -182,7 +182,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
 
                drvdata->enable_clock = devm_clk_get(dev, NULL);
                if (IS_ERR(drvdata->enable_clock)) {
-                       dev_err(dev, "Cant get enable-clock from devicetree\n");
+                       dev_err(dev, "Can't get enable-clock from devicetree\n");
                        return -ENOENT;
                }
        } else {
index 3234b11..990bd50 100644 (file)
@@ -279,7 +279,7 @@ static int pwm_regulator_init_table(struct platform_device *pdev,
                return ret;
        }
 
-       drvdata->state                  = -EINVAL;
+       drvdata->state                  = -ENOTRECOVERABLE;
        drvdata->duty_cycle_table       = duty_cycle_table;
        drvdata->desc.ops = &pwm_regulator_voltage_table_ops;
        drvdata->desc.n_voltages        = length / sizeof(*duty_cycle_table);
index 44e4cec..87b020d 100644 (file)
@@ -319,7 +319,7 @@ static int slg51000_regulator_init(struct slg51000 *chip)
                                rdesc->linear_min_sel = 0;
                                break;
                        }
-                       /* Fall through - to the check below.*/
+                       fallthrough;    /* to the check below */
 
                default:
                        rdesc->linear_min_sel = vsel_range[0];
index f7db250..430265c 100644 (file)
@@ -312,7 +312,7 @@ static int twl6030smps_list_voltage(struct regulator_dev *rdev, unsigned index)
        switch (info->flags) {
        case SMPS_OFFSET_EN:
                voltage = 100000;
-               /* fall through */
+               fallthrough;
        case 0:
                switch (index) {
                case 0:
index 6955fab..d94b739 100644 (file)
@@ -511,7 +511,6 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data)
                dev_info(dev, "received echo reply from %s\n", name);
                break;
        case RP_MBOX_SUSPEND_ACK:
-               /* Fall through */
        case RP_MBOX_SUSPEND_CANCEL:
                oproc->suspend_acked = msg == RP_MBOX_SUSPEND_ACK;
                complete(&oproc->pm_comp);
index d170fe6..e8aa869 100644 (file)
@@ -222,7 +222,7 @@ static int imx8mq_reset_set(struct reset_controller_dev *rcdev,
 
        switch (id) {
        case IMX8MQ_RESET_PCIEPHY:
-       case IMX8MQ_RESET_PCIEPHY2: /* fallthrough */
+       case IMX8MQ_RESET_PCIEPHY2:
                /*
                 * wait for more than 10us to release phy g_rst and
                 * btnrst
@@ -232,12 +232,12 @@ static int imx8mq_reset_set(struct reset_controller_dev *rcdev,
                break;
 
        case IMX8MQ_RESET_PCIE_CTRL_APPS_EN:
-       case IMX8MQ_RESET_PCIE2_CTRL_APPS_EN:   /* fallthrough */
-       case IMX8MQ_RESET_MIPI_DSI_PCLK_RESET_N:        /* fallthrough */
-       case IMX8MQ_RESET_MIPI_DSI_ESC_RESET_N: /* fallthrough */
-       case IMX8MQ_RESET_MIPI_DSI_DPI_RESET_N: /* fallthrough */
-       case IMX8MQ_RESET_MIPI_DSI_RESET_N:     /* fallthrough */
-       case IMX8MQ_RESET_MIPI_DSI_RESET_BYTE_N:        /* fallthrough */
+       case IMX8MQ_RESET_PCIE2_CTRL_APPS_EN:
+       case IMX8MQ_RESET_MIPI_DSI_PCLK_RESET_N:
+       case IMX8MQ_RESET_MIPI_DSI_ESC_RESET_N:
+       case IMX8MQ_RESET_MIPI_DSI_DPI_RESET_N:
+       case IMX8MQ_RESET_MIPI_DSI_RESET_N:
+       case IMX8MQ_RESET_MIPI_DSI_RESET_BYTE_N:
                value = assert ? 0 : bit;
                break;
        }
index 1995f5b..f40312b 100644 (file)
@@ -553,7 +553,7 @@ static void qcom_glink_receive_version(struct qcom_glink *glink,
                break;
        case GLINK_VERSION_1:
                glink->features &= features;
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                qcom_glink_send_version_ack(glink);
                break;
@@ -584,7 +584,7 @@ static void qcom_glink_receive_version_ack(struct qcom_glink *glink,
                        break;
 
                glink->features &= features;
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                qcom_glink_send_version(glink);
                break;
index 9b70b37..8a89bc5 100644 (file)
@@ -740,7 +740,7 @@ static int wdt_ioctl(struct file *file, unsigned int cmd,
                        return -EINVAL;
                wdt_margin = new_margin;
                wdt_ping();
-               /* Fall through */
+               fallthrough;
        case WDIOC_GETTIMEOUT:
                return put_user(wdt_margin, (int __user *)arg);
 
index ca55ba9..f8b99cb 100644 (file)
@@ -353,7 +353,7 @@ static int pcf85063_load_capacitance(struct pcf85063 *pcf85063,
        default:
                dev_warn(&pcf85063->rtc->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 7000",
                         load);
-               /* fall through */
+               fallthrough;
        case 7000:
                break;
        case 12500:
index 47e0f41..57d351d 100644 (file)
@@ -108,7 +108,7 @@ static int pcf8523_load_capacitance(struct i2c_client *client)
        default:
                dev_warn(&client->dev, "Unknown quartz-load-femtofarads value: %d. Assuming 12500",
                         load);
-               /* fall through */
+               fallthrough;
        case 12500:
                value |= REG_CONTROL1_CAP_SEL;
                break;
index c9bc3d4..0a969af 100644 (file)
@@ -331,7 +331,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
        default:
                dev_warn(&pdev->dev,
                         "invalid crystal-freq specified in device-tree. Assuming no crystal\n");
-               /* fall-through */
+               fallthrough;
        case 0:
                /* keep XTAL on in low-power mode */
                pers0_set = STMP3XXX_RTC_PERSISTENT0_XTAL24MHZ_PWRUP;
index 94edbb3..aca0222 100644 (file)
@@ -677,6 +677,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data)
                rc = css_evaluate_known_subchannel(sch, 1);
                if (rc == -EAGAIN)
                        css_schedule_eval(sch->schid);
+               /*
+                * The loop might take long time for platforms with lots of
+                * known devices. Allow scheduling here.
+                */
+               cond_resched();
        }
        return 0;
 }
index 3ce99e4..661d2a4 100644 (file)
@@ -1695,7 +1695,7 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg)
                        grp->changed_side = 2;
                        break;
                }
-               /* Else, fall through */
+               fallthrough;
        case MPCG_STATE_XID0IOWAIX:
        case MPCG_STATE_XID7INITW:
        case MPCG_STATE_XID7INITX:
index ab316ba..85a1a45 100644 (file)
@@ -357,7 +357,7 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int))
                /*fsm_newstate(grp->fsm, MPCG_STATE_XID2INITW);*/
                if (callback)
                        grp->send_qllc_disc = 1;
-               /* Else, fall through */
+               fallthrough;
        case MPCG_STATE_XID0IOWAIT:
                fsm_deltimer(&grp->timer);
                grp->outstanding_xid2 = 0;
@@ -1470,7 +1470,7 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg)
                if ((fsm_getstate(rch->fsm) == CH_XID0_PENDING) &&
                   (fsm_getstate(wch->fsm) == CH_XID0_PENDING))
                        break;
-               /* Else, fall through */
+               fallthrough;
        default:
                fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
        }
@@ -2089,7 +2089,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev)
                        grp->estconnfunc = NULL;
                        break;
                }
-               /* Else, fall through */
+               fallthrough;
        case MPCG_STATE_FLOWC:
        case MPCG_STATE_READY:
                grp->send_qllc_disc = 2;
index bba1b54..6a73982 100644 (file)
@@ -1071,7 +1071,7 @@ static void qeth_issue_next_read_cb(struct qeth_card *card,
                break;
        case -EIO:
                qeth_schedule_recovery(card);
-               /* fall through */
+               fallthrough;
        default:
                qeth_clear_ipacmd_list(card);
                goto err_idx;
@@ -2886,7 +2886,7 @@ void qeth_print_status_message(struct qeth_card *card)
                                card->info.mcl_level[3]);
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case QETH_CARD_TYPE_IQD:
                if (IS_VM_NIC(card) || (card->info.mcl_level[0] & 0x80)) {
                        card->info.mcl_level[0] = (char) _ebcasc[(__u8)
index ebdc032..f870c53 100644 (file)
@@ -356,7 +356,7 @@ static void qeth_set_cmd_adv_sup(struct ethtool_link_ksettings *cmd,
                                                     10000baseT_Full);
                ethtool_link_ksettings_add_link_mode(cmd, advertising,
                                                     10000baseT_Full);
-               /* fall through */
+               fallthrough;
        case SPEED_1000:
                ethtool_link_ksettings_add_link_mode(cmd, supported,
                                                     1000baseT_Full);
@@ -366,7 +366,7 @@ static void qeth_set_cmd_adv_sup(struct ethtool_link_ksettings *cmd,
                                                     1000baseT_Half);
                ethtool_link_ksettings_add_link_mode(cmd, advertising,
                                                     1000baseT_Half);
-               /* fall through */
+               fallthrough;
        case SPEED_100:
                ethtool_link_ksettings_add_link_mode(cmd, supported,
                                                     100baseT_Full);
@@ -376,7 +376,7 @@ static void qeth_set_cmd_adv_sup(struct ethtool_link_ksettings *cmd,
                                                     100baseT_Half);
                ethtool_link_ksettings_add_link_mode(cmd, advertising,
                                                     100baseT_Half);
-               /* fall through */
+               fallthrough;
        case SPEED_10:
                ethtool_link_ksettings_add_link_mode(cmd, supported,
                                                     10baseT_Full);
index 8b342a8..3a94f6c 100644 (file)
@@ -488,7 +488,7 @@ static void qeth_l2_rx_mode_work(struct work_struct *work)
                                kfree(mac);
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        /* for next call to set_rx_mode(): */
                        mac->disp_flag = QETH_DISP_ADDR_DELETE;
index fe44b02..4d46196 100644 (file)
@@ -1235,7 +1235,7 @@ static void qeth_l3_rx_mode_work(struct work_struct *work)
                                        break;
                                }
                                addr->ref_counter = 1;
-                               /* fall through */
+                               fallthrough;
                        default:
                                /* for next call to set_rx_mode(): */
                                addr->disp_flag = QETH_DISP_ADDR_DELETE;
index c795f22..140186f 100644 (file)
@@ -434,7 +434,7 @@ static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
                return;
        }
 
-       del_timer(&req->timer);
+       del_timer_sync(&req->timer);
        zfcp_fsf_protstatus_eval(req);
        zfcp_fsf_fsfstatus_eval(req);
        req->handler(req);
@@ -867,7 +867,7 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
        req->qdio_req.qdio_outb_usage = atomic_read(&qdio->req_q_free);
        req->issued = get_tod_clock();
        if (zfcp_qdio_send(qdio, &req->qdio_req)) {
-               del_timer(&req->timer);
+               del_timer_sync(&req->timer);
                /* lookup request again, list might have changed */
                zfcp_reqlist_find_rm(adapter->req_list, req_id);
                zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1");
index 461b3ba..84b57a8 100644 (file)
@@ -1832,7 +1832,7 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *)
        case REQUEST_SENSE:
                /* clear the internal sense magic */
                SCp->cmnd[6] = 0;
-               /* fall through */
+               fallthrough;
        default:
                /* OK, get it from the command */
                switch(SCp->sc_data_direction) {
index bb49d83..ccb061a 100644 (file)
@@ -2635,7 +2635,7 @@ static int blogic_resultcode(struct blogic_adapter *adapter,
        case BLOGIC_BAD_CMD_PARAM:
                blogic_warn("BusLogic Driver Protocol Error 0x%02X\n",
                                adapter, adapter_status);
-               /* fall through */
+               fallthrough;
        case BLOGIC_DATA_UNDERRUN:
        case BLOGIC_DATA_OVERRUN:
        case BLOGIC_NOEXPECT_BUSFREE:
index 0f17bd5..24ace18 100644 (file)
@@ -1034,11 +1034,14 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
                        temp6 >>= 1;
                        switch (temp & 0x3) {
                        case AUTO_RATE_20:      /* Synchronous, 20 mega-transfers/second */
-                               temp6 |= 0x8000;        /* Fall through */
+                               temp6 |= 0x8000;
+                               fallthrough;
                        case AUTO_RATE_10:      /* Synchronous, 10 mega-transfers/second */
-                               temp5 |= 0x8000;        /* Fall through */
+                               temp5 |= 0x8000;
+                               fallthrough;
                        case AUTO_RATE_05:      /* Synchronous, 5 mega-transfers/second */
-                               temp2 |= 0x8000;        /* Fall through */
+                               temp2 |= 0x8000;
+                               fallthrough;
                        case AUTO_RATE_00:      /* Asynchronous */
                                break;
                        }
index f2f7e6e..d654a6c 100644 (file)
@@ -1943,7 +1943,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
                                                return;
 
                                        /* Reject message */
-                                       /* Fall through */
+                                       fallthrough;
                                default:
                                        /*
                                         * If we get something weird that we aren't expecting,
index 769af4c..fd6ae5c 100644 (file)
@@ -2809,7 +2809,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                                            !(dev->raw_io_64) ||
                                            ((scsicmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
                                                break;
-                                       /* fall through */
+                                       fallthrough;
                                case INQUIRY:
                                case READ_CAPACITY:
                                case TEST_UNIT_READY:
@@ -2884,7 +2884,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                /* Issue FIB to tell Firmware to flush it's cache */
                if ((aac_cache & 6) != 2)
                        return aac_synchronize(scsicmd);
-               /* fall through */
+               fallthrough;
        case INQUIRY:
        {
                struct inquiry_data inq_data;
@@ -3240,7 +3240,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
                                     SCSI_SENSE_BUFFERSIZE));
                        break;
                }
-               /* fall through */
+               fallthrough;
        case RESERVE:
        case RELEASE:
        case REZERO_UNIT:
@@ -3253,7 +3253,7 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
        case START_STOP:
                return aac_start_stop(scsicmd);
 
-       /* FALLTHRU */
+               fallthrough;
        default:
        /*
         *      Unhandled commands
index adbdc3b..383e74f 100644 (file)
@@ -1431,7 +1431,7 @@ retry_next:
                                                "enclosure services event");
                                scsi_device_set_state(device, SDEV_RUNNING);
                        }
-                       /* FALLTHRU */
+                       fallthrough;
                case CHANGE:
                        if ((channel == CONTAINER_CHANNEL)
                         && (!dev->fsa_dev[container].valid)) {
index 8588da0..a3aee14 100644 (file)
@@ -765,7 +765,7 @@ static int aac_eh_abort(struct scsi_cmnd* cmd)
                            !(aac->raw_io_64) ||
                            ((cmd->cmnd[1] & 0x1f) != SAI_READ_CAPACITY_16))
                                break;
-                       /* fall through */
+                       fallthrough;
                case INQUIRY:
                case READ_CAPACITY:
                        /*
index c912d29..1c617c0 100644 (file)
@@ -2274,7 +2274,7 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
                        switch (scb->hscb->task_management) {
                        case SIU_TASKMGMT_ABORT_TASK:
                                tag = SCB_GET_TAG(scb);
-                               /* fall through */
+                               fallthrough;
                        case SIU_TASKMGMT_ABORT_TASK_SET:
                        case SIU_TASKMGMT_CLEAR_TASK_SET:
                                lun = scb->hscb->lun;
@@ -2285,7 +2285,7 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
                                break;
                        case SIU_TASKMGMT_LUN_RESET:
                                lun = scb->hscb->lun;
-                               /* fall through */
+                               fallthrough;
                        case SIU_TASKMGMT_TARGET_RESET:
                        {
                                struct ahd_devinfo devinfo;
@@ -3791,7 +3791,7 @@ ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
                        *bus_width = MSG_EXT_WDTR_BUS_16_BIT;
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case MSG_EXT_WDTR_BUS_8_BIT:
                *bus_width = MSG_EXT_WDTR_BUS_8_BIT;
                break;
@@ -5104,7 +5104,7 @@ ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
                break;
        case MSG_MESSAGE_REJECT:
                response = ahd_handle_msg_reject(ahd, devinfo);
-               /* FALLTHROUGH */
+               fallthrough;
        case MSG_NOOP:
                done = MSGLOOP_MSGCOMPLETE;
                break;
@@ -5454,7 +5454,7 @@ ahd_parse_msg(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
                               ahd_name(ahd), ahd_inb(ahd, SCSISIGI));
 #endif
                ahd->msg_flags |= MSG_FLAG_EXPECT_QASREJ_BUSFREE;
-               /* FALLTHROUGH */
+               fallthrough;
        case MSG_TERM_IO_PROC:
        default:
                reject = TRUE;
@@ -6117,17 +6117,17 @@ ahd_free(struct ahd_softc *ahd)
        default:
        case 5:
                ahd_shutdown(ahd);
-               /* FALLTHROUGH */
+               fallthrough;
        case 4:
                ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
                                  ahd->shared_data_map.dmamap);
-               /* FALLTHROUGH */
+               fallthrough;
        case 3:
                ahd_dmamem_free(ahd, ahd->shared_data_dmat, ahd->qoutfifo,
                                ahd->shared_data_map.dmamap);
                ahd_dmamap_destroy(ahd, ahd->shared_data_dmat,
                                   ahd->shared_data_map.dmamap);
-               /* FALLTHROUGH */
+               fallthrough;
        case 2:
                ahd_dma_tag_destroy(ahd, ahd->shared_data_dmat);
        case 1:
@@ -6513,7 +6513,7 @@ ahd_fini_scbdata(struct ahd_softc *ahd)
                }
                ahd_dma_tag_destroy(ahd, scb_data->sense_dmat);
        }
-               /* fall through */
+               fallthrough;
        case 6:
        {
                struct map_node *sg_map;
@@ -6528,7 +6528,7 @@ ahd_fini_scbdata(struct ahd_softc *ahd)
                }
                ahd_dma_tag_destroy(ahd, scb_data->sg_dmat);
        }
-               /* fall through */
+               fallthrough;
        case 5:
        {
                struct map_node *hscb_map;
@@ -7171,7 +7171,7 @@ ahd_init(struct ahd_softc *ahd)
                case FLX_CSTAT_OVER:
                case FLX_CSTAT_UNDER:
                        warn_user++;
-                       /* fall through */
+                       fallthrough;
                case FLX_CSTAT_INVALID:
                case FLX_CSTAT_OKAY:
                        if (warn_user == 0 && bootverbose == 0)
@@ -8175,12 +8175,12 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
                                if ((scb->flags & SCB_ACTIVE) == 0)
                                        printk("Inactive SCB in qinfifo\n");
                                ahd_done_with_status(ahd, scb, status);
-                               /* FALLTHROUGH */
+                               fallthrough;
                        case SEARCH_REMOVE:
                                break;
                        case SEARCH_PRINT:
                                printk(" 0x%x", ahd->qinfifo[qinpos]);
-                               /* FALLTHROUGH */
+                               fallthrough;
                        case SEARCH_COUNT:
                                ahd_qinfifo_requeue(ahd, prev_scb, scb);
                                prev_scb = scb;
@@ -8271,7 +8271,7 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
                                if ((mk_msg_scb->flags & SCB_ACTIVE) == 0)
                                        printk("Inactive SCB pending MK_MSG\n");
                                ahd_done_with_status(ahd, mk_msg_scb, status);
-                               /* FALLTHROUGH */
+                               fallthrough;
                        case SEARCH_REMOVE:
                        {
                                u_int tail_offset;
@@ -8295,7 +8295,7 @@ ahd_search_qinfifo(struct ahd_softc *ahd, int target, char channel,
                        }
                        case SEARCH_PRINT:
                                printk(" 0x%x", SCB_GET_TAG(scb));
-                               /* FALLTHROUGH */
+                               fallthrough;
                        case SEARCH_COUNT:
                                break;
                        }
@@ -8376,7 +8376,7 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
                        if ((scb->flags & SCB_ACTIVE) == 0)
                                printk("Inactive SCB in Waiting List\n");
                        ahd_done_with_status(ahd, scb, status);
-                       /* fall through */
+                       fallthrough;
                case SEARCH_REMOVE:
                        ahd_rem_wscb(ahd, scbid, prev, next, tid);
                        *list_tail = prev;
@@ -8385,7 +8385,7 @@ ahd_search_scb_list(struct ahd_softc *ahd, int target, char channel,
                        break;
                case SEARCH_PRINT:
                        printk("0x%x ", scbid);
-                       /* fall through */
+                       fallthrough;
                case SEARCH_COUNT:
                        prev = scbid;
                        break;
@@ -9023,7 +9023,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
        case SCSI_STATUS_OK:
                printk("%s: Interrupted for status of 0???\n",
                       ahd_name(ahd));
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                ahd_done(ahd, scb);
                break;
@@ -9512,7 +9512,7 @@ ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
                fmt3_ins = &instr.format3;
                fmt3_ins->address = ahd_resolve_seqaddr(ahd, fmt3_ins->address);
        }
-               /* fall through */
+               fallthrough;
        case AIC_OP_OR:
        case AIC_OP_AND:
        case AIC_OP_XOR:
@@ -9523,7 +9523,7 @@ ahd_download_instr(struct ahd_softc *ahd, u_int instrptr, uint8_t *dconsts)
                        fmt1_ins->immediate = dconsts[fmt1_ins->immediate];
                }
                fmt1_ins->parity = 0;
-               /* fall through */
+               fallthrough;
        case AIC_OP_ROL:
        {
                int i, count;
index d019e3f..7c32130 100644 (file)
@@ -2035,7 +2035,7 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)
                break;
        case CAM_AUTOSENSE_FAIL:
                new_status = DID_ERROR;
-               /* Fallthrough */
+               fallthrough;
        case CAM_SCSI_STATUS_ERROR:
                scsi_status = ahd_cmd_get_scsi_status(cmd);
 
index 3d4df90..2231c4a 100644 (file)
@@ -2404,7 +2404,7 @@ ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo,
                        *bus_width = MSG_EXT_WDTR_BUS_16_BIT;
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case MSG_EXT_WDTR_BUS_8_BIT:
                *bus_width = MSG_EXT_WDTR_BUS_8_BIT;
                break;
@@ -3599,7 +3599,7 @@ ahc_parse_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo)
                break;
        case MSG_MESSAGE_REJECT:
                response = ahc_handle_msg_reject(ahc, devinfo);
-               /* FALLTHROUGH */
+               fallthrough;
        case MSG_NOOP:
                done = MSGLOOP_MSGCOMPLETE;
                break;
@@ -4465,17 +4465,17 @@ ahc_free(struct ahc_softc *ahc)
        default:
        case 5:
                ahc_shutdown(ahc);
-               /* FALLTHROUGH */
+               fallthrough;
        case 4:
                ahc_dmamap_unload(ahc, ahc->shared_data_dmat,
                                  ahc->shared_data_dmamap);
-               /* FALLTHROUGH */
+               fallthrough;
        case 3:
                ahc_dmamem_free(ahc, ahc->shared_data_dmat, ahc->qoutfifo,
                                ahc->shared_data_dmamap);
                ahc_dmamap_destroy(ahc, ahc->shared_data_dmat,
                                   ahc->shared_data_dmamap);
-               /* FALLTHROUGH */
+               fallthrough;
        case 2:
                ahc_dma_tag_destroy(ahc, ahc->shared_data_dmat);
        case 1:
@@ -4893,30 +4893,30 @@ ahc_fini_scbdata(struct ahc_softc *ahc)
                }
                ahc_dma_tag_destroy(ahc, scb_data->sg_dmat);
        }
-               /* fall through */
+               fallthrough;
        case 6:
                ahc_dmamap_unload(ahc, scb_data->sense_dmat,
                                  scb_data->sense_dmamap);
-               /* fall through */
+               fallthrough;
        case 5:
                ahc_dmamem_free(ahc, scb_data->sense_dmat, scb_data->sense,
                                scb_data->sense_dmamap);
                ahc_dmamap_destroy(ahc, scb_data->sense_dmat,
                                   scb_data->sense_dmamap);
-               /* fall through */
+               fallthrough;
        case 4:
                ahc_dma_tag_destroy(ahc, scb_data->sense_dmat);
-               /* fall through */
+               fallthrough;
        case 3:
                ahc_dmamap_unload(ahc, scb_data->hscb_dmat,
                                  scb_data->hscb_dmamap);
-               /* fall through */
+               fallthrough;
        case 2:
                ahc_dmamem_free(ahc, scb_data->hscb_dmat, scb_data->hscbs,
                                scb_data->hscb_dmamap);
                ahc_dmamap_destroy(ahc, scb_data->hscb_dmat,
                                   scb_data->hscb_dmamap);
-               /* fall through */
+               fallthrough;
        case 1:
                ahc_dma_tag_destroy(ahc, scb_data->hscb_dmat);
                break;
@@ -5981,7 +5981,7 @@ ahc_search_qinfifo(struct ahc_softc *ahc, int target, char channel,
                                        printk("Inactive SCB in Waiting List\n");
                                ahc_done(ahc, scb);
                        }
-                               /* fall through */
+                               fallthrough;
                        case SEARCH_REMOVE:
                                next = ahc_rem_wscb(ahc, next, prev);
                                break;
@@ -6987,7 +6987,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
                address -= address_offset;
                fmt3_ins->address = address;
        }
-               /* fall through */
+               fallthrough;
        case AIC_OP_OR:
        case AIC_OP_AND:
        case AIC_OP_XOR:
@@ -7013,7 +7013,7 @@ ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts)
                        fmt1_ins->opcode = AIC_OP_AND;
                        fmt1_ins->immediate = 0xff;
                }
-               /* fall through */
+               fallthrough;
        case AIC_OP_ROL:
                if ((ahc->features & AHC_ULTRA2) != 0) {
                        int i, count;
index c264b4b..e2d880a 100644 (file)
@@ -706,11 +706,11 @@ static void set_speed_mask(u8 *speed_mask, struct asd_phy_desc *pd)
        switch (pd->max_sas_lrate) {
        case SAS_LINK_RATE_6_0_GBPS:
                *speed_mask &= ~SAS_SPEED_60_DIS;
-               /* fall through*/
+               fallthrough;
        default:
        case SAS_LINK_RATE_3_0_GBPS:
                *speed_mask &= ~SAS_SPEED_30_DIS;
-               /* fall through*/
+               fallthrough;
        case SAS_LINK_RATE_1_5_GBPS:
                *speed_mask &= ~SAS_SPEED_15_DIS;
        }
@@ -718,7 +718,7 @@ static void set_speed_mask(u8 *speed_mask, struct asd_phy_desc *pd)
        switch (pd->min_sas_lrate) {
        case SAS_LINK_RATE_6_0_GBPS:
                *speed_mask |= SAS_SPEED_30_DIS;
-               /* fall through*/
+               fallthrough;
        case SAS_LINK_RATE_3_0_GBPS:
                *speed_mask |= SAS_SPEED_15_DIS;
        default:
@@ -730,7 +730,7 @@ static void set_speed_mask(u8 *speed_mask, struct asd_phy_desc *pd)
        switch (pd->max_sata_lrate) {
        case SAS_LINK_RATE_3_0_GBPS:
                *speed_mask &= ~SATA_SPEED_30_DIS;
-               /* fall through*/
+               fallthrough;
        default:
        case SAS_LINK_RATE_1_5_GBPS:
                *speed_mask &= ~SATA_SPEED_15_DIS;
@@ -789,7 +789,7 @@ void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc)
 
                /* link reset retries, this should be nominal */
                control_phy->link_reset_retries = 10;
-               /* fall through */
+               fallthrough;
 
        case RELEASE_SPINUP_HOLD: /* 0x02 */
                /* decide the func_mask */
index 1fcee65..0eb6e20 100644 (file)
@@ -490,7 +490,7 @@ int asd_abort_task(struct sas_task *task)
                switch (tcs.dl_opcode) {
                default:
                        res = asd_clear_nexus(task);
-                       /* fallthrough */
+                       fallthrough;
                case TC_NO_ERROR:
                        break;
                        /* The task hasn't been sent to the device xor
index fa562a0..ec895d0 100644 (file)
@@ -4470,7 +4470,7 @@ static const char *arcmsr_info(struct Scsi_Host *host)
        case PCI_DEVICE_ID_ARECA_1202:
        case PCI_DEVICE_ID_ARECA_1210:
                raid6 = 0;
-               /*FALLTHRU*/
+               fallthrough;
        case PCI_DEVICE_ID_ARECA_1120:
        case PCI_DEVICE_ID_ARECA_1130:
        case PCI_DEVICE_ID_ARECA_1160:
index 6c68c23..2e687ce 100644 (file)
@@ -603,7 +603,7 @@ static void fas216_handlesync(FAS216_Info *info, char *msg)
                msgqueue_flush(&info->scsi.msgs);
                msgqueue_addmsg(&info->scsi.msgs, 1, MESSAGE_REJECT);
                info->scsi.phase = PHASE_MSGOUT_EXPECT;
-               /* fall through */
+               fallthrough;
 
        case async:
                dev->period = info->ifcfg.asyncperiod / 4;
@@ -916,7 +916,7 @@ static void fas216_disconnect_intr(FAS216_Info *info)
                        fas216_done(info, DID_ABORT);
                        break;
                }
-               /* else, fall through */
+               fallthrough;
 
        default:                                /* huh?                                 */
                printk(KERN_ERR "scsi%d.%c: unexpected disconnect in phase %s\n",
@@ -1413,7 +1413,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
        case STATE(STAT_STATUS, PHASE_DATAOUT): /* Data Out     -> Status       */
        case STATE(STAT_STATUS, PHASE_DATAIN):  /* Data In      -> Status       */
                fas216_stoptransfer(info);
-               /* fall through */
+               fallthrough;
 
        case STATE(STAT_STATUS, PHASE_SELSTEPS):/* Sel w/ steps -> Status       */
        case STATE(STAT_STATUS, PHASE_MSGOUT):  /* Message Out  -> Status       */
@@ -1426,7 +1426,7 @@ static void fas216_busservice_intr(FAS216_Info *info, unsigned int stat, unsigne
        case STATE(STAT_MESGIN, PHASE_DATAOUT): /* Data Out     -> Message In   */
        case STATE(STAT_MESGIN, PHASE_DATAIN):  /* Data In      -> Message In   */
                fas216_stoptransfer(info);
-               /* fall through */
+               fallthrough;
 
        case STATE(STAT_MESGIN, PHASE_COMMAND): /* Command      -> Message In   */
        case STATE(STAT_MESGIN, PHASE_SELSTEPS):/* Sel w/ steps -> Message In   */
@@ -1581,7 +1581,7 @@ static void fas216_funcdone_intr(FAS216_Info *info, unsigned int stat, unsigned
                        fas216_message(info);
                        break;
                }
-               /* else, fall through */
+               fallthrough;
 
        default:
                fas216_log(info, 0, "internal phase %s for function done?"
@@ -1964,7 +1964,7 @@ static void fas216_kick(FAS216_Info *info)
        switch (where_from) {
        case TYPE_QUEUE:
                fas216_allocate_tag(info, SCpnt);
-               /* fall through */
+               fallthrough;
        case TYPE_OTHER:
                fas216_start_command(info, SCpnt);
                break;
index 93da634..a13c203 100644 (file)
@@ -677,7 +677,7 @@ int beiscsi_set_param(struct iscsi_cls_conn *cls_conn,
        case ISCSI_PARAM_MAX_XMIT_DLENGTH:
                if (conn->max_xmit_dlength > 65536)
                        conn->max_xmit_dlength = 65536;
-               /* fall through */
+               fallthrough;
        default:
                return 0;
        }
index 8dc2e08..5c3513a 100644 (file)
@@ -1532,7 +1532,7 @@ beiscsi_hdl_get_handle(struct beiscsi_conn *beiscsi_conn,
                break;
        case UNSOL_DATA_DIGEST_ERROR_NOTIFY:
                error = 1;
-               /* fall through */
+               fallthrough;
        case UNSOL_DATA_NOTIFY:
                pasync_handle = pasync_ctx->async_entry[ci].data;
                break;
index 29f9956..38d1c45 100644 (file)
@@ -2572,7 +2572,7 @@ bfa_ioim_send_ioreq(struct bfa_ioim_s *ioim)
        case FCP_IODIR_RW:
                bfa_stats(itnim, input_reqs);
                bfa_stats(itnim, output_reqs);
-               /* fall through */
+               fallthrough;
        default:
                bfi_h2i_set(m->mh, BFI_MC_IOIM_IO, 0, bfa_fn_lpu(ioim->bfa));
        }
@@ -2807,7 +2807,7 @@ bfa_ioim_isr(struct bfa_s *bfa, struct bfi_msg_s *m)
 
        case BFI_IOIM_STS_TIMEDOUT:
                bfa_stats(ioim->itnim, iocomp_timedout);
-               /* fall through */
+               fallthrough;
        case BFI_IOIM_STS_ABORTED:
                rsp->io_status = BFI_IOIM_STS_ABORTED;
                bfa_stats(ioim->itnim, iocomp_aborted);
@@ -3203,7 +3203,7 @@ bfa_tskim_sm_cleanup_qfull(struct bfa_tskim_s *tskim,
        switch (event) {
        case BFA_TSKIM_SM_DONE:
                bfa_reqq_wcancel(&tskim->reqq_wait);
-               /* fall through */
+               fallthrough;
        case BFA_TSKIM_SM_QRESUME:
                bfa_sm_set_state(tskim, bfa_tskim_sm_cleanup);
                bfa_tskim_send_abort(tskim);
index 297a77f..3486e40 100644 (file)
@@ -6422,7 +6422,7 @@ bfa_fcs_vport_sm_logo_for_stop(struct bfa_fcs_vport_s *vport,
        switch (event) {
        case BFA_FCS_VPORT_SM_OFFLINE:
                bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
-               /* fall through */
+               fallthrough;
 
        case BFA_FCS_VPORT_SM_RSP_OK:
        case BFA_FCS_VPORT_SM_RSP_ERROR:
@@ -6448,7 +6448,7 @@ bfa_fcs_vport_sm_logo(struct bfa_fcs_vport_s *vport,
        switch (event) {
        case BFA_FCS_VPORT_SM_OFFLINE:
                bfa_sm_send_event(vport->lps, BFA_LPS_SM_OFFLINE);
-               /* fall through */
+               fallthrough;
 
        case BFA_FCS_VPORT_SM_RSP_OK:
        case BFA_FCS_VPORT_SM_RSP_ERROR:
index 143c35b..c21aa37 100644 (file)
@@ -419,13 +419,13 @@ bfa_fcs_rport_sm_plogi(struct bfa_fcs_rport_s *rport, enum rport_event event)
 
        case RPSM_EVENT_LOGO_RCVD:
                bfa_fcs_rport_send_logo_acc(rport);
-               /* fall through */
+               fallthrough;
        case RPSM_EVENT_PRLO_RCVD:
                if (rport->prlo == BFA_TRUE)
                        bfa_fcs_rport_send_prlo_acc(rport);
 
                bfa_fcxp_discard(rport->fcxp);
-               /* fall through */
+               fallthrough;
        case RPSM_EVENT_FAILED:
                if (rport->plogi_retries < BFA_FCS_RPORT_MAX_RETRIES) {
                        rport->plogi_retries++;
@@ -856,7 +856,7 @@ bfa_fcs_rport_sm_adisc_online(struct bfa_fcs_rport_s *rport,
                 * At least go offline when a PLOGI is received.
                 */
                bfa_fcxp_discard(rport->fcxp);
-               /* fall through */
+               fallthrough;
 
        case RPSM_EVENT_FAILED:
        case RPSM_EVENT_ADDRESS_CHANGE:
@@ -1042,7 +1042,7 @@ bfa_fcs_rport_sm_fc4_logosend(struct bfa_fcs_rport_s *rport,
 
        case RPSM_EVENT_LOGO_RCVD:
                bfa_fcs_rport_send_logo_acc(rport);
-               /* fall through */
+               fallthrough;
        case RPSM_EVENT_PRLO_RCVD:
                if (rport->prlo == BFA_TRUE)
                        bfa_fcs_rport_send_prlo_acc(rport);
@@ -1131,7 +1131,7 @@ bfa_fcs_rport_sm_hcb_offline(struct bfa_fcs_rport_s *rport,
                        bfa_fcs_rport_send_plogiacc(rport, NULL);
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case RPSM_EVENT_ADDRESS_CHANGE:
                if (!bfa_fcs_lport_is_online(rport->port)) {
@@ -1288,7 +1288,7 @@ bfa_fcs_rport_sm_hcb_logosend(struct bfa_fcs_rport_s *rport,
 
        case RPSM_EVENT_LOGO_RCVD:
                bfa_fcs_rport_send_logo_acc(rport);
-               /* fall through */
+               fallthrough;
        case RPSM_EVENT_PRLO_RCVD:
                if (rport->prlo == BFA_TRUE)
                        bfa_fcs_rport_send_prlo_acc(rport);
@@ -1332,7 +1332,7 @@ bfa_fcs_rport_sm_logo_sending(struct bfa_fcs_rport_s *rport,
 
        case RPSM_EVENT_LOGO_RCVD:
                bfa_fcs_rport_send_logo_acc(rport);
-               /* fall through */
+               fallthrough;
        case RPSM_EVENT_PRLO_RCVD:
                if (rport->prlo == BFA_TRUE)
                        bfa_fcs_rport_send_prlo_acc(rport);
index dd5821d..325ad8a 100644 (file)
@@ -969,7 +969,7 @@ bfa_iocpf_sm_enabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
 
        case IOCPF_E_INITFAIL:
                bfa_iocpf_timer_stop(ioc);
-               /* fall through */
+               fallthrough;
 
        case IOCPF_E_TIMEOUT:
                writel(1, ioc->ioc_regs.ioc_sem_reg);
@@ -1045,7 +1045,7 @@ bfa_iocpf_sm_disabling(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
 
        case IOCPF_E_FAIL:
                bfa_iocpf_timer_stop(ioc);
-               /* fall through */
+               fallthrough;
 
        case IOCPF_E_TIMEOUT:
                bfa_ioc_set_cur_ioc_fwstate(ioc, BFI_IOC_FAIL);
@@ -5988,7 +5988,7 @@ bfa_dconf_sm_final_sync(struct bfa_dconf_mod_s *dconf,
        case BFA_DCONF_SM_IOCDISABLE:
        case BFA_DCONF_SM_FLASH_COMP:
                bfa_timer_stop(&dconf->timer);
-               /* fall through */
+               fallthrough;
        case BFA_DCONF_SM_TIMEOUT:
                bfa_sm_set_state(dconf, bfa_dconf_sm_uninit);
                bfa_fsm_send_event(&dconf->bfa->iocfc, IOCFC_E_DCONF_DONE);
index 1e266c1..11c0c3e 100644 (file)
@@ -6397,7 +6397,7 @@ bfa_dport_sm_starting(struct bfa_dport_s *dport, enum bfa_dport_sm_event event)
                        dport->test_state = BFA_DPORT_ST_INP;
                        bfa_dport_result_start(dport, BFA_DPORT_OPMODE_MANU);
                }
-               /* fall thru */
+               fallthrough;
 
        case BFA_DPORT_SM_REQFAIL:
                bfa_sm_set_state(dport, bfa_dport_sm_enabled);
index e72d7bb..0899209 100644 (file)
@@ -1404,7 +1404,6 @@ void bnx2fc_indicate_kcqe(void *context, struct kcqe *kcq[],
                        break;
 
                case FCOE_KCQE_OPCODE_FCOE_ERROR:
-                       /* fall thru */
                default:
                        printk(KERN_ERR PFX "unknown opcode 0x%x\n",
                                                                kcqe->op_code);
index 98d4d39..7fa2060 100644 (file)
@@ -2939,7 +2939,7 @@ csio_hws_quiescing(struct csio_hw *hw, enum csio_hw_ev evt)
                case CSIO_HWE_FW_DLOAD:
                        csio_set_state(&hw->sm, csio_hws_resetting);
                        /* Download firmware */
-                       /* Fall through */
+                       fallthrough;
 
                case CSIO_HWE_HBA_RESET:
                        csio_set_state(&hw->sm, csio_hws_resetting);
index 61cf542..dc98f51 100644 (file)
@@ -1187,7 +1187,6 @@ csio_lns_online(struct csio_lnode *ln, enum csio_ln_ev evt)
                break;
 
        case CSIO_LNE_LINK_DOWN:
-               /* Fall through */
        case CSIO_LNE_DOWN_LINK:
                csio_set_state(&ln->sm, csio_lns_uninit);
                if (csio_is_phys_ln(ln)) {
index 0ca6951..9010cb6 100644 (file)
@@ -808,7 +808,7 @@ csio_wr_destroy_queues(struct csio_hw *hw, bool cmd)
 
                                csio_q_eqid(hw, i) = CSIO_MAX_QID;
                        }
-                       /* fall through */
+                       fallthrough;
                case CSIO_INGRESS:
                        if (csio_q_iqid(hw, i) != CSIO_MAX_QID) {
                                csio_wr_cleanup_iq_ftr(hw, i);
index 2b48954..37d9935 100644 (file)
@@ -643,7 +643,7 @@ static int abort_status_to_errno(struct cxgbi_sock *csk, int abort_reason,
                                 int *need_rst)
 {
        switch (abort_reason) {
-       case CPL_ERR_BAD_SYN: /* fall through */
+       case CPL_ERR_BAD_SYN:
        case CPL_ERR_CONN_RESET:
                return csk->state > CTP_ESTABLISHED ? -EPIPE : -ECONNRESET;
        case CPL_ERR_XMIT_TIMEDOUT:
index 4e82c14..2c34915 100644 (file)
@@ -1133,7 +1133,7 @@ static int abort_status_to_errno(struct cxgbi_sock *csk, int abort_reason,
                                                                int *need_rst)
 {
        switch (abort_reason) {
-       case CPL_ERR_BAD_SYN: /* fall through */
+       case CPL_ERR_BAD_SYN:
        case CPL_ERR_CONN_RESET:
                return csk->state > CTP_ESTABLISHED ?
                        -EPIPE : -ECONNRESET;
index 71aebaf..0e8621a 100644 (file)
@@ -2457,10 +2457,10 @@ int cxgbi_conn_xmit_pdu(struct iscsi_task *task)
                return err;
        }
 
-       __kfree_skb(skb);
        log_debug(1 << CXGBI_DBG_ISCSI | 1 << CXGBI_DBG_PDU_TX,
                  "itt 0x%x, skb 0x%p, len %u/%u, xmit err %d.\n",
                  task->itt, skb, skb->len, skb->data_len, err);
+       __kfree_skb(skb);
        iscsi_conn_printk(KERN_ERR, task->conn, "xmit err %d.\n", err);
        iscsi_conn_failure(task->conn, ISCSI_ERR_XMIT_FAILED);
        return err;
index 94250eb..e72440d 100644 (file)
@@ -748,16 +748,16 @@ static void term_intr(struct cxlflash_cfg *cfg, enum undo_level level,
                /* SISL_MSI_ASYNC_ERROR is setup only for the primary HWQ */
                if (index == PRIMARY_HWQ)
                        cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 3, hwq);
-               /* fall through */
+               fallthrough;
        case UNMAP_TWO:
                cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 2, hwq);
-               /* fall through */
+               fallthrough;
        case UNMAP_ONE:
                cfg->ops->unmap_afu_irq(hwq->ctx_cookie, 1, hwq);
-               /* fall through */
+               fallthrough;
        case FREE_IRQ:
                cfg->ops->free_afu_irqs(hwq->ctx_cookie);
-               /* fall through */
+               fallthrough;
        case UNDO_NOOP:
                /* No action required */
                break;
@@ -971,18 +971,18 @@ static void cxlflash_remove(struct pci_dev *pdev)
        switch (cfg->init_state) {
        case INIT_STATE_CDEV:
                cxlflash_release_chrdev(cfg);
-               /* fall through */
+               fallthrough;
        case INIT_STATE_SCSI:
                cxlflash_term_local_luns(cfg);
                scsi_remove_host(cfg->host);
-               /* fall through */
+               fallthrough;
        case INIT_STATE_AFU:
                term_afu(cfg);
-               /* fall through */
+               fallthrough;
        case INIT_STATE_PCI:
                cfg->ops->destroy_afu(cfg->afu_cookie);
                pci_disable_device(pdev);
-               /* fall through */
+               fallthrough;
        case INIT_STATE_NONE:
                free_mem(cfg);
                scsi_host_put(cfg->host);
@@ -2355,11 +2355,11 @@ retry:
                        cxlflash_schedule_async_reset(cfg);
                        break;
                }
-               /* fall through - to retry */
+               fallthrough;    /* to retry */
        case -EAGAIN:
                if (++nretry < 2)
                        goto retry;
-               /* fall through - to exit */
+               fallthrough;    /* to exit */
        default:
                break;
        }
@@ -2533,12 +2533,12 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp)
                        cfg->state = STATE_NORMAL;
                wake_up_all(&cfg->reset_waitq);
                ssleep(1);
-               /* fall through */
+               fallthrough;
        case STATE_RESET:
                wait_event(cfg->reset_waitq, cfg->state != STATE_RESET);
                if (cfg->state == STATE_NORMAL)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                rc = FAILED;
                break;
@@ -3019,7 +3019,7 @@ retry:
                wait_event(cfg->reset_waitq, cfg->state != STATE_RESET);
                if (cfg->state == STATE_NORMAL)
                        goto retry;
-               /* else, fall through */
+               fallthrough;
        default:
                /* Ideally should not happen */
                dev_err(dev, "%s: Device is not ready, state=%d\n",
@@ -3531,7 +3531,7 @@ static long cxlflash_chr_ioctl(struct file *file, unsigned int cmd,
                if (likely(do_ioctl))
                        break;
 
-               /* fall through */
+               fallthrough;
        default:
                rc = -EINVAL;
                goto out;
index 593669a..5dddf67 100644 (file)
@@ -375,14 +375,13 @@ retry:
                        switch (sshdr.sense_key) {
                        case NO_SENSE:
                        case RECOVERED_ERROR:
-                               /* fall through */
                        case NOT_READY:
                                result &= ~SAM_STAT_CHECK_CONDITION;
                                break;
                        case UNIT_ATTENTION:
                                switch (sshdr.asc) {
                                case 0x29: /* Power on Reset or Device Reset */
-                                       /* fall through */
+                                       fallthrough;
                                case 0x2A: /* Device capacity changed */
                                case 0x3F: /* Report LUNs changed */
                                        /* Retry the command once more */
@@ -1791,13 +1790,12 @@ static int process_sense(struct scsi_device *sdev,
        switch (sshdr.sense_key) {
        case NO_SENSE:
        case RECOVERED_ERROR:
-               /* fall through */
        case NOT_READY:
                break;
        case UNIT_ATTENTION:
                switch (sshdr.asc) {
                case 0x29: /* Power on Reset or Device Reset */
-                       /* fall through */
+                       fallthrough;
                case 0x2A: /* Device settings/capacity changed */
                        rc = read_cap16(sdev, lli);
                        if (rc) {
@@ -2157,7 +2155,7 @@ int cxlflash_ioctl(struct scsi_device *sdev, unsigned int cmd, void __user *arg)
                if (unlikely(rc))
                        goto cxlflash_ioctl_exit;
 
-               /* fall through */
+               fallthrough;
 
        case DK_CXLFLASH_MANAGE_LUN:
                known_ioctl = true;
@@ -2168,7 +2166,7 @@ int cxlflash_ioctl(struct scsi_device *sdev, unsigned int cmd, void __user *arg)
                if (likely(do_ioctl))
                        break;
 
-               /* fall through */
+               fallthrough;
        default:
                rc = -EINVAL;
                goto cxlflash_ioctl_exit;
index 8acd4bb..4a3f783 100644 (file)
@@ -60,7 +60,7 @@ static int tur_done(struct scsi_device *sdev, struct hp_sw_dh_data *h,
                        ret = SCSI_DH_OK;
                        break;
                }
-               /* Fallthrough */
+               fallthrough;
        default:
                sdev_printk(KERN_WARNING, sdev,
                           "%s: sending tur failed, sense %x/%x/%x\n",
@@ -147,7 +147,7 @@ retry:
                                rc = SCSI_DH_RETRY;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        sdev_printk(KERN_WARNING, sdev,
                                    "%s: sending start_stop_unit failed, "
index b02ac38..429d642 100644 (file)
@@ -1500,7 +1500,7 @@ bool esas2r_fm_api(struct esas2r_adapter *a, struct esas2r_flash_img *fi,
                        return complete_fmapi_req(a, rq, FI_STAT_SUCCESS);
                }
 
-       /* fall through */
+               fallthrough;
 
        case FI_ACT_UP: /* Upload the components */
        default:
index eb7d139..09c5c24 100644 (file)
@@ -1236,7 +1236,7 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a,
                        a->init_msg = ESAS2R_INIT_MSG_GET_INIT;
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case ESAS2R_INIT_MSG_GET_INIT:
                if (msg == ESAS2R_INIT_MSG_GET_INIT) {
@@ -1250,7 +1250,7 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a,
                                esas2r_hdebug("FAILED");
                        }
                }
-               /* fall through */
+               fallthrough;
 
        default:
                rq->req_stat = RS_SUCCESS;
index 89afa31..43a1fd1 100644 (file)
@@ -307,7 +307,7 @@ static void esp_reset_esp(struct esp *esp)
 
        case FASHME:
                esp->config2 |= (ESP_CONFIG2_HME32 | ESP_CONFIG2_HMEFENAB);
-               /* fallthrough... */
+               fallthrough;
 
        case FAS236:
        case PCSCSI:
@@ -1741,7 +1741,7 @@ again:
 
        case ESP_EVENT_DATA_IN:
                write = 1;
-               /* fallthru */
+               fallthrough;
 
        case ESP_EVENT_DATA_OUT: {
                struct esp_cmd_entry *ent = esp->active_cmd;
index 1409c76..5ea426e 100644 (file)
@@ -450,10 +450,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
                switch (fip->mode) {
                default:
                        LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
-                       /* fall-through */
+                       fallthrough;
                case FIP_MODE_AUTO:
                        LIBFCOE_FIP_DBG(fip, "%s", "setting AUTO mode.\n");
-                       /* fall-through */
+                       fallthrough;
                case FIP_MODE_FABRIC:
                case FIP_MODE_NON_FIP:
                        mutex_unlock(&fip->ctlr_mutex);
@@ -773,7 +773,7 @@ int fcoe_ctlr_els_send(struct fcoe_ctlr *fip, struct fc_lport *lport,
                        fc_fcoe_set_mac(mac, fh->fh_d_id);
                        fip->update_mac(lport, mac);
                }
-               /* fall through */
+               fallthrough;
        case ELS_LS_RJT:
                op = fr_encaps(fp);
                if (op)
@@ -2439,7 +2439,7 @@ static void fcoe_ctlr_vn_probe_req(struct fcoe_ctlr *fip,
                                          frport->enode_mac, 0);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case FIP_ST_VNMP_START:
                LIBFCOE_FIP_DBG(fip, "vn_probe_req: "
                                "restart VN2VN negotiation\n");
index 2cc676e..29e4cdc 100644 (file)
@@ -340,7 +340,7 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt,
                        break;
                case BOARD_DTC3181E:
                        hostdata->io_width = 2; /* 16-bit PDMA */
-                       /* fall through */
+                       fallthrough;
                case BOARD_NCR53C400A:
                case BOARD_HP_C2502:
                        hostdata->c400_ctl_status = 9;
index 11caa4b..d9d21d2 100644 (file)
@@ -1144,7 +1144,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func,
                        hisi_hba->hw->get_events(hisi_hba, phy_no);
                        break;
                }
-               /* fallthru */
+               fallthrough;
        case PHY_FUNC_RELEASE_SPINUP_HOLD:
        default:
                return -EOPNOTSUPP;
index 91794a5..48d5da5 100644 (file)
@@ -4697,7 +4697,7 @@ static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)
        case WRITE_6:
        case WRITE_12:
                is_write = 1;
-               /* fall through */
+               fallthrough;
        case READ_6:
        case READ_12:
                if (*cdb_len == 6) {
@@ -5147,7 +5147,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
        switch (cmd->cmnd[0]) {
        case WRITE_6:
                is_write = 1;
-               /* fall through */
+               fallthrough;
        case READ_6:
                first_block = (((cmd->cmnd[1] & 0x1F) << 16) |
                                (cmd->cmnd[2] << 8) |
@@ -5158,7 +5158,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
                break;
        case WRITE_10:
                is_write = 1;
-               /* fall through */
+               fallthrough;
        case READ_10:
                first_block =
                        (((u64) cmd->cmnd[2]) << 24) |
@@ -5171,7 +5171,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
                break;
        case WRITE_12:
                is_write = 1;
-               /* fall through */
+               fallthrough;
        case READ_12:
                first_block =
                        (((u64) cmd->cmnd[2]) << 24) |
@@ -5186,7 +5186,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,
                break;
        case WRITE_16:
                is_write = 1;
-               /* fall through */
+               fallthrough;
        case READ_16:
                first_block =
                        (((u64) cmd->cmnd[2]) << 56) |
index 77f4d37..ea7c893 100644 (file)
@@ -1866,7 +1866,7 @@ static int ibmvfc_bsg_request(struct bsg_job *job)
                port_id = (bsg_request->rqst_data.h_els.port_id[0] << 16) |
                        (bsg_request->rqst_data.h_els.port_id[1] << 8) |
                        bsg_request->rqst_data.h_els.port_id[2];
-               /* fall through */
+               fallthrough;
        case FC_BSG_RPT_ELS:
                fc_flags = IBMVFC_FC_ELS;
                break;
@@ -1875,7 +1875,7 @@ static int ibmvfc_bsg_request(struct bsg_job *job)
                port_id = (bsg_request->rqst_data.h_ct.port_id[0] << 16) |
                        (bsg_request->rqst_data.h_ct.port_id[1] << 8) |
                        bsg_request->rqst_data.h_ct.port_id[2];
-               /* fall through */
+               fallthrough;
        case FC_BSG_RPT_CT:
                fc_flags = IBMVFC_FC_CT_IU;
                break;
@@ -4122,7 +4122,7 @@ static void ibmvfc_npiv_login_done(struct ibmvfc_event *evt)
                return;
        case IBMVFC_MAD_CRQ_ERROR:
                ibmvfc_retry_host_init(vhost);
-               /* fall through */
+               fallthrough;
        case IBMVFC_MAD_DRIVER_FAILED:
                ibmvfc_free_event(evt);
                return;
index d9e94e8..cc3908c 100644 (file)
@@ -1581,7 +1581,7 @@ static long ibmvscsis_adapter_info(struct scsi_info *vscsi,
        case H_PERMISSION:
                if (connection_broken(vscsi))
                        flag_bits = (RESPONSE_Q_DOWN | CLIENT_FAILED);
-               /* Fall through */
+               fallthrough;
        default:
                dev_err(&vscsi->dev, "adapter_info: h_copy_rdma to client failed, rc %ld\n",
                        rc);
@@ -2489,10 +2489,10 @@ static long ibmvscsis_ping_response(struct scsi_info *vscsi)
                break;
        case H_CLOSED:
                vscsi->flags |= CLIENT_FAILED;
-               /* Fall through */
+               fallthrough;
        case H_DROPPED:
                vscsi->flags |= RESPONSE_Q_DOWN;
-               /* Fall through */
+               fallthrough;
        case H_REMOTE_PARM:
                dev_err(&vscsi->dev, "ping_response: h_send_crq failed, rc %ld\n",
                        rc);
index 1459b14..862d35a 100644 (file)
@@ -801,7 +801,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
        case 1:         /* Phase 1 - Connected */
                imm_connect(dev, CONNECT_EPP_MAYBE);
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 2:         /* Phase 2 - We are now talking to the scsi bus */
                if (!imm_select(dev, scmd_id(cmd))) {
@@ -809,7 +809,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        return 0;
                }
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 3:         /* Phase 3 - Ready to accept a command */
                w_ctr(ppb, 0x0c);
@@ -819,7 +819,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                if (!imm_send_command(cmd))
                        return 0;
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 4:         /* Phase 4 - Setup scatter/gather buffers */
                if (scsi_bufflen(cmd)) {
@@ -835,7 +835,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                cmd->SCp.phase++;
                if (cmd->SCp.this_residual & 0x01)
                        cmd->SCp.this_residual++;
-               /* fall through */
+               fallthrough;
 
        case 5:         /* Phase 5 - Pre-Data transfer stage */
                /* Spin lock for BUSY */
@@ -852,7 +852,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        if (imm_negotiate(dev))
                                return 0;
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 6:         /* Phase 6 - Data transfer stage */
                /* Spin lock for BUSY */
@@ -868,7 +868,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                                return 1;
                }
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 7:         /* Phase 7 - Post data transfer stage */
                if ((dev->dp) && (dev->rd)) {
@@ -880,7 +880,7 @@ static int imm_engine(imm_struct *dev, struct scsi_cmnd *cmd)
                        }
                }
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 8:         /* Phase 8 - Read status/message */
                /* Check for data overrun */
index 7f9b3f2..4cacb80 100644 (file)
@@ -778,7 +778,7 @@ enum sci_status sci_phy_event_handler(struct isci_phy *iphy, u32 event_code)
                        break;
                case SCU_EVENT_LINK_FAILURE:
                        scu_link_layer_set_txcomsas_timeout(iphy, SCU_SAS_LINK_LAYER_TXCOMSAS_NEGTIME_DEFAULT);
-                       /* fall through */
+                       fallthrough;
                case SCU_EVENT_HARD_RESET_RECEIVED:
                        /* Start the oob/sn state machine over again */
                        sci_change_state(&iphy->sm, SCI_PHY_STARTING);
index cd1e4b4..c3f540b 100644 (file)
@@ -310,7 +310,7 @@ static void isci_remote_device_not_ready(struct isci_host *ihost,
                /* Kill all outstanding requests for the device. */
                sci_remote_device_terminate_requests(idev);
 
-               /* Fall through - into the default case... */
+               fallthrough;    /* into the default case */
        default:
                clear_bit(IDEV_IO_READY, &idev->flags);
                break;
@@ -593,7 +593,7 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev,
 
                        break;
                }
-               /* fall through - and treat as unhandled... */
+               fallthrough;    /* and treat as unhandled */
        default:
                dev_dbg(scirdev_to_dev(idev),
                        "%s: device: %p event code: %x: %s\n",
index 474a434..68333f5 100644 (file)
@@ -225,7 +225,7 @@ static void sci_remote_node_context_continue_state_transitions(struct sci_remote
        case RNC_DEST_READY:
        case RNC_DEST_SUSPENDED_RESUME:
                rnc->destination_state = RNC_DEST_READY;
-               /* Fall through... */
+               fallthrough;
        case RNC_DEST_FINAL:
                sci_remote_node_context_resume(rnc, rnc->user_callback,
                                               rnc->user_cookie);
@@ -601,9 +601,9 @@ enum sci_status sci_remote_node_context_suspend(
                                 __func__, sci_rnc);
                        return SCI_FAILURE_INVALID_STATE;
                }
-               /* Fall through - and handle like SCI_RNC_POSTING */
+               fallthrough;    /* and handle like SCI_RNC_POSTING */
        case SCI_RNC_RESUMING:
-               /* Fall through - and handle like SCI_RNC_POSTING */
+               fallthrough;    /* and handle like SCI_RNC_POSTING */
        case SCI_RNC_POSTING:
                /* Set the destination state to AWAIT - this signals the
                 * entry into the SCI_RNC_READY state that a suspension
index 6561a07..6e08179 100644 (file)
@@ -894,7 +894,7 @@ sci_io_request_terminate(struct isci_request *ireq)
                 * and don't wait for the task response.
                 */
                sci_change_state(&ireq->sm, SCI_REQ_ABORTING);
-               /* Fall through - and handle like ABORTING... */
+               fallthrough;    /* and handle like ABORTING */
        case SCI_REQ_ABORTING:
                if (!isci_remote_device_is_safe_to_abort(ireq->target_device))
                        set_bit(IREQ_PENDING_ABORT, &ireq->flags);
index d8cbc9c..e67abb1 100644 (file)
@@ -634,8 +634,6 @@ free_fp:
        fc_frame_free(fp);
 out:
        kref_put(&rdata->kref, fc_rport_destroy);
-       if (!IS_ERR(fp))
-               fc_frame_free(fp);
 }
 
 /**
index 16eb3b6..96a2952 100644 (file)
@@ -2108,7 +2108,7 @@ static void fc_exch_rrq_resp(struct fc_seq *sp, struct fc_frame *fp, void *arg)
        switch (op) {
        case ELS_LS_RJT:
                FC_EXCH_DBG(aborted_ep, "LS_RJT for RRQ\n");
-               /* fall through */
+               fallthrough;
        case ELS_LS_ACC:
                goto cleanup;
        default:
@@ -2622,7 +2622,7 @@ void fc_exch_recv(struct fc_lport *lport, struct fc_frame *fp)
        case FC_EOF_T:
                if (f_ctl & FC_FC_END_SEQ)
                        skb_trim(fp_skb(fp), fr_len(fp) - FC_FC_FILL(f_ctl));
-               /* fall through */
+               fallthrough;
        case FC_EOF_N:
                if (fh->fh_type == FC_TYPE_BLS)
                        fc_exch_recv_bls(ema->mp, fp);
index e11d4f0..7cfeb68 100644 (file)
@@ -752,7 +752,7 @@ static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
                brp = fc_frame_payload_get(fp, sizeof(*brp));
                if (brp && brp->br_reason == FC_BA_RJT_LOG_ERR)
                        break;
-               /* fall thru */
+               fallthrough;
        default:
                /*
                 * we will let the command timeout
@@ -1536,7 +1536,7 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
                                   "device %x invalid REC reject %d/%d\n",
                                   fsp->rport->port_id, rjt->er_reason,
                                   rjt->er_explan);
-                       /* fall through */
+                       fallthrough;
                case ELS_RJT_UNSUP:
                        FC_FCP_DBG(fsp, "device does not support REC\n");
                        rpriv = fsp->rport->dd_data;
@@ -1668,7 +1668,7 @@ static void fc_fcp_rec_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
                FC_FCP_DBG(fsp, "REC %p fid %6.6x error unexpected error %d\n",
                           fsp, fsp->rport->port_id, error);
                fsp->status_code = FC_CMD_PLOGO;
-               /* fall through */
+               fallthrough;
 
        case -FC_EX_TIMEOUT:
                /*
@@ -1830,7 +1830,7 @@ static void fc_fcp_srr_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
                break;
        case -FC_EX_CLOSED:                     /* e.g., link failure */
                FC_FCP_DBG(fsp, "SRR error, exchange closed\n");
-               /* fall through */
+               fallthrough;
        default:
                fc_fcp_retry_cmd(fsp, FC_ERROR);
                break;
index b84dbc3..6557fda 100644 (file)
@@ -1578,7 +1578,7 @@ static void fc_lport_timeout(struct work_struct *work)
        case LPORT_ST_DPRT:
                FC_LPORT_DBG(lport, "Skipping lport state %s to SCR\n",
                             fc_lport_state(lport));
-               /* fall thru */
+               fallthrough;
        case LPORT_ST_SCR:
                fc_lport_enter_scr(lport);
                break;
index 18663a8..a60b228 100644 (file)
@@ -1723,7 +1723,7 @@ static void fc_rport_recv_els_req(struct fc_lport *lport, struct fc_frame *fp)
                        kref_put(&rdata->kref, fc_rport_destroy);
                        goto busy;
                }
-               /* fall through */
+               fallthrough;
        default:
                FC_RPORT_DBG(rdata,
                             "Reject ELS 0x%02x while in state %s\n",
index 49c8a18..1e9c317 100644 (file)
@@ -248,7 +248,7 @@ static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
                hdr_lun = scsilun_to_int(&tmf->lun);
                if (hdr_lun != task->sc->device->lun)
                        return 0;
-               /* fall through */
+               fallthrough;
        case ISCSI_TM_FUNC_TARGET_WARM_RESET:
                /*
                 * Fail all SCSI cmd PDUs
@@ -1674,7 +1674,7 @@ int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc)
                                sc->result = DID_NO_CONNECT << 16;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                case ISCSI_STATE_IN_RECOVERY:
                        reason = FAILURE_SESSION_IN_RECOVERY;
                        sc->result = DID_IMM_RETRY << 16;
@@ -2239,7 +2239,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
                                              "progress\n");
                        goto success;
                }
-               /* fall through */
+               fallthrough;
        default:
                conn->tmf_state = TMF_INITIAL;
                goto failed;
index 6ef93c7..37e5d4e 100644 (file)
@@ -772,7 +772,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
                        iscsi_tcp_data_recv_prep(tcp_conn);
                        return 0;
                }
-       /* fall through */
+               fallthrough;
        case ISCSI_OP_LOGOUT_RSP:
        case ISCSI_OP_NOOP_IN:
        case ISCSI_OP_SCSI_TMFUNC_RSP:
index 1b93332..a488798 100644 (file)
@@ -209,7 +209,10 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
                task->num_scatter = si;
        }
 
-       task->data_dir = qc->dma_dir;
+       if (qc->tf.protocol == ATA_PROT_NODATA)
+               task->data_dir = DMA_NONE;
+       else
+               task->data_dir = qc->dma_dir;
        task->scatter = qc->sg;
        task->ata_task.retry_count = 1;
        task->task_state_flags = SAS_TASK_STATE_PENDING;
@@ -324,7 +327,7 @@ static int smp_ata_check_ready(struct ata_link *link)
        case SAS_END_DEVICE:
                if (ex_phy->attached_sata_dev)
                        return sas_ata_clear_pending(dev, ex_phy);
-               /* fall through */
+               fallthrough;
        default:
                return -ENODEV;
        }
index daf951b..cd7c7d2 100644 (file)
@@ -108,7 +108,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
                        rphy = NULL;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case SAS_END_DEVICE:
                rphy = sas_end_device_alloc(port->port);
                break;
index b7d1b1e..8d6bcc1 100644 (file)
@@ -1096,7 +1096,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
                } else
                        memcpy(dev->port->disc.fanout_sas_addr,
                               ex_phy->attached_sas_addr, SAS_ADDR_SIZE);
-               /* fallthrough */
+               fallthrough;
        case SAS_EDGE_EXPANDER_DEVICE:
                child = sas_ex_discover_expander(dev, phy_id);
                break;
index 9e0975e..1bf9398 100644 (file)
@@ -622,7 +622,7 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head *
                                sas_scsi_clear_queue_lu(work_q, cmd);
                                goto Again;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case TASK_IS_NOT_AT_LU:
                case TASK_ABORT_FAILED:
                        pr_notice("task 0x%p is not at LU: I_T recover\n",
index ef2015f..d0141a2 100644 (file)
@@ -3202,7 +3202,7 @@ port_out:
        case SLI_MGMT_GHAT:
        case SLI_MGMT_GRPL:
                rsp_size = FC_MAX_NS_RSP;
-               /* fall through */
+               fallthrough;
        case SLI_MGMT_DHBA:
        case SLI_MGMT_DHAT:
                pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
@@ -3215,7 +3215,7 @@ port_out:
        case SLI_MGMT_GPAT:
        case SLI_MGMT_GPAS:
                rsp_size = FC_MAX_NS_RSP;
-               /* fall through */
+               fallthrough;
        case SLI_MGMT_DPRT:
        case SLI_MGMT_DPA:
                pe = (struct lpfc_fdmi_port_entry *)&CtReq->un.PortID;
index 48dc63f..b609451 100644 (file)
@@ -3517,6 +3517,9 @@ lpfc_issue_els_rdf(struct lpfc_vport *vport, uint8_t retry)
                                FC_TLV_DESC_LENGTH_FROM_SZ(prdf->reg_d1));
        prdf->reg_d1.reg_desc.count = cpu_to_be32(ELS_RDF_REG_TAG_CNT);
        prdf->reg_d1.desc_tags[0] = cpu_to_be32(ELS_DTAG_LNK_INTEGRITY);
+       prdf->reg_d1.desc_tags[1] = cpu_to_be32(ELS_DTAG_DELIVERY);
+       prdf->reg_d1.desc_tags[2] = cpu_to_be32(ELS_DTAG_PEER_CONGEST);
+       prdf->reg_d1.desc_tags[3] = cpu_to_be32(ELS_DTAG_CONGESTION);
 
        lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_CMD,
                              "Issue RDF:       did:x%x",
@@ -4656,7 +4659,9 @@ lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
 out:
        if (ndlp && NLP_CHK_NODE_ACT(ndlp) && shost) {
                spin_lock_irq(shost->host_lock);
-               ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);
+               if (mbox)
+                       ndlp->nlp_flag &= ~NLP_ACC_REGLOGIN;
+               ndlp->nlp_flag &= ~NLP_RM_DFLT_RPI;
                spin_unlock_irq(shost->host_lock);
 
                /* If the node is not being used by another discovery thread,
@@ -9134,7 +9139,7 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)
                                lpfc_nlp_put(ndlp);
                                return;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        /* Try to recover from this error */
                        if (phba->sli_rev == LPFC_SLI_REV4)
index 142a021..d32c7e7 100644 (file)
@@ -4728,15 +4728,14 @@ lpfc_check_sli_ndlp(struct lpfc_hba *phba,
                case CMD_GEN_REQUEST64_CR:
                        if (iocb->context_un.ndlp == ndlp)
                                return 1;
-                       /* fall through */
+                       fallthrough;
                case CMD_ELS_REQUEST64_CR:
                        if (icmd->un.elsreq64.remoteID == ndlp->nlp_DID)
                                return 1;
-                       /* fall through */
+                       fallthrough;
                case CMD_XMIT_ELS_RSP64_CX:
                        if (iocb->context1 == (uint8_t *) ndlp)
                                return 1;
-                       /* fall through */
                }
        } else if (pring->ringno == LPFC_FCP_RING) {
                /* Skip match check if waiting to relogin to FCP target */
@@ -6055,7 +6054,7 @@ restart_disc:
 
        case LPFC_LINK_UP:
                lpfc_issue_clear_la(phba, vport);
-               /* fall through */
+               fallthrough;
        case LPFC_LINK_UNKNOWN:
        case LPFC_WARM_START:
        case LPFC_INIT_START:
index c4ba827..12e4e76 100644 (file)
@@ -4800,7 +4800,7 @@ struct send_frame_wqe {
        uint32_t fc_hdr_wd5;           /* word 15 */
 };
 
-#define ELS_RDF_REG_TAG_CNT            1
+#define ELS_RDF_REG_TAG_CNT            4
 struct lpfc_els_rdf_reg_desc {
        struct fc_df_desc_fpin_reg      reg_desc;       /* descriptor header */
        __be32                          desc_tags[ELS_RDF_REG_TAG_CNT];
index c697259..ca25e54 100644 (file)
@@ -11376,7 +11376,6 @@ lpfc_irq_clear_aff(struct lpfc_hba_eq_hdl *eqhdl)
 {
        cpumask_clear(&eqhdl->aff_mask);
        irq_clear_status_flags(eqhdl->irq, IRQ_NO_BALANCING);
-       irq_set_affinity_hint(eqhdl->irq, &eqhdl->aff_mask);
 }
 
 /**
index cad53d1..92d6e7b 100644 (file)
@@ -464,7 +464,7 @@ lpfc_rcv_plogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
        case  NLP_STE_NPR_NODE:
                if (!(ndlp->nlp_flag & NLP_NPR_ADISC))
                        break;
-               /* fall through */
+               fallthrough;
        case  NLP_STE_REG_LOGIN_ISSUE:
        case  NLP_STE_PRLI_ISSUE:
        case  NLP_STE_UNMAPPED_NODE:
index e5be334..0c39ed5 100644 (file)
@@ -1225,7 +1225,7 @@ lpfc_nvme_io_cmd_wqe_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pwqeIn,
                                         lpfc_ncmd, nCmd,
                                         lpfc_ncmd->cur_iocbq.sli4_xritag,
                                         bf_get(lpfc_wcqe_c_xb, wcqe));
-                       /* fall through */
+                       fallthrough;
                default:
 out_err:
                        lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR,
index 5e802c8..983eeb0 100644 (file)
@@ -1093,7 +1093,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        case SCSI_PROT_WRITE_INSERT:
                                /*
                                 * For WRITE_INSERT, force the error
@@ -1213,7 +1213,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
                                        rc = BG_ERR_TGT | BG_ERR_CHECK;
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        case SCSI_PROT_WRITE_INSERT:
                                /*
                                 * For WRITE_INSERT, force the
@@ -1295,7 +1295,7 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
                        switch (op) {
                        case SCSI_PROT_WRITE_PASS:
                                rc = BG_ERR_CHECK;
-                               /* fall through */
+                               fallthrough;
 
                        case SCSI_PROT_WRITE_INSERT:
                                /*
@@ -3980,7 +3980,7 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
                                        lpfc_cmd->cur_iocbq.sli4_lxritag,
                                        0, 0);
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        cmd->result = DID_ERROR << 16;
                        break;
index 4cd7ded..e158cd7 100644 (file)
@@ -9339,7 +9339,7 @@ __lpfc_sli_issue_iocb_s3(struct lpfc_hba *phba, uint32_t ring_number,
                         */
                        if (piocb->iocb_cmpl)
                                piocb->iocb_cmpl = NULL;
-                       /*FALLTHROUGH*/
+                       fallthrough;
                case CMD_CREATE_XRI_CR:
                case CMD_CLOSE_XRI_CN:
                case CMD_CLOSE_XRI_CX:
@@ -9653,7 +9653,7 @@ lpfc_sli4_iocb2wqe(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq,
                cmnd = CMD_XMIT_SEQUENCE64_CR;
                if (phba->link_flag & LS_LOOPBACK_MODE)
                        bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1);
-               /* fall through */
+               fallthrough;
        case CMD_XMIT_SEQUENCE64_CR:
                /* word3 iocb=io_tag32 wqe=reserved */
                wqe->xmit_sequence.rsvd3 = 0;
@@ -13630,7 +13630,7 @@ lpfc_sli4_sp_handle_rcqe(struct lpfc_hba *phba, struct lpfc_rcqe *rcqe)
        case FC_STATUS_RQ_BUF_LEN_EXCEEDED:
                lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
                                "2537 Receive Frame Truncated!!\n");
-               /* fall through */
+               fallthrough;
        case FC_STATUS_RQ_SUCCESS:
                spin_lock_irqsave(&phba->hbalock, iflags);
                lpfc_sli4_rq_release(hrq, drq);
@@ -13678,7 +13678,7 @@ lpfc_sli4_sp_handle_rcqe(struct lpfc_hba *phba, struct lpfc_rcqe *rcqe)
                                        atomic_read(&tgtp->rcv_fcp_cmd_out),
                                        atomic_read(&tgtp->xmt_fcp_release));
                }
-               /* fallthrough */
+               fallthrough;
 
        case FC_STATUS_INSUFF_BUF_NEED_BUF:
                hrq->RQ_no_posted_buf++;
@@ -14162,7 +14162,7 @@ lpfc_sli4_nvmet_handle_rcqe(struct lpfc_hba *phba, struct lpfc_queue *cq,
        case FC_STATUS_RQ_BUF_LEN_EXCEEDED:
                lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
                                "6126 Receive Frame Truncated!!\n");
-               /* fall through */
+               fallthrough;
        case FC_STATUS_RQ_SUCCESS:
                spin_lock_irqsave(&phba->hbalock, iflags);
                lpfc_sli4_rq_release(hrq, drq);
@@ -14209,7 +14209,7 @@ drop:
                                        atomic_read(&tgtp->rcv_fcp_cmd_out),
                                        atomic_read(&tgtp->xmt_fcp_release));
                }
-               /* fallthrough */
+               fallthrough;
 
        case FC_STATUS_INSUFF_BUF_NEED_BUF:
                hrq->RQ_no_posted_buf++;
@@ -15096,7 +15096,7 @@ lpfc_eq_create(struct lpfc_hba *phba, struct lpfc_queue *eq, uint32_t imax)
                        status = -EINVAL;
                        goto out;
                }
-               /* fall through - otherwise default to smallest count */
+               fallthrough;    /* otherwise default to smallest count */
        case 256:
                bf_set(lpfc_eq_context_count, &eq_create->u.request.context,
                       LPFC_EQ_CNT_256);
@@ -15238,7 +15238,7 @@ lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq,
                               LPFC_CQ_CNT_WORD7);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
                                "0361 Unsupported CQ count: "
@@ -15249,7 +15249,7 @@ lpfc_cq_create(struct lpfc_hba *phba, struct lpfc_queue *cq,
                        status = -EINVAL;
                        goto out;
                }
-               /* fall through - otherwise default to smallest count */
+               fallthrough;    /* otherwise default to smallest count */
        case 256:
                bf_set(lpfc_cq_context_count, &cq_create->u.request.context,
                       LPFC_CQ_CNT_256);
@@ -15417,7 +15417,7 @@ lpfc_cq_create_set(struct lpfc_hba *phba, struct lpfc_queue **cqp,
                                               LPFC_CQ_CNT_WORD7);
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
                                                "3118 Bad CQ count. (%d)\n",
@@ -15426,7 +15426,7 @@ lpfc_cq_create_set(struct lpfc_hba *phba, struct lpfc_queue **cqp,
                                        status = -EINVAL;
                                        goto out;
                                }
-                               /* fall through - otherwise default to smallest */
+                               fallthrough;    /* otherwise default to smallest */
                        case 256:
                                bf_set(lpfc_mbx_cq_create_set_cqe_cnt,
                                       &cq_set->u.request, LPFC_CQ_CNT_256);
@@ -15702,7 +15702,7 @@ lpfc_mq_create(struct lpfc_hba *phba, struct lpfc_queue *mq,
                        status = -EINVAL;
                        goto out;
                }
-               /* fall through - otherwise default to smallest count */
+               fallthrough;    /* otherwise default to smallest count */
        case 16:
                bf_set(lpfc_mq_context_ring_size,
                       &mq_create_ext->u.request.context,
@@ -16123,7 +16123,7 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
                                status = -EINVAL;
                                goto out;
                        }
-                       /* fall through - otherwise default to smallest count */
+                       fallthrough;    /* otherwise default to smallest count */
                case 512:
                        bf_set(lpfc_rq_context_rqe_count,
                               &rq_create->u.request.context,
@@ -16260,7 +16260,7 @@ lpfc_rq_create(struct lpfc_hba *phba, struct lpfc_queue *hrq,
                                status = -EINVAL;
                                goto out;
                        }
-                       /* fall through - otherwise default to smallest count */
+                       fallthrough;    /* otherwise default to smallest count */
                case 512:
                        bf_set(lpfc_rq_context_rqe_count,
                               &rq_create->u.request.context,
index 20adec4..c657abf 100644 (file)
@@ -20,7 +20,7 @@
  * included with this package.                                     *
  *******************************************************************/
 
-#define LPFC_DRIVER_VERSION "12.8.0.3"
+#define LPFC_DRIVER_VERSION "12.8.0.4"
 #define LPFC_DRIVER_NAME               "lpfc"
 
 /* Used for SLI 2/3 */
index 0484ee5..ac40604 100644 (file)
@@ -491,9 +491,9 @@ mega_get_ldrv_num(adapter_t *adapter, struct scsi_cmnd *cmd, int channel)
 
        if (adapter->support_random_del && adapter->read_ldidmap )
                switch (cmd->cmnd[0]) {
-               case READ_6:    /* fall through */
-               case WRITE_6:   /* fall through */
-               case READ_10:   /* fall through */
+               case READ_6:
+               case WRITE_6:
+               case READ_10:
                case WRITE_10:
                        ldrv_num += 0x80;
                }
@@ -852,7 +852,7 @@ mega_build_cmd(adapter_t *adapter, struct scsi_cmnd *cmd, int *busy)
                        return scb;
 
 #if MEGA_HAVE_CLUSTERING
-               case RESERVE:   /* Fall through */
+               case RESERVE:
                case RELEASE:
 
                        /*
@@ -987,7 +987,7 @@ mega_prepare_passthru(adapter_t *adapter, scb_t *scb, struct scsi_cmnd *cmd,
 
                        adapter->flag |= (1L << cmd->device->channel);
                }
-               /* Fall through */
+               fallthrough;
        default:
                pthru->numsgelements = mega_build_sglist(adapter, scb,
                                &pthru->dataxferaddr, &pthru->dataxferlen);
@@ -1050,7 +1050,7 @@ mega_prepare_extpassthru(adapter_t *adapter, scb_t *scb,
 
                        adapter->flag |= (1L << cmd->device->channel);
                }
-               /* Fall through */
+               fallthrough;
        default:
                epthru->numsgelements = mega_build_sglist(adapter, scb,
                                &epthru->dataxferaddr, &epthru->dataxferlen);
index 19469a2..4a27ac8 100644 (file)
@@ -1581,7 +1581,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy)
                                return NULL;
                        }
 
-                       /* Fall through */
+                       fallthrough;
 
                case READ_CAPACITY:
                        /*
index 861f714..2b7e7b5 100644 (file)
@@ -3522,7 +3522,7 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,
                        megasas_complete_int_cmd(instance, cmd);
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case MFI_CMD_LD_READ:
        case MFI_CMD_LD_WRITE:
index 0824410..b0c01cf 100644 (file)
@@ -3534,7 +3534,7 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex,
                                atomic_dec(&lbinfo->scsi_pending_cmds[cmd_fusion->pd_r1_lb]);
                                cmd_fusion->scmd->SCp.Status &= ~MEGASAS_LOAD_BALANCE_FLAG;
                        }
-                       /* Fall through - and complete IO */
+                       fallthrough;    /* and complete IO */
                case MEGASAS_MPI2_FUNCTION_LD_IO_REQUEST: /* LD-IO Path */
                        atomic_dec(&instance->fw_outstanding);
                        if (cmd_fusion->r1_alt_dev_handle == MR_DEVHANDLE_INVALID) {
@@ -3689,7 +3689,7 @@ int megasas_irqpoll(struct irq_poll *irqpoll, int budget)
        instance = irq_ctx->instance;
 
        if (irq_ctx->irq_line_enable) {
-               disable_irq(irq_ctx->os_irq);
+               disable_irq_nosync(irq_ctx->os_irq);
                irq_ctx->irq_line_enable = false;
        }
 
index fd1d030..0a9f4e4 100644 (file)
@@ -1457,7 +1457,7 @@ static void cmd_complete(struct mesh_state *ms)
                /* huh?  we expected a phase mismatch */
                ms->n_msgin = 0;
                ms->msgphase = msg_in;
-               /* fall through */
+               fallthrough;
 
        case msg_in:
                /* should have some message bytes in fifo */
index 1d64524..8062bd9 100644 (file)
@@ -1733,7 +1733,7 @@ _base_irqpoll(struct irq_poll *irqpoll, int budget)
        reply_q = container_of(irqpoll, struct adapter_reply_queue,
                        irqpoll);
        if (reply_q->irq_line_enable) {
-               disable_irq(reply_q->os_irq);
+               disable_irq_nosync(reply_q->os_irq);
                reply_q->irq_line_enable = false;
        }
        num_entries = _base_process_reply_queue(reply_q);
@@ -4681,7 +4681,7 @@ _base_update_ioc_page1_inlinewith_perf_mode(struct MPT3SAS_ADAPTER *ioc)
                        ioc_info(ioc, "performance mode: balanced\n");
                        return;
                }
-               /* Fall through */
+               fallthrough;
        case MPT_PERF_MODE_LATENCY:
                /*
                 * Enable interrupt coalescing on all reply queues
index 4326030..7c119b9 100644 (file)
@@ -1002,7 +1002,7 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg,
                }
                /* drop to default case for posting the request */
        }
-               /* fall through */
+               fallthrough;
        default:
                ioc->build_sg_mpi(ioc, psge, data_out_dma, data_out_sz,
                    data_in_dma, data_in_sz);
index 08fc4b3..2e2756d 100644 (file)
@@ -5470,7 +5470,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)
 
        case MPI2_IOCSTATUS_SCSI_DATA_OVERRUN:
                scsi_set_resid(scmd, 0);
-               /* fall through */
+               fallthrough;
        case MPI2_IOCSTATUS_SCSI_RECOVERED_ERROR:
        case MPI2_IOCSTATUS_SUCCESS:
                scmd->result = (DID_OK << 16) | scsi_status;
@@ -6480,7 +6480,7 @@ _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
                        if (!test_bit(handle, ioc->pend_os_device_add))
                                break;
 
-                       /* fall through */
+                       fallthrough;
 
                case MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED:
 
@@ -7208,7 +7208,7 @@ _scsih_pcie_topology_change_event(struct MPT3SAS_ADAPTER *ioc,
                        event_data->PortEntry[i].PortStatus &= 0xF0;
                        event_data->PortEntry[i].PortStatus |=
                                MPI26_EVENT_PCIE_TOPO_PS_DEV_ADDED;
-                       /* fall through */
+                       fallthrough;
                case MPI26_EVENT_PCIE_TOPO_PS_DEV_ADDED:
                        if (ioc->shost_recovery)
                                break;
@@ -10653,7 +10653,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                case MPI26_MFGPAGE_DEVID_CFG_SEC_3916:
                        dev_info(&pdev->dev,
                            "HBA is in Configurable Secure mode\n");
-                       /* fall through */
+                       fallthrough;
                case MPI26_MFGPAGE_DEVID_HARD_SEC_3816:
                case MPI26_MFGPAGE_DEVID_HARD_SEC_3916:
                        ioc->is_aero_ioc = ioc->is_gen35_ioc = 1;
index d4bd31a..b2869c5 100644 (file)
@@ -650,7 +650,7 @@ static void myrb_bgi_control(struct myrb_hba *cb)
                if (sdev && cb->bgi_status.status == MYRB_BGI_INPROGRESS)
                        sdev_printk(KERN_INFO, sdev,
                                    "Background Initialization Aborted\n");
-               /* Fallthrough */
+               fallthrough;
        case MYRB_STATUS_NO_BGI_INPROGRESS:
                cb->bgi_status.status = MYRB_BGI_INVALID;
                break;
@@ -1528,7 +1528,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
                        scmd->scsi_done(scmd);
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        case WRITE_6:
                lba = (((scmd->cmnd[1] & 0x1F) << 16) |
                       (scmd->cmnd[2] << 8) |
@@ -1545,7 +1545,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
                        scmd->scsi_done(scmd);
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        case WRITE_10:
        case VERIFY:            /* 0x2F */
        case WRITE_VERIFY:      /* 0x2E */
@@ -1562,7 +1562,7 @@ static int myrb_ldev_queuecommand(struct Scsi_Host *shost,
                        scmd->scsi_done(scmd);
                        return 0;
                }
-               /* fall through */
+               fallthrough;
        case WRITE_12:
        case VERIFY_12: /* 0xAF */
        case WRITE_VERIFY_12:   /* 0xAE */
index f88adab..03d7013 100644 (file)
@@ -3640,7 +3640,7 @@ ncr_script_copy_and_bind (struct ncb *np, ncrcmd *src, ncrcmd *dst, int len)
                                                new = old;
                                                break;
                                        }
-                                       /* fall through */
+                                       fallthrough;
                                default:
                                        panic("ncr_script_copy_and_bind: weird relocation %x\n", old);
                                        break;
@@ -3910,14 +3910,14 @@ static void __init ncr_prepare_setting(struct ncb *np)
                                        np->scsi_mode = SMODE_HVD;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                case 3: /* SYMBIOS controllers report HVD through GPIO3 */
                        if (INB(nc_gpreg) & 0x08)
                                break;
-                       /* fall through */
+                       fallthrough;
                case 2: /* Set HVD unconditionally */
                        np->scsi_mode = SMODE_HVD;
-                       /* fall through */
+                       fallthrough;
                case 1: /* Trust previous settings for HVD */
                        if (np->sv_stest2 & 0x20)
                                np->scsi_mode = SMODE_HVD;
@@ -4296,7 +4296,7 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd)
                        break;
                cp->phys.header.wgoalp  = cpu_to_scr(goalp);
                cp->phys.header.wlastp  = cpu_to_scr(lastp);
-               /* fall through */
+               fallthrough;
        case DMA_FROM_DEVICE:
                goalp = NCB_SCRIPT_PHYS (np, data_in2) + 8;
                if (segments <= MAX_SCATTERL)
@@ -6717,7 +6717,7 @@ void ncr_int_sir (struct ncb *np)
                        OUTL_DSP (scr_to_cpu(tp->lp[0]->jump_ccb[0]));
                        return;
                }
-               /* fall through */
+               fallthrough;
        case SIR_RESEL_BAD_TARGET:      /* Will send a TARGET RESET message */
        case SIR_RESEL_BAD_LUN:         /* Will send a TARGET RESET message */
        case SIR_RESEL_BAD_I_T_L_Q:     /* Will send an ABORT TAG message   */
@@ -6825,7 +6825,7 @@ void ncr_int_sir (struct ncb *np)
                */
                OUTB (HS_PRT, HS_BUSY);
 
-               /* fall through */
+               fallthrough;
 
        case SIR_NEGO_PROTO:
                /*-------------------------------------------------------
index 8655ff1..bc5a623 100644 (file)
@@ -1113,7 +1113,7 @@ static irqreturn_t nspintr(int irq, void *dev_id)
                        nsp_scsi_done(tmpSC);
                        return IRQ_HANDLED;
                }
-               /* fall thru */
+               fallthrough;
        default:
                if ((irq_status & (IRQSTATUS_SCSI | IRQSTATUS_FIFO)) == 0) {
                        return IRQ_HANDLED;
index 337e79d..9889bab 100644 (file)
@@ -818,7 +818,7 @@ pm8001_exec_internal_task_abort(struct pm8001_hba_info *pm8001_ha,
 
                res = pm8001_tag_alloc(pm8001_ha, &ccb_tag);
                if (res)
-                       return res;
+                       goto ex_err;
                ccb = &pm8001_ha->ccb_info[ccb_tag];
                ccb->device = pm8001_dev;
                ccb->ccb_tag = ccb_tag;
index 0ae800c..aa41f7a 100644 (file)
@@ -717,7 +717,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
                        }
                        cmd->SCp.phase++;
                }
-               /* fall through */
+               fallthrough;
 
        case 2:         /* Phase 2 - We are now talking to the scsi bus */
                if (!ppa_select(dev, scmd_id(cmd))) {
@@ -725,7 +725,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
                        return 0;
                }
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 3:         /* Phase 3 - Ready to accept a command */
                w_ctr(ppb, 0x0c);
@@ -735,7 +735,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
                if (!ppa_send_command(cmd))
                        return 0;
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 4:         /* Phase 4 - Setup scatter/gather buffers */
                if (scsi_bufflen(cmd)) {
@@ -749,7 +749,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
                }
                cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 5:         /* Phase 5 - Data transfer stage */
                w_ctr(ppb, 0x0c);
@@ -762,7 +762,7 @@ static int ppa_engine(ppa_struct *dev, struct scsi_cmnd *cmd)
                if (retv == 0)
                        return 1;
                cmd->SCp.phase++;
-               /* fall through */
+               fallthrough;
 
        case 6:         /* Phase 6 - Read status/message */
                cmd->result = DID_OK << 16;
index 3f04f2c..5ca424d 100644 (file)
@@ -3863,7 +3863,7 @@ void qedf_stag_change_work(struct work_struct *work)
            container_of(work, struct qedf_ctx, stag_work.work);
 
        if (!qedf) {
-               QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+               QEDF_ERR(NULL, "qedf is NULL");
                return;
        }
        QEDF_ERR(&qedf->dbg_ctx, "Performing software context reset.\n");
index 91eb690..e1d7de6 100644 (file)
@@ -380,5 +380,8 @@ extern int qla24xx_soft_reset(struct qla_hw_data *);
 static inline int
 ql_mask_match(uint level)
 {
+       if (ql2xextended_error_logging == 1)
+               ql2xextended_error_logging = QL_DBG_DEFAULT1_MASK;
+
        return (level & ql2xextended_error_logging) == level;
 }
index 8c92af5..a165120 100644 (file)
@@ -1626,7 +1626,7 @@ typedef struct {
         */
        uint8_t  firmware_options[2];
 
-       uint16_t frame_payload_size;
+       __le16  frame_payload_size;
        __le16  max_iocb_allocation;
        __le16  execution_throttle;
        uint8_t  retry_count;
@@ -3880,6 +3880,7 @@ struct qla_hw_data {
                uint32_t        scm_supported_f:1;
                                /* Enabled in Driver */
                uint32_t        scm_enabled:1;
+               uint32_t        max_req_queue_warned:1;
        } flags;
 
        uint16_t max_exchg;
index df670fb..b569fd6 100644 (file)
@@ -177,7 +177,7 @@ qla2x00_chk_ms_status(scsi_qla_host_t *vha, ms_iocb_entry_t *ms_pkt,
                        break;
                case CS_TIMEOUT:
                        rval = QLA_FUNCTION_TIMEOUT;
-                       /* fall through */
+                       fallthrough;
                default:
                        ql_dbg(ql_dbg_disc, vha, 0x2033,
                            "%s failed, completion status (%x) on port_id: "
@@ -1505,11 +1505,11 @@ qla2x00_prep_ct_fdmi_req(struct ct_sns_pkt *p, uint16_t cmd,
 static uint
 qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
 {
+       uint speeds = 0;
+
        if (IS_CNA_CAPABLE(ha))
                return FDMI_PORT_SPEED_10GB;
        if (IS_QLA28XX(ha) || IS_QLA27XX(ha)) {
-               uint speeds = 0;
-
                if (ha->max_supported_speed == 2) {
                        if (ha->min_supported_speed <= 6)
                                speeds |= FDMI_PORT_SPEED_64GB;
@@ -1536,9 +1536,16 @@ qla25xx_fdmi_port_speed_capability(struct qla_hw_data *ha)
                }
                return speeds;
        }
-       if (IS_QLA2031(ha))
-               return FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
-                       FDMI_PORT_SPEED_4GB;
+       if (IS_QLA2031(ha)) {
+               if ((ha->pdev->subsystem_vendor == 0x103C) &&
+                   (ha->pdev->subsystem_device == 0x8002)) {
+                       speeds = FDMI_PORT_SPEED_16GB;
+               } else {
+                       speeds = FDMI_PORT_SPEED_16GB|FDMI_PORT_SPEED_8GB|
+                               FDMI_PORT_SPEED_4GB;
+               }
+               return speeds;
+       }
        if (IS_QLA25XX(ha))
                return FDMI_PORT_SPEED_8GB|FDMI_PORT_SPEED_4GB|
                        FDMI_PORT_SPEED_2GB|FDMI_PORT_SPEED_1GB;
@@ -3436,7 +3443,6 @@ void qla24xx_async_gnnft_done(scsi_qla_host_t *vha, srb_t *sp)
                        list_for_each_entry(fcport, &vha->vp_fcports, list) {
                                if ((fcport->flags & FCF_FABRIC_DEVICE) != 0) {
                                        fcport->scan_state = QLA_FCPORT_SCAN;
-                                       fcport->logout_on_delete = 0;
                                }
                        }
                        goto login_logout;
@@ -3532,10 +3538,22 @@ login_logout:
                }
 
                if (fcport->scan_state != QLA_FCPORT_FOUND) {
+                       bool do_delete = false;
+
+                       if (fcport->scan_needed &&
+                           fcport->disc_state == DSC_LOGIN_PEND) {
+                               /* Cable got disconnected after we sent
+                                * a login. Do delete to prevent timeout.
+                                */
+                               fcport->logout_on_delete = 1;
+                               do_delete = true;
+                       }
+
                        fcport->scan_needed = 0;
-                       if ((qla_dual_mode_enabled(vha) ||
-                               qla_ini_mode_enabled(vha)) &&
-                           atomic_read(&fcport->state) == FCS_ONLINE) {
+                       if (((qla_dual_mode_enabled(vha) ||
+                             qla_ini_mode_enabled(vha)) &&
+                           atomic_read(&fcport->state) == FCS_ONLINE) ||
+                               do_delete) {
                                if (fcport->loop_id != FC_NO_LOOP_ID) {
                                        if (fcport->flags & FCF_FCP2_DEVICE)
                                                fcport->logout_on_delete = 0;
@@ -3736,6 +3754,18 @@ static void qla2x00_async_gpnft_gnnft_sp_done(srb_t *sp, int res)
                unsigned long flags;
                const char *name = sp->name;
 
+               if (res == QLA_OS_TIMER_EXPIRED) {
+                       /* switch is ignoring all commands.
+                        * This might be a zone disable behavior.
+                        * This means we hit 64s timeout.
+                        * 22s GPNFT + 44s Abort = 64s
+                        */
+                       ql_dbg(ql_dbg_disc, vha, 0xffff,
+                              "%s: Switch Zone check please .\n",
+                              name);
+                       qla2x00_mark_all_devices_lost(vha);
+               }
+
                /*
                 * We are in an Interrupt context, queue up this
                 * sp for GNNFT_DONE work. This will allow all
index 57a2d76..0bd04a6 100644 (file)
@@ -857,7 +857,7 @@ static void qla24xx_handle_gnl_done_event(scsi_qla_host_t *vha,
                                            fcport);
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                if (fcport_is_smaller(fcport)) {
                                        /* local adapter is bigger */
@@ -4603,18 +4603,18 @@ qla2x00_nvram_config(scsi_qla_host_t *vha)
                        nv->firmware_options[1] = BIT_7 | BIT_5;
                        nv->add_firmware_options[0] = BIT_5;
                        nv->add_firmware_options[1] = BIT_5 | BIT_4;
-                       nv->frame_payload_size = 2048;
+                       nv->frame_payload_size = cpu_to_le16(2048);
                        nv->special_options[1] = BIT_7;
                } else if (IS_QLA2200(ha)) {
                        nv->firmware_options[0] = BIT_2 | BIT_1;
                        nv->firmware_options[1] = BIT_7 | BIT_5;
                        nv->add_firmware_options[0] = BIT_5;
                        nv->add_firmware_options[1] = BIT_5 | BIT_4;
-                       nv->frame_payload_size = 1024;
+                       nv->frame_payload_size = cpu_to_le16(1024);
                } else if (IS_QLA2100(ha)) {
                        nv->firmware_options[0] = BIT_3 | BIT_1;
                        nv->firmware_options[1] = BIT_5;
-                       nv->frame_payload_size = 1024;
+                       nv->frame_payload_size = cpu_to_le16(1024);
                }
 
                nv->max_iocb_allocation = cpu_to_le16(256);
index e3d2dea..0954fa4 100644 (file)
@@ -2874,7 +2874,7 @@ static void qla2x00_els_dcmd2_sp_done(srb_t *sp, int res)
                                            &vha->dpc_flags);
                                        qla2xxx_wake_dpc(vha);
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                ql_dbg(ql_dbg_disc, vha, 0x20eb,
                                    "%s %8phC cmd error fw_status 0x%x 0x%x 0x%x\n",
index 27bcd34..25e0a16 100644 (file)
@@ -1580,11 +1580,11 @@ global_port_update:
                                qla2xxx_wake_dpc(vha);
                        }
                }
-               /* fall through */
+               fallthrough;
        case MBA_IDC_COMPLETE:
                if (ha->notify_lb_portup_comp && !vha->vp_idx)
                        complete(&ha->lb_portup_comp);
-               /* Fallthru */
+               fallthrough;
        case MBA_IDC_TIME_EXT:
                if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) ||
                    IS_QLA8044(ha))
@@ -2024,8 +2024,8 @@ qla24xx_els_ct_entry(scsi_qla_host_t *vha, struct req_que *req,
                                res = DID_ERROR << 16;
                        }
                }
-               ql_dbg(ql_dbg_user, vha, 0x503f,
-                   "ELS IOCB Done -%s error hdl=%x comp_status=0x%x error subcode 1=0x%x error subcode 2=0x%x total_byte=0x%x\n",
+               ql_dbg(ql_dbg_disc, vha, 0x503f,
+                   "ELS IOCB Done -%s hdl=%x comp_status=0x%x error subcode 1=0x%x error subcode 2=0x%x total_byte=0x%x\n",
                    type, sp->handle, comp_status, fw_status[1], fw_status[2],
                    le32_to_cpu(ese->total_byte_count));
                goto els_ct_done;
@@ -2188,7 +2188,7 @@ qla24xx_logio_entry(scsi_qla_host_t *vha, struct req_que *req,
                                set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
                        qla2xxx_wake_dpc(vha);
                }
-               /* fall through */
+               fallthrough;
        default:
                data[0] = MBS_COMMAND_ERROR;
                break;
@@ -2368,7 +2368,7 @@ static void qla24xx_nvme_iocb_entry(scsi_qla_host_t *vha, struct req_que *req,
        case CS_PORT_UNAVAILABLE:
        case CS_PORT_LOGGED_OUT:
                fcport->nvme_flag |= NVME_FLAG_RESETTING;
-               /* fall through */
+               fallthrough;
        case CS_ABORTED:
        case CS_PORT_BUSY:
                fd->transferred_length = 0;
@@ -3485,7 +3485,7 @@ process_err:
                        } else {
                                qlt_24xx_process_atio_queue(vha, 1);
                        }
-                       /* fall through */
+                       fallthrough;
                case ABTS_RESP_24XX:
                case CTIO_TYPE7:
                case CTIO_CRC2:
index 7388343..226f142 100644 (file)
@@ -334,14 +334,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                        if (time_after(jiffies, wait_time))
                                break;
 
-                       /*
-                        * Check if it's UNLOADING, cause we cannot poll in
-                        * this case, or else a NULL pointer dereference
-                        * is triggered.
-                        */
-                       if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)))
-                               return QLA_FUNCTION_TIMEOUT;
-
                        /* Check for pending interrupts. */
                        qla2x00_poll(ha->rsp_q_map[0]);
 
@@ -5240,7 +5232,7 @@ qla2x00_read_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t *data)
        mcp->mb[8] = MSW(risc_addr);
        mcp->out_mb = MBX_8|MBX_1|MBX_0;
        mcp->in_mb = MBX_3|MBX_2|MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(vha, mcp);
        if (rval != QLA_SUCCESS) {
@@ -5428,7 +5420,7 @@ qla2x00_write_ram_word(scsi_qla_host_t *vha, uint32_t risc_addr, uint32_t data)
        mcp->mb[8] = MSW(risc_addr);
        mcp->out_mb = MBX_8|MBX_3|MBX_2|MBX_1|MBX_0;
        mcp->in_mb = MBX_1|MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(vha, mcp);
        if (rval != QLA_SUCCESS) {
@@ -5700,7 +5692,7 @@ qla24xx_set_fcp_prio(scsi_qla_host_t *vha, uint16_t loop_id, uint16_t priority,
        mcp->mb[9] = vha->vp_idx;
        mcp->out_mb = MBX_9|MBX_4|MBX_3|MBX_2|MBX_1|MBX_0;
        mcp->in_mb = MBX_4|MBX_3|MBX_1|MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
        rval = qla2x00_mailbox_command(vha, mcp);
        if (mb != NULL) {
@@ -5787,7 +5779,7 @@ qla82xx_mbx_intr_enable(scsi_qla_host_t *vha)
 
        mcp->out_mb = MBX_1|MBX_0;
        mcp->in_mb = MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
 
        rval = qla2x00_mailbox_command(vha, mcp);
@@ -5822,7 +5814,7 @@ qla82xx_mbx_intr_disable(scsi_qla_host_t *vha)
 
        mcp->out_mb = MBX_1|MBX_0;
        mcp->in_mb = MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
 
        rval = qla2x00_mailbox_command(vha, mcp);
@@ -6014,7 +6006,7 @@ qla81xx_set_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg)
        if (IS_QLA8031(ha))
                mcp->out_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
        mcp->in_mb = MBX_0;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
 
        rval = qla2x00_mailbox_command(vha, mcp);
@@ -6050,7 +6042,7 @@ qla81xx_get_led_config(scsi_qla_host_t *vha, uint16_t *led_cfg)
        mcp->in_mb = MBX_2|MBX_1|MBX_0;
        if (IS_QLA8031(ha))
                mcp->in_mb |= MBX_6|MBX_5|MBX_4|MBX_3;
-       mcp->tov = 30;
+       mcp->tov = MBX_TOV_SECONDS;
        mcp->flags = 0;
 
        rval = qla2x00_mailbox_command(vha, mcp);
index fa695a4..90bbc61 100644 (file)
@@ -536,6 +536,11 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport,
        struct nvme_private *priv = fd->private;
        struct qla_nvme_rport *qla_rport = rport->private;
 
+       if (!priv) {
+               /* nvme association has been torn down */
+               return rval;
+       }
+
        fcport = qla_rport->fcport;
 
        if (!qpair || !fcport || (qpair && !qpair->fw_started) ||
@@ -687,7 +692,15 @@ int qla_nvme_register_hba(struct scsi_qla_host *vha)
        tmpl = &qla_nvme_fc_transport;
 
        WARN_ON(vha->nvme_local_port);
-       WARN_ON(ha->max_req_queues < 3);
+
+       if (ha->max_req_queues < 3) {
+               if (!ha->flags.max_req_queue_warned)
+                       ql_log(ql_log_info, vha, 0x2120,
+                              "%s: Disabling FC-NVME due to lack of free queue pairs (%d).\n",
+                              __func__, ha->max_req_queues);
+               ha->flags.max_req_queue_warned = 1;
+               return ret;
+       }
 
        qla_nvme_fc_transport.max_hw_queues =
            min((uint8_t)(qla_nvme_fc_transport.max_hw_queues),
index 9b59f03..8da00ba 100644 (file)
@@ -2017,6 +2017,11 @@ skip_pio:
        /* Determine queue resources */
        ha->max_req_queues = ha->max_rsp_queues = 1;
        ha->msix_count = QLA_BASE_VECTORS;
+
+       /* Check if FW supports MQ or not */
+       if (!(ha->fw_attributes & BIT_6))
+               goto mqiobase_exit;
+
        if (!ql2xmqsupport || !ql2xnvmeenable ||
            (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
                goto mqiobase_exit;
@@ -2829,10 +2834,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        /* This may fail but that's ok */
        pci_enable_pcie_error_reporting(pdev);
 
-       /* Turn off T10-DIF when FC-NVMe is enabled */
-       if (ql2xnvmeenable)
-               ql2xenabledif = 0;
-
        ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
        if (!ha) {
                ql_log_pci(ql_log_fatal, pdev, 0x0009,
index e161c05..411b8a9 100644 (file)
@@ -2457,7 +2457,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, void *buf,
                                sec_mask = 0x10000;
                                break;
                        }
-                       /* Fall through... */
+                       fallthrough;
 
                case 0x1f: /* Atmel flash. */
                        /* 512k sector size. */
@@ -2466,7 +2466,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, void *buf,
                                sec_mask =   0x80000000;
                                break;
                        }
-                       /* Fall through... */
+                       fallthrough;
 
                case 0x01: /* AMD flash. */
                        if (flash_id == 0x38 || flash_id == 0x40 ||
@@ -2499,7 +2499,7 @@ qla2x00_write_optrom_data(struct scsi_qla_host *vha, void *buf,
                                sec_mask = 0x1e000;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        /* Default to 16 kb sector size. */
                        rest_addr = 0x3fff;
index fbb80a0..2d445bd 100644 (file)
@@ -442,7 +442,7 @@ void qlt_response_pkt_all_vps(struct scsi_qla_host *vha,
                ql_dbg(ql_dbg_tgt, vha, 0xe073,
                        "qla_target(%d):%s: CRC2 Response pkt\n",
                        vha->vp_idx, __func__);
-               /* fall through */
+               fallthrough;
        case CTIO_TYPE7:
        {
                struct ctio7_from_24xx *entry = (struct ctio7_from_24xx *)pkt;
@@ -1270,7 +1270,7 @@ void qlt_schedule_sess_for_deletion(struct fc_port *sess)
 
        qla24xx_chk_fcp_state(sess);
 
-       ql_dbg(ql_dbg_tgt, sess->vha, 0xe001,
+       ql_dbg(ql_dbg_disc, sess->vha, 0xe001,
            "Scheduling sess %p for deletion %8phC\n",
            sess, sess->port_name);
 
@@ -4423,7 +4423,7 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
        case QLA_TGT_CLEAR_TS:
        case QLA_TGT_ABORT_TS:
                abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id);
-               /* fall through */
+               fallthrough;
        case QLA_TGT_CLEAR_ACA:
                h = qlt_find_qphint(vha, mcmd->unpacked_lun);
                mcmd->qpair = h->qpair;
@@ -5057,7 +5057,7 @@ static int qlt_24xx_handle_els(struct scsi_qla_host *vha,
                        res = 1;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case ELS_LOGO:
        case ELS_PRLO:
                spin_lock_irqsave(&ha->tgt.sess_lock, flags);
index bab87e4..676778c 100644 (file)
@@ -2907,7 +2907,7 @@ static int qla4xxx_session_get_param(struct iscsi_cls_session *cls_sess,
                                                chap_tbl.secret_len);
                        }
                }
-               /* fall through */
+               fallthrough;
        default:
                return iscsi_session_get_param(cls_sess, param, buf);
        }
index 3790e8b..48ff7d8 100644 (file)
@@ -200,15 +200,15 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f
        /* Write mailbox command registers. */
        switch (mbox_param[param[0]] >> 4) {
        case 6: sbus_writew(param[5], qpti->qregs + MBOX5);
-               /* Fall through */
+               fallthrough;
        case 5: sbus_writew(param[4], qpti->qregs + MBOX4);
-               /* Fall through */
+               fallthrough;
        case 4: sbus_writew(param[3], qpti->qregs + MBOX3);
-               /* Fall through */
+               fallthrough;
        case 3: sbus_writew(param[2], qpti->qregs + MBOX2);
-               /* Fall through */
+               fallthrough;
        case 2: sbus_writew(param[1], qpti->qregs + MBOX1);
-               /* Fall through */
+               fallthrough;
        case 1: sbus_writew(param[0], qpti->qregs + MBOX0);
        }
 
@@ -259,15 +259,15 @@ static int qlogicpti_mbox_command(struct qlogicpti *qpti, u_short param[], int f
        /* Read back output parameters. */
        switch (mbox_param[param[0]] & 0xf) {
        case 6: param[5] = sbus_readw(qpti->qregs + MBOX5);
-               /* Fall through */
+               fallthrough;
        case 5: param[4] = sbus_readw(qpti->qregs + MBOX4);
-               /* Fall through */
+               fallthrough;
        case 4: param[3] = sbus_readw(qpti->qregs + MBOX3);
-               /* Fall through */
+               fallthrough;
        case 3: param[2] = sbus_readw(qpti->qregs + MBOX2);
-               /* Fall through */
+               fallthrough;
        case 2: param[1] = sbus_readw(qpti->qregs + MBOX1);
-               /* Fall through */
+               fallthrough;
        case 1: param[0] = sbus_readw(qpti->qregs + MBOX0);
        }
 
index 064ed68..1ad7260 100644 (file)
@@ -4482,8 +4482,6 @@ static int resp_open_zone(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
                goto fini;
        }
 
-       if (zc == ZC2_IMPLICIT_OPEN)
-               zbc_close_zone(devip, zsp);
        zbc_open_zone(devip, zsp, true);
 fini:
        write_unlock(macc_lckp);
@@ -5490,9 +5488,11 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
                                u64 d = ktime_get_boottime_ns() - ns_from_boot;
 
                                if (kt <= d) {  /* elapsed duration >= kt */
+                                       spin_lock_irqsave(&sqp->qc_lock, iflags);
                                        sqcp->a_cmnd = NULL;
                                        atomic_dec(&devip->num_in_q);
                                        clear_bit(k, sqp->in_use_bm);
+                                       spin_unlock_irqrestore(&sqp->qc_lock, iflags);
                                        if (new_sd_dp)
                                                kfree(sd_dp);
                                        /* call scsi_done() from this thread */
index 927b1e6..7d3571a 100644 (file)
@@ -599,7 +599,7 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
                        set_host_byte(scmd, DID_ALLOC_FAILURE);
                        return SUCCESS;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case COPY_ABORTED:
        case VOLUME_OVERFLOW:
        case MISCOMPARE:
@@ -621,7 +621,7 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
                        return ADD_TO_MLQUEUE;
                else
                        set_host_byte(scmd, DID_TARGET_FAILURE);
-               /* FALLTHROUGH */
+               fallthrough;
 
        case ILLEGAL_REQUEST:
                if (sshdr.asc == 0x20 || /* Invalid command operation code */
@@ -734,7 +734,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
        switch (status_byte(scmd->result)) {
        case GOOD:
                scsi_handle_queue_ramp_up(scmd->device);
-               /* FALLTHROUGH */
+               fallthrough;
        case COMMAND_TERMINATED:
                return SUCCESS;
        case CHECK_CONDITION:
@@ -755,7 +755,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
                return FAILED;
        case QUEUE_FULL:
                scsi_handle_queue_full(scmd->device);
-               /* fall through */
+               fallthrough;
        case BUSY:
                return NEEDS_RETRY;
        default:
@@ -1302,7 +1302,7 @@ retry_tur:
        case NEEDS_RETRY:
                if (retry_cnt--)
                        goto retry_tur;
-               /*FALLTHRU*/
+               fallthrough;
        case SUCCESS:
                return 0;
        default:
@@ -1739,7 +1739,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
                if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
                    status_byte(scmd->result) == RESERVATION_CONFLICT)
                        return 0;
-               /* fall through */
+               fallthrough;
        case DID_SOFT_ERROR:
                return (scmd->request->cmd_flags & REQ_FAILFAST_DRIVER);
        }
@@ -1810,7 +1810,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
                        set_host_byte(scmd, DID_TIME_OUT);
                        return SUCCESS;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case DID_NO_CONNECT:
        case DID_BAD_TARGET:
                /*
@@ -1854,7 +1854,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
                         * lower down
                         */
                        break;
-               /* fallthrough */
+               fallthrough;
        case DID_BUS_BUSY:
        case DID_PARITY:
                goto maybe_retry;
@@ -1892,7 +1892,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
                 * the case of trying to send too many commands to a
                 * tagged queueing device.
                 */
-               /* FALLTHROUGH */
+               fallthrough;
        case BUSY:
                /*
                 * device can't talk to us at the moment.  Should only
@@ -1905,7 +1905,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
                if (scmd->cmnd[0] == REPORT_LUNS)
                        scmd->device->sdev_target->expecting_lun_change = 0;
                scsi_handle_queue_ramp_up(scmd->device);
-               /* FALLTHROUGH */
+               fallthrough;
        case COMMAND_TERMINATED:
                return SUCCESS;
        case TASK_ABORTED:
@@ -2376,22 +2376,22 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
                rtn = scsi_try_bus_device_reset(scmd);
                if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        case SG_SCSI_RESET_TARGET:
                rtn = scsi_try_target_reset(scmd);
                if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        case SG_SCSI_RESET_BUS:
                rtn = scsi_try_bus_reset(scmd);
                if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        case SG_SCSI_RESET_HOST:
                rtn = scsi_try_host_reset(scmd);
                if (rtn == SUCCESS)
                        break;
-               /* FALLTHROUGH */
+               fallthrough;
        default:
                rtn = FAILED;
                break;
index 45d04b7..14872c9 100644 (file)
@@ -117,14 +117,14 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
                case NOT_READY: /* This happens if there is no disc in drive */
                        if (sdev->removable)
                                break;
-                       /* FALLTHROUGH */
+                       fallthrough;
                case UNIT_ATTENTION:
                        if (sdev->removable) {
                                sdev->changed = 1;
                                result = 0;     /* This is no longer considered an error */
                                break;
                        }
-                       /* FALLTHROUGH -- for non-removable media */
+                       fallthrough;    /* for non-removable media */
                default:
                        sdev_printk(KERN_INFO, sdev,
                                    "ioctl_internal_command return code = %x\n",
index 7c6dd6f..7affaaf 100644 (file)
@@ -795,7 +795,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)
                }
                if (!scsi_end_request(req, blk_stat, blk_rq_err_bytes(req)))
                        return;
-               /*FALLTHRU*/
+               fallthrough;
        case ACTION_REPREP:
                scsi_io_completion_reprep(cmd, q);
                break;
index bd38c8c..ca1e6cf 100644 (file)
@@ -516,7 +516,7 @@ static int pqi_build_raid_path_request(struct pqi_ctrl_info *ctrl_info,
                break;
        case BMIC_SENSE_DIAG_OPTIONS:
                cdb_length = 0;
-               /* fall through */
+               fallthrough;
        case BMIC_IDENTIFY_CONTROLLER:
        case BMIC_IDENTIFY_PHYSICAL_DEVICE:
        case BMIC_SENSE_SUBSYSTEM_INFORMATION:
@@ -527,7 +527,7 @@ static int pqi_build_raid_path_request(struct pqi_ctrl_info *ctrl_info,
                break;
        case BMIC_SET_DIAG_OPTIONS:
                cdb_length = 0;
-               /* fall through */
+               fallthrough;
        case BMIC_WRITE_HOST_WELLNESS:
                request->data_direction = SOP_WRITE_FLAG;
                cdb[0] = BMIC_WRITE;
@@ -2324,7 +2324,7 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
        switch (scmd->cmnd[0]) {
        case WRITE_6:
                is_write = true;
-               /* fall through */
+               fallthrough;
        case READ_6:
                first_block = (u64)(((scmd->cmnd[1] & 0x1f) << 16) |
                        (scmd->cmnd[2] << 8) | scmd->cmnd[3]);
@@ -2334,21 +2334,21 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info,
                break;
        case WRITE_10:
                is_write = true;
-               /* fall through */
+               fallthrough;
        case READ_10:
                first_block = (u64)get_unaligned_be32(&scmd->cmnd[2]);
                block_cnt = (u32)get_unaligned_be16(&scmd->cmnd[7]);
                break;
        case WRITE_12:
                is_write = true;
-               /* fall through */
+               fallthrough;
        case READ_12:
                first_block = (u64)get_unaligned_be32(&scmd->cmnd[2]);
                block_cnt = get_unaligned_be32(&scmd->cmnd[6]);
                break;
        case WRITE_16:
                is_write = true;
-               /* fall through */
+               fallthrough;
        case READ_16:
                first_block = get_unaligned_be64(&scmd->cmnd[2]);
                block_cnt = get_unaligned_be32(&scmd->cmnd[10]);
@@ -2948,7 +2948,7 @@ static unsigned int pqi_process_io_intr(struct pqi_ctrl_info *ctrl_info,
                case PQI_RESPONSE_IU_AIO_PATH_IO_SUCCESS:
                        if (io_request->scmd)
                                io_request->scmd->result = 0;
-                       /* fall through */
+                       fallthrough;
                case PQI_RESPONSE_IU_GENERAL_MANAGEMENT:
                        break;
                case PQI_RESPONSE_IU_VENDOR_GENERAL:
@@ -3115,12 +3115,11 @@ static void pqi_process_soft_reset(struct pqi_ctrl_info *ctrl_info,
 
        switch (reset_status) {
        case RESET_INITIATE_DRIVER:
-               /* fall through */
        case RESET_TIMEDOUT:
                dev_info(&ctrl_info->pci_dev->dev,
                        "resetting controller %u\n", ctrl_info->ctrl_id);
                sis_soft_reset(ctrl_info);
-               /* fall through */
+               fallthrough;
        case RESET_INITIATE_FIRMWARE:
                rc = pqi_ofa_ctrl_restart(ctrl_info);
                pqi_ofa_free_host_buffer(ctrl_info);
index 0c4aa46..3b3a53c 100644 (file)
@@ -877,10 +877,10 @@ static void get_sectorsize(struct scsi_cd *cd)
                case 2340:
                case 2352:
                        sector_size = 2048;
-                       /* fall through */
+                       fallthrough;
                case 2048:
                        cd->capacity *= 4;
-                       /* fall through */
+                       fallthrough;
                case 512:
                        break;
                default:
index 87fbc0e..e2e5356 100644 (file)
@@ -339,14 +339,14 @@ static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s)
                switch (sense[0] & 0x7f) {
                case 0x71:
                        s->deferred = 1;
-                       /* fall through */
+                       fallthrough;
                case 0x70:
                        s->fixed_format = 1;
                        s->flags = sense[2] & 0xe0;
                        break;
                case 0x73:
                        s->deferred = 1;
-                       /* fall through */
+                       fallthrough;
                case 0x72:
                        s->fixed_format = 0;
                        ucp = scsi_sense_desc_find(sense, SCSI_SENSE_BUFFERSIZE, 4);
@@ -2723,7 +2723,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
        switch (cmd_in) {
        case MTFSFM:
                chg_eof = 0;    /* Changed from the FSF after this */
-               /* fall through */
+               fallthrough;
        case MTFSF:
                cmd[0] = SPACE;
                cmd[1] = 0x01;  /* Space FileMarks */
@@ -2738,7 +2738,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
                break;
        case MTBSFM:
                chg_eof = 0;    /* Changed from the FSF after this */
-               /* fall through */
+               fallthrough;
        case MTBSF:
                cmd[0] = SPACE;
                cmd[1] = 0x01;  /* Space FileMarks */
index 701b842..2e3fbc2 100644 (file)
@@ -397,12 +397,12 @@ static int sun3scsi_dma_finish(int write_flag)
                case CSR_LEFT_3:
                        *vaddr = (dregs->bpack_lo & 0xff00) >> 8;
                        vaddr--;
-                       /* Fall through */
+                       fallthrough;
 
                case CSR_LEFT_2:
                        *vaddr = (dregs->bpack_hi & 0x00ff);
                        vaddr--;
-                       /* Fall through */
+                       fallthrough;
 
                case CSR_LEFT_1:
                        *vaddr = (dregs->bpack_hi & 0xff00) >> 8;
index 6d7651a..c6db61b 100644 (file)
@@ -523,7 +523,7 @@ void sym_fw_bind_script(struct sym_hcb *np, u32 *start, int len)
                                        new = old;
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                new = 0;
                                panic("sym_fw_bind_script: "
index 8410117..cc11daa 100644 (file)
@@ -3059,7 +3059,7 @@ static void sym_sir_bad_scsi_status(struct sym_hcb *np, int num, struct sym_ccb
                        sym_print_addr(cp->cmd, "%s\n",
                                s_status == S_BUSY ? "BUSY" : "QUEUE FULL\n");
                }
-               /* fall through */
+               fallthrough;
        default:        /* S_INT, S_INT_COND_MET, S_CONFLICT */
                sym_complete_error (np, cp);
                break;
@@ -4620,7 +4620,7 @@ static void sym_int_sir(struct sym_hcb *np)
         *  Negotiation failed.
         *  Target does not want answer message.
         */
-       /* fall through */
+               fallthrough;
        case SIR_NEGO_PROTO:
                sym_nego_default(np, tp, cp);
                goto out;
index d37e2a6..e13d535 100644 (file)
@@ -695,7 +695,7 @@ static int sym_read_Tekram_nvram (struct sym_device *np, Tekram_nvram *nvram)
                                          data, len);
                if (!x)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                x = sym_read_T93C46_nvram(np, nvram);
                break;
index 46bb905..eafe0db 100644 (file)
@@ -38,6 +38,7 @@ static int ti_j721e_ufs_probe(struct platform_device *pdev)
        /* Select MPHY refclk frequency */
        clk = devm_clk_get(dev, NULL);
        if (IS_ERR(clk)) {
+               ret = PTR_ERR(clk);
                dev_err(dev, "Cannot claim MPHY clock.\n");
                goto clk_err;
        }
index 29cd017..1755dd6 100644 (file)
@@ -212,7 +212,7 @@ static int ufs_mtk_wait_link_state(struct ufs_hba *hba, u32 state,
        ktime_t timeout, time_checked;
        u32 val;
 
-       timeout = ktime_add_us(ktime_get(), ms_to_ktime(max_wait_ms));
+       timeout = ktime_add_ms(ktime_get(), max_wait_ms);
        do {
                time_checked = ktime_get();
                ufshcd_writel(hba, 0x20, REG_UFS_DEBUG_SEL);
index bcfbbd0..5b2bc1a 100644 (file)
@@ -110,7 +110,7 @@ static int ufs_bsg_request(struct bsg_job *job)
                        goto out;
                }
 
-               /* fall through */
+               fallthrough;
        case UPIU_TRANSACTION_NOP_OUT:
        case UPIU_TRANSACTION_TASK_REQ:
                ret = ufshcd_exec_raw_upiu_cmd(hba, &bsg_request->upiu_req,
index f407b13..5a95a7b 100644 (file)
@@ -44,11 +44,23 @@ static int ufs_intel_link_startup_notify(struct ufs_hba *hba,
        return err;
 }
 
+static int ufs_intel_ehl_init(struct ufs_hba *hba)
+{
+       hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8;
+       return 0;
+}
+
 static struct ufs_hba_variant_ops ufs_intel_cnl_hba_vops = {
        .name                   = "intel-pci",
        .link_startup_notify    = ufs_intel_link_startup_notify,
 };
 
+static struct ufs_hba_variant_ops ufs_intel_ehl_hba_vops = {
+       .name                   = "intel-pci",
+       .init                   = ufs_intel_ehl_init,
+       .link_startup_notify    = ufs_intel_link_startup_notify,
+};
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * ufshcd_pci_suspend - suspend power management function
@@ -177,8 +189,8 @@ static const struct dev_pm_ops ufshcd_pci_pm_ops = {
 static const struct pci_device_id ufshcd_pci_tbl[] = {
        { PCI_VENDOR_ID_SAMSUNG, 0xC00C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
        { PCI_VDEVICE(INTEL, 0x9DFA), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
-       { PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
-       { PCI_VDEVICE(INTEL, 0x4B43), (kernel_ulong_t)&ufs_intel_cnl_hba_vops },
+       { PCI_VDEVICE(INTEL, 0x4B41), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
+       { PCI_VDEVICE(INTEL, 0x4B43), (kernel_ulong_t)&ufs_intel_ehl_hba_vops },
        { }     /* terminate list */
 };
 
index 3076222..1d157ff 100644 (file)
@@ -1561,6 +1561,7 @@ unblock_reqs:
 int ufshcd_hold(struct ufs_hba *hba, bool async)
 {
        int rc = 0;
+       bool flush_result;
        unsigned long flags;
 
        if (!ufshcd_is_clkgating_allowed(hba))
@@ -1592,7 +1593,9 @@ start:
                                break;
                        }
                        spin_unlock_irqrestore(hba->host->host_lock, flags);
-                       flush_work(&hba->clk_gating.ungate_work);
+                       flush_result = flush_work(&hba->clk_gating.ungate_work);
+                       if (hba->clk_gating.is_suspended && !flush_result)
+                               goto out;
                        spin_lock_irqsave(hba->host->host_lock, flags);
                        goto start;
                }
@@ -1609,7 +1612,7 @@ start:
                 * currently running. Hence, fall through to cancel gating
                 * work and to enable clocks.
                 */
-               /* fallthrough */
+               fallthrough;
        case CLKS_OFF:
                ufshcd_scsi_block_requests(hba);
                hba->clk_gating.state = REQ_CLKS_ON;
@@ -1621,7 +1624,7 @@ start:
                 * fall through to check if we should wait for this
                 * work to be done or not.
                 */
-               /* fallthrough */
+               fallthrough;
        case REQ_CLKS_ON:
                if (async) {
                        rc = -EAGAIN;
@@ -4734,7 +4737,7 @@ ufshcd_scsi_cmd_status(struct ufshcd_lrb *lrbp, int scsi_status)
        switch (scsi_status) {
        case SAM_STAT_CHECK_CONDITION:
                ufshcd_copy_sense_data(lrbp);
-               /* fallthrough */
+               fallthrough;
        case SAM_STAT_GOOD:
                result |= DID_OK << 16 |
                          COMMAND_COMPLETE << 8 |
@@ -5941,7 +5944,7 @@ static irqreturn_t ufshcd_sl_intr(struct ufs_hba *hba, u32 intr_status)
  */
 static irqreturn_t ufshcd_intr(int irq, void *__hba)
 {
-       u32 intr_status, enabled_intr_status;
+       u32 intr_status, enabled_intr_status = 0;
        irqreturn_t retval = IRQ_NONE;
        struct ufs_hba *hba = __hba;
        int retries = hba->nutrs;
@@ -5955,7 +5958,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
         * read, make sure we handle them by checking the interrupt status
         * again in a loop until we process all of the reqs before returning.
         */
-       do {
+       while (intr_status && retries--) {
                enabled_intr_status =
                        intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
                if (intr_status)
@@ -5964,9 +5967,9 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
                        retval |= ufshcd_sl_intr(hba, enabled_intr_status);
 
                intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
-       } while (intr_status && --retries);
+       }
 
-       if (retval == IRQ_NONE) {
+       if (enabled_intr_status && retval == IRQ_NONE) {
                dev_err(hba->dev, "%s: Unhandled interrupt 0x%08x\n",
                                        __func__, intr_status);
                ufshcd_dump_regs(hba, 0, UFSHCI_REG_SPACE_SIZE, "host_regs: ");
@@ -6274,7 +6277,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
        switch (msgcode) {
        case UPIU_TRANSACTION_NOP_OUT:
                cmd_type = DEV_CMD_TYPE_NOP;
-               /* fall through */
+               fallthrough;
        case UPIU_TRANSACTION_QUERY_REQ:
                ufshcd_hold(hba, false);
                mutex_lock(&hba->dev_cmd.lock);
@@ -6434,14 +6437,8 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
                goto out;
        }
 
-       if (!(reg & (1 << tag))) {
-               dev_err(hba->dev,
-               "%s: cmd was completed, but without a notifying intr, tag = %d",
-               __func__, tag);
-       }
-
        /* Print Transfer Request of aborted task */
-       dev_err(hba->dev, "%s: Device abort task at tag %d\n", __func__, tag);
+       dev_info(hba->dev, "%s: Device abort task at tag %d\n", __func__, tag);
 
        /*
         * Print detailed info about aborted request.
@@ -6462,6 +6459,13 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
        }
        hba->req_abort_count++;
 
+       if (!(reg & (1 << tag))) {
+               dev_err(hba->dev,
+               "%s: cmd was completed, but without a notifying intr, tag = %d",
+               __func__, tag);
+               goto cleanup;
+       }
+
        /* Skip task abort in case previous aborts failed and report failure */
        if (lrbp->req_abort_skip) {
                err = -EIO;
@@ -6492,7 +6496,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
                        /* command completed already */
                        dev_err(hba->dev, "%s: cmd at tag %d successfully cleared from DB.\n",
                                __func__, tag);
-                       goto out;
+                       goto cleanup;
                } else {
                        dev_err(hba->dev,
                                "%s: no response from device. tag = %d, err %d\n",
@@ -6526,6 +6530,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
                goto out;
        }
 
+cleanup:
        scsi_dma_unmap(cmd);
 
        spin_lock_irqsave(host->host_lock, flags);
index b2ef18f..363589c 100644 (file)
@@ -520,6 +520,12 @@ enum ufshcd_quirks {
         * OCS FATAL ERROR with device error through sense data
         */
        UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR             = 1 << 10,
+
+       /*
+        * This quirk needs to be enabled if the host controller has
+        * auto-hibernate capability but it doesn't work.
+        */
+       UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8                = 1 << 11,
 };
 
 enum ufshcd_caps {
@@ -803,7 +809,8 @@ return true;
 
 static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
 {
-       return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT);
+       return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) &&
+               !(hba->quirks & UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8);
 }
 
 static inline bool ufshcd_is_auto_hibern8_enabled(struct ufs_hba *hba)
index ca1c39b..3b18034 100644 (file)
@@ -148,7 +148,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
        default:
                scmd_printk(KERN_WARNING, sc, "Unknown response %d",
                            resp->response);
-               /* fall through */
+               fallthrough;
        case VIRTIO_SCSI_S_FAILURE:
                set_host_byte(sc, DID_ERROR);
                break;
index 8dbb4db..081f54a 100644 (file)
@@ -607,7 +607,7 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
                case BTSTAT_TAGREJECT:
                case BTSTAT_BADMSG:
                        cmd->result = (DRIVER_INVALID << 24);
-                       /* fall through */
+                       fallthrough;
 
                case BTSTAT_HAHARDWARE:
                case BTSTAT_INVPHASE:
index f81046f..87dafbc 100644 (file)
@@ -1854,7 +1854,7 @@ round_4(unsigned int x)
                case 1: --x;
                        break;
                case 2: ++x;
-                       /* fall through */
+                       fallthrough;
                case 3: ++x;
        }
        return x;
index f0068e9..259fc24 100644 (file)
@@ -1111,7 +1111,7 @@ static void scsifront_backend_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* fall through - Missed the backend's Closing state */
+               fallthrough;    /* Missed the backend's Closing state */
        case XenbusStateClosing:
                scsifront_disconnect(info);
                break;
index ae1e248..1d2bc18 100644 (file)
@@ -301,8 +301,6 @@ int slim_unregister_controller(struct slim_controller *ctrl)
 {
        /* Remove all clients */
        device_for_each_child(ctrl->dev, NULL, slim_ctrl_remove_device);
-       /* Enter Clock Pause */
-       slim_ctrl_clk_pause(ctrl, false, 0);
        ida_simple_remove(&ctrl_ida, ctrl->id);
 
        return 0;
@@ -326,8 +324,8 @@ void slim_report_absent(struct slim_device *sbdev)
        mutex_lock(&ctrl->lock);
        sbdev->is_laddr_valid = false;
        mutex_unlock(&ctrl->lock);
-
-       ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr);
+       if (!ctrl->get_laddr)
+               ida_simple_remove(&ctrl->laddr_ida, sbdev->laddr);
        slim_device_update_status(sbdev, SLIM_DEVICE_STATUS_DOWN);
 }
 EXPORT_SYMBOL_GPL(slim_report_absent);
index 743ee7b..218aefc 100644 (file)
@@ -1277,9 +1277,13 @@ static void qcom_slim_ngd_qmi_del_server(struct qmi_handle *hdl,
 {
        struct qcom_slim_ngd_qmi *qmi =
                container_of(hdl, struct qcom_slim_ngd_qmi, svc_event_hdl);
+       struct qcom_slim_ngd_ctrl *ctrl =
+               container_of(qmi, struct qcom_slim_ngd_ctrl, qmi);
 
        qmi->svc_info.sq_node = 0;
        qmi->svc_info.sq_port = 0;
+
+       qcom_slim_ngd_enable(ctrl, false);
 }
 
 static struct qmi_ops qcom_slim_ngd_qmi_svc_event_ops = {
index e19102f..b25d0f7 100644 (file)
@@ -353,7 +353,7 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
 
                debugfs_create_u32("nmodem_supported", 0400, qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.nmodem_supported);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 14):
                qcom_socinfo->info.num_clusters = __le32_to_cpu(info->num_clusters);
                qcom_socinfo->info.ncluster_array_offset = __le32_to_cpu(info->ncluster_array_offset);
@@ -368,14 +368,14 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
                                   &qcom_socinfo->info.num_defective_parts);
                debugfs_create_u32("ndefective_parts_array_offset", 0400, qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.ndefective_parts_array_offset);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 13):
                qcom_socinfo->info.nproduct_id = __le32_to_cpu(info->nproduct_id);
 
                debugfs_create_u32("nproduct_id", 0400, qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.nproduct_id);
                DEBUGFS_ADD(info, chip_id);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 12):
                qcom_socinfo->info.chip_family =
                        __le32_to_cpu(info->chip_family);
@@ -392,7 +392,7 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
                debugfs_create_x32("raw_device_number", 0400,
                                   qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.raw_device_num);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 11):
        case SOCINFO_VERSION(0, 10):
        case SOCINFO_VERSION(0, 9):
@@ -400,12 +400,12 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
 
                debugfs_create_u32("foundry_id", 0400, qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.foundry_id);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 8):
        case SOCINFO_VERSION(0, 7):
                DEBUGFS_ADD(info, pmic_model);
                DEBUGFS_ADD(info, pmic_die_rev);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 6):
                qcom_socinfo->info.hw_plat_subtype =
                        __le32_to_cpu(info->hw_plat_subtype);
@@ -413,7 +413,7 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
                debugfs_create_u32("hardware_platform_subtype", 0400,
                                   qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.hw_plat_subtype);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 5):
                qcom_socinfo->info.accessory_chip =
                        __le32_to_cpu(info->accessory_chip);
@@ -421,27 +421,27 @@ static void socinfo_debugfs_init(struct qcom_socinfo *qcom_socinfo,
                debugfs_create_u32("accessory_chip", 0400,
                                   qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.accessory_chip);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 4):
                qcom_socinfo->info.plat_ver = __le32_to_cpu(info->plat_ver);
 
                debugfs_create_u32("platform_version", 0400,
                                   qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.plat_ver);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 3):
                qcom_socinfo->info.hw_plat = __le32_to_cpu(info->hw_plat);
 
                debugfs_create_u32("hardware_platform", 0400,
                                   qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.hw_plat);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 2):
                qcom_socinfo->info.raw_ver  = __le32_to_cpu(info->raw_ver);
 
                debugfs_create_u32("raw_version", 0400, qcom_socinfo->dbg_root,
                                   &qcom_socinfo->info.raw_ver);
-               /* Fall through */
+               fallthrough;
        case SOCINFO_VERSION(0, 1):
                DEBUGFS_ADD(info, build_id);
                break;
index 42cf37a..d332e5d 100644 (file)
@@ -2229,7 +2229,7 @@ static int tegra_pmc_clk_notify_cb(struct notifier_block *nb,
 
        case POST_RATE_CHANGE:
                pmc->rate = data->new_rate;
-               /* fall through */
+               fallthrough;
 
        case ABORT_RATE_CHANGE:
                mutex_unlock(&pmc->powergates_lock);
index f4c7887..8eaf31e 100644 (file)
@@ -1437,7 +1437,7 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
                return ret;
        }
 
-       /* Read Instat 1, Instat 2 and Instat 3 registers */
+       /* Read Intstat 1, Intstat 2 and Intstat 3 registers */
        ret = sdw_read(slave, SDW_SCP_INT1);
        if (ret < 0) {
                dev_err(slave->bus->dev,
index 8608b09..1099b5d 100644 (file)
@@ -717,6 +717,7 @@ error:
        kfree(wbuf);
 error_1:
        kfree(wr_msg);
+       bus->defer_msg.msg = NULL;
        return ret;
 }
 
@@ -843,9 +844,10 @@ static int do_bank_switch(struct sdw_stream_runtime *stream)
 error:
        list_for_each_entry(m_rt, &stream->master_list, stream_node) {
                bus = m_rt->bus;
-
-               kfree(bus->defer_msg.msg->buf);
-               kfree(bus->defer_msg.msg);
+               if (bus->defer_msg.msg) {
+                       kfree(bus->defer_msg.msg->buf);
+                       kfree(bus->defer_msg.msg);
+               }
        }
 
 msg_unlock:
index c3008e4..c6ea760 100644 (file)
@@ -1017,4 +1017,7 @@ config SPI_SLAVE_SYSTEM_CONTROL
 
 endif # SPI_SLAVE
 
+config SPI_DYNAMIC
+       def_bool ACPI || OF_DYNAMIC || SPI_SLAVE
+
 endif # SPI
index 2f71781..03b034c 100644 (file)
@@ -164,10 +164,10 @@ static inline void bcm2835aux_rd_fifo(struct bcm2835aux_spi *bs)
                switch (count) {
                case 3:
                        *bs->rx_buf++ = (data >> 16) & 0xff;
-                       /* fallthrough */
+                       fallthrough;
                case 2:
                        *bs->rx_buf++ = (data >> 8) & 0xff;
-                       /* fallthrough */
+                       fallthrough;
                case 1:
                        *bs->rx_buf++ = (data >> 0) & 0xff;
                        /* fallthrough - no default */
index 1c1a9d1..c6795c6 100644 (file)
@@ -907,14 +907,16 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
        struct dma_async_tx_descriptor *tx;
        dma_cookie_t cookie;
        dma_addr_t dma_dst;
+       struct device *ddev;
 
        if (!cqspi->rx_chan || !virt_addr_valid(buf)) {
                memcpy_fromio(buf, cqspi->ahb_base + from, len);
                return 0;
        }
 
-       dma_dst = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
-       if (dma_mapping_error(dev, dma_dst)) {
+       ddev = cqspi->rx_chan->device->dev;
+       dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE);
+       if (dma_mapping_error(ddev, dma_dst)) {
                dev_err(dev, "dma mapping failed\n");
                return -ENOMEM;
        }
@@ -948,7 +950,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
        }
 
 err_unmap:
-       dma_unmap_single(dev, dma_dst, len, DMA_FROM_DEVICE);
+       dma_unmap_single(ddev, dma_dst, len, DMA_FROM_DEVICE);
 
        return ret;
 }
@@ -1128,8 +1130,17 @@ static int cqspi_request_mmap_dma(struct cqspi_st *cqspi)
        return 0;
 }
 
+static const char *cqspi_get_name(struct spi_mem *mem)
+{
+       struct cqspi_st *cqspi = spi_master_get_devdata(mem->spi->master);
+       struct device *dev = &cqspi->pdev->dev;
+
+       return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev), mem->spi->chip_select);
+}
+
 static const struct spi_controller_mem_ops cqspi_mem_ops = {
        .exec_op = cqspi_exec_mem_op,
+       .get_name = cqspi_get_name,
 };
 
 static int cqspi_setup_flash(struct cqspi_st *cqspi)
index 54ad0ac..ee90588 100644 (file)
@@ -226,7 +226,7 @@ static void fsl_spi_free_dummy_rx(void)
        case 1:
                kfree(fsl_dummy_rx);
                fsl_dummy_rx = NULL;
-               /* fall through */
+               fallthrough;
        default:
                fsl_dummy_rx_refcnt--;
                break;
@@ -294,7 +294,7 @@ int fsl_spi_cpm_init(struct mpc8xxx_spi *mspi)
                switch (mspi->subblock) {
                default:
                        dev_warn(dev, "cell-index unspecified, assuming SPI1\n");
-                       /* fall through */
+                       fallthrough;
                case 0:
                        mspi->subblock = QE_CR_SUBBLOCK_SPI1;
                        break;
index 9522d1b..df981e5 100644 (file)
@@ -90,7 +90,7 @@ static struct spi_test spi_tests[] = {
        {
                .description    = "tx/rx-transfer - crossing PAGE_SIZE",
                .fill_option    = FILL_COUNT_8,
-               .iterate_len    = { ITERATE_MAX_LEN },
+               .iterate_len    = { ITERATE_LEN },
                .iterate_tx_align = ITERATE_ALIGN,
                .iterate_rx_align = ITERATE_ALIGN,
                .transfer_count = 1,
index bd23c46..127b8bd 100644 (file)
@@ -506,7 +506,7 @@ static int sprd_adi_probe(struct platform_device *pdev)
                default:
                        dev_err(&pdev->dev,
                                "failed to find hwlock id, %d\n", ret);
-                       /* fall-through */
+                       fallthrough;
                case -EPROBE_DEFER:
                        goto put_ctlr;
                }
index 4c643df..3056428 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/reset.h>
 #include <linux/spi/spi.h>
@@ -441,7 +442,8 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
 {
        u32 div, mbrdiv;
 
-       div = DIV_ROUND_UP(spi->clk_rate, speed_hz);
+       /* Ensure spi->clk_rate is even */
+       div = DIV_ROUND_UP(spi->clk_rate & ~0x1, speed_hz);
 
        /*
         * SPI framework set xfer->speed_hz to master->max_speed_hz if
@@ -467,20 +469,27 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz,
 /**
  * stm32h7_spi_prepare_fthlv - Determine FIFO threshold level
  * @spi: pointer to the spi controller data structure
+ * @xfer_len: length of the message to be transferred
  */
-static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
+static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi, u32 xfer_len)
 {
-       u32 fthlv, half_fifo;
+       u32 fthlv, half_fifo, packet;
 
        /* data packet should not exceed 1/2 of fifo space */
        half_fifo = (spi->fifo_size / 2);
 
+       /* data_packet should not exceed transfer length */
+       if (half_fifo > xfer_len)
+               packet = xfer_len;
+       else
+               packet = half_fifo;
+
        if (spi->cur_bpw <= 8)
-               fthlv = half_fifo;
+               fthlv = packet;
        else if (spi->cur_bpw <= 16)
-               fthlv = half_fifo / 2;
+               fthlv = packet / 2;
        else
-               fthlv = half_fifo / 4;
+               fthlv = packet / 4;
 
        /* align packet size with data registers access */
        if (spi->cur_bpw > 8)
@@ -488,6 +497,9 @@ static u32 stm32h7_spi_prepare_fthlv(struct stm32_spi *spi)
        else
                fthlv -= (fthlv % 4); /* multiple of 4 */
 
+       if (!fthlv)
+               fthlv = 1;
+
        return fthlv;
 }
 
@@ -924,7 +936,11 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
        }
 
        if (sr & STM32H7_SPI_SR_SUSP) {
-               dev_warn(spi->dev, "Communication suspended\n");
+               static DEFINE_RATELIMIT_STATE(rs,
+                                             DEFAULT_RATELIMIT_INTERVAL * 10,
+                                             1);
+               if (__ratelimit(&rs))
+                       dev_dbg_ratelimited(spi->dev, "Communication suspended\n");
                if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
                        stm32h7_spi_read_rxfifo(spi, false);
                /*
@@ -966,13 +982,13 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id)
                if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
                        stm32h7_spi_read_rxfifo(spi, false);
 
-       writel_relaxed(mask, spi->base + STM32H7_SPI_IFCR);
+       writel_relaxed(sr & mask, spi->base + STM32H7_SPI_IFCR);
 
        spin_unlock_irqrestore(&spi->lock, flags);
 
        if (end) {
-               spi_finalize_current_transfer(master);
                stm32h7_spi_disable(spi);
+               spi_finalize_current_transfer(master);
        }
 
        return IRQ_HANDLED;
@@ -1393,7 +1409,7 @@ static void stm32h7_spi_set_bpw(struct stm32_spi *spi)
        cfg1_setb |= (bpw << STM32H7_SPI_CFG1_DSIZE_SHIFT) &
                     STM32H7_SPI_CFG1_DSIZE;
 
-       spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi);
+       spi->cur_fthlv = stm32h7_spi_prepare_fthlv(spi, spi->cur_xferlen);
        fthlv = spi->cur_fthlv - 1;
 
        cfg1_clrb |= STM32H7_SPI_CFG1_FTHLV;
@@ -1585,39 +1601,33 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
        unsigned long flags;
        unsigned int comm_type;
        int nb_words, ret = 0;
+       int mbr;
 
        spin_lock_irqsave(&spi->lock, flags);
 
-       if (spi->cur_bpw != transfer->bits_per_word) {
-               spi->cur_bpw = transfer->bits_per_word;
-               spi->cfg->set_bpw(spi);
-       }
+       spi->cur_xferlen = transfer->len;
 
-       if (spi->cur_speed != transfer->speed_hz) {
-               int mbr;
+       spi->cur_bpw = transfer->bits_per_word;
+       spi->cfg->set_bpw(spi);
 
-               /* Update spi->cur_speed with real clock speed */
-               mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
-                                           spi->cfg->baud_rate_div_min,
-                                           spi->cfg->baud_rate_div_max);
-               if (mbr < 0) {
-                       ret = mbr;
-                       goto out;
-               }
-
-               transfer->speed_hz = spi->cur_speed;
-               stm32_spi_set_mbr(spi, mbr);
+       /* Update spi->cur_speed with real clock speed */
+       mbr = stm32_spi_prepare_mbr(spi, transfer->speed_hz,
+                                   spi->cfg->baud_rate_div_min,
+                                   spi->cfg->baud_rate_div_max);
+       if (mbr < 0) {
+               ret = mbr;
+               goto out;
        }
 
-       comm_type = stm32_spi_communication_type(spi_dev, transfer);
-       if (spi->cur_comm != comm_type) {
-               ret = spi->cfg->set_mode(spi, comm_type);
+       transfer->speed_hz = spi->cur_speed;
+       stm32_spi_set_mbr(spi, mbr);
 
-               if (ret < 0)
-                       goto out;
+       comm_type = stm32_spi_communication_type(spi_dev, transfer);
+       ret = spi->cfg->set_mode(spi, comm_type);
+       if (ret < 0)
+               goto out;
 
-               spi->cur_comm = comm_type;
-       }
+       spi->cur_comm = comm_type;
 
        if (spi->cfg->set_data_idleness)
                spi->cfg->set_data_idleness(spi, transfer->len);
@@ -1635,8 +1645,6 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
                        goto out;
        }
 
-       spi->cur_xferlen = transfer->len;
-
        dev_dbg(spi->dev, "transfer communication mode set to %d\n",
                spi->cur_comm);
        dev_dbg(spi->dev,
@@ -1996,6 +2004,8 @@ static int stm32_spi_remove(struct platform_device *pdev)
 
        pm_runtime_disable(&pdev->dev);
 
+       pinctrl_pm_select_sleep_state(&pdev->dev);
+
        return 0;
 }
 
@@ -2007,13 +2017,18 @@ static int stm32_spi_runtime_suspend(struct device *dev)
 
        clk_disable_unprepare(spi->clk);
 
-       return 0;
+       return pinctrl_pm_select_sleep_state(dev);
 }
 
 static int stm32_spi_runtime_resume(struct device *dev)
 {
        struct spi_master *master = dev_get_drvdata(dev);
        struct stm32_spi *spi = spi_master_get_devdata(master);
+       int ret;
+
+       ret = pinctrl_pm_select_default_state(dev);
+       if (ret)
+               return ret;
 
        return clk_prepare_enable(spi->clk);
 }
@@ -2043,10 +2058,23 @@ static int stm32_spi_resume(struct device *dev)
                return ret;
 
        ret = spi_master_resume(master);
-       if (ret)
+       if (ret) {
                clk_disable_unprepare(spi->clk);
+               return ret;
+       }
 
-       return ret;
+       ret = pm_runtime_get_sync(dev);
+       if (ret < 0) {
+               dev_err(dev, "Unable to power device:%d\n", ret);
+               return ret;
+       }
+
+       spi->cfg->config(spi);
+
+       pm_runtime_mark_last_busy(dev);
+       pm_runtime_put_autosuspend(dev);
+
+       return 0;
 }
 #endif
 
index 6626587..0cab239 100644 (file)
@@ -475,6 +475,12 @@ static LIST_HEAD(spi_controller_list);
  */
 static DEFINE_MUTEX(board_lock);
 
+/*
+ * Prevents addition of devices with same chip select and
+ * addition of devices below an unregistering controller.
+ */
+static DEFINE_MUTEX(spi_add_lock);
+
 /**
  * spi_alloc_device - Allocate a new SPI device
  * @ctlr: Controller to which device is connected
@@ -554,7 +560,6 @@ static int spi_dev_check(struct device *dev, void *data)
  */
 int spi_add_device(struct spi_device *spi)
 {
-       static DEFINE_MUTEX(spi_add_lock);
        struct spi_controller *ctlr = spi->controller;
        struct device *dev = ctlr->dev.parent;
        int status;
@@ -582,6 +587,13 @@ int spi_add_device(struct spi_device *spi)
                goto done;
        }
 
+       /* Controller may unregister concurrently */
+       if (IS_ENABLED(CONFIG_SPI_DYNAMIC) &&
+           !device_is_registered(&ctlr->dev)) {
+               status = -ENODEV;
+               goto done;
+       }
+
        /* Descriptors take precedence */
        if (ctlr->cs_gpiods)
                spi->cs_gpiod = ctlr->cs_gpiods[spi->chip_select];
@@ -1315,8 +1327,6 @@ out:
        if (msg->status && ctlr->handle_err)
                ctlr->handle_err(ctlr, msg);
 
-       spi_res_release(ctlr, msg);
-
        spi_finalize_current_message(ctlr);
 
        return ret;
@@ -1713,6 +1723,13 @@ void spi_finalize_current_message(struct spi_controller *ctlr)
 
        spi_unmap_msg(ctlr, mesg);
 
+       /* In the prepare_messages callback the spi bus has the opportunity to
+        * split a transfer to smaller chunks.
+        * Release splited transfers here since spi_map_msg is done on the
+        * splited transfers.
+        */
+       spi_res_release(ctlr, mesg);
+
        if (ctlr->cur_msg_prepared && ctlr->unprepare_message) {
                ret = ctlr->unprepare_message(ctlr, mesg);
                if (ret) {
@@ -2795,6 +2812,10 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        struct spi_controller *found;
        int id = ctlr->bus_num;
 
+       /* Prevent addition of new devices, unregister existing ones */
+       if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
+               mutex_lock(&spi_add_lock);
+
        device_for_each_child(&ctlr->dev, NULL, __unregister);
 
        /* First make sure that this controller was ever added */
@@ -2815,6 +2836,9 @@ void spi_unregister_controller(struct spi_controller *ctlr)
        if (found == ctlr)
                idr_remove(&spi_master_idr, id);
        mutex_unlock(&board_lock);
+
+       if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
+               mutex_unlock(&spi_add_lock);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_controller);
 
index 823dc99..a8d2525 100644 (file)
@@ -425,7 +425,7 @@ void ssb_chipco_get_clockcontrol(struct ssb_chipcommon *cc,
                        *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_M2);
                        break;
                }
-               /* Fall through */
+               fallthrough;
        default:
                *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_SB);
        }
index 1ca2ac5..354486b 100644 (file)
@@ -342,7 +342,7 @@ void ssb_mipscore_init(struct ssb_mipscore *mcore)
                                set_irq(dev, irq++);
                                break;
                        }
-                       /* fallthrough */
+                       fallthrough;
                case SSB_DEV_EXTIF:
                        set_irq(dev, 0);
                        break;
index b97a5c3..f49ab1a 100644 (file)
@@ -228,7 +228,7 @@ static void __iomem *ssb_ioremap(struct ssb_bus *bus,
        switch (bus->bustype) {
        case SSB_BUSTYPE_SSB:
                /* Only map the first core for now. */
-               /* fallthrough... */
+               fallthrough;
        case SSB_BUSTYPE_PCMCIA:
                mmio = ioremap(baseaddr, SSB_CORE_SIZE);
                break;
index 8b100a7..237531b 100644 (file)
@@ -173,8 +173,7 @@ static int gbaudio_remove_controls(struct snd_card *card, struct device *dev,
                id.index = control->index;
                kctl = snd_ctl_find_id(card, &id);
                if (!kctl) {
-                       dev_err(dev, "%d: Failed to find %s\n", err,
-                               control->name);
+                       dev_err(dev, "Failed to find %s\n", control->name);
                        continue;
                }
                err = snd_ctl_remove(card, kctl);
index 2f9fdbd..83b38ae 100644 (file)
@@ -456,6 +456,15 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
        val = ucontrol->value.integer.value[0] & mask;
        connect = !!val;
 
+       ret = gb_pm_runtime_get_sync(bundle);
+       if (ret)
+               return ret;
+
+       ret = gb_audio_gb_get_control(module->mgmt_connection, data->ctl_id,
+                                     GB_AUDIO_INVALID_INDEX, &gbvalue);
+       if (ret)
+               goto exit;
+
        /* update ucontrol */
        if (gbvalue.value.integer_value[0] != val) {
                for (wi = 0; wi < wlist->num_widgets; wi++) {
@@ -466,25 +475,17 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
                gbvalue.value.integer_value[0] =
                        cpu_to_le32(ucontrol->value.integer.value[0]);
 
-               ret = gb_pm_runtime_get_sync(bundle);
-               if (ret)
-                       return ret;
-
                ret = gb_audio_gb_set_control(module->mgmt_connection,
                                              data->ctl_id,
                                              GB_AUDIO_INVALID_INDEX, &gbvalue);
-
-               gb_pm_runtime_put_autosuspend(bundle);
-
-               if (ret) {
-                       dev_err_ratelimited(codec_dev,
-                                           "%d:Error in %s for %s\n", ret,
-                                           __func__, kcontrol->id.name);
-                       return ret;
-               }
        }
 
-       return 0;
+exit:
+       gb_pm_runtime_put_autosuspend(bundle);
+       if (ret)
+               dev_err_ratelimited(codec_dev, "%d:Error in %s for %s\n", ret,
+                                   __func__, kcontrol->id.name);
+       return ret;
 }
 
 #define SOC_DAPM_MIXER_GB(xname, kcount, data) \
index 8ea65be..a4e4eef 100644 (file)
@@ -4984,7 +4984,7 @@ enum mipi_port_id __get_mipi_port(struct atomisp_device *isp,
                if (MIPI_PORT1_ID + 1 != N_MIPI_PORT_ID) {
                        return MIPI_PORT1_ID + 1;
                }
-       /* fall through */
+               fallthrough;
        default:
                dev_err(isp->dev, "unsupported port: %d\n", port);
                return MIPI_PORT0_ID;
index cccc5bf..1b2b2c6 100644 (file)
@@ -704,14 +704,14 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 
                        return false;
                }
-       /* fall-through */
+               fallthrough;
        case ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE:
                if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
                    pipe_id == IA_CSS_PIPE_ID_PREVIEW)
                        return true;
 
                return false;
-       /* fall-through */
+               fallthrough;
        case ATOMISP_RUN_MODE_VIDEO:
                if (!asd->continuous_mode->val) {
                        if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
@@ -720,7 +720,7 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
                        else
                                return false;
                }
-       /* fall through  */
+               fallthrough;
        case ATOMISP_RUN_MODE_SDV:
                if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
                    pipe_id == IA_CSS_PIPE_ID_VIDEO)
@@ -2765,7 +2765,7 @@ static unsigned int atomisp_get_pipe_index(struct atomisp_sub_device *asd,
                if (!atomisp_is_mbuscode_raw(asd->fmt[asd->capture_pad].fmt.code)) {
                        return IA_CSS_PIPE_ID_CAPTURE;
                }
-               /* fall through */
+               fallthrough;
        case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW:
                if (asd->yuvpp_mode)
                        return IA_CSS_PIPE_ID_YUVPP;
index f8d616f..65b0c8a 100644 (file)
@@ -1467,7 +1467,6 @@ enum ia_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device *asd)
        case ATOMISP_RUN_MODE_VIDEO:
                return IA_CSS_PIPE_ID_VIDEO;
        case ATOMISP_RUN_MODE_STILL_CAPTURE:
-       /* fall through */
        default:
                return IA_CSS_PIPE_ID_CAPTURE;
        }
index a000a1e..0114b04 100644 (file)
@@ -1086,7 +1086,7 @@ static int atomisp_subdev_probe(struct atomisp_device *isp)
                case RAW_CAMERA:
                        dev_dbg(isp->dev, "raw_index: %d\n", raw_index);
                        raw_index = isp->input_cnt;
-                       /* fall through */
+                       fallthrough;
                case SOC_CAMERA:
                        dev_dbg(isp->dev, "SOC_INDEX: %d\n", isp->input_cnt);
                        if (isp->input_cnt >= ATOM_ISP_MAX_INPUTS) {
index 4fb9bfd..f13af23 100644 (file)
@@ -660,7 +660,7 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo,
                                break;
                        }
 
-                       /* fall through */
+                       fallthrough;
 
                /*
                 * if dynamic memory pool doesn't exist, need to free
index 54434c2..a68cbb4 100644 (file)
@@ -4510,7 +4510,7 @@ ia_css_pipe_dequeue_buffer(struct ia_css_pipe *pipe,
 #endif
                                        pipe->stop_requested = false;
                                }
-                               /* fall through */
+                               fallthrough;
                        case IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME:
                        case IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
                                frame = (struct ia_css_frame *)HOST_ADDRESS(ddr_buffer.kernel_ptr);
index 2404184..6386a39 100644 (file)
@@ -110,7 +110,7 @@ hantro_g1_mpeg2_dec_set_buffers(struct hantro_dev *vpu, struct hantro_ctx *ctx,
        case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
                backward_addr = hantro_get_ref(ctx,
                                               slice_params->backward_ref_ts);
-               /* fall-through */
+               fallthrough;
        case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
                forward_addr = hantro_get_ref(ctx,
                                              slice_params->forward_ref_ts);
index 7e9aad6..f610fa5 100644 (file)
@@ -112,7 +112,7 @@ rk3399_vpu_mpeg2_dec_set_buffers(struct hantro_dev *vpu,
        case V4L2_MPEG2_PICTURE_CODING_TYPE_B:
                backward_addr = hantro_get_ref(ctx,
                                               slice_params->backward_ref_ts);
-               /* fall-through */
+               fallthrough;
        case V4L2_MPEG2_PICTURE_CODING_TYPE_P:
                forward_addr = hantro_get_ref(ctx,
                                              slice_params->forward_ref_ts);
index d92fd80..21ebf77 100644 (file)
@@ -488,7 +488,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv)
                        passthrough_cycles = incc->cycles;
                        break;
                }
-               /* fallthrough - non-passthrough RGB565 (CSI-2 bus) */
+               fallthrough;    /* non-passthrough RGB565 (CSI-2 bus) */
        default:
                burst_size = (image.pix.width & 0xf) ? 8 : 16;
                passthrough_bits = 16;
index bc27f94..7c6b91f 100644 (file)
@@ -199,6 +199,7 @@ static int cedrus_request_validate(struct media_request *req)
        struct v4l2_ctrl *ctrl_test;
        unsigned int count;
        unsigned int i;
+       int ret = 0;
 
        list_for_each_entry(obj, &req->objects, list) {
                struct vb2_buffer *vb;
@@ -243,12 +244,16 @@ static int cedrus_request_validate(struct media_request *req)
                if (!ctrl_test) {
                        v4l2_info(&ctx->dev->v4l2_dev,
                                  "Missing required codec control\n");
-                       return -ENOENT;
+                       ret = -ENOENT;
+                       break;
                }
        }
 
        v4l2_ctrl_request_hdl_put(hdl);
 
+       if (ret)
+               return ret;
+
        return vb2_request_validate(req);
 }
 
index 6e4df33..aa3ff67 100644 (file)
@@ -303,13 +303,13 @@ usbvision_i2c_read_max4(struct usb_usbvision *usbvision, unsigned char addr,
        switch (len) {
        case 4:
                buf[3] = usbvision_read_reg(usbvision, USBVISION_SER_DAT4);
-               /* fall through */
+               fallthrough;
        case 3:
                buf[2] = usbvision_read_reg(usbvision, USBVISION_SER_DAT3);
-               /* fall through */
+               fallthrough;
        case 2:
                buf[1] = usbvision_read_reg(usbvision, USBVISION_SER_DAT2);
-               /* fall through */
+               fallthrough;
        case 1:
                buf[0] = usbvision_read_reg(usbvision, USBVISION_SER_DAT1);
                break;
index fa1bf8b..2720f73 100644 (file)
@@ -524,13 +524,8 @@ static void hfa384x_usb_defer(struct work_struct *data)
  */
 void hfa384x_create(struct hfa384x *hw, struct usb_device *usb)
 {
-       memset(hw, 0, sizeof(*hw));
        hw->usb = usb;
 
-       /* set up the endpoints */
-       hw->endp_in = usb_rcvbulkpipe(usb, 1);
-       hw->endp_out = usb_sndbulkpipe(usb, 2);
-
        /* Set up the waitq */
        init_waitqueue_head(&hw->cmdq);
 
index 456603f..4b08dc1 100644 (file)
@@ -61,23 +61,14 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
                               const struct usb_device_id *id)
 {
        struct usb_device *dev;
-       const struct usb_endpoint_descriptor *epd;
-       const struct usb_host_interface *iface_desc = interface->cur_altsetting;
+       struct usb_endpoint_descriptor *bulk_in, *bulk_out;
+       struct usb_host_interface *iface_desc = interface->cur_altsetting;
        struct wlandevice *wlandev = NULL;
        struct hfa384x *hw = NULL;
        int result = 0;
 
-       if (iface_desc->desc.bNumEndpoints != 2) {
-               result = -ENODEV;
-               goto failed;
-       }
-
-       result = -EINVAL;
-       epd = &iface_desc->endpoint[1].desc;
-       if (!usb_endpoint_is_bulk_in(epd))
-               goto failed;
-       epd = &iface_desc->endpoint[2].desc;
-       if (!usb_endpoint_is_bulk_out(epd))
+       result = usb_find_common_endpoints(iface_desc, &bulk_in, &bulk_out, NULL, NULL);
+       if (result)
                goto failed;
 
        dev = interface_to_usbdev(interface);
@@ -96,6 +87,8 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
        }
 
        /* Initialize the hw data */
+       hw->endp_in = usb_rcvbulkpipe(dev, bulk_in->bEndpointAddress);
+       hw->endp_out = usb_sndbulkpipe(dev, bulk_out->bEndpointAddress);
        hfa384x_create(hw, dev);
        hw->wlandev = wlandev;
 
index 30ea37e..bd37f2a 100644 (file)
@@ -444,7 +444,7 @@ cxgbit_uld_lro_rx_handler(void *hndl, const __be64 *rsp,
        case CPL_RX_ISCSI_DDP:
        case CPL_FW4_ACK:
                lro_flush = false;
-               /* fall through */
+               fallthrough;
        case CPL_ABORT_RPL_RSS:
        case CPL_PASS_ESTABLISH:
        case CPL_PEER_CLOSE:
index c968961..7b56fe9 100644 (file)
@@ -1389,14 +1389,27 @@ static u32 iscsit_do_crypto_hash_sg(
        sg = cmd->first_data_sg;
        page_off = cmd->first_data_sg_off;
 
+       if (data_length && page_off) {
+               struct scatterlist first_sg;
+               u32 len = min_t(u32, data_length, sg->length - page_off);
+
+               sg_init_table(&first_sg, 1);
+               sg_set_page(&first_sg, sg_page(sg), len, sg->offset + page_off);
+
+               ahash_request_set_crypt(hash, &first_sg, NULL, len);
+               crypto_ahash_update(hash);
+
+               data_length -= len;
+               sg = sg_next(sg);
+       }
+
        while (data_length) {
-               u32 cur_len = min_t(u32, data_length, (sg->length - page_off));
+               u32 cur_len = min_t(u32, data_length, sg->length);
 
                ahash_request_set_crypt(hash, sg, NULL, cur_len);
                crypto_ahash_update(hash);
 
                data_length -= cur_len;
-               page_off = 0;
                /* iscsit_map_iovec has already checked for invalid sg pointers */
                sg = sg_next(sg);
        }
@@ -3740,7 +3753,7 @@ check_rsp_state:
        case ISTATE_SEND_LOGOUTRSP:
                if (!iscsit_logout_post_handler(cmd, conn))
                        return -ECONNRESET;
-               /* fall through */
+               fallthrough;
        case ISTATE_SEND_STATUS:
        case ISTATE_SEND_ASYNCMSG:
        case ISTATE_SEND_NOPIN:
index 85748e3..893d1b4 100644 (file)
@@ -1149,7 +1149,7 @@ void iscsit_free_conn(struct iscsi_conn *conn)
 }
 
 void iscsi_target_login_sess_out(struct iscsi_conn *conn,
-               struct iscsi_np *np, bool zero_tsih, bool new_sess)
+                                bool zero_tsih, bool new_sess)
 {
        if (!new_sess)
                goto old_sess_out;
@@ -1167,7 +1167,6 @@ void iscsi_target_login_sess_out(struct iscsi_conn *conn,
        conn->sess = NULL;
 
 old_sess_out:
-       iscsi_stop_login_thread_timer(np);
        /*
         * If login negotiation fails check if the Time2Retain timer
         * needs to be restarted.
@@ -1407,8 +1406,9 @@ static int __iscsi_target_login_thread(struct iscsi_np *np)
 new_sess_out:
        new_sess = true;
 old_sess_out:
+       iscsi_stop_login_thread_timer(np);
        tpg_np = conn->tpg_np;
-       iscsi_target_login_sess_out(conn, np, zero_tsih, new_sess);
+       iscsi_target_login_sess_out(conn, zero_tsih, new_sess);
        new_sess = false;
 
        if (tpg) {
index 3b8e363..fc95e61 100644 (file)
@@ -22,8 +22,7 @@ extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
 extern void iscsit_free_conn(struct iscsi_conn *);
 extern int iscsit_start_kthreads(struct iscsi_conn *);
 extern void iscsi_post_login_handler(struct iscsi_np *, struct iscsi_conn *, u8);
-extern void iscsi_target_login_sess_out(struct iscsi_conn *, struct iscsi_np *,
-                               bool, bool);
+extern void iscsi_target_login_sess_out(struct iscsi_conn *, bool, bool);
 extern int iscsi_target_login_thread(void *);
 extern void iscsi_handle_login_thread_timeout(struct timer_list *t);
 
index f88a52f..8b40f10 100644 (file)
@@ -535,12 +535,11 @@ static bool iscsi_target_sk_check_and_clear(struct iscsi_conn *conn, unsigned in
 
 static void iscsi_target_login_drop(struct iscsi_conn *conn, struct iscsi_login *login)
 {
-       struct iscsi_np *np = login->np;
        bool zero_tsih = login->zero_tsih;
 
        iscsi_remove_failed_auth_entry(conn);
        iscsi_target_nego_release(conn);
-       iscsi_target_login_sess_out(conn, np, zero_tsih, true);
+       iscsi_target_login_sess_out(conn, zero_tsih, true);
 }
 
 struct conn_timeout {
index 8fc8865..5f79ea0 100644 (file)
@@ -345,7 +345,7 @@ static int core_scsi3_pr_seq_non_holder(struct se_cmd *cmd, u32 pr_reg_type,
                break;
        case PR_TYPE_WRITE_EXCLUSIVE_REGONLY:
                we = 1;
-               /* fall through */
+               fallthrough;
        case PR_TYPE_EXCLUSIVE_ACCESS_REGONLY:
                /*
                 * Some commands are only allowed for registered I_T Nexuses.
@@ -354,7 +354,7 @@ static int core_scsi3_pr_seq_non_holder(struct se_cmd *cmd, u32 pr_reg_type,
                break;
        case PR_TYPE_WRITE_EXCLUSIVE_ALLREG:
                we = 1;
-               /* fall through */
+               fallthrough;
        case PR_TYPE_EXCLUSIVE_ACCESS_ALLREG:
                /*
                 * Each registered I_T Nexus is a reservation holder.
index f1e8188..6e8b8d3 100644 (file)
@@ -734,7 +734,7 @@ sbc_check_prot(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb,
                }
                if (!protect)
                        return TCM_NO_SENSE;
-               /* Fallthrough */
+               fallthrough;
        default:
                pr_err("Unable to determine pi_prot_type for CDB: 0x%02x "
                       "PROTECT: 0x%02x\n", cdb[0], protect);
index 9fb0be0..590eac2 100644 (file)
@@ -2236,7 +2236,7 @@ static void transport_complete_qf(struct se_cmd *cmd)
                        ret = cmd->se_tfo->queue_data_in(cmd);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case DMA_NONE:
 queue_status:
                trace_target_cmd_complete(cmd);
@@ -2431,7 +2431,7 @@ queue_rsp:
                                goto queue_full;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case DMA_NONE:
 queue_status:
                trace_target_cmd_complete(cmd);
index e9f0dda..a7ed566 100644 (file)
@@ -537,7 +537,7 @@ static void ft_send_work(struct work_struct *work)
        case FCP_PTA_ACA:
                task_attr = TCM_ACA_TAG;
                break;
-       case FCP_PTA_SIMPLE: /* Fallthrough */
+       case FCP_PTA_SIMPLE:
        default:
                task_attr = TCM_SIMPLE_TAG;
        }
index bf7bae4..6dc879f 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2011-2015, 2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2015, 2017, 2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/bitops.h>
@@ -191,7 +191,7 @@ static int qpnp_tm_get_temp(void *data, int *temp)
                chip->temp = mili_celsius;
        }
 
-       *temp = chip->temp < 0 ? 0 : chip->temp;
+       *temp = chip->temp;
 
        return 0;
 }
index e64db5f..4ffa2e2 100644 (file)
@@ -220,7 +220,7 @@ static int calibrate_8916(struct tsens_priv *priv)
                p2[4] = (qfprom_cdata[1] & MSM8916_S4_P2_MASK) >> MSM8916_S4_P2_SHIFT;
                for (i = 0; i < priv->num_sensors; i++)
                        p2[i] = ((base1 + p2[i]) << 3);
-               /* Fall through */
+               fallthrough;
        case ONE_PT_CALIB2:
                base0 = (qfprom_cdata[0] & MSM8916_BASE0_MASK);
                p1[0] = (qfprom_cdata[0] & MSM8916_S0_P1_MASK) >> MSM8916_S0_P1_SHIFT;
@@ -355,7 +355,7 @@ static int calibrate_8974(struct tsens_priv *priv)
                        p2[8] = (calib[5] & S8_P2_BKP_MASK) >> S8_P2_BKP_SHIFT;
                        p2[9] = (calib[5] & S9_P2_BKP_MASK) >> S9_P2_BKP_SHIFT;
                        p2[10] = (calib[5] & S10_P2_BKP_MASK) >> S10_P2_BKP_SHIFT;
-                       /* Fall through */
+                       fallthrough;
                case ONE_PT_CALIB:
                case ONE_PT_CALIB2:
                        base1 = bkp[0] & BASE1_MASK;
@@ -390,7 +390,7 @@ static int calibrate_8974(struct tsens_priv *priv)
                        p2[8] = (calib[4] & S8_P2_MASK) >> S8_P2_SHIFT;
                        p2[9] = (calib[4] & S9_P2_MASK) >> S9_P2_SHIFT;
                        p2[10] = (calib[4] & S10_P2_MASK) >> S10_P2_SHIFT;
-                       /* Fall through */
+                       fallthrough;
                case ONE_PT_CALIB:
                case ONE_PT_CALIB2:
                        base1 = calib[0] & BASE1_MASK;
@@ -420,7 +420,7 @@ static int calibrate_8974(struct tsens_priv *priv)
                        p2[i] <<= 2;
                        p2[i] |= BIT_APPEND;
                }
-               /* Fall through */
+               fallthrough;
        case ONE_PT_CALIB2:
                for (i = 0; i < priv->num_sensors; i++) {
                        p1[i] += base1;
index b682a4d..3c19a38 100644 (file)
@@ -202,7 +202,7 @@ static int calibrate_v1(struct tsens_priv *priv)
                p2[9] = (qfprom_cdata[3] & S9_P2_MASK) >> S9_P2_SHIFT;
                for (i = 0; i < priv->num_sensors; i++)
                        p2[i] = ((base1 + p2[i]) << 2);
-               /* Fall through */
+               fallthrough;
        case ONE_PT_CALIB2:
                base0 = (qfprom_cdata[4] & BASE0_MASK) >> BASE0_SHIFT;
                p1[0] = (qfprom_cdata[0] & S0_P1_MASK) >> S0_P1_SHIFT;
@@ -263,7 +263,7 @@ static int calibrate_8976(struct tsens_priv *priv)
 
                for (i = 0; i < priv->num_sensors; i++)
                        p2[i] = ((base1 + p2[i]) << 2);
-               /* Fall through */
+               fallthrough;
        case ONE_PT_CALIB2:
                base0 = qfprom_cdata[0] & MSM8976_BASE0_MASK;
                p1[0] = (qfprom_cdata[0] & MSM8976_S0_P1_MASK) >> MSM8976_S0_P1_SHIFT;
index 72bf159..a6616e5 100644 (file)
@@ -1516,7 +1516,7 @@ EXPORT_SYMBOL_GPL(thermal_zone_device_register);
  */
 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 {
-       int i;
+       int i, tz_id;
        const struct thermal_zone_params *tzp;
        struct thermal_cooling_device *cdev;
        struct thermal_zone_device *pos = NULL;
@@ -1525,6 +1525,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
                return;
 
        tzp = tz->tzp;
+       tz_id = tz->id;
 
        mutex_lock(&thermal_list_lock);
        list_for_each_entry(pos, &thermal_tz_list, node)
@@ -1567,7 +1568,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
        mutex_destroy(&tz->lock);
        device_unregister(&tz->device);
 
-       thermal_notify_tz_delete(tz->id);
+       thermal_notify_tz_delete(tz_id);
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
 
index 63b02bf..fdb8a49 100644 (file)
@@ -37,20 +37,21 @@ static struct temp_sensor_data omap4430_mpu_temp_sensor_data = {
 
 /*
  * Temperature values in milli degree celsius
- * ADC code values from 530 to 923
+ * ADC code values from 13 to 107, see TRM
+ * "18.4.10.2.3 ADC Codes Versus Temperature".
  */
 static const int
 omap4430_adc_to_temp[OMAP4430_ADC_END_VALUE - OMAP4430_ADC_START_VALUE + 1] = {
-       -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000, -22000,
-       -20000, -18000, -17000, -15000, -13000, -12000, -10000, -8000, -6000,
-       -5000, -3000, -1000, 0, 2000, 3000, 5000, 6000, 8000, 10000, 12000,
-       13000, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28000, 30000,
-       32000, 33000, 35000, 37000, 38000, 40000, 42000, 43000, 45000, 47000,
-       48000, 50000, 52000, 53000, 55000, 57000, 58000, 60000, 62000, 64000,
-       66000, 68000, 70000, 71000, 73000, 75000, 77000, 78000, 80000, 82000,
-       83000, 85000, 87000, 88000, 90000, 92000, 93000, 95000, 97000, 98000,
-       100000, 102000, 103000, 105000, 107000, 109000, 111000, 113000, 115000,
-       117000, 118000, 120000, 122000, 123000,
+       -40000, -38000, -35000, -34000, -32000, -30000, -28000, -26000, -24000,
+       -22000, -20000, -18500, -17000, -15000, -13500, -12000, -10000, -8000,
+       -6500, -5000, -3500, -1500, 0, 2000, 3500, 5000, 6500, 8500, 10000,
+       12000, 13500, 15000, 17000, 19000, 21000, 23000, 25000, 27000, 28500,
+       30000, 32000, 33500, 35000, 37000, 38500, 40000, 42000, 43500, 45000,
+       47000, 48500, 50000, 52000, 53500, 55000, 57000, 58500, 60000, 62000,
+       64000, 66000, 68000, 70000, 71500, 73500, 75000, 77000, 78500, 80000,
+       82000, 83500, 85000, 87000, 88500, 90000, 92000, 93500, 95000, 97000,
+       98500, 100000, 102000, 103500, 105000, 107000, 109000, 111000, 113000,
+       115000, 117000, 118500, 120000, 122000, 123500, 125000,
 };
 
 /* OMAP4430 data */
index a453ff8..9a3955c 100644 (file)
  * and thresholds for OMAP4430.
  */
 
-/* ADC conversion table limits */
-#define OMAP4430_ADC_START_VALUE                       0
-#define OMAP4430_ADC_END_VALUE                         127
+/*
+ * ADC conversion table limits. Ignore values outside the TRM listed
+ * range to avoid bogus thermal shutdowns. See omap4430 TRM chapter
+ * "18.4.10.2.3 ADC Codes Versus Temperature".
+ */
+#define OMAP4430_ADC_START_VALUE                       13
+#define OMAP4430_ADC_END_VALUE                         107
 /* bandgap clock limits (no control on 4430) */
 #define OMAP4430_MAX_FREQ                              32768
 #define OMAP4430_MIN_FREQ                              32768
index f77ceae..394a23c 100644 (file)
@@ -453,7 +453,7 @@ static void tb_ctl_rx_callback(struct tb_ring *ring, struct ring_frame *frame,
                                   "RX: checksum mismatch, dropping packet\n");
                        goto rx;
                }
-               /* Fall through */
+               fallthrough;
        case TB_CFG_PKG_ICM_EVENT:
                if (tb_ctl_handle_event(pkg->ctl, frame->eof, pkg, frame->size))
                        goto rx;
index 712395f..a921de9 100644 (file)
@@ -684,6 +684,7 @@ static int tb_init_port(struct tb_port *port)
                if (res == -ENODEV) {
                        tb_dbg(port->sw->tb, " Port %d: not implemented\n",
                               port->port);
+                       port->disabled = true;
                        return 0;
                }
                return res;
@@ -2092,7 +2093,7 @@ static int tb_switch_add_dma_port(struct tb_switch *sw)
                if (tb_route(sw))
                        return 0;
 
-               /* fallthrough */
+               fallthrough;
        case 3:
                ret = tb_switch_set_uuid(sw);
                if (ret)
index a413d55..3c620a9 100644 (file)
@@ -186,7 +186,7 @@ struct tb_switch {
  * @cap_adap: Offset of the adapter specific capability (%0 if not present)
  * @cap_usb4: Offset to the USB4 port capability (%0 if not present)
  * @port: Port number on switch
- * @disabled: Disabled by eeprom
+ * @disabled: Disabled by eeprom or enabled but not implemented
  * @bonded: true if the port is bonded (two lanes combined as one)
  * @dual_link_port: If the switch is connected using two ports, points
  *                 to the other port.
index 2aae2c7..829b6cc 100644 (file)
@@ -315,7 +315,7 @@ static inline u32 tb_dp_cap_set_rate(u32 val, u32 rate)
        switch (rate) {
        default:
                WARN(1, "invalid rate %u passed, defaulting to 1620 MB/s\n", rate);
-               /* Fallthrough */
+               fallthrough;
        case 1620:
                val |= DP_COMMON_CAP_RATE_RBR << DP_COMMON_CAP_RATE_SHIFT;
                break;
@@ -355,7 +355,7 @@ static inline u32 tb_dp_cap_set_lanes(u32 val, u32 lanes)
        default:
                WARN(1, "invalid number of lanes %u passed, defaulting to 1\n",
                     lanes);
-               /* Fallthrough */
+               fallthrough;
        case 1:
                val |= DP_COMMON_CAP_1_LANE << DP_COMMON_CAP_LANES_SHIFT;
                break;
@@ -951,10 +951,18 @@ static void tb_usb3_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
        int ret, max_rate, allocate_up, allocate_down;
 
        ret = usb4_usb3_port_actual_link_rate(tunnel->src_port);
-       if (ret <= 0) {
-               tb_tunnel_warn(tunnel, "tunnel is not up\n");
+       if (ret < 0) {
+               tb_tunnel_warn(tunnel, "failed to read actual link rate\n");
                return;
+       } else if (!ret) {
+               /* Use maximum link rate if the link valid is not set */
+               ret = usb4_usb3_port_max_link_rate(tunnel->src_port);
+               if (ret < 0) {
+                       tb_tunnel_warn(tunnel, "failed to read maximum link rate\n");
+                       return;
+               }
        }
+
        /*
         * 90% of the max rate can be allocated for isochronous
         * transfers.
index 2a0e51a..92c9a47 100644 (file)
@@ -492,7 +492,7 @@ static void xencons_backend_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* fall through - Missed the backend's CLOSING state. */
+               fallthrough;    /* Missed the backend's CLOSING state */
        case XenbusStateClosing:
                xenbus_frontend_closed(dev);
                break;
index 21e76a2..a8e19b4 100644 (file)
@@ -243,7 +243,7 @@ done:
                /* Fall back to a 3 byte encoding */
                word.bytes = 3;
                word.word &= 0x00ffffff;
-               /* Fall through */
+               fallthrough;
        case 3:
                /* 3 byte encoding */
                word.word |= 0x82000000;
index 0a29a94..35cf121 100644 (file)
@@ -1584,7 +1584,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
                        gsm_process_modem(tty, dlci, modem, clen);
                        tty_kref_put(tty);
                }
-               /* Fall through */
+               fallthrough;
        case 1:         /* Line state will go via DLCI 0 controls only */
        default:
                tty_insert_flip_string(port, data, len);
@@ -1986,7 +1986,7 @@ static void gsm1_receive(struct gsm_mux *gsm, unsigned char c)
                gsm->address = 0;
                gsm->state = GSM_ADDRESS;
                gsm->fcs = INIT_FCS;
-               /* Fall through */
+               fallthrough;
        case GSM_ADDRESS:       /* Address continuation */
                gsm->fcs = gsm_fcs_add(gsm->fcs, c);
                if (gsm_read_ea(&gsm->address, c))
index b09eac4..8e975cb 100644 (file)
@@ -602,7 +602,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
                case TCOFLUSH:
                        flush_tx_queue(tty);
                }
-               /* fall through - to default */
+               fallthrough;    /* to default */
 
        default:
                error = n_tty_ioctl_helper(tty, file, cmd, arg);
index f75696f..934dd2f 100644 (file)
@@ -605,7 +605,6 @@ static void receive_char(struct r3964_info *pInfo, const unsigned char c)
                }
                break;
        case R3964_WAIT_FOR_RX_REPEAT:
-               /* FALLTHROUGH */
        case R3964_IDLE:
                if (c == STX) {
                        /* Prevent rx_queue from overflow: */
index db88dee..f8e9999 100644 (file)
@@ -39,7 +39,7 @@ static void serial8250_em_serial_out(struct uart_port *p, int offset, int value)
                break;
        case UART_IER: /* IER @ 0x04 */
                value &= 0x0f; /* only 4 valid bits - not Xscale */
-               /* fall-through */
+               fallthrough;
        case UART_DLL_EM: /* DLL @ 0x24 (+9) */
        case UART_DLM_EM: /* DLM @ 0x28 (+9) */
                writel(value, p->membase + (offset << 2));
index 04b9af7..2d0e7c7 100644 (file)
@@ -744,6 +744,24 @@ static const struct exar8250_board pbn_exar_XR17V35x = {
        .exit           = pci_xr17v35x_exit,
 };
 
+static const struct exar8250_board pbn_fastcom35x_2 = {
+       .num_ports      = 2,
+       .setup          = pci_xr17v35x_setup,
+       .exit           = pci_xr17v35x_exit,
+};
+
+static const struct exar8250_board pbn_fastcom35x_4 = {
+       .num_ports      = 4,
+       .setup          = pci_xr17v35x_setup,
+       .exit           = pci_xr17v35x_exit,
+};
+
+static const struct exar8250_board pbn_fastcom35x_8 = {
+       .num_ports      = 8,
+       .setup          = pci_xr17v35x_setup,
+       .exit           = pci_xr17v35x_exit,
+};
+
 static const struct exar8250_board pbn_exar_XR17V4358 = {
        .num_ports      = 12,
        .setup          = pci_xr17v35x_setup,
@@ -811,9 +829,9 @@ static const struct pci_device_id exar_pci_tbl[] = {
        EXAR_DEVICE(EXAR, XR17V358, pbn_exar_XR17V35x),
        EXAR_DEVICE(EXAR, XR17V4358, pbn_exar_XR17V4358),
        EXAR_DEVICE(EXAR, XR17V8358, pbn_exar_XR17V8358),
-       EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_exar_XR17V35x),
-       EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_exar_XR17V35x),
-       EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_exar_XR17V35x),
+       EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_fastcom35x_2),
+       EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_fastcom35x_4),
+       EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_fastcom35x_8),
 
        EXAR_DEVICE(COMMTECH, 4222PCI335, pbn_fastcom335_2),
        EXAR_DEVICE(COMMTECH, 4224PCI335, pbn_fastcom335_4),
index d1d253c..31c9e83 100644 (file)
@@ -255,7 +255,7 @@ static void fintek_8250_set_irq_mode(struct fintek_8250 *pdata, bool is_level)
        case CHIP_ID_F81866:
                sio_write_mask_reg(pdata, F81866_FIFO_CTRL, F81866_IRQ_MODE1,
                                   0);
-               /* fall through */
+               fallthrough;
        case CHIP_ID_F81865:
                sio_write_mask_reg(pdata, F81866_IRQ_MODE, F81866_IRQ_SHARE,
                                   F81866_IRQ_SHARE);
index 1a74d51..3eb2d48 100644 (file)
@@ -631,7 +631,7 @@ pci_timedia_setup(struct serial_private *priv,
                break;
        case 3:
                offset = board->uart_offset;
-               /* FALLTHROUGH */
+               fallthrough;
        case 4: /* BAR 2 */
        case 5: /* BAR 3 */
        case 6: /* BAR 4 */
index 0947569..c71d647 100644 (file)
@@ -1872,7 +1872,7 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir)
        switch (iir & 0x3f) {
        case UART_IIR_RX_TIMEOUT:
                serial8250_rx_dma_flush(up);
-               /* fall-through */
+               fallthrough;
        case UART_IIR_RLSI:
                return true;
        }
@@ -2275,6 +2275,10 @@ int serial8250_do_startup(struct uart_port *port)
 
        if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
                unsigned char iir1;
+
+               if (port->irqflags & IRQF_SHARED)
+                       disable_irq_nosync(port->irq);
+
                /*
                 * Test for UARTs that do not reassert THRE when the
                 * transmitter is idle and the interrupt has already
@@ -2284,8 +2288,6 @@ int serial8250_do_startup(struct uart_port *port)
                 * allow register changes to become visible.
                 */
                spin_lock_irqsave(&port->lock, flags);
-               if (up->port.irqflags & IRQF_SHARED)
-                       disable_irq_nosync(port->irq);
 
                wait_for_xmitr(up, UART_LSR_THRE);
                serial_port_out_sync(port, UART_IER, UART_IER_THRI);
@@ -2297,9 +2299,10 @@ int serial8250_do_startup(struct uart_port *port)
                iir = serial_port_in(port, UART_IIR);
                serial_port_out(port, UART_IER, 0);
 
+               spin_unlock_irqrestore(&port->lock, flags);
+
                if (port->irqflags & IRQF_SHARED)
                        enable_irq(port->irq);
-               spin_unlock_irqrestore(&port->lock, flags);
 
                /*
                 * If the interrupt is not reasserted, or we otherwise
index e0b73a5..a2978ab 100644 (file)
@@ -75,7 +75,7 @@ static unsigned int uniphier_serial_in(struct uart_port *p, int offset)
                break;
        case UART_LCR:
                valshift = 8;
-               /* fall through */
+               fallthrough;
        case UART_MCR:
                offset = UNIPHIER_UART_LCR_MCR;
                break;
@@ -101,7 +101,7 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value)
        case UART_SCR:
                /* No SCR for this hardware.  Use CHAR as a scratch register */
                valshift = 8;
-               /* fall through */
+               fallthrough;
        case UART_FCR:
                offset = UNIPHIER_UART_CHAR_FCR;
                break;
@@ -109,7 +109,7 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value)
                valshift = 8;
                /* Divisor latch access bit does not exist. */
                value &= ~UART_LCR_DLAB;
-               /* fall through */
+               fallthrough;
        case UART_MCR:
                offset = UNIPHIER_UART_LCR_MCR;
                break;
index 8a0352e..9409be9 100644 (file)
@@ -517,6 +517,7 @@ config SERIAL_IMX_CONSOLE
 
 config SERIAL_IMX_EARLYCON
        bool "Earlycon on IMX serial port"
+       depends on ARCH_MXC || COMPILE_TEST
        depends on OF
        select SERIAL_EARLYCON
        help
index d056ee6..caf167f 100644 (file)
@@ -43,6 +43,7 @@ obj-$(CONFIG_SERIAL_ZS) += zs.o
 obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
 obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
 obj-$(CONFIG_SERIAL_IMX) += imx.o
+obj-$(CONFIG_SERIAL_IMX_EARLYCON) += imx_earlycon.o
 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
 obj-$(CONFIG_SERIAL_ICOM) += icom.o
 obj-$(CONFIG_SERIAL_MESON) += meson_uart.o
index c010f63..6749859 100644 (file)
@@ -2241,9 +2241,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
        clk_disable(uap->clk);
 }
 
-static void __init
-pl011_console_get_options(struct uart_amba_port *uap, int *baud,
-                            int *parity, int *bits)
+static void pl011_console_get_options(struct uart_amba_port *uap, int *baud,
+                                     int *parity, int *bits)
 {
        if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) {
                unsigned int lcr_h, ibrd, fbrd;
@@ -2276,7 +2275,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
        }
 }
 
-static int __init pl011_console_setup(struct console *co, char *options)
+static int pl011_console_setup(struct console *co, char *options)
 {
        struct uart_amba_port *uap;
        int baud = 38400;
@@ -2344,8 +2343,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
  *
  *     Returns 0 if console matches; otherwise non-zero to use default matching
  */
-static int __init pl011_console_match(struct console *co, char *name, int idx,
-                                     char *options)
+static int pl011_console_match(struct console *co, char *name, int idx,
+                              char *options)
 {
        unsigned char iotype;
        resource_size_t addr;
@@ -2615,7 +2614,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
 
 static int pl011_register_port(struct uart_amba_port *uap)
 {
-       int ret;
+       int ret, i;
 
        /* Ensure interrupts from this UART are masked and cleared */
        pl011_write(0, uap, REG_IMSC);
@@ -2626,6 +2625,9 @@ static int pl011_register_port(struct uart_amba_port *uap)
                if (ret < 0) {
                        dev_err(uap->port.dev,
                                "Failed to register AMBA-PL011 driver\n");
+                       for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
+                               if (amba_ports[i] == uap)
+                                       amba_ports[i] = NULL;
                        return ret;
                }
        }
index e43471b..bb5fc8b 100644 (file)
@@ -1845,7 +1845,7 @@ static void atmel_get_ip_name(struct uart_port *port)
                version = atmel_uart_readl(port, ATMEL_US_VERSION);
                switch (version) {
                case 0x814:     /* sama5d2 */
-                       /* fall through */
+                       fallthrough;
                case 0x701:     /* sama5d4 */
                        atmel_port->fidi_min = 3;
                        atmel_port->fidi_max = 65535;
index 8573fc9..76b94d0 100644 (file)
@@ -587,7 +587,6 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
                        transmit_chars(up, lsr);
                        break;
                case UART_IIR_RX_TIMEOUT:
-                       /* FALLTHROUGH */
                case UART_IIR_RDI:
                        serial_omap_rdi(up, lsr);
                        break;
@@ -598,7 +597,6 @@ static irqreturn_t serial_omap_irq(int irq, void *dev_id)
                        /* simply try again */
                        break;
                case UART_IIR_XOFF:
-                       /* FALLTHROUGH */
                default:
                        break;
                }
index 3aa29d2..184b458 100644 (file)
@@ -361,11 +361,16 @@ static int qcom_geni_serial_get_char(struct uart_port *uport)
                        return NO_POLL_CHAR;
 
                if (word_cnt == 1 && (status & RX_LAST))
+                       /*
+                        * NOTE: If RX_LAST_BYTE_VALID is 0 it needs to be
+                        * treated as if it was BYTES_PER_FIFO_WORD.
+                        */
                        private_data->poll_cached_bytes_cnt =
                                (status & RX_LAST_BYTE_VALID_MSK) >>
                                RX_LAST_BYTE_VALID_SHFT;
-               else
-                       private_data->poll_cached_bytes_cnt = 4;
+
+               if (private_data->poll_cached_bytes_cnt == 0)
+                       private_data->poll_cached_bytes_cnt = BYTES_PER_FIFO_WORD;
 
                private_data->poll_cached_bytes =
                        readl(uport->membase + SE_GENI_RX_FIFOn);
@@ -1098,7 +1103,7 @@ static unsigned int qcom_geni_serial_tx_empty(struct uart_port *uport)
 }
 
 #ifdef CONFIG_SERIAL_QCOM_GENI_CONSOLE
-static int __init qcom_geni_console_setup(struct console *co, char *options)
+static int qcom_geni_console_setup(struct console *co, char *options)
 {
        struct uart_port *uport;
        struct qcom_geni_serial_port *port;
index b5ef86a..85366e0 100644 (file)
@@ -259,7 +259,7 @@ static void rda_uart_set_termios(struct uart_port *port,
        case CS5:
        case CS6:
                dev_warn(port->dev, "bit size not supported, using 7 bits\n");
-               /* Fall through */
+               fallthrough;
        case CS7:
                ctrl &= ~RDA_UART_DBITS_8;
                break;
index 8ed3482..8ae3e03 100644 (file)
@@ -1905,9 +1905,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
                ourport->tx_irq = ret + 1;
        }
 
-       ret = platform_get_irq(platdev, 1);
-       if (ret > 0)
-               ourport->tx_irq = ret;
+       if (!s3c24xx_serial_has_interrupt_mask(port)) {
+               ret = platform_get_irq(platdev, 1);
+               if (ret > 0)
+                       ourport->tx_irq = ret;
+       }
        /*
         * DMA is currently supported only on DT platforms, if DMA properties
         * are specified.
index b87914a..bd13014 100644 (file)
@@ -876,7 +876,7 @@ static irqreturn_t tegra_uart_isr(int irq, void *data)
                                tegra_uart_write(tup, ier, UART_IER);
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                case 2: /* Receive */
                        if (!tup->use_rx_pio) {
                                is_rx_start = tup->rx_in_progress;
index 3403dd7..f797c97 100644 (file)
@@ -2101,7 +2101,7 @@ uart_set_options(struct uart_port *port, struct console *co,
        switch (parity) {
        case 'o': case 'O':
                termios.c_cflag |= PARODD;
-               /*fall through*/
+               fallthrough;
        case 'e': case 'E':
                termios.c_cflag |= PARENB;
                break;
index 143300a..ba503dd 100644 (file)
@@ -970,7 +970,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
                return ret;
 
        if (stm32port->info->cfg.has_wakeup) {
-               stm32port->wakeirq = platform_get_irq(pdev, 1);
+               stm32port->wakeirq = platform_get_irq_optional(pdev, 1);
                if (stm32port->wakeirq <= 0 && stm32port->wakeirq != -ENXIO)
                        return stm32port->wakeirq ? : -ENODEV;
        }
index 8ce9a7a..319e5ce 100644 (file)
@@ -514,7 +514,7 @@ static void receive_kbd_ms_chars(struct uart_sunsu_port *up, int is_break)
                        switch (ret) {
                        case 2:
                                sunsu_change_mouse_baud(up);
-                               /* fallthru */
+                               fallthrough;
                        case 1:
                                break;
 
index 7ea06bb..001e19d 100644 (file)
@@ -306,7 +306,7 @@ static void sunzilog_kbdms_receive_chars(struct uart_sunzilog_port *up,
                switch (ret) {
                case 2:
                        sunzilog_change_mouse_baud(up);
-                       /* fallthru */
+                       fallthrough;
                case 1:
                        break;
 
index 2833f14..a9b1ee2 100644 (file)
@@ -544,7 +544,7 @@ static int cdns_uart_clk_notifier_cb(struct notifier_block *nb,
 
                cdns_uart->baud = cdns_uart_set_baud_rate(cdns_uart->port,
                                cdns_uart->baud);
-               /* fall through */
+               fallthrough;
        case ABORT_RATE_CHANGE:
                if (!locked)
                        spin_lock_irqsave(&cdns_uart->port->lock, flags);
index 9245fff..e18f318 100644 (file)
@@ -866,7 +866,7 @@ static int __tty_perform_flush(struct tty_struct *tty, unsigned long arg)
                        ld->ops->flush_buffer(tty);
                        tty_unthrottle(tty);
                }
-               /* fall through */
+               fallthrough;
        case TCOFLUSH:
                tty_driver_flush_buffer(tty);
                break;
index ccb533f..19cd4a4 100644 (file)
@@ -1201,7 +1201,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
        unsigned int old_rows, old_row_size, first_copied_row;
        unsigned int new_cols, new_rows, new_row_size, new_screen_size;
        unsigned int user;
-       unsigned short *newscreen;
+       unsigned short *oldscreen, *newscreen;
        struct uni_screen *new_uniscr = NULL;
 
        WARN_CONSOLE_UNLOCKED();
@@ -1299,10 +1299,11 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
        if (new_scr_end > new_origin)
                scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
                            new_scr_end - new_origin);
-       kfree(vc->vc_screenbuf);
+       oldscreen = vc->vc_screenbuf;
        vc->vc_screenbuf = newscreen;
        vc->vc_screenbuf_size = new_screen_size;
        set_origin(vc);
+       kfree(oldscreen);
 
        /* do part of a reset_terminal() */
        vc->vc_top = 0;
@@ -1553,7 +1554,7 @@ static void csi_J(struct vc_data *vc, int vpar)
                        break;
                case 3: /* include scrollback */
                        flush_scrollback(vc);
-                       /* fallthrough */
+                       fallthrough;
                case 2: /* erase whole display */
                        vc_uniscr_clear_lines(vc, 0, vc->vc_rows);
                        count = vc->vc_cols * vc->vc_rows;
@@ -2167,7 +2168,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
                lf(vc);
                if (!is_kbd(vc, lnm))
                        return;
-               /* fall through */
+               fallthrough;
        case 13:
                cr(vc);
                return;
@@ -2306,7 +2307,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c)
                        return;
                }
                vc->vc_priv = EPecma;
-               /* fall through */
+               fallthrough;
        case ESgetpars:
                if (c == ';' && vc->vc_npar < NPAR - 1) {
                        vc->vc_npar++;
index 91c3017..a4e520b 100644 (file)
@@ -806,12 +806,22 @@ static int vt_resizex(struct vc_data *vc, struct vt_consize __user *cs)
                console_lock();
                vcp = vc_cons[i].d;
                if (vcp) {
+                       int ret;
+                       int save_scan_lines = vcp->vc_scan_lines;
+                       int save_font_height = vcp->vc_font.height;
+
                        if (v.v_vlin)
                                vcp->vc_scan_lines = v.v_vlin;
                        if (v.v_clin)
                                vcp->vc_font.height = v.v_clin;
                        vcp->vc_resize_user = 1;
-                       vc_resize(vcp, v.v_cols, v.v_rows);
+                       ret = vc_resize(vcp, v.v_cols, v.v_rows);
+                       if (ret) {
+                               vcp->vc_scan_lines = save_scan_lines;
+                               vcp->vc_font.height = save_font_height;
+                               console_unlock();
+                               return ret;
+                       }
                }
                console_unlock();
        }
index 73efb80..6dca744 100644 (file)
@@ -1048,8 +1048,6 @@ void uio_unregister_device(struct uio_info *info)
 
        idev = info->uio_dev;
 
-       uio_free_minor(idev);
-
        mutex_lock(&idev->info_lock);
        uio_dev_del_attributes(idev);
 
@@ -1064,6 +1062,8 @@ void uio_unregister_device(struct uio_info *info)
 
        device_unregister(&idev->dev);
 
+       uio_free_minor(idev);
+
        return;
 }
 EXPORT_SYMBOL_GPL(uio_unregister_device);
index f7f6229..60f4711 100644 (file)
@@ -710,7 +710,8 @@ static int c67x00_add_ctrl_urb(struct c67x00_hcd *c67x00, struct urb *urb)
                        if (ret)
                                return ret;
                        break;
-               }               /* else fallthrough */
+               }
+               fallthrough;
        case STATUS_STAGE:
                pid = !usb_pipeout(urb->pipe) ? USB_PID_OUT : USB_PID_IN;
                ret = c67x00_create_td(c67x00, urb, NULL, 0, pid, 1,
index 9917868..7f6f3ab 100644 (file)
@@ -378,21 +378,19 @@ static void acm_ctrl_irq(struct urb *urb)
        if (current_size < expected_size) {
                /* notification is transmitted fragmented, reassemble */
                if (acm->nb_size < expected_size) {
-                       if (acm->nb_size) {
-                               kfree(acm->notification_buffer);
-                               acm->nb_size = 0;
-                       }
+                       u8 *new_buffer;
                        alloc_size = roundup_pow_of_two(expected_size);
-                       /*
-                        * kmalloc ensures a valid notification_buffer after a
-                        * use of kfree in case the previous allocation was too
-                        * small. Final freeing is done on disconnect.
-                        */
-                       acm->notification_buffer =
-                               kmalloc(alloc_size, GFP_ATOMIC);
-                       if (!acm->notification_buffer)
+                       /* Final freeing is done on disconnect. */
+                       new_buffer = krealloc(acm->notification_buffer,
+                                             alloc_size, GFP_ATOMIC);
+                       if (!new_buffer) {
+                               acm->nb_index = 0;
                                goto exit;
+                       }
+
+                       acm->notification_buffer = new_buffer;
                        acm->nb_size = alloc_size;
+                       dr = (struct usb_cdc_notification *)acm->notification_buffer;
                }
 
                copy_size = min(current_size,
index f81606c..7e73e98 100644 (file)
@@ -905,6 +905,35 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env)
        return 0;
 }
 
+static bool is_dev_usb_generic_driver(struct device *dev)
+{
+       struct usb_device_driver *udd = dev->driver ?
+               to_usb_device_driver(dev->driver) : NULL;
+
+       return udd == &usb_generic_driver;
+}
+
+static int __usb_bus_reprobe_drivers(struct device *dev, void *data)
+{
+       struct usb_device_driver *new_udriver = data;
+       struct usb_device *udev;
+       int ret;
+
+       if (!is_dev_usb_generic_driver(dev))
+               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))
+               return 0;
+
+       ret = device_reprobe(dev);
+       if (ret && ret != -EPROBE_DEFER)
+               dev_err(dev, "Failed to reprobe device (error %d)\n", ret);
+
+       return 0;
+}
+
 /**
  * usb_register_device_driver - register a USB device (not interface) driver
  * @new_udriver: USB operations for the device driver
@@ -934,13 +963,20 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver,
 
        retval = driver_register(&new_udriver->drvwrap.driver);
 
-       if (!retval)
+       if (!retval) {
                pr_info("%s: registered new device driver %s\n",
                        usbcore_name, new_udriver->name);
-       else
+               /*
+                * Check whether any device could be better served with
+                * this new driver
+                */
+               bus_for_each_dev(&usb_bus_type, NULL, new_udriver,
+                                __usb_bus_reprobe_drivers);
+       } else {
                printk(KERN_ERR "%s: error %d registering device "
                        "       driver %s\n",
                        usbcore_name, retval, new_udriver->name);
+       }
 
        return retval;
 }
index b6f2d4b..2b2f1ab 100644 (file)
@@ -205,8 +205,9 @@ static int __check_usb_generic(struct device_driver *drv, void *data)
        udrv = to_usb_device_driver(drv);
        if (udrv == &usb_generic_driver)
                return 0;
-
-       return usb_device_match_id(udev, udrv->id_table) != NULL;
+       if (usb_device_match_id(udev, udrv->id_table) != NULL)
+               return 1;
+       return (udrv->match && udrv->match(udev));
 }
 
 static bool usb_generic_driver_match(struct usb_device *udev)
index 4dc443a..ec0d6c5 100644 (file)
@@ -315,11 +315,14 @@ EXPORT_SYMBOL_GPL(usb_hcd_pci_probe);
 void usb_hcd_pci_remove(struct pci_dev *dev)
 {
        struct usb_hcd          *hcd;
+       int                     hcd_driver_flags;
 
        hcd = pci_get_drvdata(dev);
        if (!hcd)
                return;
 
+       hcd_driver_flags = hcd->driver->flags;
+
        if (pci_dev_run_wake(dev))
                pm_runtime_get_noresume(&dev->dev);
 
@@ -347,7 +350,7 @@ void usb_hcd_pci_remove(struct pci_dev *dev)
                up_read(&companions_rwsem);
        }
        usb_put_hcd(hcd);
-       if ((hcd->driver->flags & HCD_MASK) < HCD_USB3)
+       if ((hcd_driver_flags & HCD_MASK) < HCD_USB3)
                pci_free_irq_vectors(dev);
        pci_disable_device(dev);
 }
index 052d5ac..5b768b8 100644 (file)
@@ -727,7 +727,7 @@ static void hub_irq(struct urb *urb)
                if ((++hub->nerrors < 10) || hub->error)
                        goto resubmit;
                hub->error = status;
-               /* FALL THROUGH */
+               fallthrough;
 
        /* let hub_wq handle things */
        case 0:                 /* we got data:  port status changed */
index 6197938..ae1de9c 100644 (file)
@@ -1205,6 +1205,34 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
        }
 }
 
+/*
+ * usb_disable_device_endpoints -- Disable all endpoints for a device
+ * @dev: the device whose endpoints are being disabled
+ * @skip_ep0: 0 to disable endpoint 0, 1 to skip it.
+ */
+static void usb_disable_device_endpoints(struct usb_device *dev, int skip_ep0)
+{
+       struct usb_hcd *hcd = bus_to_hcd(dev->bus);
+       int i;
+
+       if (hcd->driver->check_bandwidth) {
+               /* First pass: Cancel URBs, leave endpoint pointers intact. */
+               for (i = skip_ep0; i < 16; ++i) {
+                       usb_disable_endpoint(dev, i, false);
+                       usb_disable_endpoint(dev, i + USB_DIR_IN, false);
+               }
+               /* Remove endpoints from the host controller internal state */
+               mutex_lock(hcd->bandwidth_mutex);
+               usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
+               mutex_unlock(hcd->bandwidth_mutex);
+       }
+       /* Second pass: remove endpoint pointers */
+       for (i = skip_ep0; i < 16; ++i) {
+               usb_disable_endpoint(dev, i, true);
+               usb_disable_endpoint(dev, i + USB_DIR_IN, true);
+       }
+}
+
 /**
  * usb_disable_device - Disable all the endpoints for a USB device
  * @dev: the device whose endpoints are being disabled
@@ -1218,7 +1246,6 @@ void usb_disable_interface(struct usb_device *dev, struct usb_interface *intf,
 void usb_disable_device(struct usb_device *dev, int skip_ep0)
 {
        int i;
-       struct usb_hcd *hcd = bus_to_hcd(dev->bus);
 
        /* getting rid of interfaces will disconnect
         * any drivers bound to them (a key side effect)
@@ -1264,22 +1291,8 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
 
        dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
                skip_ep0 ? "non-ep0" : "all");
-       if (hcd->driver->check_bandwidth) {
-               /* First pass: Cancel URBs, leave endpoint pointers intact. */
-               for (i = skip_ep0; i < 16; ++i) {
-                       usb_disable_endpoint(dev, i, false);
-                       usb_disable_endpoint(dev, i + USB_DIR_IN, false);
-               }
-               /* Remove endpoints from the host controller internal state */
-               mutex_lock(hcd->bandwidth_mutex);
-               usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
-               mutex_unlock(hcd->bandwidth_mutex);
-               /* Second pass: remove endpoint pointers */
-       }
-       for (i = skip_ep0; i < 16; ++i) {
-               usb_disable_endpoint(dev, i, true);
-               usb_disable_endpoint(dev, i + USB_DIR_IN, true);
-       }
+
+       usb_disable_device_endpoints(dev, skip_ep0);
 }
 
 /**
@@ -1522,6 +1535,9 @@ EXPORT_SYMBOL_GPL(usb_set_interface);
  * The caller must own the device lock.
  *
  * Return: Zero on success, else a negative error code.
+ *
+ * If this routine fails the device will probably be in an unusable state
+ * with endpoints disabled, and interfaces only partially enabled.
  */
 int usb_reset_configuration(struct usb_device *dev)
 {
@@ -1537,10 +1553,7 @@ int usb_reset_configuration(struct usb_device *dev)
         * calls during probe() are fine
         */
 
-       for (i = 1; i < 16; ++i) {
-               usb_disable_endpoint(dev, i, true);
-               usb_disable_endpoint(dev, i + USB_DIR_IN, true);
-       }
+       usb_disable_device_endpoints(dev, 1); /* skip ep0*/
 
        config = dev->actconfig;
        retval = 0;
@@ -1553,34 +1566,10 @@ int usb_reset_configuration(struct usb_device *dev)
                mutex_unlock(hcd->bandwidth_mutex);
                return -ENOMEM;
        }
-       /* Make sure we have enough bandwidth for each alternate setting 0 */
-       for (i = 0; i < config->desc.bNumInterfaces; i++) {
-               struct usb_interface *intf = config->interface[i];
-               struct usb_host_interface *alt;
 
-               alt = usb_altnum_to_altsetting(intf, 0);
-               if (!alt)
-                       alt = &intf->altsetting[0];
-               if (alt != intf->cur_altsetting)
-                       retval = usb_hcd_alloc_bandwidth(dev, NULL,
-                                       intf->cur_altsetting, alt);
-               if (retval < 0)
-                       break;
-       }
-       /* If not, reinstate the old alternate settings */
+       /* xHCI adds all endpoints in usb_hcd_alloc_bandwidth */
+       retval = usb_hcd_alloc_bandwidth(dev, config, NULL, NULL);
        if (retval < 0) {
-reset_old_alts:
-               for (i--; i >= 0; i--) {
-                       struct usb_interface *intf = config->interface[i];
-                       struct usb_host_interface *alt;
-
-                       alt = usb_altnum_to_altsetting(intf, 0);
-                       if (!alt)
-                               alt = &intf->altsetting[0];
-                       if (alt != intf->cur_altsetting)
-                               usb_hcd_alloc_bandwidth(dev, NULL,
-                                               alt, intf->cur_altsetting);
-               }
                usb_enable_lpm(dev);
                mutex_unlock(hcd->bandwidth_mutex);
                return retval;
@@ -1589,8 +1578,12 @@ reset_old_alts:
                        USB_REQ_SET_CONFIGURATION, 0,
                        config->desc.bConfigurationValue, 0,
                        NULL, 0, USB_CTRL_SET_TIMEOUT);
-       if (retval < 0)
-               goto reset_old_alts;
+       if (retval < 0) {
+               usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL);
+               usb_enable_lpm(dev);
+               mutex_unlock(hcd->bandwidth_mutex);
+               return retval;
+       }
        mutex_unlock(hcd->bandwidth_mutex);
 
        /* re-init hc/hcd interface/endpoint state */
index 7c1198f..f232914 100644 (file)
@@ -370,6 +370,10 @@ static const struct usb_device_id usb_quirk_list[] = {
        { USB_DEVICE(0x0926, 0x0202), .driver_info =
                        USB_QUIRK_ENDPOINT_IGNORE },
 
+       /* Sound Devices MixPre-D */
+       { USB_DEVICE(0x0926, 0x0208), .driver_info =
+                       USB_QUIRK_ENDPOINT_IGNORE },
+
        /* Keytouch QWERTY Panel keyboard */
        { USB_DEVICE(0x0926, 0x3333), .driver_info =
                        USB_QUIRK_CONFIG_INTF_STRINGS },
@@ -465,6 +469,8 @@ static const struct usb_device_id usb_quirk_list[] = {
 
        { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
 
+       { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
+
        /* DJI CineSSD */
        { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
 
@@ -509,6 +515,7 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = {
  */
 static const struct usb_device_id usb_endpoint_ignore[] = {
        { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0202, 1), .driver_info = 0x85 },
+       { USB_DEVICE_INTERFACE_NUMBER(0x0926, 0x0208, 1), .driver_info = 0x85 },
        { }
 };
 
index a2ca38e..8d13419 100644 (file)
@@ -889,7 +889,11 @@ read_descriptors(struct file *filp, struct kobject *kobj,
        size_t srclen, n;
        int cfgno;
        void *src;
+       int retval;
 
+       retval = usb_lock_device_interruptible(udev);
+       if (retval < 0)
+               return -EINTR;
        /* The binary attribute begins with the device descriptor.
         * Following that are the raw descriptor entries for all the
         * configurations (config plus subsidiary descriptors).
@@ -914,6 +918,7 @@ read_descriptors(struct file *filp, struct kobject *kobj,
                        off -= srclen;
                }
        }
+       usb_unlock_device(udev);
        return count - nleft;
 }
 
index 422aea2..2eb34c8 100644 (file)
@@ -646,9 +646,8 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
                        if (!(reg & DWC3_GUSB2PHYCFG_ULPI_UTMI))
                                break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case DWC3_GHWPARAMS3_HSPHY_IFC_ULPI:
-               /* FALLTHROUGH */
        default:
                break;
        }
@@ -1411,7 +1410,7 @@ static void dwc3_check_params(struct dwc3 *dwc)
        default:
                dev_err(dev, "invalid maximum_speed parameter %d\n",
                        dwc->maximum_speed);
-               /* fall through */
+               fallthrough;
        case USB_SPEED_UNKNOWN:
                /* default to superspeed */
                dwc->maximum_speed = USB_SPEED_SUPER;
index 88b75b5..1f7f4d8 100644 (file)
@@ -737,13 +737,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
                goto err_disable_clks;
        }
 
-       ret = reset_control_deassert(priv->reset);
+       ret = reset_control_reset(priv->reset);
        if (ret)
-               goto err_assert_reset;
+               goto err_disable_clks;
 
        ret = dwc3_meson_g12a_get_phys(priv);
        if (ret)
-               goto err_assert_reset;
+               goto err_disable_clks;
 
        ret = priv->drvdata->setup_regmaps(priv, base);
        if (ret)
@@ -752,7 +752,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
        if (priv->vbus) {
                ret = regulator_enable(priv->vbus);
                if (ret)
-                       goto err_assert_reset;
+                       goto err_disable_clks;
        }
 
        /* Get dr_mode */
@@ -765,13 +765,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)
 
        ret = priv->drvdata->usb_init(priv);
        if (ret)
-               goto err_assert_reset;
+               goto err_disable_clks;
 
        /* Init PHYs */
        for (i = 0 ; i < PHY_COUNT ; ++i) {
                ret = phy_init(priv->phys[i]);
                if (ret)
-                       goto err_assert_reset;
+                       goto err_disable_clks;
        }
 
        /* Set PHY Power */
@@ -809,9 +809,6 @@ err_phys_exit:
        for (i = 0 ; i < PHY_COUNT ; ++i)
                phy_exit(priv->phys[i]);
 
-err_assert_reset:
-       reset_control_assert(priv->reset);
-
 err_disable_clks:
        clk_bulk_disable_unprepare(priv->drvdata->num_clks,
                                   priv->drvdata->clks);
index e44bfc3..c2a0f64 100644 (file)
@@ -1054,27 +1054,25 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
  * dwc3_prepare_one_trb - setup one TRB from one request
  * @dep: endpoint for which this request is prepared
  * @req: dwc3_request pointer
+ * @trb_length: buffer size of the TRB
  * @chain: should this TRB be chained to the next?
  * @node: only for isochronous endpoints. First TRB needs different type.
  */
 static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
-               struct dwc3_request *req, unsigned chain, unsigned node)
+               struct dwc3_request *req, unsigned int trb_length,
+               unsigned chain, unsigned node)
 {
        struct dwc3_trb         *trb;
-       unsigned int            length;
        dma_addr_t              dma;
        unsigned                stream_id = req->request.stream_id;
        unsigned                short_not_ok = req->request.short_not_ok;
        unsigned                no_interrupt = req->request.no_interrupt;
        unsigned                is_last = req->request.is_last;
 
-       if (req->request.num_sgs > 0) {
-               length = sg_dma_len(req->start_sg);
+       if (req->request.num_sgs > 0)
                dma = sg_dma_address(req->start_sg);
-       } else {
-               length = req->request.length;
+       else
                dma = req->request.dma;
-       }
 
        trb = &dep->trb_pool[dep->trb_enqueue];
 
@@ -1086,7 +1084,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep,
 
        req->num_trbs++;
 
-       __dwc3_prepare_one_trb(dep, trb, dma, length, chain, node,
+       __dwc3_prepare_one_trb(dep, trb, dma, trb_length, chain, node,
                        stream_id, short_not_ok, no_interrupt, is_last);
 }
 
@@ -1096,16 +1094,27 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
        struct scatterlist *sg = req->start_sg;
        struct scatterlist *s;
        int             i;
-
+       unsigned int length = req->request.length;
        unsigned int remaining = req->request.num_mapped_sgs
                - req->num_queued_sgs;
 
+       /*
+        * If we resume preparing the request, then get the remaining length of
+        * the request and resume where we left off.
+        */
+       for_each_sg(req->request.sg, s, req->num_queued_sgs, i)
+               length -= sg_dma_len(s);
+
        for_each_sg(sg, s, remaining, i) {
-               unsigned int length = req->request.length;
                unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
                unsigned int rem = length % maxp;
+               unsigned int trb_length;
                unsigned chain = true;
 
+               trb_length = min_t(unsigned int, length, sg_dma_len(s));
+
+               length -= trb_length;
+
                /*
                 * IOMMU driver is coalescing the list of sgs which shares a
                 * page boundary into one and giving it to USB driver. With
@@ -1113,7 +1122,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
                 * sgs passed. So mark the chain bit to false if it isthe last
                 * mapped sg.
                 */
-               if (i == remaining - 1)
+               if ((i == remaining - 1) || !length)
                        chain = false;
 
                if (rem && usb_endpoint_dir_out(dep->endpoint.desc) && !chain) {
@@ -1123,7 +1132,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
                        req->needs_extra_trb = true;
 
                        /* prepare normal TRB */
-                       dwc3_prepare_one_trb(dep, req, true, i);
+                       dwc3_prepare_one_trb(dep, req, trb_length, true, i);
 
                        /* Now prepare one extra TRB to align transfer size */
                        trb = &dep->trb_pool[dep->trb_enqueue];
@@ -1134,8 +1143,39 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
                                        req->request.short_not_ok,
                                        req->request.no_interrupt,
                                        req->request.is_last);
+               } else if (req->request.zero && req->request.length &&
+                          !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
+                          !rem && !chain) {
+                       struct dwc3     *dwc = dep->dwc;
+                       struct dwc3_trb *trb;
+
+                       req->needs_extra_trb = true;
+
+                       /* Prepare normal TRB */
+                       dwc3_prepare_one_trb(dep, req, trb_length, true, i);
+
+                       /* Prepare one extra TRB to handle ZLP */
+                       trb = &dep->trb_pool[dep->trb_enqueue];
+                       req->num_trbs++;
+                       __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
+                                              !req->direction, 1,
+                                              req->request.stream_id,
+                                              req->request.short_not_ok,
+                                              req->request.no_interrupt,
+                                              req->request.is_last);
+
+                       /* Prepare one more TRB to handle MPS alignment */
+                       if (!req->direction) {
+                               trb = &dep->trb_pool[dep->trb_enqueue];
+                               req->num_trbs++;
+                               __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
+                                                      false, 1, req->request.stream_id,
+                                                      req->request.short_not_ok,
+                                                      req->request.no_interrupt,
+                                                      req->request.is_last);
+                       }
                } else {
-                       dwc3_prepare_one_trb(dep, req, chain, i);
+                       dwc3_prepare_one_trb(dep, req, trb_length, chain, i);
                }
 
                /*
@@ -1150,6 +1190,16 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
 
                req->num_queued_sgs++;
 
+               /*
+                * The number of pending SG entries may not correspond to the
+                * number of mapped SG entries. If all the data are queued, then
+                * don't include unused SG entries.
+                */
+               if (length == 0) {
+                       req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
+                       break;
+               }
+
                if (!dwc3_calc_trbs_left(dep))
                        break;
        }
@@ -1169,7 +1219,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
                req->needs_extra_trb = true;
 
                /* prepare normal TRB */
-               dwc3_prepare_one_trb(dep, req, true, 0);
+               dwc3_prepare_one_trb(dep, req, length, true, 0);
 
                /* Now prepare one extra TRB to align transfer size */
                trb = &dep->trb_pool[dep->trb_enqueue];
@@ -1180,6 +1230,7 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
                                req->request.no_interrupt,
                                req->request.is_last);
        } else if (req->request.zero && req->request.length &&
+                  !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
                   (IS_ALIGNED(req->request.length, maxp))) {
                struct dwc3     *dwc = dep->dwc;
                struct dwc3_trb *trb;
@@ -1187,18 +1238,29 @@ static void dwc3_prepare_one_trb_linear(struct dwc3_ep *dep,
                req->needs_extra_trb = true;
 
                /* prepare normal TRB */
-               dwc3_prepare_one_trb(dep, req, true, 0);
+               dwc3_prepare_one_trb(dep, req, length, true, 0);
 
-               /* Now prepare one extra TRB to handle ZLP */
+               /* Prepare one extra TRB to handle ZLP */
                trb = &dep->trb_pool[dep->trb_enqueue];
                req->num_trbs++;
                __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, 0,
-                               false, 1, req->request.stream_id,
+                               !req->direction, 1, req->request.stream_id,
                                req->request.short_not_ok,
                                req->request.no_interrupt,
                                req->request.is_last);
+
+               /* Prepare one more TRB to handle MPS alignment for OUT */
+               if (!req->direction) {
+                       trb = &dep->trb_pool[dep->trb_enqueue];
+                       req->num_trbs++;
+                       __dwc3_prepare_one_trb(dep, trb, dwc->bounce_addr, maxp,
+                                              false, 1, req->request.stream_id,
+                                              req->request.short_not_ok,
+                                              req->request.no_interrupt,
+                                              req->request.is_last);
+               }
        } else {
-               dwc3_prepare_one_trb(dep, req, false, 0);
+               dwc3_prepare_one_trb(dep, req, length, false, 0);
        }
 }
 
@@ -2671,8 +2733,17 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
                                status);
 
        if (req->needs_extra_trb) {
+               unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
+
                ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event,
                                status);
+
+               /* Reclaim MPS padding TRB for ZLP */
+               if (!req->direction && req->request.zero && req->request.length &&
+                   !usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
+                   (IS_ALIGNED(req->request.length, maxp)))
+                       ret = dwc3_gadget_ep_reclaim_trb_linear(dep, req, event, status);
+
                req->needs_extra_trb = false;
        }
 
index 331c951..950c943 100644 (file)
@@ -2039,7 +2039,6 @@ static int do_scsi_command(struct fsg_common *common)
        case RELEASE:
        case RESERVE:
        case SEND_DIAGNOSTIC:
-               fallthrough;
 
        default:
 unknown_cmnd:
index 1d90008..b4206b0 100644 (file)
@@ -1181,12 +1181,15 @@ static int ncm_unwrap_ntb(struct gether *port,
        int             ndp_index;
        unsigned        dg_len, dg_len2;
        unsigned        ndp_len;
+       unsigned        block_len;
        struct sk_buff  *skb2;
        int             ret = -EINVAL;
-       unsigned        max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
+       unsigned        ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
+       unsigned        frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize);
        const struct ndp_parser_opts *opts = ncm->parser_opts;
        unsigned        crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
        int             dgram_counter;
+       bool            ndp_after_header;
 
        /* dwSignature */
        if (get_unaligned_le32(tmp) != opts->nth_sign) {
@@ -1205,25 +1208,37 @@ static int ncm_unwrap_ntb(struct gether *port,
        }
        tmp++; /* skip wSequence */
 
+       block_len = get_ncm(&tmp, opts->block_length);
        /* (d)wBlockLength */
-       if (get_ncm(&tmp, opts->block_length) > max_size) {
+       if (block_len > ntb_max) {
                INFO(port->func.config->cdev, "OUT size exceeded\n");
                goto err;
        }
 
        ndp_index = get_ncm(&tmp, opts->ndp_index);
+       ndp_after_header = false;
 
        /* Run through all the NDP's in the NTB */
        do {
-               /* NCM 3.2 */
-               if (((ndp_index % 4) != 0) &&
-                               (ndp_index < opts->nth_size)) {
+               /*
+                * NCM 3.2
+                * dwNdpIndex
+                */
+               if (((ndp_index % 4) != 0) ||
+                               (ndp_index < opts->nth_size) ||
+                               (ndp_index > (block_len -
+                                             opts->ndp_size))) {
                        INFO(port->func.config->cdev, "Bad index: %#X\n",
                             ndp_index);
                        goto err;
                }
+               if (ndp_index == opts->nth_size)
+                       ndp_after_header = true;
 
-               /* walk through NDP */
+               /*
+                * walk through NDP
+                * dwSignature
+                */
                tmp = (void *)(skb->data + ndp_index);
                if (get_unaligned_le32(tmp) != ncm->ndp_sign) {
                        INFO(port->func.config->cdev, "Wrong NDP SIGN\n");
@@ -1234,14 +1249,15 @@ static int ncm_unwrap_ntb(struct gether *port,
                ndp_len = get_unaligned_le16(tmp++);
                /*
                 * NCM 3.3.1
+                * wLength
                 * entry is 2 items
                 * item size is 16/32 bits, opts->dgram_item_len * 2 bytes
                 * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry
                 * Each entry is a dgram index and a dgram length.
                 */
                if ((ndp_len < opts->ndp_size
-                               + 2 * 2 * (opts->dgram_item_len * 2))
-                               || (ndp_len % opts->ndplen_align != 0)) {
+                               + 2 * 2 * (opts->dgram_item_len * 2)) ||
+                               (ndp_len % opts->ndplen_align != 0)) {
                        INFO(port->func.config->cdev, "Bad NDP length: %#X\n",
                             ndp_len);
                        goto err;
@@ -1258,8 +1274,21 @@ static int ncm_unwrap_ntb(struct gether *port,
 
                do {
                        index = index2;
+                       /* wDatagramIndex[0] */
+                       if ((index < opts->nth_size) ||
+                                       (index > block_len - opts->dpe_size)) {
+                               INFO(port->func.config->cdev,
+                                    "Bad index: %#X\n", index);
+                               goto err;
+                       }
+
                        dg_len = dg_len2;
-                       if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */
+                       /*
+                        * wDatagramLength[0]
+                        * ethernet hdr + crc or larger than max frame size
+                        */
+                       if ((dg_len < 14 + crc_len) ||
+                                       (dg_len > frame_max)) {
                                INFO(port->func.config->cdev,
                                     "Bad dgram length: %#X\n", dg_len);
                                goto err;
@@ -1283,6 +1312,37 @@ static int ncm_unwrap_ntb(struct gether *port,
                        index2 = get_ncm(&tmp, opts->dgram_item_len);
                        dg_len2 = get_ncm(&tmp, opts->dgram_item_len);
 
+                       if (index2 == 0 || dg_len2 == 0)
+                               break;
+
+                       /* wDatagramIndex[1] */
+                       if (ndp_after_header) {
+                               if (index2 < opts->nth_size + opts->ndp_size) {
+                                       INFO(port->func.config->cdev,
+                                            "Bad index: %#X\n", index2);
+                                       goto err;
+                               }
+                       } else {
+                               if (index2 < opts->nth_size + opts->dpe_size) {
+                                       INFO(port->func.config->cdev,
+                                            "Bad index: %#X\n", index2);
+                                       goto err;
+                               }
+                       }
+                       if (index2 > block_len - opts->dpe_size) {
+                               INFO(port->func.config->cdev,
+                                    "Bad index: %#X\n", index2);
+                               goto err;
+                       }
+
+                       /* wDatagramLength[1] */
+                       if ((dg_len2 < 14 + crc_len) ||
+                                       (dg_len2 > frame_max)) {
+                               INFO(port->func.config->cdev,
+                                    "Bad dgram length: %#X\n", dg_len);
+                               goto err;
+                       }
+
                        /*
                         * Copy the data into a new skb.
                         * This ensures the truesize is correct
@@ -1299,9 +1359,6 @@ static int ncm_unwrap_ntb(struct gether *port,
                        ndp_len -= 2 * (opts->dgram_item_len * 2);
 
                        dgram_counter++;
-
-                       if (index2 == 0 || dg_len2 == 0)
-                               break;
                } while (ndp_len > 2 * (opts->dgram_item_len * 2));
        } while (ndp_index);
 
index d94b814..184165e 100644 (file)
@@ -753,12 +753,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream)
                goto err_sts;
 
        return 0;
+
 err_sts:
-       usb_ep_free_request(fu->ep_status, stream->req_status);
-       stream->req_status = NULL;
-err_out:
        usb_ep_free_request(fu->ep_out, stream->req_out);
        stream->req_out = NULL;
+err_out:
+       usb_ep_free_request(fu->ep_in, stream->req_in);
+       stream->req_in = NULL;
 out:
        return -ENOMEM;
 }
index eaa13fd..e313c3b 100644 (file)
@@ -14,6 +14,7 @@
 #define __U_F_H__
 
 #include <linux/usb/gadget.h>
+#include <linux/overflow.h>
 
 /* Variable Length Array Macros **********************************************/
 #define vla_group(groupname) size_t groupname##__next = 0
 
 #define vla_item(groupname, type, name, n) \
        size_t groupname##_##name##__offset = ({                               \
-               size_t align_mask = __alignof__(type) - 1;                     \
-               size_t offset = (groupname##__next + align_mask) & ~align_mask;\
-               size_t size = (n) * sizeof(type);                              \
-               groupname##__next = offset + size;                             \
+               size_t offset = 0;                                             \
+               if (groupname##__next != SIZE_MAX) {                           \
+                       size_t align_mask = __alignof__(type) - 1;             \
+                       size_t size = array_size(n, sizeof(type));             \
+                       offset = (groupname##__next + align_mask) &            \
+                                 ~align_mask;                                 \
+                       if (check_add_overflow(offset, size,                   \
+                                              &groupname##__next)) {          \
+                               groupname##__next = SIZE_MAX;                  \
+                               offset = 0;                                    \
+                       }                                                      \
+               }                                                              \
                offset;                                                        \
        })
 
 #define vla_item_with_sz(groupname, type, name, n) \
-       size_t groupname##_##name##__sz = (n) * sizeof(type);                  \
-       size_t groupname##_##name##__offset = ({                               \
-               size_t align_mask = __alignof__(type) - 1;                     \
-               size_t offset = (groupname##__next + align_mask) & ~align_mask;\
-               size_t size = groupname##_##name##__sz;                        \
-               groupname##__next = offset + size;                             \
-               offset;                                                        \
+       size_t groupname##_##name##__sz = array_size(n, sizeof(type));          \
+       size_t groupname##_##name##__offset = ({                                \
+               size_t offset = 0;                                              \
+               if (groupname##__next != SIZE_MAX) {                            \
+                       size_t align_mask = __alignof__(type) - 1;              \
+                       offset = (groupname##__next + align_mask) &             \
+                                 ~align_mask;                                  \
+                       if (check_add_overflow(offset, groupname##_##name##__sz,\
+                                                       &groupname##__next)) {  \
+                               groupname##__next = SIZE_MAX;                   \
+                               offset = 0;                                     \
+                       }                                                       \
+               }                                                               \
+               offset;                                                         \
        })
 
 #define vla_ptr(ptr, groupname, name) \
index fa67930..a6426dd 100644 (file)
@@ -328,7 +328,7 @@ static int usba_config_fifo_table(struct usba_udc *udc)
        switch (fifo_mode) {
        default:
                fifo_mode = 0;
-               /* fall through */
+               fallthrough;
        case 0:
                udc->fifo_cfg = NULL;
                n = 0;
index b2638e8..a6f7b25 100644 (file)
@@ -250,7 +250,7 @@ static int dr_controller_setup(struct fsl_udc *udc)
                break;
        case FSL_USB2_PHY_UTMI_WIDE:
                portctrl |= PORTSCX_PTW_16BIT;
-               /* fall through */
+               fallthrough;
        case FSL_USB2_PHY_UTMI:
        case FSL_USB2_PHY_UTMI_DUAL:
                if (udc->pdata->have_sysif_regs) {
index cfafdd9..10324a7 100644 (file)
@@ -2340,12 +2340,12 @@ static int pxa25x_udc_probe(struct platform_device *pdev)
        case PXA250_A0:
        case PXA250_A1:
                /* A0/A1 "not released"; ep 13, 15 unusable */
-               /* fall through */
+               fallthrough;
        case PXA250_B2: case PXA210_B2:
        case PXA250_B1: case PXA210_B1:
        case PXA250_B0: case PXA210_B0:
                /* OUT-DMA is broken ... */
-               /* fall through */
+               fallthrough;
        case PXA250_C0: case PXA210_C0:
                break;
 #elif  defined(CONFIG_ARCH_IXP4XX)
index a87c0b2..3055d9a 100644 (file)
@@ -1019,7 +1019,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
                        spin_lock_irqsave(&isp116x->lock, flags);
                        isp116x_write_reg32(isp116x, HCRHSTATUS, RH_HS_OCIC);
                        spin_unlock_irqrestore(&isp116x->lock, flags);
-                       /* fall through */
+                       fallthrough;
                case C_HUB_LOCAL_POWER:
                        DBG("C_HUB_LOCAL_POWER\n");
                        break;
@@ -1421,10 +1421,10 @@ static int isp116x_bus_suspend(struct usb_hcd *hcd)
                isp116x_write_reg32(isp116x, HCCONTROL,
                                    (val & ~HCCONTROL_HCFS) |
                                    HCCONTROL_USB_RESET);
-               /* fall through */
+               fallthrough;
        case HCCONTROL_USB_RESET:
                ret = -EBUSY;
-               /* fall through */
+               fallthrough;
        default:                /* HCCONTROL_USB_SUSPEND */
                spin_unlock_irqrestore(&isp116x->lock, flags);
                break;
index bd40e59..5f5e8a6 100644 (file)
@@ -171,9 +171,8 @@ static int exynos_ohci_probe(struct platform_device *pdev)
        hcd->rsrc_len = resource_size(res);
 
        irq = platform_get_irq(pdev, 0);
-       if (!irq) {
-               dev_err(&pdev->dev, "Failed to get IRQ\n");
-               err = -ENODEV;
+       if (irq < 0) {
+               err = irq;
                goto fail_io;
        }
 
index b8961c0..8c1bbac 100644 (file)
@@ -957,7 +957,8 @@ static void quirk_usb_disable_ehci(struct pci_dev *pdev)
                        ehci_bios_handoff(pdev, op_reg_base, cap, offset);
                        break;
                case 0: /* Illegal reserved cap, set cap=0 so we exit */
-                       cap = 0; /* fall through */
+                       cap = 0;
+                       fallthrough;
                default:
                        dev_warn(&pdev->dev,
                                 "EHCI: unrecognized capability %02x\n",
index fcc5ac5..ccb0156 100644 (file)
@@ -699,7 +699,7 @@ static void dbc_handle_xfer_event(struct xhci_dbc *dbc, union xhci_trb *event)
        switch (comp_code) {
        case COMP_SUCCESS:
                remain_length = 0;
-       /* FALLTHROUGH */
+               fallthrough;
        case COMP_SHORT_PACKET:
                status = 0;
                break;
index 92e25a6..c88bffd 100644 (file)
@@ -274,7 +274,7 @@ static int xhci_slot_context_show(struct seq_file *s, void *unused)
 
 static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
 {
-       int                     dci;
+       int                     ep_index;
        dma_addr_t              dma;
        struct xhci_hcd         *xhci;
        struct xhci_ep_ctx      *ep_ctx;
@@ -283,9 +283,9 @@ static int xhci_endpoint_context_show(struct seq_file *s, void *unused)
 
        xhci = hcd_to_xhci(bus_to_hcd(dev->udev->bus));
 
-       for (dci = 1; dci < 32; dci++) {
-               ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, dci);
-               dma = dev->out_ctx->dma + dci * CTX_SIZE(xhci->hcc_params);
+       for (ep_index = 0; ep_index < 31; ep_index++) {
+               ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index);
+               dma = dev->out_ctx->dma + (ep_index + 1) * CTX_SIZE(xhci->hcc_params);
                seq_printf(s, "%pad: %s\n", &dma,
                           xhci_decode_ep_context(le32_to_cpu(ep_ctx->ep_info),
                                                  le32_to_cpu(ep_ctx->ep_info2),
index c3554e3..c799ca5 100644 (file)
@@ -740,15 +740,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
 {
        u32 pls = status_reg & PORT_PLS_MASK;
 
-       /* resume state is a xHCI internal state.
-        * Do not report it to usb core, instead, pretend to be U3,
-        * thus usb core knows it's not ready for transfer
-        */
-       if (pls == XDEV_RESUME) {
-               *status |= USB_SS_PORT_LS_U3;
-               return;
-       }
-
        /* When the CAS bit is set then warm reset
         * should be performed on port
         */
@@ -770,6 +761,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
                 */
                pls |= USB_PORT_STAT_CONNECTION;
        } else {
+               /*
+                * Resume state is an xHCI internal state.  Do not report it to
+                * usb core, instead, pretend to be U3, thus usb core knows
+                * it's not ready for transfer.
+                */
+               if (pls == XDEV_RESUME) {
+                       *status |= USB_SS_PORT_LS_U3;
+                       return;
+               }
+
                /*
                 * If CAS bit isn't set but the Port is already at
                 * Compliance Mode, fake a connection so the USB core
@@ -1483,7 +1484,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        break;
                case USB_PORT_FEAT_C_SUSPEND:
                        bus_state->port_c_suspend &= ~(1 << wIndex);
-                       /* fall through */
+                       fallthrough;
                case USB_PORT_FEAT_C_RESET:
                case USB_PORT_FEAT_C_BH_PORT_RESET:
                case USB_PORT_FEAT_C_CONNECTION:
index 696fad5..fe405cd 100644 (file)
@@ -1311,7 +1311,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
                        interval = xhci_parse_microframe_interval(udev, ep);
                        break;
                }
-               /* Fall through - SS and HS isoc/int have same decoding */
+               fallthrough;    /* SS and HS isoc/int have same decoding */
 
        case USB_SPEED_SUPER_PLUS:
        case USB_SPEED_SUPER:
@@ -1331,7 +1331,7 @@ static unsigned int xhci_get_endpoint_interval(struct usb_device *udev,
                 * since it uses the same rules as low speed interrupt
                 * endpoints.
                 */
-               /* fall through */
+               fallthrough;
 
        case USB_SPEED_LOW:
                if (usb_endpoint_xfer_int(&ep->desc) ||
index 59b1965..f97ac9f 100644 (file)
 #define RENESAS_RETRY  10000
 #define RENESAS_DELAY  10
 
-#define ROM_VALID_01 0x2013
-#define ROM_VALID_02 0x2026
-
-static int renesas_verify_fw_version(struct pci_dev *pdev, u32 version)
-{
-       switch (version) {
-       case ROM_VALID_01:
-       case ROM_VALID_02:
-               return 0;
-       }
-       dev_err(&pdev->dev, "FW has invalid version :%d\n", version);
-       return -EINVAL;
-}
-
 static int renesas_fw_download_image(struct pci_dev *dev,
                                     const u32 *fw, size_t step, bool rom)
 {
@@ -202,10 +188,7 @@ static int renesas_check_rom_state(struct pci_dev *pdev)
 
        version &= RENESAS_FW_VERSION_FIELD;
        version = version >> RENESAS_FW_VERSION_OFFSET;
-
-       err = renesas_verify_fw_version(pdev, version);
-       if (err)
-               return err;
+       dev_dbg(&pdev->dev, "Found ROM version: %x\n", version);
 
        /*
         * Test if ROM is present and loaded, if so we can skip everything
index 2c255d0..a741a38 100644 (file)
@@ -2103,7 +2103,7 @@ static int process_ctrl_td(struct xhci_hcd *xhci, struct xhci_td *td,
                        break;
                xhci_dbg(xhci, "TRB error %u, halted endpoint index = %u\n",
                         trb_comp_code, ep_index);
-               /* else fall through */
+               fallthrough;
        case COMP_STALL_ERROR:
                /* Did we transfer part of the data (middle) phase? */
                if (trb_type == TRB_DATA || trb_type == TRB_NORMAL)
index 014d793..190923d 100644 (file)
@@ -1136,7 +1136,7 @@ static struct phy *tegra_xusb_get_phy(struct tegra_xusb *tegra, char *name,
        unsigned int i, phy_count = 0;
 
        for (i = 0; i < tegra->soc->num_types; i++) {
-               if (!strncmp(tegra->soc->phy_types[i].name, "usb2",
+               if (!strncmp(tegra->soc->phy_types[i].name, name,
                                                            strlen(name)))
                        return tegra->phys[phy_count+port];
 
@@ -1258,6 +1258,8 @@ static int tegra_xusb_init_usb_phy(struct tegra_xusb *tegra)
 
        INIT_WORK(&tegra->id_work, tegra_xhci_id_work);
        tegra->id_nb.notifier_call = tegra_xhci_id_notify;
+       tegra->otg_usb2_port = -EINVAL;
+       tegra->otg_usb3_port = -EINVAL;
 
        for (i = 0; i < tegra->num_usb_phys; i++) {
                struct phy *phy = tegra_xusb_get_phy(tegra, "usb2", i);
index 3c41b14..f4cedca 100644 (file)
@@ -3236,10 +3236,11 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
 
        wait_for_completion(cfg_cmd->completion);
 
-       ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
        xhci_free_command(xhci, cfg_cmd);
 cleanup:
        xhci_free_command(xhci, stop_cmd);
+       if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
+               ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
 }
 
 static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
@@ -4618,7 +4619,7 @@ static unsigned long long xhci_calculate_intel_u1_timeout(
                        break;
                }
                /* Otherwise the calculation is the same as isoc eps */
-               /* fall through */
+               fallthrough;
        case USB_ENDPOINT_XFER_ISOC:
                timeout_ns = xhci_service_interval_to_ns(desc);
                timeout_ns = DIV_ROUND_UP_ULL(timeout_ns * 105, 100);
index 407fe75..f868613 100644 (file)
@@ -426,7 +426,7 @@ static int lvs_rh_probe(struct usb_interface *intf,
                        USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT);
        if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) {
                dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret);
-               return ret;
+               return ret < 0 ? ret : -EINVAL;
        }
 
        /* submit urb to poll interrupt endpoint */
index 6e7d34e..b2e0988 100644 (file)
@@ -492,7 +492,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
        prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
        dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
                dev->cntl_buffer[0]);
-       retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
+       retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC);
        if (retval >= 0)
                timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
        finish_wait(&dev->waitq, &wait);
index c545b27..edb5b63 100644 (file)
@@ -975,7 +975,7 @@ static int cppi_channel_program(struct dma_channel *ch,
                musb_dbg(musb, "%cX DMA%d not allocated!",
                                cppi_ch->transmit ? 'T' : 'R',
                                cppi_ch->index);
-               /* FALLTHROUGH */
+               fallthrough;
        case MUSB_DMA_STATUS_FREE:
                break;
        }
index 5a56a03..849e0b7 100644 (file)
@@ -852,7 +852,7 @@ static void musb_handle_intr_suspend(struct musb *musb, u8 devctl)
        case OTG_STATE_B_IDLE:
                if (!musb->is_active)
                        break;
-               /* fall through */
+               fallthrough;
        case OTG_STATE_B_PERIPHERAL:
                musb_g_suspend(musb);
                musb->is_active = musb->g.b_hnp_enable;
@@ -972,9 +972,8 @@ static void musb_handle_intr_disconnect(struct musb *musb, u8 devctl)
        case OTG_STATE_A_PERIPHERAL:
                musb_hnp_stop(musb);
                musb_root_disconnect(musb);
-               /* FALLTHROUGH */
+               fallthrough;
        case OTG_STATE_B_WAIT_ACON:
-               /* FALLTHROUGH */
        case OTG_STATE_B_PERIPHERAL:
        case OTG_STATE_B_IDLE:
                musb_g_disconnect(musb);
@@ -1009,7 +1008,7 @@ static void musb_handle_intr_reset(struct musb *musb)
                switch (musb->xceiv->otg->state) {
                case OTG_STATE_A_SUSPEND:
                        musb_g_reset(musb);
-                       /* FALLTHROUGH */
+                       fallthrough;
                case OTG_STATE_A_WAIT_BCON:     /* OPT TD.4.7-900ms */
                        /* never use invalid T(a_wait_bcon) */
                        musb_dbg(musb, "HNP: in %s, %d msec timeout",
@@ -1030,7 +1029,7 @@ static void musb_handle_intr_reset(struct musb *musb)
                        break;
                case OTG_STATE_B_IDLE:
                        musb->xceiv->otg->state = OTG_STATE_B_PERIPHERAL;
-                       /* FALLTHROUGH */
+                       fallthrough;
                case OTG_STATE_B_PERIPHERAL:
                        musb_g_reset(musb);
                        break;
@@ -1471,7 +1470,7 @@ static int ep_config_from_table(struct musb *musb)
        switch (fifo_mode) {
        default:
                fifo_mode = 0;
-               /* FALLTHROUGH */
+               fallthrough;
        case 0:
                cfg = mode_0_cfg;
                n = ARRAY_SIZE(mode_0_cfg);
@@ -2018,7 +2017,7 @@ static void musb_pm_runtime_check_session(struct musb *musb)
                        musb->quirk_retries--;
                        return;
                }
-               /* fall through */
+               fallthrough;
        case MUSB_QUIRK_A_DISCONNECT_19:
                if (musb->quirk_retries && !musb->flush_irq_work) {
                        musb_dbg(musb,
index 19556c1..30085b2 100644 (file)
@@ -232,7 +232,7 @@ static int dsps_check_status(struct musb *musb, void *unused)
                        dsps_mod_timer_optional(glue);
                        break;
                }
-               /* fall through */
+               fallthrough;
 
        case OTG_STATE_A_WAIT_BCON:
                /* keep VBUS on for host-only mode */
@@ -242,7 +242,7 @@ static int dsps_check_status(struct musb *musb, void *unused)
                }
                musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
                skip_session = 1;
-               /* fall through */
+               fallthrough;
 
        case OTG_STATE_A_IDLE:
        case OTG_STATE_B_IDLE:
@@ -793,7 +793,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue,
        case USB_SPEED_SUPER:
                dev_warn(dev, "ignore incorrect maximum_speed "
                                "(super-speed) setting in dts");
-               /* fall through */
+               fallthrough;
        default:
                config->maximum_speed = USB_SPEED_HIGH;
        }
index 0ae3e0b..44d3cb0 100644 (file)
@@ -735,7 +735,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
                        musb_writeb(mbase, MUSB_TESTMODE,
                                        musb->test_mode_nr);
                }
-               /* FALLTHROUGH */
+               fallthrough;
 
        case MUSB_EP0_STAGE_STATUSOUT:
                /* end of sequence #1: write to host (TX state) */
@@ -767,7 +767,7 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb)
                 */
                retval = IRQ_HANDLED;
                musb->ep0_state = MUSB_EP0_STAGE_SETUP;
-               /* FALLTHROUGH */
+               fallthrough;
 
        case MUSB_EP0_STAGE_SETUP:
 setup:
index 8b7d22a..30c5e7d 100644 (file)
@@ -360,7 +360,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb,
                                qh = first_qh(head);
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
 
                case USB_ENDPOINT_XFER_ISOC:
                case USB_ENDPOINT_XFER_INT:
@@ -1019,7 +1019,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb)
                        musb->ep0_stage = MUSB_EP0_OUT;
                        more = true;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case MUSB_EP0_OUT:
                fifo_count = min_t(size_t, qh->maxpacket,
                                   urb->transfer_buffer_length -
@@ -2222,7 +2222,7 @@ static int musb_urb_enqueue(
                        interval = max_t(u8, epd->bInterval, 1);
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case USB_ENDPOINT_XFER_ISOC:
                /* ISO always uses logarithmic encoding */
                interval = min_t(u8, epd->bInterval, 16);
index cb7ae29..cafc695 100644 (file)
@@ -211,7 +211,7 @@ void musb_root_disconnect(struct musb *musb)
                        musb->g.is_a_peripheral = 1;
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case OTG_STATE_A_HOST:
                musb->xceiv->otg->state = OTG_STATE_A_WAIT_BCON;
                musb->is_active = 0;
index d62c78b..4232f1c 100644 (file)
@@ -104,7 +104,7 @@ static void omap_musb_set_mailbox(struct omap2430_glue *glue)
                        if (error)
                                break;
                        musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE;
-                       /* Fall through */
+                       fallthrough;
                case OTG_STATE_A_WAIT_VRISE:
                case OTG_STATE_A_WAIT_BCON:
                case OTG_STATE_A_HOST:
index 99890d1..c26683a 100644 (file)
@@ -464,7 +464,7 @@ static void musb_do_idle(struct timer_list *t)
                        dev_dbg(musb->controller, "Nothing connected %s, turning off VBUS\n",
                                        usb_otg_state_string(musb->xceiv->otg->state));
                }
-               /* FALLTHROUGH */
+               fallthrough;
        case OTG_STATE_A_IDLE:
                tusb_musb_set_vbus(musb, 0);
        default:
index d4ee3cb..f6d3731 100644 (file)
@@ -176,6 +176,7 @@ static int ingenic_usb_phy_init(struct usb_phy *phy)
 
        /* Wait for PHY to reset */
        usleep_range(30, 300);
+       reg = readl(priv->base + REG_USBPCR_OFFSET);
        writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET);
        usleep_range(300, 1000);
 
index 871cdcc..9823bb4 100644 (file)
@@ -713,6 +713,7 @@ static const struct usb_device_id id_table_combined[] = {
        { USB_DEVICE(XSENS_VID, XSENS_AWINDA_STATION_PID) },
        { USB_DEVICE(XSENS_VID, XSENS_CONVERTER_PID) },
        { USB_DEVICE(XSENS_VID, XSENS_MTDEVBOARD_PID) },
+       { USB_DEVICE(XSENS_VID, XSENS_MTIUSBCONVERTER_PID) },
        { USB_DEVICE(XSENS_VID, XSENS_MTW_PID) },
        { USB_DEVICE(FTDI_VID, FTDI_OMNI1509) },
        { USB_DEVICE(MOBILITY_VID, MOBILITY_USB_SERIAL_PID) },
index e837352..b5ca17a 100644 (file)
 #define XSENS_AWINDA_DONGLE_PID 0x0102
 #define XSENS_MTW_PID          0x0200  /* Xsens MTw */
 #define XSENS_MTDEVBOARD_PID   0x0300  /* Motion Tracker Development Board */
+#define XSENS_MTIUSBCONVERTER_PID      0x0301  /* MTi USB converter */
 #define XSENS_CONVERTER_PID    0xD00D  /* Xsens USB-serial converter */
 
 /* Xsens devices using FTDI VID */
index 89b3192..0c6f160 100644 (file)
@@ -1094,14 +1094,18 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M),
          .driver_info = RSVD(1) | RSVD(3) },
        /* Quectel products using Quectel vendor ID */
-       { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
-         .driver_info = RSVD(4) },
-       { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
-         .driver_info = RSVD(4) },
-       { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95),
-         .driver_info = RSVD(4) },
-       { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
-         .driver_info = RSVD(4) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0xff, 0xff),
+         .driver_info = NUMEP2 },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21, 0xff, 0, 0) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0xff, 0xff),
+         .driver_info = NUMEP2 },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25, 0xff, 0, 0) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0xff, 0xff),
+         .driver_info = NUMEP2 },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EG95, 0xff, 0, 0) },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0xff, 0xff),
+         .driver_info = NUMEP2 },
+       { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96, 0xff, 0, 0) },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0xff, 0xff),
          .driver_info = RSVD(1) | RSVD(2) | RSVD(3) | RSVD(4) | NUMEP2 },
        { USB_DEVICE_AND_INTERFACE_INFO(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06, 0xff, 0, 0) },
@@ -1819,6 +1823,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9003, 0xff) },   /* Simcom SIM7500/SIM7600 MBIM mode */
        { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9011, 0xff),     /* Simcom SIM7500/SIM7600 RNDIS mode */
          .driver_info = RSVD(7) },
+       { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9205, 0xff) },   /* Simcom SIM7070/SIM7080/SIM7090 AT+ECM mode */
+       { USB_DEVICE_INTERFACE_CLASS(0x1e0e, 0x9206, 0xff) },   /* Simcom SIM7070/SIM7080/SIM7090 AT-only mode */
        { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
          .driver_info = NCTRL(0) | NCTRL(1) | RSVD(4) },
        { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D),
index c8a988d..15dc258 100644 (file)
@@ -592,7 +592,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) {
        case 0x64:
                info->pageshift = 8;
                info->smallpageshift = 1;
-               /* fall through */
+               fallthrough;
        case 0x5d: // 5d is a ROM card with pagesize 512.
                return 0x00200000;
 
index d592071..08f9296 100644 (file)
@@ -688,7 +688,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,
                break;
        case DMA_BIDIRECTIONAL:
                cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
-               /* fall through */
+               fallthrough;
        case DMA_TO_DEVICE:
                cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB;
        case DMA_NONE:
index 220ae2c..5732e96 100644 (file)
@@ -2328,7 +2328,7 @@ UNUSUAL_DEV(  0x357d, 0x7788, 0x0114, 0x0114,
                "JMicron",
                "USB to ATA/ATAPI Bridge",
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
-               US_FL_BROKEN_FUA ),
+               US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ),
 
 /* Reported by Andrey Rahmatullin <wrar@altlinux.org> */
 UNUSUAL_DEV(  0x4102, 0x1020, 0x0100,  0x0100,
index 162b09d..711ab24 100644 (file)
  * and don't forget to CC: the USB development list <linux-usb@vger.kernel.org>
  */
 
+/* Reported-by: Till Dörges <doerges@pre-sense.de> */
+UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
+               "Sony",
+               "PSZ-HA*",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_NO_REPORT_OPCODES),
+
 /* Reported-by: Julian Groß <julian.g@posteo.de> */
 UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
                "LaCie",
@@ -80,6 +87,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
                USB_SC_DEVICE, USB_PR_DEVICE, NULL,
                US_FL_BROKEN_FUA),
 
+/* Reported-by: Thinh Nguyen <thinhn@synopsys.com> */
+UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999,
+               "PNY",
+               "Pro Elite SSD",
+               USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+               US_FL_NO_ATA_1X),
+
 /* Reported-by: Hans de Goede <hdegoede@redhat.com> */
 UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
                "VIA",
index e4021e1..ec7da0f 100644 (file)
@@ -61,14 +61,11 @@ enum {
 
 #define PMC_USB_ALTMODE_ORI_SHIFT      1
 #define PMC_USB_ALTMODE_UFP_SHIFT      3
-#define PMC_USB_ALTMODE_ORI_AUX_SHIFT  4
-#define PMC_USB_ALTMODE_ORI_HSL_SHIFT  5
 
 /* DP specific Mode Data bits */
 #define PMC_USB_ALTMODE_DP_MODE_SHIFT  8
 
 /* TBT specific Mode Data bits */
-#define PMC_USB_ALTMODE_HPD_HIGH       BIT(14)
 #define PMC_USB_ALTMODE_TBT_TYPE       BIT(17)
 #define PMC_USB_ALTMODE_CABLE_TYPE     BIT(18)
 #define PMC_USB_ALTMODE_ACTIVE_LINK    BIT(20)
@@ -179,15 +176,9 @@ pmc_usb_mux_dp(struct pmc_usb_port *port, struct typec_mux_state *state)
        req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
        req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
 
-       req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT;
-       req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT;
-
        req.mode_data |= (state->mode - TYPEC_STATE_MODAL) <<
                         PMC_USB_ALTMODE_DP_MODE_SHIFT;
 
-       if (data->status & DP_STATUS_HPD_STATE)
-               req.mode_data |= PMC_USB_ALTMODE_HPD_HIGH;
-
        ret = pmc_usb_command(port, (void *)&req, sizeof(req));
        if (ret)
                return ret;
@@ -212,9 +203,6 @@ pmc_usb_mux_tbt(struct pmc_usb_port *port, struct typec_mux_state *state)
        req.mode_data = (port->orientation - 1) << PMC_USB_ALTMODE_ORI_SHIFT;
        req.mode_data |= (port->role - 1) << PMC_USB_ALTMODE_UFP_SHIFT;
 
-       req.mode_data |= sbu_orientation(port) << PMC_USB_ALTMODE_ORI_AUX_SHIFT;
-       req.mode_data |= hsl_orientation(port) << PMC_USB_ALTMODE_ORI_HSL_SHIFT;
-
        if (TBT_ADAPTER(data->device_mode) == TBT_ADAPTER_TBT3)
                req.mode_data |= PMC_USB_ALTMODE_TBT_TYPE;
 
@@ -497,6 +485,7 @@ err_remove_ports:
        for (i = 0; i < pmc->num_ports; i++) {
                typec_switch_unregister(pmc->port[i].typec_sw);
                typec_mux_unregister(pmc->port[i].typec_mux);
+               usb_role_switch_unregister(pmc->port[i].usb_sw);
        }
 
        return ret;
@@ -510,6 +499,7 @@ static int pmc_usb_remove(struct platform_device *pdev)
        for (i = 0; i < pmc->num_ports; i++) {
                typec_switch_unregister(pmc->port[i].typec_sw);
                typec_mux_unregister(pmc->port[i].typec_mux);
+               usb_role_switch_unregister(pmc->port[i].usb_sw);
        }
 
        return 0;
index f57d91f..bd80e03 100644 (file)
@@ -157,7 +157,7 @@ static enum typec_cc_status tcpci_to_typec_cc(unsigned int cc, bool sink)
        case 0x3:
                if (sink)
                        return TYPEC_CC_RP_3_0;
-               /* fall through */
+               fallthrough;
        case 0x0:
        default:
                return TYPEC_CC_OPEN;
index 3ef3720..a48e3f9 100644 (file)
@@ -3372,13 +3372,31 @@ static void run_state_machine(struct tcpm_port *port)
                        tcpm_set_state(port, SNK_HARD_RESET_SINK_OFF, 0);
                break;
        case SRC_HARD_RESET_VBUS_OFF:
-               tcpm_set_vconn(port, true);
+               /*
+                * 7.1.5 Response to Hard Resets
+                * Hard Reset Signaling indicates a communication failure has occurred and the
+                * Source Shall stop driving VCONN, Shall remove Rp from the VCONN pin and Shall
+                * drive VBUS to vSafe0V as shown in Figure 7-9.
+                */
+               tcpm_set_vconn(port, false);
                tcpm_set_vbus(port, false);
                tcpm_set_roles(port, port->self_powered, TYPEC_SOURCE,
                               tcpm_data_role_for_source(port));
-               tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
+               /*
+                * If tcpc fails to notify vbus off, TCPM will wait for PD_T_SAFE_0V +
+                * PD_T_SRC_RECOVER before turning vbus back on.
+                * From Table 7-12 Sequence Description for a Source Initiated Hard Reset:
+                * 4. Policy Engine waits tPSHardReset after sending Hard Reset Signaling and then
+                * tells the Device Policy Manager to instruct the power supply to perform a
+                * Hard Reset. The transition to vSafe0V Shall occur within tSafe0V (t2).
+                * 5. After tSrcRecover the Source applies power to VBUS in an attempt to
+                * re-establish communication with the Sink and resume USB Default Operation.
+                * The transition to vSafe5V Shall occur within tSrcTurnOn(t4).
+                */
+               tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SAFE_0V + PD_T_SRC_RECOVER);
                break;
        case SRC_HARD_RESET_VBUS_ON:
+               tcpm_set_vconn(port, true);
                tcpm_set_vbus(port, true);
                port->tcpc->set_pd_rx(port->tcpc, true);
                tcpm_set_attached_state(port, true);
@@ -3944,7 +3962,11 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
                tcpm_set_state(port, SNK_HARD_RESET_WAIT_VBUS, 0);
                break;
        case SRC_HARD_RESET_VBUS_OFF:
-               tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, 0);
+               /*
+                * After establishing the vSafe0V voltage condition on VBUS, the Source Shall wait
+                * tSrcRecover before re-applying VCONN and restoring VBUS to vSafe5V.
+                */
+               tcpm_set_state(port, SRC_HARD_RESET_VBUS_ON, PD_T_SRC_RECOVER);
                break;
        case HARD_RESET_SEND:
                break;
index 048381c..261131c 100644 (file)
@@ -288,8 +288,6 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
        struct typec_altmode *alt;
        struct ucsi_dp *dp;
 
-       mutex_lock(&con->lock);
-
        /* We can't rely on the firmware with the capabilities. */
        desc->vdo |= DP_CAP_DP_SIGNALING | DP_CAP_RECEPTACLE;
 
@@ -298,15 +296,12 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
        desc->vdo |= all_assignments << 16;
 
        alt = typec_port_register_altmode(con->port, desc);
-       if (IS_ERR(alt)) {
-               mutex_unlock(&con->lock);
+       if (IS_ERR(alt))
                return alt;
-       }
 
        dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
        if (!dp) {
                typec_unregister_altmode(alt);
-               mutex_unlock(&con->lock);
                return ERR_PTR(-ENOMEM);
        }
 
@@ -319,7 +314,5 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,
        alt->ops = &ucsi_displayport_ops;
        typec_altmode_set_drvdata(alt, dp);
 
-       mutex_unlock(&con->lock);
-
        return alt;
 }
index affd024..e680fcf 100644 (file)
@@ -146,40 +146,33 @@ static int ucsi_exec_command(struct ucsi *ucsi, u64 cmd)
        return UCSI_CCI_LENGTH(cci);
 }
 
-static int ucsi_run_command(struct ucsi *ucsi, u64 command,
-                           void *data, size_t size)
+int ucsi_send_command(struct ucsi *ucsi, u64 command,
+                     void *data, size_t size)
 {
        u8 length;
        int ret;
 
+       mutex_lock(&ucsi->ppm_lock);
+
        ret = ucsi_exec_command(ucsi, command);
        if (ret < 0)
-               return ret;
+               goto out;
 
        length = ret;
 
        if (data) {
                ret = ucsi->ops->read(ucsi, UCSI_MESSAGE_IN, data, size);
                if (ret)
-                       return ret;
+                       goto out;
        }
 
        ret = ucsi_acknowledge_command(ucsi);
        if (ret)
-               return ret;
-
-       return length;
-}
-
-int ucsi_send_command(struct ucsi *ucsi, u64 command,
-                     void *retval, size_t size)
-{
-       int ret;
+               goto out;
 
-       mutex_lock(&ucsi->ppm_lock);
-       ret = ucsi_run_command(ucsi, command, retval, size);
+       ret = length;
+out:
        mutex_unlock(&ucsi->ppm_lock);
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(ucsi_send_command);
@@ -205,7 +198,7 @@ void ucsi_altmode_update_active(struct ucsi_connector *con)
        int i;
 
        command = UCSI_GET_CURRENT_CAM | UCSI_CONNECTOR_NUMBER(con->num);
-       ret = ucsi_run_command(con->ucsi, command, &cur, sizeof(cur));
+       ret = ucsi_send_command(con->ucsi, command, &cur, sizeof(cur));
        if (ret < 0) {
                if (con->ucsi->version > 0x0100) {
                        dev_err(con->ucsi->dev,
@@ -354,7 +347,7 @@ ucsi_register_altmodes_nvidia(struct ucsi_connector *con, u8 recipient)
                command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
                command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
                command |= UCSI_GET_ALTMODE_OFFSET(i);
-               len = ucsi_run_command(con->ucsi, command, &alt, sizeof(alt));
+               len = ucsi_send_command(con->ucsi, command, &alt, sizeof(alt));
                /*
                 * We are collecting all altmodes first and then registering.
                 * Some type-C device will return zero length data beyond last
@@ -431,7 +424,7 @@ static int ucsi_register_altmodes(struct ucsi_connector *con, u8 recipient)
                command |= UCSI_GET_ALTMODE_RECIPIENT(recipient);
                command |= UCSI_GET_ALTMODE_CONNECTOR_NUMBER(con->num);
                command |= UCSI_GET_ALTMODE_OFFSET(i);
-               len = ucsi_run_command(con->ucsi, command, alt, sizeof(alt));
+               len = ucsi_send_command(con->ucsi, command, alt, sizeof(alt));
                if (len <= 0)
                        return len;
 
@@ -502,7 +495,7 @@ static void ucsi_get_pdos(struct ucsi_connector *con, int is_partner)
        command |= UCSI_GET_PDOS_PARTNER_PDO(is_partner);
        command |= UCSI_GET_PDOS_NUM_PDOS(UCSI_MAX_PDOS - 1);
        command |= UCSI_GET_PDOS_SRC_PDOS;
-       ret = ucsi_run_command(ucsi, command, con->src_pdos,
+       ret = ucsi_send_command(ucsi, command, con->src_pdos,
                               sizeof(con->src_pdos));
        if (ret < 0) {
                dev_err(ucsi->dev, "UCSI_GET_PDOS failed (%d)\n", ret);
@@ -681,7 +674,7 @@ static void ucsi_handle_connector_change(struct work_struct *work)
                 */
                command = UCSI_GET_CAM_SUPPORTED;
                command |= UCSI_CONNECTOR_NUMBER(con->num);
-               ucsi_run_command(con->ucsi, command, NULL, 0);
+               ucsi_send_command(con->ucsi, command, NULL, 0);
        }
 
        if (con->status.change & UCSI_CONSTAT_PARTNER_CHANGE)
@@ -736,20 +729,24 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
        u32 cci;
        int ret;
 
+       mutex_lock(&ucsi->ppm_lock);
+
        ret = ucsi->ops->async_write(ucsi, UCSI_CONTROL, &command,
                                     sizeof(command));
        if (ret < 0)
-               return ret;
+               goto out;
 
        tmo = jiffies + msecs_to_jiffies(UCSI_TIMEOUT_MS);
 
        do {
-               if (time_is_before_jiffies(tmo))
-                       return -ETIMEDOUT;
+               if (time_is_before_jiffies(tmo)) {
+                       ret = -ETIMEDOUT;
+                       goto out;
+               }
 
                ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
                if (ret)
-                       return ret;
+                       goto out;
 
                /* If the PPM is still doing something else, reset it again. */
                if (cci & ~UCSI_CCI_RESET_COMPLETE) {
@@ -757,13 +754,15 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
                                                     &command,
                                                     sizeof(command));
                        if (ret < 0)
-                               return ret;
+                               goto out;
                }
 
                msleep(20);
        } while (!(cci & UCSI_CCI_RESET_COMPLETE));
 
-       return 0;
+out:
+       mutex_unlock(&ucsi->ppm_lock);
+       return ret;
 }
 
 static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
@@ -775,9 +774,7 @@ static int ucsi_role_cmd(struct ucsi_connector *con, u64 command)
                u64 c;
 
                /* PPM most likely stopped responding. Resetting everything. */
-               mutex_lock(&con->ucsi->ppm_lock);
                ucsi_reset_ppm(con->ucsi);
-               mutex_unlock(&con->ucsi->ppm_lock);
 
                c = UCSI_SET_NOTIFICATION_ENABLE | con->ucsi->ntfy;
                ucsi_send_command(con->ucsi, c, NULL, 0);
@@ -901,12 +898,15 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
        con->num = index + 1;
        con->ucsi = ucsi;
 
+       /* Delay other interactions with the con until registration is complete */
+       mutex_lock(&con->lock);
+
        /* Get connector capability */
        command = UCSI_GET_CONNECTOR_CAPABILITY;
        command |= UCSI_CONNECTOR_NUMBER(con->num);
-       ret = ucsi_run_command(ucsi, command, &con->cap, sizeof(con->cap));
+       ret = ucsi_send_command(ucsi, command, &con->cap, sizeof(con->cap));
        if (ret < 0)
-               return ret;
+               goto out;
 
        if (con->cap.op_mode & UCSI_CONCAP_OPMODE_DRP)
                cap->data = TYPEC_PORT_DRD;
@@ -938,27 +938,32 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
        ret = ucsi_register_port_psy(con);
        if (ret)
-               return ret;
+               goto out;
 
        /* Register the connector */
        con->port = typec_register_port(ucsi->dev, cap);
-       if (IS_ERR(con->port))
-               return PTR_ERR(con->port);
+       if (IS_ERR(con->port)) {
+               ret = PTR_ERR(con->port);
+               goto out;
+       }
 
        /* Alternate modes */
        ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_CON);
-       if (ret)
+       if (ret) {
                dev_err(ucsi->dev, "con%d: failed to register alt modes\n",
                        con->num);
+               goto out;
+       }
 
        /* Get the status */
        command = UCSI_GET_CONNECTOR_STATUS | UCSI_CONNECTOR_NUMBER(con->num);
-       ret = ucsi_run_command(ucsi, command, &con->status,
-                              sizeof(con->status));
+       ret = ucsi_send_command(ucsi, command, &con->status, sizeof(con->status));
        if (ret < 0) {
                dev_err(ucsi->dev, "con%d: failed to get status\n", con->num);
-               return 0;
+               ret = 0;
+               goto out;
        }
+       ret = 0; /* ucsi_send_command() returns length on success */
 
        switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
        case UCSI_CONSTAT_PARTNER_TYPE_UFP:
@@ -983,17 +988,21 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
 
        if (con->partner) {
                ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP);
-               if (ret)
+               if (ret) {
                        dev_err(ucsi->dev,
                                "con%d: failed to register alternate modes\n",
                                con->num);
-               else
+                       ret = 0;
+               } else {
                        ucsi_altmode_update_active(con);
+               }
        }
 
        trace_ucsi_register_port(con->num, &con->status);
 
-       return 0;
+out:
+       mutex_unlock(&con->lock);
+       return ret;
 }
 
 /**
@@ -1009,8 +1018,6 @@ static int ucsi_init(struct ucsi *ucsi)
        int ret;
        int i;
 
-       mutex_lock(&ucsi->ppm_lock);
-
        /* Reset the PPM */
        ret = ucsi_reset_ppm(ucsi);
        if (ret) {
@@ -1021,13 +1028,13 @@ static int ucsi_init(struct ucsi *ucsi)
        /* Enable basic notifications */
        ucsi->ntfy = UCSI_ENABLE_NTFY_CMD_COMPLETE | UCSI_ENABLE_NTFY_ERROR;
        command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
-       ret = ucsi_run_command(ucsi, command, NULL, 0);
+       ret = ucsi_send_command(ucsi, command, NULL, 0);
        if (ret < 0)
                goto err_reset;
 
        /* Get PPM capabilities */
        command = UCSI_GET_CAPABILITY;
-       ret = ucsi_run_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
+       ret = ucsi_send_command(ucsi, command, &ucsi->cap, sizeof(ucsi->cap));
        if (ret < 0)
                goto err_reset;
 
@@ -1054,12 +1061,10 @@ static int ucsi_init(struct ucsi *ucsi)
        /* Enable all notifications */
        ucsi->ntfy = UCSI_ENABLE_NTFY_ALL;
        command = UCSI_SET_NOTIFICATION_ENABLE | ucsi->ntfy;
-       ret = ucsi_run_command(ucsi, command, NULL, 0);
+       ret = ucsi_send_command(ucsi, command, NULL, 0);
        if (ret < 0)
                goto err_unregister;
 
-       mutex_unlock(&ucsi->ppm_lock);
-
        return 0;
 
 err_unregister:
@@ -1074,8 +1079,6 @@ err_unregister:
 err_reset:
        ucsi_reset_ppm(ucsi);
 err:
-       mutex_unlock(&ucsi->ppm_lock);
-
        return ret;
 }
 
index 9fc4f33..c0aca2f 100644 (file)
@@ -112,11 +112,15 @@ static void ucsi_acpi_notify(acpi_handle handle, u32 event, void *data)
 
 static int ucsi_acpi_probe(struct platform_device *pdev)
 {
+       struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
        struct ucsi_acpi *ua;
        struct resource *res;
        acpi_status status;
        int ret;
 
+       if (adev->dep_unmet)
+               return -EPROBE_DEFER;
+
        ua = devm_kzalloc(&pdev->dev, sizeof(*ua), GFP_KERNEL);
        if (!ua)
                return -ENOMEM;
index 2305d42..9d7d642 100644 (file)
@@ -461,6 +461,11 @@ static void stub_disconnect(struct usb_device *udev)
        return;
 }
 
+static bool usbip_match(struct usb_device *udev)
+{
+       return true;
+}
+
 #ifdef CONFIG_PM
 
 /* These functions need usb_port_suspend and usb_port_resume,
@@ -486,6 +491,7 @@ struct usb_device_driver stub_driver = {
        .name           = "usbip-host",
        .probe          = stub_probe,
        .disconnect     = stub_disconnect,
+       .match          = usbip_match,
 #ifdef CONFIG_PM
        .suspend        = stub_suspend,
        .resume         = stub_resume,
index 08f267a..64696d6 100644 (file)
@@ -84,7 +84,7 @@ struct ifcvf_hw {
        void __iomem * const *base;
        char config_msix_name[256];
        struct vdpa_callback config_cb;
-
+       unsigned int config_irq;
 };
 
 struct ifcvf_adapter {
index 076d7ac..8b40285 100644 (file)
@@ -55,6 +55,7 @@ static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)
                vf->vring[i].irq = -EINVAL;
        }
 
+       devm_free_irq(&pdev->dev, vf->config_irq, vf);
        ifcvf_free_irq_vectors(pdev);
 }
 
@@ -74,10 +75,14 @@ static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
        snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n",
                 pci_name(pdev));
        vector = 0;
-       irq = pci_irq_vector(pdev, vector);
-       ret = devm_request_irq(&pdev->dev, irq,
+       vf->config_irq = pci_irq_vector(pdev, vector);
+       ret = devm_request_irq(&pdev->dev, vf->config_irq,
                               ifcvf_config_changed, 0,
                               vf->config_msix_name, vf);
+       if (ret) {
+               IFCVF_ERR(pdev, "Failed to request config irq\n");
+               return ret;
+       }
 
        for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) {
                snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n",
index 9df69d5..70676a6 100644 (file)
 #define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev)
 
 #define VALID_FEATURES_MASK                                                                        \
-       (BIT(VIRTIO_NET_F_CSUM) | BIT(VIRTIO_NET_F_GUEST_CSUM) |                                   \
-        BIT(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT(VIRTIO_NET_F_MTU) | BIT(VIRTIO_NET_F_MAC) |   \
-        BIT(VIRTIO_NET_F_GUEST_TSO4) | BIT(VIRTIO_NET_F_GUEST_TSO6) |                             \
-        BIT(VIRTIO_NET_F_GUEST_ECN) | BIT(VIRTIO_NET_F_GUEST_UFO) | BIT(VIRTIO_NET_F_HOST_TSO4) | \
-        BIT(VIRTIO_NET_F_HOST_TSO6) | BIT(VIRTIO_NET_F_HOST_ECN) | BIT(VIRTIO_NET_F_HOST_UFO) |   \
-        BIT(VIRTIO_NET_F_MRG_RXBUF) | BIT(VIRTIO_NET_F_STATUS) | BIT(VIRTIO_NET_F_CTRL_VQ) |      \
-        BIT(VIRTIO_NET_F_CTRL_RX) | BIT(VIRTIO_NET_F_CTRL_VLAN) |                                 \
-        BIT(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT(VIRTIO_NET_F_GUEST_ANNOUNCE) |                      \
-        BIT(VIRTIO_NET_F_MQ) | BIT(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT(VIRTIO_NET_F_HASH_REPORT) |  \
-        BIT(VIRTIO_NET_F_RSS) | BIT(VIRTIO_NET_F_RSC_EXT) | BIT(VIRTIO_NET_F_STANDBY) |           \
-        BIT(VIRTIO_NET_F_SPEED_DUPLEX) | BIT(VIRTIO_F_NOTIFY_ON_EMPTY) |                          \
-        BIT(VIRTIO_F_ANY_LAYOUT) | BIT(VIRTIO_F_VERSION_1) | BIT(VIRTIO_F_ACCESS_PLATFORM) |      \
-        BIT(VIRTIO_F_RING_PACKED) | BIT(VIRTIO_F_ORDER_PLATFORM) | BIT(VIRTIO_F_SR_IOV))
+       (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) |                                   \
+        BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) |   \
+        BIT_ULL(VIRTIO_NET_F_GUEST_TSO4) | BIT_ULL(VIRTIO_NET_F_GUEST_TSO6) |                             \
+        BIT_ULL(VIRTIO_NET_F_GUEST_ECN) | BIT_ULL(VIRTIO_NET_F_GUEST_UFO) | BIT_ULL(VIRTIO_NET_F_HOST_TSO4) | \
+        BIT_ULL(VIRTIO_NET_F_HOST_TSO6) | BIT_ULL(VIRTIO_NET_F_HOST_ECN) | BIT_ULL(VIRTIO_NET_F_HOST_UFO) |   \
+        BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) |      \
+        BIT_ULL(VIRTIO_NET_F_CTRL_RX) | BIT_ULL(VIRTIO_NET_F_CTRL_VLAN) |                                 \
+        BIT_ULL(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT_ULL(VIRTIO_NET_F_GUEST_ANNOUNCE) |                      \
+        BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT_ULL(VIRTIO_NET_F_HASH_REPORT) |  \
+        BIT_ULL(VIRTIO_NET_F_RSS) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY) |           \
+        BIT_ULL(VIRTIO_NET_F_SPEED_DUPLEX) | BIT_ULL(VIRTIO_F_NOTIFY_ON_EMPTY) |                          \
+        BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_F_VERSION_1) | BIT_ULL(VIRTIO_F_ACCESS_PLATFORM) |      \
+        BIT_ULL(VIRTIO_F_RING_PACKED) | BIT_ULL(VIRTIO_F_ORDER_PLATFORM) | BIT_ULL(VIRTIO_F_SR_IOV))
 
 #define VALID_STATUS_MASK                                                                          \
        (VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER | VIRTIO_CONFIG_S_DRIVER_OK |        \
@@ -149,7 +149,7 @@ static bool mlx5_vdpa_debug;
 
 #define MLX5_LOG_VIO_FLAG(_feature)                                                                \
        do {                                                                                       \
-               if (features & BIT(_feature))                                                      \
+               if (features & BIT_ULL(_feature))                                                  \
                        mlx5_vdpa_info(mvdev, "%s\n", #_feature);                                  \
        } while (0)
 
@@ -750,10 +750,10 @@ static bool vq_is_tx(u16 idx)
 
 static u16 get_features_12_3(u64 features)
 {
-       return (!!(features & BIT(VIRTIO_NET_F_HOST_TSO4)) << 9) |
-              (!!(features & BIT(VIRTIO_NET_F_HOST_TSO6)) << 8) |
-              (!!(features & BIT(VIRTIO_NET_F_CSUM)) << 7) |
-              (!!(features & BIT(VIRTIO_NET_F_GUEST_CSUM)) << 6);
+       return (!!(features & BIT_ULL(VIRTIO_NET_F_HOST_TSO4)) << 9) |
+              (!!(features & BIT_ULL(VIRTIO_NET_F_HOST_TSO6)) << 8) |
+              (!!(features & BIT_ULL(VIRTIO_NET_F_CSUM)) << 7) |
+              (!!(features & BIT_ULL(VIRTIO_NET_F_GUEST_CSUM)) << 6);
 }
 
 static int create_virtqueue(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *mvq)
@@ -1439,13 +1439,13 @@ static u64 mlx_to_vritio_features(u16 dev_features)
        u64 result = 0;
 
        if (dev_features & MLX5_VIRTIO_NET_F_GUEST_CSUM)
-               result |= BIT(VIRTIO_NET_F_GUEST_CSUM);
+               result |= BIT_ULL(VIRTIO_NET_F_GUEST_CSUM);
        if (dev_features & MLX5_VIRTIO_NET_F_CSUM)
-               result |= BIT(VIRTIO_NET_F_CSUM);
+               result |= BIT_ULL(VIRTIO_NET_F_CSUM);
        if (dev_features & MLX5_VIRTIO_NET_F_HOST_TSO6)
-               result |= BIT(VIRTIO_NET_F_HOST_TSO6);
+               result |= BIT_ULL(VIRTIO_NET_F_HOST_TSO6);
        if (dev_features & MLX5_VIRTIO_NET_F_HOST_TSO4)
-               result |= BIT(VIRTIO_NET_F_HOST_TSO4);
+               result |= BIT_ULL(VIRTIO_NET_F_HOST_TSO4);
 
        return result;
 }
@@ -1459,15 +1459,15 @@ static u64 mlx5_vdpa_get_features(struct vdpa_device *vdev)
        dev_features = MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, device_features_bits_mask);
        ndev->mvdev.mlx_features = mlx_to_vritio_features(dev_features);
        if (MLX5_CAP_DEV_VDPA_EMULATION(mvdev->mdev, virtio_version_1_0))
-               ndev->mvdev.mlx_features |= BIT(VIRTIO_F_VERSION_1);
-       ndev->mvdev.mlx_features |= BIT(VIRTIO_F_ACCESS_PLATFORM);
+               ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_VERSION_1);
+       ndev->mvdev.mlx_features |= BIT_ULL(VIRTIO_F_ACCESS_PLATFORM);
        print_features(mvdev, ndev->mvdev.mlx_features, false);
        return ndev->mvdev.mlx_features;
 }
 
 static int verify_min_features(struct mlx5_vdpa_dev *mvdev, u64 features)
 {
-       if (!(features & BIT(VIRTIO_F_ACCESS_PLATFORM)))
+       if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)))
                return -EOPNOTSUPP;
 
        return 0;
index 620465c..1ab1f5c 100644 (file)
@@ -990,7 +990,7 @@ static long vfio_pci_ioctl(void *device_data,
                case VFIO_PCI_ERR_IRQ_INDEX:
                        if (pci_is_pcie(vdev->pdev))
                                break;
-               /* fall through */
+                       fallthrough;
                default:
                        return -EINVAL;
                }
index 86a02af..61ca8ab 100644 (file)
 
 struct vfio_pci_ioeventfd {
        struct list_head        next;
+       struct vfio_pci_device  *vdev;
        struct virqfd           *virqfd;
        void __iomem            *addr;
        uint64_t                data;
        loff_t                  pos;
        int                     bar;
        int                     count;
+       bool                    test_mem;
 };
 
 struct vfio_pci_irq_ctx {
index 916b184..9e353c4 100644 (file)
 #define vfio_ioread8   ioread8
 #define vfio_iowrite8  iowrite8
 
+#define VFIO_IOWRITE(size) \
+static int vfio_pci_iowrite##size(struct vfio_pci_device *vdev,                \
+                       bool test_mem, u##size val, void __iomem *io)   \
+{                                                                      \
+       if (test_mem) {                                                 \
+               down_read(&vdev->memory_lock);                          \
+               if (!__vfio_pci_memory_enabled(vdev)) {                 \
+                       up_read(&vdev->memory_lock);                    \
+                       return -EIO;                                    \
+               }                                                       \
+       }                                                               \
+                                                                       \
+       vfio_iowrite##size(val, io);                                    \
+                                                                       \
+       if (test_mem)                                                   \
+               up_read(&vdev->memory_lock);                            \
+                                                                       \
+       return 0;                                                       \
+}
+
+VFIO_IOWRITE(8)
+VFIO_IOWRITE(16)
+VFIO_IOWRITE(32)
+#ifdef iowrite64
+VFIO_IOWRITE(64)
+#endif
+
+#define VFIO_IOREAD(size) \
+static int vfio_pci_ioread##size(struct vfio_pci_device *vdev,         \
+                       bool test_mem, u##size *val, void __iomem *io)  \
+{                                                                      \
+       if (test_mem) {                                                 \
+               down_read(&vdev->memory_lock);                          \
+               if (!__vfio_pci_memory_enabled(vdev)) {                 \
+                       up_read(&vdev->memory_lock);                    \
+                       return -EIO;                                    \
+               }                                                       \
+       }                                                               \
+                                                                       \
+       *val = vfio_ioread##size(io);                                   \
+                                                                       \
+       if (test_mem)                                                   \
+               up_read(&vdev->memory_lock);                            \
+                                                                       \
+       return 0;                                                       \
+}
+
+VFIO_IOREAD(8)
+VFIO_IOREAD(16)
+VFIO_IOREAD(32)
+
 /*
  * Read or write from an __iomem region (MMIO or I/O port) with an excluded
  * range which is inaccessible.  The excluded range drops writes and fills
  * reads with -1.  This is intended for handling MSI-X vector tables and
  * leftover space for ROM BARs.
  */
-static ssize_t do_io_rw(void __iomem *io, char __user *buf,
+static ssize_t do_io_rw(struct vfio_pci_device *vdev, bool test_mem,
+                       void __iomem *io, char __user *buf,
                        loff_t off, size_t count, size_t x_start,
                        size_t x_end, bool iswrite)
 {
        ssize_t done = 0;
+       int ret;
 
        while (count) {
                size_t fillable, filled;
@@ -66,9 +119,15 @@ static ssize_t do_io_rw(void __iomem *io, char __user *buf,
                                if (copy_from_user(&val, buf, 4))
                                        return -EFAULT;
 
-                               vfio_iowrite32(val, io + off);
+                               ret = vfio_pci_iowrite32(vdev, test_mem,
+                                                        val, io + off);
+                               if (ret)
+                                       return ret;
                        } else {
-                               val = vfio_ioread32(io + off);
+                               ret = vfio_pci_ioread32(vdev, test_mem,
+                                                       &val, io + off);
+                               if (ret)
+                                       return ret;
 
                                if (copy_to_user(buf, &val, 4))
                                        return -EFAULT;
@@ -82,9 +141,15 @@ static ssize_t do_io_rw(void __iomem *io, char __user *buf,
                                if (copy_from_user(&val, buf, 2))
                                        return -EFAULT;
 
-                               vfio_iowrite16(val, io + off);
+                               ret = vfio_pci_iowrite16(vdev, test_mem,
+                                                        val, io + off);
+                               if (ret)
+                                       return ret;
                        } else {
-                               val = vfio_ioread16(io + off);
+                               ret = vfio_pci_ioread16(vdev, test_mem,
+                                                       &val, io + off);
+                               if (ret)
+                                       return ret;
 
                                if (copy_to_user(buf, &val, 2))
                                        return -EFAULT;
@@ -98,9 +163,15 @@ static ssize_t do_io_rw(void __iomem *io, char __user *buf,
                                if (copy_from_user(&val, buf, 1))
                                        return -EFAULT;
 
-                               vfio_iowrite8(val, io + off);
+                               ret = vfio_pci_iowrite8(vdev, test_mem,
+                                                       val, io + off);
+                               if (ret)
+                                       return ret;
                        } else {
-                               val = vfio_ioread8(io + off);
+                               ret = vfio_pci_ioread8(vdev, test_mem,
+                                                      &val, io + off);
+                               if (ret)
+                                       return ret;
 
                                if (copy_to_user(buf, &val, 1))
                                        return -EFAULT;
@@ -178,14 +249,6 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf,
 
        count = min(count, (size_t)(end - pos));
 
-       if (res->flags & IORESOURCE_MEM) {
-               down_read(&vdev->memory_lock);
-               if (!__vfio_pci_memory_enabled(vdev)) {
-                       up_read(&vdev->memory_lock);
-                       return -EIO;
-               }
-       }
-
        if (bar == PCI_ROM_RESOURCE) {
                /*
                 * The ROM can fill less space than the BAR, so we start the
@@ -213,7 +276,8 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf,
                x_end = vdev->msix_offset + vdev->msix_size;
        }
 
-       done = do_io_rw(io, buf, pos, count, x_start, x_end, iswrite);
+       done = do_io_rw(vdev, res->flags & IORESOURCE_MEM, io, buf, pos,
+                       count, x_start, x_end, iswrite);
 
        if (done >= 0)
                *ppos += done;
@@ -221,9 +285,6 @@ ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf,
        if (bar == PCI_ROM_RESOURCE)
                pci_unmap_rom(pdev, io);
 out:
-       if (res->flags & IORESOURCE_MEM)
-               up_read(&vdev->memory_lock);
-
        return done;
 }
 
@@ -278,7 +339,12 @@ ssize_t vfio_pci_vga_rw(struct vfio_pci_device *vdev, char __user *buf,
                return ret;
        }
 
-       done = do_io_rw(iomem, buf, off, count, 0, 0, iswrite);
+       /*
+        * VGA MMIO is a legacy, non-BAR resource that hopefully allows
+        * probing, so we don't currently worry about access in relation
+        * to the memory enable bit in the command register.
+        */
+       done = do_io_rw(vdev, false, iomem, buf, off, count, 0, 0, iswrite);
 
        vga_put(vdev->pdev, rsrc);
 
@@ -296,17 +362,21 @@ static int vfio_pci_ioeventfd_handler(void *opaque, void *unused)
 
        switch (ioeventfd->count) {
        case 1:
-               vfio_iowrite8(ioeventfd->data, ioeventfd->addr);
+               vfio_pci_iowrite8(ioeventfd->vdev, ioeventfd->test_mem,
+                                 ioeventfd->data, ioeventfd->addr);
                break;
        case 2:
-               vfio_iowrite16(ioeventfd->data, ioeventfd->addr);
+               vfio_pci_iowrite16(ioeventfd->vdev, ioeventfd->test_mem,
+                                  ioeventfd->data, ioeventfd->addr);
                break;
        case 4:
-               vfio_iowrite32(ioeventfd->data, ioeventfd->addr);
+               vfio_pci_iowrite32(ioeventfd->vdev, ioeventfd->test_mem,
+                                  ioeventfd->data, ioeventfd->addr);
                break;
 #ifdef iowrite64
        case 8:
-               vfio_iowrite64(ioeventfd->data, ioeventfd->addr);
+               vfio_pci_iowrite64(ioeventfd->vdev, ioeventfd->test_mem,
+                                  ioeventfd->data, ioeventfd->addr);
                break;
 #endif
        }
@@ -378,11 +448,13 @@ long vfio_pci_ioeventfd(struct vfio_pci_device *vdev, loff_t offset,
                goto out_unlock;
        }
 
+       ioeventfd->vdev = vdev;
        ioeventfd->addr = vdev->barmap[bar] + pos;
        ioeventfd->data = data;
        ioeventfd->pos = pos;
        ioeventfd->bar = bar;
        ioeventfd->count = count;
+       ioeventfd->test_mem = vdev->pdev->resource[bar].flags & IORESOURCE_MEM;
 
        ret = vfio_virqfd_enable(ioeventfd, vfio_pci_ioeventfd_handler,
                                 NULL, NULL, &ioeventfd->virqfd, fd);
index 6990fc7..5fbf0c1 100644 (file)
@@ -1424,13 +1424,16 @@ static int vfio_bus_type(struct device *dev, void *data)
 static int vfio_iommu_replay(struct vfio_iommu *iommu,
                             struct vfio_domain *domain)
 {
-       struct vfio_domain *d;
+       struct vfio_domain *d = NULL;
        struct rb_node *n;
        unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
        int ret;
 
        /* Arbitrarily pick the first domain in the list for lookups */
-       d = list_first_entry(&iommu->domain_list, struct vfio_domain, next);
+       if (!list_empty(&iommu->domain_list))
+               d = list_first_entry(&iommu->domain_list,
+                                    struct vfio_domain, next);
+
        n = rb_first(&iommu->dma_list);
 
        for (; n; n = rb_next(n)) {
@@ -1448,6 +1451,11 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
                                phys_addr_t p;
                                dma_addr_t i;
 
+                               if (WARN_ON(!d)) { /* mapped w/o a domain?! */
+                                       ret = -EINVAL;
+                                       goto unwind;
+                               }
+
                                phys = iommu_iova_to_phys(d->domain, iova);
 
                                if (WARN_ON(!phys)) {
@@ -1477,7 +1485,7 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
                                if (npage <= 0) {
                                        WARN_ON(!npage);
                                        ret = (int)npage;
-                                       return ret;
+                                       goto unwind;
                                }
 
                                phys = pfn << PAGE_SHIFT;
@@ -1486,14 +1494,67 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
 
                        ret = iommu_map(domain->domain, iova, phys,
                                        size, dma->prot | domain->prot);
-                       if (ret)
-                               return ret;
+                       if (ret) {
+                               if (!dma->iommu_mapped)
+                                       vfio_unpin_pages_remote(dma, iova,
+                                                       phys >> PAGE_SHIFT,
+                                                       size >> PAGE_SHIFT,
+                                                       true);
+                               goto unwind;
+                       }
 
                        iova += size;
                }
+       }
+
+       /* All dmas are now mapped, defer to second tree walk for unwind */
+       for (n = rb_first(&iommu->dma_list); n; n = rb_next(n)) {
+               struct vfio_dma *dma = rb_entry(n, struct vfio_dma, node);
+
                dma->iommu_mapped = true;
        }
+
        return 0;
+
+unwind:
+       for (; n; n = rb_prev(n)) {
+               struct vfio_dma *dma = rb_entry(n, struct vfio_dma, node);
+               dma_addr_t iova;
+
+               if (dma->iommu_mapped) {
+                       iommu_unmap(domain->domain, dma->iova, dma->size);
+                       continue;
+               }
+
+               iova = dma->iova;
+               while (iova < dma->iova + dma->size) {
+                       phys_addr_t phys, p;
+                       size_t size;
+                       dma_addr_t i;
+
+                       phys = iommu_iova_to_phys(domain->domain, iova);
+                       if (!phys) {
+                               iova += PAGE_SIZE;
+                               continue;
+                       }
+
+                       size = PAGE_SIZE;
+                       p = phys + size;
+                       i = iova + size;
+                       while (i < dma->iova + dma->size &&
+                              p == iommu_iova_to_phys(domain->domain, i)) {
+                               size += PAGE_SIZE;
+                               p += PAGE_SIZE;
+                               i += PAGE_SIZE;
+                       }
+
+                       iommu_unmap(domain->domain, iova, size);
+                       vfio_unpin_pages_remote(dma, iova, phys >> PAGE_SHIFT,
+                                               size >> PAGE_SHIFT, true);
+               }
+       }
+
+       return ret;
 }
 
 /*
@@ -2378,7 +2439,7 @@ static void *vfio_iommu_type1_open(unsigned long arg)
                break;
        case VFIO_TYPE1_NESTING_IOMMU:
                iommu->nesting = true;
-               /* fall through */
+               fallthrough;
        case VFIO_TYPE1v2_IOMMU:
                iommu->v2 = true;
                break;
index 1f0ca6e..34aec4b 100644 (file)
@@ -159,8 +159,8 @@ vhost_iotlb_itree_first(struct vhost_iotlb *iotlb, u64 start, u64 last)
 EXPORT_SYMBOL_GPL(vhost_iotlb_itree_first);
 
 /**
- * vhost_iotlb_itree_first - return the next overlapped range
- * @iotlb: the IOTLB
+ * vhost_iotlb_itree_next - return the next overlapped range
+ * @map: the starting map node
  * @start: start of IOVA range
  * @end: end of IOVA range
  */
index 5857d4e..b45519c 100644 (file)
@@ -2537,7 +2537,7 @@ void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)
        if (!vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX)) {
                r = vhost_update_used_flags(vq);
                if (r)
-                       vq_err(vq, "Failed to enable notification at %p: %d\n",
+                       vq_err(vq, "Failed to disable notification at %p: %d\n",
                               &vq->used->flags, r);
        }
 }
index ddc7f5f..8ec1942 100644 (file)
@@ -681,7 +681,7 @@ static int adp8860_probe(struct i2c_client *client,
        switch (ADP8860_MANID(reg_val)) {
        case ADP8863_MANUFID:
                data->gdwn_dis = !!pdata->gdwn_dis;
-               /* fall through */
+               fallthrough;
        case ADP8860_MANUFID:
                data->en_ambl_sens = !!pdata->en_ambl_sens;
                break;
index 09a9ad9..bcc92ae 100644 (file)
@@ -857,7 +857,7 @@ static void acornfb_parse_dram(char *opt)
                case 'M':
                case 'm':
                        size *= 1024;
-                       /* Fall through */
+                       fallthrough;
                case 'K':
                case 'k':
                        size *= 1024;
index 6f78389..ae3d8e8 100644 (file)
@@ -419,7 +419,7 @@ static int arcfb_ioctl(struct fb_info *info,
                        schedule();
                        finish_wait(&arcfb_waitq, &wait);
                }
-               /* fall through */
+                       fallthrough;
 
                case FBIO_GETCONTROL2:
                {
index 1e25219..bfd2f00 100644 (file)
@@ -508,7 +508,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
        case 32:
                var->transp.offset = 24;
                var->transp.length = 8;
-               /* fall through */
+               fallthrough;
        case 24:
                if (pdata->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
                        /* RGB:888 mode */
@@ -633,7 +633,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
                case 2: value |= ATMEL_LCDC_PIXELSIZE_2; break;
                case 4: value |= ATMEL_LCDC_PIXELSIZE_4; break;
                case 8: value |= ATMEL_LCDC_PIXELSIZE_8; break;
-               case 15: /* fall through */
+               case 15:
                case 16: value |= ATMEL_LCDC_PIXELSIZE_16; break;
                case 24: value |= ATMEL_LCDC_PIXELSIZE_24; break;
                case 32: value |= ATMEL_LCDC_PIXELSIZE_32; break;
index 7c4483c..f3d8123 100644 (file)
@@ -1208,11 +1208,11 @@ static void radeon_pm_enable_dll_m10(struct radeonfb_info *rinfo)
        case 1:
                if (mc & 0x4)
                        break;
-               /* fall through */
+               fallthrough;
        case 2:
                dll_sleep_mask |= MDLL_R300_RDCK__MRDCKB_SLEEP;
                dll_reset_mask |= MDLL_R300_RDCK__MRDCKB_RESET;
-               /* fall through */
+               fallthrough;
        case 0:
                dll_sleep_mask |= MDLL_R300_RDCK__MRDCKA_SLEEP;
                dll_reset_mask |= MDLL_R300_RDCK__MRDCKA_RESET;
@@ -1221,7 +1221,7 @@ static void radeon_pm_enable_dll_m10(struct radeonfb_info *rinfo)
        case 1:
                if (!(mc & 0x4))
                        break;
-               /* fall through */
+               fallthrough;
        case 2:
                dll_sleep_mask |= MDLL_R300_RDCK__MRDCKD_SLEEP;
                dll_reset_mask |= MDLL_R300_RDCK__MRDCKD_RESET;
index 3df64a9..15a9ee7 100644 (file)
@@ -1476,11 +1476,11 @@ static void init_vgachip(struct fb_info *info)
                mdelay(100);
                /* mode */
                vga_wgfx(cinfo->regbase, CL_GR31, 0x00);
-               /* fall through */
+               fallthrough;
        case BT_GD5480:
                /* from Klaus' NetBSD driver: */
                vga_wgfx(cinfo->regbase, CL_GR2F, 0x00);
-               /* fall through */
+               fallthrough;
        case BT_ALPINE:
                /* put blitter into 542x compat */
                vga_wgfx(cinfo->regbase, CL_GR33, 0x00);
index 9c4f1be..2df56bd 100644 (file)
@@ -49,6 +49,8 @@
 #include <linux/cuda.h>
 #ifdef CONFIG_PPC_PMAC
 #include <asm/prom.h>
+#endif
+#ifdef CONFIG_BOOTX_TEXT
 #include <asm/btext.h>
 #endif
 
@@ -713,7 +715,7 @@ static int controlfb_blank(int blank_mode, struct fb_info *info)
                        break;
                case FB_BLANK_POWERDOWN:
                        ctrl &= ~0x33;
-                       /* fall through */
+                       fallthrough;
                case FB_BLANK_NORMAL:
                        ctrl |= 0x400;
                        break;
index 8a31fc2..6616783 100644 (file)
@@ -2191,6 +2191,9 @@ static void updatescrollmode(struct fbcon_display *p,
        }
 }
 
+#define PITCH(w) (((w) + 7) >> 3)
+#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */
+
 static int fbcon_resize(struct vc_data *vc, unsigned int width, 
                        unsigned int height, unsigned int user)
 {
@@ -2200,6 +2203,24 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
        struct fb_var_screeninfo var = info->var;
        int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
 
+       if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) {
+               int size;
+               int pitch = PITCH(vc->vc_font.width);
+
+               /*
+                * If user font, ensure that a possible change to user font
+                * height or width will not allow a font data out-of-bounds access.
+                * NOTE: must use original charcount in calculation as font
+                * charcount can change and cannot be used to determine the
+                * font data allocated size.
+                */
+               if (pitch <= 0)
+                       return -EINVAL;
+               size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data));
+               if (size > FNTSIZE(vc->vc_font.data))
+                       return -EINVAL;
+       }
+
        virt_w = FBCON_SWAP(ops->rotate, width, height);
        virt_h = FBCON_SWAP(ops->rotate, height, width);
        virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
@@ -2652,7 +2673,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
        int size;
        int i, csum;
        u8 *new_data, *data = font->data;
-       int pitch = (font->width+7) >> 3;
+       int pitch = PITCH(font->width);
 
        /* Is there a reason why fbconsole couldn't handle any charcount >256?
         * If not this check should be changed to charcount < 256 */
@@ -2668,7 +2689,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
        if (fbcon_invalid_charcount(info, charcount))
                return -EINVAL;
 
-       size = h * pitch * charcount;
+       size = CALC_FONTSZ(h, pitch, charcount);
 
        new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
 
index da7c88f..6815bfb 100644 (file)
@@ -1306,7 +1306,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
        case FBIOGET_CON2FBMAP:
        case FBIOPUT_CON2FBMAP:
                arg = (unsigned long) compat_ptr(arg);
-               /* fall through */
+               fallthrough;
        case FBIOBLANK:
                ret = do_fb_ioctl(info, cmd, arg);
                break;
index 65491ae..e57c008 100644 (file)
@@ -453,7 +453,7 @@ static int efifb_probe(struct platform_device *dev)
        info->apertures->ranges[0].base = efifb_fix.smem_start;
        info->apertures->ranges[0].size = size_remap;
 
-       if (efi_enabled(EFI_BOOT) &&
+       if (efi_enabled(EFI_MEMMAP) &&
            !efi_mem_desc_lookup(efifb_fix.smem_start, &md)) {
                if ((efifb_fix.smem_start + efifb_fix.smem_len) >
                    (md.phys_addr + (md.num_pages << EFI_PAGE_SHIFT))) {
index 67ebfe5..a547c21 100644 (file)
@@ -1287,7 +1287,7 @@ static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
                dev_warn(info->dev,
                         "MFB_SET_PIXFMT value of 0x%08x is deprecated.\n",
                         MFB_SET_PIXFMT_OLD);
-               /* fall through */
+               fallthrough;
        case MFB_SET_PIXFMT:
                if (copy_from_user(&pix_fmt, buf, sizeof(pix_fmt)))
                        return -EFAULT;
@@ -1297,7 +1297,7 @@ static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
                dev_warn(info->dev,
                         "MFB_GET_PIXFMT value of 0x%08x is deprecated.\n",
                         MFB_GET_PIXFMT_OLD);
-               /* fall through */
+               fallthrough;
        case MFB_GET_PIXFMT:
                pix_fmt = ad->pix_fmt;
                if (copy_to_user(buf, &pix_fmt, sizeof(pix_fmt)))
index 13ded3a..e5475ae 100644 (file)
@@ -534,7 +534,7 @@ static int gxt4500_setcolreg(unsigned int reg, unsigned int red,
                        break;
                case DFA_PIX_32BIT:
                        val |= (reg << 24);
-                       /* fall through */
+                       fallthrough;
                case DFA_PIX_24BIT:
                        val |= (reg << 16) | (reg << 8);
                        break;
index e4c3c8b..02411d8 100644 (file)
@@ -648,13 +648,13 @@ static int synthvid_connect_vsp(struct hv_device *hdev)
                ret = synthvid_negotiate_ver(hdev, SYNTHVID_VERSION_WIN10);
                if (!ret)
                        break;
-               /* Fallthrough */
+               fallthrough;
        case VERSION_WIN8:
        case VERSION_WIN8_1:
                ret = synthvid_negotiate_ver(hdev, SYNTHVID_VERSION_WIN8);
                if (!ret)
                        break;
-               /* Fallthrough */
+               fallthrough;
        case VERSION_WS2008:
        case VERSION_WIN7:
                ret = synthvid_negotiate_ver(hdev, SYNTHVID_VERSION_WIN7);
index c65ec73..e6f35f8 100644 (file)
@@ -430,7 +430,7 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var,
                break;
        case 9 ... 15:
                bpp = 15;
-               /* fall through */
+               fallthrough;
        case 16:
                if ((1000000 / var->pixclock) > DACSPEED16) {
                        dev_err(info->device, "requested pixclock %i MHz out of range (max. %i MHz at 15/16bpp)\n",
index 01c75c0..39ebbe0 100644 (file)
@@ -90,8 +90,6 @@ static int var_to_pixfmt(struct fb_var_screeninfo *var)
                        else
                                return PIXFMT_BGR888UNPACK;
                }
-
-               /* fall through */
        }
 
        return -EINVAL;
index 8335da4..9b0a324 100644 (file)
@@ -896,7 +896,7 @@ void NVCalcStateExt(struct nvidia_par *par,
                if (!par->FlatPanel)
                        state->control = NV_RD32(par->PRAMDAC0, 0x0580) &
                                0xeffffeff;
-               /* fallthrough */
+               fallthrough;
        case NV_ARCH_10:
        case NV_ARCH_20:
        case NV_ARCH_30:
index 5cd0f5f..4501e84 100644 (file)
@@ -141,7 +141,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
                /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
                out_le32(par->cmap_adr + 0x58,
                         in_le32(par->cmap_adr + 0x58) & ~0x20);
-               /* fall through */
+               fallthrough;
        case cmap_r128:
                /* Set palette index & data */
                out_8(par->cmap_adr + 0xb0, regno);
@@ -211,7 +211,7 @@ static int offb_blank(int blank, struct fb_info *info)
                                /* Clear PALETTE_ACCESS_CNTL in DAC_CNTL */
                                out_le32(par->cmap_adr + 0x58,
                                         in_le32(par->cmap_adr + 0x58) & ~0x20);
-                               /* fall through */
+                               fallthrough;
                        case cmap_r128:
                                /* Set palette index & data */
                                out_8(par->cmap_adr + 0xb0, i);
index fa73acf..7317c9a 100644 (file)
@@ -328,13 +328,13 @@ static int omap_lcdc_setup_plane(int plane, int channel_out,
                        lcdc.bpp = 12;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        case OMAPFB_COLOR_YUV422:
                if (lcdc.ext_mode) {
                        lcdc.bpp = 16;
                        break;
                }
-               /* fallthrough */
+               fallthrough;
        default:
                /* FIXME: other BPPs.
                 * bpp1: code  0,     size 256
index 0cbcc74..3d090d2 100644 (file)
@@ -253,7 +253,7 @@ static int _setcolreg(struct fb_info *info, u_int regno, u_int red, u_int green,
                if (fbdev->ctrl->setcolreg)
                        r = fbdev->ctrl->setcolreg(regno, red, green, blue,
                                                        transp, update_hw_pal);
-               /* Fallthrough */
+               fallthrough;
        case OMAPFB_COLOR_RGB565:
        case OMAPFB_COLOR_RGB444:
                if (r != 0)
@@ -443,7 +443,7 @@ static int set_color_mode(struct omapfb_plane_struct *plane,
                return 0;
        case 12:
                var->bits_per_pixel = 16;
-               /* fall through */
+               fallthrough;
        case 16:
                if (plane->fbdev->panel->bpp == 12)
                        plane->color_mode = OMAPFB_COLOR_RGB444;
@@ -1531,27 +1531,27 @@ static void omapfb_free_resources(struct omapfb_device *fbdev, int state)
        case OMAPFB_ACTIVE:
                for (i = 0; i < fbdev->mem_desc.region_cnt; i++)
                        unregister_framebuffer(fbdev->fb_info[i]);
-               /* fall through */
+               fallthrough;
        case 7:
                omapfb_unregister_sysfs(fbdev);
-               /* fall through */
+               fallthrough;
        case 6:
                if (fbdev->panel->disable)
                        fbdev->panel->disable(fbdev->panel);
-               /* fall through */
+               fallthrough;
        case 5:
                omapfb_set_update_mode(fbdev, OMAPFB_UPDATE_DISABLED);
-               /* fall through */
+               fallthrough;
        case 4:
                planes_cleanup(fbdev);
-               /* fall through */
+               fallthrough;
        case 3:
                ctrl_cleanup(fbdev);
-               /* fall through */
+               fallthrough;
        case 2:
                if (fbdev->panel->cleanup)
                        fbdev->panel->cleanup(fbdev->panel);
-               /* fall through */
+               fallthrough;
        case 1:
                dev_set_drvdata(fbdev->dev, NULL);
                kfree(fbdev);
@@ -1854,7 +1854,7 @@ static int __init omapfb_setup(char *options)
                        case 'm':
                        case 'M':
                                vram *= 1024;
-                               /* Fall through */
+                               fallthrough;
                        case 'k':
                        case 'K':
                                vram *= 1024;
index 3920a0d..b2d6e6d 100644 (file)
@@ -1861,7 +1861,7 @@ static void calc_vrfb_rotation_offset(u8 rotation, bool mirror,
                if (color_mode == OMAP_DSS_COLOR_YUV2 ||
                        color_mode == OMAP_DSS_COLOR_UYVY)
                        width = width >> 1;
-               /* fall through */
+               fallthrough;
        case OMAP_DSS_ROT_90:
        case OMAP_DSS_ROT_270:
                *offset1 = 0;
@@ -1884,7 +1884,7 @@ static void calc_vrfb_rotation_offset(u8 rotation, bool mirror,
                if (color_mode == OMAP_DSS_COLOR_YUV2 ||
                        color_mode == OMAP_DSS_COLOR_UYVY)
                        width = width >> 1;
-               /* fall through */
+               fallthrough;
        case OMAP_DSS_ROT_90 + 4:
        case OMAP_DSS_ROT_270 + 4:
                *offset1 = 0;
index f40be68..ea8c88a 100644 (file)
@@ -760,7 +760,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
                        r = -ENODEV;
                        break;
                }
-               /* FALLTHROUGH */
+               fallthrough;
 
        case OMAPFB_WAITFORVSYNC:
                DBG("ioctl WAITFORVSYNC\n");
index 836e7b1..a3decc7 100644 (file)
@@ -882,7 +882,7 @@ int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
                                / (var->bits_per_pixel >> 2);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                screen_width = fix->line_length / (var->bits_per_pixel >> 3);
                break;
index c7c98d8..0642555 100644 (file)
@@ -233,10 +233,10 @@ static u32 to3264(u32 timing, int bpp, int is64)
        switch (bpp) {
        case 24:
                timing *= 3;
-               /* fall through */
+               fallthrough;
        case 8:
                timing >>= 1;
-               /* fall through */
+               fallthrough;
        case 16:
                timing >>= 1;
        case 32:
index eedfbd3..47e6a1d 100644 (file)
@@ -60,8 +60,6 @@ static int determine_best_pix_fmt(struct fb_var_screeninfo *var)
                        else
                                return PIX_FMT_BGR1555;
                }
-
-               /* fall through */
        }
 
        /*
@@ -87,8 +85,6 @@ static int determine_best_pix_fmt(struct fb_var_screeninfo *var)
                        else
                                return PIX_FMT_BGR888UNPACK;
                }
-
-               /* fall through */
        }
 
        return -EINVAL;
index a53d24f..f1551e0 100644 (file)
@@ -1614,7 +1614,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
                 */
                if (old_state != C_DISABLE_PM)
                        break;
-               /* fall through */
+               fallthrough;
 
        case C_ENABLE:
                /*
index 9b34938..ce55b9d 100644 (file)
@@ -1093,7 +1093,7 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                break;
        case 9 ... 15:
                var->green.length = 5;
-               /* fall through */
+               fallthrough;
        case 16:
                var->bits_per_pixel = 16;
                /* The Riva128 supports RGB555 only */
index 9dc9250..ba316bd 100644 (file)
@@ -284,7 +284,7 @@ static int s3c_fb_check_var(struct fb_var_screeninfo *var,
                /* 666 with one bit alpha/transparency */
                var->transp.offset      = 18;
                var->transp.length      = 1;
-               /* fall through */
+               fallthrough;
        case 18:
                var->bits_per_pixel     = 32;
 
@@ -312,7 +312,7 @@ static int s3c_fb_check_var(struct fb_var_screeninfo *var,
        case 25:
                var->transp.length      = var->bits_per_pixel - 24;
                var->transp.offset      = 24;
-               /* fall through */
+               fallthrough;
        case 24:
                /* our 24bpp is unpacked, so 32bpp */
                var->bits_per_pixel     = 32;
@@ -809,7 +809,7 @@ static int s3c_fb_blank(int blank_mode, struct fb_info *info)
        case FB_BLANK_POWERDOWN:
                wincon &= ~WINCONx_ENWIN;
                sfb->enabled &= ~(1 << index);
-               /* fall through - to FB_BLANK_NORMAL */
+               fallthrough;    /* to FB_BLANK_NORMAL */
 
        case FB_BLANK_NORMAL:
                /* disable the DMA and display 0x0 (black) */
index bda6cc3..e31cf63 100644 (file)
@@ -935,7 +935,7 @@ static void set_ctrlr_state(struct sa1100fb_info *fbi, u_int state)
                 */
                if (old_state != C_DISABLE_PM)
                        break;
-               /* fall through */
+               fallthrough;
 
        case C_ENABLE:
                /*
index 3fd87ae..a2442aa 100644 (file)
@@ -1860,7 +1860,7 @@ static int savage_init_hw(struct savagefb_par *par)
                if ((vga_in8(0x3d5, par) & 0xC0) == (0x01 << 6))
                        RamSavage4[1] = 8;
 
-               /*FALLTHROUGH*/
+               fallthrough;
 
        case S3_SAVAGE2000:
                videoRam = RamSavage4[(config1 & 0xE0) >> 5] * 1024;
index 8a27d12..c104342 100644 (file)
@@ -1594,7 +1594,7 @@ sh_mobile_lcdc_overlay_fb_init(struct sh_mobile_lcdc_overlay *ovl)
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
                info->fix.ypanstep = 2;
-               /* Fall through */
+               fallthrough;
        case V4L2_PIX_FMT_NV16:
        case V4L2_PIX_FMT_NV61:
                info->fix.xpanstep = 2;
@@ -2085,7 +2085,7 @@ sh_mobile_lcdc_channel_fb_init(struct sh_mobile_lcdc_chan *ch,
        case V4L2_PIX_FMT_NV12:
        case V4L2_PIX_FMT_NV21:
                info->fix.ypanstep = 2;
-               /* Fall through */
+               fallthrough;
        case V4L2_PIX_FMT_NV16:
        case V4L2_PIX_FMT_NV61:
                info->fix.xpanstep = 2;
index ac14096..03c736f 100644 (file)
@@ -1739,7 +1739,7 @@ static int        sisfb_ioctl(struct fb_info *info, unsigned int cmd,
                if(ivideo->warncount++ < 10)
                        printk(KERN_INFO
                                "sisfb: Deprecated ioctl call received - update your application!\n");
-               /* fall through */
+               fallthrough;
           case SISFB_GET_INFO:  /* For communication with X driver */
                ivideo->sisfb_infoblock.sisfb_id         = SISFB_ID;
                ivideo->sisfb_infoblock.sisfb_version    = VER_MAJOR;
@@ -1793,7 +1793,7 @@ static int        sisfb_ioctl(struct fb_info *info, unsigned int cmd,
                if(ivideo->warncount++ < 10)
                        printk(KERN_INFO
                                "sisfb: Deprecated ioctl call received - update your application!\n");
-               /* fall through */
+               fallthrough;
           case SISFB_GET_VBRSTATUS:
                if(sisfb_CheckVBRetrace(ivideo))
                        return put_user((u32)1, argp);
@@ -1804,7 +1804,7 @@ static int        sisfb_ioctl(struct fb_info *info, unsigned int cmd,
                if(ivideo->warncount++ < 10)
                        printk(KERN_INFO
                                "sisfb: Deprecated ioctl call received - update your application!\n");
-               /* fall through */
+               fallthrough;
           case SISFB_GET_AUTOMAXIMIZE:
                if(ivideo->sisfb_max)
                        return put_user((u32)1, argp);
@@ -1815,7 +1815,7 @@ static int        sisfb_ioctl(struct fb_info *info, unsigned int cmd,
                if(ivideo->warncount++ < 10)
                        printk(KERN_INFO
                                "sisfb: Deprecated ioctl call received - update your application!\n");
-               /* fall through */
+               fallthrough;
           case SISFB_SET_AUTOMAXIMIZE:
                if(get_user(gpu32, argp))
                        return -EFAULT;
index 3dd1b1d..6a52eba 100644 (file)
@@ -1005,7 +1005,7 @@ static int sm501fb_blank_crt(int blank_mode, struct fb_info *info)
        case FB_BLANK_POWERDOWN:
                ctrl &= ~SM501_DC_CRT_CONTROL_ENABLE;
                sm501_misc_control(fbi->dev->parent, SM501_MISC_DAC_POWER, 0);
-               /* fall through */
+               fallthrough;
 
        case FB_BLANK_NORMAL:
                ctrl |= SM501_DC_CRT_CONTROL_BLANK;
index de953dd..2658656 100644 (file)
@@ -999,7 +999,7 @@ stifb_blank(int blank_mode, struct fb_info *info)
        case S9000_ID_HCRX:
                HYPER_ENABLE_DISABLE_DISPLAY(fb, enable);
                break;
-       case S9000_ID_A1659A:   /* fall through */
+       case S9000_ID_A1659A:
        case S9000_ID_TIMBER:
        case CRX24_OVERLAY_PLANES:
        default:
@@ -1157,7 +1157,7 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
                        dev_name);
                   goto out_err0;
                }
-               /* fall through */
+               fallthrough;
        case S9000_ID_ARTIST:
        case S9000_ID_HCRX:
        case S9000_ID_TIMBER:
index f73e26c..f056d80 100644 (file)
@@ -523,7 +523,7 @@ static int tdfxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
        case 32:
                var->transp.offset = 24;
                var->transp.length = 8;
-               /* fall through */
+               fallthrough;
        case 24:
                var->red.offset = 16;
                var->green.offset = 8;
index a20eeb8..578d354 100644 (file)
@@ -1121,7 +1121,7 @@ static void vga_8planes_imageblit(struct fb_info *info, const struct fb_image *i
         char oldop = setop(0);
         char oldsr = setsr(0);
         char oldmask = selectmask();
-        const char *cdat = image->data;
+       const unsigned char *cdat = image->data;
        u32 dx = image->dx;
         char __iomem *where;
         int y;
index 3fea01d..4a86940 100644 (file)
@@ -744,7 +744,7 @@ static void set_lcd_output_path(int set_iga, int output_interface)
                    viaparinfo->chip_info->gfx_chip_name))
                        viafb_write_reg_mask(CR97, VIACR, 0x84,
                                       BIT7 + BIT2 + BIT1 + BIT0);
-               /* fall through */
+               fallthrough;
        case INTERFACE_DVP0:
        case INTERFACE_DVP1:
        case INTERFACE_DFP_HIGH:
index 00307b8..5ec5144 100644 (file)
@@ -677,7 +677,7 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* fall through - Missed the backend's CLOSING state. */
+               fallthrough;    /* Missed the backend's CLOSING state */
        case XenbusStateClosing:
                xenbus_frontend_closed(dev);
                break;
index cbc1f25..80c5f9c 100644 (file)
@@ -32,4 +32,6 @@ config FSL_HV_MANAGER
             partition shuts down.
 
 source "drivers/virt/vboxguest/Kconfig"
+
+source "drivers/virt/nitro_enclaves/Kconfig"
 endif
index fd33124..f28425c 100644 (file)
@@ -5,3 +5,5 @@
 
 obj-$(CONFIG_FSL_HV_MANAGER)   += fsl_hypervisor.o
 obj-y                          += vboxguest/
+
+obj-$(CONFIG_NITRO_ENCLAVES)   += nitro_enclaves/
index 1b0b11b..46ee0a0 100644 (file)
@@ -157,7 +157,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
 
        unsigned int i;
        long ret = 0;
-       int num_pinned; /* return value from get_user_pages() */
+       int num_pinned = 0; /* return value from get_user_pages_fast() */
        phys_addr_t remote_paddr; /* The next address in the remote buffer */
        uint32_t count; /* The number of bytes left to copy */
 
@@ -174,7 +174,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
                return -EINVAL;
 
        /*
-        * The array of pages returned by get_user_pages() covers only
+        * The array of pages returned by get_user_pages_fast() covers only
         * page-aligned memory.  Since the user buffer is probably not
         * page-aligned, we need to handle the discrepancy.
         *
@@ -224,7 +224,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
 
        /*
         * 'pages' is an array of struct page pointers that's initialized by
-        * get_user_pages().
+        * get_user_pages_fast().
         */
        pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
        if (!pages) {
@@ -241,7 +241,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
        if (!sg_list_unaligned) {
                pr_debug("fsl-hv: could not allocate S/G list\n");
                ret = -ENOMEM;
-               goto exit;
+               goto free_pages;
        }
        sg_list = PTR_ALIGN(sg_list_unaligned, sizeof(struct fh_sg_list));
 
@@ -250,7 +250,6 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
                num_pages, param.source != -1 ? FOLL_WRITE : 0, pages);
 
        if (num_pinned != num_pages) {
-               /* get_user_pages() failed */
                pr_debug("fsl-hv: could not lock source buffer\n");
                ret = (num_pinned < 0) ? num_pinned : -EFAULT;
                goto exit;
@@ -292,13 +291,13 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
                virt_to_phys(sg_list), num_pages);
 
 exit:
-       if (pages) {
-               for (i = 0; i < num_pages; i++)
-                       if (pages[i])
-                               put_page(pages[i]);
+       if (pages && (num_pinned > 0)) {
+               for (i = 0; i < num_pinned; i++)
+                       put_page(pages[i]);
        }
 
        kfree(sg_list_unaligned);
+free_pages:
        kfree(pages);
 
        if (!ret)
diff --git a/drivers/virt/nitro_enclaves/Kconfig b/drivers/virt/nitro_enclaves/Kconfig
new file mode 100644 (file)
index 0000000..8c9387a
--- /dev/null
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+# Amazon Nitro Enclaves (NE) support.
+# Nitro is a hypervisor that has been developed by Amazon.
+
+# TODO: Add dependency for ARM64 once NE is supported on Arm platforms. For now,
+# the NE kernel driver can be built for aarch64 arch.
+# depends on (ARM64 || X86) && HOTPLUG_CPU && PCI && SMP
+
+config NITRO_ENCLAVES
+       tristate "Nitro Enclaves Support"
+       depends on X86 && HOTPLUG_CPU && PCI && SMP
+       help
+         This driver consists of support for enclave lifetime management
+         for Nitro Enclaves (NE).
+
+         To compile this driver as a module, choose M here.
+         The module will be called nitro_enclaves.
diff --git a/drivers/virt/nitro_enclaves/Makefile b/drivers/virt/nitro_enclaves/Makefile
new file mode 100644 (file)
index 0000000..da61260
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+# Enclave lifetime management support for Nitro Enclaves (NE).
+
+obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves.o
+
+nitro_enclaves-y := ne_pci_dev.o ne_misc_dev.o
diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
new file mode 100644 (file)
index 0000000..f06622b
--- /dev/null
@@ -0,0 +1,1733 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+/**
+ * DOC: Enclave lifetime management driver for Nitro Enclaves (NE).
+ * Nitro is a hypervisor that has been developed by Amazon.
+ */
+
+#include <linux/anon_inodes.h>
+#include <linux/capability.h>
+#include <linux/cpu.h>
+#include <linux/device.h>
+#include <linux/file.h>
+#include <linux/hugetlb.h>
+#include <linux/limits.h>
+#include <linux/list.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/mman.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nitro_enclaves.h>
+#include <linux/pci.h>
+#include <linux/poll.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <uapi/linux/vm_sockets.h>
+
+#include "ne_misc_dev.h"
+#include "ne_pci_dev.h"
+
+/**
+ * NE_CPUS_SIZE - Size for max 128 CPUs, for now, in a cpu-list string, comma
+ *               separated. The NE CPU pool includes CPUs from a single NUMA
+ *               node.
+ */
+#define NE_CPUS_SIZE           (512)
+
+/**
+ * NE_EIF_LOAD_OFFSET - The offset where to copy the Enclave Image Format (EIF)
+ *                     image in enclave memory.
+ */
+#define NE_EIF_LOAD_OFFSET     (8 * 1024UL * 1024UL)
+
+/**
+ * NE_MIN_ENCLAVE_MEM_SIZE - The minimum memory size an enclave can be launched
+ *                          with.
+ */
+#define NE_MIN_ENCLAVE_MEM_SIZE        (64 * 1024UL * 1024UL)
+
+/**
+ * NE_MIN_MEM_REGION_SIZE - The minimum size of an enclave memory region.
+ */
+#define NE_MIN_MEM_REGION_SIZE (2 * 1024UL * 1024UL)
+
+/**
+ * NE_PARENT_VM_CID - The CID for the vsock device of the primary / parent VM.
+ */
+#define NE_PARENT_VM_CID       (3)
+
+static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+
+static const struct file_operations ne_fops = {
+       .owner          = THIS_MODULE,
+       .llseek         = noop_llseek,
+       .unlocked_ioctl = ne_ioctl,
+};
+
+static struct miscdevice ne_misc_dev = {
+       .minor  = MISC_DYNAMIC_MINOR,
+       .name   = "nitro_enclaves",
+       .fops   = &ne_fops,
+       .mode   = 0660,
+};
+
+struct ne_devs ne_devs = {
+       .ne_misc_dev    = &ne_misc_dev,
+};
+
+/*
+ * TODO: Update logic to create new sysfs entries instead of using
+ * a kernel parameter e.g. if multiple sysfs files needed.
+ */
+static int ne_set_kernel_param(const char *val, const struct kernel_param *kp);
+
+static const struct kernel_param_ops ne_cpu_pool_ops = {
+       .get    = param_get_string,
+       .set    = ne_set_kernel_param,
+};
+
+static char ne_cpus[NE_CPUS_SIZE];
+static struct kparam_string ne_cpus_arg = {
+       .maxlen = sizeof(ne_cpus),
+       .string = ne_cpus,
+};
+
+module_param_cb(ne_cpus, &ne_cpu_pool_ops, &ne_cpus_arg, 0644);
+/* https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html#cpu-lists */
+MODULE_PARM_DESC(ne_cpus, "<cpu-list> - CPU pool used for Nitro Enclaves");
+
+/**
+ * struct ne_cpu_pool - CPU pool used for Nitro Enclaves.
+ * @avail_threads_per_core:    Available full CPU cores to be dedicated to
+ *                             enclave(s). The cpumasks from the array, indexed
+ *                             by core id, contain all the threads from the
+ *                             available cores, that are not set for created
+ *                             enclave(s). The full CPU cores are part of the
+ *                             NE CPU pool.
+ * @mutex:                     Mutex for the access to the NE CPU pool.
+ * @nr_parent_vm_cores :       The size of the available threads per core array.
+ *                             The total number of CPU cores available on the
+ *                             primary / parent VM.
+ * @nr_threads_per_core:       The number of threads that a full CPU core has.
+ * @numa_node:                 NUMA node of the CPUs in the pool.
+ */
+struct ne_cpu_pool {
+       cpumask_var_t   *avail_threads_per_core;
+       struct mutex    mutex;
+       unsigned int    nr_parent_vm_cores;
+       unsigned int    nr_threads_per_core;
+       int             numa_node;
+};
+
+static struct ne_cpu_pool ne_cpu_pool;
+
+/**
+ * ne_check_enclaves_created() - Verify if at least one enclave has been created.
+ * @void:      No parameters provided.
+ *
+ * Context: Process context.
+ * Return:
+ * * True if at least one enclave is created.
+ * * False otherwise.
+ */
+static bool ne_check_enclaves_created(void)
+{
+       struct ne_pci_dev *ne_pci_dev = ne_devs.ne_pci_dev;
+       bool ret = false;
+
+       if (!ne_pci_dev)
+               return ret;
+
+       mutex_lock(&ne_pci_dev->enclaves_list_mutex);
+
+       if (!list_empty(&ne_pci_dev->enclaves_list))
+               ret = true;
+
+       mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+
+       return ret;
+}
+
+/**
+ * ne_setup_cpu_pool() - Set the NE CPU pool after handling sanity checks such
+ *                      as not sharing CPU cores with the primary / parent VM
+ *                      or not using CPU 0, which should remain available for
+ *                      the primary / parent VM. Offline the CPUs from the
+ *                      pool after the checks passed.
+ * @ne_cpu_list:       The CPU list used for setting NE CPU pool.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_setup_cpu_pool(const char *ne_cpu_list)
+{
+       int core_id = -1;
+       unsigned int cpu = 0;
+       cpumask_var_t cpu_pool;
+       unsigned int cpu_sibling = 0;
+       unsigned int i = 0;
+       int numa_node = -1;
+       int rc = -EINVAL;
+
+       if (!zalloc_cpumask_var(&cpu_pool, GFP_KERNEL))
+               return -ENOMEM;
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       rc = cpulist_parse(ne_cpu_list, cpu_pool);
+       if (rc < 0) {
+               pr_err("%s: Error in cpulist parse [rc=%d]\n", ne_misc_dev.name, rc);
+
+               goto free_pool_cpumask;
+       }
+
+       cpu = cpumask_any(cpu_pool);
+       if (cpu >= nr_cpu_ids) {
+               pr_err("%s: No CPUs available in CPU pool\n", ne_misc_dev.name);
+
+               rc = -EINVAL;
+
+               goto free_pool_cpumask;
+       }
+
+       /*
+        * Check if the CPUs are online, to further get info about them
+        * e.g. numa node, core id, siblings.
+        */
+       for_each_cpu(cpu, cpu_pool)
+               if (cpu_is_offline(cpu)) {
+                       pr_err("%s: CPU %d is offline, has to be online to get its metadata\n",
+                              ne_misc_dev.name, cpu);
+
+                       rc = -EINVAL;
+
+                       goto free_pool_cpumask;
+               }
+
+       /*
+        * Check if the CPUs from the NE CPU pool are from the same NUMA node.
+        */
+       for_each_cpu(cpu, cpu_pool)
+               if (numa_node < 0) {
+                       numa_node = cpu_to_node(cpu);
+                       if (numa_node < 0) {
+                               pr_err("%s: Invalid NUMA node %d\n",
+                                      ne_misc_dev.name, numa_node);
+
+                               rc = -EINVAL;
+
+                               goto free_pool_cpumask;
+                       }
+               } else {
+                       if (numa_node != cpu_to_node(cpu)) {
+                               pr_err("%s: CPUs with different NUMA nodes\n",
+                                      ne_misc_dev.name);
+
+                               rc = -EINVAL;
+
+                               goto free_pool_cpumask;
+                       }
+               }
+
+       /*
+        * Check if CPU 0 and its siblings are included in the provided CPU pool
+        * They should remain available for the primary / parent VM.
+        */
+       if (cpumask_test_cpu(0, cpu_pool)) {
+               pr_err("%s: CPU 0 has to remain available\n", ne_misc_dev.name);
+
+               rc = -EINVAL;
+
+               goto free_pool_cpumask;
+       }
+
+       for_each_cpu(cpu_sibling, topology_sibling_cpumask(0)) {
+               if (cpumask_test_cpu(cpu_sibling, cpu_pool)) {
+                       pr_err("%s: CPU sibling %d for CPU 0 is in CPU pool\n",
+                              ne_misc_dev.name, cpu_sibling);
+
+                       rc = -EINVAL;
+
+                       goto free_pool_cpumask;
+               }
+       }
+
+       /*
+        * Check if CPU siblings are included in the provided CPU pool. The
+        * expectation is that full CPU cores are made available in the CPU pool
+        * for enclaves.
+        */
+       for_each_cpu(cpu, cpu_pool) {
+               for_each_cpu(cpu_sibling, topology_sibling_cpumask(cpu)) {
+                       if (!cpumask_test_cpu(cpu_sibling, cpu_pool)) {
+                               pr_err("%s: CPU %d is not in CPU pool\n",
+                                      ne_misc_dev.name, cpu_sibling);
+
+                               rc = -EINVAL;
+
+                               goto free_pool_cpumask;
+                       }
+               }
+       }
+
+       /* Calculate the number of threads from a full CPU core. */
+       cpu = cpumask_any(cpu_pool);
+       for_each_cpu(cpu_sibling, topology_sibling_cpumask(cpu))
+               ne_cpu_pool.nr_threads_per_core++;
+
+       ne_cpu_pool.nr_parent_vm_cores = nr_cpu_ids / ne_cpu_pool.nr_threads_per_core;
+
+       ne_cpu_pool.avail_threads_per_core = kcalloc(ne_cpu_pool.nr_parent_vm_cores,
+                                            sizeof(*ne_cpu_pool.avail_threads_per_core),
+                                            GFP_KERNEL);
+       if (!ne_cpu_pool.avail_threads_per_core) {
+               rc = -ENOMEM;
+
+               goto free_pool_cpumask;
+       }
+
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               if (!zalloc_cpumask_var(&ne_cpu_pool.avail_threads_per_core[i], GFP_KERNEL)) {
+                       rc = -ENOMEM;
+
+                       goto free_cores_cpumask;
+               }
+
+       /*
+        * Split the NE CPU pool in threads per core to keep the CPU topology
+        * after offlining the CPUs.
+        */
+       for_each_cpu(cpu, cpu_pool) {
+               core_id = topology_core_id(cpu);
+               if (core_id < 0 || core_id >= ne_cpu_pool.nr_parent_vm_cores) {
+                       pr_err("%s: Invalid core id  %d for CPU %d\n",
+                              ne_misc_dev.name, core_id, cpu);
+
+                       rc = -EINVAL;
+
+                       goto clear_cpumask;
+               }
+
+               cpumask_set_cpu(cpu, ne_cpu_pool.avail_threads_per_core[core_id]);
+       }
+
+       /*
+        * CPUs that are given to enclave(s) should not be considered online
+        * by Linux anymore, as the hypervisor will degrade them to floating.
+        * The physical CPUs (full cores) are carved out of the primary / parent
+        * VM and given to the enclave VM. The same number of vCPUs would run
+        * on less pCPUs for the primary / parent VM.
+        *
+        * We offline them here, to not degrade performance and expose correct
+        * topology to Linux and user space.
+        */
+       for_each_cpu(cpu, cpu_pool) {
+               rc = remove_cpu(cpu);
+               if (rc != 0) {
+                       pr_err("%s: CPU %d is not offlined [rc=%d]\n",
+                              ne_misc_dev.name, cpu, rc);
+
+                       goto online_cpus;
+               }
+       }
+
+       free_cpumask_var(cpu_pool);
+
+       ne_cpu_pool.numa_node = numa_node;
+
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       return 0;
+
+online_cpus:
+       for_each_cpu(cpu, cpu_pool)
+               add_cpu(cpu);
+clear_cpumask:
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               cpumask_clear(ne_cpu_pool.avail_threads_per_core[i]);
+free_cores_cpumask:
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               free_cpumask_var(ne_cpu_pool.avail_threads_per_core[i]);
+       kfree(ne_cpu_pool.avail_threads_per_core);
+free_pool_cpumask:
+       free_cpumask_var(cpu_pool);
+       ne_cpu_pool.nr_parent_vm_cores = 0;
+       ne_cpu_pool.nr_threads_per_core = 0;
+       ne_cpu_pool.numa_node = -1;
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       return rc;
+}
+
+/**
+ * ne_teardown_cpu_pool() - Online the CPUs from the NE CPU pool and cleanup the
+ *                         CPU pool.
+ * @void:      No parameters provided.
+ *
+ * Context: Process context.
+ */
+static void ne_teardown_cpu_pool(void)
+{
+       unsigned int cpu = 0;
+       unsigned int i = 0;
+       int rc = -EINVAL;
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       if (!ne_cpu_pool.nr_parent_vm_cores) {
+               mutex_unlock(&ne_cpu_pool.mutex);
+
+               return;
+       }
+
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++) {
+               for_each_cpu(cpu, ne_cpu_pool.avail_threads_per_core[i]) {
+                       rc = add_cpu(cpu);
+                       if (rc != 0)
+                               pr_err("%s: CPU %d is not onlined [rc=%d]\n",
+                                      ne_misc_dev.name, cpu, rc);
+               }
+
+               cpumask_clear(ne_cpu_pool.avail_threads_per_core[i]);
+
+               free_cpumask_var(ne_cpu_pool.avail_threads_per_core[i]);
+       }
+
+       kfree(ne_cpu_pool.avail_threads_per_core);
+       ne_cpu_pool.nr_parent_vm_cores = 0;
+       ne_cpu_pool.nr_threads_per_core = 0;
+       ne_cpu_pool.numa_node = -1;
+
+       mutex_unlock(&ne_cpu_pool.mutex);
+}
+
+/**
+ * ne_set_kernel_param() - Set the NE CPU pool value via the NE kernel parameter.
+ * @val:       NE CPU pool string value.
+ * @kp :       NE kernel parameter associated with the NE CPU pool.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_set_kernel_param(const char *val, const struct kernel_param *kp)
+{
+       char error_val[] = "";
+       int rc = -EINVAL;
+
+       if (!capable(CAP_SYS_ADMIN))
+               return -EPERM;
+
+       if (ne_check_enclaves_created()) {
+               pr_err("%s: The CPU pool is used by enclave(s)\n", ne_misc_dev.name);
+
+               return -EPERM;
+       }
+
+       ne_teardown_cpu_pool();
+
+       rc = ne_setup_cpu_pool(val);
+       if (rc < 0) {
+               pr_err("%s: Error in setup CPU pool [rc=%d]\n", ne_misc_dev.name, rc);
+
+               param_set_copystring(error_val, kp);
+
+               return rc;
+       }
+
+       rc = param_set_copystring(val, kp);
+       if (rc < 0) {
+               pr_err("%s: Error in param set copystring [rc=%d]\n", ne_misc_dev.name, rc);
+
+               ne_teardown_cpu_pool();
+
+               param_set_copystring(error_val, kp);
+
+               return rc;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_donated_cpu() - Check if the provided CPU is already used by the enclave.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @cpu:               CPU to check if already used.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * True if the provided CPU is already used by the enclave.
+ * * False otherwise.
+ */
+static bool ne_donated_cpu(struct ne_enclave *ne_enclave, unsigned int cpu)
+{
+       if (cpumask_test_cpu(cpu, ne_enclave->vcpu_ids))
+               return true;
+
+       return false;
+}
+
+/**
+ * ne_get_unused_core_from_cpu_pool() - Get the id of a full core from the
+ *                                     NE CPU pool.
+ * @void:      No parameters provided.
+ *
+ * Context: Process context. This function is called with the ne_enclave and
+ *         ne_cpu_pool mutexes held.
+ * Return:
+ * * Core id.
+ * * -1 if no CPU core available in the pool.
+ */
+static int ne_get_unused_core_from_cpu_pool(void)
+{
+       int core_id = -1;
+       unsigned int i = 0;
+
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               if (!cpumask_empty(ne_cpu_pool.avail_threads_per_core[i])) {
+                       core_id = i;
+
+                       break;
+               }
+
+       return core_id;
+}
+
+/**
+ * ne_set_enclave_threads_per_core() - Set the threads of the provided core in
+ *                                    the enclave data structure.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @core_id:           Core id to get its threads from the NE CPU pool.
+ * @vcpu_id:           vCPU id part of the provided core.
+ *
+ * Context: Process context. This function is called with the ne_enclave and
+ *         ne_cpu_pool mutexes held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_set_enclave_threads_per_core(struct ne_enclave *ne_enclave,
+                                          int core_id, u32 vcpu_id)
+{
+       unsigned int cpu = 0;
+
+       if (core_id < 0 && vcpu_id == 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "No CPUs available in NE CPU pool\n");
+
+               return -NE_ERR_NO_CPUS_AVAIL_IN_POOL;
+       }
+
+       if (core_id < 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "CPU %d is not in NE CPU pool\n", vcpu_id);
+
+               return -NE_ERR_VCPU_NOT_IN_CPU_POOL;
+       }
+
+       if (core_id >= ne_enclave->nr_parent_vm_cores) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Invalid core id %d - ne_enclave\n", core_id);
+
+               return -NE_ERR_VCPU_INVALID_CPU_CORE;
+       }
+
+       for_each_cpu(cpu, ne_cpu_pool.avail_threads_per_core[core_id])
+               cpumask_set_cpu(cpu, ne_enclave->threads_per_core[core_id]);
+
+       cpumask_clear(ne_cpu_pool.avail_threads_per_core[core_id]);
+
+       return 0;
+}
+
+/**
+ * ne_get_cpu_from_cpu_pool() - Get a CPU from the NE CPU pool, either from the
+ *                             remaining sibling(s) of a CPU core or the first
+ *                             sibling of a new CPU core.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @vcpu_id:           vCPU to get from the NE CPU pool.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_get_cpu_from_cpu_pool(struct ne_enclave *ne_enclave, u32 *vcpu_id)
+{
+       int core_id = -1;
+       unsigned int cpu = 0;
+       unsigned int i = 0;
+       int rc = -EINVAL;
+
+       /*
+        * If previously allocated a thread of a core to this enclave, first
+        * check remaining sibling(s) for new CPU allocations, so that full
+        * CPU cores are used for the enclave.
+        */
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++)
+               for_each_cpu(cpu, ne_enclave->threads_per_core[i])
+                       if (!ne_donated_cpu(ne_enclave, cpu)) {
+                               *vcpu_id = cpu;
+
+                               return 0;
+                       }
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       /*
+        * If no remaining siblings, get a core from the NE CPU pool and keep
+        * track of all the threads in the enclave threads per core data structure.
+        */
+       core_id = ne_get_unused_core_from_cpu_pool();
+
+       rc = ne_set_enclave_threads_per_core(ne_enclave, core_id, *vcpu_id);
+       if (rc < 0)
+               goto unlock_mutex;
+
+       *vcpu_id = cpumask_any(ne_enclave->threads_per_core[core_id]);
+
+       rc = 0;
+
+unlock_mutex:
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       return rc;
+}
+
+/**
+ * ne_get_vcpu_core_from_cpu_pool() - Get from the NE CPU pool the id of the
+ *                                   core associated with the provided vCPU.
+ * @vcpu_id:   Provided vCPU id to get its associated core id.
+ *
+ * Context: Process context. This function is called with the ne_enclave and
+ *         ne_cpu_pool mutexes held.
+ * Return:
+ * * Core id.
+ * * -1 if the provided vCPU is not in the pool.
+ */
+static int ne_get_vcpu_core_from_cpu_pool(u32 vcpu_id)
+{
+       int core_id = -1;
+       unsigned int i = 0;
+
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               if (cpumask_test_cpu(vcpu_id, ne_cpu_pool.avail_threads_per_core[i])) {
+                       core_id = i;
+
+                       break;
+       }
+
+       return core_id;
+}
+
+/**
+ * ne_check_cpu_in_cpu_pool() - Check if the given vCPU is in the available CPUs
+ *                             from the pool.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @vcpu_id:           ID of the vCPU to check if available in the NE CPU pool.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_check_cpu_in_cpu_pool(struct ne_enclave *ne_enclave, u32 vcpu_id)
+{
+       int core_id = -1;
+       unsigned int i = 0;
+       int rc = -EINVAL;
+
+       if (ne_donated_cpu(ne_enclave, vcpu_id)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "CPU %d already used\n", vcpu_id);
+
+               return -NE_ERR_VCPU_ALREADY_USED;
+       }
+
+       /*
+        * If previously allocated a thread of a core to this enclave, but not
+        * the full core, first check remaining sibling(s).
+        */
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++)
+               if (cpumask_test_cpu(vcpu_id, ne_enclave->threads_per_core[i]))
+                       return 0;
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       /*
+        * If no remaining siblings, get from the NE CPU pool the core
+        * associated with the vCPU and keep track of all the threads in the
+        * enclave threads per core data structure.
+        */
+       core_id = ne_get_vcpu_core_from_cpu_pool(vcpu_id);
+
+       rc = ne_set_enclave_threads_per_core(ne_enclave, core_id, vcpu_id);
+       if (rc < 0)
+               goto unlock_mutex;
+
+       rc = 0;
+
+unlock_mutex:
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       return rc;
+}
+
+/**
+ * ne_add_vcpu_ioctl() - Add a vCPU to the slot associated with the current
+ *                      enclave.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @vcpu_id:           ID of the CPU to be associated with the given slot,
+ *                     apic id on x86.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_add_vcpu_ioctl(struct ne_enclave *ne_enclave, u32 vcpu_id)
+{
+       struct ne_pci_dev_cmd_reply cmd_reply = {};
+       struct pci_dev *pdev = ne_devs.ne_pci_dev->pdev;
+       int rc = -EINVAL;
+       struct slot_add_vcpu_req slot_add_vcpu_req = {};
+
+       if (ne_enclave->mm != current->mm)
+               return -EIO;
+
+       slot_add_vcpu_req.slot_uid = ne_enclave->slot_uid;
+       slot_add_vcpu_req.vcpu_id = vcpu_id;
+
+       rc = ne_do_request(pdev, SLOT_ADD_VCPU,
+                          &slot_add_vcpu_req, sizeof(slot_add_vcpu_req),
+                          &cmd_reply, sizeof(cmd_reply));
+       if (rc < 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in slot add vCPU [rc=%d]\n", rc);
+
+               return rc;
+       }
+
+       cpumask_set_cpu(vcpu_id, ne_enclave->vcpu_ids);
+
+       ne_enclave->nr_vcpus++;
+
+       return 0;
+}
+
+/**
+ * ne_sanity_check_user_mem_region() - Sanity check the user space memory
+ *                                    region received during the set user
+ *                                    memory region ioctl call.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @mem_region :       User space memory region to be sanity checked.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_sanity_check_user_mem_region(struct ne_enclave *ne_enclave,
+       struct ne_user_memory_region mem_region)
+{
+       struct ne_mem_region *ne_mem_region = NULL;
+
+       if (ne_enclave->mm != current->mm)
+               return -EIO;
+
+       if (mem_region.memory_size & (NE_MIN_MEM_REGION_SIZE - 1)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "User space memory size is not multiple of 2 MiB\n");
+
+               return -NE_ERR_INVALID_MEM_REGION_SIZE;
+       }
+
+       if (!IS_ALIGNED(mem_region.userspace_addr, NE_MIN_MEM_REGION_SIZE)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "User space address is not 2 MiB aligned\n");
+
+               return -NE_ERR_UNALIGNED_MEM_REGION_ADDR;
+       }
+
+       if ((mem_region.userspace_addr & (NE_MIN_MEM_REGION_SIZE - 1)) ||
+           !access_ok((void __user *)(unsigned long)mem_region.userspace_addr,
+                      mem_region.memory_size)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Invalid user space address range\n");
+
+               return -NE_ERR_INVALID_MEM_REGION_ADDR;
+       }
+
+       list_for_each_entry(ne_mem_region, &ne_enclave->mem_regions_list,
+                           mem_region_list_entry) {
+               u64 memory_size = ne_mem_region->memory_size;
+               u64 userspace_addr = ne_mem_region->userspace_addr;
+
+               if ((userspace_addr <= mem_region.userspace_addr &&
+                   mem_region.userspace_addr < (userspace_addr + memory_size)) ||
+                   (mem_region.userspace_addr <= userspace_addr &&
+                   (mem_region.userspace_addr + mem_region.memory_size) > userspace_addr)) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "User space memory region already used\n");
+
+                       return -NE_ERR_MEM_REGION_ALREADY_USED;
+               }
+       }
+
+       return 0;
+}
+
+/**
+ * ne_sanity_check_user_mem_region_page() - Sanity check a page from the user space
+ *                                         memory region received during the set
+ *                                         user memory region ioctl call.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @mem_region_page:   Page from the user space memory region to be sanity checked.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_sanity_check_user_mem_region_page(struct ne_enclave *ne_enclave,
+                                               struct page *mem_region_page)
+{
+       if (!PageHuge(mem_region_page)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Not a hugetlbfs page\n");
+
+               return -NE_ERR_MEM_NOT_HUGE_PAGE;
+       }
+
+       if (page_size(mem_region_page) & (NE_MIN_MEM_REGION_SIZE - 1)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Page size not multiple of 2 MiB\n");
+
+               return -NE_ERR_INVALID_PAGE_SIZE;
+       }
+
+       if (ne_enclave->numa_node != page_to_nid(mem_region_page)) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Page is not from NUMA node %d\n",
+                                   ne_enclave->numa_node);
+
+               return -NE_ERR_MEM_DIFFERENT_NUMA_NODE;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_set_user_memory_region_ioctl() - Add user space memory region to the slot
+ *                                    associated with the current enclave.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @mem_region :       User space memory region to be associated with the given slot.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_set_user_memory_region_ioctl(struct ne_enclave *ne_enclave,
+       struct ne_user_memory_region mem_region)
+{
+       long gup_rc = 0;
+       unsigned long i = 0;
+       unsigned long max_nr_pages = 0;
+       unsigned long memory_size = 0;
+       struct ne_mem_region *ne_mem_region = NULL;
+       unsigned long nr_phys_contig_mem_regions = 0;
+       struct pci_dev *pdev = ne_devs.ne_pci_dev->pdev;
+       struct page **phys_contig_mem_regions = NULL;
+       int rc = -EINVAL;
+
+       rc = ne_sanity_check_user_mem_region(ne_enclave, mem_region);
+       if (rc < 0)
+               return rc;
+
+       ne_mem_region = kzalloc(sizeof(*ne_mem_region), GFP_KERNEL);
+       if (!ne_mem_region)
+               return -ENOMEM;
+
+       max_nr_pages = mem_region.memory_size / NE_MIN_MEM_REGION_SIZE;
+
+       ne_mem_region->pages = kcalloc(max_nr_pages, sizeof(*ne_mem_region->pages),
+                                      GFP_KERNEL);
+       if (!ne_mem_region->pages) {
+               rc = -ENOMEM;
+
+               goto free_mem_region;
+       }
+
+       phys_contig_mem_regions = kcalloc(max_nr_pages, sizeof(*phys_contig_mem_regions),
+                                         GFP_KERNEL);
+       if (!phys_contig_mem_regions) {
+               rc = -ENOMEM;
+
+               goto free_mem_region;
+       }
+
+       do {
+               i = ne_mem_region->nr_pages;
+
+               if (i == max_nr_pages) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Reached max nr of pages in the pages data struct\n");
+
+                       rc = -ENOMEM;
+
+                       goto put_pages;
+               }
+
+               gup_rc = get_user_pages(mem_region.userspace_addr + memory_size, 1, FOLL_GET,
+                                       ne_mem_region->pages + i, NULL);
+               if (gup_rc < 0) {
+                       rc = gup_rc;
+
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Error in get user pages [rc=%d]\n", rc);
+
+                       goto put_pages;
+               }
+
+               rc = ne_sanity_check_user_mem_region_page(ne_enclave, ne_mem_region->pages[i]);
+               if (rc < 0)
+                       goto put_pages;
+
+               /*
+                * TODO: Update once handled non-contiguous memory regions
+                * received from user space or contiguous physical memory regions
+                * larger than 2 MiB e.g. 8 MiB.
+                */
+               phys_contig_mem_regions[i] = ne_mem_region->pages[i];
+
+               memory_size += page_size(ne_mem_region->pages[i]);
+
+               ne_mem_region->nr_pages++;
+       } while (memory_size < mem_region.memory_size);
+
+       /*
+        * TODO: Update once handled non-contiguous memory regions received
+        * from user space or contiguous physical memory regions larger than
+        * 2 MiB e.g. 8 MiB.
+        */
+       nr_phys_contig_mem_regions = ne_mem_region->nr_pages;
+
+       if ((ne_enclave->nr_mem_regions + nr_phys_contig_mem_regions) >
+           ne_enclave->max_mem_regions) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Reached max memory regions %lld\n",
+                                   ne_enclave->max_mem_regions);
+
+               rc = -NE_ERR_MEM_MAX_REGIONS;
+
+               goto put_pages;
+       }
+
+       for (i = 0; i < nr_phys_contig_mem_regions; i++) {
+               u64 phys_region_addr = page_to_phys(phys_contig_mem_regions[i]);
+               u64 phys_region_size = page_size(phys_contig_mem_regions[i]);
+
+               if (phys_region_size & (NE_MIN_MEM_REGION_SIZE - 1)) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Physical mem region size is not multiple of 2 MiB\n");
+
+                       rc = -EINVAL;
+
+                       goto put_pages;
+               }
+
+               if (!IS_ALIGNED(phys_region_addr, NE_MIN_MEM_REGION_SIZE)) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Physical mem region address is not 2 MiB aligned\n");
+
+                       rc = -EINVAL;
+
+                       goto put_pages;
+               }
+       }
+
+       ne_mem_region->memory_size = mem_region.memory_size;
+       ne_mem_region->userspace_addr = mem_region.userspace_addr;
+
+       list_add(&ne_mem_region->mem_region_list_entry, &ne_enclave->mem_regions_list);
+
+       for (i = 0; i < nr_phys_contig_mem_regions; i++) {
+               struct ne_pci_dev_cmd_reply cmd_reply = {};
+               struct slot_add_mem_req slot_add_mem_req = {};
+
+               slot_add_mem_req.slot_uid = ne_enclave->slot_uid;
+               slot_add_mem_req.paddr = page_to_phys(phys_contig_mem_regions[i]);
+               slot_add_mem_req.size = page_size(phys_contig_mem_regions[i]);
+
+               rc = ne_do_request(pdev, SLOT_ADD_MEM,
+                                  &slot_add_mem_req, sizeof(slot_add_mem_req),
+                                  &cmd_reply, sizeof(cmd_reply));
+               if (rc < 0) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Error in slot add mem [rc=%d]\n", rc);
+
+                       kfree(phys_contig_mem_regions);
+
+                       /*
+                        * Exit here without put pages as memory regions may
+                        * already been added.
+                        */
+                       return rc;
+               }
+
+               ne_enclave->mem_size += slot_add_mem_req.size;
+               ne_enclave->nr_mem_regions++;
+       }
+
+       kfree(phys_contig_mem_regions);
+
+       return 0;
+
+put_pages:
+       for (i = 0; i < ne_mem_region->nr_pages; i++)
+               put_page(ne_mem_region->pages[i]);
+free_mem_region:
+       kfree(phys_contig_mem_regions);
+       kfree(ne_mem_region->pages);
+       kfree(ne_mem_region);
+
+       return rc;
+}
+
+/**
+ * ne_start_enclave_ioctl() - Trigger enclave start after the enclave resources,
+ *                           such as memory and CPU, have been set.
+ * @ne_enclave :               Private data associated with the current enclave.
+ * @enclave_start_info :       Enclave info that includes enclave cid and flags.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_start_enclave_ioctl(struct ne_enclave *ne_enclave,
+       struct ne_enclave_start_info *enclave_start_info)
+{
+       struct ne_pci_dev_cmd_reply cmd_reply = {};
+       unsigned int cpu = 0;
+       struct enclave_start_req enclave_start_req = {};
+       unsigned int i = 0;
+       struct pci_dev *pdev = ne_devs.ne_pci_dev->pdev;
+       int rc = -EINVAL;
+
+       if (!ne_enclave->nr_mem_regions) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Enclave has no mem regions\n");
+
+               return -NE_ERR_NO_MEM_REGIONS_ADDED;
+       }
+
+       if (ne_enclave->mem_size < NE_MIN_ENCLAVE_MEM_SIZE) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Enclave memory is less than %ld\n",
+                                   NE_MIN_ENCLAVE_MEM_SIZE);
+
+               return -NE_ERR_ENCLAVE_MEM_MIN_SIZE;
+       }
+
+       if (!ne_enclave->nr_vcpus) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Enclave has no vCPUs\n");
+
+               return -NE_ERR_NO_VCPUS_ADDED;
+       }
+
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++)
+               for_each_cpu(cpu, ne_enclave->threads_per_core[i])
+                       if (!cpumask_test_cpu(cpu, ne_enclave->vcpu_ids)) {
+                               dev_err_ratelimited(ne_misc_dev.this_device,
+                                                   "Full CPU cores not used\n");
+
+                               return -NE_ERR_FULL_CORES_NOT_USED;
+                       }
+
+       enclave_start_req.enclave_cid = enclave_start_info->enclave_cid;
+       enclave_start_req.flags = enclave_start_info->flags;
+       enclave_start_req.slot_uid = ne_enclave->slot_uid;
+
+       rc = ne_do_request(pdev, ENCLAVE_START,
+                          &enclave_start_req, sizeof(enclave_start_req),
+                          &cmd_reply, sizeof(cmd_reply));
+       if (rc < 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in enclave start [rc=%d]\n", rc);
+
+               return rc;
+       }
+
+       ne_enclave->state = NE_STATE_RUNNING;
+
+       enclave_start_info->enclave_cid = cmd_reply.enclave_cid;
+
+       return 0;
+}
+
+/**
+ * ne_enclave_ioctl() - Ioctl function provided by the enclave file.
+ * @file:      File associated with this ioctl function.
+ * @cmd:       The command that is set for the ioctl call.
+ * @arg:       The argument that is provided for the ioctl call.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static long ne_enclave_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       struct ne_enclave *ne_enclave = file->private_data;
+
+       switch (cmd) {
+       case NE_ADD_VCPU: {
+               int rc = -EINVAL;
+               u32 vcpu_id = 0;
+
+               if (copy_from_user(&vcpu_id, (void __user *)arg, sizeof(vcpu_id)))
+                       return -EFAULT;
+
+               mutex_lock(&ne_enclave->enclave_info_mutex);
+
+               if (ne_enclave->state != NE_STATE_INIT) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Enclave is not in init state\n");
+
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return -NE_ERR_NOT_IN_INIT_STATE;
+               }
+
+               if (vcpu_id >= (ne_enclave->nr_parent_vm_cores *
+                   ne_enclave->nr_threads_per_core)) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "vCPU id higher than max CPU id\n");
+
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return -NE_ERR_INVALID_VCPU;
+               }
+
+               if (!vcpu_id) {
+                       /* Use the CPU pool for choosing a CPU for the enclave. */
+                       rc = ne_get_cpu_from_cpu_pool(ne_enclave, &vcpu_id);
+                       if (rc < 0) {
+                               dev_err_ratelimited(ne_misc_dev.this_device,
+                                                   "Error in get CPU from pool [rc=%d]\n",
+                                                   rc);
+
+                               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                               return rc;
+                       }
+               } else {
+                       /* Check if the provided vCPU is available in the NE CPU pool. */
+                       rc = ne_check_cpu_in_cpu_pool(ne_enclave, vcpu_id);
+                       if (rc < 0) {
+                               dev_err_ratelimited(ne_misc_dev.this_device,
+                                                   "Error in check CPU %d in pool [rc=%d]\n",
+                                                   vcpu_id, rc);
+
+                               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                               return rc;
+                       }
+               }
+
+               rc = ne_add_vcpu_ioctl(ne_enclave, vcpu_id);
+               if (rc < 0) {
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return rc;
+               }
+
+               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+               if (copy_to_user((void __user *)arg, &vcpu_id, sizeof(vcpu_id)))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case NE_GET_IMAGE_LOAD_INFO: {
+               struct ne_image_load_info image_load_info = {};
+
+               if (copy_from_user(&image_load_info, (void __user *)arg, sizeof(image_load_info)))
+                       return -EFAULT;
+
+               mutex_lock(&ne_enclave->enclave_info_mutex);
+
+               if (ne_enclave->state != NE_STATE_INIT) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Enclave is not in init state\n");
+
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return -NE_ERR_NOT_IN_INIT_STATE;
+               }
+
+               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+               if (!image_load_info.flags ||
+                   image_load_info.flags >= NE_IMAGE_LOAD_MAX_FLAG_VAL) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Incorrect flag in enclave image load info\n");
+
+                       return -NE_ERR_INVALID_FLAG_VALUE;
+               }
+
+               if (image_load_info.flags == NE_EIF_IMAGE)
+                       image_load_info.memory_offset = NE_EIF_LOAD_OFFSET;
+
+               if (copy_to_user((void __user *)arg, &image_load_info, sizeof(image_load_info)))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case NE_SET_USER_MEMORY_REGION: {
+               struct ne_user_memory_region mem_region = {};
+               int rc = -EINVAL;
+
+               if (copy_from_user(&mem_region, (void __user *)arg, sizeof(mem_region)))
+                       return -EFAULT;
+
+               if (mem_region.flags >= NE_MEMORY_REGION_MAX_FLAG_VAL) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Incorrect flag for user memory region\n");
+
+                       return -NE_ERR_INVALID_FLAG_VALUE;
+               }
+
+               mutex_lock(&ne_enclave->enclave_info_mutex);
+
+               if (ne_enclave->state != NE_STATE_INIT) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Enclave is not in init state\n");
+
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return -NE_ERR_NOT_IN_INIT_STATE;
+               }
+
+               rc = ne_set_user_memory_region_ioctl(ne_enclave, mem_region);
+               if (rc < 0) {
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return rc;
+               }
+
+               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+               return 0;
+       }
+
+       case NE_START_ENCLAVE: {
+               struct ne_enclave_start_info enclave_start_info = {};
+               int rc = -EINVAL;
+
+               if (copy_from_user(&enclave_start_info, (void __user *)arg,
+                                  sizeof(enclave_start_info)))
+                       return -EFAULT;
+
+               if (enclave_start_info.flags >= NE_ENCLAVE_START_MAX_FLAG_VAL) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Incorrect flag in enclave start info\n");
+
+                       return -NE_ERR_INVALID_FLAG_VALUE;
+               }
+
+               /*
+                * Do not use well-known CIDs - 0, 1, 2 - for enclaves.
+                * VMADDR_CID_ANY = -1U
+                * VMADDR_CID_HYPERVISOR = 0
+                * VMADDR_CID_LOCAL = 1
+                * VMADDR_CID_HOST = 2
+                * Note: 0 is used as a placeholder to auto-generate an enclave CID.
+                * http://man7.org/linux/man-pages/man7/vsock.7.html
+                */
+               if (enclave_start_info.enclave_cid > 0 &&
+                   enclave_start_info.enclave_cid <= VMADDR_CID_HOST) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Well-known CID value, not to be used for enclaves\n");
+
+                       return -NE_ERR_INVALID_ENCLAVE_CID;
+               }
+
+               if (enclave_start_info.enclave_cid == U32_MAX) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Well-known CID value, not to be used for enclaves\n");
+
+                       return -NE_ERR_INVALID_ENCLAVE_CID;
+               }
+
+               /*
+                * Do not use the CID of the primary / parent VM for enclaves.
+                */
+               if (enclave_start_info.enclave_cid == NE_PARENT_VM_CID) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "CID of the parent VM, not to be used for enclaves\n");
+
+                       return -NE_ERR_INVALID_ENCLAVE_CID;
+               }
+
+               /* 64-bit CIDs are not yet supported for the vsock device. */
+               if (enclave_start_info.enclave_cid > U32_MAX) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "64-bit CIDs not yet supported for the vsock device\n");
+
+                       return -NE_ERR_INVALID_ENCLAVE_CID;
+               }
+
+               mutex_lock(&ne_enclave->enclave_info_mutex);
+
+               if (ne_enclave->state != NE_STATE_INIT) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Enclave is not in init state\n");
+
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return -NE_ERR_NOT_IN_INIT_STATE;
+               }
+
+               rc = ne_start_enclave_ioctl(ne_enclave, &enclave_start_info);
+               if (rc < 0) {
+                       mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+                       return rc;
+               }
+
+               mutex_unlock(&ne_enclave->enclave_info_mutex);
+
+               if (copy_to_user((void __user *)arg, &enclave_start_info,
+                                sizeof(enclave_start_info)))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       default:
+               return -ENOTTY;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_enclave_remove_all_mem_region_entries() - Remove all memory region entries
+ *                                             from the enclave data structure.
+ * @ne_enclave :       Private data associated with the current enclave.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ */
+static void ne_enclave_remove_all_mem_region_entries(struct ne_enclave *ne_enclave)
+{
+       unsigned long i = 0;
+       struct ne_mem_region *ne_mem_region = NULL;
+       struct ne_mem_region *ne_mem_region_tmp = NULL;
+
+       list_for_each_entry_safe(ne_mem_region, ne_mem_region_tmp,
+                                &ne_enclave->mem_regions_list,
+                                mem_region_list_entry) {
+               list_del(&ne_mem_region->mem_region_list_entry);
+
+               for (i = 0; i < ne_mem_region->nr_pages; i++)
+                       put_page(ne_mem_region->pages[i]);
+
+               kfree(ne_mem_region->pages);
+
+               kfree(ne_mem_region);
+       }
+}
+
+/**
+ * ne_enclave_remove_all_vcpu_id_entries() - Remove all vCPU id entries from
+ *                                          the enclave data structure.
+ * @ne_enclave :       Private data associated with the current enclave.
+ *
+ * Context: Process context. This function is called with the ne_enclave mutex held.
+ */
+static void ne_enclave_remove_all_vcpu_id_entries(struct ne_enclave *ne_enclave)
+{
+       unsigned int cpu = 0;
+       unsigned int i = 0;
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++) {
+               for_each_cpu(cpu, ne_enclave->threads_per_core[i])
+                       /* Update the available NE CPU pool. */
+                       cpumask_set_cpu(cpu, ne_cpu_pool.avail_threads_per_core[i]);
+
+               free_cpumask_var(ne_enclave->threads_per_core[i]);
+       }
+
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       kfree(ne_enclave->threads_per_core);
+
+       free_cpumask_var(ne_enclave->vcpu_ids);
+}
+
+/**
+ * ne_pci_dev_remove_enclave_entry() - Remove the enclave entry from the data
+ *                                    structure that is part of the NE PCI
+ *                                    device private data.
+ * @ne_enclave :       Private data associated with the current enclave.
+ * @ne_pci_dev :       Private data associated with the PCI device.
+ *
+ * Context: Process context. This function is called with the ne_pci_dev enclave
+ *         mutex held.
+ */
+static void ne_pci_dev_remove_enclave_entry(struct ne_enclave *ne_enclave,
+                                           struct ne_pci_dev *ne_pci_dev)
+{
+       struct ne_enclave *ne_enclave_entry = NULL;
+       struct ne_enclave *ne_enclave_entry_tmp = NULL;
+
+       list_for_each_entry_safe(ne_enclave_entry, ne_enclave_entry_tmp,
+                                &ne_pci_dev->enclaves_list, enclave_list_entry) {
+               if (ne_enclave_entry->slot_uid == ne_enclave->slot_uid) {
+                       list_del(&ne_enclave_entry->enclave_list_entry);
+
+                       break;
+               }
+       }
+}
+
+/**
+ * ne_enclave_release() - Release function provided by the enclave file.
+ * @inode:     Inode associated with this file release function.
+ * @file:      File associated with this release function.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_enclave_release(struct inode *inode, struct file *file)
+{
+       struct ne_pci_dev_cmd_reply cmd_reply = {};
+       struct enclave_stop_req enclave_stop_request = {};
+       struct ne_enclave *ne_enclave = file->private_data;
+       struct ne_pci_dev *ne_pci_dev = ne_devs.ne_pci_dev;
+       struct pci_dev *pdev = ne_pci_dev->pdev;
+       int rc = -EINVAL;
+       struct slot_free_req slot_free_req = {};
+
+       if (!ne_enclave)
+               return 0;
+
+       /*
+        * Early exit in case there is an error in the enclave creation logic
+        * and fput() is called on the cleanup path.
+        */
+       if (!ne_enclave->slot_uid)
+               return 0;
+
+       /*
+        * Acquire the enclave list mutex before the enclave mutex
+        * in order to avoid deadlocks with @ref ne_event_work_handler.
+        */
+       mutex_lock(&ne_pci_dev->enclaves_list_mutex);
+       mutex_lock(&ne_enclave->enclave_info_mutex);
+
+       if (ne_enclave->state != NE_STATE_INIT && ne_enclave->state != NE_STATE_STOPPED) {
+               enclave_stop_request.slot_uid = ne_enclave->slot_uid;
+
+               rc = ne_do_request(pdev, ENCLAVE_STOP,
+                                  &enclave_stop_request, sizeof(enclave_stop_request),
+                                  &cmd_reply, sizeof(cmd_reply));
+               if (rc < 0) {
+                       dev_err_ratelimited(ne_misc_dev.this_device,
+                                           "Error in enclave stop [rc=%d]\n", rc);
+
+                       goto unlock_mutex;
+               }
+
+               memset(&cmd_reply, 0, sizeof(cmd_reply));
+       }
+
+       slot_free_req.slot_uid = ne_enclave->slot_uid;
+
+       rc = ne_do_request(pdev, SLOT_FREE,
+                          &slot_free_req, sizeof(slot_free_req),
+                          &cmd_reply, sizeof(cmd_reply));
+       if (rc < 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in slot free [rc=%d]\n", rc);
+
+               goto unlock_mutex;
+       }
+
+       ne_pci_dev_remove_enclave_entry(ne_enclave, ne_pci_dev);
+       ne_enclave_remove_all_mem_region_entries(ne_enclave);
+       ne_enclave_remove_all_vcpu_id_entries(ne_enclave);
+
+       mutex_unlock(&ne_enclave->enclave_info_mutex);
+       mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+
+       kfree(ne_enclave);
+
+       return 0;
+
+unlock_mutex:
+       mutex_unlock(&ne_enclave->enclave_info_mutex);
+       mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+
+       return rc;
+}
+
+/**
+ * ne_enclave_poll() - Poll functionality used for enclave out-of-band events.
+ * @file:      File associated with this poll function.
+ * @wait:      Poll table data structure.
+ *
+ * Context: Process context.
+ * Return:
+ * * Poll mask.
+ */
+static __poll_t ne_enclave_poll(struct file *file, poll_table *wait)
+{
+       __poll_t mask = 0;
+       struct ne_enclave *ne_enclave = file->private_data;
+
+       poll_wait(file, &ne_enclave->eventq, wait);
+
+       if (!ne_enclave->has_event)
+               return mask;
+
+       mask = POLLHUP;
+
+       return mask;
+}
+
+static const struct file_operations ne_enclave_fops = {
+       .owner          = THIS_MODULE,
+       .llseek         = noop_llseek,
+       .poll           = ne_enclave_poll,
+       .unlocked_ioctl = ne_enclave_ioctl,
+       .release        = ne_enclave_release,
+};
+
+/**
+ * ne_create_vm_ioctl() - Alloc slot to be associated with an enclave. Create
+ *                       enclave file descriptor to be further used for enclave
+ *                       resources handling e.g. memory regions and CPUs.
+ * @ne_pci_dev :       Private data associated with the PCI device.
+ * @slot_uid:          Generated unique slot id associated with an enclave.
+ *
+ * Context: Process context. This function is called with the ne_pci_dev enclave
+ *         mutex held.
+ * Return:
+ * * Enclave fd on success.
+ * * Negative return value on failure.
+ */
+static int ne_create_vm_ioctl(struct ne_pci_dev *ne_pci_dev, u64 *slot_uid)
+{
+       struct ne_pci_dev_cmd_reply cmd_reply = {};
+       int enclave_fd = -1;
+       struct file *enclave_file = NULL;
+       unsigned int i = 0;
+       struct ne_enclave *ne_enclave = NULL;
+       struct pci_dev *pdev = ne_pci_dev->pdev;
+       int rc = -EINVAL;
+       struct slot_alloc_req slot_alloc_req = {};
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       for (i = 0; i < ne_cpu_pool.nr_parent_vm_cores; i++)
+               if (!cpumask_empty(ne_cpu_pool.avail_threads_per_core[i]))
+                       break;
+
+       if (i == ne_cpu_pool.nr_parent_vm_cores) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "No CPUs available in CPU pool\n");
+
+               mutex_unlock(&ne_cpu_pool.mutex);
+
+               return -NE_ERR_NO_CPUS_AVAIL_IN_POOL;
+       }
+
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       ne_enclave = kzalloc(sizeof(*ne_enclave), GFP_KERNEL);
+       if (!ne_enclave)
+               return -ENOMEM;
+
+       mutex_lock(&ne_cpu_pool.mutex);
+
+       ne_enclave->nr_parent_vm_cores = ne_cpu_pool.nr_parent_vm_cores;
+       ne_enclave->nr_threads_per_core = ne_cpu_pool.nr_threads_per_core;
+       ne_enclave->numa_node = ne_cpu_pool.numa_node;
+
+       mutex_unlock(&ne_cpu_pool.mutex);
+
+       ne_enclave->threads_per_core = kcalloc(ne_enclave->nr_parent_vm_cores,
+               sizeof(*ne_enclave->threads_per_core), GFP_KERNEL);
+       if (!ne_enclave->threads_per_core) {
+               rc = -ENOMEM;
+
+               goto free_ne_enclave;
+       }
+
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++)
+               if (!zalloc_cpumask_var(&ne_enclave->threads_per_core[i], GFP_KERNEL)) {
+                       rc = -ENOMEM;
+
+                       goto free_cpumask;
+               }
+
+       if (!zalloc_cpumask_var(&ne_enclave->vcpu_ids, GFP_KERNEL)) {
+               rc = -ENOMEM;
+
+               goto free_cpumask;
+       }
+
+       enclave_fd = get_unused_fd_flags(O_CLOEXEC);
+       if (enclave_fd < 0) {
+               rc = enclave_fd;
+
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in getting unused fd [rc=%d]\n", rc);
+
+               goto free_cpumask;
+       }
+
+       enclave_file = anon_inode_getfile("ne-vm", &ne_enclave_fops, ne_enclave, O_RDWR);
+       if (IS_ERR(enclave_file)) {
+               rc = PTR_ERR(enclave_file);
+
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in anon inode get file [rc=%d]\n", rc);
+
+               goto put_fd;
+       }
+
+       rc = ne_do_request(pdev, SLOT_ALLOC,
+                          &slot_alloc_req, sizeof(slot_alloc_req),
+                          &cmd_reply, sizeof(cmd_reply));
+       if (rc < 0) {
+               dev_err_ratelimited(ne_misc_dev.this_device,
+                                   "Error in slot alloc [rc=%d]\n", rc);
+
+               goto put_file;
+       }
+
+       init_waitqueue_head(&ne_enclave->eventq);
+       ne_enclave->has_event = false;
+       mutex_init(&ne_enclave->enclave_info_mutex);
+       ne_enclave->max_mem_regions = cmd_reply.mem_regions;
+       INIT_LIST_HEAD(&ne_enclave->mem_regions_list);
+       ne_enclave->mm = current->mm;
+       ne_enclave->slot_uid = cmd_reply.slot_uid;
+       ne_enclave->state = NE_STATE_INIT;
+
+       list_add(&ne_enclave->enclave_list_entry, &ne_pci_dev->enclaves_list);
+
+       *slot_uid = ne_enclave->slot_uid;
+
+       fd_install(enclave_fd, enclave_file);
+
+       return enclave_fd;
+
+put_file:
+       fput(enclave_file);
+put_fd:
+       put_unused_fd(enclave_fd);
+free_cpumask:
+       free_cpumask_var(ne_enclave->vcpu_ids);
+       for (i = 0; i < ne_enclave->nr_parent_vm_cores; i++)
+               free_cpumask_var(ne_enclave->threads_per_core[i]);
+       kfree(ne_enclave->threads_per_core);
+free_ne_enclave:
+       kfree(ne_enclave);
+
+       return rc;
+}
+
+/**
+ * ne_ioctl() - Ioctl function provided by the NE misc device.
+ * @file:      File associated with this ioctl function.
+ * @cmd:       The command that is set for the ioctl call.
+ * @arg:       The argument that is provided for the ioctl call.
+ *
+ * Context: Process context.
+ * Return:
+ * * Ioctl result (e.g. enclave file descriptor) on success.
+ * * Negative return value on failure.
+ */
+static long ne_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case NE_CREATE_VM: {
+               int enclave_fd = -1;
+               struct file *enclave_file = NULL;
+               struct ne_pci_dev *ne_pci_dev = ne_devs.ne_pci_dev;
+               int rc = -EINVAL;
+               u64 slot_uid = 0;
+
+               mutex_lock(&ne_pci_dev->enclaves_list_mutex);
+
+               enclave_fd = ne_create_vm_ioctl(ne_pci_dev, &slot_uid);
+               if (enclave_fd < 0) {
+                       rc = enclave_fd;
+
+                       mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+
+                       return rc;
+               }
+
+               mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+
+               if (copy_to_user((void __user *)arg, &slot_uid, sizeof(slot_uid))) {
+                       enclave_file = fget(enclave_fd);
+                       /* Decrement file refs to have release() called. */
+                       fput(enclave_file);
+                       fput(enclave_file);
+                       put_unused_fd(enclave_fd);
+
+                       return -EFAULT;
+               }
+
+               return enclave_fd;
+       }
+
+       default:
+               return -ENOTTY;
+       }
+
+       return 0;
+}
+
+static int __init ne_init(void)
+{
+       mutex_init(&ne_cpu_pool.mutex);
+
+       return pci_register_driver(&ne_pci_driver);
+}
+
+static void __exit ne_exit(void)
+{
+       pci_unregister_driver(&ne_pci_driver);
+
+       ne_teardown_cpu_pool();
+}
+
+module_init(ne_init);
+module_exit(ne_exit);
+
+MODULE_AUTHOR("Amazon.com, Inc. or its affiliates");
+MODULE_DESCRIPTION("Nitro Enclaves Driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.h b/drivers/virt/nitro_enclaves/ne_misc_dev.h
new file mode 100644 (file)
index 0000000..2a4d222
--- /dev/null
@@ -0,0 +1,109 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _NE_MISC_DEV_H_
+#define _NE_MISC_DEV_H_
+
+#include <linux/cpumask.h>
+#include <linux/list.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/wait.h>
+
+#include "ne_pci_dev.h"
+
+/**
+ * struct ne_mem_region - Entry in the enclave user space memory regions list.
+ * @mem_region_list_entry:     Entry in the list of enclave memory regions.
+ * @memory_size:               Size of the user space memory region.
+ * @nr_pages:                  Number of pages that make up the memory region.
+ * @pages:                     Pages that make up the user space memory region.
+ * @userspace_addr:            User space address of the memory region.
+ */
+struct ne_mem_region {
+       struct list_head        mem_region_list_entry;
+       u64                     memory_size;
+       unsigned long           nr_pages;
+       struct page             **pages;
+       u64                     userspace_addr;
+};
+
+/**
+ * struct ne_enclave - Per-enclave data used for enclave lifetime management.
+ * @enclave_info_mutex :       Mutex for accessing this internal state.
+ * @enclave_list_entry :       Entry in the list of created enclaves.
+ * @eventq:                    Wait queue used for out-of-band event notifications
+ *                             triggered from the PCI device event handler to
+ *                             the enclave process via the poll function.
+ * @has_event:                 Variable used to determine if the out-of-band event
+ *                             was triggered.
+ * @max_mem_regions:           The maximum number of memory regions that can be
+ *                             handled by the hypervisor.
+ * @mem_regions_list:          Enclave user space memory regions list.
+ * @mem_size:                  Enclave memory size.
+ * @mm :                       Enclave process abstraction mm data struct.
+ * @nr_mem_regions:            Number of memory regions associated with the enclave.
+ * @nr_parent_vm_cores :       The size of the threads per core array. The
+ *                             total number of CPU cores available on the
+ *                             parent / primary VM.
+ * @nr_threads_per_core:       The number of threads that a full CPU core has.
+ * @nr_vcpus:                  Number of vcpus associated with the enclave.
+ * @numa_node:                 NUMA node of the enclave memory and CPUs.
+ * @slot_uid:                  Slot unique id mapped to the enclave.
+ * @state:                     Enclave state, updated during enclave lifetime.
+ * @threads_per_core:          Enclave full CPU cores array, indexed by core id,
+ *                             consisting of cpumasks with all their threads.
+ *                             Full CPU cores are taken from the NE CPU pool
+ *                             and are available to the enclave.
+ * @vcpu_ids:                  Cpumask of the vCPUs that are set for the enclave.
+ */
+struct ne_enclave {
+       struct mutex            enclave_info_mutex;
+       struct list_head        enclave_list_entry;
+       wait_queue_head_t       eventq;
+       bool                    has_event;
+       u64                     max_mem_regions;
+       struct list_head        mem_regions_list;
+       u64                     mem_size;
+       struct mm_struct        *mm;
+       unsigned int            nr_mem_regions;
+       unsigned int            nr_parent_vm_cores;
+       unsigned int            nr_threads_per_core;
+       unsigned int            nr_vcpus;
+       int                     numa_node;
+       u64                     slot_uid;
+       u16                     state;
+       cpumask_var_t           *threads_per_core;
+       cpumask_var_t           vcpu_ids;
+};
+
+/**
+ * enum ne_state - States available for an enclave.
+ * @NE_STATE_INIT:     The enclave has not been started yet.
+ * @NE_STATE_RUNNING:  The enclave was started and is running as expected.
+ * @NE_STATE_STOPPED:  The enclave exited without userspace interaction.
+ */
+enum ne_state {
+       NE_STATE_INIT           = 0,
+       NE_STATE_RUNNING        = 2,
+       NE_STATE_STOPPED        = U16_MAX,
+};
+
+/**
+ * struct ne_devs - Data structure to keep refs to the NE misc and PCI devices.
+ * @ne_misc_dev:       Nitro Enclaves misc device.
+ * @ne_pci_dev :       Nitro Enclaves PCI device.
+ */
+struct ne_devs {
+       struct miscdevice       *ne_misc_dev;
+       struct ne_pci_dev       *ne_pci_dev;
+};
+
+/* Nitro Enclaves (NE) data structure for keeping refs to the NE misc and PCI devices. */
+extern struct ne_devs ne_devs;
+
+#endif /* _NE_MISC_DEV_H_ */
diff --git a/drivers/virt/nitro_enclaves/ne_pci_dev.c b/drivers/virt/nitro_enclaves/ne_pci_dev.c
new file mode 100644 (file)
index 0000000..b9c1de4
--- /dev/null
@@ -0,0 +1,625 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+/**
+ * DOC: Nitro Enclaves (NE) PCI device driver.
+ */
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/nitro_enclaves.h>
+#include <linux/pci.h>
+#include <linux/types.h>
+#include <linux/wait.h>
+
+#include "ne_misc_dev.h"
+#include "ne_pci_dev.h"
+
+/**
+ * NE_DEFAULT_TIMEOUT_MSECS - Default timeout to wait for a reply from
+ *                           the NE PCI device.
+ */
+#define NE_DEFAULT_TIMEOUT_MSECS       (120000) /* 120 sec */
+
+static const struct pci_device_id ne_pci_ids[] = {
+       { PCI_DEVICE(PCI_VENDOR_ID_AMAZON, PCI_DEVICE_ID_NE) },
+       { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, ne_pci_ids);
+
+/**
+ * ne_submit_request() - Submit command request to the PCI device based on the
+ *                      command type.
+ * @pdev:              PCI device to send the command to.
+ * @cmd_type:          Command type of the request sent to the PCI device.
+ * @cmd_request:       Command request payload.
+ * @cmd_request_size:  Size of the command request payload.
+ *
+ * Context: Process context. This function is called with the ne_pci_dev mutex held.
+ */
+static void ne_submit_request(struct pci_dev *pdev, enum ne_pci_dev_cmd_type cmd_type,
+                             void *cmd_request, size_t cmd_request_size)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       memcpy_toio(ne_pci_dev->iomem_base + NE_SEND_DATA, cmd_request, cmd_request_size);
+
+       iowrite32(cmd_type, ne_pci_dev->iomem_base + NE_COMMAND);
+}
+
+/**
+ * ne_retrieve_reply() - Retrieve reply from the PCI device.
+ * @pdev:              PCI device to receive the reply from.
+ * @cmd_reply:         Command reply payload.
+ * @cmd_reply_size:    Size of the command reply payload.
+ *
+ * Context: Process context. This function is called with the ne_pci_dev mutex held.
+ */
+static void ne_retrieve_reply(struct pci_dev *pdev, struct ne_pci_dev_cmd_reply *cmd_reply,
+                             size_t cmd_reply_size)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       memcpy_fromio(cmd_reply, ne_pci_dev->iomem_base + NE_RECV_DATA, cmd_reply_size);
+}
+
+/**
+ * ne_wait_for_reply() - Wait for a reply of a PCI device command.
+ * @pdev:      PCI device for which a reply is waited.
+ *
+ * Context: Process context. This function is called with the ne_pci_dev mutex held.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_wait_for_reply(struct pci_dev *pdev)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+       int rc = -EINVAL;
+
+       /*
+        * TODO: Update to _interruptible and handle interrupted wait event
+        * e.g. -ERESTARTSYS, incoming signals + update timeout, if needed.
+        */
+       rc = wait_event_timeout(ne_pci_dev->cmd_reply_wait_q,
+                               atomic_read(&ne_pci_dev->cmd_reply_avail) != 0,
+                               msecs_to_jiffies(NE_DEFAULT_TIMEOUT_MSECS));
+       if (!rc)
+               return -ETIMEDOUT;
+
+       return 0;
+}
+
+int ne_do_request(struct pci_dev *pdev, enum ne_pci_dev_cmd_type cmd_type,
+                 void *cmd_request, size_t cmd_request_size,
+                 struct ne_pci_dev_cmd_reply *cmd_reply, size_t cmd_reply_size)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+       int rc = -EINVAL;
+
+       if (cmd_type <= INVALID_CMD || cmd_type >= MAX_CMD) {
+               dev_err_ratelimited(&pdev->dev, "Invalid cmd type=%u\n", cmd_type);
+
+               return -EINVAL;
+       }
+
+       if (!cmd_request) {
+               dev_err_ratelimited(&pdev->dev, "Null cmd request for cmd type=%u\n",
+                                   cmd_type);
+
+               return -EINVAL;
+       }
+
+       if (cmd_request_size > NE_SEND_DATA_SIZE) {
+               dev_err_ratelimited(&pdev->dev, "Invalid req size=%zu for cmd type=%u\n",
+                                   cmd_request_size, cmd_type);
+
+               return -EINVAL;
+       }
+
+       if (!cmd_reply) {
+               dev_err_ratelimited(&pdev->dev, "Null cmd reply for cmd type=%u\n",
+                                   cmd_type);
+
+               return -EINVAL;
+       }
+
+       if (cmd_reply_size > NE_RECV_DATA_SIZE) {
+               dev_err_ratelimited(&pdev->dev, "Invalid reply size=%zu for cmd type=%u\n",
+                                   cmd_reply_size, cmd_type);
+
+               return -EINVAL;
+       }
+
+       /*
+        * Use this mutex so that the PCI device handles one command request at
+        * a time.
+        */
+       mutex_lock(&ne_pci_dev->pci_dev_mutex);
+
+       atomic_set(&ne_pci_dev->cmd_reply_avail, 0);
+
+       ne_submit_request(pdev, cmd_type, cmd_request, cmd_request_size);
+
+       rc = ne_wait_for_reply(pdev);
+       if (rc < 0) {
+               dev_err_ratelimited(&pdev->dev, "Error in wait for reply for cmd type=%u [rc=%d]\n",
+                                   cmd_type, rc);
+
+               goto unlock_mutex;
+       }
+
+       ne_retrieve_reply(pdev, cmd_reply, cmd_reply_size);
+
+       atomic_set(&ne_pci_dev->cmd_reply_avail, 0);
+
+       if (cmd_reply->rc < 0) {
+               rc = cmd_reply->rc;
+
+               dev_err_ratelimited(&pdev->dev, "Error in cmd process logic, cmd type=%u [rc=%d]\n",
+                                   cmd_type, rc);
+
+               goto unlock_mutex;
+       }
+
+       rc = 0;
+
+unlock_mutex:
+       mutex_unlock(&ne_pci_dev->pci_dev_mutex);
+
+       return rc;
+}
+
+/**
+ * ne_reply_handler() - Interrupt handler for retrieving a reply matching a
+ *                     request sent to the PCI device for enclave lifetime
+ *                     management.
+ * @irq:       Received interrupt for a reply sent by the PCI device.
+ * @args:      PCI device private data structure.
+ *
+ * Context: Interrupt context.
+ * Return:
+ * * IRQ_HANDLED on handled interrupt.
+ */
+static irqreturn_t ne_reply_handler(int irq, void *args)
+{
+       struct ne_pci_dev *ne_pci_dev = (struct ne_pci_dev *)args;
+
+       atomic_set(&ne_pci_dev->cmd_reply_avail, 1);
+
+       /* TODO: Update to _interruptible. */
+       wake_up(&ne_pci_dev->cmd_reply_wait_q);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * ne_event_work_handler() - Work queue handler for notifying enclaves on a
+ *                          state change received by the event interrupt
+ *                          handler.
+ * @work:      Item containing the NE PCI device for which an out-of-band event
+ *             was issued.
+ *
+ * An out-of-band event is being issued by the Nitro Hypervisor when at least
+ * one enclave is changing state without client interaction.
+ *
+ * Context: Work queue context.
+ */
+static void ne_event_work_handler(struct work_struct *work)
+{
+       struct ne_pci_dev_cmd_reply cmd_reply = {};
+       struct ne_enclave *ne_enclave = NULL;
+       struct ne_pci_dev *ne_pci_dev =
+               container_of(work, struct ne_pci_dev, notify_work);
+       struct pci_dev *pdev = ne_pci_dev->pdev;
+       int rc = -EINVAL;
+       struct slot_info_req slot_info_req = {};
+
+       mutex_lock(&ne_pci_dev->enclaves_list_mutex);
+
+       /*
+        * Iterate over all enclaves registered for the Nitro Enclaves
+        * PCI device and determine for which enclave(s) the out-of-band event
+        * is corresponding to.
+        */
+       list_for_each_entry(ne_enclave, &ne_pci_dev->enclaves_list, enclave_list_entry) {
+               mutex_lock(&ne_enclave->enclave_info_mutex);
+
+               /*
+                * Enclaves that were never started cannot receive out-of-band
+                * events.
+                */
+               if (ne_enclave->state != NE_STATE_RUNNING)
+                       goto unlock;
+
+               slot_info_req.slot_uid = ne_enclave->slot_uid;
+
+               rc = ne_do_request(pdev, SLOT_INFO,
+                                  &slot_info_req, sizeof(slot_info_req),
+                                  &cmd_reply, sizeof(cmd_reply));
+               if (rc < 0)
+                       dev_err(&pdev->dev, "Error in slot info [rc=%d]\n", rc);
+
+               /* Notify enclave process that the enclave state changed. */
+               if (ne_enclave->state != cmd_reply.state) {
+                       ne_enclave->state = cmd_reply.state;
+
+                       ne_enclave->has_event = true;
+
+                       wake_up_interruptible(&ne_enclave->eventq);
+               }
+
+unlock:
+                mutex_unlock(&ne_enclave->enclave_info_mutex);
+       }
+
+       mutex_unlock(&ne_pci_dev->enclaves_list_mutex);
+}
+
+/**
+ * ne_event_handler() - Interrupt handler for PCI device out-of-band events.
+ *                     This interrupt does not supply any data in the MMIO
+ *                     region. It notifies a change in the state of any of
+ *                     the launched enclaves.
+ * @irq:       Received interrupt for an out-of-band event.
+ * @args:      PCI device private data structure.
+ *
+ * Context: Interrupt context.
+ * Return:
+ * * IRQ_HANDLED on handled interrupt.
+ */
+static irqreturn_t ne_event_handler(int irq, void *args)
+{
+       struct ne_pci_dev *ne_pci_dev = (struct ne_pci_dev *)args;
+
+       queue_work(ne_pci_dev->event_wq, &ne_pci_dev->notify_work);
+
+       return IRQ_HANDLED;
+}
+
+/**
+ * ne_setup_msix() - Setup MSI-X vectors for the PCI device.
+ * @pdev:      PCI device to setup the MSI-X for.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_setup_msix(struct pci_dev *pdev)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+       int nr_vecs = 0;
+       int rc = -EINVAL;
+
+       nr_vecs = pci_msix_vec_count(pdev);
+       if (nr_vecs < 0) {
+               rc = nr_vecs;
+
+               dev_err(&pdev->dev, "Error in getting vec count [rc=%d]\n", rc);
+
+               return rc;
+       }
+
+       rc = pci_alloc_irq_vectors(pdev, nr_vecs, nr_vecs, PCI_IRQ_MSIX);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in alloc MSI-X vecs [rc=%d]\n", rc);
+
+               return rc;
+       }
+
+       /*
+        * This IRQ gets triggered every time the PCI device responds to a
+        * command request. The reply is then retrieved, reading from the MMIO
+        * space of the PCI device.
+        */
+       rc = request_irq(pci_irq_vector(pdev, NE_VEC_REPLY), ne_reply_handler,
+                        0, "enclave_cmd", ne_pci_dev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in request irq reply [rc=%d]\n", rc);
+
+               goto free_irq_vectors;
+       }
+
+       ne_pci_dev->event_wq = create_singlethread_workqueue("ne_pci_dev_wq");
+       if (!ne_pci_dev->event_wq) {
+               rc = -ENOMEM;
+
+               dev_err(&pdev->dev, "Cannot get wq for dev events [rc=%d]\n", rc);
+
+               goto free_reply_irq_vec;
+       }
+
+       INIT_WORK(&ne_pci_dev->notify_work, ne_event_work_handler);
+
+       /*
+        * This IRQ gets triggered every time any enclave's state changes. Its
+        * handler then scans for the changes and propagates them to the user
+        * space.
+        */
+       rc = request_irq(pci_irq_vector(pdev, NE_VEC_EVENT), ne_event_handler,
+                        0, "enclave_evt", ne_pci_dev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in request irq event [rc=%d]\n", rc);
+
+               goto destroy_wq;
+       }
+
+       return 0;
+
+destroy_wq:
+       destroy_workqueue(ne_pci_dev->event_wq);
+free_reply_irq_vec:
+       free_irq(pci_irq_vector(pdev, NE_VEC_REPLY), ne_pci_dev);
+free_irq_vectors:
+       pci_free_irq_vectors(pdev);
+
+       return rc;
+}
+
+/**
+ * ne_teardown_msix() - Teardown MSI-X vectors for the PCI device.
+ * @pdev:      PCI device to teardown the MSI-X for.
+ *
+ * Context: Process context.
+ */
+static void ne_teardown_msix(struct pci_dev *pdev)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       free_irq(pci_irq_vector(pdev, NE_VEC_EVENT), ne_pci_dev);
+
+       flush_work(&ne_pci_dev->notify_work);
+       flush_workqueue(ne_pci_dev->event_wq);
+       destroy_workqueue(ne_pci_dev->event_wq);
+
+       free_irq(pci_irq_vector(pdev, NE_VEC_REPLY), ne_pci_dev);
+
+       pci_free_irq_vectors(pdev);
+}
+
+/**
+ * ne_pci_dev_enable() - Select the PCI device version and enable it.
+ * @pdev:      PCI device to select version for and then enable.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_pci_dev_enable(struct pci_dev *pdev)
+{
+       u8 dev_enable_reply = 0;
+       u16 dev_version_reply = 0;
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       iowrite16(NE_VERSION_MAX, ne_pci_dev->iomem_base + NE_VERSION);
+
+       dev_version_reply = ioread16(ne_pci_dev->iomem_base + NE_VERSION);
+       if (dev_version_reply != NE_VERSION_MAX) {
+               dev_err(&pdev->dev, "Error in pci dev version cmd\n");
+
+               return -EIO;
+       }
+
+       iowrite8(NE_ENABLE_ON, ne_pci_dev->iomem_base + NE_ENABLE);
+
+       dev_enable_reply = ioread8(ne_pci_dev->iomem_base + NE_ENABLE);
+       if (dev_enable_reply != NE_ENABLE_ON) {
+               dev_err(&pdev->dev, "Error in pci dev enable cmd\n");
+
+               return -EIO;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_pci_dev_disable() - Disable the PCI device.
+ * @pdev:      PCI device to disable.
+ *
+ * Context: Process context.
+ */
+static void ne_pci_dev_disable(struct pci_dev *pdev)
+{
+       u8 dev_disable_reply = 0;
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+       const unsigned int sleep_time = 10; /* 10 ms */
+       unsigned int sleep_time_count = 0;
+
+       iowrite8(NE_ENABLE_OFF, ne_pci_dev->iomem_base + NE_ENABLE);
+
+       /*
+        * Check for NE_ENABLE_OFF in a loop, to handle cases when the device
+        * state is not immediately set to disabled and going through a
+        * transitory state of disabling.
+        */
+       while (sleep_time_count < NE_DEFAULT_TIMEOUT_MSECS) {
+               dev_disable_reply = ioread8(ne_pci_dev->iomem_base + NE_ENABLE);
+               if (dev_disable_reply == NE_ENABLE_OFF)
+                       return;
+
+               msleep_interruptible(sleep_time);
+               sleep_time_count += sleep_time;
+       }
+
+       dev_disable_reply = ioread8(ne_pci_dev->iomem_base + NE_ENABLE);
+       if (dev_disable_reply != NE_ENABLE_OFF)
+               dev_err(&pdev->dev, "Error in pci dev disable cmd\n");
+}
+
+/**
+ * ne_pci_probe() - Probe function for the NE PCI device.
+ * @pdev:      PCI device to match with the NE PCI driver.
+ * @id :       PCI device id table associated with the NE PCI driver.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+{
+       struct ne_pci_dev *ne_pci_dev = NULL;
+       int rc = -EINVAL;
+
+       ne_pci_dev = kzalloc(sizeof(*ne_pci_dev), GFP_KERNEL);
+       if (!ne_pci_dev)
+               return -ENOMEM;
+
+       rc = pci_enable_device(pdev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in pci dev enable [rc=%d]\n", rc);
+
+               goto free_ne_pci_dev;
+       }
+
+       rc = pci_request_regions_exclusive(pdev, "nitro_enclaves");
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in pci request regions [rc=%d]\n", rc);
+
+               goto disable_pci_dev;
+       }
+
+       ne_pci_dev->iomem_base = pci_iomap(pdev, PCI_BAR_NE, 0);
+       if (!ne_pci_dev->iomem_base) {
+               rc = -ENOMEM;
+
+               dev_err(&pdev->dev, "Error in pci iomap [rc=%d]\n", rc);
+
+               goto release_pci_regions;
+       }
+
+       pci_set_drvdata(pdev, ne_pci_dev);
+
+       rc = ne_setup_msix(pdev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in pci dev msix setup [rc=%d]\n", rc);
+
+               goto iounmap_pci_bar;
+       }
+
+       ne_pci_dev_disable(pdev);
+
+       rc = ne_pci_dev_enable(pdev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in ne_pci_dev enable [rc=%d]\n", rc);
+
+               goto teardown_msix;
+       }
+
+       atomic_set(&ne_pci_dev->cmd_reply_avail, 0);
+       init_waitqueue_head(&ne_pci_dev->cmd_reply_wait_q);
+       INIT_LIST_HEAD(&ne_pci_dev->enclaves_list);
+       mutex_init(&ne_pci_dev->enclaves_list_mutex);
+       mutex_init(&ne_pci_dev->pci_dev_mutex);
+       ne_pci_dev->pdev = pdev;
+
+       ne_devs.ne_pci_dev = ne_pci_dev;
+
+       rc = misc_register(ne_devs.ne_misc_dev);
+       if (rc < 0) {
+               dev_err(&pdev->dev, "Error in misc dev register [rc=%d]\n", rc);
+
+               goto disable_ne_pci_dev;
+       }
+
+       return 0;
+
+disable_ne_pci_dev:
+       ne_devs.ne_pci_dev = NULL;
+       ne_pci_dev_disable(pdev);
+teardown_msix:
+       ne_teardown_msix(pdev);
+iounmap_pci_bar:
+       pci_set_drvdata(pdev, NULL);
+       pci_iounmap(pdev, ne_pci_dev->iomem_base);
+release_pci_regions:
+       pci_release_regions(pdev);
+disable_pci_dev:
+       pci_disable_device(pdev);
+free_ne_pci_dev:
+       kfree(ne_pci_dev);
+
+       return rc;
+}
+
+/**
+ * ne_pci_remove() - Remove function for the NE PCI device.
+ * @pdev:      PCI device associated with the NE PCI driver.
+ *
+ * Context: Process context.
+ */
+static void ne_pci_remove(struct pci_dev *pdev)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       misc_deregister(ne_devs.ne_misc_dev);
+
+       ne_devs.ne_pci_dev = NULL;
+
+       ne_pci_dev_disable(pdev);
+
+       ne_teardown_msix(pdev);
+
+       pci_set_drvdata(pdev, NULL);
+
+       pci_iounmap(pdev, ne_pci_dev->iomem_base);
+
+       pci_release_regions(pdev);
+
+       pci_disable_device(pdev);
+
+       kfree(ne_pci_dev);
+}
+
+/**
+ * ne_pci_shutdown() - Shutdown function for the NE PCI device.
+ * @pdev:      PCI device associated with the NE PCI driver.
+ *
+ * Context: Process context.
+ */
+static void ne_pci_shutdown(struct pci_dev *pdev)
+{
+       struct ne_pci_dev *ne_pci_dev = pci_get_drvdata(pdev);
+
+       if (!ne_pci_dev)
+               return;
+
+       misc_deregister(ne_devs.ne_misc_dev);
+
+       ne_devs.ne_pci_dev = NULL;
+
+       ne_pci_dev_disable(pdev);
+
+       ne_teardown_msix(pdev);
+
+       pci_set_drvdata(pdev, NULL);
+
+       pci_iounmap(pdev, ne_pci_dev->iomem_base);
+
+       pci_release_regions(pdev);
+
+       pci_disable_device(pdev);
+
+       kfree(ne_pci_dev);
+}
+
+/*
+ * TODO: Add suspend / resume functions for power management w/ CONFIG_PM, if
+ * needed.
+ */
+/* NE PCI device driver. */
+struct pci_driver ne_pci_driver = {
+       .name           = "nitro_enclaves",
+       .id_table       = ne_pci_ids,
+       .probe          = ne_pci_probe,
+       .remove         = ne_pci_remove,
+       .shutdown       = ne_pci_shutdown,
+};
diff --git a/drivers/virt/nitro_enclaves/ne_pci_dev.h b/drivers/virt/nitro_enclaves/ne_pci_dev.h
new file mode 100644 (file)
index 0000000..8bfbc66
--- /dev/null
@@ -0,0 +1,327 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _NE_PCI_DEV_H_
+#define _NE_PCI_DEV_H_
+
+#include <linux/atomic.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
+#include <linux/wait.h>
+
+/**
+ * DOC: Nitro Enclaves (NE) PCI device
+ */
+
+/**
+ * PCI_DEVICE_ID_NE - Nitro Enclaves PCI device id.
+ */
+#define PCI_DEVICE_ID_NE       (0xe4c1)
+/**
+ * PCI_BAR_NE - Nitro Enclaves PCI device MMIO BAR.
+ */
+#define PCI_BAR_NE             (0x03)
+
+/**
+ * DOC: Device registers in the NE PCI device MMIO BAR
+ */
+
+/**
+ * NE_ENABLE - (1 byte) Register to notify the device that the driver is using
+ *            it (Read/Write).
+ */
+#define NE_ENABLE              (0x0000)
+#define NE_ENABLE_OFF          (0x00)
+#define NE_ENABLE_ON           (0x01)
+
+/**
+ * NE_VERSION - (2 bytes) Register to select the device run-time version
+ *             (Read/Write).
+ */
+#define NE_VERSION             (0x0002)
+#define NE_VERSION_MAX         (0x0001)
+
+/**
+ * NE_COMMAND - (4 bytes) Register to notify the device what command was
+ *             requested (Write-Only).
+ */
+#define NE_COMMAND             (0x0004)
+
+/**
+ * NE_EVTCNT - (4 bytes) Register to notify the driver that a reply or a device
+ *            event is available (Read-Only):
+ *            - Lower half  - command reply counter
+ *            - Higher half - out-of-band device event counter
+ */
+#define NE_EVTCNT              (0x000c)
+#define NE_EVTCNT_REPLY_SHIFT  (0)
+#define NE_EVTCNT_REPLY_MASK   (0x0000ffff)
+#define NE_EVTCNT_REPLY(cnt)   (((cnt) & NE_EVTCNT_REPLY_MASK) >> \
+                               NE_EVTCNT_REPLY_SHIFT)
+#define NE_EVTCNT_EVENT_SHIFT  (16)
+#define NE_EVTCNT_EVENT_MASK   (0xffff0000)
+#define NE_EVTCNT_EVENT(cnt)   (((cnt) & NE_EVTCNT_EVENT_MASK) >> \
+                               NE_EVTCNT_EVENT_SHIFT)
+
+/**
+ * NE_SEND_DATA - (240 bytes) Buffer for sending the command request payload
+ *               (Read/Write).
+ */
+#define NE_SEND_DATA           (0x0010)
+
+/**
+ * NE_RECV_DATA - (240 bytes) Buffer for receiving the command reply payload
+ *               (Read-Only).
+ */
+#define NE_RECV_DATA           (0x0100)
+
+/**
+ * DOC: Device MMIO buffer sizes
+ */
+
+/**
+ * NE_SEND_DATA_SIZE / NE_RECV_DATA_SIZE - 240 bytes for send / recv buffer.
+ */
+#define NE_SEND_DATA_SIZE      (240)
+#define NE_RECV_DATA_SIZE      (240)
+
+/**
+ * DOC: MSI-X interrupt vectors
+ */
+
+/**
+ * NE_VEC_REPLY - MSI-X vector used for command reply notification.
+ */
+#define NE_VEC_REPLY           (0)
+
+/**
+ * NE_VEC_EVENT - MSI-X vector used for out-of-band events e.g. enclave crash.
+ */
+#define NE_VEC_EVENT           (1)
+
+/**
+ * enum ne_pci_dev_cmd_type - Device command types.
+ * @INVALID_CMD:               Invalid command.
+ * @ENCLAVE_START:             Start an enclave, after setting its resources.
+ * @ENCLAVE_GET_SLOT:          Get the slot uid of an enclave.
+ * @ENCLAVE_STOP:              Terminate an enclave.
+ * @SLOT_ALLOC :               Allocate a slot for an enclave.
+ * @SLOT_FREE:                 Free the slot allocated for an enclave
+ * @SLOT_ADD_MEM:              Add a memory region to an enclave slot.
+ * @SLOT_ADD_VCPU:             Add a vCPU to an enclave slot.
+ * @SLOT_COUNT :               Get the number of allocated slots.
+ * @NEXT_SLOT:                 Get the next slot in the list of allocated slots.
+ * @SLOT_INFO:                 Get the info for a slot e.g. slot uid, vCPUs count.
+ * @SLOT_ADD_BULK_VCPUS:       Add a number of vCPUs, not providing CPU ids.
+ * @MAX_CMD:                   A gatekeeper for max possible command type.
+ */
+enum ne_pci_dev_cmd_type {
+       INVALID_CMD             = 0,
+       ENCLAVE_START           = 1,
+       ENCLAVE_GET_SLOT        = 2,
+       ENCLAVE_STOP            = 3,
+       SLOT_ALLOC              = 4,
+       SLOT_FREE               = 5,
+       SLOT_ADD_MEM            = 6,
+       SLOT_ADD_VCPU           = 7,
+       SLOT_COUNT              = 8,
+       NEXT_SLOT               = 9,
+       SLOT_INFO               = 10,
+       SLOT_ADD_BULK_VCPUS     = 11,
+       MAX_CMD,
+};
+
+/**
+ * DOC: Device commands - payload structure for requests and replies.
+ */
+
+/**
+ * struct enclave_start_req - ENCLAVE_START request.
+ * @slot_uid:          Slot unique id mapped to the enclave to start.
+ * @enclave_cid:       Context ID (CID) for the enclave vsock device.
+ *                     If 0, CID is autogenerated.
+ * @flags:             Flags for the enclave to start with (e.g. debug mode).
+ */
+struct enclave_start_req {
+       u64     slot_uid;
+       u64     enclave_cid;
+       u64     flags;
+};
+
+/**
+ * struct enclave_get_slot_req - ENCLAVE_GET_SLOT request.
+ * @enclave_cid:       Context ID (CID) for the enclave vsock device.
+ */
+struct enclave_get_slot_req {
+       u64     enclave_cid;
+};
+
+/**
+ * struct enclave_stop_req - ENCLAVE_STOP request.
+ * @slot_uid:  Slot unique id mapped to the enclave to stop.
+ */
+struct enclave_stop_req {
+       u64     slot_uid;
+};
+
+/**
+ * struct slot_alloc_req - SLOT_ALLOC request.
+ * @unused:    In order to avoid weird sizeof edge cases.
+ */
+struct slot_alloc_req {
+       u8      unused;
+};
+
+/**
+ * struct slot_free_req - SLOT_FREE request.
+ * @slot_uid:  Slot unique id mapped to the slot to free.
+ */
+struct slot_free_req {
+       u64     slot_uid;
+};
+
+/* TODO: Add flags field to the request to add memory region. */
+/**
+ * struct slot_add_mem_req - SLOT_ADD_MEM request.
+ * @slot_uid:  Slot unique id mapped to the slot to add the memory region to.
+ * @paddr:     Physical address of the memory region to add to the slot.
+ * @size:      Memory size, in bytes, of the memory region to add to the slot.
+ */
+struct slot_add_mem_req {
+       u64     slot_uid;
+       u64     paddr;
+       u64     size;
+};
+
+/**
+ * struct slot_add_vcpu_req - SLOT_ADD_VCPU request.
+ * @slot_uid:  Slot unique id mapped to the slot to add the vCPU to.
+ * @vcpu_id:   vCPU ID of the CPU to add to the enclave.
+ * @padding:   Padding for the overall data structure.
+ */
+struct slot_add_vcpu_req {
+       u64     slot_uid;
+       u32     vcpu_id;
+       u8      padding[4];
+};
+
+/**
+ * struct slot_count_req - SLOT_COUNT request.
+ * @unused:    In order to avoid weird sizeof edge cases.
+ */
+struct slot_count_req {
+       u8      unused;
+};
+
+/**
+ * struct next_slot_req - NEXT_SLOT request.
+ * @slot_uid:  Slot unique id of the next slot in the iteration.
+ */
+struct next_slot_req {
+       u64     slot_uid;
+};
+
+/**
+ * struct slot_info_req - SLOT_INFO request.
+ * @slot_uid:  Slot unique id mapped to the slot to get information about.
+ */
+struct slot_info_req {
+       u64     slot_uid;
+};
+
+/**
+ * struct slot_add_bulk_vcpus_req - SLOT_ADD_BULK_VCPUS request.
+ * @slot_uid:  Slot unique id mapped to the slot to add vCPUs to.
+ * @nr_vcpus:  Number of vCPUs to add to the slot.
+ */
+struct slot_add_bulk_vcpus_req {
+       u64     slot_uid;
+       u64     nr_vcpus;
+};
+
+/**
+ * struct ne_pci_dev_cmd_reply - NE PCI device command reply.
+ * @rc :               Return code of the logic that processed the request.
+ * @padding0:          Padding for the overall data structure.
+ * @slot_uid:          Valid for all commands except SLOT_COUNT.
+ * @enclave_cid:       Valid for ENCLAVE_START command.
+ * @slot_count :       Valid for SLOT_COUNT command.
+ * @mem_regions:       Valid for SLOT_ALLOC and SLOT_INFO commands.
+ * @mem_size:          Valid for SLOT_INFO command.
+ * @nr_vcpus:          Valid for SLOT_INFO command.
+ * @flags:             Valid for SLOT_INFO command.
+ * @state:             Valid for SLOT_INFO command.
+ * @padding1:          Padding for the overall data structure.
+ */
+struct ne_pci_dev_cmd_reply {
+       s32     rc;
+       u8      padding0[4];
+       u64     slot_uid;
+       u64     enclave_cid;
+       u64     slot_count;
+       u64     mem_regions;
+       u64     mem_size;
+       u64     nr_vcpus;
+       u64     flags;
+       u16     state;
+       u8      padding1[6];
+};
+
+/**
+ * struct ne_pci_dev - Nitro Enclaves (NE) PCI device.
+ * @cmd_reply_avail:           Variable set if a reply has been sent by the
+ *                             PCI device.
+ * @cmd_reply_wait_q:          Wait queue for handling command reply from the
+ *                             PCI device.
+ * @enclaves_list:             List of the enclaves managed by the PCI device.
+ * @enclaves_list_mutex:       Mutex for accessing the list of enclaves.
+ * @event_wq:                  Work queue for handling out-of-band events
+ *                             triggered by the Nitro Hypervisor which require
+ *                             enclave state scanning and propagation to the
+ *                             enclave process.
+ * @iomem_base :               MMIO region of the PCI device.
+ * @notify_work:               Work item for every received out-of-band event.
+ * @pci_dev_mutex:             Mutex for accessing the PCI device MMIO space.
+ * @pdev:                      PCI device data structure.
+ */
+struct ne_pci_dev {
+       atomic_t                cmd_reply_avail;
+       wait_queue_head_t       cmd_reply_wait_q;
+       struct list_head        enclaves_list;
+       struct mutex            enclaves_list_mutex;
+       struct workqueue_struct *event_wq;
+       void __iomem            *iomem_base;
+       struct work_struct      notify_work;
+       struct mutex            pci_dev_mutex;
+       struct pci_dev          *pdev;
+};
+
+/**
+ * ne_do_request() - Submit command request to the PCI device based on the command
+ *                  type and retrieve the associated reply.
+ * @pdev:              PCI device to send the command to and receive the reply from.
+ * @cmd_type:          Command type of the request sent to the PCI device.
+ * @cmd_request:       Command request payload.
+ * @cmd_request_size:  Size of the command request payload.
+ * @cmd_reply:         Command reply payload.
+ * @cmd_reply_size:    Size of the command reply payload.
+ *
+ * Context: Process context. This function uses the ne_pci_dev mutex to handle
+ *         one command at a time.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+int ne_do_request(struct pci_dev *pdev, enum ne_pci_dev_cmd_type cmd_type,
+                 void *cmd_request, size_t cmd_request_size,
+                 struct ne_pci_dev_cmd_reply *cmd_reply,
+                 size_t cmd_reply_size);
+
+/* Nitro Enclaves (NE) PCI device driver */
+extern struct pci_driver ne_pci_driver;
+
+#endif /* _NE_PCI_DEV_H_ */
index 32c2c52..6215a68 100644 (file)
@@ -35,7 +35,7 @@ static u32 vbg_misc_device_requestor(struct inode *inode)
                        VMMDEV_REQUESTOR_CON_DONT_KNOW |
                        VMMDEV_REQUESTOR_TRUST_NOT_GIVEN;
 
-       if (from_kuid(current_user_ns(), current->cred->uid) == 0)
+       if (from_kuid(current_user_ns(), current_uid()) == 0)
                requestor |= VMMDEV_REQUESTOR_USR_ROOT;
        else
                requestor |= VMMDEV_REQUESTOR_USR_USER;
index 9673eb1..f22ebe8 100644 (file)
@@ -234,7 +234,7 @@ static long sc1200wdt_ioctl(struct file *file, unsigned int cmd,
                        return -EINVAL;
                timeout = new_timeout;
                sc1200wdt_write_data(WDTO, timeout);
-               /* fall through - and return the new timeout */
+               fallthrough;    /* and return the new timeout */
 
        case WDIOC_GETTIMEOUT:
                return put_user(timeout * 60, p);
index 184a06a..c006278 100644 (file)
@@ -332,7 +332,7 @@ static long wdrtas_ioctl(struct file *file, unsigned int cmd,
                        wdrtas_interval = i;
                else
                        wdrtas_interval = wdrtas_get_interval(i);
-               /* fallthrough */
+               fallthrough;
 
        case WDIOC_GETTIMEOUT:
                return put_user(wdrtas_interval, argp);
index ea6c1e7..41645fe 100644 (file)
@@ -325,4 +325,14 @@ config XEN_HAVE_VPMU
 config XEN_FRONT_PGDIR_SHBUF
        tristate
 
+config XEN_UNPOPULATED_ALLOC
+       bool "Use unpopulated memory ranges for guest mappings"
+       depends on X86 && ZONE_DEVICE
+       default XEN_BACKEND || XEN_GNTDEV || XEN_DOM0
+       help
+         Use unpopulated memory ranges in order to create mappings for guest
+         memory regions, including grant maps and foreign pages. This avoids
+         having to balloon out RAM regions in order to obtain physical memory
+         space to create such mappings.
+
 endmenu
index c25c9a6..babdca8 100644 (file)
@@ -41,3 +41,4 @@ xen-gntdev-$(CONFIG_XEN_GNTDEV_DMABUF)        += gntdev-dmabuf.o
 xen-gntalloc-y                         := gntalloc.o
 xen-privcmd-y                          := privcmd.o privcmd-buf.o
 obj-$(CONFIG_XEN_FRONT_PGDIR_SHBUF)    += xen-front-pgdir-shbuf.o
+obj-$(CONFIG_XEN_UNPOPULATED_ALLOC)    += unpopulated-alloc.o
index 37ffccd..51427c7 100644 (file)
@@ -653,7 +653,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
 }
 EXPORT_SYMBOL(free_xenballooned_pages);
 
-#ifdef CONFIG_XEN_PV
+#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
 static void __init balloon_add_region(unsigned long start_pfn,
                                      unsigned long pages)
 {
@@ -707,7 +707,7 @@ static int __init balloon_init(void)
        register_sysctl_table(xen_root);
 #endif
 
-#ifdef CONFIG_XEN_PV
+#if defined(CONFIG_XEN_PV) && !defined(CONFIG_XEN_UNPOPULATED_ALLOC)
        {
                int i;
 
index 140c7bf..90b8f56 100644 (file)
@@ -156,7 +156,7 @@ int get_evtchn_to_irq(evtchn_port_t evtchn)
 /* Get info for IRQ */
 struct irq_info *info_for_irq(unsigned irq)
 {
-       return irq_get_handler_data(irq);
+       return irq_get_chip_data(irq);
 }
 
 /* Constructors for packed IRQ information. */
@@ -377,7 +377,7 @@ static void xen_irq_init(unsigned irq)
        info->type = IRQT_UNBOUND;
        info->refcnt = -1;
 
-       irq_set_handler_data(irq, info);
+       irq_set_chip_data(irq, info);
 
        list_add_tail(&info->list, &xen_irq_list_head);
 }
@@ -426,14 +426,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
 
 static void xen_free_irq(unsigned irq)
 {
-       struct irq_info *info = irq_get_handler_data(irq);
+       struct irq_info *info = irq_get_chip_data(irq);
 
        if (WARN_ON(!info))
                return;
 
        list_del(&info->list);
 
-       irq_set_handler_data(irq, NULL);
+       irq_set_chip_data(irq, NULL);
 
        WARN_ON(info->refcnt > 0);
 
@@ -603,7 +603,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
 static void __unbind_from_irq(unsigned int irq)
 {
        evtchn_port_t evtchn = evtchn_from_irq(irq);
-       struct irq_info *info = irq_get_handler_data(irq);
+       struct irq_info *info = irq_get_chip_data(irq);
 
        if (info->refcnt > 0) {
                info->refcnt--;
@@ -1108,7 +1108,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
 
 void unbind_from_irqhandler(unsigned int irq, void *dev_id)
 {
-       struct irq_info *info = irq_get_handler_data(irq);
+       struct irq_info *info = irq_get_chip_data(irq);
 
        if (WARN_ON(!info))
                return;
@@ -1142,7 +1142,7 @@ int evtchn_make_refcounted(evtchn_port_t evtchn)
        if (irq == -1)
                return -ENOENT;
 
-       info = irq_get_handler_data(irq);
+       info = irq_get_chip_data(irq);
 
        if (!info)
                return -ENOENT;
@@ -1170,7 +1170,7 @@ int evtchn_get(evtchn_port_t evtchn)
        if (irq == -1)
                goto done;
 
-       info = irq_get_handler_data(irq);
+       info = irq_get_chip_data(irq);
 
        if (!info)
                goto done;
index 8d06bf1..523dcdf 100644 (file)
@@ -801,7 +801,7 @@ int gnttab_alloc_pages(int nr_pages, struct page **pages)
 {
        int ret;
 
-       ret = alloc_xenballooned_pages(nr_pages, pages);
+       ret = xen_alloc_unpopulated_pages(nr_pages, pages);
        if (ret < 0)
                return ret;
 
@@ -836,7 +836,7 @@ EXPORT_SYMBOL_GPL(gnttab_pages_clear_private);
 void gnttab_free_pages(int nr_pages, struct page **pages)
 {
        gnttab_pages_clear_private(nr_pages, pages);
-       free_xenballooned_pages(nr_pages, pages);
+       xen_free_unpopulated_pages(nr_pages, pages);
 }
 EXPORT_SYMBOL_GPL(gnttab_free_pages);
 
index 63abe6c..b0c73c5 100644 (file)
@@ -424,7 +424,7 @@ static int alloc_empty_pages(struct vm_area_struct *vma, int numpgs)
        if (pages == NULL)
                return -ENOMEM;
 
-       rc = alloc_xenballooned_pages(numpgs, pages);
+       rc = xen_alloc_unpopulated_pages(numpgs, pages);
        if (rc != 0) {
                pr_warn("%s Could not alloc %d pfns rc:%d\n", __func__,
                        numpgs, rc);
@@ -895,7 +895,7 @@ static void privcmd_close(struct vm_area_struct *vma)
 
        rc = xen_unmap_domain_gfn_range(vma, numgfns, pages);
        if (rc == 0)
-               free_xenballooned_pages(numpgs, pages);
+               xen_free_unpopulated_pages(numpgs, pages);
        else
                pr_crit("unable to unmap MFN range: leaking %d pages. rc=%d\n",
                        numpgs, rc);
index b43b559..72d725a 100644 (file)
@@ -1263,7 +1263,7 @@ static void pvcalls_front_changed(struct xenbus_device *dev,
                if (dev->state == XenbusStateClosed)
                        break;
                /* Missed the backend's CLOSING state */
-               /* fall through */
+               fallthrough;
        case XenbusStateClosing:
                xenbus_frontend_closed(dev);
                break;
diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-alloc.c
new file mode 100644 (file)
index 0000000..3b98dc9
--- /dev/null
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/errno.h>
+#include <linux/gfp.h>
+#include <linux/kernel.h>
+#include <linux/mm.h>
+#include <linux/memremap.h>
+#include <linux/slab.h>
+
+#include <asm/page.h>
+
+#include <xen/page.h>
+#include <xen/xen.h>
+
+static DEFINE_MUTEX(list_lock);
+static LIST_HEAD(page_list);
+static unsigned int list_count;
+
+static int fill_list(unsigned int nr_pages)
+{
+       struct dev_pagemap *pgmap;
+       void *vaddr;
+       unsigned int i, alloc_pages = round_up(nr_pages, PAGES_PER_SECTION);
+       int ret;
+
+       pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL);
+       if (!pgmap)
+               return -ENOMEM;
+
+       pgmap->type = MEMORY_DEVICE_GENERIC;
+       pgmap->res.name = "Xen scratch";
+       pgmap->res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+
+       ret = allocate_resource(&iomem_resource, &pgmap->res,
+                               alloc_pages * PAGE_SIZE, 0, -1,
+                               PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL);
+       if (ret < 0) {
+               pr_err("Cannot allocate new IOMEM resource\n");
+               kfree(pgmap);
+               return ret;
+       }
+
+#ifdef CONFIG_XEN_HAVE_PVMMU
+        /*
+         * memremap will build page tables for the new memory so
+         * the p2m must contain invalid entries so the correct
+         * non-present PTEs will be written.
+         *
+         * If a failure occurs, the original (identity) p2m entries
+         * are not restored since this region is now known not to
+         * conflict with any devices.
+         */
+       if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+               xen_pfn_t pfn = PFN_DOWN(pgmap->res.start);
+
+               for (i = 0; i < alloc_pages; i++) {
+                       if (!set_phys_to_machine(pfn + i, INVALID_P2M_ENTRY)) {
+                               pr_warn("set_phys_to_machine() failed, no memory added\n");
+                               release_resource(&pgmap->res);
+                               kfree(pgmap);
+                               return -ENOMEM;
+                       }
+                }
+       }
+#endif
+
+       vaddr = memremap_pages(pgmap, NUMA_NO_NODE);
+       if (IS_ERR(vaddr)) {
+               pr_err("Cannot remap memory range\n");
+               release_resource(&pgmap->res);
+               kfree(pgmap);
+               return PTR_ERR(vaddr);
+       }
+
+       for (i = 0; i < alloc_pages; i++) {
+               struct page *pg = virt_to_page(vaddr + PAGE_SIZE * i);
+
+               BUG_ON(!virt_addr_valid(vaddr + PAGE_SIZE * i));
+               list_add(&pg->lru, &page_list);
+               list_count++;
+       }
+
+       return 0;
+}
+
+/**
+ * xen_alloc_unpopulated_pages - alloc unpopulated pages
+ * @nr_pages: Number of pages
+ * @pages: pages returned
+ * @return 0 on success, error otherwise
+ */
+int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages)
+{
+       unsigned int i;
+       int ret = 0;
+
+       mutex_lock(&list_lock);
+       if (list_count < nr_pages) {
+               ret = fill_list(nr_pages - list_count);
+               if (ret)
+                       goto out;
+       }
+
+       for (i = 0; i < nr_pages; i++) {
+               struct page *pg = list_first_entry_or_null(&page_list,
+                                                          struct page,
+                                                          lru);
+
+               BUG_ON(!pg);
+               list_del(&pg->lru);
+               list_count--;
+               pages[i] = pg;
+
+#ifdef CONFIG_XEN_HAVE_PVMMU
+               if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+                       ret = xen_alloc_p2m_entry(page_to_pfn(pg));
+                       if (ret < 0) {
+                               unsigned int j;
+
+                               for (j = 0; j <= i; j++) {
+                                       list_add(&pages[j]->lru, &page_list);
+                                       list_count++;
+                               }
+                               goto out;
+                       }
+               }
+#endif
+       }
+
+out:
+       mutex_unlock(&list_lock);
+       return ret;
+}
+EXPORT_SYMBOL(xen_alloc_unpopulated_pages);
+
+/**
+ * xen_free_unpopulated_pages - return unpopulated pages
+ * @nr_pages: Number of pages
+ * @pages: pages to return
+ */
+void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages)
+{
+       unsigned int i;
+
+       mutex_lock(&list_lock);
+       for (i = 0; i < nr_pages; i++) {
+               list_add(&pages[i]->lru, &page_list);
+               list_count++;
+       }
+       mutex_unlock(&list_lock);
+}
+EXPORT_SYMBOL(xen_free_unpopulated_pages);
+
+#ifdef CONFIG_XEN_PV
+static int __init init(void)
+{
+       unsigned int i;
+
+       if (!xen_domain())
+               return -ENODEV;
+
+       if (!xen_pv_domain())
+               return 0;
+
+       /*
+        * Initialize with pages from the extra memory regions (see
+        * arch/x86/xen/setup.c).
+        */
+       for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
+               unsigned int j;
+
+               for (j = 0; j < xen_extra_mem[i].n_pfns; j++) {
+                       struct page *pg =
+                               pfn_to_page(xen_extra_mem[i].start_pfn + j);
+
+                       list_add(&pg->lru, &page_list);
+                       list_count++;
+               }
+       }
+
+       return 0;
+}
+subsys_initcall(init);
+#endif
index 7457213..f914b72 100644 (file)
@@ -229,7 +229,7 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)
        case ACPI_NOTIFY_BUS_CHECK:
                ACPI_DEBUG_PRINT((ACPI_DB_INFO,
                        "\nReceived BUS CHECK notification for device\n"));
-               /* Fall Through */
+               fallthrough;
        case ACPI_NOTIFY_DEVICE_CHECK:
                if (event == ACPI_NOTIFY_DEVICE_CHECK)
                        ACPI_DEBUG_PRINT((ACPI_DB_INFO,
index f211558..b500466 100644 (file)
@@ -545,7 +545,7 @@ static void xen_pcibk_frontend_changed(struct xenbus_device *xdev,
                xenbus_switch_state(xdev, XenbusStateClosed);
                if (xenbus_dev_is_online(xdev))
                        break;
-               /* fall through - if not online */
+               fallthrough;    /* if not online */
        case XenbusStateUnknown:
                dev_dbg(&xdev->dev, "frontend is gone! unregister device\n");
                device_unregister(&xdev->dev);
index 75c0a2e..1e8cfd8 100644 (file)
@@ -1185,7 +1185,7 @@ static void scsiback_frontend_changed(struct xenbus_device *dev,
                xenbus_switch_state(dev, XenbusStateClosed);
                if (xenbus_dev_is_online(dev))
                        break;
-               /* fall through - if not online */
+               fallthrough;    /* if not online */
        case XenbusStateUnknown:
                device_unregister(&dev->dev);
                break;
index 786fbb7..2690318 100644 (file)
@@ -379,8 +379,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
        int i, j;
 
        for (i = 0; i < nr_pages; i++) {
-               err = gnttab_grant_foreign_access(dev->otherend_id,
-                                                 virt_to_gfn(vaddr), 0);
+               unsigned long gfn;
+
+               if (is_vmalloc_addr(vaddr))
+                       gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr));
+               else
+                       gfn = virt_to_gfn(vaddr);
+
+               err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0);
                if (err < 0) {
                        xenbus_dev_fatal(dev, err,
                                         "granting access to ring page");
@@ -615,7 +621,7 @@ static int xenbus_map_ring_hvm(struct xenbus_device *dev,
        bool leaked = false;
        unsigned int nr_pages = XENBUS_PAGES(nr_grefs);
 
-       err = alloc_xenballooned_pages(nr_pages, node->hvm.pages);
+       err = xen_alloc_unpopulated_pages(nr_pages, node->hvm.pages);
        if (err)
                goto out_err;
 
@@ -656,7 +662,7 @@ static int xenbus_map_ring_hvm(struct xenbus_device *dev,
                         addr, nr_pages);
  out_free_ballooned_pages:
        if (!leaked)
-               free_xenballooned_pages(nr_pages, node->hvm.pages);
+               xen_free_unpopulated_pages(nr_pages, node->hvm.pages);
  out_err:
        return err;
 }
@@ -852,7 +858,7 @@ static int xenbus_unmap_ring_hvm(struct xenbus_device *dev, void *vaddr)
                               info.addrs);
        if (!rv) {
                vunmap(vaddr);
-               free_xenballooned_pages(nr_pages, node->hvm.pages);
+               xen_free_unpopulated_pages(nr_pages, node->hvm.pages);
        }
        else
                WARN(1, "Leaking %p, size %u page(s)\n", vaddr, nr_pages);
index 1537908..4809446 100644 (file)
@@ -401,12 +401,12 @@ static void xenbus_reset_frontend(char *fe, char *be, int be_state)
        case XenbusStateConnected:
                xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateClosing);
                xenbus_reset_wait_for_backend(be, XenbusStateClosing);
-               /* fall through */
+               fallthrough;
 
        case XenbusStateClosing:
                xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateClosed);
                xenbus_reset_wait_for_backend(be, XenbusStateClosed);
-               /* fall through */
+               fallthrough;
 
        case XenbusStateClosed:
                xenbus_printf(XBT_NIL, fe, "state", "%d", XenbusStateInitialising);
index 7b1077f..34742c6 100644 (file)
@@ -232,7 +232,7 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
                kfree(pages);
                return -ENOMEM;
        }
-       rc = alloc_xenballooned_pages(nr_pages, pages);
+       rc = xen_alloc_unpopulated_pages(nr_pages, pages);
        if (rc) {
                pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
                        nr_pages, rc);
@@ -249,7 +249,7 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
        if (!vaddr) {
                pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
                        nr_pages, rc);
-               free_xenballooned_pages(nr_pages, pages);
+               xen_free_unpopulated_pages(nr_pages, pages);
                kfree(pages);
                kfree(pfns);
                return -ENOMEM;
index 92cd1d8..3576123 100644 (file)
@@ -213,7 +213,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
                break;
        default:
                WARN_ONCE(1, "unknown lock status code: %d\n", status);
-               /* fall through */
+               fallthrough;
        case P9_LOCK_ERROR:
        case P9_LOCK_GRACE:
                res = -ENOLCK;
index 30d526f..05e9634 100644 (file)
@@ -18,11 +18,11 @@ static inline unsigned int adfs_readval(unsigned char *p, int len)
 
        switch (len) {
        case 4:         val |= p[3] << 24;
-                       /* fall through */
+               fallthrough;
        case 3:         val |= p[2] << 16;
-                       /* fall through */
+               fallthrough;
        case 2:         val |= p[1] << 8;
-                       /* fall through */
+               fallthrough;
        default:        val |= p[0];
        }
        return val;
@@ -32,11 +32,11 @@ static inline void adfs_writeval(unsigned char *p, int len, unsigned int val)
 {
        switch (len) {
        case 4:         p[3] = val >> 24;
-                       /* fall through */
+               fallthrough;
        case 3:         p[2] = val >> 16;
-                       /* fall through */
+               fallthrough;
        case 2:         p[1] = val >> 8;
-                       /* fall through */
+               fallthrough;
        default:        p[0] = val;
        }
 }
index f708c45..29f11e1 100644 (file)
@@ -420,24 +420,51 @@ affs_mode_to_prot(struct inode *inode)
        u32 prot = AFFS_I(inode)->i_protect;
        umode_t mode = inode->i_mode;
 
+       /*
+        * First, clear all RWED bits for owner, group, other.
+        * Then, recalculate them afresh.
+        *
+        * We'll always clear the delete-inhibit bit for the owner, as that is
+        * the classic single-user mode AmigaOS protection bit and we need to
+        * stay compatible with all scenarios.
+        *
+        * Since multi-user AmigaOS is an extension, we'll only set the
+        * delete-allow bit if any of the other bits in the same user class
+        * (group/other) are used.
+        */
+       prot &= ~(FIBF_NOEXECUTE | FIBF_NOREAD
+                 | FIBF_NOWRITE | FIBF_NODELETE
+                 | FIBF_GRP_EXECUTE | FIBF_GRP_READ
+                 | FIBF_GRP_WRITE   | FIBF_GRP_DELETE
+                 | FIBF_OTR_EXECUTE | FIBF_OTR_READ
+                 | FIBF_OTR_WRITE   | FIBF_OTR_DELETE);
+
+       /* Classic single-user AmigaOS flags. These are inverted. */
        if (!(mode & 0100))
                prot |= FIBF_NOEXECUTE;
        if (!(mode & 0400))
                prot |= FIBF_NOREAD;
        if (!(mode & 0200))
                prot |= FIBF_NOWRITE;
+
+       /* Multi-user extended flags. Not inverted. */
        if (mode & 0010)
                prot |= FIBF_GRP_EXECUTE;
        if (mode & 0040)
                prot |= FIBF_GRP_READ;
        if (mode & 0020)
                prot |= FIBF_GRP_WRITE;
+       if (mode & 0070)
+               prot |= FIBF_GRP_DELETE;
+
        if (mode & 0001)
                prot |= FIBF_OTR_EXECUTE;
        if (mode & 0004)
                prot |= FIBF_OTR_READ;
        if (mode & 0002)
                prot |= FIBF_OTR_WRITE;
+       if (mode & 0007)
+               prot |= FIBF_OTR_DELETE;
 
        AFFS_I(inode)->i_protect = prot;
 }
index a26a0f9..d91b013 100644 (file)
@@ -429,6 +429,24 @@ static int affs_write_begin(struct file *file, struct address_space *mapping,
        return ret;
 }
 
+static int affs_write_end(struct file *file, struct address_space *mapping,
+                         loff_t pos, unsigned int len, unsigned int copied,
+                         struct page *page, void *fsdata)
+{
+       struct inode *inode = mapping->host;
+       int ret;
+
+       ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
+
+       /* Clear Archived bit on file writes, as AmigaOS would do */
+       if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) {
+               AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED;
+               mark_inode_dirty(inode);
+       }
+
+       return ret;
+}
+
 static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
 {
        return generic_block_bmap(mapping,block,affs_get_block);
@@ -438,7 +456,7 @@ const struct address_space_operations affs_aops = {
        .readpage = affs_readpage,
        .writepage = affs_writepage,
        .write_begin = affs_write_begin,
-       .write_end = generic_write_end,
+       .write_end = affs_write_end,
        .direct_IO = affs_direct_IO,
        .bmap = _affs_bmap
 };
@@ -795,6 +813,12 @@ done:
        if (tmp > inode->i_size)
                inode->i_size = AFFS_I(inode)->mmu_private = tmp;
 
+       /* Clear Archived bit on file writes, as AmigaOS would do */
+       if (AFFS_I(inode)->i_protect & FIBF_ARCHIVED) {
+               AFFS_I(inode)->i_protect &= ~FIBF_ARCHIVED;
+               mark_inode_dirty(inode);
+       }
+
 err_first_bh:
        unlock_page(page);
        put_page(page);
index a346cf7..0444121 100644 (file)
@@ -93,7 +93,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
        case ST_ROOT:
                inode->i_uid = sbi->s_uid;
                inode->i_gid = sbi->s_gid;
-               /* fall through */
+               fallthrough;
        case ST_USERDIR:
                if (be32_to_cpu(tail->stype) == ST_USERDIR ||
                    affs_test_opt(sbi->s_flags, SF_SETMODE)) {
index 47107c6..a100cd9 100644 (file)
@@ -474,7 +474,7 @@ got_root:
        case MUFS_INTLFFS:
        case MUFS_DCFFS:
                affs_set_opt(sbi->s_flags, SF_MUFS);
-               /* fall thru */
+               fallthrough;
        case FS_INTLFFS:
        case FS_DCFFS:
                affs_set_opt(sbi->s_flags, SF_INTL);
@@ -486,7 +486,7 @@ got_root:
                break;
        case MUFS_OFS:
                affs_set_opt(sbi->s_flags, SF_MUFS);
-               /* fall through */
+               fallthrough;
        case FS_OFS:
                affs_set_opt(sbi->s_flags, SF_OFS);
                sb->s_flags |= SB_NOEXEC;
@@ -494,7 +494,7 @@ got_root:
        case MUFS_DCOFS:
        case MUFS_INTLOFS:
                affs_set_opt(sbi->s_flags, SF_MUFS);
-               /* fall through */
+               fallthrough;
        case FS_DCOFS:
        case FS_INTLOFS:
                affs_set_opt(sbi->s_flags, SF_INTL);
index bef4138..a4e9e6e 100644 (file)
@@ -252,7 +252,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                call->unmarshall++;
 
                /* extract the FID array and its count in two steps */
-               /* fall through */
+               fallthrough;
        case 1:
                _debug("extract FID count");
                ret = afs_extract_data(call, true);
@@ -271,7 +271,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                afs_extract_to_buf(call, call->count * 3 * 4);
                call->unmarshall++;
 
-               /* Fall through */
+               fallthrough;
        case 2:
                _debug("extract FID array");
                ret = afs_extract_data(call, true);
@@ -297,7 +297,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                call->unmarshall++;
 
                /* extract the callback array and its count in two steps */
-               /* fall through */
+               fallthrough;
        case 3:
                _debug("extract CB count");
                ret = afs_extract_data(call, true);
@@ -312,7 +312,7 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                iov_iter_discard(&call->def_iter, READ, call->count2 * 3 * 4);
                call->unmarshall++;
 
-               /* Fall through */
+               fallthrough;
        case 4:
                _debug("extract discard %zu/%u",
                       iov_iter_count(call->iter), call->count2 * 3 * 4);
@@ -391,7 +391,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
                afs_extract_to_buf(call, 11 * sizeof(__be32));
                call->unmarshall++;
 
-               /* Fall through */
+               fallthrough;
        case 1:
                _debug("extract UUID");
                ret = afs_extract_data(call, false);
@@ -503,7 +503,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
                afs_extract_to_buf(call, 11 * sizeof(__be32));
                call->unmarshall++;
 
-               /* Fall through */
+               fallthrough;
        case 1:
                _debug("extract UUID");
                ret = afs_extract_data(call, false);
@@ -618,7 +618,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
                call->unmarshall++;
 
                /* extract the FID array and its count in two steps */
-               /* Fall through */
+               fallthrough;
        case 1:
                _debug("extract FID count");
                ret = afs_extract_data(call, true);
@@ -637,7 +637,7 @@ static int afs_deliver_yfs_cb_callback(struct afs_call *call)
                afs_extract_to_buf(call, size);
                call->unmarshall++;
 
-               /* Fall through */
+               fallthrough;
        case 2:
                _debug("extract FID array");
                ret = afs_extract_data(call, false);
index b79879a..7b784af 100644 (file)
@@ -382,15 +382,17 @@ void afs_dynroot_depopulate(struct super_block *sb)
                net->dynroot_sb = NULL;
        mutex_unlock(&net->proc_cells_lock);
 
-       inode_lock(root->d_inode);
-
-       /* Remove all the pins for dirs created for manually added cells */
-       list_for_each_entry_safe(subdir, tmp, &root->d_subdirs, d_child) {
-               if (subdir->d_fsdata) {
-                       subdir->d_fsdata = NULL;
-                       dput(subdir);
+       if (root) {
+               inode_lock(root->d_inode);
+
+               /* Remove all the pins for dirs created for manually added cells */
+               list_for_each_entry_safe(subdir, tmp, &root->d_subdirs, d_child) {
+                       if (subdir->d_fsdata) {
+                               subdir->d_fsdata = NULL;
+                               dput(subdir);
+                       }
                }
-       }
 
-       inode_unlock(root->d_inode);
+               inode_unlock(root->d_inode);
+       }
 }
index 6f6ed16..371d148 100644 (file)
@@ -311,7 +311,7 @@ int afs_page_filler(void *data, struct page *page)
        case -ENOBUFS:
                _debug("cache said ENOBUFS");
 
-               /* fall through */
+               fallthrough;
        default:
        go_on:
                req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
index ffb8575..cb3054c 100644 (file)
@@ -376,7 +376,6 @@ again:
                spin_unlock(&vnode->lock);
                return;
 
-               /* Fall through */
        default:
                /* Looks like a lock request was withdrawn. */
                spin_unlock(&vnode->lock);
index 24fd163..97cab12 100644 (file)
@@ -235,6 +235,7 @@ int afs_put_operation(struct afs_operation *op)
        afs_end_cursor(&op->ac);
        afs_put_serverlist(op->net, op->server_list);
        afs_put_volume(op->net, op->volume, afs_volume_trace_put_put_op);
+       key_put(op->key);
        kfree(op);
        return ret;
 }
index 5d9ef51..e7e98ad 100644 (file)
@@ -161,8 +161,8 @@ responded:
                }
        }
 
-       rtt_us = rxrpc_kernel_get_srtt(call->net->socket, call->rxcall);
-       if (rtt_us < server->probe.rtt) {
+       if (rxrpc_kernel_get_srtt(call->net->socket, call->rxcall, &rtt_us) &&
+           rtt_us < server->probe.rtt) {
                server->probe.rtt = rtt_us;
                server->rtt = rtt_us;
                alist->preferred = index;
index acb4d0c..1d95ed9 100644 (file)
@@ -320,7 +320,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                        call->tmp_u = htonl(0);
                        afs_extract_to_tmp(call);
                }
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data length */
        case 1:
@@ -348,7 +348,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                call->bvec[0].bv_page = req->pages[req->index];
                iov_iter_bvec(&call->def_iter, READ, call->bvec, 1, size);
                ASSERTCMP(size, <=, PAGE_SIZE);
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data */
        case 2:
@@ -375,7 +375,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                /* Discard any excess data the server gave us */
                afs_extract_discard(call, req->actual_len - req->len);
                call->unmarshall = 3;
-               /* Fall through */
+               fallthrough;
 
        case 3:
                _debug("extract discard %zu/%llu",
@@ -388,7 +388,7 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
        no_more_data:
                call->unmarshall = 4;
                afs_extract_to_buf(call, (21 + 3 + 6) * 4);
-               /* Fall through */
+               fallthrough;
 
                /* extract the metadata */
        case 4:
@@ -1343,7 +1343,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
        case 0:
                call->unmarshall++;
                afs_extract_to_buf(call, 12 * 4);
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned status record */
        case 1:
@@ -1356,7 +1356,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
                xdr_decode_AFSFetchVolumeStatus(&bp, &op->volstatus.vs);
                call->unmarshall++;
                afs_extract_to_tmp(call);
-               /* Fall through */
+               fallthrough;
 
                /* extract the volume name length */
        case 2:
@@ -1371,7 +1371,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the volume name */
        case 3:
@@ -1385,7 +1385,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
                _debug("volname '%s'", p);
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the offline message length */
        case 4:
@@ -1400,7 +1400,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the offline message */
        case 5:
@@ -1415,7 +1415,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
 
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the message of the day length */
        case 6:
@@ -1430,7 +1430,7 @@ static int afs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the message of the day */
        case 7:
@@ -1682,7 +1682,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
        case 0:
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the capabilities word count */
        case 1:
@@ -1696,7 +1696,7 @@ static int afs_deliver_fs_get_capabilities(struct afs_call *call)
                call->count2 = count;
                afs_extract_discard(call, count * sizeof(__be32));
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract capabilities words */
        case 2:
@@ -1776,7 +1776,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
        case 0:
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the file status count and array in two steps */
        case 1:
@@ -1794,7 +1794,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->unmarshall++;
        more_counts:
                afs_extract_to_buf(call, 21 * sizeof(__be32));
-               /* Fall through */
+               fallthrough;
 
        case 2:
                _debug("extract status array %u", call->count);
@@ -1824,7 +1824,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->count = 0;
                call->unmarshall++;
                afs_extract_to_tmp(call);
-               /* Fall through */
+               fallthrough;
 
                /* Extract the callback count and array in two steps */
        case 3:
@@ -1841,7 +1841,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->unmarshall++;
        more_cbs:
                afs_extract_to_buf(call, 3 * sizeof(__be32));
-               /* Fall through */
+               fallthrough;
 
        case 4:
                _debug("extract CB array");
@@ -1870,7 +1870,7 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
 
                afs_extract_to_buf(call, 6 * sizeof(__be32));
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 5:
                ret = afs_extract_data(call, false);
@@ -1974,7 +1974,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
        case 0:
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data length */
        case 1:
@@ -1992,7 +1992,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
                acl->size = call->count2;
                afs_extract_begin(call, acl->data, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data */
        case 2:
@@ -2002,7 +2002,7 @@ static int afs_deliver_fs_fetch_acl(struct afs_call *call)
 
                afs_extract_to_buf(call, (21 + 6) * 4);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the metadata */
        case 3:
index 792ac71..18042b7 100644 (file)
@@ -401,22 +401,24 @@ struct afs_vlserver {
 #define AFS_VLSERVER_FL_PROBED 0               /* The VL server has been probed */
 #define AFS_VLSERVER_FL_PROBING        1               /* VL server is being probed */
 #define AFS_VLSERVER_FL_IS_YFS 2               /* Server is YFS not AFS */
+#define AFS_VLSERVER_FL_RESPONDING 3           /* VL server is responding */
        rwlock_t                lock;           /* Lock on addresses */
        atomic_t                usage;
+       unsigned int            rtt;            /* Server's current RTT in uS */
 
        /* Probe state */
        wait_queue_head_t       probe_wq;
        atomic_t                probe_outstanding;
        spinlock_t              probe_lock;
        struct {
-               unsigned int    rtt;            /* RTT as ktime/64 */
+               unsigned int    rtt;            /* RTT in uS */
                u32             abort_code;
                short           error;
-               bool            have_result;
-               bool            responded:1;
-               bool            is_yfs:1;
-               bool            not_yfs:1;
-               bool            local_failure:1;
+               unsigned short  flags;
+#define AFS_VLSERVER_PROBE_RESPONDED           0x01 /* At least once response (may be abort) */
+#define AFS_VLSERVER_PROBE_IS_YFS              0x02 /* The peer appears to be YFS */
+#define AFS_VLSERVER_PROBE_NOT_YFS             0x04 /* The peer appears not to be YFS */
+#define AFS_VLSERVER_PROBE_LOCAL_FAILURE       0x08 /* A local failure prevented a probe */
        } probe;
 
        u16                     port;
index 5334f1b..1d1a8de 100644 (file)
@@ -120,42 +120,42 @@ void afs_prioritise_error(struct afs_error *e, int error, u32 abort_code)
                if (e->error == -ETIMEDOUT ||
                    e->error == -ETIME)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ETIMEDOUT:
        case -ETIME:
                if (e->error == -ENOMEM ||
                    e->error == -ENONET)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ENOMEM:
        case -ENONET:
                if (e->error == -ERFKILL)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ERFKILL:
                if (e->error == -EADDRNOTAVAIL)
                        return;
-               /* Fall through */
+               fallthrough;
        case -EADDRNOTAVAIL:
                if (e->error == -ENETUNREACH)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ENETUNREACH:
                if (e->error == -EHOSTUNREACH)
                        return;
-               /* Fall through */
+               fallthrough;
        case -EHOSTUNREACH:
                if (e->error == -EHOSTDOWN)
                        return;
-               /* Fall through */
+               fallthrough;
        case -EHOSTDOWN:
                if (e->error == -ECONNREFUSED)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ECONNREFUSED:
                if (e->error == -ECONNRESET)
                        return;
-               /* Fall through */
+               fallthrough;
        case -ECONNRESET: /* Responded, but call expired. */
                if (e->responded)
                        return;
index e817fc7..e8babb6 100644 (file)
@@ -310,6 +310,11 @@ static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
                                   alist->preferred == i ? '>' : '-',
                                   &alist->addrs[i].transport);
        }
+       seq_printf(m, " info: fl=%lx rtt=%d\n", vlserver->flags, vlserver->rtt);
+       seq_printf(m, " probe: fl=%x e=%d ac=%d out=%d\n",
+                  vlserver->probe.flags, vlserver->probe.error,
+                  vlserver->probe.abort_code,
+                  atomic_read(&vlserver->probe_outstanding));
        return 0;
 }
 
index 6a0935c..d83f13c 100644 (file)
@@ -281,7 +281,7 @@ bool afs_select_fileserver(struct afs_operation *op)
        case -ETIME:
                if (op->error != -EDESTADDRREQ)
                        goto iterate_address;
-               /* Fall through */
+               fallthrough;
        case -ERFKILL:
        case -EADDRNOTAVAIL:
        case -ENETUNREACH:
index 8fc8fb4..8be709c 100644 (file)
@@ -568,7 +568,7 @@ static void afs_deliver_to_call(struct afs_call *call)
                case -EIO:
                        pr_err("kAFS: Call %u in bad state %u\n",
                               call->debug_id, state);
-                       /* Fall through */
+                       fallthrough;
                case -ENODATA:
                case -EBADMSG:
                case -EMSGSIZE:
@@ -669,7 +669,7 @@ long afs_wait_for_call_to_complete(struct afs_call *call,
                ret = call->ret0;
                call->ret0 = 0;
 
-               /* Fall through */
+               fallthrough;
        case -ECONNABORTED:
                ac->responded = true;
                break;
@@ -872,7 +872,7 @@ void afs_send_empty_reply(struct afs_call *call)
                _debug("oom");
                rxrpc_kernel_abort_call(net->socket, call->rxcall,
                                        RX_USER_ABORT, -ENOMEM, "KOO");
-               /* Fall through */
+               fallthrough;
        default:
                _leave(" [error]");
                return;
index 8fea54e..38b2ba1 100644 (file)
@@ -21,6 +21,7 @@ struct afs_vlserver *afs_alloc_vlserver(const char *name, size_t name_len,
                rwlock_init(&vlserver->lock);
                init_waitqueue_head(&vlserver->probe_wq);
                spin_lock_init(&vlserver->probe_lock);
+               vlserver->rtt = UINT_MAX;
                vlserver->name_len = name_len;
                vlserver->port = port;
                memcpy(vlserver->name, name, name_len);
index e3aa013..d1c7068 100644 (file)
 #include "internal.h"
 #include "protocol_yfs.h"
 
-static bool afs_vl_probe_done(struct afs_vlserver *server)
+
+/*
+ * Handle the completion of a set of probes.
+ */
+static void afs_finished_vl_probe(struct afs_vlserver *server)
 {
-       if (!atomic_dec_and_test(&server->probe_outstanding))
-               return false;
+       if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)) {
+               server->rtt = UINT_MAX;
+               clear_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags);
+       }
 
-       wake_up_var(&server->probe_outstanding);
        clear_bit_unlock(AFS_VLSERVER_FL_PROBING, &server->flags);
        wake_up_bit(&server->flags, AFS_VLSERVER_FL_PROBING);
-       return true;
+}
+
+/*
+ * Handle the completion of a probe RPC call.
+ */
+static void afs_done_one_vl_probe(struct afs_vlserver *server, bool wake_up)
+{
+       if (atomic_dec_and_test(&server->probe_outstanding)) {
+               afs_finished_vl_probe(server);
+               wake_up = true;
+       }
+
+       if (wake_up)
+               wake_up_all(&server->probe_wq);
 }
 
 /*
@@ -45,15 +63,20 @@ void afs_vlserver_probe_result(struct afs_call *call)
                server->probe.error = 0;
                goto responded;
        case -ECONNABORTED:
-               if (!server->probe.responded) {
+               if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)) {
                        server->probe.abort_code = call->abort_code;
                        server->probe.error = ret;
                }
                goto responded;
        case -ENOMEM:
        case -ENONET:
-               server->probe.local_failure = true;
-               afs_io_error(call, afs_io_error_vl_probe_fail);
+       case -EKEYEXPIRED:
+       case -EKEYREVOKED:
+       case -EKEYREJECTED:
+               server->probe.flags |= AFS_VLSERVER_PROBE_LOCAL_FAILURE;
+               if (server->probe.error == 0)
+                       server->probe.error = ret;
+               trace_afs_io_error(call->debug_id, ret, afs_io_error_vl_probe_fail);
                goto out;
        case -ECONNRESET: /* Responded, but call expired. */
        case -ERFKILL:
@@ -67,12 +90,12 @@ void afs_vlserver_probe_result(struct afs_call *call)
        default:
                clear_bit(index, &alist->responded);
                set_bit(index, &alist->failed);
-               if (!server->probe.responded &&
+               if (!(server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED) &&
                    (server->probe.error == 0 ||
                     server->probe.error == -ETIMEDOUT ||
                     server->probe.error == -ETIME))
                        server->probe.error = ret;
-               afs_io_error(call, afs_io_error_vl_probe_fail);
+               trace_afs_io_error(call->debug_id, ret, afs_io_error_vl_probe_fail);
                goto out;
        }
 
@@ -81,39 +104,36 @@ responded:
        clear_bit(index, &alist->failed);
 
        if (call->service_id == YFS_VL_SERVICE) {
-               server->probe.is_yfs = true;
+               server->probe.flags |= AFS_VLSERVER_PROBE_IS_YFS;
                set_bit(AFS_VLSERVER_FL_IS_YFS, &server->flags);
                alist->addrs[index].srx_service = call->service_id;
        } else {
-               server->probe.not_yfs = true;
-               if (!server->probe.is_yfs) {
+               server->probe.flags |= AFS_VLSERVER_PROBE_NOT_YFS;
+               if (!(server->probe.flags & AFS_VLSERVER_PROBE_IS_YFS)) {
                        clear_bit(AFS_VLSERVER_FL_IS_YFS, &server->flags);
                        alist->addrs[index].srx_service = call->service_id;
                }
        }
 
-       rtt_us = rxrpc_kernel_get_srtt(call->net->socket, call->rxcall);
-       if (rtt_us < server->probe.rtt) {
+       if (rxrpc_kernel_get_srtt(call->net->socket, call->rxcall, &rtt_us) &&
+           rtt_us < server->probe.rtt) {
                server->probe.rtt = rtt_us;
+               server->rtt = rtt_us;
                alist->preferred = index;
-               have_result = true;
        }
 
        smp_wmb(); /* Set rtt before responded. */
-       server->probe.responded = true;
+       server->probe.flags |= AFS_VLSERVER_PROBE_RESPONDED;
        set_bit(AFS_VLSERVER_FL_PROBED, &server->flags);
+       set_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags);
+       have_result = true;
 out:
        spin_unlock(&server->probe_lock);
 
        _debug("probe [%u][%u] %pISpc rtt=%u ret=%d",
               server_index, index, &alist->addrs[index].transport, rtt_us, ret);
 
-       have_result |= afs_vl_probe_done(server);
-       if (have_result) {
-               server->probe.have_result = true;
-               wake_up_var(&server->probe.have_result);
-               wake_up_all(&server->probe_wq);
-       }
+       afs_done_one_vl_probe(server, have_result);
 }
 
 /*
@@ -151,11 +171,10 @@ static bool afs_do_probe_vlserver(struct afs_net *net,
                        in_progress = true;
                } else {
                        afs_prioritise_error(_e, PTR_ERR(call), ac.abort_code);
+                       afs_done_one_vl_probe(server, false);
                }
        }
 
-       if (!in_progress)
-               afs_vl_probe_done(server);
        return in_progress;
 }
 
@@ -193,7 +212,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
 {
        struct wait_queue_entry *waits;
        struct afs_vlserver *server;
-       unsigned int rtt = UINT_MAX;
+       unsigned int rtt = UINT_MAX, rtt_s;
        bool have_responders = false;
        int pref = -1, i;
 
@@ -205,7 +224,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
                        server = vllist->servers[i].server;
                        if (!test_bit(AFS_VLSERVER_FL_PROBING, &server->flags))
                                __clear_bit(i, &untried);
-                       if (server->probe.responded)
+                       if (server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)
                                have_responders = true;
                }
        }
@@ -231,7 +250,7 @@ int afs_wait_for_vl_probes(struct afs_vlserver_list *vllist,
                for (i = 0; i < vllist->nr_servers; i++) {
                        if (test_bit(i, &untried)) {
                                server = vllist->servers[i].server;
-                               if (server->probe.responded)
+                               if (server->probe.flags & AFS_VLSERVER_PROBE_RESPONDED)
                                        goto stop;
                                if (test_bit(AFS_VLSERVER_FL_PROBING, &server->flags))
                                        still_probing = true;
@@ -249,10 +268,11 @@ stop:
        for (i = 0; i < vllist->nr_servers; i++) {
                if (test_bit(i, &untried)) {
                        server = vllist->servers[i].server;
-                       if (server->probe.responded &&
-                           server->probe.rtt < rtt) {
+                       rtt_s = READ_ONCE(server->rtt);
+                       if (test_bit(AFS_VLSERVER_FL_RESPONDING, &server->flags) &&
+                           rtt_s < rtt) {
                                pref = i;
-                               rtt = server->probe.rtt;
+                               rtt = rtt_s;
                        }
 
                        remove_wait_queue(&server->probe_wq, &waits[i]);
index f405ca8..c0458c9 100644 (file)
@@ -192,7 +192,8 @@ pick_server:
        for (i = 0; i < vc->server_list->nr_servers; i++) {
                struct afs_vlserver *s = vc->server_list->servers[i].server;
 
-               if (!test_bit(i, &vc->untried) || !s->probe.responded)
+               if (!test_bit(i, &vc->untried) ||
+                   !test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags))
                        continue;
                if (s->probe.rtt < rtt) {
                        vc->index = i;
@@ -262,10 +263,14 @@ no_more_servers:
        for (i = 0; i < vc->server_list->nr_servers; i++) {
                struct afs_vlserver *s = vc->server_list->servers[i].server;
 
+               if (test_bit(AFS_VLSERVER_FL_RESPONDING, &s->flags))
+                       e.responded = true;
                afs_prioritise_error(&e, READ_ONCE(s->probe.error),
                                     s->probe.abort_code);
        }
 
+       error = e.error;
+
 failed_set_error:
        vc->error = error;
 failed:
index fd82850..dc93273 100644 (file)
@@ -196,7 +196,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
 
                /* Extract the returned uuid, uniquifier, nentries and
                 * blkaddrs size */
-               /* Fall through */
+               fallthrough;
        case 1:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -221,7 +221,7 @@ static int afs_deliver_vl_get_addrs_u(struct afs_call *call)
                count = min(call->count, 4U);
                afs_extract_to_buf(call, count * sizeof(__be32));
 
-               /* Fall through - and extract entries */
+               fallthrough;    /* and extract entries */
        case 2:
                ret = afs_extract_data(call, call->count > 4);
                if (ret < 0)
@@ -324,7 +324,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
                afs_extract_to_tmp(call);
                call->unmarshall++;
 
-               /* Fall through - and extract the capabilities word count */
+               fallthrough;    /* and extract the capabilities word count */
        case 1:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -337,7 +337,7 @@ static int afs_deliver_vl_get_capabilities(struct afs_call *call)
                call->unmarshall++;
                afs_extract_discard(call, count * sizeof(__be32));
 
-               /* Fall through - and extract capabilities words */
+               fallthrough;    /* and extract capabilities words */
        case 2:
                ret = afs_extract_data(call, false);
                if (ret < 0)
@@ -436,7 +436,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
                /* Extract the returned uuid, uniquifier, fsEndpoints count and
                 * either the first fsEndpoint type or the volEndpoints
                 * count if there are no fsEndpoints. */
-               /* Fall through */
+               fallthrough;
        case 1:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -475,7 +475,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
                afs_extract_to_buf(call, size);
                call->unmarshall = 2;
 
-               /* Fall through - and extract fsEndpoints[] entries */
+               fallthrough;    /* and extract fsEndpoints[] entries */
        case 2:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -526,7 +526,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
                 * extract the type of the next endpoint when we extract the
                 * data of the current one, but this is the first...
                 */
-               /* Fall through */
+               fallthrough;
        case 3:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -552,7 +552,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
                afs_extract_to_buf(call, size);
                call->unmarshall = 4;
 
-               /* Fall through - and extract volEndpoints[] entries */
+               fallthrough;    /* and extract volEndpoints[] entries */
        case 4:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -587,7 +587,7 @@ static int afs_deliver_yfsvl_get_endpoints(struct afs_call *call)
                afs_extract_discard(call, 0);
                call->unmarshall = 5;
 
-               /* Fall through - Done */
+               fallthrough;    /* Done */
        case 5:
                ret = afs_extract_data(call, false);
                if (ret < 0)
@@ -663,7 +663,7 @@ static int afs_deliver_yfsvl_get_cell_name(struct afs_call *call)
                afs_extract_to_tmp(call);
                call->unmarshall++;
 
-               /* Fall through - and extract the cell name length */
+               fallthrough;    /* and extract the cell name length */
        case 1:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -685,7 +685,7 @@ static int afs_deliver_yfsvl_get_cell_name(struct afs_call *call)
                afs_extract_begin(call, cell_name, namesz);
                call->unmarshall++;
 
-               /* Fall through - and extract cell name */
+               fallthrough;    /* and extract cell name */
        case 2:
                ret = afs_extract_data(call, true);
                if (ret < 0)
@@ -694,7 +694,7 @@ static int afs_deliver_yfsvl_get_cell_name(struct afs_call *call)
                afs_extract_discard(call, call->count2);
                call->unmarshall++;
 
-               /* Fall through - and extract padding */
+               fallthrough;    /* and extract padding */
        case 3:
                ret = afs_extract_data(call, false);
                if (ret < 0)
index a121c24..4b2265c 100644 (file)
@@ -609,7 +609,7 @@ no_more:
 
        default:
                pr_notice("kAFS: Unexpected error from FS.StoreData %d\n", ret);
-               /* Fall through */
+               fallthrough;
        case -EACCES:
        case -EPERM:
        case -ENOKEY:
index 8c24fdc..3b1239b 100644 (file)
@@ -373,7 +373,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                req->offset = req->pos & (PAGE_SIZE - 1);
                afs_extract_to_tmp64(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data length */
        case 1:
@@ -401,7 +401,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                call->bvec[0].bv_page = req->pages[req->index];
                iov_iter_bvec(&call->def_iter, READ, call->bvec, 1, size);
                ASSERTCMP(size, <=, PAGE_SIZE);
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned data */
        case 2:
@@ -428,7 +428,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                /* Discard any excess data the server gave us */
                afs_extract_discard(call, req->actual_len - req->len);
                call->unmarshall = 3;
-               /* Fall through */
+               fallthrough;
 
        case 3:
                _debug("extract discard %zu/%llu",
@@ -444,7 +444,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                                   sizeof(struct yfs_xdr_YFSFetchStatus) +
                                   sizeof(struct yfs_xdr_YFSCallBack) +
                                   sizeof(struct yfs_xdr_YFSVolSync));
-               /* Fall through */
+               fallthrough;
 
                /* extract the metadata */
        case 4:
@@ -461,7 +461,7 @@ static int yfs_deliver_fs_fetch_data64(struct afs_call *call)
                req->file_size = vp->scb.status.size;
 
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 5:
                break;
@@ -1262,7 +1262,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
        case 0:
                call->unmarshall++;
                afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSFetchVolumeStatus));
-               /* Fall through */
+               fallthrough;
 
                /* extract the returned status record */
        case 1:
@@ -1275,7 +1275,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                xdr_decode_YFSFetchVolumeStatus(&bp, &op->volstatus.vs);
                call->unmarshall++;
                afs_extract_to_tmp(call);
-               /* Fall through */
+               fallthrough;
 
                /* extract the volume name length */
        case 2:
@@ -1290,7 +1290,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the volume name */
        case 3:
@@ -1304,7 +1304,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                _debug("volname '%s'", p);
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the offline message length */
        case 4:
@@ -1319,7 +1319,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the offline message */
        case 5:
@@ -1334,7 +1334,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
 
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the message of the day length */
        case 6:
@@ -1349,7 +1349,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                size = (call->count + 3) & ~3; /* It's padded */
                afs_extract_to_buf(call, size);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the message of the day */
        case 7:
@@ -1363,7 +1363,7 @@ static int yfs_deliver_fs_get_volume_status(struct afs_call *call)
                _debug("motd '%s'", p);
 
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 8:
                break;
@@ -1622,7 +1622,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
        case 0:
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the file status count and array in two steps */
        case 1:
@@ -1640,7 +1640,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->unmarshall++;
        more_counts:
                afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSFetchStatus));
-               /* Fall through */
+               fallthrough;
 
        case 2:
                _debug("extract status array %u", call->count);
@@ -1670,7 +1670,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->count = 0;
                call->unmarshall++;
                afs_extract_to_tmp(call);
-               /* Fall through */
+               fallthrough;
 
                /* Extract the callback count and array in two steps */
        case 3:
@@ -1687,7 +1687,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
                call->unmarshall++;
        more_cbs:
                afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSCallBack));
-               /* Fall through */
+               fallthrough;
 
        case 4:
                _debug("extract CB array");
@@ -1716,7 +1716,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
 
                afs_extract_to_buf(call, sizeof(struct yfs_xdr_YFSVolSync));
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 5:
                ret = afs_extract_data(call, false);
@@ -1727,7 +1727,7 @@ static int yfs_deliver_fs_inline_bulk_status(struct afs_call *call)
                xdr_decode_YFSVolSync(&bp, &op->volsync);
 
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 6:
                break;
@@ -1804,7 +1804,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
        case 0:
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the file ACL length */
        case 1:
@@ -1826,7 +1826,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
                        afs_extract_discard(call, size);
                }
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the file ACL */
        case 2:
@@ -1836,7 +1836,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
 
                afs_extract_to_tmp(call);
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the volume ACL length */
        case 3:
@@ -1858,7 +1858,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
                        afs_extract_discard(call, size);
                }
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* Extract the volume ACL */
        case 4:
@@ -1871,7 +1871,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
                                   sizeof(struct yfs_xdr_YFSFetchStatus) +
                                   sizeof(struct yfs_xdr_YFSVolSync));
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
                /* extract the metadata */
        case 5:
@@ -1886,7 +1886,7 @@ static int yfs_deliver_fs_fetch_opaque_acl(struct afs_call *call)
                xdr_decode_YFSVolSync(&bp, &op->volsync);
 
                call->unmarshall++;
-               /* Fall through */
+               fallthrough;
 
        case 6:
                break;
index 5736bff..d5ec303 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1511,7 +1511,7 @@ static inline void aio_rw_done(struct kiocb *req, ssize_t ret)
                 * may be already running. Just fail this IO with EINTR.
                 */
                ret = -EINTR;
-               /*FALLTHRU*/
+               fallthrough;
        default:
                req->ki_complete(req, ret, 0);
        }
index f2f9086..b9c658e 100644 (file)
@@ -576,7 +576,7 @@ static int load_flat_file(struct linux_binprm *bprm,
                        goto err;
                }
 
-               len = data_len + extra;
+               len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
                len = PAGE_ALIGN(len);
                realdatastart = vm_mmap(NULL, 0, len,
                        PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0);
@@ -590,7 +590,9 @@ static int load_flat_file(struct linux_binprm *bprm,
                        vm_munmap(textpos, text_len);
                        goto err;
                }
-               datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN);
+               datapos = ALIGN(realdatastart +
+                               MAX_SHARED_LIBS * sizeof(unsigned long),
+                               FLAT_DATA_ALIGN);
 
                pr_debug("Allocated data+bss+stack (%u bytes): %lx\n",
                         data_len + bss_len + stack_len, datapos);
@@ -620,7 +622,7 @@ static int load_flat_file(struct linux_binprm *bprm,
                memp_size = len;
        } else {
 
-               len = text_len + data_len + extra;
+               len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(u32);
                len = PAGE_ALIGN(len);
                textpos = vm_mmap(NULL, 0, len,
                        PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0);
@@ -635,7 +637,9 @@ static int load_flat_file(struct linux_binprm *bprm,
                }
 
                realdatastart = textpos + ntohl(hdr->data_start);
-               datapos = ALIGN(realdatastart, FLAT_DATA_ALIGN);
+               datapos = ALIGN(realdatastart +
+                               MAX_SHARED_LIBS * sizeof(u32),
+                               FLAT_DATA_ALIGN);
 
                reloc = (__be32 __user *)
                        (datapos + (ntohl(hdr->reloc_start) - text_len));
@@ -652,9 +656,8 @@ static int load_flat_file(struct linux_binprm *bprm,
                                         (text_len + full_data
                                                  - sizeof(struct flat_hdr)),
                                         0);
-                       if (datapos != realdatastart)
-                               memmove((void *)datapos, (void *)realdatastart,
-                                               full_data);
+                       memmove((void *) datapos, (void *) realdatastart,
+                                       full_data);
 #else
                        /*
                         * This is used on MMU systems mainly for testing.
@@ -710,7 +713,8 @@ static int load_flat_file(struct linux_binprm *bprm,
                if (IS_ERR_VALUE(result)) {
                        ret = result;
                        pr_err("Unable to read code+data+bss, errno %d\n", ret);
-                       vm_munmap(textpos, text_len + data_len + extra);
+                       vm_munmap(textpos, text_len + data_len + extra +
+                               MAX_SHARED_LIBS * sizeof(u32));
                        goto err;
                }
        }
index 613920c..ea8aaf3 100644 (file)
@@ -1798,7 +1798,6 @@ static struct btrfs_block_group *btrfs_create_block_group_cache(
 
        cache->fs_info = fs_info;
        cache->full_stripe_len = btrfs_full_stripe_len(fs_info, start);
-       set_free_space_tree_thresholds(cache);
 
        cache->discard_index = BTRFS_DISCARD_INDEX_UNUSED;
 
@@ -1912,6 +1911,8 @@ static int read_one_block_group(struct btrfs_fs_info *info,
        if (ret < 0)
                goto error;
 
+       set_free_space_tree_thresholds(cache);
+
        if (need_clear) {
                /*
                 * When we mount with old space cache, we need to
@@ -2132,6 +2133,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
                return -ENOMEM;
 
        cache->length = size;
+       set_free_space_tree_thresholds(cache);
        cache->used = bytes_used;
        cache->flags = type;
        cache->last_byte_to_unpin = (u64)-1;
index 70e49d8..cd392da 100644 (file)
@@ -68,7 +68,7 @@ const char *btrfs_super_csum_driver(u16 csum_type)
                btrfs_csums[csum_type].name;
 }
 
-size_t __const btrfs_get_num_csums(void)
+size_t __attribute_const__ btrfs_get_num_csums(void)
 {
        return ARRAY_SIZE(btrfs_csums);
 }
@@ -1297,6 +1297,8 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
        btrfs_tree_read_unlock_blocking(eb);
        free_extent_buffer(eb);
 
+       btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb_rewin),
+                                      eb_rewin, btrfs_header_level(eb_rewin));
        btrfs_tree_read_lock(eb_rewin);
        __tree_mod_log_rewind(fs_info, eb_rewin, time_seq, tm);
        WARN_ON(btrfs_header_nritems(eb_rewin) >
@@ -1370,7 +1372,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
 
        if (!eb)
                return NULL;
-       btrfs_tree_read_lock(eb);
        if (old_root) {
                btrfs_set_header_bytenr(eb, eb->start);
                btrfs_set_header_backref_rev(eb, BTRFS_MIXED_BACKREF_REV);
@@ -1378,6 +1379,9 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
                btrfs_set_header_level(eb, old_root->level);
                btrfs_set_header_generation(eb, old_generation);
        }
+       btrfs_set_buffer_lockdep_class(btrfs_header_owner(eb), eb,
+                                      btrfs_header_level(eb));
+       btrfs_tree_read_lock(eb);
        if (tm)
                __tree_mod_log_rewind(fs_info, eb, time_seq, tm);
        else
index 9c7e466..9a72896 100644 (file)
@@ -2262,7 +2262,7 @@ BTRFS_SETGET_STACK_FUNCS(super_uuid_tree_generation, struct btrfs_super_block,
 int btrfs_super_csum_size(const struct btrfs_super_block *s);
 const char *btrfs_super_csum_name(u16 csum_type);
 const char *btrfs_super_csum_driver(u16 csum_type);
-size_t __const btrfs_get_num_csums(void);
+size_t __attribute_const__ btrfs_get_num_csums(void);
 
 
 /*
@@ -2518,7 +2518,7 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
                                    u64 bytenr, u64 num_bytes);
 int btrfs_exclude_logged_extents(struct extent_buffer *eb);
 int btrfs_cross_ref_exist(struct btrfs_root *root,
-                         u64 objectid, u64 offset, u64 bytenr);
+                         u64 objectid, u64 offset, u64 bytenr, bool strict);
 struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
                                             struct btrfs_root *root,
                                             u64 parent, u64 root_objectid,
@@ -2934,7 +2934,7 @@ struct extent_map *btrfs_get_extent_fiemap(struct btrfs_inode *inode,
                                           u64 start, u64 len);
 noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
                              u64 *orig_start, u64 *orig_block_len,
-                             u64 *ram_bytes);
+                             u64 *ram_bytes, bool strict);
 
 void __btrfs_del_delalloc_inode(struct btrfs_root *root,
                                struct btrfs_inode *inode);
index 9ae25f6..abf86b2 100644 (file)
@@ -3418,6 +3418,8 @@ fail_block_groups:
        btrfs_put_block_group_cache(fs_info);
 
 fail_tree_roots:
+       if (fs_info->data_reloc_root)
+               btrfs_drop_and_free_fs_root(fs_info, fs_info->data_reloc_root);
        free_root_pointers(fs_info, true);
        invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
 
@@ -4551,6 +4553,7 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group *cache)
                cache->io_ctl.inode = NULL;
                iput(inode);
        }
+       ASSERT(cache->io_ctl.pages == NULL);
        btrfs_put_block_group(cache);
 }
 
index de6fe17..780b9c9 100644 (file)
@@ -400,12 +400,11 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
                        if (type == BTRFS_SHARED_BLOCK_REF_KEY) {
                                ASSERT(eb->fs_info);
                                /*
-                                * Every shared one has parent tree
-                                * block, which must be aligned to
-                                * nodesize.
+                                * Every shared one has parent tree block,
+                                * which must be aligned to sector size.
                                 */
                                if (offset &&
-                                   IS_ALIGNED(offset, eb->fs_info->nodesize))
+                                   IS_ALIGNED(offset, eb->fs_info->sectorsize))
                                        return type;
                        }
                } else if (is_data == BTRFS_REF_TYPE_DATA) {
@@ -414,12 +413,11 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
                        if (type == BTRFS_SHARED_DATA_REF_KEY) {
                                ASSERT(eb->fs_info);
                                /*
-                                * Every shared one has parent tree
-                                * block, which must be aligned to
-                                * nodesize.
+                                * Every shared one has parent tree block,
+                                * which must be aligned to sector size.
                                 */
                                if (offset &&
-                                   IS_ALIGNED(offset, eb->fs_info->nodesize))
+                                   IS_ALIGNED(offset, eb->fs_info->sectorsize))
                                        return type;
                        }
                } else {
@@ -429,8 +427,9 @@ int btrfs_get_extent_inline_ref_type(const struct extent_buffer *eb,
        }
 
        btrfs_print_leaf((struct extent_buffer *)eb);
-       btrfs_err(eb->fs_info, "eb %llu invalid extent inline ref type %d",
-                 eb->start, type);
+       btrfs_err(eb->fs_info,
+                 "eb %llu iref 0x%lx invalid extent inline ref type %d",
+                 eb->start, (unsigned long)iref, type);
        WARN_ON(1);
 
        return BTRFS_REF_TYPE_INVALID;
@@ -2306,7 +2305,8 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
 
 static noinline int check_committed_ref(struct btrfs_root *root,
                                        struct btrfs_path *path,
-                                       u64 objectid, u64 offset, u64 bytenr)
+                                       u64 objectid, u64 offset, u64 bytenr,
+                                       bool strict)
 {
        struct btrfs_fs_info *fs_info = root->fs_info;
        struct btrfs_root *extent_root = fs_info->extent_root;
@@ -2348,9 +2348,13 @@ static noinline int check_committed_ref(struct btrfs_root *root,
            btrfs_extent_inline_ref_size(BTRFS_EXTENT_DATA_REF_KEY))
                goto out;
 
-       /* If extent created before last snapshot => it's definitely shared */
-       if (btrfs_extent_generation(leaf, ei) <=
-           btrfs_root_last_snapshot(&root->root_item))
+       /*
+        * If extent created before last snapshot => it's shared unless the
+        * snapshot has been deleted. Use the heuristic if strict is false.
+        */
+       if (!strict &&
+           (btrfs_extent_generation(leaf, ei) <=
+            btrfs_root_last_snapshot(&root->root_item)))
                goto out;
 
        iref = (struct btrfs_extent_inline_ref *)(ei + 1);
@@ -2375,7 +2379,7 @@ out:
 }
 
 int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
-                         u64 bytenr)
+                         u64 bytenr, bool strict)
 {
        struct btrfs_path *path;
        int ret;
@@ -2386,7 +2390,7 @@ int btrfs_cross_ref_exist(struct btrfs_root *root, u64 objectid, u64 offset,
 
        do {
                ret = check_committed_ref(root, path, objectid,
-                                         offset, bytenr);
+                                         offset, bytenr, strict);
                if (ret && ret != -ENOENT)
                        goto out;
 
@@ -4522,7 +4526,7 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
                return ERR_PTR(-EUCLEAN);
        }
 
-       btrfs_set_buffer_lockdep_class(root->root_key.objectid, buf, level);
+       btrfs_set_buffer_lockdep_class(owner, buf, level);
        btrfs_tree_lock(buf);
        btrfs_clean_tree_block(buf);
        clear_bit(EXTENT_BUFFER_STALE, &buf->bflags);
index 6def411..a940edb 100644 (file)
@@ -5655,9 +5655,9 @@ void read_extent_buffer(const struct extent_buffer *eb, void *dstv,
        }
 }
 
-int read_extent_buffer_to_user(const struct extent_buffer *eb,
-                              void __user *dstv,
-                              unsigned long start, unsigned long len)
+int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb,
+                                      void __user *dstv,
+                                      unsigned long start, unsigned long len)
 {
        size_t cur;
        size_t offset;
@@ -5677,7 +5677,7 @@ int read_extent_buffer_to_user(const struct extent_buffer *eb,
 
                cur = min(len, (PAGE_SIZE - offset));
                kaddr = page_address(page);
-               if (copy_to_user(dst, kaddr + offset, cur)) {
+               if (copy_to_user_nofault(dst, kaddr + offset, cur)) {
                        ret = -EFAULT;
                        break;
                }
index 00a88f2..30794ae 100644 (file)
@@ -241,9 +241,9 @@ int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv,
 void read_extent_buffer(const struct extent_buffer *eb, void *dst,
                        unsigned long start,
                        unsigned long len);
-int read_extent_buffer_to_user(const struct extent_buffer *eb,
-                              void __user *dst, unsigned long start,
-                              unsigned long len);
+int read_extent_buffer_to_user_nofault(const struct extent_buffer *eb,
+                                      void __user *dst, unsigned long start,
+                                      unsigned long len);
 void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src);
 void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
                const void *src);
index bb824c7..4507c3d 100644 (file)
@@ -1571,7 +1571,7 @@ static int check_can_nocow(struct btrfs_inode *inode, loff_t pos,
        }
 
        ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes,
-                       NULL, NULL, NULL);
+                       NULL, NULL, NULL, false);
        if (ret <= 0) {
                ret = 0;
                if (!nowait)
index ef0fd7a..dc82fd0 100644 (file)
@@ -1186,7 +1186,6 @@ static int __btrfs_wait_cache_io(struct btrfs_root *root,
        ret = update_cache_item(trans, root, inode, path, offset,
                                io_ctl->entries, io_ctl->bitmaps);
 out:
-       io_ctl_free(io_ctl);
        if (ret) {
                invalidate_inode_pages2(inode->i_mapping);
                BTRFS_I(inode)->generation = 0;
@@ -1347,6 +1346,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
         * them out later
         */
        io_ctl_drop_pages(io_ctl);
+       io_ctl_free(io_ctl);
 
        unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
                             i_size_read(inode) - 1, &cached_state);
index 8b1f5c8..6b9faf3 100644 (file)
@@ -22,6 +22,10 @@ void set_free_space_tree_thresholds(struct btrfs_block_group *cache)
        size_t bitmap_size;
        u64 num_bitmaps, total_bitmap_size;
 
+       if (WARN_ON(cache->length == 0))
+               btrfs_warn(cache->fs_info, "block group %llu length is zero",
+                          cache->start);
+
        /*
         * We convert to bitmaps when the disk space required for using extents
         * exceeds that required for using bitmaps.
index 51fcd82..9570458 100644 (file)
@@ -1610,7 +1610,7 @@ next_slot:
                                goto out_check;
                        ret = btrfs_cross_ref_exist(root, ino,
                                                    found_key.offset -
-                                                   extent_offset, disk_bytenr);
+                                                   extent_offset, disk_bytenr, false);
                        if (ret) {
                                /*
                                 * ret could be -EIO if the above fails to read
@@ -2161,11 +2161,8 @@ static blk_status_t btrfs_submit_bio_start(void *private_data, struct bio *bio,
                                    u64 bio_offset)
 {
        struct inode *inode = private_data;
-       blk_status_t ret = 0;
 
-       ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
-       BUG_ON(ret); /* -ENOMEM */
-       return 0;
+       return btrfs_csum_one_bio(BTRFS_I(inode), bio, 0, 0);
 }
 
 /*
@@ -6953,6 +6950,8 @@ static struct extent_map *btrfs_new_extent_direct(struct btrfs_inode *inode,
  * @orig_start:        (optional) Return the original file offset of the file extent
  * @orig_len:  (optional) Return the original on-disk length of the file extent
  * @ram_bytes: (optional) Return the ram_bytes of the file extent
+ * @strict:    if true, omit optimizations that might force us into unnecessary
+ *             cow. e.g., don't trust generation number.
  *
  * This function will flush ordered extents in the range to ensure proper
  * nocow checks for (nowait == false) case.
@@ -6967,7 +6966,7 @@ static struct extent_map *btrfs_new_extent_direct(struct btrfs_inode *inode,
  */
 noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
                              u64 *orig_start, u64 *orig_block_len,
-                             u64 *ram_bytes)
+                             u64 *ram_bytes, bool strict)
 {
        struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
        struct btrfs_path *path;
@@ -7045,8 +7044,9 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
         * Do the same check as in btrfs_cross_ref_exist but without the
         * unnecessary search.
         */
-       if (btrfs_file_extent_generation(leaf, fi) <=
-           btrfs_root_last_snapshot(&root->root_item))
+       if (!strict &&
+           (btrfs_file_extent_generation(leaf, fi) <=
+            btrfs_root_last_snapshot(&root->root_item)))
                goto out;
 
        backref_offset = btrfs_file_extent_offset(leaf, fi);
@@ -7082,7 +7082,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
         */
 
        ret = btrfs_cross_ref_exist(root, btrfs_ino(BTRFS_I(inode)),
-                                   key.offset - backref_offset, disk_bytenr);
+                                   key.offset - backref_offset, disk_bytenr,
+                                   strict);
        if (ret) {
                ret = 0;
                goto out;
@@ -7303,7 +7304,7 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
                block_start = em->block_start + (start - em->start);
 
                if (can_nocow_extent(inode, start, &len, &orig_start,
-                                    &orig_block_len, &ram_bytes) == 1 &&
+                                    &orig_block_len, &ram_bytes, false) == 1 &&
                    btrfs_inc_nocow_writers(fs_info, block_start)) {
                        struct extent_map *em2;
 
@@ -7619,10 +7620,8 @@ static blk_status_t btrfs_submit_bio_start_direct_io(void *private_data,
                                    struct bio *bio, u64 offset)
 {
        struct inode *inode = private_data;
-       blk_status_t ret;
-       ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, offset, 1);
-       BUG_ON(ret); /* -ENOMEM */
-       return 0;
+
+       return btrfs_csum_one_bio(BTRFS_I(inode), bio, offset, 1);
 }
 
 static void btrfs_end_dio_bio(struct bio *bio)
@@ -10136,7 +10135,7 @@ static int btrfs_swap_activate(struct swap_info_struct *sis, struct file *file,
                free_extent_map(em);
                em = NULL;
 
-               ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL);
+               ret = can_nocow_extent(inode, start, &len, NULL, NULL, NULL, true);
                if (ret < 0) {
                        goto out;
                } else if (ret) {
index bd3511c..ac45f02 100644 (file)
@@ -2086,9 +2086,14 @@ static noinline int copy_to_sk(struct btrfs_path *path,
                sh.len = item_len;
                sh.transid = found_transid;
 
-               /* copy search result header */
-               if (copy_to_user(ubuf + *sk_offset, &sh, sizeof(sh))) {
-                       ret = -EFAULT;
+               /*
+                * Copy search result header. If we fault then loop again so we
+                * can fault in the pages and -EFAULT there if there's a
+                * problem. Otherwise we'll fault and then copy the buffer in
+                * properly this next time through
+                */
+               if (copy_to_user_nofault(ubuf + *sk_offset, &sh, sizeof(sh))) {
+                       ret = 0;
                        goto out;
                }
 
@@ -2096,10 +2101,14 @@ static noinline int copy_to_sk(struct btrfs_path *path,
 
                if (item_len) {
                        char __user *up = ubuf + *sk_offset;
-                       /* copy the item */
-                       if (read_extent_buffer_to_user(leaf, up,
-                                                      item_off, item_len)) {
-                               ret = -EFAULT;
+                       /*
+                        * Copy the item, same behavior as above, but reset the
+                        * * sk_offset so we copy the full thing again.
+                        */
+                       if (read_extent_buffer_to_user_nofault(leaf, up,
+                                               item_off, item_len)) {
+                               ret = 0;
+                               *sk_offset -= sizeof(sh);
                                goto out;
                        }
 
@@ -2184,6 +2193,10 @@ static noinline int search_ioctl(struct inode *inode,
        key.offset = sk->min_offset;
 
        while (1) {
+               ret = fault_in_pages_writeable(ubuf, *buf_size - sk_offset);
+               if (ret)
+                       break;
+
                ret = btrfs_search_forward(root, &key, path, sk->min_transid);
                if (ret != 0) {
                        if (ret > 0)
index 61f44e7..80567c1 100644 (file)
@@ -95,9 +95,10 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
                         * offset is supposed to be a tree block which
                         * must be aligned to nodesize.
                         */
-                       if (!IS_ALIGNED(offset, eb->fs_info->nodesize))
-                               pr_info("\t\t\t(parent %llu is NOT ALIGNED to nodesize %llu)\n",
-                                       offset, (unsigned long long)eb->fs_info->nodesize);
+                       if (!IS_ALIGNED(offset, eb->fs_info->sectorsize))
+                               pr_info(
+                       "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
+                                       offset, eb->fs_info->sectorsize);
                        break;
                case BTRFS_EXTENT_DATA_REF_KEY:
                        dref = (struct btrfs_extent_data_ref *)(&iref->offset);
@@ -112,8 +113,9 @@ static void print_extent_item(struct extent_buffer *eb, int slot, int type)
                         * must be aligned to nodesize.
                         */
                        if (!IS_ALIGNED(offset, eb->fs_info->nodesize))
-                               pr_info("\t\t\t(parent %llu is NOT ALIGNED to nodesize %llu)\n",
-                                    offset, (unsigned long long)eb->fs_info->nodesize);
+                               pr_info(
+                       "\t\t\t(parent %llu not aligned to sectorsize %u)\n",
+                                    offset, eb->fs_info->sectorsize);
                        break;
                default:
                        pr_cont("(extent %llu has INVALID ref type %d)\n",
index 5a6cb9d..354ab99 100644 (file)
@@ -3716,50 +3716,84 @@ static noinline_for_stack int scrub_supers(struct scrub_ctx *sctx,
        return 0;
 }
 
+static void scrub_workers_put(struct btrfs_fs_info *fs_info)
+{
+       if (refcount_dec_and_mutex_lock(&fs_info->scrub_workers_refcnt,
+                                       &fs_info->scrub_lock)) {
+               struct btrfs_workqueue *scrub_workers = NULL;
+               struct btrfs_workqueue *scrub_wr_comp = NULL;
+               struct btrfs_workqueue *scrub_parity = NULL;
+
+               scrub_workers = fs_info->scrub_workers;
+               scrub_wr_comp = fs_info->scrub_wr_completion_workers;
+               scrub_parity = fs_info->scrub_parity_workers;
+
+               fs_info->scrub_workers = NULL;
+               fs_info->scrub_wr_completion_workers = NULL;
+               fs_info->scrub_parity_workers = NULL;
+               mutex_unlock(&fs_info->scrub_lock);
+
+               btrfs_destroy_workqueue(scrub_workers);
+               btrfs_destroy_workqueue(scrub_wr_comp);
+               btrfs_destroy_workqueue(scrub_parity);
+       }
+}
+
 /*
  * get a reference count on fs_info->scrub_workers. start worker if necessary
  */
 static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
                                                int is_dev_replace)
 {
+       struct btrfs_workqueue *scrub_workers = NULL;
+       struct btrfs_workqueue *scrub_wr_comp = NULL;
+       struct btrfs_workqueue *scrub_parity = NULL;
        unsigned int flags = WQ_FREEZABLE | WQ_UNBOUND;
        int max_active = fs_info->thread_pool_size;
+       int ret = -ENOMEM;
 
-       lockdep_assert_held(&fs_info->scrub_lock);
+       if (refcount_inc_not_zero(&fs_info->scrub_workers_refcnt))
+               return 0;
 
-       if (refcount_read(&fs_info->scrub_workers_refcnt) == 0) {
-               ASSERT(fs_info->scrub_workers == NULL);
-               fs_info->scrub_workers = btrfs_alloc_workqueue(fs_info, "scrub",
-                               flags, is_dev_replace ? 1 : max_active, 4);
-               if (!fs_info->scrub_workers)
-                       goto fail_scrub_workers;
-
-               ASSERT(fs_info->scrub_wr_completion_workers == NULL);
-               fs_info->scrub_wr_completion_workers =
-                       btrfs_alloc_workqueue(fs_info, "scrubwrc", flags,
-                                             max_active, 2);
-               if (!fs_info->scrub_wr_completion_workers)
-                       goto fail_scrub_wr_completion_workers;
+       scrub_workers = btrfs_alloc_workqueue(fs_info, "scrub", flags,
+                                             is_dev_replace ? 1 : max_active, 4);
+       if (!scrub_workers)
+               goto fail_scrub_workers;
 
-               ASSERT(fs_info->scrub_parity_workers == NULL);
-               fs_info->scrub_parity_workers =
-                       btrfs_alloc_workqueue(fs_info, "scrubparity", flags,
+       scrub_wr_comp = btrfs_alloc_workqueue(fs_info, "scrubwrc", flags,
                                              max_active, 2);
-               if (!fs_info->scrub_parity_workers)
-                       goto fail_scrub_parity_workers;
+       if (!scrub_wr_comp)
+               goto fail_scrub_wr_completion_workers;
 
+       scrub_parity = btrfs_alloc_workqueue(fs_info, "scrubparity", flags,
+                                            max_active, 2);
+       if (!scrub_parity)
+               goto fail_scrub_parity_workers;
+
+       mutex_lock(&fs_info->scrub_lock);
+       if (refcount_read(&fs_info->scrub_workers_refcnt) == 0) {
+               ASSERT(fs_info->scrub_workers == NULL &&
+                      fs_info->scrub_wr_completion_workers == NULL &&
+                      fs_info->scrub_parity_workers == NULL);
+               fs_info->scrub_workers = scrub_workers;
+               fs_info->scrub_wr_completion_workers = scrub_wr_comp;
+               fs_info->scrub_parity_workers = scrub_parity;
                refcount_set(&fs_info->scrub_workers_refcnt, 1);
-       } else {
-               refcount_inc(&fs_info->scrub_workers_refcnt);
+               mutex_unlock(&fs_info->scrub_lock);
+               return 0;
        }
-       return 0;
+       /* Other thread raced in and created the workers for us */
+       refcount_inc(&fs_info->scrub_workers_refcnt);
+       mutex_unlock(&fs_info->scrub_lock);
 
+       ret = 0;
+       btrfs_destroy_workqueue(scrub_parity);
 fail_scrub_parity_workers:
-       btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers);
+       btrfs_destroy_workqueue(scrub_wr_comp);
 fail_scrub_wr_completion_workers:
-       btrfs_destroy_workqueue(fs_info->scrub_workers);
+       btrfs_destroy_workqueue(scrub_workers);
 fail_scrub_workers:
-       return -ENOMEM;
+       return ret;
 }
 
 int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
@@ -3770,9 +3804,6 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
        int ret;
        struct btrfs_device *dev;
        unsigned int nofs_flag;
-       struct btrfs_workqueue *scrub_workers = NULL;
-       struct btrfs_workqueue *scrub_wr_comp = NULL;
-       struct btrfs_workqueue *scrub_parity = NULL;
 
        if (btrfs_fs_closing(fs_info))
                return -EAGAIN;
@@ -3819,13 +3850,17 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
        if (IS_ERR(sctx))
                return PTR_ERR(sctx);
 
+       ret = scrub_workers_get(fs_info, is_dev_replace);
+       if (ret)
+               goto out_free_ctx;
+
        mutex_lock(&fs_info->fs_devices->device_list_mutex);
        dev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL, true);
        if (!dev || (test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) &&
                     !is_dev_replace)) {
                mutex_unlock(&fs_info->fs_devices->device_list_mutex);
                ret = -ENODEV;
-               goto out_free_ctx;
+               goto out;
        }
 
        if (!is_dev_replace && !readonly &&
@@ -3834,7 +3869,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
                btrfs_err_in_rcu(fs_info, "scrub: device %s is not writable",
                                rcu_str_deref(dev->name));
                ret = -EROFS;
-               goto out_free_ctx;
+               goto out;
        }
 
        mutex_lock(&fs_info->scrub_lock);
@@ -3843,7 +3878,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
                mutex_unlock(&fs_info->scrub_lock);
                mutex_unlock(&fs_info->fs_devices->device_list_mutex);
                ret = -EIO;
-               goto out_free_ctx;
+               goto out;
        }
 
        down_read(&fs_info->dev_replace.rwsem);
@@ -3854,17 +3889,10 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
                mutex_unlock(&fs_info->scrub_lock);
                mutex_unlock(&fs_info->fs_devices->device_list_mutex);
                ret = -EINPROGRESS;
-               goto out_free_ctx;
+               goto out;
        }
        up_read(&fs_info->dev_replace.rwsem);
 
-       ret = scrub_workers_get(fs_info, is_dev_replace);
-       if (ret) {
-               mutex_unlock(&fs_info->scrub_lock);
-               mutex_unlock(&fs_info->fs_devices->device_list_mutex);
-               goto out_free_ctx;
-       }
-
        sctx->readonly = readonly;
        dev->scrub_ctx = sctx;
        mutex_unlock(&fs_info->fs_devices->device_list_mutex);
@@ -3917,24 +3945,14 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 
        mutex_lock(&fs_info->scrub_lock);
        dev->scrub_ctx = NULL;
-       if (refcount_dec_and_test(&fs_info->scrub_workers_refcnt)) {
-               scrub_workers = fs_info->scrub_workers;
-               scrub_wr_comp = fs_info->scrub_wr_completion_workers;
-               scrub_parity = fs_info->scrub_parity_workers;
-
-               fs_info->scrub_workers = NULL;
-               fs_info->scrub_wr_completion_workers = NULL;
-               fs_info->scrub_parity_workers = NULL;
-       }
        mutex_unlock(&fs_info->scrub_lock);
 
-       btrfs_destroy_workqueue(scrub_workers);
-       btrfs_destroy_workqueue(scrub_wr_comp);
-       btrfs_destroy_workqueue(scrub_parity);
+       scrub_workers_put(fs_info);
        scrub_put_ctx(sctx);
 
        return ret;
-
+out:
+       scrub_workers_put(fs_info);
 out_free_ctx:
        scrub_free_ctx(sctx);
 
index e529ddb..25967ec 100644 (file)
@@ -625,6 +625,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options,
                        } else if (strncmp(args[0].from, "lzo", 3) == 0) {
                                compress_type = "lzo";
                                info->compress_type = BTRFS_COMPRESS_LZO;
+                               info->compress_level = 0;
                                btrfs_set_opt(info->mount_opt, COMPRESS);
                                btrfs_clear_opt(info->mount_opt, NODATACOW);
                                btrfs_clear_opt(info->mount_opt, NODATASUM);
index 20c6ac1..d2fc292 100644 (file)
@@ -1636,6 +1636,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        pending->snap = btrfs_get_new_fs_root(fs_info, objectid, pending->anon_dev);
        if (IS_ERR(pending->snap)) {
                ret = PTR_ERR(pending->snap);
+               pending->snap = NULL;
                btrfs_abort_transaction(trans, ret);
                goto fail;
        }
index 517b443..7b1fee6 100644 (file)
@@ -984,7 +984,7 @@ static int check_inode_item(struct extent_buffer *leaf,
        /* Note for ROOT_TREE_DIR_ITEM, mkfs could set its transid 0 */
        if (btrfs_inode_transid(leaf, iitem) > super_gen + 1) {
                inode_item_err(leaf, slot,
-                       "invalid inode generation: has %llu expect [0, %llu]",
+                       "invalid inode transid: has %llu expect [0, %llu]",
                               btrfs_inode_transid(leaf, iitem), super_gen + 1);
                return -EUCLEAN;
        }
index 696dd86..39da9db 100644 (file)
@@ -3449,11 +3449,13 @@ fail:
        btrfs_free_path(path);
 out_unlock:
        mutex_unlock(&dir->log_mutex);
-       if (ret == -ENOSPC) {
+       if (err == -ENOSPC) {
                btrfs_set_log_full_commit(trans);
-               ret = 0;
-       } else if (ret < 0)
-               btrfs_abort_transaction(trans, ret);
+               err = 0;
+       } else if (err < 0 && err != -ENOENT) {
+               /* ENOENT can be returned if the entry hasn't been fsynced yet */
+               btrfs_abort_transaction(trans, err);
+       }
 
        btrfs_end_log_trans(root);
 
index ee96c58..117b433 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <linux/sched.h>
+#include <linux/sched/mm.h>
 #include <linux/bio.h>
 #include <linux/slab.h>
 #include <linux/blkdev.h>
@@ -4462,6 +4463,7 @@ int btrfs_uuid_scan_kthread(void *data)
                        goto skip;
                }
 update_tree:
+               btrfs_release_path(path);
                if (!btrfs_is_empty_uuid(root_item.uuid)) {
                        ret = btrfs_uuid_tree_add(trans, root_item.uuid,
                                                  BTRFS_UUID_KEY_SUBVOL,
@@ -4486,6 +4488,7 @@ update_tree:
                }
 
 skip:
+               btrfs_release_path(path);
                if (trans) {
                        ret = btrfs_end_transaction(trans);
                        trans = NULL;
@@ -4493,7 +4496,6 @@ skip:
                                break;
                }
 
-               btrfs_release_path(path);
                if (key.offset < (u64)-1) {
                        key.offset++;
                } else if (key.type < BTRFS_ROOT_ITEM_KEY) {
@@ -6483,8 +6485,17 @@ static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices,
                                            u64 devid, u8 *dev_uuid)
 {
        struct btrfs_device *device;
+       unsigned int nofs_flag;
 
+       /*
+        * We call this under the chunk_mutex, so we want to use NOFS for this
+        * allocation, however we don't want to change btrfs_alloc_device() to
+        * always do NOFS because we use it in a lot of other GFP_KERNEL safe
+        * places.
+        */
+       nofs_flag = memalloc_nofs_save();
        device = btrfs_alloc_device(NULL, &devid, dev_uuid);
+       memalloc_nofs_restore(nofs_flag);
        if (IS_ERR(device))
                return device;
 
index 061dd20..50bbc99 100644 (file)
@@ -1958,7 +1958,7 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
                 */
                set_buffer_new(bh);
                set_buffer_unwritten(bh);
-               /* FALLTHRU */
+               fallthrough;
        case IOMAP_MAPPED:
                if ((iomap->flags & IOMAP_F_NEW) ||
                    offset >= i_size_read(inode))
@@ -3157,6 +3157,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
        WARN_ON(atomic_read(&bh->b_count) < 1);
        lock_buffer(bh);
        if (test_clear_buffer_dirty(bh)) {
+               /*
+                * The bh should be mapped, but it might not be if the
+                * device was hot-removed. Not much we can do but fail the I/O.
+                */
+               if (!buffer_mapped(bh)) {
+                       unlock_buffer(bh);
+                       return -EIO;
+               }
+
                get_bh(bh);
                bh->b_end_io = end_buffer_write_sync;
                ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
index 55ccccf..034b3f4 100644 (file)
@@ -887,8 +887,8 @@ int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch)
        int have = ci->i_snap_caps;
 
        if ((have & mask) == mask) {
-               dout("__ceph_caps_issued_mask ino 0x%lx snap issued %s"
-                    " (mask %s)\n", ci->vfs_inode.i_ino,
+               dout("__ceph_caps_issued_mask ino 0x%llx snap issued %s"
+                    " (mask %s)\n", ceph_ino(&ci->vfs_inode),
                     ceph_cap_string(have),
                     ceph_cap_string(mask));
                return 1;
@@ -899,8 +899,8 @@ int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch)
                if (!__cap_is_valid(cap))
                        continue;
                if ((cap->issued & mask) == mask) {
-                       dout("__ceph_caps_issued_mask ino 0x%lx cap %p issued %s"
-                            " (mask %s)\n", ci->vfs_inode.i_ino, cap,
+                       dout("__ceph_caps_issued_mask ino 0x%llx cap %p issued %s"
+                            " (mask %s)\n", ceph_ino(&ci->vfs_inode), cap,
                             ceph_cap_string(cap->issued),
                             ceph_cap_string(mask));
                        if (touch)
@@ -911,8 +911,8 @@ int __ceph_caps_issued_mask(struct ceph_inode_info *ci, int mask, int touch)
                /* does a combination of caps satisfy mask? */
                have |= cap->issued;
                if ((have & mask) == mask) {
-                       dout("__ceph_caps_issued_mask ino 0x%lx combo issued %s"
-                            " (mask %s)\n", ci->vfs_inode.i_ino,
+                       dout("__ceph_caps_issued_mask ino 0x%llx combo issued %s"
+                            " (mask %s)\n", ceph_ino(&ci->vfs_inode),
                             ceph_cap_string(cap->issued),
                             ceph_cap_string(mask));
                        if (touch) {
@@ -2872,7 +2872,7 @@ int ceph_get_caps(struct file *filp, int need, int want,
                        struct cap_wait cw;
                        DEFINE_WAIT_FUNC(wait, woken_wake_function);
 
-                       cw.ino = inode->i_ino;
+                       cw.ino = ceph_ino(inode);
                        cw.tgid = current->tgid;
                        cw.need = need;
                        cw.want = want;
index 97539b4..3e3fcda 100644 (file)
@@ -202,7 +202,7 @@ static int caps_show_cb(struct inode *inode, struct ceph_cap *cap, void *p)
 {
        struct seq_file *s = p;
 
-       seq_printf(s, "0x%-17lx%-17s%-17s\n", inode->i_ino,
+       seq_printf(s, "0x%-17llx%-17s%-17s\n", ceph_ino(inode),
                   ceph_cap_string(cap->issued),
                   ceph_cap_string(cap->implemented));
        return 0;
@@ -247,7 +247,7 @@ static int caps_show(struct seq_file *s, void *p)
 
        spin_lock(&mdsc->caps_list_lock);
        list_for_each_entry(cw, &mdsc->cap_wait_list, list) {
-               seq_printf(s, "%-13d0x%-17lx%-17s%-17s\n", cw->tgid, cw->ino,
+               seq_printf(s, "%-13d0x%-17llx%-17s%-17s\n", cw->tgid, cw->ino,
                                ceph_cap_string(cw->need),
                                ceph_cap_string(cw->want));
        }
index 060bdcc..d72e4a1 100644 (file)
@@ -259,9 +259,7 @@ static int __dcache_readdir(struct file *file,  struct dir_context *ctx,
                             dentry, dentry, d_inode(dentry));
                        ctx->pos = di->offset;
                        if (!dir_emit(ctx, dentry->d_name.name,
-                                     dentry->d_name.len,
-                                     ceph_translate_ino(dentry->d_sb,
-                                                        d_inode(dentry)->i_ino),
+                                     dentry->d_name.len, ceph_present_inode(d_inode(dentry)),
                                      d_inode(dentry)->i_mode >> 12)) {
                                dput(dentry);
                                err = 0;
@@ -324,18 +322,21 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
        /* always start with . and .. */
        if (ctx->pos == 0) {
                dout("readdir off 0 -> '.'\n");
-               if (!dir_emit(ctx, ".", 1, 
-                           ceph_translate_ino(inode->i_sb, inode->i_ino),
+               if (!dir_emit(ctx, ".", 1, ceph_present_inode(inode),
                            inode->i_mode >> 12))
                        return 0;
                ctx->pos = 1;
        }
        if (ctx->pos == 1) {
-               ino_t ino = parent_ino(file->f_path.dentry);
+               u64 ino;
+               struct dentry *dentry = file->f_path.dentry;
+
+               spin_lock(&dentry->d_lock);
+               ino = ceph_present_inode(dentry->d_parent->d_inode);
+               spin_unlock(&dentry->d_lock);
+
                dout("readdir off 1 -> '..'\n");
-               if (!dir_emit(ctx, "..", 2,
-                           ceph_translate_ino(inode->i_sb, ino),
-                           inode->i_mode >> 12))
+               if (!dir_emit(ctx, "..", 2, ino, inode->i_mode >> 12))
                        return 0;
                ctx->pos = 2;
        }
@@ -507,9 +508,6 @@ more:
        }
        for (; i < rinfo->dir_nr; i++) {
                struct ceph_mds_reply_dir_entry *rde = rinfo->dir_entries + i;
-               struct ceph_vino vino;
-               ino_t ino;
-               u32 ftype;
 
                BUG_ON(rde->offset < ctx->pos);
 
@@ -519,13 +517,10 @@ more:
                     rde->name_len, rde->name, &rde->inode.in);
 
                BUG_ON(!rde->inode.in);
-               ftype = le32_to_cpu(rde->inode.in->mode) >> 12;
-               vino.ino = le64_to_cpu(rde->inode.in->ino);
-               vino.snap = le64_to_cpu(rde->inode.in->snapid);
-               ino = ceph_vino_to_ino(vino);
 
                if (!dir_emit(ctx, rde->name, rde->name_len,
-                             ceph_translate_ino(inode->i_sb, ino), ftype)) {
+                             ceph_present_ino(inode->i_sb, le64_to_cpu(rde->inode.in->ino)),
+                             le32_to_cpu(rde->inode.in->mode) >> 12)) {
                        dout("filldir stopping us...\n");
                        return 0;
                }
@@ -1161,7 +1156,7 @@ retry:
 
        if (try_async && op == CEPH_MDS_OP_UNLINK &&
            (req->r_dir_caps = get_caps_for_async_unlink(dir, dentry))) {
-               dout("async unlink on %lu/%.*s caps=%s", dir->i_ino,
+               dout("async unlink on %llu/%.*s caps=%s", ceph_ino(dir),
                     dentry->d_name.len, dentry->d_name.name,
                     ceph_cap_string(req->r_dir_caps));
                set_bit(CEPH_MDS_R_ASYNC, &req->r_req_flags);
@@ -1745,7 +1740,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
                        case -ENOENT:
                                if (d_really_is_negative(dentry))
                                        valid = 1;
-                               /* Fallthrough */
+                               fallthrough;
                        default:
                                break;
                        }
index d51c3f2..3f4c993 100644 (file)
@@ -252,7 +252,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode)
        case S_IFREG:
                ceph_fscache_register_inode_cookie(inode);
                ceph_fscache_file_set_cookie(inode, file);
-               /* fall through */
+               fallthrough;
        case S_IFDIR:
                ret = ceph_init_file_info(inode, file, fmode,
                                                S_ISDIR(inode->i_mode));
@@ -630,8 +630,8 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry,
        } else {
                struct dentry *dn;
 
-               dout("%s d_adding new inode 0x%llx to 0x%lx/%s\n", __func__,
-                       vino.ino, dir->i_ino, dentry->d_name.name);
+               dout("%s d_adding new inode 0x%llx to 0x%llx/%s\n", __func__,
+                       vino.ino, ceph_ino(dir), dentry->d_name.name);
                ceph_dir_clear_ordered(dir);
                ceph_init_inode_acls(inode, as_ctx);
                if (inode->i_state & I_NEW) {
@@ -2507,6 +2507,7 @@ const struct file_operations ceph_file_fops = {
        .mmap = ceph_mmap,
        .fsync = ceph_fsync,
        .lock = ceph_lock,
+       .setlease = simple_nosetlease,
        .flock = ceph_flock,
        .splice_read = generic_file_splice_read,
        .splice_write = iter_file_splice_write,
index 357c937..d163fa9 100644 (file)
@@ -41,8 +41,10 @@ static void ceph_inode_work(struct work_struct *work);
  */
 static int ceph_set_ino_cb(struct inode *inode, void *data)
 {
-       ceph_inode(inode)->i_vino = *(struct ceph_vino *)data;
-       inode->i_ino = ceph_vino_to_ino(*(struct ceph_vino *)data);
+       struct ceph_inode_info *ci = ceph_inode(inode);
+
+       ci->i_vino = *(struct ceph_vino *)data;
+       inode->i_ino = ceph_vino_to_ino_t(ci->i_vino);
        inode_set_iversion_raw(inode, 0);
        return 0;
 }
@@ -50,17 +52,14 @@ static int ceph_set_ino_cb(struct inode *inode, void *data)
 struct inode *ceph_get_inode(struct super_block *sb, struct ceph_vino vino)
 {
        struct inode *inode;
-       ino_t t = ceph_vino_to_ino(vino);
 
-       inode = iget5_locked(sb, t, ceph_ino_compare, ceph_set_ino_cb, &vino);
+       inode = iget5_locked(sb, (unsigned long)vino.ino, ceph_ino_compare,
+                            ceph_set_ino_cb, &vino);
        if (!inode)
                return ERR_PTR(-ENOMEM);
-       if (inode->i_state & I_NEW)
-               dout("get_inode created new inode %p %llx.%llx ino %llx\n",
-                    inode, ceph_vinop(inode), (u64)inode->i_ino);
 
-       dout("get_inode on %lu=%llx.%llx got %p\n", inode->i_ino, vino.ino,
-            vino.snap, inode);
+       dout("get_inode on %llu=%llx.%llx got %p new %d\n", ceph_present_inode(inode),
+            ceph_vinop(inode), inode, !!(inode->i_state & I_NEW));
        return inode;
 }
 
@@ -2378,7 +2377,7 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
        }
 
        generic_fillattr(inode, stat);
-       stat->ino = ceph_translate_ino(inode->i_sb, inode->i_ino);
+       stat->ino = ceph_present_inode(inode);
 
        /*
         * btime on newly-allocated inodes is 0, so if this is still set to
index bc9e959..6588006 100644 (file)
@@ -372,7 +372,7 @@ struct ceph_quotarealm_inode {
 
 struct cap_wait {
        struct list_head        list;
-       unsigned long           ino;
+       u64                     ino;
        pid_t                   tgid;
        int                     need;
        int                     want;
index 198ddde..cc2c4d4 100644 (file)
@@ -23,12 +23,12 @@ static inline bool ceph_has_realms_with_quotas(struct inode *inode)
 {
        struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
        struct super_block *sb = mdsc->fsc->sb;
+       struct inode *root = d_inode(sb->s_root);
 
        if (atomic64_read(&mdsc->quotarealms_count) > 0)
                return true;
        /* if root is the real CephFS root, we don't have quota realms */
-       if (sb->s_root->d_inode &&
-           (sb->s_root->d_inode->i_ino == CEPH_INO_ROOT))
+       if (root && ceph_ino(root) == CEPH_INO_ROOT)
                return false;
        /* otherwise, we can't know for sure */
        return true;
index 4c3c964..a3995eb 100644 (file)
@@ -457,15 +457,7 @@ ceph_vino(const struct inode *inode)
        return ceph_inode(inode)->i_vino;
 }
 
-/*
- * ino_t is <64 bits on many architectures, blech.
- *
- *               i_ino (kernel inode)   st_ino (userspace)
- * i386          32                     32
- * x86_64+ino32  64                     32
- * x86_64        64                     64
- */
-static inline u32 ceph_ino_to_ino32(__u64 vino)
+static inline u32 ceph_ino_to_ino32(u64 vino)
 {
        u32 ino = vino & 0xffffffff;
        ino ^= vino >> 32;
@@ -475,34 +467,17 @@ static inline u32 ceph_ino_to_ino32(__u64 vino)
 }
 
 /*
- * kernel i_ino value
+ * Inode numbers in cephfs are 64 bits, but inode->i_ino is 32-bits on
+ * some arches. We generally do not use this value inside the ceph driver, but
+ * we do want to set it to something, so that generic vfs code has an
+ * appropriate value for tracepoints and the like.
  */
-static inline ino_t ceph_vino_to_ino(struct ceph_vino vino)
+static inline ino_t ceph_vino_to_ino_t(struct ceph_vino vino)
 {
-#if BITS_PER_LONG == 32
-       return ceph_ino_to_ino32(vino.ino);
-#else
+       if (sizeof(ino_t) == sizeof(u32))
+               return ceph_ino_to_ino32(vino.ino);
        return (ino_t)vino.ino;
-#endif
-}
-
-/*
- * user-visible ino (stat, filldir)
- */
-#if BITS_PER_LONG == 32
-static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino)
-{
-       return ino;
-}
-#else
-static inline ino_t ceph_translate_ino(struct super_block *sb, ino_t ino)
-{
-       if (ceph_test_mount_opt(ceph_sb_to_client(sb), INO32))
-               ino = ceph_ino_to_ino32(ino);
-       return ino;
 }
-#endif
-
 
 /* for printf-style formatting */
 #define ceph_vinop(i) ceph_inode(i)->i_vino.ino, ceph_inode(i)->i_vino.snap
@@ -511,11 +486,34 @@ static inline u64 ceph_ino(struct inode *inode)
 {
        return ceph_inode(inode)->i_vino.ino;
 }
+
 static inline u64 ceph_snap(struct inode *inode)
 {
        return ceph_inode(inode)->i_vino.snap;
 }
 
+/**
+ * ceph_present_ino - format an inode number for presentation to userland
+ * @sb: superblock where the inode lives
+ * @ino: inode number to (possibly) convert
+ *
+ * If the user mounted with the ino32 option, then the 64-bit value needs
+ * to be converted to something that can fit inside 32 bits. Note that
+ * internal kernel code never uses this value, so this is entirely for
+ * userland consumption.
+ */
+static inline u64 ceph_present_ino(struct super_block *sb, u64 ino)
+{
+       if (unlikely(ceph_test_mount_opt(ceph_sb_to_client(sb), INO32)))
+               return ceph_ino_to_ino32(ino);
+       return ino;
+}
+
+static inline u64 ceph_present_inode(struct inode *inode)
+{
+       return ceph_present_ino(inode->i_sb, ceph_ino(inode));
+}
+
 static inline int ceph_ino_compare(struct inode *inode, void *data)
 {
        struct ceph_vino *pvino = (struct ceph_vino *)data;
@@ -524,11 +522,16 @@ static inline int ceph_ino_compare(struct inode *inode, void *data)
                ci->i_vino.snap == pvino->snap;
 }
 
+
 static inline struct inode *ceph_find_inode(struct super_block *sb,
                                            struct ceph_vino vino)
 {
-       ino_t t = ceph_vino_to_ino(vino);
-       return ilookup5(sb, t, ceph_ino_compare, &vino);
+       /*
+        * NB: The hashval will be run through the fs/inode.c hash function
+        * anyway, so there is no need to squash the inode number down to
+        * 32-bits first. Just use low-order bits on arches with 32-bit long.
+        */
+       return ilookup5(sb, (unsigned long)vino.ino, ceph_ino_compare, &vino);
 }
 
 
index b296964..b565d83 100644 (file)
@@ -2031,4 +2031,19 @@ static inline bool is_smb1_server(struct TCP_Server_Info *server)
        return strcmp(server->vals->version_string, SMB1_VERSION_STRING) == 0;
 }
 
+static inline bool is_tcon_dfs(struct cifs_tcon *tcon)
+{
+       /*
+        * For SMB1, see MS-CIFS 2.4.55 SMB_COM_TREE_CONNECT_ANDX (0x75) and MS-CIFS 3.3.4.4 DFS
+        * Subsystem Notifies That a Share Is a DFS Share.
+        *
+        * For SMB2+, see MS-SMB2 2.2.10 SMB2 TREE_CONNECT Response and MS-SMB2 3.3.4.14 Server
+        * Application Updates a Share.
+        */
+       if (!tcon || !tcon->ses || !tcon->ses->server)
+               return false;
+       return is_smb1_server(tcon->ses->server) ? tcon->Flags & SMB_SHARE_IS_IN_DFS :
+               tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT);
+}
+
 #endif /* _CIFS_GLOB_H */
index 0e763d2..0496934 100644 (file)
@@ -581,7 +581,7 @@ should_set_ext_sec_flag(enum securityEnum sectype)
                if (global_secflags &
                    (CIFSSEC_MAY_KRB5 | CIFSSEC_MAY_NTLMSSP))
                        return true;
-               /* Fallthrough */
+               fallthrough;
        default:
                return false;
        }
index a275ee3..a5731dd 100644 (file)
@@ -1378,25 +1378,25 @@ static int cifs_parse_security_flavors(char *value,
                return 1;
        case Opt_sec_krb5i:
                vol->sign = true;
-               /* Fallthrough */
+               fallthrough;
        case Opt_sec_krb5:
                vol->sectype = Kerberos;
                break;
        case Opt_sec_ntlmsspi:
                vol->sign = true;
-               /* Fallthrough */
+               fallthrough;
        case Opt_sec_ntlmssp:
                vol->sectype = RawNTLMSSP;
                break;
        case Opt_sec_ntlmi:
                vol->sign = true;
-               /* Fallthrough */
+               fallthrough;
        case Opt_ntlm:
                vol->sectype = NTLM;
                break;
        case Opt_sec_ntlmv2i:
                vol->sign = true;
-               /* Fallthrough */
+               fallthrough;
        case Opt_sec_ntlmv2:
                vol->sectype = NTLMv2;
                break;
@@ -2187,7 +2187,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname,
                                vol->password = NULL;
                                break;
                        }
-                       /* Fallthrough - to Opt_pass below.*/
+                       fallthrough;    /* to Opt_pass below */
                case Opt_pass:
                        /* Obtain the value string */
                        value = strchr(data, '=');
@@ -4909,7 +4909,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol)
                if (!tcon)
                        continue;
                /* Make sure that requests go through new root servers */
-               if (tcon->share_flags & (SHI1005_FLAGS_DFS | SHI1005_FLAGS_DFS_ROOT)) {
+               if (is_tcon_dfs(tcon)) {
                        put_root_ses(root_ses);
                        set_root_ses(cifs_sb, ses, &root_ses);
                }
index 3989d08..1f75b25 100644 (file)
@@ -1017,6 +1017,8 @@ handle_mnt_opt:
        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) {
                rc = cifs_acl_to_fattr(cifs_sb, &fattr, *inode, true,
                                       full_path, fid);
+               if (rc == -EREMOTE)
+                       rc = 0;
                if (rc) {
                        cifs_dbg(FYI, "%s: Get mode from SID failed. rc=%d\n",
                                 __func__, rc);
@@ -1025,6 +1027,8 @@ handle_mnt_opt:
        } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
                rc = cifs_acl_to_fattr(cifs_sb, &fattr, *inode, false,
                                       full_path, fid);
+               if (rc == -EREMOTE)
+                       rc = 0;
                if (rc) {
                        cifs_dbg(FYI, "%s: Getting ACL failed with error: %d\n",
                                 __func__, rc);
index 69cd585..de56436 100644 (file)
@@ -798,7 +798,7 @@ cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
                        if ((server->sec_kerberos || server->sec_mskerberos) &&
                            (global_secflags & CIFSSEC_MAY_KRB5))
                                return Kerberos;
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        return Unspecified;
                }
@@ -815,7 +815,7 @@ cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
                default:
                        break;
                }
-               /* Fallthrough - to attempt LANMAN authentication next */
+               fallthrough;    /* to attempt LANMAN authentication next */
        case CIFS_NEGFLAVOR_LANMAN:
                switch (requested) {
                case LANMAN:
@@ -823,7 +823,7 @@ cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
                case Unspecified:
                        if (global_secflags & CIFSSEC_MAY_LANMAN)
                                return LANMAN;
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        return Unspecified;
                }
index 667d70a..96c172d 100644 (file)
@@ -1101,7 +1101,7 @@ smb2_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
                if ((server->sec_kerberos || server->sec_mskerberos) &&
                        (global_secflags & CIFSSEC_MAY_KRB5))
                        return Kerberos;
-               /* Fallthrough */
+               fallthrough;
        default:
                return Unspecified;
        }
index cb73365..ca22737 100644 (file)
@@ -1688,11 +1688,11 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence)
        switch (whence) {
                case 1:
                        offset += file->f_pos;
-                       /* fall through */
+                       fallthrough;
                case 0:
                        if (offset >= 0)
                                break;
-                       /* fall through */
+                       fallthrough;
                default:
                        return -EINVAL;
        }
index 95341af..994ab66 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1367,7 +1367,7 @@ static vm_fault_t dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp,
                        ret = dax_load_hole(&xas, mapping, &entry, vmf);
                        goto finish_iomap;
                }
-               /*FALLTHRU*/
+               fallthrough;
        default:
                WARN_ON_ONCE(1);
                error = -EIO;
index b167d2d..a768a09 100644 (file)
@@ -177,7 +177,7 @@ static int open_proxy_open(struct inode *inode, struct file *filp)
                goto out;
 
        if (!fops_get(real_fops)) {
-#ifdef MODULE
+#ifdef CONFIG_MODULES
                if (real_fops->owner &&
                    real_fops->owner->state == MODULE_STATE_GOING)
                        goto out;
@@ -312,7 +312,7 @@ static int full_proxy_open(struct inode *inode, struct file *filp)
                goto out;
 
        if (!fops_get(real_fops)) {
-#ifdef MODULE
+#ifdef CONFIG_MODULES
                if (real_fops->owner &&
                    real_fops->owner->state == MODULE_STATE_GOING)
                        goto out;
index 18d8159..002123e 100644 (file)
@@ -5817,7 +5817,7 @@ int dlm_user_request(struct dlm_ls *ls, struct dlm_user_args *ua,
                break;
        case -EAGAIN:
                error = 0;
-               /* fall through */
+               fallthrough;
        default:
                __put_lkb(ls, lkb);
                goto out;
index 7d40d78..ae32554 100644 (file)
@@ -359,7 +359,7 @@ static int z_erofs_extent_lookback(struct z_erofs_maprecorder *m,
                return z_erofs_extent_lookback(m, m->delta[0]);
        case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN:
                map->m_flags &= ~EROFS_MAP_ZIPPED;
-               /* fallthrough */
+               fallthrough;
        case Z_EROFS_VLE_CLUSTER_TYPE_HEAD:
                map->m_la = (lcn << lclusterbits) | m->clusterofs;
                break;
@@ -416,7 +416,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
        case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN:
                if (endoff >= m.clusterofs)
                        map->m_flags &= ~EROFS_MAP_ZIPPED;
-               /* fallthrough */
+               fallthrough;
        case Z_EROFS_VLE_CLUSTER_TYPE_HEAD:
                if (endoff >= m.clusterofs) {
                        map->m_la = (m.lcn << lclusterbits) | m.clusterofs;
@@ -433,7 +433,7 @@ int z_erofs_map_blocks_iter(struct inode *inode,
                end = (m.lcn << lclusterbits) | m.clusterofs;
                map->m_flags |= EROFS_MAP_FULL_MAPPED;
                m.delta[0] = 1;
-               /* fallthrough */
+               fallthrough;
        case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD:
                /* get the correspoinding first chunk */
                err = z_erofs_extent_lookback(&m, m.delta[0]);
index 12eebcd..8107e06 100644 (file)
@@ -1994,9 +1994,11 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests)
                         * not already there, and calling reverse_path_check()
                         * during ep_insert().
                         */
-                       if (list_empty(&epi->ffd.file->f_tfile_llink))
-                               list_add(&epi->ffd.file->f_tfile_llink,
-                                        &tfile_check_list);
+                       if (list_empty(&epi->ffd.file->f_tfile_llink)) {
+                               if (get_file_rcu(epi->ffd.file))
+                                       list_add(&epi->ffd.file->f_tfile_llink,
+                                                &tfile_check_list);
+                       }
                }
        }
        mutex_unlock(&ep->mtx);
@@ -2040,6 +2042,7 @@ static void clear_tfile_check_list(void)
                file = list_first_entry(&tfile_check_list, struct file,
                                        f_tfile_llink);
                list_del_init(&file->f_tfile_llink);
+               fput(file);
        }
        INIT_LIST_HEAD(&tfile_check_list);
 }
@@ -2200,25 +2203,22 @@ int do_epoll_ctl(int epfd, int op, int fd, struct epoll_event *epds,
                        full_check = 1;
                        if (is_file_epoll(tf.file)) {
                                error = -ELOOP;
-                               if (ep_loop_check(ep, tf.file) != 0) {
-                                       clear_tfile_check_list();
+                               if (ep_loop_check(ep, tf.file) != 0)
                                        goto error_tgt_fput;
-                               }
-                       } else
+                       } else {
+                               get_file(tf.file);
                                list_add(&tf.file->f_tfile_llink,
                                                        &tfile_check_list);
+                       }
                        error = epoll_mutex_lock(&ep->mtx, 0, nonblock);
-                       if (error) {
-out_del:
-                               list_del(&tf.file->f_tfile_llink);
+                       if (error)
                                goto error_tgt_fput;
-                       }
                        if (is_file_epoll(tf.file)) {
                                tep = tf.file->private_data;
                                error = epoll_mutex_lock(&tep->mtx, 1, nonblock);
                                if (error) {
                                        mutex_unlock(&ep->mtx);
-                                       goto out_del;
+                                       goto error_tgt_fput;
                                }
                        }
                }
@@ -2239,8 +2239,6 @@ out_del:
                        error = ep_insert(ep, epds, tf.file, fd, full_check);
                } else
                        error = -EEXIST;
-               if (full_check)
-                       clear_tfile_check_list();
                break;
        case EPOLL_CTL_DEL:
                if (epi)
@@ -2263,8 +2261,10 @@ out_del:
        mutex_unlock(&ep->mtx);
 
 error_tgt_fput:
-       if (full_check)
+       if (full_check) {
+               clear_tfile_check_list();
                mutex_unlock(&epmutex);
+       }
 
        fdput(tf);
 error_fput:
index 60378dd..96044f5 100644 (file)
@@ -93,8 +93,10 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
        struct inode *inode = file_inode(vmf->vma->vm_file);
        struct ext2_inode_info *ei = EXT2_I(inode);
        vm_fault_t ret;
+       bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
+               (vmf->vma->vm_flags & VM_SHARED);
 
-       if (vmf->flags & FAULT_FLAG_WRITE) {
+       if (write) {
                sb_start_pagefault(inode->i_sb);
                file_update_time(vmf->vma->vm_file);
        }
@@ -103,7 +105,7 @@ static vm_fault_t ext2_dax_fault(struct vm_fault *vmf)
        ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops);
 
        up_read(&ei->dax_sem);
-       if (vmf->flags & FAULT_FLAG_WRITE)
+       if (write)
                sb_end_pagefault(inode->i_sb);
        return ret;
 }
index 80662e1..415c21f 100644 (file)
@@ -1241,7 +1241,7 @@ do_indirects:
                                mark_inode_dirty(inode);
                                ext2_free_branches(inode, &nr, &nr+1, 1);
                        }
-                       /* fall through */
+                       fallthrough;
                case EXT2_IND_BLOCK:
                        nr = i_data[EXT2_DIND_BLOCK];
                        if (nr) {
@@ -1249,7 +1249,7 @@ do_indirects:
                                mark_inode_dirty(inode);
                                ext2_free_branches(inode, &nr, &nr+1, 2);
                        }
-                       /* fall through */
+                       fallthrough;
                case EXT2_DIND_BLOCK:
                        nr = i_data[EXT2_TIND_BLOCK];
                        if (nr) {
index dda8605..7fab2b3 100644 (file)
@@ -587,7 +587,7 @@ static int parse_options(char *options, struct super_block *sb,
                case Opt_xip:
                        ext2_msg(sb, KERN_INFO, "use dax instead of xip");
                        set_opt(opts->s_mount_opt, XIP);
-                       /* Fall through */
+                       fallthrough;
                case Opt_dax:
 #ifdef CONFIG_FS_DAX
                        ext2_msg(sb, KERN_WARNING,
index 1afa5a4..619dd35 100644 (file)
@@ -110,7 +110,7 @@ config EXT4_KUNIT_TESTS
          This builds the ext4 KUnit tests.
 
          KUnit tests run during boot and output the results to the debug log
-         in TAP format (http://testanything.org/). Only useful for kernel devs
+         in TAP format (https://testanything.org/). Only useful for kernel devs
          running KUnit test harness and are not for inclusion into a production
          build.
 
index 1ba46d8..48c3df4 100644 (file)
@@ -413,7 +413,8 @@ verified:
  * Return buffer_head on success or an ERR_PTR in case of failure.
  */
 struct buffer_head *
-ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
+ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group,
+                             bool ignore_locked)
 {
        struct ext4_group_desc *desc;
        struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -441,6 +442,12 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
                return ERR_PTR(-ENOMEM);
        }
 
+       if (ignore_locked && buffer_locked(bh)) {
+               /* buffer under IO already, return if called for prefetching */
+               put_bh(bh);
+               return NULL;
+       }
+
        if (bitmap_uptodate(bh))
                goto verify;
 
@@ -487,10 +494,11 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
         * submit the buffer_head for reading
         */
        set_buffer_new(bh);
-       trace_ext4_read_block_bitmap_load(sb, block_group);
+       trace_ext4_read_block_bitmap_load(sb, block_group, ignore_locked);
        bh->b_end_io = ext4_end_bitmap_read;
        get_bh(bh);
-       submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO, bh);
+       submit_bh(REQ_OP_READ, REQ_META | REQ_PRIO |
+                 (ignore_locked ? REQ_RAHEAD : 0), bh);
        return bh;
 verify:
        err = ext4_validate_block_bitmap(sb, desc, block_group, bh);
@@ -534,7 +542,7 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
        struct buffer_head *bh;
        int err;
 
-       bh = ext4_read_block_bitmap_nowait(sb, block_group);
+       bh = ext4_read_block_bitmap_nowait(sb, block_group, false);
        if (IS_ERR(bh))
                return bh;
        err = ext4_wait_block_bitmap(sb, block_group, bh);
index 16e9b2f..c54ba52 100644 (file)
@@ -24,6 +24,7 @@ struct ext4_system_zone {
        struct rb_node  node;
        ext4_fsblk_t    start_blk;
        unsigned int    count;
+       u32             ino;
 };
 
 static struct kmem_cache *ext4_system_zone_cachep;
@@ -45,7 +46,8 @@ void ext4_exit_system_zone(void)
 static inline int can_merge(struct ext4_system_zone *entry1,
                     struct ext4_system_zone *entry2)
 {
-       if ((entry1->start_blk + entry1->count) == entry2->start_blk)
+       if ((entry1->start_blk + entry1->count) == entry2->start_blk &&
+           entry1->ino == entry2->ino)
                return 1;
        return 0;
 }
@@ -66,9 +68,9 @@ static void release_system_zone(struct ext4_system_blocks *system_blks)
  */
 static int add_system_zone(struct ext4_system_blocks *system_blks,
                           ext4_fsblk_t start_blk,
-                          unsigned int count)
+                          unsigned int count, u32 ino)
 {
-       struct ext4_system_zone *new_entry = NULL, *entry;
+       struct ext4_system_zone *new_entry, *entry;
        struct rb_node **n = &system_blks->root.rb_node, *node;
        struct rb_node *parent = NULL, *new_node = NULL;
 
@@ -79,30 +81,21 @@ static int add_system_zone(struct ext4_system_blocks *system_blks,
                        n = &(*n)->rb_left;
                else if (start_blk >= (entry->start_blk + entry->count))
                        n = &(*n)->rb_right;
-               else {
-                       if (start_blk + count > (entry->start_blk +
-                                                entry->count))
-                               entry->count = (start_blk + count -
-                                               entry->start_blk);
-                       new_node = *n;
-                       new_entry = rb_entry(new_node, struct ext4_system_zone,
-                                            node);
-                       break;
-               }
+               else    /* Unexpected overlap of system zones. */
+                       return -EFSCORRUPTED;
        }
 
-       if (!new_entry) {
-               new_entry = kmem_cache_alloc(ext4_system_zone_cachep,
-                                            GFP_KERNEL);
-               if (!new_entry)
-                       return -ENOMEM;
-               new_entry->start_blk = start_blk;
-               new_entry->count = count;
-               new_node = &new_entry->node;
-
-               rb_link_node(new_node, parent, n);
-               rb_insert_color(new_node, &system_blks->root);
-       }
+       new_entry = kmem_cache_alloc(ext4_system_zone_cachep,
+                                    GFP_KERNEL);
+       if (!new_entry)
+               return -ENOMEM;
+       new_entry->start_blk = start_blk;
+       new_entry->count = count;
+       new_entry->ino = ino;
+       new_node = &new_entry->node;
+
+       rb_link_node(new_node, parent, n);
+       rb_insert_color(new_node, &system_blks->root);
 
        /* Can we merge to the left? */
        node = rb_prev(new_node);
@@ -151,40 +144,6 @@ static void debug_print_tree(struct ext4_sb_info *sbi)
        printk(KERN_CONT "\n");
 }
 
-/*
- * Returns 1 if the passed-in block region (start_blk,
- * start_blk+count) is valid; 0 if some part of the block region
- * overlaps with filesystem metadata blocks.
- */
-static int ext4_data_block_valid_rcu(struct ext4_sb_info *sbi,
-                                    struct ext4_system_blocks *system_blks,
-                                    ext4_fsblk_t start_blk,
-                                    unsigned int count)
-{
-       struct ext4_system_zone *entry;
-       struct rb_node *n;
-
-       if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
-           (start_blk + count < start_blk) ||
-           (start_blk + count > ext4_blocks_count(sbi->s_es)))
-               return 0;
-
-       if (system_blks == NULL)
-               return 1;
-
-       n = system_blks->root.rb_node;
-       while (n) {
-               entry = rb_entry(n, struct ext4_system_zone, node);
-               if (start_blk + count - 1 < entry->start_blk)
-                       n = n->rb_left;
-               else if (start_blk >= (entry->start_blk + entry->count))
-                       n = n->rb_right;
-               else
-                       return 0;
-       }
-       return 1;
-}
-
 static int ext4_protect_reserved_inode(struct super_block *sb,
                                       struct ext4_system_blocks *system_blks,
                                       u32 ino)
@@ -214,19 +173,18 @@ static int ext4_protect_reserved_inode(struct super_block *sb,
                if (n == 0) {
                        i++;
                } else {
-                       if (!ext4_data_block_valid_rcu(sbi, system_blks,
-                                               map.m_pblk, n)) {
-                               err = -EFSCORRUPTED;
-                               __ext4_error(sb, __func__, __LINE__, -err,
-                                            map.m_pblk, "blocks %llu-%llu "
-                                            "from inode %u overlap system zone",
-                                            map.m_pblk,
-                                            map.m_pblk + map.m_len - 1, ino);
+                       err = add_system_zone(system_blks, map.m_pblk, n, ino);
+                       if (err < 0) {
+                               if (err == -EFSCORRUPTED) {
+                                       __ext4_error(sb, __func__, __LINE__,
+                                                    -err, map.m_pblk,
+                                                    "blocks %llu-%llu from inode %u overlap system zone",
+                                                    map.m_pblk,
+                                                    map.m_pblk + map.m_len - 1,
+                                                    ino);
+                               }
                                break;
                        }
-                       err = add_system_zone(system_blks, map.m_pblk, n);
-                       if (err < 0)
-                               break;
                        i += n;
                }
        }
@@ -262,14 +220,6 @@ int ext4_setup_system_zone(struct super_block *sb)
        int flex_size = ext4_flex_bg_size(sbi);
        int ret;
 
-       if (!test_opt(sb, BLOCK_VALIDITY)) {
-               if (sbi->system_blks)
-                       ext4_release_system_zone(sb);
-               return 0;
-       }
-       if (sbi->system_blks)
-               return 0;
-
        system_blks = kzalloc(sizeof(*system_blks), GFP_KERNEL);
        if (!system_blks)
                return -ENOMEM;
@@ -277,22 +227,25 @@ int ext4_setup_system_zone(struct super_block *sb)
        for (i=0; i < ngroups; i++) {
                cond_resched();
                if (ext4_bg_has_super(sb, i) &&
-                   ((i < 5) || ((i % flex_size) == 0)))
-                       add_system_zone(system_blks,
+                   ((i < 5) || ((i % flex_size) == 0))) {
+                       ret = add_system_zone(system_blks,
                                        ext4_group_first_block_no(sb, i),
-                                       ext4_bg_num_gdb(sb, i) + 1);
+                                       ext4_bg_num_gdb(sb, i) + 1, 0);
+                       if (ret)
+                               goto err;
+               }
                gdp = ext4_get_group_desc(sb, i, NULL);
                ret = add_system_zone(system_blks,
-                               ext4_block_bitmap(sb, gdp), 1);
+                               ext4_block_bitmap(sb, gdp), 1, 0);
                if (ret)
                        goto err;
                ret = add_system_zone(system_blks,
-                               ext4_inode_bitmap(sb, gdp), 1);
+                               ext4_inode_bitmap(sb, gdp), 1, 0);
                if (ret)
                        goto err;
                ret = add_system_zone(system_blks,
                                ext4_inode_table(sb, gdp),
-                               sbi->s_itb_per_group);
+                               sbi->s_itb_per_group, 0);
                if (ret)
                        goto err;
        }
@@ -341,11 +294,24 @@ void ext4_release_system_zone(struct super_block *sb)
                call_rcu(&system_blks->rcu, ext4_destroy_system_zone);
 }
 
-int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
+/*
+ * Returns 1 if the passed-in block region (start_blk,
+ * start_blk+count) is valid; 0 if some part of the block region
+ * overlaps with some other filesystem metadata blocks.
+ */
+int ext4_inode_block_valid(struct inode *inode, ext4_fsblk_t start_blk,
                          unsigned int count)
 {
+       struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
        struct ext4_system_blocks *system_blks;
-       int ret;
+       struct ext4_system_zone *entry;
+       struct rb_node *n;
+       int ret = 1;
+
+       if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
+           (start_blk + count < start_blk) ||
+           (start_blk + count > ext4_blocks_count(sbi->s_es)))
+               return 0;
 
        /*
         * Lock the system zone to prevent it being released concurrently
@@ -354,8 +320,22 @@ int ext4_data_block_valid(struct ext4_sb_info *sbi, ext4_fsblk_t start_blk,
         */
        rcu_read_lock();
        system_blks = rcu_dereference(sbi->system_blks);
-       ret = ext4_data_block_valid_rcu(sbi, system_blks, start_blk,
-                                       count);
+       if (system_blks == NULL)
+               goto out_rcu;
+
+       n = system_blks->root.rb_node;
+       while (n) {
+               entry = rb_entry(n, struct ext4_system_zone, node);
+               if (start_blk + count - 1 < entry->start_blk)
+                       n = n->rb_left;
+               else if (start_blk >= (entry->start_blk + entry->count))
+                       n = n->rb_right;
+               else {
+                       ret = (entry->ino == inode->i_ino);
+                       break;
+               }
+       }
+out_rcu:
        rcu_read_unlock();
        return ret;
 }
@@ -374,8 +354,7 @@ int ext4_check_blockref(const char *function, unsigned int line,
        while (bref < p+max) {
                blk = le32_to_cpu(*bref++);
                if (blk &&
-                   unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
-                                                   blk, 1))) {
+                   unlikely(!ext4_inode_block_valid(inode, blk, 1))) {
                        ext4_error_inode(inode, function, line, blk,
                                         "invalid block");
                        return -EFSCORRUPTED;
index 42f5060..523e00d 100644 (file)
@@ -434,10 +434,36 @@ struct flex_groups {
 #define EXT4_CASEFOLD_FL               0x40000000 /* Casefolded directory */
 #define EXT4_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
 
-#define EXT4_FL_USER_VISIBLE           0x725BDFFF /* User visible flags */
-#define EXT4_FL_USER_MODIFIABLE                0x624BC0FF /* User modifiable flags */
-
-/* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
+/* User modifiable flags */
+#define EXT4_FL_USER_MODIFIABLE                (EXT4_SECRM_FL | \
+                                        EXT4_UNRM_FL | \
+                                        EXT4_COMPR_FL | \
+                                        EXT4_SYNC_FL | \
+                                        EXT4_IMMUTABLE_FL | \
+                                        EXT4_APPEND_FL | \
+                                        EXT4_NODUMP_FL | \
+                                        EXT4_NOATIME_FL | \
+                                        EXT4_JOURNAL_DATA_FL | \
+                                        EXT4_NOTAIL_FL | \
+                                        EXT4_DIRSYNC_FL | \
+                                        EXT4_TOPDIR_FL | \
+                                        EXT4_EXTENTS_FL | \
+                                        0x00400000 /* EXT4_EOFBLOCKS_FL */ | \
+                                        EXT4_DAX_FL | \
+                                        EXT4_PROJINHERIT_FL | \
+                                        EXT4_CASEFOLD_FL)
+
+/* User visible flags */
+#define EXT4_FL_USER_VISIBLE           (EXT4_FL_USER_MODIFIABLE | \
+                                        EXT4_DIRTY_FL | \
+                                        EXT4_COMPRBLK_FL | \
+                                        EXT4_NOCOMPR_FL | \
+                                        EXT4_ENCRYPT_FL | \
+                                        EXT4_INDEX_FL | \
+                                        EXT4_VERITY_FL | \
+                                        EXT4_INLINE_DATA_FL)
+
+/* Flags we can manipulate with through FS_IOC_FSSETXATTR */
 #define EXT4_FL_XFLAG_VISIBLE          (EXT4_SYNC_FL | \
                                         EXT4_IMMUTABLE_FL | \
                                         EXT4_APPEND_FL | \
@@ -669,8 +695,6 @@ enum {
 /*
  * ioctl commands
  */
-#define        EXT4_IOC_GETFLAGS               FS_IOC_GETFLAGS
-#define        EXT4_IOC_SETFLAGS               FS_IOC_SETFLAGS
 #define        EXT4_IOC_GETVERSION             _IOR('f', 3, long)
 #define        EXT4_IOC_SETVERSION             _IOW('f', 4, long)
 #define        EXT4_IOC_GETVERSION_OLD         FS_IOC_GETVERSION
@@ -687,17 +711,11 @@ enum {
 #define EXT4_IOC_RESIZE_FS             _IOW('f', 16, __u64)
 #define EXT4_IOC_SWAP_BOOT             _IO('f', 17)
 #define EXT4_IOC_PRECACHE_EXTENTS      _IO('f', 18)
-#define EXT4_IOC_SET_ENCRYPTION_POLICY FS_IOC_SET_ENCRYPTION_POLICY
-#define EXT4_IOC_GET_ENCRYPTION_PWSALT FS_IOC_GET_ENCRYPTION_PWSALT
-#define EXT4_IOC_GET_ENCRYPTION_POLICY FS_IOC_GET_ENCRYPTION_POLICY
 /* ioctl codes 19--39 are reserved for fscrypt */
 #define EXT4_IOC_CLEAR_ES_CACHE                _IO('f', 40)
 #define EXT4_IOC_GETSTATE              _IOW('f', 41, __u32)
 #define EXT4_IOC_GET_ES_CACHE          _IOWR('f', 42, struct fiemap)
 
-#define EXT4_IOC_FSGETXATTR            FS_IOC_FSGETXATTR
-#define EXT4_IOC_FSSETXATTR            FS_IOC_FSSETXATTR
-
 #define EXT4_IOC_SHUTDOWN _IOR ('X', 125, __u32)
 
 /*
@@ -722,8 +740,6 @@ enum {
 /*
  * ioctl commands in 32 bit emulation
  */
-#define EXT4_IOC32_GETFLAGS            FS_IOC32_GETFLAGS
-#define EXT4_IOC32_SETFLAGS            FS_IOC32_SETFLAGS
 #define EXT4_IOC32_GETVERSION          _IOR('f', 3, int)
 #define EXT4_IOC32_SETVERSION          _IOW('f', 4, int)
 #define EXT4_IOC32_GETRSVSZ            _IOR('f', 5, int)
@@ -1054,6 +1070,7 @@ struct ext4_inode_info {
        struct timespec64 i_crtime;
 
        /* mballoc */
+       atomic_t i_prealloc_active;
        struct list_head i_prealloc_list;
        spinlock_t i_prealloc_lock;
 
@@ -1172,6 +1189,7 @@ struct ext4_inode_info {
 #define EXT4_MOUNT_JOURNAL_CHECKSUM    0x800000 /* Journal checksums */
 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT        0x1000000 /* Journal Async Commit */
 #define EXT4_MOUNT_WARN_ON_ERROR       0x2000000 /* Trigger WARN_ON on error */
+#define EXT4_MOUNT_PREFETCH_BLOCK_BITMAPS 0x4000000
 #define EXT4_MOUNT_DELALLOC            0x8000000 /* Delalloc support */
 #define EXT4_MOUNT_DATA_ERR_ABORT      0x10000000 /* Abort on file data write */
 #define EXT4_MOUNT_BLOCK_VALIDITY      0x20000000 /* Block validity checking */
@@ -1501,10 +1519,13 @@ struct ext4_sb_info {
        unsigned int s_mb_stats;
        unsigned int s_mb_order2_reqs;
        unsigned int s_mb_group_prealloc;
+       unsigned int s_mb_max_inode_prealloc;
        unsigned int s_max_dir_size_kb;
        /* where last allocation was done - for stream allocation */
        unsigned long s_mb_last_group;
        unsigned long s_mb_last_start;
+       unsigned int s_mb_prefetch;
+       unsigned int s_mb_prefetch_limit;
 
        /* stats for buddy allocator */
        atomic_t s_bal_reqs;    /* number of reqs with len > 1 */
@@ -1572,6 +1593,8 @@ struct ext4_sb_info {
        struct ratelimit_state s_err_ratelimit_state;
        struct ratelimit_state s_warning_ratelimit_state;
        struct ratelimit_state s_msg_ratelimit_state;
+       atomic_t s_warning_count;
+       atomic_t s_msg_count;
 
        /* Encryption context for '-o test_dummy_encryption' */
        struct fscrypt_dummy_context s_dummy_enc_ctx;
@@ -1585,6 +1608,9 @@ struct ext4_sb_info {
 #ifdef CONFIG_EXT4_DEBUG
        unsigned long s_simulate_fail;
 #endif
+       /* Record the errseq of the backing block device */
+       errseq_t s_bdev_wb_err;
+       spinlock_t s_bdev_wb_lock;
 };
 
 static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
@@ -2313,9 +2339,15 @@ struct ext4_lazy_init {
        struct mutex            li_list_mtx;
 };
 
+enum ext4_li_mode {
+       EXT4_LI_MODE_PREFETCH_BBITMAP,
+       EXT4_LI_MODE_ITABLE,
+};
+
 struct ext4_li_request {
        struct super_block      *lr_super;
-       struct ext4_sb_info     *lr_sbi;
+       enum ext4_li_mode       lr_mode;
+       ext4_group_t            lr_first_not_zeroed;
        ext4_group_t            lr_next_group;
        struct list_head        lr_request;
        unsigned long           lr_next_sched;
@@ -2446,7 +2478,8 @@ extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
 extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
 
 extern struct buffer_head *ext4_read_block_bitmap_nowait(struct super_block *sb,
-                                               ext4_group_t block_group);
+                                               ext4_group_t block_group,
+                                               bool ignore_locked);
 extern int ext4_wait_block_bitmap(struct super_block *sb,
                                  ext4_group_t block_group,
                                  struct buffer_head *bh);
@@ -2651,9 +2684,15 @@ extern int ext4_mb_release(struct super_block *);
 extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
                                struct ext4_allocation_request *, int *);
 extern int ext4_mb_reserve_blocks(struct super_block *, int);
-extern void ext4_discard_preallocations(struct inode *);
+extern void ext4_discard_preallocations(struct inode *, unsigned int);
 extern int __init ext4_init_mballoc(void);
 extern void ext4_exit_mballoc(void);
+extern ext4_group_t ext4_mb_prefetch(struct super_block *sb,
+                                    ext4_group_t group,
+                                    unsigned int nr, int *cnt);
+extern void ext4_mb_prefetch_fini(struct super_block *sb, ext4_group_t group,
+                                 unsigned int nr);
+
 extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
                             struct buffer_head *bh, ext4_fsblk_t block,
                             unsigned long count, int flags);
@@ -2765,8 +2804,7 @@ extern int ext4_search_dir(struct buffer_head *bh,
                           struct ext4_filename *fname,
                           unsigned int offset,
                           struct ext4_dir_entry_2 **res_dir);
-extern int ext4_generic_delete_entry(handle_t *handle,
-                                    struct inode *dir,
+extern int ext4_generic_delete_entry(struct inode *dir,
                                     struct ext4_dir_entry_2 *de_del,
                                     struct buffer_head *bh,
                                     void *entry_buf,
@@ -2924,12 +2962,6 @@ do {                                                                     \
 
 #endif
 
-extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
-                                       __u32 compat);
-extern int ext4_update_rocompat_feature(handle_t *handle,
-                                       struct super_block *sb, __u32 rocompat);
-extern int ext4_update_incompat_feature(handle_t *handle,
-                                       struct super_block *sb, __u32 incompat);
 extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
                                      struct ext4_group_desc *bg);
 extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -3145,6 +3177,7 @@ struct ext4_group_info {
        (1 << EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT)
 #define EXT4_GROUP_INFO_IBITMAP_CORRUPT                \
        (1 << EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT)
+#define EXT4_GROUP_INFO_BBITMAP_READ_BIT       4
 
 #define EXT4_MB_GRP_NEED_INIT(grp)     \
        (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state)))
@@ -3159,6 +3192,8 @@ struct ext4_group_info {
        (set_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
 #define EXT4_MB_GRP_CLEAR_TRIMMED(grp) \
        (clear_bit(EXT4_GROUP_INFO_WAS_TRIMMED_BIT, &((grp)->bb_state)))
+#define EXT4_MB_GRP_TEST_AND_SET_READ(grp)     \
+       (test_and_set_bit(EXT4_GROUP_INFO_BBITMAP_READ_BIT, &((grp)->bb_state)))
 
 #define EXT4_MAX_CONTENTION            8
 #define EXT4_CONTENTION_THRESHOLD      2
@@ -3363,9 +3398,9 @@ extern void ext4_release_system_zone(struct super_block *sb);
 extern int ext4_setup_system_zone(struct super_block *sb);
 extern int __init ext4_init_system_zone(void);
 extern void ext4_exit_system_zone(void);
-extern int ext4_data_block_valid(struct ext4_sb_info *sbi,
-                                ext4_fsblk_t start_blk,
-                                unsigned int count);
+extern int ext4_inode_block_valid(struct inode *inode,
+                                 ext4_fsblk_t start_blk,
+                                 unsigned int count);
 extern int ext4_check_blockref(const char *, unsigned int,
                               struct inode *, __le32 *, unsigned int);
 
index 0c76cdd..760b9ee 100644 (file)
@@ -195,6 +195,28 @@ static void ext4_journal_abort_handle(const char *caller, unsigned int line,
        jbd2_journal_abort_handle(handle);
 }
 
+static void ext4_check_bdev_write_error(struct super_block *sb)
+{
+       struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping;
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
+       int err;
+
+       /*
+        * If the block device has write error flag, it may have failed to
+        * async write out metadata buffers in the background. In this case,
+        * we could read old data from disk and write it out again, which
+        * may lead to on-disk filesystem inconsistency.
+        */
+       if (errseq_check(&mapping->wb_err, READ_ONCE(sbi->s_bdev_wb_err))) {
+               spin_lock(&sbi->s_bdev_wb_lock);
+               err = errseq_check_and_advance(&mapping->wb_err, &sbi->s_bdev_wb_err);
+               spin_unlock(&sbi->s_bdev_wb_lock);
+               if (err)
+                       ext4_error_err(sb, -err,
+                                      "Error while async write back metadata");
+       }
+}
+
 int __ext4_journal_get_write_access(const char *where, unsigned int line,
                                    handle_t *handle, struct buffer_head *bh)
 {
@@ -202,6 +224,9 @@ int __ext4_journal_get_write_access(const char *where, unsigned int line,
 
        might_sleep();
 
+       if (bh->b_bdev->bd_super)
+               ext4_check_bdev_write_error(bh->b_bdev->bd_super);
+
        if (ext4_handle_valid(handle)) {
                err = jbd2_journal_get_write_access(handle, bh);
                if (err)
index 221f240..a048158 100644 (file)
@@ -100,7 +100,7 @@ static int ext4_ext_trunc_restart_fn(struct inode *inode, int *dropped)
         * i_mutex. So we can safely drop the i_data_sem here.
         */
        BUG_ON(EXT4_JOURNAL(inode) == NULL);
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
        up_write(&EXT4_I(inode)->i_data_sem);
        *dropped = 1;
        return 0;
@@ -340,7 +340,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
         */
        if (lblock + len <= lblock)
                return 0;
-       return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
+       return ext4_inode_block_valid(inode, block, len);
 }
 
 static int ext4_valid_extent_idx(struct inode *inode,
@@ -348,7 +348,7 @@ static int ext4_valid_extent_idx(struct inode *inode,
 {
        ext4_fsblk_t block = ext4_idx_pblock(ext_idx);
 
-       return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, 1);
+       return ext4_inode_block_valid(inode, block, 1);
 }
 
 static int ext4_valid_extent_entries(struct inode *inode,
@@ -507,14 +507,10 @@ __read_extent_tree_block(const char *function, unsigned int line,
        }
        if (buffer_verified(bh) && !(flags & EXT4_EX_FORCE_CACHE))
                return bh;
-       if (!ext4_has_feature_journal(inode->i_sb) ||
-           (inode->i_ino !=
-            le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum))) {
-               err = __ext4_ext_check(function, line, inode,
-                                      ext_block_hdr(bh), depth, pblk);
-               if (err)
-                       goto errout;
-       }
+       err = __ext4_ext_check(function, line, inode,
+                              ext_block_hdr(bh), depth, pblk);
+       if (err)
+               goto errout;
        set_buffer_verified(bh);
        /*
         * If this is a leaf block, cache all of its entries
@@ -693,10 +689,8 @@ void ext4_ext_drop_refs(struct ext4_ext_path *path)
                return;
        depth = path->p_depth;
        for (i = 0; i <= depth; i++, path++) {
-               if (path->p_bh) {
-                       brelse(path->p_bh);
-                       path->p_bh = NULL;
-               }
+               brelse(path->p_bh);
+               path->p_bh = NULL;
        }
 }
 
@@ -1915,7 +1909,7 @@ out:
 
 /*
  * ext4_ext_insert_extent:
- * tries to merge requsted extent into the existing extent or
+ * tries to merge requested extent into the existing extent or
  * inserts requested extent as new one into the tree,
  * creating new leaf in the no-space case.
  */
@@ -3125,7 +3119,7 @@ static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
  *
  *
  * Splits extent [a, b] into two extents [a, @split) and [@split, b], states
- * of which are deterimined by split_flag.
+ * of which are determined by split_flag.
  *
  * There are two cases:
  *  a> the extent are splitted into two extent.
@@ -3650,7 +3644,7 @@ static int ext4_split_convert_extents(handle_t *handle,
                eof_block = map->m_lblk + map->m_len;
        /*
         * It is safe to convert extent to initialized via explicit
-        * zeroout only if extent is fully insde i_size or new_size.
+        * zeroout only if extent is fully inside i_size or new_size.
         */
        depth = ext_depth(inode);
        ex = path[depth].p_ext;
@@ -4272,7 +4266,7 @@ got_allocated_blocks:
                         * not a good idea to call discard here directly,
                         * but otherwise we'd need to call it every free().
                         */
-                       ext4_discard_preallocations(inode);
+                       ext4_discard_preallocations(inode, 0);
                        if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE)
                                fb_flags = EXT4_FREE_BLOCKS_NO_QUOT_UPDATE;
                        ext4_free_blocks(handle, inode, NULL, newblock,
@@ -4495,7 +4489,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
        }
 
        /*
-        * Round up offset. This is not fallocate, we neet to zero out
+        * Round up offset. This is not fallocate, we need to zero out
         * blocks, so convert interior block aligned part of the range to
         * unwritten and possibly manually zero out unaligned parts of the
         * range.
@@ -5299,7 +5293,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
        }
 
        down_write(&EXT4_I(inode)->i_data_sem);
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
 
        ret = ext4_es_remove_extent(inode, punch_start,
                                    EXT_MAX_BLOCKS - punch_start);
@@ -5313,7 +5307,7 @@ static int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
                up_write(&EXT4_I(inode)->i_data_sem);
                goto out_stop;
        }
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
 
        ret = ext4_ext_shift_extents(inode, handle, punch_stop,
                                     punch_stop - punch_start, SHIFT_LEFT);
@@ -5445,7 +5439,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
                goto out_stop;
 
        down_write(&EXT4_I(inode)->i_data_sem);
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
 
        path = ext4_find_extent(inode, offset_lblk, NULL, 0);
        if (IS_ERR(path)) {
@@ -5579,7 +5573,7 @@ ext4_swap_extents(handle_t *handle, struct inode *inode1,
                }
                ex1 = path1[path1->p_depth].p_ext;
                ex2 = path2[path2->p_depth].p_ext;
-               /* Do we have somthing to swap ? */
+               /* Do we have something to swap ? */
                if (unlikely(!ex2 || !ex1))
                        goto finish;
 
index 129cc1d..7d61069 100644 (file)
@@ -145,10 +145,9 @@ static int ext4_release_file(struct inode *inode, struct file *filp)
        /* if we are the last writer on the inode, drop the block reservation */
        if ((filp->f_mode & FMODE_WRITE) &&
                        (atomic_read(&inode->i_writecount) == 1) &&
-                       !EXT4_I(inode)->i_reserved_data_blocks)
-       {
+                       !EXT4_I(inode)->i_reserved_data_blocks) {
                down_write(&EXT4_I(inode)->i_data_sem);
-               ext4_discard_preallocations(inode);
+               ext4_discard_preallocations(inode, 0);
                up_write(&EXT4_I(inode)->i_data_sem);
        }
        if (is_dx(inode) && filp->private_data)
@@ -428,6 +427,10 @@ restart:
         */
        if (*ilock_shared && (!IS_NOSEC(inode) || *extend ||
             !ext4_overwrite_io(inode, offset, count))) {
+               if (iocb->ki_flags & IOCB_NOWAIT) {
+                       ret = -EAGAIN;
+                       goto out;
+               }
                inode_unlock_shared(inode);
                *ilock_shared = false;
                inode_lock(inode);
@@ -812,7 +815,7 @@ out:
        return err;
 }
 
-static int ext4_file_open(struct inode * inode, struct file * filp)
+static int ext4_file_open(struct inode *inode, struct file *filp)
 {
        int ret;
 
index 3e13379..2924261 100644 (file)
@@ -233,7 +233,7 @@ static int __ext4fs_dirhash(const char *name, int len,
                break;
        case DX_HASH_HALF_MD4_UNSIGNED:
                str2hashbuf = str2hashbuf_unsigned;
-               /* fall through */
+               fallthrough;
        case DX_HASH_HALF_MD4:
                p = name;
                while (len > 0) {
@@ -247,7 +247,7 @@ static int __ext4fs_dirhash(const char *name, int len,
                break;
        case DX_HASH_TEA_UNSIGNED:
                str2hashbuf = str2hashbuf_unsigned;
-               /* fall through */
+               fallthrough;
        case DX_HASH_TEA:
                p = name;
                while (len > 0) {
index be2b66e..80c9f33 100644 (file)
@@ -696,7 +696,7 @@ static int ext4_ind_trunc_restart_fn(handle_t *handle, struct inode *inode,
         * i_mutex. So we can safely drop the i_data_sem here.
         */
        BUG_ON(EXT4_JOURNAL(inode) == NULL);
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
        up_write(&EXT4_I(inode)->i_data_sem);
        *dropped = 1;
        return 0;
@@ -858,8 +858,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
        else if (ext4_should_journal_data(inode))
                flags |= EXT4_FREE_BLOCKS_FORGET;
 
-       if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free,
-                                  count)) {
+       if (!ext4_inode_block_valid(inode, block_to_free, count)) {
                EXT4_ERROR_INODE(inode, "attempt to clear invalid "
                                 "blocks %llu len %lu",
                                 (unsigned long long) block_to_free, count);
@@ -1004,8 +1003,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
                        if (!nr)
                                continue;               /* A hole */
 
-                       if (!ext4_data_block_valid(EXT4_SB(inode->i_sb),
-                                                  nr, 1)) {
+                       if (!ext4_inode_block_valid(inode, nr, 1)) {
                                EXT4_ERROR_INODE(inode,
                                                 "invalid indirect mapped "
                                                 "block %lu (level %d)",
@@ -1182,21 +1180,21 @@ do_indirects:
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
                        i_data[EXT4_IND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_IND_BLOCK:
                nr = i_data[EXT4_DIND_BLOCK];
                if (nr) {
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
                        i_data[EXT4_DIND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_DIND_BLOCK:
                nr = i_data[EXT4_TIND_BLOCK];
                if (nr) {
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
                        i_data[EXT4_TIND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_TIND_BLOCK:
                ;
        }
@@ -1436,7 +1434,7 @@ do_indirects:
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
                        i_data[EXT4_IND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_IND_BLOCK:
                if (++n >= n2)
                        break;
@@ -1445,7 +1443,7 @@ do_indirects:
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
                        i_data[EXT4_DIND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_DIND_BLOCK:
                if (++n >= n2)
                        break;
@@ -1454,7 +1452,7 @@ do_indirects:
                        ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
                        i_data[EXT4_TIND_BLOCK] = 0;
                }
-               /* fall through */
+               fallthrough;
        case EXT4_TIND_BLOCK:
                ;
        }
index c3a1ad2..75c97bc 100644 (file)
@@ -276,7 +276,7 @@ static int ext4_create_inline_data(handle_t *handle,
                len = 0;
        }
 
-       /* Insert the the xttr entry. */
+       /* Insert the xttr entry. */
        i.value = value;
        i.value_len = len;
 
@@ -1706,7 +1706,7 @@ int ext4_delete_inline_entry(handle_t *handle,
        if (err)
                goto out;
 
-       err = ext4_generic_delete_entry(handle, dir, de_del, bh,
+       err = ext4_generic_delete_entry(dir, de_del, bh,
                                        inline_start, inline_size, 0);
        if (err)
                goto out;
index 44bad4b..bf59646 100644 (file)
@@ -383,7 +383,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
         */
        if ((ei->i_reserved_data_blocks == 0) &&
            !inode_is_open_for_write(inode))
-               ext4_discard_preallocations(inode);
+               ext4_discard_preallocations(inode, 0);
 }
 
 static int __check_block_validity(struct inode *inode, const char *func,
@@ -394,8 +394,7 @@ static int __check_block_validity(struct inode *inode, const char *func,
            (inode->i_ino ==
             le32_to_cpu(EXT4_SB(inode->i_sb)->s_es->s_journal_inum)))
                return 0;
-       if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,
-                                  map->m_len)) {
+       if (!ext4_inode_block_valid(inode, map->m_pblk, map->m_len)) {
                ext4_error_inode(inode, func, line, map->m_pblk,
                                 "lblock %lu mapped to illegal pblock %llu "
                                 "(length %d)", (unsigned long) map->m_lblk,
@@ -3288,7 +3287,7 @@ static int ext4_releasepage(struct page *page, gfp_t wait)
        if (PageChecked(page))
                return 0;
        if (journal)
-               return jbd2_journal_try_to_free_buffers(journal, page, wait);
+               return jbd2_journal_try_to_free_buffers(journal, page);
        else
                return try_to_free_buffers(page);
 }
@@ -4056,7 +4055,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
        if (stop_block > first_block) {
 
                down_write(&EXT4_I(inode)->i_data_sem);
-               ext4_discard_preallocations(inode);
+               ext4_discard_preallocations(inode, 0);
 
                ret = ext4_es_remove_extent(inode, first_block,
                                            stop_block - first_block);
@@ -4163,7 +4162,7 @@ int ext4_truncate(struct inode *inode)
        trace_ext4_truncate_enter(inode);
 
        if (!ext4_can_truncate(inode))
-               return 0;
+               goto out_trace;
 
        if (inode->i_size == 0 && !test_opt(inode->i_sb, NO_AUTO_DA_ALLOC))
                ext4_set_inode_state(inode, EXT4_STATE_DA_ALLOC_CLOSE);
@@ -4172,16 +4171,14 @@ int ext4_truncate(struct inode *inode)
                int has_inline = 1;
 
                err = ext4_inline_data_truncate(inode, &has_inline);
-               if (err)
-                       return err;
-               if (has_inline)
-                       return 0;
+               if (err || has_inline)
+                       goto out_trace;
        }
 
        /* If we zero-out tail of the page, we have to create jinode for jbd2 */
        if (inode->i_size & (inode->i_sb->s_blocksize - 1)) {
                if (ext4_inode_attach_jinode(inode) < 0)
-                       return 0;
+                       goto out_trace;
        }
 
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
@@ -4190,8 +4187,10 @@ int ext4_truncate(struct inode *inode)
                credits = ext4_blocks_for_truncate(inode);
 
        handle = ext4_journal_start(inode, EXT4_HT_TRUNCATE, credits);
-       if (IS_ERR(handle))
-               return PTR_ERR(handle);
+       if (IS_ERR(handle)) {
+               err = PTR_ERR(handle);
+               goto out_trace;
+       }
 
        if (inode->i_size & (inode->i_sb->s_blocksize - 1))
                ext4_block_truncate_page(handle, mapping, inode->i_size);
@@ -4211,7 +4210,7 @@ int ext4_truncate(struct inode *inode)
 
        down_write(&EXT4_I(inode)->i_data_sem);
 
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
 
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
                err = ext4_ext_truncate(handle, inode);
@@ -4242,6 +4241,7 @@ out_stop:
                err = err2;
        ext4_journal_stop(handle);
 
+out_trace:
        trace_ext4_truncate_exit(inode);
        return err;
 }
@@ -4760,7 +4760,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
 
        ret = 0;
        if (ei->i_file_acl &&
-           !ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
+           !ext4_inode_block_valid(inode, ei->i_file_acl, 1)) {
                ext4_error_inode(inode, function, line, 0,
                                 "iget: bad extended attribute block %llu",
                                 ei->i_file_acl);
@@ -4901,7 +4901,7 @@ static void __ext4_update_other_inode_time(struct super_block *sb,
            (inode->i_state & I_DIRTY_TIME)) {
                struct ext4_inode_info  *ei = EXT4_I(inode);
 
-               inode->i_state &= ~(I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED);
+               inode->i_state &= ~I_DIRTY_TIME;
                spin_unlock(&inode->i_lock);
 
                spin_lock(&ei->i_raw_lock);
index 999cf6a..36eca3b 100644 (file)
@@ -202,7 +202,7 @@ static long swap_inode_boot_loader(struct super_block *sb,
        reset_inode_seed(inode);
        reset_inode_seed(inode_bl);
 
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
 
        err = ext4_mark_inode_dirty(handle, inode);
        if (err < 0) {
@@ -819,12 +819,12 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        switch (cmd) {
        case FS_IOC_GETFSMAP:
                return ext4_ioc_getfsmap(sb, (void __user *)arg);
-       case EXT4_IOC_GETFLAGS:
+       case FS_IOC_GETFLAGS:
                flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
                if (S_ISREG(inode->i_mode))
                        flags &= ~EXT4_PROJINHERIT_FL;
                return put_user(flags, (int __user *) arg);
-       case EXT4_IOC_SETFLAGS: {
+       case FS_IOC_SETFLAGS: {
                int err;
 
                if (!inode_owner_or_capable(inode))
@@ -1129,12 +1129,12 @@ resizefs_out:
        case EXT4_IOC_PRECACHE_EXTENTS:
                return ext4_ext_precache(inode);
 
-       case EXT4_IOC_SET_ENCRYPTION_POLICY:
+       case FS_IOC_SET_ENCRYPTION_POLICY:
                if (!ext4_has_feature_encrypt(sb))
                        return -EOPNOTSUPP;
                return fscrypt_ioctl_set_policy(filp, (const void __user *)arg);
 
-       case EXT4_IOC_GET_ENCRYPTION_PWSALT: {
+       case FS_IOC_GET_ENCRYPTION_PWSALT: {
 #ifdef CONFIG_FS_ENCRYPTION
                int err, err2;
                struct ext4_sb_info *sbi = EXT4_SB(sb);
@@ -1174,7 +1174,7 @@ resizefs_out:
                return -EOPNOTSUPP;
 #endif
        }
-       case EXT4_IOC_GET_ENCRYPTION_POLICY:
+       case FS_IOC_GET_ENCRYPTION_POLICY:
                if (!ext4_has_feature_encrypt(sb))
                        return -EOPNOTSUPP;
                return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
@@ -1236,7 +1236,7 @@ resizefs_out:
        case EXT4_IOC_GET_ES_CACHE:
                return ext4_ioctl_get_es_cache(filp, arg);
 
-       case EXT4_IOC_FSGETXATTR:
+       case FS_IOC_FSGETXATTR:
        {
                struct fsxattr fa;
 
@@ -1247,7 +1247,7 @@ resizefs_out:
                        return -EFAULT;
                return 0;
        }
-       case EXT4_IOC_FSSETXATTR:
+       case FS_IOC_FSSETXATTR:
        {
                struct fsxattr fa, old_fa;
                int err;
@@ -1313,11 +1313,11 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
        /* These are just misnamed, they actually get/put from/to user an int */
        switch (cmd) {
-       case EXT4_IOC32_GETFLAGS:
-               cmd = EXT4_IOC_GETFLAGS;
+       case FS_IOC32_GETFLAGS:
+               cmd = FS_IOC_GETFLAGS;
                break;
-       case EXT4_IOC32_SETFLAGS:
-               cmd = EXT4_IOC_SETFLAGS;
+       case FS_IOC32_SETFLAGS:
+               cmd = FS_IOC_SETFLAGS;
                break;
        case EXT4_IOC32_GETVERSION:
                cmd = EXT4_IOC_GETVERSION;
@@ -1361,9 +1361,9 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case EXT4_IOC_RESIZE_FS:
        case FITRIM:
        case EXT4_IOC_PRECACHE_EXTENTS:
-       case EXT4_IOC_SET_ENCRYPTION_POLICY:
-       case EXT4_IOC_GET_ENCRYPTION_PWSALT:
-       case EXT4_IOC_GET_ENCRYPTION_POLICY:
+       case FS_IOC_SET_ENCRYPTION_POLICY:
+       case FS_IOC_GET_ENCRYPTION_PWSALT:
+       case FS_IOC_GET_ENCRYPTION_POLICY:
        case FS_IOC_GET_ENCRYPTION_POLICY_EX:
        case FS_IOC_ADD_ENCRYPTION_KEY:
        case FS_IOC_REMOVE_ENCRYPTION_KEY:
@@ -1377,8 +1377,8 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case EXT4_IOC_CLEAR_ES_CACHE:
        case EXT4_IOC_GETSTATE:
        case EXT4_IOC_GET_ES_CACHE:
-       case EXT4_IOC_FSGETXATTR:
-       case EXT4_IOC_FSSETXATTR:
+       case FS_IOC_FSGETXATTR:
+       case FS_IOC_FSSETXATTR:
                break;
        default:
                return -ENOIOCTLCMD;
index c0a331e..132c118 100644 (file)
@@ -922,7 +922,7 @@ static int ext4_mb_init_cache(struct page *page, char *incore, gfp_t gfp)
                        bh[i] = NULL;
                        continue;
                }
-               bh[i] = ext4_read_block_bitmap_nowait(sb, group);
+               bh[i] = ext4_read_block_bitmap_nowait(sb, group, false);
                if (IS_ERR(bh[i])) {
                        err = PTR_ERR(bh[i]);
                        bh[i] = NULL;
@@ -1279,9 +1279,6 @@ ext4_mb_load_buddy_gfp(struct super_block *sb, ext4_group_t group,
        e4b->bd_buddy_page = page;
        e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize);
 
-       BUG_ON(e4b->bd_bitmap_page == NULL);
-       BUG_ON(e4b->bd_buddy_page == NULL);
-
        return 0;
 
 err:
@@ -1743,10 +1740,6 @@ static void ext4_mb_use_best_found(struct ext4_allocation_context *ac,
 
 }
 
-/*
- * regular allocator, for general purposes allocation
- */
-
 static void ext4_mb_check_limits(struct ext4_allocation_context *ac,
                                        struct ext4_buddy *e4b,
                                        int finish_group)
@@ -2119,13 +2112,11 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac,
 
        BUG_ON(cr < 0 || cr >= 4);
 
-       free = grp->bb_free;
-       if (free == 0)
-               return false;
-       if (cr <= 2 && free < ac->ac_g_ex.fe_len)
+       if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp)))
                return false;
 
-       if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(grp)))
+       free = grp->bb_free;
+       if (free == 0)
                return false;
 
        fragments = grp->bb_fragments;
@@ -2142,8 +2133,10 @@ static bool ext4_mb_good_group(struct ext4_allocation_context *ac,
                    ((group % flex_size) == 0))
                        return false;
 
-               if ((ac->ac_2order > ac->ac_sb->s_blocksize_bits+1) ||
-                   (free / fragments) >= ac->ac_g_ex.fe_len)
+               if (free < ac->ac_g_ex.fe_len)
+                       return false;
+
+               if (ac->ac_2order > ac->ac_sb->s_blocksize_bits+1)
                        return true;
 
                if (grp->bb_largest_free_order < ac->ac_2order)
@@ -2177,6 +2170,7 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
 {
        struct ext4_group_info *grp = ext4_get_group_info(ac->ac_sb, group);
        struct super_block *sb = ac->ac_sb;
+       struct ext4_sb_info *sbi = EXT4_SB(sb);
        bool should_lock = ac->ac_flags & EXT4_MB_STRICT_CHECK;
        ext4_grpblk_t free;
        int ret = 0;
@@ -2195,7 +2189,25 @@ static int ext4_mb_good_group_nolock(struct ext4_allocation_context *ac,
 
        /* We only do this if the grp has never been initialized */
        if (unlikely(EXT4_MB_GRP_NEED_INIT(grp))) {
-               ret = ext4_mb_init_group(ac->ac_sb, group, GFP_NOFS);
+               struct ext4_group_desc *gdp =
+                       ext4_get_group_desc(sb, group, NULL);
+               int ret;
+
+               /* cr=0/1 is a very optimistic search to find large
+                * good chunks almost for free.  If buddy data is not
+                * ready, then this optimization makes no sense.  But
+                * we never skip the first block group in a flex_bg,
+                * since this gets used for metadata block allocation,
+                * and we want to make sure we locate metadata blocks
+                * in the first block group in the flex_bg if possible.
+                */
+               if (cr < 2 &&
+                   (!sbi->s_log_groups_per_flex ||
+                    ((group & ((1 << sbi->s_log_groups_per_flex) - 1)) != 0)) &&
+                   !(ext4_has_group_desc_csum(sb) &&
+                     (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT))))
+                       return 0;
+               ret = ext4_mb_init_group(sb, group, GFP_NOFS);
                if (ret)
                        return ret;
        }
@@ -2209,15 +2221,95 @@ out:
        return ret;
 }
 
+/*
+ * Start prefetching @nr block bitmaps starting at @group.
+ * Return the next group which needs to be prefetched.
+ */
+ext4_group_t ext4_mb_prefetch(struct super_block *sb, ext4_group_t group,
+                             unsigned int nr, int *cnt)
+{
+       ext4_group_t ngroups = ext4_get_groups_count(sb);
+       struct buffer_head *bh;
+       struct blk_plug plug;
+
+       blk_start_plug(&plug);
+       while (nr-- > 0) {
+               struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group,
+                                                                 NULL);
+               struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+
+               /*
+                * Prefetch block groups with free blocks; but don't
+                * bother if it is marked uninitialized on disk, since
+                * it won't require I/O to read.  Also only try to
+                * prefetch once, so we avoid getblk() call, which can
+                * be expensive.
+                */
+               if (!EXT4_MB_GRP_TEST_AND_SET_READ(grp) &&
+                   EXT4_MB_GRP_NEED_INIT(grp) &&
+                   ext4_free_group_clusters(sb, gdp) > 0 &&
+                   !(ext4_has_group_desc_csum(sb) &&
+                     (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)))) {
+                       bh = ext4_read_block_bitmap_nowait(sb, group, true);
+                       if (bh && !IS_ERR(bh)) {
+                               if (!buffer_uptodate(bh) && cnt)
+                                       (*cnt)++;
+                               brelse(bh);
+                       }
+               }
+               if (++group >= ngroups)
+                       group = 0;
+       }
+       blk_finish_plug(&plug);
+       return group;
+}
+
+/*
+ * Prefetching reads the block bitmap into the buffer cache; but we
+ * need to make sure that the buddy bitmap in the page cache has been
+ * initialized.  Note that ext4_mb_init_group() will block if the I/O
+ * is not yet completed, or indeed if it was not initiated by
+ * ext4_mb_prefetch did not start the I/O.
+ *
+ * TODO: We should actually kick off the buddy bitmap setup in a work
+ * queue when the buffer I/O is completed, so that we don't block
+ * waiting for the block allocation bitmap read to finish when
+ * ext4_mb_prefetch_fini is called from ext4_mb_regular_allocator().
+ */
+void ext4_mb_prefetch_fini(struct super_block *sb, ext4_group_t group,
+                          unsigned int nr)
+{
+       while (nr-- > 0) {
+               struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group,
+                                                                 NULL);
+               struct ext4_group_info *grp = ext4_get_group_info(sb, group);
+
+               if (!group)
+                       group = ext4_get_groups_count(sb);
+               group--;
+               grp = ext4_get_group_info(sb, group);
+
+               if (EXT4_MB_GRP_NEED_INIT(grp) &&
+                   ext4_free_group_clusters(sb, gdp) > 0 &&
+                   !(ext4_has_group_desc_csum(sb) &&
+                     (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)))) {
+                       if (ext4_mb_init_group(sb, group, GFP_NOFS))
+                               break;
+               }
+       }
+}
+
 static noinline_for_stack int
 ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
 {
-       ext4_group_t ngroups, group, i;
+       ext4_group_t prefetch_grp = 0, ngroups, group, i;
        int cr = -1;
        int err = 0, first_err = 0;
+       unsigned int nr = 0, prefetch_ios = 0;
        struct ext4_sb_info *sbi;
        struct super_block *sb;
        struct ext4_buddy e4b;
+       int lost;
 
        sb = ac->ac_sb;
        sbi = EXT4_SB(sb);
@@ -2237,8 +2329,8 @@ ext4_mb_regular_allocator(struct ext4_allocation_context *ac)
                goto out;
 
        /*
-        * ac->ac2_order is set only if the fe_len is a power of 2
-        * if ac2_order is set we also set criteria to 0 so that we
+        * ac->ac_2order is set only if the fe_len is a power of 2
+        * if ac->ac_2order is set we also set criteria to 0 so that we
         * try exact allocation using buddy.
         */
        i = fls(ac->ac_g_ex.fe_len);
@@ -2282,6 +2374,7 @@ repeat:
                 * from the goal value specified
                 */
                group = ac->ac_g_ex.fe_group;
+               prefetch_grp = group;
 
                for (i = 0; i < ngroups; group++, i++) {
                        int ret = 0;
@@ -2293,6 +2386,29 @@ repeat:
                        if (group >= ngroups)
                                group = 0;
 
+                       /*
+                        * Batch reads of the block allocation bitmaps
+                        * to get multiple READs in flight; limit
+                        * prefetching at cr=0/1, otherwise mballoc can
+                        * spend a lot of time loading imperfect groups
+                        */
+                       if ((prefetch_grp == group) &&
+                           (cr > 1 ||
+                            prefetch_ios < sbi->s_mb_prefetch_limit)) {
+                               unsigned int curr_ios = prefetch_ios;
+
+                               nr = sbi->s_mb_prefetch;
+                               if (ext4_has_feature_flex_bg(sb)) {
+                                       nr = (group / sbi->s_mb_prefetch) *
+                                               sbi->s_mb_prefetch;
+                                       nr = nr + sbi->s_mb_prefetch - group;
+                               }
+                               prefetch_grp = ext4_mb_prefetch(sb, group,
+                                                       nr, &prefetch_ios);
+                               if (prefetch_ios == curr_ios)
+                                       nr = 0;
+                       }
+
                        /* This now checks without needing the buddy page */
                        ret = ext4_mb_good_group_nolock(ac, group, cr);
                        if (ret <= 0) {
@@ -2341,22 +2457,24 @@ repeat:
                 * We've been searching too long. Let's try to allocate
                 * the best chunk we've found so far
                 */
-
                ext4_mb_try_best_found(ac, &e4b);
                if (ac->ac_status != AC_STATUS_FOUND) {
                        /*
                         * Someone more lucky has already allocated it.
                         * The only thing we can do is just take first
                         * found block(s)
-                       printk(KERN_DEBUG "EXT4-fs: someone won our chunk\n");
                         */
+                       lost = atomic_inc_return(&sbi->s_mb_lost_chunks);
+                       mb_debug(sb, "lost chunk, group: %u, start: %d, len: %d, lost: %d\n",
+                                ac->ac_b_ex.fe_group, ac->ac_b_ex.fe_start,
+                                ac->ac_b_ex.fe_len, lost);
+
                        ac->ac_b_ex.fe_group = 0;
                        ac->ac_b_ex.fe_start = 0;
                        ac->ac_b_ex.fe_len = 0;
                        ac->ac_status = AC_STATUS_CONTINUE;
                        ac->ac_flags |= EXT4_MB_HINT_FIRST;
                        cr = 3;
-                       atomic_inc(&sbi->s_mb_lost_chunks);
                        goto repeat;
                }
        }
@@ -2367,6 +2485,10 @@ out:
        mb_debug(sb, "Best len %d, origin len %d, ac_status %u, ac_flags 0x%x, cr %d ret %d\n",
                 ac->ac_b_ex.fe_len, ac->ac_o_ex.fe_len, ac->ac_status,
                 ac->ac_flags, cr, err);
+
+       if (nr)
+               ext4_mb_prefetch_fini(sb, prefetch_grp, nr);
+
        return err;
 }
 
@@ -2439,7 +2561,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
        for (i = 0; i <= 13; i++)
                seq_printf(seq, " %-5u", i <= blocksize_bits + 1 ?
                                sg.info.bb_counters[i] : 0);
-       seq_printf(seq, " ]\n");
+       seq_puts(seq, " ]\n");
 
        return 0;
 }
@@ -2613,6 +2735,26 @@ static int ext4_mb_init_backend(struct super_block *sb)
                        goto err_freebuddy;
        }
 
+       if (ext4_has_feature_flex_bg(sb)) {
+               /* a single flex group is supposed to be read by a single IO */
+               sbi->s_mb_prefetch = 1 << sbi->s_es->s_log_groups_per_flex;
+               sbi->s_mb_prefetch *= 8; /* 8 prefetch IOs in flight at most */
+       } else {
+               sbi->s_mb_prefetch = 32;
+       }
+       if (sbi->s_mb_prefetch > ext4_get_groups_count(sb))
+               sbi->s_mb_prefetch = ext4_get_groups_count(sb);
+       /* now many real IOs to prefetch within a single allocation at cr=0
+        * given cr=0 is an CPU-related optimization we shouldn't try to
+        * load too many groups, at some point we should start to use what
+        * we've got in memory.
+        * with an average random access time 5ms, it'd take a second to get
+        * 200 groups (* N with flex_bg), so let's make this limit 4
+        */
+       sbi->s_mb_prefetch_limit = sbi->s_mb_prefetch * 4;
+       if (sbi->s_mb_prefetch_limit > ext4_get_groups_count(sb))
+               sbi->s_mb_prefetch_limit = ext4_get_groups_count(sb);
+
        return 0;
 
 err_freebuddy:
@@ -2736,6 +2878,7 @@ int ext4_mb_init(struct super_block *sb)
        sbi->s_mb_stats = MB_DEFAULT_STATS;
        sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
        sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
+       sbi->s_mb_max_inode_prealloc = MB_DEFAULT_MAX_INODE_PREALLOC;
        /*
         * The default group preallocation is 512, which for 4k block
         * sizes translates to 2 megabytes.  However for bigalloc file
@@ -3090,7 +3233,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
        block = ext4_grp_offs_to_block(sb, &ac->ac_b_ex);
 
        len = EXT4_C2B(sbi, ac->ac_b_ex.fe_len);
-       if (!ext4_data_block_valid(sbi, block, len)) {
+       if (!ext4_inode_block_valid(ac->ac_inode, block, len)) {
                ext4_error(sb, "Allocating blocks %llu-%llu which overlap "
                           "fs metadata", block, block+len);
                /* File system mounted not to panic on error
@@ -3674,6 +3817,26 @@ void ext4_mb_generate_from_pa(struct super_block *sb, void *bitmap,
        mb_debug(sb, "preallocated %d for group %u\n", preallocated, group);
 }
 
+static void ext4_mb_mark_pa_deleted(struct super_block *sb,
+                                   struct ext4_prealloc_space *pa)
+{
+       struct ext4_inode_info *ei;
+
+       if (pa->pa_deleted) {
+               ext4_warning(sb, "deleted pa, type:%d, pblk:%llu, lblk:%u, len:%d\n",
+                            pa->pa_type, pa->pa_pstart, pa->pa_lstart,
+                            pa->pa_len);
+               return;
+       }
+
+       pa->pa_deleted = 1;
+
+       if (pa->pa_type == MB_INODE_PA) {
+               ei = EXT4_I(pa->pa_inode);
+               atomic_dec(&ei->i_prealloc_active);
+       }
+}
+
 static void ext4_mb_pa_callback(struct rcu_head *head)
 {
        struct ext4_prealloc_space *pa;
@@ -3706,7 +3869,7 @@ static void ext4_mb_put_pa(struct ext4_allocation_context *ac,
                return;
        }
 
-       pa->pa_deleted = 1;
+       ext4_mb_mark_pa_deleted(sb, pa);
        spin_unlock(&pa->pa_lock);
 
        grp_blk = pa->pa_pstart;
@@ -3830,6 +3993,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
        spin_lock(pa->pa_obj_lock);
        list_add_rcu(&pa->pa_inode_list, &ei->i_prealloc_list);
        spin_unlock(pa->pa_obj_lock);
+       atomic_inc(&ei->i_prealloc_active);
 }
 
 /*
@@ -4040,7 +4204,7 @@ repeat:
                }
 
                /* seems this one can be freed ... */
-               pa->pa_deleted = 1;
+               ext4_mb_mark_pa_deleted(sb, pa);
 
                /* we can trust pa_free ... */
                free += pa->pa_free;
@@ -4103,7 +4267,7 @@ out_dbg:
  *
  * FIXME!! Make sure it is valid at all the call sites
  */
-void ext4_discard_preallocations(struct inode *inode)
+void ext4_discard_preallocations(struct inode *inode, unsigned int needed)
 {
        struct ext4_inode_info *ei = EXT4_I(inode);
        struct super_block *sb = inode->i_sb;
@@ -4121,15 +4285,19 @@ void ext4_discard_preallocations(struct inode *inode)
 
        mb_debug(sb, "discard preallocation for inode %lu\n",
                 inode->i_ino);
-       trace_ext4_discard_preallocations(inode);
+       trace_ext4_discard_preallocations(inode,
+                       atomic_read(&ei->i_prealloc_active), needed);
 
        INIT_LIST_HEAD(&list);
 
+       if (needed == 0)
+               needed = UINT_MAX;
+
 repeat:
        /* first, collect all pa's in the inode */
        spin_lock(&ei->i_prealloc_lock);
-       while (!list_empty(&ei->i_prealloc_list)) {
-               pa = list_entry(ei->i_prealloc_list.next,
+       while (!list_empty(&ei->i_prealloc_list) && needed) {
+               pa = list_entry(ei->i_prealloc_list.prev,
                                struct ext4_prealloc_space, pa_inode_list);
                BUG_ON(pa->pa_obj_lock != &ei->i_prealloc_lock);
                spin_lock(&pa->pa_lock);
@@ -4146,10 +4314,11 @@ repeat:
 
                }
                if (pa->pa_deleted == 0) {
-                       pa->pa_deleted = 1;
+                       ext4_mb_mark_pa_deleted(sb, pa);
                        spin_unlock(&pa->pa_lock);
                        list_del_rcu(&pa->pa_inode_list);
                        list_add(&pa->u.pa_tmp_list, &list);
+                       needed--;
                        continue;
                }
 
@@ -4399,7 +4568,7 @@ ext4_mb_initialize_context(struct ext4_allocation_context *ac,
        ac->ac_g_ex = ac->ac_o_ex;
        ac->ac_flags = ar->flags;
 
-       /* we have to define context: we'll we work with a file or
+       /* we have to define context: we'll work with a file or
         * locality group. this is a policy, actually */
        ext4_mb_group_or_file(ac);
 
@@ -4450,7 +4619,7 @@ ext4_mb_discard_lg_preallocations(struct super_block *sb,
                BUG_ON(pa->pa_type != MB_GROUP_PA);
 
                /* seems this one can be freed ... */
-               pa->pa_deleted = 1;
+               ext4_mb_mark_pa_deleted(sb, pa);
                spin_unlock(&pa->pa_lock);
 
                list_del_rcu(&pa->pa_inode_list);
@@ -4548,11 +4717,30 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
        return ;
 }
 
+/*
+ * if per-inode prealloc list is too long, trim some PA
+ */
+static void ext4_mb_trim_inode_pa(struct inode *inode)
+{
+       struct ext4_inode_info *ei = EXT4_I(inode);
+       struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
+       int count, delta;
+
+       count = atomic_read(&ei->i_prealloc_active);
+       delta = (sbi->s_mb_max_inode_prealloc >> 2) + 1;
+       if (count > sbi->s_mb_max_inode_prealloc + delta) {
+               count -= sbi->s_mb_max_inode_prealloc;
+               ext4_discard_preallocations(inode, count);
+       }
+}
+
 /*
  * release all resource we used in allocation
  */
 static int ext4_mb_release_context(struct ext4_allocation_context *ac)
 {
+       struct inode *inode = ac->ac_inode;
+       struct ext4_inode_info *ei = EXT4_I(inode);
        struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
        struct ext4_prealloc_space *pa = ac->ac_pa;
        if (pa) {
@@ -4564,21 +4752,31 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
                        pa->pa_free -= ac->ac_b_ex.fe_len;
                        pa->pa_len -= ac->ac_b_ex.fe_len;
                        spin_unlock(&pa->pa_lock);
+
+                       /*
+                        * We want to add the pa to the right bucket.
+                        * Remove it from the list and while adding
+                        * make sure the list to which we are adding
+                        * doesn't grow big.
+                        */
+                       if (likely(pa->pa_free)) {
+                               spin_lock(pa->pa_obj_lock);
+                               list_del_rcu(&pa->pa_inode_list);
+                               spin_unlock(pa->pa_obj_lock);
+                               ext4_mb_add_n_trim(ac);
+                       }
                }
-       }
-       if (pa) {
-               /*
-                * We want to add the pa to the right bucket.
-                * Remove it from the list and while adding
-                * make sure the list to which we are adding
-                * doesn't grow big.
-                */
-               if ((pa->pa_type == MB_GROUP_PA) && likely(pa->pa_free)) {
+
+               if (pa->pa_type == MB_INODE_PA) {
+                       /*
+                        * treat per-inode prealloc list as a lru list, then try
+                        * to trim the least recently used PA.
+                        */
                        spin_lock(pa->pa_obj_lock);
-                       list_del_rcu(&pa->pa_inode_list);
+                       list_move(&pa->pa_inode_list, &ei->i_prealloc_list);
                        spin_unlock(pa->pa_obj_lock);
-                       ext4_mb_add_n_trim(ac);
                }
+
                ext4_mb_put_pa(ac, ac->ac_sb, pa);
        }
        if (ac->ac_bitmap_page)
@@ -4588,6 +4786,7 @@ static int ext4_mb_release_context(struct ext4_allocation_context *ac)
        if (ac->ac_flags & EXT4_MB_HINT_GROUP_ALLOC)
                mutex_unlock(&ac->ac_lg->lg_mutex);
        ext4_mb_collect_stats(ac);
+       ext4_mb_trim_inode_pa(inode);
        return 0;
 }
 
@@ -4915,7 +5114,7 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
 
        sbi = EXT4_SB(sb);
        if (!(flags & EXT4_FREE_BLOCKS_VALIDATED) &&
-           !ext4_data_block_valid(sbi, block, count)) {
+           !ext4_inode_block_valid(inode, block, count)) {
                ext4_error(sb, "Freeing blocks not in datazone - "
                           "block = %llu, count = %lu", block, count);
                goto error_return;
index 6b4d17c..e75b474 100644 (file)
  */
 #define MB_DEFAULT_GROUP_PREALLOC      512
 
+/*
+ * maximum length of inode prealloc list
+ */
+#define MB_DEFAULT_MAX_INODE_PREALLOC  512
 
 struct ext4_free_data {
        /* this links the free block information from sb_info */
index 1ed86fb..0d601b8 100644 (file)
@@ -686,8 +686,8 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
 
 out:
        if (*moved_len) {
-               ext4_discard_preallocations(orig_inode);
-               ext4_discard_preallocations(donor_inode);
+               ext4_discard_preallocations(orig_inode, 0);
+               ext4_discard_preallocations(donor_inode, 0);
        }
 
        ext4_ext_drop_refs(path);
index 56738b5..153a9fb 100644 (file)
@@ -1396,8 +1396,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
                    ext4_match(dir, fname, de)) {
                        /* found a match - just to be sure, do
                         * a full check */
-                       if (ext4_check_dir_entry(dir, NULL, de, bh, bh->b_data,
-                                                bh->b_size, offset))
+                       if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf,
+                                                buf_size, offset))
                                return -1;
                        *res_dir = de;
                        return 1;
@@ -1858,7 +1858,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
                             blocksize, hinfo, map);
        map -= count;
        dx_sort_map(map, count);
-       /* Split the existing block in the middle, size-wise */
+       /* Ensure that neither split block is over half full */
        size = 0;
        move = 0;
        for (i = count-1; i >= 0; i--) {
@@ -1868,8 +1868,18 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
                size += map[i].size;
                move++;
        }
-       /* map index at which we will split */
-       split = count - move;
+       /*
+        * map index at which we will split
+        *
+        * If the sum of active entries didn't exceed half the block size, just
+        * split it in half by count; each resulting block will have at least
+        * half the space free.
+        */
+       if (i > 0)
+               split = count - move;
+       else
+               split = count/2;
+
        hash2 = map[split].hash;
        continued = hash2 == map[split - 1].hash;
        dxtrace(printk(KERN_INFO "Split block %lu at %x, %i/%i\n",
@@ -2455,8 +2465,7 @@ cleanup:
  * ext4_generic_delete_entry deletes a directory entry by merging it
  * with the previous entry
  */
-int ext4_generic_delete_entry(handle_t *handle,
-                             struct inode *dir,
+int ext4_generic_delete_entry(struct inode *dir,
                              struct ext4_dir_entry_2 *de_del,
                              struct buffer_head *bh,
                              void *entry_buf,
@@ -2472,7 +2481,7 @@ int ext4_generic_delete_entry(handle_t *handle,
        de = (struct ext4_dir_entry_2 *)entry_buf;
        while (i < buf_size - csum_size) {
                if (ext4_check_dir_entry(dir, NULL, de, bh,
-                                        bh->b_data, bh->b_size, i))
+                                        entry_buf, buf_size, i))
                        return -EFSCORRUPTED;
                if (de == de_del)  {
                        if (pde)
@@ -2517,8 +2526,7 @@ static int ext4_delete_entry(handle_t *handle,
        if (unlikely(err))
                goto out;
 
-       err = ext4_generic_delete_entry(handle, dir, de_del,
-                                       bh, bh->b_data,
+       err = ext4_generic_delete_entry(dir, de_del, bh, bh->b_data,
                                        dir->i_sb->s_blocksize, csum_size);
        if (err)
                goto out;
@@ -3193,30 +3201,33 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
         * in separate transaction */
        retval = dquot_initialize(dir);
        if (retval)
-               return retval;
+               goto out_trace;
        retval = dquot_initialize(d_inode(dentry));
        if (retval)
-               return retval;
+               goto out_trace;
 
-       retval = -ENOENT;
        bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL);
-       if (IS_ERR(bh))
-               return PTR_ERR(bh);
-       if (!bh)
-               goto end_unlink;
+       if (IS_ERR(bh)) {
+               retval = PTR_ERR(bh);
+               goto out_trace;
+       }
+       if (!bh) {
+               retval = -ENOENT;
+               goto out_trace;
+       }
 
        inode = d_inode(dentry);
 
-       retval = -EFSCORRUPTED;
-       if (le32_to_cpu(de->inode) != inode->i_ino)
-               goto end_unlink;
+       if (le32_to_cpu(de->inode) != inode->i_ino) {
+               retval = -EFSCORRUPTED;
+               goto out_bh;
+       }
 
        handle = ext4_journal_start(dir, EXT4_HT_DIR,
                                    EXT4_DATA_TRANS_BLOCKS(dir->i_sb));
        if (IS_ERR(handle)) {
                retval = PTR_ERR(handle);
-               handle = NULL;
-               goto end_unlink;
+               goto out_bh;
        }
 
        if (IS_DIRSYNC(dir))
@@ -3224,12 +3235,12 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
 
        retval = ext4_delete_entry(handle, dir, de, bh);
        if (retval)
-               goto end_unlink;
+               goto out_handle;
        dir->i_ctime = dir->i_mtime = current_time(dir);
        ext4_update_dx_flag(dir);
        retval = ext4_mark_inode_dirty(handle, dir);
        if (retval)
-               goto end_unlink;
+               goto out_handle;
        if (inode->i_nlink == 0)
                ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
                                   dentry->d_name.len, dentry->d_name.name);
@@ -3251,10 +3262,11 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)
                d_invalidate(dentry);
 #endif
 
-end_unlink:
+out_handle:
+       ext4_journal_stop(handle);
+out_bh:
        brelse(bh);
-       if (handle)
-               ext4_journal_stop(handle);
+out_trace:
        trace_ext4_unlink_exit(dentry, retval);
        return retval;
 }
index f2df2db..f014c5e 100644 (file)
@@ -140,7 +140,7 @@ static void bio_post_read_processing(struct bio_post_read_ctx *ctx)
                        return;
                }
                ctx->cur_step++;
-               /* fall-through */
+               fallthrough;
        case STEP_VERITY:
                if (ctx->enabled_steps & (1 << STEP_VERITY)) {
                        INIT_WORK(&ctx->work, verity_work);
@@ -148,7 +148,7 @@ static void bio_post_read_processing(struct bio_post_read_ctx *ctx)
                        return;
                }
                ctx->cur_step++;
-               /* fall-through */
+               fallthrough;
        default:
                __read_end_io(ctx->bio);
        }
index 0907f90..ea425b4 100644 (file)
@@ -66,10 +66,10 @@ static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
                             unsigned long journal_devnum);
 static int ext4_show_options(struct seq_file *seq, struct dentry *root);
 static int ext4_commit_super(struct super_block *sb, int sync);
-static void ext4_mark_recovery_complete(struct super_block *sb,
+static int ext4_mark_recovery_complete(struct super_block *sb,
                                        struct ext4_super_block *es);
-static void ext4_clear_journal_err(struct super_block *sb,
-                                  struct ext4_super_block *es);
+static int ext4_clear_journal_err(struct super_block *sb,
+                                 struct ext4_super_block *es);
 static int ext4_sync_fs(struct super_block *sb, int wait);
 static int ext4_remount(struct super_block *sb, int *flags, char *data);
 static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
@@ -744,6 +744,7 @@ void __ext4_msg(struct super_block *sb,
        struct va_format vaf;
        va_list args;
 
+       atomic_inc(&EXT4_SB(sb)->s_msg_count);
        if (!___ratelimit(&(EXT4_SB(sb)->s_msg_ratelimit_state), "EXT4-fs"))
                return;
 
@@ -754,9 +755,12 @@ void __ext4_msg(struct super_block *sb,
        va_end(args);
 }
 
-#define ext4_warning_ratelimit(sb)                                     \
-               ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state), \
-                            "EXT4-fs warning")
+static int ext4_warning_ratelimit(struct super_block *sb)
+{
+       atomic_inc(&EXT4_SB(sb)->s_warning_count);
+       return ___ratelimit(&(EXT4_SB(sb)->s_warning_ratelimit_state),
+                           "EXT4-fs warning");
+}
 
 void __ext4_warning(struct super_block *sb, const char *function,
                    unsigned int line, const char *fmt, ...)
@@ -1123,6 +1127,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
        inode_set_iversion(&ei->vfs_inode, 1);
        spin_lock_init(&ei->i_raw_lock);
        INIT_LIST_HEAD(&ei->i_prealloc_list);
+       atomic_set(&ei->i_prealloc_active, 0);
        spin_lock_init(&ei->i_prealloc_lock);
        ext4_es_init_tree(&ei->i_es_tree);
        rwlock_init(&ei->i_es_lock);
@@ -1216,7 +1221,7 @@ void ext4_clear_inode(struct inode *inode)
 {
        invalidate_inode_buffers(inode);
        clear_inode(inode);
-       ext4_discard_preallocations(inode);
+       ext4_discard_preallocations(inode, 0);
        ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
        dquot_drop(inode);
        if (EXT4_I(inode)->jinode) {
@@ -1288,8 +1293,8 @@ static int bdev_try_to_free_page(struct super_block *sb, struct page *page,
        if (!page_has_buffers(page))
                return 0;
        if (journal)
-               return jbd2_journal_try_to_free_buffers(journal, page,
-                                               wait & ~__GFP_DIRECT_RECLAIM);
+               return jbd2_journal_try_to_free_buffers(journal, page);
+
        return try_to_free_buffers(page);
 }
 
@@ -1522,6 +1527,7 @@ enum {
        Opt_dioread_nolock, Opt_dioread_lock,
        Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
        Opt_max_dir_size_kb, Opt_nojournal_checksum, Opt_nombcache,
+       Opt_prefetch_block_bitmaps,
 };
 
 static const match_table_t tokens = {
@@ -1614,6 +1620,7 @@ static const match_table_t tokens = {
        {Opt_inlinecrypt, "inlinecrypt"},
        {Opt_nombcache, "nombcache"},
        {Opt_nombcache, "no_mbcache"},  /* for backward compatibility */
+       {Opt_prefetch_block_bitmaps, "prefetch_block_bitmaps"},
        {Opt_removed, "check=none"},    /* mount option from ext2/3 */
        {Opt_removed, "nocheck"},       /* mount option from ext2/3 */
        {Opt_removed, "reservation"},   /* mount option from ext2/3 */
@@ -1831,6 +1838,8 @@ static const struct mount_opts {
        {Opt_max_dir_size_kb, 0, MOPT_GTE0},
        {Opt_test_dummy_encryption, 0, MOPT_STRING},
        {Opt_nombcache, EXT4_MOUNT_NO_MBCACHE, MOPT_SET},
+       {Opt_prefetch_block_bitmaps, EXT4_MOUNT_PREFETCH_BLOCK_BITMAPS,
+        MOPT_SET},
        {Opt_err, 0, 0}
 };
 
@@ -3213,15 +3222,34 @@ static void print_daily_error_info(struct timer_list *t)
 static int ext4_run_li_request(struct ext4_li_request *elr)
 {
        struct ext4_group_desc *gdp = NULL;
-       ext4_group_t group, ngroups;
-       struct super_block *sb;
+       struct super_block *sb = elr->lr_super;
+       ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
+       ext4_group_t group = elr->lr_next_group;
        unsigned long timeout = 0;
+       unsigned int prefetch_ios = 0;
        int ret = 0;
 
-       sb = elr->lr_super;
-       ngroups = EXT4_SB(sb)->s_groups_count;
+       if (elr->lr_mode == EXT4_LI_MODE_PREFETCH_BBITMAP) {
+               elr->lr_next_group = ext4_mb_prefetch(sb, group,
+                               EXT4_SB(sb)->s_mb_prefetch, &prefetch_ios);
+               if (prefetch_ios)
+                       ext4_mb_prefetch_fini(sb, elr->lr_next_group,
+                                             prefetch_ios);
+               trace_ext4_prefetch_bitmaps(sb, group, elr->lr_next_group,
+                                           prefetch_ios);
+               if (group >= elr->lr_next_group) {
+                       ret = 1;
+                       if (elr->lr_first_not_zeroed != ngroups &&
+                           !sb_rdonly(sb) && test_opt(sb, INIT_INODE_TABLE)) {
+                               elr->lr_next_group = elr->lr_first_not_zeroed;
+                               elr->lr_mode = EXT4_LI_MODE_ITABLE;
+                               ret = 0;
+                       }
+               }
+               return ret;
+       }
 
-       for (group = elr->lr_next_group; group < ngroups; group++) {
+       for (; group < ngroups; group++) {
                gdp = ext4_get_group_desc(sb, group, NULL);
                if (!gdp) {
                        ret = 1;
@@ -3239,9 +3267,10 @@ static int ext4_run_li_request(struct ext4_li_request *elr)
                timeout = jiffies;
                ret = ext4_init_inode_table(sb, group,
                                            elr->lr_timeout ? 0 : 1);
+               trace_ext4_lazy_itable_init(sb, group);
                if (elr->lr_timeout == 0) {
                        timeout = (jiffies - timeout) *
-                                 elr->lr_sbi->s_li_wait_mult;
+                               EXT4_SB(elr->lr_super)->s_li_wait_mult;
                        elr->lr_timeout = timeout;
                }
                elr->lr_next_sched = jiffies + elr->lr_timeout;
@@ -3256,15 +3285,11 @@ static int ext4_run_li_request(struct ext4_li_request *elr)
  */
 static void ext4_remove_li_request(struct ext4_li_request *elr)
 {
-       struct ext4_sb_info *sbi;
-
        if (!elr)
                return;
 
-       sbi = elr->lr_sbi;
-
        list_del(&elr->lr_request);
-       sbi->s_li_request = NULL;
+       EXT4_SB(elr->lr_super)->s_li_request = NULL;
        kfree(elr);
 }
 
@@ -3473,7 +3498,6 @@ static int ext4_li_info_new(void)
 static struct ext4_li_request *ext4_li_request_new(struct super_block *sb,
                                            ext4_group_t start)
 {
-       struct ext4_sb_info *sbi = EXT4_SB(sb);
        struct ext4_li_request *elr;
 
        elr = kzalloc(sizeof(*elr), GFP_KERNEL);
@@ -3481,8 +3505,13 @@ static struct ext4_li_request *ext4_li_request_new(struct super_block *sb,
                return NULL;
 
        elr->lr_super = sb;
-       elr->lr_sbi = sbi;
-       elr->lr_next_group = start;
+       elr->lr_first_not_zeroed = start;
+       if (test_opt(sb, PREFETCH_BLOCK_BITMAPS))
+               elr->lr_mode = EXT4_LI_MODE_PREFETCH_BBITMAP;
+       else {
+               elr->lr_mode = EXT4_LI_MODE_ITABLE;
+               elr->lr_next_group = start;
+       }
 
        /*
         * Randomize first schedule time of the request to
@@ -3512,8 +3541,9 @@ int ext4_register_li_request(struct super_block *sb,
                goto out;
        }
 
-       if (first_not_zeroed == ngroups || sb_rdonly(sb) ||
-           !test_opt(sb, INIT_INODE_TABLE))
+       if (!test_opt(sb, PREFETCH_BLOCK_BITMAPS) &&
+           (first_not_zeroed == ngroups || sb_rdonly(sb) ||
+            !test_opt(sb, INIT_INODE_TABLE)))
                goto out;
 
        elr = ext4_li_request_new(sb, first_not_zeroed);
@@ -4710,11 +4740,13 @@ no_journal:
 
        ext4_set_resv_clusters(sb);
 
-       err = ext4_setup_system_zone(sb);
-       if (err) {
-               ext4_msg(sb, KERN_ERR, "failed to initialize system "
-                        "zone (%d)", err);
-               goto failed_mount4a;
+       if (test_opt(sb, BLOCK_VALIDITY)) {
+               err = ext4_setup_system_zone(sb);
+               if (err) {
+                       ext4_msg(sb, KERN_ERR, "failed to initialize system "
+                                "zone (%d)", err);
+                       goto failed_mount4a;
+               }
        }
 
        ext4_ext_init(sb);
@@ -4777,12 +4809,23 @@ no_journal:
        }
 #endif  /* CONFIG_QUOTA */
 
+       /*
+        * Save the original bdev mapping's wb_err value which could be
+        * used to detect the metadata async write error.
+        */
+       spin_lock_init(&sbi->s_bdev_wb_lock);
+       if (!sb_rdonly(sb))
+               errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
+                                        &sbi->s_bdev_wb_err);
+       sb->s_bdev->bd_super = sb;
        EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
        ext4_orphan_cleanup(sb, es);
        EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
        if (needs_recovery) {
                ext4_msg(sb, KERN_INFO, "recovery complete");
-               ext4_mark_recovery_complete(sb, es);
+               err = ext4_mark_recovery_complete(sb, es);
+               if (err)
+                       goto failed_mount8;
        }
        if (EXT4_SB(sb)->s_journal) {
                if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA)
@@ -4816,6 +4859,8 @@ no_journal:
        ratelimit_state_init(&sbi->s_err_ratelimit_state, 5 * HZ, 10);
        ratelimit_state_init(&sbi->s_warning_ratelimit_state, 5 * HZ, 10);
        ratelimit_state_init(&sbi->s_msg_ratelimit_state, 5 * HZ, 10);
+       atomic_set(&sbi->s_warning_count, 0);
+       atomic_set(&sbi->s_msg_count, 0);
 
        kfree(orig_data);
        return 0;
@@ -4825,10 +4870,8 @@ cantfind_ext4:
                ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
        goto failed_mount;
 
-#ifdef CONFIG_QUOTA
 failed_mount8:
        ext4_unregister_sysfs(sb);
-#endif
 failed_mount7:
        ext4_unregister_li_request(sb);
 failed_mount6:
@@ -4968,7 +5011,8 @@ static journal_t *ext4_get_journal(struct super_block *sb,
        struct inode *journal_inode;
        journal_t *journal;
 
-       BUG_ON(!ext4_has_feature_journal(sb));
+       if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+               return NULL;
 
        journal_inode = ext4_get_journal_inode(sb, journal_inum);
        if (!journal_inode)
@@ -4998,7 +5042,8 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
        struct ext4_super_block *es;
        struct block_device *bdev;
 
-       BUG_ON(!ext4_has_feature_journal(sb));
+       if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+               return NULL;
 
        bdev = ext4_blkdev_get(j_dev, sb);
        if (bdev == NULL)
@@ -5089,8 +5134,10 @@ static int ext4_load_journal(struct super_block *sb,
        dev_t journal_dev;
        int err = 0;
        int really_read_only;
+       int journal_dev_ro;
 
-       BUG_ON(!ext4_has_feature_journal(sb));
+       if (WARN_ON_ONCE(!ext4_has_feature_journal(sb)))
+               return -EFSCORRUPTED;
 
        if (journal_devnum &&
            journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -5100,7 +5147,31 @@ static int ext4_load_journal(struct super_block *sb,
        } else
                journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
 
-       really_read_only = bdev_read_only(sb->s_bdev);
+       if (journal_inum && journal_dev) {
+               ext4_msg(sb, KERN_ERR,
+                        "filesystem has both journal inode and journal device!");
+               return -EINVAL;
+       }
+
+       if (journal_inum) {
+               journal = ext4_get_journal(sb, journal_inum);
+               if (!journal)
+                       return -EINVAL;
+       } else {
+               journal = ext4_get_dev_journal(sb, journal_dev);
+               if (!journal)
+                       return -EINVAL;
+       }
+
+       journal_dev_ro = bdev_read_only(journal->j_dev);
+       really_read_only = bdev_read_only(sb->s_bdev) | journal_dev_ro;
+
+       if (journal_dev_ro && !sb_rdonly(sb)) {
+               ext4_msg(sb, KERN_ERR,
+                        "journal device read-only, try mounting with '-o ro'");
+               err = -EROFS;
+               goto err_out;
+       }
 
        /*
         * Are we loading a blank journal or performing recovery after a
@@ -5115,27 +5186,14 @@ static int ext4_load_journal(struct super_block *sb,
                                ext4_msg(sb, KERN_ERR, "write access "
                                        "unavailable, cannot proceed "
                                        "(try mounting with noload)");
-                               return -EROFS;
+                               err = -EROFS;
+                               goto err_out;
                        }
                        ext4_msg(sb, KERN_INFO, "write access will "
                               "be enabled during recovery");
                }
        }
 
-       if (journal_inum && journal_dev) {
-               ext4_msg(sb, KERN_ERR, "filesystem has both journal "
-                      "and inode journals!");
-               return -EINVAL;
-       }
-
-       if (journal_inum) {
-               if (!(journal = ext4_get_journal(sb, journal_inum)))
-                       return -EINVAL;
-       } else {
-               if (!(journal = ext4_get_dev_journal(sb, journal_dev)))
-                       return -EINVAL;
-       }
-
        if (!(journal->j_flags & JBD2_BARRIER))
                ext4_msg(sb, KERN_INFO, "barriers disabled");
 
@@ -5155,12 +5213,16 @@ static int ext4_load_journal(struct super_block *sb,
 
        if (err) {
                ext4_msg(sb, KERN_ERR, "error loading journal");
-               jbd2_journal_destroy(journal);
-               return err;
+               goto err_out;
        }
 
        EXT4_SB(sb)->s_journal = journal;
-       ext4_clear_journal_err(sb, es);
+       err = ext4_clear_journal_err(sb, es);
+       if (err) {
+               EXT4_SB(sb)->s_journal = NULL;
+               jbd2_journal_destroy(journal);
+               return err;
+       }
 
        if (!really_read_only && journal_devnum &&
            journal_devnum != le32_to_cpu(es->s_journal_dev)) {
@@ -5171,6 +5233,10 @@ static int ext4_load_journal(struct super_block *sb,
        }
 
        return 0;
+
+err_out:
+       jbd2_journal_destroy(journal);
+       return err;
 }
 
 static int ext4_commit_super(struct super_block *sb, int sync)
@@ -5182,13 +5248,6 @@ static int ext4_commit_super(struct super_block *sb, int sync)
        if (!sbh || block_device_ejected(sb))
                return error;
 
-       /*
-        * The superblock bh should be mapped, but it might not be if the
-        * device was hot-removed. Not much we can do but fail the I/O.
-        */
-       if (!buffer_mapped(sbh))
-               return error;
-
        /*
         * If the file system is mounted read-only, don't update the
         * superblock write time.  This avoids updating the superblock
@@ -5256,26 +5315,32 @@ static int ext4_commit_super(struct super_block *sb, int sync)
  * remounting) the filesystem readonly, then we will end up with a
  * consistent fs on disk.  Record that fact.
  */
-static void ext4_mark_recovery_complete(struct super_block *sb,
-                                       struct ext4_super_block *es)
+static int ext4_mark_recovery_complete(struct super_block *sb,
+                                      struct ext4_super_block *es)
 {
+       int err;
        journal_t *journal = EXT4_SB(sb)->s_journal;
 
        if (!ext4_has_feature_journal(sb)) {
-               BUG_ON(journal != NULL);
-               return;
+               if (journal != NULL) {
+                       ext4_error(sb, "Journal got removed while the fs was "
+                                  "mounted!");
+                       return -EFSCORRUPTED;
+               }
+               return 0;
        }
        jbd2_journal_lock_updates(journal);
-       if (jbd2_journal_flush(journal) < 0)
+       err = jbd2_journal_flush(journal);
+       if (err < 0)
                goto out;
 
        if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) {
                ext4_clear_feature_journal_needs_recovery(sb);
                ext4_commit_super(sb, 1);
        }
-
 out:
        jbd2_journal_unlock_updates(journal);
+       return err;
 }
 
 /*
@@ -5283,14 +5348,17 @@ out:
  * has recorded an error from a previous lifetime, move that error to the
  * main filesystem now.
  */
-static void ext4_clear_journal_err(struct super_block *sb,
+static int ext4_clear_journal_err(struct super_block *sb,
                                   struct ext4_super_block *es)
 {
        journal_t *journal;
        int j_errno;
        const char *errstr;
 
-       BUG_ON(!ext4_has_feature_journal(sb));
+       if (!ext4_has_feature_journal(sb)) {
+               ext4_error(sb, "Journal got removed while the fs was mounted!");
+               return -EFSCORRUPTED;
+       }
 
        journal = EXT4_SB(sb)->s_journal;
 
@@ -5315,6 +5383,7 @@ static void ext4_clear_journal_err(struct super_block *sb,
                jbd2_journal_clear_err(journal);
                jbd2_journal_update_sb_errno(journal);
        }
+       return 0;
 }
 
 /*
@@ -5457,7 +5526,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 {
        struct ext4_super_block *es;
        struct ext4_sb_info *sbi = EXT4_SB(sb);
-       unsigned long old_sb_flags;
+       unsigned long old_sb_flags, vfs_flags;
        struct ext4_mount_options old_opts;
        int enable_quota = 0;
        ext4_group_t g;
@@ -5500,6 +5569,14 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
        if (sbi->s_journal && sbi->s_journal->j_task->io_context)
                journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
 
+       /*
+        * Some options can be enabled by ext4 and/or by VFS mount flag
+        * either way we need to make sure it matches in both *flags and
+        * s_flags. Copy those selected flags from *flags to s_flags
+        */
+       vfs_flags = SB_LAZYTIME | SB_I_VERSION;
+       sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags);
+
        if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) {
                err = -EINVAL;
                goto restore_opts;
@@ -5553,9 +5630,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
        }
 
-       if (*flags & SB_LAZYTIME)
-               sb->s_flags |= SB_LAZYTIME;
-
        if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) {
                if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
                        err = -EROFS;
@@ -5585,8 +5659,13 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                            (sbi->s_mount_state & EXT4_VALID_FS))
                                es->s_state = cpu_to_le16(sbi->s_mount_state);
 
-                       if (sbi->s_journal)
+                       if (sbi->s_journal) {
+                               /*
+                                * We let remount-ro finish even if marking fs
+                                * as clean failed...
+                                */
                                ext4_mark_recovery_complete(sb, es);
+                       }
                        if (sbi->s_mmp_tsk)
                                kthread_stop(sbi->s_mmp_tsk);
                } else {
@@ -5628,14 +5707,25 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                                goto restore_opts;
                        }
 
+                       /*
+                        * Update the original bdev mapping's wb_err value
+                        * which could be used to detect the metadata async
+                        * write error.
+                        */
+                       errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err,
+                                                &sbi->s_bdev_wb_err);
+
                        /*
                         * Mounting a RDONLY partition read-write, so reread
                         * and store the current valid flag.  (It may have
                         * been changed by e2fsck since we originally mounted
                         * the partition.)
                         */
-                       if (sbi->s_journal)
-                               ext4_clear_journal_err(sb, es);
+                       if (sbi->s_journal) {
+                               err = ext4_clear_journal_err(sb, es);
+                               if (err)
+                                       goto restore_opts;
+                       }
                        sbi->s_mount_state = le16_to_cpu(es->s_state);
 
                        err = ext4_setup_super(sb, es, 0);
@@ -5665,7 +5755,17 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                ext4_register_li_request(sb, first_not_zeroed);
        }
 
-       ext4_setup_system_zone(sb);
+       /*
+        * Handle creation of system zone data early because it can fail.
+        * Releasing of existing data is done when we are sure remount will
+        * succeed.
+        */
+       if (test_opt(sb, BLOCK_VALIDITY) && !sbi->system_blks) {
+               err = ext4_setup_system_zone(sb);
+               if (err)
+                       goto restore_opts;
+       }
+
        if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
                err = ext4_commit_super(sb, 1);
                if (err)
@@ -5686,8 +5786,16 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
                }
        }
 #endif
+       if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
+               ext4_release_system_zone(sb);
+
+       /*
+        * Some options can be enabled by ext4 and/or by VFS mount flag
+        * either way we need to make sure it matches in both *flags and
+        * s_flags. Copy those selected flags from s_flags to *flags
+        */
+       *flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags);
 
-       *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME);
        ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
        kfree(orig_data);
        return 0;
@@ -5701,6 +5809,8 @@ restore_opts:
        sbi->s_commit_interval = old_opts.s_commit_interval;
        sbi->s_min_batch_time = old_opts.s_min_batch_time;
        sbi->s_max_batch_time = old_opts.s_max_batch_time;
+       if (!test_opt(sb, BLOCK_VALIDITY) && sbi->system_blks)
+               ext4_release_system_zone(sb);
 #ifdef CONFIG_QUOTA
        sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
        for (i = 0; i < EXT4_MAXQUOTAS; i++) {
index 6c9fc9e..bfabb79 100644 (file)
@@ -189,6 +189,9 @@ static struct ext4_attr ext4_attr_##_name = {                       \
 #define EXT4_RW_ATTR_SBI_UL(_name,_elname)     \
        EXT4_ATTR_OFFSET(_name, 0644, pointer_ul, ext4_sb_info, _elname)
 
+#define EXT4_RO_ATTR_SBI_ATOMIC(_name,_elname) \
+       EXT4_ATTR_OFFSET(_name, 0444, pointer_atomic, ext4_sb_info, _elname)
+
 #define EXT4_ATTR_PTR(_name,_mode,_id,_ptr) \
 static struct ext4_attr ext4_attr_##_name = {                  \
        .attr = {.name = __stringify(_name), .mode = _mode },   \
@@ -215,6 +218,7 @@ EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
 EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
 EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
 EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
+EXT4_RW_ATTR_SBI_UI(mb_max_inode_prealloc, s_mb_max_inode_prealloc);
 EXT4_RW_ATTR_SBI_UI(extent_max_zeroout_kb, s_extent_max_zeroout_kb);
 EXT4_ATTR(trigger_fs_error, 0200, trigger_test_error);
 EXT4_RW_ATTR_SBI_UI(err_ratelimit_interval_ms, s_err_ratelimit_state.interval);
@@ -226,6 +230,8 @@ EXT4_RW_ATTR_SBI_UI(msg_ratelimit_burst, s_msg_ratelimit_state.burst);
 #ifdef CONFIG_EXT4_DEBUG
 EXT4_RW_ATTR_SBI_UL(simulate_fail, s_simulate_fail);
 #endif
+EXT4_RO_ATTR_SBI_ATOMIC(warning_count, s_warning_count);
+EXT4_RO_ATTR_SBI_ATOMIC(msg_count, s_msg_count);
 EXT4_RO_ATTR_ES_UI(errors_count, s_error_count);
 EXT4_RO_ATTR_ES_U8(first_error_errcode, s_first_error_errcode);
 EXT4_RO_ATTR_ES_U8(last_error_errcode, s_last_error_errcode);
@@ -240,6 +246,8 @@ EXT4_RO_ATTR_ES_STRING(last_error_func, s_last_error_func, 32);
 EXT4_ATTR(first_error_time, 0444, first_error_time);
 EXT4_ATTR(last_error_time, 0444, last_error_time);
 EXT4_ATTR(journal_task, 0444, journal_task);
+EXT4_RW_ATTR_SBI_UI(mb_prefetch, s_mb_prefetch);
+EXT4_RW_ATTR_SBI_UI(mb_prefetch_limit, s_mb_prefetch_limit);
 
 static unsigned int old_bump_val = 128;
 EXT4_ATTR_PTR(max_writeback_mb_bump, 0444, pointer_ui, &old_bump_val);
@@ -257,6 +265,7 @@ static struct attribute *ext4_attrs[] = {
        ATTR_LIST(mb_order2_req),
        ATTR_LIST(mb_stream_req),
        ATTR_LIST(mb_group_prealloc),
+       ATTR_LIST(mb_max_inode_prealloc),
        ATTR_LIST(max_writeback_mb_bump),
        ATTR_LIST(extent_max_zeroout_kb),
        ATTR_LIST(trigger_fs_error),
@@ -267,6 +276,8 @@ static struct attribute *ext4_attrs[] = {
        ATTR_LIST(msg_ratelimit_interval_ms),
        ATTR_LIST(msg_ratelimit_burst),
        ATTR_LIST(errors_count),
+       ATTR_LIST(warning_count),
+       ATTR_LIST(msg_count),
        ATTR_LIST(first_error_ino),
        ATTR_LIST(last_error_ino),
        ATTR_LIST(first_error_block),
@@ -283,6 +294,8 @@ static struct attribute *ext4_attrs[] = {
 #ifdef CONFIG_EXT4_DEBUG
        ATTR_LIST(simulate_fail),
 #endif
+       ATTR_LIST(mb_prefetch),
+       ATTR_LIST(mb_prefetch_limit),
        NULL,
 };
 ATTRIBUTE_GROUPS(ext4);
index 7d2f657..cba4b87 100644 (file)
@@ -1356,8 +1356,7 @@ retry:
 
        block = 0;
        while (wsize < bufsize) {
-               if (bh != NULL)
-                       brelse(bh);
+               brelse(bh);
                csize = (bufsize - wsize) > blocksize ? blocksize :
                                                                bufsize - wsize;
                bh = ext4_getblk(handle, ea_inode, block, 0);
index ed2bca0..73683e5 100644 (file)
@@ -3550,6 +3550,9 @@ static int check_direct_IO(struct inode *inode, struct iov_iter *iter,
        unsigned long align = offset | iov_iter_alignment(iter);
        struct block_device *bdev = inode->i_sb->s_bdev;
 
+       if (iov_iter_rw(iter) == READ && offset >= i_size_read(inode))
+               return 1;
+
        if (align & blocksize_mask) {
                if (bdev)
                        blkbits = blksize_bits(bdev_logical_block_size(bdev));
index 16322ea..d9e52a7 100644 (file)
@@ -2646,7 +2646,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,
        case FI_NEW_INODE:
                if (set)
                        return;
-               /* fall through */
+               fallthrough;
        case FI_DATA_EXIST:
        case FI_INLINE_DOTS:
        case FI_PIN_FILE:
index 9bbaa26..cb1b5b6 100644 (file)
@@ -618,10 +618,10 @@ pgoff_t f2fs_get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs)
        switch (dn->max_level) {
        case 3:
                base += 2 * indirect_blks;
-               /* fall through */
+               fallthrough;
        case 2:
                base += 2 * direct_blks;
-               /* fall through */
+               fallthrough;
        case 1:
                base += direct_index;
                break;
@@ -2373,6 +2373,9 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
        if (unlikely(nid >= nm_i->max_nid))
                nid = 0;
 
+       if (unlikely(nid % NAT_ENTRY_PER_BLOCK))
+               nid = NAT_BLOCK_OFFSET(nid) * NAT_ENTRY_PER_BLOCK;
+
        /* Enough entries */
        if (nm_i->nid_cnt[FREE_NID] >= NAT_ENTRY_PER_BLOCK)
                return 0;
index a65d357..e247a5e 100644 (file)
@@ -799,7 +799,7 @@ static void __locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
 
                if (__is_large_section(sbi)) {
                        unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
-                       unsigned short valid_blocks =
+                       block_t valid_blocks =
                                get_valid_blocks(sbi, segno, true);
 
                        f2fs_bug_on(sbi, unlikely(!valid_blocks ||
@@ -815,7 +815,7 @@ static void __remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno,
                enum dirty_type dirty_type)
 {
        struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
-       unsigned short valid_blocks;
+       block_t valid_blocks;
 
        if (test_and_clear_bit(segno, dirty_i->dirty_segmap[dirty_type]))
                dirty_i->nr_dirty[dirty_type]--;
@@ -4316,8 +4316,8 @@ static void init_dirty_segmap(struct f2fs_sb_info *sbi)
        struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
        struct free_segmap_info *free_i = FREE_I(sbi);
        unsigned int segno = 0, offset = 0, secno;
-       unsigned short valid_blocks;
-       unsigned short blks_per_sec = BLKS_PER_SEC(sbi);
+       block_t valid_blocks;
+       block_t blks_per_sec = BLKS_PER_SEC(sbi);
 
        while (1) {
                /* find dirty segment based on free segmap */
index 2e4c0fa..19ac5ba 100644 (file)
@@ -362,7 +362,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
        case F_OFD_SETLK:
        case F_OFD_SETLKW:
 #endif
-               /* Fallthrough */
+               fallthrough;
        case F_SETLK:
        case F_SETLKW:
                if (copy_from_user(&flock, argp, sizeof(flock)))
@@ -771,7 +771,7 @@ static void send_sigio_to_task(struct task_struct *p,
                        if (!do_send_sig_info(signum, &si, p, type))
                                break;
                }
-               /* fall-through - fall back on the old plain SIGIO signal */
+                       fallthrough;    /* fall back on the old plain SIGIO signal */
                case 0:
                        do_send_sig_info(SIGIO, SEND_SIG_PRIV, p, type);
        }
index a605c3d..1492271 100644 (file)
@@ -42,7 +42,6 @@
 struct wb_writeback_work {
        long nr_pages;
        struct super_block *sb;
-       unsigned long *older_than_this;
        enum writeback_sync_modes sync_mode;
        unsigned int tagged_writepages:1;
        unsigned int for_kupdate:1;
@@ -144,7 +143,9 @@ static void inode_io_list_del_locked(struct inode *inode,
                                     struct bdi_writeback *wb)
 {
        assert_spin_locked(&wb->list_lock);
+       assert_spin_locked(&inode->i_lock);
 
+       inode->i_state &= ~I_SYNC_QUEUED;
        list_del_init(&inode->i_io_list);
        wb_io_lists_depopulated(wb);
 }
@@ -1122,7 +1123,9 @@ void inode_io_list_del(struct inode *inode)
        struct bdi_writeback *wb;
 
        wb = inode_to_wb_and_lock_list(inode);
+       spin_lock(&inode->i_lock);
        inode_io_list_del_locked(inode, wb);
+       spin_unlock(&inode->i_lock);
        spin_unlock(&wb->list_lock);
 }
 EXPORT_SYMBOL(inode_io_list_del);
@@ -1172,8 +1175,10 @@ void sb_clear_inode_writeback(struct inode *inode)
  * the case then the inode must have been redirtied while it was being written
  * out and we don't reset its dirtied_when.
  */
-static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
+static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb)
 {
+       assert_spin_locked(&inode->i_lock);
+
        if (!list_empty(&wb->b_dirty)) {
                struct inode *tail;
 
@@ -1182,6 +1187,14 @@ static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
                        inode->dirtied_when = jiffies;
        }
        inode_io_list_move_locked(inode, wb, &wb->b_dirty);
+       inode->i_state &= ~I_SYNC_QUEUED;
+}
+
+static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
+{
+       spin_lock(&inode->i_lock);
+       redirty_tail_locked(inode, wb);
+       spin_unlock(&inode->i_lock);
 }
 
 /*
@@ -1220,16 +1233,13 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t)
 #define EXPIRE_DIRTY_ATIME 0x0001
 
 /*
- * Move expired (dirtied before work->older_than_this) dirty inodes from
+ * Move expired (dirtied before dirtied_before) dirty inodes from
  * @delaying_queue to @dispatch_queue.
  */
 static int move_expired_inodes(struct list_head *delaying_queue,
                               struct list_head *dispatch_queue,
-                              int flags,
-                              struct wb_writeback_work *work)
+                              unsigned long dirtied_before)
 {
-       unsigned long *older_than_this = NULL;
-       unsigned long expire_time;
        LIST_HEAD(tmp);
        struct list_head *pos, *node;
        struct super_block *sb = NULL;
@@ -1237,21 +1247,15 @@ static int move_expired_inodes(struct list_head *delaying_queue,
        int do_sb_sort = 0;
        int moved = 0;
 
-       if ((flags & EXPIRE_DIRTY_ATIME) == 0)
-               older_than_this = work->older_than_this;
-       else if (!work->for_sync) {
-               expire_time = jiffies - (dirtytime_expire_interval * HZ);
-               older_than_this = &expire_time;
-       }
        while (!list_empty(delaying_queue)) {
                inode = wb_inode(delaying_queue->prev);
-               if (older_than_this &&
-                   inode_dirtied_after(inode, *older_than_this))
+               if (inode_dirtied_after(inode, dirtied_before))
                        break;
                list_move(&inode->i_io_list, &tmp);
                moved++;
-               if (flags & EXPIRE_DIRTY_ATIME)
-                       set_bit(__I_DIRTY_TIME_EXPIRED, &inode->i_state);
+               spin_lock(&inode->i_lock);
+               inode->i_state |= I_SYNC_QUEUED;
+               spin_unlock(&inode->i_lock);
                if (sb_is_blkdev_sb(inode->i_sb))
                        continue;
                if (sb && sb != inode->i_sb)
@@ -1289,18 +1293,22 @@ out:
  *                                           |
  *                                           +--> dequeue for IO
  */
-static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work)
+static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work,
+                    unsigned long dirtied_before)
 {
        int moved;
+       unsigned long time_expire_jif = dirtied_before;
 
        assert_spin_locked(&wb->list_lock);
        list_splice_init(&wb->b_more_io, &wb->b_io);
-       moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, work);
+       moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, dirtied_before);
+       if (!work->for_sync)
+               time_expire_jif = jiffies - dirtytime_expire_interval * HZ;
        moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io,
-                                    EXPIRE_DIRTY_ATIME, work);
+                                    time_expire_jif);
        if (moved)
                wb_io_lists_populated(wb);
-       trace_writeback_queue_io(wb, work, moved);
+       trace_writeback_queue_io(wb, work, dirtied_before, moved);
 }
 
 static int write_inode(struct inode *inode, struct writeback_control *wbc)
@@ -1394,7 +1402,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                 * writeback is not making progress due to locked
                 * buffers. Skip this inode for now.
                 */
-               redirty_tail(inode, wb);
+               redirty_tail_locked(inode, wb);
                return;
        }
 
@@ -1414,7 +1422,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                         * retrying writeback of the dirty page/inode
                         * that cannot be performed immediately.
                         */
-                       redirty_tail(inode, wb);
+                       redirty_tail_locked(inode, wb);
                }
        } else if (inode->i_state & I_DIRTY) {
                /*
@@ -1422,10 +1430,11 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
                 * such as delayed allocation during submission or metadata
                 * updates after data IO completion.
                 */
-               redirty_tail(inode, wb);
+               redirty_tail_locked(inode, wb);
        } else if (inode->i_state & I_DIRTY_TIME) {
                inode->dirtied_when = jiffies;
                inode_io_list_move_locked(inode, wb, &wb->b_dirty_time);
+               inode->i_state &= ~I_SYNC_QUEUED;
        } else {
                /* The inode is clean. Remove from writeback lists. */
                inode_io_list_del_locked(inode, wb);
@@ -1472,18 +1481,14 @@ __writeback_single_inode(struct inode *inode, struct writeback_control *wbc)
        spin_lock(&inode->i_lock);
 
        dirty = inode->i_state & I_DIRTY;
-       if (inode->i_state & I_DIRTY_TIME) {
-               if ((dirty & I_DIRTY_INODE) ||
-                   wbc->sync_mode == WB_SYNC_ALL ||
-                   unlikely(inode->i_state & I_DIRTY_TIME_EXPIRED) ||
-                   unlikely(time_after(jiffies,
-                                       (inode->dirtied_time_when +
-                                        dirtytime_expire_interval * HZ)))) {
-                       dirty |= I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED;
-                       trace_writeback_lazytime(inode);
-               }
-       } else
-               inode->i_state &= ~I_DIRTY_TIME_EXPIRED;
+       if ((inode->i_state & I_DIRTY_TIME) &&
+           ((dirty & I_DIRTY_INODE) ||
+            wbc->sync_mode == WB_SYNC_ALL || wbc->for_sync ||
+            time_after(jiffies, inode->dirtied_time_when +
+                       dirtytime_expire_interval * HZ))) {
+               dirty |= I_DIRTY_TIME;
+               trace_writeback_lazytime(inode);
+       }
        inode->i_state &= ~dirty;
 
        /*
@@ -1669,8 +1674,8 @@ static long writeback_sb_inodes(struct super_block *sb,
                 */
                spin_lock(&inode->i_lock);
                if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
+                       redirty_tail_locked(inode, wb);
                        spin_unlock(&inode->i_lock);
-                       redirty_tail(inode, wb);
                        continue;
                }
                if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) {
@@ -1811,7 +1816,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
        blk_start_plug(&plug);
        spin_lock(&wb->list_lock);
        if (list_empty(&wb->b_io))
-               queue_io(wb, &work);
+               queue_io(wb, &work, jiffies);
        __writeback_inodes_wb(wb, &work);
        spin_unlock(&wb->list_lock);
        blk_finish_plug(&plug);
@@ -1831,7 +1836,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
  * takes longer than a dirty_writeback_interval interval, then leave a
  * one-second gap.
  *
- * older_than_this takes precedence over nr_to_write.  So we'll only write back
+ * dirtied_before takes precedence over nr_to_write.  So we'll only write back
  * all dirty pages if they are all attached to "old" mappings.
  */
 static long wb_writeback(struct bdi_writeback *wb,
@@ -1839,14 +1844,11 @@ static long wb_writeback(struct bdi_writeback *wb,
 {
        unsigned long wb_start = jiffies;
        long nr_pages = work->nr_pages;
-       unsigned long oldest_jif;
+       unsigned long dirtied_before = jiffies;
        struct inode *inode;
        long progress;
        struct blk_plug plug;
 
-       oldest_jif = jiffies;
-       work->older_than_this = &oldest_jif;
-
        blk_start_plug(&plug);
        spin_lock(&wb->list_lock);
        for (;;) {
@@ -1880,14 +1882,14 @@ static long wb_writeback(struct bdi_writeback *wb,
                 * safe.
                 */
                if (work->for_kupdate) {
-                       oldest_jif = jiffies -
+                       dirtied_before = jiffies -
                                msecs_to_jiffies(dirty_expire_interval * 10);
                } else if (work->for_background)
-                       oldest_jif = jiffies;
+                       dirtied_before = jiffies;
 
                trace_writeback_start(wb, work);
                if (list_empty(&wb->b_io))
-                       queue_io(wb, work);
+                       queue_io(wb, work, dirtied_before);
                if (work->sb)
                        progress = writeback_sb_inodes(work->sb, wb, work);
                else
@@ -2289,11 +2291,12 @@ void __mark_inode_dirty(struct inode *inode, int flags)
                inode->i_state |= flags;
 
                /*
-                * If the inode is being synced, just update its dirty state.
-                * The unlocker will place the inode on the appropriate
-                * superblock list, based upon its state.
+                * If the inode is queued for writeback by flush worker, just
+                * update its dirty state. Once the flush worker is done with
+                * the inode it will place it on the appropriate superblock
+                * list, based upon its state.
                 */
-               if (inode->i_state & I_SYNC)
+               if (inode->i_state & I_SYNC_QUEUED)
                        goto out_unlock_inode;
 
                /*
index 7d5c5dd..2834d1a 100644 (file)
@@ -521,7 +521,7 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param)
        switch (param->type) {
        case fs_value_is_string:
                len = 1 + param->size;
-               /* Fall through */
+               fallthrough;
        case fs_value_is_flag:
                len += strlen(param->key);
                break;
index 2fa3f24..27a890a 100644 (file)
@@ -412,7 +412,7 @@ SYSCALL_DEFINE5(fsconfig,
                break;
        case FSCONFIG_SET_PATH_EMPTY:
                lookup_flags = LOOKUP_EMPTY;
-               /* fallthru */
+               fallthrough;
        case FSCONFIG_SET_PATH:
                param.type = fs_value_is_filename;
                param.name = getname_flags(_value, lookup_flags, NULL);
index 770f3a7..0f69fbd 100644 (file)
@@ -746,7 +746,7 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
                        }
                        if (n == 0)
                                break;
-               /* fall through - To branching from existing tree */
+                       fallthrough;    /* To branching from existing tree */
                case ALLOC_GROW_DEPTH:
                        if (i > 1 && i < mp->mp_fheight)
                                gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[i-1]);
@@ -757,7 +757,7 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
                                state = ALLOC_DATA;
                        if (n == 0)
                                break;
-               /* fall through - To tree complete, adding data blocks */
+                       fallthrough;    /* To tree complete, adding data blocks */
                case ALLOC_DATA:
                        BUG_ON(n > dblks);
                        BUG_ON(mp->mp_bh[end_of_metadata] == NULL);
index a58333e..3763c9f 100644 (file)
@@ -901,6 +901,36 @@ static void empty_ail1_list(struct gfs2_sbd *sdp)
        }
 }
 
+/**
+ * drain_bd - drain the buf and databuf queue for a failed transaction
+ * @tr: the transaction to drain
+ *
+ * When this is called, we're taking an error exit for a log write that failed
+ * but since we bypassed the after_commit functions, we need to remove the
+ * items from the buf and databuf queue.
+ */
+static void trans_drain(struct gfs2_trans *tr)
+{
+       struct gfs2_bufdata *bd;
+       struct list_head *head;
+
+       if (!tr)
+               return;
+
+       head = &tr->tr_buf;
+       while (!list_empty(head)) {
+               bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+               list_del_init(&bd->bd_list);
+               kmem_cache_free(gfs2_bufdata_cachep, bd);
+       }
+       head = &tr->tr_databuf;
+       while (!list_empty(head)) {
+               bd = list_first_entry(head, struct gfs2_bufdata, bd_list);
+               list_del_init(&bd->bd_list);
+               kmem_cache_free(gfs2_bufdata_cachep, bd);
+       }
+}
+
 /**
  * gfs2_log_flush - flush incore transaction(s)
  * @sdp: the filesystem
@@ -1005,6 +1035,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)
 
 out:
        if (gfs2_withdrawn(sdp)) {
+               trans_drain(tr);
                /**
                 * If the tr_list is empty, we're withdrawing during a log
                 * flush that targets a transaction, but the transaction was
index 4b67d47..6e173ae 100644 (file)
@@ -1599,7 +1599,7 @@ static int gfs2_quota_get_state(struct super_block *sb, struct qc_state *state)
        case GFS2_QUOTA_ON:
                state->s_state[USRQUOTA].flags |= QCI_LIMITS_ENFORCED;
                state->s_state[GRPQUOTA].flags |= QCI_LIMITS_ENFORCED;
-               /*FALLTHRU*/
+               fallthrough;
        case GFS2_QUOTA_ACCOUNT:
                state->s_state[USRQUOTA].flags |= QCI_ACCT_ENABLED |
                                                  QCI_SYSFILE;
index e1c7eb6..6d4bf7e 100644 (file)
@@ -67,6 +67,7 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
                tr->tr_reserved += gfs2_struct2blk(sdp, revokes);
        INIT_LIST_HEAD(&tr->tr_databuf);
        INIT_LIST_HEAD(&tr->tr_buf);
+       INIT_LIST_HEAD(&tr->tr_list);
        INIT_LIST_HEAD(&tr->tr_ail1_list);
        INIT_LIST_HEAD(&tr->tr_ail2_list);
 
index 61eec62..0350dc7 100644 (file)
@@ -195,7 +195,7 @@ reread:
        switch (sbi->s_vhdr->signature) {
        case cpu_to_be16(HFSPLUS_VOLHEAD_SIGX):
                set_bit(HFSPLUS_SB_HFSX, &sbi->flags);
-               /*FALLTHRU*/
+               fallthrough;
        case cpu_to_be16(HFSPLUS_VOLHEAD_SIG):
                break;
        case cpu_to_be16(HFSP_WRAP_MAGIC):
index e92c472..414beb5 100644 (file)
@@ -925,6 +925,24 @@ static bool io_wq_worker_cancel(struct io_worker *worker, void *data)
        return match->nr_running && !match->cancel_all;
 }
 
+static inline void io_wqe_remove_pending(struct io_wqe *wqe,
+                                        struct io_wq_work *work,
+                                        struct io_wq_work_node *prev)
+{
+       unsigned int hash = io_get_work_hash(work);
+       struct io_wq_work *prev_work = NULL;
+
+       if (io_wq_is_hashed(work) && work == wqe->hash_tail[hash]) {
+               if (prev)
+                       prev_work = container_of(prev, struct io_wq_work, list);
+               if (prev_work && io_get_work_hash(prev_work) == hash)
+                       wqe->hash_tail[hash] = prev_work;
+               else
+                       wqe->hash_tail[hash] = NULL;
+       }
+       wq_list_del(&wqe->work_list, &work->list, prev);
+}
+
 static void io_wqe_cancel_pending_work(struct io_wqe *wqe,
                                       struct io_cb_cancel_data *match)
 {
@@ -938,8 +956,7 @@ retry:
                work = container_of(node, struct io_wq_work, list);
                if (!match->fn(work, match->data))
                        continue;
-
-               wq_list_del(&wqe->work_list, node, prev);
+               io_wqe_remove_pending(wqe, work, prev);
                spin_unlock_irqrestore(&wqe->lock, flags);
                io_run_cancel(work, wqe);
                match->nr_pending++;
index dc506b7..3790c7f 100644 (file)
@@ -540,7 +540,6 @@ enum {
        REQ_F_ISREG_BIT,
        REQ_F_COMP_LOCKED_BIT,
        REQ_F_NEED_CLEANUP_BIT,
-       REQ_F_OVERFLOW_BIT,
        REQ_F_POLLED_BIT,
        REQ_F_BUFFER_SELECTED_BIT,
        REQ_F_NO_FILE_TABLE_BIT,
@@ -583,8 +582,6 @@ enum {
        REQ_F_COMP_LOCKED       = BIT(REQ_F_COMP_LOCKED_BIT),
        /* needs cleanup */
        REQ_F_NEED_CLEANUP      = BIT(REQ_F_NEED_CLEANUP_BIT),
-       /* in overflow list */
-       REQ_F_OVERFLOW          = BIT(REQ_F_OVERFLOW_BIT),
        /* already went through poll handler */
        REQ_F_POLLED            = BIT(REQ_F_POLLED_BIT),
        /* buffer already selected */
@@ -946,7 +943,8 @@ static void io_get_req_task(struct io_kiocb *req)
 
 static inline void io_clean_op(struct io_kiocb *req)
 {
-       if (req->flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED))
+       if (req->flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED |
+                         REQ_F_INFLIGHT))
                __io_clean_op(req);
 }
 
@@ -1152,7 +1150,7 @@ static void io_prep_async_work(struct io_kiocb *req)
        io_req_init_async(req);
 
        if (req->flags & REQ_F_ISREG) {
-               if (def->hash_reg_file)
+               if (def->hash_reg_file || (req->ctx->flags & IORING_SETUP_IOPOLL))
                        io_wq_hash_work(&req->work, file_inode(req->file));
        } else {
                if (def->unbound_nonreg_file)
@@ -1366,7 +1364,6 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force)
                req = list_first_entry(&ctx->cq_overflow_list, struct io_kiocb,
                                                compl.list);
                list_move(&req->compl.list, &list);
-               req->flags &= ~REQ_F_OVERFLOW;
                if (cqe) {
                        WRITE_ONCE(cqe->user_data, req->user_data);
                        WRITE_ONCE(cqe->res, req->result);
@@ -1419,7 +1416,6 @@ static void __io_cqring_fill_event(struct io_kiocb *req, long res, long cflags)
                        ctx->rings->sq_flags |= IORING_SQ_CQ_OVERFLOW;
                }
                io_clean_op(req);
-               req->flags |= REQ_F_OVERFLOW;
                req->result = res;
                req->compl.cflags = cflags;
                refcount_inc(&req->refs);
@@ -1563,17 +1559,6 @@ static bool io_dismantle_req(struct io_kiocb *req)
        if (req->file)
                io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
 
-       if (req->flags & REQ_F_INFLIGHT) {
-               struct io_ring_ctx *ctx = req->ctx;
-               unsigned long flags;
-
-               spin_lock_irqsave(&ctx->inflight_lock, flags);
-               list_del(&req->inflight_entry);
-               if (waitqueue_active(&ctx->inflight_wait))
-                       wake_up(&ctx->inflight_wait);
-               spin_unlock_irqrestore(&ctx->inflight_lock, flags);
-       }
-
        return io_req_clean_work(req);
 }
 
@@ -1761,7 +1746,8 @@ static struct io_kiocb *io_req_find_next(struct io_kiocb *req)
        return __io_req_find_next(req);
 }
 
-static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
+static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb,
+                               bool twa_signal_ok)
 {
        struct task_struct *tsk = req->task;
        struct io_ring_ctx *ctx = req->ctx;
@@ -1774,7 +1760,7 @@ static int io_req_task_work_add(struct io_kiocb *req, struct callback_head *cb)
         * will do the job.
         */
        notify = 0;
-       if (!(ctx->flags & IORING_SETUP_SQPOLL))
+       if (!(ctx->flags & IORING_SETUP_SQPOLL) && twa_signal_ok)
                notify = TWA_SIGNAL;
 
        ret = task_work_add(tsk, cb, notify);
@@ -1834,7 +1820,7 @@ static void io_req_task_queue(struct io_kiocb *req)
        init_task_work(&req->task_work, io_req_task_submit);
        percpu_ref_get(&req->ctx->refs);
 
-       ret = io_req_task_work_add(req, &req->task_work);
+       ret = io_req_task_work_add(req, &req->task_work, true);
        if (unlikely(ret)) {
                struct task_struct *tsk;
 
@@ -2063,6 +2049,7 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events,
 
                req = list_first_entry(done, struct io_kiocb, inflight_entry);
                if (READ_ONCE(req->result) == -EAGAIN) {
+                       req->result = 0;
                        req->iopoll_completed = 0;
                        list_move_tail(&req->inflight_entry, &again);
                        continue;
@@ -2308,38 +2295,27 @@ end_req:
        io_req_complete(req, ret);
        return false;
 }
-
-static void io_rw_resubmit(struct callback_head *cb)
-{
-       struct io_kiocb *req = container_of(cb, struct io_kiocb, task_work);
-       struct io_ring_ctx *ctx = req->ctx;
-       int err;
-
-       err = io_sq_thread_acquire_mm(ctx, req);
-
-       if (io_resubmit_prep(req, err)) {
-               refcount_inc(&req->refs);
-               io_queue_async_work(req);
-       }
-
-       percpu_ref_put(&ctx->refs);
-}
 #endif
 
 static bool io_rw_reissue(struct io_kiocb *req, long res)
 {
 #ifdef CONFIG_BLOCK
+       umode_t mode = file_inode(req->file)->i_mode;
        int ret;
 
+       if (!S_ISBLK(mode) && !S_ISREG(mode))
+               return false;
        if ((res != -EAGAIN && res != -EOPNOTSUPP) || io_wq_current_is_worker())
                return false;
 
-       init_task_work(&req->task_work, io_rw_resubmit);
-       percpu_ref_get(&req->ctx->refs);
+       ret = io_sq_thread_acquire_mm(req->ctx, req);
 
-       ret = io_req_task_work_add(req, &req->task_work);
-       if (!ret)
+       if (io_resubmit_prep(req, ret)) {
+               refcount_inc(&req->refs);
+               io_queue_async_work(req);
                return true;
+       }
+
 #endif
        return false;
 }
@@ -2578,7 +2554,7 @@ static inline void io_rw_done(struct kiocb *kiocb, ssize_t ret)
                 * IO with EINTR.
                 */
                ret = -EINTR;
-               /* fall through */
+               fallthrough;
        default:
                kiocb->ki_complete(kiocb, ret, 0);
        }
@@ -2819,22 +2795,15 @@ static ssize_t io_iov_buffer_select(struct io_kiocb *req, struct iovec *iov,
        return __io_iov_buffer_select(req, iov, needs_lock);
 }
 
-static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
-                              struct iovec **iovec, struct iov_iter *iter,
-                              bool needs_lock)
+static ssize_t __io_import_iovec(int rw, struct io_kiocb *req,
+                                struct iovec **iovec, struct iov_iter *iter,
+                                bool needs_lock)
 {
        void __user *buf = u64_to_user_ptr(req->rw.addr);
        size_t sqe_len = req->rw.len;
        ssize_t ret;
        u8 opcode;
 
-       if (req->io) {
-               struct io_async_rw *iorw = &req->io->rw;
-
-               *iovec = NULL;
-               return iov_iter_count(&iorw->iter);
-       }
-
        opcode = req->opcode;
        if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {
                *iovec = NULL;
@@ -2848,10 +2817,8 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
        if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
                if (req->flags & REQ_F_BUFFER_SELECT) {
                        buf = io_rw_buffer_select(req, &sqe_len, needs_lock);
-                       if (IS_ERR(buf)) {
-                               *iovec = NULL;
+                       if (IS_ERR(buf))
                                return PTR_ERR(buf);
-                       }
                        req->rw.len = sqe_len;
                }
 
@@ -2879,6 +2846,21 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
        return import_iovec(rw, buf, sqe_len, UIO_FASTIOV, iovec, iter);
 }
 
+static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
+                              struct iovec **iovec, struct iov_iter *iter,
+                              bool needs_lock)
+{
+       if (!req->io)
+               return __io_import_iovec(rw, req, iovec, iter, needs_lock);
+       *iovec = NULL;
+       return iov_iter_count(&req->io->rw.iter);
+}
+
+static inline loff_t *io_kiocb_ppos(struct kiocb *kiocb)
+{
+       return kiocb->ki_filp->f_mode & FMODE_STREAM ? NULL : &kiocb->ki_pos;
+}
+
 /*
  * For files that don't have ->read_iter() and ->write_iter(), handle them
  * by looping over ->read() or ->write() manually.
@@ -2914,10 +2896,10 @@ static ssize_t loop_rw_iter(int rw, struct file *file, struct kiocb *kiocb,
 
                if (rw == READ) {
                        nr = file->f_op->read(file, iovec.iov_base,
-                                             iovec.iov_len, &kiocb->ki_pos);
+                                             iovec.iov_len, io_kiocb_ppos(kiocb));
                } else {
                        nr = file->f_op->write(file, iovec.iov_base,
-                                              iovec.iov_len, &kiocb->ki_pos);
+                                              iovec.iov_len, io_kiocb_ppos(kiocb));
                }
 
                if (iov_iter_is_bvec(iter))
@@ -2998,17 +2980,15 @@ static inline int io_rw_prep_async(struct io_kiocb *req, int rw,
                                   bool force_nonblock)
 {
        struct io_async_rw *iorw = &req->io->rw;
+       struct iovec *iov;
        ssize_t ret;
 
-       iorw->iter.iov = iorw->fast_iov;
-       /* reset ->io around the iovec import, we don't want to use it */
-       req->io = NULL;
-       ret = io_import_iovec(rw, req, (struct iovec **) &iorw->iter.iov,
-                               &iorw->iter, !force_nonblock);
-       req->io = container_of(iorw, struct io_async_ctx, rw);
+       iorw->iter.iov = iov = iorw->fast_iov;
+       ret = __io_import_iovec(rw, req, &iov, &iorw->iter, !force_nonblock);
        if (unlikely(ret < 0))
                return ret;
 
+       iorw->iter.iov = iov;
        io_req_map_rw(req, iorw->iter.iov, iorw->fast_iov, &iorw->iter);
        return 0;
 }
@@ -3061,7 +3041,7 @@ static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode,
 
        /* submit ref gets dropped, acquire a new one */
        refcount_inc(&req->refs);
-       ret = io_req_task_work_add(req, &req->task_work);
+       ret = io_req_task_work_add(req, &req->task_work, true);
        if (unlikely(ret)) {
                struct task_struct *tsk;
 
@@ -3074,27 +3054,6 @@ static int io_async_buf_func(struct wait_queue_entry *wait, unsigned mode,
        return 1;
 }
 
-static inline int kiocb_wait_page_queue_init(struct kiocb *kiocb,
-                                            struct wait_page_queue *wait,
-                                            wait_queue_func_t func,
-                                            void *data)
-{
-       /* Can't support async wakeup with polled IO */
-       if (kiocb->ki_flags & IOCB_HIPRI)
-               return -EINVAL;
-       if (kiocb->ki_filp->f_mode & FMODE_BUF_RASYNC) {
-               wait->wait.func = func;
-               wait->wait.private = data;
-               wait->wait.flags = 0;
-               INIT_LIST_HEAD(&wait->wait.entry);
-               kiocb->ki_flags |= IOCB_WAITQ;
-               kiocb->ki_waitq = wait;
-               return 0;
-       }
-
-       return -EOPNOTSUPP;
-}
-
 /*
  * This controls whether a given IO request should be armed for async page
  * based retry. If we return false here, the request is handed to the async
@@ -3109,16 +3068,17 @@ static inline int kiocb_wait_page_queue_init(struct kiocb *kiocb,
  */
 static bool io_rw_should_retry(struct io_kiocb *req)
 {
+       struct wait_page_queue *wait = &req->io->rw.wpq;
        struct kiocb *kiocb = &req->rw.kiocb;
-       int ret;
 
        /* never retry for NOWAIT, we just complete with -EAGAIN */
        if (req->flags & REQ_F_NOWAIT)
                return false;
 
        /* Only for buffered IO */
-       if (kiocb->ki_flags & IOCB_DIRECT)
+       if (kiocb->ki_flags & (IOCB_DIRECT | IOCB_HIPRI))
                return false;
+
        /*
         * just use poll if we can, and don't attempt if the fs doesn't
         * support callback based unlocks
@@ -3126,14 +3086,15 @@ static bool io_rw_should_retry(struct io_kiocb *req)
        if (file_can_poll(req->file) || !(req->file->f_mode & FMODE_BUF_RASYNC))
                return false;
 
-       ret = kiocb_wait_page_queue_init(kiocb, &req->io->rw.wpq,
-                                               io_async_buf_func, req);
-       if (!ret) {
-               io_get_req_task(req);
-               return true;
-       }
+       wait->wait.func = io_async_buf_func;
+       wait->wait.private = req;
+       wait->wait.flags = 0;
+       INIT_LIST_HEAD(&wait->wait.entry);
+       kiocb->ki_flags |= IOCB_WAITQ;
+       kiocb->ki_waitq = wait;
 
-       return false;
+       io_get_req_task(req);
+       return true;
 }
 
 static int io_iter_do_read(struct io_kiocb *req, struct iov_iter *iter)
@@ -3161,6 +3122,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
        ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock);
        if (ret < 0)
                return ret;
+       iov_count = iov_iter_count(iter);
        io_size = ret;
        req->result = io_size;
        ret = 0;
@@ -3173,8 +3135,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
        if (force_nonblock && !io_file_supports_async(req->file, READ))
                goto copy_iov;
 
-       iov_count = iov_iter_count(iter);
-       ret = rw_verify_area(READ, req->file, &kiocb->ki_pos, iov_count);
+       ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), iov_count);
        if (unlikely(ret))
                goto out_free;
 
@@ -3186,14 +3147,21 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
                ret = 0;
                goto out_free;
        } else if (ret == -EAGAIN) {
-               if (!force_nonblock)
+               /* IOPOLL retry should happen for io-wq threads */
+               if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL))
                        goto done;
+               /* no retry on NONBLOCK marked file */
+               if (req->file->f_flags & O_NONBLOCK)
+                       goto done;
+               /* some cases will consume bytes even on error returns */
+               iov_iter_revert(iter, iov_count - iov_iter_count(iter));
                ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
                if (ret)
                        goto out_free;
                return -EAGAIN;
        } else if (ret < 0) {
-               goto out_free;
+               /* make sure -ERESTARTSYS -> -EINTR is done */
+               goto done;
        }
 
        /* read it all, or we did blocking attempt. no retry. */
@@ -3238,6 +3206,7 @@ done:
        kiocb_done(kiocb, ret, cs);
        ret = 0;
 out_free:
+       /* it's reportedly faster than delegating the null check to kfree() */
        if (iovec)
                kfree(iovec);
        return ret;
@@ -3276,6 +3245,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
        ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);
        if (ret < 0)
                return ret;
+       iov_count = iov_iter_count(iter);
        io_size = ret;
        req->result = io_size;
 
@@ -3292,8 +3262,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
            (req->flags & REQ_F_ISREG))
                goto copy_iov;
 
-       iov_count = iov_iter_count(iter);
-       ret = rw_verify_area(WRITE, req->file, &kiocb->ki_pos, iov_count);
+       ret = rw_verify_area(WRITE, req->file, io_kiocb_ppos(kiocb), iov_count);
        if (unlikely(ret))
                goto out_free;
 
@@ -3325,15 +3294,25 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
         */
        if (ret2 == -EOPNOTSUPP && (kiocb->ki_flags & IOCB_NOWAIT))
                ret2 = -EAGAIN;
+       /* no retry on NONBLOCK marked file */
+       if (ret2 == -EAGAIN && (req->file->f_flags & O_NONBLOCK))
+               goto done;
        if (!force_nonblock || ret2 != -EAGAIN) {
+               /* IOPOLL retry should happen for io-wq threads */
+               if ((req->ctx->flags & IORING_SETUP_IOPOLL) && ret2 == -EAGAIN)
+                       goto copy_iov;
+done:
                kiocb_done(kiocb, ret2, cs);
        } else {
 copy_iov:
+               /* some cases will consume bytes even on error returns */
+               iov_iter_revert(iter, iov_count - iov_iter_count(iter));
                ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false);
                if (!ret)
                        return -EAGAIN;
        }
 out_free:
+       /* it's reportedly faster than delegating the null check to kfree() */
        if (iovec)
                kfree(iovec);
        return ret;
@@ -4600,6 +4579,7 @@ struct io_poll_table {
 static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,
                           __poll_t mask, task_work_func_t func)
 {
+       bool twa_signal_ok;
        int ret;
 
        /* for instances that support it check for an event match first: */
@@ -4614,13 +4594,21 @@ static int __io_async_wake(struct io_kiocb *req, struct io_poll_iocb *poll,
        init_task_work(&req->task_work, func);
        percpu_ref_get(&req->ctx->refs);
 
+       /*
+        * If we using the signalfd wait_queue_head for this wakeup, then
+        * it's not safe to use TWA_SIGNAL as we could be recursing on the
+        * tsk->sighand->siglock on doing the wakeup. Should not be needed
+        * either, as the normal wakeup will suffice.
+        */
+       twa_signal_ok = (poll->head != &req->task->sighand->signalfd_wqh);
+
        /*
         * If this fails, then the task is exiting. When a task exits, the
         * work gets canceled, so just cancel this request as well instead
         * of executing it. We can't safely execute it anyway, as we may not
         * have the needed state needed for it anyway.
         */
-       ret = io_req_task_work_add(req, &req->task_work);
+       ret = io_req_task_work_add(req, &req->task_work, twa_signal_ok);
        if (unlikely(ret)) {
                struct task_struct *tsk;
 
@@ -4909,12 +4897,20 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
        struct async_poll *apoll;
        struct io_poll_table ipt;
        __poll_t mask, ret;
+       int rw;
 
        if (!req->file || !file_can_poll(req->file))
                return false;
        if (req->flags & REQ_F_POLLED)
                return false;
-       if (!def->pollin && !def->pollout)
+       if (def->pollin)
+               rw = READ;
+       else if (def->pollout)
+               rw = WRITE;
+       else
+               return false;
+       /* if we can't nonblock try, then no point in arming a poll handler */
+       if (!io_file_supports_async(req->file, rw))
                return false;
 
        apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
@@ -5653,6 +5649,18 @@ static void __io_clean_op(struct io_kiocb *req)
                }
                req->flags &= ~REQ_F_NEED_CLEANUP;
        }
+
+       if (req->flags & REQ_F_INFLIGHT) {
+               struct io_ring_ctx *ctx = req->ctx;
+               unsigned long flags;
+
+               spin_lock_irqsave(&ctx->inflight_lock, flags);
+               list_del(&req->inflight_entry);
+               if (waitqueue_active(&ctx->inflight_wait))
+                       wake_up(&ctx->inflight_wait);
+               spin_unlock_irqrestore(&ctx->inflight_lock, flags);
+               req->flags &= ~REQ_F_INFLIGHT;
+       }
 }
 
 static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
@@ -7327,7 +7335,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
                table = &ctx->file_data->table[i >> IORING_FILE_TABLE_SHIFT];
                index = i & IORING_FILE_TABLE_MASK;
                if (table->files[index]) {
-                       file = io_file_from_index(ctx, index);
+                       file = table->files[index];
                        err = io_queue_file_removal(data, file);
                        if (err)
                                break;
@@ -7356,6 +7364,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
                        table->files[index] = file;
                        err = io_sqe_file_register(ctx, file, i);
                        if (err) {
+                               table->files[index] = NULL;
                                fput(file);
                                break;
                        }
@@ -7455,9 +7464,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
 {
        int ret;
 
-       mmgrab(current->mm);
-       ctx->sqo_mm = current->mm;
-
        if (ctx->flags & IORING_SETUP_SQPOLL) {
                ret = -EPERM;
                if (!capable(CAP_SYS_ADMIN))
@@ -7502,10 +7508,6 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
        return 0;
 err:
        io_finish_async(ctx);
-       if (ctx->sqo_mm) {
-               mmdrop(ctx->sqo_mm);
-               ctx->sqo_mm = NULL;
-       }
        return ret;
 }
 
@@ -7979,7 +7981,13 @@ static void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
                         ACCT_LOCKED);
 
        INIT_WORK(&ctx->exit_work, io_ring_exit_work);
-       queue_work(system_wq, &ctx->exit_work);
+       /*
+        * Use system_unbound_wq to avoid spawning tons of event kworkers
+        * if we're exiting a ton of rings at the same time. It just adds
+        * noise and overhead, there's no discernable change in runtime
+        * over using system_wq.
+        */
+       queue_work(system_unbound_wq, &ctx->exit_work);
 }
 
 static int io_uring_release(struct inode *inode, struct file *file)
@@ -8016,6 +8024,28 @@ static bool io_match_link(struct io_kiocb *preq, struct io_kiocb *req)
        return false;
 }
 
+static inline bool io_match_files(struct io_kiocb *req,
+                                      struct files_struct *files)
+{
+       return (req->flags & REQ_F_WORK_INITIALIZED) && req->work.files == files;
+}
+
+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
@@ -8063,12 +8093,65 @@ static bool io_timeout_remove_link(struct io_ring_ctx *ctx,
        return found;
 }
 
+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);
+}
+
+static void io_attempt_cancel(struct io_ring_ctx *ctx, struct io_kiocb *req)
+{
+       enum io_wq_cancel cret;
+
+       /* cancel this particular work, if it's running */
+       cret = io_wq_cancel_work(ctx->io_wq, &req->work);
+       if (cret != IO_WQ_CANCEL_NOTFOUND)
+               return;
+
+       /* find links that hold this pending, cancel those */
+       cret = io_wq_cancel_cb(ctx->io_wq, io_cancel_link_cb, req, true);
+       if (cret != IO_WQ_CANCEL_NOTFOUND)
+               return;
+
+       /* if we have a poll link holding this pending, cancel that */
+       if (io_poll_remove_link(ctx, req))
+               return;
+
+       /* final option, timeout link is holding this req pending */
+       io_timeout_remove_link(ctx, req);
+}
+
+static void io_cancel_defer_files(struct io_ring_ctx *ctx,
+                                 struct files_struct *files)
+{
+       struct io_defer_entry *de = NULL;
+       LIST_HEAD(list);
+
+       spin_lock_irq(&ctx->completion_lock);
+       list_for_each_entry_reverse(de, &ctx->defer_list, list) {
+               if (io_match_link_files(de->req, files)) {
+                       list_cut_position(&list, &ctx->defer_list, &de->list);
+                       break;
+               }
+       }
+       spin_unlock_irq(&ctx->completion_lock);
+
+       while (!list_empty(&list)) {
+               de = list_first_entry(&list, struct io_defer_entry, list);
+               list_del_init(&de->list);
+               req_set_fail_links(de->req);
+               io_put_req(de->req);
+               io_req_complete(de->req, -ECANCELED);
+               kfree(de);
+       }
+}
+
 static void io_uring_cancel_files(struct io_ring_ctx *ctx,
                                  struct files_struct *files)
 {
        if (list_empty_careful(&ctx->inflight_list))
                return;
 
+       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);
 
@@ -8094,35 +8177,9 @@ static void io_uring_cancel_files(struct io_ring_ctx *ctx,
                /* We need to keep going until we don't find a matching req */
                if (!cancel_req)
                        break;
-
-               if (cancel_req->flags & REQ_F_OVERFLOW) {
-                       spin_lock_irq(&ctx->completion_lock);
-                       list_del(&cancel_req->compl.list);
-                       cancel_req->flags &= ~REQ_F_OVERFLOW;
-
-                       io_cqring_mark_overflow(ctx);
-                       WRITE_ONCE(ctx->rings->cq_overflow,
-                               atomic_inc_return(&ctx->cached_cq_overflow));
-                       io_commit_cqring(ctx);
-                       spin_unlock_irq(&ctx->completion_lock);
-
-                       /*
-                        * Put inflight ref and overflow ref. If that's
-                        * all we had, then we're done with this request.
-                        */
-                       if (refcount_sub_and_test(2, &cancel_req->refs)) {
-                               io_free_req(cancel_req);
-                               finish_wait(&ctx->inflight_wait, &wait);
-                               continue;
-                       }
-               } else {
-                       io_wq_cancel_work(ctx->io_wq, &cancel_req->work);
-                       /* could be a link, check and remove if it is */
-                       if (!io_poll_remove_link(ctx, cancel_req))
-                               io_timeout_remove_link(ctx, cancel_req);
-                       io_put_req(cancel_req);
-               }
-
+               /* cancel this request, or head link requests */
+               io_attempt_cancel(ctx, cancel_req);
+               io_put_req(cancel_req);
                schedule();
                finish_wait(&ctx->inflight_wait, &wait);
        }
@@ -8548,6 +8605,9 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p,
        ctx->user = user;
        ctx->creds = get_current_cred();
 
+       mmgrab(current->mm);
+       ctx->sqo_mm = current->mm;
+
        /*
         * Account memory _before_ installing the file descriptor. Once
         * the descriptor is installed, it can get closed at any time. Also
index 89f61d9..107ee80 100644 (file)
@@ -127,7 +127,7 @@ iomap_seek_hole_actor(struct inode *inode, loff_t offset, loff_t length,
                                                   SEEK_HOLE);
                if (offset < 0)
                        return length;
-               /* fall through */
+               fallthrough;
        case IOMAP_HOLE:
                *(loff_t *)data = offset;
                return 0;
@@ -175,7 +175,7 @@ iomap_seek_data_actor(struct inode *inode, loff_t offset, loff_t length,
                                                   SEEK_DATA);
                if (offset < 0)
                        return length;
-               /*FALLTHRU*/
+               fallthrough;
        default:
                *(loff_t *)data = offset;
                return 0;
index e494443..17fdc48 100644 (file)
@@ -1285,7 +1285,7 @@ journal_t *jbd2_journal_init_inode(struct inode *inode)
  * superblock as being NULL to prevent the journal destroy from writing
  * back a bogus superblock.
  */
-static void journal_fail_superblock (journal_t *journal)
+static void journal_fail_superblock(journal_t *journal)
 {
        struct buffer_head *bh = journal->j_sb_buffer;
        brelse(bh);
@@ -1367,8 +1367,10 @@ static int jbd2_write_superblock(journal_t *journal, int write_flags)
        int ret;
 
        /* Buffer got discarded which means block device got invalidated */
-       if (!buffer_mapped(bh))
+       if (!buffer_mapped(bh)) {
+               unlock_buffer(bh);
                return -EIO;
+       }
 
        trace_jbd2_write_superblock(journal, write_flags);
        if (!(journal->j_flags & JBD2_BARRIER))
@@ -1815,7 +1817,7 @@ int jbd2_journal_destroy(journal_t *journal)
 
 
 /**
- *int jbd2_journal_check_used_features () - Check if features specified are used.
+ *int jbd2_journal_check_used_features() - Check if features specified are used.
  * @journal: Journal to check.
  * @compat: bitmask of compatible features
  * @ro: bitmask of features that force read-only mount
@@ -1825,7 +1827,7 @@ int jbd2_journal_destroy(journal_t *journal)
  * features.  Return true (non-zero) if it does.
  **/
 
-int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat,
+int jbd2_journal_check_used_features(journal_t *journal, unsigned long compat,
                                 unsigned long ro, unsigned long incompat)
 {
        journal_superblock_t *sb;
@@ -1860,7 +1862,7 @@ int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat,
  * all of a given set of features on this journal.  Return true
  * (non-zero) if it can. */
 
-int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat,
+int jbd2_journal_check_available_features(journal_t *journal, unsigned long compat,
                                      unsigned long ro, unsigned long incompat)
 {
        if (!compat && !ro && !incompat)
@@ -1882,7 +1884,7 @@ int jbd2_journal_check_available_features (journal_t *journal, unsigned long com
 }
 
 /**
- * int jbd2_journal_set_features () - Mark a given journal feature in the superblock
+ * int jbd2_journal_set_features() - Mark a given journal feature in the superblock
  * @journal: Journal to act on.
  * @compat: bitmask of compatible features
  * @ro: bitmask of features that force read-only mount
@@ -1893,7 +1895,7 @@ int jbd2_journal_check_available_features (journal_t *journal, unsigned long com
  *
  */
 
-int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
+int jbd2_journal_set_features(journal_t *journal, unsigned long compat,
                          unsigned long ro, unsigned long incompat)
 {
 #define INCOMPAT_FEATURE_ON(f) \
index 2ed278f..faa97d7 100644 (file)
@@ -690,14 +690,11 @@ static int do_one_pass(journal_t *journal,
                         * number. */
                        if (pass == PASS_SCAN &&
                            jbd2_has_feature_checksum(journal)) {
-                               int chksum_err, chksum_seen;
                                struct commit_header *cbh =
                                        (struct commit_header *)bh->b_data;
                                unsigned found_chksum =
                                        be32_to_cpu(cbh->h_chksum[0]);
 
-                               chksum_err = chksum_seen = 0;
-
                                if (info->end_transaction) {
                                        journal->j_failed_commit =
                                                info->end_transaction;
@@ -705,42 +702,23 @@ static int do_one_pass(journal_t *journal,
                                        break;
                                }
 
-                               if (crc32_sum == found_chksum &&
-                                   cbh->h_chksum_type == JBD2_CRC32_CHKSUM &&
-                                   cbh->h_chksum_size ==
-                                               JBD2_CRC32_CHKSUM_SIZE)
-                                      chksum_seen = 1;
-                               else if (!(cbh->h_chksum_type == 0 &&
-                                            cbh->h_chksum_size == 0 &&
-                                            found_chksum == 0 &&
-                                            !chksum_seen))
-                               /*
-                                * If fs is mounted using an old kernel and then
-                                * kernel with journal_chksum is used then we
-                                * get a situation where the journal flag has
-                                * checksum flag set but checksums are not
-                                * present i.e chksum = 0, in the individual
-                                * commit blocks.
-                                * Hence to avoid checksum failures, in this
-                                * situation, this extra check is added.
-                                */
-                                               chksum_err = 1;
-
-                               if (chksum_err) {
-                                       info->end_transaction = next_commit_ID;
-
-                                       if (!jbd2_has_feature_async_commit(journal)) {
-                                               journal->j_failed_commit =
-                                                       next_commit_ID;
-                                               brelse(bh);
-                                               break;
-                                       }
-                               }
+                               /* Neither checksum match nor unused? */
+                               if (!((crc32_sum == found_chksum &&
+                                      cbh->h_chksum_type ==
+                                               JBD2_CRC32_CHKSUM &&
+                                      cbh->h_chksum_size ==
+                                               JBD2_CRC32_CHKSUM_SIZE) ||
+                                     (cbh->h_chksum_type == 0 &&
+                                      cbh->h_chksum_size == 0 &&
+                                      found_chksum == 0)))
+                                       goto chksum_error;
+
                                crc32_sum = ~0;
                        }
                        if (pass == PASS_SCAN &&
                            !jbd2_commit_block_csum_verify(journal,
                                                           bh->b_data)) {
+                       chksum_error:
                                info->end_transaction = next_commit_ID;
 
                                if (!jbd2_has_feature_async_commit(journal)) {
index e91aad3..4398573 100644 (file)
@@ -2026,6 +2026,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
  */
 static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
 {
+       J_ASSERT_JH(jh, jh->b_transaction != NULL);
+       J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
+
        __jbd2_journal_temp_unlink_buffer(jh);
        jh->b_transaction = NULL;
 }
@@ -2078,10 +2081,6 @@ out:
  * int jbd2_journal_try_to_free_buffers() - try to free page buffers.
  * @journal: journal for operation
  * @page: to try and free
- * @gfp_mask: we use the mask to detect how hard should we try to release
- * buffers. If __GFP_DIRECT_RECLAIM and __GFP_FS is set, we wait for commit
- * code to release the buffers.
- *
  *
  * For all the buffers on this page,
  * if they are fully written out ordered data, move them onto BUF_CLEAN
@@ -2112,11 +2111,11 @@ out:
  *
  * Return 0 on failure, 1 on success
  */
-int jbd2_journal_try_to_free_buffers(journal_t *journal,
-                               struct page *page, gfp_t gfp_mask)
+int jbd2_journal_try_to_free_buffers(journal_t *journal, struct page *page)
 {
        struct buffer_head *head;
        struct buffer_head *bh;
+       bool has_write_io_error = false;
        int ret = 0;
 
        J_ASSERT(PageLocked(page));
@@ -2141,11 +2140,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
                jbd2_journal_put_journal_head(jh);
                if (buffer_jbd(bh))
                        goto busy;
+
+               /*
+                * If we free a metadata buffer which has been failed to
+                * write out, the jbd2 checkpoint procedure will not detect
+                * this failure and may lead to filesystem inconsistency
+                * after cleanup journal tail.
+                */
+               if (buffer_write_io_error(bh)) {
+                       pr_err("JBD2: Error while async write back metadata bh %llu.",
+                              (unsigned long long)bh->b_blocknr);
+                       has_write_io_error = true;
+               }
        } while ((bh = bh->b_this_page) != head);
 
        ret = try_to_free_buffers(page);
 
 busy:
+       if (has_write_io_error)
+               jbd2_journal_abort(journal, -EIO);
+
        return ret;
 }
 
@@ -2572,6 +2586,13 @@ bool __jbd2_journal_refile_buffer(struct journal_head *jh)
 
        was_dirty = test_clear_buffer_jbddirty(bh);
        __jbd2_journal_temp_unlink_buffer(jh);
+
+       /*
+        * b_transaction must be set, otherwise the new b_transaction won't
+        * be holding jh reference
+        */
+       J_ASSERT_JH(jh, jh->b_transaction != NULL);
+
        /*
         * We set b_transaction here because b_next_transaction will inherit
         * our jh reference and thus __jbd2_journal_file_buffer() must not
index ab8cdd9..78858f6 100644 (file)
@@ -341,7 +341,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
                        rdev = old_decode_dev(je16_to_cpu(jdev.old_id));
                else
                        rdev = new_decode_dev(je32_to_cpu(jdev.new_id));
-               /* fall through */
+               fallthrough;
 
        case S_IFSOCK:
        case S_IFIFO:
index bccfc40..2f6f0b1 100644 (file)
@@ -1273,7 +1273,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
                        dbg_readinode("symlink's target '%s' cached\n", f->target);
                }
 
-               /* fall through... */
+               fallthrough;
 
        case S_IFBLK:
        case S_IFCHR:
index 4d08edf..e0d42e9 100644 (file)
@@ -137,11 +137,11 @@ loff_t dcache_dir_lseek(struct file *file, loff_t offset, int whence)
        switch (whence) {
                case 1:
                        offset += file->f_pos;
-                       /* fall through */
+                       fallthrough;
                case 0:
                        if (offset >= 0)
                                break;
-                       /* fall through */
+                       fallthrough;
                default:
                        return -EINVAL;
        }
index 8fc0542..1f84a03 100644 (file)
@@ -1499,7 +1499,7 @@ static void lease_clear_pending(struct file_lock *fl, int arg)
        switch (arg) {
        case F_UNLCK:
                fl->fl_flags &= ~FL_UNLOCK_PENDING;
-               /* fall through */
+               fallthrough;
        case F_RDLCK:
                fl->fl_flags &= ~FL_DOWNGRADE_PENDING;
        }
@@ -2525,7 +2525,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
                cmd = F_SETLKW;
                file_lock->fl_flags |= FL_OFDLCK;
                file_lock->fl_owner = filp;
-               /* Fallthrough */
+               fallthrough;
        case F_SETLKW:
                file_lock->fl_flags |= FL_SLEEP;
        }
@@ -2656,7 +2656,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
                cmd = F_SETLKW64;
                file_lock->fl_flags |= FL_OFDLCK;
                file_lock->fl_owner = filp;
-               /* Fallthrough */
+               fallthrough;
        case F_SETLKW64:
                file_lock->fl_flags |= FL_SLEEP;
        }
index d1a0e2c..08108b6 100644 (file)
@@ -753,7 +753,7 @@ out:
        case -ENODEV:
                /* Our extent block devices are unavailable */
                set_bit(NFS_LSEG_UNAVAILABLE, &lseg->pls_flags);
-               /* Fall through */
+               fallthrough;
        case 0:
                return lseg;
        default:
index a12f42e..e732580 100644 (file)
@@ -1181,7 +1181,7 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
                        /* A NFSv4 OPEN will revalidate later */
                        if (server->caps & NFS_CAP_ATOMIC_OPEN)
                                goto out;
-                       /* Fallthrough */
+                       fallthrough;
                case S_IFDIR:
                        if (server->flags & NFS_MOUNT_NOCTO)
                                break;
index a13e690..7f5aa04 100644 (file)
@@ -187,7 +187,7 @@ static int filelayout_async_handle_error(struct rpc_task *task,
                pnfs_error_mark_layout_for_return(inode, lseg);
                pnfs_set_lo_fail(lseg);
                rpc_wake_up(&tbl->slot_tbl_waitq);
-               /* fall through */
+               fallthrough;
        default:
 reset:
                dprintk("%s Retry through MDS. Error %d\n", __func__,
index 9651455..ff8965d 100644 (file)
@@ -1133,7 +1133,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
                nfs4_delete_deviceid(devid->ld, devid->nfs_client,
                                &devid->deviceid);
                rpc_wake_up(&tbl->slot_tbl_waitq);
-               /* fall through */
+               fallthrough;
        default:
                if (ff_layout_avoid_mds_available_ds(lseg))
                        return -NFS4ERR_RESET_TO_PNFS;
@@ -1260,7 +1260,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
                 */
                if (opnum == OP_READ)
                        break;
-               /* Fallthrough */
+               fallthrough;
        default:
                pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode,
                                                  lseg);
index 66949da..5248129 100644 (file)
@@ -651,21 +651,21 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
                switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) {
                case Opt_xprt_udp6:
                        protofamily = AF_INET6;
-                       /* fall through */
+                       fallthrough;
                case Opt_xprt_udp:
                        ctx->flags &= ~NFS_MOUNT_TCP;
                        ctx->nfs_server.protocol = XPRT_TRANSPORT_UDP;
                        break;
                case Opt_xprt_tcp6:
                        protofamily = AF_INET6;
-                       /* fall through */
+                       fallthrough;
                case Opt_xprt_tcp:
                        ctx->flags |= NFS_MOUNT_TCP;
                        ctx->nfs_server.protocol = XPRT_TRANSPORT_TCP;
                        break;
                case Opt_xprt_rdma6:
                        protofamily = AF_INET6;
-                       /* fall through */
+                       fallthrough;
                case Opt_xprt_rdma:
                        /* vector side protocols to TCP */
                        ctx->flags |= NFS_MOUNT_TCP;
@@ -684,13 +684,13 @@ static int nfs_fs_context_parse_param(struct fs_context *fc,
                switch (lookup_constant(nfs_xprt_protocol_tokens, param->string, -1)) {
                case Opt_xprt_udp6:
                        mountfamily = AF_INET6;
-                       /* fall through */
+                       fallthrough;
                case Opt_xprt_udp:
                        ctx->mount_server.protocol = XPRT_TRANSPORT_UDP;
                        break;
                case Opt_xprt_tcp6:
                        mountfamily = AF_INET6;
-                       /* fall through */
+                       fallthrough;
                case Opt_xprt_tcp:
                        ctx->mount_server.protocol = XPRT_TRANSPORT_TCP;
                        break;
@@ -899,9 +899,11 @@ static int nfs23_parse_monolithic(struct fs_context *fc,
        ctx->version = NFS_DEFAULT_VERSION;
        switch (data->version) {
        case 1:
-               data->namlen = 0; /* fall through */
+               data->namlen = 0;
+               fallthrough;
        case 2:
-               data->bsize = 0; /* fall through */
+               data->bsize = 0;
+               fallthrough;
        case 3:
                if (data->flags & NFS_MOUNT_VER3)
                        goto out_no_v3;
@@ -909,14 +911,14 @@ static int nfs23_parse_monolithic(struct fs_context *fc,
                memcpy(data->root.data, data->old_root.data, NFS2_FHSIZE);
                /* Turn off security negotiation */
                extra_flags |= NFS_MOUNT_SECFLAVOUR;
-               /* fall through */
+               fallthrough;
        case 4:
                if (data->flags & NFS_MOUNT_SECFLAVOUR)
                        goto out_no_sec;
-               /* fall through */
+               fallthrough;
        case 5:
                memset(data->context, 0, sizeof(data->context));
-               /* fall through */
+               fallthrough;
        case 6:
                if (data->flags & NFS_MOUNT_VER3) {
                        if (data->root.size > NFS3_FHSIZE || data->root.size == 0)
index 26c94b3..c6c8633 100644 (file)
@@ -108,7 +108,7 @@ struct posix_acl *nfs3_get_acl(struct inode *inode, int type)
                case -EPROTONOSUPPORT:
                        dprintk("NFS_V3_ACL extension not supported; disabling\n");
                        server->caps &= ~NFS_CAP_ACLS;
-                       /* fall through */
+                       fallthrough;
                case -ENOTSUPP:
                        status = -EOPNOTSUPP;
                default:
@@ -228,7 +228,7 @@ static int __nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
                        dprintk("NFS_V3_ACL SETACL RPC not supported"
                                        "(will not retry)\n");
                        server->caps &= ~NFS_CAP_ACLS;
-                       /* fall through */
+                       fallthrough;
                case -ENOTSUPP:
                        status = -EOPNOTSUPP;
        }
index a339707..fdfc774 100644 (file)
@@ -211,7 +211,7 @@ static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
                ret = nfs42_proc_llseek(filep, offset, whence);
                if (ret != -ENOTSUPP)
                        return ret;
-               /* Fall through */
+               fallthrough;
        default:
                return nfs_file_llseek(filep, offset, whence);
        }
index 1e72963..62e6eea 100644 (file)
@@ -520,7 +520,7 @@ static int nfs_idmap_prepare_message(char *desc, struct idmap *idmap,
        switch (token) {
        case Opt_find_uid:
                im->im_type = IDMAP_TYPE_USER;
-               /* Fall through */
+               fallthrough;
        case Opt_find_gid:
                im->im_conv = IDMAP_CONV_NAMETOID;
                ret = match_strlcpy(im->im_name, &substr, IDMAP_NAMESZ);
@@ -528,7 +528,7 @@ static int nfs_idmap_prepare_message(char *desc, struct idmap *idmap,
 
        case Opt_find_user:
                im->im_type = IDMAP_TYPE_USER;
-               /* Fall through */
+               fallthrough;
        case Opt_find_group:
                im->im_conv = IDMAP_CONV_IDTONAME;
                ret = match_int(&substr, &im->im_id);
index dbd0154..6e95c85 100644 (file)
@@ -483,7 +483,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
                                                stateid);
                                goto wait_on_recovery;
                        }
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_OPENMODE:
                        if (inode) {
                                int err;
@@ -534,10 +534,10 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
                                ret = -EBUSY;
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_DELAY:
                        nfs_inc_server_stats(server, NFSIOS_DELAY);
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_GRACE:
                case -NFS4ERR_LAYOUTTRYLATER:
                case -NFS4ERR_RECALLCONFLICT:
@@ -1505,7 +1505,7 @@ static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode,
        case NFS4_OPEN_CLAIM_PREVIOUS:
                if (!test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))
                        break;
-               /* Fall through */
+               fallthrough;
        default:
                return 0;
        }
@@ -2439,7 +2439,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
        case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
        case NFS4_OPEN_CLAIM_DELEG_PREV_FH:
                data->o_arg.open_bitmap = &nfs4_open_noattr_bitmap[0];
-               /* Fall through */
+               fallthrough;
        case NFS4_OPEN_CLAIM_FH:
                task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR];
        }
@@ -3293,8 +3293,10 @@ static int _nfs4_do_setattr(struct inode *inode,
 
        /* Servers should only apply open mode checks for file size changes */
        truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false;
-       if (!truncate)
+       if (!truncate) {
+               nfs4_inode_make_writeable(inode);
                goto zero_stateid;
+       }
 
        if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) {
                /* Use that stateid */
@@ -3545,11 +3547,11 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
                        nfs4_free_revoked_stateid(server,
                                        &calldata->arg.stateid,
                                        task->tk_msg.rpc_cred);
-                       /* Fallthrough */
+                       fallthrough;
                case -NFS4ERR_BAD_STATEID:
                        if (calldata->arg.fmode == 0)
                                break;
-                       /* Fallthrough */
+                       fallthrough;
                default:
                        task->tk_status = nfs4_async_handle_exception(task,
                                        server, task->tk_status, &exception);
@@ -6294,7 +6296,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
                nfs4_free_revoked_stateid(data->res.server,
                                data->args.stateid,
                                task->tk_msg.rpc_cred);
-               /* Fallthrough */
+               fallthrough;
        case -NFS4ERR_BAD_STATEID:
        case -NFS4ERR_STALE_STATEID:
        case -ETIMEDOUT:
@@ -6314,7 +6316,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
                        data->res.fattr = NULL;
                        goto out_restart;
                }
-               /* Fallthrough */
+               fallthrough;
        default:
                task->tk_status = nfs4_async_handle_exception(task,
                                data->res.server, task->tk_status,
@@ -6622,13 +6624,13 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
                        if (nfs4_update_lock_stateid(calldata->lsp,
                                        &calldata->res.stateid))
                                break;
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_ADMIN_REVOKED:
                case -NFS4ERR_EXPIRED:
                        nfs4_free_revoked_stateid(calldata->server,
                                        &calldata->arg.stateid,
                                        task->tk_msg.rpc_cred);
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_BAD_STATEID:
                case -NFS4ERR_STALE_STATEID:
                        if (nfs4_sync_lock_stateid(&calldata->arg.stateid,
@@ -7298,7 +7300,12 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state,
        err = nfs4_set_lock_state(state, fl);
        if (err != 0)
                return err;
-       err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW);
+       do {
+               err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW);
+               if (err != -NFS4ERR_DELAY)
+                       break;
+               ssleep(1);
+       } while (err == -NFS4ERR_DELAY);
        return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err);
 }
 
@@ -8665,7 +8672,7 @@ static void nfs4_get_lease_time_done(struct rpc_task *task, void *calldata)
                dprintk("%s Retry: tk_status %d\n", __func__, task->tk_status);
                rpc_delay(task, NFS4_POLL_RETRY_MIN);
                task->tk_status = 0;
-               /* fall through */
+               fallthrough;
        case -NFS4ERR_RETRY_UNCACHED_REP:
                rpc_restart_call_prepare(task);
                return;
@@ -9113,13 +9120,13 @@ static int nfs41_reclaim_complete_handle_errors(struct rpc_task *task, struct nf
        switch(task->tk_status) {
        case 0:
                wake_up_all(&clp->cl_lock_waitq);
-               /* Fallthrough */
+               fallthrough;
        case -NFS4ERR_COMPLETE_ALREADY:
        case -NFS4ERR_WRONG_CRED: /* What to do here? */
                break;
        case -NFS4ERR_DELAY:
                rpc_delay(task, NFS4_POLL_RETRY_MAX);
-               /* fall through */
+               fallthrough;
        case -NFS4ERR_RETRY_UNCACHED_REP:
                return -EAGAIN;
        case -NFS4ERR_BADSESSION:
@@ -9434,10 +9441,10 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata)
                                        &lrp->args.range,
                                        lrp->args.inode))
                        goto out_restart;
-               /* Fallthrough */
+               fallthrough;
        default:
                task->tk_status = 0;
-               /* Fallthrough */
+               fallthrough;
        case 0:
                break;
        case -NFS4ERR_DELAY:
index b1dba24..4bf1079 100644 (file)
@@ -1530,7 +1530,7 @@ restart:
                default:
                        pr_err("NFS: %s: unhandled error %d\n",
                                        __func__, status);
-                       /* Fall through */
+                       fallthrough;
                case -ENOMEM:
                case -NFS4ERR_DENIED:
                case -NFS4ERR_RECLAIM_BAD:
@@ -1667,7 +1667,7 @@ restart:
                                break;
                        }
                        printk(KERN_ERR "NFS: %s: unhandled error %d\n", __func__, status);
-                       /* Fall through */
+                       fallthrough;
                case -ENOENT:
                case -ENOMEM:
                case -EACCES:
@@ -1683,7 +1683,7 @@ restart:
                                set_bit(ops->state_flag_bit, &state->flags);
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_ADMIN_REVOKED:
                case -NFS4ERR_STALE_STATEID:
                case -NFS4ERR_OLD_STATEID:
@@ -1695,7 +1695,7 @@ restart:
                case -NFS4ERR_EXPIRED:
                case -NFS4ERR_NO_GRACE:
                        nfs4_state_mark_reclaim_nograce(sp->so_server->nfs_client, state);
-                       /* Fall through */
+                       fallthrough;
                case -NFS4ERR_STALE_CLIENTID:
                case -NFS4ERR_BADSESSION:
                case -NFS4ERR_BADSLOT:
@@ -2273,11 +2273,11 @@ again:
        case -ETIMEDOUT:
                if (clnt->cl_softrtry)
                        break;
-               /* Fall through */
+               fallthrough;
        case -NFS4ERR_DELAY:
        case -EAGAIN:
                ssleep(1);
-               /* Fall through */
+               fallthrough;
        case -NFS4ERR_STALE_CLIENTID:
                dprintk("NFS: %s after status %d, retrying\n",
                        __func__, status);
@@ -2289,7 +2289,7 @@ again:
                }
                if (clnt->cl_auth->au_flavor == RPC_AUTH_UNIX)
                        break;
-               /* Fall through */
+               fallthrough;
        case -NFS4ERR_CLID_INUSE:
        case -NFS4ERR_WRONGSEC:
                /* No point in retrying if we already used RPC_AUTH_UNIX */
index 6ea4cac..6985cac 100644 (file)
@@ -711,7 +711,7 @@ static void nfs_pgio_rpcsetup(struct nfs_pgio_header *hdr,
        case FLUSH_COND_STABLE:
                if (nfs_reqs_to_commit(cinfo))
                        break;
-               /* fall through */
+               fallthrough;
        default:
                hdr->args.stable = NFS_FILE_SYNC;
        }
index 40332c7..71f7741 100644 (file)
@@ -1541,7 +1541,7 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
        case 0:
                if (res->lrs_present)
                        res_stateid = &res->stateid;
-               /* Fallthrough */
+               fallthrough;
        default:
                arg_stateid = &args->stateid;
        }
index 8ceb642..d056ad2 100644 (file)
@@ -237,7 +237,7 @@ posix_acl_from_nfsacl(struct posix_acl *acl)
                                break;
                        case ACL_MASK:
                                mask = pa;
-                               /* fall through */
+                               fallthrough;
                        case ACL_OTHER:
                                break;
                }
index 9bbaa67..311e5ce 100644 (file)
@@ -83,13 +83,13 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
                        bex->soff = iomap.addr;
                        break;
                }
-               /*FALLTHRU*/
+               fallthrough;
        case IOMAP_HOLE:
                if (seg->iomode == IOMODE_READ) {
                        bex->es = PNFS_BLOCK_NONE_DATA;
                        break;
                }
-               /*FALLTHRU*/
+               fallthrough;
        case IOMAP_DELALLOC:
        default:
                WARN(1, "pnfsd: filesystem returned %d extent\n", iomap.type);
index 7fbe984..052be5b 100644 (file)
@@ -1119,7 +1119,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
                break;
        case -ESERVERFAULT:
                ++session->se_cb_seq_nr;
-               /* Fall through */
+               fallthrough;
        case 1:
        case -NFS4ERR_BADSESSION:
                nfsd4_mark_cb_fault(cb->cb_clp, cb->cb_seq_status);
index e12409e..a97873f 100644 (file)
@@ -681,7 +681,7 @@ nfsd4_cb_layout_done(struct nfsd4_callback *cb, struct rpc_task *task)
                        rpc_delay(task, HZ/100); /* 10 mili-seconds */
                        return 0;
                }
-               /* Fallthrough */
+               fallthrough;
        default:
                /*
                 * Unknown error or non-responding client, we'll need to fence.
index a527da3..eaf50ea 100644 (file)
@@ -428,7 +428,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                                goto out;
                        open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED;
                        reclaim = true;
-                       /* fall through */
+                       fallthrough;
                case NFS4_OPEN_CLAIM_FH:
                case NFS4_OPEN_CLAIM_DELEG_CUR_FH:
                        status = do_open_fhandle(rqstp, cstate, open);
index 81ed8e8..c09a2a4 100644 (file)
@@ -3117,7 +3117,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                break;
        default:                                /* checked by xdr code */
                WARN_ON_ONCE(1);
-               /* fall through */
+               fallthrough;
        case SP4_SSV:
                status = nfserr_encr_alg_unsupp;
                goto out_nolock;
@@ -4532,7 +4532,7 @@ static int nfsd4_cb_recall_done(struct nfsd4_callback *cb,
                        rpc_delay(task, 2 * HZ);
                        return 0;
                }
-               /*FALLTHRU*/
+               fallthrough;
        default:
                return 1;
        }
@@ -4597,6 +4597,8 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl)
        if (!i_am_nfsd())
                return NULL;
        rqst = kthread_data(current);
+       if (!rqst->rq_lease_breaker)
+               return NULL;
        clp = *(rqst->rq_lease_breaker);
        return dl->dl_stid.sc_client == clp;
 }
@@ -5652,7 +5654,7 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid)
                break;
        default:
                printk("unknown stateid type %x\n", s->sc_type);
-               /* Fallthrough */
+               fallthrough;
        case NFS4_CLOSED_STID:
        case NFS4_CLOSED_DELEG_STID:
                status = nfserr_bad_stateid;
@@ -6742,7 +6744,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                case NFS4_READW_LT:
                        if (nfsd4_has_session(cstate))
                                fl_flags |= FL_SLEEP;
-                       /* Fallthrough */
+                       fallthrough;
                case NFS4_READ_LT:
                        spin_lock(&fp->fi_lock);
                        nf = find_readable_file_locked(fp);
@@ -6754,7 +6756,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                case NFS4_WRITEW_LT:
                        if (nfsd4_has_session(cstate))
                                fl_flags |= FL_SLEEP;
-                       /* Fallthrough */
+                       fallthrough;
                case NFS4_WRITE_LT:
                        spin_lock(&fp->fi_lock);
                        nf = find_writeable_file_locked(fp);
@@ -6816,7 +6818,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                break;
        case FILE_LOCK_DEFERRED:
                nbl = NULL;
-               /* Fallthrough */
+               fallthrough;
        case -EAGAIN:           /* conflock holds conflicting lock */
                status = nfserr_denied;
                dprintk("NFSD: nfsd4_lock: conflicting lock found!\n");
index 37bc8f5..c81dbba 100644 (file)
@@ -459,7 +459,7 @@ static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp)
        case FSID_DEV:
                if (!old_valid_dev(exp_sb(exp)->s_dev))
                        return false;
-               /* FALL THROUGH */
+               fallthrough;
        case FSID_MAJOR_MINOR:
        case FSID_ENCODE_DEV:
                return exp_sb(exp)->s_type->fs_flags & FS_REQUIRES_DEV;
@@ -469,7 +469,7 @@ static bool fsid_type_ok_for_exp(u8 fsid_type, struct svc_export *exp)
        case FSID_UUID16:
                if (!is_root_export(exp))
                        return false;
-               /* fall through */
+               fallthrough;
        case FSID_UUID4_INUM:
        case FSID_UUID16_INUM:
                return exp->ex_uuid != NULL;
index 543bbe0..6e0b066 100644 (file)
@@ -314,7 +314,7 @@ nfsd_proc_create(struct svc_rqst *rqstp)
                                        rdev = inode->i_rdev;
                                        attr->ia_valid |= ATTR_SIZE;
 
-                                       /* FALLTHROUGH */
+                                       fallthrough;
                                case S_IFIFO:
                                        /* this is probably a permission check..
                                         * at least IRIX implements perm checking on
index b603dfc..f7f6473 100644 (file)
@@ -221,7 +221,7 @@ int nfsd_vers(struct nfsd_net *nn, int vers, enum vers_op change)
        case NFSD_TEST:
                if (nn->nfsd_versions)
                        return nn->nfsd_versions[vers];
-               /* Fallthrough */
+               fallthrough;
        case NFSD_AVAIL:
                return nfsd_support_version(vers);
        }
index 7d2933b..aba5af9 100644 (file)
@@ -1456,7 +1456,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
                                        *created = true;
                                break;
                        }
-                       /* fall through */
+                       fallthrough;
                case NFS4_CREATE_EXCLUSIVE4_1:
                        if (   d_inode(dchild)->i_mtime.tv_sec == v_mtime
                            && d_inode(dchild)->i_atime.tv_sec == v_atime
@@ -1465,7 +1465,7 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
                                        *created = true;
                                goto set_attr;
                        }
-                       /* fall through */
+                       fallthrough;
                case NFS3_CREATE_GUARDED:
                        err = nfserr_exist;
                }
index fb5a9a8..e516ae3 100644 (file)
@@ -519,7 +519,7 @@ int nilfs_bmap_read(struct nilfs_bmap *bmap, struct nilfs_inode *raw_inode)
                break;
        case NILFS_IFILE_INO:
                lockdep_set_class(&bmap->b_sem, &nilfs_bmap_mdt_lock_key);
-               /* Fall through */
+               fallthrough;
        default:
                bmap->b_ptr_type = NILFS_BMAP_PTR_VM;
                bmap->b_last_allocated_key = 0;
index 0b453ef..2217f90 100644 (file)
@@ -626,7 +626,7 @@ static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
                            !(flags & NILFS_SS_SYNDT))
                                goto try_next_pseg;
                        state = RF_DSYNC_ST;
-                       /* Fall through */
+                       fallthrough;
                case RF_DSYNC_ST:
                        if (!(flags & NILFS_SS_SYNDT))
                                goto confused;
index a651e82..e3726ac 100644 (file)
@@ -1138,7 +1138,8 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                        nilfs_sc_cstage_set(sci, NILFS_ST_DAT);
                        goto dat_stage;
                }
-               nilfs_sc_cstage_inc(sci);  /* Fall through */
+               nilfs_sc_cstage_inc(sci);
+               fallthrough;
        case NILFS_ST_GC:
                if (nilfs_doing_gc()) {
                        head = &sci->sc_gc_inodes;
@@ -1159,7 +1160,8 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                        }
                        sci->sc_stage.gc_inode_ptr = NULL;
                }
-               nilfs_sc_cstage_inc(sci);  /* Fall through */
+               nilfs_sc_cstage_inc(sci);
+               fallthrough;
        case NILFS_ST_FILE:
                head = &sci->sc_dirty_files;
                ii = list_prepare_entry(sci->sc_stage.dirty_file_ptr, head,
@@ -1186,7 +1188,7 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                }
                nilfs_sc_cstage_inc(sci);
                sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED;
-               /* Fall through */
+               fallthrough;
        case NILFS_ST_IFILE:
                err = nilfs_segctor_scan_file(sci, sci->sc_root->ifile,
                                              &nilfs_sc_file_ops);
@@ -1197,13 +1199,14 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                err = nilfs_segctor_create_checkpoint(sci);
                if (unlikely(err))
                        break;
-               /* Fall through */
+               fallthrough;
        case NILFS_ST_CPFILE:
                err = nilfs_segctor_scan_file(sci, nilfs->ns_cpfile,
                                              &nilfs_sc_file_ops);
                if (unlikely(err))
                        break;
-               nilfs_sc_cstage_inc(sci);  /* Fall through */
+               nilfs_sc_cstage_inc(sci);
+               fallthrough;
        case NILFS_ST_SUFILE:
                err = nilfs_sufile_freev(nilfs->ns_sufile, sci->sc_freesegs,
                                         sci->sc_nfreesegs, &ndone);
@@ -1219,7 +1222,8 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                                              &nilfs_sc_file_ops);
                if (unlikely(err))
                        break;
-               nilfs_sc_cstage_inc(sci);  /* Fall through */
+               nilfs_sc_cstage_inc(sci);
+               fallthrough;
        case NILFS_ST_DAT:
  dat_stage:
                err = nilfs_segctor_scan_file(sci, nilfs->ns_dat,
@@ -1230,7 +1234,8 @@ static int nilfs_segctor_collect_blocks(struct nilfs_sc_info *sci, int mode)
                        nilfs_sc_cstage_set(sci, NILFS_ST_DONE);
                        return 0;
                }
-               nilfs_sc_cstage_inc(sci);  /* Fall through */
+               nilfs_sc_cstage_inc(sci);
+               fallthrough;
        case NILFS_ST_SR:
                if (mode == SC_LSEG_SR) {
                        /* Appending a super root */
index 559de31..3e01d8f 100644 (file)
@@ -1147,7 +1147,7 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
        }
 
        switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {
-       case FAN_MARK_ADD:              /* fallthrough */
+       case FAN_MARK_ADD:
        case FAN_MARK_REMOVE:
                if (!mask)
                        return -EINVAL;
index 1ef2457..cea739b 100644 (file)
@@ -67,7 +67,7 @@ static void o2quo_fence_self(void)
        default:
                WARN_ON(o2nm_single_cluster->cl_fence_method >=
                        O2NM_FENCE_METHODS);
-               /* fall through */
+               fallthrough;
        case O2NM_FENCE_RESET:
                printk(KERN_ERR "*** ocfs2 is very sorry to be fencing this "
                       "system by restarting ***\n");
index 819428d..3ce8921 100644 (file)
@@ -1081,7 +1081,6 @@ next_zone:
                readop = psz_ftrace_read;
                break;
        case PSTORE_TYPE_CONSOLE:
-               fallthrough;
        case PSTORE_TYPE_PMSG:
                readop = psz_record_read;
                break;
index 5444d3c..47f9e15 100644 (file)
@@ -38,7 +38,7 @@ static int check_quotactl_permission(struct super_block *sb, int type, int cmd,
                if ((type == USRQUOTA && uid_eq(current_euid(), make_kuid(current_user_ns(), id))) ||
                    (type == GRPQUOTA && in_egroup_p(make_kgid(current_user_ns(), id))))
                        break;
-               /*FALLTHROUGH*/
+               fallthrough;
        default:
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
index 6b2b436..b57b3ff 100644 (file)
@@ -217,10 +217,8 @@ int romfs_dev_read(struct super_block *sb, unsigned long pos,
        size_t limit;
 
        limit = romfs_maxsize(sb);
-       if (pos >= limit)
+       if (pos >= limit || buflen > limit - pos)
                return -EIO;
-       if (buflen > limit - pos)
-               buflen = limit - pos;
 
 #ifdef CONFIG_ROMFS_ON_MTD
        if (sb->s_mtd)
index 4e6239f..31219c1 100644 (file)
@@ -295,7 +295,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence)
        switch (whence) {
        case SEEK_CUR:
                offset += file->f_pos;
-               /* fall through */
+               fallthrough;
        case SEEK_SET:
                if (offset < 0)
                        break;
index 5b78719..456046e 100644 (file)
@@ -176,7 +176,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info
                if (!nonblock)
                        break;
                ret = -EAGAIN;
-               /* fall through */
+               fallthrough;
        default:
                spin_unlock_irq(&current->sighand->siglock);
                return ret;
index 76bb1c8..8a19773 100644 (file)
@@ -87,7 +87,11 @@ static int squashfs_bio_read(struct super_block *sb, u64 index, int length,
        int error, i;
        struct bio *bio;
 
-       bio = bio_alloc(GFP_NOIO, page_count);
+       if (page_count <= BIO_MAX_PAGES)
+               bio = bio_alloc(GFP_NOIO, page_count);
+       else
+               bio = bio_kmalloc(GFP_NOIO, page_count);
+
        if (!bio)
                return -ENOMEM;
 
index 22bfda1..6d6cd85 100644 (file)
@@ -269,7 +269,7 @@ void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
                        break;
                /* No more room on heap so make it un-categorized */
                cat = LPROPS_UNCAT;
-               /* Fall through */
+               fallthrough;
        case LPROPS_UNCAT:
                list_add(&lprops->list, &c->uncat_list);
                break;
@@ -313,7 +313,7 @@ static void ubifs_remove_from_cat(struct ubifs_info *c,
        case LPROPS_FREEABLE:
                c->freeable_cnt -= 1;
                ubifs_assert(c, c->freeable_cnt >= 0);
-               /* Fall through */
+               fallthrough;
        case LPROPS_UNCAT:
        case LPROPS_EMPTY:
        case LPROPS_FRDI_IDX:
index 6023c97..25ff91c 100644 (file)
@@ -52,7 +52,7 @@ static int udf_pc_to_char(struct super_block *sb, unsigned char *from,
                                elen += pc->lengthComponentIdent;
                                break;
                        }
-                       /* Fall through */
+                       fallthrough;
                case 2:
                        if (tolen == 0)
                                return -ENAMETOOLONG;
index e1f1b2e..4931bec 100644 (file)
@@ -42,7 +42,7 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,
        case UFS_ST_SUNOS:
                if (fs32_to_cpu(sb, usb3->fs_postblformat) == UFS_42POSTBLFMT)
                        return fs32_to_cpu(sb, usb1->fs_u0.fs_sun.fs_state);
-               /* Fall Through - to UFS_ST_SUN */
+               fallthrough;    /* to UFS_ST_SUN */
        case UFS_ST_SUN:
                return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state);
        case UFS_ST_SUNx86:
@@ -63,7 +63,7 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,
                        usb1->fs_u0.fs_sun.fs_state = cpu_to_fs32(sb, value);
                        break;
                }
-               /* Fall Through - to UFS_ST_SUN */
+               fallthrough;    /* to UFS_ST_SUN */
        case UFS_ST_SUN:
                usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value);
                break;
@@ -197,7 +197,7 @@ ufs_get_inode_uid(struct super_block *sb, struct ufs_inode *inode)
        case UFS_UID_EFT:
                if (inode->ui_u1.oldids.ui_suid == 0xFFFF)
                        return fs32_to_cpu(sb, inode->ui_u3.ui_sun.ui_uid);
-               /* Fall through */
+               fallthrough;
        default:
                return fs16_to_cpu(sb, inode->ui_u1.oldids.ui_suid);
        }
@@ -215,7 +215,7 @@ ufs_set_inode_uid(struct super_block *sb, struct ufs_inode *inode, u32 value)
                inode->ui_u3.ui_sun.ui_uid = cpu_to_fs32(sb, value);
                if (value > 0xFFFF)
                        value = 0xFFFF;
-               /* Fall through */
+               fallthrough;
        default:
                inode->ui_u1.oldids.ui_suid = cpu_to_fs16(sb, value);
                break;
@@ -231,7 +231,7 @@ ufs_get_inode_gid(struct super_block *sb, struct ufs_inode *inode)
        case UFS_UID_EFT:
                if (inode->ui_u1.oldids.ui_sgid == 0xFFFF)
                        return fs32_to_cpu(sb, inode->ui_u3.ui_sun.ui_gid);
-               /* Fall through */
+               fallthrough;
        default:
                return fs16_to_cpu(sb, inode->ui_u1.oldids.ui_sgid);
        }
@@ -249,7 +249,7 @@ ufs_set_inode_gid(struct super_block *sb, struct ufs_inode *inode, u32 value)
                inode->ui_u3.ui_sun.ui_gid = cpu_to_fs32(sb, value);
                if (value > 0xFFFF)
                        value = 0xFFFF;
-               /* Fall through */
+               fallthrough;
        default:
                inode->ui_u1.oldids.ui_sgid =  cpu_to_fs16(sb, value);
                break;
index 96bd160..0180575 100644 (file)
@@ -226,7 +226,7 @@ int vboxsf_getattr(const struct path *path, struct kstat *kstat,
                break;
        case AT_STATX_FORCE_SYNC:
                sf_i->force_restat = 1;
-               /* fall-through */
+               fallthrough;
        default:
                err = vboxsf_inode_revalidate(dentry);
        }
index 8623c81..305d4bc 100644 (file)
@@ -653,8 +653,8 @@ xfs_attr_shortform_create(
                ASSERT(ifp->if_flags & XFS_IFINLINE);
        }
        xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
-       hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
-       hdr->count = 0;
+       hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
+       memset(hdr, 0, sizeof(*hdr));
        hdr->totsize = cpu_to_be16(sizeof(*hdr));
        xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
 }
@@ -1036,8 +1036,10 @@ xfs_attr_shortform_verify(
                 * struct xfs_attr_sf_entry has a variable length.
                 * Check the fixed-offset parts of the structure are
                 * within the data buffer.
+                * xfs_attr_sf_entry is defined with a 1-byte variable
+                * array at the end, so we must subtract that off.
                 */
-               if (((char *)sfep + sizeof(*sfep)) >= endp)
+               if (((char *)sfep + sizeof(*sfep) - 1) >= endp)
                        return __this_address;
 
                /* Don't allow names with known bad length. */
index 9c40d59..1b0a01b 100644 (file)
@@ -6226,7 +6226,7 @@ xfs_bmap_validate_extent(
 
        isrt = XFS_IS_REALTIME_INODE(ip);
        endfsb = irec->br_startblock + irec->br_blockcount - 1;
-       if (isrt) {
+       if (isrt && whichfork == XFS_DATA_FORK) {
                if (!xfs_verify_rtbno(mp, irec->br_startblock))
                        return __this_address;
                if (!xfs_verify_rtbno(mp, endfsb))
index f742a96..a6b37db 100644 (file)
@@ -688,7 +688,7 @@ xfs_ialloc_ag_alloc(
                args.minalignslop = igeo->cluster_align - 1;
 
                /* Allow space for the inode btree to split. */
-               args.minleft = igeo->inobt_maxlevels - 1;
+               args.minleft = igeo->inobt_maxlevels;
                if ((error = xfs_alloc_vextent(&args)))
                        return error;
 
@@ -736,7 +736,7 @@ xfs_ialloc_ag_alloc(
                /*
                 * Allow space for the inode btree to split.
                 */
-               args.minleft = igeo->inobt_maxlevels - 1;
+               args.minleft = igeo->inobt_maxlevels;
                if ((error = xfs_alloc_vextent(&args)))
                        return error;
        }
index e151296..b7e222b 100644 (file)
@@ -110,9 +110,9 @@ xfs_trans_log_inode(
         * to log the timestamps, or will clear already cleared fields in the
         * worst case.
         */
-       if (inode->i_state & (I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED)) {
+       if (inode->i_state & I_DIRTY_TIME) {
                spin_lock(&inode->i_lock);
-               inode->i_state &= ~(I_DIRTY_TIME | I_DIRTY_TIME_EXPIRED);
+               inode->i_state &= ~I_DIRTY_TIME;
                spin_unlock(&inode->i_lock);
        }
 
index c6df01a..7ad3659 100644 (file)
@@ -58,7 +58,7 @@
 #define        XFS_IALLOC_SPACE_RES(mp)        \
        (M_IGEO(mp)->ialloc_blks + \
         ((xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1) * \
-         (M_IGEO(mp)->inobt_maxlevels - 1)))
+         M_IGEO(mp)->inobt_maxlevels))
 
 /*
  * Space reservation values for various transactions.
index 73cafc8..5123f82 100644 (file)
@@ -1165,7 +1165,7 @@ xfs_insert_file_space(
                goto out_trans_cancel;
 
        do {
-               error = xfs_trans_roll_inode(&tp, ip);
+               error = xfs_defer_finish(&tp);
                if (error)
                        goto out_trans_cancel;
 
index c31cd3b..a29f78a 100644 (file)
@@ -1223,6 +1223,14 @@ __xfs_filemap_fault(
        return ret;
 }
 
+static inline bool
+xfs_is_write_fault(
+       struct vm_fault         *vmf)
+{
+       return (vmf->flags & FAULT_FLAG_WRITE) &&
+              (vmf->vma->vm_flags & VM_SHARED);
+}
+
 static vm_fault_t
 xfs_filemap_fault(
        struct vm_fault         *vmf)
@@ -1230,7 +1238,7 @@ xfs_filemap_fault(
        /* DAX can shortcut the normal fault path on write faults! */
        return __xfs_filemap_fault(vmf, PE_SIZE_PTE,
                        IS_DAX(file_inode(vmf->vma->vm_file)) &&
-                       (vmf->flags & FAULT_FLAG_WRITE));
+                       xfs_is_write_fault(vmf));
 }
 
 static vm_fault_t
@@ -1243,7 +1251,7 @@ xfs_filemap_huge_fault(
 
        /* DAX can shortcut the normal fault path on write faults! */
        return __xfs_filemap_fault(vmf, pe_size,
-                       (vmf->flags & FAULT_FLAG_WRITE));
+                       xfs_is_write_fault(vmf));
 }
 
 static vm_fault_t
index c6bab49..fe58dbb 100644 (file)
@@ -29,6 +29,9 @@
 /* Slave address for the HDCP registers in the receiver */
 #define DRM_HDCP_DDC_ADDR                      0x3A
 
+/* Value to use at the end of the SHA-1 bytestream used for repeaters */
+#define DRM_HDCP_SHA1_TERMINATOR               0x80
+
 /* HDCP register offsets for HDMI/DVI devices */
 #define DRM_HDCP_DDC_BKSV                      0x00
 #define DRM_HDCP_DDC_RI_PRIME                  0x08
index 4fc9a43..aafd073 100644 (file)
@@ -164,6 +164,8 @@ int drm_modeset_lock_all_ctx(struct drm_device *dev,
  * is 0, so no error checking is necessary
  */
 #define DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, flags, ret)               \
+       if (!drm_drv_uses_atomic_modeset(dev))                          \
+               mutex_lock(&dev->mode_config.mutex);                    \
        drm_modeset_acquire_init(&ctx, flags);                          \
 modeset_lock_retry:                                                    \
        ret = drm_modeset_lock_all_ctx(dev, &ctx);                      \
@@ -172,6 +174,7 @@ modeset_lock_retry:                                                 \
 
 /**
  * DRM_MODESET_LOCK_ALL_END - Helper to release and cleanup modeset locks
+ * @dev: drm device
  * @ctx: local modeset acquire context, will be dereferenced
  * @ret: local ret/err/etc variable to track error status
  *
@@ -188,7 +191,7 @@ modeset_lock_retry:                                                 \
  * to that failure. In both of these cases the code between BEGIN/END will not
  * be run, so the failure will reflect the inability to grab the locks.
  */
-#define DRM_MODESET_LOCK_ALL_END(ctx, ret)                             \
+#define DRM_MODESET_LOCK_ALL_END(dev, ctx, ret)                                \
 modeset_lock_fail:                                                     \
        if (ret == -EDEADLK) {                                          \
                ret = drm_modeset_backoff(&ctx);                        \
@@ -196,6 +199,8 @@ modeset_lock_fail:                                                  \
                        goto modeset_lock_retry;                        \
        }                                                               \
        drm_modeset_drop_locks(&ctx);                                   \
-       drm_modeset_acquire_fini(&ctx);
+       drm_modeset_acquire_fini(&ctx);                                 \
+       if (!drm_drv_uses_atomic_modeset(dev))                          \
+               mutex_unlock(&dev->mode_config.mutex);
 
 #endif /* DRM_MODESET_LOCK_H_ */
diff --git a/include/dt-bindings/interconnect/qcom,icc.h b/include/dt-bindings/interconnect/qcom,icc.h
new file mode 100644 (file)
index 0000000..cd34f36
--- /dev/null
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DT_BINDINGS_INTERCONNECT_QCOM_ICC_H
+#define __DT_BINDINGS_INTERCONNECT_QCOM_ICC_H
+
+/*
+ * The AMC bucket denotes constraints that are applied to hardware when
+ * icc_set_bw() completes, whereas the WAKE and SLEEP constraints are applied
+ * when the execution environment transitions between active and low power mode.
+ */
+#define QCOM_ICC_BUCKET_AMC            0
+#define QCOM_ICC_BUCKET_WAKE           1
+#define QCOM_ICC_BUCKET_SLEEP          2
+#define QCOM_ICC_NUM_BUCKETS           3
+
+#define QCOM_ICC_TAG_AMC               (1 << QCOM_ICC_BUCKET_AMC)
+#define QCOM_ICC_TAG_WAKE              (1 << QCOM_ICC_BUCKET_WAKE)
+#define QCOM_ICC_TAG_SLEEP             (1 << QCOM_ICC_BUCKET_SLEEP)
+#define QCOM_ICC_TAG_ACTIVE_ONLY       (QCOM_ICC_TAG_AMC | QCOM_ICC_TAG_WAKE)
+#define QCOM_ICC_TAG_ALWAYS            (QCOM_ICC_TAG_AMC | QCOM_ICC_TAG_WAKE |\
+                                        QCOM_ICC_TAG_SLEEP)
+
+#endif
index 54858ff..61ef649 100644 (file)
@@ -9,4 +9,7 @@
 #define MASTER_OSM_L3_APPS     0
 #define SLAVE_OSM_L3           1
 
+#define MASTER_EPSS_L3_APPS    0
+#define SLAVE_EPSS_L3_SHARED   1
+
 #endif
diff --git a/include/dt-bindings/interconnect/qcom,sm8150.h b/include/dt-bindings/interconnect/qcom,sm8150.h
new file mode 100644 (file)
index 0000000..a256846
--- /dev/null
@@ -0,0 +1,162 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Qualcomm SM8150 interconnect IDs
+ *
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DT_BINDINGS_INTERCONNECT_QCOM_SM8150_H
+#define __DT_BINDINGS_INTERCONNECT_QCOM_SM8150_H
+
+#define MASTER_A1NOC_CFG               0
+#define MASTER_QUP_0                   1
+#define MASTER_EMAC                    2
+#define MASTER_UFS_MEM                 3
+#define MASTER_USB3                    4
+#define MASTER_USB3_1                  5
+#define A1NOC_SNOC_SLV                 6
+#define SLAVE_SERVICE_A1NOC            7
+
+#define MASTER_A2NOC_CFG               0
+#define MASTER_QDSS_BAM                        1
+#define MASTER_QSPI                    2
+#define MASTER_QUP_1                   3
+#define MASTER_QUP_2                   4
+#define MASTER_SENSORS_AHB             5
+#define MASTER_TSIF                    6
+#define MASTER_CNOC_A2NOC              7
+#define MASTER_CRYPTO_CORE_0           8
+#define MASTER_IPA                     9
+#define MASTER_PCIE                    10
+#define MASTER_PCIE_1                  11
+#define MASTER_QDSS_ETR                        12
+#define MASTER_SDCC_2                  13
+#define MASTER_SDCC_4                  14
+#define A2NOC_SNOC_SLV                 15
+#define SLAVE_ANOC_PCIE_GEM_NOC                16
+#define SLAVE_SERVICE_A2NOC            17
+
+#define MASTER_CAMNOC_HF0_UNCOMP       0
+#define MASTER_CAMNOC_HF1_UNCOMP       1
+#define MASTER_CAMNOC_SF_UNCOMP                2
+#define SLAVE_CAMNOC_UNCOMP            3
+
+#define MASTER_NPU                     0
+#define SLAVE_CDSP_MEM_NOC             1
+
+#define MASTER_SPDM                    0
+#define SNOC_CNOC_MAS                  1
+#define MASTER_QDSS_DAP                        2
+#define SLAVE_A1NOC_CFG                        3
+#define SLAVE_A2NOC_CFG                        4
+#define SLAVE_AHB2PHY_SOUTH            5
+#define SLAVE_AOP                      6
+#define SLAVE_AOSS                     7
+#define SLAVE_CAMERA_CFG               8
+#define SLAVE_CLK_CTL                  9
+#define SLAVE_CDSP_CFG                 10
+#define SLAVE_RBCPR_CX_CFG             11
+#define SLAVE_RBCPR_MMCX_CFG           12
+#define SLAVE_RBCPR_MX_CFG             13
+#define SLAVE_CRYPTO_0_CFG             14
+#define SLAVE_CNOC_DDRSS               15
+#define SLAVE_DISPLAY_CFG              16
+#define SLAVE_EMAC_CFG                 17
+#define SLAVE_GLM                      18
+#define SLAVE_GRAPHICS_3D_CFG          19
+#define SLAVE_IMEM_CFG                 20
+#define SLAVE_IPA_CFG                  21
+#define SLAVE_CNOC_MNOC_CFG            22
+#define SLAVE_NPU_CFG                  23
+#define SLAVE_PCIE_0_CFG               24
+#define SLAVE_PCIE_1_CFG               25
+#define SLAVE_NORTH_PHY_CFG            26
+#define SLAVE_PIMEM_CFG                        27
+#define SLAVE_PRNG                     28
+#define SLAVE_QDSS_CFG                 29
+#define SLAVE_QSPI                     30
+#define SLAVE_QUP_2                    31
+#define SLAVE_QUP_1                    32
+#define SLAVE_QUP_0                    33
+#define SLAVE_SDCC_2                   34
+#define SLAVE_SDCC_4                   35
+#define SLAVE_SNOC_CFG                 36
+#define SLAVE_SPDM_WRAPPER             37
+#define SLAVE_SPSS_CFG                 38
+#define SLAVE_SSC_CFG                  39
+#define SLAVE_TCSR                     40
+#define SLAVE_TLMM_EAST                        41
+#define SLAVE_TLMM_NORTH               42
+#define SLAVE_TLMM_SOUTH               43
+#define SLAVE_TLMM_WEST                        44
+#define SLAVE_TSIF                     45
+#define SLAVE_UFS_CARD_CFG             46
+#define SLAVE_UFS_MEM_CFG              47
+#define SLAVE_USB3                     48
+#define SLAVE_USB3_1                   49
+#define SLAVE_VENUS_CFG                        50
+#define SLAVE_VSENSE_CTRL_CFG          51
+#define SLAVE_CNOC_A2NOC               52
+#define SLAVE_SERVICE_CNOC             53
+
+#define MASTER_CNOC_DC_NOC             0
+#define SLAVE_LLCC_CFG                 1
+#define SLAVE_GEM_NOC_CFG              2
+
+#define MASTER_AMPSS_M0                        0
+#define MASTER_GPU_TCU                 1
+#define MASTER_SYS_TCU                 2
+#define MASTER_GEM_NOC_CFG             3
+#define MASTER_COMPUTE_NOC             4
+#define MASTER_GRAPHICS_3D             5
+#define MASTER_MNOC_HF_MEM_NOC         6
+#define MASTER_MNOC_SF_MEM_NOC         7
+#define MASTER_GEM_NOC_PCIE_SNOC       8
+#define MASTER_SNOC_GC_MEM_NOC         9
+#define MASTER_SNOC_SF_MEM_NOC         10
+#define MASTER_ECC                     11
+#define SLAVE_MSS_PROC_MS_MPU_CFG      12
+#define SLAVE_ECC                      13
+#define SLAVE_GEM_NOC_SNOC             14
+#define SLAVE_LLCC                     15
+#define SLAVE_SERVICE_GEM_NOC          16
+
+#define MASTER_IPA_CORE                        0
+#define SLAVE_IPA_CORE                 1
+
+#define MASTER_LLCC                    0
+#define SLAVE_EBI_CH0                  1
+
+#define MASTER_CNOC_MNOC_CFG           0
+#define MASTER_CAMNOC_HF0              1
+#define MASTER_CAMNOC_HF1              2
+#define MASTER_CAMNOC_SF               3
+#define MASTER_MDP_PORT0               4
+#define MASTER_MDP_PORT1               5
+#define MASTER_ROTATOR                 6
+#define MASTER_VIDEO_P0                        7
+#define MASTER_VIDEO_P1                        8
+#define MASTER_VIDEO_PROC              9
+#define SLAVE_MNOC_SF_MEM_NOC          10
+#define SLAVE_MNOC_HF_MEM_NOC          11
+#define SLAVE_SERVICE_MNOC             12
+
+#define MASTER_SNOC_CFG                        0
+#define A1NOC_SNOC_MAS                 1
+#define A2NOC_SNOC_MAS                 2
+#define MASTER_GEM_NOC_SNOC            3
+#define MASTER_PIMEM                   4
+#define MASTER_GIC                     5
+#define SLAVE_APPSS                    6
+#define SNOC_CNOC_SLV                  7
+#define SLAVE_SNOC_GEM_NOC_GC          8
+#define SLAVE_SNOC_GEM_NOC_SF          9
+#define SLAVE_OCIMEM                   10
+#define SLAVE_PIMEM                    11
+#define SLAVE_SERVICE_SNOC             12
+#define SLAVE_PCIE_0                   13
+#define SLAVE_PCIE_1                   14
+#define SLAVE_QDSS_STM                 15
+#define SLAVE_TCU                      16
+
+#endif
diff --git a/include/dt-bindings/interconnect/qcom,sm8250.h b/include/dt-bindings/interconnect/qcom,sm8250.h
new file mode 100644 (file)
index 0000000..1b4d9fb
--- /dev/null
@@ -0,0 +1,172 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Qualcomm SM8250 interconnect IDs
+ *
+ * Copyright (c) 2020, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef __DT_BINDINGS_INTERCONNECT_QCOM_SM8250_H
+#define __DT_BINDINGS_INTERCONNECT_QCOM_SM8250_H
+
+#define MASTER_A1NOC_CFG               0
+#define MASTER_QSPI_0                  1
+#define MASTER_QUP_1                   2
+#define MASTER_QUP_2                   3
+#define MASTER_TSIF                    4
+#define MASTER_PCIE_2                  5
+#define MASTER_SDCC_4                  6
+#define MASTER_UFS_MEM                 7
+#define MASTER_USB3                    8
+#define MASTER_USB3_1                  9
+#define A1NOC_SNOC_SLV                 10
+#define SLAVE_ANOC_PCIE_GEM_NOC_1      11
+#define SLAVE_SERVICE_A1NOC            12
+
+#define MASTER_A2NOC_CFG               0
+#define MASTER_QDSS_BAM                        1
+#define MASTER_QUP_0                   2
+#define MASTER_CNOC_A2NOC              3
+#define MASTER_CRYPTO_CORE_0           4
+#define MASTER_IPA                     5
+#define MASTER_PCIE                    6
+#define MASTER_PCIE_1                  7
+#define MASTER_QDSS_ETR                        8
+#define MASTER_SDCC_2                  9
+#define MASTER_UFS_CARD                        10
+#define A2NOC_SNOC_SLV                 11
+#define SLAVE_ANOC_PCIE_GEM_NOC                12
+#define SLAVE_SERVICE_A2NOC            13
+
+#define MASTER_NPU                     0
+#define SLAVE_CDSP_MEM_NOC             1
+
+#define SNOC_CNOC_MAS                  0
+#define MASTER_QDSS_DAP                        1
+#define SLAVE_A1NOC_CFG                        2
+#define SLAVE_A2NOC_CFG                        3
+#define SLAVE_AHB2PHY_SOUTH            4
+#define SLAVE_AHB2PHY_NORTH            5
+#define SLAVE_AOSS                     6
+#define SLAVE_CAMERA_CFG               7
+#define SLAVE_CLK_CTL                  8
+#define SLAVE_CDSP_CFG                 9
+#define SLAVE_RBCPR_CX_CFG             10
+#define SLAVE_RBCPR_MMCX_CFG           11
+#define SLAVE_RBCPR_MX_CFG             12
+#define SLAVE_CRYPTO_0_CFG             13
+#define SLAVE_CX_RDPM                  14
+#define SLAVE_DCC_CFG                  15
+#define SLAVE_CNOC_DDRSS               16
+#define SLAVE_DISPLAY_CFG              17
+#define SLAVE_GRAPHICS_3D_CFG          18
+#define SLAVE_IMEM_CFG                 19
+#define SLAVE_IPA_CFG                  20
+#define SLAVE_IPC_ROUTER_CFG           21
+#define SLAVE_LPASS                    22
+#define SLAVE_CNOC_MNOC_CFG            23
+#define SLAVE_NPU_CFG                  24
+#define SLAVE_PCIE_0_CFG               25
+#define SLAVE_PCIE_1_CFG               26
+#define SLAVE_PCIE_2_CFG               27
+#define SLAVE_PDM                      28
+#define SLAVE_PIMEM_CFG                        29
+#define SLAVE_PRNG                     30
+#define SLAVE_QDSS_CFG                 31
+#define SLAVE_QSPI_0                   32
+#define SLAVE_QUP_0                    33
+#define SLAVE_QUP_1                    34
+#define SLAVE_QUP_2                    35
+#define SLAVE_SDCC_2                   36
+#define SLAVE_SDCC_4                   37
+#define SLAVE_SNOC_CFG                 38
+#define SLAVE_TCSR                     39
+#define SLAVE_TLMM_NORTH               40
+#define SLAVE_TLMM_SOUTH               41
+#define SLAVE_TLMM_WEST                        42
+#define SLAVE_TSIF                     43
+#define SLAVE_UFS_CARD_CFG             44
+#define SLAVE_UFS_MEM_CFG              45
+#define SLAVE_USB3                     46
+#define SLAVE_USB3_1                   47
+#define SLAVE_VENUS_CFG                        48
+#define SLAVE_VSENSE_CTRL_CFG          49
+#define SLAVE_CNOC_A2NOC               50
+#define SLAVE_SERVICE_CNOC             51
+
+#define MASTER_CNOC_DC_NOC             0
+#define SLAVE_LLCC_CFG                 1
+#define SLAVE_GEM_NOC_CFG              2
+
+#define MASTER_GPU_TCU                 0
+#define MASTER_SYS_TCU                 1
+#define MASTER_AMPSS_M0                        2
+#define MASTER_GEM_NOC_CFG             3
+#define MASTER_COMPUTE_NOC             4
+#define MASTER_GRAPHICS_3D             5
+#define MASTER_MNOC_HF_MEM_NOC         6
+#define MASTER_MNOC_SF_MEM_NOC         7
+#define MASTER_ANOC_PCIE_GEM_NOC       8
+#define MASTER_SNOC_GC_MEM_NOC         9
+#define MASTER_SNOC_SF_MEM_NOC         10
+#define SLAVE_GEM_NOC_SNOC             11
+#define SLAVE_LLCC                     12
+#define SLAVE_MEM_NOC_PCIE_SNOC                13
+#define SLAVE_SERVICE_GEM_NOC_1                14
+#define SLAVE_SERVICE_GEM_NOC_2                15
+#define SLAVE_SERVICE_GEM_NOC          16
+
+#define MASTER_IPA_CORE                        0
+#define SLAVE_IPA_CORE                 1
+
+#define MASTER_LLCC                    0
+#define SLAVE_EBI_CH0                  1
+
+#define MASTER_CNOC_MNOC_CFG           0
+#define MASTER_CAMNOC_HF               1
+#define MASTER_CAMNOC_ICP              2
+#define MASTER_CAMNOC_SF               3
+#define MASTER_VIDEO_P0                        4
+#define MASTER_VIDEO_P1                        5
+#define MASTER_VIDEO_PROC              6
+#define MASTER_MDP_PORT0               7
+#define MASTER_MDP_PORT1               8
+#define MASTER_ROTATOR                 9
+#define SLAVE_MNOC_HF_MEM_NOC          10
+#define SLAVE_MNOC_SF_MEM_NOC          11
+#define SLAVE_SERVICE_MNOC             12
+
+#define MASTER_NPU_SYS                 0
+#define MASTER_NPU_CDP                 1
+#define MASTER_NPU_NOC_CFG             2
+#define SLAVE_NPU_CAL_DP0              3
+#define SLAVE_NPU_CAL_DP1              4
+#define SLAVE_NPU_CP                   5
+#define SLAVE_NPU_INT_DMA_BWMON_CFG    6
+#define SLAVE_NPU_DPM                  7
+#define SLAVE_ISENSE_CFG               8
+#define SLAVE_NPU_LLM_CFG              9
+#define SLAVE_NPU_TCM                  10
+#define SLAVE_NPU_COMPUTE_NOC          11
+#define SLAVE_SERVICE_NPU_NOC          12
+
+#define MASTER_SNOC_CFG                        0
+#define A1NOC_SNOC_MAS                 1
+#define A2NOC_SNOC_MAS                 2
+#define MASTER_GEM_NOC_SNOC            3
+#define MASTER_GEM_NOC_PCIE_SNOC       4
+#define MASTER_PIMEM                   5
+#define MASTER_GIC                     6
+#define SLAVE_APPSS                    7
+#define SNOC_CNOC_SLV                  8
+#define SLAVE_SNOC_GEM_NOC_GC          9
+#define SLAVE_SNOC_GEM_NOC_SF          10
+#define SLAVE_OCIMEM                   11
+#define SLAVE_PIMEM                    12
+#define SLAVE_SERVICE_SNOC             13
+#define SLAVE_PCIE_0                   14
+#define SLAVE_PCIE_1                   15
+#define SLAVE_PCIE_2                   16
+#define SLAVE_QDSS_STM                 17
+#define SLAVE_TCU                      18
+
+#endif
index ac0c729..dd74503 100644 (file)
@@ -117,11 +117,18 @@ static inline bool bvec_iter_advance(const struct bio_vec *bv,
        return true;
 }
 
+static inline void bvec_iter_skip_zero_bvec(struct bvec_iter *iter)
+{
+       iter->bi_bvec_done = 0;
+       iter->bi_idx++;
+}
+
 #define for_each_bvec(bvl, bio_vec, iter, start)                       \
        for (iter = (start);                                            \
             (iter).bi_size &&                                          \
                ((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
-            bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
+            (bvl).bv_len ? (void)bvec_iter_advance((bio_vec), &(iter), \
+                    (bvl).bv_len) : bvec_iter_skip_zero_bvec(&(iter)))
 
 /* for iterating one bio from start to end */
 #define BVEC_ITER_ALL_INIT (struct bvec_iter)                          \
index fcd84e8..999636d 100644 (file)
 #define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL
 
 #define DEFINE_CEPH_FEATURE(bit, incarnation, name)                    \
-       static const uint64_t CEPH_FEATURE_##name = (1ULL<<bit);                \
-       static const uint64_t CEPH_FEATUREMASK_##name =                 \
+       static const uint64_t __maybe_unused CEPH_FEATURE_##name = (1ULL<<bit);         \
+       static const uint64_t __maybe_unused CEPH_FEATUREMASK_##name =                  \
                (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation);
 
 /* this bit is ignored but still advertised by release *when* */
 #define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \
-       static const uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \
-       static const uint64_t DEPRECATED_CEPH_FEATUREMASK_##name =              \
+       static const uint64_t __maybe_unused DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit);      \
+       static const uint64_t __maybe_unused DEPRECATED_CEPH_FEATUREMASK_##name =               \
                (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation);
 
 /*
index d38c4d7..b354ce5 100644 (file)
@@ -429,11 +429,11 @@ put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
        compat_sigset_t v;
        switch (_NSIG_WORDS) {
        case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
-               /* fall through */
+               fallthrough;
        case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
-               /* fall through */
+               fallthrough;
        case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
-               /* fall through */
+               fallthrough;
        case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
        }
        return copy_to_user(compat, &v, size) ? -EFAULT : 0;
index 6122efd..ea7b756 100644 (file)
 
 /*
  * __has_attribute is supported on gcc >= 5, clang >= 2.9 and icc >= 17.
- * In the meantime, to support 4.6 <= gcc < 5, we implement __has_attribute
+ * In the meantime, to support gcc < 5, we implement __has_attribute
  * by hand.
- *
- * sparse does not support __has_attribute (yet) and defines __GNUC_MINOR__
- * depending on the compiler used to build it; however, these attributes have
- * no semantic effects for sparse, so it does not matter. Also note that,
- * in order to avoid sparse's warnings, even the unsupported ones must be
- * defined to 0.
  */
 #ifndef __has_attribute
 # define __has_attribute(x) __GCC4_has_attribute_##x
index 4b33cb3..6e390d5 100644 (file)
@@ -11,8 +11,8 @@
 # define __iomem       __attribute__((noderef, address_space(__iomem)))
 # define __percpu      __attribute__((noderef, address_space(__percpu)))
 # define __rcu         __attribute__((noderef, address_space(__rcu)))
-extern void __chk_user_ptr(const volatile void __user *);
-extern void __chk_io_ptr(const volatile void __iomem *);
+static inline void __chk_user_ptr(const volatile void __user *ptr) { }
+static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
 /* context/locking */
 # define __must_hold(x)        __attribute__((context(x,1,1)))
 # define __acquires(x) __attribute__((context(x,0,1)))
index 58fffde..7d3c87e 100644 (file)
@@ -208,6 +208,7 @@ struct coresight_device {
        /* sysfs links between components */
        int nr_links;
        bool has_conns_grp;
+       bool ect_enabled; /* true only if associated ect device is enabled */
 };
 
 /*
@@ -324,7 +325,7 @@ struct coresight_ops {
        const struct coresight_ops_ect *ect_ops;
 };
 
-#ifdef CONFIG_CORESIGHT
+#if IS_ENABLED(CONFIG_CORESIGHT)
 extern struct coresight_device *
 coresight_register(struct coresight_desc *desc);
 extern void coresight_unregister(struct coresight_device *csdev);
index 8f141d4..a911e5d 100644 (file)
@@ -956,8 +956,8 @@ static inline int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
        case CPUFREQ_RELATION_C:
                return cpufreq_table_find_index_c(policy, target_freq);
        default:
-               pr_err("%s: Invalid relation: %d\n", __func__, relation);
-               return -EINVAL;
+               WARN_ON_ONCE(1);
+               return 0;
        }
 }
 
index a2710e6..3215023 100644 (file)
@@ -132,6 +132,7 @@ enum cpuhp_state {
        CPUHP_AP_MIPS_GIC_TIMER_STARTING,
        CPUHP_AP_ARC_TIMER_STARTING,
        CPUHP_AP_RISCV_TIMER_STARTING,
+       CPUHP_AP_CLINT_TIMER_STARTING,
        CPUHP_AP_CSKY_TIMER_STARTING,
        CPUHP_AP_HYPERV_TIMER_STARTING,
        CPUHP_AP_KVM_STARTING,
index b65909a..75895e6 100644 (file)
@@ -75,12 +75,13 @@ struct cpuidle_state {
 };
 
 /* Idle State Flags */
-#define CPUIDLE_FLAG_NONE       (0x00)
-#define CPUIDLE_FLAG_POLLING   BIT(0) /* polling state */
-#define CPUIDLE_FLAG_COUPLED   BIT(1) /* state applies to multiple cpus */
-#define CPUIDLE_FLAG_TIMER_STOP BIT(2) /* timer is stopped on this state */
-#define CPUIDLE_FLAG_UNUSABLE  BIT(3) /* avoid using this state */
-#define CPUIDLE_FLAG_OFF       BIT(4) /* disable this state by default */
+#define CPUIDLE_FLAG_NONE              (0x00)
+#define CPUIDLE_FLAG_POLLING           BIT(0) /* polling state */
+#define CPUIDLE_FLAG_COUPLED           BIT(1) /* state applies to multiple cpus */
+#define CPUIDLE_FLAG_TIMER_STOP        BIT(2) /* timer is stopped on this state */
+#define CPUIDLE_FLAG_UNUSABLE          BIT(3) /* avoid using this state */
+#define CPUIDLE_FLAG_OFF               BIT(4) /* disable this state by default */
+#define CPUIDLE_FLAG_TLB_FLUSHED       BIT(5) /* idle-state flushes TLBs */
 
 struct cpuidle_device_kobj;
 struct cpuidle_state_kobj;
index ca18da4..9e6ea89 100644 (file)
@@ -454,6 +454,7 @@ struct dev_links_info {
  * @pm_domain: Provide callbacks that are executed during system suspend,
  *             hibernation, system resume and during runtime PM transitions
  *             along with subsystem-level and driver-level callbacks.
+ * @em_pd:     device's energy model performance domain
  * @pins:      For device pin management.
  *             See Documentation/driver-api/pinctl.rst for details.
  * @msi_list:  Hosts MSI descriptors
index 5a3ce2a..6e87225 100644 (file)
@@ -73,9 +73,6 @@ static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size,
 }
 
 u64 dma_direct_get_required_mask(struct device *dev);
-gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
-                                 u64 *phys_mask);
-bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size);
 void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
                gfp_t gfp, unsigned long attrs);
 void dma_direct_free(struct device *dev, size_t size, void *cpu_addr,
index 016b96b..52635e9 100644 (file)
@@ -522,8 +522,9 @@ void *dma_common_pages_remap(struct page **pages, size_t size,
                        pgprot_t prot, const void *caller);
 void dma_common_free_remap(void *cpu_addr, size_t size);
 
-void *dma_alloc_from_pool(struct device *dev, size_t size,
-                         struct page **ret_page, gfp_t flags);
+struct page *dma_alloc_from_pool(struct device *dev, size_t size,
+               void **cpu_addr, gfp_t flags,
+               bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t));
 bool dma_free_from_pool(struct device *dev, void *start, size_t size);
 
 int
index aa9ff9e..8aa0c7c 100644 (file)
@@ -49,6 +49,10 @@ struct _ddebug {
 
 
 #if defined(CONFIG_DYNAMIC_DEBUG_CORE)
+
+/* exported for module authors to exercise >control */
+int dynamic_debug_exec_queries(const char *query, const char *modname);
+
 int ddebug_add_module(struct _ddebug *tab, unsigned int n,
                                const char *modname);
 extern int ddebug_remove_module(const char *mod_name);
@@ -105,7 +109,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
        static_branch_unlikely(&descriptor.key.dd_key_false)
 #endif
 
-#else /* !HAVE_JUMP_LABEL */
+#else /* !CONFIG_JUMP_LABEL */
 
 #define _DPRINTK_KEY_INIT
 
@@ -117,7 +121,7 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
        unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)
 #endif
 
-#endif
+#endif /* CONFIG_JUMP_LABEL */
 
 #define __dynamic_func_call(id, fmt, func, ...) do {   \
        DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt);         \
@@ -172,10 +176,11 @@ void __dynamic_ibdev_dbg(struct _ddebug *descriptor,
                                   KERN_DEBUG, prefix_str, prefix_type, \
                                   rowsize, groupsize, buf, len, ascii)
 
-#else
+#else /* !CONFIG_DYNAMIC_DEBUG_CORE */
 
 #include <linux/string.h>
 #include <linux/errno.h>
+#include <linux/printk.h>
 
 static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n,
                                    const char *modname)
@@ -210,6 +215,13 @@ static inline int ddebug_dyndbg_module_param_cb(char *param, char *val,
                print_hex_dump(KERN_DEBUG, prefix_str, prefix_type,     \
                                rowsize, groupsize, buf, len, ascii);   \
        } while (0)
-#endif
+
+static inline int dynamic_debug_exec_queries(const char *query, const char *modname)
+{
+       pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n");
+       return 0;
+}
+
+#endif /* !CONFIG_DYNAMIC_DEBUG_CORE */
 
 #endif
index 57eac52..a97a12b 100644 (file)
@@ -8,8 +8,8 @@
 #define EFI_EMBEDDED_FW_PREFIX_LEN             8
 
 /*
- * This struct and efi_embedded_fw_list are private to the efi-embedded fw
- * implementation they are in this header for use by lib/test_firmware.c only!
+ * This struct is private to the efi-embedded fw implementation.
+ * They are in this header for use by lib/test_firmware.c only!
  */
 struct efi_embedded_fw {
        struct list_head list;
@@ -18,8 +18,6 @@ struct efi_embedded_fw {
        size_t length;
 };
 
-extern struct list_head efi_embedded_fw_list;
-
 /**
  * struct efi_embedded_fw_desc - This struct is used by the EFI embedded-fw
  *                               code to search for embedded firmwares.
index efebbff..159c747 100644 (file)
@@ -110,15 +110,30 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
 #endif
 
 /**
- * syscall_enter_from_user_mode - Check and handle work before invoking
- *                              a syscall
+ * syscall_enter_from_user_mode_prepare - Establish state and enable interrupts
  * @regs:      Pointer to currents pt_regs
- * @syscall:   The syscall number
  *
  * Invoked from architecture specific syscall entry code with interrupts
  * disabled. The calling code has to be non-instrumentable. When the
- * function returns all state is correct and the subsequent functions can be
- * instrumented.
+ * function returns all state is correct, interrupts are enabled and the
+ * subsequent functions can be instrumented.
+ *
+ * This handles lockdep, RCU (context tracking) and tracing state.
+ *
+ * This is invoked when there is extra architecture specific functionality
+ * to be done between establishing state and handling user mode entry work.
+ */
+void syscall_enter_from_user_mode_prepare(struct pt_regs *regs);
+
+/**
+ * syscall_enter_from_user_mode_work - Check and handle work before invoking
+ *                                    a syscall
+ * @regs:      Pointer to currents pt_regs
+ * @syscall:   The syscall number
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * enabled after invoking syscall_enter_from_user_mode_prepare() and extra
+ * architecture specific work.
  *
  * Returns: The original or a modified syscall number
  *
@@ -127,12 +142,30 @@ static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs
  * syscall_set_return_value() first.  If neither of those are called and -1
  * is returned, then the syscall will fail with ENOSYS.
  *
- * The following functionality is handled here:
+ * It handles the following work items:
  *
- *  1) Establish state (lockdep, RCU (context tracking), tracing)
- *  2) TIF flag dependent invocations of arch_syscall_enter_tracehook(),
+ *  1) TIF flag dependent invocations of arch_syscall_enter_tracehook(),
  *     __secure_computing(), trace_sys_enter()
- *  3) Invocation of audit_syscall_entry()
+ *  2) Invocation of audit_syscall_entry()
+ */
+long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall);
+
+/**
+ * syscall_enter_from_user_mode - Establish state and check and handle work
+ *                               before invoking a syscall
+ * @regs:      Pointer to currents pt_regs
+ * @syscall:   The syscall number
+ *
+ * Invoked from architecture specific syscall entry code with interrupts
+ * disabled. The calling code has to be non-instrumentable. When the
+ * function returns all state is correct, interrupts are enabled and the
+ * subsequent functions can be instrumented.
+ *
+ * This is combination of syscall_enter_from_user_mode_prepare() and
+ * syscall_enter_from_user_mode_work().
+ *
+ * Returns: The original or a modified syscall number. See
+ * syscall_enter_from_user_mode_work() for further explanation.
  */
 long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall);
 
index 0a355b0..ebfb7cf 100644 (file)
@@ -1200,7 +1200,7 @@ static inline u16 bpf_anc_helper(const struct sock_filter *ftest)
                BPF_ANCILLARY(RANDOM);
                BPF_ANCILLARY(VLAN_TPID);
                }
-               /* Fallthrough. */
+               fallthrough;
        default:
                return ftest->code;
        }
index e019ea2..7519ae0 100644 (file)
@@ -2132,6 +2132,10 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
  *
  * I_DONTCACHE         Evict inode as soon as it is not used anymore.
  *
+ * I_SYNC_QUEUED       Inode is queued in b_io or b_more_io writeback lists.
+ *                     Used to detect that mark_inode_dirty() should not move
+ *                     inode between dirty lists.
+ *
  * Q: What is the difference between I_WILL_FREE and I_FREEING?
  */
 #define I_DIRTY_SYNC           (1 << 0)
@@ -2149,12 +2153,11 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
 #define I_DIO_WAKEUP           (1 << __I_DIO_WAKEUP)
 #define I_LINKABLE             (1 << 10)
 #define I_DIRTY_TIME           (1 << 11)
-#define __I_DIRTY_TIME_EXPIRED 12
-#define I_DIRTY_TIME_EXPIRED   (1 << __I_DIRTY_TIME_EXPIRED)
 #define I_WB_SWITCH            (1 << 13)
 #define I_OVL_INUSE            (1 << 14)
 #define I_CREATING             (1 << 15)
 #define I_DONTCACHE            (1 << 16)
+#define I_SYNC_QUEUED          (1 << 17)
 
 #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
 #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
index 875f711..c7044a1 100644 (file)
@@ -959,34 +959,49 @@ static inline void hid_device_io_stop(struct hid_device *hid) {
  * @max: maximal valid usage->code to consider later (out parameter)
  * @type: input event type (EV_KEY, EV_REL, ...)
  * @c: code which corresponds to this usage and type
+ *
+ * The value pointed to by @bit will be set to NULL if either @type is
+ * an unhandled event type, or if @c is out of range for @type. This
+ * can be used as an error condition.
  */
 static inline void hid_map_usage(struct hid_input *hidinput,
                struct hid_usage *usage, unsigned long **bit, int *max,
-               __u8 type, __u16 c)
+               __u8 type, unsigned int c)
 {
        struct input_dev *input = hidinput->input;
-
-       usage->type = type;
-       usage->code = c;
+       unsigned long *bmap = NULL;
+       unsigned int limit = 0;
 
        switch (type) {
        case EV_ABS:
-               *bit = input->absbit;
-               *max = ABS_MAX;
+               bmap = input->absbit;
+               limit = ABS_MAX;
                break;
        case EV_REL:
-               *bit = input->relbit;
-               *max = REL_MAX;
+               bmap = input->relbit;
+               limit = REL_MAX;
                break;
        case EV_KEY:
-               *bit = input->keybit;
-               *max = KEY_MAX;
+               bmap = input->keybit;
+               limit = KEY_MAX;
                break;
        case EV_LED:
-               *bit = input->ledbit;
-               *max = LED_MAX;
+               bmap = input->ledbit;
+               limit = LED_MAX;
                break;
        }
+
+       if (unlikely(c > limit || !bmap)) {
+               pr_warn_ratelimited("%s: Invalid code %d type %d\n",
+                                   input->name, c, type);
+               *bit = NULL;
+               return;
+       }
+
+       usage->type = type;
+       usage->code = c;
+       *max = limit;
+       *bit = bmap;
 }
 
 /**
@@ -1000,7 +1015,8 @@ static inline void hid_map_usage_clear(struct hid_input *hidinput,
                __u8 type, __u16 c)
 {
        hid_map_usage(hidinput, usage, bit, max, type, c);
-       clear_bit(c, *bit);
+       if (*bit)
+               clear_bit(usage->code, *bit);
 }
 
 /**
index d030717..7c522fd 100644 (file)
 #define I2C_PCA_CON_SI         0x08 /* Serial Interrupt */
 #define I2C_PCA_CON_CR         0x07 /* Clock Rate (MASK) */
 
+/**
+ * struct pca_i2c_bus_settings - The configured PCA i2c bus settings
+ * @mode: Configured i2c bus mode
+ * @tlow: Configured SCL LOW period
+ * @thi: Configured SCL HIGH period
+ * @clock_freq: The configured clock frequency
+ */
+struct pca_i2c_bus_settings {
+       int mode;
+       int tlow;
+       int thi;
+       int clock_freq;
+};
+
 struct i2c_algo_pca_data {
        void                            *data;  /* private low level data */
        void (*write_byte)              (void *data, int reg, int val);
@@ -64,6 +78,7 @@ struct i2c_algo_pca_data {
         * For PCA9665, use the frequency you want here. */
        unsigned int                    i2c_clock;
        unsigned int                    chip;
+       struct pca_i2c_bus_settings             bus_settings;
 };
 
 int i2c_pca_add_bus(struct i2c_adapter *);
index 4735518..6bd01f7 100644 (file)
 struct icc_node;
 struct of_phandle_args;
 
+/**
+ * struct icc_node_data - icc node data
+ *
+ * @node: icc node
+ * @tag: tag
+ */
+struct icc_node_data {
+       struct icc_node *node;
+       u32 tag;
+};
+
 /**
  * struct icc_onecell_data - driver data for onecell interconnect providers
  *
@@ -38,7 +49,9 @@ struct icc_node *of_icc_xlate_onecell(struct of_phandle_args *spec,
  * @aggregate: pointer to device specific aggregate operation function
  * @pre_aggregate: pointer to device specific function that is called
  *                before the aggregation begins (optional)
+ * @get_bw: pointer to device specific function to get current bandwidth
  * @xlate: provider-specific callback for mapping nodes from phandle arguments
+ * @xlate_extended: vendor-specific callback for mapping node data from phandle arguments
  * @dev: the device this interconnect provider belongs to
  * @users: count of active users
  * @inter_set: whether inter-provider pairs will be configured with @set
@@ -51,7 +64,9 @@ struct icc_provider {
        int (*aggregate)(struct icc_node *node, u32 tag, u32 avg_bw,
                         u32 peak_bw, u32 *agg_avg, u32 *agg_peak);
        void (*pre_aggregate)(struct icc_node *node);
+       int (*get_bw)(struct icc_node *node, u32 *avg, u32 *peak);
        struct icc_node* (*xlate)(struct of_phandle_args *spec, void *data);
+       struct icc_node_data* (*xlate_extended)(struct of_phandle_args *spec, void *data);
        struct device           *dev;
        int                     users;
        bool                    inter_set;
@@ -73,6 +88,8 @@ struct icc_provider {
  * @req_list: a list of QoS constraint requests associated with this node
  * @avg_bw: aggregated value of average bandwidth requests from all consumers
  * @peak_bw: aggregated value of peak bandwidth requests from all consumers
+ * @init_avg: average bandwidth value that is read from the hardware during init
+ * @init_peak: peak bandwidth value that is read from the hardware during init
  * @data: pointer to private data
  */
 struct icc_node {
@@ -89,6 +106,8 @@ struct icc_node {
        struct hlist_head       req_list;
        u32                     avg_bw;
        u32                     peak_bw;
+       u32                     init_avg;
+       u32                     init_peak;
        void                    *data;
 };
 
@@ -105,7 +124,8 @@ void icc_node_del(struct icc_node *node);
 int icc_nodes_remove(struct icc_provider *provider);
 int icc_provider_add(struct icc_provider *provider);
 int icc_provider_del(struct icc_provider *provider);
-struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec);
+struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec);
+void icc_sync_state(struct device *dev);
 
 #else
 
@@ -157,7 +177,7 @@ static inline int icc_provider_del(struct icc_provider *provider)
        return -ENOTSUPP;
 }
 
-static inline struct icc_node *of_icc_get_from_provider(struct of_phandle_args *spec)
+static inline struct icc_node_data *of_icc_get_from_provider(struct of_phandle_args *spec)
 {
        return ERR_PTR(-ENOTSUPP);
 }
index 3a63d98..f2dd2fc 100644 (file)
 struct icc_path;
 struct device;
 
+/**
+ * struct icc_bulk_data - Data used for bulk icc operations.
+ *
+ * @path: reference to the interconnect path (internal use)
+ * @name: the name from the "interconnect-names" DT property
+ * @avg_bw: average bandwidth in icc units
+ * @peak_bw: peak bandwidth in icc units
+ */
+struct icc_bulk_data {
+       struct icc_path *path;
+       const char *name;
+       u32 avg_bw;
+       u32 peak_bw;
+};
+
+int __must_check of_icc_bulk_get(struct device *dev, int num_paths,
+                                struct icc_bulk_data *paths);
+void icc_bulk_put(int num_paths, struct icc_bulk_data *paths);
+int icc_bulk_set_bw(int num_paths, const struct icc_bulk_data *paths);
+int icc_bulk_enable(int num_paths, const struct icc_bulk_data *paths);
+void icc_bulk_disable(int num_paths, const struct icc_bulk_data *paths);
+
 #if IS_ENABLED(CONFIG_INTERCONNECT)
 
 struct icc_path *icc_get(struct device *dev, const int src_id,
index bd5c557..3ed4e87 100644 (file)
@@ -49,17 +49,18 @@ struct irqtrace_events {
 DECLARE_PER_CPU(int, hardirqs_enabled);
 DECLARE_PER_CPU(int, hardirq_context);
 
-  extern void trace_hardirqs_on_prepare(void);
-  extern void trace_hardirqs_off_finish(void);
-  extern void trace_hardirqs_on(void);
-  extern void trace_hardirqs_off(void);
-# define lockdep_hardirq_context()     (this_cpu_read(hardirq_context))
+extern void trace_hardirqs_on_prepare(void);
+extern void trace_hardirqs_off_finish(void);
+extern void trace_hardirqs_on(void);
+extern void trace_hardirqs_off(void);
+
+# define lockdep_hardirq_context()     (raw_cpu_read(hardirq_context))
 # define lockdep_softirq_context(p)    ((p)->softirq_context)
 # define lockdep_hardirqs_enabled()    (this_cpu_read(hardirqs_enabled))
 # define lockdep_softirqs_enabled(p)   ((p)->softirqs_enabled)
 # define lockdep_hardirq_enter()                       \
 do {                                                   \
-       if (this_cpu_inc_return(hardirq_context) == 1)  \
+       if (__this_cpu_inc_return(hardirq_context) == 1)\
                current->hardirq_threaded = 0;          \
 } while (0)
 # define lockdep_hardirq_threaded()            \
@@ -68,7 +69,7 @@ do {                                          \
 } while (0)
 # define lockdep_hardirq_exit()                        \
 do {                                           \
-       this_cpu_dec(hardirq_context);          \
+       __this_cpu_dec(hardirq_context);        \
 } while (0)
 # define lockdep_softirq_enter()               \
 do {                                           \
@@ -120,17 +121,17 @@ do {                                              \
 #else
 # define trace_hardirqs_on_prepare()           do { } while (0)
 # define trace_hardirqs_off_finish()           do { } while (0)
-# define trace_hardirqs_on()           do { } while (0)
-# define trace_hardirqs_off()          do { } while (0)
-# define lockdep_hardirq_context()     0
-# define lockdep_softirq_context(p)    0
-# define lockdep_hardirqs_enabled()    0
-# define lockdep_softirqs_enabled(p)   0
-# define lockdep_hardirq_enter()       do { } while (0)
-# define lockdep_hardirq_threaded()    do { } while (0)
-# define lockdep_hardirq_exit()                do { } while (0)
-# define lockdep_softirq_enter()       do { } while (0)
-# define lockdep_softirq_exit()                do { } while (0)
+# define trace_hardirqs_on()                   do { } while (0)
+# define trace_hardirqs_off()                  do { } while (0)
+# define lockdep_hardirq_context()             0
+# define lockdep_softirq_context(p)            0
+# define lockdep_hardirqs_enabled()            0
+# define lockdep_softirqs_enabled(p)           0
+# define lockdep_hardirq_enter()               do { } while (0)
+# define lockdep_hardirq_threaded()            do { } while (0)
+# define lockdep_hardirq_exit()                        do { } while (0)
+# define lockdep_softirq_enter()               do { } while (0)
+# define lockdep_softirq_exit()                        do { } while (0)
 # define lockdep_hrtimer_enter(__hrtimer)      false
 # define lockdep_hrtimer_exit(__context)       do { } while (0)
 # define lockdep_posixtimer_enter()            do { } while (0)
@@ -181,26 +182,33 @@ do {                                              \
  * if !TRACE_IRQFLAGS.
  */
 #ifdef CONFIG_TRACE_IRQFLAGS
-#define local_irq_enable() \
-       do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
-#define local_irq_disable() \
-       do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
+
+#define local_irq_enable()                             \
+       do {                                            \
+               trace_hardirqs_on();                    \
+               raw_local_irq_enable();                 \
+       } while (0)
+
+#define local_irq_disable()                            \
+       do {                                            \
+               bool was_disabled = raw_irqs_disabled();\
+               raw_local_irq_disable();                \
+               if (!was_disabled)                      \
+                       trace_hardirqs_off();           \
+       } while (0)
+
 #define local_irq_save(flags)                          \
        do {                                            \
                raw_local_irq_save(flags);              \
-               trace_hardirqs_off();                   \
+               if (!raw_irqs_disabled_flags(flags))    \
+                       trace_hardirqs_off();           \
        } while (0)
 
-
 #define local_irq_restore(flags)                       \
        do {                                            \
-               if (raw_irqs_disabled_flags(flags)) {   \
-                       raw_local_irq_restore(flags);   \
-                       trace_hardirqs_off();           \
-               } else {                                \
+               if (!raw_irqs_disabled_flags(flags))    \
                        trace_hardirqs_on();            \
-                       raw_local_irq_restore(flags);   \
-               }                                       \
+               raw_local_irq_restore(flags);           \
        } while (0)
 
 #define safe_halt()                            \
@@ -214,10 +222,7 @@ do {                                               \
 
 #define local_irq_enable()     do { raw_local_irq_enable(); } while (0)
 #define local_irq_disable()    do { raw_local_irq_disable(); } while (0)
-#define local_irq_save(flags)                                  \
-       do {                                                    \
-               raw_local_irq_save(flags);                      \
-       } while (0)
+#define local_irq_save(flags)  do { raw_local_irq_save(flags); } while (0)
 #define local_irq_restore(flags) do { raw_local_irq_restore(flags); } while (0)
 #define safe_halt()            do { raw_safe_halt(); } while (0)
 
index 4aaa297..08f9049 100644 (file)
@@ -1381,7 +1381,7 @@ extern int         jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *);
 extern int      jbd2_journal_forget (handle_t *, struct buffer_head *);
 extern int      jbd2_journal_invalidatepage(journal_t *,
                                struct page *, unsigned int, unsigned int);
-extern int      jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t);
+extern int      jbd2_journal_try_to_free_buffers(journal_t *journal, struct page *page);
 extern int      jbd2_journal_stop(handle_t *);
 extern int      jbd2_journal_flush (journal_t *);
 extern void     jbd2_journal_lock_updates (journal_t *);
index 19ddd43..cfb62e9 100644 (file)
@@ -86,17 +86,17 @@ static inline u32 jhash(const void *key, u32 length, u32 initval)
        }
        /* Last block: affect all 32 bits of (c) */
        switch (length) {
-       case 12: c += (u32)k[11]<<24;   /* fall through */
-       case 11: c += (u32)k[10]<<16;   /* fall through */
-       case 10: c += (u32)k[9]<<8;     /* fall through */
-       case 9:  c += k[8];             /* fall through */
-       case 8:  b += (u32)k[7]<<24;    /* fall through */
-       case 7:  b += (u32)k[6]<<16;    /* fall through */
-       case 6:  b += (u32)k[5]<<8;     /* fall through */
-       case 5:  b += k[4];             /* fall through */
-       case 4:  a += (u32)k[3]<<24;    /* fall through */
-       case 3:  a += (u32)k[2]<<16;    /* fall through */
-       case 2:  a += (u32)k[1]<<8;     /* fall through */
+       case 12: c += (u32)k[11]<<24;   fallthrough;
+       case 11: c += (u32)k[10]<<16;   fallthrough;
+       case 10: c += (u32)k[9]<<8;     fallthrough;
+       case 9:  c += k[8];             fallthrough;
+       case 8:  b += (u32)k[7]<<24;    fallthrough;
+       case 7:  b += (u32)k[6]<<16;    fallthrough;
+       case 6:  b += (u32)k[5]<<8;     fallthrough;
+       case 5:  b += k[4];             fallthrough;
+       case 4:  a += (u32)k[3]<<24;    fallthrough;
+       case 3:  a += (u32)k[2]<<16;    fallthrough;
+       case 2:  a += (u32)k[1]<<8;     fallthrough;
        case 1:  a += k[0];
                 __jhash_final(a, b, c);
        case 0: /* Nothing left to add */
@@ -132,8 +132,8 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval)
 
        /* Handle the last 3 u32's */
        switch (length) {
-       case 3: c += k[2];      /* fall through */
-       case 2: b += k[1];      /* fall through */
+       case 3: c += k[2];      fallthrough;
+       case 2: b += k[1];      fallthrough;
        case 1: a += k[0];
                __jhash_final(a, b, c);
        case 0: /* Nothing left to add */
index 500def6..c25b8e4 100644 (file)
  * lower_32_bits - return bits 0-31 of a number
  * @n: the number we're accessing
  */
-#define lower_32_bits(n) ((u32)(n))
+#define lower_32_bits(n) ((u32)((n) & 0xffffffff))
 
 struct completion;
 struct pt_regs;
index e48b1e4..161e816 100644 (file)
@@ -53,8 +53,6 @@ struct page *ksm_might_need_to_copy(struct page *page,
 
 void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc);
 void ksm_migrate_page(struct page *newpage, struct page *oldpage);
-bool reuse_ksm_page(struct page *page,
-                       struct vm_area_struct *vma, unsigned long address);
 
 #else  /* !CONFIG_KSM */
 
@@ -88,11 +86,6 @@ static inline void rmap_walk_ksm(struct page *page,
 static inline void ksm_migrate_page(struct page *newpage, struct page *oldpage)
 {
 }
-static inline bool reuse_ksm_page(struct page *page,
-                       struct vm_area_struct *vma, unsigned long address)
-{
-       return false;
-}
 #endif /* CONFIG_MMU */
 #endif /* !CONFIG_KSM */
 
index a230767..05e3c2f 100644 (file)
@@ -749,25 +749,46 @@ int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
 int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
                              gpa_t gpa, unsigned long len);
 
-#define __kvm_put_guest(kvm, gfn, offset, value, type)                 \
+#define __kvm_get_guest(kvm, gfn, offset, v)                           \
 ({                                                                     \
        unsigned long __addr = gfn_to_hva(kvm, gfn);                    \
-       type __user *__uaddr = (type __user *)(__addr + offset);        \
+       typeof(v) __user *__uaddr = (typeof(__uaddr))(__addr + offset); \
        int __ret = -EFAULT;                                            \
                                                                        \
        if (!kvm_is_error_hva(__addr))                                  \
-               __ret = put_user(value, __uaddr);                       \
+               __ret = get_user(v, __uaddr);                           \
+       __ret;                                                          \
+})
+
+#define kvm_get_guest(kvm, gpa, v)                                     \
+({                                                                     \
+       gpa_t __gpa = gpa;                                              \
+       struct kvm *__kvm = kvm;                                        \
+                                                                       \
+       __kvm_get_guest(__kvm, __gpa >> PAGE_SHIFT,                     \
+                       offset_in_page(__gpa), v);                      \
+})
+
+#define __kvm_put_guest(kvm, gfn, offset, v)                           \
+({                                                                     \
+       unsigned long __addr = gfn_to_hva(kvm, gfn);                    \
+       typeof(v) __user *__uaddr = (typeof(__uaddr))(__addr + offset); \
+       int __ret = -EFAULT;                                            \
+                                                                       \
+       if (!kvm_is_error_hva(__addr))                                  \
+               __ret = put_user(v, __uaddr);                           \
        if (!__ret)                                                     \
                mark_page_dirty(kvm, gfn);                              \
        __ret;                                                          \
 })
 
-#define kvm_put_guest(kvm, gpa, value, type)                           \
+#define kvm_put_guest(kvm, gpa, v)                                     \
 ({                                                                     \
        gpa_t __gpa = gpa;                                              \
        struct kvm *__kvm = kvm;                                        \
+                                                                       \
        __kvm_put_guest(__kvm, __gpa >> PAGE_SHIFT,                     \
-                       offset_in_page(__gpa), (value), type);          \
+                       offset_in_page(__gpa), v);                      \
 })
 
 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
index 77ccf04..5f550eb 100644 (file)
@@ -421,6 +421,7 @@ enum {
        ATA_HORKAGE_NO_DMA_LOG  = (1 << 23),    /* don't use DMA for log read */
        ATA_HORKAGE_NOTRIM      = (1 << 24),    /* don't use TRIM */
        ATA_HORKAGE_MAX_SEC_1024 = (1 << 25),   /* Limit max sects to 1024 */
+       ATA_HORKAGE_MAX_TRIM_128M = (1 << 26),  /* Limit max trim size to 128M */
 
         /* DMA mask for user DMA control: User visible values; DO NOT
            renumber */
index 62a382d..6a584b3 100644 (file)
@@ -535,19 +535,27 @@ do {                                                                      \
 DECLARE_PER_CPU(int, hardirqs_enabled);
 DECLARE_PER_CPU(int, hardirq_context);
 
+/*
+ * The below lockdep_assert_*() macros use raw_cpu_read() to access the above
+ * per-cpu variables. This is required because this_cpu_read() will potentially
+ * call into preempt/irq-disable and that obviously isn't right. This is also
+ * correct because when IRQs are enabled, it doesn't matter if we accidentally
+ * read the value from our previous CPU.
+ */
+
 #define lockdep_assert_irqs_enabled()                                  \
 do {                                                                   \
-       WARN_ON_ONCE(debug_locks && !this_cpu_read(hardirqs_enabled));  \
+       WARN_ON_ONCE(debug_locks && !raw_cpu_read(hardirqs_enabled));   \
 } while (0)
 
 #define lockdep_assert_irqs_disabled()                                 \
 do {                                                                   \
-       WARN_ON_ONCE(debug_locks && this_cpu_read(hardirqs_enabled));   \
+       WARN_ON_ONCE(debug_locks && raw_cpu_read(hardirqs_enabled));    \
 } while (0)
 
 #define lockdep_assert_in_irq()                                                \
 do {                                                                   \
-       WARN_ON_ONCE(debug_locks && !this_cpu_read(hardirq_context));   \
+       WARN_ON_ONCE(debug_locks && !raw_cpu_read(hardirq_context));    \
 } while (0)
 
 #define lockdep_assert_preemption_enabled()                            \
@@ -555,7 +563,7 @@ do {                                                                        \
        WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT)   &&              \
                     debug_locks                        &&              \
                     (preempt_count() != 0              ||              \
-                     !this_cpu_read(hardirqs_enabled)));               \
+                     !raw_cpu_read(hardirqs_enabled)));                \
 } while (0)
 
 #define lockdep_assert_preemption_disabled()                           \
@@ -563,7 +571,7 @@ do {                                                                        \
        WARN_ON_ONCE(IS_ENABLED(CONFIG_PREEMPT_COUNT)   &&              \
                     debug_locks                        &&              \
                     (preempt_count() == 0              &&              \
-                     this_cpu_read(hardirqs_enabled)));                \
+                     raw_cpu_read(hardirqs_enabled)));                 \
 } while (0)
 
 #else
index 83a4a3c..c619ec6 100644 (file)
@@ -173,7 +173,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)
 #define roundup_pow_of_two(n)                  \
 (                                              \
        __builtin_constant_p(n) ? (             \
-               (n == 1) ? 1 :                  \
+               ((n) == 1) ? 1 :                \
                (1UL << (ilog2((n) - 1) + 1))   \
                                   ) :          \
        __roundup_pow_of_two(n)                 \
index 5f5b2df..e586274 100644 (file)
@@ -46,11 +46,10 @@ struct vmem_altmap {
  * wakeup is used to coordinate physical address space management (ex:
  * fs truncate/hole punch) vs pinned pages (ex: device dma).
  *
- * MEMORY_DEVICE_DEVDAX:
+ * MEMORY_DEVICE_GENERIC:
  * Host memory that has similar access semantics as System RAM i.e. DMA
- * coherent and supports page pinning. In contrast to
- * MEMORY_DEVICE_FS_DAX, this memory is access via a device-dax
- * character device.
+ * coherent and supports page pinning. This is for example used by DAX devices
+ * that expose memory using a character device.
  *
  * MEMORY_DEVICE_PCI_P2PDMA:
  * Device memory residing in a PCI BAR intended for use with Peer-to-Peer
@@ -60,7 +59,7 @@ enum memory_type {
        /* 0 is reserved to catch uninitialized type fields */
        MEMORY_DEVICE_PRIVATE = 1,
        MEMORY_DEVICE_FS_DAX,
-       MEMORY_DEVICE_DEVDAX,
+       MEMORY_DEVICE_GENERIC,
        MEMORY_DEVICE_PCI_P2PDMA,
 };
 
index c7a9300..0676f18 100644 (file)
@@ -7,9 +7,9 @@
 #include <linux/device.h>
 
 /*
- *     These allocations are managed by device@lanana.org. If you use an
- *     entry that is not in assigned your entry may well be moved and
- *     reassigned, or set dynamic if a fixed value is not justified.
+ *     These allocations are managed by device@lanana.org. If you need
+ *     an entry that is not assigned here, it can be moved and
+ *     reassigned or dynamically set if a fixed value is not justified.
  */
 
 #define PSMOUSE_MINOR          1
@@ -93,14 +93,14 @@ extern void misc_deregister(struct miscdevice *misc);
 
 /*
  * Helper macro for drivers that don't do anything special in the initcall.
- * This helps in eleminating of boilerplate code.
+ * This helps to eliminate boilerplate code.
  */
 #define builtin_misc_device(__misc_device) \
        builtin_driver(__misc_device, misc_register)
 
 /*
  * Helper macro for drivers that don't do anything special in module init / exit
- * call. This helps in eleminating of boilerplate code.
+ * call. This helps to eliminate boilerplate code.
  */
 #define module_misc_device(__misc_device) \
        module_driver(__misc_device, misc_register, misc_deregister)
index 1983e08..ca6e6a8 100644 (file)
@@ -157,11 +157,14 @@ static inline void __mm_zero_struct_page(struct page *page)
 
        switch (sizeof(struct page)) {
        case 80:
-               _pp[9] = 0;     /* fallthrough */
+               _pp[9] = 0;
+               fallthrough;
        case 72:
-               _pp[8] = 0;     /* fallthrough */
+               _pp[8] = 0;
+               fallthrough;
        case 64:
-               _pp[7] = 0;     /* fallthrough */
+               _pp[7] = 0;
+               fallthrough;
        case 56:
                _pp[6] = 0;
                _pp[5] = 0;
@@ -321,6 +324,8 @@ extern unsigned int kobjsize(const void *objp);
 
 #if defined(CONFIG_X86)
 # define VM_PAT                VM_ARCH_1       /* PAT reserves whole VMA at once (x86) */
+#elif defined(CONFIG_PPC)
+# define VM_SAO                VM_ARCH_1       /* Strong Access Ordering (powerpc) */
 #elif defined(CONFIG_PARISC)
 # define VM_GROWSUP    VM_ARCH_1
 #elif defined(CONFIG_IA64)
index c51a841..03dee12 100644 (file)
@@ -3,10 +3,15 @@
 #define _LINUX_MMU_CONTEXT_H
 
 #include <asm/mmu_context.h>
+#include <asm/mmu.h>
 
 /* Architectures that care about IRQ state in switch_mm can override this. */
 #ifndef switch_mm_irqs_off
 # define switch_mm_irqs_off switch_mm
 #endif
 
+#ifndef leave_mm
+static inline void leave_mm(int cpu) { }
+#endif
+
 #endif
index 9a33f17..625f491 100644 (file)
@@ -9,6 +9,8 @@ struct ip_ct_sctp {
        enum sctp_conntrack state;
 
        __be32 vtag[IP_CT_DIR_MAX];
+       u8 last_dir;
+       u8 flags;
 };
 
 #endif /* _NF_CONNTRACK_SCTP_H */
index 851425c..89016d0 100644 (file)
@@ -43,8 +43,7 @@ int nfnetlink_has_listeners(struct net *net, unsigned int group);
 int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 portid,
                   unsigned int group, int echo, gfp_t flags);
 int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error);
-int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
-                     int flags);
+int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid);
 
 static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type)
 {
index aac42c2..9b67394 100644 (file)
@@ -58,7 +58,6 @@ struct nf_ipv6_ops {
                        int (*output)(struct net *, struct sock *, struct sk_buff *));
        int (*reroute)(struct sk_buff *skb, const struct nf_queue_entry *entry);
 #if IS_MODULE(CONFIG_IPV6)
-       int (*br_defrag)(struct net *net, struct sk_buff *skb, u32 user);
        int (*br_fragment)(struct net *net, struct sock *sk,
                           struct sk_buff *skb,
                           struct nf_bridge_frag_data *data,
@@ -117,23 +116,6 @@ static inline int nf_ip6_route(struct net *net, struct dst_entry **dst,
 
 #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
 
-static inline int nf_ipv6_br_defrag(struct net *net, struct sk_buff *skb,
-                                   u32 user)
-{
-#if IS_MODULE(CONFIG_IPV6)
-       const struct nf_ipv6_ops *v6_ops = nf_get_ipv6_ops();
-
-       if (!v6_ops)
-               return 1;
-
-       return v6_ops->br_defrag(net, skb, user);
-#elif IS_BUILTIN(CONFIG_IPV6)
-       return nf_ct_frag6_gather(net, skb, user);
-#else
-       return 1;
-#endif
-}
-
 int br_ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
                    struct nf_bridge_frag_data *data,
                    int (*output)(struct net *, struct sock *sk,
diff --git a/include/linux/nitro_enclaves.h b/include/linux/nitro_enclaves.h
new file mode 100644 (file)
index 0000000..d91ef2b
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _LINUX_NITRO_ENCLAVES_H_
+#define _LINUX_NITRO_ENCLAVES_H_
+
+#include <uapi/linux/nitro_enclaves.h>
+
+#endif /* _LINUX_NITRO_ENCLAVES_H_ */
index a124c21..e8cbc2e 100644 (file)
@@ -117,7 +117,9 @@ static inline pgd_t *pgd_offset_pgd(pgd_t *pgd, unsigned long address)
  * a shortcut which implies the use of the kernel's pgd, instead
  * of a process's
  */
+#ifndef pgd_offset_k
 #define pgd_offset_k(address)          pgd_offset(&init_mm, (address))
+#endif
 
 /*
  * In many cases it is known that a virtual address is mapped at PMD or PTE
index a8e8763..c36fb41 100644 (file)
@@ -402,7 +402,8 @@ void pcs_get_state(struct phylink_pcs *pcs,
  * For most 10GBASE-R, there is no advertisement.
  */
 int pcs_config(struct phylink_pcs *pcs, unsigned int mode,
-              phy_interface_t interface, const unsigned long *advertising);
+              phy_interface_t interface, const unsigned long *advertising,
+              bool permit_pause_to_mac);
 
 /**
  * pcs_an_restart() - restart 802.3z BaseX autonegotiation
index 4537f57..3d557bb 100644 (file)
@@ -44,19 +44,18 @@ struct powercap_control_type_ops {
 };
 
 /**
- * struct powercap_control_type- Defines a powercap control_type
- * @name:              name of control_type
+ * struct powercap_control_type - Defines a powercap control_type
  * @dev:               device for this control_type
  * @idr:               idr to have unique id for its child
- * @root_node:         Root holding power zones for this control_type
+ * @nr_zones:          counter for number of zones of this type
  * @ops:               Pointer to callback struct
- * @node_lock:         mutex for control type
+ * @lock:              mutex for control type
  * @allocated:         This is possible that client owns the memory
  *                     used by this structure. In this case
  *                     this flag is set to false by framework to
  *                     prevent deallocation during release process.
  *                     Otherwise this flag is set to true.
- * @ctrl_inst:         link to the control_type list
+ * @node:              linked-list node
  *
  * Defines powercap control_type. This acts as a container for power
  * zones, which use same method to control power. E.g. RAPL, RAPL-PCI etc.
@@ -129,7 +128,7 @@ struct powercap_zone_ops {
  *                     this flag is set to false by framework to
  *                     prevent deallocation during release process.
  *                     Otherwise this flag is set to true.
- * @constraint_ptr:    List of constraints for this zone.
+ * @constraints:       List of constraints for this zone.
  *
  * This defines a power zone instance. The fields of this structure are
  * private, and should not be used by client drivers.
index 93ecd93..afe01e2 100644 (file)
@@ -1666,7 +1666,7 @@ extern struct task_struct *idle_task(int cpu);
  *
  * Return: 1 if @p is an idle task. 0 otherwise.
  */
-static inline bool is_idle_task(const struct task_struct *p)
+static __always_inline bool is_idle_task(const struct task_struct *p)
 {
        return !!(p->flags & PF_IDLE);
 }
index 917d88e..a8ec3b6 100644 (file)
@@ -36,6 +36,9 @@ struct user_struct {
     defined(CONFIG_NET) || defined(CONFIG_IO_URING)
        atomic_long_t locked_vm;
 #endif
+#ifdef CONFIG_WATCH_QUEUE
+       atomic_t nr_watches;    /* The number of watches this user currently has */
+#endif
 
        /* Miscellaneous per-user rate limit */
        struct ratelimit_state ratelimit;
index 6bb1a3f..7bbc0e9 100644 (file)
@@ -137,11 +137,11 @@ static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
                b3 = b->sig[3]; b2 = b->sig[2];                         \
                r->sig[3] = op(a3, b3);                                 \
                r->sig[2] = op(a2, b2);                                 \
-               /* fall through */                                      \
+               fallthrough;                                            \
        case 2:                                                         \
                a1 = a->sig[1]; b1 = b->sig[1];                         \
                r->sig[1] = op(a1, b1);                                 \
-               /* fall through */                                      \
+               fallthrough;                                            \
        case 1:                                                         \
                a0 = a->sig[0]; b0 = b->sig[0];                         \
                r->sig[0] = op(a0, b0);                                 \
@@ -171,9 +171,9 @@ static inline void name(sigset_t *set)                                      \
        switch (_NSIG_WORDS) {                                          \
        case 4: set->sig[3] = op(set->sig[3]);                          \
                set->sig[2] = op(set->sig[2]);                          \
-               /* fall through */                                      \
+               fallthrough;                                            \
        case 2: set->sig[1] = op(set->sig[1]);                          \
-               /* fall through */                                      \
+               fallthrough;                                            \
        case 1: set->sig[0] = op(set->sig[0]);                          \
                    break;                                              \
        default:                                                        \
@@ -194,7 +194,7 @@ static inline void sigemptyset(sigset_t *set)
                memset(set, 0, sizeof(sigset_t));
                break;
        case 2: set->sig[1] = 0;
-               /* fall through */
+               fallthrough;
        case 1: set->sig[0] = 0;
                break;
        }
@@ -207,7 +207,7 @@ static inline void sigfillset(sigset_t *set)
                memset(set, -1, sizeof(sigset_t));
                break;
        case 2: set->sig[1] = -1;
-               /* fall through */
+               fallthrough;
        case 1: set->sig[0] = -1;
                break;
        }
index 46881d9..ed9bea9 100644 (file)
@@ -71,7 +71,7 @@
  *     NETIF_F_IPV6_CSUM - Driver (device) is only able to checksum plain
  *                       TCP or UDP packets over IPv6. These are specifically
  *                       unencapsulated packets of the form IPv6|TCP or
- *                       IPv4|UDP where the Next Header field in the IPv6
+ *                       IPv6|UDP where the Next Header field in the IPv6
  *                       header is either TCP or UDP. IPv6 extension headers
  *                       are not supported with this feature. This feature
  *                       cannot be set in features for a device with
@@ -1056,7 +1056,16 @@ void kfree_skb(struct sk_buff *skb);
 void kfree_skb_list(struct sk_buff *segs);
 void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
 void skb_tx_error(struct sk_buff *skb);
+
+#ifdef CONFIG_TRACEPOINTS
 void consume_skb(struct sk_buff *skb);
+#else
+static inline void consume_skb(struct sk_buff *skb)
+{
+       return kfree_skb(skb);
+}
+#endif
+
 void __consume_stateless_skb(struct sk_buff *skb);
 void  __kfree_skb(struct sk_buff *skb);
 extern struct kmem_cache *skbuff_head_cache;
@@ -2658,7 +2667,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
  *
  * Using max(32, L1_CACHE_BYTES) makes sense (especially with RPS)
  * to reduce average number of cache lines per packet.
- * get_rps_cpus() for example only access one 64 bytes aligned block :
+ * get_rps_cpu() for example only access one 64 bytes aligned block :
  * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
  */
 #ifndef NET_SKB_PAD
@@ -3745,19 +3754,19 @@ static inline bool __skb_metadata_differs(const struct sk_buff *skb_a,
 #define __it(x, op) (x -= sizeof(u##op))
 #define __it_diff(a, b, op) (*(u##op *)__it(a, op)) ^ (*(u##op *)__it(b, op))
        case 32: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case 24: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case 16: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case  8: diffs |= __it_diff(a, b, 64);
                break;
        case 28: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case 20: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case 12: diffs |= __it_diff(a, b, 64);
-                /* fall through */
+               fallthrough;
        case  4: diffs |= __it_diff(a, b, 32);
                break;
        }
index 49c5d29..cf27b08 100644 (file)
@@ -220,6 +220,9 @@ struct ti_sci_rm_core_ops {
                                    u16 *range_start, u16 *range_num);
 };
 
+#define TI_SCI_RESASG_SUBTYPE_IR_OUTPUT                0
+#define TI_SCI_RESASG_SUBTYPE_IA_VINT          0xa
+#define TI_SCI_RESASG_SUBTYPE_GLOBAL_EVENT_SEVT        0xd
 /**
  * struct ti_sci_rm_irq_ops: IRQ management operations
  * @set_irq:           Set an IRQ route between the requested source
@@ -556,6 +559,9 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res);
 struct ti_sci_resource *
 devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
                            struct device *dev, u32 dev_id, char *of_prop);
+struct ti_sci_resource *
+devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
+                        u32 dev_id, u32 sub_type);
 
 #else  /* CONFIG_TI_SCI_PROTOCOL */
 
@@ -609,6 +615,13 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle,
 {
        return ERR_PTR(-EINVAL);
 }
+
+static inline struct ti_sci_resource *
+devm_ti_sci_get_resource(const struct ti_sci_handle *handle, struct device *dev,
+                        u32 dev_id, u32 sub_type);
+{
+       return ERR_PTR(-EINVAL);
+}
 #endif /* CONFIG_TI_SCI_PROTOCOL */
 
 #endif /* __TISCI_PROTOCOL_H */
index aceccf9..1cca3dd 100644 (file)
@@ -14,7 +14,7 @@
 struct spi_eeprom {
        u32             byte_len;
        char            name[10];
-       u16             page_size;              /* for writes */
+       u32             page_size;              /* for writes */
        u16             flags;
 #define        EE_ADDR1        0x0001                  /*  8 bit addrs */
 #define        EE_ADDR2        0x0002                  /* 16 bit addrs */
index 2e6ca53..18e7597 100644 (file)
@@ -30,6 +30,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                PGFAULT, PGMAJFAULT,
                PGLAZYFREED,
                PGREFILL,
+               PGREUSE,
                PGSTEAL_KSWAPD,
                PGSTEAL_DIRECT,
                PGSCAN_KSWAPD,
index adcc6a9..143568d 100644 (file)
@@ -308,7 +308,7 @@ do {                                                                             \
                                                                             \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO):                          \
     R##_e = X##_e;                                                          \
-         /* Fall through */                                                 \
+       fallthrough;                                                         \
   case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NORMAL):                           \
   case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF):                              \
   case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO):                                     \
@@ -319,7 +319,7 @@ do {                                                                             \
                                                                             \
   case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NORMAL):                          \
     R##_e = Y##_e;                                                          \
-         /* Fall through */                                                 \
+       fallthrough;                                                         \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NAN):                           \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN):                              \
   case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN):                                     \
@@ -417,7 +417,7 @@ do {                                                        \
   case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF):         \
   case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO):                \
     R##_s = X##_s;                                     \
-       /* Fall through */                              \
+         fallthrough;                                  \
                                                        \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF):         \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL):      \
@@ -431,7 +431,7 @@ do {                                                        \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN):         \
   case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN):                \
     R##_s = Y##_s;                                     \
-       /* Fall through */                              \
+         fallthrough;                                  \
                                                        \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_INF):      \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO):     \
@@ -497,7 +497,7 @@ do {                                                        \
                                                        \
   case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO):     \
     FP_SET_EXCEPTION(FP_EX_DIVZERO);                   \
-         /* Fall through */                            \
+       fallthrough;                                    \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_ZERO):                \
   case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL):      \
     R##_c = FP_CLS_INF;                                        \
index ba3f6c1..18f783d 100644 (file)
@@ -97,7 +97,8 @@ bool ipv6_chk_custom_prefix(const struct in6_addr *addr,
 
 int ipv6_chk_prefix(const struct in6_addr *addr, struct net_device *dev);
 
-struct net_device *ipv6_dev_find(struct net *net, const struct in6_addr *addr);
+struct net_device *ipv6_dev_find(struct net *net, const struct in6_addr *addr,
+                                struct net_device *dev);
 
 struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
                                     const struct in6_addr *addr,
index 91eacbd..f6abcc0 100644 (file)
@@ -59,7 +59,7 @@ bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
 void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
 void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
                           struct sockaddr_rxrpc *);
-u32 rxrpc_kernel_get_srtt(struct socket *, struct rxrpc_call *);
+bool rxrpc_kernel_get_srtt(struct socket *, struct rxrpc_call *, u32 *);
 int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
                               rxrpc_user_attach_call_t, unsigned long, gfp_t,
                               unsigned int);
index 9205a76..38e4094 100644 (file)
@@ -494,7 +494,7 @@ int igmp6_event_report(struct sk_buff *skb);
 
 #ifdef CONFIG_SYSCTL
 int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
-                              void __user *buffer, size_t *lenp, loff_t *ppos);
+                              void *buffer, size_t *lenp, loff_t *ppos);
 int ndisc_ifinfo_sysctl_strategy(struct ctl_table *ctl,
                                 void __user *oldval, size_t __user *oldlenp,
                                 void __user *newval, size_t newlen);
index bf9491b..224d194 100644 (file)
@@ -143,6 +143,8 @@ static inline u64 nft_reg_load64(const u32 *sreg)
 static inline void nft_data_copy(u32 *dst, const struct nft_data *src,
                                 unsigned int len)
 {
+       if (len % NFT_REG32_SIZE)
+               dst[len / NFT_REG32_SIZE] = 0;
        memcpy(dst, src, len);
 }
 
index 9b1d43d..8c18dc6 100644 (file)
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST     0x5B60
 #define CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM     0x00010422
 
+#ifndef AUX_IENABLE
+#define AUX_IENABLE                            0x40c
+#endif
+
+#define CTOP_AUX_IACK                          (0xFFFFF800 + 0x088)
+
 #ifndef __ASSEMBLY__
 
 /* In order to increase compilation test coverage */
index cc41d69..4c8b99e 100644 (file)
@@ -746,24 +746,29 @@ TRACE_EVENT(ext4_mb_release_group_pa,
 );
 
 TRACE_EVENT(ext4_discard_preallocations,
-       TP_PROTO(struct inode *inode),
+       TP_PROTO(struct inode *inode, unsigned int len, unsigned int needed),
 
-       TP_ARGS(inode),
+       TP_ARGS(inode, len, needed),
 
        TP_STRUCT__entry(
-               __field(        dev_t,  dev                     )
-               __field(        ino_t,  ino                     )
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   needed          )
 
        ),
 
        TP_fast_assign(
                __entry->dev    = inode->i_sb->s_dev;
                __entry->ino    = inode->i_ino;
+               __entry->len    = len;
+               __entry->needed = needed;
        ),
 
-       TP_printk("dev %d,%d ino %lu",
+       TP_printk("dev %d,%d ino %lu len: %u needed %u",
                  MAJOR(__entry->dev), MINOR(__entry->dev),
-                 (unsigned long) __entry->ino)
+                 (unsigned long) __entry->ino, __entry->len,
+                 __entry->needed)
 );
 
 TRACE_EVENT(ext4_mb_discard_preallocations,
@@ -1312,18 +1317,34 @@ DEFINE_EVENT(ext4__bitmap_load, ext4_mb_buddy_bitmap_load,
        TP_ARGS(sb, group)
 );
 
-DEFINE_EVENT(ext4__bitmap_load, ext4_read_block_bitmap_load,
+DEFINE_EVENT(ext4__bitmap_load, ext4_load_inode_bitmap,
 
        TP_PROTO(struct super_block *sb, unsigned long group),
 
        TP_ARGS(sb, group)
 );
 
-DEFINE_EVENT(ext4__bitmap_load, ext4_load_inode_bitmap,
+TRACE_EVENT(ext4_read_block_bitmap_load,
+       TP_PROTO(struct super_block *sb, unsigned long group, bool prefetch),
 
-       TP_PROTO(struct super_block *sb, unsigned long group),
+       TP_ARGS(sb, group, prefetch),
 
-       TP_ARGS(sb, group)
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+               __field(        bool,   prefetch                )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->group  = group;
+               __entry->prefetch = prefetch;
+       ),
+
+       TP_printk("dev %d,%d group %u prefetch %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group, __entry->prefetch)
 );
 
 TRACE_EVENT(ext4_direct_IO_enter,
@@ -2726,6 +2747,50 @@ TRACE_EVENT(ext4_error,
                  __entry->function, __entry->line)
 );
 
+TRACE_EVENT(ext4_prefetch_bitmaps,
+           TP_PROTO(struct super_block *sb, ext4_group_t group,
+                    ext4_group_t next, unsigned int prefetch_ios),
+
+       TP_ARGS(sb, group, next, prefetch_ios),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+               __field(        __u32,  next                    )
+               __field(        __u32,  ios                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->group  = group;
+               __entry->next   = next;
+               __entry->ios    = prefetch_ios;
+       ),
+
+       TP_printk("dev %d,%d group %u next %u ios %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group, __entry->next, __entry->ios)
+);
+
+TRACE_EVENT(ext4_lazy_itable_init,
+           TP_PROTO(struct super_block *sb, ext4_group_t group),
+
+       TP_ARGS(sb, group),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->group  = group;
+       ),
+
+       TP_printk("dev %d,%d group %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->group)
+);
+
 #endif /* _TRACE_EXT4_H */
 
 /* This part must be outside protection */
index 939092d..5fb7520 100644 (file)
@@ -114,6 +114,8 @@ IF_HAVE_PG_IDLE(PG_idle,            "idle"          )
 
 #if defined(CONFIG_X86)
 #define __VM_ARCH_SPECIFIC_1 {VM_PAT,     "pat"           }
+#elif defined(CONFIG_PPC)
+#define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,      "growsup"       }
 #elif !defined(CONFIG_MMU)
index 059b6e4..c33079b 100644 (file)
@@ -138,11 +138,16 @@ enum rxrpc_recvmsg_trace {
 };
 
 enum rxrpc_rtt_tx_trace {
+       rxrpc_rtt_tx_cancel,
        rxrpc_rtt_tx_data,
+       rxrpc_rtt_tx_no_slot,
        rxrpc_rtt_tx_ping,
 };
 
 enum rxrpc_rtt_rx_trace {
+       rxrpc_rtt_rx_cancel,
+       rxrpc_rtt_rx_lost,
+       rxrpc_rtt_rx_obsolete,
        rxrpc_rtt_rx_ping_response,
        rxrpc_rtt_rx_requested_ack,
 };
@@ -339,10 +344,15 @@ enum rxrpc_tx_point {
        E_(rxrpc_recvmsg_wait,                  "WAIT")
 
 #define rxrpc_rtt_tx_traces \
+       EM(rxrpc_rtt_tx_cancel,                 "CNCE") \
        EM(rxrpc_rtt_tx_data,                   "DATA") \
+       EM(rxrpc_rtt_tx_no_slot,                "FULL") \
        E_(rxrpc_rtt_tx_ping,                   "PING")
 
 #define rxrpc_rtt_rx_traces \
+       EM(rxrpc_rtt_rx_cancel,                 "CNCL") \
+       EM(rxrpc_rtt_rx_obsolete,               "OBSL") \
+       EM(rxrpc_rtt_rx_lost,                   "LOST") \
        EM(rxrpc_rtt_rx_ping_response,          "PONG") \
        E_(rxrpc_rtt_rx_requested_ack,          "RACK")
 
@@ -1087,38 +1097,43 @@ TRACE_EVENT(rxrpc_recvmsg,
 
 TRACE_EVENT(rxrpc_rtt_tx,
            TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_tx_trace why,
-                    rxrpc_serial_t send_serial),
+                    int slot, rxrpc_serial_t send_serial),
 
-           TP_ARGS(call, why, send_serial),
+           TP_ARGS(call, why, slot, send_serial),
 
            TP_STRUCT__entry(
                    __field(unsigned int,               call            )
                    __field(enum rxrpc_rtt_tx_trace,    why             )
+                   __field(int,                        slot            )
                    __field(rxrpc_serial_t,             send_serial     )
                             ),
 
            TP_fast_assign(
                    __entry->call = call->debug_id;
                    __entry->why = why;
+                   __entry->slot = slot;
                    __entry->send_serial = send_serial;
                           ),
 
-           TP_printk("c=%08x %s sr=%08x",
+           TP_printk("c=%08x [%d] %s sr=%08x",
                      __entry->call,
+                     __entry->slot,
                      __print_symbolic(__entry->why, rxrpc_rtt_tx_traces),
                      __entry->send_serial)
            );
 
 TRACE_EVENT(rxrpc_rtt_rx,
            TP_PROTO(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
+                    int slot,
                     rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial,
                     u32 rtt, u32 rto),
 
-           TP_ARGS(call, why, send_serial, resp_serial, rtt, rto),
+           TP_ARGS(call, why, slot, send_serial, resp_serial, rtt, rto),
 
            TP_STRUCT__entry(
                    __field(unsigned int,               call            )
                    __field(enum rxrpc_rtt_rx_trace,    why             )
+                   __field(int,                        slot            )
                    __field(rxrpc_serial_t,             send_serial     )
                    __field(rxrpc_serial_t,             resp_serial     )
                    __field(u32,                        rtt             )
@@ -1128,14 +1143,16 @@ TRACE_EVENT(rxrpc_rtt_rx,
            TP_fast_assign(
                    __entry->call = call->debug_id;
                    __entry->why = why;
+                   __entry->slot = slot;
                    __entry->send_serial = send_serial;
                    __entry->resp_serial = resp_serial;
                    __entry->rtt = rtt;
                    __entry->rto = rto;
                           ),
 
-           TP_printk("c=%08x %s sr=%08x rr=%08x rtt=%u rto=%u",
+           TP_printk("c=%08x [%d] %s sr=%08x rr=%08x rtt=%u rto=%u",
                      __entry->call,
+                     __entry->slot,
                      __print_symbolic(__entry->why, rxrpc_rtt_rx_traces),
                      __entry->send_serial,
                      __entry->resp_serial,
index 10f5d1f..e7cbccc 100644 (file)
@@ -20,7 +20,6 @@
                {I_CLEAR,               "I_CLEAR"},             \
                {I_SYNC,                "I_SYNC"},              \
                {I_DIRTY_TIME,          "I_DIRTY_TIME"},        \
-               {I_DIRTY_TIME_EXPIRED,  "I_DIRTY_TIME_EXPIRED"}, \
                {I_REFERENCED,          "I_REFERENCED"}         \
        )
 
@@ -498,8 +497,9 @@ DEFINE_WBC_EVENT(wbc_writepage);
 TRACE_EVENT(writeback_queue_io,
        TP_PROTO(struct bdi_writeback *wb,
                 struct wb_writeback_work *work,
+                unsigned long dirtied_before,
                 int moved),
-       TP_ARGS(wb, work, moved),
+       TP_ARGS(wb, work, dirtied_before, moved),
        TP_STRUCT__entry(
                __array(char,           name, 32)
                __field(unsigned long,  older)
@@ -509,19 +509,17 @@ TRACE_EVENT(writeback_queue_io,
                __field(ino_t,          cgroup_ino)
        ),
        TP_fast_assign(
-               unsigned long *older_than_this = work->older_than_this;
                strscpy_pad(__entry->name, bdi_dev_name(wb->bdi), 32);
-               __entry->older  = older_than_this ?  *older_than_this : 0;
-               __entry->age    = older_than_this ?
-                                 (jiffies - *older_than_this) * 1000 / HZ : -1;
+               __entry->older  = dirtied_before;
+               __entry->age    = (jiffies - dirtied_before) * 1000 / HZ;
                __entry->moved  = moved;
                __entry->reason = work->reason;
                __entry->cgroup_ino     = __trace_wb_assign_cgroup(wb);
        ),
        TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%lu",
                __entry->name,
-               __entry->older, /* older_than_this in jiffies */
-               __entry->age,   /* older_than_this in relative milliseconds */
+               __entry->older, /* dirtied_before in jiffies */
+               __entry->age,   /* dirtied_before in relative milliseconds */
                __entry->moved,
                __print_symbolic(__entry->reason, WB_WORK_REASON),
                (unsigned long)__entry->cgroup_ino
index 0480f89..b6238b2 100644 (file)
@@ -767,7 +767,7 @@ union bpf_attr {
  *
  *             Also, note that **bpf_trace_printk**\ () is slow, and should
  *             only be used for debugging purposes. For this reason, a notice
- *             bloc (spanning several lines) is printed to kernel logs and
+ *             block (spanning several lines) is printed to kernel logs and
  *             states that the helper should not be used "for production use"
  *             the first time this helper is used (or more precisely, when
  *             **trace_printk**\ () buffers are allocated). For passing values
@@ -1033,14 +1033,14 @@ union bpf_attr {
  *
  *                     int ret;
  *                     struct bpf_tunnel_key key = {};
- *                     
+ *
  *                     ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
  *                     if (ret < 0)
  *                             return TC_ACT_SHOT;     // drop packet
- *                     
+ *
  *                     if (key.remote_ipv4 != 0x0a000001)
  *                             return TC_ACT_SHOT;     // drop packet
- *                     
+ *
  *                     return TC_ACT_OK;               // accept packet
  *
  *             This interface can also be used with all encapsulation devices
@@ -1147,7 +1147,7 @@ union bpf_attr {
  *     Description
  *             Retrieve the realm or the route, that is to say the
  *             **tclassid** field of the destination for the *skb*. The
- *             indentifier retrieved is a user-provided tag, similar to the
+ *             identifier retrieved is a user-provided tag, similar to the
  *             one used with the net_cls cgroup (see description for
  *             **bpf_get_cgroup_classid**\ () helper), but here this tag is
  *             held by a route (a destination entry), not by a task.
index 8847dbf..7ff3709 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/const.h>
 
 #define STM_FLAG_TIMESTAMPED   _BITUL(3)
+#define STM_FLAG_MARKED        _BITUL(4)
 #define STM_FLAG_GUARANTEED    _BITUL(7)
 
 /*
index 3d0d823..7d66876 100644 (file)
@@ -135,7 +135,7 @@ struct in_addr {
  * this socket to prevent accepting spoofed ones.
  */
 #define IP_PMTUDISC_INTERFACE          4
-/* weaker version of IP_PMTUDISC_INTERFACE, which allos packets to get
+/* weaker version of IP_PMTUDISC_INTERFACE, which allows packets to get
  * fragmented if they exeed the interface mtu
  */
 #define IP_PMTUDISC_OMIT               5
index f6d8603..7d8eced 100644 (file)
@@ -790,9 +790,10 @@ struct kvm_ppc_resize_hpt {
 #define KVM_VM_PPC_HV 1
 #define KVM_VM_PPC_PR 2
 
-/* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */
-#define KVM_VM_MIPS_TE         0
+/* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */
+#define KVM_VM_MIPS_AUTO       0
 #define KVM_VM_MIPS_VZ         1
+#define KVM_VM_MIPS_TE         2
 
 #define KVM_S390_SIE_PAGE_OFFSET 1
 
@@ -1035,6 +1036,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_LAST_CPU 184
 #define KVM_CAP_SMALLER_MAXPHYADDR 185
 #define KVM_CAP_S390_DIAG318 186
+#define KVM_CAP_STEAL_TIME 187
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
index c6aec86..4f36384 100644 (file)
@@ -66,4 +66,53 @@ struct mei_connect_client_data {
  */
 #define IOCTL_MEI_NOTIFY_GET _IOR('H', 0x03, __u32)
 
+/**
+ * struct mei_connect_client_vtag - mei client information struct with vtag
+ *
+ * @in_client_uuid: UUID of client to connect
+ * @vtag: virtual tag
+ * @reserved: reserved for future use
+ */
+struct mei_connect_client_vtag {
+       uuid_le in_client_uuid;
+       __u8 vtag;
+       __u8 reserved[3];
+};
+
+/**
+ * struct mei_connect_client_data_vtag - IOCTL connect data union
+ *
+ * @connect: input connect data
+ * @out_client_properties: output client data
+ */
+struct mei_connect_client_data_vtag {
+       union {
+               struct mei_connect_client_vtag connect;
+               struct mei_client out_client_properties;
+       };
+};
+
+/**
+ * DOC:
+ * This IOCTL is used to associate the current file descriptor with a
+ * FW Client (given by UUID), and virtual tag (vtag).
+ * The IOCTL opens a communication channel between a host client and
+ * a FW client on a tagged channel. From this point on, every read
+ * and write will communicate with the associated FW client with
+ * on the tagged channel.
+ * Upone close() the communication is terminated.
+ *
+ * The IOCTL argument is a struct with a union that contains
+ * the input parameter and the output parameter for this IOCTL.
+ *
+ * The input parameter is UUID of the FW Client, a vtag [0,255]
+ * The output parameter is the properties of the FW client
+ * (FW protocool version and max message size).
+ *
+ * Clients that do not support tagged connection
+ * will respond with -EOPNOTSUPP.
+ */
+#define IOCTL_MEI_CONNECT_CLIENT_VTAG \
+       _IOWR('H', 0x04, struct mei_connect_client_data_vtag)
+
 #endif /* _LINUX_MEI_H  */
index 42f351c..2b8e12f 100644 (file)
@@ -133,7 +133,7 @@ enum nf_tables_msg_types {
  * @NFTA_LIST_ELEM: list element (NLA_NESTED)
  */
 enum nft_list_attributes {
-       NFTA_LIST_UNPEC,
+       NFTA_LIST_UNSPEC,
        NFTA_LIST_ELEM,
        __NFTA_LIST_MAX
 };
diff --git a/include/uapi/linux/nitro_enclaves.h b/include/uapi/linux/nitro_enclaves.h
new file mode 100644 (file)
index 0000000..b945073
--- /dev/null
@@ -0,0 +1,359 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+#ifndef _UAPI_LINUX_NITRO_ENCLAVES_H_
+#define _UAPI_LINUX_NITRO_ENCLAVES_H_
+
+#include <linux/types.h>
+
+/**
+ * DOC: Nitro Enclaves (NE) Kernel Driver Interface
+ */
+
+/**
+ * NE_CREATE_VM - The command is used to create a slot that is associated with
+ *               an enclave VM.
+ *               The generated unique slot id is an output parameter.
+ *               The ioctl can be invoked on the /dev/nitro_enclaves fd, before
+ *               setting any resources, such as memory and vCPUs, for an
+ *               enclave. Memory and vCPUs are set for the slot mapped to an enclave.
+ *               A NE CPU pool has to be set before calling this function. The
+ *               pool can be set after the NE driver load, using
+ *               /sys/module/nitro_enclaves/parameters/ne_cpus.
+ *               Its format is the detailed in the cpu-lists section:
+ *               https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
+ *               CPU 0 and its siblings have to remain available for the
+ *               primary / parent VM, so they cannot be set for enclaves. Full
+ *               CPU core(s), from the same NUMA node, need(s) to be included
+ *               in the CPU pool.
+ *
+ * Context: Process context.
+ * Return:
+ * * Enclave file descriptor           - Enclave file descriptor used with
+ *                                       ioctl calls to set vCPUs and memory
+ *                                       regions, then start the enclave.
+ * *  -1                               - There was a failure in the ioctl logic.
+ * On failure, errno is set to:
+ * * EFAULT                            - copy_to_user() failure.
+ * * ENOMEM                            - Memory allocation failure for internal
+ *                                       bookkeeping variables.
+ * * NE_ERR_NO_CPUS_AVAIL_IN_POOL      - No NE CPU pool set / no CPUs available
+ *                                       in the pool.
+ * * Error codes from get_unused_fd_flags() and anon_inode_getfile().
+ * * Error codes from the NE PCI device request.
+ */
+#define NE_CREATE_VM                   _IOR(0xAE, 0x20, __u64)
+
+/**
+ * NE_ADD_VCPU - The command is used to set a vCPU for an enclave. The vCPU can
+ *              be auto-chosen from the NE CPU pool or it can be set by the
+ *              caller, with the note that it needs to be available in the NE
+ *              CPU pool. Full CPU core(s), from the same NUMA node, need(s) to
+ *              be associated with an enclave.
+ *              The vCPU id is an input / output parameter. If its value is 0,
+ *              then a CPU is chosen from the enclave CPU pool and returned via
+ *              this parameter.
+ *              The ioctl can be invoked on the enclave fd, before an enclave
+ *              is started.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0                                 - Logic succesfully completed.
+ * *  -1                               - There was a failure in the ioctl logic.
+ * On failure, errno is set to:
+ * * EFAULT                            - copy_from_user() / copy_to_user() failure.
+ * * ENOMEM                            - Memory allocation failure for internal
+ *                                       bookkeeping variables.
+ * * EIO                               - Current task mm is not the same as the one
+ *                                       that created the enclave.
+ * * NE_ERR_NO_CPUS_AVAIL_IN_POOL      - No CPUs available in the NE CPU pool.
+ * * NE_ERR_VCPU_ALREADY_USED          - The provided vCPU is already used.
+ * * NE_ERR_VCPU_NOT_IN_CPU_POOL       - The provided vCPU is not available in the
+ *                                       NE CPU pool.
+ * * NE_ERR_VCPU_INVALID_CPU_CORE      - The core id of the provided vCPU is invalid
+ *                                       or out of range.
+ * * NE_ERR_NOT_IN_INIT_STATE          - The enclave is not in init state
+ *                                       (init = before being started).
+ * * NE_ERR_INVALID_VCPU               - The provided vCPU is not in the available
+ *                                       CPUs range.
+ * * Error codes from the NE PCI device request.
+ */
+#define NE_ADD_VCPU                    _IOWR(0xAE, 0x21, __u32)
+
+/**
+ * NE_GET_IMAGE_LOAD_INFO - The command is used to get information needed for
+ *                         in-memory enclave image loading e.g. offset in
+ *                         enclave memory to start placing the enclave image.
+ *                         The image load info is an input / output parameter.
+ *                         It includes info provided by the caller - flags -
+ *                         and returns the offset in enclave memory where to
+ *                         start placing the enclave image.
+ *                         The ioctl can be invoked on the enclave fd, before
+ *                         an enclave is started.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0                         - Logic succesfully completed.
+ * *  -1                       - There was a failure in the ioctl logic.
+ * On failure, errno is set to:
+ * * EFAULT                    - copy_from_user() / copy_to_user() failure.
+ * * NE_ERR_NOT_IN_INIT_STATE  - The enclave is not in init state (init =
+ *                               before being started).
+ * * NE_ERR_INVALID_FLAG_VALUE - The value of the provided flag is invalid.
+ */
+#define NE_GET_IMAGE_LOAD_INFO         _IOWR(0xAE, 0x22, struct ne_image_load_info)
+
+/**
+ * NE_SET_USER_MEMORY_REGION - The command is used to set a memory region for an
+ *                            enclave, given the allocated memory from the
+ *                            userspace. Enclave memory needs to be from the
+ *                            same NUMA node as the enclave CPUs.
+ *                            The user memory region is an input parameter. It
+ *                            includes info provided by the caller - flags,
+ *                            memory size and userspace address.
+ *                            The ioctl can be invoked on the enclave fd,
+ *                            before an enclave is started.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0                                 - Logic succesfully completed.
+ * *  -1                               - There was a failure in the ioctl logic.
+ * On failure, errno is set to:
+ * * EFAULT                            - copy_from_user() failure.
+ * * EINVAL                            - Invalid physical memory region(s) e.g.
+ *                                       unaligned address.
+ * * EIO                               - Current task mm is not the same as
+ *                                       the one that created the enclave.
+ * * ENOMEM                            - Memory allocation failure for internal
+ *                                       bookkeeping variables.
+ * * NE_ERR_NOT_IN_INIT_STATE          - The enclave is not in init state
+ *                                       (init = before being started).
+ * * NE_ERR_INVALID_MEM_REGION_SIZE    - The memory size of the region is not
+ *                                       multiple of 2 MiB.
+ * * NE_ERR_INVALID_MEM_REGION_ADDR    - Invalid user space address given.
+ * * NE_ERR_UNALIGNED_MEM_REGION_ADDR  - Unaligned user space address given.
+ * * NE_ERR_MEM_REGION_ALREADY_USED    - The memory region is already used.
+ * * NE_ERR_MEM_NOT_HUGE_PAGE          - The memory region is not backed by
+ *                                       huge pages.
+ * * NE_ERR_MEM_DIFFERENT_NUMA_NODE    - The memory region is not from the same
+ *                                       NUMA node as the CPUs.
+ * * NE_ERR_MEM_MAX_REGIONS            - The number of memory regions set for
+ *                                       the enclave reached maximum.
+ * * NE_ERR_INVALID_PAGE_SIZE          - The memory region is not backed by
+ *                                       pages multiple of 2 MiB.
+ * * NE_ERR_INVALID_FLAG_VALUE         - The value of the provided flag is invalid.
+ * * Error codes from get_user_pages().
+ * * Error codes from the NE PCI device request.
+ */
+#define NE_SET_USER_MEMORY_REGION      _IOW(0xAE, 0x23, struct ne_user_memory_region)
+
+/**
+ * NE_START_ENCLAVE - The command is used to trigger enclave start after the
+ *                   enclave resources, such as memory and CPU, have been set.
+ *                   The enclave start info is an input / output parameter. It
+ *                   includes info provided by the caller - enclave cid and
+ *                   flags - and returns the cid (if input cid is 0).
+ *                   The ioctl can be invoked on the enclave fd, after an
+ *                   enclave slot is created and resources, such as memory and
+ *                   vCPUs are set for an enclave.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0                                 - Logic succesfully completed.
+ * *  -1                               - There was a failure in the ioctl logic.
+ * On failure, errno is set to:
+ * * EFAULT                            - copy_from_user() / copy_to_user() failure.
+ * * NE_ERR_NOT_IN_INIT_STATE          - The enclave is not in init state
+ *                                       (init = before being started).
+ * * NE_ERR_NO_MEM_REGIONS_ADDED       - No memory regions are set.
+ * * NE_ERR_NO_VCPUS_ADDED             - No vCPUs are set.
+ * *  NE_ERR_FULL_CORES_NOT_USED       - Full core(s) not set for the enclave.
+ * * NE_ERR_ENCLAVE_MEM_MIN_SIZE       - Enclave memory is less than minimum
+ *                                       memory size (64 MiB).
+ * * NE_ERR_INVALID_FLAG_VALUE         - The value of the provided flag is invalid.
+ * *  NE_ERR_INVALID_ENCLAVE_CID       - The provided enclave CID is invalid.
+ * * Error codes from the NE PCI device request.
+ */
+#define NE_START_ENCLAVE               _IOWR(0xAE, 0x24, struct ne_enclave_start_info)
+
+/**
+ * DOC: NE specific error codes
+ */
+
+/**
+ * NE_ERR_VCPU_ALREADY_USED - The provided vCPU is already used.
+ */
+#define NE_ERR_VCPU_ALREADY_USED               (256)
+/**
+ * NE_ERR_VCPU_NOT_IN_CPU_POOL - The provided vCPU is not available in the
+ *                              NE CPU pool.
+ */
+#define NE_ERR_VCPU_NOT_IN_CPU_POOL            (257)
+/**
+ * NE_ERR_VCPU_INVALID_CPU_CORE - The core id of the provided vCPU is invalid
+ *                               or out of range of the NE CPU pool.
+ */
+#define NE_ERR_VCPU_INVALID_CPU_CORE           (258)
+/**
+ * NE_ERR_INVALID_MEM_REGION_SIZE - The user space memory region size is not
+ *                                 multiple of 2 MiB.
+ */
+#define NE_ERR_INVALID_MEM_REGION_SIZE         (259)
+/**
+ * NE_ERR_INVALID_MEM_REGION_ADDR - The user space memory region address range
+ *                                 is invalid.
+ */
+#define NE_ERR_INVALID_MEM_REGION_ADDR         (260)
+/**
+ * NE_ERR_UNALIGNED_MEM_REGION_ADDR - The user space memory region address is
+ *                                   not aligned.
+ */
+#define NE_ERR_UNALIGNED_MEM_REGION_ADDR       (261)
+/**
+ * NE_ERR_MEM_REGION_ALREADY_USED - The user space memory region is already used.
+ */
+#define NE_ERR_MEM_REGION_ALREADY_USED         (262)
+/**
+ * NE_ERR_MEM_NOT_HUGE_PAGE - The user space memory region is not backed by
+ *                           contiguous physical huge page(s).
+ */
+#define NE_ERR_MEM_NOT_HUGE_PAGE               (263)
+/**
+ * NE_ERR_MEM_DIFFERENT_NUMA_NODE - The user space memory region is backed by
+ *                                 pages from different NUMA nodes than the CPUs.
+ */
+#define NE_ERR_MEM_DIFFERENT_NUMA_NODE         (264)
+/**
+ * NE_ERR_MEM_MAX_REGIONS - The supported max memory regions per enclaves has
+ *                         been reached.
+ */
+#define NE_ERR_MEM_MAX_REGIONS                 (265)
+/**
+ * NE_ERR_NO_MEM_REGIONS_ADDED - The command to start an enclave is triggered
+ *                              and no memory regions are added.
+ */
+#define NE_ERR_NO_MEM_REGIONS_ADDED            (266)
+/**
+ * NE_ERR_NO_VCPUS_ADDED - The command to start an enclave is triggered and no
+ *                        vCPUs are added.
+ */
+#define NE_ERR_NO_VCPUS_ADDED                  (267)
+/**
+ * NE_ERR_ENCLAVE_MEM_MIN_SIZE - The enclave memory size is lower than the
+ *                              minimum supported.
+ */
+#define NE_ERR_ENCLAVE_MEM_MIN_SIZE            (268)
+/**
+ * NE_ERR_FULL_CORES_NOT_USED - The command to start an enclave is triggered and
+ *                             full CPU cores are not set.
+ */
+#define NE_ERR_FULL_CORES_NOT_USED             (269)
+/**
+ * NE_ERR_NOT_IN_INIT_STATE - The enclave is not in init state when setting
+ *                           resources or triggering start.
+ */
+#define NE_ERR_NOT_IN_INIT_STATE               (270)
+/**
+ * NE_ERR_INVALID_VCPU - The provided vCPU is out of range of the available CPUs.
+ */
+#define NE_ERR_INVALID_VCPU                    (271)
+/**
+ * NE_ERR_NO_CPUS_AVAIL_IN_POOL - The command to create an enclave is triggered
+ *                               and no CPUs are available in the pool.
+ */
+#define NE_ERR_NO_CPUS_AVAIL_IN_POOL           (272)
+/**
+ * NE_ERR_INVALID_PAGE_SIZE - The user space memory region is not backed by pages
+ *                           multiple of 2 MiB.
+ */
+#define NE_ERR_INVALID_PAGE_SIZE               (273)
+/**
+ * NE_ERR_INVALID_FLAG_VALUE - The provided flag value is invalid.
+ */
+#define NE_ERR_INVALID_FLAG_VALUE              (274)
+/**
+ * NE_ERR_INVALID_ENCLAVE_CID - The provided enclave CID is invalid, either
+ *                             being a well-known value or the CID of the
+ *                             parent / primary VM.
+ */
+#define NE_ERR_INVALID_ENCLAVE_CID             (275)
+
+/**
+ * DOC: Image load info flags
+ */
+
+/**
+ * NE_EIF_IMAGE - Enclave Image Format (EIF)
+ */
+#define NE_EIF_IMAGE                   (0x01)
+
+#define NE_IMAGE_LOAD_MAX_FLAG_VAL     (0x02)
+
+/**
+ * struct ne_image_load_info - Info necessary for in-memory enclave image
+ *                            loading (in / out).
+ * @flags:             Flags to determine the enclave image type
+ *                     (e.g. Enclave Image Format - EIF) (in).
+ * @memory_offset:     Offset in enclave memory where to start placing the
+ *                     enclave image (out).
+ */
+struct ne_image_load_info {
+       __u64   flags;
+       __u64   memory_offset;
+};
+
+/**
+ * DOC: User memory region flags
+ */
+
+/**
+ * NE_DEFAULT_MEMORY_REGION - Memory region for enclave general usage.
+ */
+#define NE_DEFAULT_MEMORY_REGION       (0x00)
+
+#define NE_MEMORY_REGION_MAX_FLAG_VAL  (0x01)
+
+/**
+ * struct ne_user_memory_region - Memory region to be set for an enclave (in).
+ * @flags:             Flags to determine the usage for the memory region (in).
+ * @memory_size:       The size, in bytes, of the memory region to be set for
+ *                     an enclave (in).
+ * @userspace_addr:    The start address of the userspace allocated memory of
+ *                     the memory region to set for an enclave (in).
+ */
+struct ne_user_memory_region {
+       __u64   flags;
+       __u64   memory_size;
+       __u64   userspace_addr;
+};
+
+/**
+ * DOC: Enclave start info flags
+ */
+
+/**
+ * NE_ENCLAVE_PRODUCTION_MODE - Start enclave in production mode.
+ */
+#define NE_ENCLAVE_PRODUCTION_MODE     (0x00)
+/**
+ * NE_ENCLAVE_DEBUG_MODE - Start enclave in debug mode.
+ */
+#define NE_ENCLAVE_DEBUG_MODE          (0x01)
+
+#define NE_ENCLAVE_START_MAX_FLAG_VAL  (0x02)
+
+/**
+ * struct ne_enclave_start_info - Setup info necessary for enclave start (in / out).
+ * @flags:             Flags for the enclave to start with (e.g. debug mode) (in).
+ * @enclave_cid:       Context ID (CID) for the enclave vsock device. If 0 as
+ *                     input, the CID is autogenerated by the hypervisor and
+ *                     returned back as output by the driver (in / out).
+ */
+struct ne_enclave_start_info {
+       __u64   flags;
+       __u64   enclave_cid;
+};
+
+#endif /* _UAPI_LINUX_NITRO_ENCLAVES_H_ */
index 07de2b7..0a89f95 100644 (file)
@@ -10,8 +10,9 @@
 #define FASTRPC_IOCTL_INVOKE           _IOWR('R', 3, struct fastrpc_invoke)
 #define FASTRPC_IOCTL_INIT_ATTACH      _IO('R', 4)
 #define FASTRPC_IOCTL_INIT_CREATE      _IOWR('R', 5, struct fastrpc_init_create)
-#define FASTRPC_IOCTL_MMAP              _IOWR('R', 6, struct fastrpc_req_mmap)
-#define FASTRPC_IOCTL_MUNMAP            _IOWR('R', 7, struct fastrpc_req_munmap)
+#define FASTRPC_IOCTL_MMAP             _IOWR('R', 6, struct fastrpc_req_mmap)
+#define FASTRPC_IOCTL_MUNMAP           _IOWR('R', 7, struct fastrpc_req_munmap)
+#define FASTRPC_IOCTL_INIT_ATTACH_SNS  _IO('R', 8)
 
 struct fastrpc_invoke_args {
        __u64 ptr;
index d5c4f98..9705b8a 100644 (file)
@@ -264,6 +264,10 @@ enum hl_device_status {
  * HL_INFO_TIME_SYNC     - Retrieve the device's time alongside the host's time
  *                         for synchronization.
  * HL_INFO_CS_COUNTERS   - Retrieve command submission counters
+ * HL_INFO_PCI_COUNTERS  - Retrieve PCI counters
+ * HL_INFO_CLK_THROTTLE_REASON - Retrieve clock throttling reason
+ * HL_INFO_SYNC_MANAGER  - Retrieve sync manager info per dcore
+ * HL_INFO_TOTAL_ENERGY  - Retrieve total energy consumption
  */
 #define HL_INFO_HW_IP_INFO             0
 #define HL_INFO_HW_EVENTS              1
@@ -276,6 +280,10 @@ enum hl_device_status {
 #define HL_INFO_RESET_COUNT            9
 #define HL_INFO_TIME_SYNC              10
 #define HL_INFO_CS_COUNTERS            11
+#define HL_INFO_PCI_COUNTERS           12
+#define HL_INFO_CLK_THROTTLE_REASON    13
+#define HL_INFO_SYNC_MANAGER           14
+#define HL_INFO_TOTAL_ENERGY           15
 
 #define HL_INFO_VERSION_MAX_LEN        128
 #define HL_INFO_CARD_NAME_MAX_LEN      16
@@ -289,7 +297,7 @@ struct hl_info_hw_ip_info {
        __u32 device_id; /* PCI Device ID */
        __u32 module_id; /* For mezzanine cards in servers (From OCP spec.) */
        __u32 reserved[2];
-       __u32 armcp_cpld_version;
+       __u32 cpld_version;
        __u32 psoc_pci_pll_nr;
        __u32 psoc_pci_pll_nf;
        __u32 psoc_pci_pll_od;
@@ -297,7 +305,7 @@ struct hl_info_hw_ip_info {
        __u8 tpc_enabled_mask;
        __u8 dram_enabled;
        __u8 pad[2];
-       __u8 armcp_version[HL_INFO_VERSION_MAX_LEN];
+       __u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
        __u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
 };
 
@@ -313,6 +321,12 @@ struct hl_info_hw_idle {
         * Bits definition is according to `enum <chip>_enging_id'.
         */
        __u32 busy_engines_mask;
+
+       /*
+        * Extended Bitmask of busy engines.
+        * Bits definition is according to `enum <chip>_enging_id'.
+        */
+       __u64 busy_engines_mask_ext;
 };
 
 struct hl_info_device_status {
@@ -340,18 +354,61 @@ struct hl_info_time_sync {
        __u64 host_time;
 };
 
+/**
+ * struct hl_info_pci_counters - pci counters
+ * @rx_throughput: PCI rx throughput KBps
+ * @tx_throughput: PCI tx throughput KBps
+ * @replay_cnt: PCI replay counter
+ */
+struct hl_info_pci_counters {
+       __u64 rx_throughput;
+       __u64 tx_throughput;
+       __u64 replay_cnt;
+};
+
+#define HL_CLK_THROTTLE_POWER  0x1
+#define HL_CLK_THROTTLE_THERMAL        0x2
+
+/**
+ * struct hl_info_clk_throttle - clock throttling reason
+ * @clk_throttling_reason: each bit represents a clk throttling reason
+ */
+struct hl_info_clk_throttle {
+       __u32 clk_throttling_reason;
+};
+
+/**
+ * struct hl_info_energy - device energy information
+ * @total_energy_consumption: total device energy consumption
+ */
+struct hl_info_energy {
+       __u64 total_energy_consumption;
+};
+
+/**
+ * struct hl_info_sync_manager - sync manager information
+ * @first_available_sync_object: first available sob
+ * @first_available_monitor: first available monitor
+ */
+struct hl_info_sync_manager {
+       __u32 first_available_sync_object;
+       __u32 first_available_monitor;
+};
+
 /**
  * struct hl_info_cs_counters - command submission counters
  * @out_of_mem_drop_cnt: dropped due to memory allocation issue
  * @parsing_drop_cnt: dropped due to error in packet parsing
  * @queue_full_drop_cnt: dropped due to queue full
  * @device_in_reset_drop_cnt: dropped due to device in reset
+ * @max_cs_in_flight_drop_cnt: dropped due to maximum CS in-flight
  */
 struct hl_cs_counters {
        __u64 out_of_mem_drop_cnt;
        __u64 parsing_drop_cnt;
        __u64 queue_full_drop_cnt;
        __u64 device_in_reset_drop_cnt;
+       __u64 max_cs_in_flight_drop_cnt;
 };
 
 struct hl_info_cs_counters {
@@ -359,6 +416,13 @@ struct hl_info_cs_counters {
        struct hl_cs_counters ctx_cs_counters;
 };
 
+enum gaudi_dcores {
+       HL_GAUDI_WS_DCORE,
+       HL_GAUDI_WN_DCORE,
+       HL_GAUDI_EN_DCORE,
+       HL_GAUDI_ES_DCORE
+};
+
 struct hl_info_args {
        /* Location of relevant struct in userspace */
        __u64 return_pointer;
@@ -375,6 +439,10 @@ struct hl_info_args {
        __u32 op;
 
        union {
+               /* Dcore id for which the information is relevant.
+                * For Gaudi refer to 'enum gaudi_dcores'
+                */
+               __u32 dcore_id;
                /* Context ID - Currently not in use */
                __u32 ctx_id;
                /* Period value for utilization rate (100ms - 1000ms, in 100ms
@@ -394,6 +462,9 @@ struct hl_info_args {
 /* 2MB minus 32 bytes for 2xMSG_PROT */
 #define HL_MAX_CB_SIZE         (0x200000 - 32)
 
+/* Indicates whether the command buffer should be mapped to the device's MMU */
+#define HL_CB_FLAGS_MAP                0x1
+
 struct hl_cb_in {
        /* Handle of CB or 0 if we want to create one */
        __u64 cb_handle;
@@ -405,7 +476,8 @@ struct hl_cb_in {
        __u32 cb_size;
        /* Context ID - Currently not in use */
        __u32 ctx_id;
-       __u32 pad;
+       /* HL_CB_FLAGS_* */
+       __u32 flags;
 };
 
 struct hl_cb_out {
@@ -788,6 +860,12 @@ struct hl_debug_args {
  * When creating a new CB, the IOCTL returns a handle of it, and the user-space
  * process needs to use that handle to mmap the buffer so it can access them.
  *
+ * In some instances, the device must access the command buffer through the
+ * device's MMU, and thus its memory should be mapped. In these cases, user can
+ * indicate the driver that such a mapping is required.
+ * The resulting device virtual address will be used internally by the driver,
+ * and won't be returned to user.
+ *
  */
 #define HL_IOCTL_CB            \
                _IOWR('H', 0x02, union hl_cb_args)
@@ -846,6 +924,9 @@ struct hl_debug_args {
  * inside the kernel until the CS has finished or until the user-requested
  * timeout has expired.
  *
+ * If the timeout value is 0, the driver won't sleep at all. It will check
+ * the status of the CS and return immediately
+ *
  * The return value of the IOCTL is a standard Linux error code. The possible
  * values are:
  *
index d7f6af5..39df751 100644 (file)
@@ -76,7 +76,11 @@ static inline unsigned long bfn_to_pfn(unsigned long bfn)
 #define bfn_to_local_pfn(bfn)  bfn_to_pfn(bfn)
 
 /* VIRT <-> GUEST conversion */
-#define virt_to_gfn(v)         (pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT))
+#define virt_to_gfn(v)                                                         \
+       ({                                                                     \
+               WARN_ON_ONCE(!virt_addr_valid(v));                              \
+               pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT);                 \
+       })
 #define gfn_to_virt(m)         (__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
 
 /* Only used in PV code. But ARM guests are always HVM. */
index 6fb95aa..6dbdb0b 100644 (file)
@@ -2,6 +2,8 @@
 /******************************************************************************
  * Xen balloon functionality
  */
+#ifndef _XEN_BALLOON_H
+#define _XEN_BALLOON_H
 
 #define RETRY_UNLIMITED        0
 
@@ -34,3 +36,5 @@ static inline void xen_balloon_init(void)
 {
 }
 #endif
+
+#endif /* _XEN_BALLOON_H */
index 19a72f5..43efba0 100644 (file)
@@ -52,4 +52,13 @@ bool xen_biovec_phys_mergeable(const struct bio_vec *vec1,
 extern u64 xen_saved_max_mem_size;
 #endif
 
+#ifdef CONFIG_XEN_UNPOPULATED_ALLOC
+int xen_alloc_unpopulated_pages(unsigned int nr_pages, struct page **pages);
+void xen_free_unpopulated_pages(unsigned int nr_pages, struct page **pages);
+#else
+#define xen_alloc_unpopulated_pages alloc_xenballooned_pages
+#define xen_free_unpopulated_pages free_xenballooned_pages
+#include <xen/balloon.h>
+#endif
+
 #endif /* _XEN_XEN_H */
index e6dbfb7..1f97c03 100644 (file)
@@ -297,7 +297,7 @@ static void __init clean_path(char *path, umode_t fmode)
 {
        struct kstat st;
 
-       if (init_stat(path, &st, AT_SYMLINK_NOFOLLOW) &&
+       if (!init_stat(path, &st, AT_SYMLINK_NOFOLLOW) &&
            (st.mode ^ fmode) & S_IFMT) {
                if (S_ISDIR(st.mode))
                        init_rmdir(path);
index d1b8644..3f312bf 100644 (file)
@@ -85,7 +85,7 @@ static int proc_ipc_auto_msgmni(struct ctl_table *table, int write,
 }
 
 static int proc_ipc_sem_dointvec(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, semmni;
        struct ipc_namespace *ns = current->nsproxy->ipc_ns;
index 8c0244e..f6c30a8 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1691,7 +1691,7 @@ static long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg, int v
        case IPC_SET:
                if (copy_semid_from_user(&semid64, p, version))
                        return -EFAULT;
-               /* fall through */
+               fallthrough;
        case IPC_RMID:
                return semctl_down(ns, semid, cmd, &semid64);
        default:
@@ -1805,7 +1805,7 @@ static long compat_ksys_semctl(int semid, int semnum, int cmd, int arg, int vers
        case IPC_SET:
                if (copy_compat_semid_from_user(&semid64, p, version))
                        return -EFAULT;
-               /* fallthru */
+               fallthrough;
        case IPC_RMID:
                return semctl_down(ns, semid, cmd, &semid64);
        default:
index f1ed36e..e25c7c6 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1179,7 +1179,7 @@ static long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf, int ver
        case IPC_SET:
                if (copy_shmid_from_user(&sem64, buf, version))
                        return -EFAULT;
-               /* fallthru */
+               fallthrough;
        case IPC_RMID:
                return shmctl_down(ns, shmid, cmd, &sem64);
        case SHM_LOCK:
@@ -1374,7 +1374,7 @@ static long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr, int versio
        case IPC_SET:
                if (copy_compat_shmid_from_user(&sem64, uptr, version))
                        return -EFAULT;
-               /* fallthru */
+               fallthrough;
        case IPC_RMID:
                return shmctl_down(ns, shmid, cmd, &sem64);
        case SHM_LOCK:
index a10e299..333b3bc 100644 (file)
@@ -681,7 +681,7 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
                                data->values[i] = AUDIT_UID_UNSET;
                                break;
                        }
-                       /* fall through - if set */
+                       fallthrough;    /* if set */
                default:
                        data->values[i] = f->val;
                }
index b671596..8faa2ce 100644 (file)
@@ -67,6 +67,9 @@ static void bpf_iter_done_stop(struct seq_file *seq)
        iter_priv->done_stop = true;
 }
 
+/* maximum visited objects before bailing out */
+#define MAX_ITER_OBJECTS       1000000
+
 /* bpf_seq_read, a customized and simpler version for bpf iterator.
  * no_llseek is assumed for this file.
  * The following are differences from seq_read():
@@ -79,7 +82,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
 {
        struct seq_file *seq = file->private_data;
        size_t n, offs, copied = 0;
-       int err = 0;
+       int err = 0, num_objs = 0;
        void *p;
 
        mutex_lock(&seq->lock);
@@ -135,6 +138,7 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
        while (1) {
                loff_t pos = seq->index;
 
+               num_objs++;
                offs = seq->count;
                p = seq->op->next(seq, p, &seq->index);
                if (pos == seq->index) {
@@ -153,6 +157,15 @@ static ssize_t bpf_seq_read(struct file *file, char __user *buf, size_t size,
                if (seq->count >= size)
                        break;
 
+               if (num_objs >= MAX_ITER_OBJECTS) {
+                       if (offs == 0) {
+                               err = -EAGAIN;
+                               seq->op->stop(seq, p);
+                               goto done;
+                       }
+                       break;
+               }
+
                err = seq->op->show(seq, p);
                if (err > 0) {
                        bpf_iter_dec_seq_num(seq);
index 83ff127..e21de4f 100644 (file)
@@ -1794,7 +1794,7 @@ static bool cg_sockopt_is_valid_access(int off, int size,
                        return prog->expected_attach_type ==
                                BPF_CGROUP_GETSOCKOPT;
                case offsetof(struct bpf_sockopt, optname):
-                       /* fallthrough */
+                       fallthrough;
                case offsetof(struct bpf_sockopt, level):
                        if (size != size_default)
                                return false;
index f1c4652..6386b7b 100644 (file)
@@ -279,7 +279,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_entry *rcpu,
                        break;
                default:
                        bpf_warn_invalid_xdp_action(act);
-                       /* fallthrough */
+                       fallthrough;
                case XDP_DROP:
                        xdp_return_frame(xdpf);
                        stats->drop++;
index 4fd830a..cfed0ac 100644 (file)
@@ -213,11 +213,13 @@ static int stack_map_get_build_id_32(void *page_addr,
 
        phdr = (Elf32_Phdr *)(page_addr + sizeof(Elf32_Ehdr));
 
-       for (i = 0; i < ehdr->e_phnum; ++i)
-               if (phdr[i].p_type == PT_NOTE)
-                       return stack_map_parse_build_id(page_addr, build_id,
-                                       page_addr + phdr[i].p_offset,
-                                       phdr[i].p_filesz);
+       for (i = 0; i < ehdr->e_phnum; ++i) {
+               if (phdr[i].p_type == PT_NOTE &&
+                   !stack_map_parse_build_id(page_addr, build_id,
+                                             page_addr + phdr[i].p_offset,
+                                             phdr[i].p_filesz))
+                       return 0;
+       }
        return -EINVAL;
 }
 
@@ -236,11 +238,13 @@ static int stack_map_get_build_id_64(void *page_addr,
 
        phdr = (Elf64_Phdr *)(page_addr + sizeof(Elf64_Ehdr));
 
-       for (i = 0; i < ehdr->e_phnum; ++i)
-               if (phdr[i].p_type == PT_NOTE)
-                       return stack_map_parse_build_id(page_addr, build_id,
-                                       page_addr + phdr[i].p_offset,
-                                       phdr[i].p_filesz);
+       for (i = 0; i < ehdr->e_phnum; ++i) {
+               if (phdr[i].p_type == PT_NOTE &&
+                   !stack_map_parse_build_id(page_addr, build_id,
+                                             page_addr + phdr[i].p_offset,
+                                             phdr[i].p_filesz))
+                       return 0;
+       }
        return -EINVAL;
 }
 
index 86299a2..b999e7f 100644 (file)
@@ -2029,7 +2029,7 @@ bpf_prog_load_check_attach(enum bpf_prog_type prog_type,
        case BPF_PROG_TYPE_EXT:
                if (expected_attach_type)
                        return -EINVAL;
-               /* fallthrough */
+               fallthrough;
        default:
                return 0;
        }
@@ -2634,7 +2634,7 @@ static int bpf_raw_tp_link_fill_link_info(const struct bpf_link *link,
        u32 ulen = info->raw_tracepoint.tp_name_len;
        size_t tp_len = strlen(tp_name);
 
-       if (ulen && !ubuf)
+       if (!ulen ^ !ubuf)
                return -EINVAL;
 
        info->raw_tracepoint.tp_name_len = tp_len + 1;
index 232df29..99af4ce 100644 (file)
@@ -29,8 +29,9 @@ static struct task_struct *task_seq_get_next(struct pid_namespace *ns,
 
        rcu_read_lock();
 retry:
-       pid = idr_get_next(&ns->idr, tid);
+       pid = find_ge_pid(*tid, ns);
        if (pid) {
+               *tid = pid_nr_ns(pid, ns);
                task = get_pid_task(pid, PIDTYPE_PID);
                if (!task) {
                        ++*tid;
@@ -178,10 +179,11 @@ again:
                f = fcheck_files(curr_files, curr_fd);
                if (!f)
                        continue;
+               if (!get_file_rcu(f))
+                       continue;
 
                /* set info->fd */
                info->fd = curr_fd;
-               get_file(f);
                rcu_read_unlock();
                return f;
        }
index ef938f1..47e74f0 100644 (file)
@@ -5236,7 +5236,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env,
                                off_reg == dst_reg ? dst : src);
                        return -EACCES;
                }
-               /* fall-through */
+               fallthrough;
        default:
                break;
        }
@@ -10988,7 +10988,7 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
        default:
                if (!prog_extension)
                        return -EINVAL;
-               /* fallthrough */
+               fallthrough;
        case BPF_MODIFY_RETURN:
        case BPF_LSM_MAC:
        case BPF_TRACE_FENTRY:
index 1444f39..7c59b09 100644 (file)
@@ -93,7 +93,7 @@ static int cap_validate_magic(cap_user_header_t header, unsigned *tocopy)
                break;
        case _LINUX_CAPABILITY_VERSION_2:
                warn_deprecated_v2();
-               /* fall through - v3 is otherwise equivalent to v2. */
+               fallthrough;    /* v3 is otherwise equivalent to v2 */
        case _LINUX_CAPABILITY_VERSION_3:
                *tocopy = _LINUX_CAPABILITY_U32S_3;
                break;
index b8d2800..05adfd6 100644 (file)
@@ -255,11 +255,11 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat)
                return -EFAULT;
        switch (_NSIG_WORDS) {
        case 4: set->sig[3] = v.sig[6] | (((long)v.sig[7]) << 32 );
-               /* fall through */
+               fallthrough;
        case 3: set->sig[2] = v.sig[4] | (((long)v.sig[5]) << 32 );
-               /* fall through */
+               fallthrough;
        case 2: set->sig[1] = v.sig[2] | (((long)v.sig[3]) << 32 );
-               /* fall through */
+               fallthrough;
        case 1: set->sig[0] = v.sig[0] | (((long)v.sig[1]) << 32 );
        }
 #else
index a790026..cc3c43d 100644 (file)
@@ -1046,14 +1046,14 @@ int gdb_serial_stub(struct kgdb_state *ks)
                                return DBG_PASS_EVENT;
                        }
 #endif
-                       /* Fall through */
+                       fallthrough;
                case 'C': /* Exception passing */
                        tmp = gdb_cmd_exception_pass(ks);
                        if (tmp > 0)
                                goto default_handle;
                        if (tmp == 0)
                                break;
-                       /* Fall through - on tmp < 0 */
+                       fallthrough;    /* on tmp < 0 */
                case 'c': /* Continue packet */
                case 's': /* Single step packet */
                        if (kgdb_contthread && kgdb_contthread != current) {
@@ -1062,7 +1062,7 @@ int gdb_serial_stub(struct kgdb_state *ks)
                                break;
                        }
                        dbg_activate_sw_breakpoints();
-                       /* Fall through - to default processing */
+                       fallthrough;    /* to default processing */
                default:
 default_handle:
                        error = kgdb_arch_handle_exception(ks->ex_vector,
index 750497b..f877a0a 100644 (file)
@@ -173,11 +173,11 @@ int kdb_get_kbd_char(void)
        case KT_LATIN:
                if (isprint(keychar))
                        break;          /* printable characters */
-               /* fall through */
+               fallthrough;
        case KT_SPEC:
                if (keychar == K_ENTER)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                return -1;      /* ignore unprintables */
        }
index 004c5b6..6226502 100644 (file)
@@ -432,7 +432,7 @@ int kdb_getphysword(unsigned long *word, unsigned long addr, size_t size)
                                *word = w8;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                diag = KDB_BADWIDTH;
                kdb_printf("kdb_getphysword: bad width %ld\n", (long) size);
@@ -481,7 +481,7 @@ int kdb_getword(unsigned long *word, unsigned long addr, size_t size)
                                *word = w8;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                diag = KDB_BADWIDTH;
                kdb_printf("kdb_getword: bad width %ld\n", (long) size);
@@ -525,7 +525,7 @@ int kdb_putword(unsigned long addr, unsigned long word, size_t size)
                        diag = kdb_putarea(addr, w8);
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                diag = KDB_BADWIDTH;
                kdb_printf("kdb_putword: bad width %ld\n", (long) size);
index bb0041e..db6ef07 100644 (file)
@@ -43,7 +43,7 @@ u64 dma_direct_get_required_mask(struct device *dev)
        return (1ULL << (fls64(max_dma) - 1)) * 2 - 1;
 }
 
-gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
+static gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
                                  u64 *phys_limit)
 {
        u64 dma_limit = min_not_zero(dma_mask, dev->bus_dma_limit);
@@ -68,7 +68,7 @@ gfp_t dma_direct_optimal_gfp_mask(struct device *dev, u64 dma_mask,
        return 0;
 }
 
-bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
+static bool dma_coherent_ok(struct device *dev, phys_addr_t phys, size_t size)
 {
        return phys_to_dma_direct(dev, phys) + size - 1 <=
                        min_not_zero(dev->coherent_dma_mask, dev->bus_dma_limit);
@@ -161,8 +161,13 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size,
        size = PAGE_ALIGN(size);
 
        if (dma_should_alloc_from_pool(dev, gfp, attrs)) {
-               ret = dma_alloc_from_pool(dev, size, &page, gfp);
-               if (!ret)
+               u64 phys_mask;
+
+               gfp |= dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
+                               &phys_mask);
+               page = dma_alloc_from_pool(dev, size, &ret, gfp,
+                               dma_coherent_ok);
+               if (!page)
                        return NULL;
                goto done;
        }
index 6bc74a2..1281c0f 100644 (file)
@@ -3,7 +3,9 @@
  * Copyright (C) 2012 ARM Ltd.
  * Copyright (C) 2020 Google LLC
  */
+#include <linux/cma.h>
 #include <linux/debugfs.h>
+#include <linux/dma-contiguous.h>
 #include <linux/dma-direct.h>
 #include <linux/dma-noncoherent.h>
 #include <linux/init.h>
@@ -55,11 +57,34 @@ static void dma_atomic_pool_size_add(gfp_t gfp, size_t size)
                pool_size_kernel += size;
 }
 
+static bool cma_in_zone(gfp_t gfp)
+{
+       unsigned long size;
+       phys_addr_t end;
+       struct cma *cma;
+
+       cma = dev_get_cma_area(NULL);
+       if (!cma)
+               return false;
+
+       size = cma_get_size(cma);
+       if (!size)
+               return false;
+
+       /* CMA can't cross zone boundaries, see cma_activate_area() */
+       end = cma_get_base(cma) + size - 1;
+       if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
+               return end <= DMA_BIT_MASK(zone_dma_bits);
+       if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
+               return end <= DMA_BIT_MASK(32);
+       return true;
+}
+
 static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
                              gfp_t gfp)
 {
        unsigned int order;
-       struct page *page;
+       struct page *page = NULL;
        void *addr;
        int ret = -ENOMEM;
 
@@ -68,7 +93,11 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
 
        do {
                pool_size = 1 << (PAGE_SHIFT + order);
-               page = alloc_pages(gfp, order);
+               if (cma_in_zone(gfp))
+                       page = dma_alloc_from_contiguous(NULL, 1 << order,
+                                                        order, false);
+               if (!page)
+                       page = alloc_pages(gfp, order);
        } while (!page && order-- > 0);
        if (!page)
                goto out;
@@ -196,93 +225,75 @@ static int __init dma_atomic_pool_init(void)
 }
 postcore_initcall(dma_atomic_pool_init);
 
-static inline struct gen_pool *dma_guess_pool_from_device(struct device *dev)
+static inline struct gen_pool *dma_guess_pool(struct gen_pool *prev, gfp_t gfp)
 {
-       u64 phys_mask;
-       gfp_t gfp;
-
-       gfp = dma_direct_optimal_gfp_mask(dev, dev->coherent_dma_mask,
-                                         &phys_mask);
-       if (IS_ENABLED(CONFIG_ZONE_DMA) && gfp == GFP_DMA)
+       if (prev == NULL) {
+               if (IS_ENABLED(CONFIG_ZONE_DMA32) && (gfp & GFP_DMA32))
+                       return atomic_pool_dma32;
+               if (IS_ENABLED(CONFIG_ZONE_DMA) && (gfp & GFP_DMA))
+                       return atomic_pool_dma;
+               return atomic_pool_kernel;
+       }
+       if (prev == atomic_pool_kernel)
+               return atomic_pool_dma32 ? atomic_pool_dma32 : atomic_pool_dma;
+       if (prev == atomic_pool_dma32)
                return atomic_pool_dma;
-       if (IS_ENABLED(CONFIG_ZONE_DMA32) && gfp == GFP_DMA32)
-               return atomic_pool_dma32;
-       return atomic_pool_kernel;
+       return NULL;
 }
 
-static inline struct gen_pool *dma_get_safer_pool(struct gen_pool *bad_pool)
+static struct page *__dma_alloc_from_pool(struct device *dev, size_t size,
+               struct gen_pool *pool, void **cpu_addr,
+               bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
 {
-       if (bad_pool == atomic_pool_kernel)
-               return atomic_pool_dma32 ? : atomic_pool_dma;
+       unsigned long addr;
+       phys_addr_t phys;
 
-       if (bad_pool == atomic_pool_dma32)
-               return atomic_pool_dma;
+       addr = gen_pool_alloc(pool, size);
+       if (!addr)
+               return NULL;
 
-       return NULL;
-}
+       phys = gen_pool_virt_to_phys(pool, addr);
+       if (phys_addr_ok && !phys_addr_ok(dev, phys, size)) {
+               gen_pool_free(pool, addr, size);
+               return NULL;
+       }
 
-static inline struct gen_pool *dma_guess_pool(struct device *dev,
-                                             struct gen_pool *bad_pool)
-{
-       if (bad_pool)
-               return dma_get_safer_pool(bad_pool);
+       if (gen_pool_avail(pool) < atomic_pool_size)
+               schedule_work(&atomic_pool_work);
 
-       return dma_guess_pool_from_device(dev);
+       *cpu_addr = (void *)addr;
+       memset(*cpu_addr, 0, size);
+       return pfn_to_page(__phys_to_pfn(phys));
 }
 
-void *dma_alloc_from_pool(struct device *dev, size_t size,
-                         struct page **ret_page, gfp_t flags)
+struct page *dma_alloc_from_pool(struct device *dev, size_t size,
+               void **cpu_addr, gfp_t gfp,
+               bool (*phys_addr_ok)(struct device *, phys_addr_t, size_t))
 {
        struct gen_pool *pool = NULL;
-       unsigned long val = 0;
-       void *ptr = NULL;
-       phys_addr_t phys;
-
-       while (1) {
-               pool = dma_guess_pool(dev, pool);
-               if (!pool) {
-                       WARN(1, "Failed to get suitable pool for %s\n",
-                            dev_name(dev));
-                       break;
-               }
-
-               val = gen_pool_alloc(pool, size);
-               if (!val)
-                       continue;
-
-               phys = gen_pool_virt_to_phys(pool, val);
-               if (dma_coherent_ok(dev, phys, size))
-                       break;
-
-               gen_pool_free(pool, val, size);
-               val = 0;
-       }
-
-
-       if (val) {
-               *ret_page = pfn_to_page(__phys_to_pfn(phys));
-               ptr = (void *)val;
-               memset(ptr, 0, size);
+       struct page *page;
 
-               if (gen_pool_avail(pool) < atomic_pool_size)
-                       schedule_work(&atomic_pool_work);
+       while ((pool = dma_guess_pool(pool, gfp))) {
+               page = __dma_alloc_from_pool(dev, size, pool, cpu_addr,
+                                            phys_addr_ok);
+               if (page)
+                       return page;
        }
 
-       return ptr;
+       WARN(1, "Failed to get suitable pool for %s\n", dev_name(dev));
+       return NULL;
 }
 
 bool dma_free_from_pool(struct device *dev, void *start, size_t size)
 {
        struct gen_pool *pool = NULL;
 
-       while (1) {
-               pool = dma_guess_pool(dev, pool);
-               if (!pool)
-                       return false;
-
-               if (gen_pool_has_addr(pool, (unsigned long)start, size)) {
-                       gen_pool_free(pool, (unsigned long)start, size);
-                       return true;
-               }
+       while ((pool = dma_guess_pool(pool, 0))) {
+               if (!gen_pool_has_addr(pool, (unsigned long)start, size))
+                       continue;
+               gen_pool_free(pool, (unsigned long)start, size);
+               return true;
        }
+
+       return false;
 }
index 9852e0d..1868359 100644 (file)
@@ -65,25 +65,49 @@ static long syscall_trace_enter(struct pt_regs *regs, long syscall,
 
        syscall_enter_audit(regs, syscall);
 
-       return ret ? : syscall;
+       /* The above might have changed the syscall number */
+       return ret ? : syscall_get_nr(current, regs);
 }
 
-noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
+static __always_inline long
+__syscall_enter_from_user_work(struct pt_regs *regs, long syscall)
 {
        unsigned long ti_work;
 
-       enter_from_user_mode(regs);
-       instrumentation_begin();
-
-       local_irq_enable();
        ti_work = READ_ONCE(current_thread_info()->flags);
        if (ti_work & SYSCALL_ENTER_WORK)
                syscall = syscall_trace_enter(regs, syscall, ti_work);
-       instrumentation_end();
 
        return syscall;
 }
 
+long syscall_enter_from_user_mode_work(struct pt_regs *regs, long syscall)
+{
+       return __syscall_enter_from_user_work(regs, syscall);
+}
+
+noinstr long syscall_enter_from_user_mode(struct pt_regs *regs, long syscall)
+{
+       long ret;
+
+       enter_from_user_mode(regs);
+
+       instrumentation_begin();
+       local_irq_enable();
+       ret = __syscall_enter_from_user_work(regs, syscall);
+       instrumentation_end();
+
+       return ret;
+}
+
+noinstr void syscall_enter_from_user_mode_prepare(struct pt_regs *regs)
+{
+       enter_from_user_mode(regs);
+       instrumentation_begin();
+       local_irq_enable();
+       instrumentation_end();
+}
+
 /**
  * exit_to_user_mode - Fixup state when exiting to user mode
  *
index 5bfe8e3..7ed5248 100644 (file)
@@ -10034,7 +10034,7 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
                case IF_SRC_KERNELADDR:
                case IF_SRC_KERNEL:
                        kernel = 1;
-                       /* fall through */
+                       fallthrough;
 
                case IF_SRC_FILEADDR:
                case IF_SRC_FILE:
index 649fd53..0e18aaf 100644 (file)
@@ -205,7 +205,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
                try_to_free_swap(old_page);
        page_vma_mapped_walk_done(&pvmw);
 
-       if (vma->vm_flags & VM_LOCKED)
+       if ((vma->vm_flags & VM_LOCKED) && !PageCompound(old_page))
                munlock_vma_page(old_page);
        put_page(old_page);
 
index 4d32190..49677d6 100644 (file)
@@ -3014,7 +3014,7 @@ int unshare_files(struct files_struct **displaced)
 }
 
 int sysctl_max_threads(struct ctl_table *table, int write,
-                      void __user *buffer, size_t *lenp, loff_t *ppos)
+                      void *buffer, size_t *lenp, loff_t *ppos)
 {
        struct ctl_table t;
        int ret;
index 908fdf5..53c67c8 100644 (file)
@@ -19,7 +19,9 @@
 #include <linux/vmalloc.h>
 #include "gcov.h"
 
-#if (__GNUC__ >= 7)
+#if (__GNUC__ >= 10)
+#define GCOV_COUNTERS                  8
+#elif (__GNUC__ >= 7)
 #define GCOV_COUNTERS                  9
 #elif (__GNUC__ > 5) || (__GNUC__ == 5 && __GNUC_MINOR__ >= 1)
 #define GCOV_COUNTERS                  10
index a8e14c8..762a928 100644 (file)
@@ -173,7 +173,7 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags
 
                        __irq_wake_thread(desc, action);
 
-                       /* Fall through - to add to randomness */
+                       fallthrough;    /* to add to randomness */
                case IRQ_HANDLED:
                        *flags |= action->flags;
                        break;
index 52ac539..5df903f 100644 (file)
@@ -271,7 +271,7 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
        case IRQ_SET_MASK_OK:
        case IRQ_SET_MASK_OK_DONE:
                cpumask_copy(desc->irq_common_data.affinity, mask);
-               /* fall through */
+               fallthrough;
        case IRQ_SET_MASK_OK_NOCOPY:
                irq_validate_effective_affinity(data);
                irq_set_thread_affinity(desc);
@@ -868,7 +868,7 @@ int __irq_set_trigger(struct irq_desc *desc, unsigned long flags)
        case IRQ_SET_MASK_OK_DONE:
                irqd_clear(&desc->irq_data, IRQD_TRIGGER_MASK);
                irqd_set(&desc->irq_data, flags);
-               /* fall through */
+               fallthrough;
 
        case IRQ_SET_MASK_OK_NOCOPY:
                flags = irqd_get_trigger_type(&desc->irq_data);
index 30cc217..651a4ad 100644 (file)
@@ -380,6 +380,13 @@ int irq_matrix_alloc(struct irq_matrix *m, const struct cpumask *msk,
        unsigned int cpu, bit;
        struct cpumap *cm;
 
+       /*
+        * Not required in theory, but matrix_find_best_cpu() uses
+        * for_each_cpu() which ignores the cpumask on UP .
+        */
+       if (cpumask_empty(msk))
+               return -EINVAL;
+
        cpu = matrix_find_best_cpu(m, msk);
        if (cpu == UINT_MAX)
                return -ENOSPC;
index 95cb74f..4fb15fa 100644 (file)
@@ -684,12 +684,12 @@ bool kallsyms_show_value(const struct cred *cred)
        case 0:
                if (kallsyms_for_perf())
                        return true;
-       /* fallthrough */
+               fallthrough;
        case 1:
                if (security_capable(cred, &init_user_ns, CAP_SYSLOG,
                                     CAP_OPT_NOAUDIT) == 0)
                        return true;
-       /* fallthrough */
+               fallthrough;
        default:
                return false;
        }
index 2fad21d..54b74fa 100644 (file)
@@ -3756,7 +3756,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip)
 
 skip_checks:
        /* we'll do an OFF -> ON transition: */
-       this_cpu_write(hardirqs_enabled, 1);
+       __this_cpu_write(hardirqs_enabled, 1);
        trace->hardirq_enable_ip = ip;
        trace->hardirq_enable_event = ++trace->irq_events;
        debug_atomic_inc(hardirqs_on_events);
@@ -3795,7 +3795,7 @@ void noinstr lockdep_hardirqs_off(unsigned long ip)
                /*
                 * We have done an ON -> OFF transition:
                 */
-               this_cpu_write(hardirqs_enabled, 0);
+               __this_cpu_write(hardirqs_enabled, 0);
                trace->hardirq_disable_ip = ip;
                trace->hardirq_disable_event = ++trace->irq_events;
                debug_atomic_inc(hardirqs_off_events);
@@ -4977,6 +4977,8 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 {
        unsigned long flags;
 
+       trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip);
+
        if (unlikely(current->lockdep_recursion)) {
                /* XXX allow trylock from NMI ?!? */
                if (lockdep_nmi() && !trylock) {
@@ -5001,7 +5003,6 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
        check_flags(flags);
 
        current->lockdep_recursion++;
-       trace_lock_acquire(lock, subclass, trylock, read, check, nest_lock, ip);
        __lock_acquire(lock, subclass, trylock, read, check,
                       irqs_disabled_flags(flags), nest_lock, ip, 0, 0);
        lockdep_recursion_finish();
@@ -5013,13 +5014,15 @@ void lock_release(struct lockdep_map *lock, unsigned long ip)
 {
        unsigned long flags;
 
+       trace_lock_release(lock, ip);
+
        if (unlikely(current->lockdep_recursion))
                return;
 
        raw_local_irq_save(flags);
        check_flags(flags);
+
        current->lockdep_recursion++;
-       trace_lock_release(lock, ip);
        if (__lock_release(lock, ip))
                check_chain_key(current);
        lockdep_recursion_finish();
@@ -5205,8 +5208,6 @@ __lock_acquired(struct lockdep_map *lock, unsigned long ip)
                hlock->holdtime_stamp = now;
        }
 
-       trace_lock_acquired(lock, ip);
-
        stats = get_lock_stats(hlock_class(hlock));
        if (waittime) {
                if (hlock->read)
@@ -5225,6 +5226,8 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
 {
        unsigned long flags;
 
+       trace_lock_acquired(lock, ip);
+
        if (unlikely(!lock_stat || !debug_locks))
                return;
 
@@ -5234,7 +5237,6 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
        raw_local_irq_save(flags);
        check_flags(flags);
        current->lockdep_recursion++;
-       trace_lock_contended(lock, ip);
        __lock_contended(lock, ip);
        lockdep_recursion_finish();
        raw_local_irq_restore(flags);
@@ -5245,6 +5247,8 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip)
 {
        unsigned long flags;
 
+       trace_lock_contended(lock, ip);
+
        if (unlikely(!lock_stat || !debug_locks))
                return;
 
index 16cb894..d4d3ba6 100644 (file)
@@ -215,12 +215,13 @@ int padata_do_parallel(struct padata_shell *ps,
        padata->pd = pd;
        padata->cb_cpu = *cb_cpu;
 
-       rcu_read_unlock_bh();
-
        spin_lock(&padata_works_lock);
        padata->seq_nr = ++pd->seq_nr;
        pw = padata_work_alloc();
        spin_unlock(&padata_works_lock);
+
+       rcu_read_unlock_bh();
+
        if (pw) {
                padata_work_init(pw, padata_parallel_worker, padata, 0);
                queue_work(pinst->parallel_wq, &pw->pw_work);
index f33769f..e7aa57f 100644 (file)
@@ -659,7 +659,7 @@ static void power_down(void)
                break;
        case HIBERNATION_PLATFORM:
                hibernation_platform_enter();
-               /* Fall through */
+               fallthrough;
        case HIBERNATION_SHUTDOWN:
                if (pm_power_off)
                        kernel_power_off();
index db0bed2..ec7e1e8 100644 (file)
@@ -119,7 +119,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
                 * and add, then see if the aggregate has changed.
                 */
                plist_del(node, &c->list);
-               /* fall through */
+               fallthrough;
        case PM_QOS_ADD_REQ:
                plist_node_init(node, new_value);
                plist_add(node, &c->list);
@@ -188,7 +188,7 @@ bool pm_qos_update_flags(struct pm_qos_flags *pqf,
                break;
        case PM_QOS_UPDATE_REQ:
                pm_qos_flags_remove_req(pqf, req);
-               /* fall through */
+               fallthrough;
        case PM_QOS_ADD_REQ:
                req->flags = val;
                INIT_LIST_HEAD(&req->node);
index 72fe443..fb4e0c5 100644 (file)
@@ -197,6 +197,7 @@ free_buf:
 static void relay_destroy_channel(struct kref *kref)
 {
        struct rchan *chan = container_of(kref, struct rchan, kref);
+       free_percpu(chan->buf);
        kfree(chan);
 }
 
index 8471a0f..2d95dc3 100644 (file)
@@ -2320,7 +2320,7 @@ static int select_fallback_rq(int cpu, struct task_struct *p)
                                state = possible;
                                break;
                        }
-                       /* Fall-through */
+                       fallthrough;
                case possible:
                        do_set_cpus_allowed(p, cpu_possible_mask);
                        state = fail;
index 6bf3498..f324dc3 100644 (file)
@@ -54,17 +54,18 @@ __setup("hlt", cpu_idle_nopoll_setup);
 
 static noinline int __cpuidle cpu_idle_poll(void)
 {
+       trace_cpu_idle(0, smp_processor_id());
+       stop_critical_timings();
        rcu_idle_enter();
-       trace_cpu_idle_rcuidle(0, smp_processor_id());
        local_irq_enable();
-       stop_critical_timings();
 
        while (!tif_need_resched() &&
-               (cpu_idle_force_poll || tick_check_broadcast_expired()))
+              (cpu_idle_force_poll || tick_check_broadcast_expired()))
                cpu_relax();
-       start_critical_timings();
-       trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
+
        rcu_idle_exit();
+       start_critical_timings();
+       trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
 
        return 1;
 }
@@ -90,9 +91,14 @@ void __cpuidle default_idle_call(void)
        if (current_clr_polling_and_test()) {
                local_irq_enable();
        } else {
+
+               trace_cpu_idle(1, smp_processor_id());
                stop_critical_timings();
+               rcu_idle_enter();
                arch_cpu_idle();
+               rcu_idle_exit();
                start_critical_timings();
+               trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
        }
 }
 
@@ -158,7 +164,6 @@ static void cpuidle_idle_call(void)
 
        if (cpuidle_not_available(drv, dev)) {
                tick_nohz_idle_stop_tick();
-               rcu_idle_enter();
 
                default_idle_call();
                goto exit_idle;
@@ -178,21 +183,17 @@ static void cpuidle_idle_call(void)
                u64 max_latency_ns;
 
                if (idle_should_enter_s2idle()) {
-                       rcu_idle_enter();
 
                        entered_state = call_cpuidle_s2idle(drv, dev);
                        if (entered_state > 0)
                                goto exit_idle;
 
-                       rcu_idle_exit();
-
                        max_latency_ns = U64_MAX;
                } else {
                        max_latency_ns = dev->forced_idle_latency_limit_ns;
                }
 
                tick_nohz_idle_stop_tick();
-               rcu_idle_enter();
 
                next_state = cpuidle_find_deepest_state(drv, dev, max_latency_ns);
                call_cpuidle(drv, dev, next_state);
@@ -209,8 +210,6 @@ static void cpuidle_idle_call(void)
                else
                        tick_nohz_idle_retain_tick();
 
-               rcu_idle_enter();
-
                entered_state = call_cpuidle(drv, dev, next_state);
                /*
                 * Give the governor an opportunity to reflect on the outcome
@@ -226,8 +225,6 @@ exit_idle:
         */
        if (WARN_ON_ONCE(irqs_disabled()))
                local_irq_enable();
-
-       rcu_idle_exit();
 }
 
 /*
index 007b0a6..1bd7e3a 100644 (file)
@@ -1219,13 +1219,13 @@ static void __free_domain_allocs(struct s_data *d, enum s_alloc what,
        case sa_rootdomain:
                if (!atomic_read(&d->rd->refcount))
                        free_rootdomain(&d->rd->rcu);
-               /* Fall through */
+               fallthrough;
        case sa_sd:
                free_percpu(d->sd);
-               /* Fall through */
+               fallthrough;
        case sa_sd_storage:
                __sdt_free(cpu_map);
-               /* Fall through */
+               fallthrough;
        case sa_none:
                break;
        }
index 3ee59ce..676d4af 100644 (file)
@@ -1109,13 +1109,18 @@ out:
 }
 
 #ifdef CONFIG_SECCOMP_FILTER
-static int seccomp_notify_release(struct inode *inode, struct file *file)
+static void seccomp_notify_free(struct seccomp_filter *filter)
+{
+       kfree(filter->notif);
+       filter->notif = NULL;
+}
+
+static void seccomp_notify_detach(struct seccomp_filter *filter)
 {
-       struct seccomp_filter *filter = file->private_data;
        struct seccomp_knotif *knotif;
 
        if (!filter)
-               return 0;
+               return;
 
        mutex_lock(&filter->notify_lock);
 
@@ -1139,9 +1144,15 @@ static int seccomp_notify_release(struct inode *inode, struct file *file)
                complete(&knotif->ready);
        }
 
-       kfree(filter->notif);
-       filter->notif = NULL;
+       seccomp_notify_free(filter);
        mutex_unlock(&filter->notify_lock);
+}
+
+static int seccomp_notify_release(struct inode *inode, struct file *file)
+{
+       struct seccomp_filter *filter = file->private_data;
+
+       seccomp_notify_detach(filter);
        __put_seccomp_filter(filter);
        return 0;
 }
@@ -1488,7 +1499,7 @@ static struct file *init_listener(struct seccomp_filter *filter)
 
 out_notif:
        if (IS_ERR(ret))
-               kfree(filter->notif);
+               seccomp_notify_free(filter);
 out:
        return ret;
 }
@@ -1581,6 +1592,7 @@ out_put_fd:
                        listener_f->private_data = NULL;
                        fput(listener_f);
                        put_unused_fd(listener);
+                       seccomp_notify_detach(prepared);
                } else {
                        fd_install(listener, listener_f);
                        ret = listener;
index 42b67d2..a38b3ed 100644 (file)
@@ -851,7 +851,7 @@ static int check_kill_permission(int sig, struct kernel_siginfo *info,
                         */
                        if (!sid || sid == task_session(current))
                                break;
-                       /* fall through */
+                       fallthrough;
                default:
                        return -EPERM;
                }
index ca11af9..ab6c409 100644 (file)
@@ -1753,7 +1753,7 @@ void getrusage(struct task_struct *p, int who, struct rusage *r)
 
                if (who == RUSAGE_CHILDREN)
                        break;
-               /* fall through */
+               fallthrough;
 
        case RUSAGE_SELF:
                thread_group_cputime_adjusted(p, &tgutime, &tgstime);
index 287862f..09e70ee 100644 (file)
@@ -204,8 +204,7 @@ static int max_extfrag_threshold = 1000;
 
 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
 static int bpf_stats_handler(struct ctl_table *table, int write,
-                            void __user *buffer, size_t *lenp,
-                            loff_t *ppos)
+                            void *buffer, size_t *lenp, loff_t *ppos)
 {
        struct static_key *key = (struct static_key *)table->data;
        static int saved_val;
index c403851..95b6a70 100644 (file)
@@ -377,7 +377,7 @@ static bool hrtimer_fixup_activate(void *addr, enum debug_obj_state state)
        switch (state) {
        case ODEBUG_STATE_ACTIVE:
                WARN_ON(1);
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
index 07709ac..bf540f5 100644 (file)
@@ -439,12 +439,12 @@ static struct pid *good_sigevent(sigevent_t * event)
                rtn = pid_task(pid, PIDTYPE_PID);
                if (!rtn || !same_thread_group(rtn, current))
                        return NULL;
-               /* FALLTHRU */
+               fallthrough;
        case SIGEV_SIGNAL:
        case SIGEV_THREAD:
                if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)
                        return NULL;
-               /* FALLTHRU */
+               fallthrough;
        case SIGEV_NONE:
                return pid;
        default:
index e51778c..36d7464 100644 (file)
@@ -381,7 +381,7 @@ void tick_broadcast_control(enum tick_broadcast_mode mode)
        switch (mode) {
        case TICK_BROADCAST_FORCE:
                tick_broadcast_forced = 1;
-               /* fall through */
+               fallthrough;
        case TICK_BROADCAST_ON:
                cpumask_set_cpu(cpu, tick_broadcast_on);
                if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) {
index a16764b..a50364d 100644 (file)
@@ -666,7 +666,7 @@ static bool timer_fixup_activate(void *addr, enum debug_obj_state state)
 
        case ODEBUG_STATE_ACTIVE:
                WARN_ON(1);
-               /* fall through */
+               fallthrough;
        default:
                return false;
        }
index 7ba62d6..4b3a42f 100644 (file)
@@ -745,7 +745,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
 #endif
        case BLKTRACESTART:
                start = 1;
-               /* fall through */
+               fallthrough;
        case BLKTRACESTOP:
                ret = __blk_trace_startstop(q, start);
                break;
index bf44f6b..78a678e 100644 (file)
@@ -499,7 +499,7 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
                                        ptr++;
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
                        default:
                                parse_error(pe, FILT_ERR_TOO_MANY_PREDS,
                                            next - str);
@@ -1273,7 +1273,7 @@ static int parse_pred(const char *str, void *data,
                switch (op) {
                case OP_NE:
                        pred->not = 1;
-                       /* Fall through */
+                       fallthrough;
                case OP_GLOB:
                case OP_EQ:
                        break;
index f74020f..0ef8f65 100644 (file)
@@ -393,6 +393,7 @@ static void free_watch(struct rcu_head *rcu)
        struct watch *watch = container_of(rcu, struct watch, rcu);
 
        put_watch_queue(rcu_access_pointer(watch->queue));
+       atomic_dec(&watch->cred->user->nr_watches);
        put_cred(watch->cred);
 }
 
@@ -452,6 +453,13 @@ int add_watch_to_object(struct watch *watch, struct watch_list *wlist)
        watch->cred = get_current_cred();
        rcu_assign_pointer(watch->watch_list, wlist);
 
+       if (atomic_inc_return(&watch->cred->user->nr_watches) >
+           task_rlimit(current, RLIMIT_NOFILE)) {
+               atomic_dec(&watch->cred->user->nr_watches);
+               put_cred(watch->cred);
+               return -EAGAIN;
+       }
+
        spin_lock_bh(&wqueue->lock);
        kref_get(&wqueue->usage);
        kref_get(&watch->usage);
index e290fc5..a4a4c68 100644 (file)
@@ -15,11 +15,16 @@ KCOV_INSTRUMENT_debugobjects.o := n
 KCOV_INSTRUMENT_dynamic_debug.o := n
 KCOV_INSTRUMENT_fault-inject.o := n
 
+# string.o implements standard library functions like memset/memcpy etc.
+# Use -ffreestanding to ensure that the compiler does not try to "optimize"
+# them into calls to themselves.
+CFLAGS_string.o := -ffreestanding
+
 # Early boot use of cmdline, don't instrument it
 ifdef CONFIG_AMD_MEM_ENCRYPT
 KASAN_SANITIZE_string.o := n
 
-CFLAGS_string.o := -fno-stack-protector
+CFLAGS_string.o += -fno-stack-protector
 endif
 
 # Used by KCSAN while enabled, avoid recursion.
index a5f7011..2c905a9 100644 (file)
@@ -817,7 +817,7 @@ int __init xbc_init(char *buf, const char **emsg, int *epos)
                                                        q - 2);
                                break;
                        }
-                       /* Fall through */
+                       /* fall through */
                case '=':
                        ret = xbc_parse_kv(&p, q, c);
                        break;
index 1d012e5..2d4dfd4 100644 (file)
@@ -353,8 +353,7 @@ static int check_set(const char **dest, char *src, char *name)
 
 /*
  * Parse words[] as a ddebug query specification, which is a series
- * of (keyword, value) pairs or combined keyword=value terms,
- * chosen from these possibilities:
+ * of (keyword, value) pairs chosen from these possibilities:
  *
  * func <function-name>
  * file <full-pathname>
@@ -373,34 +372,22 @@ static int ddebug_parse_query(char *words[], int nwords,
        unsigned int i;
        int rc = 0;
        char *fline;
-       char *keyword, *arg;
+
+       /* check we have an even number of words */
+       if (nwords % 2 != 0) {
+               pr_err("expecting pairs of match-spec <value>\n");
+               return -EINVAL;
+       }
 
        if (modname)
                /* support $modname.dyndbg=<multiple queries> */
                query->module = modname;
 
-       for (i = 0; i < nwords; i++) {
-               /* accept keyword=arg */
-               vpr_info("%d w:%s\n", i, words[i]);
-
-               keyword = words[i];
-               arg = strchr(keyword, '=');
-               if (arg) {
-                       *arg++ = '\0';
-               } else {
-                       i++; /* next word is arg */
-                       if (!(i < nwords)) {
-                               pr_err("missing arg to keyword: %s\n", keyword);
-                               return -EINVAL;
-                       }
-                       arg = words[i];
-               }
-               vpr_info("%d key:%s arg:%s\n", i, keyword, arg);
-
-               if (!strcmp(keyword, "func")) {
-                       rc = check_set(&query->function, arg, "func");
-               } else if (!strcmp(keyword, "file")) {
-                       if (check_set(&query->filename, arg, "file"))
+       for (i = 0; i < nwords; i += 2) {
+               if (!strcmp(words[i], "func")) {
+                       rc = check_set(&query->function, words[i+1], "func");
+               } else if (!strcmp(words[i], "file")) {
+                       if (check_set(&query->filename, words[i+1], "file"))
                                return -EINVAL;
 
                        /* tail :$info is function or line-range */
@@ -416,18 +403,18 @@ static int ddebug_parse_query(char *words[], int nwords,
                                if (parse_linerange(query, fline))
                                        return -EINVAL;
                        }
-               } else if (!strcmp(keyword, "module")) {
-                       rc = check_set(&query->module, arg, "module");
-               } else if (!strcmp(keyword, "format")) {
-                       string_unescape_inplace(arg, UNESCAPE_SPACE |
+               } else if (!strcmp(words[i], "module")) {
+                       rc = check_set(&query->module, words[i+1], "module");
+               } else if (!strcmp(words[i], "format")) {
+                       string_unescape_inplace(words[i+1], UNESCAPE_SPACE |
                                                            UNESCAPE_OCTAL |
                                                            UNESCAPE_SPECIAL);
-                       rc = check_set(&query->format, arg, "format");
-               } else if (!strcmp(keyword, "line")) {
-                       if (parse_linerange(query, arg))
+                       rc = check_set(&query->format, words[i+1], "format");
+               } else if (!strcmp(words[i], "line")) {
+                       if (parse_linerange(query, words[i+1]))
                                return -EINVAL;
                } else {
-                       pr_err("unknown keyword \"%s\"\n", keyword);
+                       pr_err("unknown keyword \"%s\"\n", words[i]);
                        return -EINVAL;
                }
                if (rc)
@@ -525,7 +512,7 @@ static int ddebug_exec_query(char *query_string, const char *modname)
    last error or number of matching callsites.  Module name is either
    in param (for boot arg) or perhaps in query string.
 */
-int ddebug_exec_queries(char *query, const char *modname)
+static int ddebug_exec_queries(char *query, const char *modname)
 {
        char *split;
        int i, errs = 0, exitcode = 0, rc, nfound = 0;
@@ -557,7 +544,30 @@ int ddebug_exec_queries(char *query, const char *modname)
                return exitcode;
        return nfound;
 }
-EXPORT_SYMBOL_GPL(ddebug_exec_queries);
+
+/**
+ * dynamic_debug_exec_queries - select and change dynamic-debug prints
+ * @query: query-string described in admin-guide/dynamic-debug-howto
+ * @modname: string containing module name, usually &module.mod_name
+ *
+ * This uses the >/proc/dynamic_debug/control reader, allowing module
+ * authors to modify their dynamic-debug callsites. The modname is
+ * canonically struct module.mod_name, but can also be null or a
+ * module-wildcard, for example: "drm*".
+ */
+int dynamic_debug_exec_queries(const char *query, const char *modname)
+{
+       int rc;
+       char *qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL);
+
+       if (!query)
+               return -ENOMEM;
+
+       rc = ddebug_exec_queries(qry, modname);
+       kfree(qry);
+       return rc;
+}
+EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries);
 
 #define PREFIX_SIZE 64
 
@@ -947,7 +957,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
        list_add(&dt->link, &ddebug_tables);
        mutex_unlock(&ddebug_lock);
 
-       v2pr_info("%u debug prints in module %s\n", n, dt->mod_name);
+       v2pr_info("%3u debug prints in module %s\n", n, dt->mod_name);
        return 0;
 }
 
index 0ba3ea8..52e3ed7 100644 (file)
@@ -102,7 +102,7 @@ bool __pure glob_match(char const *pat, char const *str)
                        break;
                case '\\':
                        d = *pat++;
-                       /*FALLTHROUGH*/
+                       /* fall through */
                default:        /* Literal character */
 literal:
                        if (c == d) {
index 3afb939..ea53b30 100644 (file)
@@ -604,9 +604,6 @@ static void __kobject_del(struct kobject *kobj)
        struct kernfs_node *sd;
        const struct kobj_type *ktype;
 
-       if (!kobj)
-               return;
-
        sd = kobj->sd;
        ktype = get_ktype(kobj);
 
@@ -637,8 +634,12 @@ static void __kobject_del(struct kobject *kobj)
  */
 void kobject_del(struct kobject *kobj)
 {
-       struct kobject *parent = kobj->parent;
+       struct kobject *parent;
+
+       if (!kobj)
+               return;
 
+       parent = kobj->parent;
        __kobject_del(kobj);
        kobject_put(parent);
 }
index 9fee2b9..06c9550 100644 (file)
@@ -26,6 +26,8 @@
 #include <linux/vmalloc.h>
 #include <linux/efi_embedded_fw.h>
 
+MODULE_IMPORT_NS(TEST_FIRMWARE);
+
 #define TEST_FIRMWARE_NAME     "test-firmware.bin"
 #define TEST_FIRMWARE_NUM_REQS 4
 #define TEST_FIRMWARE_BUF_SIZE SZ_1K
@@ -489,6 +491,9 @@ out:
 static DEVICE_ATTR_WO(trigger_request);
 
 #ifdef CONFIG_EFI_EMBEDDED_FIRMWARE
+extern struct list_head efi_embedded_fw_list;
+extern bool efi_embedded_fw_checked;
+
 static ssize_t trigger_request_platform_store(struct device *dev,
                                              struct device_attribute *attr,
                                              const char *buf, size_t count)
@@ -501,6 +506,7 @@ static ssize_t trigger_request_platform_store(struct device *dev,
        };
        struct efi_embedded_fw efi_embedded_fw;
        const struct firmware *firmware = NULL;
+       bool saved_efi_embedded_fw_checked;
        char *name;
        int rc;
 
@@ -513,6 +519,8 @@ static ssize_t trigger_request_platform_store(struct device *dev,
        efi_embedded_fw.data = (void *)test_data;
        efi_embedded_fw.length = sizeof(test_data);
        list_add(&efi_embedded_fw.list, &efi_embedded_fw_list);
+       saved_efi_embedded_fw_checked = efi_embedded_fw_checked;
+       efi_embedded_fw_checked = true;
 
        pr_info("loading '%s'\n", name);
        rc = firmware_request_platform(&firmware, name, dev);
@@ -530,6 +538,7 @@ static ssize_t trigger_request_platform_store(struct device *dev,
        rc = count;
 
 out:
+       efi_embedded_fw_checked = saved_efi_embedded_fw_checked;
        release_firmware(firmware);
        list_del(&efi_embedded_fw.list);
        kfree(name);
index c155769..afb9521 100644 (file)
@@ -1681,7 +1681,8 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
 
        switch (*(++fmt)) {
        case 'L':
-               uc = true;              /* fall-through */
+               uc = true;
+               /* fall through */
        case 'l':
                index = guid_index;
                break;
@@ -2218,7 +2219,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
        case 'S':
        case 's':
                ptr = dereference_symbol_descriptor(ptr);
-               /* Fallthrough */
+               /* fall through */
        case 'B':
                return symbol_string(buf, end, ptr, spec, fmt);
        case 'R':
@@ -2467,7 +2468,7 @@ qualifier:
                 * utility, treat it as any other invalid or
                 * unsupported format specifier.
                 */
-               /* Fall-through */
+               /* fall through */
 
        default:
                WARN_ONCE(1, "Please remove unsupported %%%c in format string\n", *fmt);
index 9f336bc..65a1aad 100644 (file)
@@ -1043,7 +1043,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
 
                        s->lzma2.sequence = SEQ_LZMA_PREPARE;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_LZMA_PREPARE:
                        if (s->lzma2.compressed < RC_INIT_BYTES)
@@ -1055,7 +1055,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
                        s->lzma2.compressed -= RC_INIT_BYTES;
                        s->lzma2.sequence = SEQ_LZMA_RUN;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_LZMA_RUN:
                        /*
index bd1d182..32ab2a0 100644 (file)
@@ -583,7 +583,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
                        if (ret != XZ_OK)
                                return ret;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_BLOCK_START:
                        /* We need one byte of input to continue. */
@@ -608,7 +608,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
                        s->temp.pos = 0;
                        s->sequence = SEQ_BLOCK_HEADER;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_BLOCK_HEADER:
                        if (!fill_temp(s, b))
@@ -620,7 +620,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_UNCOMPRESS;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_BLOCK_UNCOMPRESS:
                        ret = dec_block(s, b);
@@ -629,7 +629,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_PADDING;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_BLOCK_PADDING:
                        /*
@@ -651,7 +651,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_BLOCK_CHECK;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_BLOCK_CHECK:
                        if (s->check_type == XZ_CHECK_CRC32) {
@@ -675,7 +675,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_INDEX_PADDING;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_INDEX_PADDING:
                        while ((s->index.size + (b->in_pos - s->in_start))
@@ -699,7 +699,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
 
                        s->sequence = SEQ_INDEX_CRC32;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_INDEX_CRC32:
                        ret = crc32_validate(s, b);
@@ -709,7 +709,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
                        s->temp.size = STREAM_HEADER_SIZE;
                        s->sequence = SEQ_STREAM_FOOTER;
 
-               /* Fall through */
+                       /* fall through */
 
                case SEQ_STREAM_FOOTER:
                        if (!fill_temp(s, b))
index 269ee9a..db6761e 100644 (file)
@@ -442,7 +442,7 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx *dctx, const void *src, size_t srcSize
                case set_repeat:
                        if (dctx->litEntropy == 0)
                                return ERROR(dictionary_corrupted);
-               /* fall-through */
+                       /* fall through */
                case set_compressed:
                        if (srcSize < 5)
                                return ERROR(corruption_detected); /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for case 3 */
@@ -2309,7 +2309,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                switch (zds->stage) {
                case zdss_init:
                        ZSTD_resetDStream(zds); /* transparent reset on starting decoding a new frame */
-                                               /* fall-through */
+                       /* fall through */
 
                case zdss_loadHeader: {
                        size_t const hSize = ZSTD_getFrameParams(&zds->fParams, zds->headerBuffer, zds->lhSize);
@@ -2376,7 +2376,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                        }
                        zds->stage = zdss_read;
                }
-               /* fall through */
+                       /* fall through */
 
                case zdss_read: {
                        size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
@@ -2405,7 +2405,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                        zds->stage = zdss_load;
                        /* pass-through */
                }
-               /* fall through */
+                       /* fall through */
 
                case zdss_load: {
                        size_t const neededInSize = ZSTD_nextSrcSizeToDecompress(zds->dctx);
@@ -2438,7 +2438,7 @@ size_t ZSTD_decompressStream(ZSTD_DStream *zds, ZSTD_outBuffer *output, ZSTD_inB
                                /* pass-through */
                        }
                }
-               /* fall through */
+                       /* fall through */
 
                case zdss_flush: {
                        size_t const toFlushSize = zds->outEnd - zds->outStart;
index ae096ea..e5739a1 100644 (file)
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -381,22 +381,13 @@ static int follow_pfn_pte(struct vm_area_struct *vma, unsigned long address,
 }
 
 /*
- * FOLL_FORCE or a forced COW break can write even to unwritable pte's,
- * but only after we've gone through a COW cycle and they are dirty.
+ * FOLL_FORCE can write to even unwritable pte's, but only
+ * after we've gone through a COW cycle and they are dirty.
  */
 static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
 {
-       return pte_write(pte) || ((flags & FOLL_COW) && pte_dirty(pte));
-}
-
-/*
- * A (separate) COW fault might break the page the other way and
- * get_user_pages() would return the page from what is now the wrong
- * VM. So we need to force a COW break at GUP time even for reads.
- */
-static inline bool should_force_cow_break(struct vm_area_struct *vma, unsigned int flags)
-{
-       return is_cow_mapping(vma->vm_flags) && (flags & (FOLL_GET | FOLL_PIN));
+       return pte_write(pte) ||
+               ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
 }
 
 static struct page *follow_page_pte(struct vm_area_struct *vma,
@@ -843,7 +834,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
                        goto unmap;
                *page = pte_page(*pte);
        }
-       if (unlikely(!try_get_page(*page))) {
+       if (unlikely(!try_grab_page(*page, gup_flags))) {
                ret = -ENOMEM;
                goto unmap;
        }
@@ -1067,11 +1058,9 @@ static long __get_user_pages(struct mm_struct *mm,
                                goto out;
                        }
                        if (is_vm_hugetlb_page(vma)) {
-                               if (should_force_cow_break(vma, foll_flags))
-                                       foll_flags |= FOLL_WRITE;
                                i = follow_hugetlb_page(mm, vma, pages, vmas,
                                                &start, &nr_pages, i,
-                                               foll_flags, locked);
+                                               gup_flags, locked);
                                if (locked && *locked == 0) {
                                        /*
                                         * We've got a VM_FAULT_RETRY
@@ -1085,10 +1074,6 @@ static long __get_user_pages(struct mm_struct *mm,
                                continue;
                        }
                }
-
-               if (should_force_cow_break(vma, foll_flags))
-                       foll_flags |= FOLL_WRITE;
-
 retry:
                /*
                 * If we have a pending SIGKILL, don't keep faulting pages and
@@ -2689,19 +2674,6 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages,
                return -EFAULT;
 
        /*
-        * The FAST_GUP case requires FOLL_WRITE even for pure reads,
-        * because get_user_pages() may need to cause an early COW in
-        * order to avoid confusing the normal COW routines. So only
-        * targets that are already writable are safe to do by just
-        * looking at the page tables.
-        *
-        * NOTE! With FOLL_FAST_ONLY we allow read-only gup_fast() here,
-        * because there is no slow path to fall back on. But you'd
-        * better be careful about possible COW pages - you'll get _a_
-        * COW page, but not necessarily the one you intended to get
-        * depending on what COW event happens after this. COW may break
-        * the page copy in a random direction.
-        *
         * Disable interrupts. The nested form is used, in order to allow
         * full, general purpose use of this routine.
         *
@@ -2714,8 +2686,6 @@ static int internal_get_user_pages_fast(unsigned long start, int nr_pages,
         */
        if (IS_ENABLED(CONFIG_HAVE_FAST_GUP) && gup_fast_permitted(start, end)) {
                unsigned long fast_flags = gup_flags;
-               if (!(gup_flags & FOLL_FAST_ONLY))
-                       fast_flags |= FOLL_WRITE;
 
                local_irq_save(flags);
                gup_pgd_range(addr, end, fast_flags, pages, &nr_pinned);
index 2ccff84..7ff29cc 100644 (file)
@@ -1291,12 +1291,13 @@ fallback:
 }
 
 /*
- * FOLL_FORCE or a forced COW break can write even to unwritable pmd's,
- * but only after we've gone through a COW cycle and they are dirty.
+ * FOLL_FORCE can write to even unwritable pmd's, but only
+ * after we've gone through a COW cycle and they are dirty.
  */
 static inline bool can_follow_write_pmd(pmd_t pmd, unsigned int flags)
 {
-       return pmd_write(pmd) || ((flags & FOLL_COW) && pmd_dirty(pmd));
+       return pmd_write(pmd) ||
+              ((flags & FOLL_FORCE) && (flags & FOLL_COW) && pmd_dirty(pmd));
 }
 
 struct page *follow_trans_huge_pmd(struct vm_area_struct *vma,
index a301c2d..67fc638 100644 (file)
@@ -1250,21 +1250,32 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask,
                int nid, nodemask_t *nodemask)
 {
        unsigned long nr_pages = 1UL << huge_page_order(h);
+       if (nid == NUMA_NO_NODE)
+               nid = numa_mem_id();
 
 #ifdef CONFIG_CMA
        {
                struct page *page;
                int node;
 
-               for_each_node_mask(node, *nodemask) {
-                       if (!hugetlb_cma[node])
-                               continue;
-
-                       page = cma_alloc(hugetlb_cma[node], nr_pages,
-                                        huge_page_order(h), true);
+               if (hugetlb_cma[nid]) {
+                       page = cma_alloc(hugetlb_cma[nid], nr_pages,
+                                       huge_page_order(h), true);
                        if (page)
                                return page;
                }
+
+               if (!(gfp_mask & __GFP_THISNODE)) {
+                       for_each_node_mask(node, *nodemask) {
+                               if (node == nid || !hugetlb_cma[node])
+                                       continue;
+
+                               page = cma_alloc(hugetlb_cma[node], nr_pages,
+                                               huge_page_order(h), true);
+                               if (page)
+                                       return page;
+                       }
+               }
        }
 #endif
 
@@ -3454,6 +3465,22 @@ static unsigned int allowed_mems_nr(struct hstate *h)
 }
 
 #ifdef CONFIG_SYSCTL
+static int proc_hugetlb_doulongvec_minmax(struct ctl_table *table, int write,
+                                         void *buffer, size_t *length,
+                                         loff_t *ppos, unsigned long *out)
+{
+       struct ctl_table dup_table;
+
+       /*
+        * In order to avoid races with __do_proc_doulongvec_minmax(), we
+        * can duplicate the @table and alter the duplicate of it.
+        */
+       dup_table = *table;
+       dup_table.data = out;
+
+       return proc_doulongvec_minmax(&dup_table, write, buffer, length, ppos);
+}
+
 static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
                         struct ctl_table *table, int write,
                         void *buffer, size_t *length, loff_t *ppos)
@@ -3465,9 +3492,8 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
        if (!hugepages_supported())
                return -EOPNOTSUPP;
 
-       table->data = &tmp;
-       table->maxlen = sizeof(unsigned long);
-       ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
+       ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos,
+                                            &tmp);
        if (ret)
                goto out;
 
@@ -3510,9 +3536,8 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
        if (write && hstate_is_gigantic(h))
                return -EINVAL;
 
-       table->data = &tmp;
-       table->maxlen = sizeof(unsigned long);
-       ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
+       ret = proc_hugetlb_doulongvec_minmax(table, write, buffer, length, ppos,
+                                            &tmp);
        if (ret)
                goto out;
 
index aabf65d..1f87aec 100644 (file)
@@ -655,7 +655,7 @@ static void __init __hugetlb_cgroup_file_dfl_init(int idx)
        snprintf(cft->name, MAX_CFTYPE_NAME, "%s.events", buf);
        cft->private = MEMFILE_PRIVATE(idx, 0);
        cft->seq_show = hugetlb_events_show;
-       cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]),
+       cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]);
        cft->flags = CFTYPE_NOT_ON_ROOT;
 
        /* Add the events.local file */
@@ -664,7 +664,7 @@ static void __init __hugetlb_cgroup_file_dfl_init(int idx)
        cft->private = MEMFILE_PRIVATE(idx, 0);
        cft->seq_show = hugetlb_events_local_show;
        cft->file_offset = offsetof(struct hugetlb_cgroup,
-                                   events_local_file[idx]),
+                                   events_local_file[idx]);
        cft->flags = CFTYPE_NOT_ON_ROOT;
 
        /* NULL terminate the last cft */
index 15a9af7..cfa0dba 100644 (file)
@@ -466,7 +466,7 @@ int __khugepaged_enter(struct mm_struct *mm)
                return -ENOMEM;
 
        /* __khugepaged_exit() must not run from under us */
-       VM_BUG_ON_MM(khugepaged_test_exit(mm), mm);
+       VM_BUG_ON_MM(atomic_read(&mm->mm_users) == 0, mm);
        if (unlikely(test_and_set_bit(MMF_VM_HUGEPAGE, &mm->flags))) {
                free_mm_slot(mm_slot);
                return 0;
@@ -1709,7 +1709,7 @@ static void collapse_file(struct mm_struct *mm,
                                xas_unlock_irq(&xas);
                                page_cache_sync_readahead(mapping, &file->f_ra,
                                                          file, index,
-                                                         PAGE_SIZE);
+                                                         end - index);
                                /* drain pagevecs to help isolate_lru_page() */
                                lru_add_drain();
                                page = find_lock_page(mapping, index);
index 0aa2247..235f55d 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2453,6 +2453,10 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
                if (vma_is_dax(vma))
                        return 0;
 
+#ifdef VM_SAO
+               if (*vm_flags & VM_SAO)
+                       return 0;
+#endif
 #ifdef VM_SPARC_ADI
                if (*vm_flags & VM_SPARC_ADI)
                        return 0;
@@ -2657,31 +2661,6 @@ again:
                goto again;
 }
 
-bool reuse_ksm_page(struct page *page,
-                   struct vm_area_struct *vma,
-                   unsigned long address)
-{
-#ifdef CONFIG_DEBUG_VM
-       if (WARN_ON(is_zero_pfn(page_to_pfn(page))) ||
-                       WARN_ON(!page_mapped(page)) ||
-                       WARN_ON(!PageLocked(page))) {
-               dump_page(page, "reuse_ksm_page");
-               return false;
-       }
-#endif
-
-       if (PageSwapCache(page) || !page_stable_node(page))
-               return false;
-       /* Prohibit parallel get_ksm_page() */
-       if (!page_ref_freeze(page, 1))
-               return false;
-
-       page_move_anon_rmap(page, vma);
-       page->index = linear_page_index(vma, address);
-       page_ref_unfreeze(page, 1);
-
-       return true;
-}
 #ifdef CONFIG_MIGRATION
 void ksm_migrate_page(struct page *newpage, struct page *oldpage)
 {
index dd1d43c..d4aa5f7 100644 (file)
@@ -289,9 +289,9 @@ static long madvise_willneed(struct vm_area_struct *vma,
         */
        *prev = NULL;   /* tell sys_madvise we drop mmap_lock */
        get_file(file);
-       mmap_read_unlock(current->mm);
        offset = (loff_t)(start - vma->vm_start)
                        + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
+       mmap_read_unlock(current->mm);
        vfs_fadvise(file, offset, end - start, POSIX_FADV_WILLNEED);
        fput(file);
        mmap_read_lock(current->mm);
index b807952..cfa6cba 100644 (file)
@@ -6774,6 +6774,9 @@ static void uncharge_batch(const struct uncharge_gather *ug)
        __this_cpu_add(ug->memcg->vmstats_percpu->nr_page_events, ug->nr_pages);
        memcg_check_events(ug->memcg, ug->dummy_page);
        local_irq_restore(flags);
+
+       /* drop reference from uncharge_page */
+       css_put(&ug->memcg->css);
 }
 
 static void uncharge_page(struct page *page, struct uncharge_gather *ug)
@@ -6797,6 +6800,9 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug)
                        uncharge_gather_clear(ug);
                }
                ug->memcg = page->mem_cgroup;
+
+               /* pairs with css_put in uncharge_batch */
+               css_get(&ug->memcg->css);
        }
 
        nr_pages = compound_nr(page);
index 3a7779d..469af37 100644 (file)
@@ -73,6 +73,7 @@
 #include <linux/numa.h>
 #include <linux/perf_event.h>
 #include <linux/ptrace.h>
+#include <linux/vmalloc.h>
 
 #include <trace/events/kmem.h>
 
@@ -83,6 +84,7 @@
 #include <asm/tlb.h>
 #include <asm/tlbflush.h>
 
+#include "pgalloc-track.h"
 #include "internal.h"
 
 #if defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) && !defined(CONFIG_COMPILE_TEST)
@@ -2206,7 +2208,8 @@ EXPORT_SYMBOL(vm_iomap_memory);
 
 static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
                                     unsigned long addr, unsigned long end,
-                                    pte_fn_t fn, void *data, bool create)
+                                    pte_fn_t fn, void *data, bool create,
+                                    pgtbl_mod_mask *mask)
 {
        pte_t *pte;
        int err = 0;
@@ -2214,7 +2217,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
 
        if (create) {
                pte = (mm == &init_mm) ?
-                       pte_alloc_kernel(pmd, addr) :
+                       pte_alloc_kernel_track(pmd, addr, mask) :
                        pte_alloc_map_lock(mm, pmd, addr, &ptl);
                if (!pte)
                        return -ENOMEM;
@@ -2235,6 +2238,7 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
                                break;
                }
        } while (addr += PAGE_SIZE, addr != end);
+       *mask |= PGTBL_PTE_MODIFIED;
 
        arch_leave_lazy_mmu_mode();
 
@@ -2245,7 +2249,8 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
 
 static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
                                     unsigned long addr, unsigned long end,
-                                    pte_fn_t fn, void *data, bool create)
+                                    pte_fn_t fn, void *data, bool create,
+                                    pgtbl_mod_mask *mask)
 {
        pmd_t *pmd;
        unsigned long next;
@@ -2254,7 +2259,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
        BUG_ON(pud_huge(*pud));
 
        if (create) {
-               pmd = pmd_alloc(mm, pud, addr);
+               pmd = pmd_alloc_track(mm, pud, addr, mask);
                if (!pmd)
                        return -ENOMEM;
        } else {
@@ -2264,7 +2269,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
                next = pmd_addr_end(addr, end);
                if (create || !pmd_none_or_clear_bad(pmd)) {
                        err = apply_to_pte_range(mm, pmd, addr, next, fn, data,
-                                                create);
+                                                create, mask);
                        if (err)
                                break;
                }
@@ -2274,14 +2279,15 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
 
 static int apply_to_pud_range(struct mm_struct *mm, p4d_t *p4d,
                                     unsigned long addr, unsigned long end,
-                                    pte_fn_t fn, void *data, bool create)
+                                    pte_fn_t fn, void *data, bool create,
+                                    pgtbl_mod_mask *mask)
 {
        pud_t *pud;
        unsigned long next;
        int err = 0;
 
        if (create) {
-               pud = pud_alloc(mm, p4d, addr);
+               pud = pud_alloc_track(mm, p4d, addr, mask);
                if (!pud)
                        return -ENOMEM;
        } else {
@@ -2291,7 +2297,7 @@ static int apply_to_pud_range(struct mm_struct *mm, p4d_t *p4d,
                next = pud_addr_end(addr, end);
                if (create || !pud_none_or_clear_bad(pud)) {
                        err = apply_to_pmd_range(mm, pud, addr, next, fn, data,
-                                                create);
+                                                create, mask);
                        if (err)
                                break;
                }
@@ -2301,14 +2307,15 @@ static int apply_to_pud_range(struct mm_struct *mm, p4d_t *p4d,
 
 static int apply_to_p4d_range(struct mm_struct *mm, pgd_t *pgd,
                                     unsigned long addr, unsigned long end,
-                                    pte_fn_t fn, void *data, bool create)
+                                    pte_fn_t fn, void *data, bool create,
+                                    pgtbl_mod_mask *mask)
 {
        p4d_t *p4d;
        unsigned long next;
        int err = 0;
 
        if (create) {
-               p4d = p4d_alloc(mm, pgd, addr);
+               p4d = p4d_alloc_track(mm, pgd, addr, mask);
                if (!p4d)
                        return -ENOMEM;
        } else {
@@ -2318,7 +2325,7 @@ static int apply_to_p4d_range(struct mm_struct *mm, pgd_t *pgd,
                next = p4d_addr_end(addr, end);
                if (create || !p4d_none_or_clear_bad(p4d)) {
                        err = apply_to_pud_range(mm, p4d, addr, next, fn, data,
-                                                create);
+                                                create, mask);
                        if (err)
                                break;
                }
@@ -2331,8 +2338,9 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
                                 void *data, bool create)
 {
        pgd_t *pgd;
-       unsigned long next;
+       unsigned long start = addr, next;
        unsigned long end = addr + size;
+       pgtbl_mod_mask mask = 0;
        int err = 0;
 
        if (WARN_ON(addr >= end))
@@ -2343,11 +2351,14 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
                next = pgd_addr_end(addr, end);
                if (!create && pgd_none_or_clear_bad(pgd))
                        continue;
-               err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, create);
+               err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, create, &mask);
                if (err)
                        break;
        } while (pgd++, addr = next, addr != end);
 
+       if (mask & ARCH_PAGE_TABLE_SYNC_MASK)
+               arch_sync_kernel_mappings(start, start + size);
+
        return err;
 }
 
@@ -2622,6 +2633,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf)
        if (ptep_set_access_flags(vma, vmf->address, vmf->pte, entry, 1))
                update_mmu_cache(vma, vmf->address, vmf->pte);
        pte_unmap_unlock(vmf->pte, vmf->ptl);
+       count_vm_event(PGREUSE);
 }
 
 /*
@@ -2927,50 +2939,25 @@ static vm_fault_t do_wp_page(struct vm_fault *vmf)
         * not dirty accountable.
         */
        if (PageAnon(vmf->page)) {
-               int total_map_swapcount;
-               if (PageKsm(vmf->page) && (PageSwapCache(vmf->page) ||
-                                          page_count(vmf->page) != 1))
+               struct page *page = vmf->page;
+
+               /* PageKsm() doesn't necessarily raise the page refcount */
+               if (PageKsm(page) || page_count(page) != 1)
+                       goto copy;
+               if (!trylock_page(page))
+                       goto copy;
+               if (PageKsm(page) || page_mapcount(page) != 1 || page_count(page) != 1) {
+                       unlock_page(page);
                        goto copy;
-               if (!trylock_page(vmf->page)) {
-                       get_page(vmf->page);
-                       pte_unmap_unlock(vmf->pte, vmf->ptl);
-                       lock_page(vmf->page);
-                       vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd,
-                                       vmf->address, &vmf->ptl);
-                       if (!pte_same(*vmf->pte, vmf->orig_pte)) {
-                               update_mmu_tlb(vma, vmf->address, vmf->pte);
-                               unlock_page(vmf->page);
-                               pte_unmap_unlock(vmf->pte, vmf->ptl);
-                               put_page(vmf->page);
-                               return 0;
-                       }
-                       put_page(vmf->page);
-               }
-               if (PageKsm(vmf->page)) {
-                       bool reused = reuse_ksm_page(vmf->page, vmf->vma,
-                                                    vmf->address);
-                       unlock_page(vmf->page);
-                       if (!reused)
-                               goto copy;
-                       wp_page_reuse(vmf);
-                       return VM_FAULT_WRITE;
-               }
-               if (reuse_swap_page(vmf->page, &total_map_swapcount)) {
-                       if (total_map_swapcount == 1) {
-                               /*
-                                * The page is all ours. Move it to
-                                * our anon_vma so the rmap code will
-                                * not search our parent or siblings.
-                                * Protected against the rmap code by
-                                * the page lock.
-                                */
-                               page_move_anon_rmap(vmf->page, vma);
-                       }
-                       unlock_page(vmf->page);
-                       wp_page_reuse(vmf);
-                       return VM_FAULT_WRITE;
                }
-               unlock_page(vmf->page);
+               /*
+                * Ok, we've got the only map reference, and the only
+                * page count reference, and the page is locked,
+                * it's dark out, and we're wearing sunglasses. Hit it.
+                */
+               wp_page_reuse(vmf);
+               unlock_page(page);
+               return VM_FAULT_WRITE;
        } else if (unlikely((vma->vm_flags & (VM_WRITE|VM_SHARED)) ==
                                        (VM_WRITE|VM_SHARED))) {
                return wp_page_shared(vmf);
@@ -4247,6 +4234,9 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
                                vmf->flags & FAULT_FLAG_WRITE)) {
                update_mmu_cache(vmf->vma, vmf->address, vmf->pte);
        } else {
+               /* Skip spurious TLB flush for retried page fault */
+               if (vmf->flags & FAULT_FLAG_TRIED)
+                       goto unlock;
                /*
                 * This is needed only for protection faults but the arch code
                 * is not yet telling us if this is a protection fault or not.
index 03e38b7..006dace 100644 (file)
@@ -216,7 +216,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
                        return ERR_PTR(-EINVAL);
                }
                break;
-       case MEMORY_DEVICE_DEVDAX:
+       case MEMORY_DEVICE_GENERIC:
                need_devmap_managed = false;
                break;
        case MEMORY_DEVICE_PCI_P2PDMA:
index 34a842a..941b893 100644 (file)
@@ -246,13 +246,13 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma,
                else if (pte_swp_uffd_wp(*pvmw.pte))
                        pte = pte_mkuffd_wp(pte);
 
-               if (unlikely(is_zone_device_page(new))) {
-                       if (is_device_private_page(new)) {
-                               entry = make_device_private_entry(new, pte_write(pte));
-                               pte = swp_entry_to_pte(entry);
-                               if (pte_swp_uffd_wp(*pvmw.pte))
-                                       pte = pte_mkuffd_wp(pte);
-                       }
+               if (unlikely(is_device_private_page(new))) {
+                       entry = make_device_private_entry(new, pte_write(pte));
+                       pte = swp_entry_to_pte(entry);
+                       if (pte_swp_soft_dirty(*pvmw.pte))
+                               pte = pte_swp_mksoft_dirty(pte);
+                       if (pte_swp_uffd_wp(*pvmw.pte))
+                               pte = pte_swp_mkuffd_wp(pte);
                }
 
 #ifdef CONFIG_HUGETLB_PAGE
@@ -2427,10 +2427,17 @@ again:
                        entry = make_migration_entry(page, mpfn &
                                                     MIGRATE_PFN_WRITE);
                        swp_pte = swp_entry_to_pte(entry);
-                       if (pte_soft_dirty(pte))
-                               swp_pte = pte_swp_mksoft_dirty(swp_pte);
-                       if (pte_uffd_wp(pte))
-                               swp_pte = pte_swp_mkuffd_wp(swp_pte);
+                       if (pte_present(pte)) {
+                               if (pte_soft_dirty(pte))
+                                       swp_pte = pte_swp_mksoft_dirty(swp_pte);
+                               if (pte_uffd_wp(pte))
+                                       swp_pte = pte_swp_mkuffd_wp(swp_pte);
+                       } else {
+                               if (pte_swp_soft_dirty(pte))
+                                       swp_pte = pte_swp_mksoft_dirty(swp_pte);
+                               if (pte_swp_uffd_wp(pte))
+                                       swp_pte = pte_swp_mkuffd_wp(swp_pte);
+                       }
                        set_pte_at(mm, addr, ptep, swp_pte);
 
                        /*
index 0e2bab4..fab5e97 100644 (file)
@@ -1302,6 +1302,11 @@ static void free_pcppages_bulk(struct zone *zone, int count,
        struct page *page, *tmp;
        LIST_HEAD(head);
 
+       /*
+        * Ensure proper count is passed which otherwise would stuck in the
+        * below while (list_empty(list)) loop.
+        */
+       count = min(pcp->count, count);
        while (count) {
                struct list_head *list;
 
@@ -7888,7 +7893,7 @@ int __meminit init_per_zone_wmark_min(void)
 
        return 0;
 }
-core_initcall(init_per_zone_wmark_min)
+postcore_initcall(init_per_zone_wmark_min)
 
 /*
  * min_free_kbytes_sysctl_handler - just a wrapper around proc_dointvec() so
index 83cc459..9425260 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1511,9 +1511,14 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                         */
                        entry = make_migration_entry(page, 0);
                        swp_pte = swp_entry_to_pte(entry);
-                       if (pte_soft_dirty(pteval))
+
+                       /*
+                        * pteval maps a zone device page and is therefore
+                        * a swap pte.
+                        */
+                       if (pte_swp_soft_dirty(pteval))
                                swp_pte = pte_swp_mksoft_dirty(swp_pte);
-                       if (pte_uffd_wp(pteval))
+                       if (pte_swp_uffd_wp(pteval))
                                swp_pte = pte_swp_mkuffd_wp(swp_pte);
                        set_pte_at(mm, pvmw.address, pvmw.pte, swp_pte);
                        /*
index 2a99df7..2613371 100644 (file)
@@ -7,6 +7,7 @@
  */
 #define pr_fmt(fmt) "rodata_test: " fmt
 
+#include <linux/rodata_test.h>
 #include <linux/uaccess.h>
 #include <asm/sections.h>
 
index 68c02b2..d4177ae 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -672,12 +672,12 @@ static void slab_fix(struct kmem_cache *s, char *fmt, ...)
 }
 
 static bool freelist_corrupted(struct kmem_cache *s, struct page *page,
-                              void *freelist, void *nextfree)
+                              void **freelist, void *nextfree)
 {
        if ((s->flags & SLAB_CONSISTENCY_CHECKS) &&
-           !check_valid_pointer(s, page, nextfree)) {
-               object_err(s, page, freelist, "Freechain corrupt");
-               freelist = NULL;
+           !check_valid_pointer(s, page, nextfree) && freelist) {
+               object_err(s, page, *freelist, "Freechain corrupt");
+               *freelist = NULL;
                slab_fix(s, "Isolate corrupted freechain");
                return true;
        }
@@ -1494,7 +1494,7 @@ static inline void dec_slabs_node(struct kmem_cache *s, int node,
                                                        int objects) {}
 
 static bool freelist_corrupted(struct kmem_cache *s, struct page *page,
-                              void *freelist, void *nextfree)
+                              void **freelist, void *nextfree)
 {
        return false;
 }
@@ -2184,7 +2184,7 @@ static void deactivate_slab(struct kmem_cache *s, struct page *page,
                 * 'freelist' is already corrupted.  So isolate all objects
                 * starting at 'freelist'.
                 */
-               if (freelist_corrupted(s, page, freelist, nextfree))
+               if (freelist_corrupted(s, page, &freelist, nextfree))
                        break;
 
                do {
index b482d24..be4724b 100644 (file)
@@ -104,6 +104,8 @@ static void vunmap_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,
                if (pmd_none_or_clear_bad(pmd))
                        continue;
                vunmap_pte_range(pmd, addr, next, mask);
+
+               cond_resched();
        } while (pmd++, addr = next, addr != end);
 }
 
index 99e1796..9727dd8 100644 (file)
@@ -2615,6 +2615,14 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc)
                unsigned long reclaimed;
                unsigned long scanned;
 
+               /*
+                * This loop can become CPU-bound when target memcgs
+                * aren't eligible for reclaim - either because they
+                * don't have any reclaimable pages, or because their
+                * memory is explicitly protected. Avoid soft lockups.
+                */
+               cond_resched();
+
                mem_cgroup_calculate_protection(target_memcg, memcg);
 
                if (mem_cgroup_below_min(memcg)) {
index e670f91..4f7b4ee 100644 (file)
@@ -1241,6 +1241,7 @@ const char * const vmstat_text[] = {
        "pglazyfreed",
 
        "pgrefill",
+       "pgreuse",
        "pgsteal_kswapd",
        "pgsteal_direct",
        "pgscan_kswapd",
index 3dd7c97..ec8408d 100644 (file)
@@ -367,7 +367,7 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        case SIOCSHWTSTAMP:
                if (!net_eq(dev_net(dev), &init_net))
                        break;
-               /* fall through */
+               fallthrough;
        case SIOCGMIIPHY:
        case SIOCGMIIREG:
        case SIOCSMIIREG:
index 3debad9..bc8807d 100644 (file)
@@ -520,7 +520,7 @@ static void xen_9pfs_front_changed(struct xenbus_device *dev,
        case XenbusStateClosed:
                if (dev->state == XenbusStateClosed)
                        break;
-               /* fall through - Missed the backend's CLOSING state */
+               fallthrough;    /* Missed the backend's CLOSING state */
        case XenbusStateClosing:
                xenbus_frontend_closed(dev);
                break;
index 84367b8..1cfa9bf 100644 (file)
@@ -297,7 +297,7 @@ static int adjust_tp(struct atm_trafprm *tp, unsigned char aal)
                break;
        default:
                pr_warn("AAL problems ... (%d)\n", aal);
-               /* fall through */
+               fallthrough;
        case ATM_AAL5:
                max_sdu = ATM_MAX_AAL5_PDU;
        }
@@ -417,7 +417,7 @@ static int __vcc_connect(struct atm_vcc *vcc, struct atm_dev *dev, short vpi,
        case ATM_NO_AAL:
                /* ATM_AAL5 is also used in the "0 for default" case */
                vcc->qos.aal = ATM_AAL5;
-               /* fall through */
+               fallthrough;
        case ATM_AAL5:
                error = atm_init_aal5(vcc);
                vcc->stats = &dev->stats.aal5;
index 875fc0b..b570ef9 100644 (file)
@@ -380,7 +380,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
 
                if (mesg->content.normal.no_source_le_narp)
                        break;
-               /* FALL THROUGH */
+               fallthrough;
        case l_arp_update:
                lec_arp_update(priv, mesg->content.normal.mac_addr,
                               mesg->content.normal.atm_addr,
index 94bdc65..5323698 100644 (file)
@@ -266,7 +266,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
                                goto done;
                        }
        }
-       /* fall through */
+               fallthrough;
        case ATM_SETESIF:
        {
                unsigned char esi[ESI_LEN];
@@ -288,7 +288,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
                        error = -EPERM;
                        goto done;
                }
-               /* fall through */
+               fallthrough;
        case ATM_GETSTAT:
                size = sizeof(struct atm_dev_stats);
                error = fetch_stats(dev, buf, cmd == ATM_GETSTATZ);
@@ -361,7 +361,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
                        error = -EINVAL;
                        goto done;
                }
-               /* fall through */
+               fallthrough;
        case ATM_SETCIRANGE:
        case SONET_GETSTATZ:
        case SONET_SETDIAG:
@@ -371,7 +371,7 @@ int atm_dev_ioctl(unsigned int cmd, void __user *buf, int __user *sioc_len,
                        error = -EPERM;
                        goto done;
                }
-               /* fall through */
+               fallthrough;
        default:
                if (IS_ENABLED(CONFIG_COMPAT) && compat) {
 #ifdef CONFIG_COMPAT
index 0f8495b..717fe65 100644 (file)
@@ -881,6 +881,12 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
                   ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl,
                   ogm_packet->version, ntohs(ogm_packet->tvlv_len));
 
+       if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) {
+               batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+                          "Drop packet: originator packet from ourself\n");
+               return;
+       }
+
        /* If the throughput metric is 0, immediately drop the packet. No need
         * to create orig_node / neigh_node for an unusable route.
         */
@@ -1008,11 +1014,6 @@ int batadv_v_ogm_packet_recv(struct sk_buff *skb,
        if (batadv_is_my_mac(bat_priv, ethhdr->h_source))
                goto free_skb;
 
-       ogm_packet = (struct batadv_ogm2_packet *)skb->data;
-
-       if (batadv_is_my_mac(bat_priv, ogm_packet->orig))
-               goto free_skb;
-
        batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX);
        batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES,
                           skb->len + ETH_HLEN);
index 91a04ca..8500f56 100644 (file)
@@ -437,7 +437,10 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
        batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
                           skb->len + ETH_HLEN);
 
-       netif_rx(skb);
+       if (in_interrupt())
+               netif_rx(skb);
+       else
+               netif_rx_ni(skb);
 out:
        if (primary_if)
                batadv_hardif_put(primary_if);
index a18dcc6..ef3f85b 100644 (file)
@@ -703,8 +703,10 @@ batadv_gw_dhcp_recipient_get(struct sk_buff *skb, unsigned int *header_len,
 
        chaddr_offset = *header_len + BATADV_DHCP_CHADDR_OFFSET;
        /* store the client address if the message is going to a client */
-       if (ret == BATADV_DHCP_TO_CLIENT &&
-           pskb_may_pull(skb, chaddr_offset + ETH_ALEN)) {
+       if (ret == BATADV_DHCP_TO_CLIENT) {
+               if (!pskb_may_pull(skb, chaddr_offset + ETH_ALEN))
+                       return BATADV_DHCP_NO;
+
                /* check if the DHCP packet carries an Ethernet DHCP */
                p = skb->data + *header_len + BATADV_DHCP_HTYPE_OFFSET;
                if (*p != BATADV_DHCP_HTYPE_ETHERNET)
index 99eb8c6..a66f211 100644 (file)
@@ -425,7 +425,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
        case BPF_PROG_TYPE_SCHED_CLS:
        case BPF_PROG_TYPE_SCHED_ACT:
                is_l2 = true;
-               /* fall through */
+               fallthrough;
        case BPF_PROG_TYPE_LWT_IN:
        case BPF_PROG_TYPE_LWT_OUT:
        case BPF_PROG_TYPE_LWT_XMIT:
index 1641f41..ebe33b6 100644 (file)
@@ -2238,6 +2238,10 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
        struct ebt_table *t;
        struct net *net = sock_net(sk);
 
+       if ((cmd == EBT_SO_GET_INFO || cmd == EBT_SO_GET_INIT_INFO) &&
+           *len != sizeof(struct compat_ebt_replace))
+               return -EINVAL;
+
        if (copy_from_user(&tmp, user, sizeof(tmp)))
                return -EFAULT;
 
index 8096732..8d033a7 100644 (file)
@@ -168,6 +168,7 @@ static unsigned int nf_ct_br_defrag4(struct sk_buff *skb,
 static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
                                     const struct nf_hook_state *state)
 {
+#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
        u16 zone_id = NF_CT_DEFAULT_ZONE_ID;
        enum ip_conntrack_info ctinfo;
        struct br_input_skb_cb cb;
@@ -180,14 +181,17 @@ static unsigned int nf_ct_br_defrag6(struct sk_buff *skb,
 
        br_skb_cb_save(skb, &cb, sizeof(struct inet6_skb_parm));
 
-       err = nf_ipv6_br_defrag(state->net, skb,
-                               IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
+       err = nf_ct_frag6_gather(state->net, skb,
+                                IP_DEFRAG_CONNTRACK_BRIDGE_IN + zone_id);
        /* queued */
        if (err == -EINPROGRESS)
                return NF_STOLEN;
 
        br_skb_cb_restore(skb, &cb, IP6CB(skb)->frag_max_size);
        return err == 0 ? NF_ACCEPT : NF_DROP;
+#else
+       return NF_ACCEPT;
+#endif
 }
 
 static int nf_ct_br_ip_check(const struct sk_buff *skb)
index ce2767e..7b0af33 100644 (file)
@@ -116,7 +116,7 @@ static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt)
        if (segmented) {
                if (rfml->incomplete_frm == NULL) {
                        /* Initial Segment */
-                       if (cfpkt_peek_head(pkt, rfml->seghead, 6) < 0)
+                       if (cfpkt_peek_head(pkt, rfml->seghead, 6) != 0)
                                goto out;
 
                        rfml->pdu_size = get_unaligned_le16(rfml->seghead+4);
@@ -233,7 +233,7 @@ static int cfrfml_transmit(struct cflayer *layr, struct cfpkt *pkt)
        if (cfpkt_getlen(pkt) > rfml->fragment_size + RFM_HEAD_SIZE)
                err = cfpkt_peek_head(pkt, head, 6);
 
-       if (err < 0)
+       if (err != 0)
                goto out;
 
        while (cfpkt_getlen(frontpkt) > rfml->fragment_size + RFM_HEAD_SIZE) {
index 78ff9b3..1be4c89 100644 (file)
@@ -398,6 +398,7 @@ static int j1939_sk_init(struct sock *sk)
        spin_lock_init(&jsk->sk_session_queue_lock);
        INIT_LIST_HEAD(&jsk->sk_session_queue);
        sk->sk_destruct = j1939_sk_sock_destruct;
+       sk->sk_protocol = CAN_J1939;
 
        return 0;
 }
@@ -466,6 +467,14 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len)
                        goto out_release_sock;
                }
 
+               if (!ndev->ml_priv) {
+                       netdev_warn_once(ndev,
+                                        "No CAN mid layer private allocated, please fix your driver and use alloc_candev()!\n");
+                       dev_put(ndev);
+                       ret = -ENODEV;
+                       goto out_release_sock;
+               }
+
                priv = j1939_netdev_start(ndev);
                dev_put(ndev);
                if (IS_ERR(priv)) {
@@ -553,6 +562,11 @@ static int j1939_sk_connect(struct socket *sock, struct sockaddr *uaddr,
 static void j1939_sk_sock2sockaddr_can(struct sockaddr_can *addr,
                                       const struct j1939_sock *jsk, int peer)
 {
+       /* There are two holes (2 bytes and 3 bytes) to clear to avoid
+        * leaking kernel information to user space.
+        */
+       memset(addr, 0, J1939_MIN_NAMELEN);
+
        addr->can_family = AF_CAN;
        addr->can_ifindex = jsk->ifindex;
        addr->can_addr.j1939.pgn = jsk->addr.pgn;
@@ -1072,7 +1086,7 @@ static int j1939_sk_send_loop(struct j1939_priv *priv,  struct sock *sk,
                break;
        case -ERESTARTSYS:
                ret = -EINTR;
-               /* fall through */
+               fallthrough;
        case -EAGAIN: /* OK */
                if (todo_size != size)
                        ret = size - todo_size;
index 9f99af5..0cec415 100644 (file)
@@ -352,17 +352,16 @@ void j1939_session_skb_queue(struct j1939_session *session,
        skb_queue_tail(&session->skb_queue, skb);
 }
 
-static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
+static struct
+sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session,
+                                         unsigned int offset_start)
 {
        struct j1939_priv *priv = session->priv;
+       struct j1939_sk_buff_cb *do_skcb;
        struct sk_buff *skb = NULL;
        struct sk_buff *do_skb;
-       struct j1939_sk_buff_cb *do_skcb;
-       unsigned int offset_start;
        unsigned long flags;
 
-       offset_start = session->pkt.dpo * 7;
-
        spin_lock_irqsave(&session->skb_queue.lock, flags);
        skb_queue_walk(&session->skb_queue, do_skb) {
                do_skcb = j1939_skb_to_cb(do_skb);
@@ -382,6 +381,14 @@ static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
        return skb;
 }
 
+static struct sk_buff *j1939_session_skb_find(struct j1939_session *session)
+{
+       unsigned int offset_start;
+
+       offset_start = session->pkt.dpo * 7;
+       return j1939_session_skb_find_by_offset(session, offset_start);
+}
+
 /* see if we are receiver
  * returns 0 for broadcasts, although we will receive them
  */
@@ -716,10 +723,12 @@ static int j1939_session_tx_rts(struct j1939_session *session)
                return ret;
 
        session->last_txcmd = dat[0];
-       if (dat[0] == J1939_TP_CMD_BAM)
+       if (dat[0] == J1939_TP_CMD_BAM) {
                j1939_tp_schedule_txtimer(session, 50);
-
-       j1939_tp_set_rxtimeout(session, 1250);
+               j1939_tp_set_rxtimeout(session, 250);
+       } else {
+               j1939_tp_set_rxtimeout(session, 1250);
+       }
 
        netdev_dbg(session->priv->ndev, "%s: 0x%p\n", __func__, session);
 
@@ -766,7 +775,7 @@ static int j1939_session_tx_dat(struct j1939_session *session)
        int ret = 0;
        u8 dat[8];
 
-       se_skb = j1939_session_skb_find(session);
+       se_skb = j1939_session_skb_find_by_offset(session, session->pkt.tx * 7);
        if (!se_skb)
                return -ENOBUFS;
 
@@ -787,6 +796,18 @@ static int j1939_session_tx_dat(struct j1939_session *session)
                if (len > 7)
                        len = 7;
 
+               if (offset + len > se_skb->len) {
+                       netdev_err_once(priv->ndev,
+                                       "%s: 0x%p: requested data outside of queued buffer: offset %i, len %i, pkt.tx: %i\n",
+                                       __func__, session, skcb->offset, se_skb->len , session->pkt.tx);
+                       return -EOVERFLOW;
+               }
+
+               if (!len) {
+                       ret = -ENOBUFS;
+                       break;
+               }
+
                memcpy(&dat[1], &tpdat[offset], len);
                ret = j1939_tp_tx_dat(session, dat, len + 1);
                if (ret < 0) {
@@ -839,7 +860,7 @@ static int j1939_xtp_txnext_transmiter(struct j1939_session *session)
                                return ret;
                }
 
-               /* fall through */
+               fallthrough;
        case J1939_TP_CMD_CTS:
        case 0xff: /* did some data */
        case J1939_ETP_CMD_DPO:
@@ -1055,9 +1076,9 @@ static void __j1939_session_cancel(struct j1939_session *session,
        lockdep_assert_held(&session->priv->active_session_list_lock);
 
        session->err = j1939_xtp_abort_to_errno(priv, err);
+       session->state = J1939_SESSION_WAITING_ABORT;
        /* do not send aborts on incoming broadcasts */
        if (!j1939_cb_is_broadcast(&session->skcb)) {
-               session->state = J1939_SESSION_WAITING_ABORT;
                j1939_xtp_tx_abort(priv, &session->skcb,
                                   !session->transmission,
                                   err, session->skcb.addr.pgn);
@@ -1120,6 +1141,9 @@ static enum hrtimer_restart j1939_tp_txtimer(struct hrtimer *hrtimer)
                 * cleanup including propagation of the error to user space.
                 */
                break;
+       case -EOVERFLOW:
+               j1939_session_cancel(session, J1939_XTP_ABORT_ECTS_TOO_BIG);
+               break;
        case 0:
                session->tx_retry = 0;
                break;
@@ -1651,8 +1675,12 @@ static void j1939_xtp_rx_rts(struct j1939_priv *priv, struct sk_buff *skb,
                        return;
                }
                session = j1939_xtp_rx_rts_session_new(priv, skb);
-               if (!session)
+               if (!session) {
+                       if (cmd == J1939_TP_CMD_BAM && j1939_sk_recv_match(priv, skcb))
+                               netdev_info(priv->ndev, "%s: failed to create TP BAM session\n",
+                                           __func__);
                        return;
+               }
        } else {
                if (j1939_xtp_rx_rts_session_active(session, skb)) {
                        j1939_session_put(session);
@@ -1661,11 +1689,15 @@ static void j1939_xtp_rx_rts(struct j1939_priv *priv, struct sk_buff *skb,
        }
        session->last_cmd = cmd;
 
-       j1939_tp_set_rxtimeout(session, 1250);
-
-       if (cmd != J1939_TP_CMD_BAM && !session->transmission) {
-               j1939_session_txtimer_cancel(session);
-               j1939_tp_schedule_txtimer(session, 0);
+       if (cmd == J1939_TP_CMD_BAM) {
+               if (!session->transmission)
+                       j1939_tp_set_rxtimeout(session, 750);
+       } else {
+               if (!session->transmission) {
+                       j1939_session_txtimer_cancel(session);
+                       j1939_tp_schedule_txtimer(session, 0);
+               }
+               j1939_tp_set_rxtimeout(session, 1250);
        }
 
        j1939_session_put(session);
@@ -1716,6 +1748,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
        int offset;
        int nbytes;
        bool final = false;
+       bool remain = false;
        bool do_cts_eoma = false;
        int packet;
 
@@ -1731,12 +1764,12 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
        case J1939_ETP_CMD_DPO:
                if (skcb->addr.type == J1939_ETP)
                        break;
-               /* fall through */
-       case J1939_TP_CMD_BAM: /* fall through */
+               fallthrough;
+       case J1939_TP_CMD_BAM:
        case J1939_TP_CMD_CTS: /* fall through */
                if (skcb->addr.type != J1939_ETP)
                        break;
-               /* fall through */
+               fallthrough;
        default:
                netdev_info(priv->ndev, "%s: 0x%p: last %02x\n", __func__,
                            session, session->last_cmd);
@@ -1750,7 +1783,8 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
                            __func__, session);
                goto out_session_cancel;
        }
-       se_skb = j1939_session_skb_find(session);
+
+       se_skb = j1939_session_skb_find_by_offset(session, packet * 7);
        if (!se_skb) {
                netdev_warn(priv->ndev, "%s: 0x%p: no skb found\n", __func__,
                            session);
@@ -1769,7 +1803,20 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
        }
 
        tpdat = se_skb->data;
-       memcpy(&tpdat[offset], &dat[1], nbytes);
+       if (!session->transmission) {
+               memcpy(&tpdat[offset], &dat[1], nbytes);
+       } else {
+               int err;
+
+               err = memcmp(&tpdat[offset], &dat[1], nbytes);
+               if (err)
+                       netdev_err_once(priv->ndev,
+                                       "%s: 0x%p: Data of RX-looped back packet (%*ph) doesn't match TX data (%*ph)!\n",
+                                       __func__, session,
+                                       nbytes, &dat[1],
+                                       nbytes, &tpdat[offset]);
+       }
+
        if (packet == session->pkt.rx)
                session->pkt.rx++;
 
@@ -1777,6 +1824,8 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
            j1939_cb_is_broadcast(&session->skcb)) {
                if (session->pkt.rx >= session->pkt.total)
                        final = true;
+               else
+                       remain = true;
        } else {
                /* never final, an EOMA must follow */
                if (session->pkt.rx >= session->pkt.last)
@@ -1784,7 +1833,11 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session,
        }
 
        if (final) {
+               j1939_session_timers_cancel(session);
                j1939_session_completed(session);
+       } else if (remain) {
+               if (!session->transmission)
+                       j1939_tp_set_rxtimeout(session, 750);
        } else if (do_cts_eoma) {
                j1939_tp_set_rxtimeout(session, 1250);
                if (!session->transmission)
@@ -1829,6 +1882,13 @@ static void j1939_xtp_rx_dat(struct j1939_priv *priv, struct sk_buff *skb)
                else
                        j1939_xtp_rx_dat_one(session, skb);
        }
+
+       if (j1939_cb_is_broadcast(skcb)) {
+               session = j1939_session_get_by_addr(priv, &skcb->addr, false,
+                                                   false);
+               if (session)
+                       j1939_xtp_rx_dat_one(session, skb);
+       }
 }
 
 /* j1939 main intf */
@@ -1905,8 +1965,8 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb)
        switch (cmd) {
        case J1939_ETP_CMD_RTS:
                extd = J1939_ETP;
-               /* fall through */
-       case J1939_TP_CMD_BAM: /* fall through */
+               fallthrough;
+       case J1939_TP_CMD_BAM:
        case J1939_TP_CMD_RTS: /* fall through */
                if (skcb->addr.type != extd)
                        return;
@@ -1920,14 +1980,14 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb)
                if (j1939_tp_im_transmitter(skcb))
                        j1939_xtp_rx_rts(priv, skb, true);
 
-               if (j1939_tp_im_receiver(skcb))
+               if (j1939_tp_im_receiver(skcb) || j1939_cb_is_broadcast(skcb))
                        j1939_xtp_rx_rts(priv, skb, false);
 
                break;
 
        case J1939_ETP_CMD_CTS:
                extd = J1939_ETP;
-               /* fall through */
+               fallthrough;
        case J1939_TP_CMD_CTS:
                if (skcb->addr.type != extd)
                        return;
@@ -1954,7 +2014,7 @@ static void j1939_tp_cmd_recv(struct j1939_priv *priv, struct sk_buff *skb)
 
        case J1939_ETP_CMD_EOMA:
                extd = J1939_ETP;
-               /* fall through */
+               fallthrough;
        case J1939_TP_CMD_EOMA:
                if (skcb->addr.type != extd)
                        return;
@@ -1984,20 +2044,20 @@ int j1939_tp_recv(struct j1939_priv *priv, struct sk_buff *skb)
 {
        struct j1939_sk_buff_cb *skcb = j1939_skb_to_cb(skb);
 
-       if (!j1939_tp_im_involved_anydir(skcb))
+       if (!j1939_tp_im_involved_anydir(skcb) && !j1939_cb_is_broadcast(skcb))
                return 0;
 
        switch (skcb->addr.pgn) {
        case J1939_ETP_PGN_DAT:
                skcb->addr.type = J1939_ETP;
-               /* fall through */
+               fallthrough;
        case J1939_TP_PGN_DAT:
                j1939_xtp_rx_dat(priv, skb);
                break;
 
        case J1939_ETP_PGN_CTL:
                skcb->addr.type = J1939_ETP;
-               /* fall through */
+               fallthrough;
        case J1939_TP_PGN_CTL:
                if (skb->len < 8)
                        return 0; /* Don't care. Nothing to extract here */
@@ -2017,6 +2077,10 @@ void j1939_simple_recv(struct j1939_priv *priv, struct sk_buff *skb)
        if (!skb->sk)
                return;
 
+       if (skb->sk->sk_family != AF_CAN ||
+           skb->sk->sk_protocol != CAN_J1939)
+               return;
+
        j1939_session_list_lock(priv);
        session = j1939_session_get_simple(priv, skb);
        j1939_session_list_unlock(priv);
index 81e1e00..16a47c0 100644 (file)
@@ -50,35 +50,35 @@ unsigned int ceph_str_hash_rjenkins(const char *str, unsigned int length)
        switch (len) {
        case 11:
                c = c + ((__u32)k[10] << 24);
-               /* fall through */
+               fallthrough;
        case 10:
                c = c + ((__u32)k[9] << 16);
-               /* fall through */
+               fallthrough;
        case 9:
                c = c + ((__u32)k[8] << 8);
                /* the first byte of c is reserved for the length */
-               /* fall through */
+               fallthrough;
        case 8:
                b = b + ((__u32)k[7] << 24);
-               /* fall through */
+               fallthrough;
        case 7:
                b = b + ((__u32)k[6] << 16);
-               /* fall through */
+               fallthrough;
        case 6:
                b = b + ((__u32)k[5] << 8);
-               /* fall through */
+               fallthrough;
        case 5:
                b = b + k[4];
-               /* fall through */
+               fallthrough;
        case 4:
                a = a + ((__u32)k[3] << 24);
-               /* fall through */
+               fallthrough;
        case 3:
                a = a + ((__u32)k[2] << 16);
-               /* fall through */
+               fallthrough;
        case 2:
                a = a + ((__u32)k[1] << 8);
-               /* fall through */
+               fallthrough;
        case 1:
                a = a + k[0];
                /* case 0: nothing left to add */
index 07e5614..7057f8d 100644 (file)
@@ -987,7 +987,7 @@ int crush_do_rule(const struct crush_map *map,
                case CRUSH_RULE_CHOOSELEAF_FIRSTN:
                case CRUSH_RULE_CHOOSE_FIRSTN:
                        firstn = 1;
-                       /* fall through */
+                       fallthrough;
                case CRUSH_RULE_CHOOSELEAF_INDEP:
                case CRUSH_RULE_CHOOSE_INDEP:
                        if (wsize == 0)
index 27d6ab1..bdfd66b 100644 (file)
@@ -412,7 +412,7 @@ static void ceph_sock_state_change(struct sock *sk)
        switch (sk->sk_state) {
        case TCP_CLOSE:
                dout("%s TCP_CLOSE\n", __func__);
-               /* fall through */
+               fallthrough;
        case TCP_CLOSE_WAIT:
                dout("%s TCP_CLOSE_WAIT\n", __func__);
                con_sock_state_closing(con);
@@ -2751,7 +2751,7 @@ more:
                        switch (ret) {
                        case -EBADMSG:
                                con->error_msg = "bad crc/signature";
-                               /* fall through */
+                               fallthrough;
                        case -EBADE:
                                ret = -EIO;
                                break;
index 3d8c801..d633a0a 100644 (file)
@@ -1307,7 +1307,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
                 * request had a non-zero tid.  Work around this weirdness
                 * by allocating a new message.
                 */
-               /* fall through */
+               fallthrough;
        case CEPH_MSG_MON_MAP:
        case CEPH_MSG_MDS_MAP:
        case CEPH_MSG_OSD_MAP:
index e4fbcad..7901ab6 100644 (file)
@@ -3854,7 +3854,7 @@ static void scan_requests(struct ceph_osd *osd,
                        if (!force_resend && !force_resend_writes)
                                break;
 
-                       /* fall through */
+                       fallthrough;
                case CALC_TARGET_NEED_RESEND:
                        cancel_linger_map_check(lreq);
                        /*
@@ -3891,7 +3891,7 @@ static void scan_requests(struct ceph_osd *osd,
                             !force_resend_writes))
                                break;
 
-                       /* fall through */
+                       fallthrough;
                case CALC_TARGET_NEED_RESEND:
                        cancel_map_check(req);
                        unlink_request(osd, req);
index 7df6c96..4086d33 100644 (file)
@@ -4690,10 +4690,10 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
                break;
        default:
                bpf_warn_invalid_xdp_action(act);
-               /* fall through */
+               fallthrough;
        case XDP_ABORTED:
                trace_xdp_exception(skb->dev, xdp_prog, act);
-               /* fall through */
+               fallthrough;
        case XDP_DROP:
        do_drop:
                kfree_skb(skb);
@@ -6612,12 +6612,13 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
                netdev_err_once(dev, "%s() called with weight %d\n", __func__,
                                weight);
        napi->weight = weight;
-       list_add(&napi->dev_list, &dev->napi_list);
        napi->dev = dev;
 #ifdef CONFIG_NETPOLL
        napi->poll_owner = -1;
 #endif
        set_bit(NAPI_STATE_SCHED, &napi->state);
+       set_bit(NAPI_STATE_NPSVC, &napi->state);
+       list_add_rcu(&napi->dev_list, &dev->napi_list);
        napi_hash_add(napi);
 }
 EXPORT_SYMBOL(netif_napi_add);
@@ -8742,13 +8743,15 @@ struct bpf_xdp_link {
        int flags;
 };
 
-static enum bpf_xdp_mode dev_xdp_mode(u32 flags)
+static enum bpf_xdp_mode dev_xdp_mode(struct net_device *dev, u32 flags)
 {
        if (flags & XDP_FLAGS_HW_MODE)
                return XDP_MODE_HW;
        if (flags & XDP_FLAGS_DRV_MODE)
                return XDP_MODE_DRV;
-       return XDP_MODE_SKB;
+       if (flags & XDP_FLAGS_SKB_MODE)
+               return XDP_MODE_SKB;
+       return dev->netdev_ops->ndo_bpf ? XDP_MODE_DRV : XDP_MODE_SKB;
 }
 
 static bpf_op_t dev_xdp_bpf_op(struct net_device *dev, enum bpf_xdp_mode mode)
@@ -8896,7 +8899,7 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
                return -EINVAL;
        }
 
-       mode = dev_xdp_mode(flags);
+       mode = dev_xdp_mode(dev, flags);
        /* can't replace attached link */
        if (dev_xdp_link(dev, mode)) {
                NL_SET_ERR_MSG(extack, "Can't replace active BPF XDP link");
@@ -8913,10 +8916,6 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
                NL_SET_ERR_MSG(extack, "Active program does not match expected");
                return -EEXIST;
        }
-       if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && cur_prog) {
-               NL_SET_ERR_MSG(extack, "XDP program already attached");
-               return -EBUSY;
-       }
 
        /* put effective new program into new_prog */
        if (link)
@@ -8927,6 +8926,10 @@ static int dev_xdp_attach(struct net_device *dev, struct netlink_ext_ack *extack
                enum bpf_xdp_mode other_mode = mode == XDP_MODE_SKB
                                               ? XDP_MODE_DRV : XDP_MODE_SKB;
 
+               if ((flags & XDP_FLAGS_UPDATE_IF_NOEXIST) && cur_prog) {
+                       NL_SET_ERR_MSG(extack, "XDP program already attached");
+                       return -EBUSY;
+               }
                if (!offload && dev_xdp_prog(dev, other_mode)) {
                        NL_SET_ERR_MSG(extack, "Native and generic XDP can't be active at the same time");
                        return -EEXIST;
@@ -8984,7 +8987,7 @@ static int dev_xdp_detach_link(struct net_device *dev,
 
        ASSERT_RTNL();
 
-       mode = dev_xdp_mode(link->flags);
+       mode = dev_xdp_mode(dev, link->flags);
        if (dev_xdp_link(dev, mode) != link)
                return -EINVAL;
 
@@ -9080,7 +9083,7 @@ static int bpf_xdp_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
                goto out_unlock;
        }
 
-       mode = dev_xdp_mode(xdp_link->flags);
+       mode = dev_xdp_mode(xdp_link->dev, xdp_link->flags);
        bpf_op = dev_xdp_bpf_op(xdp_link->dev, mode);
        err = dev_xdp_install(xdp_link->dev, mode, bpf_op, NULL,
                              xdp_link->flags, new_prog);
@@ -9164,7 +9167,7 @@ out_put_dev:
 int dev_change_xdp_fd(struct net_device *dev, struct netlink_ext_ack *extack,
                      int fd, int expected_fd, u32 flags)
 {
-       enum bpf_xdp_mode mode = dev_xdp_mode(flags);
+       enum bpf_xdp_mode mode = dev_xdp_mode(dev, flags);
        struct bpf_prog *new_prog = NULL, *old_prog = NULL;
        int err;
 
index b2cf9b7..205e92e 100644 (file)
@@ -322,7 +322,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd)
                err = net_hwtstamp_validate(ifr);
                if (err)
                        return err;
-               /* fall through */
+               fallthrough;
 
        /*
         *      Unknown or private ioctl
@@ -478,7 +478,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
        case SIOCSIFTXQLEN:
                if (!capable(CAP_NET_ADMIN))
                        return -EPERM;
-               /* fall through */
+               fallthrough;
        /*
         *      These ioctl calls:
         *      - require local superuser power.
@@ -503,7 +503,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c
        case SIOCSHWTSTAMP:
                if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
                        return -EPERM;
-               /* fall through */
+               fallthrough;
        case SIOCBONDSLAVEINFOQUERY:
        case SIOCBONDINFOQUERY:
                dev_load(net, ifr->ifr_name);
index e674f0f..80ec1cd 100644 (file)
@@ -4063,7 +4063,7 @@ static int __devlink_snapshot_id_insert(struct devlink *devlink, u32 id)
 {
        lockdep_assert_held(&devlink->lock);
 
-       if (WARN_ON(xa_load(&devlink->snapshot_ids, id)))
+       if (xa_load(&devlink->snapshot_ids, id))
                return -EEXIST;
 
        return xa_err(xa_store(&devlink->snapshot_ids, id, xa_mk_value(0),
@@ -6196,8 +6196,8 @@ devlink_trap_action_get_from_info(struct genl_info *info,
 
        val = nla_get_u8(info->attrs[DEVLINK_ATTR_TRAP_ACTION]);
        switch (val) {
-       case DEVLINK_TRAP_ACTION_DROP: /* fall-through */
-       case DEVLINK_TRAP_ACTION_TRAP: /* fall-through */
+       case DEVLINK_TRAP_ACTION_DROP:
+       case DEVLINK_TRAP_ACTION_TRAP:
        case DEVLINK_TRAP_ACTION_MIRROR:
                *p_trap_action = val;
                break;
index b09bebe..9704522 100644 (file)
@@ -1189,7 +1189,7 @@ static int net_dm_alert_mode_get_from_info(struct genl_info *info,
        val = nla_get_u8(info->attrs[NET_DM_ATTR_ALERT_MODE]);
 
        switch (val) {
-       case NET_DM_ALERT_MODE_SUMMARY: /* fall-through */
+       case NET_DM_ALERT_MODE_SUMMARY:
        case NET_DM_ALERT_MODE_PACKET:
                *p_alert_mode = val;
                break;
index 7124f0f..1f647ab 100644 (file)
@@ -8317,15 +8317,31 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
 /* Helper macro for adding read access to tcp_sock or sock fields. */
 #define SOCK_OPS_GET_FIELD(BPF_FIELD, OBJ_FIELD, OBJ)                        \
        do {                                                                  \
+               int fullsock_reg = si->dst_reg, reg = BPF_REG_9, jmp = 2;     \
                BUILD_BUG_ON(sizeof_field(OBJ, OBJ_FIELD) >                   \
                             sizeof_field(struct bpf_sock_ops, BPF_FIELD));   \
+               if (si->dst_reg == reg || si->src_reg == reg)                 \
+                       reg--;                                                \
+               if (si->dst_reg == reg || si->src_reg == reg)                 \
+                       reg--;                                                \
+               if (si->dst_reg == si->src_reg) {                             \
+                       *insn++ = BPF_STX_MEM(BPF_DW, si->src_reg, reg,       \
+                                         offsetof(struct bpf_sock_ops_kern,  \
+                                         temp));                             \
+                       fullsock_reg = reg;                                   \
+                       jmp += 2;                                             \
+               }                                                             \
                *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(                       \
                                                struct bpf_sock_ops_kern,     \
                                                is_fullsock),                 \
-                                     si->dst_reg, si->src_reg,               \
+                                     fullsock_reg, si->src_reg,              \
                                      offsetof(struct bpf_sock_ops_kern,      \
                                               is_fullsock));                 \
-               *insn++ = BPF_JMP_IMM(BPF_JEQ, si->dst_reg, 0, 2);            \
+               *insn++ = BPF_JMP_IMM(BPF_JEQ, fullsock_reg, 0, jmp);         \
+               if (si->dst_reg == si->src_reg)                               \
+                       *insn++ = BPF_LDX_MEM(BPF_DW, reg, si->src_reg,       \
+                                     offsetof(struct bpf_sock_ops_kern,      \
+                                     temp));                                 \
                *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(                       \
                                                struct bpf_sock_ops_kern, sk),\
                                      si->dst_reg, si->src_reg,               \
@@ -8334,6 +8350,49 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
                                                       OBJ_FIELD),            \
                                      si->dst_reg, si->dst_reg,               \
                                      offsetof(OBJ, OBJ_FIELD));              \
+               if (si->dst_reg == si->src_reg) {                             \
+                       *insn++ = BPF_JMP_A(1);                               \
+                       *insn++ = BPF_LDX_MEM(BPF_DW, reg, si->src_reg,       \
+                                     offsetof(struct bpf_sock_ops_kern,      \
+                                     temp));                                 \
+               }                                                             \
+       } while (0)
+
+#define SOCK_OPS_GET_SK()                                                            \
+       do {                                                                  \
+               int fullsock_reg = si->dst_reg, reg = BPF_REG_9, jmp = 1;     \
+               if (si->dst_reg == reg || si->src_reg == reg)                 \
+                       reg--;                                                \
+               if (si->dst_reg == reg || si->src_reg == reg)                 \
+                       reg--;                                                \
+               if (si->dst_reg == si->src_reg) {                             \
+                       *insn++ = BPF_STX_MEM(BPF_DW, si->src_reg, reg,       \
+                                         offsetof(struct bpf_sock_ops_kern,  \
+                                         temp));                             \
+                       fullsock_reg = reg;                                   \
+                       jmp += 2;                                             \
+               }                                                             \
+               *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(                       \
+                                               struct bpf_sock_ops_kern,     \
+                                               is_fullsock),                 \
+                                     fullsock_reg, si->src_reg,              \
+                                     offsetof(struct bpf_sock_ops_kern,      \
+                                              is_fullsock));                 \
+               *insn++ = BPF_JMP_IMM(BPF_JEQ, fullsock_reg, 0, jmp);         \
+               if (si->dst_reg == si->src_reg)                               \
+                       *insn++ = BPF_LDX_MEM(BPF_DW, reg, si->src_reg,       \
+                                     offsetof(struct bpf_sock_ops_kern,      \
+                                     temp));                                 \
+               *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(                       \
+                                               struct bpf_sock_ops_kern, sk),\
+                                     si->dst_reg, si->src_reg,               \
+                                     offsetof(struct bpf_sock_ops_kern, sk));\
+               if (si->dst_reg == si->src_reg) {                             \
+                       *insn++ = BPF_JMP_A(1);                               \
+                       *insn++ = BPF_LDX_MEM(BPF_DW, reg, si->src_reg,       \
+                                     offsetof(struct bpf_sock_ops_kern,      \
+                                     temp));                                 \
+               }                                                             \
        } while (0)
 
 #define SOCK_OPS_GET_TCP_SOCK_FIELD(FIELD) \
@@ -8620,17 +8679,7 @@ static u32 sock_ops_convert_ctx_access(enum bpf_access_type type,
                SOCK_OPS_GET_TCP_SOCK_FIELD(bytes_acked);
                break;
        case offsetof(struct bpf_sock_ops, sk):
-               *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(
-                                               struct bpf_sock_ops_kern,
-                                               is_fullsock),
-                                     si->dst_reg, si->src_reg,
-                                     offsetof(struct bpf_sock_ops_kern,
-                                              is_fullsock));
-               *insn++ = BPF_JMP_IMM(BPF_JEQ, si->dst_reg, 0, 1);
-               *insn++ = BPF_LDX_MEM(BPF_FIELD_SIZEOF(
-                                               struct bpf_sock_ops_kern, sk),
-                                     si->dst_reg, si->src_reg,
-                                     offsetof(struct bpf_sock_ops_kern, sk));
+               SOCK_OPS_GET_SK();
                break;
        }
        return insn - insn_buf;
@@ -9174,7 +9223,7 @@ sk_reuseport_is_valid_access(int off, int size,
        case bpf_ctx_range(struct sk_reuseport_md, eth_protocol):
                if (size < sizeof_field(struct sk_buff, protocol))
                        return false;
-               /* fall through */
+               fallthrough;
        case bpf_ctx_range(struct sk_reuseport_md, ip_protocol):
        case bpf_ctx_range(struct sk_reuseport_md, bind_inany):
        case bpf_ctx_range(struct sk_reuseport_md, len):
index 093e90e..2338753 100644 (file)
@@ -162,7 +162,7 @@ static void poll_napi(struct net_device *dev)
        struct napi_struct *napi;
        int cpu = smp_processor_id();
 
-       list_for_each_entry(napi, &dev->napi_list, dev_list) {
+       list_for_each_entry_rcu(napi, &dev->napi_list, dev_list) {
                if (cmpxchg(&napi->poll_owner, -1, cpu) == -1) {
                        poll_one_napi(napi);
                        smp_store_release(&napi->poll_owner, -1);
index b53b6d3..44fdbb9 100644 (file)
@@ -3430,7 +3430,7 @@ xmit_more:
                net_info_ratelimited("%s xmit error: %d\n",
                                     pkt_dev->odevname, ret);
                pkt_dev->errors++;
-               /* fall through */
+               fallthrough;
        case NETDEV_TX_BUSY:
                /* Retry it next time */
                refcount_dec(&(pkt_dev->skb->users));
@@ -3699,7 +3699,7 @@ static int __net_init pktgen_create_thread(int cpu, struct pktgen_net *pn)
                                   cpu_to_node(cpu),
                                   "kpktgend_%d", cpu);
        if (IS_ERR(p)) {
-               pr_err("kernel_thread() failed for cpu %d\n", t->cpu);
+               pr_err("kthread_create_on_node() failed for cpu %d\n", t->cpu);
                list_del(&t->th_list);
                kfree(t);
                return PTR_ERR(p);
index 7e2e502..6faf73d 100644 (file)
@@ -820,6 +820,7 @@ void skb_tx_error(struct sk_buff *skb)
 }
 EXPORT_SYMBOL(skb_tx_error);
 
+#ifdef CONFIG_TRACEPOINTS
 /**
  *     consume_skb - free an skbuff
  *     @skb: buffer to free
@@ -837,6 +838,7 @@ void consume_skb(struct sk_buff *skb)
        __kfree_skb(skb);
 }
 EXPORT_SYMBOL(consume_skb);
+#endif
 
 /**
  *     consume_stateless_skb - free an skbuff, assuming it is stateless
@@ -5418,8 +5420,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
        skb = skb_share_check(skb, GFP_ATOMIC);
        if (unlikely(!skb))
                goto err_free;
-
-       if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
+       /* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */
+       if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short))))
                goto err_free;
 
        vhdr = (struct vlan_hdr *)skb->data;
@@ -5987,9 +5989,13 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
        if (skb_has_frag_list(skb))
                skb_clone_fraglist(skb);
 
-       if (k == 0) {
-               /* split line is in frag list */
-               pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask);
+       /* split line is in frag list */
+       if (k == 0 && pskb_carve_frag_list(skb, shinfo, off - pos, gfp_mask)) {
+               /* skb_frag_unref() is not needed here as shinfo->nr_frags = 0. */
+               if (skb_has_frag_list(skb))
+                       kfree_skb_list(skb_shinfo(skb)->frag_list);
+               kfree(data);
+               return -ENOMEM;
        }
        skb_release_data(skb);
 
index 6a32a1f..6495831 100644 (file)
@@ -772,7 +772,6 @@ static void sk_psock_verdict_apply(struct sk_psock *psock,
                sk_psock_skb_redirect(skb);
                break;
        case __SK_DROP:
-               /* fall-through */
        default:
 out_free:
                kfree_skb(skb);
index e4f40b1..6c5c6b1 100644 (file)
@@ -1008,7 +1008,7 @@ set_sndbuf:
                break;
        case SO_TIMESTAMPING_NEW:
                sock_set_flag(sk, SOCK_TSTAMP_NEW);
-               /* fall through */
+               fallthrough;
        case SO_TIMESTAMPING_OLD:
                if (val & ~SOF_TIMESTAMPING_MASK) {
                        ret = -EINVAL;
@@ -3254,7 +3254,7 @@ void sk_common_release(struct sock *sk)
                sk->sk_prot->destroy(sk);
 
        /*
-        * Observation: when sock_common_release is called, processes have
+        * Observation: when sk_common_release is called, processes have
         * no access to socket. But net still has.
         * Step one, detach it from networking:
         *
index aef72f6..b9ee1a4 100644 (file)
@@ -608,7 +608,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
                 */
                if (hc->rx_x_recv > 0)
                        break;
-               /* fall through */
+               fallthrough;
        case CCID3_FBACK_PERIODIC:
                delta = ktime_us_delta(now, hc->rx_tstamp_last_feedback);
                if (delta <= 0)
index afc071e..788dd62 100644 (file)
@@ -1407,7 +1407,8 @@ int dccp_feat_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
         *      Negotiation during connection setup
         */
        case DCCP_LISTEN:
-               server = true;                  /* fall through */
+               server = true;
+               fallthrough;
        case DCCP_REQUESTING:
                switch (opt) {
                case DCCPO_CHANGE_L:
index bd9cfdb..2cbb757 100644 (file)
@@ -64,7 +64,7 @@ static int dccp_rcv_close(struct sock *sk, struct sk_buff *skb)
                 */
                if (dccp_sk(sk)->dccps_role != DCCP_ROLE_CLIENT)
                        break;
-               /* fall through */
+               fallthrough;
        case DCCP_REQUESTING:
        case DCCP_ACTIVE_CLOSEREQ:
                dccp_send_reset(sk, DCCP_RESET_CODE_CLOSED);
@@ -76,7 +76,7 @@ static int dccp_rcv_close(struct sock *sk, struct sk_buff *skb)
                queued = 1;
                dccp_fin(sk, skb);
                dccp_set_state(sk, DCCP_PASSIVE_CLOSE);
-               /* fall through */
+               fallthrough;
        case DCCP_PASSIVE_CLOSE:
                /*
                 * Retransmitted Close: we have already enqueued the first one.
@@ -113,7 +113,7 @@ static int dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb)
                queued = 1;
                dccp_fin(sk, skb);
                dccp_set_state(sk, DCCP_PASSIVE_CLOSEREQ);
-               /* fall through */
+               fallthrough;
        case DCCP_PASSIVE_CLOSEREQ:
                sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_HUP);
        }
@@ -530,7 +530,7 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
        case DCCP_PKT_DATA:
                if (sk->sk_state == DCCP_RESPOND)
                        break;
-               /* fall through */
+               fallthrough;
        case DCCP_PKT_DATAACK:
        case DCCP_PKT_ACK:
                /*
@@ -684,7 +684,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
                /* Step 8: if using Ack Vectors, mark packet acknowledgeable */
                dccp_handle_ackvec_processing(sk, skb);
                dccp_deliver_input_to_ccids(sk, skb);
-               /* fall through */
+               fallthrough;
        case DCCP_RESPOND:
                queued = dccp_rcv_respond_partopen_state_process(sk, skb,
                                                                 dh, len);
index 51aaba7..d24cad0 100644 (file)
@@ -225,7 +225,7 @@ int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
                         * interested. The RX CCID need not parse Ack Vectors,
                         * since it is only interested in clearing old state.
                         */
-                       /* fall through */
+                       fallthrough;
                case DCCPO_MIN_TX_CCID_SPECIFIC ... DCCPO_MAX_TX_CCID_SPECIFIC:
                        if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
                                                     pkt_type, opt, value, len))
index 6433187..50e6d56 100644 (file)
@@ -62,7 +62,7 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
                switch (dcb->dccpd_type) {
                case DCCP_PKT_DATA:
                        set_ack = 0;
-                       /* fall through */
+                       fallthrough;
                case DCCP_PKT_DATAACK:
                case DCCP_PKT_RESET:
                        break;
@@ -72,12 +72,12 @@ static int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
                        /* Use ISS on the first (non-retransmitted) Request. */
                        if (icsk->icsk_retransmits == 0)
                                dcb->dccpd_seq = dp->dccps_iss;
-                       /* fall through */
+                       fallthrough;
 
                case DCCP_PKT_SYNC:
                case DCCP_PKT_SYNCACK:
                        ackno = dcb->dccpd_ack_seq;
-                       /* fall through */
+                       fallthrough;
                default:
                        /*
                         * Set owner/destructor: some skbs are allocated via
@@ -481,7 +481,7 @@ struct sk_buff *dccp_ctl_make_reset(struct sock *sk, struct sk_buff *rcv_skb)
        case DCCP_RESET_CODE_PACKET_ERROR:
                dhr->dccph_reset_data[0] = rxdh->dccph_type;
                break;
-       case DCCP_RESET_CODE_OPTION_ERROR:      /* fall through */
+       case DCCP_RESET_CODE_OPTION_ERROR:
        case DCCP_RESET_CODE_MANDATORY_ERROR:
                memcpy(dhr->dccph_reset_data, dcb->dccpd_reset_data, 3);
                break;
index d148ab1..6d705d9 100644 (file)
@@ -101,7 +101,7 @@ void dccp_set_state(struct sock *sk, const int state)
                if (inet_csk(sk)->icsk_bind_hash != NULL &&
                    !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
                        inet_put_port(sk);
-               /* fall through */
+               fallthrough;
        default:
                if (oldstate == DCCP_OPEN)
                        DCCP_DEC_STATS(DCCP_MIB_CURRESTAB);
@@ -834,7 +834,7 @@ int dccp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
                case DCCP_PKT_CLOSEREQ:
                        if (!(flags & MSG_PEEK))
                                dccp_finish_passive_close(sk);
-                       /* fall through */
+                       fallthrough;
                case DCCP_PKT_RESET:
                        dccp_pr_debug("found fin (%s) ok!\n",
                                      dccp_packet_name(dh->dccph_type));
@@ -960,7 +960,7 @@ static void dccp_terminate_connection(struct sock *sk)
        case DCCP_PARTOPEN:
                dccp_pr_debug("Stop PARTOPEN timer (%p)\n", sk);
                inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
-               /* fall through */
+               fallthrough;
        case DCCP_OPEN:
                dccp_send_close(sk, 1);
 
@@ -969,7 +969,7 @@ static void dccp_terminate_connection(struct sock *sk)
                        next_state = DCCP_ACTIVE_CLOSEREQ;
                else
                        next_state = DCCP_CLOSING;
-               /* fall through */
+               fallthrough;
        default:
                dccp_set_state(sk, next_state);
        }
index 3b53d76..5dbd45d 100644 (file)
@@ -623,12 +623,12 @@ static void dn_destroy_sock(struct sock *sk)
                goto disc_reject;
        case DN_RUN:
                scp->state = DN_DI;
-               /* fall through */
+               fallthrough;
        case DN_DI:
        case DN_DR:
 disc_reject:
                dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation);
-               /* fall through */
+               fallthrough;
        case DN_NC:
        case DN_NR:
        case DN_RJ:
@@ -642,7 +642,7 @@ disc_reject:
                break;
        default:
                printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n");
-               /* fall through */
+               fallthrough;
        case DN_O:
                dn_stop_slow_timer(sk);
 
index c68503a..c97bdca 100644 (file)
@@ -483,7 +483,7 @@ static void dn_nsp_disc_conf(struct sock *sk, struct sk_buff *skb)
                break;
        case DN_RUN:
                sk->sk_shutdown |= SHUTDOWN_MASK;
-               /* fall through */
+               fallthrough;
        case DN_CC:
                scp->state = DN_CN;
        }
index 33fefb0..4086f9c 100644 (file)
@@ -156,7 +156,7 @@ static void dn_rehash_zone(struct dn_zone *dz)
        default:
                printk(KERN_DEBUG "DECnet: dn_rehash_zone: BUG! %d\n",
                       old_divisor);
-               /* fall through */
+               fallthrough;
        case 256:
                new_divisor = 1024;
                new_hashmask = 0x3FF;
index deae519..67b5ab2 100644 (file)
@@ -75,7 +75,7 @@ static void strip_it(char *str)
                case '\r':
                case ':':
                        *str = 0;
-                       /* Fallthrough */
+                       fallthrough;
                case 0:
                        return;
                }
index 41d60ee..9af1a2d 100644 (file)
@@ -2009,7 +2009,7 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
        switchdev_work->event = event;
 
        switch (event) {
-       case SWITCHDEV_FDB_ADD_TO_DEVICE: /* fall through */
+       case SWITCHDEV_FDB_ADD_TO_DEVICE:
        case SWITCHDEV_FDB_DEL_TO_DEVICE:
                if (dsa_slave_switchdev_fdb_work_init(switchdev_work, ptr))
                        goto err_fdb_work_init;
index 4e632dc..495635f 100644 (file)
@@ -224,7 +224,9 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
        DECLARE_BITMAP(wanted_diff_mask, NETDEV_FEATURE_COUNT);
        DECLARE_BITMAP(active_diff_mask, NETDEV_FEATURE_COUNT);
        DECLARE_BITMAP(old_active, NETDEV_FEATURE_COUNT);
+       DECLARE_BITMAP(old_wanted, NETDEV_FEATURE_COUNT);
        DECLARE_BITMAP(new_active, NETDEV_FEATURE_COUNT);
+       DECLARE_BITMAP(new_wanted, NETDEV_FEATURE_COUNT);
        DECLARE_BITMAP(req_wanted, NETDEV_FEATURE_COUNT);
        DECLARE_BITMAP(req_mask, NETDEV_FEATURE_COUNT);
        struct nlattr *tb[ETHTOOL_A_FEATURES_MAX + 1];
@@ -250,6 +252,7 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
 
        rtnl_lock();
        ethnl_features_to_bitmap(old_active, dev->features);
+       ethnl_features_to_bitmap(old_wanted, dev->wanted_features);
        ret = ethnl_parse_bitset(req_wanted, req_mask, NETDEV_FEATURE_COUNT,
                                 tb[ETHTOOL_A_FEATURES_WANTED],
                                 netdev_features_strings, info->extack);
@@ -261,17 +264,15 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
                goto out_rtnl;
        }
 
-       /* set req_wanted bits not in req_mask from old_active */
+       /* set req_wanted bits not in req_mask from old_wanted */
        bitmap_and(req_wanted, req_wanted, req_mask, NETDEV_FEATURE_COUNT);
-       bitmap_andnot(new_active, old_active, req_mask, NETDEV_FEATURE_COUNT);
-       bitmap_or(req_wanted, new_active, req_wanted, NETDEV_FEATURE_COUNT);
-       if (bitmap_equal(req_wanted, old_active, NETDEV_FEATURE_COUNT)) {
-               ret = 0;
-               goto out_rtnl;
+       bitmap_andnot(new_wanted, old_wanted, req_mask, NETDEV_FEATURE_COUNT);
+       bitmap_or(req_wanted, new_wanted, req_wanted, NETDEV_FEATURE_COUNT);
+       if (!bitmap_equal(req_wanted, old_wanted, NETDEV_FEATURE_COUNT)) {
+               dev->wanted_features &= ~dev->hw_features;
+               dev->wanted_features |= ethnl_bitmap_to_features(req_wanted) & dev->hw_features;
+               __netdev_update_features(dev);
        }
-
-       dev->wanted_features = ethnl_bitmap_to_features(req_wanted);
-       __netdev_update_features(dev);
        ethnl_features_to_bitmap(new_active, dev->features);
        mod = !bitmap_equal(old_active, new_active, NETDEV_FEATURE_COUNT);
 
index bbe9b3b..be6f06a 100644 (file)
@@ -195,7 +195,7 @@ static int lowpan_frag_rx_handlers_result(struct sk_buff *skb,
                net_warn_ratelimited("%s: received unknown dispatch\n",
                                     __func__);
 
-               /* fall-through */
+               fallthrough;
        default:
                /* all others failure */
                return NET_RX_DROP;
index b34d050..517e649 100644 (file)
@@ -35,11 +35,11 @@ static int lowpan_rx_handlers_result(struct sk_buff *skb, lowpan_rx_result res)
                net_warn_ratelimited("%s: received unknown dispatch\n",
                                     __func__);
 
-               /* fall-through */
+               fallthrough;
        case RX_DROP_UNUSABLE:
                kfree_skb(skb);
 
-               /* fall-through */
+               fallthrough;
        case RX_DROP:
                return NET_RX_DROP;
        case RX_QUEUED:
index 60db5a6..87983e7 100644 (file)
@@ -661,13 +661,13 @@ config TCP_CONG_BBR
 
          BBR (Bottleneck Bandwidth and RTT) TCP congestion control aims to
          maximize network utilization and minimize queues. It builds an explicit
-         model of the the bottleneck delivery rate and path round-trip
-         propagation delay. It tolerates packet loss and delay unrelated to
-         congestion. It can operate over LAN, WAN, cellular, wifi, or cable
-         modem links. It can coexist with flows that use loss-based congestion
-         control, and can operate with shallow buffers, deep buffers,
-         bufferbloat, policers, or AQM schemes that do not provide a delay
-         signal. It requires the fq ("Fair Queue") pacing packet scheduler.
+         model of the bottleneck delivery rate and path round-trip propagation
+         delay. It tolerates packet loss and delay unrelated to congestion. It
+         can operate over LAN, WAN, cellular, wifi, or cable modem links. It can
+         coexist with flows that use loss-based congestion control, and can
+         operate with shallow buffers, deep buffers, bufferbloat, policers, or
+         AQM schemes that do not provide a delay signal. It requires the fq
+         ("Fair Queue") pacing packet scheduler.
 
 choice
        prompt "Default TCP congestion control"
index c89b46f..ffc5332 100644 (file)
@@ -2121,7 +2121,8 @@ void fib_info_notify_update(struct net *net, struct nl_info *info)
                struct hlist_head *head = &net->ipv4.fib_table_hash[h];
                struct fib_table *tb;
 
-               hlist_for_each_entry_rcu(tb, head, tb_hlist)
+               hlist_for_each_entry_rcu(tb, head, tb_hlist,
+                                        lockdep_rtnl_is_held())
                        __fib_info_notify_update(net, tb, info);
        }
 }
index 7afde88..3f248a1 100644 (file)
@@ -3,7 +3,7 @@
  * nf_nat_pptp.c
  *
  * NAT support for PPTP (Point to Point Tunneling Protocol).
- * PPTP is a protocol for creating virtual private networks.
+ * PPTP is a protocol for creating virtual private networks.
  * It is a specification defined by Microsoft and some vendors
  * working with Microsoft.  PPTP is built on top of a modified
  * version of the Internet Generic Routing Encapsulation Protocol.
index cc8049b..134e923 100644 (file)
@@ -446,7 +446,7 @@ static int nh_check_attr_group(struct net *net, struct nlattr *tb[],
        unsigned int i, j;
        u8 nhg_fdb = 0;
 
-       if (len & (sizeof(struct nexthop_grp) - 1)) {
+       if (!len || len & (sizeof(struct nexthop_grp) - 1)) {
                NL_SET_ERR_MSG(extack,
                               "Invalid length for nexthop group attribute");
                return -EINVAL;
@@ -1187,6 +1187,9 @@ static struct nexthop *nexthop_create_group(struct net *net,
        struct nexthop *nh;
        int i;
 
+       if (WARN_ON(!num_nh))
+               return ERR_PTR(-EINVAL);
+
        nh = nexthop_alloc();
        if (!nh)
                return ERR_PTR(-ENOMEM);
index 6fd4330..407956b 100644 (file)
@@ -610,7 +610,7 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
        } else if (!ipc.oif) {
                ipc.oif = inet->uc_index;
        } else if (ipv4_is_lbcast(daddr) && inet->uc_index) {
-               /* oif is set, packet is to local broadcast and
+               /* oif is set, packet is to local broadcast
                 * and uc_index is set. oif is most likely set
                 * by sk_bound_dev_if. If uc_index != oif check if the
                 * oif is an L3 master and uc_index is an L3 slave.
index 8e761b8..01146b6 100644 (file)
@@ -1893,12 +1893,13 @@ EXPORT_SYMBOL(ipv6_chk_addr);
  *   2. does the address exist on the specific device
  *      (skip_dev_check = false)
  */
-int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
-                           const struct net_device *dev, bool skip_dev_check,
-                           int strict, u32 banned_flags)
+static struct net_device *
+__ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
+                         const struct net_device *dev, bool skip_dev_check,
+                         int strict, u32 banned_flags)
 {
        unsigned int hash = inet6_addr_hash(net, addr);
-       const struct net_device *l3mdev;
+       struct net_device *l3mdev, *ndev;
        struct inet6_ifaddr *ifp;
        u32 ifp_flags;
 
@@ -1909,10 +1910,11 @@ int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
                dev = NULL;
 
        hlist_for_each_entry_rcu(ifp, &inet6_addr_lst[hash], addr_lst) {
-               if (!net_eq(dev_net(ifp->idev->dev), net))
+               ndev = ifp->idev->dev;
+               if (!net_eq(dev_net(ndev), net))
                        continue;
 
-               if (l3mdev_master_dev_rcu(ifp->idev->dev) != l3mdev)
+               if (l3mdev_master_dev_rcu(ndev) != l3mdev)
                        continue;
 
                /* Decouple optimistic from tentative for evaluation here.
@@ -1923,15 +1925,23 @@ int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
                            : ifp->flags;
                if (ipv6_addr_equal(&ifp->addr, addr) &&
                    !(ifp_flags&banned_flags) &&
-                   (!dev || ifp->idev->dev == dev ||
+                   (!dev || ndev == dev ||
                     !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) {
                        rcu_read_unlock();
-                       return 1;
+                       return ndev;
                }
        }
 
        rcu_read_unlock();
-       return 0;
+       return NULL;
+}
+
+int ipv6_chk_addr_and_flags(struct net *net, const struct in6_addr *addr,
+                           const struct net_device *dev, bool skip_dev_check,
+                           int strict, u32 banned_flags)
+{
+       return __ipv6_chk_addr_and_flags(net, addr, dev, skip_dev_check,
+                                        strict, banned_flags) ? 1 : 0;
 }
 EXPORT_SYMBOL(ipv6_chk_addr_and_flags);
 
@@ -1990,35 +2000,11 @@ EXPORT_SYMBOL(ipv6_chk_prefix);
  *
  * The caller should be protected by RCU, or RTNL.
  */
-struct net_device *ipv6_dev_find(struct net *net, const struct in6_addr *addr)
+struct net_device *ipv6_dev_find(struct net *net, const struct in6_addr *addr,
+                                struct net_device *dev)
 {
-       unsigned int hash = inet6_addr_hash(net, addr);
-       struct inet6_ifaddr *ifp, *result = NULL;
-       struct net_device *dev = NULL;
-
-       rcu_read_lock();
-       hlist_for_each_entry_rcu(ifp, &inet6_addr_lst[hash], addr_lst) {
-               if (net_eq(dev_net(ifp->idev->dev), net) &&
-                   ipv6_addr_equal(&ifp->addr, addr)) {
-                       result = ifp;
-                       break;
-               }
-       }
-
-       if (!result) {
-               struct rt6_info *rt;
-
-               rt = rt6_lookup(net, addr, NULL, 0, NULL, 0);
-               if (rt) {
-                       dev = rt->dst.dev;
-                       ip6_rt_put(rt);
-               }
-       } else {
-               dev = result->idev->dev;
-       }
-       rcu_read_unlock();
-
-       return dev;
+       return __ipv6_chk_addr_and_flags(net, addr, dev, !dev, 1,
+                                        IFA_F_TENTATIVE);
 }
 EXPORT_SYMBOL(ipv6_dev_find);
 
index f635914..a0217e5 100644 (file)
@@ -915,7 +915,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,
                struct metadata_dst *tun_dst,
                bool log_ecn_err)
 {
-       return __ip6_tnl_rcv(t, skb, tpi, tun_dst, ip6ip6_dscp_ecn_decapsulate,
+       int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,
+                                   const struct ipv6hdr *ipv6h,
+                                   struct sk_buff *skb);
+
+       dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate;
+       if (tpi->proto == htons(ETH_P_IP))
+               dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate;
+
+       return __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
                             log_ecn_err);
 }
 EXPORT_SYMBOL(ip6_tnl_rcv);
index 409e79b..6d0e942 100644 (file)
@@ -245,9 +245,6 @@ static const struct nf_ipv6_ops ipv6ops = {
        .route_input            = ip6_route_input,
        .fragment               = ip6_fragment,
        .reroute                = nf_ip6_reroute,
-#if IS_MODULE(CONFIG_IPV6) && IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
-       .br_defrag              = nf_ct_frag6_gather,
-#endif
 #if IS_MODULE(CONFIG_IPV6)
        .br_fragment            = br_ip6_fragment,
 #endif
index fac2135..5b60a4b 100644 (file)
@@ -21,6 +21,7 @@
 #include <net/calipso.h>
 #endif
 
+static int two = 2;
 static int flowlabel_reflect_max = 0x7;
 static int auto_flowlabels_min;
 static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
@@ -150,7 +151,7 @@ static struct ctl_table ipv6_table_template[] = {
                .mode           = 0644,
                .proc_handler   = proc_rt6_multipath_hash_policy,
                .extra1         = SYSCTL_ZERO,
-               .extra2         = SYSCTL_ONE,
+               .extra2         = &two,
        },
        {
                .procname       = "seg6_flowlabel",
index 6ee9851..a95af62 100644 (file)
@@ -418,7 +418,7 @@ static void iucv_sock_close(struct sock *sk)
                        sk->sk_state = IUCV_DISCONN;
                        sk->sk_state_change(sk);
                }
-               /* fall through */
+               fallthrough;
 
        case IUCV_DISCONN:
                sk->sk_state = IUCV_CLOSING;
@@ -433,7 +433,7 @@ static void iucv_sock_close(struct sock *sk)
                                        iucv_sock_in_state(sk, IUCV_CLOSED, 0),
                                        timeo);
                }
-               /* fall through */
+               fallthrough;
 
        case IUCV_CLOSING:
                sk->sk_state = IUCV_CLOSED;
@@ -444,7 +444,7 @@ static void iucv_sock_close(struct sock *sk)
 
                skb_queue_purge(&iucv->send_skb_q);
                skb_queue_purge(&iucv->backlog_skb_q);
-               /* fall through */
+               fallthrough;
 
        default:
                iucv_sever_path(sk, 1);
@@ -2111,10 +2111,10 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
                        kfree_skb(skb);
                        break;
                }
-               /* fall through - and receive non-zero length data */
+               fallthrough;    /* and receive non-zero length data */
        case (AF_IUCV_FLAG_SHT):
                /* shutdown request */
-               /* fall through - and receive zero length data */
+               fallthrough;    /* and receive zero length data */
        case 0:
                /* plain data frame */
                IUCV_SKB_CB(skb)->class = trans_hdr->iucv_hdr.class;
index e71ca5a..864326f 100644 (file)
@@ -154,7 +154,7 @@ int l3mdev_master_upper_ifindex_by_index_rcu(struct net *net, int ifindex)
 EXPORT_SYMBOL_GPL(l3mdev_master_upper_ifindex_by_index_rcu);
 
 /**
- *     l3mdev_fib_table - get FIB table id associated with an L3
+ *     l3mdev_fib_table_rcu - get FIB table id associated with an L3
  *                             master interface
  *     @dev: targeted interface
  */
index 366f76c..3149730 100644 (file)
@@ -405,18 +405,14 @@ ieee80211_calc_legacy_rate_duration(u16 bitrate, bool short_pre,
        return duration;
 }
 
-u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
-                             struct ieee80211_rx_status *status,
-                             int len)
+static u32 ieee80211_get_rate_duration(struct ieee80211_hw *hw,
+                                      struct ieee80211_rx_status *status,
+                                      u32 *overhead)
 {
-       struct ieee80211_supported_band *sband;
-       const struct ieee80211_rate *rate;
        bool sgi = status->enc_flags & RX_ENC_FLAG_SHORT_GI;
-       bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE;
        int bw, streams;
        int group, idx;
        u32 duration;
-       bool cck;
 
        switch (status->bw) {
        case RATE_INFO_BW_20:
@@ -437,20 +433,6 @@ u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
        }
 
        switch (status->encoding) {
-       case RX_ENC_LEGACY:
-               if (WARN_ON_ONCE(status->band > NL80211_BAND_5GHZ))
-                       return 0;
-
-               sband = hw->wiphy->bands[status->band];
-               if (!sband || status->rate_idx >= sband->n_bitrates)
-                       return 0;
-
-               rate = &sband->bitrates[status->rate_idx];
-               cck = rate->flags & IEEE80211_RATE_MANDATORY_B;
-
-               return ieee80211_calc_legacy_rate_duration(rate->bitrate, sp,
-                                                          cck, len);
-
        case RX_ENC_VHT:
                streams = status->nss;
                idx = status->rate_idx;
@@ -477,51 +459,144 @@ u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
 
        duration = airtime_mcs_groups[group].duration[idx];
        duration <<= airtime_mcs_groups[group].shift;
+       *overhead = 36 + (streams << 2);
+
+       return duration;
+}
+
+
+u32 ieee80211_calc_rx_airtime(struct ieee80211_hw *hw,
+                             struct ieee80211_rx_status *status,
+                             int len)
+{
+       struct ieee80211_supported_band *sband;
+       u32 duration, overhead = 0;
+
+       if (status->encoding == RX_ENC_LEGACY) {
+               const struct ieee80211_rate *rate;
+               bool sp = status->enc_flags & RX_ENC_FLAG_SHORTPRE;
+               bool cck;
+
+               if (WARN_ON_ONCE(status->band > NL80211_BAND_5GHZ))
+                       return 0;
+
+               sband = hw->wiphy->bands[status->band];
+               if (!sband || status->rate_idx >= sband->n_bitrates)
+                       return 0;
+
+               rate = &sband->bitrates[status->rate_idx];
+               cck = rate->flags & IEEE80211_RATE_MANDATORY_B;
+
+               return ieee80211_calc_legacy_rate_duration(rate->bitrate, sp,
+                                                          cck, len);
+       }
+
+       duration = ieee80211_get_rate_duration(hw, status, &overhead);
+       if (!duration)
+               return 0;
+
        duration *= len;
        duration /= AVG_PKT_SIZE;
        duration /= 1024;
 
-       duration += 36 + (streams << 2);
-
-       return duration;
+       return duration + overhead;
 }
 EXPORT_SYMBOL_GPL(ieee80211_calc_rx_airtime);
 
-static u32 ieee80211_calc_tx_airtime_rate(struct ieee80211_hw *hw,
-                                         struct ieee80211_tx_rate *rate,
-                                         u8 band, int len)
+static bool ieee80211_fill_rate_info(struct ieee80211_hw *hw,
+                                    struct ieee80211_rx_status *stat, u8 band,
+                                    struct rate_info *ri)
 {
-       struct ieee80211_rx_status stat = {
-               .band = band,
-       };
+       struct ieee80211_supported_band *sband = hw->wiphy->bands[band];
+       int i;
 
-       if (rate->idx < 0 || !rate->count)
+       if (!ri || !sband)
+           return false;
+
+       stat->bw = ri->bw;
+       stat->nss = ri->nss;
+       stat->rate_idx = ri->mcs;
+
+       if (ri->flags & RATE_INFO_FLAGS_HE_MCS)
+               stat->encoding = RX_ENC_HE;
+       else if (ri->flags & RATE_INFO_FLAGS_VHT_MCS)
+               stat->encoding = RX_ENC_VHT;
+       else if (ri->flags & RATE_INFO_FLAGS_MCS)
+               stat->encoding = RX_ENC_HT;
+       else
+               stat->encoding = RX_ENC_LEGACY;
+
+       if (ri->flags & RATE_INFO_FLAGS_SHORT_GI)
+               stat->enc_flags |= RX_ENC_FLAG_SHORT_GI;
+
+       stat->he_gi = ri->he_gi;
+
+       if (stat->encoding != RX_ENC_LEGACY)
+               return true;
+
+       stat->rate_idx = 0;
+       for (i = 0; i < sband->n_bitrates; i++) {
+               if (ri->legacy != sband->bitrates[i].bitrate)
+                       continue;
+
+               stat->rate_idx = i;
+               return true;
+       }
+
+       return false;
+}
+
+static int ieee80211_fill_rx_status(struct ieee80211_rx_status *stat,
+                                   struct ieee80211_hw *hw,
+                                   struct ieee80211_tx_rate *rate,
+                                   struct rate_info *ri, u8 band, int len)
+{
+       memset(stat, 0, sizeof(*stat));
+       stat->band = band;
+
+       if (ieee80211_fill_rate_info(hw, stat, band, ri))
                return 0;
 
+       if (rate->idx < 0 || !rate->count)
+               return -1;
+
        if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
-               stat.bw = RATE_INFO_BW_80;
+               stat->bw = RATE_INFO_BW_80;
        else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
-               stat.bw = RATE_INFO_BW_40;
+               stat->bw = RATE_INFO_BW_40;
        else
-               stat.bw = RATE_INFO_BW_20;
+               stat->bw = RATE_INFO_BW_20;
 
-       stat.enc_flags = 0;
+       stat->enc_flags = 0;
        if (rate->flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
-               stat.enc_flags |= RX_ENC_FLAG_SHORTPRE;
+               stat->enc_flags |= RX_ENC_FLAG_SHORTPRE;
        if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
-               stat.enc_flags |= RX_ENC_FLAG_SHORT_GI;
+               stat->enc_flags |= RX_ENC_FLAG_SHORT_GI;
 
-       stat.rate_idx = rate->idx;
+       stat->rate_idx = rate->idx;
        if (rate->flags & IEEE80211_TX_RC_VHT_MCS) {
-               stat.encoding = RX_ENC_VHT;
-               stat.rate_idx = ieee80211_rate_get_vht_mcs(rate);
-               stat.nss = ieee80211_rate_get_vht_nss(rate);
+               stat->encoding = RX_ENC_VHT;
+               stat->rate_idx = ieee80211_rate_get_vht_mcs(rate);
+               stat->nss = ieee80211_rate_get_vht_nss(rate);
        } else if (rate->flags & IEEE80211_TX_RC_MCS) {
-               stat.encoding = RX_ENC_HT;
+               stat->encoding = RX_ENC_HT;
        } else {
-               stat.encoding = RX_ENC_LEGACY;
+               stat->encoding = RX_ENC_LEGACY;
        }
 
+       return 0;
+}
+
+static u32 ieee80211_calc_tx_airtime_rate(struct ieee80211_hw *hw,
+                                         struct ieee80211_tx_rate *rate,
+                                         struct rate_info *ri,
+                                         u8 band, int len)
+{
+       struct ieee80211_rx_status stat;
+
+       if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len))
+               return 0;
+
        return ieee80211_calc_rx_airtime(hw, &stat, len);
 }
 
@@ -536,7 +611,7 @@ u32 ieee80211_calc_tx_airtime(struct ieee80211_hw *hw,
                struct ieee80211_tx_rate *rate = &info->status.rates[i];
                u32 cur_duration;
 
-               cur_duration = ieee80211_calc_tx_airtime_rate(hw, rate,
+               cur_duration = ieee80211_calc_tx_airtime_rate(hw, rate, NULL,
                                                              info->band, len);
                if (!cur_duration)
                        break;
@@ -572,26 +647,41 @@ u32 ieee80211_calc_expected_tx_airtime(struct ieee80211_hw *hw,
        if (pubsta) {
                struct sta_info *sta = container_of(pubsta, struct sta_info,
                                                    sta);
+               struct ieee80211_rx_status stat;
                struct ieee80211_tx_rate *rate = &sta->tx_stats.last_rate;
-               u32 airtime;
+               struct rate_info *ri = &sta->tx_stats.last_rate_info;
+               u32 duration, overhead;
+               u8 agg_shift;
 
-               if (!(rate->flags & (IEEE80211_TX_RC_VHT_MCS |
-                                    IEEE80211_TX_RC_MCS)))
-                       ampdu = false;
+               if (ieee80211_fill_rx_status(&stat, hw, rate, ri, band, len))
+                       return 0;
 
+               if (stat.encoding == RX_ENC_LEGACY || !ampdu)
+                       return ieee80211_calc_rx_airtime(hw, &stat, len);
+
+               duration = ieee80211_get_rate_duration(hw, &stat, &overhead);
                /*
                 * Assume that HT/VHT transmission on any AC except VO will
                 * use aggregation. Since we don't have reliable reporting
-                * of aggregation length, assume an average of 16.
+                * of aggregation length, assume an average size based on the
+                * tx rate.
                 * This will not be very accurate, but much better than simply
-                * assuming un-aggregated tx.
+                * assuming un-aggregated tx in all cases.
                 */
-               airtime = ieee80211_calc_tx_airtime_rate(hw, rate, band,
-                                                        ampdu ? len * 16 : len);
-               if (ampdu)
-                       airtime /= 16;
-
-               return airtime;
+               if (duration > 400) /* <= VHT20 MCS2 1S */
+                       agg_shift = 1;
+               else if (duration > 250) /* <= VHT20 MCS3 1S or MCS1 2S */
+                       agg_shift = 2;
+               else if (duration > 150) /* <= VHT20 MCS5 1S or MCS3 2S */
+                       agg_shift = 3;
+               else
+                       agg_shift = 4;
+
+               duration *= len;
+               duration /= AVG_PKT_SIZE;
+               duration /= 1024;
+
+               return duration + (overhead >> agg_shift);
        }
 
        if (!conf)
index 9d398c9..d501011 100644 (file)
@@ -524,7 +524,7 @@ struct ieee80211_sta_rx_stats {
  * @status_stats.retry_failed: # of frames that failed after retry
  * @status_stats.retry_count: # of retries attempted
  * @status_stats.lost_packets: # of lost packets
- * @status_stats.last_tdls_pkt_time: timestamp of last TDLS packet
+ * @status_stats.last_pkt_time: timestamp of last ACKed packet
  * @status_stats.msdu_retries: # of MSDU retries
  * @status_stats.msdu_failed: # of failed MSDUs
  * @status_stats.last_ack: last ack timestamp (jiffies)
@@ -597,7 +597,7 @@ struct sta_info {
                unsigned long filtered;
                unsigned long retry_failed, retry_count;
                unsigned int lost_packets;
-               unsigned long last_tdls_pkt_time;
+               unsigned long last_pkt_time;
                u64 msdu_retries[IEEE80211_NUM_TIDS + 1];
                u64 msdu_failed[IEEE80211_NUM_TIDS + 1];
                unsigned long last_ack;
@@ -611,6 +611,7 @@ struct sta_info {
                u64 packets[IEEE80211_NUM_ACS];
                u64 bytes[IEEE80211_NUM_ACS];
                struct ieee80211_tx_rate last_rate;
+               struct rate_info last_rate_info;
                u64 msdu[IEEE80211_NUM_TIDS + 1];
        } tx_stats;
        u16 tid_seq[IEEE80211_QOS_CTL_TID_MASK + 1];
index adb1d30..0794396 100644 (file)
@@ -755,12 +755,16 @@ static void ieee80211_report_used_skb(struct ieee80211_local *local,
  *  - current throughput (higher value for higher tpt)?
  */
 #define STA_LOST_PKT_THRESHOLD 50
+#define STA_LOST_PKT_TIME      HZ              /* 1 sec since last ACK */
 #define STA_LOST_TDLS_PKT_THRESHOLD    10
 #define STA_LOST_TDLS_PKT_TIME         (10*HZ) /* 10secs since last ACK */
 
 static void ieee80211_lost_packet(struct sta_info *sta,
                                  struct ieee80211_tx_info *info)
 {
+       unsigned long pkt_time = STA_LOST_PKT_TIME;
+       unsigned int pkt_thr = STA_LOST_PKT_THRESHOLD;
+
        /* If driver relies on its own algorithm for station kickout, skip
         * mac80211 packet loss mechanism.
         */
@@ -773,21 +777,20 @@ static void ieee80211_lost_packet(struct sta_info *sta,
                return;
 
        sta->status_stats.lost_packets++;
-       if (!sta->sta.tdls &&
-           sta->status_stats.lost_packets < STA_LOST_PKT_THRESHOLD)
-               return;
+       if (sta->sta.tdls) {
+               pkt_time = STA_LOST_TDLS_PKT_TIME;
+               pkt_thr = STA_LOST_PKT_THRESHOLD;
+       }
 
        /*
         * If we're in TDLS mode, make sure that all STA_LOST_TDLS_PKT_THRESHOLD
         * of the last packets were lost, and that no ACK was received in the
         * last STA_LOST_TDLS_PKT_TIME ms, before triggering the CQM packet-loss
         * mechanism.
+        * For non-TDLS, use STA_LOST_PKT_THRESHOLD and STA_LOST_PKT_TIME
         */
-       if (sta->sta.tdls &&
-           (sta->status_stats.lost_packets < STA_LOST_TDLS_PKT_THRESHOLD ||
-            time_before(jiffies,
-                        sta->status_stats.last_tdls_pkt_time +
-                        STA_LOST_TDLS_PKT_TIME)))
+       if (sta->status_stats.lost_packets < pkt_thr ||
+           !time_after(jiffies, sta->status_stats.last_pkt_time + pkt_time))
                return;
 
        cfg80211_cqm_pktloss_notify(sta->sdata->dev, sta->sta.addr,
@@ -1033,9 +1036,7 @@ static void __ieee80211_tx_status(struct ieee80211_hw *hw,
                                        sta->status_stats.lost_packets = 0;
 
                                /* Track when last TDLS packet was ACKed */
-                               if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
-                                       sta->status_stats.last_tdls_pkt_time =
-                                               jiffies;
+                               sta->status_stats.last_pkt_time = jiffies;
                        } else if (noack_success) {
                                /* nothing to do here, do not account as lost */
                        } else {
@@ -1137,9 +1138,17 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
        struct ieee80211_tx_info *info = status->info;
        struct ieee80211_sta *pubsta = status->sta;
        struct ieee80211_supported_band *sband;
+       struct sta_info *sta;
        int retry_count;
        bool acked, noack_success;
 
+       if (pubsta) {
+               sta = container_of(pubsta, struct sta_info, sta);
+
+               if (status->rate)
+                       sta->tx_stats.last_rate_info = *status->rate;
+       }
+
        if (status->skb)
                return __ieee80211_tx_status(hw, status);
 
@@ -1154,10 +1163,6 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
        noack_success = !!(info->flags & IEEE80211_TX_STAT_NOACK_TRANSMITTED);
 
        if (pubsta) {
-               struct sta_info *sta;
-
-               sta = container_of(pubsta, struct sta_info, sta);
-
                if (!acked && !noack_success)
                        sta->status_stats.retry_failed++;
                sta->status_stats.retry_count += retry_count;
@@ -1168,9 +1173,8 @@ void ieee80211_tx_status_ext(struct ieee80211_hw *hw,
                        if (sta->status_stats.lost_packets)
                                sta->status_stats.lost_packets = 0;
 
-                       /* Track when last TDLS packet was ACKed */
-                       if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
-                               sta->status_stats.last_tdls_pkt_time = jiffies;
+                       /* Track when last packet was ACKed */
+                       sta->status_stats.last_pkt_time = jiffies;
                } else if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
                        return;
                } else if (noack_success) {
@@ -1259,8 +1263,7 @@ void ieee80211_tx_status_8023(struct ieee80211_hw *hw,
                        if (sta->status_stats.lost_packets)
                                sta->status_stats.lost_packets = 0;
 
-                       if (test_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH))
-                               sta->status_stats.last_tdls_pkt_time = jiffies;
+                       sta->status_stats.last_pkt_time = jiffies;
                } else {
                        ieee80211_lost_packet(sta, info);
                }
index 6fdd0c9..f2868a8 100644 (file)
@@ -1516,7 +1516,7 @@ static void mpls_ifdown(struct net_device *dev, int event)
                        case NETDEV_DOWN:
                        case NETDEV_UNREGISTER:
                                nh_flags |= RTNH_F_DEAD;
-                               /* fall through */
+                               fallthrough;
                        case NETDEV_CHANGE:
                                nh_flags |= RTNH_F_LINKDOWN;
                                break;
index 8c1d1a5..365ba96 100644 (file)
@@ -193,7 +193,6 @@ static void mptcp_check_data_fin_ack(struct sock *sk)
                        sk->sk_state_change(sk);
                        break;
                case TCP_CLOSING:
-                       fallthrough;
                case TCP_LAST_ACK:
                        inet_sk_state_store(sk, TCP_CLOSE);
                        sk->sk_state_change(sk);
@@ -725,8 +724,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
                if (!psize)
                        return -EINVAL;
 
-               if (!sk_wmem_schedule(sk, psize + dfrag->overhead))
+               if (!sk_wmem_schedule(sk, psize + dfrag->overhead)) {
+                       iov_iter_revert(&msg->msg_iter, psize);
                        return -ENOMEM;
+               }
        } else {
                offset = dfrag->offset;
                psize = min_t(size_t, dfrag->data_len, avail_size);
@@ -737,8 +738,11 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
         */
        ret = do_tcp_sendpages(ssk, page, offset, psize,
                               msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT);
-       if (ret <= 0)
+       if (ret <= 0) {
+               if (!retransmission)
+                       iov_iter_revert(&msg->msg_iter, psize);
                return ret;
+       }
 
        frag_truesize += ret;
        if (!retransmission) {
@@ -887,7 +891,6 @@ restart:
                goto out;
        }
 
-wait_for_sndbuf:
        __mptcp_flush_join_list(msk);
        ssk = mptcp_subflow_get_send(msk);
        while (!sk_stream_memory_free(sk) ||
@@ -977,7 +980,7 @@ wait_for_sndbuf:
                                 */
                                mptcp_set_timeout(sk, ssk);
                                release_sock(ssk);
-                               goto wait_for_sndbuf;
+                               goto restart;
                        }
                }
        }
@@ -1388,7 +1391,9 @@ static void mptcp_worker(struct work_struct *work)
        struct mptcp_data_frag *dfrag;
        u64 orig_write_seq;
        size_t copied = 0;
-       struct msghdr msg;
+       struct msghdr msg = {
+               .msg_flags = MSG_DONTWAIT,
+       };
        long timeo = 0;
 
        lock_sock(sk);
@@ -1421,7 +1426,6 @@ static void mptcp_worker(struct work_struct *work)
 
        lock_sock(ssk);
 
-       msg.msg_flags = MSG_DONTWAIT;
        orig_len = dfrag->data_len;
        orig_offset = dfrag->offset;
        orig_write_seq = dfrag->data_seq;
@@ -1535,7 +1539,7 @@ static void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how)
        case TCP_LISTEN:
                if (!(how & RCV_SHUTDOWN))
                        break;
-               /* fall through */
+               fallthrough;
        case TCP_SYN_SENT:
                tcp_disconnect(ssk, O_NONBLOCK);
                break;
index 1f387be..f1be3e3 100644 (file)
@@ -474,7 +474,7 @@ static void ncsi_suspend_channel(struct ncsi_dev_priv *ndp)
        switch (nd->state) {
        case ncsi_dev_state_suspend:
                nd->state = ncsi_dev_state_suspend_select;
-               /* Fall through */
+               fallthrough;
        case ncsi_dev_state_suspend_select:
                ndp->pending_req_num = 1;
 
@@ -1302,7 +1302,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
        switch (nd->state) {
        case ncsi_dev_state_probe:
                nd->state = ncsi_dev_state_probe_deselect;
-               /* Fall through */
+               fallthrough;
        case ncsi_dev_state_probe_deselect:
                ndp->pending_req_num = 8;
 
index 32b0288..dc2e7da 100644 (file)
@@ -315,7 +315,7 @@ tcp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
        switch (skb->ip_summed) {
        case CHECKSUM_NONE:
                skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
-               /* fall through */
+               fallthrough;
        case CHECKSUM_COMPLETE:
 #ifdef CONFIG_IP_VS_IPV6
                if (af == AF_INET6) {
index 153d896..68260d9 100644 (file)
@@ -318,7 +318,7 @@ udp_csum_check(int af, struct sk_buff *skb, struct ip_vs_protocol *pp)
                case CHECKSUM_NONE:
                        skb->csum = skb_checksum(skb, udphoff,
                                                 skb->len - udphoff, 0);
-                       /* fall through */
+                       fallthrough;
                case CHECKSUM_COMPLETE:
 #ifdef CONFIG_IP_VS_IPV6
                        if (af == AF_INET6) {
index 1f44d52..5105d42 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Connection tracking support for PPTP (Point to Point Tunneling Protocol).
- * PPTP is a protocol for creating virtual private networks.
+ * PPTP is a protocol for creating virtual private networks.
  * It is a specification defined by Microsoft and some vendors
  * working with Microsoft.  PPTP is built on top of a modified
  * version of the Internet Generic Routing Encapsulation Protocol.
index 4f897b1..810cca2 100644 (file)
@@ -62,6 +62,8 @@ static const unsigned int sctp_timeouts[SCTP_CONNTRACK_MAX] = {
        [SCTP_CONNTRACK_HEARTBEAT_ACKED]        = 210 SECS,
 };
 
+#define        SCTP_FLAG_HEARTBEAT_VTAG_FAILED 1
+
 #define sNO SCTP_CONNTRACK_NONE
 #define        sCL SCTP_CONNTRACK_CLOSED
 #define        sCW SCTP_CONNTRACK_COOKIE_WAIT
@@ -369,6 +371,7 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,
        u_int32_t offset, count;
        unsigned int *timeouts;
        unsigned long map[256 / sizeof(unsigned long)] = { 0 };
+       bool ignore = false;
 
        if (sctp_error(skb, dataoff, state))
                return -NF_ACCEPT;
@@ -427,15 +430,39 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,
                        /* Sec 8.5.1 (D) */
                        if (sh->vtag != ct->proto.sctp.vtag[dir])
                                goto out_unlock;
-               } else if (sch->type == SCTP_CID_HEARTBEAT ||
-                          sch->type == SCTP_CID_HEARTBEAT_ACK) {
+               } else if (sch->type == SCTP_CID_HEARTBEAT) {
+                       if (ct->proto.sctp.vtag[dir] == 0) {
+                               pr_debug("Setting %d vtag %x for dir %d\n", sch->type, sh->vtag, dir);
+                               ct->proto.sctp.vtag[dir] = sh->vtag;
+                       } else if (sh->vtag != ct->proto.sctp.vtag[dir]) {
+                               if (test_bit(SCTP_CID_DATA, map) || ignore)
+                                       goto out_unlock;
+
+                               ct->proto.sctp.flags |= SCTP_FLAG_HEARTBEAT_VTAG_FAILED;
+                               ct->proto.sctp.last_dir = dir;
+                               ignore = true;
+                               continue;
+                       } else if (ct->proto.sctp.flags & SCTP_FLAG_HEARTBEAT_VTAG_FAILED) {
+                               ct->proto.sctp.flags &= ~SCTP_FLAG_HEARTBEAT_VTAG_FAILED;
+                       }
+               } else if (sch->type == SCTP_CID_HEARTBEAT_ACK) {
                        if (ct->proto.sctp.vtag[dir] == 0) {
                                pr_debug("Setting vtag %x for dir %d\n",
                                         sh->vtag, dir);
                                ct->proto.sctp.vtag[dir] = sh->vtag;
                        } else if (sh->vtag != ct->proto.sctp.vtag[dir]) {
-                               pr_debug("Verification tag check failed\n");
-                               goto out_unlock;
+                               if (test_bit(SCTP_CID_DATA, map) || ignore)
+                                       goto out_unlock;
+
+                               if ((ct->proto.sctp.flags & SCTP_FLAG_HEARTBEAT_VTAG_FAILED) == 0 ||
+                                   ct->proto.sctp.last_dir == dir)
+                                       goto out_unlock;
+
+                               ct->proto.sctp.flags &= ~SCTP_FLAG_HEARTBEAT_VTAG_FAILED;
+                               ct->proto.sctp.vtag[dir] = sh->vtag;
+                               ct->proto.sctp.vtag[!dir] = 0;
+                       } else if (ct->proto.sctp.flags & SCTP_FLAG_HEARTBEAT_VTAG_FAILED) {
+                               ct->proto.sctp.flags &= ~SCTP_FLAG_HEARTBEAT_VTAG_FAILED;
                        }
                }
 
@@ -470,6 +497,10 @@ int nf_conntrack_sctp_packet(struct nf_conn *ct,
        }
        spin_unlock_bh(&ct->lock);
 
+       /* allow but do not refresh timeout */
+       if (ignore)
+               return NF_ACCEPT;
+
        timeouts = nf_ct_timeout_lookup(ct);
        if (!timeouts)
                timeouts = nf_sctp_pernet(nf_ct_net(ct))->timeouts;
index 6892e49..e8c86ee 100644 (file)
@@ -1152,7 +1152,7 @@ int nf_conntrack_tcp_packet(struct nf_conn *ct,
                   && (old_state == TCP_CONNTRACK_SYN_RECV
                       || old_state == TCP_CONNTRACK_ESTABLISHED)
                   && new_state == TCP_CONNTRACK_ESTABLISHED) {
-               /* Set ASSURED if we see see valid ack in ESTABLISHED
+               /* Set ASSURED if we see valid ack in ESTABLISHED
                   after SYN_RECV or a valid answer for a picked up
                   connection. */
                set_bit(IPS_ASSURED_BIT, &ct->status);
index 760ca24..af402f4 100644 (file)
@@ -81,18 +81,6 @@ static bool udp_error(struct sk_buff *skb,
        return false;
 }
 
-static void nf_conntrack_udp_refresh_unreplied(struct nf_conn *ct,
-                                              struct sk_buff *skb,
-                                              enum ip_conntrack_info ctinfo,
-                                              u32 extra_jiffies)
-{
-       if (unlikely(ctinfo == IP_CT_ESTABLISHED_REPLY &&
-                    ct->status & IPS_NAT_CLASH))
-               nf_ct_kill(ct);
-       else
-               nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies);
-}
-
 /* Returns verdict for packet, and may modify conntracktype */
 int nf_conntrack_udp_packet(struct nf_conn *ct,
                            struct sk_buff *skb,
@@ -124,12 +112,15 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,
 
                nf_ct_refresh_acct(ct, ctinfo, skb, extra);
 
+               /* never set ASSURED for IPS_NAT_CLASH, they time out soon */
+               if (unlikely((ct->status & IPS_NAT_CLASH)))
+                       return NF_ACCEPT;
+
                /* Also, more likely to be important, and not a probe */
                if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
                        nf_conntrack_event_cache(IPCT_ASSURED, ct);
        } else {
-               nf_conntrack_udp_refresh_unreplied(ct, skb, ctinfo,
-                                                  timeouts[UDP_CT_UNREPLIED]);
+               nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED]);
        }
        return NF_ACCEPT;
 }
@@ -206,12 +197,15 @@ int nf_conntrack_udplite_packet(struct nf_conn *ct,
        if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
                nf_ct_refresh_acct(ct, ctinfo, skb,
                                   timeouts[UDP_CT_REPLIED]);
+
+               if (unlikely((ct->status & IPS_NAT_CLASH)))
+                       return NF_ACCEPT;
+
                /* Also, more likely to be important, and not a probe */
                if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
                        nf_conntrack_event_cache(IPCT_ASSURED, ct);
        } else {
-               nf_conntrack_udp_refresh_unreplied(ct, skb, ctinfo,
-                                                  timeouts[UDP_CT_UNREPLIED]);
+               nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED]);
        }
        return NF_ACCEPT;
 }
index d878e34..b7dc1cb 100644 (file)
@@ -815,11 +815,11 @@ static int nf_tables_gettable(struct net *net, struct sock *nlsk,
                                        nlh->nlmsg_seq, NFT_MSG_NEWTABLE, 0,
                                        family, table);
        if (err < 0)
-               goto err;
+               goto err_fill_table_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
 
-err:
+err_fill_table_info:
        kfree_skb(skb2);
        return err;
 }
@@ -1563,11 +1563,11 @@ static int nf_tables_getchain(struct net *net, struct sock *nlsk,
                                        nlh->nlmsg_seq, NFT_MSG_NEWCHAIN, 0,
                                        family, table, chain);
        if (err < 0)
-               goto err;
+               goto err_fill_chain_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
 
-err:
+err_fill_chain_info:
        kfree_skb(skb2);
        return err;
 }
@@ -2018,8 +2018,10 @@ static int nf_tables_addchain(struct nft_ctx *ctx, u8 family, u8 genmask,
        if (nla[NFTA_CHAIN_NAME]) {
                chain->name = nla_strdup(nla[NFTA_CHAIN_NAME], GFP_KERNEL);
        } else {
-               if (!(flags & NFT_CHAIN_BINDING))
-                       return -EINVAL;
+               if (!(flags & NFT_CHAIN_BINDING)) {
+                       err = -EINVAL;
+                       goto err1;
+               }
 
                snprintf(name, sizeof(name), "__chain%llu", ++chain_id);
                chain->name = kstrdup(name, GFP_KERNEL);
@@ -3006,11 +3008,11 @@ static int nf_tables_getrule(struct net *net, struct sock *nlsk,
                                       nlh->nlmsg_seq, NFT_MSG_NEWRULE, 0,
                                       family, table, chain, rule, NULL);
        if (err < 0)
-               goto err;
+               goto err_fill_rule_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
 
-err:
+err_fill_rule_info:
        kfree_skb(skb2);
        return err;
 }
@@ -3768,7 +3770,8 @@ static int nf_tables_fill_set(struct sk_buff *skb, const struct nft_ctx *ctx,
                        goto nla_put_failure;
        }
 
-       if (nla_put(skb, NFTA_SET_USERDATA, set->udlen, set->udata))
+       if (set->udata &&
+           nla_put(skb, NFTA_SET_USERDATA, set->udlen, set->udata))
                goto nla_put_failure;
 
        nest = nla_nest_start_noflag(skb, NFTA_SET_DESC);
@@ -3965,11 +3968,11 @@ static int nf_tables_getset(struct net *net, struct sock *nlsk,
 
        err = nf_tables_fill_set(skb2, &ctx, set, NFT_MSG_NEWSET, 0);
        if (err < 0)
-               goto err;
+               goto err_fill_set_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
 
-err:
+err_fill_set_info:
        kfree_skb(skb2);
        return err;
 }
@@ -4857,24 +4860,18 @@ static int nft_get_set_elem(struct nft_ctx *ctx, struct nft_set *set,
        err = -ENOMEM;
        skb = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
        if (skb == NULL)
-               goto err1;
+               return err;
 
        err = nf_tables_fill_setelem_info(skb, ctx, ctx->seq, ctx->portid,
                                          NFT_MSG_NEWSETELEM, 0, set, &elem);
        if (err < 0)
-               goto err2;
+               goto err_fill_setelem;
 
-       err = nfnetlink_unicast(skb, ctx->net, ctx->portid, MSG_DONTWAIT);
-       /* This avoids a loop in nfnetlink. */
-       if (err < 0)
-               goto err1;
+       return nfnetlink_unicast(skb, ctx->net, ctx->portid);
 
-       return 0;
-err2:
+err_fill_setelem:
        kfree_skb(skb);
-err1:
-       /* this avoids a loop in nfnetlink. */
-       return err == -EAGAIN ? -ENOBUFS : err;
+       return err;
 }
 
 /* called with rcu_read_lock held */
@@ -6179,10 +6176,11 @@ static int nf_tables_getobj(struct net *net, struct sock *nlsk,
                                      nlh->nlmsg_seq, NFT_MSG_NEWOBJ, 0,
                                      family, table, obj, reset);
        if (err < 0)
-               goto err;
+               goto err_fill_obj_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
-err:
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
+
+err_fill_obj_info:
        kfree_skb(skb2);
        return err;
 }
@@ -7042,10 +7040,11 @@ static int nf_tables_getflowtable(struct net *net, struct sock *nlsk,
                                            NFT_MSG_NEWFLOWTABLE, 0, family,
                                            flowtable, &flowtable->hook_list);
        if (err < 0)
-               goto err;
+               goto err_fill_flowtable_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
-err:
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
+
+err_fill_flowtable_info:
        kfree_skb(skb2);
        return err;
 }
@@ -7231,10 +7230,11 @@ static int nf_tables_getgen(struct net *net, struct sock *nlsk,
        err = nf_tables_fill_gen_info(skb2, net, NETLINK_CB(skb).portid,
                                      nlh->nlmsg_seq);
        if (err < 0)
-               goto err;
+               goto err_fill_gen_info;
 
-       return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
-err:
+       return nfnetlink_unicast(skb2, net, NETLINK_CB(skb).portid);
+
+err_fill_gen_info:
        kfree_skb(skb2);
        return err;
 }
index 5f24edf..3a2e64e 100644 (file)
@@ -149,10 +149,15 @@ int nfnetlink_set_err(struct net *net, u32 portid, u32 group, int error)
 }
 EXPORT_SYMBOL_GPL(nfnetlink_set_err);
 
-int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid,
-                     int flags)
+int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u32 portid)
 {
-       return netlink_unicast(net->nfnl, skb, portid, flags);
+       int err;
+
+       err = nlmsg_unicast(net->nfnl, skb, portid);
+       if (err == -EAGAIN)
+               err = -ENOBUFS;
+
+       return err;
 }
 EXPORT_SYMBOL_GPL(nfnetlink_unicast);
 
index f029924..b35e8d9 100644 (file)
@@ -356,8 +356,7 @@ __nfulnl_send(struct nfulnl_instance *inst)
                        goto out;
                }
        }
-       nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid,
-                         MSG_DONTWAIT);
+       nfnetlink_unicast(inst->skb, inst->net, inst->peer_portid);
 out:
        inst->qlen = 0;
        inst->skb = NULL;
index dadfc06..d1d8bca 100644 (file)
@@ -681,7 +681,7 @@ __nfqnl_enqueue_packet(struct net *net, struct nfqnl_instance *queue,
        *packet_id_ptr = htonl(entry->id);
 
        /* nfnetlink_unicast will either free the nskb or add it to a socket */
-       err = nfnetlink_unicast(nskb, net, queue->peer_portid, MSG_DONTWAIT);
+       err = nfnetlink_unicast(nskb, net, queue->peer_portid);
        if (err < 0) {
                if (queue->flags & NFQA_CFG_F_FAIL_OPEN) {
                        failopen = 1;
index 6428856..8e56f35 100644 (file)
@@ -27,8 +27,6 @@ struct nft_xt_match_priv {
        void *info;
 };
 
-static refcount_t nft_compat_pending_destroy = REFCOUNT_INIT(1);
-
 static int nft_compat_chain_validate_dependency(const struct nft_ctx *ctx,
                                                const char *tablename)
 {
@@ -215,6 +213,17 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
        return 0;
 }
 
+static void nft_compat_wait_for_destructors(void)
+{
+       /* xtables matches or targets can have side effects, e.g.
+        * creation/destruction of /proc files.
+        * The xt ->destroy functions are run asynchronously from
+        * work queue.  If we have pending invocations we thus
+        * need to wait for those to finish.
+        */
+       nf_tables_trans_destroy_flush_work();
+}
+
 static int
 nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
                const struct nlattr * const tb[])
@@ -238,14 +247,7 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
 
        nft_target_set_tgchk_param(&par, ctx, target, info, &e, proto, inv);
 
-       /* xtables matches or targets can have side effects, e.g.
-        * creation/destruction of /proc files.
-        * The xt ->destroy functions are run asynchronously from
-        * work queue.  If we have pending invocations we thus
-        * need to wait for those to finish.
-        */
-       if (refcount_read(&nft_compat_pending_destroy) > 1)
-               nf_tables_trans_destroy_flush_work();
+       nft_compat_wait_for_destructors();
 
        ret = xt_check_target(&par, size, proto, inv);
        if (ret < 0)
@@ -260,7 +262,6 @@ nft_target_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
 
 static void __nft_mt_tg_destroy(struct module *me, const struct nft_expr *expr)
 {
-       refcount_dec(&nft_compat_pending_destroy);
        module_put(me);
        kfree(expr->ops);
 }
@@ -468,6 +469,8 @@ __nft_match_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
 
        nft_match_set_mtchk_param(&par, ctx, match, info, &e, proto, inv);
 
+       nft_compat_wait_for_destructors();
+
        return xt_check_match(&par, size, proto, inv);
 }
 
@@ -716,14 +719,6 @@ static const struct nfnetlink_subsystem nfnl_compat_subsys = {
 
 static struct nft_expr_type nft_match_type;
 
-static void nft_mt_tg_deactivate(const struct nft_ctx *ctx,
-                                const struct nft_expr *expr,
-                                enum nft_trans_phase phase)
-{
-       if (phase == NFT_TRANS_COMMIT)
-               refcount_inc(&nft_compat_pending_destroy);
-}
-
 static const struct nft_expr_ops *
 nft_match_select_ops(const struct nft_ctx *ctx,
                     const struct nlattr * const tb[])
@@ -762,7 +757,6 @@ nft_match_select_ops(const struct nft_ctx *ctx,
        ops->type = &nft_match_type;
        ops->eval = nft_match_eval;
        ops->init = nft_match_init;
-       ops->deactivate = nft_mt_tg_deactivate,
        ops->destroy = nft_match_destroy;
        ops->dump = nft_match_dump;
        ops->validate = nft_match_validate;
@@ -853,7 +847,6 @@ nft_target_select_ops(const struct nft_ctx *ctx,
        ops->size = NFT_EXPR_SIZE(XT_ALIGN(target->targetsize));
        ops->init = nft_target_init;
        ops->destroy = nft_target_destroy;
-       ops->deactivate = nft_mt_tg_deactivate,
        ops->dump = nft_target_dump;
        ops->validate = nft_target_validate;
        ops->data = target;
@@ -917,8 +910,6 @@ static void __exit nft_compat_module_exit(void)
        nfnetlink_subsys_unregister(&nfnl_compat_subsys);
        nft_unregister_expr(&nft_target_type);
        nft_unregister_expr(&nft_match_type);
-
-       WARN_ON_ONCE(refcount_read(&nft_compat_pending_destroy) != 1);
 }
 
 MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_NFT_COMPAT);
index 0778283..3c48cdc 100644 (file)
@@ -44,7 +44,7 @@ static void nft_exthdr_ipv6_eval(const struct nft_expr *expr,
 
        err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
        if (priv->flags & NFT_EXTHDR_F_PRESENT) {
-               *dest = (err >= 0);
+               nft_reg_store8(dest, err >= 0);
                return;
        } else if (err < 0) {
                goto err;
@@ -141,7 +141,7 @@ static void nft_exthdr_ipv4_eval(const struct nft_expr *expr,
 
        err = ipv4_find_option(nft_net(pkt), skb, &offset, priv->type);
        if (priv->flags & NFT_EXTHDR_F_PRESENT) {
-               *dest = (err >= 0);
+               nft_reg_store8(dest, err >= 0);
                return;
        } else if (err < 0) {
                goto err;
index 3b9b97a..3a6c84f 100644 (file)
@@ -102,7 +102,7 @@ static void nft_flow_offload_eval(const struct nft_expr *expr,
        }
 
        if (nf_ct_ext_exist(ct, NF_CT_EXT_HELPER) ||
-           ct->status & IPS_SEQ_ADJUST)
+           ct->status & (IPS_SEQ_ADJUST | IPS_NAT_CLASH))
                goto out;
 
        if (!nf_ct_is_confirmed(ct))
index ed7cb9f..7a2e596 100644 (file)
@@ -87,7 +87,9 @@ void nft_payload_eval(const struct nft_expr *expr,
        u32 *dest = &regs->data[priv->dreg];
        int offset;
 
-       dest[priv->len / NFT_REG32_SIZE] = 0;
+       if (priv->len % NFT_REG32_SIZE)
+               dest[priv->len / NFT_REG32_SIZE] = 0;
+
        switch (priv->base) {
        case NFT_PAYLOAD_LL_HEADER:
                if (!skb_mac_header_was_set(skb))
index 4b2834f..217ab36 100644 (file)
@@ -218,11 +218,11 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
                               struct nft_rbtree_elem *new,
                               struct nft_set_ext **ext)
 {
+       bool overlap = false, dup_end_left = false, dup_end_right = false;
        struct nft_rbtree *priv = nft_set_priv(set);
        u8 genmask = nft_genmask_next(net);
        struct nft_rbtree_elem *rbe;
        struct rb_node *parent, **p;
-       bool overlap = false;
        int d;
 
        /* Detect overlaps as we descend the tree. Set the flag in these cases:
@@ -238,24 +238,44 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
         *
         * b1. _ _ __>|  !_ _ __|  (insert end before existing start)
         * b2. _ _ ___|  !_ _ _>|  (insert end after existing start)
-        * b3. _ _ ___! >|_ _ __|  (insert start after existing end)
+        * b3. _ _ ___! >|_ _ __|  (insert start after existing end, as a leaf)
+        *            '--' no nodes falling in this range
+        * b4.          >|_ _   !  (insert start before existing start)
         *
         * Case a3. resolves to b3.:
         * - if the inserted start element is the leftmost, because the '0'
         *   element in the tree serves as end element
-        * - otherwise, if an existing end is found. Note that end elements are
-        *   always inserted after corresponding start elements.
+        * - otherwise, if an existing end is found immediately to the left. If
+        *   there are existing nodes in between, we need to further descend the
+        *   tree before we can conclude the new start isn't causing an overlap
+        *
+        * or to b4., which, preceded by a3., means we already traversed one or
+        * more existing intervals entirely, from the right.
         *
         * For a new, rightmost pair of elements, we'll hit cases b3. and b2.,
         * in that order.
         *
         * The flag is also cleared in two special cases:
         *
-        * b4. |__ _ _!|<_ _ _   (insert start right before existing end)
-        * b5. |__ _ >|!__ _ _   (insert end right after existing start)
+        * b5. |__ _ _!|<_ _ _   (insert start right before existing end)
+        * b6. |__ _ >|!__ _ _   (insert end right after existing start)
         *
         * which always happen as last step and imply that no further
         * overlapping is possible.
+        *
+        * Another special case comes from the fact that start elements matching
+        * an already existing start element are allowed: insertion is not
+        * performed but we return -EEXIST in that case, and the error will be
+        * cleared by the caller if NLM_F_EXCL is not present in the request.
+        * This way, request for insertion of an exact overlap isn't reported as
+        * error to userspace if not desired.
+        *
+        * However, if the existing start matches a pre-existing start, but the
+        * end element doesn't match the corresponding pre-existing end element,
+        * we need to report a partial overlap. This is a local condition that
+        * can be noticed without need for a tracking flag, by checking for a
+        * local duplicated end for a corresponding start, from left and right,
+        * separately.
         */
 
        parent = NULL;
@@ -272,26 +292,41 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
                        if (nft_rbtree_interval_start(new)) {
                                if (nft_rbtree_interval_end(rbe) &&
                                    nft_set_elem_active(&rbe->ext, genmask) &&
-                                   !nft_set_elem_expired(&rbe->ext))
+                                   !nft_set_elem_expired(&rbe->ext) && !*p)
                                        overlap = false;
                        } else {
+                               if (dup_end_left && !*p)
+                                       return -ENOTEMPTY;
+
                                overlap = nft_rbtree_interval_end(rbe) &&
                                          nft_set_elem_active(&rbe->ext,
                                                              genmask) &&
                                          !nft_set_elem_expired(&rbe->ext);
+
+                               if (overlap) {
+                                       dup_end_right = true;
+                                       continue;
+                               }
                        }
                } else if (d > 0) {
                        p = &parent->rb_right;
 
                        if (nft_rbtree_interval_end(new)) {
+                               if (dup_end_right && !*p)
+                                       return -ENOTEMPTY;
+
                                overlap = nft_rbtree_interval_end(rbe) &&
                                          nft_set_elem_active(&rbe->ext,
                                                              genmask) &&
                                          !nft_set_elem_expired(&rbe->ext);
-                       } else if (nft_rbtree_interval_end(rbe) &&
-                                  nft_set_elem_active(&rbe->ext, genmask) &&
+
+                               if (overlap) {
+                                       dup_end_left = true;
+                                       continue;
+                               }
+                       } else if (nft_set_elem_active(&rbe->ext, genmask) &&
                                   !nft_set_elem_expired(&rbe->ext)) {
-                               overlap = true;
+                               overlap = nft_rbtree_interval_end(rbe);
                        }
                } else {
                        if (nft_rbtree_interval_end(rbe) &&
@@ -316,6 +351,8 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
                                p = &parent->rb_left;
                        }
                }
+
+               dup_end_left = dup_end_right = false;
        }
 
        if (overlap)
index 19bef17..6064118 100644 (file)
@@ -640,7 +640,7 @@ static void __net_exit recent_proc_net_exit(struct net *net)
        struct recent_table *t;
 
        /* recent_net_exit() is called before recent_mt_destroy(). Make sure
-        * that the parent xt_recent proc entry is is empty before trying to
+        * that the parent xt_recent proc entry is empty before trying to
         * remove it.
         */
        spin_lock_bh(&recent_lock);
index d07de2c..f73a838 100644 (file)
@@ -85,6 +85,7 @@ static void netlbl_domhsh_free_entry(struct rcu_head *entry)
                        kfree(netlbl_domhsh_addr6_entry(iter6));
                }
 #endif /* IPv6 */
+               kfree(ptr->def.addrsel);
        }
        kfree(ptr->domain);
        kfree(ptr);
@@ -537,6 +538,8 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
                                goto add_return;
                }
 #endif /* IPv6 */
+               /* cleanup the new entry since we've moved everything over */
+               netlbl_domhsh_free_entry(&entry->rcu);
        } else
                ret_val = -EINVAL;
 
@@ -580,6 +583,12 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
 {
        int ret_val = 0;
        struct audit_buffer *audit_buf;
+       struct netlbl_af4list *iter4;
+       struct netlbl_domaddr4_map *map4;
+#if IS_ENABLED(CONFIG_IPV6)
+       struct netlbl_af6list *iter6;
+       struct netlbl_domaddr6_map *map6;
+#endif /* IPv6 */
 
        if (entry == NULL)
                return -ENOENT;
@@ -597,6 +606,9 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
                ret_val = -ENOENT;
        spin_unlock(&netlbl_domhsh_lock);
 
+       if (ret_val)
+               return ret_val;
+
        audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info);
        if (audit_buf != NULL) {
                audit_log_format(audit_buf,
@@ -606,40 +618,29 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry,
                audit_log_end(audit_buf);
        }
 
-       if (ret_val == 0) {
-               struct netlbl_af4list *iter4;
-               struct netlbl_domaddr4_map *map4;
-#if IS_ENABLED(CONFIG_IPV6)
-               struct netlbl_af6list *iter6;
-               struct netlbl_domaddr6_map *map6;
-#endif /* IPv6 */
-
-               switch (entry->def.type) {
-               case NETLBL_NLTYPE_ADDRSELECT:
-                       netlbl_af4list_foreach_rcu(iter4,
-                                            &entry->def.addrsel->list4) {
-                               map4 = netlbl_domhsh_addr4_entry(iter4);
-                               cipso_v4_doi_putdef(map4->def.cipso);
-                       }
+       switch (entry->def.type) {
+       case NETLBL_NLTYPE_ADDRSELECT:
+               netlbl_af4list_foreach_rcu(iter4, &entry->def.addrsel->list4) {
+                       map4 = netlbl_domhsh_addr4_entry(iter4);
+                       cipso_v4_doi_putdef(map4->def.cipso);
+               }
 #if IS_ENABLED(CONFIG_IPV6)
-                       netlbl_af6list_foreach_rcu(iter6,
-                                            &entry->def.addrsel->list6) {
-                               map6 = netlbl_domhsh_addr6_entry(iter6);
-                               calipso_doi_putdef(map6->def.calipso);
-                       }
+               netlbl_af6list_foreach_rcu(iter6, &entry->def.addrsel->list6) {
+                       map6 = netlbl_domhsh_addr6_entry(iter6);
+                       calipso_doi_putdef(map6->def.calipso);
+               }
 #endif /* IPv6 */
-                       break;
-               case NETLBL_NLTYPE_CIPSOV4:
-                       cipso_v4_doi_putdef(entry->def.cipso);
-                       break;
+               break;
+       case NETLBL_NLTYPE_CIPSOV4:
+               cipso_v4_doi_putdef(entry->def.cipso);
+               break;
 #if IS_ENABLED(CONFIG_IPV6)
-               case NETLBL_NLTYPE_CALIPSO:
-                       calipso_doi_putdef(entry->def.calipso);
-                       break;
+       case NETLBL_NLTYPE_CALIPSO:
+               calipso_doi_putdef(entry->def.calipso);
+               break;
 #endif /* IPv6 */
-               }
-               call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
        }
+       call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
 
        return ret_val;
 }
index b5f30d7..d2d1448 100644 (file)
@@ -353,7 +353,7 @@ static void netlink_rcv_wake(struct sock *sk)
 {
        struct netlink_sock *nlk = nlk_sk(sk);
 
-       if (skb_queue_empty(&sk->sk_receive_queue))
+       if (skb_queue_empty_lockless(&sk->sk_receive_queue))
                clear_bit(NETLINK_S_CONGESTED, &nlk->state);
        if (!test_bit(NETLINK_S_CONGESTED, &nlk->state))
                wake_up_interruptible(&nlk->wait);
index f649185..641ffbd 100644 (file)
@@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_dump **statep,
        if (!state)
                return -ENOMEM;
 
+       memset(&state->policies[state->n_alloc], 0,
+              flex_array_size(state, policies, n_alloc - state->n_alloc));
+
        state->policies[state->n_alloc].policy = policy;
        state->policies[state->n_alloc].maxtype = maxtype;
        state->n_alloc = n_alloc;
@@ -185,7 +188,7 @@ send_attribute:
                goto next;
        case NLA_NESTED:
                type = NL_ATTR_TYPE_NESTED;
-               /* fall through */
+               fallthrough;
        case NLA_NESTED_ARRAY:
                if (pt->type == NLA_NESTED_ARRAY)
                        type = NL_ATTR_TYPE_NESTED_ARRAY;
index 2bef377..69e5890 100644 (file)
@@ -122,7 +122,7 @@ static int nr_state2_machine(struct sock *sk, struct sk_buff *skb,
 
        case NR_DISCREQ:
                nr_write_internal(sk, NR_DISCACK);
-               /* fall through */
+               fallthrough;
        case NR_DISCACK:
                nr_disconnect(sk, 0);
                break;
index 0891ee0..78da5ea 100644 (file)
@@ -263,7 +263,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic,
        case 3:
                re_sort_routes(nr_node, 0, 1);
                re_sort_routes(nr_node, 1, 2);
-               /* fall through */
+               fallthrough;
        case 2:
                re_sort_routes(nr_node, 0, 1);
        case 1:
@@ -356,7 +356,7 @@ static int nr_del_node(ax25_address *callsign, ax25_address *neighbour, struct n
                                switch (i) {
                                case 0:
                                        nr_node->routes[0] = nr_node->routes[1];
-                                       /* fall through */
+                                       fallthrough;
                                case 1:
                                        nr_node->routes[1] = nr_node->routes[2];
                                case 2:
@@ -479,7 +479,7 @@ static int nr_dec_obs(void)
                                switch (i) {
                                case 0:
                                        s->routes[0] = s->routes[1];
-                                       /* Fallthrough */
+                                       fallthrough;
                                case 1:
                                        s->routes[1] = s->routes[2];
                                case 2:
@@ -526,7 +526,7 @@ void nr_rt_device_down(struct net_device *dev)
                                                switch (i) {
                                                case 0:
                                                        t->routes[0] = t->routes[1];
-                                                       /* fall through */
+                                                       fallthrough;
                                                case 1:
                                                        t->routes[1] = t->routes[2];
                                                case 2:
index 98d393e..a3f1204 100644 (file)
@@ -778,7 +778,7 @@ static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct,
                        }
                }
                /* Non-ICMP, fall thru to initialize if needed. */
-               /* fall through */
+               fallthrough;
        case IP_CT_NEW:
                /* Seen it before?  This can happen for loopback, retrans,
                 * or local packets.
@@ -1540,7 +1540,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info,
                switch (type) {
                case OVS_CT_ATTR_FORCE_COMMIT:
                        info->force = true;
-                       /* fall through. */
+                       fallthrough;
                case OVS_CT_ATTR_COMMIT:
                        info->commit = true;
                        break;
index 03942c3..b03d142 100644 (file)
@@ -675,7 +675,7 @@ static int key_extract_l3l4(struct sk_buff *skb, struct sw_flow_key *key)
                        case -EINVAL:
                                memset(&key->ip, 0, sizeof(key->ip));
                                memset(&key->ipv6.addr, 0, sizeof(key->ipv6.addr));
-                               /* fall-through */
+                               fallthrough;
                        case -EPROTO:
                                skb->transport_header = skb->network_header;
                                error = 0;
index 479c257..2b33e97 100644 (file)
@@ -2170,7 +2170,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
        int skb_len = skb->len;
        unsigned int snaplen, res;
        unsigned long status = TP_STATUS_USER;
-       unsigned short macoff, netoff, hdrlen;
+       unsigned short macoff, hdrlen;
+       unsigned int netoff;
        struct sk_buff *copy_skb = NULL;
        struct timespec64 ts;
        __u32 ts_status;
@@ -2239,6 +2240,10 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
                }
                macoff = netoff - maclen;
        }
+       if (netoff > USHRT_MAX) {
+               atomic_inc(&po->tp_drops);
+               goto drop_n_restore;
+       }
        if (po->tp_version <= TPACKET_V2) {
                if (macoff + snaplen > po->rx_ring.frame_size) {
                        if (po->copy_thresh &&
@@ -4061,7 +4066,7 @@ static int packet_notifier(struct notifier_block *this,
                case NETDEV_UNREGISTER:
                        if (po->mclist)
                                packet_dev_mclist_delete(dev, &po->mclist);
-                       /* fallthrough */
+                       fallthrough;
 
                case NETDEV_DOWN:
                        if (dev->ifindex == po->ifindex) {
index e47d09a..a152591 100644 (file)
@@ -368,7 +368,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
                        err = -EINVAL;
                        goto out;
                }
-               /* fall through */
+               fallthrough;
        case PNS_PEP_DISABLE_REQ:
                atomic_set(&pn->tx_credits, 0);
                pep_reply(sk, skb, PN_PIPE_NO_ERROR, NULL, 0, GFP_ATOMIC);
@@ -385,7 +385,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
 
        case PNS_PIPE_ALIGNED_DATA:
                __skb_pull(skb, 1);
-               /* fall through */
+               fallthrough;
        case PNS_PIPE_DATA:
                __skb_pull(skb, 3); /* Pipe data header */
                if (!pn_flow_safe(pn->rx_fc)) {
@@ -417,11 +417,11 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
                err = pipe_rcv_created(sk, skb);
                if (err)
                        break;
-               /* fall through */
+               fallthrough;
        case PNS_PIPE_RESET_IND:
                if (!pn->init_enable)
                        break;
-               /* fall through */
+               fallthrough;
        case PNS_PIPE_ENABLED_IND:
                if (!pn_flow_safe(pn->tx_fc)) {
                        atomic_set(&pn->tx_credits, 1);
@@ -555,7 +555,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
        switch (hdr->message_id) {
        case PNS_PIPE_ALIGNED_DATA:
                __skb_pull(skb, 1);
-               /* fall through */
+               fallthrough;
        case PNS_PIPE_DATA:
                __skb_pull(skb, 3); /* Pipe data header */
                if (!pn_flow_safe(pn->rx_fc)) {
index b4c0db0..90c558f 100644 (file)
@@ -692,23 +692,25 @@ static void qrtr_port_remove(struct qrtr_sock *ipc)
  */
 static int qrtr_port_assign(struct qrtr_sock *ipc, int *port)
 {
+       u32 min_port;
        int rc;
 
        mutex_lock(&qrtr_port_lock);
        if (!*port) {
-               rc = idr_alloc(&qrtr_ports, ipc,
-                              QRTR_MIN_EPH_SOCKET, QRTR_MAX_EPH_SOCKET + 1,
-                              GFP_ATOMIC);
-               if (rc >= 0)
-                       *port = rc;
+               min_port = QRTR_MIN_EPH_SOCKET;
+               rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, QRTR_MAX_EPH_SOCKET, GFP_ATOMIC);
+               if (!rc)
+                       *port = min_port;
        } else if (*port < QRTR_MIN_EPH_SOCKET && !capable(CAP_NET_ADMIN)) {
                rc = -EACCES;
        } else if (*port == QRTR_PORT_CTRL) {
-               rc = idr_alloc(&qrtr_ports, ipc, 0, 1, GFP_ATOMIC);
+               min_port = 0;
+               rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, 0, GFP_ATOMIC);
        } else {
-               rc = idr_alloc(&qrtr_ports, ipc, *port, *port + 1, GFP_ATOMIC);
-               if (rc >= 0)
-                       *port = rc;
+               min_port = *port;
+               rc = idr_alloc_u32(&qrtr_ports, ipc, &min_port, *port, GFP_ATOMIC);
+               if (!rc)
+                       *port = min_port;
        }
        mutex_unlock(&qrtr_port_lock);
 
index 9a529a0..985d0b7 100644 (file)
@@ -934,7 +934,7 @@ static int rds_rm_size(struct msghdr *msg, int num_sgs,
 
                case RDS_CMSG_ZCOPY_COOKIE:
                        zcopy_cookie = true;
-                       /* fall through */
+                       fallthrough;
 
                case RDS_CMSG_RDMA_DEST:
                case RDS_CMSG_RDMA_MAP:
index 0d4fab2..6af786d 100644 (file)
@@ -216,7 +216,7 @@ static int rose_state4_machine(struct sock *sk, struct sk_buff *skb, int framety
        switch (frametype) {
        case ROSE_RESET_REQUEST:
                rose_write_internal(sk, ROSE_RESET_CONFIRMATION);
-               /* fall through */
+               fallthrough;
        case ROSE_RESET_CONFIRMATION:
                rose_stop_timer(sk);
                rose_start_idletimer(sk);
index 5277631..6e35703 100644 (file)
@@ -343,7 +343,7 @@ static int rose_del_node(struct rose_route_struct *rose_route,
                                case 0:
                                        rose_node->neighbour[0] =
                                                rose_node->neighbour[1];
-                                       /* fall through */
+                                       fallthrough;
                                case 1:
                                        rose_node->neighbour[1] =
                                                rose_node->neighbour[2];
@@ -505,7 +505,7 @@ void rose_rt_device_down(struct net_device *dev)
                                switch (i) {
                                case 0:
                                        t->neighbour[0] = t->neighbour[1];
-                                       /* fall through */
+                                       fallthrough;
                                case 1:
                                        t->neighbour[1] = t->neighbour[2];
                                case 2:
index e6725a6..186c8a8 100644 (file)
@@ -246,7 +246,7 @@ static int rxrpc_listen(struct socket *sock, int backlog)
                        ret = 0;
                        break;
                }
-               /* Fall through */
+               fallthrough;
        default:
                ret = -EBUSY;
                break;
@@ -545,7 +545,7 @@ static int rxrpc_sendmsg(struct socket *sock, struct msghdr *m, size_t len)
 
                rx->local = local;
                rx->sk.sk_state = RXRPC_CLIENT_BOUND;
-               /* Fall through */
+               fallthrough;
 
        case RXRPC_CLIENT_BOUND:
                if (!m->msg_name &&
@@ -553,7 +553,7 @@ static int rxrpc_sendmsg(struct socket *sock, struct msghdr *m, size_t len)
                        m->msg_name = &rx->connect_srx;
                        m->msg_namelen = sizeof(rx->connect_srx);
                }
-               /* Fall through */
+               fallthrough;
        case RXRPC_SERVER_BOUND:
        case RXRPC_SERVER_LISTENING:
                ret = rxrpc_do_sendmsg(rx, m, len);
index 6d29a36..884cff7 100644 (file)
@@ -488,7 +488,6 @@ enum rxrpc_call_flag {
        RXRPC_CALL_RX_LAST,             /* Received the last packet (at rxtx_top) */
        RXRPC_CALL_TX_LAST,             /* Last packet in Tx buffer (at rxtx_top) */
        RXRPC_CALL_SEND_PING,           /* A ping will need to be sent */
-       RXRPC_CALL_PINGING,             /* Ping in process */
        RXRPC_CALL_RETRANS_TIMEOUT,     /* Retransmission due to timeout occurred */
        RXRPC_CALL_BEGAN_RX_TIMER,      /* We began the expect_rx_by timer */
        RXRPC_CALL_RX_HEARD,            /* The peer responded at least once to this call */
@@ -673,9 +672,13 @@ struct rxrpc_call {
        rxrpc_seq_t             ackr_consumed;  /* Highest packet shown consumed */
        rxrpc_seq_t             ackr_seen;      /* Highest packet shown seen */
 
-       /* ping management */
-       rxrpc_serial_t          ping_serial;    /* Last ping sent */
-       ktime_t                 ping_time;      /* Time last ping sent */
+       /* RTT management */
+       rxrpc_serial_t          rtt_serial[4];  /* Serial number of DATA or PING sent */
+       ktime_t                 rtt_sent_at[4]; /* Time packet sent */
+       unsigned long           rtt_avail;      /* Mask of available slots in bits 0-3,
+                                                * Mask of pending samples in 8-11 */
+#define RXRPC_CALL_RTT_AVAIL_MASK      0xf
+#define RXRPC_CALL_RTT_PEND_SHIFT      8
 
        /* transmission-phase ACK management */
        ktime_t                 acks_latest_ts; /* Timestamp of latest ACK received */
@@ -1037,7 +1040,7 @@ static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
 /*
  * rtt.c
  */
-void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace,
+void rxrpc_peer_add_rtt(struct rxrpc_call *, enum rxrpc_rtt_rx_trace, int,
                        rxrpc_serial_t, rxrpc_serial_t, ktime_t, ktime_t);
 unsigned long rxrpc_get_rto_backoff(struct rxrpc_peer *, bool);
 void rxrpc_peer_init_rtt(struct rxrpc_peer *);
index 032ed76..ef16056 100644 (file)
@@ -622,7 +622,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx)
        case RXRPC_CALL_SERVER_ACCEPTING:
                __rxrpc_abort_call("REJ", call, 1, RX_USER_ABORT, -ECONNABORTED);
                abort = true;
-               /* fall through */
+               fallthrough;
        case RXRPC_CALL_COMPLETE:
                ret = call->error;
                goto out_discard;
index 38a4616..a40fae0 100644 (file)
@@ -153,6 +153,7 @@ struct rxrpc_call *rxrpc_alloc_call(struct rxrpc_sock *rx, gfp_t gfp,
        call->cong_ssthresh = RXRPC_RXTX_BUFF_SIZE - 1;
 
        call->rxnet = rxnet;
+       call->rtt_avail = RXRPC_CALL_RTT_AVAIL_MASK;
        atomic_inc(&rxnet->nr_calls);
        return call;
 
index f2a1a5d..159e3ed 100644 (file)
@@ -881,7 +881,7 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call)
                        conn->cache_state = RXRPC_CONN_CLIENT_ACTIVE;
                        rxrpc_activate_channels_locked(conn);
                }
-               /* fall through */
+               fallthrough;
        case RXRPC_CONN_CLIENT_ACTIVE:
                if (list_empty(&conn->waiting_calls)) {
                        rxrpc_deactivate_one_channel(conn, channel);
index 7675793..667c44a 100644 (file)
@@ -608,36 +608,57 @@ unlock:
 }
 
 /*
- * Process a requested ACK.
+ * See if there's a cached RTT probe to complete.
  */
-static void rxrpc_input_requested_ack(struct rxrpc_call *call,
-                                     ktime_t resp_time,
-                                     rxrpc_serial_t orig_serial,
-                                     rxrpc_serial_t ack_serial)
+static void rxrpc_complete_rtt_probe(struct rxrpc_call *call,
+                                    ktime_t resp_time,
+                                    rxrpc_serial_t acked_serial,
+                                    rxrpc_serial_t ack_serial,
+                                    enum rxrpc_rtt_rx_trace type)
 {
-       struct rxrpc_skb_priv *sp;
-       struct sk_buff *skb;
+       rxrpc_serial_t orig_serial;
+       unsigned long avail;
        ktime_t sent_at;
-       int ix;
+       bool matched = false;
+       int i;
 
-       for (ix = 0; ix < RXRPC_RXTX_BUFF_SIZE; ix++) {
-               skb = call->rxtx_buffer[ix];
-               if (!skb)
-                       continue;
+       avail = READ_ONCE(call->rtt_avail);
+       smp_rmb(); /* Read avail bits before accessing data. */
 
-               sent_at = skb->tstamp;
-               smp_rmb(); /* Read timestamp before serial. */
-               sp = rxrpc_skb(skb);
-               if (sp->hdr.serial != orig_serial)
+       for (i = 0; i < ARRAY_SIZE(call->rtt_serial); i++) {
+               if (!test_bit(i + RXRPC_CALL_RTT_PEND_SHIFT, &avail))
                        continue;
-               goto found;
-       }
 
-       return;
+               sent_at = call->rtt_sent_at[i];
+               orig_serial = call->rtt_serial[i];
+
+               if (orig_serial == acked_serial) {
+                       clear_bit(i + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
+                       smp_mb(); /* Read data before setting avail bit */
+                       set_bit(i, &call->rtt_avail);
+                       if (type != rxrpc_rtt_rx_cancel)
+                               rxrpc_peer_add_rtt(call, type, i, acked_serial, ack_serial,
+                                                  sent_at, resp_time);
+                       else
+                               trace_rxrpc_rtt_rx(call, rxrpc_rtt_rx_cancel, i,
+                                                  orig_serial, acked_serial, 0, 0);
+                       matched = true;
+               }
+
+               /* If a later serial is being acked, then mark this slot as
+                * being available.
+                */
+               if (after(acked_serial, orig_serial)) {
+                       trace_rxrpc_rtt_rx(call, rxrpc_rtt_rx_obsolete, i,
+                                          orig_serial, acked_serial, 0, 0);
+                       clear_bit(i + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
+                       smp_wmb();
+                       set_bit(i, &call->rtt_avail);
+               }
+       }
 
-found:
-       rxrpc_peer_add_rtt(call, rxrpc_rtt_rx_requested_ack,
-                          orig_serial, ack_serial, sent_at, resp_time);
+       if (!matched)
+               trace_rxrpc_rtt_rx(call, rxrpc_rtt_rx_lost, 9, 0, acked_serial, 0, 0);
 }
 
 /*
@@ -682,27 +703,11 @@ static void rxrpc_input_check_for_lost_ack(struct rxrpc_call *call)
  */
 static void rxrpc_input_ping_response(struct rxrpc_call *call,
                                      ktime_t resp_time,
-                                     rxrpc_serial_t orig_serial,
+                                     rxrpc_serial_t acked_serial,
                                      rxrpc_serial_t ack_serial)
 {
-       rxrpc_serial_t ping_serial;
-       ktime_t ping_time;
-
-       ping_time = call->ping_time;
-       smp_rmb();
-       ping_serial = READ_ONCE(call->ping_serial);
-
-       if (orig_serial == call->acks_lost_ping)
+       if (acked_serial == call->acks_lost_ping)
                rxrpc_input_check_for_lost_ack(call);
-
-       if (before(orig_serial, ping_serial) ||
-           !test_and_clear_bit(RXRPC_CALL_PINGING, &call->flags))
-               return;
-       if (after(orig_serial, ping_serial))
-               return;
-
-       rxrpc_peer_add_rtt(call, rxrpc_rtt_rx_ping_response,
-                          orig_serial, ack_serial, ping_time, resp_time);
 }
 
 /*
@@ -843,7 +848,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
                struct rxrpc_ackinfo info;
                u8 acks[RXRPC_MAXACKS];
        } buf;
-       rxrpc_serial_t acked_serial;
+       rxrpc_serial_t ack_serial, acked_serial;
        rxrpc_seq_t first_soft_ack, hard_ack, prev_pkt;
        int nr_acks, offset, ioffset;
 
@@ -856,6 +861,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
        }
        offset += sizeof(buf.ack);
 
+       ack_serial = sp->hdr.serial;
        acked_serial = ntohl(buf.ack.serial);
        first_soft_ack = ntohl(buf.ack.firstPacket);
        prev_pkt = ntohl(buf.ack.previousPacket);
@@ -864,31 +870,42 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
        summary.ack_reason = (buf.ack.reason < RXRPC_ACK__INVALID ?
                              buf.ack.reason : RXRPC_ACK__INVALID);
 
-       trace_rxrpc_rx_ack(call, sp->hdr.serial, acked_serial,
+       trace_rxrpc_rx_ack(call, ack_serial, acked_serial,
                           first_soft_ack, prev_pkt,
                           summary.ack_reason, nr_acks);
 
-       if (buf.ack.reason == RXRPC_ACK_PING_RESPONSE)
+       switch (buf.ack.reason) {
+       case RXRPC_ACK_PING_RESPONSE:
                rxrpc_input_ping_response(call, skb->tstamp, acked_serial,
-                                         sp->hdr.serial);
-       if (buf.ack.reason == RXRPC_ACK_REQUESTED)
-               rxrpc_input_requested_ack(call, skb->tstamp, acked_serial,
-                                         sp->hdr.serial);
+                                         ack_serial);
+               rxrpc_complete_rtt_probe(call, skb->tstamp, acked_serial, ack_serial,
+                                        rxrpc_rtt_rx_ping_response);
+               break;
+       case RXRPC_ACK_REQUESTED:
+               rxrpc_complete_rtt_probe(call, skb->tstamp, acked_serial, ack_serial,
+                                        rxrpc_rtt_rx_requested_ack);
+               break;
+       default:
+               if (acked_serial != 0)
+                       rxrpc_complete_rtt_probe(call, skb->tstamp, acked_serial, ack_serial,
+                                                rxrpc_rtt_rx_cancel);
+               break;
+       }
 
        if (buf.ack.reason == RXRPC_ACK_PING) {
-               _proto("Rx ACK %%%u PING Request", sp->hdr.serial);
+               _proto("Rx ACK %%%u PING Request", ack_serial);
                rxrpc_propose_ACK(call, RXRPC_ACK_PING_RESPONSE,
-                                 sp->hdr.serial, true, true,
+                                 ack_serial, true, true,
                                  rxrpc_propose_ack_respond_to_ping);
        } else if (sp->hdr.flags & RXRPC_REQUEST_ACK) {
                rxrpc_propose_ACK(call, RXRPC_ACK_REQUESTED,
-                                 sp->hdr.serial, true, true,
+                                 ack_serial, true, true,
                                  rxrpc_propose_ack_respond_to_ack);
        }
 
        /* Discard any out-of-order or duplicate ACKs (outside lock). */
        if (!rxrpc_is_ack_valid(call, first_soft_ack, prev_pkt)) {
-               trace_rxrpc_rx_discard_ack(call->debug_id, sp->hdr.serial,
+               trace_rxrpc_rx_discard_ack(call->debug_id, ack_serial,
                                           first_soft_ack, call->ackr_first_seq,
                                           prev_pkt, call->ackr_prev_seq);
                return;
@@ -904,7 +921,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
 
        /* Discard any out-of-order or duplicate ACKs (inside lock). */
        if (!rxrpc_is_ack_valid(call, first_soft_ack, prev_pkt)) {
-               trace_rxrpc_rx_discard_ack(call->debug_id, sp->hdr.serial,
+               trace_rxrpc_rx_discard_ack(call->debug_id, ack_serial,
                                           first_soft_ack, call->ackr_first_seq,
                                           prev_pkt, call->ackr_prev_seq);
                goto out;
@@ -964,7 +981,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
            RXRPC_TX_ANNO_LAST &&
            summary.nr_acks == call->tx_top - hard_ack &&
            rxrpc_is_client_call(call))
-               rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
+               rxrpc_propose_ACK(call, RXRPC_ACK_PING, ack_serial,
                                  false, true,
                                  rxrpc_propose_ack_ping_for_lost_reply);
 
@@ -1084,7 +1101,7 @@ static void rxrpc_input_implicit_end_call(struct rxrpc_sock *rx,
        switch (READ_ONCE(call->state)) {
        case RXRPC_CALL_SERVER_AWAIT_ACK:
                rxrpc_call_completed(call);
-               /* Fall through */
+               fallthrough;
        case RXRPC_CALL_COMPLETE:
                break;
        default:
@@ -1243,12 +1260,12 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
        case RXRPC_PACKET_TYPE_BUSY:
                if (rxrpc_to_server(sp))
                        goto discard;
-               /* Fall through */
+               fallthrough;
        case RXRPC_PACKET_TYPE_ACK:
        case RXRPC_PACKET_TYPE_ACKALL:
                if (sp->hdr.callNumber == 0)
                        goto bad_message;
-               /* Fall through */
+               fallthrough;
        case RXRPC_PACKET_TYPE_ABORT:
                break;
 
index c8b2097..ede058f 100644 (file)
@@ -162,7 +162,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
                /* Fall through and set IPv4 options too otherwise we don't get
                 * errors from IPv4 packets sent through the IPv6 socket.
                 */
-               /* Fall through */
+               fallthrough;
        case AF_INET:
                /* we want to receive ICMP errors */
                ip_sock_set_recverr(local->socket->sk);
index 1ba43c3..3cfff79 100644 (file)
@@ -123,6 +123,49 @@ static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn,
        return top - hard_ack + 3;
 }
 
+/*
+ * Record the beginning of an RTT probe.
+ */
+static int rxrpc_begin_rtt_probe(struct rxrpc_call *call, rxrpc_serial_t serial,
+                                enum rxrpc_rtt_tx_trace why)
+{
+       unsigned long avail = call->rtt_avail;
+       int rtt_slot = 9;
+
+       if (!(avail & RXRPC_CALL_RTT_AVAIL_MASK))
+               goto no_slot;
+
+       rtt_slot = __ffs(avail & RXRPC_CALL_RTT_AVAIL_MASK);
+       if (!test_and_clear_bit(rtt_slot, &call->rtt_avail))
+               goto no_slot;
+
+       call->rtt_serial[rtt_slot] = serial;
+       call->rtt_sent_at[rtt_slot] = ktime_get_real();
+       smp_wmb(); /* Write data before avail bit */
+       set_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
+
+       trace_rxrpc_rtt_tx(call, why, rtt_slot, serial);
+       return rtt_slot;
+
+no_slot:
+       trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_no_slot, rtt_slot, serial);
+       return -1;
+}
+
+/*
+ * Cancel an RTT probe.
+ */
+static void rxrpc_cancel_rtt_probe(struct rxrpc_call *call,
+                                  rxrpc_serial_t serial, int rtt_slot)
+{
+       if (rtt_slot != -1) {
+               clear_bit(rtt_slot + RXRPC_CALL_RTT_PEND_SHIFT, &call->rtt_avail);
+               smp_wmb(); /* Clear pending bit before setting slot */
+               set_bit(rtt_slot, &call->rtt_avail);
+               trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_cancel, rtt_slot, serial);
+       }
+}
+
 /*
  * Send an ACK call packet.
  */
@@ -136,7 +179,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping,
        rxrpc_serial_t serial;
        rxrpc_seq_t hard_ack, top;
        size_t len, n;
-       int ret;
+       int ret, rtt_slot = -1;
        u8 reason;
 
        if (test_bit(RXRPC_CALL_DISCONNECTED, &call->flags))
@@ -196,18 +239,8 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping,
        if (_serial)
                *_serial = serial;
 
-       if (ping) {
-               call->ping_serial = serial;
-               smp_wmb();
-               /* We need to stick a time in before we send the packet in case
-                * the reply gets back before kernel_sendmsg() completes - but
-                * asking UDP to send the packet can take a relatively long
-                * time.
-                */
-               call->ping_time = ktime_get_real();
-               set_bit(RXRPC_CALL_PINGING, &call->flags);
-               trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_ping, serial);
-       }
+       if (ping)
+               rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_ping);
 
        ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
        conn->params.peer->last_tx_at = ktime_get_seconds();
@@ -221,8 +254,7 @@ int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping,
 
        if (call->state < RXRPC_CALL_COMPLETE) {
                if (ret < 0) {
-                       if (ping)
-                               clear_bit(RXRPC_CALL_PINGING, &call->flags);
+                       rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
                        rxrpc_propose_ACK(call, pkt->ack.reason,
                                          ntohl(pkt->ack.serial),
                                          false, true,
@@ -321,7 +353,7 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
        struct kvec iov[2];
        rxrpc_serial_t serial;
        size_t len;
-       int ret;
+       int ret, rtt_slot = -1;
 
        _enter(",{%d}", skb->len);
 
@@ -397,6 +429,8 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
        sp->hdr.serial = serial;
        smp_wmb(); /* Set serial before timestamp */
        skb->tstamp = ktime_get_real();
+       if (whdr.flags & RXRPC_REQUEST_ACK)
+               rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_data);
 
        /* send the packet by UDP
         * - returns -EMSGSIZE if UDP would have to fragment the packet
@@ -408,12 +442,15 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
        conn->params.peer->last_tx_at = ktime_get_seconds();
 
        up_read(&conn->params.local->defrag_sem);
-       if (ret < 0)
+       if (ret < 0) {
+               rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
                trace_rxrpc_tx_fail(call->debug_id, serial, ret,
                                    rxrpc_tx_point_call_data_nofrag);
-       else
+       } else {
                trace_rxrpc_tx_packet(call->debug_id, &whdr,
                                      rxrpc_tx_point_call_data_nofrag);
+       }
+
        rxrpc_tx_backoff(call, ret);
        if (ret == -EMSGSIZE)
                goto send_fragmentable;
@@ -422,7 +459,6 @@ done:
        if (ret >= 0) {
                if (whdr.flags & RXRPC_REQUEST_ACK) {
                        call->peer->rtt_last_req = skb->tstamp;
-                       trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial);
                        if (call->peer->rtt_count > 1) {
                                unsigned long nowj = jiffies, ack_lost_at;
 
@@ -469,6 +505,8 @@ send_fragmentable:
        sp->hdr.serial = serial;
        smp_wmb(); /* Set serial before timestamp */
        skb->tstamp = ktime_get_real();
+       if (whdr.flags & RXRPC_REQUEST_ACK)
+               rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_data);
 
        switch (conn->params.local->srx.transport.family) {
        case AF_INET6:
@@ -487,12 +525,14 @@ send_fragmentable:
                BUG();
        }
 
-       if (ret < 0)
+       if (ret < 0) {
+               rxrpc_cancel_rtt_probe(call, serial, rtt_slot);
                trace_rxrpc_tx_fail(call->debug_id, serial, ret,
                                    rxrpc_tx_point_call_data_frag);
-       else
+       } else {
                trace_rxrpc_tx_packet(call->debug_id, &whdr,
                                      rxrpc_tx_point_call_data_frag);
+       }
        rxrpc_tx_backoff(call, ret);
 
        up_write(&conn->params.local->defrag_sem);
index a852f46..be03285 100644 (file)
@@ -273,7 +273,7 @@ static void rxrpc_store_error(struct rxrpc_peer *peer,
        case SO_EE_ORIGIN_ICMP6:
                if (err == EACCES)
                        err = EHOSTUNREACH;
-               /* Fall through */
+               fallthrough;
        default:
                _proto("Rx Received error report { orig=%u }", ee->ee_origin);
                break;
index ca29976..68396d0 100644 (file)
@@ -502,11 +502,21 @@ EXPORT_SYMBOL(rxrpc_kernel_get_peer);
  * rxrpc_kernel_get_srtt - Get a call's peer smoothed RTT
  * @sock: The socket on which the call is in progress.
  * @call: The call to query
+ * @_srtt: Where to store the SRTT value.
  *
- * Get the call's peer smoothed RTT.
+ * Get the call's peer smoothed RTT in uS.
  */
-u32 rxrpc_kernel_get_srtt(struct socket *sock, struct rxrpc_call *call)
+bool rxrpc_kernel_get_srtt(struct socket *sock, struct rxrpc_call *call,
+                          u32 *_srtt)
 {
-       return call->peer->srtt_us >> 3;
+       struct rxrpc_peer *peer = call->peer;
+
+       if (peer->rtt_count == 0) {
+               *_srtt = 1000000; /* 1S */
+               return false;
+       }
+
+       *_srtt = call->peer->srtt_us >> 3;
+       return true;
 }
 EXPORT_SYMBOL(rxrpc_kernel_get_srtt);
index efecc5a..c4684dd 100644 (file)
@@ -776,7 +776,7 @@ out:
        case RXRPC_ACK_DELAY:
                if (ret != -EAGAIN)
                        break;
-               /* Fall through */
+               fallthrough;
        default:
                rxrpc_send_ack_packet(call, false, NULL);
        }
index 928d8b3..1221b06 100644 (file)
@@ -146,6 +146,7 @@ static void rxrpc_ack_update_rtt(struct rxrpc_peer *peer, long rtt_us)
  * exclusive access to the peer RTT data.
  */
 void rxrpc_peer_add_rtt(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
+                       int rtt_slot,
                        rxrpc_serial_t send_serial, rxrpc_serial_t resp_serial,
                        ktime_t send_time, ktime_t resp_time)
 {
@@ -162,7 +163,7 @@ void rxrpc_peer_add_rtt(struct rxrpc_call *call, enum rxrpc_rtt_rx_trace why,
                peer->rtt_count++;
        spin_unlock(&peer->rtt_input_lock);
 
-       trace_rxrpc_rtt_rx(call, why, send_serial, resp_serial,
+       trace_rxrpc_rtt_rx(call, why, rtt_slot, send_serial, resp_serial,
                           peer->srtt_us >> 3, peer->rto_j);
 }
 
index 52a24d4..e08130e 100644 (file)
@@ -1137,7 +1137,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
        ret = -ENOMEM;
        ticket = kmalloc(ticket_len, GFP_NOFS);
        if (!ticket)
-               goto temporary_error;
+               goto temporary_error_free_resp;
 
        eproto = tracepoint_string("rxkad_tkt_short");
        abort_code = RXKADPACKETSHORT;
@@ -1230,6 +1230,7 @@ protocol_error:
 
 temporary_error_free_ticket:
        kfree(ticket);
+temporary_error_free_resp:
        kfree(response);
 temporary_error:
        /* Ignore the response packet if we got a temporary error such as
index f3f6da6..0824e10 100644 (file)
@@ -241,7 +241,7 @@ static int rxrpc_queue_packet(struct rxrpc_sock *rx, struct rxrpc_call *call,
                        trace_rxrpc_timer(call, rxrpc_timer_init_for_send_reply, now);
                        if (!last)
                                break;
-                       /* Fall through */
+                       fallthrough;
                case RXRPC_CALL_SERVER_SEND_REPLY:
                        call->state = RXRPC_CALL_SERVER_AWAIT_ACK;
                        rxrpc_notify_end_tx(rx, call, notify_end_tx);
@@ -721,13 +721,13 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
                if (p.call.timeouts.normal > 0 && j == 0)
                        j = 1;
                WRITE_ONCE(call->next_rx_timo, j);
-               /* Fall through */
+               fallthrough;
        case 2:
                j = msecs_to_jiffies(p.call.timeouts.idle);
                if (p.call.timeouts.idle > 0 && j == 0)
                        j = 1;
                WRITE_ONCE(call->next_req_timo, j);
-               /* Fall through */
+               fallthrough;
        case 1:
                if (p.call.timeouts.hard > 0) {
                        j = msecs_to_jiffies(p.call.timeouts.hard);
index e6ad42b..2c36191 100644 (file)
@@ -704,7 +704,7 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
                err = ip_defrag(net, skb, user);
                local_bh_enable();
                if (err && err != -EINPROGRESS)
-                       goto out_free;
+                       return err;
 
                if (!err) {
                        *defrag = true;
index 0618b63..7d37638 100644 (file)
@@ -1670,7 +1670,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t,
                case TC_ACT_QUEUED:
                case TC_ACT_TRAP:
                        *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
-                       /* fall through */
+                       fallthrough;
                case TC_ACT_SHOT:
                        return 0;
                }
index deac82f..e89fab6 100644 (file)
@@ -353,23 +353,11 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
                              FLOW_BLOCK_BINDER_TYPE_RED_EARLY_DROP,
                              tb[TCA_RED_EARLY_DROP_BLOCK], extack);
        if (err)
-               goto err_early_drop_init;
-
-       err = tcf_qevent_init(&q->qe_mark, sch,
-                             FLOW_BLOCK_BINDER_TYPE_RED_MARK,
-                             tb[TCA_RED_MARK_BLOCK], extack);
-       if (err)
-               goto err_mark_init;
-
-       return 0;
+               return err;
 
-err_mark_init:
-       tcf_qevent_destroy(&q->qe_early_drop, sch);
-err_early_drop_init:
-       del_timer_sync(&q->adapt_timer);
-       red_offload(sch, false);
-       qdisc_put(q->qdisc);
-       return err;
+       return tcf_qevent_init(&q->qe_mark, sch,
+                              FLOW_BLOCK_BINDER_TYPE_RED_MARK,
+                              tb[TCA_RED_MARK_BLOCK], extack);
 }
 
 static int red_change(struct Qdisc *sch, struct nlattr *opt,
index e981992..fe53c1e 100644 (file)
@@ -1176,9 +1176,27 @@ static void taprio_offload_config_changed(struct taprio_sched *q)
        spin_unlock(&q->current_entry_lock);
 }
 
-static void taprio_sched_to_offload(struct taprio_sched *q,
+static u32 tc_map_to_queue_mask(struct net_device *dev, u32 tc_mask)
+{
+       u32 i, queue_mask = 0;
+
+       for (i = 0; i < dev->num_tc; i++) {
+               u32 offset, count;
+
+               if (!(tc_mask & BIT(i)))
+                       continue;
+
+               offset = dev->tc_to_txq[i].offset;
+               count = dev->tc_to_txq[i].count;
+
+               queue_mask |= GENMASK(offset + count - 1, offset);
+       }
+
+       return queue_mask;
+}
+
+static void taprio_sched_to_offload(struct net_device *dev,
                                    struct sched_gate_list *sched,
-                                   const struct tc_mqprio_qopt *mqprio,
                                    struct tc_taprio_qopt_offload *offload)
 {
        struct sched_entry *entry;
@@ -1193,7 +1211,8 @@ static void taprio_sched_to_offload(struct taprio_sched *q,
 
                e->command = entry->command;
                e->interval = entry->interval;
-               e->gate_mask = entry->gate_mask;
+               e->gate_mask = tc_map_to_queue_mask(dev, entry->gate_mask);
+
                i++;
        }
 
@@ -1201,7 +1220,6 @@ static void taprio_sched_to_offload(struct taprio_sched *q,
 }
 
 static int taprio_enable_offload(struct net_device *dev,
-                                struct tc_mqprio_qopt *mqprio,
                                 struct taprio_sched *q,
                                 struct sched_gate_list *sched,
                                 struct netlink_ext_ack *extack)
@@ -1223,7 +1241,7 @@ static int taprio_enable_offload(struct net_device *dev,
                return -ENOMEM;
        }
        offload->enable = 1;
-       taprio_sched_to_offload(q, sched, mqprio, offload);
+       taprio_sched_to_offload(dev, sched, offload);
 
        err = ops->ndo_setup_tc(dev, TC_SETUP_QDISC_TAPRIO, offload);
        if (err < 0) {
@@ -1485,7 +1503,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,
        }
 
        if (FULL_OFFLOAD_IS_ENABLED(q->flags))
-               err = taprio_enable_offload(dev, mqprio, q, new_admin, extack);
+               err = taprio_enable_offload(dev, q, new_admin, extack);
        else
                err = taprio_disable_offload(dev, q, extack);
        if (err)
index aea2a98..8a58f42 100644 (file)
@@ -875,7 +875,7 @@ static int sctp_inet6_af_supported(sa_family_t family, struct sctp_sock *sp)
        case AF_INET:
                if (!__ipv6_only_sock(sctp_opt2sk(sp)))
                        return 1;
-               /* fallthru */
+               fallthrough;
        default:
                return 0;
        }
index 577e3bc..3fd06a2 100644 (file)
@@ -912,7 +912,7 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx)
                case SCTP_CID_ABORT:
                        if (sctp_test_T_bit(chunk))
                                ctx->packet->vtag = ctx->asoc->c.my_vtag;
-                       /* fallthru */
+                       fallthrough;
 
                /* The following chunks are "response" chunks, i.e.
                 * they are generated in response to something we
@@ -927,7 +927,7 @@ static void sctp_outq_flush_ctrl(struct sctp_flush_ctx *ctx)
                case SCTP_CID_ECN_CWR:
                case SCTP_CID_ASCONF_ACK:
                        one_packet = 1;
-                       /* Fall through */
+                       fallthrough;
 
                case SCTP_CID_SACK:
                case SCTP_CID_HEARTBEAT:
@@ -1030,7 +1030,7 @@ static void sctp_outq_flush_data(struct sctp_flush_ctx *ctx,
                if (!ctx->packet || !ctx->packet->has_cookie_echo)
                        return;
 
-               /* fall through */
+               fallthrough;
        case SCTP_STATE_ESTABLISHED:
        case SCTP_STATE_SHUTDOWN_PENDING:
        case SCTP_STATE_SHUTDOWN_RECEIVED:
index 4791047..c11c245 100644 (file)
@@ -2077,7 +2077,7 @@ static enum sctp_ierror sctp_process_unk_param(
                break;
        case SCTP_PARAM_ACTION_DISCARD_ERR:
                retval =  SCTP_IERROR_ERROR;
-               /* Fall through */
+               fallthrough;
        case SCTP_PARAM_ACTION_SKIP_ERR:
                /* Make an ERROR chunk, preparing enough room for
                 * returning multiple unknown parameters.
index 9f36fe9..aa821e7 100644 (file)
@@ -1516,7 +1516,7 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
 
                        if (timer_pending(timer))
                                break;
-                       /* fall through */
+                       fallthrough;
 
                case SCTP_CMD_TIMER_START:
                        timer = &asoc->timers[cmd->obj.to];
index e86620f..c669f8b 100644 (file)
@@ -4315,7 +4315,7 @@ enum sctp_disposition sctp_sf_eat_auth(struct net *net,
                        sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
                                        SCTP_CHUNK(err_chunk));
                }
-               /* Fall Through */
+               fallthrough;
        case SCTP_IERROR_AUTH_BAD_KEYID:
        case SCTP_IERROR_BAD_SIG:
                return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands);
index ec1fba1..836615f 100644 (file)
@@ -8060,8 +8060,6 @@ static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
 
        pr_debug("%s: begins, snum:%d\n", __func__, snum);
 
-       local_bh_disable();
-
        if (snum == 0) {
                /* Search for an available port. */
                int low, high, remaining, index;
@@ -8079,20 +8077,21 @@ static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
                                continue;
                        index = sctp_phashfn(net, rover);
                        head = &sctp_port_hashtable[index];
-                       spin_lock(&head->lock);
+                       spin_lock_bh(&head->lock);
                        sctp_for_each_hentry(pp, &head->chain)
                                if ((pp->port == rover) &&
                                    net_eq(net, pp->net))
                                        goto next;
                        break;
                next:
-                       spin_unlock(&head->lock);
+                       spin_unlock_bh(&head->lock);
+                       cond_resched();
                } while (--remaining > 0);
 
                /* Exhausted local port range during search? */
                ret = 1;
                if (remaining <= 0)
-                       goto fail;
+                       return ret;
 
                /* OK, here is the one we will use.  HEAD (the port
                 * hash table list entry) is non-NULL and we hold it's
@@ -8107,7 +8106,7 @@ static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
                 * port iterator, pp being NULL.
                 */
                head = &sctp_port_hashtable[sctp_phashfn(net, snum)];
-               spin_lock(&head->lock);
+               spin_lock_bh(&head->lock);
                sctp_for_each_hentry(pp, &head->chain) {
                        if ((pp->port == snum) && net_eq(pp->net, net))
                                goto pp_found;
@@ -8207,10 +8206,7 @@ success:
        ret = 0;
 
 fail_unlock:
-       spin_unlock(&head->lock);
-
-fail:
-       local_bh_enable();
+       spin_unlock_bh(&head->lock);
        return ret;
 }
 
index bda2536..6dc95dc 100644 (file)
@@ -88,12 +88,13 @@ static int sctp_stream_alloc_out(struct sctp_stream *stream, __u16 outcnt,
        int ret;
 
        if (outcnt <= stream->outcnt)
-               return 0;
+               goto out;
 
        ret = genradix_prealloc(&stream->out, outcnt, gfp);
        if (ret)
                return ret;
 
+out:
        stream->outcnt = outcnt;
        return 0;
 }
@@ -104,12 +105,13 @@ static int sctp_stream_alloc_in(struct sctp_stream *stream, __u16 incnt,
        int ret;
 
        if (incnt <= stream->incnt)
-               return 0;
+               goto out;
 
        ret = genradix_prealloc(&stream->in, incnt, gfp);
        if (ret)
                return ret;
 
+out:
        stream->incnt = incnt;
        return 0;
 }
index 290270c..0e7409e 100644 (file)
@@ -116,7 +116,6 @@ static void smc_close_cancel_work(struct smc_sock *smc)
        cancel_work_sync(&smc->conn.close_work);
        cancel_delayed_work_sync(&smc->conn.tx_work);
        lock_sock(sk);
-       sk->sk_state = SMC_CLOSED;
 }
 
 /* terminate smc socket abnormally - active abort
@@ -134,22 +133,22 @@ void smc_close_active_abort(struct smc_sock *smc)
        }
        switch (sk->sk_state) {
        case SMC_ACTIVE:
-               sk->sk_state = SMC_PEERABORTWAIT;
-               smc_close_cancel_work(smc);
-               sk->sk_state = SMC_CLOSED;
-               sock_put(sk); /* passive closing */
-               break;
        case SMC_APPCLOSEWAIT1:
        case SMC_APPCLOSEWAIT2:
+               sk->sk_state = SMC_PEERABORTWAIT;
                smc_close_cancel_work(smc);
+               if (sk->sk_state != SMC_PEERABORTWAIT)
+                       break;
                sk->sk_state = SMC_CLOSED;
-               sock_put(sk); /* postponed passive closing */
+               sock_put(sk); /* (postponed) passive closing */
                break;
        case SMC_PEERCLOSEWAIT1:
        case SMC_PEERCLOSEWAIT2:
        case SMC_PEERFINCLOSEWAIT:
                sk->sk_state = SMC_PEERABORTWAIT;
                smc_close_cancel_work(smc);
+               if (sk->sk_state != SMC_PEERABORTWAIT)
+                       break;
                sk->sk_state = SMC_CLOSED;
                smc_conn_free(&smc->conn);
                release_clcsock = true;
@@ -159,6 +158,8 @@ void smc_close_active_abort(struct smc_sock *smc)
        case SMC_APPFINCLOSEWAIT:
                sk->sk_state = SMC_PEERABORTWAIT;
                smc_close_cancel_work(smc);
+               if (sk->sk_state != SMC_PEERABORTWAIT)
+                       break;
                sk->sk_state = SMC_CLOSED;
                smc_conn_free(&smc->conn);
                release_clcsock = true;
@@ -372,7 +373,7 @@ static void smc_close_passive_work(struct work_struct *work)
        case SMC_PEERCLOSEWAIT1:
                if (rxflags->peer_done_writing)
                        sk->sk_state = SMC_PEERCLOSEWAIT2;
-               /* fall through */
+               fallthrough;
                /* to check for closing */
        case SMC_PEERCLOSEWAIT2:
                if (!smc_cdc_rxed_any_close(conn))
index b42fa3b..a406627 100644 (file)
@@ -1356,6 +1356,8 @@ create:
        if (ini->is_smcd) {
                conn->rx_off = sizeof(struct smcd_cdc_msg);
                smcd_cdc_rx_init(conn); /* init tasklet for this conn */
+       } else {
+               conn->rx_off = 0;
        }
 #ifndef KERNEL_HAS_ATOMIC64
        spin_lock_init(&conn->acurs_lock);
@@ -1777,6 +1779,7 @@ int smc_buf_create(struct smc_sock *smc, bool is_smcd)
                list_del(&smc->conn.sndbuf_desc->list);
                mutex_unlock(&smc->conn.lgr->sndbufs_lock);
                smc_buf_free(smc->conn.lgr, false, smc->conn.sndbuf_desc);
+               smc->conn.sndbuf_desc = NULL;
        }
        return rc;
 }
index e1f64f4..da9ba6d 100644 (file)
@@ -170,13 +170,15 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
            (req->diag_ext & (1 << (SMC_DIAG_DMBINFO - 1))) &&
            !list_empty(&smc->conn.lgr->list)) {
                struct smc_connection *conn = &smc->conn;
-               struct smcd_diag_dmbinfo dinfo = {
-                       .linkid = *((u32 *)conn->lgr->id),
-                       .peer_gid = conn->lgr->peer_gid,
-                       .my_gid = conn->lgr->smcd->local_gid,
-                       .token = conn->rmb_desc->token,
-                       .peer_token = conn->peer_token
-               };
+               struct smcd_diag_dmbinfo dinfo;
+
+               memset(&dinfo, 0, sizeof(dinfo));
+
+               dinfo.linkid = *((u32 *)conn->lgr->id);
+               dinfo.peer_gid = conn->lgr->peer_gid;
+               dinfo.my_gid = conn->lgr->smcd->local_gid;
+               dinfo.token = conn->rmb_desc->token;
+               dinfo.peer_token = conn->peer_token;
 
                if (nla_put(skb, SMC_DIAG_DMBINFO, sizeof(dinfo), &dinfo) < 0)
                        goto errout;
index df5b0a6..3ea3346 100644 (file)
@@ -841,6 +841,9 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
        struct smc_init_info ini;
        int lnk_idx, rc = 0;
 
+       if (!llc->qp_mtu)
+               goto out_reject;
+
        ini.vlan_id = lgr->vlan_id;
        smc_pnet_find_alt_roce(lgr, &ini, link->smcibdev);
        if (!memcmp(llc->sender_gid, link->peer_gid, SMC_GID_SIZE) &&
@@ -917,10 +920,20 @@ out:
        kfree(qentry);
 }
 
+static bool smc_llc_is_empty_llc_message(union smc_llc_msg *llc)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(llc->raw.data); i++)
+               if (llc->raw.data[i])
+                       return false;
+       return true;
+}
+
 static bool smc_llc_is_local_add_link(union smc_llc_msg *llc)
 {
        if (llc->raw.hdr.common.type == SMC_LLC_ADD_LINK &&
-           !llc->add_link.qp_mtu && !llc->add_link.link_num)
+           smc_llc_is_empty_llc_message(llc))
                return true;
        return false;
 }
index dbbe8ea..0c01446 100644 (file)
@@ -3610,7 +3610,7 @@ int kernel_getsockname(struct socket *sock, struct sockaddr *addr)
 EXPORT_SYMBOL(kernel_getsockname);
 
 /**
- *     kernel_peername - get the address which the socket is connected (kernel space)
+ *     kernel_getpeername - get the address which the socket is connected (kernel space)
  *     @sock: socket
  *     @addr: address holder
  *
@@ -3671,7 +3671,7 @@ int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset,
 EXPORT_SYMBOL(kernel_sendpage_locked);
 
 /**
- *     kernel_shutdown - shut down part of a full-duplex connection (kernel space)
+ *     kernel_sock_shutdown - shut down part of a full-duplex connection (kernel space)
  *     @sock: socket
  *     @how: connection part
  *
index 90b8329..8b300b7 100644 (file)
@@ -137,7 +137,7 @@ gss_krb5_make_confounder(char *p, u32 conflen)
        switch (conflen) {
        case 16:
                *q++ = i++;
-               /* fall through */
+               fallthrough;
        case 8:
                *q++ = i++;
                break;
index d26036a..76685ab 100644 (file)
@@ -9,7 +9,6 @@
 #include <linux/sunrpc/svc_xprt.h>
 #include <linux/sunrpc/auth_gss.h>
 #include <linux/sunrpc/gss_err.h>
-#include <linux/sunrpc/auth_gss.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/rpcgss.h>
index a91d1cd..62e0b6c 100644 (file)
@@ -1702,7 +1702,7 @@ call_reserveresult(struct rpc_task *task)
        switch (status) {
        case -ENOMEM:
                rpc_delay(task, HZ >> 2);
-               /* fall through */
+               fallthrough;
        case -EAGAIN:   /* woken up; retry */
                task->tk_action = call_retry_reserve;
                return;
@@ -1759,13 +1759,13 @@ call_refreshresult(struct rpc_task *task)
                /* Use rate-limiting and a max number of retries if refresh
                 * had status 0 but failed to update the cred.
                 */
-               /* fall through */
+               fallthrough;
        case -ETIMEDOUT:
                rpc_delay(task, 3*HZ);
-               /* fall through */
+               fallthrough;
        case -EAGAIN:
                status = -EACCES;
-               /* fall through */
+               fallthrough;
        case -EKEYEXPIRED:
                if (!task->tk_cred_retry)
                        break;
@@ -2132,7 +2132,7 @@ call_connect_status(struct rpc_task *task)
                        rpc_force_rebind(clnt);
                        goto out_retry;
                }
-               /* fall through */
+               fallthrough;
        case -ECONNRESET:
        case -ECONNABORTED:
        case -ENETDOWN:
@@ -2146,7 +2146,7 @@ call_connect_status(struct rpc_task *task)
                        break;
                /* retry with existing socket, after a delay */
                rpc_delay(task, 3*HZ);
-               /* fall through */
+               fallthrough;
        case -EADDRINUSE:
        case -ENOTCONN:
        case -EAGAIN:
@@ -2228,7 +2228,7 @@ call_transmit_status(struct rpc_task *task)
                 */
        case -ENOBUFS:
                rpc_delay(task, HZ>>2);
-               /* fall through */
+               fallthrough;
        case -EBADSLT:
        case -EAGAIN:
                task->tk_action = call_transmit;
@@ -2247,7 +2247,7 @@ call_transmit_status(struct rpc_task *task)
                        rpc_call_rpcerror(task, task->tk_status);
                        return;
                }
-               /* fall through */
+               fallthrough;
        case -ECONNRESET:
        case -ECONNABORTED:
        case -EADDRINUSE:
@@ -2313,7 +2313,7 @@ call_bc_transmit_status(struct rpc_task *task)
                break;
        case -ENOBUFS:
                rpc_delay(task, HZ>>2);
-               /* fall through */
+               fallthrough;
        case -EBADSLT:
        case -EAGAIN:
                task->tk_status = 0;
@@ -2380,7 +2380,7 @@ call_status(struct rpc_task *task)
                 * were a timeout.
                 */
                rpc_delay(task, 3*HZ);
-               /* fall through */
+               fallthrough;
        case -ETIMEDOUT:
                break;
        case -ECONNREFUSED:
@@ -2391,7 +2391,7 @@ call_status(struct rpc_task *task)
                break;
        case -EADDRINUSE:
                rpc_delay(task, 3*HZ);
-               /* fall through */
+               fallthrough;
        case -EPIPE:
        case -EAGAIN:
                break;
index c27123e..4a67685 100644 (file)
@@ -982,8 +982,8 @@ static int rpcb_dec_getaddr(struct rpc_rqst *req, struct xdr_stream *xdr,
        p = xdr_inline_decode(xdr, len);
        if (unlikely(p == NULL))
                goto out_fail;
-       dprintk("RPC: %5u RPCB_%s reply: %s\n", req->rq_task->tk_pid,
-                       req->rq_task->tk_msg.rpc_proc->p_name, (char *)p);
+       dprintk("RPC: %5u RPCB_%s reply: %*pE\n", req->rq_task->tk_pid,
+                       req->rq_task->tk_msg.rpc_proc->p_name, len, (char *)p);
 
        if (rpc_uaddr2sockaddr(req->rq_xprt->xprt_net, (char *)p, len,
                                sap, sizeof(address)) == 0)
index 6ba9d58..5a8e47b 100644 (file)
@@ -1623,7 +1623,7 @@ void xprt_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task)
        case -EAGAIN:
                xprt_add_backlog(xprt, task);
                dprintk("RPC:       waiting for request slot\n");
-               /* fall through */
+               fallthrough;
        default:
                task->tk_status = -EAGAIN;
        }
index 75c6467..ad6e2e4 100644 (file)
@@ -268,7 +268,7 @@ rpcrdma_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
        case RDMA_CM_EVENT_DEVICE_REMOVAL:
                pr_info("rpcrdma: removing device %s for %pISpc\n",
                        ep->re_id->device->name, sap);
-               /* fall through */
+               fallthrough;
        case RDMA_CM_EVENT_ADDR_CHANGE:
                ep->re_connect_status = -ENODEV;
                goto disconnected;
@@ -933,6 +933,8 @@ static void rpcrdma_req_reset(struct rpcrdma_req *req)
 
        rpcrdma_regbuf_dma_unmap(req->rl_sendbuf);
        rpcrdma_regbuf_dma_unmap(req->rl_recvbuf);
+
+       frwr_reset(req);
 }
 
 /* ASSUMPTION: the rb_allreqs list is stable for the duration,
index c57aef8..554e1bb 100644 (file)
@@ -885,7 +885,7 @@ static int xs_local_send_request(struct rpc_rqst *req)
        default:
                dprintk("RPC:       sendmsg returned unrecognized error %d\n",
                        -status);
-               /* fall through */
+               fallthrough;
        case -EPIPE:
                xs_close(xprt);
                status = -ENOTCONN;
@@ -1436,7 +1436,7 @@ static void xs_tcp_state_change(struct sock *sk)
                xprt->connect_cookie++;
                clear_bit(XPRT_CONNECTED, &xprt->state);
                xs_run_error_worker(transport, XPRT_SOCK_WAKE_DISCONNECT);
-               /* fall through */
+               fallthrough;
        case TCP_CLOSING:
                /*
                 * If the server closed down the connection, make sure that
@@ -2202,7 +2202,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
        switch (ret) {
        case 0:
                xs_set_srcport(transport, sock);
-               /* fall through */
+               fallthrough;
        case -EINPROGRESS:
                /* SYN_SENT! */
                if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO)
@@ -2255,7 +2255,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)
        default:
                printk("%s: connect returned unhandled error %d\n",
                        __func__, status);
-               /* fall through */
+               fallthrough;
        case -EADDRNOTAVAIL:
                /* We're probably in TIME_WAIT. Get rid of existing socket,
                 * and retry
index 9dd7802..be1c400 100644 (file)
@@ -6,6 +6,7 @@
 menuconfig TIPC
        tristate "The TIPC Protocol"
        depends on INET
+       depends on IPV6 || IPV6=n
        help
          The Transparent Inter Process Communication (TIPC) protocol is
          specially designed for intra cluster communication. This protocol
index 808b147..6504141 100644 (file)
@@ -652,7 +652,7 @@ static int tipc_l2_device_event(struct notifier_block *nb, unsigned long evt,
                        test_and_set_bit_lock(0, &b->up);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case NETDEV_GOING_DOWN:
                clear_bit_unlock(0, &b->up);
                tipc_reset_bearer(net, b);
index 001bcb0..7c523dc 100644 (file)
@@ -326,7 +326,8 @@ static void tipc_aead_free(struct rcu_head *rp)
        if (aead->cloned) {
                tipc_aead_put(aead->cloned);
        } else {
-               head = *this_cpu_ptr(aead->tfm_entry);
+               head = *get_cpu_ptr(aead->tfm_entry);
+               put_cpu_ptr(aead->tfm_entry);
                list_for_each_entry_safe(tfm_entry, tmp, &head->list, list) {
                        crypto_free_aead(tfm_entry->tfm);
                        list_del(&tfm_entry->list);
@@ -399,10 +400,15 @@ static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val)
  */
 static struct crypto_aead *tipc_aead_tfm_next(struct tipc_aead *aead)
 {
-       struct tipc_tfm **tfm_entry = this_cpu_ptr(aead->tfm_entry);
+       struct tipc_tfm **tfm_entry;
+       struct crypto_aead *tfm;
 
+       tfm_entry = get_cpu_ptr(aead->tfm_entry);
        *tfm_entry = list_next_entry(*tfm_entry, list);
-       return (*tfm_entry)->tfm;
+       tfm = (*tfm_entry)->tfm;
+       put_cpu_ptr(tfm_entry);
+
+       return tfm;
 }
 
 /**
@@ -757,10 +763,12 @@ static void tipc_aead_encrypt_done(struct crypto_async_request *base, int err)
        switch (err) {
        case 0:
                this_cpu_inc(tx->stats->stat[STAT_ASYNC_OK]);
+               rcu_read_lock();
                if (likely(test_bit(0, &b->up)))
                        b->media->send_msg(net, skb, b, &tx_ctx->dst);
                else
                        kfree_skb(skb);
+               rcu_read_unlock();
                break;
        case -EINPROGRESS:
                return;
index 89257e2..588c2d2 100644 (file)
@@ -536,7 +536,7 @@ void tipc_group_filter_msg(struct tipc_group *grp, struct sk_buff_head *inputq,
                                update = true;
                                deliver = false;
                        }
-                       /* Fall thru */
+                       fallthrough;
                case TIPC_GRP_BCAST_MSG:
                        m->bc_rcv_nxt++;
                        ack = msg_grp_bc_ack_req(hdr);
index 1075781..b736255 100644 (file)
@@ -1239,7 +1239,7 @@ static bool tipc_data_input(struct tipc_link *l, struct sk_buff *skb,
                        skb_queue_tail(mc_inputq, skb);
                        return true;
                }
-               /* fall through */
+               fallthrough;
        case CONN_MANAGER:
                skb_queue_tail(inputq, skb);
                return true;
index 2175163..90e3c70 100644 (file)
@@ -275,8 +275,9 @@ err_out:
 static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
                                 struct tipc_nl_compat_msg *msg)
 {
-       int err;
+       struct nlmsghdr *nlh;
        struct sk_buff *arg;
+       int err;
 
        if (msg->req_type && (!msg->req_size ||
                              !TLV_CHECK_TYPE(msg->req, msg->req_type)))
@@ -305,6 +306,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
                return -ENOMEM;
        }
 
+       nlh = nlmsg_put(arg, 0, 0, tipc_genl_family.id, 0, NLM_F_MULTI);
+       if (!nlh) {
+               kfree_skb(arg);
+               kfree_skb(msg->rep);
+               msg->rep = NULL;
+               return -EMSGSIZE;
+       }
+       nlmsg_end(arg, nlh);
+
        err = __tipc_nl_compat_dumpit(cmd, msg, arg);
        if (err) {
                kfree_skb(msg->rep);
index 07419f3..ebd280e 100644 (file)
@@ -783,7 +783,7 @@ static __poll_t tipc_poll(struct file *file, struct socket *sock,
        case TIPC_ESTABLISHED:
                if (!tsk->cong_link_cnt && !tsk_conn_cong(tsk))
                        revents |= EPOLLOUT;
-               /* fall through */
+               fallthrough;
        case TIPC_LISTEN:
        case TIPC_CONNECTING:
                if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
@@ -2597,7 +2597,7 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
                 * case is EINPROGRESS, rather than EALREADY.
                 */
                res = -EINPROGRESS;
-               /* fall through */
+               fallthrough;
        case TIPC_CONNECTING:
                if (!timeout) {
                        if (previous == TIPC_CONNECTING)
@@ -2771,18 +2771,21 @@ static int tipc_shutdown(struct socket *sock, int how)
 
        trace_tipc_sk_shutdown(sk, NULL, TIPC_DUMP_ALL, " ");
        __tipc_shutdown(sock, TIPC_CONN_SHUTDOWN);
-       sk->sk_shutdown = SEND_SHUTDOWN;
+       if (tipc_sk_type_connectionless(sk))
+               sk->sk_shutdown = SHUTDOWN_MASK;
+       else
+               sk->sk_shutdown = SEND_SHUTDOWN;
 
        if (sk->sk_state == TIPC_DISCONNECTING) {
                /* Discard any unreceived messages */
                __skb_queue_purge(&sk->sk_receive_queue);
 
-               /* Wake up anyone sleeping in poll */
-               sk->sk_state_change(sk);
                res = 0;
        } else {
                res = -ENOTCONN;
        }
+       /* Wake up anyone sleeping in poll. */
+       sk->sk_state_change(sk);
 
        release_sock(sk);
        return res;
index 53f0de0..911d13c 100644 (file)
@@ -660,6 +660,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
        struct udp_tunnel_sock_cfg tuncfg = {NULL};
        struct nlattr *opts[TIPC_NLA_UDP_MAX + 1];
        u8 node_id[NODE_ID_LEN] = {0,};
+       struct net_device *dev;
        int rmcast = 0;
 
        ub = kzalloc(sizeof(*ub), GFP_ATOMIC);
@@ -714,8 +715,6 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
        rcu_assign_pointer(ub->bearer, b);
        tipc_udp_media_addr_set(&b->addr, &local);
        if (local.proto == htons(ETH_P_IP)) {
-               struct net_device *dev;
-
                dev = __ip_dev_find(net, local.ipv4.s_addr, false);
                if (!dev) {
                        err = -ENODEV;
@@ -738,9 +737,8 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,
                b->mtu = b->media->mtu;
 #if IS_ENABLED(CONFIG_IPV6)
        } else if (local.proto == htons(ETH_P_IPV6)) {
-               struct net_device *dev;
-
-               dev = ipv6_dev_find(net, &local.ipv6);
+               dev = ub->ifindex ? __dev_get_by_index(net, ub->ifindex) : NULL;
+               dev = ipv6_dev_find(net, &local.ipv6, dev);
                if (!dev) {
                        err = -ENODEV;
                        goto err;
index 181ea6f..92784e5 100644 (file)
@@ -837,7 +837,7 @@ static int unix_create(struct net *net, struct socket *sock, int protocol,
                 */
        case SOCK_RAW:
                sock->type = SOCK_DGRAM;
-               /* fall through */
+               fallthrough;
        case SOCK_DGRAM:
                sock->ops = &unix_dgram_ops;
                break;
index 90f0f82..6a6f2f2 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/export.h>
+#include <linux/bitfield.h>
 #include <net/cfg80211.h>
 #include "core.h"
 #include "rdev-ops.h"
@@ -912,6 +913,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
        struct ieee80211_sta_vht_cap *vht_cap;
        struct ieee80211_edmg *edmg_cap;
        u32 width, control_freq, cap;
+       bool support_80_80 = false;
 
        if (WARN_ON(!cfg80211_chandef_valid(chandef)))
                return false;
@@ -957,7 +959,7 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
                if (!ht_cap->ht_supported &&
                    chandef->chan->band != NL80211_BAND_6GHZ)
                        return false;
-               /* fall through */
+               fallthrough;
        case NL80211_CHAN_WIDTH_20_NOHT:
                prohibited_flags |= IEEE80211_CHAN_NO_20MHZ;
                width = 20;
@@ -979,11 +981,15 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
                        return false;
                break;
        case NL80211_CHAN_WIDTH_80P80:
-               cap = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
-               if (chandef->chan->band != NL80211_BAND_6GHZ &&
-                   cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)
+               cap = vht_cap->cap;
+               support_80_80 =
+                       (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ) ||
+                       (cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
+                        cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) ||
+                       u32_get_bits(cap, IEEE80211_VHT_CAP_EXT_NSS_BW_MASK) > 1;
+               if (chandef->chan->band != NL80211_BAND_6GHZ && !support_80_80)
                        return false;
-               /* fall through */
+               fallthrough;
        case NL80211_CHAN_WIDTH_80:
                prohibited_flags |= IEEE80211_CHAN_NO_80MHZ;
                width = 80;
@@ -1001,7 +1007,8 @@ bool cfg80211_chandef_usable(struct wiphy *wiphy,
                        return false;
                cap = vht_cap->cap & IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK;
                if (cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ &&
-                   cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ)
+                   cap != IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ &&
+                   !(vht_cap->cap & IEEE80211_VHT_CAP_EXT_NSS_BW_MASK))
                        return false;
                break;
        default:
index a6c61a2..db7333e 100644 (file)
@@ -941,7 +941,7 @@ void cfg80211_cac_event(struct net_device *netdev,
                       sizeof(struct cfg80211_chan_def));
                queue_work(cfg80211_wq, &rdev->propagate_cac_done_wk);
                cfg80211_sched_dfs_chan_update(rdev);
-               /* fall through */
+               fallthrough;
        case NL80211_RADAR_CAC_ABORTED:
                wdev->cac_started = false;
                break;
index c04fc6c..2c9e9a2 100644 (file)
@@ -2107,7 +2107,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 1:
                if (nla_put(msg, NL80211_ATTR_CIPHER_SUITES,
                            sizeof(u32) * rdev->wiphy.n_cipher_suites,
@@ -2154,7 +2154,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 2:
                if (nl80211_put_iftypes(msg, NL80211_ATTR_SUPPORTED_IFTYPES,
                                        rdev->wiphy.interface_modes))
@@ -2162,7 +2162,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 3:
                nl_bands = nla_nest_start_noflag(msg,
                                                 NL80211_ATTR_WIPHY_BANDS);
@@ -2189,7 +2189,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                                state->chan_start++;
                                if (state->split)
                                        break;
-                               /* fall through */
+                               fallthrough;
                        default:
                                /* add frequencies */
                                nl_freqs = nla_nest_start_noflag(msg,
@@ -2244,7 +2244,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                        state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 4:
                nl_cmds = nla_nest_start_noflag(msg,
                                                NL80211_ATTR_SUPPORTED_COMMANDS);
@@ -2273,7 +2273,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 5:
                if (rdev->ops->remain_on_channel &&
                    (rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) &&
@@ -2291,7 +2291,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 6:
 #ifdef CONFIG_PM
                if (nl80211_send_wowlan(msg, rdev, state->split))
@@ -2302,7 +2302,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
 #else
                state->split_start++;
 #endif
-               /* fall through */
+               fallthrough;
        case 7:
                if (nl80211_put_iftypes(msg, NL80211_ATTR_SOFTWARE_IFTYPES,
                                        rdev->wiphy.software_iftypes))
@@ -2315,7 +2315,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
                state->split_start++;
                if (state->split)
                        break;
-               /* fall through */
+               fallthrough;
        case 8:
                if ((rdev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) &&
                    nla_put_u32(msg, NL80211_ATTR_DEVICE_AP_SME,
@@ -5207,7 +5207,7 @@ bool nl80211_put_sta_rate(struct sk_buff *msg, struct rate_info *info, int attr)
                break;
        default:
                WARN_ON(1);
-               /* fall through */
+               fallthrough;
        case RATE_INFO_BW_20:
                rate_flg = 0;
                break;
@@ -6011,7 +6011,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
 
        if (info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY])
                params.he_6ghz_capa =
-                       nla_data(info->attrs[NL80211_ATTR_HE_CAPABILITY]);
+                       nla_data(info->attrs[NL80211_ATTR_HE_6GHZ_CAPABILITY]);
 
        if (info->attrs[NL80211_ATTR_AIRTIME_WEIGHT])
                params.airtime_weight =
index 35b8847..d8a90d3 100644 (file)
@@ -2946,6 +2946,9 @@ int regulatory_hint_user(const char *alpha2,
        if (WARN_ON(!alpha2))
                return -EINVAL;
 
+       if (!is_world_regdom(alpha2) && !is_an_alpha2(alpha2))
+               return -EINVAL;
+
        request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL);
        if (!request)
                return -ENOMEM;
index e67a744..04f2d19 100644 (file)
@@ -1433,7 +1433,7 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
        switch (ftype) {
        case CFG80211_BSS_FTYPE_BEACON:
                ies->from_beacon = true;
-               /* fall through */
+               fallthrough;
        case CFG80211_BSS_FTYPE_UNKNOWN:
                rcu_assign_pointer(tmp.pub.beacon_ies, ies);
                break;
index 985f3c2..079ce32 100644 (file)
@@ -205,7 +205,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev,
                return err;
        case CFG80211_CONN_ASSOC_FAILED_TIMEOUT:
                *treason = NL80211_TIMEOUT_ASSOC;
-               /* fall through */
+               fallthrough;
        case CFG80211_CONN_ASSOC_FAILED:
                cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
                                     NULL, 0,
@@ -215,7 +215,7 @@ static int cfg80211_conn_do_work(struct wireless_dev *wdev,
                cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
                                     NULL, 0,
                                     WLAN_REASON_DEAUTH_LEAVING, false);
-               /* fall through */
+               fallthrough;
        case CFG80211_CONN_ABANDON:
                /* free directly, disconnected event already sent */
                cfg80211_sme_free(wdev);
index dfad1c0..4a9ff9e 100644 (file)
@@ -123,11 +123,13 @@ int ieee80211_freq_khz_to_channel(u32 freq)
                return (freq - 2407) / 5;
        else if (freq >= 4910 && freq <= 4980)
                return (freq - 4000) / 5;
-       else if (freq < 5945)
+       else if (freq < 5925)
                return (freq - 5000) / 5;
+       else if (freq == 5935)
+               return 2;
        else if (freq <= 45000) /* DMG band lower limit */
-               /* see 802.11ax D4.1 27.3.22.2 */
-               return (freq - 5940) / 5;
+               /* see 802.11ax D6.1 27.3.22.2 */
+               return (freq - 5950) / 5;
        else if (freq >= 58320 && freq <= 70200)
                return (freq - 56160) / 2160;
        else
@@ -198,7 +200,7 @@ static void set_mandatory_flags_band(struct ieee80211_supported_band *sband)
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_MANDATORY_G;
                                want--;
-                               /* fall through */
+                               fallthrough;
                        default:
                                sband->bitrates[i].flags |=
                                        IEEE80211_RATE_ERP_G;
@@ -1008,7 +1010,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
                case NL80211_IFTYPE_STATION:
                        if (dev->ieee80211_ptr->use_4addr)
                                break;
-                       /* fall through */
+                       fallthrough;
                case NL80211_IFTYPE_OCB:
                case NL80211_IFTYPE_P2P_CLIENT:
                case NL80211_IFTYPE_ADHOC:
index aa918d7..4d2160c 100644 (file)
@@ -1334,7 +1334,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
                        wstats.qual.qual = sig + 110;
                        break;
                }
-               /* fall through */
+               fallthrough;
        case CFG80211_SIGNAL_TYPE_UNSPEC:
                if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL)) {
                        wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
@@ -1343,7 +1343,7 @@ static struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev)
                        wstats.qual.qual = sinfo.signal;
                        break;
                }
-               /* fall through */
+               fallthrough;
        default:
                wstats.qual.updated |= IW_QUAL_LEVEL_INVALID;
                wstats.qual.updated |= IW_QUAL_QUAL_INVALID;
index 7fb3276..8e1a49b 100644 (file)
@@ -98,7 +98,7 @@ int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
                                        *vc_fac_mask |= X25_MASK_REVERSE;
                                        break;
                                }
-                               /*fall through */
+                               fallthrough;
                        case X25_FAC_THROUGHPUT:
                                facilities->throughput = p[1];
                                *vc_fac_mask |= X25_MASK_THROUGHPUT;
index 4d3bb46..e1c4197 100644 (file)
@@ -349,7 +349,7 @@ static int x25_state4_machine(struct sock *sk, struct sk_buff *skb, int frametyp
 
                case X25_RESET_REQUEST:
                        x25_write_internal(sk, X25_RESET_CONFIRMATION);
-                       /* fall through */
+                       fallthrough;
                case X25_RESET_CONFIRMATION: {
                        x25_stop_timer(sk);
                        x25->condition = 0x00;
index d5280fd..d622c25 100644 (file)
@@ -3410,7 +3410,7 @@ decode_session6(struct sk_buff *skb, struct flowi *fl, bool reverse)
                switch (nexthdr) {
                case NEXTHDR_FRAGMENT:
                        onlyproto = 1;
-                       /* fall through */
+                       fallthrough;
                case NEXTHDR_ROUTING:
                case NEXTHDR_HOP:
                case NEXTHDR_DEST:
index 7d71537..4b22ace 100644 (file)
@@ -483,7 +483,7 @@ int main(int argc, char **argv)
                                        "Option -%c requires an argument.\n\n",
                                        optopt);
                case 'h':
-                       // fallthrough
+                       fallthrough;
                default:
                        Usage();
                        return 0;
diff --git a/samples/nitro_enclaves/.gitignore b/samples/nitro_enclaves/.gitignore
new file mode 100644 (file)
index 0000000..8279341
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+ne_ioctl_sample
diff --git a/samples/nitro_enclaves/Makefile b/samples/nitro_enclaves/Makefile
new file mode 100644 (file)
index 0000000..a3ec78f
--- /dev/null
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+
+# Enclave lifetime management support for Nitro Enclaves (NE) - ioctl sample
+# usage.
+
+.PHONY: all clean
+
+CFLAGS += -Wall
+
+all:
+       $(CC) $(CFLAGS) -o ne_ioctl_sample ne_ioctl_sample.c -lpthread
+
+clean:
+       rm -f ne_ioctl_sample
diff --git a/samples/nitro_enclaves/ne_ioctl_sample.c b/samples/nitro_enclaves/ne_ioctl_sample.c
new file mode 100644 (file)
index 0000000..480b763
--- /dev/null
@@ -0,0 +1,883 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ */
+
+/**
+ * DOC: Sample flow of using the ioctl interface provided by the Nitro Enclaves (NE)
+ * kernel driver.
+ *
+ * Usage
+ * -----
+ *
+ * Load the nitro_enclaves module, setting also the enclave CPU pool. The
+ * enclave CPUs need to be full cores from the same NUMA node. CPU 0 and its
+ * siblings have to remain available for the primary / parent VM, so they
+ * cannot be included in the enclave CPU pool.
+ *
+ * See the cpu list section from the kernel documentation.
+ * https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html#cpu-lists
+ *
+ *     insmod drivers/virt/nitro_enclaves/nitro_enclaves.ko
+ *     lsmod
+ *
+ *     The CPU pool can be set at runtime, after the kernel module is loaded.
+ *
+ *     echo <cpu-list> > /sys/module/nitro_enclaves/parameters/ne_cpus
+ *
+ *     NUMA and CPU siblings information can be found using:
+ *
+ *     lscpu
+ *     /proc/cpuinfo
+ *
+ * Check the online / offline CPU list. The CPUs from the pool should be
+ * offlined.
+ *
+ *     lscpu
+ *
+ * Check dmesg for any warnings / errors through the NE driver lifetime / usage.
+ * The NE logs contain the "nitro_enclaves" or "pci 0000:00:02.0" pattern.
+ *
+ *     dmesg
+ *
+ * Setup hugetlbfs huge pages. The memory needs to be from the same NUMA node as
+ * the enclave CPUs.
+ *
+ * https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
+ *
+ * By default, the allocation of hugetlb pages are distributed on all possible
+ * NUMA nodes. Use the following configuration files to set the number of huge
+ * pages from a NUMA node:
+ *
+ *     /sys/devices/system/node/node<X>/hugepages/hugepages-2048kB/nr_hugepages
+ *     /sys/devices/system/node/node<X>/hugepages/hugepages-1048576kB/nr_hugepages
+ *
+ *     or, if not on a system with multiple NUMA nodes, can also set the number
+ *     of 2 MiB / 1 GiB huge pages using
+ *
+ *     /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
+ *     /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
+ *
+ *     In this example 256 hugepages of 2 MiB are used.
+ *
+ * Build and run the NE sample.
+ *
+ *     make -C samples/nitro_enclaves clean
+ *     make -C samples/nitro_enclaves
+ *     ./samples/nitro_enclaves/ne_ioctl_sample <path_to_enclave_image>
+ *
+ * Unload the nitro_enclaves module.
+ *
+ *     rmmod nitro_enclaves
+ *     lsmod
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <poll.h>
+#include <pthread.h>
+#include <string.h>
+#include <sys/eventfd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <linux/mman.h>
+#include <linux/nitro_enclaves.h>
+#include <linux/vm_sockets.h>
+
+/**
+ * NE_DEV_NAME - Nitro Enclaves (NE) misc device that provides the ioctl interface.
+ */
+#define NE_DEV_NAME                    "/dev/nitro_enclaves"
+
+/**
+ * NE_POLL_WAIT_TIME - Timeout in seconds for each poll event.
+ */
+#define NE_POLL_WAIT_TIME              (60)
+/**
+ * NE_POLL_WAIT_TIME_MS - Timeout in milliseconds for each poll event.
+ */
+#define NE_POLL_WAIT_TIME_MS           (NE_POLL_WAIT_TIME * 1000)
+
+/**
+ * NE_SLEEP_TIME - Amount of time in seconds for the process to keep the enclave alive.
+ */
+#define NE_SLEEP_TIME                  (300)
+
+/**
+ * NE_DEFAULT_NR_VCPUS - Default number of vCPUs set for an enclave.
+ */
+#define NE_DEFAULT_NR_VCPUS            (2)
+
+/**
+ * NE_MIN_MEM_REGION_SIZE - Minimum size of a memory region - 2 MiB.
+ */
+#define NE_MIN_MEM_REGION_SIZE         (2 * 1024 * 1024)
+
+/**
+ * NE_DEFAULT_NR_MEM_REGIONS - Default number of memory regions of 2 MiB set for
+ *                            an enclave.
+ */
+#define NE_DEFAULT_NR_MEM_REGIONS      (256)
+
+/**
+ * NE_IMAGE_LOAD_HEARTBEAT_CID - Vsock CID for enclave image loading heartbeat logic.
+ */
+#define NE_IMAGE_LOAD_HEARTBEAT_CID    (3)
+/**
+ * NE_IMAGE_LOAD_HEARTBEAT_PORT - Vsock port for enclave image loading heartbeat logic.
+ */
+#define NE_IMAGE_LOAD_HEARTBEAT_PORT   (9000)
+/**
+ * NE_IMAGE_LOAD_HEARTBEAT_VALUE - Heartbeat value for enclave image loading.
+ */
+#define NE_IMAGE_LOAD_HEARTBEAT_VALUE  (0xb7)
+
+/**
+ * struct ne_user_mem_region - User space memory region set for an enclave.
+ * @userspace_addr:    Address of the user space memory region.
+ * @memory_size:       Size of the user space memory region.
+ */
+struct ne_user_mem_region {
+       void    *userspace_addr;
+       size_t  memory_size;
+};
+
+/**
+ * ne_create_vm() - Create a slot for the enclave VM.
+ * @ne_dev_fd:         The file descriptor of the NE misc device.
+ * @slot_uid:          The generated slot uid for the enclave.
+ * @enclave_fd :       The generated file descriptor for the enclave.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_create_vm(int ne_dev_fd, unsigned long *slot_uid, int *enclave_fd)
+{
+       int rc = -EINVAL;
+       *enclave_fd = ioctl(ne_dev_fd, NE_CREATE_VM, slot_uid);
+
+       if (*enclave_fd < 0) {
+               rc = *enclave_fd;
+               switch (errno) {
+               case NE_ERR_NO_CPUS_AVAIL_IN_POOL: {
+                       printf("Error in create VM, no CPUs available in the NE CPU pool\n");
+
+                       break;
+               }
+
+               default:
+                       printf("Error in create VM [%m]\n");
+               }
+
+               return rc;
+       }
+
+       return 0;
+}
+
+
+/**
+ * ne_poll_enclave_fd() - Thread function for polling the enclave fd.
+ * @data:      Argument provided for the polling function.
+ *
+ * Context: Process context.
+ * Return:
+ * * NULL on success / failure.
+ */
+void *ne_poll_enclave_fd(void *data)
+{
+       int enclave_fd = *(int *)data;
+       struct pollfd fds[1] = {};
+       int i = 0;
+       int rc = -EINVAL;
+
+       printf("Running from poll thread, enclave fd %d\n", enclave_fd);
+
+       fds[0].fd = enclave_fd;
+       fds[0].events = POLLIN | POLLERR | POLLHUP;
+
+       /* Keep on polling until the current process is terminated. */
+       while (1) {
+               printf("[iter %d] Polling ...\n", i);
+
+               rc = poll(fds, 1, NE_POLL_WAIT_TIME_MS);
+               if (rc < 0) {
+                       printf("Error in poll [%m]\n");
+
+                       return NULL;
+               }
+
+               i++;
+
+               if (!rc) {
+                       printf("Poll: %d seconds elapsed\n",
+                              i * NE_POLL_WAIT_TIME);
+
+                       continue;
+               }
+
+               printf("Poll received value 0x%x\n", fds[0].revents);
+
+               if (fds[0].revents & POLLHUP) {
+                       printf("Received POLLHUP\n");
+
+                       return NULL;
+               }
+
+               if (fds[0].revents & POLLNVAL) {
+                       printf("Received POLLNVAL\n");
+
+                       return NULL;
+               }
+       }
+
+       return NULL;
+}
+
+/**
+ * ne_alloc_user_mem_region() - Allocate a user space memory region for an enclave.
+ * @ne_user_mem_region:        User space memory region allocated using hugetlbfs.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_alloc_user_mem_region(struct ne_user_mem_region *ne_user_mem_region)
+{
+       /**
+        * Check available hugetlb encodings for different huge page sizes in
+        * include/uapi/linux/mman.h.
+        */
+       ne_user_mem_region->userspace_addr = mmap(NULL, ne_user_mem_region->memory_size,
+                                                 PROT_READ | PROT_WRITE,
+                                                 MAP_PRIVATE | MAP_ANONYMOUS |
+                                                 MAP_HUGETLB | MAP_HUGE_2MB, -1, 0);
+       if (ne_user_mem_region->userspace_addr == MAP_FAILED) {
+               printf("Error in mmap memory [%m]\n");
+
+               return -1;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_load_enclave_image() - Place the enclave image in the enclave memory.
+ * @enclave_fd :               The file descriptor associated with the enclave.
+ * @ne_user_mem_regions:       User space memory regions allocated for the enclave.
+ * @enclave_image_path :       The file path of the enclave image.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_load_enclave_image(int enclave_fd, struct ne_user_mem_region ne_user_mem_regions[],
+                                char *enclave_image_path)
+{
+       unsigned char *enclave_image = NULL;
+       int enclave_image_fd = -1;
+       size_t enclave_image_size = 0;
+       size_t enclave_memory_size = 0;
+       unsigned long i = 0;
+       size_t image_written_bytes = 0;
+       struct ne_image_load_info image_load_info = {
+               .flags = NE_EIF_IMAGE,
+       };
+       struct stat image_stat_buf = {};
+       int rc = -EINVAL;
+       size_t temp_image_offset = 0;
+
+       for (i = 0; i < NE_DEFAULT_NR_MEM_REGIONS; i++)
+               enclave_memory_size += ne_user_mem_regions[i].memory_size;
+
+       rc = stat(enclave_image_path, &image_stat_buf);
+       if (rc < 0) {
+               printf("Error in get image stat info [%m]\n");
+
+               return rc;
+       }
+
+       enclave_image_size = image_stat_buf.st_size;
+
+       if (enclave_memory_size < enclave_image_size) {
+               printf("The enclave memory is smaller than the enclave image size\n");
+
+               return -ENOMEM;
+       }
+
+       rc = ioctl(enclave_fd, NE_GET_IMAGE_LOAD_INFO, &image_load_info);
+       if (rc < 0) {
+               switch (errno) {
+               case NE_ERR_NOT_IN_INIT_STATE: {
+                       printf("Error in get image load info, enclave not in init state\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_FLAG_VALUE: {
+                       printf("Error in get image load info, provided invalid flag\n");
+
+                       break;
+               }
+
+               default:
+                       printf("Error in get image load info [%m]\n");
+               }
+
+               return rc;
+       }
+
+       printf("Enclave image offset in enclave memory is %lld\n",
+              image_load_info.memory_offset);
+
+       enclave_image_fd = open(enclave_image_path, O_RDONLY);
+       if (enclave_image_fd < 0) {
+               printf("Error in open enclave image file [%m]\n");
+
+               return enclave_image_fd;
+       }
+
+       enclave_image = mmap(NULL, enclave_image_size, PROT_READ,
+                            MAP_PRIVATE, enclave_image_fd, 0);
+       if (enclave_image == MAP_FAILED) {
+               printf("Error in mmap enclave image [%m]\n");
+
+               return -1;
+       }
+
+       temp_image_offset = image_load_info.memory_offset;
+
+       for (i = 0; i < NE_DEFAULT_NR_MEM_REGIONS; i++) {
+               size_t bytes_to_write = 0;
+               size_t memory_offset = 0;
+               size_t memory_size = ne_user_mem_regions[i].memory_size;
+               size_t remaining_bytes = 0;
+               void *userspace_addr = ne_user_mem_regions[i].userspace_addr;
+
+               if (temp_image_offset >= memory_size) {
+                       temp_image_offset -= memory_size;
+
+                       continue;
+               } else if (temp_image_offset != 0) {
+                       memory_offset = temp_image_offset;
+                       memory_size -= temp_image_offset;
+                       temp_image_offset = 0;
+               }
+
+               remaining_bytes = enclave_image_size - image_written_bytes;
+               bytes_to_write = memory_size < remaining_bytes ?
+                                memory_size : remaining_bytes;
+
+               memcpy(userspace_addr + memory_offset,
+                      enclave_image + image_written_bytes, bytes_to_write);
+
+               image_written_bytes += bytes_to_write;
+
+               if (image_written_bytes == enclave_image_size)
+                       break;
+       }
+
+       munmap(enclave_image, enclave_image_size);
+
+       close(enclave_image_fd);
+
+       return 0;
+}
+
+/**
+ * ne_set_user_mem_region() - Set a user space memory region for the given enclave.
+ * @enclave_fd :               The file descriptor associated with the enclave.
+ * @ne_user_mem_region :       User space memory region to be set for the enclave.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_set_user_mem_region(int enclave_fd, struct ne_user_mem_region ne_user_mem_region)
+{
+       struct ne_user_memory_region mem_region = {
+               .flags = NE_DEFAULT_MEMORY_REGION,
+               .memory_size = ne_user_mem_region.memory_size,
+               .userspace_addr = (__u64)ne_user_mem_region.userspace_addr,
+       };
+       int rc = -EINVAL;
+
+       rc = ioctl(enclave_fd, NE_SET_USER_MEMORY_REGION, &mem_region);
+       if (rc < 0) {
+               switch (errno) {
+               case NE_ERR_NOT_IN_INIT_STATE: {
+                       printf("Error in set user memory region, enclave not in init state\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_MEM_REGION_SIZE: {
+                       printf("Error in set user memory region, mem size not multiple of 2 MiB\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_MEM_REGION_ADDR: {
+                       printf("Error in set user memory region, invalid user space address\n");
+
+                       break;
+               }
+
+               case NE_ERR_UNALIGNED_MEM_REGION_ADDR: {
+                       printf("Error in set user memory region, unaligned user space address\n");
+
+                       break;
+               }
+
+               case NE_ERR_MEM_REGION_ALREADY_USED: {
+                       printf("Error in set user memory region, memory region already used\n");
+
+                       break;
+               }
+
+               case NE_ERR_MEM_NOT_HUGE_PAGE: {
+                       printf("Error in set user memory region, not backed by huge pages\n");
+
+                       break;
+               }
+
+               case NE_ERR_MEM_DIFFERENT_NUMA_NODE: {
+                       printf("Error in set user memory region, different NUMA node than CPUs\n");
+
+                       break;
+               }
+
+               case NE_ERR_MEM_MAX_REGIONS: {
+                       printf("Error in set user memory region, max memory regions reached\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_PAGE_SIZE: {
+                       printf("Error in set user memory region, has page not multiple of 2 MiB\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_FLAG_VALUE: {
+                       printf("Error in set user memory region, provided invalid flag\n");
+
+                       break;
+               }
+
+               default:
+                       printf("Error in set user memory region [%m]\n");
+               }
+
+               return rc;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_free_mem_regions() - Unmap all the user space memory regions that were set
+ *                        aside for the enclave.
+ * @ne_user_mem_regions:       The user space memory regions associated with an enclave.
+ *
+ * Context: Process context.
+ */
+static void ne_free_mem_regions(struct ne_user_mem_region ne_user_mem_regions[])
+{
+       unsigned int i = 0;
+
+       for (i = 0; i < NE_DEFAULT_NR_MEM_REGIONS; i++)
+               munmap(ne_user_mem_regions[i].userspace_addr,
+                      ne_user_mem_regions[i].memory_size);
+}
+
+/**
+ * ne_add_vcpu() - Add a vCPU to the given enclave.
+ * @enclave_fd :       The file descriptor associated with the enclave.
+ * @vcpu_id:           vCPU id to be set for the enclave, either provided or
+ *                     auto-generated (if provided vCPU id is 0).
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_add_vcpu(int enclave_fd, unsigned int *vcpu_id)
+{
+       int rc = -EINVAL;
+
+       rc = ioctl(enclave_fd, NE_ADD_VCPU, vcpu_id);
+       if (rc < 0) {
+               switch (errno) {
+               case NE_ERR_NO_CPUS_AVAIL_IN_POOL: {
+                       printf("Error in add vcpu, no CPUs available in the NE CPU pool\n");
+
+                       break;
+               }
+
+               case NE_ERR_VCPU_ALREADY_USED: {
+                       printf("Error in add vcpu, the provided vCPU is already used\n");
+
+                       break;
+               }
+
+               case NE_ERR_VCPU_NOT_IN_CPU_POOL: {
+                       printf("Error in add vcpu, the provided vCPU is not in the NE CPU pool\n");
+
+                       break;
+               }
+
+               case NE_ERR_VCPU_INVALID_CPU_CORE: {
+                       printf("Error in add vcpu, the core id of the provided vCPU is invalid\n");
+
+                       break;
+               }
+
+               case NE_ERR_NOT_IN_INIT_STATE: {
+                       printf("Error in add vcpu, enclave not in init state\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_VCPU: {
+                       printf("Error in add vcpu, the provided vCPU is out of avail CPUs range\n");
+
+                       break;
+               }
+
+               default:
+                       printf("Error in add vcpu [%m]\n");
+
+               }
+               return rc;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_start_enclave() - Start the given enclave.
+ * @enclave_fd :               The file descriptor associated with the enclave.
+ * @enclave_start_info :       Enclave metadata used for starting e.g. vsock CID.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_start_enclave(int enclave_fd,  struct ne_enclave_start_info *enclave_start_info)
+{
+       int rc = -EINVAL;
+
+       rc = ioctl(enclave_fd, NE_START_ENCLAVE, enclave_start_info);
+       if (rc < 0) {
+               switch (errno) {
+               case NE_ERR_NOT_IN_INIT_STATE: {
+                       printf("Error in start enclave, enclave not in init state\n");
+
+                       break;
+               }
+
+               case NE_ERR_NO_MEM_REGIONS_ADDED: {
+                       printf("Error in start enclave, no memory regions have been added\n");
+
+                       break;
+               }
+
+               case NE_ERR_NO_VCPUS_ADDED: {
+                       printf("Error in start enclave, no vCPUs have been added\n");
+
+                       break;
+               }
+
+               case NE_ERR_FULL_CORES_NOT_USED: {
+                       printf("Error in start enclave, enclave has no full cores set\n");
+
+                       break;
+               }
+
+               case NE_ERR_ENCLAVE_MEM_MIN_SIZE: {
+                       printf("Error in start enclave, enclave memory is less than min size\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_FLAG_VALUE: {
+                       printf("Error in start enclave, provided invalid flag\n");
+
+                       break;
+               }
+
+               case NE_ERR_INVALID_ENCLAVE_CID: {
+                       printf("Error in start enclave, provided invalid enclave CID\n");
+
+                       break;
+               }
+
+               default:
+                       printf("Error in start enclave [%m]\n");
+               }
+
+               return rc;
+       }
+
+       return 0;
+}
+
+/**
+ * ne_start_enclave_check_booted() - Start the enclave and wait for a hearbeat
+ *                                  from it, on a newly created vsock channel,
+ *                                  to check it has booted.
+ * @enclave_fd :       The file descriptor associated with the enclave.
+ *
+ * Context: Process context.
+ * Return:
+ * * 0 on success.
+ * * Negative return value on failure.
+ */
+static int ne_start_enclave_check_booted(int enclave_fd)
+{
+       struct sockaddr_vm client_vsock_addr = {};
+       int client_vsock_fd = -1;
+       socklen_t client_vsock_len = sizeof(client_vsock_addr);
+       struct ne_enclave_start_info enclave_start_info = {};
+       struct pollfd fds[1] = {};
+       int rc = -EINVAL;
+       unsigned char recv_buf = 0;
+       struct sockaddr_vm server_vsock_addr = {
+               .svm_family = AF_VSOCK,
+               .svm_cid = NE_IMAGE_LOAD_HEARTBEAT_CID,
+               .svm_port = NE_IMAGE_LOAD_HEARTBEAT_PORT,
+       };
+       int server_vsock_fd = -1;
+
+       server_vsock_fd = socket(AF_VSOCK, SOCK_STREAM, 0);
+       if (server_vsock_fd < 0) {
+               rc = server_vsock_fd;
+
+               printf("Error in socket [%m]\n");
+
+               return rc;
+       }
+
+       rc = bind(server_vsock_fd, (struct sockaddr *)&server_vsock_addr,
+                 sizeof(server_vsock_addr));
+       if (rc < 0) {
+               printf("Error in bind [%m]\n");
+
+               goto out;
+       }
+
+       rc = listen(server_vsock_fd, 1);
+       if (rc < 0) {
+               printf("Error in listen [%m]\n");
+
+               goto out;
+       }
+
+       rc = ne_start_enclave(enclave_fd, &enclave_start_info);
+       if (rc < 0)
+               goto out;
+
+       printf("Enclave started, CID %llu\n", enclave_start_info.enclave_cid);
+
+       fds[0].fd = server_vsock_fd;
+       fds[0].events = POLLIN;
+
+       rc = poll(fds, 1, NE_POLL_WAIT_TIME_MS);
+       if (rc < 0) {
+               printf("Error in poll [%m]\n");
+
+               goto out;
+       }
+
+       if (!rc) {
+               printf("Poll timeout, %d seconds elapsed\n", NE_POLL_WAIT_TIME);
+
+               rc = -ETIMEDOUT;
+
+               goto out;
+       }
+
+       if ((fds[0].revents & POLLIN) == 0) {
+               printf("Poll received value %d\n", fds[0].revents);
+
+               rc = -EINVAL;
+
+               goto out;
+       }
+
+       rc = accept(server_vsock_fd, (struct sockaddr *)&client_vsock_addr,
+                   &client_vsock_len);
+       if (rc < 0) {
+               printf("Error in accept [%m]\n");
+
+               goto out;
+       }
+
+       client_vsock_fd = rc;
+
+       /*
+        * Read the heartbeat value that the init process in the enclave sends
+        * after vsock connect.
+        */
+       rc = read(client_vsock_fd, &recv_buf, sizeof(recv_buf));
+       if (rc < 0) {
+               printf("Error in read [%m]\n");
+
+               goto out;
+       }
+
+       if (rc != sizeof(recv_buf) || recv_buf != NE_IMAGE_LOAD_HEARTBEAT_VALUE) {
+               printf("Read %d instead of %d\n", recv_buf,
+                      NE_IMAGE_LOAD_HEARTBEAT_VALUE);
+
+               goto out;
+       }
+
+       /* Write the heartbeat value back. */
+       rc = write(client_vsock_fd, &recv_buf, sizeof(recv_buf));
+       if (rc < 0) {
+               printf("Error in write [%m]\n");
+
+               goto out;
+       }
+
+       rc = 0;
+
+out:
+       close(server_vsock_fd);
+
+       return rc;
+}
+
+int main(int argc, char *argv[])
+{
+       int enclave_fd = -1;
+       unsigned int i = 0;
+       int ne_dev_fd = -1;
+       struct ne_user_mem_region ne_user_mem_regions[NE_DEFAULT_NR_MEM_REGIONS] = {};
+       unsigned int ne_vcpus[NE_DEFAULT_NR_VCPUS] = {};
+       int rc = -EINVAL;
+       pthread_t thread_id = 0;
+       unsigned long slot_uid = 0;
+
+       if (argc != 2) {
+               printf("Usage: %s <path_to_enclave_image>\n", argv[0]);
+
+               exit(EXIT_FAILURE);
+       }
+
+       if (strlen(argv[1]) >= PATH_MAX) {
+               printf("The size of the path to enclave image is higher than max path\n");
+
+               exit(EXIT_FAILURE);
+       }
+
+       ne_dev_fd = open(NE_DEV_NAME, O_RDWR | O_CLOEXEC);
+       if (ne_dev_fd < 0) {
+               printf("Error in open NE device [%m]\n");
+
+               exit(EXIT_FAILURE);
+       }
+
+       printf("Creating enclave slot ...\n");
+
+       rc = ne_create_vm(ne_dev_fd, &slot_uid, &enclave_fd);
+
+       close(ne_dev_fd);
+
+       if (rc < 0)
+               exit(EXIT_FAILURE);
+
+       printf("Enclave fd %d\n", enclave_fd);
+
+       rc = pthread_create(&thread_id, NULL, ne_poll_enclave_fd, (void *)&enclave_fd);
+       if (rc < 0) {
+               printf("Error in thread create [%m]\n");
+
+               close(enclave_fd);
+
+               exit(EXIT_FAILURE);
+       }
+
+       for (i = 0; i < NE_DEFAULT_NR_MEM_REGIONS; i++) {
+               ne_user_mem_regions[i].memory_size = NE_MIN_MEM_REGION_SIZE;
+
+               rc = ne_alloc_user_mem_region(&ne_user_mem_regions[i]);
+               if (rc < 0) {
+                       printf("Error in alloc userspace memory region, iter %d\n", i);
+
+                       goto release_enclave_fd;
+               }
+       }
+
+       rc = ne_load_enclave_image(enclave_fd, ne_user_mem_regions, argv[1]);
+       if (rc < 0)
+               goto release_enclave_fd;
+
+       for (i = 0; i < NE_DEFAULT_NR_MEM_REGIONS; i++) {
+               rc = ne_set_user_mem_region(enclave_fd, ne_user_mem_regions[i]);
+               if (rc < 0) {
+                       printf("Error in set memory region, iter %d\n", i);
+
+                       goto release_enclave_fd;
+               }
+       }
+
+       printf("Enclave memory regions were added\n");
+
+       for (i = 0; i < NE_DEFAULT_NR_VCPUS; i++) {
+               /*
+                * The vCPU is chosen from the enclave vCPU pool, if the value
+                * of the vcpu_id is 0.
+                */
+               ne_vcpus[i] = 0;
+               rc = ne_add_vcpu(enclave_fd, &ne_vcpus[i]);
+               if (rc < 0) {
+                       printf("Error in add vcpu, iter %d\n", i);
+
+                       goto release_enclave_fd;
+               }
+
+               printf("Added vCPU %d to the enclave\n", ne_vcpus[i]);
+       }
+
+       printf("Enclave vCPUs were added\n");
+
+       rc = ne_start_enclave_check_booted(enclave_fd);
+       if (rc < 0) {
+               printf("Error in the enclave start / image loading heartbeat logic [rc=%d]\n", rc);
+
+               goto release_enclave_fd;
+       }
+
+       printf("Entering sleep for %d seconds ...\n", NE_SLEEP_TIME);
+
+       sleep(NE_SLEEP_TIME);
+
+       close(enclave_fd);
+
+       ne_free_mem_regions(ne_user_mem_regions);
+
+       exit(EXIT_SUCCESS);
+
+release_enclave_fd:
+       close(enclave_fd);
+       ne_free_mem_regions(ne_user_mem_regions);
+
+       exit(EXIT_FAILURE);
+}
index 62c2756..95e4cdb 100644 (file)
@@ -66,7 +66,6 @@ KBUILD_CFLAGS += -Wnested-externs
 KBUILD_CFLAGS += -Wshadow
 KBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
 KBUILD_CFLAGS += -Wmissing-field-initializers
-KBUILD_CFLAGS += -Wsign-compare
 KBUILD_CFLAGS += -Wtype-limits
 KBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
 KBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
@@ -87,6 +86,7 @@ KBUILD_CFLAGS += -Wpacked
 KBUILD_CFLAGS += -Wpadded
 KBUILD_CFLAGS += -Wpointer-arith
 KBUILD_CFLAGS += -Wredundant-decls
+KBUILD_CFLAGS += -Wsign-compare
 KBUILD_CFLAGS += -Wswitch-default
 KBUILD_CFLAGS += $(call cc-option, -Wpacked-bitfield-compat)
 
index 60d4a79..504d2e4 100755 (executable)
@@ -2639,8 +2639,8 @@ sub process {
 
 # Check if the commit log has what seems like a diff which can confuse patch
                if ($in_commit_log && !$commit_log_has_diff &&
-                   (($line =~ m@^\s+diff\b.*a/[\w/]+@ &&
-                     $line =~ m@^\s+diff\b.*a/([\w/]+)\s+b/$1\b@) ||
+                   (($line =~ m@^\s+diff\b.*a/([\w/]+)@ &&
+                     $line =~ m@^\s+diff\b.*a/[\w/]+\s+b/$1\b@) ||
                     $line =~ m@^\s*(?:\-\-\-\s+a/|\+\+\+\s+b/)@ ||
                     $line =~ m/^\s*\@\@ \-\d+,\d+ \+\d+,\d+ \@\@/)) {
                        ERROR("DIFF_IN_COMMIT_MSG",
index b071bf4..3bc48c7 100644 (file)
@@ -71,7 +71,7 @@ static void drain_openssl_errors(void)
 static const char *key_pass;
 static BIO *wb;
 static char *cert_dst;
-int kbuild_verbose;
+static int kbuild_verbose;
 
 static void write_cert(X509 *x509)
 {
index 7a85c4e..057c6ca 100644 (file)
@@ -25,9 +25,9 @@ static struct resword {
        { "__int128_t", BUILTIN_INT_KEYW },
        { "__uint128_t", BUILTIN_INT_KEYW },
 
-       // According to rth, c99 defines "_Bool", __restrict", __restrict__", "restrict".  KAO
+       // According to rth, c99 defines "_Bool", "__restrict", "__restrict__", "restrict".  KAO
        { "_Bool", BOOL_KEYW },
-       { "_restrict", RESTRICT_KEYW },
+       { "__restrict", RESTRICT_KEYW },
        { "__restrict__", RESTRICT_KEYW },
        { "restrict", RESTRICT_KEYW },
        { "asm", ASM_KEYW },
index daf1c15..e0f9655 100644 (file)
@@ -755,7 +755,6 @@ static void build_conf(struct menu *menu)
                        switch (ptype) {
                        case P_MENU:
                                child_count++;
-                               prompt = prompt;
                                if (single_menu_mode) {
                                        item_make(menu, 'm',
                                                "%s%*c%s",
index bc390df..8638785 100644 (file)
@@ -885,7 +885,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                connect(action, SIGNAL(toggled(bool)),
                        parent(), SLOT(setShowName(bool)));
                connect(parent(), SIGNAL(showNameChanged(bool)),
-                       action, SLOT(setOn(bool)));
+                       action, SLOT(setChecked(bool)));
                action->setChecked(showName);
                headerPopup->addAction(action);
 
@@ -894,7 +894,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                connect(action, SIGNAL(toggled(bool)),
                        parent(), SLOT(setShowRange(bool)));
                connect(parent(), SIGNAL(showRangeChanged(bool)),
-                       action, SLOT(setOn(bool)));
+                       action, SLOT(setChecked(bool)));
                action->setChecked(showRange);
                headerPopup->addAction(action);
 
@@ -903,7 +903,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
                connect(action, SIGNAL(toggled(bool)),
                        parent(), SLOT(setShowData(bool)));
                connect(parent(), SIGNAL(showDataChanged(bool)),
-                       action, SLOT(setOn(bool)));
+                       action, SLOT(setChecked(bool)));
                action->setChecked(showData);
                headerPopup->addAction(action);
        }
@@ -1012,6 +1012,16 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name)
                configSettings->endGroup();
                connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
        }
+
+       contextMenu = createStandardContextMenu();
+       QAction *action = new QAction("Show Debug Info", contextMenu);
+
+       action->setCheckable(true);
+       connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
+       connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setChecked(bool)));
+       action->setChecked(showDebug());
+       contextMenu->addSeparator();
+       contextMenu->addAction(action);
 }
 
 void ConfigInfoView::saveSettings(void)
@@ -1066,80 +1076,80 @@ void ConfigInfoView::symbolInfo(void)
 void ConfigInfoView::menuInfo(void)
 {
        struct symbol* sym;
-       QString head, debug, help;
+       QString info;
+       QTextStream stream(&info);
 
        sym = _menu->sym;
        if (sym) {
                if (_menu->prompt) {
-                       head += "<big><b>";
-                       head += print_filter(_menu->prompt->text);
-                       head += "</b></big>";
+                       stream << "<big><b>";
+                       stream << print_filter(_menu->prompt->text);
+                       stream << "</b></big>";
                        if (sym->name) {
-                               head += " (";
+                               stream << " (";
                                if (showDebug())
-                                       head += QString().sprintf("<a href=\"s%s\">", sym->name);
-                               head += print_filter(sym->name);
+                                       stream << "<a href=\"s" << sym->name << "\">";
+                               stream << print_filter(sym->name);
                                if (showDebug())
-                                       head += "</a>";
-                               head += ")";
+                                       stream << "</a>";
+                               stream << ")";
                        }
                } else if (sym->name) {
-                       head += "<big><b>";
+                       stream << "<big><b>";
                        if (showDebug())
-                               head += QString().sprintf("<a href=\"s%s\">", sym->name);
-                       head += print_filter(sym->name);
+                               stream << "<a href=\"s" << sym->name << "\">";
+                       stream << print_filter(sym->name);
                        if (showDebug())
-                               head += "</a>";
-                       head += "</b></big>";
+                               stream << "</a>";
+                       stream << "</b></big>";
                }
-               head += "<br><br>";
+               stream << "<br><br>";
 
                if (showDebug())
-                       debug = debug_info(sym);
+                       stream << debug_info(sym);
 
-               struct gstr help_gstr = str_new();
-               menu_get_ext_help(_menu, &help_gstr);
-               help = print_filter(str_get(&help_gstr));
-               str_free(&help_gstr);
        } else if (_menu->prompt) {
-               head += "<big><b>";
-               head += print_filter(_menu->prompt->text);
-               head += "</b></big><br><br>";
+               stream << "<big><b>";
+               stream << print_filter(_menu->prompt->text);
+               stream << "</b></big><br><br>";
                if (showDebug()) {
                        if (_menu->prompt->visible.expr) {
-                               debug += "&nbsp;&nbsp;dep: ";
-                               expr_print(_menu->prompt->visible.expr, expr_print_help, &debug, E_NONE);
-                               debug += "<br><br>";
+                               stream << "&nbsp;&nbsp;dep: ";
+                               expr_print(_menu->prompt->visible.expr,
+                                          expr_print_help, &stream, E_NONE);
+                               stream << "<br><br>";
                        }
                }
        }
        if (showDebug())
-               debug += QString().sprintf("defined at %s:%d<br><br>", _menu->file->name, _menu->lineno);
+               stream << "defined at " << _menu->file->name << ":"
+                      << _menu->lineno << "<br><br>";
 
-       setText(head + debug + help);
+       setText(info);
 }
 
 QString ConfigInfoView::debug_info(struct symbol *sym)
 {
        QString debug;
+       QTextStream stream(&debug);
 
-       debug += "type: ";
-       debug += print_filter(sym_type_name(sym->type));
+       stream << "type: ";
+       stream << print_filter(sym_type_name(sym->type));
        if (sym_is_choice(sym))
-               debug += " (choice)";
+               stream << " (choice)";
        debug += "<br>";
        if (sym->rev_dep.expr) {
-               debug += "reverse dep: ";
-               expr_print(sym->rev_dep.expr, expr_print_help, &debug, E_NONE);
-               debug += "<br>";
+               stream << "reverse dep: ";
+               expr_print(sym->rev_dep.expr, expr_print_help, &stream, E_NONE);
+               stream << "<br>";
        }
        for (struct property *prop = sym->prop; prop; prop = prop->next) {
                switch (prop->type) {
                case P_PROMPT:
                case P_MENU:
-                       debug += QString().sprintf("prompt: <a href=\"m%s\">", sym->name);
-                       debug += print_filter(prop->text);
-                       debug += "</a><br>";
+                       stream << "prompt: <a href=\"m" << sym->name << "\">";
+                       stream << print_filter(prop->text);
+                       stream << "</a><br>";
                        break;
                case P_DEFAULT:
                case P_SELECT:
@@ -1147,30 +1157,33 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
                case P_COMMENT:
                case P_IMPLY:
                case P_SYMBOL:
-                       debug += prop_get_type_name(prop->type);
-                       debug += ": ";
-                       expr_print(prop->expr, expr_print_help, &debug, E_NONE);
-                       debug += "<br>";
+                       stream << prop_get_type_name(prop->type);
+                       stream << ": ";
+                       expr_print(prop->expr, expr_print_help,
+                                  &stream, E_NONE);
+                       stream << "<br>";
                        break;
                case P_CHOICE:
                        if (sym_is_choice(sym)) {
-                               debug += "choice: ";
-                               expr_print(prop->expr, expr_print_help, &debug, E_NONE);
-                               debug += "<br>";
+                               stream << "choice: ";
+                               expr_print(prop->expr, expr_print_help,
+                                          &stream, E_NONE);
+                               stream << "<br>";
                        }
                        break;
                default:
-                       debug += "unknown property: ";
-                       debug += prop_get_type_name(prop->type);
-                       debug += "<br>";
+                       stream << "unknown property: ";
+                       stream << prop_get_type_name(prop->type);
+                       stream << "<br>";
                }
                if (prop->visible.expr) {
-                       debug += "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
-                       expr_print(prop->visible.expr, expr_print_help, &debug, E_NONE);
-                       debug += "<br>";
+                       stream << "&nbsp;&nbsp;&nbsp;&nbsp;dep: ";
+                       expr_print(prop->visible.expr, expr_print_help,
+                                  &stream, E_NONE);
+                       stream << "<br>";
                }
        }
-       debug += "<br>";
+       stream << "<br>";
 
        return debug;
 }
@@ -1208,15 +1221,15 @@ QString ConfigInfoView::print_filter(const QString &str)
 
 void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *str)
 {
-       QString* text = reinterpret_cast<QString*>(data);
-       QString str2 = print_filter(str);
+       QTextStream *stream = reinterpret_cast<QTextStream *>(data);
 
        if (sym && sym->name && !(sym->flags & SYMBOL_CONST)) {
-               *text += QString().sprintf("<a href=\"s%s\">", sym->name);
-               *text += str2;
-               *text += "</a>";
-       } else
-               *text += str2;
+               *stream << "<a href=\"s" << sym->name << "\">";
+               *stream << print_filter(str);
+               *stream << "</a>";
+       } else {
+               *stream << print_filter(str);
+       }
 }
 
 void ConfigInfoView::clicked(const QUrl &url)
@@ -1228,7 +1241,6 @@ void ConfigInfoView::clicked(const QUrl &url)
        struct menu *m = NULL;
 
        if (count < 1) {
-               qInfo() << "Clicked link is empty";
                delete[] data;
                return;
        }
@@ -1241,7 +1253,6 @@ void ConfigInfoView::clicked(const QUrl &url)
        strcat(data, "$");
        result = sym_re_search(data);
        if (!result) {
-               qInfo() << "Clicked symbol is invalid:" << data;
                delete[] data;
                return;
        }
@@ -1268,23 +1279,10 @@ void ConfigInfoView::clicked(const QUrl &url)
        delete data;
 }
 
-QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos)
-{
-       QMenu* popup = Parent::createStandardContextMenu(pos);
-       QAction* action = new QAction("Show Debug Info", popup);
-
-       action->setCheckable(true);
-       connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
-       connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
-       action->setChecked(showDebug());
-       popup->addSeparator();
-       popup->addAction(action);
-       return popup;
-}
-
-void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e)
+void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
 {
-       Parent::contextMenuEvent(e);
+       contextMenu->popup(event->globalPos());
+       event->accept();
 }
 
 ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow *parent)
index 461df64..f97376a 100644 (file)
@@ -30,7 +30,7 @@ public:
 };
 
 enum colIdx {
-       promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
+       promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx
 };
 enum listMode {
        singleMode, menuMode, symbolMode, fullMode, listMode
@@ -215,6 +215,7 @@ public:
 class ConfigInfoView : public QTextBrowser {
        Q_OBJECT
        typedef class QTextBrowser Parent;
+       QMenu *contextMenu;
 public:
        ConfigInfoView(QWidget* parent, const char *name = 0);
        bool showDebug(void) const { return _showDebug; }
@@ -235,8 +236,7 @@ protected:
        QString debug_info(struct symbol *sym);
        static QString print_filter(const QString &str);
        static void expr_print_help(void *data, struct symbol *sym, const char *str);
-       QMenu *createStandardContextMenu(const QPoint & pos);
-       void contextMenuEvent(QContextMenuEvent *e);
+       void contextMenuEvent(QContextMenuEvent *event);
 
        struct symbol *sym;
        struct menu *_menu;
index 19857d1..1c78ba4 100755 (executable)
@@ -593,7 +593,10 @@ while ($repeat) {
 }
 
 my %setconfigs;
-my @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
+my @preserved_kconfigs;
+if (defined($ENV{'LMC_KEEP'})) {
+       @preserved_kconfigs = split(/:/,$ENV{LMC_KEEP});
+}
 
 sub in_preserved_kconfigs {
     my $kconfig = $config2kfile{$_[0]};
index 32d3f53..850f4cc 100755 (executable)
@@ -26,7 +26,11 @@ else
 fi
 
 # ignore userspace tools
-ignore="$ignore ( -path ${tree}tools ) -prune -o"
+if [ -n "$COMPILED_SOURCE" ]; then
+       ignore="$ignore ( -path ./tools ) -prune -o"
+else
+       ignore="$ignore ( -path ${tree}tools ) -prune -o"
+fi
 
 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
 if [ "${ALLSOURCE_ARCHS}" = "" ]; then
@@ -92,7 +96,7 @@ all_sources()
 all_compiled_sources()
 {
        realpath -es $([ -z "$KBUILD_ABS_SRCTREE" ] && echo --relative-to=.) \
-               include/generated/autoconf.h $(find -name "*.cmd" -exec \
+               include/generated/autoconf.h $(find $ignore -name "*.cmd" -exec \
                grep -Poh '(?(?=^source_.* \K).*|(?=^  \K\S).*(?= \\))' {} \+ |
                awk '!a[$0]++') | sort -u
 }
index 7b0e13c..f919ebd 100644 (file)
@@ -577,7 +577,7 @@ static struct aa_label *x_to_label(struct aa_profile *profile,
                        stack = NULL;
                        break;
                }
-               /* fall through - to X_NAME */
+               fallthrough;    /* to X_NAME */
        case AA_X_NAME:
                if (xindex & AA_X_CHILD)
                        /* released by caller */
index 30c246a..fa49b81 100644 (file)
@@ -292,13 +292,13 @@ void aa_apply_modes_to_perms(struct aa_profile *profile, struct aa_perms *perms)
        switch (AUDIT_MODE(profile)) {
        case AUDIT_ALL:
                perms->audit = ALL_PERMS_MASK;
-               /* fall through */
+               fallthrough;
        case AUDIT_NOQUIET:
                perms->quiet = 0;
                break;
        case AUDIT_QUIET:
                perms->audit = 0;
-               /* fall through */
+               fallthrough;
        case AUDIT_QUIET_DENIED:
                perms->quiet = ALL_PERMS_MASK;
                break;
index 372d163..b8848f5 100644 (file)
@@ -223,7 +223,7 @@ static int xattr_verify(enum ima_hooks func, struct integrity_iint_cache *iint,
        case IMA_XATTR_DIGEST_NG:
                /* first byte contains algorithm id */
                hash_start = 1;
-               /* fall through */
+               fallthrough;
        case IMA_XATTR_DIGEST:
                if (iint->flags & IMA_DIGSIG_REQUIRED) {
                        *cause = "IMA-signature-required";
@@ -395,7 +395,7 @@ int ima_appraise_measurement(enum ima_hooks func,
                /* It's fine not to have xattrs when using a modsig. */
                if (try_modsig)
                        break;
-               /* fall through */
+               fallthrough;
        case INTEGRITY_NOLABEL:         /* No security.evm xattr. */
                cause = "missing-HMAC";
                goto out;
index 07f0336..b4de330 100644 (file)
@@ -1279,12 +1279,12 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
                case Opt_uid_gt:
                case Opt_euid_gt:
                        entry->uid_op = &uid_gt;
-                       /* fall through */
+                       fallthrough;
                case Opt_uid_lt:
                case Opt_euid_lt:
                        if ((token == Opt_uid_lt) || (token == Opt_euid_lt))
                                entry->uid_op = &uid_lt;
-                       /* fall through */
+                       fallthrough;
                case Opt_uid_eq:
                case Opt_euid_eq:
                        uid_token = (token == Opt_uid_eq) ||
@@ -1313,11 +1313,11 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
                        break;
                case Opt_fowner_gt:
                        entry->fowner_op = &uid_gt;
-                       /* fall through */
+                       fallthrough;
                case Opt_fowner_lt:
                        if (token == Opt_fowner_lt)
                                entry->fowner_op = &uid_lt;
-                       /* fall through */
+                       fallthrough;
                case Opt_fowner_eq:
                        ima_log_string_op(ab, "fowner", args[0].from,
                                          entry->fowner_op);
index 41a5f43..c022ee9 100644 (file)
@@ -77,7 +77,7 @@ static void ima_show_template_data_ascii(struct seq_file *m,
                /* skip ':' and '\0' */
                buf_ptr += 2;
                buflen -= buf_ptr - field_data->data;
-               /* fall through */
+               fallthrough;
        case DATA_FMT_DIGEST:
        case DATA_FMT_HEX:
                if (!buflen)
index 7e0232d..1fe8b93 100644 (file)
@@ -465,7 +465,7 @@ key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx)
                case -EAGAIN: /* no key */
                        if (ret)
                                break;
-                       /* fall through */
+                       fallthrough;
                case -ENOKEY: /* negative key */
                        ret = key_ref;
                        break;
@@ -487,7 +487,7 @@ key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx)
                case -EAGAIN: /* no key */
                        if (ret)
                                break;
-                       /* fall through */
+                       fallthrough;
                case -ENOKEY: /* negative key */
                        ret = key_ref;
                        break;
@@ -509,7 +509,7 @@ key_ref_t search_cred_keyrings_rcu(struct keyring_search_context *ctx)
                case -EAGAIN: /* no key */
                        if (ret)
                                break;
-                       /* fall through */
+                       fallthrough;
                case -ENOKEY: /* negative key */
                        ret = key_ref;
                        break;
index e1b9f1a..2da4404 100644 (file)
@@ -295,26 +295,26 @@ static int construct_get_dest_keyring(struct key **_dest_keyring)
                                }
                        }
 
-                       /* fall through */
+                       fallthrough;
                case KEY_REQKEY_DEFL_THREAD_KEYRING:
                        dest_keyring = key_get(cred->thread_keyring);
                        if (dest_keyring)
                                break;
 
-                       /* fall through */
+                       fallthrough;
                case KEY_REQKEY_DEFL_PROCESS_KEYRING:
                        dest_keyring = key_get(cred->process_keyring);
                        if (dest_keyring)
                                break;
 
-                       /* fall through */
+                       fallthrough;
                case KEY_REQKEY_DEFL_SESSION_KEYRING:
                        dest_keyring = key_get(cred->session_keyring);
 
                        if (dest_keyring)
                                break;
 
-                       /* fall through */
+                       fallthrough;
                case KEY_REQKEY_DEFL_USER_SESSION_KEYRING:
                        ret = look_up_user_keyrings(NULL, &dest_keyring);
                        if (ret < 0)
index ca90102..a340986 100644 (file)
@@ -3606,26 +3606,20 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
 
        switch (cmd) {
        case FIONREAD:
-       /* fall through */
        case FIBMAP:
-       /* fall through */
        case FIGETBSZ:
-       /* fall through */
        case FS_IOC_GETFLAGS:
-       /* fall through */
        case FS_IOC_GETVERSION:
                error = file_has_perm(cred, file, FILE__GETATTR);
                break;
 
        case FS_IOC_SETFLAGS:
-       /* fall through */
        case FS_IOC_SETVERSION:
                error = file_has_perm(cred, file, FILE__SETATTR);
                break;
 
        /* sys_ioctl() checks */
        case FIONBIO:
-       /* fall through */
        case FIOASYNC:
                error = file_has_perm(cred, file, 0);
                break;
@@ -3783,7 +3777,7 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
                        err = file_has_perm(cred, file, FILE__WRITE);
                        break;
                }
-               /* fall through */
+               fallthrough;
        case F_SETOWN:
        case F_SETSIG:
        case F_GETFL:
index 408d306..d338962 100644 (file)
@@ -535,7 +535,7 @@ int mls_compute_sid(struct policydb *p,
                                                  scontext, tcontext);
                }
 
-               /* Fallthrough */
+               fallthrough;
        case AVTAB_CHANGE:
                if ((tclass == p->process_class) || sock)
                        /* Use the process MLS attributes. */
@@ -546,8 +546,6 @@ int mls_compute_sid(struct policydb *p,
        case AVTAB_MEMBER:
                /* Use the process effective MLS attributes. */
                return mls_context_cpy_low(newcontext, scontext);
-
-       /* fall through */
        }
        return -EINVAL;
 }
index 8ffbf95..8c0893e 100644 (file)
@@ -3365,7 +3365,7 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
                 * to set mount options simulate setting the
                 * superblock default.
                 */
-               /* Fall through */
+               fallthrough;
        default:
                /*
                 * This isn't an understood special case.
index c16b8c1..4bee32b 100644 (file)
@@ -1240,7 +1240,7 @@ static bool tomoyo_print_condition(struct tomoyo_io_buffer *head,
                        tomoyo_set_space(head);
                        tomoyo_set_string(head, cond->transit->name);
                }
-               /* fall through */
+               fallthrough;
        case 1:
                {
                        const u16 condc = cond->condc;
@@ -1345,12 +1345,12 @@ static bool tomoyo_print_condition(struct tomoyo_io_buffer *head,
                        }
                }
                head->r.cond_step++;
-               /* fall through */
+               fallthrough;
        case 2:
                if (!tomoyo_flush(head))
                        break;
                head->r.cond_step++;
-               /* fall through */
+               fallthrough;
        case 3:
                if (cond->grant_log != TOMOYO_GRANTLOG_AUTO)
                        tomoyo_io_printf(head, " grant_log=%s",
@@ -1639,7 +1639,7 @@ static void tomoyo_read_domain(struct tomoyo_io_buffer *head)
                                        tomoyo_set_string(head, tomoyo_dif[i]);
                        head->r.index = 0;
                        head->r.step++;
-                       /* fall through */
+                       fallthrough;
                case 1:
                        while (head->r.index < TOMOYO_MAX_ACL_GROUPS) {
                                i = head->r.index++;
@@ -1652,14 +1652,14 @@ static void tomoyo_read_domain(struct tomoyo_io_buffer *head)
                        head->r.index = 0;
                        head->r.step++;
                        tomoyo_set_lf(head);
-                       /* fall through */
+                       fallthrough;
                case 2:
                        if (!tomoyo_read_domain2(head, &domain->acl_info_list))
                                return;
                        head->r.step++;
                        if (!tomoyo_set_lf(head))
                                return;
-                       /* fall through */
+                       fallthrough;
                case 3:
                        head->r.step = 0;
                        if (head->r.print_this_domain_only)
@@ -2088,7 +2088,7 @@ int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
                /* Check max_learning_entry parameter. */
                if (tomoyo_domain_quota_is_ok(r))
                        break;
-               /* fall through */
+               fallthrough;
        default:
                return 0;
        }
@@ -2710,13 +2710,13 @@ ssize_t tomoyo_write_control(struct tomoyo_io_buffer *head,
                case TOMOYO_DOMAINPOLICY:
                        if (tomoyo_select_domain(head, cp0))
                                continue;
-                       /* fall through */
+                       fallthrough;
                case TOMOYO_EXCEPTIONPOLICY:
                        if (!strcmp(cp0, "select transition_only")) {
                                head->r.print_transition_related_only = true;
                                continue;
                        }
-                       /* fall through */
+                       fallthrough;
                default:
                        if (!tomoyo_manager()) {
                                error = -EPERM;
index 86f7d1b..051f729 100644 (file)
@@ -927,7 +927,7 @@ int tomoyo_path2_perm(const u8 operation, const struct path *path1,
        case TOMOYO_TYPE_LINK:
                if (!d_is_dir(path1->dentry))
                        break;
-               /* fall through */
+               fallthrough;
        case TOMOYO_TYPE_PIVOT_ROOT:
                tomoyo_add_slash(&buf1);
                tomoyo_add_slash(&buf2);
index 3788906..fe27034 100644 (file)
@@ -329,8 +329,8 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
                snd_BUG();
                return -EINVAL;
        }
-       if (snd_BUG_ON(!snd_pcm_format_linear(format->format)))
-               return -ENXIO;
+       if (!snd_pcm_format_linear(format->format))
+               return -EINVAL;
 
        err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion",
                                   src_format, dst_format,
index d9f85f2..6e27d87 100644 (file)
@@ -816,9 +816,9 @@ static void snd_timer_clear_callbacks(struct snd_timer *timer,
  * timer tasklet
  *
  */
-static void snd_timer_tasklet(unsigned long arg)
+static void snd_timer_tasklet(struct tasklet_struct *t)
 {
-       struct snd_timer *timer = (struct snd_timer *) arg;
+       struct snd_timer *timer = from_tasklet(timer, t, task_queue);
        unsigned long flags;
 
        if (timer->card && timer->card->shutdown) {
@@ -967,8 +967,7 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,
        INIT_LIST_HEAD(&timer->ack_list_head);
        INIT_LIST_HEAD(&timer->sack_list_head);
        spin_lock_init(&timer->lock);
-       tasklet_init(&timer->task_queue, snd_timer_tasklet,
-                    (unsigned long)timer);
+       tasklet_setup(&timer->task_queue, snd_timer_tasklet);
        timer->max_instances = 1000; /* default limit per timer */
        if (card != NULL) {
                timer->module = card->module;
index f8586f7..ee1c428 100644 (file)
@@ -64,7 +64,7 @@
 #define IT_PKT_HEADER_SIZE_CIP         8 // For 2 CIP header.
 #define IT_PKT_HEADER_SIZE_NO_CIP      0 // Nothing.
 
-static void pcm_period_tasklet(unsigned long data);
+static void pcm_period_tasklet(struct tasklet_struct *t);
 
 /**
  * amdtp_stream_init - initialize an AMDTP stream structure
@@ -94,7 +94,7 @@ int amdtp_stream_init(struct amdtp_stream *s, struct fw_unit *unit,
        s->flags = flags;
        s->context = ERR_PTR(-1);
        mutex_init(&s->mutex);
-       tasklet_init(&s->period_tasklet, pcm_period_tasklet, (unsigned long)s);
+       tasklet_setup(&s->period_tasklet, pcm_period_tasklet);
        s->packet_index = 0;
 
        init_waitqueue_head(&s->callback_wait);
@@ -441,9 +441,9 @@ static void update_pcm_pointers(struct amdtp_stream *s,
        }
 }
 
-static void pcm_period_tasklet(unsigned long data)
+static void pcm_period_tasklet(struct tasklet_struct *t)
 {
-       struct amdtp_stream *s = (void *)data;
+       struct amdtp_stream *s = from_tasklet(s, t, period_tasklet);
        struct snd_pcm_substream *pcm = READ_ONCE(s->pcm);
 
        if (pcm)
index c84b913..ab84089 100644 (file)
@@ -14,6 +14,7 @@ MODULE_LICENSE("GPL v2");
 #define VENDOR_DIGIDESIGN      0x00a07e
 #define MODEL_CONSOLE          0x000001
 #define MODEL_RACK             0x000002
+#define SPEC_VERSION           0x000001
 
 static int name_card(struct snd_dg00x *dg00x)
 {
@@ -175,14 +176,18 @@ static const struct ieee1394_device_id snd_dg00x_id_table[] = {
        /* Both of 002/003 use the same ID. */
        {
                .match_flags = IEEE1394_MATCH_VENDOR_ID |
+                              IEEE1394_MATCH_VERSION |
                               IEEE1394_MATCH_MODEL_ID,
                .vendor_id = VENDOR_DIGIDESIGN,
+               .version = SPEC_VERSION,
                .model_id = MODEL_CONSOLE,
        },
        {
                .match_flags = IEEE1394_MATCH_VENDOR_ID |
+                              IEEE1394_MATCH_VERSION |
                               IEEE1394_MATCH_MODEL_ID,
                .vendor_id = VENDOR_DIGIDESIGN,
+               .version = SPEC_VERSION,
                .model_id = MODEL_RACK,
        },
        {}
index 5dac0d9..75f2edd 100644 (file)
@@ -39,9 +39,6 @@ static const struct snd_tscm_spec model_specs[] = {
                .midi_capture_ports = 2,
                .midi_playback_ports = 4,
        },
-       // This kernel module doesn't support FE-8 because the most of features
-       // can be implemented in userspace without any specific support of this
-       // module.
 };
 
 static int identify_model(struct snd_tscm *tscm)
@@ -211,11 +208,39 @@ static void snd_tscm_remove(struct fw_unit *unit)
 }
 
 static const struct ieee1394_device_id snd_tscm_id_table[] = {
+       // Tascam, FW-1884.
+       {
+               .match_flags = IEEE1394_MATCH_VENDOR_ID |
+                              IEEE1394_MATCH_SPECIFIER_ID |
+                              IEEE1394_MATCH_VERSION,
+               .vendor_id = 0x00022e,
+               .specifier_id = 0x00022e,
+               .version = 0x800000,
+       },
+       // Tascam, FE-8 (.version = 0x800001)
+       // This kernel module doesn't support FE-8 because the most of features
+       // can be implemented in userspace without any specific support of this
+       // module.
+       //
+       // .version = 0x800002 is unknown.
+       //
+       // Tascam, FW-1082.
+       {
+               .match_flags = IEEE1394_MATCH_VENDOR_ID |
+                              IEEE1394_MATCH_SPECIFIER_ID |
+                              IEEE1394_MATCH_VERSION,
+               .vendor_id = 0x00022e,
+               .specifier_id = 0x00022e,
+               .version = 0x800003,
+       },
+       // Tascam, FW-1804.
        {
                .match_flags = IEEE1394_MATCH_VENDOR_ID |
-                              IEEE1394_MATCH_SPECIFIER_ID,
+                              IEEE1394_MATCH_SPECIFIER_ID |
+                              IEEE1394_MATCH_VERSION,
                .vendor_id = 0x00022e,
                .specifier_id = 0x00022e,
+               .version = 0x800004,
        },
        {}
 };
index 09ddab5..9766f6a 100644 (file)
@@ -46,6 +46,18 @@ int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
        INIT_LIST_HEAD(&bus->hlink_list);
        init_waitqueue_head(&bus->rirb_wq);
        bus->irq = -1;
+
+       /*
+        * Default value of '8' is as per the HD audio specification (Rev 1.0a).
+        * Following relation is used to derive STRIPE control value.
+        *  For sample rate <= 48K:
+        *   { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }
+        *  For sample rate > 48K:
+        *   { ((num_channels * bits_per_sample * rate/48000) /
+        *      number of SDOs) >= 8 }
+        */
+       bus->sdo_limit = 8;
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_init);
index 011b17c..b98449f 100644 (file)
@@ -529,17 +529,6 @@ bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset)
 
        bus->chip_init = true;
 
-       /*
-        * Default value of '8' is as per the HD audio specification (Rev 1.0a).
-        * Following relation is used to derive STRIPE control value.
-        *  For sample rate <= 48K:
-        *   { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }
-        *  For sample rate > 48K:
-        *   { ((num_channels * bits_per_sample * rate/48000) /
-        *      number of SDOs) >= 8 }
-        */
-       bus->sdo_limit = 8;
-
        return true;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_init_chip);
index 333220f..3e9e9ac 100644 (file)
@@ -127,6 +127,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_init);
 void snd_hdac_device_exit(struct hdac_device *codec)
 {
        pm_runtime_put_noidle(&codec->dev);
+       /* keep balance of runtime PM child_count in parent device */
+       pm_runtime_set_suspended(&codec->dev);
        snd_hdac_bus_remove_device(codec->bus, codec);
        kfree(codec->vendor_name);
        kfree(codec->chip_name);
index 99aec73..1c5114d 100644 (file)
@@ -54,7 +54,7 @@ static const struct config_entry config_table[] = {
 #endif
 /*
  * Apollolake (Broxton-P)
- * the legacy HDaudio driver is used except on Up Squared (SOF) and
+ * the legacy HDAudio driver is used except on Up Squared (SOF) and
  * Chromebooks (SST)
  */
 #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE)
@@ -89,7 +89,7 @@ static const struct config_entry config_table[] = {
        },
 #endif
 /*
- * Skylake and Kabylake use legacy HDaudio driver except for Google
+ * Skylake and Kabylake use legacy HDAudio driver except for Google
  * Chromebooks (SST)
  */
 
@@ -135,7 +135,7 @@ static const struct config_entry config_table[] = {
 #endif
 
 /*
- * Geminilake uses legacy HDaudio driver except for Google
+ * Geminilake uses legacy HDAudio driver except for Google
  * Chromebooks
  */
 /* Geminilake */
@@ -157,7 +157,7 @@ static const struct config_entry config_table[] = {
 
 /*
  * CoffeeLake, CannonLake, CometLake, IceLake, TigerLake use legacy
- * HDaudio driver except for Google Chromebooks and when DMICs are
+ * HDAudio driver except for Google Chromebooks and when DMICs are
  * present. Two cases are required since Coreboot does not expose NHLT
  * tables.
  *
@@ -391,7 +391,7 @@ int snd_intel_dsp_driver_probe(struct pci_dev *pci)
        if (pci->class == 0x040300)
                return SND_INTEL_DSP_DRIVER_LEGACY;
        if (pci->class != 0x040100 && pci->class != 0x040380) {
-               dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDA legacy driver\n", pci->class);
+               dev_err(&pci->dev, "Unknown PCI class/subclass/prog-if information (0x%06x) found, selecting HDAudio legacy driver\n", pci->class);
                return SND_INTEL_DSP_DRIVER_LEGACY;
        }
 
index 5363d88..2e5a5c5 100644 (file)
@@ -308,7 +308,7 @@ static inline int verify_mpu401(const struct snd_mpu401 *mpu)
 }
 
 /*
- * This is apparently the standard way to initailise an MPU-401
+ * This is apparently the standard way to initialise an MPU-401
  */
 static inline void initialise_mpu401(const struct snd_mpu401 *mpu)
 {
@@ -339,7 +339,7 @@ static void soundscape_free(struct snd_card *c)
 }
 
 /*
- * Tell the SoundScape to begin a DMA tranfer using the given channel.
+ * Tell the SoundScape to begin a DMA transfer using the given channel.
  * All locking issues are left to the caller.
  */
 static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg)
@@ -803,7 +803,7 @@ static int mpu401_open(struct snd_mpu401 *mpu)
 }
 
 /*
- * Initialse an MPU-401 subdevice for MIDI support on the SoundScape.
+ * Initialise an MPU-401 subdevice for MIDI support on the SoundScape.
  */
 static int create_mpu401(struct snd_card *card, int devnum,
                         unsigned long port, int irq)
index 023c35a..35e7648 100644 (file)
@@ -921,10 +921,10 @@ static void snd_card_asihpi_timer_function(struct timer_list *t)
                add_timer(&dpcm->timer);
 }
 
-static void snd_card_asihpi_int_task(unsigned long data)
+static void snd_card_asihpi_int_task(struct tasklet_struct *t)
 {
-       struct hpi_adapter *a = (struct hpi_adapter *)data;
-       struct snd_card_asihpi *asihpi;
+       struct snd_card_asihpi *asihpi = from_tasklet(asihpi, t, t);
+       struct hpi_adapter *a = asihpi->hpi;
 
        WARN_ON(!a || !a->snd_card || !a->snd_card->private_data);
        asihpi = (struct snd_card_asihpi *)a->snd_card->private_data;
@@ -2871,8 +2871,7 @@ static int snd_asihpi_probe(struct pci_dev *pci_dev,
        if (hpi->interrupt_mode) {
                asihpi->pcm_start = snd_card_asihpi_pcm_int_start;
                asihpi->pcm_stop = snd_card_asihpi_pcm_int_stop;
-               tasklet_init(&asihpi->t, snd_card_asihpi_int_task,
-                       (unsigned long)hpi);
+               tasklet_setup(&asihpi->t, snd_card_asihpi_int_task);
                hpi->interrupt_callback = snd_card_asihpi_isr;
        } else {
                asihpi->pcm_start = snd_card_asihpi_pcm_timer_start;
index 70d775f..c189f70 100644 (file)
@@ -537,7 +537,8 @@ static int snd_ca0106_pcm_power_dac(struct snd_ca0106 *chip, int channel_id,
                else
                        /* Power down */
                        chip->spi_dac_reg[reg] |= bit;
-               return snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]);
+               if (snd_ca0106_spi_write(chip, chip->spi_dac_reg[reg]) != 0)
+                       return -ENXIO;
        }
        return 0;
 }
index e34a4d5..36a9dbc 100644 (file)
@@ -2127,9 +2127,10 @@ static int azx_probe(struct pci_dev *pci,
         */
        if (dmic_detect) {
                err = snd_intel_dsp_driver_probe(pci);
-               if (err != SND_INTEL_DSP_DRIVER_ANY &&
-                   err != SND_INTEL_DSP_DRIVER_LEGACY)
+               if (err != SND_INTEL_DSP_DRIVER_ANY && err != SND_INTEL_DSP_DRIVER_LEGACY) {
+                       dev_dbg(&pci->dev, "HDAudio driver not selected, aborting probe\n");
                        return -ENODEV;
+               }
        } else {
                dev_warn(&pci->dev, "dmic_detect option is deprecated, pass snd-intel-dspcfg.dsp_driver=1 option instead\n");
        }
@@ -2745,8 +2746,6 @@ static const struct pci_device_id azx_ids[] = {
          .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_HDMI },
        /* Zhaoxin */
        { PCI_DEVICE(0x1d17, 0x3288), .driver_data = AZX_DRIVER_ZHAOXIN },
-       /* Loongson */
-       { PCI_DEVICE(0x0014, 0x7a07), .driver_data = AZX_DRIVER_GENERIC },
        { 0, }
 };
 MODULE_DEVICE_TABLE(pci, azx_ids);
index c94553b..70164d1 100644 (file)
@@ -179,6 +179,10 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev)
        struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip);
 
        if (chip && chip->running) {
+               /* enable controller wake up event */
+               azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
+                          STATESTS_INT_MASK);
+
                azx_stop_chip(chip);
                azx_enter_link_reset(chip);
        }
@@ -200,6 +204,9 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev)
        if (chip && chip->running) {
                hda_tegra_init(hda);
                azx_init_chip(chip, 1);
+               /* disable controller wake up event*/
+               azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
+                          ~STATESTS_INT_MASK);
        }
 
        return 0;
index b8c8490..4020500 100644 (file)
@@ -2794,6 +2794,7 @@ static void i915_pin_cvt_fixup(struct hda_codec *codec,
                               hda_nid_t cvt_nid)
 {
        if (per_pin) {
+               haswell_verify_D0(codec, per_pin->cvt_nid, per_pin->pin_nid);
                snd_hda_set_dev_select(codec, per_pin->pin_nid,
                               per_pin->dev_id);
                intel_verify_pin_cvt_connect(codec, per_pin);
@@ -3734,6 +3735,7 @@ static int tegra_hdmi_build_pcms(struct hda_codec *codec)
 
 static int patch_tegra_hdmi(struct hda_codec *codec)
 {
+       struct hdmi_spec *spec;
        int err;
 
        err = patch_generic_hdmi(codec);
@@ -3741,6 +3743,10 @@ static int patch_tegra_hdmi(struct hda_codec *codec)
                return err;
 
        codec->patch_ops.build_pcms = tegra_hdmi_build_pcms;
+       spec = codec->spec;
+       spec->chmap.ops.chmap_cea_alloc_validate_get_type =
+               nvhdmi_chmap_cea_alloc_validate_get_type;
+       spec->chmap.ops.chmap_validate = nvhdmi_chmap_validate;
 
        return 0;
 }
@@ -4263,6 +4269,7 @@ HDA_CODEC_ENTRY(0x8086280c, "Cannonlake HDMI",    patch_i915_glk_hdmi),
 HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_glk_hdmi),
 HDA_CODEC_ENTRY(0x8086280f, "Icelake HDMI",    patch_i915_icl_hdmi),
 HDA_CODEC_ENTRY(0x80862812, "Tigerlake HDMI",  patch_i915_tgl_hdmi),
+HDA_CODEC_ENTRY(0x80862816, "Rocketlake HDMI", patch_i915_tgl_hdmi),
 HDA_CODEC_ENTRY(0x8086281a, "Jasperlake HDMI", patch_i915_icl_hdmi),
 HDA_CODEC_ENTRY(0x8086281b, "Elkhartlake HDMI",        patch_i915_icl_hdmi),
 HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
index 7f9d352..c521a1f 100644 (file)
@@ -2475,6 +2475,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
+       SND_PCI_QUIRK(0x1462, 0x9c37, "MSI X570-A PRO", ALC1220_FIXUP_CLEVO_P950),
        SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS),
        SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
        SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
@@ -5867,6 +5868,39 @@ static void alc275_fixup_gpio4_off(struct hda_codec *codec,
        }
 }
 
+/* Quirk for Thinkpad X1 7th and 8th Gen
+ * The following fixed routing needed
+ * DAC1 (NID 0x02) -> Speaker (NID 0x14); some eq applied secretly
+ * DAC2 (NID 0x03) -> Bass (NID 0x17) & Headphone (NID 0x21); sharing a DAC
+ * DAC3 (NID 0x06) -> Unused, due to the lack of volume amp
+ */
+static void alc285_fixup_thinkpad_x1_gen7(struct hda_codec *codec,
+                                         const struct hda_fixup *fix, int action)
+{
+       static const hda_nid_t conn[] = { 0x02, 0x03 }; /* exclude 0x06 */
+       static const hda_nid_t preferred_pairs[] = {
+               0x14, 0x02, 0x17, 0x03, 0x21, 0x03, 0
+       };
+       struct alc_spec *spec = codec->spec;
+
+       switch (action) {
+       case HDA_FIXUP_ACT_PRE_PROBE:
+               snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
+               spec->gen.preferred_dacs = preferred_pairs;
+               break;
+       case HDA_FIXUP_ACT_BUILD:
+               /* The generic parser creates somewhat unintuitive volume ctls
+                * with the fixed routing above, and the shared DAC2 may be
+                * confusing for PA.
+                * Rename those to unique names so that PA doesn't touch them
+                * and use only Master volume.
+                */
+               rename_ctl(codec, "Front Playback Volume", "DAC1 Playback Volume");
+               rename_ctl(codec, "Bass Speaker Playback Volume", "DAC2 Playback Volume");
+               break;
+       }
+}
+
 static void alc233_alc662_fixup_lenovo_dual_codecs(struct hda_codec *codec,
                                         const struct hda_fixup *fix,
                                         int action)
@@ -6135,6 +6169,7 @@ enum {
        ALC289_FIXUP_DUAL_SPK,
        ALC294_FIXUP_SPK2_TO_DAC1,
        ALC294_FIXUP_ASUS_DUAL_SPK,
+       ALC285_FIXUP_THINKPAD_X1_GEN7,
        ALC285_FIXUP_THINKPAD_HEADSET_JACK,
        ALC294_FIXUP_ASUS_HPE,
        ALC294_FIXUP_ASUS_COEF_1B,
@@ -7280,11 +7315,17 @@ static const struct hda_fixup alc269_fixups[] = {
                .chained = true,
                .chain_id = ALC294_FIXUP_SPK2_TO_DAC1
        },
+       [ALC285_FIXUP_THINKPAD_X1_GEN7] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc285_fixup_thinkpad_x1_gen7,
+               .chained = true,
+               .chain_id = ALC269_FIXUP_THINKPAD_ACPI
+       },
        [ALC285_FIXUP_THINKPAD_HEADSET_JACK] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_headset_jack,
                .chained = true,
-               .chain_id = ALC285_FIXUP_SPEAKER2_TO_DAC1
+               .chain_id = ALC285_FIXUP_THINKPAD_X1_GEN7
        },
        [ALC294_FIXUP_ASUS_HPE] = {
                .type = HDA_FIXUP_VERBS,
@@ -7694,6 +7735,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC),
        SND_PCI_QUIRK(0x144d, 0xc169, "Samsung Notebook 9 Pen (NP930SBE-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
        SND_PCI_QUIRK(0x144d, 0xc176, "Samsung Notebook 9 Pro (NP930MBE-K04US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
+       SND_PCI_QUIRK(0x144d, 0xc189, "Samsung Galaxy Flex Book (NT950QCG-X716)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
+       SND_PCI_QUIRK(0x144d, 0xc18a, "Samsung Galaxy Book Ion (NP930XCJ-K01US)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
+       SND_PCI_QUIRK(0x144d, 0xc830, "Samsung Galaxy Book Ion (NT950XCJ-X716A)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
        SND_PCI_QUIRK(0x144d, 0xc740, "Samsung Ativ book 8 (NP870Z5G)", ALC269_FIXUP_ATIV_BOOK_8),
        SND_PCI_QUIRK(0x144d, 0xc812, "Samsung Notebook Pen S (NT950SBE-X58)", ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET),
        SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_HEADSET_MIC),
@@ -7955,6 +7999,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
        {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"},
        {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"},
        {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"},
+       {.id = ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET, .name = "alc298-samsung-headphone"},
        {}
 };
 #define ALC225_STANDARD_PINS \
index b4f3002..098c69b 100644 (file)
@@ -1070,9 +1070,9 @@ getmixer(struct cmdif *cif, short num, unsigned short *rval,
        return 0;
 }
 
-static void riptide_handleirq(unsigned long dev_id)
+static void riptide_handleirq(struct tasklet_struct *t)
 {
-       struct snd_riptide *chip = (void *)dev_id;
+       struct snd_riptide *chip = from_tasklet(chip, t, riptide_tq);
        struct cmdif *cif = chip->cif;
        struct snd_pcm_substream *substream[PLAYBACK_SUBSTREAMS + 1];
        struct snd_pcm_runtime *runtime;
@@ -1843,7 +1843,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci,
        chip->received_irqs = 0;
        chip->handled_irqs = 0;
        chip->cif = NULL;
-       tasklet_init(&chip->riptide_tq, riptide_handleirq, (unsigned long)chip);
+       tasklet_setup(&chip->riptide_tq, riptide_handleirq);
 
        if ((chip->res_port =
             request_region(chip->port, 64, "RIPTIDE")) == NULL) {
index 227aece..dda56ec 100644 (file)
@@ -3791,9 +3791,9 @@ static int snd_hdsp_set_defaults(struct hdsp *hdsp)
        return 0;
 }
 
-static void hdsp_midi_tasklet(unsigned long arg)
+static void hdsp_midi_tasklet(struct tasklet_struct *t)
 {
-       struct hdsp *hdsp = (struct hdsp *)arg;
+       struct hdsp *hdsp = from_tasklet(hdsp, t, midi_tasklet);
 
        if (hdsp->midi[0].pending)
                snd_hdsp_midi_input_read (&hdsp->midi[0]);
@@ -5182,7 +5182,7 @@ static int snd_hdsp_create(struct snd_card *card,
 
        spin_lock_init(&hdsp->lock);
 
-       tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp);
+       tasklet_setup(&hdsp->midi_tasklet, hdsp_midi_tasklet);
 
        pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev);
        hdsp->firmware_rev &= 0xff;
index 0fa49f4..572350a 100644 (file)
@@ -2169,9 +2169,9 @@ static int snd_hdspm_create_midi(struct snd_card *card,
 }
 
 
-static void hdspm_midi_tasklet(unsigned long arg)
+static void hdspm_midi_tasklet(struct tasklet_struct *t)
 {
-       struct hdspm *hdspm = (struct hdspm *)arg;
+       struct hdspm *hdspm = from_tasklet(hdspm, t, midi_tasklet);
        int i = 0;
 
        while (i < hdspm->midiPorts) {
@@ -6836,8 +6836,7 @@ static int snd_hdspm_create(struct snd_card *card,
 
        }
 
-       tasklet_init(&hdspm->midi_tasklet,
-                       hdspm_midi_tasklet, (unsigned long) hdspm);
+       tasklet_setup(&hdspm->midi_tasklet, hdspm_midi_tasklet);
 
 
        if (hdspm->io_type != MADIface) {
index b8161a0..58bb49f 100644 (file)
@@ -227,14 +227,14 @@ static int snd_ps3_program_dma(struct snd_ps3_card_info *card,
        switch (filltype) {
        case SND_PS3_DMA_FILLTYPE_SILENT_FIRSTFILL:
                silent = 1;
-               /* intentionally fall thru */
+               fallthrough;
        case SND_PS3_DMA_FILLTYPE_FIRSTFILL:
                ch0_kick_event = PS3_AUDIO_KICK_EVENT_ALWAYS;
                break;
 
        case SND_PS3_DMA_FILLTYPE_SILENT_RUNNING:
                silent = 1;
-               /* intentionally fall thru */
+               fallthrough;
        case SND_PS3_DMA_FILLTYPE_RUNNING:
                ch0_kick_event = PS3_AUDIO_KICK_EVENT_SERIALOUT0_EMPTY;
                break;
index 55815fd..406526e 100644 (file)
@@ -138,7 +138,7 @@ static int acp3x_1015_hw_params(struct snd_pcm_substream *substream,
        srate = params_rate(params);
 
        for_each_rtd_codec_dais(rtd, i, codec_dai) {
-               if (strcmp(codec_dai->component->name, "rt1015-aif"))
+               if (strcmp(codec_dai->name, "rt1015-aif"))
                        continue;
                ret = snd_soc_dai_set_bclk_ratio(codec_dai, 64);
                if (ret < 0)
index 623dfd3..7b14d9a 100644 (file)
@@ -314,40 +314,30 @@ static int acp_pdm_dma_close(struct snd_soc_component *component,
        return 0;
 }
 
-static int acp_pdm_dai_hw_params(struct snd_pcm_substream *substream,
-                                struct snd_pcm_hw_params *params,
-                                struct snd_soc_dai *dai)
+static int acp_pdm_dai_trigger(struct snd_pcm_substream *substream,
+                              int cmd, struct snd_soc_dai *dai)
 {
        struct pdm_stream_instance *rtd;
+       int ret;
+       bool pdm_status;
        unsigned int ch_mask;
 
        rtd = substream->runtime->private_data;
-       switch (params_channels(params)) {
+       ret = 0;
+       switch (substream->runtime->channels) {
        case TWO_CH:
                ch_mask = 0x00;
                break;
        default:
                return -EINVAL;
        }
-       rn_writel(ch_mask, rtd->acp_base + ACP_WOV_PDM_NO_OF_CHANNELS);
-       rn_writel(PDM_DECIMATION_FACTOR, rtd->acp_base +
-                 ACP_WOV_PDM_DECIMATION_FACTOR);
-       return 0;
-}
-
-static int acp_pdm_dai_trigger(struct snd_pcm_substream *substream,
-                              int cmd, struct snd_soc_dai *dai)
-{
-       struct pdm_stream_instance *rtd;
-       int ret;
-       bool pdm_status;
-
-       rtd = substream->runtime->private_data;
-       ret = 0;
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+               rn_writel(ch_mask, rtd->acp_base + ACP_WOV_PDM_NO_OF_CHANNELS);
+               rn_writel(PDM_DECIMATION_FACTOR, rtd->acp_base +
+                         ACP_WOV_PDM_DECIMATION_FACTOR);
                rtd->bytescount = acp_pdm_get_byte_count(rtd,
                                                         substream->stream);
                pdm_status = check_pdm_dma_status(rtd->acp_base);
@@ -369,7 +359,6 @@ static int acp_pdm_dai_trigger(struct snd_pcm_substream *substream,
 }
 
 static struct snd_soc_dai_ops acp_pdm_dai_ops = {
-       .hw_params = acp_pdm_dai_hw_params,
        .trigger   = acp_pdm_dai_trigger,
 };
 
index 3cb6388..04acc18 100644 (file)
@@ -536,7 +536,7 @@ static int mchp_i2s_mcc_hw_params(struct snd_pcm_substream *substream,
                /* cpu is BCLK master */
                mrb |= MCHP_I2SMCC_MRB_CLKSEL_INT;
                set_divs = 1;
-               /* fall through */
+               fallthrough;
        case SND_SOC_DAIFMT_CBM_CFM:
                /* cpu is slave */
                mra |= MCHP_I2SMCC_MRA_MODE_SLAVE;
index c0a28f0..298689a 100644 (file)
@@ -202,7 +202,7 @@ static int jz4770_codec_set_bias_level(struct snd_soc_component *codec,
                                   REG_CR_VIC_SB_SLEEP, REG_CR_VIC_SB_SLEEP);
                regmap_update_bits(regmap, JZ4770_CODEC_REG_CR_VIC,
                                   REG_CR_VIC_SB, REG_CR_VIC_SB);
-       /* fall-through */
+               fallthrough;
        default:
                break;
        }
index 4428c62..3ddd822 100644 (file)
@@ -19,8 +19,8 @@
 
 #define CDC_D_REVISION1                        (0xf000)
 #define CDC_D_PERPH_SUBTYPE            (0xf005)
-#define CDC_D_INT_EN_SET               (0x015)
-#define CDC_D_INT_EN_CLR               (0x016)
+#define CDC_D_INT_EN_SET               (0xf015)
+#define CDC_D_INT_EN_CLR               (0xf016)
 #define MBHC_SWITCH_INT                        BIT(7)
 #define MBHC_MIC_ELECTRICAL_INS_REM_DET        BIT(6)
 #define MBHC_BUTTON_PRESS_DET          BIT(5)
index f0da559..b8845f4 100644 (file)
@@ -401,7 +401,7 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format)
                break;
        case SND_SOC_DAIFMT_DSP_A:
                priv->tdm_offset += 1;
-               /* fall through */
+               fallthrough;
                /* DSP_A uses the same basic config as DSP_B
                 * except we need to shift the TDM output by one BCK cycle
                 */
index 68a3b48..3bce9a1 100644 (file)
@@ -412,8 +412,12 @@ int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
                  struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+       struct wm8994 *control = dev_get_drvdata(component->dev->parent);
        int i;
 
+       if (control->type != WM8958)
+               return 0;
+
        switch (event) {
        case SND_SOC_DAPM_POST_PMU:
        case SND_SOC_DAPM_PRE_PMU:
index 317916c..0623a22 100644 (file)
@@ -151,7 +151,6 @@ static const struct reg_default wm8962_reg[] = {
        { 40, 0x0000 },   /* R40    - SPKOUTL volume */
        { 41, 0x0000 },   /* R41    - SPKOUTR volume */
 
-       { 48, 0x0000 },   /* R48    - Additional control(4) */
        { 49, 0x0010 },   /* R49    - Class D Control 1 */
        { 51, 0x0003 },   /* R51    - Class D Control 2 */
 
@@ -842,6 +841,7 @@ static bool wm8962_readable_register(struct device *dev, unsigned int reg)
        case WM8962_SPKOUTL_VOLUME:
        case WM8962_SPKOUTR_VOLUME:
        case WM8962_THERMAL_SHUTDOWN_STATUS:
+       case WM8962_ADDITIONAL_CONTROL_4:
        case WM8962_CLASS_D_CONTROL_1:
        case WM8962_CLASS_D_CONTROL_2:
        case WM8962_CLOCKING_4:
index a84ae87..038be66 100644 (file)
 #define WM8994_NUM_DRC 3
 #define WM8994_NUM_EQ  3
 
-static struct {
+struct wm8994_reg_mask {
        unsigned int reg;
        unsigned int mask;
-} wm8994_vu_bits[] = {
+};
+
+static struct wm8994_reg_mask wm8994_vu_bits[] = {
        { WM8994_LEFT_LINE_INPUT_1_2_VOLUME, WM8994_IN1_VU },
        { WM8994_RIGHT_LINE_INPUT_1_2_VOLUME, WM8994_IN1_VU },
        { WM8994_LEFT_LINE_INPUT_3_4_VOLUME, WM8994_IN2_VU },
@@ -60,14 +62,10 @@ static struct {
 
        { WM8994_AIF1_DAC1_LEFT_VOLUME, WM8994_AIF1DAC1_VU },
        { WM8994_AIF1_DAC1_RIGHT_VOLUME, WM8994_AIF1DAC1_VU },
-       { WM8994_AIF1_DAC2_LEFT_VOLUME, WM8994_AIF1DAC2_VU },
-       { WM8994_AIF1_DAC2_RIGHT_VOLUME, WM8994_AIF1DAC2_VU },
        { WM8994_AIF2_DAC_LEFT_VOLUME, WM8994_AIF2DAC_VU },
        { WM8994_AIF2_DAC_RIGHT_VOLUME, WM8994_AIF2DAC_VU },
        { WM8994_AIF1_ADC1_LEFT_VOLUME, WM8994_AIF1ADC1_VU },
        { WM8994_AIF1_ADC1_RIGHT_VOLUME, WM8994_AIF1ADC1_VU },
-       { WM8994_AIF1_ADC2_LEFT_VOLUME, WM8994_AIF1ADC2_VU },
-       { WM8994_AIF1_ADC2_RIGHT_VOLUME, WM8994_AIF1ADC2_VU },
        { WM8994_AIF2_ADC_LEFT_VOLUME, WM8994_AIF2ADC_VU },
        { WM8994_AIF2_ADC_RIGHT_VOLUME, WM8994_AIF1ADC2_VU },
        { WM8994_DAC1_LEFT_VOLUME, WM8994_DAC1_VU },
@@ -76,6 +74,14 @@ static struct {
        { WM8994_DAC2_RIGHT_VOLUME, WM8994_DAC2_VU },
 };
 
+/* VU bitfields for ADC2, DAC2 not available on WM1811 */
+static struct wm8994_reg_mask wm8994_adc2_dac2_vu_bits[] = {
+       { WM8994_AIF1_DAC2_LEFT_VOLUME, WM8994_AIF1DAC2_VU },
+       { WM8994_AIF1_DAC2_RIGHT_VOLUME, WM8994_AIF1DAC2_VU },
+       { WM8994_AIF1_ADC2_LEFT_VOLUME, WM8994_AIF1ADC2_VU },
+       { WM8994_AIF1_ADC2_RIGHT_VOLUME, WM8994_AIF1ADC2_VU },
+};
+
 static int wm8994_drc_base[] = {
        WM8994_AIF1_DRC1_1,
        WM8994_AIF1_DRC2_1,
@@ -1030,6 +1036,26 @@ static bool wm8994_check_class_w_digital(struct snd_soc_component *component)
        return true;
 }
 
+static void wm8994_update_vu_bits(struct snd_soc_component *component)
+{
+       struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
+       struct wm8994 *control = wm8994->wm8994;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
+               snd_soc_component_write(component, wm8994_vu_bits[i].reg,
+                                       snd_soc_component_read(component,
+                                                      wm8994_vu_bits[i].reg));
+       if (control->type == WM1811)
+               return;
+
+       for (i = 0; i < ARRAY_SIZE(wm8994_adc2_dac2_vu_bits); i++)
+               snd_soc_component_write(component,
+                               wm8994_adc2_dac2_vu_bits[i].reg,
+                               snd_soc_component_read(component,
+                                       wm8994_adc2_dac2_vu_bits[i].reg));
+}
+
 static int aif_mclk_set(struct snd_soc_component *component, int aif, bool enable)
 {
        struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
@@ -1076,7 +1102,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
        struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
        struct wm8994 *control = wm8994->wm8994;
        int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
-       int ret, i;
+       int ret;
        int dac;
        int adc;
        int val;
@@ -1144,10 +1170,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
                break;
 
        case SND_SOC_DAPM_POST_PMU:
-               for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
-                       snd_soc_component_write(component, wm8994_vu_bits[i].reg,
-                                     snd_soc_component_read(component,
-                                                  wm8994_vu_bits[i].reg));
+               wm8994_update_vu_bits(component);
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
@@ -1181,7 +1204,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
                      struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
-       int ret, i;
+       int ret;
        int dac;
        int adc;
        int val;
@@ -1237,10 +1260,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
                break;
 
        case SND_SOC_DAPM_POST_PMU:
-               for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
-                       snd_soc_component_write(component, wm8994_vu_bits[i].reg,
-                                     snd_soc_component_read(component,
-                                                  wm8994_vu_bits[i].reg));
+               wm8994_update_vu_bits(component);
                break;
 
        case SND_SOC_DAPM_PRE_PMD:
@@ -4346,6 +4366,14 @@ static int wm8994_component_probe(struct snd_soc_component *component)
                                    wm8994_vu_bits[i].mask,
                                    wm8994_vu_bits[i].mask);
 
+       if (control->type != WM1811) {
+               for (i = 0; i < ARRAY_SIZE(wm8994_adc2_dac2_vu_bits); i++)
+                       snd_soc_component_update_bits(component,
+                                       wm8994_adc2_dac2_vu_bits[i].reg,
+                                       wm8994_adc2_dac2_vu_bits[i].mask,
+                                       wm8994_adc2_dac2_vu_bits[i].mask);
+       }
+
        /* Set the low bit of the 3D stereo depth so TLV matches */
        snd_soc_component_update_bits(component, WM8994_AIF1_DAC1_FILTERS_2,
                            1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT,
index de136c0..52adedc 100644 (file)
@@ -73,6 +73,7 @@ struct cpu_priv {
  * @codec_priv: CODEC private data
  * @cpu_priv: CPU private data
  * @card: ASoC card structure
+ * @streams: Mask of current active streams
  * @sample_rate: Current sample rate
  * @sample_format: Current sample format
  * @asrc_rate: ASRC sample rate used by Back-Ends
@@ -89,6 +90,7 @@ struct fsl_asoc_card_priv {
        struct codec_priv codec_priv;
        struct cpu_priv cpu_priv;
        struct snd_soc_card card;
+       u8 streams;
        u32 sample_rate;
        snd_pcm_format_t sample_format;
        u32 asrc_rate;
@@ -151,21 +153,17 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
        struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
        struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
        bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
+       struct codec_priv *codec_priv = &priv->codec_priv;
        struct cpu_priv *cpu_priv = &priv->cpu_priv;
        struct device *dev = rtd->card->dev;
+       unsigned int pll_out;
        int ret;
 
        priv->sample_rate = params_rate(params);
        priv->sample_format = params_format(params);
+       priv->streams |= BIT(substream->stream);
 
-       /*
-        * If codec-dai is DAI Master and all configurations are already in the
-        * set_bias_level(), bypass the remaining settings in hw_params().
-        * Note: (dai_fmt & CBM_CFM) includes CBM_CFM and CBM_CFS.
-        */
-       if ((priv->card.set_bias_level &&
-            priv->dai_fmt & SND_SOC_DAIFMT_CBM_CFM) ||
-           fsl_asoc_card_is_ac97(priv))
+       if (fsl_asoc_card_is_ac97(priv))
                return 0;
 
        /* Specific configurations of DAIs starts from here */
@@ -174,7 +172,7 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
                                     cpu_priv->sysclk_dir[tx]);
        if (ret && ret != -ENOTSUPP) {
                dev_err(dev, "failed to set sysclk for cpu dai\n");
-               return ret;
+               goto fail;
        }
 
        if (cpu_priv->slot_width) {
@@ -182,6 +180,68 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
                                               cpu_priv->slot_width);
                if (ret && ret != -ENOTSUPP) {
                        dev_err(dev, "failed to set TDM slot for cpu dai\n");
+                       goto fail;
+               }
+       }
+
+       /* Specific configuration for PLL */
+       if (codec_priv->pll_id && codec_priv->fll_id) {
+               if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
+                       pll_out = priv->sample_rate * 384;
+               else
+                       pll_out = priv->sample_rate * 256;
+
+               ret = snd_soc_dai_set_pll(asoc_rtd_to_codec(rtd, 0),
+                                         codec_priv->pll_id,
+                                         codec_priv->mclk_id,
+                                         codec_priv->mclk_freq, pll_out);
+               if (ret) {
+                       dev_err(dev, "failed to start FLL: %d\n", ret);
+                       goto fail;
+               }
+
+               ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0),
+                                            codec_priv->fll_id,
+                                            pll_out, SND_SOC_CLOCK_IN);
+
+               if (ret && ret != -ENOTSUPP) {
+                       dev_err(dev, "failed to set SYSCLK: %d\n", ret);
+                       goto fail;
+               }
+       }
+
+       return 0;
+
+fail:
+       priv->streams &= ~BIT(substream->stream);
+       return ret;
+}
+
+static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream)
+{
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+       struct codec_priv *codec_priv = &priv->codec_priv;
+       struct device *dev = rtd->card->dev;
+       int ret;
+
+       priv->streams &= ~BIT(substream->stream);
+
+       if (!priv->streams && codec_priv->pll_id && codec_priv->fll_id) {
+               /* Force freq to be 0 to avoid error message in codec */
+               ret = snd_soc_dai_set_sysclk(asoc_rtd_to_codec(rtd, 0),
+                                            codec_priv->mclk_id,
+                                            0,
+                                            SND_SOC_CLOCK_IN);
+               if (ret) {
+                       dev_err(dev, "failed to switch away from FLL: %d\n", ret);
+                       return ret;
+               }
+
+               ret = snd_soc_dai_set_pll(asoc_rtd_to_codec(rtd, 0),
+                                         codec_priv->pll_id, 0, 0, 0);
+               if (ret && ret != -ENOTSUPP) {
+                       dev_err(dev, "failed to stop FLL: %d\n", ret);
                        return ret;
                }
        }
@@ -191,6 +251,7 @@ static int fsl_asoc_card_hw_params(struct snd_pcm_substream *substream,
 
 static const struct snd_soc_ops fsl_asoc_card_ops = {
        .hw_params = fsl_asoc_card_hw_params,
+       .hw_free = fsl_asoc_card_hw_free,
 };
 
 static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
@@ -254,75 +315,6 @@ static struct snd_soc_dai_link fsl_asoc_card_dai[] = {
        },
 };
 
-static int fsl_asoc_card_set_bias_level(struct snd_soc_card *card,
-                                       struct snd_soc_dapm_context *dapm,
-                                       enum snd_soc_bias_level level)
-{
-       struct fsl_asoc_card_priv *priv = snd_soc_card_get_drvdata(card);
-       struct snd_soc_pcm_runtime *rtd;
-       struct snd_soc_dai *codec_dai;
-       struct codec_priv *codec_priv = &priv->codec_priv;
-       struct device *dev = card->dev;
-       unsigned int pll_out;
-       int ret;
-
-       rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
-       codec_dai = asoc_rtd_to_codec(rtd, 0);
-       if (dapm->dev != codec_dai->dev)
-               return 0;
-
-       switch (level) {
-       case SND_SOC_BIAS_PREPARE:
-               if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
-                       break;
-
-               if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
-                       pll_out = priv->sample_rate * 384;
-               else
-                       pll_out = priv->sample_rate * 256;
-
-               ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id,
-                                         codec_priv->mclk_id,
-                                         codec_priv->mclk_freq, pll_out);
-               if (ret) {
-                       dev_err(dev, "failed to start FLL: %d\n", ret);
-                       return ret;
-               }
-
-               ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->fll_id,
-                                            pll_out, SND_SOC_CLOCK_IN);
-               if (ret && ret != -ENOTSUPP) {
-                       dev_err(dev, "failed to set SYSCLK: %d\n", ret);
-                       return ret;
-               }
-               break;
-
-       case SND_SOC_BIAS_STANDBY:
-               if (dapm->bias_level != SND_SOC_BIAS_PREPARE)
-                       break;
-
-               ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->mclk_id,
-                                            codec_priv->mclk_freq,
-                                            SND_SOC_CLOCK_IN);
-               if (ret && ret != -ENOTSUPP) {
-                       dev_err(dev, "failed to switch away from FLL: %d\n", ret);
-                       return ret;
-               }
-
-               ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id, 0, 0, 0);
-               if (ret) {
-                       dev_err(dev, "failed to stop FLL: %d\n", ret);
-                       return ret;
-               }
-               break;
-
-       default:
-               break;
-       }
-
-       return 0;
-}
-
 static int fsl_asoc_card_audmux_init(struct device_node *np,
                                     struct fsl_asoc_card_priv *priv)
 {
@@ -611,7 +603,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
        /* Diversify the card configurations */
        if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) {
                codec_dai_name = "cs42888";
-               priv->card.set_bias_level = NULL;
                priv->cpu_priv.sysclk_freq[TX] = priv->codec_priv.mclk_freq;
                priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq;
                priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT;
@@ -628,26 +619,22 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
                priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
        } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) {
                codec_dai_name = "wm8962";
-               priv->card.set_bias_level = fsl_asoc_card_set_bias_level;
                priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK;
                priv->codec_priv.fll_id = WM8962_SYSCLK_FLL;
                priv->codec_priv.pll_id = WM8962_FLL;
                priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
        } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8960")) {
                codec_dai_name = "wm8960-hifi";
-               priv->card.set_bias_level = fsl_asoc_card_set_bias_level;
                priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO;
                priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO;
                priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
        } else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) {
                codec_dai_name = "ac97-hifi";
-               priv->card.set_bias_level = NULL;
                priv->dai_fmt = SND_SOC_DAIFMT_AC97;
                priv->card.dapm_routes = audio_map_ac97;
                priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_ac97);
        } else if (of_device_is_compatible(np, "fsl,imx-audio-mqs")) {
                codec_dai_name = "fsl-mqs-dai";
-               priv->card.set_bias_level = NULL;
                priv->dai_fmt = SND_SOC_DAIFMT_LEFT_J |
                                SND_SOC_DAIFMT_CBS_CFS |
                                SND_SOC_DAIFMT_NB_NF;
@@ -657,7 +644,6 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
                priv->card.num_dapm_routes = ARRAY_SIZE(audio_map_tx);
        } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8524")) {
                codec_dai_name = "wm8524-hifi";
-               priv->card.set_bias_level = NULL;
                priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
                priv->dai_link[1].dpcm_capture = 0;
                priv->dai_link[2].dpcm_capture = 0;
index 4ae3609..79b861a 100644 (file)
@@ -708,9 +708,9 @@ static void fsl_esai_trigger_stop(struct fsl_esai *esai_priv, bool tx)
                           ESAI_xFCR_xFR, 0);
 }
 
-static void fsl_esai_hw_reset(unsigned long arg)
+static void fsl_esai_hw_reset(struct tasklet_struct *t)
 {
-       struct fsl_esai *esai_priv = (struct fsl_esai *)arg;
+       struct fsl_esai *esai_priv = from_tasklet(esai_priv, t, task);
        bool tx = true, rx = false, enabled[2];
        unsigned long lock_flags;
        u32 tfcr, rfcr;
@@ -1070,8 +1070,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
                return ret;
        }
 
-       tasklet_init(&esai_priv->task, fsl_esai_hw_reset,
-                    (unsigned long)esai_priv);
+       tasklet_setup(&esai_priv->task, fsl_esai_hw_reset);
 
        pm_runtime_enable(&pdev->dev);
 
index d8b9c65..404be27 100644 (file)
@@ -898,7 +898,7 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt)
                                        "missing baudclk for master mode\n");
                                return -EINVAL;
                        }
-                       /* fall through */
+                       fallthrough;
                case SND_SOC_DAIFMT_CBM_CFS:
                        ssi->i2s_net |= SSI_SCR_I2S_MODE_MASTER;
                        break;
index 9e4f66b..2319848 100644 (file)
@@ -339,7 +339,6 @@ static int psc_dma_new(struct snd_soc_component *component,
 static void psc_dma_free(struct snd_soc_component *component,
                         struct snd_pcm *pcm)
 {
-       struct snd_soc_pcm_runtime *rtd = pcm->private_data;
        struct snd_pcm_substream *substream;
        int stream;
 
index fd5dcd6..907f5f1 100644 (file)
@@ -261,13 +261,13 @@ static int hi6210_i2s_hw_params(struct snd_pcm_substream *substream,
        switch (params_format(params)) {
        case SNDRV_PCM_FORMAT_U16_LE:
                signed_data = HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT;
-               /* fall through */
+               fallthrough;
        case SNDRV_PCM_FORMAT_S16_LE:
                bits = HII2S_BITS_16;
                break;
        case SNDRV_PCM_FORMAT_U24_LE:
                signed_data = HII2S_I2S_CFG__S2_CODEC_DATA_FORMAT;
-               /* fall through */
+               fallthrough;
        case SNDRV_PCM_FORMAT_S24_LE:
                bits = HII2S_BITS_24;
                break;
index 49b9f18..b1cac7a 100644 (file)
@@ -331,7 +331,7 @@ static int sst_media_open(struct snd_pcm_substream *substream,
 
        ret_val = power_up_sst(stream);
        if (ret_val < 0)
-               return ret_val;
+               goto out_power_up;
 
        /* Make sure, that the period size is always even */
        snd_pcm_hw_constraint_step(substream->runtime, 0,
@@ -340,8 +340,9 @@ static int sst_media_open(struct snd_pcm_substream *substream,
        return snd_pcm_hw_constraint_integer(runtime,
                         SNDRV_PCM_HW_PARAM_PERIODS);
 out_ops:
-       kfree(stream);
        mutex_unlock(&sst_lock);
+out_power_up:
+       kfree(stream);
        return ret_val;
 }
 
index 54a66cc..d2cda33 100644 (file)
@@ -181,7 +181,7 @@ static int sst_byt_pcm_trigger(struct snd_soc_component *component,
                break;
        case SNDRV_PCM_TRIGGER_SUSPEND:
                pdata->restore_stream = false;
-               /* fallthrough */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                sst_byt_stream_pause(byt, pcm_data->stream);
                break;
index 414ae4b..7ae34b4 100644 (file)
@@ -573,7 +573,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
                        break;
                default:
                        dev_err(dev, "get speaker GPIO failed: %d\n", ret);
-                       /* fall through */
+                       fallthrough;
                case -EPROBE_DEFER:
                        return ret;
                }
index 4e28975..688b5e0 100644 (file)
@@ -1009,7 +1009,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
                        default:
                                dev_err(&pdev->dev, "Failed to get ext-amp-enable GPIO: %d\n",
                                        ret_val);
-                               /* fall through */
+                               fallthrough;
                        case -EPROBE_DEFER:
                                put_device(codec_dev);
                                return ret_val;
@@ -1029,7 +1029,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
                        default:
                                dev_err(&pdev->dev, "Failed to get hp-detect GPIO: %d\n",
                                        ret_val);
-                               /* fall through */
+                               fallthrough;
                        case -EPROBE_DEFER:
                                put_device(codec_dev);
                                return ret_val;
index 5dee55e..bbe8d78 100644 (file)
@@ -488,7 +488,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
                                                        stream->lpib);
                        snd_hdac_ext_stream_set_lpib(stream, stream->lpib);
                }
-               /* fall through */
+               fallthrough;
 
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
index 36df309..c8664ab 100644 (file)
@@ -58,17 +58,17 @@ int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask,
        switch (slot_width) {
        case 0:
                slot_width = 32;
-               /* Fall-through */
+               fallthrough;
        case 32:
                fmt |= SNDRV_PCM_FMTBIT_S32_LE;
-               /* Fall-through */
+               fallthrough;
        case 24:
                fmt |= SNDRV_PCM_FMTBIT_S24_LE;
                fmt |= SNDRV_PCM_FMTBIT_S20_LE;
-               /* Fall-through */
+               fallthrough;
        case 16:
                fmt |= SNDRV_PCM_FMTBIT_S16_LE;
-               /* Fall-through */
+               fallthrough;
        case 8:
                fmt |= SNDRV_PCM_FMTBIT_S8;
                break;
@@ -133,7 +133,7 @@ static int axg_tdm_iface_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
        case SND_SOC_DAIFMT_CBS_CFM:
        case SND_SOC_DAIFMT_CBM_CFS:
                dev_err(dai->dev, "only CBS_CFS and CBM_CFM are supported\n");
-               /* Fall-through */
+               fallthrough;
        default:
                return -EINVAL;
        }
index d1e09ad..c4e7307 100644 (file)
@@ -488,7 +488,7 @@ static int pxa_ssp_configure_dai_fmt(struct ssp_priv *priv)
 
        case SND_SOC_DAIFMT_DSP_A:
                sspsp |= SSPSP_FSRT;
-               /* fall through */
+               fallthrough;
        case SND_SOC_DAIFMT_DSP_B:
                sscr0 |= SSCR0_MOD | SSCR0_PSP;
                sscr1 |= SSCR1_TRAIL | SSCR1_RWOT;
index 2a5302f..0168af8 100644 (file)
@@ -1150,206 +1150,206 @@ static int q6afe_of_xlate_dai_name(struct snd_soc_component *component,
 }
 
 static const struct snd_soc_dapm_widget q6afe_dai_widgets[] = {
-       SND_SOC_DAPM_AIF_IN("HDMI_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_0_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_1_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_2_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_3_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_4_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_5_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_IN("SLIMBUS_6_RX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_0_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_1_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_2_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_3_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_5_TX", NULL, 0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("SLIMBUS_6_TX", NULL, 0, 0, 0, 0),
+       SND_SOC_DAPM_AIF_IN("HDMI_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_0_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_1_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_2_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_3_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_4_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_5_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_IN("SLIMBUS_6_RX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_0_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_1_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_2_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_3_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_4_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_5_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("SLIMBUS_6_TX", NULL, 0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_MI2S_RX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_MI2S_TX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_MI2S_RX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_MI2S_TX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_MI2S_RX", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_MI2S_TX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_MI2S_RX_SD1",
                        "Secondary MI2S Playback SD1",
-                       0, 0, 0, 0),
+                       0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRI_MI2S_RX", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRI_MI2S_TX", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
 
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_0", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_1", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_2", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_3", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_4", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_5", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_6", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("PRIMARY_TDM_RX_7", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_0", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_1", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_2", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_3", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_4", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_5", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_6", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("PRIMARY_TDM_TX_7", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
 
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_0", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_1", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_2", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_3", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_4", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_5", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_6", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("SEC_TDM_RX_7", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_0", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_1", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_2", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_3", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_4", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_5", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_6", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("SEC_TDM_TX_7", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
 
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_0", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_1", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_2", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_3", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_4", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_5", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_6", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("TERT_TDM_RX_7", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_0", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_1", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_2", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_3", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_4", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_5", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_6", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("TERT_TDM_TX_7", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
 
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_0", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_1", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_2", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_3", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_4", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_5", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_6", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUAT_TDM_RX_7", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_0", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_1", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_2", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_3", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_4", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_5", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_6", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUAT_TDM_TX_7", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
 
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_0", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_1", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_2", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_3", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_4", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_5", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_6", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_IN("QUIN_TDM_RX_7", NULL,
-                            0, 0, 0, 0),
+                            0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_0", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_1", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_2", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_3", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_4", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_5", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_6", NULL,
-                                               0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
        SND_SOC_DAPM_AIF_OUT("QUIN_TDM_TX_7", NULL,
-                                               0, 0, 0, 0),
-       SND_SOC_DAPM_AIF_OUT("DISPLAY_PORT_RX", "NULL", 0, 0, 0, 0),
+                                               0, SND_SOC_NOPM, 0, 0),
+       SND_SOC_DAPM_AIF_OUT("DISPLAY_PORT_RX", "NULL", 0, SND_SOC_NOPM, 0, 0),
 };
 
 static const struct snd_soc_component_driver q6afe_dai_component = {
index eaa95b5..25d23e0 100644 (file)
@@ -973,6 +973,20 @@ static int msm_routing_probe(struct snd_soc_component *c)
        return 0;
 }
 
+static unsigned int q6routing_reg_read(struct snd_soc_component *component,
+                                      unsigned int reg)
+{
+       /* default value */
+       return 0;
+}
+
+static int q6routing_reg_write(struct snd_soc_component *component,
+                              unsigned int reg, unsigned int val)
+{
+       /* dummy */
+       return 0;
+}
+
 static const struct snd_soc_component_driver msm_soc_routing_component = {
        .probe = msm_routing_probe,
        .name = DRV_NAME,
@@ -981,6 +995,8 @@ static const struct snd_soc_component_driver msm_soc_routing_component = {
        .num_dapm_widgets = ARRAY_SIZE(msm_qdsp6_widgets),
        .dapm_routes = intercon,
        .num_dapm_routes = ARRAY_SIZE(intercon),
+       .read = q6routing_reg_read,
+       .write = q6routing_reg_write,
 };
 
 static int q6pcm_routing_probe(struct platform_device *pdev)
index 1707414..5adb293 100644 (file)
@@ -229,13 +229,13 @@ static int rockchip_pdm_hw_params(struct snd_pcm_substream *substream,
        switch (params_channels(params)) {
        case 8:
                val |= PDM_PATH3_EN;
-               /* fallthrough */
+               fallthrough;
        case 6:
                val |= PDM_PATH2_EN;
-               /* fallthrough */
+               fallthrough;
        case 4:
                val |= PDM_PATH1_EN;
-               /* fallthrough */
+               fallthrough;
        case 2:
                val |= PDM_PATH0_EN;
                break;
index 80ecb5c..df53d4e 100644 (file)
@@ -733,7 +733,7 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
        switch (params_channels(params)) {
        case 6:
                val |= MOD_DC2_EN;
-               /* Fall through */
+               fallthrough;
        case 4:
                val |= MOD_DC1_EN;
                break;
index bd9de77..50fc781 100644 (file)
@@ -198,9 +198,9 @@ static int siu_pcm_rd_set(struct siu_port *port_info,
        return 0;
 }
 
-static void siu_io_tasklet(unsigned long data)
+static void siu_io_tasklet(struct tasklet_struct *t)
 {
-       struct siu_stream *siu_stream = (struct siu_stream *)data;
+       struct siu_stream *siu_stream = from_tasklet(siu_stream, t, tasklet);
        struct snd_pcm_substream *substream = siu_stream->substream;
        struct device *dev = substream->pcm->card->dev;
        struct snd_pcm_runtime *rt = substream->runtime;
@@ -520,10 +520,8 @@ static int siu_pcm_new(struct snd_soc_component *component,
                (*port_info)->pcm = pcm;
 
                /* IO tasklets */
-               tasklet_init(&(*port_info)->playback.tasklet, siu_io_tasklet,
-                            (unsigned long)&(*port_info)->playback);
-               tasklet_init(&(*port_info)->capture.tasklet, siu_io_tasklet,
-                            (unsigned long)&(*port_info)->capture);
+               tasklet_setup(&(*port_info)->playback.tasklet, siu_io_tasklet);
+               tasklet_setup(&(*port_info)->capture.tasklet, siu_io_tasklet);
        }
 
        dev_info(card->dev, "SuperH SIU driver initialized.\n");
index f0b4f4b..5504b92 100644 (file)
@@ -406,7 +406,7 @@ static unsigned int soc_component_read_no_lock(
                ret = -EIO;
 
        if (ret < 0)
-               soc_component_ret(component, ret);
+               return soc_component_ret(component, ret);
 
        return val;
 }
index 2fe1b2e..663e383 100644 (file)
@@ -618,7 +618,7 @@ int snd_soc_suspend(struct device *dev)
                                                "ASoC: idle_bias_off CODEC on over suspend\n");
                                        break;
                                }
-                               /* fall through */
+                               fallthrough;
 
                        case SND_SOC_BIAS_OFF:
                                snd_soc_component_suspend(component);
index cee9986..5b60379 100644 (file)
@@ -1057,7 +1057,7 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count,
                                        ec->hdr.name);
                                goto err_denum;
                        }
-                       /* fall through */
+                       fallthrough;
                case SND_SOC_TPLG_CTL_ENUM:
                case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE:
                case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT:
@@ -1445,7 +1445,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create(
                                        ec->hdr.name);
                                goto err_se;
                        }
-                       /* fall through */
+                       fallthrough;
                case SND_SOC_TPLG_CTL_ENUM:
                case SND_SOC_TPLG_DAPM_CTL_ENUM_DOUBLE:
                case SND_SOC_TPLG_DAPM_CTL_ENUM_VIRT:
index df1c699..c6cb8c2 100644 (file)
@@ -310,7 +310,7 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
                        return ret;
                }
 
-               /* fallthrough */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                snd_hdac_ext_link_stream_start(link_dev);
@@ -333,7 +333,7 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream,
 
                link_dev->link_prepared = 0;
 
-               /* fallthrough */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                snd_hdac_ext_link_stream_clear(link_dev);
                break;
index d730e43..71c3f29 100644 (file)
@@ -361,7 +361,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
                        return ret;
                }
 
-               /* fallthrough */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_START:
                if (spcm->stream[substream->stream].suspend_ignored) {
                        /*
@@ -386,7 +386,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component,
                        spcm->stream[substream->stream].suspend_ignored = true;
                        return 0;
                }
-               /* fallthrough */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_STOP:
                stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP;
                ipc_first = true;
index fe71171..0cbe31e 100644 (file)
@@ -71,7 +71,7 @@ static int tegra186_dspk_put_control(struct snd_kcontrol *kcontrol,
        return 0;
 }
 
-static int tegra186_dspk_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra186_dspk_runtime_suspend(struct device *dev)
 {
        struct tegra186_dspk *dspk = dev_get_drvdata(dev);
 
@@ -83,7 +83,7 @@ static int tegra186_dspk_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int tegra186_dspk_runtime_resume(struct device *dev)
+static int __maybe_unused tegra186_dspk_runtime_resume(struct device *dev)
 {
        struct tegra186_dspk *dspk = dev_get_drvdata(dev);
        int err;
index 4894e8e..1268046 100644 (file)
@@ -219,7 +219,7 @@ static const struct regmap_config tegra186_admaif_regmap_config = {
        .cache_type             = REGCACHE_FLAT,
 };
 
-static int tegra_admaif_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra_admaif_runtime_suspend(struct device *dev)
 {
        struct tegra_admaif *admaif = dev_get_drvdata(dev);
 
@@ -229,7 +229,7 @@ static int tegra_admaif_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int tegra_admaif_runtime_resume(struct device *dev)
+static int __maybe_unused tegra_admaif_runtime_resume(struct device *dev)
 {
        struct tegra_admaif *admaif = dev_get_drvdata(dev);
 
index 5123a96..66287a7 100644 (file)
@@ -564,7 +564,7 @@ static const struct of_device_id tegra_ahub_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_ahub_of_match);
 
-static int tegra_ahub_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra_ahub_runtime_suspend(struct device *dev)
 {
        struct tegra_ahub *ahub = dev_get_drvdata(dev);
 
@@ -576,7 +576,7 @@ static int tegra_ahub_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int tegra_ahub_runtime_resume(struct device *dev)
+static int __maybe_unused tegra_ahub_runtime_resume(struct device *dev)
 {
        struct tegra_ahub *ahub = dev_get_drvdata(dev);
        int err;
index d682414..a661f40 100644 (file)
@@ -40,7 +40,7 @@ static const struct reg_default tegra210_dmic_reg_defaults[] = {
        { TEGRA210_DMIC_LP_BIQUAD_1_COEF_4, 0x0 },
 };
 
-static int tegra210_dmic_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra210_dmic_runtime_suspend(struct device *dev)
 {
        struct tegra210_dmic *dmic = dev_get_drvdata(dev);
 
@@ -52,7 +52,7 @@ static int tegra210_dmic_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int tegra210_dmic_runtime_resume(struct device *dev)
+static int __maybe_unused tegra210_dmic_runtime_resume(struct device *dev)
 {
        struct tegra210_dmic *dmic = dev_get_drvdata(dev);
        int err;
index 7220921..a383bd5 100644 (file)
@@ -164,7 +164,7 @@ static int tegra210_i2s_init(struct snd_soc_dapm_widget *w,
        return tegra210_i2s_sw_reset(compnt, is_playback);
 }
 
-static int tegra210_i2s_runtime_suspend(struct device *dev)
+static int __maybe_unused tegra210_i2s_runtime_suspend(struct device *dev)
 {
        struct tegra210_i2s *i2s = dev_get_drvdata(dev);
 
@@ -176,7 +176,7 @@ static int tegra210_i2s_runtime_suspend(struct device *dev)
        return 0;
 }
 
-static int tegra210_i2s_runtime_resume(struct device *dev)
+static int __maybe_unused tegra210_i2s_runtime_resume(struct device *dev)
 {
        struct tegra210_i2s *i2s = dev_get_drvdata(dev);
        int err;
index d89b5c9..dd34504 100644 (file)
@@ -289,7 +289,7 @@ static int davinci_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai,
                 * rate is lowered.
                 */
                inv_fs = true;
-               /* fall through */
+               fallthrough;
        case SND_SOC_DAIFMT_DSP_A:
                dev->mode = MOD_DSP_A;
                break;
index 2802a33..ed217b3 100644 (file)
@@ -46,7 +46,7 @@ static void n810_ext_control(struct snd_soc_dapm_context *dapm)
        switch (n810_jack_func) {
        case N810_JACK_HS:
                line1l = 1;
-               /* fall through */
+               fallthrough;
        case N810_JACK_HP:
                hp = 1;
                break;
index 01abf1b..a26588e 100644 (file)
@@ -203,10 +203,10 @@ static int omap_dmic_dai_hw_params(struct snd_pcm_substream *substream,
        switch (channels) {
        case 6:
                dmic->ch_enabled |= OMAP_DMIC_UP3_ENABLE;
-               /* fall through */
+               fallthrough;
        case 4:
                dmic->ch_enabled |= OMAP_DMIC_UP2_ENABLE;
-               /* fall through */
+               fallthrough;
        case 2:
                dmic->ch_enabled |= OMAP_DMIC_UP1_ENABLE;
                break;
index d482b62..fafb299 100644 (file)
@@ -309,19 +309,19 @@ static int omap_mcpdm_dai_hw_params(struct snd_pcm_substream *substream,
                        /* up to 3 channels for capture */
                        return -EINVAL;
                link_mask |= 1 << 4;
-               /* fall through */
+               fallthrough;
        case 4:
                if (stream == SNDRV_PCM_STREAM_CAPTURE)
                        /* up to 3 channels for capture */
                        return -EINVAL;
                link_mask |= 1 << 3;
-               /* fall through */
+               fallthrough;
        case 3:
                link_mask |= 1 << 2;
-               /* fall through */
+               fallthrough;
        case 2:
                link_mask |= 1 << 1;
-               /* fall through */
+               fallthrough;
        case 1:
                link_mask |= 1 << 0;
                break;
index 2176a95..a2629cc 100644 (file)
@@ -55,7 +55,7 @@ static void rx51_ext_control(struct snd_soc_dapm_context *dapm)
                break;
        case RX51_JACK_HS:
                hs = 1;
-               /* fall through */
+               fallthrough;
        case RX51_JACK_HP:
                hp = 1;
                break;
index 4b1cd4d..939b33e 100644 (file)
@@ -134,9 +134,9 @@ txx9aclc_dma_submit(struct txx9aclc_dmadata *dmadata, dma_addr_t buf_dma_addr)
 
 #define NR_DMA_CHAIN           2
 
-static void txx9aclc_dma_tasklet(unsigned long data)
+static void txx9aclc_dma_tasklet(struct tasklet_struct *t)
 {
-       struct txx9aclc_dmadata *dmadata = (struct txx9aclc_dmadata *)data;
+       struct txx9aclc_dmadata *dmadata = from_tasklet(dmadata, t, tasklet);
        struct dma_chan *chan = dmadata->dma_chan;
        struct dma_async_tx_descriptor *desc;
        struct snd_pcm_substream *substream = dmadata->substream;
@@ -352,8 +352,7 @@ static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev,
                        "playback" : "capture");
                return -EBUSY;
        }
-       tasklet_init(&dmadata->tasklet, txx9aclc_dma_tasklet,
-                    (unsigned long)dmadata);
+       tasklet_setup(&dmadata->tasklet, txx9aclc_dma_tasklet);
        return 0;
 }
 
index 568cde6..1c1a44e 100644 (file)
@@ -294,7 +294,7 @@ static int zx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
                        zx_i2s_rx_dma_en(zx_i2s->reg_base, true);
                else
                        zx_i2s_tx_dma_en(zx_i2s->reg_base, true);
-       /* fall thru */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                if (capture)
@@ -308,7 +308,7 @@ static int zx_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
                        zx_i2s_rx_dma_en(zx_i2s->reg_base, false);
                else
                        zx_i2s_tx_dma_en(zx_i2s->reg_base, false);
-       /* fall thru */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_SUSPEND:
        case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
                if (capture)
index a3a07c0..b4168bd 100644 (file)
@@ -218,7 +218,7 @@ static int zx_spdif_trigger(struct snd_pcm_substream *substream, int cmd,
                val = readl_relaxed(zx_spdif->reg_base + ZX_FIFOCTRL);
                val |= ZX_FIFOCTRL_TX_FIFO_RST;
                writel_relaxed(val, zx_spdif->reg_base + ZX_FIFOCTRL);
-       /* fall thru */
+               fallthrough;
        case SNDRV_PCM_TRIGGER_RESUME:
        case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
                zx_spdif_cfg_tx(zx_spdif->reg_base, true);
index df639fe..e8287a0 100644 (file)
@@ -344,10 +344,9 @@ static void snd_usbmidi_do_output(struct snd_usb_midi_out_endpoint *ep)
        spin_unlock_irqrestore(&ep->buffer_lock, flags);
 }
 
-static void snd_usbmidi_out_tasklet(unsigned long data)
+static void snd_usbmidi_out_tasklet(struct tasklet_struct *t)
 {
-       struct snd_usb_midi_out_endpoint *ep =
-               (struct snd_usb_midi_out_endpoint *) data;
+       struct snd_usb_midi_out_endpoint *ep = from_tasklet(ep, t, tasklet);
 
        snd_usbmidi_do_output(ep);
 }
@@ -1441,7 +1440,7 @@ static int snd_usbmidi_out_endpoint_create(struct snd_usb_midi *umidi,
        }
 
        spin_lock_init(&ep->buffer_lock);
-       tasklet_init(&ep->tasklet, snd_usbmidi_out_tasklet, (unsigned long)ep);
+       tasklet_setup(&ep->tasklet, snd_usbmidi_out_tasklet);
        init_waitqueue_head(&ep->drain_wait);
 
        for (i = 0; i < 0x10; ++i)
index 884e740..3b2dce1 100644 (file)
@@ -247,9 +247,9 @@ static inline void add_with_wraparound(struct ua101 *ua,
                *value -= ua->playback.queue_length;
 }
 
-static void playback_tasklet(unsigned long data)
+static void playback_tasklet(struct tasklet_struct *t)
 {
-       struct ua101 *ua = (void *)data;
+       struct ua101 *ua = from_tasklet(ua, t, playback_tasklet);
        unsigned long flags;
        unsigned int frames;
        struct ua101_urb *urb;
@@ -1218,8 +1218,7 @@ static int ua101_probe(struct usb_interface *interface,
        spin_lock_init(&ua->lock);
        mutex_init(&ua->mutex);
        INIT_LIST_HEAD(&ua->ready_playback_urbs);
-       tasklet_init(&ua->playback_tasklet,
-                    playback_tasklet, (unsigned long)ua);
+       tasklet_setup(&ua->playback_tasklet, playback_tasklet);
        init_waitqueue_head(&ua->alsa_capture_wait);
        init_waitqueue_head(&ua->rate_feedback_wait);
        init_waitqueue_head(&ua->alsa_playback_wait);
index 6b0f3a8..81e987e 100644 (file)
@@ -2371,7 +2371,7 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
        int num_ins;
        struct usb_mixer_elem_info *cval;
        struct snd_kcontrol *kctl;
-       int i, err, nameid, type, len;
+       int i, err, nameid, type, len, val;
        const struct procunit_info *info;
        const struct procunit_value_info *valinfo;
        const struct usbmix_name_map *map;
@@ -2474,6 +2474,12 @@ static int build_audio_procunit(struct mixer_build *state, int unitid,
                        break;
                }
 
+               err = get_cur_ctl_value(cval, cval->control << 8, &val);
+               if (err < 0) {
+                       usb_mixer_elem_info_free(cval);
+                       return -EINVAL;
+               }
+
                kctl = snd_ctl_new1(&mixer_procunit_ctl, cval);
                if (!kctl) {
                        usb_mixer_elem_info_free(cval);
index 5600751..b401ee8 100644 (file)
@@ -369,11 +369,13 @@ static int set_sync_ep_implicit_fb_quirk(struct snd_usb_substream *subs,
        case USB_ID(0x07fd, 0x0008): /* MOTU M Series */
        case USB_ID(0x31e9, 0x0001): /* Solid State Logic SSL2 */
        case USB_ID(0x31e9, 0x0002): /* Solid State Logic SSL2+ */
+       case USB_ID(0x0499, 0x172f): /* Steinberg UR22C */
        case USB_ID(0x0d9a, 0x00df): /* RTX6001 */
                ep = 0x81;
                ifnum = 2;
                goto add_sync_ep_from_ifnum;
        case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */
+       case USB_ID(0x2b73, 0x0017): /* Pioneer DJ DJM-250MK2 */
                ep = 0x82;
                ifnum = 0;
                goto add_sync_ep_from_ifnum;
index d79e3dd..23eafd5 100644 (file)
@@ -2678,6 +2678,10 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                .ifnum = QUIRK_ANY_INTERFACE,
                .type = QUIRK_COMPOSITE,
                .data = (const struct snd_usb_audio_quirk[]) {
+                       {
+                               .ifnum = 0,
+                               .type = QUIRK_AUDIO_STANDARD_MIXER,
+                       },
                        {
                                .ifnum = 0,
                                .type = QUIRK_AUDIO_FIXED_ENDPOINT,
@@ -2690,6 +2694,32 @@ YAMAHA_DEVICE(0x7010, "UB99"),
                                        .attributes = UAC_EP_CS_ATTR_SAMPLE_RATE,
                                        .endpoint = 0x01,
                                        .ep_attr = USB_ENDPOINT_XFER_ISOC,
+                                       .datainterval = 1,
+                                       .maxpacksize = 0x024c,
+                                       .rates = SNDRV_PCM_RATE_44100 |
+                                                SNDRV_PCM_RATE_48000,
+                                       .rate_min = 44100,
+                                       .rate_max = 48000,
+                                       .nr_rates = 2,
+                                       .rate_table = (unsigned int[]) {
+                                               44100, 48000
+                                       }
+                               }
+                       },
+                       {
+                               .ifnum = 0,
+                               .type = QUIRK_AUDIO_FIXED_ENDPOINT,
+                               .data = &(const struct audioformat) {
+                                       .formats = SNDRV_PCM_FMTBIT_S24_3LE,
+                                       .channels = 2,
+                                       .iface = 0,
+                                       .altsetting = 1,
+                                       .altset_idx = 1,
+                                       .attributes = 0,
+                                       .endpoint = 0x82,
+                                       .ep_attr = USB_ENDPOINT_XFER_ISOC,
+                                       .datainterval = 1,
+                                       .maxpacksize = 0x0126,
                                        .rates = SNDRV_PCM_RATE_44100 |
                                                 SNDRV_PCM_RATE_48000,
                                        .rate_min = 44100,
@@ -2797,14 +2827,24 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 /* Lenovo ThinkStation P620 Rear Line-in, Line-out and Microphone */
 {
        USB_DEVICE(0x17aa, 0x1046),
-       QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Rear",
-                            "Lenovo-ThinkStation-P620-Rear"),
+       .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+               .vendor_name = "Lenovo",
+               .product_name = "ThinkStation P620 Rear",
+               .profile_name = "Lenovo-ThinkStation-P620-Rear",
+               .ifnum = QUIRK_ANY_INTERFACE,
+               .type = QUIRK_SETUP_DISABLE_AUTOSUSPEND
+       }
 },
 /* Lenovo ThinkStation P620 Internal Speaker + Front Headset */
 {
        USB_DEVICE(0x17aa, 0x104d),
-       QUIRK_DEVICE_PROFILE("Lenovo", "ThinkStation P620 Main",
-                            "Lenovo-ThinkStation-P620-Main"),
+       .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
+               .vendor_name = "Lenovo",
+               .product_name = "ThinkStation P620 Main",
+               .profile_name = "Lenovo-ThinkStation-P620-Main",
+               .ifnum = QUIRK_ANY_INTERFACE,
+               .type = QUIRK_SETUP_DISABLE_AUTOSUSPEND
+       }
 },
 
 /* Native Instruments MK2 series */
@@ -3519,14 +3559,40 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
 {
        /*
         * Pioneer DJ DJM-250MK2
-        * PCM is 8 channels out @ 48 fixed (endpoints 0x01).
-        * The output from computer to the mixer is usable.
+        * PCM is 8 channels out @ 48 fixed (endpoint 0x01)
+        * and 8 channels in @ 48 fixed (endpoint 0x82).
+        *
+        * Both playback and recording is working, even simultaneously.
+        *
+        * Playback channels could be mapped to:
+        *  - CH1
+        *  - CH2
+        *  - AUX
         *
-        * The input (phono or line to computer) is not working.
-        * It should be at endpoint 0x82 and probably also 8 channels,
-        * but it seems that it works only with Pioneer proprietary software.
-        * Even on officially supported OS, the Audacity was unable to record
-        * and Mixxx to recognize the control vinyls.
+        * Recording channels could be mapped to:
+        *  - Post CH1 Fader
+        *  - Post CH2 Fader
+        *  - Cross Fader A
+        *  - Cross Fader B
+        *  - MIC
+        *  - AUX
+        *  - REC OUT
+        *
+        * There is remaining problem with recording directly from PHONO/LINE.
+        * If we map a channel to:
+        *  - CH1 Control Tone PHONO
+        *  - CH1 Control Tone LINE
+        *  - CH2 Control Tone PHONO
+        *  - CH2 Control Tone LINE
+        * it is silent.
+        * There is no signal even on other operating systems with official drivers.
+        * The signal appears only when a supported application is started.
+        * This needs to be investigated yet...
+        * (there is quite a lot communication on the USB in both directions)
+        *
+        * In current version this mixer could be used for playback
+        * and for recording from vinyls (through Post CH* Fader)
+        * but not for DVS (Digital Vinyl Systems) like in Mixxx.
         */
        USB_DEVICE_VENDOR_SPEC(0x2b73, 0x0017),
        .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
@@ -3550,6 +3616,26 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
                                        .rate_max = 48000,
                                        .nr_rates = 1,
                                        .rate_table = (unsigned int[]) { 48000 }
+                                       }
+                       },
+                       {
+                               .ifnum = 0,
+                               .type = QUIRK_AUDIO_FIXED_ENDPOINT,
+                               .data = &(const struct audioformat) {
+                                       .formats = SNDRV_PCM_FMTBIT_S24_3LE,
+                                       .channels = 8, // inputs
+                                       .iface = 0,
+                                       .altsetting = 1,
+                                       .altset_idx = 1,
+                                       .endpoint = 0x82,
+                                       .ep_attr = USB_ENDPOINT_XFER_ISOC|
+                                               USB_ENDPOINT_SYNC_ASYNC|
+                                               USB_ENDPOINT_USAGE_IMPLICIT_FB,
+                                       .rates = SNDRV_PCM_RATE_48000,
+                                       .rate_min = 48000,
+                                       .rate_max = 48000,
+                                       .nr_rates = 1,
+                                       .rate_table = (unsigned int[]) { 48000 }
                                }
                        },
                        {
@@ -3714,8 +3800,8 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* Asrock TRX40 Creator */
  * they pretend to be 96kHz mono as a workaround for stereo being broken
  * by that...
  *
- * They also have swapped L-R channels, but that's for userspace to deal
- * with.
+ * They also have an issue with initial stream alignment that causes the
+ * channels to be swapped and out of phase, which is dealt with in quirks.c.
  */
 {
        .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
index abf99b8..75bbdc6 100644 (file)
@@ -518,6 +518,15 @@ static int setup_fmt_after_resume_quirk(struct snd_usb_audio *chip,
        return 1;       /* Continue with creating streams and mixer */
 }
 
+static int setup_disable_autosuspend(struct snd_usb_audio *chip,
+                                      struct usb_interface *iface,
+                                      struct usb_driver *driver,
+                                      const struct snd_usb_audio_quirk *quirk)
+{
+       driver->supports_autosuspend = 0;
+       return 1;       /* Continue with creating streams and mixer */
+}
+
 /*
  * audio-interface quirks
  *
@@ -557,6 +566,7 @@ int snd_usb_create_quirk(struct snd_usb_audio *chip,
                [QUIRK_AUDIO_ALIGN_TRANSFER] = create_align_transfer_quirk,
                [QUIRK_AUDIO_STANDARD_MIXER] = create_standard_mixer_quirk,
                [QUIRK_SETUP_FMT_AFTER_RESUME] = setup_fmt_after_resume_quirk,
+               [QUIRK_SETUP_DISABLE_AUTOSUSPEND] = setup_disable_autosuspend,
        };
 
        if (quirk->type < QUIRK_TYPE_COUNT) {
@@ -1493,6 +1503,7 @@ void snd_usb_set_format_quirk(struct snd_usb_substream *subs,
                set_format_emu_quirk(subs, fmt);
                break;
        case USB_ID(0x2b73, 0x000a): /* Pioneer DJ DJM-900NXS2 */
+       case USB_ID(0x2b73, 0x0017): /* Pioneer DJ DJM-250MK2 */
                pioneer_djm_set_format_quirk(subs);
                break;
        case USB_ID(0x534d, 0x2109): /* MacroSilicon MS2109 */
index b91c4c0..6839915 100644 (file)
@@ -102,6 +102,7 @@ enum quirk_type {
        QUIRK_AUDIO_ALIGN_TRANSFER,
        QUIRK_AUDIO_STANDARD_MIXER,
        QUIRK_SETUP_FMT_AFTER_RESUME,
+       QUIRK_SETUP_DISABLE_AUTOSUSPEND,
 
        QUIRK_TYPE_COUNT
 };
index 7777719..4ffcc5e 100644 (file)
@@ -9,7 +9,7 @@ menuconfig SND_X86
 if SND_X86
 
 config HDMI_LPE_AUDIO
-       tristate "HDMI audio without HDaudio on Intel Atom platforms"
+       tristate "HDMI audio without HDAudio on Intel Atom platforms"
        depends on DRM_I915
        select SND_PCM
        help
index ede162f..0e93107 100644 (file)
@@ -67,7 +67,7 @@ static int dump_prog_id_as_func_ptr(const struct btf_dumper *d,
        if (!info->btf_id || !info->nr_func_info ||
            btf__get_from_id(info->btf_id, &prog_btf))
                goto print;
-       finfo = (struct bpf_func_info *)info->func_info;
+       finfo = u64_to_ptr(info->func_info);
        func_type = btf__type_by_id(prog_btf, finfo->type_id);
        if (!func_type || !btf_is_func(func_type))
                goto print;
index 8a4c2b3..f611846 100644 (file)
@@ -143,6 +143,20 @@ static int codegen_datasec_def(struct bpf_object *obj,
                              var_name, align);
                        return -EINVAL;
                }
+               /* Assume 32-bit architectures when generating data section
+                * struct memory layout. Given bpftool can't know which target
+                * host architecture it's emitting skeleton for, we need to be
+                * conservative and assume 32-bit one to ensure enough padding
+                * bytes are generated for pointer and long types. This will
+                * still work correctly for 64-bit architectures, because in
+                * the worst case we'll generate unnecessary padding field,
+                * which on 64-bit architectures is not strictly necessary and
+                * would be handled by natural 8-byte alignment. But it still
+                * will be a correct memory layout, based on recorded offsets
+                * in BTF.
+                */
+               if (align > 4)
+                       align = 4;
 
                align_off = (off + align - 1) / align * align;
                if (align_off != need_off) {
@@ -397,7 +411,7 @@ static int do_skeleton(int argc, char **argv)
                {                                                           \n\
                        struct %1$s *obj;                                   \n\
                                                                            \n\
-                       obj = (typeof(obj))calloc(1, sizeof(*obj));         \n\
+                       obj = (struct %1$s *)calloc(1, sizeof(*obj));       \n\
                        if (!obj)                                           \n\
                                return NULL;                                \n\
                        if (%1$s__create_skeleton(obj))                     \n\
@@ -461,7 +475,7 @@ static int do_skeleton(int argc, char **argv)
                {                                                           \n\
                        struct bpf_object_skeleton *s;                      \n\
                                                                            \n\
-                       s = (typeof(s))calloc(1, sizeof(*s));               \n\
+                       s = (struct bpf_object_skeleton *)calloc(1, sizeof(*s));\n\
                        if (!s)                                             \n\
                                return -1;                                  \n\
                        obj->skeleton = s;                                  \n\
@@ -479,7 +493,7 @@ static int do_skeleton(int argc, char **argv)
                                /* maps */                                  \n\
                                s->map_cnt = %zu;                           \n\
                                s->map_skel_sz = sizeof(*s->maps);          \n\
-                               s->maps = (typeof(s->maps))calloc(s->map_cnt, s->map_skel_sz);\n\
+                               s->maps = (struct bpf_map_skeleton *)calloc(s->map_cnt, s->map_skel_sz);\n\
                                if (!s->maps)                               \n\
                                        goto err;                           \n\
                        ",
@@ -515,7 +529,7 @@ static int do_skeleton(int argc, char **argv)
                                /* programs */                              \n\
                                s->prog_cnt = %zu;                          \n\
                                s->prog_skel_sz = sizeof(*s->progs);        \n\
-                               s->progs = (typeof(s->progs))calloc(s->prog_cnt, s->prog_skel_sz);\n\
+                               s->progs = (struct bpf_prog_skeleton *)calloc(s->prog_cnt, s->prog_skel_sz);\n\
                                if (!s->progs)                              \n\
                                        goto err;                           \n\
                        ",
index 1b79375..a89f09e 100644 (file)
@@ -106,7 +106,7 @@ static int show_link_close_json(int fd, struct bpf_link_info *info)
        switch (info->type) {
        case BPF_LINK_TYPE_RAW_TRACEPOINT:
                jsonw_string_field(json_wtr, "tp_name",
-                                  (const char *)info->raw_tracepoint.tp_name);
+                                  u64_to_ptr(info->raw_tracepoint.tp_name));
                break;
        case BPF_LINK_TYPE_TRACING:
                err = get_prog_info(info->prog_id, &prog_info);
@@ -185,7 +185,7 @@ static int show_link_close_plain(int fd, struct bpf_link_info *info)
        switch (info->type) {
        case BPF_LINK_TYPE_RAW_TRACEPOINT:
                printf("\n\ttp '%s'  ",
-                      (const char *)info->raw_tracepoint.tp_name);
+                      (const char *)u64_to_ptr(info->raw_tracepoint.tp_name));
                break;
        case BPF_LINK_TYPE_TRACING:
                err = get_prog_info(info->prog_id, &prog_info);
index e3a79b5..c46e521 100644 (file)
 /* Make sure we do not use kernel-only integer typedefs */
 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
 
-#define ptr_to_u64(ptr)        ((__u64)(unsigned long)(ptr))
+static inline __u64 ptr_to_u64(const void *ptr)
+{
+       return (__u64)(unsigned long)ptr;
+}
+
+static inline void *u64_to_ptr(__u64 ptr)
+{
+       return (void *)(unsigned long)ptr;
+}
 
 #define NEXT_ARG()     ({ argc--; argv++; if (argc < 0) usage(); })
 #define NEXT_ARGP()    ({ (*argc)--; (*argv)++; if (*argc < 0) usage(); })
index e3b1163..df7d8ec 100644 (file)
@@ -134,6 +134,8 @@ int build_obj_refs_table(struct obj_refs_table *table, enum bpf_obj_type type)
        while (true) {
                ret = read(fd, buf, sizeof(buf));
                if (ret < 0) {
+                       if (errno == EAGAIN)
+                               continue;
                        err = -errno;
                        p_err("failed to read PID iterator output: %d", err);
                        goto out;
index 158995d..d393eb8 100644 (file)
@@ -428,14 +428,14 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
                        p_info("no instructions returned");
                        return -1;
                }
-               buf = (unsigned char *)(info->jited_prog_insns);
+               buf = u64_to_ptr(info->jited_prog_insns);
                member_len = info->jited_prog_len;
        } else {        /* DUMP_XLATED */
                if (info->xlated_prog_len == 0 || !info->xlated_prog_insns) {
                        p_err("error retrieving insn dump: kernel.kptr_restrict set?");
                        return -1;
                }
-               buf = (unsigned char *)info->xlated_prog_insns;
+               buf = u64_to_ptr(info->xlated_prog_insns);
                member_len = info->xlated_prog_len;
        }
 
@@ -444,7 +444,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
                return -1;
        }
 
-       func_info = (void *)info->func_info;
+       func_info = u64_to_ptr(info->func_info);
 
        if (info->nr_line_info) {
                prog_linfo = bpf_prog_linfo__new(info);
@@ -462,7 +462,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
 
                n = write(fd, buf, member_len);
                close(fd);
-               if (n != member_len) {
+               if (n != (ssize_t)member_len) {
                        p_err("error writing output file: %s",
                              n < 0 ? strerror(errno) : "short write");
                        return -1;
@@ -492,13 +492,13 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
                        __u32 i;
                        if (info->nr_jited_ksyms) {
                                kernel_syms_load(&dd);
-                               ksyms = (__u64 *) info->jited_ksyms;
+                               ksyms = u64_to_ptr(info->jited_ksyms);
                        }
 
                        if (json_output)
                                jsonw_start_array(json_wtr);
 
-                       lens = (__u32 *) info->jited_func_lens;
+                       lens = u64_to_ptr(info->jited_func_lens);
                        for (i = 0; i < info->nr_jited_func_lens; i++) {
                                if (ksyms) {
                                        sym = kernel_syms_search(&dd, ksyms[i]);
@@ -559,7 +559,7 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,
        } else {
                kernel_syms_load(&dd);
                dd.nr_jited_ksyms = info->nr_jited_ksyms;
-               dd.jited_ksyms = (__u64 *) info->jited_ksyms;
+               dd.jited_ksyms = u64_to_ptr(info->jited_ksyms);
                dd.btf = btf;
                dd.func_info = func_info;
                dd.finfo_rec_size = info->func_info_rec_size;
@@ -1681,7 +1681,7 @@ static char *profile_target_name(int tgt_fd)
                goto out;
        }
 
-       func_info = (struct bpf_func_info *)(info_linear->info.func_info);
+       func_info = u64_to_ptr(info_linear->info.func_info);
        t = btf__type_by_id(btf, func_info[0].type_id);
        if (!t) {
                p_err("btf %d doesn't have type %d",
index 4d9ecb9..0def0bb 100644 (file)
@@ -233,6 +233,39 @@ static struct btf_id *add_symbol(struct rb_root *root, char *name, size_t size)
        return btf_id__add(root, id, false);
 }
 
+/*
+ * The data of compressed section should be aligned to 4
+ * (for 32bit) or 8 (for 64 bit) bytes. The binutils ld
+ * sets sh_addralign to 1, which makes libelf fail with
+ * misaligned section error during the update:
+ *    FAILED elf_update(WRITE): invalid section alignment
+ *
+ * While waiting for ld fix, we fix the compressed sections
+ * sh_addralign value manualy.
+ */
+static int compressed_section_fix(Elf *elf, Elf_Scn *scn, GElf_Shdr *sh)
+{
+       int expected = gelf_getclass(elf) == ELFCLASS32 ? 4 : 8;
+
+       if (!(sh->sh_flags & SHF_COMPRESSED))
+               return 0;
+
+       if (sh->sh_addralign == expected)
+               return 0;
+
+       pr_debug2(" - fixing wrong alignment sh_addralign %u, expected %u\n",
+                 sh->sh_addralign, expected);
+
+       sh->sh_addralign = expected;
+
+       if (gelf_update_shdr(scn, sh) == 0) {
+               printf("FAILED cannot update section header: %s\n",
+                       elf_errmsg(-1));
+               return -1;
+       }
+       return 0;
+}
+
 static int elf_collect(struct object *obj)
 {
        Elf_Scn *scn = NULL;
@@ -309,6 +342,9 @@ static int elf_collect(struct object *obj)
                        obj->efile.idlist_shndx = idx;
                        obj->efile.idlist_addr  = sh.sh_addr;
                }
+
+               if (compressed_section_fix(elf, scn, &sh))
+                       return -1;
        }
 
        return 0;
index 0480f89..b6238b2 100644 (file)
@@ -767,7 +767,7 @@ union bpf_attr {
  *
  *             Also, note that **bpf_trace_printk**\ () is slow, and should
  *             only be used for debugging purposes. For this reason, a notice
- *             bloc (spanning several lines) is printed to kernel logs and
+ *             block (spanning several lines) is printed to kernel logs and
  *             states that the helper should not be used "for production use"
  *             the first time this helper is used (or more precisely, when
  *             **trace_printk**\ () buffers are allocated). For passing values
@@ -1033,14 +1033,14 @@ union bpf_attr {
  *
  *                     int ret;
  *                     struct bpf_tunnel_key key = {};
- *                     
+ *
  *                     ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
  *                     if (ret < 0)
  *                             return TC_ACT_SHOT;     // drop packet
- *                     
+ *
  *                     if (key.remote_ipv4 != 0x0a000001)
  *                             return TC_ACT_SHOT;     // drop packet
- *                     
+ *
  *                     return TC_ACT_OK;               // accept packet
  *
  *             This interface can also be used with all encapsulation devices
@@ -1147,7 +1147,7 @@ union bpf_attr {
  *     Description
  *             Retrieve the realm or the route, that is to say the
  *             **tclassid** field of the destination for the *skb*. The
- *             indentifier retrieved is a user-provided tag, similar to the
+ *             identifier retrieved is a user-provided tag, similar to the
  *             one used with the net_cls cgroup (see description for
  *             **bpf_get_cgroup_classid**\ () helper), but here this tag is
  *             held by a route (a destination entry), not by a task.
index 077e7ee..3e5dcdd 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  37
+#define PERF_MEM_SNOOPX_SHIFT  38
 
 /* locked instruction */
 #define PERF_MEM_LOCK_NA       0x01 /* not available */
index bc14db7..e9a4ecd 100644 (file)
@@ -40,7 +40,7 @@
  * Helper macro to manipulate data structures
  */
 #ifndef offsetof
-#define offsetof(TYPE, MEMBER)  __builtin_offsetof(TYPE, MEMBER)
+#define offsetof(TYPE, MEMBER) ((unsigned long)&((TYPE *)0)->MEMBER)
 #endif
 #ifndef container_of
 #define container_of(ptr, type, member)                                \
index 4843e44..7dfca70 100644 (file)
@@ -41,6 +41,7 @@ struct btf {
        __u32 types_size;
        __u32 data_size;
        int fd;
+       int ptr_sz;
 };
 
 static inline __u64 ptr_to_u64(const void *ptr)
@@ -221,6 +222,70 @@ const struct btf_type *btf__type_by_id(const struct btf *btf, __u32 type_id)
        return btf->types[type_id];
 }
 
+static int determine_ptr_size(const struct btf *btf)
+{
+       const struct btf_type *t;
+       const char *name;
+       int i;
+
+       for (i = 1; i <= btf->nr_types; i++) {
+               t = btf__type_by_id(btf, i);
+               if (!btf_is_int(t))
+                       continue;
+
+               name = btf__name_by_offset(btf, t->name_off);
+               if (!name)
+                       continue;
+
+               if (strcmp(name, "long int") == 0 ||
+                   strcmp(name, "long unsigned int") == 0) {
+                       if (t->size != 4 && t->size != 8)
+                               continue;
+                       return t->size;
+               }
+       }
+
+       return -1;
+}
+
+static size_t btf_ptr_sz(const struct btf *btf)
+{
+       if (!btf->ptr_sz)
+               ((struct btf *)btf)->ptr_sz = determine_ptr_size(btf);
+       return btf->ptr_sz < 0 ? sizeof(void *) : btf->ptr_sz;
+}
+
+/* Return pointer size this BTF instance assumes. The size is heuristically
+ * determined by looking for 'long' or 'unsigned long' integer type and
+ * recording its size in bytes. If BTF type information doesn't have any such
+ * type, this function returns 0. In the latter case, native architecture's
+ * pointer size is assumed, so will be either 4 or 8, depending on
+ * architecture that libbpf was compiled for. It's possible to override
+ * guessed value by using btf__set_pointer_size() API.
+ */
+size_t btf__pointer_size(const struct btf *btf)
+{
+       if (!btf->ptr_sz)
+               ((struct btf *)btf)->ptr_sz = determine_ptr_size(btf);
+
+       if (btf->ptr_sz < 0)
+               /* not enough BTF type info to guess */
+               return 0;
+
+       return btf->ptr_sz;
+}
+
+/* Override or set pointer size in bytes. Only values of 4 and 8 are
+ * supported.
+ */
+int btf__set_pointer_size(struct btf *btf, size_t ptr_sz)
+{
+       if (ptr_sz != 4 && ptr_sz != 8)
+               return -EINVAL;
+       btf->ptr_sz = ptr_sz;
+       return 0;
+}
+
 static bool btf_type_is_void(const struct btf_type *t)
 {
        return t == &btf_void || btf_is_fwd(t);
@@ -253,7 +318,7 @@ __s64 btf__resolve_size(const struct btf *btf, __u32 type_id)
                        size = t->size;
                        goto done;
                case BTF_KIND_PTR:
-                       size = sizeof(void *);
+                       size = btf_ptr_sz(btf);
                        goto done;
                case BTF_KIND_TYPEDEF:
                case BTF_KIND_VOLATILE:
@@ -293,9 +358,9 @@ int btf__align_of(const struct btf *btf, __u32 id)
        switch (kind) {
        case BTF_KIND_INT:
        case BTF_KIND_ENUM:
-               return min(sizeof(void *), (size_t)t->size);
+               return min(btf_ptr_sz(btf), (size_t)t->size);
        case BTF_KIND_PTR:
-               return sizeof(void *);
+               return btf_ptr_sz(btf);
        case BTF_KIND_TYPEDEF:
        case BTF_KIND_VOLATILE:
        case BTF_KIND_CONST:
@@ -533,6 +598,18 @@ struct btf *btf__parse_elf(const char *path, struct btf_ext **btf_ext)
        if (IS_ERR(btf))
                goto done;
 
+       switch (gelf_getclass(elf)) {
+       case ELFCLASS32:
+               btf__set_pointer_size(btf, 4);
+               break;
+       case ELFCLASS64:
+               btf__set_pointer_size(btf, 8);
+               break;
+       default:
+               pr_warn("failed to get ELF class (bitness) for %s\n", path);
+               break;
+       }
+
        if (btf_ext && btf_ext_data) {
                *btf_ext = btf_ext__new(btf_ext_data->d_buf,
                                        btf_ext_data->d_size);
index f4a1a1d..1ca1444 100644 (file)
@@ -76,6 +76,8 @@ LIBBPF_API __s32 btf__find_by_name_kind(const struct btf *btf,
 LIBBPF_API __u32 btf__get_nr_types(const struct btf *btf);
 LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
                                                  __u32 id);
+LIBBPF_API size_t btf__pointer_size(const struct btf *btf);
+LIBBPF_API int btf__set_pointer_size(struct btf *btf, size_t ptr_sz);
 LIBBPF_API __s64 btf__resolve_size(const struct btf *btf, __u32 type_id);
 LIBBPF_API int btf__resolve_type(const struct btf *btf, __u32 type_id);
 LIBBPF_API int btf__align_of(const struct btf *btf, __u32 id);
index cf71116..57c00fa 100644 (file)
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <linux/err.h>
 #include <linux/btf.h>
+#include <linux/kernel.h>
 #include "btf.h"
 #include "hashmap.h"
 #include "libbpf.h"
@@ -60,6 +61,7 @@ struct btf_dump {
        const struct btf_ext *btf_ext;
        btf_dump_printf_fn_t printf_fn;
        struct btf_dump_opts opts;
+       int ptr_sz;
        bool strip_mods;
 
        /* per-type auxiliary state */
@@ -138,6 +140,7 @@ struct btf_dump *btf_dump__new(const struct btf *btf,
        d->btf_ext = btf_ext;
        d->printf_fn = printf_fn;
        d->opts.ctx = opts ? opts->ctx : NULL;
+       d->ptr_sz = btf__pointer_size(btf) ? : sizeof(void *);
 
        d->type_names = hashmap__new(str_hash_fn, str_equal_fn, NULL);
        if (IS_ERR(d->type_names)) {
@@ -549,6 +552,9 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 id, bool through_ptr)
        }
 }
 
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+                                         const struct btf_type *t);
+
 static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id,
                                     const struct btf_type *t);
 static void btf_dump_emit_struct_def(struct btf_dump *d, __u32 id,
@@ -671,6 +677,9 @@ static void btf_dump_emit_type(struct btf_dump *d, __u32 id, __u32 cont_id)
 
        switch (kind) {
        case BTF_KIND_INT:
+               /* Emit type alias definitions if necessary */
+               btf_dump_emit_missing_aliases(d, id, t);
+
                tstate->emit_state = EMITTED;
                break;
        case BTF_KIND_ENUM:
@@ -797,7 +806,7 @@ static void btf_dump_emit_bit_padding(const struct btf_dump *d,
                                      int align, int lvl)
 {
        int off_diff = m_off - cur_off;
-       int ptr_bits = sizeof(void *) * 8;
+       int ptr_bits = d->ptr_sz * 8;
 
        if (off_diff <= 0)
                /* no gap */
@@ -870,7 +879,7 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
                        btf_dump_printf(d, ": %d", m_sz);
                        off = m_off + m_sz;
                } else {
-                       m_sz = max(0, btf__resolve_size(d->btf, m->type));
+                       m_sz = max((__s64)0, btf__resolve_size(d->btf, m->type));
                        off = m_off + m_sz * 8;
                }
                btf_dump_printf(d, ";");
@@ -890,6 +899,32 @@ static void btf_dump_emit_struct_def(struct btf_dump *d,
                btf_dump_printf(d, " __attribute__((packed))");
 }
 
+static const char *missing_base_types[][2] = {
+       /*
+        * GCC emits typedefs to its internal __PolyX_t types when compiling Arm
+        * SIMD intrinsics. Alias them to standard base types.
+        */
+       { "__Poly8_t",          "unsigned char" },
+       { "__Poly16_t",         "unsigned short" },
+       { "__Poly64_t",         "unsigned long long" },
+       { "__Poly128_t",        "unsigned __int128" },
+};
+
+static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id,
+                                         const struct btf_type *t)
+{
+       const char *name = btf_dump_type_name(d, id);
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(missing_base_types); i++) {
+               if (strcmp(name, missing_base_types[i][0]) == 0) {
+                       btf_dump_printf(d, "typedef %s %s;\n\n",
+                                       missing_base_types[i][1], name);
+                       break;
+               }
+       }
+}
+
 static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id,
                                   const struct btf_type *t)
 {
index 0a06124..0ad0b04 100644 (file)
@@ -2264,7 +2264,7 @@ static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict,
                data = elf_getdata(scn, NULL);
        if (!scn || !data) {
                pr_warn("failed to get Elf_Data from map section %d (%s)\n",
-                       obj->efile.maps_shndx, MAPS_ELF_SEC);
+                       obj->efile.btf_maps_shndx, MAPS_ELF_SEC);
                return -EINVAL;
        }
 
@@ -2434,6 +2434,8 @@ static int bpf_object__init_btf(struct bpf_object *obj,
                                BTF_ELF_SEC, err);
                        goto out;
                }
+               /* enforce 8-byte pointers for BPF-targeted BTFs */
+               btf__set_pointer_size(obj->btf, 8);
                err = 0;
        }
        if (btf_ext_data) {
@@ -2542,6 +2544,8 @@ static int bpf_object__sanitize_and_load_btf(struct bpf_object *obj)
                if (IS_ERR(kern_btf))
                        return PTR_ERR(kern_btf);
 
+               /* enforce 8-byte pointers for BPF-targeted BTFs */
+               btf__set_pointer_size(obj->btf, 8);
                bpf_object__sanitize_btf(obj, kern_btf);
        }
 
@@ -3478,10 +3482,11 @@ bpf_object__probe_global_data(struct bpf_object *obj)
 
        map = bpf_create_map_xattr(&map_attr);
        if (map < 0) {
-               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               ret = -errno;
+               cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
                pr_warn("Error in %s():%s(%d). Couldn't create simple array map.\n",
-                       __func__, cp, errno);
-               return -errno;
+                       __func__, cp, -ret);
+               return ret;
        }
 
        insns[0].imm = map;
@@ -5194,7 +5199,8 @@ static int bpf_object__collect_st_ops_relos(struct bpf_object *obj,
 static int bpf_object__collect_map_relos(struct bpf_object *obj,
                                         GElf_Shdr *shdr, Elf_Data *data)
 {
-       int i, j, nrels, new_sz, ptr_sz = sizeof(void *);
+       const int bpf_ptr_sz = 8, host_ptr_sz = sizeof(void *);
+       int i, j, nrels, new_sz;
        const struct btf_var_secinfo *vi = NULL;
        const struct btf_type *sec, *var, *def;
        const struct btf_member *member;
@@ -5243,7 +5249,7 @@ static int bpf_object__collect_map_relos(struct bpf_object *obj,
 
                        vi = btf_var_secinfos(sec) + map->btf_var_idx;
                        if (vi->offset <= rel.r_offset &&
-                           rel.r_offset + sizeof(void *) <= vi->offset + vi->size)
+                           rel.r_offset + bpf_ptr_sz <= vi->offset + vi->size)
                                break;
                }
                if (j == obj->nr_maps) {
@@ -5279,17 +5285,20 @@ static int bpf_object__collect_map_relos(struct bpf_object *obj,
                        return -EINVAL;
 
                moff = rel.r_offset - vi->offset - moff;
-               if (moff % ptr_sz)
+               /* here we use BPF pointer size, which is always 64 bit, as we
+                * are parsing ELF that was built for BPF target
+                */
+               if (moff % bpf_ptr_sz)
                        return -EINVAL;
-               moff /= ptr_sz;
+               moff /= bpf_ptr_sz;
                if (moff >= map->init_slots_sz) {
                        new_sz = moff + 1;
-                       tmp = realloc(map->init_slots, new_sz * ptr_sz);
+                       tmp = realloc(map->init_slots, new_sz * host_ptr_sz);
                        if (!tmp)
                                return -ENOMEM;
                        map->init_slots = tmp;
                        memset(map->init_slots + map->init_slots_sz, 0,
-                              (new_sz - map->init_slots_sz) * ptr_sz);
+                              (new_sz - map->init_slots_sz) * host_ptr_sz);
                        map->init_slots_sz = new_sz;
                }
                map->init_slots[moff] = targ_map;
@@ -6012,9 +6021,10 @@ int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
        }
 
        if (bpf_obj_pin(prog->instances.fds[instance], path)) {
-               cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
+               err = -errno;
+               cp = libbpf_strerror_r(err, errmsg, sizeof(errmsg));
                pr_warn("failed to pin program: %s\n", cp);
-               return -errno;
+               return err;
        }
        pr_debug("pinned program '%s'\n", path);
 
index 0c4722b..e35bd6c 100644 (file)
@@ -295,5 +295,7 @@ LIBBPF_0.1.0 {
                bpf_program__set_sk_lookup;
                btf__parse;
                btf__parse_raw;
+               btf__pointer_size;
                btf__set_fd;
+               btf__set_pointer_size;
 } LIBBPF_0.0.9;
index 3ba566d..5acc18b 100644 (file)
@@ -5259,7 +5259,7 @@ static int print_arg_pointer(struct trace_seq *s, const char *format, int plen,
        default:
                ret = 0;
                val = eval_num_arg(data, size, event, arg);
-               trace_seq_printf(s, "%p", (void *)val);
+               trace_seq_printf(s, "%p", (void *)(intptr_t)val);
                break;
        }
 
index 3f72d8e..bd50cdf 100644 (file)
@@ -33,6 +33,10 @@ OPTIONS
         - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
          hexadecimal event descriptor.
 
+        - a symbolic or raw PMU event followed by an optional colon
+         and a list of event modifiers, e.g., cpu-cycles:p.  See the
+         linkperf:perf-list[1] man page for details on event modifiers.
+
        - a symbolically formed PMU event like 'pmu/param1=0x3,param2/' where
          'param1', 'param2', etc are defined as formats for the PMU in
          /sys/bus/event_source/devices/<pmu>/format/*.
index c9bfefc..db420dd 100644 (file)
@@ -39,6 +39,10 @@ report::
        - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
          hexadecimal event descriptor.
 
+        - a symbolic or raw PMU event followed by an optional colon
+         and a list of event modifiers, e.g., cpu-cycles:p.  See the
+         linkperf:perf-list[1] man page for details on event modifiers.
+
        - a symbolically formed event like 'pmu/param1=0x3,param2/' where
          param1 and param2 are defined as formats for the PMU in
          /sys/bus/event_source/devices/<pmu>/format/*
@@ -416,6 +420,9 @@ counts for all hardware threads in a core but show the sum counts per
 hardware thread. This is essentially a replacement for the any bit and
 convenient for post processing.
 
+--summary::
+Print summary for interval mode (-I).
+
 EXAMPLES
 --------
 
index 8d624ae..b2924e3 100644 (file)
@@ -162,8 +162,8 @@ static int do_run_multi_threaded(struct target *target,
        init_stats(&event_stats);
        for (i = 0; i < multi_iterations; i++) {
                session = perf_session__new(NULL, false, NULL);
-               if (!session)
-                       return -ENOMEM;
+               if (IS_ERR(session))
+                       return PTR_ERR(session);
 
                atomic_set(&event_count, 0);
                gettimeofday(&start, NULL);
index f91352f..772f105 100644 (file)
@@ -2452,7 +2452,7 @@ static struct option __record_options[] = {
        OPT_BOOLEAN(0, "tail-synthesize", &record.opts.tail_synthesize,
                    "synthesize non-sample events at the end of output"),
        OPT_BOOLEAN(0, "overwrite", &record.opts.overwrite, "use overwrite mode"),
-       OPT_BOOLEAN(0, "no-bpf-event", &record.opts.no_bpf_event, "record bpf events"),
+       OPT_BOOLEAN(0, "no-bpf-event", &record.opts.no_bpf_event, "do not record bpf events"),
        OPT_BOOLEAN(0, "strict-freq", &record.opts.strict_freq,
                    "Fail if the specified frequency can't be used"),
        OPT_CALLBACK('F', "freq", &record.opts, "freq or 'max'",
index ece1cdd..3c74c9c 100644 (file)
@@ -1332,6 +1332,9 @@ int cmd_report(int argc, const char **argv)
        if (report.mmaps_mode)
                report.tasks_mode = true;
 
+       if (dump_trace)
+               report.tool.ordered_events = false;
+
        if (quiet)
                perf_quiet_option();
 
index 0c7d599..e6fc297 100644 (file)
@@ -2584,7 +2584,8 @@ static int timehist_sched_change_event(struct perf_tool *tool,
        }
 
        if (!sched->idle_hist || thread->tid == 0) {
-               timehist_update_runtime_stats(tr, t, tprev);
+               if (!cpu_list || test_bit(sample->cpu, cpu_bitmap))
+                       timehist_update_runtime_stats(tr, t, tprev);
 
                if (sched->idle_hist) {
                        struct idle_thread_runtime *itr = (void *)tr;
@@ -2857,6 +2858,9 @@ static void timehist_print_summary(struct perf_sched *sched,
 
        printf("\nIdle stats:\n");
        for (i = 0; i < idle_max_cpu; ++i) {
+               if (cpu_list && !test_bit(i, cpu_bitmap))
+                       continue;
+
                t = idle_threads[i];
                if (!t)
                        continue;
index 483a28e..fddc97c 100644 (file)
@@ -404,7 +404,7 @@ static void read_counters(struct timespec *rs)
 {
        struct evsel *counter;
 
-       if (!stat_config.summary && (read_affinity_counters(rs) < 0))
+       if (!stat_config.stop_read_counter && (read_affinity_counters(rs) < 0))
                return;
 
        evlist__for_each_entry(evsel_list, counter) {
@@ -897,9 +897,9 @@ try_again_reset:
        if (stat_config.walltime_run_table)
                stat_config.walltime_run[run_idx] = t1 - t0;
 
-       if (interval) {
+       if (interval && stat_config.summary) {
                stat_config.interval = 0;
-               stat_config.summary = true;
+               stat_config.stop_read_counter = true;
                init_stats(&walltime_nsecs_stats);
                update_stats(&walltime_nsecs_stats, t1 - t0);
 
@@ -1164,6 +1164,8 @@ static struct option stat_options[] = {
                    "Use with 'percore' event qualifier to show the event "
                    "counts of one hardware thread by sum up total hardware "
                    "threads of same physical core"),
+       OPT_BOOLEAN(0, "summary", &stat_config.summary,
+                      "print summary for interval mode"),
 #ifdef HAVE_LIBPFM
        OPT_CALLBACK(0, "pfm-events", &evsel_list, "event",
                "libpfm4 event selector. use 'perf list' to list available events",
index 994c230..7c64134 100644 (file)
@@ -1746,6 +1746,7 @@ int cmd_top(int argc, const char **argv)
                goto out_delete_evlist;
        }
 
+#ifdef HAVE_LIBBPF_SUPPORT
        if (!top.record_opts.no_bpf_event) {
                top.sb_evlist = evlist__new();
 
@@ -1759,6 +1760,7 @@ int cmd_top(int argc, const char **argv)
                        goto out_delete_evlist;
                }
        }
+#endif
 
        if (perf_evlist__start_sb_thread(top.sb_evlist, target)) {
                pr_debug("Couldn't start the BPF side band thread:\nBPF programs starting from now on won't be annotatable\n");
index fa86c5f..fc9c158 100644 (file)
@@ -137,7 +137,7 @@ static char *fixregex(char *s)
                return s;
 
        /* allocate space for a new string */
-       fixed = (char *) malloc(len + 1);
+       fixed = (char *) malloc(len + esc_count + 1);
        if (!fixed)
                return NULL;
 
index 5d20bf8..cd77e33 100644 (file)
@@ -197,7 +197,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),
                perf_mmap__read_done(&md->core);
        }
 
-       if (count != expect) {
+       if (count != expect * evlist->core.nr_entries) {
                pr_debug("BPF filter result incorrect, expected %d, got %d samples\n", expect, count);
                goto out_delete_evlist;
        }
index 7f9f87a..aae0fd9 100644 (file)
@@ -719,7 +719,7 @@ static int test__group2(struct evlist *evlist)
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
        TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
-       TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
+       TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
        TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
        TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
        TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
@@ -842,7 +842,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)
        TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
        TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
        TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
-       TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
+       TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
        TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
        TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
        TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
index fc0838a..23db8ac 100644 (file)
@@ -70,6 +70,9 @@ static struct pmu_event pme_test[] = {
 {
        .metric_expr    = "1/m3",
        .metric_name    = "M3",
+},
+{
+       .name   = NULL,
 }
 };
 
index be9c4c0..a07626f 100644 (file)
@@ -3629,8 +3629,8 @@ int perf_evlist__tui_browse_hists(struct evlist *evlist, const char *help,
 {
        int nr_entries = evlist->core.nr_entries;
 
-single_entry:
        if (perf_evlist__single_entry(evlist)) {
+single_entry: {
                struct evsel *first = evlist__first(evlist);
 
                return perf_evsel__hists_browse(first, nr_entries, help,
@@ -3638,6 +3638,7 @@ single_entry:
                                                env, warn_lost_event,
                                                annotation_opts);
        }
+       }
 
        if (symbol_conf.event_group) {
                struct evsel *pos;
index 302a14d..93e063f 100644 (file)
@@ -182,15 +182,15 @@ static int arm_spe_read_record(struct arm_spe_decoder *decoder)
                        if (payload & BIT(EV_TLB_ACCESS))
                                decoder->record.type |= ARM_SPE_TLB_ACCESS;
 
-                       if ((idx == 1 || idx == 2 || idx == 3) &&
+                       if ((idx == 2 || idx == 4 || idx == 8) &&
                            (payload & BIT(EV_LLC_MISS)))
                                decoder->record.type |= ARM_SPE_LLC_MISS;
 
-                       if ((idx == 1 || idx == 2 || idx == 3) &&
+                       if ((idx == 2 || idx == 4 || idx == 8) &&
                            (payload & BIT(EV_LLC_ACCESS)))
                                decoder->record.type |= ARM_SPE_LLC_ACCESS;
 
-                       if ((idx == 1 || idx == 2 || idx == 3) &&
+                       if ((idx == 2 || idx == 4 || idx == 8) &&
                            (payload & BIT(EV_REMOTE_ACCESS)))
                                decoder->record.type |= ARM_SPE_REMOTE_ACCESS;
 
index c283223..a2a369e 100644 (file)
@@ -1344,8 +1344,15 @@ static int cs_etm__synth_events(struct cs_etm_auxtrace *etm,
                attr.sample_type &= ~(u64)PERF_SAMPLE_ADDR;
        }
 
-       if (etm->synth_opts.last_branch)
+       if (etm->synth_opts.last_branch) {
                attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
+               /*
+                * We don't use the hardware index, but the sample generation
+                * code uses the new format branch_stack with this field,
+                * so the event attributes must indicate that it's present.
+                */
+               attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX;
+       }
 
        if (etm->synth_opts.instructions) {
                attr.config = PERF_COUNT_HW_INSTRUCTIONS;
index 2a8d245..0af4e81 100644 (file)
@@ -3017,8 +3017,15 @@ static int intel_pt_synth_events(struct intel_pt *pt,
 
        if (pt->synth_opts.callchain)
                attr.sample_type |= PERF_SAMPLE_CALLCHAIN;
-       if (pt->synth_opts.last_branch)
+       if (pt->synth_opts.last_branch) {
                attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
+               /*
+                * We don't use the hardware index, but the sample generation
+                * code uses the new format branch_stack with this field,
+                * so the event attributes must indicate that it's present.
+                */
+               attr.branch_sample_type |= PERF_SAMPLE_BRANCH_HW_INDEX;
+       }
 
        if (pt->synth_opts.instructions) {
                attr.config = PERF_COUNT_HW_INSTRUCTIONS;
index 208b813..85587de 100644 (file)
@@ -736,12 +736,6 @@ int machine__process_switch_event(struct machine *machine __maybe_unused,
        return 0;
 }
 
-static int is_bpf_image(const char *name)
-{
-       return strncmp(name, "bpf_trampoline_", sizeof("bpf_trampoline_") - 1) == 0 ||
-              strncmp(name, "bpf_dispatcher_", sizeof("bpf_dispatcher_") - 1) == 0;
-}
-
 static int machine__process_ksymbol_register(struct machine *machine,
                                             union perf_event *event,
                                             struct perf_sample *sample __maybe_unused)
index 1d72108..cc0faf8 100644 (file)
@@ -267,6 +267,22 @@ bool __map__is_bpf_prog(const struct map *map)
        return name && (strstr(name, "bpf_prog_") == name);
 }
 
+bool __map__is_bpf_image(const struct map *map)
+{
+       const char *name;
+
+       if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_IMAGE)
+               return true;
+
+       /*
+        * If PERF_RECORD_KSYMBOL is not included, the dso will not have
+        * type of DSO_BINARY_TYPE__BPF_IMAGE. In such cases, we can
+        * guess the type based on name.
+        */
+       name = map->dso->short_name;
+       return name && is_bpf_image(name);
+}
+
 bool __map__is_ool(const struct map *map)
 {
        return map->dso && map->dso->binary_type == DSO_BINARY_TYPE__OOL;
index 9e312ae..c2f5d28 100644 (file)
@@ -147,12 +147,14 @@ int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
 bool __map__is_kernel(const struct map *map);
 bool __map__is_extra_kernel_map(const struct map *map);
 bool __map__is_bpf_prog(const struct map *map);
+bool __map__is_bpf_image(const struct map *map);
 bool __map__is_ool(const struct map *map);
 
 static inline bool __map__is_kmodule(const struct map *map)
 {
        return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
-              !__map__is_bpf_prog(map) && !__map__is_ool(map);
+              !__map__is_bpf_prog(map) && !__map__is_ool(map) &&
+              !__map__is_bpf_image(map);
 }
 
 bool map__has_symbols(const struct map *map);
@@ -164,4 +166,9 @@ static inline bool is_entry_trampoline(const char *name)
        return !strcmp(name, ENTRY_TRAMPOLINE_NAME);
 }
 
+static inline bool is_bpf_image(const char *name)
+{
+       return strncmp(name, "bpf_trampoline_", sizeof("bpf_trampoline_") - 1) == 0 ||
+              strncmp(name, "bpf_dispatcher_", sizeof("bpf_dispatcher_") - 1) == 0;
+}
 #endif /* __PERF_MAP_H */
index 9f7260e..c4d2394 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/evsel_config.h"
 #include "util/event.h"
 #include "util/pfm.h"
+#include "perf.h"
 
 #define MAX_NAME_LEN 100
 
@@ -1533,19 +1534,23 @@ int parse_events_add_pmu(struct parse_events_state *parse_state,
        evsel = __add_event(list, &parse_state->idx, &attr, true,
                            get_config_name(head_config), pmu,
                            &config_terms, auto_merge_stats, NULL);
-       if (evsel) {
-               evsel->unit = info.unit;
-               evsel->scale = info.scale;
-               evsel->per_pkg = info.per_pkg;
-               evsel->snapshot = info.snapshot;
-               evsel->metric_expr = info.metric_expr;
-               evsel->metric_name = info.metric_name;
-               evsel->pmu_name = name ? strdup(name) : NULL;
-               evsel->use_uncore_alias = use_uncore_alias;
-               evsel->percore = config_term_percore(&evsel->config_terms);
-       }
+       if (!evsel)
+               return -ENOMEM;
+
+       evsel->pmu_name = name ? strdup(name) : NULL;
+       evsel->use_uncore_alias = use_uncore_alias;
+       evsel->percore = config_term_percore(&evsel->config_terms);
 
-       return evsel ? 0 : -ENOMEM;
+       if (parse_state->fake_pmu)
+               return 0;
+
+       evsel->unit = info.unit;
+       evsel->scale = info.scale;
+       evsel->per_pkg = info.per_pkg;
+       evsel->snapshot = info.snapshot;
+       evsel->metric_expr = info.metric_expr;
+       evsel->metric_name = info.metric_name;
+       return 0;
 }
 
 int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
@@ -1794,6 +1799,8 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
                if (*str == 'u') {
                        if (!exclude)
                                exclude = eu = ek = eh = 1;
+                       if (!exclude_GH && !perf_guest)
+                               eG = 1;
                        eu = 0;
                } else if (*str == 'k') {
                        if (!exclude)
index b9fb91f..645bf4f 100644 (file)
@@ -511,7 +511,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc
        list = alloc_list();
        ABORT_ON(!list);
        err = parse_events_add_breakpoint(list, &parse_state->idx,
-                                       (void *) $2, $6, $4);
+                                       (void *)(uintptr_t) $2, $6, $4);
        free($6);
        if (err) {
                free(list);
@@ -528,7 +528,7 @@ PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc
        list = alloc_list();
        ABORT_ON(!list);
        if (parse_events_add_breakpoint(list, &parse_state->idx,
-                                               (void *) $2, NULL, $4)) {
+                                               (void *)(uintptr_t) $2, NULL, $4)) {
                free(list);
                YYABORT;
        }
@@ -544,7 +544,7 @@ PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc
        list = alloc_list();
        ABORT_ON(!list);
        err = parse_events_add_breakpoint(list, &parse_state->idx,
-                                       (void *) $2, $4, 0);
+                                       (void *)(uintptr_t) $2, $4, 0);
        free($4);
        if (err) {
                free(list);
@@ -561,7 +561,7 @@ PE_PREFIX_MEM PE_VALUE sep_dc
        list = alloc_list();
        ABORT_ON(!list);
        if (parse_events_add_breakpoint(list, &parse_state->idx,
-                                               (void *) $2, NULL, 0)) {
+                                               (void *)(uintptr_t) $2, NULL, 0)) {
                free(list);
                YYABORT;
        }
index ffbc9d3..7a5f037 100644 (file)
@@ -87,7 +87,7 @@ static int perf_session__process_compressed_event(struct perf_session *session,
                session->decomp_last = decomp;
        }
 
-       pr_debug("decomp (B): %ld to %ld\n", src_size, decomp_size);
+       pr_debug("decomp (B): %zd to %zd\n", src_size, decomp_size);
 
        return 0;
 }
index 57d0706..493ec37 100644 (file)
@@ -117,7 +117,7 @@ static void aggr_printout(struct perf_stat_config *config,
                                cpu_map__id_to_die(id),
                                config->csv_output ? 0 : -3,
                                cpu_map__id_to_cpu(id), config->csv_sep);
-               } else {
+               } else if (id > -1) {
                        fprintf(config->output, "CPU%*d%s",
                                config->csv_output ? 0 : -7,
                                evsel__cpus(evsel)->map[id],
index f8778cf..aa3bed4 100644 (file)
@@ -113,6 +113,7 @@ struct perf_stat_config {
        bool                     summary;
        bool                     metric_no_group;
        bool                     metric_no_merge;
+       bool                     stop_read_counter;
        FILE                    *output;
        unsigned int             interval;
        unsigned int             timeout;
index 1f5fcb8..5151a8c 100644 (file)
@@ -663,6 +663,7 @@ static bool symbol__is_idle(const char *name)
                "exit_idle",
                "mwait_idle",
                "mwait_idle_with_hints",
+               "mwait_idle_with_hints.constprop.0",
                "poll_idle",
                "ppc64_runlatch_off",
                "pseries_dedicated_idle_sleep",
index d220239..48dd2b0 100644 (file)
@@ -99,7 +99,7 @@ size_t zstd_decompress_stream(struct zstd_data *data, void *src, size_t src_size
        while (input.pos < input.size) {
                ret = ZSTD_decompressStream(data->dstream, &output, &input);
                if (ZSTD_isError(ret)) {
-                       pr_err("failed to decompress (B): %ld -> %ld, dst_size %ld : %s\n",
+                       pr_err("failed to decompress (B): %zd -> %zd, dst_size %zd : %s\n",
                               src_size, output.size, dst_size, ZSTD_getErrorName(ret));
                        break;
                }
index 1bb204c..9a0946d 100644 (file)
@@ -6,7 +6,6 @@ test_lpm_map
 test_tag
 FEATURE-DUMP.libbpf
 fixdep
-test_align
 test_dev_cgroup
 /test_progs*
 test_tcpbpf_user
index a83b582..fc946b7 100644 (file)
@@ -32,7 +32,7 @@ LDLIBS += -lcap -lelf -lz -lrt -lpthread
 
 # Order correspond to 'make run_tests' order
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
-       test_align test_verifier_log test_dev_cgroup test_tcpbpf_user \
+       test_verifier_log test_dev_cgroup test_tcpbpf_user \
        test_sock test_btf test_sockmap get_cgroup_id_user test_socket_cookie \
        test_cgroup_storage \
        test_netcnt test_tcpnotify_user test_sock_fields test_sysctl \
index 7afa416..284d592 100644 (file)
@@ -159,15 +159,15 @@ void test_bpf_obj_id(void)
                /* Check getting link info */
                info_len = sizeof(struct bpf_link_info) * 2;
                bzero(&link_infos[i], info_len);
-               link_infos[i].raw_tracepoint.tp_name = (__u64)&tp_name;
+               link_infos[i].raw_tracepoint.tp_name = ptr_to_u64(&tp_name);
                link_infos[i].raw_tracepoint.tp_name_len = sizeof(tp_name);
                err = bpf_obj_get_info_by_fd(bpf_link__fd(links[i]),
                                             &link_infos[i], &info_len);
                if (CHECK(err ||
                          link_infos[i].type != BPF_LINK_TYPE_RAW_TRACEPOINT ||
                          link_infos[i].prog_id != prog_infos[i].id ||
-                         link_infos[i].raw_tracepoint.tp_name != (__u64)&tp_name ||
-                         strcmp((char *)link_infos[i].raw_tracepoint.tp_name,
+                         link_infos[i].raw_tracepoint.tp_name != ptr_to_u64(&tp_name) ||
+                         strcmp(u64_to_ptr(link_infos[i].raw_tracepoint.tp_name),
                                 "sys_enter") ||
                          info_len != sizeof(struct bpf_link_info),
                          "get-link-info(fd)",
@@ -178,7 +178,7 @@ void test_bpf_obj_id(void)
                          link_infos[i].type, BPF_LINK_TYPE_RAW_TRACEPOINT,
                          link_infos[i].id,
                          link_infos[i].prog_id, prog_infos[i].id,
-                         (char *)link_infos[i].raw_tracepoint.tp_name,
+                         (const char *)u64_to_ptr(link_infos[i].raw_tracepoint.tp_name),
                          "sys_enter"))
                        goto done;
 
index cb33a7e..39fb81d 100644 (file)
@@ -12,15 +12,16 @@ void btf_dump_printf(void *ctx, const char *fmt, va_list args)
 static struct btf_dump_test_case {
        const char *name;
        const char *file;
+       bool known_ptr_sz;
        struct btf_dump_opts opts;
 } btf_dump_test_cases[] = {
-       {"btf_dump: syntax", "btf_dump_test_case_syntax", {}},
-       {"btf_dump: ordering", "btf_dump_test_case_ordering", {}},
-       {"btf_dump: padding", "btf_dump_test_case_padding", {}},
-       {"btf_dump: packing", "btf_dump_test_case_packing", {}},
-       {"btf_dump: bitfields", "btf_dump_test_case_bitfields", {}},
-       {"btf_dump: multidim", "btf_dump_test_case_multidim", {}},
-       {"btf_dump: namespacing", "btf_dump_test_case_namespacing", {}},
+       {"btf_dump: syntax", "btf_dump_test_case_syntax", true, {}},
+       {"btf_dump: ordering", "btf_dump_test_case_ordering", false, {}},
+       {"btf_dump: padding", "btf_dump_test_case_padding", true, {}},
+       {"btf_dump: packing", "btf_dump_test_case_packing", true, {}},
+       {"btf_dump: bitfields", "btf_dump_test_case_bitfields", true, {}},
+       {"btf_dump: multidim", "btf_dump_test_case_multidim", false, {}},
+       {"btf_dump: namespacing", "btf_dump_test_case_namespacing", false, {}},
 };
 
 static int btf_dump_all_types(const struct btf *btf,
@@ -62,6 +63,18 @@ static int test_btf_dump_case(int n, struct btf_dump_test_case *t)
                goto done;
        }
 
+       /* tests with t->known_ptr_sz have no "long" or "unsigned long" type,
+        * so it's impossible to determine correct pointer size; but if they
+        * do, it should be 8 regardless of host architecture, becaues BPF
+        * target is always 64-bit
+        */
+       if (!t->known_ptr_sz) {
+               btf__set_pointer_size(btf, 8);
+       } else {
+               CHECK(btf__pointer_size(btf) != 8, "ptr_sz", "exp %d, got %zu\n",
+                     8, btf__pointer_size(btf));
+       }
+
        snprintf(out_file, sizeof(out_file), "/tmp/%s.output.XXXXXX", t->file);
        fd = mkstemp(out_file);
        if (CHECK(fd < 0, "create_tmp", "failed to create file: %d\n", fd)) {
index b093787..1931a15 100644 (file)
@@ -159,8 +159,8 @@ void test_core_extern(void)
                exp = (uint64_t *)&t->data;
                for (j = 0; j < n; j++) {
                        CHECK(got[j] != exp[j], "check_res",
-                             "result #%d: expected %lx, but got %lx\n",
-                              j, exp[j], got[j]);
+                             "result #%d: expected %llx, but got %llx\n",
+                              j, (__u64)exp[j], (__u64)got[j]);
                }
 cleanup:
                test_core_extern__destroy(skel);
index 084ed26..a54eafc 100644 (file)
                .union_sz = sizeof(((type *)0)->union_field),           \
                .arr_sz = sizeof(((type *)0)->arr_field),               \
                .arr_elem_sz = sizeof(((type *)0)->arr_field[0]),       \
-               .ptr_sz = sizeof(((type *)0)->ptr_field),               \
-               .enum_sz = sizeof(((type *)0)->enum_field),     \
+               .ptr_sz = 8, /* always 8-byte pointer for BPF */        \
+               .enum_sz = sizeof(((type *)0)->enum_field),             \
        }
 
 #define SIZE_CASE(name) {                                              \
@@ -432,20 +432,20 @@ static struct core_reloc_test_case test_cases[] = {
                .sb4 = -1,
                .sb20 = -0x17654321,
                .u32 = 0xBEEF,
-               .s32 = -0x3FEDCBA987654321,
+               .s32 = -0x3FEDCBA987654321LL,
        }),
        BITFIELDS_CASE(bitfields___bitfield_vs_int, {
-               .ub1 = 0xFEDCBA9876543210,
+               .ub1 = 0xFEDCBA9876543210LL,
                .ub2 = 0xA6,
-               .ub7 = -0x7EDCBA987654321,
-               .sb4 = -0x6123456789ABCDE,
-               .sb20 = 0xD00D,
+               .ub7 = -0x7EDCBA987654321LL,
+               .sb4 = -0x6123456789ABCDELL,
+               .sb20 = 0xD00DLL,
                .u32 = -0x76543,
-               .s32 = 0x0ADEADBEEFBADB0B,
+               .s32 = 0x0ADEADBEEFBADB0BLL,
        }),
        BITFIELDS_CASE(bitfields___just_big_enough, {
-               .ub1 = 0xF,
-               .ub2 = 0x0812345678FEDCBA,
+               .ub1 = 0xFLL,
+               .ub2 = 0x0812345678FEDCBALL,
        }),
        BITFIELDS_ERR_CASE(bitfields___err_too_big_bitfield),
 
index a895bfe..197d0d2 100644 (file)
@@ -16,7 +16,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
        __u32 duration = 0, retval;
        struct bpf_map *data_map;
        const int zero = 0;
-       u64 *result = NULL;
+       __u64 *result = NULL;
 
        err = bpf_prog_load(target_obj_file, BPF_PROG_TYPE_UNSPEC,
                            &pkt_obj, &pkt_fd);
@@ -29,7 +29,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
 
        link = calloc(sizeof(struct bpf_link *), prog_cnt);
        prog = calloc(sizeof(struct bpf_program *), prog_cnt);
-       result = malloc((prog_cnt + 32 /* spare */) * sizeof(u64));
+       result = malloc((prog_cnt + 32 /* spare */) * sizeof(__u64));
        if (CHECK(!link || !prog || !result, "alloc_memory",
                  "failed to alloc memory"))
                goto close_prog;
@@ -72,7 +72,7 @@ static void test_fexit_bpf2bpf_common(const char *obj_file,
                goto close_prog;
 
        for (i = 0; i < prog_cnt; i++)
-               if (CHECK(result[i] != 1, "result", "fexit_bpf2bpf failed err %ld\n",
+               if (CHECK(result[i] != 1, "result", "fexit_bpf2bpf failed err %llu\n",
                          result[i]))
                        goto close_prog;
 
index f11f187..cd6dc80 100644 (file)
@@ -591,7 +591,7 @@ void test_flow_dissector(void)
                CHECK_ATTR(tattr.data_size_out != sizeof(flow_keys) ||
                           err || tattr.retval != 1,
                           tests[i].name,
-                          "err %d errno %d retval %d duration %d size %u/%lu\n",
+                          "err %d errno %d retval %d duration %d size %u/%zu\n",
                           err, errno, tattr.retval, tattr.duration,
                           tattr.data_size_out, sizeof(flow_keys));
                CHECK_FLOW_KEYS(tests[i].name, flow_keys, tests[i].keys);
index e3cb62b..9efa7e5 100644 (file)
@@ -5,7 +5,7 @@
 static void test_global_data_number(struct bpf_object *obj, __u32 duration)
 {
        int i, err, map_fd;
-       uint64_t num;
+       __u64 num;
 
        map_fd = bpf_find_map(__func__, obj, "result_number");
        if (CHECK_FAIL(map_fd < 0))
@@ -14,7 +14,7 @@ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
        struct {
                char *name;
                uint32_t key;
-               uint64_t num;
+               __u64 num;
        } tests[] = {
                { "relocate .bss reference",     0, 0 },
                { "relocate .data reference",    1, 42 },
@@ -32,7 +32,7 @@ static void test_global_data_number(struct bpf_object *obj, __u32 duration)
        for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
                err = bpf_map_lookup_elem(map_fd, &tests[i].key, &num);
                CHECK(err || num != tests[i].num, tests[i].name,
-                     "err %d result %lx expected %lx\n",
+                     "err %d result %llx expected %llx\n",
                      err, num, tests[i].num);
        }
 }
index 43d0b55..9c3c5c0 100644 (file)
@@ -21,7 +21,7 @@ void test_mmap(void)
        const long page_size = sysconf(_SC_PAGE_SIZE);
        int err, duration = 0, i, data_map_fd, data_map_id, tmp_fd, rdmap_fd;
        struct bpf_map *data_map, *bss_map;
-       void *bss_mmaped = NULL, *map_mmaped = NULL, *tmp1, *tmp2;
+       void *bss_mmaped = NULL, *map_mmaped = NULL, *tmp0, *tmp1, *tmp2;
        struct test_mmap__bss *bss_data;
        struct bpf_map_info map_info;
        __u32 map_info_sz = sizeof(map_info);
@@ -183,16 +183,23 @@ void test_mmap(void)
 
        /* check some more advanced mmap() manipulations */
 
+       tmp0 = mmap(NULL, 4 * page_size, PROT_READ, MAP_SHARED | MAP_ANONYMOUS,
+                         -1, 0);
+       if (CHECK(tmp0 == MAP_FAILED, "adv_mmap0", "errno %d\n", errno))
+               goto cleanup;
+
        /* map all but last page: pages 1-3 mapped */
-       tmp1 = mmap(NULL, 3 * page_size, PROT_READ, MAP_SHARED,
+       tmp1 = mmap(tmp0, 3 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
                          data_map_fd, 0);
-       if (CHECK(tmp1 == MAP_FAILED, "adv_mmap1", "errno %d\n", errno))
+       if (CHECK(tmp0 != tmp1, "adv_mmap1", "tmp0: %p, tmp1: %p\n", tmp0, tmp1)) {
+               munmap(tmp0, 4 * page_size);
                goto cleanup;
+       }
 
        /* unmap second page: pages 1, 3 mapped */
        err = munmap(tmp1 + page_size, page_size);
        if (CHECK(err, "adv_mmap2", "errno %d\n", errno)) {
-               munmap(tmp1, map_sz);
+               munmap(tmp1, 4 * page_size);
                goto cleanup;
        }
 
@@ -201,7 +208,7 @@ void test_mmap(void)
                    MAP_SHARED | MAP_FIXED, data_map_fd, 0);
        if (CHECK(tmp2 == MAP_FAILED, "adv_mmap3", "errno %d\n", errno)) {
                munmap(tmp1, page_size);
-               munmap(tmp1 + 2*page_size, page_size);
+               munmap(tmp1 + 2*page_size, 2 * page_size);
                goto cleanup;
        }
        CHECK(tmp1 + page_size != tmp2, "adv_mmap4",
@@ -211,7 +218,7 @@ void test_mmap(void)
        tmp2 = mmap(tmp1, 4 * page_size, PROT_READ, MAP_SHARED | MAP_FIXED,
                    data_map_fd, 0);
        if (CHECK(tmp2 == MAP_FAILED, "adv_mmap5", "errno %d\n", errno)) {
-               munmap(tmp1, 3 * page_size); /* unmap page 1 */
+               munmap(tmp1, 4 * page_size); /* unmap page 1 */
                goto cleanup;
        }
        CHECK(tmp1 != tmp2, "adv_mmap6", "tmp1: %p, tmp2: %p\n", tmp1, tmp2);
index dde2b7a..935a294 100644 (file)
@@ -28,7 +28,7 @@ void test_prog_run_xattr(void)
              "err %d errno %d retval %d\n", err, errno, tattr.retval);
 
        CHECK_ATTR(tattr.data_size_out != sizeof(pkt_v4), "data_size_out",
-             "incorrect output size, want %lu have %u\n",
+             "incorrect output size, want %zu have %u\n",
              sizeof(pkt_v4), tattr.data_size_out);
 
        CHECK_ATTR(buf[5] != 0, "overflow",
index c571584..9ff0412 100644 (file)
@@ -309,6 +309,7 @@ static void v4_to_v6(struct sockaddr_storage *ss)
        v6->sin6_addr.s6_addr[10] = 0xff;
        v6->sin6_addr.s6_addr[11] = 0xff;
        memcpy(&v6->sin6_addr.s6_addr[12], &v4.sin_addr.s_addr, 4);
+       memset(&v6->sin6_addr.s6_addr[0], 0, 10);
 }
 
 static int udp_recv_send(int server_fd)
index 25de86a..fafedda 100644 (file)
@@ -81,7 +81,7 @@ void test_skb_ctx(void)
 
        CHECK_ATTR(tattr.ctx_size_out != sizeof(skb),
                   "ctx_size_out",
-                  "incorrect output size, want %lu have %u\n",
+                  "incorrect output size, want %zu have %u\n",
                   sizeof(skb), tattr.ctx_size_out);
 
        for (i = 0; i < 5; i++)
index 25b0685..193002b 100644 (file)
@@ -19,7 +19,7 @@ static int libbpf_debug_print(enum libbpf_print_level level,
        log_buf = va_arg(args, char *);
        if (!log_buf)
                goto out;
-       if (strstr(log_buf, err_str) == 0)
+       if (err_str && strstr(log_buf, err_str) == 0)
                found = true;
 out:
        printf(format, log_buf);
index c75525e..dd324b4 100644 (file)
@@ -44,25 +44,25 @@ void test_varlen(void)
        CHECK_VAL(bss->payload1_len2, size2);
        CHECK_VAL(bss->total1, size1 + size2);
        CHECK(memcmp(bss->payload1, exp_str, size1 + size2), "content_check",
-             "doesn't match!");
+             "doesn't match!\n");
 
        CHECK_VAL(data->payload2_len1, size1);
        CHECK_VAL(data->payload2_len2, size2);
        CHECK_VAL(data->total2, size1 + size2);
        CHECK(memcmp(data->payload2, exp_str, size1 + size2), "content_check",
-             "doesn't match!");
+             "doesn't match!\n");
 
        CHECK_VAL(data->payload3_len1, size1);
        CHECK_VAL(data->payload3_len2, size2);
        CHECK_VAL(data->total3, size1 + size2);
        CHECK(memcmp(data->payload3, exp_str, size1 + size2), "content_check",
-             "doesn't match!");
+             "doesn't match!\n");
 
        CHECK_VAL(data->payload4_len1, size1);
        CHECK_VAL(data->payload4_len2, size2);
        CHECK_VAL(data->total4, size1 + size2);
        CHECK(memcmp(data->payload4, exp_str, size1 + size2), "content_check",
-             "doesn't match!");
+             "doesn't match!\n");
 cleanup:
        test_varlen__destroy(skel);
 }
index 34d8471..69139ed 100644 (file)
@@ -1,5 +1,10 @@
 #include <stdint.h>
 #include <stdbool.h>
+
+void preserce_ptr_sz_fn(long x) {}
+
+#define __bpf_aligned __attribute__((aligned(8)))
+
 /*
  * KERNEL
  */
@@ -444,51 +449,51 @@ struct core_reloc_primitives {
        char a;
        int b;
        enum core_reloc_primitives_enum c;
-       void *d;
-       int (*f)(const char *);
+       void *d __bpf_aligned;
+       int (*f)(const char *) __bpf_aligned;
 };
 
 struct core_reloc_primitives___diff_enum_def {
        char a;
        int b;
-       void *d;
-       int (*f)(const char *);
+       void *d __bpf_aligned;
+       int (*f)(const char *) __bpf_aligned;
        enum {
                X = 100,
                Y = 200,
-       } c; /* inline enum def with differing set of values */
+       } c __bpf_aligned; /* inline enum def with differing set of values */
 };
 
 struct core_reloc_primitives___diff_func_proto {
-       void (*f)(int); /* incompatible function prototype */
-       void *d;
-       enum core_reloc_primitives_enum c;
+       void (*f)(int) __bpf_aligned; /* incompatible function prototype */
+       void *d __bpf_aligned;
+       enum core_reloc_primitives_enum c __bpf_aligned;
        int b;
        char a;
 };
 
 struct core_reloc_primitives___diff_ptr_type {
-       const char * const d; /* different pointee type + modifiers */
-       char a;
+       const char * const d __bpf_aligned; /* different pointee type + modifiers */
+       char a __bpf_aligned;
        int b;
        enum core_reloc_primitives_enum c;
-       int (*f)(const char *);
+       int (*f)(const char *) __bpf_aligned;
 };
 
 struct core_reloc_primitives___err_non_enum {
        char a[1];
        int b;
        int c; /* int instead of enum */
-       void *d;
-       int (*f)(const char *);
+       void *d __bpf_aligned;
+       int (*f)(const char *) __bpf_aligned;
 };
 
 struct core_reloc_primitives___err_non_int {
        char a[1];
-       int *b; /* ptr instead of int */
-       enum core_reloc_primitives_enum c;
-       void *d;
-       int (*f)(const char *);
+       int *b __bpf_aligned; /* ptr instead of int */
+       enum core_reloc_primitives_enum c __bpf_aligned;
+       void *d __bpf_aligned;
+       int (*f)(const char *) __bpf_aligned;
 };
 
 struct core_reloc_primitives___err_non_ptr {
@@ -496,7 +501,7 @@ struct core_reloc_primitives___err_non_ptr {
        int b;
        enum core_reloc_primitives_enum c;
        int d; /* int instead of ptr */
-       int (*f)(const char *);
+       int (*f)(const char *) __bpf_aligned;
 };
 
 /*
@@ -507,7 +512,7 @@ struct core_reloc_mods_output {
 };
 
 typedef const int int_t;
-typedef const char *char_ptr_t;
+typedef const char *char_ptr_t __bpf_aligned;
 typedef const int arr_t[7];
 
 struct core_reloc_mods_substruct {
@@ -523,9 +528,9 @@ typedef struct {
 struct core_reloc_mods {
        int a;
        int_t b;
-       char *c;
+       char *c __bpf_aligned;
        char_ptr_t d;
-       int e[3];
+       int e[3] __bpf_aligned;
        arr_t f;
        struct core_reloc_mods_substruct g;
        core_reloc_mods_substruct_t h;
@@ -535,9 +540,9 @@ struct core_reloc_mods {
 struct core_reloc_mods___mod_swap {
        int b;
        int_t a;
-       char *d;
+       char *d __bpf_aligned;
        char_ptr_t c;
-       int f[3];
+       int f[3] __bpf_aligned;
        arr_t e;
        struct {
                int y;
@@ -555,7 +560,7 @@ typedef arr1_t arr2_t;
 typedef arr2_t arr3_t;
 typedef arr3_t arr4_t;
 
-typedef const char * const volatile fancy_char_ptr_t;
+typedef const char * const volatile fancy_char_ptr_t __bpf_aligned;
 
 typedef core_reloc_mods_substruct_t core_reloc_mods_substruct_tt;
 
@@ -567,7 +572,7 @@ struct core_reloc_mods___typedefs {
        arr4_t e;
        fancy_char_ptr_t d;
        fancy_char_ptr_t c;
-       int3_t b;
+       int3_t b __bpf_aligned;
        int3_t a;
 };
 
@@ -739,19 +744,19 @@ struct core_reloc_bitfields___bit_sz_change {
        int8_t          sb4: 1;         /*  4 ->  1 */
        int32_t         sb20: 30;       /* 20 -> 30 */
        /* non-bitfields */
-       uint16_t        u32;            /* 32 -> 16 */
-       int64_t         s32;            /* 32 -> 64 */
+       uint16_t        u32;                    /* 32 -> 16 */
+       int64_t         s32 __bpf_aligned;      /* 32 -> 64 */
 };
 
 /* turn bitfield into non-bitfield and vice versa */
 struct core_reloc_bitfields___bitfield_vs_int {
        uint64_t        ub1;            /*  3 -> 64 non-bitfield */
        uint8_t         ub2;            /* 20 ->  8 non-bitfield */
-       int64_t         ub7;            /*  7 -> 64 non-bitfield signed */
-       int64_t         sb4;            /*  4 -> 64 non-bitfield signed */
-       uint64_t        sb20;           /* 20 -> 16 non-bitfield unsigned */
-       int32_t         u32: 20;        /* 32 non-bitfield -> 20 bitfield */
-       uint64_t        s32: 60;        /* 32 non-bitfield -> 60 bitfield */
+       int64_t         ub7 __bpf_aligned;      /*  7 -> 64 non-bitfield signed */
+       int64_t         sb4 __bpf_aligned;      /*  4 -> 64 non-bitfield signed */
+       uint64_t        sb20 __bpf_aligned;     /* 20 -> 16 non-bitfield unsigned */
+       int32_t         u32: 20;                /* 32 non-bitfield -> 20 bitfield */
+       uint64_t        s32: 60 __bpf_aligned;  /* 32 non-bitfield -> 60 bitfield */
 };
 
 struct core_reloc_bitfields___just_big_enough {
index 1f1966e..3e6912e 100644 (file)
@@ -54,6 +54,7 @@ SEC("sockops")
 int bpf_testcb(struct bpf_sock_ops *skops)
 {
        char header[sizeof(struct ipv6hdr) + sizeof(struct tcphdr)];
+       struct bpf_sock_ops *reuse = skops;
        struct tcphdr *thdr;
        int good_call_rv = 0;
        int bad_call_rv = 0;
@@ -62,6 +63,46 @@ int bpf_testcb(struct bpf_sock_ops *skops)
        int v = 0;
        int op;
 
+       /* Test reading fields in bpf_sock_ops using single register */
+       asm volatile (
+               "%[reuse] = *(u32 *)(%[reuse] +96)"
+               : [reuse] "+r"(reuse)
+               :);
+
+       asm volatile (
+               "%[op] = *(u32 *)(%[skops] +96)"
+               : [op] "+r"(op)
+               : [skops] "r"(skops)
+               :);
+
+       asm volatile (
+               "r9 = %[skops];\n"
+               "r8 = *(u32 *)(r9 +164);\n"
+               "*(u32 *)(r9 +164) = r8;\n"
+               :: [skops] "r"(skops)
+               : "r9", "r8");
+
+       asm volatile (
+               "r1 = %[skops];\n"
+               "r1 = *(u64 *)(r1 +184);\n"
+               "if r1 == 0 goto +1;\n"
+               "r1 = *(u32 *)(r1 +4);\n"
+               :: [skops] "r"(skops):"r1");
+
+       asm volatile (
+               "r9 = %[skops];\n"
+               "r9 = *(u64 *)(r9 +184);\n"
+               "if r9 == 0 goto +1;\n"
+               "r9 = *(u32 *)(r9 +4);\n"
+               :: [skops] "r"(skops):"r9");
+
+       asm volatile (
+               "r1 = %[skops];\n"
+               "r2 = *(u64 *)(r1 +184);\n"
+               "if r2 == 0 goto +1;\n"
+               "r2 = *(u32 *)(r2 +4);\n"
+               :: [skops] "r"(skops):"r1", "r2");
+
        op = (int) skops->op;
 
        update_event_map(op);
index cd4b72c..913acdf 100644 (file)
@@ -15,9 +15,9 @@ int test_pid = 0;
 bool capture = false;
 
 /* .bss */
-long payload1_len1 = 0;
-long payload1_len2 = 0;
-long total1 = 0;
+__u64 payload1_len1 = 0;
+__u64 payload1_len2 = 0;
+__u64 total1 = 0;
 char payload1[MAX_LEN + MAX_LEN] = {};
 
 /* .data */
index 305fae8..c75fc64 100644 (file)
@@ -3883,7 +3883,7 @@ static int test_big_btf_info(unsigned int test_num)
        info_garbage.garbage = 0;
        err = bpf_obj_get_info_by_fd(btf_fd, info, &info_len);
        if (CHECK(err || info_len != sizeof(*info),
-                 "err:%d errno:%d info_len:%u sizeof(*info):%lu",
+                 "err:%d errno:%d info_len:%u sizeof(*info):%zu",
                  err, errno, info_len, sizeof(*info))) {
                err = -1;
                goto done;
@@ -4094,7 +4094,7 @@ static int do_test_get_info(unsigned int test_num)
        if (CHECK(err || !info.id || info_len != sizeof(info) ||
                  info.btf_size != raw_btf_size ||
                  (ret = memcmp(raw_btf, user_btf, expected_nbytes)),
-                 "err:%d errno:%d info.id:%u info_len:%u sizeof(info):%lu raw_btf_size:%u info.btf_size:%u expected_nbytes:%u memcmp:%d",
+                 "err:%d errno:%d info.id:%u info_len:%u sizeof(info):%zu raw_btf_size:%u info.btf_size:%u expected_nbytes:%u memcmp:%d",
                  err, errno, info.id, info_len, sizeof(info),
                  raw_btf_size, info.btf_size, expected_nbytes, ret)) {
                err = -1;
@@ -4730,7 +4730,7 @@ ssize_t get_pprint_expected_line(enum pprint_mapv_kind_t mapv_kind,
 
                nexpected_line = snprintf(expected_line, line_size,
                                          "%s%u: {%u,0,%d,0x%x,0x%x,0x%x,"
-                                         "{%lu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s,"
+                                         "{%llu|[%u,%u,%u,%u,%u,%u,%u,%u]},%s,"
                                          "%u,0x%x,[[%d,%d],[%d,%d]]}\n",
                                          percpu_map ? "\tcpu" : "",
                                          percpu_map ? cpu : next_key,
@@ -4738,7 +4738,7 @@ ssize_t get_pprint_expected_line(enum pprint_mapv_kind_t mapv_kind,
                                          v->unused_bits2a,
                                          v->bits28,
                                          v->unused_bits2b,
-                                         v->ui64,
+                                         (__u64)v->ui64,
                                          v->ui8a[0], v->ui8a[1],
                                          v->ui8a[2], v->ui8a[3],
                                          v->ui8a[4], v->ui8a[5],
index 754cf61..0d92ebc 100644 (file)
@@ -1274,6 +1274,8 @@ static void __run_parallel(unsigned int tasks,
        pid_t pid[tasks];
        int i;
 
+       fflush(stdout);
+
        for (i = 0; i < tasks; i++) {
                pid[i] = fork();
                if (pid[i] == 0) {
index b1e4dad..22943b5 100644 (file)
@@ -618,7 +618,9 @@ int cd_flavor_subdir(const char *exec_name)
        if (!flavor)
                return 0;
        flavor++;
-       fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
+       if (env.verbosity > VERBOSE_NONE)
+               fprintf(stdout, "Switching to flavor '%s' subdirectory...\n", flavor);
+
        return chdir(flavor);
 }
 
index 6e09bf7..dbb820d 100644 (file)
@@ -135,6 +135,11 @@ static inline __u64 ptr_to_u64(const void *ptr)
        return (__u64) (unsigned long) ptr;
 }
 
+static inline void *u64_to_ptr(__u64 ptr)
+{
+       return (void *) (unsigned long) ptr;
+}
+
 int bpf_find_map(const char *test, struct bpf_object *obj, const char *name);
 int compare_map_keys(int map1_fd, int map2_fd);
 int compare_stack_ips(int smap_fd, int amap_fd, int stack_trace_len);
index 8162c58..b8d14f9 100644 (file)
@@ -40,11 +40,11 @@ static void guest_code(void)
 
        /* Single step test, covers 2 basic instructions and 2 emulated */
        asm volatile("ss_start: "
-                    "xor %%rax,%%rax\n\t"
+                    "xor %%eax,%%eax\n\t"
                     "cpuid\n\t"
                     "movl $0x1a0,%%ecx\n\t"
                     "rdmsr\n\t"
-                    : : : "rax", "ecx");
+                    : : : "eax", "ebx", "ecx", "edx");
 
        /* DR6.BD test */
        asm volatile("bd_start: mov %%dr0, %%rax" : : : "rax");
index 8383eb8..bb7a177 100755 (executable)
@@ -82,7 +82,7 @@ dmesg > "$DMESG"
 ($SHELL -c 'cat <(echo '"$test"') >'"$TRIGGER" 2>/dev/null) || true
 
 # Record and dump the results
-dmesg | diff --changed-group-format='%>' --unchanged-group-format='' "$DMESG" - > "$LOG" || true
+dmesg | comm --nocheck-order -13 "$DMESG" - > "$LOG" || true
 
 cat "$LOG"
 # Check for expected output
index 18c5de5..bf361f3 100755 (executable)
@@ -180,6 +180,8 @@ setup()
                        ;;
                r[12]) ip netns exec $ns sysctl -q -w net.ipv4.ip_forward=1
                       ip netns exec $ns sysctl -q -w net.ipv4.conf.all.send_redirects=1
+                      ip netns exec $ns sysctl -q -w net.ipv4.conf.default.rp_filter=0
+                      ip netns exec $ns sysctl -q -w net.ipv4.conf.all.rp_filter=0
 
                       ip netns exec $ns sysctl -q -w net.ipv6.conf.all.forwarding=1
                       ip netns exec $ns sysctl -q -w net.ipv6.route.mtu_expires=10
index d3e0809..431296c 100755 (executable)
@@ -2,13 +2,18 @@
 # SPDX-License-Identifier: GPL-2.0
 #
 # This tests basic flowtable functionality.
-# Creates following topology:
+# Creates following default topology:
 #
 # Originator (MTU 9000) <-Router1-> MTU 1500 <-Router2-> Responder (MTU 2000)
 # Router1 is the one doing flow offloading, Router2 has no special
 # purpose other than having a link that is smaller than either Originator
 # and responder, i.e. TCPMSS announced values are too large and will still
 # result in fragmentation and/or PMTU discovery.
+#
+# You can check with different Orgininator/Link/Responder MTU eg:
+# nft_flowtable.sh -o8000 -l1500 -r2000
+#
+
 
 # Kselftest framework requirement - SKIP code is 4.
 ksft_skip=4
@@ -21,29 +26,17 @@ ns2out=""
 
 log_netns=$(sysctl -n net.netfilter.nf_log_all_netns)
 
-nft --version > /dev/null 2>&1
-if [ $? -ne 0 ];then
-       echo "SKIP: Could not run test without nft tool"
-       exit $ksft_skip
-fi
-
-ip -Version > /dev/null 2>&1
-if [ $? -ne 0 ];then
-       echo "SKIP: Could not run test without ip tool"
-       exit $ksft_skip
-fi
-
-which nc > /dev/null 2>&1
-if [ $? -ne 0 ];then
-       echo "SKIP: Could not run test without nc (netcat)"
-       exit $ksft_skip
-fi
+checktool (){
+       if ! $1 > /dev/null 2>&1; then
+               echo "SKIP: Could not $2"
+               exit $ksft_skip
+       fi
+}
 
-ip netns add nsr1
-if [ $? -ne 0 ];then
-       echo "SKIP: Could not create net namespace"
-       exit $ksft_skip
-fi
+checktool "nft --version" "run test without nft tool"
+checktool "ip -Version" "run test without ip tool"
+checktool "which nc" "run test without nc (netcat)"
+checktool "ip netns add nsr1" "create net namespace"
 
 ip netns add ns1
 ip netns add ns2
@@ -89,11 +82,41 @@ ip -net nsr2 addr add dead:2::1/64 dev veth1
 # ns2 is going via nsr2 with a smaller mtu, so that TCPMSS announced by both peers
 # is NOT the lowest link mtu.
 
-ip -net nsr1 link set veth0 mtu 9000
-ip -net ns1 link set eth0 mtu 9000
+omtu=9000
+lmtu=1500
+rmtu=2000
+
+usage(){
+       echo "nft_flowtable.sh [OPTIONS]"
+       echo
+       echo "MTU options"
+       echo "   -o originator"
+       echo "   -l link"
+       echo "   -r responder"
+       exit 1
+}
+
+while getopts "o:l:r:" o
+do
+       case $o in
+               o) omtu=$OPTARG;;
+               l) lmtu=$OPTARG;;
+               r) rmtu=$OPTARG;;
+               *) usage;;
+       esac
+done
+
+if ! ip -net nsr1 link set veth0 mtu $omtu; then
+       exit 1
+fi
+
+ip -net ns1 link set eth0 mtu $omtu
+
+if ! ip -net nsr2 link set veth1 mtu $rmtu; then
+       exit 1
+fi
 
-ip -net nsr2 link set veth1 mtu 2000
-ip -net ns2 link set eth0 mtu 2000
+ip -net ns2 link set eth0 mtu $rmtu
 
 # transfer-net between nsr1 and nsr2.
 # these addresses are not used for connections.
@@ -113,7 +136,10 @@ for i in 1 2; do
   ip -net ns$i route add default via 10.0.$i.1
   ip -net ns$i addr add dead:$i::99/64 dev eth0
   ip -net ns$i route add default via dead:$i::1
-  ip netns exec ns$i sysctl net.ipv4.tcp_no_metrics_save=1 > /dev/null
+  if ! ip netns exec ns$i sysctl net.ipv4.tcp_no_metrics_save=1 > /dev/null; then
+       echo "ERROR: Check Originator/Responder values (problem during address addition)"
+       exit 1
+  fi
 
   # don't set ip DF bit for first two tests
   ip netns exec ns$i sysctl net.ipv4.ip_no_pmtu_disc=1 > /dev/null
@@ -147,7 +173,7 @@ table inet filter {
       # as PMTUd is off.
       # This rule is deleted for the last test, when we expect PMTUd
       # to kick in and ensure all packets meet mtu requirements.
-      meta length gt 1500 accept comment something-to-grep-for
+      meta length gt $lmtu accept comment something-to-grep-for
 
       # next line blocks connection w.o. working offload.
       # we only do this for reverse dir, because we expect packets to
@@ -171,15 +197,13 @@ if [ $? -ne 0 ]; then
 fi
 
 # test basic connectivity
-ip netns exec ns1 ping -c 1 -q 10.0.2.99 > /dev/null
-if [ $? -ne 0 ];then
+if ! ip netns exec ns1 ping -c 1 -q 10.0.2.99 > /dev/null; then
   echo "ERROR: ns1 cannot reach ns2" 1>&2
   bash
   exit 1
 fi
 
-ip netns exec ns2 ping -c 1 -q 10.0.1.99 > /dev/null
-if [ $? -ne 0 ];then
+if ! ip netns exec ns2 ping -c 1 -q 10.0.1.99 > /dev/null; then
   echo "ERROR: ns2 cannot reach ns1" 1>&2
   exit 1
 fi
@@ -196,7 +220,6 @@ ns2out=$(mktemp)
 make_file()
 {
        name=$1
-       who=$2
 
        SIZE=$((RANDOM % (1024 * 8)))
        TSIZE=$((SIZE * 1024))
@@ -215,8 +238,7 @@ check_transfer()
        out=$2
        what=$3
 
-       cmp "$in" "$out" > /dev/null 2>&1
-       if [ $? -ne 0 ] ;then
+       if ! cmp "$in" "$out" > /dev/null 2>&1; then
                echo "FAIL: file mismatch for $what" 1>&2
                ls -l "$in"
                ls -l "$out"
@@ -243,17 +265,21 @@ test_tcp_forwarding_ip()
 
        sleep 3
 
-       kill $lpid
-       kill $cpid
+       if ps -p $lpid > /dev/null;then
+               kill $lpid
+       fi
+
+       if ps -p $cpid > /dev/null;then
+               kill $cpid
+       fi
+
        wait
 
-       check_transfer "$ns1in" "$ns2out" "ns1 -> ns2"
-       if [ $? -ne 0 ];then
+       if ! check_transfer "$ns1in" "$ns2out" "ns1 -> ns2"; then
                lret=1
        fi
 
-       check_transfer "$ns2in" "$ns1out" "ns1 <- ns2"
-       if [ $? -ne 0 ];then
+       if ! check_transfer "$ns2in" "$ns1out" "ns1 <- ns2"; then
                lret=1
        fi
 
@@ -282,13 +308,12 @@ test_tcp_forwarding_nat()
        return $lret
 }
 
-make_file "$ns1in" "ns1"
-make_file "$ns2in" "ns2"
+make_file "$ns1in"
+make_file "$ns2in"
 
 # First test:
 # No PMTU discovery, nsr1 is expected to fragment packets from ns1 to ns2 as needed.
-test_tcp_forwarding ns1 ns2
-if [ $? -eq 0 ] ;then
+if test_tcp_forwarding ns1 ns2; then
        echo "PASS: flow offloaded for ns1/ns2"
 else
        echo "FAIL: flow offload for ns1/ns2:" 1>&2
@@ -319,9 +344,7 @@ table ip nat {
 }
 EOF
 
-test_tcp_forwarding_nat ns1 ns2
-
-if [ $? -eq 0 ] ;then
+if test_tcp_forwarding_nat ns1 ns2; then
        echo "PASS: flow offloaded for ns1/ns2 with NAT"
 else
        echo "FAIL: flow offload for ns1/ns2 with NAT" 1>&2
@@ -333,8 +356,7 @@ fi
 # Same as second test, but with PMTU discovery enabled.
 handle=$(ip netns exec nsr1 nft -a list table inet filter | grep something-to-grep-for | cut -d \# -f 2)
 
-ip netns exec nsr1 nft delete rule inet filter forward $handle
-if [ $? -ne 0 ] ;then
+if ! ip netns exec nsr1 nft delete rule inet filter forward $handle; then
        echo "FAIL: Could not delete large-packet accept rule"
        exit 1
 fi
@@ -342,8 +364,7 @@ fi
 ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
 ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null
 
-test_tcp_forwarding_nat ns1 ns2
-if [ $? -eq 0 ] ;then
+if test_tcp_forwarding_nat ns1 ns2; then
        echo "PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery"
 else
        echo "FAIL: flow offload for ns1/ns2 with NAT and pmtu discovery" 1>&2
@@ -389,8 +410,7 @@ ip -net ns2 route del 192.168.10.1 via 10.0.2.1
 ip -net ns2 route add default via 10.0.2.1
 ip -net ns2 route add default via dead:2::1
 
-test_tcp_forwarding ns1 ns2
-if [ $? -eq 0 ] ;then
+if test_tcp_forwarding ns1 ns2; then
        echo "PASS: ipsec tunnel mode for ns1/ns2"
 else
        echo "FAIL: ipsec tunnel mode for ns1/ns2"
index 91c775c..aac4a59 100644 (file)
@@ -2,6 +2,7 @@
 hugetlb_vs_thp_test
 subpage_prot
 tempfile
+prot_sao
 segv_errors
 wild_bctr
 large_vm_fork_separation
index 250ce17..defe488 100644 (file)
@@ -2,7 +2,7 @@
 noarg:
        $(MAKE) -C ../
 
-TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot segv_errors wild_bctr \
+TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors wild_bctr \
                  large_vm_fork_separation bad_accesses pkey_exec_prot \
                  pkey_siginfo stack_expansion_signal stack_expansion_ldst
 
@@ -14,6 +14,8 @@ include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c ../utils.c
 
+$(OUTPUT)/prot_sao: ../utils.c
+
 $(OUTPUT)/wild_bctr: CFLAGS += -m64
 $(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64
 $(OUTPUT)/bad_accesses: CFLAGS += -m64
diff --git a/tools/testing/selftests/powerpc/mm/prot_sao.c b/tools/testing/selftests/powerpc/mm/prot_sao.c
new file mode 100644 (file)
index 0000000..e0cf8eb
--- /dev/null
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2016, Michael Ellerman, IBM Corp.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+
+#include <asm/cputable.h>
+
+#include "utils.h"
+
+#define SIZE (64 * 1024)
+
+int test_prot_sao(void)
+{
+       char *p;
+
+       /* SAO was introduced in 2.06 and removed in 3.1 */
+       SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06) ||
+               have_hwcap2(PPC_FEATURE2_ARCH_3_1));
+
+       /*
+        * Ensure we can ask for PROT_SAO.
+        * We can't really verify that it does the right thing, but at least we
+        * confirm the kernel will accept it.
+        */
+       p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE | PROT_SAO,
+                MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+       FAIL_IF(p == MAP_FAILED);
+
+       /* Write to the mapping, to at least cause a fault */
+       memset(p, 0xaa, SIZE);
+
+       return 0;
+}
+
+int main(void)
+{
+       return test_harness(test_prot_sao, "prot-sao");
+}
index 7656c7c..0e73a16 100644 (file)
@@ -13,6 +13,7 @@ DESTRUCTIVE_TESTS = alarmtimer-suspend valid-adjtimex adjtick change_skew \
 
 TEST_GEN_PROGS_EXTENDED = $(DESTRUCTIVE_TESTS)
 
+TEST_FILES := settings
 
 include ../lib.mk
 
diff --git a/tools/testing/selftests/timers/settings b/tools/testing/selftests/timers/settings
new file mode 100644 (file)
index 0000000..e7b9417
--- /dev/null
@@ -0,0 +1 @@
+timeout=0
index c41f24b..65c141e 100644 (file)
@@ -462,6 +462,17 @@ static int test_vsys_x(void)
        return 0;
 }
 
+/*
+ * Debuggers expect ptrace() to be able to peek at the vsyscall page.
+ * Use process_vm_readv() as a proxy for ptrace() to test this.  We
+ * want it to work in the vsyscall=emulate case and to fail in the
+ * vsyscall=xonly case.
+ *
+ * It's worth noting that this ABI is a bit nutty.  write(2) can't
+ * read from the vsyscall page on any kernel version or mode.  The
+ * fact that ptrace() ever worked was a nice courtesy of old kernels,
+ * but the code to support it is fairly gross.
+ */
 static int test_process_vm_readv(void)
 {
 #ifdef __x86_64__
@@ -477,8 +488,12 @@ static int test_process_vm_readv(void)
        remote.iov_len = 4096;
        ret = process_vm_readv(getpid(), &local, 1, &remote, 1, 0);
        if (ret != 4096) {
-               printf("[OK]\tprocess_vm_readv() failed (ret = %d, errno = %d)\n", ret, errno);
-               return 0;
+               /*
+                * We expect process_vm_readv() to work if and only if the
+                * vsyscall page is readable.
+                */
+               printf("[%s]\tprocess_vm_readv() failed (ret = %d, errno = %d)\n", vsyscall_map_r ? "FAIL" : "OK", ret, errno);
+               return vsyscall_map_r ? 1 : 0;
        }
 
        if (vsyscall_map_r) {
@@ -488,6 +503,9 @@ static int test_process_vm_readv(void)
                        printf("[FAIL]\tIt worked but returned incorrect data\n");
                        return 1;
                }
+       } else {
+               printf("[FAIL]\tprocess_rm_readv() succeeded, but it should have failed in this configuration\n");
+               return 1;
        }
 #endif
 
diff --git a/tools/usb/Build b/tools/usb/Build
new file mode 100644 (file)
index 0000000..2ad6f97
--- /dev/null
@@ -0,0 +1,2 @@
+testusb-y += testusb.o
+ffs-test-y += ffs-test.o
index 01d758d..1b128e5 100644 (file)
@@ -1,14 +1,51 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for USB tools
+include ../scripts/Makefile.include
 
-PTHREAD_LIBS = -lpthread
-WARNINGS = -Wall -Wextra
-CFLAGS = $(WARNINGS) -g -I../include
-LDFLAGS = $(PTHREAD_LIBS)
+bindir ?= /usr/bin
 
-all: testusb ffs-test
-%: %.c
-       $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+endif
+
+# Do not use make's built-in rules
+# (this improves performance and avoids hard-to-debug behaviour);
+MAKEFLAGS += -r
+
+override CFLAGS += -O2 -Wall -Wextra -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(srctree)/tools/include
+override LDFLAGS += -lpthread
+
+ALL_TARGETS := testusb ffs-test
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
+
+all: $(ALL_PROGRAMS)
+
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
+
+TESTUSB_IN := $(OUTPUT)testusb-in.o
+$(TESTUSB_IN): FORCE
+       $(Q)$(MAKE) $(build)=testusb
+$(OUTPUT)testusb: $(TESTUSB_IN)
+       $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+
+FFS_TEST_IN := $(OUTPUT)ffs-test-in.o
+$(FFS_TEST_IN): FORCE
+       $(Q)$(MAKE) $(build)=ffs-test
+$(OUTPUT)ffs-test: $(FFS_TEST_IN)
+       $(QUIET_LINK)$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
 
 clean:
-       $(RM) testusb ffs-test
+       rm -f $(ALL_PROGRAMS)
+       find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete -o -name '\.*.o.cmd' -delete
+
+install: $(ALL_PROGRAMS)
+       install -d -m 755 $(DESTDIR)$(bindir);          \
+       for program in $(ALL_PROGRAMS); do              \
+               install $$program $(DESTDIR)$(bindir);  \
+       done
+
+FORCE:
+
+.PHONY: all install clean FORCE prepare
index 737666d..cf88233 100644 (file)
@@ -482,7 +482,8 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
         * count is also read inside the mmu_lock critical section.
         */
        kvm->mmu_notifier_count++;
-       need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end);
+       need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end,
+                                            range->flags);
        need_tlb_flush |= kvm->tlbs_dirty;
        /* we've to flush the tlb before the pages can be freed */
        if (need_tlb_flush)
@@ -4331,7 +4332,7 @@ int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
 void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
                               struct kvm_io_device *dev)
 {
-       int i;
+       int i, j;
        struct kvm_io_bus *new_bus, *bus;
 
        bus = kvm_get_bus(kvm, bus_idx);
@@ -4348,17 +4349,20 @@ void kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
 
        new_bus = kmalloc(struct_size(bus, range, bus->dev_count - 1),
                          GFP_KERNEL_ACCOUNT);
-       if (!new_bus)  {
+       if (new_bus) {
+               memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range));
+               new_bus->dev_count--;
+               memcpy(new_bus->range + i, bus->range + i + 1,
+                      (new_bus->dev_count - i) * sizeof(struct kvm_io_range));
+       } else {
                pr_err("kvm: failed to shrink bus, removing it completely\n");
-               goto broken;
+               for (j = 0; j < bus->dev_count; j++) {
+                       if (j == i)
+                               continue;
+                       kvm_iodevice_destructor(bus->range[j].dev);
+               }
        }
 
-       memcpy(new_bus, bus, sizeof(*bus) + i * sizeof(struct kvm_io_range));
-       new_bus->dev_count--;
-       memcpy(new_bus->range + i, bus->range + i + 1,
-              (new_bus->dev_count - i) * sizeof(struct kvm_io_range));
-
-broken:
        rcu_assign_pointer(kvm->buses[bus_idx], new_bus);
        synchronize_srcu_expedited(&kvm->srcu);
        kfree(bus);