Compare
7afc36c92a2812de36ec2e15a6f281fca081beab..7cbaa0f4579f48e92639c6abb761fdef8fbade47
entry: Account the deferred hrtimer rearm as hardirq context for lockdep
On a desktop debug kernel (PROVE_LOCKING, KASAN, LOCKDEP_CHAINS_BITS=19)
lockdep switches itself off after about two days of uptime with
"BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!", and locking is not validated
until the next reboot. In the last such boot the pool ran out after 46.6
hours, and a fifth of it, 533509 of 2621431 chain hlocks in 63838 of
344717 chains, had been created by the deferred hrtimer rearm on return
from interrupt.
Make lockdep account that rearm as part of the timer interrupt it
belongs to.
Commit 15dd3a948855
("hrtimer: Push reprogramming timers into the interrupt return path")
moved the reprogramming of the clock event device out of the timer
interrupt into the interrupt return path. On return to kernel mode
irqentry_exit_to_kernel_mode_after_preempt() performs it after
irq_exit_rcu() has already left lockdep's hardirq context. lockdep
therefore records hrtimer_bases.lock and the timekeeper sequence count
as taken by the interrupted context, on top of the locks that context
holds, and every distinct held-lock stack an interrupt hits adds two
lock chains. When the rearm runs from irq_enter_rcu() or
__irq_exit_rcu() it is still inside lockdep's hardirq context, and there
the same acquisitions reuse one pair of chains.
The dependencies recorded on the return path are "lock held with
interrupts enabled -> hrtimer_bases.lock". Such a lock is hardirq-unsafe
and hrtimer_bases.lock is hardirq-safe, so a path in the reverse
direction is already reported by the irq-safety checks without these
edges.
Re-enter lockdep's hardirq context around the rearm on the kernel return
path. The return to user mode path holds no locks and is left alone, as
is the rearm in __schedule(), which runs under the runqueue lock.
With the same kernel tree, configuration and workload, one hour of
uptime including a full kernel build, the chains of this shape, with
hrtimer_bases.lock and optionally the timekeeper sequence count on top
of a held-lock stack outside the scheduler, go from 13266 (96187 chain
hlocks, 15.9% of those in use) to 4. Those 4 come from clock_was_set(),
which takes cpus_read_lock() and each CPU's hrtimer_bases.lock and reads
the clock under it.
Fixes: 15dd3a948855 ("hrtimer: Push reprogramming timers into the interrupt return path")
Signed-off-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20261013071318.33300-1-mikhail.v.gavrilov@gmail.com
Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com> · 2026-10-13 07:13 UTC · committed by Peter Zijlstra
663 files changed,
+7869
−3795
- .get_maintainer.ignore
- .mailmap
- Documentation/ABI/testing/sysfs-devices-platform-trackpoint
- Documentation/admin-guide/ext4.rst
- Documentation/admin-guide/kernel-parameters.txt
- Documentation/arch/arm64/booting.rst
- Documentation/arch/arm64/memory-tagging-extension.rst
- Documentation/arch/arm64/silicon-errata.rst
- Documentation/arch/s390/pci.rst
- Documentation/bpf/kfuncs.rst
- Documentation/devicetree/bindings/display/msm/qcom,qcs8300-mdss.yaml
- Documentation/devicetree/bindings/display/msm/qcom,sar2130p-mdss.yaml
- Documentation/devicetree/bindings/display/msm/qcom,sm6150-dpu.yaml
- Documentation/devicetree/bindings/display/msm/qcom,sm8350-mdss.yaml
- Documentation/devicetree/bindings/display/msm/qcom,x1e80100-mdss.yaml
- Documentation/devicetree/bindings/iio/adc/rockchip-saradc.yaml
- Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml
- Documentation/devicetree/bindings/pinctrl/qcom,nord-tlmm.yaml
- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
- Documentation/filesystems/netfs_library.rst
- Documentation/filesystems/propagate_umount.txt
- Documentation/filesystems/sharedsubtree.rst
- Documentation/hwmon/cgbc-hwmon.rst
- Documentation/netlink/specs/netdev.yaml
- Documentation/netlink/specs/rt-neigh.yaml
- Documentation/networking/ip-sysctl.rst
- Documentation/networking/strparser.rst
- Documentation/trace/events-landlock.rst
- MAINTAINERS
- Makefile
- arch/arc/Kconfig
- arch/arc/include/asm/atomic64-arcv2.h
- arch/arc/include/asm/cmpxchg.h
- arch/arc/kernel/setup.c
- arch/arc/kernel/smp.c
- arch/arm/mach-socfpga/Kconfig
- arch/arm64/Kconfig
- arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dtsi
- arch/arm64/boot/dts/altera/socfpga_stratix10_socdk_emmc.dts
- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts
- arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts
- arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi
- arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
- arch/arm64/boot/dts/freescale/imx8mp-var-dart-sonata.dts
- arch/arm64/boot/dts/qcom/x1-microsoft-denali.dtsi
- arch/arm64/boot/dts/renesas/r8a779f0.dtsi
- arch/arm64/boot/dts/renesas/r9a09g047.dtsi
- arch/arm64/boot/dts/renesas/r9a09g056.dtsi
- arch/arm64/boot/dts/renesas/r9a09g057.dtsi
- arch/arm64/boot/dts/renesas/r9a09g077.dtsi
- arch/arm64/boot/dts/renesas/r9a09g087.dtsi
- arch/arm64/include/asm/el2_setup.h
- arch/arm64/include/asm/io.h
- arch/arm64/include/asm/kvm_host.h
- arch/arm64/include/asm/kvm_nested.h
- arch/arm64/include/asm/kvm_pkvm.h
- arch/arm64/include/asm/percpu.h
- arch/arm64/kernel/Makefile
- arch/arm64/kernel/cpu_errata.c
- arch/arm64/kernel/cpufeature.c
- arch/arm64/kernel/hibernate-asm.S
- arch/arm64/kernel/hibernate.c
- arch/arm64/kernel/mte.c
- arch/arm64/kernel/pi/idreg-override.c
- arch/arm64/kernel/signal.c
- arch/arm64/kernel/topology.c
- arch/arm64/kernel/vdso/Makefile
- arch/arm64/kvm/arm.c
- arch/arm64/kvm/emulate-nested.c
- arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
- arch/arm64/kvm/hyp/include/nvhe/mm.h
- arch/arm64/kvm/hyp/include/nvhe/pkvm.h
- arch/arm64/kvm/hyp/nvhe/hyp-main.c
- arch/arm64/kvm/hyp/nvhe/mem_protect.c
- arch/arm64/kvm/hyp/nvhe/mm.c
- arch/arm64/kvm/hyp/nvhe/pkvm.c
- arch/arm64/kvm/hyp/nvhe/setup.c
- arch/arm64/kvm/hypercalls.c
- arch/arm64/kvm/mmu.c
- arch/arm64/kvm/nested.c
- arch/arm64/kvm/sys_regs.c
- arch/arm64/kvm/vgic/vgic-init.c
- arch/arm64/kvm/vgic/vgic-its.c
- arch/arm64/kvm/vgic/vgic-v2.c
- arch/arm64/kvm/vgic/vgic-v3.c
- arch/arm64/kvm/vgic/vgic.c
- arch/arm64/mm/mmu.c
- arch/arm64/net/bpf_jit_comp.c
- arch/arm64/tools/cpucaps
- arch/loongarch/net/bpf_jit.c
- arch/loongarch/vdso/Makefile
- arch/mips/Kconfig
- arch/mips/cavium-octeon/octeon-platform.c
- arch/mips/configs/econet_en751221_defconfig
- arch/mips/net/bpf_jit_comp32.c
- arch/mips/net/bpf_jit_comp64.c
- arch/parisc/include/asm/compat_ucontext.h
- arch/parisc/include/asm/thread_info.h
- arch/parisc/kernel/setup.c
- arch/parisc/kernel/unwind.c
- arch/powerpc/kernel/iommu.c
- arch/powerpc/kernel/vdso/Makefile
- arch/powerpc/kvm/book3s_hv.c
- arch/powerpc/kvm/book3s_hv_nested.c
- arch/powerpc/kvm/book3s_hv_uvmem.c
- arch/powerpc/net/bpf_jit_comp.c
- arch/powerpc/perf/imc-pmu.c
- arch/riscv/Kconfig
- arch/riscv/Kconfig.errata
- arch/riscv/Kconfig.socs
- arch/riscv/errata/sifive/errata.c
- arch/riscv/include/asm/cpufeature.h
- arch/riscv/include/asm/csr.h
- arch/riscv/include/asm/errata_list_vendors.h
- arch/riscv/include/asm/futex.h
- arch/riscv/include/asm/insn-def.h
- arch/riscv/include/asm/scs.h
- arch/riscv/include/asm/vector.h
- arch/riscv/include/uapi/asm/vendor/mips.h
- arch/riscv/kernel/cpufeature.c
- arch/riscv/kernel/entry.S
- arch/riscv/kernel/patch.c
- arch/riscv/kernel/ptrace.c
- arch/riscv/kernel/setup.c
- arch/riscv/kernel/smpboot.c
- arch/riscv/kernel/suspend.c
- arch/riscv/kernel/vdso/Makefile
- arch/riscv/kvm/aia_device.c
- arch/riscv/kvm/aia_imsic.c
- arch/riscv/kvm/mmu.c
- arch/riscv/kvm/nacl.c
- arch/riscv/kvm/vcpu.c
- arch/riscv/kvm/vcpu_exit.c
- arch/riscv/kvm/vcpu_onereg.c
- arch/riscv/kvm/vcpu_pmu.c
- arch/riscv/kvm/vcpu_sbi_hsm.c
- arch/riscv/kvm/vcpu_timer.c
- arch/riscv/lib/strnlen.S
- arch/riscv/mm/extable.c
- arch/riscv/net/bpf_jit_comp64.c
- arch/s390/crypto/hmac_s390.c
- arch/s390/include/asm/debug.h
- arch/s390/kernel/debug.c
- arch/s390/kernel/uv.c
- arch/s390/kernel/vdso/Makefile
- arch/s390/kvm/gmap/dat.c
- arch/s390/kvm/gmap/dat.h
- arch/s390/kvm/gmap/gmap.c
- arch/s390/kvm/gmap/kvm_mmu.c
- arch/s390/kvm/gmap/kvm_mmu.h
- arch/s390/kvm/s390/gaccess.c
- arch/s390/kvm/s390/interrupt.c
- arch/s390/kvm/s390/s390.c
- arch/s390/kvm/s390/s390.h
- arch/s390/net/bpf_jit_comp.c
- arch/s390/pci/pci_event.c
- arch/s390/pci/pci_report.c
- arch/s390/pci/pci_report.h
- arch/um/drivers/vector_transports.c
- arch/x86/Kconfig.cpu
- arch/x86/Makefile
- arch/x86/coco/sev/svsm.c
- arch/x86/crypto/aesni-intel_glue.c
- arch/x86/entry/entry_fred.c
- arch/x86/entry/vdso/vdso64/Makefile
- arch/x86/events/amd/brs.c
- arch/x86/events/amd/lbr.c
- arch/x86/events/intel/core.c
- arch/x86/events/intel/ds.c
- arch/x86/events/intel/lbr.c
- arch/x86/events/perf_event.h
- arch/x86/include/asm/cpufeatures.h
- arch/x86/include/asm/div64.h
- arch/x86/include/asm/pgtable.h
- arch/x86/include/asm/text-patching.h
- arch/x86/include/asm/tlb.h
- arch/x86/include/uapi/asm/ptrace-abi.h
- arch/x86/kernel/alternative.c
- arch/x86/kernel/amd_node.c
- arch/x86/kernel/cpu/amd.c
- arch/x86/kernel/cpu/mce/core.c
- arch/x86/kernel/cpu/microcode/intel.c
- arch/x86/kernel/kprobes/core.c
- arch/x86/kernel/sys_x86_64.c
- arch/x86/kvm/mmu/mmu.c
- arch/x86/kvm/pmu.c
- arch/x86/kvm/svm/nested.c
- arch/x86/kvm/svm/sev.c
- arch/x86/kvm/svm/svm.c
- arch/x86/kvm/svm/svm.h
- arch/x86/kvm/vmx/nested.c
- arch/x86/kvm/vmx/pmu_intel.c
- arch/x86/kvm/vmx/tdx.c
- arch/x86/kvm/x86.c
- arch/x86/mm/mem_encrypt.c
- arch/x86/mm/pat/set_memory.c
- arch/x86/mm/pgtable.c
- arch/x86/net/bpf_jit_comp.c
- arch/x86/pci/fixup.c
- arch/x86/um/asm/ptrace.h
- arch/x86/um/ptrace_32.c
- block/blk-cgroup.c
- block/blk-mq.c
- block/blk-zoned.c
- block/fops.c
- block/mq-deadline.c
- crypto/aes.c
- drivers/accessibility/braille/braille_console.c
- drivers/android/binder.c
- drivers/android/binder/node.rs
- drivers/android/binder/node/wrapper.rs
- drivers/android/binder/rust_binderfs.c
- drivers/android/binder/thread.rs
- drivers/android/binderfs.c
- drivers/ata/libahci.c
- drivers/ata/libahci_platform.c
- drivers/ata/libata-core.c
- drivers/ata/libata-scsi.c
- drivers/base/cacheinfo.c
- drivers/block/drbd/drbd_nl_gen.c
- drivers/block/virtio_blk.c
- drivers/block/zloop.c
- drivers/bluetooth/btintel.c
- drivers/bluetooth/btintel_pcie.c
- drivers/bluetooth/btmtk.c
- drivers/bluetooth/btmtksdio.c
- drivers/bluetooth/btmtkuart.c
- drivers/bluetooth/btnxpuart.c
- drivers/bluetooth/btusb.c
- drivers/bluetooth/hci_qca.c
- drivers/char/mem.c
- drivers/char/tpm/tpm-interface.c
- drivers/char/tpm/tpm2-cmd.c
- drivers/char/tpm/tpm2-sessions.c
- drivers/clk/clk-scpi.c
- drivers/clk/qcom/gcc-eliza.c
- drivers/clk/qcom/gcc-hawi.c
- drivers/clk/qcom/gcc-kaanapali.c
- drivers/clk/qcom/gpucc-glymur.c
- drivers/clk/qcom/gpucc-kaanapali.c
- drivers/clk/spacemit/ccu-k3.c
- drivers/clk/ti/composite.c
- drivers/cpufreq/cpufreq.c
- drivers/cpufreq/intel_pstate.c
- drivers/crypto/caam/jr.c
- drivers/dma/dmaengine.c
- drivers/dma/mmp_pdma.c
- drivers/dma/pxa_dma.c
- drivers/dma/sprd-dma.c
- drivers/dma/sun6i-dma.c
- drivers/dma/ti/k3-udma-glue.c
- drivers/dma/xilinx/xilinx_dma.c
- drivers/dpll/dpll_netlink.c
- drivers/edac/altera_edac.c
- drivers/edac/amd64_edac.c
- drivers/edac/versalnet_edac.c
- drivers/firewire/core-cdev.c
- drivers/firmware/arm_ffa/driver.c
- drivers/firmware/arm_scmi/driver.c
- drivers/firmware/arm_scpi.c
- drivers/gpio/gpio-arizona.c
- drivers/gpio/gpio-exar.c
- drivers/gpio/gpio-mpsse.c
- drivers/gpio/gpio-mvebu.c
- drivers/gpio/gpio-tps65219.c
- drivers/gpio/gpio-virtuser.c
- drivers/gpio/gpio-xilinx.c
- drivers/gpio/gpio-zynq.c
- drivers/gpio/gpiolib-cdev.c
- drivers/gpio/gpiolib-of.c
- drivers/gpio/gpiolib-shared.c
- drivers/gpio/gpiolib.c
- drivers/gpu/drm/amd/amdgpu/amdgpu.h
- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
- drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
- drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
- drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
- drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
- drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c
- drivers/gpu/drm/amd/amdgpu/vi.c
- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v11.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
- drivers/gpu/drm/amd/amdkfd/kfd_priv.h
- drivers/gpu/drm/amd/amdkfd/kfd_svm.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_helpers_test.c
- drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
- drivers/gpu/drm/amd/display/dc/dc.h
- drivers/gpu/drm/amd/display/dc/dml/Makefile
- drivers/gpu/drm/amd/display/dc/dml2_0/Makefile
- drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c
- drivers/gpu/drm/amd/display/dc/hwss/dcn50/dcn50_hwseq.c
- drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c
- drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
- drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c
- drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c
- drivers/gpu/drm/amd/display/modules/power/power.c
- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
- drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
- drivers/gpu/drm/ci/xfails/msm-apq8016-fails.txt
- drivers/gpu/drm/i915/display/intel_cursor.c
- drivers/gpu/drm/i915/display/intel_display_params.c
- drivers/gpu/drm/i915/display/intel_display_params.h
- drivers/gpu/drm/i915/display/intel_display_types.h
- drivers/gpu/drm/i915/display/intel_dp_link_caps.c
- drivers/gpu/drm/i915/display/intel_dp_link_training.c
- drivers/gpu/drm/i915/display/intel_dp_mst.c
- drivers/gpu/drm/i915/display/intel_dp_mst.h
- drivers/gpu/drm/i915/display/intel_link_bw.c
- drivers/gpu/drm/i915/display/intel_psr.c
- drivers/gpu/drm/i915/display/intel_quirks.c
- drivers/gpu/drm/i915/display/intel_vrr.c
- drivers/gpu/drm/i915/display/skl_universal_plane.c
- drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
- drivers/gpu/drm/i915/gem/i915_gem_object.c
- drivers/gpu/drm/i915/gt/intel_rps.c
- drivers/gpu/drm/mediatek/mtk_drm_drv.c
- drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c
- drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h
- drivers/gpu/drm/msm/Makefile
- drivers/gpu/drm/msm/adreno/a6xx_gmu.c
- drivers/gpu/drm/msm/adreno/a6xx_gpu.c
- drivers/gpu/drm/msm/adreno/adreno_device.c
- drivers/gpu/drm/msm/adreno/adreno_gpu.c
- drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
- drivers/gpu/drm/msm/dp/dp_display.c
- drivers/gpu/drm/msm/dsi/dsi_host.c
- drivers/gpu/drm/msm/hdmi/hdmi_phy.c
- drivers/gpu/drm/msm/msm_drv.c
- drivers/gpu/drm/msm/msm_fbdev.c
- drivers/gpu/drm/msm/msm_gem.h
- drivers/gpu/drm/msm/msm_gem_vma.c
- drivers/gpu/drm/msm/msm_ringbuffer.c
- drivers/gpu/drm/msm/msm_ringbuffer.h
- drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml
- drivers/gpu/drm/radeon/radeon_bios.c
- drivers/gpu/drm/vc4/vc4_hdmi.c
- drivers/gpu/drm/virtio/virtgpu_plane.c
- drivers/gpu/drm/xe/display/xe_fb_pin.c
- drivers/gpu/drm/xe/regs/xe_gt_regs.h
- drivers/gpu/drm/xe/xe_bo.c
- drivers/gpu/drm/xe/xe_bo.h
- drivers/gpu/drm/xe/xe_gt_throttle.c
- drivers/gpu/drm/xe/xe_guc_ads.c
- drivers/gpu/drm/xe/xe_hw_engine.c
- drivers/gpu/drm/xe/xe_i2c.c
- drivers/gpu/drm/xe/xe_lrc.c
- drivers/gpu/drm/xe/xe_mmio.c
- drivers/gpu/drm/xe/xe_mmio_gem.c
- drivers/gpu/drm/xe/xe_mmio_gem.h
- drivers/gpu/drm/xe/xe_pci_sriov.c
- drivers/gpu/drm/xe/xe_shrinker.c
- drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
- drivers/gpu/drm/xe/xe_tlb_inval.c
- drivers/gpu/drm/xe/xe_vm.c
- drivers/gpu/drm/xe/xe_wa_oob.rules
- drivers/hid/Kconfig
- drivers/hid/amd-sfh-hid/amd_sfh_common.h
- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
- drivers/hid/bpf/hid_bpf_dispatch.c
- drivers/hid/hid-alps.c
- drivers/hid/hid-corsair-void.c
- drivers/hid/hid-elecom.c
- drivers/hid/hid-ids.h
- drivers/hid/hid-logitech-dj.c
- drivers/hid/hid-logitech-hidpp.c
- drivers/hid/hid-multitouch.c
- drivers/hid/hid-oxp.c
- drivers/hid/hid-quirks.c
- drivers/hid/hid-roccat.c
- drivers/hid/hid-steelseries-arctis.c
- drivers/hid/hid-universal-pidff.c
- drivers/hid/hid-winwing.c
- drivers/hid/i2c-hid/i2c-hid-core.c
- drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
- drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
- drivers/hid/wacom_sys.c
- drivers/hwmon/cgbc-hwmon.c
- drivers/hwmon/gpio-fan.c
- drivers/hwmon/hp-wmi-sensors.c
- drivers/hwmon/k10temp.c
- drivers/hwmon/pmbus/pmbus.h
- drivers/hwmon/pmbus/tps53679.c
- drivers/hwmon/pwm-fan.c
- drivers/hwmon/w83791d.c
- drivers/hwmon/w83793.c
- drivers/i2c/busses/i2c-at91-core.c
- drivers/i2c/busses/i2c-at91-master.c
- drivers/i2c/busses/i2c-at91.h
- drivers/i2c/busses/i2c-imx.c
- drivers/i2c/busses/i2c-qcom-cci.c
- drivers/i2c/busses/i2c-qcom-geni.c
- drivers/i2c/busses/i2c-xiic.c
- drivers/i2c/i2c-atr.c
- drivers/iio/accel/kionix-kx022a.c
- drivers/iio/accel/kxcjk-1013.c
- drivers/iio/accel/sca3000.c
- drivers/iio/adc/ad4030.c
- drivers/iio/adc/ad7173.c
- drivers/iio/adc/ad_sigma_delta.c
- drivers/iio/adc/ade9000.c
- drivers/iio/adc/adi-axi-adc.c
- drivers/iio/adc/aspeed_adc.c
- drivers/iio/adc/axp288_adc.c
- drivers/iio/adc/max1363.c
- drivers/iio/adc/pac1934.c
- drivers/iio/adc/rohm-bd79124.c
- drivers/iio/adc/stm32-adc.c
- drivers/iio/adc/sun4i-gpadc-iio.c
- drivers/iio/adc/xilinx-xadc-core.c
- drivers/iio/buffer/industrialio-buffer-dmaengine.c
- drivers/iio/cdc/ad7150.c
- drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
- drivers/iio/dac/mcp47a1.c
- drivers/iio/dac/rohm-bd79703.c
- drivers/iio/frequency/adf4377.c
- drivers/iio/frequency/admv1013.c
- drivers/iio/gyro/adis16136.c
- drivers/iio/health/max30102.c
- drivers/iio/imu/adis16400.c
- drivers/iio/imu/adis16480.c
- drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
- drivers/iio/industrialio-buffer.c
- drivers/iio/industrialio-trigger.c
- drivers/iio/light/gp2ap020a00f.c
- drivers/iio/light/rohm-bu27034.c
- drivers/iio/pressure/bmp280-core.c
- drivers/iio/pressure/rohm-bm1390.c
- drivers/iio/proximity/aw96103.c
- drivers/iio/proximity/isl29501.c
- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
- drivers/iio/proximity/sx9324.c
- drivers/iio/proximity/vcnl3020.c
- drivers/iio/proximity/vl53l0x-i2c.c
- drivers/infiniband/core/iwpm_util.c
- drivers/infiniband/core/mad.c
- drivers/infiniband/core/rdma_core.c
- drivers/infiniband/core/ucma.c
- drivers/infiniband/core/uverbs_flow.c
- drivers/infiniband/core/uverbs_main.c
- drivers/infiniband/core/verbs.c
- drivers/infiniband/hw/bnxt_re/main.c
- drivers/infiniband/hw/bnxt_re/uapi.c
- drivers/infiniband/hw/efa/efa_com.c
- drivers/infiniband/hw/efa/efa_com.h
- drivers/infiniband/hw/efa/efa_main.c
- drivers/infiniband/hw/erdma/erdma_main.c
- drivers/infiniband/hw/erdma/erdma_verbs.c
- drivers/infiniband/hw/hfi1/file_ops.c
- drivers/infiniband/hw/irdma/verbs.c
- drivers/infiniband/hw/mlx4/sysfs.c
- drivers/infiniband/hw/mlx5/main.c
- drivers/infiniband/sw/rxe/rxe_mcast.c
- drivers/infiniband/sw/rxe/rxe_mr.c
- drivers/infiniband/sw/rxe/rxe_odp.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/ulp/ipoib/ipoib.h
- drivers/infiniband/ulp/ipoib/ipoib_ib.c
- drivers/infiniband/ulp/ipoib/ipoib_multicast.c
- drivers/infiniband/ulp/iser/iser_initiator.c
- drivers/infiniband/ulp/isert/ib_isert.c
- drivers/infiniband/ulp/isert/ib_isert.h
- drivers/infiniband/ulp/rtrs/rtrs-clt-trace.h
- drivers/infiniband/ulp/rtrs/rtrs-clt.c
- drivers/infiniband/ulp/rtrs/rtrs-clt.h
- drivers/infiniband/ulp/rtrs/rtrs-srv-trace.h
- drivers/infiniband/ulp/srp/ib_srp.c
- drivers/input/evdev.c
- drivers/input/input-compat.c
- drivers/input/joystick/xpad.c
- drivers/input/keyboard/adp5588-keys.c
- drivers/input/keyboard/atkbd.c
- drivers/input/misc/ati_remote2.c
- drivers/input/misc/soc_button_array.c
- drivers/input/mouse/synaptics.c
- drivers/input/rmi4/rmi_driver.c
- drivers/input/rmi4/rmi_smbus.c
- drivers/input/serio/hp_sdc.c
- drivers/input/serio/i8042-acpipnpio.h
- drivers/input/touchscreen/cyttsp5.c
- drivers/input/touchscreen/eeti_ts.c
- drivers/input/touchscreen/s6sy761.c
- drivers/input/touchscreen/tsc2007_core.c
- drivers/interconnect/qcom/x1e80100.c
- drivers/iommu/dma-iommu.c
- drivers/md/dm-crypt.c
- drivers/md/dm-integrity.c
- drivers/md/dm-ioctl.c
- drivers/md/dm-snap.c
- drivers/media/usb/em28xx/em28xx-video.c
- drivers/memstick/core/memstick.c
- drivers/memstick/core/ms_block.c
- drivers/memstick/host/rtsx_usb_ms.c
- drivers/mmc/core/bus.c
- drivers/mmc/core/host.c
- drivers/mmc/core/sdio_uart.c
- drivers/mmc/host/cavium-octeon.c
- drivers/mmc/host/cavium-thunderx.c
- drivers/mmc/host/mmc_hsq.c
- drivers/mmc/host/mmc_spi.c
- drivers/mmc/host/mmci.c
- drivers/mmc/host/mtk-sd.c
- drivers/mmc/host/mxcmmc.c
- drivers/mmc/host/rtsx_pci_sdmmc.c
- drivers/mmc/host/sdhci-of-aspeed.c
- drivers/mmc/host/sdhci-sprd.c
- drivers/mmc/host/sdhci_am654.c
- drivers/mmc/host/sh_mmcif.c
- drivers/mtd/chips/cfi_cmdset_0001.c
- drivers/mtd/devices/block2mtd.c
- drivers/mtd/devices/mtd_intel_dg.c
- drivers/mtd/mtdcore.c
- drivers/mtd/nand/ecc.c
- drivers/mtd/nand/raw/cadence-nand-controller.c
- drivers/mtd/nand/raw/vf610_nfc.c
- drivers/mtd/nand/spi/core.c
- drivers/mtd/spi-nor/core.c
- drivers/net/amt.c
- drivers/net/bareudp.c
- drivers/net/bonding/bond_main.c
- drivers/net/can/dev/skb.c
- drivers/net/can/usb/f81604.c
- drivers/net/can/vxcan.c
- drivers/net/dsa/microchip/ksz_common.h
- drivers/net/dsa/mt7530-mdio.c
- drivers/net/dsa/mt7530.c
- drivers/net/dsa/mv88e6xxx/chip.c
- drivers/net/dsa/mxl862xx/mxl862xx.c
- drivers/net/ethernet/airoha/airoha_eth.c
- drivers/net/ethernet/airoha/airoha_eth.h
- drivers/net/ethernet/airoha/airoha_npu.c
- drivers/net/ethernet/allwinner/sun4i-emac.c
- drivers/net/ethernet/amazon/ena/ena_netdev.c
- drivers/net/ethernet/atheros/atl1c/atl1c_main.c
- drivers/net/ethernet/atheros/atl1e/atl1e_main.c
- drivers/net/ethernet/atheros/atlx/atl1.c
- drivers/net/ethernet/broadcom/bcmsysport.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.c
- drivers/net/ethernet/broadcom/bnxt/bnxt.h
- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
- drivers/net/ethernet/broadcom/genet/bcmgenet.c
- drivers/net/ethernet/broadcom/genet/bcmgenet.h
- drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
- drivers/net/ethernet/broadcom/tg3.c
- drivers/net/ethernet/brocade/bna/bnad.c
- drivers/net/ethernet/cadence/macb_main.c
- drivers/net/ethernet/cadence/macb_ptp.c
- drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
- drivers/net/ethernet/cortina/gemini.c
- drivers/net/ethernet/freescale/fman/fman.c
- drivers/net/ethernet/google/gve/gve_desc_dqo.h
- drivers/net/ethernet/google/gve/gve_main.c
- drivers/net/ethernet/google/gve/gve_rx_dqo.c
- drivers/net/ethernet/google/gve/gve_tx_dqo.c
- drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
- drivers/net/ethernet/ibm/emac/core.c
- drivers/net/ethernet/ibm/ibmveth.c
- drivers/net/ethernet/intel/e1000e/netdev.c
- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
- drivers/net/ethernet/intel/iavf/iavf.h
- drivers/net/ethernet/intel/iavf/iavf_main.c
- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
- drivers/net/ethernet/intel/ice/devlink/port.c
- drivers/net/ethernet/intel/ice/ice_eswitch.c
- drivers/net/ethernet/intel/ice/ice_sriov.c
- drivers/net/ethernet/intel/ice/ice_txrx.c
- drivers/net/ethernet/marvell/mvneta.c
- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
- drivers/net/ethernet/marvell/octeontx2/af/common.h
- drivers/net/ethernet/marvell/octeontx2/af/mcs.c
- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
- drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
- drivers/net/ethernet/mediatek/mtk_eth_soc.c
- drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
- drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
- drivers/net/ethernet/mellanox/mlx5/core/en_main.c
- drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
- drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
- drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c
- drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.h
- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
- drivers/net/ethernet/mellanox/mlx5/core/lag/shared_fdb.c
- drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
- drivers/net/ethernet/mellanox/mlx5/core/vport.c
- drivers/net/ethernet/mellanox/mlxsw/spectrum.h
- drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
- drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
- drivers/net/ethernet/meta/fbnic/fbnic_csr.h
- drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
- drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
- drivers/net/ethernet/meta/fbnic/fbnic_fw.c
- drivers/net/ethernet/meta/fbnic/fbnic_fw.h
- drivers/net/ethernet/meta/fbnic/fbnic_pci.c
- drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
- drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
- drivers/net/ethernet/microchip/lan743x_main.c
- drivers/net/ethernet/microchip/sparx5/sparx5_main.c
- drivers/net/ethernet/microchip/sparx5/sparx5_main.h
- drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
- drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
- drivers/net/ethernet/microchip/vcap/vcap_api.c
- drivers/net/ethernet/microsoft/mana/mana_bpf.c
- drivers/net/ethernet/microsoft/mana/mana_en.c
- drivers/net/ethernet/microsoft/mana/mana_ethtool.c
- drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
- drivers/net/ethernet/realtek/r8169_main.c
- drivers/net/ethernet/sfc/efx.c
- drivers/net/ethernet/socionext/netsec.c
- drivers/net/ethernet/spacemit/k1_emac.c
- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
- drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
- drivers/net/ethernet/stmicro/stmmac/hwif.h
- drivers/net/ethernet/stmicro/stmmac/ring_mode.c
- drivers/net/ethernet/stmicro/stmmac/stmmac.h
- drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
modified .get_maintainer.ignore
| @@ -4,6 +4,8 @@ Alyssa Rosenzweig <alyssa@rosenzweig.io> | |||
| 4 | 4 | Askar Safin <safinaskar@gmail.com> | |
| 5 | 5 | Christoph Hellwig <hch@lst.de> | |
| 6 | 6 | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | |
| 7 | + | Johannes Berg <johannes.berg@intel.com> | |
| 8 | + | Johannes Berg <johannes@sipsolutions.net> | |
| 7 | 9 | Marc Gonzalez <marc.w.gonzalez@free.fr> | |
| 8 | 10 | Nathan Chancellor <nathan@kernel.org> | |
| 9 | 11 | Ralf Baechle <ralf@linux-mips.org> | |
modified .mailmap
| @@ -101,6 +101,7 @@ Andy Chiu <andybnac@gmail.com> <andy.chiu@sifive.com> | |||
| 101 | 101 | Andy Chiu <andybnac@gmail.com> <taochiu@synology.com> | |
| 102 | 102 | Andy Shevchenko <andy@kernel.org> <andy@smile.org.ua> | |
| 103 | 103 | Andy Shevchenko <andy@kernel.org> <ext-andriy.shevchenko@nokia.com> | |
| 104 | + | Andy Yan <andyshrk@163.com> <andy.yan@rock-chips.com> | |
| 104 | 105 | Anilkumar Kolli <quic_akolli@quicinc.com> <akolli@codeaurora.org> | |
| 105 | 106 | Anirudh Ghayal <quic_aghayal@quicinc.com> <aghayal@codeaurora.org> | |
| 106 | 107 | Antoine Tenart <atenart@kernel.org> <antoine.tenart@bootlin.com> | |
| @@ -211,7 +212,8 @@ Christophe Leroy <chleroy@kernel.org> <christophe.leroy@c-s.fr> | |||
| 211 | 212 | Christophe Leroy <chleroy@kernel.org> <christophe.leroy@csgroup.eu> | |
| 212 | 213 | Christophe Leroy <chleroy@kernel.org> <christophe.leroy2@cs-soprasteria.com> | |
| 213 | 214 | Christophe Ricard <christophe.ricard@gmail.com> | |
| 214 | - | Christopher Obbard <christopher.obbard@linaro.org> <chris.obbard@collabora.com> | |
| 215 | + | Christopher Obbard <chris.obbard@oss.qualcomm.com> <chris.obbard@collabora.com> | |
| 216 | + | Christopher Obbard <chris.obbard@oss.qualcomm.com> <christopher.obbard@linaro.org> | |
| 215 | 217 | Christoph Hellwig <hch@lst.de> | |
| 216 | 218 | Christoph Manszewski <c.manszewski@gmail.com> <christoph.manszewski@intel.com> | |
| 217 | 219 | Christoph Paasch <cpaasch@openai.com> <christoph.paasch@gmail.com> | |
| @@ -222,6 +224,7 @@ Chuck Lever <cel@kernel.org> <chuck.lever@oracle.com> | |||
| 222 | 224 | Chuck Lever <cel@kernel.org> <cel@netapp.com> | |
| 223 | 225 | Chuck Lever <cel@kernel.org> <cel@citi.umich.edu> | |
| 224 | 226 | Claudiu Beznea <claudiu.beznea@tuxon.dev> <claudiu.beznea@microchip.com> | |
| 227 | + | Coiby Xu <coiby.xu@gmail.com> <coxu@redhat.com> | |
| 225 | 228 | Colin Ian King <colin.i.king@gmail.com> <colin.king@canonical.com> | |
| 226 | 229 | Corey Minyard <minyard@acm.org> | |
| 227 | 230 | Damian Hobson-Garcia <dhobsong@igel.co.jp> | |
| @@ -284,6 +287,8 @@ Ed L. Cashin <ecashin@coraid.com> | |||
| 284 | 287 | Elliot Berman <quic_eberman@quicinc.com> <eberman@codeaurora.org> | |
| 285 | 288 | Enric Balletbo i Serra <eballetbo@kernel.org> <enric.balletbo@collabora.com> | |
| 286 | 289 | Enric Balletbo i Serra <eballetbo@kernel.org> <eballetbo@iseebcn.com> | |
| 290 | + | Eric Dumazet <edumazet@kernel.org> <edumazet@google.com> | |
| 291 | + | Eric Dumazet <edumazet@kernel.org> <eric.dumazet@gmail.com> | |
| 287 | 292 | Erik Kaneda <erik.kaneda@intel.com> <erik.schmauss@intel.com> | |
| 288 | 293 | Ethan Carter Edwards <ethan@ethancedwards.com> Ethan Edwards <ethancarteredwards@gmail.com> | |
| 289 | 294 | Eugen Hristev <ehristev@kernel.org> <eugen.hristev@microchip.com> | |
| @@ -353,6 +358,8 @@ Hans Verkuil <hverkuil@kernel.org> <hverkuil-cisco@xs4all.nl> | |||
| 353 | 358 | Hans Verkuil <hverkuil@kernel.org> <hansverk@cisco.com> | |
| 354 | 359 | Hans Verkuil <hverkuil@kernel.org> <hans.verkuil@cisco.com> | |
| 355 | 360 | Hao Ge <hao.ge@linux.dev> <gehao@kylinos.cn> | |
| 361 | + | Haowen Bai <baihaowen88@gmail.com> <baihaowen@meizu.com> | |
| 362 | + | Haowen Bai <baihaowen88@gmail.com> <calvin.bai@ugreen.com> | |
| 356 | 363 | Harry Yoo <harry.yoo@oracle.com> <42.hyeyoo@gmail.com> | |
| 357 | 364 | Harry Yoo <harry@kernel.org> <harry.yoo@oracle.com> | |
| 358 | 365 | Heiko Carstens <hca@linux.ibm.com> <h.carstens@de.ibm.com> | |
| @@ -455,7 +462,8 @@ Johan Hovold <johan@kernel.org> <jhovold@gmail.com> | |||
| 455 | 462 | Johan Hovold <johan@kernel.org> <johan@hovoldconsulting.com> | |
| 456 | 463 | John Crispin <john@phrozen.org> <blogic@openwrt.org> | |
| 457 | 464 | John Fastabend <john.fastabend@gmail.com> <john.r.fastabend@intel.com> | |
| 458 | - | John Garry <john.g.garry@oracle.com> <john.garry@huawei.com> | |
| 465 | + | John Garry <john.garry@linux.dev> <john.garry@huawei.com> | |
| 466 | + | John Garry <john.garry@linux.dev> <john.g.garry@oracle.com> | |
| 459 | 467 | John Keeping <john@keeping.me.uk> <john@metanate.com> | |
| 460 | 468 | John Moon <john@jmoon.dev> <quic_johmoo@quicinc.com> | |
| 461 | 469 | John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> | |
| @@ -480,6 +488,7 @@ Juha Yrjola <juha.yrjola@nokia.com> | |||
| 480 | 488 | Juha Yrjola <juha.yrjola@solidboot.com> | |
| 481 | 489 | Julien Thierry <julien.thierry.kdev@gmail.com> <julien.thierry@arm.com> | |
| 482 | 490 | Justin Iurman <justin.iurman@gmail.com> <justin.iurman@uliege.be> | |
| 491 | + | Imre Kaloz <kaloz@kernel.org> <kaloz@openwrt.org> | |
| 483 | 492 | Ira Weiny <iweiny@kernel.org> <ira.weiny@intel.com> | |
| 484 | 493 | Iskren Chernev <me@iskren.info> <iskren.chernev@gmail.com> | |
| 485 | 494 | Kalle Valo <kvalo@kernel.org> <kvalo@codeaurora.org> | |
| @@ -973,6 +982,7 @@ Vladimir Davydov <vdavydov.dev@gmail.com> <vdavydov@virtuozzo.com> | |||
| 973 | 982 | Vlastimil Babka <vbabka@kernel.org> <vbabka@suse.cz> | |
| 974 | 983 | WangYuli <wangyuli@aosc.io> <wangyl5933@chinaunicom.cn> | |
| 975 | 984 | WangYuli <wangyuli@aosc.io> <wangyuli@deepin.org> | |
| 985 | + | Wei Wang <weiwan@google.com> <weibunny@fb.com> | |
| 976 | 986 | Weiwen Hu <huweiwen@linux.alibaba.com> <sehuww@mail.scut.edu.cn> | |
| 977 | 987 | WeiXiong Liao <gmpy.liaowx@gmail.com> <liaoweixiong@allwinnertech.com> | |
| 978 | 988 | Wen Gong <quic_wgong@quicinc.com> <wgong@codeaurora.org> | |
| @@ -980,6 +990,8 @@ Wesley Cheng <quic_wcheng@quicinc.com> <wcheng@codeaurora.org> | |||
| 980 | 990 | Will Deacon <will@kernel.org> <will.deacon@arm.com> | |
| 981 | 991 | Wolfram Sang <wsa@kernel.org> <w.sang@pengutronix.de> | |
| 982 | 992 | Wolfram Sang <wsa@kernel.org> <wsa@the-dreams.de> | |
| 993 | + | Xu Xin <xu.xin@linux.dev> <xu.xin16@zte.com.cn> | |
| 994 | + | Xu Xin <xu.xin@linux.dev> xu xin <cgel.zte@gmail.com> | |
| 983 | 995 | Yakir Yang <kuankuan.y@gmail.com> <ykk@rock-chips.com> | |
| 984 | 996 | Yanteng Si <si.yanteng@linux.dev> <siyanteng@loongson.cn> | |
| 985 | 997 | Ying Huang <huang.ying.caritas@gmail.com> <ying.huang@intel.com> | |
modified Documentation/ABI/testing/sysfs-devices-platform-trackpoint
| @@ -5,7 +5,7 @@ Contact: linux-input@vger.kernel.org | |||
| 5 | 5 | Description: | |
| 6 | 6 | (RW) Trackpoint sensitivity. | |
| 7 | 7 | ||
| 8 | - | What: /sys/devices/platform/i8042/.../intertia | |
| 8 | + | What: /sys/devices/platform/i8042/.../inertia | |
| 9 | 9 | Date: Aug, 2005 | |
| 10 | 10 | KernelVersion: 2.6.14 | |
| 11 | 11 | Contact: linux-input@vger.kernel.org | |
modified Documentation/admin-guide/ext4.rst
| @@ -172,7 +172,8 @@ When mounting an ext4 filesystem, the following option are accepted: | |||
| 172 | 172 | data=journal | |
| 173 | 173 | All data are committed into the journal prior to being written into the | |
| 174 | 174 | main file system. Enabling this mode will disable delayed allocation | |
| 175 | - | and O_DIRECT support. | |
| 175 | + | and O_DIRECT support. This feature is deprecated and support | |
| 176 | + | will be removed in January 2028. | |
| 176 | 177 | ||
| 177 | 178 | data=ordered (*) | |
| 178 | 179 | All data are forced directly out to the main file system prior to its | |
| @@ -418,7 +419,8 @@ There are 3 different data modes: | |||
| 418 | 419 | consistent state. This mode is the slowest except when data needs to be read | |
| 419 | 420 | from and written to disk at the same time where it outperforms all others | |
| 420 | 421 | modes. Enabling this mode will disable delayed allocation and O_DIRECT | |
| 421 | - | support. | |
| 422 | + | support. The data=journal feature is deprecated and support will be | |
| 423 | + | removed in January 2028. | |
| 422 | 424 | ||
| 423 | 425 | /proc entries | |
| 424 | 426 | ============= | |
modified Documentation/admin-guide/kernel-parameters.txt
| @@ -589,6 +589,9 @@ Kernel parameters | |||
| 589 | 589 | arm64.nosve [ARM64] Unconditionally disable Scalable Vector | |
| 590 | 590 | Extension support | |
| 591 | 591 | ||
| 592 | + | arm64.nowfxt [ARM64] Unconditionally disable Wait For Event with | |
| 593 | + | Timeout and Wait For Interrupt with Timeout support | |
| 594 | + | ||
| 592 | 595 | ataflop= [HW,M68k] | |
| 593 | 596 | ||
| 594 | 597 | atarimouse= [HW,MOUSE] Atari Mouse | |
| @@ -3491,7 +3494,7 @@ Kernel parameters | |||
| 3491 | 3494 | ||
| 3492 | 3495 | * SATA link speed limit: 1.5Gbps or 3.0Gbps. | |
| 3493 | 3496 | ||
| 3494 | - | * Transfer mode: pio[0-7], mwdma[0-4] and udma[0-7]. | |
| 3497 | + | * Transfer mode: pio[0-6], mwdma[0-4] and udma[0-7]. | |
| 3495 | 3498 | udma[/][16,25,33,44,66,100,133] notation is also | |
| 3496 | 3499 | allowed. | |
| 3497 | 3500 | ||
| @@ -3509,7 +3512,7 @@ Kernel parameters | |||
| 3509 | 3512 | ||
| 3510 | 3513 | * [no]ncqtrim: Enable or disable queued DSM TRIM. | |
| 3511 | 3514 | ||
| 3512 | - | * [no]ncqati: Enable or disable NCQ trim on ATI chipset. | |
| 3515 | + | * [no]ncqati: Enable or disable NCQ on ATI chipsets. | |
| 3513 | 3516 | ||
| 3514 | 3517 | * [no]trim: Enable or disable (unqueued) TRIM. | |
| 3515 | 3518 | ||
| @@ -3540,11 +3543,9 @@ Kernel parameters | |||
| 3540 | 3543 | ||
| 3541 | 3544 | * max_sec_128: Set transfer size limit to 128 sectors. | |
| 3542 | 3545 | ||
| 3543 | - | * max_sec_1024: Set or clear transfer size limit to | |
| 3544 | - | 1024 sectors. | |
| 3546 | + | * max_sec_1024: Set transfer size limit to 1024 sectors. | |
| 3545 | 3547 | ||
| 3546 | - | * max_sec_lba48: Set or clear transfer size limit to | |
| 3547 | - | 65535 sectors. | |
| 3548 | + | * max_sec_lba48: Set transfer size limit to 65535 sectors. | |
| 3548 | 3549 | ||
| 3549 | 3550 | * external: Mark port as external (hotplug-capable). | |
| 3550 | 3551 | ||
modified Documentation/arch/arm64/booting.rst
| @@ -465,6 +465,7 @@ Before jumping into the kernel, the following conditions must be met: | |||
| 465 | 465 | - HDFGWTR2_EL2.nPMICNTR_EL0 (bit 2) must be initialised to 0b1. | |
| 466 | 466 | - HDFGWTR2_EL2.nPMICFILTR_EL0 (bit 3) must be initialised to 0b1. | |
| 467 | 467 | - HDFGWTR2_EL2.nPMUACR_EL1 (bit 4) must be initialised to 0b1. | |
| 468 | + | - HDFGWTR2_EL2.nPMZR_EL0 (bit 21) must be initialised to 0b1. | |
| 468 | 469 | ||
| 469 | 470 | For CPUs with SPE data source filtering (FEAT_SPE_FDS): | |
| 470 | 471 | ||
modified Documentation/arch/arm64/memory-tagging-extension.rst
| @@ -208,11 +208,10 @@ will use the corresponding aligned address. | |||
| 208 | 208 | tracer's space cannot be accessed or does not have valid tags. | |
| 209 | 209 | - ``-EPERM`` - the specified process cannot be traced. | |
| 210 | 210 | - ``-EIO`` - the tracee's address range cannot be accessed (e.g. invalid | |
| 211 | - | address) and no tags copied. ``iov_len`` not updated. | |
| 211 | + | address) or does not have valid tags (not mapped with the ``PROT_MTE`` | |
| 212 | + | flag) and no tags copied. ``iov_len`` not updated. | |
| 212 | 213 | - ``-EFAULT`` - fault on accessing the tracer's memory (``struct iovec`` | |
| 213 | 214 | or ``iov_base`` buffer) and no tags copied. ``iov_len`` not updated. | |
| 214 | - | - ``-EOPNOTSUPP`` - the tracee's address does not have valid tags (never | |
| 215 | - | mapped with the ``PROT_MTE`` flag). ``iov_len`` not updated. | |
| 216 | 215 | ||
| 217 | 216 | **Note**: There are no transient errors for the requests above, so user | |
| 218 | 217 | programs should not retry in case of a non-zero system call return. | |
modified Documentation/arch/arm64/silicon-errata.rst
| @@ -174,6 +174,8 @@ stable kernels. | |||
| 174 | 174 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 175 | 175 | | ARM | Cortex-A725 | #3456106 | ARM64_ERRATUM_3194386 | | |
| 176 | 176 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 177 | + | | ARM | Cortex-A725 | #3821522 | ARM64_ERRATUM_3821522 | | |
| 178 | + | +----------------+-----------------+-----------------+-----------------------------+ | |
| 177 | 179 | | ARM | Cortex-X1 | #1502854 | N/A | | |
| 178 | 180 | +----------------+-----------------+-----------------+-----------------------------+ | |
| 179 | 181 | | ARM | Cortex-X1 | #3324344 | ARM64_ERRATUM_3194386 | | |
modified Documentation/arch/s390/pci.rst
| @@ -67,7 +67,7 @@ Entries specific to zPCI functions and entries that hold zPCI information. | |||
| 67 | 67 | ||
| 68 | 68 | A physical function that currently supports a virtual function cannot be | |
| 69 | 69 | powered off until all virtual functions are removed with: | |
| 70 | - | echo 0 > /sys/bus/pci/devices/DDDD:BB:dd.f/sriov_numvf | |
| 70 | + | echo 0 > /sys/bus/pci/devices/DDDD:BB:dd.f/sriov_numvfs | |
| 71 | 71 | ||
| 72 | 72 | * /sys/bus/pci/devices/DDDD:BB:dd.f/: | |
| 73 | 73 | ||
modified Documentation/bpf/kfuncs.rst
| @@ -486,6 +486,16 @@ Example usage in BPF program: | |||
| 486 | 486 | /* note that the last argument is omitted */ | |
| 487 | 487 | bpf_task_work_schedule_signal(task, &work->tw, &arrmap, task_work_callback); | |
| 488 | 488 | ||
| 489 | + | 2.5.10 KF_PERFMON flag | |
| 490 | + | ---------------------- | |
| 491 | + | ||
| 492 | + | The KF_PERFMON flag is used for kfuncs that can expose kernel memory or kernel | |
| 493 | + | addresses to the BPF program, for example by reading through a pointer that the | |
| 494 | + | verifier does not check. Calling such a kfunc requires CAP_PERFMON, or | |
| 495 | + | CAP_SYS_ADMIN, in the same way that the equivalent BPF helpers are gated in | |
| 496 | + | bpf_base_func_proto(). A program loaded with CAP_BPF alone is rejected at load | |
| 497 | + | time. | |
| 498 | + | ||
| 489 | 499 | 2.6 Registering the kfuncs | |
| 490 | 500 | -------------------------- | |
| 491 | 501 | ||
modified Documentation/devicetree/bindings/display/msm/qcom,qcs8300-mdss.yaml
| @@ -150,7 +150,7 @@ examples: | |||
| 150 | 150 | reg = <0>; | |
| 151 | 151 | ||
| 152 | 152 | dpu_intf0_out: endpoint { | |
| 153 | - | remote-endpoint = <&mdss_dp0_in>; | |
| 153 | + | remote-endpoint = <&mdss_dp0_in>; | |
| 154 | 154 | }; | |
| 155 | 155 | }; | |
| 156 | 156 | ||
| @@ -352,9 +352,9 @@ examples: | |||
| 352 | 352 | }; | |
| 353 | 353 | ||
| 354 | 354 | port@1 { | |
| 355 | - | reg = <1>; | |
| 355 | + | reg = <1>; | |
| 356 | 356 | ||
| 357 | - | mdss_dp_out: endpoint { }; | |
| 357 | + | mdss_dp_out: endpoint { }; | |
| 358 | 358 | }; | |
| 359 | 359 | }; | |
| 360 | 360 | ||
modified Documentation/devicetree/bindings/display/msm/qcom,sar2130p-mdss.yaml
| @@ -248,9 +248,9 @@ examples: | |||
| 248 | 248 | remote-endpoint = <&usb_dp_qmpphy_dp_in>; | |
| 249 | 249 | }; | |
| 250 | 250 | }; | |
| 251 | - | }; | |
| 251 | + | }; | |
| 252 | 252 | ||
| 253 | - | dp_opp_table: opp-table { | |
| 253 | + | dp_opp_table: opp-table { | |
| 254 | 254 | compatible = "operating-points-v2"; | |
| 255 | 255 | ||
| 256 | 256 | opp-162000000 { | |
modified Documentation/devicetree/bindings/display/msm/qcom,sm6150-dpu.yaml
| @@ -81,7 +81,7 @@ examples: | |||
| 81 | 81 | port@1 { | |
| 82 | 82 | reg = <1>; | |
| 83 | 83 | dpu_intf1_out: endpoint { | |
| 84 | - | remote-endpoint = <&mdss_dsi0_in>; | |
| 84 | + | remote-endpoint = <&mdss_dsi0_in>; | |
| 85 | 85 | }; | |
| 86 | 86 | }; | |
| 87 | 87 | }; | |
| @@ -90,18 +90,18 @@ examples: | |||
| 90 | 90 | compatible = "operating-points-v2"; | |
| 91 | 91 | ||
| 92 | 92 | opp-19200000 { | |
| 93 | - | opp-hz = /bits/ 64 <19200000>; | |
| 94 | - | required-opps = <&rpmhpd_opp_low_svs>; | |
| 93 | + | opp-hz = /bits/ 64 <19200000>; | |
| 94 | + | required-opps = <&rpmhpd_opp_low_svs>; | |
| 95 | 95 | }; | |
| 96 | 96 | ||
| 97 | 97 | opp-25600000 { | |
| 98 | - | opp-hz = /bits/ 64 <25600000>; | |
| 99 | - | required-opps = <&rpmhpd_opp_svs>; | |
| 98 | + | opp-hz = /bits/ 64 <25600000>; | |
| 99 | + | required-opps = <&rpmhpd_opp_svs>; | |
| 100 | 100 | }; | |
| 101 | 101 | ||
| 102 | 102 | opp-307200000 { | |
| 103 | - | opp-hz = /bits/ 64 <307200000>; | |
| 104 | - | required-opps = <&rpmhpd_opp_nom>; | |
| 103 | + | opp-hz = /bits/ 64 <307200000>; | |
| 104 | + | required-opps = <&rpmhpd_opp_nom>; | |
| 105 | 105 | }; | |
| 106 | 106 | }; | |
| 107 | 107 | }; | |
modified Documentation/devicetree/bindings/display/msm/qcom,sm8350-mdss.yaml
| @@ -223,7 +223,7 @@ examples: | |||
| 223 | 223 | phys = <&mdss_dsi0_phy>; | |
| 224 | 224 | ||
| 225 | 225 | ports { | |
| 226 | - | #address-cells = <1>; | |
| 226 | + | #address-cells = <1>; | |
| 227 | 227 | #size-cells = <0>; | |
| 228 | 228 | ||
| 229 | 229 | port@0 { | |
modified Documentation/devicetree/bindings/display/msm/qcom,x1e80100-mdss.yaml
| @@ -208,47 +208,47 @@ examples: | |||
| 208 | 208 | #sound-dai-cells = <0>; | |
| 209 | 209 | ||
| 210 | 210 | ports { | |
| 211 | - | #address-cells = <1>; | |
| 212 | - | #size-cells = <0>; | |
| 211 | + | #address-cells = <1>; | |
| 212 | + | #size-cells = <0>; | |
| 213 | 213 | ||
| 214 | - | port@0 { | |
| 215 | - | reg = <0>; | |
| 214 | + | port@0 { | |
| 215 | + | reg = <0>; | |
| 216 | 216 | ||
| 217 | - | mdss_dp0_in: endpoint { | |
| 218 | - | remote-endpoint = <&mdss_intf0_out>; | |
| 219 | - | }; | |
| 220 | - | }; | |
| 217 | + | mdss_dp0_in: endpoint { | |
| 218 | + | remote-endpoint = <&mdss_intf0_out>; | |
| 219 | + | }; | |
| 220 | + | }; | |
| 221 | 221 | ||
| 222 | - | port@1 { | |
| 223 | - | reg = <1>; | |
| 222 | + | port@1 { | |
| 223 | + | reg = <1>; | |
| 224 | 224 | ||
| 225 | - | mdss_dp0_out: endpoint { | |
| 226 | - | }; | |
| 227 | - | }; | |
| 225 | + | mdss_dp0_out: endpoint { | |
| 226 | + | }; | |
| 227 | + | }; | |
| 228 | 228 | }; | |
| 229 | 229 | ||
| 230 | 230 | mdss_dp0_opp_table: opp-table { | |
| 231 | - | compatible = "operating-points-v2"; | |
| 232 | - | ||
| 233 | - | opp-160000000 { | |
| 234 | - | opp-hz = /bits/ 64 <160000000>; | |
| 235 | - | required-opps = <&rpmhpd_opp_low_svs>; | |
| 236 | - | }; | |
| 237 | - | ||
| 238 | - | opp-270000000 { | |
| 239 | - | opp-hz = /bits/ 64 <270000000>; | |
| 240 | - | required-opps = <&rpmhpd_opp_svs>; | |
| 241 | - | }; | |
| 242 | - | ||
| 243 | - | opp-540000000 { | |
| 244 | - | opp-hz = /bits/ 64 <540000000>; | |
| 245 | - | required-opps = <&rpmhpd_opp_svs_l1>; | |
| 246 | - | }; | |
| 247 | - | ||
| 248 | - | opp-810000000 { | |
| 249 | - | opp-hz = /bits/ 64 <810000000>; | |
| 250 | - | required-opps = <&rpmhpd_opp_nom>; | |
| 251 | - | }; | |
| 231 | + | compatible = "operating-points-v2"; | |
| 232 | + | ||
| 233 | + | opp-160000000 { | |
| 234 | + | opp-hz = /bits/ 64 <160000000>; | |
| 235 | + | required-opps = <&rpmhpd_opp_low_svs>; | |
| 236 | + | }; | |
| 237 | + | ||
| 238 | + | opp-270000000 { | |
| 239 | + | opp-hz = /bits/ 64 <270000000>; | |
| 240 | + | required-opps = <&rpmhpd_opp_svs>; | |
| 241 | + | }; | |
| 242 | + | ||
| 243 | + | opp-540000000 { | |
| 244 | + | opp-hz = /bits/ 64 <540000000>; | |
| 245 | + | required-opps = <&rpmhpd_opp_svs_l1>; | |
| 246 | + | }; | |
| 247 | + | ||
| 248 | + | opp-810000000 { | |
| 249 | + | opp-hz = /bits/ 64 <810000000>; | |
| 250 | + | required-opps = <&rpmhpd_opp_nom>; | |
| 251 | + | }; | |
| 252 | 252 | }; | |
| 253 | 253 | }; | |
| 254 | 254 | }; | |
modified Documentation/devicetree/bindings/iio/adc/rockchip-saradc.yaml
| @@ -12,19 +12,19 @@ maintainers: | |||
| 12 | 12 | properties: | |
| 13 | 13 | compatible: | |
| 14 | 14 | oneOf: | |
| 15 | - | - const: rockchip,saradc | |
| 16 | - | - const: rockchip,rk3066-tsadc | |
| 17 | - | - const: rockchip,rk3399-saradc | |
| 18 | - | - const: rockchip,rk3528-saradc | |
| 15 | + | - enum: | |
| 16 | + | - rockchip,saradc | |
| 17 | + | - rockchip,rk3066-tsadc | |
| 18 | + | - rockchip,rk3399-saradc | |
| 19 | + | - rockchip,rk3528-saradc | |
| 20 | + | - rockchip,rk3562-saradc | |
| 21 | + | - rockchip,rk3588-saradc | |
| 22 | + | - rockchip,rv1106-saradc | |
| 19 | 23 | - items: | |
| 20 | 24 | - const: rockchip,rk3506-saradc | |
| 21 | 25 | - const: rockchip,rk3528-saradc | |
| 22 | - | - const: rockchip,rk3562-saradc | |
| 23 | - | - const: rockchip,rk3588-saradc | |
| 24 | 26 | - items: | |
| 25 | - | - enum: | |
| 26 | - | - rockchip,rk3576-saradc | |
| 27 | - | - rockchip,rv1106-saradc | |
| 27 | + | - const: rockchip,rk3576-saradc | |
| 28 | 28 | - const: rockchip,rk3588-saradc | |
| 29 | 29 | - items: | |
| 30 | 30 | - enum: | |
modified Documentation/devicetree/bindings/input/mediatek,mt6779-keypad.yaml
| @@ -26,6 +26,7 @@ properties: | |||
| 26 | 26 | - const: mediatek,mt6779-keypad | |
| 27 | 27 | - items: | |
| 28 | 28 | - enum: | |
| 29 | + | - mediatek,mt6572-keypad | |
| 29 | 30 | - mediatek,mt6873-keypad | |
| 30 | 31 | - mediatek,mt8183-keypad | |
| 31 | 32 | - mediatek,mt8365-keypad | |
modified Documentation/devicetree/bindings/pinctrl/qcom,nord-tlmm.yaml
| @@ -67,7 +67,7 @@ $defs: | |||
| 67 | 67 | Specify the alternative function to be configured for the specified | |
| 68 | 68 | pins. | |
| 69 | 69 | ||
| 70 | - | enum: [ aoss_cti, atest_char, atest_usb20, atest_usb21, | |
| 70 | + | enum: [ gpio, aoss_cti, atest_char, atest_usb20, atest_usb21, | |
| 71 | 71 | aud_intfc0_clk, aud_intfc0_data, aud_intfc0_ws, | |
| 72 | 72 | aud_intfc10_clk, aud_intfc10_data, aud_intfc10_ws, | |
| 73 | 73 | aud_intfc1_clk, aud_intfc1_data, aud_intfc1_ws, | |
| @@ -98,9 +98,10 @@ $defs: | |||
| 98 | 98 | pcie3_clk_req_n, phase_flag, pll_bist_sync, pll_clk_aux, | |
| 99 | 99 | prng_rosc0, prng_rosc1, pwrbrk_i_n, qdss, qdss_cti, qspi, | |
| 100 | 100 | qup0_se0, qup0_se1, qup0_se2, qup0_se3, qup0_se4, qup0_se5, | |
| 101 | - | qup1_se0, qup1_se1, qup1_se3, qup1_se2, qup1_se4, qup1_se5, | |
| 101 | + | qup1_se0, qup1_se1, qup1_se2_01, qup1_se2_23, qup1_se3_01, | |
| 102 | + | qup1_se3_23, qup1_se4, qup1_se5, | |
| 102 | 103 | qup1_se6, qup2_se0, qup2_se1, qup2_se2, qup2_se3, qup2_se4, | |
| 103 | - | qup2_se5, qup2_se6, | |
| 104 | + | qup2_se5, qup2_se6, qup3_se0_mira, qup3_se0_mirb, | |
| 104 | 105 | sailss_ospi, sdc4_clk, sdc4_cmd, sdc4_data, smb_alert, | |
| 105 | 106 | smb_alert_n, smb_clk, smb_dat, tb_trig_sdc4, tmess_prng0, | |
| 106 | 107 | tmess_prng1, tsc_timer, tsense_pwm, usb0_hs, | |
modified Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
| @@ -77,6 +77,7 @@ properties: | |||
| 77 | 77 | - mscc,ocelot-spi | |
| 78 | 78 | - mscc,jaguar2-spi | |
| 79 | 79 | - sophgo,sg2042-spi | |
| 80 | + | - syna,sl2610-spi | |
| 80 | 81 | - thead,th1520-spi | |
| 81 | 82 | - ultrarisc,dp1000-spi | |
| 82 | 83 | - const: snps,dw-apb-ssi | |
modified Documentation/filesystems/netfs_library.rst
| @@ -451,6 +451,32 @@ one. | |||
| 451 | 451 | The inode should be marked ``NETFS_ICTX_SINGLE_NO_UPLOAD`` if this API is to be | |
| 452 | 452 | used. The writeback function requires the buffer to be of ITER_FOLIOQ type. | |
| 453 | 453 | ||
| 454 | + | Clearing Stale Post-EOF Pagecache | |
| 455 | + | --------------------------------- | |
| 456 | + | ||
| 457 | + | When a file is extended, data left in the pagecache past the old EOF by a write | |
| 458 | + | through an mmap must not be exposed as file content. Netfslib clears this on | |
| 459 | + | its own write paths, and exports a helper so a filesystem can do the same from | |
| 460 | + | a resize path (truncate, setattr, fallocate and the like) that holds the | |
| 461 | + | inode's ``i_rwsem`` exclusively across the whole resize:: | |
| 462 | + | ||
| 463 | + | void netfs_clear_stale_post_isize(struct inode *inode, uoff_t from, | |
| 464 | + | uoff_t to); | |
| 465 | + | ||
| 466 | + | This zeroes any such data within the ``[from, to)`` hole to be made, where | |
| 467 | + | @from is the old EOF and @to is the new one, and the caller must have already | |
| 468 | + | updated ``i_size`` to @to before calling it. Only the folio straddling @from | |
| 469 | + | can hold data written past the EOF through an mmap, as pages wholly beyond the | |
| 470 | + | EOF can't be faulted in, so the zeroing is limited to that folio. The folio is | |
| 471 | + | zeroed rather than dropped so that a concurrent extending write can't lose | |
| 472 | + | data. | |
| 473 | + | ||
| 474 | + | This overlaps with ``pagecache_isize_extended()`` but can't reuse it: that | |
| 475 | + | helper is keyed on a sub-page block size and is a no-op when the block size is | |
| 476 | + | ``>= PAGE_SIZE`` (as on network filesystems), and it doesn't wait for | |
| 477 | + | writeback. As both address the same problem, a change to one should probably | |
| 478 | + | be reflected in the other to keep them in sync. | |
| 479 | + | ||
| 454 | 480 | High-Level VM API | |
| 455 | 481 | ================== | |
| 456 | 482 | ||
modified Documentation/filesystems/propagate_umount.txt
| @@ -32,12 +32,12 @@ of set. They can be reparented to the place where the bottom of | |||
| 32 | 32 | stack is attached to a mount that will survive. NOTE: doing that | |
| 33 | 33 | will violate a constraint on having no more than one mount with | |
| 34 | 34 | the same parent/mountpoint pair; however, the caller (umount_tree()) | |
| 35 | - | will immediately remedy that - it may keep unmounted element attached | |
| 36 | - | to parent, but only if the parent itself is unmounted. Since all | |
| 37 | - | conflicts created by reparenting have common parent *not* in the | |
| 38 | - | set and one side of the conflict (bottom of the stack of overmounts) | |
| 39 | - | is in the set, it will be resolved. However, we rely upon umount_tree() | |
| 40 | - | doing that pretty much immediately after the call of propagate_umount(). | |
| 35 | + | will immediately remedy that - it detaches every element of the set | |
| 36 | + | from its parent. Since all conflicts created by reparenting have | |
| 37 | + | common parent *not* in the set and one side of the conflict (bottom | |
| 38 | + | of the stack of overmounts) is in the set, it will be resolved. | |
| 39 | + | However, we rely upon umount_tree() doing that pretty much immediately | |
| 40 | + | after the call of propagate_umount(). | |
| 41 | 41 | ||
| 42 | 42 | Algorithm is based on two statements: | |
| 43 | 43 | 1) for any set S, there is a maximal non-shifting subset of S | |
modified Documentation/hwmon/cgbc-hwmon.rst
| @@ -28,34 +28,44 @@ system. | |||
| 28 | 28 | Name Description | |
| 29 | 29 | ============= ====================== | |
| 30 | 30 | temp1_input CPU temperature | |
| 31 | - | temp2_input Box temperature | |
| 31 | + | temp2_input Case temperature | |
| 32 | 32 | temp3_input Ambient temperature | |
| 33 | - | temp4_input Board temperature | |
| 34 | - | temp5_input Carrier temperature | |
| 35 | - | temp6_input Chipset temperature | |
| 36 | - | temp7_input Video temperature | |
| 33 | + | temp4_input CPU Board temperature | |
| 34 | + | temp5_input Carrier Board temperature | |
| 35 | + | temp6_input System Chipset temperature | |
| 36 | + | temp7_input Video Controller/Board temperature | |
| 37 | 37 | temp8_input Other temperature | |
| 38 | - | temp9_input TOPDIM temperature | |
| 39 | - | temp10_input BOTTOMDIM temperature | |
| 40 | - | in0_input CPU voltage | |
| 38 | + | temp9_input Top DIMM 0 temperature | |
| 39 | + | temp10_input Bottom DIMM 0 temperature | |
| 40 | + | temp11_input Alternate Board temperature | |
| 41 | + | temp12_input Top DIMM 1 temperature | |
| 42 | + | temp13_input Top DIMM 2 temperature | |
| 43 | + | temp14_input Top DIMM 3 temperature | |
| 44 | + | temp15_input Top DIMM 4 temperature | |
| 45 | + | temp16_input Top DIMM 5 temperature | |
| 46 | + | temp17_input Top DIMM 6 temperature | |
| 47 | + | temp18_input Top DIMM 7 temperature | |
| 48 | + | temp19_input Bottom DIMM 1 temperature | |
| 49 | + | in0_input CPU Core voltage | |
| 41 | 50 | in1_input DC Runtime voltage | |
| 42 | 51 | in2_input DC Standby voltage | |
| 43 | 52 | in3_input CMOS Battery voltage | |
| 44 | - | in4_input Battery voltage | |
| 53 | + | in4_input Battery Supply voltage | |
| 45 | 54 | in5_input AC voltage | |
| 46 | 55 | in6_input Other voltage | |
| 47 | - | in7_input 5V voltage | |
| 56 | + | in7_input 5V Runtime voltage | |
| 48 | 57 | in8_input 5V Standby voltage | |
| 49 | - | in9_input 3V3 voltage | |
| 58 | + | in9_input 3V3 Runtime voltage | |
| 50 | 59 | in10_input 3V3 Standby voltage | |
| 51 | 60 | in11_input VCore A voltage | |
| 52 | 61 | in12_input VCore B voltage | |
| 53 | - | in13_input 12V voltage | |
| 54 | - | curr1_input DC current | |
| 55 | - | curr2_input 5V current | |
| 56 | - | curr3_input 12V current | |
| 62 | + | in13_input 12V Runtime voltage | |
| 63 | + | in14_input 12V Standby voltage | |
| 64 | + | curr1_input DC Runtime current | |
| 65 | + | curr2_input 5V Runtime current | |
| 66 | + | curr3_input 12V Runtime current | |
| 57 | 67 | fan1_input CPU fan | |
| 58 | - | fan2_input Box fan | |
| 68 | + | fan2_input Case fan | |
| 59 | 69 | fan3_input Ambient fan | |
| 60 | 70 | fan4_input Chiptset fan | |
| 61 | 71 | fan5_input Video fan | |
modified Documentation/netlink/specs/netdev.yaml
| @@ -851,6 +851,8 @@ operations: | |||
| 851 | 851 | name: bind-tx | |
| 852 | 852 | doc: Bind dmabuf to netdev for TX | |
| 853 | 853 | attribute-set: dmabuf | |
| 854 | + | # Intentionally unprivileged (no admin-perm / uns-admin-perm); see | |
| 855 | + | # comment above netdev_nl_bind_tx_doit(). | |
| 854 | 856 | do: | |
| 855 | 857 | request: | |
| 856 | 858 | attributes: | |
modified Documentation/netlink/specs/rt-neigh.yaml
| @@ -341,6 +341,9 @@ attribute-sets: | |||
| 341 | 341 | - | |
| 342 | 342 | name: interval-probe-time-ms | |
| 343 | 343 | type: u64 | |
| 344 | + | checks: | |
| 345 | + | min: 1 | |
| 346 | + | max: 86400000 | |
| 344 | 347 | ||
| 345 | 348 | operations: | |
| 346 | 349 | enum-model: directional | |
modified Documentation/networking/ip-sysctl.rst
| @@ -248,7 +248,7 @@ neigh/default/unres_qlen - INTEGER | |||
| 248 | 248 | ||
| 249 | 249 | neigh/default/interval_probe_time_ms - INTEGER | |
| 250 | 250 | The probe interval for neighbor entries with NTF_MANAGED flag, | |
| 251 | - | the min value is 1. | |
| 251 | + | the min value is 1, and the max value is 86400000 (1 day). | |
| 252 | 252 | ||
| 253 | 253 | Default: 5000 | |
| 254 | 254 | ||
| @@ -874,6 +874,8 @@ tcp_rmem - vector of 3 INTEGERs: min, default, max | |||
| 874 | 874 | case this value is ignored. | |
| 875 | 875 | Default: between 131072 and 32MB, depending on RAM size. | |
| 876 | 876 | ||
| 877 | + | Each of the three values cannot be set below 4096. | |
| 878 | + | ||
| 877 | 879 | tcp_sack - BOOLEAN | |
| 878 | 880 | Enable select acknowledgments (SACKS). | |
| 879 | 881 | ||
modified Documentation/networking/strparser.rst
| @@ -77,7 +77,7 @@ Functions | |||
| 77 | 77 | ||
| 78 | 78 | strp_done is called to release any resources held by the stream | |
| 79 | 79 | parser instance. This must be called after the stream processor | |
| 80 | - | has been stopped. | |
| 80 | + | has been stopped. The socket lock must not be held. | |
| 81 | 81 | ||
| 82 | 82 | :: | |
| 83 | 83 | ||
modified Documentation/trace/events-landlock.rst
| @@ -6,7 +6,7 @@ Landlock Trace Events | |||
| 6 | 6 | ===================== | |
| 7 | 7 | ||
| 8 | 8 | :Author: Mickaël Salaün | |
| 9 | - | :Date: August 2026 | |
| 9 | + | :Date: September 2026 | |
| 10 | 10 | ||
| 11 | 11 | Landlock emits trace events for sandbox lifecycle operations and access | |
| 12 | 12 | denials. These events can be consumed by ftrace (for human-readable | |
| @@ -31,8 +31,8 @@ Landlock trace events are organized in four categories: | |||
| 31 | 31 | **Syscall events** are emitted during Landlock system calls: | |
| 32 | 32 | ||
| 33 | 33 | - ``landlock_create_ruleset``: a new ruleset is created | |
| 34 | - | - ``landlock_add_rule_fs``: a filesystem rule is added to a ruleset | |
| 35 | - | - ``landlock_add_rule_net``: a network port rule is added to a ruleset | |
| 34 | + | - ``landlock_add_rule_path_beneath``: a filesystem rule is added to a ruleset | |
| 35 | + | - ``landlock_add_rule_net_port``: a network port rule is added to a ruleset | |
| 36 | 36 | - ``landlock_create_domain``: a new domain is created from a ruleset | |
| 37 | 37 | - ``landlock_enforce_domain``: a domain is enforced on a thread | |
| 38 | 38 | ||
| @@ -47,8 +47,8 @@ Landlock trace events are organized in four categories: | |||
| 47 | 47 | ||
| 48 | 48 | **Rule evaluation events** are emitted during rule matching: | |
| 49 | 49 | ||
| 50 | - | - ``landlock_check_rule_fs``: a filesystem rule is evaluated | |
| 51 | - | - ``landlock_check_rule_net``: a network port rule is evaluated | |
| 50 | + | - ``landlock_check_rule_inode``: an inode-keyed rule is evaluated | |
| 51 | + | - ``landlock_check_rule_net_port``: a network-port-keyed rule is evaluated | |
| 52 | 52 | ||
| 53 | 53 | **Lifecycle events**: | |
| 54 | 54 | ||
| @@ -141,10 +141,10 @@ in some field formats: | |||
| 141 | 141 | treated as untrusted input and escaped in the trace text output so it | |
| 142 | 142 | cannot inject field separators or control characters. | |
| 143 | 143 | ||
| 144 | - | - **Other party's domain**: A scope or ptrace denial compares the | |
| 145 | - | subject's denying domain (``domain=``, always the enforcing domain and | |
| 146 | - | never the current task) with the other party's domain, so these | |
| 147 | - | tracepoints also report the other party's domain as a scalar ID: | |
| 144 | + | - **Other party's domain**: A scope or ptrace denial compares the subject's | |
| 145 | + | denying domain (``domain=``), which is the enforcing domain and not | |
| 146 | + | necessarily the current task's domain, with the other party's domain. | |
| 147 | + | These tracepoints also report the other party's domain as a scalar ID: | |
| 148 | 148 | ``tracee_domain=`` (ptrace), ``target_domain=`` (signal), and | |
| 149 | 149 | ``peer_domain=`` (abstract unix socket). It is ``0`` when the other | |
| 150 | 150 | party is unsandboxed, and otherwise a domain ID that a consumer resolves | |
| @@ -189,7 +189,7 @@ rather than the caller's, so correlate those to the syscall by domain ID. | |||
| 189 | 189 | Interpreting check_rule events | |
| 190 | 190 | ============================== | |
| 191 | 191 | ||
| 192 | - | The ``check_rule_fs`` and ``check_rule_net`` events expose the per-layer | |
| 192 | + | The ``check_rule_inode`` and ``check_rule_net_port`` events expose the per-layer | |
| 193 | 193 | rule evaluation, which is useful for understanding *why* a specific | |
| 194 | 194 | access is allowed or denied. | |
| 195 | 195 | ||
| @@ -231,9 +231,10 @@ contribution, not the final decision: | |||
| 231 | 231 | through another matching rule, or the right is denied and appears in the | |
| 232 | 232 | ``blockers=`` field of the corresponding ``deny_access`` event. | |
| 233 | 233 | ||
| 234 | - | To reconstruct the decision for an object, aggregate the ``grants=`` | |
| 235 | - | groups of all ``check_rule`` events emitted for that object during the | |
| 236 | - | check. | |
| 234 | + | For an access check that a consumer can delimit, aggregate the ``grants=`` | |
| 235 | + | groups of all matching ``check_rule`` events. These events do not carry a | |
| 236 | + | request ID; use their execution context and generic tracepoints to separate | |
| 237 | + | concurrent or successive checks of the same object. | |
| 237 | 238 | ||
| 238 | 239 | .. note:: | |
| 239 | 240 | ||
| @@ -244,29 +245,31 @@ check. | |||
| 244 | 245 | ||
| 245 | 246 | For example, a program sandboxed with read and execute access to the | |
| 246 | 247 | whole filesystem reads ``/etc/passwd``; both the ``execve()`` and the | |
| 247 | - | read match the rule covering ``/`` (inode 2), so ``check_rule_fs`` fires | |
| 248 | + | read match the rule covering ``/`` (inode 2), so ``check_rule_inode`` fires | |
| 248 | 249 | with the requested rights intersected against what that rule grants. | |
| 249 | 250 | The ``access_request=`` mask includes ``truncate`` because the file-open hook | |
| 250 | 251 | evaluates that optional right alongside the required access, but the | |
| 251 | 252 | rule does not grant it, so ``truncate`` never appears in ``grants=``:: | |
| 252 | 253 | ||
| 253 | - | cat-127 [...] landlock_check_rule_fs: domain=1e40cb56f access_request=execute|read_file|truncate dev=0:17 ino=2 grants={execute|read_file} | |
| 254 | - | cat-127 [...] landlock_check_rule_fs: domain=1e40cb56f access_request=read_file|truncate dev=0:17 ino=2 grants={read_file} | |
| 254 | + | cat-127 [...] landlock_check_rule_inode: domain=1e40cb56f access_request=execute|read_file|truncate dev=0:17 ino=2 grants={execute|read_file} | |
| 255 | + | cat-127 [...] landlock_check_rule_inode: domain=1e40cb56f access_request=read_file|truncate dev=0:17 ino=2 grants={read_file} | |
| 255 | 256 | ||
| 256 | 257 | The ``[...]`` replaces the ftrace CPU, flags, and timestamp columns. A | |
| 257 | 258 | single ``grants=`` group means the enforcing domain has one layer. With | |
| 258 | 259 | two nested sandboxes that each grant the same rights, the rule spans both | |
| 259 | 260 | layers, so ``grants=`` has one group per layer:: | |
| 260 | 261 | ||
| 261 | - | cat-128 [...] landlock_check_rule_fs: domain=184788b52 access_request=execute|read_file|truncate dev=0:17 ino=2 grants={execute|read_file,execute|read_file} | |
| 262 | - | cat-128 [...] landlock_check_rule_fs: domain=184788b52 access_request=read_file|truncate dev=0:17 ino=2 grants={read_file,read_file} | |
| 262 | + | cat-128 [...] landlock_check_rule_inode: domain=184788b52 access_request=execute|read_file|truncate dev=0:17 ino=2 grants={execute|read_file,execute|read_file} | |
| 263 | + | cat-128 [...] landlock_check_rule_inode: domain=184788b52 access_request=read_file|truncate dev=0:17 ino=2 grants={read_file,read_file} | |
| 263 | 264 | ||
| 264 | 265 | eBPF access | |
| 265 | 266 | =========== | |
| 266 | 267 | ||
| 267 | - | eBPF programs attached via ``BPF_RAW_TRACEPOINT`` can access the | |
| 268 | - | tracepoint arguments directly through BTF. The arguments include both | |
| 269 | - | standard kernel objects and Landlock-internal objects: | |
| 268 | + | BTF-enabled raw tracepoint programs attached through libbpf | |
| 269 | + | ``SEC("tp_btf/...")`` sections receive typed callback arguments. The | |
| 270 | + | event prototypes in `Event reference`_ document their argument layouts. | |
| 271 | + | The arguments include both standard kernel objects and Landlock-internal | |
| 272 | + | objects: | |
| 270 | 273 | ||
| 271 | 274 | - Standard kernel objects (``struct task_struct``, ``struct sock``, | |
| 272 | 275 | ``struct path``, ``struct dentry``) can be used with existing BPF | |
| @@ -277,7 +280,7 @@ standard kernel objects and Landlock-internal objects: | |||
| 277 | 280 | Internal struct layouts may change between kernel versions; use CO-RE | |
| 278 | 281 | for field relocation. | |
| 279 | 282 | ||
| 280 | - | A stateful eBPF program observes the full event stream and maintains | |
| 283 | + | A stateful eBPF program attached before sandbox construction can maintain | |
| 281 | 284 | per-domain state in BPF maps: | |
| 282 | 285 | ||
| 283 | 286 | 1. On ``landlock_create_domain``: record the domain ID and parent (the | |
| @@ -293,7 +296,10 @@ per-domain state in BPF maps: | |||
| 293 | 296 | final statistics. | |
| 294 | 297 | ||
| 295 | 298 | This approach requires no kernel modification and no Landlock-specific | |
| 296 | - | BPF helpers. The Landlock IDs serve as correlation keys across events. | |
| 299 | + | BPF helpers. Landlock IDs serve as correlation keys within one boot. | |
| 300 | + | Records exported through tracing or BPF buffers can be lost, and records | |
| 301 | + | from different CPUs are not globally ordered, so consumers must detect and | |
| 302 | + | reconcile incomplete state. | |
| 297 | 303 | ||
| 298 | 304 | Audit filtering equivalence | |
| 299 | 305 | =========================== | |
modified MAINTAINERS
| @@ -3012,7 +3012,7 @@ F: arch/arm/boot/dts/ti/omap/omap3-igep* | |||
| 3012 | 3012 | ||
| 3013 | 3013 | ARM/INTEL IXP4XX ARM ARCHITECTURE | |
| 3014 | 3014 | M: Linus Walleij <linusw@kernel.org> | |
| 3015 | - | M: Imre Kaloz <kaloz@openwrt.org> | |
| 3015 | + | M: Imre Kaloz <kaloz@kernel.org> | |
| 3016 | 3016 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | |
| 3017 | 3017 | S: Maintained | |
| 3018 | 3018 | F: Documentation/devicetree/bindings/arm/intel-ixp4xx.yaml | |
| @@ -5143,6 +5143,7 @@ L: netdev@vger.kernel.org | |||
| 5143 | 5143 | L: openwrt-devel@lists.openwrt.org (subscribers-only) | |
| 5144 | 5144 | S: Supported | |
| 5145 | 5145 | F: Documentation/devicetree/bindings/net/dsa/brcm,b53.yaml | |
| 5146 | + | F: Documentation/networking/dsa/b53.rst | |
| 5146 | 5147 | F: drivers/net/dsa/b53/* | |
| 5147 | 5148 | F: drivers/net/dsa/bcm_sf2* | |
| 5148 | 5149 | F: include/linux/dsa/brcm.h | |
| @@ -5454,6 +5455,7 @@ F: include/linux/brcmphy.h | |||
| 5454 | 5455 | BROADCOM GENET ETHERNET DRIVER | |
| 5455 | 5456 | M: Doug Berger <opendmb@gmail.com> | |
| 5456 | 5457 | M: Florian Fainelli <florian.fainelli@broadcom.com> | |
| 5458 | + | M: Nicolai Buchwitz <nb@tipi-net.de> | |
| 5457 | 5459 | R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com> | |
| 5458 | 5460 | L: netdev@vger.kernel.org | |
| 5459 | 5461 | S: Maintained | |
| @@ -8573,7 +8575,7 @@ F: Documentation/devicetree/bindings/display/panel/synaptics,r63353.yaml | |||
| 8573 | 8575 | F: drivers/gpu/drm/panel/panel-synaptics-r63353.c | |
| 8574 | 8576 | ||
| 8575 | 8577 | DRM DRIVER FOR SYNOPSYS DESIGNWARE DISPLAYPORT BRIDGE | |
| 8576 | - | M: Andy Yan <andyshrk@163.com> | |
| 8578 | + | M: Andy Yan <andy.yan@rock-chips.com> | |
| 8577 | 8579 | S: Maintained | |
| 8578 | 8580 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| 8579 | 8581 | F: Documentation/devicetree/bindings/display/rockchip/rockchip,dw-dp.yaml | |
| @@ -8926,7 +8928,7 @@ F: include/linux/platform_data/shmob_drm.h | |||
| 8926 | 8928 | DRM DRIVERS FOR ROCKCHIP | |
| 8927 | 8929 | M: Sandy Huang <hjc@rock-chips.com> | |
| 8928 | 8930 | M: Heiko Stübner <heiko@sntech.de> | |
| 8929 | - | M: Andy Yan <andyshrk@163.com> | |
| 8931 | + | M: Andy Yan <andy.yan@rock-chips.com> | |
| 8930 | 8932 | L: dri-devel@lists.freedesktop.org | |
| 8931 | 8933 | L: linux-rockchip@lists.infradead.org | |
| 8932 | 8934 | S: Maintained | |
| @@ -9324,6 +9326,7 @@ F: Documentation/devicetree/bindings/interrupt-controller/econet,en751221-intc.y | |||
| 9324 | 9326 | F: Documentation/devicetree/bindings/mips/econet.yaml | |
| 9325 | 9327 | F: Documentation/devicetree/bindings/timer/econet,en751221-timer.yaml | |
| 9326 | 9328 | F: arch/mips/boot/dts/econet/ | |
| 9329 | + | F: arch/mips/configs/econet_en751221_defconfig | |
| 9327 | 9330 | F: arch/mips/econet/ | |
| 9328 | 9331 | F: drivers/clocksource/timer-econet-en751221.c | |
| 9329 | 9332 | F: drivers/irqchip/irq-econet-en751221.c | |
| @@ -9858,7 +9861,7 @@ L: linux-ext4@vger.kernel.org | |||
| 9858 | 9861 | S: Maintained | |
| 9859 | 9862 | W: http://ext4.wiki.kernel.org | |
| 9860 | 9863 | Q: http://patchwork.ozlabs.org/project/linux-ext4/list/ | |
| 9861 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git | |
| 9864 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev | |
| 9862 | 9865 | F: Documentation/filesystems/ext4/ | |
| 9863 | 9866 | F: fs/ext4/ | |
| 9864 | 9867 | F: include/trace/events/ext4.h | |
| @@ -12880,7 +12883,7 @@ S: Maintained | |||
| 12880 | 12883 | F: drivers/power/supply/ip5xxx_power.c | |
| 12881 | 12884 | ||
| 12882 | 12885 | INNOSILICON HDMI BRIDGE DRIVER | |
| 12883 | - | M: Andy Yan <andyshrk@163.com> | |
| 12886 | + | M: Andy Yan <andy.yan@rock-chips.com> | |
| 12884 | 12887 | L: dri-devel@lists.freedesktop.org | |
| 12885 | 12888 | S: Maintained | |
| 12886 | 12889 | T: git https://gitlab.freedesktop.org/drm/misc/kernel.git | |
| @@ -14904,7 +14907,7 @@ M: Damien Le Moal <dlemoal@kernel.org> | |||
| 14904 | 14907 | M: Niklas Cassel <cassel@kernel.org> | |
| 14905 | 14908 | L: linux-ide@vger.kernel.org | |
| 14906 | 14909 | S: Maintained | |
| 14907 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git | |
| 14910 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux.git for-next | |
| 14908 | 14911 | F: Documentation/ABI/testing/sysfs-ata | |
| 14909 | 14912 | F: Documentation/devicetree/bindings/ata/ | |
| 14910 | 14913 | F: drivers/ata/ | |
| @@ -17031,8 +17034,8 @@ MEMBLOCK AND MEMORY MANAGEMENT INITIALIZATION | |||
| 17031 | 17034 | M: Mike Rapoport <rppt@kernel.org> | |
| 17032 | 17035 | L: linux-mm@kvack.org | |
| 17033 | 17036 | S: Maintained | |
| 17034 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git for-next | |
| 17035 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git fixes | |
| 17037 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock.git for-next | |
| 17038 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/memblock.git fixes | |
| 17036 | 17039 | F: Documentation/core-api/boot-time-mm.rst | |
| 17037 | 17040 | F: include/linux/kho/abi/memblock.h | |
| 17038 | 17041 | F: include/linux/memblock.h | |
| @@ -17193,7 +17196,7 @@ F: tools/testing/selftests/mm/gup_test.c | |||
| 17193 | 17196 | MEMORY MANAGEMENT - KSM (Kernel Samepage Merging) | |
| 17194 | 17197 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17195 | 17198 | M: David Hildenbrand <david@kernel.org> | |
| 17196 | - | R: Xu Xin <xu.xin16@zte.com.cn> | |
| 17199 | + | R: Xu Xin <xu.xin@linux.dev> | |
| 17197 | 17200 | R: Chengming Zhou <chengming.zhou@linux.dev> | |
| 17198 | 17201 | L: linux-mm@kvack.org | |
| 17199 | 17202 | S: Maintained | |
| @@ -17207,31 +17210,6 @@ F: include/trace/events/ksm.h | |||
| 17207 | 17210 | F: mm/ksm.c | |
| 17208 | 17211 | F: mm/mm_slot.h | |
| 17209 | 17212 | ||
| 17210 | - | MEMORY MANAGEMENT - MEMORY POLICY AND MIGRATION | |
| 17211 | - | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17212 | - | M: David Hildenbrand <david@kernel.org> | |
| 17213 | - | R: Zi Yan <ziy@nvidia.com> | |
| 17214 | - | R: Matthew Brost <matthew.brost@intel.com> | |
| 17215 | - | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17216 | - | R: Rakie Kim <rakie.kim@sk.com> | |
| 17217 | - | R: Byungchul Park <byungchul@sk.com> | |
| 17218 | - | R: Gregory Price <gourry@gourry.net> | |
| 17219 | - | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17220 | - | R: Alistair Popple <apopple@nvidia.com> | |
| 17221 | - | L: linux-mm@kvack.org | |
| 17222 | - | S: Maintained | |
| 17223 | - | W: http://www.linux-mm.org | |
| 17224 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17225 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy | |
| 17226 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy-weighted-interleave | |
| 17227 | - | F: include/linux/mempolicy.h | |
| 17228 | - | F: include/uapi/linux/mempolicy.h | |
| 17229 | - | F: include/linux/migrate.h | |
| 17230 | - | F: include/linux/migrate_mode.h | |
| 17231 | - | F: mm/mempolicy.c | |
| 17232 | - | F: mm/migrate.c | |
| 17233 | - | F: mm/migrate_device.c | |
| 17234 | - | ||
| 17235 | 17213 | MEMORY MANAGEMENT - MGLRU (MULTI-GEN LRU) | |
| 17236 | 17214 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17237 | 17215 | R: Kairui Song <kasong@tencent.com> | |
| @@ -17241,6 +17219,8 @@ R: Barry Song <baohua@kernel.org> | |||
| 17241 | 17219 | R: Axel Rasmussen <axelrasmussen@google.com> | |
| 17242 | 17220 | R: Yuanchu Xie <yuanchu@google.com> | |
| 17243 | 17221 | R: Wei Xu <weixugc@google.com> | |
| 17222 | + | R: Baoquan He <baoquan.he@linux.dev> | |
| 17223 | + | R: Baolin Wang <baolin.wang@linux.alibaba.com> | |
| 17244 | 17224 | L: linux-mm@kvack.org | |
| 17245 | 17225 | S: Maintained | |
| 17246 | 17226 | W: http://www.linux-mm.org | |
| @@ -17252,6 +17232,25 @@ F: include/linux/mmzone.h | |||
| 17252 | 17232 | F: mm/vmscan.c | |
| 17253 | 17233 | F: mm/workingset.c | |
| 17254 | 17234 | ||
| 17235 | + | MEMORY MANAGEMENT - MIGRATION | |
| 17236 | + | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17237 | + | M: David Hildenbrand <david@kernel.org> | |
| 17238 | + | R: Zi Yan <ziy@nvidia.com> | |
| 17239 | + | R: Matthew Brost <matthew.brost@intel.com> | |
| 17240 | + | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17241 | + | R: Byungchul Park <byungchul@sk.com> | |
| 17242 | + | R: Gregory Price <gourry@gourry.net> | |
| 17243 | + | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17244 | + | R: Alistair Popple <apopple@nvidia.com> | |
| 17245 | + | L: linux-mm@kvack.org | |
| 17246 | + | S: Maintained | |
| 17247 | + | W: http://www.linux-mm.org | |
| 17248 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17249 | + | F: include/linux/migrate.h | |
| 17250 | + | F: include/linux/migrate_mode.h | |
| 17251 | + | F: mm/migrate.c | |
| 17252 | + | F: mm/migrate_device.c | |
| 17253 | + | ||
| 17255 | 17254 | MEMORY MANAGEMENT - MISC | |
| 17256 | 17255 | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17257 | 17256 | M: David Hildenbrand <david@kernel.org> | |
| @@ -17267,7 +17266,6 @@ W: http://www.linux-mm.org | |||
| 17267 | 17266 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17268 | 17267 | F: Documentation/ABI/testing/sysfs-kernel-mm | |
| 17269 | 17268 | F: Documentation/ABI/testing/sysfs-kernel-mm-cma | |
| 17270 | - | F: Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers | |
| 17271 | 17269 | F: Documentation/ABI/testing/sysfs-kernel-mm-numa | |
| 17272 | 17270 | F: Documentation/admin-guide/mm/ | |
| 17273 | 17271 | F: Documentation/mm/ | |
| @@ -17275,7 +17273,6 @@ F: drivers/char/mem.c | |||
| 17275 | 17273 | F: include/linux/cma.h | |
| 17276 | 17274 | F: include/linux/dmapool.h | |
| 17277 | 17275 | F: include/linux/ioremap.h | |
| 17278 | - | F: include/linux/memory-tiers.h | |
| 17279 | 17276 | F: include/linux/page_idle.h | |
| 17280 | 17277 | F: mm/backing-dev.c | |
| 17281 | 17278 | F: mm/cma.c | |
| @@ -17287,7 +17284,6 @@ F: mm/early_ioremap.c | |||
| 17287 | 17284 | F: mm/fadvise.c | |
| 17288 | 17285 | F: mm/ioremap.c | |
| 17289 | 17286 | F: mm/mapping_dirty_helpers.c | |
| 17290 | - | F: mm/memory-tiers.c | |
| 17291 | 17287 | F: mm/page_idle.c | |
| 17292 | 17288 | F: mm/pgalloc-track.h | |
| 17293 | 17289 | F: mm/process_vm_access.c | |
| @@ -17304,6 +17300,27 @@ F: mm/numa.c | |||
| 17304 | 17300 | F: mm/numa_emulation.c | |
| 17305 | 17301 | F: mm/numa_memblks.c | |
| 17306 | 17302 | ||
| 17303 | + | MEMORY MANAGEMENT - NUMA PLACEMENT | |
| 17304 | + | M: Andrew Morton <akpm@linux-foundation.org> | |
| 17305 | + | M: David Hildenbrand <david@kernel.org> | |
| 17306 | + | M: Gregory Price <gourry@gourry.net> | |
| 17307 | + | R: Zi Yan <ziy@nvidia.com> | |
| 17308 | + | R: Joshua Hahn <joshua.hahnjy@gmail.com> | |
| 17309 | + | R: Rakie Kim <rakie.kim@sk.com> | |
| 17310 | + | R: Ying Huang <ying.huang@linux.alibaba.com> | |
| 17311 | + | L: linux-mm@kvack.org | |
| 17312 | + | S: Maintained | |
| 17313 | + | W: http://www.linux-mm.org | |
| 17314 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm | |
| 17315 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-memory-tiers | |
| 17316 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy | |
| 17317 | + | F: Documentation/ABI/testing/sysfs-kernel-mm-mempolicy-weighted-interleave | |
| 17318 | + | F: include/linux/memory-tiers.h | |
| 17319 | + | F: include/linux/mempolicy.h | |
| 17320 | + | F: include/uapi/linux/mempolicy.h | |
| 17321 | + | F: mm/memory-tiers.c | |
| 17322 | + | F: mm/mempolicy.c | |
| 17323 | + | ||
| 17307 | 17324 | MEMORY MANAGEMENT - OOM KILLER | |
| 17308 | 17325 | M: Michal Hocko <mhocko@suse.com> | |
| 17309 | 17326 | R: David Rientjes <rientjes@google.com> | |
| @@ -18881,7 +18898,7 @@ F: net/core/drop_monitor.c | |||
| 18881 | 18898 | NETWORKING DRIVERS | |
| 18882 | 18899 | M: Andrew Lunn <andrew+netdev@lunn.ch> | |
| 18883 | 18900 | M: "David S. Miller" <davem@davemloft.net> | |
| 18884 | - | M: Eric Dumazet <edumazet@google.com> | |
| 18901 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 18885 | 18902 | M: Jakub Kicinski <kuba@kernel.org> | |
| 18886 | 18903 | M: Paolo Abeni <pabeni@redhat.com> | |
| 18887 | 18904 | L: netdev@vger.kernel.org | |
| @@ -18998,7 +19015,7 @@ K: struct\s+phy_port|phy_port_ | |||
| 18998 | 19015 | ||
| 18999 | 19016 | NETWORKING [GENERAL] | |
| 19000 | 19017 | M: "David S. Miller" <davem@davemloft.net> | |
| 19001 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19018 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19002 | 19019 | M: Jakub Kicinski <kuba@kernel.org> | |
| 19003 | 19020 | M: Paolo Abeni <pabeni@redhat.com> | |
| 19004 | 19021 | R: Simon Horman <horms@kernel.org> | |
| @@ -19224,7 +19241,7 @@ F: net/ipv6/seg6* | |||
| 19224 | 19241 | F: tools/testing/selftests/net/srv6* | |
| 19225 | 19242 | ||
| 19226 | 19243 | NETWORKING [TCP] | |
| 19227 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19244 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19228 | 19245 | M: Neal Cardwell <ncardwell@google.com> | |
| 19229 | 19246 | R: Kuniyuki Iwashima <kuniyu@google.com> | |
| 19230 | 19247 | L: netdev@vger.kernel.org | |
| @@ -19257,7 +19274,7 @@ F: net/tls/ | |||
| 19257 | 19274 | F: tools/testing/selftests/net/tls.c | |
| 19258 | 19275 | ||
| 19259 | 19276 | NETWORKING [SOCKETS] | |
| 19260 | - | M: Eric Dumazet <edumazet@google.com> | |
| 19277 | + | M: Eric Dumazet <edumazet@kernel.org> | |
| 19261 | 19278 | M: Kuniyuki Iwashima <kuniyu@google.com> | |
| 19262 | 19279 | M: Paolo Abeni <pabeni@redhat.com> | |
| 19263 | 19280 | M: Willem de Bruijn <willemb@google.com> | |
| @@ -20553,6 +20570,7 @@ ORACLE CLUSTER FILESYSTEM 2 (OCFS2) | |||
| 20553 | 20570 | M: Mark Fasheh <mark@fasheh.com> | |
| 20554 | 20571 | M: Joel Becker <jlbec@evilplan.org> | |
| 20555 | 20572 | M: Joseph Qi <joseph.qi@linux.alibaba.com> | |
| 20573 | + | R: Heming Zhao <heming.zhao@suse.com> | |
| 20556 | 20574 | L: ocfs2-devel@lists.linux.dev | |
| 20557 | 20575 | S: Supported | |
| 20558 | 20576 | W: http://ocfs2.wiki.kernel.org | |
| @@ -24471,6 +24489,11 @@ R: Marc Murphy <marc.murphy@sancloud.com> | |||
| 24471 | 24489 | S: Supported | |
| 24472 | 24490 | F: arch/arm/boot/dts/ti/omap/am335x-sancloud* | |
| 24473 | 24491 | ||
| 24492 | + | SB1250-DUART BROADCOM SOC SERIAL DRIVER | |
| 24493 | + | M: "Maciej W. Rozycki" <macro@orcam.me.uk> | |
| 24494 | + | S: Maintained | |
| 24495 | + | F: drivers/tty/serial/sb1250-duart.c | |
| 24496 | + | ||
| 24474 | 24497 | SBOM | |
| 24475 | 24498 | M: Luis Augenstein <luis.augenstein@tngtech.com> | |
| 24476 | 24499 | M: Maximilian Huber <maximilian.huber@tngtech.com> | |
| @@ -25181,7 +25204,7 @@ R: David Rientjes <rientjes@google.com> | |||
| 25181 | 25204 | R: Roman Gushchin <roman.gushchin@linux.dev> | |
| 25182 | 25205 | L: linux-mm@kvack.org | |
| 25183 | 25206 | S: Maintained | |
| 25184 | - | T: git git://git.kernel.org/pub/scm/linux/kernel/git/vbabka/slab.git | |
| 25207 | + | T: git git://git.kernel.org/pub/scm/linux/kernel/git/mm/slab.git | |
| 25185 | 25208 | F: Documentation/admin-guide/mm/slab.rst | |
| 25186 | 25209 | F: Documentation/mm/slab.rst | |
| 25187 | 25210 | F: include/linux/mempool.h | |
modified Makefile
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | VERSION = 7 | |
| 3 | 3 | PATCHLEVEL = 3 | |
| 4 | 4 | SUBLEVEL = 0 | |
| 5 | - | EXTRAVERSION = -rc3 | |
| 5 | + | EXTRAVERSION = -rc7 | |
| 6 | 6 | NAME = Baby Opossum Posse | |
| 7 | 7 | ||
| 8 | 8 | # *DOCUMENTATION* | |
modified arch/arc/Kconfig
| @@ -331,13 +331,9 @@ config ARC_FPU_SAVE_RESTORE | |||
| 331 | 331 | for floating point exceptions and rounding modes. These are | |
| 332 | 332 | preserved across task context switch when enabled. | |
| 333 | 333 | ||
| 334 | - | config ARC_CANT_LLSC | |
| 335 | - | def_bool n | |
| 336 | - | ||
| 337 | 334 | config ARC_HAS_LLSC | |
| 338 | 335 | bool "Insn: LLOCK/SCOND (efficient atomic ops)" | |
| 339 | 336 | default y | |
| 340 | - | depends on !ARC_CANT_LLSC | |
| 341 | 337 | ||
| 342 | 338 | if ISA_ARCV2 | |
| 343 | 339 | ||
modified arch/arc/include/asm/atomic64-arcv2.h
| @@ -156,6 +156,12 @@ static inline u64 __arch_cmpxchg64_relaxed(volatile void *ptr, u64 old, u64 new) | |||
| 156 | 156 | } | |
| 157 | 157 | #define arch_cmpxchg64_relaxed __arch_cmpxchg64_relaxed | |
| 158 | 158 | ||
| 159 | + | static inline s64 arch_atomic64_cmpxchg_relaxed(atomic64_t *v, s64 old, s64 new) | |
| 160 | + | { | |
| 161 | + | return arch_cmpxchg64_relaxed(&v->counter, old, new); | |
| 162 | + | } | |
| 163 | + | #define arch_atomic64_cmpxchg_relaxed arch_atomic64_cmpxchg_relaxed | |
| 164 | + | ||
| 159 | 165 | static inline s64 arch_atomic64_xchg(atomic64_t *ptr, s64 new) | |
| 160 | 166 | { | |
| 161 | 167 | s64 prev; | |
modified arch/arc/include/asm/cmpxchg.h
| @@ -46,7 +46,7 @@ | |||
| 46 | 46 | __typeof__(*(ptr)) _n_ = (new); \ | |
| 47 | 47 | __typeof__(*(ptr)) _prev_; \ | |
| 48 | 48 | \ | |
| 49 | - | switch(sizeof((_p_))) { \ | |
| 49 | + | switch (sizeof(*(_p_))) { \ | |
| 50 | 50 | case 1: \ | |
| 51 | 51 | _prev_ = (__typeof__(*(ptr)))cmpxchg_emu_u8((volatile u8 *__force)_p_, (uintptr_t)_o_, (uintptr_t)_n_); \ | |
| 52 | 52 | break; \ | |
| @@ -102,7 +102,7 @@ | |||
| 102 | 102 | __typeof__(ptr) _p_ = (ptr); \ | |
| 103 | 103 | __typeof__(*(ptr)) _val_ = (val); \ | |
| 104 | 104 | \ | |
| 105 | - | switch(sizeof(*(_p_))) { \ | |
| 105 | + | switch (sizeof(*(_p_))) { \ | |
| 106 | 106 | case 4: \ | |
| 107 | 107 | _val_ = __arch_xchg(_p_, _val_); \ | |
| 108 | 108 | break; \ | |
modified arch/arc/kernel/setup.c
| @@ -593,6 +593,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
| 593 | 593 | cpu_id); | |
| 594 | 594 | } else { | |
| 595 | 595 | freq = clk_get_rate(cpu_clk); | |
| 596 | + | clk_put(cpu_clk); | |
| 596 | 597 | } | |
| 597 | 598 | if (freq) | |
| 598 | 599 | seq_printf(m, "CPU speed\t: %lu.%02lu Mhz\n", | |
modified arch/arc/kernel/smp.c
| @@ -12,7 +12,6 @@ | |||
| 12 | 12 | #include <linux/spinlock.h> | |
| 13 | 13 | #include <linux/sched/mm.h> | |
| 14 | 14 | #include <linux/interrupt.h> | |
| 15 | - | #include <linux/profile.h> | |
| 16 | 15 | #include <linux/mm.h> | |
| 17 | 16 | #include <linux/cpu.h> | |
| 18 | 17 | #include <linux/irq.h> | |
modified arch/arm/mach-socfpga/Kconfig
| @@ -16,7 +16,7 @@ menuconfig ARCH_INTEL_SOCFPGA | |||
| 16 | 16 | select ARM_ERRATA_775420 | |
| 17 | 17 | select PL310_ERRATA_588369 | |
| 18 | 18 | select PL310_ERRATA_727915 | |
| 19 | - | select PL310_ERRATA_753970 if PL310 | |
| 19 | + | select PL310_ERRATA_753970 | |
| 20 | 20 | select PL310_ERRATA_769419 | |
| 21 | 21 | select RESET_CONTROLLER | |
| 22 | 22 | ||
modified arch/arm64/Kconfig
| @@ -1040,9 +1040,17 @@ config ARM64_ERRATUM_1902691 | |||
| 1040 | 1040 | ||
| 1041 | 1041 | If unsure, say Y. | |
| 1042 | 1042 | ||
| 1043 | + | config ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1044 | + | bool | |
| 1045 | + | # Targeting errata affecting AMEVCNTR01, the AMU constant counter. | |
| 1046 | + | # On affected CPUs the counter may not increment at the expected rate, | |
| 1047 | + | # making it unreliable. As a result, AMU users should treat it as | |
| 1048 | + | # unavailable rather than relying on misleading counter values. | |
| 1049 | + | ||
| 1043 | 1050 | config ARM64_ERRATUM_2457168 | |
| 1044 | 1051 | bool "Cortex-A510: 2457168: workaround for AMEVCNTR01 incrementing incorrectly" | |
| 1045 | 1052 | depends on ARM64_AMU_EXTN | |
| 1053 | + | select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1046 | 1054 | default y | |
| 1047 | 1055 | help | |
| 1048 | 1056 | This option adds the workaround for ARM Cortex-A510 erratum 2457168. | |
| @@ -1073,6 +1081,28 @@ config ARM64_ERRATUM_2645198 | |||
| 1073 | 1081 | ||
| 1074 | 1082 | If unsure, say Y. | |
| 1075 | 1083 | ||
| 1084 | + | config ARM64_ERRATUM_3821522 | |
| 1085 | + | bool "Cortex-A725: 3821522: workaround for possible CNT_CYCLES increment error due to WFE/WFI" | |
| 1086 | + | depends on ARM64_AMU_EXTN | |
| 1087 | + | select ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 1088 | + | default y | |
| 1089 | + | help | |
| 1090 | + | This option adds the workaround for ARM Cortex-A725 erratum 3821522. | |
| 1091 | + | ||
| 1092 | + | On affected A725 cores, the CNT_CYCLES event may incur a significant | |
| 1093 | + | increment error when entering and subsequently exiting WFx. | |
| 1094 | + | As a result, the CNT_CYCLES may diverge from the system counter | |
| 1095 | + | frequency at which it is expected to increment. | |
| 1096 | + | This renders the AMU counter AMEVCNTR01, that implements CNT_CYCLES, | |
| 1097 | + | being unreliable and unsuitable for use. | |
| 1098 | + | ||
| 1099 | + | Since there is no hardware workaround, reads of the affected CNT_CYCLES | |
| 1100 | + | counter return 0 in the relevant paths. This causes users of the counter | |
| 1101 | + | to treat it as unavailable and is functionally equivalent to firmware | |
| 1102 | + | disabling the affected counter. | |
| 1103 | + | ||
| 1104 | + | If unsure, say Y. | |
| 1105 | + | ||
| 1076 | 1106 | config ARM64_WORKAROUND_SPECULATIVE_UNPRIV_LOAD | |
| 1077 | 1107 | bool | |
| 1078 | 1108 | ||
modified arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dtsi mode 100755 → 100644
No content changes.
modified arch/arm64/boot/dts/altera/socfpga_stratix10_socdk_emmc.dts mode 100755 → 100644
No content changes.
modified arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-an400.dts
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | }; | |
| 34 | 34 | ||
| 35 | 35 | &uart_a { | |
| 36 | - | clocks = <&xtal>, <&xtal>, <&xtal>; | |
| 36 | + | clocks = <&xtal>, <&clkc_periphs CLKID_SYS_UART_A>, <&xtal>; | |
| 37 | 37 | clock-names = "xtal", "pclk", "baud"; | |
| 38 | 38 | status = "okay"; | |
| 39 | 39 | }; | |
modified arch/arm64/boot/dts/amlogic/amlogic-t7-a311d2-khadas-vim4.dts
| @@ -71,7 +71,6 @@ | |||
| 71 | 71 | vin-supply = <&vddao_3v3>; | |
| 72 | 72 | gpio = <&gpio GPIOD_11 GPIO_ACTIVE_LOW>; | |
| 73 | 73 | regulator-boot-on; | |
| 74 | - | regulator-always-on; | |
| 75 | 74 | }; | |
| 76 | 75 | ||
| 77 | 76 | sdio_pwrseq: sdio-pwrseq { | |
| @@ -105,6 +104,66 @@ | |||
| 105 | 104 | enable-active-high; | |
| 106 | 105 | }; | |
| 107 | 106 | ||
| 107 | + | vdd_ddr: regulator-vddddr { | |
| 108 | + | /* | |
| 109 | + | * SY8003ADFC Regulator. | |
| 110 | + | */ | |
| 111 | + | compatible = "pwm-regulator"; | |
| 112 | + | regulator-name = "VDDDDR"; | |
| 113 | + | regulator-min-microvolt = <690000>; | |
| 114 | + | regulator-max-microvolt = <890000>; | |
| 115 | + | pwm-supply = <&dc_in>; | |
| 116 | + | pwms = <&pwm_ao_gh 0 1500 0>; | |
| 117 | + | pwm-dutycycle-range = <100 0>; | |
| 118 | + | regulator-boot-on; | |
| 119 | + | regulator-always-on; | |
| 120 | + | }; | |
| 121 | + | ||
| 122 | + | vdd_ee: regulator-vddee { | |
| 123 | + | /* | |
| 124 | + | * MP8756GD Regulator. | |
| 125 | + | */ | |
| 126 | + | compatible = "pwm-regulator"; | |
| 127 | + | regulator-name = "VDDEE"; | |
| 128 | + | regulator-min-microvolt = <700000>; | |
| 129 | + | regulator-max-microvolt = <922000>; | |
| 130 | + | pwm-supply = <&dc_in>; | |
| 131 | + | pwms = <&pwm_ao_ab 0 1500 0>; | |
| 132 | + | pwm-dutycycle-range = <100 0>; | |
| 133 | + | regulator-boot-on; | |
| 134 | + | regulator-always-on; | |
| 135 | + | }; | |
| 136 | + | ||
| 137 | + | vdd_gpu: regulator-vddgpu { | |
| 138 | + | /* | |
| 139 | + | * SY8003ADFC Regulator. | |
| 140 | + | */ | |
| 141 | + | compatible = "pwm-regulator"; | |
| 142 | + | regulator-name = "VDDGPU"; | |
| 143 | + | regulator-min-microvolt = <700000>; | |
| 144 | + | regulator-max-microvolt = <922000>; | |
| 145 | + | pwm-supply = <&dc_in>; | |
| 146 | + | pwms = <&pwm_ao_ef 0 1500 0>; | |
| 147 | + | pwm-dutycycle-range = <100 0>; | |
| 148 | + | regulator-boot-on; | |
| 149 | + | regulator-always-on; | |
| 150 | + | }; | |
| 151 | + | ||
| 152 | + | vdd_npu: regulator-vddnpu { | |
| 153 | + | /* | |
| 154 | + | * SY8003ADFC Regulator. | |
| 155 | + | */ | |
| 156 | + | compatible = "pwm-regulator"; | |
| 157 | + | regulator-name = "VDDNPU"; | |
| 158 | + | regulator-min-microvolt = <733000>; | |
| 159 | + | regulator-max-microvolt = <933000>; | |
| 160 | + | pwm-supply = <&dc_in>; | |
| 161 | + | pwms = <&pwm_ao_ef 1 1500 0>; | |
| 162 | + | pwm-dutycycle-range = <100 0>; | |
| 163 | + | regulator-boot-on; | |
| 164 | + | regulator-always-on; | |
| 165 | + | }; | |
| 166 | + | ||
| 108 | 167 | vddao_1v8: regulator-vddao-1v8 { | |
| 109 | 168 | compatible = "regulator-fixed"; | |
| 110 | 169 | regulator-name = "VDDAO_1V8"; | |
| @@ -123,6 +182,36 @@ | |||
| 123 | 182 | regulator-always-on; | |
| 124 | 183 | }; | |
| 125 | 184 | ||
| 185 | + | vddcpu_a: regulator-vddcpu-a { | |
| 186 | + | /* | |
| 187 | + | * MP8756GD Regulator. | |
| 188 | + | */ | |
| 189 | + | compatible = "pwm-regulator"; | |
| 190 | + | regulator-name = "VDDCPU_A"; | |
| 191 | + | regulator-min-microvolt = <689000>; | |
| 192 | + | regulator-max-microvolt = <1049000>; | |
| 193 | + | pwm-supply = <&dc_in>; | |
| 194 | + | pwms = <&pwm_ao_cd 1 1500 0>; | |
| 195 | + | pwm-dutycycle-range = <100 0>; | |
| 196 | + | regulator-boot-on; | |
| 197 | + | regulator-always-on; | |
| 198 | + | }; | |
| 199 | + | ||
| 200 | + | vddcpu_b: regulator-vddcpu-b { | |
| 201 | + | /* | |
| 202 | + | * MP8756GD Regulator. | |
| 203 | + | */ | |
| 204 | + | compatible = "pwm-regulator"; | |
| 205 | + | regulator-name = "VDDCPU_B"; | |
| 206 | + | regulator-min-microvolt = <689000>; | |
| 207 | + | regulator-max-microvolt = <1049000>; | |
| 208 | + | pwm-supply = <&dc_in>; | |
| 209 | + | pwms = <&pwm_ao_ab 1 1500 0>; | |
| 210 | + | pwm-dutycycle-range = <100 0>; | |
| 211 | + | regulator-boot-on; | |
| 212 | + | regulator-always-on; | |
| 213 | + | }; | |
| 214 | + | ||
| 126 | 215 | vddio_1v8: regulator-vddio-1v8 { | |
| 127 | 216 | compatible = "regulator-fixed"; | |
| 128 | 217 | regulator-name = "VDDIO_1V8"; | |
| @@ -173,9 +262,27 @@ | |||
| 173 | 262 | pinctrl-names = "default"; | |
| 174 | 263 | }; | |
| 175 | 264 | ||
| 265 | + | &pwm_ao_ab { | |
| 266 | + | status = "okay"; | |
| 267 | + | pinctrl-0 = <&pwm_ao_a_pins>, <&pwm_ao_b_pins>; | |
| 268 | + | pinctrl-names = "default"; | |
| 269 | + | }; | |
| 270 | + | ||
| 176 | 271 | &pwm_ao_cd { | |
| 177 | 272 | status = "okay"; | |
| 178 | - | pinctrl-0 = <&pwm_ao_c_d_pins>; | |
| 273 | + | pinctrl-0 = <&pwm_ao_c_d_pins>, <&pwm_ao_d_pins>; | |
| 274 | + | pinctrl-names = "default"; | |
| 275 | + | }; | |
| 276 | + | ||
| 277 | + | &pwm_ao_ef { | |
| 278 | + | status = "okay"; | |
| 279 | + | pinctrl-0 = <&pwm_ao_e_pins>, <&pwm_ao_f_pins>; | |
| 280 | + | pinctrl-names = "default"; | |
| 281 | + | }; | |
| 282 | + | ||
| 283 | + | &pwm_ao_gh { | |
| 284 | + | status = "okay"; | |
| 285 | + | pinctrl-0 = <&pwm_ao_g_e_pins>; | |
| 179 | 286 | pinctrl-names = "default"; | |
| 180 | 287 | }; | |
| 181 | 288 | ||
| @@ -266,6 +373,6 @@ | |||
| 266 | 373 | ||
| 267 | 374 | &uart_a { | |
| 268 | 375 | status = "okay"; | |
| 269 | - | clocks = <&xtal>, <&xtal>, <&xtal>; | |
| 376 | + | clocks = <&xtal>, <&clkc_periphs CLKID_SYS_UART_A>, <&xtal>; | |
| 270 | 377 | clock-names = "xtal", "pclk", "baud"; | |
| 271 | 378 | }; | |
modified arch/arm64/boot/dts/amlogic/amlogic-t7.dtsi
| @@ -458,9 +458,25 @@ | |||
| 458 | 458 | }; | |
| 459 | 459 | }; | |
| 460 | 460 | ||
| 461 | - | pwm_ao_g_pins: pwm-ao-g { | |
| 461 | + | pwm_ao_g_d11_pins: pwm-ao-g-d11 { | |
| 462 | 462 | mux { | |
| 463 | - | groups = "pwm_ao_g"; | |
| 463 | + | groups = "pwm_ao_g_d11"; | |
| 464 | + | function = "pwm_ao_g"; | |
| 465 | + | bias-disable; | |
| 466 | + | }; | |
| 467 | + | }; | |
| 468 | + | ||
| 469 | + | pwm_ao_g_d7_pins: pwm-ao-g-d7 { | |
| 470 | + | mux { | |
| 471 | + | groups = "pwm_ao_g_d7"; | |
| 472 | + | function = "pwm_ao_g"; | |
| 473 | + | bias-disable; | |
| 474 | + | }; | |
| 475 | + | }; | |
| 476 | + | ||
| 477 | + | pwm_ao_g_e_pins: pwm-ao-g-e { | |
| 478 | + | mux { | |
| 479 | + | groups = "pwm_ao_g_e"; | |
| 464 | 480 | function = "pwm_ao_g"; | |
| 465 | 481 | bias-disable; | |
| 466 | 482 | }; | |
| @@ -474,9 +490,17 @@ | |||
| 474 | 490 | }; | |
| 475 | 491 | }; | |
| 476 | 492 | ||
| 477 | - | pwm_ao_h_pins: pwm-ao-h { | |
| 493 | + | pwm_ao_h_d5_pins: pwm-ao-h-d5 { | |
| 478 | 494 | mux { | |
| 479 | - | groups = "pwm_ao_h"; | |
| 495 | + | groups = "pwm_ao_h_d5"; | |
| 496 | + | function = "pwm_ao_h"; | |
| 497 | + | bias-disable; | |
| 498 | + | }; | |
| 499 | + | }; | |
| 500 | + | ||
| 501 | + | pwm_ao_h_d10_pins: pwm-ao-h-d10 { | |
| 502 | + | mux { | |
| 503 | + | groups = "pwm_ao_h_d10"; | |
| 480 | 504 | function = "pwm_ao_h"; | |
| 481 | 505 | bias-disable; | |
| 482 | 506 | }; | |
| @@ -522,9 +546,17 @@ | |||
| 522 | 546 | }; | |
| 523 | 547 | }; | |
| 524 | 548 | ||
| 525 | - | pwm_vs_pins: pwm-vs { | |
| 549 | + | pwm_vs_y_pins: pwm-vs-y { | |
| 550 | + | mux { | |
| 551 | + | groups = "pwm_vs_y"; | |
| 552 | + | function = "pwm_vs"; | |
| 553 | + | bias-disable; | |
| 554 | + | }; | |
| 555 | + | }; | |
| 556 | + | ||
| 557 | + | pwm_vs_h_pins: pwm-vs-h { | |
| 526 | 558 | mux { | |
| 527 | - | groups = "pwm_vs"; | |
| 559 | + | groups = "pwm_vs_h"; | |
| 528 | 560 | function = "pwm_vs"; | |
| 529 | 561 | bias-disable; | |
| 530 | 562 | }; | |
modified arch/arm64/boot/dts/freescale/fsl-lx216x.dtsi
| @@ -1602,7 +1602,7 @@ | |||
| 1602 | 1602 | }; | |
| 1603 | 1603 | ||
| 1604 | 1604 | dspi2_miso_mosi_pins: iic5-spi3-pins { | |
| 1605 | - | pinctrl-single,bits = <0x3 (0x2 << 9) (0x7 << 9)>; | |
| 1605 | + | pinctrl-single,bits = <0x0 (0x3 << 9) (0x7 << 9)>; | |
| 1606 | 1606 | }; | |
| 1607 | 1607 | ||
| 1608 | 1608 | i2c5_pins: iic6-i2c-pins { | |
| @@ -1622,7 +1622,7 @@ | |||
| 1622 | 1622 | }; | |
| 1623 | 1623 | ||
| 1624 | 1624 | gpio1_31_28_pins: xspi1-data74-gpio-pins { | |
| 1625 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 15)>; | |
| 1625 | + | pinctrl-single,bits = <0x0 (0x1 << 15) (0x7 << 15)>; | |
| 1626 | 1626 | }; | |
| 1627 | 1627 | ||
| 1628 | 1628 | fspi_data30_pins: xspi1-data30-pins { | |
| @@ -1630,7 +1630,7 @@ | |||
| 1630 | 1630 | }; | |
| 1631 | 1631 | ||
| 1632 | 1632 | gpio1_27_24_pins: xspi1-data30-gpio-pins { | |
| 1633 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 18)>; | |
| 1633 | + | pinctrl-single,bits = <0x0 (0x1 << 18) (0x7 << 18)>; | |
| 1634 | 1634 | }; | |
| 1635 | 1635 | ||
| 1636 | 1636 | fspi_dqs_sck_cs10_pins: xspi1-base-pins { | |
| @@ -1638,7 +1638,7 @@ | |||
| 1638 | 1638 | }; | |
| 1639 | 1639 | ||
| 1640 | 1640 | gpio1_23_20_pins: xspi1-base-gpio-pins { | |
| 1641 | - | pinctrl-single,bits = <0x0 0x1 (0x7 << 21)>; | |
| 1641 | + | pinctrl-single,bits = <0x0 (0x1 << 21) (0x7 << 21)>; | |
| 1642 | 1642 | }; | |
| 1643 | 1643 | ||
| 1644 | 1644 | esdhc0_cmd_data30_clk_vsel_pins: sdhc1-base-sdhc-vsel-pins { | |
| @@ -1687,12 +1687,19 @@ | |||
| 1687 | 1687 | }; | |
| 1688 | 1688 | ||
| 1689 | 1689 | /* RCWSR14 */ | |
| 1690 | + | /* | |
| 1691 | + | * IIC1_PMUX is a single bit at RCWSR14[10], but bit-per-mux | |
| 1692 | + | * uses the mask for the field to clear before applying the | |
| 1693 | + | * value. | |
| 1694 | + | * So bits 11 and 12, which are reserved, are written as 0 | |
| 1695 | + | * on every mux switch, it is harmless. | |
| 1696 | + | */ | |
| 1690 | 1697 | i2c0_pins: iic1-i2c-pins { | |
| 1691 | - | pinctrl-single,bits = <0x8 0x0 (0x1 << 10)>; | |
| 1698 | + | pinctrl-single,bits = <0x8 0x0 (0x7 << 10)>; | |
| 1692 | 1699 | }; | |
| 1693 | 1700 | ||
| 1694 | 1701 | gpio0_3_2_pins: iic1-gpio-pins { | |
| 1695 | - | pinctrl-single,bits = <0x8 (0x1 << 10) (0x1 << 10)>; | |
| 1702 | + | pinctrl-single,bits = <0x8 (0x1 << 10) (0x7 << 10)>; | |
| 1696 | 1703 | }; | |
| 1697 | 1704 | }; | |
| 1698 | 1705 | ||
modified arch/arm64/boot/dts/freescale/imx8mp-var-dart-sonata.dts
| @@ -511,6 +511,7 @@ | |||
| 511 | 511 | pinctrl-2 = <&pinctrl_usdhc2_200mhz>, <&pinctrl_usdhc2_gpio>; | |
| 512 | 512 | cd-gpios = <&gpio2 12 GPIO_ACTIVE_LOW>; | |
| 513 | 513 | vmmc-supply = <®_usdhc2_vmmc>; | |
| 514 | + | vqmmc-supply = <&ldo5>; | |
| 514 | 515 | bus-width = <4>; | |
| 515 | 516 | status = "okay"; | |
| 516 | 517 | }; | |
modified arch/arm64/boot/dts/qcom/x1-microsoft-denali.dtsi
| @@ -863,11 +863,11 @@ | |||
| 863 | 863 | }; | |
| 864 | 864 | ||
| 865 | 865 | &lpass_vamacro { | |
| 866 | - | pinctrl-0 = <&dmic01_default>, <&dmic23_default>; | |
| 866 | + | pinctrl-0 = <&dmic01_default>; | |
| 867 | 867 | pinctrl-names = "default"; | |
| 868 | 868 | ||
| 869 | 869 | vdd-micb-supply = <&vreg_l1b_1p8>; | |
| 870 | - | qcom,dmic-sample-rate = <4800000>; | |
| 870 | + | qcom,dmic-sample-rate = <2400000>; | |
| 871 | 871 | }; | |
| 872 | 872 | ||
| 873 | 873 | &mdss { | |
modified arch/arm64/boot/dts/renesas/r8a779f0.dtsi
| @@ -901,6 +901,7 @@ | |||
| 901 | 901 | clocks = <&cpg CPG_MOD 1514>, <&ufs30_clk>; | |
| 902 | 902 | clock-names = "fck", "ref_clk"; | |
| 903 | 903 | freq-table-hz = <200000000 200000000>, <38400000 38400000>; | |
| 904 | + | lanes-per-direction = <1>; | |
| 904 | 905 | power-domains = <&sysc R8A779F0_PD_ALWAYS_ON>; | |
| 905 | 906 | resets = <&cpg 1514>; | |
| 906 | 907 | status = "disabled"; | |
modified arch/arm64/boot/dts/renesas/r9a09g047.dtsi
| @@ -1913,23 +1913,28 @@ | |||
| 1913 | 1913 | ||
| 1914 | 1914 | mtl_tx_setup0: tx-queues-config { | |
| 1915 | 1915 | snps,tx-queues-to-use = <4>; | |
| 1916 | + | snps,tx-sched-wrr; | |
| 1916 | 1917 | ||
| 1917 | 1918 | queue0 { | |
| 1919 | + | snps,weight = <0x10>; | |
| 1918 | 1920 | snps,dcb-algorithm; | |
| 1919 | 1921 | snps,priority = <0x1>; | |
| 1920 | 1922 | }; | |
| 1921 | 1923 | ||
| 1922 | 1924 | queue1 { | |
| 1925 | + | snps,weight = <0x12>; | |
| 1923 | 1926 | snps,dcb-algorithm; | |
| 1924 | 1927 | snps,priority = <0x2>; | |
| 1925 | 1928 | }; | |
| 1926 | 1929 | ||
| 1927 | 1930 | queue2 { | |
| 1931 | + | snps,weight = <0x14>; | |
| 1928 | 1932 | snps,dcb-algorithm; | |
| 1929 | 1933 | snps,priority = <0x4>; | |
| 1930 | 1934 | }; | |
| 1931 | 1935 | ||
| 1932 | 1936 | queue3 { | |
| 1937 | + | snps,weight = <0x18>; | |
| 1933 | 1938 | snps,dcb-algorithm; | |
| 1934 | 1939 | snps,priority = <0x8>; | |
| 1935 | 1940 | }; | |
| @@ -2013,23 +2018,28 @@ | |||
| 2013 | 2018 | ||
| 2014 | 2019 | mtl_tx_setup1: tx-queues-config { | |
| 2015 | 2020 | snps,tx-queues-to-use = <4>; | |
| 2021 | + | snps,tx-sched-wrr; | |
| 2016 | 2022 | ||
| 2017 | 2023 | queue0 { | |
| 2024 | + | snps,weight = <0x10>; | |
| 2018 | 2025 | snps,dcb-algorithm; | |
| 2019 | 2026 | snps,priority = <0x1>; | |
| 2020 | 2027 | }; | |
| 2021 | 2028 | ||
| 2022 | 2029 | queue1 { | |
| 2030 | + | snps,weight = <0x12>; | |
| 2023 | 2031 | snps,dcb-algorithm; | |
| 2024 | 2032 | snps,priority = <0x2>; | |
| 2025 | 2033 | }; | |
| 2026 | 2034 | ||
| 2027 | 2035 | queue2 { | |
| 2036 | + | snps,weight = <0x14>; | |
| 2028 | 2037 | snps,dcb-algorithm; | |
| 2029 | 2038 | snps,priority = <0x4>; | |
| 2030 | 2039 | }; | |
| 2031 | 2040 | ||
| 2032 | 2041 | queue3 { | |
| 2042 | + | snps,weight = <0x18>; | |
| 2033 | 2043 | snps,dcb-algorithm; | |
| 2034 | 2044 | snps,priority = <0x8>; | |
| 2035 | 2045 | }; | |
modified arch/arm64/boot/dts/renesas/r9a09g056.dtsi
| @@ -1585,23 +1585,28 @@ | |||
| 1585 | 1585 | ||
| 1586 | 1586 | mtl_tx_setup0: tx-queues-config { | |
| 1587 | 1587 | snps,tx-queues-to-use = <4>; | |
| 1588 | + | snps,tx-sched-wrr; | |
| 1588 | 1589 | ||
| 1589 | 1590 | queue0 { | |
| 1591 | + | snps,weight = <0x10>; | |
| 1590 | 1592 | snps,dcb-algorithm; | |
| 1591 | 1593 | snps,priority = <0x1>; | |
| 1592 | 1594 | }; | |
| 1593 | 1595 | ||
| 1594 | 1596 | queue1 { | |
| 1597 | + | snps,weight = <0x12>; | |
| 1595 | 1598 | snps,dcb-algorithm; | |
| 1596 | 1599 | snps,priority = <0x2>; | |
| 1597 | 1600 | }; | |
| 1598 | 1601 | ||
| 1599 | 1602 | queue2 { | |
| 1603 | + | snps,weight = <0x14>; | |
| 1600 | 1604 | snps,dcb-algorithm; | |
| 1601 | 1605 | snps,priority = <0x4>; | |
| 1602 | 1606 | }; | |
| 1603 | 1607 | ||
| 1604 | 1608 | queue3 { | |
| 1609 | + | snps,weight = <0x18>; | |
| 1605 | 1610 | snps,dcb-algorithm; | |
| 1606 | 1611 | snps,priority = <0x8>; | |
| 1607 | 1612 | }; | |
| @@ -1686,23 +1691,28 @@ | |||
| 1686 | 1691 | ||
| 1687 | 1692 | mtl_tx_setup1: tx-queues-config { | |
| 1688 | 1693 | snps,tx-queues-to-use = <4>; | |
| 1694 | + | snps,tx-sched-wrr; | |
| 1689 | 1695 | ||
| 1690 | 1696 | queue0 { | |
| 1697 | + | snps,weight = <0x10>; | |
| 1691 | 1698 | snps,dcb-algorithm; | |
| 1692 | 1699 | snps,priority = <0x1>; | |
| 1693 | 1700 | }; | |
| 1694 | 1701 | ||
| 1695 | 1702 | queue1 { | |
| 1703 | + | snps,weight = <0x12>; | |
| 1696 | 1704 | snps,dcb-algorithm; | |
| 1697 | 1705 | snps,priority = <0x2>; | |
| 1698 | 1706 | }; | |
| 1699 | 1707 | ||
| 1700 | 1708 | queue2 { | |
| 1709 | + | snps,weight = <0x14>; | |
| 1701 | 1710 | snps,dcb-algorithm; | |
| 1702 | 1711 | snps,priority = <0x4>; | |
| 1703 | 1712 | }; | |
| 1704 | 1713 | ||
| 1705 | 1714 | queue3 { | |
| 1715 | + | snps,weight = <0x18>; | |
| 1706 | 1716 | snps,dcb-algorithm; | |
| 1707 | 1717 | snps,priority = <0x8>; | |
| 1708 | 1718 | }; | |
modified arch/arm64/boot/dts/renesas/r9a09g057.dtsi
| @@ -1715,23 +1715,28 @@ | |||
| 1715 | 1715 | ||
| 1716 | 1716 | mtl_tx_setup0: tx-queues-config { | |
| 1717 | 1717 | snps,tx-queues-to-use = <4>; | |
| 1718 | + | snps,tx-sched-wrr; | |
| 1718 | 1719 | ||
| 1719 | 1720 | queue0 { | |
| 1721 | + | snps,weight = <0x10>; | |
| 1720 | 1722 | snps,dcb-algorithm; | |
| 1721 | 1723 | snps,priority = <0x1>; | |
| 1722 | 1724 | }; | |
| 1723 | 1725 | ||
| 1724 | 1726 | queue1 { | |
| 1727 | + | snps,weight = <0x12>; | |
| 1725 | 1728 | snps,dcb-algorithm; | |
| 1726 | 1729 | snps,priority = <0x2>; | |
| 1727 | 1730 | }; | |
| 1728 | 1731 | ||
| 1729 | 1732 | queue2 { | |
| 1733 | + | snps,weight = <0x14>; | |
| 1730 | 1734 | snps,dcb-algorithm; | |
| 1731 | 1735 | snps,priority = <0x4>; | |
| 1732 | 1736 | }; | |
| 1733 | 1737 | ||
| 1734 | 1738 | queue3 { | |
| 1739 | + | snps,weight = <0x18>; | |
| 1735 | 1740 | snps,dcb-algorithm; | |
| 1736 | 1741 | snps,priority = <0x8>; | |
| 1737 | 1742 | }; | |
| @@ -1816,23 +1821,28 @@ | |||
| 1816 | 1821 | ||
| 1817 | 1822 | mtl_tx_setup1: tx-queues-config { | |
| 1818 | 1823 | snps,tx-queues-to-use = <4>; | |
| 1824 | + | snps,tx-sched-wrr; | |
| 1819 | 1825 | ||
| 1820 | 1826 | queue0 { | |
| 1827 | + | snps,weight = <0x10>; | |
| 1821 | 1828 | snps,dcb-algorithm; | |
| 1822 | 1829 | snps,priority = <0x1>; | |
| 1823 | 1830 | }; | |
| 1824 | 1831 | ||
| 1825 | 1832 | queue1 { | |
| 1833 | + | snps,weight = <0x12>; | |
| 1826 | 1834 | snps,dcb-algorithm; | |
| 1827 | 1835 | snps,priority = <0x2>; | |
| 1828 | 1836 | }; | |
| 1829 | 1837 | ||
| 1830 | 1838 | queue2 { | |
| 1839 | + | snps,weight = <0x14>; | |
| 1831 | 1840 | snps,dcb-algorithm; | |
| 1832 | 1841 | snps,priority = <0x4>; | |
| 1833 | 1842 | }; | |
| 1834 | 1843 | ||
| 1835 | 1844 | queue3 { | |
| 1845 | + | snps,weight = <0x18>; | |
| 1836 | 1846 | snps,dcb-algorithm; | |
| 1837 | 1847 | snps,priority = <0x8>; | |
| 1838 | 1848 | }; | |
modified arch/arm64/boot/dts/renesas/r9a09g077.dtsi
| @@ -642,36 +642,45 @@ | |||
| 642 | 642 | ||
| 643 | 643 | mtl_tx_setup0: tx-queues-config { | |
| 644 | 644 | snps,tx-queues-to-use = <8>; | |
| 645 | + | snps,tx-sched-wrr; | |
| 645 | 646 | ||
| 646 | 647 | queue0 { | |
| 648 | + | snps,weight = <0x10>; | |
| 647 | 649 | snps,dcb-algorithm; | |
| 648 | 650 | }; | |
| 649 | 651 | ||
| 650 | 652 | queue1 { | |
| 653 | + | snps,weight = <0x11>; | |
| 651 | 654 | snps,dcb-algorithm; | |
| 652 | 655 | }; | |
| 653 | 656 | ||
| 654 | 657 | queue2 { | |
| 658 | + | snps,weight = <0x12>; | |
| 655 | 659 | snps,dcb-algorithm; | |
| 656 | 660 | }; | |
| 657 | 661 | ||
| 658 | 662 | queue3 { | |
| 663 | + | snps,weight = <0x13>; | |
| 659 | 664 | snps,dcb-algorithm; | |
| 660 | 665 | }; | |
| 661 | 666 | ||
| 662 | 667 | queue4 { | |
| 668 | + | snps,weight = <0x14>; | |
| 663 | 669 | snps,dcb-algorithm; | |
| 664 | 670 | }; | |
| 665 | 671 | ||
| 666 | 672 | queue5 { | |
| 673 | + | snps,weight = <0x15>; | |
| 667 | 674 | snps,dcb-algorithm; | |
| 668 | 675 | }; | |
| 669 | 676 | ||
| 670 | 677 | queue6 { | |
| 678 | + | snps,weight = <0x16>; | |
| 671 | 679 | snps,dcb-algorithm; | |
| 672 | 680 | }; | |
| 673 | 681 | ||
| 674 | 682 | queue7 { | |
| 683 | + | snps,weight = <0x17>; | |
| 675 | 684 | snps,dcb-algorithm; | |
| 676 | 685 | }; | |
| 677 | 686 | }; | |
| @@ -788,36 +797,45 @@ | |||
| 788 | 797 | ||
| 789 | 798 | mtl_tx_setup1: tx-queues-config { | |
| 790 | 799 | snps,tx-queues-to-use = <8>; | |
| 800 | + | snps,tx-sched-wrr; | |
| 791 | 801 | ||
| 792 | 802 | queue0 { | |
| 803 | + | snps,weight = <0x10>; | |
| 793 | 804 | snps,dcb-algorithm; | |
| 794 | 805 | }; | |
| 795 | 806 | ||
| 796 | 807 | queue1 { | |
| 808 | + | snps,weight = <0x11>; | |
| 797 | 809 | snps,dcb-algorithm; | |
| 798 | 810 | }; | |
| 799 | 811 | ||
| 800 | 812 | queue2 { | |
| 813 | + | snps,weight = <0x12>; | |
| 801 | 814 | snps,dcb-algorithm; | |
| 802 | 815 | }; | |
| 803 | 816 | ||
| 804 | 817 | queue3 { | |
| 818 | + | snps,weight = <0x13>; | |
| 805 | 819 | snps,dcb-algorithm; | |
| 806 | 820 | }; | |
| 807 | 821 | ||
| 808 | 822 | queue4 { | |
| 823 | + | snps,weight = <0x14>; | |
| 809 | 824 | snps,dcb-algorithm; | |
| 810 | 825 | }; | |
| 811 | 826 | ||
| 812 | 827 | queue5 { | |
| 828 | + | snps,weight = <0x15>; | |
| 813 | 829 | snps,dcb-algorithm; | |
| 814 | 830 | }; | |
| 815 | 831 | ||
| 816 | 832 | queue6 { | |
| 833 | + | snps,weight = <0x16>; | |
| 817 | 834 | snps,dcb-algorithm; | |
| 818 | 835 | }; | |
| 819 | 836 | ||
| 820 | 837 | queue7 { | |
| 838 | + | snps,weight = <0x17>; | |
| 821 | 839 | snps,dcb-algorithm; | |
| 822 | 840 | }; | |
| 823 | 841 | }; | |
| @@ -934,36 +952,45 @@ | |||
| 934 | 952 | ||
| 935 | 953 | mtl_tx_setup2: tx-queues-config { | |
| 936 | 954 | snps,tx-queues-to-use = <8>; | |
| 955 | + | snps,tx-sched-wrr; | |
| 937 | 956 | ||
| 938 | 957 | queue0 { | |
| 958 | + | snps,weight = <0x10>; | |
| 939 | 959 | snps,dcb-algorithm; | |
| 940 | 960 | }; | |
| 941 | 961 | ||
| 942 | 962 | queue1 { | |
| 963 | + | snps,weight = <0x11>; | |
| 943 | 964 | snps,dcb-algorithm; | |
| 944 | 965 | }; | |
| 945 | 966 | ||
| 946 | 967 | queue2 { | |
| 968 | + | snps,weight = <0x12>; | |
| 947 | 969 | snps,dcb-algorithm; | |
| 948 | 970 | }; | |
| 949 | 971 | ||
| 950 | 972 | queue3 { | |
| 973 | + | snps,weight = <0x13>; | |
| 951 | 974 | snps,dcb-algorithm; | |
| 952 | 975 | }; | |
| 953 | 976 | ||
| 954 | 977 | queue4 { | |
| 978 | + | snps,weight = <0x14>; | |
| 955 | 979 | snps,dcb-algorithm; | |
| 956 | 980 | }; | |
| 957 | 981 | ||
| 958 | 982 | queue5 { | |
| 983 | + | snps,weight = <0x15>; | |
| 959 | 984 | snps,dcb-algorithm; | |
| 960 | 985 | }; | |
| 961 | 986 | ||
| 962 | 987 | queue6 { | |
| 988 | + | snps,weight = <0x16>; | |
| 963 | 989 | snps,dcb-algorithm; | |
| 964 | 990 | }; | |
| 965 | 991 | ||
| 966 | 992 | queue7 { | |
| 993 | + | snps,weight = <0x17>; | |
| 967 | 994 | snps,dcb-algorithm; | |
| 968 | 995 | }; | |
| 969 | 996 | }; | |
modified arch/arm64/boot/dts/renesas/r9a09g087.dtsi
| @@ -643,36 +643,45 @@ | |||
| 643 | 643 | ||
| 644 | 644 | mtl_tx_setup0: tx-queues-config { | |
| 645 | 645 | snps,tx-queues-to-use = <8>; | |
| 646 | + | snps,tx-sched-wrr; | |
| 646 | 647 | ||
| 647 | 648 | queue0 { | |
| 649 | + | snps,weight = <0x10>; | |
| 648 | 650 | snps,dcb-algorithm; | |
| 649 | 651 | }; | |
| 650 | 652 | ||
| 651 | 653 | queue1 { | |
| 654 | + | snps,weight = <0x11>; | |
| 652 | 655 | snps,dcb-algorithm; | |
| 653 | 656 | }; | |
| 654 | 657 | ||
| 655 | 658 | queue2 { | |
| 659 | + | snps,weight = <0x12>; | |
| 656 | 660 | snps,dcb-algorithm; | |
| 657 | 661 | }; | |
| 658 | 662 | ||
| 659 | 663 | queue3 { | |
| 664 | + | snps,weight = <0x13>; | |
| 660 | 665 | snps,dcb-algorithm; | |
| 661 | 666 | }; | |
| 662 | 667 | ||
| 663 | 668 | queue4 { | |
| 669 | + | snps,weight = <0x14>; | |
| 664 | 670 | snps,dcb-algorithm; | |
| 665 | 671 | }; | |
| 666 | 672 | ||
| 667 | 673 | queue5 { | |
| 674 | + | snps,weight = <0x15>; | |
| 668 | 675 | snps,dcb-algorithm; | |
| 669 | 676 | }; | |
| 670 | 677 | ||
| 671 | 678 | queue6 { | |
| 679 | + | snps,weight = <0x16>; | |
| 672 | 680 | snps,dcb-algorithm; | |
| 673 | 681 | }; | |
| 674 | 682 | ||
| 675 | 683 | queue7 { | |
| 684 | + | snps,weight = <0x17>; | |
| 676 | 685 | snps,dcb-algorithm; | |
| 677 | 686 | }; | |
| 678 | 687 | }; | |
| @@ -790,36 +799,45 @@ | |||
| 790 | 799 | ||
| 791 | 800 | mtl_tx_setup1: tx-queues-config { | |
| 792 | 801 | snps,tx-queues-to-use = <8>; | |
| 802 | + | snps,tx-sched-wrr; | |
| 793 | 803 | ||
| 794 | 804 | queue0 { | |
| 805 | + | snps,weight = <0x10>; | |
| 795 | 806 | snps,dcb-algorithm; | |
| 796 | 807 | }; | |
| 797 | 808 | ||
| 798 | 809 | queue1 { | |
| 810 | + | snps,weight = <0x11>; | |
| 799 | 811 | snps,dcb-algorithm; | |
| 800 | 812 | }; | |
| 801 | 813 | ||
| 802 | 814 | queue2 { | |
| 815 | + | snps,weight = <0x12>; | |
| 803 | 816 | snps,dcb-algorithm; | |
| 804 | 817 | }; | |
| 805 | 818 | ||
| 806 | 819 | queue3 { | |
| 820 | + | snps,weight = <0x13>; | |
| 807 | 821 | snps,dcb-algorithm; | |
| 808 | 822 | }; | |
| 809 | 823 | ||
| 810 | 824 | queue4 { | |
| 825 | + | snps,weight = <0x14>; | |
| 811 | 826 | snps,dcb-algorithm; | |
| 812 | 827 | }; | |
| 813 | 828 | ||
| 814 | 829 | queue5 { | |
| 830 | + | snps,weight = <0x15>; | |
| 815 | 831 | snps,dcb-algorithm; | |
| 816 | 832 | }; | |
| 817 | 833 | ||
| 818 | 834 | queue6 { | |
| 835 | + | snps,weight = <0x16>; | |
| 819 | 836 | snps,dcb-algorithm; | |
| 820 | 837 | }; | |
| 821 | 838 | ||
| 822 | 839 | queue7 { | |
| 840 | + | snps,weight = <0x17>; | |
| 823 | 841 | snps,dcb-algorithm; | |
| 824 | 842 | }; | |
| 825 | 843 | }; | |
| @@ -937,36 +955,45 @@ | |||
| 937 | 955 | ||
| 938 | 956 | mtl_tx_setup2: tx-queues-config { | |
| 939 | 957 | snps,tx-queues-to-use = <8>; | |
| 958 | + | snps,tx-sched-wrr; | |
| 940 | 959 | ||
| 941 | 960 | queue0 { | |
| 961 | + | snps,weight = <0x10>; | |
| 942 | 962 | snps,dcb-algorithm; | |
| 943 | 963 | }; | |
| 944 | 964 | ||
| 945 | 965 | queue1 { | |
| 966 | + | snps,weight = <0x11>; | |
| 946 | 967 | snps,dcb-algorithm; | |
| 947 | 968 | }; | |
| 948 | 969 | ||
| 949 | 970 | queue2 { | |
| 971 | + | snps,weight = <0x12>; | |
| 950 | 972 | snps,dcb-algorithm; | |
| 951 | 973 | }; | |
| 952 | 974 | ||
| 953 | 975 | queue3 { | |
| 976 | + | snps,weight = <0x13>; | |
| 954 | 977 | snps,dcb-algorithm; | |
| 955 | 978 | }; | |
| 956 | 979 | ||
| 957 | 980 | queue4 { | |
| 981 | + | snps,weight = <0x14>; | |
| 958 | 982 | snps,dcb-algorithm; | |
| 959 | 983 | }; | |
| 960 | 984 | ||
| 961 | 985 | queue5 { | |
| 986 | + | snps,weight = <0x15>; | |
| 962 | 987 | snps,dcb-algorithm; | |
| 963 | 988 | }; | |
| 964 | 989 | ||
| 965 | 990 | queue6 { | |
| 991 | + | snps,weight = <0x16>; | |
| 966 | 992 | snps,dcb-algorithm; | |
| 967 | 993 | }; | |
| 968 | 994 | ||
| 969 | 995 | queue7 { | |
| 996 | + | snps,weight = <0x17>; | |
| 970 | 997 | snps,dcb-algorithm; | |
| 971 | 998 | }; | |
| 972 | 999 | }; | |
modified arch/arm64/include/asm/el2_setup.h
| @@ -418,14 +418,21 @@ | |||
| 418 | 418 | b.lt .Lskip_fgt2_\@ | |
| 419 | 419 | ||
| 420 | 420 | mov x0, xzr | |
| 421 | + | mov x2, xzr | |
| 421 | 422 | mrs x1, id_aa64dfr0_el1 | |
| 422 | 423 | ubfx x1, x1, #ID_AA64DFR0_EL1_PMUVer_SHIFT, #4 | |
| 423 | - | cmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9 | |
| 424 | - | b.lt .Lskip_pmuv3p9_\@ | |
| 424 | + | cmp x1, #ID_AA64DFR0_EL1_PMUVer_IMP_DEF | |
| 425 | + | ccmp x1, #ID_AA64DFR0_EL1_PMUVer_V3P9, #8, ne | |
| 426 | + | b.lt .Lskip_pmuv3p9_\@ // Skip if < PMUv3p9 or IMP_DEF | |
| 425 | 427 | ||
| 426 | 428 | orr x0, x0, #HDFGRTR2_EL2_nPMICNTR_EL0 | |
| 427 | 429 | orr x0, x0, #HDFGRTR2_EL2_nPMICFILTR_EL0 | |
| 428 | 430 | orr x0, x0, #HDFGRTR2_EL2_nPMUACR_EL1 | |
| 431 | + | orr x2, x2, #HDFGWTR2_EL2_nPMICNTR_EL0 | |
| 432 | + | orr x2, x2, #HDFGWTR2_EL2_nPMICFILTR_EL0 | |
| 433 | + | orr x2, x2, #HDFGWTR2_EL2_nPMUACR_EL1 | |
| 434 | + | /* PMZR_EL0 is write-only, so it has no read trap to disable */ | |
| 435 | + | orr x2, x2, #HDFGWTR2_EL2_nPMZR_EL0 | |
| 429 | 436 | .Lskip_pmuv3p9_\@: | |
| 430 | 437 | /* If SPE is implemented, */ | |
| 431 | 438 | __spe_vers_imp .Lskip_spefds_\@, ID_AA64DFR0_EL1_PMSVer_IMP, x1 | |
| @@ -436,10 +443,11 @@ | |||
| 436 | 443 | cbz x1, .Lskip_spefds_\@ | |
| 437 | 444 | /* disable traps of PMSDSFR to EL2. */ | |
| 438 | 445 | orr x0, x0, #HDFGRTR2_EL2_nPMSDSFR_EL1 | |
| 446 | + | orr x2, x2, #HDFGWTR2_EL2_nPMSDSFR_EL1 | |
| 439 | 447 | ||
| 440 | 448 | .Lskip_spefds_\@: | |
| 441 | 449 | msr_s SYS_HDFGRTR2_EL2, x0 | |
| 442 | - | msr_s SYS_HDFGWTR2_EL2, x0 | |
| 450 | + | msr_s SYS_HDFGWTR2_EL2, x2 | |
| 443 | 451 | msr_s SYS_HFGRTR2_EL2, xzr | |
| 444 | 452 | msr_s SYS_HFGWTR2_EL2, xzr | |
| 445 | 453 | msr_s SYS_HFGITR2_EL2, xzr | |
modified arch/arm64/include/asm/io.h
| @@ -280,7 +280,8 @@ static inline void __iomem *ioremap_prot(phys_addr_t phys, size_t size, | |||
| 280 | 280 | pgprot_t prot; | |
| 281 | 281 | ptval_t user_prot_val = pgprot_val(user_prot); | |
| 282 | 282 | ||
| 283 | - | if (WARN_ON_ONCE(!(user_prot_val & PTE_USER))) | |
| 283 | + | /* Reject PROT_NONE and exec-only */ | |
| 284 | + | if (!(user_prot_val & PTE_USER)) | |
| 284 | 285 | return NULL; | |
| 285 | 286 | ||
| 286 | 287 | prot = __pgprot_modify(PAGE_KERNEL, PTE_ATTRINDX_MASK, | |
modified arch/arm64/include/asm/kvm_host.h
| @@ -322,7 +322,7 @@ struct kvm_arch { | |||
| 322 | 322 | * Stage 2 paging state for VMs with nested S2 using a virtual | |
| 323 | 323 | * VMID. | |
| 324 | 324 | */ | |
| 325 | - | struct kvm_s2_mmu *nested_mmus; | |
| 325 | + | struct kvm_s2_mmu **nested_mmus; | |
| 326 | 326 | size_t nested_mmus_size; | |
| 327 | 327 | int nested_mmus_next; | |
| 328 | 328 | ||
modified arch/arm64/include/asm/kvm_nested.h
| @@ -66,7 +66,8 @@ static inline u64 translate_ttbr0_el2_to_ttbr0_el1(u64 ttbr0) | |||
| 66 | 66 | ||
| 67 | 67 | extern bool forward_smc_trap(struct kvm_vcpu *vcpu); | |
| 68 | 68 | extern bool forward_debug_exception(struct kvm_vcpu *vcpu); | |
| 69 | - | extern void kvm_init_nested(struct kvm *kvm); | |
| 69 | + | extern int kvm_init_nested(struct kvm *kvm); | |
| 70 | + | extern void kvm_destroy_nested(struct kvm *kvm); | |
| 70 | 71 | extern int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu); | |
| 71 | 72 | extern void kvm_init_nested_s2_mmu(struct kvm_s2_mmu *mmu); | |
| 72 | 73 | extern struct kvm_s2_mmu *lookup_s2_mmu(struct kvm_vcpu *vcpu); | |
modified arch/arm64/include/asm/kvm_pkvm.h
| @@ -65,8 +65,7 @@ static inline bool kvm_pkvm_ioctl_allowed(struct kvm *kvm, unsigned int ioctl) | |||
| 65 | 65 | int r; | |
| 66 | 66 | ||
| 67 | 67 | r = kvm_get_cap_for_kvm_ioctl(ioctl, &ext); | |
| 68 | - | ||
| 69 | - | if (WARN_ON_ONCE(r < 0)) | |
| 68 | + | if (r < 0) | |
| 70 | 69 | return false; | |
| 71 | 70 | ||
| 72 | 71 | return kvm_pkvm_ext_allowed(kvm, ext); | |
modified arch/arm64/include/asm/percpu.h
| @@ -77,7 +77,7 @@ __percpu_##name##_case_##sz(void *ptr, unsigned long val) \ | |||
| 77 | 77 | " stxr" #sfx "\t%w[loop], %" #w "[tmp], %[ptr]\n" \ | |
| 78 | 78 | " cbnz %w[loop], 1b", \ | |
| 79 | 79 | /* LSE atomics */ \ | |
| 80 | - | #op_lse "\t%" #w "[val], %" #w "[tmp], %[ptr]\n" \ | |
| 80 | + | #op_lse #sfx "\t%" #w "[val], %" #w "[tmp], %[ptr]\n" \ | |
| 81 | 81 | __nops(3)) \ | |
| 82 | 82 | : [loop] "=&r" (loop), [tmp] "=&r" (tmp), \ | |
| 83 | 83 | [ptr] "+Q"(*(u##sz *)ptr) \ | |
| @@ -98,7 +98,7 @@ __percpu_##name##_return_case_##sz(void *ptr, unsigned long val) \ | |||
| 98 | 98 | " stxr" #sfx "\t%w[loop], %" #w "[ret], %[ptr]\n" \ | |
| 99 | 99 | " cbnz %w[loop], 1b", \ | |
| 100 | 100 | /* LSE atomics */ \ | |
| 101 | - | #op_lse "\t%" #w "[val], %" #w "[ret], %[ptr]\n" \ | |
| 101 | + | #op_lse #sfx "\t%" #w "[val], %" #w "[ret], %[ptr]\n" \ | |
| 102 | 102 | #op_llsc "\t%" #w "[ret], %" #w "[ret], %" #w "[val]\n" \ | |
| 103 | 103 | __nops(2)) \ | |
| 104 | 104 | : [loop] "=&r" (loop), [ret] "=&r" (ret), \ | |
| @@ -179,13 +179,13 @@ PERCPU_RET_OP(add, add, ldadd) | |||
| 179 | 179 | _pcp_protect_return(__percpu_read_64, pcp) | |
| 180 | 180 | ||
| 181 | 181 | #define this_cpu_write_1(pcp, val) \ | |
| 182 | - | _pcp_protect(__percpu_write_8, pcp, (unsigned long)val) | |
| 182 | + | _pcp_protect(__percpu_write_8, pcp, (unsigned long)(val)) | |
| 183 | 183 | #define this_cpu_write_2(pcp, val) \ | |
| 184 | - | _pcp_protect(__percpu_write_16, pcp, (unsigned long)val) | |
| 184 | + | _pcp_protect(__percpu_write_16, pcp, (unsigned long)(val)) | |
| 185 | 185 | #define this_cpu_write_4(pcp, val) \ | |
| 186 | - | _pcp_protect(__percpu_write_32, pcp, (unsigned long)val) | |
| 186 | + | _pcp_protect(__percpu_write_32, pcp, (unsigned long)(val)) | |
| 187 | 187 | #define this_cpu_write_8(pcp, val) \ | |
| 188 | - | _pcp_protect(__percpu_write_64, pcp, (unsigned long)val) | |
| 188 | + | _pcp_protect(__percpu_write_64, pcp, (unsigned long)(val)) | |
| 189 | 189 | ||
| 190 | 190 | #define this_cpu_add_1(pcp, val) \ | |
| 191 | 191 | _pcp_protect(__percpu_add_case_8, pcp, val) | |
| @@ -206,13 +206,13 @@ PERCPU_RET_OP(add, add, ldadd) | |||
| 206 | 206 | _pcp_protect_return(__percpu_add_return_case_64, pcp, val) | |
| 207 | 207 | ||
| 208 | 208 | #define this_cpu_and_1(pcp, val) \ | |
| 209 | - | _pcp_protect(__percpu_andnot_case_8, pcp, ~val) | |
| 209 | + | _pcp_protect(__percpu_andnot_case_8, pcp, ~(u8)(val)) | |
| 210 | 210 | #define this_cpu_and_2(pcp, val) \ | |
| 211 | - | _pcp_protect(__percpu_andnot_case_16, pcp, ~val) | |
| 211 | + | _pcp_protect(__percpu_andnot_case_16, pcp, ~(u16)(val)) | |
| 212 | 212 | #define this_cpu_and_4(pcp, val) \ | |
| 213 | - | _pcp_protect(__percpu_andnot_case_32, pcp, ~val) | |
| 213 | + | _pcp_protect(__percpu_andnot_case_32, pcp, ~(u32)(val)) | |
| 214 | 214 | #define this_cpu_and_8(pcp, val) \ | |
| 215 | - | _pcp_protect(__percpu_andnot_case_64, pcp, ~val) | |
| 215 | + | _pcp_protect(__percpu_andnot_case_64, pcp, ~(u64)(val)) | |
| 216 | 216 | ||
| 217 | 217 | #define this_cpu_or_1(pcp, val) \ | |
| 218 | 218 | _pcp_protect(__percpu_or_case_8, pcp, val) | |
modified arch/arm64/kernel/Makefile
| @@ -25,6 +25,9 @@ KASAN_SANITIZE_stacktrace.o := n | |||
| 25 | 25 | KCOV_INSTRUMENT_entry-common.o := n | |
| 26 | 26 | KCOV_INSTRUMENT_idle.o := n | |
| 27 | 27 | ||
| 28 | + | # Softirq stack switching can run outside interrupt context. | |
| 29 | + | KCOV_INSTRUMENT_irq.o := n | |
| 30 | + | ||
| 28 | 31 | # Object file lists. | |
| 29 | 32 | obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ | |
| 30 | 33 | entry-common.o process.o ptrace.o \ | |
modified arch/arm64/kernel/cpu_errata.c
| @@ -28,18 +28,21 @@ bool cpu_errata_set_target_impl(u64 num, void *impl_cpus) | |||
| 28 | 28 | return true; | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | + | static inline bool __is_midr_in_range(u32 midr, struct midr_range const *range) | |
| 32 | + | { | |
| 33 | + | return midr_is_cpu_model_range(midr, range->model, | |
| 34 | + | range->rv_min, range->rv_max); | |
| 35 | + | } | |
| 36 | + | ||
| 31 | 37 | static inline bool is_midr_in_range(struct midr_range const *range) | |
| 32 | 38 | { | |
| 33 | 39 | int i; | |
| 34 | 40 | ||
| 35 | 41 | if (!target_impl_cpu_num) | |
| 36 | - | return midr_is_cpu_model_range(read_cpuid_id(), range->model, | |
| 37 | - | range->rv_min, range->rv_max); | |
| 42 | + | return __is_midr_in_range(read_cpuid_id(), range); | |
| 38 | 43 | ||
| 39 | 44 | for (i = 0; i < target_impl_cpu_num; i++) { | |
| 40 | - | if (midr_is_cpu_model_range(target_impl_cpus[i].midr, | |
| 41 | - | range->model, | |
| 42 | - | range->rv_min, range->rv_max)) | |
| 45 | + | if (__is_midr_in_range(target_impl_cpus[i].midr, range)) | |
| 43 | 46 | return true; | |
| 44 | 47 | } | |
| 45 | 48 | return false; | |
| @@ -59,7 +62,7 @@ __is_affected_midr_range(const struct arm64_cpu_capabilities *entry, | |||
| 59 | 62 | u32 midr, u32 revidr) | |
| 60 | 63 | { | |
| 61 | 64 | const struct arm64_midr_revidr *fix; | |
| 62 | - | if (!is_midr_in_range(&entry->midr_range)) | |
| 65 | + | if (!__is_midr_in_range(midr, &entry->midr_range)) | |
| 63 | 66 | return false; | |
| 64 | 67 | ||
| 65 | 68 | midr &= MIDR_REVISION_MASK | MIDR_VARIANT_MASK; | |
| @@ -381,6 +384,20 @@ static const struct arm64_cpu_capabilities arm64_repeat_tlbi_list[] = { | |||
| 381 | 384 | }; | |
| 382 | 385 | #endif | |
| 383 | 386 | ||
| 387 | + | #ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 388 | + | static const struct midr_range workaround_amu_constcnt_list[] = { | |
| 389 | + | #ifdef CONFIG_ARM64_ERRATUM_2457168 | |
| 390 | + | /* Cortex-A510 r0p0-r1p1 */ | |
| 391 | + | MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1), | |
| 392 | + | #endif | |
| 393 | + | #ifdef CONFIG_ARM64_ERRATUM_3821522 | |
| 394 | + | /* Cortex-A725 r0p0 - r0p2 */ | |
| 395 | + | MIDR_RANGE(MIDR_CORTEX_A725, 0, 0, 0, 2), | |
| 396 | + | #endif | |
| 397 | + | {} | |
| 398 | + | }; | |
| 399 | + | #endif /* CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT */ | |
| 400 | + | ||
| 384 | 401 | #ifdef CONFIG_CAVIUM_ERRATUM_23154 | |
| 385 | 402 | static const struct midr_range cavium_erratum_23154_cpus[] = { | |
| 386 | 403 | MIDR_ALL_VERSIONS(MIDR_THUNDERX), | |
| @@ -916,14 +933,12 @@ const struct arm64_cpu_capabilities arm64_errata[] = { | |||
| 916 | 933 | ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) | |
| 917 | 934 | }, | |
| 918 | 935 | #endif | |
| 919 | - | #ifdef CONFIG_ARM64_ERRATUM_2457168 | |
| 936 | + | #ifdef CONFIG_ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT | |
| 920 | 937 | { | |
| 921 | - | .desc = "ARM erratum 2457168", | |
| 922 | - | .capability = ARM64_WORKAROUND_2457168, | |
| 938 | + | .desc = "Broken AMU AMEVCNTR01 (const counter)", | |
| 939 | + | .capability = ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT, | |
| 923 | 940 | .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, | |
| 924 | - | ||
| 925 | - | /* Cortex-A510 r0p0-r1p1 */ | |
| 926 | - | CAP_MIDR_RANGE(MIDR_CORTEX_A510, 0, 0, 1, 1) | |
| 941 | + | CAP_MIDR_RANGE_LIST(workaround_amu_constcnt_list) | |
| 927 | 942 | }, | |
| 928 | 943 | #endif | |
| 929 | 944 | #ifdef CONFIG_ARM64_ERRATUM_2038923 | |
modified arch/arm64/kernel/cpufeature.c
| @@ -2089,7 +2089,7 @@ static void cpu_amu_enable(struct arm64_cpu_capabilities const *cap) | |||
| 2089 | 2089 | cpumask_set_cpu(smp_processor_id(), &amu_cpus); | |
| 2090 | 2090 | ||
| 2091 | 2091 | /* 0 reference values signal broken/disabled counters */ | |
| 2092 | - | if (!this_cpu_has_cap(ARM64_WORKAROUND_2457168)) | |
| 2092 | + | if (!this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT)) | |
| 2093 | 2093 | update_freq_counters_refs(); | |
| 2094 | 2094 | } | |
| 2095 | 2095 | } | |
modified arch/arm64/kernel/hibernate-asm.S
| @@ -89,6 +89,8 @@ alternative_insn "dc cvau, x4", "dc civac, x4", ARM64_WORKAROUND_CLEAN_CACHE | |||
| 89 | 89 | isb | |
| 90 | 90 | ||
| 91 | 91 | cbz x24, 3f /* Do we need to re-initialise EL2? */ | |
| 92 | + | mov x1, x24 | |
| 93 | + | mov x0, #HVC_SET_VECTORS | |
| 92 | 94 | hvc #0 | |
| 93 | 95 | 3: ret | |
| 94 | 96 | SYM_CODE_END(swsusp_arch_suspend_exit) | |
modified arch/arm64/kernel/hibernate.c
| @@ -423,8 +423,8 @@ int __nocfi swsusp_arch_resume(void) | |||
| 423 | 423 | * Create a second copy of just the linear map, and use this when | |
| 424 | 424 | * restoring. | |
| 425 | 425 | */ | |
| 426 | - | rc = trans_pgd_create_copy(&trans_info, &tmp_pg_dir, PAGE_OFFSET, | |
| 427 | - | PAGE_END); | |
| 426 | + | rc = trans_pgd_create_copy(&trans_info, &tmp_pg_dir, | |
| 427 | + | _PAGE_OFFSET(vabits_actual), PAGE_END); | |
| 428 | 428 | if (rc) | |
| 429 | 429 | return rc; | |
| 430 | 430 | ||
modified arch/arm64/kernel/mte.c
| @@ -476,7 +476,7 @@ static int __access_remote_tags(struct mm_struct *mm, unsigned long addr, | |||
| 476 | 476 | * was never mapped with PROT_MTE. | |
| 477 | 477 | */ | |
| 478 | 478 | if (!(vma->vm_flags & VM_MTE)) { | |
| 479 | - | err = -EOPNOTSUPP; | |
| 479 | + | err = -EIO; | |
| 480 | 480 | put_page(page); | |
| 481 | 481 | break; | |
| 482 | 482 | } | |
modified arch/arm64/kernel/pi/idreg-override.c
| @@ -186,6 +186,7 @@ static const struct ftr_set_desc isar2 __prel64_initconst = { | |||
| 186 | 186 | .name = "id_aa64isar2", | |
| 187 | 187 | .override = &id_aa64isar2_override, | |
| 188 | 188 | .fields = { | |
| 189 | + | FIELD("wfxt", ID_AA64ISAR2_EL1_WFxT_SHIFT, NULL), | |
| 189 | 190 | FIELD("gpa3", ID_AA64ISAR2_EL1_GPA3_SHIFT, NULL), | |
| 190 | 191 | FIELD("apa3", ID_AA64ISAR2_EL1_APA3_SHIFT, NULL), | |
| 191 | 192 | FIELD("mops", ID_AA64ISAR2_EL1_MOPS_SHIFT, NULL), | |
| @@ -254,6 +255,7 @@ static const struct { | |||
| 254 | 255 | "id_aa64isar1.api=0 id_aa64isar1.apa=0 " | |
| 255 | 256 | "id_aa64isar2.gpa3=0 id_aa64isar2.apa3=0" }, | |
| 256 | 257 | { "arm64.nomops", "id_aa64isar2.mops=0" }, | |
| 258 | + | { "arm64.nowfxt", "id_aa64isar2.wfxt=0" }, | |
| 257 | 259 | { "arm64.nomte", "id_aa64pfr1.mte=0" }, | |
| 258 | 260 | { "nokaslr", "arm64_sw.nokaslr=1" }, | |
| 259 | 261 | { "rodata=off", "arm64_sw.rodataoff=1" }, | |
modified arch/arm64/kernel/signal.c
| @@ -433,6 +433,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 433 | 433 | unsigned int vl, vq; | |
| 434 | 434 | struct user_fpsimd_state fpsimd; | |
| 435 | 435 | u16 user_vl, flags; | |
| 436 | + | bool fpsimd_only; | |
| 436 | 437 | bool sm; | |
| 437 | 438 | ||
| 438 | 439 | if (user->sve_size < sizeof(*user->sve)) | |
| @@ -443,19 +444,33 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 443 | 444 | if (err) | |
| 444 | 445 | return err; | |
| 445 | 446 | ||
| 447 | + | fpsimd_only = (user->sve_size == sizeof(*user->sve)); | |
| 446 | 448 | sm = flags & SVE_SIG_FLAG_SM; | |
| 449 | + | ||
| 447 | 450 | if (sm) { | |
| 448 | 451 | if (!system_supports_sme()) | |
| 449 | 452 | return -EINVAL; | |
| 450 | 453 | ||
| 454 | + | /* | |
| 455 | + | * Streaming SVE state is always preserved with an SVE payload. | |
| 456 | + | * Only accept streaming state which has an SVE payload. | |
| 457 | + | */ | |
| 458 | + | if (fpsimd_only) | |
| 459 | + | return -EINVAL; | |
| 460 | + | ||
| 451 | 461 | vl = task_get_sme_vl(current); | |
| 452 | 462 | } else { | |
| 453 | 463 | /* | |
| 454 | - | * A SME only system use SVE for streaming mode so can | |
| 455 | - | * have a SVE formatted context with a zero VL and no | |
| 456 | - | * payload data. | |
| 464 | + | * Non-streaming SVE state may be preserved without an SVE | |
| 465 | + | * payload, in which case all state is saved in the FPSIMD | |
| 466 | + | * context. | |
| 467 | + | * | |
| 468 | + | * On SME-only systems, non-streaming (FPSIMD-only) state is | |
| 469 | + | * always preserved without an SVE payload, and with VL==0. On | |
| 470 | + | * such systems, only accept non-streaming state without an SVE | |
| 471 | + | * payload. | |
| 457 | 472 | */ | |
| 458 | - | if (!system_supports_sve() && !system_supports_sme()) | |
| 473 | + | if (!system_supports_sve() && !fpsimd_only) | |
| 459 | 474 | return -EINVAL; | |
| 460 | 475 | ||
| 461 | 476 | vl = task_get_sve_vl(current); | |
| @@ -464,16 +479,7 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user) | |||
| 464 | 479 | if (user_vl != vl) | |
| 465 | 480 | return -EINVAL; | |
| 466 | 481 | ||
| 467 | - | /* | |
| 468 | - | * Non-streaming SVE state may be preserved without an SVE payload, in | |
| 469 | - | * which case the SVE context only has a header with VL==0, and all | |
| 470 | - | * state can be restored from the FPSIMD context. | |
| 471 | - | * | |
| 472 | - | * Streaming SVE state is always preserved with an SVE payload. For | |
| 473 | - | * consistency and robustness, reject restoring streaming SVE state | |
| 474 | - | * without an SVE payload. | |
| 475 | - | */ | |
| 476 | - | if (!sm && user->sve_size == sizeof(*user->sve)) | |
| 482 | + | if (fpsimd_only) | |
| 477 | 483 | return restore_fpsimd_context(user); | |
| 478 | 484 | ||
| 479 | 485 | vq = sve_vq_from_vl(vl); | |
modified arch/arm64/kernel/topology.c
| @@ -186,7 +186,6 @@ int arch_freq_get_on_cpu(int cpu) | |||
| 186 | 186 | struct amu_cntr_sample *amu_sample; | |
| 187 | 187 | unsigned int start_cpu = cpu; | |
| 188 | 188 | unsigned long last_update; | |
| 189 | - | unsigned int freq = 0; | |
| 190 | 189 | u64 scale; | |
| 191 | 190 | ||
| 192 | 191 | if (!amu_fie_cpu_supported(cpu) || !arch_scale_freq_ref(cpu)) | |
| @@ -245,9 +244,8 @@ int arch_freq_get_on_cpu(int cpu) | |||
| 245 | 244 | * (see amu_scale_freq_tick for details) | |
| 246 | 245 | */ | |
| 247 | 246 | scale = arch_scale_freq_capacity(cpu); | |
| 248 | - | freq = scale * arch_scale_freq_ref(cpu); | |
| 249 | - | freq >>= SCHED_CAPACITY_SHIFT; | |
| 250 | - | return freq; | |
| 247 | + | ||
| 248 | + | return (scale * arch_scale_freq_ref(cpu)) >> SCHED_CAPACITY_SHIFT; | |
| 251 | 249 | } | |
| 252 | 250 | ||
| 253 | 251 | static void amu_fie_setup(const struct cpumask *cpus) | |
| @@ -397,12 +395,13 @@ static void cpu_read_corecnt(void *val) | |||
| 397 | 395 | static void cpu_read_constcnt(void *val) | |
| 398 | 396 | { | |
| 399 | 397 | /* | |
| 400 | - | * Return 0 if the current CPU is affected by erratum 2457168. A value | |
| 401 | - | * of 0 is also returned if the current CPU does not support AMUs or if | |
| 402 | - | * the counter is disabled. A return value of 0 at counter read is | |
| 403 | - | * properly handled as an error case by the users of the counter. | |
| 398 | + | * Return 0 if the current CPU is affected by a HW erratum. | |
| 399 | + | * A value of 0 is also returned if the current CPU does not | |
| 400 | + | * support AMUs or if the counter is disabled. A return | |
| 401 | + | * value of 0 at counter read is properly handled as an error | |
| 402 | + | * case by the users of the counter. | |
| 404 | 403 | */ | |
| 405 | - | *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_2457168) ? | |
| 404 | + | *(u64 *)val = this_cpu_has_cap(ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT) ? | |
| 406 | 405 | 0UL : read_constcnt(); | |
| 407 | 406 | } | |
| 408 | 407 | ||
| @@ -463,8 +462,9 @@ static void amu_read_core_const_ctrs(void *val) | |||
| 463 | 462 | ||
| 464 | 463 | /* | |
| 465 | 464 | * cpu_read_constcnt() incurs slight latency due to the | |
| 466 | - | * ARM64_WORKAROUND_2457168 check. Read it first to minimize | |
| 467 | - | * the sampling skew between the const and core counters. | |
| 465 | + | * ARM64_WORKAROUND_BROKEN_AMU_CONSTCNT check. | |
| 466 | + | * Read it first to minimize the sampling skew between the const | |
| 467 | + | * and core counters. | |
| 468 | 468 | */ | |
| 469 | 469 | cpu_read_constcnt(&ctrs->constcnt); | |
| 470 | 470 | cpu_read_corecnt(&ctrs->corecnt); | |
modified arch/arm64/kernel/vdso/Makefile
| @@ -41,7 +41,7 @@ CC_FLAGS_REMOVE_VDSO := $(CC_FLAGS_FTRACE) -Os $(CC_FLAGS_SCS) \ | |||
| 41 | 41 | $(CC_FLAGS_LTO) $(CC_FLAGS_CFI) \ | |
| 42 | 42 | -Wmissing-prototypes -Wmissing-declarations | |
| 43 | 43 | ||
| 44 | - | CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables | |
| 44 | + | CC_FLAGS_ADD_VDSO := -O2 -mcmodel=tiny -fasynchronous-unwind-tables $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 45 | 45 | ||
| 46 | 46 | CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_REMOVE_VDSO) | |
| 47 | 47 | CFLAGS_REMOVE_vgetrandom.o = $(CC_FLAGS_REMOVE_VDSO) | |
modified arch/arm64/kvm/arm.c
| @@ -236,8 +236,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
| 236 | 236 | mutex_unlock(&kvm->lock); | |
| 237 | 237 | #endif | |
| 238 | 238 | ||
| 239 | - | kvm_init_nested(kvm); | |
| 240 | - | ||
| 241 | 239 | ret = kvm_share_hyp(kvm, kvm + 1); | |
| 242 | 240 | if (ret) | |
| 243 | 241 | return ret; | |
| @@ -252,6 +250,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
| 252 | 250 | if (ret) | |
| 253 | 251 | goto err_free_cpumask; | |
| 254 | 252 | ||
| 253 | + | ret = kvm_init_nested(kvm); | |
| 254 | + | if (ret) | |
| 255 | + | goto err_uninit_mmu; | |
| 256 | + | ||
| 255 | 257 | if (is_protected_kvm_enabled()) { | |
| 256 | 258 | /* | |
| 257 | 259 | * If any failures occur after this is successful, make sure to | |
| @@ -280,6 +282,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) | |||
| 280 | 282 | ||
| 281 | 283 | err_uninit_mmu: | |
| 282 | 284 | kvm_uninit_stage2_mmu(kvm); | |
| 285 | + | kvm_destroy_nested(kvm); | |
| 283 | 286 | err_free_cpumask: | |
| 284 | 287 | free_cpumask_var(kvm->arch.supported_cpus); | |
| 285 | 288 | err_unshare_kvm: | |
| @@ -337,6 +340,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) | |||
| 337 | 340 | ||
| 338 | 341 | kvm_unshare_hyp(kvm, kvm + 1); | |
| 339 | 342 | ||
| 343 | + | kvm_destroy_nested(kvm); | |
| 340 | 344 | kvm_arm_teardown_hypercalls(kvm); | |
| 341 | 345 | } | |
| 342 | 346 | ||
| @@ -1129,7 +1133,7 @@ static int kvm_vcpu_suspend(struct kvm_vcpu *vcpu) | |||
| 1129 | 1133 | static int check_vcpu_requests(struct kvm_vcpu *vcpu) | |
| 1130 | 1134 | { | |
| 1131 | 1135 | if (kvm_request_pending(vcpu)) { | |
| 1132 | - | if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 1136 | + | if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 1133 | 1137 | return -EIO; | |
| 1134 | 1138 | ||
| 1135 | 1139 | if (kvm_check_request(KVM_REQ_SLEEP, vcpu)) | |
modified arch/arm64/kvm/emulate-nested.c
| @@ -1445,7 +1445,7 @@ static const struct encoding_to_trap_config encoding_to_fgt[] __initconst = { | |||
| 1445 | 1445 | SR_FGT(OP_AT_S1E1A, HFGITR, ATS1E1A, 1), | |
| 1446 | 1446 | SR_FGT(OP_COSP_RCTX, HFGITR, COSPRCTX, 1), | |
| 1447 | 1447 | SR_FGT(OP_GCSPUSHX, HFGITR, nGCSEPP, 0), | |
| 1448 | - | SR_FGT(OP_GCSPOPX, HFGITR, nGCSEPP, 0), | |
| 1448 | + | SR_FGT(OP_GCSPOPCX, HFGITR, nGCSEPP, 0), | |
| 1449 | 1449 | SR_FGT(OP_GCSPUSHM, HFGITR, nGCSPUSHM_EL1, 0), | |
| 1450 | 1450 | SR_FGT(OP_BRB_IALL, HFGITR, nBRBIALL, 0), | |
| 1451 | 1451 | SR_FGT(OP_BRB_INJ, HFGITR, nBRBINJ, 0), | |
| @@ -2386,9 +2386,6 @@ int __init populate_nv_trap_config(void) | |||
| 2386 | 2386 | print_nv_trap_error(fgt, "FGT bit is reserved", ret); | |
| 2387 | 2387 | } | |
| 2388 | 2388 | ||
| 2389 | - | if (!cpus_have_final_cap(ARM64_HAS_FGT)) | |
| 2390 | - | continue; | |
| 2391 | - | ||
| 2392 | 2389 | prev = xa_store(&sr_forward_xa, enc, | |
| 2393 | 2390 | xa_mk_value(tc.val), GFP_KERNEL); | |
| 2394 | 2391 | ||
modified arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
| @@ -52,8 +52,10 @@ int __pkvm_host_test_clear_young_guest(u64 gfn, u64 nr_pages, bool mkold, struct | |||
| 52 | 52 | int __pkvm_host_mkyoung_guest(u64 gfn, struct pkvm_hyp_vcpu *vcpu); | |
| 53 | 53 | ||
| 54 | 54 | bool addr_is_memory(phys_addr_t phys); | |
| 55 | + | bool addr_is_hyp_text(phys_addr_t phys); | |
| 55 | 56 | int host_stage2_idmap_locked(phys_addr_t addr, u64 size, enum kvm_pgtable_prot prot); | |
| 56 | 57 | int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id); | |
| 58 | + | bool host_stage2_pte_is_hyp_owned(kvm_pte_t pte); | |
| 57 | 59 | int kvm_host_prepare_stage2(void *pgt_pool_base); | |
| 58 | 60 | int kvm_guest_prepare_stage2(struct pkvm_hyp_vm *vm, void *pgd); | |
| 59 | 61 | void kvm_guest_destroy_stage2(struct pkvm_hyp_vm *vm); | |
modified arch/arm64/kvm/hyp/include/nvhe/mm.h
| @@ -29,6 +29,7 @@ int __pkvm_create_private_mapping(phys_addr_t phys, size_t size, | |||
| 29 | 29 | enum kvm_pgtable_prot prot, | |
| 30 | 30 | unsigned long *haddr); | |
| 31 | 31 | int pkvm_create_stack(phys_addr_t phys, unsigned long *haddr); | |
| 32 | + | int pkvm_check_host_ownership(void); | |
| 32 | 33 | int pkvm_alloc_private_va_range(size_t size, unsigned long *haddr); | |
| 33 | 34 | ||
| 34 | 35 | #endif /* __KVM_HYP_MM_H */ | |
modified arch/arm64/kvm/hyp/include/nvhe/pkvm.h
| @@ -12,6 +12,15 @@ | |||
| 12 | 12 | #include <nvhe/gfp.h> | |
| 13 | 13 | #include <nvhe/spinlock.h> | |
| 14 | 14 | ||
| 15 | + | /* | |
| 16 | + | * HCR_EL2 bits EL2 takes from the host on each entry, per VM type. The rest | |
| 17 | + | * are EL2's own and nothing the host sets there reaches the guest. | |
| 18 | + | */ | |
| 19 | + | #define PKVM_HCR_EL2_HOST_PVM (HCR_EL2_TWI | HCR_EL2_TWE | HCR_EL2_VSE) | |
| 20 | + | #define PKVM_HCR_EL2_HOST_NPVM (PKVM_HCR_EL2_HOST_PVM | HCR_EL2_VI | HCR_EL2_VF | \ | |
| 21 | + | HCR_EL2_TVM | HCR_EL2_TID2 | HCR_EL2_TID4 | \ | |
| 22 | + | HCR_EL2_TID5 | HCR_EL2_TTLBOS) | |
| 23 | + | ||
| 15 | 24 | /* | |
| 16 | 25 | * Holds the relevant data for maintaining the vcpu state completely at hyp. | |
| 17 | 26 | */ | |
modified arch/arm64/kvm/hyp/nvhe/hyp-main.c
| @@ -216,6 +216,7 @@ static void sync_debug_state(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 216 | 216 | static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |
| 217 | 217 | { | |
| 218 | 218 | struct kvm_vcpu *host_vcpu = hyp_vcpu->host_vcpu; | |
| 219 | + | u64 host_hcr_mask = PKVM_HCR_EL2_HOST_PVM; | |
| 219 | 220 | ||
| 220 | 221 | fpsimd_sve_flush(); | |
| 221 | 222 | flush_debug_state(hyp_vcpu); | |
| @@ -228,6 +229,7 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 228 | 229 | if (!pkvm_hyp_vcpu_is_protected(hyp_vcpu)) { | |
| 229 | 230 | if (vcpu_get_flag(host_vcpu, PKVM_HOST_STATE_DIRTY)) | |
| 230 | 231 | flush_hyp_vcpu_state(hyp_vcpu); | |
| 232 | + | host_hcr_mask = PKVM_HCR_EL2_HOST_NPVM; | |
| 231 | 233 | } else { | |
| 232 | 234 | hyp_vcpu->vcpu.arch.ctxt = host_vcpu->arch.ctxt; | |
| 233 | 235 | } | |
| @@ -241,9 +243,8 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 241 | 243 | * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE | |
| 242 | 244 | * for the vSError to be delivered. sync_hyp_vcpu() reflects it back. | |
| 243 | 245 | */ | |
| 244 | - | hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI | HCR_TWE | HCR_VSE); | |
| 245 | - | hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) & | |
| 246 | - | (HCR_TWI | HCR_TWE | HCR_VSE); | |
| 246 | + | hyp_vcpu->vcpu.arch.hcr_el2 &= ~host_hcr_mask; | |
| 247 | + | hyp_vcpu->vcpu.arch.hcr_el2 |= READ_ONCE(host_vcpu->arch.hcr_el2) & host_hcr_mask; | |
| 247 | 248 | ||
| 248 | 249 | hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags; | |
| 249 | 250 | ||
modified arch/arm64/kvm/hyp/nvhe/mem_protect.c
| @@ -450,6 +450,14 @@ bool addr_is_memory(phys_addr_t phys) | |||
| 450 | 450 | return !!find_mem_range(phys, &range); | |
| 451 | 451 | } | |
| 452 | 452 | ||
| 453 | + | bool addr_is_hyp_text(phys_addr_t phys) | |
| 454 | + | { | |
| 455 | + | phys_addr_t start = ALIGN_DOWN(__hyp_pa(__hyp_text_start), PAGE_SIZE); | |
| 456 | + | phys_addr_t end = PAGE_ALIGN(__hyp_pa(__hyp_text_end)); | |
| 457 | + | ||
| 458 | + | return phys >= start && phys < end; | |
| 459 | + | } | |
| 460 | + | ||
| 453 | 461 | static bool is_in_mem_range(u64 addr, struct kvm_mem_range *range) | |
| 454 | 462 | { | |
| 455 | 463 | return range->start <= addr && addr < range->end; | |
| @@ -633,6 +641,18 @@ int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id) | |||
| 633 | 641 | return ret; | |
| 634 | 642 | } | |
| 635 | 643 | ||
| 644 | + | bool host_stage2_pte_is_hyp_owned(kvm_pte_t pte) | |
| 645 | + | { | |
| 646 | + | if (kvm_pte_valid(pte)) | |
| 647 | + | return false; | |
| 648 | + | ||
| 649 | + | if (FIELD_GET(KVM_INVALID_PTE_TYPE_MASK, pte) != | |
| 650 | + | KVM_HOST_INVALID_PTE_TYPE_DONATION) | |
| 651 | + | return false; | |
| 652 | + | ||
| 653 | + | return FIELD_GET(KVM_HOST_DONATION_PTE_OWNER_MASK, pte) == PKVM_ID_HYP; | |
| 654 | + | } | |
| 655 | + | ||
| 636 | 656 | #define KVM_HOST_PTE_OWNER_GUEST_HANDLE_MASK GENMASK(15, 0) | |
| 637 | 657 | /* We need 40 bits for the GFN to cover a 52-bit IPA with 4k pages and LPA2 */ | |
| 638 | 658 | #define KVM_HOST_PTE_OWNER_GUEST_GFN_MASK GENMASK(55, 16) | |
modified arch/arm64/kvm/hyp/nvhe/mm.c
| @@ -25,6 +25,7 @@ struct memblock_region hyp_memory[HYP_MEMBLOCK_REGIONS]; | |||
| 25 | 25 | unsigned int hyp_memblock_nr; | |
| 26 | 26 | ||
| 27 | 27 | static u64 __io_map_base; | |
| 28 | + | static u64 __io_map_next; | |
| 28 | 29 | ||
| 29 | 30 | struct hyp_fixmap_slot { | |
| 30 | 31 | u64 addr; | |
| @@ -50,7 +51,7 @@ static int __pkvm_alloc_private_va_range(unsigned long start, size_t size) | |||
| 50 | 51 | ||
| 51 | 52 | hyp_assert_lock_held(&pkvm_pgd_lock); | |
| 52 | 53 | ||
| 53 | - | if (!start || start < __io_map_base) | |
| 54 | + | if (!start || start < __io_map_next) | |
| 54 | 55 | return -EINVAL; | |
| 55 | 56 | ||
| 56 | 57 | /* The allocated size is always a multiple of PAGE_SIZE */ | |
| @@ -60,7 +61,7 @@ static int __pkvm_alloc_private_va_range(unsigned long start, size_t size) | |||
| 60 | 61 | if (cur > __hyp_vmemmap) | |
| 61 | 62 | return -ENOMEM; | |
| 62 | 63 | ||
| 63 | - | __io_map_base = cur; | |
| 64 | + | __io_map_next = cur; | |
| 64 | 65 | ||
| 65 | 66 | return 0; | |
| 66 | 67 | } | |
| @@ -70,7 +71,7 @@ static int __pkvm_alloc_private_va_range(unsigned long start, size_t size) | |||
| 70 | 71 | * @size: The size of the VA range to reserve. | |
| 71 | 72 | * @haddr: The hypervisor virtual start address of the allocation. | |
| 72 | 73 | * | |
| 73 | - | * The private virtual address (VA) range is allocated above __io_map_base | |
| 74 | + | * The private virtual address (VA) range is allocated above __io_map_next | |
| 74 | 75 | * and aligned based on the order of @size. | |
| 75 | 76 | * | |
| 76 | 77 | * Return: 0 on success or negative error code on failure. | |
| @@ -81,7 +82,7 @@ int pkvm_alloc_private_va_range(size_t size, unsigned long *haddr) | |||
| 81 | 82 | int ret; | |
| 82 | 83 | ||
| 83 | 84 | hyp_spin_lock(&pkvm_pgd_lock); | |
| 84 | - | addr = __io_map_base; | |
| 85 | + | addr = __io_map_next; | |
| 85 | 86 | ret = __pkvm_alloc_private_va_range(addr, size); | |
| 86 | 87 | hyp_spin_unlock(&pkvm_pgd_lock); | |
| 87 | 88 | ||
| @@ -341,7 +342,7 @@ static int create_fixblock(void) | |||
| 341 | 342 | return -EINVAL; | |
| 342 | 343 | ||
| 343 | 344 | hyp_spin_lock(&pkvm_pgd_lock); | |
| 344 | - | addr = ALIGN(__io_map_base, PMD_SIZE); | |
| 345 | + | addr = ALIGN(__io_map_next, PMD_SIZE); | |
| 345 | 346 | ret = __pkvm_alloc_private_va_range(addr, PMD_SIZE); | |
| 346 | 347 | if (ret) | |
| 347 | 348 | goto unlock; | |
| @@ -426,6 +427,7 @@ int hyp_create_idmap(u32 hyp_va_bits) | |||
| 426 | 427 | */ | |
| 427 | 428 | __io_map_base = start & BIT(hyp_va_bits - 2); | |
| 428 | 429 | __io_map_base ^= BIT(hyp_va_bits - 2); | |
| 430 | + | __io_map_next = __io_map_base; | |
| 429 | 431 | __hyp_vmemmap = __io_map_base | BIT(hyp_va_bits - 3); | |
| 430 | 432 | ||
| 431 | 433 | return __pkvm_create_mappings(start, end - start, start, PAGE_HYP_EXEC); | |
| @@ -433,19 +435,19 @@ int hyp_create_idmap(u32 hyp_va_bits) | |||
| 433 | 435 | ||
| 434 | 436 | int pkvm_create_stack(phys_addr_t phys, unsigned long *haddr) | |
| 435 | 437 | { | |
| 436 | - | unsigned long addr, prev_base; | |
| 438 | + | unsigned long addr, prev_next; | |
| 437 | 439 | size_t size; | |
| 438 | 440 | int ret; | |
| 439 | 441 | ||
| 440 | 442 | hyp_spin_lock(&pkvm_pgd_lock); | |
| 441 | 443 | ||
| 442 | - | prev_base = __io_map_base; | |
| 444 | + | prev_next = __io_map_next; | |
| 443 | 445 | /* | |
| 444 | 446 | * Efficient stack verification using the NVHE_STACK_SHIFT bit implies | |
| 445 | 447 | * an alignment of our allocation on the order of the size. | |
| 446 | 448 | */ | |
| 447 | 449 | size = NVHE_STACK_SIZE * 2; | |
| 448 | - | addr = ALIGN(__io_map_base, size); | |
| 450 | + | addr = ALIGN(__io_map_next, size); | |
| 449 | 451 | ||
| 450 | 452 | ret = __pkvm_alloc_private_va_range(addr, size); | |
| 451 | 453 | if (!ret) { | |
| @@ -461,7 +463,7 @@ int pkvm_create_stack(phys_addr_t phys, unsigned long *haddr) | |||
| 461 | 463 | ret = kvm_pgtable_hyp_map(&pkvm_pgtable, addr + NVHE_STACK_SIZE, | |
| 462 | 464 | NVHE_STACK_SIZE, phys, PAGE_HYP); | |
| 463 | 465 | if (ret) | |
| 464 | - | __io_map_base = prev_base; | |
| 466 | + | __io_map_next = prev_next; | |
| 465 | 467 | } | |
| 466 | 468 | hyp_spin_unlock(&pkvm_pgd_lock); | |
| 467 | 469 | ||
| @@ -470,6 +472,65 @@ int pkvm_create_stack(phys_addr_t phys, unsigned long *haddr) | |||
| 470 | 472 | return ret; | |
| 471 | 473 | } | |
| 472 | 474 | ||
| 475 | + | static int check_page_ownership(phys_addr_t phys) | |
| 476 | + | { | |
| 477 | + | kvm_pte_t pte; | |
| 478 | + | bool host_ok; | |
| 479 | + | int ret; | |
| 480 | + | ||
| 481 | + | if (addr_is_memory(phys)) { | |
| 482 | + | struct hyp_page *page = hyp_phys_to_page(phys); | |
| 483 | + | ||
| 484 | + | if (get_hyp_state(page) != PKVM_PAGE_OWNED || | |
| 485 | + | get_host_state(page) != PKVM_NOPAGE) | |
| 486 | + | return -EPERM; | |
| 487 | + | } | |
| 488 | + | ||
| 489 | + | ret = kvm_pgtable_get_leaf(&host_mmu.pgt, phys, &pte, NULL); | |
| 490 | + | if (ret) | |
| 491 | + | return ret; | |
| 492 | + | ||
| 493 | + | /* Hyp text may stay host-readable, see fix_host_ownership_walker(). */ | |
| 494 | + | if (kvm_pte_valid(pte) && addr_is_hyp_text(phys)) | |
| 495 | + | host_ok = !(kvm_pgtable_stage2_pte_prot(pte) & KVM_PGTABLE_PROT_W); | |
| 496 | + | else | |
| 497 | + | host_ok = host_stage2_pte_is_hyp_owned(pte); | |
| 498 | + | ||
| 499 | + | return host_ok ? 0 : -EPERM; | |
| 500 | + | } | |
| 501 | + | ||
| 502 | + | static int check_host_ownership_walker(const struct kvm_pgtable_visit_ctx *ctx, | |
| 503 | + | enum kvm_pgtable_walk_flags visit) | |
| 504 | + | { | |
| 505 | + | phys_addr_t phys, end; | |
| 506 | + | int ret; | |
| 507 | + | ||
| 508 | + | if (!kvm_pte_valid(ctx->old)) | |
| 509 | + | return 0; | |
| 510 | + | ||
| 511 | + | phys = kvm_pte_to_phys(ctx->old); | |
| 512 | + | end = phys + kvm_granule_size(ctx->level); | |
| 513 | + | for (; phys < end; phys += PAGE_SIZE) { | |
| 514 | + | ret = check_page_ownership(phys); | |
| 515 | + | if (ret) | |
| 516 | + | return ret; | |
| 517 | + | } | |
| 518 | + | ||
| 519 | + | return 0; | |
| 520 | + | } | |
| 521 | + | ||
| 522 | + | int pkvm_check_host_ownership(void) | |
| 523 | + | { | |
| 524 | + | struct kvm_pgtable_walker walker = { | |
| 525 | + | .cb = check_host_ownership_walker, | |
| 526 | + | .flags = KVM_PGTABLE_WALK_LEAF, | |
| 527 | + | }; | |
| 528 | + | ||
| 529 | + | /* The private range and the vmemmap share one quarter of the VA space. */ | |
| 530 | + | return kvm_pgtable_walk(&pkvm_pgtable, __io_map_base, | |
| 531 | + | BIT(pkvm_pgtable.ia_bits - 2), &walker); | |
| 532 | + | } | |
| 533 | + | ||
| 473 | 534 | static void *admit_host_page(void *arg) | |
| 474 | 535 | { | |
| 475 | 536 | struct kvm_hyp_memcache *host_mc = arg; | |
modified arch/arm64/kvm/hyp/nvhe/pkvm.c
| @@ -30,6 +30,7 @@ unsigned int kvm_host_sve_max_vl; | |||
| 30 | 30 | */ | |
| 31 | 31 | static DEFINE_PER_CPU(struct pkvm_hyp_vcpu *, loaded_hyp_vcpu); | |
| 32 | 32 | ||
| 33 | + | /* The PKVM_HCR_EL2_HOST_{PVM,NPVM} bits of this value come from the host on each entry. */ | |
| 33 | 34 | static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu) | |
| 34 | 35 | { | |
| 35 | 36 | vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS; | |
| @@ -47,18 +48,17 @@ static void pkvm_vcpu_reset_hcr(struct kvm_vcpu *vcpu) | |||
| 47 | 48 | if (cpus_have_final_cap(ARM64_HAS_STAGE2_FWB)) | |
| 48 | 49 | vcpu->arch.hcr_el2 |= HCR_FWB; | |
| 49 | 50 | ||
| 50 | - | if (cpus_have_final_cap(ARM64_HAS_EVT) && | |
| 51 | - | !cpus_have_final_cap(ARM64_MISMATCHED_CACHE_TYPE) && | |
| 52 | - | kvm_read_vm_id_reg(vcpu->kvm, SYS_CTR_EL0) == read_cpuid(CTR_EL0)) | |
| 53 | - | vcpu->arch.hcr_el2 |= HCR_TID4; | |
| 54 | - | else | |
| 55 | - | vcpu->arch.hcr_el2 |= HCR_TID2; | |
| 51 | + | /* | |
| 52 | + | * Without AArch32 EL1, leave RW set and let the entry fail with an | |
| 53 | + | * illegal exception return: the *32_EL2 registers EL2 would otherwise | |
| 54 | + | * switch are UNDEFINED there. | |
| 55 | + | */ | |
| 56 | + | if (vcpu_has_feature(vcpu, KVM_ARM_VCPU_EL1_32BIT) && | |
| 57 | + | cpus_have_final_cap(ARM64_HAS_32BIT_EL1)) | |
| 58 | + | vcpu->arch.hcr_el2 &= ~HCR_EL2_RW; | |
| 56 | 59 | ||
| 57 | 60 | if (vcpu_has_ptrauth(vcpu)) | |
| 58 | 61 | vcpu->arch.hcr_el2 |= (HCR_API | HCR_APK); | |
| 59 | - | ||
| 60 | - | if (kvm_has_mte(vcpu->kvm)) | |
| 61 | - | vcpu->arch.hcr_el2 |= HCR_ATA; | |
| 62 | 62 | } | |
| 63 | 63 | ||
| 64 | 64 | static void pvm_init_traps_hcr(struct kvm_vcpu *vcpu) | |
| @@ -76,6 +76,13 @@ static void pvm_init_traps_hcr(struct kvm_vcpu *vcpu) | |||
| 76 | 76 | */ | |
| 77 | 77 | val |= HCR_TACR | HCR_TIDCP | HCR_TID3 | HCR_TID1; | |
| 78 | 78 | ||
| 79 | + | if (cpus_have_final_cap(ARM64_HAS_EVT) && | |
| 80 | + | !cpus_have_final_cap(ARM64_MISMATCHED_CACHE_TYPE) && | |
| 81 | + | kvm_read_vm_id_reg(kvm, SYS_CTR_EL0) == read_cpuid(CTR_EL0)) | |
| 82 | + | val |= HCR_EL2_TID4; | |
| 83 | + | else | |
| 84 | + | val |= HCR_EL2_TID2; | |
| 85 | + | ||
| 79 | 86 | if (!kvm_has_feat(kvm, ID_AA64PFR0_EL1, RAS, IMP)) { | |
| 80 | 87 | val |= HCR_TERR | HCR_TEA; | |
| 81 | 88 | val &= ~(HCR_FIEN); | |
| @@ -360,7 +367,7 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc | |||
| 360 | 367 | if (test_bit(KVM_ARCH_FLAG_WRITABLE_IMP_ID_REGS, &host_arch_flags)) | |
| 361 | 368 | hyp_vm->kvm.arch.midr_el1 = host_kvm->arch.midr_el1; | |
| 362 | 369 | ||
| 363 | - | return; | |
| 370 | + | goto out; | |
| 364 | 371 | } | |
| 365 | 372 | ||
| 366 | 373 | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_MTE)) | |
| @@ -379,13 +386,14 @@ static void pkvm_init_features_from_host(struct pkvm_hyp_vm *hyp_vm, const struc | |||
| 379 | 386 | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_PTRAUTH_GENERIC)) | |
| 380 | 387 | set_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, allowed_features); | |
| 381 | 388 | ||
| 382 | - | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_SVE)) { | |
| 389 | + | if (kvm_pkvm_ext_allowed(kvm, KVM_CAP_ARM_SVE)) | |
| 383 | 390 | set_bit(KVM_ARM_VCPU_SVE, allowed_features); | |
| 384 | - | kvm->arch.flags |= host_arch_flags & BIT(KVM_ARCH_FLAG_GUEST_HAS_SVE); | |
| 385 | - | } | |
| 386 | 391 | ||
| 387 | 392 | bitmap_and(kvm->arch.vcpu_features, host_kvm->arch.vcpu_features, | |
| 388 | 393 | allowed_features, KVM_VCPU_MAX_FEATURES); | |
| 394 | + | out: | |
| 395 | + | __assign_bit(KVM_ARCH_FLAG_GUEST_HAS_SVE, &kvm->arch.flags, | |
| 396 | + | kvm_vcpu_has_feature(kvm, KVM_ARM_VCPU_SVE)); | |
| 389 | 397 | } | |
| 390 | 398 | ||
| 391 | 399 | static void unpin_host_vcpu(struct kvm_vcpu *host_vcpu) | |
| @@ -398,10 +406,10 @@ static void unpin_host_sve_state(struct pkvm_hyp_vcpu *hyp_vcpu) | |||
| 398 | 406 | { | |
| 399 | 407 | void *sve_state; | |
| 400 | 408 | ||
| 401 | - | if (!vcpu_has_feature(&hyp_vcpu->vcpu, KVM_ARM_VCPU_SVE)) | |
| 409 | + | sve_state = hyp_vcpu->vcpu.arch.sve_state; | |
| 410 | + | if (!sve_state) | |
| 402 | 411 | return; | |
| 403 | 412 | ||
| 404 | - | sve_state = hyp_vcpu->vcpu.arch.sve_state; | |
| 405 | 413 | hyp_unpin_shared_mem(sve_state, | |
| 406 | 414 | sve_state + vcpu_sve_state_size(&hyp_vcpu->vcpu)); | |
| 407 | 415 | } | |
| @@ -450,7 +458,7 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h | |||
| 450 | 458 | unsigned int sve_max_vl; | |
| 451 | 459 | size_t sve_state_size; | |
| 452 | 460 | void *sve_state; | |
| 453 | - | int ret = 0; | |
| 461 | + | int ret; | |
| 454 | 462 | ||
| 455 | 463 | if (!vcpu_has_feature(vcpu, KVM_ARM_VCPU_SVE)) { | |
| 456 | 464 | vcpu_clear_flag(vcpu, VCPU_SVE_FINALIZED); | |
| @@ -459,25 +467,21 @@ static int pkvm_vcpu_init_sve(struct pkvm_hyp_vcpu *hyp_vcpu, struct kvm_vcpu *h | |||
| 459 | 467 | ||
| 460 | 468 | /* Limit guest vector length to the maximum supported by the host. */ | |
| 461 | 469 | sve_max_vl = min(READ_ONCE(host_vcpu->arch.sve_max_vl), kvm_host_sve_max_vl); | |
| 462 | - | sve_state_size = sve_state_size_from_vl(sve_max_vl); | |
| 463 | 470 | sve_state = kern_hyp_va(READ_ONCE(host_vcpu->arch.sve_state)); | |
| 464 | 471 | ||
| 465 | - | if (!sve_state || !sve_state_size) { | |
| 466 | - | ret = -EINVAL; | |
| 467 | - | goto err; | |
| 468 | - | } | |
| 472 | + | if (!sve_vl_valid(sve_max_vl) || !sve_state) | |
| 473 | + | return -EINVAL; | |
| 474 | + | ||
| 475 | + | sve_state_size = sve_state_size_from_vl(sve_max_vl); | |
| 469 | 476 | ||
| 470 | 477 | ret = hyp_pin_shared_mem(sve_state, sve_state + sve_state_size); | |
| 471 | 478 | if (ret) | |
| 472 | - | goto err; | |
| 479 | + | return ret; | |
| 473 | 480 | ||
| 474 | 481 | vcpu->arch.sve_state = sve_state; | |
| 475 | 482 | vcpu->arch.sve_max_vl = sve_max_vl; | |
| 476 | 483 | ||
| 477 | 484 | return 0; | |
| 478 | - | err: | |
| 479 | - | clear_bit(KVM_ARM_VCPU_SVE, vcpu->kvm->arch.vcpu_features); | |
| 480 | - | return ret; | |
| 481 | 485 | } | |
| 482 | 486 | ||
| 483 | 487 | static int vm_copy_id_regs(struct pkvm_hyp_vcpu *hyp_vcpu) | |
modified arch/arm64/kvm/hyp/nvhe/setup.c
| @@ -217,7 +217,7 @@ static int fix_host_ownership_walker(const struct kvm_pgtable_visit_ctx *ctx, | |||
| 217 | 217 | case PKVM_PAGE_OWNED: | |
| 218 | 218 | set_hyp_state(page, PKVM_PAGE_OWNED); | |
| 219 | 219 | /* hyp text is RO in the host stage-2 to be inspected on panic. */ | |
| 220 | - | if (prot == PAGE_HYP_EXEC) { | |
| 220 | + | if (addr_is_hyp_text(phys)) { | |
| 221 | 221 | set_host_state(page, PKVM_NOPAGE); | |
| 222 | 222 | return host_stage2_idmap_locked(phys, PAGE_SIZE, KVM_PGTABLE_PROT_R); | |
| 223 | 223 | } else { | |
| @@ -269,6 +269,16 @@ static int fix_host_ownership(void) | |||
| 269 | 269 | return ret; | |
| 270 | 270 | } | |
| 271 | 271 | ||
| 272 | + | /* The stacks sit in the private VA range, not the linear map. */ | |
| 273 | + | for (i = 0; i < hyp_nr_cpus; i++) { | |
| 274 | + | struct kvm_nvhe_init_params *params = per_cpu_ptr(&kvm_init_params, i); | |
| 275 | + | u64 start = params->stack_hyp_va - NVHE_STACK_SIZE; | |
| 276 | + | ||
| 277 | + | ret = kvm_pgtable_walk(&pkvm_pgtable, start, NVHE_STACK_SIZE, &walker); | |
| 278 | + | if (ret) | |
| 279 | + | return ret; | |
| 280 | + | } | |
| 281 | + | ||
| 272 | 282 | return 0; | |
| 273 | 283 | } | |
| 274 | 284 | ||
| @@ -324,6 +334,10 @@ void __noreturn __pkvm_init_finalise(void) | |||
| 324 | 334 | if (ret) | |
| 325 | 335 | goto out; | |
| 326 | 336 | ||
| 337 | + | ret = pkvm_check_host_ownership(); | |
| 338 | + | if (ret) | |
| 339 | + | goto out; | |
| 340 | + | ||
| 327 | 341 | ret = hyp_ffa_init(ffa_proxy_pages); | |
| 328 | 342 | if (ret) | |
| 329 | 343 | goto out; | |
modified arch/arm64/kvm/hypercalls.c
| @@ -185,7 +185,8 @@ static int kvm_smccc_set_filter(struct kvm *kvm, struct kvm_smccc_filter __user | |||
| 185 | 185 | start = filter.base; | |
| 186 | 186 | end = start + filter.nr_functions - 1; | |
| 187 | 187 | ||
| 188 | - | if (end < start || filter.action >= NR_SMCCC_FILTER_ACTIONS) | |
| 188 | + | if (!filter.nr_functions || end < start || | |
| 189 | + | filter.action >= NR_SMCCC_FILTER_ACTIONS) | |
| 189 | 190 | return -EINVAL; | |
| 190 | 191 | ||
| 191 | 192 | mutex_lock(&kvm->arch.config_lock); | |
modified arch/arm64/kvm/mmu.c
| @@ -59,27 +59,36 @@ static phys_addr_t stage2_range_addr_end(phys_addr_t addr, phys_addr_t end) | |||
| 59 | 59 | * long will also starve other vCPUs. We have to also make sure that the page | |
| 60 | 60 | * tables are not freed while we released the lock. | |
| 61 | 61 | */ | |
| 62 | - | static int stage2_apply_range(struct kvm_s2_mmu *mmu, phys_addr_t addr, | |
| 62 | + | static int stage2_apply_range(struct kvm_s2_mmu *mmu, phys_addr_t start, | |
| 63 | 63 | phys_addr_t end, | |
| 64 | 64 | int (*fn)(struct kvm_pgtable *, u64, u64), | |
| 65 | 65 | bool resched) | |
| 66 | 66 | { | |
| 67 | 67 | struct kvm *kvm = kvm_s2_mmu_to_kvm(mmu); | |
| 68 | + | bool lock_dropped = false; | |
| 69 | + | phys_addr_t addr = start; | |
| 68 | 70 | int ret; | |
| 69 | 71 | u64 next; | |
| 70 | 72 | ||
| 71 | 73 | do { | |
| 72 | 74 | struct kvm_pgtable *pgt = mmu->pgt; | |
| 75 | + | /* | |
| 76 | + | * We may be raced on PGT teardown when we release the | |
| 77 | + | * kvm->mmu_lock. That's fine as the PGT is legitimately no | |
| 78 | + | * longer present. | |
| 79 | + | */ | |
| 73 | 80 | if (!pgt) | |
| 74 | - | return -EINVAL; | |
| 81 | + | return lock_dropped ? 0 : -EINVAL; | |
| 75 | 82 | ||
| 76 | 83 | next = stage2_range_addr_end(addr, end); | |
| 77 | 84 | ret = fn(pgt, addr, next - addr); | |
| 78 | 85 | if (ret) | |
| 79 | 86 | break; | |
| 80 | 87 | ||
| 81 | - | if (resched && next != end) | |
| 88 | + | if (resched && next != end) { | |
| 82 | 89 | cond_resched_rwlock_write(&kvm->mmu_lock); | |
| 90 | + | lock_dropped = true; | |
| 91 | + | } | |
| 83 | 92 | } while (addr = next, addr != end); | |
| 84 | 93 | ||
| 85 | 94 | return ret; | |
| @@ -1459,32 +1468,11 @@ transparent_hugepage_adjust(struct kvm *kvm, struct kvm_memory_slot *memslot, | |||
| 1459 | 1468 | return PAGE_SIZE; | |
| 1460 | 1469 | } | |
| 1461 | 1470 | ||
| 1462 | - | static int get_vma_page_shift(struct vm_area_struct *vma, unsigned long hva) | |
| 1471 | + | static int get_vma_page_shift(struct vm_area_struct *vma) | |
| 1463 | 1472 | { | |
| 1464 | - | unsigned long pa; | |
| 1465 | - | ||
| 1466 | - | if (is_vm_hugetlb_page(vma) && !(vma->vm_flags & VM_PFNMAP)) | |
| 1473 | + | if (is_vm_hugetlb_page(vma)) | |
| 1467 | 1474 | return huge_page_shift(hstate_vma(vma)); | |
| 1468 | 1475 | ||
| 1469 | - | if (!(vma->vm_flags & VM_PFNMAP)) | |
| 1470 | - | return PAGE_SHIFT; | |
| 1471 | - | ||
| 1472 | - | VM_BUG_ON(is_vm_hugetlb_page(vma)); | |
| 1473 | - | ||
| 1474 | - | pa = (vma->vm_pgoff << PAGE_SHIFT) + (hva - vma->vm_start); | |
| 1475 | - | ||
| 1476 | - | #ifndef __PAGETABLE_PMD_FOLDED | |
| 1477 | - | if ((hva & (PUD_SIZE - 1)) == (pa & (PUD_SIZE - 1)) && | |
| 1478 | - | ALIGN_DOWN(hva, PUD_SIZE) >= vma->vm_start && | |
| 1479 | - | ALIGN(hva, PUD_SIZE) <= vma->vm_end) | |
| 1480 | - | return PUD_SHIFT; | |
| 1481 | - | #endif | |
| 1482 | - | ||
| 1483 | - | if ((hva & (PMD_SIZE - 1)) == (pa & (PMD_SIZE - 1)) && | |
| 1484 | - | ALIGN_DOWN(hva, PMD_SIZE) >= vma->vm_start && | |
| 1485 | - | ALIGN(hva, PMD_SIZE) <= vma->vm_end) | |
| 1486 | - | return PMD_SHIFT; | |
| 1487 | - | ||
| 1488 | 1476 | return PAGE_SHIFT; | |
| 1489 | 1477 | } | |
| 1490 | 1478 | ||
| @@ -1785,7 +1773,7 @@ static short kvm_s2_resolve_vma_size(const struct kvm_s2_fault_desc *s2fd, | |||
| 1785 | 1773 | vma_shift = PAGE_SHIFT; | |
| 1786 | 1774 | } else { | |
| 1787 | 1775 | s2vi->max_map_size = PUD_SIZE; | |
| 1788 | - | vma_shift = get_vma_page_shift(vma, s2fd->hva); | |
| 1776 | + | vma_shift = get_vma_page_shift(vma); | |
| 1789 | 1777 | } | |
| 1790 | 1778 | ||
| 1791 | 1779 | switch (vma_shift) { | |
| @@ -1943,16 +1931,6 @@ static int kvm_s2_fault_pin_pfn(const struct kvm_s2_fault_desc *s2fd, | |||
| 1943 | 1931 | return -EFAULT; | |
| 1944 | 1932 | } | |
| 1945 | 1933 | } else { | |
| 1946 | - | /* | |
| 1947 | - | * If the page was identified as device early by looking at | |
| 1948 | - | * the VMA flags, vma_pagesize is already representing the | |
| 1949 | - | * largest quantity we can map. If instead it was mapped | |
| 1950 | - | * via __kvm_faultin_pfn(), vma_pagesize is set to PAGE_SIZE | |
| 1951 | - | * and must not be upgraded. | |
| 1952 | - | * | |
| 1953 | - | * In both cases, we don't let transparent_hugepage_adjust() | |
| 1954 | - | * change things at the last minute. | |
| 1955 | - | */ | |
| 1956 | 1934 | s2vi->map_non_cacheable = true; | |
| 1957 | 1935 | } | |
| 1958 | 1936 | ||
| @@ -2042,10 +2020,10 @@ static int kvm_s2_fault_map(const struct kvm_s2_fault_desc *s2fd, | |||
| 2042 | 2020 | ||
| 2043 | 2021 | /* | |
| 2044 | 2022 | * If we are not forced to use page mapping, check if we are | |
| 2045 | - | * backed by a THP and thus use block mapping if possible. | |
| 2023 | + | * backed by a huge stage-1 mapping and thus use block mapping if | |
| 2024 | + | * possible. | |
| 2046 | 2025 | */ | |
| 2047 | - | if (mapping_size == PAGE_SIZE && | |
| 2048 | - | !(s2vi->max_map_size == PAGE_SIZE || s2vi->map_non_cacheable)) { | |
| 2026 | + | if (mapping_size == PAGE_SIZE && s2vi->max_map_size != PAGE_SIZE) { | |
| 2049 | 2027 | if (perm_fault_granule > PAGE_SIZE) { | |
| 2050 | 2028 | mapping_size = perm_fault_granule; | |
| 2051 | 2029 | } else { | |
| @@ -2126,10 +2104,6 @@ static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd) | |||
| 2126 | 2104 | return ret; | |
| 2127 | 2105 | } | |
| 2128 | 2106 | ||
| 2129 | - | /* | |
| 2130 | - | * Let's check if we will get back a huge page backed by hugetlbfs, or | |
| 2131 | - | * get block mapping for device MMIO region. | |
| 2132 | - | */ | |
| 2133 | 2107 | ret = kvm_s2_fault_pin_pfn(s2fd, &s2vi); | |
| 2134 | 2108 | if (ret != 1) | |
| 2135 | 2109 | return ret; | |
modified arch/arm64/kvm/nested.c
| @@ -45,11 +45,24 @@ struct vncr_tlb { | |||
| 45 | 45 | */ | |
| 46 | 46 | #define S2_MMU_PER_VCPU 2 | |
| 47 | 47 | ||
| 48 | - | void kvm_init_nested(struct kvm *kvm) | |
| 48 | + | int kvm_init_nested(struct kvm *kvm) | |
| 49 | 49 | { | |
| 50 | - | kvm->arch.nested_mmus = NULL; | |
| 50 | + | kvm->arch.nested_mmus = kvmalloc_objs(struct kvm_s2_mmu *, | |
| 51 | + | KVM_MAX_VCPUS * S2_MMU_PER_VCPU, | |
| 52 | + | GFP_KERNEL_ACCOUNT); | |
| 51 | 53 | kvm->arch.nested_mmus_size = 0; | |
| 52 | 54 | atomic_set(&kvm->arch.vncr_tlb_count, 0); | |
| 55 | + | ||
| 56 | + | return kvm->arch.nested_mmus ? 0 : -ENOMEM; | |
| 57 | + | } | |
| 58 | + | ||
| 59 | + | void kvm_destroy_nested(struct kvm *kvm) | |
| 60 | + | { | |
| 61 | + | for (int i = 0; i < kvm->arch.nested_mmus_size; i+= S2_MMU_PER_VCPU) | |
| 62 | + | kvfree(kvm->arch.nested_mmus[i]); | |
| 63 | + | ||
| 64 | + | kvm->arch.nested_mmus_size = 0; | |
| 65 | + | kvfree(kvm->arch.nested_mmus); | |
| 53 | 66 | } | |
| 54 | 67 | ||
| 55 | 68 | static int init_nested_s2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu) | |
| @@ -70,8 +83,9 @@ static int init_nested_s2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu) | |||
| 70 | 83 | int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu) | |
| 71 | 84 | { | |
| 72 | 85 | struct kvm *kvm = vcpu->kvm; | |
| 73 | - | struct kvm_s2_mmu *tmp; | |
| 74 | - | int num_mmus, ret = 0; | |
| 86 | + | int num_mmus; | |
| 87 | + | ||
| 88 | + | lockdep_assert_held(&kvm->arch.config_lock); | |
| 75 | 89 | ||
| 76 | 90 | if (test_bit(KVM_ARM_VCPU_HAS_EL2_E2H0, kvm->arch.vcpu_features) && | |
| 77 | 91 | !cpus_have_final_cap(ARM64_HAS_HCR_NV1)) | |
| @@ -84,51 +98,40 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu) | |||
| 84 | 98 | if (!vcpu->arch.ctxt.vncr_array) | |
| 85 | 99 | return -ENOMEM; | |
| 86 | 100 | ||
| 87 | - | /* | |
| 88 | - | * Let's treat memory allocation failures as benign: If we fail to | |
| 89 | - | * allocate anything, return an error and keep the allocated array | |
| 90 | - | * alive. Userspace may try to recover by initializing the vcpu | |
| 91 | - | * again, and there is no reason to affect the whole VM for this. | |
| 92 | - | */ | |
| 93 | 101 | num_mmus = atomic_read(&kvm->online_vcpus) * S2_MMU_PER_VCPU; | |
| 94 | 102 | ||
| 95 | 103 | if (num_mmus > kvm->arch.nested_mmus_size) { | |
| 96 | - | tmp = kvzalloc_objs(*tmp, num_mmus, GFP_KERNEL_ACCOUNT); | |
| 97 | - | if (!tmp) | |
| 98 | - | return -ENOMEM; | |
| 104 | + | struct kvm_s2_mmu *tmp; | |
| 105 | + | int i, ret = 0; | |
| 99 | 106 | ||
| 100 | - | write_lock(&kvm->mmu_lock); | |
| 101 | - | ||
| 102 | - | if (kvm->arch.nested_mmus_size) { | |
| 103 | - | memcpy(tmp, kvm->arch.nested_mmus, | |
| 104 | - | size_mul(sizeof(*tmp), kvm->arch.nested_mmus_size)); | |
| 107 | + | tmp = kvzalloc_objs(*tmp, S2_MMU_PER_VCPU, GFP_KERNEL_ACCOUNT); | |
| 108 | + | if (!tmp) | |
| 109 | + | ret = -ENOMEM; | |
| 105 | 110 | ||
| 106 | - | for (int i = 0; i < kvm->arch.nested_mmus_size; i++) | |
| 107 | - | tmp[i].pgt->mmu = &tmp[i]; | |
| 111 | + | for (i = 0; !ret && i < S2_MMU_PER_VCPU; i++) { | |
| 112 | + | ret = init_nested_s2_mmu(kvm, &tmp[i]); | |
| 113 | + | if (ret) | |
| 114 | + | break; | |
| 108 | 115 | } | |
| 109 | 116 | ||
| 110 | - | swap(kvm->arch.nested_mmus, tmp); | |
| 111 | - | ||
| 112 | - | write_unlock(&kvm->mmu_lock); | |
| 113 | - | ||
| 114 | - | kvfree(tmp); | |
| 115 | - | } | |
| 117 | + | if (ret) { | |
| 118 | + | while (--i >= 0) | |
| 119 | + | kvm_free_stage2_pgd(&tmp[i]); | |
| 116 | 120 | ||
| 117 | - | for (int i = kvm->arch.nested_mmus_size; !ret && i < num_mmus; i++) | |
| 118 | - | ret = init_nested_s2_mmu(kvm, &kvm->arch.nested_mmus[i]); | |
| 121 | + | kvfree(tmp); | |
| 122 | + | free_page((unsigned long)vcpu->arch.ctxt.vncr_array); | |
| 123 | + | vcpu->arch.ctxt.vncr_array = NULL; | |
| 124 | + | return ret; | |
| 125 | + | } | |
| 119 | 126 | ||
| 120 | - | if (ret) { | |
| 121 | - | for (int i = kvm->arch.nested_mmus_size; i < num_mmus; i++) | |
| 122 | - | kvm_free_stage2_pgd(&kvm->arch.nested_mmus[i]); | |
| 127 | + | guard(write_lock)(&kvm->mmu_lock); | |
| 123 | 128 | ||
| 124 | - | free_page((unsigned long)vcpu->arch.ctxt.vncr_array); | |
| 125 | - | vcpu->arch.ctxt.vncr_array = NULL; | |
| 129 | + | for (i = 0; i < S2_MMU_PER_VCPU; i++) | |
| 130 | + | kvm->arch.nested_mmus[i + kvm->arch.nested_mmus_size] = &tmp[i]; | |
| 126 | 131 | ||
| 127 | - | return ret; | |
| 132 | + | kvm->arch.nested_mmus_size += S2_MMU_PER_VCPU; | |
| 128 | 133 | } | |
| 129 | 134 | ||
| 130 | - | kvm->arch.nested_mmus_size = num_mmus; | |
| 131 | - | ||
| 132 | 135 | return 0; | |
| 133 | 136 | } | |
| 134 | 137 | ||
| @@ -742,7 +745,7 @@ void kvm_s2_mmu_iterate_by_vmid(struct kvm *kvm, u16 vmid, | |||
| 742 | 745 | write_lock(&kvm->mmu_lock); | |
| 743 | 746 | ||
| 744 | 747 | for (int i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 745 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 748 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 746 | 749 | ||
| 747 | 750 | if (!kvm_s2_mmu_valid(mmu)) | |
| 748 | 751 | continue; | |
| @@ -784,7 +787,7 @@ struct kvm_s2_mmu *lookup_s2_mmu(struct kvm_vcpu *vcpu) | |||
| 784 | 787 | * if S2 translation is disabled. | |
| 785 | 788 | */ | |
| 786 | 789 | for (int i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 787 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 790 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 788 | 791 | ||
| 789 | 792 | if (!kvm_s2_mmu_valid(mmu)) | |
| 790 | 793 | continue; | |
| @@ -823,7 +826,7 @@ static struct kvm_s2_mmu *get_s2_mmu_nested(struct kvm_vcpu *vcpu) | |||
| 823 | 826 | for (i = kvm->arch.nested_mmus_next; | |
| 824 | 827 | i < (kvm->arch.nested_mmus_size + kvm->arch.nested_mmus_next); | |
| 825 | 828 | i++) { | |
| 826 | - | s2_mmu = &kvm->arch.nested_mmus[i % kvm->arch.nested_mmus_size]; | |
| 829 | + | s2_mmu = kvm->arch.nested_mmus[i % kvm->arch.nested_mmus_size]; | |
| 827 | 830 | ||
| 828 | 831 | if (atomic_read(&s2_mmu->refcnt) == 0) | |
| 829 | 832 | break; | |
| @@ -1260,6 +1263,17 @@ void kvm_handle_s1e2_tlbi(struct kvm_vcpu *vcpu, u32 inst, u64 val) | |||
| 1260 | 1263 | invalidate_vncr_va(vcpu->kvm, &scope); | |
| 1261 | 1264 | } | |
| 1262 | 1265 | ||
| 1266 | + | static void kvm_invalidate_vncr_ipa_all(struct kvm *kvm) | |
| 1267 | + | { | |
| 1268 | + | struct kvm_pgtable *pgt = kvm->arch.mmu.pgt; | |
| 1269 | + | ||
| 1270 | + | lockdep_assert_held_write(&kvm->mmu_lock); | |
| 1271 | + | ||
| 1272 | + | /* if the mmu lock was dropped, pgt teardown may have raced. */ | |
| 1273 | + | if (pgt) | |
| 1274 | + | kvm_invalidate_vncr_ipa(kvm, 0, BIT(pgt->ia_bits)); | |
| 1275 | + | } | |
| 1276 | + | ||
| 1263 | 1277 | void kvm_nested_s2_wp(struct kvm *kvm) | |
| 1264 | 1278 | { | |
| 1265 | 1279 | int i; | |
| @@ -1270,13 +1284,13 @@ void kvm_nested_s2_wp(struct kvm *kvm) | |||
| 1270 | 1284 | return; | |
| 1271 | 1285 | ||
| 1272 | 1286 | for (i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 1273 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 1287 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 1274 | 1288 | ||
| 1275 | 1289 | if (kvm_s2_mmu_valid(mmu)) | |
| 1276 | 1290 | kvm_stage2_wp_range(mmu, 0, kvm_phys_size(mmu)); | |
| 1277 | 1291 | } | |
| 1278 | 1292 | ||
| 1279 | - | kvm_invalidate_vncr_ipa(kvm, 0, BIT(kvm->arch.mmu.pgt->ia_bits)); | |
| 1293 | + | kvm_invalidate_vncr_ipa_all(kvm); | |
| 1280 | 1294 | } | |
| 1281 | 1295 | ||
| 1282 | 1296 | void kvm_nested_s2_unmap(struct kvm *kvm, bool may_block) | |
| @@ -1289,13 +1303,13 @@ void kvm_nested_s2_unmap(struct kvm *kvm, bool may_block) | |||
| 1289 | 1303 | return; | |
| 1290 | 1304 | ||
| 1291 | 1305 | for (i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 1292 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 1306 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 1293 | 1307 | ||
| 1294 | 1308 | if (kvm_s2_mmu_valid(mmu)) | |
| 1295 | 1309 | kvm_stage2_unmap_range(mmu, 0, kvm_phys_size(mmu), may_block); | |
| 1296 | 1310 | } | |
| 1297 | 1311 | ||
| 1298 | - | kvm_invalidate_vncr_ipa(kvm, 0, BIT(kvm->arch.mmu.pgt->ia_bits)); | |
| 1312 | + | kvm_invalidate_vncr_ipa_all(kvm); | |
| 1299 | 1313 | } | |
| 1300 | 1314 | ||
| 1301 | 1315 | void kvm_nested_s2_flush(struct kvm *kvm) | |
| @@ -1308,7 +1322,7 @@ void kvm_nested_s2_flush(struct kvm *kvm) | |||
| 1308 | 1322 | return; | |
| 1309 | 1323 | ||
| 1310 | 1324 | for (i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 1311 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 1325 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 1312 | 1326 | ||
| 1313 | 1327 | if (kvm_s2_mmu_valid(mmu)) | |
| 1314 | 1328 | kvm_stage2_flush_range(mmu, 0, kvm_phys_size(mmu)); | |
| @@ -1317,17 +1331,12 @@ void kvm_nested_s2_flush(struct kvm *kvm) | |||
| 1317 | 1331 | ||
| 1318 | 1332 | void kvm_arch_flush_shadow_all(struct kvm *kvm) | |
| 1319 | 1333 | { | |
| 1320 | - | int i; | |
| 1321 | - | ||
| 1322 | - | for (i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 1323 | - | struct kvm_s2_mmu *mmu = &kvm->arch.nested_mmus[i]; | |
| 1334 | + | for (int i = 0; i < kvm->arch.nested_mmus_size; i++) { | |
| 1335 | + | struct kvm_s2_mmu *mmu = kvm->arch.nested_mmus[i]; | |
| 1324 | 1336 | ||
| 1325 | 1337 | if (!WARN_ON(atomic_read(&mmu->refcnt))) | |
| 1326 | 1338 | kvm_free_stage2_pgd(mmu); | |
| 1327 | 1339 | } | |
| 1328 | - | kvfree(kvm->arch.nested_mmus); | |
| 1329 | - | kvm->arch.nested_mmus = NULL; | |
| 1330 | - | kvm->arch.nested_mmus_size = 0; | |
| 1331 | 1340 | kvm_uninit_stage2_mmu(kvm); | |
| 1332 | 1341 | } | |
| 1333 | 1342 | ||
modified arch/arm64/kvm/sys_regs.c
| @@ -926,6 +926,7 @@ static u64 *demux_wb_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd) | |||
| 926 | 926 | struct kvm_guest_debug_arch *dbg = &vcpu->arch.vcpu_debug_state; | |
| 927 | 927 | ||
| 928 | 928 | switch (rd->Op2) { | |
| 929 | + | case 0b001: | |
| 929 | 930 | case 0b100: | |
| 930 | 931 | return &dbg->dbg_bvr[rd->CRm]; | |
| 931 | 932 | case 0b101: | |
modified arch/arm64/kvm/vgic/vgic-init.c
| @@ -97,6 +97,9 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) | |||
| 97 | 97 | /* | |
| 98 | 98 | * - Acquiring the vCPU mutex for every *online* vCPU to prevent | |
| 99 | 99 | * concurrent vCPU ioctls for vCPUs already visible to userspace. | |
| 100 | + | * This also ensures KVM isn't in the middle of creating a vCPU, | |
| 101 | + | * i.e. that there are no vCPUs that have been created but aren't | |
| 102 | + | * yet fully online. | |
| 100 | 103 | */ | |
| 101 | 104 | ret = -EBUSY; | |
| 102 | 105 | if (kvm_trylock_all_vcpus(kvm)) | |
| @@ -105,18 +108,11 @@ int kvm_vgic_create(struct kvm *kvm, u32 type) | |||
| 105 | 108 | /* | |
| 106 | 109 | * - Taking the config_lock which protects VGIC data structures such | |
| 107 | 110 | * as the per-vCPU arrays of private IRQs (SGIs, PPIs). | |
| 108 | - | */ | |
| 109 | - | mutex_lock(&kvm->arch.config_lock); | |
| 110 | - | ||
| 111 | - | /* | |
| 112 | - | * - Bailing on the entire thing if a vCPU is in the middle of creation, | |
| 113 | - | * dropped the kvm->lock, but hasn't reached kvm_arch_vcpu_create(). | |
| 114 | 111 | * | |
| 115 | 112 | * The whole combination of this guarantees that no vCPU can get into | |
| 116 | 113 | * KVM with a VGIC configuration inconsistent with the VM's VGIC. | |
| 117 | 114 | */ | |
| 118 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) | |
| 119 | - | goto out_unlock; | |
| 115 | + | mutex_lock(&kvm->arch.config_lock); | |
| 120 | 116 | ||
| 121 | 117 | if (irqchip_in_kernel(kvm)) { | |
| 122 | 118 | ret = -EEXIST; | |
modified arch/arm64/kvm/vgic/vgic-its.c
| @@ -319,12 +319,16 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, | |||
| 319 | 319 | return ret; | |
| 320 | 320 | } | |
| 321 | 321 | ||
| 322 | - | static int update_affinity(struct vgic_irq *irq, struct kvm_vcpu *vcpu) | |
| 322 | + | static int update_affinity(struct vgic_irq *irq, | |
| 323 | + | struct kvm_vcpu *from_vcpu, struct kvm_vcpu *vcpu) | |
| 323 | 324 | { | |
| 324 | 325 | struct its_vlpi_map map; | |
| 325 | 326 | int ret; | |
| 326 | 327 | ||
| 327 | 328 | guard(raw_spinlock_irqsave)(&irq->irq_lock); | |
| 329 | + | if (from_vcpu && irq->target_vcpu != from_vcpu) | |
| 330 | + | return 0; | |
| 331 | + | ||
| 328 | 332 | irq->target_vcpu = vcpu; | |
| 329 | 333 | ||
| 330 | 334 | if (!irq->hw) | |
| @@ -362,7 +366,7 @@ static void update_affinity_ite(struct kvm *kvm, struct its_ite *ite) | |||
| 362 | 366 | return; | |
| 363 | 367 | ||
| 364 | 368 | vcpu = collection_to_vcpu(kvm, ite->collection); | |
| 365 | - | update_affinity(ite->irq, vcpu); | |
| 369 | + | update_affinity(ite->irq, NULL, vcpu); | |
| 366 | 370 | } | |
| 367 | 371 | ||
| 368 | 372 | /* | |
| @@ -856,7 +860,7 @@ static int vgic_its_cmd_handle_movi(struct kvm *kvm, struct vgic_its *its, | |||
| 856 | 860 | ||
| 857 | 861 | vgic_its_invalidate_cache(its); | |
| 858 | 862 | ||
| 859 | - | return update_affinity(ite->irq, vcpu); | |
| 863 | + | return update_affinity(ite->irq, NULL, vcpu); | |
| 860 | 864 | } | |
| 861 | 865 | ||
| 862 | 866 | static bool __is_visible_gfn_locked(struct vgic_its *its, gpa_t gpa) | |
| @@ -1383,7 +1387,7 @@ static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its, | |||
| 1383 | 1387 | if (!irq) | |
| 1384 | 1388 | continue; | |
| 1385 | 1389 | ||
| 1386 | - | update_affinity(irq, vcpu2); | |
| 1390 | + | update_affinity(irq, vcpu1, vcpu2); | |
| 1387 | 1391 | ||
| 1388 | 1392 | vgic_put_irq(kvm, irq); | |
| 1389 | 1393 | } | |
| @@ -1658,7 +1662,7 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1658 | 1662 | unsigned long val) | |
| 1659 | 1663 | { | |
| 1660 | 1664 | const struct vgic_its_abi *abi = vgic_its_get_abi(its); | |
| 1661 | - | u64 entry_size, table_type; | |
| 1665 | + | u64 old, entry_size, table_type; | |
| 1662 | 1666 | u64 reg, *regptr, clearbits = 0; | |
| 1663 | 1667 | ||
| 1664 | 1668 | /* When GITS_CTLR.Enable is 1, we ignore write accesses. */ | |
| @@ -1681,7 +1685,9 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1681 | 1685 | return; | |
| 1682 | 1686 | } | |
| 1683 | 1687 | ||
| 1684 | - | reg = update_64bit_reg(*regptr, addr & 7, len, val); | |
| 1688 | + | old = *regptr; | |
| 1689 | + | ||
| 1690 | + | reg = update_64bit_reg(old, addr & 7, len, val); | |
| 1685 | 1691 | reg &= ~GITS_BASER_RO_MASK; | |
| 1686 | 1692 | reg &= ~clearbits; | |
| 1687 | 1693 | ||
| @@ -1691,7 +1697,8 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1691 | 1697 | ||
| 1692 | 1698 | *regptr = reg; | |
| 1693 | 1699 | ||
| 1694 | - | if (!(reg & GITS_BASER_VALID)) { | |
| 1700 | + | /* The ITS driver rewrites an unchanged GITS_BASER<n> on resume. */ | |
| 1701 | + | if (reg != old) { | |
| 1695 | 1702 | /* Take the its_lock to prevent a race with a save/restore */ | |
| 1696 | 1703 | mutex_lock(&its->its_lock); | |
| 1697 | 1704 | switch (table_type) { | |
| @@ -1702,6 +1709,8 @@ static void vgic_mmio_write_its_baser(struct kvm *kvm, | |||
| 1702 | 1709 | vgic_its_free_collection_list(kvm, its); | |
| 1703 | 1710 | break; | |
| 1704 | 1711 | } | |
| 1712 | + | /* A concurrent injection may have cached a translation. */ | |
| 1713 | + | vgic_its_invalidate_cache(its); | |
| 1705 | 1714 | mutex_unlock(&its->its_lock); | |
| 1706 | 1715 | } | |
| 1707 | 1716 | } | |
| @@ -2019,18 +2028,22 @@ out: | |||
| 2019 | 2028 | return ret; | |
| 2020 | 2029 | } | |
| 2021 | 2030 | ||
| 2022 | - | static u32 compute_next_devid_offset(struct list_head *h, | |
| 2031 | + | static u32 compute_next_devid_offset(struct vgic_its *its, u64 baser, | |
| 2023 | 2032 | struct its_device *dev) | |
| 2024 | 2033 | { | |
| 2025 | - | struct its_device *next; | |
| 2026 | - | u32 next_offset; | |
| 2034 | + | struct its_device *next = dev; | |
| 2027 | 2035 | ||
| 2028 | - | if (list_is_last(&dev->dev_list, h)) | |
| 2029 | - | return 0; | |
| 2030 | - | next = list_next_entry(dev, dev_list); | |
| 2031 | - | next_offset = next->device_id - dev->device_id; | |
| 2036 | + | /* | |
| 2037 | + | * Point at the next device vgic_its_save_device_tables() saves. It | |
| 2038 | + | * sorts device_list first, so the subtraction cannot underflow. | |
| 2039 | + | */ | |
| 2040 | + | list_for_each_entry_continue(next, &its->device_list, dev_list) { | |
| 2041 | + | if (vgic_its_check_id(its, baser, next->device_id, NULL)) | |
| 2042 | + | return min_t(u32, next->device_id - dev->device_id, | |
| 2043 | + | VITS_DTE_MAX_DEVID_OFFSET); | |
| 2044 | + | } | |
| 2032 | 2045 | ||
| 2033 | - | return min_t(u32, next_offset, VITS_DTE_MAX_DEVID_OFFSET); | |
| 2046 | + | return 0; | |
| 2034 | 2047 | } | |
| 2035 | 2048 | ||
| 2036 | 2049 | static u32 compute_next_eventid_offset(struct list_head *h, struct its_ite *ite) | |
| @@ -2271,17 +2284,18 @@ static int vgic_its_restore_itt(struct vgic_its *its, struct its_device *dev) | |||
| 2271 | 2284 | * vgic_its_save_dte - Save a device table entry at a given GPA | |
| 2272 | 2285 | * | |
| 2273 | 2286 | * @its: ITS handle | |
| 2287 | + | * @baser: GITS_BASER<dev> the caller is saving against | |
| 2274 | 2288 | * @dev: ITS device | |
| 2275 | 2289 | * @ptr: GPA | |
| 2276 | 2290 | */ | |
| 2277 | - | static int vgic_its_save_dte(struct vgic_its *its, struct its_device *dev, | |
| 2278 | - | gpa_t ptr) | |
| 2291 | + | static int vgic_its_save_dte(struct vgic_its *its, u64 baser, | |
| 2292 | + | struct its_device *dev, gpa_t ptr) | |
| 2279 | 2293 | { | |
| 2280 | 2294 | u64 val, itt_addr_field; | |
| 2281 | 2295 | u32 next_offset; | |
| 2282 | 2296 | ||
| 2283 | 2297 | itt_addr_field = dev->itt_addr >> 8; | |
| 2284 | - | next_offset = compute_next_devid_offset(&its->device_list, dev); | |
| 2298 | + | next_offset = compute_next_devid_offset(its, baser, dev); | |
| 2285 | 2299 | val = (1ULL << KVM_ITS_DTE_VALID_SHIFT | | |
| 2286 | 2300 | ((u64)next_offset << KVM_ITS_DTE_NEXT_SHIFT) | | |
| 2287 | 2301 | (itt_addr_field << KVM_ITS_DTE_ITTADDR_SHIFT) | | |
| @@ -2380,15 +2394,16 @@ static int vgic_its_save_device_tables(struct vgic_its *its) | |||
| 2380 | 2394 | int ret; | |
| 2381 | 2395 | gpa_t eaddr; | |
| 2382 | 2396 | ||
| 2397 | + | /* Don't fail a save that userspace must be able to issue. */ | |
| 2383 | 2398 | if (!vgic_its_check_id(its, baser, | |
| 2384 | 2399 | dev->device_id, &eaddr)) | |
| 2385 | - | return -EINVAL; | |
| 2400 | + | continue; | |
| 2386 | 2401 | ||
| 2387 | 2402 | ret = vgic_its_save_itt(its, dev); | |
| 2388 | 2403 | if (ret) | |
| 2389 | 2404 | return ret; | |
| 2390 | 2405 | ||
| 2391 | - | ret = vgic_its_save_dte(its, dev, eaddr); | |
| 2406 | + | ret = vgic_its_save_dte(its, baser, dev, eaddr); | |
| 2392 | 2407 | if (ret) | |
| 2393 | 2408 | return ret; | |
| 2394 | 2409 | } | |
| @@ -2541,9 +2556,6 @@ static int vgic_its_save_collection_table(struct vgic_its *its) | |||
| 2541 | 2556 | max_size = GITS_BASER_NR_PAGES(baser) * SZ_64K; | |
| 2542 | 2557 | ||
| 2543 | 2558 | list_for_each_entry(collection, &its->collection_list, coll_list) { | |
| 2544 | - | if (!vgic_its_check_id(its, baser, collection->collection_id, NULL)) | |
| 2545 | - | return -EINVAL; | |
| 2546 | - | ||
| 2547 | 2559 | ret = vgic_its_save_cte(its, collection, gpa); | |
| 2548 | 2560 | if (ret) | |
| 2549 | 2561 | return ret; | |
modified arch/arm64/kvm/vgic/vgic-v2.c
| @@ -122,6 +122,10 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 122 | 122 | for (int lr = 0; lr < vgic_cpu->vgic_v2.used_lrs; lr++) | |
| 123 | 123 | vgic_v2_fold_lr(vcpu, cpuif->vgic_lr[lr]); | |
| 124 | 124 | ||
| 125 | + | cpuif->used_lrs = 0; | |
| 126 | + | if (!irq) | |
| 127 | + | return; | |
| 128 | + | ||
| 125 | 129 | /* See the GICv3 equivalent for the EOIcount handling rationale */ | |
| 126 | 130 | list_for_each_entry_continue(irq, &vgic_cpu->ap_list_head, ap_list) { | |
| 127 | 131 | u32 lr; | |
| @@ -144,8 +148,6 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 144 | 148 | vgic_v2_fold_lr(vcpu, lr); | |
| 145 | 149 | eoicount--; | |
| 146 | 150 | } | |
| 147 | - | ||
| 148 | - | cpuif->used_lrs = 0; | |
| 149 | 151 | } | |
| 150 | 152 | ||
| 151 | 153 | void vgic_v2_deactivate(struct kvm_vcpu *vcpu, u32 val) | |
modified arch/arm64/kvm/vgic/vgic-v3.c
| @@ -155,6 +155,10 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 155 | 155 | for (int lr = 0; lr < cpuif->used_lrs; lr++) | |
| 156 | 156 | vgic_v3_fold_lr(vcpu, cpuif->vgic_lr[lr]); | |
| 157 | 157 | ||
| 158 | + | cpuif->used_lrs = 0; | |
| 159 | + | if (!irq) | |
| 160 | + | return; | |
| 161 | + | ||
| 158 | 162 | /* | |
| 159 | 163 | * EOIMode=0: use EOIcount to emulate deactivation. We are | |
| 160 | 164 | * guaranteed to deactivate in reverse order of the activation, so | |
| @@ -188,8 +192,6 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) | |||
| 188 | 192 | vgic_v3_fold_lr(vcpu, lr); | |
| 189 | 193 | eoicount--; | |
| 190 | 194 | } | |
| 191 | - | ||
| 192 | - | cpuif->used_lrs = 0; | |
| 193 | 195 | } | |
| 194 | 196 | ||
| 195 | 197 | void vgic_v3_deactivate(struct kvm_vcpu *vcpu, u64 val) | |
modified arch/arm64/kvm/vgic/vgic.c
| @@ -853,6 +853,17 @@ retry: | |||
| 853 | 853 | goto retry; | |
| 854 | 854 | } | |
| 855 | 855 | ||
| 856 | + | /* | |
| 857 | + | * Fix the last_lr_irq refcount which was obtained while | |
| 858 | + | * populating the LRs. This can also result in the LPI being | |
| 859 | + | * deleted. | |
| 860 | + | */ | |
| 861 | + | irq = *host_data_ptr(last_lr_irq); | |
| 862 | + | if (irq) { | |
| 863 | + | deleted_lpis |= vgic_put_irq_norelease(vcpu->kvm, irq); | |
| 864 | + | *host_data_ptr(last_lr_irq) = NULL; | |
| 865 | + | } | |
| 866 | + | ||
| 856 | 867 | raw_spin_unlock(&vgic_cpu->ap_list_lock); | |
| 857 | 868 | ||
| 858 | 869 | if (unlikely(deleted_lpis)) | |
| @@ -866,9 +877,6 @@ static void vgic_fold_state(struct kvm_vcpu *vcpu) | |||
| 866 | 877 | return; | |
| 867 | 878 | } | |
| 868 | 879 | ||
| 869 | - | if (!*host_data_ptr(last_lr_irq)) | |
| 870 | - | return; | |
| 871 | - | ||
| 872 | 880 | if (kvm_vgic_global_state.type == VGIC_V2) | |
| 873 | 881 | vgic_v2_fold_lr_state(vcpu); | |
| 874 | 882 | else | |
| @@ -1021,11 +1029,14 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) | |||
| 1021 | 1029 | scoped_guard(raw_spinlock, &irq->irq_lock) { | |
| 1022 | 1030 | if (likely(vgic_target_oracle(irq) == vcpu)) { | |
| 1023 | 1031 | vgic_populate_lr(vcpu, irq, count++); | |
| 1024 | - | *host_data_ptr(last_lr_irq) = irq; | |
| 1032 | + | if (count == kvm_vgic_global_state.nr_lr) { | |
| 1033 | + | vgic_get_irq_ref(irq); | |
| 1034 | + | *host_data_ptr(last_lr_irq) = irq; | |
| 1035 | + | } | |
| 1025 | 1036 | } | |
| 1026 | 1037 | } | |
| 1027 | 1038 | ||
| 1028 | - | if (count == kvm_vgic_global_state.nr_lr) | |
| 1039 | + | if (*host_data_ptr(last_lr_irq)) | |
| 1029 | 1040 | break; | |
| 1030 | 1041 | } | |
| 1031 | 1042 | ||
modified arch/arm64/mm/mmu.c
| @@ -2295,7 +2295,7 @@ pte_t modify_prot_start_ptes(struct vm_area_struct *vma, unsigned long addr, | |||
| 2295 | 2295 | * in cases where cpu is affected with errata #2645198. | |
| 2296 | 2296 | */ | |
| 2297 | 2297 | if (pte_accessible(vma->vm_mm, pte) && pte_user_exec(pte)) | |
| 2298 | - | __flush_tlb_range(vma, addr, nr * PAGE_SIZE, | |
| 2298 | + | __flush_tlb_range(vma, addr, addr + nr * PAGE_SIZE, | |
| 2299 | 2299 | PAGE_SIZE, 3, TLBF_NOWALKCACHE); | |
| 2300 | 2300 | } | |
| 2301 | 2301 | ||
modified arch/arm64/net/bpf_jit_comp.c
| @@ -600,6 +600,8 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf) | |||
| 600 | 600 | * 12 registers are on the stack | |
| 601 | 601 | */ | |
| 602 | 602 | emit(A64_SUB_I(1, A64_SP, A64_FP, 96), ctx); | |
| 603 | + | /* The callback may use its own BPF stack, set up fp for it. */ | |
| 604 | + | ctx->fp_used = true; | |
| 603 | 605 | } | |
| 604 | 606 | ||
| 605 | 607 | /* Stack must be multiples of 16B */ | |
| @@ -2416,10 +2418,11 @@ bool bpf_jit_supports_subprog_tailcalls(void) | |||
| 2416 | 2418 | return true; | |
| 2417 | 2419 | } | |
| 2418 | 2420 | ||
| 2419 | - | static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |
| 2420 | - | int bargs_off, int retval_off, int run_ctx_off, | |
| 2421 | - | bool save_ret) | |
| 2421 | + | static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 2422 | + | struct bpf_tramp_node *node, int bargs_off, | |
| 2423 | + | int retval_off, int run_ctx_off, bool save_ret) | |
| 2422 | 2424 | { | |
| 2425 | + | void *skip; | |
| 2423 | 2426 | __le32 *branch; | |
| 2424 | 2427 | u64 enter_prog; | |
| 2425 | 2428 | u64 exit_prog; | |
| @@ -2429,6 +2432,10 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |||
| 2429 | 2432 | enter_prog = (u64)bpf_trampoline_enter(p); | |
| 2430 | 2433 | exit_prog = (u64)bpf_trampoline_exit(p); | |
| 2431 | 2434 | ||
| 2435 | + | /* nop, patched to skip this prog when it is detached */ | |
| 2436 | + | skip = ctx->ro_image + ctx->idx; | |
| 2437 | + | emit(A64_NOP, ctx); | |
| 2438 | + | ||
| 2432 | 2439 | if (node->cookie == 0) { | |
| 2433 | 2440 | /* if cookie is zero, one instruction is enough to store it */ | |
| 2434 | 2441 | emit(A64_STR64I(A64_ZR, A64_SP, run_ctx_off + cookie_off), ctx); | |
| @@ -2481,11 +2488,13 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *node, | |||
| 2481 | 2488 | emit(A64_ADD_I(1, A64_R(2), A64_SP, run_ctx_off), ctx); | |
| 2482 | 2489 | ||
| 2483 | 2490 | emit_call(exit_prog, ctx); | |
| 2491 | + | ||
| 2492 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_image + ctx->idx); | |
| 2484 | 2493 | } | |
| 2485 | 2494 | ||
| 2486 | - | static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |
| 2487 | - | int bargs_off, int retval_off, int run_ctx_off, | |
| 2488 | - | __le32 **branches) | |
| 2495 | + | static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 2496 | + | struct bpf_tramp_nodes *tn, int bargs_off, | |
| 2497 | + | int retval_off, int run_ctx_off, __le32 **branches) | |
| 2489 | 2498 | { | |
| 2490 | 2499 | int i; | |
| 2491 | 2500 | ||
| @@ -2494,7 +2503,7 @@ static void invoke_bpf_mod_ret(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |||
| 2494 | 2503 | */ | |
| 2495 | 2504 | emit(A64_STR64I(A64_ZR, A64_SP, retval_off), ctx); | |
| 2496 | 2505 | for (i = 0; i < tn->nr_nodes; i++) { | |
| 2497 | - | invoke_bpf_prog(ctx, tn->nodes[i], bargs_off, retval_off, | |
| 2506 | + | invoke_bpf_prog(ctx, im, tn->nodes[i], bargs_off, retval_off, | |
| 2498 | 2507 | run_ctx_off, true); | |
| 2499 | 2508 | /* if (*(u64 *)(sp + retval_off) != 0) | |
| 2500 | 2509 | * goto do_fexit; | |
| @@ -2880,7 +2889,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2880 | 2889 | store_func_meta(ctx, meta, func_meta_off); | |
| 2881 | 2890 | cookie_bargs_off--; | |
| 2882 | 2891 | } | |
| 2883 | - | invoke_bpf_prog(ctx, fentry->nodes[i], bargs_off, | |
| 2892 | + | invoke_bpf_prog(ctx, im, fentry->nodes[i], bargs_off, | |
| 2884 | 2893 | retval_off, run_ctx_off, | |
| 2885 | 2894 | flags & BPF_TRAMP_F_RET_FENTRY_RET); | |
| 2886 | 2895 | } | |
| @@ -2891,7 +2900,7 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2891 | 2900 | if (!branches) | |
| 2892 | 2901 | return -ENOMEM; | |
| 2893 | 2902 | ||
| 2894 | - | invoke_bpf_mod_ret(ctx, fmod_ret, bargs_off, retval_off, | |
| 2903 | + | invoke_bpf_mod_ret(ctx, im, fmod_ret, bargs_off, retval_off, | |
| 2895 | 2904 | run_ctx_off, branches); | |
| 2896 | 2905 | } | |
| 2897 | 2906 | ||
| @@ -2904,9 +2913,6 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2904 | 2913 | emit(A64_RET(A64_R(10)), ctx); | |
| 2905 | 2914 | /* store return value */ | |
| 2906 | 2915 | emit(A64_STR64I(A64_R(0), A64_SP, retval_off), ctx); | |
| 2907 | - | /* reserve a nop for bpf_tramp_image_put */ | |
| 2908 | - | im->ip_after_call = ctx->ro_image + ctx->idx; | |
| 2909 | - | emit(A64_NOP, ctx); | |
| 2910 | 2916 | } | |
| 2911 | 2917 | ||
| 2912 | 2918 | /* update the branches saved in invoke_bpf_mod_ret with cbnz */ | |
| @@ -2928,12 +2934,11 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |||
| 2928 | 2934 | store_func_meta(ctx, meta, func_meta_off); | |
| 2929 | 2935 | cookie_bargs_off--; | |
| 2930 | 2936 | } | |
| 2931 | - | invoke_bpf_prog(ctx, fexit->nodes[i], bargs_off, retval_off, | |
| 2937 | + | invoke_bpf_prog(ctx, im, fexit->nodes[i], bargs_off, retval_off, | |
| 2932 | 2938 | run_ctx_off, false); | |
| 2933 | 2939 | } | |
| 2934 | 2940 | ||
| 2935 | 2941 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2936 | - | im->ip_epilogue = ctx->ro_image + ctx->idx; | |
| 2937 | 2942 | /* for the first pass, assume the worst case */ | |
| 2938 | 2943 | if (!ctx->image) | |
| 2939 | 2944 | ctx->idx += 4; | |
| @@ -2992,7 +2997,7 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |||
| 2992 | 2997 | .image = NULL, | |
| 2993 | 2998 | .idx = 0, | |
| 2994 | 2999 | }; | |
| 2995 | - | struct bpf_tramp_image im; | |
| 3000 | + | struct bpf_tramp_image im = {}; | |
| 2996 | 3001 | struct arg_aux aaux; | |
| 2997 | 3002 | int ret; | |
| 2998 | 3003 | ||
| @@ -3279,6 +3284,10 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |||
| 3279 | 3284 | * longer reachable, since bpf_tramp_image_put() function already | |
| 3280 | 3285 | * uses percpu_ref and task-based rcu to do the sync, no need to call | |
| 3281 | 3286 | * the sync version here, see bpf_tramp_image_put() for details. | |
| 3287 | + | * | |
| 3288 | + | * 3. when a detached prog is patched out of a trampoline, a CPU that | |
| 3289 | + | * still executes the old nop calls the prog before it went through | |
| 3290 | + | * a quiescent state, and the prog is freed after grace periods. | |
| 3282 | 3291 | */ | |
| 3283 | 3292 | ret = aarch64_insn_patch_text_nosync(ip, new_insn); | |
| 3284 | 3293 | out: | |
modified arch/arm64/tools/cpucaps
| @@ -105,7 +105,6 @@ WORKAROUND_1902691 | |||
| 105 | 105 | WORKAROUND_2038923 | |
| 106 | 106 | WORKAROUND_2064142 | |
| 107 | 107 | WORKAROUND_2077057 | |
| 108 | - | WORKAROUND_2457168 | |
| 109 | 108 | WORKAROUND_2645198 | |
| 110 | 109 | WORKAROUND_2658417 | |
| 111 | 110 | WORKAROUND_4193714 | |
| @@ -132,3 +131,4 @@ WORKAROUND_REPEAT_TLBI_SYNC | |||
| 132 | 131 | WORKAROUND_SPECULATIVE_AT | |
| 133 | 132 | WORKAROUND_SPECULATIVE_SSBS | |
| 134 | 133 | WORKAROUND_SPECULATIVE_UNPRIV_LOAD | |
| 134 | + | WORKAROUND_BROKEN_AMU_CONSTCNT | |
modified arch/loongarch/net/bpf_jit.c
| @@ -1578,6 +1578,24 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len) | |||
| 1578 | 1578 | return ret ? ERR_PTR(-EINVAL) : dst; | |
| 1579 | 1579 | } | |
| 1580 | 1580 | ||
| 1581 | + | int arch_bpf_trampoline_skip(void *nop, void *target) | |
| 1582 | + | { | |
| 1583 | + | u32 old_insn = INSN_NOP; | |
| 1584 | + | u32 new_insn = larch_insn_gen_b((unsigned long)nop, (unsigned long)target); | |
| 1585 | + | int ret; | |
| 1586 | + | ||
| 1587 | + | if (memcmp(nop, &old_insn, LOONGARCH_INSN_SIZE)) | |
| 1588 | + | return -EFAULT; | |
| 1589 | + | ||
| 1590 | + | cpus_read_lock(); | |
| 1591 | + | mutex_lock(&text_mutex); | |
| 1592 | + | ret = larch_insn_text_copy(nop, &new_insn, LOONGARCH_INSN_SIZE); | |
| 1593 | + | mutex_unlock(&text_mutex); | |
| 1594 | + | cpus_read_unlock(); | |
| 1595 | + | ||
| 1596 | + | return ret; | |
| 1597 | + | } | |
| 1598 | + | ||
| 1581 | 1599 | int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |
| 1582 | 1600 | enum bpf_text_poke_type new_t, void *old_addr, | |
| 1583 | 1601 | void *new_addr) | |
| @@ -1696,13 +1714,18 @@ static void restore_stk_args(struct jit_ctx *ctx, int nr_stk_args, int args_off, | |||
| 1696 | 1714 | } | |
| 1697 | 1715 | } | |
| 1698 | 1716 | ||
| 1699 | - | static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *n, | |
| 1700 | - | int args_off, int retval_off, int run_ctx_off, bool save_ret) | |
| 1717 | + | static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 1718 | + | struct bpf_tramp_node *n, int args_off, int retval_off, | |
| 1719 | + | int run_ctx_off, bool save_ret) | |
| 1701 | 1720 | { | |
| 1702 | 1721 | int ret; | |
| 1703 | 1722 | u32 *branch; | |
| 1704 | 1723 | struct bpf_prog *p = n->link->prog; | |
| 1705 | 1724 | int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 1725 | + | void *skip = ctx->ro_image + ctx->idx; | |
| 1726 | + | ||
| 1727 | + | /* nop, patched to a b over this prog when it is detached */ | |
| 1728 | + | emit_insn(ctx, nop); | |
| 1706 | 1729 | ||
| 1707 | 1730 | if (n->cookie) | |
| 1708 | 1731 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, | |
| @@ -1755,13 +1778,17 @@ static int invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_node *n, | |||
| 1755 | 1778 | /* arg3: &run_ctx */ | |
| 1756 | 1779 | emit_insn(ctx, addid, LOONGARCH_GPR_A2, LOONGARCH_GPR_FP, -run_ctx_off); | |
| 1757 | 1780 | ret = emit_call(ctx, (const u64)bpf_trampoline_exit(p)); | |
| 1781 | + | if (ret) | |
| 1782 | + | return ret; | |
| 1758 | 1783 | ||
| 1759 | - | return ret; | |
| 1784 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_image + ctx->idx); | |
| 1785 | + | return 0; | |
| 1760 | 1786 | } | |
| 1761 | 1787 | ||
| 1762 | - | static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |
| 1763 | - | int args_off, int retval_off, int run_ctx_off, | |
| 1764 | - | int func_meta_off, bool save_ret, u64 func_meta, int cookie_off) | |
| 1788 | + | static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_image *im, | |
| 1789 | + | struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |
| 1790 | + | int run_ctx_off, int func_meta_off, bool save_ret, | |
| 1791 | + | u64 func_meta, int cookie_off) | |
| 1765 | 1792 | { | |
| 1766 | 1793 | int i, cur_cookie = (cookie_off - args_off) / 8; | |
| 1767 | 1794 | ||
| @@ -1774,7 +1801,8 @@ static int invoke_bpf(struct jit_ctx *ctx, struct bpf_tramp_nodes *tn, | |||
| 1774 | 1801 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, -func_meta_off, meta); | |
| 1775 | 1802 | cur_cookie--; | |
| 1776 | 1803 | } | |
| 1777 | - | err = invoke_bpf_prog(ctx, tn->nodes[i], args_off, retval_off, run_ctx_off, save_ret); | |
| 1804 | + | err = invoke_bpf_prog(ctx, im, tn->nodes[i], args_off, retval_off, | |
| 1805 | + | run_ctx_off, save_ret); | |
| 1778 | 1806 | if (err) | |
| 1779 | 1807 | return err; | |
| 1780 | 1808 | } | |
| @@ -2017,7 +2045,7 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2017 | 2045 | } | |
| 2018 | 2046 | ||
| 2019 | 2047 | if (fentry->nr_nodes) { | |
| 2020 | - | ret = invoke_bpf(ctx, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 2048 | + | ret = invoke_bpf(ctx, im, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 2021 | 2049 | flags & BPF_TRAMP_F_RET_FENTRY_RET, func_meta, cookie_off); | |
| 2022 | 2050 | if (ret) | |
| 2023 | 2051 | return ret; | |
| @@ -2029,7 +2057,7 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2029 | 2057 | ||
| 2030 | 2058 | emit_insn(ctx, std, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_FP, -retval_off); | |
| 2031 | 2059 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 2032 | - | ret = invoke_bpf_prog(ctx, fmod_ret->nodes[i], | |
| 2060 | + | ret = invoke_bpf_prog(ctx, im, fmod_ret->nodes[i], | |
| 2033 | 2061 | args_off, retval_off, run_ctx_off, true); | |
| 2034 | 2062 | if (ret) | |
| 2035 | 2063 | goto out; | |
| @@ -2051,10 +2079,6 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2051 | 2079 | goto out; | |
| 2052 | 2080 | emit_insn(ctx, std, LOONGARCH_GPR_A0, LOONGARCH_GPR_FP, -retval_off); | |
| 2053 | 2081 | emit_insn(ctx, std, regmap[BPF_REG_0], LOONGARCH_GPR_FP, -(retval_off - 8)); | |
| 2054 | - | im->ip_after_call = ctx->ro_image + ctx->idx; | |
| 2055 | - | /* Reserve space for the move_imm + jirl instruction */ | |
| 2056 | - | for (i = 0; i < LOONGARCH_LONG_JUMP_NINSNS; i++) | |
| 2057 | - | emit_insn(ctx, nop); | |
| 2058 | 2082 | } | |
| 2059 | 2083 | ||
| 2060 | 2084 | for (i = 0; ctx->image && i < fmod_ret->nr_nodes; i++) { | |
| @@ -2068,14 +2092,13 @@ static int __arch_prepare_bpf_trampoline(struct jit_ctx *ctx, struct bpf_tramp_i | |||
| 2068 | 2092 | emit_store_stack_imm64(ctx, LOONGARCH_GPR_T1, -func_meta_off, func_meta); | |
| 2069 | 2093 | ||
| 2070 | 2094 | if (fexit->nr_nodes) { | |
| 2071 | - | ret = invoke_bpf(ctx, fexit, args_off, retval_off, run_ctx_off, | |
| 2095 | + | ret = invoke_bpf(ctx, im, fexit, args_off, retval_off, run_ctx_off, | |
| 2072 | 2096 | func_meta_off, false, func_meta, cookie_off); | |
| 2073 | 2097 | if (ret) | |
| 2074 | 2098 | goto out; | |
| 2075 | 2099 | } | |
| 2076 | 2100 | ||
| 2077 | 2101 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2078 | - | im->ip_epilogue = ctx->ro_image + ctx->idx; | |
| 2079 | 2102 | move_addr(ctx, LOONGARCH_GPR_A0, (const u64)im); | |
| 2080 | 2103 | ret = emit_call(ctx, (const u64)__bpf_tramp_exit); | |
| 2081 | 2104 | if (ret) | |
| @@ -2177,11 +2200,8 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |||
| 2177 | 2200 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 2178 | 2201 | { | |
| 2179 | 2202 | int ret; | |
| 2180 | - | struct jit_ctx ctx; | |
| 2181 | - | struct bpf_tramp_image im; | |
| 2182 | - | ||
| 2183 | - | ctx.image = NULL; | |
| 2184 | - | ctx.idx = 0; | |
| 2203 | + | struct jit_ctx ctx = {}; | |
| 2204 | + | struct bpf_tramp_image im = {}; | |
| 2185 | 2205 | ||
| 2186 | 2206 | ret = __arch_prepare_bpf_trampoline(&ctx, &im, m, tnodes, func_addr, flags); | |
| 2187 | 2207 | ||
modified arch/loongarch/vdso/Makefile
| @@ -16,6 +16,7 @@ ccflags-vdso := \ | |||
| 16 | 16 | $(filter -m64,$(KBUILD_CFLAGS)) \ | |
| 17 | 17 | $(filter -march=%,$(KBUILD_CFLAGS)) \ | |
| 18 | 18 | $(filter -m%-float,$(KBUILD_CFLAGS)) \ | |
| 19 | + | $(CONFIG_CC_OPT_INLINE_MEMSET) \ | |
| 19 | 20 | $(CLANG_FLAGS) \ | |
| 20 | 21 | -D__VDSO__ | |
| 21 | 22 | ||
modified arch/mips/Kconfig
| @@ -396,10 +396,7 @@ config ECONET | |||
| 396 | 396 | bool "EcoNet MIPS family" | |
| 397 | 397 | select BOOT_RAW | |
| 398 | 398 | select DEBUG_ZBOOT if DEBUG_KERNEL | |
| 399 | - | select EARLY_PRINTK_8250 | |
| 400 | 399 | select ECONET_EN751221_TIMER | |
| 401 | - | select SERIAL_8250 | |
| 402 | - | select SERIAL_OF_PLATFORM | |
| 403 | 400 | select SYS_SUPPORTS_BIG_ENDIAN | |
| 404 | 401 | select SYS_HAS_CPU_MIPS32_R1 | |
| 405 | 402 | select SYS_HAS_CPU_MIPS32_R2 | |
| @@ -661,6 +658,7 @@ config EYEQ | |||
| 661 | 658 | select USB_UHCI_BIG_ENDIAN_MMIO if CPU_BIG_ENDIAN | |
| 662 | 659 | select USE_OF | |
| 663 | 660 | select HOTPLUG_PARALLEL if HOTPLUG_CPU | |
| 661 | + | select WEAK_REORDERING_BEYOND_LLSC | |
| 664 | 662 | help | |
| 665 | 663 | Select this to build a kernel supporting EyeQ SoC from Mobileye. | |
| 666 | 664 | ||
modified arch/mips/cavium-octeon/octeon-platform.c
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | #include <asm/octeon/octeon.h> | |
| 19 | 19 | #include <asm/octeon/cvmx-helper-board.h> | |
| 20 | 20 | ||
| 21 | - | #ifdef CONFIG_USB | |
| 21 | + | #if IS_ENABLED(CONFIG_USB) | |
| 22 | 22 | #include <linux/usb/ehci_def.h> | |
| 23 | 23 | #include <linux/usb/ehci_pdriver.h> | |
| 24 | 24 | #include <linux/usb/ohci_pdriver.h> | |
| @@ -1080,7 +1080,7 @@ end_led: | |||
| 1080 | 1080 | ; | |
| 1081 | 1081 | } | |
| 1082 | 1082 | ||
| 1083 | - | #ifdef CONFIG_USB | |
| 1083 | + | #if IS_ENABLED(CONFIG_USB) | |
| 1084 | 1084 | /* OHCI/UHCI USB */ | |
| 1085 | 1085 | alias_prop = fdt_getprop(initial_boot_params, aliases, | |
| 1086 | 1086 | "uctl", NULL); | |
added arch/mips/configs/econet_en751221_defconfig mode 100644
| @@ -0,0 +1,264 @@ | |||
| 1 | + | # CONFIG_LOCALVERSION_AUTO is not set | |
| 2 | + | CONFIG_KERNEL_XZ=y | |
| 3 | + | CONFIG_SYSVIPC=y | |
| 4 | + | CONFIG_POSIX_MQUEUE=y | |
| 5 | + | # CONFIG_CROSS_MEMORY_ATTACH is not set | |
| 6 | + | CONFIG_HIGH_RES_TIMERS=y | |
| 7 | + | CONFIG_BPF_SYSCALL=y | |
| 8 | + | CONFIG_BPF_JIT=y | |
| 9 | + | CONFIG_PREEMPT=y | |
| 10 | + | CONFIG_CGROUPS=y | |
| 11 | + | CONFIG_MEMCG=y | |
| 12 | + | CONFIG_BLK_CGROUP=y | |
| 13 | + | CONFIG_CGROUP_SCHED=y | |
| 14 | + | CONFIG_CFS_BANDWIDTH=y | |
| 15 | + | CONFIG_RT_GROUP_SCHED=y | |
| 16 | + | CONFIG_CGROUP_PIDS=y | |
| 17 | + | CONFIG_CGROUP_RDMA=y | |
| 18 | + | CONFIG_CPUSETS=y | |
| 19 | + | CONFIG_CGROUP_CPUACCT=y | |
| 20 | + | CONFIG_CGROUP_BPF=y | |
| 21 | + | CONFIG_NAMESPACES=y | |
| 22 | + | # CONFIG_TIME_NS is not set | |
| 23 | + | CONFIG_USER_NS=y | |
| 24 | + | CONFIG_BLK_DEV_INITRD=y | |
| 25 | + | # CONFIG_RD_GZIP is not set | |
| 26 | + | # CONFIG_RD_BZIP2 is not set | |
| 27 | + | # CONFIG_RD_LZMA is not set | |
| 28 | + | # CONFIG_RD_XZ is not set | |
| 29 | + | # CONFIG_RD_LZO is not set | |
| 30 | + | # CONFIG_RD_LZ4 is not set | |
| 31 | + | # CONFIG_RD_ZSTD is not set | |
| 32 | + | # CONFIG_INITRAMFS_PRESERVE_MTIME is not set | |
| 33 | + | CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y | |
| 34 | + | CONFIG_EXPERT=y | |
| 35 | + | # CONFIG_SGETMASK_SYSCALL is not set | |
| 36 | + | # CONFIG_IO_URING is not set | |
| 37 | + | # CONFIG_RSEQ is not set | |
| 38 | + | # CONFIG_CACHESTAT_SYSCALL is not set | |
| 39 | + | CONFIG_ECONET=y | |
| 40 | + | CONFIG_CPU_MIPS32_R2=y | |
| 41 | + | CONFIG_ZBOOT_LOAD_ADDRESS=0x80020000 | |
| 42 | + | CONFIG_ARCH_FORCE_MAX_ORDER=11 | |
| 43 | + | # CONFIG_MIPS_FP_SUPPORT is not set | |
| 44 | + | CONFIG_NR_CPUS=2 | |
| 45 | + | CONFIG_HZ_100=y | |
| 46 | + | CONFIG_MIPS_RAW_APPENDED_DTB=y | |
| 47 | + | # CONFIG_SCHED_SMT is not set | |
| 48 | + | CONFIG_JUMP_LABEL=y | |
| 49 | + | # CONFIG_STACKPROTECTOR_STRONG is not set | |
| 50 | + | # CONFIG_GCC_PLUGINS is not set | |
| 51 | + | CONFIG_MODULES=y | |
| 52 | + | CONFIG_MODULE_UNLOAD=y | |
| 53 | + | # CONFIG_BLOCK_LEGACY_AUTOLOAD is not set | |
| 54 | + | CONFIG_BLK_DEV_THROTTLING=y | |
| 55 | + | # CONFIG_BLK_DEBUG_FS is not set | |
| 56 | + | CONFIG_PARTITION_ADVANCED=y | |
| 57 | + | CONFIG_OF_PARTITION=y | |
| 58 | + | # CONFIG_MQ_IOSCHED_DEADLINE is not set | |
| 59 | + | # CONFIG_MQ_IOSCHED_KYBER is not set | |
| 60 | + | # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set | |
| 61 | + | CONFIG_SLAB_FREELIST_RANDOM=y | |
| 62 | + | CONFIG_SLAB_FREELIST_HARDENED=y | |
| 63 | + | # CONFIG_COMPAT_BRK is not set | |
| 64 | + | CONFIG_LRU_GEN=y | |
| 65 | + | CONFIG_LRU_GEN_ENABLED=y | |
| 66 | + | CONFIG_NET=y | |
| 67 | + | CONFIG_PACKET=y | |
| 68 | + | CONFIG_UNIX=y | |
| 69 | + | CONFIG_INET=y | |
| 70 | + | CONFIG_IP_MULTICAST=y | |
| 71 | + | CONFIG_IP_ADVANCED_ROUTER=y | |
| 72 | + | CONFIG_IP_MULTIPLE_TABLES=y | |
| 73 | + | CONFIG_IP_ROUTE_MULTIPATH=y | |
| 74 | + | CONFIG_IP_ROUTE_VERBOSE=y | |
| 75 | + | CONFIG_IP_MROUTE=y | |
| 76 | + | CONFIG_IP_MROUTE_MULTIPLE_TABLES=y | |
| 77 | + | CONFIG_IP_PIMSM_V1=y | |
| 78 | + | CONFIG_IP_PIMSM_V2=y | |
| 79 | + | CONFIG_SYN_COOKIES=y | |
| 80 | + | # CONFIG_INET_DIAG is not set | |
| 81 | + | CONFIG_TCP_CONG_ADVANCED=y | |
| 82 | + | # CONFIG_TCP_CONG_BIC is not set | |
| 83 | + | # CONFIG_TCP_CONG_WESTWOOD is not set | |
| 84 | + | # CONFIG_TCP_CONG_HTCP is not set | |
| 85 | + | # CONFIG_IPV6_SIT is not set | |
| 86 | + | CONFIG_IPV6_SUBTREES=y | |
| 87 | + | CONFIG_IPV6_MROUTE=y | |
| 88 | + | CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y | |
| 89 | + | CONFIG_IPV6_PIMSM_V2=y | |
| 90 | + | CONFIG_IPV6_SEG6_LWTUNNEL=y | |
| 91 | + | CONFIG_MPTCP=y | |
| 92 | + | CONFIG_NETFILTER=y | |
| 93 | + | # CONFIG_NETFILTER_EGRESS is not set | |
| 94 | + | CONFIG_NF_CONNTRACK=m | |
| 95 | + | CONFIG_NF_CONNTRACK_MARK=y | |
| 96 | + | CONFIG_NF_CONNTRACK_ZONES=y | |
| 97 | + | CONFIG_NF_CONNTRACK_PROCFS=y | |
| 98 | + | CONFIG_NF_CONNTRACK_TIMEOUT=y | |
| 99 | + | # CONFIG_NF_CT_PROTO_SCTP is not set | |
| 100 | + | CONFIG_NF_TABLES=m | |
| 101 | + | CONFIG_NF_TABLES_INET=y | |
| 102 | + | CONFIG_NF_TABLES_NETDEV=y | |
| 103 | + | CONFIG_NFT_NUMGEN=m | |
| 104 | + | CONFIG_NFT_CT=m | |
| 105 | + | CONFIG_NFT_FLOW_OFFLOAD=m | |
| 106 | + | CONFIG_NFT_LOG=m | |
| 107 | + | CONFIG_NFT_LIMIT=m | |
| 108 | + | CONFIG_NFT_MASQ=m | |
| 109 | + | CONFIG_NFT_REDIR=m | |
| 110 | + | CONFIG_NFT_NAT=m | |
| 111 | + | CONFIG_NFT_QUOTA=m | |
| 112 | + | CONFIG_NFT_REJECT=m | |
| 113 | + | CONFIG_NFT_HASH=m | |
| 114 | + | CONFIG_NFT_FIB_INET=m | |
| 115 | + | CONFIG_NF_FLOW_TABLE_INET=m | |
| 116 | + | CONFIG_NF_FLOW_TABLE=m | |
| 117 | + | CONFIG_NFT_FIB_IPV4=m | |
| 118 | + | CONFIG_NF_TABLES_ARP=y | |
| 119 | + | CONFIG_NF_LOG_IPV4=m | |
| 120 | + | CONFIG_NFT_FIB_IPV6=m | |
| 121 | + | CONFIG_NF_LOG_IPV6=m | |
| 122 | + | CONFIG_NF_TABLES_BRIDGE=m | |
| 123 | + | CONFIG_BRIDGE=y | |
| 124 | + | CONFIG_BRIDGE_VLAN_FILTERING=y | |
| 125 | + | CONFIG_VLAN_8021Q=y | |
| 126 | + | CONFIG_NET_SCHED=y | |
| 127 | + | CONFIG_NET_SCH_FQ_CODEL=y | |
| 128 | + | CONFIG_NET_SCH_DEFAULT=y | |
| 129 | + | CONFIG_DEFAULT_FQ_CODEL=y | |
| 130 | + | CONFIG_NET_SWITCHDEV=y | |
| 131 | + | CONFIG_NET_L3_MASTER_DEV=y | |
| 132 | + | CONFIG_RFKILL=y | |
| 133 | + | # CONFIG_LWTUNNEL_BPF is not set | |
| 134 | + | CONFIG_PCI=y | |
| 135 | + | CONFIG_PCIEPORTBUS=y | |
| 136 | + | CONFIG_PCIEAER=y | |
| 137 | + | # CONFIG_PCIEASPM is not set | |
| 138 | + | CONFIG_PCI_MSI=y | |
| 139 | + | # CONFIG_VGA_ARB is not set | |
| 140 | + | CONFIG_PCIE_MEDIATEK=y | |
| 141 | + | CONFIG_MTD=y | |
| 142 | + | CONFIG_MTD_BLOCK=y | |
| 143 | + | CONFIG_MTD_CFI=y | |
| 144 | + | CONFIG_MTD_CFI_INTELEXT=y | |
| 145 | + | CONFIG_MTD_CFI_AMDSTD=y | |
| 146 | + | CONFIG_MTD_COMPLEX_MAPPINGS=y | |
| 147 | + | CONFIG_MTD_SPI_NAND=y | |
| 148 | + | CONFIG_MTD_UBI=y | |
| 149 | + | CONFIG_MTD_UBI_BEB_LIMIT=13 | |
| 150 | + | CONFIG_MTD_UBI_BLOCK=y | |
| 151 | + | CONFIG_NETDEVICES=y | |
| 152 | + | # CONFIG_NET_VENDOR_ASIX is not set | |
| 153 | + | # CONFIG_NET_VENDOR_ENGLEDER is not set | |
| 154 | + | # CONFIG_NET_VENDOR_FUNGIBLE is not set | |
| 155 | + | # CONFIG_NET_VENDOR_LITEX is not set | |
| 156 | + | # CONFIG_NET_VENDOR_MICROSOFT is not set | |
| 157 | + | # CONFIG_NET_VENDOR_VERTEXCOM is not set | |
| 158 | + | # CONFIG_NET_VENDOR_WANGXUN is not set | |
| 159 | + | CONFIG_PPP=m | |
| 160 | + | CONFIG_PPP_FILTER=y | |
| 161 | + | CONFIG_PPP_MULTILINK=y | |
| 162 | + | CONFIG_PPPOE=m | |
| 163 | + | CONFIG_PPP_ASYNC=m | |
| 164 | + | # CONFIG_WLAN_VENDOR_ADMTEK is not set | |
| 165 | + | # CONFIG_WLAN_VENDOR_ATH is not set | |
| 166 | + | # CONFIG_WLAN_VENDOR_ATMEL is not set | |
| 167 | + | # CONFIG_WLAN_VENDOR_BROADCOM is not set | |
| 168 | + | # CONFIG_WLAN_VENDOR_INTEL is not set | |
| 169 | + | # CONFIG_WLAN_VENDOR_INTERSIL is not set | |
| 170 | + | # CONFIG_WLAN_VENDOR_MARVELL is not set | |
| 171 | + | # CONFIG_WLAN_VENDOR_MEDIATEK is not set | |
| 172 | + | # CONFIG_WLAN_VENDOR_MICROCHIP is not set | |
| 173 | + | # CONFIG_WLAN_VENDOR_PURELIFI is not set | |
| 174 | + | # CONFIG_WLAN_VENDOR_RALINK is not set | |
| 175 | + | # CONFIG_WLAN_VENDOR_REALTEK is not set | |
| 176 | + | # CONFIG_WLAN_VENDOR_RSI is not set | |
| 177 | + | # CONFIG_WLAN_VENDOR_SILABS is not set | |
| 178 | + | # CONFIG_WLAN_VENDOR_ST is not set | |
| 179 | + | # CONFIG_WLAN_VENDOR_TI is not set | |
| 180 | + | # CONFIG_WLAN_VENDOR_ZYDAS is not set | |
| 181 | + | # CONFIG_WLAN_VENDOR_QUANTENNA is not set | |
| 182 | + | # CONFIG_INPUT is not set | |
| 183 | + | # CONFIG_SERIO is not set | |
| 184 | + | # CONFIG_VT is not set | |
| 185 | + | # CONFIG_LEGACY_PTYS is not set | |
| 186 | + | # CONFIG_LEGACY_TIOCSTI is not set | |
| 187 | + | CONFIG_SERIAL_8250=y | |
| 188 | + | CONFIG_SERIAL_8250_CONSOLE=y | |
| 189 | + | CONFIG_SERIAL_OF_PLATFORM=y | |
| 190 | + | # CONFIG_HW_RANDOM is not set | |
| 191 | + | # CONFIG_DEVMEM is not set | |
| 192 | + | CONFIG_SPI=y | |
| 193 | + | # CONFIG_PTP_1588_CLOCK is not set | |
| 194 | + | CONFIG_GPIOLIB=y | |
| 195 | + | # CONFIG_HWMON is not set | |
| 196 | + | CONFIG_WATCHDOG=y | |
| 197 | + | CONFIG_MFD_SYSCON=y | |
| 198 | + | # CONFIG_USB_PCI is not set | |
| 199 | + | CONFIG_NEW_LEDS=y | |
| 200 | + | CONFIG_LEDS_CLASS=y | |
| 201 | + | CONFIG_LEDS_CLASS_MULTICOLOR=y | |
| 202 | + | CONFIG_LEDS_GPIO=m | |
| 203 | + | CONFIG_LEDS_TRIGGERS=y | |
| 204 | + | CONFIG_LEDS_TRIGGER_TIMER=y | |
| 205 | + | CONFIG_LEDS_TRIGGER_HEARTBEAT=y | |
| 206 | + | CONFIG_LEDS_TRIGGER_DEFAULT_ON=y | |
| 207 | + | CONFIG_LEDS_TRIGGER_NETDEV=y | |
| 208 | + | CONFIG_STAGING=y | |
| 209 | + | # CONFIG_MIPS_PLATFORM_DEVICES is not set | |
| 210 | + | CONFIG_COMMON_CLK_EN7523=y | |
| 211 | + | # CONFIG_IOMMU_SUPPORT is not set | |
| 212 | + | CONFIG_RESET_CONTROLLER=y | |
| 213 | + | CONFIG_PHY_ECONET_PCIE=y | |
| 214 | + | # CONFIG_DNOTIFY is not set | |
| 215 | + | CONFIG_FANOTIFY=y | |
| 216 | + | CONFIG_OVERLAY_FS=y | |
| 217 | + | # CONFIG_OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW is not set | |
| 218 | + | # CONFIG_PROC_PAGE_MONITOR is not set | |
| 219 | + | CONFIG_TMPFS=y | |
| 220 | + | CONFIG_TMPFS_POSIX_ACL=y | |
| 221 | + | CONFIG_JFFS2_FS=y | |
| 222 | + | CONFIG_JFFS2_SUMMARY=y | |
| 223 | + | CONFIG_JFFS2_FS_XATTR=y | |
| 224 | + | CONFIG_JFFS2_COMPRESSION_OPTIONS=y | |
| 225 | + | CONFIG_UBIFS_FS=y | |
| 226 | + | CONFIG_SQUASHFS=y | |
| 227 | + | CONFIG_SQUASHFS_FILE_DIRECT=y | |
| 228 | + | CONFIG_SQUASHFS_COMPILE_DECOMP_MULTI_PERCPU=y | |
| 229 | + | # CONFIG_SQUASHFS_ZLIB is not set | |
| 230 | + | CONFIG_SQUASHFS_XZ=y | |
| 231 | + | CONFIG_SQUASHFS_EMBEDDED=y | |
| 232 | + | CONFIG_KEYS=y | |
| 233 | + | CONFIG_INIT_STACK_NONE=y | |
| 234 | + | CONFIG_FORTIFY_SOURCE=y | |
| 235 | + | CONFIG_HARDENED_USERCOPY=y | |
| 236 | + | CONFIG_LIST_HARDENED=y | |
| 237 | + | CONFIG_CRYPTO_NULL=y | |
| 238 | + | CONFIG_CRYPTO_AES=y | |
| 239 | + | CONFIG_CRYPTO_CCM=y | |
| 240 | + | CONFIG_CRYPTO_GCM=y | |
| 241 | + | # CONFIG_CRYPTO_HW is not set | |
| 242 | + | # CONFIG_XZ_DEC_X86 is not set | |
| 243 | + | # CONFIG_XZ_DEC_POWERPC is not set | |
| 244 | + | # CONFIG_XZ_DEC_ARM is not set | |
| 245 | + | # CONFIG_XZ_DEC_ARMTHUMB is not set | |
| 246 | + | # CONFIG_XZ_DEC_ARM64 is not set | |
| 247 | + | # CONFIG_XZ_DEC_SPARC is not set | |
| 248 | + | # CONFIG_XZ_DEC_RISCV is not set | |
| 249 | + | CONFIG_PRINTK_TIME=y | |
| 250 | + | # CONFIG_DEBUG_MISC is not set | |
| 251 | + | CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y | |
| 252 | + | CONFIG_DEBUG_INFO_REDUCED=y | |
| 253 | + | CONFIG_FRAME_WARN=1024 | |
| 254 | + | CONFIG_STRIP_ASM_SYMS=y | |
| 255 | + | CONFIG_MAGIC_SYSRQ=y | |
| 256 | + | # CONFIG_MAGIC_SYSRQ_SERIAL is not set | |
| 257 | + | CONFIG_DEBUG_FS=y | |
| 258 | + | # CONFIG_SLUB_DEBUG is not set | |
| 259 | + | CONFIG_SCHED_STACK_END_CHECK=y | |
| 260 | + | CONFIG_PANIC_ON_OOPS=y | |
| 261 | + | CONFIG_PANIC_TIMEOUT=1 | |
| 262 | + | CONFIG_RCU_CPU_STALL_TIMEOUT=60 | |
| 263 | + | # CONFIG_RCU_TRACE is not set | |
| 264 | + | # CONFIG_FTRACE is not set | |
modified arch/mips/net/bpf_jit_comp32.c
| @@ -1111,7 +1111,7 @@ static void emit_jmp_i64(struct jit_context *ctx, | |||
| 1111 | 1111 | emit(ctx, xor, tmp, lo(dst), tmp); | |
| 1112 | 1112 | } | |
| 1113 | 1113 | if (imm < 0) { /* Compare sign extension */ | |
| 1114 | - | emit(ctx, addu, MIPS_R_T9, hi(dst), 1); | |
| 1114 | + | emit(ctx, addiu, MIPS_R_T9, hi(dst), 1); | |
| 1115 | 1115 | emit(ctx, or, tmp, tmp, MIPS_R_T9); | |
| 1116 | 1116 | } else { /* Compare zero extension */ | |
| 1117 | 1117 | emit(ctx, or, tmp, tmp, hi(dst)); | |
modified arch/mips/net/bpf_jit_comp64.c
| @@ -305,8 +305,7 @@ static void emit_bswap_r64(struct jit_context *ctx, u8 dst, u32 width) | |||
| 305 | 305 | case 16: | |
| 306 | 306 | emit_sext(ctx, dst, dst); | |
| 307 | 307 | emit_bswap_r(ctx, dst, width); | |
| 308 | - | if (cpu_has_mips64r2 || cpu_has_mips64r6) | |
| 309 | - | emit_zext(ctx, dst); | |
| 308 | + | emit_zext(ctx, dst); | |
| 310 | 309 | break; | |
| 311 | 310 | } | |
| 312 | 311 | clobber_reg(ctx, dst); | |
deleted arch/parisc/include/asm/compat_ucontext.h mode 100644
| @@ -1,18 +0,0 @@ | |||
| 1 | - | /* SPDX-License-Identifier: GPL-2.0 */ | |
| 2 | - | #ifndef _ASM_PARISC_COMPAT_UCONTEXT_H | |
| 3 | - | #define _ASM_PARISC_COMPAT_UCONTEXT_H | |
| 4 | - | ||
| 5 | - | #include <linux/compat.h> | |
| 6 | - | ||
| 7 | - | /* 32-bit ucontext as seen from an 64-bit kernel */ | |
| 8 | - | struct compat_ucontext { | |
| 9 | - | compat_uint_t uc_flags; | |
| 10 | - | compat_uptr_t uc_link; | |
| 11 | - | compat_stack_t uc_stack; /* struct compat_sigaltstack (12 bytes)*/ | |
| 12 | - | /* FIXME: Pad out to get uc_mcontext to start at an 8-byte aligned boundary */ | |
| 13 | - | compat_uint_t pad[1]; | |
| 14 | - | struct compat_sigcontext uc_mcontext; | |
| 15 | - | compat_sigset_t uc_sigmask; /* mask last for extensibility */ | |
| 16 | - | }; | |
| 17 | - | ||
| 18 | - | #endif /* !_ASM_PARISC_COMPAT_UCONTEXT_H */ | |
modified arch/parisc/include/asm/thread_info.h
| @@ -24,7 +24,7 @@ struct thread_info { | |||
| 24 | 24 | ||
| 25 | 25 | /* thread information allocation */ | |
| 26 | 26 | ||
| 27 | - | #ifdef CONFIG_IRQSTACKS | |
| 27 | + | #if defined(CONFIG_IRQSTACKS) && !defined(CONFIG_64BIT) | |
| 28 | 28 | #define THREAD_SIZE_ORDER 2 /* PA-RISC requires at least 16k stack */ | |
| 29 | 29 | #else | |
| 30 | 30 | #define THREAD_SIZE_ORDER 3 /* PA-RISC requires at least 32k stack */ | |
modified arch/parisc/kernel/setup.c
| @@ -132,6 +132,18 @@ void __init setup_arch(char **cmdline_p) | |||
| 132 | 132 | parisc_cache_init(); | |
| 133 | 133 | paging_init(); | |
| 134 | 134 | ||
| 135 | + | /* | |
| 136 | + | * Parse early parameters before mm_core_init_early() runs. | |
| 137 | + | * Several early_param() handlers only record data that is consumed | |
| 138 | + | * from there - for example hugepages=, hugepagesz=, | |
| 139 | + | * default_hugepagesz=, hugetlb_cma= and hugetlb_free_vmemmap= - so | |
| 140 | + | * the generic parse_early_param() call in start_kernel() is too late | |
| 141 | + | * for them. jump_label_init() must come first, since early param | |
| 142 | + | * handlers may enable or disable static keys. | |
| 143 | + | */ | |
| 144 | + | jump_label_init(); | |
| 145 | + | parse_early_param(); | |
| 146 | + | ||
| 135 | 147 | #ifdef CONFIG_PA11 | |
| 136 | 148 | dma_ops_init(); | |
| 137 | 149 | #endif | |
modified arch/parisc/kernel/unwind.c
| @@ -14,6 +14,7 @@ | |||
| 14 | 14 | #include <linux/sched.h> | |
| 15 | 15 | #include <linux/slab.h> | |
| 16 | 16 | #include <linux/sort.h> | |
| 17 | + | #include <linux/bsearch.h> | |
| 17 | 18 | #include <linux/sched/task_stack.h> | |
| 18 | 19 | ||
| 19 | 20 | #include <linux/uaccess.h> | |
| @@ -49,27 +50,23 @@ static DEFINE_SPINLOCK(unwind_lock); | |||
| 49 | 50 | static struct unwind_table kernel_unwind_table __ro_after_init; | |
| 50 | 51 | static LIST_HEAD(unwind_tables); | |
| 51 | 52 | ||
| 52 | - | static inline const struct unwind_table_entry * | |
| 53 | - | find_unwind_entry_in_table(const struct unwind_table *table, unsigned long addr) | |
| 53 | + | static int cmp_unwind_entry(const void *key, const void *elt) | |
| 54 | 54 | { | |
| 55 | - | const struct unwind_table_entry *e = NULL; | |
| 56 | - | unsigned long lo, hi, mid; | |
| 55 | + | unsigned long addr = (unsigned long)key; | |
| 56 | + | const struct unwind_table_entry *e = elt; | |
| 57 | 57 | ||
| 58 | - | lo = 0; | |
| 59 | - | hi = table->length - 1; | |
| 60 | - | ||
| 61 | - | while (lo <= hi) { | |
| 62 | - | mid = (hi - lo) / 2 + lo; | |
| 63 | - | e = &table->table[mid]; | |
| 64 | - | if (addr < e->region_start) | |
| 65 | - | hi = mid - 1; | |
| 66 | - | else if (addr > e->region_end) | |
| 67 | - | lo = mid + 1; | |
| 68 | - | else | |
| 69 | - | return e; | |
| 70 | - | } | |
| 58 | + | if (addr < e->region_start) | |
| 59 | + | return -1; | |
| 60 | + | if (addr > e->region_end) | |
| 61 | + | return 1; | |
| 62 | + | return 0; | |
| 63 | + | } | |
| 71 | 64 | ||
| 72 | - | return NULL; | |
| 65 | + | static inline const struct unwind_table_entry * | |
| 66 | + | find_unwind_entry_in_table(const struct unwind_table *table, unsigned long addr) | |
| 67 | + | { | |
| 68 | + | return bsearch((void *)addr, table->table, table->length, | |
| 69 | + | sizeof(*table->table), cmp_unwind_entry); | |
| 73 | 70 | } | |
| 74 | 71 | ||
| 75 | 72 | static const struct unwind_table_entry * | |
modified arch/powerpc/kernel/iommu.c
| @@ -1076,7 +1076,7 @@ int iommu_tce_check_ioba(unsigned long page_shift, | |||
| 1076 | 1076 | if (ioba < offset) | |
| 1077 | 1077 | return -EINVAL; | |
| 1078 | 1078 | ||
| 1079 | - | if ((ioba + 1) > (offset + size)) | |
| 1079 | + | if ((ioba + npages < ioba) || (ioba - offset + npages > size)) | |
| 1080 | 1080 | return -EINVAL; | |
| 1081 | 1081 | ||
| 1082 | 1082 | return 0; | |
modified arch/powerpc/kernel/vdso/Makefile
| @@ -43,6 +43,7 @@ ccflags-y := -fno-common -fno-builtin -DBUILD_VDSO | |||
| 43 | 43 | ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN) | |
| 44 | 44 | ccflags-y += $(call cc-option, -fno-stack-protector) | |
| 45 | 45 | ccflags-y += -DDISABLE_BRANCH_PROFILING | |
| 46 | + | ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 46 | 47 | ccflags-y += -ffreestanding -fasynchronous-unwind-tables | |
| 47 | 48 | ccflags-remove-y := $(CC_FLAGS_FTRACE) | |
| 48 | 49 | ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) | |
modified arch/powerpc/kvm/book3s_hv.c
| @@ -3058,7 +3058,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) | |||
| 3058 | 3058 | ||
| 3059 | 3059 | init_waitqueue_head(&vcpu->arch.cpu_run); | |
| 3060 | 3060 | ||
| 3061 | - | mutex_lock(&kvm->lock); | |
| 3062 | 3061 | vcore = NULL; | |
| 3063 | 3062 | err = -EINVAL; | |
| 3064 | 3063 | if (cpu_has_feature(CPU_FTR_ARCH_300)) { | |
| @@ -3091,7 +3090,6 @@ static int kvmppc_core_vcpu_create_hv(struct kvm_vcpu *vcpu) | |||
| 3091 | 3090 | mutex_unlock(&kvm->arch.mmu_setup_lock); | |
| 3092 | 3091 | } | |
| 3093 | 3092 | } | |
| 3094 | - | mutex_unlock(&kvm->lock); | |
| 3095 | 3093 | ||
| 3096 | 3094 | if (!vcore) | |
| 3097 | 3095 | return err; | |
modified arch/powerpc/kvm/book3s_hv_nested.c
| @@ -1204,8 +1204,10 @@ static void kvmhv_emulate_tlbie_all_lpid(struct kvm_vcpu *vcpu, int ric) | |||
| 1204 | 1204 | ||
| 1205 | 1205 | spin_lock(&kvm->mmu_lock); | |
| 1206 | 1206 | idr_for_each_entry(&kvm->arch.kvm_nested_guest_idr, gp, lpid) { | |
| 1207 | + | ++gp->refcnt; | |
| 1207 | 1208 | spin_unlock(&kvm->mmu_lock); | |
| 1208 | 1209 | kvmhv_emulate_tlbie_lpid(vcpu, gp, ric); | |
| 1210 | + | kvmhv_put_nested(gp); | |
| 1209 | 1211 | spin_lock(&kvm->mmu_lock); | |
| 1210 | 1212 | } | |
| 1211 | 1213 | spin_unlock(&kvm->mmu_lock); | |
modified arch/powerpc/kvm/book3s_hv_uvmem.c
| @@ -779,8 +779,11 @@ static int kvmppc_svm_page_in(struct vm_area_struct *vma, | |||
| 779 | 779 | if (spage) { | |
| 780 | 780 | ret = uv_page_in(kvm->arch.lpid, pfn << page_shift, | |
| 781 | 781 | gpa, 0, page_shift); | |
| 782 | - | if (ret) | |
| 782 | + | if (ret) { | |
| 783 | + | unlock_page(dpage); | |
| 784 | + | put_page(dpage); | |
| 783 | 785 | goto out_finalize; | |
| 786 | + | } | |
| 784 | 787 | } | |
| 785 | 788 | } | |
| 786 | 789 | ||
modified arch/powerpc/net/bpf_jit_comp.c
| @@ -602,14 +602,18 @@ int arch_protect_bpf_trampoline(void *image, unsigned int size) | |||
| 602 | 602 | } | |
| 603 | 603 | ||
| 604 | 604 | static int invoke_bpf_prog(u32 *image, u32 *ro_image, struct codegen_context *ctx, | |
| 605 | - | struct bpf_tramp_node *n, int regs_off, int retval_off, | |
| 606 | - | int run_ctx_off, bool save_ret) | |
| 605 | + | struct bpf_tramp_image *im, struct bpf_tramp_node *n, | |
| 606 | + | int regs_off, int retval_off, int run_ctx_off, bool save_ret) | |
| 607 | 607 | { | |
| 608 | 608 | struct bpf_prog *p = n->link->prog; | |
| 609 | 609 | ppc_inst_t branch_insn; | |
| 610 | - | u32 jmp_idx; | |
| 610 | + | u32 jmp_idx, skip_idx; | |
| 611 | 611 | int ret = 0; | |
| 612 | 612 | ||
| 613 | + | /* nop, patched to skip this prog when it is detached */ | |
| 614 | + | skip_idx = ctx->idx; | |
| 615 | + | EMIT(PPC_RAW_NOP()); | |
| 616 | + | ||
| 613 | 617 | /* Save cookie */ | |
| 614 | 618 | if (IS_ENABLED(CONFIG_PPC64)) { | |
| 615 | 619 | PPC_LI64(_R3, n->cookie); | |
| @@ -679,13 +683,17 @@ static int invoke_bpf_prog(u32 *image, u32 *ro_image, struct codegen_context *ct | |||
| 679 | 683 | EMIT(PPC_RAW_ADDI(_R5, _R1, run_ctx_off)); | |
| 680 | 684 | ret = bpf_jit_emit_func_call_rel(image, ro_image, ctx, | |
| 681 | 685 | (unsigned long)bpf_trampoline_exit(p)); | |
| 686 | + | if (ret) | |
| 687 | + | return ret; | |
| 682 | 688 | ||
| 683 | - | return ret; | |
| 689 | + | if (ro_image) /* image is NULL for dummy pass */ | |
| 690 | + | bpf_tramp_image_add_skip(im, p, &ro_image[skip_idx], &ro_image[ctx->idx]); | |
| 691 | + | return 0; | |
| 684 | 692 | } | |
| 685 | 693 | ||
| 686 | 694 | static int invoke_bpf_mod_ret(u32 *image, u32 *ro_image, struct codegen_context *ctx, | |
| 687 | - | struct bpf_tramp_nodes *tn, int regs_off, int retval_off, | |
| 688 | - | int run_ctx_off, u32 *branches) | |
| 695 | + | struct bpf_tramp_image *im, struct bpf_tramp_nodes *tn, | |
| 696 | + | int regs_off, int retval_off, int run_ctx_off, u32 *branches) | |
| 689 | 697 | { | |
| 690 | 698 | int i; | |
| 691 | 699 | ||
| @@ -696,8 +704,8 @@ static int invoke_bpf_mod_ret(u32 *image, u32 *ro_image, struct codegen_context | |||
| 696 | 704 | EMIT(PPC_RAW_LI(_R3, 0)); | |
| 697 | 705 | EMIT(PPC_RAW_STL(_R3, _R1, retval_off)); | |
| 698 | 706 | for (i = 0; i < tn->nr_nodes; i++) { | |
| 699 | - | if (invoke_bpf_prog(image, ro_image, ctx, tn->nodes[i], regs_off, retval_off, | |
| 700 | - | run_ctx_off, true)) | |
| 707 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, tn->nodes[i], regs_off, | |
| 708 | + | retval_off, run_ctx_off, true)) | |
| 701 | 709 | return -EINVAL; | |
| 702 | 710 | ||
| 703 | 711 | /* | |
| @@ -1043,8 +1051,8 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1043 | 1051 | cookie_ctx_off--; | |
| 1044 | 1052 | } | |
| 1045 | 1053 | ||
| 1046 | - | if (invoke_bpf_prog(image, ro_image, ctx, fentry->nodes[i], regs_off, retval_off, | |
| 1047 | - | run_ctx_off, flags & BPF_TRAMP_F_RET_FENTRY_RET)) | |
| 1054 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, fentry->nodes[i], regs_off, | |
| 1055 | + | retval_off, run_ctx_off, flags & BPF_TRAMP_F_RET_FENTRY_RET)) | |
| 1048 | 1056 | return -EINVAL; | |
| 1049 | 1057 | } | |
| 1050 | 1058 | ||
| @@ -1053,7 +1061,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1053 | 1061 | if (!branches) | |
| 1054 | 1062 | return -ENOMEM; | |
| 1055 | 1063 | ||
| 1056 | - | if (invoke_bpf_mod_ret(image, ro_image, ctx, fmod_ret, regs_off, retval_off, | |
| 1064 | + | if (invoke_bpf_mod_ret(image, ro_image, ctx, im, fmod_ret, regs_off, retval_off, | |
| 1057 | 1065 | run_ctx_off, branches)) { | |
| 1058 | 1066 | ret = -EINVAL; | |
| 1059 | 1067 | goto cleanup; | |
| @@ -1090,11 +1098,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1090 | 1098 | /* Restore updated tail_call_cnt */ | |
| 1091 | 1099 | if (flags & BPF_TRAMP_F_TAIL_CALL_CTX) | |
| 1092 | 1100 | bpf_trampoline_restore_tail_call_cnt(image, ctx, bpf_frame_size, r4_off); | |
| 1093 | - | ||
| 1094 | - | /* Reserve space to patch branch instruction to skip fexit progs */ | |
| 1095 | - | if (ro_image) /* image is NULL for dummy pass */ | |
| 1096 | - | im->ip_after_call = &((u32 *)ro_image)[ctx->idx]; | |
| 1097 | - | EMIT(PPC_RAW_NOP()); | |
| 1098 | 1101 | } | |
| 1099 | 1102 | ||
| 1100 | 1103 | /* Update branches saved in invoke_bpf_mod_ret with address of do_fexit */ | |
| @@ -1123,16 +1126,14 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 1123 | 1126 | cookie_ctx_off--; | |
| 1124 | 1127 | } | |
| 1125 | 1128 | ||
| 1126 | - | if (invoke_bpf_prog(image, ro_image, ctx, fexit->nodes[i], regs_off, retval_off, | |
| 1127 | - | run_ctx_off, false)) { | |
| 1129 | + | if (invoke_bpf_prog(image, ro_image, ctx, im, fexit->nodes[i], regs_off, | |
| 1130 | + | retval_off, run_ctx_off, false)) { | |
| 1128 | 1131 | ret = -EINVAL; | |
| 1129 | 1132 | goto cleanup; | |
| 1130 | 1133 | } | |
| 1131 | 1134 | } | |
| 1132 | 1135 | ||
| 1133 | 1136 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 1134 | - | if (ro_image) /* image is NULL for dummy pass */ | |
| 1135 | - | im->ip_epilogue = &((u32 *)ro_image)[ctx->idx]; | |
| 1136 | 1137 | PPC_LI_ADDR(_R3, im); | |
| 1137 | 1138 | ret = bpf_jit_emit_func_call_rel(image, ro_image, ctx, | |
| 1138 | 1139 | (unsigned long)__bpf_tramp_exit); | |
| @@ -1192,7 +1193,7 @@ cleanup: | |||
| 1192 | 1193 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 1193 | 1194 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 1194 | 1195 | { | |
| 1195 | - | struct bpf_tramp_image im; | |
| 1196 | + | struct bpf_tramp_image im = {}; | |
| 1196 | 1197 | int ret; | |
| 1197 | 1198 | ||
| 1198 | 1199 | ret = __arch_prepare_bpf_trampoline(&im, NULL, NULL, NULL, m, flags, tnodes, func_addr); | |
| @@ -1320,7 +1321,7 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |||
| 1320 | 1321 | ||
| 1321 | 1322 | /* | |
| 1322 | 1323 | * If we are not poking at bpf prog entry, then we are simply patching in/out | |
| 1323 | - | * an unconditional branch instruction at im->ip_after_call | |
| 1324 | + | * an unconditional branch instruction in a trampoline image | |
| 1324 | 1325 | */ | |
| 1325 | 1326 | if (offset) { | |
| 1326 | 1327 | if (old_t == BPF_MOD_CALL || new_t == BPF_MOD_CALL) { | |
modified arch/powerpc/perf/imc-pmu.c
| @@ -1275,6 +1275,8 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1275 | 1275 | struct perf_event_header *header, | |
| 1276 | 1276 | struct perf_event *event) | |
| 1277 | 1277 | { | |
| 1278 | + | u16 misc = 0; | |
| 1279 | + | ||
| 1278 | 1280 | /* Sanity checks for a valid record */ | |
| 1279 | 1281 | if (be64_to_cpu(READ_ONCE(mem->tb1)) > *prev_tb) | |
| 1280 | 1282 | *prev_tb = be64_to_cpu(READ_ONCE(mem->tb1)); | |
| @@ -1289,23 +1291,19 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1289 | 1291 | data->ip = be64_to_cpu(READ_ONCE(mem->ip)); | |
| 1290 | 1292 | data->period = event->hw.last_period; | |
| 1291 | 1293 | ||
| 1292 | - | header->type = PERF_RECORD_SAMPLE; | |
| 1293 | - | header->size = sizeof(*header) + event->header_size; | |
| 1294 | - | header->misc = 0; | |
| 1295 | - | ||
| 1296 | 1294 | if (cpu_has_feature(CPU_FTR_ARCH_31)) { | |
| 1297 | 1295 | switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) { | |
| 1298 | 1296 | case 0:/* when MSR HV and PR not set in the trace-record */ | |
| 1299 | - | header->misc |= PERF_RECORD_MISC_GUEST_KERNEL; | |
| 1297 | + | misc |= PERF_RECORD_MISC_GUEST_KERNEL; | |
| 1300 | 1298 | break; | |
| 1301 | 1299 | case 1: /* MSR HV is 0 and PR is 1 */ | |
| 1302 | - | header->misc |= PERF_RECORD_MISC_GUEST_USER; | |
| 1300 | + | misc |= PERF_RECORD_MISC_GUEST_USER; | |
| 1303 | 1301 | break; | |
| 1304 | 1302 | case 2: /* MSR HV is 1 and PR is 0 */ | |
| 1305 | - | header->misc |= PERF_RECORD_MISC_KERNEL; | |
| 1303 | + | misc |= PERF_RECORD_MISC_KERNEL; | |
| 1306 | 1304 | break; | |
| 1307 | 1305 | case 3: /* MSR HV is 1 and PR is 1 */ | |
| 1308 | - | header->misc |= PERF_RECORD_MISC_USER; | |
| 1306 | + | misc |= PERF_RECORD_MISC_USER; | |
| 1309 | 1307 | break; | |
| 1310 | 1308 | default: | |
| 1311 | 1309 | pr_info("IMC: Unable to set the flag based on MSR bits\n"); | |
| @@ -1313,11 +1311,14 @@ static int trace_imc_prepare_sample(struct trace_imc_data *mem, | |||
| 1313 | 1311 | } | |
| 1314 | 1312 | } else { | |
| 1315 | 1313 | if (is_kernel_addr(data->ip)) | |
| 1316 | - | header->misc |= PERF_RECORD_MISC_KERNEL; | |
| 1314 | + | misc |= PERF_RECORD_MISC_KERNEL; | |
| 1317 | 1315 | else | |
| 1318 | - | header->misc |= PERF_RECORD_MISC_USER; | |
| 1316 | + | misc |= PERF_RECORD_MISC_USER; | |
| 1319 | 1317 | } | |
| 1320 | - | perf_event_header__init_id(header, data, event); | |
| 1318 | + | perf_event_header__init(header, data, | |
| 1319 | + | PERF_RECORD_SAMPLE, misc, | |
| 1320 | + | sizeof(*header) + event->header_size, | |
| 1321 | + | event); | |
| 1321 | 1322 | ||
| 1322 | 1323 | return 0; | |
| 1323 | 1324 | } | |
modified arch/riscv/Kconfig
| @@ -453,9 +453,10 @@ config SMP | |||
| 453 | 453 | config NR_CPUS | |
| 454 | 454 | int "Maximum number of CPUs (2-512)" | |
| 455 | 455 | depends on SMP | |
| 456 | - | range 2 512 if !RISCV_SBI_V01 | |
| 457 | - | range 2 32 if RISCV_SBI_V01 && 32BIT | |
| 456 | + | range 2 512 if !RISCV_SBI_V01 && 64BIT | |
| 457 | + | range 2 128 if !RISCV_SBI_V01 && 32BIT | |
| 458 | 458 | range 2 64 if RISCV_SBI_V01 && 64BIT | |
| 459 | + | range 2 32 if RISCV_SBI_V01 && 32BIT | |
| 459 | 460 | default "32" if 32BIT | |
| 460 | 461 | default "64" if RISCV_SBI_V01 && 64BIT | |
| 461 | 462 | default "256" if !RISCV_SBI_V01 && 64BIT | |
modified arch/riscv/Kconfig.errata
| @@ -46,7 +46,7 @@ config ERRATA_MIPS_P8700_PAUSE_OPCODE | |||
| 46 | 46 | ||
| 47 | 47 | config ERRATA_SIFIVE | |
| 48 | 48 | bool "SiFive errata" | |
| 49 | - | depends on RISCV_ALTERNATIVE | |
| 49 | + | depends on RISCV_ALTERNATIVE && 64BIT | |
| 50 | 50 | help | |
| 51 | 51 | All SiFive errata Kconfig depend on this Kconfig. Disabling | |
| 52 | 52 | this Kconfig will disable all SiFive errata. Please say "Y" | |
| @@ -96,6 +96,20 @@ config ERRATA_STARFIVE_JH7100 | |||
| 96 | 96 | Say "Y" if you want to support the BeagleV Starlight and/or | |
| 97 | 97 | StarFive VisionFive V1 boards. | |
| 98 | 98 | ||
| 99 | + | config ERRATA_SIFIVE_MAL_9092 | |
| 100 | + | bool "Apply SiFive HLV/HLVX/HSV fence errata" | |
| 101 | + | depends on ERRATA_SIFIVE && 64BIT | |
| 102 | + | default y | |
| 103 | + | help | |
| 104 | + | This will apply the SiFive MAL-9092 errata to add fence.rw | |
| 105 | + | instructions around all HLV/HLVX/HSV instructions. | |
| 106 | + | ||
| 107 | + | Note: HSTATUS.HU is cleared during KVM initialization. If future | |
| 108 | + | changes enable HSTATUS.HU to allow hypervisor instructions in | |
| 109 | + | U-mode, additional errata handling may be required. | |
| 110 | + | ||
| 111 | + | If you don't know what to do here, say "Y". | |
| 112 | + | ||
| 99 | 113 | config ERRATA_THEAD | |
| 100 | 114 | bool "T-HEAD errata" | |
| 101 | 115 | depends on RISCV_ALTERNATIVE | |
| @@ -146,6 +160,7 @@ config ERRATA_THEAD_PMU | |||
| 146 | 160 | config ERRATA_THEAD_GHOSTWRITE | |
| 147 | 161 | bool "Apply T-Head Ghostwrite errata" | |
| 148 | 162 | depends on ERRATA_THEAD && RISCV_ISA_XTHEADVECTOR | |
| 163 | + | select RISCV_ALTERNATIVE_EARLY | |
| 149 | 164 | default y | |
| 150 | 165 | help | |
| 151 | 166 | The T-Head C9xx cores have a vulnerability in the xtheadvector | |
modified arch/riscv/Kconfig.socs
| @@ -34,6 +34,7 @@ config ARCH_RENESAS | |||
| 34 | 34 | config ARCH_SIFIVE | |
| 35 | 35 | bool "SiFive SoCs" | |
| 36 | 36 | select ERRATA_SIFIVE | |
| 37 | + | depends on 64BIT | |
| 37 | 38 | help | |
| 38 | 39 | This enables support for SiFive SoC platform hardware. | |
| 39 | 40 | ||
modified arch/riscv/errata/sifive/errata.c
| @@ -51,6 +51,22 @@ static bool errata_cip_1200_check_func(unsigned long arch_id, unsigned long imp | |||
| 51 | 51 | return true; | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | + | static bool errata_mal_9092_check_func(unsigned long arch_id, unsigned long impid) | |
| 55 | + | { | |
| 56 | + | /* | |
| 57 | + | * Affected cores: | |
| 58 | + | * Architecture ID: 0x8000000000000109 | |
| 59 | + | * Implementation ID: 0x19251031, 0x19251217, 0x19260320 | |
| 60 | + | */ | |
| 61 | + | ||
| 62 | + | if (arch_id != 0x8000000000000109) | |
| 63 | + | return false; | |
| 64 | + | if (impid != 0x19251031 && impid != 0x19251217 && impid != 0x19260320) | |
| 65 | + | return false; | |
| 66 | + | ||
| 67 | + | return true; | |
| 68 | + | } | |
| 69 | + | ||
| 54 | 70 | static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { | |
| 55 | 71 | { | |
| 56 | 72 | .name = "cip-453", | |
| @@ -60,6 +76,10 @@ static struct errata_info_t errata_list[ERRATA_SIFIVE_NUMBER] = { | |||
| 60 | 76 | .name = "cip-1200", | |
| 61 | 77 | .check_func = errata_cip_1200_check_func | |
| 62 | 78 | }, | |
| 79 | + | { | |
| 80 | + | .name = "mal-9092", | |
| 81 | + | .check_func = errata_mal_9092_check_func | |
| 82 | + | }, | |
| 63 | 83 | }; | |
| 64 | 84 | ||
| 65 | 85 | static u32 __init_or_module sifive_errata_probe(unsigned long archid, | |
modified arch/riscv/include/asm/cpufeature.h
| @@ -40,6 +40,8 @@ extern u32 thead_vlenb_of; | |||
| 40 | 40 | ||
| 41 | 41 | void __init riscv_user_isa_enable(void); | |
| 42 | 42 | ||
| 43 | + | void riscv_clear_hypervisor_csr(void); | |
| 44 | + | ||
| 43 | 45 | #define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \ | |
| 44 | 46 | .name = #_name, \ | |
| 45 | 47 | .property = #_name, \ | |
modified arch/riscv/include/asm/csr.h
| @@ -188,12 +188,24 @@ | |||
| 188 | 188 | #define HGATP_MODE_SHIFT HGATP32_MODE_SHIFT | |
| 189 | 189 | #endif | |
| 190 | 190 | ||
| 191 | - | /* VSIP & HVIP relation */ | |
| 191 | + | /* | |
| 192 | + | * VSIP & HVIP relation | |
| 193 | + | * | |
| 194 | + | * The bit positions are same between VSIP and HVIP for interrupt | |
| 195 | + | * numbers 13-63, where there's a shift for the SSI, STI and SEI. | |
| 196 | + | */ | |
| 192 | 197 | #define VSIP_TO_HVIP_SHIFT (IRQ_VS_SOFT - IRQ_S_SOFT) | |
| 193 | - | #define VSIP_VALID_MASK ((_AC(1, UL) << IRQ_S_SOFT) | \ | |
| 198 | + | #define VSIP_BIAS_MASK ((_AC(1, UL) << IRQ_S_SOFT) | \ | |
| 194 | 199 | (_AC(1, UL) << IRQ_S_TIMER) | \ | |
| 195 | - | (_AC(1, UL) << IRQ_S_EXT) | \ | |
| 196 | - | (_AC(1, UL) << IRQ_PMU_OVF)) | |
| 200 | + | (_AC(1, UL) << IRQ_S_EXT)) | |
| 201 | + | #define VSIP_NO_BIAS_MASK (_AC(1, UL) << IRQ_PMU_OVF) | |
| 202 | + | #define VSIP_VALID_MASK (VSIP_BIAS_MASK | VSIP_NO_BIAS_MASK) | |
| 203 | + | #define vsip_to_hvip(_vsip) ((((_vsip) & VSIP_BIAS_MASK) << \ | |
| 204 | + | VSIP_TO_HVIP_SHIFT) | \ | |
| 205 | + | ((_vsip) & VSIP_NO_BIAS_MASK)) | |
| 206 | + | #define hvip_to_vsip(_hvip) ((((_hvip) >> VSIP_TO_HVIP_SHIFT) & \ | |
| 207 | + | VSIP_BIAS_MASK) | \ | |
| 208 | + | ((_hvip) & VSIP_NO_BIAS_MASK)) | |
| 197 | 209 | ||
| 198 | 210 | /* AIA CSR bits */ | |
| 199 | 211 | #define TOPI_IID_SHIFT 16 | |
modified arch/riscv/include/asm/errata_list_vendors.h
| @@ -11,7 +11,8 @@ | |||
| 11 | 11 | #ifdef CONFIG_ERRATA_SIFIVE | |
| 12 | 12 | #define ERRATA_SIFIVE_CIP_453 0 | |
| 13 | 13 | #define ERRATA_SIFIVE_CIP_1200 1 | |
| 14 | - | #define ERRATA_SIFIVE_NUMBER 2 | |
| 14 | + | #define ERRATA_SIFIVE_MAL_9092 2 | |
| 15 | + | #define ERRATA_SIFIVE_NUMBER 3 | |
| 15 | 16 | #endif | |
| 16 | 17 | ||
| 17 | 18 | #ifdef CONFIG_ERRATA_THEAD | |
modified arch/riscv/include/asm/futex.h
| @@ -40,6 +40,7 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) | |||
| 40 | 40 | ||
| 41 | 41 | if (!access_ok(uaddr, sizeof(u32))) | |
| 42 | 42 | return -EFAULT; | |
| 43 | + | uaddr = untagged_addr(uaddr); | |
| 43 | 44 | ||
| 44 | 45 | switch (op) { | |
| 45 | 46 | case FUTEX_OP_SET: | |
| @@ -82,6 +83,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, | |||
| 82 | 83 | ||
| 83 | 84 | if (!access_ok(uaddr, sizeof(u32))) | |
| 84 | 85 | return -EFAULT; | |
| 86 | + | uaddr = untagged_addr(uaddr); | |
| 85 | 87 | ||
| 86 | 88 | __enable_user_access(); | |
| 87 | 89 | __asm__ __volatile__ ( | |
modified arch/riscv/include/asm/insn-def.h
| @@ -192,18 +192,28 @@ | |||
| 192 | 192 | INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(49), \ | |
| 193 | 193 | __RD(0), RS1(gaddr), RS2(vmid)) | |
| 194 | 194 | ||
| 195 | + | #define ALT_SIFIVE_MAL_9092_FENCE \ | |
| 196 | + | ALTERNATIVE("nop", "fence rw, rw", SIFIVE_VENDOR_ID, \ | |
| 197 | + | ERRATA_SIFIVE_MAL_9092, CONFIG_ERRATA_SIFIVE_MAL_9092) | |
| 198 | + | ||
| 195 | 199 | #define HLVX_HU(dest, addr) \ | |
| 200 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 196 | 201 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(50), \ | |
| 197 | - | RD(dest), RS1(addr), __RS2(3)) | |
| 202 | + | RD(dest), RS1(addr), __RS2(3)) "\n" \ | |
| 203 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 198 | 204 | ||
| 199 | 205 | #define HLV_W(dest, addr) \ | |
| 206 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 200 | 207 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(52), \ | |
| 201 | - | RD(dest), RS1(addr), __RS2(0)) | |
| 208 | + | RD(dest), RS1(addr), __RS2(0)) "\n" \ | |
| 209 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 202 | 210 | ||
| 203 | 211 | #ifdef CONFIG_64BIT | |
| 204 | 212 | #define HLV_D(dest, addr) \ | |
| 213 | + | ALT_SIFIVE_MAL_9092_FENCE "\n" \ | |
| 205 | 214 | INSN_R(OPCODE_SYSTEM, FUNC3(4), FUNC7(54), \ | |
| 206 | - | RD(dest), RS1(addr), __RS2(0)) | |
| 215 | + | RD(dest), RS1(addr), __RS2(0)) "\n" \ | |
| 216 | + | ALT_SIFIVE_MAL_9092_FENCE | |
| 207 | 217 | #else | |
| 208 | 218 | #define HLV_D(dest, addr) \ | |
| 209 | 219 | __ASM_STR(.error "hlv.d requires 64-bit support") | |
modified arch/riscv/include/asm/scs.h
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | 5 | #ifdef __ASSEMBLER__ | |
| 6 | 6 | #include <asm/asm-offsets.h> | |
| 7 | + | #include <asm/csr.h> | |
| 7 | 8 | ||
| 8 | 9 | #ifdef CONFIG_SHADOW_CALL_STACK | |
| 9 | 10 | ||
| @@ -22,9 +23,17 @@ | |||
| 22 | 23 | REG_L gp, TASK_TI_SCS_SP(tp) | |
| 23 | 24 | .endm | |
| 24 | 25 | ||
| 25 | - | /* Load task_scs_sp(current) to gp, but only if tp has changed. */ | |
| 26 | - | .macro scs_load_current_if_task_changed prev | |
| 27 | - | beq \prev, tp, _skip_scs | |
| 26 | + | /* | |
| 27 | + | * Load task_scs_sp(current) to gp, but only when the trap came from U-mode. | |
| 28 | + | * The source privilege level is taken from the saved sstatus.SPP bit (written | |
| 29 | + | * by hardware on trap entry), not by comparing tp. tp is a user-writable | |
| 30 | + | * register, so gating the shadow call stack reload on it let a user task that | |
| 31 | + | * set tp == ¤t skip the reload and run the kernel with an attacker | |
| 32 | + | * controlled gp (the shadow call stack pointer). | |
| 33 | + | */ | |
| 34 | + | .macro scs_load_current_if_from_user status, tmp | |
| 35 | + | andi \tmp, \status, SR_SPP | |
| 36 | + | bnez \tmp, _skip_scs | |
| 28 | 37 | scs_load_current | |
| 29 | 38 | _skip_scs: | |
| 30 | 39 | .endm | |
| @@ -42,7 +51,7 @@ _skip_scs: | |||
| 42 | 51 | .endm | |
| 43 | 52 | .macro scs_load_current | |
| 44 | 53 | .endm | |
| 45 | - | .macro scs_load_current_if_task_changed prev | |
| 54 | + | .macro scs_load_current_if_from_user status, tmp | |
| 46 | 55 | .endm | |
| 47 | 56 | .macro scs_save_current | |
| 48 | 57 | .endm | |
modified arch/riscv/include/asm/vector.h
| @@ -137,8 +137,8 @@ static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest) | |||
| 137 | 137 | "csrr %0, " __stringify(CSR_VSTART) "\n\t" | |
| 138 | 138 | "csrr %1, " __stringify(CSR_VTYPE) "\n\t" | |
| 139 | 139 | "csrr %2, " __stringify(CSR_VL) "\n\t" | |
| 140 | - | : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), | |
| 141 | - | "=r" (dest->vcsr) : :); | |
| 140 | + | : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl) | |
| 141 | + | : :); | |
| 142 | 142 | ||
| 143 | 143 | if (has_xtheadvector()) { | |
| 144 | 144 | unsigned long status; | |
| @@ -230,7 +230,7 @@ static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to, | |||
| 230 | 230 | "add %1, %1, %0\n\t" | |
| 231 | 231 | "vse8.v v24, (%1)\n\t" | |
| 232 | 232 | ".option pop\n\t" | |
| 233 | - | : "=&r" (vl) : "r" (datap) : "memory"); | |
| 233 | + | : "=&r" (vl), "+r" (datap) : : "memory"); | |
| 234 | 234 | } | |
| 235 | 235 | riscv_v_disable(); | |
| 236 | 236 | } | |
| @@ -266,7 +266,7 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_ | |||
| 266 | 266 | "add %1, %1, %0\n\t" | |
| 267 | 267 | "vle8.v v24, (%1)\n\t" | |
| 268 | 268 | ".option pop\n\t" | |
| 269 | - | : "=&r" (vl) : "r" (datap) : "memory"); | |
| 269 | + | : "=&r" (vl), "+r" (datap) : : "memory"); | |
| 270 | 270 | } | |
| 271 | 271 | __vstate_csr_restore(restore_from); | |
| 272 | 272 | riscv_v_disable(); | |
modified arch/riscv/include/uapi/asm/vendor/mips.h
| @@ -1,3 +1,5 @@ | |||
| 1 | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ | |
| 2 | 2 | ||
| 3 | - | #define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL BIT(0) | |
| 3 | + | #include <linux/const.h> | |
| 4 | + | ||
| 5 | + | #define RISCV_HWPROBE_VENDOR_EXT_XMIPSEXECTL _BITULL(0) | |
modified arch/riscv/kernel/cpufeature.c
| @@ -1233,6 +1233,18 @@ void __init riscv_user_isa_enable(void) | |||
| 1233 | 1233 | pr_warn("Zicbop disabled as it is unavailable on some harts\n"); | |
| 1234 | 1234 | } | |
| 1235 | 1235 | ||
| 1236 | + | void riscv_clear_hypervisor_csr(void) | |
| 1237 | + | { | |
| 1238 | + | if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_H)) | |
| 1239 | + | return; | |
| 1240 | + | ||
| 1241 | + | /* | |
| 1242 | + | * Clear HSTATUS.HU to restrict hypervisor instructions to HS-mode. | |
| 1243 | + | * This prevents user-mode from executing HLV/HSV instructions. | |
| 1244 | + | */ | |
| 1245 | + | csr_clear(CSR_HSTATUS, HSTATUS_HU); | |
| 1246 | + | } | |
| 1247 | + | ||
| 1236 | 1248 | #ifdef CONFIG_RISCV_ALTERNATIVE | |
| 1237 | 1249 | /* | |
| 1238 | 1250 | * Alternative patch sites consider 48 bits when determining when to patch | |
modified arch/riscv/kernel/entry.S
| @@ -208,7 +208,7 @@ SYM_CODE_START(handle_exception) | |||
| 208 | 208 | load_global_pointer | |
| 209 | 209 | ||
| 210 | 210 | /* Load the kernel shadow call stack pointer if coming from userspace */ | |
| 211 | - | scs_load_current_if_task_changed s5 | |
| 211 | + | scs_load_current_if_from_user s1, s5 | |
| 212 | 212 | ||
| 213 | 213 | #ifdef CONFIG_RISCV_ISA_V_PREEMPTIVE | |
| 214 | 214 | move a0, sp | |
modified arch/riscv/kernel/patch.c
| @@ -48,7 +48,7 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap) | |||
| 48 | 48 | if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX)) | |
| 49 | 49 | return addr; | |
| 50 | 50 | phys = __pa_symbol(addr); | |
| 51 | - | } else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) { | |
| 51 | + | } else if (IS_ENABLED(CONFIG_EXECMEM)) { | |
| 52 | 52 | struct page *page = vmalloc_to_page(addr); | |
| 53 | 53 | ||
| 54 | 54 | BUG_ON(!page); | |
modified arch/riscv/kernel/ptrace.c
| @@ -230,6 +230,7 @@ static int riscv_vr_set(struct task_struct *target, | |||
| 230 | 230 | return -ENODATA; | |
| 231 | 231 | ||
| 232 | 232 | /* Copy rest of the vstate except datap */ | |
| 233 | + | memset(&ptrace_vstate, 0, sizeof(ptrace_vstate)); | |
| 233 | 234 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ptrace_vstate, 0, | |
| 234 | 235 | sizeof(struct __riscv_v_regset_state)); | |
| 235 | 236 | if (unlikely(ret)) | |
| @@ -299,6 +300,9 @@ static int riscv_cfi_get(struct task_struct *target, | |||
| 299 | 300 | struct user_cfi_state user_cfi; | |
| 300 | 301 | struct pt_regs *regs; | |
| 301 | 302 | ||
| 303 | + | if (!is_user_lpad_enabled() && !is_user_shstk_enabled()) | |
| 304 | + | return -EINVAL; | |
| 305 | + | ||
| 302 | 306 | memset(&user_cfi, 0, sizeof(user_cfi)); | |
| 303 | 307 | regs = task_pt_regs(target); | |
| 304 | 308 | ||
| @@ -337,8 +341,12 @@ static int riscv_cfi_set(struct task_struct *target, | |||
| 337 | 341 | struct user_cfi_state user_cfi; | |
| 338 | 342 | struct pt_regs *regs; | |
| 339 | 343 | ||
| 344 | + | if (!is_user_lpad_enabled() && !is_user_shstk_enabled()) | |
| 345 | + | return -EINVAL; | |
| 346 | + | ||
| 340 | 347 | regs = task_pt_regs(target); | |
| 341 | 348 | ||
| 349 | + | memset(&user_cfi, 0, sizeof(user_cfi)); | |
| 342 | 350 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &user_cfi, 0, -1); | |
| 343 | 351 | if (ret) | |
| 344 | 352 | return ret; | |
modified arch/riscv/kernel/setup.c
| @@ -366,6 +366,8 @@ void __init setup_arch(char **cmdline_p) | |||
| 366 | 366 | ||
| 367 | 367 | if (!IS_ENABLED(CONFIG_RISCV_ISA_ZBB) || !riscv_isa_extension_available(NULL, ZBB)) | |
| 368 | 368 | static_branch_disable(&efficient_ffs_key); | |
| 369 | + | ||
| 370 | + | riscv_clear_hypervisor_csr(); | |
| 369 | 371 | } | |
| 370 | 372 | ||
| 371 | 373 | bool arch_cpu_is_hotpluggable(int cpu) | |
modified arch/riscv/kernel/smpboot.c
| @@ -244,6 +244,8 @@ asmlinkage __visible void smp_callin(void) | |||
| 244 | 244 | ||
| 245 | 245 | numa_add_cpu(curr_cpuid); | |
| 246 | 246 | ||
| 247 | + | riscv_clear_hypervisor_csr(); | |
| 248 | + | ||
| 247 | 249 | pr_debug("CPU%u: Booted secondary hartid %lu\n", curr_cpuid, | |
| 248 | 250 | cpuid_to_hartid_map(curr_cpuid)); | |
| 249 | 251 | ||
modified arch/riscv/kernel/suspend.c
| @@ -43,6 +43,8 @@ void suspend_save_csrs(struct suspend_context *context) | |||
| 43 | 43 | ||
| 44 | 44 | void suspend_restore_csrs(struct suspend_context *context) | |
| 45 | 45 | { | |
| 46 | + | riscv_clear_hypervisor_csr(); | |
| 47 | + | ||
| 46 | 48 | csr_write(CSR_SCRATCH, 0); | |
| 47 | 49 | if (riscv_has_extension_unlikely(RISCV_ISA_EXT_XLINUXENVCFG)) | |
| 48 | 50 | csr_write(CSR_ENVCFG, context->envcfg); | |
modified arch/riscv/kernel/vdso/Makefile
| @@ -36,6 +36,7 @@ endif | |||
| 36 | 36 | ccflags-y := -fno-stack-protector | |
| 37 | 37 | ccflags-y += -DDISABLE_BRANCH_PROFILING | |
| 38 | 38 | ccflags-y += -fno-builtin | |
| 39 | + | ccflags-y += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 39 | 40 | ccflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) | |
| 40 | 41 | ccflags-y += $(CFI_FULL) | |
| 41 | 42 | asflags-y += $(KBUILD_BASE_ISA)$(CFI_MARCH) | |
modified arch/riscv/kvm/aia_device.c
| @@ -237,7 +237,7 @@ static int aia_init(struct kvm *kvm) | |||
| 237 | 237 | return -EBUSY; | |
| 238 | 238 | ||
| 239 | 239 | /* We might be in the middle of creating a VCPU? */ | |
| 240 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) | |
| 240 | + | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 241 | 241 | return -EBUSY; | |
| 242 | 242 | ||
| 243 | 243 | /* Number of sources should be less than or equals number of IDs */ | |
modified arch/riscv/kvm/aia_imsic.c
| @@ -965,9 +965,14 @@ int kvm_riscv_aia_imsic_rw_attr(struct kvm *kvm, unsigned long type, | |||
| 965 | 965 | if (!vcpu) | |
| 966 | 966 | return -ENODEV; | |
| 967 | 967 | ||
| 968 | + | if (mutex_lock_killable(&vcpu->mutex)) | |
| 969 | + | return -EINTR; | |
| 970 | + | ||
| 968 | 971 | imsic = vcpu->arch.aia_context.imsic_state; | |
| 969 | - | if (!imsic) | |
| 970 | - | return -ENODEV; | |
| 972 | + | if (!imsic) { | |
| 973 | + | rc = -ENODEV; | |
| 974 | + | goto out_unlock; | |
| 975 | + | } | |
| 971 | 976 | isel = KVM_DEV_RISCV_AIA_IMSIC_GET_ISEL(type); | |
| 972 | 977 | ||
| 973 | 978 | read_lock_irqsave(&imsic->vsfile_lock, flags); | |
| @@ -991,6 +996,8 @@ int kvm_riscv_aia_imsic_rw_attr(struct kvm *kvm, unsigned long type, | |||
| 991 | 996 | rc = imsic_vsfile_rw(vsfile_hgei, vsfile_cpu, imsic->nr_eix, | |
| 992 | 997 | isel, write, val); | |
| 993 | 998 | ||
| 999 | + | out_unlock: | |
| 1000 | + | mutex_unlock(&vcpu->mutex); | |
| 994 | 1001 | return rc; | |
| 995 | 1002 | } | |
| 996 | 1003 | ||
modified arch/riscv/kvm/mmu.c
| @@ -627,6 +627,7 @@ int kvm_riscv_mmu_map(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot, | |||
| 627 | 627 | int ret; | |
| 628 | 628 | kvm_pfn_t hfn; | |
| 629 | 629 | bool is_hugetlb; | |
| 630 | + | bool unused = false; | |
| 630 | 631 | bool writable; | |
| 631 | 632 | unsigned int vma_pageshift; | |
| 632 | 633 | gfn_t gfn = gpa >> PAGE_SHIFT; | |
| @@ -707,6 +708,8 @@ int kvm_riscv_mmu_map(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot, | |||
| 707 | 708 | vma_pageshift, current); | |
| 708 | 709 | return 0; | |
| 709 | 710 | } | |
| 711 | + | if (is_sigpending_pfn(hfn)) | |
| 712 | + | return -EINTR; | |
| 710 | 713 | if (is_error_noslot_pfn(hfn)) | |
| 711 | 714 | return -EFAULT; | |
| 712 | 715 | ||
| @@ -719,8 +722,10 @@ int kvm_riscv_mmu_map(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot, | |||
| 719 | 722 | ||
| 720 | 723 | write_lock(&kvm->mmu_lock); | |
| 721 | 724 | ||
| 722 | - | if (mmu_invalidate_retry(kvm, mmu_seq)) | |
| 725 | + | if (mmu_invalidate_retry(kvm, mmu_seq)) { | |
| 726 | + | unused = true; | |
| 723 | 727 | goto out_unlock; | |
| 728 | + | } | |
| 724 | 729 | ||
| 725 | 730 | /* | |
| 726 | 731 | * Check if we are backed by a THP and thus use block mapping if | |
| @@ -743,7 +748,8 @@ int kvm_riscv_mmu_map(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot, | |||
| 743 | 748 | kvm_err("Failed to map in G-stage\n"); | |
| 744 | 749 | ||
| 745 | 750 | out_unlock: | |
| 746 | - | kvm_release_faultin_page(kvm, page, ret && ret != -EEXIST, writable); | |
| 751 | + | kvm_release_faultin_page(kvm, page, | |
| 752 | + | unused || (ret && ret != -EEXIST), writable); | |
| 747 | 753 | write_unlock(&kvm->mmu_lock); | |
| 748 | 754 | return ret; | |
| 749 | 755 | } | |
modified arch/riscv/kvm/nacl.c
| @@ -42,12 +42,24 @@ again: | |||
| 42 | 42 | } | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | - | entp = shmem + SBI_NACL_SHMEM_HFENCE_ENTRY_CONFIG(i); | |
| 46 | - | *entp = cpu_to_lelong(control); | |
| 45 | + | /* | |
| 46 | + | * Per SBI v3.0 section 15.1.2, the Page_Number and Page_Count | |
| 47 | + | * words must be updated before the Config word with its Pending | |
| 48 | + | * bit set. WRITE_ONCE() stops the compiler from reordering the | |
| 49 | + | * stores and smp_wmb() makes the parameter words globally | |
| 50 | + | * visible to the SBI implementation (or NACL hardware) before | |
| 51 | + | * the Pending bit is set. | |
| 52 | + | */ | |
| 47 | 53 | entp = shmem + SBI_NACL_SHMEM_HFENCE_ENTRY_PNUM(i); | |
| 48 | - | *entp = cpu_to_lelong(page_num); | |
| 54 | + | WRITE_ONCE(*entp, cpu_to_lelong(page_num)); | |
| 49 | 55 | entp = shmem + SBI_NACL_SHMEM_HFENCE_ENTRY_PCOUNT(i); | |
| 50 | - | *entp = cpu_to_lelong(page_count); | |
| 56 | + | WRITE_ONCE(*entp, cpu_to_lelong(page_count)); | |
| 57 | + | ||
| 58 | + | /* Ensure the parameter words are visible before the Pending bit */ | |
| 59 | + | smp_wmb(); | |
| 60 | + | ||
| 61 | + | entp = shmem + SBI_NACL_SHMEM_HFENCE_ENTRY_CONFIG(i); | |
| 62 | + | WRITE_ONCE(*entp, cpu_to_lelong(control)); | |
| 51 | 63 | } | |
| 52 | 64 | ||
| 53 | 65 | int kvm_riscv_nacl_enable(void) | |
modified arch/riscv/kvm/vcpu.c
| @@ -491,8 +491,7 @@ bool kvm_riscv_vcpu_has_interrupts(struct kvm_vcpu *vcpu, u64 mask) | |||
| 491 | 491 | bool ret; | |
| 492 | 492 | ||
| 493 | 493 | raw_spin_lock_irqsave(&vcpu->arch.irqs_pending_lock, flags); | |
| 494 | - | ie = ((vcpu->arch.guest_csr.vsie & VSIP_VALID_MASK) | |
| 495 | - | << VSIP_TO_HVIP_SHIFT) & (unsigned long)mask; | |
| 494 | + | ie = vsip_to_hvip(vcpu->arch.guest_csr.vsie) & (unsigned long)mask; | |
| 496 | 495 | ie |= vcpu->arch.guest_csr.vsie & ~IRQ_LOCAL_MASK & | |
| 497 | 496 | (unsigned long)mask; | |
| 498 | 497 | ret = vcpu->arch.irqs_pending[0] & ie; | |
modified arch/riscv/kvm/vcpu_exit.c
| @@ -283,7 +283,7 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, | |||
| 283 | 283 | } | |
| 284 | 284 | ||
| 285 | 285 | /* Print details in-case of error */ | |
| 286 | - | if (ret < 0) { | |
| 286 | + | if (ret < 0 && ret != -EINTR) { | |
| 287 | 287 | kvm_err("VCPU exit error %d\n", ret); | |
| 288 | 288 | kvm_err("SEPC=0x%lx SSTATUS=0x%lx HSTATUS=0x%lx\n", | |
| 289 | 289 | vcpu->arch.guest_context.sepc, | |
modified arch/riscv/kvm/vcpu_onereg.c
| @@ -272,7 +272,7 @@ static int kvm_riscv_vcpu_general_get_csr(struct kvm_vcpu *vcpu, | |||
| 272 | 272 | ||
| 273 | 273 | if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) { | |
| 274 | 274 | kvm_riscv_vcpu_flush_interrupts(vcpu); | |
| 275 | - | *out_val = (csr->hvip >> VSIP_TO_HVIP_SHIFT) & VSIP_VALID_MASK; | |
| 275 | + | *out_val = hvip_to_vsip(csr->hvip); | |
| 276 | 276 | *out_val |= csr->hvip & ~IRQ_LOCAL_MASK; | |
| 277 | 277 | } else | |
| 278 | 278 | *out_val = ((unsigned long *)csr)[reg_num]; | |
| @@ -293,10 +293,8 @@ static int kvm_riscv_vcpu_general_set_csr(struct kvm_vcpu *vcpu, | |||
| 293 | 293 | ||
| 294 | 294 | reg_num = array_index_nospec(reg_num, regs_max); | |
| 295 | 295 | ||
| 296 | - | if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) { | |
| 297 | - | reg_val &= VSIP_VALID_MASK; | |
| 298 | - | reg_val <<= VSIP_TO_HVIP_SHIFT; | |
| 299 | - | } | |
| 296 | + | if (reg_num == KVM_REG_RISCV_CSR_REG(sip)) | |
| 297 | + | reg_val = vsip_to_hvip(reg_val); | |
| 300 | 298 | ||
| 301 | 299 | ((unsigned long *)csr)[reg_num] = reg_val; | |
| 302 | 300 | ||
modified arch/riscv/kvm/vcpu_pmu.c
| @@ -270,12 +270,13 @@ static int pmu_ctr_read(struct kvm_vcpu *vcpu, unsigned long cidx, | |||
| 270 | 270 | return -EINVAL; | |
| 271 | 271 | ||
| 272 | 272 | pmc->counter_val = kvpmu->fw_event[fevent_code].value; | |
| 273 | + | *out_val = pmc->counter_val; | |
| 273 | 274 | } else if (pmc->perf_event) { | |
| 274 | - | pmc->counter_val += perf_event_read_value(pmc->perf_event, &enabled, &running); | |
| 275 | + | *out_val = pmc->counter_val + | |
| 276 | + | perf_event_read_value(pmc->perf_event, &enabled, &running); | |
| 275 | 277 | } else { | |
| 276 | 278 | return -EINVAL; | |
| 277 | 279 | } | |
| 278 | - | *out_val = pmc->counter_val; | |
| 279 | 280 | ||
| 280 | 281 | return 0; | |
| 281 | 282 | } | |
| @@ -454,6 +455,14 @@ int kvm_riscv_vcpu_pmu_snapshot_set_shmem(struct kvm_vcpu *vcpu, unsigned long s | |||
| 454 | 455 | } | |
| 455 | 456 | } | |
| 456 | 457 | ||
| 458 | + | /* | |
| 459 | + | * Clear any previously installed snapshot area to avoid leaking | |
| 460 | + | * the old sdata and to keep sdata/snapshot_addr consistent if | |
| 461 | + | * the re-install fails below. | |
| 462 | + | */ | |
| 463 | + | if (kvpmu->snapshot_addr != INVALID_GPA) | |
| 464 | + | kvm_pmu_clear_snapshot_area(vcpu); | |
| 465 | + | ||
| 457 | 466 | kvpmu->sdata = kzalloc(snapshot_area_size, GFP_ATOMIC | __GFP_ACCOUNT); | |
| 458 | 467 | if (!kvpmu->sdata) { | |
| 459 | 468 | sbiret = SBI_ERR_FAILURE; | |
| @@ -645,7 +654,6 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, | |||
| 645 | 654 | { | |
| 646 | 655 | struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu); | |
| 647 | 656 | int i, pmc_index, sbiret = 0; | |
| 648 | - | u64 enabled, running; | |
| 649 | 657 | struct kvm_pmc *pmc; | |
| 650 | 658 | int fevent_code; | |
| 651 | 659 | bool snap_flag_set = flags & SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT; | |
| @@ -675,14 +683,19 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, | |||
| 675 | 683 | goto out; | |
| 676 | 684 | } | |
| 677 | 685 | ||
| 678 | - | if (!kvpmu->fw_event[fevent_code].started) | |
| 686 | + | if (!kvpmu->fw_event[fevent_code].started) { | |
| 679 | 687 | sbiret = SBI_ERR_ALREADY_STOPPED; | |
| 680 | - | ||
| 681 | - | kvpmu->fw_event[fevent_code].started = false; | |
| 688 | + | } else { | |
| 689 | + | kvpmu->fw_event[fevent_code].started = false; | |
| 690 | + | pmc->counter_val = kvpmu->fw_event[fevent_code].value; | |
| 691 | + | } | |
| 682 | 692 | } else if (pmc->perf_event) { | |
| 683 | 693 | if (pmc->started) { | |
| 684 | - | /* Stop counting the counter */ | |
| 685 | - | perf_event_disable(pmc->perf_event); | |
| 694 | + | /* | |
| 695 | + | * Stop the counter and fold the live count into counter_val. | |
| 696 | + | * Reset the event value to avoid redundant accumulation. | |
| 697 | + | */ | |
| 698 | + | pmc->counter_val += perf_event_pause(pmc->perf_event, true); | |
| 686 | 699 | pmc->started = false; | |
| 687 | 700 | } else { | |
| 688 | 701 | sbiret = SBI_ERR_ALREADY_STOPPED; | |
| @@ -696,11 +709,6 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, | |||
| 696 | 709 | } | |
| 697 | 710 | ||
| 698 | 711 | if (snap_flag_set && !sbiret) { | |
| 699 | - | if (pmc->cinfo.type == SBI_PMU_CTR_TYPE_FW) | |
| 700 | - | pmc->counter_val = kvpmu->fw_event[fevent_code].value; | |
| 701 | - | else if (pmc->perf_event) | |
| 702 | - | pmc->counter_val += perf_event_read_value(pmc->perf_event, | |
| 703 | - | &enabled, &running); | |
| 704 | 712 | /* | |
| 705 | 713 | * The counter and overflow indices in the snapshot region are w.r.to | |
| 706 | 714 | * cbase. Modify the set bit in the counter mask instead of the pmc_index | |
| @@ -727,9 +735,10 @@ int kvm_riscv_vcpu_pmu_ctr_stop(struct kvm_vcpu *vcpu, unsigned long ctr_base, | |||
| 727 | 735 | } | |
| 728 | 736 | } | |
| 729 | 737 | ||
| 730 | - | if (shmem_needs_update) | |
| 731 | - | kvm_vcpu_write_guest(vcpu, kvpmu->snapshot_addr, kvpmu->sdata, | |
| 732 | - | sizeof(struct riscv_pmu_snapshot_data)); | |
| 738 | + | if (shmem_needs_update && | |
| 739 | + | kvm_vcpu_write_guest(vcpu, kvpmu->snapshot_addr, kvpmu->sdata, | |
| 740 | + | sizeof(struct riscv_pmu_snapshot_data))) | |
| 741 | + | sbiret = SBI_ERR_FAILURE; | |
| 733 | 742 | ||
| 734 | 743 | out: | |
| 735 | 744 | retdata->err_val = sbiret; | |
modified arch/riscv/kvm/vcpu_sbi_hsm.c
| @@ -95,9 +95,9 @@ static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, | |||
| 95 | 95 | ret = kvm_sbi_hsm_vcpu_get_status(vcpu); | |
| 96 | 96 | if (ret >= 0) { | |
| 97 | 97 | retdata->out_val = ret; | |
| 98 | - | retdata->err_val = 0; | |
| 98 | + | ret = 0; | |
| 99 | 99 | } | |
| 100 | - | return 0; | |
| 100 | + | break; | |
| 101 | 101 | case SBI_EXT_HSM_HART_SUSPEND: | |
| 102 | 102 | switch (lower_32_bits(cp->a0)) { | |
| 103 | 103 | case SBI_HSM_SUSPEND_RET_DEFAULT: | |
modified arch/riscv/kvm/vcpu_timer.c
| @@ -61,10 +61,13 @@ static enum hrtimer_restart kvm_riscv_vcpu_hrtimer_expired(struct hrtimer *h) | |||
| 61 | 61 | ||
| 62 | 62 | static int kvm_riscv_vcpu_timer_cancel(struct kvm_vcpu_timer *t) | |
| 63 | 63 | { | |
| 64 | - | if (!t->init_done || !t->next_set) | |
| 64 | + | if (!t->init_done) | |
| 65 | 65 | return -EINVAL; | |
| 66 | 66 | ||
| 67 | 67 | hrtimer_cancel(&t->hrt); | |
| 68 | + | ||
| 69 | + | if (!t->next_set) | |
| 70 | + | return -EINVAL; | |
| 68 | 71 | t->next_set = false; | |
| 69 | 72 | ||
| 70 | 73 | return 0; | |
modified arch/riscv/lib/strnlen.S
| @@ -87,9 +87,25 @@ strnlen_zbb: | |||
| 87 | 87 | * Aligned boundary. Use the address of the last valid byte | |
| 88 | 88 | * (s + count - 1) to avoid loading a word past the count | |
| 89 | 89 | * boundary in the loop below. count == 0 is handled above. | |
| 90 | + | * | |
| 91 | + | * Saturate the boundary when s + count would wrap around (very | |
| 92 | + | * large counts, e.g. SIZE_MAX passed by FORTIFY strcat/strlcat | |
| 93 | + | * with a destination whose size is unknown at compile time). | |
| 94 | + | * Without this, the wrapped boundary lands before s and the | |
| 95 | + | * pre-loop guard below always exits, returning a truncated | |
| 96 | + | * length. | |
| 97 | + | * | |
| 98 | + | * Clamping the increment to ~s (== SIZE_MAX - s) keeps the | |
| 99 | + | * computation branchless and wrap-free: | |
| 100 | + | * | |
| 101 | + | * s + min(count - 1, ~s) == saturating_add(s, count - 1) | |
| 102 | + | * | |
| 103 | + | * Saturating makes the scan equivalent to strlen(). | |
| 90 | 104 | */ | |
| 91 | - | add t4, a0, a1 | |
| 92 | - | addi t4, t4, -1 | |
| 105 | + | addi t4, a1, -1 /* count - 1 */ | |
| 106 | + | not t1, a0 /* SIZE_MAX - s */ | |
| 107 | + | minu t4, t4, t1 /* clamp, so s + t4 can never wrap */ | |
| 108 | + | add t4, a0, t4 /* saturated s + count - 1 */ | |
| 93 | 109 | andi t4, t4, -SZREG | |
| 94 | 110 | ||
| 95 | 111 | /* Get the first word. */ | |
modified arch/riscv/mm/extable.c
| @@ -68,8 +68,8 @@ ex_handler_load_unaligned_zeropad(const struct exception_table_entry *ex, | |||
| 68 | 68 | ||
| 69 | 69 | addr = regs_get_gpr(regs, reg_addr * sizeof(unsigned long)); | |
| 70 | 70 | ||
| 71 | - | offset = addr & 0x7UL; | |
| 72 | - | addr &= ~0x7UL; | |
| 71 | + | offset = addr & (sizeof(data) - 1); | |
| 72 | + | addr &= ~(sizeof(data) - 1); | |
| 73 | 73 | ||
| 74 | 74 | data = *(unsigned long *)addr >> (offset * 8); | |
| 75 | 75 | ||
modified arch/riscv/net/bpf_jit_comp64.c
| @@ -822,6 +822,24 @@ static int gen_jump_or_nops(void *target, void *ip, u32 *insns, bool is_call) | |||
| 822 | 822 | return emit_jump_and_link(is_call ? RV_REG_T0 : RV_REG_ZERO, rvoff, false, &ctx); | |
| 823 | 823 | } | |
| 824 | 824 | ||
| 825 | + | int arch_bpf_trampoline_skip(void *nop, void *target) | |
| 826 | + | { | |
| 827 | + | u32 old_insn = rv_nop(); | |
| 828 | + | u32 new_insn = rv_jal(RV_REG_ZERO, (target - nop) >> 1); | |
| 829 | + | int ret; | |
| 830 | + | ||
| 831 | + | if (memcmp(nop, &old_insn, sizeof(old_insn))) | |
| 832 | + | return -EFAULT; | |
| 833 | + | ||
| 834 | + | cpus_read_lock(); | |
| 835 | + | mutex_lock(&text_mutex); | |
| 836 | + | ret = patch_text(nop, &new_insn, sizeof(new_insn)); | |
| 837 | + | mutex_unlock(&text_mutex); | |
| 838 | + | cpus_read_unlock(); | |
| 839 | + | ||
| 840 | + | return ret; | |
| 841 | + | } | |
| 842 | + | ||
| 825 | 843 | int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, | |
| 826 | 844 | enum bpf_text_poke_type new_t, void *old_addr, | |
| 827 | 845 | void *new_addr) | |
| @@ -904,12 +922,17 @@ static void emit_store_stack_imm64(u8 reg, int stack_off, u64 imm64, | |||
| 904 | 922 | emit_sd(RV_REG_FP, stack_off, reg, ctx); | |
| 905 | 923 | } | |
| 906 | 924 | ||
| 907 | - | static int invoke_bpf_prog(struct bpf_tramp_node *node, int args_off, int retval_off, | |
| 908 | - | int run_ctx_off, bool save_ret, struct rv_jit_context *ctx) | |
| 925 | + | static int invoke_bpf_prog(struct bpf_tramp_image *im, struct bpf_tramp_node *node, | |
| 926 | + | int args_off, int retval_off, int run_ctx_off, bool save_ret, | |
| 927 | + | struct rv_jit_context *ctx) | |
| 909 | 928 | { | |
| 910 | 929 | int ret, branch_off; | |
| 911 | 930 | struct bpf_prog *p = node->link->prog; | |
| 912 | 931 | int cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 932 | + | void *skip = ctx->ro_insns + ctx->ninsns; | |
| 933 | + | ||
| 934 | + | /* nop, patched to a jal over this prog when it is detached */ | |
| 935 | + | emit(rv_nop(), ctx); | |
| 913 | 936 | ||
| 914 | 937 | if (node->cookie) | |
| 915 | 938 | emit_store_stack_imm64(RV_REG_T1, -run_ctx_off + cookie_off, node->cookie, ctx); | |
| @@ -962,13 +985,17 @@ static int invoke_bpf_prog(struct bpf_tramp_node *node, int args_off, int retval | |||
| 962 | 985 | /* arg3: &run_ctx */ | |
| 963 | 986 | emit_addi(RV_REG_A2, RV_REG_FP, -run_ctx_off, ctx); | |
| 964 | 987 | ret = emit_call((const u64)bpf_trampoline_exit(p), true, ctx); | |
| 988 | + | if (ret) | |
| 989 | + | return ret; | |
| 965 | 990 | ||
| 966 | - | return ret; | |
| 991 | + | bpf_tramp_image_add_skip(im, p, skip, ctx->ro_insns + ctx->ninsns); | |
| 992 | + | return 0; | |
| 967 | 993 | } | |
| 968 | 994 | ||
| 969 | - | static int invoke_bpf(struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |
| 970 | - | int run_ctx_off, int func_meta_off, bool save_ret, u64 func_meta, | |
| 971 | - | int cookie_off, struct rv_jit_context *ctx) | |
| 995 | + | static int invoke_bpf(struct bpf_tramp_image *im, struct bpf_tramp_nodes *tn, | |
| 996 | + | int args_off, int retval_off, int run_ctx_off, int func_meta_off, | |
| 997 | + | bool save_ret, u64 func_meta, int cookie_off, | |
| 998 | + | struct rv_jit_context *ctx) | |
| 972 | 999 | { | |
| 973 | 1000 | int i, cur_cookie = (cookie_off - args_off) / 8; | |
| 974 | 1001 | ||
| @@ -981,8 +1008,8 @@ static int invoke_bpf(struct bpf_tramp_nodes *tn, int args_off, int retval_off, | |||
| 981 | 1008 | emit_store_stack_imm64(RV_REG_T1, -func_meta_off, meta, ctx); | |
| 982 | 1009 | cur_cookie--; | |
| 983 | 1010 | } | |
| 984 | - | err = invoke_bpf_prog(tn->nodes[i], args_off, retval_off, run_ctx_off, | |
| 985 | - | save_ret, ctx); | |
| 1011 | + | err = invoke_bpf_prog(im, tn->nodes[i], args_off, retval_off, | |
| 1012 | + | run_ctx_off, save_ret, ctx); | |
| 986 | 1013 | if (err) | |
| 987 | 1014 | return err; | |
| 988 | 1015 | } | |
| @@ -1170,7 +1197,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1170 | 1197 | } | |
| 1171 | 1198 | ||
| 1172 | 1199 | if (fentry->nr_nodes) { | |
| 1173 | - | ret = invoke_bpf(fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1200 | + | ret = invoke_bpf(im, fentry, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1174 | 1201 | flags & BPF_TRAMP_F_RET_FENTRY_RET, func_meta, cookie_off, ctx); | |
| 1175 | 1202 | if (ret) | |
| 1176 | 1203 | return ret; | |
| @@ -1184,7 +1211,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1184 | 1211 | /* cleanup to avoid garbage return value confusion */ | |
| 1185 | 1212 | emit_sd(RV_REG_FP, -retval_off, RV_REG_ZERO, ctx); | |
| 1186 | 1213 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 1187 | - | ret = invoke_bpf_prog(fmod_ret->nodes[i], args_off, retval_off, | |
| 1214 | + | ret = invoke_bpf_prog(im, fmod_ret->nodes[i], args_off, retval_off, | |
| 1188 | 1215 | run_ctx_off, true, ctx); | |
| 1189 | 1216 | if (ret) | |
| 1190 | 1217 | goto out; | |
| @@ -1211,10 +1238,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1211 | 1238 | emit_sd(RV_REG_FP, -tcc_off, RV_REG_TCC, ctx); | |
| 1212 | 1239 | emit_sd(RV_REG_FP, -retval_off, RV_REG_A0, ctx); | |
| 1213 | 1240 | emit_sd(RV_REG_FP, -(retval_off - 8), regmap[BPF_REG_0], ctx); | |
| 1214 | - | im->ip_after_call = ctx->ro_insns + ctx->ninsns; | |
| 1215 | - | /* 2 nops reserved for auipc+jalr pair */ | |
| 1216 | - | emit(rv_nop(), ctx); | |
| 1217 | - | emit(rv_nop(), ctx); | |
| 1218 | 1241 | } | |
| 1219 | 1242 | ||
| 1220 | 1243 | /* update branches saved in invoke_bpf_mod_ret with bnez */ | |
| @@ -1230,14 +1253,13 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 1230 | 1253 | emit_store_stack_imm64(RV_REG_T1, -func_meta_off, func_meta, ctx); | |
| 1231 | 1254 | ||
| 1232 | 1255 | if (fexit->nr_nodes) { | |
| 1233 | - | ret = invoke_bpf(fexit, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1256 | + | ret = invoke_bpf(im, fexit, args_off, retval_off, run_ctx_off, func_meta_off, | |
| 1234 | 1257 | false, func_meta, cookie_off, ctx); | |
| 1235 | 1258 | if (ret) | |
| 1236 | 1259 | goto out; | |
| 1237 | 1260 | } | |
| 1238 | 1261 | ||
| 1239 | 1262 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 1240 | - | im->ip_epilogue = ctx->ro_insns + ctx->ninsns; | |
| 1241 | 1263 | emit_imm(RV_REG_A0, ctx->insns ? (const s64)im : RV_MAX_COUNT_IMM, ctx); | |
| 1242 | 1264 | ret = emit_call((const u64)__bpf_tramp_exit, true, ctx); | |
| 1243 | 1265 | if (ret) | |
| @@ -1299,7 +1321,7 @@ out: | |||
| 1299 | 1321 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 1300 | 1322 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 1301 | 1323 | { | |
| 1302 | - | struct bpf_tramp_image im; | |
| 1324 | + | struct bpf_tramp_image im = {}; | |
| 1303 | 1325 | struct rv_jit_context ctx; | |
| 1304 | 1326 | int ret; | |
| 1305 | 1327 | ||
modified arch/s390/crypto/hmac_s390.c
| @@ -150,7 +150,10 @@ static int hash_data(const u8 *in, unsigned int inlen, | |||
| 150 | 150 | ||
| 151 | 151 | #undef PARAM_INIT | |
| 152 | 152 | ||
| 153 | - | cpacf_klmd(func, ¶m, in, inlen); | |
| 153 | + | if (final) | |
| 154 | + | cpacf_klmd(func, ¶m, in, inlen); | |
| 155 | + | else | |
| 156 | + | cpacf_kimd(func, ¶m, in, inlen); | |
| 154 | 157 | ||
| 155 | 158 | memcpy(digest, ¶m, digestsize); | |
| 156 | 159 | ||
modified arch/s390/include/asm/debug.h
| @@ -460,7 +460,11 @@ static int VNAME(var, active_entries)[EARLY_AREAS] __initdata | |||
| 460 | 460 | #define __REGISTER_STATIC_DEBUG_INFO(var, name, pages, areas, view) \ | |
| 461 | 461 | static int __init VNAME(var, reg)(void) \ | |
| 462 | 462 | { \ | |
| 463 | - | debug_register_static(&var, (pages), (areas)); \ | |
| 463 | + | int rc; \ | |
| 464 | + | \ | |
| 465 | + | rc = debug_register_static(&var, (pages), (areas)); \ | |
| 466 | + | if (rc) \ | |
| 467 | + | return rc; \ | |
| 464 | 468 | debug_register_view(&var, (view)); \ | |
| 465 | 469 | return 0; \ | |
| 466 | 470 | } \ | |
| @@ -493,7 +497,7 @@ static debug_info_t __refdata var = \ | |||
| 493 | 497 | static debug_info_t __used __section(".s390dbf_info") *VNAME(var, info) = &var; \ | |
| 494 | 498 | __REGISTER_STATIC_DEBUG_INFO(var, name, pages, nr_areas, view) | |
| 495 | 499 | ||
| 496 | - | void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas); | |
| 500 | + | int debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas); | |
| 497 | 501 | ||
| 498 | 502 | #endif /* MODULE */ | |
| 499 | 503 | ||
modified arch/s390/kernel/debug.c
| @@ -434,7 +434,8 @@ static debug_info_t *debug_info_copy(debug_info_t *in, int mode) | |||
| 434 | 434 | debug_info_free(rc); | |
| 435 | 435 | } while (1); | |
| 436 | 436 | ||
| 437 | - | if (mode == NO_AREAS) | |
| 437 | + | /* debug_register_static() failure leaves areas NULL, bounds intact */ | |
| 438 | + | if (mode == NO_AREAS || !in->areas) | |
| 438 | 439 | goto out; | |
| 439 | 440 | ||
| 440 | 441 | for (i = 0; i < in->nr_areas; i++) { | |
| @@ -823,6 +824,9 @@ ssize_t debug_dump(debug_info_t *id, struct debug_view *view, | |||
| 823 | 824 | file_private_info_t *p_info; | |
| 824 | 825 | size_t size, offset = 0; | |
| 825 | 826 | ||
| 827 | + | if (!id) | |
| 828 | + | return -EINVAL; | |
| 829 | + | ||
| 826 | 830 | /* Need space for '\0' byte */ | |
| 827 | 831 | if (buf_size < 1) | |
| 828 | 832 | return 0; | |
| @@ -950,8 +954,12 @@ EXPORT_SYMBOL(debug_register); | |||
| 950 | 954 | * | |
| 951 | 955 | * Note: This function is called automatically via an initcall generated by | |
| 952 | 956 | * DEFINE_STATIC_DEBUG_INFO. | |
| 957 | + | * | |
| 958 | + | * Return: | |
| 959 | + | * - 0 on success | |
| 960 | + | * - negative error code on failure | |
| 953 | 961 | */ | |
| 954 | - | void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |
| 962 | + | int debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |
| 955 | 963 | { | |
| 956 | 964 | unsigned long flags; | |
| 957 | 965 | debug_info_t *copy; | |
| @@ -959,7 +967,7 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 959 | 967 | if (!initialized) { | |
| 960 | 968 | pr_err("Tried to register debug feature %s too early\n", | |
| 961 | 969 | id->name); | |
| 962 | - | return; | |
| 970 | + | return -EINVAL; | |
| 963 | 971 | } | |
| 964 | 972 | ||
| 965 | 973 | debug_get_param(id->name, &id->level, &pages_per_area, false); | |
| @@ -975,7 +983,7 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 975 | 983 | id->active_entries = NULL; | |
| 976 | 984 | raw_spin_unlock_irqrestore(&id->lock, flags); | |
| 977 | 985 | ||
| 978 | - | return; | |
| 986 | + | return -ENOMEM; | |
| 979 | 987 | } | |
| 980 | 988 | ||
| 981 | 989 | /* Replace static trace area with dynamic copy. */ | |
| @@ -993,6 +1001,8 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas) | |||
| 993 | 1001 | mutex_lock(&debug_mutex); | |
| 994 | 1002 | _debug_register(id); | |
| 995 | 1003 | mutex_unlock(&debug_mutex); | |
| 1004 | + | ||
| 1005 | + | return 0; | |
| 996 | 1006 | } | |
| 997 | 1007 | ||
| 998 | 1008 | /* Remove debugfs entries. */ | |
modified arch/s390/kernel/uv.c
| @@ -825,7 +825,7 @@ static int find_secret_in_page(const u8 secret_id[UV_SECRET_ID_LEN], | |||
| 825 | 825 | { | |
| 826 | 826 | u16 i; | |
| 827 | 827 | ||
| 828 | - | for (i = 0; i < list->total_num_secrets; i++) { | |
| 828 | + | for (i = 0; i < list->num_secr_stored; i++) { | |
| 829 | 829 | if (memcmp(secret_id, list->secrets[i].id, UV_SECRET_ID_LEN) == 0) { | |
| 830 | 830 | *secret = list->secrets[i].hdr; | |
| 831 | 831 | return 0; | |
| @@ -846,11 +846,14 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN], | |||
| 846 | 846 | struct uv_secret_list *list, | |
| 847 | 847 | struct uv_secret_list_item_hdr *secret) | |
| 848 | 848 | { | |
| 849 | - | u16 start_idx = 0; | |
| 849 | + | u16 start_idx; | |
| 850 | 850 | u16 list_rc; | |
| 851 | 851 | int ret; | |
| 852 | 852 | ||
| 853 | + | list->next_secret_idx = 0; | |
| 854 | + | ||
| 853 | 855 | do { | |
| 856 | + | start_idx = list->next_secret_idx; | |
| 854 | 857 | uv_list_secrets(list, start_idx, &list_rc, NULL); | |
| 855 | 858 | if (list_rc != UVC_RC_EXECUTED && list_rc != UVC_RC_MORE_DATA) { | |
| 856 | 859 | if (list_rc == UVC_RC_INV_CMD) | |
| @@ -861,7 +864,6 @@ int uv_find_secret(const u8 secret_id[UV_SECRET_ID_LEN], | |||
| 861 | 864 | ret = find_secret_in_page(secret_id, list, secret); | |
| 862 | 865 | if (ret == 0) | |
| 863 | 866 | return ret; | |
| 864 | - | start_idx = list->next_secret_idx; | |
| 865 | 867 | } while (list_rc == UVC_RC_MORE_DATA && start_idx < list->next_secret_idx); | |
| 866 | 868 | ||
| 867 | 869 | return -ENOENT; | |
modified arch/s390/kernel/vdso/Makefile
| @@ -29,6 +29,7 @@ KBUILD_CFLAGS_VDSO := $(filter-out -munaligned-symbols,$(KBUILD_CFLAGS_VDSO)) | |||
| 29 | 29 | KBUILD_CFLAGS_VDSO := $(filter-out -fno-asynchronous-unwind-tables,$(KBUILD_CFLAGS_VDSO)) | |
| 30 | 30 | KBUILD_CFLAGS_VDSO += -fPIC -fno-common -fno-builtin -fasynchronous-unwind-tables | |
| 31 | 31 | KBUILD_CFLAGS_VDSO += -fno-stack-protector $(DISABLE_KSTACK_ERASE) | |
| 32 | + | KBUILD_CFLAGS_VDSO += $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 32 | 33 | ldflags-y := -shared -soname=linux-vdso.so.1 \ | |
| 33 | 34 | --hash-style=both --build-id=sha1 \ | |
| 34 | 35 | $(call ld-option, --eh-frame-hdr) -T | |
modified arch/s390/kvm/gmap/dat.c
| @@ -621,17 +621,20 @@ int dat_get_storage_key(union asce asce, gfn_t gfn, union skey *skey) | |||
| 621 | 621 | union pte *ptep; | |
| 622 | 622 | int rc; | |
| 623 | 623 | ||
| 624 | + | again: | |
| 624 | 625 | skey->skey = 0; | |
| 625 | 626 | rc = dat_entry_walk(NULL, gfn, asce, DAT_WALK_ANY, TABLE_TYPE_PAGE_TABLE, &crstep, &ptep); | |
| 626 | 627 | if (rc) | |
| 627 | 628 | return rc; | |
| 628 | 629 | ||
| 629 | 630 | if (!ptep) { | |
| 630 | - | union crste crste; | |
| 631 | + | union crste crste = READ_ONCE(*crstep); | |
| 631 | 632 | ||
| 632 | - | crste = READ_ONCE(*crstep); | |
| 633 | - | if (!crste.h.fc || !crste.s.fc1.pr) | |
| 633 | + | if (!crste_leaf(crste) && !crste.h.i) | |
| 634 | + | goto again; | |
| 635 | + | if (!crste.s.fc1.pr) | |
| 634 | 636 | return 0; | |
| 637 | + | ||
| 635 | 638 | skey->skey = page_get_storage_key(large_crste_to_phys(crste, gfn)); | |
| 636 | 639 | return 0; | |
| 637 | 640 | } | |
| @@ -662,13 +665,20 @@ int dat_set_storage_key(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t gf | |||
| 662 | 665 | union pte *ptep; | |
| 663 | 666 | int rc; | |
| 664 | 667 | ||
| 668 | + | again: | |
| 665 | 669 | rc = dat_entry_walk(mc, gfn, asce, DAT_WALK_LEAF_ALLOC, TABLE_TYPE_PAGE_TABLE, | |
| 666 | 670 | &crstep, &ptep); | |
| 667 | 671 | if (rc) | |
| 668 | 672 | return rc; | |
| 669 | 673 | ||
| 670 | 674 | if (!ptep) { | |
| 671 | - | page_set_storage_key(large_crste_to_phys(*crstep, gfn), skey.skey, !nq); | |
| 675 | + | union crste crste = READ_ONCE(*crstep); | |
| 676 | + | ||
| 677 | + | /* A large page has been split concurrently, try again */ | |
| 678 | + | if (!crste_leaf(crste)) | |
| 679 | + | goto again; | |
| 680 | + | ||
| 681 | + | page_set_storage_key(large_crste_to_phys(crste, gfn), skey.skey, !nq); | |
| 672 | 682 | return 0; | |
| 673 | 683 | } | |
| 674 | 684 | ||
| @@ -718,15 +728,22 @@ int dat_cond_set_storage_key(struct kvm_s390_mmu_cache *mmc, union asce asce, gf | |||
| 718 | 728 | union pte *ptep; | |
| 719 | 729 | int rc; | |
| 720 | 730 | ||
| 731 | + | again: | |
| 721 | 732 | rc = dat_entry_walk(mmc, gfn, asce, DAT_WALK_LEAF_ALLOC, TABLE_TYPE_PAGE_TABLE, | |
| 722 | 733 | &crstep, &ptep); | |
| 723 | 734 | if (rc) | |
| 724 | 735 | return rc; | |
| 725 | 736 | ||
| 726 | 737 | if (!ptep) { | |
| 738 | + | union crste crste = READ_ONCE(*crstep); | |
| 739 | + | ||
| 740 | + | /* A large page has been split concurrently, try again */ | |
| 741 | + | if (!crste_leaf(crste)) | |
| 742 | + | goto again; | |
| 727 | 743 | if (!oldkey) | |
| 728 | 744 | oldkey = &prev; | |
| 729 | - | return page_cond_set_storage_key(large_crste_to_phys(*crstep, gfn), skey, oldkey, | |
| 745 | + | ||
| 746 | + | return page_cond_set_storage_key(large_crste_to_phys(crste, gfn), skey, oldkey, | |
| 730 | 747 | nq, mr, mc); | |
| 731 | 748 | } | |
| 732 | 749 | ||
| @@ -768,7 +785,7 @@ int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey) | |||
| 768 | 785 | int rc; | |
| 769 | 786 | ||
| 770 | 787 | skey->skey = 0; | |
| 771 | - | ||
| 788 | + | again: | |
| 772 | 789 | rc = dat_entry_walk(NULL, gfn, asce, DAT_WALK_ANY, TABLE_TYPE_PAGE_TABLE, &crstep, &ptep); | |
| 773 | 790 | if (rc) | |
| 774 | 791 | return rc; | |
| @@ -776,9 +793,12 @@ int dat_reset_reference_bit(union asce asce, gfn_t gfn, union skey *skey) | |||
| 776 | 793 | if (!ptep) { | |
| 777 | 794 | union crste crste = READ_ONCE(*crstep); | |
| 778 | 795 | ||
| 779 | - | if (!crste.h.fc || !crste.s.fc1.pr) | |
| 796 | + | /* A large page has been split concurrently, try again */ | |
| 797 | + | if (!crste_leaf(crste) && !crste.h.i) | |
| 798 | + | goto again; | |
| 799 | + | if (!crste.s.fc1.pr) | |
| 780 | 800 | return 0; | |
| 781 | - | skey->skey = page_reset_referenced(large_crste_to_phys(*crstep, gfn)) << 1; | |
| 801 | + | skey->skey = page_reset_referenced(large_crste_to_phys(crste, gfn)) << 1; | |
| 782 | 802 | return 0; | |
| 783 | 803 | } | |
| 784 | 804 | old = pgste_get_lock(ptep); | |
| @@ -846,19 +866,12 @@ long dat_reset_skeys(union asce asce, gfn_t start) | |||
| 846 | 866 | } | |
| 847 | 867 | #endif /* KVM_S390_MANAGES_S390_GUEST */ | |
| 848 | 868 | ||
| 849 | - | struct slot_priv { | |
| 850 | - | unsigned long token; | |
| 851 | - | struct kvm_s390_mmu_cache *mc; | |
| 852 | - | }; | |
| 853 | - | ||
| 854 | 869 | static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_walk *walk) | |
| 855 | 870 | { | |
| 856 | - | struct slot_priv *p = walk->priv; | |
| 857 | - | union crste dummy = { .val = p->token }; | |
| 858 | 871 | union pte new_pte, pte = READ_ONCE(*ptep); | |
| 859 | 872 | union pgste pgste; | |
| 860 | 873 | ||
| 861 | - | new_pte = _PTE_TOK(dummy.tok.type, dummy.tok.par); | |
| 874 | + | new_pte = walk->priv ? _PTE_EMPTY : _PTE_TOK(_DAT_TOKEN_PIC, PGM_ADDRESSING); | |
| 862 | 875 | ||
| 863 | 876 | /* Table entry already in the desired state. */ | |
| 864 | 877 | if (pte.val == new_pte.val) | |
| @@ -875,10 +888,9 @@ static long _dat_slot_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_wal | |||
| 875 | 888 | static long _dat_slot_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk) | |
| 876 | 889 | { | |
| 877 | 890 | union crste new_crste, crste = READ_ONCE(*crstep); | |
| 878 | - | struct slot_priv *p = walk->priv; | |
| 891 | + | struct kvm_s390_mmu_cache *mc = walk->priv; | |
| 879 | 892 | ||
| 880 | - | new_crste.val = p->token; | |
| 881 | - | new_crste.h.tt = crste.h.tt; | |
| 893 | + | new_crste = mc ? _CRSTE_EMPTY(crste.h.tt) : _CRSTE_HOLE(crste.h.tt); | |
| 882 | 894 | ||
| 883 | 895 | /* Table entry already in the desired state. */ | |
| 884 | 896 | if (crste.val == new_crste.val) | |
| @@ -902,7 +914,10 @@ static long _dat_slot_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct d | |||
| 902 | 914 | if (!crste.h.fc && !crste.h.i) | |
| 903 | 915 | return 0; | |
| 904 | 916 | /* Split (install a lower level table), and handle things there. */ | |
| 905 | - | return dat_split_crste(p->mc, crstep, gfn, walk->asce, false); | |
| 917 | + | if (mc) | |
| 918 | + | return dat_split_crste(mc, crstep, gfn, walk->asce, false); | |
| 919 | + | /* A large page should never cross memslots boundaries */ | |
| 920 | + | return -EINVAL; | |
| 906 | 921 | } | |
| 907 | 922 | ||
| 908 | 923 | static const struct dat_walk_ops dat_slot_ops = { | |
| @@ -910,16 +925,10 @@ static const struct dat_walk_ops dat_slot_ops = { | |||
| 910 | 925 | .crste_ops = { _dat_slot_crste, _dat_slot_crste, _dat_slot_crste, _dat_slot_crste, }, | |
| 911 | 926 | }; | |
| 912 | 927 | ||
| 913 | - | int dat_set_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, gfn_t end, | |
| 914 | - | u16 type, u16 param) | |
| 928 | + | int dat_set_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, gfn_t end) | |
| 915 | 929 | { | |
| 916 | - | struct slot_priv priv = { | |
| 917 | - | .token = _CRSTE_TOK(0, type, param).val, | |
| 918 | - | .mc = mc, | |
| 919 | - | }; | |
| 920 | - | ||
| 921 | 930 | return _dat_walk_gfn_range(start, end, asce, &dat_slot_ops, | |
| 922 | - | DAT_WALK_IGN_HOLES | DAT_WALK_ANY, &priv); | |
| 931 | + | DAT_WALK_IGN_HOLES | DAT_WALK_ANY, mc); | |
| 923 | 932 | } | |
| 924 | 933 | ||
| 925 | 934 | static void pgste_set_unlock_multiple(union pte *first, int n, union pgste *pgstes) | |
modified arch/s390/kvm/gmap/dat.h
| @@ -547,8 +547,7 @@ long dat_reset_skeys(union asce asce, gfn_t start); | |||
| 547 | 547 | unsigned long dat_get_ptval(struct page_table *table, struct ptval_param param); | |
| 548 | 548 | void dat_set_ptval(struct page_table *table, struct ptval_param param, unsigned long val); | |
| 549 | 549 | ||
| 550 | - | int dat_set_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, gfn_t end, | |
| 551 | - | u16 type, u16 param); | |
| 550 | + | int dat_set_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, gfn_t end); | |
| 552 | 551 | ||
| 553 | 552 | #if KVM_S390_MANAGES_S390_GUEST | |
| 554 | 553 | int dat_set_prefix_notif_bit(union asce asce, gfn_t gfn); | |
| @@ -973,16 +972,15 @@ static inline int get_level(union crste *crstep, union pte *ptep) | |||
| 973 | 972 | return ptep ? TABLE_TYPE_PAGE_TABLE : crstep->h.tt; | |
| 974 | 973 | } | |
| 975 | 974 | ||
| 976 | - | static inline int dat_delete_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, | |
| 977 | - | unsigned long npages) | |
| 975 | + | static inline int dat_delete_slot(union asce asce, gfn_t start, unsigned long npages) | |
| 978 | 976 | { | |
| 979 | - | return dat_set_slot(mc, asce, start, start + npages, _DAT_TOKEN_PIC, PGM_ADDRESSING); | |
| 977 | + | return dat_set_slot(NULL, asce, start, start + npages); | |
| 980 | 978 | } | |
| 981 | 979 | ||
| 982 | 980 | static inline int dat_create_slot(struct kvm_s390_mmu_cache *mc, union asce asce, gfn_t start, | |
| 983 | 981 | unsigned long npages) | |
| 984 | 982 | { | |
| 985 | - | return dat_set_slot(mc, asce, start, start + npages, _DAT_TOKEN_NONE, 0); | |
| 983 | + | return dat_set_slot(mc, asce, start, start + npages); | |
| 986 | 984 | } | |
| 987 | 985 | ||
| 988 | 986 | static inline bool crste_is_ucas(union crste crste) | |
modified arch/s390/kvm/gmap/gmap.c
| @@ -994,11 +994,13 @@ static long _destroy_pages_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct da | |||
| 994 | 994 | static long _destroy_pages_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk) | |
| 995 | 995 | { | |
| 996 | 996 | phys_addr_t origin, cur, end; | |
| 997 | + | union crste crste; | |
| 997 | 998 | ||
| 998 | - | if (!crstep->h.fc || !crstep->s.fc1.pr) | |
| 999 | + | crste = READ_ONCE(*crstep); | |
| 1000 | + | if (!crste.h.fc || !crste.s.fc1.pr) | |
| 999 | 1001 | return 0; | |
| 1000 | 1002 | ||
| 1001 | - | origin = crste_origin_large(*crstep); | |
| 1003 | + | origin = crste_origin_large(crste); | |
| 1002 | 1004 | cur = ((max(gfn, walk->start) - gfn) << PAGE_SHIFT) + origin; | |
| 1003 | 1005 | end = ((min(next, walk->end) - gfn) << PAGE_SHIFT) + origin; | |
| 1004 | 1006 | for ( ; cur < end; cur += PAGE_SIZE) | |
modified arch/s390/kvm/gmap/kvm_mmu.c
| @@ -47,6 +47,9 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm, | |||
| 47 | 47 | struct kvm_memory_slot *new, | |
| 48 | 48 | enum kvm_mr_change change) | |
| 49 | 49 | { | |
| 50 | + | struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL; | |
| 51 | + | int rc = 0; | |
| 52 | + | ||
| 50 | 53 | if (kvm_is_ucontrol(kvm) && new && new->id < KVM_USER_MEM_SLOTS) | |
| 51 | 54 | return -EINVAL; | |
| 52 | 55 | ||
| @@ -61,6 +64,10 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm, | |||
| 61 | 64 | * and munmap() stuff in this slot after doing this call at any | |
| 62 | 65 | * time. | |
| 63 | 66 | */ | |
| 67 | + | if (change != KVM_MR_MOVE && change != KVM_MR_CREATE) { | |
| 68 | + | WARN(1, "Unknown KVM MR CHANGE: %d\n", change); | |
| 69 | + | return -EINVAL; | |
| 70 | + | } | |
| 64 | 71 | if (new->userspace_addr & ~PAGE_MASK) | |
| 65 | 72 | return -EINVAL; | |
| 66 | 73 | if ((new->base_gfn + new->npages) * PAGE_SIZE > kvm->arch.mem_limit) | |
| @@ -69,65 +76,41 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm, | |||
| 69 | 76 | return -EINVAL; | |
| 70 | 77 | } | |
| 71 | 78 | ||
| 72 | - | if (!kvm_s390_is_migration_mode(kvm)) | |
| 73 | - | return 0; | |
| 74 | - | ||
| 75 | - | /* | |
| 76 | - | * Turn off migration mode when: | |
| 77 | - | * - userspace creates a new memslot with dirty logging off, | |
| 78 | - | * - userspace modifies an existing memslot (MOVE or FLAGS_ONLY) and | |
| 79 | - | * dirty logging is turned off. | |
| 80 | - | * Migration mode expects dirty page logging being enabled to store | |
| 81 | - | * its dirty bitmap. | |
| 82 | - | */ | |
| 83 | - | if (change != KVM_MR_DELETE && | |
| 84 | - | !(new->flags & KVM_MEM_LOG_DIRTY_PAGES)) | |
| 85 | - | WARN(kvm_s390_vm_stop_migration(kvm), | |
| 86 | - | "Failed to stop migration mode"); | |
| 87 | - | ||
| 88 | - | return 0; | |
| 89 | - | } | |
| 90 | - | ||
| 91 | - | void s390_kvm_mmu_commit_memory_region(struct kvm *kvm, | |
| 92 | - | struct kvm_memory_slot *old, | |
| 93 | - | const struct kvm_memory_slot *new, | |
| 94 | - | enum kvm_mr_change change) | |
| 95 | - | { | |
| 96 | - | struct kvm_s390_mmu_cache *mc __free(kvm_s390_mmu_cache) = NULL; | |
| 97 | - | int rc = 0; | |
| 98 | - | ||
| 99 | - | guard(mutex)(&kvm->slots_arch_lock); | |
| 79 | + | if (kvm->arch.migration_mode) { | |
| 80 | + | /* | |
| 81 | + | * Turn off migration mode when: | |
| 82 | + | * - userspace creates a new memslot with dirty logging off, | |
| 83 | + | * - userspace modifies an existing memslot (MOVE or FLAGS_ONLY) | |
| 84 | + | * and dirty logging is turned off. | |
| 85 | + | * Migration mode expects dirty page logging being enabled to | |
| 86 | + | * store its dirty bitmap. | |
| 87 | + | */ | |
| 88 | + | if (change != KVM_MR_DELETE && | |
| 89 | + | !(new->flags & KVM_MEM_LOG_DIRTY_PAGES)) | |
| 90 | + | WARN(kvm_s390_vm_stop_migration(kvm), | |
| 91 | + | "Failed to stop migration mode"); | |
| 92 | + | } | |
| 100 | 93 | ||
| 101 | 94 | if (change == KVM_MR_FLAGS_ONLY) | |
| 102 | - | return; | |
| 103 | - | ||
| 104 | - | mc = kvm_s390_new_mmu_cache(); | |
| 105 | - | if (!mc) { | |
| 106 | - | rc = -ENOMEM; | |
| 107 | - | goto out; | |
| 95 | + | return 0; | |
| 96 | + | if (change != KVM_MR_DELETE) { | |
| 97 | + | /* Enough capacity to add a new memslot */ | |
| 98 | + | mc = kvm_s390_new_mmu_cache(); | |
| 99 | + | if (!mc) | |
| 100 | + | return -ENOMEM; | |
| 108 | 101 | } | |
| 109 | - | ||
| 110 | 102 | scoped_guard(write_lock, &kvm->mmu_lock) { | |
| 111 | 103 | kvm_s390_update_cmma_dirty(kvm, old); | |
| 112 | - | switch (change) { | |
| 113 | - | case KVM_MR_DELETE: | |
| 114 | - | rc = dat_delete_slot(mc, kvm->arch.gmap->asce, old->base_gfn, old->npages); | |
| 115 | - | break; | |
| 116 | - | case KVM_MR_MOVE: | |
| 117 | - | rc = dat_delete_slot(mc, kvm->arch.gmap->asce, old->base_gfn, old->npages); | |
| 118 | - | if (rc) | |
| 119 | - | break; | |
| 120 | - | fallthrough; | |
| 121 | - | case KVM_MR_CREATE: | |
| 104 | + | if (change == KVM_MR_DELETE || change == KVM_MR_MOVE) | |
| 105 | + | rc = dat_delete_slot(kvm->arch.gmap->asce, old->base_gfn, old->npages); | |
| 106 | + | if (!rc && (change == KVM_MR_MOVE || change == KVM_MR_CREATE)) | |
| 122 | 107 | rc = dat_create_slot(mc, kvm->arch.gmap->asce, new->base_gfn, new->npages); | |
| 123 | - | break; | |
| 124 | - | case KVM_MR_FLAGS_ONLY: | |
| 125 | - | break; | |
| 126 | - | default: | |
| 127 | - | WARN(1, "Unknown KVM MR CHANGE: %d\n", change); | |
| 128 | - | } | |
| 129 | 108 | } | |
| 130 | - | out: | |
| 131 | - | if (rc) | |
| 132 | - | pr_warn("failed to commit memory region\n"); | |
| 109 | + | /* | |
| 110 | + | * Can only be triggered if dat_{create,delete}_slot() found an | |
| 111 | + | * internal inconsistency or if the mmu cache ran out of memory; | |
| 112 | + | * both should be impossible. | |
| 113 | + | */ | |
| 114 | + | KVM_BUG_ON(rc, kvm); | |
| 115 | + | return rc; | |
| 133 | 116 | } | |
modified arch/s390/kvm/gmap/kvm_mmu.h
| @@ -10,9 +10,5 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm, | |||
| 10 | 10 | const struct kvm_memory_slot *old, | |
| 11 | 11 | struct kvm_memory_slot *new, | |
| 12 | 12 | enum kvm_mr_change change); | |
| 13 | - | void s390_kvm_mmu_commit_memory_region(struct kvm *kvm, | |
| 14 | - | struct kvm_memory_slot *old, | |
| 15 | - | const struct kvm_memory_slot *new, | |
| 16 | - | enum kvm_mr_change change); | |
| 17 | 13 | ||
| 18 | 14 | #endif /* ARCH_KVM_GMAP_KVM_MMU_H */ | |
modified arch/s390/kvm/s390/gaccess.c
| @@ -1589,12 +1589,25 @@ static inline int ___gaccess_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg | |||
| 1589 | 1589 | parent = READ_ONCE(sg->parent); | |
| 1590 | 1590 | if (!parent) | |
| 1591 | 1591 | return -EAGAIN; | |
| 1592 | + | retry: | |
| 1592 | 1593 | scoped_guard(spinlock, &parent->children_lock) { | |
| 1593 | 1594 | if (READ_ONCE(sg->parent) != parent) | |
| 1594 | 1595 | return -EAGAIN; | |
| 1595 | 1596 | sg->invalidated = false; | |
| 1596 | 1597 | rc = _gaccess_do_shadow(vcpu->arch.mc, sg, saddr, walk); | |
| 1597 | 1598 | } | |
| 1599 | + | if (rc == -ENOENT) { | |
| 1600 | + | struct kvm_memory_slot *slot; | |
| 1601 | + | struct guest_fault *entries; | |
| 1602 | + | ||
| 1603 | + | entries = get_entries(walk); | |
| 1604 | + | slot = kvm_vcpu_gfn_to_memslot(vcpu, entries[LEVEL_MEM].gfn); | |
| 1605 | + | if (!slot) | |
| 1606 | + | return PGM_ADDRESSING; | |
| 1607 | + | rc = gmap_link(vcpu->arch.mc, parent, entries + LEVEL_MEM, slot); | |
| 1608 | + | if (!rc) | |
| 1609 | + | goto retry; | |
| 1610 | + | } | |
| 1598 | 1611 | if (!rc) | |
| 1599 | 1612 | kvm_s390_release_faultin_array(vcpu->kvm, walk->raw_entries, false); | |
| 1600 | 1613 | return rc; | |
modified arch/s390/kvm/s390/interrupt.c
| @@ -2984,61 +2984,58 @@ static int adapter_indicators_set(struct kvm *kvm, | |||
| 2984 | 2984 | struct s390_io_adapter *adapter, | |
| 2985 | 2985 | struct kvm_s390_adapter_int *adapter_int) | |
| 2986 | 2986 | { | |
| 2987 | - | unsigned long bit; | |
| 2988 | - | int summary_set, idx; | |
| 2989 | 2987 | struct s390_map_info *ind_info, *summary_info; | |
| 2990 | - | void *map; | |
| 2991 | 2988 | struct page *ind_page, *summary_page; | |
| 2992 | - | unsigned long flags; | |
| 2989 | + | unsigned long bit; | |
| 2990 | + | int summary_set; | |
| 2991 | + | void *map; | |
| 2993 | 2992 | ||
| 2994 | 2993 | ind_page = NULL; | |
| 2995 | 2994 | ||
| 2996 | - | spin_lock_irqsave(&adapter->maps_lock, flags); | |
| 2997 | - | ind_info = get_map_info(adapter, adapter_int->ind_addr); | |
| 2995 | + | scoped_guard(spinlock_irqsave, &adapter->maps_lock) { | |
| 2996 | + | ind_info = get_map_info(adapter, adapter_int->ind_addr); | |
| 2997 | + | if (ind_info) { | |
| 2998 | + | map = page_address(ind_info->page); | |
| 2999 | + | bit = get_ind_bit(ind_info->addr, adapter_int->ind_offset, adapter->swap); | |
| 3000 | + | set_bit(bit, map); | |
| 3001 | + | } | |
| 3002 | + | } | |
| 2998 | 3003 | if (!ind_info) { | |
| 2999 | - | spin_unlock_irqrestore(&adapter->maps_lock, flags); | |
| 3000 | 3004 | ind_page = pin_map_page(kvm, adapter_int->ind_addr, 0); | |
| 3001 | 3005 | if (!ind_page) | |
| 3002 | 3006 | return -1; | |
| 3003 | - | idx = srcu_read_lock(&kvm->srcu); | |
| 3004 | 3007 | map = page_address(ind_page); | |
| 3005 | 3008 | bit = get_ind_bit(adapter_int->ind_addr, | |
| 3006 | 3009 | adapter_int->ind_offset, adapter->swap); | |
| 3007 | 3010 | set_bit(bit, map); | |
| 3008 | - | mark_page_dirty(kvm, adapter_int->ind_gaddr >> PAGE_SHIFT); | |
| 3009 | 3011 | set_page_dirty_lock(ind_page); | |
| 3010 | - | srcu_read_unlock(&kvm->srcu, idx); | |
| 3011 | 3012 | unpin_user_page(ind_page); | |
| 3012 | - | } else { | |
| 3013 | - | map = page_address(ind_info->page); | |
| 3014 | - | bit = get_ind_bit(ind_info->addr, adapter_int->ind_offset, adapter->swap); | |
| 3015 | - | set_bit(bit, map); | |
| 3016 | - | spin_unlock_irqrestore(&adapter->maps_lock, flags); | |
| 3017 | 3013 | } | |
| 3014 | + | scoped_guard(srcu, &kvm->srcu) | |
| 3015 | + | mark_page_dirty(kvm, gpa_to_gfn(adapter_int->ind_gaddr)); | |
| 3018 | 3016 | ||
| 3019 | - | spin_lock_irqsave(&adapter->maps_lock, flags); | |
| 3020 | - | summary_info = get_map_info(adapter, adapter_int->summary_addr); | |
| 3017 | + | scoped_guard(spinlock_irqsave, &adapter->maps_lock) { | |
| 3018 | + | summary_info = get_map_info(adapter, adapter_int->summary_addr); | |
| 3019 | + | if (summary_info) { | |
| 3020 | + | map = page_address(summary_info->page); | |
| 3021 | + | bit = get_ind_bit(summary_info->addr, adapter_int->summary_offset, | |
| 3022 | + | adapter->swap); | |
| 3023 | + | summary_set = test_and_set_bit(bit, map); | |
| 3024 | + | } | |
| 3025 | + | } | |
| 3021 | 3026 | if (!summary_info) { | |
| 3022 | - | spin_unlock_irqrestore(&adapter->maps_lock, flags); | |
| 3023 | 3027 | summary_page = pin_map_page(kvm, adapter_int->summary_addr, 0); | |
| 3024 | 3028 | if (!summary_page) | |
| 3025 | 3029 | return -1; | |
| 3026 | - | idx = srcu_read_lock(&kvm->srcu); | |
| 3027 | 3030 | map = page_address(summary_page); | |
| 3028 | 3031 | bit = get_ind_bit(adapter_int->summary_addr, | |
| 3029 | 3032 | adapter_int->summary_offset, adapter->swap); | |
| 3030 | 3033 | summary_set = test_and_set_bit(bit, map); | |
| 3031 | - | mark_page_dirty(kvm, adapter_int->summary_gaddr >> PAGE_SHIFT); | |
| 3032 | 3034 | set_page_dirty_lock(summary_page); | |
| 3033 | - | srcu_read_unlock(&kvm->srcu, idx); | |
| 3034 | 3035 | unpin_user_page(summary_page); | |
| 3035 | - | } else { | |
| 3036 | - | map = page_address(summary_info->page); | |
| 3037 | - | bit = get_ind_bit(summary_info->addr, adapter_int->summary_offset, | |
| 3038 | - | adapter->swap); | |
| 3039 | - | summary_set = test_and_set_bit(bit, map); | |
| 3040 | - | spin_unlock_irqrestore(&adapter->maps_lock, flags); | |
| 3041 | 3036 | } | |
| 3037 | + | scoped_guard(srcu, &kvm->srcu) | |
| 3038 | + | mark_page_dirty(kvm, gpa_to_gfn(adapter_int->summary_gaddr)); | |
| 3042 | 3039 | ||
| 3043 | 3040 | return summary_set ? 0 : 1; | |
| 3044 | 3041 | } | |
| @@ -3048,26 +3045,29 @@ static int adapter_indicators_set_fast(struct kvm *kvm, | |||
| 3048 | 3045 | struct kvm_s390_adapter_int *adapter_int, | |
| 3049 | 3046 | int setbit) | |
| 3050 | 3047 | { | |
| 3048 | + | struct s390_map_info *ind_info, *summary_info; | |
| 3051 | 3049 | unsigned long bit; | |
| 3052 | 3050 | int summary_set; | |
| 3053 | - | struct s390_map_info *ind_info, *summary_info; | |
| 3054 | 3051 | void *map; | |
| 3055 | 3052 | ||
| 3056 | - | spin_lock(&adapter->maps_lock); | |
| 3053 | + | guard(srcu)(&kvm->srcu); | |
| 3054 | + | guard(spinlock)(&adapter->maps_lock); | |
| 3055 | + | ||
| 3057 | 3056 | ind_info = get_map_info(adapter, adapter_int->ind_addr); | |
| 3058 | - | if (!ind_info) { | |
| 3059 | - | spin_unlock(&adapter->maps_lock); | |
| 3057 | + | if (!ind_info) | |
| 3060 | 3058 | return -EWOULDBLOCK; | |
| 3061 | - | } | |
| 3059 | + | ||
| 3062 | 3060 | map = page_address(ind_info->page); | |
| 3063 | 3061 | bit = get_ind_bit(ind_info->addr, adapter_int->ind_offset, adapter->swap); | |
| 3064 | - | if (setbit) | |
| 3062 | + | if (setbit) { | |
| 3065 | 3063 | set_bit(bit, map); | |
| 3064 | + | mark_page_dirty(kvm, gpa_to_gfn(adapter_int->ind_gaddr)); | |
| 3065 | + | } | |
| 3066 | + | ||
| 3066 | 3067 | summary_info = get_map_info(adapter, adapter_int->summary_addr); | |
| 3067 | - | if (!summary_info) { | |
| 3068 | - | spin_unlock(&adapter->maps_lock); | |
| 3068 | + | if (!summary_info) | |
| 3069 | 3069 | return -EWOULDBLOCK; | |
| 3070 | - | } | |
| 3070 | + | ||
| 3071 | 3071 | map = page_address(summary_info->page); | |
| 3072 | 3072 | bit = get_ind_bit(summary_info->addr, adapter_int->summary_offset, | |
| 3073 | 3073 | adapter->swap); | |
| @@ -3077,7 +3077,8 @@ static int adapter_indicators_set_fast(struct kvm *kvm, | |||
| 3077 | 3077 | summary_set = test_and_set_bit(bit, map); | |
| 3078 | 3078 | else | |
| 3079 | 3079 | summary_set = test_and_clear_bit(bit, map); | |
| 3080 | - | spin_unlock(&adapter->maps_lock); | |
| 3080 | + | mark_page_dirty(kvm, gpa_to_gfn(adapter_int->summary_gaddr)); | |
| 3081 | + | ||
| 3081 | 3082 | return summary_set ? 0 : 1; | |
| 3082 | 3083 | } | |
| 3083 | 3084 | ||
| @@ -3228,9 +3229,9 @@ int kvm_s390_set_irq_state(struct kvm_vcpu *vcpu, void __user *irqstate, int len | |||
| 3228 | 3229 | break; | |
| 3229 | 3230 | } | |
| 3230 | 3231 | } | |
| 3231 | - | ||
| 3232 | 3232 | if (storestatus) { | |
| 3233 | - | n = kvm_s390_store_status_unloaded(vcpu, KVM_S390_STORE_STATUS_NOADDR); | |
| 3233 | + | scoped_guard(srcu, &vcpu->kvm->srcu) | |
| 3234 | + | n = kvm_s390_store_status_unloaded(vcpu, KVM_S390_STORE_STATUS_NOADDR); | |
| 3234 | 3235 | return r ? r : n; | |
| 3235 | 3236 | } | |
| 3236 | 3237 | ||
modified arch/s390/kvm/s390/s390.c
| @@ -3579,12 +3579,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) | |||
| 3579 | 3579 | ||
| 3580 | 3580 | void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) | |
| 3581 | 3581 | { | |
| 3582 | - | mutex_lock(&vcpu->kvm->lock); | |
| 3583 | 3582 | preempt_disable(); | |
| 3584 | 3583 | vcpu->arch.sie_block->epoch = vcpu->kvm->arch.epoch; | |
| 3585 | 3584 | vcpu->arch.sie_block->epdx = vcpu->kvm->arch.epdx; | |
| 3586 | 3585 | preempt_enable(); | |
| 3587 | - | mutex_unlock(&vcpu->kvm->lock); | |
| 3586 | + | ||
| 3588 | 3587 | if (!kvm_is_ucontrol(vcpu->kvm)) { | |
| 3589 | 3588 | vcpu->arch.gmap = vcpu->kvm->arch.gmap; | |
| 3590 | 3589 | sca_add_vcpu(vcpu); | |
| @@ -3757,13 +3756,11 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu) | |||
| 3757 | 3756 | ||
| 3758 | 3757 | kvm_s390_vcpu_pci_setup(vcpu); | |
| 3759 | 3758 | ||
| 3760 | - | mutex_lock(&vcpu->kvm->lock); | |
| 3761 | 3759 | if (kvm_s390_pv_is_protected(vcpu->kvm)) { | |
| 3762 | 3760 | rc = kvm_s390_pv_create_cpu(vcpu, &uvrc, &uvrrc); | |
| 3763 | 3761 | if (rc) | |
| 3764 | 3762 | kvm_s390_vcpu_unsetup_cmma(vcpu); | |
| 3765 | 3763 | } | |
| 3766 | - | mutex_unlock(&vcpu->kvm->lock); | |
| 3767 | 3764 | ||
| 3768 | 3765 | return rc; | |
| 3769 | 3766 | } | |
| @@ -5766,7 +5763,7 @@ static long cmma_d_count_pte(union pte *ptep, gfn_t gfn, gfn_t next, struct dat_ | |||
| 5766 | 5763 | return 0; | |
| 5767 | 5764 | } | |
| 5768 | 5765 | ||
| 5769 | - | void kvm_s390_update_cmma_dirty(struct kvm *kvm, struct kvm_memory_slot *old) | |
| 5766 | + | void kvm_s390_update_cmma_dirty(struct kvm *kvm, const struct kvm_memory_slot *old) | |
| 5770 | 5767 | { | |
| 5771 | 5768 | const struct dat_walk_ops ops = { .pte_entry = cmma_d_count_pte, }; | |
| 5772 | 5769 | ||
| @@ -5781,7 +5778,6 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, struct kvm_memory_slot *old, | |||
| 5781 | 5778 | const struct kvm_memory_slot *new, | |
| 5782 | 5779 | enum kvm_mr_change change) | |
| 5783 | 5780 | { | |
| 5784 | - | s390_kvm_mmu_commit_memory_region(kvm, old, new, change); | |
| 5785 | 5781 | } | |
| 5786 | 5782 | ||
| 5787 | 5783 | /** | |
modified arch/s390/kvm/s390/s390.h
| @@ -472,7 +472,7 @@ int __kvm_s390_mprotect_many(struct gmap *gmap, gpa_t gpa, u8 npages, unsigned i | |||
| 472 | 472 | unsigned long bits); | |
| 473 | 473 | ||
| 474 | 474 | bool kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu); | |
| 475 | - | void kvm_s390_update_cmma_dirty(struct kvm *kvm, struct kvm_memory_slot *old); | |
| 475 | + | void kvm_s390_update_cmma_dirty(struct kvm *kvm, const struct kvm_memory_slot *old); | |
| 476 | 476 | int kvm_s390_vm_stop_migration(struct kvm *kvm); | |
| 477 | 477 | ||
| 478 | 478 | ||
modified arch/s390/net/bpf_jit_comp.c
| @@ -2566,6 +2566,8 @@ struct bpf_tramp_jit { | |||
| 2566 | 2566 | int r14_off; /* Offset of saved %r14, has to be at the | |
| 2567 | 2567 | * bottom */ | |
| 2568 | 2568 | int do_fexit; /* do_fexit: label */ | |
| 2569 | + | int skip[BPF_MAX_TRAMP_LINKS]; /* skip: labels after each prog */ | |
| 2570 | + | int nr_progs; | |
| 2569 | 2571 | }; | |
| 2570 | 2572 | ||
| 2571 | 2573 | static void load_imm64(struct bpf_jit *jit, int dst_reg, u64 val) | |
| @@ -2584,6 +2586,7 @@ static void emit_store_stack_imm64(struct bpf_jit *jit, int tmp_reg, int stack_o | |||
| 2584 | 2586 | } | |
| 2585 | 2587 | ||
| 2586 | 2588 | static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |
| 2589 | + | struct bpf_tramp_image *im, | |
| 2587 | 2590 | const struct btf_func_model *m, | |
| 2588 | 2591 | struct bpf_tramp_node *node, bool save_ret) | |
| 2589 | 2592 | { | |
| @@ -2591,8 +2594,20 @@ static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |||
| 2591 | 2594 | int cookie_off = tjit->run_ctx_off + | |
| 2592 | 2595 | offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 2593 | 2596 | struct bpf_prog *p = node->link->prog; | |
| 2597 | + | void *skip = jit->prg_buf + jit->prg; | |
| 2598 | + | int idx = tjit->nr_progs++; | |
| 2594 | 2599 | int patch; | |
| 2595 | 2600 | ||
| 2601 | + | if (idx >= ARRAY_SIZE(tjit->skip)) | |
| 2602 | + | return -E2BIG; | |
| 2603 | + | ||
| 2604 | + | /* | |
| 2605 | + | * nop, patched to skip this prog when it is detached | |
| 2606 | + | */ | |
| 2607 | + | ||
| 2608 | + | /* brcl 0,skip */ | |
| 2609 | + | EMIT6_PCREL_RILC(0xc0040000, 0, tjit->skip[idx]); | |
| 2610 | + | ||
| 2596 | 2611 | /* | |
| 2597 | 2612 | * run_ctx.cookie = node->cookie; | |
| 2598 | 2613 | */ | |
| @@ -2652,10 +2667,15 @@ static int invoke_bpf_prog(struct bpf_tramp_jit *tjit, | |||
| 2652 | 2667 | /* brasl %r14,__bpf_prog_exit */ | |
| 2653 | 2668 | EMIT6_PCREL_RILB_PTR(0xc0050000, REG_14, bpf_trampoline_exit(p)); | |
| 2654 | 2669 | ||
| 2670 | + | /* skip: */ | |
| 2671 | + | tjit->skip[idx] = jit->prg; | |
| 2672 | + | bpf_tramp_image_add_skip(im, p, skip, jit->prg_buf + jit->prg); | |
| 2673 | + | ||
| 2655 | 2674 | return 0; | |
| 2656 | 2675 | } | |
| 2657 | 2676 | ||
| 2658 | 2677 | static int invoke_bpf(struct bpf_tramp_jit *tjit, | |
| 2678 | + | struct bpf_tramp_image *im, | |
| 2659 | 2679 | const struct btf_func_model *m, | |
| 2660 | 2680 | struct bpf_tramp_nodes *tn, bool save_ret, | |
| 2661 | 2681 | u64 func_meta, int cookie_off) | |
| @@ -2670,7 +2690,7 @@ static int invoke_bpf(struct bpf_tramp_jit *tjit, | |||
| 2670 | 2690 | emit_store_stack_imm64(jit, REG_0, tjit->func_meta_off, meta); | |
| 2671 | 2691 | cur_cookie--; | |
| 2672 | 2692 | } | |
| 2673 | - | if (invoke_bpf_prog(tjit, m, tn->nodes[i], save_ret)) | |
| 2693 | + | if (invoke_bpf_prog(tjit, im, m, tn->nodes[i], save_ret)) | |
| 2674 | 2694 | return -EINVAL; | |
| 2675 | 2695 | } | |
| 2676 | 2696 | ||
| @@ -2712,6 +2732,11 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2712 | 2732 | u64 func_meta; | |
| 2713 | 2733 | int i, j; | |
| 2714 | 2734 | ||
| 2735 | + | /* The skip labels are taken from the previous pass. */ | |
| 2736 | + | tjit->nr_progs = 0; | |
| 2737 | + | if (im) | |
| 2738 | + | im->nr_skips = 0; | |
| 2739 | + | ||
| 2715 | 2740 | /* Support as many stack arguments as "mvc" instruction can handle. */ | |
| 2716 | 2741 | nr_reg_args = min_t(int, m->nr_args, MAX_NR_REG_ARGS); | |
| 2717 | 2742 | nr_stack_args = m->nr_args - nr_reg_args; | |
| @@ -2875,7 +2900,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2875 | 2900 | emit_store_stack_imm64(jit, REG_0, tjit->retval_off, 0); | |
| 2876 | 2901 | } | |
| 2877 | 2902 | ||
| 2878 | - | if (invoke_bpf(tjit, m, fentry, flags & BPF_TRAMP_F_RET_FENTRY_RET, | |
| 2903 | + | if (invoke_bpf(tjit, im, m, fentry, flags & BPF_TRAMP_F_RET_FENTRY_RET, | |
| 2879 | 2904 | func_meta, cookie_off)) | |
| 2880 | 2905 | return -EINVAL; | |
| 2881 | 2906 | ||
| @@ -2889,7 +2914,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2889 | 2914 | 0xf000 | tjit->retval_off); | |
| 2890 | 2915 | ||
| 2891 | 2916 | for (i = 0; i < fmod_ret->nr_nodes; i++) { | |
| 2892 | - | if (invoke_bpf_prog(tjit, m, fmod_ret->nodes[i], true)) | |
| 2917 | + | if (invoke_bpf_prog(tjit, im, m, fmod_ret->nodes[i], true)) | |
| 2893 | 2918 | return -EINVAL; | |
| 2894 | 2919 | ||
| 2895 | 2920 | /* | |
| @@ -2943,15 +2968,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2943 | 2968 | /* mvc tccnt_off(%r15),tail_call_cnt(4,%r15) */ | |
| 2944 | 2969 | _EMIT6(0xd203f000 | tjit->tccnt_off, | |
| 2945 | 2970 | 0xf000 | offsetof(struct prog_frame, tail_call_cnt)); | |
| 2946 | - | ||
| 2947 | - | im->ip_after_call = jit->prg_buf + jit->prg; | |
| 2948 | - | ||
| 2949 | - | /* | |
| 2950 | - | * The following nop will be patched by bpf_tramp_image_put(). | |
| 2951 | - | */ | |
| 2952 | - | ||
| 2953 | - | /* brcl 0,im->ip_epilogue */ | |
| 2954 | - | EMIT6_PCREL_RILC(0xc0040000, 0, (u64)im->ip_epilogue); | |
| 2955 | 2971 | } | |
| 2956 | 2972 | ||
| 2957 | 2973 | /* Set the "is_return" flag for fsession. */ | |
| @@ -2962,12 +2978,10 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 2962 | 2978 | ||
| 2963 | 2979 | /* do_fexit: */ | |
| 2964 | 2980 | tjit->do_fexit = jit->prg; | |
| 2965 | - | if (invoke_bpf(tjit, m, fexit, false, func_meta, cookie_off)) | |
| 2981 | + | if (invoke_bpf(tjit, im, m, fexit, false, func_meta, cookie_off)) | |
| 2966 | 2982 | return -EINVAL; | |
| 2967 | 2983 | ||
| 2968 | 2984 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 2969 | - | im->ip_epilogue = jit->prg_buf + jit->prg; | |
| 2970 | - | ||
| 2971 | 2985 | /* | |
| 2972 | 2986 | * __bpf_tramp_exit(im); | |
| 2973 | 2987 | */ | |
| @@ -3016,7 +3030,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, | |||
| 3016 | 3030 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 3017 | 3031 | struct bpf_tramp_nodes *tnodes, void *orig_call) | |
| 3018 | 3032 | { | |
| 3019 | - | struct bpf_tramp_image im; | |
| 3033 | + | struct bpf_tramp_image im = {}; | |
| 3020 | 3034 | struct bpf_tramp_jit tjit; | |
| 3021 | 3035 | int ret; | |
| 3022 | 3036 | ||
modified arch/s390/pci/pci_event.c
| @@ -226,6 +226,7 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev, | |||
| 226 | 226 | device_lock(&pdev->dev); | |
| 227 | 227 | if (pdev->error_state == pci_channel_io_perm_failure) { | |
| 228 | 228 | ers_res = PCI_ERS_RESULT_DISCONNECT; | |
| 229 | + | status_str = "skipped (permanent failure)"; | |
| 229 | 230 | goto out_unlock; | |
| 230 | 231 | } | |
| 231 | 232 | pdev->error_state = pci_channel_io_frozen; | |
| @@ -297,8 +298,8 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev, | |||
| 297 | 298 | driver->err_handler->resume(pdev); | |
| 298 | 299 | pci_uevent_ers(pdev, PCI_ERS_RESULT_RECOVERED); | |
| 299 | 300 | out_unlock: | |
| 301 | + | zpci_report_status(zdev, pdev, "recovery", status_str); | |
| 300 | 302 | device_unlock(&pdev->dev); | |
| 301 | - | zpci_report_status(zdev, "recovery", status_str); | |
| 302 | 303 | ||
| 303 | 304 | return ers_res; | |
| 304 | 305 | } | |
| @@ -361,8 +362,10 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf) | |||
| 361 | 362 | ||
| 362 | 363 | __zpci_event_print_error(pdev, ccdf); | |
| 363 | 364 | ||
| 364 | - | if (!pdev) | |
| 365 | + | if (!pdev) { | |
| 366 | + | zpci_report_status(zdev, NULL, "error event", "no pdev bound"); | |
| 365 | 367 | goto no_pdev; | |
| 368 | + | } | |
| 366 | 369 | ||
| 367 | 370 | switch (ccdf->pec) { | |
| 368 | 371 | case 0x002a: /* Error event concerns FMB */ | |
modified arch/s390/pci/pci_report.c
| @@ -87,9 +87,23 @@ static struct debug_view debug_log_view = { | |||
| 87 | 87 | NULL | |
| 88 | 88 | }; | |
| 89 | 89 | ||
| 90 | + | static ssize_t zpci_report_pdev(struct pci_dev *pdev, char *buf, size_t size) | |
| 91 | + | { | |
| 92 | + | struct pci_driver *driver; | |
| 93 | + | const char *start = buf; | |
| 94 | + | char *end = buf + size; | |
| 95 | + | ||
| 96 | + | device_lock_assert(&pdev->dev); | |
| 97 | + | buf += scnprintf(buf, end - buf, "state: %s\n", zpci_state_str(pdev->error_state)); | |
| 98 | + | driver = to_pci_driver(pdev->dev.driver); | |
| 99 | + | buf += scnprintf(buf, end - buf, "driver: %s\n", (driver) ? driver->name : "n/a"); | |
| 100 | + | return buf - start; | |
| 101 | + | } | |
| 102 | + | ||
| 90 | 103 | /** | |
| 91 | 104 | * zpci_report_status - Report the status of operations on a PCI device | |
| 92 | - | * @zdev: The PCI device for which to report status | |
| 105 | + | * @zdev: The zPCI device for which to report status | |
| 106 | + | * @pdev: The PCI device associated with the zdev if any, NULL otherwise | |
| 93 | 107 | * @operation: A string representing the operation reported | |
| 94 | 108 | * @status: A string representing the status of the operation | |
| 95 | 109 | * | |
| @@ -103,15 +117,14 @@ static struct debug_view debug_log_view = { | |||
| 103 | 117 | * | |
| 104 | 118 | * Return: 0 on success an error code < 0 otherwise. | |
| 105 | 119 | */ | |
| 106 | - | int zpci_report_status(struct zpci_dev *zdev, const char *operation, const char *status) | |
| 120 | + | int zpci_report_status(struct zpci_dev *zdev, struct pci_dev *pdev, | |
| 121 | + | const char *operation, const char *status) | |
| 107 | 122 | { | |
| 108 | 123 | struct zpci_report_error *report; | |
| 109 | - | struct pci_driver *driver = NULL; | |
| 110 | - | struct pci_dev *pdev = NULL; | |
| 111 | 124 | char *buf, *end; | |
| 112 | 125 | int ret; | |
| 113 | 126 | ||
| 114 | - | if (!zdev || !zdev->zbus) | |
| 127 | + | if (!zdev) | |
| 115 | 128 | return -ENODEV; | |
| 116 | 129 | ||
| 117 | 130 | /* Protected virtualization hosts get nothing from us */ | |
| @@ -121,18 +134,13 @@ int zpci_report_status(struct zpci_dev *zdev, const char *operation, const char | |||
| 121 | 134 | report = (void *)get_zeroed_page(GFP_KERNEL); | |
| 122 | 135 | if (!report) | |
| 123 | 136 | return -ENOMEM; | |
| 124 | - | if (zdev->zbus->bus) | |
| 125 | - | pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn); | |
| 126 | - | if (pdev) | |
| 127 | - | driver = to_pci_driver(pdev->dev.driver); | |
| 128 | 137 | ||
| 129 | 138 | buf = report->data.log_data; | |
| 130 | 139 | end = report->data.log_data + ZPCI_REPORT_DATA_SIZE; | |
| 131 | 140 | buf += scnprintf(buf, end - buf, "report: %s\n", operation); | |
| 132 | 141 | buf += scnprintf(buf, end - buf, "status: %s\n", status); | |
| 133 | - | buf += scnprintf(buf, end - buf, "state: %s\n", | |
| 134 | - | (pdev) ? zpci_state_str(pdev->error_state) : "n/a"); | |
| 135 | - | buf += scnprintf(buf, end - buf, "driver: %s\n", (driver) ? driver->name : "n/a"); | |
| 142 | + | if (pdev) | |
| 143 | + | buf += zpci_report_pdev(pdev, buf, end - buf); | |
| 136 | 144 | ret = debug_dump(pci_debug_msg_id, &debug_log_view, buf, end - buf, true); | |
| 137 | 145 | if (ret < 0) | |
| 138 | 146 | pr_err("Reading PCI debug messages failed with code %d\n", ret); | |
modified arch/s390/pci/pci_report.h
| @@ -8,9 +8,11 @@ | |||
| 8 | 8 | */ | |
| 9 | 9 | #ifndef __S390_PCI_REPORT_H | |
| 10 | 10 | #define __S390_PCI_REPORT_H | |
| 11 | + | #include <linux/pci.h> | |
| 11 | 12 | ||
| 12 | 13 | struct zpci_dev; | |
| 13 | 14 | ||
| 14 | - | int zpci_report_status(struct zpci_dev *zdev, const char *operation, const char *status); | |
| 15 | + | int zpci_report_status(struct zpci_dev *zdev, struct pci_dev *pdev, | |
| 16 | + | const char *operation, const char *status); | |
| 15 | 17 | ||
| 16 | 18 | #endif /* __S390_PCI_REPORT_H */ | |
modified arch/um/drivers/vector_transports.c
| @@ -209,6 +209,7 @@ static int raw_verify_header( | |||
| 209 | 209 | if ((vheader->flags & VIRTIO_NET_HDR_F_DATA_VALID) > 0) | |
| 210 | 210 | return 1; | |
| 211 | 211 | ||
| 212 | + | skb_set_network_header(skb, ETH_HLEN); | |
| 212 | 213 | virtio_net_hdr_to_skb(skb, vheader, virtio_legacy_is_little_endian()); | |
| 213 | 214 | return 0; | |
| 214 | 215 | } | |
modified arch/x86/Kconfig.cpu
| @@ -204,10 +204,21 @@ config CC_HAS_MARCH_NATIVE | |||
| 204 | 204 | # usage warnings that only appear wth '-march=native'. | |
| 205 | 205 | depends on CC_IS_GCC || CLANG_VERSION >= 190100 | |
| 206 | 206 | ||
| 207 | + | config RUSTC_HAS_APXF | |
| 208 | + | # The kernel isn't ready for in-kernel APX instructions. Without | |
| 209 | + | # explicit frontend gating of APX, the backend may emit those | |
| 210 | + | # instructions in native builds. | |
| 211 | + | # | |
| 212 | + | # Rust 1.88 added the `apxf` feature option, but versions before 1.93 | |
| 213 | + | # emit an `apxf` target attribute that only LLVM 23+ can interpret. | |
| 214 | + | def_bool (RUSTC_VERSION >= 108800 && RUSTC_LLVM_MAJOR_VERSION >= 23) || \ | |
| 215 | + | RUSTC_VERSION >= 109300 | |
| 216 | + | ||
| 207 | 217 | config X86_NATIVE_CPU | |
| 208 | 218 | bool "Build and optimize for local/native CPU" | |
| 209 | 219 | depends on X86_64 | |
| 210 | 220 | depends on CC_HAS_MARCH_NATIVE | |
| 221 | + | depends on !RUST || RUSTC_HAS_APXF | |
| 211 | 222 | help | |
| 212 | 223 | Optimize for the current CPU used to compile the kernel. | |
| 213 | 224 | Use this option if you intend to build the kernel for your | |
modified arch/x86/Makefile
| @@ -161,6 +161,11 @@ else | |||
| 161 | 161 | ||
| 162 | 162 | ifdef CONFIG_X86_NATIVE_CPU | |
| 163 | 163 | KBUILD_CFLAGS += -march=native | |
| 164 | + | # Prevent the compiler from generating EGPR use. The kernel is | |
| 165 | + | # not yet prepared for general in-kernel use. | |
| 166 | + | KBUILD_CFLAGS += $(call cc-option,-mno-apx-features=egpr) | |
| 167 | + | ||
| 168 | + | # generate_rust_target.rs handles Rust APX gating. | |
| 164 | 169 | KBUILD_RUSTFLAGS += -Ctarget-cpu=native | |
| 165 | 170 | else | |
| 166 | 171 | KBUILD_CFLAGS += -march=x86-64 -mtune=generic | |
modified arch/x86/coco/sev/svsm.c
| @@ -74,6 +74,14 @@ int svsm_perform_call_protocol(struct svsm_call *call) | |||
| 74 | 74 | ||
| 75 | 75 | flags = native_local_irq_save(); | |
| 76 | 76 | ||
| 77 | + | /* | |
| 78 | + | * 'caa' is a per-CPU variable. To avoid using a stale or incorrect | |
| 79 | + | * 'caa' if the task is preempted or migrated to another CPU after it | |
| 80 | + | * is fetched, always fetch 'caa' and then issue the SVSM call with | |
| 81 | + | * interrupts disabled. This ensures the correct 'caa' is used. | |
| 82 | + | */ | |
| 83 | + | call->caa = svsm_get_caa(); | |
| 84 | + | ||
| 77 | 85 | ghcb = __sev_get_ghcb(&state); | |
| 78 | 86 | ||
| 79 | 87 | do { | |
| @@ -321,7 +329,6 @@ int snp_svsm_vtpm_send_command(u8 *buffer) | |||
| 321 | 329 | { | |
| 322 | 330 | struct svsm_call call = {}; | |
| 323 | 331 | ||
| 324 | - | call.caa = svsm_get_caa(); | |
| 325 | 332 | call.rax = SVSM_VTPM_CALL(SVSM_VTPM_CMD); | |
| 326 | 333 | call.rcx = __pa(buffer); | |
| 327 | 334 | ||
| @@ -345,7 +352,6 @@ bool snp_svsm_vtpm_probe(void) | |||
| 345 | 352 | if (!snp_vmpl) | |
| 346 | 353 | return false; | |
| 347 | 354 | ||
| 348 | - | call.caa = svsm_get_caa(); | |
| 349 | 355 | call.rax = SVSM_VTPM_CALL(SVSM_VTPM_QUERY); | |
| 350 | 356 | ||
| 351 | 357 | if (svsm_perform_call_protocol(&call)) | |
modified arch/x86/crypto/aesni-intel_glue.c
| @@ -1293,6 +1293,7 @@ static void gcm_process_assoc(const struct aes_gcm_key *key, u8 ghash_acc[16], | |||
| 1293 | 1293 | unsigned int len; | |
| 1294 | 1294 | const u8 *src = walk.addr; | |
| 1295 | 1295 | ||
| 1296 | + | assoclen -= orig_len_this_step; | |
| 1296 | 1297 | if (unlikely(pos)) { | |
| 1297 | 1298 | len = min(len_this_step, 16 - pos); | |
| 1298 | 1299 | memcpy(&buf[pos], src, len); | |
| @@ -1320,7 +1321,6 @@ next: | |||
| 1320 | 1321 | kernel_fpu_end(); | |
| 1321 | 1322 | kernel_fpu_begin(); | |
| 1322 | 1323 | } | |
| 1323 | - | assoclen -= orig_len_this_step; | |
| 1324 | 1324 | } | |
| 1325 | 1325 | if (unlikely(pos)) | |
| 1326 | 1326 | aes_gcm_aad_update(key, ghash_acc, buf, pos, flags); | |
modified arch/x86/entry/entry_fred.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include <asm/desc.h> | |
| 11 | 11 | #include <asm/fred.h> | |
| 12 | 12 | #include <asm/idtentry.h> | |
| 13 | + | #include <asm/processor-flags.h> | |
| 13 | 14 | #include <asm/syscall.h> | |
| 14 | 15 | #include <asm/trapnr.h> | |
| 15 | 16 | #include <asm/traps.h> | |
| @@ -71,7 +72,15 @@ static noinstr void fred_intx(struct pt_regs *regs) | |||
| 71 | 72 | #endif | |
| 72 | 73 | ||
| 73 | 74 | default: | |
| 74 | - | return exc_general_protection(regs, 0); | |
| 75 | + | /* | |
| 76 | + | * Reconstruct the #GP fault state that IDT delivery would produce. | |
| 77 | + | * Clear the software event flag so ERETU with TF set does not trap | |
| 78 | + | * before the resumed instruction. See prevent_single_step_upon_eretu(). | |
| 79 | + | */ | |
| 80 | + | regs->ip -= regs->fred_ss.insnlen; | |
| 81 | + | regs->flags |= X86_EFLAGS_RF; | |
| 82 | + | regs->fred_ss.swevent = 0; | |
| 83 | + | return exc_general_protection(regs, (regs->fred_ss.vector << 3) | 2); | |
| 75 | 84 | } | |
| 76 | 85 | } | |
| 77 | 86 | ||
modified arch/x86/entry/vdso/vdso64/Makefile
| @@ -14,7 +14,7 @@ vobjs-$(CONFIG_X86_SGX) += vsgx.o | |||
| 14 | 14 | vobjs-$(CONFIG_FUTEX_ROBUST_UNLOCK) += vfutex.o | |
| 15 | 15 | ||
| 16 | 16 | # Compilation flags | |
| 17 | - | flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small | |
| 17 | + | flags-y := -DBUILD_VDSO64 -m64 -mcmodel=small $(CONFIG_CC_OPT_INLINE_MEMSET) | |
| 18 | 18 | ||
| 19 | 19 | # The location of this include matters! | |
| 20 | 20 | include $(src)/../common/Makefile.include | |
modified arch/x86/events/amd/brs.c
| @@ -343,11 +343,10 @@ void amd_brs_drain(void) | |||
| 343 | 343 | if (!amd_brs_match_plm(event, from, to)) | |
| 344 | 344 | continue; | |
| 345 | 345 | ||
| 346 | - | perf_clear_branch_entry_bitfields(br+nr); | |
| 347 | - | ||
| 348 | - | br[nr].from = from; | |
| 349 | - | br[nr].to = to; | |
| 350 | - | ||
| 346 | + | br[nr] = (struct perf_branch_entry){ | |
| 347 | + | .from = from, | |
| 348 | + | .to = to, | |
| 349 | + | }; | |
| 351 | 350 | nr++; | |
| 352 | 351 | } | |
| 353 | 352 | empty: | |
modified arch/x86/events/amd/lbr.c
| @@ -184,13 +184,6 @@ void amd_pmu_lbr_read(void) | |||
| 184 | 184 | entry.to.split.reserved) | |
| 185 | 185 | continue; | |
| 186 | 186 | ||
| 187 | - | perf_clear_branch_entry_bitfields(br + out); | |
| 188 | - | ||
| 189 | - | br[out].from = sign_ext_branch_ip(entry.from.split.ip); | |
| 190 | - | br[out].to = sign_ext_branch_ip(entry.to.split.ip); | |
| 191 | - | br[out].mispred = entry.from.split.mispredict; | |
| 192 | - | br[out].predicted = !br[out].mispred; | |
| 193 | - | ||
| 194 | 187 | /* | |
| 195 | 188 | * Set branch speculation information using the status of | |
| 196 | 189 | * the valid and spec bits. | |
| @@ -208,7 +201,14 @@ void amd_pmu_lbr_read(void) | |||
| 208 | 201 | * speculative and took the correct path | |
| 209 | 202 | */ | |
| 210 | 203 | idx = (entry.to.split.valid << 1) | entry.to.split.spec; | |
| 211 | - | br[out].spec = lbr_spec_map[idx]; | |
| 204 | + | ||
| 205 | + | br[out] = (struct perf_branch_entry){ | |
| 206 | + | .from = sign_ext_branch_ip(entry.from.split.ip), | |
| 207 | + | .to = sign_ext_branch_ip(entry.to.split.ip), | |
| 208 | + | .mispred = entry.from.split.mispredict, | |
| 209 | + | .predicted = !entry.from.split.mispredict, | |
| 210 | + | .spec = lbr_spec_map[idx], | |
| 211 | + | }; | |
| 212 | 212 | out++; | |
| 213 | 213 | } | |
| 214 | 214 | ||
modified arch/x86/events/intel/core.c
| @@ -506,6 +506,8 @@ static struct event_constraint intel_pnc_event_constraints[] = { | |||
| 506 | 506 | INTEL_EVENT_CONSTRAINT(0xce, 0x1), | |
| 507 | 507 | ||
| 508 | 508 | INTEL_UEVENT_CONSTRAINT(0x01b1, 0x8), | |
| 509 | + | INTEL_UEVENT_CONSTRAINT(0x01b2, 0xf), | |
| 510 | + | INTEL_UEVENT_CONSTRAINT(0x02b2, 0xf), | |
| 509 | 511 | INTEL_UEVENT_CONSTRAINT(0x0847, 0xf), | |
| 510 | 512 | INTEL_UEVENT_CONSTRAINT(0x0446, 0xf), | |
| 511 | 513 | INTEL_UEVENT_CONSTRAINT(0x0846, 0xf), | |
| @@ -520,6 +522,14 @@ static struct extra_reg intel_pnc_extra_regs[] __read_mostly = { | |||
| 520 | 522 | INTEL_UEVENT_EXTRA_REG(0x022a, MSR_OMR_1, 0x40ffffff0000ffffull, OMR_1), | |
| 521 | 523 | INTEL_UEVENT_EXTRA_REG(0x042a, MSR_OMR_2, 0x40ffffff0000ffffull, OMR_2), | |
| 522 | 524 | INTEL_UEVENT_EXTRA_REG(0x082a, MSR_OMR_3, 0x40ffffff0000ffffull, OMR_3), | |
| 525 | + | INTEL_UEVENT_EXTRA_REG(0x014f, MSR_OMR_0, 0x40ffffff0000ffffull, OMR_0), | |
| 526 | + | INTEL_UEVENT_EXTRA_REG(0x024f, MSR_OMR_1, 0x40ffffff0000ffffull, OMR_1), | |
| 527 | + | INTEL_UEVENT_EXTRA_REG(0x044f, MSR_OMR_2, 0x40ffffff0000ffffull, OMR_2), | |
| 528 | + | INTEL_UEVENT_EXTRA_REG(0x084f, MSR_OMR_3, 0x40ffffff0000ffffull, OMR_3), | |
| 529 | + | INTEL_UEVENT_EXTRA_REG(0x01d6, MSR_OMR_0, 0x40ffffff0000ffffull, OMR_0), | |
| 530 | + | INTEL_UEVENT_EXTRA_REG(0x02d6, MSR_OMR_1, 0x40ffffff0000ffffull, OMR_1), | |
| 531 | + | INTEL_UEVENT_EXTRA_REG(0x04d6, MSR_OMR_2, 0x40ffffff0000ffffull, OMR_2), | |
| 532 | + | INTEL_UEVENT_EXTRA_REG(0x08d6, MSR_OMR_3, 0x40ffffff0000ffffull, OMR_3), | |
| 523 | 533 | INTEL_UEVENT_PEBS_LDLAT_EXTRA_REG(0x01cd), | |
| 524 | 534 | INTEL_UEVENT_EXTRA_REG(0x02c6, MSR_PEBS_FRONTEND, 0x9, FE), | |
| 525 | 535 | INTEL_UEVENT_EXTRA_REG(0x03c6, MSR_PEBS_FRONTEND, 0x7fff1f, FE), | |
| @@ -5292,12 +5302,15 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) | |||
| 5292 | 5302 | struct kvm_pmu *kvm_pmu = (struct kvm_pmu *)data; | |
| 5293 | 5303 | u64 intel_ctrl = hybrid(cpuc->pmu, intel_ctrl); | |
| 5294 | 5304 | u64 pebs_mask = cpuc->pebs_enabled & x86_pmu.pebs_capable; | |
| 5295 | - | int global_ctrl, pebs_enable; | |
| 5305 | + | u64 guest_pebs_mask; | |
| 5306 | + | int global_ctrl; | |
| 5296 | 5307 | ||
| 5297 | 5308 | /* | |
| 5298 | 5309 | * In addition to obeying exclude_guest/exclude_host, remove bits being | |
| 5299 | 5310 | * used for PEBS when running a guest, because PEBS writes to virtual | |
| 5300 | - | * addresses (not physical addresses). | |
| 5311 | + | * addresses (not physical addresses). If the guest wants to utilize | |
| 5312 | + | * PEBS, and PEBS can be safely enabled in the guest, bits for the guest's | |
| 5313 | + | * PEBS-enabled counters will be OR'd back in as appropriate. | |
| 5301 | 5314 | */ | |
| 5302 | 5315 | *nr = 0; | |
| 5303 | 5316 | global_ctrl = (*nr)++; | |
| @@ -5327,41 +5340,68 @@ static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) | |||
| 5327 | 5340 | return arr; | |
| 5328 | 5341 | } | |
| 5329 | 5342 | ||
| 5330 | - | if (!kvm_pmu || !x86_pmu.pebs_ept) | |
| 5343 | + | /* | |
| 5344 | + | * If the CPU doesn't support PEBS in the guest, then there's nothing | |
| 5345 | + | * more to do as disabling PMCs via PERF_GLOBAL_CTRL is sufficient on | |
| 5346 | + | * CPUs with guest/host isolation. | |
| 5347 | + | */ | |
| 5348 | + | if (!x86_pmu.pebs_ept) | |
| 5331 | 5349 | return arr; | |
| 5332 | 5350 | ||
| 5351 | + | /* | |
| 5352 | + | * Restrict guest PEBS events to counters that (a) perf supports, (b) | |
| 5353 | + | * the guest wants to use for PEBS, (c) are not excluded from counting | |
| 5354 | + | * in the guest, and (d) _are_ excluded from counting in the host. | |
| 5355 | + | */ | |
| 5356 | + | guest_pebs_mask = pebs_mask & intel_ctrl & kvm_pmu->pebs_enable & | |
| 5357 | + | ~cpuc->intel_ctrl_host_mask & | |
| 5358 | + | cpuc->intel_ctrl_guest_mask; | |
| 5359 | + | ||
| 5360 | + | /* | |
| 5361 | + | * Disable counters where the guest PMC is different than the host PMC | |
| 5362 | + | * being used on behalf of the guest, as the PEBS record includes | |
| 5363 | + | * PERF_GLOBAL_STATUS, i.e. the guest will see overflow status for the | |
| 5364 | + | * wrong counter(s). | |
| 5365 | + | */ | |
| 5366 | + | guest_pebs_mask &= ~kvm_pmu->host_cross_mapped_mask; | |
| 5367 | + | ||
| 5368 | + | /* | |
| 5369 | + | * FIXME: Allow guest and host usage of PEBS events to co-exist instead | |
| 5370 | + | * of disabling guest PEBS entirely if the host is using PEBS. | |
| 5371 | + | * What exactly goes wrong if guest and host are using PEBS is | |
| 5372 | + | * unknown. | |
| 5373 | + | */ | |
| 5374 | + | if (pebs_mask & ~cpuc->intel_ctrl_guest_mask) | |
| 5375 | + | guest_pebs_mask = 0; | |
| 5376 | + | ||
| 5377 | + | /* | |
| 5378 | + | * Context switch DS_AREA and PEBS_DATA_CFG if and only if PEBS will be | |
| 5379 | + | * active in the guest; if no records will be generated while the guest | |
| 5380 | + | * is running, then simply keep the host values resident in hardware. | |
| 5381 | + | */ | |
| 5333 | 5382 | arr[(*nr)++] = (struct perf_guest_switch_msr){ | |
| 5334 | 5383 | .msr = MSR_IA32_DS_AREA, | |
| 5335 | 5384 | .host = (unsigned long)cpuc->ds, | |
| 5336 | - | .guest = kvm_pmu->ds_area, | |
| 5385 | + | .guest = guest_pebs_mask ? kvm_pmu->ds_area : (unsigned long)cpuc->ds, | |
| 5337 | 5386 | }; | |
| 5338 | 5387 | ||
| 5339 | 5388 | if (x86_pmu.intel_cap.pebs_baseline) { | |
| 5340 | 5389 | arr[(*nr)++] = (struct perf_guest_switch_msr){ | |
| 5341 | 5390 | .msr = MSR_PEBS_DATA_CFG, | |
| 5342 | 5391 | .host = cpuc->active_pebs_data_cfg, | |
| 5343 | - | .guest = kvm_pmu->pebs_data_cfg, | |
| 5392 | + | .guest = guest_pebs_mask ? kvm_pmu->pebs_data_cfg : | |
| 5393 | + | cpuc->active_pebs_data_cfg, | |
| 5344 | 5394 | }; | |
| 5345 | 5395 | } | |
| 5346 | 5396 | ||
| 5347 | - | pebs_enable = (*nr)++; | |
| 5348 | - | arr[pebs_enable] = (struct perf_guest_switch_msr){ | |
| 5349 | - | .msr = MSR_IA32_PEBS_ENABLE, | |
| 5350 | - | .host = cpuc->pebs_enabled & ~cpuc->intel_ctrl_guest_mask, | |
| 5351 | - | .guest = pebs_mask & ~cpuc->intel_ctrl_host_mask & kvm_pmu->pebs_enable, | |
| 5352 | - | }; | |
| 5353 | - | ||
| 5354 | - | if (arr[pebs_enable].host) { | |
| 5355 | - | /* Disable guest PEBS if host PEBS is enabled. */ | |
| 5356 | - | arr[pebs_enable].guest = 0; | |
| 5357 | - | } else { | |
| 5358 | - | /* Disable guest PEBS thoroughly for cross-mapped PEBS counters. */ | |
| 5359 | - | arr[pebs_enable].guest &= ~kvm_pmu->host_cross_mapped_mask; | |
| 5360 | - | arr[global_ctrl].guest &= ~kvm_pmu->host_cross_mapped_mask; | |
| 5361 | - | /* Set hw GLOBAL_CTRL bits for PEBS counter when it runs for guest */ | |
| 5362 | - | arr[global_ctrl].guest |= arr[pebs_enable].guest; | |
| 5363 | - | } | |
| 5364 | - | ||
| 5397 | + | /* | |
| 5398 | + | * Do NOT mess with PEBS_ENABLED. As above, disabling counters via | |
| 5399 | + | * PERF_GLOBAL_CTRL is sufficient, and loading a stale PEBS_ENABLED, | |
| 5400 | + | * e.g. on VM-Exit, can put the system in a bad state. Simply enable | |
| 5401 | + | * counters in PERF_GLOBAL_CTRL, as perf load PEBS_ENABLED with the | |
| 5402 | + | * full value, i.e. perf *also* relies on PERF_GLOBAL_CTRL. | |
| 5403 | + | */ | |
| 5404 | + | arr[global_ctrl].guest |= guest_pebs_mask; | |
| 5365 | 5405 | return arr; | |
| 5366 | 5406 | } | |
| 5367 | 5407 | ||
| @@ -6561,6 +6601,8 @@ static void intel_pmu_filter(struct pmu *pmu, int cpu, bool *ret) | |||
| 6561 | 6601 | ||
| 6562 | 6602 | PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63"); | |
| 6563 | 6603 | ||
| 6604 | + | PMU_FORMAT_ATTR(offmodule_rsp, "config1:0-63"); | |
| 6605 | + | ||
| 6564 | 6606 | PMU_FORMAT_ATTR(ldlat, "config1:0-15"); | |
| 6565 | 6607 | ||
| 6566 | 6608 | PMU_FORMAT_ATTR(frontend, "config1:0-23"); | |
| @@ -6609,6 +6651,20 @@ static struct attribute *skl_format_attr[] = { | |||
| 6609 | 6651 | NULL, | |
| 6610 | 6652 | }; | |
| 6611 | 6653 | ||
| 6654 | + | static struct attribute *pnc_format_attr_rtm[] = { | |
| 6655 | + | &format_attr_in_tx.attr, | |
| 6656 | + | &format_attr_in_tx_cp.attr, | |
| 6657 | + | &format_attr_offmodule_rsp.attr, | |
| 6658 | + | &format_attr_ldlat.attr, | |
| 6659 | + | NULL | |
| 6660 | + | }; | |
| 6661 | + | ||
| 6662 | + | static struct attribute *pnc_format_attr[] = { | |
| 6663 | + | &format_attr_offmodule_rsp.attr, | |
| 6664 | + | &format_attr_ldlat.attr, | |
| 6665 | + | NULL | |
| 6666 | + | }; | |
| 6667 | + | ||
| 6612 | 6668 | static __initconst const struct x86_pmu core_pmu = { | |
| 6613 | 6669 | .name = "core", | |
| 6614 | 6670 | .handle_irq = x86_pmu_handle_irq, | |
| @@ -7474,6 +7530,7 @@ static struct attribute *adl_hybrid_tsx_attrs[] = { | |||
| 7474 | 7530 | FORMAT_ATTR_HYBRID(in_tx, hybrid_big); | |
| 7475 | 7531 | FORMAT_ATTR_HYBRID(in_tx_cp, hybrid_big); | |
| 7476 | 7532 | FORMAT_ATTR_HYBRID(offcore_rsp, hybrid_big_small_tiny); | |
| 7533 | + | FORMAT_ATTR_HYBRID(offmodule_rsp, hybrid_big_small_tiny); | |
| 7477 | 7534 | FORMAT_ATTR_HYBRID(ldlat, hybrid_big_small_tiny); | |
| 7478 | 7535 | FORMAT_ATTR_HYBRID(frontend, hybrid_big); | |
| 7479 | 7536 | ||
| @@ -7512,6 +7569,23 @@ static struct attribute *mtl_hybrid_extra_attr[] = { | |||
| 7512 | 7569 | NULL | |
| 7513 | 7570 | }; | |
| 7514 | 7571 | ||
| 7572 | + | static struct attribute *nvl_hybrid_extra_attr_rtm[] = { | |
| 7573 | + | ADL_HYBRID_RTM_FORMAT_ATTR, | |
| 7574 | + | FORMAT_HYBRID_PTR(offmodule_rsp), | |
| 7575 | + | FORMAT_HYBRID_PTR(ldlat), | |
| 7576 | + | FORMAT_HYBRID_PTR(frontend), | |
| 7577 | + | FORMAT_HYBRID_PTR(snoop_rsp), | |
| 7578 | + | NULL | |
| 7579 | + | }; | |
| 7580 | + | ||
| 7581 | + | static struct attribute *nvl_hybrid_extra_attr[] = { | |
| 7582 | + | FORMAT_HYBRID_PTR(offmodule_rsp), | |
| 7583 | + | FORMAT_HYBRID_PTR(ldlat), | |
| 7584 | + | FORMAT_HYBRID_PTR(frontend), | |
| 7585 | + | FORMAT_HYBRID_PTR(snoop_rsp), | |
| 7586 | + | NULL | |
| 7587 | + | }; | |
| 7588 | + | ||
| 7515 | 7589 | static bool is_attr_for_this_pmu(struct kobject *kobj, struct attribute *attr) | |
| 7516 | 7590 | { | |
| 7517 | 7591 | struct device *dev = kobj_to_dev(kobj); | |
| @@ -8549,6 +8623,8 @@ __init int intel_pmu_init(void) | |||
| 8549 | 8623 | case INTEL_DIAMONDRAPIDS_X: | |
| 8550 | 8624 | intel_pmu_init_pnc(NULL); | |
| 8551 | 8625 | x86_pmu.pebs_latency_data = pnc_latency_data; | |
| 8626 | + | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8627 | + | pnc_format_attr_rtm : pnc_format_attr; | |
| 8552 | 8628 | ||
| 8553 | 8629 | pr_cont("Panthercove events, "); | |
| 8554 | 8630 | name = "panthercove"; | |
| @@ -8557,13 +8633,12 @@ __init int intel_pmu_init(void) | |||
| 8557 | 8633 | glc_common: | |
| 8558 | 8634 | intel_pmu_init_glc(NULL); | |
| 8559 | 8635 | intel_pmu_pebs_data_source_skl(true); | |
| 8560 | - | ||
| 8636 | + | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8637 | + | hsw_format_attr : nhm_format_attr; | |
| 8561 | 8638 | glc_base: | |
| 8562 | 8639 | x86_pmu.pebs_ept = 1; | |
| 8563 | 8640 | x86_pmu.hw_config = hsw_hw_config; | |
| 8564 | 8641 | x86_pmu.get_event_constraints = glc_get_event_constraints; | |
| 8565 | - | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8566 | - | hsw_format_attr : nhm_format_attr; | |
| 8567 | 8642 | extra_skl_attr = skl_format_attr; | |
| 8568 | 8643 | mem_attr = glc_events_attrs; | |
| 8569 | 8644 | td_attr = glc_td_events_attrs; | |
| @@ -8785,7 +8860,7 @@ __init int intel_pmu_init(void) | |||
| 8785 | 8860 | mem_attr = mtl_hybrid_mem_attrs; | |
| 8786 | 8861 | tsx_attr = adl_hybrid_tsx_attrs; | |
| 8787 | 8862 | extra_attr = boot_cpu_has(X86_FEATURE_RTM) ? | |
| 8788 | - | mtl_hybrid_extra_attr_rtm : mtl_hybrid_extra_attr; | |
| 8863 | + | nvl_hybrid_extra_attr_rtm : nvl_hybrid_extra_attr; | |
| 8789 | 8864 | ||
| 8790 | 8865 | /* Initialize big core specific PerfMon capabilities.*/ | |
| 8791 | 8866 | pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_CORE_IDX]; | |
| @@ -8794,8 +8869,6 @@ __init int intel_pmu_init(void) | |||
| 8794 | 8869 | /* Initialize Atom core specific PerfMon capabilities.*/ | |
| 8795 | 8870 | pmu = &x86_pmu.hybrid_pmu[X86_HYBRID_PMU_ATOM_IDX]; | |
| 8796 | 8871 | intel_pmu_init_arw(&pmu->pmu); | |
| 8797 | - | ||
| 8798 | - | intel_pmu_pebs_data_source_lnl(); | |
| 8799 | 8872 | break; | |
| 8800 | 8873 | ||
| 8801 | 8874 | default: | |
modified arch/x86/events/intel/ds.c
| @@ -277,8 +277,8 @@ static u64 pnc_pebs_l2_hit_data_source[PNC_PEBS_DATA_SOURCE_MAX] = { | |||
| 277 | 277 | 0, /* 0x06: Reserved */ | |
| 278 | 278 | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, HIT), /* 0x07: L2 Hit Snoop HIT */ | |
| 279 | 279 | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, HITM), /* 0x08: L2 Hit Snoop Hit Modified */ | |
| 280 | - | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, MISS), /* 0x09: Prefetch Promotion */ | |
| 281 | - | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, MISS), /* 0x0a: Cross Core Prefetch Promotion */ | |
| 280 | + | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, NONE), /* 0x09: Prefetch Promotion */ | |
| 281 | + | OP_LH | P(LVL, L2) | LEVEL(L2) | P(SNOOP, NONE), /* 0x0a: Cross Core Prefetch Promotion */ | |
| 282 | 282 | 0, /* 0x0b: Reserved */ | |
| 283 | 283 | 0, /* 0x0c: Reserved */ | |
| 284 | 284 | 0, /* 0x0d: Reserved */ | |
| @@ -455,6 +455,7 @@ static inline void pebs_set_tlb_lock(u64 *val, bool tlb, bool lock) | |||
| 455 | 455 | static u64 __grt_latency_data(struct perf_event *event, u64 status, | |
| 456 | 456 | u8 dse, bool tlb, bool lock, bool blk) | |
| 457 | 457 | { | |
| 458 | + | union perf_mem_data_src src; | |
| 458 | 459 | u64 val; | |
| 459 | 460 | ||
| 460 | 461 | WARN_ON_ONCE(is_hybrid() && | |
| @@ -470,7 +471,16 @@ static u64 __grt_latency_data(struct perf_event *event, u64 status, | |||
| 470 | 471 | else | |
| 471 | 472 | val |= P(BLK, NA); | |
| 472 | 473 | ||
| 473 | - | return val; | |
| 474 | + | src.val = val; | |
| 475 | + | ||
| 476 | + | if (event->hw.flags & | |
| 477 | + | (PERF_X86_EVENT_PEBS_LDLAT | PERF_X86_EVENT_PEBS_LD_HSW)) | |
| 478 | + | src.mem_op = P(OP, LOAD); | |
| 479 | + | if (event->hw.flags & | |
| 480 | + | (PERF_X86_EVENT_PEBS_STLAT | PERF_X86_EVENT_PEBS_ST_HSW)) | |
| 481 | + | src.mem_op = P(OP, STORE); | |
| 482 | + | ||
| 483 | + | return src.val; | |
| 474 | 484 | } | |
| 475 | 485 | ||
| 476 | 486 | u64 grt_latency_data(struct perf_event *event, u64 status) | |
| @@ -528,7 +538,11 @@ static u64 arw_latency_data(struct perf_event *event, u64 status) | |||
| 528 | 538 | val |= P(BLK, NA); | |
| 529 | 539 | ||
| 530 | 540 | src.val = val; | |
| 531 | - | if (event->hw.flags & PERF_X86_EVENT_PEBS_ST_HSW) | |
| 541 | + | if (event->hw.flags & | |
| 542 | + | (PERF_X86_EVENT_PEBS_LDLAT | PERF_X86_EVENT_PEBS_LD_HSW)) | |
| 543 | + | src.mem_op = P(OP, LOAD); | |
| 544 | + | if (event->hw.flags & | |
| 545 | + | (PERF_X86_EVENT_PEBS_STLAT | PERF_X86_EVENT_PEBS_ST_HSW)) | |
| 532 | 546 | src.mem_op = P(OP, STORE); | |
| 533 | 547 | ||
| 534 | 548 | return src.val; | |
| @@ -563,7 +577,11 @@ static u64 lnc_latency_data(struct perf_event *event, u64 status) | |||
| 563 | 577 | val |= P(BLK, NA); | |
| 564 | 578 | ||
| 565 | 579 | src.val = val; | |
| 566 | - | if (event->hw.flags & PERF_X86_EVENT_PEBS_ST_HSW) | |
| 580 | + | if (event->hw.flags & | |
| 581 | + | (PERF_X86_EVENT_PEBS_LDLAT | PERF_X86_EVENT_PEBS_LD_HSW)) | |
| 582 | + | src.mem_op = P(OP, LOAD); | |
| 583 | + | if (event->hw.flags & | |
| 584 | + | (PERF_X86_EVENT_PEBS_STLAT | PERF_X86_EVENT_PEBS_ST_HSW)) | |
| 567 | 585 | src.mem_op = P(OP, STORE); | |
| 568 | 586 | ||
| 569 | 587 | return src.val; | |
| @@ -621,7 +639,11 @@ u64 pnc_latency_data(struct perf_event *event, u64 status) | |||
| 621 | 639 | val |= P(BLK, NA); | |
| 622 | 640 | ||
| 623 | 641 | src.val = val; | |
| 624 | - | if (event->hw.flags & PERF_X86_EVENT_PEBS_ST_HSW) | |
| 642 | + | if (event->hw.flags & | |
| 643 | + | (PERF_X86_EVENT_PEBS_LDLAT | PERF_X86_EVENT_PEBS_LD_HSW)) | |
| 644 | + | src.mem_op = P(OP, LOAD); | |
| 645 | + | if (event->hw.flags & | |
| 646 | + | (PERF_X86_EVENT_PEBS_STLAT | PERF_X86_EVENT_PEBS_ST_HSW)) | |
| 625 | 647 | src.mem_op = P(OP, STORE); | |
| 626 | 648 | ||
| 627 | 649 | return src.val; | |
| @@ -1291,22 +1313,22 @@ struct event_constraint intel_glm_pebs_event_constraints[] = { | |||
| 1291 | 1313 | ||
| 1292 | 1314 | struct event_constraint intel_grt_pebs_event_constraints[] = { | |
| 1293 | 1315 | /* Allow all events as PEBS with no flags */ | |
| 1294 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0x3), | |
| 1295 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0x3f), | |
| 1316 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0x3), | |
| 1317 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0x3f), | |
| 1296 | 1318 | EVENT_CONSTRAINT_END | |
| 1297 | 1319 | }; | |
| 1298 | 1320 | ||
| 1299 | 1321 | struct event_constraint intel_cmt_pebs_event_constraints[] = { | |
| 1300 | 1322 | /* Allow all events as PEBS with no flags */ | |
| 1301 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0x3), | |
| 1302 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0xff), | |
| 1323 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0x3), | |
| 1324 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0xff), | |
| 1303 | 1325 | EVENT_CONSTRAINT_END | |
| 1304 | 1326 | }; | |
| 1305 | 1327 | ||
| 1306 | 1328 | struct event_constraint intel_dkt_pebs_event_constraints[] = { | |
| 1307 | 1329 | /* Allow all events as PEBS with no flags */ | |
| 1308 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x5d0, 0xff), | |
| 1309 | - | INTEL_HYBRID_LAT_CONSTRAINT(0x6d0, 0xff), | |
| 1330 | + | INTEL_HYBRID_LDLAT_CONSTRAINT(0x5d0, 0xff), | |
| 1331 | + | INTEL_HYBRID_STLAT_CONSTRAINT(0x6d0, 0xff), | |
| 1310 | 1332 | EVENT_CONSTRAINT_END | |
| 1311 | 1333 | }; | |
| 1312 | 1334 | ||
| @@ -1496,24 +1518,8 @@ struct event_constraint intel_lnc_pebs_event_constraints[] = { | |||
| 1496 | 1518 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x012a, 0x1), /* OCR.* events */ | |
| 1497 | 1519 | INTEL_FLAGS_UEVENT_CONSTRAINT(0x012b, 0x1), /* OCR.* events */ | |
| 1498 | 1520 | ||
| 1499 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x04a4, 0x1), /* TOPDOWN.BAD_SPEC_SLOTS */ | |
| 1500 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x08a4, 0x1), /* TOPDOWN.BR_MISPREDICT_SLOTS */ | |
| 1501 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x10a4, 0x8), /* TOPDOWN.MEMORY_BOUND_SLOTS */ | |
| 1502 | - | ||
| 1503 | 1521 | INTEL_HYBRID_LDLAT_CONSTRAINT(0x1cd, 0x3fc), | |
| 1504 | 1522 | INTEL_HYBRID_STLAT_CONSTRAINT(0x2cd, 0x3), | |
| 1505 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ | |
| 1506 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ | |
| 1507 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_INST_RETIRED.LOCK_LOADS */ | |
| 1508 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x41d0, 0xf), /* MEM_INST_RETIRED.SPLIT_LOADS */ | |
| 1509 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x42d0, 0xf), /* MEM_INST_RETIRED.SPLIT_STORES */ | |
| 1510 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x81d0, 0xf), /* MEM_INST_RETIRED.ALL_LOADS */ | |
| 1511 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x82d0, 0xf), /* MEM_INST_RETIRED.ALL_STORES */ | |
| 1512 | - | INTEL_FLAGS_UEVENT_CONSTRAINT(0x87d0, 0x3ff), /* MEM_INST_RETIRED.ANY */ | |
| 1513 | - | ||
| 1514 | - | INTEL_FLAGS_EVENT_CONSTRAINT_DATALA_LD_RANGE(0xd1, 0xd4, 0xf), | |
| 1515 | - | ||
| 1516 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd0, 0xf), | |
| 1517 | 1523 | ||
| 1518 | 1524 | /* | |
| 1519 | 1525 | * Everything else is handled by PMU_FL_PEBS_ALL, because we | |
| @@ -1526,18 +1532,6 @@ struct event_constraint intel_lnc_pebs_event_constraints[] = { | |||
| 1526 | 1532 | struct event_constraint intel_pnc_pebs_event_constraints[] = { | |
| 1527 | 1533 | INTEL_HYBRID_LDLAT_CONSTRAINT(0x1cd, 0xfc), | |
| 1528 | 1534 | INTEL_HYBRID_STLAT_CONSTRAINT(0x2cd, 0x3), | |
| 1529 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ | |
| 1530 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ | |
| 1531 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_INST_RETIRED.LOCK_LOADS */ | |
| 1532 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x41d0, 0xf), /* MEM_INST_RETIRED.SPLIT_LOADS */ | |
| 1533 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x42d0, 0xf), /* MEM_INST_RETIRED.SPLIT_STORES */ | |
| 1534 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x81d0, 0xf), /* MEM_INST_RETIRED.ALL_LOADS */ | |
| 1535 | - | INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x82d0, 0xf), /* MEM_INST_RETIRED.ALL_STORES */ | |
| 1536 | - | ||
| 1537 | - | INTEL_FLAGS_EVENT_CONSTRAINT_DATALA_LD_RANGE(0xd1, 0xd4, 0xf), | |
| 1538 | - | ||
| 1539 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd0, 0xf), | |
| 1540 | - | INTEL_FLAGS_EVENT_CONSTRAINT(0xd6, 0xf), | |
| 1541 | 1535 | ||
| 1542 | 1536 | /* | |
| 1543 | 1537 | * Everything else is handled by PMU_FL_PEBS_ALL, because we | |
modified arch/x86/events/intel/lbr.c
| @@ -756,10 +756,10 @@ void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc) | |||
| 756 | 756 | ||
| 757 | 757 | rdmsrq(x86_pmu.lbr_from + lbr_idx, msr_lastbranch.lbr); | |
| 758 | 758 | ||
| 759 | - | perf_clear_branch_entry_bitfields(br); | |
| 760 | - | ||
| 761 | - | br->from = msr_lastbranch.from; | |
| 762 | - | br->to = msr_lastbranch.to; | |
| 759 | + | *br = (struct perf_branch_entry){ | |
| 760 | + | .from = msr_lastbranch.from, | |
| 761 | + | .to = msr_lastbranch.to, | |
| 762 | + | }; | |
| 763 | 763 | br++; | |
| 764 | 764 | } | |
| 765 | 765 | cpuc->lbr_stack.nr = i; | |
| @@ -847,14 +847,15 @@ void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc) | |||
| 847 | 847 | if (abort && x86_pmu.lbr_double_abort && out > 0) | |
| 848 | 848 | out--; | |
| 849 | 849 | ||
| 850 | - | perf_clear_branch_entry_bitfields(br+out); | |
| 851 | - | br[out].from = from; | |
| 852 | - | br[out].to = to; | |
| 853 | - | br[out].mispred = mis; | |
| 854 | - | br[out].predicted = pred; | |
| 855 | - | br[out].in_tx = in_tx; | |
| 856 | - | br[out].abort = abort; | |
| 857 | - | br[out].cycles = cycles; | |
| 850 | + | br[out] = (struct perf_branch_entry){ | |
| 851 | + | .from = from, | |
| 852 | + | .to = to, | |
| 853 | + | .mispred = mis, | |
| 854 | + | .predicted = pred, | |
| 855 | + | .in_tx = in_tx, | |
| 856 | + | .abort = abort, | |
| 857 | + | .cycles = cycles, | |
| 858 | + | }; | |
| 858 | 859 | out++; | |
| 859 | 860 | } | |
| 860 | 861 | cpuc->lbr_stack.nr = out; | |
| @@ -905,6 +906,7 @@ static void intel_pmu_store_lbr(struct cpu_hw_events *cpuc, | |||
| 905 | 906 | struct perf_branch_entry *e; | |
| 906 | 907 | struct lbr_entry *lbr; | |
| 907 | 908 | u64 from, to, info; | |
| 909 | + | bool mispred; | |
| 908 | 910 | int i; | |
| 909 | 911 | ||
| 910 | 912 | for (i = 0; i < x86_pmu.lbr_nr; i++) { | |
| @@ -921,24 +923,27 @@ static void intel_pmu_store_lbr(struct cpu_hw_events *cpuc, | |||
| 921 | 923 | to = rdlbr_to(i, lbr); | |
| 922 | 924 | info = rdlbr_info(i, lbr); | |
| 923 | 925 | ||
| 924 | - | perf_clear_branch_entry_bitfields(e); | |
| 925 | - | ||
| 926 | - | e->from = from; | |
| 927 | - | e->to = to; | |
| 928 | - | e->mispred = get_lbr_mispred(info); | |
| 929 | - | e->predicted = !e->mispred; | |
| 930 | - | e->in_tx = !!(info & LBR_INFO_IN_TX); | |
| 931 | - | e->abort = !!(info & LBR_INFO_ABORT); | |
| 932 | - | e->cycles = get_lbr_cycles(info); | |
| 933 | - | e->type = get_lbr_br_type(info); | |
| 934 | - | ||
| 935 | - | /* | |
| 936 | - | * Leverage the reserved field of cpuc->lbr_entries[i] to | |
| 937 | - | * temporarily store the branch counters information. | |
| 938 | - | * The later code will decide what content can be disclosed | |
| 939 | - | * to the perf tool. Pleae see intel_pmu_lbr_counters_reorder(). | |
| 940 | - | */ | |
| 941 | - | e->reserved = (info >> LBR_INFO_BR_CNTR_OFFSET) & LBR_INFO_BR_CNTR_FULL_MASK; | |
| 926 | + | mispred = get_lbr_mispred(info); | |
| 927 | + | ||
| 928 | + | *e = (struct perf_branch_entry){ | |
| 929 | + | .from = from, | |
| 930 | + | .to = to, | |
| 931 | + | .mispred = mispred, | |
| 932 | + | .predicted = !mispred, | |
| 933 | + | .in_tx = !!(info & LBR_INFO_IN_TX), | |
| 934 | + | .abort = !!(info & LBR_INFO_ABORT), | |
| 935 | + | .cycles = get_lbr_cycles(info), | |
| 936 | + | .type = get_lbr_br_type(info), | |
| 937 | + | /* | |
| 938 | + | * Leverage the reserved field of | |
| 939 | + | * cpuc->lbr_entries[i] to temporarily store the | |
| 940 | + | * branch counters information. The later code will | |
| 941 | + | * decide what content can be disclosed to the perf | |
| 942 | + | * tool. Pleae see intel_pmu_lbr_counters_reorder(). | |
| 943 | + | */ | |
| 944 | + | .reserved = (info >> LBR_INFO_BR_CNTR_OFFSET) & | |
| 945 | + | LBR_INFO_BR_CNTR_FULL_MASK, | |
| 946 | + | }; | |
| 942 | 947 | } | |
| 943 | 948 | ||
| 944 | 949 | cpuc->lbr_stack.nr = i; | |
modified arch/x86/events/perf_event.h
| @@ -517,10 +517,6 @@ struct cpu_hw_events { | |||
| 517 | 517 | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \ | |
| 518 | 518 | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_ST) | |
| 519 | 519 | ||
| 520 | - | #define INTEL_HYBRID_LAT_CONSTRAINT(c, n) \ | |
| 521 | - | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \ | |
| 522 | - | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_LAT_HYBRID) | |
| 523 | - | ||
| 524 | 520 | #define INTEL_HYBRID_LDLAT_CONSTRAINT(c, n) \ | |
| 525 | 521 | __EVENT_CONSTRAINT(c, n, INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \ | |
| 526 | 522 | HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_LAT_HYBRID|PERF_X86_EVENT_PEBS_LD_HSW) | |
modified arch/x86/include/asm/cpufeatures.h
| @@ -477,6 +477,8 @@ | |||
| 477 | 477 | #define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* No Nested Data Breakpoints */ | |
| 478 | 478 | #define X86_FEATURE_WRMSR_XX_BASE_NS (20*32+ 1) /* WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */ | |
| 479 | 479 | #define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* LFENCE always serializing / synchronizes RDTSC */ | |
| 480 | + | ||
| 481 | + | #define X86_FEATURE_TLBSYNC_SFW_NO (20*32+ 4) /* TLBI Erratum #1718 fixed in microcode */ | |
| 480 | 482 | #define X86_FEATURE_VERW_CLEAR (20*32+ 5) /* The memory form of VERW mitigates TSA */ | |
| 481 | 483 | #define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* Null Selector Clears Base */ | |
| 482 | 484 | ||
| @@ -587,4 +589,5 @@ | |||
| 587 | 589 | #define X86_BUG_TSA X86_BUG( 1*32+ 9) /* "tsa" CPU is affected by Transient Scheduler Attacks */ | |
| 588 | 590 | #define X86_BUG_VMSCAPE X86_BUG( 1*32+10) /* "vmscape" CPU is affected by VMSCAPE attacks from guests */ | |
| 589 | 591 | #define X86_BUG_SEAMRET_INVD_VMCS X86_BUG( 1*32+11) /* "seamret_invd_vmcs" SEAMRET from P-SEAMLDR clears the current VMCS */ | |
| 592 | + | #define X86_BUG_TLBI X86_BUG( 1*32+12) /* "tlbi" AMD TLBI Erratum #1718 */ | |
| 590 | 593 | #endif /* _ASM_X86_CPUFEATURES_H */ | |
modified arch/x86/include/asm/div64.h
| @@ -111,7 +111,7 @@ static inline u64 mul_u64_add_u64_div_u64(u64 rax, u64 mul, u64 add, u64 div) | |||
| 111 | 111 | ||
| 112 | 112 | if (!statically_true(!add)) | |
| 113 | 113 | asm ("addq %[add], %[lo]; adcq $0, %[hi]" : | |
| 114 | - | [lo] "+r" (rax), [hi] "+r" (rdx) : [add] "irm" (add)); | |
| 114 | + | [lo] "+r" (rax), [hi] "+r" (rdx) : [add] "erm" (add)); | |
| 115 | 115 | ||
| 116 | 116 | asm ("divq %[div]" : "+a" (rax), "+d" (rdx) : [div] "rm" (div)); | |
| 117 | 117 | ||
modified arch/x86/include/asm/pgtable.h
| @@ -806,7 +806,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) | |||
| 806 | 806 | pmdval_t val = pmd_val(pmd), oldval = val; | |
| 807 | 807 | pmd_t pmd_result; | |
| 808 | 808 | ||
| 809 | - | val &= (_HPAGE_CHG_MASK & ~_PAGE_DIRTY); | |
| 809 | + | val &= _HPAGE_CHG_MASK; | |
| 810 | 810 | val |= check_pgprot(newprot) & ~_HPAGE_CHG_MASK; | |
| 811 | 811 | val = flip_protnone_guard(oldval, val, PHYSICAL_PMD_PAGE_MASK); | |
| 812 | 812 | ||
modified arch/x86/include/asm/text-patching.h
| @@ -164,9 +164,9 @@ unsigned long int3_emulate_pop(struct pt_regs *regs) | |||
| 164 | 164 | } | |
| 165 | 165 | ||
| 166 | 166 | static __always_inline | |
| 167 | - | void int3_emulate_call(struct pt_regs *regs, unsigned long func) | |
| 167 | + | void int3_emulate_call(struct pt_regs *regs, unsigned long ip, unsigned long func) | |
| 168 | 168 | { | |
| 169 | - | int3_emulate_push(regs, regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE); | |
| 169 | + | int3_emulate_push(regs, ip); | |
| 170 | 170 | int3_emulate_jmp(regs, func); | |
| 171 | 171 | } | |
| 172 | 172 | ||
modified arch/x86/include/asm/tlb.h
| @@ -110,6 +110,12 @@ static inline void __tlbsync(void) | |||
| 110 | 110 | ||
| 111 | 111 | /* TLBSYNC: supported in binutils >= 0.36. */ | |
| 112 | 112 | asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory"); | |
| 113 | + | ||
| 114 | + | if (!static_cpu_has_bug(X86_BUG_TLBI)) | |
| 115 | + | return; | |
| 116 | + | ||
| 117 | + | /* TLBSYNC: supported in binutils >= 0.36. */ | |
| 118 | + | asm volatile(".byte 0x0f, 0x01, 0xff" ::: "memory"); | |
| 113 | 119 | } | |
| 114 | 120 | #else | |
| 115 | 121 | /* Some compilers (I'm looking at you clang!) simply can't do DCE */ | |
modified arch/x86/include/uapi/asm/ptrace-abi.h
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | #ifndef _ASM_X86_PTRACE_ABI_H | |
| 3 | 3 | #define _ASM_X86_PTRACE_ABI_H | |
| 4 | 4 | ||
| 5 | + | #if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) | |
| 5 | 6 | #ifdef __i386__ | |
| 6 | 7 | ||
| 7 | 8 | #define EBX 0 | |
| @@ -25,7 +26,6 @@ | |||
| 25 | 26 | ||
| 26 | 27 | #else /* __i386__ */ | |
| 27 | 28 | ||
| 28 | - | #if defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) | |
| 29 | 29 | /* | |
| 30 | 30 | * C ABI says these regs are callee-preserved. They aren't saved on kernel entry | |
| 31 | 31 | * unless syscall needs a complete, fully filled "struct pt_regs". | |
| @@ -57,12 +57,12 @@ | |||
| 57 | 57 | #define EFLAGS 144 | |
| 58 | 58 | #define RSP 152 | |
| 59 | 59 | #define SS 160 | |
| 60 | - | #endif /* __ASSEMBLER__ */ | |
| 61 | 60 | ||
| 62 | 61 | /* top of stack page */ | |
| 63 | 62 | #define FRAME_SIZE 168 | |
| 64 | 63 | ||
| 65 | 64 | #endif /* !__i386__ */ | |
| 65 | + | #endif /* defined(__ASSEMBLER__) || defined(__FRAME_OFFSETS) */ | |
| 66 | 66 | ||
| 67 | 67 | /* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */ | |
| 68 | 68 | #define PTRACE_GETREGS 12 | |
modified arch/x86/kernel/alternative.c
| @@ -6,6 +6,9 @@ | |||
| 6 | 6 | #include <linux/vmalloc.h> | |
| 7 | 7 | #include <linux/memory.h> | |
| 8 | 8 | #include <linux/execmem.h> | |
| 9 | + | #include <linux/cleanup.h> | |
| 10 | + | #include <linux/kgdb.h> | |
| 11 | + | #include <linux/mmap_lock.h> | |
| 9 | 12 | ||
| 10 | 13 | #include <asm/text-patching.h> | |
| 11 | 14 | #include <asm/insn.h> | |
| @@ -1198,6 +1201,41 @@ static bool cfi_debug __ro_after_init; | |||
| 1198 | 1201 | bool cfi_bhi __ro_after_init = false; | |
| 1199 | 1202 | #endif | |
| 1200 | 1203 | ||
| 1204 | + | #ifdef CONFIG_FINEIBT | |
| 1205 | + | /* | |
| 1206 | + | * <fineibt_preamble_start>: | |
| 1207 | + | * 0: f3 0f 1e fa endbr64 | |
| 1208 | + | * 4: 2d 78 56 34 12 sub $0x12345678, %eax | |
| 1209 | + | * 9: 2e 0f 85 03 00 00 00 jne,pn 13 <fineibt_preamble_start+0x13> | |
| 1210 | + | * 10: 0f 1f 40 d6 nopl -0x2a(%rax) | |
| 1211 | + | * | |
| 1212 | + | * Note that the JNE target is the 0xD6 byte inside the NOPL, this decodes as | |
| 1213 | + | * UDB on x86_64 and raises #UD. | |
| 1214 | + | */ | |
| 1215 | + | asm( ".pushsection .rodata \n" | |
| 1216 | + | "fineibt_preamble_start: \n" | |
| 1217 | + | " endbr64 \n" | |
| 1218 | + | " subl $0x12345678, %eax \n" | |
| 1219 | + | "fineibt_preamble_bhi: \n" | |
| 1220 | + | " cs jne.d32 fineibt_preamble_start+0x13 \n" | |
| 1221 | + | "#fineibt_func: \n" | |
| 1222 | + | " nopl -42(%rax) \n" | |
| 1223 | + | "fineibt_preamble_end: \n" | |
| 1224 | + | ".popsection\n" | |
| 1225 | + | ); | |
| 1226 | + | ||
| 1227 | + | extern u8 fineibt_preamble_start[]; | |
| 1228 | + | extern u8 fineibt_preamble_bhi[]; | |
| 1229 | + | extern u8 fineibt_preamble_end[]; | |
| 1230 | + | ||
| 1231 | + | #define fineibt_preamble_size (fineibt_preamble_end - fineibt_preamble_start) | |
| 1232 | + | #define fineibt_preamble_bhi (fineibt_preamble_bhi - fineibt_preamble_start) | |
| 1233 | + | #define fineibt_preamble_ud 0x13 | |
| 1234 | + | #define fineibt_preamble_hash 5 | |
| 1235 | + | ||
| 1236 | + | #define fineibt_prefix_size (fineibt_preamble_size - ENDBR_INSN_SIZE) | |
| 1237 | + | #endif /* CONFIG_FINEIBT */ | |
| 1238 | + | ||
| 1201 | 1239 | #ifdef CONFIG_CFI | |
| 1202 | 1240 | u32 cfi_get_func_hash(void *func) | |
| 1203 | 1241 | { | |
| @@ -1205,9 +1243,11 @@ u32 cfi_get_func_hash(void *func) | |||
| 1205 | 1243 | ||
| 1206 | 1244 | func -= cfi_get_offset(); | |
| 1207 | 1245 | switch (cfi_mode) { | |
| 1246 | + | #ifdef CONFIG_FINEIBT | |
| 1208 | 1247 | case CFI_FINEIBT: | |
| 1209 | - | func += 7; | |
| 1248 | + | func += fineibt_preamble_hash; | |
| 1210 | 1249 | break; | |
| 1250 | + | #endif | |
| 1211 | 1251 | case CFI_KCFI: | |
| 1212 | 1252 | func += 1; | |
| 1213 | 1253 | break; | |
| @@ -1363,39 +1403,6 @@ early_param("cfi", cfi_parse_cmdline); | |||
| 1363 | 1403 | * anyway. | |
| 1364 | 1404 | */ | |
| 1365 | 1405 | ||
| 1366 | - | /* | |
| 1367 | - | * <fineibt_preamble_start>: | |
| 1368 | - | * 0: f3 0f 1e fa endbr64 | |
| 1369 | - | * 4: 2d 78 56 34 12 sub $0x12345678, %eax | |
| 1370 | - | * 9: 2e 0f 85 03 00 00 00 jne,pn 13 <fineibt_preamble_start+0x13> | |
| 1371 | - | * 10: 0f 1f 40 d6 nopl -0x2a(%rax) | |
| 1372 | - | * | |
| 1373 | - | * Note that the JNE target is the 0xD6 byte inside the NOPL, this decodes as | |
| 1374 | - | * UDB on x86_64 and raises #UD. | |
| 1375 | - | */ | |
| 1376 | - | asm( ".pushsection .rodata \n" | |
| 1377 | - | "fineibt_preamble_start: \n" | |
| 1378 | - | " endbr64 \n" | |
| 1379 | - | " subl $0x12345678, %eax \n" | |
| 1380 | - | "fineibt_preamble_bhi: \n" | |
| 1381 | - | " cs jne.d32 fineibt_preamble_start+0x13 \n" | |
| 1382 | - | "#fineibt_func: \n" | |
| 1383 | - | " nopl -42(%rax) \n" | |
| 1384 | - | "fineibt_preamble_end: \n" | |
| 1385 | - | ".popsection\n" | |
| 1386 | - | ); | |
| 1387 | - | ||
| 1388 | - | extern u8 fineibt_preamble_start[]; | |
| 1389 | - | extern u8 fineibt_preamble_bhi[]; | |
| 1390 | - | extern u8 fineibt_preamble_end[]; | |
| 1391 | - | ||
| 1392 | - | #define fineibt_preamble_size (fineibt_preamble_end - fineibt_preamble_start) | |
| 1393 | - | #define fineibt_preamble_bhi (fineibt_preamble_bhi - fineibt_preamble_start) | |
| 1394 | - | #define fineibt_preamble_ud 0x13 | |
| 1395 | - | #define fineibt_preamble_hash 5 | |
| 1396 | - | ||
| 1397 | - | #define fineibt_prefix_size (fineibt_preamble_size - ENDBR_INSN_SIZE) | |
| 1398 | - | ||
| 1399 | 1406 | /* | |
| 1400 | 1407 | * <fineibt_caller_start>: | |
| 1401 | 1408 | * 0: b8 78 56 34 12 mov $0x12345678, %eax | |
| @@ -2169,6 +2176,7 @@ int3_exception_notify(struct notifier_block *self, unsigned long val, void *data | |||
| 2169 | 2176 | unsigned long selftest = (unsigned long)&int3_selftest_asm; | |
| 2170 | 2177 | struct die_args *args = data; | |
| 2171 | 2178 | struct pt_regs *regs = args->regs; | |
| 2179 | + | unsigned long ip; | |
| 2172 | 2180 | ||
| 2173 | 2181 | OPTIMIZER_HIDE_VAR(selftest); | |
| 2174 | 2182 | ||
| @@ -2181,7 +2189,8 @@ int3_exception_notify(struct notifier_block *self, unsigned long val, void *data | |||
| 2181 | 2189 | if (regs->ip - INT3_INSN_SIZE != selftest) | |
| 2182 | 2190 | return NOTIFY_DONE; | |
| 2183 | 2191 | ||
| 2184 | - | int3_emulate_call(regs, (unsigned long)&int3_selftest_callee); | |
| 2192 | + | ip = regs->ip - INT3_INSN_SIZE + CALL_INSN_SIZE; | |
| 2193 | + | int3_emulate_call(regs, ip, (unsigned long)&int3_selftest_callee); | |
| 2185 | 2194 | return NOTIFY_STOP; | |
| 2186 | 2195 | } | |
| 2187 | 2196 | ||
| @@ -2372,6 +2381,38 @@ static void text_poke_memset(void *dst, const void *src, size_t len) | |||
| 2372 | 2381 | ||
| 2373 | 2382 | typedef void text_poke_f(void *dst, const void *src, size_t len); | |
| 2374 | 2383 | ||
| 2384 | + | static void __poke_vmalloc_pages(struct page **pages, void *addr, | |
| 2385 | + | bool cross_page_boundary) | |
| 2386 | + | { | |
| 2387 | + | pages[0] = vmalloc_to_page(addr); | |
| 2388 | + | if (cross_page_boundary) | |
| 2389 | + | pages[1] = vmalloc_to_page(addr + PAGE_SIZE); | |
| 2390 | + | } | |
| 2391 | + | ||
| 2392 | + | static void poke_vmalloc_pages(struct page **pages, void *addr, | |
| 2393 | + | bool cross_page_boundary) | |
| 2394 | + | { | |
| 2395 | + | if (in_dbg_master()) { | |
| 2396 | + | /* | |
| 2397 | + | * If called from kgdb cannot sleep, but all other CPUs stopped | |
| 2398 | + | * anyway so safe to proceed without locks | |
| 2399 | + | */ | |
| 2400 | + | __poke_vmalloc_pages(pages, addr, cross_page_boundary); | |
| 2401 | + | } else { | |
| 2402 | + | /* | |
| 2403 | + | * execmem ROX ranges are shared between modules and can be | |
| 2404 | + | * collapsed to huge PMD entries, and this collapse can happen | |
| 2405 | + | * concurrently with a racing set_memory_rox(). | |
| 2406 | + | * | |
| 2407 | + | * Prevent vmalloc_to_page() from racing by acquiring an | |
| 2408 | + | * init_mm read lock which pairs with the init_mm write lock in | |
| 2409 | + | * cpa_collapse_large_pages(). | |
| 2410 | + | */ | |
| 2411 | + | guard(mmap_read_lock)(&init_mm); | |
| 2412 | + | __poke_vmalloc_pages(pages, addr, cross_page_boundary); | |
| 2413 | + | } | |
| 2414 | + | } | |
| 2415 | + | ||
| 2375 | 2416 | static void *__text_poke(text_poke_f func, void *addr, const void *src, size_t len) | |
| 2376 | 2417 | { | |
| 2377 | 2418 | bool cross_page_boundary = offset_in_page(addr) + len > PAGE_SIZE; | |
| @@ -2389,9 +2430,7 @@ static void *__text_poke(text_poke_f func, void *addr, const void *src, size_t l | |||
| 2389 | 2430 | BUG_ON(!after_bootmem); | |
| 2390 | 2431 | ||
| 2391 | 2432 | if (!core_kernel_text((unsigned long)addr)) { | |
| 2392 | - | pages[0] = vmalloc_to_page(addr); | |
| 2393 | - | if (cross_page_boundary) | |
| 2394 | - | pages[1] = vmalloc_to_page(addr + PAGE_SIZE); | |
| 2433 | + | poke_vmalloc_pages(pages, addr, cross_page_boundary); | |
| 2395 | 2434 | } else { | |
| 2396 | 2435 | pages[0] = virt_to_page(addr); | |
| 2397 | 2436 | WARN_ON(!PageReserved(pages[0])); | |
| @@ -2721,7 +2760,7 @@ noinstr int smp_text_poke_int3_handler(struct pt_regs *regs) | |||
| 2721 | 2760 | break; | |
| 2722 | 2761 | ||
| 2723 | 2762 | case CALL_INSN_OPCODE: | |
| 2724 | - | int3_emulate_call(regs, (long)ip + tpl->disp); | |
| 2763 | + | int3_emulate_call(regs, (long)ip, (long)ip + tpl->disp); | |
| 2725 | 2764 | break; | |
| 2726 | 2765 | ||
| 2727 | 2766 | case JMP32_INSN_OPCODE: | |
modified arch/x86/kernel/amd_node.c
| @@ -251,7 +251,7 @@ __setup("amd_smn_debugfs_enable", amd_smn_enable_dfs); | |||
| 251 | 251 | static int __init amd_smn_init(void) | |
| 252 | 252 | { | |
| 253 | 253 | u16 count, num_roots, roots_per_node, node, num_nodes; | |
| 254 | - | struct pci_dev *root; | |
| 254 | + | struct pci_dev *root __free(pci_dev_put) = NULL; | |
| 255 | 255 | ||
| 256 | 256 | if (!cpu_feature_enabled(X86_FEATURE_ZEN)) | |
| 257 | 257 | return 0; | |
| @@ -262,7 +262,6 @@ static int __init amd_smn_init(void) | |||
| 262 | 262 | return 0; | |
| 263 | 263 | ||
| 264 | 264 | num_roots = 0; | |
| 265 | - | root = NULL; | |
| 266 | 265 | while ((root = get_next_root(root))) { | |
| 267 | 266 | pci_dbg(root, "Reserving PCI config space\n"); | |
| 268 | 267 | ||
| @@ -299,14 +298,13 @@ static int __init amd_smn_init(void) | |||
| 299 | 298 | ||
| 300 | 299 | count = 0; | |
| 301 | 300 | node = 0; | |
| 302 | - | root = NULL; | |
| 303 | 301 | while (node < num_nodes && (root = get_next_root(root))) { | |
| 304 | 302 | /* Use one root for each node and skip the rest. */ | |
| 305 | 303 | if (count++ % roots_per_node) | |
| 306 | 304 | continue; | |
| 307 | 305 | ||
| 308 | 306 | pci_dbg(root, "is root for AMD node %u\n", node); | |
| 309 | - | amd_roots[node++] = root; | |
| 307 | + | amd_roots[node++] = pci_dev_get(root); | |
| 310 | 308 | } | |
| 311 | 309 | ||
| 312 | 310 | if (enable_dfs) { | |
modified arch/x86/kernel/cpu/amd.c
| @@ -1049,6 +1049,10 @@ static void init_amd_zen5(struct cpuinfo_x86 *c) | |||
| 1049 | 1049 | msr_clear_bit(MSR_AMD64_CPUID_FN_7, 18); | |
| 1050 | 1050 | pr_emerg_once("RDSEED32 is broken. Disabling the corresponding CPUID bit.\n"); | |
| 1051 | 1051 | } | |
| 1052 | + | ||
| 1053 | + | if (cpu_has(c, X86_FEATURE_INVLPGB) && | |
| 1054 | + | !cpu_has(c, X86_FEATURE_TLBSYNC_SFW_NO)) | |
| 1055 | + | set_cpu_bug(c, X86_BUG_TLBI); | |
| 1052 | 1056 | } | |
| 1053 | 1057 | ||
| 1054 | 1058 | static void init_amd(struct cpuinfo_x86 *c) | |
modified arch/x86/kernel/cpu/mce/core.c
| @@ -2108,6 +2108,9 @@ bool filter_mce(struct mce *m) | |||
| 2108 | 2108 | static __always_inline void exc_machine_check_kernel(struct pt_regs *regs) | |
| 2109 | 2109 | { | |
| 2110 | 2110 | irqentry_state_t irq_state; | |
| 2111 | + | unsigned long dr7; | |
| 2112 | + | ||
| 2113 | + | dr7 = local_db_save(); | |
| 2111 | 2114 | ||
| 2112 | 2115 | WARN_ON_ONCE(user_mode(regs)); | |
| 2113 | 2116 | ||
| @@ -2116,20 +2119,26 @@ static __always_inline void exc_machine_check_kernel(struct pt_regs *regs) | |||
| 2116 | 2119 | * mce_check_crashing_cpu() for details. | |
| 2117 | 2120 | */ | |
| 2118 | 2121 | if (mca_cfg.initialized && mce_check_crashing_cpu()) | |
| 2119 | - | return; | |
| 2122 | + | goto out; | |
| 2120 | 2123 | ||
| 2121 | 2124 | irq_state = irqentry_nmi_enter(regs); | |
| 2122 | 2125 | ||
| 2123 | 2126 | do_machine_check(regs); | |
| 2124 | 2127 | ||
| 2125 | 2128 | irqentry_nmi_exit(regs, irq_state); | |
| 2129 | + | out: | |
| 2130 | + | local_db_restore(dr7); | |
| 2126 | 2131 | } | |
| 2127 | 2132 | ||
| 2128 | 2133 | static __always_inline void exc_machine_check_user(struct pt_regs *regs) | |
| 2129 | 2134 | { | |
| 2135 | + | unsigned long dr7; | |
| 2136 | + | ||
| 2130 | 2137 | irqentry_enter_from_user_mode(regs); | |
| 2131 | 2138 | ||
| 2139 | + | dr7 = local_db_save(); | |
| 2132 | 2140 | do_machine_check(regs); | |
| 2141 | + | local_db_restore(dr7); | |
| 2133 | 2142 | ||
| 2134 | 2143 | irqentry_exit_to_user_mode(regs); | |
| 2135 | 2144 | } | |
| @@ -2138,21 +2147,13 @@ static __always_inline void exc_machine_check_user(struct pt_regs *regs) | |||
| 2138 | 2147 | /* MCE hit kernel mode */ | |
| 2139 | 2148 | DEFINE_IDTENTRY_MCE(exc_machine_check) | |
| 2140 | 2149 | { | |
| 2141 | - | unsigned long dr7; | |
| 2142 | - | ||
| 2143 | - | dr7 = local_db_save(); | |
| 2144 | 2150 | exc_machine_check_kernel(regs); | |
| 2145 | - | local_db_restore(dr7); | |
| 2146 | 2151 | } | |
| 2147 | 2152 | ||
| 2148 | 2153 | /* The user mode variant. */ | |
| 2149 | 2154 | DEFINE_IDTENTRY_MCE_USER(exc_machine_check) | |
| 2150 | 2155 | { | |
| 2151 | - | unsigned long dr7; | |
| 2152 | - | ||
| 2153 | - | dr7 = local_db_save(); | |
| 2154 | 2156 | exc_machine_check_user(regs); | |
| 2155 | - | local_db_restore(dr7); | |
| 2156 | 2157 | } | |
| 2157 | 2158 | ||
| 2158 | 2159 | #ifdef CONFIG_X86_FRED | |
| @@ -2169,28 +2170,20 @@ DEFINE_IDTENTRY_MCE_USER(exc_machine_check) | |||
| 2169 | 2170 | */ | |
| 2170 | 2171 | DEFINE_FREDENTRY_MCE(exc_machine_check) | |
| 2171 | 2172 | { | |
| 2172 | - | unsigned long dr7; | |
| 2173 | - | ||
| 2174 | - | dr7 = local_db_save(); | |
| 2175 | 2173 | if (user_mode(regs)) | |
| 2176 | 2174 | exc_machine_check_user(regs); | |
| 2177 | 2175 | else | |
| 2178 | 2176 | exc_machine_check_kernel(regs); | |
| 2179 | - | local_db_restore(dr7); | |
| 2180 | 2177 | } | |
| 2181 | 2178 | #endif | |
| 2182 | 2179 | #else | |
| 2183 | 2180 | /* 32bit unified entry point */ | |
| 2184 | 2181 | DEFINE_IDTENTRY_RAW(exc_machine_check) | |
| 2185 | 2182 | { | |
| 2186 | - | unsigned long dr7; | |
| 2187 | - | ||
| 2188 | - | dr7 = local_db_save(); | |
| 2189 | 2183 | if (user_mode(regs)) | |
| 2190 | 2184 | exc_machine_check_user(regs); | |
| 2191 | 2185 | else | |
| 2192 | 2186 | exc_machine_check_kernel(regs); | |
| 2193 | - | local_db_restore(dr7); | |
| 2194 | 2187 | } | |
| 2195 | 2188 | #endif | |
| 2196 | 2189 | ||
modified arch/x86/kernel/cpu/microcode/intel.c
| @@ -309,6 +309,26 @@ static void save_microcode_patch(struct microcode_intel *patch) | |||
| 309 | 309 | pr_err("Unable to allocate microcode memory size: %u\n", size); | |
| 310 | 310 | } | |
| 311 | 311 | ||
| 312 | + | static bool revision_is_safe(struct cpu_signature *sig, u32 rev) | |
| 313 | + | { | |
| 314 | + | u32 vfm = IFM(x86_family(sig->sig), x86_model(sig->sig)); | |
| 315 | + | ||
| 316 | + | /* | |
| 317 | + | * Erratum GNR98 can cause #MCs if "jumping over" revision 0x1000405. | |
| 318 | + | * Avoid the jumps. | |
| 319 | + | */ | |
| 320 | + | if (vfm == INTEL_GRANITERAPIDS_X && | |
| 321 | + | x86_stepping(sig->sig) == 1 && | |
| 322 | + | sig->pf & 0x95 && | |
| 323 | + | sig->rev < 0x1000405 && | |
| 324 | + | rev > 0x1000405) { | |
| 325 | + | pr_err_once("Erratum GNR98: skipping revision 0x%x.\n", rev); | |
| 326 | + | return false; | |
| 327 | + | } | |
| 328 | + | ||
| 329 | + | return true; | |
| 330 | + | } | |
| 331 | + | ||
| 312 | 332 | /* Scan blob for microcode matching the boot CPUs family, model, stepping */ | |
| 313 | 333 | static __init struct microcode_intel *scan_microcode(void *data, size_t size, | |
| 314 | 334 | struct ucode_cpu_info *uci, | |
| @@ -330,6 +350,9 @@ static __init struct microcode_intel *scan_microcode(void *data, size_t size, | |||
| 330 | 350 | if (!intel_find_matching_signature(data, &uci->cpu_sig)) | |
| 331 | 351 | continue; | |
| 332 | 352 | ||
| 353 | + | if (!revision_is_safe(&uci->cpu_sig, mc_header->rev)) | |
| 354 | + | continue; | |
| 355 | + | ||
| 333 | 356 | /* | |
| 334 | 357 | * For saving the early microcode, find the matching revision which | |
| 335 | 358 | * was loaded on the BSP. | |
| @@ -878,6 +901,9 @@ static enum ucode_state parse_microcode_blobs(int cpu, struct iov_iter *iter) | |||
| 878 | 901 | if (!intel_find_matching_signature(mc, &uci->cpu_sig)) | |
| 879 | 902 | continue; | |
| 880 | 903 | ||
| 904 | + | if (!revision_is_safe(&uci->cpu_sig, mc_header.rev)) | |
| 905 | + | continue; | |
| 906 | + | ||
| 881 | 907 | is_safe = ucode_validate_minrev(&mc_header); | |
| 882 | 908 | if (force_minrev && !is_safe) | |
| 883 | 909 | continue; | |
modified arch/x86/kernel/kprobes/core.c
| @@ -510,10 +510,9 @@ NOKPROBE_SYMBOL(kprobe_emulate_ret); | |||
| 510 | 510 | ||
| 511 | 511 | static void kprobe_emulate_call(struct kprobe *p, struct pt_regs *regs) | |
| 512 | 512 | { | |
| 513 | - | unsigned long func = regs->ip - INT3_INSN_SIZE + p->ainsn.size; | |
| 513 | + | unsigned long ip = regs->ip - INT3_INSN_SIZE + p->ainsn.size; | |
| 514 | 514 | ||
| 515 | - | func += p->ainsn.rel32; | |
| 516 | - | int3_emulate_call(regs, func); | |
| 515 | + | int3_emulate_call(regs, ip, ip + p->ainsn.rel32); | |
| 517 | 516 | } | |
| 518 | 517 | NOKPROBE_SYMBOL(kprobe_emulate_call); | |
| 519 | 518 | ||
modified arch/x86/kernel/sys_x86_64.c
| @@ -50,9 +50,16 @@ static unsigned long get_align_mask(struct file *filp) | |||
| 50 | 50 | * value before calling vm_unmapped_area() or ORed directly to the | |
| 51 | 51 | * address. | |
| 52 | 52 | */ | |
| 53 | - | static unsigned long get_align_bits(void) | |
| 53 | + | static unsigned long get_align_bits(struct file *filp) | |
| 54 | 54 | { | |
| 55 | - | return va_align.bits & get_align_mask(NULL); | |
| 55 | + | /* | |
| 56 | + | * va_align.bits is smaller than the huge page size and will | |
| 57 | + | * lead to misaligned huge pages. Ignore it for huge mappings. | |
| 58 | + | */ | |
| 59 | + | if (is_file_hugepages(filp)) | |
| 60 | + | return 0; | |
| 61 | + | ||
| 62 | + | return va_align.bits & get_align_mask(filp); | |
| 56 | 63 | } | |
| 57 | 64 | ||
| 58 | 65 | static int __init control_va_addr_alignment(char *str) | |
| @@ -157,7 +164,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, | |||
| 157 | 164 | } | |
| 158 | 165 | if (filp) { | |
| 159 | 166 | info.align_mask = get_align_mask(filp); | |
| 160 | - | info.align_offset += get_align_bits(); | |
| 167 | + | info.align_offset += get_align_bits(filp); | |
| 161 | 168 | } | |
| 162 | 169 | ||
| 163 | 170 | return vm_unmapped_area(&info); | |
| @@ -222,7 +229,7 @@ get_unmapped_area: | |||
| 222 | 229 | ||
| 223 | 230 | if (filp) { | |
| 224 | 231 | info.align_mask = get_align_mask(filp); | |
| 225 | - | info.align_offset += get_align_bits(); | |
| 232 | + | info.align_offset += get_align_bits(filp); | |
| 226 | 233 | } | |
| 227 | 234 | addr = vm_unmapped_area(&info); | |
| 228 | 235 | if (!(addr & ~PAGE_MASK)) | |
modified arch/x86/kvm/mmu/mmu.c
| @@ -2512,6 +2512,12 @@ static void shadow_walk_init_using_root(struct kvm_shadow_walk_iterator *iterato | |||
| 2512 | 2512 | ||
| 2513 | 2513 | iterator->addr = addr; | |
| 2514 | 2514 | iterator->shadow_addr = root; | |
| 2515 | + | ||
| 2516 | + | if (WARN_ON_ONCE(!VALID_PAGE(root)) || kvm_mmu_is_dummy_root(root)) { | |
| 2517 | + | iterator->level = 0; | |
| 2518 | + | return; | |
| 2519 | + | } | |
| 2520 | + | ||
| 2515 | 2521 | iterator->level = vcpu->arch.mmu->root_role.level; | |
| 2516 | 2522 | ||
| 2517 | 2523 | if (iterator->level >= PT64_ROOT_4LEVEL && | |
| @@ -5058,7 +5064,7 @@ static int kvm_tdp_page_prefault(struct kvm_vcpu *vcpu, gpa_t gpa, | |||
| 5058 | 5064 | if (signal_pending(current)) | |
| 5059 | 5065 | return -EINTR; | |
| 5060 | 5066 | ||
| 5061 | - | if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 5067 | + | if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu)) | |
| 5062 | 5068 | return -EIO; | |
| 5063 | 5069 | ||
| 5064 | 5070 | cond_resched(); | |
modified arch/x86/kvm/pmu.c
| @@ -823,14 +823,6 @@ void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu) | |||
| 823 | 823 | ||
| 824 | 824 | bool kvm_pmu_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr) | |
| 825 | 825 | { | |
| 826 | - | switch (msr) { | |
| 827 | - | case MSR_CORE_PERF_GLOBAL_STATUS: | |
| 828 | - | case MSR_CORE_PERF_GLOBAL_CTRL: | |
| 829 | - | case MSR_CORE_PERF_GLOBAL_OVF_CTRL: | |
| 830 | - | return kvm_pmu_has_perf_global_ctrl(vcpu_to_pmu(vcpu)); | |
| 831 | - | default: | |
| 832 | - | break; | |
| 833 | - | } | |
| 834 | 826 | return kvm_pmu_call(msr_idx_to_pmc)(vcpu, msr) || | |
| 835 | 827 | kvm_pmu_call(is_valid_msr)(vcpu, msr); | |
| 836 | 828 | } | |
modified arch/x86/kvm/svm/nested.c
| @@ -2125,13 +2125,8 @@ static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu) | |||
| 2125 | 2125 | return false; | |
| 2126 | 2126 | } | |
| 2127 | 2127 | ||
| 2128 | - | if (!nested_svm_merge_msrpm(vcpu)) { | |
| 2129 | - | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 2130 | - | vcpu->run->internal.suberror = | |
| 2131 | - | KVM_INTERNAL_ERROR_EMULATION; | |
| 2132 | - | vcpu->run->internal.ndata = 0; | |
| 2128 | + | if (!nested_svm_merge_msrpm(vcpu)) | |
| 2133 | 2129 | return false; | |
| 2134 | - | } | |
| 2135 | 2130 | ||
| 2136 | 2131 | if (kvm_hv_verify_vp_assist(vcpu)) | |
| 2137 | 2132 | return false; | |
modified arch/x86/kvm/svm/sev.c
| @@ -488,6 +488,20 @@ static void snp_guest_req_cleanup(struct kvm *kvm) | |||
| 488 | 488 | sev->guest_resp_buf = NULL; | |
| 489 | 489 | } | |
| 490 | 490 | ||
| 491 | + | static int sev_alloc_have_run_cpus(struct kvm_sev_info *sev) | |
| 492 | + | { | |
| 493 | + | if (!zalloc_cpumask_var(&sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) | |
| 494 | + | return -ENOMEM; | |
| 495 | + | ||
| 496 | + | return 0; | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | static void sev_free_have_run_cpus(struct kvm_sev_info *sev) | |
| 500 | + | { | |
| 501 | + | free_cpumask_var(sev->have_run_cpus); | |
| 502 | + | memset(&sev->have_run_cpus, 0, sizeof(sev->have_run_cpus)); | |
| 503 | + | } | |
| 504 | + | ||
| 491 | 505 | static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |
| 492 | 506 | struct kvm_sev_init *data, | |
| 493 | 507 | unsigned long vm_type) | |
| @@ -545,10 +559,9 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |||
| 545 | 559 | if (ret) | |
| 546 | 560 | goto e_free_asid; | |
| 547 | 561 | ||
| 548 | - | if (!zalloc_cpumask_var(&sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 549 | - | ret = -ENOMEM; | |
| 562 | + | ret = sev_alloc_have_run_cpus(sev); | |
| 563 | + | if (ret) | |
| 550 | 564 | goto e_free_asid; | |
| 551 | - | } | |
| 552 | 565 | ||
| 553 | 566 | /* This needs to happen after SEV/SNP firmware initialization. */ | |
| 554 | 567 | if (snp_active) { | |
| @@ -566,7 +579,7 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, | |||
| 566 | 579 | return 0; | |
| 567 | 580 | ||
| 568 | 581 | e_free: | |
| 569 | - | free_cpumask_var(sev->have_run_cpus); | |
| 582 | + | sev_free_have_run_cpus(sev); | |
| 570 | 583 | e_free_asid: | |
| 571 | 584 | argp->error = init_args.error; | |
| 572 | 585 | sev_asid_free(sev); | |
| @@ -1125,9 +1138,6 @@ static int sev_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) | |||
| 1125 | 1138 | if (!sev_es_guest(kvm)) | |
| 1126 | 1139 | return -ENOTTY; | |
| 1127 | 1140 | ||
| 1128 | - | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 1129 | - | return -EBUSY; | |
| 1130 | - | ||
| 1131 | 1141 | ret = kvm_lock_all_vcpus(kvm); | |
| 1132 | 1142 | if (ret) | |
| 1133 | 1143 | return ret; | |
| @@ -2035,6 +2045,13 @@ static void sev_migrate_from(struct kvm *dst_kvm, struct kvm *src_kvm) | |||
| 2035 | 2045 | struct kvm_sev_info *mirror; | |
| 2036 | 2046 | unsigned long i; | |
| 2037 | 2047 | ||
| 2048 | + | /* | |
| 2049 | + | * Do cache maintenance on the source VM *before* clearing "SEV active", | |
| 2050 | + | * as memory reclaim flows won't trigger cache maintenance on the VM | |
| 2051 | + | * once it's no longer an SEV VM. | |
| 2052 | + | */ | |
| 2053 | + | sev_writeback_caches(src_kvm); | |
| 2054 | + | ||
| 2038 | 2055 | dst->active = true; | |
| 2039 | 2056 | dst->asid = src->asid; | |
| 2040 | 2057 | dst->handle = src->handle; | |
| @@ -2115,10 +2132,6 @@ static int sev_check_source_vcpus(struct kvm *dst, struct kvm *src) | |||
| 2115 | 2132 | struct kvm_vcpu *src_vcpu; | |
| 2116 | 2133 | unsigned long i; | |
| 2117 | 2134 | ||
| 2118 | - | if (kvm_is_vcpu_creation_in_progress(src) || | |
| 2119 | - | kvm_is_vcpu_creation_in_progress(dst)) | |
| 2120 | - | return -EBUSY; | |
| 2121 | - | ||
| 2122 | 2135 | if (!sev_es_guest(src)) | |
| 2123 | 2136 | return 0; | |
| 2124 | 2137 | ||
| @@ -2187,11 +2200,14 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd) | |||
| 2187 | 2200 | * the set of CPUs from the source. If a CPU was used to run a vCPU in | |
| 2188 | 2201 | * the source VM but is never used for the destination VM, then the CPU | |
| 2189 | 2202 | * can only have cached memory that was accessible to the source VM. | |
| 2203 | + | * Furthermore, KVM *must* perform cache maintenance on the source VM, | |
| 2204 | + | * as the source VM may have access to memory that the destination VM | |
| 2205 | + | * does not, i.e. KVM could skip flushes if memory is reclaimed from | |
| 2206 | + | * the old VM but not the new VM. | |
| 2190 | 2207 | */ | |
| 2191 | - | if (!zalloc_cpumask_var(&dst_sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 2192 | - | ret = -ENOMEM; | |
| 2208 | + | ret = sev_alloc_have_run_cpus(dst_sev); | |
| 2209 | + | if (ret) | |
| 2193 | 2210 | goto out_source_vcpu; | |
| 2194 | - | } | |
| 2195 | 2211 | ||
| 2196 | 2212 | sev_migrate_from(kvm, source_kvm); | |
| 2197 | 2213 | kvm_vm_dead(source_kvm); | |
| @@ -2510,9 +2526,6 @@ static int snp_launch_update_vmsa(struct kvm *kvm, struct kvm_sev_cmd *argp) | |||
| 2510 | 2526 | unsigned long i; | |
| 2511 | 2527 | int ret; | |
| 2512 | 2528 | ||
| 2513 | - | if (kvm_is_vcpu_creation_in_progress(kvm)) | |
| 2514 | - | return -EBUSY; | |
| 2515 | - | ||
| 2516 | 2529 | ret = kvm_lock_all_vcpus(kvm); | |
| 2517 | 2530 | if (ret) | |
| 2518 | 2531 | return ret; | |
| @@ -2888,10 +2901,9 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd) | |||
| 2888 | 2901 | } | |
| 2889 | 2902 | ||
| 2890 | 2903 | mirror_sev = to_kvm_sev_info(kvm); | |
| 2891 | - | if (!zalloc_cpumask_var(&mirror_sev->have_run_cpus, GFP_KERNEL_ACCOUNT)) { | |
| 2892 | - | ret = -ENOMEM; | |
| 2904 | + | ret = sev_alloc_have_run_cpus(mirror_sev); | |
| 2905 | + | if (ret) | |
| 2893 | 2906 | goto e_unlock; | |
| 2894 | - | } | |
| 2895 | 2907 | ||
| 2896 | 2908 | /* | |
| 2897 | 2909 | * The mirror kvm holds an enc_context_owner ref so its asid can't | |
| @@ -2980,13 +2992,17 @@ void sev_vm_destroy(struct kvm *kvm) | |||
| 2980 | 2992 | struct list_head *head = &sev->regions_list; | |
| 2981 | 2993 | struct list_head *pos, *q; | |
| 2982 | 2994 | ||
| 2995 | + | /* | |
| 2996 | + | * Free the mask even if the VM is not *currently* an SEV VM, as it may | |
| 2997 | + | * have been an SEV VM prior to intra-host migration. | |
| 2998 | + | */ | |
| 2999 | + | sev_free_have_run_cpus(sev); | |
| 3000 | + | ||
| 2983 | 3001 | if (!sev_guest(kvm)) | |
| 2984 | 3002 | return; | |
| 2985 | 3003 | ||
| 2986 | 3004 | WARN_ON(!list_empty(&sev->mirror_vms)); | |
| 2987 | 3005 | ||
| 2988 | - | free_cpumask_var(sev->have_run_cpus); | |
| 2989 | - | ||
| 2990 | 3006 | /* | |
| 2991 | 3007 | * If this is a mirror VM, remove it from the owner's list of a mirrors | |
| 2992 | 3008 | * and skip ASID cleanup (the ASID is tied to the lifetime of the owner). | |
| @@ -3616,7 +3632,6 @@ int pre_sev_run(struct vcpu_svm *svm, int cpu) | |||
| 3616 | 3632 | ||
| 3617 | 3633 | sd->sev_vmcbs[asid] = svm->vmcb; | |
| 3618 | 3634 | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID; | |
| 3619 | - | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 3620 | 3635 | return 0; | |
| 3621 | 3636 | } | |
| 3622 | 3637 | ||
modified arch/x86/kvm/svm/svm.c
| @@ -673,16 +673,7 @@ static void clr_dr_intercepts(struct vcpu_svm *svm) | |||
| 673 | 673 | ||
| 674 | 674 | static bool msr_write_intercepted(struct vcpu_svm *svm, u32 msr) | |
| 675 | 675 | { | |
| 676 | - | /* | |
| 677 | - | * For non-nested case: | |
| 678 | - | * If the L01 MSR bitmap does not intercept the MSR, then we need to | |
| 679 | - | * save it. | |
| 680 | - | * | |
| 681 | - | * For nested case: | |
| 682 | - | * If the L02 MSR bitmap does not intercept the MSR, then we need to | |
| 683 | - | * save it. | |
| 684 | - | */ | |
| 685 | - | void *msrpm = is_guest_mode(&svm->vcpu) ? svm->nested.msrpm : svm->msrpm; | |
| 676 | + | void *msrpm = __va(__sme_clr(svm->vmcb->control.msrpm_base_pa)); | |
| 686 | 677 | ||
| 687 | 678 | return svm_test_msr_bitmap_write(msrpm, msr); | |
| 688 | 679 | } | |
| @@ -1902,8 +1893,7 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd) | |||
| 1902 | 1893 | if (sd->next_asid > sd->max_asid) { | |
| 1903 | 1894 | ++sd->asid_generation; | |
| 1904 | 1895 | sd->next_asid = sd->min_asid; | |
| 1905 | - | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; | |
| 1906 | - | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 1896 | + | sd->flush_all_asids = true; | |
| 1907 | 1897 | } | |
| 1908 | 1898 | ||
| 1909 | 1899 | svm->current_vmcb->asid_generation = sd->asid_generation; | |
| @@ -4528,6 +4518,9 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4528 | 4518 | svm->vmcb->control.asid = svm->asid; | |
| 4529 | 4519 | vmcb_mark_dirty(svm->vmcb, VMCB_ASID); | |
| 4530 | 4520 | } | |
| 4521 | + | if (this_cpu_ptr(&svm_data)->flush_all_asids) | |
| 4522 | + | svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; | |
| 4523 | + | ||
| 4531 | 4524 | svm->vmcb->save.cr2 = vcpu->arch.cr2; | |
| 4532 | 4525 | ||
| 4533 | 4526 | if (guest_cpu_cap_has(vcpu, X86_FEATURE_ERAPS) && | |
| @@ -4618,16 +4611,23 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4618 | 4611 | vcpu->arch.nested_run_pending = 0; | |
| 4619 | 4612 | } | |
| 4620 | 4613 | ||
| 4621 | - | svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; | |
| 4614 | + | if (!svm_is_vmrun_failure(svm->vmcb->control.exit_code)) { | |
| 4615 | + | this_cpu_ptr(&svm_data)->flush_all_asids = false; | |
| 4616 | + | svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; | |
| 4622 | 4617 | ||
| 4623 | - | /* | |
| 4624 | - | * Unconditionally mask off the CLEAR_RAP bit, the AND is just as cheap | |
| 4625 | - | * as the TEST+Jcc to avoid it. | |
| 4626 | - | */ | |
| 4627 | - | if (cpu_feature_enabled(X86_FEATURE_ERAPS)) | |
| 4628 | - | svm->vmcb->control.erap_ctl &= ~ERAP_CONTROL_CLEAR_RAP; | |
| 4618 | + | /* | |
| 4619 | + | * Unconditionally mask off the CLEAR_RAP bit, the AND is just | |
| 4620 | + | * as cheap as the TEST+Jcc to avoid it. | |
| 4621 | + | */ | |
| 4622 | + | if (cpu_feature_enabled(X86_FEATURE_ERAPS)) | |
| 4623 | + | svm->vmcb->control.erap_ctl &= ~ERAP_CONTROL_CLEAR_RAP; | |
| 4629 | 4624 | ||
| 4630 | - | vmcb_mark_all_clean(svm->vmcb); | |
| 4625 | + | vmcb_mark_all_clean(svm->vmcb); | |
| 4626 | + | ||
| 4627 | + | if (!msr_write_intercepted(svm, MSR_AMD64_PERF_CNTR_GLOBAL_CTL)) | |
| 4628 | + | rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, | |
| 4629 | + | vcpu_to_pmu(vcpu)->global_ctrl); | |
| 4630 | + | } | |
| 4631 | 4631 | ||
| 4632 | 4632 | /* if exit due to PF check for async PF */ | |
| 4633 | 4633 | if (svm->vmcb->control.exit_code == SVM_EXIT_EXCP_BASE + PF_VECTOR) | |
| @@ -4636,9 +4636,6 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags) | |||
| 4636 | 4636 | ||
| 4637 | 4637 | kvm_clear_available_registers(vcpu, SVM_REGS_LAZY_LOAD_SET); | |
| 4638 | 4638 | ||
| 4639 | - | if (!msr_write_intercepted(svm, MSR_AMD64_PERF_CNTR_GLOBAL_CTL)) | |
| 4640 | - | rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, vcpu_to_pmu(vcpu)->global_ctrl); | |
| 4641 | - | ||
| 4642 | 4639 | trace_kvm_exit(vcpu, KVM_ISA_SVM); | |
| 4643 | 4640 | ||
| 4644 | 4641 | svm_complete_interrupts(vcpu); | |
modified arch/x86/kvm/svm/svm.h
| @@ -376,6 +376,7 @@ struct svm_cpu_data { | |||
| 376 | 376 | u32 next_asid; | |
| 377 | 377 | u32 min_asid; | |
| 378 | 378 | ||
| 379 | + | bool flush_all_asids; | |
| 379 | 380 | bool bp_spec_reduce_set; | |
| 380 | 381 | ||
| 381 | 382 | struct vmcb *save_area; | |
modified arch/x86/kvm/vmx/nested.c
| @@ -1754,6 +1754,9 @@ static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) | |||
| 1754 | 1754 | static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields) | |
| 1755 | 1755 | { | |
| 1756 | 1756 | #ifdef CONFIG_KVM_HYPERV | |
| 1757 | + | const u64 runtime_controls = HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP1 | | |
| 1758 | + | HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2 | | |
| 1759 | + | HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_PROC; | |
| 1757 | 1760 | struct vmcs12 *vmcs12 = vmx->nested.cached_vmcs12; | |
| 1758 | 1761 | struct hv_enlightened_vmcs *evmcs = nested_vmx_evmcs(vmx); | |
| 1759 | 1762 | struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(&vmx->vcpu); | |
| @@ -1762,6 +1765,9 @@ static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields | |||
| 1762 | 1765 | vmcs12->tpr_threshold = evmcs->tpr_threshold; | |
| 1763 | 1766 | vmcs12->guest_rip = evmcs->guest_rip; | |
| 1764 | 1767 | ||
| 1768 | + | if ((hv_clean_fields & runtime_controls) != runtime_controls) | |
| 1769 | + | vmx->nested.force_msr_bitmap_recalc = true; | |
| 1770 | + | ||
| 1765 | 1771 | if (unlikely(!(hv_clean_fields & | |
| 1766 | 1772 | HV_VMX_ENLIGHTENED_CLEAN_FIELD_ENLIGHTENMENTSCONTROL))) { | |
| 1767 | 1773 | hv_vcpu->nested.pa_page_gpa = evmcs->partition_assist_page; | |
| @@ -3465,10 +3471,6 @@ static bool nested_get_vmcs12_pages(struct kvm_vcpu *vcpu) | |||
| 3465 | 3471 | } else { | |
| 3466 | 3472 | pr_debug_ratelimited("%s: no backing for APIC-access address in vmcs12\n", | |
| 3467 | 3473 | __func__); | |
| 3468 | - | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 3469 | - | vcpu->run->internal.suberror = | |
| 3470 | - | KVM_INTERNAL_ERROR_EMULATION; | |
| 3471 | - | vcpu->run->internal.ndata = 0; | |
| 3472 | 3474 | return false; | |
| 3473 | 3475 | } | |
| 3474 | 3476 | } | |
| @@ -3539,11 +3541,6 @@ static bool vmx_get_nested_state_pages(struct kvm_vcpu *vcpu) | |||
| 3539 | 3541 | if (!nested_get_evmcs_page(vcpu)) { | |
| 3540 | 3542 | pr_debug_ratelimited("%s: enlightened vmptrld failed\n", | |
| 3541 | 3543 | __func__); | |
| 3542 | - | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 3543 | - | vcpu->run->internal.suberror = | |
| 3544 | - | KVM_INTERNAL_ERROR_EMULATION; | |
| 3545 | - | vcpu->run->internal.ndata = 0; | |
| 3546 | - | ||
| 3547 | 3544 | return false; | |
| 3548 | 3545 | } | |
| 3549 | 3546 | #endif | |
| @@ -3915,8 +3912,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) | |||
| 3915 | 3912 | ||
| 3916 | 3913 | vmentry_failed: | |
| 3917 | 3914 | vcpu->arch.nested_run_pending = 0; | |
| 3918 | - | if (status == NVMX_VMENTRY_KVM_INTERNAL_ERROR) | |
| 3915 | + | if (status == NVMX_VMENTRY_KVM_INTERNAL_ERROR) { | |
| 3916 | + | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 3917 | + | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | |
| 3918 | + | vcpu->run->internal.ndata = 0; | |
| 3919 | 3919 | return 0; | |
| 3920 | + | } | |
| 3920 | 3921 | if (status == NVMX_VMENTRY_VMEXIT) | |
| 3921 | 3922 | return 1; | |
| 3922 | 3923 | WARN_ON_ONCE(status != NVMX_VMENTRY_VMFAIL); | |
modified arch/x86/kvm/vmx/pmu_intel.c
| @@ -187,6 +187,9 @@ static bool intel_is_valid_msr(struct kvm_vcpu *vcpu, u32 msr) | |||
| 187 | 187 | int ret; | |
| 188 | 188 | ||
| 189 | 189 | switch (msr) { | |
| 190 | + | case MSR_CORE_PERF_GLOBAL_STATUS: | |
| 191 | + | case MSR_CORE_PERF_GLOBAL_CTRL: | |
| 192 | + | case MSR_CORE_PERF_GLOBAL_OVF_CTRL: | |
| 190 | 193 | case MSR_CORE_PERF_FIXED_CTR_CTRL: | |
| 191 | 194 | return kvm_pmu_has_perf_global_ctrl(pmu); | |
| 192 | 195 | case MSR_IA32_PEBS_ENABLE: | |
modified arch/x86/kvm/vmx/tdx.c
| @@ -1995,7 +1995,7 @@ static int tdx_handle_ept_violation(struct kvm_vcpu *vcpu) | |||
| 1995 | 1995 | if (kvm_vcpu_has_events(vcpu) || signal_pending(current)) | |
| 1996 | 1996 | break; | |
| 1997 | 1997 | ||
| 1998 | - | if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) { | |
| 1998 | + | if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu)) { | |
| 1999 | 1999 | ret = -EIO; | |
| 2000 | 2000 | break; | |
| 2001 | 2001 | } | |
| @@ -2728,11 +2728,6 @@ static tdx_vm_state_guard_t tdx_acquire_vm_state_locks(struct kvm *kvm) | |||
| 2728 | 2728 | ||
| 2729 | 2729 | mutex_lock(&kvm->lock); | |
| 2730 | 2730 | ||
| 2731 | - | if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) { | |
| 2732 | - | r = -EBUSY; | |
| 2733 | - | goto out_err; | |
| 2734 | - | } | |
| 2735 | - | ||
| 2736 | 2731 | r = kvm_lock_all_vcpus(kvm); | |
| 2737 | 2732 | if (r) | |
| 2738 | 2733 | goto out_err; | |
modified arch/x86/kvm/x86.c
| @@ -8060,7 +8060,7 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
| 8060 | 8060 | bool req_immediate_exit = false; | |
| 8061 | 8061 | ||
| 8062 | 8062 | if (kvm_request_pending(vcpu)) { | |
| 8063 | - | if (kvm_check_request(KVM_REQ_VM_DEAD, vcpu)) { | |
| 8063 | + | if (kvm_test_request(KVM_REQ_VM_DEAD, vcpu)) { | |
| 8064 | 8064 | r = -EIO; | |
| 8065 | 8065 | goto out; | |
| 8066 | 8066 | } | |
| @@ -8072,6 +8072,10 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) | |||
| 8072 | 8072 | ||
| 8073 | 8073 | if (kvm_check_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu)) { | |
| 8074 | 8074 | if (unlikely(!kvm_nested_call(get_nested_state_pages)(vcpu))) { | |
| 8075 | + | vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; | |
| 8076 | + | vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; | |
| 8077 | + | vcpu->run->internal.ndata = 0; | |
| 8078 | + | kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); | |
| 8075 | 8079 | r = 0; | |
| 8076 | 8080 | goto out; | |
| 8077 | 8081 | } | |
modified arch/x86/mm/mem_encrypt.c
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | #include <linux/cc_platform.h> | |
| 14 | 14 | #include <linux/mem_encrypt.h> | |
| 15 | 15 | #include <linux/virtio_anchor.h> | |
| 16 | + | #include <linux/iommu-dma.h> | |
| 16 | 17 | ||
| 17 | 18 | #include <asm/sev.h> | |
| 18 | 19 | ||
| @@ -30,7 +31,7 @@ bool force_dma_unencrypted(struct device *dev) | |||
| 30 | 31 | * device does not support DMA to addresses that include the | |
| 31 | 32 | * encryption mask. | |
| 32 | 33 | */ | |
| 33 | - | if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT)) { | |
| 34 | + | if (cc_platform_has(CC_ATTR_HOST_MEM_ENCRYPT) && !use_dma_iommu(dev)) { | |
| 34 | 35 | u64 dma_enc_mask = DMA_BIT_MASK(__ffs64(sme_me_mask)); | |
| 35 | 36 | u64 dma_dev_mask = min_not_zero(dev->coherent_dma_mask, | |
| 36 | 37 | dev->bus_dma_limit); | |
modified arch/x86/mm/pat/set_memory.c
| @@ -22,6 +22,7 @@ | |||
| 22 | 22 | #include <linux/cc_platform.h> | |
| 23 | 23 | #include <linux/set_memory.h> | |
| 24 | 24 | #include <linux/memregion.h> | |
| 25 | + | #include <linux/cleanup.h> | |
| 25 | 26 | ||
| 26 | 27 | #include <asm/e820/api.h> | |
| 27 | 28 | #include <asm/processor.h> | |
| @@ -49,7 +50,8 @@ struct cpa_data { | |||
| 49 | 50 | unsigned int flags; | |
| 50 | 51 | unsigned int force_split : 1, | |
| 51 | 52 | force_static_prot : 1, | |
| 52 | - | force_flush_all : 1; | |
| 53 | + | force_flush_all : 1, | |
| 54 | + | init_mm_read_locked : 1; | |
| 53 | 55 | struct page **pages; | |
| 54 | 56 | }; | |
| 55 | 57 | ||
| @@ -409,7 +411,7 @@ static void __cpa_flush_tlb(void *data) | |||
| 409 | 411 | ||
| 410 | 412 | static int collapse_large_pages(unsigned long addr, struct list_head *pgtables); | |
| 411 | 413 | ||
| 412 | - | static void cpa_collapse_large_pages(struct cpa_data *cpa) | |
| 414 | + | static void __cpa_collapse_large_pages(struct cpa_data *cpa) | |
| 413 | 415 | { | |
| 414 | 416 | unsigned long start, addr, end; | |
| 415 | 417 | struct ptdesc *ptdesc, *tmp; | |
| @@ -439,10 +441,30 @@ static void cpa_collapse_large_pages(struct cpa_data *cpa) | |||
| 439 | 441 | ||
| 440 | 442 | list_for_each_entry_safe(ptdesc, tmp, &pgtables, pt_list) { | |
| 441 | 443 | list_del(&ptdesc->pt_list); | |
| 442 | - | pagetable_free(ptdesc); | |
| 444 | + | /* | |
| 445 | + | * Only early alloc'd direct map should not be flagged PG_table | |
| 446 | + | * here and those shouldn't be collapsed. However be abundantly | |
| 447 | + | * cautious and handle the !PG_table case too. | |
| 448 | + | */ | |
| 449 | + | if (PageTable((ptdesc_page(ptdesc)))) | |
| 450 | + | pagetable_dtor_free(ptdesc); | |
| 451 | + | else | |
| 452 | + | pagetable_free(ptdesc); | |
| 443 | 453 | } | |
| 444 | 454 | } | |
| 445 | 455 | ||
| 456 | + | static void cpa_collapse_large_pages(struct cpa_data *cpa) | |
| 457 | + | { | |
| 458 | + | /* | |
| 459 | + | * Take the mmap write lock on init_mm to: | |
| 460 | + | * - Avoid a use-after-free if raced by ptdump (which takes its own | |
| 461 | + | * write lock on init_mm). | |
| 462 | + | * - Serialise concurrent CPA walkers. | |
| 463 | + | */ | |
| 464 | + | scoped_guard(mmap_write_lock, &init_mm) | |
| 465 | + | __cpa_collapse_large_pages(cpa); | |
| 466 | + | } | |
| 467 | + | ||
| 446 | 468 | static void cpa_flush(struct cpa_data *cpa, int cache) | |
| 447 | 469 | { | |
| 448 | 470 | unsigned int i; | |
| @@ -1120,11 +1142,10 @@ set: | |||
| 1120 | 1142 | ||
| 1121 | 1143 | static int | |
| 1122 | 1144 | __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, | |
| 1123 | - | struct ptdesc *ptdesc) | |
| 1145 | + | pte_t *pbase) | |
| 1124 | 1146 | { | |
| 1125 | 1147 | unsigned long lpaddr, lpinc, ref_pfn, pfn, pfninc = 1; | |
| 1126 | - | struct page *base = ptdesc_page(ptdesc); | |
| 1127 | - | pte_t *pbase = (pte_t *)page_address(base); | |
| 1148 | + | struct page *base = virt_to_page(pbase); | |
| 1128 | 1149 | unsigned int i, level; | |
| 1129 | 1150 | pgprot_t ref_prot; | |
| 1130 | 1151 | bool nx, rw; | |
| @@ -1224,16 +1245,20 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, | |||
| 1224 | 1245 | static int split_large_page(struct cpa_data *cpa, pte_t *kpte, | |
| 1225 | 1246 | unsigned long address) | |
| 1226 | 1247 | { | |
| 1227 | - | struct ptdesc *ptdesc; | |
| 1248 | + | pte_t *pte; | |
| 1228 | 1249 | ||
| 1229 | 1250 | spin_unlock(&cpa_lock); | |
| 1230 | - | ptdesc = pagetable_alloc(GFP_KERNEL, 0); | |
| 1251 | + | if (cpa->init_mm_read_locked) | |
| 1252 | + | mmap_read_unlock(&init_mm); | |
| 1253 | + | pte = pte_alloc_one_kernel(&init_mm); | |
| 1254 | + | if (cpa->init_mm_read_locked) | |
| 1255 | + | mmap_read_lock(&init_mm); | |
| 1231 | 1256 | spin_lock(&cpa_lock); | |
| 1232 | - | if (!ptdesc) | |
| 1257 | + | if (!pte) | |
| 1233 | 1258 | return -ENOMEM; | |
| 1234 | 1259 | ||
| 1235 | - | if (__split_large_page(cpa, kpte, address, ptdesc)) | |
| 1236 | - | pagetable_free(ptdesc); | |
| 1260 | + | if (__split_large_page(cpa, kpte, address, pte)) | |
| 1261 | + | pte_free_kernel(&init_mm, pte); | |
| 1237 | 1262 | ||
| 1238 | 1263 | return 0; | |
| 1239 | 1264 | } | |
| @@ -2121,7 +2146,11 @@ static int change_page_attr_set_clr(unsigned long *addr, int numpages, | |||
| 2121 | 2146 | cpa.curpage = 0; | |
| 2122 | 2147 | cpa.force_split = force_split; | |
| 2123 | 2148 | ||
| 2124 | - | ret = __change_page_attr_set_clr(&cpa, 1); | |
| 2149 | + | /* Avoid race with concurrent CPA collapse. */ | |
| 2150 | + | cpa.init_mm_read_locked = true; | |
| 2151 | + | scoped_guard(mmap_read_lock, &init_mm) | |
| 2152 | + | ret = __change_page_attr_set_clr(&cpa, 1); | |
| 2153 | + | cpa.init_mm_read_locked = false; | |
| 2125 | 2154 | ||
| 2126 | 2155 | /* | |
| 2127 | 2156 | * Check whether we really changed something: | |
modified arch/x86/mm/pgtable.c
| @@ -705,47 +705,37 @@ int pmd_clear_huge(pmd_t *pmd) | |||
| 705 | 705 | } | |
| 706 | 706 | ||
| 707 | 707 | #ifdef CONFIG_X86_64 | |
| 708 | - | /** | |
| 709 | - | * pud_free_pmd_page - Clear PUD entry and free PMD page | |
| 710 | - | * @pud: Pointer to a PUD | |
| 711 | - | * @addr: Virtual address associated with PUD | |
| 712 | - | * | |
| 713 | - | * Context: The PUD range has been unmapped and TLB purged. | |
| 714 | - | * Return: 1 if clearing the entry succeeded. 0 otherwise. | |
| 715 | - | * | |
| 716 | - | * NOTE: Callers must allow a single page allocation. | |
| 708 | + | /* | |
| 709 | + | * Given a PUD poitner, detach and free the pointed-to | |
| 710 | + | * PMD page and any PTE page children. The entire range | |
| 711 | + | * under the PUD must not have any valid translations | |
| 712 | + | * and the TLB must have already been flushed. | |
| 717 | 713 | */ | |
| 718 | 714 | int pud_free_pmd_page(pud_t *pud, unsigned long addr) | |
| 719 | 715 | { | |
| 720 | - | pmd_t *pmd, *pmd_sv; | |
| 721 | 716 | struct ptdesc *pt; | |
| 717 | + | pmd_t *pmd; | |
| 722 | 718 | int i; | |
| 723 | 719 | ||
| 724 | 720 | pmd = pud_pgtable(*pud); | |
| 725 | - | pmd_sv = (pmd_t *)__get_free_page(GFP_KERNEL); | |
| 726 | - | if (!pmd_sv) | |
| 727 | - | return 0; | |
| 728 | - | ||
| 729 | - | for (i = 0; i < PTRS_PER_PMD; i++) { | |
| 730 | - | pmd_sv[i] = pmd[i]; | |
| 731 | - | if (!pmd_none(pmd[i])) | |
| 732 | - | pmd_clear(&pmd[i]); | |
| 733 | - | } | |
| 734 | 721 | ||
| 722 | + | /* Detach the PMD page: */ | |
| 735 | 723 | pud_clear(pud); | |
| 736 | 724 | ||
| 737 | - | /* INVLPG to clear all paging-structure caches */ | |
| 725 | + | /* | |
| 726 | + | * PMD and all its descendents are unreachable | |
| 727 | + | * via normal page walks. Make them unreachable | |
| 728 | + | * in cached mid-level walks too: | |
| 729 | + | */ | |
| 738 | 730 | flush_tlb_kernel_range(addr, addr + PAGE_SIZE-1); | |
| 739 | 731 | ||
| 740 | 732 | for (i = 0; i < PTRS_PER_PMD; i++) { | |
| 741 | - | if (!pmd_none(pmd_sv[i])) { | |
| 742 | - | pt = page_ptdesc(pmd_page(pmd_sv[i])); | |
| 733 | + | if (!pmd_none(pmd[i])) { | |
| 734 | + | pt = page_ptdesc(pmd_page(pmd[i])); | |
| 743 | 735 | pagetable_dtor_free(pt); | |
| 744 | 736 | } | |
| 745 | 737 | } | |
| 746 | 738 | ||
| 747 | - | free_page((unsigned long)pmd_sv); | |
| 748 | - | ||
| 749 | 739 | pmd_free(&init_mm, pmd); | |
| 750 | 740 | ||
| 751 | 741 | return 1; | |
modified arch/x86/net/bpf_jit_comp.c
| @@ -3217,16 +3217,21 @@ static void restore_regs(const struct btf_func_model *m, u8 **prog, | |||
| 3217 | 3217 | } | |
| 3218 | 3218 | ||
| 3219 | 3219 | static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, | |
| 3220 | + | struct bpf_tramp_image *im, | |
| 3220 | 3221 | struct bpf_tramp_node *node, int stack_size, | |
| 3221 | 3222 | int run_ctx_off, bool save_ret, | |
| 3222 | 3223 | void *image, void *rw_image) | |
| 3223 | 3224 | { | |
| 3224 | 3225 | u8 *prog = *pprog; | |
| 3225 | - | u8 *jmp_insn; | |
| 3226 | + | u8 *jmp_insn, *skip; | |
| 3226 | 3227 | int ctx_cookie_off = offsetof(struct bpf_tramp_run_ctx, bpf_cookie); | |
| 3227 | 3228 | struct bpf_prog *p = node->link->prog; | |
| 3228 | 3229 | u64 cookie = node->cookie; | |
| 3229 | 3230 | ||
| 3231 | + | /* nop, patched to skip this prog when it is detached */ | |
| 3232 | + | skip = image + (prog - (u8 *)rw_image); | |
| 3233 | + | emit_nops(&prog, X86_PATCH_SIZE); | |
| 3234 | + | ||
| 3230 | 3235 | /* mov rdi, cookie */ | |
| 3231 | 3236 | emit_mov_imm64(&prog, BPF_REG_1, (long) cookie >> 32, (u32) (long) cookie); | |
| 3232 | 3237 | ||
| @@ -3301,6 +3306,8 @@ static int invoke_bpf_prog(const struct btf_func_model *m, u8 **pprog, | |||
| 3301 | 3306 | if (emit_rsb_call(&prog, bpf_trampoline_exit(p), image + (prog - (u8 *)rw_image))) | |
| 3302 | 3307 | return -EINVAL; | |
| 3303 | 3308 | ||
| 3309 | + | bpf_tramp_image_add_skip(im, p, skip, image + (prog - (u8 *)rw_image)); | |
| 3310 | + | ||
| 3304 | 3311 | *pprog = prog; | |
| 3305 | 3312 | return 0; | |
| 3306 | 3313 | } | |
| @@ -3332,6 +3339,7 @@ static int emit_cond_near_jump(u8 **pprog, void *func, void *ip, u8 jmp_cond) | |||
| 3332 | 3339 | } | |
| 3333 | 3340 | ||
| 3334 | 3341 | static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |
| 3342 | + | struct bpf_tramp_image *im, | |
| 3335 | 3343 | struct bpf_tramp_nodes *tl, int stack_size, | |
| 3336 | 3344 | int run_ctx_off, int func_meta_off, bool save_ret, | |
| 3337 | 3345 | void *image, void *rw_image, u64 func_meta, | |
| @@ -3346,7 +3354,7 @@ static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |||
| 3346 | 3354 | func_meta | (cur_cookie << BPF_TRAMP_COOKIE_INDEX_SHIFT)); | |
| 3347 | 3355 | cur_cookie--; | |
| 3348 | 3356 | } | |
| 3349 | - | if (invoke_bpf_prog(m, &prog, tl->nodes[i], stack_size, | |
| 3357 | + | if (invoke_bpf_prog(m, &prog, im, tl->nodes[i], stack_size, | |
| 3350 | 3358 | run_ctx_off, save_ret, image, rw_image)) | |
| 3351 | 3359 | return -EINVAL; | |
| 3352 | 3360 | } | |
| @@ -3355,6 +3363,7 @@ static int invoke_bpf(const struct btf_func_model *m, u8 **pprog, | |||
| 3355 | 3363 | } | |
| 3356 | 3364 | ||
| 3357 | 3365 | static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog, | |
| 3366 | + | struct bpf_tramp_image *im, | |
| 3358 | 3367 | struct bpf_tramp_nodes *tl, int stack_size, | |
| 3359 | 3368 | int run_ctx_off, u8 **branches, | |
| 3360 | 3369 | void *image, void *rw_image) | |
| @@ -3368,7 +3377,7 @@ static int invoke_bpf_mod_ret(const struct btf_func_model *m, u8 **pprog, | |||
| 3368 | 3377 | emit_mov_imm32(&prog, false, BPF_REG_0, 0); | |
| 3369 | 3378 | emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); | |
| 3370 | 3379 | for (i = 0; i < tl->nr_nodes; i++) { | |
| 3371 | - | if (invoke_bpf_prog(m, &prog, tl->nodes[i], stack_size, run_ctx_off, true, | |
| 3380 | + | if (invoke_bpf_prog(m, &prog, im, tl->nodes[i], stack_size, run_ctx_off, true, | |
| 3372 | 3381 | image, rw_image)) | |
| 3373 | 3382 | return -EINVAL; | |
| 3374 | 3383 | ||
| @@ -3640,7 +3649,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3640 | 3649 | } | |
| 3641 | 3650 | ||
| 3642 | 3651 | if (fentry->nr_nodes) { | |
| 3643 | - | if (invoke_bpf(m, &prog, fentry, regs_off, run_ctx_off, func_meta_off, | |
| 3652 | + | if (invoke_bpf(m, &prog, im, fentry, regs_off, run_ctx_off, func_meta_off, | |
| 3644 | 3653 | flags & BPF_TRAMP_F_RET_FENTRY_RET, image, rw_image, | |
| 3645 | 3654 | func_meta, cookie_off)) | |
| 3646 | 3655 | return -EINVAL; | |
| @@ -3652,7 +3661,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3652 | 3661 | if (!branches) | |
| 3653 | 3662 | return -ENOMEM; | |
| 3654 | 3663 | ||
| 3655 | - | if (invoke_bpf_mod_ret(m, &prog, fmod_ret, regs_off, | |
| 3664 | + | if (invoke_bpf_mod_ret(m, &prog, im, fmod_ret, regs_off, | |
| 3656 | 3665 | run_ctx_off, branches, image, rw_image)) { | |
| 3657 | 3666 | ret = -EINVAL; | |
| 3658 | 3667 | goto cleanup; | |
| @@ -3682,8 +3691,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3682 | 3691 | } | |
| 3683 | 3692 | /* remember return value in a stack for bpf prog to access */ | |
| 3684 | 3693 | emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); | |
| 3685 | - | im->ip_after_call = image + (prog - (u8 *)rw_image); | |
| 3686 | - | emit_nops(&prog, X86_PATCH_SIZE); | |
| 3687 | 3694 | } | |
| 3688 | 3695 | ||
| 3689 | 3696 | if (fmod_ret->nr_nodes) { | |
| @@ -3708,7 +3715,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3708 | 3715 | emit_store_stack_imm64(&prog, BPF_REG_0, -func_meta_off, func_meta); | |
| 3709 | 3716 | ||
| 3710 | 3717 | if (fexit->nr_nodes) { | |
| 3711 | - | if (invoke_bpf(m, &prog, fexit, regs_off, run_ctx_off, func_meta_off, | |
| 3718 | + | if (invoke_bpf(m, &prog, im, fexit, regs_off, run_ctx_off, func_meta_off, | |
| 3712 | 3719 | false, image, rw_image, func_meta, cookie_off)) { | |
| 3713 | 3720 | ret = -EINVAL; | |
| 3714 | 3721 | goto cleanup; | |
| @@ -3723,7 +3730,6 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *rw_im | |||
| 3723 | 3730 | * restored to R0. | |
| 3724 | 3731 | */ | |
| 3725 | 3732 | if (flags & BPF_TRAMP_F_CALL_ORIG) { | |
| 3726 | - | im->ip_epilogue = image + (prog - (u8 *)rw_image); | |
| 3727 | 3733 | /* arg1: mov rdi, im */ | |
| 3728 | 3734 | emit_mov_imm64(&prog, BPF_REG_1, (long) im >> 32, (u32) (long) im); | |
| 3729 | 3735 | if (emit_rsb_call(&prog, __bpf_tramp_exit, image + (prog - (u8 *)rw_image))) { | |
| @@ -3811,7 +3817,7 @@ out: | |||
| 3811 | 3817 | int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags, | |
| 3812 | 3818 | struct bpf_tramp_nodes *tnodes, void *func_addr) | |
| 3813 | 3819 | { | |
| 3814 | - | struct bpf_tramp_image im; | |
| 3820 | + | struct bpf_tramp_image im = {}; | |
| 3815 | 3821 | void *image; | |
| 3816 | 3822 | int ret; | |
| 3817 | 3823 | ||
modified arch/x86/pci/fixup.c
| @@ -886,6 +886,105 @@ static void quirk_clear_strap_no_soft_reset_dev2_f0(struct pci_dev *dev) | |||
| 886 | 886 | } | |
| 887 | 887 | } | |
| 888 | 888 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15b8, quirk_clear_strap_no_soft_reset_dev2_f0); | |
| 889 | + | ||
| 890 | + | /* | |
| 891 | + | * Enhanced atomic operations can cause corruption with 64-bit DMA | |
| 892 | + | * on these devices. | |
| 893 | + | */ | |
| 894 | + | #define RX_ENH_ATOMIC_EN BIT(8) | |
| 895 | + | ||
| 896 | + | static const u32 nbio_7_7_pcie_smn_addrs[] = { | |
| 897 | + | 0x111401d0, | |
| 898 | + | 0x111411d0, | |
| 899 | + | 0x111421d0, | |
| 900 | + | 0x111431d0, | |
| 901 | + | 0x111441d0, | |
| 902 | + | 0x112401d0, | |
| 903 | + | 0x112411d0, | |
| 904 | + | 0x112421d0, | |
| 905 | + | 0x112431d0, | |
| 906 | + | 0x112441d0, | |
| 907 | + | 0x112451d0, | |
| 908 | + | 0x113401d0, | |
| 909 | + | 0x114401d0, | |
| 910 | + | }; | |
| 911 | + | ||
| 912 | + | static const u32 nbio_7_11_pcie_smn_addrs[] = { | |
| 913 | + | 0x112401d0, | |
| 914 | + | 0x112411d0, | |
| 915 | + | 0x112421d0, | |
| 916 | + | 0x112431d0, | |
| 917 | + | 0x112441d0, | |
| 918 | + | 0x112451d0, | |
| 919 | + | 0x113401d0, | |
| 920 | + | 0x113411d0, | |
| 921 | + | 0x113421d0, | |
| 922 | + | 0x113431d0, | |
| 923 | + | 0x113441d0, | |
| 924 | + | 0x113451d0, | |
| 925 | + | }; | |
| 926 | + | ||
| 927 | + | static void quirk_amd_nbio_enhanced_atomic(struct pci_dev *host_bridge, | |
| 928 | + | const u32 *smn_addrs, | |
| 929 | + | size_t nr_smn_addrs) | |
| 930 | + | { | |
| 931 | + | bool changed = false; | |
| 932 | + | size_t i; | |
| 933 | + | u32 data; | |
| 934 | + | int ret; | |
| 935 | + | ||
| 936 | + | for (i = 0; i < nr_smn_addrs; i++) { | |
| 937 | + | ret = amd_smn_read(0, smn_addrs[i], &data); | |
| 938 | + | if (ret) | |
| 939 | + | continue; | |
| 940 | + | if (!(data & RX_ENH_ATOMIC_EN)) | |
| 941 | + | continue; | |
| 942 | + | data = data & ~RX_ENH_ATOMIC_EN; | |
| 943 | + | ret = amd_smn_write(0, smn_addrs[i], data); | |
| 944 | + | if (ret) | |
| 945 | + | continue; | |
| 946 | + | if (changed) | |
| 947 | + | continue; | |
| 948 | + | ret = amd_smn_read(0, smn_addrs[i], &data); | |
| 949 | + | if (ret) | |
| 950 | + | continue; | |
| 951 | + | if (data & RX_ENH_ATOMIC_EN) | |
| 952 | + | continue; | |
| 953 | + | changed = true; | |
| 954 | + | } | |
| 955 | + | ||
| 956 | + | if (changed) | |
| 957 | + | pci_info(host_bridge, "enhanced atomics disabled\n"); | |
| 958 | + | } | |
| 959 | + | ||
| 960 | + | static void quirk_amd_nbio_7_7_disable_enhanced_atomic(struct pci_dev *dev) | |
| 961 | + | { | |
| 962 | + | quirk_amd_nbio_enhanced_atomic(dev, nbio_7_7_pcie_smn_addrs, | |
| 963 | + | ARRAY_SIZE(nbio_7_7_pcie_smn_addrs)); | |
| 964 | + | } | |
| 965 | + | ||
| 966 | + | static void quirk_amd_nbio_7_11_disable_enhanced_atomic(struct pci_dev *dev) | |
| 967 | + | { | |
| 968 | + | quirk_amd_nbio_enhanced_atomic(dev, nbio_7_11_pcie_smn_addrs, | |
| 969 | + | ARRAY_SIZE(nbio_7_11_pcie_smn_addrs)); | |
| 970 | + | } | |
| 971 | + | ||
| 972 | + | /* Phoenix, Hawk Point (NBIO 7.7) */ | |
| 973 | + | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x14E8, | |
| 974 | + | quirk_amd_nbio_7_7_disable_enhanced_atomic); | |
| 975 | + | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x14E8, | |
| 976 | + | quirk_amd_nbio_7_7_disable_enhanced_atomic); | |
| 977 | + | ||
| 978 | + | /* Strix, Krackan, Strix Halo (NBIO 7.11) */ | |
| 979 | + | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x1507, | |
| 980 | + | quirk_amd_nbio_7_11_disable_enhanced_atomic); | |
| 981 | + | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1507, | |
| 982 | + | quirk_amd_nbio_7_11_disable_enhanced_atomic); | |
| 983 | + | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x1122, | |
| 984 | + | quirk_amd_nbio_7_11_disable_enhanced_atomic); | |
| 985 | + | DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, 0x1122, | |
| 986 | + | quirk_amd_nbio_7_11_disable_enhanced_atomic); | |
| 987 | + | ||
| 889 | 988 | #endif | |
| 890 | 989 | ||
| 891 | 990 | /* | |
modified arch/x86/um/asm/ptrace.h
| @@ -13,9 +13,7 @@ enum { | |||
| 13 | 13 | }; | |
| 14 | 14 | ||
| 15 | 15 | #include <linux/compiler.h> | |
| 16 | - | #ifndef CONFIG_X86_32 | |
| 17 | - | #define __FRAME_OFFSETS /* Needed to get the R* macros */ | |
| 18 | - | #endif | |
| 16 | + | #define __FRAME_OFFSETS /* Needed to get the register macros */ | |
| 19 | 17 | #include <asm/ptrace-generic.h> | |
| 20 | 18 | ||
| 21 | 19 | #define user_mode(r) UPT_IS_USER(&(r)->regs) | |
modified arch/x86/um/ptrace_32.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | #include <linux/sched.h> | |
| 8 | 8 | #include <linux/uaccess.h> | |
| 9 | 9 | #include <linux/regset.h> | |
| 10 | + | #define __FRAME_OFFSETS | |
| 10 | 11 | #include <asm/ptrace-abi.h> | |
| 11 | 12 | #include <registers.h> | |
| 12 | 13 | #include <skas.h> | |
modified block/blk-cgroup.c
| @@ -2091,6 +2091,7 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, | |||
| 2091 | 2091 | struct request_queue *q = bio->bi_bdev->bd_queue; | |
| 2092 | 2092 | struct blkcg *blkcg = css_to_blkcg(css); | |
| 2093 | 2093 | struct blkcg_gq *blkg; | |
| 2094 | + | unsigned long flags; | |
| 2094 | 2095 | ||
| 2095 | 2096 | rcu_read_lock(); | |
| 2096 | 2097 | blkg = blkg_lookup(blkcg, q); | |
| @@ -2105,11 +2106,11 @@ static inline struct blkcg_gq *blkg_tryget_closest(struct bio *bio, | |||
| 2105 | 2106 | * Fast path failed, we're probably issuing IO in this cgroup the first | |
| 2106 | 2107 | * time, hold lock to create new blkg. | |
| 2107 | 2108 | */ | |
| 2108 | - | spin_lock_irq(&q->queue_lock); | |
| 2109 | + | spin_lock_irqsave(&q->queue_lock, flags); | |
| 2109 | 2110 | blkg = blkg_lookup_create(blkcg, bio->bi_bdev->bd_disk); | |
| 2110 | 2111 | if (blkg) | |
| 2111 | 2112 | blkg = blkg_lookup_tryget(blkg); | |
| 2112 | - | spin_unlock_irq(&q->queue_lock); | |
| 2113 | + | spin_unlock_irqrestore(&q->queue_lock, flags); | |
| 2113 | 2114 | ||
| 2114 | 2115 | return blkg; | |
| 2115 | 2116 | } | |
modified block/blk-mq.c
| @@ -447,16 +447,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, | |||
| 447 | 447 | WRITE_ONCE(rq->deadline, 0); | |
| 448 | 448 | req_ref_set(rq, 1); | |
| 449 | 449 | ||
| 450 | - | if (rq->rq_flags & RQF_USE_SCHED) { | |
| 451 | - | struct elevator_queue *e = data->q->elevator; | |
| 452 | - | ||
| 453 | - | INIT_HLIST_NODE(&rq->hash); | |
| 454 | - | RB_CLEAR_NODE(&rq->rb_node); | |
| 455 | - | ||
| 456 | - | if (e->type->ops.prepare_request) | |
| 457 | - | e->type->ops.prepare_request(rq); | |
| 458 | - | } | |
| 459 | - | ||
| 460 | 450 | return rq; | |
| 461 | 451 | } | |
| 462 | 452 | ||
| @@ -498,6 +488,12 @@ __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data) | |||
| 498 | 488 | return rq_list_pop(data->cached_rqs); | |
| 499 | 489 | } | |
| 500 | 490 | ||
| 491 | + | static bool blk_op_bypass_sched(blk_opf_t opf) | |
| 492 | + | { | |
| 493 | + | return (opf & REQ_OP_MASK) == REQ_OP_FLUSH || | |
| 494 | + | blk_op_is_passthrough(opf); | |
| 495 | + | } | |
| 496 | + | ||
| 501 | 497 | static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |
| 502 | 498 | { | |
| 503 | 499 | struct elevator_mq_ops *ops; | |
| @@ -518,12 +514,10 @@ static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |||
| 518 | 514 | * Flush/passthrough requests are special and go directly to the | |
| 519 | 515 | * dispatch list, they are not subject to the async_depth limit. | |
| 520 | 516 | */ | |
| 521 | - | if ((data->cmd_flags & REQ_OP_MASK) == REQ_OP_FLUSH || | |
| 522 | - | blk_op_is_passthrough(data->cmd_flags)) | |
| 517 | + | if (blk_op_bypass_sched(data->cmd_flags)) | |
| 523 | 518 | return; | |
| 524 | 519 | ||
| 525 | 520 | WARN_ON_ONCE(data->flags & BLK_MQ_REQ_RESERVED); | |
| 526 | - | data->rq_flags |= RQF_USE_SCHED; | |
| 527 | 521 | ||
| 528 | 522 | /* | |
| 529 | 523 | * By default, sync requests have no limit, and async requests are | |
| @@ -534,6 +528,29 @@ static void blk_mq_limit_depth(struct blk_mq_alloc_data *data) | |||
| 534 | 528 | ops->limit_depth(data->cmd_flags, data); | |
| 535 | 529 | } | |
| 536 | 530 | ||
| 531 | + | /* | |
| 532 | + | * Finish initializing a request once it has been claimed for an operation. | |
| 533 | + | * Cached requests are allocated before that operation is known. | |
| 534 | + | */ | |
| 535 | + | static void blk_mq_rq_late_init(struct request *rq, u64 alloc_time_ns) | |
| 536 | + | { | |
| 537 | + | struct elevator_queue *e; | |
| 538 | + | ||
| 539 | + | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 540 | + | ||
| 541 | + | if (!(rq->rq_flags & RQF_SCHED_TAGS) || (rq->rq_flags & RQF_RESV) || | |
| 542 | + | blk_op_bypass_sched(rq->cmd_flags)) | |
| 543 | + | return; | |
| 544 | + | ||
| 545 | + | rq->rq_flags |= RQF_USE_SCHED; | |
| 546 | + | INIT_HLIST_NODE(&rq->hash); | |
| 547 | + | RB_CLEAR_NODE(&rq->rb_node); | |
| 548 | + | ||
| 549 | + | e = rq->q->elevator; | |
| 550 | + | if (e->type->ops.prepare_request) | |
| 551 | + | e->type->ops.prepare_request(rq); | |
| 552 | + | } | |
| 553 | + | ||
| 537 | 554 | static struct request *__blk_mq_alloc_requests(struct blk_mq_alloc_data *data) | |
| 538 | 555 | { | |
| 539 | 556 | struct request_queue *q = data->q; | |
| @@ -562,7 +579,7 @@ retry: | |||
| 562 | 579 | if (data->nr_tags > 1) { | |
| 563 | 580 | rq = __blk_mq_alloc_requests_batch(data); | |
| 564 | 581 | if (rq) { | |
| 565 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 582 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 566 | 583 | return rq; | |
| 567 | 584 | } | |
| 568 | 585 | data->nr_tags = 1; | |
| @@ -590,7 +607,7 @@ retry: | |||
| 590 | 607 | if (!(data->rq_flags & RQF_SCHED_TAGS)) | |
| 591 | 608 | blk_mq_inc_active_requests(data->hctx); | |
| 592 | 609 | rq = blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag); | |
| 593 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 610 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 594 | 611 | return rq; | |
| 595 | 612 | } | |
| 596 | 613 | ||
| @@ -637,8 +654,6 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, | |||
| 637 | 654 | if (plug->nr_ios == 1) | |
| 638 | 655 | return NULL; | |
| 639 | 656 | rq = blk_mq_rq_cache_fill(q, plug, opf, flags); | |
| 640 | - | if (!rq) | |
| 641 | - | return NULL; | |
| 642 | 657 | } else { | |
| 643 | 658 | rq = rq_list_peek(&plug->cached_rqs); | |
| 644 | 659 | if (!rq || rq->q != q) | |
| @@ -646,15 +661,13 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, | |||
| 646 | 661 | ||
| 647 | 662 | if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) | |
| 648 | 663 | return NULL; | |
| 649 | - | if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) | |
| 650 | - | return NULL; | |
| 651 | 664 | ||
| 652 | 665 | rq_list_pop(&plug->cached_rqs); | |
| 653 | - | blk_mq_rq_time_init(rq, blk_time_get_ns()); | |
| 666 | + | rq->cmd_flags = opf; | |
| 667 | + | INIT_LIST_HEAD(&rq->queuelist); | |
| 668 | + | blk_mq_rq_late_init(rq, blk_time_get_ns()); | |
| 654 | 669 | } | |
| 655 | 670 | ||
| 656 | - | rq->cmd_flags = opf; | |
| 657 | - | INIT_LIST_HEAD(&rq->queuelist); | |
| 658 | 671 | return rq; | |
| 659 | 672 | } | |
| 660 | 673 | ||
| @@ -766,7 +779,7 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q, | |||
| 766 | 779 | if (!(data.rq_flags & RQF_SCHED_TAGS)) | |
| 767 | 780 | blk_mq_inc_active_requests(data.hctx); | |
| 768 | 781 | rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag); | |
| 769 | - | blk_mq_rq_time_init(rq, alloc_time_ns); | |
| 782 | + | blk_mq_rq_late_init(rq, alloc_time_ns); | |
| 770 | 783 | rq->__data_len = 0; | |
| 771 | 784 | rq->phys_gap_bit = 0; | |
| 772 | 785 | rq->__sector = (sector_t) -1; | |
| @@ -3060,8 +3073,6 @@ static struct request *blk_mq_get_cached_request(struct blk_plug *plug, | |||
| 3060 | 3073 | if (type != rq->mq_hctx->type && | |
| 3061 | 3074 | (type != HCTX_TYPE_READ || rq->mq_hctx->type != HCTX_TYPE_DEFAULT)) | |
| 3062 | 3075 | return NULL; | |
| 3063 | - | if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) | |
| 3064 | - | return NULL; | |
| 3065 | 3076 | rq_list_pop(&plug->cached_rqs); | |
| 3066 | 3077 | return rq; | |
| 3067 | 3078 | } | |
| @@ -3163,9 +3174,9 @@ void blk_mq_submit_bio(struct bio *bio) | |||
| 3163 | 3174 | new_request: | |
| 3164 | 3175 | if (rq) { | |
| 3165 | 3176 | rq_qos_throttle(rq->q, bio); | |
| 3166 | - | blk_mq_rq_time_init(rq, blk_time_get_ns()); | |
| 3167 | 3177 | rq->cmd_flags = bio->bi_opf; | |
| 3168 | 3178 | INIT_LIST_HEAD(&rq->queuelist); | |
| 3179 | + | blk_mq_rq_late_init(rq, blk_time_get_ns()); | |
| 3169 | 3180 | } else { | |
| 3170 | 3181 | rq = blk_mq_get_new_requests(q, plug, bio); | |
| 3171 | 3182 | if (unlikely(!rq)) { | |
modified block/blk-zoned.c
| @@ -2018,12 +2018,17 @@ static int disk_revalidate_zone_resources(struct gendisk *disk, | |||
| 2018 | 2018 | struct blk_revalidate_zone_args *args) | |
| 2019 | 2019 | { | |
| 2020 | 2020 | struct queue_limits *lim = &disk->queue->limits; | |
| 2021 | + | unsigned long long nr_zones; | |
| 2021 | 2022 | unsigned int pool_size; | |
| 2022 | 2023 | int ret = 0; | |
| 2023 | 2024 | ||
| 2024 | 2025 | args->disk = disk; | |
| 2025 | - | args->nr_zones = | |
| 2026 | - | DIV_ROUND_UP_ULL(get_capacity(disk), lim->chunk_sectors); | |
| 2026 | + | nr_zones = DIV_ROUND_UP_ULL(get_capacity(disk), lim->chunk_sectors); | |
| 2027 | + | if (nr_zones > UINT_MAX) { | |
| 2028 | + | pr_warn("%s: Too many zones (%llu)\n", disk->disk_name, nr_zones); | |
| 2029 | + | return -EINVAL; | |
| 2030 | + | } | |
| 2031 | + | args->nr_zones = nr_zones; | |
| 2027 | 2032 | ||
| 2028 | 2033 | /* Cached zone conditions: 1 byte per zone */ | |
| 2029 | 2034 | args->zones_cond = kzalloc(args->nr_zones, GFP_NOIO); | |
| @@ -2131,6 +2136,12 @@ static int blk_revalidate_zone_cond(struct blk_zone *zone, unsigned int idx, | |||
| 2131 | 2136 | { | |
| 2132 | 2137 | enum blk_zone_cond cond = zone->cond; | |
| 2133 | 2138 | ||
| 2139 | + | if (idx >= args->nr_zones) { | |
| 2140 | + | pr_warn("%s: Zone report index %u exceeds zone count %u\n", | |
| 2141 | + | args->disk->disk_name, idx, args->nr_zones); | |
| 2142 | + | return -EINVAL; | |
| 2143 | + | } | |
| 2144 | + | ||
| 2134 | 2145 | /* Check that the zone condition is consistent with the zone type. */ | |
| 2135 | 2146 | switch (cond) { | |
| 2136 | 2147 | case BLK_ZONE_COND_NOT_WP: | |
modified block/fops.c
| @@ -402,6 +402,11 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) | |||
| 402 | 402 | if (blkdev_dio_invalid(bdev, iocb, iter)) | |
| 403 | 403 | return -EINVAL; | |
| 404 | 404 | ||
| 405 | + | /* HIPRI needs private as bio; HAS_METADATA keeps it as uio_meta */ | |
| 406 | + | if ((iocb->ki_flags & IOCB_HIPRI) && | |
| 407 | + | (iocb->ki_flags & IOCB_HAS_METADATA)) | |
| 408 | + | return -EOPNOTSUPP; | |
| 409 | + | ||
| 405 | 410 | if (iov_iter_rw(iter) == WRITE) { | |
| 406 | 411 | u16 max_write_streams = bdev_max_write_streams(bdev); | |
| 407 | 412 | ||
modified block/mq-deadline.c
| @@ -685,7 +685,7 @@ static void dd_insert_requests(struct blk_mq_hw_ctx *hctx, | |||
| 685 | 685 | blk_mq_free_requests(&free); | |
| 686 | 686 | } | |
| 687 | 687 | ||
| 688 | - | /* Callback from inside blk_mq_rq_ctx_init(). */ | |
| 688 | + | /* Callback from inside blk_mq_rq_late_init(). */ | |
| 689 | 689 | static void dd_prepare_request(struct request *rq) | |
| 690 | 690 | { | |
| 691 | 691 | rq->elv.priv[0] = NULL; | |
modified crypto/aes.c
| @@ -637,7 +637,18 @@ static struct skcipher_alg skcipher_algs[] = { | |||
| 637 | 637 | .decrypt = crypto_aes_cbc_decrypt, | |
| 638 | 638 | }, | |
| 639 | 639 | #endif | |
| 640 | - | #if IS_ENABLED(CONFIG_CRYPTO_CTS) | |
| 640 | + | /* | |
| 641 | + | * Don't register library-based "cts(cbc(aes))" on architectures where | |
| 642 | + | * it might block a "better" implementation from being instantiated via | |
| 643 | + | * the "cts" template. These exclusions are temporary and will go away | |
| 644 | + | * as the arch-optimized AES code is migrated into the library. | |
| 645 | + | */ | |
| 646 | + | #if IS_ENABLED(CONFIG_CRYPTO_CTS) && \ | |
| 647 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 648 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 649 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 650 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 651 | + | IS_ENABLED(CONFIG_SPARC)) | |
| 641 | 652 | { | |
| 642 | 653 | .base.cra_name = "cts(cbc(aes))", | |
| 643 | 654 | .base.cra_driver_name = "cts-cbc-aes-lib", | |
| @@ -687,7 +698,13 @@ static struct skcipher_alg skcipher_algs[] = { | |||
| 687 | 698 | .decrypt = crypto_aes_xctr_crypt, | |
| 688 | 699 | }, | |
| 689 | 700 | #endif | |
| 690 | - | #if IS_ENABLED(CONFIG_CRYPTO_XTS) | |
| 701 | + | /* | |
| 702 | + | * Don't register library-based "xts(aes)" on architectures where it | |
| 703 | + | * might block a "better" implementation from being instantiated via the | |
| 704 | + | * "xts" template. This exclusion is temporary and will go away when | |
| 705 | + | * the library AES-XTS is optimized for SPARC. | |
| 706 | + | */ | |
| 707 | + | #if IS_ENABLED(CONFIG_CRYPTO_XTS) && !IS_ENABLED(CONFIG_SPARC) | |
| 691 | 708 | { | |
| 692 | 709 | .base.cra_name = "xts(aes)", | |
| 693 | 710 | .base.cra_driver_name = "xts-aes-lib", | |
| @@ -980,7 +997,20 @@ static __maybe_unused int crypto_aes_ccm_decrypt(struct aead_request *req) | |||
| 980 | 997 | } | |
| 981 | 998 | ||
| 982 | 999 | static struct aead_alg aead_algs[] = { | |
| 983 | - | #if IS_ENABLED(CONFIG_CRYPTO_GCM) | |
| 1000 | + | /* | |
| 1001 | + | * Don't register library-based "gcm(aes)" and "rfc4106(gcm(aes))" on | |
| 1002 | + | * architectures where they might block a "better" implementation from | |
| 1003 | + | * being instantiated via the "gcm" and "rfc4106" templates. These | |
| 1004 | + | * exclusions are temporary and will go away as the arch-optimized AES | |
| 1005 | + | * code is migrated into the library. | |
| 1006 | + | */ | |
| 1007 | + | #if IS_ENABLED(CONFIG_CRYPTO_GCM) && \ | |
| 1008 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 1009 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 1010 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 1011 | + | IS_ENABLED(CONFIG_RISCV) || \ | |
| 1012 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 1013 | + | IS_ENABLED(CONFIG_SPARC)) | |
| 984 | 1014 | { | |
| 985 | 1015 | .base.cra_name = "gcm(aes)", | |
| 986 | 1016 | .base.cra_driver_name = "gcm-aes-lib", | |
| @@ -1012,7 +1042,20 @@ static struct aead_alg aead_algs[] = { | |||
| 1012 | 1042 | .chunksize = AES_BLOCK_SIZE, | |
| 1013 | 1043 | }, | |
| 1014 | 1044 | #endif /* CONFIG_CRYPTO_GCM */ | |
| 1015 | - | #if IS_ENABLED(CONFIG_CRYPTO_CCM) | |
| 1045 | + | /* | |
| 1046 | + | * Don't register library-based "ccm(aes)" on architectures where it | |
| 1047 | + | * might block a "better" implementation from being instantiated via the | |
| 1048 | + | * "ccm" template. These exclusions are temporary and will go away as | |
| 1049 | + | * the arch-optimized AES code is migrated into the library. | |
| 1050 | + | */ | |
| 1051 | + | #if IS_ENABLED(CONFIG_CRYPTO_CCM) && \ | |
| 1052 | + | !(IS_ENABLED(CONFIG_ARM) || \ | |
| 1053 | + | IS_ENABLED(CONFIG_ARM64) || \ | |
| 1054 | + | IS_ENABLED(CONFIG_PPC) || \ | |
| 1055 | + | IS_ENABLED(CONFIG_RISCV) || \ | |
| 1056 | + | IS_ENABLED(CONFIG_S390) || \ | |
| 1057 | + | IS_ENABLED(CONFIG_SPARC) || \ | |
| 1058 | + | IS_ENABLED(CONFIG_X86)) | |
| 1016 | 1059 | { | |
| 1017 | 1060 | .base.cra_name = "ccm(aes)", | |
| 1018 | 1061 | .base.cra_driver_name = "ccm-aes-lib", | |
modified drivers/accessibility/braille/braille_console.c
| @@ -62,14 +62,50 @@ static void braille_write(u16 *buf) | |||
| 62 | 62 | { | |
| 63 | 63 | static u16 lastwrite[WIDTH]; | |
| 64 | 64 | unsigned char data[1 + 1 + 2*WIDTH + 2 + 1], csum = 0, *c; | |
| 65 | + | struct nbcon_write_context wctxt = { }; | |
| 66 | + | unsigned long flags; | |
| 65 | 67 | u16 out; | |
| 66 | 68 | int i; | |
| 67 | 69 | ||
| 68 | 70 | if (!braille_co) | |
| 69 | 71 | return; | |
| 70 | 72 | ||
| 73 | + | /* | |
| 74 | + | * Braille console is not registered in console_list. Instead, it | |
| 75 | + | * is integrated with VT and shows what appears on the graphical | |
| 76 | + | * console under console_lock(). From this POV it is a legacy | |
| 77 | + | * console. But it calls serial console driver which might be | |
| 78 | + | * converted to the NBCON API. It is similar to | |
| 79 | + | * nbcon_legacy_emit_next_record() except that we should try | |
| 80 | + | * harder to get the lock. Otherwise, the Braille device won't show | |
| 81 | + | * everything what is displayed on the terminal. | |
| 82 | + | * | |
| 83 | + | * In short, simulate the original locking using NBCON API. | |
| 84 | + | */ | |
| 85 | + | if (braille_co->flags & CON_NBCON) { | |
| 86 | + | if (panic_on_this_cpu()) { | |
| 87 | + | /* | |
| 88 | + | * This should be good enough in practice. Most/all | |
| 89 | + | * serial console drivers have the atomic callback. | |
| 90 | + | */ | |
| 91 | + | if (!braille_co->write_atomic) | |
| 92 | + | return; | |
| 93 | + | ||
| 94 | + | local_irq_save(flags); | |
| 95 | + | /* NBCON API strictly requires the ownership. */ | |
| 96 | + | if (!nbcon_braille_try_acquire(braille_co, &wctxt)) { | |
| 97 | + | local_irq_restore(flags); | |
| 98 | + | return; | |
| 99 | + | } | |
| 100 | + | } else { | |
| 101 | + | braille_co->device_lock(braille_co, &flags); | |
| 102 | + | while (!nbcon_braille_try_acquire(braille_co, &wctxt)) | |
| 103 | + | cpu_relax(); | |
| 104 | + | } | |
| 105 | + | } | |
| 106 | + | ||
| 71 | 107 | if (!memcmp(lastwrite, buf, WIDTH * sizeof(*buf))) | |
| 72 | - | return; | |
| 108 | + | goto unlock_nbcon; | |
| 73 | 109 | memcpy(lastwrite, buf, WIDTH * sizeof(*buf)); | |
| 74 | 110 | ||
| 75 | 111 | #define SOH 1 | |
| @@ -102,7 +138,24 @@ static void braille_write(u16 *buf) | |||
| 102 | 138 | *c++ = csum; | |
| 103 | 139 | *c++ = ETX; | |
| 104 | 140 | ||
| 105 | - | braille_co->write(braille_co, data, c - data); | |
| 141 | + | if (braille_co->flags & CON_NBCON) { | |
| 142 | + | nbcon_write_context_set_buf(&wctxt, (char *)data, c - data); | |
| 143 | + | if (panic_on_this_cpu()) | |
| 144 | + | braille_co->write_atomic(braille_co, &wctxt); | |
| 145 | + | else | |
| 146 | + | braille_co->write_thread(braille_co, &wctxt); | |
| 147 | + | } else { | |
| 148 | + | braille_co->write(braille_co, data, c - data); | |
| 149 | + | } | |
| 150 | + | ||
| 151 | + | unlock_nbcon: | |
| 152 | + | if (braille_co->flags & CON_NBCON) { | |
| 153 | + | nbcon_braille_release(&wctxt); | |
| 154 | + | if (panic_on_this_cpu()) | |
| 155 | + | local_irq_restore(flags); | |
| 156 | + | else | |
| 157 | + | braille_co->device_unlock(braille_co, flags); | |
| 158 | + | } | |
| 106 | 159 | } | |
| 107 | 160 | ||
| 108 | 161 | /* Follow the VC cursor*/ | |
modified drivers/android/binder.c
| @@ -2930,8 +2930,9 @@ static int binder_proc_transaction(struct binder_transaction *t, | |||
| 2930 | 2930 | t_outdated->buffer = NULL; | |
| 2931 | 2931 | buffer->transaction = NULL; | |
| 2932 | 2932 | trace_binder_transaction_update_buffer_release(buffer); | |
| 2933 | - | binder_release_entire_buffer(proc, NULL, buffer, false); | |
| 2933 | + | binder_release_entire_buffer(proc, NULL, buffer, true); | |
| 2934 | 2934 | binder_alloc_free_buf(&proc->alloc, buffer); | |
| 2935 | + | binder_free_txn_fixups(t_outdated); | |
| 2935 | 2936 | kfree(t_outdated); | |
| 2936 | 2937 | binder_stats_deleted(BINDER_STAT_TRANSACTION); | |
| 2937 | 2938 | } | |
modified drivers/android/binder/node.rs
| @@ -51,9 +51,9 @@ pub(crate) struct CouldNotDeliverCriticalIncrement; | |||
| 51 | 51 | /// about to drop the weak reference, then the strong increment could be processed after the | |
| 52 | 52 | /// other thread has already exited, which would be too late. | |
| 53 | 53 | /// | |
| 54 | - | /// Note that trying to create a `ListArc` to the node can succeed even if `has_normal_push` is | |
| 54 | + | /// Note that trying to create a `ListArc` to the node can succeed even if `has_pushed_node` is | |
| 55 | 55 | /// set. This is because another thread might just have popped the node from a todo list, but not | |
| 56 | - | /// yet called `do_work`. However, if `has_normal_push` is false, then creating a `ListArc` should | |
| 56 | + | /// yet called `do_work`. However, if `has_pushed_node` is false, then creating a `ListArc` should | |
| 57 | 57 | /// always succeed. | |
| 58 | 58 | /// | |
| 59 | 59 | /// Like the other fields in `NodeInner`, the delivery state is protected by the process lock. | |
| @@ -738,7 +738,21 @@ impl DeliverToRead for Node { | |||
| 738 | 738 | self.do_work_locked(writer, owner_inner) | |
| 739 | 739 | } | |
| 740 | 740 | ||
| 741 | - | fn cancel(self: DArc<Self>) {} | |
| 741 | + | fn cancel(self: DArc<Self>) { | |
| 742 | + | let _drop_outside_lock; | |
| 743 | + | let mut owner_inner = self.owner.inner.lock(); | |
| 744 | + | ||
| 745 | + | // We only do something on BINDER_THREAD_EXIT, not process exit. | |
| 746 | + | if owner_inner.is_dead { | |
| 747 | + | return; | |
| 748 | + | } | |
| 749 | + | ||
| 750 | + | // If BINDER_THREAD_EXIT is invoked on a thread with a pending node refcount update, we | |
| 751 | + | // should move ourselves to ensure the refcount update is still delivered. | |
| 752 | + | if let Some(node) = ListArc::try_from_arc_borrow(self.as_arc_borrow()) { | |
| 753 | + | _drop_outside_lock = owner_inner.push_work(&self.owner, node); | |
| 754 | + | } | |
| 755 | + | } | |
| 742 | 756 | ||
| 743 | 757 | fn should_sync_wakeup(&self) -> bool { | |
| 744 | 758 | false | |
modified drivers/android/binder/node/wrapper.rs
| @@ -57,7 +57,39 @@ impl DeliverToRead for NodeWrapper { | |||
| 57 | 57 | node.do_work_locked(writer, owner_inner) | |
| 58 | 58 | } | |
| 59 | 59 | ||
| 60 | - | fn cancel(self: DArc<Self>) {} | |
| 60 | + | fn cancel(self: DArc<Self>) { | |
| 61 | + | let _drop_outside_lock; | |
| 62 | + | let node = &self.node; | |
| 63 | + | let mut owner_inner = node.owner.inner.lock(); | |
| 64 | + | ||
| 65 | + | // We only do something on BINDER_THREAD_EXIT, not process exit. | |
| 66 | + | if owner_inner.is_dead { | |
| 67 | + | return; | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | // We transfer the responsibility of the node refcount update to the scheduled Node because | |
| 71 | + | // NodeWrapper has no way to re-create the ListArc. | |
| 72 | + | let inner = node.inner.access_mut(&mut owner_inner); | |
| 73 | + | ||
| 74 | + | let ds = &mut inner.delivery_state; | |
| 75 | + | assert!(ds.has_pushed_wrapper); | |
| 76 | + | assert!(ds.has_strong_zero2one); | |
| 77 | + | ds.has_pushed_wrapper = false; | |
| 78 | + | ||
| 79 | + | // We are changing the state to one where the Node is the strong zero2one update instead of | |
| 80 | + | // the wrapper. | |
| 81 | + | ds.has_weak_zero2one = false; | |
| 82 | + | ||
| 83 | + | if !ds.has_pushed_node { | |
| 84 | + | if let Some(node2) = ListArc::try_from_arc_borrow(node.as_arc_borrow()) { | |
| 85 | + | ds.has_pushed_node = true; | |
| 86 | + | _drop_outside_lock = owner_inner.push_work(&node.owner, node2); | |
| 87 | + | } else { | |
| 88 | + | // This can't actually happen. | |
| 89 | + | ds.has_strong_zero2one = false; | |
| 90 | + | } | |
| 91 | + | } | |
| 92 | + | } | |
| 61 | 93 | ||
| 62 | 94 | fn should_sync_wakeup(&self) -> bool { | |
| 63 | 95 | false | |
modified drivers/android/binder/rust_binderfs.c
| @@ -72,6 +72,7 @@ struct binder_features { | |||
| 72 | 72 | bool oneway_spam_detection; | |
| 73 | 73 | bool extended_error; | |
| 74 | 74 | bool freeze_notification; | |
| 75 | + | bool transaction_report; | |
| 75 | 76 | }; | |
| 76 | 77 | ||
| 77 | 78 | static const struct constant_table binderfs_param_stats[] = { | |
| @@ -89,6 +90,7 @@ static struct binder_features binder_features = { | |||
| 89 | 90 | .oneway_spam_detection = true, | |
| 90 | 91 | .extended_error = true, | |
| 91 | 92 | .freeze_notification = true, | |
| 93 | + | .transaction_report = true, | |
| 92 | 94 | }; | |
| 93 | 95 | ||
| 94 | 96 | static inline struct binderfs_info *BINDERFS_SB(const struct super_block *sb) | |
| @@ -566,6 +568,12 @@ static int init_binder_features(struct super_block *sb) | |||
| 566 | 568 | if (IS_ERR(dentry)) | |
| 567 | 569 | return PTR_ERR(dentry); | |
| 568 | 570 | ||
| 571 | + | dentry = rust_binderfs_create_file(dir, "transaction_report", | |
| 572 | + | &binder_features_fops, | |
| 573 | + | &binder_features.transaction_report); | |
| 574 | + | if (IS_ERR(dentry)) | |
| 575 | + | return PTR_ERR(dentry); | |
| 576 | + | ||
| 569 | 577 | return 0; | |
| 570 | 578 | } | |
| 571 | 579 | ||
modified drivers/android/binder/thread.rs
| @@ -686,6 +686,12 @@ impl Thread { | |||
| 686 | 686 | self.inner.lock().push_return_work(reply); | |
| 687 | 687 | } | |
| 688 | 688 | ||
| 689 | + | pub(crate) fn pop_work_even_if_deferred(&self) -> Option<DLArc<dyn DeliverToRead>> { | |
| 690 | + | let mut thread_inner = self.inner.lock(); | |
| 691 | + | thread_inner.process_work_list = true; | |
| 692 | + | thread_inner.pop_work() | |
| 693 | + | } | |
| 694 | + | ||
| 689 | 695 | fn translate_object( | |
| 690 | 696 | &self, | |
| 691 | 697 | obj_index: usize, | |
| @@ -1678,7 +1684,7 @@ impl Thread { | |||
| 1678 | 1684 | self.unwind_transaction_stack(); | |
| 1679 | 1685 | ||
| 1680 | 1686 | // Cancel all pending work items. | |
| 1681 | - | while let Ok(Some(work)) = self.get_work_local(false) { | |
| 1687 | + | while let Some(work) = self.pop_work_even_if_deferred() { | |
| 1682 | 1688 | work.into_arc().cancel(); | |
| 1683 | 1689 | } | |
| 1684 | 1690 | } | |
modified drivers/android/binderfs.c
| @@ -189,12 +189,11 @@ static int binderfs_binder_device_create(struct inode *ref_inode, | |||
| 189 | 189 | goto err; | |
| 190 | 190 | } | |
| 191 | 191 | inode->i_private = device; | |
| 192 | + | binder_add_device(device); | |
| 192 | 193 | d_make_persistent(dentry, inode); | |
| 193 | 194 | fsnotify_create(root->d_inode, dentry); | |
| 194 | 195 | simple_done_creating(dentry); | |
| 195 | 196 | ||
| 196 | - | binder_add_device(device); | |
| 197 | - | ||
| 198 | 197 | return 0; | |
| 199 | 198 | ||
| 200 | 199 | err: | |
modified drivers/ata/libahci.c
| @@ -744,15 +744,28 @@ void ahci_start_fis_rx(struct ata_port *ap) | |||
| 744 | 744 | struct ahci_port_priv *pp = ap->private_data; | |
| 745 | 745 | u32 tmp; | |
| 746 | 746 | ||
| 747 | - | /* set FIS registers */ | |
| 747 | + | /* | |
| 748 | + | * On HBAs that only support 32-bit addressing PxCLBU is read only '0'. | |
| 749 | + | * When applying the AHCI_HFLAG_32BIT_ONLY quirk, PxCLBU is RW, and the | |
| 750 | + | * reset value is Implementation Specific, so we need to clear it to 0. | |
| 751 | + | */ | |
| 748 | 752 | if (hpriv->cap & HOST_CAP_64) | |
| 749 | 753 | writel((pp->cmd_slot_dma >> 16) >> 16, | |
| 750 | 754 | port_mmio + PORT_LST_ADDR_HI); | |
| 755 | + | else if (hpriv->flags & AHCI_HFLAG_32BIT_ONLY) | |
| 756 | + | writel(0, port_mmio + PORT_LST_ADDR_HI); | |
| 751 | 757 | writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR); | |
| 752 | 758 | ||
| 759 | + | /* | |
| 760 | + | * On HBAs that only support 32-bit addressing PxFBU is read only '0'. | |
| 761 | + | * When applying the AHCI_HFLAG_32BIT_ONLY quirk, PxFBU is RW, and the | |
| 762 | + | * reset value is Implementation Specific, so we need to clear it to 0. | |
| 763 | + | */ | |
| 753 | 764 | if (hpriv->cap & HOST_CAP_64) | |
| 754 | 765 | writel((pp->rx_fis_dma >> 16) >> 16, | |
| 755 | 766 | port_mmio + PORT_FIS_ADDR_HI); | |
| 767 | + | else if (hpriv->flags & AHCI_HFLAG_32BIT_ONLY) | |
| 768 | + | writel(0, port_mmio + PORT_FIS_ADDR_HI); | |
| 756 | 769 | writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR); | |
| 757 | 770 | ||
| 758 | 771 | /* enable FIS reception */ | |
modified drivers/ata/libahci_platform.c
| @@ -620,10 +620,10 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev, | |||
| 620 | 620 | of_platform_device_create(child, NULL, NULL); | |
| 621 | 621 | ||
| 622 | 622 | port_dev = of_find_device_by_node(child); | |
| 623 | - | ||
| 624 | 623 | if (port_dev) { | |
| 625 | 624 | rc = ahci_platform_get_regulator(hpriv, port, | |
| 626 | 625 | &port_dev->dev); | |
| 626 | + | put_device(&port_dev->dev); | |
| 627 | 627 | if (rc == -EPROBE_DEFER) | |
| 628 | 628 | goto err_out; | |
| 629 | 629 | } | |
modified drivers/ata/libata-core.c
| @@ -2972,9 +2972,10 @@ static void ata_dev_config_lpm(struct ata_device *dev) | |||
| 2972 | 2972 | (dev->id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2) | |
| 2973 | 2973 | dev->quirks |= ATA_QUIRK_NOLPM; | |
| 2974 | 2974 | ||
| 2975 | - | /* ATI specific quirk */ | |
| 2976 | - | if ((dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI) && | |
| 2977 | - | ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI)) | |
| 2975 | + | /* ATI and AMD specific quirk */ | |
| 2976 | + | if ((dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI_AND_AMD) && | |
| 2977 | + | (ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI) || | |
| 2978 | + | ata_dev_check_adapter(dev, PCI_VENDOR_ID_AMD))) | |
| 2978 | 2979 | dev->quirks |= ATA_QUIRK_NOLPM; | |
| 2979 | 2980 | } | |
| 2980 | 2981 | ||
| @@ -4136,7 +4137,7 @@ static const char * const ata_quirk_names[] = { | |||
| 4136 | 4137 | [__ATA_QUIRK_MAX_SEC] = "maxsec", | |
| 4137 | 4138 | [__ATA_QUIRK_MAX_TRIM_128M] = "maxtrim128m", | |
| 4138 | 4139 | [__ATA_QUIRK_NO_NCQ_ON_ATI] = "noncqonati", | |
| 4139 | - | [__ATA_QUIRK_NO_LPM_ON_ATI] = "nolpmonati", | |
| 4140 | + | [__ATA_QUIRK_NO_LPM_ON_ATI_AND_AMD] = "nolpmonatiandamd", | |
| 4140 | 4141 | [__ATA_QUIRK_NO_ID_DEV_LOG] = "noiddevlog", | |
| 4141 | 4142 | [__ATA_QUIRK_NO_LOG_DIR] = "nologdir", | |
| 4142 | 4143 | [__ATA_QUIRK_NO_FUA] = "nofua", | |
| @@ -4420,15 +4421,15 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { | |||
| 4420 | 4421 | { "Samsung SSD 860*", NULL, ATA_QUIRK_NO_NCQ_TRIM | | |
| 4421 | 4422 | ATA_QUIRK_ZERO_AFTER_TRIM | | |
| 4422 | 4423 | ATA_QUIRK_NO_NCQ_ON_ATI | | |
| 4423 | - | ATA_QUIRK_NO_LPM_ON_ATI }, | |
| 4424 | + | ATA_QUIRK_NO_LPM_ON_ATI_AND_AMD }, | |
| 4424 | 4425 | { "Samsung SSD 870*", NULL, ATA_QUIRK_NO_NCQ_TRIM | | |
| 4425 | 4426 | ATA_QUIRK_ZERO_AFTER_TRIM | | |
| 4426 | 4427 | ATA_QUIRK_NO_NCQ_ON_ATI | | |
| 4427 | - | ATA_QUIRK_NO_LPM_ON_ATI }, | |
| 4428 | + | ATA_QUIRK_NO_LPM_ON_ATI_AND_AMD }, | |
| 4428 | 4429 | { "SAMSUNG*MZ7LH*", NULL, ATA_QUIRK_NO_NCQ_TRIM | | |
| 4429 | 4430 | ATA_QUIRK_ZERO_AFTER_TRIM | | |
| 4430 | 4431 | ATA_QUIRK_NO_NCQ_ON_ATI | | |
| 4431 | - | ATA_QUIRK_NO_LPM_ON_ATI }, | |
| 4432 | + | ATA_QUIRK_NO_LPM_ON_ATI_AND_AMD }, | |
| 4432 | 4433 | { "FCCT*M500*", NULL, ATA_QUIRK_NO_NCQ_TRIM | | |
| 4433 | 4434 | ATA_QUIRK_ZERO_AFTER_TRIM }, | |
| 4434 | 4435 | ||
modified drivers/ata/libata-scsi.c
| @@ -261,12 +261,18 @@ static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) | |||
| 261 | 261 | ||
| 262 | 262 | /* descriptor format */ | |
| 263 | 263 | len = sb[7]; | |
| 264 | - | desc = (char *)scsi_sense_desc_find(sb, len + 8, 9); | |
| 264 | + | desc = (char *)scsi_sense_desc_find(sb, SCSI_SENSE_BUFFERSIZE, 9); | |
| 265 | 265 | if (!desc) { | |
| 266 | - | if (SCSI_SENSE_BUFFERSIZE < len + 14) | |
| 266 | + | /* | |
| 267 | + | * The descriptor is written at sb[8 + len] and is 14 | |
| 268 | + | * bytes long, so it needs len + 22 bytes of buffer. | |
| 269 | + | */ | |
| 270 | + | if (len + 22 > SCSI_SENSE_BUFFERSIZE) | |
| 267 | 271 | return; | |
| 268 | 272 | sb[7] = len + 14; | |
| 269 | 273 | desc = sb + 8 + len; | |
| 274 | + | } else if (desc - sb > SCSI_SENSE_BUFFERSIZE - 14) { | |
| 275 | + | return; | |
| 270 | 276 | } | |
| 271 | 277 | desc[0] = 9; | |
| 272 | 278 | desc[1] = 12; | |
| @@ -2297,10 +2303,9 @@ static unsigned int ata_scsiop_inq_89(struct ata_device *dev, | |||
| 2297 | 2303 | * logical block, so it can hold at most sector_size / 512 pages. | |
| 2298 | 2304 | * | |
| 2299 | 2305 | * Return: the maximum number of 512-byte pages a single translated WRITE SAME | |
| 2300 | - | * command may send to @dev (never less than one), that is the smaller of: | |
| 2301 | - | * - MAX PAGES PER DSM COMMAND (IDENTIFY DEVICE word 105), when the device | |
| 2302 | - | * reports a non-zero limit; and | |
| 2303 | - | * - the logical sector size expressed in 512-byte pages (see above). | |
| 2306 | + | * command may send to @dev, that is the smaller of MAX PAGES PER DSM COMMAND | |
| 2307 | + | * (IDENTIFY DEVICE word 105, when the device reports a non-zero limit) and | |
| 2308 | + | * the logical sector size expressed in 512-byte pages; never less than one. | |
| 2304 | 2309 | */ | |
| 2305 | 2310 | static unsigned int ata_dsm_trim_pages(struct ata_device *dev) | |
| 2306 | 2311 | { | |
| @@ -3054,10 +3059,15 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc) | |||
| 3054 | 3059 | if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) | |
| 3055 | 3060 | qc->dev->sdev->locked = 0; | |
| 3056 | 3061 | ||
| 3057 | - | if (cmd->result) | |
| 3058 | - | ata_scsi_qc_done(qc, false, 0); | |
| 3059 | - | else | |
| 3060 | - | ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION); | |
| 3062 | + | /* | |
| 3063 | + | * Report CHECK CONDITION unless the command was terminated | |
| 3064 | + | * with a host byte set. Only set the status byte, so that the | |
| 3065 | + | * SCSI midlayer internal byte, which scsi_check_sense() may | |
| 3066 | + | * have set from the sense data, is preserved. | |
| 3067 | + | */ | |
| 3068 | + | if (get_host_byte(cmd) == DID_OK) | |
| 3069 | + | set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); | |
| 3070 | + | ata_scsi_qc_done(qc, false, 0); | |
| 3061 | 3071 | goto schedule_deferred; | |
| 3062 | 3072 | } | |
| 3063 | 3073 | ||
modified drivers/base/cacheinfo.c
| @@ -1040,9 +1040,10 @@ static int cacheinfo_cpu_online(unsigned int cpu) | |||
| 1040 | 1040 | rc = cache_add_dev(cpu); | |
| 1041 | 1041 | if (rc) | |
| 1042 | 1042 | goto err; | |
| 1043 | - | if (cpu_map_shared_cache(true, cpu, &cpu_map)) | |
| 1043 | + | if (cpu_map_shared_cache(true, cpu, &cpu_map)) { | |
| 1044 | 1044 | update_per_cpu_data_slice_size(true, cpu, cpu_map); | |
| 1045 | - | sched_update_llc_bytes(cpu); | |
| 1045 | + | sched_update_llc_bytes(cpu_map); | |
| 1046 | + | } | |
| 1046 | 1047 | return 0; | |
| 1047 | 1048 | err: | |
| 1048 | 1049 | free_cache_attributes(cpu); | |
| @@ -1059,10 +1060,10 @@ static int cacheinfo_cpu_pre_down(unsigned int cpu) | |||
| 1059 | 1060 | cpu_cache_sysfs_exit(cpu); | |
| 1060 | 1061 | ||
| 1061 | 1062 | free_cache_attributes(cpu); | |
| 1062 | - | if (nr_shared > 1) | |
| 1063 | + | if (nr_shared > 1) { | |
| 1063 | 1064 | update_per_cpu_data_slice_size(false, cpu, cpu_map); | |
| 1064 | - | ||
| 1065 | - | sched_update_llc_bytes(cpu); | |
| 1065 | + | sched_update_llc_bytes(cpu_map); | |
| 1066 | + | } | |
| 1066 | 1067 | ||
| 1067 | 1068 | return 0; | |
| 1068 | 1069 | } | |
modified drivers/block/drbd/drbd_nl_gen.c
| @@ -638,10 +638,6 @@ const struct genl_split_ops drbd_nl_ops[32] = { | |||
| 638 | 638 | }, | |
| 639 | 639 | }; | |
| 640 | 640 | ||
| 641 | - | static const struct genl_multicast_group drbd_nl_mcgrps[] = { | |
| 642 | - | [DRBD_NLGRP_EVENTS] = { "events", }, | |
| 643 | - | }; | |
| 644 | - | ||
| 645 | 641 | static int __drbd_cfg_context_from_attrs(struct drbd_cfg_context *s, | |
| 646 | 642 | struct nlattr ***ret_nested_attribute_table, | |
| 647 | 643 | struct genl_info *info) | |
modified drivers/block/virtio_blk.c
| @@ -743,6 +743,7 @@ static int virtblk_read_zoned_limits(struct virtio_blk *vblk, | |||
| 743 | 743 | dev_warn(&vdev->dev, "zero write granularity reported\n"); | |
| 744 | 744 | return -ENODEV; | |
| 745 | 745 | } | |
| 746 | + | lim->zone_write_granularity = wg; | |
| 746 | 747 | lim->physical_block_size = wg; | |
| 747 | 748 | lim->io_min = wg; | |
| 748 | 749 | ||
modified drivers/block/zloop.c
| @@ -800,6 +800,27 @@ static void zloop_cmd_workfn(struct work_struct *work) | |||
| 800 | 800 | current->flags = orig_flags; | |
| 801 | 801 | } | |
| 802 | 802 | ||
| 803 | + | static void zloop_fill_zero_rq(struct request *rq, unsigned int zero_from) | |
| 804 | + | { | |
| 805 | + | struct req_iterator iter; | |
| 806 | + | struct bio_vec bv; | |
| 807 | + | unsigned int pos = 0; | |
| 808 | + | unsigned int end, off; | |
| 809 | + | ||
| 810 | + | rq_for_each_segment(bv, rq, iter) { | |
| 811 | + | end = pos + bv.bv_len; | |
| 812 | + | if (end > zero_from) { | |
| 813 | + | if (pos < zero_from) | |
| 814 | + | off = zero_from - pos; | |
| 815 | + | else | |
| 816 | + | off = 0; | |
| 817 | + | memzero_page(bv.bv_page, bv.bv_offset + off, | |
| 818 | + | bv.bv_len - off); | |
| 819 | + | } | |
| 820 | + | pos = end; | |
| 821 | + | } | |
| 822 | + | } | |
| 823 | + | ||
| 803 | 824 | static void zloop_complete_rq(struct request *rq) | |
| 804 | 825 | { | |
| 805 | 826 | struct zloop_cmd *cmd = blk_mq_rq_to_pdu(rq); | |
| @@ -814,13 +835,9 @@ static void zloop_complete_rq(struct request *rq) | |||
| 814 | 835 | pr_err("Zone %u: failed read sector %llu, %llu sectors\n", | |
| 815 | 836 | zone_no, cmd->sector, cmd->nr_sectors); | |
| 816 | 837 | ||
| 817 | - | if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq)) { | |
| 818 | - | /* short read */ | |
| 819 | - | struct bio *bio; | |
| 820 | - | ||
| 821 | - | __rq_for_each_bio(bio, rq) | |
| 822 | - | zero_fill_bio(bio); | |
| 823 | - | } | |
| 838 | + | /* Short read. Zero out the unread tail beyond cmd->ret. */ | |
| 839 | + | if (cmd->ret >= 0 && cmd->ret != blk_rq_bytes(rq)) | |
| 840 | + | zloop_fill_zero_rq(rq, cmd->ret); | |
| 824 | 841 | break; | |
| 825 | 842 | case REQ_OP_WRITE: | |
| 826 | 843 | case REQ_OP_ZONE_APPEND: | |
modified drivers/bluetooth/btintel.c
| @@ -289,7 +289,8 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) | |||
| 289 | 289 | goto unlock; | |
| 290 | 290 | } | |
| 291 | 291 | ||
| 292 | - | bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1)); | |
| 292 | + | bt_dev_err(hdev, "Exception info %.*s", (int)(skb->len - 1), | |
| 293 | + | (char *)(skb->data + 1)); | |
| 293 | 294 | ||
| 294 | 295 | kfree_skb(skb); | |
| 295 | 296 | ||
| @@ -408,8 +409,16 @@ int btintel_load_ddc_config(struct hci_dev *hdev, const char *ddc_name) | |||
| 408 | 409 | /* DDC file contains one or more DDC structure which has | |
| 409 | 410 | * Length (1 byte), DDC ID (2 bytes), and DDC value (Length - 2). | |
| 410 | 411 | */ | |
| 411 | - | while (fw->size > fw_ptr - fw->data) { | |
| 412 | - | u8 cmd_plen = fw_ptr[0] + sizeof(u8); | |
| 412 | + | while (fw->size > (size_t)(fw_ptr - fw->data)) { | |
| 413 | + | size_t remaining = fw->size - (fw_ptr - fw->data); | |
| 414 | + | unsigned int cmd_plen = fw_ptr[0] + 1U; | |
| 415 | + | ||
| 416 | + | if (cmd_plen < 3 || cmd_plen > U8_MAX || cmd_plen > remaining) { | |
| 417 | + | bt_dev_err(hdev, "Malformed DDC record (plen=%u, remaining=%zu)", | |
| 418 | + | cmd_plen, remaining); | |
| 419 | + | release_firmware(fw); | |
| 420 | + | return -EINVAL; | |
| 421 | + | } | |
| 413 | 422 | ||
| 414 | 423 | skb = __hci_cmd_sync(hdev, 0xfc8b, cmd_plen, fw_ptr, | |
| 415 | 424 | HCI_INIT_TIMEOUT); | |
modified drivers/bluetooth/btintel_pcie.c
| @@ -401,9 +401,15 @@ static int btintel_pcie_send_sync(struct btintel_pcie_data *data, | |||
| 401 | 401 | ||
| 402 | 402 | tfd_index = data->ia.tr_hia[BTINTEL_PCIE_TXQ_NUM]; | |
| 403 | 403 | ||
| 404 | - | if (tfd_index > txq->count) | |
| 404 | + | if (tfd_index >= txq->count) | |
| 405 | 405 | return -ERANGE; | |
| 406 | 406 | ||
| 407 | + | if (skb->len > BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN) { | |
| 408 | + | bt_dev_err(hdev, "TX skb too large (%u > %u)", skb->len, | |
| 409 | + | BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN); | |
| 410 | + | return -EMSGSIZE; | |
| 411 | + | } | |
| 412 | + | ||
| 407 | 413 | /* Firmware raises alive interrupt on HCI_OP_RESET or | |
| 408 | 414 | * BTINTEL_HCI_OP_RESET | |
| 409 | 415 | */ | |
| @@ -502,7 +508,7 @@ static int btintel_pcie_submit_rx(struct btintel_pcie_data *data) | |||
| 502 | 508 | ||
| 503 | 509 | frbd_index = data->ia.tr_hia[BTINTEL_PCIE_RXQ_NUM]; | |
| 504 | 510 | ||
| 505 | - | if (frbd_index > rxq->count) | |
| 511 | + | if (frbd_index >= rxq->count) | |
| 506 | 512 | return -ERANGE; | |
| 507 | 513 | ||
| 508 | 514 | /* Prepare for RX submit. It updates the FRBD with the address of DMA | |
| @@ -1093,6 +1099,11 @@ static void btintel_pcie_msix_tx_handle(struct btintel_pcie_data *data) | |||
| 1093 | 1099 | ||
| 1094 | 1100 | txq = &data->txq; | |
| 1095 | 1101 | ||
| 1102 | + | if (cr_hia >= txq->count) { | |
| 1103 | + | bt_dev_err(data->hdev, "TXQ: invalid cr_hia %u", cr_hia); | |
| 1104 | + | return; | |
| 1105 | + | } | |
| 1106 | + | ||
| 1096 | 1107 | while (cr_tia != cr_hia) { | |
| 1097 | 1108 | data->tx_wait_done = true; | |
| 1098 | 1109 | wake_up(&data->tx_wait_q); | |
| @@ -1186,7 +1197,7 @@ static int btintel_pcie_recv_frame(struct btintel_pcie_data *data, | |||
| 1186 | 1197 | { | |
| 1187 | 1198 | int ret; | |
| 1188 | 1199 | u8 pkt_type; | |
| 1189 | - | u16 plen; | |
| 1200 | + | u32 plen; | |
| 1190 | 1201 | u32 pcie_pkt_type; | |
| 1191 | 1202 | void *pdata; | |
| 1192 | 1203 | struct hci_dev *hdev = data->hdev; | |
| @@ -1644,6 +1655,11 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data) | |||
| 1644 | 1655 | ||
| 1645 | 1656 | rxq = &data->rxq; | |
| 1646 | 1657 | ||
| 1658 | + | if (cr_hia >= rxq->count) { | |
| 1659 | + | bt_dev_err(hdev, "RXQ: invalid cr_hia %u", cr_hia); | |
| 1660 | + | return; | |
| 1661 | + | } | |
| 1662 | + | ||
| 1647 | 1663 | /* The firmware sends multiple CD in a single MSI-X and it needs to | |
| 1648 | 1664 | * process all received CDs in this interrupt. | |
| 1649 | 1665 | */ | |
| @@ -1651,6 +1667,12 @@ static void btintel_pcie_msix_rx_handle(struct btintel_pcie_data *data) | |||
| 1651 | 1667 | urbd1 = &rxq->urbd1s[cr_tia]; | |
| 1652 | 1668 | ipc_print_urbd1(data->hdev, urbd1, cr_tia); | |
| 1653 | 1669 | ||
| 1670 | + | if (urbd1->frbd_tag >= rxq->count) { | |
| 1671 | + | bt_dev_err(hdev, "RXQ: invalid frbd_tag %u", | |
| 1672 | + | urbd1->frbd_tag); | |
| 1673 | + | return; | |
| 1674 | + | } | |
| 1675 | + | ||
| 1654 | 1676 | buf = &rxq->bufs[urbd1->frbd_tag]; | |
| 1655 | 1677 | if (!buf) { | |
| 1656 | 1678 | bt_dev_err(hdev, "RXQ: failed to get the DMA buffer for %d", | |
| @@ -1755,7 +1777,7 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id) | |||
| 1755 | 1777 | static int btintel_pcie_setup_irq(struct btintel_pcie_data *data) | |
| 1756 | 1778 | { | |
| 1757 | 1779 | int err; | |
| 1758 | - | int num_irqs, i; | |
| 1780 | + | int num_irqs, i, j; | |
| 1759 | 1781 | ||
| 1760 | 1782 | for (i = 0; i < BTINTEL_PCIE_MSIX_VEC_MAX; i++) | |
| 1761 | 1783 | data->msix_entries[i].entry = i; | |
| @@ -1784,6 +1806,10 @@ static int btintel_pcie_setup_irq(struct btintel_pcie_data *data) | |||
| 1784 | 1806 | KBUILD_MODNAME, | |
| 1785 | 1807 | msix_entry); | |
| 1786 | 1808 | if (err) { | |
| 1809 | + | for (j = 0; j < i; j++) | |
| 1810 | + | devm_free_irq(&data->pdev->dev, | |
| 1811 | + | data->msix_entries[j].vector, | |
| 1812 | + | &data->msix_entries[j]); | |
| 1787 | 1813 | pci_free_irq_vectors(data->pdev); | |
| 1788 | 1814 | data->alloc_vecs = 0; | |
| 1789 | 1815 | return err; | |
| @@ -1855,6 +1881,13 @@ static int btintel_pcie_config_pcie(struct pci_dev *pdev, | |||
| 1855 | 1881 | if (IS_ERR(data->base_addr)) | |
| 1856 | 1882 | return PTR_ERR(data->base_addr); | |
| 1857 | 1883 | ||
| 1884 | + | /* Do shared hardware reset to ensure a clean start before | |
| 1885 | + | * configuring interrupts. | |
| 1886 | + | */ | |
| 1887 | + | err = btintel_pcie_reset_bt(data); | |
| 1888 | + | if (err) | |
| 1889 | + | return err; | |
| 1890 | + | ||
| 1858 | 1891 | err = btintel_pcie_setup_irq(data); | |
| 1859 | 1892 | if (err) | |
| 1860 | 1893 | return err; | |
| @@ -2197,6 +2230,16 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, | |||
| 2197 | 2230 | if (test_bit(BTINTEL_PCIE_RECOVERY_IN_PROGRESS, &data->flags)) | |
| 2198 | 2231 | return -ENODEV; | |
| 2199 | 2232 | ||
| 2233 | + | /* Account for the 4-byte PCIe type header prepended before the | |
| 2234 | + | * DMA copy. Written as a subtraction to avoid wrap-around on | |
| 2235 | + | * attacker-controlled skb->len. | |
| 2236 | + | */ | |
| 2237 | + | if (skb->len > BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN) { | |
| 2238 | + | bt_dev_err(hdev, "Packet too large: %u > %u", skb->len, | |
| 2239 | + | BTINTEL_PCIE_BUFFER_SIZE - BTINTEL_PCIE_HCI_TYPE_LEN); | |
| 2240 | + | return -EMSGSIZE; | |
| 2241 | + | } | |
| 2242 | + | ||
| 2200 | 2243 | /* Due to the fw limitation, the type header of the packet should be | |
| 2201 | 2244 | * 4 bytes unlike 1 byte for UART. In UART, the firmware can read | |
| 2202 | 2245 | * the first byte to get the packet type and redirect the rest of data | |
| @@ -3106,7 +3149,7 @@ static void btintel_pcie_remove(struct pci_dev *pdev) | |||
| 3106 | 3149 | struct msix_entry *msix_entry; | |
| 3107 | 3150 | ||
| 3108 | 3151 | msix_entry = &data->msix_entries[i]; | |
| 3109 | - | free_irq(msix_entry->vector, msix_entry); | |
| 3152 | + | devm_free_irq(&pdev->dev, msix_entry->vector, msix_entry); | |
| 3110 | 3153 | } | |
| 3111 | 3154 | ||
| 3112 | 3155 | pci_free_irq_vectors(pdev); | |
modified drivers/bluetooth/btmtk.c
| @@ -721,7 +721,12 @@ static int btmtk_usb_hci_wmt_sync(struct hci_dev *hdev, | |||
| 721 | 721 | case BTMTK_WMT_FUNC_CTRL: | |
| 722 | 722 | if (!skb_pull_data(data->evt_skb, | |
| 723 | 723 | sizeof(wmt_evt_funcc->status))) { | |
| 724 | - | status = BTMTK_WMT_ON_UNDONE; | |
| 724 | + | /* A plain enable/disable request is acked with just | |
| 725 | + | * the WMT header and no trailing status word; the | |
| 726 | + | * result is carried in the header's own flag byte. | |
| 727 | + | */ | |
| 728 | + | status = wmt_evt->whdr.flag ? BTMTK_WMT_ON_UNDONE : | |
| 729 | + | BTMTK_WMT_ON_DONE; | |
| 725 | 730 | break; | |
| 726 | 731 | } | |
| 727 | 732 | ||
modified drivers/bluetooth/btmtksdio.c
| @@ -217,7 +217,14 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, | |||
| 217 | 217 | } | |
| 218 | 218 | ||
| 219 | 219 | /* Parse and handle the return WMT event */ | |
| 220 | - | wmt_evt = (struct btmtk_hci_wmt_evt *)bdev->evt_skb->data; | |
| 220 | + | wmt_evt = skb_pull_data(bdev->evt_skb, sizeof(*wmt_evt)); | |
| 221 | + | if (!wmt_evt) { | |
| 222 | + | bt_dev_err(hdev, "WMT event too short (%u bytes)", | |
| 223 | + | bdev->evt_skb->len); | |
| 224 | + | err = -EINVAL; | |
| 225 | + | goto err_free_skb; | |
| 226 | + | } | |
| 227 | + | ||
| 221 | 228 | if (wmt_evt->whdr.op != hdr->op) { | |
| 222 | 229 | bt_dev_err(hdev, "Wrong op received %d expected %d", | |
| 223 | 230 | wmt_evt->whdr.op, hdr->op); | |
| @@ -233,6 +240,17 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, | |||
| 233 | 240 | status = BTMTK_WMT_PATCH_DONE; | |
| 234 | 241 | break; | |
| 235 | 242 | case BTMTK_WMT_FUNC_CTRL: | |
| 243 | + | if (!skb_pull_data(bdev->evt_skb, | |
| 244 | + | sizeof(wmt_evt_funcc->status))) { | |
| 245 | + | /* A plain enable/disable request is acked with just | |
| 246 | + | * the WMT header and no trailing status word; the | |
| 247 | + | * result is carried in the header's own flag byte. | |
| 248 | + | */ | |
| 249 | + | status = wmt_evt->whdr.flag ? BTMTK_WMT_ON_UNDONE : | |
| 250 | + | BTMTK_WMT_ON_DONE; | |
| 251 | + | break; | |
| 252 | + | } | |
| 253 | + | ||
| 236 | 254 | wmt_evt_funcc = (struct btmtk_hci_wmt_evt_funcc *)wmt_evt; | |
| 237 | 255 | if (be16_to_cpu(wmt_evt_funcc->status) == 0x404) | |
| 238 | 256 | status = BTMTK_WMT_ON_DONE; | |
| @@ -1244,10 +1262,8 @@ static int btmtksdio_shutdown(struct hci_dev *hdev) | |||
| 1244 | 1262 | wmt_params.status = NULL; | |
| 1245 | 1263 | ||
| 1246 | 1264 | err = mtk_hci_wmt_sync(hdev, &wmt_params); | |
| 1247 | - | if (err < 0) { | |
| 1265 | + | if (err < 0) | |
| 1248 | 1266 | bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err); | |
| 1249 | - | return err; | |
| 1250 | - | } | |
| 1251 | 1267 | ||
| 1252 | 1268 | ignore_wmt_cmd: | |
| 1253 | 1269 | pm_runtime_put_noidle(bdev->dev); | |
modified drivers/bluetooth/btmtkuart.c
| @@ -151,7 +151,14 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, | |||
| 151 | 151 | } | |
| 152 | 152 | ||
| 153 | 153 | /* Parse and handle the return WMT event */ | |
| 154 | - | wmt_evt = (struct btmtk_hci_wmt_evt *)bdev->evt_skb->data; | |
| 154 | + | wmt_evt = skb_pull_data(bdev->evt_skb, sizeof(*wmt_evt)); | |
| 155 | + | if (!wmt_evt) { | |
| 156 | + | bt_dev_err(hdev, "WMT event too short (%u bytes)", | |
| 157 | + | bdev->evt_skb->len); | |
| 158 | + | err = -EINVAL; | |
| 159 | + | goto err_free_wc; | |
| 160 | + | } | |
| 161 | + | ||
| 155 | 162 | if (wmt_evt->whdr.op != hdr->op) { | |
| 156 | 163 | bt_dev_err(hdev, "Wrong op received %d expected %d", | |
| 157 | 164 | wmt_evt->whdr.op, hdr->op); | |
| @@ -167,6 +174,17 @@ static int mtk_hci_wmt_sync(struct hci_dev *hdev, | |||
| 167 | 174 | status = BTMTK_WMT_PATCH_DONE; | |
| 168 | 175 | break; | |
| 169 | 176 | case BTMTK_WMT_FUNC_CTRL: | |
| 177 | + | if (!skb_pull_data(bdev->evt_skb, | |
| 178 | + | sizeof(wmt_evt_funcc->status))) { | |
| 179 | + | /* A plain enable/disable request is acked with just | |
| 180 | + | * the WMT header and no trailing status word; the | |
| 181 | + | * result is carried in the header's own flag byte. | |
| 182 | + | */ | |
| 183 | + | status = wmt_evt->whdr.flag ? BTMTK_WMT_ON_UNDONE : | |
| 184 | + | BTMTK_WMT_ON_DONE; | |
| 185 | + | break; | |
| 186 | + | } | |
| 187 | + | ||
| 170 | 188 | wmt_evt_funcc = (struct btmtk_hci_wmt_evt_funcc *)wmt_evt; | |
| 171 | 189 | if (be16_to_cpu(wmt_evt_funcc->status) == 0x404) | |
| 172 | 190 | status = BTMTK_WMT_ON_DONE; | |
modified drivers/bluetooth/btnxpuart.c
| @@ -1388,9 +1388,11 @@ static int nxp_process_fw_dump(struct hci_dev *hdev, struct sk_buff *skb) | |||
| 1388 | 1388 | msecs_to_jiffies(20000)); | |
| 1389 | 1389 | } | |
| 1390 | 1390 | ||
| 1391 | - | err = hci_devcd_append(hdev, skb_clone(skb, GFP_ATOMIC)); | |
| 1392 | - | if (err < 0) | |
| 1393 | - | goto free_skb; | |
| 1391 | + | if (IS_ENABLED(CONFIG_DEV_COREDUMP)) { | |
| 1392 | + | err = hci_devcd_append(hdev, skb_clone(skb, GFP_ATOMIC)); | |
| 1393 | + | if (err < 0) | |
| 1394 | + | goto free_skb; | |
| 1395 | + | } | |
| 1394 | 1396 | ||
| 1395 | 1397 | if (buf_len == 0) { | |
| 1396 | 1398 | bt_dev_warn(hdev, "==== FW dump complete ==="); | |
modified drivers/bluetooth/btusb.c
| @@ -71,6 +71,15 @@ static struct usb_driver btusb_driver; | |||
| 71 | 71 | #define BTUSB_BROKEN_EXT_SCAN BIT(29) | |
| 72 | 72 | ||
| 73 | 73 | static const struct usb_device_id btusb_table[] = { | |
| 74 | + | /* | |
| 75 | + | * NXP IW610 (0471:0215): the composite device reports Bluetooth | |
| 76 | + | * class at the whole-device level, so the generic entry below | |
| 77 | + | * would also match this WiFi vendor interface. Ignore it here | |
| 78 | + | * first so mwifiex-nxp can bind it instead. | |
| 79 | + | */ | |
| 80 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x0471, 0x0215, 0xff, 0xff, 0xff), | |
| 81 | + | .driver_info = BTUSB_IGNORE }, | |
| 82 | + | ||
| 74 | 83 | /* Generic Bluetooth USB device */ | |
| 75 | 84 | { USB_DEVICE_INFO(0xe0, 0x01, 0x01) }, | |
| 76 | 85 | ||
| @@ -477,6 +486,14 @@ static const struct usb_device_id quirks_table[] = { | |||
| 477 | 486 | { USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL }, | |
| 478 | 487 | { USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL }, | |
| 479 | 488 | ||
| 489 | + | /* | |
| 490 | + | * NXP IW610 BT interfaces (Marvell-lineage silicon, same quirk as | |
| 491 | + | * the 0x1286 entries above). Scoped to the BT interface class, | |
| 492 | + | * not just VID/PID -- see the btusb_table entry above. | |
| 493 | + | */ | |
| 494 | + | { USB_DEVICE_AND_INTERFACE_INFO(0x0471, 0x0215, 0xe0, 0x01, 0x01), | |
| 495 | + | .driver_info = BTUSB_MARVELL }, | |
| 496 | + | ||
| 480 | 497 | /* Intel Bluetooth devices */ | |
| 481 | 498 | { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED }, | |
| 482 | 499 | { USB_DEVICE(0x8087, 0x0026), .driver_info = BTUSB_INTEL_COMBINED }, | |
modified drivers/bluetooth/hci_qca.c
| @@ -2228,8 +2228,8 @@ static void qca_power_off(struct hci_uart *hu) | |||
| 2228 | 2228 | bool sw_ctrl_state; | |
| 2229 | 2229 | struct qca_power *power; | |
| 2230 | 2230 | ||
| 2231 | - | /* From this point we go into power off state. But serial port is | |
| 2232 | - | * still open, stop queueing the IBS data and flush all the buffered | |
| 2231 | + | /* From this point we go into power off state. But serial port may | |
| 2232 | + | * still be open, stop queueing the IBS data and flush all the buffered | |
| 2233 | 2233 | * data in skb's. | |
| 2234 | 2234 | */ | |
| 2235 | 2235 | spin_lock_irqsave(&qca->hci_ibs_lock, flags); | |
| @@ -2251,8 +2251,14 @@ static void qca_power_off(struct hci_uart *hu) | |||
| 2251 | 2251 | case QCA_WCN3990: | |
| 2252 | 2252 | case QCA_WCN3991: | |
| 2253 | 2253 | case QCA_WCN3998: | |
| 2254 | - | host_set_baudrate(hu, 2400); | |
| 2255 | - | qca_send_power_pulse(hu, false); | |
| 2254 | + | /* Both of these write to the serial port which may have | |
| 2255 | + | * already been closed by hci_uart_close(), which closes | |
| 2256 | + | * the port if HCI_QUIRK_NON_PERSISTENT_SETUP is set. | |
| 2257 | + | */ | |
| 2258 | + | if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) { | |
| 2259 | + | host_set_baudrate(hu, 2400); | |
| 2260 | + | qca_send_power_pulse(hu, false); | |
| 2261 | + | } | |
| 2256 | 2262 | break; | |
| 2257 | 2263 | default: | |
| 2258 | 2264 | break; | |
modified drivers/char/mem.c
| @@ -503,7 +503,7 @@ static int mmap_zero_prepare(struct vm_area_desc *desc) | |||
| 503 | 503 | #ifndef CONFIG_MMU | |
| 504 | 504 | return -ENOSYS; | |
| 505 | 505 | #endif | |
| 506 | - | if (vma_desc_test(desc, VMA_SHARED_BIT)) | |
| 506 | + | if (vma_desc_test(desc, VMA_MAYSHARE_BIT)) | |
| 507 | 507 | return shmem_zero_setup_desc(desc); | |
| 508 | 508 | ||
| 509 | 509 | /* | |
modified drivers/char/tpm/tpm-interface.c
| @@ -268,7 +268,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf, | |||
| 268 | 268 | int err; | |
| 269 | 269 | ssize_t len; | |
| 270 | 270 | ||
| 271 | - | len = tpm_transmit(chip, buf->data, PAGE_SIZE); | |
| 271 | + | len = tpm_transmit(chip, buf->data, buf->capacity); | |
| 272 | 272 | if (len < 0) | |
| 273 | 273 | return len; | |
| 274 | 274 | ||
modified drivers/char/tpm/tpm2-cmd.c
| @@ -281,8 +281,10 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max) | |||
| 281 | 281 | } | |
| 282 | 282 | tpm_buf_append_u16(buf, num_bytes); | |
| 283 | 283 | err = tpm_buf_fill_hmac_session(chip, buf); | |
| 284 | - | if (err) | |
| 284 | + | if (err) { | |
| 285 | + | tpm2_end_auth_session(chip); | |
| 285 | 286 | return err; | |
| 287 | + | } | |
| 286 | 288 | ||
| 287 | 289 | err = tpm_transmit_cmd(chip, buf, | |
| 288 | 290 | offsetof(struct tpm2_get_random_out, | |
| @@ -305,7 +307,7 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max) | |||
| 305 | 307 | out = (struct tpm2_get_random_out *)&buf->data[offset]; | |
| 306 | 308 | recd = min_t(u32, be16_to_cpu(out->size), num_bytes); | |
| 307 | 309 | if (tpm_buf_length(buf) < | |
| 308 | - | TPM_HEADER_SIZE + | |
| 310 | + | offset + | |
| 309 | 311 | offsetof(struct tpm2_get_random_out, buffer) + | |
| 310 | 312 | recd) { | |
| 311 | 313 | tpm2_end_auth_session(chip); | |
modified drivers/char/tpm/tpm2-sessions.c
| @@ -975,6 +975,7 @@ static int tpm2_load_null(struct tpm_chip *chip, u32 *null_key) | |||
| 975 | 975 | /* Deduce from the name change TPM interference: */ | |
| 976 | 976 | dev_err(&chip->dev, "null key integrity check failed\n"); | |
| 977 | 977 | tpm2_flush_context(chip, tmp_null_key); | |
| 978 | + | rc = -ENODEV; | |
| 978 | 979 | ||
| 979 | 980 | err: | |
| 980 | 981 | if (rc) { | |
modified drivers/clk/clk-scpi.c
| @@ -73,7 +73,7 @@ static unsigned long scpi_dvfs_recalc_rate(struct clk_hw *hw, | |||
| 73 | 73 | int idx = clk->scpi_ops->dvfs_get_idx(clk->id); | |
| 74 | 74 | const struct scpi_opp *opp; | |
| 75 | 75 | ||
| 76 | - | if (idx < 0) | |
| 76 | + | if (idx < 0 || idx >= clk->info->count) | |
| 77 | 77 | return 0; | |
| 78 | 78 | ||
| 79 | 79 | opp = clk->info->opps + idx; | |
| @@ -272,10 +272,15 @@ static int scpi_clocks_probe(struct platform_device *pdev) | |||
| 272 | 272 | if (match->data != &scpi_dvfs_ops) | |
| 273 | 273 | continue; | |
| 274 | 274 | /* Add the virtual cpufreq device if it's DVFS clock provider */ | |
| 275 | + | if (cpufreq_dev) | |
| 276 | + | continue; | |
| 275 | 277 | cpufreq_dev = platform_device_register_simple("scpi-cpufreq", | |
| 276 | - | -1, NULL, 0); | |
| 277 | - | if (IS_ERR(cpufreq_dev)) | |
| 278 | + | PLATFORM_DEVID_NONE, | |
| 279 | + | NULL, 0); | |
| 280 | + | if (IS_ERR(cpufreq_dev)) { | |
| 278 | 281 | pr_warn("unable to register cpufreq device"); | |
| 282 | + | cpufreq_dev = NULL; | |
| 283 | + | } | |
| 279 | 284 | } | |
| 280 | 285 | return 0; | |
| 281 | 286 | } | |
modified drivers/clk/qcom/gcc-eliza.c
| @@ -3010,8 +3010,6 @@ static const u32 gcc_eliza_critical_cbcrs[] = { | |||
| 3010 | 3010 | 0x26034, /* GCC_CAMERA_XO_CLK */ | |
| 3011 | 3011 | 0x27004, /* GCC_DISP_AHB_CLK */ | |
| 3012 | 3012 | 0x71004, /* GCC_GPU_CFG_AHB_CLK */ | |
| 3013 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3014 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3015 | 3013 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3016 | 3014 | 0x32038, /* GCC_VIDEO_XO_CLK */ | |
| 3017 | 3015 | }; | |
| @@ -3045,6 +3043,10 @@ static const struct regmap_config gcc_eliza_regmap_config = { | |||
| 3045 | 3043 | ||
| 3046 | 3044 | static void clk_eliza_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3047 | 3045 | { | |
| 3046 | + | /* Keep clocks always enabled */ | |
| 3047 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3048 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3049 | + | ||
| 3048 | 3050 | /* FORCE_MEM_CORE_ON for ufs phy ice core and gcc ufs phy axi clocks */ | |
| 3049 | 3051 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3050 | 3052 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_axi_clk, true); | |
modified drivers/clk/qcom/gcc-hawi.c
| @@ -3692,8 +3692,6 @@ static const u32 gcc_hawi_critical_cbcrs[] = { | |||
| 3692 | 3692 | 0x67084, /* GCC_PCIE_1_RSC_CORE_CLK */ | |
| 3693 | 3693 | 0x43014, /* GCC_PCIE_LINK_XO_CLK */ | |
| 3694 | 3694 | 0x6b088, /* GCC_PCIE_RSC_CORE_CLK */ | |
| 3695 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3696 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3697 | 3695 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3698 | 3696 | 0x32028, /* GCC_VIDEO_XO_CLK */ | |
| 3699 | 3697 | }; | |
| @@ -3763,6 +3761,10 @@ static const struct regmap_config gcc_hawi_regmap_config = { | |||
| 3763 | 3761 | ||
| 3764 | 3762 | static void clk_hawi_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3765 | 3763 | { | |
| 3764 | + | /* Keep clocks always enabled */ | |
| 3765 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3766 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3767 | + | ||
| 3766 | 3768 | /* FORCE_MEM_CORE_ON for ufs phy ice core clocks */ | |
| 3767 | 3769 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3768 | 3770 | } | |
modified drivers/clk/qcom/gcc-kaanapali.c
| @@ -3464,8 +3464,6 @@ static const u32 gcc_kaanapali_critical_cbcrs[] = { | |||
| 3464 | 3464 | 0x9f004, /* GCC_EVA_AHB_CLK */ | |
| 3465 | 3465 | 0x9f024, /* GCC_EVA_XO_CLK */ | |
| 3466 | 3466 | 0x71004, /* GCC_GPU_CFG_AHB_CLK */ | |
| 3467 | - | 0x52010, /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3468 | - | 0x52010, /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3469 | 3467 | 0x32004, /* GCC_VIDEO_AHB_CLK */ | |
| 3470 | 3468 | 0x32040, /* GCC_VIDEO_XO_CLK */ | |
| 3471 | 3469 | }; | |
| @@ -3480,6 +3478,10 @@ static const struct regmap_config gcc_kaanapali_regmap_config = { | |||
| 3480 | 3478 | ||
| 3481 | 3479 | static void clk_kaanapali_regs_configure(struct device *dev, struct regmap *regmap) | |
| 3482 | 3480 | { | |
| 3481 | + | /* Keep clocks always enabled */ | |
| 3482 | + | regmap_update_bits(regmap, 0x52010, BIT(20), BIT(20)); /* GCC_PCIE_RSCC_CFG_AHB_CLK */ | |
| 3483 | + | regmap_update_bits(regmap, 0x52010, BIT(21), BIT(21)); /* GCC_PCIE_RSCC_XO_CLK */ | |
| 3484 | + | ||
| 3483 | 3485 | /* FORCE_MEM_CORE_ON for ufs phy ice core clocks */ | |
| 3484 | 3486 | qcom_branch_set_force_mem_core(regmap, gcc_ufs_phy_ice_core_clk, true); | |
| 3485 | 3487 | } | |
modified drivers/clk/qcom/gpucc-glymur.c
| @@ -510,7 +510,7 @@ static struct gdsc gpu_cc_cx_gdsc = { | |||
| 510 | 510 | .name = "gpu_cc_cx_gdsc", | |
| 511 | 511 | }, | |
| 512 | 512 | .pwrsts = PWRSTS_OFF_ON, | |
| 513 | - | .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE, | |
| 513 | + | .flags = RETAIN_FF_ENABLE | VOTABLE, | |
| 514 | 514 | }; | |
| 515 | 515 | ||
| 516 | 516 | static struct clk_regmap *gpu_cc_glymur_clocks[] = { | |
modified drivers/clk/qcom/gpucc-kaanapali.c
| @@ -380,7 +380,7 @@ static struct gdsc gpu_cc_cx_gdsc = { | |||
| 380 | 380 | .name = "gpu_cc_cx_gdsc", | |
| 381 | 381 | }, | |
| 382 | 382 | .pwrsts = PWRSTS_OFF_ON, | |
| 383 | - | .flags = POLL_CFG_GDSCR | RETAIN_FF_ENABLE, | |
| 383 | + | .flags = RETAIN_FF_ENABLE | VOTABLE, | |
| 384 | 384 | }; | |
| 385 | 385 | ||
| 386 | 386 | static struct clk_regmap *gpu_cc_kaanapali_clocks[] = { | |
modified drivers/clk/spacemit/ccu-k3.c
| @@ -30,14 +30,87 @@ static const struct ccu_pll_rate_tbl pll2_rate_tbl[] = { | |||
| 30 | 30 | }; | |
| 31 | 31 | ||
| 32 | 32 | static const struct ccu_pll_rate_tbl pll3_rate_tbl[] = { | |
| 33 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 34 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 35 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 36 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 37 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 38 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 39 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 40 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 41 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 42 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 43 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 44 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 45 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 46 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 47 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 48 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 49 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 50 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 51 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 52 | + | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 53 | + | CCU_PLLA_RATE(2050000000UL, 0x0b2a2d55, 0x00005500, 0xa0558686), | |
| 54 | + | CCU_PLLA_RATE(2100000000UL, 0x0b2b3000, 0x00000000, 0xa0558787), | |
| 55 | + | CCU_PLLA_RATE(2150000000UL, 0x0b2c32aa, 0x0000ab00, 0xa0558787), | |
| 33 | 56 | CCU_PLLA_RATE(2200000000UL, 0x0b2d3555, 0x00005500, 0xa0558787), | |
| 57 | + | CCU_PLLA_RATE(2250000000UL, 0x0b2e3800, 0x00000000, 0xa0558888), | |
| 58 | + | CCU_PLLA_RATE(2300000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0558888), | |
| 59 | + | CCU_PLLA_RATE(2350000000UL, 0x0b303d55, 0x00005500, 0xa0558888), | |
| 60 | + | CCU_PLLA_RATE(2400000000UL, 0x0b320000, 0x00000000, 0xa0558989), | |
| 34 | 61 | }; | |
| 35 | 62 | ||
| 36 | 63 | static const struct ccu_pll_rate_tbl pll4_rate_tbl[] = { | |
| 64 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 65 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 66 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 67 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 68 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 69 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 70 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 71 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 72 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 73 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 74 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 75 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 76 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 77 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 78 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 79 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 80 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 81 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 82 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 83 | + | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 84 | + | CCU_PLLA_RATE(2050000000UL, 0x0b2a2d55, 0x00005500, 0xa0558686), | |
| 85 | + | CCU_PLLA_RATE(2100000000UL, 0x0b2b3000, 0x00000000, 0xa0558787), | |
| 86 | + | CCU_PLLA_RATE(2150000000UL, 0x0b2c32aa, 0x0000ab00, 0xa0558787), | |
| 37 | 87 | CCU_PLLA_RATE(2200000000UL, 0x0b2d3555, 0x00005500, 0xa0558787), | |
| 88 | + | CCU_PLLA_RATE(2250000000UL, 0x0b2e3800, 0x00000000, 0xa0558888), | |
| 89 | + | CCU_PLLA_RATE(2300000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0558888), | |
| 90 | + | CCU_PLLA_RATE(2350000000UL, 0x0b303d55, 0x00005500, 0xa0558888), | |
| 91 | + | CCU_PLLA_RATE(2400000000UL, 0x0b320000, 0x00000000, 0xa0558989), | |
| 38 | 92 | }; | |
| 39 | 93 | ||
| 40 | 94 | static const struct ccu_pll_rate_tbl pll5_rate_tbl[] = { | |
| 95 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 96 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 97 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 98 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 99 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 100 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 101 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 102 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 103 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 104 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 105 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 106 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 107 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 108 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 109 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 110 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 111 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 112 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 113 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 41 | 114 | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 42 | 115 | }; | |
| 43 | 116 | ||
| @@ -50,6 +123,25 @@ static const struct ccu_pll_rate_tbl pll7_rate_tbl[] = { | |||
| 50 | 123 | }; | |
| 51 | 124 | ||
| 52 | 125 | static const struct ccu_pll_rate_tbl pll8_rate_tbl[] = { | |
| 126 | + | CCU_PLLA_RATE(1050000000UL, 0x0b2b3000, 0x00000000, 0xa0458080), | |
| 127 | + | CCU_PLLA_RATE(1100000000UL, 0x0b2d3555, 0x00005500, 0xa0458181), | |
| 128 | + | CCU_PLLA_RATE(1150000000UL, 0x0b2f3aaa, 0x0000ab00, 0xa0458181), | |
| 129 | + | CCU_PLLA_RATE(1200000000UL, 0x0b320000, 0x00000000, 0xa0458181), | |
| 130 | + | CCU_PLLA_RATE(1250000000UL, 0x0b340555, 0x00005500, 0xa0458181), | |
| 131 | + | CCU_PLLA_RATE(1300000000UL, 0x0b360aaa, 0x0000ab00, 0xa0458282), | |
| 132 | + | CCU_PLLA_RATE(1350000000UL, 0x0b381000, 0x00000000, 0xa0458282), | |
| 133 | + | CCU_PLLA_RATE(1400000000UL, 0x0b3a1555, 0x00005500, 0xa0458282), | |
| 134 | + | CCU_PLLA_RATE(1450000000UL, 0x0b3c1aaa, 0x0000ab00, 0xa0458383), | |
| 135 | + | CCU_PLLA_RATE(1500000000UL, 0x0b3e2000, 0x00000000, 0xa0458383), | |
| 136 | + | CCU_PLLA_RATE(1550000000UL, 0x0b402555, 0x00005500, 0xa0458383), | |
| 137 | + | CCU_PLLA_RATE(1600000000UL, 0x0b422aaa, 0x0000ab00, 0xa0458484), | |
| 138 | + | CCU_PLLA_RATE(1650000000UL, 0x0b443000, 0x00000000, 0xa0458484), | |
| 139 | + | CCU_PLLA_RATE(1700000000UL, 0x0b463555, 0x00005500, 0xa0458484), | |
| 140 | + | CCU_PLLA_RATE(1750000000UL, 0x0b483aaa, 0x0000ab00, 0xa0458585), | |
| 141 | + | CCU_PLLA_RATE(1800000000UL, 0x0b4b0000, 0x00000000, 0xa0458585), | |
| 142 | + | CCU_PLLA_RATE(1850000000UL, 0x0b4d0555, 0x00005500, 0xa0458585), | |
| 143 | + | CCU_PLLA_RATE(1900000000UL, 0x0b4f0aaa, 0x0000ab00, 0xa0458686), | |
| 144 | + | CCU_PLLA_RATE(1950000000UL, 0x0b511000, 0x00000000, 0xa0458686), | |
| 53 | 145 | CCU_PLLA_RATE(2000000000UL, 0x0b292aaa, 0x0000ab00, 0xa0558686), | |
| 54 | 146 | }; | |
| 55 | 147 | ||
modified drivers/clk/ti/composite.c
| @@ -52,7 +52,7 @@ static const struct clk_ops ti_composite_gate_ops = { | |||
| 52 | 52 | ||
| 53 | 53 | struct component_clk { | |
| 54 | 54 | int num_parents; | |
| 55 | - | struct clk_parent_data *parent_data; | |
| 55 | + | const char **parent_names; | |
| 56 | 56 | struct device_node *node; | |
| 57 | 57 | int type; | |
| 58 | 58 | struct clk_hw *hw; | |
| @@ -116,7 +116,7 @@ static void __init _register_composite(void *user, | |||
| 116 | 116 | struct clk_hw_omap_comp *cclk = to_clk_hw_comp(hw); | |
| 117 | 117 | struct component_clk *comp; | |
| 118 | 118 | int num_parents = 0; | |
| 119 | - | struct clk_parent_data *parent_data = NULL; | |
| 119 | + | const char **parent_names = NULL; | |
| 120 | 120 | const char *name; | |
| 121 | 121 | int i; | |
| 122 | 122 | int ret; | |
| @@ -155,7 +155,7 @@ static void __init _register_composite(void *user, | |||
| 155 | 155 | continue; | |
| 156 | 156 | if (comp->num_parents) { | |
| 157 | 157 | num_parents = comp->num_parents; | |
| 158 | - | parent_data = comp->parent_data; | |
| 158 | + | parent_names = comp->parent_names; | |
| 159 | 159 | break; | |
| 160 | 160 | } | |
| 161 | 161 | } | |
| @@ -166,8 +166,8 @@ static void __init _register_composite(void *user, | |||
| 166 | 166 | } | |
| 167 | 167 | ||
| 168 | 168 | name = ti_dt_clk_name(node); | |
| 169 | - | clk = clk_register_composite_pdata(NULL, name, | |
| 170 | - | parent_data, num_parents, | |
| 169 | + | clk = clk_register_composite(NULL, name, | |
| 170 | + | parent_names, num_parents, | |
| 171 | 171 | _get_hw(cclk, CLK_COMPONENT_TYPE_MUX), | |
| 172 | 172 | &ti_clk_mux_ops, | |
| 173 | 173 | _get_hw(cclk, CLK_COMPONENT_TYPE_DIVIDER), | |
| @@ -190,7 +190,7 @@ cleanup: | |||
| 190 | 190 | if (!cclk->comp_clks[i]) | |
| 191 | 191 | continue; | |
| 192 | 192 | list_del(&cclk->comp_clks[i]->link); | |
| 193 | - | kfree(cclk->comp_clks[i]->parent_data); | |
| 193 | + | kfree(cclk->comp_clks[i]->parent_names); | |
| 194 | 194 | kfree(cclk->comp_clks[i]); | |
| 195 | 195 | } | |
| 196 | 196 | ||
| @@ -237,9 +237,8 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw, | |||
| 237 | 237 | int type) | |
| 238 | 238 | { | |
| 239 | 239 | unsigned int num_parents; | |
| 240 | - | struct clk_parent_data *parent_data; | |
| 240 | + | const char **parent_names; | |
| 241 | 241 | struct component_clk *clk; | |
| 242 | - | unsigned int i; | |
| 243 | 242 | ||
| 244 | 243 | num_parents = of_clk_get_parent_count(node); | |
| 245 | 244 | ||
| @@ -248,21 +247,20 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw, | |||
| 248 | 247 | return -EINVAL; | |
| 249 | 248 | } | |
| 250 | 249 | ||
| 251 | - | parent_data = kzalloc_objs(*parent_data, num_parents); | |
| 252 | - | if (!parent_data) | |
| 250 | + | parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL); | |
| 251 | + | if (!parent_names) | |
| 253 | 252 | return -ENOMEM; | |
| 254 | 253 | ||
| 255 | - | for (i = 0; i < num_parents; i++) | |
| 256 | - | parent_data[i].index = i; | |
| 254 | + | of_clk_parent_fill(node, parent_names, num_parents); | |
| 257 | 255 | ||
| 258 | 256 | clk = kzalloc_obj(*clk); | |
| 259 | 257 | if (!clk) { | |
| 260 | - | kfree(parent_data); | |
| 258 | + | kfree(parent_names); | |
| 261 | 259 | return -ENOMEM; | |
| 262 | 260 | } | |
| 263 | 261 | ||
| 264 | 262 | clk->num_parents = num_parents; | |
| 265 | - | clk->parent_data = parent_data; | |
| 263 | + | clk->parent_names = parent_names; | |
| 266 | 264 | clk->hw = hw; | |
| 267 | 265 | clk->node = node; | |
| 268 | 266 | clk->type = type; | |
modified drivers/cpufreq/cpufreq.c
| @@ -2590,8 +2590,8 @@ static void cpufreq_update_pressure(struct cpufreq_policy *policy) | |||
| 2590 | 2590 | ||
| 2591 | 2591 | cpu = cpumask_first(policy->related_cpus); | |
| 2592 | 2592 | max_freq = arch_scale_freq_ref(cpu); | |
| 2593 | - | if (!max_freq) | |
| 2594 | - | max_freq = policy->cpuinfo.max_freq; | |
| 2593 | + | if (!max_freq && cpufreq_driver->scale_freq_ref) | |
| 2594 | + | max_freq = cpufreq_driver->scale_freq_ref(policy); | |
| 2595 | 2595 | ||
| 2596 | 2596 | capped_freq = policy->max; | |
| 2597 | 2597 | ||
modified drivers/cpufreq/intel_pstate.c
| @@ -1135,6 +1135,14 @@ static bool hybrid_clear_max_perf_cpu(void) | |||
| 1135 | 1135 | return ret; | |
| 1136 | 1136 | } | |
| 1137 | 1137 | ||
| 1138 | + | static unsigned int intel_pstate_scale_freq_ref(struct cpufreq_policy *policy) | |
| 1139 | + | { | |
| 1140 | + | if (READ_ONCE(all_cpu_data[policy->cpu]->capacity_perf)) | |
| 1141 | + | return policy->cpuinfo.max_freq; | |
| 1142 | + | ||
| 1143 | + | return 0; | |
| 1144 | + | } | |
| 1145 | + | ||
| 1138 | 1146 | static void intel_pstate_update_freq_limits(struct cpudata *cpu) | |
| 1139 | 1147 | { | |
| 1140 | 1148 | int scaling = cpu->pstate.scaling; | |
| @@ -3088,6 +3096,7 @@ static struct cpufreq_driver intel_pstate = { | |||
| 3088 | 3096 | .offline = intel_pstate_cpu_offline, | |
| 3089 | 3097 | .online = intel_pstate_cpu_online, | |
| 3090 | 3098 | .update_limits = intel_pstate_update_limits, | |
| 3099 | + | .scale_freq_ref = intel_pstate_scale_freq_ref, | |
| 3091 | 3100 | .name = "intel_pstate", | |
| 3092 | 3101 | }; | |
| 3093 | 3102 | ||
| @@ -3411,6 +3420,7 @@ static struct cpufreq_driver intel_cpufreq = { | |||
| 3411 | 3420 | .suspend = intel_cpufreq_suspend, | |
| 3412 | 3421 | .resume = intel_pstate_resume, | |
| 3413 | 3422 | .update_limits = intel_pstate_update_limits, | |
| 3423 | + | .scale_freq_ref = intel_pstate_scale_freq_ref, | |
| 3414 | 3424 | .name = "intel_cpufreq", | |
| 3415 | 3425 | }; | |
| 3416 | 3426 | ||
modified drivers/crypto/caam/jr.c
| @@ -583,12 +583,29 @@ static int caam_jr_probe(struct platform_device *pdev) | |||
| 583 | 583 | struct caam_drv_private_jr *jrpriv; | |
| 584 | 584 | static int total_jobrs; | |
| 585 | 585 | void __iomem *ctrl; | |
| 586 | + | struct resource *r; | |
| 586 | 587 | int error; | |
| 587 | 588 | int irq; | |
| 588 | 589 | ||
| 589 | - | ctrl = devm_platform_ioremap_resource(pdev, 0); | |
| 590 | - | if (IS_ERR(ctrl)) | |
| 591 | - | return PTR_ERR(ctrl); | |
| 590 | + | /* | |
| 591 | + | * The job rings live inside the register window of their parent | |
| 592 | + | * fsl,sec-v4.0 node, which caam_probe() already reserves (and maps) | |
| 593 | + | * via devm_of_iomap(). A requested region that overlaps that | |
| 594 | + | * reservation, e.g. from devm_platform_ioremap_resource(), would | |
| 595 | + | * therefore fail with -EBUSY, so map the registers without claiming | |
| 596 | + | * the region here. | |
| 597 | + | */ | |
| 598 | + | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 599 | + | if (!r) { | |
| 600 | + | dev_err(&pdev->dev, "platform_get_resource() failed\n"); | |
| 601 | + | return -EINVAL; | |
| 602 | + | } | |
| 603 | + | ||
| 604 | + | ctrl = devm_ioremap(&pdev->dev, r->start, resource_size(r)); | |
| 605 | + | if (!ctrl) { | |
| 606 | + | dev_err(&pdev->dev, "devm_ioremap() failed\n"); | |
| 607 | + | return -ENOMEM; | |
| 608 | + | } | |
| 592 | 609 | ||
| 593 | 610 | irq = platform_get_irq(pdev, 0); | |
| 594 | 611 | if (irq < 0) | |
modified drivers/dma/dmaengine.c
| @@ -428,11 +428,18 @@ static void dma_device_release(struct kref *ref) | |||
| 428 | 428 | ||
| 429 | 429 | list_del_rcu(&device->global_node); | |
| 430 | 430 | dma_channel_rebalance(); | |
| 431 | + | synchronize_rcu(); | |
| 431 | 432 | ||
| 432 | 433 | if (device->device_release) | |
| 433 | 434 | device->device_release(device); | |
| 434 | 435 | } | |
| 435 | 436 | ||
| 437 | + | static int __must_check dma_device_get(struct dma_device *device) | |
| 438 | + | { | |
| 439 | + | lockdep_assert_held(&dma_list_mutex); | |
| 440 | + | return kref_get_unless_zero(&device->ref); | |
| 441 | + | } | |
| 442 | + | ||
| 436 | 443 | static void dma_device_put(struct dma_device *device) | |
| 437 | 444 | { | |
| 438 | 445 | lockdep_assert_held(&dma_list_mutex); | |
| @@ -460,8 +467,7 @@ static int dma_chan_get(struct dma_chan *chan) | |||
| 460 | 467 | if (!try_module_get(owner)) | |
| 461 | 468 | return -ENODEV; | |
| 462 | 469 | ||
| 463 | - | ret = kref_get_unless_zero(&chan->device->ref); | |
| 464 | - | if (!ret) { | |
| 470 | + | if (!dma_device_get(chan->device)) { | |
| 465 | 471 | ret = -ENODEV; | |
| 466 | 472 | goto module_put_out; | |
| 467 | 473 | } | |
| @@ -495,10 +501,13 @@ module_put_out: | |||
| 495 | 501 | */ | |
| 496 | 502 | static void dma_chan_put(struct dma_chan *chan) | |
| 497 | 503 | { | |
| 504 | + | struct module *owner; | |
| 505 | + | ||
| 498 | 506 | /* This channel is not in use, bail out */ | |
| 499 | 507 | if (!chan->client_count) | |
| 500 | 508 | return; | |
| 501 | 509 | ||
| 510 | + | owner = dma_chan_to_owner(chan); | |
| 502 | 511 | chan->client_count--; | |
| 503 | 512 | ||
| 504 | 513 | /* This channel is not in use anymore, free it */ | |
| @@ -515,8 +524,10 @@ static void dma_chan_put(struct dma_chan *chan) | |||
| 515 | 524 | chan->route_data = NULL; | |
| 516 | 525 | } | |
| 517 | 526 | ||
| 518 | - | dma_device_put(chan->device); | |
| 519 | - | module_put(dma_chan_to_owner(chan)); | |
| 527 | + | /* This channel is not in use anymore, drop the device ref */ | |
| 528 | + | if (!chan->client_count) | |
| 529 | + | dma_device_put(chan->device); | |
| 530 | + | module_put(owner); | |
| 520 | 531 | } | |
| 521 | 532 | ||
| 522 | 533 | enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie) | |
modified drivers/dma/mmp_pdma.c
| @@ -52,7 +52,6 @@ | |||
| 52 | 52 | #define DCSR_EORINTR BIT(9) /* The end of Receive */ | |
| 53 | 53 | ||
| 54 | 54 | #define DRCMR_BASE 0x0100 | |
| 55 | - | #define DRCMR_EXT_BASE_K3 0x1000 | |
| 56 | 55 | #define DRCMR_EXT_BASE_DEFAULT 0x1100 | |
| 57 | 56 | #define DRCMR_REQ_LIMIT 64 | |
| 58 | 57 | #define DRCMR_MAPVLD BIT(7) /* Map Valid (read / write) */ | |
| @@ -713,7 +712,7 @@ mmp_pdma_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl, | |||
| 713 | 712 | ||
| 714 | 713 | for_each_sg(sgl, sg, sg_len, i) { | |
| 715 | 714 | addr = sg_dma_address(sg); | |
| 716 | - | avail = sg_dma_len(sgl); | |
| 715 | + | avail = sg_dma_len(sg); | |
| 717 | 716 | ||
| 718 | 717 | do { | |
| 719 | 718 | len = min_t(size_t, avail, PDMA_MAX_DESC_BYTES); | |
| @@ -1219,7 +1218,7 @@ static const struct mmp_pdma_ops spacemit_k3_pdma_ops = { | |||
| 1219 | 1218 | .get_desc_dst_addr = get_desc_dst_addr_64, | |
| 1220 | 1219 | .run_bits = (DCSR_RUN | DCSR_LPAEEN | DCSR_EORIRQEN | DCSR_EORSTOPEN), | |
| 1221 | 1220 | .dma_width = 64, | |
| 1222 | - | .drcmr_ext_base = DRCMR_EXT_BASE_K3, | |
| 1221 | + | .drcmr_ext_base = DRCMR_EXT_BASE_DEFAULT, | |
| 1223 | 1222 | }; | |
| 1224 | 1223 | ||
| 1225 | 1224 | static const struct of_device_id mmp_pdma_dt_ids[] = { | |
modified drivers/dma/pxa_dma.c
| @@ -744,6 +744,7 @@ pxad_alloc_desc(struct pxad_chan *chan, unsigned int nb_hw_desc) | |||
| 744 | 744 | sw_desc = kzalloc_flex(*sw_desc, hw_desc, nb_hw_desc, GFP_NOWAIT); | |
| 745 | 745 | if (!sw_desc) | |
| 746 | 746 | return NULL; | |
| 747 | + | sw_desc->nb_desc = nb_hw_desc; | |
| 747 | 748 | sw_desc->desc_pool = chan->desc_pool; | |
| 748 | 749 | ||
| 749 | 750 | for (i = 0; i < nb_hw_desc; i++) { | |
| @@ -752,10 +753,10 @@ pxad_alloc_desc(struct pxad_chan *chan, unsigned int nb_hw_desc) | |||
| 752 | 753 | dev_err(&chan->vc.chan.dev->device, | |
| 753 | 754 | "%s(): Couldn't allocate the %dth hw_desc from dma_pool %p\n", | |
| 754 | 755 | __func__, i, sw_desc->desc_pool); | |
| 756 | + | sw_desc->nb_desc = i; | |
| 755 | 757 | goto err; | |
| 756 | 758 | } | |
| 757 | 759 | ||
| 758 | - | sw_desc->nb_desc++; | |
| 759 | 760 | sw_desc->hw_desc[i] = desc; | |
| 760 | 761 | ||
| 761 | 762 | if (i == 0) | |
modified drivers/dma/sprd-dma.c
| @@ -1212,7 +1212,7 @@ static int sprd_dma_probe(struct platform_device *pdev) | |||
| 1212 | 1212 | ||
| 1213 | 1213 | ret = pm_runtime_get_sync(&pdev->dev); | |
| 1214 | 1214 | if (ret < 0) | |
| 1215 | - | goto err_rpm; | |
| 1215 | + | goto err_register; | |
| 1216 | 1216 | ||
| 1217 | 1217 | ret = dma_async_device_register(&sdev->dma_dev); | |
| 1218 | 1218 | if (ret < 0) { | |
| @@ -1234,7 +1234,6 @@ err_of_register: | |||
| 1234 | 1234 | err_register: | |
| 1235 | 1235 | pm_runtime_put_noidle(&pdev->dev); | |
| 1236 | 1236 | pm_runtime_disable(&pdev->dev); | |
| 1237 | - | err_rpm: | |
| 1238 | 1237 | sprd_dma_disable(sdev); | |
| 1239 | 1238 | return ret; | |
| 1240 | 1239 | } | |
modified drivers/dma/sun6i-dma.c
| @@ -354,8 +354,10 @@ static size_t sun6i_get_chan_size(struct sun6i_pchan *pchan) | |||
| 354 | 354 | size_t bytes; | |
| 355 | 355 | dma_addr_t pos; | |
| 356 | 356 | ||
| 357 | - | pos = readl(pchan->base + DMA_CHAN_LLI_ADDR); | |
| 358 | - | bytes = readl(pchan->base + DMA_CHAN_CUR_CNT); | |
| 357 | + | do { | |
| 358 | + | pos = readl(pchan->base + DMA_CHAN_LLI_ADDR); | |
| 359 | + | bytes = readl(pchan->base + DMA_CHAN_CUR_CNT); | |
| 360 | + | } while (pos != readl(pchan->base + DMA_CHAN_LLI_ADDR)); | |
| 359 | 361 | ||
| 360 | 362 | if (pos == LLI_LAST_ITEM) | |
| 361 | 363 | return bytes; | |
| @@ -979,7 +981,6 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, | |||
| 979 | 981 | struct sun6i_pchan *pchan = vchan->phy; | |
| 980 | 982 | struct sun6i_dma_lli *lli; | |
| 981 | 983 | struct virt_dma_desc *vd; | |
| 982 | - | struct sun6i_desc *txd; | |
| 983 | 984 | enum dma_status ret; | |
| 984 | 985 | unsigned long flags; | |
| 985 | 986 | size_t bytes = 0; | |
| @@ -991,9 +992,9 @@ static enum dma_status sun6i_dma_tx_status(struct dma_chan *chan, | |||
| 991 | 992 | spin_lock_irqsave(&vchan->vc.lock, flags); | |
| 992 | 993 | ||
| 993 | 994 | vd = vchan_find_desc(&vchan->vc, cookie); | |
| 994 | - | txd = to_sun6i_desc(&vd->tx); | |
| 995 | 995 | ||
| 996 | 996 | if (vd) { | |
| 997 | + | struct sun6i_desc *txd = to_sun6i_desc(&vd->tx); | |
| 997 | 998 | for (lli = txd->v_lli; lli != NULL; lli = lli->v_lli_next) | |
| 998 | 999 | bytes += lli->len; | |
| 999 | 1000 | } else if (!pchan || !pchan->desc) { | |
modified drivers/dma/ti/k3-udma-glue.c
| @@ -1243,8 +1243,9 @@ void k3_udma_glue_release_rx_chn(struct k3_udma_glue_rx_channel *rx_chn) | |||
| 1243 | 1243 | rx_chn->psil_paired = false; | |
| 1244 | 1244 | } | |
| 1245 | 1245 | ||
| 1246 | - | for (i = 0; i < rx_chn->flow_num; i++) | |
| 1247 | - | k3_udma_glue_release_rx_flow(rx_chn, i); | |
| 1246 | + | if (rx_chn->flows) | |
| 1247 | + | for (i = 0; i < rx_chn->flow_num; i++) | |
| 1248 | + | k3_udma_glue_release_rx_flow(rx_chn, i); | |
| 1248 | 1249 | ||
| 1249 | 1250 | if (xudma_rflow_is_gp(rx_chn->common.udmax, rx_chn->flow_id_base)) | |
| 1250 | 1251 | xudma_free_gp_rflow_range(rx_chn->common.udmax, | |
modified drivers/dma/xilinx/xilinx_dma.c
| @@ -756,15 +756,25 @@ xilinx_aximcdma_alloc_tx_segment(struct xilinx_dma_chan *chan) | |||
| 756 | 756 | return segment; | |
| 757 | 757 | } | |
| 758 | 758 | ||
| 759 | - | static void xilinx_dma_clean_hw_desc(struct xilinx_axidma_desc_hw *hw) | |
| 759 | + | static void xilinx_dma_clean_hw_desc(struct xilinx_dma_chan *chan, | |
| 760 | + | struct xilinx_axidma_tx_segment *segment) | |
| 760 | 761 | { | |
| 761 | - | u32 next_desc = hw->next_desc; | |
| 762 | - | u32 next_desc_msb = hw->next_desc_msb; | |
| 762 | + | dma_addr_t next; | |
| 763 | + | u32 i; | |
| 763 | 764 | ||
| 764 | - | memset(hw, 0, sizeof(struct xilinx_axidma_desc_hw)); | |
| 765 | + | /* | |
| 766 | + | * Restore the buffer descriptor's next descriptor pointer to the value | |
| 767 | + | * set up in xilinx_dma_alloc_chan_resources(). Otherwise using the DMA | |
| 768 | + | * in cyclic mode leaves the next descriptor pointer altered and | |
| 769 | + | * prevents subsequent non-cyclic transfers. | |
| 770 | + | */ | |
| 771 | + | i = segment - chan->seg_v; | |
| 772 | + | next = chan->seg_p + | |
| 773 | + | sizeof(*chan->seg_v) * ((i + 1) % XILINX_DMA_NUM_DESCS); | |
| 765 | 774 | ||
| 766 | - | hw->next_desc = next_desc; | |
| 767 | - | hw->next_desc_msb = next_desc_msb; | |
| 775 | + | memset(&segment->hw, 0, sizeof(segment->hw)); | |
| 776 | + | segment->hw.next_desc = lower_32_bits(next); | |
| 777 | + | segment->hw.next_desc_msb = upper_32_bits(next); | |
| 768 | 778 | } | |
| 769 | 779 | ||
| 770 | 780 | static void xilinx_mcdma_clean_hw_desc(struct xilinx_aximcdma_desc_hw *hw) | |
| @@ -786,7 +796,7 @@ static void xilinx_mcdma_clean_hw_desc(struct xilinx_aximcdma_desc_hw *hw) | |||
| 786 | 796 | static void xilinx_dma_free_tx_segment(struct xilinx_dma_chan *chan, | |
| 787 | 797 | struct xilinx_axidma_tx_segment *segment) | |
| 788 | 798 | { | |
| 789 | - | xilinx_dma_clean_hw_desc(&segment->hw); | |
| 799 | + | xilinx_dma_clean_hw_desc(chan, segment); | |
| 790 | 800 | ||
| 791 | 801 | list_add_tail(&segment->node, &chan->free_seg_list); | |
| 792 | 802 | } | |
| @@ -920,9 +930,9 @@ static void xilinx_dma_free_descriptors(struct xilinx_dma_chan *chan) | |||
| 920 | 930 | ||
| 921 | 931 | spin_lock_irqsave(&chan->lock, flags); | |
| 922 | 932 | ||
| 923 | - | xilinx_dma_free_desc_list(chan, &chan->pending_list); | |
| 924 | 933 | xilinx_dma_free_desc_list(chan, &chan->done_list); | |
| 925 | 934 | xilinx_dma_free_desc_list(chan, &chan->active_list); | |
| 935 | + | xilinx_dma_free_desc_list(chan, &chan->pending_list); | |
| 926 | 936 | ||
| 927 | 937 | spin_unlock_irqrestore(&chan->lock, flags); | |
| 928 | 938 | } | |
modified drivers/dpll/dpll_netlink.c
| @@ -1202,6 +1202,7 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin, | |||
| 1202 | 1202 | const enum dpll_pin_state state, | |
| 1203 | 1203 | struct netlink_ext_ack *extack) | |
| 1204 | 1204 | { | |
| 1205 | + | void *pin_priv, *ref_sync_pin_priv; | |
| 1205 | 1206 | const struct dpll_pin_ops *ops; | |
| 1206 | 1207 | enum dpll_pin_state old_state; | |
| 1207 | 1208 | struct dpll_pin *ref_sync_pin; | |
| @@ -1209,8 +1210,7 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin, | |||
| 1209 | 1210 | struct dpll_device *dpll; | |
| 1210 | 1211 | int ret; | |
| 1211 | 1212 | ||
| 1212 | - | ref_sync_pin = xa_find(&pin->ref_sync_pins, &ref_sync_pin_idx, | |
| 1213 | - | ULONG_MAX, XA_PRESENT); | |
| 1213 | + | ref_sync_pin = xa_load(&pin->ref_sync_pins, ref_sync_pin_idx); | |
| 1214 | 1214 | if (!ref_sync_pin) { | |
| 1215 | 1215 | NL_SET_ERR_MSG(extack, "reference sync pin not found"); | |
| 1216 | 1216 | return -EINVAL; | |
| @@ -1230,9 +1230,15 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin, | |||
| 1230 | 1230 | return -EOPNOTSUPP; | |
| 1231 | 1231 | } | |
| 1232 | 1232 | dpll = ref->dpll; | |
| 1233 | - | ret = ops->ref_sync_get(pin, dpll_pin_on_dpll_priv(dpll, pin), | |
| 1234 | - | ref_sync_pin, | |
| 1235 | - | dpll_pin_on_dpll_priv(dpll, ref_sync_pin), | |
| 1233 | + | pin_priv = dpll_pin_on_dpll_priv(dpll, pin); | |
| 1234 | + | ref_sync_pin_priv = dpll_pin_on_dpll_priv(dpll, ref_sync_pin); | |
| 1235 | + | /* Pin may have been unregistered from this dpll already */ | |
| 1236 | + | if (!ref_sync_pin_priv) { | |
| 1237 | + | NL_SET_ERR_MSG(extack, | |
| 1238 | + | "reference sync pin not registered with the dpll"); | |
| 1239 | + | return -ENODEV; | |
| 1240 | + | } | |
| 1241 | + | ret = ops->ref_sync_get(pin, pin_priv, ref_sync_pin, ref_sync_pin_priv, | |
| 1236 | 1242 | &old_state, extack); | |
| 1237 | 1243 | if (ret) { | |
| 1238 | 1244 | NL_SET_ERR_MSG(extack, "unable to get old reference sync state"); | |
| @@ -1241,9 +1247,7 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin, | |||
| 1241 | 1247 | if (state == old_state) | |
| 1242 | 1248 | return 0; | |
| 1243 | 1249 | ||
| 1244 | - | ret = ops->ref_sync_set(pin, dpll_pin_on_dpll_priv(dpll, pin), | |
| 1245 | - | ref_sync_pin, | |
| 1246 | - | dpll_pin_on_dpll_priv(dpll, ref_sync_pin), | |
| 1250 | + | ret = ops->ref_sync_set(pin, pin_priv, ref_sync_pin, ref_sync_pin_priv, | |
| 1247 | 1251 | state, extack); | |
| 1248 | 1252 | if (ret) { | |
| 1249 | 1253 | NL_SET_ERR_MSG_FMT(extack, | |
modified drivers/edac/altera_edac.c
| @@ -453,15 +453,6 @@ free: | |||
| 453 | 453 | return res; | |
| 454 | 454 | } | |
| 455 | 455 | ||
| 456 | - | static void altr_sdram_remove(struct platform_device *pdev) | |
| 457 | - | { | |
| 458 | - | struct mem_ctl_info *mci = platform_get_drvdata(pdev); | |
| 459 | - | ||
| 460 | - | edac_mc_del_mc(&pdev->dev); | |
| 461 | - | edac_mc_free(mci); | |
| 462 | - | platform_set_drvdata(pdev, NULL); | |
| 463 | - | } | |
| 464 | - | ||
| 465 | 456 | /* | |
| 466 | 457 | * If you want to suspend, need to disable EDAC by removing it | |
| 467 | 458 | * from the device tree or defconfig. | |
| @@ -481,13 +472,13 @@ static const struct dev_pm_ops altr_sdram_pm_ops = { | |||
| 481 | 472 | ||
| 482 | 473 | static struct platform_driver altr_sdram_edac_driver = { | |
| 483 | 474 | .probe = altr_sdram_probe, | |
| 484 | - | .remove = altr_sdram_remove, | |
| 485 | 475 | .driver = { | |
| 486 | 476 | .name = "altr_sdram_edac", | |
| 487 | 477 | #ifdef CONFIG_PM | |
| 488 | 478 | .pm = &altr_sdram_pm_ops, | |
| 489 | 479 | #endif | |
| 490 | 480 | .of_match_table = altr_sdram_ctrl_of_match, | |
| 481 | + | .suppress_bind_attrs = true, | |
| 491 | 482 | }, | |
| 492 | 483 | }; | |
| 493 | 484 | ||
| @@ -517,6 +508,7 @@ static struct platform_driver altr_edac_driver = { | |||
| 517 | 508 | .driver = { | |
| 518 | 509 | .name = "socfpga_ecc_manager", | |
| 519 | 510 | .of_match_table = altr_edac_of_match, | |
| 511 | + | .suppress_bind_attrs = true, | |
| 520 | 512 | }, | |
| 521 | 513 | }; | |
| 522 | 514 | module_platform_driver(altr_edac_driver); | |
| @@ -803,22 +795,12 @@ fail: | |||
| 803 | 795 | return res; | |
| 804 | 796 | } | |
| 805 | 797 | ||
| 806 | - | static void altr_edac_device_remove(struct platform_device *pdev) | |
| 807 | - | { | |
| 808 | - | struct edac_device_ctl_info *dci = platform_get_drvdata(pdev); | |
| 809 | - | struct altr_edac_device_dev *drvdata = dci->pvt_info; | |
| 810 | - | ||
| 811 | - | debugfs_remove_recursive(drvdata->debugfs_dir); | |
| 812 | - | edac_device_del_device(&pdev->dev); | |
| 813 | - | edac_device_free_ctl_info(dci); | |
| 814 | - | } | |
| 815 | - | ||
| 816 | 798 | static struct platform_driver altr_edac_device_driver = { | |
| 817 | 799 | .probe = altr_edac_device_probe, | |
| 818 | - | .remove = altr_edac_device_remove, | |
| 819 | 800 | .driver = { | |
| 820 | 801 | .name = "altr_edac_device", | |
| 821 | 802 | .of_match_table = altr_edac_device_of_match, | |
| 803 | + | .suppress_bind_attrs = true, | |
| 822 | 804 | }, | |
| 823 | 805 | }; | |
| 824 | 806 | module_platform_driver(altr_edac_device_driver); | |
| @@ -944,7 +926,7 @@ static int __maybe_unused altr_init_memory_port(void __iomem *ioaddr, int port) | |||
| 944 | 926 | return ret; | |
| 945 | 927 | } | |
| 946 | 928 | ||
| 947 | - | static __init int __maybe_unused | |
| 929 | + | static int __maybe_unused | |
| 948 | 930 | altr_init_a10_ecc_block(struct device_node *np, u32 irq_mask, | |
| 949 | 931 | u32 ecc_ctrl_en_mask, bool dual_port) | |
| 950 | 932 | { | |
| @@ -1019,7 +1001,7 @@ out: | |||
| 1019 | 1001 | ||
| 1020 | 1002 | static int validate_parent_available(struct device_node *np); | |
| 1021 | 1003 | static const struct of_device_id altr_edac_a10_device_of_match[]; | |
| 1022 | - | static int __init __maybe_unused altr_init_a10_ecc_device_type(char *compat) | |
| 1004 | + | static int __maybe_unused altr_init_a10_ecc_device_type(char *compat) | |
| 1023 | 1005 | { | |
| 1024 | 1006 | int irq; | |
| 1025 | 1007 | struct device_node *child, *np; | |
| @@ -1348,7 +1330,7 @@ static const struct edac_device_prv_data a10_l2ecc_data = { | |||
| 1348 | 1330 | ||
| 1349 | 1331 | #ifdef CONFIG_EDAC_ALTERA_ETHERNET | |
| 1350 | 1332 | ||
| 1351 | - | static int __init socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev) | |
| 1333 | + | static int socfpga_init_ethernet_ecc(struct altr_edac_device_dev *dev) | |
| 1352 | 1334 | { | |
| 1353 | 1335 | int ret; | |
| 1354 | 1336 | ||
| @@ -1378,7 +1360,7 @@ static const struct edac_device_prv_data a10_enetecc_data = { | |||
| 1378 | 1360 | ||
| 1379 | 1361 | #ifdef CONFIG_EDAC_ALTERA_NAND | |
| 1380 | 1362 | ||
| 1381 | - | static int __init socfpga_init_nand_ecc(struct altr_edac_device_dev *device) | |
| 1363 | + | static int socfpga_init_nand_ecc(struct altr_edac_device_dev *device) | |
| 1382 | 1364 | { | |
| 1383 | 1365 | int ret; | |
| 1384 | 1366 | ||
| @@ -1408,7 +1390,7 @@ static const struct edac_device_prv_data a10_nandecc_data = { | |||
| 1408 | 1390 | ||
| 1409 | 1391 | #ifdef CONFIG_EDAC_ALTERA_DMA | |
| 1410 | 1392 | ||
| 1411 | - | static int __init socfpga_init_dma_ecc(struct altr_edac_device_dev *device) | |
| 1393 | + | static int socfpga_init_dma_ecc(struct altr_edac_device_dev *device) | |
| 1412 | 1394 | { | |
| 1413 | 1395 | int ret; | |
| 1414 | 1396 | ||
| @@ -1438,7 +1420,7 @@ static const struct edac_device_prv_data a10_dmaecc_data = { | |||
| 1438 | 1420 | ||
| 1439 | 1421 | #ifdef CONFIG_EDAC_ALTERA_USB | |
| 1440 | 1422 | ||
| 1441 | - | static int __init socfpga_init_usb_ecc(struct altr_edac_device_dev *device) | |
| 1423 | + | static int socfpga_init_usb_ecc(struct altr_edac_device_dev *device) | |
| 1442 | 1424 | { | |
| 1443 | 1425 | int ret; | |
| 1444 | 1426 | ||
| @@ -1468,7 +1450,7 @@ static const struct edac_device_prv_data a10_usbecc_data = { | |||
| 1468 | 1450 | ||
| 1469 | 1451 | #ifdef CONFIG_EDAC_ALTERA_QSPI | |
| 1470 | 1452 | ||
| 1471 | - | static int __init socfpga_init_qspi_ecc(struct altr_edac_device_dev *device) | |
| 1453 | + | static int socfpga_init_qspi_ecc(struct altr_edac_device_dev *device) | |
| 1472 | 1454 | { | |
| 1473 | 1455 | int ret; | |
| 1474 | 1456 | ||
| @@ -1524,6 +1506,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1524 | 1506 | dci = edac_device_alloc_ctl_info(sizeof(*altdev), ecc_name, 1, | |
| 1525 | 1507 | ecc_name, 1, 0, edac_idx); | |
| 1526 | 1508 | if (!dci) { | |
| 1509 | + | of_node_put(np); | |
| 1527 | 1510 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1528 | 1511 | "%s: Unable to allocate PortB EDAC device\n", | |
| 1529 | 1512 | ecc_name); | |
| @@ -1534,8 +1517,11 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1534 | 1517 | altdev = dci->pvt_info; | |
| 1535 | 1518 | *altdev = *device; | |
| 1536 | 1519 | ||
| 1537 | - | if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) | |
| 1520 | + | if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL)) { | |
| 1521 | + | edac_device_free_ctl_info(dci); | |
| 1522 | + | of_node_put(np); | |
| 1538 | 1523 | return -ENOMEM; | |
| 1524 | + | } | |
| 1539 | 1525 | ||
| 1540 | 1526 | /* Update PortB specific values */ | |
| 1541 | 1527 | altdev->edac_dev_name = ecc_name; | |
| @@ -1600,6 +1586,8 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1600 | 1586 | rc = -ENOMEM; | |
| 1601 | 1587 | goto err_release_group_1; | |
| 1602 | 1588 | } | |
| 1589 | + | of_node_put(np); | |
| 1590 | + | ||
| 1603 | 1591 | altr_create_edacdev_dbgfs(dci, prv); | |
| 1604 | 1592 | ||
| 1605 | 1593 | list_add(&altdev->next, &altdev->edac->a10_ecc_devices); | |
| @@ -1609,14 +1597,20 @@ static int altr_portb_setup(struct altr_edac_device_dev *device) | |||
| 1609 | 1597 | return 0; | |
| 1610 | 1598 | ||
| 1611 | 1599 | err_release_group_1: | |
| 1612 | - | edac_device_free_ctl_info(dci); | |
| 1600 | + | /* | |
| 1601 | + | * Release the devres group first so the managed IRQs are | |
| 1602 | + | * unregistered before dci (which contains the IRQ handler's | |
| 1603 | + | * data via dci->pvt_info) is freed, avoiding a use-after-free. | |
| 1604 | + | */ | |
| 1613 | 1605 | devres_release_group(device->edac->dev, altr_portb_setup); | |
| 1606 | + | edac_device_free_ctl_info(dci); | |
| 1607 | + | of_node_put(np); | |
| 1614 | 1608 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 1615 | 1609 | "%s:Error setting up EDAC device: %d\n", ecc_name, rc); | |
| 1616 | 1610 | return rc; | |
| 1617 | 1611 | } | |
| 1618 | 1612 | ||
| 1619 | - | static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |
| 1613 | + | static int socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |
| 1620 | 1614 | { | |
| 1621 | 1615 | int rc = -ENODEV; | |
| 1622 | 1616 | struct device_node *child; | |
| @@ -1638,7 +1632,7 @@ static int __init socfpga_init_sdmmc_ecc(struct altr_edac_device_dev *device) | |||
| 1638 | 1632 | goto exit; | |
| 1639 | 1633 | ||
| 1640 | 1634 | /* Setup portB */ | |
| 1641 | - | return altr_portb_setup(device); | |
| 1635 | + | rc = altr_portb_setup(device); | |
| 1642 | 1636 | ||
| 1643 | 1637 | exit: | |
| 1644 | 1638 | of_node_put(child); | |
| @@ -2013,9 +2007,17 @@ static int altr_edac_a10_device_add(struct altr_arria10_edac *edac, | |||
| 2013 | 2007 | return 0; | |
| 2014 | 2008 | ||
| 2015 | 2009 | err_release_group1: | |
| 2010 | + | /* | |
| 2011 | + | * Release the devres group first so the managed IRQs are | |
| 2012 | + | * unregistered before dci (which contains the IRQ handler's | |
| 2013 | + | * data via dci->pvt_info) is freed, avoiding a use-after-free. | |
| 2014 | + | */ | |
| 2015 | + | devres_release_group(edac->dev, NULL); | |
| 2016 | 2016 | edac_device_free_ctl_info(dci); | |
| 2017 | + | goto err_print; | |
| 2017 | 2018 | err_release_group: | |
| 2018 | 2019 | devres_release_group(edac->dev, NULL); | |
| 2020 | + | err_print: | |
| 2019 | 2021 | edac_printk(KERN_ERR, EDAC_DEVICE, | |
| 2020 | 2022 | "%s:Error setting up EDAC device: %d\n", ecc_name, rc); | |
| 2021 | 2023 | ||
| @@ -2214,6 +2216,7 @@ static struct platform_driver altr_edac_a10_driver = { | |||
| 2214 | 2216 | .driver = { | |
| 2215 | 2217 | .name = "socfpga_a10_ecc_manager", | |
| 2216 | 2218 | .of_match_table = altr_edac_a10_of_match, | |
| 2219 | + | .suppress_bind_attrs = true, | |
| 2217 | 2220 | }, | |
| 2218 | 2221 | }; | |
| 2219 | 2222 | module_platform_driver(altr_edac_a10_driver); | |
modified drivers/edac/amd64_edac.c
| @@ -2796,13 +2796,13 @@ static inline void decode_bus_error(int node_id, struct mce *m) | |||
| 2796 | 2796 | * the instance_id. For example, instance_id=0xYXXXXX where Y is the channel | |
| 2797 | 2797 | * number. | |
| 2798 | 2798 | * | |
| 2799 | - | * For DRAM ECC errors, the Chip Select number is given in bits [2:0] of | |
| 2799 | + | * For DRAM ECC errors, the Chip Select number is given in bits [1:0] of | |
| 2800 | 2800 | * the MCA_SYND[ErrorInformation] field. | |
| 2801 | 2801 | */ | |
| 2802 | 2802 | static void umc_get_err_info(struct mce *m, struct err_info *err) | |
| 2803 | 2803 | { | |
| 2804 | 2804 | err->channel = (m->ipid & GENMASK(31, 0)) >> 20; | |
| 2805 | - | err->csrow = m->synd & 0x7; | |
| 2805 | + | err->csrow = m->synd & 0x3; | |
| 2806 | 2806 | } | |
| 2807 | 2807 | ||
| 2808 | 2808 | static void decode_umc_error(int node_id, struct mce *m) | |
modified drivers/edac/versalnet_edac.c
| @@ -953,6 +953,7 @@ static void mc_remove(struct platform_device *pdev) | |||
| 953 | 953 | remove_versalnet(priv); | |
| 954 | 954 | rproc_shutdown(priv->mcdi->r5_rproc); | |
| 955 | 955 | cdx_mcdi_finish(priv->mcdi); | |
| 956 | + | rproc_put(priv->mcdi->r5_rproc); | |
| 956 | 957 | kfree(priv->mcdi); | |
| 957 | 958 | } | |
| 958 | 959 | ||
modified drivers/firewire/core-cdev.c
| @@ -1397,8 +1397,10 @@ static void iso_resource_auto_work(struct work_struct *work) | |||
| 1397 | 1397 | } else { | |
| 1398 | 1398 | // Transit from allocation to reallocation, except if the client requested | |
| 1399 | 1399 | // deallocation in the meantime. | |
| 1400 | - | scoped_guard(spinlock_irq, &client->lock) | |
| 1401 | - | r->todo = ISO_RES_AUTO_REALLOC; | |
| 1400 | + | scoped_guard(spinlock_irq, &client->lock) { | |
| 1401 | + | if (r->todo == ISO_RES_AUTO_ALLOC) | |
| 1402 | + | r->todo = ISO_RES_AUTO_REALLOC; | |
| 1403 | + | } | |
| 1402 | 1404 | ||
| 1403 | 1405 | if (channel >= 0) | |
| 1404 | 1406 | r->params.channels_mask = BIT_ULL(channel); | |
modified drivers/firmware/arm_ffa/driver.c
| @@ -2225,6 +2225,7 @@ static void ffa_remove(struct platform_device *pdev) | |||
| 2225 | 2225 | static struct platform_driver ffa_driver = { | |
| 2226 | 2226 | .probe = ffa_probe, | |
| 2227 | 2227 | .remove = ffa_remove, | |
| 2228 | + | .shutdown = ffa_remove, | |
| 2228 | 2229 | .driver = { | |
| 2229 | 2230 | .name = FFA_PLATFORM_NAME, | |
| 2230 | 2231 | }, | |
modified drivers/firmware/arm_scmi/driver.c
| @@ -477,7 +477,7 @@ void *scmi_notification_instance_data_get(const struct scmi_handle *handle) | |||
| 477 | 477 | * - exactly 'next_token' may be NOT available so pick xfer_id >= next_token | |
| 478 | 478 | * using find_next_zero_bit() starting from candidate next_token bit | |
| 479 | 479 | * | |
| 480 | - | * - all tokens ahead upto (MSG_TOKEN_ID_MASK - 1) are used in-flight but we | |
| 480 | + | * - all tokens ahead up to (MSG_TOKEN_ID_MASK - 1) are used in-flight but we | |
| 481 | 481 | * are plenty of free tokens at start, so try a second pass using | |
| 482 | 482 | * find_next_zero_bit() and starting from 0. | |
| 483 | 483 | * | |
modified drivers/firmware/arm_scpi.c
| @@ -631,8 +631,8 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain) | |||
| 631 | 631 | if (ret) | |
| 632 | 632 | return ERR_PTR(ret); | |
| 633 | 633 | ||
| 634 | - | if (!buf.opp_count) | |
| 635 | - | return ERR_PTR(-ENOENT); | |
| 634 | + | if (!buf.opp_count || buf.opp_count > MAX_DVFS_OPPS) | |
| 635 | + | return ERR_PTR(-EINVAL); | |
| 636 | 636 | ||
| 637 | 637 | info = kmalloc_obj(*info); | |
| 638 | 638 | if (!info) | |
| @@ -661,12 +661,15 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain) | |||
| 661 | 661 | static int scpi_dev_domain_id(struct device *dev) | |
| 662 | 662 | { | |
| 663 | 663 | struct of_phandle_args clkspec; | |
| 664 | + | int domain; | |
| 664 | 665 | ||
| 665 | 666 | if (of_parse_phandle_with_args(dev->of_node, "clocks", "#clock-cells", | |
| 666 | 667 | 0, &clkspec)) | |
| 667 | 668 | return -EINVAL; | |
| 668 | 669 | ||
| 669 | - | return clkspec.args[0]; | |
| 670 | + | domain = clkspec.args[0]; | |
| 671 | + | of_node_put(clkspec.np); | |
| 672 | + | return domain; | |
| 670 | 673 | } | |
| 671 | 674 | ||
| 672 | 675 | static struct scpi_dvfs_info *scpi_dvfs_info(struct device *dev) | |
modified drivers/gpio/gpio-arizona.c
| @@ -115,8 +115,12 @@ static int arizona_gpio_direction_out(struct gpio_chip *chip, | |||
| 115 | 115 | if (value) | |
| 116 | 116 | value = ARIZONA_GPN_LVL; | |
| 117 | 117 | ||
| 118 | - | return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, | |
| 119 | - | ARIZONA_GPN_DIR | ARIZONA_GPN_LVL, value); | |
| 118 | + | ret = regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset, | |
| 119 | + | ARIZONA_GPN_DIR | ARIZONA_GPN_LVL, value); | |
| 120 | + | if (ret < 0 && (val & ARIZONA_GPN_DIR) && persistent) | |
| 121 | + | pm_runtime_put_autosuspend(chip->parent); | |
| 122 | + | ||
| 123 | + | return ret; | |
| 120 | 124 | } | |
| 121 | 125 | ||
| 122 | 126 | static int arizona_gpio_set(struct gpio_chip *chip, unsigned int offset, | |
modified drivers/gpio/gpio-exar.c
| @@ -199,6 +199,7 @@ static int gpio_exar_probe(struct platform_device *pdev) | |||
| 199 | 199 | index = ida_alloc(&ida_index, GFP_KERNEL); | |
| 200 | 200 | if (index < 0) | |
| 201 | 201 | return index; | |
| 202 | + | exar_gpio->index = index; | |
| 202 | 203 | ||
| 203 | 204 | ret = devm_add_action_or_reset(dev, exar_devm_ida_free, exar_gpio); | |
| 204 | 205 | if (ret) | |
| @@ -214,7 +215,6 @@ static int gpio_exar_probe(struct platform_device *pdev) | |||
| 214 | 215 | exar_gpio->gpio_chip.set = exar_set_value; | |
| 215 | 216 | exar_gpio->gpio_chip.base = -1; | |
| 216 | 217 | exar_gpio->gpio_chip.ngpio = ngpios; | |
| 217 | - | exar_gpio->index = index; | |
| 218 | 218 | exar_gpio->first_pin = first_pin; | |
| 219 | 219 | ||
| 220 | 220 | ret = devm_gpiochip_add_data(dev, &exar_gpio->gpio_chip, exar_gpio); | |
modified drivers/gpio/gpio-mpsse.c
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | #include <linux/cleanup.h> | |
| 11 | 11 | #include <linux/gpio/driver.h> | |
| 12 | 12 | #include <linux/mutex.h> | |
| 13 | + | #include <linux/rcupdate.h> | |
| 13 | 14 | #include <linux/spinlock.h> | |
| 14 | 15 | #include <linux/usb.h> | |
| 15 | 16 | ||
| @@ -24,6 +25,7 @@ struct mpsse_priv { | |||
| 24 | 25 | raw_spinlock_t irq_spin; /* protects worker list */ | |
| 25 | 26 | atomic_t irq_type[16]; /* pin -> edge detection type */ | |
| 26 | 27 | atomic_t irq_enabled; | |
| 28 | + | atomic_t dying; /* no new workers after disconnect */ | |
| 27 | 29 | int id; | |
| 28 | 30 | ||
| 29 | 31 | u8 gpio_outputs[2]; /* Output states for GPIOs [L, H] */ | |
| @@ -46,6 +48,7 @@ struct mpsse_worker { | |||
| 46 | 48 | atomic_t cancelled; | |
| 47 | 49 | struct list_head list; /* linked list */ | |
| 48 | 50 | struct list_head destroy; /* teardown linked list */ | |
| 51 | + | struct rcu_head rcu; /* deferred free for dying path */ | |
| 49 | 52 | }; | |
| 50 | 53 | ||
| 51 | 54 | struct bulk_desc { | |
| @@ -525,10 +528,24 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd) | |||
| 525 | 528 | worker->priv = priv; | |
| 526 | 529 | INIT_LIST_HEAD(&worker->list); | |
| 527 | 530 | INIT_WORK(&worker->work, gpio_mpsse_poll); | |
| 528 | - | schedule_work(&worker->work); | |
| 529 | 531 | ||
| 530 | - | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) | |
| 532 | + | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) { | |
| 533 | + | if (atomic_read(&priv->dying)) { | |
| 534 | + | /* | |
| 535 | + | * Cannot kfree() here: this callback | |
| 536 | + | * runs with the IRQ descriptor's raw | |
| 537 | + | * spinlock held and kfree() may sleep | |
| 538 | + | * on PREEMPT_RT. The worker is not | |
| 539 | + | * yet published, so the deferred free | |
| 540 | + | * is unobservable. | |
| 541 | + | */ | |
| 542 | + | kfree_rcu(worker, rcu); | |
| 543 | + | return; | |
| 544 | + | } | |
| 545 | + | ||
| 531 | 546 | list_add(&worker->list, &priv->workers); | |
| 547 | + | schedule_work(&worker->work); | |
| 548 | + | } | |
| 532 | 549 | } | |
| 533 | 550 | } | |
| 534 | 551 | ||
| @@ -704,6 +721,9 @@ static void gpio_mpsse_disconnect(struct usb_interface *intf) | |||
| 704 | 721 | { | |
| 705 | 722 | struct mpsse_priv *priv = usb_get_intfdata(intf); | |
| 706 | 723 | ||
| 724 | + | scoped_guard(raw_spinlock_irqsave, &priv->irq_spin) | |
| 725 | + | atomic_set(&priv->dying, 1); | |
| 726 | + | ||
| 707 | 727 | /* | |
| 708 | 728 | * Lock prevents double-free of worker from here and the teardown | |
| 709 | 729 | * step at the beginning of gpio_mpsse_poll | |
modified drivers/gpio/gpio-mvebu.c
| @@ -1034,6 +1034,8 @@ static int mvebu_gpio_suspend(struct platform_device *pdev, pm_message_t state) | |||
| 1034 | 1034 | static int mvebu_gpio_resume(struct platform_device *pdev) | |
| 1035 | 1035 | { | |
| 1036 | 1036 | struct mvebu_gpio_chip *mvchip = platform_get_drvdata(pdev); | |
| 1037 | + | u32 edge_cache = ~0U, level_cache = ~0U; | |
| 1038 | + | unsigned long flags; | |
| 1037 | 1039 | int i; | |
| 1038 | 1040 | ||
| 1039 | 1041 | regmap_write(mvchip->regs, GPIO_OUT_OFF + mvchip->offset, | |
| @@ -1045,32 +1047,51 @@ static int mvebu_gpio_resume(struct platform_device *pdev) | |||
| 1045 | 1047 | regmap_write(mvchip->regs, GPIO_IN_POL_OFF + mvchip->offset, | |
| 1046 | 1048 | mvchip->in_pol_reg); | |
| 1047 | 1049 | ||
| 1050 | + | /* | |
| 1051 | + | * genirq skips mask_irq() for a line it already considers masked, so | |
| 1052 | + | * unmasking one behind its back leaves an asserted level line that | |
| 1053 | + | * nobody masks. Restore only bits the irqchip cache still has set. | |
| 1054 | + | * | |
| 1055 | + | * Snapshot the caches under the raw spinlock, but release it before | |
| 1056 | + | * the regmap writes below: regmap_write() takes a sleepable lock on | |
| 1057 | + | * PREEMPT_RT. | |
| 1058 | + | */ | |
| 1059 | + | if (mvchip->domain) { | |
| 1060 | + | struct irq_chip_generic *gc; | |
| 1061 | + | ||
| 1062 | + | gc = irq_get_domain_generic_chip(mvchip->domain, 0); | |
| 1063 | + | raw_spin_lock_irqsave(&gc->lock, flags); | |
| 1064 | + | level_cache = gc->chip_types[0].mask_cache_priv; | |
| 1065 | + | edge_cache = gc->chip_types[1].mask_cache_priv; | |
| 1066 | + | raw_spin_unlock_irqrestore(&gc->lock, flags); | |
| 1067 | + | } | |
| 1068 | + | ||
| 1048 | 1069 | switch (mvchip->soc_variant) { | |
| 1049 | 1070 | case MVEBU_GPIO_SOC_VARIANT_ORION: | |
| 1050 | 1071 | case MVEBU_GPIO_SOC_VARIANT_A8K: | |
| 1051 | 1072 | regmap_write(mvchip->regs, GPIO_EDGE_MASK_OFF + mvchip->offset, | |
| 1052 | - | mvchip->edge_mask_regs[0]); | |
| 1073 | + | mvchip->edge_mask_regs[0] & edge_cache); | |
| 1053 | 1074 | regmap_write(mvchip->regs, GPIO_LEVEL_MASK_OFF + mvchip->offset, | |
| 1054 | - | mvchip->level_mask_regs[0]); | |
| 1075 | + | mvchip->level_mask_regs[0] & level_cache); | |
| 1055 | 1076 | break; | |
| 1056 | 1077 | case MVEBU_GPIO_SOC_VARIANT_MV78200: | |
| 1057 | 1078 | for (i = 0; i < 2; i++) { | |
| 1058 | 1079 | regmap_write(mvchip->regs, | |
| 1059 | 1080 | GPIO_EDGE_MASK_MV78200_OFF(i), | |
| 1060 | - | mvchip->edge_mask_regs[i]); | |
| 1081 | + | mvchip->edge_mask_regs[i] & edge_cache); | |
| 1061 | 1082 | regmap_write(mvchip->regs, | |
| 1062 | 1083 | GPIO_LEVEL_MASK_MV78200_OFF(i), | |
| 1063 | - | mvchip->level_mask_regs[i]); | |
| 1084 | + | mvchip->level_mask_regs[i] & level_cache); | |
| 1064 | 1085 | } | |
| 1065 | 1086 | break; | |
| 1066 | 1087 | case MVEBU_GPIO_SOC_VARIANT_ARMADAXP: | |
| 1067 | 1088 | for (i = 0; i < 4; i++) { | |
| 1068 | 1089 | regmap_write(mvchip->regs, | |
| 1069 | 1090 | GPIO_EDGE_MASK_ARMADAXP_OFF(i), | |
| 1070 | - | mvchip->edge_mask_regs[i]); | |
| 1091 | + | mvchip->edge_mask_regs[i] & edge_cache); | |
| 1071 | 1092 | regmap_write(mvchip->regs, | |
| 1072 | 1093 | GPIO_LEVEL_MASK_ARMADAXP_OFF(i), | |
| 1073 | - | mvchip->level_mask_regs[i]); | |
| 1094 | + | mvchip->level_mask_regs[i] & level_cache); | |
| 1074 | 1095 | } | |
| 1075 | 1096 | break; | |
| 1076 | 1097 | default: | |
modified drivers/gpio/gpio-tps65219.c
| @@ -79,7 +79,7 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset) | |||
| 79 | 79 | if (ret) | |
| 80 | 80 | return ret; | |
| 81 | 81 | ||
| 82 | - | ret = !!(val & BIT(TPS65219_MFP_GPIO_STATUS_MASK)); | |
| 82 | + | ret = !!(val & TPS65219_MFP_GPIO_STATUS_MASK); | |
| 83 | 83 | dev_warn(dev, "GPIO%d = %d, MULTI_DEVICE_ENABLE, not a standard GPIO\n", offset, ret); | |
| 84 | 84 | ||
| 85 | 85 | /* | |
| @@ -87,7 +87,7 @@ static int tps65219_gpio_get(struct gpio_chip *gc, unsigned int offset) | |||
| 87 | 87 | * status bit. | |
| 88 | 88 | */ | |
| 89 | 89 | ||
| 90 | - | if (tps65219_gpio_get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT) | |
| 90 | + | if (gc->get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT) | |
| 91 | 91 | return -ENOTSUPP; | |
| 92 | 92 | ||
| 93 | 93 | return ret; | |
| @@ -158,8 +158,10 @@ static int tps65214_gpio_change_direction(struct gpio_chip *gc, unsigned int off | |||
| 158 | 158 | if (ret) | |
| 159 | 159 | dev_err(dev, "GPIO%d configured as VSEL, not GPIO\n", offset); | |
| 160 | 160 | ||
| 161 | + | val = direction == GPIO_LINE_DIRECTION_OUT ? | |
| 162 | + | TPS65214_GPIO0_DIR_MASK : 0; | |
| 161 | 163 | ret = regmap_update_bits(gpio->tps->regmap, TPS65219_REG_GENERAL_CONFIG, | |
| 162 | - | TPS65214_GPIO0_DIR_MASK, direction); | |
| 164 | + | TPS65214_GPIO0_DIR_MASK, val); | |
| 163 | 165 | if (ret) | |
| 164 | 166 | dev_err(dev, "Fail to change direction to %u for GPIO%d.\n", direction, offset); | |
| 165 | 167 | ||
| @@ -176,7 +178,7 @@ static int tps65219_gpio_direction_input(struct gpio_chip *gc, unsigned int offs | |||
| 176 | 178 | return -ENOTSUPP; | |
| 177 | 179 | } | |
| 178 | 180 | ||
| 179 | - | if (tps65219_gpio_get_direction(gc, offset) == GPIO_LINE_DIRECTION_IN) | |
| 181 | + | if (gc->get_direction(gc, offset) == GPIO_LINE_DIRECTION_IN) | |
| 180 | 182 | return 0; | |
| 181 | 183 | ||
| 182 | 184 | return gpio->change_dir(gc, offset, GPIO_LINE_DIRECTION_IN); | |
| @@ -190,7 +192,7 @@ static int tps65219_gpio_direction_output(struct gpio_chip *gc, unsigned int off | |||
| 190 | 192 | if (offset != TPS6521X_GPIO0_IDX) | |
| 191 | 193 | return 0; | |
| 192 | 194 | ||
| 193 | - | if (tps65219_gpio_get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT) | |
| 195 | + | if (gc->get_direction(gc, offset) == GPIO_LINE_DIRECTION_OUT) | |
| 194 | 196 | return 0; | |
| 195 | 197 | ||
| 196 | 198 | return gpio->change_dir(gc, offset, GPIO_LINE_DIRECTION_OUT); | |
modified drivers/gpio/gpio-virtuser.c
| @@ -692,7 +692,8 @@ static int gpio_virtuser_interrupts_set(void *data, u64 val) | |||
| 692 | 692 | atomic_set(&ld->irq, irq); | |
| 693 | 693 | } else { | |
| 694 | 694 | irq = atomic_xchg(&ld->irq, 0); | |
| 695 | - | free_irq(irq, ld); | |
| 695 | + | if (irq) | |
| 696 | + | free_irq(irq, ld); | |
| 696 | 697 | } | |
| 697 | 698 | ||
| 698 | 699 | return 0; | |
modified drivers/gpio/gpio-xilinx.c
| @@ -271,14 +271,7 @@ static void xgpio_save_regs(struct xgpio_instance *chip) | |||
| 271 | 271 | ||
| 272 | 272 | static int xgpio_request(struct gpio_chip *chip, unsigned int offset) | |
| 273 | 273 | { | |
| 274 | - | int ret; | |
| 275 | - | ||
| 276 | - | ret = pm_runtime_get_sync(chip->parent); | |
| 277 | - | /* | |
| 278 | - | * If the device is already active pm_runtime_get() will return 1 on | |
| 279 | - | * success, but gpio_request still needs to return 0. | |
| 280 | - | */ | |
| 281 | - | return ret < 0 ? ret : 0; | |
| 274 | + | return pm_runtime_resume_and_get(chip->parent); | |
| 282 | 275 | } | |
| 283 | 276 | ||
| 284 | 277 | static void xgpio_free(struct gpio_chip *chip, unsigned int offset) | |
modified drivers/gpio/gpio-zynq.c
| @@ -798,15 +798,7 @@ static int zynq_gpio_runtime_resume(struct device *dev) | |||
| 798 | 798 | ||
| 799 | 799 | static int zynq_gpio_request(struct gpio_chip *chip, unsigned int offset) | |
| 800 | 800 | { | |
| 801 | - | int ret; | |
| 802 | - | ||
| 803 | - | ret = pm_runtime_get_sync(chip->parent); | |
| 804 | - | ||
| 805 | - | /* | |
| 806 | - | * If the device is already active pm_runtime_get() will return 1 on | |
| 807 | - | * success, but gpio_request still needs to return 0. | |
| 808 | - | */ | |
| 809 | - | return ret < 0 ? ret : 0; | |
| 801 | + | return pm_runtime_resume_and_get(chip->parent); | |
| 810 | 802 | } | |
| 811 | 803 | ||
| 812 | 804 | static void zynq_gpio_free(struct gpio_chip *chip, unsigned int offset) | |
modified drivers/gpio/gpiolib-cdev.c
| @@ -2172,18 +2172,19 @@ static void gpio_v2_line_info_changed_to_v1( | |||
| 2172 | 2172 | ||
| 2173 | 2173 | #endif /* CONFIG_GPIO_CDEV_V1 */ | |
| 2174 | 2174 | ||
| 2175 | - | static void gpio_desc_to_lineinfo(struct gpio_desc *desc, | |
| 2176 | - | struct gpio_v2_line_info *info, bool atomic) | |
| 2175 | + | static int gpio_desc_to_lineinfo(struct gpio_desc *desc, | |
| 2176 | + | struct gpio_v2_line_info *info, bool atomic) | |
| 2177 | 2177 | { | |
| 2178 | 2178 | u32 debounce_period_us; | |
| 2179 | 2179 | unsigned long dflags; | |
| 2180 | 2180 | const char *label; | |
| 2181 | 2181 | ||
| 2182 | + | memset(info, 0, sizeof(*info)); | |
| 2183 | + | ||
| 2182 | 2184 | CLASS(gpio_chip_guard, guard)(desc); | |
| 2183 | 2185 | if (!guard.gc) | |
| 2184 | - | return; | |
| 2186 | + | return -ENODEV; | |
| 2185 | 2187 | ||
| 2186 | - | memset(info, 0, sizeof(*info)); | |
| 2187 | 2188 | info->offset = gpiod_hwgpio(desc); | |
| 2188 | 2189 | ||
| 2189 | 2190 | if (desc->name) | |
| @@ -2258,6 +2259,8 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc, | |||
| 2258 | 2259 | debounce_period_us; | |
| 2259 | 2260 | info->num_attrs++; | |
| 2260 | 2261 | } | |
| 2262 | + | ||
| 2263 | + | return 0; | |
| 2261 | 2264 | } | |
| 2262 | 2265 | ||
| 2263 | 2266 | struct gpio_chardev_data { | |
| @@ -2309,6 +2312,7 @@ static int lineinfo_get_v1(struct gpio_chardev_data *cdev, void __user *ip, | |||
| 2309 | 2312 | struct gpio_desc *desc; | |
| 2310 | 2313 | struct gpioline_info lineinfo; | |
| 2311 | 2314 | struct gpio_v2_line_info lineinfo_v2; | |
| 2315 | + | int ret; | |
| 2312 | 2316 | ||
| 2313 | 2317 | if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) | |
| 2314 | 2318 | return -EFAULT; | |
| @@ -2326,7 +2330,10 @@ static int lineinfo_get_v1(struct gpio_chardev_data *cdev, void __user *ip, | |||
| 2326 | 2330 | return -EBUSY; | |
| 2327 | 2331 | } | |
| 2328 | 2332 | ||
| 2329 | - | gpio_desc_to_lineinfo(desc, &lineinfo_v2, false); | |
| 2333 | + | ret = gpio_desc_to_lineinfo(desc, &lineinfo_v2, false); | |
| 2334 | + | if (ret) | |
| 2335 | + | return ret; | |
| 2336 | + | ||
| 2330 | 2337 | gpio_v2_line_info_to_v1(&lineinfo_v2, &lineinfo); | |
| 2331 | 2338 | ||
| 2332 | 2339 | if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) { | |
| @@ -2344,6 +2351,7 @@ static int lineinfo_get(struct gpio_chardev_data *cdev, void __user *ip, | |||
| 2344 | 2351 | { | |
| 2345 | 2352 | struct gpio_desc *desc; | |
| 2346 | 2353 | struct gpio_v2_line_info lineinfo; | |
| 2354 | + | int ret; | |
| 2347 | 2355 | ||
| 2348 | 2356 | if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) | |
| 2349 | 2357 | return -EFAULT; | |
| @@ -2363,7 +2371,10 @@ static int lineinfo_get(struct gpio_chardev_data *cdev, void __user *ip, | |||
| 2363 | 2371 | if (test_and_set_bit(lineinfo.offset, cdev->watched_lines)) | |
| 2364 | 2372 | return -EBUSY; | |
| 2365 | 2373 | } | |
| 2366 | - | gpio_desc_to_lineinfo(desc, &lineinfo, false); | |
| 2374 | + | ||
| 2375 | + | ret = gpio_desc_to_lineinfo(desc, &lineinfo, false); | |
| 2376 | + | if (ret) | |
| 2377 | + | return ret; | |
| 2367 | 2378 | ||
| 2368 | 2379 | if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) { | |
| 2369 | 2380 | if (watch) | |
| @@ -2489,6 +2500,7 @@ static int lineinfo_changed_notify(struct notifier_block *nb, | |||
| 2489 | 2500 | struct lineinfo_changed_ctx *ctx; | |
| 2490 | 2501 | struct gpio_desc *desc = data; | |
| 2491 | 2502 | struct file *fp; | |
| 2503 | + | int ret; | |
| 2492 | 2504 | ||
| 2493 | 2505 | if (!test_bit(gpiod_hwgpio(desc), cdev->watched_lines)) | |
| 2494 | 2506 | return NOTIFY_DONE; | |
| @@ -2519,7 +2531,13 @@ static int lineinfo_changed_notify(struct notifier_block *nb, | |||
| 2519 | 2531 | ||
| 2520 | 2532 | ctx->chg.event_type = action; | |
| 2521 | 2533 | ctx->chg.timestamp_ns = ktime_get_ns(); | |
| 2522 | - | gpio_desc_to_lineinfo(desc, &ctx->chg.info, true); | |
| 2534 | + | ||
| 2535 | + | ret = gpio_desc_to_lineinfo(desc, &ctx->chg.info, true); | |
| 2536 | + | if (ret) { | |
| 2537 | + | fput(fp); | |
| 2538 | + | return NOTIFY_DONE; | |
| 2539 | + | } | |
| 2540 | + | ||
| 2523 | 2541 | /* Keep the GPIO device alive until we emit the event. */ | |
| 2524 | 2542 | ctx->gdev = gpio_device_get(desc->gdev); | |
| 2525 | 2543 | ctx->cdev = cdev; | |
modified drivers/gpio/gpiolib-of.c
| @@ -788,13 +788,13 @@ static int of_gpio_notify(struct notifier_block *nb, unsigned long action, | |||
| 788 | 788 | if (!of_property_read_bool(rd->dn, "gpio-hog")) | |
| 789 | 789 | return NOTIFY_DONE; /* not for us */ | |
| 790 | 790 | ||
| 791 | - | if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) | |
| 792 | - | return NOTIFY_DONE; | |
| 793 | - | ||
| 794 | 791 | gdev = of_find_gpio_device_by_node(rd->dn->parent); | |
| 795 | 792 | if (!gdev) | |
| 796 | 793 | return NOTIFY_DONE; /* not for us */ | |
| 797 | 794 | ||
| 795 | + | if (of_node_test_and_set_flag(rd->dn, OF_POPULATED)) | |
| 796 | + | return NOTIFY_DONE; | |
| 797 | + | ||
| 798 | 798 | ret = gpiochip_add_hog(gpio_device_get_chip(gdev), of_fwnode_handle(rd->dn)); | |
| 799 | 799 | if (ret < 0) { | |
| 800 | 800 | pr_err("%s: failed to add hogs for %pOF\n", __func__, | |
modified drivers/gpio/gpiolib.c
| @@ -1029,6 +1029,13 @@ int gpiochip_add_hog(struct gpio_chip *gc, struct fwnode_handle *fwnode) | |||
| 1029 | 1029 | ret = of_gpiochip_get_lflags(gc, &gpiospec, &lflags); | |
| 1030 | 1030 | if (ret) | |
| 1031 | 1031 | return ret; | |
| 1032 | + | ||
| 1033 | + | /* | |
| 1034 | + | * If no line-name property is present, fall back to the OF | |
| 1035 | + | * node name as in the previous implementation. | |
| 1036 | + | */ | |
| 1037 | + | if (!name) | |
| 1038 | + | name = to_of_node(fwnode)->name; | |
| 1032 | 1039 | } else { | |
| 1033 | 1040 | /* | |
| 1034 | 1041 | * GPIO_ACTIVE_LOW is currently the only lookup flag | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu.h
| @@ -621,6 +621,9 @@ enum amdgpu_enforce_isolation_mode { | |||
| 621 | 621 | struct amdgpu_device { | |
| 622 | 622 | struct device *dev; | |
| 623 | 623 | struct pci_dev *pdev; | |
| 624 | + | /* The two ends of the physical PCIe link outside the device. */ | |
| 625 | + | struct pci_dev *link_dev; | |
| 626 | + | struct pci_dev *link_partner; | |
| 624 | 627 | struct drm_device ddev; | |
| 625 | 628 | ||
| 626 | 629 | #ifdef CONFIG_DRM_AMD_ACP | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
| @@ -318,7 +318,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 318 | 318 | r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, | |
| 319 | 319 | acp_genpd_add_device); | |
| 320 | 320 | if (r) | |
| 321 | - | goto failure; | |
| 321 | + | goto failure_remove_mfd; | |
| 322 | 322 | break; | |
| 323 | 323 | } | |
| 324 | 324 | default: | |
| @@ -443,7 +443,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 443 | 443 | r = device_for_each_child(adev->acp.parent, &adev->acp.acp_genpd->gpd, | |
| 444 | 444 | acp_genpd_add_device); | |
| 445 | 445 | if (r) | |
| 446 | - | goto failure; | |
| 446 | + | goto failure_remove_mfd; | |
| 447 | 447 | } | |
| 448 | 448 | ||
| 449 | 449 | /* Assert Soft reset of ACP */ | |
| @@ -461,7 +461,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 461 | 461 | if (--count == 0) { | |
| 462 | 462 | dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); | |
| 463 | 463 | r = -ETIMEDOUT; | |
| 464 | - | goto failure; | |
| 464 | + | goto failure_remove_mfd; | |
| 465 | 465 | } | |
| 466 | 466 | udelay(100); | |
| 467 | 467 | } | |
| @@ -479,7 +479,7 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 479 | 479 | if (--count == 0) { | |
| 480 | 480 | dev_err(&adev->pdev->dev, "Failed to reset ACP\n"); | |
| 481 | 481 | r = -ETIMEDOUT; | |
| 482 | - | goto failure; | |
| 482 | + | goto failure_remove_mfd; | |
| 483 | 483 | } | |
| 484 | 484 | udelay(100); | |
| 485 | 485 | } | |
| @@ -489,6 +489,11 @@ static int acp_hw_init(struct amdgpu_ip_block *ip_block) | |||
| 489 | 489 | cgs_write_register(adev->acp.cgs_device, mmACP_SOFT_RESET, val); | |
| 490 | 490 | return 0; | |
| 491 | 491 | ||
| 492 | + | failure_remove_mfd: | |
| 493 | + | device_for_each_child(adev->acp.parent, NULL, | |
| 494 | + | acp_genpd_remove_device); | |
| 495 | + | mfd_remove_devices(adev->acp.parent); | |
| 496 | + | ||
| 492 | 497 | failure: | |
| 493 | 498 | kfree(adev->acp.i2s_pdata); | |
| 494 | 499 | kfree(adev->acp.acp_res); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c
| @@ -1167,8 +1167,10 @@ int amdgpu_acpi_enumerate_xcc(void) | |||
| 1167 | 1167 | } | |
| 1168 | 1168 | ||
| 1169 | 1169 | xcc_info = kzalloc_obj(struct amdgpu_acpi_xcc_info); | |
| 1170 | - | if (!xcc_info) | |
| 1170 | + | if (!xcc_info) { | |
| 1171 | + | acpi_dev_put(acpi_dev); | |
| 1171 | 1172 | return -ENOMEM; | |
| 1173 | + | } | |
| 1172 | 1174 | ||
| 1173 | 1175 | INIT_LIST_HEAD(&xcc_info->list); | |
| 1174 | 1176 | xcc_info->handle = acpi_device_handle(acpi_dev); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
| @@ -330,7 +330,7 @@ void amdgpu_amdkfd_clear_kfd_mapping(struct amdgpu_device *adev) | |||
| 330 | 330 | struct kfd_dev *kfd = adev->kfd.dev; | |
| 331 | 331 | unsigned int i; | |
| 332 | 332 | ||
| 333 | - | if (!kfd) | |
| 333 | + | if (!kfd || !kfd->init_complete) | |
| 334 | 334 | return; | |
| 335 | 335 | ||
| 336 | 336 | for (i = 0; i < kfd->num_nodes; i++) { | |
| @@ -598,14 +598,18 @@ int amdgpu_amdkfd_get_dmabuf_info(struct amdgpu_device *adev, int dma_buf_fd, | |||
| 598 | 598 | /* first get metadata_size by buffer = NULL */ | |
| 599 | 599 | r = amdgpu_bo_get_metadata(bo, NULL, 0, | |
| 600 | 600 | metadata_size, NULL); | |
| 601 | + | if (r) | |
| 602 | + | goto out_put; | |
| 601 | 603 | ||
| 602 | 604 | /* user buf_size is bigger than bo metadata_size | |
| 603 | 605 | * allocate a buf at kernel space and copy */ | |
| 604 | 606 | if (*metadata_size <= buffer_size) { | |
| 605 | 607 | *metadata_buffer = kzalloc(*metadata_size, GFP_KERNEL); | |
| 606 | 608 | ||
| 607 | - | if (!*metadata_buffer) | |
| 608 | - | return -ENOMEM; | |
| 609 | + | if (!*metadata_buffer) { | |
| 610 | + | r = -ENOMEM; | |
| 611 | + | goto out_put; | |
| 612 | + | } | |
| 609 | 613 | ||
| 610 | 614 | r = amdgpu_bo_get_metadata(bo, *metadata_buffer, *metadata_size, | |
| 611 | 615 | NULL, &metadata_flags); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
| @@ -121,6 +121,20 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f, | |||
| 121 | 121 | ||
| 122 | 122 | *pos &= (1UL << 22) - 1; | |
| 123 | 123 | ||
| 124 | + | if (size > PAGE_SIZE) | |
| 125 | + | return -EINVAL; | |
| 126 | + | ||
| 127 | + | /* | |
| 128 | + | * Access the user buffer only while none of the locks below are held: | |
| 129 | + | * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest | |
| 130 | + | * inside it. | |
| 131 | + | */ | |
| 132 | + | u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL); | |
| 133 | + | if (!data) | |
| 134 | + | return -ENOMEM; | |
| 135 | + | if (!read && copy_from_user(data, buf, size)) | |
| 136 | + | return -EFAULT; | |
| 137 | + | ||
| 124 | 138 | r = pm_runtime_get_sync(adev_to_drm(adev)->dev); | |
| 125 | 139 | if (r < 0) { | |
| 126 | 140 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| @@ -152,28 +166,16 @@ static int amdgpu_debugfs_process_reg_op(bool read, struct file *f, | |||
| 152 | 166 | mutex_lock(&adev->pm.mutex); | |
| 153 | 167 | ||
| 154 | 168 | while (size) { | |
| 155 | - | uint32_t value; | |
| 156 | - | ||
| 157 | - | if (read) { | |
| 158 | - | value = RREG32(*pos >> 2); | |
| 159 | - | r = put_user(value, (uint32_t *)buf); | |
| 160 | - | } else { | |
| 161 | - | r = get_user(value, (uint32_t *)buf); | |
| 162 | - | if (!r) | |
| 163 | - | amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, value, 0); | |
| 164 | - | } | |
| 165 | - | if (r) { | |
| 166 | - | result = r; | |
| 167 | - | goto end; | |
| 168 | - | } | |
| 169 | + | if (read) | |
| 170 | + | data[result >> 2] = RREG32(*pos >> 2); | |
| 171 | + | else | |
| 172 | + | amdgpu_mm_wreg_mmio_rlc(adev, *pos >> 2, data[result >> 2], 0); | |
| 169 | 173 | ||
| 170 | 174 | result += 4; | |
| 171 | - | buf += 4; | |
| 172 | 175 | *pos += 4; | |
| 173 | 176 | size -= 4; | |
| 174 | 177 | } | |
| 175 | 178 | ||
| 176 | - | end: | |
| 177 | 179 | if (use_bank) { | |
| 178 | 180 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, 0); | |
| 179 | 181 | mutex_unlock(&adev->grbm_idx_mutex); | |
| @@ -188,6 +190,10 @@ end: | |||
| 188 | 190 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 189 | 191 | ||
| 190 | 192 | amdgpu_virt_disable_access_debugfs(adev); | |
| 193 | + | ||
| 194 | + | if (read && copy_to_user(buf, data, result)) | |
| 195 | + | return -EFAULT; | |
| 196 | + | ||
| 191 | 197 | return result; | |
| 192 | 198 | } | |
| 193 | 199 | ||
| @@ -238,11 +244,24 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off | |||
| 238 | 244 | struct amdgpu_device *adev = rd->adev; | |
| 239 | 245 | ssize_t result = 0; | |
| 240 | 246 | int r; | |
| 241 | - | uint32_t value; | |
| 242 | 247 | ||
| 243 | 248 | if (size & 0x3 || offset & 0x3) | |
| 244 | 249 | return -EINVAL; | |
| 245 | 250 | ||
| 251 | + | if (size > PAGE_SIZE) | |
| 252 | + | return -EINVAL; | |
| 253 | + | ||
| 254 | + | /* | |
| 255 | + | * Access the user buffer only while none of the locks below are held: | |
| 256 | + | * a fault takes mmap_lock, and grbm_idx_mutex and srbm_mutex nest | |
| 257 | + | * inside it. | |
| 258 | + | */ | |
| 259 | + | u32 *data __free(kfree) = kmalloc(size, GFP_KERNEL); | |
| 260 | + | if (!data) | |
| 261 | + | return -ENOMEM; | |
| 262 | + | if (write_en && copy_from_user(data, buf, size)) | |
| 263 | + | return -EFAULT; | |
| 264 | + | ||
| 246 | 265 | r = pm_runtime_get_sync(adev_to_drm(adev)->dev); | |
| 247 | 266 | if (r < 0) { | |
| 248 | 267 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| @@ -281,24 +300,16 @@ static ssize_t amdgpu_debugfs_regs2_op(struct file *f, char __user *buf, u32 off | |||
| 281 | 300 | mutex_lock(&adev->pm.mutex); | |
| 282 | 301 | ||
| 283 | 302 | while (size) { | |
| 284 | - | if (!write_en) { | |
| 285 | - | value = RREG32(offset >> 2); | |
| 286 | - | r = put_user(value, (uint32_t *)buf); | |
| 287 | - | } else { | |
| 288 | - | r = get_user(value, (uint32_t *)buf); | |
| 289 | - | if (!r) | |
| 290 | - | amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, value, rd->id.xcc_id); | |
| 291 | - | } | |
| 292 | - | if (r) { | |
| 293 | - | result = r; | |
| 294 | - | goto end; | |
| 295 | - | } | |
| 303 | + | if (!write_en) | |
| 304 | + | data[result >> 2] = RREG32(offset >> 2); | |
| 305 | + | else | |
| 306 | + | amdgpu_mm_wreg_mmio_rlc(adev, offset >> 2, data[result >> 2], | |
| 307 | + | rd->id.xcc_id); | |
| 296 | 308 | offset += 4; | |
| 297 | 309 | size -= 4; | |
| 298 | 310 | result += 4; | |
| 299 | - | buf += 4; | |
| 300 | 311 | } | |
| 301 | - | end: | |
| 312 | + | ||
| 302 | 313 | if (rd->id.use_grbm) { | |
| 303 | 314 | amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff, rd->id.xcc_id); | |
| 304 | 315 | mutex_unlock(&adev->grbm_idx_mutex); | |
| @@ -317,6 +328,10 @@ end: | |||
| 317 | 328 | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 318 | 329 | ||
| 319 | 330 | amdgpu_virt_disable_access_debugfs(adev); | |
| 331 | + | ||
| 332 | + | if (!write_en && copy_to_user(buf, data, result)) | |
| 333 | + | return -EFAULT; | |
| 334 | + | ||
| 320 | 335 | return result; | |
| 321 | 336 | } | |
| 322 | 337 | ||
| @@ -1780,8 +1795,10 @@ static int amdgpu_debugfs_test_ib_show(struct seq_file *m, void *unused) | |||
| 1780 | 1795 | ||
| 1781 | 1796 | /* Avoid accidently unparking the sched thread during GPU reset */ | |
| 1782 | 1797 | r = down_write_killable(&adev->reset_domain->sem); | |
| 1783 | - | if (r) | |
| 1798 | + | if (r) { | |
| 1799 | + | pm_runtime_put_autosuspend(dev->dev); | |
| 1784 | 1800 | return r; | |
| 1801 | + | } | |
| 1785 | 1802 | ||
| 1786 | 1803 | /* hold on the scheduler */ | |
| 1787 | 1804 | for (i = 0; i < AMDGPU_MAX_RINGS; i++) { | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
| @@ -1954,18 +1954,17 @@ static void amdgpu_uid_fini(struct amdgpu_device *adev) | |||
| 1954 | 1954 | adev->uid_info = NULL; | |
| 1955 | 1955 | } | |
| 1956 | 1956 | ||
| 1957 | - | static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev) | |
| 1957 | + | static void amdgpu_device_init_pcie_links(struct amdgpu_device *adev) | |
| 1958 | 1958 | { | |
| 1959 | - | struct pci_dev *parent = adev->pdev; | |
| 1959 | + | adev->link_dev = adev->pdev; | |
| 1960 | + | adev->link_partner = pci_upstream_bridge(adev->link_dev); | |
| 1960 | 1961 | ||
| 1961 | - | /* skip upstream/downstream switches internal to dGPU */ | |
| 1962 | - | while ((parent = pci_upstream_bridge(parent))) { | |
| 1963 | - | if (parent->vendor == PCI_VENDOR_ID_ATI) | |
| 1964 | - | continue; | |
| 1965 | - | break; | |
| 1962 | + | /* Skip upstream/downstream switches internal to the dGPU. */ | |
| 1963 | + | while (adev->link_partner && | |
| 1964 | + | adev->link_partner->vendor == PCI_VENDOR_ID_ATI) { | |
| 1965 | + | adev->link_dev = adev->link_partner; | |
| 1966 | + | adev->link_partner = pci_upstream_bridge(adev->link_dev); | |
| 1966 | 1967 | } | |
| 1967 | - | ||
| 1968 | - | return parent; | |
| 1969 | 1968 | } | |
| 1970 | 1969 | ||
| 1971 | 1970 | /** | |
| @@ -1981,7 +1980,6 @@ static struct pci_dev *amdgpu_device_find_parent(struct amdgpu_device *adev) | |||
| 1981 | 1980 | static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |
| 1982 | 1981 | { | |
| 1983 | 1982 | struct amdgpu_ip_block *ip_block; | |
| 1984 | - | struct pci_dev *parent; | |
| 1985 | 1983 | bool total, skip_bios, early_full_gpu_access = false; | |
| 1986 | 1984 | uint32_t bios_flags; | |
| 1987 | 1985 | int i, r; | |
| @@ -2077,10 +2075,9 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) | |||
| 2077 | 2075 | !dev_is_removable(&adev->pdev->dev)) | |
| 2078 | 2076 | adev->flags |= AMD_IS_PX; | |
| 2079 | 2077 | ||
| 2080 | - | if (!(adev->flags & AMD_IS_APU)) { | |
| 2081 | - | parent = amdgpu_device_find_parent(adev); | |
| 2082 | - | adev->has_pr3 = parent ? pci_pr3_present(parent) : false; | |
| 2083 | - | } | |
| 2078 | + | if (!(adev->flags & AMD_IS_APU)) | |
| 2079 | + | adev->has_pr3 = adev->link_partner && | |
| 2080 | + | pci_pr3_present(adev->link_partner); | |
| 2084 | 2081 | ||
| 2085 | 2082 | adev->pm.pp_feature = amdgpu_pp_feature_mask; | |
| 2086 | 2083 | if (amdgpu_sriov_vf(adev) || sched_policy == KFD_SCHED_POLICY_NO_HWS) | |
| @@ -3776,6 +3773,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, | |||
| 3776 | 3773 | ||
| 3777 | 3774 | adev->shutdown = false; | |
| 3778 | 3775 | adev->flags = flags; | |
| 3776 | + | amdgpu_device_init_pcie_links(adev); | |
| 3779 | 3777 | ||
| 3780 | 3778 | if (amdgpu_force_asic_type >= 0 && amdgpu_force_asic_type < CHIP_LAST) | |
| 3781 | 3779 | adev->asic_type = amdgpu_force_asic_type; | |
| @@ -4337,7 +4335,7 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev) | |||
| 4337 | 4335 | ||
| 4338 | 4336 | void amdgpu_device_fini_sw(struct amdgpu_device *adev) | |
| 4339 | 4337 | { | |
| 4340 | - | int i, idx; | |
| 4338 | + | int i; | |
| 4341 | 4339 | bool px; | |
| 4342 | 4340 | ||
| 4343 | 4341 | amdgpu_device_ip_fini(adev); | |
| @@ -4379,11 +4377,9 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev) | |||
| 4379 | 4377 | if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA) | |
| 4380 | 4378 | vga_client_unregister(adev->pdev); | |
| 4381 | 4379 | ||
| 4382 | - | if (drm_dev_enter(adev_to_drm(adev), &idx)) { | |
| 4383 | - | ||
| 4380 | + | if (adev->rmmio) { | |
| 4384 | 4381 | iounmap(adev->rmmio); | |
| 4385 | 4382 | adev->rmmio = NULL; | |
| 4386 | - | drm_dev_exit(idx); | |
| 4387 | 4383 | } | |
| 4388 | 4384 | ||
| 4389 | 4385 | if (IS_ENABLED(CONFIG_PERF_EVENTS)) | |
| @@ -5872,11 +5868,9 @@ static void amdgpu_device_partner_bandwidth(struct amdgpu_device *adev, | |||
| 5872 | 5868 | *width = PCIE_LNK_WIDTH_UNKNOWN; | |
| 5873 | 5869 | ||
| 5874 | 5870 | if (amdgpu_device_pcie_dynamic_switching_supported(adev)) { | |
| 5875 | - | struct pci_dev *parent = amdgpu_device_find_parent(adev); | |
| 5876 | - | ||
| 5877 | - | if (parent) { | |
| 5878 | - | *speed = pcie_get_speed_cap(parent); | |
| 5879 | - | *width = pcie_get_width_cap(parent); | |
| 5871 | + | if (adev->link_partner) { | |
| 5872 | + | *speed = pcie_get_speed_cap(adev->link_partner); | |
| 5873 | + | *width = pcie_get_width_cap(adev->link_partner); | |
| 5880 | 5874 | } | |
| 5881 | 5875 | } else { | |
| 5882 | 5876 | /* use the current speeds rather than max if switching is not supported */ | |
| @@ -5898,21 +5892,11 @@ static void amdgpu_device_gpu_bandwidth(struct amdgpu_device *adev, | |||
| 5898 | 5892 | enum pci_bus_speed *speed, | |
| 5899 | 5893 | enum pcie_link_width *width) | |
| 5900 | 5894 | { | |
| 5901 | - | struct pci_dev *parent = adev->pdev; | |
| 5902 | - | ||
| 5903 | 5895 | if (!speed || !width) | |
| 5904 | 5896 | return; | |
| 5905 | 5897 | ||
| 5906 | - | /* use the device itself */ | |
| 5907 | - | *speed = pcie_get_speed_cap(adev->pdev); | |
| 5908 | - | *width = pcie_get_width_cap(adev->pdev); | |
| 5909 | - | ||
| 5910 | - | /* use the link outside the device */ | |
| 5911 | - | parent = amdgpu_device_find_parent(adev); | |
| 5912 | - | if (parent) { | |
| 5913 | - | *speed = pcie_get_speed_cap(parent); | |
| 5914 | - | *width = pcie_get_width_cap(parent); | |
| 5915 | - | } | |
| 5898 | + | *speed = pcie_get_speed_cap(adev->link_dev); | |
| 5899 | + | *width = pcie_get_width_cap(adev->link_dev); | |
| 5916 | 5900 | } | |
| 5917 | 5901 | ||
| 5918 | 5902 | /** | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
| @@ -1325,6 +1325,8 @@ static int amdgpu_discovery_sysfs_ips(struct amdgpu_device *adev, | |||
| 1325 | 1325 | ip_hw_instance->kobj.kset = &ip_hw_id->hw_id_kset; | |
| 1326 | 1326 | res = kobject_add(&ip_hw_instance->kobj, NULL, | |
| 1327 | 1327 | "%d", ip_hw_instance->num_instance); | |
| 1328 | + | if (res) | |
| 1329 | + | kobject_put(&ip_hw_instance->kobj); | |
| 1328 | 1330 | next_ip: | |
| 1329 | 1331 | if (reg_base_64) | |
| 1330 | 1332 | ip_offset += struct_size(ip, base_address_64, | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
| @@ -43,6 +43,7 @@ | |||
| 43 | 43 | #include <linux/dma-buf.h> | |
| 44 | 44 | #include <linux/dma-fence-array.h> | |
| 45 | 45 | #include <linux/pci-p2pdma.h> | |
| 46 | + | #include <linux/pm_runtime.h> | |
| 46 | 47 | ||
| 47 | 48 | static const struct dma_buf_attach_ops amdgpu_dma_buf_attach_ops; | |
| 48 | 49 | ||
| @@ -100,15 +101,54 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf, | |||
| 100 | 101 | pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0) | |
| 101 | 102 | attach->peer2peer = false; | |
| 102 | 103 | ||
| 104 | + | /* | |
| 105 | + | * Only allow P2P while the exporter is active, and keep it active | |
| 106 | + | * until detach. With runtime PM disabled take a plain reference so | |
| 107 | + | * the put in detach stays balanced. | |
| 108 | + | */ | |
| 109 | + | if (attach->peer2peer) { | |
| 110 | + | struct device *dev = adev_to_drm(adev)->dev; | |
| 111 | + | int ret = pm_runtime_get_if_active(dev); | |
| 112 | + | ||
| 113 | + | if (!ret) | |
| 114 | + | attach->peer2peer = false; | |
| 115 | + | else if (ret < 0) | |
| 116 | + | pm_runtime_get_noresume(dev); | |
| 117 | + | } | |
| 118 | + | ||
| 103 | 119 | r = dma_resv_lock(bo->tbo.base.resv, NULL); | |
| 104 | 120 | if (r) | |
| 105 | - | return r; | |
| 121 | + | goto err_pm_put; | |
| 106 | 122 | ||
| 107 | 123 | amdgpu_vm_bo_update_shared(bo); | |
| 108 | 124 | ||
| 109 | 125 | dma_resv_unlock(bo->tbo.base.resv); | |
| 110 | 126 | ||
| 111 | 127 | return 0; | |
| 128 | + | ||
| 129 | + | err_pm_put: | |
| 130 | + | if (attach->peer2peer) | |
| 131 | + | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 132 | + | return r; | |
| 133 | + | } | |
| 134 | + | ||
| 135 | + | /** | |
| 136 | + | * amdgpu_dma_buf_detach - &dma_buf_ops.detach implementation | |
| 137 | + | * | |
| 138 | + | * @dmabuf: DMA-buf where we remove the attachment from | |
| 139 | + | * @attach: the attachment to remove | |
| 140 | + | * | |
| 141 | + | * Drop the runtime PM reference taken in amdgpu_dma_buf_attach(). | |
| 142 | + | */ | |
| 143 | + | static void amdgpu_dma_buf_detach(struct dma_buf *dmabuf, | |
| 144 | + | struct dma_buf_attachment *attach) | |
| 145 | + | { | |
| 146 | + | struct drm_gem_object *obj = dmabuf->priv; | |
| 147 | + | struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); | |
| 148 | + | struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); | |
| 149 | + | ||
| 150 | + | if (attach->peer2peer) | |
| 151 | + | pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); | |
| 112 | 152 | } | |
| 113 | 153 | ||
| 114 | 154 | /** | |
| @@ -350,6 +390,7 @@ static void amdgpu_dma_buf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map | |||
| 350 | 390 | ||
| 351 | 391 | const struct dma_buf_ops amdgpu_dmabuf_ops = { | |
| 352 | 392 | .attach = amdgpu_dma_buf_attach, | |
| 393 | + | .detach = amdgpu_dma_buf_detach, | |
| 353 | 394 | .pin = amdgpu_dma_buf_pin, | |
| 354 | 395 | .unpin = amdgpu_dma_buf_unpin, | |
| 355 | 396 | .map_dma_buf = amdgpu_dma_buf_map, | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
| @@ -2664,6 +2664,14 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev) | |||
| 2664 | 2664 | struct amdgpu_device *adev = drm_to_adev(drm_dev); | |
| 2665 | 2665 | int r; | |
| 2666 | 2666 | ||
| 2667 | + | /* | |
| 2668 | + | * A GPU parked by vga_switcheroo has no power and no PCIe link, so the | |
| 2669 | + | * ASIC reset below would fail and abort the whole noirq suspend phase. | |
| 2670 | + | * Bail out like amdgpu_device_prepare/suspend/resume() already do. | |
| 2671 | + | */ | |
| 2672 | + | if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) | |
| 2673 | + | return 0; | |
| 2674 | + | ||
| 2667 | 2675 | if (amdgpu_acpi_should_gpu_reset(adev)) { | |
| 2668 | 2676 | amdgpu_device_lock_reset_domain(adev->reset_domain); | |
| 2669 | 2677 | r = amdgpu_asic_reset(adev); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_eviction_fence.c
| @@ -68,6 +68,9 @@ amdgpu_eviction_fence_suspend_worker(struct work_struct *work) | |||
| 68 | 68 | ||
| 69 | 69 | mutex_lock(&uq_mgr->userq_mutex); | |
| 70 | 70 | ||
| 71 | + | /* Fence waits are not allowed in a fence signalling critical section. */ | |
| 72 | + | amdgpu_userq_wait_for_signal(uq_mgr); | |
| 73 | + | ||
| 71 | 74 | /* | |
| 72 | 75 | * This is intentionally after taking the userq_mutex since we do | |
| 73 | 76 | * allocate memory while holding this lock, but only after ensuring that | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
| @@ -724,8 +724,14 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 724 | 724 | bool is_guilty_fence; | |
| 725 | 725 | bool is_guilty_context; | |
| 726 | 726 | ||
| 727 | - | last_seq = amdgpu_fence_read(ring) & ring->fence_drv.num_fences_mask; | |
| 728 | - | seq = ring->fence_drv.sync_seq & ring->fence_drv.num_fences_mask; | |
| 727 | + | last_seq = amdgpu_fence_read(ring); | |
| 728 | + | seq = ring->fence_drv.sync_seq; | |
| 729 | + | ||
| 730 | + | /* Hardware completion can precede the interrupt which signals fences. */ | |
| 731 | + | if (last_seq == seq) { | |
| 732 | + | amdgpu_fence_process(ring); | |
| 733 | + | return; | |
| 734 | + | } | |
| 729 | 735 | ||
| 730 | 736 | /* If there is nothing to reemit, return early and set an error on the fence | |
| 731 | 737 | * if applicable. If all of the fences are siganlled, this will be a nop. | |
| @@ -733,7 +739,9 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 733 | 739 | * we are skipping it on purpose. | |
| 734 | 740 | */ | |
| 735 | 741 | if (!ring->ring_backup_entries_to_copy) { | |
| 736 | - | amdgpu_fence_driver_force_completion(ring, &guilty_fence->base); | |
| 742 | + | if (guilty_fence) | |
| 743 | + | amdgpu_fence_driver_force_completion(ring, | |
| 744 | + | &guilty_fence->base); | |
| 737 | 745 | return; | |
| 738 | 746 | } | |
| 739 | 747 | ring->reemit = true; | |
| @@ -741,9 +749,8 @@ void amdgpu_ring_set_fence_errors_and_reemit(struct amdgpu_ring *ring, | |||
| 741 | 749 | spin_lock_irqsave(&ring->fence_drv.lock, flags); | |
| 742 | 750 | do { | |
| 743 | 751 | last_seq++; | |
| 744 | - | last_seq &= ring->fence_drv.num_fences_mask; | |
| 745 | 752 | ||
| 746 | - | ptr = &ring->fence_drv.fences[last_seq]; | |
| 753 | + | ptr = &ring->fence_drv.fences[last_seq & ring->fence_drv.num_fences_mask]; | |
| 747 | 754 | rcu_read_lock(); | |
| 748 | 755 | unprocessed = rcu_dereference(*ptr); | |
| 749 | 756 | ||
| @@ -800,26 +807,24 @@ void amdgpu_ring_backup_unprocessed_commands(struct amdgpu_ring *ring, | |||
| 800 | 807 | struct amdgpu_fence *fence; | |
| 801 | 808 | u32 seq, last_seq; | |
| 802 | 809 | ||
| 803 | - | last_seq = amdgpu_fence_read(ring) & ring->fence_drv.num_fences_mask; | |
| 804 | - | seq = ring->fence_drv.sync_seq & ring->fence_drv.num_fences_mask; | |
| 810 | + | last_seq = amdgpu_fence_read(ring); | |
| 811 | + | seq = ring->fence_drv.sync_seq; | |
| 805 | 812 | ring->ring_backup_entries_to_copy = 0; | |
| 806 | 813 | ||
| 807 | - | /* if we've already seen this fence, return early. | |
| 808 | - | * ring->ring_backup_entries_to_copy is set to 0 so | |
| 809 | - | * the reemit helper will return early as well to | |
| 810 | - | * avoid getting stuck in a reemit loop. | |
| 814 | + | /* | |
| 815 | + | * Avoid replay loops for a repeated guilty fence. NULL identifies a | |
| 816 | + | * collateral ring, whose pending commands still need backup. | |
| 811 | 817 | */ | |
| 812 | - | if (ring->guilty_fence == guilty_fence) { | |
| 818 | + | if (guilty_fence && ring->guilty_fence == guilty_fence) { | |
| 813 | 819 | ring->guilty_fence = NULL; | |
| 814 | 820 | return; | |
| 815 | 821 | } | |
| 816 | 822 | ring->guilty_fence = guilty_fence; | |
| 817 | 823 | ||
| 818 | - | do { | |
| 824 | + | while (last_seq != seq) { | |
| 819 | 825 | last_seq++; | |
| 820 | - | last_seq &= ring->fence_drv.num_fences_mask; | |
| 821 | 826 | ||
| 822 | - | ptr = &ring->fence_drv.fences[last_seq]; | |
| 827 | + | ptr = &ring->fence_drv.fences[last_seq & ring->fence_drv.num_fences_mask]; | |
| 823 | 828 | rcu_read_lock(); | |
| 824 | 829 | unprocessed = rcu_dereference(*ptr); | |
| 825 | 830 | ||
| @@ -829,7 +834,7 @@ void amdgpu_ring_backup_unprocessed_commands(struct amdgpu_ring *ring, | |||
| 829 | 834 | amdgpu_ring_backup_unprocessed_command(ring, fence); | |
| 830 | 835 | } | |
| 831 | 836 | rcu_read_unlock(); | |
| 832 | - | } while (last_seq != seq); | |
| 837 | + | } | |
| 833 | 838 | } | |
| 834 | 839 | ||
| 835 | 840 | struct amdgpu_fence * | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
| @@ -1080,20 +1080,17 @@ void amdgpu_gmc_init_vga_resv_regions(struct amdgpu_device *adev) | |||
| 1080 | 1080 | case CHIP_RENOIR: | |
| 1081 | 1081 | adev->mman.keep_stolen_vga_memory = true; | |
| 1082 | 1082 | break; | |
| 1083 | - | case CHIP_POLARIS10: | |
| 1084 | - | case CHIP_POLARIS11: | |
| 1085 | - | case CHIP_POLARIS12: | |
| 1086 | - | /* MacBookPros with switchable graphics put VRAM at 0 when | |
| 1087 | - | * the iGPU is enabled which results in cursor issues if | |
| 1088 | - | * the cursor ends up at 0. Reserve vram at 0 in that case. | |
| 1089 | - | */ | |
| 1090 | - | if (adev->gmc.vram_start == 0) | |
| 1091 | - | adev->mman.keep_stolen_vga_memory = true; | |
| 1092 | - | break; | |
| 1093 | 1083 | default: | |
| 1094 | 1084 | adev->mman.keep_stolen_vga_memory = false; | |
| 1095 | 1085 | break; | |
| 1096 | 1086 | } | |
| 1087 | + | /* MacBookPros with switchable graphics put VRAM at 0 when | |
| 1088 | + | * the iGPU is enabled which results in cursor issues if | |
| 1089 | + | * the cursor ends up at 0. Reserve vram at 0 in that case. | |
| 1090 | + | */ | |
| 1091 | + | if ((adev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) && | |
| 1092 | + | (adev->gmc.vram_start == 0)) | |
| 1093 | + | adev->mman.keep_stolen_vga_memory = true; | |
| 1097 | 1094 | ||
| 1098 | 1095 | if (amdgpu_sriov_vf(adev) || | |
| 1099 | 1096 | !amdgpu_device_has_display_hardware(adev)) { | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
| @@ -30,6 +30,7 @@ | |||
| 30 | 30 | #include <drm/amdgpu_drm.h> | |
| 31 | 31 | #include <drm/drm_drv.h> | |
| 32 | 32 | #include <drm/drm_fb_helper.h> | |
| 33 | + | #include <drm/drm_vblank.h> | |
| 33 | 34 | #include "amdgpu_uvd.h" | |
| 34 | 35 | #include "amdgpu_vce.h" | |
| 35 | 36 | #include "atom.h" | |
| @@ -1660,6 +1661,9 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc) | |||
| 1660 | 1661 | DRM_ERROR("Invalid crtc %u\n", pipe); | |
| 1661 | 1662 | return -EINVAL; | |
| 1662 | 1663 | } | |
| 1664 | + | if (!down_read_trylock(&adev->reset_domain->sem)) | |
| 1665 | + | return drm_crtc_vblank_count(crtc); | |
| 1666 | + | ||
| 1663 | 1667 | ||
| 1664 | 1668 | /* The hw increments its frame counter at start of vsync, not at start | |
| 1665 | 1669 | * of vblank, as is required by DRM core vblank counter handling. | |
| @@ -1705,6 +1709,7 @@ u32 amdgpu_get_vblank_counter_kms(struct drm_crtc *crtc) | |||
| 1705 | 1709 | DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n"); | |
| 1706 | 1710 | } | |
| 1707 | 1711 | ||
| 1712 | + | up_read(&adev->reset_domain->sem); | |
| 1708 | 1713 | return count; | |
| 1709 | 1714 | } | |
| 1710 | 1715 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
| @@ -254,7 +254,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
| 254 | 254 | ring->adev = adev; | |
| 255 | 255 | ring->num_hw_submission = sched_hw_submission; | |
| 256 | 256 | ring->sched_score = sched_score; | |
| 257 | - | ring->vmid_wait = dma_fence_get_stub(); | |
| 258 | 257 | ||
| 259 | 258 | ring->idx = adev->num_rings++; | |
| 260 | 259 | adev->rings[ring->idx] = ring; | |
| @@ -374,6 +373,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring, | |||
| 374 | 373 | ||
| 375 | 374 | ring->max_dw = max_dw; | |
| 376 | 375 | ring->hw_prio = hw_prio; | |
| 376 | + | ring->vmid_wait = dma_fence_get_stub(); | |
| 377 | 377 | ||
| 378 | 378 | if (!ring->no_scheduler && ring->funcs->type < AMDGPU_HW_IP_NUM) { | |
| 379 | 379 | hw_ip = ring->funcs->type; | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
| @@ -2342,7 +2342,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev) | |||
| 2342 | 2342 | void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev) | |
| 2343 | 2343 | { | |
| 2344 | 2344 | struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); | |
| 2345 | - | u32 num_clear_entities, num_move_entities; | |
| 2345 | + | u32 num_clear_entities, num_move_entities, sdma_ip_version; | |
| 2346 | 2346 | int r, i, j; | |
| 2347 | 2347 | ||
| 2348 | 2348 | if (!adev->mman.initialized || amdgpu_in_reset(adev) || | |
| @@ -2367,6 +2367,12 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev) | |||
| 2367 | 2367 | ||
| 2368 | 2368 | num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2369 | 2369 | num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES); | |
| 2370 | + | /* TODO: workaround for DCC corruption when moving BOs from multiple queues at | |
| 2371 | + | * the same time: use a single queue until the root cause is identified and fixed. | |
| 2372 | + | */ | |
| 2373 | + | sdma_ip_version = amdgpu_ip_version(adev, SDMA0_HWIP, 0); | |
| 2374 | + | if (sdma_ip_version == IP_VERSION(7, 0, 0) || sdma_ip_version == IP_VERSION(7, 0, 1)) | |
| 2375 | + | num_move_entities = 1; | |
| 2370 | 2376 | ||
| 2371 | 2377 | adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity, | |
| 2372 | 2378 | num_clear_entities); | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
| @@ -184,27 +184,27 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work) | |||
| 184 | 184 | void amdgpu_userq_start_hang_detect_work(struct amdgpu_usermode_queue *queue) | |
| 185 | 185 | { | |
| 186 | 186 | struct amdgpu_device *adev; | |
| 187 | - | unsigned long timeout_ms; | |
| 187 | + | unsigned long timeout_jiffies; | |
| 188 | 188 | ||
| 189 | 189 | adev = queue->userq_mgr->adev; | |
| 190 | 190 | /* Determine timeout based on queue type */ | |
| 191 | 191 | switch (queue->queue_type) { | |
| 192 | 192 | case AMDGPU_RING_TYPE_GFX: | |
| 193 | - | timeout_ms = adev->gfx_timeout; | |
| 193 | + | timeout_jiffies = adev->gfx_timeout; | |
| 194 | 194 | break; | |
| 195 | 195 | case AMDGPU_RING_TYPE_COMPUTE: | |
| 196 | - | timeout_ms = adev->compute_timeout; | |
| 196 | + | timeout_jiffies = adev->compute_timeout; | |
| 197 | 197 | break; | |
| 198 | 198 | case AMDGPU_RING_TYPE_SDMA: | |
| 199 | - | timeout_ms = adev->sdma_timeout; | |
| 199 | + | timeout_jiffies = adev->sdma_timeout; | |
| 200 | 200 | break; | |
| 201 | 201 | default: | |
| 202 | - | timeout_ms = adev->gfx_timeout; | |
| 202 | + | timeout_jiffies = adev->gfx_timeout; | |
| 203 | 203 | break; | |
| 204 | 204 | } | |
| 205 | 205 | ||
| 206 | 206 | queue_delayed_work(adev->reset_domain->wq, &queue->hang_detect_work, | |
| 207 | - | msecs_to_jiffies(timeout_ms)); | |
| 207 | + | timeout_jiffies); | |
| 208 | 208 | } | |
| 209 | 209 | ||
| 210 | 210 | void amdgpu_userq_process_fence_irq(struct amdgpu_device *adev, u32 doorbell) | |
| @@ -472,6 +472,7 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr, | |||
| 472 | 472 | u64 doorbell_index; | |
| 473 | 473 | struct drm_gem_object *gobj; | |
| 474 | 474 | struct amdgpu_userq_obj *db_obj = db_info->db_obj; | |
| 475 | + | struct amdgpu_bo *abo; | |
| 475 | 476 | int r, db_size; | |
| 476 | 477 | ||
| 477 | 478 | gobj = drm_gem_object_lookup(filp, db_info->doorbell_handle); | |
| @@ -480,7 +481,17 @@ amdgpu_userq_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr, | |||
| 480 | 481 | return -EINVAL; | |
| 481 | 482 | } | |
| 482 | 483 | ||
| 483 | - | db_obj->obj = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); | |
| 484 | + | /* | |
| 485 | + | * Pinning a regular BO into the doorbell domain would discard its | |
| 486 | + | * contents, possibly those of a buffer shared by another client. | |
| 487 | + | */ | |
| 488 | + | abo = gem_to_amdgpu_bo(gobj); | |
| 489 | + | if (!(abo->preferred_domains & AMDGPU_GEM_DOMAIN_DOORBELL)) { | |
| 490 | + | drm_gem_object_put(gobj); | |
| 491 | + | return -EINVAL; | |
| 492 | + | } | |
| 493 | + | ||
| 494 | + | db_obj->obj = amdgpu_bo_ref(abo); | |
| 484 | 495 | drm_gem_object_put(gobj); | |
| 485 | 496 | ||
| 486 | 497 | r = amdgpu_bo_reserve(db_obj->obj, true); | |
| @@ -1272,7 +1283,7 @@ amdgpu_userq_evict_all(struct amdgpu_userq_mgr *uq_mgr) | |||
| 1272 | 1283 | return ret; | |
| 1273 | 1284 | } | |
| 1274 | 1285 | ||
| 1275 | - | static void | |
| 1286 | + | void | |
| 1276 | 1287 | amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr) | |
| 1277 | 1288 | { | |
| 1278 | 1289 | struct amdgpu_usermode_queue *queue; | |
| @@ -1291,8 +1302,6 @@ amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr) | |||
| 1291 | 1302 | void | |
| 1292 | 1303 | amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr) | |
| 1293 | 1304 | { | |
| 1294 | - | /* Wait for any pending userqueue fence work to finish */ | |
| 1295 | - | amdgpu_userq_wait_for_signal(uq_mgr); | |
| 1296 | 1305 | amdgpu_userq_evict_all(uq_mgr); | |
| 1297 | 1306 | } | |
| 1298 | 1307 | ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
| @@ -162,6 +162,7 @@ void amdgpu_userq_mgr_cancel_reset_work(struct amdgpu_device *adev); | |||
| 162 | 162 | void amdgpu_userq_mgr_cancel_resume(struct amdgpu_userq_mgr *userq_mgr); | |
| 163 | 163 | void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr); | |
| 164 | 164 | ||
| 165 | + | void amdgpu_userq_wait_for_signal(struct amdgpu_userq_mgr *uq_mgr); | |
| 165 | 166 | void amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr); | |
| 166 | 167 | ||
| 167 | 168 | void amdgpu_userq_ensure_ev_fence(struct amdgpu_userq_mgr *userq_mgr, | |
modified drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
| @@ -2678,6 +2678,7 @@ error_free_root: | |||
| 2678 | 2678 | amdgpu_bo_unref(&root_bo); | |
| 2679 | 2679 | ||
| 2680 | 2680 | error_free_delayed: | |
| 2681 | + | dma_fence_put(vm->last_update); | |
| 2681 | 2682 | dma_fence_put(vm->last_tlb_flush); | |
| 2682 | 2683 | dma_fence_put(vm->last_unlocked); | |
| 2683 | 2684 | ttm_lru_bulk_move_fini(&adev->mman.bdev, &vm->lru_bulk_move); | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
| @@ -3808,6 +3808,7 @@ static int gfx_v11_0_cp_gfx_resume(struct amdgpu_device *adev) | |||
| 3808 | 3808 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
| 3809 | 3809 | tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz); | |
| 3810 | 3810 | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 3811 | + | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, KMD_QUEUE, 1); | |
| 3811 | 3812 | WREG32_SOC15(GC, 0, regCP_RB0_CNTL, tmp); | |
| 3812 | 3813 | ||
| 3813 | 3814 | /* Initialize the ring buffer's write pointers */ | |
| @@ -4216,6 +4217,7 @@ static int gfx_v11_0_gfx_mqd_init(struct amdgpu_device *adev, void *m, | |||
| 4216 | 4217 | tmp = regCP_GFX_HQD_CNTL_DEFAULT; | |
| 4217 | 4218 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BUFSZ, rb_bufsz); | |
| 4218 | 4219 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 4220 | + | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, KMD_QUEUE, prop->kernel_queue); | |
| 4219 | 4221 | #ifdef __BIG_ENDIAN | |
| 4220 | 4222 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, BUF_SWAP, 1); | |
| 4221 | 4223 | #endif | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
| @@ -2767,6 +2767,7 @@ static int gfx_v12_0_cp_gfx_resume(struct amdgpu_device *adev) | |||
| 2767 | 2767 | rb_bufsz = order_base_2(ring->ring_size / 8); | |
| 2768 | 2768 | tmp = REG_SET_FIELD(0, CP_RB0_CNTL, RB_BUFSZ, rb_bufsz); | |
| 2769 | 2769 | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 2770 | + | tmp = REG_SET_FIELD(tmp, CP_RB0_CNTL, KMD_QUEUE, 1); | |
| 2770 | 2771 | WREG32_SOC15(GC, 0, regCP_RB0_CNTL, tmp); | |
| 2771 | 2772 | ||
| 2772 | 2773 | /* Initialize the ring buffer's write pointers */ | |
| @@ -3059,6 +3060,7 @@ static int gfx_v12_0_gfx_mqd_init(struct amdgpu_device *adev, void *m, | |||
| 3059 | 3060 | tmp = regCP_GFX_HQD_CNTL_DEFAULT; | |
| 3060 | 3061 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BUFSZ, rb_bufsz); | |
| 3061 | 3062 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, RB_BLKSZ, rb_bufsz - 2); | |
| 3063 | + | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, KMD_QUEUE, prop->kernel_queue); | |
| 3062 | 3064 | #ifdef __BIG_ENDIAN | |
| 3063 | 3065 | tmp = REG_SET_FIELD(tmp, CP_GFX_HQD_CNTL, BUF_SWAP, 1); | |
| 3064 | 3066 | #endif | |
modified drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
| @@ -322,6 +322,14 @@ static const u32 verde_rlc_save_restore_register_list[] = | |||
| 322 | 322 | 0x00000000 | |
| 323 | 323 | }; | |
| 324 | 324 | ||
| 325 | + | static void gfx_v6_0_free_microcode(struct amdgpu_device *adev) | |
| 326 | + | { | |
| 327 | + | amdgpu_ucode_release(&adev->gfx.pfp_fw); | |
| 328 | + | amdgpu_ucode_release(&adev->gfx.me_fw); | |
| 329 | + | amdgpu_ucode_release(&adev->gfx.ce_fw); | |
| 330 | + | amdgpu_ucode_release(&adev->gfx.rlc_fw); | |
| 331 | + | } | |
| 332 | + | ||
| 325 | 333 | static int gfx_v6_0_init_microcode(struct amdgpu_device *adev) | |
| 326 | 334 | { | |
| 327 | 335 | const char *chip_name; | |
| @@ -3249,6 +3257,7 @@ static int gfx_v6_0_sw_fini(struct amdgpu_ip_block *ip_block) | |||
| 3249 | 3257 | amdgpu_ring_fini(&adev->gfx.compute_ring[i]); | |
| 3250 | 3258 | ||
| 3251 | 3259 | amdgpu_gfx_rlc_fini(adev); | |
| 3260 | + | gfx_v6_0_free_microcode(adev); | |
| 3252 | 3261 | ||
| 3253 | 3262 | return 0; | |
| 3254 | 3263 | } | |
modified drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
| @@ -327,7 +327,7 @@ static void gmc_v12_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, | |||
| 327 | 327 | return; | |
| 328 | 328 | } | |
| 329 | 329 | ||
| 330 | - | gmc_v12_0_flush_vm_hub(adev, vmid, vmhub, 0); | |
| 330 | + | gmc_v12_0_flush_vm_hub(adev, vmid, vmhub, flush_type); | |
| 331 | 331 | return; | |
| 332 | 332 | } | |
| 333 | 333 | ||
modified drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
| @@ -389,7 +389,7 @@ static void gmc_v12_1_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, | |||
| 389 | 389 | return; | |
| 390 | 390 | } | |
| 391 | 391 | ||
| 392 | - | gmc_v12_1_flush_vm_hub(adev, vmid, vmhub, 0); | |
| 392 | + | gmc_v12_1_flush_vm_hub(adev, vmid, vmhub, flush_type); | |
| 393 | 393 | return; | |
| 394 | 394 | } | |
| 395 | 395 | ||
modified drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
| @@ -361,8 +361,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 361 | 361 | ||
| 362 | 362 | compute_mqd = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 363 | 363 | if (IS_ERR(compute_mqd)) { | |
| 364 | - | DRM_ERROR("Failed to read user MQD\n"); | |
| 365 | - | r = -ENOMEM; | |
| 364 | + | r = PTR_ERR(compute_mqd); | |
| 366 | 365 | goto free_mqd; | |
| 367 | 366 | } | |
| 368 | 367 | ||
| @@ -406,8 +405,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 406 | 405 | ||
| 407 | 406 | mqd_gfx_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 408 | 407 | if (IS_ERR(mqd_gfx_v11)) { | |
| 409 | - | DRM_ERROR("Failed to read user MQD\n"); | |
| 410 | - | r = -ENOMEM; | |
| 408 | + | r = PTR_ERR(mqd_gfx_v11); | |
| 411 | 409 | goto free_mqd; | |
| 412 | 410 | } | |
| 413 | 411 | ||
| @@ -451,8 +449,7 @@ static int mes_userq_mqd_create(struct amdgpu_usermode_queue *queue, | |||
| 451 | 449 | ||
| 452 | 450 | mqd_sdma_v11 = memdup_user(u64_to_user_ptr(mqd_user->mqd), mqd_user->mqd_size); | |
| 453 | 451 | if (IS_ERR(mqd_sdma_v11)) { | |
| 454 | - | DRM_ERROR("Failed to read sdma user MQD\n"); | |
| 455 | - | r = -ENOMEM; | |
| 452 | + | r = PTR_ERR(mqd_sdma_v11); | |
| 456 | 453 | goto free_mqd; | |
| 457 | 454 | } | |
| 458 | 455 | ||
modified drivers/gpu/drm/amd/amdgpu/nbio_v7_9.c
| @@ -535,7 +535,7 @@ static void nbio_v7_9_handle_ras_controller_intr_no_bifring(struct amdgpu_device | |||
| 535 | 535 | RAS_CNTLR_INTERRUPT_CLEAR, 1); | |
| 536 | 536 | WREG32_SOC15(NBIO, 0, regBIF_BX0_BIF_DOORBELL_INT_CNTL, bif_doorbell_intr_cntl); | |
| 537 | 537 | ||
| 538 | - | if (!ras->disable_ras_err_cnt_harvest) { | |
| 538 | + | if (ras && !ras->disable_ras_err_cnt_harvest && obj) { | |
| 539 | 539 | /* | |
| 540 | 540 | * clear error status after ras_controller_intr | |
| 541 | 541 | * according to hw team and count ue number | |
modified drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
| @@ -1339,10 +1339,6 @@ static int sdma_v7_1_sw_init(struct amdgpu_ip_block *ip_block) | |||
| 1339 | 1339 | else | |
| 1340 | 1340 | DRM_ERROR("Failed to allocated memory for SDMA IP Dump\n"); | |
| 1341 | 1341 | ||
| 1342 | - | #ifdef CONFIG_DRM_AMDGPU_NAVI3X_USERQ | |
| 1343 | - | adev->userq_funcs[AMDGPU_HW_IP_DMA] = &userq_mes_funcs; | |
| 1344 | - | #endif | |
| 1345 | - | ||
| 1346 | 1342 | return r; | |
| 1347 | 1343 | } | |
| 1348 | 1344 | ||
modified drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
| @@ -1689,7 +1689,8 @@ static int vcn_v4_0_3_reset_jpeg_pre_helper(struct amdgpu_device *adev, int inst | |||
| 1689 | 1689 | /* if Jobs are still pending after timeout, | |
| 1690 | 1690 | * We'll handle them in the bottom helper | |
| 1691 | 1691 | */ | |
| 1692 | - | amdgpu_fence_wait_polling(ring, wait_seq, adev->video_timeout); | |
| 1692 | + | amdgpu_fence_wait_polling(ring, wait_seq, | |
| 1693 | + | jiffies_to_usecs(adev->video_timeout)); | |
| 1693 | 1694 | } | |
| 1694 | 1695 | ||
| 1695 | 1696 | return 0; | |
modified drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c
| @@ -1335,7 +1335,8 @@ static int vcn_v5_0_1_reset_jpeg_pre_helper(struct amdgpu_device *adev, int inst | |||
| 1335 | 1335 | /* if Jobs are still pending after timeout, | |
| 1336 | 1336 | * We'll handle them in the bottom helper | |
| 1337 | 1337 | */ | |
| 1338 | - | amdgpu_fence_wait_polling(ring, wait_seq, adev->video_timeout); | |
| 1338 | + | amdgpu_fence_wait_polling(ring, wait_seq, | |
| 1339 | + | jiffies_to_usecs(adev->video_timeout)); | |
| 1339 | 1340 | } | |
| 1340 | 1341 | ||
| 1341 | 1342 | return 0; | |
modified drivers/gpu/drm/amd/amdgpu/vi.c
| @@ -1397,6 +1397,7 @@ struct vi_reset_quirk { | |||
| 1397 | 1397 | static const struct vi_reset_quirk vi_reset_quirks[] = { | |
| 1398 | 1398 | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x0190, 0xe3 }, /* Radeon Pro 555X */ | |
| 1399 | 1399 | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x018f, 0xc2 }, /* Radeon Pro 560X */ | |
| 1400 | + | { 0x67ef, PCI_VENDOR_ID_APPLE, 0x017a, 0xc7 }, /* Radeon Pro 555 */ | |
| 1400 | 1401 | }; | |
| 1401 | 1402 | ||
| 1402 | 1403 | static bool vi_need_reset_on_init(struct amdgpu_device *adev) | |
modified drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
| @@ -35,6 +35,7 @@ | |||
| 35 | 35 | #include <linux/time.h> | |
| 36 | 36 | #include <linux/mm.h> | |
| 37 | 37 | #include <linux/mman.h> | |
| 38 | + | #include <linux/pseudo_fs.h> | |
| 38 | 39 | #include <linux/ptrace.h> | |
| 39 | 40 | #include <linux/dma-buf.h> | |
| 40 | 41 | #include <linux/processor.h> | |
| @@ -70,18 +71,54 @@ static const struct class kfd_class = { | |||
| 70 | 71 | }; | |
| 71 | 72 | ||
| 72 | 73 | /* | |
| 73 | - | * Cache the address space of the chardev on first open so that the reset | |
| 74 | - | * path can drop all userspace mappings of doorbell and MMIO ranges via | |
| 75 | - | * unmap_mapping_range(). | |
| 74 | + | * Private pseudo-filesystem for KFD, Provides a stable, module-owned | |
| 75 | + | * inode whose address_space is the unmap target for all /dev/kfd | |
| 76 | + | * openers during GPU reset. | |
| 76 | 77 | */ | |
| 77 | - | static struct address_space *kfd_dev_mapping; | |
| 78 | + | static struct vfsmount *kfd_fs_mnt; | |
| 79 | + | static int kfd_fs_cnt; | |
| 78 | 80 | ||
| 79 | - | void kfd_dev_unmap_mapping_range(loff_t const holebegin, loff_t const holelen) | |
| 81 | + | static int kfd_fs_init_fs_context(struct fs_context *fc) | |
| 82 | + | { | |
| 83 | + | return init_pseudo(fc, 0x4b464400 /* "KFD" */) ? 0 : -ENOMEM; | |
| 84 | + | } | |
| 85 | + | ||
| 86 | + | static struct file_system_type kfd_fs_type = { | |
| 87 | + | .name = "kfd", | |
| 88 | + | .init_fs_context = kfd_fs_init_fs_context, | |
| 89 | + | .kill_sb = kill_anon_super, | |
| 90 | + | }; | |
| 91 | + | ||
| 92 | + | static struct inode *kfd_fs_inode_new(void) | |
| 80 | 93 | { | |
| 81 | - | struct address_space *mapping = READ_ONCE(kfd_dev_mapping); | |
| 94 | + | struct inode *inode; | |
| 95 | + | int r; | |
| 96 | + | ||
| 97 | + | r = simple_pin_fs(&kfd_fs_type, &kfd_fs_mnt, &kfd_fs_cnt); | |
| 98 | + | if (r < 0) | |
| 99 | + | return ERR_PTR(r); | |
| 100 | + | ||
| 101 | + | inode = alloc_anon_inode(kfd_fs_mnt->mnt_sb); | |
| 102 | + | if (IS_ERR(inode)) | |
| 103 | + | simple_release_fs(&kfd_fs_mnt, &kfd_fs_cnt); | |
| 82 | 104 | ||
| 83 | - | if (mapping) | |
| 84 | - | unmap_mapping_range(mapping, holebegin, holelen, 1); | |
| 105 | + | return inode; | |
| 106 | + | } | |
| 107 | + | ||
| 108 | + | static void kfd_fs_inode_free(struct inode *inode) | |
| 109 | + | { | |
| 110 | + | if (inode) { | |
| 111 | + | iput(inode); | |
| 112 | + | simple_release_fs(&kfd_fs_mnt, &kfd_fs_cnt); | |
| 113 | + | } | |
| 114 | + | } | |
| 115 | + | ||
| 116 | + | static struct inode *kfd_anon_inode; | |
| 117 | + | ||
| 118 | + | void kfd_dev_unmap_mapping_range(loff_t const holebegin, loff_t const holelen) | |
| 119 | + | { | |
| 120 | + | if (kfd_anon_inode) | |
| 121 | + | unmap_mapping_range(kfd_anon_inode->i_mapping, holebegin, holelen, 1); | |
| 85 | 122 | } | |
| 86 | 123 | ||
| 87 | 124 | static inline struct kfd_process_device *kfd_lock_pdd_by_id(struct kfd_process *p, __u32 gpu_id) | |
| @@ -107,6 +144,13 @@ int kfd_chardev_init(void) | |||
| 107 | 144 | { | |
| 108 | 145 | int err = 0; | |
| 109 | 146 | ||
| 147 | + | kfd_anon_inode = kfd_fs_inode_new(); | |
| 148 | + | if (IS_ERR(kfd_anon_inode)) { | |
| 149 | + | err = PTR_ERR(kfd_anon_inode); | |
| 150 | + | kfd_anon_inode = NULL; | |
| 151 | + | return err; | |
| 152 | + | } | |
| 153 | + | ||
| 110 | 154 | kfd_char_dev_major = register_chrdev(0, kfd_dev_name, &kfd_fops); | |
| 111 | 155 | err = kfd_char_dev_major; | |
| 112 | 156 | if (err < 0) | |
| @@ -130,6 +174,8 @@ err_device_create: | |||
| 130 | 174 | err_class_create: | |
| 131 | 175 | unregister_chrdev(kfd_char_dev_major, kfd_dev_name); | |
| 132 | 176 | err_register_chrdev: | |
| 177 | + | kfd_fs_inode_free(kfd_anon_inode); | |
| 178 | + | kfd_anon_inode = NULL; | |
| 133 | 179 | return err; | |
| 134 | 180 | } | |
| 135 | 181 | ||
| @@ -138,6 +184,8 @@ void kfd_chardev_exit(void) | |||
| 138 | 184 | device_destroy(&kfd_class, MKDEV(kfd_char_dev_major, 0)); | |
| 139 | 185 | class_unregister(&kfd_class); | |
| 140 | 186 | unregister_chrdev(kfd_char_dev_major, kfd_dev_name); | |
| 187 | + | kfd_fs_inode_free(kfd_anon_inode); | |
| 188 | + | kfd_anon_inode = NULL; | |
| 141 | 189 | kfd_device = NULL; | |
| 142 | 190 | } | |
| 143 | 191 | ||
| @@ -150,12 +198,7 @@ static int kfd_open(struct inode *inode, struct file *filep) | |||
| 150 | 198 | if (iminor(inode) != 0) | |
| 151 | 199 | return -ENODEV; | |
| 152 | 200 | ||
| 153 | - | /* | |
| 154 | - | * /dev/kfd is a single chardev so all opens share one inode. Cache | |
| 155 | - | * its address_space on the first open for use by the reset path. | |
| 156 | - | */ | |
| 157 | - | if (!READ_ONCE(kfd_dev_mapping)) | |
| 158 | - | cmpxchg(&kfd_dev_mapping, NULL, inode->i_mapping); | |
| 201 | + | filep->f_mapping = kfd_anon_inode->i_mapping; | |
| 159 | 202 | ||
| 160 | 203 | is_32bit_user_mode = in_compat_syscall(); | |
| 161 | 204 | ||
modified drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
| @@ -572,12 +572,32 @@ static int allocate_doorbell(struct qcm_process_device *qpd, | |||
| 572 | 572 | * we need the physical sdma engine id in order to get the | |
| 573 | 573 | * correct doorbell offset. | |
| 574 | 574 | */ | |
| 575 | - | uint32_t valid_id = idx_offset[qpd->dqm->dev->node_id * | |
| 576 | - | get_num_all_sdma_engines(qpd->dqm) + | |
| 577 | - | q->properties.sdma_engine_id] | |
| 578 | - | + (q->properties.sdma_queue_id & 1) | |
| 579 | - | * KFD_QUEUE_DOORBELL_MIRROR_OFFSET | |
| 580 | - | + (q->properties.sdma_queue_id >> 1); | |
| 575 | + | u32 engine_base = idx_offset[dev->node_id * | |
| 576 | + | get_num_all_sdma_engines(qpd->dqm) + | |
| 577 | + | q->properties.sdma_engine_id]; | |
| 578 | + | u32 valid_id; | |
| 579 | + | ||
| 580 | + | /* | |
| 581 | + | * With the aqua_vanjaram doorbell layout, a shader doorbell | |
| 582 | + | * write whose 32-byte block starts in the previous engine's | |
| 583 | + | * range rings that engine instead. Engine ranges are 10 | |
| 584 | + | * indices apart (sdma_doorbell_range = 20 dwords, halved for | |
| 585 | + | * 8-byte doorbells, in aqua_vanjaram_doorbell_index_init()), | |
| 586 | + | * which puts odd engines 2 indices into a shared block. | |
| 587 | + | * Aligning costs at most 2 indices, and 8 queues per engine use | |
| 588 | + | * only 4 of the 10, so the aligned base stays in range. The | |
| 589 | + | * 512-index mirror offset keeps the alignment. | |
| 590 | + | */ | |
| 591 | + | if (KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 3) || | |
| 592 | + | KFD_GC_VERSION(dev) == IP_VERSION(9, 4, 4) || | |
| 593 | + | KFD_GC_VERSION(dev) == IP_VERSION(9, 5, 0)) | |
| 594 | + | engine_base = ALIGN(engine_base, | |
| 595 | + | KFD_SDMA_SHADER_DOORBELL_GRANULARITY); | |
| 596 | + | ||
| 597 | + | valid_id = engine_base + | |
| 598 | + | (q->properties.sdma_queue_id & 1) * | |
| 599 | + | KFD_QUEUE_DOORBELL_MIRROR_OFFSET + | |
| 600 | + | (q->properties.sdma_queue_id >> 1); | |
| 581 | 601 | ||
| 582 | 602 | if (restore_id && *restore_id != valid_id) | |
| 583 | 603 | return -EINVAL; | |
| @@ -770,10 +790,12 @@ static int create_queue_nocpsch(struct device_queue_manager *dqm, | |||
| 770 | 790 | mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type( | |
| 771 | 791 | q->properties.type)]; | |
| 772 | 792 | if (qd && !mqd_mgr->restore_mqd) { | |
| 773 | - | pr_debug("restore_mqd not implemented for this GPU\n"); | |
| 793 | + | pr_debug("restore_mqd not implemented for queue type %d\n", | |
| 794 | + | q->properties.type); | |
| 774 | 795 | retval = -EOPNOTSUPP; | |
| 775 | 796 | goto deallocate_vmid; | |
| 776 | 797 | } | |
| 798 | + | ||
| 777 | 799 | if (q->properties.type == KFD_QUEUE_TYPE_COMPUTE) { | |
| 778 | 800 | retval = allocate_hqd(dqm, q); | |
| 779 | 801 | if (retval) | |
| @@ -2250,7 +2272,8 @@ static int create_queue_cpsch(struct device_queue_manager *dqm, struct queue *q, | |||
| 2250 | 2272 | mqd_mgr = dqm->mqd_mgrs[get_mqd_type_from_queue_type( | |
| 2251 | 2273 | q->properties.type)]; | |
| 2252 | 2274 | if (qd && !mqd_mgr->restore_mqd) { | |
| 2253 | - | pr_debug("restore_mqd not implemented for this GPU\n"); | |
| 2275 | + | pr_debug("restore_mqd not implemented for queue type %d\n", | |
| 2276 | + | q->properties.type); | |
| 2254 | 2277 | retval = -EOPNOTSUPP; | |
| 2255 | 2278 | goto out_deallocate_doorbell; | |
| 2256 | 2279 | } | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v10.c
| @@ -204,7 +204,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 204 | 204 | * is safe, giving a maximum field value of 0xA. | |
| 205 | 205 | */ | |
| 206 | 206 | m->cp_hqd_eop_control = q->eop_ring_buffer_size ? min(0xA, | |
| 207 | - | ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1) : 0; | |
| 207 | + | ffs(q->eop_ring_buffer_size / sizeof(unsigned int) / 4)) : 0; | |
| 208 | 208 | m->cp_hqd_eop_base_addr_lo = | |
| 209 | 209 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
| 210 | 210 | m->cp_hqd_eop_base_addr_hi = | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v11.c
| @@ -242,7 +242,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 242 | 242 | * is safe, giving a maximum field value of 0xA. | |
| 243 | 243 | */ | |
| 244 | 244 | m->cp_hqd_eop_control = q->eop_ring_buffer_size ? min(0xA, | |
| 245 | - | ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1) : 0; | |
| 245 | + | ffs(q->eop_ring_buffer_size / sizeof(unsigned int) / 4)) : 0; | |
| 246 | 246 | m->cp_hqd_eop_base_addr_lo = | |
| 247 | 247 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
| 248 | 248 | m->cp_hqd_eop_base_addr_hi = | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12.c
| @@ -217,7 +217,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 217 | 217 | * is safe, giving a maximum field value of 0xA. | |
| 218 | 218 | */ | |
| 219 | 219 | m->cp_hqd_eop_control = q->eop_ring_buffer_size ? min(0xA, | |
| 220 | - | ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1) : 0; | |
| 220 | + | ffs(q->eop_ring_buffer_size / sizeof(unsigned int) / 4)) : 0; | |
| 221 | 221 | m->cp_hqd_eop_base_addr_lo = | |
| 222 | 222 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
| 223 | 223 | m->cp_hqd_eop_base_addr_hi = | |
| @@ -380,6 +380,63 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) | |||
| 380 | 380 | ||
| 381 | 381 | #endif | |
| 382 | 382 | ||
| 383 | + | static void restore_mqd(struct mqd_manager *mm, void **mqd, | |
| 384 | + | struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, | |
| 385 | + | struct queue_properties *qp, const void *mqd_src, | |
| 386 | + | const void *ctl_stack_src, const u32 ctl_stack_size) | |
| 387 | + | { | |
| 388 | + | u64 addr; | |
| 389 | + | struct v12_compute_mqd *m; | |
| 390 | + | ||
| 391 | + | m = (struct v12_compute_mqd *)mqd_mem_obj->cpu_ptr; | |
| 392 | + | addr = mqd_mem_obj->gpu_addr; | |
| 393 | + | ||
| 394 | + | memset(m, 0, AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size)); | |
| 395 | + | memcpy(m, mqd_src, sizeof(*m)); | |
| 396 | + | ||
| 397 | + | /* Update MQD base address to the newly allocated location */ | |
| 398 | + | m->cp_mqd_base_addr_lo = lower_32_bits(addr); | |
| 399 | + | m->cp_mqd_base_addr_hi = upper_32_bits(addr); | |
| 400 | + | ||
| 401 | + | m->cp_hqd_pq_doorbell_control &= | |
| 402 | + | ~CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET_MASK; | |
| 403 | + | m->cp_hqd_pq_doorbell_control |= | |
| 404 | + | qp->doorbell_off << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; | |
| 405 | + | pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", m->cp_hqd_pq_doorbell_control); | |
| 406 | + | ||
| 407 | + | *mqd = m; | |
| 408 | + | if (gart_addr) | |
| 409 | + | *gart_addr = addr; | |
| 410 | + | ||
| 411 | + | qp->is_active = 0; | |
| 412 | + | } | |
| 413 | + | ||
| 414 | + | static void restore_mqd_sdma(struct mqd_manager *mm, void **mqd, | |
| 415 | + | struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, | |
| 416 | + | struct queue_properties *qp, | |
| 417 | + | const void *mqd_src, | |
| 418 | + | const void *ctl_stack_src, | |
| 419 | + | const u32 ctl_stack_size) | |
| 420 | + | { | |
| 421 | + | u64 addr; | |
| 422 | + | struct v12_sdma_mqd *m; | |
| 423 | + | ||
| 424 | + | m = (struct v12_sdma_mqd *)mqd_mem_obj->cpu_ptr; | |
| 425 | + | addr = mqd_mem_obj->gpu_addr; | |
| 426 | + | ||
| 427 | + | memset(m, 0, AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size)); | |
| 428 | + | memcpy(m, mqd_src, sizeof(*m)); | |
| 429 | + | ||
| 430 | + | m->sdmax_rlcx_doorbell_offset = | |
| 431 | + | qp->doorbell_off << SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT; | |
| 432 | + | ||
| 433 | + | *mqd = m; | |
| 434 | + | if (gart_addr) | |
| 435 | + | *gart_addr = addr; | |
| 436 | + | ||
| 437 | + | qp->is_active = 0; | |
| 438 | + | } | |
| 439 | + | ||
| 383 | 440 | struct mqd_manager *mqd_manager_init_v12(enum KFD_MQD_TYPE type, | |
| 384 | 441 | struct kfd_node *dev) | |
| 385 | 442 | { | |
| @@ -407,6 +464,7 @@ struct mqd_manager *mqd_manager_init_v12(enum KFD_MQD_TYPE type, | |||
| 407 | 464 | mqd->mqd_size = sizeof(struct v12_compute_mqd); | |
| 408 | 465 | mqd->get_wave_state = get_wave_state; | |
| 409 | 466 | mqd->mqd_stride = kfd_mqd_stride; | |
| 467 | + | mqd->restore_mqd = restore_mqd; | |
| 410 | 468 | #if defined(CONFIG_DEBUG_FS) | |
| 411 | 469 | mqd->debugfs_show_mqd = debugfs_show_mqd; | |
| 412 | 470 | #endif | |
| @@ -453,6 +511,7 @@ struct mqd_manager *mqd_manager_init_v12(enum KFD_MQD_TYPE type, | |||
| 453 | 511 | mqd->is_occupied = kfd_is_occupied_sdma; | |
| 454 | 512 | mqd->mqd_size = sizeof(struct v12_sdma_mqd); | |
| 455 | 513 | mqd->mqd_stride = kfd_mqd_stride; | |
| 514 | + | mqd->restore_mqd = restore_mqd_sdma; | |
| 456 | 515 | #if defined(CONFIG_DEBUG_FS) | |
| 457 | 516 | mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; | |
| 458 | 517 | #endif | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c
| @@ -295,7 +295,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 295 | 295 | * is safe, giving a maximum field value of 0xA. | |
| 296 | 296 | */ | |
| 297 | 297 | m->cp_hqd_eop_control = q->eop_ring_buffer_size ? min(0xA, | |
| 298 | - | ffs(q->eop_ring_buffer_size / sizeof(unsigned int)) - 1 - 1) : 0; | |
| 298 | + | ffs(q->eop_ring_buffer_size / sizeof(unsigned int) / 4)) : 0; | |
| 299 | 299 | m->cp_hqd_eop_base_addr_lo = | |
| 300 | 300 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
| 301 | 301 | m->cp_hqd_eop_base_addr_hi = | |
| @@ -641,6 +641,72 @@ static int debugfs_show_mqd_sdma(struct seq_file *m, void *data) | |||
| 641 | 641 | ||
| 642 | 642 | #endif | |
| 643 | 643 | ||
| 644 | + | static void restore_mqd_v12_1(struct mqd_manager *mm, void **mqd, | |
| 645 | + | struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, | |
| 646 | + | struct queue_properties *qp, const void *mqd_src, | |
| 647 | + | const void *ctl_stack_src, const u32 ctl_stack_size) | |
| 648 | + | { | |
| 649 | + | u64 addr; | |
| 650 | + | struct v12_1_compute_mqd *m; | |
| 651 | + | ||
| 652 | + | /* | |
| 653 | + | * GFX12.1 is multi-XCC capable but this restore handles XCC0 only. | |
| 654 | + | * Multi-XCC CRIU restore is currently unreachable because | |
| 655 | + | * kfd_criu_restore_queue() validates against unscaled mqd_size. | |
| 656 | + | */ | |
| 657 | + | if (NUM_XCC(mm->dev->xcc_mask) > 1) | |
| 658 | + | pr_warn_once("GFX12.1 multi-XCC CRIU restore not fully supported\n"); | |
| 659 | + | ||
| 660 | + | m = (struct v12_1_compute_mqd *)mqd_mem_obj->cpu_ptr; | |
| 661 | + | addr = mqd_mem_obj->gpu_addr; | |
| 662 | + | ||
| 663 | + | memset(m, 0, AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size) * | |
| 664 | + | NUM_XCC(mm->dev->xcc_mask)); | |
| 665 | + | memcpy(m, mqd_src, sizeof(*m)); | |
| 666 | + | ||
| 667 | + | /* Update MQD base address to the newly allocated location */ | |
| 668 | + | m->cp_mqd_base_addr_lo = lower_32_bits(addr); | |
| 669 | + | m->cp_mqd_base_addr_hi = upper_32_bits(addr); | |
| 670 | + | ||
| 671 | + | m->cp_hqd_pq_doorbell_control &= | |
| 672 | + | ~CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET_MASK; | |
| 673 | + | m->cp_hqd_pq_doorbell_control |= | |
| 674 | + | qp->doorbell_off << CP_HQD_PQ_DOORBELL_CONTROL__DOORBELL_OFFSET__SHIFT; | |
| 675 | + | pr_debug("cp_hqd_pq_doorbell_control 0x%x\n", m->cp_hqd_pq_doorbell_control); | |
| 676 | + | ||
| 677 | + | *mqd = m; | |
| 678 | + | if (gart_addr) | |
| 679 | + | *gart_addr = addr; | |
| 680 | + | ||
| 681 | + | qp->is_active = 0; | |
| 682 | + | } | |
| 683 | + | ||
| 684 | + | static void restore_mqd_sdma_v12_1(struct mqd_manager *mm, void **mqd, | |
| 685 | + | struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr, | |
| 686 | + | struct queue_properties *qp, | |
| 687 | + | const void *mqd_src, | |
| 688 | + | const void *ctl_stack_src, | |
| 689 | + | const u32 ctl_stack_size) | |
| 690 | + | { | |
| 691 | + | u64 addr; | |
| 692 | + | struct v12_sdma_mqd *m; | |
| 693 | + | ||
| 694 | + | m = (struct v12_sdma_mqd *)mqd_mem_obj->cpu_ptr; | |
| 695 | + | addr = mqd_mem_obj->gpu_addr; | |
| 696 | + | ||
| 697 | + | memset(m, 0, AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size)); | |
| 698 | + | memcpy(m, mqd_src, sizeof(*m)); | |
| 699 | + | ||
| 700 | + | m->sdmax_rlcx_doorbell_offset = | |
| 701 | + | qp->doorbell_off << SDMA0_SDMA_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT; | |
| 702 | + | ||
| 703 | + | *mqd = m; | |
| 704 | + | if (gart_addr) | |
| 705 | + | *gart_addr = addr; | |
| 706 | + | ||
| 707 | + | qp->is_active = 0; | |
| 708 | + | } | |
| 709 | + | ||
| 644 | 710 | struct mqd_manager *mqd_manager_init_v12_1(enum KFD_MQD_TYPE type, | |
| 645 | 711 | struct kfd_node *dev) | |
| 646 | 712 | { | |
| @@ -668,6 +734,7 @@ struct mqd_manager *mqd_manager_init_v12_1(enum KFD_MQD_TYPE type, | |||
| 668 | 734 | mqd->mqd_size = sizeof(struct v12_1_compute_mqd); | |
| 669 | 735 | mqd->get_wave_state = get_wave_state_v12_1; | |
| 670 | 736 | mqd->mqd_stride = kfd_mqd_stride; | |
| 737 | + | mqd->restore_mqd = restore_mqd_v12_1; | |
| 671 | 738 | #if defined(CONFIG_DEBUG_FS) | |
| 672 | 739 | mqd->debugfs_show_mqd = debugfs_show_mqd; | |
| 673 | 740 | #endif | |
| @@ -714,6 +781,7 @@ struct mqd_manager *mqd_manager_init_v12_1(enum KFD_MQD_TYPE type, | |||
| 714 | 781 | mqd->is_occupied = kfd_is_occupied_sdma; | |
| 715 | 782 | mqd->mqd_size = sizeof(struct v12_sdma_mqd); | |
| 716 | 783 | mqd->mqd_stride = kfd_mqd_stride; | |
| 784 | + | mqd->restore_mqd = restore_mqd_sdma_v12_1; | |
| 717 | 785 | #if defined(CONFIG_DEBUG_FS) | |
| 718 | 786 | mqd->debugfs_show_mqd = debugfs_show_mqd_sdma; | |
| 719 | 787 | #endif | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c
| @@ -285,6 +285,10 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 285 | 285 | 1 << CP_HQD_IB_CONTROL__IB_EXE_DISABLE__SHIFT; | |
| 286 | 286 | ||
| 287 | 287 | /* | |
| 288 | + | * The lowest 6 bits of eop_control store the EOP ring size. If | |
| 289 | + | * their value is X, the ring size is 2^(X + 1) dwords, or | |
| 290 | + | * 2^(X + 3) bytes. | |
| 291 | + | * | |
| 288 | 292 | * HW does not clamp this field correctly. Maximum EOP queue size | |
| 289 | 293 | * is constrained by per-SE EOP done signal count, which is 8-bit. | |
| 290 | 294 | * Limit is 0xFF EOP entries (= 0x7F8 dwords). CP will not submit | |
| @@ -296,7 +300,7 @@ static void update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 296 | 300 | * | |
| 297 | 301 | */ | |
| 298 | 302 | m->cp_hqd_eop_control = q->eop_ring_buffer_size ? | |
| 299 | - | min(0xA, order_base_2(q->eop_ring_buffer_size / 4) - 1) : 0; | |
| 303 | + | min(0xA, order_base_2(q->eop_ring_buffer_size / 8)) : 0; | |
| 300 | 304 | ||
| 301 | 305 | m->cp_hqd_eop_base_addr_lo = | |
| 302 | 306 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
modified drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_vi.c
| @@ -208,6 +208,9 @@ static void __update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 208 | 208 | mtype << CP_HQD_IB_CONTROL__MTYPE__SHIFT; | |
| 209 | 209 | ||
| 210 | 210 | /* | |
| 211 | + | * The lowest 6 bits of eop_control store the EOP ring size. If | |
| 212 | + | * their value is X, the ring size is 2^(X + 1) dwords, or | |
| 213 | + | * 2^(X + 3) bytes. | |
| 211 | 214 | * HW does not clamp this field correctly. Maximum EOP queue size | |
| 212 | 215 | * is constrained by per-SE EOP done signal count, which is 8-bit. | |
| 213 | 216 | * Limit is 0xFF EOP entries (= 0x7F8 dwords). CP will not submit | |
| @@ -215,7 +218,7 @@ static void __update_mqd(struct mqd_manager *mm, void *mqd, | |||
| 215 | 218 | * is safe, giving a maximum field value of 0xA. | |
| 216 | 219 | */ | |
| 217 | 220 | m->cp_hqd_eop_control |= q->eop_ring_buffer_size ? min(0xA, | |
| 218 | - | order_base_2(q->eop_ring_buffer_size / 4) - 1) : 0; | |
| 221 | + | order_base_2(q->eop_ring_buffer_size / 8)) : 0; | |
| 219 | 222 | m->cp_hqd_eop_base_addr_lo = | |
| 220 | 223 | lower_32_bits(q->eop_ring_buffer_address >> 8); | |
| 221 | 224 | m->cp_hqd_eop_base_addr_hi = | |
modified drivers/gpu/drm/amd/amdkfd/kfd_priv.h
| @@ -133,6 +133,13 @@ | |||
| 133 | 133 | */ | |
| 134 | 134 | #define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 | |
| 135 | 135 | ||
| 136 | + | /* | |
| 137 | + | * On GC 9.4.3, 9.4.4 and 9.5.0, doorbell writes issued from shaders are | |
| 138 | + | * routed to an SDMA engine at 32-byte granularity, i.e. 4 indices with the | |
| 139 | + | * 8-byte SDMA doorbells used on SOC15. | |
| 140 | + | */ | |
| 141 | + | #define KFD_SDMA_SHADER_DOORBELL_GRANULARITY 4 | |
| 142 | + | ||
| 136 | 143 | /** | |
| 137 | 144 | * enum kfd_ioctl_flags - KFD ioctl flags | |
| 138 | 145 | * Various flags that can be set in &amdkfd_ioctl_desc.flags to control how | |
modified drivers/gpu/drm/amd/amdkfd/kfd_svm.c
| @@ -1752,12 +1752,15 @@ static int svm_range_validate_and_map(struct mm_struct *mm, | |||
| 1752 | 1752 | } | |
| 1753 | 1753 | ||
| 1754 | 1754 | /* | |
| 1755 | - | * If prange with always mapped flag, update mapping on GPUs with | |
| 1756 | - | * ACCESS attribute | |
| 1755 | + | * If prange with always mapped flag is not mapped or migrated | |
| 1756 | + | * yet, update mapping on GPUs with ACCESS attribute. Don't add | |
| 1757 | + | * them otherwise, ACCESS GPUs may be on different XGMI hives, | |
| 1758 | + | * that would force hmm_range_fault to migrate VRAM back to ram. | |
| 1757 | 1759 | */ | |
| 1758 | - | if (prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED) | |
| 1759 | - | bitmap_or(ctx->bitmap, ctx->bitmap, prange->bitmap_access, | |
| 1760 | - | MAX_GPU_INSTANCE); | |
| 1760 | + | if (bitmap_empty(ctx->bitmap, MAX_GPU_INSTANCE) && | |
| 1761 | + | prange->flags & KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED) | |
| 1762 | + | bitmap_copy(ctx->bitmap, prange->bitmap_access, | |
| 1763 | + | MAX_GPU_INSTANCE); | |
| 1761 | 1764 | } else { | |
| 1762 | 1765 | bitmap_or(ctx->bitmap, prange->bitmap_access, | |
| 1763 | 1766 | prange->bitmap_aip, MAX_GPU_INSTANCE); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
| @@ -426,6 +426,8 @@ static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm) | |||
| 426 | 426 | init_data[i].use_custom_backlight_caps = false; | |
| 427 | 427 | init_data[i].custom_backlight_caps_config_no = 0; | |
| 428 | 428 | init_data[i].use_linear_backlight_curve = false; | |
| 429 | + | if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE) | |
| 430 | + | init_data[i].use_linear_backlight_curve = true; | |
| 429 | 431 | init_data[i].def_varibright_enable = 0; | |
| 430 | 432 | init_data[i].varibright_level = 0; | |
| 431 | 433 | /* | |
| @@ -1420,7 +1422,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, | |||
| 1420 | 1422 | if (acrtc && state->stream_status[i].plane_count != 0 && | |
| 1421 | 1423 | amdgpu_ip_version(adev, DCE_HWIP, 0) == 0) { | |
| 1422 | 1424 | irq_source = IRQ_TYPE_PFLIP + acrtc->otg_inst; | |
| 1423 | - | rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY; | |
| 1425 | + | rc = amdgpu_dm_irq_set(adev, irq_source, enable) ? 0 : -EBUSY; | |
| 1424 | 1426 | if (rc) | |
| 1425 | 1427 | drm_warn(adev_to_drm(adev), "Failed to %s pflip interrupts\n", | |
| 1426 | 1428 | enable ? "enable" : "disable"); | |
| @@ -1444,7 +1446,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, | |||
| 1444 | 1446 | /* During gpu-reset we disable and then enable vblank irq, so | |
| 1445 | 1447 | * don't use amdgpu_irq_get/put() to avoid refcount change. | |
| 1446 | 1448 | */ | |
| 1447 | - | if (!dc_interrupt_set(adev->dm.dc, irq_source, enable)) | |
| 1449 | + | if (!amdgpu_dm_irq_set(adev, irq_source, enable)) | |
| 1448 | 1450 | drm_warn(adev_to_drm(adev), "Failed to %sable vblank interrupt\n", enable ? "en" : "dis"); | |
| 1449 | 1451 | ||
| 1450 | 1452 | } else if (acrtc && state->stream_status[i].plane_count != 0) { | |
| @@ -1582,9 +1584,14 @@ static int dm_suspend(struct amdgpu_ip_block *ip_block) | |||
| 1582 | 1584 | dc_allow_idle_optimizations(adev->dm.dc, false); | |
| 1583 | 1585 | ||
| 1584 | 1586 | dm->cached_dc_state = dc_state_create_copy(dm->dc->current_state); | |
| 1587 | + | if (!dm->cached_dc_state) { | |
| 1588 | + | drm_err(adev_to_drm(adev), | |
| 1589 | + | "Failed to allocate cached DC state during suspend\n"); | |
| 1590 | + | mutex_unlock(&dm->dc_lock); | |
| 1591 | + | return -ENOMEM; | |
| 1592 | + | } | |
| 1585 | 1593 | ||
| 1586 | - | if (dm->cached_dc_state) | |
| 1587 | - | dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false); | |
| 1594 | + | dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false); | |
| 1588 | 1595 | ||
| 1589 | 1596 | res = amdgpu_dm_commit_zero_streams(dm->dc); | |
| 1590 | 1597 | if (res != DC_OK) { | |
| @@ -3701,6 +3708,13 @@ static void amdgpu_dm_enable_self_refresh(struct amdgpu_display_manager *dm, | |||
| 3701 | 3708 | struct amdgpu_dm_connector *aconn = | |
| 3702 | 3709 | (struct amdgpu_dm_connector *)acrtc_state->stream->dm_stream_context; | |
| 3703 | 3710 | ||
| 3711 | + | if (!acrtc_state->base.async_flip) { | |
| 3712 | + | amdgpu_dm_psr_set_event(dm, acrtc_state->stream, false, | |
| 3713 | + | psr_event_immediate_flip, false); | |
| 3714 | + | amdgpu_dm_replay_set_event(dm, acrtc_state->stream, false, | |
| 3715 | + | replay_event_immediate_flip, false); | |
| 3716 | + | } | |
| 3717 | + | ||
| 3704 | 3718 | /* Decrement skip count when SR is enabled and we're doing fast updates. */ | |
| 3705 | 3719 | if (acrtc_state->update_type == UPDATE_TYPE_FAST && | |
| 3706 | 3720 | (psr->psr_feature_enabled || pr->replay_feature_enabled)) { | |
| @@ -4111,6 +4125,18 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state, | |||
| 4111 | 4125 | spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags); | |
| 4112 | 4126 | } | |
| 4113 | 4127 | mutex_lock(&dm->dc_lock); | |
| 4128 | + | /* | |
| 4129 | + | * Tearing (immediate) flips cannot work with panel self-refresh | |
| 4130 | + | * features. The event is cleared by | |
| 4131 | + | * amdgpu_dm_enable_self_refresh() once async flips stop. | |
| 4132 | + | */ | |
| 4133 | + | if (immediate_flip) { | |
| 4134 | + | dc_exit_ips_for_hw_access(dm->dc); | |
| 4135 | + | amdgpu_dm_psr_set_event(dm, acrtc_state->stream, true, | |
| 4136 | + | psr_event_immediate_flip, true); | |
| 4137 | + | amdgpu_dm_replay_set_event(dm, acrtc_state->stream, true, | |
| 4138 | + | replay_event_immediate_flip, true); | |
| 4139 | + | } | |
| 4114 | 4140 | update_planes_and_stream_adapter(dm->dc, | |
| 4115 | 4141 | acrtc_state->update_type, | |
| 4116 | 4142 | planes_count, | |
| @@ -5583,8 +5609,10 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm, | |||
| 5583 | 5609 | ||
| 5584 | 5610 | skip_modeset: | |
| 5585 | 5611 | /* Release extra reference */ | |
| 5586 | - | if (new_stream) | |
| 5612 | + | if (new_stream) { | |
| 5587 | 5613 | dc_stream_release(new_stream); | |
| 5614 | + | new_stream = NULL; | |
| 5615 | + | } | |
| 5588 | 5616 | new_stream = NULL; | |
| 5589 | 5617 | ||
| 5590 | 5618 | /* | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
| @@ -552,6 +552,18 @@ struct amdgpu_display_manager { | |||
| 552 | 552 | struct common_irq_params | |
| 553 | 553 | vupdate_params[DC_IRQ_SOURCE_VUPDATE6 - DC_IRQ_SOURCE_VUPDATE1 + 1]; | |
| 554 | 554 | ||
| 555 | + | /** | |
| 556 | + | * @irq_reg_lock: | |
| 557 | + | * | |
| 558 | + | * Serializes the read-modify-writes of the HW interrupt control | |
| 559 | + | * registers. Several interrupt sources share one register - e.g. the | |
| 560 | + | * enable and clear bits of both VSTARTUP (vblank) and VUPDATE_NO_LOCK | |
| 561 | + | * live in OTG_GLOBAL_SYNC_STATUS. Therefore, enabling one source must | |
| 562 | + | * not race with acking another. Held only across amdgpu_dm_irq_set() | |
| 563 | + | * and amdgpu_dm_irq_ack(). | |
| 564 | + | */ | |
| 565 | + | spinlock_t irq_reg_lock; | |
| 566 | + | ||
| 555 | 567 | /** | |
| 556 | 568 | * @dmub_trace_params: | |
| 557 | 569 | * | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
| @@ -39,6 +39,7 @@ | |||
| 39 | 39 | #include "modules/inc/mod_power.h" | |
| 40 | 40 | ||
| 41 | 41 | #include <linux/backlight.h> | |
| 42 | + | #include <linux/minmax.h> | |
| 42 | 43 | #include <linux/power_supply.h> | |
| 43 | 44 | #include <drm/drm_edid.h> | |
| 44 | 45 | #include <drm/drm_utils.h> | |
| @@ -118,6 +119,68 @@ static inline u32 scale_fw_to_input(int min, int max, u64 input) | |||
| 118 | 119 | return min + DIV_ROUND_CLOSEST_ULL(input * (max - min), AMDGPU_MAX_BL_LEVEL); | |
| 119 | 120 | } | |
| 120 | 121 | ||
| 122 | + | static u32 backlight_signal_to_luminance(const struct amdgpu_dm_backlight_caps *caps, | |
| 123 | + | u32 signal) | |
| 124 | + | { | |
| 125 | + | u32 lower_signal, upper_signal; | |
| 126 | + | u32 lower_lum, upper_lum; | |
| 127 | + | int i; | |
| 128 | + | ||
| 129 | + | if (!caps->data_points) | |
| 130 | + | return DIV_ROUND_CLOSEST(signal * 100, AMDGPU_MAX_BL_LEVEL); | |
| 131 | + | ||
| 132 | + | if (signal < caps->luminance_data[0].input_signal) { | |
| 133 | + | lower_signal = 0; | |
| 134 | + | lower_lum = 0; | |
| 135 | + | upper_signal = caps->luminance_data[0].input_signal; | |
| 136 | + | upper_lum = caps->luminance_data[0].luminance; | |
| 137 | + | } else if (signal >= | |
| 138 | + | caps->luminance_data[caps->data_points - 1].input_signal) { | |
| 139 | + | lower_signal = caps->luminance_data[caps->data_points - 1].input_signal; | |
| 140 | + | lower_lum = caps->luminance_data[caps->data_points - 1].luminance; | |
| 141 | + | upper_signal = caps->max_input_signal; | |
| 142 | + | upper_lum = 100; | |
| 143 | + | } else { | |
| 144 | + | for (i = 1; | |
| 145 | + | i < caps->data_points && | |
| 146 | + | signal > caps->luminance_data[i].input_signal; | |
| 147 | + | i++) | |
| 148 | + | ; | |
| 149 | + | ||
| 150 | + | lower_signal = caps->luminance_data[i - 1].input_signal; | |
| 151 | + | upper_signal = caps->luminance_data[i].input_signal; | |
| 152 | + | lower_lum = caps->luminance_data[i - 1].luminance; | |
| 153 | + | upper_lum = caps->luminance_data[i].luminance; | |
| 154 | + | } | |
| 155 | + | ||
| 156 | + | if (upper_signal == lower_signal) | |
| 157 | + | return upper_lum; | |
| 158 | + | ||
| 159 | + | return lower_lum + DIV_ROUND_CLOSEST((upper_lum - lower_lum) * | |
| 160 | + | (signal - lower_signal), | |
| 161 | + | upper_signal - lower_signal); | |
| 162 | + | } | |
| 163 | + | ||
| 164 | + | static u32 convert_brightness_to_millipercent(const struct amdgpu_dm_backlight_caps *caps, | |
| 165 | + | u32 user_brightness) | |
| 166 | + | { | |
| 167 | + | unsigned int min, max; | |
| 168 | + | u32 signal, luminance; | |
| 169 | + | ||
| 170 | + | if (!get_brightness_range(caps, &min, &max)) | |
| 171 | + | return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000, | |
| 172 | + | MAX_BACKLIGHT_LEVEL); | |
| 173 | + | ||
| 174 | + | user_brightness = clamp(user_brightness, min, max); | |
| 175 | + | if (amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE) | |
| 176 | + | return DIV_ROUND_CLOSEST_ULL((u64)user_brightness * 100000, max); | |
| 177 | + | ||
| 178 | + | signal = scale_input_to_fw(max, user_brightness); | |
| 179 | + | luminance = backlight_signal_to_luminance(caps, signal); | |
| 180 | + | ||
| 181 | + | return min_t(u32, luminance * 1000, 100000); | |
| 182 | + | } | |
| 183 | + | ||
| 121 | 184 | STATIC_IFN_KUNIT | |
| 122 | 185 | void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps, | |
| 123 | 186 | unsigned int min, unsigned int max, | |
| @@ -260,10 +323,10 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 260 | 323 | struct amdgpu_dm_backlight_caps *caps; | |
| 261 | 324 | struct dc_link *link; | |
| 262 | 325 | u32 brightness = 0; | |
| 326 | + | u32 millipercent = 0; | |
| 263 | 327 | bool rc = false, reallow_idle = false; | |
| 264 | 328 | struct drm_connector *connector; | |
| 265 | 329 | struct dc_stream_state *stream; | |
| 266 | - | unsigned int min, max; | |
| 267 | 330 | ||
| 268 | 331 | list_for_each_entry(connector, &dm->ddev->mode_config.connector_list, head) { | |
| 269 | 332 | struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); | |
| @@ -286,12 +349,21 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 286 | 349 | /* update scratch register */ | |
| 287 | 350 | if (bl_idx == 0) | |
| 288 | 351 | amdgpu_atombios_scratch_regs_set_backlight_level(dm->adev, dm->brightness[bl_idx]); | |
| 289 | - | brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]); | |
| 352 | + | ||
| 290 | 353 | link = (struct dc_link *)dm->backlight_link[bl_idx]; | |
| 354 | + | stream = dm_find_stream_with_link(dm, link); | |
| 355 | + | if (!stream) | |
| 356 | + | return; | |
| 291 | 357 | ||
| 292 | - | /* Apply brightness quirk */ | |
| 293 | - | if (caps->brightness_mask) | |
| 294 | - | brightness |= caps->brightness_mask; | |
| 358 | + | if (caps->aux_support) { | |
| 359 | + | brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]); | |
| 360 | + | /* Apply brightness quirk */ | |
| 361 | + | if (caps->brightness_mask) | |
| 362 | + | brightness |= caps->brightness_mask; | |
| 363 | + | } else { | |
| 364 | + | millipercent = convert_brightness_to_millipercent(caps, | |
| 365 | + | user_brightness); | |
| 366 | + | } | |
| 295 | 367 | ||
| 296 | 368 | if (trace_amdgpu_dm_brightness_enabled()) { | |
| 297 | 369 | trace_amdgpu_dm_brightness(__builtin_return_address(0), | |
| @@ -301,10 +373,6 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 301 | 373 | power_supply_is_system_supplied() > 0); | |
| 302 | 374 | } | |
| 303 | 375 | ||
| 304 | - | stream = dm_find_stream_with_link(dm, link); | |
| 305 | - | if (!stream) | |
| 306 | - | return; | |
| 307 | - | ||
| 308 | 376 | mutex_lock(&dm->dc_lock); | |
| 309 | 377 | if (dm->dc->caps.ips_support && dm->dc->ctx->dmub_srv->idle_allowed) { | |
| 310 | 378 | dc_allow_idle_optimizations(dm->dc, false); | |
| @@ -316,10 +384,8 @@ void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, | |||
| 316 | 384 | AUX_BL_DEFAULT_TRANSITION_TIME_MS, false, true); | |
| 317 | 385 | } else { | |
| 318 | 386 | /* power module uses millipercent */ | |
| 319 | - | get_brightness_range(caps, &min, &max); | |
| 320 | - | brightness = DIV_ROUND_CLOSEST(brightness * 100, (max - min)) * 1000; | |
| 321 | 387 | rc = mod_power_set_backlight_percent(dm->power_module, stream, | |
| 322 | - | brightness, 0, false); | |
| 388 | + | millipercent, 0, false); | |
| 323 | 389 | } | |
| 324 | 390 | ||
| 325 | 391 | /* | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
| @@ -732,6 +732,24 @@ get_aspect_ratio(const struct drm_display_mode *mode_in) | |||
| 732 | 732 | } | |
| 733 | 733 | EXPORT_IF_KUNIT(get_aspect_ratio); | |
| 734 | 734 | ||
| 735 | + | /* | |
| 736 | + | * CTA-861 5.1: RGB video formats default to limited range except 640x480 (VIC 1). | |
| 737 | + | * With Broadcast RGB left at Automatic follow that default, as i915 does. | |
| 738 | + | */ | |
| 739 | + | static bool rgb_output_is_limited_range(const struct dc_crtc_timing *dc_crtc_timing, | |
| 740 | + | const struct drm_connector_state *connector_state) | |
| 741 | + | { | |
| 742 | + | switch (connector_state->hdmi.broadcast_rgb) { | |
| 743 | + | case DRM_HDMI_BROADCAST_RGB_FULL: | |
| 744 | + | return false; | |
| 745 | + | case DRM_HDMI_BROADCAST_RGB_LIMITED: | |
| 746 | + | return true; | |
| 747 | + | default: | |
| 748 | + | return connector_state->connector->display_info.is_hdmi && | |
| 749 | + | dc_crtc_timing->vic > 1; | |
| 750 | + | } | |
| 751 | + | } | |
| 752 | + | ||
| 735 | 753 | enum dc_color_space | |
| 736 | 754 | amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |
| 737 | 755 | const struct drm_connector_state *connector_state) | |
| @@ -757,7 +775,7 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |||
| 757 | 775 | case DRM_MODE_COLORIMETRY_BT2020_RGB: | |
| 758 | 776 | case DRM_MODE_COLORIMETRY_BT2020_YCC: | |
| 759 | 777 | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) { | |
| 760 | - | if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) | |
| 778 | + | if (rgb_output_is_limited_range(dc_crtc_timing, connector_state)) | |
| 761 | 779 | color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE; | |
| 762 | 780 | else | |
| 763 | 781 | color_space = COLOR_SPACE_2020_RGB_FULLRANGE; | |
| @@ -769,7 +787,7 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing, | |||
| 769 | 787 | default: | |
| 770 | 788 | if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) { | |
| 771 | 789 | color_space = COLOR_SPACE_SRGB; | |
| 772 | - | if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED) | |
| 790 | + | if (rgb_output_is_limited_range(dc_crtc_timing, connector_state)) | |
| 773 | 791 | color_space = COLOR_SPACE_SRGB_LIMITED; | |
| 774 | 792 | /* | |
| 775 | 793 | * 27030khz is the separation point between HDTV and SDTV | |
| @@ -994,10 +1012,15 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode, | |||
| 994 | 1012 | const struct drm_display_mode *native_mode, | |
| 995 | 1013 | bool scale_enabled) | |
| 996 | 1014 | { | |
| 1015 | + | /* Inserted modes copy the native sync; a sink mode with equal totals may not */ | |
| 997 | 1016 | if (scale_enabled || ( | |
| 998 | 1017 | native_mode->clock == drm_mode->clock && | |
| 999 | 1018 | native_mode->htotal == drm_mode->htotal && | |
| 1000 | - | native_mode->vtotal == drm_mode->vtotal)) { | |
| 1019 | + | native_mode->vtotal == drm_mode->vtotal && | |
| 1020 | + | native_mode->hsync_start == drm_mode->hsync_start && | |
| 1021 | + | native_mode->hsync_end == drm_mode->hsync_end && | |
| 1022 | + | native_mode->vsync_start == drm_mode->vsync_start && | |
| 1023 | + | native_mode->vsync_end == drm_mode->vsync_end)) { | |
| 1001 | 1024 | if (native_mode->crtc_clock) | |
| 1002 | 1025 | copy_crtc_timing_for_drm_display_mode(native_mode, drm_mode); | |
| 1003 | 1026 | } else { | |
| @@ -2256,8 +2279,8 @@ amdgpu_dm_create_validate_stream_for_sink(struct drm_connector *connector, | |||
| 2256 | 2279 | * below gate which of these entries are actually attempted. | |
| 2257 | 2280 | */ | |
| 2258 | 2281 | static const enum dc_pixel_encoding encoding_order[] = { | |
| 2259 | - | PIXEL_ENCODING_YCBCR444, | |
| 2260 | 2282 | PIXEL_ENCODING_RGB, | |
| 2283 | + | PIXEL_ENCODING_YCBCR444, | |
| 2261 | 2284 | PIXEL_ENCODING_YCBCR422, | |
| 2262 | 2285 | PIXEL_ENCODING_YCBCR420, | |
| 2263 | 2286 | }; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crtc.c
| @@ -31,6 +31,7 @@ | |||
| 31 | 31 | #include "amdgpu_dm_psr.h" | |
| 32 | 32 | #include "amdgpu_dm_replay.h" | |
| 33 | 33 | #include "amdgpu_dm_crtc.h" | |
| 34 | + | #include "amdgpu_dm_irq.h" | |
| 34 | 35 | #include "amdgpu_dm_plane.h" | |
| 35 | 36 | #include "amdgpu_dm_trace.h" | |
| 36 | 37 | #include "amdgpu_dm_debugfs.h" | |
| @@ -91,7 +92,7 @@ int amdgpu_dm_crtc_set_vupdate_irq(struct drm_crtc *crtc, bool enable) | |||
| 91 | 92 | ||
| 92 | 93 | irq_source = IRQ_TYPE_VUPDATE + acrtc->otg_inst; | |
| 93 | 94 | ||
| 94 | - | rc = dc_interrupt_set(adev->dm.dc, irq_source, enable) ? 0 : -EBUSY; | |
| 95 | + | rc = amdgpu_dm_irq_set(adev, irq_source, enable) ? 0 : -EBUSY; | |
| 95 | 96 | ||
| 96 | 97 | DRM_DEBUG_VBL("crtc %d - vupdate irq %sabling: r=%d\n", | |
| 97 | 98 | acrtc->crtc_id, enable ? "en" : "dis", rc); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
| @@ -1439,12 +1439,13 @@ void dm_helpers_free_gpu_mem( | |||
| 1439 | 1439 | ||
| 1440 | 1440 | bool dm_helpers_dmub_outbox_interrupt_control(struct dc_context *ctx, bool enable) | |
| 1441 | 1441 | { | |
| 1442 | + | struct amdgpu_device *adev = ctx->driver_context; | |
| 1442 | 1443 | enum dc_irq_source irq_source; | |
| 1443 | 1444 | bool ret; | |
| 1444 | 1445 | ||
| 1445 | 1446 | irq_source = DC_IRQ_SOURCE_DMCUB_OUTBOX; | |
| 1446 | 1447 | ||
| 1447 | - | ret = dc_interrupt_set(ctx->dc, irq_source, enable); | |
| 1448 | + | ret = amdgpu_dm_irq_set(adev, irq_source, enable); | |
| 1448 | 1449 | ||
| 1449 | 1450 | DRM_DEBUG_DRIVER("Dmub trace irq %sabling: r=%d\n", | |
| 1450 | 1451 | enable ? "en" : "dis", ret); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
| @@ -396,6 +396,7 @@ int amdgpu_dm_irq_init(struct amdgpu_device *adev) | |||
| 396 | 396 | DRM_DEBUG_KMS("DM_IRQ\n"); | |
| 397 | 397 | ||
| 398 | 398 | spin_lock_init(&adev->dm.irq_handler_list_table_lock); | |
| 399 | + | spin_lock_init(&adev->dm.irq_reg_lock); | |
| 399 | 400 | ||
| 400 | 401 | adev->dm.irq_wq = alloc_workqueue("amdgpu_dm_irq", | |
| 401 | 402 | WQ_UNBOUND | WQ_HIGHPRI, 0); | |
| @@ -530,7 +531,7 @@ void amdgpu_dm_irq_suspend(struct amdgpu_device *adev) | |||
| 530 | 531 | */ | |
| 531 | 532 | for (src = DC_IRQ_SOURCE_HPD1; src <= DC_IRQ_SOURCE_HPD6RX; src++) { | |
| 532 | 533 | hnd_list_l = &adev->dm.irq_handler_list_low_tab[src]; | |
| 533 | - | dc_interrupt_set(adev->dm.dc, src, false); | |
| 534 | + | amdgpu_dm_irq_set(adev, src, false); | |
| 534 | 535 | ||
| 535 | 536 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); | |
| 536 | 537 | ||
| @@ -568,7 +569,7 @@ void amdgpu_dm_irq_resume_early(struct amdgpu_device *adev) | |||
| 568 | 569 | hnd_list_l = &adev->dm.irq_handler_list_low_tab[src]; | |
| 569 | 570 | hnd_list_h = &adev->dm.irq_handler_list_high_tab[src]; | |
| 570 | 571 | if (!list_empty(hnd_list_l) || !list_empty(hnd_list_h)) | |
| 571 | - | dc_interrupt_set(adev->dm.dc, src, true); | |
| 572 | + | amdgpu_dm_irq_set(adev, src, true); | |
| 572 | 573 | } | |
| 573 | 574 | ||
| 574 | 575 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); | |
| @@ -594,7 +595,7 @@ void amdgpu_dm_irq_resume_late(struct amdgpu_device *adev) | |||
| 594 | 595 | hnd_list_l = &adev->dm.irq_handler_list_low_tab[src]; | |
| 595 | 596 | hnd_list_h = &adev->dm.irq_handler_list_high_tab[src]; | |
| 596 | 597 | if (!list_empty(hnd_list_l) || !list_empty(hnd_list_h)) | |
| 597 | - | dc_interrupt_set(adev->dm.dc, src, true); | |
| 598 | + | amdgpu_dm_irq_set(adev, src, true); | |
| 598 | 599 | } | |
| 599 | 600 | ||
| 600 | 601 | DM_IRQ_TABLE_UNLOCK(adev, irq_table_flags); | |
| @@ -690,6 +691,23 @@ STATIC_IFN_KUNIT void amdgpu_dm_irq_immediate_work(struct amdgpu_device *adev, | |||
| 690 | 691 | } | |
| 691 | 692 | EXPORT_IF_KUNIT(amdgpu_dm_irq_immediate_work); | |
| 692 | 693 | ||
| 694 | + | bool amdgpu_dm_irq_set(struct amdgpu_device *adev, enum dc_irq_source src, | |
| 695 | + | bool enable) | |
| 696 | + | { | |
| 697 | + | guard(spinlock_irqsave)(&adev->dm.irq_reg_lock); | |
| 698 | + | ||
| 699 | + | return dc_interrupt_set(adev->dm.dc, src, enable); | |
| 700 | + | } | |
| 701 | + | EXPORT_IF_KUNIT(amdgpu_dm_irq_set); | |
| 702 | + | ||
| 703 | + | void amdgpu_dm_irq_ack(struct amdgpu_device *adev, enum dc_irq_source src) | |
| 704 | + | { | |
| 705 | + | guard(spinlock_irqsave)(&adev->dm.irq_reg_lock); | |
| 706 | + | ||
| 707 | + | dc_interrupt_ack(adev->dm.dc, src); | |
| 708 | + | } | |
| 709 | + | EXPORT_IF_KUNIT(amdgpu_dm_irq_ack); | |
| 710 | + | ||
| 693 | 711 | /** | |
| 694 | 712 | * amdgpu_dm_irq_handler - Generic DM IRQ handler | |
| 695 | 713 | * @adev: amdgpu base driver device containing the DM device | |
| @@ -710,7 +728,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_irq_handler(struct amdgpu_device *adev, | |||
| 710 | 728 | entry->src_id, | |
| 711 | 729 | entry->src_data[0]); | |
| 712 | 730 | ||
| 713 | - | dc_interrupt_ack(adev->dm.dc, src); | |
| 731 | + | amdgpu_dm_irq_ack(adev, src); | |
| 714 | 732 | ||
| 715 | 733 | /* Call high irq work immediately */ | |
| 716 | 734 | amdgpu_dm_irq_immediate_work(adev, src); | |
| @@ -750,7 +768,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_set_hpd_irq_state(struct amdgpu_device *adev, | |||
| 750 | 768 | enum dc_irq_source src = amdgpu_dm_hpd_to_dal_irq_source(type); | |
| 751 | 769 | bool st = (state == AMDGPU_IRQ_STATE_ENABLE); | |
| 752 | 770 | ||
| 753 | - | dc_interrupt_set(adev->dm.dc, src, st); | |
| 771 | + | amdgpu_dm_irq_set(adev, src, st); | |
| 754 | 772 | return 0; | |
| 755 | 773 | } | |
| 756 | 774 | EXPORT_IF_KUNIT(amdgpu_dm_set_hpd_irq_state); | |
| @@ -785,7 +803,7 @@ static inline int dm_irq_state(struct amdgpu_device *adev, | |||
| 785 | 803 | if (dc && dc->caps.ips_support && dc->idle_optimizations_allowed) | |
| 786 | 804 | dc_allow_idle_optimizations(dc, false); | |
| 787 | 805 | ||
| 788 | - | dc_interrupt_set(adev->dm.dc, irq_source, st); | |
| 806 | + | amdgpu_dm_irq_set(adev, irq_source, st); | |
| 789 | 807 | return 0; | |
| 790 | 808 | } | |
| 791 | 809 | ||
| @@ -842,7 +860,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_set_dmub_outbox_irq_state(struct amdgpu_device *a | |||
| 842 | 860 | enum dc_irq_source irq_source = DC_IRQ_SOURCE_DMCUB_OUTBOX; | |
| 843 | 861 | bool st = (state == AMDGPU_IRQ_STATE_ENABLE); | |
| 844 | 862 | ||
| 845 | - | dc_interrupt_set(adev->dm.dc, irq_source, st); | |
| 863 | + | amdgpu_dm_irq_set(adev, irq_source, st); | |
| 846 | 864 | return 0; | |
| 847 | 865 | } | |
| 848 | 866 | EXPORT_IF_KUNIT(amdgpu_dm_set_dmub_outbox_irq_state); | |
| @@ -870,7 +888,7 @@ STATIC_IFN_KUNIT int amdgpu_dm_set_dmub_trace_irq_state(struct amdgpu_device *ad | |||
| 870 | 888 | enum dc_irq_source irq_source = DC_IRQ_SOURCE_DMCUB_OUTBOX0; | |
| 871 | 889 | bool st = (state == AMDGPU_IRQ_STATE_ENABLE); | |
| 872 | 890 | ||
| 873 | - | dc_interrupt_set(adev->dm.dc, irq_source, st); | |
| 891 | + | amdgpu_dm_irq_set(adev, irq_source, st); | |
| 874 | 892 | return 0; | |
| 875 | 893 | } | |
| 876 | 894 | EXPORT_IF_KUNIT(amdgpu_dm_set_dmub_trace_irq_state); | |
| @@ -937,9 +955,7 @@ EXPORT_IF_KUNIT(amdgpu_dm_set_irq_funcs); | |||
| 937 | 955 | ||
| 938 | 956 | void amdgpu_dm_outbox_init(struct amdgpu_device *adev) | |
| 939 | 957 | { | |
| 940 | - | dc_interrupt_set(adev->dm.dc, | |
| 941 | - | DC_IRQ_SOURCE_DMCUB_OUTBOX, | |
| 942 | - | true); | |
| 958 | + | amdgpu_dm_irq_set(adev, DC_IRQ_SOURCE_DMCUB_OUTBOX, true); | |
| 943 | 959 | } | |
| 944 | 960 | EXPORT_IF_KUNIT(amdgpu_dm_outbox_init); | |
| 945 | 961 | ||
| @@ -962,7 +978,7 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) | |||
| 962 | 978 | ||
| 963 | 979 | /* First, clear all hpd and hpdrx interrupts */ | |
| 964 | 980 | for (i = DC_IRQ_SOURCE_HPD1; i <= DC_IRQ_SOURCE_HPD6RX; i++) { | |
| 965 | - | if (!dc_interrupt_set(adev->dm.dc, i, false)) | |
| 981 | + | if (!amdgpu_dm_irq_set(adev, i, false)) | |
| 966 | 982 | drm_err(dev, "Failed to clear hpd(rx) source=%d on init\n", | |
| 967 | 983 | i); | |
| 968 | 984 | } | |
| @@ -991,7 +1007,7 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) | |||
| 991 | 1007 | * of dm. Note that only hpd interrupt types are registered with | |
| 992 | 1008 | * base driver; hpd_rx types aren't. IOW, amdgpu_irq_get/put on | |
| 993 | 1009 | * hpd_rx isn't available. DM currently controls hpd_rx | |
| 994 | - | * explicitly with dc_interrupt_set() | |
| 1010 | + | * explicitly with amdgpu_dm_irq_set() | |
| 995 | 1011 | */ | |
| 996 | 1012 | if (dc_link->irq_source_hpd != DC_IRQ_SOURCE_INVALID) { | |
| 997 | 1013 | irq_type = dc_link->irq_source_hpd - DC_IRQ_SOURCE_HPD1; | |
| @@ -1000,23 +1016,21 @@ void amdgpu_dm_hpd_init(struct amdgpu_device *adev) | |||
| 1000 | 1016 | * and what bios reports as the # of connectors with hpd | |
| 1001 | 1017 | * sources. Since the # of hpd source types registered | |
| 1002 | 1018 | * with base driver == mode_info.num_hpd, we have to | |
| 1003 | - | * fallback to dc_interrupt_set for the remaining types. | |
| 1019 | + | * fallback to amdgpu_dm_irq_set for the remaining types. | |
| 1004 | 1020 | */ | |
| 1005 | 1021 | if (irq_type < adev->mode_info.num_hpd) { | |
| 1006 | 1022 | if (amdgpu_irq_get(adev, &adev->hpd_irq, irq_type)) | |
| 1007 | 1023 | drm_err(dev, "DM_IRQ: Failed get HPD for source=%d)!\n", | |
| 1008 | 1024 | dc_link->irq_source_hpd); | |
| 1009 | 1025 | } else { | |
| 1010 | - | dc_interrupt_set(adev->dm.dc, | |
| 1011 | - | dc_link->irq_source_hpd, | |
| 1012 | - | true); | |
| 1026 | + | amdgpu_dm_irq_set(adev, dc_link->irq_source_hpd, | |
| 1027 | + | true); | |
| 1013 | 1028 | } | |
| 1014 | 1029 | } | |
| 1015 | 1030 | ||
| 1016 | 1031 | if (dc_link->irq_source_hpd_rx != DC_IRQ_SOURCE_INVALID) { | |
| 1017 | - | dc_interrupt_set(adev->dm.dc, | |
| 1018 | - | dc_link->irq_source_hpd_rx, | |
| 1019 | - | true); | |
| 1032 | + | amdgpu_dm_irq_set(adev, dc_link->irq_source_hpd_rx, | |
| 1033 | + | true); | |
| 1020 | 1034 | } | |
| 1021 | 1035 | } | |
| 1022 | 1036 | drm_connector_list_iter_end(&iter); | |
| @@ -1061,16 +1075,14 @@ void amdgpu_dm_hpd_fini(struct amdgpu_device *adev) | |||
| 1061 | 1075 | drm_err(dev, "DM_IRQ: Failed put HPD for source=%d!\n", | |
| 1062 | 1076 | dc_link->irq_source_hpd); | |
| 1063 | 1077 | } else { | |
| 1064 | - | dc_interrupt_set(adev->dm.dc, | |
| 1065 | - | dc_link->irq_source_hpd, | |
| 1066 | - | false); | |
| 1078 | + | amdgpu_dm_irq_set(adev, dc_link->irq_source_hpd, | |
| 1079 | + | false); | |
| 1067 | 1080 | } | |
| 1068 | 1081 | } | |
| 1069 | 1082 | ||
| 1070 | 1083 | if (dc_link->irq_source_hpd_rx != DC_IRQ_SOURCE_INVALID) { | |
| 1071 | - | dc_interrupt_set(adev->dm.dc, | |
| 1072 | - | dc_link->irq_source_hpd_rx, | |
| 1073 | - | false); | |
| 1084 | + | amdgpu_dm_irq_set(adev, dc_link->irq_source_hpd_rx, | |
| 1085 | + | false); | |
| 1074 | 1086 | } | |
| 1075 | 1087 | } | |
| 1076 | 1088 | drm_connector_list_iter_end(&iter); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.h
| @@ -89,6 +89,34 @@ void amdgpu_dm_irq_unregister_interrupt(struct amdgpu_device *adev, | |||
| 89 | 89 | enum dc_irq_source irq_source, | |
| 90 | 90 | void *ih_index); | |
| 91 | 91 | ||
| 92 | + | /** | |
| 93 | + | * amdgpu_dm_irq_set - enable or disable a DC interrupt source. | |
| 94 | + | * | |
| 95 | + | * @adev: AMD DRM device | |
| 96 | + | * @src: DC interrupt source to toggle | |
| 97 | + | * @enable: true to enable the source, false to disable it | |
| 98 | + | * | |
| 99 | + | * DM-wide replacement for dc_interrupt_set(). As locking is DM's | |
| 100 | + | * responsibility, this is a thin wrapper serializes the underlying | |
| 101 | + | * read-modify-write against the other interrupt sources sharing HW control | |
| 102 | + | * registers with @src, so DM must never call dc_interrupt_set() directly. | |
| 103 | + | * | |
| 104 | + | * Returns: true if the source was toggled. | |
| 105 | + | */ | |
| 106 | + | bool amdgpu_dm_irq_set(struct amdgpu_device *adev, enum dc_irq_source src, | |
| 107 | + | bool enable); | |
| 108 | + | ||
| 109 | + | /** | |
| 110 | + | * amdgpu_dm_irq_ack - acknowledge a DC interrupt source. | |
| 111 | + | * | |
| 112 | + | * @adev: AMD DRM device | |
| 113 | + | * @src: DC interrupt source to acknowledge | |
| 114 | + | * | |
| 115 | + | * DM-wide replacement for dc_interrupt_ack(), serialized the same way as | |
| 116 | + | * amdgpu_dm_irq_set(). | |
| 117 | + | */ | |
| 118 | + | void amdgpu_dm_irq_ack(struct amdgpu_device *adev, enum dc_irq_source src); | |
| 119 | + | ||
| 92 | 120 | void amdgpu_dm_set_irq_funcs(struct amdgpu_device *adev); | |
| 93 | 121 | ||
| 94 | 122 | void amdgpu_dm_outbox_init(struct amdgpu_device *adev); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
| @@ -1231,7 +1231,8 @@ static bool get_conv_frl_bw(struct amdgpu_dm_connector *aconnector, | |||
| 1231 | 1231 | unsigned int max_sink_bw_in_kbps = 0; | |
| 1232 | 1232 | unsigned int dsc_max_sink_bw_in_kbps = 0; | |
| 1233 | 1233 | ||
| 1234 | - | if (aconnector->dc_link->dc->caps.dp_hdmi21_pcon_support && | |
| 1234 | + | if (aconnector->dc_sink && | |
| 1235 | + | aconnector->dc_link->dc->caps.dp_hdmi21_pcon_support && | |
| 1235 | 1236 | aconnector->mst_downstream_port_caps.bytes.byte0.bits.DWN_STRM_PORTX_TYPE == DOWN_STREAM_DETAILED_HDMI) { | |
| 1236 | 1237 | max_conv_bw_in_kbps = dc_link_bw_kbps_from_raw_frl_link_rate_data( | |
| 1237 | 1238 | aconnector->dc_link->dc, | |
| @@ -1996,6 +1997,9 @@ enum dc_status dm_dp_mst_is_port_support_mode( | |||
| 1996 | 1997 | struct dc_dsc_config_options dsc_options = {0}; | |
| 1997 | 1998 | uint32_t stream_kbps; | |
| 1998 | 1999 | ||
| 2000 | + | if (!aconnector->dc_sink) | |
| 2001 | + | return DC_FAIL_BANDWIDTH_VALIDATE; | |
| 2002 | + | ||
| 1999 | 2003 | /* DSC unnecessary case | |
| 2000 | 2004 | * Check if timing could be supported within end-to-end BW | |
| 2001 | 2005 | */ | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
| @@ -112,25 +112,7 @@ void amdgpu_dm_plane_fill_blending_from_plane_state(const struct drm_plane_state | |||
| 112 | 112 | ||
| 113 | 113 | if (plane_state->pixel_blend_mode == DRM_MODE_BLEND_PREMULTI || | |
| 114 | 114 | plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) { | |
| 115 | - | static const uint32_t alpha_formats[] = { | |
| 116 | - | DRM_FORMAT_ARGB8888, | |
| 117 | - | DRM_FORMAT_RGBA8888, | |
| 118 | - | DRM_FORMAT_ABGR8888, | |
| 119 | - | DRM_FORMAT_ARGB2101010, | |
| 120 | - | DRM_FORMAT_ABGR2101010, | |
| 121 | - | DRM_FORMAT_ARGB16161616, | |
| 122 | - | DRM_FORMAT_ABGR16161616, | |
| 123 | - | DRM_FORMAT_ARGB16161616F, | |
| 124 | - | }; | |
| 125 | - | uint32_t format = plane_state->fb->format->format; | |
| 126 | - | unsigned int i; | |
| 127 | - | ||
| 128 | - | for (i = 0; i < ARRAY_SIZE(alpha_formats); ++i) { | |
| 129 | - | if (format == alpha_formats[i]) { | |
| 130 | - | *per_pixel_alpha = true; | |
| 131 | - | break; | |
| 132 | - | } | |
| 133 | - | } | |
| 115 | + | *per_pixel_alpha = plane_state->fb->format->has_alpha; | |
| 134 | 116 | ||
| 135 | 117 | if (*per_pixel_alpha && plane_state->pixel_blend_mode == DRM_MODE_BLEND_COVERAGE) | |
| 136 | 118 | *pre_multiplied_alpha = false; | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
| @@ -409,7 +409,9 @@ static void dm_test_output_color_space_default_rgb_full(struct kunit *test) | |||
| 409 | 409 | { | |
| 410 | 410 | struct dc_crtc_timing timing = {}; | |
| 411 | 411 | struct drm_connector_state state = {}; | |
| 412 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 412 | 413 | ||
| 414 | + | state.connector = connector; | |
| 413 | 415 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 414 | 416 | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 415 | 417 | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| @@ -559,7 +561,9 @@ static void dm_test_output_color_space_bt2020_rgb(struct kunit *test) | |||
| 559 | 561 | { | |
| 560 | 562 | struct dc_crtc_timing timing = {}; | |
| 561 | 563 | struct drm_connector_state state = {}; | |
| 564 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 562 | 565 | ||
| 566 | + | state.connector = connector; | |
| 563 | 567 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 564 | 568 | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB; | |
| 565 | 569 | ||
| @@ -584,6 +588,110 @@ static void dm_test_output_color_space_bt2020_rgb_limited(struct kunit *test) | |||
| 584 | 588 | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 585 | 589 | } | |
| 586 | 590 | ||
| 591 | + | /** | |
| 592 | + | * dm_test_output_color_space_default_rgb_auto_hdmi_cta - Automatic follows the CTA-861 default | |
| 593 | + | * @test: The KUnit test context | |
| 594 | + | */ | |
| 595 | + | static void dm_test_output_color_space_default_rgb_auto_hdmi_cta(struct kunit *test) | |
| 596 | + | { | |
| 597 | + | struct dc_crtc_timing timing = {}; | |
| 598 | + | struct drm_connector_state state = {}; | |
| 599 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 600 | + | ||
| 601 | + | connector->display_info.is_hdmi = true; | |
| 602 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 603 | + | timing.vic = 32; | |
| 604 | + | state.connector = connector; | |
| 605 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 606 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 607 | + | ||
| 608 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 609 | + | (int)COLOR_SPACE_SRGB_LIMITED); | |
| 610 | + | } | |
| 611 | + | ||
| 612 | + | /** | |
| 613 | + | * dm_test_output_color_space_default_rgb_auto_hdmi_vga - 640x480 (VIC 1) stays full range | |
| 614 | + | * @test: The KUnit test context | |
| 615 | + | */ | |
| 616 | + | static void dm_test_output_color_space_default_rgb_auto_hdmi_vga(struct kunit *test) | |
| 617 | + | { | |
| 618 | + | struct dc_crtc_timing timing = {}; | |
| 619 | + | struct drm_connector_state state = {}; | |
| 620 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 621 | + | ||
| 622 | + | connector->display_info.is_hdmi = true; | |
| 623 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 624 | + | timing.vic = 1; | |
| 625 | + | state.connector = connector; | |
| 626 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 627 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 628 | + | ||
| 629 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 630 | + | (int)COLOR_SPACE_SRGB); | |
| 631 | + | } | |
| 632 | + | ||
| 633 | + | /** | |
| 634 | + | * dm_test_output_color_space_default_rgb_auto_dp_cta - Automatic on a non-HDMI sink is full range | |
| 635 | + | * @test: The KUnit test context | |
| 636 | + | */ | |
| 637 | + | static void dm_test_output_color_space_default_rgb_auto_dp_cta(struct kunit *test) | |
| 638 | + | { | |
| 639 | + | struct dc_crtc_timing timing = {}; | |
| 640 | + | struct drm_connector_state state = {}; | |
| 641 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 642 | + | ||
| 643 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 644 | + | timing.vic = 32; | |
| 645 | + | state.connector = connector; | |
| 646 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 647 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 648 | + | ||
| 649 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 650 | + | (int)COLOR_SPACE_SRGB); | |
| 651 | + | } | |
| 652 | + | ||
| 653 | + | /** | |
| 654 | + | * dm_test_output_color_space_default_rgb_full_hdmi_cta - Full overrides the CTA-861 default | |
| 655 | + | * @test: The KUnit test context | |
| 656 | + | */ | |
| 657 | + | static void dm_test_output_color_space_default_rgb_full_hdmi_cta(struct kunit *test) | |
| 658 | + | { | |
| 659 | + | struct dc_crtc_timing timing = {}; | |
| 660 | + | struct drm_connector_state state = {}; | |
| 661 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 662 | + | ||
| 663 | + | connector->display_info.is_hdmi = true; | |
| 664 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 665 | + | timing.vic = 32; | |
| 666 | + | state.connector = connector; | |
| 667 | + | state.colorspace = DRM_MODE_COLORIMETRY_DEFAULT; | |
| 668 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_FULL; | |
| 669 | + | ||
| 670 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 671 | + | (int)COLOR_SPACE_SRGB); | |
| 672 | + | } | |
| 673 | + | ||
| 674 | + | /** | |
| 675 | + | * dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta - BT.2020 RGB follows the same default | |
| 676 | + | * @test: The KUnit test context | |
| 677 | + | */ | |
| 678 | + | static void dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta(struct kunit *test) | |
| 679 | + | { | |
| 680 | + | struct dc_crtc_timing timing = {}; | |
| 681 | + | struct drm_connector_state state = {}; | |
| 682 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 683 | + | ||
| 684 | + | connector->display_info.is_hdmi = true; | |
| 685 | + | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 686 | + | timing.vic = 32; | |
| 687 | + | state.connector = connector; | |
| 688 | + | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB; | |
| 689 | + | state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_AUTO; | |
| 690 | + | ||
| 691 | + | KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state), | |
| 692 | + | (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE); | |
| 693 | + | } | |
| 694 | + | ||
| 587 | 695 | /** | |
| 588 | 696 | * dm_test_output_color_space_bt2020_ycc - Test Output color space bt2020 ycc | |
| 589 | 697 | * @test: The KUnit test context | |
| @@ -647,7 +755,9 @@ static void dm_test_output_color_space_bt2020_ycc_rgb_encoding(struct kunit *tes | |||
| 647 | 755 | { | |
| 648 | 756 | struct dc_crtc_timing timing = {}; | |
| 649 | 757 | struct drm_connector_state state = {}; | |
| 758 | + | struct drm_connector *connector = kunit_kzalloc(test, sizeof(*connector), GFP_KERNEL); | |
| 650 | 759 | ||
| 760 | + | state.connector = connector; | |
| 651 | 761 | timing.pixel_encoding = PIXEL_ENCODING_RGB; | |
| 652 | 762 | state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC; | |
| 653 | 763 | ||
| @@ -1462,6 +1572,46 @@ static void dm_test_decide_crtc_timing_no_crtc_clock(struct kunit *test) | |||
| 1462 | 1572 | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 0); | |
| 1463 | 1573 | } | |
| 1464 | 1574 | ||
| 1575 | + | static void dm_test_decide_crtc_timing_sink_mode_same_totals(struct kunit *test) | |
| 1576 | + | { | |
| 1577 | + | struct drm_display_mode native_mode = { | |
| 1578 | + | DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, 4104, | |
| 1579 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1580 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1581 | + | struct drm_display_mode drm_mode = { | |
| 1582 | + | DRM_MODE("4096x2160", DRM_MODE_TYPE_DRIVER, 594000, 4096, 4184, 4272, | |
| 1583 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1584 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1585 | + | ||
| 1586 | + | drm_mode_set_crtcinfo(&native_mode, 0); | |
| 1587 | + | drm_mode_set_crtcinfo(&drm_mode, 0); | |
| 1588 | + | ||
| 1589 | + | decide_crtc_timing_for_drm_display_mode(&drm_mode, &native_mode, false); | |
| 1590 | + | ||
| 1591 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 4096); | |
| 1592 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hsync_start, 4184); | |
| 1593 | + | } | |
| 1594 | + | ||
| 1595 | + | static void dm_test_decide_crtc_timing_inserted_mode(struct kunit *test) | |
| 1596 | + | { | |
| 1597 | + | struct drm_display_mode native_mode = { | |
| 1598 | + | DRM_MODE("3840x2160", DRM_MODE_TYPE_DRIVER, 594000, 3840, 4016, 4104, | |
| 1599 | + | 4400, 0, 2160, 2168, 2178, 2250, 0, | |
| 1600 | + | DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) }; | |
| 1601 | + | struct drm_display_mode drm_mode; | |
| 1602 | + | ||
| 1603 | + | drm_mode_set_crtcinfo(&native_mode, 0); | |
| 1604 | + | drm_mode = native_mode; | |
| 1605 | + | drm_mode.hdisplay = 1920; | |
| 1606 | + | drm_mode.vdisplay = 1080; | |
| 1607 | + | drm_mode_set_crtcinfo(&drm_mode, 0); | |
| 1608 | + | ||
| 1609 | + | decide_crtc_timing_for_drm_display_mode(&drm_mode, &native_mode, false); | |
| 1610 | + | ||
| 1611 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_hdisplay, 3840); | |
| 1612 | + | KUNIT_EXPECT_EQ(test, drm_mode.crtc_vdisplay, 2160); | |
| 1613 | + | } | |
| 1614 | + | ||
| 1465 | 1615 | /* Tests for amdgpu_dm_connector_funcs_reset() */ | |
| 1466 | 1616 | ||
| 1467 | 1617 | static const struct drm_connector_funcs dm_test_connector_funcs = { | |
| @@ -3425,6 +3575,7 @@ static struct dm_test_fill_ctx *dm_test_fill_ctx_alloc(struct kunit *test) | |||
| 3425 | 3575 | ||
| 3426 | 3576 | ctx->conn_state = drmm_kzalloc(ctx->drm, sizeof(*ctx->conn_state), GFP_KERNEL); | |
| 3427 | 3577 | KUNIT_ASSERT_NOT_NULL(test, ctx->conn_state); | |
| 3578 | + | ctx->conn_state->connector = &ctx->aconnector->base; | |
| 3428 | 3579 | ctx->stream = kunit_kzalloc(test, sizeof(*ctx->stream), GFP_KERNEL); | |
| 3429 | 3580 | KUNIT_ASSERT_NOT_NULL(test, ctx->stream); | |
| 3430 | 3581 | ctx->mode = kunit_kzalloc(test, sizeof(*ctx->mode), GFP_KERNEL); | |
| @@ -3818,6 +3969,7 @@ static struct dm_test_stream_ctx *dm_test_stream_ctx_alloc(struct kunit *test) | |||
| 3818 | 3969 | ||
| 3819 | 3970 | ctx->dm_state = kunit_kzalloc(test, sizeof(*ctx->dm_state), GFP_KERNEL); | |
| 3820 | 3971 | KUNIT_ASSERT_NOT_NULL(test, ctx->dm_state); | |
| 3972 | + | ctx->dm_state->base.connector = &ctx->aconnector->base; | |
| 3821 | 3973 | ctx->dm_state->scaling = RMX_OFF; | |
| 3822 | 3974 | ||
| 3823 | 3975 | ctx->mode = kunit_kzalloc(test, sizeof(*ctx->mode), GFP_KERNEL); | |
| @@ -5458,6 +5610,11 @@ static struct kunit_case amdgpu_dm_connector_tests[] = { | |||
| 5458 | 5610 | KUNIT_CASE(dm_test_output_color_space_oprgb), | |
| 5459 | 5611 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb), | |
| 5460 | 5612 | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_limited), | |
| 5613 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_cta), | |
| 5614 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_hdmi_vga), | |
| 5615 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_auto_dp_cta), | |
| 5616 | + | KUNIT_CASE(dm_test_output_color_space_default_rgb_full_hdmi_cta), | |
| 5617 | + | KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_auto_hdmi_cta), | |
| 5461 | 5618 | KUNIT_CASE(dm_test_output_color_space_bt2020_ycc), | |
| 5462 | 5619 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr709_y_only), | |
| 5463 | 5620 | KUNIT_CASE(dm_test_output_color_space_default_ycbcr601), | |
| @@ -5518,6 +5675,8 @@ static struct kunit_case amdgpu_dm_connector_tests[] = { | |||
| 5518 | 5675 | KUNIT_CASE(dm_test_decide_crtc_timing_matching_mode), | |
| 5519 | 5676 | KUNIT_CASE(dm_test_decide_crtc_timing_no_copy), | |
| 5520 | 5677 | KUNIT_CASE(dm_test_decide_crtc_timing_no_crtc_clock), | |
| 5678 | + | KUNIT_CASE(dm_test_decide_crtc_timing_sink_mode_same_totals), | |
| 5679 | + | KUNIT_CASE(dm_test_decide_crtc_timing_inserted_mode), | |
| 5521 | 5680 | /* amdgpu_dm_connector_funcs_reset */ | |
| 5522 | 5681 | KUNIT_CASE(dm_test_funcs_reset_sets_defaults), | |
| 5523 | 5682 | KUNIT_CASE(dm_test_funcs_reset_edp_abm_level), | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
| @@ -436,7 +436,7 @@ static void dm_test_crtc_set_vupdate_irq_no_otg(struct kunit *test) | |||
| 436 | 436 | * dm_test_crtc_set_vupdate_irq_dc_busy - Test vupdate irq when DC rejects request | |
| 437 | 437 | * @test: The KUnit test context | |
| 438 | 438 | * | |
| 439 | - | * With an OTG instance assigned but no DC attached, dc_interrupt_set() returns | |
| 439 | + | * With an OTG instance assigned but no DC attached, amdgpu_dm_irq_set() returns | |
| 440 | 440 | * false and the function must report the request as busy (-EBUSY). | |
| 441 | 441 | */ | |
| 442 | 442 | static void dm_test_crtc_set_vupdate_irq_dc_busy(struct kunit *test) | |
| @@ -453,12 +453,12 @@ static void dm_test_crtc_set_vupdate_irq_dc_busy(struct kunit *test) | |||
| 453 | 453 | acrtc->base.dev = &adev->ddev; | |
| 454 | 454 | acrtc->otg_inst = 0; | |
| 455 | 455 | ||
| 456 | - | /* adev->dm.dc is NULL, so dc_interrupt_set() returns false. */ | |
| 456 | + | /* adev->dm.dc is NULL, so amdgpu_dm_irq_set() returns false. */ | |
| 457 | 457 | KUNIT_EXPECT_EQ(test, | |
| 458 | 458 | amdgpu_dm_crtc_set_vupdate_irq(&acrtc->base, true), -EBUSY); | |
| 459 | 459 | } | |
| 460 | 460 | ||
| 461 | - | /* Per-source funcs let dc_interrupt_set() succeed without register access. */ | |
| 461 | + | /* Per-source funcs let amdgpu_dm_irq_set() succeed without register access. */ | |
| 462 | 462 | static bool dm_test_vupdate_irq_src_set(struct irq_service *irq_service, | |
| 463 | 463 | const struct irq_source_info *info, | |
| 464 | 464 | bool enable) | |
| @@ -477,7 +477,7 @@ static struct irq_source_info_funcs dm_test_vupdate_irq_src_funcs = { | |||
| 477 | 477 | .ack = dm_test_vupdate_irq_src_ack, | |
| 478 | 478 | }; | |
| 479 | 479 | ||
| 480 | - | /* A .set that fails so dc_interrupt_set() reports the source as busy. */ | |
| 480 | + | /* A .set that fails so amdgpu_dm_irq_set() reports the source as busy. */ | |
| 481 | 481 | static bool dm_test_vupdate_irq_src_set_busy(struct irq_service *irq_service, | |
| 482 | 482 | const struct irq_source_info *info, | |
| 483 | 483 | bool enable) | |
| @@ -519,7 +519,9 @@ static void dm_test_crtc_set_vupdate_irq_enable(struct kunit *test) | |||
| 519 | 519 | irqs = kunit_kzalloc(test, sizeof(*irqs), GFP_KERNEL); | |
| 520 | 520 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, irqs); | |
| 521 | 521 | ||
| 522 | - | /* Populate the per-source info table so dc_interrupt_set() succeeds. */ | |
| 522 | + | /* | |
| 523 | + | * Populate the per-source info table so amdgpu_dm_irq_set() succeeds. | |
| 524 | + | */ | |
| 523 | 525 | info = kunit_kzalloc(test, sizeof(*info) * DAL_IRQ_SOURCES_NUMBER, | |
| 524 | 526 | GFP_KERNEL); | |
| 525 | 527 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); | |
| @@ -1018,7 +1020,9 @@ static void dm_test_crtc_enable_vblank_vupdate_busy(struct kunit *test) | |||
| 1018 | 1020 | irqs = kunit_kzalloc(test, sizeof(*irqs), GFP_KERNEL); | |
| 1019 | 1021 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, irqs); | |
| 1020 | 1022 | ||
| 1021 | - | /* Per-source .set fails so dc_interrupt_set() reports the source busy. */ | |
| 1023 | + | /* | |
| 1024 | + | * Per-source .set fails so amdgpu_dm_irq_set() reports the source busy. | |
| 1025 | + | */ | |
| 1022 | 1026 | info = kunit_kzalloc(test, sizeof(*info) * DAL_IRQ_SOURCES_NUMBER, | |
| 1023 | 1027 | GFP_KERNEL); | |
| 1024 | 1028 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_helpers_test.c
| @@ -2442,17 +2442,21 @@ static void dm_test_is_dp_sink_present_null_priv(struct kunit *test) | |||
| 2442 | 2442 | * dm_test_dmub_outbox_interrupt_control_null_dc - Test outbox irq control with NULL dc | |
| 2443 | 2443 | * @test: The KUnit test context | |
| 2444 | 2444 | * | |
| 2445 | - | * dc_interrupt_set() is NULL-safe and returns false when dc is NULL, so the | |
| 2445 | + | * amdgpu_dm_irq_set() is NULL-safe and returns false when dc is NULL, so the | |
| 2446 | 2446 | * helper returns false without touching real interrupt hardware. | |
| 2447 | 2447 | */ | |
| 2448 | 2448 | static void dm_test_dmub_outbox_interrupt_control_null_dc(struct kunit *test) | |
| 2449 | 2449 | { | |
| 2450 | + | struct amdgpu_device *adev; | |
| 2450 | 2451 | struct dc_context *ctx; | |
| 2451 | 2452 | ||
| 2453 | + | adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); | |
| 2454 | + | KUNIT_ASSERT_NOT_NULL(test, adev); | |
| 2452 | 2455 | ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); | |
| 2453 | 2456 | KUNIT_ASSERT_NOT_NULL(test, ctx); | |
| 2457 | + | ctx->driver_context = adev; | |
| 2454 | 2458 | ||
| 2455 | - | /* ctx->dc is NULL → dc_interrupt_set returns false */ | |
| 2459 | + | /* adev->dm.dc is NULL → amdgpu_dm_irq_set returns false */ | |
| 2456 | 2460 | KUNIT_EXPECT_FALSE(test, dm_helpers_dmub_outbox_interrupt_control(ctx, true)); | |
| 2457 | 2461 | KUNIT_EXPECT_FALSE(test, dm_helpers_dmub_outbox_interrupt_control(ctx, false)); | |
| 2458 | 2462 | } | |
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
| @@ -268,7 +268,7 @@ static bool dm_test_irq_src_ack(struct irq_service *irq_service, | |||
| 268 | 268 | return true; | |
| 269 | 269 | } | |
| 270 | 270 | ||
| 271 | - | /* Per-source funcs let dc_interrupt_set() succeed without register access. */ | |
| 271 | + | /* Per-source funcs let amdgpu_dm_irq_set() succeed without register access. */ | |
| 272 | 272 | static struct irq_source_info_funcs dm_test_irq_src_funcs = { | |
| 273 | 273 | .set = dm_test_irq_src_set, | |
| 274 | 274 | .ack = dm_test_irq_src_ack, | |
| @@ -290,7 +290,7 @@ static struct dc *dm_test_alloc_dc_with_irq_service(struct kunit *test, | |||
| 290 | 290 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, irqs); | |
| 291 | 291 | ||
| 292 | 292 | /* | |
| 293 | - | * Populate the per-source info table so dc_interrupt_set()/_ack() | |
| 293 | + | * Populate the per-source info table so amdgpu_dm_irq_set()/_ack() | |
| 294 | 294 | * succeed without touching hardware registers. | |
| 295 | 295 | */ | |
| 296 | 296 | info = kunit_kzalloc(test, sizeof(*info) * DAL_IRQ_SOURCES_NUMBER, | |
| @@ -1227,7 +1227,7 @@ static void dm_test_irq_suspend_empty(struct kunit *test) | |||
| 1227 | 1227 | KUNIT_ASSERT_EQ(test, amdgpu_dm_irq_init(adev), 0); | |
| 1228 | 1228 | ||
| 1229 | 1229 | /* | |
| 1230 | - | * With no registered handlers the HW dc_interrupt_set() calls are | |
| 1230 | + | * With no registered handlers the amdgpu_dm_irq_set() calls are | |
| 1231 | 1231 | * skipped, so suspend must complete without touching the (absent) DC. | |
| 1232 | 1232 | */ | |
| 1233 | 1233 | amdgpu_dm_irq_suspend(adev); | |
| @@ -1275,11 +1275,11 @@ static void dm_test_irq_resume_late_empty(struct kunit *test) | |||
| 1275 | 1275 | } | |
| 1276 | 1276 | ||
| 1277 | 1277 | /** | |
| 1278 | - | * dm_test_irq_suspend_registered - Test suspend reaches the dc_interrupt_set path | |
| 1278 | + | * dm_test_irq_suspend_registered - Test suspend reaches the irq set path | |
| 1279 | 1279 | * @test: The KUnit test context | |
| 1280 | 1280 | * | |
| 1281 | 1281 | * Registers a low-context HPD handler so the handler list is non-empty, | |
| 1282 | - | * forcing amdgpu_dm_irq_suspend() to call dc_interrupt_set() (NULL-safe with | |
| 1282 | + | * forcing amdgpu_dm_irq_suspend() to call amdgpu_dm_irq_set() (NULL-safe with | |
| 1283 | 1283 | * no DC) and flush_work() on the registered handler. | |
| 1284 | 1284 | */ | |
| 1285 | 1285 | static void dm_test_irq_suspend_registered(struct kunit *test) | |
| @@ -1330,11 +1330,11 @@ static void dm_test_irq_suspend_disables_polling(struct kunit *test) | |||
| 1330 | 1330 | } | |
| 1331 | 1331 | ||
| 1332 | 1332 | /** | |
| 1333 | - | * dm_test_irq_resume_early_registered - Test early resume reaches dc_interrupt_set | |
| 1333 | + | * dm_test_irq_resume_early_registered - Test early resume reaches irq set | |
| 1334 | 1334 | * @test: The KUnit test context | |
| 1335 | 1335 | * | |
| 1336 | 1336 | * Registers a low-context HPD RX handler so early resume calls | |
| 1337 | - | * dc_interrupt_set() for the short-pulse interrupt source. | |
| 1337 | + | * amdgpu_dm_irq_set() for the short-pulse interrupt source. | |
| 1338 | 1338 | */ | |
| 1339 | 1339 | static void dm_test_irq_resume_early_registered(struct kunit *test) | |
| 1340 | 1340 | { | |
| @@ -1358,10 +1358,10 @@ static void dm_test_irq_resume_early_registered(struct kunit *test) | |||
| 1358 | 1358 | } | |
| 1359 | 1359 | ||
| 1360 | 1360 | /** | |
| 1361 | - | * dm_test_irq_resume_late_registered - Test late resume reaches dc_interrupt_set | |
| 1361 | + | * dm_test_irq_resume_late_registered - Test late resume reaches irq set | |
| 1362 | 1362 | * @test: The KUnit test context | |
| 1363 | 1363 | * | |
| 1364 | - | * Registers a low-context HPD handler so late resume calls dc_interrupt_set() | |
| 1364 | + | * Registers a low-context HPD handler so late resume calls amdgpu_dm_irq_set() | |
| 1365 | 1365 | * for the HPD interrupt source. | |
| 1366 | 1366 | */ | |
| 1367 | 1367 | static void dm_test_irq_resume_late_registered(struct kunit *test) | |
| @@ -1592,7 +1592,7 @@ static void dm_test_set_crtc_irq_state_enable(struct kunit *test) | |||
| 1592 | 1592 | ||
| 1593 | 1593 | /* | |
| 1594 | 1594 | * otg_inst >= 0 computes the irq source and reaches the NULL-safe | |
| 1595 | - | * dc_interrupt_set(); the ips_support branch is skipped (dc == NULL). | |
| 1595 | + | * amdgpu_dm_irq_set(); the ips_support branch is skipped (dc == NULL). | |
| 1596 | 1596 | */ | |
| 1597 | 1597 | acrtc->otg_inst = 3; | |
| 1598 | 1598 | adev->mode_info.crtcs[0] = acrtc; | |
| @@ -1671,8 +1671,8 @@ static void dm_test_set_vupdate_irq_state_enable(struct kunit *test) | |||
| 1671 | 1671 | * | |
| 1672 | 1672 | * With a non-NULL DC that advertises IPS support and currently allows idle | |
| 1673 | 1673 | * optimizations, dm_irq_state() must call dc_allow_idle_optimizations() before | |
| 1674 | - | * dc_interrupt_set(). disable_idle_power_optimizations makes that call a safe | |
| 1675 | - | * early return, and per-source stub funcs let dc_interrupt_set() succeed. | |
| 1674 | + | * amdgpu_dm_irq_set(). disable_idle_power_optimizations makes that call a safe | |
| 1675 | + | * early return, and per-source stub funcs let amdgpu_dm_irq_set() succeed. | |
| 1676 | 1676 | */ | |
| 1677 | 1677 | static void dm_test_set_crtc_irq_state_allows_idle(struct kunit *test) | |
| 1678 | 1678 | { | |
| @@ -1891,7 +1891,7 @@ static void dm_test_set_hpd_irq_state_null_dc(struct kunit *test) | |||
| 1891 | 1891 | adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); | |
| 1892 | 1892 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev); | |
| 1893 | 1893 | ||
| 1894 | - | /* dc_interrupt_set() is a no-op when dc is NULL, so both states | |
| 1894 | + | /* amdgpu_dm_irq_set() is a no-op when dc is NULL, so both states | |
| 1895 | 1895 | * return 0 without dereferencing the (absent) DC. | |
| 1896 | 1896 | */ | |
| 1897 | 1897 | KUNIT_EXPECT_EQ(test, amdgpu_dm_set_hpd_irq_state(adev, NULL, AMDGPU_HPD_1, | |
| @@ -1951,7 +1951,7 @@ static void dm_test_outbox_init_null_dc(struct kunit *test) | |||
| 1951 | 1951 | adev = kunit_kzalloc(test, sizeof(*adev), GFP_KERNEL); | |
| 1952 | 1952 | KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adev); | |
| 1953 | 1953 | ||
| 1954 | - | /* Single dc_interrupt_set() call must be skipped when dc is NULL. */ | |
| 1954 | + | /* Single amdgpu_dm_irq_set() call must be skipped when dc is NULL. */ | |
| 1955 | 1955 | amdgpu_dm_outbox_init(adev); | |
| 1956 | 1956 | } | |
| 1957 | 1957 | ||
| @@ -1969,7 +1969,7 @@ static void dm_test_hpd_init_empty_connectors(struct kunit *test) | |||
| 1969 | 1969 | ||
| 1970 | 1970 | /* | |
| 1971 | 1971 | * With an empty connector list the per-connector loop is skipped and | |
| 1972 | - | * the initial clear loop relies on dc_interrupt_set() being a no-op | |
| 1972 | + | * the initial clear loop relies on amdgpu_dm_irq_set() being a no-op | |
| 1973 | 1973 | * for a NULL dc, so init must complete without touching the DC. | |
| 1974 | 1974 | */ | |
| 1975 | 1975 | amdgpu_dm_hpd_init(adev); | |
| @@ -2004,7 +2004,7 @@ static void dm_test_hpd_init_fini_with_connectors(struct kunit *test) | |||
| 2004 | 2004 | ||
| 2005 | 2005 | /* | |
| 2006 | 2006 | * num_hpd = 0 forces irq_type >= num_hpd so the loop takes the HW | |
| 2007 | - | * fallback (dc_interrupt_set()) instead of amdgpu_irq_get(); with a | |
| 2007 | + | * fallback (amdgpu_dm_irq_set()) instead of amdgpu_irq_get(); with a | |
| 2008 | 2008 | * NULL dc that fallback is a safe no-op. | |
| 2009 | 2009 | */ | |
| 2010 | 2010 | adev->mode_info.num_hpd = 0; | |
| @@ -2090,7 +2090,7 @@ static void dm_test_hpd_init_fini_irq_ref(struct kunit *test) | |||
| 2090 | 2090 | /* | |
| 2091 | 2091 | * num_hpd >= 1 makes irq_type (0) < num_hpd, so the loop takes the | |
| 2092 | 2092 | * amdgpu_irq_get()/amdgpu_irq_put() branch instead of the | |
| 2093 | - | * dc_interrupt_set() fallback. The mock device has irq.installed == | |
| 2093 | + | * amdgpu_dm_irq_set() fallback. The mock device has irq.installed == | |
| 2094 | 2094 | * false, so both calls fail early with -ENOENT (logging an error) | |
| 2095 | 2095 | * without touching the base-driver irq state. | |
| 2096 | 2096 | */ | |
modified drivers/gpu/drm/amd/display/dc/dc.h
| @@ -1905,6 +1905,7 @@ struct dc_scratch_space { | |||
| 1905 | 1905 | struct ddc_service *ddc; | |
| 1906 | 1906 | ||
| 1907 | 1907 | enum dp_panel_mode panel_mode; | |
| 1908 | + | bool panel_mode_initialized; | |
| 1908 | 1909 | bool aux_mode; | |
| 1909 | 1910 | ||
| 1910 | 1911 | /* Private to DC core */ | |
modified drivers/gpu/drm/amd/display/dc/dml/Makefile
| @@ -29,14 +29,14 @@ dml_ccflags := $(CC_FLAGS_FPU) | |||
| 29 | 29 | dml_rcflags := $(CC_FLAGS_NO_FPU) | |
| 30 | 30 | ||
| 31 | 31 | ifneq ($(CONFIG_FRAME_WARN),0) | |
| 32 | - | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) | |
| 32 | + | ifneq ($(filter y,$(CONFIG_KASAN) $(CONFIG_KCSAN) $(CONFIG_UBSAN)),) | |
| 33 | 33 | ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_COMPILE_TEST),yy) | |
| 34 | 34 | frame_warn_limit := 4096 | |
| 35 | 35 | else | |
| 36 | 36 | frame_warn_limit := 3072 | |
| 37 | 37 | endif | |
| 38 | 38 | else | |
| 39 | - | frame_warn_limit := 2048 | |
| 39 | + | frame_warn_limit := 3072 | |
| 40 | 40 | endif | |
| 41 | 41 | ||
| 42 | 42 | ifeq ($(call test-lt, $(CONFIG_FRAME_WARN), $(frame_warn_limit)),y) | |
modified drivers/gpu/drm/amd/display/dc/dml2_0/Makefile
| @@ -28,14 +28,14 @@ dml2_ccflags := $(CC_FLAGS_FPU) | |||
| 28 | 28 | dml2_rcflags := $(CC_FLAGS_NO_FPU) | |
| 29 | 29 | ||
| 30 | 30 | ifneq ($(CONFIG_FRAME_WARN),0) | |
| 31 | - | ifeq ($(filter y,$(CONFIG_KASAN)$(CONFIG_KCSAN)),y) | |
| 31 | + | ifneq ($(filter y,$(CONFIG_KASAN) $(CONFIG_KCSAN) $(CONFIG_UBSAN)),) | |
| 32 | 32 | ifeq ($(CONFIG_CC_IS_CLANG)$(CONFIG_COMPILE_TEST),yy) | |
| 33 | 33 | frame_warn_limit := 4096 | |
| 34 | 34 | else | |
| 35 | 35 | frame_warn_limit := 3072 | |
| 36 | 36 | endif | |
| 37 | 37 | else | |
| 38 | - | frame_warn_limit := 2056 | |
| 38 | + | frame_warn_limit := 3072 | |
| 39 | 39 | endif | |
| 40 | 40 | ||
| 41 | 41 | ifeq ($(call test-lt, $(CONFIG_FRAME_WARN), $(frame_warn_limit)),y) | |
modified drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c
| @@ -1064,10 +1064,12 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable) | |||
| 1064 | 1064 | */ | |
| 1065 | 1065 | unsigned int denom = refresh_hz * 6528; | |
| 1066 | 1066 | unsigned int stutter_period = dc->current_state->perf_params.stutter_period_us; | |
| 1067 | + | uint64_t num = (1000000LL + 2 * stutter_period * refresh_hz) * | |
| 1068 | + | (100LL + dc->debug.mall_additional_timer_percent); | |
| 1069 | + | uint64_t tmr_ticks; | |
| 1067 | 1070 | ||
| 1068 | - | tmr_delay = (uint32_t)(div_u64(((1000000LL + 2 * stutter_period * refresh_hz) * | |
| 1069 | - | (100LL + dc->debug.mall_additional_timer_percent) + denom - 1), | |
| 1070 | - | denom) - 64LL); | |
| 1071 | + | tmr_ticks = div_u64(num + denom - 1, denom); | |
| 1072 | + | tmr_delay = tmr_ticks > 64 ? (uint32_t)(tmr_ticks - 64) : 0; | |
| 1071 | 1073 | ||
| 1072 | 1074 | /* In some cases the stutter period is really big (tiny modes) in these | |
| 1073 | 1075 | * cases MALL cant be enabled, So skip these cases to avoid a ASSERT() | |
| @@ -1089,9 +1091,8 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable) | |||
| 1089 | 1091 | } | |
| 1090 | 1092 | ||
| 1091 | 1093 | denom *= 2; | |
| 1092 | - | tmr_delay = (uint32_t)(div_u64(((1000000LL + 2 * stutter_period * refresh_hz) * | |
| 1093 | - | (100LL + dc->debug.mall_additional_timer_percent) + denom - 1), | |
| 1094 | - | denom) - 64LL); | |
| 1094 | + | tmr_ticks = div_u64(num + denom - 1, denom); | |
| 1095 | + | tmr_delay = tmr_ticks > 64 ? (uint32_t)(tmr_ticks - 64) : 0; | |
| 1095 | 1096 | } | |
| 1096 | 1097 | ||
| 1097 | 1098 | /* Copy HW cursor */ | |
modified drivers/gpu/drm/amd/display/dc/hwss/dcn50/dcn50_hwseq.c
| @@ -67,7 +67,8 @@ static void dcn50_initialize_min_clocks(struct dc *dc) | |||
| 67 | 67 | * audio corruption. Read current DISPCLK from DENTIST and request the same | |
| 68 | 68 | * freq to ensure that the timing is valid and unchanged. | |
| 69 | 69 | */ | |
| 70 | - | clocks->dispclk_khz = dc->clk_mgr->funcs->get_dispclk_from_dentist(dc->clk_mgr); | |
| 70 | + | if (dc->clk_mgr->funcs->get_dispclk_from_dentist) | |
| 71 | + | clocks->dispclk_khz = dc->clk_mgr->funcs->get_dispclk_from_dentist(dc->clk_mgr); | |
| 71 | 72 | } | |
| 72 | 73 | clocks->ref_dtbclk_khz = dc->clk_mgr->bw_params->clk_table.entries[0].dtbclk_mhz * 1000; | |
| 73 | 74 | clocks->fclk_p_state_change_support = true; | |
| @@ -639,7 +640,8 @@ void dcn50_init_hw(struct dc *dc) | |||
| 639 | 640 | dc->res_pool->hubbub->funcs->allow_self_refresh_control(dc->res_pool->hubbub, | |
| 640 | 641 | !dc->res_pool->hubbub->ctx->dc->debug.disable_stutter); | |
| 641 | 642 | ||
| 642 | - | dcn50_initialize_min_clocks(dc); | |
| 643 | + | if (dc->clk_mgr && dc->clk_mgr->funcs) | |
| 644 | + | dcn50_initialize_min_clocks(dc); | |
| 643 | 645 | ||
| 644 | 646 | /* On HW init, allow idle optimizations after pipes have been turned off. | |
| 645 | 647 | * | |
modified drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c
| @@ -643,7 +643,8 @@ void dcn60_init_hw(struct dc *dc) | |||
| 643 | 643 | dc->res_pool->hubbub->funcs->allow_self_refresh_control(dc->res_pool->hubbub, | |
| 644 | 644 | !dc->res_pool->hubbub->ctx->dc->debug.disable_stutter); | |
| 645 | 645 | ||
| 646 | - | dcn401_initialize_min_clocks(dc); | |
| 646 | + | if (dc->clk_mgr && dc->clk_mgr->funcs) | |
| 647 | + | dcn401_initialize_min_clocks(dc); | |
| 647 | 648 | ||
| 648 | 649 | /* On HW init, allow idle optimizations after pipes have been turned off. | |
| 649 | 650 | * | |
| @@ -1001,6 +1002,7 @@ static void dcn60_build_hubbub_perfmon_sequence( | |||
| 1001 | 1002 | /** | |
| 1002 | 1003 | * dcn60_update_probe_status - Set the valid flag on a latched probe result. | |
| 1003 | 1004 | * @status: result sink whose u was written by the GET BLS step during execute | |
| 1005 | + | * @probe: current probe state used to determine measurement type and validity | |
| 1004 | 1006 | */ | |
| 1005 | 1007 | static void dcn60_update_probe_status(struct dc_probe_status *status) | |
| 1006 | 1008 | { | |
| @@ -1024,6 +1026,7 @@ static void dcn60_update_probe_status(struct dc_probe_status *status) | |||
| 1024 | 1026 | /** | |
| 1025 | 1027 | * is_probe_measurement_type_for_hubbub - Returns true if the probe type is | |
| 1026 | 1028 | * served by the hubbub perfmon block on DCN60. | |
| 1029 | + | * @type: the probe measurement type to classify | |
| 1027 | 1030 | */ | |
| 1028 | 1031 | static bool is_probe_measurement_type_for_hubbub(enum dc_probe_type type) | |
| 1029 | 1032 | { | |
modified drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c
| @@ -93,6 +93,7 @@ void dp_set_panel_mode(struct dc_link *link, enum dp_panel_mode panel_mode) | |||
| 93 | 93 | } | |
| 94 | 94 | ||
| 95 | 95 | link->panel_mode = panel_mode; | |
| 96 | + | link->panel_mode_initialized = true; | |
| 96 | 97 | DC_LOG_DETECTION_DP_CAPS("%d eDP panel mode supported: %d, enabled: %d\n", | |
| 97 | 98 | link->link_index, | |
| 98 | 99 | link->dpcd_caps.panel_mode_edp, | |
| @@ -1297,7 +1298,8 @@ void edp_set_panel_assr(struct dc_link *link, struct pipe_ctx *pipe_ctx, | |||
| 1297 | 1298 | ||
| 1298 | 1299 | result = cp_psp->funcs.enable_assr(cp_psp->handle, link); | |
| 1299 | 1300 | ||
| 1300 | - | if (!result && link->panel_mode != DP_PANEL_MODE_EDP) | |
| 1301 | + | if (!result && link->panel_mode_initialized && | |
| 1302 | + | link->panel_mode != DP_PANEL_MODE_EDP) | |
| 1301 | 1303 | *panel_mode = DP_PANEL_MODE_DEFAULT; | |
| 1302 | 1304 | } | |
| 1303 | 1305 | } | |
modified drivers/gpu/drm/amd/display/dc/resource/dce60/dce60_resource.c
| @@ -448,6 +448,12 @@ static const struct dce_abm_mask abm_mask = { | |||
| 448 | 448 | ABM_MASK_SH_LIST_DCE110(_MASK) | |
| 449 | 449 | }; | |
| 450 | 450 | ||
| 451 | + | static const struct dc_debug_options debug_defaults = { 0 }; | |
| 452 | + | ||
| 453 | + | static const struct dc_check_config config_defaults = { | |
| 454 | + | .enable_legacy_fast_update = true, | |
| 455 | + | }; | |
| 456 | + | ||
| 451 | 457 | #define CTX ctx | |
| 452 | 458 | #define REG(reg) mm ## reg | |
| 453 | 459 | ||
| @@ -937,6 +943,8 @@ static bool dce60_construct( | |||
| 937 | 943 | dc->caps.max_cursor_size = 64; | |
| 938 | 944 | dc->caps.dual_link_dvi = true; | |
| 939 | 945 | dc->caps.extended_aux_timeout_support = false; | |
| 946 | + | dc->debug = debug_defaults; | |
| 947 | + | dc->check_config = config_defaults; | |
| 940 | 948 | ||
| 941 | 949 | /************************************************* | |
| 942 | 950 | * Create resources * | |
| @@ -1134,6 +1142,8 @@ static bool dce61_construct( | |||
| 1134 | 1142 | dc->caps.i2c_speed_in_khz = 40; | |
| 1135 | 1143 | dc->caps.max_cursor_size = 64; | |
| 1136 | 1144 | dc->caps.is_apu = true; | |
| 1145 | + | dc->debug = debug_defaults; | |
| 1146 | + | dc->check_config = config_defaults; | |
| 1137 | 1147 | ||
| 1138 | 1148 | /************************************************* | |
| 1139 | 1149 | * Create resources * | |
| @@ -1331,7 +1341,8 @@ static bool dce64_construct( | |||
| 1331 | 1341 | dc->caps.max_downscale_ratio = 200; | |
| 1332 | 1342 | dc->caps.i2c_speed_in_khz = 40; | |
| 1333 | 1343 | dc->caps.max_cursor_size = 64; | |
| 1334 | - | dc->caps.is_apu = true; | |
| 1344 | + | dc->debug = debug_defaults; | |
| 1345 | + | dc->check_config = config_defaults; | |
| 1335 | 1346 | ||
| 1336 | 1347 | /************************************************* | |
| 1337 | 1348 | * Create resources * | |
modified drivers/gpu/drm/amd/display/dc/resource/dce80/dce80_resource.c
| @@ -1148,6 +1148,8 @@ static bool dce81_construct( | |||
| 1148 | 1148 | dc->caps.max_cursor_size = 128; | |
| 1149 | 1149 | dc->caps.min_horizontal_blanking_period = 80; | |
| 1150 | 1150 | dc->caps.is_apu = true; | |
| 1151 | + | dc->debug = debug_defaults; | |
| 1152 | + | dc->check_config = config_defaults; | |
| 1151 | 1153 | ||
| 1152 | 1154 | /************************************************* | |
| 1153 | 1155 | * Create resources * | |
modified drivers/gpu/drm/amd/display/modules/power/power.c
| @@ -328,6 +328,7 @@ bool mod_power_add_stream(struct mod_power *mod_power, | |||
| 328 | 328 | core_power->map[core_power->num_entities].psr_enabled = 0; | |
| 329 | 329 | core_power->map[core_power->num_entities].psr_events = psr_event_vsync; | |
| 330 | 330 | core_power->map[core_power->num_entities].psr_power_opt = 0; | |
| 331 | + | core_power->map[core_power->num_entities].replay_events = replay_event_vsync; | |
| 331 | 332 | core_power->num_entities++; | |
| 332 | 333 | return true; | |
| 333 | 334 | } | |
| @@ -387,6 +388,7 @@ bool mod_power_remove_stream(struct mod_power *mod_power, | |||
| 387 | 388 | core_power->map[i].psr_enabled = core_power->map[i + 1].psr_enabled; | |
| 388 | 389 | core_power->map[i].psr_events = core_power->map[i + 1].psr_events; | |
| 389 | 390 | core_power->map[i].psr_power_opt = core_power->map[i + 1].psr_power_opt; | |
| 391 | + | core_power->map[i].replay_events = core_power->map[i + 1].replay_events; | |
| 390 | 392 | ||
| 391 | 393 | memcpy(core_power->map[i].psr_context, core_power->map[i + 1].psr_context, sizeof(struct mod_power_psr_context)); | |
| 392 | 394 | memset(core_power->map[i + 1].psr_context, 0, sizeof(struct mod_power_psr_context)); | |
modified drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
| @@ -5263,7 +5263,8 @@ static int si_init_smc_table(struct amdgpu_device *adev) | |||
| 5263 | 5263 | break; | |
| 5264 | 5264 | } | |
| 5265 | 5265 | ||
| 5266 | - | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC) | |
| 5266 | + | if ((adev->flags & AMD_IS_MOBILITY) && | |
| 5267 | + | (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_HARDWAREDC)) | |
| 5267 | 5268 | table->systemFlags |= PPSMC_SYSTEMFLAG_GPIO_DC; | |
| 5268 | 5269 | ||
| 5269 | 5270 | if (adev->pm.dpm.platform_caps & ATOM_PP_PLATFORM_CAP_REGULATOR_HOT) { | |
| @@ -7237,6 +7238,19 @@ static void si_parse_pplib_non_clock_info(struct amdgpu_device *adev, | |||
| 7237 | 7238 | adev->pm.dpm.uvd_ps = rps; | |
| 7238 | 7239 | } | |
| 7239 | 7240 | ||
| 7241 | + | static void si_update_limits(struct amdgpu_clock_and_voltage_limits *limits, | |
| 7242 | + | struct rv7xx_pl *pl) | |
| 7243 | + | { | |
| 7244 | + | if (pl->sclk > limits->sclk) | |
| 7245 | + | limits->sclk = pl->sclk; | |
| 7246 | + | if (pl->mclk > limits->mclk) | |
| 7247 | + | limits->mclk = pl->mclk; | |
| 7248 | + | if (pl->vddc > limits->vddc) | |
| 7249 | + | limits->vddc = pl->vddc; | |
| 7250 | + | if (pl->vddci > limits->vddci) | |
| 7251 | + | limits->vddci = pl->vddci; | |
| 7252 | + | } | |
| 7253 | + | ||
| 7240 | 7254 | static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |
| 7241 | 7255 | struct amdgpu_ps *rps, int index, | |
| 7242 | 7256 | union pplib_clock_info *clock_info) | |
| @@ -7245,7 +7259,6 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |||
| 7245 | 7259 | struct evergreen_power_info *eg_pi = evergreen_get_pi(adev); | |
| 7246 | 7260 | struct si_power_info *si_pi = si_get_pi(adev); | |
| 7247 | 7261 | struct si_ps *ps = si_get_ps(rps); | |
| 7248 | - | struct amdgpu_clock_and_voltage_limits *limits; | |
| 7249 | 7262 | u16 leakage_voltage; | |
| 7250 | 7263 | struct rv7xx_pl *pl = &ps->performance_levels[index]; | |
| 7251 | 7264 | int ret; | |
| @@ -7310,26 +7323,14 @@ static void si_parse_pplib_clock_info(struct amdgpu_device *adev, | |||
| 7310 | 7323 | * VBIOS can contain conflicting values between: | |
| 7311 | 7324 | * - the maximum allowed clocks and voltages on AC or DC | |
| 7312 | 7325 | * - the clocks and voltages in power states on AC or DC | |
| 7326 | + | * | |
| 7327 | + | * Assume that the AC limits are the maximum of all power states, | |
| 7328 | + | * and the DC limits are the maximum of battery power states. | |
| 7313 | 7329 | */ | |
| 7330 | + | si_update_limits(&adev->pm.dpm.dyn_state.max_clock_voltage_on_ac, pl); | |
| 7314 | 7331 | if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | |
| 7315 | - | ATOM_PPLIB_CLASSIFICATION_UI_PERFORMANCE) | |
| 7316 | - | limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_ac; | |
| 7317 | - | else if ((rps->class & ATOM_PPLIB_CLASSIFICATION_UI_MASK) == | |
| 7318 | 7332 | ATOM_PPLIB_CLASSIFICATION_UI_BATTERY) | |
| 7319 | - | limits = &adev->pm.dpm.dyn_state.max_clock_voltage_on_dc; | |
| 7320 | - | else | |
| 7321 | - | limits = NULL; | |
| 7322 | - | ||
| 7323 | - | if (limits) { | |
| 7324 | - | if (pl->sclk > limits->sclk) | |
| 7325 | - | limits->sclk = pl->sclk; | |
| 7326 | - | if (pl->mclk > limits->mclk) | |
| 7327 | - | limits->mclk = pl->mclk; | |
| 7328 | - | if (pl->vddc > limits->vddc) | |
| 7329 | - | limits->vddc = pl->vddc; | |
| 7330 | - | if (pl->vddci > limits->vddci) | |
| 7331 | - | limits->vddci = pl->vddci; | |
| 7332 | - | } | |
| 7333 | + | si_update_limits(&adev->pm.dpm.dyn_state.max_clock_voltage_on_dc, pl); | |
| 7333 | 7334 | } | |
| 7334 | 7335 | ||
| 7335 | 7336 | union pplib_power_state { | |
modified drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
| @@ -2142,6 +2142,7 @@ static void smu_v14_0_2_init_msg_ctl(struct smu_context *smu) | |||
| 2142 | 2142 | static ssize_t smu_v14_0_2_get_gpu_metrics(struct smu_context *smu, | |
| 2143 | 2143 | void **table) | |
| 2144 | 2144 | { | |
| 2145 | + | uint32_t mp1_ver = amdgpu_ip_version(smu->adev, MP1_HWIP, 0); | |
| 2145 | 2146 | struct gpu_metrics_v1_3 *gpu_metrics = | |
| 2146 | 2147 | (struct gpu_metrics_v1_3 *)smu_driver_table_ptr( | |
| 2147 | 2148 | smu, SMU_DRIVER_TABLE_GPU_METRICS); | |
| @@ -2171,6 +2172,8 @@ static ssize_t smu_v14_0_2_get_gpu_metrics(struct smu_context *smu, | |||
| 2171 | 2172 | metrics->Vcn1ActivityPercentage); | |
| 2172 | 2173 | ||
| 2173 | 2174 | gpu_metrics->average_socket_power = metrics->AverageSocketPower; | |
| 2175 | + | if (mp1_ver == IP_VERSION(14, 0, 3) && smu->smc_fw_version >= 0x00685000) | |
| 2176 | + | gpu_metrics->energy_accumulator = metrics->EnergyAccumulator; | |
| 2174 | 2177 | ||
| 2175 | 2178 | if (metrics->AverageGfxActivity <= SMU_14_0_2_BUSY_THRESHOLD) | |
| 2176 | 2179 | gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs; | |
modified drivers/gpu/drm/ci/xfails/msm-apq8016-fails.txt
| @@ -7,3 +7,10 @@ kms_hdmi_inject@inject-4k,Fail | |||
| 7 | 7 | kms_lease@lease-uevent,Fail | |
| 8 | 8 | msm/msm_mapping@memptrs,Fail | |
| 9 | 9 | msm/msm_mapping@ring,Fail | |
| 10 | + | ||
| 11 | + | # Started failing with v7.3-rc2 backmerge | |
| 12 | + | # https://gitlab.freedesktop.org/drm/msm/-/work_items/104 | |
| 13 | + | kms_cursor_legacy@single-move,Fail | |
| 14 | + | kms_cursor_legacy@torture-bo,Fail | |
| 15 | + | kms_cursor_legacy@forked-bo,Fail | |
| 16 | + | kms_cursor_legacy@torture-move,Fail | |
modified drivers/gpu/drm/i915/display/intel_cursor.c
| @@ -530,18 +530,14 @@ static int i9xx_check_cursor(struct intel_crtc_state *crtc_state, | |||
| 530 | 530 | } | |
| 531 | 531 | ||
| 532 | 532 | static void i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb *dsb, | |
| 533 | - | struct intel_plane *plane) | |
| 533 | + | struct intel_plane *plane, | |
| 534 | + | const struct intel_crtc_state *crtc_state) | |
| 534 | 535 | { | |
| 535 | 536 | struct intel_display *display = to_intel_display(plane); | |
| 536 | 537 | enum pipe pipe = plane->pipe; | |
| 537 | 538 | ||
| 538 | - | /* | |
| 539 | - | * Clear this whenever the hardware has selective fetch, not just when | |
| 540 | - | * the current state uses it. The cursor may have been enabled with | |
| 541 | - | * selective fetch earlier and had its enable bit orphaned when the | |
| 542 | - | * feature was switched off. | |
| 543 | - | */ | |
| 544 | - | if (!HAS_PSR2_SEL_FETCH(display)) | |
| 539 | + | if (!crtc_state->enable_psr2_sel_fetch && | |
| 540 | + | !crtc_state->clear_psr2_sel_fetch) | |
| 545 | 541 | return; | |
| 546 | 542 | ||
| 547 | 543 | intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), 0); | |
| @@ -574,8 +570,10 @@ static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 574 | 570 | struct intel_display *display = to_intel_display(plane); | |
| 575 | 571 | enum pipe pipe = plane->pipe; | |
| 576 | 572 | ||
| 577 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 573 | + | if (!crtc_state->enable_psr2_sel_fetch) { | |
| 574 | + | i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 578 | 575 | return; | |
| 576 | + | } | |
| 579 | 577 | ||
| 580 | 578 | if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) { | |
| 581 | 579 | if (crtc_state->enable_psr2_su_region_et) { | |
| @@ -591,7 +589,7 @@ static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 591 | 589 | if (crtc_state->enable_psr2_su_region_et) | |
| 592 | 590 | wa_16021440873(dsb, plane, crtc_state, plane_state); | |
| 593 | 591 | else | |
| 594 | - | i9xx_cursor_disable_sel_fetch_arm(dsb, plane); | |
| 592 | + | i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 595 | 593 | } | |
| 596 | 594 | } | |
| 597 | 595 | ||
| @@ -700,7 +698,7 @@ static void i9xx_cursor_update_arm(struct intel_dsb *dsb, | |||
| 700 | 698 | if (plane_state) | |
| 701 | 699 | i9xx_cursor_update_sel_fetch_arm(dsb, plane, crtc_state, plane_state); | |
| 702 | 700 | else | |
| 703 | - | i9xx_cursor_disable_sel_fetch_arm(dsb, plane); | |
| 701 | + | i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 704 | 702 | ||
| 705 | 703 | if (plane->cursor.base != base || | |
| 706 | 704 | plane->cursor.size != fbc_ctl || | |
modified drivers/gpu/drm/i915/display/intel_display_params.c
| @@ -120,6 +120,10 @@ intel_display_param_named_unsafe(enable_psr, int, 0400, | |||
| 120 | 120 | "(0=disabled, 1=enable up to PSR1, 2=enable up to PSR2) " | |
| 121 | 121 | "Default: -1 (use per-chip default)"); | |
| 122 | 122 | ||
| 123 | + | intel_display_param_named_unsafe(enable_dc_balance, bool, 0400, | |
| 124 | + | "Enable VRR DC balance (0=disabled, 1=enabled). " | |
| 125 | + | "Default: 0 (disabled)"); | |
| 126 | + | ||
| 123 | 127 | intel_display_param_named_unsafe(enable_panel_replay, int, 0400, | |
| 124 | 128 | "Enable Panel Replay (0=disabled, 1=enabled). Default: -1 (use per-chip default)"); | |
| 125 | 129 | ||
modified drivers/gpu/drm/i915/display/intel_display_params.h
| @@ -46,6 +46,7 @@ struct drm_printer; | |||
| 46 | 46 | param(bool, enable_dp_mst, true, 0600) \ | |
| 47 | 47 | param(int, enable_fbc, -1, 0600) \ | |
| 48 | 48 | param(int, enable_psr, -1, 0600) \ | |
| 49 | + | param(bool, enable_dc_balance, false, 0600) \ | |
| 49 | 50 | param(int, enable_panel_replay, -1, 0600) \ | |
| 50 | 51 | param(bool, psr_safest_params, false, 0400) \ | |
| 51 | 52 | param(bool, enable_psr2_sel_fetch, true, 0400) \ | |
modified drivers/gpu/drm/i915/display/intel_display_types.h
| @@ -1187,6 +1187,8 @@ struct intel_crtc_state { | |||
| 1187 | 1187 | bool has_sel_update; | |
| 1188 | 1188 | bool enable_psr2_sel_fetch; | |
| 1189 | 1189 | bool enable_psr2_su_region_et; | |
| 1190 | + | /* Drop the stale selective fetch enable bits as selective fetch is turned off */ | |
| 1191 | + | bool clear_psr2_sel_fetch; | |
| 1190 | 1192 | bool req_psr2_sdp_prior_scanline; | |
| 1191 | 1193 | bool has_panel_replay; | |
| 1192 | 1194 | bool link_off_after_as_sdp_when_pr_active; | |
modified drivers/gpu/drm/i915/display/intel_dp_link_caps.c
| @@ -3,6 +3,8 @@ | |||
| 3 | 3 | * Copyright © 2026 Intel Corporation | |
| 4 | 4 | */ | |
| 5 | 5 | ||
| 6 | + | #include <kunit/visibility.h> | |
| 7 | + | ||
| 6 | 8 | #include <linux/bitops.h> | |
| 7 | 9 | #include <linux/debugfs.h> | |
| 8 | 10 | #include <linux/log2.h> | |
| @@ -426,12 +428,15 @@ calc_allowed_config_filter(struct intel_dp_link_caps *link_caps, | |||
| 426 | 428 | const struct intel_dp_link_config *forced_params) | |
| 427 | 429 | { | |
| 428 | 430 | struct intel_dp_link_caps_filter allowed_configs = INTEL_DP_LINK_CAPS_FILTER_NONE; | |
| 431 | + | struct intel_display *display = to_intel_display(link_caps->dp); | |
| 429 | 432 | struct intel_dp_link_caps_order order = bw_desc_config_order(); | |
| 430 | 433 | struct intel_dp_link_caps_iter iter; | |
| 431 | 434 | struct intel_dp_link_config config; | |
| 432 | 435 | ||
| 433 | 436 | iter_start(&iter, link_caps, order, enabled_configs); | |
| 434 | 437 | for_each_dp_link_config(&iter, &config) { | |
| 438 | + | int config_idx; | |
| 439 | + | ||
| 435 | 440 | if (forced_params->rate && | |
| 436 | 441 | forced_params->rate != config.rate) | |
| 437 | 442 | continue; | |
| @@ -446,7 +451,11 @@ calc_allowed_config_filter(struct intel_dp_link_caps *link_caps, | |||
| 446 | 451 | if (config.lane_count > max_limits->lane_count) | |
| 447 | 452 | continue; | |
| 448 | 453 | ||
| 449 | - | allowed_configs.config_mask |= BIT(iter_pos_to_idx(link_caps, order, iter.pos)); | |
| 454 | + | config_idx = iter_pos_to_idx(link_caps, order, iter.pos); | |
| 455 | + | if (drm_WARN_ON(display->drm, config_idx < 0)) | |
| 456 | + | continue; | |
| 457 | + | ||
| 458 | + | allowed_configs.config_mask |= BIT(config_idx); | |
| 450 | 459 | } | |
| 451 | 460 | intel_dp_link_caps_iter_end(&iter); | |
| 452 | 461 | ||
| @@ -1295,14 +1304,14 @@ void intel_dp_link_caps_cleanup(struct intel_dp_link_caps *link_caps) | |||
| 1295 | 1304 | const struct intel_dp_link_caps_test_ops i915_display_dp_link_caps_test_ops = { | |
| 1296 | 1305 | INTEL_DP_LINK_CAPS_TEST_OPS_INIT | |
| 1297 | 1306 | }; | |
| 1298 | - | EXPORT_SYMBOL(i915_display_dp_link_caps_test_ops); | |
| 1307 | + | EXPORT_SYMBOL_IF_KUNIT(i915_display_dp_link_caps_test_ops); | |
| 1299 | 1308 | ||
| 1300 | 1309 | #else | |
| 1301 | 1310 | ||
| 1302 | 1311 | const struct intel_dp_link_caps_test_ops intel_display_dp_link_caps_test_ops = { | |
| 1303 | 1312 | INTEL_DP_LINK_CAPS_TEST_OPS_INIT | |
| 1304 | 1313 | }; | |
| 1305 | - | EXPORT_SYMBOL(intel_display_dp_link_caps_test_ops); | |
| 1314 | + | EXPORT_SYMBOL_IF_KUNIT(intel_display_dp_link_caps_test_ops); | |
| 1306 | 1315 | ||
| 1307 | 1316 | #endif /* I915 */ | |
| 1308 | 1317 | ||
modified drivers/gpu/drm/i915/display/intel_dp_link_training.c
| @@ -2825,14 +2825,14 @@ void intel_dp_link_training_cleanup(struct intel_dp_link_training *link_training | |||
| 2825 | 2825 | const struct intel_dp_link_training_test_ops i915_display_dp_link_training_test_ops = { | |
| 2826 | 2826 | INTEL_DP_LINK_TRAINING_TEST_OPS_INIT | |
| 2827 | 2827 | }; | |
| 2828 | - | EXPORT_SYMBOL(i915_display_dp_link_training_test_ops); | |
| 2828 | + | EXPORT_SYMBOL_IF_KUNIT(i915_display_dp_link_training_test_ops); | |
| 2829 | 2829 | ||
| 2830 | 2830 | #else | |
| 2831 | 2831 | ||
| 2832 | 2832 | const struct intel_dp_link_training_test_ops intel_display_dp_link_training_test_ops = { | |
| 2833 | 2833 | INTEL_DP_LINK_TRAINING_TEST_OPS_INIT | |
| 2834 | 2834 | }; | |
| 2835 | - | EXPORT_SYMBOL(intel_display_dp_link_training_test_ops); | |
| 2835 | + | EXPORT_SYMBOL_IF_KUNIT(intel_display_dp_link_training_test_ops); | |
| 2836 | 2836 | ||
| 2837 | 2837 | #endif /* I915 */ | |
| 2838 | 2838 | ||
modified drivers/gpu/drm/i915/display/intel_dp_mst.c
| @@ -852,7 +852,8 @@ static u8 get_pipes_downstream_of_mst_port(struct intel_atomic_state *state, | |||
| 852 | 852 | if (&connector->mst.dp->mst.mgr != mst_mgr) | |
| 853 | 853 | continue; | |
| 854 | 854 | ||
| 855 | - | if (connector->mst.port != parent_port && | |
| 855 | + | if (parent_port && | |
| 856 | + | connector->mst.port != parent_port && | |
| 856 | 857 | !drm_dp_mst_port_downstream_of_parent(mst_mgr, | |
| 857 | 858 | connector->mst.port, | |
| 858 | 859 | parent_port)) | |
| @@ -2167,6 +2168,27 @@ bool intel_dp_mst_crtc_needs_modeset(struct intel_atomic_state *state, | |||
| 2167 | 2168 | return false; | |
| 2168 | 2169 | } | |
| 2169 | 2170 | ||
| 2171 | + | bool intel_dp_mst_stream_disconnected(struct intel_atomic_state *state, | |
| 2172 | + | const struct intel_crtc *crtc) | |
| 2173 | + | { | |
| 2174 | + | struct intel_connector *connector; | |
| 2175 | + | ||
| 2176 | + | connector = get_connector_in_state_for_crtc(state, crtc); | |
| 2177 | + | if (!connector) | |
| 2178 | + | return false; | |
| 2179 | + | ||
| 2180 | + | if (!connector->mst.dp) | |
| 2181 | + | return false; | |
| 2182 | + | ||
| 2183 | + | if (!connector->mst.dp->mst.mgr.mst_state) | |
| 2184 | + | return true; | |
| 2185 | + | ||
| 2186 | + | if (drm_connector_is_unregistered(&connector->base)) | |
| 2187 | + | return true; | |
| 2188 | + | ||
| 2189 | + | return false; | |
| 2190 | + | } | |
| 2191 | + | ||
| 2170 | 2192 | /** | |
| 2171 | 2193 | * intel_dp_mst_prepare_probe - Prepare an MST link for topology probing | |
| 2172 | 2194 | * @intel_dp: DP port object | |
modified drivers/gpu/drm/i915/display/intel_dp_mst.h
| @@ -28,6 +28,8 @@ int intel_dp_mst_atomic_check_link(struct intel_atomic_state *state, | |||
| 28 | 28 | struct intel_link_bw_limits *limits); | |
| 29 | 29 | bool intel_dp_mst_crtc_needs_modeset(struct intel_atomic_state *state, | |
| 30 | 30 | struct intel_crtc *crtc); | |
| 31 | + | bool intel_dp_mst_stream_disconnected(struct intel_atomic_state *state, | |
| 32 | + | const struct intel_crtc *crtc); | |
| 31 | 33 | void intel_dp_mst_prepare_probe(struct intel_dp *intel_dp); | |
| 32 | 34 | bool intel_dp_mst_verify_dpcd_state(struct intel_dp *intel_dp); | |
| 33 | 35 | ||
modified drivers/gpu/drm/i915/display/intel_link_bw.c
| @@ -64,7 +64,8 @@ void intel_link_bw_init_limits(struct intel_atomic_state *state, | |||
| 64 | 64 | intel_atomic_get_new_crtc_state(state, crtc); | |
| 65 | 65 | int forced_bpp_x16 = get_forced_link_bpp_x16(state, crtc); | |
| 66 | 66 | ||
| 67 | - | if (state->base.duplicated && crtc_state) { | |
| 67 | + | if ((state->base.duplicated && crtc_state) || | |
| 68 | + | intel_dp_mst_stream_disconnected(state, crtc)) { | |
| 68 | 69 | limits->max_bpp_x16[pipe] = crtc_state->max_link_bpp_x16; | |
| 69 | 70 | if (intel_dsc_enabled_on_link(crtc_state)) | |
| 70 | 71 | limits->link_dsc_pipes |= BIT(pipe); | |
modified drivers/gpu/drm/i915/display/intel_psr.c
| @@ -2883,6 +2883,8 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, | |||
| 2883 | 2883 | struct intel_crtc *crtc) | |
| 2884 | 2884 | { | |
| 2885 | 2885 | struct intel_display *display = to_intel_display(state); | |
| 2886 | + | const struct intel_crtc_state *old_crtc_state = | |
| 2887 | + | intel_atomic_get_old_crtc_state(state, crtc); | |
| 2886 | 2888 | struct intel_crtc_state *crtc_state = intel_atomic_get_new_crtc_state(state, crtc); | |
| 2887 | 2889 | struct intel_plane_state *new_plane_state, *old_plane_state; | |
| 2888 | 2890 | struct intel_plane *plane; | |
| @@ -2895,6 +2897,19 @@ int intel_psr2_sel_fetch_update(struct intel_atomic_state *state, | |||
| 2895 | 2897 | bool full_update = false, su_area_changed; | |
| 2896 | 2898 | int i, ret; | |
| 2897 | 2899 | ||
| 2900 | + | /* | |
| 2901 | + | * Selective fetch is not always usable, for instance it is dropped | |
| 2902 | + | * while pipe CRC is active. The planes keep their selective fetch | |
| 2903 | + | * enable bit set in hardware over that, and a plane disabled while | |
| 2904 | + | * selective fetch is off never gets the bit cleared. Once selective | |
| 2905 | + | * fetch comes back the hardware would resume fetching for a plane that | |
| 2906 | + | * is no longer enabled and keep its DDB range reserved, so have the | |
| 2907 | + | * plane update drop the bit for every plane of the pipe as selective | |
| 2908 | + | * fetch is turned off. | |
| 2909 | + | */ | |
| 2910 | + | crtc_state->clear_psr2_sel_fetch = old_crtc_state->enable_psr2_sel_fetch && | |
| 2911 | + | !crtc_state->enable_psr2_sel_fetch; | |
| 2912 | + | ||
| 2898 | 2913 | if (!crtc_state->enable_psr2_sel_fetch) | |
| 2899 | 2914 | return 0; | |
| 2900 | 2915 | ||
modified drivers/gpu/drm/i915/display/intel_quirks.c
| @@ -257,6 +257,9 @@ static struct intel_quirk intel_quirks[] = { | |||
| 257 | 257 | /* Dell XPS 13 7390 2-in-1 */ | |
| 258 | 258 | { 0x8a52, 0x1028, 0x08b0, quirk_edp_limit_rate_hbr2 }, | |
| 259 | 259 | ||
| 260 | + | /* HP Pavilion Plus Laptop 14-ew1xxx */ | |
| 261 | + | { 0x7d55, 0x103c, 0x8c31, quirk_edp_limit_rate_hbr2 }, | |
| 262 | + | ||
| 260 | 263 | /* Xiaomi Book Pro 14 2026 */ | |
| 261 | 264 | { 0xb081, 0x1d72, 0x2424, quirk_disable_psr2 }, | |
| 262 | 265 | }; | |
modified drivers/gpu/drm/i915/display/intel_vrr.c
| @@ -386,10 +386,12 @@ static bool intel_vrr_dc_balance_possible(const struct intel_crtc_state *crtc_st | |||
| 386 | 386 | static void | |
| 387 | 387 | intel_vrr_dc_balance_compute_config(struct intel_crtc_state *crtc_state) | |
| 388 | 388 | { | |
| 389 | + | struct intel_display *display = to_intel_display(crtc_state); | |
| 389 | 390 | int guardband_usec, adjustment_usec; | |
| 390 | 391 | struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; | |
| 391 | 392 | ||
| 392 | - | if (!intel_vrr_dc_balance_possible(crtc_state) || !crtc_state->vrr.enable) | |
| 393 | + | if (!intel_vrr_dc_balance_possible(crtc_state) || | |
| 394 | + | !crtc_state->vrr.enable || !display->params.enable_dc_balance) | |
| 393 | 395 | return; | |
| 394 | 396 | ||
| 395 | 397 | crtc_state->vrr.dc_balance.vmax = crtc_state->vrr.vmax; | |
modified drivers/gpu/drm/i915/display/skl_universal_plane.c
| @@ -879,18 +879,14 @@ skl_plane_disable_arm(struct intel_dsb *dsb, | |||
| 879 | 879 | } | |
| 880 | 880 | ||
| 881 | 881 | static void icl_plane_disable_sel_fetch_arm(struct intel_dsb *dsb, | |
| 882 | - | struct intel_plane *plane) | |
| 882 | + | struct intel_plane *plane, | |
| 883 | + | const struct intel_crtc_state *crtc_state) | |
| 883 | 884 | { | |
| 884 | 885 | struct intel_display *display = to_intel_display(plane); | |
| 885 | 886 | enum pipe pipe = plane->pipe; | |
| 886 | 887 | ||
| 887 | - | /* | |
| 888 | - | * Clear this whenever the hardware has selective fetch, not just when | |
| 889 | - | * the current state uses it. The plane may have been enabled with | |
| 890 | - | * selective fetch earlier and had its enable bit orphaned when the | |
| 891 | - | * feature was switched off. | |
| 892 | - | */ | |
| 893 | - | if (!HAS_PSR2_SEL_FETCH(display)) | |
| 888 | + | if (!crtc_state->enable_psr2_sel_fetch && | |
| 889 | + | !crtc_state->clear_psr2_sel_fetch) | |
| 894 | 890 | return; | |
| 895 | 891 | ||
| 896 | 892 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), 0); | |
| @@ -926,7 +922,7 @@ icl_plane_disable_arm(struct intel_dsb *dsb, | |||
| 926 | 922 | ||
| 927 | 923 | skl_write_plane_wm(dsb, plane, crtc_state); | |
| 928 | 924 | ||
| 929 | - | icl_plane_disable_sel_fetch_arm(dsb, plane); | |
| 925 | + | icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 930 | 926 | ||
| 931 | 927 | if (plane_has_normalizer(plane)) | |
| 932 | 928 | intel_de_write_dsb(display, dsb, | |
| @@ -1639,14 +1635,12 @@ static void icl_plane_update_sel_fetch_arm(struct intel_dsb *dsb, | |||
| 1639 | 1635 | struct intel_display *display = to_intel_display(plane); | |
| 1640 | 1636 | enum pipe pipe = plane->pipe; | |
| 1641 | 1637 | ||
| 1642 | - | if (!crtc_state->enable_psr2_sel_fetch) | |
| 1643 | - | return; | |
| 1644 | - | ||
| 1645 | - | if (drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) | |
| 1638 | + | if (crtc_state->enable_psr2_sel_fetch && | |
| 1639 | + | drm_rect_height(&plane_state->psr2_sel_fetch_area) > 0) | |
| 1646 | 1640 | intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), | |
| 1647 | 1641 | SEL_FETCH_PLANE_CTL_ENABLE); | |
| 1648 | 1642 | else | |
| 1649 | - | icl_plane_disable_sel_fetch_arm(dsb, plane); | |
| 1643 | + | icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state); | |
| 1650 | 1644 | } | |
| 1651 | 1645 | ||
| 1652 | 1646 | static void | |
modified drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
| @@ -1766,6 +1766,7 @@ static int eb_reinit_userptr(struct i915_execbuffer *eb) | |||
| 1766 | 1766 | ||
| 1767 | 1767 | static noinline int eb_relocate_parse_slow(struct i915_execbuffer *eb) | |
| 1768 | 1768 | { | |
| 1769 | + | const unsigned int count = eb->buffer_count; | |
| 1769 | 1770 | bool have_copy = false; | |
| 1770 | 1771 | struct eb_vma *ev; | |
| 1771 | 1772 | int err = 0; | |
| @@ -1868,7 +1869,6 @@ err: | |||
| 1868 | 1869 | ||
| 1869 | 1870 | out: | |
| 1870 | 1871 | if (have_copy) { | |
| 1871 | - | const unsigned int count = eb->buffer_count; | |
| 1872 | 1872 | unsigned int i; | |
| 1873 | 1873 | ||
| 1874 | 1874 | for (i = 0; i < count; i++) { | |
modified drivers/gpu/drm/i915/gem/i915_gem_object.c
| @@ -89,6 +89,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void) | |||
| 89 | 89 | ||
| 90 | 90 | void i915_gem_object_free(struct drm_i915_gem_object *obj) | |
| 91 | 91 | { | |
| 92 | + | dma_resv_fini(&obj->base._resv); | |
| 92 | 93 | return kmem_cache_free(slab_objects, obj); | |
| 93 | 94 | } | |
| 94 | 95 | ||
| @@ -144,7 +145,6 @@ void __i915_gem_object_fini(struct drm_i915_gem_object *obj) | |||
| 144 | 145 | { | |
| 145 | 146 | mutex_destroy(&obj->mm.get_page.lock); | |
| 146 | 147 | mutex_destroy(&obj->mm.get_dma_page.lock); | |
| 147 | - | dma_resv_fini(&obj->base._resv); | |
| 148 | 148 | } | |
| 149 | 149 | ||
| 150 | 150 | /** | |
modified drivers/gpu/drm/i915/gt/intel_rps.c
| @@ -1904,7 +1904,8 @@ static void rps_work(struct work_struct *work) | |||
| 1904 | 1904 | ||
| 1905 | 1905 | out: | |
| 1906 | 1906 | spin_lock_irq(gt->irq_lock); | |
| 1907 | - | gen6_gt_pm_unmask_irq(gt, rps->pm_events); | |
| 1907 | + | if (intel_rps_is_active(rps)) | |
| 1908 | + | gen6_gt_pm_unmask_irq(gt, rps->pm_events); | |
| 1908 | 1909 | spin_unlock_irq(gt->irq_lock); | |
| 1909 | 1910 | } | |
| 1910 | 1911 | ||
modified drivers/gpu/drm/mediatek/mtk_drm_drv.c
| @@ -638,8 +638,10 @@ static int mtk_drm_bind(struct device *dev) | |||
| 638 | 638 | private->mtk_drm_bound = true; | |
| 639 | 639 | private->dev = dev; | |
| 640 | 640 | ||
| 641 | - | if (!mtk_drm_get_all_drm_priv(dev)) | |
| 641 | + | if (!mtk_drm_get_all_drm_priv(dev)) { | |
| 642 | + | put_device(private->mutex_dev); | |
| 642 | 643 | return 0; | |
| 644 | + | } | |
| 643 | 645 | ||
| 644 | 646 | drm = drm_dev_alloc(&mtk_drm_driver, dev); | |
| 645 | 647 | if (IS_ERR(drm)) { | |
| @@ -1060,7 +1062,7 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1060 | 1062 | struct mtk_mmsys_driver_data *mtk_drm_data; | |
| 1061 | 1063 | struct device_node *node; | |
| 1062 | 1064 | struct component_match *match = NULL; | |
| 1063 | - | struct platform_device *ovl_adaptor; | |
| 1065 | + | struct platform_device *ovl_adaptor = NULL; | |
| 1064 | 1066 | int ret; | |
| 1065 | 1067 | int i; | |
| 1066 | 1068 | ||
| @@ -1112,6 +1114,9 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1112 | 1114 | PLATFORM_DEVID_AUTO, | |
| 1113 | 1115 | (void *)private->mmsys_dev, | |
| 1114 | 1116 | sizeof(*private->mmsys_dev)); | |
| 1117 | + | if (IS_ERR(ovl_adaptor)) | |
| 1118 | + | return PTR_ERR(ovl_adaptor); | |
| 1119 | + | ||
| 1115 | 1120 | private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev; | |
| 1116 | 1121 | mtk_ddp_comp_init(dev, NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR], | |
| 1117 | 1122 | DDP_COMPONENT_DRM_OVL_ADAPTOR); | |
| @@ -1205,6 +1210,8 @@ static int mtk_drm_probe(struct platform_device *pdev) | |||
| 1205 | 1210 | err_pm: | |
| 1206 | 1211 | pm_runtime_disable(dev); | |
| 1207 | 1212 | err_node: | |
| 1213 | + | if (ovl_adaptor) | |
| 1214 | + | platform_device_unregister(ovl_adaptor); | |
| 1208 | 1215 | of_node_put(private->mutex_node); | |
| 1209 | 1216 | for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) | |
| 1210 | 1217 | of_node_put(private->comp_node[i]); | |
| @@ -1214,9 +1221,15 @@ err_node: | |||
| 1214 | 1221 | static void mtk_drm_remove(struct platform_device *pdev) | |
| 1215 | 1222 | { | |
| 1216 | 1223 | struct mtk_drm_private *private = platform_get_drvdata(pdev); | |
| 1224 | + | struct device *ovl_adaptor_dev; | |
| 1217 | 1225 | int i; | |
| 1218 | 1226 | ||
| 1227 | + | ovl_adaptor_dev = | |
| 1228 | + | private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev; | |
| 1229 | + | ||
| 1219 | 1230 | component_master_del(&pdev->dev, &mtk_drm_ops); | |
| 1231 | + | if (ovl_adaptor_dev) | |
| 1232 | + | platform_device_unregister(to_platform_device(ovl_adaptor_dev)); | |
| 1220 | 1233 | pm_runtime_disable(&pdev->dev); | |
| 1221 | 1234 | of_node_put(private->mutex_node); | |
| 1222 | 1235 | for (i = 0; i < DDP_COMPONENT_DRM_ID_MAX; i++) | |
modified drivers/gpu/drm/mediatek/mtk_hdmi_ddc_v2.c
| @@ -376,8 +376,10 @@ static int mtk_hdmi_ddc_v2_probe(struct platform_device *pdev) | |||
| 376 | 376 | pm_runtime_get_sync(dev); | |
| 377 | 377 | ||
| 378 | 378 | ret = devm_i2c_add_adapter(dev, &ddc->adap); | |
| 379 | - | if (ret < 0) | |
| 379 | + | if (ret < 0) { | |
| 380 | + | pm_runtime_put_noidle(dev); | |
| 380 | 381 | return dev_err_probe(dev, ret, "Cannot add DDC I2C adapter\n"); | |
| 382 | + | } | |
| 381 | 383 | ||
| 382 | 384 | platform_set_drvdata(pdev, ddc); | |
| 383 | 385 | return 0; | |
modified drivers/gpu/drm/mediatek/mtk_hdmi_regs_v2.h
| @@ -173,7 +173,7 @@ | |||
| 173 | 173 | #define TPI_AUDIO_LOOKUP_EN BIT(2) | |
| 174 | 174 | ||
| 175 | 175 | /* Video downsampling configuration */ | |
| 176 | - | #define VID_DOWNSAMPLE_CONFIG 0x8d0 | |
| 176 | + | #define VID_DOWNSAMPLE_CONFIG 0x8f0 | |
| 177 | 177 | #define C444_C422_CONFIG_ENABLE BIT(0) | |
| 178 | 178 | #define C422_C420_CONFIG_ENABLE BIT(4) | |
| 179 | 179 | #define C422_C420_CONFIG_BYPASS BIT(5) | |
modified drivers/gpu/drm/msm/Makefile
| @@ -177,7 +177,6 @@ quiet_cmd_headergen = GENHDR $@ | |||
| 177 | 177 | cmd_headergen = mkdir -p $(obj)/generated && $(PYTHON3) $(src)/registers/gen_header.py \ | |
| 178 | 178 | $(headergen-opts) --rnn $(src)/registers --xml $< c-defines > $@ | |
| 179 | 179 | ||
| 180 | - | # TODO how to do this for a2xx/a5xx which have different .xml arg? | |
| 181 | 180 | quiet_cmd_headergen_json = GENHDRJSN $@ | |
| 182 | 181 | cmd_headergen_json = mkdir -p $(obj)/generated && $(PYTHON3) $(src)/registers/gen_header.py \ | |
| 183 | 182 | $(headergen-opts) --rnn $(src)/registers --xml $(filter %.xml,$^) perfcntrs --json $< > $@ | |
modified drivers/gpu/drm/msm/adreno/a6xx_gmu.c
| @@ -320,7 +320,7 @@ static int a6xx_gmu_start(struct a6xx_gmu *gmu) | |||
| 320 | 320 | gmu_write(gmu, REG_A6XX_GMU_CM3_SYSRESET, 0); | |
| 321 | 321 | ||
| 322 | 322 | ret = gmu_poll_timeout(gmu, REG_A6XX_GMU_CM3_FW_INIT_RESULT, val, | |
| 323 | - | (val & mask) == reset_val, 100, 10000); | |
| 323 | + | (val & mask) == reset_val, 100, 100000); | |
| 324 | 324 | ||
| 325 | 325 | if (ret) | |
| 326 | 326 | DRM_DEV_ERROR(gmu->dev, "GMU firmware initialization timed out\n"); | |
modified drivers/gpu/drm/msm/adreno/a6xx_gpu.c
| @@ -23,9 +23,15 @@ static u64 a6xx_gmu_get_timestamp(struct msm_gpu *gpu) | |||
| 23 | 23 | u64 count_hi, count_lo, temp; | |
| 24 | 24 | ||
| 25 | 25 | do { | |
| 26 | - | count_hi = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H); | |
| 27 | - | count_lo = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L); | |
| 28 | - | temp = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H); | |
| 26 | + | if (adreno_is_a750_family(adreno_gpu)) { | |
| 27 | + | count_hi = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_H); | |
| 28 | + | count_lo = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_L); | |
| 29 | + | temp = gmu_read(&a6xx_gpu->gmu, REG_A7XX_GMU_CX_AO_COUNTER_H); | |
| 30 | + | } else { | |
| 31 | + | count_hi = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H); | |
| 32 | + | count_lo = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L); | |
| 33 | + | temp = gmu_read(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_H); | |
| 34 | + | } | |
| 29 | 35 | } while (unlikely(count_hi != temp)); | |
| 30 | 36 | ||
| 31 | 37 | return (count_hi << 32) | count_lo; | |
modified drivers/gpu/drm/msm/adreno/adreno_device.c
| @@ -25,7 +25,7 @@ MODULE_PARM_DESC(disable_acd, "Forcefully disable GPU ACD"); | |||
| 25 | 25 | module_param_unsafe(disable_acd, bool, 0400); | |
| 26 | 26 | ||
| 27 | 27 | static bool skip_gpu; | |
| 28 | - | MODULE_PARM_DESC(no_gpu, "Disable GPU driver register (0=enable GPU driver register (default), 1=skip GPU driver register"); | |
| 28 | + | MODULE_PARM_DESC(skip_gpu, "Disable GPU driver register (0=enable GPU driver register (default), 1=skip GPU driver register"); | |
| 29 | 29 | module_param(skip_gpu, bool, 0400); | |
| 30 | 30 | ||
| 31 | 31 | extern const struct adreno_gpulist a2xx_gpulist; | |
modified drivers/gpu/drm/msm/adreno/adreno_gpu.c
| @@ -52,6 +52,12 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, | |||
| 52 | 52 | return -ENODEV; | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | + | /* We need PAS to be able to load the firmware */ | |
| 56 | + | if (!qcom_pas_is_available()) { | |
| 57 | + | DRM_DEV_ERROR(dev, "PAS is not available\n"); | |
| 58 | + | return -EPROBE_DEFER; | |
| 59 | + | } | |
| 60 | + | ||
| 55 | 61 | ret = of_reserved_mem_region_to_resource(np, 0, &r); | |
| 56 | 62 | if (ret) { | |
| 57 | 63 | zap_available = false; | |
| @@ -170,18 +176,11 @@ out: | |||
| 170 | 176 | int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid) | |
| 171 | 177 | { | |
| 172 | 178 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); | |
| 173 | - | struct platform_device *pdev = gpu->pdev; | |
| 174 | 179 | ||
| 175 | 180 | /* Short cut if we determine the zap shader isn't available/needed */ | |
| 176 | 181 | if (!zap_available) | |
| 177 | 182 | return -ENODEV; | |
| 178 | 183 | ||
| 179 | - | /* We need PAS to be able to load the firmware */ | |
| 180 | - | if (!qcom_pas_is_available()) { | |
| 181 | - | DRM_DEV_ERROR(&pdev->dev, "PAS is not available\n"); | |
| 182 | - | return -EPROBE_DEFER; | |
| 183 | - | } | |
| 184 | - | ||
| 185 | 184 | return zap_shader_load_mdt(gpu, adreno_gpu->info->zapfw, pasid); | |
| 186 | 185 | } | |
| 187 | 186 | ||
| @@ -1262,6 +1261,8 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu) | |||
| 1262 | 1261 | for (i = 0; i < ARRAY_SIZE(adreno_gpu->info->fw); i++) | |
| 1263 | 1262 | release_firmware(adreno_gpu->fw[i]); | |
| 1264 | 1263 | ||
| 1264 | + | pm_runtime_dont_use_autosuspend(&gpu->pdev->dev); | |
| 1265 | + | ||
| 1265 | 1266 | if (priv && pm_runtime_enabled(&priv->gpu_pdev->dev)) | |
| 1266 | 1267 | pm_runtime_disable(&priv->gpu_pdev->dev); | |
| 1267 | 1268 | ||
modified drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
| @@ -118,6 +118,7 @@ static inline void dpu_hw_ctl_clear_pending_flush(struct dpu_hw_ctl *ctx) | |||
| 118 | 118 | ctx->pending_intf_flush_mask = 0; | |
| 119 | 119 | ctx->pending_wb_flush_mask = 0; | |
| 120 | 120 | ctx->pending_cwb_flush_mask = 0; | |
| 121 | + | ctx->pending_periph_flush_mask = 0; | |
| 121 | 122 | ctx->pending_merge_3d_flush_mask = 0; | |
| 122 | 123 | ctx->pending_dsc_flush_mask = 0; | |
| 123 | 124 | ctx->pending_cdm_flush_mask = 0; | |
modified drivers/gpu/drm/msm/dp/dp_display.c
| @@ -756,6 +756,7 @@ enum drm_mode_status msm_dp_display_mode_valid(struct msm_dp *dp, | |||
| 756 | 756 | struct msm_dp_link_info *link_info; | |
| 757 | 757 | u32 mode_rate_khz = 0, supported_rate_khz = 0, mode_bpp = 0; | |
| 758 | 758 | int mode_pclk_khz = mode->clock; | |
| 759 | + | int link_pclk_khz; | |
| 759 | 760 | bool is_yuv_420; | |
| 760 | 761 | ||
| 761 | 762 | if (!dp || !mode_pclk_khz || !dp->connector) { | |
| @@ -775,6 +776,8 @@ enum drm_mode_status msm_dp_display_mode_valid(struct msm_dp *dp, | |||
| 775 | 776 | if (is_yuv_420 && !msm_dp_display->panel->vsc_sdp_supported) | |
| 776 | 777 | return MODE_NO_420; | |
| 777 | 778 | ||
| 779 | + | link_pclk_khz = is_yuv_420 ? mode_pclk_khz / 2 : mode_pclk_khz; | |
| 780 | + | ||
| 778 | 781 | if (is_yuv_420 || msm_dp_display->wide_bus_supported) | |
| 779 | 782 | mode_pclk_khz /= 2; | |
| 780 | 783 | ||
| @@ -786,9 +789,9 @@ enum drm_mode_status msm_dp_display_mode_valid(struct msm_dp *dp, | |||
| 786 | 789 | mode_bpp = default_bpp; | |
| 787 | 790 | ||
| 788 | 791 | mode_bpp = msm_dp_panel_get_mode_bpp(msm_dp_display->panel, | |
| 789 | - | mode_bpp, mode_pclk_khz); | |
| 792 | + | mode_bpp, link_pclk_khz); | |
| 790 | 793 | ||
| 791 | - | mode_rate_khz = mode_pclk_khz * mode_bpp; | |
| 794 | + | mode_rate_khz = link_pclk_khz * mode_bpp; | |
| 792 | 795 | supported_rate_khz = link_info->num_lanes * link_info->rate * 8; | |
| 793 | 796 | ||
| 794 | 797 | if (mode_rate_khz > supported_rate_khz) | |
| @@ -1458,6 +1461,20 @@ void msm_dp_display_atomic_disable(struct msm_dp *dp) | |||
| 1458 | 1461 | ||
| 1459 | 1462 | msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); | |
| 1460 | 1463 | ||
| 1464 | + | /* | |
| 1465 | + | * If .atomic_enable() bailed out - link training failure is the common | |
| 1466 | + | * case - the mainlink was never brought up and ->power_on stayed false. | |
| 1467 | + | * Driving the PUSH_IDLE pattern into a controller that was never | |
| 1468 | + | * enabled times out, and .atomic_post_disable() then drops the | |
| 1469 | + | * controller's runtime-PM reference without tearing the PHY back down, | |
| 1470 | + | * because msm_dp_display_disable() returns early on !power_on. On | |
| 1471 | + | * glymur (Snapdragon X2 Elite) that combination is answered by a | |
| 1472 | + | * TrustZone-level SOCCP/ADSP force-stop and a silent SoC reset. | |
| 1473 | + | * There is nothing to push idle, so leave it alone. | |
| 1474 | + | */ | |
| 1475 | + | if (!dp->power_on) | |
| 1476 | + | return; | |
| 1477 | + | ||
| 1461 | 1478 | msm_dp_ctrl_push_idle(msm_dp_display->ctrl); | |
| 1462 | 1479 | } | |
| 1463 | 1480 | ||
modified drivers/gpu/drm/msm/dsi/dsi_host.c
| @@ -129,7 +129,7 @@ struct msm_dsi_host { | |||
| 129 | 129 | struct clk *dsi_pll_pixel_clk; | |
| 130 | 130 | ||
| 131 | 131 | unsigned long byte_clk_rate; | |
| 132 | - | unsigned long byte_intf_clk_rate; | |
| 132 | + | bool byte_intf_clk_div_2; | |
| 133 | 133 | unsigned long pixel_clk_rate; | |
| 134 | 134 | unsigned long esc_clk_rate; | |
| 135 | 135 | ||
| @@ -382,8 +382,20 @@ int msm_dsi_runtime_resume(struct device *dev) | |||
| 382 | 382 | ||
| 383 | 383 | int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) | |
| 384 | 384 | { | |
| 385 | + | unsigned long byte_intf_clk_rate; | |
| 386 | + | long rounded_byte_clk_rate; | |
| 385 | 387 | int ret; | |
| 386 | 388 | ||
| 389 | + | rounded_byte_clk_rate = clk_round_rate(msm_host->byte_clk, | |
| 390 | + | msm_host->byte_clk_rate); | |
| 391 | + | if (rounded_byte_clk_rate < 0) { | |
| 392 | + | pr_err("%s: failed to round byte clock rate, %ld\n", | |
| 393 | + | __func__, rounded_byte_clk_rate); | |
| 394 | + | return rounded_byte_clk_rate; | |
| 395 | + | } | |
| 396 | + | ||
| 397 | + | msm_host->byte_clk_rate = rounded_byte_clk_rate; | |
| 398 | + | ||
| 387 | 399 | DBG("Set clk rates: pclk=%lu, byteclk=%lu", | |
| 388 | 400 | msm_host->pixel_clk_rate, msm_host->byte_clk_rate); | |
| 389 | 401 | ||
| @@ -401,7 +413,11 @@ int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host) | |||
| 401 | 413 | } | |
| 402 | 414 | ||
| 403 | 415 | if (msm_host->byte_intf_clk) { | |
| 404 | - | ret = clk_set_rate(msm_host->byte_intf_clk, msm_host->byte_intf_clk_rate); | |
| 416 | + | byte_intf_clk_rate = msm_host->byte_clk_rate; | |
| 417 | + | if (msm_host->byte_intf_clk_div_2) | |
| 418 | + | byte_intf_clk_rate /= 2; | |
| 419 | + | ||
| 420 | + | ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_clk_rate); | |
| 405 | 421 | if (ret) { | |
| 406 | 422 | pr_err("%s: Failed to set rate byte intf clk, %d\n", | |
| 407 | 423 | __func__, ret); | |
| @@ -669,24 +685,12 @@ static void dsi_calc_pclk(struct msm_dsi_host *msm_host, bool is_bonded_dsi) | |||
| 669 | 685 | ||
| 670 | 686 | int dsi_calc_clk_rate_6g(struct msm_dsi_host *msm_host, bool is_bonded_dsi) | |
| 671 | 687 | { | |
| 672 | - | long rounded_byte_clk_rate; | |
| 673 | - | ||
| 674 | 688 | if (!msm_host->mode) { | |
| 675 | 689 | pr_err("%s: mode not set\n", __func__); | |
| 676 | 690 | return -EINVAL; | |
| 677 | 691 | } | |
| 678 | 692 | ||
| 679 | 693 | dsi_calc_pclk(msm_host, is_bonded_dsi); | |
| 680 | - | ||
| 681 | - | rounded_byte_clk_rate = clk_round_rate(msm_host->byte_clk, | |
| 682 | - | msm_host->byte_clk_rate); | |
| 683 | - | if (rounded_byte_clk_rate < 0) { | |
| 684 | - | pr_err("%s: failed to round byte clock rate, %ld\n", | |
| 685 | - | __func__, rounded_byte_clk_rate); | |
| 686 | - | return rounded_byte_clk_rate; | |
| 687 | - | } | |
| 688 | - | ||
| 689 | - | msm_host->byte_clk_rate = rounded_byte_clk_rate; | |
| 690 | 694 | msm_host->esc_clk_rate = clk_get_rate(msm_host->esc_clk); | |
| 691 | 695 | return 0; | |
| 692 | 696 | } | |
| @@ -2495,9 +2499,7 @@ int msm_dsi_host_power_on(struct mipi_dsi_host *host, | |||
| 2495 | 2499 | goto unlock_ret; | |
| 2496 | 2500 | } | |
| 2497 | 2501 | ||
| 2498 | - | msm_host->byte_intf_clk_rate = msm_host->byte_clk_rate; | |
| 2499 | - | if (phy_shared_timings->byte_intf_clk_div_2) | |
| 2500 | - | msm_host->byte_intf_clk_rate /= 2; | |
| 2502 | + | msm_host->byte_intf_clk_div_2 = phy_shared_timings->byte_intf_clk_div_2; | |
| 2501 | 2503 | ||
| 2502 | 2504 | msm_dsi_sfpb_config(msm_host, true); | |
| 2503 | 2505 | ||
modified drivers/gpu/drm/msm/hdmi/hdmi_phy.c
| @@ -168,13 +168,13 @@ static int msm_hdmi_phy_probe(struct platform_device *pdev) | |||
| 168 | 168 | ||
| 169 | 169 | ret = msm_hdmi_phy_resource_enable(phy); | |
| 170 | 170 | if (ret) | |
| 171 | - | return ret; | |
| 171 | + | goto err_pm_disable; | |
| 172 | 172 | ||
| 173 | 173 | ret = msm_hdmi_phy_pll_init(pdev, phy->cfg->type); | |
| 174 | 174 | if (ret) { | |
| 175 | 175 | DRM_DEV_ERROR(dev, "couldn't init PLL\n"); | |
| 176 | 176 | msm_hdmi_phy_resource_disable(phy); | |
| 177 | - | return ret; | |
| 177 | + | goto err_pm_disable; | |
| 178 | 178 | } | |
| 179 | 179 | ||
| 180 | 180 | msm_hdmi_phy_resource_disable(phy); | |
| @@ -182,6 +182,10 @@ static int msm_hdmi_phy_probe(struct platform_device *pdev) | |||
| 182 | 182 | platform_set_drvdata(pdev, phy); | |
| 183 | 183 | ||
| 184 | 184 | return 0; | |
| 185 | + | ||
| 186 | + | err_pm_disable: | |
| 187 | + | pm_runtime_disable(dev); | |
| 188 | + | return ret; | |
| 185 | 189 | } | |
| 186 | 190 | ||
| 187 | 191 | static void msm_hdmi_phy_remove(struct platform_device *pdev) | |
modified drivers/gpu/drm/msm/msm_drv.c
| @@ -55,7 +55,7 @@ MODULE_PARM_DESC(modeset, "Use kernel modesetting [KMS] (1=on (default), 0=disab | |||
| 55 | 55 | module_param(modeset, bool, 0600); | |
| 56 | 56 | ||
| 57 | 57 | static bool separate_gpu_kms; | |
| 58 | - | MODULE_PARM_DESC(separate_gpu_drm, "Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)"); | |
| 58 | + | MODULE_PARM_DESC(separate_gpu_kms, "Use separate DRM device for the GPU (0=single DRM device for both GPU and display (default), 1=two DRM devices)"); | |
| 59 | 59 | module_param(separate_gpu_kms, bool, 0400); | |
| 60 | 60 | ||
| 61 | 61 | DECLARE_FAULT_ATTR(fail_gem_alloc); | |
modified drivers/gpu/drm/msm/msm_fbdev.c
| @@ -155,6 +155,7 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, | |||
| 155 | 155 | helper->fb = buffer->fb; | |
| 156 | 156 | ||
| 157 | 157 | fbi->fbops = &msm_fb_ops; | |
| 158 | + | fbi->flags |= FBINFO_VIRTFB; /* system memory */ | |
| 158 | 159 | ||
| 159 | 160 | drm_fb_helper_fill_info(fbi, helper, sizes); | |
| 160 | 161 | ||
modified drivers/gpu/drm/msm/msm_gem.h
| @@ -68,6 +68,9 @@ struct msm_gem_vm { | |||
| 68 | 68 | /** @base: Inherit from drm_gpuvm. */ | |
| 69 | 69 | struct drm_gpuvm base; | |
| 70 | 70 | ||
| 71 | + | /** @rcu: RCU-delayed free so an exported sched fence->sched stays valid. */ | |
| 72 | + | struct rcu_head rcu; | |
| 73 | + | ||
| 71 | 74 | /** | |
| 72 | 75 | * @sched: Scheduler used for asynchronous VM_BIND request. | |
| 73 | 76 | * | |
modified drivers/gpu/drm/msm/msm_gem_vma.c
| @@ -166,7 +166,7 @@ msm_gem_vm_free(struct drm_gpuvm *gpuvm) | |||
| 166 | 166 | dma_fence_put(vm->last_fence); | |
| 167 | 167 | put_pid(vm->pid); | |
| 168 | 168 | kfree(vm->log); | |
| 169 | - | kfree(vm); | |
| 169 | + | kfree_rcu(vm, rcu); | |
| 170 | 170 | } | |
| 171 | 171 | ||
| 172 | 172 | /** | |
modified drivers/gpu/drm/msm/msm_ringbuffer.c
| @@ -140,5 +140,5 @@ void msm_ringbuffer_destroy(struct msm_ringbuffer *ring) | |||
| 140 | 140 | ||
| 141 | 141 | msm_gem_kernel_put(ring->bo, ring->gpu->vm); | |
| 142 | 142 | ||
| 143 | - | kfree(ring); | |
| 143 | + | kfree_rcu(ring, rcu); | |
| 144 | 144 | } | |
modified drivers/gpu/drm/msm/msm_ringbuffer.h
| @@ -55,6 +55,7 @@ struct msm_ringbuffer { | |||
| 55 | 55 | /* | |
| 56 | 56 | * The job scheduler for this ring. | |
| 57 | 57 | */ | |
| 58 | + | struct rcu_head rcu; | |
| 58 | 59 | struct drm_gpu_scheduler sched; | |
| 59 | 60 | bool sched_initialized; | |
| 60 | 61 | ||
modified drivers/gpu/drm/msm/registers/adreno/a6xx_gmu.xml
| @@ -141,6 +141,8 @@ xsi:schemaLocation="https://gitlab.freedesktop.org/freedreno/ rules-fd.xsd"> | |||
| 141 | 141 | <reg32 offset="0x1f9f0" name="GMU_BOOT_KMD_LM_HANDSHAKE"/> | |
| 142 | 142 | <reg32 offset="0x1f957" name="GMU_LLM_GLM_SLEEP_CTRL"/> | |
| 143 | 143 | <reg32 offset="0x1f958" name="GMU_LLM_GLM_SLEEP_STATUS"/> | |
| 144 | + | <reg32 offset="0x1f880" name="GMU_CX_AO_COUNTER_L" variants="A7XX"/> | |
| 145 | + | <reg32 offset="0x1f881" name="GMU_CX_AO_COUNTER_H" variants="A7XX"/> | |
| 144 | 146 | <reg32 offset="0x1f888" name="GMU_ALWAYS_ON_COUNTER_L" variants="A6XX-A7XX"/> | |
| 145 | 147 | <reg32 offset="0x1f840" name="GMU_ALWAYS_ON_COUNTER_L" variants="A8XX-"/> | |
| 146 | 148 | <reg32 offset="0x1f889" name="GMU_ALWAYS_ON_COUNTER_H" variants="A6XX-A7XX"/> | |
modified drivers/gpu/drm/radeon/radeon_bios.c
| @@ -49,6 +49,7 @@ | |||
| 49 | 49 | static bool igp_read_bios_from_vram(struct radeon_device *rdev) | |
| 50 | 50 | { | |
| 51 | 51 | uint8_t __iomem *bios; | |
| 52 | + | uint8_t val1, val2; | |
| 52 | 53 | resource_size_t vram_base; | |
| 53 | 54 | resource_size_t size = 256 * 1024; /* ??? */ | |
| 54 | 55 | ||
| @@ -63,7 +64,10 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) | |||
| 63 | 64 | return false; | |
| 64 | 65 | } | |
| 65 | 66 | ||
| 66 | - | if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { | |
| 67 | + | val1 = readb(&bios[0]); | |
| 68 | + | val2 = readb(&bios[1]); | |
| 69 | + | ||
| 70 | + | if (size == 0 || val1 != 0x55 || val2 != 0xaa) { | |
| 67 | 71 | iounmap(bios); | |
| 68 | 72 | return false; | |
| 69 | 73 | } | |
modified drivers/gpu/drm/vc4/vc4_hdmi.c
| @@ -894,7 +894,7 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder, | |||
| 894 | 894 | ||
| 895 | 895 | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 896 | 896 | ||
| 897 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE); | |
| 897 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); | |
| 898 | 898 | ||
| 899 | 899 | HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) | VC4_HD_VID_CTL_CLRRGB); | |
| 900 | 900 | ||
| @@ -1663,6 +1663,9 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, | |||
| 1663 | 1663 | WARN_ONCE(ret, "Timeout waiting for " | |
| 1664 | 1664 | "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n"); | |
| 1665 | 1665 | } else { | |
| 1666 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, | |
| 1667 | + | HDMI_READ(HDMI_RAM_PACKET_CONFIG) & | |
| 1668 | + | ~(VC4_HDMI_RAM_PACKET_ENABLE)); | |
| 1666 | 1669 | HDMI_WRITE(HDMI_SCHEDULER_CONTROL, | |
| 1667 | 1670 | HDMI_READ(HDMI_SCHEDULER_CONTROL) & | |
| 1668 | 1671 | ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI); | |
| @@ -1681,6 +1684,9 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder, | |||
| 1681 | 1684 | WARN_ON(!(HDMI_READ(HDMI_SCHEDULER_CONTROL) & | |
| 1682 | 1685 | VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE)); | |
| 1683 | 1686 | ||
| 1687 | + | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, | |
| 1688 | + | VC4_HDMI_RAM_PACKET_ENABLE); | |
| 1689 | + | ||
| 1684 | 1690 | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 1685 | 1691 | vc4_hdmi->packet_ram_enabled = true; | |
| 1686 | 1692 | ||
| @@ -3137,11 +3143,6 @@ static int vc5_hdmi_init_resources(struct drm_device *drm, | |||
| 3137 | 3143 | static int vc4_hdmi_runtime_suspend(struct device *dev) | |
| 3138 | 3144 | { | |
| 3139 | 3145 | struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); | |
| 3140 | - | unsigned long flags; | |
| 3141 | - | ||
| 3142 | - | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 3143 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0); | |
| 3144 | - | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 3145 | 3146 | ||
| 3146 | 3147 | clk_disable_unprepare(vc4_hdmi->audio_clock); | |
| 3147 | 3148 | clk_disable_unprepare(vc4_hdmi->hsm_clock); | |
| @@ -3152,8 +3153,9 @@ static int vc4_hdmi_runtime_suspend(struct device *dev) | |||
| 3152 | 3153 | static int vc4_hdmi_runtime_resume(struct device *dev) | |
| 3153 | 3154 | { | |
| 3154 | 3155 | struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev); | |
| 3155 | - | unsigned long rate, flags; | |
| 3156 | + | unsigned long __maybe_unused flags; | |
| 3156 | 3157 | u32 __maybe_unused value; | |
| 3158 | + | unsigned long rate; | |
| 3157 | 3159 | int ret; | |
| 3158 | 3160 | ||
| 3159 | 3161 | ret = clk_prepare_enable(vc4_hdmi->hsm_clock); | |
| @@ -3199,10 +3201,6 @@ static int vc4_hdmi_runtime_resume(struct device *dev) | |||
| 3199 | 3201 | } | |
| 3200 | 3202 | #endif | |
| 3201 | 3203 | ||
| 3202 | - | spin_lock_irqsave(&vc4_hdmi->hw_lock, flags); | |
| 3203 | - | HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE); | |
| 3204 | - | spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags); | |
| 3205 | - | ||
| 3206 | 3204 | return 0; | |
| 3207 | 3205 | ||
| 3208 | 3206 | err_disable_clk: | |
modified drivers/gpu/drm/virtio/virtgpu_plane.c
| @@ -589,6 +589,7 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev, | |||
| 589 | 589 | struct drm_plane *plane; | |
| 590 | 590 | const uint32_t *formats; | |
| 591 | 591 | int nformats; | |
| 592 | + | int ret; | |
| 592 | 593 | ||
| 593 | 594 | if (type == DRM_PLANE_TYPE_CURSOR) { | |
| 594 | 595 | formats = virtio_gpu_cursor_formats; | |
| @@ -614,5 +615,17 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev, | |||
| 614 | 615 | drm_plane_create_blend_mode_property(plane, | |
| 615 | 616 | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 616 | 617 | ||
| 618 | + | if (type == DRM_PLANE_TYPE_CURSOR) { | |
| 619 | + | /* | |
| 620 | + | * The cursor plane exposes a format with an alpha channel, | |
| 621 | + | * which requires a blend mode property. The host blends | |
| 622 | + | * premultiplied alpha, matching the property's default. | |
| 623 | + | */ | |
| 624 | + | ret = drm_plane_create_blend_mode_property(plane, | |
| 625 | + | BIT(DRM_MODE_BLEND_PREMULTI)); | |
| 626 | + | if (ret) | |
| 627 | + | return ERR_PTR(ret); | |
| 628 | + | } | |
| 629 | + | ||
| 617 | 630 | return plane; | |
| 618 | 631 | } | |
modified drivers/gpu/drm/xe/display/xe_fb_pin.c
| @@ -356,7 +356,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt, | |||
| 356 | 356 | drm_exec_retry_on_contention(&exec); | |
| 357 | 357 | xe_validation_retry_on_oom(&ctx, &ret); | |
| 358 | 358 | if (!ret) | |
| 359 | - | ttm_bo_pin(&bo->ttm); | |
| 359 | + | xe_bo_pin_account(bo); | |
| 360 | 360 | } | |
| 361 | 361 | if (ret) | |
| 362 | 362 | goto err; | |
| @@ -373,7 +373,7 @@ static struct i915_vma *__xe_pin_fb_vma(struct drm_gem_object *obj, bool is_dpt, | |||
| 373 | 373 | ||
| 374 | 374 | err_unpin: | |
| 375 | 375 | ttm_bo_reserve(&bo->ttm, false, false, NULL); | |
| 376 | - | ttm_bo_unpin(&bo->ttm); | |
| 376 | + | xe_bo_unpin_account(bo); | |
| 377 | 377 | ttm_bo_unreserve(&bo->ttm); | |
| 378 | 378 | err: | |
| 379 | 379 | kfree(vma); | |
| @@ -393,7 +393,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma) | |||
| 393 | 393 | xe_ggtt_node_remove(vma->node, false); | |
| 394 | 394 | ||
| 395 | 395 | ttm_bo_reserve(&vma->bo->ttm, false, false, NULL); | |
| 396 | - | ttm_bo_unpin(&vma->bo->ttm); | |
| 396 | + | xe_bo_unpin_account(vma->bo); | |
| 397 | 397 | ttm_bo_unreserve(&vma->bo->ttm); | |
| 398 | 398 | kfree(vma); | |
| 399 | 399 | } | |
modified drivers/gpu/drm/xe/regs/xe_gt_regs.h
| @@ -651,6 +651,7 @@ | |||
| 651 | 651 | #define MEM_THERMAL_MASK REG_BIT(2) | |
| 652 | 652 | #define VR_THERMAL_MASK REG_BIT(3) | |
| 653 | 653 | #define ICCMAX_MASK REG_BIT(4) | |
| 654 | + | #define PWRBRK_MASK REG_BIT(5) | |
| 654 | 655 | #define SOC_AVG_THERMAL_MASK REG_BIT(6) | |
| 655 | 656 | #define FASTVMODE_MASK REG_BIT(7) | |
| 656 | 657 | #define PSYS_PL1_MASK REG_BIT(12) | |
modified drivers/gpu/drm/xe/xe_bo.c
| @@ -455,6 +455,100 @@ static void xe_ttm_tt_account_subtract(struct xe_device *xe, struct ttm_tt *tt) | |||
| 455 | 455 | xe_shrinker_mod_pages(xe->mem.shrinker, -(long)tt->num_pages, 0); | |
| 456 | 456 | } | |
| 457 | 457 | ||
| 458 | + | static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo) | |
| 459 | + | { | |
| 460 | + | dma_resv_assert_held(tbo->base.resv); | |
| 461 | + | ||
| 462 | + | return tbo->ttm && | |
| 463 | + | (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) == | |
| 464 | + | TTM_TT_FLAG_EXTERNAL; | |
| 465 | + | } | |
| 466 | + | ||
| 467 | + | /* | |
| 468 | + | * Account @bo's pages as pinned for the shrinker. Removes @bo's pages | |
| 469 | + | * from the shrinker's shrinkable / purgeable counts on the transition | |
| 470 | + | * from unpinned to pinned. Must be called with @bo's dma-resv held, | |
| 471 | + | * after &ttm_buffer_object.pin_count has been incremented by | |
| 472 | + | * ttm_bo_pin(). Safe to call unconditionally regardless of which pin | |
| 473 | + | * path (kernel, external, framebuffer, backup object, ...) is pinning | |
| 474 | + | * @bo, since it only acts on the true 0->1 pin_count transition. | |
| 475 | + | * | |
| 476 | + | * Imported bos (xe_ttm_bo_is_imported()) are excluded: for those, | |
| 477 | + | * xe_ttm_tt_populate() never actually populates the tt or calls | |
| 478 | + | * xe_ttm_tt_account_add(), but TTM core's ttm_tt_populate() still | |
| 479 | + | * unconditionally marks the tt as populated on driver-hook success. | |
| 480 | + | * Relying on ttm_tt_is_populated() for these would subtract pages that | |
| 481 | + | * were never added, underflowing the shrinker's counts. | |
| 482 | + | */ | |
| 483 | + | static void xe_bo_account_pin(struct xe_bo *bo) | |
| 484 | + | { | |
| 485 | + | struct xe_device *xe = xe_bo_device(bo); | |
| 486 | + | ||
| 487 | + | if (bo->ttm.pin_count == 1 && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) && | |
| 488 | + | !xe_ttm_bo_is_imported(&bo->ttm)) | |
| 489 | + | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 490 | + | } | |
| 491 | + | ||
| 492 | + | /* | |
| 493 | + | * Counterpart to xe_bo_account_pin(). Must be called with @bo's dma-resv | |
| 494 | + | * held, before &ttm_buffer_object.pin_count is decremented by | |
| 495 | + | * ttm_bo_unpin(), so that the check against the true 1->0 transition sees | |
| 496 | + | * the pin count that is about to be released. See xe_bo_account_pin() for | |
| 497 | + | * why imported bos are excluded. | |
| 498 | + | * | |
| 499 | + | * On the true last unpin, also removes @bo from whichever pinned-bo list | |
| 500 | + | * (external or kernel_bo_present) it may currently be linked on, since a | |
| 501 | + | * bo's final unpin can happen through a pin path (e.g. framebuffer, | |
| 502 | + | * backup object) that has no notion of, or ownership over, that list. | |
| 503 | + | * This is safe and list-agnostic: list_del_init() only needs the node | |
| 504 | + | * itself, not knowledge of which list it is threaded through, and is a | |
| 505 | + | * no-op if @bo is not linked. | |
| 506 | + | */ | |
| 507 | + | static void xe_bo_account_unpin(struct xe_bo *bo) | |
| 508 | + | { | |
| 509 | + | struct xe_device *xe = xe_bo_device(bo); | |
| 510 | + | bool last_unpin = bo->ttm.pin_count == 1; | |
| 511 | + | ||
| 512 | + | if (last_unpin && !list_empty(&bo->pinned_link)) { | |
| 513 | + | spin_lock(&xe->pinned.lock); | |
| 514 | + | list_del_init(&bo->pinned_link); | |
| 515 | + | spin_unlock(&xe->pinned.lock); | |
| 516 | + | } | |
| 517 | + | ||
| 518 | + | if (last_unpin && bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm) && | |
| 519 | + | !xe_ttm_bo_is_imported(&bo->ttm)) | |
| 520 | + | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 521 | + | } | |
| 522 | + | ||
| 523 | + | /** | |
| 524 | + | * xe_bo_pin_account() - Pin a bo and account its pages for the shrinker | |
| 525 | + | * @bo: The buffer object to pin. | |
| 526 | + | * | |
| 527 | + | * Pins @bo via ttm_bo_pin() and updates the shrinker's shrinkable / | |
| 528 | + | * purgeable page accounting to match. Must be called with @bo's dma-resv | |
| 529 | + | * held. Safe to call regardless of which pin path (kernel, external, | |
| 530 | + | * framebuffer, backup object, ...) is pinning @bo. | |
| 531 | + | */ | |
| 532 | + | void xe_bo_pin_account(struct xe_bo *bo) | |
| 533 | + | { | |
| 534 | + | ttm_bo_pin(&bo->ttm); | |
| 535 | + | xe_bo_account_pin(bo); | |
| 536 | + | } | |
| 537 | + | ||
| 538 | + | /** | |
| 539 | + | * xe_bo_unpin_account() - Unpin a bo and account its pages for the shrinker | |
| 540 | + | * @bo: The buffer object to unpin. | |
| 541 | + | * | |
| 542 | + | * Counterpart to xe_bo_pin_account(). Updates the shrinker's shrinkable / | |
| 543 | + | * purgeable page accounting to match, then unpins @bo via ttm_bo_unpin(). | |
| 544 | + | * Must be called with @bo's dma-resv held. | |
| 545 | + | */ | |
| 546 | + | void xe_bo_unpin_account(struct xe_bo *bo) | |
| 547 | + | { | |
| 548 | + | xe_bo_account_unpin(bo); | |
| 549 | + | ttm_bo_unpin(&bo->ttm); | |
| 550 | + | } | |
| 551 | + | ||
| 458 | 552 | static void update_global_total_pages(struct ttm_device *ttm_dev, | |
| 459 | 553 | long num_pages) | |
| 460 | 554 | { | |
| @@ -1037,6 +1131,13 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, | |||
| 1037 | 1131 | } else { | |
| 1038 | 1132 | drm_dbg(&xe->drm, "Evict system allocator BO failed=%pe\n", | |
| 1039 | 1133 | ERR_PTR(ret)); | |
| 1134 | + | /* | |
| 1135 | + | * The semantic we want upon SVM eviction failure | |
| 1136 | + | * because of racing access is keep walking for | |
| 1137 | + | * eviction, which is -ENOSPC. | |
| 1138 | + | */ | |
| 1139 | + | if (ret == -EBUSY) | |
| 1140 | + | ret = -ENOSPC; | |
| 1040 | 1141 | } | |
| 1041 | 1142 | ||
| 1042 | 1143 | goto out; | |
| @@ -1382,7 +1483,8 @@ int xe_bo_notifier_prepare_pinned(struct xe_bo *bo) | |||
| 1382 | 1483 | } | |
| 1383 | 1484 | ||
| 1384 | 1485 | backup->parent_obj = xe_bo_get(bo); /* Released by bo_destroy */ | |
| 1385 | - | ttm_bo_pin(&backup->ttm); | |
| 1486 | + | /* Note: XE_BO_FLAG_SYSTEM resolves to XE_PL_TT so already populated. */ | |
| 1487 | + | xe_bo_pin_account(backup); | |
| 1386 | 1488 | bo->backup_obj = backup; | |
| 1387 | 1489 | } | |
| 1388 | 1490 | ||
| @@ -1402,7 +1504,7 @@ int xe_bo_notifier_unprepare_pinned(struct xe_bo *bo) | |||
| 1402 | 1504 | { | |
| 1403 | 1505 | xe_bo_lock(bo, false); | |
| 1404 | 1506 | if (bo->backup_obj) { | |
| 1405 | - | ttm_bo_unpin(&bo->backup_obj->ttm); | |
| 1507 | + | xe_bo_unpin_account(bo->backup_obj); | |
| 1406 | 1508 | xe_bo_put(bo->backup_obj); | |
| 1407 | 1509 | bo->backup_obj = NULL; | |
| 1408 | 1510 | } | |
| @@ -1613,7 +1715,7 @@ out_backup: | |||
| 1613 | 1715 | xe_bo_vunmap(backup); | |
| 1614 | 1716 | if (!bo->backup_obj) { | |
| 1615 | 1717 | if (xe_bo_is_pinned(backup)) | |
| 1616 | - | ttm_bo_unpin(&backup->ttm); | |
| 1718 | + | xe_bo_unpin_account(backup); | |
| 1617 | 1719 | xe_bo_put(backup); | |
| 1618 | 1720 | } | |
| 1619 | 1721 | out_unlock_bo: | |
| @@ -2005,15 +2107,6 @@ static vm_fault_t xe_err_to_fault_t(int err) | |||
| 2005 | 2107 | return VM_FAULT_SIGBUS; | |
| 2006 | 2108 | } | |
| 2007 | 2109 | ||
| 2008 | - | static bool xe_ttm_bo_is_imported(struct ttm_buffer_object *tbo) | |
| 2009 | - | { | |
| 2010 | - | dma_resv_assert_held(tbo->base.resv); | |
| 2011 | - | ||
| 2012 | - | return tbo->ttm && | |
| 2013 | - | (tbo->ttm->page_flags & (TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE)) == | |
| 2014 | - | TTM_TT_FLAG_EXTERNAL; | |
| 2015 | - | } | |
| 2016 | - | ||
| 2017 | 2110 | static vm_fault_t xe_bo_cpu_fault_fastpath(struct vm_fault *vmf, struct xe_device *xe, | |
| 2018 | 2111 | struct xe_bo *bo, bool needs_rpm) | |
| 2019 | 2112 | { | |
| @@ -3134,12 +3227,13 @@ uint64_t vram_region_gpu_offset(struct ttm_resource *res) | |||
| 3134 | 3227 | int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec) | |
| 3135 | 3228 | { | |
| 3136 | 3229 | struct xe_device *xe = xe_bo_device(bo); | |
| 3230 | + | bool first_pin = !xe_bo_is_pinned(bo); | |
| 3137 | 3231 | int err; | |
| 3138 | 3232 | ||
| 3139 | 3233 | xe_assert(xe, !bo->vm); | |
| 3140 | 3234 | xe_assert(xe, xe_bo_is_user(bo)); | |
| 3141 | 3235 | ||
| 3142 | - | if (!xe_bo_is_pinned(bo)) { | |
| 3236 | + | if (first_pin) { | |
| 3143 | 3237 | if (!in_place) { | |
| 3144 | 3238 | err = xe_bo_validate(bo, NULL, false, exec); | |
| 3145 | 3239 | if (err) | |
| @@ -3151,9 +3245,7 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec) | |||
| 3151 | 3245 | spin_unlock(&xe->pinned.lock); | |
| 3152 | 3246 | } | |
| 3153 | 3247 | ||
| 3154 | - | ttm_bo_pin(&bo->ttm); | |
| 3155 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3156 | - | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 3248 | + | xe_bo_pin_account(bo); | |
| 3157 | 3249 | ||
| 3158 | 3250 | /* | |
| 3159 | 3251 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3209,9 +3301,7 @@ int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec) | |||
| 3209 | 3301 | spin_unlock(&xe->pinned.lock); | |
| 3210 | 3302 | } | |
| 3211 | 3303 | ||
| 3212 | - | ttm_bo_pin(&bo->ttm); | |
| 3213 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3214 | - | xe_ttm_tt_account_subtract(xe, bo->ttm.ttm); | |
| 3304 | + | xe_bo_pin_account(bo); | |
| 3215 | 3305 | ||
| 3216 | 3306 | /* | |
| 3217 | 3307 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3240,14 +3330,7 @@ void xe_bo_unpin_external(struct xe_bo *bo) | |||
| 3240 | 3330 | xe_assert(xe, xe_bo_is_pinned(bo)); | |
| 3241 | 3331 | xe_assert(xe, xe_bo_is_user(bo)); | |
| 3242 | 3332 | ||
| 3243 | - | spin_lock(&xe->pinned.lock); | |
| 3244 | - | if (bo->ttm.pin_count == 1 && !list_empty(&bo->pinned_link)) | |
| 3245 | - | list_del_init(&bo->pinned_link); | |
| 3246 | - | spin_unlock(&xe->pinned.lock); | |
| 3247 | - | ||
| 3248 | - | ttm_bo_unpin(&bo->ttm); | |
| 3249 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3250 | - | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 3333 | + | xe_bo_unpin_account(bo); | |
| 3251 | 3334 | ||
| 3252 | 3335 | /* | |
| 3253 | 3336 | * FIXME: If we always use the reserve / unreserve functions for locking | |
| @@ -3265,21 +3348,16 @@ void xe_bo_unpin(struct xe_bo *bo) | |||
| 3265 | 3348 | xe_assert(xe, xe_bo_is_pinned(bo)); | |
| 3266 | 3349 | ||
| 3267 | 3350 | if (mem_type_is_vram(place->mem_type) || bo->flags & XE_BO_FLAG_GGTT) { | |
| 3268 | - | spin_lock(&xe->pinned.lock); | |
| 3269 | 3351 | xe_assert(xe, !list_empty(&bo->pinned_link)); | |
| 3270 | - | list_del_init(&bo->pinned_link); | |
| 3271 | - | spin_unlock(&xe->pinned.lock); | |
| 3272 | 3352 | ||
| 3273 | 3353 | if (bo->backup_obj) { | |
| 3274 | 3354 | if (xe_bo_is_pinned(bo->backup_obj)) | |
| 3275 | - | ttm_bo_unpin(&bo->backup_obj->ttm); | |
| 3355 | + | xe_bo_unpin_account(bo->backup_obj); | |
| 3276 | 3356 | xe_bo_put(bo->backup_obj); | |
| 3277 | 3357 | bo->backup_obj = NULL; | |
| 3278 | 3358 | } | |
| 3279 | 3359 | } | |
| 3280 | - | ttm_bo_unpin(&bo->ttm); | |
| 3281 | - | if (bo->ttm.ttm && ttm_tt_is_populated(bo->ttm.ttm)) | |
| 3282 | - | xe_ttm_tt_account_add(xe, bo->ttm.ttm); | |
| 3360 | + | xe_bo_unpin_account(bo); | |
| 3283 | 3361 | } | |
| 3284 | 3362 | ||
| 3285 | 3363 | /** | |
modified drivers/gpu/drm/xe/xe_bo.h
| @@ -9,6 +9,8 @@ | |||
| 9 | 9 | #include <drm/drm_prime.h> | |
| 10 | 10 | #include <drm/ttm/ttm_tt.h> | |
| 11 | 11 | ||
| 12 | + | #include <xen/xen.h> | |
| 13 | + | ||
| 12 | 14 | #include "xe_bo_types.h" | |
| 13 | 15 | #include "xe_ggtt.h" | |
| 14 | 16 | #include "xe_macros.h" | |
| @@ -227,6 +229,8 @@ int xe_bo_pin_external(struct xe_bo *bo, bool in_place, struct drm_exec *exec); | |||
| 227 | 229 | int xe_bo_pin(struct xe_bo *bo, struct drm_exec *exec); | |
| 228 | 230 | void xe_bo_unpin_external(struct xe_bo *bo); | |
| 229 | 231 | void xe_bo_unpin(struct xe_bo *bo); | |
| 232 | + | void xe_bo_pin_account(struct xe_bo *bo); | |
| 233 | + | void xe_bo_unpin_account(struct xe_bo *bo); | |
| 230 | 234 | int xe_bo_validate(struct xe_bo *bo, struct xe_vm *vm, bool allow_res_evict, | |
| 231 | 235 | struct drm_exec *exec); | |
| 232 | 236 | ||
| @@ -575,6 +579,23 @@ static inline unsigned int xe_sg_segment_size(struct device *dev) | |||
| 575 | 579 | struct scatterlist __maybe_unused sg; | |
| 576 | 580 | size_t max = BIT_ULL(sizeof(sg.length) * 8) - 1; | |
| 577 | 581 | ||
| 582 | + | /* | |
| 583 | + | * For Xen PV guests pages aren't contiguous in DMA (machine) address | |
| 584 | + | * space. The DMA API takes care of that both in dma_alloc_* (by | |
| 585 | + | * calling into the hypervisor to make the pages contiguous) and in | |
| 586 | + | * dma_map_* (by bounce buffering). But xe (like i915, see commit | |
| 587 | + | * 78a07fe777c4) ignores the coherency aspects of the DMA API and thus | |
| 588 | + | * can't cope with bounce buffering actually happening, so add a hack | |
| 589 | + | * here to force small allocations and mappings when running in PV | |
| 590 | + | * mode on Xen. | |
| 591 | + | * | |
| 592 | + | * Note this will still break if bounce buffering is required for other | |
| 593 | + | * reasons, like confidential computing hypervisors or PCIe root ports | |
| 594 | + | * with addressing limitations. | |
| 595 | + | */ | |
| 596 | + | if (xen_pv_domain()) | |
| 597 | + | return PAGE_SIZE; | |
| 598 | + | ||
| 578 | 599 | max = min_t(size_t, max, dma_max_mapping_size(dev)); | |
| 579 | 600 | ||
| 580 | 601 | /* | |
modified drivers/gpu/drm/xe/xe_gt_throttle.c
| @@ -39,7 +39,7 @@ | |||
| 39 | 39 | * - ``reason_mem_thermal``: Memory thermal | |
| 40 | 40 | * - ``reason_vr_thermal``: VR thermal | |
| 41 | 41 | * - ``reason_iccmax``: ICCMAX | |
| 42 | - | * - ``reason_ratl``: RATL thermal algorithm | |
| 42 | + | * - ``reason_pwrbrk``: Power brake | |
| 43 | 43 | * - ``reason_soc_avg_thermal``: SoC average temp | |
| 44 | 44 | * - ``reason_fastvmode``: VR is hitting FastVMode | |
| 45 | 45 | * - ``reason_psys_pl1``: PSYS PL1 | |
| @@ -200,6 +200,7 @@ static THROTTLE_ATTR_RO(reason_psys_pl1, PSYS_PL1_MASK); | |||
| 200 | 200 | static THROTTLE_ATTR_RO(reason_psys_pl2, PSYS_PL2_MASK); | |
| 201 | 201 | static THROTTLE_ATTR_RO(reason_p0_freq, P0_FREQ_MASK); | |
| 202 | 202 | static THROTTLE_ATTR_RO(reason_psys_crit, PSYS_CRIT_MASK); | |
| 203 | + | static THROTTLE_ATTR_RO(reason_pwrbrk, PWRBRK_MASK); | |
| 203 | 204 | ||
| 204 | 205 | static struct attribute *cri_throttle_attrs[] = { | |
| 205 | 206 | /* Common */ | |
| @@ -209,12 +210,12 @@ static struct attribute *cri_throttle_attrs[] = { | |||
| 209 | 210 | &attr_reason_pl2.attr.attr, | |
| 210 | 211 | &attr_reason_pl4.attr.attr, | |
| 211 | 212 | &attr_reason_prochot.attr.attr, | |
| 212 | - | &attr_reason_ratl.attr.attr, | |
| 213 | 213 | /* CRI */ | |
| 214 | 214 | &attr_reason_vr_thermal.attr.attr, | |
| 215 | 215 | &attr_reason_soc_thermal.attr.attr, | |
| 216 | 216 | &attr_reason_mem_thermal.attr.attr, | |
| 217 | 217 | &attr_reason_iccmax.attr.attr, | |
| 218 | + | &attr_reason_pwrbrk.attr.attr, | |
| 218 | 219 | &attr_reason_soc_avg_thermal.attr.attr, | |
| 219 | 220 | &attr_reason_fastvmode.attr.attr, | |
| 220 | 221 | &attr_reason_psys_pl1.attr.attr, | |
modified drivers/gpu/drm/xe/xe_guc_ads.c
| @@ -864,7 +864,7 @@ static unsigned int guc_mmio_regset_write(struct xe_guc_ads *ads, | |||
| 864 | 864 | } | |
| 865 | 865 | } | |
| 866 | 866 | ||
| 867 | - | if (XE_GT_WA(hwe->gt, 16023105232)) | |
| 867 | + | if (XE_GT_WA(hwe->gt, 16023105232) || XE_GT_WA(hwe->gt, 14025941587)) | |
| 868 | 868 | guc_mmio_regset_write_one(ads, regset_map, | |
| 869 | 869 | RING_IDLEDLY(hwe->mmio_base), | |
| 870 | 870 | count++); | |
modified drivers/gpu/drm/xe/xe_hw_engine.c
| @@ -585,28 +585,102 @@ static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe, | |||
| 585 | 585 | xe_reg_whitelist_process_engine(hwe); | |
| 586 | 586 | } | |
| 587 | 587 | ||
| 588 | + | static u32 idledly_floor_ticks(u32 idledly_ns, u32 idledly_units_ps) | |
| 589 | + | { | |
| 590 | + | return DIV_ROUND_DOWN_ULL((u64)idledly_ns * 1000, idledly_units_ps); | |
| 591 | + | } | |
| 592 | + | ||
| 588 | 593 | static void adjust_idledly(struct xe_hw_engine *hwe) | |
| 589 | 594 | { | |
| 590 | 595 | struct xe_gt *gt = hwe->gt; | |
| 591 | - | u32 idledly, maxcnt; | |
| 596 | + | u32 idledly, idledly_hw, idledly_reg_val, maxcnt; | |
| 592 | 597 | u32 idledly_units_ps = 8 * gt->info.timestamp_base; | |
| 593 | 598 | u32 maxcnt_units_ns = 640; | |
| 594 | - | bool inhibit_switch = 0; | |
| 599 | + | bool inhibit_switch = false; | |
| 600 | + | bool wa_applied = false; | |
| 601 | + | bool clamped_below_maxcnt = false; | |
| 602 | + | ||
| 603 | + | if ((!IS_SRIOV_VF(gt_to_xe(gt)) && XE_GT_WA(gt, 16023105232)) || | |
| 604 | + | XE_GT_WA(gt, 14025941587)) { | |
| 605 | + | u32 mincnt_idledly_ns = 5000; | |
| 606 | + | ||
| 607 | + | /* xe_gt_clock_init() warns and zeroes timestamp_base on unknown crystal clock. */ | |
| 608 | + | if (!idledly_units_ps) | |
| 609 | + | return; | |
| 595 | 610 | ||
| 596 | - | if (!IS_SRIOV_VF(gt_to_xe(hwe->gt)) && XE_GT_WA(gt, 16023105232)) { | |
| 597 | - | idledly = xe_mmio_read32(>->mmio, RING_IDLEDLY(hwe->mmio_base)); | |
| 611 | + | idledly_reg_val = xe_mmio_read32(>->mmio, RING_IDLEDLY(hwe->mmio_base)); | |
| 598 | 612 | maxcnt = xe_mmio_read32(>->mmio, RING_PWRCTX_MAXCNT(hwe->mmio_base)); | |
| 599 | 613 | ||
| 600 | - | inhibit_switch = idledly & INHIBIT_SWITCH_UNTIL_PREEMPTED; | |
| 601 | - | idledly = REG_FIELD_GET(IDLE_DELAY, idledly); | |
| 602 | - | idledly = DIV_ROUND_CLOSEST(idledly * idledly_units_ps, 1000); | |
| 614 | + | inhibit_switch = idledly_reg_val & INHIBIT_SWITCH_UNTIL_PREEMPTED; | |
| 615 | + | idledly = REG_FIELD_GET(IDLE_DELAY, idledly_reg_val); | |
| 616 | + | idledly = DIV_ROUND_CLOSEST_ULL((u64)idledly * idledly_units_ps, 1000); | |
| 617 | + | idledly_hw = idledly; | |
| 603 | 618 | maxcnt = REG_FIELD_GET(IDLE_WAIT_TIME, maxcnt); | |
| 604 | 619 | maxcnt *= maxcnt_units_ns; | |
| 605 | 620 | ||
| 606 | - | if (xe_gt_WARN_ON(gt, idledly >= maxcnt || inhibit_switch)) { | |
| 607 | - | idledly = DIV_ROUND_CLOSEST(((maxcnt - 1) * 1000), | |
| 608 | - | idledly_units_ps); | |
| 609 | - | xe_mmio_write32(>->mmio, RING_IDLEDLY(hwe->mmio_base), idledly); | |
| 621 | + | /* | |
| 622 | + | * Wa_14025941587 is applied before Wa_16023105232, which takes | |
| 623 | + | * priority if the two ever conflict (not expected in practice). | |
| 624 | + | */ | |
| 625 | + | if (XE_GT_WA(gt, 14025941587) && | |
| 626 | + | idledly < mincnt_idledly_ns) { | |
| 627 | + | idledly = mincnt_idledly_ns; | |
| 628 | + | wa_applied = true; | |
| 629 | + | } | |
| 630 | + | ||
| 631 | + | if (XE_GT_WA(gt, 16023105232)) { | |
| 632 | + | /* Clear the inhibit switch without disturbing a valid delay. */ | |
| 633 | + | if (inhibit_switch) { | |
| 634 | + | idledly_reg_val &= ~INHIBIT_SWITCH_UNTIL_PREEMPTED; | |
| 635 | + | wa_applied = true; | |
| 636 | + | } | |
| 637 | + | ||
| 638 | + | /* Warn only on the value read from hardware. */ | |
| 639 | + | xe_gt_WARN_ON(gt, idledly_hw >= maxcnt); | |
| 640 | + | ||
| 641 | + | if (idledly >= maxcnt) { | |
| 642 | + | /* maxcnt may be 0 if IDLE_WAIT_TIME is unprogrammed. */ | |
| 643 | + | idledly = maxcnt ? maxcnt - 1 : 0; | |
| 644 | + | clamped_below_maxcnt = true; | |
| 645 | + | wa_applied = true; | |
| 646 | + | } | |
| 647 | + | } | |
| 648 | + | ||
| 649 | + | if (wa_applied) { | |
| 650 | + | u32 idledly_ticks; | |
| 651 | + | ||
| 652 | + | /* | |
| 653 | + | * Wa_16023105232 requires idledly < maxcnt, so floor | |
| 654 | + | * that clamp; otherwise round up to guarantee the | |
| 655 | + | * Wa_14025941587 minimum survives tick quantization. | |
| 656 | + | */ | |
| 657 | + | if (clamped_below_maxcnt) | |
| 658 | + | idledly_ticks = idledly_floor_ticks(idledly, idledly_units_ps); | |
| 659 | + | else | |
| 660 | + | idledly_ticks = DIV_ROUND_UP_ULL((u64)idledly * 1000, | |
| 661 | + | idledly_units_ps); | |
| 662 | + | ||
| 663 | + | /* | |
| 664 | + | * Tick quantization can still push the rounded-up value | |
| 665 | + | * to/above maxcnt; re-floor here so Wa_16023105232 keeps | |
| 666 | + | * priority even in that case. | |
| 667 | + | */ | |
| 668 | + | if (!clamped_below_maxcnt && XE_GT_WA(gt, 16023105232) && | |
| 669 | + | (u64)idledly_ticks * idledly_units_ps >= (u64)maxcnt * 1000) { | |
| 670 | + | xe_gt_dbg(gt, "idledly %s: %u ticks would exceed maxcnt=%u, so flooring\n", | |
| 671 | + | hwe->name, idledly_ticks, maxcnt); | |
| 672 | + | idledly = maxcnt ? maxcnt - 1 : 0; | |
| 673 | + | idledly_ticks = idledly_floor_ticks(idledly, idledly_units_ps); | |
| 674 | + | } | |
| 675 | + | ||
| 676 | + | idledly_reg_val &= ~IDLE_DELAY; | |
| 677 | + | idledly_reg_val |= REG_FIELD_PREP(IDLE_DELAY, idledly_ticks); | |
| 678 | + | xe_gt_dbg(gt, "idledly %s: set %u max=%u inh=%u ts=%u\n", | |
| 679 | + | hwe->name, idledly, maxcnt, | |
| 680 | + | !!inhibit_switch, gt->info.timestamp_base); | |
| 681 | + | xe_mmio_write32(>->mmio, | |
| 682 | + | RING_IDLEDLY(hwe->mmio_base), | |
| 683 | + | idledly_reg_val); | |
| 610 | 684 | } | |
| 611 | 685 | } | |
| 612 | 686 | } | |
modified drivers/gpu/drm/xe/xe_i2c.c
| @@ -318,17 +318,23 @@ void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) | |||
| 318 | 318 | static void xe_i2c_remove(void *data) | |
| 319 | 319 | { | |
| 320 | 320 | struct xe_i2c *i2c = data; | |
| 321 | + | struct xe_device *xe = tile_to_xe(i2c->mmio->tile); | |
| 321 | 322 | unsigned int i; | |
| 322 | 323 | ||
| 324 | + | xe_i2c_irq_reset(xe); | |
| 323 | 325 | xe_amc_exit(i2c); | |
| 324 | 326 | ||
| 327 | + | /* Stop the notifier from arming the client work before teardown. */ | |
| 328 | + | bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); | |
| 329 | + | cancel_work_sync(&i2c->work); | |
| 330 | + | ||
| 325 | 331 | for (i = 0; i < XE_I2C_MAX_CLIENTS; i++) { | |
| 326 | 332 | i2c_unregister_device(i2c->client[i]); | |
| 327 | 333 | i2c->client[i] = NULL; | |
| 328 | 334 | } | |
| 329 | 335 | ||
| 330 | - | bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); | |
| 331 | 336 | xe_i2c_unregister_adapter(i2c); | |
| 337 | + | xe->i2c = NULL; | |
| 332 | 338 | } | |
| 333 | 339 | ||
| 334 | 340 | /** | |
modified drivers/gpu/drm/xe/xe_lrc.c
| @@ -1099,8 +1099,7 @@ static void xe_lrc_finish(struct xe_lrc *lrc) | |||
| 1099 | 1099 | #define CONTEXT_ACTIVE XE_LRC_CTX_TIMESTAMP_ACTIVE | |
| 1100 | 1100 | static ssize_t setup_utilization_wa(struct xe_lrc *lrc, | |
| 1101 | 1101 | struct xe_hw_engine *hwe, | |
| 1102 | - | u32 *batch, | |
| 1103 | - | size_t max_len) | |
| 1102 | + | u32 *batch, size_t max_len, bool indirect) | |
| 1104 | 1103 | { | |
| 1105 | 1104 | u32 *cmd = batch; | |
| 1106 | 1105 | ||
| @@ -1131,19 +1130,25 @@ static ssize_t setup_utilization_wa(struct xe_lrc *lrc, | |||
| 1131 | 1130 | } | |
| 1132 | 1131 | ||
| 1133 | 1132 | static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |
| 1134 | - | u32 *batch, size_t max_len) | |
| 1133 | + | u32 *batch, size_t max_len, bool indirect) | |
| 1135 | 1134 | { | |
| 1136 | 1135 | const u32 ts_addr = __xe_lrc_ctx_timestamp_ggtt_addr(lrc); | |
| 1137 | 1136 | u32 *cmd = batch; | |
| 1138 | 1137 | ||
| 1139 | - | if (!XE_GT_WA(lrc->gt, 16010904313) || | |
| 1140 | - | !(hwe->class == XE_ENGINE_CLASS_RENDER || | |
| 1141 | - | hwe->class == XE_ENGINE_CLASS_COMPUTE || | |
| 1142 | - | hwe->class == XE_ENGINE_CLASS_COPY || | |
| 1138 | + | if (!XE_GT_WA(lrc->gt, 16010904313)) | |
| 1139 | + | return 0; | |
| 1140 | + | ||
| 1141 | + | if (!indirect && | |
| 1142 | + | !(hwe->class == XE_ENGINE_CLASS_COPY || | |
| 1143 | 1143 | hwe->class == XE_ENGINE_CLASS_VIDEO_DECODE || | |
| 1144 | 1144 | hwe->class == XE_ENGINE_CLASS_VIDEO_ENHANCE)) | |
| 1145 | 1145 | return 0; | |
| 1146 | 1146 | ||
| 1147 | + | if (indirect && | |
| 1148 | + | !(hwe->class == XE_ENGINE_CLASS_RENDER || | |
| 1149 | + | hwe->class == XE_ENGINE_CLASS_COMPUTE)) | |
| 1150 | + | return 0; | |
| 1151 | + | ||
| 1147 | 1152 | if (xe_gt_WARN_ON(lrc->gt, max_len < 12)) | |
| 1148 | 1153 | return -ENOSPC; | |
| 1149 | 1154 | ||
| @@ -1169,7 +1174,8 @@ static ssize_t setup_timestamp_wa(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |||
| 1169 | 1174 | ||
| 1170 | 1175 | static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc, | |
| 1171 | 1176 | struct xe_hw_engine *hwe, | |
| 1172 | - | u32 *batch, size_t max_len) | |
| 1177 | + | u32 *batch, size_t max_len, | |
| 1178 | + | bool indirect) | |
| 1173 | 1179 | { | |
| 1174 | 1180 | struct xe_device *xe = gt_to_xe(lrc->gt); | |
| 1175 | 1181 | const u32 *user_batch; | |
| @@ -1198,7 +1204,8 @@ static ssize_t setup_configfs_post_ctx_restore_bb(struct xe_lrc *lrc, | |||
| 1198 | 1204 | ||
| 1199 | 1205 | static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc, | |
| 1200 | 1206 | struct xe_hw_engine *hwe, | |
| 1201 | - | u32 *batch, size_t max_len) | |
| 1207 | + | u32 *batch, size_t max_len, | |
| 1208 | + | bool indirect) | |
| 1202 | 1209 | { | |
| 1203 | 1210 | struct xe_device *xe = gt_to_xe(lrc->gt); | |
| 1204 | 1211 | const u32 *user_batch; | |
| @@ -1227,7 +1234,8 @@ static ssize_t setup_configfs_mid_ctx_restore_bb(struct xe_lrc *lrc, | |||
| 1227 | 1234 | ||
| 1228 | 1235 | static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc, | |
| 1229 | 1236 | struct xe_hw_engine *hwe, | |
| 1230 | - | u32 *batch, size_t max_len) | |
| 1237 | + | u32 *batch, size_t max_len, | |
| 1238 | + | bool indirect) | |
| 1231 | 1239 | { | |
| 1232 | 1240 | u32 *cmd = batch; | |
| 1233 | 1241 | ||
| @@ -1247,7 +1255,8 @@ static ssize_t setup_invalidate_state_cache_wa(struct xe_lrc *lrc, | |||
| 1247 | 1255 | ||
| 1248 | 1256 | static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc, | |
| 1249 | 1257 | struct xe_hw_engine *hwe, | |
| 1250 | - | u32 *batch, size_t max_len) | |
| 1258 | + | u32 *batch, size_t max_len, | |
| 1259 | + | bool indirect) | |
| 1251 | 1260 | { | |
| 1252 | 1261 | struct xe_gt *gt = lrc->gt; | |
| 1253 | 1262 | u32 *(*emit)(struct xe_gt *gt, u32 *cmd) = | |
| @@ -1264,7 +1273,7 @@ static ssize_t setup_invalidate_auxccs_wa(struct xe_lrc *lrc, | |||
| 1264 | 1273 | ||
| 1265 | 1274 | struct bo_setup { | |
| 1266 | 1275 | ssize_t (*setup)(struct xe_lrc *lrc, struct xe_hw_engine *hwe, | |
| 1267 | - | u32 *batch, size_t max_size); | |
| 1276 | + | u32 *batch, size_t max_size, bool indirect); | |
| 1268 | 1277 | }; | |
| 1269 | 1278 | ||
| 1270 | 1279 | struct bo_setup_state { | |
| @@ -1273,6 +1282,7 @@ struct bo_setup_state { | |||
| 1273 | 1282 | struct xe_hw_engine *hwe; | |
| 1274 | 1283 | size_t max_size; | |
| 1275 | 1284 | size_t reserve_dw; | |
| 1285 | + | bool indirect; | |
| 1276 | 1286 | unsigned int offset; | |
| 1277 | 1287 | const struct bo_setup *funcs; | |
| 1278 | 1288 | unsigned int num_funcs; | |
| @@ -1298,7 +1308,8 @@ static int setup_bo(struct bo_setup_state *state) | |||
| 1298 | 1308 | ||
| 1299 | 1309 | for (size_t i = 0; i < state->num_funcs; i++) { | |
| 1300 | 1310 | ssize_t len = state->funcs[i].setup(state->lrc, state->hwe, | |
| 1301 | - | state->ptr, remain); | |
| 1311 | + | state->ptr, remain, | |
| 1312 | + | state->indirect); | |
| 1302 | 1313 | ||
| 1303 | 1314 | remain -= len; | |
| 1304 | 1315 | ||
| @@ -1404,6 +1415,7 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe) | |||
| 1404 | 1415 | struct bo_setup_state state = { | |
| 1405 | 1416 | .lrc = lrc, | |
| 1406 | 1417 | .hwe = hwe, | |
| 1418 | + | .indirect = true, | |
| 1407 | 1419 | .max_size = (63 * 64) /* max 63 cachelines */, | |
| 1408 | 1420 | .buffer = NULL, | |
| 1409 | 1421 | .offset = __xe_lrc_indirect_ctx_offset(lrc), | |
modified drivers/gpu/drm/xe/xe_mmio.c
| @@ -320,6 +320,7 @@ u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg) | |||
| 320 | 320 | return (u64)udw << 32 | ldw; | |
| 321 | 321 | } | |
| 322 | 322 | ||
| 323 | + | #define __XE_MMIO_WAIT_MAX_BACKOFF_100MS (100 * USEC_PER_MSEC) | |
| 323 | 324 | static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val, | |
| 324 | 325 | u32 timeout_us, u32 *out_val, bool atomic, bool expect_match) | |
| 325 | 326 | { | |
| @@ -350,10 +351,10 @@ static int __xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u | |||
| 350 | 351 | wait = ktime_us_delta(end, cur); | |
| 351 | 352 | ||
| 352 | 353 | if (atomic) | |
| 353 | - | udelay(wait); | |
| 354 | + | udelay(min_t(s64, wait, (MAX_UDELAY_MS * 1000))); | |
| 354 | 355 | else | |
| 355 | 356 | usleep_range(wait, wait << 1); | |
| 356 | - | wait <<= 1; | |
| 357 | + | wait = min_t(s64, wait << 1, __XE_MMIO_WAIT_MAX_BACKOFF_100MS); | |
| 357 | 358 | } | |
| 358 | 359 | ||
| 359 | 360 | if (ret != 0) { | |
modified drivers/gpu/drm/xe/xe_mmio_gem.c
| @@ -5,9 +5,9 @@ | |||
| 5 | 5 | ||
| 6 | 6 | #include "xe_mmio_gem.h" | |
| 7 | 7 | ||
| 8 | + | #include <linux/dma-resv.h> | |
| 8 | 9 | #include <drm/drm_drv.h> | |
| 9 | 10 | #include <drm/drm_gem.h> | |
| 10 | - | #include <drm/drm_managed.h> | |
| 11 | 11 | ||
| 12 | 12 | #include "xe_device_types.h" | |
| 13 | 13 | ||
| @@ -37,12 +37,24 @@ static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *); | |||
| 37 | 37 | struct xe_mmio_gem { | |
| 38 | 38 | struct drm_gem_object base; | |
| 39 | 39 | phys_addr_t phys_addr; | |
| 40 | + | struct page *dummy_page; /* protected by the GEM's dma_resv */ | |
| 41 | + | bool destroyed; /* protected by the GEM's dma_resv */ | |
| 40 | 42 | }; | |
| 41 | 43 | ||
| 44 | + | static int xe_mmio_gem_vm_may_split(struct vm_area_struct *area, unsigned long addr) | |
| 45 | + | { | |
| 46 | + | /* | |
| 47 | + | * Forbid splitting. Together with VM_DONTEXPAND, this keeps the VMA | |
| 48 | + | * matching the GEM object exactly. | |
| 49 | + | */ | |
| 50 | + | return -EINVAL; | |
| 51 | + | } | |
| 52 | + | ||
| 42 | 53 | static const struct vm_operations_struct vm_ops = { | |
| 43 | 54 | .open = drm_gem_vm_open, | |
| 44 | 55 | .close = drm_gem_vm_close, | |
| 45 | 56 | .fault = xe_mmio_gem_vm_fault, | |
| 57 | + | .may_split = xe_mmio_gem_vm_may_split, | |
| 46 | 58 | }; | |
| 47 | 59 | ||
| 48 | 60 | static const struct drm_gem_object_funcs xe_mmio_gem_funcs = { | |
| @@ -121,6 +133,8 @@ static void xe_mmio_gem_free(struct drm_gem_object *base) | |||
| 121 | 133 | { | |
| 122 | 134 | struct xe_mmio_gem *obj = to_xe_mmio_gem(base); | |
| 123 | 135 | ||
| 136 | + | if (obj->dummy_page) | |
| 137 | + | __free_page(obj->dummy_page); | |
| 124 | 138 | drm_gem_object_release(base); | |
| 125 | 139 | kfree(obj); | |
| 126 | 140 | } | |
| @@ -128,15 +142,31 @@ static void xe_mmio_gem_free(struct drm_gem_object *base) | |||
| 128 | 142 | /** | |
| 129 | 143 | * xe_mmio_gem_destroy - Destroy the GEM object that exposes an MMIO region | |
| 130 | 144 | * @gem: the GEM object to destroy | |
| 145 | + | * @file: DRM file descriptor previously passed to xe_mmio_gem_create() | |
| 131 | 146 | * | |
| 132 | 147 | * This function releases resources associated with the GEM object created by | |
| 133 | 148 | * xe_mmio_gem_create(). | |
| 134 | 149 | * | |
| 135 | 150 | * See: "Exposing MMIO regions to userspace" | |
| 136 | 151 | */ | |
| 137 | - | void xe_mmio_gem_destroy(struct xe_mmio_gem *gem) | |
| 152 | + | void xe_mmio_gem_destroy(struct xe_mmio_gem *gem, struct drm_file *file) | |
| 138 | 153 | { | |
| 139 | - | xe_mmio_gem_free(&gem->base); | |
| 154 | + | struct drm_gem_object *base = &gem->base; | |
| 155 | + | struct drm_device *dev = base->dev; | |
| 156 | + | ||
| 157 | + | drm_vma_node_revoke(&base->vma_node, file); | |
| 158 | + | ||
| 159 | + | dma_resv_lock(base->resv, NULL); | |
| 160 | + | gem->destroyed = true; | |
| 161 | + | dma_resv_unlock(base->resv); | |
| 162 | + | /* | |
| 163 | + | * Setting 'destroyed' under lock takes care of the subsequent faults. | |
| 164 | + | * Zap the existing PTEs to cut off access to the real MMIO through | |
| 165 | + | * currently mapped pages. | |
| 166 | + | */ | |
| 167 | + | drm_vma_node_unmap(&base->vma_node, dev->anon_inode->i_mapping); | |
| 168 | + | ||
| 169 | + | drm_gem_object_put(base); | |
| 140 | 170 | } | |
| 141 | 171 | ||
| 142 | 172 | static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct *vma) | |
| @@ -147,8 +177,6 @@ static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct * | |||
| 147 | 177 | if ((vma->vm_flags & VM_SHARED) == 0) | |
| 148 | 178 | return -EINVAL; | |
| 149 | 179 | ||
| 150 | - | /* Set vm_pgoff (used as a fake buffer offset by DRM) to 0 */ | |
| 151 | - | vma->vm_pgoff = 0; | |
| 152 | 180 | vma->vm_page_prot = pgprot_noncached(vma_get_page_prot(vma)); | |
| 153 | 181 | vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | | |
| 154 | 182 | VM_DONTCOPY | VM_NORESERVE); | |
| @@ -157,51 +185,47 @@ static int xe_mmio_gem_mmap(struct drm_gem_object *base, struct vm_area_struct * | |||
| 157 | 185 | return 0; | |
| 158 | 186 | } | |
| 159 | 187 | ||
| 160 | - | static void xe_mmio_gem_release_dummy_page(struct drm_device *dev, void *res) | |
| 188 | + | static int alloc_dummy_page_if_needed(struct drm_gem_object *base) | |
| 161 | 189 | { | |
| 162 | - | __free_page((struct page *)res); | |
| 190 | + | struct xe_mmio_gem *obj = to_xe_mmio_gem(base); | |
| 191 | + | ||
| 192 | + | dma_resv_assert_held(base->resv); | |
| 193 | + | if (!obj->dummy_page) | |
| 194 | + | obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO); | |
| 195 | + | ||
| 196 | + | return obj->dummy_page ? 0 : -ENOMEM; | |
| 163 | 197 | } | |
| 164 | 198 | ||
| 165 | - | static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_area_struct *vma) | |
| 199 | + | static vm_fault_t xe_mmio_gem_vm_fault_dummy_page(struct vm_fault *vmf) | |
| 166 | 200 | { | |
| 201 | + | struct vm_area_struct *vma = vmf->vma; | |
| 167 | 202 | struct drm_gem_object *base = vma->vm_private_data; | |
| 168 | - | struct drm_device *dev = base->dev; | |
| 169 | - | vm_fault_t ret = VM_FAULT_NOPAGE; | |
| 170 | - | struct page *page; | |
| 203 | + | struct xe_mmio_gem *obj = to_xe_mmio_gem(base); | |
| 171 | 204 | unsigned long pfn; | |
| 172 | - | unsigned long i; | |
| 173 | 205 | ||
| 174 | - | page = alloc_page(GFP_KERNEL | __GFP_ZERO); | |
| 175 | - | if (!page) | |
| 206 | + | if (alloc_dummy_page_if_needed(base)) | |
| 176 | 207 | return VM_FAULT_OOM; | |
| 177 | 208 | ||
| 178 | - | if (drmm_add_action_or_reset(dev, xe_mmio_gem_release_dummy_page, page)) | |
| 179 | - | return VM_FAULT_OOM; | |
| 180 | - | ||
| 181 | - | pfn = page_to_pfn(page); | |
| 182 | - | ||
| 183 | - | /* Map the entire VMA to the same dummy page */ | |
| 184 | - | for (i = 0; i < base->size; i += PAGE_SIZE) { | |
| 185 | - | unsigned long addr = vma->vm_start + i; | |
| 186 | - | ||
| 187 | - | ret = vmf_insert_pfn(vma, addr, pfn); | |
| 188 | - | if (ret & VM_FAULT_ERROR) | |
| 189 | - | break; | |
| 190 | - | } | |
| 209 | + | pfn = page_to_pfn(obj->dummy_page); | |
| 191 | 210 | ||
| 192 | - | return ret; | |
| 211 | + | return vmf_insert_pfn_prot(vma, vmf->address, pfn, | |
| 212 | + | vm_get_page_prot(vma->vm_flags)); | |
| 193 | 213 | } | |
| 194 | 214 | ||
| 195 | - | static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf) | |
| 215 | + | static vm_fault_t xe_mmio_gem_vm_fault_locked(struct vm_fault *vmf) | |
| 196 | 216 | { | |
| 197 | 217 | struct vm_area_struct *vma = vmf->vma; | |
| 198 | 218 | struct drm_gem_object *base = vma->vm_private_data; | |
| 199 | 219 | struct xe_mmio_gem *obj = to_xe_mmio_gem(base); | |
| 200 | 220 | struct drm_device *dev = base->dev; | |
| 201 | 221 | vm_fault_t ret = VM_FAULT_NOPAGE; | |
| 202 | - | unsigned long i; | |
| 222 | + | unsigned long addr, pfn; | |
| 203 | 223 | int idx; | |
| 204 | 224 | ||
| 225 | + | dma_resv_assert_held(base->resv); | |
| 226 | + | if (obj->destroyed) | |
| 227 | + | return VM_FAULT_SIGBUS; | |
| 228 | + | ||
| 205 | 229 | if (!drm_dev_enter(dev, &idx)) { | |
| 206 | 230 | /* | |
| 207 | 231 | * Provide a dummy page to avoid SIGBUS for events such as hot-unplug. | |
| @@ -209,18 +233,30 @@ static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf) | |||
| 209 | 233 | * It is assumed the userspace will receive the notification via some | |
| 210 | 234 | * other channel (e.g. drm uevent). | |
| 211 | 235 | */ | |
| 212 | - | return xe_mmio_gem_vm_fault_dummy_page(vma); | |
| 236 | + | return xe_mmio_gem_vm_fault_dummy_page(vmf); | |
| 213 | 237 | } | |
| 214 | 238 | ||
| 215 | - | for (i = 0; i < base->size; i += PAGE_SIZE) { | |
| 216 | - | unsigned long addr = vma->vm_start + i; | |
| 217 | - | unsigned long phys_addr = obj->phys_addr + i; | |
| 218 | - | ||
| 219 | - | ret = vmf_insert_pfn(vma, addr, PHYS_PFN(phys_addr)); | |
| 239 | + | pfn = PHYS_PFN(obj->phys_addr); | |
| 240 | + | for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { | |
| 241 | + | ret = vmf_insert_pfn(vma, addr, pfn); | |
| 220 | 242 | if (ret & VM_FAULT_ERROR) | |
| 221 | 243 | break; | |
| 244 | + | ||
| 245 | + | pfn++; | |
| 222 | 246 | } | |
| 223 | 247 | ||
| 224 | 248 | drm_dev_exit(idx); | |
| 225 | 249 | return ret; | |
| 226 | 250 | } | |
| 251 | + | ||
| 252 | + | static vm_fault_t xe_mmio_gem_vm_fault(struct vm_fault *vmf) | |
| 253 | + | { | |
| 254 | + | struct vm_area_struct *vma = vmf->vma; | |
| 255 | + | struct drm_gem_object *base = vma->vm_private_data; | |
| 256 | + | vm_fault_t ret; | |
| 257 | + | ||
| 258 | + | dma_resv_lock(base->resv, NULL); | |
| 259 | + | ret = xe_mmio_gem_vm_fault_locked(vmf); | |
| 260 | + | dma_resv_unlock(base->resv); | |
| 261 | + | return ret; | |
| 262 | + | } | |
modified drivers/gpu/drm/xe/xe_mmio_gem.h
| @@ -15,6 +15,6 @@ struct xe_mmio_gem; | |||
| 15 | 15 | struct xe_mmio_gem *xe_mmio_gem_create(struct xe_device *xe, struct drm_file *file, | |
| 16 | 16 | phys_addr_t phys_addr, size_t size); | |
| 17 | 17 | u64 xe_mmio_gem_mmap_offset(struct xe_mmio_gem *gem); | |
| 18 | - | void xe_mmio_gem_destroy(struct xe_mmio_gem *gem); | |
| 18 | + | void xe_mmio_gem_destroy(struct xe_mmio_gem *gem, struct drm_file *file); | |
| 19 | 19 | ||
| 20 | 20 | #endif /* _XE_MMIO_GEM_H_ */ | |
modified drivers/gpu/drm/xe/xe_pci_sriov.c
| @@ -82,16 +82,33 @@ static void pf_engine_activity_stats(struct xe_device *xe, unsigned int num_vfs, | |||
| 82 | 82 | } | |
| 83 | 83 | } | |
| 84 | 84 | ||
| 85 | - | static int resize_vf_vram_bar(struct xe_device *xe, int num_vfs) | |
| 85 | + | static int pf_resize_vf_vram_bar(struct xe_device *xe, int num_vfs) | |
| 86 | 86 | { | |
| 87 | 87 | struct pci_dev *pdev = to_pci_dev(xe->drm.dev); | |
| 88 | + | char buf[10]; | |
| 88 | 89 | u32 sizes; | |
| 90 | + | int size; | |
| 91 | + | int err; | |
| 92 | + | ||
| 93 | + | if (!IS_DGFX(xe)) | |
| 94 | + | return 0; | |
| 89 | 95 | ||
| 90 | 96 | sizes = pci_iov_vf_bar_get_sizes(pdev, VF_LMEM_BAR, num_vfs); | |
| 91 | 97 | if (!sizes) | |
| 92 | 98 | return 0; | |
| 93 | 99 | ||
| 94 | - | return pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, __fls(sizes)); | |
| 100 | + | size = __fls(sizes); | |
| 101 | + | string_get_size(pci_rebar_size_to_bytes(size), 1, STRING_UNITS_2, buf, sizeof(buf)); | |
| 102 | + | ||
| 103 | + | err = pci_iov_vf_bar_set_size(pdev, VF_LMEM_BAR, size); | |
| 104 | + | if (err) { | |
| 105 | + | xe_sriov_notice(xe, "Failed to resize VF BAR %u to %s (%pe)\n", | |
| 106 | + | VF_LMEM_BAR, buf, ERR_PTR(err)); | |
| 107 | + | return err; | |
| 108 | + | } | |
| 109 | + | ||
| 110 | + | xe_sriov_dbg(xe, "VF LMEM BAR resized to %s\n", buf); | |
| 111 | + | return 0; | |
| 95 | 112 | } | |
| 96 | 113 | ||
| 97 | 114 | static int pf_prepare_vfs_enabling(struct xe_device *xe) | |
| @@ -142,11 +159,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs) | |||
| 142 | 159 | if (err < 0) | |
| 143 | 160 | goto failed; | |
| 144 | 161 | ||
| 145 | - | if (IS_DGFX(xe)) { | |
| 146 | - | err = resize_vf_vram_bar(xe, num_vfs); | |
| 147 | - | if (err) | |
| 148 | - | xe_sriov_info(xe, "Failed to set VF LMEM BAR size: %d\n", err); | |
| 149 | - | } | |
| 162 | + | pf_resize_vf_vram_bar(xe, num_vfs); | |
| 150 | 163 | ||
| 151 | 164 | err = pci_enable_sriov(pdev, num_vfs); | |
| 152 | 165 | if (err < 0) | |
| @@ -164,6 +177,7 @@ static int pf_enable_vfs(struct xe_device *xe, int num_vfs) | |||
| 164 | 177 | return num_vfs; | |
| 165 | 178 | ||
| 166 | 179 | failed: | |
| 180 | + | pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs); | |
| 167 | 181 | xe_sriov_pf_unprovision_vfs(xe, num_vfs); | |
| 168 | 182 | xe_pm_runtime_put(xe); | |
| 169 | 183 | pf_finish_vfs_enabling(xe); | |
| @@ -191,6 +205,8 @@ static int pf_disable_vfs(struct xe_device *xe) | |||
| 191 | 205 | ||
| 192 | 206 | pci_disable_sriov(pdev); | |
| 193 | 207 | ||
| 208 | + | pf_resize_vf_vram_bar(xe, xe->sriov.pf.device_total_vfs); | |
| 209 | + | ||
| 194 | 210 | xe_sriov_pf_reprovision_default(xe); | |
| 195 | 211 | ||
| 196 | 212 | pf_reset_vfs(xe, num_vfs); | |
modified drivers/gpu/drm/xe/xe_shrinker.c
| @@ -54,13 +54,40 @@ xe_shrinker_mod_pages(struct xe_shrinker *shrinker, long shrinkable, long purgea | |||
| 54 | 54 | write_unlock(&shrinker->lock); | |
| 55 | 55 | } | |
| 56 | 56 | ||
| 57 | - | static s64 __xe_shrinker_walk(struct xe_device *xe, | |
| 57 | + | static bool __xe_shrinker_runtime_pm_get(struct xe_shrinker *shrinker) | |
| 58 | + | { | |
| 59 | + | struct xe_device *xe = shrinker->xe; | |
| 60 | + | ||
| 61 | + | if (xe_pm_runtime_get_if_active(xe)) | |
| 62 | + | return true; | |
| 63 | + | ||
| 64 | + | if (xe_rpm_reclaim_safe(xe) && !ttm_bo_shrink_avoid_wait()) { | |
| 65 | + | xe_pm_runtime_get(xe); | |
| 66 | + | return true; | |
| 67 | + | } | |
| 68 | + | ||
| 69 | + | queue_work(xe->unordered_wq, &shrinker->pm_worker); | |
| 70 | + | ||
| 71 | + | return false; | |
| 72 | + | } | |
| 73 | + | ||
| 74 | + | static void xe_shrinker_runtime_pm_put(struct xe_shrinker *shrinker, bool runtime_pm) | |
| 75 | + | { | |
| 76 | + | if (runtime_pm) | |
| 77 | + | xe_pm_runtime_put(shrinker->xe); | |
| 78 | + | } | |
| 79 | + | ||
| 80 | + | static int __xe_shrinker_walk(struct xe_shrinker *shrinker, | |
| 58 | 81 | struct ttm_operation_ctx *ctx, | |
| 59 | 82 | const struct xe_bo_shrink_flags flags, | |
| 60 | - | unsigned long to_scan, unsigned long *scanned) | |
| 83 | + | unsigned long to_scan, unsigned long *scanned, | |
| 84 | + | unsigned long *freed) | |
| 61 | 85 | { | |
| 86 | + | struct xe_device *xe = shrinker->xe; | |
| 62 | 87 | unsigned int mem_type; | |
| 63 | - | s64 freed = 0, lret; | |
| 88 | + | bool rpm = false; | |
| 89 | + | int ret = 0; | |
| 90 | + | s64 lret; | |
| 64 | 91 | ||
| 65 | 92 | for (mem_type = XE_PL_SYSTEM; mem_type <= XE_PL_TT; ++mem_type) { | |
| 66 | 93 | struct ttm_resource_manager *man = ttm_manager_type(&xe->ttm, mem_type); | |
| @@ -74,23 +101,35 @@ static s64 __xe_shrinker_walk(struct xe_device *xe, | |||
| 74 | 101 | if (!man || !man->use_tt) | |
| 75 | 102 | continue; | |
| 76 | 103 | ||
| 104 | + | if (mem_type != XE_PL_SYSTEM && !rpm && | |
| 105 | + | xe_device_is_l2_flush_optimized(xe)) { | |
| 106 | + | if (!__xe_shrinker_runtime_pm_get(shrinker)) | |
| 107 | + | break; | |
| 108 | + | rpm = true; | |
| 109 | + | } | |
| 110 | + | ||
| 77 | 111 | ttm_bo_lru_for_each_reserved_guarded(&curs, man, &arg, ttm_bo) { | |
| 78 | 112 | if (!ttm_bo_shrink_suitable(ttm_bo, ctx)) | |
| 79 | 113 | continue; | |
| 80 | 114 | ||
| 81 | 115 | lret = xe_bo_shrink(ctx, ttm_bo, flags, scanned); | |
| 82 | - | if (lret < 0) | |
| 83 | - | return lret; | |
| 116 | + | if (lret < 0) { | |
| 117 | + | ret = lret; | |
| 118 | + | goto out; | |
| 119 | + | } | |
| 84 | 120 | ||
| 85 | - | freed += lret; | |
| 121 | + | *freed += lret; | |
| 86 | 122 | if (*scanned >= to_scan) | |
| 87 | - | break; | |
| 123 | + | goto out; | |
| 88 | 124 | } | |
| 89 | 125 | /* Trylocks should never error, just fail. */ | |
| 90 | 126 | xe_assert(xe, !IS_ERR(ttm_bo)); | |
| 91 | 127 | } | |
| 92 | 128 | ||
| 93 | - | return freed; | |
| 129 | + | out: | |
| 130 | + | xe_shrinker_runtime_pm_put(shrinker, rpm); | |
| 131 | + | ||
| 132 | + | return ret; | |
| 94 | 133 | } | |
| 95 | 134 | ||
| 96 | 135 | /* | |
| @@ -99,40 +138,36 @@ static s64 __xe_shrinker_walk(struct xe_device *xe, | |||
| 99 | 138 | * add writeback. This avoids stalls and explicit writebacks with light or | |
| 100 | 139 | * moderate memory pressure. | |
| 101 | 140 | */ | |
| 102 | - | static s64 xe_shrinker_walk(struct xe_device *xe, | |
| 141 | + | static int xe_shrinker_walk(struct xe_shrinker *shrinker, | |
| 103 | 142 | struct ttm_operation_ctx *ctx, | |
| 104 | 143 | const struct xe_bo_shrink_flags flags, | |
| 105 | - | unsigned long to_scan, unsigned long *scanned) | |
| 144 | + | unsigned long to_scan, unsigned long *scanned, | |
| 145 | + | unsigned long *freed) | |
| 106 | 146 | { | |
| 107 | 147 | bool no_wait_gpu = true; | |
| 108 | 148 | struct xe_bo_shrink_flags save_flags = flags; | |
| 109 | - | s64 lret, freed; | |
| 149 | + | int ret; | |
| 110 | 150 | ||
| 111 | 151 | swap(no_wait_gpu, ctx->no_wait_gpu); | |
| 112 | 152 | save_flags.writeback = false; | |
| 113 | - | lret = __xe_shrinker_walk(xe, ctx, save_flags, to_scan, scanned); | |
| 153 | + | ret = __xe_shrinker_walk(shrinker, ctx, save_flags, to_scan, scanned, | |
| 154 | + | freed); | |
| 114 | 155 | swap(no_wait_gpu, ctx->no_wait_gpu); | |
| 115 | - | if (lret < 0 || *scanned >= to_scan) | |
| 116 | - | return lret; | |
| 156 | + | if (ret || *scanned >= to_scan) | |
| 157 | + | return ret; | |
| 117 | 158 | ||
| 118 | - | freed = lret; | |
| 119 | 159 | if (!ctx->no_wait_gpu) { | |
| 120 | - | lret = __xe_shrinker_walk(xe, ctx, save_flags, to_scan, scanned); | |
| 121 | - | if (lret < 0) | |
| 122 | - | return lret; | |
| 123 | - | freed += lret; | |
| 124 | - | if (*scanned >= to_scan) | |
| 125 | - | return freed; | |
| 160 | + | ret = __xe_shrinker_walk(shrinker, ctx, save_flags, to_scan, scanned, | |
| 161 | + | freed); | |
| 162 | + | if (ret || *scanned >= to_scan) | |
| 163 | + | return ret; | |
| 126 | 164 | } | |
| 127 | 165 | ||
| 128 | - | if (flags.writeback) { | |
| 129 | - | lret = __xe_shrinker_walk(xe, ctx, flags, to_scan, scanned); | |
| 130 | - | if (lret < 0) | |
| 131 | - | return lret; | |
| 132 | - | freed += lret; | |
| 133 | - | } | |
| 166 | + | if (flags.writeback) | |
| 167 | + | ret = __xe_shrinker_walk(shrinker, ctx, flags, to_scan, scanned, | |
| 168 | + | freed); | |
| 134 | 169 | ||
| 135 | - | return freed; | |
| 170 | + | return ret; | |
| 136 | 171 | } | |
| 137 | 172 | ||
| 138 | 173 | static unsigned long | |
| @@ -180,22 +215,7 @@ static bool xe_shrinker_runtime_pm_get(struct xe_shrinker *shrinker, bool force, | |||
| 180 | 215 | return false; | |
| 181 | 216 | } | |
| 182 | 217 | ||
| 183 | - | if (!xe_pm_runtime_get_if_active(xe)) { | |
| 184 | - | if (xe_rpm_reclaim_safe(xe) && !ttm_bo_shrink_avoid_wait()) { | |
| 185 | - | xe_pm_runtime_get(xe); | |
| 186 | - | return true; | |
| 187 | - | } | |
| 188 | - | queue_work(xe->unordered_wq, &shrinker->pm_worker); | |
| 189 | - | return false; | |
| 190 | - | } | |
| 191 | - | ||
| 192 | - | return true; | |
| 193 | - | } | |
| 194 | - | ||
| 195 | - | static void xe_shrinker_runtime_pm_put(struct xe_shrinker *shrinker, bool runtime_pm) | |
| 196 | - | { | |
| 197 | - | if (runtime_pm) | |
| 198 | - | xe_pm_runtime_put(shrinker->xe); | |
| 218 | + | return __xe_shrinker_runtime_pm_get(shrinker); | |
| 199 | 219 | } | |
| 200 | 220 | ||
| 201 | 221 | static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_control *sc) | |
| @@ -214,7 +234,6 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con | |||
| 214 | 234 | bool runtime_pm; | |
| 215 | 235 | bool purgeable; | |
| 216 | 236 | bool can_backup = !!(sc->gfp_mask & __GFP_FS); | |
| 217 | - | s64 lret; | |
| 218 | 237 | ||
| 219 | 238 | nr_to_scan = sc->nr_to_scan; | |
| 220 | 239 | ||
| @@ -225,12 +244,9 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con | |||
| 225 | 244 | /* Might need runtime PM. Try to wake early if it looks like it. */ | |
| 226 | 245 | runtime_pm = xe_shrinker_runtime_pm_get(shrinker, false, nr_to_scan, can_backup); | |
| 227 | 246 | ||
| 228 | - | if (purgeable && nr_scanned < nr_to_scan) { | |
| 229 | - | lret = xe_shrinker_walk(shrinker->xe, &ctx, shrink_flags, | |
| 230 | - | nr_to_scan, &nr_scanned); | |
| 231 | - | if (lret >= 0) | |
| 232 | - | freed += lret; | |
| 233 | - | } | |
| 247 | + | if (purgeable && nr_scanned < nr_to_scan) | |
| 248 | + | xe_shrinker_walk(shrinker, &ctx, shrink_flags, | |
| 249 | + | nr_to_scan, &nr_scanned, &freed); | |
| 234 | 250 | ||
| 235 | 251 | sc->nr_scanned = nr_scanned; | |
| 236 | 252 | if (nr_scanned >= nr_to_scan || !can_backup) | |
| @@ -242,10 +258,8 @@ static unsigned long xe_shrinker_scan(struct shrinker *shrink, struct shrink_con | |||
| 242 | 258 | ||
| 243 | 259 | shrink_flags.purge = false; | |
| 244 | 260 | ||
| 245 | - | lret = xe_shrinker_walk(shrinker->xe, &ctx, shrink_flags, | |
| 246 | - | nr_to_scan, &nr_scanned); | |
| 247 | - | if (lret >= 0) | |
| 248 | - | freed += lret; | |
| 261 | + | xe_shrinker_walk(shrinker, &ctx, shrink_flags, | |
| 262 | + | nr_to_scan, &nr_scanned, &freed); | |
| 249 | 263 | ||
| 250 | 264 | sc->nr_scanned = nr_scanned; | |
| 251 | 265 | out: | |
modified drivers/gpu/drm/xe/xe_sysctrl_mailbox.c
| @@ -19,20 +19,20 @@ | |||
| 19 | 19 | #include "xe_sysctrl_mailbox_types.h" | |
| 20 | 20 | ||
| 21 | 21 | struct xe_sysctrl_mailbox_msg_hdr { | |
| 22 | - | __le32 data; | |
| 23 | - | } __packed; | |
| 22 | + | u32 data; | |
| 23 | + | }; | |
| 24 | 24 | ||
| 25 | 25 | #define XE_SYSCTRL_HDR_GROUP_ID(hdr) \ | |
| 26 | - | FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, le32_to_cpu((hdr)->data)) | |
| 26 | + | FIELD_GET(SYSCTRL_HDR_GROUP_ID_MASK, (hdr)->data) | |
| 27 | 27 | ||
| 28 | 28 | #define XE_SYSCTRL_HDR_COMMAND(hdr) \ | |
| 29 | - | FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, le32_to_cpu((hdr)->data)) | |
| 29 | + | FIELD_GET(SYSCTRL_HDR_COMMAND_MASK, (hdr)->data) | |
| 30 | 30 | ||
| 31 | 31 | #define XE_SYSCTRL_HDR_IS_RESPONSE(hdr) \ | |
| 32 | - | FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, le32_to_cpu((hdr)->data)) | |
| 32 | + | FIELD_GET(SYSCTRL_HDR_IS_RESPONSE, (hdr)->data) | |
| 33 | 33 | ||
| 34 | 34 | #define XE_SYSCTRL_HDR_RESULT(hdr) \ | |
| 35 | - | FIELD_GET(SYSCTRL_HDR_RESULT_MASK, le32_to_cpu((hdr)->data)) | |
| 35 | + | FIELD_GET(SYSCTRL_HDR_RESULT_MASK, (hdr)->data) | |
| 36 | 36 | ||
| 37 | 37 | static bool sysctrl_wait_bit_clear(struct xe_sysctrl *sc, u32 bit_mask, | |
| 38 | 38 | unsigned int timeout_ms) | |
| @@ -126,8 +126,8 @@ static int sysctrl_prepare_command(struct xe_device *xe, | |||
| 126 | 126 | return -ENOMEM; | |
| 127 | 127 | ||
| 128 | 128 | hdr = (struct xe_sysctrl_mailbox_msg_hdr *)buffer; | |
| 129 | - | hdr->data = cpu_to_le32(FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) | | |
| 130 | - | FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command)); | |
| 129 | + | hdr->data = FIELD_PREP(SYSCTRL_HDR_GROUP_ID_MASK, group_id) | | |
| 130 | + | FIELD_PREP(SYSCTRL_HDR_COMMAND_MASK, command); | |
| 131 | 131 | ||
| 132 | 132 | if (data_in && data_in_len) | |
| 133 | 133 | memcpy(buffer + sizeof(*hdr), data_in, data_in_len); | |
modified drivers/gpu/drm/xe/xe_tlb_inval.c
| @@ -280,7 +280,8 @@ static void xe_tlb_inval_fence_prep(struct xe_tlb_inval_fence *fence) | |||
| 280 | 280 | xe_tlb_inval_fence_signal_unlocked((__fence)); \ | |
| 281 | 281 | mutex_unlock(&(__tlb_inval)->seqno_lock); \ | |
| 282 | 282 | \ | |
| 283 | - | __ret == -ECANCELED ? 0 : __ret; \ | |
| 283 | + | /* Undelivered: fence already signalled, report done */ \ | |
| 284 | + | (__ret == -ECANCELED || __ret == -ENOTRECOVERABLE) ? 0 : __ret; \ | |
| 284 | 285 | }) | |
| 285 | 286 | ||
| 286 | 287 | /** | |
modified drivers/gpu/drm/xe/xe_vm.c
| @@ -1947,21 +1947,13 @@ void xe_vm_close_and_put(struct xe_vm *vm) | |||
| 1947 | 1947 | vma->gpuva.flags |= XE_VMA_DESTROYED; | |
| 1948 | 1948 | } | |
| 1949 | 1949 | ||
| 1950 | - | /* | |
| 1951 | - | * All vm operations will add shared fences to resv. | |
| 1952 | - | * The only exception is eviction for a shared object, | |
| 1953 | - | * but even so, the unbind when evicted would still | |
| 1954 | - | * install a fence to resv. Hence it's safe to | |
| 1955 | - | * destroy the pagetables immediately. | |
| 1956 | - | */ | |
| 1957 | - | xe_vm_free_scratch(vm); | |
| 1958 | - | xe_vm_pt_destroy(vm); | |
| 1959 | 1950 | xe_vm_unlock(vm); | |
| 1960 | 1951 | ||
| 1961 | 1952 | /* | |
| 1962 | - | * VM is now dead, cannot re-add nodes to vm->vmas if it's NULL | |
| 1963 | - | * Since we hold a refcount to the bo, we can remove and free | |
| 1964 | - | * the members safely without locking. | |
| 1953 | + | * Unlink and destroy all contested external-BO VMAs before destroying | |
| 1954 | + | * the page tables. Otherwise, concurrent eviction holding only bo->resv | |
| 1955 | + | * can walk the BO's VMAs and attempt to invalidate/zap page tables that | |
| 1956 | + | * have already been freed. | |
| 1965 | 1957 | */ | |
| 1966 | 1958 | list_for_each_entry_safe(vma, next_vma, &contested, | |
| 1967 | 1959 | combined_links.destroy) { | |
| @@ -1969,6 +1961,11 @@ void xe_vm_close_and_put(struct xe_vm *vm) | |||
| 1969 | 1961 | xe_vma_destroy_unlocked(vma); | |
| 1970 | 1962 | } | |
| 1971 | 1963 | ||
| 1964 | + | xe_vm_lock(vm, false); | |
| 1965 | + | xe_vm_free_scratch(vm); | |
| 1966 | + | xe_vm_pt_destroy(vm); | |
| 1967 | + | xe_vm_unlock(vm); | |
| 1968 | + | ||
| 1972 | 1969 | xe_svm_fini(vm); | |
| 1973 | 1970 | ||
| 1974 | 1971 | up_write(&vm->lock); | |
modified drivers/gpu/drm/xe/xe_wa_oob.rules
| @@ -72,3 +72,5 @@ | |||
| 72 | 72 | 16029897822 MEDIA_VERSION(3500) | |
| 73 | 73 | GRAPHICS_VERSION(3510) | |
| 74 | 74 | 14027054324 GRAPHICS_VERSION(3511) | |
| 75 | + | 14025941587 GRAPHICS_VERSION_RANGE(2001, 3511), FUNC(xe_rtp_match_not_sriov_vf) | |
| 76 | + | MEDIA_VERSION_RANGE(1301, 3503), FUNC(xe_rtp_match_not_sriov_vf) | |
modified drivers/hid/Kconfig
| @@ -1210,7 +1210,8 @@ config HID_STEELSERIES | |||
| 1210 | 1210 | depends on USB_HID | |
| 1211 | 1211 | help | |
| 1212 | 1212 | Support for Steelseries SRW-S1 steering wheel, and the Steelseries | |
| 1213 | - | Arctis 1 Wireless for XBox headset. | |
| 1213 | + | Arctis 1 Wireless for XBox, Arctis 7 (2018), Arctis 9, and Arctis | |
| 1214 | + | Nova headsets. | |
| 1214 | 1215 | ||
| 1215 | 1216 | config HID_SUNPLUS | |
| 1216 | 1217 | tristate "Sunplus wireless desktop" | |
modified drivers/hid/amd-sfh-hid/amd_sfh_common.h
| @@ -13,11 +13,15 @@ | |||
| 13 | 13 | #include <linux/auxiliary_bus.h> | |
| 14 | 14 | #include <linux/mutex.h> | |
| 15 | 15 | #include <linux/pci.h> | |
| 16 | + | #include <linux/sizes.h> | |
| 16 | 17 | #include "amd_sfh_hid.h" | |
| 17 | 18 | ||
| 18 | 19 | #define PCI_DEVICE_ID_AMD_MP2 0x15E4 | |
| 19 | 20 | #define PCI_DEVICE_ID_AMD_MP2_1_1 0x164A | |
| 20 | 21 | ||
| 22 | + | /* The BAR 2 size must cover the highest register offset (0x10958) */ | |
| 23 | + | #define AMD_SFH_MIN_BAR_SIZE SZ_128K | |
| 24 | + | ||
| 21 | 25 | #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4)) | |
| 22 | 26 | #define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4)) | |
| 23 | 27 | ||
modified drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
| @@ -497,6 +497,16 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i | |||
| 497 | 497 | if (rc) | |
| 498 | 498 | return rc; | |
| 499 | 499 | ||
| 500 | + | if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) { | |
| 501 | + | dev_err(&pdev->dev, "BAR 2 is not IORESOURCE_MEM\n"); | |
| 502 | + | return -ENODEV; | |
| 503 | + | } | |
| 504 | + | ||
| 505 | + | if (pci_resource_len(pdev, 2) < AMD_SFH_MIN_BAR_SIZE) { | |
| 506 | + | dev_err(&pdev->dev, "BAR 2 is too small\n"); | |
| 507 | + | return -EINVAL; | |
| 508 | + | } | |
| 509 | + | ||
| 500 | 510 | rc = pcim_iomap_regions(pdev, BIT(2), DRIVER_NAME); | |
| 501 | 511 | if (rc) | |
| 502 | 512 | return rc; | |
modified drivers/hid/bpf/hid_bpf_dispatch.c
| @@ -359,7 +359,7 @@ hid_bpf_release_context(struct hid_bpf_ctx *ctx) | |||
| 359 | 359 | ||
| 360 | 360 | static int | |
| 361 | 361 | __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, | |
| 362 | - | enum hid_report_type rtype) | |
| 362 | + | enum hid_report_type rtype, bool hw_request) | |
| 363 | 363 | { | |
| 364 | 364 | struct hid_report_enum *report_enum; | |
| 365 | 365 | struct hid_report *report; | |
| @@ -388,6 +388,10 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz, | |||
| 388 | 388 | ||
| 389 | 389 | report_len = hid_report_len(report); | |
| 390 | 390 | ||
| 391 | + | /* unnumbered reports need to have a report ID reserved in the first byte */ | |
| 392 | + | if (hw_request && report_enum->numbered == 0) | |
| 393 | + | report_len += 1; | |
| 394 | + | ||
| 391 | 395 | if (*buf__sz > report_len) | |
| 392 | 396 | *buf__sz = report_len; | |
| 393 | 397 | ||
| @@ -420,7 +424,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, | |||
| 420 | 424 | return -EDEADLOCK; | |
| 421 | 425 | ||
| 422 | 426 | /* check arguments */ | |
| 423 | - | ret = __hid_bpf_hw_check_params(ctx, buf, &size, rtype); | |
| 427 | + | ret = __hid_bpf_hw_check_params(ctx, buf, &size, rtype, true); | |
| 424 | 428 | if (ret) | |
| 425 | 429 | return ret; | |
| 426 | 430 | ||
| @@ -449,7 +453,7 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, | |||
| 449 | 453 | (u64)(long)ctx, | |
| 450 | 454 | true); /* prevent infinite recursions */ | |
| 451 | 455 | ||
| 452 | - | if (ret > size) | |
| 456 | + | if (ret > (ssize_t)size) | |
| 453 | 457 | ret = size; | |
| 454 | 458 | if (ret > 0) | |
| 455 | 459 | memcpy(buf, dma_data, ret); | |
| @@ -480,7 +484,7 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz) | |||
| 480 | 484 | return -EDEADLOCK; | |
| 481 | 485 | ||
| 482 | 486 | /* check arguments */ | |
| 483 | - | ret = __hid_bpf_hw_check_params(ctx, buf, &size, HID_OUTPUT_REPORT); | |
| 487 | + | ret = __hid_bpf_hw_check_params(ctx, buf, &size, HID_OUTPUT_REPORT, true); | |
| 484 | 488 | if (ret) | |
| 485 | 489 | return ret; | |
| 486 | 490 | ||
| @@ -506,7 +510,7 @@ __hid_bpf_input_report(struct hid_bpf_ctx *ctx, enum hid_report_type type, u8 *b | |||
| 506 | 510 | return -EDEADLOCK; | |
| 507 | 511 | ||
| 508 | 512 | /* check arguments */ | |
| 509 | - | ret = __hid_bpf_hw_check_params(ctx, buf, &size, type); | |
| 513 | + | ret = __hid_bpf_hw_check_params(ctx, buf, &size, type, false); | |
| 510 | 514 | if (ret) | |
| 511 | 515 | return ret; | |
| 512 | 516 | ||
modified drivers/hid/hid-alps.c
| @@ -407,6 +407,8 @@ static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size) | |||
| 407 | 407 | return 1; | |
| 408 | 408 | ||
| 409 | 409 | case U1_SP_ABSOLUTE_REPORT_ID: | |
| 410 | + | if (!hdata->input2) | |
| 411 | + | return 0; | |
| 410 | 412 | sp_x = get_unaligned_le16(data+2); | |
| 411 | 413 | sp_y = get_unaligned_le16(data+4); | |
| 412 | 414 | ||
| @@ -738,7 +740,6 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) | |||
| 738 | 740 | goto exit; | |
| 739 | 741 | } | |
| 740 | 742 | ||
| 741 | - | data->input2 = input2; | |
| 742 | 743 | input2->phys = input->phys; | |
| 743 | 744 | input2->name = "DualPoint Stick"; | |
| 744 | 745 | input2->id.bustype = BUS_I2C; | |
| @@ -762,11 +763,12 @@ static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) | |||
| 762 | 763 | __set_bit(INPUT_PROP_POINTER, input2->propbit); | |
| 763 | 764 | __set_bit(INPUT_PROP_POINTING_STICK, input2->propbit); | |
| 764 | 765 | ||
| 765 | - | if (input_register_device(data->input2)) { | |
| 766 | + | if (input_register_device(input2)) { | |
| 766 | 767 | input_free_device(input2); | |
| 767 | 768 | ret = -ENOENT; | |
| 768 | 769 | goto exit; | |
| 769 | 770 | } | |
| 771 | + | data->input2 = input2; | |
| 770 | 772 | } | |
| 771 | 773 | ||
| 772 | 774 | exit: | |
| @@ -823,6 +825,24 @@ static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 823 | 825 | return 0; | |
| 824 | 826 | } | |
| 825 | 827 | ||
| 828 | + | static void alps_remove(struct hid_device *hdev) | |
| 829 | + | { | |
| 830 | + | struct alps_dev *data = hid_get_drvdata(hdev); | |
| 831 | + | ||
| 832 | + | /* | |
| 833 | + | * input2 ("DualPoint Stick") is allocated separately and is not | |
| 834 | + | * tracked in hdev->inputs, so the default remove path | |
| 835 | + | * (hid_hw_stop -> hidinput_disconnect) does not unregister it. | |
| 836 | + | * | |
| 837 | + | * Stop the device first so that no URB callback can touch input2 | |
| 838 | + | * while it is being unregistered, then drop it explicitly. | |
| 839 | + | */ | |
| 840 | + | hid_hw_stop(hdev); | |
| 841 | + | ||
| 842 | + | if (data->input2) | |
| 843 | + | input_unregister_device(data->input2); | |
| 844 | + | } | |
| 845 | + | ||
| 826 | 846 | static const struct hid_device_id alps_id[] = { | |
| 827 | 847 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, | |
| 828 | 848 | USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, | |
| @@ -845,6 +865,7 @@ static struct hid_driver alps_driver = { | |||
| 845 | 865 | .input_configured = alps_input_configured, | |
| 846 | 866 | .resume = pm_ptr(alps_post_resume), | |
| 847 | 867 | .reset_resume = pm_ptr(alps_post_reset), | |
| 868 | + | .remove = alps_remove, | |
| 848 | 869 | }; | |
| 849 | 870 | ||
| 850 | 871 | module_hid_driver(alps_driver); | |
modified drivers/hid/hid-corsair-void.c
| @@ -51,20 +51,23 @@ | |||
| 51 | 51 | /* Receiver report information: (ID 102) */ | |
| 52 | 52 | /* -------------------------------------------------------------------------- */ | |
| 53 | 53 | /* | |
| 54 | - | * When queried, the recevier responds with 4 bytes to describe the firmware | |
| 55 | - | * The first 2 bytes are for the receiver, the second 2 are the headset | |
| 54 | + | * When queried, the receiver responds with 5 bytes to describe the firmware | |
| 55 | + | * The first byte is the ID, then 2 bytes for the receiver, then 2 for the headset | |
| 56 | 56 | * The headset firmware version will be 0 if no headset is connected | |
| 57 | 57 | * | |
| 58 | - | * 0: Recevier firmware major version | |
| 58 | + | * 0: Report ID | |
| 59 | + | * 102 for the firmware packet | |
| 60 | + | * | |
| 61 | + | * 1: Receiver firmware major version | |
| 59 | 62 | * Major version of the receiver's firmware | |
| 60 | 63 | * | |
| 61 | - | * 1: Recevier firmware minor version | |
| 64 | + | * 2: Receiver firmware minor version | |
| 62 | 65 | * Minor version of the receiver's firmware | |
| 63 | 66 | * | |
| 64 | - | * 2: Headset firmware major version | |
| 67 | + | * 3: Headset firmware major version | |
| 65 | 68 | * Major version of the headset's firmware | |
| 66 | 69 | * | |
| 67 | - | * 3: Headset firmware minor version | |
| 70 | + | * 4: Headset firmware minor version | |
| 68 | 71 | * Minor version of the headset's firmware | |
| 69 | 72 | */ | |
| 70 | 73 | /* -------------------------------------------------------------------------- */ | |
modified drivers/hid/hid-elecom.c
| @@ -79,7 +79,7 @@ static const __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
| 79 | 79 | case USB_DEVICE_ID_ELECOM_M_XT3URBK_00FB: | |
| 80 | 80 | case USB_DEVICE_ID_ELECOM_M_XT3URBK_018F: | |
| 81 | 81 | case USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC: | |
| 82 | - | case USB_DEVICE_ID_ELECOM_M_XT4DRBK: | |
| 82 | + | case USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD: | |
| 83 | 83 | /* | |
| 84 | 84 | * Report descriptor format: | |
| 85 | 85 | * 12: button bit count | |
| @@ -104,6 +104,7 @@ static const __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
| 104 | 104 | mouse_button_fixup(hdev, rdesc, *rsize, 12, 30, 14, 20, 8); | |
| 105 | 105 | break; | |
| 106 | 106 | case USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C: | |
| 107 | + | case USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E: | |
| 107 | 108 | /* | |
| 108 | 109 | * Report descriptor format: | |
| 109 | 110 | * 22: button bit count | |
| @@ -148,7 +149,8 @@ static const struct hid_device_id elecom_devices[] = { | |||
| 148 | 149 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK_018F) }, | |
| 149 | 150 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC) }, | |
| 150 | 151 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C) }, | |
| 151 | - | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, | |
| 152 | + | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD) }, | |
| 153 | + | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E) }, | |
| 152 | 154 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, | |
| 153 | 155 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, | |
| 154 | 156 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT2DRBK) }, | |
modified drivers/hid/hid-ids.h
| @@ -477,7 +477,8 @@ | |||
| 477 | 477 | #define USB_DEVICE_ID_ELECOM_M_XT3URBK_018F 0x018f | |
| 478 | 478 | #define USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC 0x00fc | |
| 479 | 479 | #define USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C 0x018c | |
| 480 | - | #define USB_DEVICE_ID_ELECOM_M_XT4DRBK 0x00fd | |
| 480 | + | #define USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD 0x00fd | |
| 481 | + | #define USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E 0x018e | |
| 481 | 482 | #define USB_DEVICE_ID_ELECOM_M_DT1URBK 0x00fe | |
| 482 | 483 | #define USB_DEVICE_ID_ELECOM_M_DT1DRBK 0x00ff | |
| 483 | 484 | #define USB_DEVICE_ID_ELECOM_M_DT2DRBK 0x018d | |
| @@ -765,6 +766,7 @@ | |||
| 765 | 766 | #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a | |
| 766 | 767 | #define USB_DEVICE_ID_ITE_LENOVO_YOGA900 0x8396 | |
| 767 | 768 | #define I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_KEYBOARD 0x8987 | |
| 769 | + | #define I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD 0x83db | |
| 768 | 770 | #define USB_DEVICE_ID_ITE8595 0x8595 | |
| 769 | 771 | #define USB_DEVICE_ID_ITE_MEDION_E1239T 0xce50 | |
| 770 | 772 | ||
| @@ -1296,6 +1298,9 @@ | |||
| 1296 | 1298 | #define USB_DEVICE_ID_SAMSUNG_WIRELESS_UNIVERSAL_KBD 0xa006 | |
| 1297 | 1299 | #define USB_DEVICE_ID_SAMSUNG_WIRELESS_MULTI_HOGP_KBD 0xa064 | |
| 1298 | 1300 | ||
| 1301 | + | #define USB_VENDOR_ID_SDINNOVATION 0x36ae | |
| 1302 | + | #define USB_DEVICE_ID_SDINNOVATION_GAMING_KBD 0xfeab | |
| 1303 | + | ||
| 1299 | 1304 | #define USB_VENDOR_ID_SEMICO 0x1a2c | |
| 1300 | 1305 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023 | |
| 1301 | 1306 | #define USB_DEVICE_ID_SEMICO_USB_KEYKOARD2 0x0027 | |
| @@ -1395,6 +1400,7 @@ | |||
| 1395 | 1400 | #define USB_VENDOR_ID_STEELSERIES 0x1038 | |
| 1396 | 1401 | #define USB_DEVICE_ID_STEELSERIES_SRWS1 0x1410 | |
| 1397 | 1402 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_1_X 0x12b6 | |
| 1403 | + | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_7_2018 0x12ad | |
| 1398 | 1404 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_9 0x12c2 | |
| 1399 | 1405 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_5_X 0x2253 | |
| 1400 | 1406 | #define USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_7 0x2202 | |
| @@ -1504,6 +1510,9 @@ | |||
| 1504 | 1510 | #define USB_DEVICE_ID_ASUS_MD_5110 0x5110 | |
| 1505 | 1511 | #define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 | |
| 1506 | 1512 | ||
| 1513 | + | #define USB_VENDOR_ID_TURTLE_BEACH 0x10f5 | |
| 1514 | + | #define USB_DEVICE_ID_TB_VELOCITYONE_RACE 0x7077 | |
| 1515 | + | ||
| 1507 | 1516 | #define USB_VENDOR_ID_TWINHAN 0x6253 | |
| 1508 | 1517 | #define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100 | |
| 1509 | 1518 | ||
modified drivers/hid/hid-logitech-dj.c
| @@ -121,7 +121,6 @@ enum recvr_type { | |||
| 121 | 121 | recvr_type_27mhz, | |
| 122 | 122 | recvr_type_bluetooth, | |
| 123 | 123 | recvr_type_dinovo, | |
| 124 | - | recvr_type_bolt, | |
| 125 | 124 | }; | |
| 126 | 125 | ||
| 127 | 126 | struct dj_report { | |
| @@ -1157,10 +1156,6 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev, | |||
| 1157 | 1156 | logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); | |
| 1158 | 1157 | workitem.reports_supported |= STD_KEYBOARD; | |
| 1159 | 1158 | break; | |
| 1160 | - | case 0x10: | |
| 1161 | - | device_type = "Bolt"; | |
| 1162 | - | logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); | |
| 1163 | - | break; | |
| 1164 | 1159 | } | |
| 1165 | 1160 | ||
| 1166 | 1161 | /* custom receiver device (eg. powerplay) */ | |
| @@ -1750,24 +1745,6 @@ static int logi_dj_hidpp_event(struct hid_device *hdev, | |||
| 1750 | 1745 | ||
| 1751 | 1746 | dj_dev = djrcv_dev->paired_dj_devices[device_index]; | |
| 1752 | 1747 | ||
| 1753 | - | /* | |
| 1754 | - | * Bolt receivers send explicit unpair notifications as HID++ events; | |
| 1755 | - | * queue device removal when we receive one. | |
| 1756 | - | */ | |
| 1757 | - | if (djrcv_dev->type == recvr_type_bolt && | |
| 1758 | - | hidpp_report->report_id == REPORT_ID_HIDPP_SHORT && | |
| 1759 | - | hidpp_report->sub_id == REPORT_TYPE_NOTIF_DEVICE_UNPAIRED) { | |
| 1760 | - | struct dj_workitem workitem = { | |
| 1761 | - | .device_index = device_index, | |
| 1762 | - | .type = WORKITEM_TYPE_UNPAIRED, | |
| 1763 | - | }; | |
| 1764 | - | ||
| 1765 | - | kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem)); | |
| 1766 | - | schedule_work(&djrcv_dev->work); | |
| 1767 | - | spin_unlock_irqrestore(&djrcv_dev->lock, flags); | |
| 1768 | - | return false; | |
| 1769 | - | } | |
| 1770 | - | ||
| 1771 | 1748 | /* | |
| 1772 | 1749 | * With 27 MHz receivers, we do not get an explicit unpair event, | |
| 1773 | 1750 | * remove the old device if the user has paired a *different* device. | |
| @@ -1907,9 +1884,6 @@ static int logi_dj_probe(struct hid_device *hdev, | |||
| 1907 | 1884 | * treat these as logitech-dj interfaces then this causes input events | |
| 1908 | 1885 | * reported through this extra interface to not be reported correctly. | |
| 1909 | 1886 | * To avoid this, we treat these as generic-hid devices. | |
| 1910 | - | * | |
| 1911 | - | * Bolt receivers only use LOGITECH_DJ_INTERFACE_NUMBER for receiver | |
| 1912 | - | * reporting. Treat all other Bolt interfaces as generic-hid devices. | |
| 1913 | 1887 | */ | |
| 1914 | 1888 | switch (id->driver_data) { | |
| 1915 | 1889 | case recvr_type_dj: no_dj_interfaces = 3; break; | |
| @@ -1923,20 +1897,10 @@ static int logi_dj_probe(struct hid_device *hdev, | |||
| 1923 | 1897 | } | |
| 1924 | 1898 | if (hid_is_usb(hdev)) { | |
| 1925 | 1899 | intf = to_usb_interface(hdev->dev.parent); | |
| 1926 | - | if (intf) { | |
| 1927 | - | bool generic_hid_interface; | |
| 1928 | - | ||
| 1929 | - | if (id->driver_data == recvr_type_bolt) | |
| 1930 | - | generic_hid_interface = | |
| 1931 | - | intf->altsetting->desc.bInterfaceNumber != | |
| 1932 | - | LOGITECH_DJ_INTERFACE_NUMBER; | |
| 1933 | - | else | |
| 1934 | - | generic_hid_interface = | |
| 1935 | - | intf->altsetting->desc.bInterfaceNumber >= no_dj_interfaces; | |
| 1936 | - | if (generic_hid_interface) { | |
| 1937 | - | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | |
| 1938 | - | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 1939 | - | } | |
| 1900 | + | if (intf && intf->altsetting->desc.bInterfaceNumber >= | |
| 1901 | + | no_dj_interfaces) { | |
| 1902 | + | hdev->quirks |= HID_QUIRK_INPUT_PER_APP; | |
| 1903 | + | return hid_hw_start(hdev, HID_CONNECT_DEFAULT); | |
| 1940 | 1904 | } | |
| 1941 | 1905 | } | |
| 1942 | 1906 | ||
| @@ -2139,10 +2103,6 @@ static const struct hid_device_id logi_dj_receivers[] = { | |||
| 2139 | 2103 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2140 | 2104 | USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_3), | |
| 2141 | 2105 | .driver_data = recvr_type_gaming_hidpp_ls_1_3}, | |
| 2142 | - | { /* Logitech Bolt receiver (0xc548) */ | |
| 2143 | - | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2144 | - | USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER), | |
| 2145 | - | .driver_data = recvr_type_bolt}, | |
| 2146 | 2106 | { /* Logitech lightspeed receiver (0xc54d) */ | |
| 2147 | 2107 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, | |
| 2148 | 2108 | USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_4), | |
modified drivers/hid/hid-logitech-hidpp.c
| @@ -988,8 +988,7 @@ static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) | |||
| 988 | 988 | } | |
| 989 | 989 | ||
| 990 | 990 | /* the device might not be connected */ | |
| 991 | - | if (ret == HIDPP_ERROR_CONNECT_FAIL || | |
| 992 | - | ret == HIDPP_ERROR_RESOURCE_ERROR || | |
| 991 | + | if (ret == HIDPP_ERROR_RESOURCE_ERROR || | |
| 993 | 992 | ret == HIDPP_ERROR_UNKNOWN_DEVICE) | |
| 994 | 993 | return -EIO; | |
| 995 | 994 | ||
| @@ -4405,50 +4404,8 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) | |||
| 4405 | 4404 | return ret; | |
| 4406 | 4405 | } | |
| 4407 | 4406 | ||
| 4408 | - | static bool hidpp_is_bolt_child(struct hid_device *hdev) | |
| 4409 | - | { | |
| 4410 | - | struct device *parent = hdev->dev.parent; | |
| 4411 | - | struct hid_device *receiver_hdev; | |
| 4412 | - | ||
| 4413 | - | if (!parent) | |
| 4414 | - | return false; | |
| 4415 | - | ||
| 4416 | - | receiver_hdev = to_hid_device(parent); | |
| 4417 | - | return receiver_hdev->vendor == USB_VENDOR_ID_LOGITECH && | |
| 4418 | - | receiver_hdev->product == USB_DEVICE_ID_LOGITECH_BOLT_RECEIVER; | |
| 4419 | - | } | |
| 4420 | - | ||
| 4421 | - | static int hidpp_bolt_init(struct hidpp_device *hidpp) | |
| 4422 | - | { | |
| 4423 | - | struct hid_device *hdev = hidpp->hid_dev; | |
| 4424 | - | char *name; | |
| 4425 | - | int ret; | |
| 4426 | - | ||
| 4427 | - | ret = hidpp_serial_init(hidpp); | |
| 4428 | - | if (ret) | |
| 4429 | - | return ret; | |
| 4430 | - | ||
| 4431 | - | name = hidpp_get_device_name(hidpp); | |
| 4432 | - | if (!name) | |
| 4433 | - | return -EIO; | |
| 4434 | - | ||
| 4435 | - | snprintf(hdev->name, sizeof(hdev->name), "%s", name); | |
| 4436 | - | dbg_hid("HID++ Bolt: Got name: %s\n", name); | |
| 4437 | - | ||
| 4438 | - | kfree(name); | |
| 4439 | - | return 0; | |
| 4440 | - | } | |
| 4441 | - | ||
| 4442 | - | static int hidpp_receiver_init(struct hidpp_device *hidpp) | |
| 4443 | - | { | |
| 4444 | - | if (hidpp_is_bolt_child(hidpp->hid_dev)) | |
| 4445 | - | return hidpp_bolt_init(hidpp); | |
| 4446 | - | ||
| 4447 | - | return hidpp_unifying_init(hidpp); | |
| 4448 | - | } | |
| 4449 | - | ||
| 4450 | 4407 | /* Get name + serial for USB and Bluetooth HID++ devices */ | |
| 4451 | - | static void hidpp_non_receiver_init(struct hidpp_device *hidpp) | |
| 4408 | + | static void hidpp_non_unifying_init(struct hidpp_device *hidpp) | |
| 4452 | 4409 | { | |
| 4453 | 4410 | struct hid_device *hdev = hidpp->hid_dev; | |
| 4454 | 4411 | char *name; | |
| @@ -4800,9 +4757,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 4800 | 4757 | ||
| 4801 | 4758 | /* Get name + serial, store in hdev->name + hdev->uniq */ | |
| 4802 | 4759 | if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE) | |
| 4803 | - | hidpp_receiver_init(hidpp); | |
| 4760 | + | hidpp_unifying_init(hidpp); | |
| 4804 | 4761 | else | |
| 4805 | - | hidpp_non_receiver_init(hidpp); | |
| 4762 | + | hidpp_non_unifying_init(hidpp); | |
| 4806 | 4763 | ||
| 4807 | 4764 | if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) | |
| 4808 | 4765 | connect_mask &= ~HID_CONNECT_HIDINPUT; | |
| @@ -4924,6 +4881,8 @@ static const struct hid_device_id hidpp_devices[] = { | |||
| 4924 | 4881 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC08D) }, | |
| 4925 | 4882 | { /* Logitech G502 X Plus Wireless Gaming Mouse over USB */ | |
| 4926 | 4883 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC095) }, | |
| 4884 | + | { /* Logitech G502 X Lightspeed Wireless Gaming Mouse over USB */ | |
| 4885 | + | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC098) }, | |
| 4927 | 4886 | { /* Logitech G703 Gaming Mouse over USB */ | |
| 4928 | 4887 | HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC087) }, | |
| 4929 | 4888 | { /* Logitech G703 Hero Gaming Mouse over USB */ | |
modified drivers/hid/hid-multitouch.c
| @@ -79,6 +79,7 @@ MODULE_LICENSE("GPL"); | |||
| 79 | 79 | #define MT_QUIRK_APPLE_TOUCHBAR BIT(23) | |
| 80 | 80 | #define MT_QUIRK_YOGABOOK9I BIT(24) | |
| 81 | 81 | #define MT_QUIRK_KEEP_LATENCY_ON_CLOSE BIT(25) | |
| 82 | + | #define MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH BIT(26) | |
| 82 | 83 | ||
| 83 | 84 | #define MT_INPUTMODE_TOUCHSCREEN 0x02 | |
| 84 | 85 | #define MT_INPUTMODE_TOUCHPAD 0x03 | |
| @@ -235,6 +236,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app); | |||
| 235 | 236 | #define MT_CLS_APPLE_TOUCHBAR 0x0114 | |
| 236 | 237 | #define MT_CLS_YOGABOOK9I 0x0115 | |
| 237 | 238 | #define MT_CLS_EGALAX_P80H84 0x0116 | |
| 239 | + | #define MT_CLS_ASUS_ROG_Z13_FOLIO 0x0117 | |
| 238 | 240 | #define MT_CLS_SIS 0x0457 | |
| 239 | 241 | ||
| 240 | 242 | #define MT_DEFAULT_MAXCONTACT 10 | |
| @@ -405,6 +407,16 @@ static const struct mt_class mt_classes[] = { | |||
| 405 | 407 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
| 406 | 408 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
| 407 | 409 | MT_QUIRK_ASUS_CUSTOM_UP }, | |
| 410 | + | { .name = MT_CLS_ASUS_ROG_Z13_FOLIO, | |
| 411 | + | .quirks = MT_QUIRK_ALWAYS_VALID | | |
| 412 | + | MT_QUIRK_IGNORE_DUPLICATES | | |
| 413 | + | MT_QUIRK_HOVERING | | |
| 414 | + | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
| 415 | + | MT_QUIRK_STICKY_FINGERS | | |
| 416 | + | MT_QUIRK_WIN8_PTP_BUTTONS | | |
| 417 | + | MT_QUIRK_CONFIDENCE | | |
| 418 | + | MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH, | |
| 419 | + | .export_all_inputs = true }, | |
| 408 | 420 | { .name = MT_CLS_VTL, | |
| 409 | 421 | .quirks = MT_QUIRK_ALWAYS_VALID | | |
| 410 | 422 | MT_QUIRK_CONTACT_CNT_ACCURATE | | |
| @@ -507,6 +519,7 @@ static const struct attribute_group mt_attribute_group = { | |||
| 507 | 519 | ||
| 508 | 520 | static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) | |
| 509 | 521 | { | |
| 522 | + | struct mt_device *td = hid_get_drvdata(hdev); | |
| 510 | 523 | int ret; | |
| 511 | 524 | u32 size = hid_report_len(report); | |
| 512 | 525 | u8 *buf; | |
| @@ -528,8 +541,14 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) | |||
| 528 | 541 | dev_warn(&hdev->dev, "failed to fetch feature %d\n", | |
| 529 | 542 | report->id); | |
| 530 | 543 | } else { | |
| 531 | - | /* The report ID in the request and the response should match */ | |
| 532 | - | if (report->id != buf[0]) { | |
| 544 | + | /* | |
| 545 | + | * The report ID in the request and the response should match. | |
| 546 | + | * Some firmware (e.g. the ASUS ROG Z13 Folio | |
| 547 | + | * touchpad) returns a mismatched ID on this specific fetch; | |
| 548 | + | * tolerate it only for devices explicitly flagged as such. | |
| 549 | + | */ | |
| 550 | + | if (report->id != buf[0] && | |
| 551 | + | !(td->mtclass.quirks & MT_QUIRK_IGNORE_FEATURE_ID_MISMATCH)) { | |
| 533 | 552 | hid_err(hdev, "Returned feature report did not match the request\n"); | |
| 534 | 553 | goto free; | |
| 535 | 554 | } | |
| @@ -2230,7 +2249,7 @@ static void mt_remove(struct hid_device *hdev) | |||
| 2230 | 2249 | { | |
| 2231 | 2250 | struct mt_device *td = hid_get_drvdata(hdev); | |
| 2232 | 2251 | ||
| 2233 | - | timer_delete_sync(&td->release_timer); | |
| 2252 | + | timer_shutdown_sync(&td->release_timer); | |
| 2234 | 2253 | ||
| 2235 | 2254 | sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); | |
| 2236 | 2255 | hid_hw_stop(hdev); | |
| @@ -2715,6 +2734,12 @@ static const struct hid_device_id mt_devices[] = { | |||
| 2715 | 2734 | HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8, | |
| 2716 | 2735 | I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288) }, | |
| 2717 | 2736 | ||
| 2737 | + | /* Asus ROG Flow Z13 (2025) GZ302EA keyboard-cover touchpad */ | |
| 2738 | + | { .driver_data = MT_CLS_ASUS_ROG_Z13_FOLIO, | |
| 2739 | + | HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8, | |
| 2740 | + | USB_VENDOR_ID_ASUSTEK, | |
| 2741 | + | USB_DEVICE_ID_ASUSTEK_ROG_Z13_FOLIO) }, | |
| 2742 | + | ||
| 2718 | 2743 | /* Generic MT device */ | |
| 2719 | 2744 | { HID_DEVICE(HID_BUS_ANY, HID_GROUP_MULTITOUCH, HID_ANY_ID, HID_ANY_ID) }, | |
| 2720 | 2745 | ||
modified drivers/hid/hid-oxp.c
| @@ -1552,9 +1552,9 @@ static int oxp_hid_probe(struct hid_device *hdev, | |||
| 1552 | 1552 | ||
| 1553 | 1553 | static void oxp_hid_remove(struct hid_device *hdev) | |
| 1554 | 1554 | { | |
| 1555 | - | cancel_delayed_work(&drvdata.oxp_rgb_queue); | |
| 1556 | - | cancel_delayed_work(&drvdata.oxp_btn_queue); | |
| 1557 | - | cancel_delayed_work(&drvdata.oxp_mcu_init); | |
| 1555 | + | cancel_delayed_work_sync(&drvdata.oxp_rgb_queue); | |
| 1556 | + | cancel_delayed_work_sync(&drvdata.oxp_btn_queue); | |
| 1557 | + | cancel_delayed_work_sync(&drvdata.oxp_mcu_init); | |
| 1558 | 1558 | hid_hw_close(hdev); | |
| 1559 | 1559 | hid_hw_stop(hdev); | |
| 1560 | 1560 | } | |
modified drivers/hid/hid-quirks.c
| @@ -186,6 +186,7 @@ static const struct hid_device_id hid_quirks[] = { | |||
| 186 | 186 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, | |
| 187 | 187 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_PRO), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, | |
| 188 | 188 | { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X65), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, | |
| 189 | + | { HID_USB_DEVICE(USB_VENDOR_ID_SDINNOVATION, USB_DEVICE_ID_SDINNOVATION_GAMING_KBD), HID_QUIRK_ALWAYS_POLL }, | |
| 189 | 190 | { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD2), HID_QUIRK_NO_INIT_REPORTS }, | |
| 190 | 191 | { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS }, | |
| 191 | 192 | { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET }, | |
| @@ -425,13 +426,14 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 425 | 426 | #endif | |
| 426 | 427 | #if IS_ENABLED(CONFIG_HID_ELECOM) | |
| 427 | 428 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, | |
| 428 | - | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XGL20DLBK) }, | |
| 429 | + | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XGL20DLBK) }, | |
| 429 | 430 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1MRBK_01AC) }, | |
| 430 | 431 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK_00FB) }, | |
| 431 | 432 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK_018F) }, | |
| 432 | 433 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_00FC) }, | |
| 433 | 434 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK_018C) }, | |
| 434 | - | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) }, | |
| 435 | + | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_00FD) }, | |
| 436 | + | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK_018E) }, | |
| 435 | 437 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) }, | |
| 436 | 438 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) }, | |
| 437 | 439 | { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT2DRBK) }, | |
| @@ -751,6 +753,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
| 751 | 753 | #if IS_ENABLED(CONFIG_HID_STEELSERIES) | |
| 752 | 754 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) }, | |
| 753 | 755 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_ARCTIS_1_X) }, | |
| 756 | + | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_ARCTIS_7_2018) }, | |
| 754 | 757 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_ARCTIS_9) }, | |
| 755 | 758 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_5_X) }, | |
| 756 | 759 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_ARCTIS_NOVA_7) }, | |
modified drivers/hid/hid-roccat.c
| @@ -344,8 +344,6 @@ int roccat_connect(const struct class *klass, struct hid_device *hid, int report | |||
| 344 | 344 | return temp; | |
| 345 | 345 | } | |
| 346 | 346 | ||
| 347 | - | mutex_unlock(&devices_lock); | |
| 348 | - | ||
| 349 | 347 | init_waitqueue_head(&device->wait); | |
| 350 | 348 | INIT_LIST_HEAD(&device->readers); | |
| 351 | 349 | mutex_init(&device->readers_lock); | |
| @@ -356,6 +354,7 @@ int roccat_connect(const struct class *klass, struct hid_device *hid, int report | |||
| 356 | 354 | device->cbuf_end = 0; | |
| 357 | 355 | device->report_size = report_size; | |
| 358 | 356 | ||
| 357 | + | mutex_unlock(&devices_lock); | |
| 359 | 358 | return minor; | |
| 360 | 359 | } | |
| 361 | 360 | EXPORT_SYMBOL_GPL(roccat_connect); | |
| @@ -369,15 +368,12 @@ void roccat_disconnect(int minor) | |||
| 369 | 368 | ||
| 370 | 369 | mutex_lock(&devices_lock); | |
| 371 | 370 | device = devices[minor]; | |
| 372 | - | mutex_unlock(&devices_lock); | |
| 373 | 371 | ||
| 374 | 372 | device->exist = 0; /* TODO exist maybe not needed */ | |
| 375 | 373 | ||
| 376 | 374 | device_destroy(device->dev->class, MKDEV(roccat_major, minor)); | |
| 377 | 375 | ||
| 378 | - | mutex_lock(&devices_lock); | |
| 379 | 376 | devices[minor] = NULL; | |
| 380 | - | mutex_unlock(&devices_lock); | |
| 381 | 377 | ||
| 382 | 378 | if (device->open) { | |
| 383 | 379 | hid_hw_close(device->hid); | |
| @@ -385,6 +381,8 @@ void roccat_disconnect(int minor) | |||
| 385 | 381 | } else { | |
| 386 | 382 | roccat_free_device(device); | |
| 387 | 383 | } | |
| 384 | + | ||
| 385 | + | mutex_unlock(&devices_lock); | |
| 388 | 386 | } | |
| 389 | 387 | EXPORT_SYMBOL_GPL(roccat_disconnect); | |
| 390 | 388 | ||
modified drivers/hid/hid-steelseries-arctis.c
| @@ -101,6 +101,19 @@ static int steelseries_arctis_1_request_status(struct hid_device *hdev) | |||
| 101 | 101 | return steelseries_send_output_report(hdev, data, sizeof(data)); | |
| 102 | 102 | } | |
| 103 | 103 | ||
| 104 | + | static int steelseries_arctis_7_2018_request_status(struct hid_device *hdev) | |
| 105 | + | { | |
| 106 | + | const u8 connection[] = { 0x06, 0x14 }; | |
| 107 | + | const u8 battery[] = { 0x06, 0x18 }; | |
| 108 | + | int ret; | |
| 109 | + | ||
| 110 | + | ret = steelseries_send_output_report(hdev, connection, sizeof(connection)); | |
| 111 | + | if (ret) | |
| 112 | + | return ret; | |
| 113 | + | ||
| 114 | + | return steelseries_send_output_report(hdev, battery, sizeof(battery)); | |
| 115 | + | } | |
| 116 | + | ||
| 104 | 117 | static int steelseries_arctis_9_request_status(struct hid_device *hdev) | |
| 105 | 118 | { | |
| 106 | 119 | const u8 data[] = { 0x00, 0x20 }; | |
| @@ -152,6 +165,27 @@ static void steelseries_arctis_1_parse_status(struct steelseries_device *sd, | |||
| 152 | 165 | sd->battery_capacity = data[3]; | |
| 153 | 166 | } | |
| 154 | 167 | ||
| 168 | + | static void steelseries_arctis_7_2018_parse_status(struct steelseries_device *sd, | |
| 169 | + | u8 *data, int size) | |
| 170 | + | { | |
| 171 | + | if (size < 3 || data[0] != 0x06) | |
| 172 | + | return; | |
| 173 | + | ||
| 174 | + | switch (data[1]) { | |
| 175 | + | case 0x14: | |
| 176 | + | /* 0x03 means that the headset is connected to the transmitter. */ | |
| 177 | + | sd->headset_connected = data[2] == 0x03; | |
| 178 | + | break; | |
| 179 | + | case 0x18: | |
| 180 | + | if (!sd->headset_connected) | |
| 181 | + | break; | |
| 182 | + | ||
| 183 | + | /* The Arctis 7 sometimes overreports battery. Cap to 100. */ | |
| 184 | + | sd->battery_capacity = steelseries_map_capacity(data[2], 0, 100); | |
| 185 | + | break; | |
| 186 | + | } | |
| 187 | + | } | |
| 188 | + | ||
| 155 | 189 | static void steelseries_arctis_9_parse_status(struct steelseries_device *sd, | |
| 156 | 190 | u8 *data, int size) | |
| 157 | 191 | { | |
| @@ -232,6 +266,13 @@ static const struct steelseries_device_info arctis_1_info = { | |||
| 232 | 266 | .parse_status = steelseries_arctis_1_parse_status, | |
| 233 | 267 | }; | |
| 234 | 268 | ||
| 269 | + | static const struct steelseries_device_info arctis_7_2018_info = { | |
| 270 | + | .sync_interface = 5, | |
| 271 | + | .capabilities = SS_CAP_BATTERY, | |
| 272 | + | .request_status = steelseries_arctis_7_2018_request_status, | |
| 273 | + | .parse_status = steelseries_arctis_7_2018_parse_status, | |
| 274 | + | }; | |
| 275 | + | ||
| 235 | 276 | static const struct steelseries_device_info arctis_9_info = { | |
| 236 | 277 | .sync_interface = 0, | |
| 237 | 278 | .capabilities = SS_CAP_BATTERY, | |
| @@ -653,6 +694,9 @@ static const struct hid_device_id steelseries_arctis_devices[] = { | |||
| 653 | 694 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, | |
| 654 | 695 | USB_DEVICE_ID_STEELSERIES_ARCTIS_1_X), | |
| 655 | 696 | .driver_data = (unsigned long)&arctis_1_info }, | |
| 697 | + | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, | |
| 698 | + | USB_DEVICE_ID_STEELSERIES_ARCTIS_7_2018), | |
| 699 | + | .driver_data = (unsigned long)&arctis_7_2018_info }, | |
| 656 | 700 | { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, | |
| 657 | 701 | USB_DEVICE_ID_STEELSERIES_ARCTIS_9), | |
| 658 | 702 | .driver_data = (unsigned long)&arctis_9_info }, | |
modified drivers/hid/hid-universal-pidff.c
| @@ -187,6 +187,7 @@ static const struct hid_device_id universal_pidff_devices[] = { | |||
| 187 | 187 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) }, | |
| 188 | 188 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_LA_PRIMA) }, | |
| 189 | 189 | { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_TONY_KANAAN) }, | |
| 190 | + | { HID_USB_DEVICE(USB_VENDOR_ID_TURTLE_BEACH, USB_DEVICE_ID_TB_VELOCITYONE_RACE)}, | |
| 190 | 191 | {} | |
| 191 | 192 | }; | |
| 192 | 193 | MODULE_DEVICE_TABLE(hid, universal_pidff_devices); | |
modified drivers/hid/hid-winwing.c
| @@ -315,7 +315,8 @@ static void winwing_haptic_rumble_cb(struct work_struct *work) | |||
| 315 | 315 | static int winwing_play_effect(struct input_dev *dev, void *context, | |
| 316 | 316 | struct ff_effect *effect) | |
| 317 | 317 | { | |
| 318 | - | struct winwing_drv_data *data = (struct winwing_drv_data *) context; | |
| 318 | + | struct hid_device *hdev = input_get_drvdata(dev); | |
| 319 | + | struct winwing_drv_data *data = hid_get_drvdata(hdev); | |
| 319 | 320 | ||
| 320 | 321 | if (effect->type != FF_RUMBLE) | |
| 321 | 322 | return 0; | |
| @@ -342,7 +343,12 @@ static int winwing_init_ff(struct hid_device *hdev, struct hid_input *hidinput) | |||
| 342 | 343 | ||
| 343 | 344 | input_set_capability(hidinput->input, EV_FF, FF_RUMBLE); | |
| 344 | 345 | ||
| 345 | - | return input_ff_create_memless(hidinput->input, data, | |
| 346 | + | /* | |
| 347 | + | * input_ff_create_memless() takes ownership of the context pointer | |
| 348 | + | * and frees it on teardown; do not hand it the devm-managed drvdata. | |
| 349 | + | * winwing_play_effect() fetches it from the input device instead. | |
| 350 | + | */ | |
| 351 | + | return input_ff_create_memless(hidinput->input, NULL, | |
| 346 | 352 | winwing_play_effect); | |
| 347 | 353 | } | |
| 348 | 354 | ||
modified drivers/hid/i2c-hid/i2c-hid-core.c
| @@ -123,9 +123,11 @@ static const struct i2c_hid_quirks { | |||
| 123 | 123 | __u32 quirks; | |
| 124 | 124 | } i2c_hid_quirks[] = { | |
| 125 | 125 | { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, | |
| 126 | - | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 126 | + | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET | I2C_HID_QUIRK_BAD_INPUT_SIZE }, | |
| 127 | 127 | { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15, | |
| 128 | 128 | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 129 | + | { USB_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_LENOVO_YOGA_SLIM_7X_G11_KEYBOARD, | |
| 130 | + | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 129 | 131 | { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118, | |
| 130 | 132 | I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, | |
| 131 | 133 | { USB_VENDOR_ID_ALPS_JP, HID_ANY_ID, | |
modified drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
| @@ -606,7 +606,8 @@ static int quicki2c_alloc_report_buf(struct quicki2c_device *qcdev) | |||
| 606 | 606 | */ | |
| 607 | 607 | max_report_len = max(le16_to_cpu(qcdev->dev_desc.max_input_len), SZ_4K); | |
| 608 | 608 | ||
| 609 | - | qcdev->input_buf = devm_kzalloc(qcdev->dev, max_report_len, GFP_KERNEL); | |
| 609 | + | qcdev->input_buf = devm_kzalloc(qcdev->dev, | |
| 610 | + | HIDI2C_PACKET_LEN(max_report_len), GFP_KERNEL); | |
| 610 | 611 | if (!qcdev->input_buf) | |
| 611 | 612 | return -ENOMEM; | |
| 612 | 613 | ||
| @@ -616,7 +617,8 @@ static int quicki2c_alloc_report_buf(struct quicki2c_device *qcdev) | |||
| 616 | 617 | max_report_len = max(le16_to_cpu(qcdev->dev_desc.max_output_len), | |
| 617 | 618 | max_report_len); | |
| 618 | 619 | ||
| 619 | - | qcdev->report_buf = devm_kzalloc(qcdev->dev, max_report_len, GFP_KERNEL); | |
| 620 | + | qcdev->report_buf = devm_kzalloc(qcdev->dev, | |
| 621 | + | HIDI2C_PACKET_LEN(max_report_len), GFP_KERNEL); | |
| 620 | 622 | if (!qcdev->report_buf) | |
| 621 | 623 | return -ENOMEM; | |
| 622 | 624 | ||
modified drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c
| @@ -552,7 +552,8 @@ static int quickspi_alloc_report_buf(struct quickspi_device *qsdev) | |||
| 552 | 552 | max_input_len = max(le16_to_cpu(qsdev->dev_desc.rep_desc_len), | |
| 553 | 553 | le16_to_cpu(qsdev->dev_desc.max_input_len)); | |
| 554 | 554 | ||
| 555 | - | qsdev->input_buf = devm_kzalloc(qsdev->dev, max_input_len, GFP_KERNEL); | |
| 555 | + | qsdev->input_buf = devm_kzalloc(qsdev->dev, | |
| 556 | + | HIDSPI_INPUT_BODY_SIZE(max_input_len), GFP_KERNEL); | |
| 556 | 557 | if (!qsdev->input_buf) | |
| 557 | 558 | return -ENOMEM; | |
| 558 | 559 | ||
modified drivers/hid/wacom_sys.c
| @@ -113,8 +113,9 @@ static int wacom_wac_pen_serial_enforce(struct hid_device *hdev, | |||
| 113 | 113 | ||
| 114 | 114 | /* Queue events which have invalid tool type or serial number */ | |
| 115 | 115 | for (i = 0; i < report->maxfield; i++) { | |
| 116 | - | for (j = 0; j < report->field[i]->maxusage; j++) { | |
| 117 | - | struct hid_field *field = report->field[i]; | |
| 116 | + | struct hid_field *field = report->field[i]; | |
| 117 | + | ||
| 118 | + | for (j = 0; j < field->report_count; j++) { | |
| 118 | 119 | struct hid_usage *usage = &field->usage[j]; | |
| 119 | 120 | unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid); | |
| 120 | 121 | unsigned int offset; | |
modified drivers/hwmon/cgbc-hwmon.c
| @@ -41,45 +41,60 @@ enum cgbc_sensor_types { | |||
| 41 | 41 | ||
| 42 | 42 | static const char * const cgbc_hwmon_labels_temp[] = { | |
| 43 | 43 | "CPU Temperature", | |
| 44 | - | "Box Temperature", | |
| 44 | + | "Case Temperature", | |
| 45 | 45 | "Ambient Temperature", | |
| 46 | - | "Board Temperature", | |
| 47 | - | "Carrier Temperature", | |
| 48 | - | "Chipset Temperature", | |
| 49 | - | "Video Temperature", | |
| 46 | + | "CPU Board Temperature", | |
| 47 | + | "Carrier Board Temperature", | |
| 48 | + | "System Chipset Temperature", | |
| 49 | + | "Video Controller/Board Temperature", | |
| 50 | 50 | "Other Temperature", | |
| 51 | - | "TOPDIM Temperature", | |
| 52 | - | "BOTTOMDIM Temperature", | |
| 51 | + | "Top DIMM 0 Temperature", | |
| 52 | + | "Bottom DIMM 0 Temperature", | |
| 53 | + | "Alternate Board Temperature", | |
| 54 | + | "Top DIMM 1 Temperature", | |
| 55 | + | "Top DIMM 2 Temperature", | |
| 56 | + | "Top DIMM 3 Temperature", | |
| 57 | + | "Top DIMM 4 Temperature", | |
| 58 | + | "Top DIMM 5 Temperature", | |
| 59 | + | "Top DIMM 6 Temperature", | |
| 60 | + | "Top DIMM 7 Temperature", | |
| 61 | + | "Bottom DIMM 1 Temperature", | |
| 53 | 62 | }; | |
| 54 | 63 | ||
| 64 | + | static const char * const cgbc_hwmon_labels_in[] = { | |
| 65 | + | "CPU Core Voltage", | |
| 66 | + | "DC Runtime Voltage", | |
| 67 | + | "DC Standby Voltage", | |
| 68 | + | "CMOS Battery Voltage", | |
| 69 | + | "Battery Supply Voltage", | |
| 70 | + | "AC Voltage", | |
| 71 | + | "Other Voltage", | |
| 72 | + | "5V Runtime Voltage", | |
| 73 | + | "5V Standby Voltage", | |
| 74 | + | "3V3 Runtime Voltage", | |
| 75 | + | "3V3 Standby Voltage", | |
| 76 | + | "VCore A Voltage", | |
| 77 | + | "VCore B Voltage", | |
| 78 | + | "12V Runtime Voltage", | |
| 79 | + | "12V Standby Voltage", | |
| 80 | + | }; | |
| 81 | + | ||
| 82 | + | /* | |
| 83 | + | * Current sensors are a bit special, they don't have consecutive IDs like | |
| 84 | + | * other types of sensors. So they need to be defined explicitly. | |
| 85 | + | */ | |
| 55 | 86 | static const struct { | |
| 56 | - | enum hwmon_sensor_types type; | |
| 57 | 87 | const char *label; | |
| 58 | - | } cgbc_hwmon_labels_in[] = { | |
| 59 | - | { hwmon_in, "CPU Voltage" }, | |
| 60 | - | { hwmon_in, "DC Runtime Voltage" }, | |
| 61 | - | { hwmon_in, "DC Standby Voltage" }, | |
| 62 | - | { hwmon_in, "CMOS Battery Voltage" }, | |
| 63 | - | { hwmon_in, "Battery Voltage" }, | |
| 64 | - | { hwmon_in, "AC Voltage" }, | |
| 65 | - | { hwmon_in, "Other Voltage" }, | |
| 66 | - | { hwmon_in, "5V Voltage" }, | |
| 67 | - | { hwmon_in, "5V Standby Voltage" }, | |
| 68 | - | { hwmon_in, "3V3 Voltage" }, | |
| 69 | - | { hwmon_in, "3V3 Standby Voltage" }, | |
| 70 | - | { hwmon_in, "VCore A Voltage" }, | |
| 71 | - | { hwmon_in, "VCore B Voltage" }, | |
| 72 | - | { hwmon_in, "12V Voltage" }, | |
| 73 | - | { hwmon_curr, "DC Current" }, | |
| 74 | - | { hwmon_curr, "5V Current" }, | |
| 75 | - | { hwmon_curr, "12V Current" }, | |
| 88 | + | int id; | |
| 89 | + | } cgbc_hwmon_labels_curr[] = { | |
| 90 | + | { "DC Runtime Current", 0x12 }, | |
| 91 | + | { "5V Runtime Current", 0x18 }, | |
| 92 | + | { "12V Runtime Current", 0x1E }, | |
| 76 | 93 | }; | |
| 77 | 94 | ||
| 78 | - | #define CGBC_HWMON_NB_IN_SENSORS 14 | |
| 79 | - | ||
| 80 | 95 | static const char * const cgbc_hwmon_labels_fan[] = { | |
| 81 | 96 | "CPU Fan", | |
| 82 | - | "Box Fan", | |
| 97 | + | "Case Fan", | |
| 83 | 98 | "Ambient Fan", | |
| 84 | 99 | "Chipset Fan", | |
| 85 | 100 | "Video Fan", | |
| @@ -114,7 +129,8 @@ static int cgbc_hwmon_probe_sensors(struct device *dev, struct cgbc_hwmon_data * | |||
| 114 | 129 | ||
| 115 | 130 | for (i = 0; i < nb_sensors; i++) { | |
| 116 | 131 | enum cgbc_sensor_types type; | |
| 117 | - | unsigned int channel; | |
| 132 | + | unsigned int channel, id; | |
| 133 | + | int j; | |
| 118 | 134 | ||
| 119 | 135 | /* | |
| 120 | 136 | * No need to request data for the first sensor. | |
| @@ -128,32 +144,49 @@ static int cgbc_hwmon_probe_sensors(struct device *dev, struct cgbc_hwmon_data * | |||
| 128 | 144 | } | |
| 129 | 145 | ||
| 130 | 146 | type = FIELD_GET(CGBC_HWMON_TYPE_MASK, data[1]); | |
| 131 | - | channel = FIELD_GET(CGBC_HWMON_ID_MASK, data[1]) - 1; | |
| 147 | + | id = FIELD_GET(CGBC_HWMON_ID_MASK, data[1]); | |
| 148 | + | channel = id - 1; | |
| 132 | 149 | ||
| 133 | 150 | if (type == CGBC_HWMON_TYPE_TEMP && channel < ARRAY_SIZE(cgbc_hwmon_labels_temp)) { | |
| 134 | 151 | sensor->type = hwmon_temp; | |
| 135 | 152 | sensor->label = cgbc_hwmon_labels_temp[channel]; | |
| 136 | - | } else if (type == CGBC_HWMON_TYPE_IN && | |
| 137 | - | channel < ARRAY_SIZE(cgbc_hwmon_labels_in)) { | |
| 153 | + | } else if (type == CGBC_HWMON_TYPE_IN) { | |
| 138 | 154 | /* | |
| 139 | 155 | * The Board Controller doesn't differentiate current and voltage sensors. | |
| 140 | - | * Get the sensor type from cgbc_hwmon_labels_in[channel].type instead. | |
| 156 | + | * First check if it is a current sensor. | |
| 141 | 157 | */ | |
| 142 | - | sensor->type = cgbc_hwmon_labels_in[channel].type; | |
| 143 | - | sensor->label = cgbc_hwmon_labels_in[channel].label; | |
| 158 | + | for (j = 0; j < ARRAY_SIZE(cgbc_hwmon_labels_curr); j++) { | |
| 159 | + | if (id == cgbc_hwmon_labels_curr[j].id) { | |
| 160 | + | sensor->type = hwmon_curr; | |
| 161 | + | sensor->label = cgbc_hwmon_labels_curr[j].label; | |
| 162 | + | channel = j; | |
| 163 | + | } | |
| 164 | + | } | |
| 165 | + | ||
| 166 | + | /* If it's not a current sensor, it may be a voltage sensor. */ | |
| 167 | + | if (!sensor->label && channel < ARRAY_SIZE(cgbc_hwmon_labels_in)) { | |
| 168 | + | sensor->type = hwmon_in; | |
| 169 | + | sensor->label = cgbc_hwmon_labels_in[channel]; | |
| 170 | + | } | |
| 144 | 171 | } else if (type == CGBC_HWMON_TYPE_FAN && | |
| 145 | 172 | channel < ARRAY_SIZE(cgbc_hwmon_labels_fan)) { | |
| 146 | 173 | sensor->type = hwmon_fan; | |
| 147 | 174 | sensor->label = cgbc_hwmon_labels_fan[channel]; | |
| 148 | - | } else { | |
| 149 | - | dev_warn(dev, "Board Controller returned an unknown sensor (type=%d, channel=%d), ignore it", | |
| 150 | - | type, channel); | |
| 175 | + | } | |
| 176 | + | ||
| 177 | + | if (!sensor->label) { | |
| 178 | + | dev_warn(dev, "Board Controller returned an unknown sensor (bc_type=%d, bc_id=%d), ignore it", | |
| 179 | + | type, id); | |
| 151 | 180 | continue; | |
| 152 | 181 | } | |
| 153 | 182 | ||
| 154 | 183 | sensor->active = FIELD_GET(CGBC_HWMON_ACTIVE_BIT, data[1]); | |
| 155 | 184 | sensor->channel = channel; | |
| 156 | 185 | sensor->index = i; | |
| 186 | + | ||
| 187 | + | dev_dbg(dev, "Found sensor: bc_type=%d, bc_id=%d, hwmon_type=%d, hwmon_channel=%d, hwmon_label='%s', active=%d\n", | |
| 188 | + | type, id, sensor->type, sensor->channel, sensor->label, sensor->active); | |
| 189 | + | ||
| 157 | 190 | sensor++; | |
| 158 | 191 | hwmon->nb_sensors++; | |
| 159 | 192 | } | |
| @@ -167,14 +200,6 @@ static struct cgbc_hwmon_sensor *cgbc_hwmon_find_sensor(struct cgbc_hwmon_data * | |||
| 167 | 200 | struct cgbc_hwmon_sensor *sensor = NULL; | |
| 168 | 201 | int i; | |
| 169 | 202 | ||
| 170 | - | /* | |
| 171 | - | * The Board Controller doesn't differentiate current and voltage sensors. | |
| 172 | - | * The channel value (from the Board Controller point of view) shall be computed for current | |
| 173 | - | * sensors. | |
| 174 | - | */ | |
| 175 | - | if (type == hwmon_curr) | |
| 176 | - | channel += CGBC_HWMON_NB_IN_SENSORS; | |
| 177 | - | ||
| 178 | 203 | for (i = 0; i < hwmon->nb_sensors; i++) { | |
| 179 | 204 | if (hwmon->sensors[i].type == type && hwmon->sensors[i].channel == channel) { | |
| 180 | 205 | sensor = &hwmon->sensors[i]; | |
| @@ -240,7 +265,12 @@ static const struct hwmon_channel_info * const cgbc_hwmon_info[] = { | |||
| 240 | 265 | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 241 | 266 | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 242 | 267 | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 243 | - | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL), | |
| 268 | + | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 269 | + | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 270 | + | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 271 | + | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 272 | + | HWMON_T_INPUT | HWMON_T_LABEL, HWMON_T_INPUT | HWMON_T_LABEL, | |
| 273 | + | HWMON_T_INPUT | HWMON_T_LABEL), | |
| 244 | 274 | HWMON_CHANNEL_INFO(in, | |
| 245 | 275 | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| 246 | 276 | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| @@ -248,7 +278,8 @@ static const struct hwmon_channel_info * const cgbc_hwmon_info[] = { | |||
| 248 | 278 | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| 249 | 279 | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| 250 | 280 | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| 251 | - | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL), | |
| 281 | + | HWMON_I_INPUT | HWMON_I_LABEL, HWMON_I_INPUT | HWMON_I_LABEL, | |
| 282 | + | HWMON_I_INPUT | HWMON_I_LABEL), | |
| 252 | 283 | HWMON_CHANNEL_INFO(curr, | |
| 253 | 284 | HWMON_C_INPUT | HWMON_C_LABEL, HWMON_C_INPUT | HWMON_C_LABEL, | |
| 254 | 285 | HWMON_C_INPUT | HWMON_C_LABEL), | |
modified drivers/hwmon/gpio-fan.c
| @@ -68,7 +68,7 @@ static irqreturn_t fan_alarm_irq_handler(int irq, void *dev_id) | |||
| 68 | 68 | ||
| 69 | 69 | schedule_work(&fan_data->alarm_work); | |
| 70 | 70 | ||
| 71 | - | return IRQ_NONE; | |
| 71 | + | return IRQ_HANDLED; | |
| 72 | 72 | } | |
| 73 | 73 | ||
| 74 | 74 | static ssize_t fan1_alarm_show(struct device *dev, | |
| @@ -103,7 +103,7 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data) | |||
| 103 | 103 | ||
| 104 | 104 | irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH); | |
| 105 | 105 | return devm_request_irq(dev, alarm_irq, fan_alarm_irq_handler, | |
| 106 | - | IRQF_SHARED, "GPIO fan alarm", fan_data); | |
| 106 | + | 0, "GPIO fan alarm", fan_data); | |
| 107 | 107 | } | |
| 108 | 108 | ||
| 109 | 109 | /* | |
modified drivers/hwmon/hp-wmi-sensors.c
| @@ -526,14 +526,12 @@ static int check_wobj(const union acpi_object *wobj, | |||
| 526 | 526 | for (prop = 0; prop <= last_prop; prop++) { | |
| 527 | 527 | type = elements[prop].type; | |
| 528 | 528 | valid_type = property_map[prop]; | |
| 529 | - | if (type != valid_type) { | |
| 530 | - | if (type == ACPI_TYPE_BUFFER && | |
| 531 | - | valid_type == ACPI_TYPE_STRING && | |
| 532 | - | is_raw_wmi_string(elements[prop].buffer.pointer, | |
| 533 | - | elements[prop].buffer.length)) | |
| 534 | - | continue; | |
| 529 | + | if (type == ACPI_TYPE_BUFFER && | |
| 530 | + | is_raw_wmi_string(elements[prop].buffer.pointer, | |
| 531 | + | elements[prop].buffer.length)) | |
| 532 | + | type = ACPI_TYPE_STRING; | |
| 533 | + | if (type != valid_type) | |
| 535 | 534 | return -EINVAL; | |
| 536 | - | } | |
| 537 | 535 | } | |
| 538 | 536 | ||
| 539 | 537 | return 0; | |
| @@ -579,6 +577,7 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, | |||
| 579 | 577 | int prop = HP_WMI_PROPERTY_NAME; | |
| 580 | 578 | acpi_object_type valid_type; | |
| 581 | 579 | union acpi_object *elements; | |
| 580 | + | union acpi_object *element; | |
| 582 | 581 | u32 elem_count; | |
| 583 | 582 | int last_prop; | |
| 584 | 583 | bool is_new; | |
| @@ -602,13 +601,20 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, | |||
| 602 | 601 | elem_count > HP_WMI_MAX_PROPERTIES) | |
| 603 | 602 | return -EINVAL; | |
| 604 | 603 | ||
| 605 | - | type = elements[HP_WMI_PROPERTY_SIZE].type; | |
| 604 | + | element = &elements[HP_WMI_PROPERTY_SIZE]; | |
| 605 | + | type = element->type; | |
| 606 | 606 | switch (type) { | |
| 607 | 607 | case ACPI_TYPE_INTEGER: | |
| 608 | 608 | is_new = true; | |
| 609 | 609 | last_prop = HP_WMI_PROPERTY_RATE_UNITS; | |
| 610 | 610 | break; | |
| 611 | 611 | ||
| 612 | + | case ACPI_TYPE_BUFFER: | |
| 613 | + | if (!is_raw_wmi_string(element->buffer.pointer, | |
| 614 | + | element->buffer.length)) | |
| 615 | + | return -EINVAL; | |
| 616 | + | fallthrough; | |
| 617 | + | ||
| 612 | 618 | case ACPI_TYPE_STRING: | |
| 613 | 619 | is_new = false; | |
| 614 | 620 | last_prop = HP_WMI_PROPERTY_CURRENT_READING; | |
| @@ -631,6 +637,10 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, | |||
| 631 | 637 | for (i = 0; i < elem_count && prop <= last_prop; i++, prop++) { | |
| 632 | 638 | type = elements[i].type; | |
| 633 | 639 | valid_type = hp_wmi_property_map[prop]; | |
| 640 | + | if (type == ACPI_TYPE_BUFFER && | |
| 641 | + | is_raw_wmi_string(elements[i].buffer.pointer, | |
| 642 | + | elements[i].buffer.length)) | |
| 643 | + | type = ACPI_TYPE_STRING; | |
| 634 | 644 | if (type != valid_type) | |
| 635 | 645 | return -EINVAL; | |
| 636 | 646 | ||
| @@ -651,6 +661,10 @@ static int check_numeric_sensor_wobj(const union acpi_object *wobj, | |||
| 651 | 661 | /* PossibleStates[0] has already been type-checked. */ | |
| 652 | 662 | for (j = 0; i + 1 < elem_count && j + 1 < count; j++) { | |
| 653 | 663 | type = elements[++i].type; | |
| 664 | + | if (type == ACPI_TYPE_BUFFER && | |
| 665 | + | is_raw_wmi_string(elements[i].buffer.pointer, | |
| 666 | + | elements[i].buffer.length)) | |
| 667 | + | type = ACPI_TYPE_STRING; | |
| 654 | 668 | if (type != valid_type) | |
| 655 | 669 | return -EINVAL; | |
| 656 | 670 | } | |
| @@ -1247,7 +1261,9 @@ static int fungible_show(struct seq_file *seqf, enum hp_wmi_property prop) | |||
| 1247 | 1261 | break; | |
| 1248 | 1262 | ||
| 1249 | 1263 | case HP_WMI_PROPERTY_CURRENT_STATE: | |
| 1264 | + | mutex_lock(&state->lock); | |
| 1250 | 1265 | seq_printf(seqf, "%s\n", nsensor->current_state); | |
| 1266 | + | mutex_unlock(&state->lock); | |
| 1251 | 1267 | break; | |
| 1252 | 1268 | ||
| 1253 | 1269 | case HP_WMI_PROPERTY_UNIT_MODIFIER: | |
modified drivers/hwmon/k10temp.c
| @@ -523,7 +523,7 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 523 | 523 | } | |
| 524 | 524 | } else if (boot_cpu_data.x86 == 0x1a) { | |
| 525 | 525 | switch (boot_cpu_data.x86_model) { | |
| 526 | - | case 0x00 ... 0x2f: /* Zen5 Turin */ | |
| 526 | + | case 0x00 ... 0x1f: /* Zen5 Turin */ | |
| 527 | 527 | data->ccd_offset = 0x1F0; | |
| 528 | 528 | k10temp_get_ccd_support(data, 16); | |
| 529 | 529 | break; | |
modified drivers/hwmon/pmbus/pmbus.h
| @@ -242,6 +242,7 @@ enum pmbus_regs { | |||
| 242 | 242 | /* | |
| 243 | 243 | * OPERATION | |
| 244 | 244 | */ | |
| 245 | + | #define PB_OPERATION_CONTROL_V_SRC GENMASK(5, 4) | |
| 245 | 246 | #define PB_OPERATION_CONTROL_ON BIT(7) | |
| 246 | 247 | ||
| 247 | 248 | /* | |
| @@ -386,7 +387,7 @@ enum pmbus_sensor_classes { | |||
| 386 | 387 | }; | |
| 387 | 388 | ||
| 388 | 389 | #define PMBUS_PAGES 32 /* Per PMBus specification */ | |
| 389 | - | #define PMBUS_PHASES 10 /* Maximum number of phases per page */ | |
| 390 | + | #define PMBUS_PHASES 16 /* Maximum number of phases per page */ | |
| 390 | 391 | ||
| 391 | 392 | /* Functionality bit mask */ | |
| 392 | 393 | #define PMBUS_HAVE_VIN BIT(0) | |
modified drivers/hwmon/pmbus/tps53679.c
| @@ -187,7 +187,7 @@ static int tps53676_identify(struct i2c_client *client, | |||
| 187 | 187 | return -EIO; | |
| 188 | 188 | for (i = 0; i < 2 * TPS53676_MAX_PHASES; i += 2) { | |
| 189 | 189 | if (buf[i + 1] & 0x80) { | |
| 190 | - | if (buf[i] & 0x08) | |
| 190 | + | if (buf[i] & BIT(4)) | |
| 191 | 191 | phases_b++; | |
| 192 | 192 | else | |
| 193 | 193 | phases_a++; | |
| @@ -200,6 +200,15 @@ static int tps53676_identify(struct i2c_client *client, | |||
| 200 | 200 | if (phases_b > 0) { | |
| 201 | 201 | info->pages = 2; | |
| 202 | 202 | info->phases[1] = phases_b; | |
| 203 | + | } else { | |
| 204 | + | /* | |
| 205 | + | * pmbus_set_page() does not update the PAGE register on | |
| 206 | + | * single-page devices, so select page 0 explicitly in case | |
| 207 | + | * the boot firmware left the device on another page. | |
| 208 | + | */ | |
| 209 | + | ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); | |
| 210 | + | if (ret < 0) | |
| 211 | + | return ret; | |
| 203 | 212 | } | |
| 204 | 213 | return 0; | |
| 205 | 214 | } | |
modified drivers/hwmon/pwm-fan.c
| @@ -483,7 +483,6 @@ static void pwm_fan_cleanup(void *__ctx) | |||
| 483 | 483 | { | |
| 484 | 484 | struct pwm_fan_ctx *ctx = __ctx; | |
| 485 | 485 | ||
| 486 | - | timer_delete_sync(&ctx->rpm_timer); | |
| 487 | 486 | if (ctx->pwm_shutdown) { | |
| 488 | 487 | ctx->enable_mode = pwm_enable_reg_enable; | |
| 489 | 488 | __set_pwm(ctx, ctx->pwm_shutdown); | |
| @@ -494,6 +493,13 @@ static void pwm_fan_cleanup(void *__ctx) | |||
| 494 | 493 | } | |
| 495 | 494 | } | |
| 496 | 495 | ||
| 496 | + | static void pwm_fan_timer_cleanup(void *__ctx) | |
| 497 | + | { | |
| 498 | + | struct pwm_fan_ctx *ctx = __ctx; | |
| 499 | + | ||
| 500 | + | timer_shutdown_sync(&ctx->rpm_timer); | |
| 501 | + | } | |
| 502 | + | ||
| 497 | 503 | static int pwm_fan_probe(struct platform_device *pdev) | |
| 498 | 504 | { | |
| 499 | 505 | struct thermal_cooling_device *cdev; | |
| @@ -644,6 +650,10 @@ static int pwm_fan_probe(struct platform_device *pdev) | |||
| 644 | 650 | } | |
| 645 | 651 | ||
| 646 | 652 | if (ctx->tach_count > 0) { | |
| 653 | + | ret = devm_add_action_or_reset(dev, pwm_fan_timer_cleanup, ctx); | |
| 654 | + | if (ret) | |
| 655 | + | return ret; | |
| 656 | + | ||
| 647 | 657 | ctx->sample_start = ktime_get(); | |
| 648 | 658 | mod_timer(&ctx->rpm_timer, jiffies + HZ); | |
| 649 | 659 | ||
| @@ -700,6 +710,7 @@ static void pwm_fan_shutdown(struct platform_device *pdev) | |||
| 700 | 710 | { | |
| 701 | 711 | struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev); | |
| 702 | 712 | ||
| 713 | + | pwm_fan_timer_cleanup(ctx); | |
| 703 | 714 | pwm_fan_cleanup(ctx); | |
| 704 | 715 | } | |
| 705 | 716 | ||
modified drivers/hwmon/w83791d.c
| @@ -1415,6 +1415,7 @@ static void w83791d_remove(struct i2c_client *client) | |||
| 1415 | 1415 | struct w83791d_data *data = i2c_get_clientdata(client); | |
| 1416 | 1416 | ||
| 1417 | 1417 | hwmon_device_unregister(data->hwmon_dev); | |
| 1418 | + | sysfs_remove_group(&client->dev.kobj, &w83791d_group_fanpwm45); | |
| 1418 | 1419 | sysfs_remove_group(&client->dev.kobj, &w83791d_group); | |
| 1419 | 1420 | } | |
| 1420 | 1421 | ||
modified drivers/hwmon/w83793.c
| @@ -1928,7 +1928,9 @@ exit_remove: | |||
| 1928 | 1928 | for (i = 0; i < ARRAY_SIZE(w83793_temp); i++) | |
| 1929 | 1929 | device_remove_file(dev, &w83793_temp[i].dev_attr); | |
| 1930 | 1930 | free_mem: | |
| 1931 | - | kfree(data); | |
| 1931 | + | mutex_lock(&watchdog_data_mutex); | |
| 1932 | + | kref_put(&data->kref, w83793_release_resources); | |
| 1933 | + | mutex_unlock(&watchdog_data_mutex); | |
| 1932 | 1934 | exit: | |
| 1933 | 1935 | return err; | |
| 1934 | 1936 | } | |
modified drivers/i2c/busses/i2c-at91-core.c
| @@ -255,6 +255,7 @@ static int at91_twi_probe(struct platform_device *pdev) | |||
| 255 | 255 | if (rc) { | |
| 256 | 256 | pm_runtime_disable(dev->dev); | |
| 257 | 257 | pm_runtime_set_suspended(dev->dev); | |
| 258 | + | at91_twi_dma_release(dev); | |
| 258 | 259 | ||
| 259 | 260 | return rc; | |
| 260 | 261 | } | |
| @@ -270,6 +271,8 @@ static void at91_twi_remove(struct platform_device *pdev) | |||
| 270 | 271 | ||
| 271 | 272 | i2c_del_adapter(&dev->adapter); | |
| 272 | 273 | ||
| 274 | + | at91_twi_dma_release(dev); | |
| 275 | + | ||
| 273 | 276 | pm_runtime_disable(dev->dev); | |
| 274 | 277 | pm_runtime_set_suspended(dev->dev); | |
| 275 | 278 | } | |
modified drivers/i2c/busses/i2c-at91-master.c
| @@ -817,11 +817,21 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) | |||
| 817 | 817 | error: | |
| 818 | 818 | if (ret != -EPROBE_DEFER) | |
| 819 | 819 | dev_info(dev->dev, "can't get DMA channel, continue without DMA support\n"); | |
| 820 | + | at91_twi_dma_release(dev); | |
| 821 | + | return ret; | |
| 822 | + | } | |
| 823 | + | ||
| 824 | + | void at91_twi_dma_release(struct at91_twi_dev *dev) | |
| 825 | + | { | |
| 826 | + | struct at91_twi_dma *dma = &dev->dma; | |
| 827 | + | ||
| 820 | 828 | if (dma->chan_rx) | |
| 821 | 829 | dma_release_channel(dma->chan_rx); | |
| 822 | 830 | if (dma->chan_tx) | |
| 823 | 831 | dma_release_channel(dma->chan_tx); | |
| 824 | - | return ret; | |
| 832 | + | dma->chan_rx = NULL; | |
| 833 | + | dma->chan_tx = NULL; | |
| 834 | + | dev->use_dma = false; | |
| 825 | 835 | } | |
| 826 | 836 | ||
| 827 | 837 | static int at91_init_twi_recovery_gpio(struct platform_device *pdev, | |
| @@ -911,8 +921,14 @@ int at91_twi_probe_master(struct platform_device *pdev, | |||
| 911 | 921 | at91_calc_twi_clock(dev); | |
| 912 | 922 | ||
| 913 | 923 | rc = at91_init_twi_recovery_info(pdev, dev); | |
| 914 | - | if (rc == -EPROBE_DEFER) | |
| 924 | + | if (rc == -EPROBE_DEFER) { | |
| 925 | + | /* | |
| 926 | + | * The DMA channels were already set up above, release them | |
| 927 | + | * before deferring the probe so they are not leaked. | |
| 928 | + | */ | |
| 929 | + | at91_twi_dma_release(dev); | |
| 915 | 930 | return rc; | |
| 931 | + | } | |
| 916 | 932 | ||
| 917 | 933 | dev->adapter.algo = &at91_twi_algorithm; | |
| 918 | 934 | dev->adapter.quirks = &at91_twi_quirks; | |
modified drivers/i2c/busses/i2c-at91.h
| @@ -172,6 +172,7 @@ void at91_twi_irq_restore(struct at91_twi_dev *dev); | |||
| 172 | 172 | void at91_init_twi_bus(struct at91_twi_dev *dev); | |
| 173 | 173 | ||
| 174 | 174 | void at91_init_twi_bus_master(struct at91_twi_dev *dev); | |
| 175 | + | void at91_twi_dma_release(struct at91_twi_dev *dev); | |
| 175 | 176 | int at91_twi_probe_master(struct platform_device *pdev, u32 phy_addr, | |
| 176 | 177 | struct at91_twi_dev *dev); | |
| 177 | 178 | ||
modified drivers/i2c/busses/i2c-imx.c
| @@ -1880,6 +1880,8 @@ static int i2c_imx_probe(struct platform_device *pdev) | |||
| 1880 | 1880 | ||
| 1881 | 1881 | clk_notifier_unregister: | |
| 1882 | 1882 | clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); | |
| 1883 | + | if (i2c_imx->dma) | |
| 1884 | + | i2c_imx_dma_free(i2c_imx); | |
| 1883 | 1885 | free_irq(irq, i2c_imx); | |
| 1884 | 1886 | rpm_disable: | |
| 1885 | 1887 | pm_runtime_put_noidle(&pdev->dev); | |
| @@ -1920,6 +1922,7 @@ static void i2c_imx_remove(struct platform_device *pdev) | |||
| 1920 | 1922 | ||
| 1921 | 1923 | pm_runtime_put_noidle(&pdev->dev); | |
| 1922 | 1924 | pm_runtime_disable(&pdev->dev); | |
| 1925 | + | pm_runtime_dont_use_autosuspend(&pdev->dev); | |
| 1923 | 1926 | } | |
| 1924 | 1927 | ||
| 1925 | 1928 | static int i2c_imx_runtime_suspend(struct device *dev) | |
modified drivers/i2c/busses/i2c-qcom-cci.c
| @@ -497,10 +497,14 @@ static const struct dev_pm_ops qcom_cci_pm = { | |||
| 497 | 497 | SET_RUNTIME_PM_OPS(cci_suspend_runtime, cci_resume_runtime, NULL) | |
| 498 | 498 | }; | |
| 499 | 499 | ||
| 500 | + | static void cci_put_of_node(void *data) | |
| 501 | + | { | |
| 502 | + | of_node_put(data); | |
| 503 | + | } | |
| 504 | + | ||
| 500 | 505 | static int cci_probe(struct platform_device *pdev) | |
| 501 | 506 | { | |
| 502 | 507 | struct device *dev = &pdev->dev; | |
| 503 | - | struct device_node *child; | |
| 504 | 508 | struct resource *r; | |
| 505 | 509 | struct cci *cci; | |
| 506 | 510 | int ret, i; | |
| @@ -516,7 +520,7 @@ static int cci_probe(struct platform_device *pdev) | |||
| 516 | 520 | if (!cci->data) | |
| 517 | 521 | return -ENOENT; | |
| 518 | 522 | ||
| 519 | - | for_each_available_child_of_node(dev->of_node, child) { | |
| 523 | + | for_each_available_child_of_node_scoped(dev->of_node, child) { | |
| 520 | 524 | struct cci_master *master; | |
| 521 | 525 | u32 idx; | |
| 522 | 526 | ||
| @@ -537,6 +541,9 @@ static int cci_probe(struct platform_device *pdev) | |||
| 537 | 541 | master->adap.algo = &cci_algo; | |
| 538 | 542 | master->adap.dev.parent = dev; | |
| 539 | 543 | master->adap.dev.of_node = of_node_get(child); | |
| 544 | + | ret = devm_add_action_or_reset(dev, cci_put_of_node, child); | |
| 545 | + | if (ret) | |
| 546 | + | return ret; | |
| 540 | 547 | master->master = idx; | |
| 541 | 548 | master->cci = cci; | |
| 542 | 549 | ||
| @@ -606,10 +613,8 @@ static int cci_probe(struct platform_device *pdev) | |||
| 606 | 613 | continue; | |
| 607 | 614 | ||
| 608 | 615 | ret = i2c_add_adapter(&cci->master[i].adap); | |
| 609 | - | if (ret < 0) { | |
| 610 | - | of_node_put(cci->master[i].adap.dev.of_node); | |
| 616 | + | if (ret < 0) | |
| 611 | 617 | goto error_i2c; | |
| 612 | - | } | |
| 613 | 618 | } | |
| 614 | 619 | ||
| 615 | 620 | return 0; | |
| @@ -617,10 +622,8 @@ static int cci_probe(struct platform_device *pdev) | |||
| 617 | 622 | error_i2c: | |
| 618 | 623 | ||
| 619 | 624 | for (--i ; i >= 0; i--) { | |
| 620 | - | if (cci->master[i].cci) { | |
| 625 | + | if (cci->master[i].cci) | |
| 621 | 626 | i2c_del_adapter(&cci->master[i].adap); | |
| 622 | - | of_node_put(cci->master[i].adap.dev.of_node); | |
| 623 | - | } | |
| 624 | 627 | } | |
| 625 | 628 | disable_clocks: | |
| 626 | 629 | cci_disable_clocks(cci); | |
| @@ -636,7 +639,6 @@ static void cci_remove(struct platform_device *pdev) | |||
| 636 | 639 | for (i = 0; i < cci->data->num_masters; i++) { | |
| 637 | 640 | if (cci->master[i].cci) { | |
| 638 | 641 | i2c_del_adapter(&cci->master[i].adap); | |
| 639 | - | of_node_put(cci->master[i].adap.dev.of_node); | |
| 640 | 642 | cci_halt(cci, i); | |
| 641 | 643 | } | |
| 642 | 644 | } | |
modified drivers/i2c/busses/i2c-qcom-geni.c
| @@ -82,6 +82,9 @@ enum geni_i2c_err_code { | |||
| 82 | 82 | #define XFER_TIMEOUT HZ | |
| 83 | 83 | #define RST_TIMEOUT HZ | |
| 84 | 84 | ||
| 85 | + | #define GENI_SE_CLK_32MHZ (32 * HZ_PER_MHZ) | |
| 86 | + | #define GENI_SE_CLK_19P2MHZ 19200000UL | |
| 87 | + | ||
| 85 | 88 | struct geni_i2c_desc { | |
| 86 | 89 | bool no_dma_support; | |
| 87 | 90 | unsigned int tx_fifo_depth; | |
| @@ -127,6 +130,7 @@ struct geni_i2c_dev { | |||
| 127 | 130 | spinlock_t lock; | |
| 128 | 131 | u32 clk_freq_out; | |
| 129 | 132 | const struct geni_i2c_clk_fld *clk_fld; | |
| 133 | + | u32 clk_idx; | |
| 130 | 134 | void *dma_buf; | |
| 131 | 135 | size_t xfer_len; | |
| 132 | 136 | dma_addr_t dma_addr; | |
| @@ -197,19 +201,44 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = { | |||
| 197 | 201 | static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c) | |
| 198 | 202 | { | |
| 199 | 203 | const struct geni_i2c_clk_fld *itr; | |
| 204 | + | unsigned long res_freq; | |
| 200 | 205 | ||
| 201 | - | if (clk_get_rate(gi2c->se.clk) == 32 * HZ_PER_MHZ) | |
| 206 | + | /* | |
| 207 | + | * Frequency counter tables are calibrated for a specific source | |
| 208 | + | * clock frequency and are not valid for any multiple of it | |
| 209 | + | * (e.g. 64 MHz, 128 MHz). | |
| 210 | + | * Use exact=true and verify res_freq matches req_freq literally | |
| 211 | + | * to reject harmonics: a 64 MHz clock that divides evenly to | |
| 212 | + | * 32 MHz would pass exact matching but produce double the intended | |
| 213 | + | * I2C frequency with these counter values. | |
| 214 | + | */ | |
| 215 | + | if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_32MHZ, | |
| 216 | + | &gi2c->clk_idx, &res_freq, true) && | |
| 217 | + | res_freq == GENI_SE_CLK_32MHZ) { | |
| 202 | 218 | itr = geni_i2c_clk_map_32mhz; | |
| 203 | - | else | |
| 219 | + | } else if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ, | |
| 220 | + | &gi2c->clk_idx, &res_freq, true) && | |
| 221 | + | res_freq == GENI_SE_CLK_19P2MHZ) { | |
| 204 | 222 | itr = geni_i2c_clk_map_19p2mhz; | |
| 223 | + | } else { | |
| 224 | + | dev_err(gi2c->se.dev, | |
| 225 | + | "Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n"); | |
| 226 | + | return -EINVAL; | |
| 227 | + | } | |
| 205 | 228 | ||
| 206 | 229 | while (itr->clk_freq_out != 0) { | |
| 207 | 230 | if (itr->clk_freq_out == gi2c->clk_freq_out) { | |
| 208 | 231 | gi2c->clk_fld = itr; | |
| 232 | + | dev_dbg(gi2c->se.dev, | |
| 233 | + | "I2C clk selected: freq: %u Hz, clk_idx: %u\n", | |
| 234 | + | gi2c->clk_freq_out, gi2c->clk_idx); | |
| 209 | 235 | return 0; | |
| 210 | 236 | } | |
| 211 | 237 | itr++; | |
| 212 | 238 | } | |
| 239 | + | ||
| 240 | + | dev_err(gi2c->se.dev, "Unsupported I2C output frequency %u Hz\n", gi2c->clk_freq_out); | |
| 241 | + | ||
| 213 | 242 | return -EINVAL; | |
| 214 | 243 | } | |
| 215 | 244 | ||
| @@ -219,7 +248,7 @@ static int qcom_geni_i2c_conf(struct geni_se *se, unsigned long freq) | |||
| 219 | 248 | const struct geni_i2c_clk_fld *itr = gi2c->clk_fld; | |
| 220 | 249 | u32 val; | |
| 221 | 250 | ||
| 222 | - | writel_relaxed(0, gi2c->se.base + SE_GENI_CLK_SEL); | |
| 251 | + | writel_relaxed(gi2c->clk_idx, gi2c->se.base + SE_GENI_CLK_SEL); | |
| 223 | 252 | ||
| 224 | 253 | val = (itr->clk_div << CLK_DIV_SHFT) | SER_CLK_EN; | |
| 225 | 254 | writel_relaxed(val, gi2c->se.base + GENI_SER_M_CLK_CFG); | |
| @@ -974,13 +1003,14 @@ static int geni_i2c_xfer(struct i2c_adapter *adap, | |||
| 974 | 1003 | ||
| 975 | 1004 | ret = gi2c->dev_data->set_rate(&gi2c->se, gi2c->clk_freq_out); | |
| 976 | 1005 | if (ret) | |
| 977 | - | return ret; | |
| 1006 | + | goto out_pm; | |
| 978 | 1007 | ||
| 979 | 1008 | if (gi2c->gpi_mode) | |
| 980 | 1009 | ret = geni_i2c_gpi_xfer(gi2c, msgs, num); | |
| 981 | 1010 | else | |
| 982 | 1011 | ret = geni_i2c_fifo_xfer(gi2c, msgs, num); | |
| 983 | 1012 | ||
| 1013 | + | out_pm: | |
| 984 | 1014 | pm_runtime_put_autosuspend(gi2c->se.dev); | |
| 985 | 1015 | gi2c->cur = NULL; | |
| 986 | 1016 | gi2c->err = 0; | |
| @@ -1111,8 +1141,7 @@ static int geni_i2c_resources_init(struct geni_se *se) | |||
| 1111 | 1141 | ||
| 1112 | 1142 | ret = geni_i2c_clk_map_idx(gi2c); | |
| 1113 | 1143 | if (ret) | |
| 1114 | - | return dev_err_probe(gi2c->se.dev, ret, "Invalid clk frequency %d Hz\n", | |
| 1115 | - | gi2c->clk_freq_out); | |
| 1144 | + | return ret; | |
| 1116 | 1145 | ||
| 1117 | 1146 | return geni_icc_set_bw_ab(&gi2c->se, GENI_DEFAULT_BW, GENI_DEFAULT_BW, | |
| 1118 | 1147 | Bps_to_icc(gi2c->clk_freq_out)); | |
| @@ -1189,8 +1218,10 @@ static int geni_i2c_probe(struct platform_device *pdev) | |||
| 1189 | 1218 | return ret; | |
| 1190 | 1219 | ||
| 1191 | 1220 | ret = i2c_add_adapter(&gi2c->adap); | |
| 1192 | - | if (ret) | |
| 1221 | + | if (ret) { | |
| 1222 | + | release_gpi_dma(gi2c); | |
| 1193 | 1223 | return dev_err_probe(dev, ret, "Error adding i2c adapter\n"); | |
| 1224 | + | } | |
| 1194 | 1225 | ||
| 1195 | 1226 | dev_dbg(dev, "Geni-I2C adaptor successfully added\n"); | |
| 1196 | 1227 | ||
modified drivers/i2c/busses/i2c-xiic.c
| @@ -73,6 +73,9 @@ enum i2c_scl_freq { | |||
| 73 | 73 | * @prev_msg_tx: Previous message is Tx | |
| 74 | 74 | * @quirks: To hold platform specific bug info | |
| 75 | 75 | * @smbus_block_read: Flag to handle block read | |
| 76 | + | * @smbus_actual_len: Valid byte count (length + payload + optional PEC) of a | |
| 77 | + | * padded SMBus block read. msg->len is trimmed to this on completion. | |
| 78 | + | * Zero when no trimming is needed. | |
| 76 | 79 | * @input_clk: Input clock to I2C controller | |
| 77 | 80 | * @i2c_clk: I2C SCL frequency | |
| 78 | 81 | * @atomic: Mode of transfer | |
| @@ -98,6 +101,7 @@ struct xiic_i2c { | |||
| 98 | 101 | bool prev_msg_tx; | |
| 99 | 102 | u32 quirks; | |
| 100 | 103 | bool smbus_block_read; | |
| 104 | + | unsigned int smbus_actual_len; | |
| 101 | 105 | unsigned long input_clk; | |
| 102 | 106 | unsigned int i2c_clk; | |
| 103 | 107 | bool atomic; | |
| @@ -539,30 +543,38 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) | |||
| 539 | 543 | ||
| 540 | 544 | /* Check if received length is valid */ | |
| 541 | 545 | if (rxmsg_len <= I2C_SMBUS_BLOCK_MAX) { | |
| 546 | + | unsigned int pec_len = i2c->rx_msg->len - 1; | |
| 547 | + | ||
| 542 | 548 | /* Set Receive fifo depth */ | |
| 543 | - | if (rxmsg_len > IIC_RX_FIFO_DEPTH) { | |
| 549 | + | if (rxmsg_len + pec_len > IIC_RX_FIFO_DEPTH) { | |
| 544 | 550 | /* | |
| 545 | - | * When Rx msg len greater than or equal to Rx fifo capacity | |
| 546 | - | * Receive fifo depth should set to Rx fifo capacity minus 1 | |
| 551 | + | * Trailing bytes (payload plus any PEC) exceed Rx FIFO | |
| 552 | + | * capacity, so drain in chunks. This also keeps the | |
| 553 | + | * else branch below from pushing rfd_set past the | |
| 554 | + | * 4-bit XIIC_RFD_REG_OFFSET field. | |
| 547 | 555 | */ | |
| 548 | 556 | rfd_set = IIC_RX_FIFO_DEPTH - 1; | |
| 549 | - | i2c->rx_msg->len = rxmsg_len + 1; | |
| 550 | - | } else if ((rxmsg_len == 1) || | |
| 551 | - | (rxmsg_len == 0)) { | |
| 557 | + | i2c->rx_msg->len = rxmsg_len + 1 + pec_len; | |
| 558 | + | } else if (1 + rxmsg_len + pec_len < SMBUS_BLOCK_READ_MIN_LEN) { | |
| 552 | 559 | /* | |
| 553 | - | * Minimum of 3 bytes required to exit cleanly. 1 byte | |
| 554 | - | * already received, Second byte is being received. Have | |
| 555 | - | * to set NACK in read_rx before receiving the last byte | |
| 560 | + | * The HW needs SMBUS_BLOCK_READ_MIN_LEN bytes on the | |
| 561 | + | * bus to exit cleanly: by the time the ISR reads the | |
| 562 | + | * length byte the second byte is already being clocked | |
| 563 | + | * in, too late to NACK. Pad the drain target and record | |
| 564 | + | * the real length, trimmed back on completion so the | |
| 565 | + | * PEC check sees the right byte. | |
| 556 | 566 | */ | |
| 557 | 567 | rfd_set = 0; | |
| 558 | 568 | i2c->rx_msg->len = SMBUS_BLOCK_READ_MIN_LEN; | |
| 569 | + | i2c->smbus_actual_len = 1 + rxmsg_len + pec_len; | |
| 559 | 570 | } else { | |
| 560 | 571 | /* | |
| 561 | - | * When Rx msg len less than Rx fifo capacity | |
| 562 | - | * Receive fifo depth should set to Rx msg len minus 2 | |
| 572 | + | * All trailing bytes fit in the Rx FIFO. Defer RX_FULL | |
| 573 | + | * until every one of them is buffered, so the drain | |
| 574 | + | * takes xiic_read_rx()'s bytes_rem == 0 path. | |
| 563 | 575 | */ | |
| 564 | - | rfd_set = rxmsg_len - 2; | |
| 565 | - | i2c->rx_msg->len = rxmsg_len + 1; | |
| 576 | + | rfd_set = rxmsg_len + pec_len - 1; | |
| 577 | + | i2c->rx_msg->len = rxmsg_len + 1 + pec_len; | |
| 566 | 578 | } | |
| 567 | 579 | xiic_setreg8(i2c, XIIC_RFD_REG_OFFSET, rfd_set); | |
| 568 | 580 | ||
| @@ -575,6 +587,16 @@ static void xiic_smbus_block_read_setup(struct xiic_i2c *i2c) | |||
| 575 | 587 | dev_err(i2c->adap.dev.parent, "smbus_block_read Invalid msg length\n"); | |
| 576 | 588 | } | |
| 577 | 589 | ||
| 590 | + | /* | |
| 591 | + | * Undo the setup-time padding of a short SMBus block read before rx_msg is | |
| 592 | + | * cleared, so the PEC check sees the right byte. | |
| 593 | + | */ | |
| 594 | + | static void xiic_smbus_trim_len(struct xiic_i2c *i2c) | |
| 595 | + | { | |
| 596 | + | if (i2c->rx_msg && i2c->smbus_actual_len) | |
| 597 | + | i2c->rx_msg->len = i2c->smbus_actual_len; | |
| 598 | + | } | |
| 599 | + | ||
| 578 | 600 | static void xiic_read_rx(struct xiic_i2c *i2c) | |
| 579 | 601 | { | |
| 580 | 602 | u8 bytes_in_fifo, cr = 0, bytes_to_read = 0; | |
| @@ -797,6 +819,8 @@ static irqreturn_t xiic_process(int irq, void *dev_id) | |||
| 797 | 819 | ||
| 798 | 820 | xiic_read_rx(i2c); | |
| 799 | 821 | if (xiic_rx_space(i2c) == 0) { | |
| 822 | + | xiic_smbus_trim_len(i2c); | |
| 823 | + | ||
| 800 | 824 | /* this is the last part of the message */ | |
| 801 | 825 | i2c->rx_msg = NULL; | |
| 802 | 826 | ||
| @@ -865,8 +889,11 @@ static irqreturn_t xiic_process(int irq, void *dev_id) | |||
| 865 | 889 | ||
| 866 | 890 | if (i2c->tx_msg && i2c->smbus_block_read) { | |
| 867 | 891 | i2c->smbus_block_read = false; | |
| 868 | - | /* Set requested message len=1 to indicate STATE_DONE */ | |
| 869 | - | i2c->tx_msg->len = 1; | |
| 892 | + | /* | |
| 893 | + | * Drive xiic_tx_space() to 0 to signal STATE_DONE | |
| 894 | + | * without truncating the rx_msg length. | |
| 895 | + | */ | |
| 896 | + | i2c->tx_pos = i2c->tx_msg->len; | |
| 870 | 897 | } | |
| 871 | 898 | ||
| 872 | 899 | if (!i2c->tx_msg) | |
| @@ -938,6 +965,7 @@ static void xiic_recv_atomic(struct xiic_i2c *i2c) | |||
| 938 | 965 | return; | |
| 939 | 966 | } | |
| 940 | 967 | ||
| 968 | + | xiic_smbus_trim_len(i2c); | |
| 941 | 969 | i2c->rx_msg = NULL; | |
| 942 | 970 | xiic_irq_clr_en(i2c, XIIC_INTR_TX_ERROR_MASK); | |
| 943 | 971 | ||
| @@ -955,6 +983,9 @@ static void xiic_start_recv(struct xiic_i2c *i2c) | |||
| 955 | 983 | u8 cr = 0, rfd_set = 0; | |
| 956 | 984 | struct i2c_msg *msg = i2c->rx_msg = i2c->tx_msg; | |
| 957 | 985 | ||
| 986 | + | /* A stale value from an aborted block read would truncate this msg. */ | |
| 987 | + | i2c->smbus_actual_len = 0; | |
| 988 | + | ||
| 958 | 989 | if (!i2c->atomic) | |
| 959 | 990 | dev_dbg(i2c->adap.dev.parent, "%s entry, ISR: 0x%x, CR: 0x%x\n", | |
| 960 | 991 | __func__, xiic_getreg32(i2c, XIIC_IISR_OFFSET), | |
modified drivers/i2c/i2c-atr.c
| @@ -855,6 +855,7 @@ int i2c_atr_add_adapter(struct i2c_atr *atr, struct i2c_atr_adap_desc *desc) | |||
| 855 | 855 | ||
| 856 | 856 | ret = i2c_add_adapter(&chan->adap); | |
| 857 | 857 | if (ret) { | |
| 858 | + | atr->adapter[chan_id] = NULL; | |
| 858 | 859 | dev_err(dev, "failed to add atr-adapter %u (error=%d)\n", | |
| 859 | 860 | chan_id, ret); | |
| 860 | 861 | goto err_free_alias_pool; | |
modified drivers/iio/accel/kionix-kx022a.c
| @@ -649,7 +649,7 @@ static int kx022a_read_raw(struct iio_dev *idev, | |||
| 649 | 649 | if (ret) | |
| 650 | 650 | return ret; | |
| 651 | 651 | ||
| 652 | - | if ((regval & KX022A_MASK_ODR) > | |
| 652 | + | if ((regval & KX022A_MASK_ODR) >= | |
| 653 | 653 | ARRAY_SIZE(kx022a_accel_samp_freq_table)) { | |
| 654 | 654 | dev_err(data->dev, "Invalid ODR\n"); | |
| 655 | 655 | return -EINVAL; | |
| @@ -980,26 +980,44 @@ static int kx022a_fifo_enable(struct kx022a_data *data) | |||
| 980 | 980 | guard(mutex)(&data->mutex); | |
| 981 | 981 | ret = __kx022a_turn_on_off(data, false); | |
| 982 | 982 | if (ret) | |
| 983 | - | return ret; | |
| 983 | + | goto err_free_out; | |
| 984 | 984 | ||
| 985 | 985 | /* Update watermark to HW */ | |
| 986 | 986 | ret = kx022a_fifo_set_wmi(data); | |
| 987 | 987 | if (ret) | |
| 988 | - | return ret; | |
| 988 | + | goto err_turn_on_out; | |
| 989 | 989 | ||
| 990 | 990 | /* Enable buffer */ | |
| 991 | 991 | ret = regmap_set_bits(data->regmap, data->chip_info->buf_cntl2, | |
| 992 | 992 | KX022A_MASK_BUF_EN); | |
| 993 | 993 | if (ret) | |
| 994 | - | return ret; | |
| 994 | + | goto err_turn_on_out; | |
| 995 | 995 | ||
| 996 | 996 | data->state |= KX022A_STATE_FIFO; | |
| 997 | 997 | ret = regmap_set_bits(data->regmap, data->ien_reg, | |
| 998 | 998 | KX022A_MASK_WMI); | |
| 999 | 999 | if (ret) | |
| 1000 | - | return ret; | |
| 1000 | + | goto err_buf_disable_out; | |
| 1001 | 1001 | ||
| 1002 | - | return __kx022a_turn_on_off(data, true); | |
| 1002 | + | ret = __kx022a_turn_on_off(data, true); | |
| 1003 | + | if (ret) | |
| 1004 | + | goto err_wmi_clear_out; | |
| 1005 | + | ||
| 1006 | + | return ret; | |
| 1007 | + | ||
| 1008 | + | err_wmi_clear_out: | |
| 1009 | + | regmap_clear_bits(data->regmap, data->ien_reg, | |
| 1010 | + | KX022A_MASK_WMI); | |
| 1011 | + | err_buf_disable_out: | |
| 1012 | + | regmap_clear_bits(data->regmap, data->chip_info->buf_cntl2, | |
| 1013 | + | KX022A_MASK_BUF_EN); | |
| 1014 | + | data->state &= ~KX022A_STATE_FIFO; | |
| 1015 | + | err_turn_on_out: | |
| 1016 | + | __kx022a_turn_on_off(data, true); | |
| 1017 | + | err_free_out: | |
| 1018 | + | kfree(data->fifo_buffer); | |
| 1019 | + | ||
| 1020 | + | return ret; | |
| 1003 | 1021 | } | |
| 1004 | 1022 | ||
| 1005 | 1023 | static int kx022a_buffer_postenable(struct iio_dev *idev) | |
modified drivers/iio/accel/kxcjk-1013.c
| @@ -1030,7 +1030,7 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev, | |||
| 1030 | 1030 | struct kxcjk1013_data *data = iio_priv(indio_dev); | |
| 1031 | 1031 | int ret; | |
| 1032 | 1032 | ||
| 1033 | - | if (state && data->ev_enable_state) | |
| 1033 | + | if (state == data->ev_enable_state) | |
| 1034 | 1034 | return 0; | |
| 1035 | 1035 | ||
| 1036 | 1036 | mutex_lock(&data->mutex); | |
modified drivers/iio/accel/sca3000.c
| @@ -638,7 +638,7 @@ static int sca3000_write_raw_samp_freq(struct sca3000_state *st, int val) | |||
| 638 | 638 | ||
| 639 | 639 | if (val == base_freq / 2) | |
| 640 | 640 | ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_2; | |
| 641 | - | if (val == base_freq / 4) | |
| 641 | + | else if (val == base_freq / 4) | |
| 642 | 642 | ctrlval |= SCA3000_REG_OUT_CTRL_BUF_DIV_4; | |
| 643 | 643 | else if (val != base_freq) | |
| 644 | 644 | return -EINVAL; | |
modified drivers/iio/adc/ad4030.c
| @@ -746,14 +746,21 @@ static int ad4030_set_chan_calibbias(struct iio_dev *indio_dev, | |||
| 746 | 746 | static int ad4030_set_avg_frame_len(struct iio_dev *dev, int avg_val) | |
| 747 | 747 | { | |
| 748 | 748 | struct ad4030_state *st = iio_priv(dev); | |
| 749 | - | unsigned int avg_log2 = ilog2(avg_val); | |
| 750 | 749 | unsigned int last_avg_idx = ARRAY_SIZE(ad4030_average_modes) - 1; | |
| 750 | + | unsigned int avg_log2; | |
| 751 | 751 | int freq_hz; | |
| 752 | 752 | int ret; | |
| 753 | 753 | ||
| 754 | - | if (avg_val < 0 || avg_val > ad4030_average_modes[last_avg_idx]) | |
| 754 | + | /* Reject unsupported modes */ | |
| 755 | + | if (avg_val > ad4030_average_modes[last_avg_idx]) | |
| 756 | + | return -EINVAL; | |
| 757 | + | ||
| 758 | + | /* Avoid invalid values for logarithm since it's undefined */ | |
| 759 | + | if (avg_val < 1) | |
| 755 | 760 | return -EINVAL; | |
| 756 | 761 | ||
| 762 | + | avg_log2 = ilog2(avg_val); | |
| 763 | + | ||
| 757 | 764 | if (st->offload_trigger) { | |
| 758 | 765 | /* | |
| 759 | 766 | * The sample averaging and sampling frequency configurations | |
modified drivers/iio/adc/ad7173.c
| @@ -775,9 +775,9 @@ static int ad7173_load_config(struct ad7173_state *st, | |||
| 775 | 775 | ||
| 776 | 776 | return ad_sd_write_reg(&st->sd, AD7173_REG_FILTER(free_cfg_slot), 2, | |
| 777 | 777 | FIELD_PREP(AD7173_FILTER_SINC3_MAP, 0) | | |
| 778 | - | FIELD_PREP(AD7173_FILTER_ENHFILT_MASK, | |
| 779 | - | post_filter_enable) | | |
| 780 | 778 | FIELD_PREP(AD7173_FILTER_ENHFILTEN, | |
| 779 | + | post_filter_enable) | | |
| 780 | + | FIELD_PREP(AD7173_FILTER_ENHFILT_MASK, | |
| 781 | 781 | post_filter_select) | | |
| 782 | 782 | FIELD_PREP(AD7173_FILTER_ORDER, 0) | | |
| 783 | 783 | FIELD_PREP(AD7173_FILTER_ODR_MASK, | |
modified drivers/iio/adc/ad_sigma_delta.c
| @@ -498,7 +498,6 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 498 | 498 | const struct iio_scan_type *scan_type = &indio_dev->channels[0].scan_type; | |
| 499 | 499 | struct spi_transfer *xfer = sigma_delta->sample_xfer; | |
| 500 | 500 | unsigned int i, slot, channel; | |
| 501 | - | u8 *samples_buf; | |
| 502 | 501 | int ret; | |
| 503 | 502 | ||
| 504 | 503 | if (sigma_delta->num_slots == 1) { | |
| @@ -530,7 +529,7 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 530 | 529 | xfer[1].bits_per_word = scan_type->realbits; | |
| 531 | 530 | xfer[1].len = spi_bpw_to_bytes(scan_type->realbits); | |
| 532 | 531 | } else { | |
| 533 | - | unsigned int samples_buf_size, scan_size; | |
| 532 | + | unsigned int scan_size; | |
| 534 | 533 | ||
| 535 | 534 | if (sigma_delta->active_slots > 1) { | |
| 536 | 535 | ret = ad_sigma_delta_append_status(sigma_delta, true); | |
| @@ -538,17 +537,6 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) | |||
| 538 | 537 | return ret; | |
| 539 | 538 | } | |
| 540 | 539 | ||
| 541 | - | samples_buf_size = | |
| 542 | - | ALIGN(slot * BITS_TO_BYTES(scan_type->storagebits), | |
| 543 | - | sizeof(s64)); | |
| 544 | - | samples_buf_size += sizeof(s64); | |
| 545 | - | samples_buf = devm_krealloc(&sigma_delta->spi->dev, | |
| 546 | - | sigma_delta->samples_buf, | |
| 547 | - | samples_buf_size, GFP_KERNEL); | |
| 548 | - | if (!samples_buf) | |
| 549 | - | return -ENOMEM; | |
| 550 | - | ||
| 551 | - | sigma_delta->samples_buf = samples_buf; | |
| 552 | 540 | scan_size = BITS_TO_BYTES(scan_type->realbits + scan_type->shift); | |
| 553 | 541 | /* For 24-bit data, there is an extra byte of padding. */ | |
| 554 | 542 | xfer[1].rx_buf = &sigma_delta->rx_buf[scan_size == 3 ? 1 : 0]; | |
| @@ -855,6 +843,23 @@ int devm_ad_sd_setup_buffer_and_trigger(struct device *dev, struct iio_dev *indi | |||
| 855 | 843 | ||
| 856 | 844 | indio_dev->setup_ops = &ad_sd_buffer_setup_ops; | |
| 857 | 845 | } else { | |
| 846 | + | const struct iio_scan_type *scan_type = | |
| 847 | + | &indio_dev->channels[0].scan_type; | |
| 848 | + | unsigned int samples_buf_size; | |
| 849 | + | ||
| 850 | + | /* | |
| 851 | + | * Worst-case size: all sequencer slots can be active, capped | |
| 852 | + | * at num_slots by ad_sd_validate_scan_mask(). | |
| 853 | + | */ | |
| 854 | + | samples_buf_size = | |
| 855 | + | ALIGN(sigma_delta->num_slots * | |
| 856 | + | BITS_TO_BYTES(scan_type->storagebits), | |
| 857 | + | sizeof(s64)); | |
| 858 | + | samples_buf_size += sizeof(s64); | |
| 859 | + | sigma_delta->samples_buf = devm_kzalloc(dev, samples_buf_size, GFP_KERNEL); | |
| 860 | + | if (!sigma_delta->samples_buf) | |
| 861 | + | return -ENOMEM; | |
| 862 | + | ||
| 858 | 863 | ret = devm_iio_triggered_buffer_setup(dev, indio_dev, | |
| 859 | 864 | &iio_pollfunc_store_time, | |
| 860 | 865 | &ad_sd_trigger_handler, | |
modified drivers/iio/adc/ade9000.c
| @@ -219,7 +219,7 @@ | |||
| 219 | 219 | #define ADE9000_ST1_ERROR2_BIT BIT(30) | |
| 220 | 220 | #define ADE9000_ST1_ERROR3_BIT BIT(31) | |
| 221 | 221 | #define ADE9000_ST1_CROSSING_FIRST 6 | |
| 222 | - | #define ADE9000_ST1_CROSSING_DEPTH 25 | |
| 222 | + | #define ADE9000_ST1_CROSSING_DEPTH 26 | |
| 223 | 223 | ||
| 224 | 224 | #define ADE9000_WFB_TRG_DIP_BIT BIT(0) | |
| 225 | 225 | #define ADE9000_WFB_TRG_SWELL_BIT BIT(1) | |
| @@ -444,7 +444,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = { | |||
| 444 | 444 | BIT(IIO_CHAN_INFO_CALIBSCALE), \ | |
| 445 | 445 | .event_spec = ade9000_current_events, \ | |
| 446 | 446 | .num_event_specs = ARRAY_SIZE(ade9000_current_events), \ | |
| 447 | - | .scan_index = num, \ | |
| 447 | + | .scan_index = num * 2, \ | |
| 448 | 448 | .indexed = 1, \ | |
| 449 | 449 | .scan_type = { \ | |
| 450 | 450 | .sign = 's', \ | |
| @@ -464,7 +464,7 @@ static const struct iio_chan_spec_ext_info ade9000_ext_info[] = { | |||
| 464 | 464 | BIT(IIO_CHAN_INFO_FREQUENCY), \ | |
| 465 | 465 | .event_spec = ade9000_voltage_events, \ | |
| 466 | 466 | .num_event_specs = ARRAY_SIZE(ade9000_voltage_events), \ | |
| 467 | - | .scan_index = num + 1, /* interleave with current channels */ \ | |
| 467 | + | .scan_index = num * 2 + 1, /* interleave with current channels */ \ | |
| 468 | 468 | .indexed = 1, \ | |
| 469 | 469 | .scan_type = { \ | |
| 470 | 470 | .sign = 's', \ | |
| @@ -1647,8 +1647,9 @@ static int ade9000_setup_clkout(struct device *dev, struct ade9000_state *st) | |||
| 1647 | 1647 | return 0; | |
| 1648 | 1648 | ||
| 1649 | 1649 | /* CLKOUT passes through CLKIN with divider of 1 */ | |
| 1650 | - | clkout_hw = devm_clk_hw_register_divider(dev, "clkout", __clk_get_name(st->clkin), | |
| 1651 | - | CLK_SET_RATE_PARENT, NULL, 0, 1, 0, NULL); | |
| 1650 | + | clkout_hw = devm_clk_hw_register_fixed_factor(dev, "clkout", | |
| 1651 | + | __clk_get_name(st->clkin), | |
| 1652 | + | CLK_SET_RATE_PARENT, 1, 1); | |
| 1652 | 1653 | if (IS_ERR(clkout_hw)) | |
| 1653 | 1654 | return dev_err_probe(dev, PTR_ERR(clkout_hw), "Failed to register clkout"); | |
| 1654 | 1655 | ||
| @@ -1705,18 +1706,6 @@ static int ade9000_probe(struct spi_device *spi) | |||
| 1705 | 1706 | if (ret) | |
| 1706 | 1707 | return ret; | |
| 1707 | 1708 | ||
| 1708 | - | ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev); | |
| 1709 | - | if (ret) | |
| 1710 | - | return ret; | |
| 1711 | - | ||
| 1712 | - | ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev); | |
| 1713 | - | if (ret) | |
| 1714 | - | return ret; | |
| 1715 | - | ||
| 1716 | - | ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev); | |
| 1717 | - | if (ret) | |
| 1718 | - | return ret; | |
| 1719 | - | ||
| 1720 | 1709 | /* External CMOS clock input (optional - crystal can be used instead) */ | |
| 1721 | 1710 | st->clkin = devm_clk_get_optional_enabled(dev, NULL); | |
| 1722 | 1711 | if (IS_ERR(st->clkin)) | |
| @@ -1736,6 +1725,19 @@ static int ade9000_probe(struct spi_device *spi) | |||
| 1736 | 1725 | return dev_err_probe(&spi->dev, ret, | |
| 1737 | 1726 | "Failed to get and enable vdd regulator\n"); | |
| 1738 | 1727 | ||
| 1728 | + | /* Request IRQs only after powering the chip; the handlers do SPI access. */ | |
| 1729 | + | ret = ade9000_request_irq(dev, "irq0", ade9000_irq0_thread, indio_dev); | |
| 1730 | + | if (ret) | |
| 1731 | + | return ret; | |
| 1732 | + | ||
| 1733 | + | ret = ade9000_request_irq(dev, "irq1", ade9000_irq1_thread, indio_dev); | |
| 1734 | + | if (ret) | |
| 1735 | + | return ret; | |
| 1736 | + | ||
| 1737 | + | ret = ade9000_request_irq(dev, "dready", ade9000_dready_thread, indio_dev); | |
| 1738 | + | if (ret) | |
| 1739 | + | return ret; | |
| 1740 | + | ||
| 1739 | 1741 | indio_dev->channels = ade9000_channels; | |
| 1740 | 1742 | indio_dev->num_channels = ARRAY_SIZE(ade9000_channels); | |
| 1741 | 1743 | ||
modified drivers/iio/adc/adi-axi-adc.c
| @@ -714,6 +714,10 @@ static int adi_axi_adc_probe(struct platform_device *pdev) | |||
| 714 | 714 | if (!st) | |
| 715 | 715 | return -ENOMEM; | |
| 716 | 716 | ||
| 717 | + | ret = devm_mutex_init(dev, &st->lock); | |
| 718 | + | if (ret) | |
| 719 | + | return ret; | |
| 720 | + | ||
| 717 | 721 | base = devm_platform_ioremap_resource(pdev, 0); | |
| 718 | 722 | if (IS_ERR(base)) | |
| 719 | 723 | return PTR_ERR(base); | |
modified drivers/iio/adc/aspeed_adc.c
| @@ -585,7 +585,9 @@ static int aspeed_adc_probe(struct platform_device *pdev) | |||
| 585 | 585 | return dev_err_probe(dev, PTR_ERR(data->rst), | |
| 586 | 586 | "invalid or missing reset controller device tree entry"); | |
| 587 | 587 | ||
| 588 | - | reset_control_deassert(data->rst); | |
| 588 | + | ret = reset_control_deassert(data->rst); | |
| 589 | + | if (ret) | |
| 590 | + | return ret; | |
| 589 | 591 | ||
| 590 | 592 | ret = devm_add_action_or_reset(dev, aspeed_adc_reset_assert, data->rst); | |
| 591 | 593 | if (ret) | |
modified drivers/iio/adc/axp288_adc.c
| @@ -207,6 +207,14 @@ static const struct dmi_system_id axp288_adc_ts_bias_override[] = { | |||
| 207 | 207 | }, | |
| 208 | 208 | .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, | |
| 209 | 209 | }, | |
| 210 | + | { | |
| 211 | + | /* Haier HV103H */ | |
| 212 | + | .matches = { | |
| 213 | + | DMI_MATCH(DMI_SYS_VENDOR, "Haier"), | |
| 214 | + | DMI_MATCH(DMI_PRODUCT_NAME, "HV103H"), | |
| 215 | + | }, | |
| 216 | + | .driver_data = (void *)(uintptr_t)AXP288_ADC_TS_BIAS_80UA, | |
| 217 | + | }, | |
| 210 | 218 | { } | |
| 211 | 219 | }; | |
| 212 | 220 | ||
modified drivers/iio/adc/max1363.c
| @@ -404,6 +404,14 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev, | |||
| 404 | 404 | ||
| 405 | 405 | data = rxbuf[0]; | |
| 406 | 406 | } | |
| 407 | + | ||
| 408 | + | /* | |
| 409 | + | * Differential channels are bipolar and the device returns the sample | |
| 410 | + | * in two's complement, so sign-extend it from the resolution bit. | |
| 411 | + | */ | |
| 412 | + | if (chan->differential) | |
| 413 | + | data = sign_extend32(data, st->chip_info->bits - 1); | |
| 414 | + | ||
| 407 | 415 | *val = data; | |
| 408 | 416 | ||
| 409 | 417 | return 0; | |
modified drivers/iio/adc/pac1934.c
| @@ -1108,6 +1108,10 @@ static int pac1934_acpi_parse_channel_config(struct i2c_client *client, | |||
| 1108 | 1108 | devm_kmemdup(dev, rez->package.elements[i].string.pointer, | |
| 1109 | 1109 | (size_t)rez->package.elements[i].string.length + 1, | |
| 1110 | 1110 | GFP_KERNEL); | |
| 1111 | + | if (!info->labels[idx]) { | |
| 1112 | + | ACPI_FREE(rez); | |
| 1113 | + | return -ENOMEM; | |
| 1114 | + | } | |
| 1111 | 1115 | info->labels[idx][rez->package.elements[i].string.length] = '\0'; | |
| 1112 | 1116 | info->shunts[idx] = rez->package.elements[i + 1].integer.value * 1000; | |
| 1113 | 1117 | info->active_channels[idx] = (info->shunts[idx] != 0); | |
modified drivers/iio/adc/rohm-bd79124.c
| @@ -200,7 +200,7 @@ static int bd79124gpo_set_multiple(struct gpio_chip *gc, unsigned long *mask, | |||
| 200 | 200 | if (ret) | |
| 201 | 201 | return ret; | |
| 202 | 202 | ||
| 203 | - | if (all_gpos ^ *mask) { | |
| 203 | + | if (*mask & ~all_gpos) { | |
| 204 | 204 | dev_dbg(data->dev, "Invalid mux config. Can't set value.\n"); | |
| 205 | 205 | ||
| 206 | 206 | return -EINVAL; | |
| @@ -381,6 +381,9 @@ static int bd79124_start_measurement(struct bd79124_data *data, int chan) | |||
| 381 | 381 | ||
| 382 | 382 | /* See if already started */ | |
| 383 | 383 | ret = regmap_read(data->map, BD79124_REG_AUTO_CHANNELS, &val); | |
| 384 | + | if (ret) | |
| 385 | + | return ret; | |
| 386 | + | ||
| 384 | 387 | if (val & BIT(chan)) | |
| 385 | 388 | return 0; | |
| 386 | 389 | ||
| @@ -420,11 +423,16 @@ static int bd79124_stop_measurement(struct bd79124_data *data, int chan) | |||
| 420 | 423 | ||
| 421 | 424 | /* See if already stopped */ | |
| 422 | 425 | ret = regmap_read(data->map, BD79124_REG_AUTO_CHANNELS, &enabled_chans); | |
| 426 | + | if (ret) | |
| 427 | + | return ret; | |
| 428 | + | ||
| 423 | 429 | if (!(enabled_chans & BIT(chan))) | |
| 424 | 430 | return 0; | |
| 425 | 431 | ||
| 426 | 432 | ret = regmap_clear_bits(data->map, BD79124_REG_SEQ_CFG, | |
| 427 | 433 | BD79124_MSK_SEQ_START); | |
| 434 | + | if (ret) | |
| 435 | + | return ret; | |
| 428 | 436 | ||
| 429 | 437 | /* Clear the channel from the measured channels */ | |
| 430 | 438 | enabled_chans &= ~BIT(chan); | |
| @@ -524,7 +532,7 @@ static int bd79124_enable_event(struct bd79124_data *data, | |||
| 524 | 532 | return ret; | |
| 525 | 533 | ||
| 526 | 534 | if (dir == IIO_EV_DIR_RISING) { | |
| 527 | - | limit = &data->alarm_f_limit[channel]; | |
| 535 | + | limit = &data->alarm_r_limit[channel]; | |
| 528 | 536 | reg = BD79124_GET_HIGH_LIMIT_REG(channel); | |
| 529 | 537 | } else { | |
| 530 | 538 | limit = &data->alarm_f_limit[channel]; | |
| @@ -919,13 +927,13 @@ static int bd79124_chan_init(struct bd79124_data *data, int channel) | |||
| 919 | 927 | { | |
| 920 | 928 | int ret; | |
| 921 | 929 | ||
| 922 | - | ret = regmap_write(data->map, BD79124_GET_HIGH_LIMIT_REG(channel), | |
| 923 | - | BD79124_HIGH_LIMIT_MAX); | |
| 930 | + | ret = bd79124_write_int_to_reg(data, BD79124_GET_HIGH_LIMIT_REG(channel), | |
| 931 | + | BD79124_HIGH_LIMIT_MAX); | |
| 924 | 932 | if (ret) | |
| 925 | 933 | return ret; | |
| 926 | 934 | ||
| 927 | - | return regmap_write(data->map, BD79124_GET_LOW_LIMIT_REG(channel), | |
| 928 | - | BD79124_LOW_LIMIT_MIN); | |
| 935 | + | return bd79124_write_int_to_reg(data, BD79124_GET_LOW_LIMIT_REG(channel), | |
| 936 | + | BD79124_LOW_LIMIT_MIN); | |
| 929 | 937 | } | |
| 930 | 938 | ||
| 931 | 939 | static int bd79124_get_gpio_pins(const struct iio_chan_spec *cs, int num_channels) | |
modified drivers/iio/adc/stm32-adc.c
| @@ -1608,11 +1608,16 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev, | |||
| 1608 | 1608 | ret = stm32_adc_single_conv(indio_dev, chan, val); | |
| 1609 | 1609 | else | |
| 1610 | 1610 | ret = -EINVAL; | |
| 1611 | + | iio_device_release_direct(indio_dev); | |
| 1612 | + | if (ret < 0) | |
| 1613 | + | return ret; | |
| 1611 | 1614 | ||
| 1612 | - | if (mask == IIO_CHAN_INFO_PROCESSED) | |
| 1615 | + | if (mask == IIO_CHAN_INFO_PROCESSED) { | |
| 1616 | + | if (*val == 0) | |
| 1617 | + | return -EINVAL; | |
| 1613 | 1618 | *val = STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; | |
| 1619 | + | } | |
| 1614 | 1620 | ||
| 1615 | - | iio_device_release_direct(indio_dev); | |
| 1616 | 1621 | return ret; | |
| 1617 | 1622 | ||
| 1618 | 1623 | case IIO_CHAN_INFO_SCALE: | |
| @@ -2263,33 +2268,37 @@ static int stm32_adc_populate_int_ch(struct iio_dev *indio_dev, const char *ch_n | |||
| 2263 | 2268 | ||
| 2264 | 2269 | for (i = 0; i < STM32_ADC_INT_CH_NB; i++) { | |
| 2265 | 2270 | if (!strncmp(stm32_adc_ic[i].name, ch_name, STM32_ADC_CH_SZ)) { | |
| 2271 | + | bool na; | |
| 2272 | + | ||
| 2266 | 2273 | /* Check internal channel availability */ | |
| 2267 | 2274 | switch (i) { | |
| 2268 | 2275 | case STM32_ADC_INT_CH_VDDCORE: | |
| 2269 | - | if (!adc->cfg->regs->or_vddcore.reg) | |
| 2270 | - | dev_warn(&indio_dev->dev, | |
| 2271 | - | "%s channel not available\n", ch_name); | |
| 2276 | + | na = !adc->cfg->regs->or_vddcore.reg; | |
| 2272 | 2277 | break; | |
| 2273 | 2278 | case STM32_ADC_INT_CH_VDDCPU: | |
| 2274 | - | if (!adc->cfg->regs->or_vddcpu.reg) | |
| 2275 | - | dev_warn(&indio_dev->dev, | |
| 2276 | - | "%s channel not available\n", ch_name); | |
| 2279 | + | na = !adc->cfg->regs->or_vddcpu.reg; | |
| 2277 | 2280 | break; | |
| 2278 | 2281 | case STM32_ADC_INT_CH_VDDQ_DDR: | |
| 2279 | - | if (!adc->cfg->regs->or_vddq_ddr.reg) | |
| 2280 | - | dev_warn(&indio_dev->dev, | |
| 2281 | - | "%s channel not available\n", ch_name); | |
| 2282 | + | na = !adc->cfg->regs->or_vddq_ddr.reg; | |
| 2282 | 2283 | break; | |
| 2283 | 2284 | case STM32_ADC_INT_CH_VREFINT: | |
| 2284 | - | if (!adc->cfg->regs->ccr_vref.reg) | |
| 2285 | - | dev_warn(&indio_dev->dev, | |
| 2286 | - | "%s channel not available\n", ch_name); | |
| 2285 | + | na = !adc->cfg->regs->ccr_vref.reg; | |
| 2287 | 2286 | break; | |
| 2288 | 2287 | case STM32_ADC_INT_CH_VBAT: | |
| 2289 | - | if (!adc->cfg->regs->ccr_vbat.reg) | |
| 2290 | - | dev_warn(&indio_dev->dev, | |
| 2291 | - | "%s channel not available\n", ch_name); | |
| 2288 | + | na = !adc->cfg->regs->ccr_vbat.reg; | |
| 2292 | 2289 | break; | |
| 2290 | + | default: | |
| 2291 | + | return -EINVAL; | |
| 2292 | + | } | |
| 2293 | + | ||
| 2294 | + | if (na) { | |
| 2295 | + | /* | |
| 2296 | + | * Channel label matches an internal STM32 ADC channel. | |
| 2297 | + | * Warn about it, as there's normally no restriction on the | |
| 2298 | + | * name but that's not among available internal channels. | |
| 2299 | + | */ | |
| 2300 | + | dev_warn(&indio_dev->dev, "no %s internal channel\n", ch_name); | |
| 2301 | + | return 0; | |
| 2293 | 2302 | } | |
| 2294 | 2303 | ||
| 2295 | 2304 | if (stm32_adc_ic[i].idx != STM32_ADC_INT_CH_VREFINT) { | |
modified drivers/iio/adc/sun4i-gpadc-iio.c
| @@ -638,10 +638,10 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) | |||
| 638 | 638 | * thermal because no thermal DT node is found. | |
| 639 | 639 | */ | |
| 640 | 640 | if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) { | |
| 641 | - | dev_err(&pdev->dev, | |
| 642 | - | "could not register thermal sensor: %ld\n", | |
| 643 | - | PTR_ERR(info->tzd)); | |
| 644 | - | return PTR_ERR(info->tzd); | |
| 641 | + | ret = dev_err_probe(&pdev->dev, | |
| 642 | + | PTR_ERR(info->tzd), | |
| 643 | + | "could not register thermal sensor\n"); | |
| 644 | + | goto err_map; | |
| 645 | 645 | } | |
| 646 | 646 | } | |
| 647 | 647 | ||
| @@ -657,7 +657,6 @@ err_map: | |||
| 657 | 657 | if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF)) | |
| 658 | 658 | iio_map_array_unregister(indio_dev); | |
| 659 | 659 | ||
| 660 | - | pm_runtime_put(&pdev->dev); | |
| 661 | 660 | pm_runtime_disable(&pdev->dev); | |
| 662 | 661 | ||
| 663 | 662 | return ret; | |
| @@ -668,7 +667,6 @@ static void sun4i_gpadc_remove(struct platform_device *pdev) | |||
| 668 | 667 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | |
| 669 | 668 | struct sun4i_gpadc_iio *info = iio_priv(indio_dev); | |
| 670 | 669 | ||
| 671 | - | pm_runtime_put(&pdev->dev); | |
| 672 | 670 | pm_runtime_disable(&pdev->dev); | |
| 673 | 671 | ||
| 674 | 672 | if (!IS_ENABLED(CONFIG_THERMAL_OF)) | |
modified drivers/iio/adc/xilinx-xadc-core.c
| @@ -1401,13 +1401,14 @@ static int xadc_probe(struct platform_device *pdev) | |||
| 1401 | 1401 | } | |
| 1402 | 1402 | ||
| 1403 | 1403 | if (irq > 0) { | |
| 1404 | - | ret = devm_request_irq(dev, irq, xadc->ops->interrupt_handler, | |
| 1405 | - | 0, dev_name(dev), indio_dev); | |
| 1404 | + | /* Clear out any work queued by the interrupt */ | |
| 1405 | + | ret = devm_add_action_or_reset(dev, xadc_cancel_delayed_work, | |
| 1406 | + | &xadc->zynq_unmask_work); | |
| 1406 | 1407 | if (ret) | |
| 1407 | 1408 | return ret; | |
| 1408 | 1409 | ||
| 1409 | - | ret = devm_add_action_or_reset(dev, xadc_cancel_delayed_work, | |
| 1410 | - | &xadc->zynq_unmask_work); | |
| 1410 | + | ret = devm_request_irq(dev, irq, xadc->ops->interrupt_handler, | |
| 1411 | + | 0, dev_name(dev), indio_dev); | |
| 1411 | 1412 | if (ret) | |
| 1412 | 1413 | return ret; | |
| 1413 | 1414 | } | |
modified drivers/iio/buffer/industrialio-buffer-dmaengine.c
| @@ -104,10 +104,13 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 104 | 104 | if (block->sg_table) { | |
| 105 | 105 | unsigned long flags; | |
| 106 | 106 | ||
| 107 | - | sgl = block->sg_table->sgl; | |
| 108 | - | nents = sg_nents_for_len(sgl, block->bytes_used); | |
| 109 | - | if (nents < 0) | |
| 110 | - | return nents; | |
| 107 | + | /* | |
| 108 | + | * Only the first sgt->nents entries carry a valid | |
| 109 | + | * sg_dma_address()/sg_dma_len() pair as mapping the table may | |
| 110 | + | * have coalesced entries, in which case nents is smaller than | |
| 111 | + | * orig_nents. | |
| 112 | + | */ | |
| 113 | + | nents = block->sg_table->nents; | |
| 111 | 114 | ||
| 112 | 115 | vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC); | |
| 113 | 116 | if (!vecs) | |
| @@ -115,7 +118,8 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 115 | 118 | ||
| 116 | 119 | len_total = block->bytes_used; | |
| 117 | 120 | ||
| 118 | - | for (i = 0; i < nents; i++) { | |
| 121 | + | sgl = block->sg_table->sgl; | |
| 122 | + | for (i = 0; i < nents && len_total; i++) { | |
| 119 | 123 | vecs[i].addr = sg_dma_address(sgl); | |
| 120 | 124 | vecs[i].len = min(sg_dma_len(sgl), len_total); | |
| 121 | 125 | len_total -= vecs[i].len; | |
| @@ -123,6 +127,8 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue, | |||
| 123 | 127 | sgl = sg_next(sgl); | |
| 124 | 128 | } | |
| 125 | 129 | ||
| 130 | + | nents = i; | |
| 131 | + | ||
| 126 | 132 | if (block->cyclic) | |
| 127 | 133 | flags = DMA_PREP_REPEAT; | |
| 128 | 134 | else | |
modified drivers/iio/cdc/ad7150.c
| @@ -636,11 +636,13 @@ static const struct i2c_device_id ad7150_id[] = { | |||
| 636 | 636 | MODULE_DEVICE_TABLE(i2c, ad7150_id); | |
| 637 | 637 | ||
| 638 | 638 | static const struct of_device_id ad7150_of_match[] = { | |
| 639 | - | { "adi,ad7150" }, | |
| 640 | - | { "adi,ad7151" }, | |
| 641 | - | { "adi,ad7156" }, | |
| 639 | + | { .compatible = "adi,ad7150" }, | |
| 640 | + | { .compatible = "adi,ad7151" }, | |
| 641 | + | { .compatible = "adi,ad7156" }, | |
| 642 | 642 | { } | |
| 643 | 643 | }; | |
| 644 | + | MODULE_DEVICE_TABLE(of, ad7150_of_match); | |
| 645 | + | ||
| 644 | 646 | static struct i2c_driver ad7150_driver = { | |
| 645 | 647 | .driver = { | |
| 646 | 648 | .name = "ad7150", | |
modified drivers/iio/common/inv_sensors/inv_sensors_timestamp.c
| @@ -167,11 +167,16 @@ void inv_sensors_timestamp_interrupt(struct inv_sensors_timestamp *ts, | |||
| 167 | 167 | valid = inv_validate_period(ts, period); | |
| 168 | 168 | } | |
| 169 | 169 | ||
| 170 | - | /* if interrupt interval is valid, sync with interrupt timestamp */ | |
| 170 | + | /* | |
| 171 | + | * If interrupt interval is valid, sync with interrupt timestamp. | |
| 172 | + | * Otherwise, use estimated value while ensuring interrupt timestamp | |
| 173 | + | * remains the maximum possible value. | |
| 174 | + | */ | |
| 175 | + | period = inv_align_timestamp_it(ts, sample_nb); | |
| 171 | 176 | if (valid) | |
| 172 | - | ts->period = inv_align_timestamp_it(ts, sample_nb); | |
| 177 | + | ts->period = period; | |
| 173 | 178 | else | |
| 174 | - | ts->period = ts->mult * ts->chip_period.val; | |
| 179 | + | ts->period = min(ts->mult * ts->chip_period.val, period); | |
| 175 | 180 | } | |
| 176 | 181 | EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_interrupt, "IIO_INV_SENSORS_TIMESTAMP"); | |
| 177 | 182 | ||
modified drivers/iio/dac/mcp47a1.c
| @@ -26,7 +26,7 @@ struct mcp47a1_data { | |||
| 26 | 26 | int vref_mV; | |
| 27 | 27 | }; | |
| 28 | 28 | ||
| 29 | - | static const int mcp47a1_raw_avail[] = { 0, 1, MCP47A1_MAX_STEPS - 1 }; | |
| 29 | + | static const int mcp47a1_raw_avail[] = { 0, 1, MCP47A1_MAX_STEPS }; | |
| 30 | 30 | ||
| 31 | 31 | static const struct iio_chan_spec mcp47a1_channel = { | |
| 32 | 32 | .type = IIO_VOLTAGE, | |
| @@ -46,7 +46,7 @@ static int mcp47a1_write(struct iio_dev *indio_dev, | |||
| 46 | 46 | ||
| 47 | 47 | switch (mask) { | |
| 48 | 48 | case IIO_CHAN_INFO_RAW: | |
| 49 | - | if (!in_range(val, 0, MCP47A1_MAX_STEPS)) | |
| 49 | + | if (!in_range(val, 0, MCP47A1_MAX_STEPS + 1)) | |
| 50 | 50 | return -EINVAL; | |
| 51 | 51 | ||
| 52 | 52 | return i2c_smbus_write_byte_data(data->client, MCP47A1_CMD_CODE, | |
modified drivers/iio/dac/rohm-bd79703.c
| @@ -73,6 +73,9 @@ static int bd79703_write_raw(struct iio_dev *idev, | |||
| 73 | 73 | { | |
| 74 | 74 | struct bd79703_data *data = iio_priv(idev); | |
| 75 | 75 | ||
| 76 | + | if (mask != IIO_CHAN_INFO_RAW) | |
| 77 | + | return -EINVAL; | |
| 78 | + | ||
| 76 | 79 | if (val < 0 || val >= 1 << BD79703_DAC_BITS) | |
| 77 | 80 | return -EINVAL; | |
| 78 | 81 | ||
modified drivers/iio/frequency/adf4377.c
| @@ -988,10 +988,10 @@ static const struct clk_ops adf4377_clk_ops = { | |||
| 988 | 988 | ||
| 989 | 989 | static int adf4377_clk_register(struct adf4377_state *st) | |
| 990 | 990 | { | |
| 991 | + | struct clk_parent_data parent_data = { }; | |
| 991 | 992 | struct spi_device *spi = st->spi; | |
| 992 | 993 | struct device *dev = &spi->dev; | |
| 993 | - | struct clk_init_data init; | |
| 994 | - | struct clk_parent_data parent_data; | |
| 994 | + | struct clk_init_data init = { }; | |
| 995 | 995 | int ret; | |
| 996 | 996 | ||
| 997 | 997 | if (!device_property_present(dev, "#clock-cells")) | |
modified drivers/iio/frequency/admv1013.c
| @@ -195,7 +195,7 @@ static int admv1013_read_raw(struct iio_dev *indio_dev, | |||
| 195 | 195 | ||
| 196 | 196 | switch (info) { | |
| 197 | 197 | case IIO_CHAN_INFO_CALIBBIAS: | |
| 198 | - | switch (chan->channel) { | |
| 198 | + | switch (chan->channel2) { | |
| 199 | 199 | case IIO_MOD_I: | |
| 200 | 200 | addr = ADMV1013_REG_OFFSET_ADJUST_I; | |
| 201 | 201 | break; | |
| @@ -601,11 +601,14 @@ static int admv1013_probe(struct spi_device *spi) | |||
| 601 | 601 | "failed to get the LO input clock\n"); | |
| 602 | 602 | ||
| 603 | 603 | st->nb.notifier_call = admv1013_freq_change; | |
| 604 | - | ret = devm_clk_notifier_register(dev, st->clkin, &st->nb); | |
| 604 | + | ||
| 605 | + | ret = devm_mutex_init(dev, &st->lock); | |
| 605 | 606 | if (ret) | |
| 606 | 607 | return ret; | |
| 607 | 608 | ||
| 608 | - | mutex_init(&st->lock); | |
| 609 | + | ret = devm_clk_notifier_register(dev, st->clkin, &st->nb); | |
| 610 | + | if (ret) | |
| 611 | + | return ret; | |
| 609 | 612 | ||
| 610 | 613 | ret = admv1013_init(st, vcm_uv); | |
| 611 | 614 | if (ret) | |
modified drivers/iio/gyro/adis16136.c
| @@ -145,7 +145,7 @@ static int adis16136_debugfs_init(struct iio_dev *indio_dev) | |||
| 145 | 145 | struct adis16136 *adis16136 = iio_priv(indio_dev); | |
| 146 | 146 | struct dentry *d = iio_get_debugfs_dentry(indio_dev); | |
| 147 | 147 | ||
| 148 | - | debugfs_create_file_unsafe("serial_number", 0400, | |
| 148 | + | debugfs_create_file("serial_number", 0400, | |
| 149 | 149 | d, adis16136, &adis16136_serial_fops); | |
| 150 | 150 | debugfs_create_file_unsafe("product_id", 0400, | |
| 151 | 151 | d, adis16136, &adis16136_product_id_fops); | |
modified drivers/iio/health/max30102.c
| @@ -290,9 +290,15 @@ static irqreturn_t max30102_interrupt_handler(int irq, void *private) | |||
| 290 | 290 | { | |
| 291 | 291 | struct iio_dev *indio_dev = private; | |
| 292 | 292 | struct max30102_data *data = iio_priv(indio_dev); | |
| 293 | - | unsigned int measurements = bitmap_weight(indio_dev->active_scan_mask, | |
| 294 | - | iio_get_masklength(indio_dev)); | |
| 295 | - | int ret, cnt = 0; | |
| 293 | + | unsigned int measurements; | |
| 294 | + | int ret, cnt; | |
| 295 | + | ||
| 296 | + | cnt = max30102_fifo_count(data); | |
| 297 | + | if (cnt <= 0) | |
| 298 | + | return IRQ_HANDLED; | |
| 299 | + | ||
| 300 | + | measurements = bitmap_weight(indio_dev->active_scan_mask, | |
| 301 | + | iio_get_masklength(indio_dev)); | |
| 296 | 302 | ||
| 297 | 303 | mutex_lock(&data->lock); | |
| 298 | 304 | ||
modified drivers/iio/imu/adis16400.c
| @@ -280,7 +280,7 @@ static void adis16400_debugfs_init(struct iio_dev *indio_dev) | |||
| 280 | 280 | return; | |
| 281 | 281 | ||
| 282 | 282 | if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER) | |
| 283 | - | debugfs_create_file_unsafe("serial_number", 0400, | |
| 283 | + | debugfs_create_file("serial_number", 0400, | |
| 284 | 284 | d, st, &adis16400_serial_number_fops); | |
| 285 | 285 | if (st->variant->flags & ADIS16400_HAS_PROD_ID) | |
| 286 | 286 | debugfs_create_file_unsafe("product_id", 0400, | |
modified drivers/iio/imu/adis16480.c
| @@ -309,9 +309,9 @@ static void adis16480_debugfs_init(struct iio_dev *indio_dev) | |||
| 309 | 309 | if (!IS_ENABLED(CONFIG_DEBUG_FS)) | |
| 310 | 310 | return; | |
| 311 | 311 | ||
| 312 | - | debugfs_create_file_unsafe("firmware_revision", 0400, | |
| 312 | + | debugfs_create_file("firmware_revision", 0400, | |
| 313 | 313 | d, adis16480, &adis16480_firmware_revision_fops); | |
| 314 | - | debugfs_create_file_unsafe("firmware_date", 0400, | |
| 314 | + | debugfs_create_file("firmware_date", 0400, | |
| 315 | 315 | d, adis16480, &adis16480_firmware_date_fops); | |
| 316 | 316 | debugfs_create_file_unsafe("serial_number", 0400, | |
| 317 | 317 | d, adis16480, &adis16480_serial_number_fops); | |
modified drivers/iio/imu/inv_icm42607/inv_icm42607_core.c
| @@ -537,9 +537,8 @@ static int inv_icm42607_enable_vddio_reg(struct inv_icm42607_state *st) | |||
| 537 | 537 | return 0; | |
| 538 | 538 | } | |
| 539 | 539 | ||
| 540 | - | static void inv_icm42607_sensors_off(void *_data) | |
| 540 | + | static int inv_icm42607_sensors_off(struct inv_icm42607_state *st) | |
| 541 | 541 | { | |
| 542 | - | struct inv_icm42607_state *st = _data; | |
| 543 | 542 | const struct device *dev = regmap_get_device(st->map); | |
| 544 | 543 | int ret; | |
| 545 | 544 | ||
| @@ -552,6 +551,13 @@ static void inv_icm42607_sensors_off(void *_data) | |||
| 552 | 551 | st->conf.accel.mode); | |
| 553 | 552 | if (ret) | |
| 554 | 553 | dev_err(dev, "Unable to turn off sensors\n"); | |
| 554 | + | ||
| 555 | + | return ret; | |
| 556 | + | } | |
| 557 | + | ||
| 558 | + | static void inv_icm42607_sensors_off_action(void *data) | |
| 559 | + | { | |
| 560 | + | inv_icm42607_sensors_off(data); | |
| 555 | 561 | } | |
| 556 | 562 | ||
| 557 | 563 | static void inv_icm42607_disable_vddio_reg(void *_data) | |
| @@ -619,7 +625,7 @@ int inv_icm42607_core_probe(struct regmap *regmap, | |||
| 619 | 625 | * Ensure if sensors get turned on at some point, they're turned off | |
| 620 | 626 | * as part of teardown. | |
| 621 | 627 | */ | |
| 622 | - | ret = devm_add_action_or_reset(dev, inv_icm42607_sensors_off, st); | |
| 628 | + | ret = devm_add_action_or_reset(dev, inv_icm42607_sensors_off_action, st); | |
| 623 | 629 | if (ret) | |
| 624 | 630 | return ret; | |
| 625 | 631 | ||
| @@ -658,9 +664,8 @@ static int inv_icm42607_suspend(struct device *dev) | |||
| 658 | 664 | return 0; | |
| 659 | 665 | } | |
| 660 | 666 | ||
| 661 | - | static int inv_icm42607_resume(struct device *dev) | |
| 667 | + | static int inv_icm42607_resume_core(struct inv_icm42607_state *st) | |
| 662 | 668 | { | |
| 663 | - | struct inv_icm42607_state *st = dev_get_drvdata(dev); | |
| 664 | 669 | int ret; | |
| 665 | 670 | ||
| 666 | 671 | ret = inv_icm42607_enable_vddio_reg(st); | |
| @@ -669,9 +674,25 @@ static int inv_icm42607_resume(struct device *dev) | |||
| 669 | 674 | ||
| 670 | 675 | /* Sync the regcache again after regulator shutdown. */ | |
| 671 | 676 | regcache_mark_dirty(st->map); | |
| 672 | - | ret = regcache_sync(st->map); | |
| 673 | - | if (ret) | |
| 677 | + | ||
| 678 | + | return regcache_sync(st->map); | |
| 679 | + | } | |
| 680 | + | ||
| 681 | + | static int inv_icm42607_resume(struct device *dev) | |
| 682 | + | { | |
| 683 | + | struct inv_icm42607_state *st = dev_get_drvdata(dev); | |
| 684 | + | int ret; | |
| 685 | + | ||
| 686 | + | ret = inv_icm42607_resume_core(st); | |
| 687 | + | if (ret) { | |
| 688 | + | int rc; | |
| 689 | + | ||
| 690 | + | rc = pm_runtime_force_resume(dev); | |
| 691 | + | if (rc) | |
| 692 | + | dev_warn(dev, "Failed to restore runtime PM state: %d\n", rc); | |
| 693 | + | ||
| 674 | 694 | return ret; | |
| 695 | + | } | |
| 675 | 696 | ||
| 676 | 697 | return pm_runtime_force_resume(dev); | |
| 677 | 698 | } | |
| @@ -688,8 +709,7 @@ static int inv_icm42607_runtime_suspend(struct device *dev) | |||
| 688 | 709 | * however the tradeoff is that an unused sensor won't be | |
| 689 | 710 | * turned off until the entire chip is no longer in use. | |
| 690 | 711 | */ | |
| 691 | - | inv_icm42607_sensors_off(st); | |
| 692 | - | return 0; | |
| 712 | + | return inv_icm42607_sensors_off(st); | |
| 693 | 713 | } | |
| 694 | 714 | ||
| 695 | 715 | EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42607_pm_ops, IIO_ICM42607) = { | |
modified drivers/iio/industrialio-buffer.c
| @@ -1377,6 +1377,10 @@ EXPORT_SYMBOL_GPL(iio_update_buffers); | |||
| 1377 | 1377 | ||
| 1378 | 1378 | void iio_disable_all_buffers(struct iio_dev *indio_dev) | |
| 1379 | 1379 | { | |
| 1380 | + | struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); | |
| 1381 | + | ||
| 1382 | + | guard(mutex)(&iio_dev_opaque->mlock); | |
| 1383 | + | ||
| 1380 | 1384 | iio_disable_buffers(indio_dev); | |
| 1381 | 1385 | iio_buffer_deactivate_all(indio_dev); | |
| 1382 | 1386 | } | |
| @@ -2462,7 +2466,8 @@ int iio_push_to_buffers_with_ts_unaligned(struct iio_dev *indio_dev, | |||
| 2462 | 2466 | ||
| 2463 | 2467 | bb = devm_krealloc(&indio_dev->dev, | |
| 2464 | 2468 | iio_dev_opaque->bounce_buffer, | |
| 2465 | - | indio_dev->scan_bytes, GFP_KERNEL); | |
| 2469 | + | indio_dev->scan_bytes, | |
| 2470 | + | GFP_KERNEL | __GFP_ZERO); | |
| 2466 | 2471 | if (!bb) | |
| 2467 | 2472 | return -ENOMEM; | |
| 2468 | 2473 | iio_dev_opaque->bounce_buffer = bb; | |
modified drivers/iio/industrialio-trigger.c
| @@ -509,6 +509,8 @@ static void iio_trig_release(struct device *device) | |||
| 509 | 509 | struct iio_trigger *trig = to_iio_trigger(device); | |
| 510 | 510 | int i; | |
| 511 | 511 | ||
| 512 | + | cancel_work_sync(&trig->reenable_work); | |
| 513 | + | ||
| 512 | 514 | if (trig->subirq_base) { | |
| 513 | 515 | for (i = 0; i < CONFIG_IIO_CONSUMERS_PER_TRIGGER; i++) { | |
| 514 | 516 | irq_modify_status(trig->subirq_base + i, | |
modified drivers/iio/light/gp2ap020a00f.c
| @@ -1497,6 +1497,7 @@ error_trigger_unregister: | |||
| 1497 | 1497 | iio_trigger_unregister(data->trig); | |
| 1498 | 1498 | error_free_irq: | |
| 1499 | 1499 | free_irq(client->irq, indio_dev); | |
| 1500 | + | irq_work_sync(&data->work); | |
| 1500 | 1501 | error_uninit_buffer: | |
| 1501 | 1502 | iio_triggered_buffer_cleanup(indio_dev); | |
| 1502 | 1503 | error_regulator_disable: | |
| @@ -1519,6 +1520,7 @@ static void gp2ap020a00f_remove(struct i2c_client *client) | |||
| 1519 | 1520 | iio_device_unregister(indio_dev); | |
| 1520 | 1521 | iio_trigger_unregister(data->trig); | |
| 1521 | 1522 | free_irq(client->irq, indio_dev); | |
| 1523 | + | irq_work_sync(&data->work); | |
| 1522 | 1524 | iio_triggered_buffer_cleanup(indio_dev); | |
| 1523 | 1525 | regulator_disable(data->vled_reg); | |
| 1524 | 1526 | } | |
modified drivers/iio/light/rohm-bu27034.c
| @@ -137,6 +137,7 @@ static const struct iio_gain_sel_pair bu27034_gains[] = { | |||
| 137 | 137 | #define BU27034_MEAS_MODE_200MS 2 | |
| 138 | 138 | #define BU27034_MEAS_MODE_400MS 4 | |
| 139 | 139 | ||
| 140 | + | #define BU27034_INT_TIME_US_MIN (55 * USEC_PER_MSEC) | |
| 140 | 141 | static const struct iio_itime_sel_mul bu27034_itimes[] = { | |
| 141 | 142 | GAIN_SCALE_ITIME_US(400000, BU27034_MEAS_MODE_400MS, 8), | |
| 142 | 143 | GAIN_SCALE_ITIME_US(200000, BU27034_MEAS_MODE_200MS, 4), | |
| @@ -296,7 +297,7 @@ static int bu27034_get_gain(struct bu27034_data *data, int chan, int *gain) | |||
| 296 | 297 | return 0; | |
| 297 | 298 | } | |
| 298 | 299 | ||
| 299 | - | static int bu27034_get_int_time(struct bu27034_data *data) | |
| 300 | + | static int bu27034_get_int_time(struct bu27034_data *data, int *itime) | |
| 300 | 301 | { | |
| 301 | 302 | int ret, sel; | |
| 302 | 303 | ||
| @@ -304,24 +305,30 @@ static int bu27034_get_int_time(struct bu27034_data *data) | |||
| 304 | 305 | if (ret) | |
| 305 | 306 | return ret; | |
| 306 | 307 | ||
| 307 | - | return iio_gts_find_int_time_by_sel(&data->gts, | |
| 308 | - | sel & BU27034_MASK_MEAS_MODE); | |
| 308 | + | ret = iio_gts_find_int_time_by_sel(&data->gts, | |
| 309 | + | sel & BU27034_MASK_MEAS_MODE); | |
| 310 | + | if (ret < 0) | |
| 311 | + | return ret; | |
| 312 | + | ||
| 313 | + | *itime = ret; | |
| 314 | + | ||
| 315 | + | return 0; | |
| 309 | 316 | } | |
| 310 | 317 | ||
| 311 | 318 | static int _bu27034_get_scale(struct bu27034_data *data, int channel, int *val, | |
| 312 | 319 | int *val2) | |
| 313 | 320 | { | |
| 314 | - | int gain, ret; | |
| 321 | + | int gain, itime, ret; | |
| 315 | 322 | ||
| 316 | 323 | ret = bu27034_get_gain(data, channel, &gain); | |
| 317 | 324 | if (ret) | |
| 318 | 325 | return ret; | |
| 319 | 326 | ||
| 320 | - | ret = bu27034_get_int_time(data); | |
| 321 | - | if (ret < 0) | |
| 327 | + | ret = bu27034_get_int_time(data, &itime); | |
| 328 | + | if (ret) | |
| 322 | 329 | return ret; | |
| 323 | 330 | ||
| 324 | - | return iio_gts_get_scale(&data->gts, gain, ret, val, val2); | |
| 331 | + | return iio_gts_get_scale(&data->gts, gain, itime, val, val2); | |
| 325 | 332 | } | |
| 326 | 333 | ||
| 327 | 334 | static int bu27034_get_scale(struct bu27034_data *data, int channel, int *val, | |
| @@ -397,12 +404,10 @@ static int bu27034_try_set_int_time(struct bu27034_data *data, int time_us) | |||
| 397 | 404 | int ret, int_time_old, i; | |
| 398 | 405 | ||
| 399 | 406 | guard(mutex)(&data->mutex); | |
| 400 | - | ret = bu27034_get_int_time(data); | |
| 401 | - | if (ret < 0) | |
| 407 | + | ret = bu27034_get_int_time(data, &int_time_old); | |
| 408 | + | if (ret) | |
| 402 | 409 | return ret; | |
| 403 | 410 | ||
| 404 | - | int_time_old = ret; | |
| 405 | - | ||
| 406 | 411 | if (!iio_gts_valid_time(&data->gts, time_us)) { | |
| 407 | 412 | dev_err(data->dev, "Unsupported integration time %u\n", | |
| 408 | 413 | time_us); | |
| @@ -415,7 +420,7 @@ static int bu27034_try_set_int_time(struct bu27034_data *data, int time_us) | |||
| 415 | 420 | for (i = 0; i < numg; i++) { | |
| 416 | 421 | ret = bu27034_get_gain(data, gains[i].chan, &gains[i].old_gain); | |
| 417 | 422 | if (ret) | |
| 418 | - | return 0; | |
| 423 | + | return ret; | |
| 419 | 424 | ||
| 420 | 425 | ret = iio_gts_find_new_gain_by_old_gain_time(&data->gts, | |
| 421 | 426 | gains[i].old_gain, | |
| @@ -841,7 +846,7 @@ static int bu27034_meas_set(struct bu27034_data *data, bool en) | |||
| 841 | 846 | static int bu27034_get_single_result(struct bu27034_data *data, int chan, | |
| 842 | 847 | int *val) | |
| 843 | 848 | { | |
| 844 | - | int ret; | |
| 849 | + | int ret, itime; | |
| 845 | 850 | ||
| 846 | 851 | if (chan < BU27034_CHAN_DATA0 || chan > BU27034_CHAN_DATA1) | |
| 847 | 852 | return -EINVAL; | |
| @@ -850,11 +855,11 @@ static int bu27034_get_single_result(struct bu27034_data *data, int chan, | |||
| 850 | 855 | if (ret) | |
| 851 | 856 | return ret; | |
| 852 | 857 | ||
| 853 | - | ret = bu27034_get_int_time(data); | |
| 854 | - | if (ret < 0) | |
| 858 | + | ret = bu27034_get_int_time(data, &itime); | |
| 859 | + | if (ret) | |
| 855 | 860 | return ret; | |
| 856 | 861 | ||
| 857 | - | msleep(ret / 1000); | |
| 862 | + | msleep(itime / 1000); | |
| 858 | 863 | ||
| 859 | 864 | return bu27034_read_result(data, chan, val); | |
| 860 | 865 | } | |
| @@ -904,12 +909,10 @@ static int bu27034_calc_mlux(struct bu27034_data *data, __le16 *res, int *val) | |||
| 904 | 909 | if (ret) | |
| 905 | 910 | return ret; | |
| 906 | 911 | ||
| 907 | - | ret = bu27034_get_int_time(data); | |
| 908 | - | if (ret < 0) | |
| 912 | + | ret = bu27034_get_int_time(data, &meastime); | |
| 913 | + | if (ret) | |
| 909 | 914 | return ret; | |
| 910 | 915 | ||
| 911 | - | meastime = ret; | |
| 912 | - | ||
| 913 | 916 | d1_d0_ratio_scaled = (unsigned int)ch1 * (unsigned int)gain0 * 100; | |
| 914 | 917 | helper64 = (u64)ch1 * (u64)gain0 * 100LLU; | |
| 915 | 918 | ||
| @@ -970,9 +973,9 @@ static int bu27034_read_raw(struct iio_dev *idev, | |||
| 970 | 973 | switch (mask) { | |
| 971 | 974 | case IIO_CHAN_INFO_INT_TIME: | |
| 972 | 975 | *val = 0; | |
| 973 | - | *val2 = bu27034_get_int_time(data); | |
| 974 | - | if (*val2 < 0) | |
| 975 | - | return *val2; | |
| 976 | + | ret = bu27034_get_int_time(data, val2); | |
| 977 | + | if (ret) | |
| 978 | + | return ret; | |
| 976 | 979 | ||
| 977 | 980 | return IIO_VAL_INT_PLUS_MICRO; | |
| 978 | 981 | ||
| @@ -1157,11 +1160,20 @@ static int bu27034_buffer_thread(void *arg) | |||
| 1157 | 1160 | { | |
| 1158 | 1161 | struct iio_dev *idev = arg; | |
| 1159 | 1162 | struct bu27034_data *data; | |
| 1160 | - | int wait_ms; | |
| 1163 | + | int wait_ms, ret; | |
| 1161 | 1164 | ||
| 1162 | 1165 | data = iio_priv(idev); | |
| 1163 | 1166 | ||
| 1164 | - | wait_ms = bu27034_get_int_time(data); | |
| 1167 | + | /* | |
| 1168 | + | * If reading the integration time fails, default to the minimum so we | |
| 1169 | + | * don't lose samples. This may waste CPU cycles, but as a hardening | |
| 1170 | + | * against theoretical, once-in-a-blue-moon error, this should be Ok. | |
| 1171 | + | */ | |
| 1172 | + | wait_ms = BU27034_INT_TIME_US_MIN; | |
| 1173 | + | ret = bu27034_get_int_time(data, &wait_ms); | |
| 1174 | + | if (ret) | |
| 1175 | + | dev_warn(data->dev, "Failed to get integration time\n"); | |
| 1176 | + | ||
| 1165 | 1177 | wait_ms /= 1000; | |
| 1166 | 1178 | ||
| 1167 | 1179 | wait_ms -= BU27034_MEAS_WAIT_PREMATURE_MS; | |
modified drivers/iio/pressure/bmp280-core.c
| @@ -839,7 +839,7 @@ static int bmp280_write_sampling_frequency(struct bmp280_data *data, | |||
| 839 | 839 | int val, int val2) | |
| 840 | 840 | { | |
| 841 | 841 | const int (*avail)[2] = data->chip_info->sampling_freq_avail; | |
| 842 | - | const int n = data->chip_info->num_sampling_freq_avail; | |
| 842 | + | const int n = data->chip_info->num_sampling_freq_avail / 2; | |
| 843 | 843 | int ret, prev; | |
| 844 | 844 | int i; | |
| 845 | 845 | ||
modified drivers/iio/pressure/rohm-bm1390.c
| @@ -289,7 +289,7 @@ static int bm1390_read_data(struct bm1390_data *data, | |||
| 289 | 289 | if (warn) | |
| 290 | 290 | dev_warn(data->dev, "Failed to stop measurement (%d)\n", warn); | |
| 291 | 291 | ||
| 292 | - | return 0; | |
| 292 | + | return ret; | |
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | static int bm1390_read_raw(struct iio_dev *idev, | |
modified drivers/iio/proximity/aw96103.c
| @@ -24,6 +24,7 @@ | |||
| 24 | 24 | #define AW96103_BIN_VALID_DATA_OFFSET 64 | |
| 25 | 25 | #define AW96103_BIN_DATA_LEN_OFFSET 16 | |
| 26 | 26 | #define AW96103_BIN_DATA_REG_NUM_SIZE 4 | |
| 27 | + | #define AW96103_BIN_REG_SIZE 6 | |
| 27 | 28 | #define AW96103_BIN_CHIP_TYPE_SIZE 8 | |
| 28 | 29 | #define AW96103_BIN_CHIP_TYPE_OFFSET 24 | |
| 29 | 30 | ||
| @@ -229,14 +230,27 @@ static const struct aw_chip_info aw_chip_info_tbl[] = { | |||
| 229 | 230 | }, | |
| 230 | 231 | }; | |
| 231 | 232 | ||
| 232 | - | static void aw96103_parsing_bin_file(struct aw_bin *bin) | |
| 233 | + | static int aw96103_parsing_bin_file(struct aw_bin *bin) | |
| 233 | 234 | { | |
| 235 | + | u32 data_len; | |
| 236 | + | ||
| 237 | + | if (bin->len < AW96103_BIN_VALID_DATA_OFFSET) | |
| 238 | + | return -EINVAL; | |
| 239 | + | ||
| 240 | + | data_len = get_unaligned_le32(bin->data + AW96103_BIN_DATA_LEN_OFFSET); | |
| 241 | + | if (data_len < AW96103_BIN_DATA_REG_NUM_SIZE) | |
| 242 | + | return -EINVAL; | |
| 243 | + | ||
| 244 | + | bin->valid_data_len = data_len - AW96103_BIN_DATA_REG_NUM_SIZE; | |
| 245 | + | if (bin->valid_data_len > bin->len - AW96103_BIN_VALID_DATA_OFFSET || | |
| 246 | + | bin->valid_data_len % AW96103_BIN_REG_SIZE) | |
| 247 | + | return -EINVAL; | |
| 248 | + | ||
| 234 | 249 | bin->valid_data_addr = AW96103_BIN_VALID_DATA_OFFSET; | |
| 235 | - | bin->valid_data_len = | |
| 236 | - | *(unsigned int *)(bin->data + AW96103_BIN_DATA_LEN_OFFSET) - | |
| 237 | - | AW96103_BIN_DATA_REG_NUM_SIZE; | |
| 238 | 250 | memcpy(bin->chip_type, bin->data + AW96103_BIN_CHIP_TYPE_OFFSET, | |
| 239 | 251 | AW96103_BIN_CHIP_TYPE_SIZE); | |
| 252 | + | ||
| 253 | + | return 0; | |
| 240 | 254 | } | |
| 241 | 255 | ||
| 242 | 256 | static const struct regmap_config aw96103_regmap_confg = { | |
| @@ -500,7 +514,7 @@ static int aw96103_bin_valid_loaded(struct aw96103 *aw96103, | |||
| 500 | 514 | int ret; | |
| 501 | 515 | ||
| 502 | 516 | for (i = 0; i < aw_bin_data_s->valid_data_len; | |
| 503 | - | i += 6, start_addr += 6) { | |
| 517 | + | i += AW96103_BIN_REG_SIZE, start_addr += AW96103_BIN_REG_SIZE) { | |
| 504 | 518 | reg_addr = get_unaligned_le16(aw_bin_data_s->data + start_addr); | |
| 505 | 519 | reg_data = get_unaligned_le32(aw_bin_data_s->data + | |
| 506 | 520 | start_addr + 2); | |
| @@ -550,6 +564,8 @@ static int aw96103_para_loaded(struct aw96103 *aw96103) | |||
| 550 | 564 | static int aw96103_cfg_all_loaded(const struct firmware *cont, | |
| 551 | 565 | struct aw96103 *aw96103) | |
| 552 | 566 | { | |
| 567 | + | int ret; | |
| 568 | + | ||
| 553 | 569 | if (!cont) | |
| 554 | 570 | return -EINVAL; | |
| 555 | 571 | ||
| @@ -561,7 +577,9 @@ static int aw96103_cfg_all_loaded(const struct firmware *cont, | |||
| 561 | 577 | aw_bin->len = cont->size; | |
| 562 | 578 | memcpy(aw_bin->data, cont->data, cont->size); | |
| 563 | 579 | release_firmware(cont); | |
| 564 | - | aw96103_parsing_bin_file(aw_bin); | |
| 580 | + | ret = aw96103_parsing_bin_file(aw_bin); | |
| 581 | + | if (ret) | |
| 582 | + | return ret; | |
| 565 | 583 | ||
| 566 | 584 | return aw96103_bin_valid_loaded(aw96103, aw_bin); | |
| 567 | 585 | } | |
modified drivers/iio/proximity/isl29501.c
| @@ -226,7 +226,7 @@ err: | |||
| 226 | 226 | return ret; | |
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | - | static u32 isl29501_register_write(struct isl29501_private *isl29501, | |
| 229 | + | static int isl29501_register_write(struct isl29501_private *isl29501, | |
| 230 | 230 | enum isl29501_register_name name, | |
| 231 | 231 | u32 value) | |
| 232 | 232 | { | |
modified drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
| @@ -294,12 +294,14 @@ static int lidar_probe(struct i2c_client *client) | |||
| 294 | 294 | ||
| 295 | 295 | ret = pm_runtime_set_active(&client->dev); | |
| 296 | 296 | if (ret) | |
| 297 | - | goto error_unreg_buffer; | |
| 297 | + | goto error_unreg_dev; | |
| 298 | 298 | pm_runtime_enable(&client->dev); | |
| 299 | 299 | pm_runtime_idle(&client->dev); | |
| 300 | 300 | ||
| 301 | 301 | return 0; | |
| 302 | 302 | ||
| 303 | + | error_unreg_dev: | |
| 304 | + | iio_device_unregister(indio_dev); | |
| 303 | 305 | error_unreg_buffer: | |
| 304 | 306 | iio_triggered_buffer_cleanup(indio_dev); | |
| 305 | 307 | ||
modified drivers/iio/proximity/sx9324.c
| @@ -222,7 +222,7 @@ static const struct iio_chan_spec_ext_info sx9324_channel_ext_info[] = { | |||
| 222 | 222 | .scan_index = idx, \ | |
| 223 | 223 | .scan_type = { \ | |
| 224 | 224 | .sign = 's', \ | |
| 225 | - | .realbits = 12, \ | |
| 225 | + | .realbits = 16, \ | |
| 226 | 226 | .storagebits = 16, \ | |
| 227 | 227 | .endianness = IIO_BE, \ | |
| 228 | 228 | }, \ | |
modified drivers/iio/proximity/vcnl3020.c
| @@ -584,16 +584,26 @@ static irqreturn_t vcnl3020_handle_irq_thread(int irq, void *p) | |||
| 584 | 584 | return IRQ_HANDLED; | |
| 585 | 585 | } | |
| 586 | 586 | ||
| 587 | - | if (!(isr & VCNL_ICR_THRES_EN)) | |
| 587 | + | if (!(isr & (VCNL_INT_TH_HI | VCNL_INT_TH_LOW))) | |
| 588 | 588 | return IRQ_NONE; | |
| 589 | 589 | ||
| 590 | - | iio_push_event(indio_dev, | |
| 591 | - | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1, | |
| 592 | - | IIO_EV_TYPE_THRESH, | |
| 593 | - | IIO_EV_DIR_RISING), | |
| 594 | - | iio_get_time_ns(indio_dev)); | |
| 590 | + | if (isr & VCNL_INT_TH_HI) { | |
| 591 | + | iio_push_event(indio_dev, | |
| 592 | + | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, | |
| 593 | + | IIO_EV_TYPE_THRESH, | |
| 594 | + | IIO_EV_DIR_RISING), | |
| 595 | + | iio_get_time_ns(indio_dev)); | |
| 596 | + | } | |
| 597 | + | ||
| 598 | + | if (isr & VCNL_INT_TH_LOW) { | |
| 599 | + | iio_push_event(indio_dev, | |
| 600 | + | IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0, | |
| 601 | + | IIO_EV_TYPE_THRESH, | |
| 602 | + | IIO_EV_DIR_FALLING), | |
| 603 | + | iio_get_time_ns(indio_dev)); | |
| 604 | + | } | |
| 595 | 605 | ||
| 596 | - | rc = regmap_write(data->regmap, VCNL_ISR, isr & VCNL_ICR_THRES_EN); | |
| 606 | + | rc = regmap_write(data->regmap, VCNL_ISR, isr & (VCNL_INT_TH_HI | VCNL_INT_TH_LOW)); | |
| 597 | 607 | if (rc) | |
| 598 | 608 | dev_err(data->dev, "Error (%d) writing in reg (0x%x)\n", | |
| 599 | 609 | rc, VCNL_ISR); | |
modified drivers/iio/proximity/vl53l0x-i2c.c
| @@ -219,7 +219,10 @@ static int vl53l0x_read_raw(struct iio_dev *indio_dev, | |||
| 219 | 219 | ||
| 220 | 220 | switch (mask) { | |
| 221 | 221 | case IIO_CHAN_INFO_RAW: | |
| 222 | + | if (!iio_device_claim_direct(indio_dev)) | |
| 223 | + | return -EBUSY; | |
| 222 | 224 | ret = vl53l0x_read_proximity(data, chan, val); | |
| 225 | + | iio_device_release_direct(indio_dev); | |
| 223 | 226 | if (ret < 0) | |
| 224 | 227 | return ret; | |
| 225 | 228 | ||
modified drivers/infiniband/core/iwpm_util.c
| @@ -314,10 +314,6 @@ struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq, | |||
| 314 | 314 | if (!nlmsg_request) | |
| 315 | 315 | return NULL; | |
| 316 | 316 | ||
| 317 | - | spin_lock_irqsave(&iwpm_nlmsg_req_lock, flags); | |
| 318 | - | list_add_tail(&nlmsg_request->inprocess_list, &iwpm_nlmsg_req_list); | |
| 319 | - | spin_unlock_irqrestore(&iwpm_nlmsg_req_lock, flags); | |
| 320 | - | ||
| 321 | 317 | kref_init(&nlmsg_request->kref); | |
| 322 | 318 | kref_get(&nlmsg_request->kref); | |
| 323 | 319 | nlmsg_request->nlmsg_seq = nlmsg_seq; | |
| @@ -326,6 +322,11 @@ struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq, | |||
| 326 | 322 | nlmsg_request->err_code = 0; | |
| 327 | 323 | sema_init(&nlmsg_request->sem, 1); | |
| 328 | 324 | down(&nlmsg_request->sem); | |
| 325 | + | ||
| 326 | + | spin_lock_irqsave(&iwpm_nlmsg_req_lock, flags); | |
| 327 | + | list_add_tail(&nlmsg_request->inprocess_list, &iwpm_nlmsg_req_list); | |
| 328 | + | spin_unlock_irqrestore(&iwpm_nlmsg_req_lock, flags); | |
| 329 | + | ||
| 329 | 330 | return nlmsg_request; | |
| 330 | 331 | } | |
| 331 | 332 | ||
modified drivers/infiniband/core/mad.c
| @@ -2059,6 +2059,8 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
| 2059 | 2059 | int ret; | |
| 2060 | 2060 | ||
| 2061 | 2061 | INIT_LIST_HEAD(&mad_recv_wc->rmpp_list); | |
| 2062 | + | list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); | |
| 2063 | + | ||
| 2062 | 2064 | ret = ib_mad_enforce_security(mad_agent_priv, | |
| 2063 | 2065 | mad_recv_wc->wc->pkey_index); | |
| 2064 | 2066 | if (ret) { | |
| @@ -2067,7 +2069,6 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, | |||
| 2067 | 2069 | return; | |
| 2068 | 2070 | } | |
| 2069 | 2071 | ||
| 2070 | - | list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); | |
| 2071 | 2072 | if (is_kernel_rmpp_data_response(mad_agent_priv, mad_recv_wc)) { | |
| 2072 | 2073 | spin_lock_irqsave(&mad_agent_priv->lock, flags); | |
| 2073 | 2074 | mad_send_wr = ib_find_send_mad(mad_agent_priv, mad_recv_wc); | |
modified drivers/infiniband/core/rdma_core.c
| @@ -69,7 +69,6 @@ void ib_uverbs_release_file(struct kref *ref) | |||
| 69 | 69 | ||
| 70 | 70 | if (file->disassociate_page) | |
| 71 | 71 | __free_pages(file->disassociate_page, 0); | |
| 72 | - | mutex_destroy(&file->disassociation_lock); | |
| 73 | 72 | mutex_destroy(&file->umap_lock); | |
| 74 | 73 | mutex_destroy(&file->ucontext_lock); | |
| 75 | 74 | kfree(file); | |
modified drivers/infiniband/core/ucma.c
| @@ -1556,9 +1556,10 @@ static ssize_t ucma_process_join(struct ucma_file *file, | |||
| 1556 | 1556 | mutex_lock(&ctx->mutex); | |
| 1557 | 1557 | ret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr, | |
| 1558 | 1558 | join_state, mc); | |
| 1559 | - | mutex_unlock(&ctx->mutex); | |
| 1560 | - | if (ret) | |
| 1559 | + | if (ret) { | |
| 1560 | + | mutex_unlock(&ctx->mutex); | |
| 1561 | 1561 | goto err_xa_erase; | |
| 1562 | + | } | |
| 1562 | 1563 | ||
| 1563 | 1564 | resp.id = mc->id; | |
| 1564 | 1565 | if (copy_to_user(u64_to_user_ptr(cmd->response), | |
| @@ -1566,6 +1567,7 @@ static ssize_t ucma_process_join(struct ucma_file *file, | |||
| 1566 | 1567 | ret = -EFAULT; | |
| 1567 | 1568 | goto err_leave_multicast; | |
| 1568 | 1569 | } | |
| 1570 | + | mutex_unlock(&ctx->mutex); | |
| 1569 | 1571 | ||
| 1570 | 1572 | xa_store(&multicast_table, mc->id, mc, 0); | |
| 1571 | 1573 | ||
| @@ -1573,7 +1575,6 @@ static ssize_t ucma_process_join(struct ucma_file *file, | |||
| 1573 | 1575 | return 0; | |
| 1574 | 1576 | ||
| 1575 | 1577 | err_leave_multicast: | |
| 1576 | - | mutex_lock(&ctx->mutex); | |
| 1577 | 1578 | rdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr); | |
| 1578 | 1579 | mutex_unlock(&ctx->mutex); | |
| 1579 | 1580 | ucma_cleanup_mc_events(mc); | |
modified drivers/infiniband/core/uverbs_flow.c
| @@ -26,6 +26,7 @@ out: | |||
| 26 | 26 | return resources; | |
| 27 | 27 | ||
| 28 | 28 | err: | |
| 29 | + | kfree(resources->collection); | |
| 29 | 30 | kfree(resources->counters); | |
| 30 | 31 | kfree(resources); | |
| 31 | 32 | ||
modified drivers/infiniband/core/uverbs_main.c
| @@ -644,12 +644,15 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) | |||
| 644 | 644 | goto out; | |
| 645 | 645 | } | |
| 646 | 646 | ||
| 647 | - | mutex_lock(&file->disassociation_lock); | |
| 647 | + | if (!down_read_trylock(&file->hw_destroy_rwsem)) { | |
| 648 | + | ret = -EIO; | |
| 649 | + | goto out; | |
| 650 | + | } | |
| 648 | 651 | ||
| 649 | 652 | vma->vm_ops = &rdma_umap_ops; | |
| 650 | 653 | ret = ucontext->device->ops.mmap(ucontext, vma); | |
| 651 | 654 | ||
| 652 | - | mutex_unlock(&file->disassociation_lock); | |
| 655 | + | up_read(&file->hw_destroy_rwsem); | |
| 653 | 656 | out: | |
| 654 | 657 | srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); | |
| 655 | 658 | return ret; | |
| @@ -671,7 +674,6 @@ static void rdma_umap_open(struct vm_area_struct *vma) | |||
| 671 | 674 | /* We are racing with disassociation */ | |
| 672 | 675 | if (!down_read_trylock(&ufile->hw_destroy_rwsem)) | |
| 673 | 676 | goto out_zap; | |
| 674 | - | mutex_lock(&ufile->disassociation_lock); | |
| 675 | 677 | ||
| 676 | 678 | /* | |
| 677 | 679 | * Disassociation already completed, the VMA should already be zapped. | |
| @@ -684,12 +686,10 @@ static void rdma_umap_open(struct vm_area_struct *vma) | |||
| 684 | 686 | goto out_unlock; | |
| 685 | 687 | rdma_umap_priv_init(priv, vma, opriv->entry); | |
| 686 | 688 | ||
| 687 | - | mutex_unlock(&ufile->disassociation_lock); | |
| 688 | 689 | up_read(&ufile->hw_destroy_rwsem); | |
| 689 | 690 | return; | |
| 690 | 691 | ||
| 691 | 692 | out_unlock: | |
| 692 | - | mutex_unlock(&ufile->disassociation_lock); | |
| 693 | 693 | up_read(&ufile->hw_destroy_rwsem); | |
| 694 | 694 | out_zap: | |
| 695 | 695 | /* | |
| @@ -773,7 +773,7 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile) | |||
| 773 | 773 | { | |
| 774 | 774 | struct rdma_umap_priv *priv, *next_priv; | |
| 775 | 775 | ||
| 776 | - | mutex_lock(&ufile->disassociation_lock); | |
| 776 | + | lockdep_assert_held_write(&ufile->hw_destroy_rwsem); | |
| 777 | 777 | ||
| 778 | 778 | while (1) { | |
| 779 | 779 | struct mm_struct *mm = NULL; | |
| @@ -799,10 +799,8 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile) | |||
| 799 | 799 | break; | |
| 800 | 800 | } | |
| 801 | 801 | mutex_unlock(&ufile->umap_lock); | |
| 802 | - | if (!mm) { | |
| 803 | - | mutex_unlock(&ufile->disassociation_lock); | |
| 802 | + | if (!mm) | |
| 804 | 803 | return; | |
| 805 | - | } | |
| 806 | 804 | ||
| 807 | 805 | /* | |
| 808 | 806 | * The umap_lock is nested under mmap_lock since it used within | |
| @@ -832,8 +830,6 @@ void uverbs_user_mmap_disassociate(struct ib_uverbs_file *ufile) | |||
| 832 | 830 | mmap_read_unlock(mm); | |
| 833 | 831 | mmput(mm); | |
| 834 | 832 | } | |
| 835 | - | ||
| 836 | - | mutex_unlock(&ufile->disassociation_lock); | |
| 837 | 833 | } | |
| 838 | 834 | ||
| 839 | 835 | /** | |
| @@ -851,8 +847,11 @@ void rdma_user_mmap_disassociate(struct ib_device *device) | |||
| 851 | 847 | ||
| 852 | 848 | mutex_lock(&uverbs_dev->lists_mutex); | |
| 853 | 849 | list_for_each_entry(ufile, &uverbs_dev->uverbs_file_list, list) { | |
| 854 | - | if (ufile->ucontext) | |
| 850 | + | if (ufile->ucontext) { | |
| 851 | + | down_write(&ufile->hw_destroy_rwsem); | |
| 855 | 852 | uverbs_user_mmap_disassociate(ufile); | |
| 853 | + | up_write(&ufile->hw_destroy_rwsem); | |
| 854 | + | } | |
| 856 | 855 | } | |
| 857 | 856 | mutex_unlock(&uverbs_dev->lists_mutex); | |
| 858 | 857 | } | |
| @@ -927,8 +926,6 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) | |||
| 927 | 926 | mutex_init(&file->umap_lock); | |
| 928 | 927 | INIT_LIST_HEAD(&file->umaps); | |
| 929 | 928 | ||
| 930 | - | mutex_init(&file->disassociation_lock); | |
| 931 | - | ||
| 932 | 929 | filp->private_data = file; | |
| 933 | 930 | list_add_tail(&file->list, &dev->uverbs_file_list); | |
| 934 | 931 | mutex_unlock(&dev->lists_mutex); | |
modified drivers/infiniband/core/verbs.c
| @@ -2058,11 +2058,13 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width) | |||
| 2058 | 2058 | return -ENODEV; | |
| 2059 | 2059 | ||
| 2060 | 2060 | rtnl_lock(); | |
| 2061 | - | rc = __ethtool_get_link_ksettings(netdev, &lksettings); | |
| 2062 | - | rtnl_unlock(); | |
| 2063 | - | ||
| 2064 | - | dev_put(netdev); | |
| 2061 | + | if (READ_ONCE(netdev->reg_state) != NETREG_REGISTERED) { | |
| 2062 | + | dev_put(netdev); | |
| 2063 | + | rtnl_unlock(); | |
| 2064 | + | return -ENODEV; | |
| 2065 | + | } | |
| 2065 | 2066 | ||
| 2067 | + | rc = __ethtool_get_link_ksettings(netdev, &lksettings); | |
| 2066 | 2068 | if (!rc && lksettings.base.speed != (u32)SPEED_UNKNOWN) { | |
| 2067 | 2069 | netdev_speed = lksettings.base.speed; | |
| 2068 | 2070 | } else { | |
| @@ -2071,6 +2073,8 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width) | |||
| 2071 | 2073 | pr_warn("%s speed is unknown, defaulting to %u\n", | |
| 2072 | 2074 | netdev->name, netdev_speed); | |
| 2073 | 2075 | } | |
| 2076 | + | dev_put(netdev); | |
| 2077 | + | rtnl_unlock(); | |
| 2074 | 2078 | ||
| 2075 | 2079 | ib_get_width_and_speed(netdev_speed, lksettings.lanes, | |
| 2076 | 2080 | speed, width); | |
modified drivers/infiniband/hw/bnxt_re/main.c
| @@ -356,9 +356,13 @@ static int bnxt_re_update_qp1_tos_dscp(struct bnxt_re_dev *rdev) | |||
| 356 | 356 | return bnxt_qplib_modify_qp(&rdev->qplib_res, &qp->qplib_qp); | |
| 357 | 357 | } | |
| 358 | 358 | ||
| 359 | - | static void bnxt_re_init_dcb_wq(struct bnxt_re_dev *rdev) | |
| 359 | + | static int bnxt_re_init_dcb_wq(struct bnxt_re_dev *rdev) | |
| 360 | 360 | { | |
| 361 | 361 | rdev->dcb_wq = create_singlethread_workqueue("bnxt_re_dcb_wq"); | |
| 362 | + | if (!rdev->dcb_wq) | |
| 363 | + | return -ENOMEM; | |
| 364 | + | ||
| 365 | + | return 0; | |
| 362 | 366 | } | |
| 363 | 367 | ||
| 364 | 368 | static void bnxt_re_uninit_dcb_wq(struct bnxt_re_dev *rdev) | |
| @@ -2339,7 +2343,9 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type) | |||
| 2339 | 2343 | } | |
| 2340 | 2344 | bnxt_re_debugfs_add_pdev(rdev); | |
| 2341 | 2345 | ||
| 2342 | - | bnxt_re_init_dcb_wq(rdev); | |
| 2346 | + | rc = bnxt_re_init_dcb_wq(rdev); | |
| 2347 | + | if (rc) | |
| 2348 | + | goto fail; | |
| 2343 | 2349 | bnxt_re_net_register_async_event(rdev); | |
| 2344 | 2350 | ||
| 2345 | 2351 | if (!rdev->is_virtfn) | |
modified drivers/infiniband/hw/bnxt_re/uapi.c
| @@ -462,7 +462,6 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_DBR_ALLOC)(struct uverbs_attr_bundle *a | |||
| 462 | 462 | uobj->object = obj; | |
| 463 | 463 | uverbs_finalize_uobj_create(attrs, BNXT_RE_ALLOC_DBR_HANDLE); | |
| 464 | 464 | ||
| 465 | - | dbr.umdbr = dpi->umdbr; | |
| 466 | 465 | dbr.dpi = dpi->dpi; | |
| 467 | 466 | ret = uverbs_copy_to_struct_or_zero(attrs, BNXT_RE_ALLOC_DBR_ATTR, | |
| 468 | 467 | &dbr, sizeof(dbr)); | |
| @@ -525,7 +524,6 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_DEFAULT_DBR)(struct uverbs_attr_bun | |||
| 525 | 524 | return PTR_ERR(ib_uctx); | |
| 526 | 525 | ||
| 527 | 526 | uctx = container_of(ib_uctx, struct bnxt_re_ucontext, ib_uctx); | |
| 528 | - | dpi.umdbr = uctx->dpi.umdbr; | |
| 529 | 527 | dpi.dpi = uctx->dpi.dpi; | |
| 530 | 528 | ||
| 531 | 529 | ret = uverbs_copy_to_struct_or_zero(attrs, BNXT_RE_DEFAULT_DBR_ATTR, | |
| @@ -543,7 +541,7 @@ DECLARE_UVERBS_NAMED_METHOD(BNXT_RE_METHOD_DBR_ALLOC, | |||
| 543 | 541 | UA_MANDATORY), | |
| 544 | 542 | UVERBS_ATTR_PTR_OUT(BNXT_RE_ALLOC_DBR_ATTR, | |
| 545 | 543 | UVERBS_ATTR_STRUCT(struct bnxt_re_db_region, | |
| 546 | - | umdbr), | |
| 544 | + | reserved2), | |
| 547 | 545 | UA_MANDATORY), | |
| 548 | 546 | UVERBS_ATTR_PTR_OUT(BNXT_RE_ALLOC_DBR_OFFSET, | |
| 549 | 547 | UVERBS_ATTR_TYPE(u64), | |
| @@ -563,7 +561,7 @@ DECLARE_UVERBS_NAMED_OBJECT(BNXT_RE_OBJECT_DBR, | |||
| 563 | 561 | DECLARE_UVERBS_NAMED_METHOD(BNXT_RE_METHOD_GET_DEFAULT_DBR, | |
| 564 | 562 | UVERBS_ATTR_PTR_OUT(BNXT_RE_DEFAULT_DBR_ATTR, | |
| 565 | 563 | UVERBS_ATTR_STRUCT(struct bnxt_re_db_region, | |
| 566 | - | umdbr), | |
| 564 | + | reserved2), | |
| 567 | 565 | UA_MANDATORY)); | |
| 568 | 566 | ||
| 569 | 567 | DECLARE_UVERBS_GLOBAL_METHODS(BNXT_RE_OBJECT_DEFAULT_DBR, | |
modified drivers/infiniband/hw/efa/efa_com.c
| @@ -850,7 +850,7 @@ int efa_com_admin_init(struct efa_com_dev *edev, | |||
| 850 | 850 | ||
| 851 | 851 | aq->dmadev = edev->dmadev; | |
| 852 | 852 | aq->efa_dev = edev->efa_dev; | |
| 853 | - | set_bit(EFA_AQ_STATE_POLLING_BIT, &aq->state); | |
| 853 | + | efa_com_set_admin_polling_mode(edev, true); | |
| 854 | 854 | ||
| 855 | 855 | sema_init(&aq->avail_cmds, aq->depth); | |
| 856 | 856 | ||
| @@ -868,8 +868,6 @@ int efa_com_admin_init(struct efa_com_dev *edev, | |||
| 868 | 868 | if (err) | |
| 869 | 869 | goto err_destroy_sq; | |
| 870 | 870 | ||
| 871 | - | efa_com_set_admin_polling_mode(edev, false); | |
| 872 | - | ||
| 873 | 871 | err = efa_com_admin_init_aenq(edev, aenq_handlers); | |
| 874 | 872 | if (err) | |
| 875 | 873 | goto err_destroy_cq; | |
| @@ -1254,7 +1252,7 @@ static void efa_com_destroy_eq(struct efa_com_dev *edev, | |||
| 1254 | 1252 | err); | |
| 1255 | 1253 | } | |
| 1256 | 1254 | ||
| 1257 | - | static void efa_com_arm_eq(struct efa_com_dev *edev, struct efa_com_eq *eeq) | |
| 1255 | + | void efa_com_arm_eq(struct efa_com_dev *edev, struct efa_com_eq *eeq) | |
| 1258 | 1256 | { | |
| 1259 | 1257 | u32 val = 0; | |
| 1260 | 1258 | ||
| @@ -1343,7 +1341,6 @@ int efa_com_eq_init(struct efa_com_dev *edev, struct efa_com_eq *eeq, | |||
| 1343 | 1341 | eeq->phase = 1; | |
| 1344 | 1342 | eeq->depth = params.depth; | |
| 1345 | 1343 | eeq->cb = cb; | |
| 1346 | - | efa_com_arm_eq(edev, eeq); | |
| 1347 | 1344 | ||
| 1348 | 1345 | return 0; | |
| 1349 | 1346 | ||
modified drivers/infiniband/hw/efa/efa_com.h
| @@ -169,6 +169,7 @@ int efa_com_admin_init(struct efa_com_dev *edev, | |||
| 169 | 169 | void efa_com_admin_destroy(struct efa_com_dev *edev); | |
| 170 | 170 | int efa_com_eq_init(struct efa_com_dev *edev, struct efa_com_eq *eeq, | |
| 171 | 171 | efa_eqe_handler cb, u16 depth, u8 msix_vec); | |
| 172 | + | void efa_com_arm_eq(struct efa_com_dev *edev, struct efa_com_eq *eeq); | |
| 172 | 173 | void efa_com_eq_destroy(struct efa_com_dev *edev, struct efa_com_eq *eeq); | |
| 173 | 174 | int efa_com_dev_reset(struct efa_com_dev *edev, | |
| 174 | 175 | enum efa_regs_reset_reason_types reset_reason); | |
modified drivers/infiniband/hw/efa/efa_main.c
| @@ -302,28 +302,30 @@ static void efa_set_host_info(struct efa_dev *dev) | |||
| 302 | 302 | ||
| 303 | 303 | static void efa_destroy_eq(struct efa_dev *dev, struct efa_eq *eq) | |
| 304 | 304 | { | |
| 305 | - | efa_com_eq_destroy(&dev->edev, &eq->eeq); | |
| 306 | 305 | efa_free_irq(dev, &eq->irq); | |
| 306 | + | efa_com_eq_destroy(&dev->edev, &eq->eeq); | |
| 307 | 307 | } | |
| 308 | 308 | ||
| 309 | 309 | static int efa_create_eq(struct efa_dev *dev, struct efa_eq *eq, u32 msix_vec) | |
| 310 | 310 | { | |
| 311 | 311 | int err; | |
| 312 | 312 | ||
| 313 | - | efa_setup_comp_irq(dev, eq, msix_vec); | |
| 314 | - | err = efa_request_irq(dev, &eq->irq); | |
| 313 | + | err = efa_com_eq_init(&dev->edev, &eq->eeq, efa_process_eqe, | |
| 314 | + | dev->dev_attr.max_eq_depth, msix_vec); | |
| 315 | 315 | if (err) | |
| 316 | 316 | return err; | |
| 317 | 317 | ||
| 318 | - | err = efa_com_eq_init(&dev->edev, &eq->eeq, efa_process_eqe, | |
| 319 | - | dev->dev_attr.max_eq_depth, msix_vec); | |
| 318 | + | efa_setup_comp_irq(dev, eq, msix_vec); | |
| 319 | + | err = efa_request_irq(dev, &eq->irq); | |
| 320 | 320 | if (err) | |
| 321 | - | goto err_free_comp_irq; | |
| 321 | + | goto err_destroy_eq; | |
| 322 | + | ||
| 323 | + | efa_com_arm_eq(&dev->edev, &eq->eeq); | |
| 322 | 324 | ||
| 323 | 325 | return 0; | |
| 324 | 326 | ||
| 325 | - | err_free_comp_irq: | |
| 326 | - | efa_free_irq(dev, &eq->irq); | |
| 327 | + | err_destroy_eq: | |
| 328 | + | efa_com_eq_destroy(&dev->edev, &eq->eeq); | |
| 327 | 329 | return err; | |
| 328 | 330 | } | |
| 329 | 331 | ||
| @@ -619,18 +621,21 @@ static struct efa_dev *efa_probe_device(struct pci_dev *pdev) | |||
| 619 | 621 | edev->aq.msix_vector_idx = dev->admin_msix_vector_idx; | |
| 620 | 622 | edev->aenq.msix_vector_idx = dev->admin_msix_vector_idx; | |
| 621 | 623 | ||
| 622 | - | err = efa_set_mgmnt_irq(dev); | |
| 624 | + | err = efa_com_admin_init(edev, &aenq_handlers); | |
| 623 | 625 | if (err) | |
| 624 | 626 | goto err_disable_msix; | |
| 625 | 627 | ||
| 626 | - | err = efa_com_admin_init(edev, &aenq_handlers); | |
| 628 | + | err = efa_set_mgmnt_irq(dev); | |
| 627 | 629 | if (err) | |
| 628 | - | goto err_free_mgmnt_irq; | |
| 630 | + | goto err_destroy_admin; | |
| 631 | + | ||
| 632 | + | efa_com_set_admin_polling_mode(edev, false); | |
| 629 | 633 | ||
| 630 | 634 | return dev; | |
| 631 | 635 | ||
| 632 | - | err_free_mgmnt_irq: | |
| 633 | - | efa_free_irq(dev, &dev->admin_irq); | |
| 636 | + | err_destroy_admin: | |
| 637 | + | efa_com_dev_reset(edev, EFA_REGS_RESET_INIT_ERR); | |
| 638 | + | efa_com_admin_destroy(edev); | |
| 634 | 639 | err_disable_msix: | |
| 635 | 640 | efa_disable_msix(dev); | |
| 636 | 641 | err_reg_read_destroy: | |
| @@ -654,8 +659,8 @@ static void efa_remove_device(struct pci_dev *pdev, | |||
| 654 | 659 | ||
| 655 | 660 | edev = &dev->edev; | |
| 656 | 661 | efa_com_dev_reset(edev, reset_reason); | |
| 657 | - | efa_com_admin_destroy(edev); | |
| 658 | 662 | efa_free_irq(dev, &dev->admin_irq); | |
| 663 | + | efa_com_admin_destroy(edev); | |
| 659 | 664 | efa_disable_msix(dev); | |
| 660 | 665 | efa_com_mmio_reg_read_destroy(edev); | |
| 661 | 666 | devm_iounmap(&pdev->dev, edev->reg_bar); | |
modified drivers/infiniband/hw/erdma/erdma_main.c
| @@ -572,8 +572,8 @@ static int erdma_ib_device_add(struct pci_dev *pdev) | |||
| 572 | 572 | INIT_LIST_HEAD(&dev->cep_list); | |
| 573 | 573 | ||
| 574 | 574 | spin_lock_init(&dev->lock); | |
| 575 | - | xa_init_flags(&dev->qp_xa, XA_FLAGS_ALLOC1); | |
| 576 | - | xa_init_flags(&dev->cq_xa, XA_FLAGS_ALLOC1); | |
| 575 | + | xa_init_flags(&dev->qp_xa, XA_FLAGS_ALLOC1 | XA_FLAGS_LOCK_IRQ); | |
| 576 | + | xa_init_flags(&dev->cq_xa, XA_FLAGS_ALLOC1 | XA_FLAGS_LOCK_IRQ); | |
| 577 | 577 | dev->next_alloc_cqn = 1; | |
| 578 | 578 | dev->next_alloc_qpn = 1; | |
| 579 | 579 | ||
modified drivers/infiniband/hw/erdma/erdma_verbs.c
| @@ -1021,15 +1021,15 @@ int erdma_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs, | |||
| 1021 | 1021 | init_completion(&qp->safe_free); | |
| 1022 | 1022 | ||
| 1023 | 1023 | if (qp->ibqp.qp_type == IB_QPT_GSI) { | |
| 1024 | - | old_entry = xa_store(&dev->qp_xa, 1, qp, GFP_KERNEL); | |
| 1024 | + | old_entry = xa_store_irq(&dev->qp_xa, 1, qp, GFP_KERNEL); | |
| 1025 | 1025 | if (xa_is_err(old_entry)) | |
| 1026 | 1026 | ret = xa_err(old_entry); | |
| 1027 | 1027 | else | |
| 1028 | 1028 | qp->ibqp.qp_num = 1; | |
| 1029 | 1029 | } else { | |
| 1030 | - | ret = xa_alloc_cyclic(&dev->qp_xa, &qp->ibqp.qp_num, qp, | |
| 1031 | - | XA_LIMIT(1, dev->attrs.max_qp - 1), | |
| 1032 | - | &dev->next_alloc_qpn, GFP_KERNEL); | |
| 1030 | + | ret = xa_alloc_cyclic_irq(&dev->qp_xa, &qp->ibqp.qp_num, qp, | |
| 1031 | + | XA_LIMIT(1, dev->attrs.max_qp - 1), | |
| 1032 | + | &dev->next_alloc_qpn, GFP_KERNEL); | |
| 1033 | 1033 | } | |
| 1034 | 1034 | ||
| 1035 | 1035 | if (ret < 0) { | |
| @@ -1089,7 +1089,7 @@ err_out_cmd: | |||
| 1089 | 1089 | else | |
| 1090 | 1090 | free_kernel_qp(qp); | |
| 1091 | 1091 | err_out_xa: | |
| 1092 | - | xa_erase(&dev->qp_xa, QP_ID(qp)); | |
| 1092 | + | xa_erase_irq(&dev->qp_xa, QP_ID(qp)); | |
| 1093 | 1093 | err_out: | |
| 1094 | 1094 | return ret; | |
| 1095 | 1095 | } | |
| @@ -1993,9 +1993,9 @@ int erdma_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, | |||
| 1993 | 1993 | refcount_set(&cq->refcount, 1); | |
| 1994 | 1994 | init_completion(&cq->free); | |
| 1995 | 1995 | ||
| 1996 | - | ret = xa_alloc_cyclic(&dev->cq_xa, &cq->cqn, cq, | |
| 1997 | - | XA_LIMIT(1, dev->attrs.max_cq - 1), | |
| 1998 | - | &dev->next_alloc_cqn, GFP_KERNEL); | |
| 1996 | + | ret = xa_alloc_cyclic_irq(&dev->cq_xa, &cq->cqn, cq, | |
| 1997 | + | XA_LIMIT(1, dev->attrs.max_cq - 1), | |
| 1998 | + | &dev->next_alloc_cqn, GFP_KERNEL); | |
| 1999 | 1999 | if (ret < 0) | |
| 2000 | 2000 | return ret; | |
| 2001 | 2001 | ||
| @@ -2041,7 +2041,7 @@ err_free_res: | |||
| 2041 | 2041 | } | |
| 2042 | 2042 | ||
| 2043 | 2043 | err_out_xa: | |
| 2044 | - | xa_erase(&dev->cq_xa, cq->cqn); | |
| 2044 | + | xa_erase_irq(&dev->cq_xa, cq->cqn); | |
| 2045 | 2045 | ||
| 2046 | 2046 | return ret; | |
| 2047 | 2047 | } | |
modified drivers/infiniband/hw/hfi1/file_ops.c
| @@ -326,6 +326,7 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) | |||
| 326 | 326 | void *memvirt = NULL; | |
| 327 | 327 | dma_addr_t memdma = 0; | |
| 328 | 328 | u8 subctxt, mapio = 0, vmf = 0, type; | |
| 329 | + | size_t memdmalen = 0; | |
| 329 | 330 | ssize_t memlen = 0; | |
| 330 | 331 | int ret = 0; | |
| 331 | 332 | u16 ctxt; | |
| @@ -371,7 +372,9 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) | |||
| 371 | 372 | mapio = 1; | |
| 372 | 373 | break; | |
| 373 | 374 | case PIO_CRED: { | |
| 375 | + | struct credit_return_base *cr = &dd->cr_base[uctxt->sc->node]; | |
| 374 | 376 | u64 cr_page_offset; | |
| 377 | + | ||
| 375 | 378 | if (flags & VM_WRITE) { | |
| 376 | 379 | ret = -EPERM; | |
| 377 | 380 | goto done; | |
| @@ -381,11 +384,18 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) | |||
| 381 | 384 | * second or third page allocated for credit returns (if number | |
| 382 | 385 | * of enabled contexts > 64 and 128 respectively). | |
| 383 | 386 | */ | |
| 384 | - | cr_page_offset = ((u64)uctxt->sc->hw_free - | |
| 385 | - | (u64)dd->cr_base[uctxt->numa_id].va) & | |
| 386 | - | PAGE_MASK; | |
| 387 | - | memvirt = dd->cr_base[uctxt->numa_id].va + cr_page_offset; | |
| 388 | - | memdma = dd->cr_base[uctxt->numa_id].dma + cr_page_offset; | |
| 387 | + | cr_page_offset = ((u64)uctxt->sc->hw_free - (u64)cr->va) & | |
| 388 | + | PAGE_MASK; | |
| 389 | + | /* | |
| 390 | + | * dma_mmap_coherent() describes the whole coherent buffer and | |
| 391 | + | * selects the page within it with vma->vm_pgoff, so pass the | |
| 392 | + | * base of the allocation and its length and let vm_pgoff pick | |
| 393 | + | * the page. | |
| 394 | + | */ | |
| 395 | + | vma->vm_pgoff = cr_page_offset >> PAGE_SHIFT; | |
| 396 | + | memvirt = cr->va; | |
| 397 | + | memdma = cr->dma; | |
| 398 | + | memdmalen = TXE_NUM_CONTEXTS * sizeof(struct credit_return); | |
| 389 | 399 | memlen = PAGE_SIZE; | |
| 390 | 400 | flags &= ~VM_MAYWRITE; | |
| 391 | 401 | flags |= VM_DONTCOPY | VM_DONTEXPAND; | |
| @@ -567,7 +577,8 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) | |||
| 567 | 577 | ret = 0; | |
| 568 | 578 | } else if (memdma) { | |
| 569 | 579 | ret = dma_mmap_coherent(&dd->pcidev->dev, vma, | |
| 570 | - | memvirt, memdma, memlen); | |
| 580 | + | memvirt, memdma, | |
| 581 | + | memdmalen ? memdmalen : memlen); | |
| 571 | 582 | } else if (mapio) { | |
| 572 | 583 | ret = io_remap_pfn_range(vma, vma->vm_start, | |
| 573 | 584 | PFN_DOWN(memaddr), | |
modified drivers/infiniband/hw/irdma/verbs.c
| @@ -4281,7 +4281,7 @@ static int irdma_post_send(struct ib_qp *ibqp, | |||
| 4281 | 4281 | stag_info.total_len = iwmr->ibmr.length; | |
| 4282 | 4282 | stag_info.reg_addr_pa = *palloc->level1.addr; | |
| 4283 | 4283 | stag_info.first_pm_pbl_index = palloc->level1.idx; | |
| 4284 | - | stag_info.local_fence = ib_wr->send_flags & IB_SEND_FENCE; | |
| 4284 | + | stag_info.local_fence = true; | |
| 4285 | 4285 | if (iwmr->npages > IRDMA_MIN_PAGES_PER_FMR) | |
| 4286 | 4286 | stag_info.chunk_size = 1; | |
| 4287 | 4287 | err = irdma_sc_mr_fast_register(&iwqp->sc_qp, &stag_info, | |
modified drivers/infiniband/hw/mlx4/sysfs.c
| @@ -751,11 +751,13 @@ err_add: | |||
| 751 | 751 | kobject_put(p); | |
| 752 | 752 | } | |
| 753 | 753 | kobject_put(dev->dev_ports_parent[slave]); | |
| 754 | + | dev->dev_ports_parent[slave] = NULL; | |
| 754 | 755 | ||
| 755 | 756 | err_ports: | |
| 756 | 757 | kobject_put(dev->pkeys.device_parent[slave]); | |
| 757 | 758 | /* extra put for the device_parent create_and_add */ | |
| 758 | 759 | kobject_put(dev->pkeys.device_parent[slave]); | |
| 760 | + | dev->pkeys.device_parent[slave] = NULL; | |
| 759 | 761 | ||
| 760 | 762 | fail_dev: | |
| 761 | 763 | kobject_put(dev->iov_parent); | |
| @@ -785,6 +787,8 @@ static void unregister_pkey_tree(struct mlx4_ib_dev *device) | |||
| 785 | 787 | return; | |
| 786 | 788 | ||
| 787 | 789 | for (slave = device->dev->persist->num_vfs; slave >= 0; --slave) { | |
| 790 | + | if (!device->pkeys.device_parent[slave]) | |
| 791 | + | continue; | |
| 788 | 792 | list_for_each_entry_safe(p, t, | |
| 789 | 793 | &device->pkeys.pkey_port_list[slave], | |
| 790 | 794 | entry) { | |
modified drivers/infiniband/hw/mlx5/main.c
| @@ -1683,11 +1683,8 @@ static int mlx5_ib_query_port_speed_rep(struct mlx5_ib_dev *dev, u32 port_num, | |||
| 1683 | 1683 | struct mlx5_core_dev *mdev; | |
| 1684 | 1684 | u16 op_mod; | |
| 1685 | 1685 | ||
| 1686 | - | if (!dev->port[port_num - 1].rep) { | |
| 1687 | - | mlx5_ib_warn(dev, "Representor doesn't exist for port %u\n", | |
| 1688 | - | port_num); | |
| 1689 | - | return -EINVAL; | |
| 1690 | - | } | |
| 1686 | + | if (!dev->port[port_num - 1].rep) | |
| 1687 | + | return -ENODEV; | |
| 1691 | 1688 | ||
| 1692 | 1689 | rep = dev->port[port_num - 1].rep; | |
| 1693 | 1690 | mdev = mlx5_eswitch_get_core_dev(rep->esw); | |
modified drivers/infiniband/sw/rxe/rxe_mcast.c
| @@ -175,7 +175,9 @@ struct rxe_mcg *rxe_lookup_mcg(struct rxe_dev *rxe, union ib_gid *mgid) | |||
| 175 | 175 | * @mgid: multicast address as a gid | |
| 176 | 176 | * @mcg: new mcg object | |
| 177 | 177 | * | |
| 178 | - | * Context: caller should hold rxe->mcg lock | |
| 178 | + | * Initializes the mcg fields. The mcg is private and not yet visible in | |
| 179 | + | * mcg_tree, so this may run without rxe->mcg_lock; __rxe_publish_mcg() | |
| 180 | + | * makes it visible under the lock once it is ready. | |
| 179 | 181 | */ | |
| 180 | 182 | static void __rxe_init_mcg(struct rxe_dev *rxe, union ib_gid *mgid, | |
| 181 | 183 | struct rxe_mcg *mcg) | |
| @@ -184,13 +186,22 @@ static void __rxe_init_mcg(struct rxe_dev *rxe, union ib_gid *mgid, | |||
| 184 | 186 | memcpy(&mcg->mgid, mgid, sizeof(mcg->mgid)); | |
| 185 | 187 | INIT_LIST_HEAD(&mcg->qp_list); | |
| 186 | 188 | mcg->rxe = rxe; | |
| 189 | + | } | |
| 187 | 190 | ||
| 188 | - | /* caller holds a ref on mcg but that will be | |
| 189 | - | * dropped when mcg goes out of scope. We need to take a ref | |
| 190 | - | * on the pointer that will be saved in the red-black tree | |
| 191 | - | * by __rxe_insert_mcg and used to lookup mcg from mgid later. | |
| 192 | - | * Inserting mcg makes it visible to outside so this should | |
| 193 | - | * be done last after the object is ready. | |
| 191 | + | /** | |
| 192 | + | * __rxe_publish_mcg - make a fully initialized mcg visible in mcg_tree | |
| 193 | + | * @mcg: the mcg object | |
| 194 | + | * | |
| 195 | + | * Context: caller must hold rxe->mcg_lock and a reference on mcg | |
| 196 | + | */ | |
| 197 | + | static void __rxe_publish_mcg(struct rxe_mcg *mcg) | |
| 198 | + | { | |
| 199 | + | /* caller holds a ref on mcg but that will be dropped when mcg goes | |
| 200 | + | * out of scope. We need to take a ref on the pointer that will be | |
| 201 | + | * saved in the red-black tree by __rxe_insert_mcg and used to lookup | |
| 202 | + | * mcg from mgid later. Inserting mcg makes it visible to outside so | |
| 203 | + | * this is done last after the object is ready and the multicast | |
| 204 | + | * address has been programmed. | |
| 194 | 205 | */ | |
| 195 | 206 | kref_get(&mcg->ref_cnt); | |
| 196 | 207 | __rxe_insert_mcg(mcg); | |
| @@ -228,26 +239,37 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid) | |||
| 228 | 239 | err = -ENOMEM; | |
| 229 | 240 | goto err_dec; | |
| 230 | 241 | } | |
| 242 | + | __rxe_init_mcg(rxe, mgid, mcg); | |
| 243 | + | ||
| 244 | + | /* program the multicast address while mcg is still private, before | |
| 245 | + | * it is inserted into mcg_tree. dev_mc_add() may sleep so this must | |
| 246 | + | * run outside mcg_lock. On failure mcg was never published, so a | |
| 247 | + | * plain free is correct and the tree is untouched. | |
| 248 | + | */ | |
| 249 | + | err = rxe_mcast_add(rxe, mgid); | |
| 250 | + | if (err) { | |
| 251 | + | kfree(mcg); | |
| 252 | + | goto err_dec; | |
| 253 | + | } | |
| 231 | 254 | ||
| 232 | 255 | spin_lock_bh(&rxe->mcg_lock); | |
| 233 | - | /* re-check to see if someone else just added it */ | |
| 256 | + | /* re-check to see if someone else just added it while we were adding | |
| 257 | + | * the multicast address; if so use theirs and drop ours | |
| 258 | + | */ | |
| 234 | 259 | tmp = __rxe_lookup_mcg(rxe, mgid); | |
| 235 | 260 | if (tmp) { | |
| 236 | 261 | spin_unlock_bh(&rxe->mcg_lock); | |
| 262 | + | rxe_mcast_del(rxe, mgid); | |
| 237 | 263 | atomic_dec(&rxe->mcg_num); | |
| 238 | 264 | kfree(mcg); | |
| 239 | 265 | return tmp; | |
| 240 | 266 | } | |
| 241 | 267 | ||
| 242 | - | __rxe_init_mcg(rxe, mgid, mcg); | |
| 268 | + | __rxe_publish_mcg(mcg); | |
| 243 | 269 | spin_unlock_bh(&rxe->mcg_lock); | |
| 244 | 270 | ||
| 245 | - | /* add mcast address outside of lock */ | |
| 246 | - | err = rxe_mcast_add(rxe, mgid); | |
| 247 | - | if (!err) | |
| 248 | - | return mcg; | |
| 271 | + | return mcg; | |
| 249 | 272 | ||
| 250 | - | kfree(mcg); | |
| 251 | 273 | err_dec: | |
| 252 | 274 | atomic_dec(&rxe->mcg_num); | |
| 253 | 275 | return ERR_PTR(err); | |
modified drivers/infiniband/sw/rxe/rxe_mr.c
| @@ -33,7 +33,8 @@ int mr_check_range(struct rxe_mr *mr, u64 iova, size_t length) | |||
| 33 | 33 | case IB_MR_TYPE_USER: | |
| 34 | 34 | case IB_MR_TYPE_MEM_REG: | |
| 35 | 35 | if (iova < mr->ibmr.iova || | |
| 36 | - | iova + length > mr->ibmr.iova + mr->ibmr.length) { | |
| 36 | + | length > mr->ibmr.length || | |
| 37 | + | iova - mr->ibmr.iova > mr->ibmr.length - length) { | |
| 37 | 38 | rxe_dbg_mr(mr, "iova/length out of range\n"); | |
| 38 | 39 | return -EINVAL; | |
| 39 | 40 | } | |
modified drivers/infiniband/sw/rxe/rxe_odp.c
| @@ -120,19 +120,23 @@ int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, | |||
| 120 | 120 | } | |
| 121 | 121 | ||
| 122 | 122 | static inline bool rxe_check_pagefault(struct ib_umem_odp *umem_odp, u64 iova, | |
| 123 | - | int length) | |
| 123 | + | int length, bool write) | |
| 124 | 124 | { | |
| 125 | 125 | bool need_fault = false; | |
| 126 | + | u64 access = HMM_PFN_VALID; | |
| 126 | 127 | u64 addr; | |
| 127 | 128 | int idx; | |
| 128 | 129 | ||
| 130 | + | if (write) | |
| 131 | + | access |= HMM_PFN_WRITE; | |
| 132 | + | ||
| 129 | 133 | addr = iova & (~(BIT(umem_odp->page_shift) - 1)); | |
| 130 | 134 | ||
| 131 | 135 | /* Skim through all pages that are to be accessed. */ | |
| 132 | 136 | while (addr < iova + length) { | |
| 133 | 137 | idx = (addr - ib_umem_start(umem_odp)) >> umem_odp->page_shift; | |
| 134 | 138 | ||
| 135 | - | if (!(umem_odp->map.pfn_list[idx] & HMM_PFN_VALID)) { | |
| 139 | + | if ((umem_odp->map.pfn_list[idx] & access) != access) { | |
| 136 | 140 | need_fault = true; | |
| 137 | 141 | break; | |
| 138 | 142 | } | |
| @@ -155,6 +159,7 @@ static unsigned long rxe_odp_iova_to_page_offset(struct ib_umem_odp *umem_odp, u | |||
| 155 | 159 | static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u32 flags) | |
| 156 | 160 | { | |
| 157 | 161 | struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem); | |
| 162 | + | bool write = !(flags & RXE_PAGEFAULT_RDONLY); | |
| 158 | 163 | bool need_fault; | |
| 159 | 164 | int err; | |
| 160 | 165 | ||
| @@ -163,7 +168,7 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u | |||
| 163 | 168 | ||
| 164 | 169 | mutex_lock(&umem_odp->umem_mutex); | |
| 165 | 170 | ||
| 166 | - | need_fault = rxe_check_pagefault(umem_odp, iova, length); | |
| 171 | + | need_fault = rxe_check_pagefault(umem_odp, iova, length, write); | |
| 167 | 172 | if (need_fault) { | |
| 168 | 173 | mutex_unlock(&umem_odp->umem_mutex); | |
| 169 | 174 | ||
| @@ -173,7 +178,7 @@ static int rxe_odp_map_range_and_lock(struct rxe_mr *mr, u64 iova, int length, u | |||
| 173 | 178 | if (err < 0) | |
| 174 | 179 | return err; | |
| 175 | 180 | ||
| 176 | - | need_fault = rxe_check_pagefault(umem_odp, iova, length); | |
| 181 | + | need_fault = rxe_check_pagefault(umem_odp, iova, length, write); | |
| 177 | 182 | if (need_fault) { | |
| 178 | 183 | mutex_unlock(&umem_odp->umem_mutex); | |
| 179 | 184 | return -EFAULT; | |
| @@ -335,8 +340,9 @@ int rxe_odp_flush_pmem_iova(struct rxe_mr *mr, u64 iova, | |||
| 335 | 340 | int err; | |
| 336 | 341 | u8 *va; | |
| 337 | 342 | ||
| 343 | + | /* A flush never modifies memory; read-only access suffices. */ | |
| 338 | 344 | err = rxe_odp_map_range_and_lock(mr, iova, length, | |
| 339 | - | RXE_PAGEFAULT_DEFAULT); | |
| 345 | + | RXE_PAGEFAULT_RDONLY); | |
| 340 | 346 | if (err) | |
| 341 | 347 | return err; | |
| 342 | 348 | ||
modified drivers/infiniband/sw/rxe/rxe_verbs.c
| @@ -1331,19 +1331,20 @@ static struct ib_mr *rxe_rereg_user_mr(struct ib_mr *ibmr, int flags, | |||
| 1331 | 1331 | if (err) | |
| 1332 | 1332 | return ERR_PTR(err); | |
| 1333 | 1333 | ||
| 1334 | + | if ((flags & IB_MR_REREG_ACCESS) && | |
| 1335 | + | (access & ~RXE_ACCESS_SUPPORTED_MR)) { | |
| 1336 | + | rxe_err_mr(mr, "access = %#x not supported\n", access); | |
| 1337 | + | return ERR_PTR(-EOPNOTSUPP); | |
| 1338 | + | } | |
| 1339 | + | ||
| 1334 | 1340 | if (flags & IB_MR_REREG_PD) { | |
| 1335 | 1341 | rxe_put(old_pd); | |
| 1336 | 1342 | rxe_get(pd); | |
| 1337 | 1343 | mr->ibmr.pd = ibpd; | |
| 1338 | 1344 | } | |
| 1339 | 1345 | ||
| 1340 | - | if (flags & IB_MR_REREG_ACCESS) { | |
| 1341 | - | if (access & ~RXE_ACCESS_SUPPORTED_MR) { | |
| 1342 | - | rxe_err_mr(mr, "access = %#x not supported\n", access); | |
| 1343 | - | return ERR_PTR(-EOPNOTSUPP); | |
| 1344 | - | } | |
| 1346 | + | if (flags & IB_MR_REREG_ACCESS) | |
| 1345 | 1347 | mr->access = access; | |
| 1346 | - | } | |
| 1347 | 1348 | ||
| 1348 | 1349 | return NULL; | |
| 1349 | 1350 | } | |
modified drivers/infiniband/sw/siw/siw_cm.c
| @@ -1719,9 +1719,12 @@ int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params) | |||
| 1719 | 1719 | SIW_QP_ATTR_STATE | SIW_QP_ATTR_LLP_HANDLE | | |
| 1720 | 1720 | SIW_QP_ATTR_ORD | SIW_QP_ATTR_IRD | | |
| 1721 | 1721 | SIW_QP_ATTR_MPA); | |
| 1722 | + | if (rv) { | |
| 1723 | + | qp->cep = NULL; | |
| 1724 | + | siw_cep_put(cep); | |
| 1725 | + | goto error_unlock; | |
| 1726 | + | } | |
| 1722 | 1727 | up_write(&qp->state_lock); | |
| 1723 | - | if (rv) | |
| 1724 | - | goto error; | |
| 1725 | 1728 | ||
| 1726 | 1729 | siw_dbg_cep(cep, "[QP %u]: send mpa reply, %d byte pdata\n", | |
| 1727 | 1730 | qp_id(qp), params->private_data_len); | |
modified drivers/infiniband/sw/siw/siw_qp_rx.c
| @@ -1079,7 +1079,7 @@ static int siw_get_hdr(struct siw_rx_stream *srx) | |||
| 1079 | 1079 | if (iwarp_pktinfo[opcode].hdr_len > sizeof(struct iwarp_ctrl_tagged)) { | |
| 1080 | 1080 | int hdrlen = iwarp_pktinfo[opcode].hdr_len; | |
| 1081 | 1081 | ||
| 1082 | - | bytes = min_t(int, hdrlen - MIN_DDP_HDR, srx->skb_new); | |
| 1082 | + | bytes = min_t(int, hdrlen - srx->fpdu_part_rcvd, srx->skb_new); | |
| 1083 | 1083 | ||
| 1084 | 1084 | skb_copy_bits(skb, srx->skb_offset, | |
| 1085 | 1085 | (char *)c_hdr + srx->fpdu_part_rcvd, bytes); | |
modified drivers/infiniband/ulp/ipoib/ipoib.h
| @@ -87,6 +87,7 @@ enum { | |||
| 87 | 87 | IPOIB_FLAG_INITIALIZED = 1, | |
| 88 | 88 | IPOIB_FLAG_ADMIN_UP = 2, | |
| 89 | 89 | IPOIB_PKEY_ASSIGNED = 3, | |
| 90 | + | IPOIB_FLAG_MCAST_FLUSH = 4, | |
| 90 | 91 | IPOIB_FLAG_SUBINTERFACE = 5, | |
| 91 | 92 | IPOIB_STOP_REAPER = 7, | |
| 92 | 93 | IPOIB_FLAG_ADMIN_CM = 9, | |
| @@ -414,6 +415,12 @@ struct ipoib_dev_priv { | |||
| 414 | 415 | const struct net_device_ops *rn_ops; | |
| 415 | 416 | }; | |
| 416 | 417 | ||
| 418 | + | static inline bool ipoib_mcast_allowed(struct ipoib_dev_priv *priv) | |
| 419 | + | { | |
| 420 | + | return test_bit(IPOIB_FLAG_OPER_UP, &priv->flags) && | |
| 421 | + | !test_bit(IPOIB_FLAG_MCAST_FLUSH, &priv->flags); | |
| 422 | + | } | |
| 423 | + | ||
| 417 | 424 | struct ipoib_ah { | |
| 418 | 425 | struct net_device *dev; | |
| 419 | 426 | struct ib_ah *ah; | |
modified drivers/infiniband/ulp/ipoib/ipoib_ib.c
| @@ -1227,17 +1227,19 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, | |||
| 1227 | 1227 | } | |
| 1228 | 1228 | ||
| 1229 | 1229 | if (level == IPOIB_FLUSH_LIGHT) { | |
| 1230 | - | int oper_up; | |
| 1231 | 1230 | ipoib_mark_paths_invalid(dev); | |
| 1232 | - | /* Set IPoIB operation as down to prevent races between: | |
| 1231 | + | /* Set MCAST_FLUSH to prevent races between: | |
| 1233 | 1232 | * the flush flow which leaves MCG and on the fly joins | |
| 1234 | 1233 | * which can happen during that time. mcast restart task | |
| 1235 | 1234 | * should deal with join requests we missed. | |
| 1235 | + | * | |
| 1236 | + | * Do not clear OPER_UP for this; restoring it races with | |
| 1237 | + | * ipoib_ib_dev_down() and can leave OPER_UP set after the | |
| 1238 | + | * device is down. | |
| 1236 | 1239 | */ | |
| 1237 | - | oper_up = test_and_clear_bit(IPOIB_FLAG_OPER_UP, &priv->flags); | |
| 1240 | + | set_bit(IPOIB_FLAG_MCAST_FLUSH, &priv->flags); | |
| 1238 | 1241 | ipoib_mcast_dev_flush(dev); | |
| 1239 | - | if (oper_up) | |
| 1240 | - | set_bit(IPOIB_FLAG_OPER_UP, &priv->flags); | |
| 1242 | + | clear_bit(IPOIB_FLAG_MCAST_FLUSH, &priv->flags); | |
| 1241 | 1243 | ipoib_reap_dead_ahs(priv); | |
| 1242 | 1244 | } | |
| 1243 | 1245 | ||
modified drivers/infiniband/ulp/ipoib/ipoib_multicast.c
| @@ -74,7 +74,7 @@ static void __ipoib_mcast_schedule_join_thread(struct ipoib_dev_priv *priv, | |||
| 74 | 74 | struct ipoib_mcast *mcast, | |
| 75 | 75 | bool delay) | |
| 76 | 76 | { | |
| 77 | - | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) | |
| 77 | + | if (!ipoib_mcast_allowed(priv)) | |
| 78 | 78 | return; | |
| 79 | 79 | ||
| 80 | 80 | /* | |
| @@ -469,7 +469,7 @@ static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast) | |||
| 469 | 469 | int ret = 0; | |
| 470 | 470 | ||
| 471 | 471 | if (!priv->broadcast || | |
| 472 | - | !test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) | |
| 472 | + | !ipoib_mcast_allowed(priv)) | |
| 473 | 473 | return -EINVAL; | |
| 474 | 474 | ||
| 475 | 475 | init_completion(&mcast->done); | |
| @@ -555,7 +555,7 @@ void ipoib_mcast_join_task(struct work_struct *work) | |||
| 555 | 555 | unsigned long delay_until = 0; | |
| 556 | 556 | struct ipoib_mcast *mcast = NULL; | |
| 557 | 557 | ||
| 558 | - | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) | |
| 558 | + | if (!ipoib_mcast_allowed(priv)) | |
| 559 | 559 | return; | |
| 560 | 560 | ||
| 561 | 561 | if (ib_query_port(priv->ca, priv->port, &port_attr)) { | |
| @@ -577,7 +577,7 @@ void ipoib_mcast_join_task(struct work_struct *work) | |||
| 577 | 577 | netif_addr_unlock_bh(dev); | |
| 578 | 578 | ||
| 579 | 579 | spin_lock_irq(&priv->lock); | |
| 580 | - | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) | |
| 580 | + | if (!ipoib_mcast_allowed(priv)) | |
| 581 | 581 | goto out; | |
| 582 | 582 | ||
| 583 | 583 | if (!priv->broadcast) { | |
| @@ -749,7 +749,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb) | |||
| 749 | 749 | ||
| 750 | 750 | spin_lock_irqsave(&priv->lock, flags); | |
| 751 | 751 | ||
| 752 | - | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags) || | |
| 752 | + | if (!ipoib_mcast_allowed(priv) || | |
| 753 | 753 | !priv->broadcast || | |
| 754 | 754 | !test_bit(IPOIB_MCAST_FLAG_ATTACHED, &priv->broadcast->flags)) { | |
| 755 | 755 | ++dev->stats.tx_dropped; | |
| @@ -871,7 +871,7 @@ void ipoib_mcast_restart_task(struct work_struct *work) | |||
| 871 | 871 | LIST_HEAD(remove_list); | |
| 872 | 872 | struct ib_sa_mcmember_rec rec; | |
| 873 | 873 | ||
| 874 | - | if (!test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) | |
| 874 | + | if (!ipoib_mcast_allowed(priv)) | |
| 875 | 875 | /* | |
| 876 | 876 | * shortcut...on shutdown flush is called next, just | |
| 877 | 877 | * let it do all the work | |
| @@ -965,9 +965,9 @@ void ipoib_mcast_restart_task(struct work_struct *work) | |||
| 965 | 965 | ipoib_mcast_remove_list(&remove_list); | |
| 966 | 966 | ||
| 967 | 967 | /* | |
| 968 | - | * Double check that we are still up | |
| 968 | + | * Double check that we are still up and not flushing | |
| 969 | 969 | */ | |
| 970 | - | if (test_bit(IPOIB_FLAG_OPER_UP, &priv->flags)) { | |
| 970 | + | if (ipoib_mcast_allowed(priv)) { | |
| 971 | 971 | spin_lock_irq(&priv->lock); | |
| 972 | 972 | __ipoib_mcast_schedule_join_thread(priv, NULL, 0); | |
| 973 | 973 | spin_unlock_irq(&priv->lock); | |
modified drivers/infiniband/ulp/iser/iser_initiator.c
| @@ -598,11 +598,8 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, | |||
| 598 | 598 | iser_dbg("conn %p: remote invalidation for rkey %#x\n", | |
| 599 | 599 | iser_conn, rkey); | |
| 600 | 600 | ||
| 601 | - | if (unlikely(!iser_conn->snd_w_inv)) { | |
| 602 | - | iser_err("conn %p: unexpected remote invalidation, terminating connection\n", | |
| 603 | - | iser_conn); | |
| 604 | - | return -EPROTO; | |
| 605 | - | } | |
| 601 | + | if (unlikely(!iser_conn->snd_w_inv)) | |
| 602 | + | goto bad_inv; | |
| 606 | 603 | ||
| 607 | 604 | task = iscsi_itt_to_ctask(iser_conn->iscsi_conn, hdr->itt); | |
| 608 | 605 | if (likely(task)) { | |
| @@ -611,12 +608,16 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, | |||
| 611 | 608 | ||
| 612 | 609 | if (iser_task->dir[ISER_DIR_IN]) { | |
| 613 | 610 | desc = iser_task->rdma_reg[ISER_DIR_IN].desc; | |
| 611 | + | if (unlikely(!desc)) | |
| 612 | + | goto bad_inv; | |
| 614 | 613 | if (unlikely(iser_inv_desc(desc, rkey))) | |
| 615 | 614 | return -EINVAL; | |
| 616 | 615 | } | |
| 617 | 616 | ||
| 618 | 617 | if (iser_task->dir[ISER_DIR_OUT]) { | |
| 619 | 618 | desc = iser_task->rdma_reg[ISER_DIR_OUT].desc; | |
| 619 | + | if (unlikely(!desc)) | |
| 620 | + | goto bad_inv; | |
| 620 | 621 | if (unlikely(iser_inv_desc(desc, rkey))) | |
| 621 | 622 | return -EINVAL; | |
| 622 | 623 | } | |
| @@ -627,6 +628,11 @@ static int iser_check_remote_inv(struct iser_conn *iser_conn, struct ib_wc *wc, | |||
| 627 | 628 | } | |
| 628 | 629 | ||
| 629 | 630 | return 0; | |
| 631 | + | ||
| 632 | + | bad_inv: | |
| 633 | + | iser_err("conn %p: unexpected remote invalidation, terminating connection\n", | |
| 634 | + | iser_conn); | |
| 635 | + | return -EPROTO; | |
| 630 | 636 | } | |
| 631 | 637 | ||
| 632 | 638 | ||
modified drivers/infiniband/ulp/isert/ib_isert.c
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | #include <target/target_core_fabric.h> | |
| 22 | 22 | #include <target/iscsi/iscsi_transport.h> | |
| 23 | 23 | #include <linux/semaphore.h> | |
| 24 | + | #include <linux/wait_bit.h> | |
| 24 | 25 | ||
| 25 | 26 | #include "ib_isert.h" | |
| 26 | 27 | ||
| @@ -310,6 +311,7 @@ isert_init_conn(struct isert_conn *isert_conn) | |||
| 310 | 311 | init_completion(&isert_conn->login_req_comp); | |
| 311 | 312 | init_waitqueue_head(&isert_conn->rem_wait); | |
| 312 | 313 | kref_init(&isert_conn->kref); | |
| 314 | + | atomic_set(&isert_conn->ctrl_comp_cnt, 0); | |
| 313 | 315 | mutex_init(&isert_conn->mutex); | |
| 314 | 316 | INIT_WORK(&isert_conn->release_work, isert_release_work); | |
| 315 | 317 | } | |
| @@ -1694,6 +1696,8 @@ isert_do_control_comp(struct work_struct *work) | |||
| 1694 | 1696 | struct isert_conn *isert_conn = isert_cmd->conn; | |
| 1695 | 1697 | struct ib_device *ib_dev = isert_conn->cm_id->device; | |
| 1696 | 1698 | struct iscsit_cmd *cmd = isert_cmd->iscsit_cmd; | |
| 1699 | + | /* The switch below may free isert_cmd. */ | |
| 1700 | + | bool counted = isert_cmd->ctrl_counted; | |
| 1697 | 1701 | ||
| 1698 | 1702 | isert_dbg("Cmd %p i_state %d\n", isert_cmd, cmd->i_state); | |
| 1699 | 1703 | ||
| @@ -1715,6 +1719,14 @@ isert_do_control_comp(struct work_struct *work) | |||
| 1715 | 1719 | dump_stack(); | |
| 1716 | 1720 | break; | |
| 1717 | 1721 | } | |
| 1722 | + | ||
| 1723 | + | /* | |
| 1724 | + | * The count is what keeps isert_conn alive, so drop it last. The wait | |
| 1725 | + | * queue lives in the global hash table, not in isert_conn, so this is | |
| 1726 | + | * safe even if the waiter has already freed the connection. | |
| 1727 | + | */ | |
| 1728 | + | if (counted && atomic_dec_and_test(&isert_conn->ctrl_comp_cnt)) | |
| 1729 | + | wake_up_var(&isert_conn->ctrl_comp_cnt); | |
| 1718 | 1730 | } | |
| 1719 | 1731 | ||
| 1720 | 1732 | static void | |
| @@ -1758,6 +1770,12 @@ isert_send_done(struct ib_cq *cq, struct ib_wc *wc) | |||
| 1758 | 1770 | case ISTATE_SEND_TEXTRSP: | |
| 1759 | 1771 | isert_unmap_tx_desc(tx_desc, ib_dev); | |
| 1760 | 1772 | ||
| 1773 | + | /* Paired with the wait in isert_wait_conn(). */ | |
| 1774 | + | isert_cmd->ctrl_counted = | |
| 1775 | + | isert_cmd->iscsit_cmd->i_state != ISTATE_SEND_LOGOUTRSP; | |
| 1776 | + | if (isert_cmd->ctrl_counted) | |
| 1777 | + | atomic_inc(&isert_conn->ctrl_comp_cnt); | |
| 1778 | + | ||
| 1761 | 1779 | INIT_WORK(&isert_cmd->comp_work, isert_do_control_comp); | |
| 1762 | 1780 | queue_work(isert_comp_wq, &isert_cmd->comp_work); | |
| 1763 | 1781 | return; | |
| @@ -2602,6 +2620,10 @@ static void isert_wait_conn(struct iscsit_conn *conn) | |||
| 2602 | 2620 | isert_wait4cmds(conn); | |
| 2603 | 2621 | isert_wait4logout(isert_conn); | |
| 2604 | 2622 | ||
| 2623 | + | /* Paired with the count taken in isert_send_done(). */ | |
| 2624 | + | wait_var_event(&isert_conn->ctrl_comp_cnt, | |
| 2625 | + | !atomic_read(&isert_conn->ctrl_comp_cnt)); | |
| 2626 | + | ||
| 2605 | 2627 | queue_work(isert_release_wq, &isert_conn->release_work); | |
| 2606 | 2628 | } | |
| 2607 | 2629 | ||
modified drivers/infiniband/ulp/isert/ib_isert.h
| @@ -153,6 +153,7 @@ struct isert_cmd { | |||
| 153 | 153 | struct work_struct comp_work; | |
| 154 | 154 | struct scatterlist sg; | |
| 155 | 155 | bool ctx_init_done; | |
| 156 | + | bool ctrl_counted; | |
| 156 | 157 | }; | |
| 157 | 158 | ||
| 158 | 159 | static inline struct isert_cmd *tx_desc_to_cmd(struct iser_tx_desc *desc) | |
| @@ -187,6 +188,7 @@ struct isert_conn { | |||
| 187 | 188 | struct mutex mutex; | |
| 188 | 189 | struct kref kref; | |
| 189 | 190 | struct work_struct release_work; | |
| 191 | + | atomic_t ctrl_comp_cnt; | |
| 190 | 192 | bool logout_posted; | |
| 191 | 193 | bool snd_w_inv; | |
| 192 | 194 | wait_queue_head_t rem_wait; | |
modified drivers/infiniband/ulp/rtrs/rtrs-clt-trace.h
| @@ -55,7 +55,7 @@ DECLARE_EVENT_CLASS(rtrs_clt_conn_class, | |||
| 55 | 55 | __entry->max_reconnect_attempts = clt->max_reconnect_attempts; | |
| 56 | 56 | __entry->fail_cnt = clt_path->stats->reconnects.fail_cnt; | |
| 57 | 57 | __entry->success_cnt = clt_path->stats->reconnects.successful_cnt; | |
| 58 | - | memcpy(__entry->sessname, kobject_name(&clt_path->kobj), NAME_MAX); | |
| 58 | + | strscpy(__entry->sessname, kobject_name(&clt_path->kobj) ?: "", NAME_MAX); | |
| 59 | 59 | ), | |
| 60 | 60 | ||
| 61 | 61 | TP_printk("RTRS-CLT: sess='%s' state=%s attempts='%d' max-attempts='%d' fail='%d' success='%d'", | |
modified drivers/infiniband/ulp/rtrs/rtrs-clt.c
| @@ -1732,6 +1732,8 @@ static void destroy_con_cq_qp(struct rtrs_clt_con *con) | |||
| 1732 | 1732 | /* | |
| 1733 | 1733 | * Be careful here: destroy_con_cq_qp() can be called even | |
| 1734 | 1734 | * create_con_cq_qp() failed, see comments there. | |
| 1735 | + | * Caller must set con->destroyed under this lock first so a | |
| 1736 | + | * racing ADDR_RESOLVED cannot ib_cq_pool_get() after we PUT/SKIP. | |
| 1735 | 1737 | */ | |
| 1736 | 1738 | lockdep_assert_held(&con->con_mutex); | |
| 1737 | 1739 | rtrs_cq_qp_destroy(&con->c); | |
| @@ -1766,6 +1768,10 @@ static int rtrs_rdma_addr_resolved(struct rtrs_clt_con *con) | |||
| 1766 | 1768 | int err; | |
| 1767 | 1769 | ||
| 1768 | 1770 | mutex_lock(&con->con_mutex); | |
| 1771 | + | if (con->destroyed) { | |
| 1772 | + | mutex_unlock(&con->con_mutex); | |
| 1773 | + | return -ECONNABORTED; | |
| 1774 | + | } | |
| 1769 | 1775 | err = create_con_cq_qp(con); | |
| 1770 | 1776 | mutex_unlock(&con->con_mutex); | |
| 1771 | 1777 | if (err) { | |
| @@ -2221,6 +2227,7 @@ static void rtrs_clt_stop_and_destroy_conns(struct rtrs_clt_path *clt_path) | |||
| 2221 | 2227 | break; | |
| 2222 | 2228 | con = to_clt_con(clt_path->s.con[cid]); | |
| 2223 | 2229 | mutex_lock(&con->con_mutex); | |
| 2230 | + | con->destroyed = true; | |
| 2224 | 2231 | destroy_con_cq_qp(con); | |
| 2225 | 2232 | mutex_unlock(&con->con_mutex); | |
| 2226 | 2233 | destroy_cm(con); | |
| @@ -2387,6 +2394,7 @@ destroy: | |||
| 2387 | 2394 | if (con->c.cm_id) { | |
| 2388 | 2395 | stop_cm(con); | |
| 2389 | 2396 | mutex_lock(&con->con_mutex); | |
| 2397 | + | con->destroyed = true; | |
| 2390 | 2398 | destroy_con_cq_qp(con); | |
| 2391 | 2399 | mutex_unlock(&con->con_mutex); | |
| 2392 | 2400 | destroy_cm(con); | |
modified drivers/infiniband/ulp/rtrs/rtrs-clt.h
| @@ -75,6 +75,8 @@ struct rtrs_clt_con { | |||
| 75 | 75 | unsigned int cpu; | |
| 76 | 76 | struct mutex con_mutex; | |
| 77 | 77 | int cm_err; | |
| 78 | + | /* Set under con_mutex before CQ/QP teardown. */ | |
| 79 | + | bool destroyed; | |
| 78 | 80 | }; | |
| 79 | 81 | ||
| 80 | 82 | /** | |
modified drivers/infiniband/ulp/rtrs/rtrs-srv-trace.h
| @@ -61,7 +61,7 @@ TRACE_EVENT(send_io_resp_imm, | |||
| 61 | 61 | __entry->msg_id = id->msg_id; | |
| 62 | 62 | __entry->wr_cnt = atomic_read(&con->c.wr_cnt); | |
| 63 | 63 | __entry->signal_interval = s->signal_interval; | |
| 64 | - | memcpy(__entry->sessname, kobject_name(&srv_path->kobj), NAME_MAX); | |
| 64 | + | strscpy(__entry->sessname, kobject_name(&srv_path->kobj) ?: "", NAME_MAX); | |
| 65 | 65 | ), | |
| 66 | 66 | ||
| 67 | 67 | TP_printk("sess='%s' state='%s' dir=%s err='%d' inval='%d' glob-inval='%d' msgid='%u' wrcnt='%d' sig-interval='%u'", | |
modified drivers/infiniband/ulp/srp/ib_srp.c
| @@ -1038,15 +1038,20 @@ static void srp_del_scsi_host_attr(struct Scsi_Host *shost) | |||
| 1038 | 1038 | ||
| 1039 | 1039 | static void srp_remove_target(struct srp_target_port *target) | |
| 1040 | 1040 | { | |
| 1041 | + | struct scsi_device *sdev; | |
| 1041 | 1042 | struct srp_rdma_ch *ch; | |
| 1042 | 1043 | int i; | |
| 1043 | 1044 | ||
| 1044 | 1045 | WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED); | |
| 1045 | 1046 | ||
| 1046 | 1047 | srp_del_scsi_host_attr(target->scsi_host); | |
| 1047 | - | srp_rport_get(target->rport); | |
| 1048 | - | srp_remove_host(target->scsi_host); | |
| 1049 | - | scsi_remove_host(target->scsi_host); | |
| 1048 | + | /* | |
| 1049 | + | * Remove all logical units. This must happen before the | |
| 1050 | + | * srp_disconnect_target() call because scsi_remove_device() may trigger | |
| 1051 | + | * submission of SCSI commands. See also sd_shutdown(). | |
| 1052 | + | */ | |
| 1053 | + | shost_for_each_device(sdev, target->scsi_host) | |
| 1054 | + | scsi_remove_device(sdev); | |
| 1050 | 1055 | srp_stop_rport_timers(target->rport); | |
| 1051 | 1056 | srp_disconnect_target(target); | |
| 1052 | 1057 | kobj_ns_drop(KOBJ_NS_TYPE_NET, to_ns_common(target->net)); | |
| @@ -1055,7 +1060,8 @@ static void srp_remove_target(struct srp_target_port *target) | |||
| 1055 | 1060 | srp_free_ch_ib(target, ch); | |
| 1056 | 1061 | } | |
| 1057 | 1062 | cancel_work_sync(&target->tl_err_work); | |
| 1058 | - | srp_rport_put(target->rport); | |
| 1063 | + | srp_remove_host(target->scsi_host); | |
| 1064 | + | scsi_remove_host(target->scsi_host); | |
| 1059 | 1065 | kfree(target->ch); | |
| 1060 | 1066 | target->ch = NULL; | |
| 1061 | 1067 | ||
modified drivers/input/evdev.c
| @@ -1229,6 +1229,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
| 1229 | 1229 | ||
| 1230 | 1230 | t = _IOC_NR(cmd) & ABS_MAX; | |
| 1231 | 1231 | ||
| 1232 | + | memset(&abs, 0, sizeof(abs)); | |
| 1233 | + | ||
| 1232 | 1234 | if (copy_from_user(&abs, p, min_t(size_t, | |
| 1233 | 1235 | size, sizeof(struct input_absinfo)))) | |
| 1234 | 1236 | return -EFAULT; | |
modified drivers/input/input-compat.c
| @@ -76,6 +76,8 @@ int input_ff_effect_from_user(const char __user *buffer, size_t size, | |||
| 76 | 76 | */ | |
| 77 | 77 | compat_effect = (struct ff_effect_compat *)effect; | |
| 78 | 78 | ||
| 79 | + | memset(effect, 0, sizeof(*effect)); | |
| 80 | + | ||
| 79 | 81 | if (copy_from_user(compat_effect, buffer, | |
| 80 | 82 | sizeof(struct ff_effect_compat))) | |
| 81 | 83 | return -EFAULT; | |
modified drivers/input/joystick/xpad.c
| @@ -215,7 +215,7 @@ static const struct xpad_device { | |||
| 215 | 215 | { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE }, | |
| 216 | 216 | { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, | |
| 217 | 217 | { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE }, | |
| 218 | - | { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE }, | |
| 218 | + | { 0x0e6f, 0x0147, "PDP Marvel Xbox 360 Controller", 0, XTYPE_XBOX360 }, | |
| 219 | 219 | { 0x0e6f, 0x015c, "PDP Xbox One Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOXONE }, | |
| 220 | 220 | { 0x0e6f, 0x015d, "PDP Mirror's Edge Official Wired Controller for Xbox One", 0, XTYPE_XBOXONE }, | |
| 221 | 221 | { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, | |
| @@ -227,6 +227,7 @@ static const struct xpad_device { | |||
| 227 | 227 | { 0x0e6f, 0x0213, "Afterglow Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, | |
| 228 | 228 | { 0x0e6f, 0x021f, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, | |
| 229 | 229 | { 0x0e6f, 0x0246, "Rock Candy Gamepad for Xbox One 2015", 0, XTYPE_XBOXONE }, | |
| 230 | + | { 0x0e6f, 0x024c, "PDP Victrix Pro BFG Wired Controller for Xbox", 0, XTYPE_XBOXONE }, | |
| 230 | 231 | { 0x0e6f, 0x02a0, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, | |
| 231 | 232 | { 0x0e6f, 0x02a1, "PDP Xbox One Controller", 0, XTYPE_XBOXONE }, | |
| 232 | 233 | { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE }, | |
| @@ -292,9 +293,17 @@ static const struct xpad_device { | |||
| 292 | 293 | { 0x1689, 0xfd00, "Razer Onza Tournament Edition", 0, XTYPE_XBOX360 }, | |
| 293 | 294 | { 0x1689, 0xfd01, "Razer Onza Classic Edition", 0, XTYPE_XBOX360 }, | |
| 294 | 295 | { 0x1689, 0xfe00, "Razer Sabertooth", 0, XTYPE_XBOX360 }, | |
| 296 | + | { 0x16d0, 0x1103, "Azeron Cyro", 0, XTYPE_XBOX360 }, | |
| 297 | + | { 0x16d0, 0x113c, "Azeron Cyborg", 0, XTYPE_XBOX360 }, | |
| 298 | + | { 0x16d0, 0x1192, "Azeron Classic/Compact", 0, XTYPE_XBOX360 }, | |
| 299 | + | { 0x16d0, 0x1212, "Azeron Cyro Lefty", 0, XTYPE_XBOX360 }, | |
| 300 | + | { 0x16d0, 0x12f7, "Azeron Cyborg II", 0, XTYPE_XBOX360 }, | |
| 301 | + | { 0x16d0, 0x13ea, "Azeron Keyzen", 0, XTYPE_XBOX360 }, | |
| 295 | 302 | { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 }, | |
| 296 | 303 | { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 }, | |
| 297 | 304 | { 0x1a86, 0xe310, "Legion Go S", 0, XTYPE_XBOX360 }, | |
| 305 | + | { 0x1b1c, 0x2b1f, "Corsair Novablade Pro (Wired)", 0, XTYPE_XBOX360 }, | |
| 306 | + | { 0x1b1c, 0x2b2b, "Corsair Novablade Pro (2.4 GHz Receiver)", 0, XTYPE_XBOX360 }, | |
| 298 | 307 | { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 }, | |
| 299 | 308 | { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, | |
| 300 | 309 | { 0x1bad, 0x0130, "Ion Drum Rocker", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, | |
| @@ -372,6 +381,7 @@ static const struct xpad_device { | |||
| 372 | 381 | { 0x2993, 0x2001, "TECNO Pocket Go", 0, XTYPE_XBOX360 }, | |
| 373 | 382 | { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE }, | |
| 374 | 383 | { 0x2dc8, 0x200f, "8BitDo Ultimate 3-mode Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, | |
| 384 | + | { 0x2dc8, 0x201e, "8BitDo Pro 2 Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, | |
| 375 | 385 | { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 }, | |
| 376 | 386 | { 0x2dc8, 0x3109, "8BitDo Ultimate Wireless Bluetooth", 0, XTYPE_XBOX360 }, | |
| 377 | 387 | { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 }, | |
| @@ -534,9 +544,11 @@ static const struct usb_device_id xpad_table[] = { | |||
| 534 | 544 | XPAD_XBOX360_VENDOR(0x15e4), /* Numark Xbox 360 controllers */ | |
| 535 | 545 | XPAD_XBOX360_VENDOR(0x162e), /* Joytech Xbox 360 controllers */ | |
| 536 | 546 | XPAD_XBOX360_VENDOR(0x1689), /* Razer Onza */ | |
| 547 | + | XPAD_XBOX360_VENDOR(0x16d0), /* Azeron controllers */ | |
| 537 | 548 | XPAD_XBOX360_VENDOR(0x17ef), /* Lenovo */ | |
| 538 | 549 | XPAD_XBOX360_VENDOR(0x1949), /* Amazon controllers */ | |
| 539 | 550 | XPAD_XBOX360_VENDOR(0x1a86), /* Nanjing Qinheng Microelectronics (WCH) */ | |
| 551 | + | XPAD_XBOX360_VENDOR(0x1b1c), /* Corsair controllers */ | |
| 540 | 552 | XPAD_XBOX360_VENDOR(0x1bad), /* Harmonix Rock Band guitar and drums */ | |
| 541 | 553 | XPAD_XBOX360_VENDOR(0x1ee9), /* ZOTAC Technology Limited */ | |
| 542 | 554 | XPAD_XBOX360_VENDOR(0x20bc), /* BETOP wireless dongles */ | |
modified drivers/input/keyboard/adp5588-keys.c
| @@ -446,12 +446,6 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad) | |||
| 446 | 446 | ||
| 447 | 447 | mutex_init(&kpad->gpio_lock); | |
| 448 | 448 | ||
| 449 | - | error = devm_gpiochip_add_data(dev, &kpad->gc, kpad); | |
| 450 | - | if (error) { | |
| 451 | - | dev_err(dev, "gpiochip_add failed: %d\n", error); | |
| 452 | - | return error; | |
| 453 | - | } | |
| 454 | - | ||
| 455 | 449 | for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { | |
| 456 | 450 | kpad->dat_out[i] = adp5588_read(kpad->client, | |
| 457 | 451 | GPIO_DAT_OUT1 + i); | |
| @@ -459,6 +453,12 @@ static int adp5588_gpio_add(struct adp5588_kpad *kpad) | |||
| 459 | 453 | kpad->pull_dis[i] = adp5588_read(kpad->client, GPIO_PULL1 + i); | |
| 460 | 454 | } | |
| 461 | 455 | ||
| 456 | + | error = devm_gpiochip_add_data(dev, &kpad->gc, kpad); | |
| 457 | + | if (error) { | |
| 458 | + | dev_err(dev, "gpiochip_add failed: %d\n", error); | |
| 459 | + | return error; | |
| 460 | + | } | |
| 461 | + | ||
| 462 | 462 | return 0; | |
| 463 | 463 | } | |
| 464 | 464 | ||
modified drivers/input/keyboard/atkbd.c
| @@ -1938,6 +1938,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = { | |||
| 1938 | 1938 | }, | |
| 1939 | 1939 | .callback = atkbd_deactivate_fixup, | |
| 1940 | 1940 | }, | |
| 1941 | + | { | |
| 1942 | + | /* Lenovo IdeaPad Slim 3 15IWC11 (83RR) */ | |
| 1943 | + | .matches = { | |
| 1944 | + | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | |
| 1945 | + | DMI_MATCH(DMI_PRODUCT_NAME, "83RR"), | |
| 1946 | + | }, | |
| 1947 | + | .callback = atkbd_deactivate_fixup, | |
| 1948 | + | }, | |
| 1941 | 1949 | { | |
| 1942 | 1950 | /* Xiaomi Book Pro 14 (TM2424) */ | |
| 1943 | 1951 | .matches = { | |
| @@ -1946,6 +1954,14 @@ static const struct dmi_system_id atkbd_dmi_quirk_table[] __initconst = { | |||
| 1946 | 1954 | }, | |
| 1947 | 1955 | .callback = atkbd_deactivate_fixup, | |
| 1948 | 1956 | }, | |
| 1957 | + | { | |
| 1958 | + | /* Xiaomi Redmi Book Pro 16 2026 (TM2425) */ | |
| 1959 | + | .matches = { | |
| 1960 | + | DMI_MATCH(DMI_SYS_VENDOR, "XIAOMI"), | |
| 1961 | + | DMI_MATCH(DMI_PRODUCT_NAME, "REDMI Book Pro 16 2026"), | |
| 1962 | + | }, | |
| 1963 | + | .callback = atkbd_deactivate_fixup, | |
| 1964 | + | }, | |
| 1949 | 1965 | { } | |
| 1950 | 1966 | }; | |
| 1951 | 1967 | ||
modified drivers/input/misc/ati_remote2.c
| @@ -672,8 +672,7 @@ static ssize_t ati_remote2_show_channel_mask(struct device *dev, | |||
| 672 | 672 | struct device_attribute *attr, | |
| 673 | 673 | char *buf) | |
| 674 | 674 | { | |
| 675 | - | struct usb_device *udev = to_usb_device(dev); | |
| 676 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 675 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 677 | 676 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 678 | 677 | ||
| 679 | 678 | return sprintf(buf, "0x%04x\n", ar2->channel_mask); | |
| @@ -683,8 +682,7 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev, | |||
| 683 | 682 | struct device_attribute *attr, | |
| 684 | 683 | const char *buf, size_t count) | |
| 685 | 684 | { | |
| 686 | - | struct usb_device *udev = to_usb_device(dev); | |
| 687 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 685 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 688 | 686 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 689 | 687 | unsigned int mask; | |
| 690 | 688 | int r; | |
| @@ -720,8 +718,7 @@ static ssize_t ati_remote2_show_mode_mask(struct device *dev, | |||
| 720 | 718 | struct device_attribute *attr, | |
| 721 | 719 | char *buf) | |
| 722 | 720 | { | |
| 723 | - | struct usb_device *udev = to_usb_device(dev); | |
| 724 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 721 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 725 | 722 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 726 | 723 | ||
| 727 | 724 | return sprintf(buf, "0x%02x\n", ar2->mode_mask); | |
| @@ -731,8 +728,7 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev, | |||
| 731 | 728 | struct device_attribute *attr, | |
| 732 | 729 | const char *buf, size_t count) | |
| 733 | 730 | { | |
| 734 | - | struct usb_device *udev = to_usb_device(dev); | |
| 735 | - | struct usb_interface *intf = usb_ifnum_to_if(udev, 0); | |
| 731 | + | struct usb_interface *intf = to_usb_interface(dev); | |
| 736 | 732 | struct ati_remote2 *ar2 = usb_get_intfdata(intf); | |
| 737 | 733 | unsigned int mask; | |
| 738 | 734 | int err; | |
modified drivers/input/mouse/synaptics.c
| @@ -192,6 +192,7 @@ static const char * const smbus_pnp_ids[] = { | |||
| 192 | 192 | "LEN2054", /* E480 */ | |
| 193 | 193 | "LEN2055", /* E580 */ | |
| 194 | 194 | "LEN2058", /* E490 */ | |
| 195 | + | "LEN205b", /* T490 */ | |
| 195 | 196 | "LEN2068", /* T14 Gen 1 */ | |
| 196 | 197 | "SYN1221", /* TUXEDO InfinityBook Pro 14 v5 */ | |
| 197 | 198 | "SYN3003", /* HP EliteBook 850 G1 */ | |
| @@ -1838,6 +1839,16 @@ static int synaptics_setup_intertouch(struct psmouse *psmouse, | |||
| 1838 | 1839 | ||
| 1839 | 1840 | return -ENXIO; | |
| 1840 | 1841 | } | |
| 1842 | + | ||
| 1843 | + | /* Disable intertouch on known-broken T440p board revisions */ | |
| 1844 | + | if (info->board_id == 2722 && | |
| 1845 | + | psmouse_matches_pnp_id(psmouse, | |
| 1846 | + | (const char * const []){"LEN0036", NULL})) { | |
| 1847 | + | psmouse_info(psmouse, | |
| 1848 | + | "Disabling intertouch for board id %u\n", | |
| 1849 | + | info->board_id); | |
| 1850 | + | return -ENXIO; | |
| 1851 | + | } | |
| 1841 | 1852 | } | |
| 1842 | 1853 | ||
| 1843 | 1854 | psmouse_info(psmouse, "Trying to set up SMBus access\n"); | |
modified drivers/input/rmi4/rmi_driver.c
| @@ -991,6 +991,15 @@ int rmi_driver_suspend(struct rmi_device *rmi_dev, bool enable_wake) | |||
| 991 | 991 | { | |
| 992 | 992 | int retval; | |
| 993 | 993 | ||
| 994 | + | /* | |
| 995 | + | * Transport driver will try to suspend RMI device even if physical | |
| 996 | + | * driver did not bind to the RMI device, because transport device | |
| 997 | + | * (I2C, SPI) is fully registered and operational. Exit early if | |
| 998 | + | * there is no driver data attached to the RMI device. | |
| 999 | + | */ | |
| 1000 | + | if (!dev_get_drvdata(&rmi_dev->dev)) | |
| 1001 | + | return 0; | |
| 1002 | + | ||
| 994 | 1003 | retval = rmi_suspend_functions(rmi_dev); | |
| 995 | 1004 | if (retval) | |
| 996 | 1005 | dev_warn(&rmi_dev->dev, "Failed to suspend functions: %d\n", | |
| @@ -1005,6 +1014,10 @@ int rmi_driver_resume(struct rmi_device *rmi_dev, bool clear_wake) | |||
| 1005 | 1014 | { | |
| 1006 | 1015 | int retval; | |
| 1007 | 1016 | ||
| 1017 | + | /* Skip if not fully bound to RMI driver */ | |
| 1018 | + | if (!dev_get_drvdata(&rmi_dev->dev)) | |
| 1019 | + | return 0; | |
| 1020 | + | ||
| 1008 | 1021 | rmi_enable_irq(rmi_dev, clear_wake); | |
| 1009 | 1022 | ||
| 1010 | 1023 | retval = rmi_resume_functions(rmi_dev); | |
modified drivers/input/rmi4/rmi_smbus.c
| @@ -140,7 +140,7 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr, | |||
| 140 | 140 | u8 commandcode; | |
| 141 | 141 | struct rmi_smb_xport *rmi_smb = | |
| 142 | 142 | container_of(xport, struct rmi_smb_xport, xport); | |
| 143 | - | int cur_len = (int)len; | |
| 143 | + | size_t cur_len = len; | |
| 144 | 144 | ||
| 145 | 145 | mutex_lock(&rmi_smb->page_mutex); | |
| 146 | 146 | ||
| @@ -148,7 +148,7 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr, | |||
| 148 | 148 | /* | |
| 149 | 149 | * break into 32 bytes chunks to write get command code | |
| 150 | 150 | */ | |
| 151 | - | int block_len = min_t(int, len, SMB_MAX_COUNT); | |
| 151 | + | int block_len = min_t(size_t, cur_len, SMB_MAX_COUNT); | |
| 152 | 152 | ||
| 153 | 153 | retval = rmi_smb_get_command_code(xport, rmiaddr, block_len, | |
| 154 | 154 | false, &commandcode); | |
| @@ -161,9 +161,9 @@ static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr, | |||
| 161 | 161 | goto exit; | |
| 162 | 162 | ||
| 163 | 163 | /* prepare to write next block of bytes */ | |
| 164 | - | cur_len -= SMB_MAX_COUNT; | |
| 165 | - | databuff += SMB_MAX_COUNT; | |
| 166 | - | rmiaddr += SMB_MAX_COUNT; | |
| 164 | + | cur_len -= block_len; | |
| 165 | + | databuff += block_len; | |
| 166 | + | rmiaddr += block_len; | |
| 167 | 167 | } | |
| 168 | 168 | exit: | |
| 169 | 169 | mutex_unlock(&rmi_smb->page_mutex); | |
modified drivers/input/serio/hp_sdc.c
| @@ -981,7 +981,7 @@ static void hp_sdc_exit(void) | |||
| 981 | 981 | free_irq(hp_sdc.irq, &hp_sdc); | |
| 982 | 982 | write_unlock_irq(&hp_sdc.lock); | |
| 983 | 983 | ||
| 984 | - | timer_delete_sync(&hp_sdc.kicker); | |
| 984 | + | timer_shutdown_sync(&hp_sdc.kicker); | |
| 985 | 985 | ||
| 986 | 986 | tasklet_kill(&hp_sdc.task); | |
| 987 | 987 | ||
modified drivers/input/serio/i8042-acpipnpio.h
| @@ -259,6 +259,13 @@ static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = { | |||
| 259 | 259 | }, | |
| 260 | 260 | .driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS) | |
| 261 | 261 | }, | |
| 262 | + | { | |
| 263 | + | .matches = { | |
| 264 | + | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
| 265 | + | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire AG15-42P"), | |
| 266 | + | }, | |
| 267 | + | .driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS) | |
| 268 | + | }, | |
| 262 | 269 | { | |
| 263 | 270 | .matches = { | |
| 264 | 271 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | |
| @@ -664,6 +671,15 @@ static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = { | |||
| 664 | 671 | }, | |
| 665 | 672 | .driver_data = (void *)(SERIO_QUIRK_NOAUX) | |
| 666 | 673 | }, | |
| 674 | + | { | |
| 675 | + | /* Fujitsu LIFEBOOK U7410 */ | |
| 676 | + | /* Mux mode also disturbs the EC keyboard, causing spurious ACKs */ | |
| 677 | + | .matches = { | |
| 678 | + | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU CLIENT COMPUTING LIMITED"), | |
| 679 | + | DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U7410"), | |
| 680 | + | }, | |
| 681 | + | .driver_data = (void *)(SERIO_QUIRK_NOMUX) | |
| 682 | + | }, | |
| 667 | 683 | { | |
| 668 | 684 | /* Gigabyte M912 */ | |
| 669 | 685 | .matches = { | |
modified drivers/input/touchscreen/cyttsp5.c
| @@ -710,6 +710,7 @@ static irqreturn_t cyttsp5_handle_irq(int irq, void *handle) | |||
| 710 | 710 | size = 2; | |
| 711 | 711 | } else { | |
| 712 | 712 | report_id = ts->input_buf[2]; | |
| 713 | + | size = min(size, CY_MAX_INPUT); | |
| 713 | 714 | } | |
| 714 | 715 | ||
| 715 | 716 | switch (report_id) { | |
modified drivers/input/touchscreen/eeti_ts.c
| @@ -276,6 +276,7 @@ static const struct of_device_id of_eeti_ts_match[] = { | |||
| 276 | 276 | { .compatible = "eeti,exc3000-i2c", }, | |
| 277 | 277 | { } | |
| 278 | 278 | }; | |
| 279 | + | MODULE_DEVICE_TABLE(of, of_eeti_ts_match); | |
| 279 | 280 | #endif | |
| 280 | 281 | ||
| 281 | 282 | static struct i2c_driver eeti_ts_driver = { | |
modified drivers/input/touchscreen/s6sy761.c
| @@ -500,10 +500,22 @@ static int s6sy761_suspend(struct device *dev) | |||
| 500 | 500 | static int s6sy761_resume(struct device *dev) | |
| 501 | 501 | { | |
| 502 | 502 | struct s6sy761_data *sdata = dev_get_drvdata(dev); | |
| 503 | + | int err; | |
| 504 | + | ||
| 505 | + | err = s6sy761_power_on(sdata); | |
| 506 | + | if (err) | |
| 507 | + | return err; | |
| 503 | 508 | ||
| 504 | 509 | enable_irq(sdata->client->irq); | |
| 505 | 510 | ||
| 506 | - | return s6sy761_power_on(sdata); | |
| 511 | + | guard(mutex)(&sdata->input->mutex); | |
| 512 | + | ||
| 513 | + | if (!input_device_enabled(sdata->input)) | |
| 514 | + | return 0; | |
| 515 | + | ||
| 516 | + | err = i2c_smbus_write_byte(sdata->client, S6SY761_SENSE_ON); | |
| 517 | + | ||
| 518 | + | return err; | |
| 507 | 519 | } | |
| 508 | 520 | ||
| 509 | 521 | static const struct dev_pm_ops s6sy761_pm_ops = { | |
modified drivers/input/touchscreen/tsc2007_core.c
| @@ -221,7 +221,6 @@ static int tsc2007_get_pendown_state_gpio(struct device *dev) | |||
| 221 | 221 | static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) | |
| 222 | 222 | { | |
| 223 | 223 | u32 val32; | |
| 224 | - | u64 val64; | |
| 225 | 224 | ||
| 226 | 225 | if (!device_property_read_u32(dev, "ti,max-rt", &val32)) | |
| 227 | 226 | ts->max_rt = val32; | |
| @@ -237,8 +236,8 @@ static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) | |||
| 237 | 236 | if (!device_property_read_u32(dev, "ti,fuzzz", &val32)) | |
| 238 | 237 | ts->fuzzz = val32; | |
| 239 | 238 | ||
| 240 | - | if (!device_property_read_u64(dev, "ti,poll-period", &val64)) | |
| 241 | - | ts->poll_period = msecs_to_jiffies(val64); | |
| 239 | + | if (!device_property_read_u32(dev, "ti,poll-period", &val32)) | |
| 240 | + | ts->poll_period = msecs_to_jiffies(val32); | |
| 242 | 241 | else | |
| 243 | 242 | ts->poll_period = msecs_to_jiffies(1); | |
| 244 | 243 | ||
modified drivers/interconnect/qcom/x1e80100.c
| @@ -173,13 +173,6 @@ static struct qcom_icc_node qhm_qspi = { | |||
| 173 | 173 | .name = "qhm_qspi", | |
| 174 | 174 | .channels = 1, | |
| 175 | 175 | .buswidth = 4, | |
| 176 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 177 | - | .num_ports = 1, | |
| 178 | - | .port_offsets = { 0xb000 }, | |
| 179 | - | .prio = 2, | |
| 180 | - | .urg_fwd = 0, | |
| 181 | - | .prio_fwd_disable = 1, | |
| 182 | - | }, | |
| 183 | 176 | .num_links = 1, | |
| 184 | 177 | .link_nodes = { &qns_a1noc_snoc }, | |
| 185 | 178 | }; | |
| @@ -188,13 +181,6 @@ static struct qcom_icc_node qhm_qup1 = { | |||
| 188 | 181 | .name = "qhm_qup1", | |
| 189 | 182 | .channels = 1, | |
| 190 | 183 | .buswidth = 4, | |
| 191 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 192 | - | .num_ports = 1, | |
| 193 | - | .port_offsets = { 0xc000 }, | |
| 194 | - | .prio = 2, | |
| 195 | - | .urg_fwd = 0, | |
| 196 | - | .prio_fwd_disable = 1, | |
| 197 | - | }, | |
| 198 | 184 | .num_links = 1, | |
| 199 | 185 | .link_nodes = { &qns_a1noc_snoc }, | |
| 200 | 186 | }; | |
| @@ -203,13 +189,6 @@ static struct qcom_icc_node xm_sdc4 = { | |||
| 203 | 189 | .name = "xm_sdc4", | |
| 204 | 190 | .channels = 1, | |
| 205 | 191 | .buswidth = 8, | |
| 206 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 207 | - | .num_ports = 1, | |
| 208 | - | .port_offsets = { 0xd000 }, | |
| 209 | - | .prio = 2, | |
| 210 | - | .urg_fwd = 0, | |
| 211 | - | .prio_fwd_disable = 1, | |
| 212 | - | }, | |
| 213 | 192 | .num_links = 1, | |
| 214 | 193 | .link_nodes = { &qns_a1noc_snoc }, | |
| 215 | 194 | }; | |
| @@ -218,13 +197,6 @@ static struct qcom_icc_node xm_ufs_mem = { | |||
| 218 | 197 | .name = "xm_ufs_mem", | |
| 219 | 198 | .channels = 1, | |
| 220 | 199 | .buswidth = 16, | |
| 221 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 222 | - | .num_ports = 1, | |
| 223 | - | .port_offsets = { 0xe000 }, | |
| 224 | - | .prio = 2, | |
| 225 | - | .urg_fwd = 0, | |
| 226 | - | .prio_fwd_disable = 1, | |
| 227 | - | }, | |
| 228 | 200 | .num_links = 1, | |
| 229 | 201 | .link_nodes = { &qns_a1noc_snoc }, | |
| 230 | 202 | }; | |
| @@ -233,13 +205,6 @@ static struct qcom_icc_node qhm_qup0 = { | |||
| 233 | 205 | .name = "qhm_qup0", | |
| 234 | 206 | .channels = 1, | |
| 235 | 207 | .buswidth = 4, | |
| 236 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 237 | - | .num_ports = 1, | |
| 238 | - | .port_offsets = { 0x16000 }, | |
| 239 | - | .prio = 2, | |
| 240 | - | .urg_fwd = 0, | |
| 241 | - | .prio_fwd_disable = 1, | |
| 242 | - | }, | |
| 243 | 208 | .num_links = 1, | |
| 244 | 209 | .link_nodes = { &qns_a2noc_snoc }, | |
| 245 | 210 | }; | |
| @@ -248,13 +213,6 @@ static struct qcom_icc_node qhm_qup2 = { | |||
| 248 | 213 | .name = "qhm_qup2", | |
| 249 | 214 | .channels = 1, | |
| 250 | 215 | .buswidth = 4, | |
| 251 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 252 | - | .num_ports = 1, | |
| 253 | - | .port_offsets = { 0x11000 }, | |
| 254 | - | .prio = 2, | |
| 255 | - | .urg_fwd = 0, | |
| 256 | - | .prio_fwd_disable = 1, | |
| 257 | - | }, | |
| 258 | 216 | .num_links = 1, | |
| 259 | 217 | .link_nodes = { &qns_a2noc_snoc }, | |
| 260 | 218 | }; | |
| @@ -263,13 +221,6 @@ static struct qcom_icc_node qxm_crypto = { | |||
| 263 | 221 | .name = "qxm_crypto", | |
| 264 | 222 | .channels = 1, | |
| 265 | 223 | .buswidth = 8, | |
| 266 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 267 | - | .num_ports = 1, | |
| 268 | - | .port_offsets = { 0x12000 }, | |
| 269 | - | .prio = 2, | |
| 270 | - | .urg_fwd = 0, | |
| 271 | - | .prio_fwd_disable = 1, | |
| 272 | - | }, | |
| 273 | 224 | .num_links = 1, | |
| 274 | 225 | .link_nodes = { &qns_a2noc_snoc }, | |
| 275 | 226 | }; | |
| @@ -286,13 +237,6 @@ static struct qcom_icc_node xm_qdss_etr_0 = { | |||
| 286 | 237 | .name = "xm_qdss_etr_0", | |
| 287 | 238 | .channels = 1, | |
| 288 | 239 | .buswidth = 8, | |
| 289 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 290 | - | .num_ports = 1, | |
| 291 | - | .port_offsets = { 0x13000 }, | |
| 292 | - | .prio = 2, | |
| 293 | - | .urg_fwd = 0, | |
| 294 | - | .prio_fwd_disable = 1, | |
| 295 | - | }, | |
| 296 | 240 | .num_links = 1, | |
| 297 | 241 | .link_nodes = { &qns_a2noc_snoc }, | |
| 298 | 242 | }; | |
| @@ -301,13 +245,6 @@ static struct qcom_icc_node xm_qdss_etr_1 = { | |||
| 301 | 245 | .name = "xm_qdss_etr_1", | |
| 302 | 246 | .channels = 1, | |
| 303 | 247 | .buswidth = 8, | |
| 304 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 305 | - | .num_ports = 1, | |
| 306 | - | .port_offsets = { 0x14000 }, | |
| 307 | - | .prio = 2, | |
| 308 | - | .urg_fwd = 0, | |
| 309 | - | .prio_fwd_disable = 1, | |
| 310 | - | }, | |
| 311 | 248 | .num_links = 1, | |
| 312 | 249 | .link_nodes = { &qns_a2noc_snoc }, | |
| 313 | 250 | }; | |
| @@ -316,13 +253,6 @@ static struct qcom_icc_node xm_sdc2 = { | |||
| 316 | 253 | .name = "xm_sdc2", | |
| 317 | 254 | .channels = 1, | |
| 318 | 255 | .buswidth = 8, | |
| 319 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 320 | - | .num_ports = 1, | |
| 321 | - | .port_offsets = { 0x15000 }, | |
| 322 | - | .prio = 2, | |
| 323 | - | .urg_fwd = 0, | |
| 324 | - | .prio_fwd_disable = 1, | |
| 325 | - | }, | |
| 326 | 256 | .num_links = 1, | |
| 327 | 257 | .link_nodes = { &qns_a2noc_snoc }, | |
| 328 | 258 | }; | |
| @@ -407,13 +337,6 @@ static struct qcom_icc_node alm_gpu_tcu = { | |||
| 407 | 337 | .name = "alm_gpu_tcu", | |
| 408 | 338 | .channels = 1, | |
| 409 | 339 | .buswidth = 8, | |
| 410 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 411 | - | .num_ports = 1, | |
| 412 | - | .port_offsets = { 0x271000 }, | |
| 413 | - | .prio = 1, | |
| 414 | - | .urg_fwd = 0, | |
| 415 | - | .prio_fwd_disable = 1, | |
| 416 | - | }, | |
| 417 | 340 | .num_links = 2, | |
| 418 | 341 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 419 | 342 | }; | |
| @@ -422,13 +345,6 @@ static struct qcom_icc_node alm_pcie_tcu = { | |||
| 422 | 345 | .name = "alm_pcie_tcu", | |
| 423 | 346 | .channels = 1, | |
| 424 | 347 | .buswidth = 8, | |
| 425 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 426 | - | .num_ports = 1, | |
| 427 | - | .port_offsets = { 0x27d000 }, | |
| 428 | - | .prio = 3, | |
| 429 | - | .urg_fwd = 0, | |
| 430 | - | .prio_fwd_disable = 1, | |
| 431 | - | }, | |
| 432 | 348 | .num_links = 2, | |
| 433 | 349 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 434 | 350 | }; | |
| @@ -437,13 +353,6 @@ static struct qcom_icc_node alm_sys_tcu = { | |||
| 437 | 353 | .name = "alm_sys_tcu", | |
| 438 | 354 | .channels = 1, | |
| 439 | 355 | .buswidth = 8, | |
| 440 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 441 | - | .num_ports = 1, | |
| 442 | - | .port_offsets = { 0x273000 }, | |
| 443 | - | .prio = 6, | |
| 444 | - | .urg_fwd = 0, | |
| 445 | - | .prio_fwd_disable = 1, | |
| 446 | - | }, | |
| 447 | 356 | .num_links = 2, | |
| 448 | 357 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 449 | 358 | }; | |
| @@ -461,13 +370,6 @@ static struct qcom_icc_node qnm_gpu = { | |||
| 461 | 370 | .name = "qnm_gpu", | |
| 462 | 371 | .channels = 4, | |
| 463 | 372 | .buswidth = 32, | |
| 464 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 465 | - | .num_ports = 4, | |
| 466 | - | .port_offsets = { 0x51000, 0x58000, 0xd1000, 0xd8000 }, | |
| 467 | - | .prio = 0, | |
| 468 | - | .urg_fwd = 0, | |
| 469 | - | .prio_fwd_disable = 1, | |
| 470 | - | }, | |
| 471 | 373 | .num_links = 2, | |
| 472 | 374 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 473 | 375 | }; | |
| @@ -476,13 +378,6 @@ static struct qcom_icc_node qnm_lpass = { | |||
| 476 | 378 | .name = "qnm_lpass", | |
| 477 | 379 | .channels = 1, | |
| 478 | 380 | .buswidth = 16, | |
| 479 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 480 | - | .num_ports = 1, | |
| 481 | - | .port_offsets = { 0x275000 }, | |
| 482 | - | .prio = 0, | |
| 483 | - | .urg_fwd = 1, | |
| 484 | - | .prio_fwd_disable = 0, | |
| 485 | - | }, | |
| 486 | 381 | .num_links = 3, | |
| 487 | 382 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 488 | 383 | &qns_pcie }, | |
| @@ -492,13 +387,6 @@ static struct qcom_icc_node qnm_mnoc_hf = { | |||
| 492 | 387 | .name = "qnm_mnoc_hf", | |
| 493 | 388 | .channels = 2, | |
| 494 | 389 | .buswidth = 32, | |
| 495 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 496 | - | .num_ports = 2, | |
| 497 | - | .port_offsets = { 0x53000, 0xd3000 }, | |
| 498 | - | .prio = 0, | |
| 499 | - | .urg_fwd = 1, | |
| 500 | - | .prio_fwd_disable = 0, | |
| 501 | - | }, | |
| 502 | 390 | .num_links = 2, | |
| 503 | 391 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 504 | 392 | }; | |
| @@ -507,13 +395,6 @@ static struct qcom_icc_node qnm_mnoc_sf = { | |||
| 507 | 395 | .name = "qnm_mnoc_sf", | |
| 508 | 396 | .channels = 2, | |
| 509 | 397 | .buswidth = 32, | |
| 510 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 511 | - | .num_ports = 2, | |
| 512 | - | .port_offsets = { 0x55000, 0xd5000 }, | |
| 513 | - | .prio = 0, | |
| 514 | - | .urg_fwd = 1, | |
| 515 | - | .prio_fwd_disable = 0, | |
| 516 | - | }, | |
| 517 | 398 | .num_links = 2, | |
| 518 | 399 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 519 | 400 | }; | |
| @@ -522,13 +403,6 @@ static struct qcom_icc_node qnm_nsp_noc = { | |||
| 522 | 403 | .name = "qnm_nsp_noc", | |
| 523 | 404 | .channels = 2, | |
| 524 | 405 | .buswidth = 32, | |
| 525 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 526 | - | .num_ports = 2, | |
| 527 | - | .port_offsets = { 0x57000, 0xd7000 }, | |
| 528 | - | .prio = 0, | |
| 529 | - | .urg_fwd = 0, | |
| 530 | - | .prio_fwd_disable = 1, | |
| 531 | - | }, | |
| 532 | 406 | .num_links = 3, | |
| 533 | 407 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 534 | 408 | &qns_pcie }, | |
| @@ -538,13 +412,6 @@ static struct qcom_icc_node qnm_pcie = { | |||
| 538 | 412 | .name = "qnm_pcie", | |
| 539 | 413 | .channels = 1, | |
| 540 | 414 | .buswidth = 64, | |
| 541 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 542 | - | .num_ports = 1, | |
| 543 | - | .port_offsets = { 0x277000 }, | |
| 544 | - | .prio = 0, | |
| 545 | - | .urg_fwd = 1, | |
| 546 | - | .prio_fwd_disable = 0, | |
| 547 | - | }, | |
| 548 | 415 | .num_links = 2, | |
| 549 | 416 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc }, | |
| 550 | 417 | }; | |
| @@ -553,13 +420,6 @@ static struct qcom_icc_node qnm_snoc_sf = { | |||
| 553 | 420 | .name = "qnm_snoc_sf", | |
| 554 | 421 | .channels = 1, | |
| 555 | 422 | .buswidth = 64, | |
| 556 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 557 | - | .num_ports = 1, | |
| 558 | - | .port_offsets = { 0x27b000 }, | |
| 559 | - | .prio = 2, | |
| 560 | - | .urg_fwd = 1, | |
| 561 | - | .prio_fwd_disable = 0, | |
| 562 | - | }, | |
| 563 | 423 | .num_links = 3, | |
| 564 | 424 | .link_nodes = { &qns_gem_noc_cnoc, &qns_llcc, | |
| 565 | 425 | &qns_pcie }, | |
| @@ -569,13 +429,6 @@ static struct qcom_icc_node xm_gic = { | |||
| 569 | 429 | .name = "xm_gic", | |
| 570 | 430 | .channels = 1, | |
| 571 | 431 | .buswidth = 8, | |
| 572 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 573 | - | .num_ports = 1, | |
| 574 | - | .port_offsets = { 0x27f000 }, | |
| 575 | - | .prio = 2, | |
| 576 | - | .urg_fwd = 0, | |
| 577 | - | .prio_fwd_disable = 1, | |
| 578 | - | }, | |
| 579 | 432 | .num_links = 1, | |
| 580 | 433 | .link_nodes = { &qns_llcc }, | |
| 581 | 434 | }; | |
| @@ -616,13 +469,6 @@ static struct qcom_icc_node qnm_av1_enc = { | |||
| 616 | 469 | .name = "qnm_av1_enc", | |
| 617 | 470 | .channels = 1, | |
| 618 | 471 | .buswidth = 32, | |
| 619 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 620 | - | .num_ports = 1, | |
| 621 | - | .port_offsets = { 0x2f000 }, | |
| 622 | - | .prio = 4, | |
| 623 | - | .urg_fwd = 0, | |
| 624 | - | .prio_fwd_disable = 1, | |
| 625 | - | }, | |
| 626 | 472 | .num_links = 1, | |
| 627 | 473 | .link_nodes = { &qns_mem_noc_sf }, | |
| 628 | 474 | }; | |
| @@ -631,13 +477,6 @@ static struct qcom_icc_node qnm_camnoc_hf = { | |||
| 631 | 477 | .name = "qnm_camnoc_hf", | |
| 632 | 478 | .channels = 2, | |
| 633 | 479 | .buswidth = 32, | |
| 634 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 635 | - | .num_ports = 2, | |
| 636 | - | .port_offsets = { 0x28000, 0x29000 }, | |
| 637 | - | .prio = 0, | |
| 638 | - | .urg_fwd = 1, | |
| 639 | - | .prio_fwd_disable = 0, | |
| 640 | - | }, | |
| 641 | 480 | .num_links = 1, | |
| 642 | 481 | .link_nodes = { &qns_mem_noc_hf }, | |
| 643 | 482 | }; | |
| @@ -646,13 +485,6 @@ static struct qcom_icc_node qnm_camnoc_icp = { | |||
| 646 | 485 | .name = "qnm_camnoc_icp", | |
| 647 | 486 | .channels = 1, | |
| 648 | 487 | .buswidth = 8, | |
| 649 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 650 | - | .num_ports = 1, | |
| 651 | - | .port_offsets = { 0x2a000 }, | |
| 652 | - | .prio = 4, | |
| 653 | - | .urg_fwd = 0, | |
| 654 | - | .prio_fwd_disable = 1, | |
| 655 | - | }, | |
| 656 | 488 | .num_links = 1, | |
| 657 | 489 | .link_nodes = { &qns_mem_noc_sf }, | |
| 658 | 490 | }; | |
| @@ -661,13 +493,6 @@ static struct qcom_icc_node qnm_camnoc_sf = { | |||
| 661 | 493 | .name = "qnm_camnoc_sf", | |
| 662 | 494 | .channels = 2, | |
| 663 | 495 | .buswidth = 32, | |
| 664 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 665 | - | .num_ports = 2, | |
| 666 | - | .port_offsets = { 0x2b000, 0x2c000 }, | |
| 667 | - | .prio = 0, | |
| 668 | - | .urg_fwd = 1, | |
| 669 | - | .prio_fwd_disable = 0, | |
| 670 | - | }, | |
| 671 | 496 | .num_links = 1, | |
| 672 | 497 | .link_nodes = { &qns_mem_noc_sf }, | |
| 673 | 498 | }; | |
| @@ -676,13 +501,6 @@ static struct qcom_icc_node qnm_eva = { | |||
| 676 | 501 | .name = "qnm_eva", | |
| 677 | 502 | .channels = 1, | |
| 678 | 503 | .buswidth = 32, | |
| 679 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 680 | - | .num_ports = 1, | |
| 681 | - | .port_offsets = { 0x33000 }, | |
| 682 | - | .prio = 0, | |
| 683 | - | .urg_fwd = 1, | |
| 684 | - | .prio_fwd_disable = 0, | |
| 685 | - | }, | |
| 686 | 504 | .num_links = 1, | |
| 687 | 505 | .link_nodes = { &qns_mem_noc_sf }, | |
| 688 | 506 | }; | |
| @@ -691,13 +509,6 @@ static struct qcom_icc_node qnm_mdp = { | |||
| 691 | 509 | .name = "qnm_mdp", | |
| 692 | 510 | .channels = 2, | |
| 693 | 511 | .buswidth = 32, | |
| 694 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 695 | - | .num_ports = 2, | |
| 696 | - | .port_offsets = { 0x2d000, 0x2e000 }, | |
| 697 | - | .prio = 0, | |
| 698 | - | .urg_fwd = 1, | |
| 699 | - | .prio_fwd_disable = 0, | |
| 700 | - | }, | |
| 701 | 512 | .num_links = 1, | |
| 702 | 513 | .link_nodes = { &qns_mem_noc_hf }, | |
| 703 | 514 | }; | |
| @@ -706,13 +517,6 @@ static struct qcom_icc_node qnm_video = { | |||
| 706 | 517 | .name = "qnm_video", | |
| 707 | 518 | .channels = 2, | |
| 708 | 519 | .buswidth = 32, | |
| 709 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 710 | - | .num_ports = 2, | |
| 711 | - | .port_offsets = { 0x30000, 0x31000 }, | |
| 712 | - | .prio = 0, | |
| 713 | - | .urg_fwd = 1, | |
| 714 | - | .prio_fwd_disable = 0, | |
| 715 | - | }, | |
| 716 | 520 | .num_links = 1, | |
| 717 | 521 | .link_nodes = { &qns_mem_noc_sf }, | |
| 718 | 522 | }; | |
| @@ -721,13 +525,6 @@ static struct qcom_icc_node qnm_video_cv_cpu = { | |||
| 721 | 525 | .name = "qnm_video_cv_cpu", | |
| 722 | 526 | .channels = 1, | |
| 723 | 527 | .buswidth = 8, | |
| 724 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 725 | - | .num_ports = 1, | |
| 726 | - | .port_offsets = { 0x32000 }, | |
| 727 | - | .prio = 4, | |
| 728 | - | .urg_fwd = 0, | |
| 729 | - | .prio_fwd_disable = 1, | |
| 730 | - | }, | |
| 731 | 528 | .num_links = 1, | |
| 732 | 529 | .link_nodes = { &qns_mem_noc_sf }, | |
| 733 | 530 | }; | |
| @@ -736,13 +533,6 @@ static struct qcom_icc_node qnm_video_v_cpu = { | |||
| 736 | 533 | .name = "qnm_video_v_cpu", | |
| 737 | 534 | .channels = 1, | |
| 738 | 535 | .buswidth = 8, | |
| 739 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 740 | - | .num_ports = 1, | |
| 741 | - | .port_offsets = { 0x34000 }, | |
| 742 | - | .prio = 4, | |
| 743 | - | .urg_fwd = 0, | |
| 744 | - | .prio_fwd_disable = 1, | |
| 745 | - | }, | |
| 746 | 536 | .num_links = 1, | |
| 747 | 537 | .link_nodes = { &qns_mem_noc_sf }, | |
| 748 | 538 | }; | |
| @@ -783,13 +573,6 @@ static struct qcom_icc_node xm_pcie_3 = { | |||
| 783 | 573 | .name = "xm_pcie_3", | |
| 784 | 574 | .channels = 1, | |
| 785 | 575 | .buswidth = 64, | |
| 786 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 787 | - | .num_ports = 1, | |
| 788 | - | .port_offsets = { 0x7000 }, | |
| 789 | - | .prio = 2, | |
| 790 | - | .urg_fwd = 0, | |
| 791 | - | .prio_fwd_disable = 1, | |
| 792 | - | }, | |
| 793 | 576 | .num_links = 1, | |
| 794 | 577 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 795 | 578 | }; | |
| @@ -798,13 +581,6 @@ static struct qcom_icc_node xm_pcie_4 = { | |||
| 798 | 581 | .name = "xm_pcie_4", | |
| 799 | 582 | .channels = 1, | |
| 800 | 583 | .buswidth = 8, | |
| 801 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 802 | - | .num_ports = 1, | |
| 803 | - | .port_offsets = { 0x8000 }, | |
| 804 | - | .prio = 2, | |
| 805 | - | .urg_fwd = 0, | |
| 806 | - | .prio_fwd_disable = 1, | |
| 807 | - | }, | |
| 808 | 584 | .num_links = 1, | |
| 809 | 585 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 810 | 586 | }; | |
| @@ -813,13 +589,6 @@ static struct qcom_icc_node xm_pcie_5 = { | |||
| 813 | 589 | .name = "xm_pcie_5", | |
| 814 | 590 | .channels = 1, | |
| 815 | 591 | .buswidth = 8, | |
| 816 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 817 | - | .num_ports = 1, | |
| 818 | - | .port_offsets = { 0x9000 }, | |
| 819 | - | .prio = 3, | |
| 820 | - | .urg_fwd = 0, | |
| 821 | - | .prio_fwd_disable = 1, | |
| 822 | - | }, | |
| 823 | 592 | .num_links = 1, | |
| 824 | 593 | .link_nodes = { &qns_pcie_north_gem_noc }, | |
| 825 | 594 | }; | |
| @@ -828,13 +597,6 @@ static struct qcom_icc_node xm_pcie_0 = { | |||
| 828 | 597 | .name = "xm_pcie_0", | |
| 829 | 598 | .channels = 1, | |
| 830 | 599 | .buswidth = 16, | |
| 831 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 832 | - | .num_ports = 1, | |
| 833 | - | .port_offsets = { 0x9000 }, | |
| 834 | - | .prio = 2, | |
| 835 | - | .urg_fwd = 0, | |
| 836 | - | .prio_fwd_disable = 1, | |
| 837 | - | }, | |
| 838 | 600 | .num_links = 1, | |
| 839 | 601 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 840 | 602 | }; | |
| @@ -843,13 +605,6 @@ static struct qcom_icc_node xm_pcie_1 = { | |||
| 843 | 605 | .name = "xm_pcie_1", | |
| 844 | 606 | .channels = 1, | |
| 845 | 607 | .buswidth = 16, | |
| 846 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 847 | - | .num_ports = 1, | |
| 848 | - | .port_offsets = { 0xa000 }, | |
| 849 | - | .prio = 2, | |
| 850 | - | .urg_fwd = 0, | |
| 851 | - | .prio_fwd_disable = 1, | |
| 852 | - | }, | |
| 853 | 608 | .num_links = 1, | |
| 854 | 609 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 855 | 610 | }; | |
| @@ -858,13 +613,6 @@ static struct qcom_icc_node xm_pcie_2 = { | |||
| 858 | 613 | .name = "xm_pcie_2", | |
| 859 | 614 | .channels = 1, | |
| 860 | 615 | .buswidth = 16, | |
| 861 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 862 | - | .num_ports = 1, | |
| 863 | - | .port_offsets = { 0xb000 }, | |
| 864 | - | .prio = 2, | |
| 865 | - | .urg_fwd = 0, | |
| 866 | - | .prio_fwd_disable = 1, | |
| 867 | - | }, | |
| 868 | 616 | .num_links = 1, | |
| 869 | 617 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 870 | 618 | }; | |
| @@ -873,13 +621,6 @@ static struct qcom_icc_node xm_pcie_6a = { | |||
| 873 | 621 | .name = "xm_pcie_6a", | |
| 874 | 622 | .channels = 1, | |
| 875 | 623 | .buswidth = 32, | |
| 876 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 877 | - | .num_ports = 1, | |
| 878 | - | .port_offsets = { 0xc000 }, | |
| 879 | - | .prio = 2, | |
| 880 | - | .urg_fwd = 0, | |
| 881 | - | .prio_fwd_disable = 1, | |
| 882 | - | }, | |
| 883 | 624 | .num_links = 1, | |
| 884 | 625 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 885 | 626 | }; | |
| @@ -888,13 +629,6 @@ static struct qcom_icc_node xm_pcie_6b = { | |||
| 888 | 629 | .name = "xm_pcie_6b", | |
| 889 | 630 | .channels = 1, | |
| 890 | 631 | .buswidth = 16, | |
| 891 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 892 | - | .num_ports = 1, | |
| 893 | - | .port_offsets = { 0xd000 }, | |
| 894 | - | .prio = 2, | |
| 895 | - | .urg_fwd = 0, | |
| 896 | - | .prio_fwd_disable = 1, | |
| 897 | - | }, | |
| 898 | 632 | .num_links = 1, | |
| 899 | 633 | .link_nodes = { &qns_pcie_south_gem_noc }, | |
| 900 | 634 | }; | |
| @@ -919,13 +653,6 @@ static struct qcom_icc_node qnm_gic = { | |||
| 919 | 653 | .name = "qnm_gic", | |
| 920 | 654 | .channels = 1, | |
| 921 | 655 | .buswidth = 8, | |
| 922 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 923 | - | .num_ports = 1, | |
| 924 | - | .port_offsets = { 0x1c000 }, | |
| 925 | - | .prio = 2, | |
| 926 | - | .urg_fwd = 0, | |
| 927 | - | .prio_fwd_disable = 1, | |
| 928 | - | }, | |
| 929 | 656 | .num_links = 1, | |
| 930 | 657 | .link_nodes = { &qns_gemnoc_sf }, | |
| 931 | 658 | }; | |
| @@ -958,13 +685,6 @@ static struct qcom_icc_node xm_usb2_0 = { | |||
| 958 | 685 | .name = "xm_usb2_0", | |
| 959 | 686 | .channels = 1, | |
| 960 | 687 | .buswidth = 8, | |
| 961 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 962 | - | .num_ports = 1, | |
| 963 | - | .port_offsets = { 0x6000 }, | |
| 964 | - | .prio = 2, | |
| 965 | - | .urg_fwd = 0, | |
| 966 | - | .prio_fwd_disable = 1, | |
| 967 | - | }, | |
| 968 | 688 | .num_links = 1, | |
| 969 | 689 | .link_nodes = { &qns_aggre_usb_north_snoc }, | |
| 970 | 690 | }; | |
| @@ -973,13 +693,6 @@ static struct qcom_icc_node xm_usb3_mp = { | |||
| 973 | 693 | .name = "xm_usb3_mp", | |
| 974 | 694 | .channels = 1, | |
| 975 | 695 | .buswidth = 16, | |
| 976 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 977 | - | .num_ports = 1, | |
| 978 | - | .port_offsets = { 0x7000 }, | |
| 979 | - | .prio = 2, | |
| 980 | - | .urg_fwd = 0, | |
| 981 | - | .prio_fwd_disable = 1, | |
| 982 | - | }, | |
| 983 | 696 | .num_links = 1, | |
| 984 | 697 | .link_nodes = { &qns_aggre_usb_north_snoc }, | |
| 985 | 698 | }; | |
| @@ -988,13 +701,6 @@ static struct qcom_icc_node xm_usb3_0 = { | |||
| 988 | 701 | .name = "xm_usb3_0", | |
| 989 | 702 | .channels = 1, | |
| 990 | 703 | .buswidth = 8, | |
| 991 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 992 | - | .num_ports = 1, | |
| 993 | - | .port_offsets = { 0xa000 }, | |
| 994 | - | .prio = 2, | |
| 995 | - | .urg_fwd = 0, | |
| 996 | - | .prio_fwd_disable = 1, | |
| 997 | - | }, | |
| 998 | 704 | .num_links = 1, | |
| 999 | 705 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1000 | 706 | }; | |
| @@ -1003,13 +709,6 @@ static struct qcom_icc_node xm_usb3_1 = { | |||
| 1003 | 709 | .name = "xm_usb3_1", | |
| 1004 | 710 | .channels = 1, | |
| 1005 | 711 | .buswidth = 8, | |
| 1006 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1007 | - | .num_ports = 1, | |
| 1008 | - | .port_offsets = { 0xb000 }, | |
| 1009 | - | .prio = 2, | |
| 1010 | - | .urg_fwd = 0, | |
| 1011 | - | .prio_fwd_disable = 1, | |
| 1012 | - | }, | |
| 1013 | 712 | .num_links = 1, | |
| 1014 | 713 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1015 | 714 | }; | |
| @@ -1018,13 +717,6 @@ static struct qcom_icc_node xm_usb3_2 = { | |||
| 1018 | 717 | .name = "xm_usb3_2", | |
| 1019 | 718 | .channels = 1, | |
| 1020 | 719 | .buswidth = 8, | |
| 1021 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1022 | - | .num_ports = 1, | |
| 1023 | - | .port_offsets = { 0xc000 }, | |
| 1024 | - | .prio = 2, | |
| 1025 | - | .urg_fwd = 0, | |
| 1026 | - | .prio_fwd_disable = 1, | |
| 1027 | - | }, | |
| 1028 | 720 | .num_links = 1, | |
| 1029 | 721 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1030 | 722 | }; | |
| @@ -1033,13 +725,6 @@ static struct qcom_icc_node xm_usb4_0 = { | |||
| 1033 | 725 | .name = "xm_usb4_0", | |
| 1034 | 726 | .channels = 1, | |
| 1035 | 727 | .buswidth = 16, | |
| 1036 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1037 | - | .num_ports = 1, | |
| 1038 | - | .port_offsets = { 0xd000 }, | |
| 1039 | - | .prio = 2, | |
| 1040 | - | .urg_fwd = 0, | |
| 1041 | - | .prio_fwd_disable = 1, | |
| 1042 | - | }, | |
| 1043 | 728 | .num_links = 1, | |
| 1044 | 729 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1045 | 730 | }; | |
| @@ -1048,13 +733,6 @@ static struct qcom_icc_node xm_usb4_1 = { | |||
| 1048 | 733 | .name = "xm_usb4_1", | |
| 1049 | 734 | .channels = 1, | |
| 1050 | 735 | .buswidth = 16, | |
| 1051 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1052 | - | .num_ports = 1, | |
| 1053 | - | .port_offsets = { 0xe000 }, | |
| 1054 | - | .prio = 2, | |
| 1055 | - | .urg_fwd = 0, | |
| 1056 | - | .prio_fwd_disable = 1, | |
| 1057 | - | }, | |
| 1058 | 736 | .num_links = 1, | |
| 1059 | 737 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1060 | 738 | }; | |
| @@ -1063,13 +741,6 @@ static struct qcom_icc_node xm_usb4_2 = { | |||
| 1063 | 741 | .name = "xm_usb4_2", | |
| 1064 | 742 | .channels = 1, | |
| 1065 | 743 | .buswidth = 16, | |
| 1066 | - | .qosbox = &(const struct qcom_icc_qosbox) { | |
| 1067 | - | .num_ports = 1, | |
| 1068 | - | .port_offsets = { 0xf000 }, | |
| 1069 | - | .prio = 2, | |
| 1070 | - | .urg_fwd = 0, | |
| 1071 | - | .prio_fwd_disable = 1, | |
| 1072 | - | }, | |
| 1073 | 744 | .num_links = 1, | |
| 1074 | 745 | .link_nodes = { &qns_aggre_usb_south_snoc }, | |
| 1075 | 746 | }; | |
| @@ -1795,21 +1466,11 @@ static struct qcom_icc_node * const aggre1_noc_nodes[] = { | |||
| 1795 | 1466 | [SLAVE_A1NOC_SNOC] = &qns_a1noc_snoc, | |
| 1796 | 1467 | }; | |
| 1797 | 1468 | ||
| 1798 | - | static const struct regmap_config x1e80100_aggre1_noc_regmap_config = { | |
| 1799 | - | .reg_bits = 32, | |
| 1800 | - | .reg_stride = 4, | |
| 1801 | - | .val_bits = 32, | |
| 1802 | - | .max_register = 0x14400, | |
| 1803 | - | .fast_io = true, | |
| 1804 | - | }; | |
| 1805 | - | ||
| 1806 | 1469 | static const struct qcom_icc_desc x1e80100_aggre1_noc = { | |
| 1807 | - | .config = &x1e80100_aggre1_noc_regmap_config, | |
| 1808 | 1470 | .nodes = aggre1_noc_nodes, | |
| 1809 | 1471 | .num_nodes = ARRAY_SIZE(aggre1_noc_nodes), | |
| 1810 | 1472 | .bcms = aggre1_noc_bcms, | |
| 1811 | 1473 | .num_bcms = ARRAY_SIZE(aggre1_noc_bcms), | |
| 1812 | - | .qos_requires_clocks = true, | |
| 1813 | 1474 | }; | |
| 1814 | 1475 | ||
| 1815 | 1476 | static struct qcom_icc_bcm * const aggre2_noc_bcms[] = { | |
| @@ -1827,16 +1488,7 @@ static struct qcom_icc_node * const aggre2_noc_nodes[] = { | |||
| 1827 | 1488 | [SLAVE_A2NOC_SNOC] = &qns_a2noc_snoc, | |
| 1828 | 1489 | }; | |
| 1829 | 1490 | ||
| 1830 | - | static const struct regmap_config x1e80100_aggre2_noc_regmap_config = { | |
| 1831 | - | .reg_bits = 32, | |
| 1832 | - | .reg_stride = 4, | |
| 1833 | - | .val_bits = 32, | |
| 1834 | - | .max_register = 0x1c400, | |
| 1835 | - | .fast_io = true, | |
| 1836 | - | }; | |
| 1837 | - | ||
| 1838 | 1491 | static const struct qcom_icc_desc x1e80100_aggre2_noc = { | |
| 1839 | - | .config = &x1e80100_aggre2_noc_regmap_config, | |
| 1840 | 1492 | .nodes = aggre2_noc_nodes, | |
| 1841 | 1493 | .num_nodes = ARRAY_SIZE(aggre2_noc_nodes), | |
| 1842 | 1494 | .bcms = aggre2_noc_bcms, | |
| @@ -1921,16 +1573,7 @@ static struct qcom_icc_node * const cnoc_cfg_nodes[] = { | |||
| 1921 | 1573 | [SLAVE_TCU] = &xs_sys_tcu_cfg, | |
| 1922 | 1574 | }; | |
| 1923 | 1575 | ||
| 1924 | - | static const struct regmap_config x1e80100_cnoc_cfg_regmap_config = { | |
| 1925 | - | .reg_bits = 32, | |
| 1926 | - | .reg_stride = 4, | |
| 1927 | - | .val_bits = 32, | |
| 1928 | - | .max_register = 0x6600, | |
| 1929 | - | .fast_io = true, | |
| 1930 | - | }; | |
| 1931 | - | ||
| 1932 | 1576 | static const struct qcom_icc_desc x1e80100_cnoc_cfg = { | |
| 1933 | - | .config = &x1e80100_cnoc_cfg_regmap_config, | |
| 1934 | 1577 | .nodes = cnoc_cfg_nodes, | |
| 1935 | 1578 | .num_nodes = ARRAY_SIZE(cnoc_cfg_nodes), | |
| 1936 | 1579 | .bcms = cnoc_cfg_bcms, | |
| @@ -1960,16 +1603,7 @@ static struct qcom_icc_node * const cnoc_main_nodes[] = { | |||
| 1960 | 1603 | [SLAVE_PCIE_6B] = &xs_pcie_6b, | |
| 1961 | 1604 | }; | |
| 1962 | 1605 | ||
| 1963 | - | static const struct regmap_config x1e80100_cnoc_main_regmap_config = { | |
| 1964 | - | .reg_bits = 32, | |
| 1965 | - | .reg_stride = 4, | |
| 1966 | - | .val_bits = 32, | |
| 1967 | - | .max_register = 0x14400, | |
| 1968 | - | .fast_io = true, | |
| 1969 | - | }; | |
| 1970 | - | ||
| 1971 | 1606 | static const struct qcom_icc_desc x1e80100_cnoc_main = { | |
| 1972 | - | .config = &x1e80100_cnoc_main_regmap_config, | |
| 1973 | 1607 | .nodes = cnoc_main_nodes, | |
| 1974 | 1608 | .num_nodes = ARRAY_SIZE(cnoc_main_nodes), | |
| 1975 | 1609 | .bcms = cnoc_main_bcms, | |
| @@ -1999,16 +1633,7 @@ static struct qcom_icc_node * const gem_noc_nodes[] = { | |||
| 1999 | 1633 | [SLAVE_MEM_NOC_PCIE_SNOC] = &qns_pcie, | |
| 2000 | 1634 | }; | |
| 2001 | 1635 | ||
| 2002 | - | static const struct regmap_config x1e80100_gem_noc_regmap_config = { | |
| 2003 | - | .reg_bits = 32, | |
| 2004 | - | .reg_stride = 4, | |
| 2005 | - | .val_bits = 32, | |
| 2006 | - | .max_register = 0x311200, | |
| 2007 | - | .fast_io = true, | |
| 2008 | - | }; | |
| 2009 | - | ||
| 2010 | 1636 | static const struct qcom_icc_desc x1e80100_gem_noc = { | |
| 2011 | - | .config = &x1e80100_gem_noc_regmap_config, | |
| 2012 | 1637 | .nodes = gem_noc_nodes, | |
| 2013 | 1638 | .num_nodes = ARRAY_SIZE(gem_noc_nodes), | |
| 2014 | 1639 | .bcms = gem_noc_bcms, | |
| @@ -2023,16 +1648,7 @@ static struct qcom_icc_node * const lpass_ag_noc_nodes[] = { | |||
| 2023 | 1648 | [SLAVE_LPASS_GEM_NOC] = &qns_lpass_ag_noc_gemnoc, | |
| 2024 | 1649 | }; | |
| 2025 | 1650 | ||
| 2026 | - | static const struct regmap_config x1e80100_lpass_ag_noc_regmap_config = { | |
| 2027 | - | .reg_bits = 32, | |
| 2028 | - | .reg_stride = 4, | |
| 2029 | - | .val_bits = 32, | |
| 2030 | - | .max_register = 0xe080, | |
| 2031 | - | .fast_io = true, | |
| 2032 | - | }; | |
| 2033 | - | ||
| 2034 | 1651 | static const struct qcom_icc_desc x1e80100_lpass_ag_noc = { | |
| 2035 | - | .config = &x1e80100_lpass_ag_noc_regmap_config, | |
| 2036 | 1652 | .nodes = lpass_ag_noc_nodes, | |
| 2037 | 1653 | .num_nodes = ARRAY_SIZE(lpass_ag_noc_nodes), | |
| 2038 | 1654 | .bcms = lpass_ag_noc_bcms, | |
| @@ -2048,16 +1664,7 @@ static struct qcom_icc_node * const lpass_lpiaon_noc_nodes[] = { | |||
| 2048 | 1664 | [SLAVE_LPIAON_NOC_LPASS_AG_NOC] = &qns_lpass_aggnoc, | |
| 2049 | 1665 | }; | |
| 2050 | 1666 | ||
| 2051 | - | static const struct regmap_config x1e80100_lpass_lpiaon_noc_regmap_config = { | |
| 2052 | - | .reg_bits = 32, | |
| 2053 | - | .reg_stride = 4, | |
| 2054 | - | .val_bits = 32, | |
| 2055 | - | .max_register = 0x19080, | |
| 2056 | - | .fast_io = true, | |
| 2057 | - | }; | |
| 2058 | - | ||
| 2059 | 1667 | static const struct qcom_icc_desc x1e80100_lpass_lpiaon_noc = { | |
| 2060 | - | .config = &x1e80100_lpass_lpiaon_noc_regmap_config, | |
| 2061 | 1668 | .nodes = lpass_lpiaon_noc_nodes, | |
| 2062 | 1669 | .num_nodes = ARRAY_SIZE(lpass_lpiaon_noc_nodes), | |
| 2063 | 1670 | .bcms = lpass_lpiaon_noc_bcms, | |
| @@ -2072,16 +1679,7 @@ static struct qcom_icc_node * const lpass_lpicx_noc_nodes[] = { | |||
| 2072 | 1679 | [SLAVE_LPICX_NOC_LPIAON_NOC] = &qns_lpi_aon_noc, | |
| 2073 | 1680 | }; | |
| 2074 | 1681 | ||
| 2075 | - | static const struct regmap_config x1e80100_lpass_lpicx_noc_regmap_config = { | |
| 2076 | - | .reg_bits = 32, | |
| 2077 | - | .reg_stride = 4, | |
| 2078 | - | .val_bits = 32, | |
| 2079 | - | .max_register = 0x3a200, | |
| 2080 | - | .fast_io = true, | |
| 2081 | - | }; | |
| 2082 | - | ||
| 2083 | 1682 | static const struct qcom_icc_desc x1e80100_lpass_lpicx_noc = { | |
| 2084 | - | .config = &x1e80100_lpass_lpicx_noc_regmap_config, | |
| 2085 | 1683 | .nodes = lpass_lpicx_noc_nodes, | |
| 2086 | 1684 | .num_nodes = ARRAY_SIZE(lpass_lpicx_noc_nodes), | |
| 2087 | 1685 | .bcms = lpass_lpicx_noc_bcms, | |
| @@ -2126,16 +1724,7 @@ static struct qcom_icc_node * const mmss_noc_nodes[] = { | |||
| 2126 | 1724 | [SLAVE_SERVICE_MNOC] = &srvc_mnoc, | |
| 2127 | 1725 | }; | |
| 2128 | 1726 | ||
| 2129 | - | static const struct regmap_config x1e80100_mmss_noc_regmap_config = { | |
| 2130 | - | .reg_bits = 32, | |
| 2131 | - | .reg_stride = 4, | |
| 2132 | - | .val_bits = 32, | |
| 2133 | - | .max_register = 0x5b800, | |
| 2134 | - | .fast_io = true, | |
| 2135 | - | }; | |
| 2136 | - | ||
| 2137 | 1727 | static const struct qcom_icc_desc x1e80100_mmss_noc = { | |
| 2138 | - | .config = &x1e80100_mmss_noc_regmap_config, | |
| 2139 | 1728 | .nodes = mmss_noc_nodes, | |
| 2140 | 1729 | .num_nodes = ARRAY_SIZE(mmss_noc_nodes), | |
| 2141 | 1730 | .bcms = mmss_noc_bcms, | |
| @@ -2151,16 +1740,7 @@ static struct qcom_icc_node * const nsp_noc_nodes[] = { | |||
| 2151 | 1740 | [SLAVE_CDSP_MEM_NOC] = &qns_nsp_gemnoc, | |
| 2152 | 1741 | }; | |
| 2153 | 1742 | ||
| 2154 | - | static const struct regmap_config x1e80100_nsp_noc_regmap_config = { | |
| 2155 | - | .reg_bits = 32, | |
| 2156 | - | .reg_stride = 4, | |
| 2157 | - | .val_bits = 32, | |
| 2158 | - | .max_register = 0xe080, | |
| 2159 | - | .fast_io = true, | |
| 2160 | - | }; | |
| 2161 | - | ||
| 2162 | 1743 | static const struct qcom_icc_desc x1e80100_nsp_noc = { | |
| 2163 | - | .config = &x1e80100_nsp_noc_regmap_config, | |
| 2164 | 1744 | .nodes = nsp_noc_nodes, | |
| 2165 | 1745 | .num_nodes = ARRAY_SIZE(nsp_noc_nodes), | |
| 2166 | 1746 | .bcms = nsp_noc_bcms, | |
| @@ -2177,16 +1757,7 @@ static struct qcom_icc_node * const pcie_center_anoc_nodes[] = { | |||
| 2177 | 1757 | [SLAVE_ANOC_PCIE_GEM_NOC] = &qns_pcie_mem_noc, | |
| 2178 | 1758 | }; | |
| 2179 | 1759 | ||
| 2180 | - | static const struct regmap_config x1e80100_pcie_center_anoc_regmap_config = { | |
| 2181 | - | .reg_bits = 32, | |
| 2182 | - | .reg_stride = 4, | |
| 2183 | - | .val_bits = 32, | |
| 2184 | - | .max_register = 0x7000, | |
| 2185 | - | .fast_io = true, | |
| 2186 | - | }; | |
| 2187 | - | ||
| 2188 | 1760 | static const struct qcom_icc_desc x1e80100_pcie_center_anoc = { | |
| 2189 | - | .config = &x1e80100_pcie_center_anoc_regmap_config, | |
| 2190 | 1761 | .nodes = pcie_center_anoc_nodes, | |
| 2191 | 1762 | .num_nodes = ARRAY_SIZE(pcie_center_anoc_nodes), | |
| 2192 | 1763 | .bcms = pcie_center_anoc_bcms, | |
| @@ -2203,16 +1774,7 @@ static struct qcom_icc_node * const pcie_north_anoc_nodes[] = { | |||
| 2203 | 1774 | [SLAVE_PCIE_NORTH] = &qns_pcie_north_gem_noc, | |
| 2204 | 1775 | }; | |
| 2205 | 1776 | ||
| 2206 | - | static const struct regmap_config x1e80100_pcie_north_anoc_regmap_config = { | |
| 2207 | - | .reg_bits = 32, | |
| 2208 | - | .reg_stride = 4, | |
| 2209 | - | .val_bits = 32, | |
| 2210 | - | .max_register = 0x9080, | |
| 2211 | - | .fast_io = true, | |
| 2212 | - | }; | |
| 2213 | - | ||
| 2214 | 1777 | static const struct qcom_icc_desc x1e80100_pcie_north_anoc = { | |
| 2215 | - | .config = &x1e80100_pcie_north_anoc_regmap_config, | |
| 2216 | 1778 | .nodes = pcie_north_anoc_nodes, | |
| 2217 | 1779 | .num_nodes = ARRAY_SIZE(pcie_north_anoc_nodes), | |
| 2218 | 1780 | .bcms = pcie_north_anoc_bcms, | |
| @@ -2231,16 +1793,7 @@ static struct qcom_icc_node * const pcie_south_anoc_nodes[] = { | |||
| 2231 | 1793 | [SLAVE_PCIE_SOUTH] = &qns_pcie_south_gem_noc, | |
| 2232 | 1794 | }; | |
| 2233 | 1795 | ||
| 2234 | - | static const struct regmap_config x1e80100_pcie_south_anoc_regmap_config = { | |
| 2235 | - | .reg_bits = 32, | |
| 2236 | - | .reg_stride = 4, | |
| 2237 | - | .val_bits = 32, | |
| 2238 | - | .max_register = 0xd080, | |
| 2239 | - | .fast_io = true, | |
| 2240 | - | }; | |
| 2241 | - | ||
| 2242 | 1796 | static const struct qcom_icc_desc x1e80100_pcie_south_anoc = { | |
| 2243 | - | .config = &x1e80100_pcie_south_anoc_regmap_config, | |
| 2244 | 1797 | .nodes = pcie_south_anoc_nodes, | |
| 2245 | 1798 | .num_nodes = ARRAY_SIZE(pcie_south_anoc_nodes), | |
| 2246 | 1799 | .bcms = pcie_south_anoc_bcms, | |
| @@ -2262,16 +1815,7 @@ static struct qcom_icc_node * const system_noc_nodes[] = { | |||
| 2262 | 1815 | [SLAVE_SNOC_GEM_NOC_SF] = &qns_gemnoc_sf, | |
| 2263 | 1816 | }; | |
| 2264 | 1817 | ||
| 2265 | - | static const struct regmap_config x1e80100_system_noc_regmap_config = { | |
| 2266 | - | .reg_bits = 32, | |
| 2267 | - | .reg_stride = 4, | |
| 2268 | - | .val_bits = 32, | |
| 2269 | - | .max_register = 0x1c080, | |
| 2270 | - | .fast_io = true, | |
| 2271 | - | }; | |
| 2272 | - | ||
| 2273 | 1818 | static const struct qcom_icc_desc x1e80100_system_noc = { | |
| 2274 | - | .config = &x1e80100_system_noc_regmap_config, | |
| 2275 | 1819 | .nodes = system_noc_nodes, | |
| 2276 | 1820 | .num_nodes = ARRAY_SIZE(system_noc_nodes), | |
| 2277 | 1821 | .bcms = system_noc_bcms, | |
| @@ -2287,16 +1831,7 @@ static struct qcom_icc_node * const usb_center_anoc_nodes[] = { | |||
| 2287 | 1831 | [SLAVE_USB_NOC_SNOC] = &qns_aggre_usb_snoc, | |
| 2288 | 1832 | }; | |
| 2289 | 1833 | ||
| 2290 | - | static const struct regmap_config x1e80100_usb_center_anoc_regmap_config = { | |
| 2291 | - | .reg_bits = 32, | |
| 2292 | - | .reg_stride = 4, | |
| 2293 | - | .val_bits = 32, | |
| 2294 | - | .max_register = 0x8800, | |
| 2295 | - | .fast_io = true, | |
| 2296 | - | }; | |
| 2297 | - | ||
| 2298 | 1834 | static const struct qcom_icc_desc x1e80100_usb_center_anoc = { | |
| 2299 | - | .config = &x1e80100_usb_center_anoc_regmap_config, | |
| 2300 | 1835 | .nodes = usb_center_anoc_nodes, | |
| 2301 | 1836 | .num_nodes = ARRAY_SIZE(usb_center_anoc_nodes), | |
| 2302 | 1837 | .bcms = usb_center_anoc_bcms, | |
| @@ -2312,21 +1847,11 @@ static struct qcom_icc_node * const usb_north_anoc_nodes[] = { | |||
| 2312 | 1847 | [SLAVE_AGGRE_USB_NORTH] = &qns_aggre_usb_north_snoc, | |
| 2313 | 1848 | }; | |
| 2314 | 1849 | ||
| 2315 | - | static const struct regmap_config x1e80100_usb_north_anoc_regmap_config = { | |
| 2316 | - | .reg_bits = 32, | |
| 2317 | - | .reg_stride = 4, | |
| 2318 | - | .val_bits = 32, | |
| 2319 | - | .max_register = 0x7080, | |
| 2320 | - | .fast_io = true, | |
| 2321 | - | }; | |
| 2322 | - | ||
| 2323 | 1850 | static const struct qcom_icc_desc x1e80100_usb_north_anoc = { | |
| 2324 | - | .config = &x1e80100_usb_north_anoc_regmap_config, | |
| 2325 | 1851 | .nodes = usb_north_anoc_nodes, | |
| 2326 | 1852 | .num_nodes = ARRAY_SIZE(usb_north_anoc_nodes), | |
| 2327 | 1853 | .bcms = usb_north_anoc_bcms, | |
| 2328 | 1854 | .num_bcms = ARRAY_SIZE(usb_north_anoc_bcms), | |
| 2329 | - | .qos_requires_clocks = true, | |
| 2330 | 1855 | }; | |
| 2331 | 1856 | ||
| 2332 | 1857 | static struct qcom_icc_bcm * const usb_south_anoc_bcms[] = { | |
| @@ -2342,21 +1867,11 @@ static struct qcom_icc_node * const usb_south_anoc_nodes[] = { | |||
| 2342 | 1867 | [SLAVE_AGGRE_USB_SOUTH] = &qns_aggre_usb_south_snoc, | |
| 2343 | 1868 | }; | |
| 2344 | 1869 | ||
| 2345 | - | static const struct regmap_config x1e80100_usb_south_anoc_regmap_config = { | |
| 2346 | - | .reg_bits = 32, | |
| 2347 | - | .reg_stride = 4, | |
| 2348 | - | .val_bits = 32, | |
| 2349 | - | .max_register = 0xf080, | |
| 2350 | - | .fast_io = true, | |
| 2351 | - | }; | |
| 2352 | - | ||
| 2353 | 1870 | static const struct qcom_icc_desc x1e80100_usb_south_anoc = { | |
| 2354 | - | .config = &x1e80100_usb_south_anoc_regmap_config, | |
| 2355 | 1871 | .nodes = usb_south_anoc_nodes, | |
| 2356 | 1872 | .num_nodes = ARRAY_SIZE(usb_south_anoc_nodes), | |
| 2357 | 1873 | .bcms = usb_south_anoc_bcms, | |
| 2358 | 1874 | .num_bcms = ARRAY_SIZE(usb_south_anoc_bcms), | |
| 2359 | - | .qos_requires_clocks = true, | |
| 2360 | 1875 | }; | |
| 2361 | 1876 | ||
| 2362 | 1877 | static const struct of_device_id qnoc_of_match[] = { | |
modified drivers/iommu/dma-iommu.c
| @@ -1228,9 +1228,9 @@ dma_addr_t iommu_dma_map_phys(struct device *dev, phys_addr_t phys, size_t size, | |||
| 1228 | 1228 | * If both the physical buffer start address and size are page aligned, | |
| 1229 | 1229 | * we don't need to use a bounce page. | |
| 1230 | 1230 | */ | |
| 1231 | - | if (dev_use_swiotlb(dev, size, dir) && | |
| 1231 | + | if (!(attrs & DMA_ATTR_MMIO) && dev_use_swiotlb(dev, size, dir) && | |
| 1232 | 1232 | iova_unaligned(iovad, phys, size)) { | |
| 1233 | - | if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT)) | |
| 1233 | + | if (attrs & DMA_ATTR_REQUIRE_COHERENT) | |
| 1234 | 1234 | return DMA_MAPPING_ERROR; | |
| 1235 | 1235 | ||
| 1236 | 1236 | phys = iommu_dma_map_swiotlb(dev, phys, size, dir, attrs); | |
modified drivers/md/dm-crypt.c
| @@ -2894,8 +2894,13 @@ static int crypt_ctr_cipher_new(struct dm_target *ti, char *cipher_in, char *key | |||
| 2894 | 2894 | } | |
| 2895 | 2895 | } | |
| 2896 | 2896 | ||
| 2897 | - | if (*ivmode && !strcmp(*ivmode, "lmk")) | |
| 2897 | + | if (*ivmode && !strcmp(*ivmode, "lmk")) { | |
| 2898 | + | if (crypt_integrity_aead(cc)) { | |
| 2899 | + | ti->error = "AEAD transforms not supported for LMK"; | |
| 2900 | + | return -EINVAL; | |
| 2901 | + | } | |
| 2898 | 2902 | cc->tfms_count = 64; | |
| 2903 | + | } | |
| 2899 | 2904 | ||
| 2900 | 2905 | if (*ivmode && !strcmp(*ivmode, "essiv")) { | |
| 2901 | 2906 | if (!*ivopts) { | |
modified drivers/md/dm-integrity.c
| @@ -180,6 +180,7 @@ struct dm_integrity_c { | |||
| 180 | 180 | struct dm_bufio_client *bufio; | |
| 181 | 181 | struct workqueue_struct *metadata_wq; | |
| 182 | 182 | struct superblock *sb; | |
| 183 | + | struct superblock *sb_copy; | |
| 183 | 184 | unsigned int journal_pages; | |
| 184 | 185 | unsigned int n_bitmap_blocks; | |
| 185 | 186 | ||
| @@ -2721,7 +2722,7 @@ static void dm_integrity_inline_recheck(struct work_struct *w) | |||
| 2721 | 2722 | outgoing_data = dio->integrity_payload + PAGE_SIZE; | |
| 2722 | 2723 | ||
| 2723 | 2724 | while (dio->bio_details.bi_iter.bi_size) { | |
| 2724 | - | char digest[HASH_MAX_DIGESTSIZE]; | |
| 2725 | + | char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; | |
| 2725 | 2726 | int r; | |
| 2726 | 2727 | struct bio_integrity_payload *bip; | |
| 2727 | 2728 | struct bio_vec bv; | |
| @@ -2788,7 +2789,7 @@ static inline bool dm_integrity_check(struct dm_integrity_c *ic, struct dm_integ | |||
| 2788 | 2789 | unsigned pos = 0; | |
| 2789 | 2790 | ||
| 2790 | 2791 | while (dio->bio_details.bi_iter.bi_size) { | |
| 2791 | - | char digest[HASH_MAX_DIGESTSIZE]; | |
| 2792 | + | char digest[MAX_T(size_t, HASH_MAX_DIGESTSIZE, MAX_TAG_SIZE)]; | |
| 2792 | 2793 | struct bio_vec bv = bio_iter_iovec(bio, dio->bio_details.bi_iter); | |
| 2793 | 2794 | char *mem = integrity_kmap(ic, bv.bv_page); | |
| 2794 | 2795 | integrity_sector_checksum(ic, &dio->ahash_req, dio->bio_details.bi_iter.bi_sector, mem, bv.bv_offset, digest); | |
| @@ -3858,6 +3859,35 @@ static void dm_integrity_postsuspend(struct dm_target *ti) | |||
| 3858 | 3859 | ic->journal_uptodate = true; | |
| 3859 | 3860 | } | |
| 3860 | 3861 | ||
| 3862 | + | /* | |
| 3863 | + | * The superblock is re-read from the device on every resume, so that we pick | |
| 3864 | + | * up the flags and the recalculate position. The geometry described by the | |
| 3865 | + | * superblock must not change though - the in-memory structures (and the | |
| 3866 | + | * journal in particular) were sized according to the superblock that was | |
| 3867 | + | * validated in the constructor. Reject a superblock that was modified behind | |
| 3868 | + | * our back. | |
| 3869 | + | * | |
| 3870 | + | * Only the fields that the driver never rewrites may be tested here. In | |
| 3871 | + | * particular, "version" is recalculated by sb_set_version on every superblock | |
| 3872 | + | * write and it depends on SB_FLAG_RECALCULATING and SB_FLAG_DIRTY_BITMAP, and | |
| 3873 | + | * SB_FLAG_DISCARD_KEYED may be set by dm_integrity_resume itself. | |
| 3874 | + | */ | |
| 3875 | + | static bool superblock_changed(struct dm_integrity_c *ic) | |
| 3876 | + | { | |
| 3877 | + | const __le32 immutable_flags = cpu_to_le32(SB_FLAG_HAVE_JOURNAL_MAC | | |
| 3878 | + | SB_FLAG_FIXED_PADDING | | |
| 3879 | + | SB_FLAG_FIXED_HMAC | | |
| 3880 | + | SB_FLAG_INLINE); | |
| 3881 | + | ||
| 3882 | + | return memcmp(ic->sb->magic, ic->sb_copy->magic, sizeof(ic->sb->magic)) != 0 || | |
| 3883 | + | ic->sb->log2_interleave_sectors != ic->sb_copy->log2_interleave_sectors || | |
| 3884 | + | ic->sb->integrity_tag_size != ic->sb_copy->integrity_tag_size || | |
| 3885 | + | ic->sb->journal_sections != ic->sb_copy->journal_sections || | |
| 3886 | + | ic->sb->log2_sectors_per_block != ic->sb_copy->log2_sectors_per_block || | |
| 3887 | + | ((ic->sb->flags ^ ic->sb_copy->flags) & immutable_flags) != 0 || | |
| 3888 | + | memcmp(ic->sb->salt, ic->sb_copy->salt, SALT_SIZE) != 0; | |
| 3889 | + | } | |
| 3890 | + | ||
| 3861 | 3891 | static void dm_integrity_resume(struct dm_target *ti) | |
| 3862 | 3892 | { | |
| 3863 | 3893 | struct dm_integrity_c *ic = ti->private; | |
| @@ -3876,6 +3906,18 @@ static void dm_integrity_resume(struct dm_target *ti) | |||
| 3876 | 3906 | if (r) | |
| 3877 | 3907 | dm_integrity_io_error(ic, "reading superblock", r); | |
| 3878 | 3908 | ||
| 3909 | + | if (unlikely(superblock_changed(ic))) { | |
| 3910 | + | /* | |
| 3911 | + | * Restore the superblock that we validated in the constructor, | |
| 3912 | + | * so that the rest of the driver doesn't operate on values | |
| 3913 | + | * that don't match the in-memory structures. | |
| 3914 | + | */ | |
| 3915 | + | memcpy(ic->sb, ic->sb_copy, sizeof(struct superblock)); | |
| 3916 | + | DMERR("The superblock was changed while the device was suspended"); | |
| 3917 | + | dm_integrity_io_error(ic, "superblock check", -EINVAL); | |
| 3918 | + | goto skip_writes; | |
| 3919 | + | } | |
| 3920 | + | ||
| 3879 | 3921 | if (ic->mode == 'R') | |
| 3880 | 3922 | goto skip_writes; | |
| 3881 | 3923 | ||
| @@ -5427,6 +5469,13 @@ try_smaller_buffer: | |||
| 5427 | 5469 | ic->just_formatted = true; | |
| 5428 | 5470 | } | |
| 5429 | 5471 | ||
| 5472 | + | ic->sb_copy = kmemdup(ic->sb, sizeof(struct superblock), GFP_KERNEL); | |
| 5473 | + | if (!ic->sb_copy) { | |
| 5474 | + | ti->error = "Cannot allocate superblock copy"; | |
| 5475 | + | r = -ENOMEM; | |
| 5476 | + | goto bad; | |
| 5477 | + | } | |
| 5478 | + | ||
| 5430 | 5479 | if (!ic->meta_dev && ic->mode != 'I') { | |
| 5431 | 5480 | r = dm_set_target_max_io_len(ti, 1U << ic->sb->log2_interleave_sectors); | |
| 5432 | 5481 | if (r) | |
| @@ -5525,6 +5574,7 @@ static void dm_integrity_dtr(struct dm_target *ti) | |||
| 5525 | 5574 | kvfree(ic->journal_tree); | |
| 5526 | 5575 | if (ic->sb) | |
| 5527 | 5576 | free_pages_exact(ic->sb, SB_SECTORS << SECTOR_SHIFT); | |
| 5577 | + | kfree(ic->sb_copy); | |
| 5528 | 5578 | ||
| 5529 | 5579 | if (ic->internal_shash) | |
| 5530 | 5580 | crypto_free_shash(ic->internal_shash); | |
modified drivers/md/dm-ioctl.c
| @@ -656,10 +656,16 @@ static void *get_result_buffer(struct dm_ioctl *param, size_t param_size, | |||
| 656 | 656 | { | |
| 657 | 657 | param->data_start = align_ptr(param + 1) - (void *) param; | |
| 658 | 658 | ||
| 659 | - | if (param->data_start < param_size) | |
| 659 | + | if (param->data_start < param_size) { | |
| 660 | 660 | *len = param_size - param->data_start; | |
| 661 | - | else | |
| 661 | + | } else { | |
| 662 | + | /* | |
| 663 | + | * The buffer can be as small as offsetof(*param, data), which | |
| 664 | + | * is less than sizeof(*param), so don't run off the end of it. | |
| 665 | + | */ | |
| 662 | 666 | *len = 0; | |
| 667 | + | param->data_start = param_size; | |
| 668 | + | } | |
| 663 | 669 | ||
| 664 | 670 | return ((void *) param) + param->data_start; | |
| 665 | 671 | } | |
| @@ -1267,6 +1273,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1267 | 1273 | /* Do we need to load a new map ? */ | |
| 1268 | 1274 | if (new_map) { | |
| 1269 | 1275 | sector_t old_size, new_size; | |
| 1276 | + | blk_mode_t new_map_mode; | |
| 1270 | 1277 | ||
| 1271 | 1278 | dm_ima_context_table_op(md, ima_context, DM_IMA_TABLE_SAVE); | |
| 1272 | 1279 | /* Suspend if it isn't already suspended */ | |
| @@ -1299,6 +1306,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1299 | 1306 | } | |
| 1300 | 1307 | } | |
| 1301 | 1308 | ||
| 1309 | + | new_map_mode = dm_table_get_mode(new_map); | |
| 1302 | 1310 | old_size = dm_get_size(md); | |
| 1303 | 1311 | old_map = dm_swap_table(md, new_map); | |
| 1304 | 1312 | if (IS_ERR(old_map)) { | |
| @@ -1314,7 +1322,7 @@ static int do_resume(struct dm_ioctl *param) | |||
| 1314 | 1322 | if (old_size && new_size && old_size != new_size) | |
| 1315 | 1323 | need_resize_uevent = true; | |
| 1316 | 1324 | ||
| 1317 | - | if (dm_table_get_mode(new_map) & BLK_OPEN_WRITE) | |
| 1325 | + | if (new_map_mode & BLK_OPEN_WRITE) | |
| 1318 | 1326 | set_disk_ro(dm_disk(md), 0); | |
| 1319 | 1327 | else | |
| 1320 | 1328 | set_disk_ro(dm_disk(md), 1); | |
modified drivers/md/dm-snap.c
| @@ -1292,6 +1292,20 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
| 1292 | 1292 | goto bad_store; | |
| 1293 | 1293 | } | |
| 1294 | 1294 | ||
| 1295 | + | /* | |
| 1296 | + | * snapshot-merge requires the optional prepare_merge/commit_merge | |
| 1297 | + | * callbacks; the transient exception store does not implement them. | |
| 1298 | + | * The handover path checks this in __validate_exception_handover(), | |
| 1299 | + | * but a directly constructed snapshot-merge never goes through it. | |
| 1300 | + | */ | |
| 1301 | + | if (dm_target_is_snapshot_merge(ti) && | |
| 1302 | + | (!s->store->type->prepare_merge || | |
| 1303 | + | !s->store->type->commit_merge)) { | |
| 1304 | + | ti->error = "Snapshot exception store does not support snapshot-merge."; | |
| 1305 | + | r = -EINVAL; | |
| 1306 | + | goto bad_hash_tables; | |
| 1307 | + | } | |
| 1308 | + | ||
| 1295 | 1309 | argv += args_used; | |
| 1296 | 1310 | argc -= args_used; | |
| 1297 | 1311 | ||
modified drivers/media/usb/em28xx/em28xx-video.c
| @@ -2416,7 +2416,7 @@ static int em28xx_v4l2_fini(struct em28xx *dev) | |||
| 2416 | 2416 | if (video_is_registered(&v4l2->radio_dev)) { | |
| 2417 | 2417 | dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", | |
| 2418 | 2418 | video_device_node_name(&v4l2->radio_dev)); | |
| 2419 | - | vb2_video_unregister_device(&v4l2->radio_dev); | |
| 2419 | + | video_unregister_device(&v4l2->radio_dev); | |
| 2420 | 2420 | } | |
| 2421 | 2421 | if (video_is_registered(&v4l2->vbi_dev)) { | |
| 2422 | 2422 | dev_info(&dev->intf->dev, "V4L2 device %s deregistered\n", | |
| @@ -3082,7 +3082,7 @@ unregister_dev: | |||
| 3082 | 3082 | dev_info(&dev->intf->dev, | |
| 3083 | 3083 | "V4L2 device %s deregistered\n", | |
| 3084 | 3084 | video_device_node_name(&v4l2->radio_dev)); | |
| 3085 | - | vb2_video_unregister_device(&v4l2->radio_dev); | |
| 3085 | + | video_unregister_device(&v4l2->radio_dev); | |
| 3086 | 3086 | } | |
| 3087 | 3087 | if (video_is_registered(&v4l2->vbi_dev)) { | |
| 3088 | 3088 | dev_info(&dev->intf->dev, | |
modified drivers/memstick/core/memstick.c
| @@ -370,9 +370,7 @@ int memstick_set_rw_addr(struct memstick_dev *card) | |||
| 370 | 370 | { | |
| 371 | 371 | card->next_request = h_memstick_set_rw_addr; | |
| 372 | 372 | memstick_new_req(card->host); | |
| 373 | - | if (!wait_for_completion_timeout(&card->mrq_complete, | |
| 374 | - | msecs_to_jiffies(500))) | |
| 375 | - | card->current_mrq.error = -ETIMEDOUT; | |
| 373 | + | wait_for_completion(&card->mrq_complete); | |
| 376 | 374 | ||
| 377 | 375 | return card->current_mrq.error; | |
| 378 | 376 | } | |
| @@ -405,9 +403,7 @@ static struct memstick_dev *memstick_alloc_card(struct memstick_host *host) | |||
| 405 | 403 | ||
| 406 | 404 | card->next_request = h_memstick_read_dev_id; | |
| 407 | 405 | memstick_new_req(host); | |
| 408 | - | if (!wait_for_completion_timeout(&card->mrq_complete, | |
| 409 | - | msecs_to_jiffies(500))) | |
| 410 | - | card->current_mrq.error = -ETIMEDOUT; | |
| 406 | + | wait_for_completion(&card->mrq_complete); | |
| 411 | 407 | ||
| 412 | 408 | if (card->current_mrq.error) | |
| 413 | 409 | goto err_out; | |
modified drivers/memstick/core/ms_block.c
| @@ -2204,6 +2204,8 @@ static void msb_remove(struct memstick_dev *card) | |||
| 2204 | 2204 | msb_data_clear(msb); | |
| 2205 | 2205 | mutex_unlock(&msb_disk_lock); | |
| 2206 | 2206 | ||
| 2207 | + | destroy_workqueue(msb->io_queue); | |
| 2208 | + | ||
| 2207 | 2209 | put_disk(msb->disk); | |
| 2208 | 2210 | memstick_set_drvdata(card, NULL); | |
| 2209 | 2211 | } | |
modified drivers/memstick/host/rtsx_usb_ms.c
| @@ -27,7 +27,6 @@ struct rtsx_usb_ms { | |||
| 27 | 27 | struct memstick_host *msh; | |
| 28 | 28 | struct memstick_request *req; | |
| 29 | 29 | ||
| 30 | - | struct mutex host_mutex; | |
| 31 | 30 | struct work_struct handle_req; | |
| 32 | 31 | struct delayed_work poll_card; | |
| 33 | 32 | ||
| @@ -514,6 +513,13 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work) | |||
| 514 | 513 | struct memstick_host *msh = host->msh; | |
| 515 | 514 | int rc; | |
| 516 | 515 | ||
| 516 | + | /* Fail requests after eject so their waiters are released. */ | |
| 517 | + | if (host->eject) { | |
| 518 | + | while (!memstick_next_req(msh, &host->req)) | |
| 519 | + | host->req->error = -ENOMEDIUM; | |
| 520 | + | return; | |
| 521 | + | } | |
| 522 | + | ||
| 517 | 523 | if (!host->req) { | |
| 518 | 524 | pm_runtime_get_sync(ms_dev(host)); | |
| 519 | 525 | do { | |
| @@ -547,8 +553,7 @@ static void rtsx_usb_ms_request(struct memstick_host *msh) | |||
| 547 | 553 | ||
| 548 | 554 | dev_dbg(ms_dev(host), "--> %s\n", __func__); | |
| 549 | 555 | ||
| 550 | - | if (!host->eject) | |
| 551 | - | schedule_work(&host->handle_req); | |
| 556 | + | schedule_work(&host->handle_req); | |
| 552 | 557 | } | |
| 553 | 558 | ||
| 554 | 559 | static int rtsx_usb_ms_set_param(struct memstick_host *msh, | |
| @@ -781,7 +786,6 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev) | |||
| 781 | 786 | host->power_mode = MEMSTICK_POWER_OFF; | |
| 782 | 787 | platform_set_drvdata(pdev, host); | |
| 783 | 788 | ||
| 784 | - | mutex_init(&host->host_mutex); | |
| 785 | 789 | INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req); | |
| 786 | 790 | ||
| 787 | 791 | INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card); | |
| @@ -812,27 +816,12 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev) | |||
| 812 | 816 | { | |
| 813 | 817 | struct rtsx_usb_ms *host = platform_get_drvdata(pdev); | |
| 814 | 818 | struct memstick_host *msh = host->msh; | |
| 815 | - | int err; | |
| 816 | 819 | ||
| 817 | 820 | host->eject = true; | |
| 818 | 821 | msh->removing = true; | |
| 819 | - | cancel_work_sync(&host->handle_req); | |
| 822 | + | flush_work(&host->handle_req); | |
| 820 | 823 | cancel_delayed_work_sync(&host->poll_card); | |
| 821 | 824 | ||
| 822 | - | mutex_lock(&host->host_mutex); | |
| 823 | - | if (host->req) { | |
| 824 | - | dev_dbg(ms_dev(host), | |
| 825 | - | "%s: Controller removed during transfer\n", | |
| 826 | - | dev_name(&msh->dev)); | |
| 827 | - | host->req->error = -ENOMEDIUM; | |
| 828 | - | do { | |
| 829 | - | err = memstick_next_req(msh, &host->req); | |
| 830 | - | if (!err) | |
| 831 | - | host->req->error = -ENOMEDIUM; | |
| 832 | - | } while (!err); | |
| 833 | - | } | |
| 834 | - | mutex_unlock(&host->host_mutex); | |
| 835 | - | ||
| 836 | 825 | /* Balance possible unbalanced usage count | |
| 837 | 826 | * e.g. unconditional module removal | |
| 838 | 827 | */ | |
| @@ -841,6 +830,8 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev) | |||
| 841 | 830 | ||
| 842 | 831 | pm_runtime_disable(ms_dev(host)); | |
| 843 | 832 | memstick_remove_host(msh); | |
| 833 | + | /* No card, no new requests; wait for the last failed one to finish. */ | |
| 834 | + | cancel_work_sync(&host->handle_req); | |
| 844 | 835 | dev_dbg(ms_dev(host), | |
| 845 | 836 | ": Realtek USB Memstick controller has been removed\n"); | |
| 846 | 837 | memstick_free_host(msh); | |
modified drivers/mmc/core/bus.c
| @@ -417,8 +417,8 @@ void mmc_remove_card(struct mmc_card *card) | |||
| 417 | 417 | mmc_hostname(card->host), card->rca); | |
| 418 | 418 | } | |
| 419 | 419 | device_del(&card->dev); | |
| 420 | - | of_node_put(card->dev.of_node); | |
| 421 | 420 | } | |
| 421 | + | of_node_put(card->dev.of_node); | |
| 422 | 422 | ||
| 423 | 423 | if (host->cqe_enabled) { | |
| 424 | 424 | host->cqe_ops->cqe_disable(host); | |
modified drivers/mmc/core/host.c
| @@ -698,6 +698,7 @@ EXPORT_SYMBOL(mmc_remove_host); | |||
| 698 | 698 | void mmc_free_host(struct mmc_host *host) | |
| 699 | 699 | { | |
| 700 | 700 | cancel_delayed_work_sync(&host->detect); | |
| 701 | + | cancel_work_sync(&host->sdio_irq_work); | |
| 701 | 702 | mmc_pwrseq_free(host); | |
| 702 | 703 | put_device(&host->class_dev); | |
| 703 | 704 | } | |
modified drivers/mmc/core/sdio_uart.c
| @@ -104,6 +104,9 @@ static int sdio_uart_add_port(struct sdio_uart_port *port) | |||
| 104 | 104 | } | |
| 105 | 105 | spin_unlock(&sdio_uart_table_lock); | |
| 106 | 106 | ||
| 107 | + | if (ret) | |
| 108 | + | kfifo_free(&port->xmit_fifo); | |
| 109 | + | ||
| 107 | 110 | return ret; | |
| 108 | 111 | } | |
| 109 | 112 | ||
modified drivers/mmc/host/cavium-octeon.c
| @@ -295,9 +295,12 @@ static void octeon_mmc_remove(struct platform_device *pdev) | |||
| 295 | 295 | u64 dma_cfg; | |
| 296 | 296 | int i; | |
| 297 | 297 | ||
| 298 | - | for (i = 0; i < CAVIUM_MAX_MMC; i++) | |
| 298 | + | for (i = 0; i < CAVIUM_MAX_MMC; i++) { | |
| 299 | 299 | if (host->slot[i]) | |
| 300 | 300 | cvm_mmc_of_slot_remove(host->slot[i]); | |
| 301 | + | if (host->slot_pdev[i]) | |
| 302 | + | of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL); | |
| 303 | + | } | |
| 301 | 304 | ||
| 302 | 305 | dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host)); | |
| 303 | 306 | dma_cfg &= ~MIO_EMM_DMA_CFG_EN; | |
modified drivers/mmc/host/cavium-thunderx.c
| @@ -173,9 +173,12 @@ static void thunder_mmc_remove(struct pci_dev *pdev) | |||
| 173 | 173 | u64 dma_cfg; | |
| 174 | 174 | int i; | |
| 175 | 175 | ||
| 176 | - | for (i = 0; i < CAVIUM_MAX_MMC; i++) | |
| 176 | + | for (i = 0; i < CAVIUM_MAX_MMC; i++) { | |
| 177 | 177 | if (host->slot[i]) | |
| 178 | 178 | cvm_mmc_of_slot_remove(host->slot[i]); | |
| 179 | + | if (host->slot_pdev[i]) | |
| 180 | + | of_platform_device_destroy(&host->slot_pdev[i]->dev, NULL); | |
| 181 | + | } | |
| 179 | 182 | ||
| 180 | 183 | dma_cfg = readq(host->dma_base + MIO_EMM_DMA_CFG(host)); | |
| 181 | 184 | dma_cfg &= ~MIO_EMM_DMA_CFG_EN; | |
modified drivers/mmc/host/mmc_hsq.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | * Author: Baolin Wang <baolin.wang@linaro.org> | |
| 8 | 8 | */ | |
| 9 | 9 | ||
| 10 | + | #include <linux/devm-helpers.h> | |
| 10 | 11 | #include <linux/mmc/card.h> | |
| 11 | 12 | #include <linux/mmc/host.h> | |
| 12 | 13 | #include <linux/module.h> | |
| @@ -345,6 +346,7 @@ static const struct mmc_cqe_ops mmc_hsq_ops = { | |||
| 345 | 346 | ||
| 346 | 347 | int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc) | |
| 347 | 348 | { | |
| 349 | + | int ret; | |
| 348 | 350 | int i; | |
| 349 | 351 | hsq->num_slots = HSQ_NUM_SLOTS; | |
| 350 | 352 | hsq->next_tag = HSQ_INVALID_TAG; | |
| @@ -363,7 +365,11 @@ int mmc_hsq_init(struct mmc_hsq *hsq, struct mmc_host *mmc) | |||
| 363 | 365 | for (i = 0; i < HSQ_NUM_SLOTS; i++) | |
| 364 | 366 | hsq->tag_slot[i] = HSQ_INVALID_TAG; | |
| 365 | 367 | ||
| 366 | - | INIT_WORK(&hsq->retry_work, mmc_hsq_retry_handler); | |
| 368 | + | ret = devm_work_autocancel(mmc_dev(mmc), &hsq->retry_work, | |
| 369 | + | mmc_hsq_retry_handler); | |
| 370 | + | if (ret) | |
| 371 | + | return ret; | |
| 372 | + | ||
| 367 | 373 | spin_lock_init(&hsq->lock); | |
| 368 | 374 | init_waitqueue_head(&hsq->wait_queue); | |
| 369 | 375 | ||
modified drivers/mmc/host/mmc_spi.c
| @@ -952,6 +952,7 @@ crc_recover: | |||
| 952 | 952 | status = mmc_spi_command_send(host, mrq, &stop, 0); | |
| 953 | 953 | crc_retry--; | |
| 954 | 954 | mrq->data->error = 0; | |
| 955 | + | mrq->data->bytes_xfered = 0; | |
| 955 | 956 | goto crc_recover; | |
| 956 | 957 | } | |
| 957 | 958 | ||
modified drivers/mmc/host/mmci.c
| @@ -2511,6 +2511,9 @@ static void mmci_remove(struct amba_device *dev) | |||
| 2511 | 2511 | writel(0, host->base + MMCICOMMAND); | |
| 2512 | 2512 | writel(0, host->base + MMCIDATACTRL); | |
| 2513 | 2513 | ||
| 2514 | + | if (variant->busy_detect) | |
| 2515 | + | disable_delayed_work_sync(&host->ux500_busy_timeout_work); | |
| 2516 | + | ||
| 2514 | 2517 | mmci_dma_release(host); | |
| 2515 | 2518 | clk_disable_unprepare(host->clk); | |
| 2516 | 2519 | } | |
modified drivers/mmc/host/mtk-sd.c
| @@ -3216,6 +3216,7 @@ static void msdc_drv_remove(struct platform_device *pdev) | |||
| 3216 | 3216 | ||
| 3217 | 3217 | platform_set_drvdata(pdev, NULL); | |
| 3218 | 3218 | mmc_remove_host(mmc); | |
| 3219 | + | cancel_delayed_work_sync(&host->req_timeout); | |
| 3219 | 3220 | msdc_deinit_hw(host); | |
| 3220 | 3221 | msdc_gate_clock(host); | |
| 3221 | 3222 | ||
modified drivers/mmc/host/mxcmmc.c
| @@ -1173,6 +1173,10 @@ static void mxcmci_remove(struct platform_device *pdev) | |||
| 1173 | 1173 | ||
| 1174 | 1174 | mmc_remove_host(mmc); | |
| 1175 | 1175 | ||
| 1176 | + | devm_free_irq(&pdev->dev, platform_get_irq(pdev, 0), host); | |
| 1177 | + | cancel_work_sync(&host->datawork); | |
| 1178 | + | timer_delete_sync(&host->watchdog); | |
| 1179 | + | ||
| 1176 | 1180 | if (host->pdata && host->pdata->exit) | |
| 1177 | 1181 | host->pdata->exit(&pdev->dev, mmc); | |
| 1178 | 1182 | ||
modified drivers/mmc/host/rtsx_pci_sdmmc.c
| @@ -1425,6 +1425,11 @@ static void realtek_init_host(struct realtek_pci_sdmmc *host) | |||
| 1425 | 1425 | mmc->caps = mmc->caps | MMC_CAP_AGGRESSIVE_PM; | |
| 1426 | 1426 | mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE | | |
| 1427 | 1427 | MMC_CAP2_NO_SDIO; | |
| 1428 | + | ||
| 1429 | + | if (pcr->pci->device == 0x522a && | |
| 1430 | + | pcr->pci->subsystem_vendor == PCI_VENDOR_ID_LENOVO && | |
| 1431 | + | pcr->pci->subsystem_device == 0x504a) | |
| 1432 | + | mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; | |
| 1428 | 1433 | mmc->max_current_330 = 400; | |
| 1429 | 1434 | mmc->max_current_180 = 800; | |
| 1430 | 1435 | mmc->ops = &realtek_pci_sdmmc_ops; | |
modified drivers/mmc/host/sdhci-of-aspeed.c
| @@ -560,12 +560,14 @@ static int aspeed_sdc_probe(struct platform_device *pdev) | |||
| 560 | 560 | cpdev = of_platform_device_create(child, NULL, &pdev->dev); | |
| 561 | 561 | if (!cpdev) { | |
| 562 | 562 | ret = -ENODEV; | |
| 563 | - | goto err_clk; | |
| 563 | + | goto err_children; | |
| 564 | 564 | } | |
| 565 | 565 | } | |
| 566 | 566 | ||
| 567 | 567 | return 0; | |
| 568 | 568 | ||
| 569 | + | err_children: | |
| 570 | + | device_for_each_child_reverse(&pdev->dev, NULL, of_platform_device_destroy); | |
| 569 | 571 | err_clk: | |
| 570 | 572 | clk_disable_unprepare(sdc->clk); | |
| 571 | 573 | return ret; | |
| @@ -575,6 +577,7 @@ static void aspeed_sdc_remove(struct platform_device *pdev) | |||
| 575 | 577 | { | |
| 576 | 578 | struct aspeed_sdc *sdc = dev_get_drvdata(&pdev->dev); | |
| 577 | 579 | ||
| 580 | + | device_for_each_child_reverse(&pdev->dev, NULL, of_platform_device_destroy); | |
| 578 | 581 | clk_disable_unprepare(sdc->clk); | |
| 579 | 582 | } | |
| 580 | 583 | ||
modified drivers/mmc/host/sdhci-sprd.c
| @@ -890,6 +890,10 @@ static void sdhci_sprd_remove(struct platform_device *pdev) | |||
| 890 | 890 | struct sdhci_host *host = platform_get_drvdata(pdev); | |
| 891 | 891 | struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); | |
| 892 | 892 | ||
| 893 | + | pm_runtime_get_sync(&pdev->dev); | |
| 894 | + | pm_runtime_disable(&pdev->dev); | |
| 895 | + | pm_runtime_put_noidle(&pdev->dev); | |
| 896 | + | ||
| 893 | 897 | sdhci_remove_host(host, 0); | |
| 894 | 898 | ||
| 895 | 899 | clk_disable_unprepare(sprd_host->clk_sdio); | |
modified drivers/mmc/host/sdhci_am654.c
| @@ -126,7 +126,7 @@ static const struct timing_data td[] = { | |||
| 126 | 126 | NULL, | |
| 127 | 127 | MMC_CAP_UHS_SDR104}, | |
| 128 | 128 | [MMC_TIMING_UHS_DDR50] = {"ti,otap-del-sel-ddr50", | |
| 129 | - | NULL, | |
| 129 | + | "ti,itap-del-sel-ddr50", | |
| 130 | 130 | MMC_CAP_UHS_DDR50}, | |
| 131 | 131 | [MMC_TIMING_MMC_DDR52] = {"ti,otap-del-sel-ddr52", | |
| 132 | 132 | "ti,itap-del-sel-ddr52", | |
| @@ -144,6 +144,8 @@ struct sdhci_am654_data { | |||
| 144 | 144 | u32 otap_del_sel[ARRAY_SIZE(td)]; | |
| 145 | 145 | u32 itap_del_sel[ARRAY_SIZE(td)]; | |
| 146 | 146 | u32 itap_del_ena[ARRAY_SIZE(td)]; | |
| 147 | + | u32 itap_del_sel_dt_ddr50; | |
| 148 | + | u32 itap_del_ena_dt_ddr50; | |
| 147 | 149 | int clkbuf_sel; | |
| 148 | 150 | int trm_icp; | |
| 149 | 151 | int drv_strength; | |
| @@ -151,7 +153,6 @@ struct sdhci_am654_data { | |||
| 151 | 153 | u32 flags; | |
| 152 | 154 | u32 quirks; | |
| 153 | 155 | bool dll_enable; | |
| 154 | - | u32 tuning_loop; | |
| 155 | 156 | ||
| 156 | 157 | #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0) | |
| 157 | 158 | #define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1) | |
| @@ -443,15 +444,13 @@ static int sdhci_am654_execute_tuning(struct mmc_host *mmc, u32 opcode) | |||
| 443 | 444 | struct sdhci_host *host = mmc_priv(mmc); | |
| 444 | 445 | int err = sdhci_execute_tuning(mmc, opcode); | |
| 445 | 446 | ||
| 446 | - | if (err) | |
| 447 | - | return err; | |
| 448 | 447 | /* | |
| 449 | 448 | * Tuning data remains in the buffer after tuning. | |
| 450 | 449 | * Do a command and data reset to get rid of it | |
| 451 | 450 | */ | |
| 452 | 451 | sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); | |
| 453 | 452 | ||
| 454 | - | return 0; | |
| 453 | + | return err; | |
| 455 | 454 | } | |
| 456 | 455 | ||
| 457 | 456 | static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) | |
| @@ -530,7 +529,6 @@ static int sdhci_am654_do_tuning(struct sdhci_host *host, | |||
| 530 | 529 | { | |
| 531 | 530 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | |
| 532 | 531 | struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); | |
| 533 | - | unsigned char timing = host->mmc->ios.timing; | |
| 534 | 532 | struct window fail_window[ITAPDLY_LENGTH]; | |
| 535 | 533 | struct device *dev = mmc_dev(host->mmc); | |
| 536 | 534 | u8 curr_pass, itap; | |
| @@ -539,11 +537,8 @@ static int sdhci_am654_do_tuning(struct sdhci_host *host, | |||
| 539 | 537 | ||
| 540 | 538 | memset(fail_window, 0, sizeof(fail_window)); | |
| 541 | 539 | ||
| 542 | - | /* Enable ITAPDLY */ | |
| 543 | - | sdhci_am654->itap_del_ena[timing] = 0x1; | |
| 544 | - | ||
| 545 | 540 | for (itap = 0; itap < ITAPDLY_LENGTH; itap++) { | |
| 546 | - | sdhci_am654_write_itapdly(sdhci_am654, itap, sdhci_am654->itap_del_ena[timing]); | |
| 541 | + | sdhci_am654_write_itapdly(sdhci_am654, itap, 0x1); | |
| 547 | 542 | ||
| 548 | 543 | curr_pass = !mmc_send_tuning(host->mmc, opcode, NULL); | |
| 549 | 544 | ||
| @@ -576,20 +571,36 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host, | |||
| 576 | 571 | struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); | |
| 577 | 572 | unsigned char timing = host->mmc->ios.timing; | |
| 578 | 573 | struct device *dev = mmc_dev(host->mmc); | |
| 574 | + | unsigned int tuning_loop = 0; | |
| 579 | 575 | int itapdly; | |
| 580 | 576 | ||
| 581 | 577 | do { | |
| 582 | 578 | itapdly = sdhci_am654_do_tuning(host, opcode); | |
| 583 | 579 | if (itapdly >= 0) | |
| 584 | 580 | break; | |
| 585 | - | } while (++sdhci_am654->tuning_loop < RETRY_TUNING_MAX); | |
| 581 | + | } while (++tuning_loop < RETRY_TUNING_MAX); | |
| 586 | 582 | ||
| 587 | 583 | if (itapdly < 0) { | |
| 588 | - | dev_err(dev, "Failed to find itapdly, fail tuning\n"); | |
| 584 | + | if (timing == MMC_TIMING_UHS_DDR50) { | |
| 585 | + | dev_dbg(dev, "Failed DDR50 tuning, fallback to DT ITAP\n"); | |
| 586 | + | sdhci_am654->itap_del_sel[timing] = sdhci_am654->itap_del_sel_dt_ddr50; | |
| 587 | + | sdhci_am654->itap_del_ena[timing] = sdhci_am654->itap_del_ena_dt_ddr50; | |
| 588 | + | } else { | |
| 589 | + | dev_err(dev, "Failed to find itapdly, fail tuning\n"); | |
| 590 | + | sdhci_am654->itap_del_ena[timing] = 0; | |
| 591 | + | sdhci_am654->itap_del_sel[timing] = 0; | |
| 592 | + | } | |
| 593 | + | ||
| 594 | + | sdhci_am654_write_itapdly(sdhci_am654, | |
| 595 | + | sdhci_am654->itap_del_sel[timing], | |
| 596 | + | sdhci_am654->itap_del_ena[timing]); | |
| 589 | 597 | return -1; | |
| 590 | 598 | } | |
| 591 | 599 | ||
| 592 | 600 | dev_dbg(dev, "Passed tuning, final itapdly=%d\n", itapdly); | |
| 601 | + | ||
| 602 | + | /* Enable ITAPDLY */ | |
| 603 | + | sdhci_am654->itap_del_ena[timing] = 0x1; | |
| 593 | 604 | sdhci_am654_write_itapdly(sdhci_am654, itapdly, sdhci_am654->itap_del_ena[timing]); | |
| 594 | 605 | /* Save ITAPDLY */ | |
| 595 | 606 | sdhci_am654->itap_del_sel[timing] = itapdly; | |
| @@ -758,6 +769,11 @@ static int sdhci_am654_get_otap_delay(struct sdhci_host *host, | |||
| 758 | 769 | } | |
| 759 | 770 | } | |
| 760 | 771 | ||
| 772 | + | sdhci_am654->itap_del_sel_dt_ddr50 = | |
| 773 | + | sdhci_am654->itap_del_sel[MMC_TIMING_UHS_DDR50]; | |
| 774 | + | sdhci_am654->itap_del_ena_dt_ddr50 = | |
| 775 | + | sdhci_am654->itap_del_ena[MMC_TIMING_UHS_DDR50]; | |
| 776 | + | ||
| 761 | 777 | return 0; | |
| 762 | 778 | } | |
| 763 | 779 | ||
| @@ -806,9 +822,6 @@ static int sdhci_am654_init(struct sdhci_host *host) | |||
| 806 | 822 | regmap_update_bits(sdhci_am654->base, CTL_CFG_3, TUNINGFORSDR50_MASK, | |
| 807 | 823 | TUNINGFORSDR50_MASK); | |
| 808 | 824 | ||
| 809 | - | /* Use to re-execute tuning */ | |
| 810 | - | sdhci_am654->tuning_loop = 0; | |
| 811 | - | ||
| 812 | 825 | ret = sdhci_setup_host(host); | |
| 813 | 826 | if (ret) | |
| 814 | 827 | return ret; | |
modified drivers/mmc/host/sh_mmcif.c
| @@ -1461,6 +1461,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) | |||
| 1461 | 1461 | host->pd = pdev; | |
| 1462 | 1462 | ||
| 1463 | 1463 | spin_lock_init(&host->lock); | |
| 1464 | + | mutex_init(&host->thread_lock); | |
| 1464 | 1465 | ||
| 1465 | 1466 | mmc->ops = &sh_mmcif_ops; | |
| 1466 | 1467 | sh_mmcif_init_ocr(host); | |
| @@ -1515,8 +1516,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) | |||
| 1515 | 1516 | goto err_clk; | |
| 1516 | 1517 | } | |
| 1517 | 1518 | ||
| 1518 | - | mutex_init(&host->thread_lock); | |
| 1519 | - | ||
| 1520 | 1519 | ret = mmc_add_host(mmc); | |
| 1521 | 1520 | if (ret < 0) | |
| 1522 | 1521 | goto err_clk; | |
modified drivers/mtd/chips/cfi_cmdset_0001.c
| @@ -1716,12 +1716,24 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le | |||
| 1716 | 1716 | } | |
| 1717 | 1717 | ||
| 1718 | 1718 | ||
| 1719 | + | /* | |
| 1720 | + | * Keep noinline: inlined, the map_word temporaries put do_write_buffer() over | |
| 1721 | + | * the frame-size limit with MTD_MAP_BANK_WIDTH_32 and KASAN_STACK. | |
| 1722 | + | */ | |
| 1723 | + | static noinline void __xipram cfi_write_cmd(struct map_info *map, | |
| 1724 | + | unsigned long cmd, unsigned long adr) | |
| 1725 | + | { | |
| 1726 | + | struct cfi_private *cfi = map->fldrv_priv; | |
| 1727 | + | ||
| 1728 | + | map_write(map, CMD(cmd), adr); | |
| 1729 | + | } | |
| 1730 | + | ||
| 1719 | 1731 | static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |
| 1720 | 1732 | unsigned long adr, const struct kvec **pvec, | |
| 1721 | 1733 | unsigned long *pvec_seek, int len) | |
| 1722 | 1734 | { | |
| 1723 | 1735 | struct cfi_private *cfi = map->fldrv_priv; | |
| 1724 | - | map_word status, write_cmd, datum; | |
| 1736 | + | map_word status, datum; | |
| 1725 | 1737 | unsigned long cmd_adr; | |
| 1726 | 1738 | int ret, wbufsize, word_gap, words; | |
| 1727 | 1739 | const struct kvec *vec; | |
| @@ -1740,9 +1752,6 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1740 | 1752 | if (is_LH28F640BF(cfi)) | |
| 1741 | 1753 | cmd_adr = adr; | |
| 1742 | 1754 | ||
| 1743 | - | /* Let's determine this according to the interleave only once */ | |
| 1744 | - | write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9); | |
| 1745 | - | ||
| 1746 | 1755 | mutex_lock(&chip->mutex); | |
| 1747 | 1756 | ret = get_chip(map, chip, cmd_adr, FL_WRITING); | |
| 1748 | 1757 | if (ret) { | |
| @@ -1759,7 +1768,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1759 | 1768 | So we must check here and reset those bits if they're set. Otherwise | |
| 1760 | 1769 | we're just pissing in the wind */ | |
| 1761 | 1770 | if (chip->state != FL_STATUS) { | |
| 1762 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1771 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1763 | 1772 | chip->state = FL_STATUS; | |
| 1764 | 1773 | } | |
| 1765 | 1774 | status = map_read(map, cmd_adr); | |
| @@ -1767,21 +1776,22 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1767 | 1776 | xip_enable(map, chip, cmd_adr); | |
| 1768 | 1777 | printk(KERN_WARNING "SR.4 or SR.5 bits set in buffer write (status %lx). Clearing.\n", status.x[0]); | |
| 1769 | 1778 | xip_disable(map, chip, cmd_adr); | |
| 1770 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1771 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1779 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1780 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1772 | 1781 | } | |
| 1773 | 1782 | ||
| 1774 | 1783 | chip->state = FL_WRITING_TO_BUFFER; | |
| 1775 | - | map_write(map, write_cmd, cmd_adr); | |
| 1784 | + | cfi_write_cmd(map, (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? 0xe8 : 0xe9, | |
| 1785 | + | cmd_adr); | |
| 1776 | 1786 | ret = WAIT_TIMEOUT(map, chip, cmd_adr, 0, 0); | |
| 1777 | 1787 | if (ret) { | |
| 1778 | 1788 | /* Argh. Not ready for write to buffer */ | |
| 1779 | 1789 | map_word Xstatus = map_read(map, cmd_adr); | |
| 1780 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1790 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1781 | 1791 | chip->state = FL_STATUS; | |
| 1782 | 1792 | status = map_read(map, cmd_adr); | |
| 1783 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1784 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1793 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1794 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1785 | 1795 | xip_enable(map, chip, cmd_adr); | |
| 1786 | 1796 | printk(KERN_ERR "%s: Chip not ready for buffer write. Xstatus = %lx, status = %lx\n", | |
| 1787 | 1797 | map->name, Xstatus.x[0], status.x[0]); | |
| @@ -1800,7 +1810,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1800 | 1810 | } | |
| 1801 | 1811 | ||
| 1802 | 1812 | /* Write length of data to come */ | |
| 1803 | - | map_write(map, CMD(words), cmd_adr ); | |
| 1813 | + | cfi_write_cmd(map, words, cmd_adr); | |
| 1804 | 1814 | ||
| 1805 | 1815 | /* Write data */ | |
| 1806 | 1816 | vec = *pvec; | |
| @@ -1837,7 +1847,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1837 | 1847 | *pvec_seek = vec_seek; | |
| 1838 | 1848 | ||
| 1839 | 1849 | /* GO GO GO */ | |
| 1840 | - | map_write(map, CMD(0xd0), cmd_adr); | |
| 1850 | + | cfi_write_cmd(map, 0xd0, cmd_adr); | |
| 1841 | 1851 | chip->state = FL_WRITING; | |
| 1842 | 1852 | ||
| 1843 | 1853 | ret = INVAL_CACHE_AND_WAIT(map, chip, cmd_adr, | |
| @@ -1845,7 +1855,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1845 | 1855 | chip->buffer_write_time, | |
| 1846 | 1856 | chip->buffer_write_time_max); | |
| 1847 | 1857 | if (ret) { | |
| 1848 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1858 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1849 | 1859 | chip->state = FL_STATUS; | |
| 1850 | 1860 | xip_enable(map, chip, cmd_adr); | |
| 1851 | 1861 | printk(KERN_ERR "%s: buffer write error (status timeout)\n", map->name); | |
| @@ -1858,8 +1868,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1858 | 1868 | unsigned long chipstatus = MERGESTATUS(status); | |
| 1859 | 1869 | ||
| 1860 | 1870 | /* reset status */ | |
| 1861 | - | map_write(map, CMD(0x50), cmd_adr); | |
| 1862 | - | map_write(map, CMD(0x70), cmd_adr); | |
| 1871 | + | cfi_write_cmd(map, 0x50, cmd_adr); | |
| 1872 | + | cfi_write_cmd(map, 0x70, cmd_adr); | |
| 1863 | 1873 | xip_enable(map, chip, cmd_adr); | |
| 1864 | 1874 | ||
| 1865 | 1875 | if (chipstatus & 0x02) { | |
modified drivers/mtd/devices/block2mtd.c
| @@ -293,7 +293,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, | |||
| 293 | 293 | } | |
| 294 | 294 | ||
| 295 | 295 | size = bdev_nr_bytes(bdev); | |
| 296 | - | if ((long)size % erase_size) { | |
| 296 | + | if (!erase_size || (long)size % erase_size) { | |
| 297 | 297 | pr_err("erasesize must be a divisor of device size\n"); | |
| 298 | 298 | goto err_free_block2mtd; | |
| 299 | 299 | } | |
modified drivers/mtd/devices/mtd_intel_dg.c
| @@ -387,7 +387,7 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a | |||
| 387 | 387 | void __iomem *base2 = nvm->base2; | |
| 388 | 388 | void __iomem *base = nvm->base; | |
| 389 | 389 | const u32 block = 0x10; | |
| 390 | - | u32 iter = 0; | |
| 390 | + | u32 iter; | |
| 391 | 391 | u32 reg; | |
| 392 | 392 | u64 i; | |
| 393 | 393 | ||
| @@ -396,6 +396,7 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a | |||
| 396 | 396 | iowrite32(region << 24 | block, base + NVM_ERASE_REG); | |
| 397 | 397 | if (nvm->non_posted_erase) { | |
| 398 | 398 | /* Wait for Erase Done */ | |
| 399 | + | iter = 0; | |
| 399 | 400 | reg = ioread32(base2 + NVM_DEBUG_REG); | |
| 400 | 401 | while (!(reg & NVM_NON_POSTED_ERASE_DONE) && | |
| 401 | 402 | ++iter < NVM_NON_POSTED_ERASE_DONE_ITER) { | |
modified drivers/mtd/mtdcore.c
| @@ -1083,6 +1083,7 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd) | |||
| 1083 | 1083 | ||
| 1084 | 1084 | err: | |
| 1085 | 1085 | nvmem_unregister(mtd->otp_user_nvmem); | |
| 1086 | + | mtd->otp_user_nvmem = NULL; | |
| 1086 | 1087 | /* Don't report error if OTP is not supported. */ | |
| 1087 | 1088 | if (err == -EOPNOTSUPP) | |
| 1088 | 1089 | return 0; | |
| @@ -1332,7 +1333,7 @@ int __get_mtd_device(struct mtd_info *mtd) | |||
| 1332 | 1333 | int err; | |
| 1333 | 1334 | ||
| 1334 | 1335 | if (master->_get_device) { | |
| 1335 | - | err = master->_get_device(mtd); | |
| 1336 | + | err = master->_get_device(master); | |
| 1336 | 1337 | if (err) | |
| 1337 | 1338 | return err; | |
| 1338 | 1339 | } | |
modified drivers/mtd/nand/ecc.c
| @@ -159,6 +159,13 @@ int nand_ecc_finish_io_req(struct nand_device *nand, | |||
| 159 | 159 | } | |
| 160 | 160 | EXPORT_SYMBOL(nand_ecc_finish_io_req); | |
| 161 | 161 | ||
| 162 | + | bool nand_ecc_is_pipelined(const struct nand_device *nand) | |
| 163 | + | { | |
| 164 | + | return nand->ecc.engine && | |
| 165 | + | nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED; | |
| 166 | + | } | |
| 167 | + | EXPORT_SYMBOL(nand_ecc_is_pipelined); | |
| 168 | + | ||
| 162 | 169 | /* Define default OOB placement schemes for large and small page devices */ | |
| 163 | 170 | static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section, | |
| 164 | 171 | struct mtd_oob_region *oobregion) | |
modified drivers/mtd/nand/raw/cadence-nand-controller.c
| @@ -3143,6 +3143,9 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) | |||
| 3143 | 3143 | goto free_buf_desc; | |
| 3144 | 3144 | } | |
| 3145 | 3145 | ||
| 3146 | + | spin_lock_init(&cdns_ctrl->irq_lock); | |
| 3147 | + | init_completion(&cdns_ctrl->complete); | |
| 3148 | + | ||
| 3146 | 3149 | if (devm_request_irq(cdns_ctrl->dev, cdns_ctrl->irq, cadence_nand_isr, | |
| 3147 | 3150 | IRQF_SHARED, "cadence-nand-controller", | |
| 3148 | 3151 | cdns_ctrl)) { | |
| @@ -3151,9 +3154,6 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) | |||
| 3151 | 3154 | goto free_buf; | |
| 3152 | 3155 | } | |
| 3153 | 3156 | ||
| 3154 | - | spin_lock_init(&cdns_ctrl->irq_lock); | |
| 3155 | - | init_completion(&cdns_ctrl->complete); | |
| 3156 | - | ||
| 3157 | 3157 | ret = cadence_nand_hw_init(cdns_ctrl); | |
| 3158 | 3158 | if (ret) | |
| 3159 | 3159 | goto disable_irq; | |
modified drivers/mtd/nand/raw/vf610_nfc.c
| @@ -505,6 +505,11 @@ static int vf610_nfc_exec_op(struct nand_chip *chip, | |||
| 505 | 505 | check_only); | |
| 506 | 506 | } | |
| 507 | 507 | ||
| 508 | + | static unsigned int vf610_nfc_spare_size(struct mtd_info *mtd) | |
| 509 | + | { | |
| 510 | + | return min_t(unsigned int, mtd->oobsize, 64); | |
| 511 | + | } | |
| 512 | + | ||
| 508 | 513 | static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |
| 509 | 514 | uint8_t *oob, int page) | |
| 510 | 515 | { | |
| @@ -514,6 +519,7 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |||
| 514 | 519 | u8 ecc_status; | |
| 515 | 520 | u8 ecc_count; | |
| 516 | 521 | int flips_threshold = nfc->chip.ecc.strength / 2; | |
| 522 | + | int ret; | |
| 517 | 523 | ||
| 518 | 524 | ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff; | |
| 519 | 525 | ecc_count = ecc_status & ECC_STATUS_ERR_COUNT; | |
| @@ -521,16 +527,22 @@ static inline int vf610_nfc_correct_data(struct nand_chip *chip, uint8_t *dat, | |||
| 521 | 527 | if (!(ecc_status & ECC_STATUS_MASK)) | |
| 522 | 528 | return ecc_count; | |
| 523 | 529 | ||
| 530 | + | /* The failed decode leaves a bogus correction in SRAM; re-read without ECC */ | |
| 524 | 531 | nfc->data_access = true; | |
| 525 | - | nand_read_oob_op(&nfc->chip, page, 0, oob, mtd->oobsize); | |
| 532 | + | ret = nand_read_page_op(&nfc->chip, page, 0, dat, mtd->writesize); | |
| 533 | + | if (!ret) | |
| 534 | + | ret = nand_read_oob_op(&nfc->chip, page, 0, oob, | |
| 535 | + | vf610_nfc_spare_size(mtd)); | |
| 526 | 536 | nfc->data_access = false; | |
| 537 | + | if (ret) | |
| 538 | + | return ret; | |
| 527 | 539 | ||
| 528 | 540 | /* | |
| 529 | - | * On an erased page, bit count (including OOB) should be zero or | |
| 530 | - | * at least less then half of the ECC strength. | |
| 541 | + | * Run the erased-page check with the driver's historic threshold | |
| 542 | + | * of half the ECC strength. | |
| 531 | 543 | */ | |
| 532 | - | return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob, | |
| 533 | - | mtd->oobsize, NULL, 0, | |
| 544 | + | return nand_check_erased_ecc_chunk(dat, mtd->writesize, oob, | |
| 545 | + | vf610_nfc_spare_size(mtd), NULL, 0, | |
| 534 | 546 | flips_threshold); | |
| 535 | 547 | } | |
| 536 | 548 | ||
| @@ -551,7 +563,7 @@ static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf, | |||
| 551 | 563 | { | |
| 552 | 564 | struct vf610_nfc *nfc = chip_to_nfc(chip); | |
| 553 | 565 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| 554 | - | int trfr_sz = mtd->writesize + mtd->oobsize; | |
| 566 | + | int trfr_sz = mtd->writesize + vf610_nfc_spare_size(mtd); | |
| 555 | 567 | u32 row = 0, cmd1 = 0, cmd2 = 0, code = 0; | |
| 556 | 568 | int stat; | |
| 557 | 569 | ||
| @@ -577,11 +589,16 @@ static int vf610_nfc_read_page(struct nand_chip *chip, uint8_t *buf, | |||
| 577 | 589 | */ | |
| 578 | 590 | vf610_nfc_rd_from_sram(buf, nfc->regs + NFC_MAIN_AREA(0), | |
| 579 | 591 | mtd->writesize, false); | |
| 580 | - | if (oob_required) | |
| 592 | + | if (oob_required) { | |
| 593 | + | unsigned int spare = vf610_nfc_spare_size(mtd); | |
| 594 | + | ||
| 581 | 595 | vf610_nfc_rd_from_sram(chip->oob_poi, | |
| 582 | 596 | nfc->regs + NFC_MAIN_AREA(0) + | |
| 583 | 597 | mtd->writesize, | |
| 584 | - | mtd->oobsize, false); | |
| 598 | + | spare, false); | |
| 599 | + | /* Not transferred, and never written: reads back erased */ | |
| 600 | + | memset(chip->oob_poi + spare, 0xff, mtd->oobsize - spare); | |
| 601 | + | } | |
| 585 | 602 | ||
| 586 | 603 | stat = vf610_nfc_correct_data(chip, buf, chip->oob_poi, page); | |
| 587 | 604 | ||
| @@ -599,7 +616,7 @@ static int vf610_nfc_write_page(struct nand_chip *chip, const uint8_t *buf, | |||
| 599 | 616 | { | |
| 600 | 617 | struct vf610_nfc *nfc = chip_to_nfc(chip); | |
| 601 | 618 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| 602 | - | int trfr_sz = mtd->writesize + mtd->oobsize; | |
| 619 | + | int trfr_sz = mtd->writesize + vf610_nfc_spare_size(mtd); | |
| 603 | 620 | u32 row = 0, cmd1 = 0, cmd2 = 0, code = 0; | |
| 604 | 621 | u8 status; | |
| 605 | 622 | int ret; | |
| @@ -740,6 +757,49 @@ static void vf610_nfc_init_controller(struct vf610_nfc *nfc) | |||
| 740 | 757 | } | |
| 741 | 758 | } | |
| 742 | 759 | ||
| 760 | + | /* | |
| 761 | + | * With 64 byte OOB chips the core's large page layout matches what | |
| 762 | + | * U-Boot uses, and on chips with more, U-Boot and older kernels clamped | |
| 763 | + | * mtd->oobsize to 64. Modifying the OOB size is no longer possible, the | |
| 764 | + | * actual chip geometry must be respected, so to avoid breaking those | |
| 765 | + | * existing setups use our own layout: the core's large page one, | |
| 766 | + | * computed over the first 64 spare bytes only. | |
| 767 | + | */ | |
| 768 | + | static int vf610_nfc_ooblayout_ecc(struct mtd_info *mtd, int section, | |
| 769 | + | struct mtd_oob_region *oobregion) | |
| 770 | + | { | |
| 771 | + | struct nand_device *nand = mtd_to_nanddev(mtd); | |
| 772 | + | unsigned int total_ecc_bytes = nand->ecc.ctx.total; | |
| 773 | + | ||
| 774 | + | if (section || !total_ecc_bytes) | |
| 775 | + | return -ERANGE; | |
| 776 | + | ||
| 777 | + | oobregion->length = total_ecc_bytes; | |
| 778 | + | oobregion->offset = vf610_nfc_spare_size(mtd) - oobregion->length; | |
| 779 | + | ||
| 780 | + | return 0; | |
| 781 | + | } | |
| 782 | + | ||
| 783 | + | static int vf610_nfc_ooblayout_free(struct mtd_info *mtd, int section, | |
| 784 | + | struct mtd_oob_region *oobregion) | |
| 785 | + | { | |
| 786 | + | struct nand_device *nand = mtd_to_nanddev(mtd); | |
| 787 | + | unsigned int total_ecc_bytes = nand->ecc.ctx.total; | |
| 788 | + | ||
| 789 | + | if (section) | |
| 790 | + | return -ERANGE; | |
| 791 | + | ||
| 792 | + | oobregion->length = vf610_nfc_spare_size(mtd) - total_ecc_bytes - 2; | |
| 793 | + | oobregion->offset = 2; | |
| 794 | + | ||
| 795 | + | return 0; | |
| 796 | + | } | |
| 797 | + | ||
| 798 | + | static const struct mtd_ooblayout_ops vf610_nfc_ooblayout_ops = { | |
| 799 | + | .ecc = vf610_nfc_ooblayout_ecc, | |
| 800 | + | .free = vf610_nfc_ooblayout_free, | |
| 801 | + | }; | |
| 802 | + | ||
| 743 | 803 | static int vf610_nfc_attach_chip(struct nand_chip *chip) | |
| 744 | 804 | { | |
| 745 | 805 | struct mtd_info *mtd = nand_to_mtd(chip); | |
| @@ -770,12 +830,7 @@ static int vf610_nfc_attach_chip(struct nand_chip *chip) | |||
| 770 | 830 | return -ENXIO; | |
| 771 | 831 | } | |
| 772 | 832 | ||
| 773 | - | /* Only 64 byte ECC layouts known */ | |
| 774 | - | if (mtd->oobsize > 64) | |
| 775 | - | mtd->oobsize = 64; | |
| 776 | - | ||
| 777 | - | /* Use default large page ECC layout defined in NAND core */ | |
| 778 | - | mtd_set_ooblayout(mtd, nand_get_large_page_ooblayout()); | |
| 833 | + | mtd_set_ooblayout(mtd, &vf610_nfc_ooblayout_ops); | |
| 779 | 834 | if (chip->ecc.strength == 32) { | |
| 780 | 835 | nfc->ecc_mode = ECC_60_BYTE; | |
| 781 | 836 | chip->ecc.bytes = 60; | |
modified drivers/mtd/nand/spi/core.c
| @@ -281,8 +281,26 @@ static int spinand_init_cfg_cache(struct spinand_device *spinand) | |||
| 281 | 281 | static int spinand_init_quad_enable(struct spinand_device *spinand, | |
| 282 | 282 | bool enable) | |
| 283 | 283 | { | |
| 284 | - | return spinand_upd_cfg(spinand, CFG_QUAD_ENABLE, | |
| 285 | - | enable ? CFG_QUAD_ENABLE : 0); | |
| 284 | + | struct nand_device *nand = spinand_to_nand(spinand); | |
| 285 | + | unsigned int target; | |
| 286 | + | int ret; | |
| 287 | + | ||
| 288 | + | /* | |
| 289 | + | * QE is a per-die setting on some devices. Program each target | |
| 290 | + | * individually when enabling or disabling quad I/O mode. | |
| 291 | + | */ | |
| 292 | + | for (target = 0; target < nand->memorg.ntargets; target++) { | |
| 293 | + | ret = spinand_select_target(spinand, target); | |
| 294 | + | if (ret) | |
| 295 | + | return ret; | |
| 296 | + | ||
| 297 | + | ret = spinand_upd_cfg(spinand, CFG_QUAD_ENABLE, | |
| 298 | + | enable ? CFG_QUAD_ENABLE : 0); | |
| 299 | + | if (ret) | |
| 300 | + | return ret; | |
| 301 | + | } | |
| 302 | + | ||
| 303 | + | return 0; | |
| 286 | 304 | } | |
| 287 | 305 | ||
| 288 | 306 | static int spinand_ecc_enable(struct spinand_device *spinand, | |
| @@ -508,8 +526,7 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand, | |||
| 508 | 526 | else | |
| 509 | 527 | rdesc->info.op_tmpl = &rdesc->info.primary_op_tmpl; | |
| 510 | 528 | ||
| 511 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED && | |
| 512 | - | req->mode != MTD_OPS_RAW) | |
| 529 | + | if (nand_ecc_is_pipelined(nand) && req->mode != MTD_OPS_RAW) | |
| 513 | 530 | rdesc->info.op_tmpl->data.ecc = true; | |
| 514 | 531 | else | |
| 515 | 532 | rdesc->info.op_tmpl->data.ecc = false; | |
| @@ -603,8 +620,7 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand, | |||
| 603 | 620 | ||
| 604 | 621 | wdesc = spinand->dirmaps[req->pos.plane].wdesc; | |
| 605 | 622 | ||
| 606 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED && | |
| 607 | - | req->mode != MTD_OPS_RAW) | |
| 623 | + | if (nand_ecc_is_pipelined(nand) && req->mode != MTD_OPS_RAW) | |
| 608 | 624 | wdesc->info.op_tmpl->data.ecc = true; | |
| 609 | 625 | else | |
| 610 | 626 | wdesc->info.op_tmpl->data.ecc = false; | |
| @@ -1261,7 +1277,7 @@ static int spinand_create_dirmap(struct spinand_device *spinand, | |||
| 1261 | 1277 | struct spi_mem_dirmap_desc *desc; | |
| 1262 | 1278 | bool enable_ecc = false, secondary_op = false; | |
| 1263 | 1279 | ||
| 1264 | - | if (nand->ecc.engine->integration == NAND_ECC_ENGINE_INTEGRATION_PIPELINED) | |
| 1280 | + | if (nand_ecc_is_pipelined(nand)) | |
| 1265 | 1281 | enable_ecc = true; | |
| 1266 | 1282 | ||
| 1267 | 1283 | if (spinand->cont_read_possible && spinand->op_templates->cont_read_cache) | |
| @@ -1797,11 +1813,11 @@ try_ssdr: | |||
| 1797 | 1813 | spinand->ssdr_op_templates.write_cache->data.buswidth == 4 || | |
| 1798 | 1814 | spinand->ssdr_op_templates.update_cache->data.buswidth == 4) | |
| 1799 | 1815 | quad_enable = true; | |
| 1800 | - | } | |
| 1801 | 1816 | ||
| 1802 | - | ret = spinand_init_quad_enable(spinand, quad_enable); | |
| 1803 | - | if (ret) | |
| 1804 | - | return ret; | |
| 1817 | + | ret = spinand_init_quad_enable(spinand, quad_enable); | |
| 1818 | + | if (ret) | |
| 1819 | + | return ret; | |
| 1820 | + | } | |
| 1805 | 1821 | ||
| 1806 | 1822 | if (spinand->configure_chip) { | |
| 1807 | 1823 | ret = spinand->configure_chip(spinand, SSDR); | |
| @@ -1809,7 +1825,7 @@ try_ssdr: | |||
| 1809 | 1825 | return ret; | |
| 1810 | 1826 | } | |
| 1811 | 1827 | ||
| 1812 | - | return ret; | |
| 1828 | + | return 0; | |
| 1813 | 1829 | } | |
| 1814 | 1830 | ||
| 1815 | 1831 | static int spinand_init_flash(struct spinand_device *spinand) | |
| @@ -1980,12 +1996,17 @@ static int spinand_init(struct spinand_device *spinand) | |||
| 1980 | 1996 | goto err_cleanup_ecc_engine; | |
| 1981 | 1997 | } | |
| 1982 | 1998 | ||
| 1983 | - | if (nand->ecc.engine) { | |
| 1984 | - | ret = mtd_ooblayout_count_freebytes(mtd); | |
| 1985 | - | if (ret < 0) | |
| 1986 | - | goto err_cleanup_ecc_engine; | |
| 1999 | + | if (!nand->ecc.engine) { | |
| 2000 | + | if (spinand->eccinfo.ooblayout) | |
| 2001 | + | mtd_set_ooblayout(mtd, spinand->eccinfo.ooblayout); | |
| 2002 | + | else | |
| 2003 | + | mtd_set_ooblayout(mtd, &spinand_noecc_ooblayout); | |
| 1987 | 2004 | } | |
| 1988 | 2005 | ||
| 2006 | + | ret = mtd_ooblayout_count_freebytes(mtd); | |
| 2007 | + | if (ret < 0) | |
| 2008 | + | goto err_cleanup_ecc_engine; | |
| 2009 | + | ||
| 1989 | 2010 | mtd->oobavail = ret; | |
| 1990 | 2011 | ||
| 1991 | 2012 | /* Propagate ECC information to mtd_info */ | |
modified drivers/mtd/spi-nor/core.c
| @@ -1310,7 +1310,7 @@ static bool spi_nor_rww_start_exclusive(struct spi_nor *nor) | |||
| 1310 | 1310 | { | |
| 1311 | 1311 | struct spi_nor_rww *rww = &nor->rww; | |
| 1312 | 1312 | ||
| 1313 | - | mutex_lock(&nor->lock); | |
| 1313 | + | guard(mutex)(&nor->lock); | |
| 1314 | 1314 | ||
| 1315 | 1315 | if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) | |
| 1316 | 1316 | return false; | |
modified drivers/net/amt.c
| @@ -80,15 +80,6 @@ static struct in6_addr mld2_all_node = MLD2_ALL_NODE_INIT; | |||
| 80 | 80 | static struct mld2_grec mldv2_zero_grec; | |
| 81 | 81 | #endif | |
| 82 | 82 | ||
| 83 | - | static struct amt_skb_cb *amt_skb_cb(struct sk_buff *skb) | |
| 84 | - | { | |
| 85 | - | BUILD_BUG_ON(sizeof(struct amt_skb_cb) + sizeof(struct tc_skb_cb) > | |
| 86 | - | sizeof_field(struct sk_buff, cb)); | |
| 87 | - | ||
| 88 | - | return (struct amt_skb_cb *)((void *)skb->cb + | |
| 89 | - | sizeof(struct tc_skb_cb)); | |
| 90 | - | } | |
| 91 | - | ||
| 92 | 83 | static void __amt_source_gc_work(void) | |
| 93 | 84 | { | |
| 94 | 85 | struct amt_source_node *snode; | |
| @@ -791,6 +782,11 @@ out: | |||
| 791 | 782 | rcu_read_unlock(); | |
| 792 | 783 | } | |
| 793 | 784 | ||
| 785 | + | static bool amt_send_membership_query(struct amt_dev *amt, | |
| 786 | + | struct sk_buff *skb, | |
| 787 | + | struct amt_tunnel_list *tunnel, | |
| 788 | + | bool v6); | |
| 789 | + | ||
| 794 | 790 | static void amt_send_igmp_gq(struct amt_dev *amt, | |
| 795 | 791 | struct amt_tunnel_list *tunnel) | |
| 796 | 792 | { | |
| @@ -800,8 +796,11 @@ static void amt_send_igmp_gq(struct amt_dev *amt, | |||
| 800 | 796 | if (!skb) | |
| 801 | 797 | return; | |
| 802 | 798 | ||
| 803 | - | amt_skb_cb(skb)->tunnel = tunnel; | |
| 804 | - | dev_queue_xmit(skb); | |
| 799 | + | skb_pull(skb, sizeof(struct ethhdr)); | |
| 800 | + | if (amt_send_membership_query(amt, skb, tunnel, false)) { | |
| 801 | + | amt->dev->stats.tx_dropped++; | |
| 802 | + | kfree_skb(skb); | |
| 803 | + | } | |
| 805 | 804 | } | |
| 806 | 805 | ||
| 807 | 806 | #if IS_ENABLED(CONFIG_IPV6) | |
| @@ -885,8 +884,11 @@ static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) | |||
| 885 | 884 | if (!skb) | |
| 886 | 885 | return; | |
| 887 | 886 | ||
| 888 | - | amt_skb_cb(skb)->tunnel = tunnel; | |
| 889 | - | dev_queue_xmit(skb); | |
| 887 | + | skb_pull(skb, sizeof(struct ethhdr)); | |
| 888 | + | if (amt_send_membership_query(amt, skb, tunnel, true)) { | |
| 889 | + | amt->dev->stats.tx_dropped++; | |
| 890 | + | kfree_skb(skb); | |
| 891 | + | } | |
| 890 | 892 | } | |
| 891 | 893 | #else | |
| 892 | 894 | static void amt_send_mld_gq(struct amt_dev *amt, struct amt_tunnel_list *tunnel) | |
| @@ -1186,7 +1188,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1186 | 1188 | #endif | |
| 1187 | 1189 | bool report = false; | |
| 1188 | 1190 | struct igmphdr *ih; | |
| 1189 | - | bool query = false; | |
| 1190 | 1191 | struct iphdr *iph; | |
| 1191 | 1192 | bool data = false; | |
| 1192 | 1193 | bool v6 = false; | |
| @@ -1204,9 +1205,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1204 | 1205 | case IGMP_HOST_MEMBERSHIP_REPORT: | |
| 1205 | 1206 | report = true; | |
| 1206 | 1207 | break; | |
| 1207 | - | case IGMP_HOST_MEMBERSHIP_QUERY: | |
| 1208 | - | query = true; | |
| 1209 | - | break; | |
| 1210 | 1208 | default: | |
| 1211 | 1209 | goto free; | |
| 1212 | 1210 | } | |
| @@ -1228,9 +1226,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1228 | 1226 | case ICMPV6_MLD2_REPORT: | |
| 1229 | 1227 | report = true; | |
| 1230 | 1228 | break; | |
| 1231 | - | case ICMPV6_MGM_QUERY: | |
| 1232 | - | query = true; | |
| 1233 | - | break; | |
| 1234 | 1229 | default: | |
| 1235 | 1230 | goto free; | |
| 1236 | 1231 | } | |
| @@ -1261,19 +1256,6 @@ static netdev_tx_t amt_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1261 | 1256 | goto free; | |
| 1262 | 1257 | goto unlock; | |
| 1263 | 1258 | } else if (amt->mode == AMT_MODE_RELAY) { | |
| 1264 | - | if (query) { | |
| 1265 | - | tunnel = amt_skb_cb(skb)->tunnel; | |
| 1266 | - | if (!tunnel) { | |
| 1267 | - | WARN_ON(1); | |
| 1268 | - | goto free; | |
| 1269 | - | } | |
| 1270 | - | ||
| 1271 | - | /* Do not forward unexpected query */ | |
| 1272 | - | if (amt_send_membership_query(amt, skb, tunnel, v6)) | |
| 1273 | - | goto free; | |
| 1274 | - | goto unlock; | |
| 1275 | - | } | |
| 1276 | - | ||
| 1277 | 1259 | if (!data) | |
| 1278 | 1260 | goto free; | |
| 1279 | 1261 | list_for_each_entry_rcu(tunnel, &amt->tunnel_list, list) { | |
modified drivers/net/bareudp.c
| @@ -356,7 +356,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
| 356 | 356 | if (err) | |
| 357 | 357 | goto free_dst; | |
| 358 | 358 | ||
| 359 | - | skb_set_inner_protocol(skb, bareudp->ethertype); | |
| 359 | + | skb_set_inner_protocol(skb, skb->protocol); | |
| 360 | 360 | udp_tunnel_xmit_skb(rt, sk, skb, saddr, info->key.u.ipv4.dst, | |
| 361 | 361 | tos, ttl, df, sport, bareudp->port, | |
| 362 | 362 | !net_eq(bareudp->net, dev_net(bareudp->dev)), | |
| @@ -424,6 +424,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev, | |||
| 424 | 424 | if (err) | |
| 425 | 425 | goto free_dst; | |
| 426 | 426 | ||
| 427 | + | skb_set_inner_protocol(skb, skb->protocol); | |
| 427 | 428 | daddr = info->key.u.ipv6.dst; | |
| 428 | 429 | udp_tunnel6_xmit_skb(dst, sk, skb, dev, | |
| 429 | 430 | &saddr, &daddr, prio, ttl, | |
modified drivers/net/bonding/bond_main.c
| @@ -490,7 +490,7 @@ static int bond_ipsec_add_sa(struct net_device *bond_dev, | |||
| 490 | 490 | !real_dev->xfrmdev_ops->xdo_dev_state_add || | |
| 491 | 491 | netif_is_bond_master(real_dev)) { | |
| 492 | 492 | NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); | |
| 493 | - | err = -EINVAL; | |
| 493 | + | err = -EOPNOTSUPP; | |
| 494 | 494 | goto out; | |
| 495 | 495 | } | |
| 496 | 496 | ||
| @@ -5732,12 +5732,12 @@ static int bond_xdp_set(struct net_device *dev, struct bpf_prog *prog, | |||
| 5732 | 5732 | bpf_prog_inc(prog); | |
| 5733 | 5733 | } | |
| 5734 | 5734 | ||
| 5735 | - | if (prog) { | |
| 5735 | + | if (prog && !old_prog) | |
| 5736 | 5736 | static_branch_inc(&bpf_master_redirect_enabled_key); | |
| 5737 | - | } else if (old_prog) { | |
| 5738 | - | bpf_prog_put(old_prog); | |
| 5737 | + | else if (!prog && old_prog) | |
| 5739 | 5738 | static_branch_dec(&bpf_master_redirect_enabled_key); | |
| 5740 | - | } | |
| 5739 | + | if (old_prog) | |
| 5740 | + | bpf_prog_put(old_prog); | |
| 5741 | 5741 | ||
| 5742 | 5742 | return 0; | |
| 5743 | 5743 | ||
modified drivers/net/can/dev/skb.c
| @@ -210,6 +210,10 @@ static void init_can_skb(struct sk_buff *skb) | |||
| 210 | 210 | { | |
| 211 | 211 | skb->pkt_type = PACKET_BROADCAST; | |
| 212 | 212 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
| 213 | + | ||
| 214 | + | skb_reset_mac_header(skb); | |
| 215 | + | skb_reset_network_header(skb); | |
| 216 | + | skb_reset_transport_header(skb); | |
| 213 | 217 | } | |
| 214 | 218 | ||
| 215 | 219 | struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) | |
modified drivers/net/can/usb/f81604.c
| @@ -169,7 +169,7 @@ struct f81604_int_data { | |||
| 169 | 169 | u8 rxerr; | |
| 170 | 170 | u8 txerr; | |
| 171 | 171 | u8 val; | |
| 172 | - | } __packed __aligned(4); | |
| 172 | + | } __packed; | |
| 173 | 173 | ||
| 174 | 174 | struct f81604_sff { | |
| 175 | 175 | __be16 id; | |
modified drivers/net/can/vxcan.c
| @@ -79,6 +79,9 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *oskb, struct net_device *dev) | |||
| 79 | 79 | ||
| 80 | 80 | /* reset CAN GW hop counter */ | |
| 81 | 81 | csx->can_gw_hops = 0; | |
| 82 | + | /* start with new CAN skb UID in the other namespace */ | |
| 83 | + | csx->can_skb_uid = 0; | |
| 84 | + | ||
| 82 | 85 | skb->pkt_type = PACKET_BROADCAST; | |
| 83 | 86 | skb->dev = peer; | |
| 84 | 87 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
modified drivers/net/dsa/microchip/ksz_common.h
| @@ -853,7 +853,7 @@ static inline bool ksz_is_sgmii_port(struct ksz_device *dev, int port) | |||
| 853 | 853 | #define KSZ88_FAMILY_ID 0x88 | |
| 854 | 854 | #define KSZ8895_FAMILY_ID 0x95 | |
| 855 | 855 | ||
| 856 | - | #define KSZ8_PORT_STATUS_0 0x08 | |
| 856 | + | #define KSZ8_PORT_STATUS_0 0x18 | |
| 857 | 857 | #define KSZ8_PORT_FIBER_MODE BIT(7) | |
| 858 | 858 | ||
| 859 | 859 | #define SW_CHIP_ID_M GENMASK(7, 4) | |
modified drivers/net/dsa/mt7530-mdio.c
| @@ -227,15 +227,17 @@ mt7530_remove(struct mdio_device *mdiodev) | |||
| 227 | 227 | if (!priv) | |
| 228 | 228 | return; | |
| 229 | 229 | ||
| 230 | - | ret = regulator_disable(priv->core_pwr); | |
| 231 | - | if (ret < 0) | |
| 232 | - | dev_err(priv->dev, | |
| 233 | - | "Failed to disable core power: %d\n", ret); | |
| 234 | - | ||
| 235 | - | ret = regulator_disable(priv->io_pwr); | |
| 236 | - | if (ret < 0) | |
| 237 | - | dev_err(priv->dev, "Failed to disable io pwr: %d\n", | |
| 238 | - | ret); | |
| 230 | + | if (priv->id == ID_MT7530) { | |
| 231 | + | ret = regulator_disable(priv->core_pwr); | |
| 232 | + | if (ret < 0) | |
| 233 | + | dev_err(priv->dev, | |
| 234 | + | "Failed to disable core power: %d\n", ret); | |
| 235 | + | ||
| 236 | + | ret = regulator_disable(priv->io_pwr); | |
| 237 | + | if (ret < 0) | |
| 238 | + | dev_err(priv->dev, "Failed to disable io pwr: %d\n", | |
| 239 | + | ret); | |
| 240 | + | } | |
| 239 | 241 | ||
| 240 | 242 | mt7530_remove_common(priv); | |
| 241 | 243 | ||
modified drivers/net/dsa/mt7530.c
| @@ -3593,9 +3593,6 @@ EXPORT_SYMBOL_GPL(mt7530_probe_common); | |||
| 3593 | 3593 | void | |
| 3594 | 3594 | mt7530_remove_common(struct mt7530_priv *priv) | |
| 3595 | 3595 | { | |
| 3596 | - | if (priv->irq_domain) | |
| 3597 | - | mt7530_free_mdio_irq(priv); | |
| 3598 | - | ||
| 3599 | 3596 | dsa_unregister_switch(priv->ds); | |
| 3600 | 3597 | ||
| 3601 | 3598 | mutex_destroy(&priv->reg_mutex); | |
modified drivers/net/dsa/mv88e6xxx/chip.c
| @@ -5639,6 +5639,68 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = { | |||
| 5639 | 5639 | .pcs_ops = &mv88e6390_pcs_ops, | |
| 5640 | 5640 | }; | |
| 5641 | 5641 | ||
| 5642 | + | static const struct mv88e6xxx_ops mv88e6191x_ops = { | |
| 5643 | + | /* MV88E6XXX_FAMILY_6393 without AVB and PTP: 6191X and 6193X */ | |
| 5644 | + | .irl_init_all = mv88e6390_g2_irl_init_all, | |
| 5645 | + | .get_eeprom = mv88e6xxx_g2_get_eeprom8, | |
| 5646 | + | .set_eeprom = mv88e6xxx_g2_set_eeprom8, | |
| 5647 | + | .set_switch_mac = mv88e6xxx_g2_set_switch_mac, | |
| 5648 | + | .phy_read = mv88e6xxx_g2_smi_phy_read_c22, | |
| 5649 | + | .phy_write = mv88e6xxx_g2_smi_phy_write_c22, | |
| 5650 | + | .phy_read_c45 = mv88e6xxx_g2_smi_phy_read_c45, | |
| 5651 | + | .phy_write_c45 = mv88e6xxx_g2_smi_phy_write_c45, | |
| 5652 | + | .port_set_link = mv88e6xxx_port_set_link, | |
| 5653 | + | .port_sync_link = mv88e6xxx_port_sync_link, | |
| 5654 | + | .port_set_rgmii_delay = mv88e6390_port_set_rgmii_delay, | |
| 5655 | + | .port_set_speed_duplex = mv88e6393x_port_set_speed_duplex, | |
| 5656 | + | .port_tag_remap = mv88e6390_port_tag_remap, | |
| 5657 | + | .port_set_policy = mv88e6393x_port_set_policy, | |
| 5658 | + | .port_set_frame_mode = mv88e6351_port_set_frame_mode, | |
| 5659 | + | .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, | |
| 5660 | + | .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, | |
| 5661 | + | .port_set_ether_type = mv88e6393x_port_set_ether_type, | |
| 5662 | + | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, | |
| 5663 | + | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, | |
| 5664 | + | .port_pause_limit = mv88e6390_port_pause_limit, | |
| 5665 | + | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, | |
| 5666 | + | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, | |
| 5667 | + | .port_get_cmode = mv88e6352_port_get_cmode, | |
| 5668 | + | .port_set_cmode = mv88e6393x_port_set_cmode, | |
| 5669 | + | .port_setup_message_port = mv88e6xxx_setup_message_port, | |
| 5670 | + | .port_set_upstream_port = mv88e6393x_port_set_upstream_port, | |
| 5671 | + | .port_enable_tcam = mv88e6xxx_port_enable_tcam, | |
| 5672 | + | .stats_snapshot = mv88e6390_g1_stats_snapshot, | |
| 5673 | + | .stats_set_histogram = mv88e6390_g1_stats_set_histogram, | |
| 5674 | + | .stats_get_sset_count = mv88e6320_stats_get_sset_count, | |
| 5675 | + | .stats_get_strings = mv88e6320_stats_get_strings, | |
| 5676 | + | .stats_get_stat = mv88e6390_stats_get_stat, | |
| 5677 | + | /* .set_cpu_port is missing because this family does not support a global | |
| 5678 | + | * CPU port, only per port CPU port which is set via | |
| 5679 | + | * .port_set_upstream_port method. | |
| 5680 | + | */ | |
| 5681 | + | .set_egress_port = mv88e6393x_set_egress_port, | |
| 5682 | + | .watchdog_ops = &mv88e6393x_watchdog_ops, | |
| 5683 | + | .mgmt_rsvd2cpu = mv88e6393x_port_mgmt_rsvd2cpu, | |
| 5684 | + | .pot_clear = mv88e6xxx_g2_pot_clear, | |
| 5685 | + | .hardware_reset_pre = mv88e6xxx_g2_eeprom_wait, | |
| 5686 | + | .hardware_reset_post = mv88e6xxx_g2_eeprom_wait, | |
| 5687 | + | .reset = mv88e6352_g1_reset, | |
| 5688 | + | .rmu_disable = mv88e6390_g1_rmu_disable, | |
| 5689 | + | .atu_get_hash = mv88e6165_g1_atu_get_hash, | |
| 5690 | + | .atu_set_hash = mv88e6165_g1_atu_set_hash, | |
| 5691 | + | .vtu_getnext = mv88e6390_g1_vtu_getnext, | |
| 5692 | + | .vtu_loadpurge = mv88e6390_g1_vtu_loadpurge, | |
| 5693 | + | .stu_getnext = mv88e6390_g1_stu_getnext, | |
| 5694 | + | .stu_loadpurge = mv88e6390_g1_stu_loadpurge, | |
| 5695 | + | .serdes_get_lane = mv88e6393x_serdes_get_lane, | |
| 5696 | + | .serdes_irq_mapping = mv88e6390_serdes_irq_mapping, | |
| 5697 | + | /* TODO: serdes stats */ | |
| 5698 | + | .gpio_ops = &mv88e6352_gpio_ops, | |
| 5699 | + | .phylink_get_caps = mv88e6393x_phylink_get_caps, | |
| 5700 | + | .pcs_ops = &mv88e6393x_pcs_ops, | |
| 5701 | + | .tcam_ops = &mv88e6393_tcam_ops, | |
| 5702 | + | }; | |
| 5703 | + | ||
| 5642 | 5704 | static const struct mv88e6xxx_ops mv88e6393x_ops = { | |
| 5643 | 5705 | /* MV88E6XXX_FAMILY_6393 */ | |
| 5644 | 5706 | .irl_init_all = mv88e6390_g2_irl_init_all, | |
| @@ -6163,8 +6225,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { | |||
| 6163 | 6225 | .atu_move_port_mask = 0x1f, | |
| 6164 | 6226 | .pvt = true, | |
| 6165 | 6227 | .multi_chip = true, | |
| 6166 | - | .ptp_support = true, | |
| 6167 | - | .ops = &mv88e6393x_ops, | |
| 6228 | + | .ops = &mv88e6191x_ops, | |
| 6168 | 6229 | }, | |
| 6169 | 6230 | ||
| 6170 | 6231 | [MV88E6193X] = { | |
| @@ -6190,8 +6251,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = { | |||
| 6190 | 6251 | .atu_move_port_mask = 0x1f, | |
| 6191 | 6252 | .pvt = true, | |
| 6192 | 6253 | .multi_chip = true, | |
| 6193 | - | .ptp_support = true, | |
| 6194 | - | .ops = &mv88e6393x_ops, | |
| 6254 | + | .ops = &mv88e6191x_ops, | |
| 6195 | 6255 | }, | |
| 6196 | 6256 | ||
| 6197 | 6257 | [MV88E6220] = { | |
modified drivers/net/dsa/mxl862xx/mxl862xx.c
| @@ -685,10 +685,22 @@ static int mxl862xx_setup(struct dsa_switch *ds) | |||
| 685 | 685 | if (ret) | |
| 686 | 686 | return ret; | |
| 687 | 687 | ||
| 688 | + | ret = mxl862xx_setup_mdio(ds); | |
| 689 | + | if (ret) | |
| 690 | + | return ret; | |
| 691 | + | ||
| 688 | 692 | schedule_delayed_work(&priv->stats_work, | |
| 689 | 693 | MXL862XX_STATS_POLL_INTERVAL); | |
| 690 | 694 | ||
| 691 | - | return mxl862xx_setup_mdio(ds); | |
| 695 | + | return 0; | |
| 696 | + | } | |
| 697 | + | ||
| 698 | + | static void mxl862xx_teardown(struct dsa_switch *ds) | |
| 699 | + | { | |
| 700 | + | struct mxl862xx_priv *priv = ds->priv; | |
| 701 | + | ||
| 702 | + | set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags); | |
| 703 | + | disable_delayed_work_sync(&priv->stats_work); | |
| 692 | 704 | } | |
| 693 | 705 | ||
| 694 | 706 | static int mxl862xx_port_state(struct dsa_switch *ds, int port, bool enable) | |
| @@ -2047,9 +2059,7 @@ static void mxl862xx_get_stats64(struct dsa_switch *ds, int port, | |||
| 2047 | 2059 | ||
| 2048 | 2060 | spin_unlock_bh(&priv->ports[port].stats_lock); | |
| 2049 | 2061 | ||
| 2050 | - | /* Trigger a fresh poll so the next read sees up-to-date counters. | |
| 2051 | - | * No-op if the work is already pending, running, or teardown started. | |
| 2052 | - | */ | |
| 2062 | + | /* Trigger a fresh poll so the next read sees up-to-date counters. */ | |
| 2053 | 2063 | if (!test_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags)) | |
| 2054 | 2064 | schedule_delayed_work(&priv->stats_work, 0); | |
| 2055 | 2065 | } | |
| @@ -2057,6 +2067,7 @@ static void mxl862xx_get_stats64(struct dsa_switch *ds, int port, | |||
| 2057 | 2067 | static const struct dsa_switch_ops mxl862xx_switch_ops = { | |
| 2058 | 2068 | .get_tag_protocol = mxl862xx_get_tag_protocol, | |
| 2059 | 2069 | .setup = mxl862xx_setup, | |
| 2070 | + | .teardown = mxl862xx_teardown, | |
| 2060 | 2071 | .port_setup = mxl862xx_port_setup, | |
| 2061 | 2072 | .port_teardown = mxl862xx_port_teardown, | |
| 2062 | 2073 | .phylink_get_caps = mxl862xx_phylink_get_caps, | |
| @@ -2131,7 +2142,6 @@ static int mxl862xx_probe(struct mdio_device *mdiodev) | |||
| 2131 | 2142 | err = dsa_register_switch(ds); | |
| 2132 | 2143 | if (err) { | |
| 2133 | 2144 | set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags); | |
| 2134 | - | cancel_delayed_work_sync(&priv->stats_work); | |
| 2135 | 2145 | mxl862xx_host_shutdown(priv); | |
| 2136 | 2146 | for (i = 0; i < MXL862XX_MAX_PORTS; i++) | |
| 2137 | 2147 | cancel_work_sync(&priv->ports[i].host_flood_work); | |
| @@ -2152,7 +2162,6 @@ static void mxl862xx_remove(struct mdio_device *mdiodev) | |||
| 2152 | 2162 | priv = ds->priv; | |
| 2153 | 2163 | ||
| 2154 | 2164 | set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags); | |
| 2155 | - | cancel_delayed_work_sync(&priv->stats_work); | |
| 2156 | 2165 | ||
| 2157 | 2166 | dsa_unregister_switch(ds); | |
| 2158 | 2167 | ||
| @@ -2181,7 +2190,7 @@ static void mxl862xx_shutdown(struct mdio_device *mdiodev) | |||
| 2181 | 2190 | dsa_switch_shutdown(ds); | |
| 2182 | 2191 | ||
| 2183 | 2192 | set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags); | |
| 2184 | - | cancel_delayed_work_sync(&priv->stats_work); | |
| 2193 | + | disable_delayed_work_sync(&priv->stats_work); | |
| 2185 | 2194 | ||
| 2186 | 2195 | mxl862xx_host_shutdown(priv); | |
| 2187 | 2196 | ||
modified drivers/net/ethernet/airoha/airoha_eth.c
| @@ -2800,14 +2800,34 @@ static int airoha_qdma_set_trtcm_param(struct airoha_qdma *qdma, int channel, | |||
| 2800 | 2800 | FIELD_PREP(TRTCM_METER_GROUP_MASK, group) | | |
| 2801 | 2801 | FIELD_PREP(TRTCM_PARAM_INDEX_MASK, idx) | | |
| 2802 | 2802 | FIELD_PREP(TRTCM_PARAM_RATE_TYPE_MASK, mode); | |
| 2803 | + | int i; | |
| 2803 | 2804 | ||
| 2804 | - | airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val); | |
| 2805 | - | airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config); | |
| 2805 | + | /* | |
| 2806 | + | * HW might be in the middle of bucket handling and might | |
| 2807 | + | * require an additional try to actually apply the new TRTCM | |
| 2808 | + | * config. | |
| 2809 | + | */ | |
| 2810 | + | for (i = 0; i < TRTCM_CONFIG_RETRY_MAX; i++) { | |
| 2811 | + | u32 data = 0; | |
| 2806 | 2812 | ||
| 2807 | - | return read_poll_timeout(airoha_qdma_rr, val, | |
| 2808 | - | val & TRTCM_PARAM_RW_DONE_MASK, | |
| 2809 | - | USEC_PER_MSEC, 10 * USEC_PER_MSEC, true, | |
| 2810 | - | qdma, REG_TRTCM_CFG_PARAM(addr)); | |
| 2813 | + | airoha_qdma_wr(qdma, REG_TRTCM_DATA_LOW(addr), val); | |
| 2814 | + | airoha_qdma_wr(qdma, REG_TRTCM_CFG_PARAM(addr), config); | |
| 2815 | + | ||
| 2816 | + | if (read_poll_timeout(airoha_qdma_rr, data, | |
| 2817 | + | data & TRTCM_PARAM_RW_DONE_MASK, | |
| 2818 | + | USEC_PER_MSEC, 10 * USEC_PER_MSEC, | |
| 2819 | + | true, qdma, REG_TRTCM_CFG_PARAM(addr))) | |
| 2820 | + | continue; | |
| 2821 | + | ||
| 2822 | + | if (airoha_qdma_get_trtcm_param(qdma, channel, addr, param, | |
| 2823 | + | mode, &data, NULL)) | |
| 2824 | + | continue; | |
| 2825 | + | ||
| 2826 | + | if (data == val) | |
| 2827 | + | return 0; | |
| 2828 | + | } | |
| 2829 | + | ||
| 2830 | + | return -EBUSY; | |
| 2811 | 2831 | } | |
| 2812 | 2832 | ||
| 2813 | 2833 | static int airoha_qdma_set_trtcm_config(struct airoha_qdma *qdma, int channel, | |
modified drivers/net/ethernet/airoha/airoha_eth.h
| @@ -171,6 +171,8 @@ enum trtcm_param { | |||
| 171 | 171 | #define TRTCM_TOKEN_RATE_MASK GENMASK(23, 6) | |
| 172 | 172 | #define TRTCM_TOKEN_RATE_FRACTION_MASK GENMASK(5, 0) | |
| 173 | 173 | ||
| 174 | + | #define TRTCM_CONFIG_RETRY_MAX 2 | |
| 175 | + | ||
| 174 | 176 | enum airoha_dma_map_type { | |
| 175 | 177 | AIROHA_DMA_UNMAPPED, | |
| 176 | 178 | AIROHA_DMA_MAP_SINGLE, | |
modified drivers/net/ethernet/airoha/airoha_npu.c
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | */ | |
| 6 | 6 | ||
| 7 | 7 | #include <linux/devcoredump.h> | |
| 8 | + | #include <linux/devm-helpers.h> | |
| 8 | 9 | #include <linux/firmware.h> | |
| 9 | 10 | #include <linux/platform_device.h> | |
| 10 | 11 | #include <linux/of_net.h> | |
| @@ -751,12 +752,15 @@ static int airoha_npu_probe(struct platform_device *pdev) | |||
| 751 | 752 | if (irq < 0) | |
| 752 | 753 | return irq; | |
| 753 | 754 | ||
| 755 | + | err = devm_work_autocancel(dev, &core->wdt_work, | |
| 756 | + | airoha_npu_wdt_work); | |
| 757 | + | if (err) | |
| 758 | + | return err; | |
| 759 | + | ||
| 754 | 760 | err = devm_request_irq(dev, irq, airoha_npu_wdt_handler, | |
| 755 | 761 | IRQF_SHARED, "airoha-npu-wdt", core); | |
| 756 | 762 | if (err) | |
| 757 | 763 | return err; | |
| 758 | - | ||
| 759 | - | INIT_WORK(&core->wdt_work, airoha_npu_wdt_work); | |
| 760 | 764 | } | |
| 761 | 765 | ||
| 762 | 766 | /* wlan IRQ lines */ | |
| @@ -803,18 +807,8 @@ static int airoha_npu_probe(struct platform_device *pdev) | |||
| 803 | 807 | return 0; | |
| 804 | 808 | } | |
| 805 | 809 | ||
| 806 | - | static void airoha_npu_remove(struct platform_device *pdev) | |
| 807 | - | { | |
| 808 | - | struct airoha_npu *npu = platform_get_drvdata(pdev); | |
| 809 | - | int i; | |
| 810 | - | ||
| 811 | - | for (i = 0; i < ARRAY_SIZE(npu->cores); i++) | |
| 812 | - | cancel_work_sync(&npu->cores[i].wdt_work); | |
| 813 | - | } | |
| 814 | - | ||
| 815 | 810 | static struct platform_driver airoha_npu_driver = { | |
| 816 | 811 | .probe = airoha_npu_probe, | |
| 817 | - | .remove = airoha_npu_remove, | |
| 818 | 812 | .driver = { | |
| 819 | 813 | .name = "airoha-npu", | |
| 820 | 814 | .of_match_table = of_airoha_npu_match, | |
modified drivers/net/ethernet/allwinner/sun4i-emac.c
| @@ -300,7 +300,7 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, | |||
| 300 | 300 | if (!req) { | |
| 301 | 301 | dev_err(db->dev, "alloc emac dma req error.\n"); | |
| 302 | 302 | ret = -ENOMEM; | |
| 303 | - | goto alloc_req_err; | |
| 303 | + | goto prepare_err; | |
| 304 | 304 | } | |
| 305 | 305 | ||
| 306 | 306 | desc->callback_param = req; | |
| @@ -319,9 +319,6 @@ static int emac_dma_inblk_32bit(struct emac_board_info *db, | |||
| 319 | 319 | submit_err: | |
| 320 | 320 | emac_free_dma_req(req); | |
| 321 | 321 | ||
| 322 | - | alloc_req_err: | |
| 323 | - | dmaengine_desc_free(desc); | |
| 324 | - | ||
| 325 | 322 | prepare_err: | |
| 326 | 323 | dma_unmap_single(db->dev, rxbuf, count, DMA_FROM_DEVICE); | |
| 327 | 324 | return ret; | |
modified drivers/net/ethernet/amazon/ena/ena_netdev.c
| @@ -4122,6 +4122,8 @@ err_worker_destroy: | |||
| 4122 | 4122 | err_device_destroy: | |
| 4123 | 4123 | ena_com_delete_host_info(ena_dev); | |
| 4124 | 4124 | ena_com_admin_destroy(ena_dev); | |
| 4125 | + | ena_phc_destroy(adapter); | |
| 4126 | + | ena_com_mmio_reg_read_request_destroy(ena_dev); | |
| 4125 | 4127 | ena_devlink_destroy: | |
| 4126 | 4128 | ena_devlink_free(devlink); | |
| 4127 | 4129 | err_metrics_destroy: | |
modified drivers/net/ethernet/atheros/atl1c/atl1c_main.c
| @@ -1602,6 +1602,9 @@ static int atl1c_clean_tx(struct napi_struct *napi, int budget) | |||
| 1602 | 1602 | AT_READ_REGW(&adapter->hw, atl1c_qregs[tpd_ring->num].tpd_cons, | |
| 1603 | 1603 | &hw_next_to_clean); | |
| 1604 | 1604 | ||
| 1605 | + | if (unlikely(hw_next_to_clean >= tpd_ring->count)) | |
| 1606 | + | hw_next_to_clean = next_to_clean; | |
| 1607 | + | ||
| 1605 | 1608 | while (next_to_clean != hw_next_to_clean) { | |
| 1606 | 1609 | buffer_info = &tpd_ring->buffer_info[next_to_clean]; | |
| 1607 | 1610 | if (buffer_info->skb) { | |
modified drivers/net/ethernet/atheros/atl1e/atl1e_main.c
| @@ -1234,6 +1234,9 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter) | |||
| 1234 | 1234 | u16 hw_next_to_clean = AT_READ_REGW(&adapter->hw, REG_TPD_CONS_IDX); | |
| 1235 | 1235 | u16 next_to_clean = atomic_read(&tx_ring->next_to_clean); | |
| 1236 | 1236 | ||
| 1237 | + | if (unlikely(hw_next_to_clean >= tx_ring->count)) | |
| 1238 | + | hw_next_to_clean = next_to_clean; | |
| 1239 | + | ||
| 1237 | 1240 | while (next_to_clean != hw_next_to_clean) { | |
| 1238 | 1241 | tx_buffer = &tx_ring->tx_buffer[next_to_clean]; | |
| 1239 | 1242 | if (tx_buffer->dma) { | |
modified drivers/net/ethernet/atheros/atlx/atl1.c
| @@ -2066,6 +2066,9 @@ static int atl1_intr_tx(struct atl1_adapter *adapter) | |||
| 2066 | 2066 | sw_tpd_next_to_clean = atomic_read(&tpd_ring->next_to_clean); | |
| 2067 | 2067 | cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx); | |
| 2068 | 2068 | ||
| 2069 | + | if (unlikely(cmb_tpd_next_to_clean >= tpd_ring->count)) | |
| 2070 | + | cmb_tpd_next_to_clean = sw_tpd_next_to_clean; | |
| 2071 | + | ||
| 2069 | 2072 | while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) { | |
| 2070 | 2073 | buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean]; | |
| 2071 | 2074 | if (buffer_info->dma) { | |
modified drivers/net/ethernet/broadcom/bcmsysport.c
| @@ -391,8 +391,10 @@ static void bcm_sysport_update_mib_counters(struct bcm_sysport_priv *priv) | |||
| 391 | 391 | if (priv->is_lite) | |
| 392 | 392 | continue; | |
| 393 | 393 | ||
| 394 | - | if (s->type != BCM_SYSPORT_STAT_MIB_RX) | |
| 394 | + | if (s->type == BCM_SYSPORT_STAT_MIB_TX) | |
| 395 | 395 | offset = UMAC_MIB_STAT_OFFSET; | |
| 396 | + | else if (s->type == BCM_SYSPORT_STAT_RUNT) | |
| 397 | + | offset = 2 * UMAC_MIB_STAT_OFFSET; | |
| 396 | 398 | val = umac_readl(priv, UMAC_MIB_START + j + offset); | |
| 397 | 399 | break; | |
| 398 | 400 | case BCM_SYSPORT_STAT_RXCHK: | |
| @@ -482,10 +484,10 @@ static void bcm_sysport_get_stats(struct net_device *dev, | |||
| 482 | 484 | s->type == BCM_SYSPORT_STAT_NETDEV64) { | |
| 483 | 485 | do { | |
| 484 | 486 | start = u64_stats_fetch_begin(syncp); | |
| 485 | - | data[i] = *(u64 *)p; | |
| 487 | + | data[j] = *(u64 *)p; | |
| 486 | 488 | } while (u64_stats_fetch_retry(syncp, start)); | |
| 487 | 489 | } else | |
| 488 | - | data[i] = *(u32 *)p; | |
| 490 | + | data[j] = *(u32 *)p; | |
| 489 | 491 | j++; | |
| 490 | 492 | } | |
| 491 | 493 | ||
modified drivers/net/ethernet/broadcom/bnxt/bnxt.c
| @@ -486,7 +486,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 486 | 486 | struct netdev_queue *txq; | |
| 487 | 487 | int i; | |
| 488 | 488 | dma_addr_t mapping; | |
| 489 | - | unsigned int length, pad = 0; | |
| 489 | + | unsigned int length; | |
| 490 | 490 | u32 len, free_size, vlan_tag_flags, cfa_action, flags; | |
| 491 | 491 | struct bnxt_ptp_cfg *ptp = bp->ptp_cfg; | |
| 492 | 492 | struct pci_dev *pdev = bp->pdev; | |
| @@ -536,6 +536,16 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 536 | 536 | return rc < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK; | |
| 537 | 537 | } | |
| 538 | 538 | ||
| 539 | + | /* Pad after the SW USO branch: bnxt_sw_udp_gso_xmit() would | |
| 540 | + | * otherwise account the padding as UDP payload. | |
| 541 | + | * Must be done before skb_shinfo(skb)->nr_frags is sampled, | |
| 542 | + | * because skb_put_padto() might linearize the skb. | |
| 543 | + | */ | |
| 544 | + | if (skb_put_padto(skb, BNXT_MIN_PKT_SIZE)) { | |
| 545 | + | /* SKB already freed. */ | |
| 546 | + | goto tx_kick_pending; | |
| 547 | + | } | |
| 548 | + | ||
| 539 | 549 | free_size = bnxt_tx_avail(bp, txr); | |
| 540 | 550 | if (unlikely(free_size < skb_shinfo(skb)->nr_frags + 2)) { | |
| 541 | 551 | /* We must have raced with NAPI cleanup */ | |
| @@ -672,14 +682,6 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 672 | 682 | } | |
| 673 | 683 | ||
| 674 | 684 | normal_tx: | |
| 675 | - | if (length < BNXT_MIN_PKT_SIZE) { | |
| 676 | - | pad = BNXT_MIN_PKT_SIZE - length; | |
| 677 | - | if (skb_pad(skb, pad)) | |
| 678 | - | /* SKB already freed. */ | |
| 679 | - | goto tx_kick_pending; | |
| 680 | - | length = BNXT_MIN_PKT_SIZE; | |
| 681 | - | } | |
| 682 | - | ||
| 683 | 685 | mapping = dma_map_single(&pdev->dev, skb->data, len, DMA_TO_DEVICE); | |
| 684 | 686 | ||
| 685 | 687 | if (unlikely(dma_mapping_error(&pdev->dev, mapping))) | |
| @@ -759,10 +761,7 @@ normal_tx: | |||
| 759 | 761 | txbd->tx_bd_len_flags_type = cpu_to_le32(flags); | |
| 760 | 762 | } | |
| 761 | 763 | ||
| 762 | - | flags &= ~TX_BD_LEN; | |
| 763 | - | txbd->tx_bd_len_flags_type = | |
| 764 | - | cpu_to_le32(((len + pad) << TX_BD_LEN_SHIFT) | flags | | |
| 765 | - | TX_BD_FLAGS_PACKET_END); | |
| 764 | + | txbd->tx_bd_len_flags_type |= cpu_to_le32(TX_BD_FLAGS_PACKET_END); | |
| 766 | 765 | ||
| 767 | 766 | netdev_tx_sent_queue(txq, skb->len); | |
| 768 | 767 | ||
| @@ -15547,7 +15546,7 @@ static void bnxt_fw_reset_task(struct work_struct *work) | |||
| 15547 | 15546 | if (test_and_clear_bit(BNXT_STATE_FW_ACTIVATE_RESET, &bp->state) && | |
| 15548 | 15547 | !test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) | |
| 15549 | 15548 | bnxt_dl_remote_reload(bp); | |
| 15550 | - | if (pci_enable_device(bp->pdev)) { | |
| 15549 | + | if (!pci_is_enabled(bp->pdev) && pci_enable_device(bp->pdev)) { | |
| 15551 | 15550 | netdev_err(bp->dev, "Cannot re-enable PCI device\n"); | |
| 15552 | 15551 | rc = -ENODEV; | |
| 15553 | 15552 | goto fw_reset_abort; | |
| @@ -17111,6 +17110,51 @@ void bnxt_print_device_info(struct bnxt *bp) | |||
| 17111 | 17110 | pcie_print_link_status(bp->pdev); | |
| 17112 | 17111 | } | |
| 17113 | 17112 | ||
| 17113 | + | static void bnxt_clear_bars(struct pci_dev *pdev) | |
| 17114 | + | { | |
| 17115 | + | int off; | |
| 17116 | + | ||
| 17117 | + | for (off = PCI_BASE_ADDRESS_0; off <= PCI_BASE_ADDRESS_5; off += 4) | |
| 17118 | + | pci_write_config_dword(pdev, off, 0); | |
| 17119 | + | } | |
| 17120 | + | ||
| 17121 | + | /* Clear any pending DMA transactions from crash kernel while loading driver in | |
| 17122 | + | * capture kernel. | |
| 17123 | + | */ | |
| 17124 | + | static int bnxt_kdump_reset(struct pci_dev *pdev) | |
| 17125 | + | { | |
| 17126 | + | int rc, i; | |
| 17127 | + | u16 cmd; | |
| 17128 | + | ||
| 17129 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17130 | + | cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); | |
| 17131 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17132 | + | ||
| 17133 | + | if (pci_save_state(pdev)) | |
| 17134 | + | dev_warn(&pdev->dev, "Failed to save PCI state, PCI restore may be incomplete\n"); | |
| 17135 | + | ||
| 17136 | + | rc = pcie_flr(pdev); | |
| 17137 | + | if (rc) | |
| 17138 | + | dev_warn(&pdev->dev, "pcie_flr() failed (rc: %d), trying to continue\n", | |
| 17139 | + | rc); | |
| 17140 | + | ||
| 17141 | + | /* In case device is not returning CRS, wait 5 seconds longer */ | |
| 17142 | + | for (i = 0; i < 50; i++) { | |
| 17143 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17144 | + | if (!PCI_POSSIBLE_ERROR(cmd)) | |
| 17145 | + | break; | |
| 17146 | + | msleep(100); | |
| 17147 | + | } | |
| 17148 | + | if (PCI_POSSIBLE_ERROR(cmd)) { | |
| 17149 | + | dev_err(&pdev->dev, "PCI config space inaccessible after FLR, aborting\n"); | |
| 17150 | + | return -ENODEV; | |
| 17151 | + | } | |
| 17152 | + | ||
| 17153 | + | bnxt_clear_bars(pdev); | |
| 17154 | + | pci_restore_state(pdev); | |
| 17155 | + | return 0; | |
| 17156 | + | } | |
| 17157 | + | ||
| 17114 | 17158 | static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |
| 17115 | 17159 | { | |
| 17116 | 17160 | struct bnxt_hw_resc *hw_resc; | |
| @@ -17126,12 +17170,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 17126 | 17170 | return -ENODEV; | |
| 17127 | 17171 | } | |
| 17128 | 17172 | ||
| 17129 | - | /* Clear any pending DMA transactions from crash kernel | |
| 17130 | - | * while loading driver in capture kernel. | |
| 17131 | - | */ | |
| 17132 | 17173 | if (is_kdump_kernel()) { | |
| 17133 | - | pci_clear_master(pdev); | |
| 17134 | - | pcie_flr(pdev); | |
| 17174 | + | rc = bnxt_kdump_reset(pdev); | |
| 17175 | + | if (rc) | |
| 17176 | + | return rc; | |
| 17135 | 17177 | } | |
| 17136 | 17178 | ||
| 17137 | 17179 | max_irqs = bnxt_get_max_irq(pdev); | |
| @@ -17565,10 +17607,8 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev, | |||
| 17565 | 17607 | * so we disable bus master to prevent any potential bad DMAs before | |
| 17566 | 17608 | * freeing kernel memory. | |
| 17567 | 17609 | */ | |
| 17568 | - | if (state == pci_channel_io_frozen) { | |
| 17569 | - | set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state); | |
| 17610 | + | if (state == pci_channel_io_frozen) | |
| 17570 | 17611 | bnxt_fw_fatal_close(bp); | |
| 17571 | - | } | |
| 17572 | 17612 | ||
| 17573 | 17613 | if (netif_running(netdev)) | |
| 17574 | 17614 | __bnxt_close_nic(bp, true, true); | |
| @@ -17598,69 +17638,80 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev) | |||
| 17598 | 17638 | struct bnxt *bp = netdev_priv(netdev); | |
| 17599 | 17639 | int retry = 0; | |
| 17600 | 17640 | int err = 0; | |
| 17601 | - | int off; | |
| 17641 | + | u16 cmd; | |
| 17602 | 17642 | ||
| 17603 | 17643 | netdev_info(bp->dev, "PCI Slot Reset\n"); | |
| 17604 | 17644 | ||
| 17605 | - | if (test_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state)) { | |
| 17606 | - | /* After DPC, the chip should return CRS when the vendor ID | |
| 17607 | - | * config register is read until it is ready. On all chips, | |
| 17608 | - | * this is not happening reliably so add a 5-second delay as a | |
| 17609 | - | * workaround. | |
| 17610 | - | */ | |
| 17611 | - | msleep(5000); | |
| 17612 | - | } | |
| 17645 | + | /* After a PCIe hot reset, the chip should return CRS when the | |
| 17646 | + | * vendor ID config register is read until it is ready. On all | |
| 17647 | + | * chips, this is not happening reliably so add a 5-second delay | |
| 17648 | + | * as a workaround. | |
| 17649 | + | */ | |
| 17650 | + | msleep(5000); | |
| 17613 | 17651 | ||
| 17614 | 17652 | netdev_lock(netdev); | |
| 17615 | 17653 | ||
| 17616 | - | if (pci_enable_device(pdev)) { | |
| 17654 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17655 | + | if (PCI_POSSIBLE_ERROR(cmd)) { | |
| 17617 | 17656 | dev_err(&pdev->dev, | |
| 17618 | - | "Cannot re-enable PCI device after reset.\n"); | |
| 17619 | - | } else { | |
| 17620 | - | pci_set_master(pdev); | |
| 17621 | - | /* Upon fatal error, our device internal logic that latches to | |
| 17622 | - | * BAR value is getting reset and will restore only upon | |
| 17623 | - | * rewriting the BARs. | |
| 17624 | - | * | |
| 17625 | - | * As pci_restore_state() does not re-write the BARs if the | |
| 17626 | - | * value is same as saved value earlier, driver needs to | |
| 17627 | - | * write the BARs to 0 to force restore, in case of fatal error. | |
| 17628 | - | */ | |
| 17629 | - | if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, | |
| 17630 | - | &bp->state)) { | |
| 17631 | - | for (off = PCI_BASE_ADDRESS_0; | |
| 17632 | - | off <= PCI_BASE_ADDRESS_5; off += 4) | |
| 17633 | - | pci_write_config_dword(bp->pdev, off, 0); | |
| 17634 | - | } | |
| 17635 | - | pci_restore_state(pdev); | |
| 17657 | + | "PCI config space inaccessible after reset\n"); | |
| 17658 | + | goto reset_exit; | |
| 17659 | + | } | |
| 17636 | 17660 | ||
| 17637 | - | bnxt_inv_fw_health_reg(bp); | |
| 17638 | - | bnxt_try_map_fw_health_reg(bp); | |
| 17661 | + | /* Upon PCIe error, our device internal logic that latches to | |
| 17662 | + | * BAR value is getting reset and will restore only upon | |
| 17663 | + | * rewriting the BARs. | |
| 17664 | + | * | |
| 17665 | + | * As pci_restore_state() does not re-write the BARs if the | |
| 17666 | + | * value is same as saved value earlier, driver needs to | |
| 17667 | + | * write the BARs to 0 to force restore. | |
| 17668 | + | */ | |
| 17669 | + | pci_clear_master(pdev); | |
| 17670 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17671 | + | cmd &= ~PCI_COMMAND_MEMORY; | |
| 17672 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17639 | 17673 | ||
| 17640 | - | /* In some PCIe AER scenarios, firmware may take up to | |
| 17641 | - | * 10 seconds to become ready in the worst case. | |
| 17642 | - | */ | |
| 17643 | - | do { | |
| 17644 | - | err = bnxt_try_recover_fw(bp); | |
| 17645 | - | if (!err) | |
| 17646 | - | break; | |
| 17647 | - | retry++; | |
| 17648 | - | } while (retry < BNXT_FW_SLOT_RESET_RETRY); | |
| 17674 | + | bnxt_clear_bars(pdev); | |
| 17675 | + | pci_restore_state(pdev); | |
| 17649 | 17676 | ||
| 17650 | - | if (err) { | |
| 17651 | - | dev_err(&pdev->dev, "Firmware not ready\n"); | |
| 17652 | - | goto reset_exit; | |
| 17677 | + | if (!pci_is_enabled(pdev) && pci_enable_device(pdev)) { | |
| 17678 | + | dev_err(&pdev->dev, | |
| 17679 | + | "Cannot re-enable PCI device after reset.\n"); | |
| 17680 | + | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
| 17681 | + | if (!PCI_POSSIBLE_ERROR(cmd)) { | |
| 17682 | + | cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); | |
| 17683 | + | pci_write_config_word(pdev, PCI_COMMAND, cmd); | |
| 17653 | 17684 | } | |
| 17685 | + | goto reset_exit; | |
| 17686 | + | } | |
| 17687 | + | pci_set_master(pdev); | |
| 17654 | 17688 | ||
| 17655 | - | err = bnxt_hwrm_func_reset(bp); | |
| 17689 | + | bnxt_inv_fw_health_reg(bp); | |
| 17690 | + | bnxt_try_map_fw_health_reg(bp); | |
| 17691 | + | ||
| 17692 | + | /* In some PCIe AER scenarios, firmware may take up to | |
| 17693 | + | * 10 seconds to become ready in the worst case. | |
| 17694 | + | */ | |
| 17695 | + | do { | |
| 17696 | + | err = bnxt_try_recover_fw(bp); | |
| 17656 | 17697 | if (!err) | |
| 17657 | - | result = PCI_ERS_RESULT_RECOVERED; | |
| 17698 | + | break; | |
| 17699 | + | retry++; | |
| 17700 | + | } while (retry < BNXT_FW_SLOT_RESET_RETRY); | |
| 17658 | 17701 | ||
| 17659 | - | /* IRQ will be initialized later in bnxt_io_resume */ | |
| 17660 | - | bnxt_ulp_irq_stop(bp); | |
| 17661 | - | bnxt_clear_int_mode(bp); | |
| 17702 | + | if (err) { | |
| 17703 | + | dev_err(&pdev->dev, "Firmware not ready\n"); | |
| 17704 | + | goto reset_exit; | |
| 17662 | 17705 | } | |
| 17663 | 17706 | ||
| 17707 | + | err = bnxt_hwrm_func_reset(bp); | |
| 17708 | + | if (!err) | |
| 17709 | + | result = PCI_ERS_RESULT_RECOVERED; | |
| 17710 | + | ||
| 17711 | + | /* IRQ will be initialized later in bnxt_io_resume */ | |
| 17712 | + | bnxt_ulp_irq_stop(bp); | |
| 17713 | + | bnxt_clear_int_mode(bp); | |
| 17714 | + | ||
| 17664 | 17715 | reset_exit: | |
| 17665 | 17716 | clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state); | |
| 17666 | 17717 | bnxt_clear_reservations(bp, true); | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt.h
| @@ -2468,7 +2468,6 @@ struct bnxt { | |||
| 2468 | 2468 | #define BNXT_STATE_ABORT_ERR 5 | |
| 2469 | 2469 | #define BNXT_STATE_FW_FATAL_COND 6 | |
| 2470 | 2470 | #define BNXT_STATE_DRV_REGISTERED 7 | |
| 2471 | - | #define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8 | |
| 2472 | 2471 | #define BNXT_STATE_NAPI_DISABLED 9 | |
| 2473 | 2472 | #define BNXT_STATE_FW_ACTIVATE 11 | |
| 2474 | 2473 | #define BNXT_STATE_RECOVER 12 | |
modified drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
| @@ -5733,7 +5733,8 @@ const struct ethtool_ops bnxt_ethtool_ops = { | |||
| 5733 | 5733 | .op_needs_rtnl = ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | | |
| 5734 | 5734 | ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM | | |
| 5735 | 5735 | ETHTOOL_OP_NEEDS_RTNL_SCOALESCE | | |
| 5736 | - | ETHTOOL_OP_NEEDS_RTNL_RSS, | |
| 5736 | + | ETHTOOL_OP_NEEDS_RTNL_RSS | | |
| 5737 | + | ETHTOOL_OP_NEEDS_RTNL_TEST, | |
| 5737 | 5738 | .supported_coalesce_params = ETHTOOL_COALESCE_USECS | | |
| 5738 | 5739 | ETHTOOL_COALESCE_MAX_FRAMES | | |
| 5739 | 5740 | ETHTOOL_COALESCE_USECS_IRQ | | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet.c
| @@ -57,6 +57,9 @@ | |||
| 57 | 57 | */ | |
| 58 | 58 | #define GENET_RSB_PAD (sizeof(struct status_64) + 2) | |
| 59 | 59 | ||
| 60 | + | /* RX buffer plus the skb_shared_info napi_build_skb() places behind it */ | |
| 61 | + | #define GENET_RX_BUF_SIZE SKB_HEAD_ALIGN(RX_BUF_LENGTH) | |
| 62 | + | ||
| 60 | 63 | /* Tx/Rx DMA register offset, skip 256 descriptors */ | |
| 61 | 64 | #define WORDS_PER_BD(p) (p->hw_params->words_per_bd) | |
| 62 | 65 | #define DMA_DESC_SIZE (WORDS_PER_BD(priv) * sizeof(u32)) | |
| @@ -749,8 +752,17 @@ static void bcmgenet_hfb_init(struct bcmgenet_priv *priv) | |||
| 749 | 752 | INIT_LIST_HEAD(&priv->rxnfc_rules[i].list); | |
| 750 | 753 | priv->rxnfc_rules[i].state = BCMGENET_RXNFC_STATE_UNUSED; | |
| 751 | 754 | } | |
| 755 | + | } | |
| 756 | + | ||
| 757 | + | static void bcmgenet_hfb_restore(struct bcmgenet_priv *priv) | |
| 758 | + | { | |
| 759 | + | struct bcmgenet_rxnfc_rule *rule; | |
| 752 | 760 | ||
| 753 | 761 | bcmgenet_hfb_clear(priv); | |
| 762 | + | ||
| 763 | + | list_for_each_entry(rule, &priv->rxnfc_list, list) | |
| 764 | + | if (rule->state != BCMGENET_RXNFC_STATE_UNUSED) | |
| 765 | + | bcmgenet_hfb_create_rxnfc_filter(priv, rule); | |
| 754 | 766 | } | |
| 755 | 767 | ||
| 756 | 768 | static int bcmgenet_begin(struct net_device *dev) | |
| @@ -843,7 +855,8 @@ static int bcmgenet_get_coalesce(struct net_device *dev, | |||
| 843 | 855 | ec->rx_max_coalesced_frames = | |
| 844 | 856 | bcmgenet_rdma_ring_readl(priv, 0, DMA_MBUF_DONE_THRESH); | |
| 845 | 857 | ec->rx_coalesce_usecs = | |
| 846 | - | bcmgenet_rdma_readl(priv, DMA_RING0_TIMEOUT) * 8192 / 1000; | |
| 858 | + | (bcmgenet_rdma_readl(priv, DMA_RING0_TIMEOUT) & | |
| 859 | + | DMA_TIMEOUT_MASK) * 8192 / 1000; | |
| 847 | 860 | ||
| 848 | 861 | for (i = 0; i <= priv->hw_params->rx_queues; i++) { | |
| 849 | 862 | ring = &priv->rx_rings[i]; | |
| @@ -1337,9 +1350,8 @@ static void bcmgenet_get_ethtool_stats(struct net_device *dev, | |||
| 1337 | 1350 | p = (char *)&stats64; | |
| 1338 | 1351 | ||
| 1339 | 1352 | p += s->stat_offset; | |
| 1340 | - | if (sizeof(unsigned long) != sizeof(u32) && | |
| 1341 | - | s->stat_sizeof == sizeof(unsigned long)) | |
| 1342 | - | data[i] = *(unsigned long *)p; | |
| 1353 | + | if (s->stat_sizeof == sizeof(u64)) | |
| 1354 | + | data[i] = *(u64 *)p; | |
| 1343 | 1355 | else | |
| 1344 | 1356 | data[i] = *(u32 *)p; | |
| 1345 | 1357 | } | |
| @@ -1754,13 +1766,12 @@ static int bcmgenet_power_up(struct bcmgenet_priv *priv, | |||
| 1754 | 1766 | int ret = 0; | |
| 1755 | 1767 | u32 reg; | |
| 1756 | 1768 | ||
| 1757 | - | if (!bcmgenet_has_ext(priv)) | |
| 1758 | - | return ret; | |
| 1759 | - | ||
| 1760 | - | reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); | |
| 1761 | - | ||
| 1762 | 1769 | switch (mode) { | |
| 1763 | 1770 | case GENET_POWER_PASSIVE: | |
| 1771 | + | if (!bcmgenet_has_ext(priv)) | |
| 1772 | + | break; | |
| 1773 | + | ||
| 1774 | + | reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); | |
| 1764 | 1775 | reg &= ~(EXT_PWR_DOWN_DLL | EXT_PWR_DOWN_BIAS | | |
| 1765 | 1776 | EXT_ENERGY_DET_MASK); | |
| 1766 | 1777 | if (GENET_IS_V5(priv) && !bcmgenet_has_ephy_16nm(priv)) { | |
| @@ -1784,8 +1795,12 @@ static int bcmgenet_power_up(struct bcmgenet_priv *priv, | |||
| 1784 | 1795 | break; | |
| 1785 | 1796 | ||
| 1786 | 1797 | case GENET_POWER_CABLE_SENSE: | |
| 1798 | + | if (!bcmgenet_has_ext(priv)) | |
| 1799 | + | break; | |
| 1800 | + | ||
| 1787 | 1801 | /* enable APD */ | |
| 1788 | 1802 | if (!GENET_IS_V5(priv)) { | |
| 1803 | + | reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); | |
| 1789 | 1804 | reg |= EXT_PWR_DN_EN_LD; | |
| 1790 | 1805 | bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); | |
| 1791 | 1806 | } | |
| @@ -2242,11 +2257,12 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, | |||
| 2242 | 2257 | struct enet_cb *cb) | |
| 2243 | 2258 | { | |
| 2244 | 2259 | struct bcmgenet_priv *priv = ring->priv; | |
| 2260 | + | unsigned int size = GENET_RX_BUF_SIZE; | |
| 2261 | + | unsigned int offset; | |
| 2245 | 2262 | dma_addr_t mapping; | |
| 2246 | 2263 | struct page *page; | |
| 2247 | 2264 | ||
| 2248 | - | page = page_pool_alloc_pages(ring->page_pool, | |
| 2249 | - | GFP_ATOMIC); | |
| 2265 | + | page = page_pool_dev_alloc(ring->page_pool, &offset, &size); | |
| 2250 | 2266 | if (!page) { | |
| 2251 | 2267 | priv->mib.alloc_rx_buff_failed++; | |
| 2252 | 2268 | netif_err(priv, rx_err, priv->dev, | |
| @@ -2255,9 +2271,13 @@ static int bcmgenet_rx_refill(struct bcmgenet_rx_ring *ring, | |||
| 2255 | 2271 | } | |
| 2256 | 2272 | ||
| 2257 | 2273 | /* page_pool handles DMA mapping via PP_FLAG_DMA_MAP */ | |
| 2258 | - | mapping = page_pool_get_dma_addr(page); | |
| 2274 | + | mapping = page_pool_get_dma_addr(page) + offset; | |
| 2275 | + | dma_sync_single_for_device(&priv->pdev->dev, mapping, RX_BUF_LENGTH, | |
| 2276 | + | DMA_FROM_DEVICE); | |
| 2259 | 2277 | ||
| 2260 | 2278 | cb->rx_page = page; | |
| 2279 | + | cb->rx_offset = offset; | |
| 2280 | + | cb->rx_size = size; | |
| 2261 | 2281 | dmadesc_set_addr(priv, cb->bd_addr, mapping); | |
| 2262 | 2282 | ||
| 2263 | 2283 | return 0; | |
| @@ -2311,6 +2331,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2311 | 2331 | ||
| 2312 | 2332 | while ((rxpktprocessed < rxpkttoprocess) && | |
| 2313 | 2333 | (rxpktprocessed < budget)) { | |
| 2334 | + | unsigned int rx_offset, rx_size; | |
| 2314 | 2335 | struct status_64 *status; | |
| 2315 | 2336 | struct page *rx_page; | |
| 2316 | 2337 | void *hard_start; | |
| @@ -2320,6 +2341,8 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2320 | 2341 | ||
| 2321 | 2342 | /* Save the received page before refilling */ | |
| 2322 | 2343 | rx_page = cb->rx_page; | |
| 2344 | + | rx_offset = cb->rx_offset; | |
| 2345 | + | rx_size = cb->rx_size; | |
| 2323 | 2346 | ||
| 2324 | 2347 | if (bcmgenet_rx_refill(ring, cb)) { | |
| 2325 | 2348 | BCMGENET_STATS64_INC(stats, dropped); | |
| @@ -2329,10 +2352,10 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2329 | 2352 | /* Sync the full buffer; the HW may have written anywhere | |
| 2330 | 2353 | * up to RX_BUF_LENGTH. | |
| 2331 | 2354 | */ | |
| 2332 | - | page_pool_dma_sync_for_cpu(ring->page_pool, rx_page, 0, | |
| 2355 | + | page_pool_dma_sync_for_cpu(ring->page_pool, rx_page, rx_offset, | |
| 2333 | 2356 | RX_BUF_LENGTH); | |
| 2334 | 2357 | ||
| 2335 | - | hard_start = page_address(rx_page); | |
| 2358 | + | hard_start = page_address(rx_page) + rx_offset; | |
| 2336 | 2359 | status = (struct status_64 *)hard_start; | |
| 2337 | 2360 | dma_length_status = status->length_status; | |
| 2338 | 2361 | ||
| @@ -2398,7 +2421,7 @@ static unsigned int bcmgenet_desc_rx(struct bcmgenet_rx_ring *ring, | |||
| 2398 | 2421 | /* Build SKB from the page - data starts at hard_start, | |
| 2399 | 2422 | * frame begins after RSB(64) + pad(2) = 66 bytes. | |
| 2400 | 2423 | */ | |
| 2401 | - | skb = napi_build_skb(hard_start, PAGE_SIZE); | |
| 2424 | + | skb = napi_build_skb(hard_start, rx_size); | |
| 2402 | 2425 | if (unlikely(!skb)) { | |
| 2403 | 2426 | BCMGENET_STATS64_INC(stats, dropped); | |
| 2404 | 2427 | page_pool_put_full_page(ring->page_pool, rx_page, | |
| @@ -2750,14 +2773,16 @@ static void bcmgenet_init_tx_ring(struct bcmgenet_priv *priv, | |||
| 2750 | 2773 | static int bcmgenet_rx_ring_create_pool(struct bcmgenet_priv *priv, | |
| 2751 | 2774 | struct bcmgenet_rx_ring *ring) | |
| 2752 | 2775 | { | |
| 2776 | + | /* Buffers share a page. bcmgenet_rx_refill() syncs each one for the | |
| 2777 | + | * device, PP_FLAG_DMA_SYNC_DEV would sync the whole page. | |
| 2778 | + | */ | |
| 2753 | 2779 | struct page_pool_params pp_params = { | |
| 2754 | 2780 | .order = 0, | |
| 2755 | - | .flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV, | |
| 2781 | + | .flags = PP_FLAG_DMA_MAP, | |
| 2756 | 2782 | .pool_size = ring->size, | |
| 2757 | 2783 | .nid = NUMA_NO_NODE, | |
| 2758 | 2784 | .dev = &priv->pdev->dev, | |
| 2759 | 2785 | .dma_dir = DMA_FROM_DEVICE, | |
| 2760 | - | .max_len = RX_BUF_LENGTH, | |
| 2761 | 2786 | }; | |
| 2762 | 2787 | int err; | |
| 2763 | 2788 | ||
| @@ -3376,8 +3401,8 @@ static int bcmgenet_open(struct net_device *dev) | |||
| 3376 | 3401 | ||
| 3377 | 3402 | bcmgenet_set_hw_addr(priv, dev->dev_addr); | |
| 3378 | 3403 | ||
| 3379 | - | /* HFB init */ | |
| 3380 | - | bcmgenet_hfb_init(priv); | |
| 3404 | + | /* Restore the filters, the MAC was reset above */ | |
| 3405 | + | bcmgenet_hfb_restore(priv); | |
| 3381 | 3406 | ||
| 3382 | 3407 | /* Reinitialize TDMA and RDMA and SW housekeeping */ | |
| 3383 | 3408 | ret = bcmgenet_init_dma(priv, true); | |
| @@ -3432,6 +3457,8 @@ static void bcmgenet_netif_stop(struct net_device *dev, bool stop_phy) | |||
| 3432 | 3457 | { | |
| 3433 | 3458 | struct bcmgenet_priv *priv = netdev_priv(dev); | |
| 3434 | 3459 | ||
| 3460 | + | /* Stop completion polling before it can wake a stopped queue */ | |
| 3461 | + | bcmgenet_disable_tx_napi(priv); | |
| 3435 | 3462 | netif_tx_disable(dev); | |
| 3436 | 3463 | ||
| 3437 | 3464 | /* Disable MAC receive */ | |
| @@ -3446,7 +3473,6 @@ static void bcmgenet_netif_stop(struct net_device *dev, bool stop_phy) | |||
| 3446 | 3473 | /* Disable MAC transmit. TX DMA disabled must be done before this */ | |
| 3447 | 3474 | umac_enable_set(priv, CMD_TX_EN, false); | |
| 3448 | 3475 | ||
| 3449 | - | bcmgenet_disable_tx_napi(priv); | |
| 3450 | 3476 | bcmgenet_disable_rx_napi(priv); | |
| 3451 | 3477 | bcmgenet_intr_disable(priv); | |
| 3452 | 3478 | ||
| @@ -3623,6 +3649,9 @@ static int bcmgenet_set_mac_addr(struct net_device *dev, void *p) | |||
| 3623 | 3649 | if (netif_running(dev)) | |
| 3624 | 3650 | return -EBUSY; | |
| 3625 | 3651 | ||
| 3652 | + | if (!is_valid_ether_addr(addr->sa_data)) | |
| 3653 | + | return -EADDRNOTAVAIL; | |
| 3654 | + | ||
| 3626 | 3655 | eth_hw_addr_set(dev, addr->sa_data); | |
| 3627 | 3656 | ||
| 3628 | 3657 | return 0; | |
| @@ -4075,6 +4104,7 @@ static int bcmgenet_probe(struct platform_device *pdev) | |||
| 4075 | 4104 | ||
| 4076 | 4105 | /* Mii wait queue */ | |
| 4077 | 4106 | init_waitqueue_head(&priv->wq); | |
| 4107 | + | bcmgenet_hfb_init(priv); | |
| 4078 | 4108 | INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); | |
| 4079 | 4109 | ||
| 4080 | 4110 | priv->clk_wol = devm_clk_get_optional(&priv->pdev->dev, "enet-wol"); | |
| @@ -4121,14 +4151,17 @@ static int bcmgenet_probe(struct platform_device *pdev) | |||
| 4121 | 4151 | netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); | |
| 4122 | 4152 | ||
| 4123 | 4153 | /* Set default coalescing parameters */ | |
| 4124 | - | for (i = 0; i <= priv->hw_params->rx_queues; i++) | |
| 4154 | + | for (i = 0; i <= priv->hw_params->rx_queues; i++) { | |
| 4155 | + | priv->rx_rings[i].priv = priv; | |
| 4156 | + | priv->rx_rings[i].index = i; | |
| 4125 | 4157 | priv->rx_rings[i].rx_max_coalesced_frames = 1; | |
| 4158 | + | } | |
| 4126 | 4159 | ||
| 4127 | 4160 | /* Initialize u64 stats seq counter for 32bit machines */ | |
| 4128 | - | for (i = 0; i <= priv->hw_params->rx_queues; i++) | |
| 4161 | + | for (i = 0; i <= GENET_MAX_MQ_CNT; i++) { | |
| 4129 | 4162 | u64_stats_init(&priv->rx_rings[i].stats64.syncp); | |
| 4130 | - | for (i = 0; i <= priv->hw_params->tx_queues; i++) | |
| 4131 | 4163 | u64_stats_init(&priv->tx_rings[i].stats64.syncp); | |
| 4164 | + | } | |
| 4132 | 4165 | ||
| 4133 | 4166 | /* libphy will determine the link state */ | |
| 4134 | 4167 | netif_carrier_off(dev); | |
| @@ -4272,10 +4305,7 @@ static int bcmgenet_resume(struct device *d) | |||
| 4272 | 4305 | bcmgenet_set_hw_addr(priv, dev->dev_addr); | |
| 4273 | 4306 | ||
| 4274 | 4307 | /* Restore hardware filters */ | |
| 4275 | - | bcmgenet_hfb_clear(priv); | |
| 4276 | - | list_for_each_entry(rule, &priv->rxnfc_list, list) | |
| 4277 | - | if (rule->state != BCMGENET_RXNFC_STATE_UNUSED) | |
| 4278 | - | bcmgenet_hfb_create_rxnfc_filter(priv, rule); | |
| 4308 | + | bcmgenet_hfb_restore(priv); | |
| 4279 | 4309 | ||
| 4280 | 4310 | /* Reinitialize TDMA and RDMA and SW housekeeping */ | |
| 4281 | 4311 | ret = bcmgenet_init_dma(priv, false); | |
| @@ -4313,6 +4343,8 @@ static int bcmgenet_suspend(struct device *d) | |||
| 4313 | 4343 | netif_device_detach(dev); | |
| 4314 | 4344 | ||
| 4315 | 4345 | if (device_may_wakeup(d) && priv->wolopts) { | |
| 4346 | + | /* Stop completion polling before it can wake a stopped queue */ | |
| 4347 | + | bcmgenet_disable_tx_napi(priv); | |
| 4316 | 4348 | netif_tx_disable(dev); | |
| 4317 | 4349 | ||
| 4318 | 4350 | /* Suspend non-wake Rx data flows */ | |
| @@ -4341,7 +4373,6 @@ static int bcmgenet_suspend(struct device *d) | |||
| 4341 | 4373 | netdev_warn(priv->dev, | |
| 4342 | 4374 | "Timed out while disabling TX DMA\n"); | |
| 4343 | 4375 | ||
| 4344 | - | bcmgenet_disable_tx_napi(priv); | |
| 4345 | 4376 | bcmgenet_disable_rx_napi(priv); | |
| 4346 | 4377 | disable_irq(priv->irq1); | |
| 4347 | 4378 | bcmgenet_tx_reclaim_all(dev); | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet.h
| @@ -470,6 +470,8 @@ struct bcmgenet_rx_stats64 { | |||
| 470 | 470 | struct enet_cb { | |
| 471 | 471 | struct sk_buff *skb; | |
| 472 | 472 | struct page *rx_page; | |
| 473 | + | unsigned int rx_offset; | |
| 474 | + | unsigned int rx_size; | |
| 473 | 475 | void __iomem *bd_addr; | |
| 474 | 476 | DEFINE_DMA_UNMAP_ADDR(dma_addr); | |
| 475 | 477 | DEFINE_DMA_UNMAP_LEN(dma_len); | |
modified drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c
| @@ -253,6 +253,17 @@ int bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, | |||
| 253 | 253 | reg = bcmgenet_umac_readl(priv, UMAC_CMD); | |
| 254 | 254 | reg &= ~CMD_CRC_FWD; | |
| 255 | 255 | bcmgenet_umac_writel(priv, reg, UMAC_CMD); | |
| 256 | + | ||
| 257 | + | /* | |
| 258 | + | * Mirror wol_power_down_cfg(). If only UMAC_RX | |
| 259 | + | * is enabled, then we must place the UMAC back | |
| 260 | + | * into SW_RESET. | |
| 261 | + | */ | |
| 262 | + | reg = bcmgenet_umac_readl(priv, UMAC_CMD); | |
| 263 | + | if ((reg & CMD_RX_EN) && !(reg & CMD_TX_EN)) { | |
| 264 | + | reg |= CMD_SW_RESET; | |
| 265 | + | bcmgenet_umac_writel(priv, reg, UMAC_CMD); | |
| 266 | + | } | |
| 256 | 267 | spin_unlock_bh(&priv->reg_lock); | |
| 257 | 268 | ||
| 258 | 269 | /* Resume link status tracking */ | |
modified drivers/net/ethernet/broadcom/tg3.c
| @@ -17915,11 +17915,14 @@ static int tg3_init_one(struct pci_dev *pdev, | |||
| 17915 | 17915 | ||
| 17916 | 17916 | err = tg3_get_device_address(tp, addr); | |
| 17917 | 17917 | if (err) { | |
| 17918 | - | dev_err(&pdev->dev, | |
| 17919 | - | "Could not obtain valid ethernet address, aborting\n"); | |
| 17920 | - | goto err_out_apeunmap; | |
| 17918 | + | dev_warn_probe(&pdev->dev, err, | |
| 17919 | + | "Could not obtain a valid ethernet address\n"); | |
| 17920 | + | if (err == -EPROBE_DEFER) | |
| 17921 | + | goto err_out_apeunmap; | |
| 17922 | + | eth_hw_addr_random(dev); | |
| 17923 | + | } else { | |
| 17924 | + | eth_hw_addr_set(dev, addr); | |
| 17921 | 17925 | } | |
| 17922 | - | eth_hw_addr_set(dev, addr); | |
| 17923 | 17926 | ||
| 17924 | 17927 | intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW; | |
| 17925 | 17928 | rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW; | |
| @@ -18047,6 +18050,10 @@ static int tg3_init_one(struct pci_dev *pdev, | |||
| 18047 | 18050 | return 0; | |
| 18048 | 18051 | ||
| 18049 | 18052 | err_out_apeunmap: | |
| 18053 | + | if (tg3_flag(tp, USE_PHYLIB)) | |
| 18054 | + | tg3_phy_fini(tp); | |
| 18055 | + | tg3_mdio_fini(tp); | |
| 18056 | + | ||
| 18050 | 18057 | if (tp->aperegs) { | |
| 18051 | 18058 | iounmap(tp->aperegs); | |
| 18052 | 18059 | tp->aperegs = NULL; | |
modified drivers/net/ethernet/brocade/bna/bnad.c
| @@ -2571,6 +2571,22 @@ bnad_ioceth_disable(struct bnad *bnad) | |||
| 2571 | 2571 | return err; | |
| 2572 | 2572 | } | |
| 2573 | 2573 | ||
| 2574 | + | /* | |
| 2575 | + | * The IOC timers rearm one another, so deleting one cannot stop a | |
| 2576 | + | * sibling callback from arming it again. Shut them down so a later | |
| 2577 | + | * mod_timer() is ignored. | |
| 2578 | + | */ | |
| 2579 | + | static void | |
| 2580 | + | bnad_ioc_timers_shutdown(struct bnad *bnad) | |
| 2581 | + | { | |
| 2582 | + | struct bfa_ioc *ioc = &bnad->bna.ioceth.ioc; | |
| 2583 | + | ||
| 2584 | + | timer_shutdown_sync(&ioc->ioc_timer); | |
| 2585 | + | timer_shutdown_sync(&ioc->sem_timer); | |
| 2586 | + | timer_shutdown_sync(&ioc->hb_timer); | |
| 2587 | + | timer_shutdown_sync(&ioc->iocpf_timer); | |
| 2588 | + | } | |
| 2589 | + | ||
| 2574 | 2590 | static int | |
| 2575 | 2591 | bnad_ioceth_enable(struct bnad *bnad) | |
| 2576 | 2592 | { | |
| @@ -3727,9 +3743,7 @@ probe_uninit: | |||
| 3727 | 3743 | bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); | |
| 3728 | 3744 | disable_ioceth: | |
| 3729 | 3745 | bnad_ioceth_disable(bnad); | |
| 3730 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.ioc_timer); | |
| 3731 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.sem_timer); | |
| 3732 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.hb_timer); | |
| 3746 | + | bnad_ioc_timers_shutdown(bnad); | |
| 3733 | 3747 | spin_lock_irqsave(&bnad->bna_lock, flags); | |
| 3734 | 3748 | bna_uninit(bna); | |
| 3735 | 3749 | spin_unlock_irqrestore(&bnad->bna_lock, flags); | |
| @@ -3770,9 +3784,7 @@ bnad_pci_remove(struct pci_dev *pdev) | |||
| 3770 | 3784 | ||
| 3771 | 3785 | mutex_lock(&bnad->conf_mutex); | |
| 3772 | 3786 | bnad_ioceth_disable(bnad); | |
| 3773 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.ioc_timer); | |
| 3774 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.sem_timer); | |
| 3775 | - | timer_delete_sync(&bnad->bna.ioceth.ioc.hb_timer); | |
| 3787 | + | bnad_ioc_timers_shutdown(bnad); | |
| 3776 | 3788 | spin_lock_irqsave(&bnad->bna_lock, flags); | |
| 3777 | 3789 | bna_uninit(bna); | |
| 3778 | 3790 | spin_unlock_irqrestore(&bnad->bna_lock, flags); | |
modified drivers/net/ethernet/cadence/macb_main.c
| @@ -2421,34 +2421,40 @@ static inline int macb_clear_csum(struct sk_buff *skb) | |||
| 2421 | 2421 | return 0; | |
| 2422 | 2422 | } | |
| 2423 | 2423 | ||
| 2424 | + | static bool macb_needs_sw_fcs(struct sk_buff *skb, struct net_device *netdev) | |
| 2425 | + | { | |
| 2426 | + | return netdev->features & NETIF_F_HW_CSUM && | |
| 2427 | + | skb->ip_summed != CHECKSUM_PARTIAL && | |
| 2428 | + | !skb_shinfo(skb)->gso_size && !ptp_one_step_sync(skb); | |
| 2429 | + | } | |
| 2430 | + | ||
| 2424 | 2431 | /* Returns a negative errno, or the FCS bytes appended (0 or ETH_FCS_LEN). */ | |
| 2425 | - | static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *netdev) | |
| 2432 | + | static int macb_pad_and_fcs(struct sk_buff **skb, bool add_fcs) | |
| 2426 | 2433 | { | |
| 2427 | 2434 | bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) || | |
| 2428 | 2435 | skb_is_nonlinear(*skb); | |
| 2429 | 2436 | int padlen = ETH_ZLEN - (*skb)->len; | |
| 2430 | 2437 | int tailroom = skb_tailroom(*skb); | |
| 2438 | + | bool shared = skb_shared(*skb); | |
| 2431 | 2439 | struct sk_buff *nskb; | |
| 2432 | 2440 | u32 fcs; | |
| 2433 | 2441 | ||
| 2434 | - | if (!(netdev->features & NETIF_F_HW_CSUM) || | |
| 2435 | - | !((*skb)->ip_summed != CHECKSUM_PARTIAL) || | |
| 2436 | - | skb_shinfo(*skb)->gso_size || ptp_one_step_sync(*skb)) | |
| 2442 | + | if (!add_fcs) | |
| 2437 | 2443 | return 0; | |
| 2438 | 2444 | ||
| 2439 | 2445 | if (padlen <= 0) { | |
| 2440 | - | /* FCS could be appeded to tailroom. */ | |
| 2441 | - | if (tailroom >= ETH_FCS_LEN) | |
| 2446 | + | /* FCS could be appended to tailroom. */ | |
| 2447 | + | if (!shared && !skb_is_nonlinear(*skb) && | |
| 2448 | + | tailroom >= ETH_FCS_LEN) | |
| 2442 | 2449 | goto add_fcs; | |
| 2443 | - | /* No room for FCS, need to reallocate skb. */ | |
| 2444 | - | else | |
| 2445 | - | padlen = ETH_FCS_LEN; | |
| 2450 | + | /* Reallocate with room for the FCS. */ | |
| 2451 | + | padlen = ETH_FCS_LEN; | |
| 2446 | 2452 | } else { | |
| 2447 | 2453 | /* Add room for FCS. */ | |
| 2448 | 2454 | padlen += ETH_FCS_LEN; | |
| 2449 | 2455 | } | |
| 2450 | 2456 | ||
| 2451 | - | if (cloned || tailroom < padlen) { | |
| 2457 | + | if (shared || cloned || tailroom < padlen) { | |
| 2452 | 2458 | nskb = skb_copy_expand(*skb, 0, padlen, GFP_ATOMIC); | |
| 2453 | 2459 | if (!nskb) | |
| 2454 | 2460 | return -ENOMEM; | |
| @@ -2481,27 +2487,15 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2481 | 2487 | unsigned int desc_cnt, nr_frags, frag_size, f; | |
| 2482 | 2488 | struct macb_queue *queue = &bp->queues[q]; | |
| 2483 | 2489 | netdev_tx_t ret = NETDEV_TX_OK; | |
| 2484 | - | unsigned int hdrlen; | |
| 2490 | + | unsigned int hdrlen, tx_len; | |
| 2491 | + | bool add_fcs, is_lso; | |
| 2485 | 2492 | unsigned long flags; | |
| 2486 | 2493 | int fcs_len; | |
| 2487 | - | bool is_lso; | |
| 2488 | - | ||
| 2489 | - | if (macb_clear_csum(skb)) { | |
| 2490 | - | dev_kfree_skb_any(skb); | |
| 2491 | - | return ret; | |
| 2492 | - | } | |
| 2493 | - | ||
| 2494 | - | fcs_len = macb_pad_and_fcs(&skb, netdev); | |
| 2495 | - | if (fcs_len < 0) { | |
| 2496 | - | dev_kfree_skb_any(skb); | |
| 2497 | - | return ret; | |
| 2498 | - | } | |
| 2499 | - | ||
| 2500 | - | if (macb_dma_ptp(bp) && | |
| 2501 | - | (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) | |
| 2502 | - | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | |
| 2503 | 2494 | ||
| 2495 | + | add_fcs = macb_needs_sw_fcs(skb, netdev); | |
| 2504 | 2496 | is_lso = (skb_shinfo(skb)->gso_size != 0); | |
| 2497 | + | tx_len = add_fcs ? max_t(unsigned int, skb->len, ETH_ZLEN) + | |
| 2498 | + | ETH_FCS_LEN : skb->len; | |
| 2505 | 2499 | ||
| 2506 | 2500 | if (is_lso) { | |
| 2507 | 2501 | /* length of headers */ | |
| @@ -2515,8 +2509,11 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2515 | 2509 | /* if this is required, would need to copy to single buffer */ | |
| 2516 | 2510 | return NETDEV_TX_BUSY; | |
| 2517 | 2511 | } | |
| 2518 | - | } else | |
| 2512 | + | } else if (add_fcs) { | |
| 2513 | + | hdrlen = umin(tx_len, bp->max_tx_length); | |
| 2514 | + | } else { | |
| 2519 | 2515 | hdrlen = umin(skb_headlen(skb), bp->max_tx_length); | |
| 2516 | + | } | |
| 2520 | 2517 | ||
| 2521 | 2518 | #if defined(DEBUG) && defined(VERBOSE_DEBUG) | |
| 2522 | 2519 | netdev_vdbg(bp->netdev, | |
| @@ -2531,12 +2528,18 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2531 | 2528 | * socket buffer: skb fragments of jumbo frames may need to be | |
| 2532 | 2529 | * split into many buffer descriptors. | |
| 2533 | 2530 | */ | |
| 2534 | - | if (is_lso && (skb_headlen(skb) > hdrlen)) | |
| 2531 | + | if (add_fcs) { | |
| 2532 | + | /* macb_pad_and_fcs() linearizes the skb before adding the FCS. */ | |
| 2533 | + | desc_cnt = DIV_ROUND_UP(tx_len, bp->max_tx_length); | |
| 2534 | + | nr_frags = 0; | |
| 2535 | + | } else if (is_lso && (skb_headlen(skb) > hdrlen)) { | |
| 2535 | 2536 | /* extra header descriptor if also payload in first buffer */ | |
| 2536 | 2537 | desc_cnt = DIV_ROUND_UP((skb_headlen(skb) - hdrlen), bp->max_tx_length) + 1; | |
| 2537 | - | else | |
| 2538 | + | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2539 | + | } else { | |
| 2538 | 2540 | desc_cnt = DIV_ROUND_UP(skb_headlen(skb), bp->max_tx_length); | |
| 2539 | - | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2541 | + | nr_frags = skb_shinfo(skb)->nr_frags; | |
| 2542 | + | } | |
| 2540 | 2543 | for (f = 0; f < nr_frags; f++) { | |
| 2541 | 2544 | frag_size = skb_frag_size(&skb_shinfo(skb)->frags[f]); | |
| 2542 | 2545 | desc_cnt += DIV_ROUND_UP(frag_size, bp->max_tx_length); | |
| @@ -2554,6 +2557,21 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb, | |||
| 2554 | 2557 | goto unlock; | |
| 2555 | 2558 | } | |
| 2556 | 2559 | ||
| 2560 | + | if (macb_clear_csum(skb)) { | |
| 2561 | + | dev_kfree_skb_any(skb); | |
| 2562 | + | goto unlock; | |
| 2563 | + | } | |
| 2564 | + | ||
| 2565 | + | fcs_len = macb_pad_and_fcs(&skb, add_fcs); | |
| 2566 | + | if (fcs_len < 0) { | |
| 2567 | + | dev_kfree_skb_any(skb); | |
| 2568 | + | goto unlock; | |
| 2569 | + | } | |
| 2570 | + | ||
| 2571 | + | if (macb_dma_ptp(bp) && | |
| 2572 | + | (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) | |
| 2573 | + | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | |
| 2574 | + | ||
| 2557 | 2575 | /* Map socket buffer for DMA transfer */ | |
| 2558 | 2576 | if (macb_tx_map(bp, queue, skb, hdrlen, fcs_len)) { | |
| 2559 | 2577 | dev_kfree_skb_any(skb); | |
| @@ -2749,14 +2767,24 @@ static int macb_alloc(struct macb *bp) | |||
| 2749 | 2767 | ||
| 2750 | 2768 | size = bp->num_queues * macb_tx_ring_size_per_queue(bp); | |
| 2751 | 2769 | tx = dma_alloc_coherent(dev, size, &tx_dma, GFP_KERNEL); | |
| 2752 | - | if (!tx || upper_32_bits(tx_dma) != upper_32_bits(tx_dma + size - 1)) | |
| 2770 | + | if (!tx) | |
| 2771 | + | goto out_err; | |
| 2772 | + | /* Record the buffer so that the error path frees it. */ | |
| 2773 | + | bp->queues[0].tx_ring = tx; | |
| 2774 | + | bp->queues[0].tx_ring_dma = tx_dma; | |
| 2775 | + | if (upper_32_bits(tx_dma) != upper_32_bits(tx_dma + size - 1)) | |
| 2753 | 2776 | goto out_err; | |
| 2754 | 2777 | netdev_dbg(bp->netdev, "Allocated %zu bytes for %u TX rings at %08lx (mapped %p)\n", | |
| 2755 | 2778 | size, bp->num_queues, (unsigned long)tx_dma, tx); | |
| 2756 | 2779 | ||
| 2757 | 2780 | size = bp->num_queues * macb_rx_ring_size_per_queue(bp); | |
| 2758 | 2781 | rx = dma_alloc_coherent(dev, size, &rx_dma, GFP_KERNEL); | |
| 2759 | - | if (!rx || upper_32_bits(rx_dma) != upper_32_bits(rx_dma + size - 1)) | |
| 2782 | + | if (!rx) | |
| 2783 | + | goto out_err; | |
| 2784 | + | /* Record the buffer so that the error path frees it. */ | |
| 2785 | + | bp->queues[0].rx_ring = rx; | |
| 2786 | + | bp->queues[0].rx_ring_dma = rx_dma; | |
| 2787 | + | if (upper_32_bits(rx_dma) != upper_32_bits(rx_dma + size - 1)) | |
| 2760 | 2788 | goto out_err; | |
| 2761 | 2789 | netdev_dbg(bp->netdev, "Allocated %zu bytes for %u RX rings at %08lx (mapped %p)\n", | |
| 2762 | 2790 | size, bp->num_queues, (unsigned long)rx_dma, rx); | |
modified drivers/net/ethernet/cadence/macb_ptp.c
| @@ -50,7 +50,12 @@ static int gem_tsu_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts, | |||
| 50 | 50 | ||
| 51 | 51 | spin_lock_irqsave(&bp->tsu_clk_lock, flags); | |
| 52 | 52 | ptp_read_system_prets(sts); | |
| 53 | + | /* explicit barriers are needed because gem_readl() is relaxed */ | |
| 54 | + | if (sts) | |
| 55 | + | rmb(); | |
| 53 | 56 | first = gem_readl(bp, TN); | |
| 57 | + | if (sts) | |
| 58 | + | rmb(); | |
| 54 | 59 | ptp_read_system_postts(sts); | |
| 55 | 60 | secl = gem_readl(bp, TSL); | |
| 56 | 61 | sech = gem_readl(bp, TSH); | |
| @@ -62,7 +67,11 @@ static int gem_tsu_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts, | |||
| 62 | 67 | * (assume all done within 1s) | |
| 63 | 68 | */ | |
| 64 | 69 | ptp_read_system_prets(sts); | |
| 70 | + | if (sts) | |
| 71 | + | rmb(); | |
| 65 | 72 | ts->tv_nsec = gem_readl(bp, TN); | |
| 73 | + | if (sts) | |
| 74 | + | rmb(); | |
| 66 | 75 | ptp_read_system_postts(sts); | |
| 67 | 76 | secl = gem_readl(bp, TSL); | |
| 68 | 77 | sech = gem_readl(bp, TSH); | |
modified drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c
| @@ -389,7 +389,7 @@ static void chcr_ktls_dev_del(struct net_device *netdev, | |||
| 389 | 389 | cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, | |
| 390 | 390 | tx_info->tid, tx_info->ip_family); | |
| 391 | 391 | ||
| 392 | - | xa_erase(&u_ctx->tid_list, tx_info->tid); | |
| 392 | + | xa_erase_bh(&u_ctx->tid_list, tx_info->tid); | |
| 393 | 393 | } | |
| 394 | 394 | ||
| 395 | 395 | port_stats = &tx_info->adap->ch_ktls_stats.ktls_port[tx_info->port_id]; | |
| @@ -577,7 +577,7 @@ free_tid: | |||
| 577 | 577 | cxgb4_remove_tid(&tx_info->adap->tids, tx_info->tx_chan, | |
| 578 | 578 | tx_info->tid, tx_info->ip_family); | |
| 579 | 579 | ||
| 580 | - | xa_erase(&u_ctx->tid_list, tx_info->tid); | |
| 580 | + | xa_erase_bh(&u_ctx->tid_list, tx_info->tid); | |
| 581 | 581 | ||
| 582 | 582 | put_module: | |
| 583 | 583 | /* release module refcount */ | |
modified drivers/net/ethernet/cortina/gemini.c
| @@ -1798,7 +1798,7 @@ static irqreturn_t gmac_irq(int irq, void *data) | |||
| 1798 | 1798 | ||
| 1799 | 1799 | if (val & (GMAC0_RX_OVERRUN_INT_BIT << (netdev->dev_id * 8))) { | |
| 1800 | 1800 | spin_lock(&geth->irq_lock); | |
| 1801 | - | writel(GMAC0_RXDERR_INT_BIT << (netdev->dev_id * 8), | |
| 1801 | + | writel(GMAC0_RX_OVERRUN_INT_BIT << (netdev->dev_id * 8), | |
| 1802 | 1802 | geth->base + GLOBAL_INTERRUPT_STATUS_4_REG); | |
| 1803 | 1803 | u64_stats_update_begin(&port->ir_stats_syncp); | |
| 1804 | 1804 | ++port->stats.rx_fifo_errors; | |
modified drivers/net/ethernet/freescale/fman/fman.c
| @@ -2734,6 +2734,7 @@ static struct fman *read_dts_node(struct platform_device *of_dev) | |||
| 2734 | 2734 | } | |
| 2735 | 2735 | ||
| 2736 | 2736 | clk_rate = clk_get_rate(clk); | |
| 2737 | + | clk_put(clk); | |
| 2737 | 2738 | if (!clk_rate) { | |
| 2738 | 2739 | err = -EINVAL; | |
| 2739 | 2740 | dev_err(&of_dev->dev, "%s: Failed to determine FM%d clock rate\n", | |
modified drivers/net/ethernet/google/gve/gve_desc_dqo.h
| @@ -14,6 +14,11 @@ | |||
| 14 | 14 | #define GVE_TX_MAX_HDR_SIZE_DQO 255 | |
| 15 | 15 | #define GVE_TX_MIN_TSO_MSS_DQO 88 | |
| 16 | 16 | ||
| 17 | + | /* HW limit. This also has to fit in the 14 bits of the mss field of | |
| 18 | + | * struct gve_tx_tso_context_desc_dqo. | |
| 19 | + | */ | |
| 20 | + | #define GVE_TX_MAX_TSO_MSS_DQO 9728 | |
| 21 | + | ||
| 17 | 22 | #ifndef __LITTLE_ENDIAN_BITFIELD | |
| 18 | 23 | #error "Only little endian supported" | |
| 19 | 24 | #endif | |
modified drivers/net/ethernet/google/gve/gve_main.c
| @@ -1708,17 +1708,17 @@ static int gve_xsk_pool_disable(struct net_device *dev, | |||
| 1708 | 1708 | } | |
| 1709 | 1709 | ||
| 1710 | 1710 | napi_rx = &priv->ntfy_blocks[priv->rx[qid].ntfy_id].napi; | |
| 1711 | - | napi_disable(napi_rx); /* make sure current rx poll is done */ | |
| 1711 | + | napi_disable_locked(napi_rx); /* make sure current rx poll is done */ | |
| 1712 | 1712 | ||
| 1713 | 1713 | tx_qid = gve_xdp_tx_queue_id(priv, qid); | |
| 1714 | 1714 | napi_tx = &priv->ntfy_blocks[priv->tx[tx_qid].ntfy_id].napi; | |
| 1715 | - | napi_disable(napi_tx); /* make sure current tx poll is done */ | |
| 1715 | + | napi_disable_locked(napi_tx); /* make sure current tx poll is done */ | |
| 1716 | 1716 | ||
| 1717 | 1717 | gve_unreg_xsk_pool(priv, qid); | |
| 1718 | 1718 | smp_mb(); /* Make sure it is visible to the workers on datapath */ | |
| 1719 | 1719 | ||
| 1720 | - | napi_enable(napi_rx); | |
| 1721 | - | napi_enable(napi_tx); | |
| 1720 | + | napi_enable_locked(napi_rx); | |
| 1721 | + | napi_enable_locked(napi_tx); | |
| 1722 | 1722 | if (gve_is_gqi(priv)) { | |
| 1723 | 1723 | if (gve_rx_work_pending(&priv->rx[qid])) | |
| 1724 | 1724 | napi_schedule(napi_rx); | |
modified drivers/net/ethernet/google/gve/gve_rx_dqo.c
| @@ -113,6 +113,12 @@ static void gve_rx_reset_ring_dqo(struct gve_priv *priv, int idx) | |||
| 113 | 113 | gve_free_to_page_pool(rx, bs, false); | |
| 114 | 114 | else | |
| 115 | 115 | gve_free_qpl_page_dqo(bs); | |
| 116 | + | ||
| 117 | + | if (gve_buf_state_is_allocated(rx, bs) && | |
| 118 | + | bs->xsk_buff) { | |
| 119 | + | xsk_buff_free(bs->xsk_buff); | |
| 120 | + | bs->xsk_buff = NULL; | |
| 121 | + | } | |
| 116 | 122 | } | |
| 117 | 123 | } | |
| 118 | 124 | ||
| @@ -836,7 +842,12 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx, | |||
| 836 | 842 | } | |
| 837 | 843 | ||
| 838 | 844 | if (unlikely(compl_desc->rx_error)) { | |
| 839 | - | gve_free_buffer(rx, buf_state); | |
| 845 | + | if (buf_state->xsk_buff) { | |
| 846 | + | xsk_buff_free(buf_state->xsk_buff); | |
| 847 | + | gve_free_buf_state(rx, buf_state); | |
| 848 | + | } else { | |
| 849 | + | gve_free_buffer(rx, buf_state); | |
| 850 | + | } | |
| 840 | 851 | return -EINVAL; | |
| 841 | 852 | } | |
| 842 | 853 | ||
modified drivers/net/ethernet/google/gve/gve_tx_dqo.c
| @@ -577,40 +577,43 @@ static int gve_prep_tso(struct sk_buff *skb) | |||
| 577 | 577 | int header_len; | |
| 578 | 578 | int err; | |
| 579 | 579 | ||
| 580 | - | /* Note: HW requires MSS (gso_size) to be <= 9728 and the total length | |
| 581 | - | * of the TSO to be <= 262143. | |
| 580 | + | /* Note: HW requires the total length of the TSO to be <= 262143, | |
| 581 | + | * this is enforced by netif_set_tso_max_size(). | |
| 582 | 582 | * | |
| 583 | - | * However, we don't validate these because: | |
| 584 | - | * - Hypervisor enforces a limit of 9K MTU | |
| 585 | - | * - Kernel will not produce a TSO larger than 64k | |
| 583 | + | * MSS (gso_size) can not be trusted: packets forwarded from a tap or | |
| 584 | + | * injected by a packet socket can carry an arbitrary value, while the | |
| 585 | + | * mss field of the TSO context descriptor is only 14 bits wide. | |
| 586 | + | * | |
| 587 | + | * A too big MSS is dropped here instead of being rejected from | |
| 588 | + | * gve_features_check_dqo(), because software segmentation would | |
| 589 | + | * produce packets larger than the device can send. | |
| 586 | 590 | */ | |
| 587 | - | ||
| 588 | - | if (unlikely(shinfo->gso_size < GVE_TX_MIN_TSO_MSS_DQO)) | |
| 591 | + | if (unlikely(shinfo->gso_size > GVE_TX_MAX_TSO_MSS_DQO)) | |
| 589 | 592 | return -1; | |
| 590 | 593 | ||
| 591 | 594 | /* Needed because we will modify header. */ | |
| 592 | 595 | err = skb_cow_head(skb, 0); | |
| 593 | 596 | if (err < 0) | |
| 594 | 597 | return err; | |
| 598 | + | shinfo = skb_shinfo(skb); | |
| 595 | 599 | ||
| 596 | 600 | l4_start = skb_transport_offset(skb); | |
| 597 | 601 | paylen = skb->len - l4_start; | |
| 598 | 602 | ||
| 599 | - | switch (shinfo->gso_type) { | |
| 600 | - | case SKB_GSO_TCPV4: | |
| 601 | - | case SKB_GSO_TCPV6: | |
| 603 | + | /* gso_type is a bitmask: SKB_GSO_DODGY, SKB_GSO_TCP_ECN and | |
| 604 | + | * SKB_GSO_TCP_FIXEDID may be set alongside the protocol bit. | |
| 605 | + | */ | |
| 606 | + | if (shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) { | |
| 602 | 607 | tcp = tcp_hdr(skb); | |
| 603 | 608 | csum_replace_by_diff(&tcp->check, | |
| 604 | 609 | (__force __wsum)htonl(paylen)); | |
| 605 | 610 | header_len = skb_tcp_all_headers(skb); | |
| 606 | - | break; | |
| 607 | - | case SKB_GSO_UDP_L4: | |
| 611 | + | } else if (shinfo->gso_type & SKB_GSO_UDP_L4) { | |
| 608 | 612 | udp = udp_hdr(skb); | |
| 609 | 613 | csum_replace_by_diff(&udp->check, | |
| 610 | 614 | (__force __wsum)htonl(paylen)); | |
| 611 | 615 | header_len = sizeof(struct udphdr) + l4_start; | |
| 612 | - | break; | |
| 613 | - | default: | |
| 616 | + | } else { | |
| 614 | 617 | return -EINVAL; | |
| 615 | 618 | } | |
| 616 | 619 | ||
| @@ -918,13 +921,22 @@ static bool gve_can_send_tso(const struct sk_buff *skb) | |||
| 918 | 921 | { | |
| 919 | 922 | const int max_bufs_per_seg = GVE_TX_MAX_DATA_DESCS - 1; | |
| 920 | 923 | const struct skb_shared_info *shinfo = skb_shinfo(skb); | |
| 921 | - | const int header_len = skb_tcp_all_headers(skb); | |
| 922 | 924 | const int gso_size = shinfo->gso_size; | |
| 923 | 925 | int cur_seg_num_bufs; | |
| 924 | 926 | int prev_frag_size; | |
| 925 | 927 | int cur_seg_size; | |
| 928 | + | int header_len; | |
| 926 | 929 | int i; | |
| 927 | 930 | ||
| 931 | + | if (unlikely(gso_size < GVE_TX_MIN_TSO_MSS_DQO)) | |
| 932 | + | return false; | |
| 933 | + | ||
| 934 | + | /* Must match the header length programmed by gve_prep_tso(). */ | |
| 935 | + | if (skb_is_gso_tcp(skb)) | |
| 936 | + | header_len = skb_tcp_all_headers(skb); | |
| 937 | + | else | |
| 938 | + | header_len = skb_transport_offset(skb) + sizeof(struct udphdr); | |
| 939 | + | ||
| 928 | 940 | cur_seg_size = skb_headlen(skb) - header_len; | |
| 929 | 941 | prev_frag_size = skb_headlen(skb); | |
| 930 | 942 | cur_seg_num_bufs = cur_seg_size > 0; | |
| @@ -966,7 +978,17 @@ netdev_features_t gve_features_check_dqo(struct sk_buff *skb, | |||
| 966 | 978 | struct net_device *dev, | |
| 967 | 979 | netdev_features_t features) | |
| 968 | 980 | { | |
| 969 | - | if (skb_is_gso(skb) && !gve_can_send_tso(skb)) | |
| 981 | + | if (!skb_is_gso(skb)) | |
| 982 | + | return features; | |
| 983 | + | ||
| 984 | + | /* Keep the GSO bits for a too big MSS, so that gve_prep_tso() drops | |
| 985 | + | * the packet: software segmentation would give packets larger than | |
| 986 | + | * the device can send. | |
| 987 | + | */ | |
| 988 | + | if (skb_shinfo(skb)->gso_size > GVE_TX_MAX_TSO_MSS_DQO) | |
| 989 | + | return features; | |
| 990 | + | ||
| 991 | + | if (!gve_can_send_tso(skb)) | |
| 970 | 992 | return features & ~NETIF_F_GSO_MASK; | |
| 971 | 993 | ||
| 972 | 994 | return features; | |
modified drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
| @@ -793,6 +793,7 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) | |||
| 793 | 793 | dev_err(mac_cb->dev, | |
| 794 | 794 | "mac%d mdio is NULL, dsaf will probe again later\n", | |
| 795 | 795 | mac_cb->mac_id); | |
| 796 | + | put_device(&pdev->dev); | |
| 796 | 797 | return -EPROBE_DEFER; | |
| 797 | 798 | } | |
| 798 | 799 | ||
| @@ -801,6 +802,8 @@ static int hns_mac_register_phy(struct hns_mac_cb *mac_cb) | |||
| 801 | 802 | dev_dbg(mac_cb->dev, "mac%d register phy addr:%d\n", | |
| 802 | 803 | mac_cb->mac_id, addr); | |
| 803 | 804 | ||
| 805 | + | put_device(&pdev->dev); | |
| 806 | + | ||
| 804 | 807 | return rc; | |
| 805 | 808 | } | |
| 806 | 809 | ||
modified drivers/net/ethernet/ibm/emac/core.c
| @@ -3044,6 +3044,15 @@ static int emac_probe(struct platform_device *ofdev) | |||
| 3044 | 3044 | if (err) | |
| 3045 | 3045 | goto err_gone; | |
| 3046 | 3046 | ||
| 3047 | + | if (emac_phy_supports_gige(dev->phy_mode)) { | |
| 3048 | + | ndev->netdev_ops = &emac_gige_netdev_ops; | |
| 3049 | + | dev->commac.ops = &emac_commac_sg_ops; | |
| 3050 | + | } else { | |
| 3051 | + | ndev->netdev_ops = &emac_netdev_ops; | |
| 3052 | + | dev->commac.ops = &emac_commac_ops; | |
| 3053 | + | } | |
| 3054 | + | ndev->ethtool_ops = &emac_ethtool_ops; | |
| 3055 | + | ||
| 3047 | 3056 | dev->emacp = devm_platform_ioremap_resource(ofdev, 0); | |
| 3048 | 3057 | if (IS_ERR(dev->emacp)) { | |
| 3049 | 3058 | err = PTR_ERR(dev->emacp); | |
| @@ -3076,7 +3085,6 @@ static int emac_probe(struct platform_device *ofdev) | |||
| 3076 | 3085 | dev->mdio_instance = platform_get_drvdata(dev->mdio_dev); | |
| 3077 | 3086 | ||
| 3078 | 3087 | /* Register with MAL */ | |
| 3079 | - | dev->commac.ops = &emac_commac_ops; | |
| 3080 | 3088 | dev->commac.dev = dev; | |
| 3081 | 3089 | dev->commac.tx_chan_mask = MAL_CHAN_MASK(dev->mal_tx_chan); | |
| 3082 | 3090 | dev->commac.rx_chan_mask = MAL_CHAN_MASK(dev->mal_rx_chan); | |
| @@ -3144,12 +3152,6 @@ static int emac_probe(struct platform_device *ofdev) | |||
| 3144 | 3152 | ndev->features |= ndev->hw_features | NETIF_F_RXCSUM; | |
| 3145 | 3153 | } | |
| 3146 | 3154 | ndev->watchdog_timeo = 5 * HZ; | |
| 3147 | - | if (emac_phy_supports_gige(dev->phy_mode)) { | |
| 3148 | - | ndev->netdev_ops = &emac_gige_netdev_ops; | |
| 3149 | - | dev->commac.ops = &emac_commac_sg_ops; | |
| 3150 | - | } else | |
| 3151 | - | ndev->netdev_ops = &emac_netdev_ops; | |
| 3152 | - | ndev->ethtool_ops = &emac_ethtool_ops; | |
| 3153 | 3155 | ||
| 3154 | 3156 | /* MTU range: 46 - 1500 or whatever is in OF */ | |
| 3155 | 3157 | ndev->min_mtu = EMAC_MIN_MTU; | |
modified drivers/net/ethernet/ibm/ibmveth.c
| @@ -553,10 +553,15 @@ static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter, | |||
| 553 | 553 | ||
| 554 | 554 | static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx) | |
| 555 | 555 | { | |
| 556 | + | void *ptr = adapter->tx_ltb_ptr[idx]; | |
| 557 | + | ||
| 558 | + | if (!ptr) | |
| 559 | + | return; | |
| 560 | + | ||
| 561 | + | adapter->tx_ltb_ptr[idx] = NULL; | |
| 556 | 562 | dma_unmap_single(&adapter->vdev->dev, adapter->tx_ltb_dma[idx], | |
| 557 | 563 | adapter->tx_ltb_size, DMA_TO_DEVICE); | |
| 558 | - | kfree(adapter->tx_ltb_ptr[idx]); | |
| 559 | - | adapter->tx_ltb_ptr[idx] = NULL; | |
| 564 | + | kfree(ptr); | |
| 560 | 565 | } | |
| 561 | 566 | ||
| 562 | 567 | static int ibmveth_allocate_tx_ltb(struct ibmveth_adapter *adapter, int idx) | |
| @@ -667,7 +672,7 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 667 | 672 | ||
| 668 | 673 | for (i = 0; i < netdev->real_num_tx_queues; i++) { | |
| 669 | 674 | if (ibmveth_allocate_tx_ltb(adapter, i)) | |
| 670 | - | goto out_free_tx_ltb; | |
| 675 | + | goto out_unmap_filter_list; | |
| 671 | 676 | } | |
| 672 | 677 | ||
| 673 | 678 | adapter->rx_queue.index = 0; | |
| @@ -718,10 +723,6 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 718 | 723 | if (rc != 0) { | |
| 719 | 724 | netdev_err(netdev, "unable to request irq 0x%x, rc %d\n", | |
| 720 | 725 | netdev->irq, rc); | |
| 721 | - | do { | |
| 722 | - | lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); | |
| 723 | - | } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); | |
| 724 | - | ||
| 725 | 726 | goto out_free_buffer_pools; | |
| 726 | 727 | } | |
| 727 | 728 | ||
| @@ -737,6 +738,9 @@ static int ibmveth_open(struct net_device *netdev) | |||
| 737 | 738 | return 0; | |
| 738 | 739 | ||
| 739 | 740 | out_free_buffer_pools: | |
| 741 | + | do { | |
| 742 | + | lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); | |
| 743 | + | } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY)); | |
| 740 | 744 | while (--i >= 0) { | |
| 741 | 745 | if (adapter->rx_buff_pool[i].active) | |
| 742 | 746 | ibmveth_free_buffer_pool(adapter, | |
| @@ -746,10 +750,8 @@ out_unmap_filter_list: | |||
| 746 | 750 | dma_unmap_single(dev, adapter->filter_list_dma, 4096, | |
| 747 | 751 | DMA_BIDIRECTIONAL); | |
| 748 | 752 | ||
| 749 | - | out_free_tx_ltb: | |
| 750 | - | while (--i >= 0) { | |
| 753 | + | for (i = netdev->real_num_tx_queues - 1; i >= 0; i--) | |
| 751 | 754 | ibmveth_free_tx_ltb(adapter, i); | |
| 752 | - | } | |
| 753 | 755 | ||
| 754 | 756 | out_unmap_buffer_list: | |
| 755 | 757 | dma_unmap_single(dev, adapter->buffer_list_dma, 4096, | |
modified drivers/net/ethernet/intel/e1000e/netdev.c
| @@ -67,6 +67,13 @@ static const struct dmi_system_id disable_k1_list[] = { | |||
| 67 | 67 | DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro 16 Plus PB16250"), | |
| 68 | 68 | }, | |
| 69 | 69 | }, | |
| 70 | + | { | |
| 71 | + | .ident = "Lenovo ThinkPad P14s Gen 5", | |
| 72 | + | .matches = { | |
| 73 | + | DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), | |
| 74 | + | DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad P14s Gen 5"), | |
| 75 | + | }, | |
| 76 | + | }, | |
| 70 | 77 | {} | |
| 71 | 78 | }; | |
| 72 | 79 | ||
modified drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
| @@ -4943,6 +4943,20 @@ out: | |||
| 4943 | 4943 | return ret; | |
| 4944 | 4944 | } | |
| 4945 | 4945 | ||
| 4946 | + | /** | |
| 4947 | + | * i40e_setup_vf_trust - Enable/disable VF trust mode without reset | |
| 4948 | + | * @vf: VF to configure | |
| 4949 | + | * @setting: trust setting | |
| 4950 | + | * | |
| 4951 | + | * Update VF flags when changing trust without performing a VF reset. | |
| 4952 | + | * This is only called when it's safe to skip the reset (VF has no advanced | |
| 4953 | + | * features configured that need cleanup). | |
| 4954 | + | */ | |
| 4955 | + | static void i40e_setup_vf_trust(struct i40e_vf *vf, bool setting) | |
| 4956 | + | { | |
| 4957 | + | assign_bit(I40E_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps, setting); | |
| 4958 | + | } | |
| 4959 | + | ||
| 4946 | 4960 | /** | |
| 4947 | 4961 | * i40e_ndo_set_vf_trust | |
| 4948 | 4962 | * @netdev: network interface device structure of the pf | |
| @@ -4987,19 +5001,20 @@ int i40e_ndo_set_vf_trust(struct net_device *netdev, int vf_id, bool setting) | |||
| 4987 | 5001 | set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); | |
| 4988 | 5002 | pf->vsi[vf->lan_vsi_idx]->flags |= I40E_VSI_FLAG_FILTER_CHANGED; | |
| 4989 | 5003 | ||
| 4990 | - | i40e_vc_reset_vf(vf, true); | |
| 5004 | + | /* Reset only if revoking trust and VF has advanced features configured */ | |
| 5005 | + | if (!setting && | |
| 5006 | + | (vf->adq_enabled || vf->num_cloud_filters > 0 || | |
| 5007 | + | test_bit(I40E_VF_STATE_UC_PROMISC, &vf->vf_states) || | |
| 5008 | + | test_bit(I40E_VF_STATE_MC_PROMISC, &vf->vf_states))) { | |
| 5009 | + | i40e_vc_reset_vf(vf, true); | |
| 5010 | + | i40e_del_all_cloud_filters(vf); | |
| 5011 | + | } else { | |
| 5012 | + | i40e_setup_vf_trust(vf, setting); | |
| 5013 | + | } | |
| 5014 | + | ||
| 4991 | 5015 | dev_info(&pf->pdev->dev, "VF %u is now %strusted\n", | |
| 4992 | 5016 | vf_id, setting ? "" : "un"); | |
| 4993 | 5017 | ||
| 4994 | - | if (vf->adq_enabled) { | |
| 4995 | - | if (!vf->trusted) { | |
| 4996 | - | dev_info(&pf->pdev->dev, | |
| 4997 | - | "VF %u no longer Trusted, deleting all cloud filters\n", | |
| 4998 | - | vf_id); | |
| 4999 | - | i40e_del_all_cloud_filters(vf); | |
| 5000 | - | } | |
| 5001 | - | } | |
| 5002 | - | ||
| 5003 | 5018 | out: | |
| 5004 | 5019 | clear_bit(__I40E_VIRTCHNL_OP_PENDING, pf->state); | |
| 5005 | 5020 | return ret; | |
modified drivers/net/ethernet/intel/iavf/iavf.h
| @@ -259,7 +259,6 @@ struct iavf_adapter { | |||
| 259 | 259 | struct work_struct adminq_task; | |
| 260 | 260 | struct work_struct finish_config; | |
| 261 | 261 | wait_queue_head_t down_waitqueue; | |
| 262 | - | wait_queue_head_t vc_waitqueue; | |
| 263 | 262 | struct iavf_q_vector *q_vectors; | |
| 264 | 263 | struct list_head vlan_filter_list; | |
| 265 | 264 | int num_vlan_filters; | |
| @@ -588,8 +587,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter); | |||
| 588 | 587 | void iavf_enable_queues(struct iavf_adapter *adapter); | |
| 589 | 588 | void iavf_disable_queues(struct iavf_adapter *adapter); | |
| 590 | 589 | void iavf_map_queues(struct iavf_adapter *adapter); | |
| 591 | - | void iavf_add_ether_addrs(struct iavf_adapter *adapter); | |
| 590 | + | int iavf_add_ether_addrs(struct iavf_adapter *adapter); | |
| 592 | 591 | void iavf_del_ether_addrs(struct iavf_adapter *adapter); | |
| 592 | + | void iavf_mac_add_reject(struct iavf_adapter *adapter); | |
| 593 | 593 | void iavf_add_vlans(struct iavf_adapter *adapter); | |
| 594 | 594 | void iavf_del_vlans(struct iavf_adapter *adapter); | |
| 595 | 595 | void iavf_set_promiscuous(struct iavf_adapter *adapter); | |
| @@ -606,6 +606,13 @@ void iavf_disable_vlan_stripping(struct iavf_adapter *adapter); | |||
| 606 | 606 | void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |
| 607 | 607 | enum virtchnl_ops v_opcode, | |
| 608 | 608 | enum iavf_status v_retval, u8 *msg, u16 msglen); | |
| 609 | + | int iavf_poll_virtchnl_response(struct iavf_adapter *adapter, | |
| 610 | + | struct iavf_arq_event_info *event, | |
| 611 | + | bool (*condition)(struct iavf_adapter *adapter, | |
| 612 | + | const void *data, | |
| 613 | + | enum virtchnl_ops v_op), | |
| 614 | + | const void *cond_data, | |
| 615 | + | unsigned int timeout_ms); | |
| 609 | 616 | int iavf_config_rss(struct iavf_adapter *adapter); | |
| 610 | 617 | void iavf_cfg_queues_bw(struct iavf_adapter *adapter); | |
| 611 | 618 | void iavf_cfg_queues_quanta_size(struct iavf_adapter *adapter); | |
modified drivers/net/ethernet/intel/iavf/iavf_main.c
| @@ -1029,6 +1029,60 @@ static bool iavf_is_mac_set_handled(struct net_device *netdev, | |||
| 1029 | 1029 | return ret; | |
| 1030 | 1030 | } | |
| 1031 | 1031 | ||
| 1032 | + | /** | |
| 1033 | + | * iavf_mac_change_done - Check if MAC change completed | |
| 1034 | + | * @adapter: board private structure | |
| 1035 | + | * @data: MAC address being checked (as const void *) | |
| 1036 | + | * @v_op: virtchnl opcode from processed message | |
| 1037 | + | * | |
| 1038 | + | * Callback for iavf_poll_virtchnl_response() to check if MAC change completed. | |
| 1039 | + | * | |
| 1040 | + | * Return: true if MAC change completed, false otherwise | |
| 1041 | + | */ | |
| 1042 | + | static bool iavf_mac_change_done(struct iavf_adapter *adapter, | |
| 1043 | + | const void *data, enum virtchnl_ops v_op) | |
| 1044 | + | { | |
| 1045 | + | const u8 *addr = data; | |
| 1046 | + | ||
| 1047 | + | return iavf_is_mac_set_handled(adapter->netdev, addr); | |
| 1048 | + | } | |
| 1049 | + | ||
| 1050 | + | /** | |
| 1051 | + | * iavf_set_mac_sync - Synchronously change MAC address | |
| 1052 | + | * @adapter: board private structure | |
| 1053 | + | * @addr: MAC address to set | |
| 1054 | + | * | |
| 1055 | + | * Send MAC change request to PF and poll admin queue for response. | |
| 1056 | + | * Caller must hold netdev_lock. This can sleep for up to 2.5 seconds. | |
| 1057 | + | * Event buffer is allocated before sending to avoid state mismatch if | |
| 1058 | + | * allocation fails after message is sent to PF. | |
| 1059 | + | * | |
| 1060 | + | * Return: 0 on success, negative on failure | |
| 1061 | + | */ | |
| 1062 | + | static int iavf_set_mac_sync(struct iavf_adapter *adapter, const u8 *addr) | |
| 1063 | + | { | |
| 1064 | + | struct iavf_arq_event_info event; | |
| 1065 | + | int ret; | |
| 1066 | + | ||
| 1067 | + | netdev_assert_locked(adapter->netdev); | |
| 1068 | + | ||
| 1069 | + | event.buf_len = IAVF_MAX_AQ_BUF_SIZE; | |
| 1070 | + | event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL); | |
| 1071 | + | if (!event.msg_buf) | |
| 1072 | + | return -ENOMEM; | |
| 1073 | + | ||
| 1074 | + | ret = iavf_add_ether_addrs(adapter); | |
| 1075 | + | if (ret) | |
| 1076 | + | goto out; | |
| 1077 | + | ||
| 1078 | + | ret = iavf_poll_virtchnl_response(adapter, &event, | |
| 1079 | + | iavf_mac_change_done, addr, 2500); | |
| 1080 | + | ||
| 1081 | + | out: | |
| 1082 | + | kfree(event.msg_buf); | |
| 1083 | + | return ret; | |
| 1084 | + | } | |
| 1085 | + | ||
| 1032 | 1086 | /** | |
| 1033 | 1087 | * iavf_set_mac - NDO callback to set port MAC address | |
| 1034 | 1088 | * @netdev: network interface device structure | |
| @@ -1046,25 +1100,23 @@ static int iavf_set_mac(struct net_device *netdev, void *p) | |||
| 1046 | 1100 | return -EADDRNOTAVAIL; | |
| 1047 | 1101 | ||
| 1048 | 1102 | ret = iavf_replace_primary_mac(adapter, addr->sa_data); | |
| 1049 | - | ||
| 1050 | 1103 | if (ret) | |
| 1051 | 1104 | return ret; | |
| 1052 | 1105 | ||
| 1053 | - | ret = wait_event_interruptible_timeout(adapter->vc_waitqueue, | |
| 1054 | - | iavf_is_mac_set_handled(netdev, addr->sa_data), | |
| 1055 | - | msecs_to_jiffies(2500)); | |
| 1056 | - | ||
| 1057 | - | /* If ret < 0 then it means wait was interrupted. | |
| 1058 | - | * If ret == 0 then it means we got a timeout. | |
| 1059 | - | * else it means we got response for set MAC from PF, | |
| 1060 | - | * check if netdev MAC was updated to requested MAC, | |
| 1061 | - | * if yes then set MAC succeeded otherwise it failed return -EACCES | |
| 1062 | - | */ | |
| 1063 | - | if (ret < 0) | |
| 1106 | + | ret = iavf_set_mac_sync(adapter, addr->sa_data); | |
| 1107 | + | if (ret) { | |
| 1108 | + | /* Rollback only if send failed (message never reached PF). | |
| 1109 | + | * Don't rollback on timeout (-EAGAIN) because the message was | |
| 1110 | + | * sent and PF will eventually respond. When the response arrives, | |
| 1111 | + | * iavf_virtchnl_completion() will handle rollback (on PF error) | |
| 1112 | + | * or acceptance (on PF success) automatically. | |
| 1113 | + | */ | |
| 1114 | + | if (ret != -EAGAIN) { | |
| 1115 | + | iavf_mac_add_reject(adapter); | |
| 1116 | + | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); | |
| 1117 | + | } | |
| 1064 | 1118 | return ret; | |
| 1065 | - | ||
| 1066 | - | if (!ret) | |
| 1067 | - | return -EAGAIN; | |
| 1119 | + | } | |
| 1068 | 1120 | ||
| 1069 | 1121 | if (!ether_addr_equal(netdev->dev_addr, addr->sa_data)) | |
| 1070 | 1122 | return -EACCES; | |
| @@ -5394,9 +5446,6 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 5394 | 5446 | /* Setup the wait queue for indicating transition to down status */ | |
| 5395 | 5447 | init_waitqueue_head(&adapter->down_waitqueue); | |
| 5396 | 5448 | ||
| 5397 | - | /* Setup the wait queue for indicating virtchannel events */ | |
| 5398 | - | init_waitqueue_head(&adapter->vc_waitqueue); | |
| 5399 | - | ||
| 5400 | 5449 | INIT_LIST_HEAD(&adapter->ptp.aq_cmds); | |
| 5401 | 5450 | init_waitqueue_head(&adapter->ptp.phc_time_waitqueue); | |
| 5402 | 5451 | mutex_init(&adapter->ptp.aq_cmd_lock); | |
modified drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | /* Copyright(c) 2013 - 2018 Intel Corporation. */ | |
| 3 | 3 | ||
| 4 | 4 | #include <linux/net/intel/libie/rx.h> | |
| 5 | + | #include <net/netdev_lock.h> | |
| 5 | 6 | ||
| 6 | 7 | #include "iavf.h" | |
| 7 | 8 | #include "iavf_ptp.h" | |
| @@ -555,20 +556,23 @@ iavf_set_mac_addr_type(struct virtchnl_ether_addr *virtchnl_ether_addr, | |||
| 555 | 556 | * @adapter: adapter structure | |
| 556 | 557 | * | |
| 557 | 558 | * Request that the PF add one or more addresses to our filters. | |
| 558 | - | **/ | |
| 559 | - | void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |
| 559 | + | * | |
| 560 | + | * Return: 0 on success, negative on failure | |
| 561 | + | */ | |
| 562 | + | int iavf_add_ether_addrs(struct iavf_adapter *adapter) | |
| 560 | 563 | { | |
| 561 | 564 | struct virtchnl_ether_addr_list *veal; | |
| 562 | 565 | struct iavf_mac_filter *f; | |
| 563 | 566 | int i = 0, count = 0; | |
| 564 | 567 | bool more = false; | |
| 565 | 568 | size_t len; | |
| 569 | + | int ret; | |
| 566 | 570 | ||
| 567 | 571 | if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) { | |
| 568 | 572 | /* bail because we already have a command pending */ | |
| 569 | 573 | dev_err(&adapter->pdev->dev, "Cannot add filters, command %d pending\n", | |
| 570 | 574 | adapter->current_op); | |
| 571 | - | return; | |
| 575 | + | return -EBUSY; | |
| 572 | 576 | } | |
| 573 | 577 | ||
| 574 | 578 | spin_lock_bh(&adapter->mac_vlan_list_lock); | |
| @@ -580,7 +584,7 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 580 | 584 | if (!count) { | |
| 581 | 585 | adapter->aq_required &= ~IAVF_FLAG_AQ_ADD_MAC_FILTER; | |
| 582 | 586 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 583 | - | return; | |
| 587 | + | return 0; | |
| 584 | 588 | } | |
| 585 | 589 | adapter->current_op = VIRTCHNL_OP_ADD_ETH_ADDR; | |
| 586 | 590 | ||
| @@ -594,8 +598,9 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 594 | 598 | ||
| 595 | 599 | veal = kzalloc(len, GFP_ATOMIC); | |
| 596 | 600 | if (!veal) { | |
| 601 | + | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 597 | 602 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 598 | - | return; | |
| 603 | + | return -ENOMEM; | |
| 599 | 604 | } | |
| 600 | 605 | ||
| 601 | 606 | veal->vsi_id = adapter->vsi_res->vsi_id; | |
| @@ -615,8 +620,15 @@ void iavf_add_ether_addrs(struct iavf_adapter *adapter) | |||
| 615 | 620 | ||
| 616 | 621 | spin_unlock_bh(&adapter->mac_vlan_list_lock); | |
| 617 | 622 | ||
| 618 | - | iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len); | |
| 623 | + | ret = iavf_send_pf_msg(adapter, VIRTCHNL_OP_ADD_ETH_ADDR, (u8 *)veal, len); | |
| 619 | 624 | kfree(veal); | |
| 625 | + | if (ret) { | |
| 626 | + | dev_err(&adapter->pdev->dev, | |
| 627 | + | "Unable to send ADD_ETH_ADDR message to PF, error %d\n", ret); | |
| 628 | + | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 629 | + | } | |
| 630 | + | ||
| 631 | + | return ret; | |
| 620 | 632 | } | |
| 621 | 633 | ||
| 622 | 634 | /** | |
| @@ -712,8 +724,8 @@ static void iavf_mac_add_ok(struct iavf_adapter *adapter) | |||
| 712 | 724 | * @adapter: adapter structure | |
| 713 | 725 | * | |
| 714 | 726 | * Remove filters from list based on PF response. | |
| 715 | - | **/ | |
| 716 | - | static void iavf_mac_add_reject(struct iavf_adapter *adapter) | |
| 727 | + | */ | |
| 728 | + | void iavf_mac_add_reject(struct iavf_adapter *adapter) | |
| 717 | 729 | { | |
| 718 | 730 | struct net_device *netdev = adapter->netdev; | |
| 719 | 731 | struct iavf_mac_filter *f, *ftmp; | |
| @@ -2364,7 +2376,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2364 | 2376 | iavf_mac_add_reject(adapter); | |
| 2365 | 2377 | /* restore administratively set MAC address */ | |
| 2366 | 2378 | ether_addr_copy(adapter->hw.mac.addr, netdev->dev_addr); | |
| 2367 | - | wake_up(&adapter->vc_waitqueue); | |
| 2368 | 2379 | break; | |
| 2369 | 2380 | case VIRTCHNL_OP_DEL_ETH_ADDR: | |
| 2370 | 2381 | dev_err(&adapter->pdev->dev, "Failed to delete MAC filter, error %s\n", | |
| @@ -2555,7 +2566,6 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2555 | 2566 | eth_hw_addr_set(netdev, adapter->hw.mac.addr); | |
| 2556 | 2567 | netif_addr_unlock_bh(netdev); | |
| 2557 | 2568 | } | |
| 2558 | - | wake_up(&adapter->vc_waitqueue); | |
| 2559 | 2569 | break; | |
| 2560 | 2570 | case VIRTCHNL_OP_GET_STATS: { | |
| 2561 | 2571 | struct iavf_eth_stats *stats = | |
| @@ -2950,3 +2960,72 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, | |||
| 2950 | 2960 | } /* switch v_opcode */ | |
| 2951 | 2961 | adapter->current_op = VIRTCHNL_OP_UNKNOWN; | |
| 2952 | 2962 | } | |
| 2963 | + | ||
| 2964 | + | /** | |
| 2965 | + | * iavf_poll_virtchnl_response - Poll admin queue for virtchnl response | |
| 2966 | + | * @adapter: adapter structure | |
| 2967 | + | * @event: pre-allocated event buffer to use for polling | |
| 2968 | + | * @condition: callback to check if desired response received | |
| 2969 | + | * @cond_data: context data passed to condition callback | |
| 2970 | + | * @timeout_ms: maximum time to wait in milliseconds | |
| 2971 | + | * | |
| 2972 | + | * Polls the admin queue and processes all incoming virtchnl messages. | |
| 2973 | + | * After processing each valid message, calls the condition callback to check | |
| 2974 | + | * if the expected response has been received. The callback receives the opcode | |
| 2975 | + | * of the processed message to identify which response was received. Continues | |
| 2976 | + | * polling until the callback returns true or timeout expires. | |
| 2977 | + | * | |
| 2978 | + | * Caller must allocate event buffer before sending any messages to PF to avoid | |
| 2979 | + | * state mismatch if allocation fails after message is sent. | |
| 2980 | + | * | |
| 2981 | + | * Caller must hold netdev_lock. This can sleep for up to timeout_ms while | |
| 2982 | + | * polling hardware. | |
| 2983 | + | * | |
| 2984 | + | * Return: 0 on success (condition met), -EAGAIN on timeout, or error code | |
| 2985 | + | */ | |
| 2986 | + | int iavf_poll_virtchnl_response(struct iavf_adapter *adapter, | |
| 2987 | + | struct iavf_arq_event_info *event, | |
| 2988 | + | bool (*condition)(struct iavf_adapter *adapter, | |
| 2989 | + | const void *data, | |
| 2990 | + | enum virtchnl_ops v_op), | |
| 2991 | + | const void *cond_data, | |
| 2992 | + | unsigned int timeout_ms) | |
| 2993 | + | { | |
| 2994 | + | struct iavf_hw *hw = &adapter->hw; | |
| 2995 | + | enum virtchnl_ops received_op; | |
| 2996 | + | unsigned long timeout; | |
| 2997 | + | int ret = -EAGAIN; | |
| 2998 | + | u16 pending = 0; | |
| 2999 | + | u32 v_retval; | |
| 3000 | + | ||
| 3001 | + | netdev_assert_locked(adapter->netdev); | |
| 3002 | + | ||
| 3003 | + | timeout = jiffies + msecs_to_jiffies(timeout_ms); | |
| 3004 | + | do { | |
| 3005 | + | if (!pending) | |
| 3006 | + | usleep_range(50, 75); | |
| 3007 | + | ||
| 3008 | + | if (iavf_clean_arq_element(hw, event, &pending) == IAVF_SUCCESS) { | |
| 3009 | + | received_op = (enum virtchnl_ops)le32_to_cpu(event->desc.cookie_high); | |
| 3010 | + | if (received_op != VIRTCHNL_OP_UNKNOWN) { | |
| 3011 | + | v_retval = le32_to_cpu(event->desc.cookie_low); | |
| 3012 | + | ||
| 3013 | + | iavf_virtchnl_completion(adapter, received_op, | |
| 3014 | + | (enum iavf_status)v_retval, | |
| 3015 | + | event->msg_buf, event->msg_len); | |
| 3016 | + | ||
| 3017 | + | if (condition(adapter, cond_data, received_op)) { | |
| 3018 | + | ret = 0; | |
| 3019 | + | break; | |
| 3020 | + | } | |
| 3021 | + | } | |
| 3022 | + | ||
| 3023 | + | memset(event->msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE); | |
| 3024 | + | ||
| 3025 | + | if (pending) | |
| 3026 | + | continue; | |
| 3027 | + | } | |
| 3028 | + | } while (time_before(jiffies, timeout)); | |
| 3029 | + | ||
| 3030 | + | return ret; | |
| 3031 | + | } | |
modified drivers/net/ethernet/intel/ice/devlink/port.c
| @@ -590,8 +590,8 @@ static void ice_dealloc_dynamic_port(struct ice_dynamic_port *dyn_port) | |||
| 590 | 590 | ||
| 591 | 591 | xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); | |
| 592 | 592 | ice_eswitch_detach_sf(pf, dyn_port); | |
| 593 | - | ice_vsi_free(dyn_port->vsi); | |
| 594 | 593 | xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); | |
| 594 | + | ice_vsi_free(dyn_port->vsi); | |
| 595 | 595 | kfree(dyn_port); | |
| 596 | 596 | } | |
| 597 | 597 | ||
modified drivers/net/ethernet/intel/ice/ice_eswitch.c
| @@ -95,7 +95,7 @@ ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr) | |||
| 95 | 95 | return; | |
| 96 | 96 | ||
| 97 | 97 | ice_vsi_update_security(vsi, ice_vsi_ctx_set_antispoof); | |
| 98 | - | metadata_dst_free(repr->dst); | |
| 98 | + | dst_release(&repr->dst->dst); | |
| 99 | 99 | repr->dst = NULL; | |
| 100 | 100 | ice_fltr_add_mac_and_broadcast(vsi, repr->parent_mac, | |
| 101 | 101 | ICE_FWD_TO_VSI); | |
modified drivers/net/ethernet/intel/ice/ice_sriov.c
| @@ -1366,6 +1366,20 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) | |||
| 1366 | 1366 | return __ice_set_vf_mac(ice_netdev_to_pf(netdev), vf_id, mac); | |
| 1367 | 1367 | } | |
| 1368 | 1368 | ||
| 1369 | + | /** | |
| 1370 | + | * ice_setup_vf_trust - Enable/disable VF trust mode without reset | |
| 1371 | + | * @vf: VF to configure | |
| 1372 | + | * @setting: trust setting | |
| 1373 | + | * | |
| 1374 | + | * Update VF flags when changing trust without performing a VF reset. | |
| 1375 | + | * This is only called when it's safe to skip the reset (VF has no advanced | |
| 1376 | + | * features configured that need cleanup). | |
| 1377 | + | */ | |
| 1378 | + | static void ice_setup_vf_trust(struct ice_vf *vf, bool setting) | |
| 1379 | + | { | |
| 1380 | + | assign_bit(ICE_VIRTCHNL_VF_CAP_PRIVILEGE, &vf->vf_caps, setting); | |
| 1381 | + | } | |
| 1382 | + | ||
| 1369 | 1383 | /** | |
| 1370 | 1384 | * ice_set_vf_trust | |
| 1371 | 1385 | * @netdev: network interface device structure | |
| @@ -1401,11 +1415,19 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) | |||
| 1401 | 1415 | ||
| 1402 | 1416 | mutex_lock(&vf->cfg_lock); | |
| 1403 | 1417 | ||
| 1404 | - | while (!trusted && vf->num_mac_lldp) | |
| 1405 | - | ice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false); | |
| 1406 | - | ||
| 1407 | - | vf->trusted = trusted; | |
| 1408 | - | ice_reset_vf(vf, ICE_VF_RESET_NOTIFY); | |
| 1418 | + | /* Reset only if revoking trust and VF has advanced features configured */ | |
| 1419 | + | if (!trusted && | |
| 1420 | + | (vf->num_mac_lldp > 0 || | |
| 1421 | + | test_bit(ICE_VF_STATE_UC_PROMISC, vf->vf_states) || | |
| 1422 | + | test_bit(ICE_VF_STATE_MC_PROMISC, vf->vf_states))) { | |
| 1423 | + | while (vf->num_mac_lldp) | |
| 1424 | + | ice_vf_update_mac_lldp_num(vf, ice_get_vf_vsi(vf), false); | |
| 1425 | + | vf->trusted = trusted; | |
| 1426 | + | ice_reset_vf(vf, ICE_VF_RESET_NOTIFY); | |
| 1427 | + | } else { | |
| 1428 | + | vf->trusted = trusted; | |
| 1429 | + | ice_setup_vf_trust(vf, trusted); | |
| 1430 | + | } | |
| 1409 | 1431 | dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", | |
| 1410 | 1432 | vf_id, trusted ? "" : "un"); | |
| 1411 | 1433 | ||
modified drivers/net/ethernet/intel/ice/ice_txrx.c
| @@ -1561,10 +1561,10 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first, | |||
| 1561 | 1561 | } | |
| 1562 | 1562 | } | |
| 1563 | 1563 | tstamp_ring->next_to_use = j; | |
| 1564 | - | writel_relaxed(j, tstamp_ring->tail); | |
| 1564 | + | writel(j, tstamp_ring->tail); | |
| 1565 | 1565 | } else { | |
| 1566 | 1566 | ring_kick: | |
| 1567 | - | writel_relaxed(i, tx_ring->tail); | |
| 1567 | + | writel(i, tx_ring->tail); | |
| 1568 | 1568 | } | |
| 1569 | 1569 | return; | |
| 1570 | 1570 | ||
modified drivers/net/ethernet/marvell/mvneta.c
| @@ -2340,7 +2340,7 @@ mvneta_swbm_rx_frame(struct mvneta_port *pp, | |||
| 2340 | 2340 | ||
| 2341 | 2341 | /* Prefetch header */ | |
| 2342 | 2342 | prefetch(data); | |
| 2343 | - | xdp_buff_clear_frags_flag(xdp); | |
| 2343 | + | xdp_reinit_buff(xdp); | |
| 2344 | 2344 | xdp_prepare_buff(xdp, data, pp->rx_offset_correction + MVNETA_MH_SIZE, | |
| 2345 | 2345 | data_len, true); | |
| 2346 | 2346 | } | |
modified drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
| @@ -5086,7 +5086,8 @@ static int mvpp2_change_mtu(struct net_device *dev, int mtu) | |||
| 5086 | 5086 | netdev_warn(dev, "mtu %d too high, switching to shared buffers", mtu); | |
| 5087 | 5087 | mvpp2_bm_switch_buffers(priv, false); | |
| 5088 | 5088 | } | |
| 5089 | - | } else { | |
| 5089 | + | } else if (priv->hw_version >= MVPP22 && | |
| 5090 | + | mvpp2_get_nrxqs(priv) * 2 <= MVPP2_BM_MAX_POOLS) { | |
| 5090 | 5091 | bool jumbo = false; | |
| 5091 | 5092 | int i; | |
| 5092 | 5093 | ||
modified drivers/net/ethernet/marvell/octeontx2/af/common.h
| @@ -7,6 +7,10 @@ | |||
| 7 | 7 | #ifndef COMMON_H | |
| 8 | 8 | #define COMMON_H | |
| 9 | 9 | ||
| 10 | + | #include <linux/dma-mapping.h> | |
| 11 | + | #include <linux/gfp.h> | |
| 12 | + | #include <linux/mm.h> | |
| 13 | + | ||
| 10 | 14 | #include "rvu_struct.h" | |
| 11 | 15 | ||
| 12 | 16 | #define OTX2_ALIGN 128 /* Align to cacheline */ | |
| @@ -44,6 +48,33 @@ struct qmem { | |||
| 44 | 48 | u32 qsize; | |
| 45 | 49 | }; | |
| 46 | 50 | ||
| 51 | + | static inline void *otx2_dma_alloc_coherent(struct device *dev, size_t size, | |
| 52 | + | dma_addr_t *dma_handle) | |
| 53 | + | { | |
| 54 | + | dma_addr_t dma_addr; | |
| 55 | + | void *vaddr; | |
| 56 | + | ||
| 57 | + | vaddr = kzalloc(size, GFP_KERNEL); | |
| 58 | + | if (!vaddr) | |
| 59 | + | return NULL; | |
| 60 | + | ||
| 61 | + | dma_addr = dma_map_single(dev, vaddr, size, DMA_BIDIRECTIONAL); | |
| 62 | + | if (dma_mapping_error(dev, dma_addr)) { | |
| 63 | + | kfree(vaddr); | |
| 64 | + | return NULL; | |
| 65 | + | } | |
| 66 | + | ||
| 67 | + | *dma_handle = dma_addr; | |
| 68 | + | return vaddr; | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | static inline void otx2_dma_free_coherent(struct device *dev, size_t size, | |
| 72 | + | void *vaddr, dma_addr_t dma_handle) | |
| 73 | + | { | |
| 74 | + | dma_unmap_single(dev, dma_handle, size, DMA_BIDIRECTIONAL); | |
| 75 | + | kfree(vaddr); | |
| 76 | + | } | |
| 77 | + | ||
| 47 | 78 | static inline int qmem_alloc(struct device *dev, struct qmem **q, | |
| 48 | 79 | int qsize, int entry_sz) | |
| 49 | 80 | { | |
| @@ -60,8 +91,11 @@ static inline int qmem_alloc(struct device *dev, struct qmem **q, | |||
| 60 | 91 | ||
| 61 | 92 | qmem->entry_sz = entry_sz; | |
| 62 | 93 | qmem->alloc_sz = (qsize * entry_sz) + OTX2_ALIGN; | |
| 63 | - | qmem->base = dma_alloc_attrs(dev, qmem->alloc_sz, &qmem->iova, | |
| 64 | - | GFP_KERNEL, DMA_ATTR_FORCE_CONTIGUOUS); | |
| 94 | + | ||
| 95 | + | if (get_order(PAGE_ALIGN(qmem->alloc_sz)) > MAX_PAGE_ORDER) | |
| 96 | + | return -ENOMEM; | |
| 97 | + | ||
| 98 | + | qmem->base = otx2_dma_alloc_coherent(dev, qmem->alloc_sz, &qmem->iova); | |
| 65 | 99 | if (!qmem->base) | |
| 66 | 100 | return -ENOMEM; | |
| 67 | 101 | ||
| @@ -80,10 +114,9 @@ static inline void qmem_free(struct device *dev, struct qmem *qmem) | |||
| 80 | 114 | return; | |
| 81 | 115 | ||
| 82 | 116 | if (qmem->base) | |
| 83 | - | dma_free_attrs(dev, qmem->alloc_sz, | |
| 84 | - | qmem->base - qmem->align, | |
| 85 | - | qmem->iova - qmem->align, | |
| 86 | - | DMA_ATTR_FORCE_CONTIGUOUS); | |
| 117 | + | otx2_dma_free_coherent(dev, qmem->alloc_sz, | |
| 118 | + | qmem->base - qmem->align, | |
| 119 | + | qmem->iova - qmem->align); | |
| 87 | 120 | devm_kfree(dev, qmem); | |
| 88 | 121 | } | |
| 89 | 122 | ||
modified drivers/net/ethernet/marvell/octeontx2/af/mcs.c
| @@ -314,7 +314,7 @@ int mcs_clear_all_stats(struct mcs *mcs, u16 pcifunc, int dir) | |||
| 314 | 314 | } | |
| 315 | 315 | ||
| 316 | 316 | /* Clear SC stats */ | |
| 317 | - | for (id = 0; id < map->secy.max; id++) { | |
| 317 | + | for (id = 0; id < map->sc.max; id++) { | |
| 318 | 318 | if (map->sc2pf_map[id] != pcifunc) | |
| 319 | 319 | continue; | |
| 320 | 320 | mcs_clear_stats(mcs, MCS_SC_STATS, id, dir); | |
| @@ -738,7 +738,7 @@ int mcs_free_all_rsrc(struct mcs *mcs, int dir, u16 pcifunc) | |||
| 738 | 738 | } | |
| 739 | 739 | ||
| 740 | 740 | /* free sc entries */ | |
| 741 | - | for (id = 0; id < map->secy.max; id++) { | |
| 741 | + | for (id = 0; id < map->sc.max; id++) { | |
| 742 | 742 | if (map->sc2pf_map[id] != pcifunc) | |
| 743 | 743 | continue; | |
| 744 | 744 | mcs_free_rsrc(&map->sc, map->sc2pf_map, id, pcifunc); | |
modified drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
| @@ -714,110 +714,72 @@ static int get_max_column_width(struct rvu *rvu) | |||
| 714 | 714 | } | |
| 715 | 715 | ||
| 716 | 716 | /* Dumps current provisioning status of all RVU block LFs */ | |
| 717 | - | static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | |
| 718 | - | char __user *buffer, | |
| 719 | - | size_t count, loff_t *ppos) | |
| 717 | + | static int rvu_dbg_rsrc_attach_status(struct seq_file *filp, void *unused) | |
| 720 | 718 | { | |
| 721 | - | int index, off = 0, flag = 0, len = 0, i = 0; | |
| 722 | - | struct rvu *rvu = filp->private_data; | |
| 723 | - | int bytes_not_copied = 0; | |
| 719 | + | struct rvu *rvu = filp->private; | |
| 720 | + | int index, pf, vf, pcifunc; | |
| 724 | 721 | struct rvu_block block; | |
| 725 | - | int pf, vf, pcifunc; | |
| 726 | - | int buf_size = 2048; | |
| 727 | 722 | int lf_str_size; | |
| 728 | 723 | char *lfs; | |
| 729 | - | char *buf; | |
| 730 | - | ||
| 731 | - | /* don't allow partial reads */ | |
| 732 | - | if (*ppos != 0) | |
| 733 | - | return 0; | |
| 734 | - | ||
| 735 | - | buf = kzalloc(buf_size, GFP_KERNEL); | |
| 736 | - | if (!buf) | |
| 737 | - | return -ENOMEM; | |
| 738 | 724 | ||
| 739 | - | /* Get the maximum width of a column */ | |
| 740 | 725 | lf_str_size = get_max_column_width(rvu); | |
| 726 | + | if (lf_str_size < 0) | |
| 727 | + | return lf_str_size; | |
| 741 | 728 | ||
| 742 | 729 | lfs = kzalloc(lf_str_size, GFP_KERNEL); | |
| 743 | - | if (!lfs) { | |
| 744 | - | kfree(buf); | |
| 730 | + | if (!lfs) | |
| 745 | 731 | return -ENOMEM; | |
| 746 | - | } | |
| 747 | - | off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size, | |
| 748 | - | "pcifunc"); | |
| 749 | - | for (index = 0; index < BLK_COUNT; index++) | |
| 750 | - | if (strlen(rvu->hw->block[index].name)) { | |
| 751 | - | off += scnprintf(&buf[off], buf_size - 1 - off, | |
| 752 | - | "%-*s", lf_str_size, | |
| 753 | - | rvu->hw->block[index].name); | |
| 754 | - | } | |
| 755 | 732 | ||
| 756 | - | off += scnprintf(&buf[off], buf_size - 1 - off, "\n"); | |
| 757 | - | bytes_not_copied = copy_to_user(buffer + (i * off), buf, off); | |
| 758 | - | if (bytes_not_copied) | |
| 759 | - | goto out; | |
| 733 | + | seq_printf(filp, "%-*s", lf_str_size, "pcifunc"); | |
| 734 | + | for (index = 0; index < BLK_COUNT; index++) | |
| 735 | + | if (strlen(rvu->hw->block[index].name)) | |
| 736 | + | seq_printf(filp, "%-*s", lf_str_size, | |
| 737 | + | rvu->hw->block[index].name); | |
| 760 | 738 | ||
| 761 | - | i++; | |
| 762 | - | *ppos += off; | |
| 739 | + | seq_putc(filp, '\n'); | |
| 763 | 740 | for (pf = 0; pf < rvu->hw->total_pfs; pf++) { | |
| 764 | 741 | for (vf = 0; vf <= rvu->hw->total_vfs; vf++) { | |
| 765 | - | off = 0; | |
| 766 | - | flag = 0; | |
| 767 | 742 | pcifunc = rvu_make_pcifunc(rvu->pdev, pf, vf); | |
| 768 | 743 | if (!pcifunc) | |
| 769 | 744 | continue; | |
| 770 | 745 | ||
| 771 | - | if (vf) { | |
| 746 | + | for (index = 0; index < BLK_COUNT; index++) { | |
| 747 | + | block = rvu->hw->block[index]; | |
| 748 | + | if (!strlen(block.name)) | |
| 749 | + | continue; | |
| 750 | + | lfs[0] = '\0'; | |
| 751 | + | get_lf_str_list(&block, pcifunc, lfs); | |
| 752 | + | if (strlen(lfs)) | |
| 753 | + | break; | |
| 754 | + | } | |
| 755 | + | if (index == BLK_COUNT) | |
| 756 | + | continue; | |
| 757 | + | ||
| 758 | + | if (vf) | |
| 772 | 759 | sprintf(lfs, "PF%d:VF%d", pf, vf - 1); | |
| 773 | - | off = scnprintf(&buf[off], | |
| 774 | - | buf_size - 1 - off, | |
| 775 | - | "%-*s", lf_str_size, lfs); | |
| 776 | - | } else { | |
| 760 | + | else | |
| 777 | 761 | sprintf(lfs, "PF%d", pf); | |
| 778 | - | off = scnprintf(&buf[off], | |
| 779 | - | buf_size - 1 - off, | |
| 780 | - | "%-*s", lf_str_size, lfs); | |
| 781 | - | } | |
| 762 | + | seq_printf(filp, "%-*s", lf_str_size, lfs); | |
| 782 | 763 | ||
| 783 | 764 | for (index = 0; index < BLK_COUNT; index++) { | |
| 784 | 765 | block = rvu->hw->block[index]; | |
| 785 | 766 | if (!strlen(block.name)) | |
| 786 | 767 | continue; | |
| 787 | - | len = 0; | |
| 788 | - | lfs[len] = '\0'; | |
| 789 | - | get_lf_str_list(&block, pcifunc, lfs); | |
| 790 | - | if (strlen(lfs)) | |
| 791 | - | flag = 1; | |
| 792 | 768 | ||
| 793 | - | off += scnprintf(&buf[off], buf_size - 1 - off, | |
| 794 | - | "%-*s", lf_str_size, lfs); | |
| 795 | - | } | |
| 796 | - | if (flag) { | |
| 797 | - | off += scnprintf(&buf[off], | |
| 798 | - | buf_size - 1 - off, "\n"); | |
| 799 | - | bytes_not_copied = copy_to_user(buffer + | |
| 800 | - | (i * off), | |
| 801 | - | buf, off); | |
| 802 | - | if (bytes_not_copied) | |
| 803 | - | goto out; | |
| 804 | - | ||
| 805 | - | i++; | |
| 806 | - | *ppos += off; | |
| 769 | + | lfs[0] = '\0'; | |
| 770 | + | get_lf_str_list(&block, pcifunc, lfs); | |
| 771 | + | seq_printf(filp, "%-*s", lf_str_size, lfs); | |
| 807 | 772 | } | |
| 773 | + | seq_putc(filp, '\n'); | |
| 808 | 774 | } | |
| 809 | 775 | } | |
| 810 | 776 | ||
| 811 | - | out: | |
| 812 | 777 | kfree(lfs); | |
| 813 | - | kfree(buf); | |
| 814 | - | if (bytes_not_copied) | |
| 815 | - | return -EFAULT; | |
| 816 | 778 | ||
| 817 | - | return *ppos; | |
| 779 | + | return 0; | |
| 818 | 780 | } | |
| 819 | 781 | ||
| 820 | - | RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL); | |
| 782 | + | RVU_DEBUG_SEQ_FOPS(rsrc_status, rsrc_attach_status, NULL); | |
| 821 | 783 | ||
| 822 | 784 | static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused) | |
| 823 | 785 | { | |
modified drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c
| @@ -242,15 +242,6 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs) | |||
| 242 | 242 | ||
| 243 | 243 | #define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100)) /* BP when 85% is full */ | |
| 244 | 244 | ||
| 245 | - | static u8 cn20k_aura_bpid_idx(struct otx2_nic *pfvf, int aura_id) | |
| 246 | - | { | |
| 247 | - | #ifdef CONFIG_DCB | |
| 248 | - | return pfvf->queue_to_pfc_map[aura_id]; | |
| 249 | - | #else | |
| 250 | - | return 0; | |
| 251 | - | #endif | |
| 252 | - | } | |
| 253 | - | ||
| 254 | 245 | static int cn20k_tc_get_entry_index(struct otx2_flow_config *flow_cfg, | |
| 255 | 246 | struct otx2_tc_flow *node) | |
| 256 | 247 | { | |
| @@ -580,7 +571,7 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 580 | 571 | if (pfvf->nix_blkaddr == BLKADDR_NIX1) | |
| 581 | 572 | aq->aura.bp_ena = 1; | |
| 582 | 573 | ||
| 583 | - | bpid_idx = cn20k_aura_bpid_idx(pfvf, aura_id); | |
| 574 | + | bpid_idx = otx2_get_bpid_idx(pfvf, aura_id); | |
| 584 | 575 | aq->aura.bpid = pfvf->bpid[bpid_idx]; | |
| 585 | 576 | ||
| 586 | 577 | /* Set backpressure level for RQ's Aura */ | |
modified drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
| @@ -394,7 +394,7 @@ int otx2_rss_init(struct otx2_nic *pfvf) | |||
| 394 | 394 | struct otx2_rss_info *rss = &pfvf->hw.rss_info; | |
| 395 | 395 | int idx, ret = 0; | |
| 396 | 396 | ||
| 397 | - | rss->rss_size = sizeof(*rss->ind_tbl); | |
| 397 | + | rss->rss_size = ARRAY_SIZE(rss->ind_tbl); | |
| 398 | 398 | ||
| 399 | 399 | /* Init RSS key if it is not setup already */ | |
| 400 | 400 | if (!rss->enable) | |
| @@ -1055,6 +1055,7 @@ int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) | |||
| 1055 | 1055 | struct nix_aq_enq_req *aq; | |
| 1056 | 1056 | struct otx2_cq_queue *cq; | |
| 1057 | 1057 | struct otx2_pool *pool; | |
| 1058 | + | u8 bpid_idx; | |
| 1058 | 1059 | ||
| 1059 | 1060 | cq = &qset->cq[qidx]; | |
| 1060 | 1061 | cq->cq_idx = qidx; | |
| @@ -1132,11 +1133,8 @@ int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) | |||
| 1132 | 1133 | if (!is_otx2_lbkvf(pfvf->pdev)) { | |
| 1133 | 1134 | /* Enable receive CQ backpressure */ | |
| 1134 | 1135 | aq->cq.bp_ena = 1; | |
| 1135 | - | #ifdef CONFIG_DCB | |
| 1136 | - | aq->cq.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[qidx]]; | |
| 1137 | - | #else | |
| 1138 | - | aq->cq.bpid = pfvf->bpid[0]; | |
| 1139 | - | #endif | |
| 1136 | + | bpid_idx = otx2_get_bpid_idx(pfvf, qidx); | |
| 1137 | + | aq->cq.bpid = pfvf->bpid[bpid_idx]; | |
| 1140 | 1138 | ||
| 1141 | 1139 | /* Set backpressure level is same as cq pass level */ | |
| 1142 | 1140 | aq->cq.bp = RQ_PASS_LVL_CQ(pfvf->hw.rq_skid, qset->rqe_cnt); | |
| @@ -1378,6 +1376,7 @@ int otx2_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 1378 | 1376 | { | |
| 1379 | 1377 | struct npa_aq_enq_req *aq; | |
| 1380 | 1378 | struct otx2_pool *pool; | |
| 1379 | + | u8 bpid_idx; | |
| 1381 | 1380 | int err; | |
| 1382 | 1381 | ||
| 1383 | 1382 | pool = &pfvf->qset.pool[pool_id]; | |
| @@ -1433,11 +1432,8 @@ int otx2_aura_aq_init(struct otx2_nic *pfvf, int aura_id, | |||
| 1433 | 1432 | */ | |
| 1434 | 1433 | if (pfvf->nix_blkaddr == BLKADDR_NIX1) | |
| 1435 | 1434 | aq->aura.bp_ena = 1; | |
| 1436 | - | #ifdef CONFIG_DCB | |
| 1437 | - | aq->aura.nix0_bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]]; | |
| 1438 | - | #else | |
| 1439 | - | aq->aura.nix0_bpid = pfvf->bpid[0]; | |
| 1440 | - | #endif | |
| 1435 | + | bpid_idx = otx2_get_bpid_idx(pfvf, aura_id); | |
| 1436 | + | aq->aura.nix0_bpid = pfvf->bpid[bpid_idx]; | |
| 1441 | 1437 | ||
| 1442 | 1438 | /* Set backpressure level for RQ's Aura */ | |
| 1443 | 1439 | aq->aura.bp = RQ_BP_LVL_AURA; | |
modified drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
| @@ -1029,6 +1029,15 @@ static inline int otx2_tc_flower_rule_cnt(struct otx2_nic *pfvf) | |||
| 1029 | 1029 | return pfvf->flow_cfg->nr_flows; | |
| 1030 | 1030 | } | |
| 1031 | 1031 | ||
| 1032 | + | static inline u8 otx2_get_bpid_idx(struct otx2_nic *pfvf, int qidx) | |
| 1033 | + | { | |
| 1034 | + | #ifdef CONFIG_DCB | |
| 1035 | + | if (pfvf->queue_to_pfc_map) | |
| 1036 | + | return pfvf->queue_to_pfc_map[qidx]; | |
| 1037 | + | #endif | |
| 1038 | + | return 0; | |
| 1039 | + | } | |
| 1040 | + | ||
| 1032 | 1041 | /* MSI-X APIs */ | |
| 1033 | 1042 | void otx2_free_cints(struct otx2_nic *pfvf, int n); | |
| 1034 | 1043 | void otx2_set_cints_affinity(struct otx2_nic *pfvf); | |
modified drivers/net/ethernet/mediatek/mtk_eth_soc.c
| @@ -4509,6 +4509,10 @@ static int mtk_unreg_dev(struct mtk_eth *eth) | |||
| 4509 | 4509 | mac = netdev_priv(eth->netdev[i]); | |
| 4510 | 4510 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) | |
| 4511 | 4511 | unregister_netdevice_notifier(&mac->device_notifier); | |
| 4512 | + | ||
| 4513 | + | if (eth->netdev[i]->reg_state != NETREG_REGISTERED) | |
| 4514 | + | continue; | |
| 4515 | + | ||
| 4512 | 4516 | unregister_netdev(eth->netdev[i]); | |
| 4513 | 4517 | } | |
| 4514 | 4518 | ||
| @@ -5337,6 +5341,22 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5337 | 5341 | } | |
| 5338 | 5342 | } | |
| 5339 | 5343 | ||
| 5344 | + | /* we run 2 devices on the same DMA ring so we need a dummy device | |
| 5345 | + | * for NAPI to work. Allocate it before registering the netdevs so a | |
| 5346 | + | * concurrent ndo_open (e.g. netifd bringing the first netdev up the | |
| 5347 | + | * instant it is registered) never observes eth->dummy_dev == NULL in | |
| 5348 | + | * mtk_dma_init() -> mtk_rx_alloc() -> __xdp_rxq_info_reg() (net/core/xdp.c | |
| 5349 | + | * "Missing net_device from driver") and fails the first open. | |
| 5350 | + | */ | |
| 5351 | + | eth->dummy_dev = alloc_netdev_dummy(0); | |
| 5352 | + | if (!eth->dummy_dev) { | |
| 5353 | + | err = -ENOMEM; | |
| 5354 | + | dev_err(eth->dev, "failed to allocated dummy device\n"); | |
| 5355 | + | goto err_unreg_netdev; | |
| 5356 | + | } | |
| 5357 | + | netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); | |
| 5358 | + | netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); | |
| 5359 | + | ||
| 5340 | 5360 | for (i = 0; i < MTK_MAX_DEVS; i++) { | |
| 5341 | 5361 | if (!eth->netdev[i]) | |
| 5342 | 5362 | continue; | |
| @@ -5344,25 +5364,13 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5344 | 5364 | err = register_netdev(eth->netdev[i]); | |
| 5345 | 5365 | if (err) { | |
| 5346 | 5366 | dev_err(eth->dev, "error bringing up device\n"); | |
| 5347 | - | goto err_deinit_ppe; | |
| 5367 | + | goto err_unreg_netdev; | |
| 5348 | 5368 | } else | |
| 5349 | 5369 | netif_info(eth, probe, eth->netdev[i], | |
| 5350 | 5370 | "mediatek frame engine at 0x%08lx, irq %d\n", | |
| 5351 | 5371 | eth->netdev[i]->base_addr, eth->irq[MTK_FE_IRQ_SHARED]); | |
| 5352 | 5372 | } | |
| 5353 | 5373 | ||
| 5354 | - | /* we run 2 devices on the same DMA ring so we need a dummy device | |
| 5355 | - | * for NAPI to work | |
| 5356 | - | */ | |
| 5357 | - | eth->dummy_dev = alloc_netdev_dummy(0); | |
| 5358 | - | if (!eth->dummy_dev) { | |
| 5359 | - | err = -ENOMEM; | |
| 5360 | - | dev_err(eth->dev, "failed to allocated dummy device\n"); | |
| 5361 | - | goto err_unreg_netdev; | |
| 5362 | - | } | |
| 5363 | - | netif_napi_add(eth->dummy_dev, ð->tx_napi, mtk_napi_tx); | |
| 5364 | - | netif_napi_add(eth->dummy_dev, ð->rx_napi, mtk_napi_rx); | |
| 5365 | - | ||
| 5366 | 5374 | platform_set_drvdata(pdev, eth); | |
| 5367 | 5375 | schedule_delayed_work(ð->reset.monitor_work, | |
| 5368 | 5376 | MTK_DMA_MONITOR_TIMEOUT); | |
| @@ -5372,6 +5380,16 @@ static int mtk_probe(struct platform_device *pdev) | |||
| 5372 | 5380 | err_unreg_netdev: | |
| 5373 | 5381 | mtk_unreg_dev(eth); | |
| 5374 | 5382 | err_deinit_ppe: | |
| 5383 | + | /* A netdev opened while probe was still registering can have queued | |
| 5384 | + | * the frame-engine reset worker, which takes rtnl and drives the | |
| 5385 | + | * hardware; cancel it before anything below is torn down. | |
| 5386 | + | */ | |
| 5387 | + | cancel_work_sync(ð->pending_work); | |
| 5388 | + | if (eth->dummy_dev) { | |
| 5389 | + | netif_napi_del(ð->tx_napi); | |
| 5390 | + | netif_napi_del(ð->rx_napi); | |
| 5391 | + | free_netdev(eth->dummy_dev); | |
| 5392 | + | } | |
| 5375 | 5393 | mtk_ppe_deinit(eth); | |
| 5376 | 5394 | mtk_mdio_cleanup(eth); | |
| 5377 | 5395 | err_free_dev: | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/rep/bridge.c
| @@ -85,9 +85,16 @@ mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(struct net_device *dev, struct m | |||
| 85 | 85 | struct net_device *lower_dev; | |
| 86 | 86 | struct list_head *iter; | |
| 87 | 87 | ||
| 88 | - | if (netif_is_lag_master(dev) || mlx5e_eswitch_rep(dev)) | |
| 89 | - | return mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, esw, vport_num, | |
| 90 | - | esw_owner_vhca_id); | |
| 88 | + | if (netif_is_lag_master(dev) || mlx5e_eswitch_rep(dev)) { | |
| 89 | + | struct net_device *rep; | |
| 90 | + | ||
| 91 | + | rep = mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, esw, vport_num, | |
| 92 | + | esw_owner_vhca_id); | |
| 93 | + | if (rep && !mlx5_esw_bridge_port_exists(*vport_num, *esw_owner_vhca_id, | |
| 94 | + | esw->br_offloads)) | |
| 95 | + | return NULL; | |
| 96 | + | return rep; | |
| 97 | + | } | |
| 91 | 98 | ||
| 92 | 99 | netdev_for_each_lower_dev(dev, lower_dev, iter) { | |
| 93 | 100 | struct net_device *rep; | |
| @@ -104,6 +111,28 @@ mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(struct net_device *dev, struct m | |||
| 104 | 111 | return NULL; | |
| 105 | 112 | } | |
| 106 | 113 | ||
| 114 | + | static bool mlx5_esw_bridge_rep_port_lookup(struct net_device *dev, | |
| 115 | + | struct mlx5_esw_bridge_offloads *br_offloads, | |
| 116 | + | u16 *vport_num, u16 *esw_owner_vhca_id) | |
| 117 | + | { | |
| 118 | + | if (!mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, br_offloads->esw, vport_num, | |
| 119 | + | esw_owner_vhca_id)) | |
| 120 | + | return false; | |
| 121 | + | ||
| 122 | + | return mlx5_esw_bridge_port_exists(*vport_num, *esw_owner_vhca_id, br_offloads); | |
| 123 | + | } | |
| 124 | + | ||
| 125 | + | static bool mlx5_esw_bridge_lower_rep_port_lookup(struct net_device *dev, | |
| 126 | + | struct mlx5_esw_bridge_offloads *br_offloads, | |
| 127 | + | u16 *vport_num, u16 *esw_owner_vhca_id) | |
| 128 | + | { | |
| 129 | + | if (!mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(dev, br_offloads->esw, vport_num, | |
| 130 | + | esw_owner_vhca_id)) | |
| 131 | + | return false; | |
| 132 | + | ||
| 133 | + | return mlx5_esw_bridge_port_exists(*vport_num, *esw_owner_vhca_id, br_offloads); | |
| 134 | + | } | |
| 135 | + | ||
| 107 | 136 | static bool mlx5_esw_bridge_is_local(struct net_device *dev, struct net_device *rep, | |
| 108 | 137 | struct mlx5_eswitch *esw) | |
| 109 | 138 | { | |
| @@ -218,8 +247,7 @@ mlx5_esw_bridge_port_obj_add(struct net_device *dev, | |||
| 218 | 247 | u16 vport_num, esw_owner_vhca_id; | |
| 219 | 248 | int err; | |
| 220 | 249 | ||
| 221 | - | if (!mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num, | |
| 222 | - | &esw_owner_vhca_id)) | |
| 250 | + | if (!mlx5_esw_bridge_rep_port_lookup(dev, br_offloads, &vport_num, &esw_owner_vhca_id)) | |
| 223 | 251 | return 0; | |
| 224 | 252 | ||
| 225 | 253 | port_obj_info->handled = true; | |
| @@ -251,8 +279,7 @@ mlx5_esw_bridge_port_obj_del(struct net_device *dev, | |||
| 251 | 279 | const struct switchdev_obj_port_mdb *mdb; | |
| 252 | 280 | u16 vport_num, esw_owner_vhca_id; | |
| 253 | 281 | ||
| 254 | - | if (!mlx5_esw_bridge_rep_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num, | |
| 255 | - | &esw_owner_vhca_id)) | |
| 282 | + | if (!mlx5_esw_bridge_rep_port_lookup(dev, br_offloads, &vport_num, &esw_owner_vhca_id)) | |
| 256 | 283 | return 0; | |
| 257 | 284 | ||
| 258 | 285 | port_obj_info->handled = true; | |
| @@ -283,8 +310,8 @@ mlx5_esw_bridge_port_obj_attr_set(struct net_device *dev, | |||
| 283 | 310 | u16 vport_num, esw_owner_vhca_id; | |
| 284 | 311 | int err = 0; | |
| 285 | 312 | ||
| 286 | - | if (!mlx5_esw_bridge_lower_rep_vport_num_vhca_id_get(dev, br_offloads->esw, &vport_num, | |
| 287 | - | &esw_owner_vhca_id)) | |
| 313 | + | if (!mlx5_esw_bridge_lower_rep_port_lookup(dev, br_offloads, &vport_num, | |
| 314 | + | &esw_owner_vhca_id)) | |
| 288 | 315 | return 0; | |
| 289 | 316 | ||
| 290 | 317 | port_attr_info->handled = true; | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
| @@ -1082,6 +1082,9 @@ mlx5_tc_ct_shared_counter_get(struct mlx5_tc_ct_priv *ct_priv, | |||
| 1082 | 1082 | ||
| 1083 | 1083 | spin_unlock_bh(&ct_priv->ht_lock); | |
| 1084 | 1084 | ||
| 1085 | + | if (rev_entry) | |
| 1086 | + | mlx5_tc_ct_entry_put(rev_entry); | |
| 1087 | + | ||
| 1085 | 1088 | create_counter: | |
| 1086 | 1089 | ||
| 1087 | 1090 | shared_counter = mlx5_tc_ct_counter_create(ct_priv); | |
modified drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
| @@ -293,6 +293,9 @@ static u64 mlx5e_xsk_fill_timestamp(void *_priv) | |||
| 293 | 293 | struct mlx5e_xsk_tx_complete *priv = _priv; | |
| 294 | 294 | u64 ts; | |
| 295 | 295 | ||
| 296 | + | if (!priv->cqe) | |
| 297 | + | return 0; | |
| 298 | + | ||
| 296 | 299 | ts = get_cqe_ts(priv->cqe); | |
| 297 | 300 | ||
| 298 | 301 | if (mlx5_is_real_time_rq(priv->cq->mdev) || mlx5_is_real_time_sq(priv->cq->mdev)) | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
| @@ -1564,14 +1564,14 @@ static void setup_fte_addr6(struct mlx5_flow_spec *spec, | |||
| 1564 | 1564 | memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value, | |
| 1565 | 1565 | outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), saddr, 16); | |
| 1566 | 1566 | memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria, | |
| 1567 | - | outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), dmask, 16); | |
| 1567 | + | outer_headers.src_ipv4_src_ipv6.ipv6_layout.ipv6), smask, 16); | |
| 1568 | 1568 | } | |
| 1569 | 1569 | ||
| 1570 | 1570 | if (!addr6_all_zero(daddr)) { | |
| 1571 | 1571 | memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_value, | |
| 1572 | 1572 | outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), daddr, 16); | |
| 1573 | 1573 | memcpy(MLX5_ADDR_OF(fte_match_param, spec->match_criteria, | |
| 1574 | - | outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), smask, 16); | |
| 1574 | + | outer_headers.dst_ipv4_dst_ipv6.ipv6_layout.ipv6), dmask, 16); | |
| 1575 | 1575 | } | |
| 1576 | 1576 | } | |
| 1577 | 1577 | ||
modified drivers/net/ethernet/mellanox/mlx5/core/en_accel/macsec.c
| @@ -1724,6 +1724,8 @@ void mlx5e_macsec_build_netdev(struct mlx5e_priv *priv) | |||
| 1724 | 1724 | mlx5_core_dbg(priv->mdev, "mlx5e: MACsec acceleration enabled\n"); | |
| 1725 | 1725 | netdev->macsec_ops = &macsec_offload_ops; | |
| 1726 | 1726 | netdev->features |= NETIF_F_HW_MACSEC; | |
| 1727 | + | netdev->hw_features |= NETIF_F_HW_MACSEC; | |
| 1728 | + | netdev->vlan_features |= NETIF_F_HW_MACSEC; | |
| 1727 | 1729 | netif_keep_dst(netdev); | |
| 1728 | 1730 | } | |
| 1729 | 1731 | ||
modified drivers/net/ethernet/mellanox/mlx5/core/en_main.c
| @@ -5851,7 +5851,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) | |||
| 5851 | 5851 | ||
| 5852 | 5852 | netdev->vlan_features |= NETIF_F_SG; | |
| 5853 | 5853 | netdev->vlan_features |= NETIF_F_HW_CSUM; | |
| 5854 | - | netdev->vlan_features |= NETIF_F_HW_MACSEC; | |
| 5855 | 5854 | netdev->vlan_features |= NETIF_F_GRO; | |
| 5856 | 5855 | netdev->vlan_features |= NETIF_F_TSO; | |
| 5857 | 5856 | netdev->vlan_features |= NETIF_F_TSO6; | |
modified drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
| @@ -908,10 +908,12 @@ int mlx5e_poll_ico_cq(struct mlx5e_cq *cq) | |||
| 908 | 908 | } while (!last_wqe); | |
| 909 | 909 | } while ((++i < MLX5E_TX_CQ_POLL_BUDGET) && (cqe = mlx5_cqwq_get_cqe(&cq->wq))); | |
| 910 | 910 | ||
| 911 | - | sq->cc = sqcc; | |
| 912 | - | ||
| 913 | 911 | mlx5_cqwq_update_db_record(&cq->wq); | |
| 914 | 912 | ||
| 913 | + | /* ensure cq space is freed before enabling more cqes */ | |
| 914 | + | dma_wmb(); | |
| 915 | + | ||
| 916 | + | sq->cc = sqcc; | |
| 915 | 917 | return i; | |
| 916 | 918 | } | |
| 917 | 919 | ||
modified drivers/net/ethernet/mellanox/mlx5/core/esw/adj_vport.c
| @@ -11,26 +11,6 @@ int mlx5_esw_adj_vport_modify(struct mlx5_core_dev *dev, u16 vport, | |||
| 11 | 11 | ||
| 12 | 12 | lockdep_assert_held(&dev->priv.eswitch->state_lock); | |
| 13 | 13 | ||
| 14 | - | if (MLX5_CAP_ESW(dev, esw_vport_state_max_tx_speed)) { | |
| 15 | - | u8 op_mod = MLX5_VPORT_STATE_OP_MOD_ESW_VPORT; | |
| 16 | - | struct mlx5_vport *esw_vport; | |
| 17 | - | u32 speed = 0; | |
| 18 | - | int err; | |
| 19 | - | ||
| 20 | - | err = mlx5_query_vport_max_tx_speed(dev, op_mod, vport, | |
| 21 | - | true, &speed, NULL); | |
| 22 | - | if (err) { | |
| 23 | - | esw_vport = mlx5_eswitch_get_vport(dev->priv.eswitch, | |
| 24 | - | vport); | |
| 25 | - | speed = IS_ERR(esw_vport) ? 0 : | |
| 26 | - | esw_vport->agg_max_tx_speed; | |
| 27 | - | mlx5_core_dbg(dev, | |
| 28 | - | "Failed to query vport %d max tx speed, err=%d, using cached %u\n", | |
| 29 | - | vport, err, speed); | |
| 30 | - | } | |
| 31 | - | MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed); | |
| 32 | - | } | |
| 33 | - | ||
| 34 | 14 | MLX5_SET(modify_vport_state_in, in, opcode, | |
| 35 | 15 | MLX5_CMD_OP_MODIFY_VPORT_STATE); | |
| 36 | 16 | MLX5_SET(modify_vport_state_in, in, op_mod, | |
modified drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.c
| @@ -1649,10 +1649,8 @@ int mlx5_esw_bridge_vport_unlink(struct net_device *br_netdev, u16 vport_num, | |||
| 1649 | 1649 | int err; | |
| 1650 | 1650 | ||
| 1651 | 1651 | port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads); | |
| 1652 | - | if (!port) { | |
| 1653 | - | NL_SET_ERR_MSG_MOD(extack, "Port is not attached to any bridge"); | |
| 1654 | - | return -EINVAL; | |
| 1655 | - | } | |
| 1652 | + | if (!port) | |
| 1653 | + | return 0; | |
| 1656 | 1654 | if (port->bridge->ifindex != br_netdev->ifindex) { | |
| 1657 | 1655 | NL_SET_ERR_MSG_MOD(extack, "Port is attached to another bridge"); | |
| 1658 | 1656 | return -EINVAL; | |
| @@ -1682,10 +1680,19 @@ int mlx5_esw_bridge_vport_peer_unlink(struct net_device *br_netdev, u16 vport_nu | |||
| 1682 | 1680 | struct mlx5_esw_bridge_offloads *br_offloads, | |
| 1683 | 1681 | struct netlink_ext_ack *extack) | |
| 1684 | 1682 | { | |
| 1683 | + | if (!MLX5_CAP_ESW(br_offloads->esw->dev, merged_eswitch)) | |
| 1684 | + | return 0; | |
| 1685 | + | ||
| 1685 | 1686 | return mlx5_esw_bridge_vport_unlink(br_netdev, vport_num, esw_owner_vhca_id, br_offloads, | |
| 1686 | 1687 | extack); | |
| 1687 | 1688 | } | |
| 1688 | 1689 | ||
| 1690 | + | bool mlx5_esw_bridge_port_exists(u16 vport_num, u16 esw_owner_vhca_id, | |
| 1691 | + | struct mlx5_esw_bridge_offloads *br_offloads) | |
| 1692 | + | { | |
| 1693 | + | return mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads); | |
| 1694 | + | } | |
| 1695 | + | ||
| 1689 | 1696 | int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid, u16 flags, | |
| 1690 | 1697 | struct mlx5_esw_bridge_offloads *br_offloads, | |
| 1691 | 1698 | struct netlink_ext_ack *extack) | |
modified drivers/net/ethernet/mellanox/mlx5/core/esw/bridge.h
| @@ -80,6 +80,8 @@ int mlx5_esw_bridge_vlan_proto_set(u16 vport_num, u16 esw_owner_vhca_id, u16 pro | |||
| 80 | 80 | struct mlx5_esw_bridge_offloads *br_offloads); | |
| 81 | 81 | int mlx5_esw_bridge_mcast_set(u16 vport_num, u16 esw_owner_vhca_id, bool enable, | |
| 82 | 82 | struct mlx5_esw_bridge_offloads *br_offloads); | |
| 83 | + | bool mlx5_esw_bridge_port_exists(u16 vport_num, u16 esw_owner_vhca_id, | |
| 84 | + | struct mlx5_esw_bridge_offloads *br_offloads); | |
| 83 | 85 | int mlx5_esw_bridge_port_vlan_add(u16 vport_num, u16 esw_owner_vhca_id, u16 vid, u16 flags, | |
| 84 | 86 | struct mlx5_esw_bridge_offloads *br_offloads, | |
| 85 | 87 | struct netlink_ext_ack *extack); | |
modified drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
| @@ -1266,25 +1266,45 @@ void mlx5_lag_remove_devices(struct mlx5_lag *ldev) | |||
| 1266 | 1266 | mlx5_lag_remove_devices_filter(ldev, MLX5_LAG_FILTER_PORTS); | |
| 1267 | 1267 | } | |
| 1268 | 1268 | ||
| 1269 | + | static int mlx5_lag_reload_ib_reps_idx(struct mlx5_lag *ldev, int idx, | |
| 1270 | + | u32 flags) | |
| 1271 | + | { | |
| 1272 | + | struct lag_func *pf = mlx5_lag_pf(ldev, idx); | |
| 1273 | + | struct mlx5_eswitch *esw; | |
| 1274 | + | int ret; | |
| 1275 | + | ||
| 1276 | + | if (pf->dev->priv.flags & flags) | |
| 1277 | + | return 0; | |
| 1278 | + | ||
| 1279 | + | esw = pf->dev->priv.eswitch; | |
| 1280 | + | mlx5_esw_reps_block(esw); | |
| 1281 | + | ret = mlx5_eswitch_reload_ib_reps(esw); | |
| 1282 | + | mlx5_esw_reps_unblock(esw); | |
| 1283 | + | ||
| 1284 | + | return ret; | |
| 1285 | + | } | |
| 1286 | + | ||
| 1269 | 1287 | static int mlx5_lag_reload_ib_reps_unlocked(struct mlx5_lag *ldev, u32 flags, | |
| 1270 | 1288 | u32 filter, bool cont_on_fail) | |
| 1271 | 1289 | { | |
| 1272 | - | struct lag_func *pf; | |
| 1290 | + | int master_idx = mlx5_lag_get_dev_index_by_seq_filter(ldev, MLX5_LAG_P1, | |
| 1291 | + | filter); | |
| 1273 | 1292 | int ret; | |
| 1274 | 1293 | int i; | |
| 1275 | 1294 | ||
| 1295 | + | if (master_idx < 0) | |
| 1296 | + | return -EINVAL; | |
| 1297 | + | ||
| 1298 | + | ret = mlx5_lag_reload_ib_reps_idx(ldev, master_idx, flags); | |
| 1299 | + | if (ret && !cont_on_fail) | |
| 1300 | + | return ret; | |
| 1301 | + | ||
| 1276 | 1302 | mlx5_lag_for_each(i, 0, ldev, filter) { | |
| 1277 | - | pf = mlx5_lag_pf(ldev, i); | |
| 1278 | - | if (!(pf->dev->priv.flags & flags)) { | |
| 1279 | - | struct mlx5_eswitch *esw; | |
| 1280 | - | ||
| 1281 | - | esw = pf->dev->priv.eswitch; | |
| 1282 | - | mlx5_esw_reps_block(esw); | |
| 1283 | - | ret = mlx5_eswitch_reload_ib_reps(esw); | |
| 1284 | - | mlx5_esw_reps_unblock(esw); | |
| 1285 | - | if (ret && !cont_on_fail) | |
| 1286 | - | return ret; | |
| 1287 | - | } | |
| 1303 | + | if (i == master_idx) | |
| 1304 | + | continue; | |
| 1305 | + | ret = mlx5_lag_reload_ib_reps_idx(ldev, i, flags); | |
| 1306 | + | if (ret && !cont_on_fail) | |
| 1307 | + | return ret; | |
| 1288 | 1308 | } | |
| 1289 | 1309 | ||
| 1290 | 1310 | return 0; | |
| @@ -1412,30 +1432,40 @@ static bool mlx5_lag_should_disable_lag(struct mlx5_lag *ldev, bool do_bond) | |||
| 1412 | 1432 | } | |
| 1413 | 1433 | ||
| 1414 | 1434 | #ifdef CONFIG_MLX5_ESWITCH | |
| 1415 | - | static int | |
| 1416 | - | mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed, | |
| 1417 | - | int (*get_speed)(struct mlx5_core_dev *, u32 *)) | |
| 1435 | + | static int mlx5_lag_get_devices_oper_speed(struct mlx5_lag *ldev, | |
| 1436 | + | u32 *sum_speed) | |
| 1418 | 1437 | { | |
| 1419 | - | struct mlx5_core_dev *pf_mdev; | |
| 1420 | - | struct lag_func *pf; | |
| 1421 | 1438 | int pf_idx; | |
| 1422 | - | u32 speed; | |
| 1423 | - | int ret; | |
| 1424 | 1439 | ||
| 1425 | 1440 | *sum_speed = 0; | |
| 1426 | 1441 | mlx5_ldev_for_each(pf_idx, 0, ldev) { | |
| 1442 | + | u8 opmod = MLX5_VPORT_STATE_OP_MOD_VNIC_VPORT; | |
| 1443 | + | struct mlx5_core_dev *pf_mdev; | |
| 1444 | + | struct lag_func *pf; | |
| 1445 | + | u32 speed; | |
| 1446 | + | u8 state; | |
| 1447 | + | int ret; | |
| 1448 | + | ||
| 1427 | 1449 | pf = mlx5_lag_pf(ldev, pf_idx); | |
| 1428 | 1450 | if (!pf) | |
| 1429 | 1451 | continue; | |
| 1430 | 1452 | pf_mdev = pf->dev; | |
| 1431 | 1453 | if (!pf_mdev) | |
| 1432 | 1454 | continue; | |
| 1455 | + | ret = mlx5_query_vport_max_tx_speed(pf_mdev, opmod, 0, 0, | |
| 1456 | + | &speed, &state); | |
| 1457 | + | if (ret) { | |
| 1458 | + | mlx5_core_dbg(pf_mdev, "State query failed (err=%d)\n", | |
| 1459 | + | ret); | |
| 1460 | + | return ret; | |
| 1461 | + | } | |
| 1462 | + | if (state != VPORT_STATE_UP) | |
| 1463 | + | continue; | |
| 1433 | 1464 | ||
| 1434 | - | ret = get_speed(pf_mdev, &speed); | |
| 1465 | + | ret = mlx5_port_oper_linkspeed(pf_mdev, &speed); | |
| 1435 | 1466 | if (ret) { | |
| 1436 | 1467 | mlx5_core_dbg(pf_mdev, | |
| 1437 | - | "Failed to get device speed using %ps. Device %s speed is not available (err=%d)\n", | |
| 1438 | - | get_speed, dev_name(pf_mdev->device), | |
| 1468 | + | "Failed to get oper speed (err=%d)\n", | |
| 1439 | 1469 | ret); | |
| 1440 | 1470 | return ret; | |
| 1441 | 1471 | } | |
| @@ -1446,17 +1476,42 @@ mlx5_lag_sum_devices_speed(struct mlx5_lag *ldev, u32 *sum_speed, | |||
| 1446 | 1476 | return 0; | |
| 1447 | 1477 | } | |
| 1448 | 1478 | ||
| 1449 | - | static int mlx5_lag_sum_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed) | |
| 1479 | + | static int mlx5_lag_get_devices_max_speed(struct mlx5_lag *ldev, u32 *max_speed) | |
| 1450 | 1480 | { | |
| 1451 | - | return mlx5_lag_sum_devices_speed(ldev, max_speed, | |
| 1452 | - | mlx5_port_max_linkspeed); | |
| 1453 | - | } | |
| 1481 | + | bool take_max; | |
| 1482 | + | int pf_idx; | |
| 1454 | 1483 | ||
| 1455 | - | static int mlx5_lag_sum_devices_oper_speed(struct mlx5_lag *ldev, | |
| 1456 | - | u32 *oper_speed) | |
| 1457 | - | { | |
| 1458 | - | return mlx5_lag_sum_devices_speed(ldev, oper_speed, | |
| 1459 | - | mlx5_port_oper_linkspeed); | |
| 1484 | + | take_max = ldev->tracker.tx_type == NETDEV_LAG_TX_TYPE_ACTIVEBACKUP; | |
| 1485 | + | if (ldev->mode == MLX5_LAG_MODE_MPESW) | |
| 1486 | + | take_max = false; | |
| 1487 | + | ||
| 1488 | + | *max_speed = 0; | |
| 1489 | + | mlx5_ldev_for_each(pf_idx, 0, ldev) { | |
| 1490 | + | struct mlx5_core_dev *pf_mdev; | |
| 1491 | + | struct lag_func *pf; | |
| 1492 | + | u32 speed; | |
| 1493 | + | int ret; | |
| 1494 | + | ||
| 1495 | + | pf = mlx5_lag_pf(ldev, pf_idx); | |
| 1496 | + | if (!pf) | |
| 1497 | + | continue; | |
| 1498 | + | pf_mdev = pf->dev; | |
| 1499 | + | if (!pf_mdev) | |
| 1500 | + | continue; | |
| 1501 | + | ||
| 1502 | + | ret = mlx5_port_max_linkspeed(pf_mdev, &speed); | |
| 1503 | + | if (ret) { | |
| 1504 | + | mlx5_core_dbg(pf_mdev, | |
| 1505 | + | "Failed to get max speed (err=%d)\n", | |
| 1506 | + | ret); | |
| 1507 | + | return ret; | |
| 1508 | + | } | |
| 1509 | + | ||
| 1510 | + | *max_speed = take_max ? | |
| 1511 | + | max(*max_speed, speed) : *max_speed + speed; | |
| 1512 | + | } | |
| 1513 | + | ||
| 1514 | + | return 0; | |
| 1460 | 1515 | } | |
| 1461 | 1516 | ||
| 1462 | 1517 | static void mlx5_lag_modify_device_vports_speed(struct mlx5_core_dev *mdev, | |
| @@ -1505,7 +1560,7 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev) | |||
| 1505 | 1560 | int pf_idx; | |
| 1506 | 1561 | ||
| 1507 | 1562 | if (ldev->mode == MLX5_LAG_MODE_MPESW) { | |
| 1508 | - | if (mlx5_lag_sum_devices_oper_speed(ldev, &speed)) | |
| 1563 | + | if (mlx5_lag_get_devices_oper_speed(ldev, &speed)) | |
| 1509 | 1564 | return; | |
| 1510 | 1565 | } else { | |
| 1511 | 1566 | speed = ldev->tracker.bond_speed_mbps; | |
| @@ -1513,8 +1568,8 @@ void mlx5_lag_set_vports_agg_speed(struct mlx5_lag *ldev) | |||
| 1513 | 1568 | return; | |
| 1514 | 1569 | } | |
| 1515 | 1570 | ||
| 1516 | - | /* If speed is not set, use the sum of max speeds of all PFs */ | |
| 1517 | - | if (!speed && mlx5_lag_sum_devices_max_speed(ldev, &speed)) | |
| 1571 | + | /* If speed is not set, fall back to the max achievable speed */ | |
| 1572 | + | if (!speed && mlx5_lag_get_devices_max_speed(ldev, &speed)) | |
| 1518 | 1573 | return; | |
| 1519 | 1574 | ||
| 1520 | 1575 | speed = speed / MLX5_MAX_TX_SPEED_UNIT; | |
| @@ -1923,9 +1978,11 @@ static int mlx5_handle_changeupper_event(struct mlx5_lag *ldev, | |||
| 1923 | 1978 | } | |
| 1924 | 1979 | } | |
| 1925 | 1980 | if (i < MLX5_MAX_PORTS) { | |
| 1926 | - | slave = bond_slave_get_rcu(ndev_tmp); | |
| 1927 | - | if (slave) | |
| 1928 | - | has_inactive |= bond_is_slave_inactive(slave); | |
| 1981 | + | if (netif_is_bond_master(upper)) { | |
| 1982 | + | slave = bond_slave_get_rcu(ndev_tmp); | |
| 1983 | + | if (slave) | |
| 1984 | + | has_inactive |= bond_is_slave_inactive(slave); | |
| 1985 | + | } | |
| 1929 | 1986 | bond_status |= (1 << idx); | |
| 1930 | 1987 | } | |
| 1931 | 1988 | ||
| @@ -2009,7 +2066,7 @@ static int mlx5_handle_changeinfodata_event(struct mlx5_lag *ldev, | |||
| 2009 | 2066 | bool has_inactive = 0; | |
| 2010 | 2067 | int idx; | |
| 2011 | 2068 | ||
| 2012 | - | if (!netif_is_lag_master(ndev)) | |
| 2069 | + | if (!netif_is_bond_master(ndev)) | |
| 2013 | 2070 | return 0; | |
| 2014 | 2071 | ||
| 2015 | 2072 | rcu_read_lock(); | |
modified drivers/net/ethernet/mellanox/mlx5/core/lib/devcom.c
| @@ -37,6 +37,7 @@ struct mlx5_devcom_comp { | |||
| 37 | 37 | struct mlx5_devcom_key key; | |
| 38 | 38 | mlx5_devcom_event_handler_t handler; | |
| 39 | 39 | struct kref ref; | |
| 40 | + | int nr_devs; | |
| 40 | 41 | bool ready; | |
| 41 | 42 | struct rw_semaphore sem; | |
| 42 | 43 | struct lock_class_key lock_key; | |
| @@ -170,6 +171,7 @@ devcom_alloc_comp_dev(struct mlx5_devcom_dev *devc, | |||
| 170 | 171 | ||
| 171 | 172 | down_write(&comp->sem); | |
| 172 | 173 | list_add_tail(&devcom->list, &comp->comp_dev_list_head); | |
| 174 | + | WRITE_ONCE(comp->nr_devs, comp->nr_devs + 1); | |
| 173 | 175 | up_write(&comp->sem); | |
| 174 | 176 | ||
| 175 | 177 | return devcom; | |
| @@ -182,6 +184,7 @@ devcom_free_comp_dev(struct mlx5_devcom_comp_dev *devcom) | |||
| 182 | 184 | ||
| 183 | 185 | down_write(&comp->sem); | |
| 184 | 186 | list_del(&devcom->list); | |
| 187 | + | WRITE_ONCE(comp->nr_devs, comp->nr_devs - 1); | |
| 185 | 188 | up_write(&comp->sem); | |
| 186 | 189 | ||
| 187 | 190 | kref_put(&devcom->devc->ref, mlx5_devcom_dev_release); | |
| @@ -284,7 +287,7 @@ int mlx5_devcom_comp_get_size(struct mlx5_devcom_comp_dev *devcom) | |||
| 284 | 287 | { | |
| 285 | 288 | struct mlx5_devcom_comp *comp = devcom->comp; | |
| 286 | 289 | ||
| 287 | - | return kref_read(&comp->ref); | |
| 290 | + | return READ_ONCE(comp->nr_devs); | |
| 288 | 291 | } | |
| 289 | 292 | ||
| 290 | 293 | int mlx5_devcom_locked_send_event(struct mlx5_devcom_comp_dev *devcom, | |
modified drivers/net/ethernet/mellanox/mlx5/core/vport.c
| @@ -93,30 +93,6 @@ int mlx5_modify_vport_admin_state(struct mlx5_core_dev *mdev, u8 opmod, | |||
| 93 | 93 | lockdep_assert_held(&mdev->priv.eswitch->state_lock); | |
| 94 | 94 | #endif | |
| 95 | 95 | ||
| 96 | - | if (MLX5_CAP_ESW(mdev, esw_vport_state_max_tx_speed) && | |
| 97 | - | opmod == MLX5_VPORT_STATE_OP_MOD_ESW_VPORT && | |
| 98 | - | vport != MLX5_VPORT_UPLINK) { | |
| 99 | - | u32 speed = 0; | |
| 100 | - | int err; | |
| 101 | - | ||
| 102 | - | err = mlx5_query_vport_max_tx_speed(mdev, opmod, vport, | |
| 103 | - | other_vport, &speed, NULL); | |
| 104 | - | if (err) { | |
| 105 | - | #ifdef CONFIG_MLX5_ESWITCH | |
| 106 | - | struct mlx5_vport *esw_vport; | |
| 107 | - | ||
| 108 | - | esw_vport = mlx5_eswitch_get_vport(mdev->priv.eswitch, | |
| 109 | - | vport); | |
| 110 | - | speed = IS_ERR(esw_vport) ? 0 : | |
| 111 | - | esw_vport->agg_max_tx_speed; | |
| 112 | - | #endif | |
| 113 | - | mlx5_core_dbg(mdev, | |
| 114 | - | "Failed to query vport %d max tx speed, err=%d, using cached %u\n", | |
| 115 | - | vport, err, speed); | |
| 116 | - | } | |
| 117 | - | MLX5_SET(modify_vport_state_in, in, max_tx_speed, speed); | |
| 118 | - | } | |
| 119 | - | ||
| 120 | 96 | MLX5_SET(modify_vport_state_in, in, opcode, | |
| 121 | 97 | MLX5_CMD_OP_MODIFY_VPORT_STATE); | |
| 122 | 98 | MLX5_SET(modify_vport_state_in, in, op_mod, opmod); | |
modified drivers/net/ethernet/mellanox/mlxsw/spectrum.h
| @@ -989,6 +989,8 @@ void mlxsw_sp_acl_ruleset_prio_get(struct mlxsw_sp_acl_ruleset *ruleset, | |||
| 989 | 989 | struct mlxsw_sp_acl_rule_info * | |
| 990 | 990 | mlxsw_sp_acl_rulei_create(struct mlxsw_sp_acl *acl, | |
| 991 | 991 | struct mlxsw_afa_block *afa_block); | |
| 992 | + | void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp, | |
| 993 | + | const struct mlxsw_sp_acl_rule_info *rulei); | |
| 992 | 994 | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 993 | 995 | struct mlxsw_sp_acl_rule_info *rulei); | |
| 994 | 996 | int mlxsw_sp_acl_rulei_commit(struct mlxsw_sp_acl_rule_info *rulei); | |
modified drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
| @@ -340,8 +340,8 @@ err_afa_block_create: | |||
| 340 | 340 | return ERR_PTR(err); | |
| 341 | 341 | } | |
| 342 | 342 | ||
| 343 | - | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 344 | - | struct mlxsw_sp_acl_rule_info *rulei) | |
| 343 | + | void mlxsw_sp_acl_rulei_free(struct mlxsw_sp *mlxsw_sp, | |
| 344 | + | const struct mlxsw_sp_acl_rule_info *rulei) | |
| 345 | 345 | { | |
| 346 | 346 | if (rulei->action_created) | |
| 347 | 347 | mlxsw_afa_block_destroy(rulei->act_block); | |
| @@ -351,6 +351,12 @@ void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |||
| 351 | 351 | if (rulei->dst_port_range_reg_valid) | |
| 352 | 352 | mlxsw_sp_port_range_reg_put(mlxsw_sp, | |
| 353 | 353 | rulei->dst_port_range_reg_index); | |
| 354 | + | } | |
| 355 | + | ||
| 356 | + | void mlxsw_sp_acl_rulei_destroy(struct mlxsw_sp *mlxsw_sp, | |
| 357 | + | struct mlxsw_sp_acl_rule_info *rulei) | |
| 358 | + | { | |
| 359 | + | mlxsw_sp_acl_rulei_free(mlxsw_sp, rulei); | |
| 354 | 360 | kfree(rulei); | |
| 355 | 361 | } | |
| 356 | 362 | ||
modified drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
| @@ -862,14 +862,19 @@ int mlxsw_sp_flower_tmplt_create(struct mlxsw_sp *mlxsw_sp, | |||
| 862 | 862 | memset(&rulei, 0, sizeof(rulei)); | |
| 863 | 863 | err = mlxsw_sp_flower_parse(mlxsw_sp, block, &rulei, f); | |
| 864 | 864 | if (err) | |
| 865 | - | return err; | |
| 865 | + | goto out; | |
| 866 | + | ||
| 866 | 867 | ruleset = mlxsw_sp_acl_ruleset_get(mlxsw_sp, block, | |
| 867 | 868 | f->common.chain_index, | |
| 868 | 869 | MLXSW_SP_ACL_PROFILE_FLOWER, | |
| 869 | 870 | &rulei.values.elusage); | |
| 871 | + | err = PTR_ERR_OR_ZERO(ruleset); | |
| 872 | + | ||
| 873 | + | out: | |
| 874 | + | mlxsw_sp_acl_rulei_free(mlxsw_sp, &rulei); | |
| 870 | 875 | ||
| 871 | 876 | /* keep the reference to the ruleset */ | |
| 872 | - | return PTR_ERR_OR_ZERO(ruleset); | |
| 877 | + | return err; | |
| 873 | 878 | } | |
| 874 | 879 | ||
| 875 | 880 | void mlxsw_sp_flower_tmplt_destroy(struct mlxsw_sp *mlxsw_sp, | |
modified drivers/net/ethernet/meta/fbnic/fbnic_csr.h
| @@ -974,6 +974,7 @@ enum { | |||
| 974 | 974 | /* PUL User Registers */ | |
| 975 | 975 | #define FBNIC_CSR_START_PUL_USER 0x31000 /* CSR section delimiter */ | |
| 976 | 976 | #define FBNIC_PUL_OB_TLP_HDR_AW_CFG 0x3103d /* 0xc40f4 */ | |
| 977 | + | #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH_MODE CSR_BIT(20) | |
| 977 | 978 | #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH CSR_BIT(19) | |
| 978 | 979 | #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_BME CSR_BIT(18) | |
| 979 | 980 | #define FBNIC_PUL_OB_TLP_HDR_AW_CFG_RDE_ATTR CSR_GENMASK(17, 15) | |
| @@ -1215,6 +1216,10 @@ enum { | |||
| 1215 | 1216 | #define FBNIC_IPC_MBX_DESC_LEN_MASK DESC_GENMASK(63, 48) | |
| 1216 | 1217 | #define FBNIC_IPC_MBX_DESC_EOM DESC_BIT(46) | |
| 1217 | 1218 | #define FBNIC_IPC_MBX_DESC_ADDR_MASK DESC_GENMASK(45, 3) | |
| 1219 | + | /* Set with FW_CMPL when the FW completed a descriptor without successfully | |
| 1220 | + | * processing it (e.g. a mailbox DMA error); the completion has no valid data. | |
| 1221 | + | */ | |
| 1222 | + | #define FBNIC_IPC_MBX_DESC_FW_ERR DESC_BIT(2) | |
| 1218 | 1223 | #define FBNIC_IPC_MBX_DESC_FW_CMPL DESC_BIT(1) | |
| 1219 | 1224 | #define FBNIC_IPC_MBX_DESC_HOST_CMPL DESC_BIT(0) | |
| 1220 | 1225 | ||
modified drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c
| @@ -539,8 +539,8 @@ static void fbnic_dbg_fw_mbx_display(struct seq_file *s, | |||
| 539 | 539 | /* Generate header */ | |
| 540 | 540 | seq_puts(s, mbx_idx == FBNIC_IPC_MBX_RX_IDX ? "Rx\n" : "Tx\n"); | |
| 541 | 541 | ||
| 542 | - | seq_printf(s, "Rdy: %d Head: %d Tail: %d\n", | |
| 543 | - | mbx->ready, mbx->head, mbx->tail); | |
| 542 | + | seq_printf(s, "Rdy: %d Head: %d Tail: %d resp_error: %llu\n", | |
| 543 | + | mbx->ready, mbx->head, mbx->tail, mbx->resp_error); | |
| 544 | 544 | ||
| 545 | 545 | snprintf(hdr, sizeof(hdr), "%3s %-4s %s %-12s %s %-3s %-16s\n", | |
| 546 | 546 | "Idx", "Len", "E", "Addr", "F", "H", "Raw"); | |
modified drivers/net/ethernet/meta/fbnic/fbnic_ethtool.c
| @@ -313,6 +313,11 @@ fbnic_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, | |||
| 313 | 313 | kernel_ring->hds_thresh = fbn->hds_thresh; | |
| 314 | 314 | } | |
| 315 | 315 | ||
| 316 | + | static u32 fbnic_ring_size_pow2(u32 size) | |
| 317 | + | { | |
| 318 | + | return size ? roundup_pow_of_two(size) : 0; | |
| 319 | + | } | |
| 320 | + | ||
| 316 | 321 | static void fbnic_set_rings(struct fbnic_net *fbn, | |
| 317 | 322 | struct ethtool_ringparam *ring, | |
| 318 | 323 | struct kernel_ethtool_ringparam *kernel_ring) | |
| @@ -334,10 +339,10 @@ fbnic_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring, | |||
| 334 | 339 | struct fbnic_net *clone; | |
| 335 | 340 | int err; | |
| 336 | 341 | ||
| 337 | - | ring->rx_pending = roundup_pow_of_two(ring->rx_pending); | |
| 338 | - | ring->rx_mini_pending = roundup_pow_of_two(ring->rx_mini_pending); | |
| 339 | - | ring->rx_jumbo_pending = roundup_pow_of_two(ring->rx_jumbo_pending); | |
| 340 | - | ring->tx_pending = roundup_pow_of_two(ring->tx_pending); | |
| 342 | + | ring->rx_pending = fbnic_ring_size_pow2(ring->rx_pending); | |
| 343 | + | ring->rx_mini_pending = fbnic_ring_size_pow2(ring->rx_mini_pending); | |
| 344 | + | ring->rx_jumbo_pending = fbnic_ring_size_pow2(ring->rx_jumbo_pending); | |
| 345 | + | ring->tx_pending = fbnic_ring_size_pow2(ring->tx_pending); | |
| 341 | 346 | ||
| 342 | 347 | /* These are absolute minimums allowing the device and driver to operate | |
| 343 | 348 | * but not necessarily guarantee reasonable performance. Settings below | |
| @@ -2025,7 +2030,8 @@ static const struct ethtool_ops fbnic_ethtool_ops = { | |||
| 2025 | 2030 | ETHTOOL_OP_NEEDS_RTNL_SPAUSEPARAM | | |
| 2026 | 2031 | ETHTOOL_OP_NEEDS_RTNL_SCHANNELS | | |
| 2027 | 2032 | ETHTOOL_OP_NEEDS_RTNL_SRINGPARAM | | |
| 2028 | - | ETHTOOL_OP_NEEDS_RTNL_GLINK, | |
| 2033 | + | ETHTOOL_OP_NEEDS_RTNL_GLINK | | |
| 2034 | + | ETHTOOL_OP_NEEDS_RTNL_TEST, | |
| 2029 | 2035 | .get_drvinfo = fbnic_get_drvinfo, | |
| 2030 | 2036 | .get_regs_len = fbnic_get_regs_len, | |
| 2031 | 2037 | .get_regs = fbnic_get_regs, | |
modified drivers/net/ethernet/meta/fbnic/fbnic_fw.c
| @@ -60,8 +60,15 @@ static void fbnic_mbx_reset_desc_ring(struct fbnic_dev *fbd, int mbx_idx) | |||
| 60 | 60 | */ | |
| 61 | 61 | switch (mbx_idx) { | |
| 62 | 62 | case FBNIC_IPC_MBX_RX_IDX: | |
| 63 | + | /* Clearing BME blocks the device from writing to the host | |
| 64 | + | * but leaves the requests parked in the write pipeline. The | |
| 65 | + | * write path only clears outstanding requests when both FLUSH | |
| 66 | + | * and FLUSH_MODE are set; FLUSH_MODE lets them drain without | |
| 67 | + | * landing on the host. | |
| 68 | + | */ | |
| 63 | 69 | wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AW_CFG, | |
| 64 | - | FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH); | |
| 70 | + | FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH | | |
| 71 | + | FBNIC_PUL_OB_TLP_HDR_AW_CFG_FLUSH_MODE); | |
| 65 | 72 | break; | |
| 66 | 73 | case FBNIC_IPC_MBX_TX_IDX: | |
| 67 | 74 | wr32(fbd, FBNIC_PUL_OB_TLP_HDR_AR_CFG, | |
| @@ -285,6 +292,12 @@ static void fbnic_mbx_process_tx_msgs(struct fbnic_dev *fbd) | |||
| 285 | 292 | if (!(desc & FBNIC_IPC_MBX_DESC_FW_CMPL)) | |
| 286 | 293 | break; | |
| 287 | 294 | ||
| 295 | + | if (desc & FBNIC_IPC_MBX_DESC_FW_ERR) { | |
| 296 | + | tx_mbx->resp_error++; | |
| 297 | + | dev_warn_ratelimited(fbd->dev, | |
| 298 | + | "FW completed a Tx mailbox request with an error\n"); | |
| 299 | + | } | |
| 300 | + | ||
| 288 | 301 | fbnic_mbx_unmap_and_free_msg(fbd, FBNIC_IPC_MBX_TX_IDX, head); | |
| 289 | 302 | ||
| 290 | 303 | head++; | |
| @@ -1666,6 +1679,13 @@ static void fbnic_mbx_process_rx_msgs(struct fbnic_dev *fbd) | |||
| 1666 | 1679 | if (!(desc & FBNIC_IPC_MBX_DESC_FW_CMPL)) | |
| 1667 | 1680 | break; | |
| 1668 | 1681 | ||
| 1682 | + | if (desc & FBNIC_IPC_MBX_DESC_FW_ERR) { | |
| 1683 | + | rx_mbx->resp_error++; | |
| 1684 | + | dev_warn_ratelimited(fbd->dev, | |
| 1685 | + | "FW reported an error on an Rx mailbox message; dropping\n"); | |
| 1686 | + | goto next_page; | |
| 1687 | + | } | |
| 1688 | + | ||
| 1669 | 1689 | dma_sync_single_for_cpu(fbd->dev, rx_mbx->buf_info[head].addr, | |
| 1670 | 1690 | FBNIC_RX_PAGE_SIZE, DMA_FROM_DEVICE); | |
| 1671 | 1691 | ||
| @@ -1733,7 +1753,9 @@ void fbnic_mbx_poll(struct fbnic_dev *fbd) | |||
| 1733 | 1753 | int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd) | |
| 1734 | 1754 | { | |
| 1735 | 1755 | struct fbnic_fw_mbx *tx_mbx = &fbd->mbx[FBNIC_IPC_MBX_TX_IDX]; | |
| 1756 | + | struct fbnic_fw_mbx *rx_mbx = &fbd->mbx[FBNIC_IPC_MBX_RX_IDX]; | |
| 1736 | 1757 | unsigned long timeout = jiffies + 10 * HZ + 1; | |
| 1758 | + | u64 tx_resp_error, rx_resp_error; | |
| 1737 | 1759 | int err, i; | |
| 1738 | 1760 | ||
| 1739 | 1761 | do { | |
| @@ -1764,6 +1786,9 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd) | |||
| 1764 | 1786 | * mgmt.version once we get the actual version from the firmware | |
| 1765 | 1787 | * in the capabilities request message. | |
| 1766 | 1788 | */ | |
| 1789 | + | send_cap_req: | |
| 1790 | + | tx_resp_error = tx_mbx->resp_error; | |
| 1791 | + | rx_resp_error = rx_mbx->resp_error; | |
| 1767 | 1792 | err = fbnic_fw_xmit_simple_msg(fbd, FBNIC_TLV_MSG_ID_HOST_CAP_REQ); | |
| 1768 | 1793 | if (err) | |
| 1769 | 1794 | goto clean_mbx; | |
| @@ -1781,9 +1806,27 @@ int fbnic_mbx_poll_tx_ready(struct fbnic_dev *fbd) | |||
| 1781 | 1806 | msleep(20); | |
| 1782 | 1807 | fbnic_mbx_poll(fbd); | |
| 1783 | 1808 | ||
| 1809 | + | /* A valid capabilities response ends the poll. Check it | |
| 1810 | + | * before the FW_ERR retry below so a response parsed in the | |
| 1811 | + | * same poll as an unrelated FW_ERR is not discarded. | |
| 1812 | + | */ | |
| 1813 | + | if (fbd->fw_cap.running.mgmt.version >= MIN_FW_VER_CODE) | |
| 1814 | + | break; | |
| 1815 | + | ||
| 1784 | 1816 | /* set err, but wait till mgmt.version check to report it */ | |
| 1785 | - | if (!time_is_after_jiffies(timeout)) | |
| 1817 | + | if (!time_is_after_jiffies(timeout)) { | |
| 1786 | 1818 | err = -ETIMEDOUT; | |
| 1819 | + | continue; | |
| 1820 | + | } | |
| 1821 | + | ||
| 1822 | + | /* The FW can flag our capabilities request (Tx) or its | |
| 1823 | + | * response (Rx) with FW_ERR, in which case it produced no | |
| 1824 | + | * usable response. The ring is not wedged, so re-issue the | |
| 1825 | + | * request instead of spinning until the timeout. | |
| 1826 | + | */ | |
| 1827 | + | if (tx_mbx->resp_error != tx_resp_error || | |
| 1828 | + | rx_mbx->resp_error != rx_resp_error) | |
| 1829 | + | goto send_cap_req; | |
| 1787 | 1830 | } | |
| 1788 | 1831 | ||
| 1789 | 1832 | return 0; | |
modified drivers/net/ethernet/meta/fbnic/fbnic_fw.h
| @@ -13,6 +13,7 @@ struct fbnic_tlv_msg; | |||
| 13 | 13 | ||
| 14 | 14 | struct fbnic_fw_mbx { | |
| 15 | 15 | u8 ready, head, tail; | |
| 16 | + | u64 resp_error; | |
| 16 | 17 | struct { | |
| 17 | 18 | struct fbnic_tlv_msg *msg; | |
| 18 | 19 | dma_addr_t addr; | |
modified drivers/net/ethernet/meta/fbnic/fbnic_pci.c
| @@ -434,6 +434,7 @@ static int fbnic_pm_suspend(struct device *dev) | |||
| 434 | 434 | { | |
| 435 | 435 | struct fbnic_dev *fbd = dev_get_drvdata(dev); | |
| 436 | 436 | struct net_device *netdev = fbd->netdev; | |
| 437 | + | struct fbnic_net *fbn; | |
| 437 | 438 | ||
| 438 | 439 | if (fbnic_init_failure(fbd)) | |
| 439 | 440 | goto null_uc_addr; | |
| @@ -441,11 +442,16 @@ static int fbnic_pm_suspend(struct device *dev) | |||
| 441 | 442 | rtnl_lock(); | |
| 442 | 443 | netdev_lock(netdev); | |
| 443 | 444 | ||
| 445 | + | fbn = netdev_priv(netdev); | |
| 446 | + | ||
| 444 | 447 | netif_device_detach(netdev); | |
| 445 | 448 | ||
| 446 | 449 | if (netif_running(netdev)) | |
| 447 | 450 | netdev->netdev_ops->ndo_stop(netdev); | |
| 448 | 451 | ||
| 452 | + | /* The IRQs are about to be freed, so drop the napi vector count */ | |
| 453 | + | fbn->num_napi = 0; | |
| 454 | + | ||
| 449 | 455 | netdev_unlock(netdev); | |
| 450 | 456 | rtnl_unlock(); | |
| 451 | 457 | ||
| @@ -508,16 +514,20 @@ static int __fbnic_pm_resume(struct device *dev) | |||
| 508 | 514 | if (fbnic_init_failure(fbd)) | |
| 509 | 515 | return 0; | |
| 510 | 516 | ||
| 517 | + | rtnl_lock(); | |
| 518 | + | netdev_lock(netdev); | |
| 519 | + | ||
| 511 | 520 | fbn = netdev_priv(netdev); | |
| 512 | 521 | ||
| 513 | 522 | /* Reset the queues if needed */ | |
| 514 | 523 | fbnic_reset_queues(fbn, fbn->num_tx_queues, fbn->num_rx_queues); | |
| 515 | 524 | ||
| 516 | - | rtnl_lock(); | |
| 517 | - | netdev_lock(netdev); | |
| 518 | - | ||
| 519 | - | if (netif_running(netdev)) | |
| 525 | + | if (netif_running(netdev)) { | |
| 520 | 526 | err = __fbnic_open(fbn); | |
| 527 | + | /* On failure the vectors are freed, so drop the count */ | |
| 528 | + | if (err) | |
| 529 | + | fbn->num_napi = 0; | |
| 530 | + | } | |
| 521 | 531 | ||
| 522 | 532 | netdev_unlock(netdev); | |
| 523 | 533 | rtnl_unlock(); | |
modified drivers/net/ethernet/meta/fbnic/fbnic_txrx.c
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | #include <linux/iopoll.h> | |
| 8 | 8 | #include <linux/pci.h> | |
| 9 | 9 | #include <net/netdev_queues.h> | |
| 10 | + | #include <net/netdev_rx_queue.h> | |
| 10 | 11 | #include <net/page_pool/helpers.h> | |
| 11 | 12 | #include <net/tcp.h> | |
| 12 | 13 | #include <net/xdp.h> | |
| @@ -311,6 +312,29 @@ fbnic_rx_csum(u64 rcd, struct sk_buff *skb, struct fbnic_ring *rcq, | |||
| 311 | 312 | } | |
| 312 | 313 | } | |
| 313 | 314 | ||
| 315 | + | static void fbnic_tx_doorbell(struct fbnic_ring *ring, __le64 *meta) | |
| 316 | + | { | |
| 317 | + | *meta |= cpu_to_le64(FBNIC_TWD_FLAG_REQ_COMPLETION); | |
| 318 | + | ring->deferred_meta = -1; | |
| 319 | + | ||
| 320 | + | /* Force DMA writes to flush before writing to tail */ | |
| 321 | + | dma_wmb(); | |
| 322 | + | ||
| 323 | + | writel(ring->tail, ring->doorbell); | |
| 324 | + | } | |
| 325 | + | ||
| 326 | + | /* Packets handed to us with xmit_more set are left in the ring without a | |
| 327 | + | * doorbell, and without a completion request, in the expectation that the | |
| 328 | + | * packet ending the burst will ring for all of them. If that packet gets | |
| 329 | + | * dropped instead we have to ring here, otherwise the descriptors sit in | |
| 330 | + | * the ring until the next transmit, which may never come. | |
| 331 | + | */ | |
| 332 | + | static void fbnic_tx_flush_doorbell(struct fbnic_ring *ring) | |
| 333 | + | { | |
| 334 | + | if (ring->deferred_meta >= 0) | |
| 335 | + | fbnic_tx_doorbell(ring, &ring->desc[ring->deferred_meta]); | |
| 336 | + | } | |
| 337 | + | ||
| 314 | 338 | static bool | |
| 315 | 339 | fbnic_tx_map(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta) | |
| 316 | 340 | { | |
| @@ -378,14 +402,10 @@ fbnic_tx_map(struct fbnic_ring *ring, struct sk_buff *skb, __le64 *meta) | |||
| 378 | 402 | /* Verify there is room for another packet */ | |
| 379 | 403 | fbnic_maybe_stop_tx(skb->dev, ring, FBNIC_MAX_SKB_DESC); | |
| 380 | 404 | ||
| 381 | - | if (fbnic_tx_sent_queue(skb, ring)) { | |
| 382 | - | *meta |= cpu_to_le64(FBNIC_TWD_FLAG_REQ_COMPLETION); | |
| 383 | - | ||
| 384 | - | /* Force DMA writes to flush before writing to tail */ | |
| 385 | - | dma_wmb(); | |
| 386 | - | ||
| 387 | - | writel(tail, ring->doorbell); | |
| 388 | - | } | |
| 405 | + | if (fbnic_tx_sent_queue(skb, ring)) | |
| 406 | + | fbnic_tx_doorbell(ring, meta); | |
| 407 | + | else | |
| 408 | + | ring->deferred_meta = meta - ring->desc; | |
| 389 | 409 | ||
| 390 | 410 | return false; | |
| 391 | 411 | dma_error: | |
| @@ -425,8 +445,10 @@ fbnic_xmit_frame_ring(struct sk_buff *skb, struct fbnic_ring *ring) | |||
| 425 | 445 | * otherwise try next time | |
| 426 | 446 | */ | |
| 427 | 447 | desc_needed = skb_shinfo(skb)->nr_frags + 10; | |
| 428 | - | if (fbnic_maybe_stop_tx(skb->dev, ring, desc_needed)) | |
| 448 | + | if (fbnic_maybe_stop_tx(skb->dev, ring, desc_needed)) { | |
| 449 | + | fbnic_tx_flush_doorbell(ring); | |
| 429 | 450 | return NETDEV_TX_BUSY; | |
| 451 | + | } | |
| 430 | 452 | ||
| 431 | 453 | *meta = cpu_to_le64(FBNIC_TWD_FLAG_DEST_MAC); | |
| 432 | 454 | ||
| @@ -447,6 +469,8 @@ fbnic_xmit_frame_ring(struct sk_buff *skb, struct fbnic_ring *ring) | |||
| 447 | 469 | err_free: | |
| 448 | 470 | dev_kfree_skb_any(skb); | |
| 449 | 471 | err_count: | |
| 472 | + | fbnic_tx_flush_doorbell(ring); | |
| 473 | + | ||
| 450 | 474 | u64_stats_update_begin(&ring->stats.syncp); | |
| 451 | 475 | ring->stats.dropped++; | |
| 452 | 476 | u64_stats_update_end(&ring->stats.syncp); | |
| @@ -1599,7 +1623,7 @@ fbnic_alloc_qt_page_pools(struct fbnic_net *fbn, struct fbnic_q_triad *qt, | |||
| 1599 | 1623 | return 0; | |
| 1600 | 1624 | ||
| 1601 | 1625 | err_destroy_sub0: | |
| 1602 | - | page_pool_destroy(pp); | |
| 1626 | + | page_pool_destroy(qt->sub0.page_pool); | |
| 1603 | 1627 | return PTR_ERR(pp); | |
| 1604 | 1628 | } | |
| 1605 | 1629 | ||
| @@ -1768,7 +1792,7 @@ int fbnic_alloc_napi_vectors(struct fbnic_net *fbn) | |||
| 1768 | 1792 | int err; | |
| 1769 | 1793 | ||
| 1770 | 1794 | /* Allocate 1 Tx queue per napi vector */ | |
| 1771 | - | if (num_napi < FBNIC_MAX_TXQS && num_napi == num_tx + num_rx) { | |
| 1795 | + | if (num_napi <= FBNIC_MAX_TXQS && num_napi == num_tx + num_rx) { | |
| 1772 | 1796 | while (num_tx) { | |
| 1773 | 1797 | err = fbnic_alloc_napi_vector(fbd, fbn, | |
| 1774 | 1798 | num_napi, v_idx, | |
| @@ -2491,6 +2515,7 @@ static void fbnic_enable_twq0(struct fbnic_ring *twq) | |||
| 2491 | 2515 | fbnic_ring_wr32(twq, FBNIC_QUEUE_TWQ0_CTL, FBNIC_QUEUE_TWQ_CTL_RESET); | |
| 2492 | 2516 | twq->tail = 0; | |
| 2493 | 2517 | twq->head = 0; | |
| 2518 | + | twq->deferred_meta = -1; | |
| 2494 | 2519 | ||
| 2495 | 2520 | /* Store descriptor ring address and size */ | |
| 2496 | 2521 | fbnic_ring_wr32(twq, FBNIC_QUEUE_TWQ0_BAL, lower_32_bits(twq->dma)); | |
| @@ -2829,6 +2854,17 @@ void fbnic_napi_depletion_check(struct net_device *netdev) | |||
| 2829 | 2854 | fbnic_wrfl(fbd); | |
| 2830 | 2855 | } | |
| 2831 | 2856 | ||
| 2857 | + | /* Returns the napi vector servicing an Rx queue, or NULL if the datapath | |
| 2858 | + | * is torn down. The association is published by fbnic_set_netif_napi() | |
| 2859 | + | * and cleared by fbnic_reset_netif_napi(), both under the instance lock. | |
| 2860 | + | */ | |
| 2861 | + | static struct fbnic_napi_vector *fbnic_rxq_nv(struct net_device *dev, int idx) | |
| 2862 | + | { | |
| 2863 | + | struct napi_struct *napi = __netif_get_rx_queue(dev, idx)->napi; | |
| 2864 | + | ||
| 2865 | + | return napi ? container_of(napi, struct fbnic_napi_vector, napi) : NULL; | |
| 2866 | + | } | |
| 2867 | + | ||
| 2832 | 2868 | static int fbnic_queue_mem_alloc(struct net_device *dev, | |
| 2833 | 2869 | struct netdev_queue_config *qcfg, | |
| 2834 | 2870 | void *qmem, int idx) | |
| @@ -2841,8 +2877,16 @@ static int fbnic_queue_mem_alloc(struct net_device *dev, | |||
| 2841 | 2877 | if (!netif_running(dev)) | |
| 2842 | 2878 | return fbnic_alloc_qt_page_pools(fbn, qt, idx); | |
| 2843 | 2879 | ||
| 2880 | + | /* A failed PCIe recovery or resume can leave the datapath torn down | |
| 2881 | + | * while netif_running() is still true. This ndo runs before | |
| 2882 | + | * netdev_rx_queue_restart() checks netif_running(), so bail out | |
| 2883 | + | * rather than touching rings and vectors that are already freed. | |
| 2884 | + | */ | |
| 2885 | + | nv = fbnic_rxq_nv(dev, idx); | |
| 2886 | + | if (!nv) | |
| 2887 | + | return -ENETDOWN; | |
| 2888 | + | ||
| 2844 | 2889 | real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl); | |
| 2845 | - | nv = fbn->napi[idx % fbn->num_napi]; | |
| 2846 | 2890 | ||
| 2847 | 2891 | fbnic_ring_init(&qt->sub0, real->sub0.doorbell, real->sub0.q_idx, | |
| 2848 | 2892 | real->sub0.flags); | |
| @@ -2893,7 +2937,7 @@ static int fbnic_queue_start(struct net_device *dev, | |||
| 2893 | 2937 | struct fbnic_q_triad *real; | |
| 2894 | 2938 | ||
| 2895 | 2939 | real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl); | |
| 2896 | - | nv = fbn->napi[idx % fbn->num_napi]; | |
| 2940 | + | nv = fbnic_rxq_nv(dev, idx); | |
| 2897 | 2941 | ||
| 2898 | 2942 | fbnic_aggregate_ring_bdq_counters(fbn, &real->sub0); | |
| 2899 | 2943 | fbnic_aggregate_ring_bdq_counters(fbn, &real->sub1); | |
| @@ -2915,7 +2959,7 @@ static int fbnic_queue_stop(struct net_device *dev, void *qmem, int idx) | |||
| 2915 | 2959 | int err; | |
| 2916 | 2960 | ||
| 2917 | 2961 | real = container_of(fbn->rx[idx], struct fbnic_q_triad, cmpl); | |
| 2918 | - | nv = fbn->napi[idx % fbn->num_napi]; | |
| 2962 | + | nv = fbnic_rxq_nv(dev, idx); | |
| 2919 | 2963 | fbnic_dbg_nv_exit(nv); | |
| 2920 | 2964 | ||
| 2921 | 2965 | napi_disable_locked(&nv->napi); | |
modified drivers/net/ethernet/meta/fbnic/fbnic_txrx.h
| @@ -128,9 +128,14 @@ struct fbnic_ring { | |||
| 128 | 128 | /* Rx BDQs only */ | |
| 129 | 129 | struct page_pool *page_pool; | |
| 130 | 130 | ||
| 131 | - | /* Deferred_head is used to cache the head for TWQ1 if | |
| 131 | + | /* TWQ0 only, index of the meta descriptor of the last packet | |
| 132 | + | * placed in the ring without ringing the doorbell, -1 if the | |
| 133 | + | * doorbell is in sync with the tail. | |
| 134 | + | */ | |
| 135 | + | s32 deferred_meta; | |
| 136 | + | ||
| 137 | + | /* TCQ only, used to cache the head for TWQ1 if | |
| 132 | 138 | * an attempt is made to clean TWQ1 with zero napi_budget. | |
| 133 | - | * We do not use it for any other ring. | |
| 134 | 139 | */ | |
| 135 | 140 | s32 deferred_head; | |
| 136 | 141 | }; | |
modified drivers/net/ethernet/microchip/lan743x_main.c
| @@ -2604,7 +2604,7 @@ process_extension: | |||
| 2604 | 2604 | rx->adapter->netdev); | |
| 2605 | 2605 | if (rx->adapter->netdev->features & NETIF_F_RXCSUM) { | |
| 2606 | 2606 | if (!is_ice && !is_tce && !is_icsm) | |
| 2607 | - | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
| 2607 | + | rx->skb_head->ip_summed = CHECKSUM_UNNECESSARY; | |
| 2608 | 2608 | } | |
| 2609 | 2609 | netdev_dbg(netdev, "sending %d byte frame to OS", | |
| 2610 | 2610 | rx->skb_head->len); | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_main.c
| @@ -898,6 +898,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev) | |||
| 898 | 898 | dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n"); | |
| 899 | 899 | eth_random_addr(sparx5->base_mac); | |
| 900 | 900 | sparx5->base_mac[5] = 0; | |
| 901 | + | sparx5->base_mac_assign_type = NET_ADDR_RANDOM; | |
| 901 | 902 | } | |
| 902 | 903 | ||
| 903 | 904 | sparx5->fdma_irq = platform_get_irq_byname(sparx5->pdev, "fdma"); | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_main.h
| @@ -392,6 +392,7 @@ struct sparx5 { | |||
| 392 | 392 | struct notifier_block switchdev_blocking_nb; | |
| 393 | 393 | /* Switch state */ | |
| 394 | 394 | u8 base_mac[ETH_ALEN]; | |
| 395 | + | u8 base_mac_assign_type; | |
| 395 | 396 | /* Associated bridge device (when bridged) */ | |
| 396 | 397 | struct net_device *hw_bridge_dev; | |
| 397 | 398 | /* Bridged interfaces */ | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
| @@ -294,6 +294,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno) | |||
| 294 | 294 | ndev->ethtool_ops = &sparx5_ethtool_ops; | |
| 295 | 295 | ||
| 296 | 296 | eth_hw_addr_gen(ndev, sparx5->base_mac, portno + 1); | |
| 297 | + | ndev->addr_assign_type = sparx5->base_mac_assign_type; | |
| 297 | 298 | ||
| 298 | 299 | return ndev; | |
| 299 | 300 | } | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c
| @@ -622,18 +622,9 @@ int sparx5_ptp_init(struct sparx5 *sparx5) | |||
| 622 | 622 | sparx5->ptp = 1; | |
| 623 | 623 | } | |
| 624 | 624 | ||
| 625 | - | if (!sparx5->ptp) | |
| 626 | - | return 0; | |
| 627 | - | ||
| 628 | - | for (i = 0; i < SPARX5_PHC_COUNT; ++i) { | |
| 629 | - | err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info); | |
| 630 | - | if (err) | |
| 631 | - | return err; | |
| 632 | - | } | |
| 633 | - | ||
| 634 | - | spin_lock_init(&sparx5->ptp_clock_lock); | |
| 635 | - | spin_lock_init(&sparx5->ptp_ts_id_lock); | |
| 636 | - | mutex_init(&sparx5->ptp_lock); | |
| 625 | + | /* The base, non-PTP-capable lan969x variants need the | |
| 626 | + | * first TOD counter running to forward frames. | |
| 627 | + | */ | |
| 637 | 628 | ||
| 638 | 629 | /* Disable master counters */ | |
| 639 | 630 | spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0), sparx5, PTP_PTP_DOM_CFG); | |
| @@ -657,6 +648,19 @@ int sparx5_ptp_init(struct sparx5 *sparx5) | |||
| 657 | 648 | /* Enable master counters */ | |
| 658 | 649 | spx5_wr(PTP_PTP_DOM_CFG_PTP_ENA_SET(0x7), sparx5, PTP_PTP_DOM_CFG); | |
| 659 | 650 | ||
| 651 | + | if (!sparx5->ptp) | |
| 652 | + | return 0; | |
| 653 | + | ||
| 654 | + | for (i = 0; i < SPARX5_PHC_COUNT; ++i) { | |
| 655 | + | err = sparx5_ptp_phc_init(sparx5, i, &sparx5_ptp_clock_info); | |
| 656 | + | if (err) | |
| 657 | + | return err; | |
| 658 | + | } | |
| 659 | + | ||
| 660 | + | spin_lock_init(&sparx5->ptp_clock_lock); | |
| 661 | + | spin_lock_init(&sparx5->ptp_ts_id_lock); | |
| 662 | + | mutex_init(&sparx5->ptp_lock); | |
| 663 | + | ||
| 660 | 664 | for (i = 0; i < sparx5->data->consts->n_ports; i++) { | |
| 661 | 665 | port = sparx5->ports[i]; | |
| 662 | 666 | if (!port) | |
| @@ -673,6 +677,9 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5) | |||
| 673 | 677 | struct sparx5_port *port; | |
| 674 | 678 | int i; | |
| 675 | 679 | ||
| 680 | + | if (!sparx5->ptp) | |
| 681 | + | return; | |
| 682 | + | ||
| 676 | 683 | if (sparx5->ptp_irq >= 0) { | |
| 677 | 684 | disable_irq(sparx5->ptp_irq); | |
| 678 | 685 | sparx5->ptp_irq = -ENXIO; | |
modified drivers/net/ethernet/microchip/sparx5/sparx5_tc_matchall.c
| @@ -160,6 +160,7 @@ static int sparx5_tc_matchall_destroy(struct net_device *ndev, | |||
| 160 | 160 | } | |
| 161 | 161 | ||
| 162 | 162 | list_del(&entry->list); | |
| 163 | + | kfree(entry); | |
| 163 | 164 | ||
| 164 | 165 | return err; | |
| 165 | 166 | } | |
modified drivers/net/ethernet/microchip/vcap/vcap_api.c
| @@ -3527,8 +3527,8 @@ int vcap_filter_rule_keys(struct vcap_rule *rule, | |||
| 3527 | 3527 | if (key == keylist[idx]) { | |
| 3528 | 3528 | list_del(&ckf->ctrl.list); | |
| 3529 | 3529 | kfree(ckf); | |
| 3530 | - | idx++; | |
| 3531 | 3530 | err = 0; | |
| 3531 | + | break; | |
| 3532 | 3532 | } | |
| 3533 | 3533 | } | |
| 3534 | 3534 | } | |
modified drivers/net/ethernet/microsoft/mana/mana_bpf.c
| @@ -91,7 +91,7 @@ u32 mana_run_xdp(struct net_device *ndev, struct mana_rxq *rxq, | |||
| 91 | 91 | goto out; | |
| 92 | 92 | ||
| 93 | 93 | xdp_init_buff(xdp, PAGE_SIZE, &rxq->xdp_rxq); | |
| 94 | - | xdp_prepare_buff(xdp, buf_va, XDP_PACKET_HEADROOM, pkt_len, true); | |
| 94 | + | xdp_prepare_buff(xdp, buf_va, rxq->headroom, pkt_len, true); | |
| 95 | 95 | ||
| 96 | 96 | act = bpf_prog_run_xdp(prog, xdp); | |
| 97 | 97 | ||
| @@ -183,9 +183,9 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, | |||
| 183 | 183 | if (!old_prog && !prog) | |
| 184 | 184 | return 0; | |
| 185 | 185 | ||
| 186 | - | if (prog && ndev->mtu > MANA_XDP_MTU_MAX) { | |
| 186 | + | if (prog && ndev->mtu > MANA_XDP_MTU_MAX(ndev)) { | |
| 187 | 187 | netdev_err(ndev, "XDP: mtu:%u too large, mtu_max:%lu\n", | |
| 188 | - | ndev->mtu, MANA_XDP_MTU_MAX); | |
| 188 | + | ndev->mtu, MANA_XDP_MTU_MAX(ndev)); | |
| 189 | 189 | NL_SET_ERR_MSG_MOD(extack, "XDP: mtu too large"); | |
| 190 | 190 | ||
| 191 | 191 | return -EOPNOTSUPP; | |
| @@ -238,7 +238,7 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog, | |||
| 238 | 238 | bpf_prog_put(old_prog); | |
| 239 | 239 | ||
| 240 | 240 | if (prog) | |
| 241 | - | ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX, | |
| 241 | + | ndev->max_mtu = min_t(unsigned int, MANA_XDP_MTU_MAX(ndev), | |
| 242 | 242 | gc->adapter_mtu - ETH_HLEN); | |
| 243 | 243 | else | |
| 244 | 244 | ndev->max_mtu = gc->adapter_mtu - ETH_HLEN; | |
modified drivers/net/ethernet/microsoft/mana/mana_en.c
| @@ -758,6 +758,44 @@ static void *mana_get_rxbuf_pre(struct mana_rxq *rxq, dma_addr_t *da) | |||
| 758 | 758 | return va; | |
| 759 | 759 | } | |
| 760 | 760 | ||
| 761 | + | /* Reserve enough headroom to satisfy the skb_cow() in ip_forward() and avoid | |
| 762 | + | * reallocation: the TX path keeps the SGE DMA mappings in struct mana_skb_head | |
| 763 | + | * at skb->head, so the port advertises ndev->needed_headroom = MANA_HEADROOM. | |
| 764 | + | */ | |
| 765 | + | static u32 mana_get_rxbuf_headroom(struct mana_port_context *apc) | |
| 766 | + | { | |
| 767 | + | if (mana_xdp_get(apc)) | |
| 768 | + | return mana_xdp_headroom(apc->ndev); | |
| 769 | + | ||
| 770 | + | return LL_RESERVED_SPACE(apc->ndev); | |
| 771 | + | } | |
| 772 | + | ||
| 773 | + | static u32 mana_get_rxbuf_size(struct mana_port_context *apc, u32 mtu) | |
| 774 | + | { | |
| 775 | + | u32 len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + | |
| 776 | + | mana_get_rxbuf_headroom(apc)); | |
| 777 | + | ||
| 778 | + | return ALIGN(len, MANA_RX_FRAG_ALIGNMENT); | |
| 779 | + | } | |
| 780 | + | ||
| 781 | + | /* Returns true when one RX buffer per page is already required by XDP or by | |
| 782 | + | * the buffer size implied by the MTU, i.e. regardless of the | |
| 783 | + | * MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF private flag. | |
| 784 | + | */ | |
| 785 | + | bool mana_single_rxbuf_per_page_forced(struct mana_port_context *apc, u32 mtu) | |
| 786 | + | { | |
| 787 | + | /* For xdp make sure only one packet fits per page. */ | |
| 788 | + | if (mana_xdp_get(apc)) | |
| 789 | + | return true; | |
| 790 | + | ||
| 791 | + | /* Only use the page_pool fragment path when at least two buffers, | |
| 792 | + | * including the headroom each of them has to reserve, actually fit | |
| 793 | + | * into one page. Otherwise the fragment path degenerates into one | |
| 794 | + | * buffer per page while still paying the fragment accounting cost. | |
| 795 | + | */ | |
| 796 | + | return PAGE_SIZE / mana_get_rxbuf_size(apc, mtu) < 2; | |
| 797 | + | } | |
| 798 | + | ||
| 761 | 799 | static bool | |
| 762 | 800 | mana_use_single_rxbuf_per_page(struct mana_port_context *apc, u32 mtu) | |
| 763 | 801 | { | |
| @@ -770,32 +808,27 @@ mana_use_single_rxbuf_per_page(struct mana_port_context *apc, u32 mtu) | |||
| 770 | 808 | if (apc->priv_flags & BIT(MANA_PRIV_FLAG_USE_FULL_PAGE_RXBUF)) | |
| 771 | 809 | return true; | |
| 772 | 810 | ||
| 773 | - | /* For xdp and jumbo frames make sure only one packet fits per page. */ | |
| 774 | - | if (mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || mana_xdp_get(apc)) | |
| 775 | - | return true; | |
| 776 | - | ||
| 777 | - | return false; | |
| 811 | + | return mana_single_rxbuf_per_page_forced(apc, mtu); | |
| 778 | 812 | } | |
| 779 | 813 | ||
| 780 | - | /* Get RX buffer's data size, alloc size, XDP headroom based on MTU */ | |
| 814 | + | /* Get RX buffer's data size, alloc size, headroom and frag count based on MTU */ | |
| 781 | 815 | static void mana_get_rxbuf_cfg(struct mana_port_context *apc, | |
| 782 | 816 | int mtu, u32 *datasize, u32 *alloc_size, | |
| 783 | 817 | u32 *headroom, u32 *frag_count) | |
| 784 | 818 | { | |
| 785 | - | u32 len, buf_size; | |
| 819 | + | u32 buf_size; | |
| 786 | 820 | ||
| 787 | 821 | /* Calculate datasize first (consistent across all cases) */ | |
| 788 | 822 | *datasize = mtu + ETH_HLEN; | |
| 789 | 823 | ||
| 824 | + | *headroom = mana_get_rxbuf_headroom(apc); | |
| 825 | + | ||
| 790 | 826 | if (mana_use_single_rxbuf_per_page(apc, mtu)) { | |
| 791 | - | if (mana_xdp_get(apc)) { | |
| 792 | - | *headroom = XDP_PACKET_HEADROOM; | |
| 827 | + | if (mana_xdp_get(apc)) | |
| 793 | 828 | *alloc_size = PAGE_SIZE; | |
| 794 | - | } else { | |
| 795 | - | *headroom = 0; /* no support for XDP */ | |
| 829 | + | else | |
| 796 | 830 | *alloc_size = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + | |
| 797 | 831 | *headroom); | |
| 798 | - | } | |
| 799 | 832 | ||
| 800 | 833 | *frag_count = 1; | |
| 801 | 834 | ||
| @@ -809,11 +842,7 @@ static void mana_get_rxbuf_cfg(struct mana_port_context *apc, | |||
| 809 | 842 | } | |
| 810 | 843 | ||
| 811 | 844 | /* Standard MTU case - optimize for multiple packets per page */ | |
| 812 | - | *headroom = 0; | |
| 813 | - | ||
| 814 | - | /* Calculate base buffer size needed */ | |
| 815 | - | len = SKB_DATA_ALIGN(mtu + MANA_RXBUF_PAD + *headroom); | |
| 816 | - | buf_size = ALIGN(len, MANA_RX_FRAG_ALIGNMENT); | |
| 845 | + | buf_size = mana_get_rxbuf_size(apc, mtu); | |
| 817 | 846 | ||
| 818 | 847 | /* Calculate how many packets can fit in a page */ | |
| 819 | 848 | *frag_count = PAGE_SIZE / buf_size; | |
modified drivers/net/ethernet/microsoft/mana/mana_ethtool.c
| @@ -815,12 +815,12 @@ static int mana_set_priv_flags(struct net_device *ndev, u32 priv_flags) | |||
| 815 | 815 | if (!apc->port_is_up) | |
| 816 | 816 | return 0; | |
| 817 | 817 | ||
| 818 | - | /* If XDP is attached or MTU is jumbo, single-buffer-per-page | |
| 819 | - | * is already forced regardless of this flag. Skip the | |
| 820 | - | * expensive detach/attach cycle since nothing changes. | |
| 818 | + | /* If XDP is attached or the MTU already forces one buffer per | |
| 819 | + | * page, single-buffer-per-page is used regardless of this | |
| 820 | + | * flag. Skip the expensive detach/attach cycle since nothing | |
| 821 | + | * changes. | |
| 821 | 822 | */ | |
| 822 | - | if (ndev->mtu + MANA_RXBUF_PAD > PAGE_SIZE / 2 || | |
| 823 | - | mana_xdp_get(apc)) | |
| 823 | + | if (mana_single_rxbuf_per_page_forced(apc, ndev->mtu)) | |
| 824 | 824 | return 0; | |
| 825 | 825 | ||
| 826 | 826 | /* Block RDMA from grabbing the vport during detach/attach */ | |
modified drivers/net/ethernet/netronome/nfp/crypto/ipsec.c
| @@ -625,11 +625,12 @@ int nfp_net_ipsec_rx(struct nfp_meta_parsed *meta, struct sk_buff *skb) | |||
| 625 | 625 | ||
| 626 | 626 | xa_lock(&nn->xa_ipsec); | |
| 627 | 627 | x = xa_load(&nn->xa_ipsec, saidx); | |
| 628 | + | if (x) | |
| 629 | + | xfrm_state_hold(x); | |
| 628 | 630 | xa_unlock(&nn->xa_ipsec); | |
| 629 | 631 | if (!x) | |
| 630 | 632 | return -EINVAL; | |
| 631 | 633 | ||
| 632 | - | xfrm_state_hold(x); | |
| 633 | 634 | sp->xvec[sp->len++] = x; | |
| 634 | 635 | sp->olen++; | |
| 635 | 636 | xo = xfrm_offload(skb); | |
modified drivers/net/ethernet/realtek/r8169_main.c
| @@ -5484,6 +5484,12 @@ static int r8169_mdio_register(struct rtl8169_private *tp) | |||
| 5484 | 5484 | phy_disable_eee_mode(tp->phydev, | |
| 5485 | 5485 | ETHTOOL_LINK_MODE_2500baseT_Full_BIT); | |
| 5486 | 5486 | ||
| 5487 | + | /* Keep EEE off but the version stays EEE-capable so that link-up | |
| 5488 | + | * still clears the MAC TX-LPI bits. | |
| 5489 | + | */ | |
| 5490 | + | if (tp->mac_version == RTL_GIGA_MAC_VER_46) | |
| 5491 | + | phy_disable_eee(tp->phydev); | |
| 5492 | + | ||
| 5487 | 5493 | /* PHY will be woken up in rtl_open() */ | |
| 5488 | 5494 | phy_suspend(tp->phydev); | |
| 5489 | 5495 | ||
modified drivers/net/ethernet/sfc/efx.c
| @@ -904,6 +904,10 @@ static const struct pci_device_id efx_pci_table[] = { | |||
| 904 | 904 | .driver_data = (unsigned long)&efx_x4_nic_type}, | |
| 905 | 905 | {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x2c03), /* X4 PF (FF only) */ | |
| 906 | 906 | .driver_data = (unsigned long)&efx_x4_nic_type}, | |
| 907 | + | {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0x8c03), /* X4D PF (FF/LL) */ | |
| 908 | + | .driver_data = (unsigned long)&efx_x4_nic_type}, | |
| 909 | + | {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 0xac03), /* X4D PF (FF only) */ | |
| 910 | + | .driver_data = (unsigned long)&efx_x4_nic_type}, | |
| 907 | 911 | {0} /* end of list */ | |
| 908 | 912 | }; | |
| 909 | 913 | ||
modified drivers/net/ethernet/socionext/netsec.c
| @@ -2149,6 +2149,7 @@ pm_disable: | |||
| 2149 | 2149 | pm_runtime_put_sync(&pdev->dev); | |
| 2150 | 2150 | pm_runtime_disable(&pdev->dev); | |
| 2151 | 2151 | free_ndev: | |
| 2152 | + | of_node_put(priv->phy_np); | |
| 2152 | 2153 | free_netdev(ndev); | |
| 2153 | 2154 | dev_err(&pdev->dev, "init failed\n"); | |
| 2154 | 2155 | ||
| @@ -2166,6 +2167,7 @@ static void netsec_remove(struct platform_device *pdev) | |||
| 2166 | 2167 | netif_napi_del(&priv->napi); | |
| 2167 | 2168 | ||
| 2168 | 2169 | pm_runtime_disable(&pdev->dev); | |
| 2170 | + | of_node_put(priv->phy_np); | |
| 2169 | 2171 | free_netdev(priv->ndev); | |
| 2170 | 2172 | } | |
| 2171 | 2173 | ||
modified drivers/net/ethernet/spacemit/k1_emac.c
| @@ -803,6 +803,9 @@ err_free_skb: | |||
| 803 | 803 | while (i != head) { | |
| 804 | 804 | emac_free_tx_buf(priv, i); | |
| 805 | 805 | ||
| 806 | + | tx_desc_addr = &((struct emac_desc *)tx_ring->desc_addr)[i]; | |
| 807 | + | memset(tx_desc_addr, 0, sizeof(*tx_desc_addr)); | |
| 808 | + | ||
| 806 | 809 | if (++i == tx_ring->total_cnt) | |
| 807 | 810 | i = 0; | |
| 808 | 811 | } | |
modified drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
| @@ -1162,8 +1162,11 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable) | |||
| 1162 | 1162 | return ret; | |
| 1163 | 1163 | ||
| 1164 | 1164 | ret = clk_prepare_enable(bsp_priv->clk_phy); | |
| 1165 | - | if (ret) | |
| 1165 | + | if (ret) { | |
| 1166 | + | clk_bulk_disable_unprepare(bsp_priv->num_clks, | |
| 1167 | + | bsp_priv->clks); | |
| 1166 | 1168 | return ret; | |
| 1169 | + | } | |
| 1167 | 1170 | ||
| 1168 | 1171 | rk_configure_io_clksel(bsp_priv); | |
| 1169 | 1172 | rk_ungate_rmii_clock(bsp_priv); | |
modified drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c
| @@ -474,11 +474,11 @@ static void dwmac4_set_sarc(struct dma_desc *p, u32 sarc_type) | |||
| 474 | 474 | sarc_type)); | |
| 475 | 475 | } | |
| 476 | 476 | ||
| 477 | - | static int set_16kib_bfsize(int mtu) | |
| 477 | + | static int set_16kib_bfsize(int len) | |
| 478 | 478 | { | |
| 479 | 479 | int ret = 0; | |
| 480 | 480 | ||
| 481 | - | if (unlikely(mtu >= BUF_SIZE_8KiB)) | |
| 481 | + | if (unlikely(len > BUF_SIZE_8KiB)) | |
| 482 | 482 | ret = BUF_SIZE_16KiB; | |
| 483 | 483 | return ret; | |
| 484 | 484 | } | |
modified drivers/net/ethernet/stmicro/stmmac/hwif.h
| @@ -494,7 +494,7 @@ struct stmmac_ops { | |||
| 494 | 494 | #define stmmac_set_arp_offload(__priv, __args...) \ | |
| 495 | 495 | stmmac_do_void_callback(__priv, mac, set_arp_offload, __args) | |
| 496 | 496 | #define stmmac_fpe_map_preemption_class(__priv, __args...) \ | |
| 497 | - | stmmac_do_void_callback(__priv, mac, fpe_map_preemption_class, __args) | |
| 497 | + | stmmac_do_callback(__priv, mac, fpe_map_preemption_class, __args) | |
| 498 | 498 | ||
| 499 | 499 | /* PTP and HW Timer helpers */ | |
| 500 | 500 | struct stmmac_hwtimestamp { | |
| @@ -540,7 +540,7 @@ struct stmmac_mode_ops { | |||
| 540 | 540 | bool (*is_jumbo_frm)(unsigned int len, bool enh_desc); | |
| 541 | 541 | int (*jumbo_frm)(struct stmmac_tx_queue *tx_q, struct sk_buff *skb, | |
| 542 | 542 | int csum); | |
| 543 | - | int (*set_16kib_bfsize)(int mtu); | |
| 543 | + | int (*set_16kib_bfsize)(int len); | |
| 544 | 544 | void (*init_desc3)(struct dma_desc *p); | |
| 545 | 545 | void (*refill_desc3)(struct stmmac_rx_queue *rx_q, struct dma_desc *p); | |
| 546 | 546 | void (*clean_desc3)(struct stmmac_tx_queue *tx_q, struct dma_desc *p); | |
| @@ -633,7 +633,7 @@ struct stmmac_est_ops { | |||
| 633 | 633 | struct stmmac_vlan_ops { | |
| 634 | 634 | /* VLAN */ | |
| 635 | 635 | void (*update_vlan_hash)(struct mac_device_info *hw, u32 hash, | |
| 636 | - | u16 perfect_match, bool is_double); | |
| 636 | + | bool is_svlan); | |
| 637 | 637 | void (*enable_vlan)(struct mac_device_info *hw, u32 type); | |
| 638 | 638 | void (*rx_hw_vlan)(struct mac_device_info *hw, struct dma_desc *rx_desc, | |
| 639 | 639 | struct sk_buff *skb); | |
modified drivers/net/ethernet/stmicro/stmmac/ring_mode.c
| @@ -124,10 +124,10 @@ static void clean_desc3(struct stmmac_tx_queue *tx_q, struct dma_desc *p) | |||
| 124 | 124 | p->des3 = 0; | |
| 125 | 125 | } | |
| 126 | 126 | ||
| 127 | - | static int set_16kib_bfsize(int mtu) | |
| 127 | + | static int set_16kib_bfsize(int len) | |
| 128 | 128 | { | |
| 129 | 129 | int ret = 0; | |
| 130 | - | if (unlikely(mtu > BUF_SIZE_8KiB)) | |
| 130 | + | if (unlikely(len > BUF_SIZE_8KiB)) | |
| 131 | 131 | ret = BUF_SIZE_16KiB; | |
| 132 | 132 | return ret; | |
| 133 | 133 | } | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac.h
| @@ -344,7 +344,7 @@ struct stmmac_priv { | |||
| 344 | 344 | void __iomem *ptpaddr; | |
| 345 | 345 | void __iomem *estaddr; | |
| 346 | 346 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; | |
| 347 | - | unsigned int num_double_vlans; | |
| 347 | + | unsigned int num_svlans; | |
| 348 | 348 | int sfty_irq; | |
| 349 | 349 | struct stmmac_msi *msi; | |
| 350 | 350 | ||
modified drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
| @@ -1016,8 +1016,6 @@ static int stmmac_get_ts_info(struct net_device *dev, | |||
| 1016 | 1016 | ||
| 1017 | 1017 | if (priv->ptp_clock) | |
| 1018 | 1018 | info->phc_index = ptp_clock_index(priv->ptp_clock); | |
| 1019 | - | else | |
| 1020 | - | info->phc_index = 0; | |
| 1021 | 1019 | ||
| 1022 | 1020 | info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); | |
| 1023 | 1021 | ||
modified drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
| @@ -1536,17 +1536,17 @@ static unsigned int stmmac_rx_offset(struct stmmac_priv *priv) | |||
| 1536 | 1536 | return NET_SKB_PAD + NET_IP_ALIGN; | |
| 1537 | 1537 | } | |
| 1538 | 1538 | ||
| 1539 | - | static int stmmac_set_bfsize(int mtu) | |
| 1539 | + | static int stmmac_set_bfsize(int len) | |
| 1540 | 1540 | { | |
| 1541 | 1541 | int ret; | |
| 1542 | 1542 | ||
| 1543 | - | if (mtu >= BUF_SIZE_8KiB) | |
| 1543 | + | if (len > BUF_SIZE_8KiB) | |
| 1544 | 1544 | ret = BUF_SIZE_16KiB; | |
| 1545 | - | else if (mtu >= BUF_SIZE_4KiB) | |
| 1545 | + | else if (len > BUF_SIZE_4KiB) | |
| 1546 | 1546 | ret = BUF_SIZE_8KiB; | |
| 1547 | - | else if (mtu >= BUF_SIZE_2KiB) | |
| 1547 | + | else if (len > BUF_SIZE_2KiB) | |
| 1548 | 1548 | ret = BUF_SIZE_4KiB; | |
| 1549 | - | else if (mtu > DEFAULT_BUFSIZE) | |
| 1549 | + | else if (len > DEFAULT_BUFSIZE) | |
| 1550 | 1550 | ret = BUF_SIZE_2KiB; | |
| 1551 | 1551 | else | |
| 1552 | 1552 | ret = DEFAULT_BUFSIZE; | |
| @@ -1629,6 +1629,16 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv, | |||
| 1629 | 1629 | stmmac_clear_tx_descriptors(priv, dma_conf, queue); | |
| 1630 | 1630 | } | |
| 1631 | 1631 | ||
| 1632 | + | static bool stmmac_rx_check_buf2_cap(struct stmmac_priv *priv) | |
| 1633 | + | { | |
| 1634 | + | /* Only cores that can program an independent secondary RX buffer | |
| 1635 | + | * (used for scatter-gather overflow or split-header payload) back | |
| 1636 | + | * buffer2. Legacy cores have no set_sec_addr op, so buffer2 is | |
| 1637 | + | * never handed to the hardware there. | |
| 1638 | + | */ | |
| 1639 | + | return priv->hw->desc && priv->hw->desc->set_sec_addr; | |
| 1640 | + | } | |
| 1641 | + | ||
| 1632 | 1642 | /** | |
| 1633 | 1643 | * stmmac_init_rx_buffers - init the RX descriptor buffer. | |
| 1634 | 1644 | * @priv: driver private structure | |
| @@ -1659,16 +1669,13 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, | |||
| 1659 | 1669 | buf->page_offset = stmmac_rx_offset(priv); | |
| 1660 | 1670 | } | |
| 1661 | 1671 | ||
| 1662 | - | if (priv->sph_active && !buf->sec_page) { | |
| 1672 | + | if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) { | |
| 1663 | 1673 | buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp); | |
| 1664 | 1674 | if (!buf->sec_page) | |
| 1665 | 1675 | return -ENOMEM; | |
| 1666 | 1676 | ||
| 1667 | 1677 | buf->sec_addr = page_pool_get_dma_addr(buf->sec_page); | |
| 1668 | 1678 | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); | |
| 1669 | - | } else { | |
| 1670 | - | buf->sec_page = NULL; | |
| 1671 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); | |
| 1672 | 1679 | } | |
| 1673 | 1680 | ||
| 1674 | 1681 | buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; | |
| @@ -2256,13 +2263,8 @@ static int __alloc_dma_rx_desc_resources(struct stmmac_priv *priv, | |||
| 2256 | 2263 | pp_params.nid = dev_to_node(priv->device); | |
| 2257 | 2264 | pp_params.dev = priv->device; | |
| 2258 | 2265 | pp_params.dma_dir = xdp_prog ? DMA_BIDIRECTIONAL : DMA_FROM_DEVICE; | |
| 2259 | - | pp_params.offset = stmmac_rx_offset(priv); | |
| 2260 | - | pp_params.max_len = dma_conf->dma_buf_sz; | |
| 2261 | - | ||
| 2262 | - | if (priv->sph_active) { | |
| 2263 | - | pp_params.offset = 0; | |
| 2264 | - | pp_params.max_len += stmmac_rx_offset(priv); | |
| 2265 | - | } | |
| 2266 | + | pp_params.offset = 0; | |
| 2267 | + | pp_params.max_len = dma_conf->dma_buf_sz + stmmac_rx_offset(priv); | |
| 2266 | 2268 | ||
| 2267 | 2269 | rx_q->page_pool = page_pool_create(&pp_params); | |
| 2268 | 2270 | if (IS_ERR(rx_q->page_pool)) { | |
| @@ -4063,7 +4065,7 @@ static struct stmmac_dma_conf * | |||
| 4063 | 4065 | stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) | |
| 4064 | 4066 | { | |
| 4065 | 4067 | struct stmmac_dma_conf *dma_conf; | |
| 4066 | - | int bfsize, ret; | |
| 4068 | + | int bfsize, len, ret; | |
| 4067 | 4069 | u8 chan; | |
| 4068 | 4070 | ||
| 4069 | 4071 | dma_conf = kzalloc_obj(*dma_conf); | |
| @@ -4073,13 +4075,15 @@ stmmac_setup_dma_desc(struct stmmac_priv *priv, unsigned int mtu) | |||
| 4073 | 4075 | return ERR_PTR(-ENOMEM); | |
| 4074 | 4076 | } | |
| 4075 | 4077 | ||
| 4076 | - | /* Returns 0 or BUF_SIZE_16KiB if mtu > 8KiB and dwmac4 or ring mode */ | |
| 4077 | - | bfsize = stmmac_set_16kib_bfsize(priv, mtu); | |
| 4078 | + | len = mtu + ETH_HLEN + 2 * VLAN_HLEN + ETH_FCS_LEN; | |
| 4079 | + | ||
| 4080 | + | /* Returns 0 or BUF_SIZE_16KiB if len > 8KiB and dwmac4 or ring mode */ | |
| 4081 | + | bfsize = stmmac_set_16kib_bfsize(priv, len); | |
| 4078 | 4082 | if (bfsize < 0) | |
| 4079 | 4083 | bfsize = 0; | |
| 4080 | 4084 | ||
| 4081 | 4085 | if (bfsize < BUF_SIZE_16KiB) | |
| 4082 | - | bfsize = stmmac_set_bfsize(mtu); | |
| 4086 | + | bfsize = stmmac_set_bfsize(len); | |
| 4083 | 4087 | ||
| 4084 | 4088 | dma_conf->dma_buf_sz = bfsize; | |
| 4085 | 4089 | /* Chose the tx/rx size from the already defined one in the | |
| @@ -4513,16 +4517,16 @@ static int stmmac_tso_get_num_desc(struct stmmac_tx_queue *tx_q, | |||
| 4513 | 4517 | */ | |
| 4514 | 4518 | static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |
| 4515 | 4519 | { | |
| 4520 | + | unsigned int first_entry, entry, tx_packets, proto_hdr_len; | |
| 4516 | 4521 | struct dma_desc *desc, *first, *mss_desc = NULL; | |
| 4517 | 4522 | struct stmmac_priv *priv = netdev_priv(dev); | |
| 4518 | - | unsigned int first_entry, entry, tx_packets; | |
| 4519 | 4523 | struct stmmac_txq_stats *txq_stats; | |
| 4520 | 4524 | int i, first_tx, nfrags, ndesc; | |
| 4521 | 4525 | struct stmmac_tx_queue *tx_q; | |
| 4522 | 4526 | bool set_ic, is_last_segment; | |
| 4523 | 4527 | u32 pay_len, mss, queue; | |
| 4524 | - | u8 proto_hdr_len, hdr; | |
| 4525 | 4528 | dma_addr_t des; | |
| 4529 | + | u8 hdr; | |
| 4526 | 4530 | ||
| 4527 | 4531 | nfrags = skb_shinfo(skb)->nr_frags; | |
| 4528 | 4532 | queue = skb_get_queue_mapping(skb); | |
| @@ -4570,7 +4574,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 4570 | 4574 | } | |
| 4571 | 4575 | ||
| 4572 | 4576 | if (netif_msg_tx_queued(priv)) { | |
| 4573 | - | pr_info("%s: hdrlen %d, hdr_len %d, pay_len %d, mss %d\n", | |
| 4577 | + | pr_info("%s: hdrlen %d, hdr_len %u, pay_len %d, mss %d\n", | |
| 4574 | 4578 | __func__, hdr, proto_hdr_len, pay_len, mss); | |
| 4575 | 4579 | pr_info("\tskb->len %d, skb->data_len %d\n", skb->len, | |
| 4576 | 4580 | skb->data_len); | |
| @@ -5097,7 +5101,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) | |||
| 5097 | 5101 | break; | |
| 5098 | 5102 | } | |
| 5099 | 5103 | ||
| 5100 | - | if (priv->sph_active && !buf->sec_page) { | |
| 5104 | + | if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) { | |
| 5101 | 5105 | buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp); | |
| 5102 | 5106 | if (!buf->sec_page) | |
| 5103 | 5107 | break; | |
| @@ -5108,10 +5112,8 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) | |||
| 5108 | 5112 | buf->addr = page_pool_get_dma_addr(buf->page) + buf->page_offset; | |
| 5109 | 5113 | ||
| 5110 | 5114 | stmmac_set_desc_addr(priv, p, buf->addr); | |
| 5111 | - | if (priv->sph_active) | |
| 5112 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, true); | |
| 5113 | - | else | |
| 5114 | - | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, false); | |
| 5115 | + | stmmac_set_desc_sec_addr(priv, p, buf->sec_addr, | |
| 5116 | + | stmmac_rx_check_buf2_cap(priv)); | |
| 5115 | 5117 | stmmac_refill_desc3(priv, rx_q, p); | |
| 5116 | 5118 | ||
| 5117 | 5119 | rx_q->rx_count_frames++; | |
| @@ -5142,7 +5144,9 @@ static unsigned int stmmac_rx_buf1_len(struct stmmac_priv *priv, | |||
| 5142 | 5144 | unsigned int plen = 0, hlen = 0; | |
| 5143 | 5145 | int coe = priv->hw->rx_csum; | |
| 5144 | 5146 | ||
| 5145 | - | /* Not first descriptor, buffer is always zero */ | |
| 5147 | + | /* Not first descriptor, SPH enabled: buffer1 only carries the | |
| 5148 | + | * split header of the first descriptor, so it is zero here. | |
| 5149 | + | */ | |
| 5146 | 5150 | if (priv->sph_active && len) | |
| 5147 | 5151 | return 0; | |
| 5148 | 5152 | ||
| @@ -5153,14 +5157,16 @@ static unsigned int stmmac_rx_buf1_len(struct stmmac_priv *priv, | |||
| 5153 | 5157 | return hlen; | |
| 5154 | 5158 | } | |
| 5155 | 5159 | ||
| 5156 | - | /* First descriptor, not last descriptor and not split header */ | |
| 5160 | + | /* Not last descriptor and not split header: buffer1 is fully filled */ | |
| 5157 | 5161 | if (status & rx_not_ls) | |
| 5158 | 5162 | return priv->dma_conf.dma_buf_sz; | |
| 5159 | 5163 | ||
| 5160 | 5164 | plen = stmmac_get_rx_frame_len(priv, p, coe); | |
| 5161 | 5165 | ||
| 5162 | - | /* First descriptor and last descriptor and not split header */ | |
| 5163 | - | return min_t(unsigned int, priv->dma_conf.dma_buf_sz, plen); | |
| 5166 | + | /* Last descriptor and not split header: buffer1 holds the remaining | |
| 5167 | + | * bytes of the frame, up to dma_buf_sz | |
| 5168 | + | */ | |
| 5169 | + | return min_t(unsigned int, priv->dma_conf.dma_buf_sz, plen - len); | |
| 5164 | 5170 | } | |
| 5165 | 5171 | ||
| 5166 | 5172 | static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |
| @@ -5170,8 +5176,7 @@ static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |||
| 5170 | 5176 | int coe = priv->hw->rx_csum; | |
| 5171 | 5177 | unsigned int plen = 0; | |
| 5172 | 5178 | ||
| 5173 | - | /* Not split header, buffer is not available */ | |
| 5174 | - | if (!priv->sph_active) | |
| 5179 | + | if (!stmmac_rx_check_buf2_cap(priv)) | |
| 5175 | 5180 | return 0; | |
| 5176 | 5181 | ||
| 5177 | 5182 | /* For GMAC4, when split header is enabled, in some rare cases, the | |
| @@ -5188,14 +5193,15 @@ static unsigned int stmmac_rx_buf2_len(struct stmmac_priv *priv, | |||
| 5188 | 5193 | * Thus 'plen - len' always gives the correct length of buf2. | |
| 5189 | 5194 | */ | |
| 5190 | 5195 | ||
| 5191 | - | /* Not GMAC4 and not last descriptor */ | |
| 5192 | - | if (priv->plat->core_type != DWMAC_CORE_GMAC4 && (status & rx_not_ls)) | |
| 5196 | + | /* Not GMAC4, or non-SPH and not last descriptor */ | |
| 5197 | + | if ((priv->plat->core_type != DWMAC_CORE_GMAC4 || !priv->sph_active) && | |
| 5198 | + | (status & rx_not_ls)) | |
| 5193 | 5199 | return priv->dma_conf.dma_buf_sz; | |
| 5194 | 5200 | ||
| 5195 | 5201 | /* GMAC4 or last descriptor */ | |
| 5196 | 5202 | plen = stmmac_get_rx_frame_len(priv, p, coe); | |
| 5197 | 5203 | ||
| 5198 | - | return plen - len; | |
| 5204 | + | return plen > len ? plen - len : 0; | |
| 5199 | 5205 | } | |
| 5200 | 5206 | ||
| 5201 | 5207 | static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue, | |
| @@ -5718,6 +5724,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) | |||
| 5718 | 5724 | unsigned int desc_size; | |
| 5719 | 5725 | struct sk_buff *skb = NULL; | |
| 5720 | 5726 | struct stmmac_xdp_buff ctx; | |
| 5727 | + | bool fcs_stripped = false; | |
| 5721 | 5728 | int xdp_status = 0; | |
| 5722 | 5729 | int bufsz; | |
| 5723 | 5730 | ||
| @@ -5807,24 +5814,25 @@ read_again: | |||
| 5807 | 5814 | len += buf2_len; | |
| 5808 | 5815 | ||
| 5809 | 5816 | /* ACS is disabled; strip manually. */ | |
| 5810 | - | if (likely(!(status & rx_not_ls))) { | |
| 5811 | - | if (buf2_len) { | |
| 5812 | - | buf2_len -= ETH_FCS_LEN; | |
| 5813 | - | len -= ETH_FCS_LEN; | |
| 5814 | - | } else if (buf1_len) { | |
| 5815 | - | buf1_len -= ETH_FCS_LEN; | |
| 5816 | - | len -= ETH_FCS_LEN; | |
| 5817 | - | } | |
| 5818 | - | } | |
| 5817 | + | if (likely(!(status & rx_not_ls))) | |
| 5818 | + | len -= ETH_FCS_LEN; | |
| 5819 | 5819 | ||
| 5820 | 5820 | if (!skb) { | |
| 5821 | 5821 | unsigned int pre_len, sync_len; | |
| 5822 | 5822 | ||
| 5823 | + | /* Each frame starts here: reset the FCS handling */ | |
| 5824 | + | fcs_stripped = false; | |
| 5825 | + | ||
| 5823 | 5826 | dma_sync_single_for_cpu(priv->device, buf->addr, | |
| 5824 | 5827 | buf1_len, dma_dir); | |
| 5825 | 5828 | net_prefetch(page_address(buf->page) + | |
| 5826 | 5829 | buf->page_offset); | |
| 5827 | 5830 | ||
| 5831 | + | if (stmmac_xdp_is_enabled(priv) && !buf2_len) { | |
| 5832 | + | buf1_len -= ETH_FCS_LEN; | |
| 5833 | + | fcs_stripped = true; | |
| 5834 | + | } | |
| 5835 | + | ||
| 5828 | 5836 | xdp_init_buff(&ctx.xdp, bufsz, &rx_q->xdp_rxq); | |
| 5829 | 5837 | xdp_prepare_buff(&ctx.xdp, page_address(buf->page), | |
| 5830 | 5838 | buf->page_offset, buf1_len, true); | |
| @@ -5887,6 +5895,7 @@ read_again: | |||
| 5887 | 5895 | if (!skb) { | |
| 5888 | 5896 | page_pool_recycle_direct(rx_q->page_pool, | |
| 5889 | 5897 | buf->page); | |
| 5898 | + | buf->page = NULL; | |
| 5890 | 5899 | rx_dropped++; | |
| 5891 | 5900 | count++; | |
| 5892 | 5901 | goto drain_data; | |
| @@ -5924,6 +5933,15 @@ drain_data: | |||
| 5924 | 5933 | ||
| 5925 | 5934 | /* Got entire packet into SKB. Finish it. */ | |
| 5926 | 5935 | ||
| 5936 | + | /* Remove FCS if needed */ | |
| 5937 | + | if (!fcs_stripped && pskb_trim(skb, len)) { | |
| 5938 | + | dev_kfree_skb_any(skb); | |
| 5939 | + | skb = NULL; | |
| 5940 | + | rx_dropped++; | |
| 5941 | + | count++; | |
| 5942 | + | continue; | |
| 5943 | + | } | |
| 5944 | + | ||
| 5927 | 5945 | stmmac_get_rx_hwtstamp(priv, p, np, skb); | |
| 5928 | 5946 | ||
| 5929 | 5947 | if (priv->hw->hw_vlan_en) | |
| @@ -6208,6 +6226,13 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev, | |||
| 6208 | 6226 | if (priv->plat->bugged_jumbo && (dev->mtu > ETH_DATA_LEN)) | |
| 6209 | 6227 | features &= ~NETIF_F_CSUM_MASK; | |
| 6210 | 6228 | ||
| 6229 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) { | |
| 6230 | + | if (features & NETIF_F_HW_VLAN_CTAG_RX) | |
| 6231 | + | features |= NETIF_F_HW_VLAN_STAG_RX; | |
| 6232 | + | else | |
| 6233 | + | features &= ~NETIF_F_HW_VLAN_STAG_RX; | |
| 6234 | + | } | |
| 6235 | + | ||
| 6211 | 6236 | return features; | |
| 6212 | 6237 | } | |
| 6213 | 6238 | ||
| @@ -6832,32 +6857,21 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le) | |||
| 6832 | 6857 | return crc; | |
| 6833 | 6858 | } | |
| 6834 | 6859 | ||
| 6835 | - | static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) | |
| 6860 | + | static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_svlan) | |
| 6836 | 6861 | { | |
| 6837 | 6862 | u32 crc, hash = 0; | |
| 6838 | - | u16 pmatch = 0; | |
| 6839 | - | int count = 0; | |
| 6840 | 6863 | u16 vid = 0; | |
| 6841 | 6864 | ||
| 6842 | 6865 | for_each_set_bit(vid, priv->active_vlans, VLAN_N_VID) { | |
| 6843 | 6866 | __le16 vid_le = cpu_to_le16(vid); | |
| 6844 | 6867 | crc = bitrev32(~stmmac_vid_crc32_le(vid_le)) >> 28; | |
| 6845 | 6868 | hash |= (1 << crc); | |
| 6846 | - | count++; | |
| 6847 | - | } | |
| 6848 | - | ||
| 6849 | - | if (!priv->dma_cap.vlhash) { | |
| 6850 | - | if (count > 2) /* VID = 0 always passes filter */ | |
| 6851 | - | return -EOPNOTSUPP; | |
| 6852 | - | ||
| 6853 | - | pmatch = vid; | |
| 6854 | - | hash = 0; | |
| 6855 | 6869 | } | |
| 6856 | 6870 | ||
| 6857 | 6871 | if (!netif_running(priv->dev)) | |
| 6858 | 6872 | return 0; | |
| 6859 | 6873 | ||
| 6860 | - | return stmmac_update_vlan_hash(priv, priv->hw, hash, pmatch, is_double); | |
| 6874 | + | return stmmac_update_vlan_hash(priv, priv->hw, hash, is_svlan); | |
| 6861 | 6875 | } | |
| 6862 | 6876 | ||
| 6863 | 6877 | /* FIXME: This may need RXC to be running, but it may be called with BH | |
| @@ -6866,8 +6880,8 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double) | |||
| 6866 | 6880 | static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid) | |
| 6867 | 6881 | { | |
| 6868 | 6882 | struct stmmac_priv *priv = netdev_priv(ndev); | |
| 6869 | - | unsigned int num_double_vlans; | |
| 6870 | - | bool is_double = false; | |
| 6883 | + | unsigned int num_svlans; | |
| 6884 | + | bool is_svlan = false; | |
| 6871 | 6885 | int ret; | |
| 6872 | 6886 | ||
| 6873 | 6887 | ret = pm_runtime_resume_and_get(priv->device); | |
| @@ -6875,11 +6889,11 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid | |||
| 6875 | 6889 | return ret; | |
| 6876 | 6890 | ||
| 6877 | 6891 | if (be16_to_cpu(proto) == ETH_P_8021AD) | |
| 6878 | - | is_double = true; | |
| 6892 | + | is_svlan = true; | |
| 6879 | 6893 | ||
| 6880 | 6894 | set_bit(vid, priv->active_vlans); | |
| 6881 | - | num_double_vlans = priv->num_double_vlans + is_double; | |
| 6882 | - | ret = stmmac_vlan_update(priv, num_double_vlans); | |
| 6895 | + | num_svlans = priv->num_svlans + is_svlan; | |
| 6896 | + | ret = stmmac_vlan_update(priv, num_svlans); | |
| 6883 | 6897 | if (ret) { | |
| 6884 | 6898 | clear_bit(vid, priv->active_vlans); | |
| 6885 | 6899 | goto err_pm_put; | |
| @@ -6889,12 +6903,12 @@ static int stmmac_vlan_rx_add_vid(struct net_device *ndev, __be16 proto, u16 vid | |||
| 6889 | 6903 | ret = stmmac_add_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); | |
| 6890 | 6904 | if (ret) { | |
| 6891 | 6905 | clear_bit(vid, priv->active_vlans); | |
| 6892 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6906 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6893 | 6907 | goto err_pm_put; | |
| 6894 | 6908 | } | |
| 6895 | 6909 | } | |
| 6896 | 6910 | ||
| 6897 | - | priv->num_double_vlans = num_double_vlans; | |
| 6911 | + | priv->num_svlans = num_svlans; | |
| 6898 | 6912 | ||
| 6899 | 6913 | err_pm_put: | |
| 6900 | 6914 | pm_runtime_put(priv->device); | |
| @@ -6908,8 +6922,8 @@ err_pm_put: | |||
| 6908 | 6922 | static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vid) | |
| 6909 | 6923 | { | |
| 6910 | 6924 | struct stmmac_priv *priv = netdev_priv(ndev); | |
| 6911 | - | unsigned int num_double_vlans; | |
| 6912 | - | bool is_double = false; | |
| 6925 | + | unsigned int num_svlans; | |
| 6926 | + | bool is_svlan = false; | |
| 6913 | 6927 | int ret; | |
| 6914 | 6928 | ||
| 6915 | 6929 | ret = pm_runtime_resume_and_get(priv->device); | |
| @@ -6917,11 +6931,11 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi | |||
| 6917 | 6931 | return ret; | |
| 6918 | 6932 | ||
| 6919 | 6933 | if (be16_to_cpu(proto) == ETH_P_8021AD) | |
| 6920 | - | is_double = true; | |
| 6934 | + | is_svlan = true; | |
| 6921 | 6935 | ||
| 6922 | 6936 | clear_bit(vid, priv->active_vlans); | |
| 6923 | - | num_double_vlans = priv->num_double_vlans - is_double; | |
| 6924 | - | ret = stmmac_vlan_update(priv, num_double_vlans); | |
| 6937 | + | num_svlans = priv->num_svlans - is_svlan; | |
| 6938 | + | ret = stmmac_vlan_update(priv, num_svlans); | |
| 6925 | 6939 | if (ret) { | |
| 6926 | 6940 | set_bit(vid, priv->active_vlans); | |
| 6927 | 6941 | goto del_vlan_error; | |
| @@ -6931,12 +6945,12 @@ static int stmmac_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, u16 vi | |||
| 6931 | 6945 | ret = stmmac_del_hw_vlan_rx_fltr(priv, ndev, priv->hw, proto, vid); | |
| 6932 | 6946 | if (ret) { | |
| 6933 | 6947 | set_bit(vid, priv->active_vlans); | |
| 6934 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6948 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6935 | 6949 | goto del_vlan_error; | |
| 6936 | 6950 | } | |
| 6937 | 6951 | } | |
| 6938 | 6952 | ||
| 6939 | - | priv->num_double_vlans = num_double_vlans; | |
| 6953 | + | priv->num_svlans = num_svlans; | |
| 6940 | 6954 | ||
| 6941 | 6955 | del_vlan_error: | |
| 6942 | 6956 | pm_runtime_put(priv->device); | |
| @@ -6952,7 +6966,7 @@ static void stmmac_vlan_restore(struct stmmac_priv *priv) | |||
| 6952 | 6966 | if (priv->hw->num_vlan) | |
| 6953 | 6967 | stmmac_restore_hw_vlan_rx_fltr(priv, priv->dev, priv->hw); | |
| 6954 | 6968 | ||
| 6955 | - | stmmac_vlan_update(priv, priv->num_double_vlans); | |
| 6969 | + | stmmac_vlan_update(priv, priv->num_svlans); | |
| 6956 | 6970 | } | |
| 6957 | 6971 | ||
| 6958 | 6972 | static int stmmac_bpf(struct net_device *dev, struct netdev_bpf *bpf) | |
| @@ -7991,14 +8005,18 @@ static int __stmmac_dvr_probe(struct device *device, | |||
| 7991 | 8005 | ndev->watchdog_timeo = msecs_to_jiffies(watchdog); | |
| 7992 | 8006 | #ifdef STMMAC_VLAN_TAG_USED | |
| 7993 | 8007 | /* Both mac100 and gmac support receive VLAN tag detection */ | |
| 7994 | - | ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX; | |
| 8008 | + | ndev->features |= NETIF_F_HW_VLAN_CTAG_RX; | |
| 8009 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) | |
| 8010 | + | ndev->features |= NETIF_F_HW_VLAN_STAG_RX; | |
| 8011 | + | ||
| 7995 | 8012 | if (dwmac_is_xmac(priv->plat->core_type)) { | |
| 7996 | 8013 | ndev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; | |
| 7997 | 8014 | priv->hw->hw_vlan_en = true; | |
| 7998 | 8015 | } | |
| 7999 | 8016 | if (priv->dma_cap.vlhash) { | |
| 8000 | 8017 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | |
| 8001 | - | ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER; | |
| 8018 | + | if (priv->plat->core_type == DWMAC_CORE_XGMAC) | |
| 8019 | + | ndev->features |= NETIF_F_HW_VLAN_STAG_FILTER; | |
| 8002 | 8020 | } | |
| 8003 | 8021 | if (priv->dma_cap.vlins) | |
| 8004 | 8022 | ndev->features |= NETIF_F_HW_VLAN_CTAG_TX; | |
modified drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
| @@ -12,6 +12,7 @@ | |||
| 12 | 12 | #include <linux/ethtool.h> | |
| 13 | 13 | #include <linux/ip.h> | |
| 14 | 14 | #include <linux/udp.h> | |
| 15 | + | #include <net/dsa.h> | |
| 15 | 16 | #include <net/pkt_cls.h> | |
| 16 | 17 | #include <net/pkt_sched.h> | |
| 17 | 18 | #include <net/tcp.h> | |
| @@ -29,6 +30,7 @@ struct stmmachdr { | |||
| 29 | 30 | sizeof(struct stmmachdr)) | |
| 30 | 31 | #define STMMAC_TEST_PKT_MAGIC 0xdeadcafecafedeadULL | |
| 31 | 32 | #define STMMAC_LB_TIMEOUT msecs_to_jiffies(200) | |
| 33 | + | #define STMMAC_SFT_MAX_LPI (5 * USEC_PER_SEC) | |
| 32 | 34 | ||
| 33 | 35 | struct stmmac_packet_attrs { | |
| 34 | 36 | int vlan; | |
| @@ -237,7 +239,11 @@ struct stmmac_test_priv { | |||
| 237 | 239 | struct stmmac_packet_attrs *packet; | |
| 238 | 240 | struct packet_type pt; | |
| 239 | 241 | struct completion comp; | |
| 240 | - | int double_vlan; | |
| 242 | + | __be16 packet_type; | |
| 243 | + | int (*func)(struct sk_buff *skb, struct net_device *ndev, | |
| 244 | + | struct packet_type *pt, struct net_device *orig_ndev); | |
| 245 | + | bool capture_all; | |
| 246 | + | int svlan; | |
| 241 | 247 | int vlan_id; | |
| 242 | 248 | int ok; | |
| 243 | 249 | }; | |
| @@ -279,7 +285,7 @@ static int stmmac_test_loopback_validate(struct sk_buff *skb, | |||
| 279 | 285 | } | |
| 280 | 286 | ||
| 281 | 287 | ihdr = ip_hdr(skb); | |
| 282 | - | if (tpriv->double_vlan) | |
| 288 | + | if (tpriv->svlan) | |
| 283 | 289 | ihdr = (struct iphdr *)(skb_network_header(skb) + 4); | |
| 284 | 290 | ||
| 285 | 291 | if (tpriv->packet->tcp) { | |
| @@ -316,6 +322,52 @@ out: | |||
| 316 | 322 | return 0; | |
| 317 | 323 | } | |
| 318 | 324 | ||
| 325 | + | static int stmmac_sft_filter(struct sk_buff *skb, struct net_device *ndev, | |
| 326 | + | struct packet_type *pt, | |
| 327 | + | struct net_device *orig_ndev) | |
| 328 | + | { | |
| 329 | + | struct stmmac_test_priv *tpriv = pt->af_packet_priv; | |
| 330 | + | struct ethhdr *hdr = eth_hdr(skb); | |
| 331 | + | int ret = 0; | |
| 332 | + | ||
| 333 | + | if (hdr->h_proto == tpriv->packet_type) { | |
| 334 | + | struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC); | |
| 335 | + | ||
| 336 | + | if (nskb) | |
| 337 | + | ret = tpriv->func(nskb, ndev, pt, orig_ndev); | |
| 338 | + | } | |
| 339 | + | ||
| 340 | + | kfree_skb(skb); | |
| 341 | + | return ret; | |
| 342 | + | } | |
| 343 | + | ||
| 344 | + | static void stmmac_sft_add_pack(struct packet_type *pt) | |
| 345 | + | { | |
| 346 | + | struct stmmac_test_priv *tpriv = pt->af_packet_priv; | |
| 347 | + | ||
| 348 | + | if (netdev_uses_dsa(tpriv->pt.dev) || tpriv->capture_all) { | |
| 349 | + | tpriv->packet_type = tpriv->pt.type; | |
| 350 | + | tpriv->func = tpriv->pt.func; | |
| 351 | + | ||
| 352 | + | /* DSA conduit will report ETH_P_XDSA, so our packet handler | |
| 353 | + | * won't match. Let's register a ETH_P_ALL match and filter | |
| 354 | + | * manually in stmmac_sft_filter. This is also useful for | |
| 355 | + | * VLAN tests, to capture packets otherwise marked as | |
| 356 | + | * OTHERHOST. | |
| 357 | + | */ | |
| 358 | + | tpriv->pt.type = htons(ETH_P_ALL); | |
| 359 | + | tpriv->pt.func = stmmac_sft_filter; | |
| 360 | + | tpriv->pt.ignore_outgoing = true; | |
| 361 | + | } | |
| 362 | + | ||
| 363 | + | dev_add_pack(pt); | |
| 364 | + | } | |
| 365 | + | ||
| 366 | + | static void stmmac_sft_remove_pack(struct packet_type *pt) | |
| 367 | + | { | |
| 368 | + | dev_remove_pack(pt); | |
| 369 | + | } | |
| 370 | + | ||
| 319 | 371 | static int __stmmac_test_loopback(struct stmmac_priv *priv, | |
| 320 | 372 | struct stmmac_packet_attrs *attr) | |
| 321 | 373 | { | |
| @@ -337,7 +389,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *priv, | |||
| 337 | 389 | tpriv->packet = attr; | |
| 338 | 390 | ||
| 339 | 391 | if (!attr->dont_wait) | |
| 340 | - | dev_add_pack(&tpriv->pt); | |
| 392 | + | stmmac_sft_add_pack(&tpriv->pt); | |
| 341 | 393 | ||
| 342 | 394 | skb = stmmac_test_get_udp_skb(priv, attr); | |
| 343 | 395 | if (!skb) { | |
| @@ -360,7 +412,7 @@ static int __stmmac_test_loopback(struct stmmac_priv *priv, | |||
| 360 | 412 | ||
| 361 | 413 | cleanup: | |
| 362 | 414 | if (!attr->dont_wait) | |
| 363 | - | dev_remove_pack(&tpriv->pt); | |
| 415 | + | stmmac_sft_remove_pack(&tpriv->pt); | |
| 364 | 416 | kfree(tpriv); | |
| 365 | 417 | return ret; | |
| 366 | 418 | } | |
| @@ -414,12 +466,16 @@ static int stmmac_test_mmc(struct stmmac_priv *priv) | |||
| 414 | 466 | static int stmmac_test_eee(struct stmmac_priv *priv) | |
| 415 | 467 | { | |
| 416 | 468 | struct stmmac_extra_stats *initial, *final; | |
| 417 | - | int retries = 10; | |
| 469 | + | unsigned long timeout, max_duration; | |
| 418 | 470 | int ret; | |
| 419 | 471 | ||
| 420 | 472 | if (!priv->dma_cap.eee || !priv->eee_active) | |
| 421 | 473 | return -EOPNOTSUPP; | |
| 422 | 474 | ||
| 475 | + | /* Bail out if the configured LPI timer is too long */ | |
| 476 | + | if (priv->tx_lpi_timer > STMMAC_SFT_MAX_LPI) | |
| 477 | + | return -EOPNOTSUPP; | |
| 478 | + | ||
| 423 | 479 | initial = kzalloc_obj(*initial); | |
| 424 | 480 | if (!initial) | |
| 425 | 481 | return -ENOMEM; | |
| @@ -430,14 +486,21 @@ static int stmmac_test_eee(struct stmmac_priv *priv) | |||
| 430 | 486 | goto out_free_initial; | |
| 431 | 487 | } | |
| 432 | 488 | ||
| 489 | + | /* Snapshot stats, we want to count the in_lpi events. We may enter | |
| 490 | + | * LPI just after the packet was sent. | |
| 491 | + | */ | |
| 433 | 492 | memcpy(initial, &priv->xstats, sizeof(*initial)); | |
| 434 | 493 | ||
| 494 | + | /* Send a frame, then wait to enter LPI */ | |
This diff is too large to show in full - only the first part is shown.